deep-chat-dev 9.0.107 → 9.0.108
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/deepChat.js
CHANGED
@@ -3300,29 +3300,29 @@ function co(_x10, _x11) {
|
|
3300
3300
|
return _co.apply(this, arguments);
|
3301
3301
|
}
|
3302
3302
|
function _co() {
|
3303
|
-
_co = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
3303
|
+
_co = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee104(s, e) {
|
3304
3304
|
var t, i;
|
3305
|
-
return _regeneratorRuntime().wrap(function
|
3306
|
-
while (1) switch (
|
3305
|
+
return _regeneratorRuntime().wrap(function _callee104$(_context104) {
|
3306
|
+
while (1) switch (_context104.prev = _context104.next) {
|
3307
3307
|
case 0:
|
3308
3308
|
t = s.getReader();
|
3309
3309
|
case 1:
|
3310
|
-
|
3310
|
+
_context104.next = 3;
|
3311
3311
|
return t.read();
|
3312
3312
|
case 3:
|
3313
|
-
if ((i =
|
3314
|
-
|
3313
|
+
if ((i = _context104.sent).done) {
|
3314
|
+
_context104.next = 7;
|
3315
3315
|
break;
|
3316
3316
|
}
|
3317
3317
|
e(i.value);
|
3318
3318
|
case 5:
|
3319
|
-
|
3319
|
+
_context104.next = 1;
|
3320
3320
|
break;
|
3321
3321
|
case 7:
|
3322
3322
|
case "end":
|
3323
|
-
return
|
3323
|
+
return _context104.stop();
|
3324
3324
|
}
|
3325
|
-
},
|
3325
|
+
}, _callee104);
|
3326
3326
|
}));
|
3327
3327
|
return _co.apply(this, arguments);
|
3328
3328
|
}
|
@@ -8196,7 +8196,7 @@ var Qi = /*#__PURE__*/function (_U10) {
|
|
8196
8196
|
key: "extractPollResultData",
|
8197
8197
|
value: function () {
|
8198
8198
|
var _extractPollResultData5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee79(e) {
|
8199
|
-
var r, o, t, i, c, n;
|
8199
|
+
var r, o, t, i, l, c, d, u, n;
|
8200
8200
|
return _regeneratorRuntime().wrap(function _callee79$(_context79) {
|
8201
8201
|
while (1) switch (_context79.prev = _context79.next) {
|
8202
8202
|
case 0:
|
@@ -8210,33 +8210,56 @@ var Qi = /*#__PURE__*/function (_U10) {
|
|
8210
8210
|
});
|
8211
8211
|
case 3:
|
8212
8212
|
if (!(t === "completed" && this.messages)) {
|
8213
|
-
_context79.next =
|
8213
|
+
_context79.next = 19;
|
8214
8214
|
break;
|
8215
8215
|
}
|
8216
8216
|
this.url = "".concat(ae.THREAD_PREFIX, "/").concat(e.thread_id, "/messages");
|
8217
8217
|
_context79.next = 7;
|
8218
8218
|
return O.directFetch(this, {}, "GET");
|
8219
8219
|
case 7:
|
8220
|
-
|
8221
|
-
|
8220
|
+
l = _context79.sent.data[0];
|
8221
|
+
c = l.content.find(function (p) {
|
8222
|
+
return !!p.text;
|
8222
8223
|
});
|
8224
|
+
d = l.content.filter(function (p) {
|
8225
|
+
var h;
|
8226
|
+
return (h = p.image_file) == null ? void 0 : h.file_id;
|
8227
|
+
}).map(function (p) {
|
8228
|
+
var h;
|
8229
|
+
return (h = p.image_file) == null ? void 0 : h.file_id;
|
8230
|
+
});
|
8231
|
+
if (!(d && d.length > 0)) {
|
8232
|
+
_context79.next = 16;
|
8233
|
+
break;
|
8234
|
+
}
|
8235
|
+
_context79.next = 13;
|
8236
|
+
return this.getFiles(d);
|
8237
|
+
case 13:
|
8238
|
+
_context79.t0 = _context79.sent;
|
8239
|
+
_context79.next = 17;
|
8240
|
+
break;
|
8241
|
+
case 16:
|
8242
|
+
_context79.t0 = void 0;
|
8243
|
+
case 17:
|
8244
|
+
u = _context79.t0;
|
8223
8245
|
return _context79.abrupt("return", {
|
8224
8246
|
text: ((r = c == null ? void 0 : c.text) == null ? void 0 : r.value) || "",
|
8225
|
-
_sessionId: this.sessionId
|
8247
|
+
_sessionId: this.sessionId,
|
8248
|
+
files: u
|
8226
8249
|
});
|
8227
|
-
case
|
8250
|
+
case 19:
|
8228
8251
|
n = (o = i == null ? void 0 : i.submit_tool_outputs) == null ? void 0 : o.tool_calls;
|
8229
8252
|
if (!(t === "requires_action" && n)) {
|
8230
|
-
_context79.next =
|
8253
|
+
_context79.next = 24;
|
8231
8254
|
break;
|
8232
8255
|
}
|
8233
|
-
_context79.next =
|
8256
|
+
_context79.next = 23;
|
8234
8257
|
return this.handleTools(n);
|
8235
|
-
case
|
8258
|
+
case 23:
|
8236
8259
|
return _context79.abrupt("return", _context79.sent);
|
8237
|
-
case
|
8260
|
+
case 24:
|
8238
8261
|
throw Error("Thread run status: ".concat(t));
|
8239
|
-
case
|
8262
|
+
case 25:
|
8240
8263
|
case "end":
|
8241
8264
|
return _context79.stop();
|
8242
8265
|
}
|
@@ -8246,17 +8269,60 @@ var Qi = /*#__PURE__*/function (_U10) {
|
|
8246
8269
|
return _extractPollResultData5.apply(this, arguments);
|
8247
8270
|
}
|
8248
8271
|
return extractPollResultData;
|
8272
|
+
}()
|
8273
|
+
}, {
|
8274
|
+
key: "getFiles",
|
8275
|
+
value: function () {
|
8276
|
+
var _getFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee80(e) {
|
8277
|
+
var _this35 = this;
|
8278
|
+
var t, n;
|
8279
|
+
return _regeneratorRuntime().wrap(function _callee80$(_context80) {
|
8280
|
+
while (1) switch (_context80.prev = _context80.next) {
|
8281
|
+
case 0:
|
8282
|
+
t = e.map(function (r) {
|
8283
|
+
return _this35.url = "https://api.openai.com/v1/files/".concat(r, "/content"), new Promise(function (o) {
|
8284
|
+
o(O.directFetch(_this35, void 0, "GET", !1));
|
8285
|
+
});
|
8286
|
+
});
|
8287
|
+
_context80.next = 3;
|
8288
|
+
return Promise.all(t);
|
8289
|
+
case 3:
|
8290
|
+
n = _context80.sent.map(function (r) {
|
8291
|
+
return new Promise(function (o) {
|
8292
|
+
var a = new FileReader();
|
8293
|
+
a.readAsDataURL(r), a.onload = function (l) {
|
8294
|
+
o({
|
8295
|
+
src: l.target.result,
|
8296
|
+
type: "image"
|
8297
|
+
});
|
8298
|
+
};
|
8299
|
+
});
|
8300
|
+
});
|
8301
|
+
_context80.next = 6;
|
8302
|
+
return Promise.all(n);
|
8303
|
+
case 6:
|
8304
|
+
return _context80.abrupt("return", _context80.sent);
|
8305
|
+
case 7:
|
8306
|
+
case "end":
|
8307
|
+
return _context80.stop();
|
8308
|
+
}
|
8309
|
+
}, _callee80);
|
8310
|
+
}));
|
8311
|
+
function getFiles(_x146) {
|
8312
|
+
return _getFiles.apply(this, arguments);
|
8313
|
+
}
|
8314
|
+
return getFiles;
|
8249
8315
|
}() // prettier-ignore
|
8250
8316
|
}, {
|
8251
8317
|
key: "handleTools",
|
8252
8318
|
value: function () {
|
8253
|
-
var _handleTools = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
8319
|
+
var _handleTools = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee81(e) {
|
8254
8320
|
var t, i, n;
|
8255
|
-
return _regeneratorRuntime().wrap(function
|
8256
|
-
while (1) switch (
|
8321
|
+
return _regeneratorRuntime().wrap(function _callee81$(_context81) {
|
8322
|
+
while (1) switch (_context81.prev = _context81.next) {
|
8257
8323
|
case 0:
|
8258
8324
|
if (this._functionHandler) {
|
8259
|
-
|
8325
|
+
_context81.next = 2;
|
8260
8326
|
break;
|
8261
8327
|
}
|
8262
8328
|
throw Error("Please define the `function_handler` property inside the [openAI](https://deepchat.dev/docs/directConnection/openAI#Assistant) object.");
|
@@ -8267,14 +8333,14 @@ var Qi = /*#__PURE__*/function (_U10) {
|
|
8267
8333
|
arguments: r["function"].arguments
|
8268
8334
|
};
|
8269
8335
|
});
|
8270
|
-
|
8336
|
+
_context81.next = 5;
|
8271
8337
|
return this._functionHandler(t);
|
8272
8338
|
case 5:
|
8273
|
-
i =
|
8339
|
+
i = _context81.sent;
|
8274
8340
|
if (!(!Array.isArray(i) || i.find(function (r) {
|
8275
8341
|
return typeof r != "string";
|
8276
8342
|
}) || e.length !== i.length)) {
|
8277
|
-
|
8343
|
+
_context81.next = 8;
|
8278
8344
|
break;
|
8279
8345
|
}
|
8280
8346
|
throw Error("Response must contain an array of strings for each individual function/tool_call, see https://deepchat.dev/docs/directConnection/OpenAI/#assistant-functions.");
|
@@ -8286,21 +8352,21 @@ var Qi = /*#__PURE__*/function (_U10) {
|
|
8286
8352
|
};
|
8287
8353
|
});
|
8288
8354
|
this.url = "".concat(ae.THREAD_PREFIX, "/").concat(this.sessionId, "/runs/").concat(this.run_id, "/submit_tool_outputs");
|
8289
|
-
|
8355
|
+
_context81.next = 12;
|
8290
8356
|
return O.directFetch(this, {
|
8291
8357
|
tool_outputs: n
|
8292
8358
|
}, "POST");
|
8293
8359
|
case 12:
|
8294
|
-
return
|
8360
|
+
return _context81.abrupt("return", {
|
8295
8361
|
timeoutMS: ae.POLLING_TIMEOUT_MS
|
8296
8362
|
});
|
8297
8363
|
case 13:
|
8298
8364
|
case "end":
|
8299
|
-
return
|
8365
|
+
return _context81.stop();
|
8300
8366
|
}
|
8301
|
-
},
|
8367
|
+
}, _callee81, this);
|
8302
8368
|
}));
|
8303
|
-
function handleTools(
|
8369
|
+
function handleTools(_x147) {
|
8304
8370
|
return _handleTools.apply(this, arguments);
|
8305
8371
|
}
|
8306
8372
|
return handleTools;
|
@@ -8315,7 +8381,7 @@ var ri = /*#__PURE__*/function (_U11) {
|
|
8315
8381
|
_inherits(Se, _U11);
|
8316
8382
|
var _super33 = _createSuper(Se);
|
8317
8383
|
function Se(e) {
|
8318
|
-
var
|
8384
|
+
var _this36;
|
8319
8385
|
_classCallCheck(this, Se);
|
8320
8386
|
var o;
|
8321
8387
|
var t = e.directConnection,
|
@@ -8328,19 +8394,19 @@ var ri = /*#__PURE__*/function (_U11) {
|
|
8328
8394
|
}
|
8329
8395
|
}
|
8330
8396
|
};
|
8331
|
-
|
8397
|
+
_this36 = _super33.call(this, e, O.buildKeyVerificationDetails(), O.buildHeaders, i, n), _this36.insertKeyPlaceholderText = "OpenAI API Key", _this36.getKeyLink = "https://platform.openai.com/account/api-keys", _this36.introPanelMarkUp = "\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>OpenAI DALL\xB7E</b></div>\n <p><b>Insert text</b> to generate an image.</p>\n <p><b>Upload 1</b> PNG image to generate its variation and optionally insert text to specify the change.</p>\n <p><b>Upload 2</b> PNG images where the second is a copy of the first with a transparent area where the edit should\n take place and text to specify the edit.</p>\n <p>Click <a href=\"https://platform.openai.com/docs/guides/images/introduction\">here</a> for more info.</p>", _this36.url = "", _this36.permittedErrorPrefixes = ["Incorrect", "Invalid input image"];
|
8332
8398
|
var r = (o = t == null ? void 0 : t.openAI) == null ? void 0 : o.images;
|
8333
|
-
if (
|
8399
|
+
if (_this36.camera) {
|
8334
8400
|
var a = _typeof(r) == "object" && r.size ? Number.parseInt(r.size) : 1024;
|
8335
|
-
|
8401
|
+
_this36.camera.files = {
|
8336
8402
|
dimensions: {
|
8337
8403
|
width: a,
|
8338
8404
|
height: a
|
8339
8405
|
}
|
8340
8406
|
};
|
8341
8407
|
}
|
8342
|
-
_typeof(r) == "object" && Object.assign(
|
8343
|
-
return
|
8408
|
+
_typeof(r) == "object" && Object.assign(_this36.rawBody, r), _this36.canSendMessage = Se.canFileSendMessage;
|
8409
|
+
return _this36;
|
8344
8410
|
}
|
8345
8411
|
_createClass(Se, [{
|
8346
8412
|
key: "preprocessBody",
|
@@ -8365,27 +8431,27 @@ var ri = /*#__PURE__*/function (_U11) {
|
|
8365
8431
|
}, {
|
8366
8432
|
key: "callServiceAPI",
|
8367
8433
|
value: function () {
|
8368
|
-
var _callServiceAPI19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
8434
|
+
var _callServiceAPI19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee82(e, t, i) {
|
8369
8435
|
var n, r;
|
8370
|
-
return _regeneratorRuntime().wrap(function
|
8371
|
-
while (1) switch (
|
8436
|
+
return _regeneratorRuntime().wrap(function _callee82$(_context82) {
|
8437
|
+
while (1) switch (_context82.prev = _context82.next) {
|
8372
8438
|
case 0:
|
8373
8439
|
if ((n = this.requestSettings) != null && n.headers) {
|
8374
|
-
|
8440
|
+
_context82.next = 2;
|
8375
8441
|
break;
|
8376
8442
|
}
|
8377
8443
|
throw new Error("Request settings have not been set up");
|
8378
8444
|
case 2:
|
8379
8445
|
if (!(i != null && i[0])) {
|
8380
|
-
|
8446
|
+
_context82.next = 6;
|
8381
8447
|
break;
|
8382
8448
|
}
|
8383
8449
|
this.callApiWithImage(e, t, i);
|
8384
|
-
|
8450
|
+
_context82.next = 11;
|
8385
8451
|
break;
|
8386
8452
|
case 6:
|
8387
8453
|
if (this.requestSettings) {
|
8388
|
-
|
8454
|
+
_context82.next = 8;
|
8389
8455
|
break;
|
8390
8456
|
}
|
8391
8457
|
throw new Error("Request settings have not been set up");
|
@@ -8395,11 +8461,11 @@ var ri = /*#__PURE__*/function (_U11) {
|
|
8395
8461
|
_.request(this, r, e);
|
8396
8462
|
case 11:
|
8397
8463
|
case "end":
|
8398
|
-
return
|
8464
|
+
return _context82.stop();
|
8399
8465
|
}
|
8400
|
-
},
|
8466
|
+
}, _callee82, this);
|
8401
8467
|
}));
|
8402
|
-
function callServiceAPI(
|
8468
|
+
function callServiceAPI(_x148, _x149, _x150) {
|
8403
8469
|
return _callServiceAPI19.apply(this, arguments);
|
8404
8470
|
}
|
8405
8471
|
return callServiceAPI;
|
@@ -8407,17 +8473,17 @@ var ri = /*#__PURE__*/function (_U11) {
|
|
8407
8473
|
}, {
|
8408
8474
|
key: "extractResultData",
|
8409
8475
|
value: function () {
|
8410
|
-
var _extractResultData22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
8411
|
-
return _regeneratorRuntime().wrap(function
|
8412
|
-
while (1) switch (
|
8476
|
+
var _extractResultData22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee83(e) {
|
8477
|
+
return _regeneratorRuntime().wrap(function _callee83$(_context83) {
|
8478
|
+
while (1) switch (_context83.prev = _context83.next) {
|
8413
8479
|
case 0:
|
8414
8480
|
if (!e.error) {
|
8415
|
-
|
8481
|
+
_context83.next = 2;
|
8416
8482
|
break;
|
8417
8483
|
}
|
8418
8484
|
throw e.error.message;
|
8419
8485
|
case 2:
|
8420
|
-
return
|
8486
|
+
return _context83.abrupt("return", {
|
8421
8487
|
files: e.data.map(function (i) {
|
8422
8488
|
return i.url ? {
|
8423
8489
|
src: i.url,
|
@@ -8430,11 +8496,11 @@ var ri = /*#__PURE__*/function (_U11) {
|
|
8430
8496
|
});
|
8431
8497
|
case 3:
|
8432
8498
|
case "end":
|
8433
|
-
return
|
8499
|
+
return _context83.stop();
|
8434
8500
|
}
|
8435
|
-
},
|
8501
|
+
}, _callee83);
|
8436
8502
|
}));
|
8437
|
-
function extractResultData(
|
8503
|
+
function extractResultData(_x151) {
|
8438
8504
|
return _extractResultData22.apply(this, arguments);
|
8439
8505
|
}
|
8440
8506
|
return extractResultData;
|
@@ -8471,22 +8537,22 @@ var dt = /*#__PURE__*/function (_U12) {
|
|
8471
8537
|
_inherits(dt, _U12);
|
8472
8538
|
var _super34 = _createSuper(dt);
|
8473
8539
|
function dt(e) {
|
8474
|
-
var
|
8475
|
-
var
|
8540
|
+
var _this37$maxMessages, _l$model;
|
8541
|
+
var _this37;
|
8476
8542
|
_classCallCheck(this, dt);
|
8477
8543
|
var r, o, a, l;
|
8478
8544
|
var t = JSON.parse(JSON.stringify(e.directConnection)),
|
8479
8545
|
i = t.openAI;
|
8480
|
-
|
8546
|
+
_this37 = _super34.call(this, e, O.buildKeyVerificationDetails(), O.buildHeaders, i), _this37.insertKeyPlaceholderText = "OpenAI API Key", _this37.getKeyLink = "https://platform.openai.com/account/api-keys", _this37.url = "https://api.openai.com/v1/chat/completions", _this37.permittedErrorPrefixes = ["Incorrect"], _this37._systemMessage = dt.generateSystemMessage("You are a helpful assistant.");
|
8481
8547
|
var n = (r = t.openAI) == null ? void 0 : r.chat;
|
8482
8548
|
if (_typeof(n) == "object") {
|
8483
|
-
n.system_prompt && (
|
8549
|
+
n.system_prompt && (_this37._systemMessage = dt.generateSystemMessage(n.system_prompt));
|
8484
8550
|
var _ref10 = (a = (o = e.directConnection) == null ? void 0 : o.openAI) == null ? void 0 : a.chat,
|
8485
8551
|
c = _ref10.function_handler;
|
8486
|
-
c && (
|
8552
|
+
c && (_this37._functionHandler = c), _this37.cleanConfig(n), Object.assign(_this37.rawBody, n);
|
8487
8553
|
}
|
8488
|
-
(
|
8489
|
-
return
|
8554
|
+
(_this37$maxMessages = _this37.maxMessages) !== null && _this37$maxMessages !== void 0 ? _this37$maxMessages : _this37.maxMessages = -1, (_l$model = (l = _this37.rawBody).model) !== null && _l$model !== void 0 ? _l$model : l.model = "gpt-3.5-turbo";
|
8555
|
+
return _this37;
|
8490
8556
|
}
|
8491
8557
|
_createClass(dt, [{
|
8492
8558
|
key: "cleanConfig",
|
@@ -8513,13 +8579,13 @@ var dt = /*#__PURE__*/function (_U12) {
|
|
8513
8579
|
}, {
|
8514
8580
|
key: "callServiceAPI",
|
8515
8581
|
value: function () {
|
8516
|
-
var _callServiceAPI20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
8582
|
+
var _callServiceAPI20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee84(e, t) {
|
8517
8583
|
var i, n;
|
8518
|
-
return _regeneratorRuntime().wrap(function
|
8519
|
-
while (1) switch (
|
8584
|
+
return _regeneratorRuntime().wrap(function _callee84$(_context84) {
|
8585
|
+
while (1) switch (_context84.prev = _context84.next) {
|
8520
8586
|
case 0:
|
8521
8587
|
if (this.requestSettings) {
|
8522
|
-
|
8588
|
+
_context84.next = 2;
|
8523
8589
|
break;
|
8524
8590
|
}
|
8525
8591
|
throw new Error("Request settings have not been set up");
|
@@ -8528,11 +8594,11 @@ var dt = /*#__PURE__*/function (_U12) {
|
|
8528
8594
|
n && (_typeof(n) != "object" || !n.simulation) || i.stream ? (i.stream = !0, I.request(this, i, e)) : _.request(this, i, e);
|
8529
8595
|
case 4:
|
8530
8596
|
case "end":
|
8531
|
-
return
|
8597
|
+
return _context84.stop();
|
8532
8598
|
}
|
8533
|
-
},
|
8599
|
+
}, _callee84, this);
|
8534
8600
|
}));
|
8535
|
-
function callServiceAPI(
|
8601
|
+
function callServiceAPI(_x152, _x153) {
|
8536
8602
|
return _callServiceAPI20.apply(this, arguments);
|
8537
8603
|
}
|
8538
8604
|
return callServiceAPI;
|
@@ -8540,17 +8606,17 @@ var dt = /*#__PURE__*/function (_U12) {
|
|
8540
8606
|
}, {
|
8541
8607
|
key: "extractResultData",
|
8542
8608
|
value: function () {
|
8543
|
-
var _extractResultData23 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
8544
|
-
return _regeneratorRuntime().wrap(function
|
8545
|
-
while (1) switch (
|
8609
|
+
var _extractResultData23 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee85(e, t, i) {
|
8610
|
+
return _regeneratorRuntime().wrap(function _callee85$(_context85) {
|
8611
|
+
while (1) switch (_context85.prev = _context85.next) {
|
8546
8612
|
case 0:
|
8547
8613
|
if (!e.error) {
|
8548
|
-
|
8614
|
+
_context85.next = 2;
|
8549
8615
|
break;
|
8550
8616
|
}
|
8551
8617
|
throw e.error.message;
|
8552
8618
|
case 2:
|
8553
|
-
return
|
8619
|
+
return _context85.abrupt("return", e.choices[0].delta ? {
|
8554
8620
|
text: e.choices[0].delta.content || ""
|
8555
8621
|
} : e.choices[0].message ? e.choices[0].message.tool_calls ? this.handleTools(e.choices[0].message, t, i) : {
|
8556
8622
|
text: e.choices[0].message.content
|
@@ -8559,11 +8625,11 @@ var dt = /*#__PURE__*/function (_U12) {
|
|
8559
8625
|
});
|
8560
8626
|
case 3:
|
8561
8627
|
case "end":
|
8562
|
-
return
|
8628
|
+
return _context85.stop();
|
8563
8629
|
}
|
8564
|
-
},
|
8630
|
+
}, _callee85, this);
|
8565
8631
|
}));
|
8566
|
-
function extractResultData(
|
8632
|
+
function extractResultData(_x154, _x155, _x156) {
|
8567
8633
|
return _extractResultData23.apply(this, arguments);
|
8568
8634
|
}
|
8569
8635
|
return extractResultData;
|
@@ -8571,13 +8637,13 @@ var dt = /*#__PURE__*/function (_U12) {
|
|
8571
8637
|
}, {
|
8572
8638
|
key: "handleTools",
|
8573
8639
|
value: function () {
|
8574
|
-
var _handleTools2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
8640
|
+
var _handleTools2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee86(e, t, i) {
|
8575
8641
|
var a, n, r, o, l;
|
8576
|
-
return _regeneratorRuntime().wrap(function
|
8577
|
-
while (1) switch (
|
8642
|
+
return _regeneratorRuntime().wrap(function _callee86$(_context86) {
|
8643
|
+
while (1) switch (_context86.prev = _context86.next) {
|
8578
8644
|
case 0:
|
8579
8645
|
if (!(!e.tool_calls || !t || !i || !this._functionHandler)) {
|
8580
|
-
|
8646
|
+
_context86.next = 2;
|
8581
8647
|
break;
|
8582
8648
|
}
|
8583
8649
|
throw Error("Please define the `function_handler` property inside the [openAI](https://deepchat.dev/docs/directConnection/openAI#Chat) object.");
|
@@ -8589,22 +8655,22 @@ var dt = /*#__PURE__*/function (_U12) {
|
|
8589
8655
|
arguments: l["function"].arguments
|
8590
8656
|
};
|
8591
8657
|
});
|
8592
|
-
|
8658
|
+
_context86.next = 6;
|
8593
8659
|
return (a = this._functionHandler) == null ? void 0 : a.call(this, r);
|
8594
8660
|
case 6:
|
8595
|
-
o =
|
8661
|
+
o = _context86.sent;
|
8596
8662
|
if (!o.text) {
|
8597
|
-
|
8663
|
+
_context86.next = 9;
|
8598
8664
|
break;
|
8599
8665
|
}
|
8600
|
-
return
|
8666
|
+
return _context86.abrupt("return", {
|
8601
8667
|
text: o.text
|
8602
8668
|
});
|
8603
8669
|
case 9:
|
8604
8670
|
if (!(n.messages.push(e), Array.isArray(o) && !o.find(function (l) {
|
8605
8671
|
return typeof l != "string";
|
8606
8672
|
}) || r.length === o.length)) {
|
8607
|
-
|
8673
|
+
_context86.next = 17;
|
8608
8674
|
break;
|
8609
8675
|
}
|
8610
8676
|
o.forEach(function (c, d) {
|
@@ -8617,30 +8683,30 @@ var dt = /*#__PURE__*/function (_U12) {
|
|
8617
8683
|
content: c.response
|
8618
8684
|
});
|
8619
8685
|
}), delete n.tools, delete n.tool_choice;
|
8620
|
-
|
8686
|
+
_context86.next = 13;
|
8621
8687
|
return t == null ? void 0 : t(n).then(function (c) {
|
8622
8688
|
return E.processResponseByType(c);
|
8623
8689
|
});
|
8624
8690
|
case 13:
|
8625
|
-
l =
|
8691
|
+
l = _context86.sent;
|
8626
8692
|
if (!l.error) {
|
8627
|
-
|
8693
|
+
_context86.next = 16;
|
8628
8694
|
break;
|
8629
8695
|
}
|
8630
8696
|
throw l.error.message;
|
8631
8697
|
case 16:
|
8632
|
-
return
|
8698
|
+
return _context86.abrupt("return", {
|
8633
8699
|
text: l.choices[0].message.content || ""
|
8634
8700
|
});
|
8635
8701
|
case 17:
|
8636
8702
|
throw Error("Response object must either be {response: string}[] for each individual function or {text: string} for a direct response, see https://deepchat.dev/docs/directConnection/OpenAI#FunctionHandler.");
|
8637
8703
|
case 18:
|
8638
8704
|
case "end":
|
8639
|
-
return
|
8705
|
+
return _context86.stop();
|
8640
8706
|
}
|
8641
|
-
},
|
8707
|
+
}, _callee86, this);
|
8642
8708
|
}));
|
8643
|
-
function handleTools(
|
8709
|
+
function handleTools(_x157, _x158, _x159) {
|
8644
8710
|
return _handleTools2.apply(this, arguments);
|
8645
8711
|
}
|
8646
8712
|
return handleTools;
|
@@ -8679,15 +8745,15 @@ var qo = /*#__PURE__*/function (_Yi3) {
|
|
8679
8745
|
_inherits(qo, _Yi3);
|
8680
8746
|
var _super35 = _createSuper(qo);
|
8681
8747
|
function qo(e) {
|
8682
|
-
var
|
8683
|
-
var
|
8748
|
+
var _this38$maxMessages;
|
8749
|
+
var _this38;
|
8684
8750
|
_classCallCheck(this, qo);
|
8685
8751
|
var r;
|
8686
8752
|
var t = JSON.parse(JSON.stringify(e.directConnection)),
|
8687
8753
|
i = (r = t.cohere) == null ? void 0 : r.chat,
|
8688
8754
|
n = t.cohere;
|
8689
|
-
|
8690
|
-
return
|
8755
|
+
_this38 = _super35.call(this, e, "https://api.cohere.ai/v1/chat", "Ask me anything!", i, n), _typeof(i) == "object" && Object.assign(_this38.rawBody, i), (_this38$maxMessages = _this38.maxMessages) !== null && _this38$maxMessages !== void 0 ? _this38$maxMessages : _this38.maxMessages = -1;
|
8756
|
+
return _this38;
|
8691
8757
|
}
|
8692
8758
|
_createClass(qo, [{
|
8693
8759
|
key: "preprocessBody",
|
@@ -8706,13 +8772,13 @@ var qo = /*#__PURE__*/function (_Yi3) {
|
|
8706
8772
|
}, {
|
8707
8773
|
key: "callServiceAPI",
|
8708
8774
|
value: function () {
|
8709
|
-
var _callServiceAPI21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
8775
|
+
var _callServiceAPI21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee87(e, t) {
|
8710
8776
|
var i;
|
8711
|
-
return _regeneratorRuntime().wrap(function
|
8712
|
-
while (1) switch (
|
8777
|
+
return _regeneratorRuntime().wrap(function _callee87$(_context87) {
|
8778
|
+
while (1) switch (_context87.prev = _context87.next) {
|
8713
8779
|
case 0:
|
8714
8780
|
if (this.requestSettings) {
|
8715
|
-
|
8781
|
+
_context87.next = 2;
|
8716
8782
|
break;
|
8717
8783
|
}
|
8718
8784
|
throw new Error("Request settings have not been set up");
|
@@ -8721,11 +8787,11 @@ var qo = /*#__PURE__*/function (_Yi3) {
|
|
8721
8787
|
_.request(this, i, e);
|
8722
8788
|
case 4:
|
8723
8789
|
case "end":
|
8724
|
-
return
|
8790
|
+
return _context87.stop();
|
8725
8791
|
}
|
8726
|
-
},
|
8792
|
+
}, _callee87, this);
|
8727
8793
|
}));
|
8728
|
-
function callServiceAPI(
|
8794
|
+
function callServiceAPI(_x160, _x161) {
|
8729
8795
|
return _callServiceAPI21.apply(this, arguments);
|
8730
8796
|
}
|
8731
8797
|
return callServiceAPI;
|
@@ -8733,26 +8799,26 @@ var qo = /*#__PURE__*/function (_Yi3) {
|
|
8733
8799
|
}, {
|
8734
8800
|
key: "extractResultData",
|
8735
8801
|
value: function () {
|
8736
|
-
var _extractResultData24 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
8737
|
-
return _regeneratorRuntime().wrap(function
|
8738
|
-
while (1) switch (
|
8802
|
+
var _extractResultData24 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee88(e) {
|
8803
|
+
return _regeneratorRuntime().wrap(function _callee88$(_context88) {
|
8804
|
+
while (1) switch (_context88.prev = _context88.next) {
|
8739
8805
|
case 0:
|
8740
8806
|
if (!e.message) {
|
8741
|
-
|
8807
|
+
_context88.next = 2;
|
8742
8808
|
break;
|
8743
8809
|
}
|
8744
8810
|
throw e.message;
|
8745
8811
|
case 2:
|
8746
|
-
return
|
8812
|
+
return _context88.abrupt("return", {
|
8747
8813
|
text: e.text
|
8748
8814
|
});
|
8749
8815
|
case 3:
|
8750
8816
|
case "end":
|
8751
|
-
return
|
8817
|
+
return _context88.stop();
|
8752
8818
|
}
|
8753
|
-
},
|
8819
|
+
}, _callee88);
|
8754
8820
|
}));
|
8755
|
-
function extractResultData(
|
8821
|
+
function extractResultData(_x162) {
|
8756
8822
|
return _extractResultData24.apply(this, arguments);
|
8757
8823
|
}
|
8758
8824
|
return extractResultData;
|
@@ -8940,20 +9006,20 @@ var fe = /*#__PURE__*/function () {
|
|
8940
9006
|
}, {
|
8941
9007
|
key: "addNewImageMessage",
|
8942
9008
|
value: function () {
|
8943
|
-
var _addNewImageMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
9009
|
+
var _addNewImageMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee89(e, t, i) {
|
8944
9010
|
var n, r;
|
8945
|
-
return _regeneratorRuntime().wrap(function
|
8946
|
-
while (1) switch (
|
9011
|
+
return _regeneratorRuntime().wrap(function _callee89$(_context89) {
|
9012
|
+
while (1) switch (_context89.prev = _context89.next) {
|
8947
9013
|
case 0:
|
8948
9014
|
n = fe.createImage(t, e.elementRef), r = e.createNewMessageElement("", i);
|
8949
9015
|
r.bubbleElement.appendChild(n), r.bubbleElement.classList.add("image-message"), ne.addMessage(e, r, "image", i);
|
8950
9016
|
case 2:
|
8951
9017
|
case "end":
|
8952
|
-
return
|
9018
|
+
return _context89.stop();
|
8953
9019
|
}
|
8954
|
-
},
|
9020
|
+
}, _callee89);
|
8955
9021
|
}));
|
8956
|
-
function addNewImageMessage(
|
9022
|
+
function addNewImageMessage(_x163, _x164, _x165) {
|
8957
9023
|
return _addNewImageMessage.apply(this, arguments);
|
8958
9024
|
}
|
8959
9025
|
return addNewImageMessage;
|
@@ -9006,23 +9072,23 @@ var me = /*#__PURE__*/function (_Ke) {
|
|
9006
9072
|
_inherits(me, _Ke);
|
9007
9073
|
var _super36 = _createSuper(me);
|
9008
9074
|
function me(e, t, i) {
|
9009
|
-
var
|
9075
|
+
var _this39;
|
9010
9076
|
_classCallCheck(this, me);
|
9011
9077
|
var a, l;
|
9012
|
-
|
9078
|
+
_this39 = _super36.call(this, e);
|
9013
9079
|
var n = t.permittedErrorPrefixes,
|
9014
9080
|
r = t.introPanelMarkUp,
|
9015
9081
|
o = t.demo;
|
9016
|
-
|
9017
|
-
return JSON.parse(JSON.stringify(
|
9018
|
-
}, e.clearMessages =
|
9019
|
-
|
9082
|
+
_this39._errorMessageOverrides = (a = e.errorMessages) == null ? void 0 : a.overrides, _this39._onClearMessages = jt.onClearMessages.bind(_assertThisInitialized(_this39), e), _this39._onError = jt.onError.bind(_assertThisInitialized(_this39), e), _this39._displayLoadingMessage = me.getDisplayLoadingMessage(e, t), _this39._permittedErrorPrefixes = n, _this39.addSetupMessageIfNeeded(e, t) || _this39.populateIntroPanel(i, r, e.introPanelStyle), _this39.addIntroductoryMessage(e, t), e.initialMessages && _this39.populateInitialMessages(e.initialMessages), _this39._displayServiceErrorMessages = (l = e.errorMessages) == null ? void 0 : l.displayServiceErrorMessages, e.getMessages = function () {
|
9083
|
+
return JSON.parse(JSON.stringify(_this39.messages));
|
9084
|
+
}, e.clearMessages = _this39.clearMessages.bind(_assertThisInitialized(_this39), t), e.refreshMessages = _this39.refreshTextMessages.bind(_assertThisInitialized(_this39)), e.scrollToBottom = Y.scrollToBottom.bind(_assertThisInitialized(_this39), _this39.elementRef), e._addMessage = function (c, d) {
|
9085
|
+
_this39.addNewMessage(_objectSpread(_objectSpread({}, c), {}, {
|
9020
9086
|
sendUpdate: !!d
|
9021
9087
|
}), !d);
|
9022
|
-
}, t.isWebModel() && t.setUpMessages(_assertThisInitialized(
|
9023
|
-
|
9088
|
+
}, t.isWebModel() && t.setUpMessages(_assertThisInitialized(_this39)), o && _this39.prepareDemo(o), e.textToSpeech && Nt.processConfig(e.textToSpeech, function (c) {
|
9089
|
+
_this39.textToSpeech = c;
|
9024
9090
|
});
|
9025
|
-
return
|
9091
|
+
return _this39;
|
9026
9092
|
}
|
9027
9093
|
_createClass(me, [{
|
9028
9094
|
key: "prepareDemo",
|
@@ -9061,11 +9127,11 @@ var me = /*#__PURE__*/function (_Ke) {
|
|
9061
9127
|
}, {
|
9062
9128
|
key: "populateInitialMessages",
|
9063
9129
|
value: function populateInitialMessages(e) {
|
9064
|
-
var
|
9130
|
+
var _this40 = this;
|
9065
9131
|
e.forEach(function (t) {
|
9066
|
-
ke.processInitialMessageFile(t),
|
9132
|
+
ke.processInitialMessageFile(t), _this40.addNewMessage(t, !0);
|
9067
9133
|
}), setTimeout(function () {
|
9068
|
-
return Y.scrollToBottom(
|
9134
|
+
return Y.scrollToBottom(_this40.elementRef);
|
9069
9135
|
}, 0);
|
9070
9136
|
}
|
9071
9137
|
// this should not be activated by streamed messages
|
@@ -9163,11 +9229,11 @@ var me = /*#__PURE__*/function (_Ke) {
|
|
9163
9229
|
}, {
|
9164
9230
|
key: "addMultipleFiles",
|
9165
9231
|
value: function () {
|
9166
|
-
var _addMultipleFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
9167
|
-
return _regeneratorRuntime().wrap(function
|
9168
|
-
while (1) switch (
|
9232
|
+
var _addMultipleFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee90(e) {
|
9233
|
+
return _regeneratorRuntime().wrap(function _callee90$(_context90) {
|
9234
|
+
while (1) switch (_context90.prev = _context90.next) {
|
9169
9235
|
case 0:
|
9170
|
-
return
|
9236
|
+
return _context90.abrupt("return", Promise.all((e || []).map(function (t) {
|
9171
9237
|
return new Promise(function (i) {
|
9172
9238
|
if (!t.type || t.type === "any") {
|
9173
9239
|
var n = t.file.name || ne.DEFAULT_FILE_NAME;
|
@@ -9190,11 +9256,11 @@ var me = /*#__PURE__*/function (_Ke) {
|
|
9190
9256
|
})));
|
9191
9257
|
case 1:
|
9192
9258
|
case "end":
|
9193
|
-
return
|
9259
|
+
return _context90.stop();
|
9194
9260
|
}
|
9195
|
-
},
|
9261
|
+
}, _callee90);
|
9196
9262
|
}));
|
9197
|
-
function addMultipleFiles(
|
9263
|
+
function addMultipleFiles(_x166) {
|
9198
9264
|
return _addMultipleFiles.apply(this, arguments);
|
9199
9265
|
}
|
9200
9266
|
return addMultipleFiles;
|
@@ -9516,11 +9582,11 @@ var _e = /*#__PURE__*/function () {
|
|
9516
9582
|
}();
|
9517
9583
|
var tn = /*#__PURE__*/function () {
|
9518
9584
|
function tn(e, t) {
|
9519
|
-
var
|
9585
|
+
var _this41 = this;
|
9520
9586
|
_classCallCheck(this, tn);
|
9521
9587
|
var i;
|
9522
9588
|
this._isOpen = !0, this._styles = t, this.elementRef = tn.createElement((i = this._styles) == null ? void 0 : i.container), this.close(), setTimeout(function () {
|
9523
|
-
return
|
9589
|
+
return _this41.addWindowEvents(e);
|
9524
9590
|
});
|
9525
9591
|
}
|
9526
9592
|
_createClass(tn, [{
|
@@ -9576,15 +9642,15 @@ var Je = /*#__PURE__*/function (_wt) {
|
|
9576
9642
|
_inherits(Je, _wt);
|
9577
9643
|
var _super37 = _createSuper(Je);
|
9578
9644
|
function Je(e, t) {
|
9579
|
-
var
|
9645
|
+
var _this42;
|
9580
9646
|
_classCallCheck(this, Je);
|
9581
9647
|
var n;
|
9582
|
-
|
9648
|
+
_this42 = _super37.call(this, Je.createButtonElement(), void 0, {
|
9583
9649
|
styles: (n = t == null ? void 0 : t.button) == null ? void 0 : n.styles
|
9584
9650
|
});
|
9585
|
-
var i =
|
9586
|
-
|
9587
|
-
return
|
9651
|
+
var i = _this42.createInnerElements(_this42._customStyles);
|
9652
|
+
_this42._menu = new tn(e, t == null ? void 0 : t.menu), _this42.addClickEvent(), _this42.buttonContainer = Je.createButtonContainer(), _this42.elementRef.appendChild(i.styles), _this42.buttonContainer.appendChild(_this42.elementRef), _this42.elementRef.classList.add("dropup-icon", "upload-file-button"), _this42.buttonContainer.appendChild(_this42._menu.elementRef), _this42.reapplyStateStyle("styles"), _this42.addContainerEvents(e);
|
9653
|
+
return _this42;
|
9588
9654
|
}
|
9589
9655
|
_createClass(Je, [{
|
9590
9656
|
key: "createInnerElements",
|
@@ -9611,9 +9677,9 @@ var Je = /*#__PURE__*/function (_wt) {
|
|
9611
9677
|
}, {
|
9612
9678
|
key: "addContainerEvents",
|
9613
9679
|
value: function addContainerEvents(e) {
|
9614
|
-
var
|
9680
|
+
var _this43 = this;
|
9615
9681
|
e.addEventListener("click", function (t) {
|
9616
|
-
t.target.classList.contains("dropup-icon") ||
|
9682
|
+
t.target.classList.contains("dropup-icon") || _this43._menu.close();
|
9617
9683
|
});
|
9618
9684
|
}
|
9619
9685
|
}], [{
|
@@ -9748,10 +9814,10 @@ var $o = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 24 24\"
|
|
9748
9814
|
var ue = /*#__PURE__*/function () {
|
9749
9815
|
// prettier-ignore
|
9750
9816
|
function ue(e, t, i, n) {
|
9751
|
-
var
|
9817
|
+
var _this44 = this;
|
9752
9818
|
_classCallCheck(this, ue);
|
9753
9819
|
this._attachments = [], this._fileCountLimit = 99, this._acceptedFormat = "", t.maxNumberOfFiles && (this._fileCountLimit = t.maxNumberOfFiles), this._toggleContainerDisplay = i, this._fileAttachmentsContainerRef = n, t.acceptedFormats && (this._acceptedFormat = t.acceptedFormats), setTimeout(function () {
|
9754
|
-
|
9820
|
+
_this44._validationHandler = e._validationHandler;
|
9755
9821
|
});
|
9756
9822
|
}
|
9757
9823
|
_createClass(ue, [{
|
@@ -9892,12 +9958,12 @@ var ea = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\"
|
|
9892
9958
|
_createClass(we, [{
|
9893
9959
|
key: "createTimer",
|
9894
9960
|
value: function createTimer(e, t) {
|
9895
|
-
var
|
9961
|
+
var _this45 = this;
|
9896
9962
|
var i = 0;
|
9897
9963
|
var n = t !== void 0 && t < we.TIMER_LIMIT_S ? t : we.TIMER_LIMIT_S;
|
9898
9964
|
return setInterval(function () {
|
9899
9965
|
var a;
|
9900
|
-
i += 1, i === n && ((a =
|
9966
|
+
i += 1, i === n && ((a = _this45.stopPlaceholderCallback) == null || a.call(_this45), _this45.clearTimer()), i === 600 && e.classList.add("audio-placeholder-text-4-digits");
|
9901
9967
|
var r = Math.floor(i / 60),
|
9902
9968
|
o = (i % 60).toString().padStart(2, "0");
|
9903
9969
|
e.textContent = "".concat(r, ":").concat(o);
|
@@ -9917,7 +9983,7 @@ var ea = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\"
|
|
9917
9983
|
}, {
|
9918
9984
|
key: "addPlaceholderAudioAttachmentEvents",
|
9919
9985
|
value: function addPlaceholderAudioAttachmentEvents(e, t, i) {
|
9920
|
-
var
|
9986
|
+
var _this46 = this;
|
9921
9987
|
var n = function n() {
|
9922
9988
|
return e.replaceChildren(t);
|
9923
9989
|
};
|
@@ -9928,7 +9994,7 @@ var ea = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\"
|
|
9928
9994
|
e.addEventListener("mouseleave", r);
|
9929
9995
|
var o = function o() {
|
9930
9996
|
var a;
|
9931
|
-
return (a =
|
9997
|
+
return (a = _this46.stopPlaceholderCallback) == null ? void 0 : a.call(_this46);
|
9932
9998
|
};
|
9933
9999
|
e.addEventListener("click", o);
|
9934
10000
|
}
|
@@ -10047,33 +10113,33 @@ var _t = /*#__PURE__*/function () {
|
|
10047
10113
|
}, {
|
10048
10114
|
key: "completePlaceholders",
|
10049
10115
|
value: function () {
|
10050
|
-
var _completePlaceholders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
10051
|
-
return _regeneratorRuntime().wrap(function
|
10052
|
-
while (1) switch (
|
10116
|
+
var _completePlaceholders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee92() {
|
10117
|
+
return _regeneratorRuntime().wrap(function _callee92$(_context92) {
|
10118
|
+
while (1) switch (_context92.prev = _context92.next) {
|
10053
10119
|
case 0:
|
10054
|
-
|
10120
|
+
_context92.next = 2;
|
10055
10121
|
return Promise.all(this._fileAttachmentsTypes.map( /*#__PURE__*/function () {
|
10056
|
-
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
10122
|
+
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee91(e) {
|
10057
10123
|
var t;
|
10058
|
-
return _regeneratorRuntime().wrap(function
|
10059
|
-
while (1) switch (
|
10124
|
+
return _regeneratorRuntime().wrap(function _callee91$(_context91) {
|
10125
|
+
while (1) switch (_context91.prev = _context91.next) {
|
10060
10126
|
case 0:
|
10061
|
-
return
|
10127
|
+
return _context91.abrupt("return", (t = e.stopPlaceholderCallback) == null ? void 0 : t.call(e));
|
10062
10128
|
case 1:
|
10063
10129
|
case "end":
|
10064
|
-
return
|
10130
|
+
return _context91.stop();
|
10065
10131
|
}
|
10066
|
-
},
|
10132
|
+
}, _callee91);
|
10067
10133
|
}));
|
10068
|
-
return function (
|
10134
|
+
return function (_x167) {
|
10069
10135
|
return _ref11.apply(this, arguments);
|
10070
10136
|
};
|
10071
10137
|
}()));
|
10072
10138
|
case 2:
|
10073
10139
|
case "end":
|
10074
|
-
return
|
10140
|
+
return _context92.stop();
|
10075
10141
|
}
|
10076
|
-
},
|
10142
|
+
}, _callee92, this);
|
10077
10143
|
}));
|
10078
10144
|
function completePlaceholders() {
|
10079
10145
|
return _completePlaceholders.apply(this, arguments);
|
@@ -10123,20 +10189,20 @@ var fs = /*#__PURE__*/function () {
|
|
10123
10189
|
}, {
|
10124
10190
|
key: "addButtons",
|
10125
10191
|
value: function addButtons() {
|
10126
|
-
var
|
10192
|
+
var _this47 = this;
|
10127
10193
|
for (var _len2 = arguments.length, e = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
10128
10194
|
e[_key2] = arguments[_key2];
|
10129
10195
|
}
|
10130
10196
|
e.forEach(function (t) {
|
10131
|
-
return
|
10197
|
+
return _this47._buttonPanel.appendChild(t);
|
10132
10198
|
});
|
10133
10199
|
}
|
10134
10200
|
}, {
|
10135
10201
|
key: "close",
|
10136
10202
|
value: function close() {
|
10137
|
-
var
|
10203
|
+
var _this48 = this;
|
10138
10204
|
this._elementRef.classList.remove("show-modal"), this._elementRef.classList.add("hide-modal"), this._backgroundPanelRef.classList.remove("show-modal-background"), this._backgroundPanelRef.classList.add("hide-modal-background"), this._isOpen = !1, setTimeout(function () {
|
10139
|
-
|
10205
|
+
_this48._elementRef.style.display = "none", _this48._backgroundPanelRef.style.display = "none";
|
10140
10206
|
}, le.MODAL_CLOSE_TIMEOUT_MS);
|
10141
10207
|
}
|
10142
10208
|
}, {
|
@@ -10152,10 +10218,10 @@ var fs = /*#__PURE__*/function () {
|
|
10152
10218
|
}, {
|
10153
10219
|
key: "addCloseButton",
|
10154
10220
|
value: function addCloseButton(e, t, i) {
|
10155
|
-
var
|
10221
|
+
var _this49 = this;
|
10156
10222
|
var n = t ? le.createSVGButton(e) : le.createTextButton(e);
|
10157
10223
|
return this.addButtons(n), n.onclick = function () {
|
10158
|
-
|
10224
|
+
_this49.close(), setTimeout(function () {
|
10159
10225
|
i == null || i();
|
10160
10226
|
}, 140);
|
10161
10227
|
}, n;
|
@@ -10229,13 +10295,13 @@ var ut = /*#__PURE__*/function (_wt2) {
|
|
10229
10295
|
var _super39 = _createSuper(ut);
|
10230
10296
|
// prettier-ignore
|
10231
10297
|
function ut(e, t, i, n, r, o) {
|
10232
|
-
var
|
10298
|
+
var _this50;
|
10233
10299
|
_classCallCheck(this, ut);
|
10234
10300
|
var l, c, d, u, p, h;
|
10235
|
-
|
10236
|
-
var a =
|
10237
|
-
|
10238
|
-
return
|
10301
|
+
_this50 = _super39.call(this, ut.createButtonElement(), (l = i.button) == null ? void 0 : l.position, i.button, o);
|
10302
|
+
var a = _this50.createInnerElements(n, r, _this50._customStyles);
|
10303
|
+
_this50._inputElement = ut.createInputElement((c = i == null ? void 0 : i.files) == null ? void 0 : c.acceptedFormats), _this50.addClickEvent(e, i), _this50.elementRef.replaceChildren(a.styles), _this50.reapplyStateStyle("styles"), _this50._fileAttachmentsType = t, _this50._openModalOnce = ((u = (d = i.files) == null ? void 0 : d.infoModal) == null ? void 0 : u.openModalOnce) === !1 || (h = (p = i.files) == null ? void 0 : p.infoModal) == null ? void 0 : h.openModalOnce;
|
10304
|
+
return _this50;
|
10239
10305
|
}
|
10240
10306
|
_createClass(ut, [{
|
10241
10307
|
key: "createInnerElements",
|
@@ -10363,26 +10429,26 @@ var Me = /*#__PURE__*/function () {
|
|
10363
10429
|
}, {
|
10364
10430
|
key: "useValidationFunc",
|
10365
10431
|
value: function () {
|
10366
|
-
var _useValidationFunc = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
10432
|
+
var _useValidationFunc = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee93(e, t, i, n) {
|
10367
10433
|
var r, o, a, l;
|
10368
|
-
return _regeneratorRuntime().wrap(function
|
10369
|
-
while (1) switch (
|
10434
|
+
return _regeneratorRuntime().wrap(function _callee93$(_context93) {
|
10435
|
+
while (1) switch (_context93.prev = _context93.next) {
|
10370
10436
|
case 0:
|
10371
10437
|
r = t.inputElementRef, o = r.classList.contains("text-input-placeholder") ? "" : r.textContent;
|
10372
|
-
|
10438
|
+
_context93.next = 3;
|
10373
10439
|
return i.completePlaceholders();
|
10374
10440
|
case 3:
|
10375
10441
|
a = i.getAllFileData(), l = a == null ? void 0 : a.map(function (c) {
|
10376
10442
|
return c.file;
|
10377
10443
|
});
|
10378
|
-
return
|
10444
|
+
return _context93.abrupt("return", Me.validate(e, n, o, l));
|
10379
10445
|
case 5:
|
10380
10446
|
case "end":
|
10381
|
-
return
|
10447
|
+
return _context93.stop();
|
10382
10448
|
}
|
10383
|
-
},
|
10449
|
+
}, _callee93);
|
10384
10450
|
}));
|
10385
|
-
function useValidationFunc(
|
10451
|
+
function useValidationFunc(_x168, _x169, _x170, _x171) {
|
10386
10452
|
return _useValidationFunc.apply(this, arguments);
|
10387
10453
|
}
|
10388
10454
|
return useValidationFunc;
|
@@ -10390,22 +10456,22 @@ var Me = /*#__PURE__*/function () {
|
|
10390
10456
|
}, {
|
10391
10457
|
key: "useValidationFuncProgrammatic",
|
10392
10458
|
value: function () {
|
10393
|
-
var _useValidationFuncProgrammatic = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
10459
|
+
var _useValidationFuncProgrammatic = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee94(e, t, i) {
|
10394
10460
|
var r, n;
|
10395
|
-
return _regeneratorRuntime().wrap(function
|
10396
|
-
while (1) switch (
|
10461
|
+
return _regeneratorRuntime().wrap(function _callee94$(_context94) {
|
10462
|
+
while (1) switch (_context94.prev = _context94.next) {
|
10397
10463
|
case 0:
|
10398
10464
|
n = (r = t.files) == null ? void 0 : r.map(function (o) {
|
10399
10465
|
return o.file;
|
10400
10466
|
});
|
10401
|
-
return
|
10467
|
+
return _context94.abrupt("return", Me.validate(e, i, t.text, n, !0));
|
10402
10468
|
case 2:
|
10403
10469
|
case "end":
|
10404
|
-
return
|
10470
|
+
return _context94.stop();
|
10405
10471
|
}
|
10406
|
-
},
|
10472
|
+
}, _callee94);
|
10407
10473
|
}));
|
10408
|
-
function useValidationFuncProgrammatic(
|
10474
|
+
function useValidationFuncProgrammatic(_x172, _x173, _x174) {
|
10409
10475
|
return _useValidationFuncProgrammatic.apply(this, arguments);
|
10410
10476
|
}
|
10411
10477
|
return useValidationFuncProgrammatic;
|
@@ -10421,26 +10487,26 @@ var Me = /*#__PURE__*/function () {
|
|
10421
10487
|
value: function attach(e, t, i, n, r) {
|
10422
10488
|
var o = e.validateInput || ke.processValidateInput(e);
|
10423
10489
|
e._validationHandler = /*#__PURE__*/function () {
|
10424
|
-
var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
10490
|
+
var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee95(a) {
|
10425
10491
|
var l;
|
10426
|
-
return _regeneratorRuntime().wrap(function
|
10427
|
-
while (1) switch (
|
10492
|
+
return _regeneratorRuntime().wrap(function _callee95$(_context95) {
|
10493
|
+
while (1) switch (_context95.prev = _context95.next) {
|
10428
10494
|
case 0:
|
10429
10495
|
if (!(r.status.loadingActive || r.status.requestInProgress || t.isSubmitProgrammaticallyDisabled === !0 || !Me.validateWebsocket(t, r))) {
|
10430
|
-
|
10496
|
+
_context95.next = 2;
|
10431
10497
|
break;
|
10432
10498
|
}
|
10433
|
-
return
|
10499
|
+
return _context95.abrupt("return", !1);
|
10434
10500
|
case 2:
|
10435
10501
|
l = o || t.canSendMessage;
|
10436
|
-
return
|
10502
|
+
return _context95.abrupt("return", l ? a ? Me.useValidationFuncProgrammatic(l, a, r) : Me.useValidationFunc(l, i, n, r) : null);
|
10437
10503
|
case 4:
|
10438
10504
|
case "end":
|
10439
|
-
return
|
10505
|
+
return _context95.stop();
|
10440
10506
|
}
|
10441
|
-
},
|
10507
|
+
}, _callee95);
|
10442
10508
|
}));
|
10443
|
-
return function (
|
10509
|
+
return function (_x175) {
|
10444
10510
|
return _ref12.apply(this, arguments);
|
10445
10511
|
};
|
10446
10512
|
}();
|
@@ -10453,10 +10519,10 @@ var bt = /*#__PURE__*/function (_wt3) {
|
|
10453
10519
|
_inherits(bt, _wt3);
|
10454
10520
|
var _super40 = _createSuper(bt);
|
10455
10521
|
function bt(e) {
|
10456
|
-
var
|
10522
|
+
var _this51;
|
10457
10523
|
_classCallCheck(this, bt);
|
10458
|
-
(e == null ? void 0 : e.position) === "dropup-menu" && (e.position = "outside-right"),
|
10459
|
-
return
|
10524
|
+
(e == null ? void 0 : e.position) === "dropup-menu" && (e.position = "outside-right"), _this51 = _super40.call(this, bt.createMicrophoneElement(), e == null ? void 0 : e.position, e), _this51.isActive = !1, _this51._innerElements = _this51.createInnerElements(_this51._customStyles), _this51.changeToDefault();
|
10525
|
+
return _this51;
|
10460
10526
|
}
|
10461
10527
|
_createClass(bt, [{
|
10462
10528
|
key: "createInnerElements",
|
@@ -10663,9 +10729,9 @@ var J = /*#__PURE__*/function () {
|
|
10663
10729
|
}, {
|
10664
10730
|
key: "keyDownWindow",
|
10665
10731
|
value: function keyDownWindow(e) {
|
10666
|
-
var
|
10732
|
+
var _this52 = this;
|
10667
10733
|
e.element && J.getElementIfFocusedOnAvailable(e.element, document.activeElement) && (J.KEY_DOWN_TIMEOUT !== null && clearTimeout(J.KEY_DOWN_TIMEOUT), J.KEY_DOWN_TIMEOUT = setTimeout(function () {
|
10668
|
-
J.KEY_DOWN_TIMEOUT = null,
|
10734
|
+
J.KEY_DOWN_TIMEOUT = null, _this52.resetRecording(e);
|
10669
10735
|
}, 500));
|
10670
10736
|
}
|
10671
10737
|
}, {
|
@@ -11286,22 +11352,22 @@ var Jt = /*#__PURE__*/function (_fa$Speech) {
|
|
11286
11352
|
}, {
|
11287
11353
|
key: "setEvents",
|
11288
11354
|
value: function setEvents() {
|
11289
|
-
var
|
11355
|
+
var _this53 = this;
|
11290
11356
|
this._service && (this._service.onstart = function () {
|
11291
|
-
|
11357
|
+
_this53.setStateOnStart();
|
11292
11358
|
}, this._service.onerror = function (e) {
|
11293
|
-
Nn.Browser.IS_SAFARI() && e.message === "Another request is started" || e.error === "aborted" &&
|
11359
|
+
Nn.Browser.IS_SAFARI() && e.message === "Another request is started" || e.error === "aborted" && _this53.isRestarting || e.error !== "no-speech" && _this53.error(e.message || e.error);
|
11294
11360
|
}, this._service.onaudioend = function () {
|
11295
|
-
|
11361
|
+
_this53.setStateOnStop();
|
11296
11362
|
}, this._service.onend = function () {
|
11297
|
-
|
11363
|
+
_this53._stopping = !1;
|
11298
11364
|
}, this._service.onresult = function (e) {
|
11299
|
-
if (_typeof(e.results) > "u" &&
|
11300
|
-
var
|
11301
|
-
t =
|
11302
|
-
_i17 =
|
11303
|
-
n =
|
11304
|
-
|
11365
|
+
if (_typeof(e.results) > "u" && _this53._service) _this53._service.onend = null, _this53._service.stop();else if (_this53._extractText && !_this53._stopping) {
|
11366
|
+
var _this53$_extractText = _this53._extractText(e, _this53.finalTranscript, _this53._translations),
|
11367
|
+
t = _this53$_extractText.interimTranscript,
|
11368
|
+
_i17 = _this53$_extractText.finalTranscript,
|
11369
|
+
n = _this53$_extractText.newText;
|
11370
|
+
_this53.updateElements(t, _i17, n);
|
11305
11371
|
}
|
11306
11372
|
});
|
11307
11373
|
}
|
@@ -11396,26 +11462,26 @@ var $t = /*#__PURE__*/function () {
|
|
11396
11462
|
}, {
|
11397
11463
|
key: "getNewSpeechConfig",
|
11398
11464
|
value: function () {
|
11399
|
-
var _getNewSpeechConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
11400
|
-
return _regeneratorRuntime().wrap(function
|
11401
|
-
while (1) switch (
|
11465
|
+
var _getNewSpeechConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee96(e, t) {
|
11466
|
+
return _regeneratorRuntime().wrap(function _callee96$(_context96) {
|
11467
|
+
while (1) switch (_context96.prev = _context96.next) {
|
11402
11468
|
case 0:
|
11403
11469
|
if (!t.region) {
|
11404
|
-
|
11470
|
+
_context96.next = 2;
|
11405
11471
|
break;
|
11406
11472
|
}
|
11407
|
-
return
|
11473
|
+
return _context96.abrupt("return", t.subscriptionKey ? e.fromSubscription(t.subscriptionKey.trim(), t.region.trim()) : t.token ? e.fromAuthorizationToken(t.token.trim(), t.region.trim()) : t.retrieveToken ? t.retrieveToken().then(function (i) {
|
11408
11474
|
return t.region ? e.fromAuthorizationToken((i == null ? void 0 : i.trim()) || "", t.region.trim()) : null;
|
11409
11475
|
})["catch"](function (i) {
|
11410
11476
|
return console.error(i), null;
|
11411
11477
|
}) : null);
|
11412
11478
|
case 2:
|
11413
11479
|
case "end":
|
11414
|
-
return
|
11480
|
+
return _context96.stop();
|
11415
11481
|
}
|
11416
|
-
},
|
11482
|
+
}, _callee96);
|
11417
11483
|
}));
|
11418
|
-
function getNewSpeechConfig(
|
11484
|
+
function getNewSpeechConfig(_x176, _x177) {
|
11419
11485
|
return _getNewSpeechConfig.apply(this, arguments);
|
11420
11486
|
}
|
11421
11487
|
return getNewSpeechConfig;
|
@@ -11428,23 +11494,23 @@ var $t = /*#__PURE__*/function () {
|
|
11428
11494
|
}, {
|
11429
11495
|
key: "get",
|
11430
11496
|
value: function () {
|
11431
|
-
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
11497
|
+
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee97(e, t) {
|
11432
11498
|
var i;
|
11433
|
-
return _regeneratorRuntime().wrap(function
|
11434
|
-
while (1) switch (
|
11499
|
+
return _regeneratorRuntime().wrap(function _callee97$(_context97) {
|
11500
|
+
while (1) switch (_context97.prev = _context97.next) {
|
11435
11501
|
case 0:
|
11436
|
-
|
11502
|
+
_context97.next = 2;
|
11437
11503
|
return $t.getNewSpeechConfig(e, t);
|
11438
11504
|
case 2:
|
11439
|
-
i =
|
11440
|
-
return
|
11505
|
+
i = _context97.sent;
|
11506
|
+
return _context97.abrupt("return", (i && $t.process(i, t), i));
|
11441
11507
|
case 4:
|
11442
11508
|
case "end":
|
11443
|
-
return
|
11509
|
+
return _context97.stop();
|
11444
11510
|
}
|
11445
|
-
},
|
11511
|
+
}, _callee97);
|
11446
11512
|
}));
|
11447
|
-
function get(
|
11513
|
+
function get(_x178, _x179) {
|
11448
11514
|
return _get.apply(this, arguments);
|
11449
11515
|
}
|
11450
11516
|
return get;
|
@@ -11521,10 +11587,10 @@ var Yt = /*#__PURE__*/function (_va$Speech) {
|
|
11521
11587
|
_inherits(Yt, _va$Speech);
|
11522
11588
|
var _super42 = _createSuper(Yt);
|
11523
11589
|
function Yt() {
|
11524
|
-
var
|
11590
|
+
var _this54;
|
11525
11591
|
_classCallCheck(this, Yt);
|
11526
|
-
|
11527
|
-
return
|
11592
|
+
_this54 = _super42.apply(this, arguments), _this54._newTextPadding = "";
|
11593
|
+
return _this54;
|
11528
11594
|
}
|
11529
11595
|
_createClass(Yt, [{
|
11530
11596
|
key: "start",
|
@@ -11534,28 +11600,28 @@ var Yt = /*#__PURE__*/function (_va$Speech) {
|
|
11534
11600
|
}, {
|
11535
11601
|
key: "startAsync",
|
11536
11602
|
value: function () {
|
11537
|
-
var _startAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
11603
|
+
var _startAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee98(e) {
|
11538
11604
|
var t;
|
11539
|
-
return _regeneratorRuntime().wrap(function
|
11540
|
-
while (1) switch (
|
11605
|
+
return _regeneratorRuntime().wrap(function _callee98$(_context98) {
|
11606
|
+
while (1) switch (_context98.prev = _context98.next) {
|
11541
11607
|
case 0:
|
11542
|
-
|
11543
|
-
if (!
|
11544
|
-
|
11608
|
+
_context98.t0 = this.validate(e);
|
11609
|
+
if (!_context98.t0) {
|
11610
|
+
_context98.next = 6;
|
11545
11611
|
break;
|
11546
11612
|
}
|
11547
|
-
|
11613
|
+
_context98.next = 4;
|
11548
11614
|
return this.instantiateService(e);
|
11549
11615
|
case 4:
|
11550
11616
|
this._translations = e == null ? void 0 : e.translations;
|
11551
11617
|
(t = this._service) === null || t === void 0 || t.startContinuousRecognitionAsync(function () {}, this.error);
|
11552
11618
|
case 6:
|
11553
11619
|
case "end":
|
11554
|
-
return
|
11620
|
+
return _context98.stop();
|
11555
11621
|
}
|
11556
|
-
},
|
11622
|
+
}, _callee98, this);
|
11557
11623
|
}));
|
11558
|
-
function startAsync(
|
11624
|
+
function startAsync(_x180) {
|
11559
11625
|
return _startAsync.apply(this, arguments);
|
11560
11626
|
}
|
11561
11627
|
return startAsync;
|
@@ -11568,28 +11634,28 @@ var Yt = /*#__PURE__*/function (_va$Speech) {
|
|
11568
11634
|
}, {
|
11569
11635
|
key: "instantiateService",
|
11570
11636
|
value: function () {
|
11571
|
-
var _instantiateService = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
11637
|
+
var _instantiateService = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee99(e) {
|
11572
11638
|
var t, i, n, r;
|
11573
|
-
return _regeneratorRuntime().wrap(function
|
11574
|
-
while (1) switch (
|
11639
|
+
return _regeneratorRuntime().wrap(function _callee99$(_context99) {
|
11640
|
+
while (1) switch (_context99.prev = _context99.next) {
|
11575
11641
|
case 0:
|
11576
11642
|
t = Yt.getAPI();
|
11577
11643
|
i = t.AudioConfig.fromDefaultMicrophoneInput();
|
11578
|
-
|
11644
|
+
_context99.next = 4;
|
11579
11645
|
return Dn.AzureSpeechConfig.get(t.SpeechConfig, e);
|
11580
11646
|
case 4:
|
11581
|
-
n =
|
11647
|
+
n = _context99.sent;
|
11582
11648
|
if (n) {
|
11583
11649
|
r = new t.SpeechRecognizer(n, i);
|
11584
11650
|
this.setEvents(r), this._service = r, e.retrieveToken && this.retrieveTokenInterval(e.retrieveToken);
|
11585
11651
|
} else this.error("Unable to contact Azure server");
|
11586
11652
|
case 6:
|
11587
11653
|
case "end":
|
11588
|
-
return
|
11654
|
+
return _context99.stop();
|
11589
11655
|
}
|
11590
|
-
},
|
11656
|
+
}, _callee99, this);
|
11591
11657
|
}));
|
11592
|
-
function instantiateService(
|
11658
|
+
function instantiateService(_x181) {
|
11593
11659
|
return _instantiateService.apply(this, arguments);
|
11594
11660
|
}
|
11595
11661
|
return instantiateService;
|
@@ -11652,12 +11718,12 @@ var Yt = /*#__PURE__*/function (_va$Speech) {
|
|
11652
11718
|
}, {
|
11653
11719
|
key: "retrieveTokenInterval",
|
11654
11720
|
value: function retrieveTokenInterval(e) {
|
11655
|
-
var
|
11721
|
+
var _this55 = this;
|
11656
11722
|
this._retrieveTokenInterval = setInterval(function () {
|
11657
11723
|
e == null || e().then(function (t) {
|
11658
|
-
|
11724
|
+
_this55._service && (_this55._service.authorizationToken = (t == null ? void 0 : t.trim()) || "");
|
11659
11725
|
})["catch"](function (t) {
|
11660
|
-
|
11726
|
+
_this55.error(t);
|
11661
11727
|
});
|
11662
11728
|
}, 1e4);
|
11663
11729
|
}
|
@@ -11739,18 +11805,18 @@ var Zt = /*#__PURE__*/function (_bt) {
|
|
11739
11805
|
_inherits(Zt, _bt);
|
11740
11806
|
var _super43 = _createSuper(Zt);
|
11741
11807
|
function Zt(e, t, i) {
|
11742
|
-
var
|
11808
|
+
var _this56;
|
11743
11809
|
_classCallCheck(this, Zt);
|
11744
11810
|
var o;
|
11745
|
-
|
11811
|
+
_this56 = _super43.call(this, _typeof(e.speechToText) == "object" ? (o = e.speechToText) == null ? void 0 : o.button : {});
|
11746
11812
|
var _Zt$processConfigurat = Zt.processConfiguration(t, e.speechToText),
|
11747
11813
|
n = _Zt$processConfigurat.serviceName,
|
11748
11814
|
r = _Zt$processConfigurat.processedConfig;
|
11749
|
-
if (
|
11815
|
+
if (_this56._addErrorMessage = i, n === "webspeech" && !Li.isWebSpeechSupported()) _this56.changeToUnsupported();else {
|
11750
11816
|
var a = !e.textInput || !e.textInput.disabled;
|
11751
|
-
|
11817
|
+
_this56.elementRef.onclick = _this56.buttonClick.bind(_assertThisInitialized(_this56), t, a, n, r);
|
11752
11818
|
}
|
11753
|
-
return
|
11819
|
+
return _this56;
|
11754
11820
|
}
|
11755
11821
|
// prettier-ignore
|
11756
11822
|
_createClass(Zt, [{
|
@@ -11831,11 +11897,11 @@ var Ea = /*#__PURE__*/function (_bt2) {
|
|
11831
11897
|
_inherits(Ea, _bt2);
|
11832
11898
|
var _super44 = _createSuper(Ea);
|
11833
11899
|
function Ea(e, t) {
|
11834
|
-
var
|
11900
|
+
var _this57;
|
11835
11901
|
_classCallCheck(this, Ea);
|
11836
11902
|
var i, n;
|
11837
|
-
|
11838
|
-
return
|
11903
|
+
_this57 = _super44.call(this, t.button), _this57._waitingForBrowserApproval = !1, _this57._audioType = e, _this57._extension = ((i = t.files) == null ? void 0 : i.format) || "mp3", _this57._maxDurationSeconds = (n = t.files) == null ? void 0 : n.maxDurationSeconds, _this57.elementRef.onclick = _this57.buttonClick.bind(_assertThisInitialized(_this57));
|
11904
|
+
return _this57;
|
11839
11905
|
}
|
11840
11906
|
_createClass(Ea, [{
|
11841
11907
|
key: "buttonClick",
|
@@ -11845,10 +11911,10 @@ var Ea = /*#__PURE__*/function (_bt2) {
|
|
11845
11911
|
}, {
|
11846
11912
|
key: "stop",
|
11847
11913
|
value: function stop() {
|
11848
|
-
var
|
11914
|
+
var _this58 = this;
|
11849
11915
|
return new Promise(function (e) {
|
11850
11916
|
var t, i;
|
11851
|
-
|
11917
|
+
_this58.changeToDefault(), (t = _this58._mediaRecorder) == null || t.stop(), (i = _this58._mediaStream) == null || i.getTracks().forEach(function (n) {
|
11852
11918
|
return n.stop();
|
11853
11919
|
}), setTimeout(function () {
|
11854
11920
|
e();
|
@@ -11858,23 +11924,23 @@ var Ea = /*#__PURE__*/function (_bt2) {
|
|
11858
11924
|
}, {
|
11859
11925
|
key: "record",
|
11860
11926
|
value: function record() {
|
11861
|
-
var
|
11927
|
+
var _this59 = this;
|
11862
11928
|
navigator.mediaDevices.getUserMedia({
|
11863
11929
|
audio: !0
|
11864
11930
|
}).then(function (e) {
|
11865
|
-
|
11866
|
-
|
11867
|
-
}),
|
11931
|
+
_this59.changeToActive(), _this59._mediaRecorder = new MediaRecorder(e), _this59._audioType.addPlaceholderAttachment(_this59.stop.bind(_this59), _this59._maxDurationSeconds), _this59._mediaStream = e, _this59._mediaRecorder.addEventListener("dataavailable", function (t) {
|
11932
|
+
_this59.createFile(t);
|
11933
|
+
}), _this59._mediaRecorder.start();
|
11868
11934
|
})["catch"](function (e) {
|
11869
|
-
console.error(e),
|
11935
|
+
console.error(e), _this59.stop();
|
11870
11936
|
})["finally"](function () {
|
11871
|
-
|
11937
|
+
_this59._waitingForBrowserApproval = !1;
|
11872
11938
|
});
|
11873
11939
|
}
|
11874
11940
|
}, {
|
11875
11941
|
key: "createFile",
|
11876
11942
|
value: function createFile(e) {
|
11877
|
-
var
|
11943
|
+
var _this60 = this;
|
11878
11944
|
var t = new Blob([e.data], {
|
11879
11945
|
type: "audio/".concat(this._extension)
|
11880
11946
|
}),
|
@@ -11884,7 +11950,7 @@ var Ea = /*#__PURE__*/function (_bt2) {
|
|
11884
11950
|
}),
|
11885
11951
|
r = new FileReader();
|
11886
11952
|
r.readAsDataURL(n), r.onload = function (o) {
|
11887
|
-
|
11953
|
+
_this60._audioType.completePlaceholderAttachment(n, o.target.result);
|
11888
11954
|
};
|
11889
11955
|
}
|
11890
11956
|
}]);
|
@@ -11964,19 +12030,19 @@ var yi = /*#__PURE__*/function (_wt4) {
|
|
11964
12030
|
var _super45 = _createSuper(k);
|
11965
12031
|
// prettier-ignore
|
11966
12032
|
function k(e, t, i, n, r) {
|
11967
|
-
var
|
12033
|
+
var _this61;
|
11968
12034
|
_classCallCheck(this, k);
|
11969
12035
|
var o = Ce.process(e.submitButtonStyles);
|
11970
|
-
|
12036
|
+
_this61 = _super45.call(this, k.createButtonContainerElement(), o == null ? void 0 : o.position, o), _this61._isSVGLoadingIconOverriden = !1, _this61.status = {
|
11971
12037
|
requestInProgress: !1,
|
11972
12038
|
loadingActive: !1
|
11973
|
-
},
|
12039
|
+
}, _this61._messages = i, _this61._inputElementRef = t, _this61._fileAttachments = r, _this61._innerElements = _this61.createInnerElements(), _this61._abortStream = new AbortController(), _this61._stopClicked = {
|
11974
12040
|
listener: function listener() {}
|
11975
|
-
},
|
12041
|
+
}, _this61._serviceIO = n, _this61._alwaysEnabled = !!(o != null && o.alwaysEnabled), e.disableSubmitButton = _this61.disableSubmitButton.bind(_assertThisInitialized(_this61), n), _this61.attemptOverwriteLoadingStyle(e), setTimeout(function () {
|
11976
12042
|
var a;
|
11977
|
-
|
12043
|
+
_this61._validationHandler = e._validationHandler, _this61.assignHandlers(_this61._validationHandler), (a = _this61._validationHandler) == null || a.call(_assertThisInitialized(_this61));
|
11978
12044
|
});
|
11979
|
-
return
|
12045
|
+
return _this61;
|
11980
12046
|
}
|
11981
12047
|
// prettier-ignore
|
11982
12048
|
_createClass(k, [{
|
@@ -12031,12 +12097,12 @@ var yi = /*#__PURE__*/function (_wt4) {
|
|
12031
12097
|
}, {
|
12032
12098
|
key: "submitFromInput",
|
12033
12099
|
value: function () {
|
12034
|
-
var _submitFromInput = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
12100
|
+
var _submitFromInput = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee100() {
|
12035
12101
|
var t, e, _i18;
|
12036
|
-
return _regeneratorRuntime().wrap(function
|
12037
|
-
while (1) switch (
|
12102
|
+
return _regeneratorRuntime().wrap(function _callee100$(_context100) {
|
12103
|
+
while (1) switch (_context100.prev = _context100.next) {
|
12038
12104
|
case 0:
|
12039
|
-
|
12105
|
+
_context100.next = 2;
|
12040
12106
|
return this._fileAttachments.completePlaceholders();
|
12041
12107
|
case 2:
|
12042
12108
|
e = this._fileAttachments.getAllFileData();
|
@@ -12052,9 +12118,9 @@ var yi = /*#__PURE__*/function (_wt4) {
|
|
12052
12118
|
}
|
12053
12119
|
case 4:
|
12054
12120
|
case "end":
|
12055
|
-
return
|
12121
|
+
return _context100.stop();
|
12056
12122
|
}
|
12057
|
-
},
|
12123
|
+
}, _callee100, this);
|
12058
12124
|
}));
|
12059
12125
|
function submitFromInput() {
|
12060
12126
|
return _submitFromInput.apply(this, arguments);
|
@@ -12064,11 +12130,11 @@ var yi = /*#__PURE__*/function (_wt4) {
|
|
12064
12130
|
}, {
|
12065
12131
|
key: "programmaticSubmit",
|
12066
12132
|
value: function () {
|
12067
|
-
var _programmaticSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
12068
|
-
var
|
12133
|
+
var _programmaticSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee101(e) {
|
12134
|
+
var _this62 = this;
|
12069
12135
|
var t;
|
12070
|
-
return _regeneratorRuntime().wrap(function
|
12071
|
-
while (1) switch (
|
12136
|
+
return _regeneratorRuntime().wrap(function _callee101$(_context101) {
|
12137
|
+
while (1) switch (_context101.prev = _context101.next) {
|
12072
12138
|
case 0:
|
12073
12139
|
typeof e == "string" && (e = ke.processSubmitUserMessage(e));
|
12074
12140
|
t = {
|
@@ -12080,15 +12146,15 @@ var yi = /*#__PURE__*/function (_wt4) {
|
|
12080
12146
|
type: ue.getTypeFromBlob(i)
|
12081
12147
|
};
|
12082
12148
|
})), setTimeout(function () {
|
12083
|
-
return
|
12149
|
+
return _this62.attemptSubmit(t, !0);
|
12084
12150
|
});
|
12085
12151
|
case 3:
|
12086
12152
|
case "end":
|
12087
|
-
return
|
12153
|
+
return _context101.stop();
|
12088
12154
|
}
|
12089
|
-
},
|
12155
|
+
}, _callee101);
|
12090
12156
|
}));
|
12091
|
-
function programmaticSubmit(
|
12157
|
+
function programmaticSubmit(_x182) {
|
12092
12158
|
return _programmaticSubmit.apply(this, arguments);
|
12093
12159
|
}
|
12094
12160
|
return programmaticSubmit;
|
@@ -12096,31 +12162,31 @@ var yi = /*#__PURE__*/function (_wt4) {
|
|
12096
12162
|
}, {
|
12097
12163
|
key: "attemptSubmit",
|
12098
12164
|
value: function () {
|
12099
|
-
var _attemptSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
12165
|
+
var _attemptSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee102(e) {
|
12100
12166
|
var t,
|
12101
12167
|
r,
|
12102
12168
|
o,
|
12103
12169
|
a,
|
12104
12170
|
i,
|
12105
12171
|
n,
|
12106
|
-
|
12107
|
-
return _regeneratorRuntime().wrap(function
|
12108
|
-
while (1) switch (
|
12172
|
+
_args102 = arguments;
|
12173
|
+
return _regeneratorRuntime().wrap(function _callee102$(_context102) {
|
12174
|
+
while (1) switch (_context102.prev = _context102.next) {
|
12109
12175
|
case 0:
|
12110
|
-
t =
|
12111
|
-
|
12176
|
+
t = _args102.length > 1 && _args102[1] !== undefined ? _args102[1] : !1;
|
12177
|
+
_context102.next = 3;
|
12112
12178
|
return (r = this._validationHandler) == null ? void 0 : r.call(this, t ? e : void 0);
|
12113
12179
|
case 3:
|
12114
|
-
|
12115
|
-
|
12116
|
-
if (!(
|
12117
|
-
|
12180
|
+
_context102.t0 = _context102.sent;
|
12181
|
+
_context102.t1 = !1;
|
12182
|
+
if (!(_context102.t0 === _context102.t1)) {
|
12183
|
+
_context102.next = 7;
|
12118
12184
|
break;
|
12119
12185
|
}
|
12120
|
-
return
|
12186
|
+
return _context102.abrupt("return");
|
12121
12187
|
case 7:
|
12122
12188
|
this.changeToLoadingIcon();
|
12123
|
-
|
12189
|
+
_context102.next = 10;
|
12124
12190
|
return this.addNewMessage(e);
|
12125
12191
|
case 10:
|
12126
12192
|
this._serviceIO.isWebModel() || this._messages.addLoadingMessage();
|
@@ -12131,17 +12197,17 @@ var yi = /*#__PURE__*/function (_wt4) {
|
|
12131
12197
|
text: e.text === "" ? void 0 : e.text,
|
12132
12198
|
files: i
|
12133
12199
|
};
|
12134
|
-
|
12200
|
+
_context102.next = 15;
|
12135
12201
|
return this._serviceIO.callAPI(n, this._messages);
|
12136
12202
|
case 15:
|
12137
12203
|
(a = this._fileAttachments) == null || a.removeAllFiles();
|
12138
12204
|
case 16:
|
12139
12205
|
case "end":
|
12140
|
-
return
|
12206
|
+
return _context102.stop();
|
12141
12207
|
}
|
12142
|
-
},
|
12208
|
+
}, _callee102, this);
|
12143
12209
|
}));
|
12144
|
-
function attemptSubmit(
|
12210
|
+
function attemptSubmit(_x183) {
|
12145
12211
|
return _attemptSubmit.apply(this, arguments);
|
12146
12212
|
}
|
12147
12213
|
return attemptSubmit;
|
@@ -12149,35 +12215,35 @@ var yi = /*#__PURE__*/function (_wt4) {
|
|
12149
12215
|
}, {
|
12150
12216
|
key: "addNewMessage",
|
12151
12217
|
value: function () {
|
12152
|
-
var _addNewMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
12218
|
+
var _addNewMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee103(_ref13) {
|
12153
12219
|
var e, t, i;
|
12154
|
-
return _regeneratorRuntime().wrap(function
|
12155
|
-
while (1) switch (
|
12220
|
+
return _regeneratorRuntime().wrap(function _callee103$(_context103) {
|
12221
|
+
while (1) switch (_context103.prev = _context103.next) {
|
12156
12222
|
case 0:
|
12157
12223
|
e = _ref13.text, t = _ref13.files;
|
12158
12224
|
i = {
|
12159
12225
|
role: v.USER_ROLE
|
12160
12226
|
};
|
12161
12227
|
e && (i.text = e);
|
12162
|
-
|
12163
|
-
if (!
|
12164
|
-
|
12228
|
+
_context103.t0 = t;
|
12229
|
+
if (!_context103.t0) {
|
12230
|
+
_context103.next = 8;
|
12165
12231
|
break;
|
12166
12232
|
}
|
12167
|
-
|
12233
|
+
_context103.next = 7;
|
12168
12234
|
return this._messages.addMultipleFiles(t);
|
12169
12235
|
case 7:
|
12170
|
-
i.files =
|
12236
|
+
i.files = _context103.sent;
|
12171
12237
|
case 8:
|
12172
12238
|
this._serviceIO.sessionId && (i._sessionId = this._serviceIO.sessionId);
|
12173
12239
|
Object.keys(i).length > 0 && this._messages.addNewMessage(i);
|
12174
12240
|
case 10:
|
12175
12241
|
case "end":
|
12176
|
-
return
|
12242
|
+
return _context103.stop();
|
12177
12243
|
}
|
12178
|
-
},
|
12244
|
+
}, _callee103, this);
|
12179
12245
|
}));
|
12180
|
-
function addNewMessage(
|
12246
|
+
function addNewMessage(_x184) {
|
12181
12247
|
return _addNewMessage.apply(this, arguments);
|
12182
12248
|
}
|
12183
12249
|
return addNewMessage;
|
@@ -12258,14 +12324,14 @@ var sn = /*#__PURE__*/function (_at) {
|
|
12258
12324
|
var _super46 = _createSuper(sn);
|
12259
12325
|
// prettier-ignore
|
12260
12326
|
function sn(e, t, i, n) {
|
12261
|
-
var
|
12327
|
+
var _this63;
|
12262
12328
|
_classCallCheck(this, sn);
|
12263
|
-
|
12264
|
-
var
|
12265
|
-
r =
|
12266
|
-
o =
|
12267
|
-
|
12268
|
-
return
|
12329
|
+
_this63 = _super46.call(this, e, ["modal-content", "modal-camera-content"], i), _this63._stopped = !1, _this63._format = "image/png", _this63._canvas = document.createElement("canvas"), _this63._canvas.classList.add("camera-modal-canvas");
|
12330
|
+
var _this63$addButtonsAnd = _this63.addButtonsAndTheirEvents(t),
|
12331
|
+
r = _this63$addButtonsAnd.captureButton,
|
12332
|
+
o = _this63$addButtonsAnd.submitButton;
|
12333
|
+
_this63._captureButton = r, _this63._submitButton = o, _this63._captureIcon = _this63._captureButton.children[0], _this63._refreshIcon = q.createSVGElement(_a), _this63._refreshIcon.classList.add("modal-svg-button-icon", "modal-svg-refresh-icon"), (n == null ? void 0 : n.format) === "jpeg" && (_this63._format = "image/jpeg"), n != null && n.dimensions && (_this63._dimensions = n.dimensions), _this63._contentRef.appendChild(_this63._canvas), _this63.extensionCloseCallback = _this63.stop;
|
12334
|
+
return _this63;
|
12269
12335
|
}
|
12270
12336
|
_createClass(sn, [{
|
12271
12337
|
key: "addButtonsAndTheirEvents",
|
@@ -12284,38 +12350,38 @@ var sn = /*#__PURE__*/function (_at) {
|
|
12284
12350
|
}, {
|
12285
12351
|
key: "addButtonEvents",
|
12286
12352
|
value: function addButtonEvents(e, t, i, n) {
|
12287
|
-
var
|
12353
|
+
var _this64 = this;
|
12288
12354
|
e.onclick = function () {
|
12289
|
-
|
12355
|
+
_this64.capture();
|
12290
12356
|
}, t.addEventListener("click", this.stop.bind(this)), i.onclick = function () {
|
12291
|
-
var r =
|
12292
|
-
r && _t.addFilesToType([r], [n]),
|
12357
|
+
var r = _this64.getFile();
|
12358
|
+
r && _t.addFilesToType([r], [n]), _this64.stop(), _this64.close();
|
12293
12359
|
};
|
12294
12360
|
}
|
12295
12361
|
}, {
|
12296
12362
|
key: "stop",
|
12297
12363
|
value: function stop() {
|
12298
|
-
var
|
12364
|
+
var _this65 = this;
|
12299
12365
|
this._mediaStream && this._mediaStream.getTracks().forEach(function (e) {
|
12300
12366
|
return e.stop();
|
12301
12367
|
}), this._stopped = !0, setTimeout(function () {
|
12302
|
-
|
12303
|
-
var e =
|
12304
|
-
e == null || e.clearRect(0, 0,
|
12368
|
+
_this65._captureButton.replaceChildren(_this65._captureIcon), _this65._captureButton.classList.replace("modal-svg-refresh-button", "modal-svg-camera-button");
|
12369
|
+
var e = _this65._canvas.getContext("2d");
|
12370
|
+
e == null || e.clearRect(0, 0, _this65._canvas.width, _this65._canvas.height);
|
12305
12371
|
}, at.MODAL_CLOSE_TIMEOUT_MS);
|
12306
12372
|
}
|
12307
12373
|
}, {
|
12308
12374
|
key: "start",
|
12309
12375
|
value: function start() {
|
12310
|
-
var
|
12376
|
+
var _this66 = this;
|
12311
12377
|
this._dataURL = void 0, this._submitButton.classList.add("modal-svg-submit-disabled"), this._stopped = !1, navigator.mediaDevices.getUserMedia({
|
12312
12378
|
video: this._dimensions || !0
|
12313
12379
|
}).then(function (e) {
|
12314
|
-
if (
|
12380
|
+
if (_this66._mediaStream = e, !_this66.isOpen()) return _this66.stop();
|
12315
12381
|
var t = document.createElement("video");
|
12316
|
-
t.srcObject = e, t.play(), requestAnimationFrame(
|
12382
|
+
t.srcObject = e, t.play(), requestAnimationFrame(_this66.updateCanvas.bind(_this66, t, _this66._canvas));
|
12317
12383
|
})["catch"](function (e) {
|
12318
|
-
console.error(e),
|
12384
|
+
console.error(e), _this66.stop(), _this66.close();
|
12319
12385
|
});
|
12320
12386
|
}
|
12321
12387
|
}, {
|
@@ -12373,13 +12439,13 @@ var Xt = /*#__PURE__*/function (_wt5) {
|
|
12373
12439
|
_inherits(Xt, _wt5);
|
12374
12440
|
var _super47 = _createSuper(Xt);
|
12375
12441
|
function Xt(e, t, i) {
|
12376
|
-
var
|
12442
|
+
var _this67;
|
12377
12443
|
_classCallCheck(this, Xt);
|
12378
12444
|
var r;
|
12379
|
-
|
12380
|
-
var n =
|
12381
|
-
i &&
|
12382
|
-
return
|
12445
|
+
_this67 = _super47.call(this, Xt.createButtonElement(), (r = i == null ? void 0 : i.button) == null ? void 0 : r.position, (i == null ? void 0 : i.button) || {}, "Photo");
|
12446
|
+
var n = _this67.createInnerElements(_this67._customStyles);
|
12447
|
+
i && _this67.addClickEvent(e, t, i.modalContainerStyle, i.files), _this67.elementRef.classList.add("upload-file-button"), _this67.elementRef.appendChild(n.styles), _this67.reapplyStateStyle("styles");
|
12448
|
+
return _this67;
|
12383
12449
|
}
|
12384
12450
|
_createClass(Xt, [{
|
12385
12451
|
key: "createInnerElements",
|
@@ -12525,22 +12591,22 @@ var b = /*#__PURE__*/function (_vo) {
|
|
12525
12591
|
_inherits(b, _vo);
|
12526
12592
|
var _super48 = _createSuper(b);
|
12527
12593
|
function b() {
|
12528
|
-
var
|
12594
|
+
var _this68;
|
12529
12595
|
_classCallCheck(this, b);
|
12530
|
-
|
12596
|
+
_this68 = _super48.call(this), _this68.getMessages = function () {
|
12531
12597
|
return [];
|
12532
|
-
},
|
12598
|
+
}, _this68.submitUserMessage = function () {
|
12533
12599
|
return console.warn("submitUserMessage failed - please wait for chat view to render before calling this property.");
|
12534
|
-
},
|
12535
|
-
return Qt.focusFromParentElement(
|
12536
|
-
},
|
12600
|
+
}, _this68.focusInput = function () {
|
12601
|
+
return Qt.focusFromParentElement(_this68._elementRef);
|
12602
|
+
}, _this68.refreshMessages = function () {}, _this68.clearMessages = function () {}, _this68.scrollToBottom = function () {}, _this68.disableSubmitButton = function () {}, _this68._hasBeenRendered = !1, _this68._auxiliaryStyleApplied = !1, _this68._addMessage = function () {
|
12537
12603
|
return console.warn("addMessage failed - please wait for chat view to render before calling this property.");
|
12538
|
-
}, Go.appendStyleSheetToHead(),
|
12604
|
+
}, Go.appendStyleSheetToHead(), _this68._elementRef = document.createElement("div"), _this68._elementRef.id = "container", _this68.attachShadow({
|
12539
12605
|
mode: "open"
|
12540
|
-
}).appendChild(
|
12541
|
-
|
12606
|
+
}).appendChild(_this68._elementRef), Ei.apply(ka, _this68.shadowRoot), setTimeout(function () {
|
12607
|
+
_this68._hasBeenRendered || _this68.onRender();
|
12542
12608
|
}, 20);
|
12543
|
-
return
|
12609
|
+
return _this68;
|
12544
12610
|
}
|
12545
12611
|
_createClass(b, [{
|
12546
12612
|
key: "changeToChatView",
|