@onedeskpro/chatbot-core 0.2.0 → 0.2.1
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/README.md +20 -4
- package/dist/index.cjs +18 -37
- package/dist/index.d.cts +15 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.iife.js +14 -33
- package/dist/index.js +229 -238
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -500,29 +500,29 @@ var Oe = class extends we {
|
|
|
500
500
|
}
|
|
501
501
|
};
|
|
502
502
|
if (D.requestsCount = 0, D.requests = {}, typeof document < "u") {
|
|
503
|
-
if (typeof attachEvent == "function") attachEvent("onunload",
|
|
503
|
+
if (typeof attachEvent == "function") attachEvent("onunload", ke);
|
|
504
504
|
else if (typeof addEventListener == "function") {
|
|
505
505
|
let e = "onpagehide" in w ? "pagehide" : "unload";
|
|
506
|
-
addEventListener(e,
|
|
506
|
+
addEventListener(e, ke, !1);
|
|
507
507
|
}
|
|
508
508
|
}
|
|
509
|
-
function
|
|
509
|
+
function ke() {
|
|
510
510
|
for (let e in D.requests) D.requests.hasOwnProperty(e) && D.requests[e].abort();
|
|
511
511
|
}
|
|
512
|
-
var
|
|
513
|
-
let e =
|
|
512
|
+
var Ae = (function() {
|
|
513
|
+
let e = Me({ xdomain: !1 });
|
|
514
514
|
return e && e.responseType !== null;
|
|
515
|
-
})(),
|
|
515
|
+
})(), je = class extends Oe {
|
|
516
516
|
constructor(e) {
|
|
517
517
|
super(e);
|
|
518
518
|
let t = e && e.forceBase64;
|
|
519
|
-
this.supportsBinary =
|
|
519
|
+
this.supportsBinary = Ae && !t;
|
|
520
520
|
}
|
|
521
521
|
request(e = {}) {
|
|
522
|
-
return Object.assign(e, { xd: this.xd }, this.opts), new D(
|
|
522
|
+
return Object.assign(e, { xd: this.xd }, this.opts), new D(Me, this.uri(), e);
|
|
523
523
|
}
|
|
524
524
|
};
|
|
525
|
-
function
|
|
525
|
+
function Me(e) {
|
|
526
526
|
let t = e.xdomain;
|
|
527
527
|
try {
|
|
528
528
|
if (typeof XMLHttpRequest < "u" && (!t || Ee)) return new XMLHttpRequest();
|
|
@@ -533,12 +533,12 @@ function je(e) {
|
|
|
533
533
|
}
|
|
534
534
|
//#endregion
|
|
535
535
|
//#region ../../node_modules/.pnpm/engine.io-client@6.6.6_supports-color@8.1.1/node_modules/engine.io-client/build/esm/transports/websocket.js
|
|
536
|
-
var
|
|
536
|
+
var Ne = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative", Pe = class extends E {
|
|
537
537
|
get name() {
|
|
538
538
|
return "websocket";
|
|
539
539
|
}
|
|
540
540
|
doOpen() {
|
|
541
|
-
let e = this.uri(), t = this.opts.protocols, n =
|
|
541
|
+
let e = this.uri(), t = this.opts.protocols, n = Ne ? {} : me(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
|
|
542
542
|
this.opts.extraHeaders && (n.headers = this.opts.extraHeaders);
|
|
543
543
|
try {
|
|
544
544
|
this.ws = this.createSocket(e, t, n);
|
|
@@ -576,10 +576,10 @@ var Me = typeof navigator < "u" && typeof navigator.product == "string" && navig
|
|
|
576
576
|
let e = this.opts.secure ? "wss" : "ws", t = this.query || {};
|
|
577
577
|
return this.opts.timestampRequests && (t[this.opts.timestampParam] = be()), this.supportsBinary || (t.b64 = 1), this.createUri(e, t);
|
|
578
578
|
}
|
|
579
|
-
},
|
|
580
|
-
websocket: class extends
|
|
579
|
+
}, O = w.WebSocket || w.MozWebSocket, Fe = {
|
|
580
|
+
websocket: class extends Pe {
|
|
581
581
|
createSocket(e, t, n) {
|
|
582
|
-
return
|
|
582
|
+
return Ne ? new O(e, t, n) : t ? new O(e, t) : new O(e);
|
|
583
583
|
}
|
|
584
584
|
doWrite(e, t) {
|
|
585
585
|
this.ws.send(t);
|
|
@@ -630,8 +630,8 @@ var Me = typeof navigator < "u" && typeof navigator.product == "string" && navig
|
|
|
630
630
|
(e = this._transport) == null || e.close();
|
|
631
631
|
}
|
|
632
632
|
},
|
|
633
|
-
polling:
|
|
634
|
-
},
|
|
633
|
+
polling: je
|
|
634
|
+
}, Ie = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, Le = [
|
|
635
635
|
"source",
|
|
636
636
|
"protocol",
|
|
637
637
|
"authority",
|
|
@@ -647,19 +647,19 @@ var Me = typeof navigator < "u" && typeof navigator.product == "string" && navig
|
|
|
647
647
|
"query",
|
|
648
648
|
"anchor"
|
|
649
649
|
];
|
|
650
|
-
function
|
|
650
|
+
function k(e) {
|
|
651
651
|
if (e.length > 8e3) throw "URI too long";
|
|
652
652
|
let t = e, n = e.indexOf("["), r = e.indexOf("]");
|
|
653
653
|
n != -1 && r != -1 && (e = e.substring(0, n) + e.substring(n, r).replace(/:/g, ";") + e.substring(r, e.length));
|
|
654
|
-
let i =
|
|
655
|
-
for (; o--;) a[
|
|
656
|
-
return n != -1 && r != -1 && (a.source = t, a.host = a.host.substring(1, a.host.length - 1).replace(/;/g, ":"), a.authority = a.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), a.ipv6uri = !0), a.pathNames =
|
|
654
|
+
let i = Ie.exec(e || ""), a = {}, o = 14;
|
|
655
|
+
for (; o--;) a[Le[o]] = i[o] || "";
|
|
656
|
+
return n != -1 && r != -1 && (a.source = t, a.host = a.host.substring(1, a.host.length - 1).replace(/;/g, ":"), a.authority = a.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), a.ipv6uri = !0), a.pathNames = Re(a, a.path), a.queryKey = ze(a, a.query), a;
|
|
657
657
|
}
|
|
658
|
-
function
|
|
658
|
+
function Re(e, t) {
|
|
659
659
|
let n = t.replace(/\/{2,9}/g, "/").split("/");
|
|
660
660
|
return (t.slice(0, 1) == "/" || t.length === 0) && n.splice(0, 1), t.slice(-1) == "/" && n.splice(n.length - 1, 1), n;
|
|
661
661
|
}
|
|
662
|
-
function
|
|
662
|
+
function ze(e, t) {
|
|
663
663
|
let n = {};
|
|
664
664
|
return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function(e, t, r) {
|
|
665
665
|
t && (n[t] = r);
|
|
@@ -667,16 +667,16 @@ function Re(e, t) {
|
|
|
667
667
|
}
|
|
668
668
|
//#endregion
|
|
669
669
|
//#region ../../node_modules/.pnpm/engine.io-client@6.6.6_supports-color@8.1.1/node_modules/engine.io-client/build/esm/socket.js
|
|
670
|
-
var
|
|
671
|
-
|
|
672
|
-
|
|
670
|
+
var A = typeof addEventListener == "function" && typeof removeEventListener == "function", j = [];
|
|
671
|
+
A && addEventListener("offline", () => {
|
|
672
|
+
j.forEach((e) => e());
|
|
673
673
|
}, !1);
|
|
674
|
-
var
|
|
674
|
+
var M = class e extends S {
|
|
675
675
|
constructor(e, t) {
|
|
676
676
|
if (super(), this.binaryType = pe, this.writeBuffer = [], this._prevBufferLen = 0, this._pingInterval = -1, this._pingTimeout = -1, this._maxPayload = -1, this._pingTimeoutTime = Infinity, e && typeof e == "object" && (t = e, e = null), e) {
|
|
677
|
-
let n =
|
|
677
|
+
let n = k(e);
|
|
678
678
|
t.hostname = n.host, t.secure = n.protocol === "https" || n.protocol === "wss", t.port = n.port, n.query && (t.query = n.query);
|
|
679
|
-
} else t.host && (t.hostname =
|
|
679
|
+
} else t.host && (t.hostname = k(t.host).host);
|
|
680
680
|
T(this, t), this.secure = t.secure == null ? typeof location < "u" && location.protocol === "https:" : t.secure, t.hostname && !t.port && (t.port = this.secure ? "443" : "80"), this.hostname = t.hostname || (typeof location < "u" ? location.hostname : "localhost"), this.port = t.port || (typeof location < "u" && location.port ? location.port : this.secure ? "443" : "80"), this.transports = [], this._transportsByName = {}, t.transports.forEach((e) => {
|
|
681
681
|
let t = e.prototype.name;
|
|
682
682
|
this.transports.push(t), this._transportsByName[t] = e;
|
|
@@ -692,11 +692,11 @@ var N = class e extends S {
|
|
|
692
692
|
perMessageDeflate: { threshold: 1024 },
|
|
693
693
|
transportOptions: {},
|
|
694
694
|
closeOnBeforeunload: !1
|
|
695
|
-
}, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = Se(this.opts.query)),
|
|
695
|
+
}, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = Se(this.opts.query)), A && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
|
|
696
696
|
this.transport && (this.transport.removeAllListeners(), this.transport.close());
|
|
697
697
|
}, addEventListener("beforeunload", this._beforeunloadEventListener, !1)), this.hostname !== "localhost" && (this._offlineEventListener = () => {
|
|
698
698
|
this._onClose("transport close", { description: "network connection lost" });
|
|
699
|
-
},
|
|
699
|
+
}, j.push(this._offlineEventListener))), this.opts.withCredentials && (this._cookieJar = void 0), this._open();
|
|
700
700
|
}
|
|
701
701
|
createTransport(e) {
|
|
702
702
|
let t = Object.assign({}, this.opts.query);
|
|
@@ -813,16 +813,16 @@ var N = class e extends S {
|
|
|
813
813
|
}
|
|
814
814
|
_onClose(e, t) {
|
|
815
815
|
if (this.readyState === "opening" || this.readyState === "open" || this.readyState === "closing") {
|
|
816
|
-
if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(),
|
|
817
|
-
let e =
|
|
818
|
-
e !== -1 &&
|
|
816
|
+
if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(), A && (this._beforeunloadEventListener && removeEventListener("beforeunload", this._beforeunloadEventListener, !1), this._offlineEventListener)) {
|
|
817
|
+
let e = j.indexOf(this._offlineEventListener);
|
|
818
|
+
e !== -1 && j.splice(e, 1);
|
|
819
819
|
}
|
|
820
820
|
this.readyState = "closed", this.id = null, this.emitReserved("close", e, t), this.writeBuffer = [], this._prevBufferLen = 0;
|
|
821
821
|
}
|
|
822
822
|
}
|
|
823
823
|
};
|
|
824
|
-
|
|
825
|
-
var
|
|
824
|
+
M.protocol = 4;
|
|
825
|
+
var Be = class extends M {
|
|
826
826
|
constructor() {
|
|
827
827
|
super(...arguments), this._upgrades = [];
|
|
828
828
|
}
|
|
@@ -831,7 +831,7 @@ var ze = class extends N {
|
|
|
831
831
|
}
|
|
832
832
|
_probe(e) {
|
|
833
833
|
let t = this.createTransport(e), n = !1;
|
|
834
|
-
|
|
834
|
+
M.priorWebsocketSuccess = !1;
|
|
835
835
|
let r = () => {
|
|
836
836
|
n || (t.send([{
|
|
837
837
|
type: "ping",
|
|
@@ -840,7 +840,7 @@ var ze = class extends N {
|
|
|
840
840
|
if (!n) {
|
|
841
841
|
if (e.type === "pong" && e.data === "probe") {
|
|
842
842
|
if (this.upgrading = !0, this.emitReserved("upgrading", t), !t) return;
|
|
843
|
-
|
|
843
|
+
M.priorWebsocketSuccess = t.name === "websocket", this.transport.pause(() => {
|
|
844
844
|
n || this.readyState !== "closed" && (l(), this.setTransport(t), t.send([{ type: "upgrade" }]), this.emitReserved("upgrade", t), t = null, this.upgrading = !1, this.flush());
|
|
845
845
|
});
|
|
846
846
|
} else {
|
|
@@ -881,22 +881,22 @@ var ze = class extends N {
|
|
|
881
881
|
for (let n = 0; n < e.length; n++) ~this.transports.indexOf(e[n]) && t.push(e[n]);
|
|
882
882
|
return t;
|
|
883
883
|
}
|
|
884
|
-
},
|
|
884
|
+
}, N = class extends Be {
|
|
885
885
|
constructor(e, t = {}) {
|
|
886
886
|
let n = typeof e == "object", r = n ? { ...e } : { ...t };
|
|
887
887
|
(!r.transports || r.transports && typeof r.transports[0] == "string") && (r.transports = (r.transports || [
|
|
888
888
|
"polling",
|
|
889
889
|
"websocket",
|
|
890
890
|
"webtransport"
|
|
891
|
-
]).map((e) =>
|
|
891
|
+
]).map((e) => Fe[e]).filter((e) => !!e)), super(n ? r : e, r);
|
|
892
892
|
}
|
|
893
893
|
};
|
|
894
|
-
|
|
894
|
+
N.protocol;
|
|
895
895
|
//#endregion
|
|
896
896
|
//#region ../../node_modules/.pnpm/socket.io-client@4.8.4_supports-color@8.1.1/node_modules/socket.io-client/build/esm/url.js
|
|
897
897
|
function Ve(e, t = "", n) {
|
|
898
898
|
let r = e;
|
|
899
|
-
n ||= typeof location < "u" && location, e ??= n.protocol + "//" + n.host, typeof e == "string" && (e.charAt(0) === "/" && (e = e.charAt(1) === "/" ? n.protocol + e : n.host + e), /^(https?|wss?):\/\//.test(e) || (e = n === void 0 ? "https://" + e : n.protocol + "//" + e), r =
|
|
899
|
+
n ||= typeof location < "u" && location, e ??= n.protocol + "//" + n.host, typeof e == "string" && (e.charAt(0) === "/" && (e = e.charAt(1) === "/" ? n.protocol + e : n.host + e), /^(https?|wss?):\/\//.test(e) || (e = n === void 0 ? "https://" + e : n.protocol + "//" + e), r = k(e)), r.port || (/^(http|ws)$/.test(r.protocol) ? r.port = "80" : /^(http|ws)s$/.test(r.protocol) && (r.port = "443")), r.path = r.path || "/";
|
|
900
900
|
let i = r.host.indexOf(":") === -1 ? r.host : "[" + r.host + "]";
|
|
901
901
|
return r.id = r.protocol + "://" + i + ":" + r.port + t, r.href = r.protocol + "://" + i + (n && n.port === r.port ? "" : ":" + r.port), r;
|
|
902
902
|
}
|
|
@@ -967,7 +967,7 @@ var Je = /* @__PURE__ */ t({
|
|
|
967
967
|
Decoder: () => Xe,
|
|
968
968
|
Encoder: () => Ye,
|
|
969
969
|
PacketType: () => B,
|
|
970
|
-
isPacketValid: () =>
|
|
970
|
+
isPacketValid: () => nt,
|
|
971
971
|
protocol: () => 5
|
|
972
972
|
}), z = [
|
|
973
973
|
"connect",
|
|
@@ -1028,7 +1028,7 @@ var Ye = class {
|
|
|
1028
1028
|
let i = t.substring(e, n);
|
|
1029
1029
|
if (i != Number(i) || t.charAt(n) !== "-") throw Error("Illegal attachments");
|
|
1030
1030
|
let a = Number(i);
|
|
1031
|
-
if (
|
|
1031
|
+
if (!$e(a) || a < 1) throw Error("Illegal attachments");
|
|
1032
1032
|
if (a > this.opts.maxAttachments) throw Error("too many attachments");
|
|
1033
1033
|
r.attachments = a;
|
|
1034
1034
|
}
|
|
@@ -1066,9 +1066,9 @@ var Ye = class {
|
|
|
1066
1066
|
}
|
|
1067
1067
|
static isPayloadValid(e, t) {
|
|
1068
1068
|
switch (e) {
|
|
1069
|
-
case B.CONNECT: return
|
|
1069
|
+
case B.CONNECT: return V(t);
|
|
1070
1070
|
case B.DISCONNECT: return t === void 0;
|
|
1071
|
-
case B.CONNECT_ERROR: return typeof t == "string" ||
|
|
1071
|
+
case B.CONNECT_ERROR: return typeof t == "string" || V(t);
|
|
1072
1072
|
case B.EVENT:
|
|
1073
1073
|
case B.BINARY_EVENT: return Array.isArray(t) && (typeof t[0] == "number" || typeof t[0] == "string" && z.indexOf(t[0]) === -1);
|
|
1074
1074
|
case B.ACK:
|
|
@@ -1096,45 +1096,45 @@ var Ye = class {
|
|
|
1096
1096
|
function Qe(e) {
|
|
1097
1097
|
return typeof e == "string";
|
|
1098
1098
|
}
|
|
1099
|
-
var
|
|
1099
|
+
var $e = Number.isInteger || function(e) {
|
|
1100
1100
|
return typeof e == "number" && isFinite(e) && Math.floor(e) === e;
|
|
1101
1101
|
};
|
|
1102
|
-
function
|
|
1103
|
-
return e === void 0 ||
|
|
1102
|
+
function et(e) {
|
|
1103
|
+
return e === void 0 || $e(e);
|
|
1104
1104
|
}
|
|
1105
|
-
function
|
|
1105
|
+
function V(e) {
|
|
1106
1106
|
return Object.prototype.toString.call(e) === "[object Object]";
|
|
1107
1107
|
}
|
|
1108
|
-
function
|
|
1108
|
+
function tt(e, t) {
|
|
1109
1109
|
switch (e) {
|
|
1110
|
-
case B.CONNECT: return t === void 0 ||
|
|
1110
|
+
case B.CONNECT: return t === void 0 || V(t);
|
|
1111
1111
|
case B.DISCONNECT: return t === void 0;
|
|
1112
1112
|
case B.EVENT: return Array.isArray(t) && (typeof t[0] == "number" || typeof t[0] == "string" && z.indexOf(t[0]) === -1);
|
|
1113
1113
|
case B.ACK: return Array.isArray(t);
|
|
1114
|
-
case B.CONNECT_ERROR: return typeof t == "string" ||
|
|
1114
|
+
case B.CONNECT_ERROR: return typeof t == "string" || V(t);
|
|
1115
1115
|
default: return !1;
|
|
1116
1116
|
}
|
|
1117
1117
|
}
|
|
1118
|
-
function
|
|
1119
|
-
return Qe(e.nsp) &&
|
|
1118
|
+
function nt(e) {
|
|
1119
|
+
return Qe(e.nsp) && et(e.id) && tt(e.type, e.data);
|
|
1120
1120
|
}
|
|
1121
1121
|
//#endregion
|
|
1122
1122
|
//#region ../../node_modules/.pnpm/socket.io-client@4.8.4_supports-color@8.1.1/node_modules/socket.io-client/build/esm/on.js
|
|
1123
|
-
function
|
|
1123
|
+
function H(e, t, n) {
|
|
1124
1124
|
return e.on(t, n), function() {
|
|
1125
1125
|
e.off(t, n);
|
|
1126
1126
|
};
|
|
1127
1127
|
}
|
|
1128
1128
|
//#endregion
|
|
1129
1129
|
//#region ../../node_modules/.pnpm/socket.io-client@4.8.4_supports-color@8.1.1/node_modules/socket.io-client/build/esm/socket.js
|
|
1130
|
-
var
|
|
1130
|
+
var rt = Object.freeze({
|
|
1131
1131
|
connect: 1,
|
|
1132
1132
|
connect_error: 1,
|
|
1133
1133
|
disconnect: 1,
|
|
1134
1134
|
disconnecting: 1,
|
|
1135
1135
|
newListener: 1,
|
|
1136
1136
|
removeListener: 1
|
|
1137
|
-
}),
|
|
1137
|
+
}), it = class extends S {
|
|
1138
1138
|
constructor(e, t, n) {
|
|
1139
1139
|
super(), this.connected = !1, this.recovered = !1, this.receiveBuffer = [], this.sendBuffer = [], this._queue = [], this._queueSeq = 0, this.ids = 0, this.acks = {}, this.flags = {}, this.io = e, this.nsp = t, n && n.auth && (this.auth = n.auth), this._opts = Object.assign({}, n), this.io._autoConnect && this.open();
|
|
1140
1140
|
}
|
|
@@ -1145,10 +1145,10 @@ var nt = Object.freeze({
|
|
|
1145
1145
|
if (this.subs) return;
|
|
1146
1146
|
let e = this.io;
|
|
1147
1147
|
this.subs = [
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1148
|
+
H(e, "open", this.onopen.bind(this)),
|
|
1149
|
+
H(e, "packet", this.onpacket.bind(this)),
|
|
1150
|
+
H(e, "error", this.onerror.bind(this)),
|
|
1151
|
+
H(e, "close", this.onclose.bind(this))
|
|
1152
1152
|
];
|
|
1153
1153
|
}
|
|
1154
1154
|
get active() {
|
|
@@ -1164,7 +1164,7 @@ var nt = Object.freeze({
|
|
|
1164
1164
|
return e.unshift("message"), this.emit.apply(this, e), this;
|
|
1165
1165
|
}
|
|
1166
1166
|
emit(e, ...t) {
|
|
1167
|
-
if (
|
|
1167
|
+
if (rt.hasOwnProperty(e)) throw Error("\"" + e.toString() + "\" is a reserved event name");
|
|
1168
1168
|
if (t.unshift(e), this._opts.retries && !this.flags.fromQueue && !this.flags.volatile) return this._addToQueue(t), this;
|
|
1169
1169
|
let n = {
|
|
1170
1170
|
type: B.EVENT,
|
|
@@ -1365,30 +1365,30 @@ var nt = Object.freeze({
|
|
|
1365
1365
|
};
|
|
1366
1366
|
//#endregion
|
|
1367
1367
|
//#region ../../node_modules/.pnpm/socket.io-client@4.8.4_supports-color@8.1.1/node_modules/socket.io-client/build/esm/contrib/backo2.js
|
|
1368
|
-
function
|
|
1368
|
+
function U(e) {
|
|
1369
1369
|
e ||= {}, this.ms = e.min || 100, this.max = e.max || 1e4, this.factor = e.factor || 2, this.jitter = e.jitter > 0 && e.jitter <= 1 ? e.jitter : 0, this.attempts = 0;
|
|
1370
1370
|
}
|
|
1371
|
-
|
|
1371
|
+
U.prototype.duration = function() {
|
|
1372
1372
|
var e = this.ms * this.factor ** +this.attempts++;
|
|
1373
1373
|
if (this.jitter) {
|
|
1374
1374
|
var t = Math.random(), n = Math.floor(t * this.jitter * e);
|
|
1375
1375
|
e = Math.floor(t * 10) & 1 ? e + n : e - n;
|
|
1376
1376
|
}
|
|
1377
1377
|
return Math.min(e, this.max) | 0;
|
|
1378
|
-
},
|
|
1378
|
+
}, U.prototype.reset = function() {
|
|
1379
1379
|
this.attempts = 0;
|
|
1380
|
-
},
|
|
1380
|
+
}, U.prototype.setMin = function(e) {
|
|
1381
1381
|
this.ms = e;
|
|
1382
|
-
},
|
|
1382
|
+
}, U.prototype.setMax = function(e) {
|
|
1383
1383
|
this.max = e;
|
|
1384
|
-
},
|
|
1384
|
+
}, U.prototype.setJitter = function(e) {
|
|
1385
1385
|
this.jitter = e;
|
|
1386
1386
|
};
|
|
1387
1387
|
//#endregion
|
|
1388
1388
|
//#region ../../node_modules/.pnpm/socket.io-client@4.8.4_supports-color@8.1.1/node_modules/socket.io-client/build/esm/manager.js
|
|
1389
|
-
var
|
|
1389
|
+
var W = class extends S {
|
|
1390
1390
|
constructor(e, t) {
|
|
1391
|
-
super(), this.nsps = {}, this.subs = [], e && typeof e == "object" && (t = e, e = void 0), t ||= {}, t.path = t.path || "/socket.io", this.opts = t, T(this, t), this.reconnection(t.reconnection !== !1), this.reconnectionAttempts(t.reconnectionAttempts || Infinity), this.reconnectionDelay(t.reconnectionDelay || 1e3), this.reconnectionDelayMax(t.reconnectionDelayMax || 5e3), this.randomizationFactor(t.randomizationFactor ?? .5), this.backoff = new
|
|
1391
|
+
super(), this.nsps = {}, this.subs = [], e && typeof e == "object" && (t = e, e = void 0), t ||= {}, t.path = t.path || "/socket.io", this.opts = t, T(this, t), this.reconnection(t.reconnection !== !1), this.reconnectionAttempts(t.reconnectionAttempts || Infinity), this.reconnectionDelay(t.reconnectionDelay || 1e3), this.reconnectionDelayMax(t.reconnectionDelayMax || 5e3), this.randomizationFactor(t.randomizationFactor ?? .5), this.backoff = new U({
|
|
1392
1392
|
min: this.reconnectionDelay(),
|
|
1393
1393
|
max: this.reconnectionDelayMax(),
|
|
1394
1394
|
jitter: this.randomizationFactor()
|
|
@@ -1422,14 +1422,14 @@ var G = class extends S {
|
|
|
1422
1422
|
}
|
|
1423
1423
|
open(e) {
|
|
1424
1424
|
if (~this._readyState.indexOf("open")) return this;
|
|
1425
|
-
this.engine = new
|
|
1425
|
+
this.engine = new N(this.uri, this.opts);
|
|
1426
1426
|
let t = this.engine, n = this;
|
|
1427
1427
|
this._readyState = "opening", this.skipReconnect = !1;
|
|
1428
|
-
let r =
|
|
1428
|
+
let r = H(t, "open", function() {
|
|
1429
1429
|
n.onopen(), e && e();
|
|
1430
1430
|
}), i = (t) => {
|
|
1431
1431
|
this.cleanup(), this._readyState = "closed", this.emitReserved("error", t), e ? e(t) : this.maybeReconnectOnOpen();
|
|
1432
|
-
}, a =
|
|
1432
|
+
}, a = H(t, "error", i);
|
|
1433
1433
|
if (!1 !== this._timeout) {
|
|
1434
1434
|
let e = this._timeout, n = this.setTimeoutFn(() => {
|
|
1435
1435
|
r(), i(/* @__PURE__ */ Error("timeout")), t.close();
|
|
@@ -1446,7 +1446,7 @@ var G = class extends S {
|
|
|
1446
1446
|
onopen() {
|
|
1447
1447
|
this.cleanup(), this._readyState = "open", this.emitReserved("open");
|
|
1448
1448
|
let e = this.engine;
|
|
1449
|
-
this.subs.push(
|
|
1449
|
+
this.subs.push(H(e, "ping", this.onping.bind(this)), H(e, "data", this.ondata.bind(this)), H(e, "error", this.onerror.bind(this)), H(e, "close", this.onclose.bind(this)), H(this.decoder, "decoded", this.ondecoded.bind(this)));
|
|
1450
1450
|
}
|
|
1451
1451
|
onping() {
|
|
1452
1452
|
this.emitReserved("ping");
|
|
@@ -1468,7 +1468,7 @@ var G = class extends S {
|
|
|
1468
1468
|
}
|
|
1469
1469
|
socket(e, t) {
|
|
1470
1470
|
let n = this.nsps[e];
|
|
1471
|
-
return n ? this._autoConnect && !n.active && n.connect() : (n = new
|
|
1471
|
+
return n ? this._autoConnect && !n.active && n.connect() : (n = new it(this, e, t), this.nsps[e] = n), n;
|
|
1472
1472
|
}
|
|
1473
1473
|
_destroy(e) {
|
|
1474
1474
|
let t = Object.keys(this.nsps);
|
|
@@ -1513,21 +1513,21 @@ var G = class extends S {
|
|
|
1513
1513
|
let e = this.backoff.attempts;
|
|
1514
1514
|
this._reconnecting = !1, this.backoff.reset(), this.emitReserved("reconnect", e);
|
|
1515
1515
|
}
|
|
1516
|
-
},
|
|
1517
|
-
function
|
|
1516
|
+
}, G = {};
|
|
1517
|
+
function K(e, t) {
|
|
1518
1518
|
typeof e == "object" && (t = e, e = void 0), t ||= {};
|
|
1519
|
-
let n = Ve(e, t.path || "/socket.io"), r = n.source, i = n.id, a = n.path, o =
|
|
1520
|
-
return s ? c = new
|
|
1521
|
-
}
|
|
1522
|
-
Object.assign(
|
|
1523
|
-
Manager:
|
|
1524
|
-
Socket:
|
|
1525
|
-
io:
|
|
1526
|
-
connect:
|
|
1519
|
+
let n = Ve(e, t.path || "/socket.io"), r = n.source, i = n.id, a = n.path, o = G[i] && a in G[i].nsps, s = t.forceNew || t["force new connection"] || !1 === t.multiplex || o, c;
|
|
1520
|
+
return s ? c = new W(r, t) : (G[i] || (G[i] = new W(r, t)), c = G[i]), n.query && !t.query && (t.query = n.queryKey), c.socket(n.path, t);
|
|
1521
|
+
}
|
|
1522
|
+
Object.assign(K, {
|
|
1523
|
+
Manager: W,
|
|
1524
|
+
Socket: it,
|
|
1525
|
+
io: K,
|
|
1526
|
+
connect: K
|
|
1527
1527
|
});
|
|
1528
1528
|
//#endregion
|
|
1529
1529
|
//#region src/sdk-socket.ts
|
|
1530
|
-
function
|
|
1530
|
+
function at(e) {
|
|
1531
1531
|
let t = e.replace(/\/$/, "");
|
|
1532
1532
|
try {
|
|
1533
1533
|
return `${new URL(t).origin}/sdk`;
|
|
@@ -1535,7 +1535,7 @@ function it(e) {
|
|
|
1535
1535
|
return `${t}/sdk`;
|
|
1536
1536
|
}
|
|
1537
1537
|
}
|
|
1538
|
-
var
|
|
1538
|
+
var ot = class {
|
|
1539
1539
|
constructor() {
|
|
1540
1540
|
this.socket = null;
|
|
1541
1541
|
}
|
|
@@ -1544,8 +1544,8 @@ var at = class {
|
|
|
1544
1544
|
}
|
|
1545
1545
|
connect(e) {
|
|
1546
1546
|
this.disconnect();
|
|
1547
|
-
let t =
|
|
1548
|
-
this.socket =
|
|
1547
|
+
let t = at(e.baseUrl);
|
|
1548
|
+
this.socket = K(t, {
|
|
1549
1549
|
auth: {
|
|
1550
1550
|
apiKey: e.apiKey,
|
|
1551
1551
|
visitorToken: e.visitorToken
|
|
@@ -1568,41 +1568,41 @@ var at = class {
|
|
|
1568
1568
|
disconnect() {
|
|
1569
1569
|
this.socket &&= (this.socket.removeAllListeners(), this.socket.disconnect(), null);
|
|
1570
1570
|
}
|
|
1571
|
-
},
|
|
1572
|
-
function
|
|
1571
|
+
}, q = "onedeskpro_visitor_token";
|
|
1572
|
+
function st(e) {
|
|
1573
1573
|
try {
|
|
1574
1574
|
return typeof window < "u" ? window.localStorage.getItem(e) : null;
|
|
1575
1575
|
} catch {
|
|
1576
1576
|
return null;
|
|
1577
1577
|
}
|
|
1578
1578
|
}
|
|
1579
|
-
function
|
|
1579
|
+
function ct(e, t) {
|
|
1580
1580
|
try {
|
|
1581
1581
|
typeof window < "u" && window.localStorage.setItem(e, t);
|
|
1582
1582
|
} catch {}
|
|
1583
1583
|
}
|
|
1584
|
-
function
|
|
1584
|
+
function lt(e) {
|
|
1585
1585
|
try {
|
|
1586
1586
|
typeof window < "u" && window.localStorage.removeItem(e);
|
|
1587
1587
|
} catch {}
|
|
1588
1588
|
}
|
|
1589
|
-
var
|
|
1589
|
+
var ut = class {
|
|
1590
1590
|
constructor() {
|
|
1591
|
-
this.token = null, this.storageKey =
|
|
1591
|
+
this.token = null, this.storageKey = q;
|
|
1592
1592
|
}
|
|
1593
1593
|
setScope(e) {
|
|
1594
|
-
this.storageKey = e?.trim() ? `${
|
|
1594
|
+
this.storageKey = e?.trim() ? `${q}:${e.trim()}` : q, this.token = st(this.storageKey);
|
|
1595
1595
|
}
|
|
1596
1596
|
get() {
|
|
1597
|
-
return this.token ??
|
|
1597
|
+
return this.token ?? st(this.storageKey);
|
|
1598
1598
|
}
|
|
1599
1599
|
set(e) {
|
|
1600
|
-
this.token = e,
|
|
1600
|
+
this.token = e, ct(this.storageKey, e);
|
|
1601
1601
|
}
|
|
1602
1602
|
clear() {
|
|
1603
|
-
this.token = null,
|
|
1603
|
+
this.token = null, lt(this.storageKey);
|
|
1604
1604
|
}
|
|
1605
|
-
},
|
|
1605
|
+
}, J = [
|
|
1606
1606
|
{
|
|
1607
1607
|
iso: "BD",
|
|
1608
1608
|
name: "Bangladesh",
|
|
@@ -1969,8 +1969,8 @@ var lt = class {
|
|
|
1969
1969
|
dial: "977",
|
|
1970
1970
|
flag: "🇳🇵"
|
|
1971
1971
|
}
|
|
1972
|
-
],
|
|
1973
|
-
function
|
|
1972
|
+
], dt = J.find((e) => e.iso === "BD") ?? J[0];
|
|
1973
|
+
function ft(e, t) {
|
|
1974
1974
|
let n = t.trim();
|
|
1975
1975
|
if (n.startsWith("+")) {
|
|
1976
1976
|
let e = n.replace(/\D/g, "");
|
|
@@ -1981,7 +1981,7 @@ function dt(e, t) {
|
|
|
1981
1981
|
}
|
|
1982
1982
|
//#endregion
|
|
1983
1983
|
//#region src/widget/styles.ts
|
|
1984
|
-
function
|
|
1984
|
+
function pt(e, t) {
|
|
1985
1985
|
let n = `
|
|
1986
1986
|
--ttcb-bg: #ffffff;
|
|
1987
1987
|
--ttcb-bg-secondary: #f3f4f6;
|
|
@@ -2194,21 +2194,6 @@ function ft(e, t) {
|
|
|
2194
2194
|
}
|
|
2195
2195
|
@keyframes ttcb-spin { to { transform: rotate(360deg); } }
|
|
2196
2196
|
|
|
2197
|
-
.ttcb-blocked {
|
|
2198
|
-
display: flex; flex-direction: column; align-items: center;
|
|
2199
|
-
justify-content: center; text-align: center;
|
|
2200
|
-
padding: 32px 20px; flex: 1;
|
|
2201
|
-
}
|
|
2202
|
-
.ttcb-blocked-icon {
|
|
2203
|
-
width: 44px; height: 44px; border-radius: 50%;
|
|
2204
|
-
background: var(--ttcb-bg-secondary);
|
|
2205
|
-
display: flex; align-items: center; justify-content: center;
|
|
2206
|
-
margin-bottom: 14px;
|
|
2207
|
-
}
|
|
2208
|
-
.ttcb-blocked-icon svg { width: 20px; height: 20px; fill: var(--ttcb-text-muted); }
|
|
2209
|
-
.ttcb-blocked-title { font-size: 14px; font-weight: 600; color: var(--ttcb-text); margin-bottom: 8px; }
|
|
2210
|
-
.ttcb-blocked-desc { font-size: 12px; color: var(--ttcb-text-muted); line-height: 1.5; max-width: 220px; }
|
|
2211
|
-
|
|
2212
2197
|
.ttcb-msg { display: flex; gap: 8px; max-width: 100%; }
|
|
2213
2198
|
.ttcb-msg.human { flex-direction: row-reverse; }
|
|
2214
2199
|
.ttcb-msg-body { display: flex; flex-direction: column; gap: 3px; max-width: 78%; }
|
|
@@ -2492,18 +2477,18 @@ function ft(e, t) {
|
|
|
2492
2477
|
}
|
|
2493
2478
|
//#endregion
|
|
2494
2479
|
//#region src/widget/render.ts
|
|
2495
|
-
function
|
|
2480
|
+
function Y(e) {
|
|
2496
2481
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
2497
2482
|
}
|
|
2498
|
-
function
|
|
2483
|
+
function mt(e) {
|
|
2499
2484
|
let t = [], n = e.replace(/```[\w]*\n?([\s\S]*?)```/g, (e, n) => {
|
|
2500
2485
|
let r = t.length;
|
|
2501
|
-
return t.push(`<pre><code>${
|
|
2486
|
+
return t.push(`<pre><code>${Y(n.trim())}</code></pre>`), `\x04${r}\x05`;
|
|
2502
2487
|
});
|
|
2503
2488
|
n = n.replace(/`([^`\n]+)`/g, (e, n) => {
|
|
2504
2489
|
let r = t.length;
|
|
2505
|
-
return t.push(`<code>${
|
|
2506
|
-
}), n =
|
|
2490
|
+
return t.push(`<code>${Y(n)}</code>`), `\x02${r}\x03`;
|
|
2491
|
+
}), n = Y(n);
|
|
2507
2492
|
let r = n.split("\n"), i = [], a = "", o = () => {
|
|
2508
2493
|
a &&= (i.push(`</${a}>`), "");
|
|
2509
2494
|
};
|
|
@@ -2520,95 +2505,92 @@ function pt(e) {
|
|
|
2520
2505
|
}).join("") : "";
|
|
2521
2506
|
}).filter(Boolean).join(""), n = n.replace(/\x04(\d+)\x05/g, (e, n) => t[+n] ?? "").replace(/\x02(\d+)\x03/g, (e, n) => t[+n] ?? ""), n;
|
|
2522
2507
|
}
|
|
2523
|
-
function mt() {
|
|
2524
|
-
return "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M19.43 12.98c.04-.32.07-.64.07-.98s-.03-.66-.07-.98l2.11-1.65c.19-.15.24-.42.12-.64l-2-3.46c-.12-.22-.39-.3-.61-.22l-2.49 1c-.52-.4-1.08-.73-1.69-.98l-.38-2.65C14.46 2.18 14.25 2 14 2h-4c-.25 0-.46.18-.49.42l-.38 2.65c-.61.25-1.17.59-1.69.98l-2.49-1c-.23-.09-.49 0-.61.22l-2 3.46c-.13.22-.07.49.12.64l2.11 1.65c-.04.32-.07.65-.07.98s.03.66.07.98l-2.11 1.65c-.19.15-.24.42-.12.64l2 3.46c.12.22.39.3.61.22l2.49-1c.52.4 1.08.73 1.69.98l.38 2.65c.03.24.24.42.49.42h4c.25 0 .46-.18.49-.42l.38-2.65c.61-.25 1.17-.59 1.69-.98l2.49 1c.23.09.49 0 .61-.22l2-3.46c.12-.22.07-.49-.12-.64l-2.11-1.65zM12 15.5c-1.93 0-3.5-1.57-3.5-3.5s1.57-3.5 3.5-3.5 3.5 1.57 3.5 3.5-1.57 3.5-3.5 3.5z\"/>\n </svg>";
|
|
2525
|
-
}
|
|
2526
2508
|
function ht() {
|
|
2527
|
-
return "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z\"/>\n </svg>";
|
|
2528
|
-
}
|
|
2529
|
-
function gt() {
|
|
2530
2509
|
return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z\"/>\n <line x1=\"12\" y1=\"8\" x2=\"12\" y2=\"14\"/>\n <line x1=\"9\" y1=\"11\" x2=\"15\" y2=\"11\"/>\n </svg>";
|
|
2531
2510
|
}
|
|
2532
|
-
function
|
|
2511
|
+
function gt() {
|
|
2533
2512
|
return "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M20 2H4C2.9 2 2 2.9 2 4v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2z\"/>\n </svg>";
|
|
2534
2513
|
}
|
|
2535
|
-
function
|
|
2514
|
+
function _t() {
|
|
2536
2515
|
return "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z\"/>\n </svg>";
|
|
2537
2516
|
}
|
|
2538
|
-
function
|
|
2517
|
+
function vt() {
|
|
2539
2518
|
return "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M2.01 21L23 12 2.01 3 2 10l15 2-15 2z\"/>\n </svg>";
|
|
2540
2519
|
}
|
|
2541
|
-
function
|
|
2520
|
+
function X() {
|
|
2542
2521
|
return "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M20 9V7c0-1.1-.9-2-2-2h-3c0-1.66-1.34-3-3-3S9 3.34 9 5H6c-1.1 0-2 .9-2 2v2c-1.66 0-3 1.34-3 3s1.34 3 3 3v4c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-4c1.66 0 3-1.34 3-3s-1.34-3-3-3zm-2 10H6V7h12v12zm-9-6c-.83 0-1.5-.67-1.5-1.5S8.17 10 9 10s1.5.67 1.5 1.5S9.83 13 9 13zm6 0c-.83 0-1.5-.67-1.5-1.5S14.17 10 15 10s1.5.67 1.5 1.5S15.83 13 15 13z\"/>\n </svg>";
|
|
2543
2522
|
}
|
|
2544
|
-
function
|
|
2523
|
+
function yt() {
|
|
2545
2524
|
return "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z\"/>\n </svg>";
|
|
2546
2525
|
}
|
|
2547
|
-
function
|
|
2526
|
+
function bt() {
|
|
2548
2527
|
return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2\"/>\n <circle cx=\"12\" cy=\"7\" r=\"4\"/>\n </svg>";
|
|
2549
2528
|
}
|
|
2550
|
-
function
|
|
2529
|
+
function xt() {
|
|
2551
2530
|
return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z\"/>\n <polyline points=\"22,6 12,13 2,6\"/>\n </svg>";
|
|
2552
2531
|
}
|
|
2553
|
-
function
|
|
2532
|
+
function St() {
|
|
2554
2533
|
return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <polyline points=\"6 9 12 15 18 9\"/>\n </svg>";
|
|
2555
2534
|
}
|
|
2556
|
-
function
|
|
2535
|
+
function Ct() {
|
|
2557
2536
|
return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"/>\n <polyline points=\"12 5 19 12 12 19\"/>\n </svg>";
|
|
2558
2537
|
}
|
|
2559
|
-
function
|
|
2538
|
+
function wt() {
|
|
2560
2539
|
return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z\"/>\n <polyline points=\"9 12 11 14 15 10\"/>\n </svg>";
|
|
2561
2540
|
}
|
|
2562
|
-
function
|
|
2541
|
+
function Tt() {
|
|
2563
2542
|
return "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <circle cx=\"12\" cy=\"12\" r=\"10\" fill=\"currentColor\"/>\n <path d=\"M9 12l2 2 4-4\" fill=\"none\" stroke=\"#fff\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n </svg>";
|
|
2564
2543
|
}
|
|
2565
|
-
function
|
|
2544
|
+
function Et() {
|
|
2566
2545
|
return "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path fill=\"#F59E0B\" d=\"M8 2.5l1.1 2.2 2.4.3-1.7 1.7.4 2.4L8 8l-2.2 1.1.4-2.4L4.5 5l2.4-.3L8 2.5z\"/>\n <path fill=\"#F59E0B\" d=\"M16 3.5l.8 1.6 1.8.2-1.3 1.3.3 1.8L16 7.5l-1.6.9.3-1.8-1.3-1.3 1.8-.2L16 3.5z\"/>\n <path fill=\"#FBBF24\" d=\"M12 11.5l1 2 2.2.3-1.6 1.6.4 2.2-2-1.1-2 1.1.4-2.2-1.6-1.6 2.2-.3 1-2z\"/>\n </svg>";
|
|
2567
2546
|
}
|
|
2568
|
-
function
|
|
2547
|
+
function Dt() {
|
|
2569
2548
|
return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2\"/>\n <circle cx=\"9\" cy=\"7\" r=\"4\"/>\n <path d=\"M23 21v-2a4 4 0 0 0-3-3.87\"/>\n <path d=\"M16 3.13a4 4 0 0 1 0 7.75\"/>\n </svg>";
|
|
2570
2549
|
}
|
|
2571
|
-
function
|
|
2550
|
+
function Ot(e, t) {
|
|
2572
2551
|
let n = document.createElement("div");
|
|
2573
2552
|
n.className = `ttcb-msg ${t}`;
|
|
2574
2553
|
let r = document.createElement("div");
|
|
2575
|
-
r.className = "ttcb-msg-avatar", r.innerHTML = t === "human" ?
|
|
2554
|
+
r.className = "ttcb-msg-avatar", r.innerHTML = t === "human" ? yt() : t === "agent" ? bt() : X();
|
|
2576
2555
|
let i = document.createElement("div");
|
|
2577
2556
|
if (i.className = "ttcb-msg-body", t === "agent") {
|
|
2578
2557
|
let e = document.createElement("span");
|
|
2579
2558
|
e.className = "ttcb-msg-label", e.textContent = "Agent", i.appendChild(e);
|
|
2580
2559
|
}
|
|
2581
2560
|
let a = document.createElement("div");
|
|
2582
|
-
return a.className = "ttcb-bubble", t === "human" ? a.textContent = e : a.innerHTML =
|
|
2561
|
+
return a.className = "ttcb-bubble", t === "human" ? a.textContent = e : a.innerHTML = mt(e), i.appendChild(a), n.appendChild(r), n.appendChild(i), n;
|
|
2583
2562
|
}
|
|
2584
|
-
function
|
|
2563
|
+
function kt() {
|
|
2585
2564
|
let e = document.createElement("div");
|
|
2586
2565
|
e.className = "ttcb-msg ai", e.id = "ttcb-typing";
|
|
2587
2566
|
let t = document.createElement("div");
|
|
2588
|
-
t.className = "ttcb-msg-avatar", t.innerHTML =
|
|
2567
|
+
t.className = "ttcb-msg-avatar", t.innerHTML = X();
|
|
2589
2568
|
let n = document.createElement("div");
|
|
2590
2569
|
return n.className = "ttcb-typing", n.innerHTML = "<span></span><span></span><span></span>", e.appendChild(t), e.appendChild(n), e;
|
|
2591
2570
|
}
|
|
2592
2571
|
//#endregion
|
|
2593
2572
|
//#region src/widget/widget.ts
|
|
2594
|
-
var
|
|
2573
|
+
var At = class {
|
|
2595
2574
|
constructor(e, t) {
|
|
2596
|
-
this.selectedCountry =
|
|
2575
|
+
this.selectedCountry = dt, this.countryOpen = !1, this.isOpen = !1, this.destroyed = !1, this.position = e.position ?? "bottom-right", this.callbacks = t, this.autoOpen = e.autoOpen === !0, this.mount(e);
|
|
2597
2576
|
}
|
|
2598
2577
|
mount(e) {
|
|
2599
|
-
this.host = document.createElement("div"), this.host.id = "onedeskpro-chatbot-host", this.shadow = this.host.attachShadow({ mode: "closed" });
|
|
2578
|
+
this.host = document.createElement("div"), this.host.id = "onedeskpro-chatbot-host", this.host.style.display = "none", this.shadow = this.host.attachShadow({ mode: "closed" });
|
|
2600
2579
|
let t = document.createElement("style");
|
|
2601
|
-
t.textContent =
|
|
2580
|
+
t.textContent = pt(e.primaryColor ?? "#2563EB", e.theme ?? "auto"), this.shadow.appendChild(t);
|
|
2602
2581
|
let n = document.createElement("button");
|
|
2603
|
-
n.className = `ttcb-fab ${this.position}`, n.setAttribute("aria-label", "Open chat"), n.innerHTML =
|
|
2582
|
+
n.className = `ttcb-fab ${this.position}`, n.setAttribute("aria-label", "Open chat"), n.innerHTML = gt(), n.addEventListener("click", () => this.toggle()), this.shadow.appendChild(n), this.panel = document.createElement("div"), this.panel.className = `ttcb-panel ${this.position} hidden ttcb-mode-compact`, this.panel.setAttribute("role", "dialog"), this.panel.setAttribute("aria-modal", "true"), this.panel.setAttribute("aria-label", e.chatbotName ?? "AI Assistant"), this.panel.appendChild(this.buildHeader(e)), this.identifyContainer = document.createElement("div"), this.identifyContainer.className = "ttcb-identify", this.buildIdentifyForm(this.identifyContainer), this.panel.appendChild(this.identifyContainer), this.messagesContainer = document.createElement("div"), this.messagesContainer.className = "ttcb-messages", this.messagesContainer.setAttribute("aria-live", "polite"), this.messagesContainer.setAttribute("aria-label", "Chat messages"), this.panel.appendChild(this.messagesContainer), this.modeBanner = document.createElement("div"), this.modeBanner.className = "ttcb-mode-banner", this.modeBanner.setAttribute("role", "status"), this.panel.appendChild(this.modeBanner), this.footer = document.createElement("div"), this.footer.className = "ttcb-footer";
|
|
2604
2583
|
let r = document.createElement("form");
|
|
2605
2584
|
r.className = "ttcb-form", r.addEventListener("submit", (e) => {
|
|
2606
2585
|
e.preventDefault(), this.handleSend();
|
|
2607
|
-
}), this.input = document.createElement("input"), this.input.type = "text", this.input.className = "ttcb-input", this.input.placeholder = e.placeholder ?? "Type your message…", this.input.setAttribute("aria-label", "Message input"), this.input.setAttribute("autocomplete", "off"), this.sendBtn = document.createElement("button"), this.sendBtn.type = "submit", this.sendBtn.className = "ttcb-send-btn", this.sendBtn.innerHTML =
|
|
2586
|
+
}), this.input = document.createElement("input"), this.input.type = "text", this.input.className = "ttcb-input", this.input.placeholder = e.placeholder ?? "Type your message…", this.input.setAttribute("aria-label", "Message input"), this.input.setAttribute("autocomplete", "off"), this.sendBtn = document.createElement("button"), this.sendBtn.type = "submit", this.sendBtn.className = "ttcb-send-btn", this.sendBtn.innerHTML = vt(), this.sendBtn.setAttribute("aria-label", "Send message"), r.appendChild(this.input), r.appendChild(this.sendBtn), this.footer.appendChild(r), this.panel.appendChild(this.footer), this.shadow.appendChild(this.panel), this.shadow.addEventListener("click", (e) => {
|
|
2608
2587
|
if (!this.countryOpen) return;
|
|
2609
2588
|
let t = e.target;
|
|
2610
2589
|
t && (this.dialBtn.contains(t) || this.countryPopover.contains(t)) || this.closeCountryPopover();
|
|
2611
|
-
}), this.attachToDocument(), this.showInitialLoading()
|
|
2590
|
+
}), this.attachToDocument(), this.showInitialLoading();
|
|
2591
|
+
}
|
|
2592
|
+
reveal() {
|
|
2593
|
+
this.host.style.removeProperty("display"), this.autoOpen && !this.isOpen && this.open();
|
|
2612
2594
|
}
|
|
2613
2595
|
buildHeader(e) {
|
|
2614
2596
|
let t = document.createElement("div");
|
|
@@ -2616,13 +2598,13 @@ var jt = class {
|
|
|
2616
2598
|
let n = document.createElement("div");
|
|
2617
2599
|
n.className = "ttcb-avatar-wrap";
|
|
2618
2600
|
let r = document.createElement("div");
|
|
2619
|
-
r.className = "ttcb-avatar", r.innerHTML =
|
|
2601
|
+
r.className = "ttcb-avatar", r.innerHTML = X(), n.appendChild(r);
|
|
2620
2602
|
let i = document.createElement("div");
|
|
2621
2603
|
i.className = "ttcb-header-main";
|
|
2622
2604
|
let a = document.createElement("div");
|
|
2623
2605
|
a.className = "ttcb-header-title-row", this.headerTitle = document.createElement("span"), this.headerTitle.className = "ttcb-header-title", this.headerTitle.textContent = e.chatbotName ?? "AI Assistant";
|
|
2624
2606
|
let o = document.createElement("span");
|
|
2625
|
-
o.className = "ttcb-verified", o.setAttribute("aria-label", "Verified"), o.innerHTML =
|
|
2607
|
+
o.className = "ttcb-verified", o.setAttribute("aria-label", "Verified"), o.innerHTML = Tt(), a.appendChild(this.headerTitle), a.appendChild(o);
|
|
2626
2608
|
let s = document.createElement("div");
|
|
2627
2609
|
s.className = "ttcb-header-meta";
|
|
2628
2610
|
let c = document.createElement("span");
|
|
@@ -2630,11 +2612,11 @@ var jt = class {
|
|
|
2630
2612
|
let l = document.createElement("span");
|
|
2631
2613
|
l.className = "ttcb-meta-sep", l.setAttribute("aria-hidden", "true");
|
|
2632
2614
|
let u = document.createElement("span");
|
|
2633
|
-
u.className = "ttcb-meta-replies", u.innerHTML = `${
|
|
2615
|
+
u.className = "ttcb-meta-replies", u.innerHTML = `${Et()}<span>Replies instantly</span>`, s.appendChild(c), s.appendChild(l), s.appendChild(u), i.appendChild(a), i.appendChild(s);
|
|
2634
2616
|
let d = document.createElement("div");
|
|
2635
|
-
d.className = "ttcb-header-actions", this.requestHumanBtn = document.createElement("button"), this.requestHumanBtn.type = "button", this.requestHumanBtn.className = "ttcb-request-human-btn hidden", this.requestHumanBtn.id = "ttcb-request-human-btn", this.requestHumanBtn.setAttribute("aria-label", "Request human agent"), this.requestHumanBtn.title = "Request human agent", this.requestHumanBtn.innerHTML =
|
|
2617
|
+
d.className = "ttcb-header-actions", this.requestHumanBtn = document.createElement("button"), this.requestHumanBtn.type = "button", this.requestHumanBtn.className = "ttcb-request-human-btn hidden", this.requestHumanBtn.id = "ttcb-request-human-btn", this.requestHumanBtn.setAttribute("aria-label", "Request human agent"), this.requestHumanBtn.title = "Request human agent", this.requestHumanBtn.innerHTML = Dt(), this.requestHumanBtn.addEventListener("click", () => this.callbacks.onRequestHuman()), this.newSessionBtn = document.createElement("button"), this.newSessionBtn.className = "ttcb-new-session-btn hidden", this.newSessionBtn.setAttribute("aria-label", "New conversation"), this.newSessionBtn.title = "New conversation", this.newSessionBtn.innerHTML = ht(), this.newSessionBtn.addEventListener("click", () => this.callbacks.onReset());
|
|
2636
2618
|
let f = document.createElement("button");
|
|
2637
|
-
return f.className = "ttcb-close-btn", f.setAttribute("aria-label", "Close chat"), f.innerHTML =
|
|
2619
|
+
return f.className = "ttcb-close-btn", f.setAttribute("aria-label", "Close chat"), f.innerHTML = _t(), f.addEventListener("click", () => this.close()), d.appendChild(this.requestHumanBtn), d.appendChild(this.newSessionBtn), d.appendChild(f), t.appendChild(n), t.appendChild(i), t.appendChild(d), t;
|
|
2638
2620
|
}
|
|
2639
2621
|
setPanelMode(e) {
|
|
2640
2622
|
this.panel.classList.remove("ttcb-mode-form", "ttcb-mode-chat", "ttcb-mode-compact"), this.panel.classList.add(`ttcb-mode-${e}`), e !== "chat" && (this.requestHumanBtn.classList.add("hidden"), this.newSessionBtn.classList.add("hidden"), this.hideModeBanner());
|
|
@@ -2651,7 +2633,7 @@ var jt = class {
|
|
|
2651
2633
|
placeholder: "Your name",
|
|
2652
2634
|
type: "text",
|
|
2653
2635
|
autocomplete: "name",
|
|
2654
|
-
icon:
|
|
2636
|
+
icon: bt()
|
|
2655
2637
|
}), this.createPhoneField(t), this.emailInput = this.createIconField(t, {
|
|
2656
2638
|
id: "email",
|
|
2657
2639
|
label: "Email (optional)",
|
|
@@ -2660,10 +2642,10 @@ var jt = class {
|
|
|
2660
2642
|
placeholder: "Email (optional)",
|
|
2661
2643
|
type: "email",
|
|
2662
2644
|
autocomplete: "email",
|
|
2663
|
-
icon:
|
|
2664
|
-
}), this.identifyError = document.createElement("p"), this.identifyError.className = "ttcb-identify-error", t.appendChild(this.identifyError), this.identifySubmit = document.createElement("button"), this.identifySubmit.type = "submit", this.identifySubmit.className = "ttcb-identify-submit", this.identifySubmit.innerHTML = `<span>Start Chatting</span>${
|
|
2645
|
+
icon: xt()
|
|
2646
|
+
}), this.identifyError = document.createElement("p"), this.identifyError.className = "ttcb-identify-error", t.appendChild(this.identifyError), this.identifySubmit = document.createElement("button"), this.identifySubmit.type = "submit", this.identifySubmit.className = "ttcb-identify-submit", this.identifySubmit.innerHTML = `<span>Start Chatting</span>${Ct()}`, t.appendChild(this.identifySubmit), e.appendChild(t);
|
|
2665
2647
|
let n = document.createElement("div");
|
|
2666
|
-
n.className = "ttcb-trust", n.innerHTML = `${
|
|
2648
|
+
n.className = "ttcb-trust", n.innerHTML = `${wt()}<span>Encrypted connection • No spam, ever</span>`, e.appendChild(n);
|
|
2667
2649
|
}
|
|
2668
2650
|
createIconField(e, t) {
|
|
2669
2651
|
let n = document.createElement("div");
|
|
@@ -2693,7 +2675,7 @@ var jt = class {
|
|
|
2693
2675
|
let a = document.createElement("div");
|
|
2694
2676
|
a.className = "ttcb-phone-row", a.id = "ttcb-phone-row", this.dialBtn = document.createElement("button"), this.dialBtn.type = "button", this.dialBtn.className = "ttcb-dial-btn", this.dialBtn.setAttribute("aria-label", "Select country code"), this.dialBtn.setAttribute("aria-haspopup", "listbox"), this.dialBtn.setAttribute("aria-expanded", "false"), this.dialFlag = document.createElement("span"), this.dialFlag.className = "ttcb-dial-flag", this.dialCode = document.createElement("span"), this.dialCode.className = "ttcb-dial-code", this.syncDialButton(), this.dialBtn.appendChild(this.dialFlag), this.dialBtn.appendChild(this.dialCode);
|
|
2695
2677
|
let o = document.createElement("span");
|
|
2696
|
-
o.setAttribute("aria-hidden", "true"), o.innerHTML =
|
|
2678
|
+
o.setAttribute("aria-hidden", "true"), o.innerHTML = St(), this.dialBtn.appendChild(o), this.dialBtn.addEventListener("click", (e) => {
|
|
2697
2679
|
e.preventDefault(), e.stopPropagation(), this.toggleCountryPopover();
|
|
2698
2680
|
}), this.phoneInput = document.createElement("input"), this.phoneInput.id = "ttcb-tel", this.phoneInput.name = "tel", this.phoneInput.type = "tel", this.phoneInput.className = "ttcb-phone-national", this.phoneInput.placeholder = "1712-345678", this.phoneInput.required = !0, this.phoneInput.autocomplete = "tel-national", this.phoneInput.setAttribute("inputmode", "tel"), a.appendChild(this.dialBtn), a.appendChild(this.phoneInput), this.countryPopover = document.createElement("div"), this.countryPopover.className = "ttcb-country-popover", this.countryPopover.setAttribute("role", "listbox"), this.countrySearch = document.createElement("input"), this.countrySearch.type = "search", this.countrySearch.className = "ttcb-country-search", this.countrySearch.placeholder = "Search country…", this.countrySearch.setAttribute("aria-label", "Search countries"), this.countrySearch.addEventListener("input", () => this.renderCountryList()), this.countryList = document.createElement("div"), this.countryList.className = "ttcb-country-list", this.countryPopover.appendChild(this.countrySearch), this.countryPopover.appendChild(this.countryList), this.renderCountryList(), t.appendChild(n), t.appendChild(a), t.appendChild(this.countryPopover), e.appendChild(t);
|
|
2699
2681
|
}
|
|
@@ -2710,7 +2692,7 @@ var jt = class {
|
|
|
2710
2692
|
this.countryOpen = !1, this.countryPopover.classList.remove("open"), this.dialBtn.setAttribute("aria-expanded", "false");
|
|
2711
2693
|
}
|
|
2712
2694
|
renderCountryList() {
|
|
2713
|
-
let e = this.countrySearch.value.trim().toLowerCase(), t =
|
|
2695
|
+
let e = this.countrySearch.value.trim().toLowerCase(), t = J.filter((t) => !e || t.name.toLowerCase().includes(e) || t.dial.includes(e) || t.iso.toLowerCase().includes(e) || `+${t.dial}`.includes(e));
|
|
2714
2696
|
this.countryList.innerHTML = "";
|
|
2715
2697
|
for (let e of t) {
|
|
2716
2698
|
let t = document.createElement("button");
|
|
@@ -2742,7 +2724,7 @@ var jt = class {
|
|
|
2742
2724
|
let t = document.createElement("div");
|
|
2743
2725
|
t.className = "ttcb-empty", t.id = "ttcb-empty";
|
|
2744
2726
|
let n = document.createElement("div");
|
|
2745
|
-
n.className = "ttcb-empty-icon", n.innerHTML =
|
|
2727
|
+
n.className = "ttcb-empty-icon", n.innerHTML = X();
|
|
2746
2728
|
let r = document.createElement("p"), i = document.createElement("strong");
|
|
2747
2729
|
i.textContent = e, r.appendChild(document.createTextNode("Welcome to ")), r.appendChild(i);
|
|
2748
2730
|
let a = document.createElement("p");
|
|
@@ -2757,7 +2739,7 @@ var jt = class {
|
|
|
2757
2739
|
e && !this.sendBtn.disabled && (this.input.value = "", this.callbacks.onSend(e), this.input.focus());
|
|
2758
2740
|
}
|
|
2759
2741
|
handleIdentifySubmit() {
|
|
2760
|
-
let e = this.nameInput.value.trim(), t =
|
|
2742
|
+
let e = this.nameInput.value.trim(), t = ft(this.selectedCountry.dial, this.phoneInput.value), n = this.emailInput.value.trim();
|
|
2761
2743
|
!e || !t ? this.showIdentifyError("Name and phone are required.") : (this.showIdentifyError(""), this.callbacks.onIdentify({
|
|
2762
2744
|
name: e,
|
|
2763
2745
|
phone: t,
|
|
@@ -2766,20 +2748,20 @@ var jt = class {
|
|
|
2766
2748
|
}
|
|
2767
2749
|
appendMessage(e) {
|
|
2768
2750
|
this.removeEmptyState();
|
|
2769
|
-
let t = "message" in e ? e.message : e, n =
|
|
2751
|
+
let t = "message" in e ? e.message : e, n = Ot(t.content, t.type);
|
|
2770
2752
|
this.messagesContainer.appendChild(n), this.scrollToBottom();
|
|
2771
2753
|
}
|
|
2772
2754
|
setMessages(e) {
|
|
2773
2755
|
if (this.messagesContainer.innerHTML = "", e.length !== 0) {
|
|
2774
2756
|
for (let t of e) {
|
|
2775
|
-
let e =
|
|
2757
|
+
let e = Ot(t.message.content, t.message.type);
|
|
2776
2758
|
this.messagesContainer.appendChild(e);
|
|
2777
2759
|
}
|
|
2778
2760
|
this.scrollToBottom();
|
|
2779
2761
|
}
|
|
2780
2762
|
}
|
|
2781
2763
|
setLoading(e) {
|
|
2782
|
-
if (this.sendBtn.disabled = e || this.input.disabled, e) this.shadow.getElementById("ttcb-typing") || (this.messagesContainer.appendChild(
|
|
2764
|
+
if (this.sendBtn.disabled = e || this.input.disabled, e) this.shadow.getElementById("ttcb-typing") || (this.messagesContainer.appendChild(kt()), this.scrollToBottom()), this.input.focus();
|
|
2783
2765
|
else {
|
|
2784
2766
|
let e = this.shadow.getElementById("ttcb-typing");
|
|
2785
2767
|
e && e.remove(), this.input.disabled || this.input.focus();
|
|
@@ -2788,7 +2770,7 @@ var jt = class {
|
|
|
2788
2770
|
setIdentifyLoading(e) {
|
|
2789
2771
|
this.identifySubmit.disabled = e, this.nameInput.disabled = e, this.phoneInput.disabled = e, this.emailInput.disabled = e, this.dialBtn.disabled = e, this.shadow.getElementById("ttcb-phone-row")?.classList.toggle("disabled", e);
|
|
2790
2772
|
for (let t of this.identifyContainer.querySelectorAll(".ttcb-input-wrap")) t.classList.toggle("disabled", e);
|
|
2791
|
-
this.identifySubmit.innerHTML = e ? "<span>Starting…</span>" : `<span>Start Chatting</span>${
|
|
2773
|
+
this.identifySubmit.innerHTML = e ? "<span>Starting…</span>" : `<span>Start Chatting</span>${Ct()}`, e && this.closeCountryPopover();
|
|
2792
2774
|
}
|
|
2793
2775
|
showIdentifyError(e) {
|
|
2794
2776
|
this.identifyError.textContent = e;
|
|
@@ -2811,17 +2793,6 @@ var jt = class {
|
|
|
2811
2793
|
content: e.welcomeMessage
|
|
2812
2794
|
}) : this.showEmptyState(e.chatbotName ?? "AI Assistant"), this.setMode("ai");
|
|
2813
2795
|
}
|
|
2814
|
-
showBlocked(e, t) {
|
|
2815
|
-
this.setPanelMode("compact"), this.closeCountryPopover(), this.identifyContainer.classList.remove("visible"), this.messagesContainer.classList.remove("hidden"), this.footer.classList.add("hidden"), this.messagesContainer.innerHTML = "";
|
|
2816
|
-
let n = document.createElement("div");
|
|
2817
|
-
n.className = "ttcb-blocked";
|
|
2818
|
-
let r = document.createElement("div");
|
|
2819
|
-
r.className = "ttcb-blocked-icon";
|
|
2820
|
-
let i = document.createElement("p");
|
|
2821
|
-
i.className = "ttcb-blocked-title";
|
|
2822
|
-
let a = document.createElement("p");
|
|
2823
|
-
a.className = "ttcb-blocked-desc", e === "no-prompt" ? (r.innerHTML = ht(), i.textContent = "Business Context Required", a.textContent = t ?? "Add a system prompt for this agent in the admin panel.") : e === "no-agent" ? (r.innerHTML = mt(), i.textContent = "Channel Not Connected", a.textContent = t ?? "Connect this Website channel under AI Agents → Connected Channels.") : e === "no-directories" || e === "no-collections" ? (r.innerHTML = ht(), i.textContent = "Knowledge Base Required", a.textContent = t ?? "Assign at least one knowledge-base collection to this agent in the admin panel.") : (r.innerHTML = mt(), i.textContent = "Chatbot Settings Required", a.textContent = t ?? "The chatbot has not been configured yet. Please set it up in the admin panel."), n.appendChild(r), n.appendChild(i), n.appendChild(a), this.messagesContainer.appendChild(n);
|
|
2824
|
-
}
|
|
2825
2796
|
clearMessages(e) {
|
|
2826
2797
|
this.messagesContainer.innerHTML = "", this.showEmptyState(e);
|
|
2827
2798
|
}
|
|
@@ -2841,7 +2812,7 @@ var jt = class {
|
|
|
2841
2812
|
scrollToBottom() {
|
|
2842
2813
|
this.messagesContainer.scrollTop = this.messagesContainer.scrollHeight;
|
|
2843
2814
|
}
|
|
2844
|
-
},
|
|
2815
|
+
}, jt = {
|
|
2845
2816
|
apiBaseUrl: o,
|
|
2846
2817
|
chatbotName: "AI Assistant",
|
|
2847
2818
|
primaryColor: "#2563EB",
|
|
@@ -2853,11 +2824,23 @@ var jt = class {
|
|
|
2853
2824
|
sessionId: "",
|
|
2854
2825
|
requestTimeoutMs: n
|
|
2855
2826
|
};
|
|
2856
|
-
function
|
|
2827
|
+
function Mt(e) {
|
|
2857
2828
|
return Object.fromEntries(Object.entries(e).filter(([, e]) => e !== void 0));
|
|
2858
2829
|
}
|
|
2859
|
-
var
|
|
2830
|
+
var Nt = [
|
|
2831
|
+
5e3,
|
|
2832
|
+
15e3,
|
|
2833
|
+
3e4,
|
|
2834
|
+
6e4
|
|
2835
|
+
];
|
|
2836
|
+
function Pt(e) {
|
|
2837
|
+
return i(e) ? e.status === 0 || e.status >= 500 || e.apiError.code === "BAD_RESPONSE" : !1;
|
|
2838
|
+
}
|
|
2860
2839
|
function Ft(e) {
|
|
2840
|
+
return i(e) ? e.apiError.message : e instanceof Error ? e.message : "Failed to load chatbot config.";
|
|
2841
|
+
}
|
|
2842
|
+
var It = 0, Z = () => Date.now() * 1e3 + It++ % 1e3;
|
|
2843
|
+
function Lt(e) {
|
|
2861
2844
|
if (!e || typeof e != "object") return null;
|
|
2862
2845
|
let t = e;
|
|
2863
2846
|
if (typeof t.textMessage == "string" && t.textMessage.trim()) return t.textMessage.trim();
|
|
@@ -2869,7 +2852,7 @@ function Ft(e) {
|
|
|
2869
2852
|
}
|
|
2870
2853
|
return null;
|
|
2871
2854
|
}
|
|
2872
|
-
function
|
|
2855
|
+
function Rt(e) {
|
|
2873
2856
|
if (!e || typeof e != "object") return null;
|
|
2874
2857
|
let t = e;
|
|
2875
2858
|
if (typeof t.id == "string" && t.id) return t.id;
|
|
@@ -2879,9 +2862,9 @@ function It(e) {
|
|
|
2879
2862
|
}
|
|
2880
2863
|
return null;
|
|
2881
2864
|
}
|
|
2882
|
-
var
|
|
2865
|
+
var Q = class {
|
|
2883
2866
|
constructor() {
|
|
2884
|
-
this.emitter = new s(), this.visitorTokens = new
|
|
2867
|
+
this.emitter = new s(), this.visitorTokens = new ut(), this.widget = null, this.sdkSocket = null, this.callerSetName = !1, this.hasActiveTicket = !1, this.retryTimer = null, this.lastPushId = null, this.initToken = 0, this._state = {
|
|
2885
2868
|
isOpen: !1,
|
|
2886
2869
|
isLoading: !1,
|
|
2887
2870
|
isReady: !1,
|
|
@@ -2915,21 +2898,58 @@ var Lt = class {
|
|
|
2915
2898
|
async init(e) {
|
|
2916
2899
|
if (!e.apiKey) throw Error("[onedeskpro-chatbot] `apiKey` is required to initialise the chatbot.");
|
|
2917
2900
|
let t = ++this.initToken;
|
|
2918
|
-
this.disconnectSdkSocket(), this.widget?.destroy(), this.widget = null, this.callerSetName = e.chatbotName !== void 0, this.options = {
|
|
2919
|
-
...
|
|
2920
|
-
...
|
|
2901
|
+
this.clearRetry(), this.disconnectSdkSocket(), this.widget?.destroy(), this.widget = null, this.callerSetName = e.chatbotName !== void 0, this.options = {
|
|
2902
|
+
...jt,
|
|
2903
|
+
...Mt(e)
|
|
2921
2904
|
}, this.apiClient = new a({
|
|
2922
2905
|
baseUrl: this.options.apiBaseUrl,
|
|
2923
2906
|
apiKey: this.options.apiKey,
|
|
2924
2907
|
timeoutMs: this.options.requestTimeoutMs
|
|
2925
2908
|
}), this.hasActiveTicket = !1, this.setState({
|
|
2909
|
+
isReady: !1,
|
|
2910
|
+
blockReason: null,
|
|
2926
2911
|
visitorToken: null,
|
|
2927
2912
|
visitorName: null,
|
|
2928
2913
|
needsIdentify: !0,
|
|
2929
2914
|
messages: [],
|
|
2930
2915
|
error: null,
|
|
2931
2916
|
mode: "ai"
|
|
2932
|
-
}),
|
|
2917
|
+
}), await this.checkReadiness(t, 0);
|
|
2918
|
+
}
|
|
2919
|
+
async checkReadiness(e, t) {
|
|
2920
|
+
let n;
|
|
2921
|
+
try {
|
|
2922
|
+
n = await this.apiClient.fetchConfig();
|
|
2923
|
+
} catch (n) {
|
|
2924
|
+
if (e !== this.initToken) return;
|
|
2925
|
+
if (Pt(n)) {
|
|
2926
|
+
this.setState({
|
|
2927
|
+
isReady: !1,
|
|
2928
|
+
blockReason: "server-unavailable",
|
|
2929
|
+
error: Ft(n)
|
|
2930
|
+
});
|
|
2931
|
+
let r = Nt[t];
|
|
2932
|
+
if (r !== void 0) {
|
|
2933
|
+
this.retryTimer = setTimeout(() => {
|
|
2934
|
+
this.retryTimer = null, this.checkReadiness(e, t + 1);
|
|
2935
|
+
}, r);
|
|
2936
|
+
return;
|
|
2937
|
+
}
|
|
2938
|
+
} else this.handleConfigError(n);
|
|
2939
|
+
this.emitter.emit("ready");
|
|
2940
|
+
return;
|
|
2941
|
+
}
|
|
2942
|
+
if (e !== this.initToken) return;
|
|
2943
|
+
!this.callerSetName && n.agentName.trim() && (this.options.chatbotName = n.agentName);
|
|
2944
|
+
let r = n.blockReason ?? null, i = n.ready && r === null;
|
|
2945
|
+
this.setState({
|
|
2946
|
+
blockReason: r,
|
|
2947
|
+
isReady: i,
|
|
2948
|
+
error: null
|
|
2949
|
+
}), i ? (this.mountWidget(), this.visitorTokens.setScope(n.agentId), await this.resolveVisitorGate(e), e === this.initToken && (this.widget?.reveal(), this.emitter.emit("ready"))) : this.emitter.emit("ready");
|
|
2950
|
+
}
|
|
2951
|
+
mountWidget() {
|
|
2952
|
+
typeof window < "u" && typeof document < "u" && (this.widget = new At(this.options, {
|
|
2933
2953
|
onSend: (e) => void this.sendMessage(e),
|
|
2934
2954
|
onIdentify: (e) => void this.submitIdentify(e),
|
|
2935
2955
|
onOpen: () => {
|
|
@@ -2941,45 +2961,16 @@ var Lt = class {
|
|
|
2941
2961
|
onReset: () => this.resetSession(),
|
|
2942
2962
|
onRequestHuman: () => void this.requestHuman()
|
|
2943
2963
|
}));
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
} catch (e) {
|
|
2948
|
-
r = e;
|
|
2949
|
-
}
|
|
2950
|
-
if (t !== this.initToken) return;
|
|
2951
|
-
if (r) {
|
|
2952
|
-
this.handleConfigError(r), this.emitter.emit("ready");
|
|
2953
|
-
return;
|
|
2954
|
-
}
|
|
2955
|
-
if (!n) {
|
|
2956
|
-
this.emitter.emit("ready");
|
|
2957
|
-
return;
|
|
2958
|
-
}
|
|
2959
|
-
!this.callerSetName && n.agentName.trim() && (this.options.chatbotName = n.agentName);
|
|
2960
|
-
let i = n.blockReason ?? null;
|
|
2961
|
-
if (this.setState({
|
|
2962
|
-
blockReason: i,
|
|
2963
|
-
isReady: i === null,
|
|
2964
|
-
error: null
|
|
2965
|
-
}), i) this.widget?.showBlocked(i);
|
|
2966
|
-
else if (this.visitorTokens.setScope(n.agentId), await this.resolveVisitorGate(t), t !== this.initToken) return;
|
|
2967
|
-
this.emitter.emit("ready");
|
|
2964
|
+
}
|
|
2965
|
+
clearRetry() {
|
|
2966
|
+
this.retryTimer !== null && (clearTimeout(this.retryTimer), this.retryTimer = null);
|
|
2968
2967
|
}
|
|
2969
2968
|
handleConfigError(e) {
|
|
2970
|
-
let t = i(e) ? e : null
|
|
2971
|
-
|
|
2972
|
-
isReady: !1,
|
|
2973
|
-
blockReason: "no-agent",
|
|
2974
|
-
error: n
|
|
2975
|
-
}), this.widget?.showBlocked("no-agent")) : a === 403 ? (this.setState({
|
|
2976
|
-
isReady: !1,
|
|
2977
|
-
blockReason: null,
|
|
2978
|
-
error: n
|
|
2979
|
-
}), this.widget?.showBlocked(null, n)) : this.setState({
|
|
2969
|
+
let t = (i(e) ? e : null)?.apiError.code === "agent_not_assigned" ? "no-agent" : null;
|
|
2970
|
+
this.setState({
|
|
2980
2971
|
isReady: !1,
|
|
2981
|
-
blockReason:
|
|
2982
|
-
error:
|
|
2972
|
+
blockReason: t,
|
|
2973
|
+
error: Ft(e)
|
|
2983
2974
|
});
|
|
2984
2975
|
}
|
|
2985
2976
|
async resolveVisitorGate(e) {
|
|
@@ -3011,7 +3002,7 @@ var Lt = class {
|
|
|
3011
3002
|
}), this.widget?.readyToChat(this.options), this.connectSdkSocket(e), await this.restoreTicketStatus(e, n);
|
|
3012
3003
|
}
|
|
3013
3004
|
connectSdkSocket(e) {
|
|
3014
|
-
this.sdkSocket ||= new
|
|
3005
|
+
this.sdkSocket ||= new ot(), this.sdkSocket.connect({
|
|
3015
3006
|
baseUrl: this.options.apiBaseUrl,
|
|
3016
3007
|
apiKey: this.options.apiKey,
|
|
3017
3008
|
visitorToken: e,
|
|
@@ -3041,13 +3032,13 @@ var Lt = class {
|
|
|
3041
3032
|
}
|
|
3042
3033
|
handleMessageReceive(e) {
|
|
3043
3034
|
if (this._state.mode === "ai") return;
|
|
3044
|
-
let t =
|
|
3035
|
+
let t = Lt(e);
|
|
3045
3036
|
if (!t) return;
|
|
3046
|
-
let n =
|
|
3037
|
+
let n = Rt(e), r = this._state.messages[this._state.messages.length - 1];
|
|
3047
3038
|
if (r?.message.content === t && (r.message.type === "ai" || r.message.type === "agent" && (!n || n === this.lastPushId))) return;
|
|
3048
3039
|
this.lastPushId = n;
|
|
3049
3040
|
let i = this.visitorTokens.get() ?? this._state.visitorToken ?? "", a = {
|
|
3050
|
-
id:
|
|
3041
|
+
id: Z(),
|
|
3051
3042
|
sessionId: i,
|
|
3052
3043
|
message: {
|
|
3053
3044
|
type: "agent",
|
|
@@ -3107,7 +3098,7 @@ var Lt = class {
|
|
|
3107
3098
|
let n = e.trim();
|
|
3108
3099
|
if (!n || this._state.isLoading || this._state.needsIdentify) return;
|
|
3109
3100
|
let r = {
|
|
3110
|
-
id:
|
|
3101
|
+
id: Z(),
|
|
3111
3102
|
sessionId: t,
|
|
3112
3103
|
message: {
|
|
3113
3104
|
type: "human",
|
|
@@ -3130,7 +3121,7 @@ var Lt = class {
|
|
|
3130
3121
|
let t = a[a.length - 1];
|
|
3131
3122
|
if (t?.message.type !== "agent" && t?.message.type !== "ai" || t.message.content !== o) {
|
|
3132
3123
|
let t = {
|
|
3133
|
-
id:
|
|
3124
|
+
id: Z(),
|
|
3134
3125
|
sessionId: e.sessionId,
|
|
3135
3126
|
message: {
|
|
3136
3127
|
type: "ai",
|
|
@@ -3178,20 +3169,20 @@ var Lt = class {
|
|
|
3178
3169
|
return { ...this._state };
|
|
3179
3170
|
}
|
|
3180
3171
|
destroy() {
|
|
3181
|
-
this.initToken++, this.disconnectSdkSocket(), this.widget?.destroy(), this.widget = null, this.setState({
|
|
3172
|
+
this.initToken++, this.clearRetry(), this.disconnectSdkSocket(), this.widget?.destroy(), this.widget = null, this.setState({
|
|
3182
3173
|
isOpen: !1,
|
|
3183
3174
|
isLoading: !1,
|
|
3184
3175
|
isReady: !1,
|
|
3185
3176
|
needsIdentify: !0
|
|
3186
3177
|
});
|
|
3187
3178
|
}
|
|
3188
|
-
}, $ = null,
|
|
3179
|
+
}, $ = null, zt = {
|
|
3189
3180
|
async init(e) {
|
|
3190
|
-
return $ = new
|
|
3181
|
+
return $ = new Q(), await $.init(e), $;
|
|
3191
3182
|
},
|
|
3192
3183
|
getInstance() {
|
|
3193
3184
|
return $;
|
|
3194
3185
|
}
|
|
3195
3186
|
};
|
|
3196
3187
|
//#endregion
|
|
3197
|
-
export { a as ApiClient,
|
|
3188
|
+
export { a as ApiClient, Q as ChatbotCore, o as DEFAULT_API_BASE_URL, n as DEFAULT_REQUEST_TIMEOUT_MS, s as EventEmitter, zt as OnedeskProChatbot, ot as SdkSocket, ut as SessionManager, i as isChatbotRequestError, at as resolveSdkSocketUrl };
|