"use strict"; /// var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var snip; (function (snip) { var bupan; (function (bupan) { var util; (function (util) { class Gemini { constructor() { this.data = { "contents": [{ "parts": [] }], "generationConfig": { "responseMimeType": "application/json", "responseSchema": { "type": "object", "properties": {}, "required": [] } } }; } addText(text) { this.data.contents[0].parts.push({ text: text }); } addImage(img) { const canvas = document.createElement('canvas'); const ctx = canvas.getContext('2d'); ctx.drawImage(img, 0, 0); let base64 = canvas.toDataURL('image/png').split("base64,")[1]; let data = { inlineData: { mimeType: "image/png", data: base64 } }; this.data.contents[0].parts.push(data); } addResponse(name, desc, require, type = "string") { this.data.generationConfig.responseSchema.properties[name] = { type: type, description: desc }; if (require) { this.data.generationConfig.responseSchema.required.push(name); } } send() { return __awaiter(this, void 0, void 0, function* () { let res = yield snip.core.post("https://bupan.nora-neko.online/api/gemini/ex", { data: this.data }); return JSON.parse(res.parts[0].text); }); } } util.Gemini = Gemini; })(util = bupan.util || (bupan.util = {})); })(bupan = snip.bupan || (snip.bupan = {})); })(snip || (snip = {})); (function (snip) { var db; (function (db) { let t = db.aloewks_bupandb.def.t_research_coin("t"); let dao = new db.Dao("aloewks_bupandb"); function guessPrice(watch_id) { return __awaiter(this, void 0, void 0, function* () { let rcoins = yield dao.query({ "watch_id": watch_id }, function () { let sql = db.select([t.sold_date, t.price]) + db.from(t) + db.where().eq(t.watch_id, db.BIND).eq(t.market_type, db.qt("sales")).notEq(t.sold_date, null) + db.orderBy().desc(t.sold_date); return sql; }); if (rcoins.length > 1) { let text = "次のデータは同一のスラブコイン(銀貨)が売れたデータです。現在の販売見込価格を予想して"; for (let coin of rcoins) { text += "\n 落札日:" + coin.sold_date + " 落札価格:" + coin.price + "円"; } var gemini = new snip.bupan.util.Gemini(); gemini.addText(text); gemini.addResponse("price", "現在の販売見込価格(単位;円)", true, "number"); return yield gemini.send(); } else { return null; } }); } db.guessPrice = guessPrice; })(db = snip.db || (snip.db = {})); })(snip || (snip = {}));