@spilki/widget 1.0.32 → 1.0.33
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/bootstrap.es.js +165 -165
- package/dist/bootstrap.es.js.map +1 -1
- package/dist/bootstrap.umd.js +6 -6
- package/dist/bootstrap.umd.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/widget.es.js +164 -164
- package/dist/widget.es.js.map +1 -1
- package/dist/widget.umd.js +6 -6
- package/dist/widget.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/bootstrap.es.js
CHANGED
|
@@ -71,13 +71,13 @@ const F = `
|
|
|
71
71
|
<span class="badge" hidden aria-hidden="true">0</span>
|
|
72
72
|
</button>
|
|
73
73
|
`;
|
|
74
|
-
function R(
|
|
74
|
+
function R(o) {
|
|
75
75
|
const e = document.createElement("div");
|
|
76
|
-
e.setAttribute("part", "bubble-root"), e.setAttribute("data-position",
|
|
76
|
+
e.setAttribute("part", "bubble-root"), e.setAttribute("data-position", o.position), e.style.setProperty("--spilki-accent", o.color);
|
|
77
77
|
const t = e.attachShadow({ mode: "open" });
|
|
78
78
|
t.innerHTML = F;
|
|
79
79
|
const s = t.querySelector("button"), i = t.querySelector(".badge");
|
|
80
|
-
return s.addEventListener("click", () =>
|
|
80
|
+
return s.addEventListener("click", () => o.onClick()), {
|
|
81
81
|
element: e,
|
|
82
82
|
mount() {
|
|
83
83
|
document.body.appendChild(e);
|
|
@@ -98,68 +98,68 @@ function R(r) {
|
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
|
-
const K = "https://api.spilki.app",
|
|
101
|
+
const K = "https://api.spilki.app", C = {
|
|
102
102
|
welcome: "Hi! I'm your assistant.",
|
|
103
103
|
placeholder: "Type a message…",
|
|
104
104
|
sendLabel: "Send",
|
|
105
|
-
typing: "Assistant is typing
|
|
106
|
-
thinking: "Assistant is thinking
|
|
107
|
-
searching: "Searching
|
|
108
|
-
executingTool: "Working on it
|
|
105
|
+
typing: "Assistant is typing",
|
|
106
|
+
thinking: "Assistant is thinking",
|
|
107
|
+
searching: "Searching",
|
|
108
|
+
executingTool: "Working on it",
|
|
109
109
|
offline: "Unable to connect. Please try again later.",
|
|
110
110
|
title: "Spilki Assistant"
|
|
111
|
-
},
|
|
111
|
+
}, w = {
|
|
112
112
|
apiBase: K,
|
|
113
113
|
position: "bottom-right",
|
|
114
114
|
theme: "auto",
|
|
115
115
|
color: "#6366f1",
|
|
116
|
-
welcome:
|
|
116
|
+
welcome: C.welcome,
|
|
117
117
|
persist: !0,
|
|
118
118
|
sound: !0,
|
|
119
|
-
i18n:
|
|
119
|
+
i18n: C
|
|
120
120
|
};
|
|
121
|
-
function H(
|
|
122
|
-
var t, s, i,
|
|
123
|
-
const e = { ...
|
|
121
|
+
function H(o) {
|
|
122
|
+
var t, s, i, r, a, n, l, g;
|
|
123
|
+
const e = { ...C, ...(t = o.i18n) != null ? t : {} };
|
|
124
124
|
return {
|
|
125
|
-
...
|
|
126
|
-
...
|
|
127
|
-
apiBase: (s =
|
|
125
|
+
...w,
|
|
126
|
+
...o,
|
|
127
|
+
apiBase: (s = o.apiBase) != null ? s : w.apiBase,
|
|
128
128
|
i18n: e,
|
|
129
|
-
welcome: (i =
|
|
130
|
-
position: (
|
|
131
|
-
theme: (a =
|
|
132
|
-
color: (n =
|
|
133
|
-
persist: (l =
|
|
134
|
-
sound: (
|
|
129
|
+
welcome: (i = o.welcome) != null ? i : e.welcome,
|
|
130
|
+
position: (r = o.position) != null ? r : w.position,
|
|
131
|
+
theme: (a = o.theme) != null ? a : w.theme,
|
|
132
|
+
color: (n = o.color) != null ? n : w.color,
|
|
133
|
+
persist: (l = o.persist) != null ? l : w.persist,
|
|
134
|
+
sound: (g = o.sound) != null ? g : w.sound
|
|
135
135
|
};
|
|
136
136
|
}
|
|
137
|
-
function z(
|
|
138
|
-
return typeof crypto != "undefined" && crypto.randomUUID ? crypto.randomUUID() : `${
|
|
137
|
+
function z(o = "msg") {
|
|
138
|
+
return typeof crypto != "undefined" && crypto.randomUUID ? crypto.randomUUID() : `${o}-${Math.random().toString(16).slice(2)}`;
|
|
139
139
|
}
|
|
140
140
|
function _() {
|
|
141
|
-
var
|
|
142
|
-
return (e = (
|
|
141
|
+
var o, e;
|
|
142
|
+
return (e = (o = window.matchMedia) == null ? void 0 : o.call(window, "(prefers-color-scheme: dark)").matches) != null ? e : !1;
|
|
143
143
|
}
|
|
144
|
-
function P(
|
|
145
|
-
return
|
|
144
|
+
function P(o) {
|
|
145
|
+
return o === "light" || o === "dark" ? o : _() ? "dark" : "light";
|
|
146
146
|
}
|
|
147
|
-
function
|
|
148
|
-
return
|
|
147
|
+
function x(o, e = 30) {
|
|
148
|
+
return o.slice(-e);
|
|
149
149
|
}
|
|
150
|
-
function G(
|
|
151
|
-
if (!
|
|
150
|
+
function G(o) {
|
|
151
|
+
if (!o || o.length === 0) return;
|
|
152
152
|
const e = window.location.origin;
|
|
153
|
-
|
|
154
|
-
`SpilkiWidget: current origin ${e} not in allowedOriginsHint: ${
|
|
153
|
+
o.includes(e) || console.warn(
|
|
154
|
+
`SpilkiWidget: current origin ${e} not in allowedOriginsHint: ${o.join(", ")}`
|
|
155
155
|
);
|
|
156
156
|
}
|
|
157
157
|
const q = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
158
|
-
function Y(
|
|
159
|
-
const e = new Date(
|
|
160
|
-
return n ===
|
|
158
|
+
function Y(o) {
|
|
159
|
+
const e = new Date(o), t = /* @__PURE__ */ new Date(), s = (l) => String(l).padStart(2, "0"), i = `${s(e.getHours())}:${s(e.getMinutes())}`, r = new Date(t.getFullYear(), t.getMonth(), t.getDate()).getTime(), a = r - 864e5, n = new Date(e.getFullYear(), e.getMonth(), e.getDate()).getTime();
|
|
160
|
+
return n === r ? `Today at ${i}` : n === a ? `Yesterday at ${i}` : `${q[e.getMonth()]} ${e.getDate()}, ${i}`;
|
|
161
161
|
}
|
|
162
|
-
const V = ':host{--spilki-bg-light: #ffffff;--spilki-bg-dark: #0f172a;--spilki-text-light: #0f172a;--spilki-text-dark: #f8fafc;--spilki-border-light: rgba(15, 23, 42, .1);--spilki-border-dark: rgba(148, 163, 184, .25);--spilki-muted-light: #64748b;--spilki-muted-dark: #94a3b8;--spilki-shadow: 0 10px 40px rgba(15, 23, 42, .2);--spilki-radius: 16px;--spilki-font: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;color:inherit;font-family:var(--spilki-font)}.wrapper{position:relative;width:100%;height:100%;display:flex;flex-direction:column;background:var(--spilki-surface);color:var(--spilki-text);border-radius:var(--spilki-radius);box-shadow:var(--spilki-shadow);border:1px solid var(--spilki-border);overflow:hidden}header{display:flex;align-items:center;justify-content:space-between;padding:.75rem 1rem;background:var(--spilki-surface);border-bottom:1px solid var(--spilki-border)}header h1{font-size:1rem;margin:0;display:flex;align-items:center;gap:.5rem}header button.close{border:none;background:transparent;color:inherit;font-size:1.25rem;cursor:pointer}header button.close:focus-visible{outline:2px solid var(--spilki-accent);outline-offset:2px;border-radius:4px}header .status-dot{width:10px;height:10px;border-radius:999px;background:var(--spilki-accent)}.messages{flex:1;overflow-y:auto;padding:1rem;display:flex;flex-direction:column;gap:.
|
|
162
|
+
const V = ':host{--spilki-bg-light: #ffffff;--spilki-bg-dark: #0f172a;--spilki-text-light: #0f172a;--spilki-text-dark: #f8fafc;--spilki-border-light: rgba(15, 23, 42, .1);--spilki-border-dark: rgba(148, 163, 184, .25);--spilki-muted-light: #64748b;--spilki-muted-dark: #94a3b8;--spilki-shadow: 0 10px 40px rgba(15, 23, 42, .2);--spilki-radius: 16px;--spilki-font: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;color:inherit;font-family:var(--spilki-font)}.wrapper{position:relative;width:100%;height:100%;display:flex;flex-direction:column;background:var(--spilki-surface);color:var(--spilki-text);border-radius:var(--spilki-radius);box-shadow:var(--spilki-shadow);border:1px solid var(--spilki-border);overflow:hidden}header{display:flex;align-items:center;justify-content:space-between;padding:.75rem 1rem;background:var(--spilki-surface);border-bottom:1px solid var(--spilki-border)}header h1{font-size:1rem;margin:0;display:flex;align-items:center;gap:.5rem}header button.close{border:none;background:transparent;color:inherit;font-size:1.25rem;cursor:pointer}header button.close:focus-visible{outline:2px solid var(--spilki-accent);outline-offset:2px;border-radius:4px}header .status-dot{width:10px;height:10px;border-radius:999px;background:var(--spilki-accent)}.messages{flex:1;overflow-y:auto;padding:1rem;display:flex;flex-direction:column;gap:.75rem;scrollbar-width:thin;scrollbar-color:rgba(148,163,184,.3) transparent;scroll-behavior:smooth}.message{display:flex;flex-direction:column;gap:.15rem;max-width:85%;width:fit-content;line-height:1.4;word-wrap:break-word;overflow-wrap:anywhere;white-space:pre-wrap}.message.user{align-self:flex-end;align-items:flex-end}.message .bubble{padding:.6rem .8rem;border-radius:1rem;background:#6366f126}.message.user .bubble{background:var(--spilki-accent);color:#fff}.message.bot .bubble{background:#94a3b826}.msg-time{font-size:.7rem;color:var(--spilki-muted);margin-top:2px}.date-separator{display:flex;align-items:center;gap:.5rem;padding:.4rem 0;font-size:.72rem;color:var(--spilki-muted);white-space:nowrap}.date-separator:before,.date-separator:after{content:"";flex:1;height:1px;background:var(--spilki-border)}.scroll-bottom{position:absolute;right:1rem;bottom:88px;width:38px;height:38px;border:none;border-radius:999px;background:var(--spilki-accent);color:#fff;box-shadow:0 8px 20px #0f172a40;cursor:pointer;opacity:0;pointer-events:none;transform:translateY(4px);transition:opacity .18s ease,transform .18s ease;z-index:3}.scroll-bottom.visible{opacity:1;pointer-events:auto;transform:translateY(0)}.scroll-arrow{font-size:.8rem;line-height:1}.scroll-count{position:absolute;top:-5px;right:-5px;min-width:16px;height:16px;border-radius:999px;background:#ef4444;color:#fff;font-size:10px;line-height:16px;text-align:center;padding:0 4px}.suggested-replies{display:flex;flex-wrap:wrap;gap:.4rem;padding:.5rem 1rem;border-top:1px solid var(--spilki-border)}.suggested-chip{border:1px solid var(--spilki-accent);background:transparent;color:var(--spilki-accent);border-radius:999px;padding:.35rem .75rem;font-size:.8rem;font-family:inherit;cursor:pointer;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;transition:background .15s,color .15s}.suggested-chip:hover{background:var(--spilki-accent);color:#fff}.suggested-chip:focus-visible{outline:2px solid var(--spilki-accent);outline-offset:2px}.input-area{padding:.5rem .75rem}.input-wrap{display:flex;align-items:center;border:1px solid var(--spilki-border);border-radius:1.5rem;background:transparent;padding-left:0}.input-area textarea{flex:1;resize:none;min-height:2.4rem;max-height:6rem;border:0;border-radius:0;outline:0;background:transparent;box-shadow:none;-webkit-box-shadow:none;-webkit-appearance:none;appearance:none;padding:.55rem 0 .55rem 1rem;font-family:inherit;font-size:.95rem;color:var(--spilki-text);scrollbar-width:thin;scrollbar-color:rgba(148,163,184,.3) transparent}.input-actions{display:flex;align-items:center;gap:.25rem;padding:.25rem .35rem;flex-shrink:0}.input-actions button{width:32px;height:32px;display:grid;place-items:center;border:none;border-radius:50%;cursor:pointer;padding:0;transition:opacity .15s}.emoji-btn{background:#6366f126;color:var(--spilki-accent)}.emoji-btn:hover{background:#6366f140}.emoji-btn:focus-visible{outline:2px solid var(--spilki-accent);outline-offset:1px}.send-btn{background:var(--spilki-accent);color:#fff}.send-btn:hover{opacity:.85}.send-btn:focus-visible{outline:2px solid var(--spilki-accent);outline-offset:2px}.emoji-picker{position:absolute;right:1rem;bottom:80px;width:240px;max-height:180px;overflow-y:auto;display:none;grid-template-columns:repeat(10,minmax(0,1fr));gap:.25rem;padding:.5rem;background:var(--spilki-surface);border:1px solid var(--spilki-border);border-radius:12px;box-shadow:0 14px 30px #0f172a40;z-index:4}.emoji-option{width:100%;aspect-ratio:1;border:none;border-radius:8px;background:transparent;font-size:1rem;cursor:pointer}.emoji-option:hover,.emoji-option:focus-visible{background:#94a3b833}.typing{font-size:.75rem;color:var(--spilki-muted);padding:0 1rem .75rem}.typing:after{content:"";animation:dots 1.2s steps(4,end) infinite}@keyframes dots{0%{content:""}25%{content:"."}50%{content:".."}75%{content:"..."}}.offline{font-size:.8rem;padding:0 1rem;color:#f97316}:host([data-theme="dark"]){--spilki-surface: var(--spilki-bg-dark);--spilki-text: var(--spilki-text-dark);--spilki-border: var(--spilki-border-dark);--spilki-muted: var(--spilki-muted-dark)}:host([data-theme="dark"]) .messages,:host([data-theme="dark"]) .input-area textarea,:host([data-theme="dark"]) .emoji-picker{scrollbar-color:rgba(255,255,255,.2) transparent}:host([data-theme="light"]){--spilki-surface: var(--spilki-bg-light);--spilki-text: var(--spilki-text-light);--spilki-border: var(--spilki-border-light);--spilki-muted: var(--spilki-muted-light)}:host([data-theme="dark"]) .message .bubble{background:#94a3b81f}:host([data-theme="dark"]) .message.bot .bubble{background:#6366f126}:host([data-theme="dark"]) .input-area textarea{background:transparent}.messages::-webkit-scrollbar,.input-area textarea::-webkit-scrollbar,.emoji-picker::-webkit-scrollbar{width:6px}.messages::-webkit-scrollbar-track,.input-area textarea::-webkit-scrollbar-track,.emoji-picker::-webkit-scrollbar-track{background:transparent}.messages::-webkit-scrollbar-thumb,.input-area textarea::-webkit-scrollbar-thumb,.emoji-picker::-webkit-scrollbar-thumb{background:#94a3b84d;border-radius:999px}.messages::-webkit-scrollbar-thumb:hover,.input-area textarea::-webkit-scrollbar-thumb:hover,.emoji-picker::-webkit-scrollbar-thumb:hover{background:#94a3b880}:host([data-theme="dark"]) .messages::-webkit-scrollbar-thumb,:host([data-theme="dark"]) .input-area textarea::-webkit-scrollbar-thumb,:host([data-theme="dark"]) .emoji-picker::-webkit-scrollbar-thumb{background:#fff3}:host([data-theme="dark"]) .messages::-webkit-scrollbar-thumb:hover,:host([data-theme="dark"]) .input-area textarea::-webkit-scrollbar-thumb:hover,:host([data-theme="dark"]) .emoji-picker::-webkit-scrollbar-thumb:hover{background:#ffffff59}.conversation-separator{display:flex;align-items:center;gap:.5rem;padding:.5rem 0;cursor:pointer;user-select:none;font-size:.7rem;color:var(--spilki-muted);white-space:nowrap}.conversation-separator:before,.conversation-separator:after{content:"";flex:1;height:1px;background:var(--spilki-border)}.conversation-separator:hover{color:var(--spilki-text)}.conversation-separator:focus-visible{outline:2px solid var(--spilki-accent);outline-offset:2px;border-radius:4px}.conversation-history{display:none;flex-direction:column;gap:.5rem}.conversation-history.expanded{display:flex}', j = 24 * 60 * 60 * 1e3, J = 2 * 60 * 1e3, X = 200, Z = [
|
|
163
163
|
"😀",
|
|
164
164
|
"😂",
|
|
165
165
|
"🤣",
|
|
@@ -211,8 +211,8 @@ const V = ':host{--spilki-bg-light: #ffffff;--spilki-bg-dark: #0f172a;--spilki-t
|
|
|
211
211
|
"☕",
|
|
212
212
|
"🍕"
|
|
213
213
|
];
|
|
214
|
-
function
|
|
215
|
-
return
|
|
214
|
+
function E(o) {
|
|
215
|
+
return o.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
216
216
|
}
|
|
217
217
|
class Q {
|
|
218
218
|
constructor(e) {
|
|
@@ -229,7 +229,7 @@ class Q {
|
|
|
229
229
|
day: "numeric",
|
|
230
230
|
year: "numeric"
|
|
231
231
|
}), this.renderedMessages = [], this.focusable = [], this.seenIds = /* @__PURE__ */ new Set(), this.lastTimelineMessage = null, this.scrollUnreadCount = 0, this.emojiPickerOpen = !1, this.open = !1, this.host = document.createElement("div"), this.host.setAttribute("part", "panel-root"), this.host.style.position = "fixed", this.host.style.bottom = "96px", this.host.style[e.position === "bottom-right" ? "right" : "left"] = "24px", this.host.style.width = "360px", this.host.style.maxWidth = "calc(100vw - 32px)", this.host.style.height = "520px", this.host.style.display = "none", this.host.style.zIndex = "2147483001", this.shadow = this.host.attachShadow({ mode: "open" });
|
|
232
|
-
const t =
|
|
232
|
+
const t = E(e.i18n.title), s = E(e.i18n.typing), i = E(e.i18n.offline), r = E(e.i18n.placeholder), a = E(e.i18n.sendLabel);
|
|
233
233
|
this.shadow.innerHTML = `
|
|
234
234
|
<style>${V}</style>
|
|
235
235
|
<div class="wrapper" role="dialog" aria-modal="true" aria-label="${t}">
|
|
@@ -248,7 +248,7 @@ class Q {
|
|
|
248
248
|
<div class="emoji-picker" aria-label="Emoji picker"></div>
|
|
249
249
|
<div class="input-area">
|
|
250
250
|
<div class="input-wrap">
|
|
251
|
-
<textarea rows="1" placeholder="${
|
|
251
|
+
<textarea rows="1" placeholder="${r}" aria-label="${r}"></textarea>
|
|
252
252
|
<div class="input-actions">
|
|
253
253
|
<button class="emoji-btn" type="button" aria-label="Insert emoji">
|
|
254
254
|
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
|
@@ -329,7 +329,7 @@ class Q {
|
|
|
329
329
|
this.messagesEl.innerHTML = "", this.seenIds.clear(), this.renderedMessages.length = 0, this.lastTimelineMessage = null;
|
|
330
330
|
for (const s of e) {
|
|
331
331
|
s.messages.forEach((n) => this.seenIds.add(n.id));
|
|
332
|
-
const i = this.createHistoryContainer(s.messages),
|
|
332
|
+
const i = this.createHistoryContainer(s.messages), r = s.messages[s.messages.length - 1].ts, a = this.createSeparatorElement(r, i);
|
|
333
333
|
this.messagesEl.appendChild(i), this.messagesEl.appendChild(a);
|
|
334
334
|
}
|
|
335
335
|
t.forEach((s) => {
|
|
@@ -397,14 +397,14 @@ class Q {
|
|
|
397
397
|
const s = document.createElement("div");
|
|
398
398
|
s.className = "conversation-separator", s.setAttribute("role", "button"), s.setAttribute("tabindex", "0"), s.setAttribute("aria-expanded", "false"), s.setAttribute("aria-label", "Show previous conversation"), s.textContent = Y(e);
|
|
399
399
|
const i = () => {
|
|
400
|
-
const
|
|
401
|
-
s.setAttribute("aria-expanded", String(
|
|
400
|
+
const r = t.classList.toggle("expanded");
|
|
401
|
+
s.setAttribute("aria-expanded", String(r)), s.setAttribute(
|
|
402
402
|
"aria-label",
|
|
403
|
-
|
|
403
|
+
r ? "Hide previous conversation" : "Show previous conversation"
|
|
404
404
|
);
|
|
405
405
|
};
|
|
406
|
-
return s.addEventListener("click", i), s.addEventListener("keydown", (
|
|
407
|
-
const a =
|
|
406
|
+
return s.addEventListener("click", i), s.addEventListener("keydown", (r) => {
|
|
407
|
+
const a = r;
|
|
408
408
|
(a.key === "Enter" || a.key === " ") && (a.preventDefault(), i());
|
|
409
409
|
}), s;
|
|
410
410
|
}
|
|
@@ -414,8 +414,8 @@ class Q {
|
|
|
414
414
|
let s = null;
|
|
415
415
|
return e.forEach((i) => {
|
|
416
416
|
this.appendDateSeparatorIfNeeded(s, i, t);
|
|
417
|
-
const { item:
|
|
418
|
-
t.appendChild(
|
|
417
|
+
const { item: r } = this.createMessageElement(i);
|
|
418
|
+
t.appendChild(r), s = i;
|
|
419
419
|
}), t;
|
|
420
420
|
}
|
|
421
421
|
appendTimelineMessage(e) {
|
|
@@ -441,8 +441,8 @@ class Q {
|
|
|
441
441
|
const i = Math.max(1, Math.round(s / 6e4));
|
|
442
442
|
if (i < 60)
|
|
443
443
|
return this.relativeTimeFormat.format(-i, "minute");
|
|
444
|
-
const
|
|
445
|
-
return this.relativeTimeFormat.format(-
|
|
444
|
+
const r = Math.max(1, Math.round(i / 60));
|
|
445
|
+
return this.relativeTimeFormat.format(-r, "hour");
|
|
446
446
|
}
|
|
447
447
|
return this.absoluteTimeFormat.format(new Date(e));
|
|
448
448
|
}
|
|
@@ -516,8 +516,8 @@ class Q {
|
|
|
516
516
|
var a, n;
|
|
517
517
|
const t = this.input.value, s = (a = this.input.selectionStart) != null ? a : t.length, i = (n = this.input.selectionEnd) != null ? n : t.length;
|
|
518
518
|
this.input.value = `${t.slice(0, s)}${e}${t.slice(i)}`;
|
|
519
|
-
const
|
|
520
|
-
this.input.setSelectionRange(
|
|
519
|
+
const r = s + e.length;
|
|
520
|
+
this.input.setSelectionRange(r, r), this.input.dispatchEvent(new Event("input", { bubbles: !0 })), this.input.focus();
|
|
521
521
|
}
|
|
522
522
|
collectFocusable() {
|
|
523
523
|
const e = this.shadow.querySelectorAll(
|
|
@@ -533,10 +533,10 @@ class Q {
|
|
|
533
533
|
e.shiftKey && i === t ? (e.preventDefault(), s.focus()) : !e.shiftKey && i === s && (e.preventDefault(), t.focus());
|
|
534
534
|
}
|
|
535
535
|
}
|
|
536
|
-
const
|
|
536
|
+
const v = 1500, D = 8e3;
|
|
537
537
|
class ee {
|
|
538
538
|
constructor(e, t) {
|
|
539
|
-
this.sessionId = null, this.currentKind = null, this.stopped = !1, this.backoff =
|
|
539
|
+
this.sessionId = null, this.currentKind = null, this.stopped = !1, this.backoff = v, this.connectPromise = null, this.options = e, this.handlers = t;
|
|
540
540
|
}
|
|
541
541
|
setAccessToken(e) {
|
|
542
542
|
this.options.accessToken = e;
|
|
@@ -577,8 +577,8 @@ class ee {
|
|
|
577
577
|
});
|
|
578
578
|
if (!i.ok)
|
|
579
579
|
throw new Error(`SpilkiWidget: connect failed (${i.status})`);
|
|
580
|
-
const
|
|
581
|
-
return this.sessionId =
|
|
580
|
+
const r = await i.json();
|
|
581
|
+
return this.sessionId = r.sessionId, this.options.sessionId = r.sessionId, this.backoff = v, await this.startTransport(r), r;
|
|
582
582
|
}
|
|
583
583
|
async send(e, t) {
|
|
584
584
|
var a, n;
|
|
@@ -593,7 +593,7 @@ class ee {
|
|
|
593
593
|
this.ws.send(JSON.stringify({ type: "message", payload: s }));
|
|
594
594
|
return;
|
|
595
595
|
}
|
|
596
|
-
const i = `${this.options.apiBase.replace(/\/$/, "")}/widget/message`,
|
|
596
|
+
const i = `${this.options.apiBase.replace(/\/$/, "")}/widget/message`, r = await fetch(i, {
|
|
597
597
|
method: "POST",
|
|
598
598
|
headers: {
|
|
599
599
|
"Content-Type": "application/json",
|
|
@@ -601,12 +601,12 @@ class ee {
|
|
|
601
601
|
},
|
|
602
602
|
body: JSON.stringify(s)
|
|
603
603
|
});
|
|
604
|
-
if (!
|
|
605
|
-
throw new Error(`SpilkiWidget: send failed (${
|
|
604
|
+
if (!r.ok)
|
|
605
|
+
throw new Error(`SpilkiWidget: send failed (${r.status})`);
|
|
606
606
|
}
|
|
607
607
|
// #1: accept resetBackoff param; #8 #9: clear retryTimer
|
|
608
608
|
stop(e = !0) {
|
|
609
|
-
this.stopped = !0, e && (this.backoff =
|
|
609
|
+
this.stopped = !0, e && (this.backoff = v), this.retryTimer && (clearTimeout(this.retryTimer), this.retryTimer = void 0), this.ws && (this.wsOnOpen && this.ws.removeEventListener("open", this.wsOnOpen), this.wsOnMessage && this.ws.removeEventListener("message", this.wsOnMessage), this.wsOnClose && this.ws.removeEventListener("close", this.wsOnClose), this.wsOnError && this.ws.removeEventListener("error", this.wsOnError), this.ws.close(), this.ws = void 0), this.wsOnOpen = this.wsOnMessage = this.wsOnClose = this.wsOnError = void 0, this.sseAbort && (this.sseAbort.abort(), this.sseAbort = void 0), this.pollTimer && (clearTimeout(this.pollTimer), this.pollTimer = void 0), this.currentKind = null;
|
|
610
610
|
}
|
|
611
611
|
async startTransport(e) {
|
|
612
612
|
if (this.stopped) return;
|
|
@@ -631,8 +631,8 @@ class ee {
|
|
|
631
631
|
i.close();
|
|
632
632
|
return;
|
|
633
633
|
}
|
|
634
|
-
this.currentKind = "ws", this.handlers.onOpen("ws"), this.backoff =
|
|
635
|
-
}, this.wsOnMessage = (
|
|
634
|
+
this.currentKind = "ws", this.handlers.onOpen("ws"), this.backoff = v, t();
|
|
635
|
+
}, this.wsOnMessage = (r) => this.handleIncoming(r.data), this.wsOnClose = () => {
|
|
636
636
|
this.stopped || this.retryFallback("ws");
|
|
637
637
|
}, this.wsOnError = () => {
|
|
638
638
|
this.handlers.onError(new Error("SpilkiWidget: websocket error")), i.readyState !== WebSocket.OPEN && s(new Error("WebSocket failed"));
|
|
@@ -652,8 +652,8 @@ class ee {
|
|
|
652
652
|
"X-Authorization": `Bearer ${this.options.accessToken}`
|
|
653
653
|
},
|
|
654
654
|
signal: i.signal
|
|
655
|
-
}).then((
|
|
656
|
-
if (!
|
|
655
|
+
}).then((r) => {
|
|
656
|
+
if (!r.ok || !r.body) {
|
|
657
657
|
s(new Error("SSE failed"));
|
|
658
658
|
return;
|
|
659
659
|
}
|
|
@@ -661,13 +661,13 @@ class ee {
|
|
|
661
661
|
i.abort();
|
|
662
662
|
return;
|
|
663
663
|
}
|
|
664
|
-
this.currentKind = "sse", this.handlers.onOpen("sse"), this.backoff =
|
|
665
|
-
const a =
|
|
664
|
+
this.currentKind = "sse", this.handlers.onOpen("sse"), this.backoff = v, t();
|
|
665
|
+
const a = r.body.getReader(), n = new TextDecoder();
|
|
666
666
|
let l = "";
|
|
667
|
-
const
|
|
668
|
-
a.read().then(({ done:
|
|
669
|
-
var
|
|
670
|
-
if (
|
|
667
|
+
const g = () => {
|
|
668
|
+
a.read().then(({ done: u, value: h }) => {
|
|
669
|
+
var m;
|
|
670
|
+
if (u || this.stopped) {
|
|
671
671
|
this.stopped || (this.handlers.onError(new Error("SpilkiWidget: SSE stream ended")), this.retryFallback("sse"));
|
|
672
672
|
return;
|
|
673
673
|
}
|
|
@@ -675,25 +675,25 @@ class ee {
|
|
|
675
675
|
const d = l.split(`
|
|
676
676
|
|
|
677
677
|
`);
|
|
678
|
-
l = (
|
|
679
|
-
for (const
|
|
680
|
-
for (const p of
|
|
678
|
+
l = (m = d.pop()) != null ? m : "";
|
|
679
|
+
for (const f of d)
|
|
680
|
+
for (const p of f.split(`
|
|
681
681
|
`))
|
|
682
682
|
p.startsWith("data:") && this.handleIncoming(p.slice(5).trim());
|
|
683
|
-
|
|
684
|
-
}).catch((
|
|
685
|
-
i.signal.aborted || (this.handlers.onError(
|
|
683
|
+
g();
|
|
684
|
+
}).catch((u) => {
|
|
685
|
+
i.signal.aborted || (this.handlers.onError(u), this.stopped || this.retryFallback("sse"));
|
|
686
686
|
});
|
|
687
687
|
};
|
|
688
|
-
|
|
689
|
-
}).catch((
|
|
690
|
-
i.signal.aborted || s(
|
|
688
|
+
g();
|
|
689
|
+
}).catch((r) => {
|
|
690
|
+
i.signal.aborted || s(r);
|
|
691
691
|
});
|
|
692
692
|
});
|
|
693
693
|
}
|
|
694
694
|
// #15: add auth header to poll fetch
|
|
695
695
|
async startPoll(e) {
|
|
696
|
-
this.currentKind = "poll", this.handlers.onOpen("poll"), this.backoff =
|
|
696
|
+
this.currentKind = "poll", this.handlers.onOpen("poll"), this.backoff = v;
|
|
697
697
|
const t = async () => {
|
|
698
698
|
if (!this.stopped)
|
|
699
699
|
try {
|
|
@@ -704,7 +704,7 @@ class ee {
|
|
|
704
704
|
});
|
|
705
705
|
if (!s.ok) throw new Error(`Poll failed ${s.status}`);
|
|
706
706
|
const i = await s.json();
|
|
707
|
-
|
|
707
|
+
x(i).forEach((r) => this.handlers.onMessage(r)), this.backoff = v;
|
|
708
708
|
} catch (s) {
|
|
709
709
|
this.handlers.onError(s), this.backoff = Math.min(this.backoff * 1.5, D);
|
|
710
710
|
} finally {
|
|
@@ -742,13 +742,13 @@ class ee {
|
|
|
742
742
|
}
|
|
743
743
|
}
|
|
744
744
|
const te = /* @__PURE__ */ new Set(["TYPING", "THINKING", "SEARCHING", "EXECUTING_TOOL"]);
|
|
745
|
-
function se(
|
|
746
|
-
if (typeof
|
|
747
|
-
const e =
|
|
745
|
+
function se(o) {
|
|
746
|
+
if (typeof o != "object" || o === null) return !1;
|
|
747
|
+
const e = o;
|
|
748
748
|
return te.has(e.eventType) && typeof e.active == "boolean";
|
|
749
749
|
}
|
|
750
|
-
const L = 30 * 60 * 1e3, ie = 3e4,
|
|
751
|
-
class
|
|
750
|
+
const L = 30 * 60 * 1e3, ie = 3e4, T = 30;
|
|
751
|
+
class oe {
|
|
752
752
|
constructor(e, t) {
|
|
753
753
|
this.org = e, this.listeners = /* @__PURE__ */ new Set(), this.activityTimer = null, this.activeEvents = /* @__PURE__ */ new Set(), this.state = {
|
|
754
754
|
isOpen: !1,
|
|
@@ -807,10 +807,10 @@ class re {
|
|
|
807
807
|
author: e.author,
|
|
808
808
|
text: e.text
|
|
809
809
|
};
|
|
810
|
-
return this.state.messages.some((
|
|
810
|
+
return this.state.messages.some((r) => r.id === t.id) ? null : (this.state.messages = x([...this.state.messages, t], T), this.persistMessages(), this.touchActivity(), this.emit(), t);
|
|
811
811
|
}
|
|
812
812
|
setMessages(e) {
|
|
813
|
-
this.state.messages =
|
|
813
|
+
this.state.messages = x(e, T), this.persistMessages(), this.emit();
|
|
814
814
|
}
|
|
815
815
|
clearMessages() {
|
|
816
816
|
this.state.messages = [], this.persistMessages(), this.emit();
|
|
@@ -930,14 +930,14 @@ class re {
|
|
|
930
930
|
const e = localStorage.getItem(this.historyKey);
|
|
931
931
|
if (!e) return [];
|
|
932
932
|
const t = JSON.parse(e);
|
|
933
|
-
return Array.isArray(t) ?
|
|
933
|
+
return Array.isArray(t) ? x(t, T) : [];
|
|
934
934
|
} catch (e) {
|
|
935
935
|
return console.error("SpilkiWidget: unable to load messages", e), [];
|
|
936
936
|
}
|
|
937
937
|
}
|
|
938
938
|
}
|
|
939
|
-
function
|
|
940
|
-
const e =
|
|
939
|
+
function re(o) {
|
|
940
|
+
const e = o.replace(/-/g, "+").replace(/_/g, "/"), t = e.padEnd(e.length + (4 - e.length % 4) % 4, "=");
|
|
941
941
|
if (typeof atob == "function")
|
|
942
942
|
return decodeURIComponent(
|
|
943
943
|
Array.prototype.map.call(atob(t), (i) => `%${`00${i.charCodeAt(0).toString(16)}`.slice(-2)}`).join("")
|
|
@@ -947,19 +947,19 @@ function oe(r) {
|
|
|
947
947
|
return s.from(t, "base64").toString("utf8");
|
|
948
948
|
throw new Error("SpilkiWidget: no base64 decoder available");
|
|
949
949
|
}
|
|
950
|
-
function ne(
|
|
951
|
-
if (!
|
|
952
|
-
const e =
|
|
950
|
+
function ne(o) {
|
|
951
|
+
if (!o) return null;
|
|
952
|
+
const e = o.split(".");
|
|
953
953
|
if (e.length < 2) return null;
|
|
954
954
|
try {
|
|
955
|
-
const t =
|
|
955
|
+
const t = re(e[1]);
|
|
956
956
|
return JSON.parse(t);
|
|
957
957
|
} catch (t) {
|
|
958
958
|
return console.error("SpilkiWidget: unable to parse JWT", t), null;
|
|
959
959
|
}
|
|
960
960
|
}
|
|
961
|
-
function ae(
|
|
962
|
-
const e = ne(
|
|
961
|
+
function ae(o) {
|
|
962
|
+
const e = ne(o);
|
|
963
963
|
if (!(e != null && e.exp) || typeof e.exp != "number") return !0;
|
|
964
964
|
const t = Math.floor(Date.now() / 1e3);
|
|
965
965
|
return e.exp < t + 60;
|
|
@@ -976,8 +976,8 @@ const le = {
|
|
|
976
976
|
onTransportChange() {
|
|
977
977
|
}
|
|
978
978
|
};
|
|
979
|
-
async function ce(
|
|
980
|
-
const s = `${
|
|
979
|
+
async function ce(o, e, t) {
|
|
980
|
+
const s = `${o.replace(/\/$/, "")}/widget/install`, i = await fetch(s, {
|
|
981
981
|
method: "POST",
|
|
982
982
|
headers: { "Content-Type": "application/json", Origin: window.location.origin },
|
|
983
983
|
body: JSON.stringify({ token: e, organisationId: t })
|
|
@@ -985,19 +985,19 @@ async function ce(r, e, t) {
|
|
|
985
985
|
if (!i.ok) throw new Error(`SpilkiWidget: install failed (${i.status})`);
|
|
986
986
|
return (await i.json()).accessToken;
|
|
987
987
|
}
|
|
988
|
-
async function he(
|
|
989
|
-
const t = `${
|
|
988
|
+
async function he(o, e) {
|
|
989
|
+
const t = `${o.replace(/\/$/, "")}/widget/refresh`, s = await fetch(t, {
|
|
990
990
|
method: "POST",
|
|
991
991
|
headers: { "X-Authorization": `Bearer ${e}`, Origin: window.location.origin }
|
|
992
992
|
});
|
|
993
993
|
if (!s.ok) throw new Error(`SpilkiWidget: refresh failed (${s.status})`);
|
|
994
994
|
return (await s.json()).accessToken;
|
|
995
995
|
}
|
|
996
|
-
function de(
|
|
996
|
+
function de(o) {
|
|
997
997
|
let e = !1, t = null;
|
|
998
998
|
const s = [], i = () => {
|
|
999
999
|
var n;
|
|
1000
|
-
if (!
|
|
1000
|
+
if (!o) return null;
|
|
1001
1001
|
if (t) return t;
|
|
1002
1002
|
try {
|
|
1003
1003
|
const l = (n = window.AudioContext) != null ? n : window.webkitAudioContext;
|
|
@@ -1007,7 +1007,7 @@ function de(r) {
|
|
|
1007
1007
|
return null;
|
|
1008
1008
|
}
|
|
1009
1009
|
return t;
|
|
1010
|
-
},
|
|
1010
|
+
}, r = () => {
|
|
1011
1011
|
e = !0;
|
|
1012
1012
|
try {
|
|
1013
1013
|
const n = i();
|
|
@@ -1017,23 +1017,23 @@ function de(r) {
|
|
|
1017
1017
|
}
|
|
1018
1018
|
}, a = (n) => {
|
|
1019
1019
|
const l = () => {
|
|
1020
|
-
|
|
1020
|
+
r(), window.removeEventListener(n, l, !0);
|
|
1021
1021
|
};
|
|
1022
1022
|
s.push({ type: n, listener: l }), window.addEventListener(n, l, { capture: !0, passive: !0 });
|
|
1023
1023
|
};
|
|
1024
1024
|
return a("pointerdown"), a("keydown"), {
|
|
1025
|
-
markUserInteraction:
|
|
1025
|
+
markUserInteraction: r,
|
|
1026
1026
|
play() {
|
|
1027
|
-
if (!
|
|
1027
|
+
if (!o || !e) return;
|
|
1028
1028
|
const n = i();
|
|
1029
1029
|
if (!n || n.state !== "running") return;
|
|
1030
1030
|
const l = n.createGain();
|
|
1031
1031
|
l.gain.value = 0.15, l.connect(n.destination);
|
|
1032
|
-
const
|
|
1033
|
-
const
|
|
1034
|
-
|
|
1035
|
-
},
|
|
1036
|
-
|
|
1032
|
+
const g = (h, d, m) => {
|
|
1033
|
+
const f = n.createOscillator(), p = n.createGain();
|
|
1034
|
+
f.type = "sine", f.frequency.setValueAtTime(h, d), p.gain.setValueAtTime(1e-4, d), p.gain.exponentialRampToValueAtTime(1, d + 0.012), p.gain.exponentialRampToValueAtTime(1e-4, d + m), f.connect(p), p.connect(l), f.start(d), f.stop(d + m + 0.02);
|
|
1035
|
+
}, u = n.currentTime;
|
|
1036
|
+
g(880, u, 0.08), g(1175, u + 0.09, 0.08);
|
|
1037
1037
|
},
|
|
1038
1038
|
destroy() {
|
|
1039
1039
|
s.forEach(({ type: n, listener: l }) => {
|
|
@@ -1043,69 +1043,69 @@ function de(r) {
|
|
|
1043
1043
|
}
|
|
1044
1044
|
};
|
|
1045
1045
|
}
|
|
1046
|
-
function U(
|
|
1047
|
-
var
|
|
1048
|
-
if (!
|
|
1046
|
+
function U(o) {
|
|
1047
|
+
var I, O, M, B;
|
|
1048
|
+
if (!o.org)
|
|
1049
1049
|
throw new Error("SpilkiWidget: org is required");
|
|
1050
|
-
const e = H(
|
|
1050
|
+
const e = H(o);
|
|
1051
1051
|
G(e.allowedOriginsHint);
|
|
1052
|
-
const t = { ...le, ...(
|
|
1053
|
-
let
|
|
1052
|
+
const t = { ...le, ...(I = e.hooks) != null ? I : {} }, s = new oe(e.org, { persist: e.persist }), i = de(e.sound);
|
|
1053
|
+
let r = (O = s.accessToken) != null ? O : void 0, a = null;
|
|
1054
1054
|
const n = () => {
|
|
1055
|
-
|
|
1055
|
+
u.setBadge(s.countUnread());
|
|
1056
1056
|
}, l = () => {
|
|
1057
|
-
s.markRead(),
|
|
1058
|
-
},
|
|
1057
|
+
s.markRead(), u.setBadge(0);
|
|
1058
|
+
}, g = async () => a || (a = (async () => {
|
|
1059
1059
|
try {
|
|
1060
|
-
if (
|
|
1060
|
+
if (r && ae(r))
|
|
1061
1061
|
try {
|
|
1062
|
-
|
|
1062
|
+
r = await he(e.apiBase, r), s.persistAccessToken(r), d.setAccessToken(r);
|
|
1063
1063
|
return;
|
|
1064
1064
|
} catch {
|
|
1065
|
-
|
|
1065
|
+
r = void 0, s.clearAccessToken();
|
|
1066
1066
|
}
|
|
1067
|
-
if (!
|
|
1068
|
-
if (!
|
|
1069
|
-
if (!
|
|
1070
|
-
|
|
1067
|
+
if (!r) {
|
|
1068
|
+
if (!o.installationToken) throw new Error("SpilkiWidget: missing installationToken");
|
|
1069
|
+
if (!o.org) throw new Error("SpilkiWidget: missing org");
|
|
1070
|
+
r = await ce(e.apiBase, o.installationToken, o.org), s.persistAccessToken(r), d.setAccessToken(r);
|
|
1071
1071
|
}
|
|
1072
1072
|
} finally {
|
|
1073
1073
|
a = null;
|
|
1074
1074
|
}
|
|
1075
|
-
})(), a),
|
|
1075
|
+
})(), a), u = R({
|
|
1076
1076
|
color: e.color,
|
|
1077
|
-
position: (
|
|
1077
|
+
position: (M = e.position) != null ? M : "bottom-right",
|
|
1078
1078
|
onClick: () => {
|
|
1079
1079
|
s.snapshot.isOpen ? (s.close(), t.onClose()) : (i.markUserInteraction(), s.open(), l(), t.onOpen());
|
|
1080
1080
|
}
|
|
1081
1081
|
}), h = new Q({
|
|
1082
1082
|
color: e.color,
|
|
1083
1083
|
theme: P(e.theme),
|
|
1084
|
-
position: (
|
|
1084
|
+
position: (B = e.position) != null ? B : "bottom-right",
|
|
1085
1085
|
i18n: e.i18n,
|
|
1086
1086
|
onClose: () => {
|
|
1087
1087
|
s.close(), t.onClose();
|
|
1088
1088
|
},
|
|
1089
1089
|
onSend: (c) => {
|
|
1090
|
-
const
|
|
1091
|
-
|
|
1092
|
-
t.onError(
|
|
1090
|
+
const k = s.addMessage({ author: "user", text: c });
|
|
1091
|
+
k && (h.appendMessage(k), g().then(() => d.send(c, k.id)).catch((b) => {
|
|
1092
|
+
t.onError(b), s.setConnected(!1), h.setOffline(!0);
|
|
1093
1093
|
}));
|
|
1094
1094
|
}
|
|
1095
1095
|
}), d = new ee(
|
|
1096
1096
|
{
|
|
1097
1097
|
apiBase: e.apiBase,
|
|
1098
|
-
accessToken:
|
|
1098
|
+
accessToken: r,
|
|
1099
1099
|
org: e.org,
|
|
1100
1100
|
sessionId: s.sessionId
|
|
1101
1101
|
},
|
|
1102
1102
|
{
|
|
1103
1103
|
onOpen(c) {
|
|
1104
|
-
|
|
1104
|
+
A.transport = c, t.onTransportChange(c), s.setConnected(!0), h.setOffline(!1);
|
|
1105
1105
|
},
|
|
1106
1106
|
onMessage(c) {
|
|
1107
|
-
const
|
|
1108
|
-
|
|
1107
|
+
const b = c.suggestedReplies, y = s.addMessage(c);
|
|
1108
|
+
y && (h.appendMessage(y), y.author === "bot" && b && b.length > 0 && h.setSuggestedReplies(b), !s.snapshot.isOpen && y.author === "bot" && (n(), i.play()), t.onMessage(y));
|
|
1109
1109
|
},
|
|
1110
1110
|
onTyping(c) {
|
|
1111
1111
|
s.setTyping(c);
|
|
@@ -1118,9 +1118,9 @@ function U(r) {
|
|
|
1118
1118
|
}
|
|
1119
1119
|
}
|
|
1120
1120
|
);
|
|
1121
|
-
|
|
1122
|
-
const
|
|
1123
|
-
if (
|
|
1121
|
+
u.mount(), h.mount();
|
|
1122
|
+
const m = s.snapshot.messages, f = s.isSessionExpired(), p = s.getConversationGroups();
|
|
1123
|
+
if (m.length === 0 && e.welcome) {
|
|
1124
1124
|
const c = {
|
|
1125
1125
|
id: "welcome",
|
|
1126
1126
|
author: "bot",
|
|
@@ -1128,30 +1128,30 @@ function U(r) {
|
|
|
1128
1128
|
ts: Date.now()
|
|
1129
1129
|
};
|
|
1130
1130
|
s.addMessage(c), h.appendMessage(c);
|
|
1131
|
-
} else
|
|
1132
|
-
let
|
|
1131
|
+
} else f && m.length > 0 ? h.renderWithConversations(p, []) : p.length > 1 ? h.renderWithConversations(p.slice(0, -1), p[p.length - 1].messages) : h.updateMessages(m);
|
|
1132
|
+
let S = !1;
|
|
1133
1133
|
const $ = s.subscribe(() => {
|
|
1134
1134
|
const c = s.snapshot;
|
|
1135
|
-
if (
|
|
1136
|
-
if (!
|
|
1137
|
-
const
|
|
1138
|
-
l(),
|
|
1135
|
+
if (u.setOpen(c.isOpen), h.setAgentActivity(c.agentActivity, e.i18n), h.setOffline(!c.isConnected), h.updateTheme(P(e.theme)), c.isOpen) {
|
|
1136
|
+
if (!S) {
|
|
1137
|
+
const k = s.countUnread() > 0, b = s.lastReadTs;
|
|
1138
|
+
l(), k && h.scrollToFirstUnread(b);
|
|
1139
1139
|
}
|
|
1140
|
-
|
|
1140
|
+
S = !0, h.show();
|
|
1141
1141
|
} else
|
|
1142
|
-
|
|
1143
|
-
}), W =
|
|
1144
|
-
n(),
|
|
1142
|
+
S = !1, h.hide();
|
|
1143
|
+
}), W = m.length === 0 || f;
|
|
1144
|
+
n(), g().then(
|
|
1145
1145
|
() => d.connect().then((c) => {
|
|
1146
|
-
var
|
|
1147
|
-
e.persist && s.persistSession(c.sessionId), s.setConnected(!0), t.onTransportChange((
|
|
1148
|
-
const
|
|
1149
|
-
|
|
1146
|
+
var b, y;
|
|
1147
|
+
e.persist && s.persistSession(c.sessionId), s.setConnected(!0), t.onTransportChange((b = d.kind) != null ? b : "ws");
|
|
1148
|
+
const k = (y = c.suggestedReplies) != null ? y : [];
|
|
1149
|
+
k.length > 0 && W && h.setSuggestedReplies(k);
|
|
1150
1150
|
})
|
|
1151
1151
|
).catch((c) => {
|
|
1152
1152
|
t.onError(c), s.setConnected(!1), h.setOffline(!0);
|
|
1153
1153
|
});
|
|
1154
|
-
const
|
|
1154
|
+
const A = {
|
|
1155
1155
|
transport: null,
|
|
1156
1156
|
open() {
|
|
1157
1157
|
i.markUserInteraction(), s.open(), l(), t.onOpen();
|
|
@@ -1160,17 +1160,17 @@ function U(r) {
|
|
|
1160
1160
|
s.close(), t.onClose();
|
|
1161
1161
|
},
|
|
1162
1162
|
destroy() {
|
|
1163
|
-
$(), d.stop(), i.destroy(),
|
|
1163
|
+
$(), d.stop(), i.destroy(), u.destroy(), h.destroy();
|
|
1164
1164
|
}
|
|
1165
1165
|
};
|
|
1166
|
-
return
|
|
1166
|
+
return A;
|
|
1167
1167
|
}
|
|
1168
1168
|
function N() {
|
|
1169
1169
|
var s, i;
|
|
1170
1170
|
if (typeof document == "undefined") return;
|
|
1171
|
-
const
|
|
1172
|
-
if (!
|
|
1173
|
-
const e =
|
|
1171
|
+
const o = document.currentScript;
|
|
1172
|
+
if (!o) return;
|
|
1173
|
+
const e = o.dataset;
|
|
1174
1174
|
if (e.autoinit === "false") return;
|
|
1175
1175
|
const t = e.org;
|
|
1176
1176
|
if (!t) {
|
|
@@ -1185,7 +1185,7 @@ function N() {
|
|
|
1185
1185
|
theme: (i = e.theme) != null ? i : void 0
|
|
1186
1186
|
});
|
|
1187
1187
|
}
|
|
1188
|
-
typeof window != "undefined" && (window.SpilkiWidget = window.SpilkiWidget || {}, window.SpilkiWidget.init = (
|
|
1188
|
+
typeof window != "undefined" && (window.SpilkiWidget = window.SpilkiWidget || {}, window.SpilkiWidget.init = (o) => U(o));
|
|
1189
1189
|
N();
|
|
1190
1190
|
N();
|
|
1191
1191
|
//# sourceMappingURL=bootstrap.es.js.map
|