@squadico/chatbot 1.4.0 → 1.5.0
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 +5 -4
- package/dist/answer-CDGrP8YE.js.map +1 -1
- package/dist/answer-DRaV2dVt.cjs.map +1 -1
- package/dist/chatbot.global.js +11 -11
- package/dist/chatbot.global.js.map +1 -1
- package/dist/components/ChatbotWidget.d.ts.map +1 -1
- package/dist/element.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/conversation.d.ts +5 -1
- package/dist/lib/conversation.d.ts.map +1 -1
- package/dist/lib/useChat.d.ts +6 -0
- package/dist/lib/useChat.d.ts.map +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +2 -2
- package/dist/react.js.map +1 -1
- package/dist/{src-BjqOavOO.js → src-BWDC0W4O.js} +456 -435
- package/dist/src-BWDC0W4O.js.map +1 -0
- package/dist/src-DvrmRR89.cjs +7 -0
- package/dist/src-DvrmRR89.cjs.map +1 -0
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/widgets/extras-loader.d.ts +1 -1
- package/package.json +1 -1
- package/dist/src-BjqOavOO.js.map +0 -1
- package/dist/src-DS8P9HdZ.cjs +0 -7
- package/dist/src-DS8P9HdZ.cjs.map +0 -1
|
@@ -52,19 +52,19 @@ function k(e, t) {
|
|
|
52
52
|
}
|
|
53
53
|
//#endregion
|
|
54
54
|
//#region src/lib/rail.ts
|
|
55
|
-
function
|
|
55
|
+
function ee(e, t) {
|
|
56
56
|
for (let t = e.length - 1; t >= 0; --t) {
|
|
57
57
|
let n = e[t];
|
|
58
58
|
if (n.role === "assistant" && n.agent) return n.agent.handle;
|
|
59
59
|
}
|
|
60
60
|
return t;
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function A(e, t, n) {
|
|
63
63
|
return !t || t === n || e.trimStart().startsWith("@") ? e : `@${t} ${e}`;
|
|
64
64
|
}
|
|
65
65
|
//#endregion
|
|
66
66
|
//#region src/lib/uid.ts
|
|
67
|
-
function
|
|
67
|
+
function j() {
|
|
68
68
|
let e = globalThis.crypto;
|
|
69
69
|
if (e && typeof e.randomUUID == "function") return e.randomUUID();
|
|
70
70
|
let t = /* @__PURE__ */ new Uint8Array(16);
|
|
@@ -77,36 +77,36 @@ function M() {
|
|
|
77
77
|
}
|
|
78
78
|
//#endregion
|
|
79
79
|
//#region \0@oxc-project+runtime@0.147.0/helpers/esm/typeof.js
|
|
80
|
-
function
|
|
80
|
+
function M(e) {
|
|
81
81
|
"@babel/helpers - typeof";
|
|
82
|
-
return
|
|
82
|
+
return M = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
|
|
83
83
|
return typeof e;
|
|
84
84
|
} : function(e) {
|
|
85
85
|
return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
|
|
86
|
-
},
|
|
86
|
+
}, M(e);
|
|
87
87
|
}
|
|
88
88
|
//#endregion
|
|
89
89
|
//#region \0@oxc-project+runtime@0.147.0/helpers/esm/toPrimitive.js
|
|
90
|
-
function
|
|
91
|
-
if (
|
|
90
|
+
function N(e, t) {
|
|
91
|
+
if (M(e) != "object" || !e) return e;
|
|
92
92
|
var n = e[Symbol.toPrimitive];
|
|
93
93
|
if (n !== void 0) {
|
|
94
94
|
var r = n.call(e, t || "default");
|
|
95
|
-
if (
|
|
95
|
+
if (M(r) != "object") return r;
|
|
96
96
|
throw TypeError("@@toPrimitive must return a primitive value.");
|
|
97
97
|
}
|
|
98
98
|
return (t === "string" ? String : Number)(e);
|
|
99
99
|
}
|
|
100
100
|
//#endregion
|
|
101
101
|
//#region \0@oxc-project+runtime@0.147.0/helpers/esm/toPropertyKey.js
|
|
102
|
-
function
|
|
103
|
-
var t =
|
|
104
|
-
return
|
|
102
|
+
function P(e) {
|
|
103
|
+
var t = N(e, "string");
|
|
104
|
+
return M(t) == "symbol" ? t : t + "";
|
|
105
105
|
}
|
|
106
106
|
//#endregion
|
|
107
107
|
//#region \0@oxc-project+runtime@0.147.0/helpers/esm/defineProperty.js
|
|
108
|
-
function
|
|
109
|
-
return (t =
|
|
108
|
+
function F(e, t, n) {
|
|
109
|
+
return (t = P(t)) in e ? Object.defineProperty(e, t, {
|
|
110
110
|
value: n,
|
|
111
111
|
enumerable: !0,
|
|
112
112
|
configurable: !0,
|
|
@@ -115,15 +115,15 @@ function I(e, t, n) {
|
|
|
115
115
|
}
|
|
116
116
|
//#endregion
|
|
117
117
|
//#region src/lib/client.ts
|
|
118
|
-
var
|
|
118
|
+
var I = "https://api.squadico.com", L = 2e4, R = class extends Error {
|
|
119
119
|
constructor(e, t, n) {
|
|
120
|
-
super(e),
|
|
120
|
+
super(e), F(this, "status", void 0), F(this, "code", void 0), this.name = "ChatHttpError", this.status = t, this.code = n;
|
|
121
121
|
}
|
|
122
122
|
};
|
|
123
|
-
function
|
|
123
|
+
function z(e, t) {
|
|
124
124
|
return `${e.replace(/\/+$/, "")}${t}`;
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function B(e, t) {
|
|
127
127
|
return {
|
|
128
128
|
"Content-Type": "application/json",
|
|
129
129
|
Accept: "text/event-stream, application/json",
|
|
@@ -131,21 +131,21 @@ function V(e, t) {
|
|
|
131
131
|
...t ? { "X-Subject-Token": t } : {}
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
|
-
function
|
|
134
|
+
function te(e) {
|
|
135
135
|
if (!e || typeof e != "object") return;
|
|
136
136
|
let { loc: t, msg: n } = e;
|
|
137
137
|
if (typeof n != "string" || !n) return;
|
|
138
138
|
let r = (Array.isArray(t) ? t.filter((e) => typeof e == "string") : []).at(-1);
|
|
139
139
|
return r && r !== "body" ? `${r}: ${n}` : n;
|
|
140
140
|
}
|
|
141
|
-
async function
|
|
141
|
+
async function V(e) {
|
|
142
142
|
let t = "", n;
|
|
143
143
|
try {
|
|
144
144
|
let r = await e.text();
|
|
145
145
|
if (r) try {
|
|
146
146
|
let e = JSON.parse(r), i = e.detail ?? e.message;
|
|
147
147
|
if (Array.isArray(i)) {
|
|
148
|
-
let e = i.map((e) =>
|
|
148
|
+
let e = i.map((e) => te(e) ?? (typeof e == "string" ? e : void 0)).filter((e) => e !== void 0);
|
|
149
149
|
t = e.length > 0 ? e.join(", ") : r;
|
|
150
150
|
} else t = typeof i == "string" ? i : r;
|
|
151
151
|
n = typeof e.code == "string" ? e.code : void 0;
|
|
@@ -153,29 +153,29 @@ async function H(e) {
|
|
|
153
153
|
t = r;
|
|
154
154
|
}
|
|
155
155
|
} catch {}
|
|
156
|
-
return new
|
|
156
|
+
return new R(t || `The API answered ${e.status}`, e.status, n);
|
|
157
157
|
}
|
|
158
|
-
function
|
|
158
|
+
function H(e, t) {
|
|
159
159
|
if (!e || typeof e != "object") return;
|
|
160
160
|
let n = e;
|
|
161
161
|
if (!(typeof n.handle != "string" || !n.handle)) return {
|
|
162
162
|
handle: n.handle,
|
|
163
163
|
name: typeof n.name == "string" ? n.name : n.handle,
|
|
164
|
-
avatarUrl: typeof n.avatar_url == "string" && n.avatar_url ?
|
|
164
|
+
avatarUrl: typeof n.avatar_url == "string" && n.avatar_url ? z(t, n.avatar_url) : void 0,
|
|
165
165
|
color: typeof n.color == "string" ? n.color : void 0
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
|
-
function
|
|
169
|
-
return (Array.isArray(e) ? e : []).map((e) =>
|
|
168
|
+
function U(e, t) {
|
|
169
|
+
return (Array.isArray(e) ? e : []).map((e) => H(e, t)).filter((e) => e !== void 0);
|
|
170
170
|
}
|
|
171
|
-
var
|
|
171
|
+
var W = [
|
|
172
172
|
"knowledge",
|
|
173
173
|
"skill",
|
|
174
174
|
"delegation",
|
|
175
175
|
"tool"
|
|
176
176
|
];
|
|
177
177
|
function G(e) {
|
|
178
|
-
return
|
|
178
|
+
return W.find((t) => t === e) ?? "tool";
|
|
179
179
|
}
|
|
180
180
|
function K(e) {
|
|
181
181
|
if (!e || typeof e != "object") return;
|
|
@@ -191,11 +191,11 @@ function J(e, t) {
|
|
|
191
191
|
if (typeof e.role != "string" || !q.has(e.role) || typeof e.content != "string" || !e.content) return null;
|
|
192
192
|
let n = typeof e.created_at == "string" ? Date.parse(e.created_at) : NaN;
|
|
193
193
|
return {
|
|
194
|
-
id: typeof e.id == "string" && e.id ? e.id :
|
|
194
|
+
id: typeof e.id == "string" && e.id ? e.id : j(),
|
|
195
195
|
role: e.role,
|
|
196
196
|
content: e.content,
|
|
197
197
|
createdAt: Number.isNaN(n) ? Date.now() : n,
|
|
198
|
-
agent:
|
|
198
|
+
agent: H(e.agent, t),
|
|
199
199
|
attachments: Y(e.attachments),
|
|
200
200
|
authorName: e.kind === "human" && typeof e.author_name == "string" && e.author_name ? e.author_name : void 0
|
|
201
201
|
};
|
|
@@ -216,34 +216,34 @@ function X(e) {
|
|
|
216
216
|
};
|
|
217
217
|
}
|
|
218
218
|
async function ne(e) {
|
|
219
|
-
let t = e.agent ? `?agent=${encodeURIComponent(e.agent)}` : "", n = await fetch(
|
|
219
|
+
let t = e.agent ? `?agent=${encodeURIComponent(e.agent)}` : "", n = await fetch(z(e.apiUrl, `/public/applications/${encodeURIComponent(e.embedKey)}${t}`), {
|
|
220
220
|
method: "GET",
|
|
221
|
-
headers:
|
|
221
|
+
headers: B(),
|
|
222
222
|
signal: e.signal
|
|
223
223
|
});
|
|
224
|
-
if (!n.ok) throw await
|
|
224
|
+
if (!n.ok) throw await V(n);
|
|
225
225
|
let r = await n.json();
|
|
226
226
|
return {
|
|
227
227
|
welcomeMessage: typeof r.welcome_message == "string" && r.welcome_message ? r.welcome_message : void 0,
|
|
228
|
-
agent:
|
|
229
|
-
handles:
|
|
228
|
+
agent: H(r.agent, e.apiUrl),
|
|
229
|
+
handles: U(r.handles, e.apiUrl),
|
|
230
230
|
agentHandle: typeof r.agent_handle == "string" && r.agent_handle ? r.agent_handle : void 0,
|
|
231
231
|
branding: r.branding === !0
|
|
232
232
|
};
|
|
233
233
|
}
|
|
234
234
|
async function re(e) {
|
|
235
|
-
let t = await fetch(
|
|
235
|
+
let t = await fetch(z(e.apiUrl, `/public/applications/${encodeURIComponent(e.embedKey)}/conversations`), {
|
|
236
236
|
method: "POST",
|
|
237
|
-
headers:
|
|
237
|
+
headers: B(),
|
|
238
238
|
body: JSON.stringify({
|
|
239
239
|
...e.user ? { user: e.user } : {},
|
|
240
240
|
...e.agent ? { agent: e.agent } : {}
|
|
241
241
|
}),
|
|
242
242
|
signal: e.signal
|
|
243
243
|
});
|
|
244
|
-
if (!t.ok) throw await
|
|
244
|
+
if (!t.ok) throw await V(t);
|
|
245
245
|
let n = await t.json();
|
|
246
|
-
if (typeof n.id != "string" || typeof n.visitor_token != "string") throw new
|
|
246
|
+
if (typeof n.id != "string" || typeof n.visitor_token != "string") throw new R("The API opened a conversation without an id or a token");
|
|
247
247
|
let r = (Array.isArray(n.messages) ? n.messages : []).map((t) => J(t, e.apiUrl)).filter((e) => e !== null);
|
|
248
248
|
return {
|
|
249
249
|
conversationId: n.id,
|
|
@@ -252,21 +252,21 @@ async function re(e) {
|
|
|
252
252
|
agentSlug: typeof n.agent_slug == "string" ? n.agent_slug : "",
|
|
253
253
|
welcomeMessage: typeof n.welcome_message == "string" && n.welcome_message ? n.welcome_message : void 0,
|
|
254
254
|
messages: r,
|
|
255
|
-
handles:
|
|
255
|
+
handles: U(n.handles, e.apiUrl),
|
|
256
256
|
agentHandle: typeof n.agent_handle == "string" && n.agent_handle ? n.agent_handle : void 0,
|
|
257
257
|
withHuman: typeof n.handling == "string" && n.handling !== "agents",
|
|
258
258
|
branding: n.branding === !0
|
|
259
259
|
};
|
|
260
260
|
}
|
|
261
261
|
async function ie(e) {
|
|
262
|
-
let t = await fetch(
|
|
262
|
+
let t = await fetch(z(e.apiUrl, `/public/conversations/${encodeURIComponent(e.conversationId)}`), {
|
|
263
263
|
method: "GET",
|
|
264
|
-
headers:
|
|
264
|
+
headers: B(e.visitorToken),
|
|
265
265
|
signal: e.signal
|
|
266
266
|
});
|
|
267
|
-
if (!t.ok) throw await
|
|
267
|
+
if (!t.ok) throw await V(t);
|
|
268
268
|
let n = await t.json();
|
|
269
|
-
if (typeof n.id != "string") throw new
|
|
269
|
+
if (typeof n.id != "string") throw new R("The API replayed a conversation without an id");
|
|
270
270
|
return {
|
|
271
271
|
conversationId: n.id,
|
|
272
272
|
visitorToken: e.visitorToken,
|
|
@@ -274,7 +274,7 @@ async function ie(e) {
|
|
|
274
274
|
agentSlug: typeof n.agent_slug == "string" ? n.agent_slug : "",
|
|
275
275
|
welcomeMessage: typeof n.welcome_message == "string" && n.welcome_message ? n.welcome_message : void 0,
|
|
276
276
|
messages: (Array.isArray(n.messages) ? n.messages : []).map((t) => J(t, e.apiUrl)).filter((e) => e !== null),
|
|
277
|
-
handles:
|
|
277
|
+
handles: U(n.handles, e.apiUrl),
|
|
278
278
|
agentHandle: typeof n.agent_handle == "string" && n.agent_handle ? n.agent_handle : void 0,
|
|
279
279
|
withHuman: typeof n.handling == "string" && n.handling !== "agents",
|
|
280
280
|
branding: n.branding === !0
|
|
@@ -283,61 +283,61 @@ async function ie(e) {
|
|
|
283
283
|
async function ae(e) {
|
|
284
284
|
let t = new FormData();
|
|
285
285
|
t.append("file", e.file);
|
|
286
|
-
let n = await fetch(
|
|
286
|
+
let n = await fetch(Z(e), {
|
|
287
287
|
method: "POST",
|
|
288
288
|
headers: { "X-Visitor-Token": e.visitorToken },
|
|
289
289
|
body: t,
|
|
290
290
|
signal: e.signal
|
|
291
291
|
});
|
|
292
|
-
if (!n.ok) throw await
|
|
292
|
+
if (!n.ok) throw await V(n);
|
|
293
293
|
let r = X(await n.json());
|
|
294
|
-
if (!r) throw new
|
|
294
|
+
if (!r) throw new R("The upload could not be read", n.status);
|
|
295
295
|
return r;
|
|
296
296
|
}
|
|
297
297
|
async function oe(e) {
|
|
298
|
-
let t = await fetch(`${
|
|
298
|
+
let t = await fetch(`${Z(e)}/${encodeURIComponent(e.attachmentId)}`, {
|
|
299
299
|
method: "DELETE",
|
|
300
300
|
headers: { "X-Visitor-Token": e.visitorToken },
|
|
301
301
|
signal: e.signal
|
|
302
302
|
});
|
|
303
|
-
if (!t.ok) throw await
|
|
303
|
+
if (!t.ok) throw await V(t);
|
|
304
304
|
}
|
|
305
|
-
async function
|
|
306
|
-
let t = await fetch(`${
|
|
305
|
+
async function se(e) {
|
|
306
|
+
let t = await fetch(`${Z(e)}/${encodeURIComponent(e.attachmentId)}/content`, {
|
|
307
307
|
headers: { "X-Visitor-Token": e.visitorToken },
|
|
308
308
|
signal: e.signal
|
|
309
309
|
});
|
|
310
|
-
if (!t.ok) throw await
|
|
310
|
+
if (!t.ok) throw await V(t);
|
|
311
311
|
return t.blob();
|
|
312
312
|
}
|
|
313
|
-
function
|
|
314
|
-
return
|
|
313
|
+
function Z(e) {
|
|
314
|
+
return z(e.apiUrl, `/public/conversations/${encodeURIComponent(e.conversationId)}/attachments`);
|
|
315
315
|
}
|
|
316
|
-
async function
|
|
317
|
-
return
|
|
316
|
+
async function ce(e) {
|
|
317
|
+
return le(z(e.apiUrl, `/public/conversations/${encodeURIComponent(e.conversationId)}/messages`), {
|
|
318
318
|
content: e.message,
|
|
319
319
|
attachment_ids: e.attachmentIds ?? [],
|
|
320
320
|
...e.context && Object.keys(e.context).length > 0 ? { context: e.context } : {}
|
|
321
321
|
}, e);
|
|
322
322
|
}
|
|
323
|
-
async function
|
|
324
|
-
return
|
|
323
|
+
async function Q(e) {
|
|
324
|
+
return le(z(e.apiUrl, `/public/conversations/${encodeURIComponent(e.conversationId)}/approvals`), {
|
|
325
325
|
tool_call_id: e.toolCallId,
|
|
326
326
|
approved: e.approved
|
|
327
327
|
}, e);
|
|
328
328
|
}
|
|
329
|
-
async function
|
|
329
|
+
async function le(e, t, n) {
|
|
330
330
|
let r = await fetch(e, {
|
|
331
331
|
method: "POST",
|
|
332
|
-
headers:
|
|
332
|
+
headers: B(n.visitorToken, n.subjectToken),
|
|
333
333
|
body: JSON.stringify({
|
|
334
334
|
...t,
|
|
335
335
|
widgets: 1
|
|
336
336
|
}),
|
|
337
337
|
signal: n.signal
|
|
338
338
|
});
|
|
339
|
-
if (!r.ok) throw await
|
|
340
|
-
if (!r.body) throw new
|
|
339
|
+
if (!r.ok) throw await V(r);
|
|
340
|
+
if (!r.body) throw new R("Answer with no stream body");
|
|
341
341
|
let i = r.body.getReader(), a = new TextDecoder(), o = "", s = "", c = "", l, u, d = { answer: "" };
|
|
342
342
|
try {
|
|
343
343
|
for (;;) {
|
|
@@ -365,30 +365,31 @@ async function ce(e, t, n) {
|
|
|
365
365
|
} catch {
|
|
366
366
|
continue;
|
|
367
367
|
}
|
|
368
|
-
s === "token" && typeof i.text == "string" ? (c += i.text, n.onToken(i.text)) : s === "progress" ? n.onProgress?.(G(i.activity)) : s === "done" ? (d.answer = typeof i.content == "string" ? i.content : c, d.agent =
|
|
368
|
+
s === "token" && typeof i.text == "string" ? (c += i.text, n.onToken(i.text)) : s === "progress" ? n.onProgress?.(G(i.activity)) : s === "done" ? (d.answer = typeof i.content == "string" ? i.content : c, d.agent = H(i.agent, n.apiUrl), typeof i.unknown_handle == "string" && i.unknown_handle && (d.unknownHandle = i.unknown_handle, d.offered = U(i.handles, n.apiUrl))) : s === "handoff" ? (typeof i.to_agent_name == "string" && (u = i.to_agent_name), c = "") : s === "escalated" ? d.withHuman = !0 : s === "held" ? (d.held = !0, d.withHuman = !0) : s === "approval_required" ? d.approval = K(i) : s === "error" && (l = typeof i.detail == "string" ? i.detail : "The turn failed");
|
|
369
369
|
}
|
|
370
370
|
if (l) break;
|
|
371
371
|
}
|
|
372
372
|
} finally {
|
|
373
373
|
i.cancel().catch(() => void 0);
|
|
374
374
|
}
|
|
375
|
-
if (l) throw new
|
|
375
|
+
if (l) throw new R(l);
|
|
376
376
|
return !d.answer && !d.approval && (d.answer = c), u && !d.agent && (d.authorName = u), d;
|
|
377
377
|
}
|
|
378
378
|
//#endregion
|
|
379
379
|
//#region src/lib/conversation.ts
|
|
380
|
-
var
|
|
380
|
+
var $ = "squadico-chatbot:conversation";
|
|
381
381
|
function ue() {
|
|
382
382
|
try {
|
|
383
383
|
if (typeof sessionStorage > "u") return;
|
|
384
|
-
let e = sessionStorage.getItem(
|
|
384
|
+
let e = sessionStorage.getItem($);
|
|
385
385
|
if (!e) return;
|
|
386
386
|
let t = JSON.parse(e);
|
|
387
387
|
return !t.sessionId || !t.visitorToken || !t.embedKey ? void 0 : {
|
|
388
388
|
sessionId: t.sessionId,
|
|
389
389
|
visitorToken: t.visitorToken,
|
|
390
390
|
embedKey: t.embedKey,
|
|
391
|
-
user: typeof t.user == "string" ? t.user : void 0
|
|
391
|
+
user: typeof t.user == "string" ? t.user : void 0,
|
|
392
|
+
scope: typeof t.scope == "string" ? t.scope : void 0
|
|
392
393
|
};
|
|
393
394
|
} catch {
|
|
394
395
|
return;
|
|
@@ -397,17 +398,17 @@ function ue() {
|
|
|
397
398
|
function de(e) {
|
|
398
399
|
try {
|
|
399
400
|
if (typeof sessionStorage > "u") return;
|
|
400
|
-
sessionStorage.setItem(
|
|
401
|
+
sessionStorage.setItem($, JSON.stringify(e));
|
|
401
402
|
} catch {}
|
|
402
403
|
}
|
|
403
404
|
function fe() {
|
|
404
405
|
try {
|
|
405
406
|
if (typeof sessionStorage > "u") return;
|
|
406
|
-
sessionStorage.removeItem(
|
|
407
|
+
sessionStorage.removeItem($);
|
|
407
408
|
} catch {}
|
|
408
409
|
}
|
|
409
|
-
function pe(e, { embedKey: t, user: n }) {
|
|
410
|
-
return e.embedKey === t && e.user === n;
|
|
410
|
+
function pe(e, { embedKey: t, user: n, scope: r }) {
|
|
411
|
+
return e.embedKey === t && e.user === n && e.scope === r;
|
|
411
412
|
}
|
|
412
413
|
//#endregion
|
|
413
414
|
//#region src/lib/useChat.ts
|
|
@@ -419,113 +420,119 @@ async function me(e) {
|
|
|
419
420
|
}
|
|
420
421
|
}
|
|
421
422
|
var he = "preview-welcome";
|
|
422
|
-
function ge(e) {
|
|
423
|
-
|
|
423
|
+
function ge(e, t) {
|
|
424
|
+
return e === void 0 && t === void 0 ? void 0 : JSON.stringify([e, t]);
|
|
425
|
+
}
|
|
426
|
+
function _e(e) {
|
|
427
|
+
let t = e instanceof R ? e.status : void 0;
|
|
424
428
|
return t === 415 ? "unsupported" : t === 413 ? "tooLarge" : t === 409 ? "tooMany" : t === 422 ? "unreadable" : "failed";
|
|
425
429
|
}
|
|
426
|
-
var
|
|
427
|
-
function
|
|
428
|
-
return e instanceof
|
|
430
|
+
var ve = 5e3;
|
|
431
|
+
function ye(e) {
|
|
432
|
+
return e instanceof R && e.code === "conversation_retired";
|
|
429
433
|
}
|
|
430
|
-
function
|
|
431
|
-
let [n, r] = e([]), [a, s] = e(!1), [c, l] = e(""), [u, d] = e(
|
|
432
|
-
|
|
433
|
-
let
|
|
434
|
+
function be(t) {
|
|
435
|
+
let [n, r] = e([]), [a, s] = e(!1), [c, l] = e(""), [u, d] = e(0), [f, p] = e([]), [m, h] = e(""), [g, _] = e(""), [x, S] = e(null), [C, w] = e(!1), [E, D] = e(!1), [O, k] = e([]), [ee, A] = e([]), [M, N] = e(null), P = o(null), F = o(t);
|
|
436
|
+
F.current = t;
|
|
437
|
+
let I = o(null), L = o(null), z = o(null), B = o(null), te = o(void 0), V = t.greeting, H = y(() => V ? {
|
|
434
438
|
id: "greeting",
|
|
435
439
|
role: "assistant",
|
|
436
440
|
content: V,
|
|
437
441
|
createdAt: Date.now()
|
|
438
|
-
} : null, [V]),
|
|
439
|
-
|
|
440
|
-
}, []),
|
|
442
|
+
} : null, [V]), U = i((e) => {
|
|
443
|
+
F.current.onEvent?.(e);
|
|
444
|
+
}, []), W = i((e, t) => {
|
|
441
445
|
r((n) => n.map((n) => n.id === e ? {
|
|
442
446
|
...n,
|
|
443
447
|
...t
|
|
444
448
|
} : n));
|
|
445
|
-
}, []),
|
|
446
|
-
let n = e instanceof
|
|
447
|
-
t &&
|
|
449
|
+
}, []), G = i((e, t) => {
|
|
450
|
+
let n = e instanceof R ? e.status : void 0, r = e instanceof Error ? e.message : String(e), i = (F.current.locale ?? b(void 0)).t.error;
|
|
451
|
+
t && W(t, {
|
|
448
452
|
content: i,
|
|
449
453
|
streaming: !1,
|
|
450
454
|
error: !0,
|
|
451
455
|
activity: void 0
|
|
452
|
-
}),
|
|
456
|
+
}), U({
|
|
453
457
|
type: "chatbot-error",
|
|
454
458
|
message: r,
|
|
455
459
|
status: n,
|
|
456
|
-
sessionId:
|
|
460
|
+
sessionId: L.current?.sessionId ?? ""
|
|
457
461
|
}), typeof console < "u" && console.error("[squadico-chatbot]", r);
|
|
458
|
-
}, [
|
|
459
|
-
let e =
|
|
460
|
-
if (!e.embedKey) throw new
|
|
462
|
+
}, [U, W]), K = i(() => {
|
|
463
|
+
let e = F.current;
|
|
464
|
+
if (!e.embedKey) throw new R("No embed key: nothing says which application to open");
|
|
461
465
|
return {
|
|
462
466
|
opts: e,
|
|
463
467
|
apiUrl: e.apiUrl ?? "https://api.squadico.com",
|
|
464
468
|
embedKey: e.embedKey,
|
|
465
|
-
claim: e.user
|
|
469
|
+
claim: e.user,
|
|
470
|
+
scope: e.scope
|
|
466
471
|
};
|
|
467
|
-
}, []),
|
|
472
|
+
}, []), q = i((e, t) => {
|
|
468
473
|
let n = {
|
|
469
474
|
sessionId: t.conversationId,
|
|
470
475
|
visitorToken: t.visitorToken
|
|
471
476
|
};
|
|
472
|
-
return
|
|
477
|
+
return L.current = n, te.current = ge(e.claim?.id, e.scope), de({
|
|
473
478
|
...n,
|
|
474
479
|
embedKey: e.embedKey,
|
|
475
|
-
user: e.claim?.id
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
480
|
+
user: e.claim?.id,
|
|
481
|
+
scope: e.scope
|
|
482
|
+
}), l(t.conversationId), p(t.handles), h(e.opts.agent && t.agentHandle ? t.agentHandle : ""), _(t.agentHandle ?? ""), w(!!t.withHuman), D(t.branding), r((e) => [...t.messages, ...e.filter((e) => e.id !== he)]), n;
|
|
483
|
+
}, []), J = i((e) => {
|
|
484
|
+
if (z.current) return z.current;
|
|
479
485
|
let t = ue();
|
|
480
486
|
if (!t || !pe(t, {
|
|
481
487
|
embedKey: e.embedKey,
|
|
482
|
-
user: e.claim?.id
|
|
488
|
+
user: e.claim?.id,
|
|
489
|
+
scope: e.scope
|
|
483
490
|
})) return Promise.resolve(null);
|
|
484
491
|
let n = ie({
|
|
485
492
|
apiUrl: e.apiUrl,
|
|
486
493
|
conversationId: t.sessionId,
|
|
487
494
|
visitorToken: t.visitorToken
|
|
488
|
-
}).then((t) =>
|
|
489
|
-
|
|
495
|
+
}).then((t) => q(e, t)).catch(() => (fe(), null)).finally(() => {
|
|
496
|
+
z.current = null;
|
|
490
497
|
});
|
|
491
|
-
return
|
|
492
|
-
}, [
|
|
498
|
+
return z.current = n, n;
|
|
499
|
+
}, [q]), Y = i(async () => {
|
|
500
|
+
if (L.current) return L.current;
|
|
493
501
|
if (I.current) return I.current;
|
|
494
|
-
|
|
495
|
-
let e = te(), t = K(e).then((t) => t ?? re({
|
|
502
|
+
let e = K(), t = J(e).then((t) => t ?? re({
|
|
496
503
|
apiUrl: e.apiUrl,
|
|
497
504
|
embedKey: e.embedKey,
|
|
498
505
|
user: e.claim,
|
|
499
506
|
agent: e.opts.agent
|
|
500
|
-
}).then((t) =>
|
|
501
|
-
|
|
507
|
+
}).then((t) => q(e, t)));
|
|
508
|
+
I.current = t;
|
|
502
509
|
try {
|
|
503
510
|
return await t;
|
|
504
511
|
} finally {
|
|
505
|
-
|
|
512
|
+
I.current = null;
|
|
506
513
|
}
|
|
507
514
|
}, [
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
]),
|
|
512
|
-
if (
|
|
515
|
+
q,
|
|
516
|
+
J,
|
|
517
|
+
K
|
|
518
|
+
]), X = i(() => {
|
|
519
|
+
if (L.current || I.current || B.current) return;
|
|
513
520
|
let e;
|
|
514
521
|
try {
|
|
515
|
-
e =
|
|
522
|
+
e = K();
|
|
516
523
|
} catch (e) {
|
|
517
|
-
|
|
524
|
+
G(e);
|
|
518
525
|
return;
|
|
519
526
|
}
|
|
520
|
-
let t =
|
|
521
|
-
if (t ||
|
|
527
|
+
let t = J(e).then(async (t) => {
|
|
528
|
+
if (t || L.current || I.current) return;
|
|
522
529
|
let n = await ne({
|
|
523
530
|
apiUrl: e.apiUrl,
|
|
524
531
|
embedKey: e.embedKey,
|
|
525
532
|
agent: e.opts.agent
|
|
526
533
|
});
|
|
527
|
-
if (
|
|
528
|
-
|
|
534
|
+
if (L.current || I.current) return;
|
|
535
|
+
p(n.handles), h(e.opts.agent && n.agentHandle ? n.agentHandle : ""), _(n.agentHandle ?? ""), D(n.branding);
|
|
529
536
|
let i = n.welcomeMessage;
|
|
530
537
|
i && r((e) => e.length > 0 ? e : [{
|
|
531
538
|
id: he,
|
|
@@ -535,22 +542,22 @@ function ye(t) {
|
|
|
535
542
|
agent: n.agent
|
|
536
543
|
}]);
|
|
537
544
|
});
|
|
538
|
-
|
|
539
|
-
|
|
545
|
+
B.current = t, t.catch((e) => {
|
|
546
|
+
B.current = null, G(e);
|
|
540
547
|
});
|
|
541
548
|
}, [
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
]),
|
|
546
|
-
if (
|
|
549
|
+
G,
|
|
550
|
+
J,
|
|
551
|
+
K
|
|
552
|
+
]), Z = i((e, t, { retry: n = !1, carried: i = [] } = {}) => {
|
|
553
|
+
if (P.current) return;
|
|
547
554
|
let a = new AbortController();
|
|
548
|
-
|
|
549
|
-
let o =
|
|
555
|
+
P.current = a, s(!0), S(null);
|
|
556
|
+
let o = j();
|
|
550
557
|
r((t) => [
|
|
551
558
|
...t,
|
|
552
559
|
{
|
|
553
|
-
id:
|
|
560
|
+
id: j(),
|
|
554
561
|
role: "user",
|
|
555
562
|
content: e,
|
|
556
563
|
createdAt: Date.now(),
|
|
@@ -564,35 +571,35 @@ function ye(t) {
|
|
|
564
571
|
streaming: !0
|
|
565
572
|
}
|
|
566
573
|
]), (async () => {
|
|
567
|
-
let i = await
|
|
568
|
-
|
|
574
|
+
let i = await Y();
|
|
575
|
+
U({
|
|
569
576
|
type: "chatbot-message",
|
|
570
577
|
role: "user",
|
|
571
578
|
content: e,
|
|
572
579
|
sessionId: i.sessionId
|
|
573
580
|
});
|
|
574
581
|
let s = "", c = (e) => {
|
|
575
|
-
s += e,
|
|
582
|
+
s += e, W(o, {
|
|
576
583
|
content: s,
|
|
577
584
|
activity: void 0
|
|
578
585
|
});
|
|
579
586
|
}, l = (e) => {
|
|
580
|
-
s ||
|
|
587
|
+
s || W(o, { activity: e });
|
|
581
588
|
}, u;
|
|
582
589
|
try {
|
|
583
590
|
u = await t(i, c, a.signal, l);
|
|
584
591
|
} catch (e) {
|
|
585
|
-
if (!
|
|
586
|
-
i = await
|
|
592
|
+
if (!ye(e) || (fe(), L.current = null, I.current = null, !n)) throw e;
|
|
593
|
+
i = await Y(), s = "", W(o, {
|
|
587
594
|
content: "",
|
|
588
595
|
activity: void 0
|
|
589
596
|
}), u = await t(i, c, a.signal, l);
|
|
590
597
|
}
|
|
591
|
-
if (u.withHuman &&
|
|
598
|
+
if (u.withHuman && w(!0), u.held) {
|
|
592
599
|
r((e) => e.filter((e) => e.id !== o));
|
|
593
600
|
return;
|
|
594
601
|
}
|
|
595
|
-
|
|
602
|
+
W(o, {
|
|
596
603
|
content: u.answer,
|
|
597
604
|
streaming: !1,
|
|
598
605
|
activity: void 0,
|
|
@@ -601,7 +608,7 @@ function ye(t) {
|
|
|
601
608
|
approval: u.approval,
|
|
602
609
|
unknownHandle: u.unknownHandle,
|
|
603
610
|
offered: u.offered
|
|
604
|
-
}),
|
|
611
|
+
}), S(u.approval ?? null), U({
|
|
605
612
|
type: "chatbot-message",
|
|
606
613
|
role: "assistant",
|
|
607
614
|
content: u.answer,
|
|
@@ -610,33 +617,33 @@ function ye(t) {
|
|
|
610
617
|
});
|
|
611
618
|
})().catch((e) => {
|
|
612
619
|
if (a.signal.aborted) {
|
|
613
|
-
|
|
620
|
+
W(o, {
|
|
614
621
|
streaming: !1,
|
|
615
622
|
activity: void 0
|
|
616
623
|
});
|
|
617
624
|
return;
|
|
618
625
|
}
|
|
619
|
-
|
|
626
|
+
G(e, o);
|
|
620
627
|
}).finally(() => {
|
|
621
|
-
|
|
628
|
+
P.current = null, s(!1);
|
|
622
629
|
});
|
|
623
630
|
}, [
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
]),
|
|
631
|
+
Y,
|
|
632
|
+
U,
|
|
633
|
+
G,
|
|
634
|
+
W
|
|
635
|
+
]), le = i((e) => {
|
|
629
636
|
let t = e.trim();
|
|
630
|
-
if (!t &&
|
|
631
|
-
let n =
|
|
632
|
-
|
|
633
|
-
subjectToken: await me(
|
|
634
|
-
apiUrl:
|
|
637
|
+
if (!t && O.length === 0) return;
|
|
638
|
+
let n = O;
|
|
639
|
+
k([]), N(null), Z(t, async (e, r, i, a) => ce({
|
|
640
|
+
subjectToken: await me(F.current.getSubjectToken),
|
|
641
|
+
apiUrl: F.current.apiUrl ?? "https://api.squadico.com",
|
|
635
642
|
conversationId: e.sessionId,
|
|
636
643
|
visitorToken: e.visitorToken,
|
|
637
644
|
message: t,
|
|
638
645
|
attachmentIds: n.map((e) => e.id),
|
|
639
|
-
context:
|
|
646
|
+
context: F.current.context ? T(F.current.context) : void 0,
|
|
640
647
|
onToken: r,
|
|
641
648
|
onProgress: a,
|
|
642
649
|
signal: i
|
|
@@ -644,39 +651,39 @@ function ye(t) {
|
|
|
644
651
|
retry: !0,
|
|
645
652
|
carried: n
|
|
646
653
|
});
|
|
647
|
-
}, [
|
|
648
|
-
|
|
649
|
-
apiUrl:
|
|
654
|
+
}, [O, Z]), $ = i((e) => {
|
|
655
|
+
N(null), A((t) => [...t, e.name]), Y().then((t) => ae({
|
|
656
|
+
apiUrl: F.current.apiUrl ?? "https://api.squadico.com",
|
|
650
657
|
conversationId: t.sessionId,
|
|
651
658
|
visitorToken: t.visitorToken,
|
|
652
659
|
file: e
|
|
653
|
-
})).then((e) =>
|
|
660
|
+
})).then((e) => k((t) => [...t, e])).catch((e) => N(_e(e))).finally(() => A((t) => {
|
|
654
661
|
let n = t.indexOf(e.name);
|
|
655
662
|
return n < 0 ? t : [...t.slice(0, n), ...t.slice(n + 1)];
|
|
656
663
|
}));
|
|
657
|
-
}, [
|
|
658
|
-
|
|
659
|
-
let t =
|
|
664
|
+
}, [Y]), be = i((e) => {
|
|
665
|
+
k((t) => t.filter((t) => t.id !== e));
|
|
666
|
+
let t = L.current;
|
|
660
667
|
t && oe({
|
|
661
|
-
apiUrl:
|
|
668
|
+
apiUrl: F.current.apiUrl ?? "https://api.squadico.com",
|
|
662
669
|
conversationId: t.sessionId,
|
|
663
670
|
visitorToken: t.visitorToken,
|
|
664
671
|
attachmentId: e
|
|
665
672
|
}).catch(() => {});
|
|
666
|
-
}, []),
|
|
667
|
-
let t =
|
|
668
|
-
if (!t) throw new
|
|
669
|
-
return
|
|
670
|
-
apiUrl:
|
|
673
|
+
}, []), xe = i(async (e) => {
|
|
674
|
+
let t = L.current;
|
|
675
|
+
if (!t) throw new R("No conversation to read that file from");
|
|
676
|
+
return se({
|
|
677
|
+
apiUrl: F.current.apiUrl ?? "https://api.squadico.com",
|
|
671
678
|
conversationId: t.sessionId,
|
|
672
679
|
visitorToken: t.visitorToken,
|
|
673
680
|
attachmentId: e
|
|
674
681
|
});
|
|
675
|
-
}, []),
|
|
676
|
-
let n =
|
|
677
|
-
n &&
|
|
678
|
-
subjectToken: await me(
|
|
679
|
-
apiUrl:
|
|
682
|
+
}, []), Se = i((e, t) => {
|
|
683
|
+
let n = x;
|
|
684
|
+
n && Z(t, async (t, r, i, a) => Q({
|
|
685
|
+
subjectToken: await me(F.current.getSubjectToken),
|
|
686
|
+
apiUrl: F.current.apiUrl ?? "https://api.squadico.com",
|
|
680
687
|
conversationId: t.sessionId,
|
|
681
688
|
visitorToken: t.visitorToken,
|
|
682
689
|
toolCallId: n.toolCallId,
|
|
@@ -685,61 +692,62 @@ function ye(t) {
|
|
|
685
692
|
onProgress: a,
|
|
686
693
|
signal: i
|
|
687
694
|
}));
|
|
688
|
-
}, [
|
|
689
|
-
|
|
690
|
-
}, []),
|
|
691
|
-
|
|
695
|
+
}, [x, Z]), Ce = i(() => {
|
|
696
|
+
P.current?.abort(), P.current = null, s(!1);
|
|
697
|
+
}, []), we = i(() => {
|
|
698
|
+
P.current?.abort(), P.current = null, L.current = null, I.current = null, z.current = null, B.current = null, te.current = void 0, fe(), s(!1), S(null), w(!1), l(""), d((e) => e + 1), h(""), _(""), r([]), U({
|
|
692
699
|
type: "chatbot-reset",
|
|
693
700
|
sessionId: ""
|
|
694
701
|
});
|
|
695
|
-
}, [
|
|
702
|
+
}, [U]), Te = t.humanPollMs ?? ve;
|
|
696
703
|
v(() => {
|
|
697
|
-
if (!
|
|
704
|
+
if (!C || !c) return;
|
|
698
705
|
let e = setInterval(() => {
|
|
699
|
-
let e =
|
|
700
|
-
!e ||
|
|
701
|
-
apiUrl:
|
|
706
|
+
let e = L.current;
|
|
707
|
+
!e || P.current || ie({
|
|
708
|
+
apiUrl: F.current.apiUrl ?? "https://api.squadico.com",
|
|
702
709
|
conversationId: e.sessionId,
|
|
703
710
|
visitorToken: e.visitorToken
|
|
704
711
|
}).then((e) => {
|
|
705
|
-
r(e.messages),
|
|
712
|
+
r(e.messages), w(!!e.withHuman);
|
|
706
713
|
}).catch(() => {});
|
|
707
|
-
},
|
|
714
|
+
}, Te);
|
|
708
715
|
return () => clearInterval(e);
|
|
709
716
|
}, [
|
|
710
|
-
|
|
717
|
+
C,
|
|
711
718
|
c,
|
|
712
|
-
|
|
719
|
+
Te
|
|
713
720
|
]);
|
|
714
|
-
let
|
|
721
|
+
let Ee = ge(t.user?.id, t.scope);
|
|
715
722
|
return v(() => {
|
|
716
|
-
|
|
717
|
-
}, [
|
|
718
|
-
messages: y(() => n.length === 0 &&
|
|
723
|
+
L.current && te.current !== Ee && we();
|
|
724
|
+
}, [Ee, we]), {
|
|
725
|
+
messages: y(() => n.length === 0 && H ? [H] : n, [H, n]),
|
|
719
726
|
busy: a,
|
|
720
727
|
sessionId: c,
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
728
|
+
resets: u,
|
|
729
|
+
handles: f,
|
|
730
|
+
addressee: m,
|
|
731
|
+
agentHandle: g,
|
|
732
|
+
approval: x,
|
|
733
|
+
withHuman: C,
|
|
734
|
+
branding: E,
|
|
735
|
+
start: X,
|
|
736
|
+
send: le,
|
|
737
|
+
attachments: O,
|
|
738
|
+
uploading: ee,
|
|
739
|
+
attachmentError: M,
|
|
740
|
+
attach: $,
|
|
741
|
+
detach: be,
|
|
742
|
+
loadAttachment: xe,
|
|
743
|
+
decide: Se,
|
|
744
|
+
stop: Ce,
|
|
745
|
+
reset: we
|
|
738
746
|
};
|
|
739
747
|
}
|
|
740
748
|
//#endregion
|
|
741
749
|
//#region src/components/Avatar.tsx
|
|
742
|
-
function
|
|
750
|
+
function xe({ name: t, color: n, url: r, size: i = 16 }) {
|
|
743
751
|
let [a, o] = e(void 0), s = !!r && a !== r;
|
|
744
752
|
return /* @__PURE__ */ l("span", {
|
|
745
753
|
class: "sqc-avatar",
|
|
@@ -755,16 +763,16 @@ function be({ name: t, color: n, url: r, size: i = 16 }) {
|
|
|
755
763
|
src: r,
|
|
756
764
|
alt: "",
|
|
757
765
|
onError: () => o(r)
|
|
758
|
-
}) :
|
|
766
|
+
}) : Se(t)
|
|
759
767
|
});
|
|
760
768
|
}
|
|
761
|
-
function
|
|
769
|
+
function Se(e) {
|
|
762
770
|
let t = Array.from(e.trim())[0];
|
|
763
771
|
return t ? t.toLocaleUpperCase() : "?";
|
|
764
772
|
}
|
|
765
773
|
//#endregion
|
|
766
774
|
//#region src/components/AgentRail.tsx
|
|
767
|
-
function
|
|
775
|
+
function Ce({ handles: e, active: t, disabled: n, onPick: r, label: i }) {
|
|
768
776
|
return /* @__PURE__ */ l("nav", {
|
|
769
777
|
class: "sqc-rail",
|
|
770
778
|
"aria-label": i,
|
|
@@ -776,7 +784,7 @@ function Se({ handles: e, active: t, disabled: n, onPick: r, label: i }) {
|
|
|
776
784
|
"data-tip": e.name,
|
|
777
785
|
disabled: n,
|
|
778
786
|
onClick: () => r(e.handle),
|
|
779
|
-
children: [/* @__PURE__ */ l(
|
|
787
|
+
children: [/* @__PURE__ */ l(xe, {
|
|
780
788
|
name: e.name,
|
|
781
789
|
color: e.color,
|
|
782
790
|
url: e.avatarUrl,
|
|
@@ -784,79 +792,79 @@ function Se({ handles: e, active: t, disabled: n, onPick: r, label: i }) {
|
|
|
784
792
|
}), /* @__PURE__ */ l("span", {
|
|
785
793
|
class: "sqc-rail__label",
|
|
786
794
|
"aria-hidden": "true",
|
|
787
|
-
children:
|
|
795
|
+
children: we(e.handle)
|
|
788
796
|
})]
|
|
789
797
|
}, e.handle))
|
|
790
798
|
});
|
|
791
799
|
}
|
|
792
|
-
function
|
|
800
|
+
function we(e) {
|
|
793
801
|
let t = e.split(/[-_]/)[0] ?? e;
|
|
794
802
|
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
795
803
|
}
|
|
796
804
|
//#endregion
|
|
797
805
|
//#region src/components/Composer.tsx
|
|
798
|
-
var
|
|
799
|
-
function
|
|
806
|
+
var Te = 132, Ee = "image/png,image/jpeg,image/gif,image/webp,application/pdf,.docx,.txt,.md,.csv,.json", De = /^[a-zA-Z0-9_-]*$/;
|
|
807
|
+
function Oe(e, t) {
|
|
800
808
|
let n = e.slice(0, t), r = n.lastIndexOf("@");
|
|
801
809
|
if (r < 0 || r > 0 && !/\s/.test(n[r - 1] ?? "")) return null;
|
|
802
810
|
let i = n.slice(r + 1);
|
|
803
|
-
return
|
|
811
|
+
return De.test(i) ? {
|
|
804
812
|
start: r,
|
|
805
813
|
query: i
|
|
806
814
|
} : null;
|
|
807
815
|
}
|
|
808
|
-
function
|
|
809
|
-
let [b, x] = e(""), [S, C] = e(null), [w, T] = e(0), [E, D] = e(!1), O = o(null), k = o(null),
|
|
816
|
+
function ke({ placeholder: n, locale: r, busy: a, autoFocus: s, handles: c, addressee: u, attachments: d = [], uploading: f = [], attachmentError: p, onAttach: m, onDetach: h, onSend: g, onStop: _ }) {
|
|
817
|
+
let [b, x] = e(""), [S, C] = e(null), [w, T] = e(0), [E, D] = e(!1), O = o(null), k = o(null), ee = !!m, A = f.length > 0, j = y(() => {
|
|
810
818
|
if (!S || !c || c.length === 0) return [];
|
|
811
819
|
let e = S.query.toLowerCase();
|
|
812
820
|
return c.filter((t) => t.handle.startsWith(e));
|
|
813
|
-
}, [c, S]),
|
|
821
|
+
}, [c, S]), M = j.length > 0, N = i(() => {
|
|
814
822
|
let e = O.current;
|
|
815
823
|
if (!e) return;
|
|
816
824
|
e.style.height = "auto";
|
|
817
|
-
let t = e.scrollHeight >
|
|
818
|
-
e.style.height = `${Math.min(e.scrollHeight,
|
|
825
|
+
let t = e.scrollHeight > Te;
|
|
826
|
+
e.style.height = `${Math.min(e.scrollHeight, Te)}px`, e.style.overflowY = t ? "auto" : "hidden";
|
|
819
827
|
}, []);
|
|
820
828
|
v(() => {
|
|
821
|
-
s && O.current?.focus(),
|
|
822
|
-
}, [s,
|
|
823
|
-
u && (x((e) => e || `@${u} `), requestAnimationFrame(
|
|
824
|
-
}, [u,
|
|
825
|
-
let
|
|
826
|
-
C(
|
|
827
|
-
}, []),
|
|
829
|
+
s && O.current?.focus(), N();
|
|
830
|
+
}, [s, N]), v(() => {
|
|
831
|
+
u && (x((e) => e || `@${u} `), requestAnimationFrame(N));
|
|
832
|
+
}, [u, N]);
|
|
833
|
+
let P = i((e) => {
|
|
834
|
+
C(Oe(e.value, e.selectionStart ?? e.value.length)), T(0);
|
|
835
|
+
}, []), F = i((e) => {
|
|
828
836
|
let t = O.current;
|
|
829
837
|
if (!t || !S) return;
|
|
830
838
|
let n = t.selectionStart ?? t.value.length, r = `${b.slice(0, S.start)}@${e} ${b.slice(n)}`, i = S.start + e.length + 2;
|
|
831
839
|
x(r), C(null), requestAnimationFrame(() => {
|
|
832
|
-
t.focus(), t.setSelectionRange(i, i),
|
|
840
|
+
t.focus(), t.setSelectionRange(i, i), N();
|
|
833
841
|
});
|
|
834
842
|
}, [
|
|
835
|
-
|
|
843
|
+
N,
|
|
836
844
|
S,
|
|
837
845
|
b
|
|
838
|
-
]),
|
|
846
|
+
]), I = i((e) => {
|
|
839
847
|
if (!(!m || !e)) for (let t of Array.from(e)) m(t);
|
|
840
|
-
}, [m]),
|
|
848
|
+
}, [m]), R = i(() => {
|
|
841
849
|
let e = b.trim();
|
|
842
|
-
!e && d.length === 0 || a ||
|
|
850
|
+
!e && d.length === 0 || a || A || (g(e), x(""), C(null), requestAnimationFrame(N));
|
|
843
851
|
}, [
|
|
844
852
|
d.length,
|
|
845
853
|
a,
|
|
846
|
-
|
|
854
|
+
N,
|
|
847
855
|
g,
|
|
848
856
|
b,
|
|
849
|
-
|
|
850
|
-
]),
|
|
851
|
-
if (
|
|
857
|
+
A
|
|
858
|
+
]), z = i((e) => {
|
|
859
|
+
if (M && !e.isComposing) {
|
|
852
860
|
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
853
861
|
e.preventDefault();
|
|
854
|
-
let t = e.key === "ArrowDown" ? 1 :
|
|
855
|
-
T((e) => (e + t) %
|
|
862
|
+
let t = e.key === "ArrowDown" ? 1 : j.length - 1;
|
|
863
|
+
T((e) => (e + t) % j.length);
|
|
856
864
|
return;
|
|
857
865
|
}
|
|
858
866
|
if (e.key === "Enter" || e.key === "Tab") {
|
|
859
|
-
e.preventDefault(),
|
|
867
|
+
e.preventDefault(), F((j[w] ?? j[0]).handle);
|
|
860
868
|
return;
|
|
861
869
|
}
|
|
862
870
|
if (e.key === "Escape") {
|
|
@@ -864,28 +872,28 @@ function Oe({ placeholder: n, locale: r, busy: a, autoFocus: s, handles: c, addr
|
|
|
864
872
|
return;
|
|
865
873
|
}
|
|
866
874
|
}
|
|
867
|
-
e.key === "Enter" && !e.shiftKey && !e.isComposing && (e.preventDefault(),
|
|
875
|
+
e.key === "Enter" && !e.shiftKey && !e.isComposing && (e.preventDefault(), R());
|
|
868
876
|
}, [
|
|
869
877
|
w,
|
|
878
|
+
j,
|
|
879
|
+
F,
|
|
870
880
|
M,
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
z
|
|
874
|
-
]), V = R - b.length;
|
|
881
|
+
R
|
|
882
|
+
]), B = L - b.length;
|
|
875
883
|
return /* @__PURE__ */ l("form", {
|
|
876
884
|
class: `sqc-composer${E ? " sqc-composer--dropping" : ""}`,
|
|
877
885
|
onSubmit: (e) => {
|
|
878
|
-
e.preventDefault(),
|
|
886
|
+
e.preventDefault(), R();
|
|
879
887
|
},
|
|
880
888
|
onDragOver: (e) => {
|
|
881
|
-
|
|
889
|
+
ee && (e.preventDefault(), D(!0));
|
|
882
890
|
},
|
|
883
891
|
onDragLeave: () => D(!1),
|
|
884
892
|
onDrop: (e) => {
|
|
885
|
-
|
|
893
|
+
ee && (e.preventDefault(), D(!1), I(e.dataTransfer?.files ?? null));
|
|
886
894
|
},
|
|
887
895
|
children: [
|
|
888
|
-
(d.length > 0 ||
|
|
896
|
+
(d.length > 0 || A || p) && /* @__PURE__ */ l("div", {
|
|
889
897
|
class: "sqc-attachments",
|
|
890
898
|
children: [
|
|
891
899
|
d.map((e) => /* @__PURE__ */ l("span", {
|
|
@@ -919,21 +927,21 @@ function Oe({ placeholder: n, locale: r, busy: a, autoFocus: s, handles: c, addr
|
|
|
919
927
|
/* @__PURE__ */ l("div", {
|
|
920
928
|
class: "sqc-composer__field",
|
|
921
929
|
children: [
|
|
922
|
-
|
|
930
|
+
M && /* @__PURE__ */ l("ul", {
|
|
923
931
|
class: "sqc-mentions",
|
|
924
932
|
role: "listbox",
|
|
925
933
|
"aria-label": r.t.handles.picker,
|
|
926
|
-
children:
|
|
934
|
+
children: j.map((e, t) => /* @__PURE__ */ l("li", {
|
|
927
935
|
role: "option",
|
|
928
936
|
"aria-selected": t === w,
|
|
929
937
|
class: `sqc-mention${t === w ? " sqc-mention--active" : ""}`,
|
|
930
938
|
onMouseDown: (e) => e.preventDefault(),
|
|
931
939
|
onMouseEnter: () => T(t),
|
|
932
|
-
onClick: () =>
|
|
940
|
+
onClick: () => F(e.handle),
|
|
933
941
|
children: [
|
|
934
942
|
/* @__PURE__ */ l("span", {
|
|
935
943
|
class: "sqc-mention__icon",
|
|
936
|
-
children: /* @__PURE__ */ l(
|
|
944
|
+
children: /* @__PURE__ */ l(xe, {
|
|
937
945
|
name: e.name,
|
|
938
946
|
color: e.color,
|
|
939
947
|
url: e.avatarUrl,
|
|
@@ -957,33 +965,33 @@ function Oe({ placeholder: n, locale: r, busy: a, autoFocus: s, handles: c, addr
|
|
|
957
965
|
rows: 1,
|
|
958
966
|
value: b,
|
|
959
967
|
placeholder: n,
|
|
960
|
-
maxLength:
|
|
968
|
+
maxLength: L,
|
|
961
969
|
"aria-label": r.t.composer.label,
|
|
962
970
|
onInput: (e) => {
|
|
963
|
-
x(e.currentTarget.value),
|
|
971
|
+
x(e.currentTarget.value), P(e.currentTarget), N();
|
|
964
972
|
},
|
|
965
|
-
onKeyDown:
|
|
966
|
-
onClick: (e) =>
|
|
973
|
+
onKeyDown: z,
|
|
974
|
+
onClick: (e) => P(e.currentTarget),
|
|
967
975
|
onPaste: (e) => {
|
|
968
976
|
let t = e.clipboardData?.files;
|
|
969
|
-
!
|
|
977
|
+
!ee || !t || t.length === 0 || (e.preventDefault(), I(t));
|
|
970
978
|
}
|
|
971
979
|
}),
|
|
972
|
-
|
|
980
|
+
B <= 200 && /* @__PURE__ */ l("span", {
|
|
973
981
|
class: "sqc-composer__count",
|
|
974
982
|
"aria-live": "polite",
|
|
975
|
-
children:
|
|
983
|
+
children: B
|
|
976
984
|
})
|
|
977
985
|
]
|
|
978
986
|
}),
|
|
979
|
-
|
|
987
|
+
ee && /* @__PURE__ */ l(t, { children: [/* @__PURE__ */ l("input", {
|
|
980
988
|
ref: k,
|
|
981
989
|
type: "file",
|
|
982
990
|
multiple: !0,
|
|
983
|
-
accept:
|
|
991
|
+
accept: Ee,
|
|
984
992
|
class: "sqc-file-input",
|
|
985
993
|
onChange: (e) => {
|
|
986
|
-
|
|
994
|
+
I(e.currentTarget.files), e.currentTarget.value = "";
|
|
987
995
|
}
|
|
988
996
|
}), /* @__PURE__ */ l("button", {
|
|
989
997
|
type: "button",
|
|
@@ -1023,7 +1031,7 @@ function Oe({ placeholder: n, locale: r, busy: a, autoFocus: s, handles: c, addr
|
|
|
1023
1031
|
}) : /* @__PURE__ */ l("button", {
|
|
1024
1032
|
type: "submit",
|
|
1025
1033
|
class: "sqc-btn sqc-btn--send",
|
|
1026
|
-
disabled: !b.trim() && d.length === 0 ||
|
|
1034
|
+
disabled: !b.trim() && d.length === 0 || A,
|
|
1027
1035
|
"aria-label": r.t.composer.send,
|
|
1028
1036
|
title: r.t.composer.sendTitle,
|
|
1029
1037
|
children: /* @__PURE__ */ l("svg", {
|
|
@@ -1042,14 +1050,14 @@ function Oe({ placeholder: n, locale: r, busy: a, autoFocus: s, handles: c, addr
|
|
|
1042
1050
|
}
|
|
1043
1051
|
//#endregion
|
|
1044
1052
|
//#region src/components/RichText.tsx
|
|
1045
|
-
var
|
|
1046
|
-
function
|
|
1053
|
+
var Ae = /^(\s*)[-*•]\s+/, je = /^(\s*)\d+[.)]\s+/, Me = /^\s{0,3}(#{1,6})\s+(.+?)#*\s*$/, Ne = /^\s*([-*_])(?:\s*\1){2,}\s*$/, Pe = /^\s*>\s?(.*)$/, Fe = /^\s*```/;
|
|
1054
|
+
function Ie(e, t, n, r) {
|
|
1047
1055
|
let i = e[t].ordered, a = [], o = t;
|
|
1048
1056
|
for (; o < e.length && e[o].depth >= n;) {
|
|
1049
1057
|
let t = e[o];
|
|
1050
1058
|
if (t.depth === n && t.ordered !== i) break;
|
|
1051
1059
|
if (t.depth > n) {
|
|
1052
|
-
let [n, i] =
|
|
1060
|
+
let [n, i] = Ie(e, o, t.depth, `${r}-${o}`), s = a[a.length - 1];
|
|
1053
1061
|
s ? s.nested.push(n) : a.push({
|
|
1054
1062
|
key: `${r}-${o}`,
|
|
1055
1063
|
text: null,
|
|
@@ -1066,7 +1074,7 @@ function Fe(e, t, n, r) {
|
|
|
1066
1074
|
let s = a.map((e) => /* @__PURE__ */ l("li", { children: [e.text === null ? null : g(e.text, e.key), e.nested] }, e.key));
|
|
1067
1075
|
return [l(i ? "ol" : "ul", { children: s }, r), o];
|
|
1068
1076
|
}
|
|
1069
|
-
function
|
|
1077
|
+
function Le(e) {
|
|
1070
1078
|
let t = e.split("\n"), n = [], r = [], i = [], a = [], o = () => {
|
|
1071
1079
|
if (!r.length) return;
|
|
1072
1080
|
let e = `p${n.length}`;
|
|
@@ -1075,7 +1083,7 @@ function Ie(e) {
|
|
|
1075
1083
|
if (!i.length) return;
|
|
1076
1084
|
let e = 0;
|
|
1077
1085
|
for (; e < i.length;) {
|
|
1078
|
-
let t = `l${n.length}`, [r, a] =
|
|
1086
|
+
let t = `l${n.length}`, [r, a] = Ie(i, e, i[e].depth, t);
|
|
1079
1087
|
n.push(r), e = a;
|
|
1080
1088
|
}
|
|
1081
1089
|
i = [];
|
|
@@ -1088,10 +1096,10 @@ function Ie(e) {
|
|
|
1088
1096
|
};
|
|
1089
1097
|
for (let e = 0; e < t.length; e += 1) {
|
|
1090
1098
|
let d = t[e];
|
|
1091
|
-
if (
|
|
1099
|
+
if (Fe.test(d)) {
|
|
1092
1100
|
u();
|
|
1093
1101
|
let r = [];
|
|
1094
|
-
for (e += 1; e < t.length && !
|
|
1102
|
+
for (e += 1; e < t.length && !Fe.test(t[e]);) r.push(t[e]), e += 1;
|
|
1095
1103
|
let i = `c${n.length}`;
|
|
1096
1104
|
n.push(/* @__PURE__ */ l("pre", { children: /* @__PURE__ */ l("code", { children: r.join("\n") }) }, i));
|
|
1097
1105
|
continue;
|
|
@@ -1100,23 +1108,23 @@ function Ie(e) {
|
|
|
1100
1108
|
u();
|
|
1101
1109
|
continue;
|
|
1102
1110
|
}
|
|
1103
|
-
let f =
|
|
1111
|
+
let f = Me.exec(d);
|
|
1104
1112
|
if (f) {
|
|
1105
1113
|
u();
|
|
1106
1114
|
let e = f[1].length, t = e <= 2 ? "h3" : e === 3 ? "h4" : "h5", r = `h${n.length}`;
|
|
1107
1115
|
n.push(/* @__PURE__ */ l(t, { children: g(f[2], r) }, r));
|
|
1108
1116
|
continue;
|
|
1109
1117
|
}
|
|
1110
|
-
if (
|
|
1118
|
+
if (Ne.test(d)) {
|
|
1111
1119
|
u(), n.push(/* @__PURE__ */ l("hr", {}, `r${n.length}`));
|
|
1112
1120
|
continue;
|
|
1113
1121
|
}
|
|
1114
|
-
let p =
|
|
1122
|
+
let p = Pe.exec(d);
|
|
1115
1123
|
if (p) {
|
|
1116
1124
|
o(), s(), a.push(p[1]);
|
|
1117
1125
|
continue;
|
|
1118
1126
|
}
|
|
1119
|
-
let m =
|
|
1127
|
+
let m = Ae.exec(d), h = m ? null : je.exec(d), _ = m ?? h;
|
|
1120
1128
|
if (_) {
|
|
1121
1129
|
o(), c(), i.push({
|
|
1122
1130
|
depth: _[1].replace(/\t/g, " ").length,
|
|
@@ -1129,7 +1137,7 @@ function Ie(e) {
|
|
|
1129
1137
|
}
|
|
1130
1138
|
return u(), n;
|
|
1131
1139
|
}
|
|
1132
|
-
function
|
|
1140
|
+
function Re(e) {
|
|
1133
1141
|
let t = o(null), { form: n, locked: i, language: a } = e;
|
|
1134
1142
|
return r(() => {
|
|
1135
1143
|
h();
|
|
@@ -1148,9 +1156,9 @@ function Le(e) {
|
|
|
1148
1156
|
children: n.fields.map((e) => /* @__PURE__ */ l("p", { children: e.label }, e.name))
|
|
1149
1157
|
});
|
|
1150
1158
|
}
|
|
1151
|
-
function
|
|
1159
|
+
function ze(e, n, r) {
|
|
1152
1160
|
switch (e.kind) {
|
|
1153
|
-
case "markdown": return /* @__PURE__ */ l(t, { children:
|
|
1161
|
+
case "markdown": return /* @__PURE__ */ l(t, { children: Le(e.text) });
|
|
1154
1162
|
case "table": return /* @__PURE__ */ l("sqc-table", {
|
|
1155
1163
|
table: {
|
|
1156
1164
|
header: e.header,
|
|
@@ -1166,24 +1174,24 @@ function Re(e, n, r) {
|
|
|
1166
1174
|
locked: r,
|
|
1167
1175
|
language: n.code
|
|
1168
1176
|
});
|
|
1169
|
-
case "form": return /* @__PURE__ */ l(
|
|
1177
|
+
case "form": return /* @__PURE__ */ l(Re, {
|
|
1170
1178
|
form: e.form,
|
|
1171
1179
|
locked: r,
|
|
1172
1180
|
language: n.code
|
|
1173
1181
|
});
|
|
1174
1182
|
}
|
|
1175
1183
|
}
|
|
1176
|
-
function
|
|
1184
|
+
function Be({ text: e, locale: n, live: r, confirmable: i }) {
|
|
1177
1185
|
let { blocks: a, confirm: o } = _(e, n.code, i === !0), s = !r;
|
|
1178
|
-
return /* @__PURE__ */ l(t, { children: [a.map((e, r) => /* @__PURE__ */ l(t, { children:
|
|
1186
|
+
return /* @__PURE__ */ l(t, { children: [a.map((e, r) => /* @__PURE__ */ l(t, { children: ze(e, n, s) }, `b${r}`)), o && /* @__PURE__ */ l("sqc-confirm", {
|
|
1179
1187
|
locked: s,
|
|
1180
1188
|
language: n.code
|
|
1181
1189
|
})] });
|
|
1182
1190
|
}
|
|
1183
1191
|
//#endregion
|
|
1184
1192
|
//#region src/components/MessageList.tsx
|
|
1185
|
-
var
|
|
1186
|
-
function
|
|
1193
|
+
var Ve = 80;
|
|
1194
|
+
function He({ at: e, locale: t }) {
|
|
1187
1195
|
let n = new Date(e);
|
|
1188
1196
|
return /* @__PURE__ */ l("time", {
|
|
1189
1197
|
class: "sqc-msg__time",
|
|
@@ -1194,7 +1202,7 @@ function Ve({ at: e, locale: t }) {
|
|
|
1194
1202
|
})
|
|
1195
1203
|
});
|
|
1196
1204
|
}
|
|
1197
|
-
function
|
|
1205
|
+
function Ue(e) {
|
|
1198
1206
|
let { call: t, locked: n, locale: i } = e, a = i.code, s = o(null);
|
|
1199
1207
|
r(() => {
|
|
1200
1208
|
h();
|
|
@@ -1233,7 +1241,7 @@ function He(e) {
|
|
|
1233
1241
|
]
|
|
1234
1242
|
});
|
|
1235
1243
|
}
|
|
1236
|
-
function
|
|
1244
|
+
function We({ file: t, load: n }) {
|
|
1237
1245
|
let [r, i] = e(null);
|
|
1238
1246
|
return v(() => {
|
|
1239
1247
|
let e = null, r = !0;
|
|
@@ -1251,7 +1259,7 @@ function Ue({ file: t, load: n }) {
|
|
|
1251
1259
|
children: t.filename
|
|
1252
1260
|
});
|
|
1253
1261
|
}
|
|
1254
|
-
function
|
|
1262
|
+
function Ge(e) {
|
|
1255
1263
|
let { file: t, load: n, language: i } = e, a = o(null), s = y(() => n(t.id).then((e) => e.text()).catch(() => ""), [t.id, n]);
|
|
1256
1264
|
return r(() => {
|
|
1257
1265
|
h();
|
|
@@ -1271,13 +1279,13 @@ function We(e) {
|
|
|
1271
1279
|
children: t.filename
|
|
1272
1280
|
});
|
|
1273
1281
|
}
|
|
1274
|
-
function
|
|
1282
|
+
function Ke({ files: e, load: t, language: n }) {
|
|
1275
1283
|
return e.length === 0 || !t ? null : /* @__PURE__ */ l("div", {
|
|
1276
1284
|
class: "sqc-attachments sqc-attachments--sent",
|
|
1277
|
-
children: e.map((e) => e.kind === "image" ? /* @__PURE__ */ l(
|
|
1285
|
+
children: e.map((e) => e.kind === "image" ? /* @__PURE__ */ l(We, {
|
|
1278
1286
|
file: e,
|
|
1279
1287
|
load: t
|
|
1280
|
-
}, e.id) : e.kind === "chart" ? /* @__PURE__ */ l(
|
|
1288
|
+
}, e.id) : e.kind === "chart" ? /* @__PURE__ */ l(Ge, {
|
|
1281
1289
|
file: e,
|
|
1282
1290
|
load: t,
|
|
1283
1291
|
language: n
|
|
@@ -1291,17 +1299,17 @@ function Ge({ files: e, load: t, language: n }) {
|
|
|
1291
1299
|
}, e.id))
|
|
1292
1300
|
});
|
|
1293
1301
|
}
|
|
1294
|
-
function
|
|
1302
|
+
function qe({ message: e, locale: t, assistantName: n, live: r, onDecide: i, onLoadAttachment: a }) {
|
|
1295
1303
|
let o = e.streaming && !e.content, s = !!e.approval;
|
|
1296
1304
|
return /* @__PURE__ */ l("div", {
|
|
1297
1305
|
class: `sqc-msg sqc-msg--${e.role}${e.error ? " sqc-msg--error" : ""}`,
|
|
1298
1306
|
children: [e.role === "assistant" && /* @__PURE__ */ l("div", {
|
|
1299
1307
|
class: "sqc-msg__who",
|
|
1300
|
-
children: [e.agent ? /* @__PURE__ */ l(
|
|
1308
|
+
children: [e.agent ? /* @__PURE__ */ l(xe, {
|
|
1301
1309
|
name: e.agent.name,
|
|
1302
1310
|
color: e.agent.color,
|
|
1303
1311
|
url: e.agent.avatarUrl
|
|
1304
|
-
}) : /* @__PURE__ */ l(
|
|
1312
|
+
}) : /* @__PURE__ */ l(Ye, {}), e.authorName ?? e.agent?.name ?? n]
|
|
1305
1313
|
}), /* @__PURE__ */ l("div", {
|
|
1306
1314
|
class: "sqc-msg__bubble",
|
|
1307
1315
|
children: [o ? /* @__PURE__ */ l("span", {
|
|
@@ -1322,7 +1330,7 @@ function Ke({ message: e, locale: t, assistantName: n, live: r, onDecide: i, onL
|
|
|
1322
1330
|
}) : /* @__PURE__ */ l("div", {
|
|
1323
1331
|
class: "sqc-msg__body",
|
|
1324
1332
|
children: [
|
|
1325
|
-
/* @__PURE__ */ l(
|
|
1333
|
+
/* @__PURE__ */ l(Be, {
|
|
1326
1334
|
text: e.content,
|
|
1327
1335
|
locale: t,
|
|
1328
1336
|
live: r,
|
|
@@ -1332,29 +1340,29 @@ function Ke({ message: e, locale: t, assistantName: n, live: r, onDecide: i, onL
|
|
|
1332
1340
|
class: "sqc-caret",
|
|
1333
1341
|
"aria-hidden": "true"
|
|
1334
1342
|
}),
|
|
1335
|
-
s && /* @__PURE__ */ l(
|
|
1343
|
+
s && /* @__PURE__ */ l(Ue, {
|
|
1336
1344
|
locale: t,
|
|
1337
1345
|
call: e.content.trim() === "" ? e.approval : void 0,
|
|
1338
1346
|
locked: !i
|
|
1339
1347
|
}),
|
|
1340
|
-
e.unknownHandle && !e.streaming && /* @__PURE__ */ l(
|
|
1348
|
+
e.unknownHandle && !e.streaming && /* @__PURE__ */ l(Je, {
|
|
1341
1349
|
message: e,
|
|
1342
1350
|
locale: t
|
|
1343
1351
|
}),
|
|
1344
|
-
/* @__PURE__ */ l(
|
|
1352
|
+
/* @__PURE__ */ l(Ke, {
|
|
1345
1353
|
files: e.attachments ?? [],
|
|
1346
1354
|
load: a,
|
|
1347
1355
|
language: t.code
|
|
1348
1356
|
})
|
|
1349
1357
|
]
|
|
1350
|
-
}), !o && /* @__PURE__ */ l(
|
|
1358
|
+
}), !o && /* @__PURE__ */ l(He, {
|
|
1351
1359
|
at: e.createdAt,
|
|
1352
1360
|
locale: t
|
|
1353
1361
|
})]
|
|
1354
1362
|
})]
|
|
1355
1363
|
});
|
|
1356
1364
|
}
|
|
1357
|
-
function
|
|
1365
|
+
function Je({ message: e, locale: n }) {
|
|
1358
1366
|
let r = e.offered ?? [];
|
|
1359
1367
|
return /* @__PURE__ */ l("p", {
|
|
1360
1368
|
class: "sqc-msg__unaddressed",
|
|
@@ -1371,7 +1379,7 @@ function qe({ message: e, locale: n }) {
|
|
|
1371
1379
|
]
|
|
1372
1380
|
});
|
|
1373
1381
|
}
|
|
1374
|
-
function
|
|
1382
|
+
function Ye() {
|
|
1375
1383
|
return /* @__PURE__ */ l("svg", {
|
|
1376
1384
|
viewBox: "0 0 24 24",
|
|
1377
1385
|
fill: "none",
|
|
@@ -1383,7 +1391,7 @@ function Je() {
|
|
|
1383
1391
|
children: /* @__PURE__ */ l("path", { d: "M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719" })
|
|
1384
1392
|
});
|
|
1385
1393
|
}
|
|
1386
|
-
function
|
|
1394
|
+
function Xe({ messages: e, locale: t, assistantName: n, suggestions: i, showSuggestions: a, busy: s, withHuman: c, onSuggestion: u, onChoice: d, onDecide: f, onCompose: m, onLoadAttachment: h }) {
|
|
1387
1395
|
let g = o(null), _ = o(!0);
|
|
1388
1396
|
r(() => {
|
|
1389
1397
|
let e = g.current;
|
|
@@ -1434,7 +1442,7 @@ function Ye({ messages: e, locale: t, assistantName: n, suggestions: i, showSugg
|
|
|
1434
1442
|
let e = g.current;
|
|
1435
1443
|
if (!e) return;
|
|
1436
1444
|
let t = () => {
|
|
1437
|
-
_.current = e.scrollHeight - e.scrollTop - e.clientHeight <
|
|
1445
|
+
_.current = e.scrollHeight - e.scrollTop - e.clientHeight < Ve;
|
|
1438
1446
|
};
|
|
1439
1447
|
return e.addEventListener("scroll", t, { passive: !0 }), () => e.removeEventListener("scroll", t);
|
|
1440
1448
|
}, []), /* @__PURE__ */ l("div", {
|
|
@@ -1444,7 +1452,7 @@ function Ye({ messages: e, locale: t, assistantName: n, suggestions: i, showSugg
|
|
|
1444
1452
|
"aria-live": "polite",
|
|
1445
1453
|
"aria-atomic": "false",
|
|
1446
1454
|
children: [
|
|
1447
|
-
e.map((r, i) => /* @__PURE__ */ l(
|
|
1455
|
+
e.map((r, i) => /* @__PURE__ */ l(qe, {
|
|
1448
1456
|
message: r,
|
|
1449
1457
|
locale: t,
|
|
1450
1458
|
assistantName: n,
|
|
@@ -1471,28 +1479,28 @@ function Ye({ messages: e, locale: t, assistantName: n, suggestions: i, showSugg
|
|
|
1471
1479
|
}
|
|
1472
1480
|
//#endregion
|
|
1473
1481
|
//#region src/components/ChatbotWidget.tsx
|
|
1474
|
-
var
|
|
1475
|
-
function
|
|
1482
|
+
var Ze = { width: "min(392px, 100vw)" }, Qe = /* @__PURE__ */ new Set(["sessionId"]);
|
|
1483
|
+
function $e(e) {
|
|
1476
1484
|
let t = e.replace(/Id$|Ref$/, "").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_-]+/g, " ").trim().toLowerCase();
|
|
1477
1485
|
return t ? t.charAt(0).toUpperCase() + t.slice(1) : e;
|
|
1478
1486
|
}
|
|
1479
|
-
function
|
|
1487
|
+
function et(e) {
|
|
1480
1488
|
if (!e) return [];
|
|
1481
1489
|
let t = [];
|
|
1482
1490
|
for (let [n, r] of Object.entries(e)) {
|
|
1483
|
-
if (
|
|
1491
|
+
if (Qe.has(n) || typeof r != "string" && !w(r)) continue;
|
|
1484
1492
|
let e = C(r);
|
|
1485
1493
|
e && t.push({
|
|
1486
|
-
label:
|
|
1494
|
+
label: $e(n),
|
|
1487
1495
|
value: e
|
|
1488
1496
|
});
|
|
1489
1497
|
}
|
|
1490
1498
|
return t;
|
|
1491
1499
|
}
|
|
1492
|
-
function
|
|
1500
|
+
function tt(e, t) {
|
|
1493
1501
|
return e?.trim() ? e : t;
|
|
1494
1502
|
}
|
|
1495
|
-
function
|
|
1503
|
+
function nt(t) {
|
|
1496
1504
|
let [n, r] = e(!1);
|
|
1497
1505
|
return v(() => {
|
|
1498
1506
|
if (t !== "auto" || typeof matchMedia != "function") return;
|
|
@@ -1502,11 +1510,12 @@ function tt(t) {
|
|
|
1502
1510
|
return e.addEventListener("change", n), () => e.removeEventListener("change", n);
|
|
1503
1511
|
}, [t]), t === "dark" ? "dark" : t === "light" ? "light" : n ? "dark" : "light";
|
|
1504
1512
|
}
|
|
1505
|
-
function
|
|
1513
|
+
function rt(t) {
|
|
1506
1514
|
a();
|
|
1507
|
-
let n = t.persistOpen ?? !0, [s, c] = e(() => k(t.defaultOpen, n)), [u, d] = e(!1), [f, p] = e(!1), m = o(null), h = o(null), g =
|
|
1515
|
+
let n = t.persistOpen ?? !0, [s, c] = e(() => k(t.defaultOpen, n)), [u, d] = e(!1), [f, p] = e(!1), m = o(null), h = o(null), g = nt(t.theme ?? "light"), _ = y(() => b(t.locale), [t.locale]), x = _.t, S = tt(t.heading, x.heading), C = tt(t.assistantName, x.assistant), w = tt(t.greeting, x.greeting), T = t.onEvent, { send: E, reset: D, decide: j, stop: M, start: N, resets: P, busy: F, messages: I, withHuman: L, branding: R, sessionId: z, handles: B, addressee: te, agentHandle: V, attachments: H, uploading: U, attachmentError: W, attach: G, detach: K, loadAttachment: q } = be({
|
|
1508
1516
|
embedKey: t.embedKey,
|
|
1509
1517
|
user: t.user,
|
|
1518
|
+
scope: t.scope,
|
|
1510
1519
|
getSubjectToken: t.getSubjectToken,
|
|
1511
1520
|
agent: t.agent,
|
|
1512
1521
|
context: t.context,
|
|
@@ -1517,10 +1526,10 @@ function nt(t) {
|
|
|
1517
1526
|
v(() => {
|
|
1518
1527
|
!s && I.some((e) => e.role === "assistant" && e.id !== "greeting") && p(!0);
|
|
1519
1528
|
}, [I, s]);
|
|
1520
|
-
let
|
|
1521
|
-
|
|
1522
|
-
let
|
|
1523
|
-
p(!1), !
|
|
1529
|
+
let J = o(s);
|
|
1530
|
+
J.current = s;
|
|
1531
|
+
let Y = i(() => {
|
|
1532
|
+
p(!1), !J.current && (J.current = !0, c(!0), n && O(!0), T?.({
|
|
1524
1533
|
type: "chatbot-open",
|
|
1525
1534
|
sessionId: z
|
|
1526
1535
|
}));
|
|
@@ -1528,8 +1537,8 @@ function nt(t) {
|
|
|
1528
1537
|
T,
|
|
1529
1538
|
n,
|
|
1530
1539
|
z
|
|
1531
|
-
]),
|
|
1532
|
-
|
|
1540
|
+
]), X = i(() => {
|
|
1541
|
+
J.current && (J.current = !1, c(!1), n && O(!1), T?.({
|
|
1533
1542
|
type: "chatbot-close",
|
|
1534
1543
|
sessionId: z
|
|
1535
1544
|
}), h.current?.focus());
|
|
@@ -1539,57 +1548,61 @@ function nt(t) {
|
|
|
1539
1548
|
z
|
|
1540
1549
|
]);
|
|
1541
1550
|
v(() => {
|
|
1542
|
-
s &&
|
|
1543
|
-
}, [
|
|
1544
|
-
|
|
1545
|
-
|
|
1551
|
+
s && N();
|
|
1552
|
+
}, [
|
|
1553
|
+
s,
|
|
1554
|
+
P,
|
|
1555
|
+
N
|
|
1556
|
+
]);
|
|
1557
|
+
let ne = B.length >= 2, re = ee(I, V || void 0), [ie, ae] = e(void 0), oe = o(void 0), se = i((e) => {
|
|
1558
|
+
oe.current = e, ae(e);
|
|
1546
1559
|
}, []);
|
|
1547
1560
|
v(() => {
|
|
1548
|
-
|
|
1549
|
-
}, [
|
|
1561
|
+
oe.current = void 0, ae(void 0);
|
|
1562
|
+
}, [re]);
|
|
1550
1563
|
let Z = i((e) => {
|
|
1551
|
-
d(!0), E(
|
|
1564
|
+
d(!0), E(ne ? A(e, oe.current, re) : e);
|
|
1552
1565
|
}, [
|
|
1553
1566
|
E,
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
]),
|
|
1567
|
+
ne,
|
|
1568
|
+
re
|
|
1569
|
+
]), ce = i(() => {
|
|
1557
1570
|
d(!1), p(!1), D();
|
|
1558
|
-
}, [D]),
|
|
1559
|
-
openPanel:
|
|
1560
|
-
closePanel:
|
|
1571
|
+
}, [D]), Q = o({
|
|
1572
|
+
openPanel: Y,
|
|
1573
|
+
closePanel: X,
|
|
1561
1574
|
send: Z,
|
|
1562
|
-
reset:
|
|
1575
|
+
reset: ce,
|
|
1563
1576
|
sessionId: z
|
|
1564
1577
|
});
|
|
1565
|
-
|
|
1566
|
-
openPanel:
|
|
1567
|
-
closePanel:
|
|
1578
|
+
Q.current = {
|
|
1579
|
+
openPanel: Y,
|
|
1580
|
+
closePanel: X,
|
|
1568
1581
|
send: Z,
|
|
1569
|
-
reset:
|
|
1582
|
+
reset: ce,
|
|
1570
1583
|
sessionId: z
|
|
1571
1584
|
};
|
|
1572
|
-
let
|
|
1573
|
-
open: () =>
|
|
1574
|
-
close: () =>
|
|
1575
|
-
toggle: () =>
|
|
1576
|
-
reset: () =>
|
|
1585
|
+
let le = o({
|
|
1586
|
+
open: () => Q.current.openPanel(),
|
|
1587
|
+
close: () => Q.current.closePanel(),
|
|
1588
|
+
toggle: () => J.current ? Q.current.closePanel() : Q.current.openPanel(),
|
|
1589
|
+
reset: () => Q.current.reset(),
|
|
1577
1590
|
send: (e) => {
|
|
1578
|
-
|
|
1591
|
+
Q.current.openPanel(), Q.current.send(e);
|
|
1579
1592
|
},
|
|
1580
|
-
isOpen: () =>
|
|
1581
|
-
sessionId: () =>
|
|
1582
|
-
}),
|
|
1583
|
-
r(() => (
|
|
1593
|
+
isOpen: () => J.current,
|
|
1594
|
+
sessionId: () => Q.current.sessionId
|
|
1595
|
+
}), $ = t.bind;
|
|
1596
|
+
r(() => ($?.(le.current), () => $?.(null)), [$]), v(() => {
|
|
1584
1597
|
if (!s) return;
|
|
1585
1598
|
let e = (e) => {
|
|
1586
|
-
e.key === "Escape" && (e.stopPropagation(),
|
|
1599
|
+
e.key === "Escape" && (e.stopPropagation(), X());
|
|
1587
1600
|
};
|
|
1588
1601
|
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
1589
|
-
}, [
|
|
1590
|
-
let
|
|
1602
|
+
}, [X, s]);
|
|
1603
|
+
let ue = y(() => I.some((e) => e.id !== "greeting"), [I]), de = y(() => et(t.context), [t.context]), fe = {
|
|
1591
1604
|
...t.accent ? { "--sqc-accent": t.accent } : {},
|
|
1592
|
-
"--sqc-width": t.width ??
|
|
1605
|
+
"--sqc-width": t.width ?? Ze.width
|
|
1593
1606
|
};
|
|
1594
1607
|
return /* @__PURE__ */ l("div", {
|
|
1595
1608
|
class: "sqc",
|
|
@@ -1597,7 +1610,7 @@ function nt(t) {
|
|
|
1597
1610
|
"data-position": t.position ?? "bottom-right",
|
|
1598
1611
|
"data-layout": t.layout ?? "sidebar",
|
|
1599
1612
|
"data-open": s ? "true" : "false",
|
|
1600
|
-
style:
|
|
1613
|
+
style: fe,
|
|
1601
1614
|
children: [/* @__PURE__ */ l("button", {
|
|
1602
1615
|
ref: h,
|
|
1603
1616
|
type: "button",
|
|
@@ -1605,13 +1618,13 @@ function nt(t) {
|
|
|
1605
1618
|
"aria-label": S,
|
|
1606
1619
|
"aria-expanded": s,
|
|
1607
1620
|
"aria-haspopup": "dialog",
|
|
1608
|
-
onClick:
|
|
1621
|
+
onClick: Y,
|
|
1609
1622
|
children: [/* @__PURE__ */ l("span", {
|
|
1610
1623
|
class: "sqc-launcher__icon",
|
|
1611
1624
|
children: /* @__PURE__ */ l("slot", {
|
|
1612
1625
|
name: "launcher-icon",
|
|
1613
1626
|
class: "sqc-slot-icon",
|
|
1614
|
-
children: /* @__PURE__ */ l(
|
|
1627
|
+
children: /* @__PURE__ */ l(Ye, {})
|
|
1615
1628
|
})
|
|
1616
1629
|
}), f && /* @__PURE__ */ l("span", {
|
|
1617
1630
|
class: "sqc-launcher__badge",
|
|
@@ -1630,7 +1643,7 @@ function nt(t) {
|
|
|
1630
1643
|
/* @__PURE__ */ l("span", {
|
|
1631
1644
|
class: "sqc-header__icon",
|
|
1632
1645
|
"aria-hidden": "true",
|
|
1633
|
-
children: /* @__PURE__ */ l(
|
|
1646
|
+
children: /* @__PURE__ */ l(Ye, {})
|
|
1634
1647
|
}),
|
|
1635
1648
|
/* @__PURE__ */ l("div", {
|
|
1636
1649
|
class: "sqc-header__titles",
|
|
@@ -1639,13 +1652,13 @@ function nt(t) {
|
|
|
1639
1652
|
children: S
|
|
1640
1653
|
}), /* @__PURE__ */ l("p", {
|
|
1641
1654
|
class: "sqc-header__sub",
|
|
1642
|
-
children:
|
|
1655
|
+
children: tt(t.subheading, x.subheading)
|
|
1643
1656
|
})]
|
|
1644
1657
|
}),
|
|
1645
1658
|
/* @__PURE__ */ l("button", {
|
|
1646
1659
|
type: "button",
|
|
1647
1660
|
class: "sqc-icon-btn",
|
|
1648
|
-
onClick:
|
|
1661
|
+
onClick: ce,
|
|
1649
1662
|
"aria-label": x.newConversation,
|
|
1650
1663
|
"data-tip": x.newConversation,
|
|
1651
1664
|
children: /* @__PURE__ */ l("svg", {
|
|
@@ -1662,7 +1675,7 @@ function nt(t) {
|
|
|
1662
1675
|
/* @__PURE__ */ l("button", {
|
|
1663
1676
|
type: "button",
|
|
1664
1677
|
class: "sqc-icon-btn",
|
|
1665
|
-
onClick:
|
|
1678
|
+
onClick: X,
|
|
1666
1679
|
"aria-label": x.close,
|
|
1667
1680
|
"data-tip": x.closeTitle,
|
|
1668
1681
|
children: /* @__PURE__ */ l("svg", {
|
|
@@ -1679,52 +1692,52 @@ function nt(t) {
|
|
|
1679
1692
|
]
|
|
1680
1693
|
}), /* @__PURE__ */ l("div", {
|
|
1681
1694
|
class: "sqc-panel__body",
|
|
1682
|
-
children: [
|
|
1695
|
+
children: [ne && /* @__PURE__ */ l(Ce, {
|
|
1683
1696
|
handles: B,
|
|
1684
|
-
active:
|
|
1697
|
+
active: ie ?? re,
|
|
1685
1698
|
disabled: L,
|
|
1686
|
-
onPick:
|
|
1699
|
+
onPick: se,
|
|
1687
1700
|
label: x.handles.rail
|
|
1688
1701
|
}), /* @__PURE__ */ l("div", {
|
|
1689
1702
|
class: "sqc-panel__main",
|
|
1690
1703
|
children: [
|
|
1691
|
-
(t.showContext ?? !0) &&
|
|
1704
|
+
(t.showContext ?? !0) && de.length > 0 && /* @__PURE__ */ l("div", {
|
|
1692
1705
|
class: "sqc-context",
|
|
1693
1706
|
"aria-label": x.context.region,
|
|
1694
|
-
children:
|
|
1707
|
+
children: de.map((e) => /* @__PURE__ */ l("span", {
|
|
1695
1708
|
class: "sqc-chip",
|
|
1696
1709
|
title: `${e.label}: ${e.value}`,
|
|
1697
1710
|
children: [/* @__PURE__ */ l("b", { children: e.label }), e.value]
|
|
1698
1711
|
}, e.label))
|
|
1699
1712
|
}),
|
|
1700
|
-
/* @__PURE__ */ l(
|
|
1713
|
+
/* @__PURE__ */ l(Xe, {
|
|
1701
1714
|
messages: I,
|
|
1702
1715
|
locale: _,
|
|
1703
1716
|
assistantName: C,
|
|
1704
1717
|
suggestions: t.suggestions,
|
|
1705
|
-
showSuggestions: !u && !
|
|
1718
|
+
showSuggestions: !u && !ue,
|
|
1706
1719
|
busy: F,
|
|
1707
1720
|
withHuman: L,
|
|
1708
1721
|
onSuggestion: Z,
|
|
1709
1722
|
onChoice: Z,
|
|
1710
|
-
onDecide:
|
|
1723
|
+
onDecide: j,
|
|
1711
1724
|
onCompose: () => m.current?.querySelector(".sqc-composer__input")?.focus(),
|
|
1712
|
-
onLoadAttachment:
|
|
1725
|
+
onLoadAttachment: q
|
|
1713
1726
|
}),
|
|
1714
|
-
/* @__PURE__ */ l(
|
|
1715
|
-
placeholder:
|
|
1727
|
+
/* @__PURE__ */ l(ke, {
|
|
1728
|
+
placeholder: tt(t.placeholder, x.placeholder),
|
|
1716
1729
|
locale: _,
|
|
1717
1730
|
busy: F,
|
|
1718
1731
|
autoFocus: s,
|
|
1719
1732
|
handles: B,
|
|
1720
|
-
addressee:
|
|
1733
|
+
addressee: te,
|
|
1721
1734
|
attachments: H,
|
|
1722
1735
|
uploading: U,
|
|
1723
1736
|
attachmentError: W ? x.attachments[W] : void 0,
|
|
1724
|
-
onAttach:
|
|
1725
|
-
onDetach:
|
|
1737
|
+
onAttach: G,
|
|
1738
|
+
onDetach: K,
|
|
1726
1739
|
onSend: Z,
|
|
1727
|
-
onStop:
|
|
1740
|
+
onStop: M
|
|
1728
1741
|
}),
|
|
1729
1742
|
/* @__PURE__ */ l("p", {
|
|
1730
1743
|
class: "sqc-hint",
|
|
@@ -1747,7 +1760,7 @@ function nt(t) {
|
|
|
1747
1760
|
}
|
|
1748
1761
|
//#endregion
|
|
1749
1762
|
//#region src/styles.css?inline
|
|
1750
|
-
var rt = ":host{--sqc-width:min(392px, 100vw);--sqc-height:640px;--sqc-z:2147480000;--sqc-radius:16px;--sqc-font-family:\"Plus Jakarta Sans\", ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif;--sqc-font-heading:var(--sqc-font-family);z-index:var(--sqc-z);pointer-events:none;font-family:var(--sqc-font-family);-webkit-font-smoothing:antialiased;text-align:left;font-size:14px;line-height:1.5;display:block;position:fixed;top:0;bottom:0;left:0;right:0;margin:0!important}:host([hidden]){display:none}.sqc{--sqc-neutral-50:#f8fafc;--sqc-neutral-100:#f1f5f9;--sqc-neutral-200:#e2e8f0;--sqc-neutral-300:#cbd5e1;--sqc-neutral-400:#94a3b8;--sqc-neutral-500:#64748b;--sqc-neutral-600:#475569;--sqc-neutral-900:#0f172a;--sqc-error-50:#fff1f2;--sqc-error-100:#ffe4e6;--sqc-error-600:#e11d48;--sqc-accent-default:#000;--sqc-accent-color:var(--sqc-accent,var(--sqc-accent-default));--sqc-on-accent:#fff;--sqc-accent-hover:color-mix(in oklab, var(--sqc-accent-color) 84%, var(--sqc-on-accent));--sqc-accent-fg:var(--sqc-accent,var(--sqc-text));--sqc-bg:#fff;--sqc-surface:var(--sqc-neutral-50);--sqc-selected:var(--sqc-neutral-100);--sqc-border:var(--sqc-neutral-200);--sqc-border-strong:var(--sqc-neutral-300);--sqc-text:var(--sqc-neutral-900);--sqc-text-muted:var(--sqc-neutral-500);--sqc-link:#2563eb;--sqc-bubble-user:var(--sqc-accent-color);--sqc-bubble-user-text:var(--sqc-on-accent);--sqc-code-bg:var(--sqc-neutral-100);--sqc-disabled:var(--sqc-neutral-300);--sqc-shadow:0 10px 15px -3px #0f172a1a, 0 4px 6px -4px #0f172a1a;--sqc-shadow-bottom:0 6px 8px -6px #0f172a2e;--sqc-focus:0 0 0 2px var(--sqc-bg), 0 0 0 4px #0f172a4d;--sqc-focus-input:0 0 0 3px #0f172a1a;--sqc-danger:var(--sqc-error-600);color:var(--sqc-text);position:absolute;top:0;bottom:0;left:0;right:0}.sqc[data-theme=dark]{--sqc-neutral-50:#172033;--sqc-neutral-100:#1e293b;--sqc-neutral-200:#334155;--sqc-neutral-300:#475569;--sqc-neutral-400:#64748b;--sqc-neutral-500:#94a3b8;--sqc-neutral-600:#cbd5e1;--sqc-neutral-900:#f8fafc;--sqc-error-50:#2a0a12;--sqc-error-100:#4c0519;--sqc-error-600:#fb7185;--sqc-accent-default:#fff;--sqc-on-accent:#0f172a;--sqc-bg:#0f172a;--sqc-link:#60a5fa;--sqc-code-bg:#020617;--sqc-shadow:0 10px 24px -4px #0000008c;--sqc-shadow-bottom:0 6px 8px -6px #0000008c;--sqc-focus:0 0 0 2px var(--sqc-bg), 0 0 0 4px #f8fafc59;--sqc-focus-input:0 0 0 3px #f8fafc1f}@supports (color:oklch(from red l c h)){.sqc{--sqc-on-accent:oklch(from var(--sqc-accent-color) clamp(.208, (.62 - l) * 1000, 1) 0 0)}}.sqc *,.sqc :before,.sqc :after{box-sizing:border-box}.sqc-launcher{background:var(--sqc-accent-color);width:56px;height:56px;color:var(--sqc-on-accent);cursor:pointer;pointer-events:auto;box-shadow:var(--sqc-shadow);border:none;border-radius:50%;place-items:center;padding:0;transition:transform .18s,opacity .18s,background .18s,box-shadow .18s;display:grid;position:absolute;bottom:24px;right:24px}.sqc[data-position=bottom-left] .sqc-launcher{left:24px;right:auto}.sqc-launcher:hover{background:var(--sqc-accent-hover);transform:scale(1.06)}.sqc-launcher:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc[data-open=true] .sqc-launcher{opacity:0;pointer-events:none;transform:scale(.5)}.sqc-launcher__icon svg{width:26px;height:26px;display:block}.sqc-slot-icon::slotted(*){justify-content:center;align-items:center;width:26px;height:26px;display:inline-flex}.sqc-launcher__badge{background:var(--sqc-error-600);border:2px solid var(--sqc-bg);border-radius:50%;width:12px;height:12px;position:absolute;top:6px;right:6px}.sqc-panel{width:var(--sqc-width);background:var(--sqc-bg);border-left:1px solid var(--sqc-border);box-shadow:var(--sqc-shadow);pointer-events:auto;visibility:hidden;flex-direction:column;transition:transform .26s cubic-bezier(.22,1,.36,1),visibility 0s linear .26s;display:flex;position:absolute;top:0;bottom:0;right:0;transform:translate(100%)}.sqc-panel__body{flex:1;min-height:0;display:flex}.sqc-panel__main{flex-direction:column;flex:1;min-width:0;min-height:0;display:flex}.sqc-rail{border-right:1px solid var(--sqc-border);background:color-mix(in oklab, var(--sqc-accent-color) 7%, var(--sqc-bg));flex-direction:column;flex-shrink:0;align-items:stretch;gap:6px;width:72px;padding:12px 0;display:flex;overflow:visible}.sqc-rail__item{color:var(--sqc-text-muted);font:inherit;cursor:pointer;background:0 0;border:0;flex-direction:column;align-items:center;gap:4px;padding:4px 0;display:flex;position:relative}.sqc-rail__label{white-space:nowrap;text-overflow:ellipsis;max-width:64px;font-size:10.5px;font-weight:500;line-height:1.2;overflow:hidden}.sqc-rail__item:hover,.sqc-rail__item[aria-pressed=true]{color:var(--sqc-text)}.sqc-rail__item[aria-pressed=true] .sqc-rail__label{font-weight:600}.sqc-rail__item .sqc-avatar{transition:box-shadow .15s}.sqc-rail__item[aria-pressed=true] .sqc-avatar{box-shadow:0 0 0 2px var(--sqc-bg), 0 0 0 4px var(--sqc-accent-color)}.sqc-rail__item:before{content:\"\";background:var(--sqc-text);border-radius:0 4px 4px 0;width:4px;height:0;transition:height .15s;position:absolute;top:24px;left:0;transform:translateY(-50%)}.sqc-rail__item:hover:before{height:12px}.sqc-rail__item[aria-pressed=true]:before{height:32px}.sqc-rail__item:focus-visible{outline:2px solid var(--sqc-accent-color);outline-offset:-2px;border-radius:8px}.sqc-rail__item:disabled{cursor:not-allowed;opacity:.5}.sqc-rail__item[data-tip]:after{content:attr(data-tip);z-index:2;background:var(--sqc-text);color:var(--sqc-bg);white-space:nowrap;pointer-events:none;opacity:0;border-radius:6px;padding:4px 8px;font-size:12px;font-weight:500;transition:opacity .12s;position:absolute;top:24px;left:calc(100% + 6px);transform:translateY(-50%)}.sqc-rail__item[data-tip]:hover:after{opacity:1}.sqc-rail__item[data-tip]:focus-visible:after{opacity:1}.sqc[data-open=true] .sqc-panel{visibility:visible;transition:transform .26s cubic-bezier(.22,1,.36,1),visibility;transform:translate(0)}.sqc[data-layout=floating] .sqc-panel{max-width:calc(100% - 48px);height:var(--sqc-height);border:1px solid var(--sqc-border);border-radius:var(--sqc-radius);opacity:0;transform-origin:100% 100%;max-height:calc(100% - 48px);transition:transform .22s cubic-bezier(.22,1,.36,1),opacity .22s,visibility 0s linear .22s;top:auto;bottom:24px;right:24px;overflow:hidden;transform:translateY(16px)scale(.96)}.sqc[data-layout=floating][data-position=bottom-left] .sqc-panel{transform-origin:0 100%;left:24px;right:auto}.sqc[data-layout=floating][data-open=true] .sqc-panel{opacity:1;transition:transform .22s cubic-bezier(.22,1,.36,1),opacity .22s,visibility;transform:none}.sqc-header{background:var(--sqc-bg);color:var(--sqc-text);border-bottom:1px solid var(--sqc-border);flex-shrink:0;align-items:center;gap:8px;padding:13px 12px 13px 16px;display:flex}.sqc-header__icon{color:var(--sqc-accent-fg);flex-shrink:0;place-items:center;display:grid}.sqc-header__icon svg{width:17px;height:17px;display:block}.sqc-header__titles{flex:1;min-width:0}.sqc-header__heading,.sqc-header__sub{text-overflow:ellipsis;white-space:nowrap;margin:0;overflow:hidden}.sqc-header__heading{font-family:var(--sqc-font-heading);letter-spacing:-.2px;font-size:15px;font-weight:700}.sqc-header__sub{color:var(--sqc-text-muted);font-size:12px}.sqc-icon-btn{width:26px;height:26px;color:var(--sqc-text-muted);cursor:pointer;background:0 0;border:none;border-radius:8px;flex-shrink:0;place-items:center;transition:background .15s;display:grid}.sqc-icon-btn:hover{background:var(--sqc-surface);color:var(--sqc-text)}.sqc-icon-btn:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-icon-btn svg{width:16px;height:16px}.sqc-icon-btn[data-tip]{position:relative}.sqc-icon-btn[data-tip]:after{content:attr(data-tip);z-index:6;background:var(--sqc-text);color:var(--sqc-bg);font-family:var(--sqc-font-family);white-space:nowrap;pointer-events:none;opacity:0;border-radius:8px;padding:4px 8px;font-size:11px;font-weight:500;line-height:1.3;transition:opacity .12s .15s;position:absolute;top:calc(100% + 6px);right:0}.sqc-icon-btn[data-tip]:hover:after{opacity:1}.sqc-icon-btn[data-tip]:focus-visible:after{opacity:1}.sqc-history-pop{z-index:5;position:absolute;top:54px;left:0;right:0}.sqc-history{background:var(--sqc-bg);max-height:320px;box-shadow:var(--sqc-shadow-bottom);flex-direction:column;display:flex;overflow-y:auto}.sqc-history__empty{color:var(--sqc-text-muted);text-align:center;margin:0;padding:14px 16px;font-size:12px}.sqc-history__item{border:none;border-bottom:1px solid var(--sqc-border);width:100%;color:var(--sqc-text);text-align:left;cursor:pointer;background:0 0;flex-direction:column;gap:2px;padding:10px 16px;transition:background .15s;display:flex}.sqc-history__item:last-child{border-bottom:none}.sqc-history__item:hover{background:var(--sqc-surface)}.sqc-history__item:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-history__item[aria-current=true]{background:var(--sqc-selected)}.sqc-history__item[aria-current=true] .sqc-history__title{color:var(--sqc-text);font-weight:600}.sqc-history__title{text-overflow:ellipsis;white-space:nowrap;font-size:13px;overflow:hidden}.sqc-history__date{color:var(--sqc-text-muted);font-size:11px}.sqc-context{background:var(--sqc-selected);border:1px solid var(--sqc-border);color:var(--sqc-text);border-radius:12px;flex-wrap:wrap;flex-shrink:0;align-items:center;gap:8px;margin:12px 16px 4px;padding:8px 11px;font-size:12px;display:flex}.sqc-chip{text-overflow:ellipsis;white-space:nowrap;align-items:baseline;gap:4px;max-width:100%;display:inline-flex;overflow:hidden}.sqc-chip b{font-weight:600}.sqc-chip:not(:last-child):after{content:\"·\";opacity:.5;margin-left:4px}.sqc-messages{overscroll-behavior:contain;background:var(--sqc-bg);scrollbar-width:thin;scrollbar-color:var(--sqc-neutral-300) transparent;flex-direction:column;flex:1;gap:13px;min-height:0;padding:12px 16px;display:flex;overflow-y:auto}.sqc-messages::-webkit-scrollbar{width:6px}.sqc-messages::-webkit-scrollbar-thumb{background:var(--sqc-neutral-300);border-radius:99px}.sqc-msg{flex-direction:column;max-width:93%;font-size:13.5px;display:flex}.sqc-msg--assistant{align-self:stretch}.sqc-msg--user{align-self:flex-end}.sqc-msg__who{color:var(--sqc-text-muted);align-items:center;gap:6px;margin-bottom:4px;font-size:11px;font-weight:500;display:flex}.sqc-msg__who svg{width:12px;height:12px;color:var(--sqc-accent-fg);flex-shrink:0}.sqc-avatar{background:var(--sqc-accent-color);color:var(--sqc-on-accent);-webkit-user-select:none;user-select:none;flex-shrink:0;justify-content:center;align-items:center;font-weight:600;line-height:1;display:inline-flex;overflow:hidden}.sqc-avatar img{object-fit:cover;width:100%;height:100%}.sqc-msg__unaddressed{color:var(--sqc-text-muted);margin:8px 0 0;font-size:11.5px;line-height:1.5}.sqc-msg__unaddressed code{background:var(--sqc-code-bg);color:var(--sqc-text);border-radius:4px;margin-right:4px;padding:1px 4px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:11px}.sqc-msg--user .sqc-msg__bubble{background:var(--sqc-bubble-user);color:var(--sqc-bubble-user-text);border-radius:var(--sqc-radius) var(--sqc-radius) 4px var(--sqc-radius);padding:9px 13px}.sqc-msg--error .sqc-msg__bubble{background:var(--sqc-error-50);color:var(--sqc-error-600);border:1px solid var(--sqc-error-100);border-radius:12px;padding:11px}.sqc-msg__body{overflow-wrap:anywhere}.sqc-msg--assistant .sqc-msg__body{font-size:14px;line-height:1.6}.sqc-msg__body>:first-child{margin-top:0}.sqc-msg__body>:last-child{margin-bottom:0}.sqc-msg__body p{white-space:pre-wrap;margin:0 0 8px}.sqc-msg__body ul,.sqc-msg__body ol{margin:0 0 8px;padding-left:20px}.sqc-msg__body li{margin-bottom:3px}.sqc-msg__body code{background:var(--sqc-code-bg);border-radius:4px;padding:1px 4px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:.85em}.sqc-msg--user .sqc-msg__body code{background:#ffffff38}.sqc-msg__body pre{background:var(--sqc-code-bg);border-radius:8px;margin:0 0 8px;padding:9px 11px;overflow-x:auto}.sqc-msg__body pre code{background:0 0;padding:0}.sqc-msg__body a{color:inherit;text-underline-offset:2px;text-decoration:underline}.sqc-msg--assistant .sqc-msg__body a{color:var(--sqc-link);text-decoration:none}.sqc-msg--assistant .sqc-msg__body a:hover{text-decoration:underline}.sqc-msg__body h3,.sqc-msg__body h4,.sqc-msg__body h5,.sqc-msg__body h6{font-family:var(--sqc-font-heading);letter-spacing:-.2px;margin:12px 0 6px;font-weight:700;line-height:1.3}.sqc-msg__body h3{font-size:1.05em}.sqc-msg__body h4{font-size:1em}.sqc-msg__body h5,.sqc-msg__body h6{font-size:.94em}.sqc-msg__body ul ul,.sqc-msg__body ul ol,.sqc-msg__body ol ul,.sqc-msg__body ol ol{margin:3px 0 0}.sqc-msg__body blockquote{border-left:2px solid var(--sqc-border-strong);color:var(--sqc-text-muted);white-space:pre-wrap;margin:0 0 8px;padding:2px 0 2px 10px}.sqc-msg--user .sqc-msg__body blockquote{color:inherit;opacity:.85;border-left-color:#ffffff73}.sqc-msg__body hr{border:0;border-top:1px solid var(--sqc-border);margin:10px 0}.sqc-msg--user .sqc-msg__body hr{border-top-color:#ffffff4d}.sqc-msg__body del{opacity:.7}.sqc-selection{flex-direction:column;gap:10px;margin:2px 0;display:flex}.sqc-selection__question{flex-direction:column;gap:2px;display:flex}.sqc-selection__ask{font-family:var(--sqc-font-family);color:var(--sqc-text);margin:0;font-size:13px;font-weight:600}.sqc-selection__actions{display:flex}.sqc-selection__validate{height:32px;font-family:var(--sqc-font-family);color:var(--sqc-on-accent);background:var(--sqc-accent-color);cursor:pointer;border:1px solid #0000;border-radius:12px;flex:auto;justify-content:center;align-items:center;padding:0 12px;font-size:13px;font-weight:600;transition:filter .12s,background .12s;display:inline-flex}.sqc-selection__validate:hover:not(:disabled){background:var(--sqc-accent-hover)}.sqc-selection__validate:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-selection__validate:disabled{cursor:not-allowed;color:#fff;background:var(--sqc-disabled)}.sqc-selection__hint{font-family:var(--sqc-font-family);color:var(--sqc-text-muted);margin:0;font-size:11.5px}.sqc-msg__time{color:var(--sqc-text-muted);font-variant-numeric:tabular-nums;margin-top:3px;font-size:10px;display:block}.sqc-msg--user .sqc-msg__time{color:#ffffffb3;text-align:right}.sqc-caret{vertical-align:text-bottom;background:currentColor;width:2px;height:1em;margin-left:2px;animation:1s step-end infinite sqc-blink;display:inline-block}@keyframes sqc-blink{0%,to{opacity:1}50%{opacity:0}}.sqc-typing{gap:3px;padding:2px 0;display:inline-flex}.sqc-typing i{background:var(--sqc-neutral-400);border-radius:50%;width:5px;height:5px;animation:1.2s infinite sqc-pulse}.sqc-typing i:nth-child(2){animation-delay:.2s}.sqc-typing i:nth-child(3){animation-delay:.4s}.sqc-waiting{align-items:center;gap:8px;display:inline-flex}.sqc-activity{color:var(--sqc-text-muted);font-size:12px}@keyframes sqc-pulse{0%,60%,to{opacity:.25}30%{opacity:1}}.sqc-suggestions{flex-direction:column;gap:7px;display:flex}.sqc-suggestion{border:1px solid var(--sqc-border);background:var(--sqc-bg);width:100%;color:var(--sqc-text);font-family:var(--sqc-font-family);cursor:pointer;text-align:left;border-radius:12px;align-items:center;gap:8px;padding:8px 11px;font-size:12.5px;transition:background .15s,border-color .15s;display:flex}.sqc-suggestion:before{content:\"\";background:var(--sqc-accent-fg);border-radius:50%;flex:none;width:5px;height:5px}.sqc-suggestion:hover{background:var(--sqc-surface);border-color:var(--sqc-border-strong)}.sqc-suggestion:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-composer{border-top:1px solid var(--sqc-border);background:var(--sqc-bg);flex-wrap:wrap;flex-shrink:0;align-items:flex-end;gap:8px;padding:12px 14px;display:flex}.sqc-composer--dropping{outline:2px dashed var(--sqc-accent-color);outline-offset:-4px}.sqc-attachments{flex-wrap:wrap;flex-basis:100%;gap:6px;display:flex}.sqc-attachments--sent{margin-top:8px}.sqc-chip{border:1px solid var(--sqc-border);background:var(--sqc-selected);max-width:100%;color:var(--sqc-text);border-radius:999px;align-items:center;gap:4px;padding:3px 4px 3px 10px;font-size:12px;display:inline-flex}.sqc-chip--waiting{opacity:.6;padding-right:10px}.sqc-chip__name{text-overflow:ellipsis;white-space:nowrap;max-width:180px;overflow:hidden}.sqc-chip__remove{width:18px;height:18px;color:var(--sqc-text-muted);cursor:pointer;background:0 0;border:0;border-radius:999px;justify-content:center;align-items:center;padding:0;font-size:14px;line-height:1;display:inline-flex}.sqc-chip__remove:hover{background:var(--sqc-selected);color:var(--sqc-text)}.sqc-attachments__error{color:var(--sqc-error-600);flex-basis:100%;margin:0;font-size:12px}.sqc-attachment__image{border-radius:12px;max-width:100%;max-height:180px;display:block}.sqc-attachment__chart{flex-basis:100%;min-width:0}.sqc-file-input{display:none}.sqc-btn--attach{color:var(--sqc-text-muted);background:0 0}.sqc-btn--attach:hover{background:var(--sqc-selected);color:var(--sqc-text)}.sqc-composer__field{flex:1;min-width:0;position:relative}.sqc-composer__input{border:1px solid var(--sqc-border-strong);background:var(--sqc-bg);width:100%;min-height:38px;max-height:132px;color:var(--sqc-text);font-family:var(--sqc-font-family);resize:none;border-radius:12px;outline:none;padding:9px 12px;font-size:13.5px;line-height:1.4;transition:border-color .15s,box-shadow .15s;display:block;overflow-y:hidden}.sqc-composer__input::placeholder{color:var(--sqc-neutral-400)}.sqc-composer__input:focus{border-color:var(--sqc-text);box-shadow:var(--sqc-focus-input)}.sqc-mentions{z-index:2;border:1px solid var(--sqc-border);background:var(--sqc-bg);max-height:184px;box-shadow:var(--sqc-shadow);scrollbar-width:thin;border-radius:12px;margin:0;padding:4px;list-style:none;position:absolute;bottom:calc(100% + 6px);left:0;right:0;overflow-y:auto}.sqc-mention{cursor:pointer;color:var(--sqc-text);border-radius:8px;align-items:baseline;gap:6px;padding:6px 8px;font-size:12.5px;display:flex}.sqc-mention--active{background:var(--sqc-neutral-100)}.sqc-mention__icon{flex-shrink:0}.sqc-mention__handle{font-weight:600}.sqc-mention__name{text-overflow:ellipsis;white-space:nowrap;color:var(--sqc-text-muted);overflow:hidden}.sqc-composer__count{color:var(--sqc-text-muted);pointer-events:none;font-variant-numeric:tabular-nums;font-size:10px;position:absolute;bottom:4px;right:8px}.sqc-btn{cursor:pointer;border:none;border-radius:12px;flex-shrink:0;place-items:center;width:38px;height:38px;transition:background .15s,opacity .15s;display:grid}.sqc-btn svg{width:17px;height:17px}.sqc-btn--send{background:var(--sqc-accent-color);color:var(--sqc-on-accent)}.sqc-btn--send:hover:not(:disabled){background:var(--sqc-accent-hover)}.sqc-btn--send:disabled{background:var(--sqc-disabled);color:#fff;cursor:not-allowed}.sqc-btn--stop{background:var(--sqc-bg);color:var(--sqc-text);border:1px solid var(--sqc-border)}.sqc-btn--stop:hover{border-color:var(--sqc-border-strong);background:var(--sqc-surface)}.sqc-btn:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-hint{padding:0 16px max(9px, env(safe-area-inset-bottom));color:var(--sqc-text-muted);text-align:center;flex-shrink:0;margin:0;font-size:10.5px;line-height:1.35}.sqc-powered{padding:0 16px max(9px, env(safe-area-inset-bottom));text-align:center;flex-shrink:0;margin:0;font-size:10.5px;line-height:1.35}.sqc-powered a{color:var(--sqc-text-muted);text-decoration:none}.sqc-powered a:hover{text-decoration:underline}@media (max-width:520px){.sqc{--sqc-width:100vw}.sqc-panel{border-left:none}.sqc-launcher{bottom:16px;right:16px}.sqc[data-position=bottom-left] .sqc-launcher{left:16px}.sqc[data-layout=floating] .sqc-panel,.sqc[data-layout=floating][data-position=bottom-left] .sqc-panel{border:none;border-radius:0;max-width:none;height:auto;max-height:none;top:0;bottom:0;left:0;right:0}}@media (prefers-reduced-motion:reduce){.sqc-launcher,.sqc-panel,.sqc-btn,.sqc-suggestion,.sqc-choice,.sqc-confirm__btn,.sqc-icon-btn,.sqc-icon-btn[data-tip]:after,.sqc-rail__item:before,.sqc-rail__item[data-tip]:after,.sqc-rail__item .sqc-avatar{transition:none}.sqc-typing i,.sqc-caret{animation:none}}.sqc-with-human{border:1px solid var(--sqc-border);background:var(--sqc-selected);color:var(--sqc-neutral-600);border-radius:12px;margin:8px 0 0;padding:8px 12px;font-size:13px}", it = "squadico-chatbot", at = [
|
|
1763
|
+
var it = ":host{--sqc-width:min(392px, 100vw);--sqc-height:640px;--sqc-z:2147480000;--sqc-radius:16px;--sqc-font-family:\"Plus Jakarta Sans\", ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif;--sqc-font-heading:var(--sqc-font-family);z-index:var(--sqc-z);pointer-events:none;font-family:var(--sqc-font-family);-webkit-font-smoothing:antialiased;text-align:left;font-size:14px;line-height:1.5;display:block;position:fixed;top:0;bottom:0;left:0;right:0;margin:0!important}:host([hidden]){display:none}.sqc{--sqc-neutral-50:#f8fafc;--sqc-neutral-100:#f1f5f9;--sqc-neutral-200:#e2e8f0;--sqc-neutral-300:#cbd5e1;--sqc-neutral-400:#94a3b8;--sqc-neutral-500:#64748b;--sqc-neutral-600:#475569;--sqc-neutral-900:#0f172a;--sqc-error-50:#fff1f2;--sqc-error-100:#ffe4e6;--sqc-error-600:#e11d48;--sqc-accent-default:#000;--sqc-accent-color:var(--sqc-accent,var(--sqc-accent-default));--sqc-on-accent:#fff;--sqc-accent-hover:color-mix(in oklab, var(--sqc-accent-color) 84%, var(--sqc-on-accent));--sqc-accent-fg:var(--sqc-accent,var(--sqc-text));--sqc-bg:#fff;--sqc-surface:var(--sqc-neutral-50);--sqc-selected:var(--sqc-neutral-100);--sqc-border:var(--sqc-neutral-200);--sqc-border-strong:var(--sqc-neutral-300);--sqc-text:var(--sqc-neutral-900);--sqc-text-muted:var(--sqc-neutral-500);--sqc-link:#2563eb;--sqc-bubble-user:var(--sqc-accent-color);--sqc-bubble-user-text:var(--sqc-on-accent);--sqc-code-bg:var(--sqc-neutral-100);--sqc-disabled:var(--sqc-neutral-300);--sqc-shadow:0 10px 15px -3px #0f172a1a, 0 4px 6px -4px #0f172a1a;--sqc-shadow-bottom:0 6px 8px -6px #0f172a2e;--sqc-focus:0 0 0 2px var(--sqc-bg), 0 0 0 4px #0f172a4d;--sqc-focus-input:0 0 0 3px #0f172a1a;--sqc-danger:var(--sqc-error-600);color:var(--sqc-text);position:absolute;top:0;bottom:0;left:0;right:0}.sqc[data-theme=dark]{--sqc-neutral-50:#172033;--sqc-neutral-100:#1e293b;--sqc-neutral-200:#334155;--sqc-neutral-300:#475569;--sqc-neutral-400:#64748b;--sqc-neutral-500:#94a3b8;--sqc-neutral-600:#cbd5e1;--sqc-neutral-900:#f8fafc;--sqc-error-50:#2a0a12;--sqc-error-100:#4c0519;--sqc-error-600:#fb7185;--sqc-accent-default:#fff;--sqc-on-accent:#0f172a;--sqc-bg:#0f172a;--sqc-link:#60a5fa;--sqc-code-bg:#020617;--sqc-shadow:0 10px 24px -4px #0000008c;--sqc-shadow-bottom:0 6px 8px -6px #0000008c;--sqc-focus:0 0 0 2px var(--sqc-bg), 0 0 0 4px #f8fafc59;--sqc-focus-input:0 0 0 3px #f8fafc1f}@supports (color:oklch(from red l c h)){.sqc{--sqc-on-accent:oklch(from var(--sqc-accent-color) clamp(.208, (.62 - l) * 1000, 1) 0 0)}}.sqc *,.sqc :before,.sqc :after{box-sizing:border-box}.sqc-launcher{background:var(--sqc-accent-color);width:56px;height:56px;color:var(--sqc-on-accent);cursor:pointer;pointer-events:auto;box-shadow:var(--sqc-shadow);border:none;border-radius:50%;place-items:center;padding:0;transition:transform .18s,opacity .18s,background .18s,box-shadow .18s;display:grid;position:absolute;bottom:24px;right:24px}.sqc[data-position=bottom-left] .sqc-launcher{left:24px;right:auto}.sqc-launcher:hover{background:var(--sqc-accent-hover);transform:scale(1.06)}.sqc-launcher:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc[data-open=true] .sqc-launcher{opacity:0;pointer-events:none;transform:scale(.5)}.sqc-launcher__icon svg{width:26px;height:26px;display:block}.sqc-slot-icon::slotted(*){justify-content:center;align-items:center;width:26px;height:26px;display:inline-flex}.sqc-launcher__badge{background:var(--sqc-error-600);border:2px solid var(--sqc-bg);border-radius:50%;width:12px;height:12px;position:absolute;top:6px;right:6px}.sqc-panel{width:var(--sqc-width);background:var(--sqc-bg);border-left:1px solid var(--sqc-border);box-shadow:var(--sqc-shadow);pointer-events:auto;visibility:hidden;flex-direction:column;transition:transform .26s cubic-bezier(.22,1,.36,1),visibility 0s linear .26s;display:flex;position:absolute;top:0;bottom:0;right:0;transform:translate(100%)}.sqc-panel__body{flex:1;min-height:0;display:flex}.sqc-panel__main{flex-direction:column;flex:1;min-width:0;min-height:0;display:flex}.sqc-rail{border-right:1px solid var(--sqc-border);background:color-mix(in oklab, var(--sqc-accent-color) 7%, var(--sqc-bg));flex-direction:column;flex-shrink:0;align-items:stretch;gap:6px;width:72px;padding:12px 0;display:flex;overflow:visible}.sqc-rail__item{color:var(--sqc-text-muted);font:inherit;cursor:pointer;background:0 0;border:0;flex-direction:column;align-items:center;gap:4px;padding:4px 0;display:flex;position:relative}.sqc-rail__label{white-space:nowrap;text-overflow:ellipsis;max-width:64px;font-size:10.5px;font-weight:500;line-height:1.2;overflow:hidden}.sqc-rail__item:hover,.sqc-rail__item[aria-pressed=true]{color:var(--sqc-text)}.sqc-rail__item[aria-pressed=true] .sqc-rail__label{font-weight:600}.sqc-rail__item .sqc-avatar{transition:box-shadow .15s}.sqc-rail__item[aria-pressed=true] .sqc-avatar{box-shadow:0 0 0 2px var(--sqc-bg), 0 0 0 4px var(--sqc-accent-color)}.sqc-rail__item:before{content:\"\";background:var(--sqc-text);border-radius:0 4px 4px 0;width:4px;height:0;transition:height .15s;position:absolute;top:24px;left:0;transform:translateY(-50%)}.sqc-rail__item:hover:before{height:12px}.sqc-rail__item[aria-pressed=true]:before{height:32px}.sqc-rail__item:focus-visible{outline:2px solid var(--sqc-accent-color);outline-offset:-2px;border-radius:8px}.sqc-rail__item:disabled{cursor:not-allowed;opacity:.5}.sqc-rail__item[data-tip]:after{content:attr(data-tip);z-index:2;background:var(--sqc-text);color:var(--sqc-bg);white-space:nowrap;pointer-events:none;opacity:0;border-radius:6px;padding:4px 8px;font-size:12px;font-weight:500;transition:opacity .12s;position:absolute;top:24px;left:calc(100% + 6px);transform:translateY(-50%)}.sqc-rail__item[data-tip]:hover:after{opacity:1}.sqc-rail__item[data-tip]:focus-visible:after{opacity:1}.sqc[data-open=true] .sqc-panel{visibility:visible;transition:transform .26s cubic-bezier(.22,1,.36,1),visibility;transform:translate(0)}.sqc[data-layout=floating] .sqc-panel{max-width:calc(100% - 48px);height:var(--sqc-height);border:1px solid var(--sqc-border);border-radius:var(--sqc-radius);opacity:0;transform-origin:100% 100%;max-height:calc(100% - 48px);transition:transform .22s cubic-bezier(.22,1,.36,1),opacity .22s,visibility 0s linear .22s;top:auto;bottom:24px;right:24px;overflow:hidden;transform:translateY(16px)scale(.96)}.sqc[data-layout=floating][data-position=bottom-left] .sqc-panel{transform-origin:0 100%;left:24px;right:auto}.sqc[data-layout=floating][data-open=true] .sqc-panel{opacity:1;transition:transform .22s cubic-bezier(.22,1,.36,1),opacity .22s,visibility;transform:none}.sqc-header{background:var(--sqc-bg);color:var(--sqc-text);border-bottom:1px solid var(--sqc-border);flex-shrink:0;align-items:center;gap:8px;padding:13px 12px 13px 16px;display:flex}.sqc-header__icon{color:var(--sqc-accent-fg);flex-shrink:0;place-items:center;display:grid}.sqc-header__icon svg{width:17px;height:17px;display:block}.sqc-header__titles{flex:1;min-width:0}.sqc-header__heading,.sqc-header__sub{text-overflow:ellipsis;white-space:nowrap;margin:0;overflow:hidden}.sqc-header__heading{font-family:var(--sqc-font-heading);letter-spacing:-.2px;font-size:15px;font-weight:700}.sqc-header__sub{color:var(--sqc-text-muted);font-size:12px}.sqc-icon-btn{width:26px;height:26px;color:var(--sqc-text-muted);cursor:pointer;background:0 0;border:none;border-radius:8px;flex-shrink:0;place-items:center;transition:background .15s;display:grid}.sqc-icon-btn:hover{background:var(--sqc-surface);color:var(--sqc-text)}.sqc-icon-btn:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-icon-btn svg{width:16px;height:16px}.sqc-icon-btn[data-tip]{position:relative}.sqc-icon-btn[data-tip]:after{content:attr(data-tip);z-index:6;background:var(--sqc-text);color:var(--sqc-bg);font-family:var(--sqc-font-family);white-space:nowrap;pointer-events:none;opacity:0;border-radius:8px;padding:4px 8px;font-size:11px;font-weight:500;line-height:1.3;transition:opacity .12s .15s;position:absolute;top:calc(100% + 6px);right:0}.sqc-icon-btn[data-tip]:hover:after{opacity:1}.sqc-icon-btn[data-tip]:focus-visible:after{opacity:1}.sqc-history-pop{z-index:5;position:absolute;top:54px;left:0;right:0}.sqc-history{background:var(--sqc-bg);max-height:320px;box-shadow:var(--sqc-shadow-bottom);flex-direction:column;display:flex;overflow-y:auto}.sqc-history__empty{color:var(--sqc-text-muted);text-align:center;margin:0;padding:14px 16px;font-size:12px}.sqc-history__item{border:none;border-bottom:1px solid var(--sqc-border);width:100%;color:var(--sqc-text);text-align:left;cursor:pointer;background:0 0;flex-direction:column;gap:2px;padding:10px 16px;transition:background .15s;display:flex}.sqc-history__item:last-child{border-bottom:none}.sqc-history__item:hover{background:var(--sqc-surface)}.sqc-history__item:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-history__item[aria-current=true]{background:var(--sqc-selected)}.sqc-history__item[aria-current=true] .sqc-history__title{color:var(--sqc-text);font-weight:600}.sqc-history__title{text-overflow:ellipsis;white-space:nowrap;font-size:13px;overflow:hidden}.sqc-history__date{color:var(--sqc-text-muted);font-size:11px}.sqc-context{background:var(--sqc-selected);border:1px solid var(--sqc-border);color:var(--sqc-text);border-radius:12px;flex-wrap:wrap;flex-shrink:0;align-items:center;gap:8px;margin:12px 16px 4px;padding:8px 11px;font-size:12px;display:flex}.sqc-chip{text-overflow:ellipsis;white-space:nowrap;align-items:baseline;gap:4px;max-width:100%;display:inline-flex;overflow:hidden}.sqc-chip b{font-weight:600}.sqc-chip:not(:last-child):after{content:\"·\";opacity:.5;margin-left:4px}.sqc-messages{overscroll-behavior:contain;background:var(--sqc-bg);scrollbar-width:thin;scrollbar-color:var(--sqc-neutral-300) transparent;flex-direction:column;flex:1;gap:13px;min-height:0;padding:12px 16px;display:flex;overflow-y:auto}.sqc-messages::-webkit-scrollbar{width:6px}.sqc-messages::-webkit-scrollbar-thumb{background:var(--sqc-neutral-300);border-radius:99px}.sqc-msg{flex-direction:column;max-width:93%;font-size:13.5px;display:flex}.sqc-msg--assistant{align-self:stretch}.sqc-msg--user{align-self:flex-end}.sqc-msg__who{color:var(--sqc-text-muted);align-items:center;gap:6px;margin-bottom:4px;font-size:11px;font-weight:500;display:flex}.sqc-msg__who svg{width:12px;height:12px;color:var(--sqc-accent-fg);flex-shrink:0}.sqc-avatar{background:var(--sqc-accent-color);color:var(--sqc-on-accent);-webkit-user-select:none;user-select:none;flex-shrink:0;justify-content:center;align-items:center;font-weight:600;line-height:1;display:inline-flex;overflow:hidden}.sqc-avatar img{object-fit:cover;width:100%;height:100%}.sqc-msg__unaddressed{color:var(--sqc-text-muted);margin:8px 0 0;font-size:11.5px;line-height:1.5}.sqc-msg__unaddressed code{background:var(--sqc-code-bg);color:var(--sqc-text);border-radius:4px;margin-right:4px;padding:1px 4px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:11px}.sqc-msg--user .sqc-msg__bubble{background:var(--sqc-bubble-user);color:var(--sqc-bubble-user-text);border-radius:var(--sqc-radius) var(--sqc-radius) 4px var(--sqc-radius);padding:9px 13px}.sqc-msg--error .sqc-msg__bubble{background:var(--sqc-error-50);color:var(--sqc-error-600);border:1px solid var(--sqc-error-100);border-radius:12px;padding:11px}.sqc-msg__body{overflow-wrap:anywhere}.sqc-msg--assistant .sqc-msg__body{font-size:14px;line-height:1.6}.sqc-msg__body>:first-child{margin-top:0}.sqc-msg__body>:last-child{margin-bottom:0}.sqc-msg__body p{white-space:pre-wrap;margin:0 0 8px}.sqc-msg__body ul,.sqc-msg__body ol{margin:0 0 8px;padding-left:20px}.sqc-msg__body li{margin-bottom:3px}.sqc-msg__body code{background:var(--sqc-code-bg);border-radius:4px;padding:1px 4px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:.85em}.sqc-msg--user .sqc-msg__body code{background:#ffffff38}.sqc-msg__body pre{background:var(--sqc-code-bg);border-radius:8px;margin:0 0 8px;padding:9px 11px;overflow-x:auto}.sqc-msg__body pre code{background:0 0;padding:0}.sqc-msg__body a{color:inherit;text-underline-offset:2px;text-decoration:underline}.sqc-msg--assistant .sqc-msg__body a{color:var(--sqc-link);text-decoration:none}.sqc-msg--assistant .sqc-msg__body a:hover{text-decoration:underline}.sqc-msg__body h3,.sqc-msg__body h4,.sqc-msg__body h5,.sqc-msg__body h6{font-family:var(--sqc-font-heading);letter-spacing:-.2px;margin:12px 0 6px;font-weight:700;line-height:1.3}.sqc-msg__body h3{font-size:1.05em}.sqc-msg__body h4{font-size:1em}.sqc-msg__body h5,.sqc-msg__body h6{font-size:.94em}.sqc-msg__body ul ul,.sqc-msg__body ul ol,.sqc-msg__body ol ul,.sqc-msg__body ol ol{margin:3px 0 0}.sqc-msg__body blockquote{border-left:2px solid var(--sqc-border-strong);color:var(--sqc-text-muted);white-space:pre-wrap;margin:0 0 8px;padding:2px 0 2px 10px}.sqc-msg--user .sqc-msg__body blockquote{color:inherit;opacity:.85;border-left-color:#ffffff73}.sqc-msg__body hr{border:0;border-top:1px solid var(--sqc-border);margin:10px 0}.sqc-msg--user .sqc-msg__body hr{border-top-color:#ffffff4d}.sqc-msg__body del{opacity:.7}.sqc-selection{flex-direction:column;gap:10px;margin:2px 0;display:flex}.sqc-selection__question{flex-direction:column;gap:2px;display:flex}.sqc-selection__ask{font-family:var(--sqc-font-family);color:var(--sqc-text);margin:0;font-size:13px;font-weight:600}.sqc-selection__actions{display:flex}.sqc-selection__validate{height:32px;font-family:var(--sqc-font-family);color:var(--sqc-on-accent);background:var(--sqc-accent-color);cursor:pointer;border:1px solid #0000;border-radius:12px;flex:auto;justify-content:center;align-items:center;padding:0 12px;font-size:13px;font-weight:600;transition:filter .12s,background .12s;display:inline-flex}.sqc-selection__validate:hover:not(:disabled){background:var(--sqc-accent-hover)}.sqc-selection__validate:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-selection__validate:disabled{cursor:not-allowed;color:#fff;background:var(--sqc-disabled)}.sqc-selection__hint{font-family:var(--sqc-font-family);color:var(--sqc-text-muted);margin:0;font-size:11.5px}.sqc-msg__time{color:var(--sqc-text-muted);font-variant-numeric:tabular-nums;margin-top:3px;font-size:10px;display:block}.sqc-msg--user .sqc-msg__time{color:#ffffffb3;text-align:right}.sqc-caret{vertical-align:text-bottom;background:currentColor;width:2px;height:1em;margin-left:2px;animation:1s step-end infinite sqc-blink;display:inline-block}@keyframes sqc-blink{0%,to{opacity:1}50%{opacity:0}}.sqc-typing{gap:3px;padding:2px 0;display:inline-flex}.sqc-typing i{background:var(--sqc-neutral-400);border-radius:50%;width:5px;height:5px;animation:1.2s infinite sqc-pulse}.sqc-typing i:nth-child(2){animation-delay:.2s}.sqc-typing i:nth-child(3){animation-delay:.4s}.sqc-waiting{align-items:center;gap:8px;display:inline-flex}.sqc-activity{color:var(--sqc-text-muted);font-size:12px}@keyframes sqc-pulse{0%,60%,to{opacity:.25}30%{opacity:1}}.sqc-suggestions{flex-direction:column;gap:7px;display:flex}.sqc-suggestion{border:1px solid var(--sqc-border);background:var(--sqc-bg);width:100%;color:var(--sqc-text);font-family:var(--sqc-font-family);cursor:pointer;text-align:left;border-radius:12px;align-items:center;gap:8px;padding:8px 11px;font-size:12.5px;transition:background .15s,border-color .15s;display:flex}.sqc-suggestion:before{content:\"\";background:var(--sqc-accent-fg);border-radius:50%;flex:none;width:5px;height:5px}.sqc-suggestion:hover{background:var(--sqc-surface);border-color:var(--sqc-border-strong)}.sqc-suggestion:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-composer{border-top:1px solid var(--sqc-border);background:var(--sqc-bg);flex-wrap:wrap;flex-shrink:0;align-items:flex-end;gap:8px;padding:12px 14px;display:flex}.sqc-composer--dropping{outline:2px dashed var(--sqc-accent-color);outline-offset:-4px}.sqc-attachments{flex-wrap:wrap;flex-basis:100%;gap:6px;display:flex}.sqc-attachments--sent{margin-top:8px}.sqc-chip{border:1px solid var(--sqc-border);background:var(--sqc-selected);max-width:100%;color:var(--sqc-text);border-radius:999px;align-items:center;gap:4px;padding:3px 4px 3px 10px;font-size:12px;display:inline-flex}.sqc-chip--waiting{opacity:.6;padding-right:10px}.sqc-chip__name{text-overflow:ellipsis;white-space:nowrap;max-width:180px;overflow:hidden}.sqc-chip__remove{width:18px;height:18px;color:var(--sqc-text-muted);cursor:pointer;background:0 0;border:0;border-radius:999px;justify-content:center;align-items:center;padding:0;font-size:14px;line-height:1;display:inline-flex}.sqc-chip__remove:hover{background:var(--sqc-selected);color:var(--sqc-text)}.sqc-attachments__error{color:var(--sqc-error-600);flex-basis:100%;margin:0;font-size:12px}.sqc-attachment__image{border-radius:12px;max-width:100%;max-height:180px;display:block}.sqc-attachment__chart{flex-basis:100%;min-width:0}.sqc-file-input{display:none}.sqc-btn--attach{color:var(--sqc-text-muted);background:0 0}.sqc-btn--attach:hover{background:var(--sqc-selected);color:var(--sqc-text)}.sqc-composer__field{flex:1;min-width:0;position:relative}.sqc-composer__input{border:1px solid var(--sqc-border-strong);background:var(--sqc-bg);width:100%;min-height:38px;max-height:132px;color:var(--sqc-text);font-family:var(--sqc-font-family);resize:none;border-radius:12px;outline:none;padding:9px 12px;font-size:13.5px;line-height:1.4;transition:border-color .15s,box-shadow .15s;display:block;overflow-y:hidden}.sqc-composer__input::placeholder{color:var(--sqc-neutral-400)}.sqc-composer__input:focus{border-color:var(--sqc-text);box-shadow:var(--sqc-focus-input)}.sqc-mentions{z-index:2;border:1px solid var(--sqc-border);background:var(--sqc-bg);max-height:184px;box-shadow:var(--sqc-shadow);scrollbar-width:thin;border-radius:12px;margin:0;padding:4px;list-style:none;position:absolute;bottom:calc(100% + 6px);left:0;right:0;overflow-y:auto}.sqc-mention{cursor:pointer;color:var(--sqc-text);border-radius:8px;align-items:baseline;gap:6px;padding:6px 8px;font-size:12.5px;display:flex}.sqc-mention--active{background:var(--sqc-neutral-100)}.sqc-mention__icon{flex-shrink:0}.sqc-mention__handle{font-weight:600}.sqc-mention__name{text-overflow:ellipsis;white-space:nowrap;color:var(--sqc-text-muted);overflow:hidden}.sqc-composer__count{color:var(--sqc-text-muted);pointer-events:none;font-variant-numeric:tabular-nums;font-size:10px;position:absolute;bottom:4px;right:8px}.sqc-btn{cursor:pointer;border:none;border-radius:12px;flex-shrink:0;place-items:center;width:38px;height:38px;transition:background .15s,opacity .15s;display:grid}.sqc-btn svg{width:17px;height:17px}.sqc-btn--send{background:var(--sqc-accent-color);color:var(--sqc-on-accent)}.sqc-btn--send:hover:not(:disabled){background:var(--sqc-accent-hover)}.sqc-btn--send:disabled{background:var(--sqc-disabled);color:#fff;cursor:not-allowed}.sqc-btn--stop{background:var(--sqc-bg);color:var(--sqc-text);border:1px solid var(--sqc-border)}.sqc-btn--stop:hover{border-color:var(--sqc-border-strong);background:var(--sqc-surface)}.sqc-btn:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-hint{padding:0 16px max(9px, env(safe-area-inset-bottom));color:var(--sqc-text-muted);text-align:center;flex-shrink:0;margin:0;font-size:10.5px;line-height:1.35}.sqc-powered{padding:0 16px max(9px, env(safe-area-inset-bottom));text-align:center;flex-shrink:0;margin:0;font-size:10.5px;line-height:1.35}.sqc-powered a{color:var(--sqc-text-muted);text-decoration:none}.sqc-powered a:hover{text-decoration:underline}@media (max-width:520px){.sqc{--sqc-width:100vw}.sqc-panel{border-left:none}.sqc-launcher{bottom:16px;right:16px}.sqc[data-position=bottom-left] .sqc-launcher{left:16px}.sqc[data-layout=floating] .sqc-panel,.sqc[data-layout=floating][data-position=bottom-left] .sqc-panel{border:none;border-radius:0;max-width:none;height:auto;max-height:none;top:0;bottom:0;left:0;right:0}}@media (prefers-reduced-motion:reduce){.sqc-launcher,.sqc-panel,.sqc-btn,.sqc-suggestion,.sqc-choice,.sqc-confirm__btn,.sqc-icon-btn,.sqc-icon-btn[data-tip]:after,.sqc-rail__item:before,.sqc-rail__item[data-tip]:after,.sqc-rail__item .sqc-avatar{transition:none}.sqc-typing i,.sqc-caret{animation:none}}.sqc-with-human{border:1px solid var(--sqc-border);background:var(--sqc-selected);color:var(--sqc-neutral-600);border-radius:12px;margin:8px 0 0;padding:8px 12px;font-size:13px}", at = "squadico-chatbot", ot = [
|
|
1751
1764
|
"embed-key",
|
|
1752
1765
|
"context",
|
|
1753
1766
|
"user",
|
|
@@ -1767,21 +1780,21 @@ var rt = ":host{--sqc-width:min(392px, 100vw);--sqc-height:640px;--sqc-z:2147480
|
|
|
1767
1780
|
"persist-open",
|
|
1768
1781
|
"show-context",
|
|
1769
1782
|
"locale"
|
|
1770
|
-
],
|
|
1771
|
-
function
|
|
1772
|
-
if (
|
|
1783
|
+
], st;
|
|
1784
|
+
function ct() {
|
|
1785
|
+
if (st !== void 0) return st;
|
|
1773
1786
|
try {
|
|
1774
1787
|
let e = new CSSStyleSheet();
|
|
1775
|
-
e.replaceSync(
|
|
1788
|
+
e.replaceSync(it), st = e;
|
|
1776
1789
|
} catch {
|
|
1777
|
-
|
|
1790
|
+
st = null;
|
|
1778
1791
|
}
|
|
1779
|
-
return
|
|
1792
|
+
return st;
|
|
1780
1793
|
}
|
|
1781
|
-
function
|
|
1782
|
-
typeof console < "u" && console.warn(`[${
|
|
1794
|
+
function lt(e, t) {
|
|
1795
|
+
typeof console < "u" && console.warn(`[${at}] ${e}`, t ?? "");
|
|
1783
1796
|
}
|
|
1784
|
-
function
|
|
1797
|
+
function ut(e) {
|
|
1785
1798
|
if (!(!e || !e.trim())) try {
|
|
1786
1799
|
let t = JSON.parse(e);
|
|
1787
1800
|
if (t && typeof t == "object" && !Array.isArray(t)) {
|
|
@@ -1792,80 +1805,81 @@ function lt(e) {
|
|
|
1792
1805
|
digest: typeof e.digest == "string" && e.digest ? e.digest : void 0
|
|
1793
1806
|
};
|
|
1794
1807
|
}
|
|
1795
|
-
|
|
1808
|
+
lt("the \"user\" attribute needs an object with an id", e);
|
|
1796
1809
|
} catch (e) {
|
|
1797
|
-
|
|
1810
|
+
lt("the \"user\" attribute is not valid JSON", e);
|
|
1798
1811
|
}
|
|
1799
1812
|
}
|
|
1800
|
-
function
|
|
1813
|
+
function dt(e) {
|
|
1801
1814
|
if (!(!e || !e.trim())) try {
|
|
1802
1815
|
let t = JSON.parse(e);
|
|
1803
1816
|
if (t && typeof t == "object" && !Array.isArray(t)) return t;
|
|
1804
|
-
|
|
1817
|
+
lt("the `context` attribute must be a JSON object", e);
|
|
1805
1818
|
} catch (e) {
|
|
1806
|
-
|
|
1819
|
+
lt("the `context` attribute is not valid JSON", e);
|
|
1807
1820
|
}
|
|
1808
1821
|
}
|
|
1809
|
-
function
|
|
1822
|
+
function ft(e) {
|
|
1810
1823
|
if (!(!e || !e.trim())) {
|
|
1811
1824
|
if (e.trim().startsWith("[")) try {
|
|
1812
1825
|
let t = JSON.parse(e);
|
|
1813
1826
|
if (Array.isArray(t)) return t.map(String);
|
|
1814
1827
|
} catch (e) {
|
|
1815
|
-
|
|
1828
|
+
lt("the `suggestions` attribute is not valid JSON", e);
|
|
1816
1829
|
return;
|
|
1817
1830
|
}
|
|
1818
1831
|
return e.split("|").map((e) => e.trim()).filter(Boolean);
|
|
1819
1832
|
}
|
|
1820
1833
|
}
|
|
1821
|
-
function
|
|
1834
|
+
function pt(e) {
|
|
1822
1835
|
if (e !== null) return e !== "false" && e !== "0";
|
|
1823
1836
|
}
|
|
1824
|
-
function
|
|
1837
|
+
function mt(e) {
|
|
1825
1838
|
return e === "dark" || e === "light" || e === "auto" ? e : void 0;
|
|
1826
1839
|
}
|
|
1827
|
-
function
|
|
1840
|
+
function ht(e) {
|
|
1828
1841
|
return e === "bottom-left" || e === "bottom-right" ? e : void 0;
|
|
1829
1842
|
}
|
|
1830
|
-
function
|
|
1843
|
+
function gt(e) {
|
|
1831
1844
|
return e === "floating" || e === "sidebar" ? e : void 0;
|
|
1832
1845
|
}
|
|
1833
|
-
var
|
|
1846
|
+
var _t = [
|
|
1834
1847
|
"context",
|
|
1835
1848
|
"embedKey",
|
|
1836
1849
|
"user",
|
|
1850
|
+
"scope",
|
|
1837
1851
|
"getSubjectToken",
|
|
1838
1852
|
"agent"
|
|
1839
1853
|
];
|
|
1840
|
-
function
|
|
1841
|
-
var e, t, r, i, a, o, d, p, h, g, _, v, y, b;
|
|
1842
|
-
return t = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new WeakMap(), o = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new WeakMap(), p = /* @__PURE__ */ new WeakMap(), h = /* @__PURE__ */ new WeakMap(), g = /* @__PURE__ */ new WeakMap(), _ = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new
|
|
1854
|
+
function vt() {
|
|
1855
|
+
var e, t, r, i, a, o, d, p, h, g, _, v, y, b, x;
|
|
1856
|
+
return t = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new WeakMap(), o = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new WeakMap(), p = /* @__PURE__ */ new WeakMap(), h = /* @__PURE__ */ new WeakMap(), g = /* @__PURE__ */ new WeakMap(), _ = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new WeakMap(), y = /* @__PURE__ */ new WeakSet(), b = /* @__PURE__ */ new WeakMap(), x = /* @__PURE__ */ new WeakMap(), e = class extends HTMLElement {
|
|
1843
1857
|
constructor() {
|
|
1844
|
-
super(), u(this,
|
|
1858
|
+
super(), u(this, y), f(this, t, void 0), f(this, r, null), f(this, i, !1), f(this, a, !1), f(this, o, ""), f(this, d, void 0), f(this, p, void 0), f(this, h, void 0), f(this, g, void 0), f(this, _, void 0), f(this, v, void 0), f(this, b, (e) => {
|
|
1845
1859
|
let { type: t, ...n } = e;
|
|
1846
1860
|
s(o, this, n.sessionId), this.dispatchEvent(new CustomEvent(t, {
|
|
1847
1861
|
detail: n,
|
|
1848
1862
|
bubbles: !0,
|
|
1849
1863
|
composed: !0
|
|
1850
1864
|
}));
|
|
1851
|
-
}), f(this,
|
|
1865
|
+
}), f(this, x, (e) => {
|
|
1852
1866
|
s(r, this, e), e && s(o, this, e.sessionId());
|
|
1853
1867
|
});
|
|
1854
|
-
let e = this.attachShadow({ mode: "open" }), n =
|
|
1868
|
+
let e = this.attachShadow({ mode: "open" }), n = ct();
|
|
1855
1869
|
if (n) e.adoptedStyleSheets = [n];
|
|
1856
1870
|
else {
|
|
1857
1871
|
let t = document.createElement("style");
|
|
1858
|
-
t.textContent =
|
|
1872
|
+
t.textContent = it, e.append(t);
|
|
1859
1873
|
}
|
|
1860
1874
|
s(t, this, document.createElement("div")), e.append(c(t, this));
|
|
1861
|
-
for (let e of
|
|
1875
|
+
for (let e of _t) {
|
|
1862
1876
|
if (!Object.hasOwn(this, e)) continue;
|
|
1863
1877
|
let t = this[e];
|
|
1864
1878
|
delete this[e], this[e] = t;
|
|
1865
1879
|
}
|
|
1866
1880
|
}
|
|
1867
1881
|
connectedCallback() {
|
|
1868
|
-
s(a, this, !0), m(
|
|
1882
|
+
s(a, this, !0), m(y, this, C).call(this);
|
|
1869
1883
|
}
|
|
1870
1884
|
disconnectedCallback() {
|
|
1871
1885
|
s(a, this, !1), n(null, c(t, this)), s(r, this, null);
|
|
@@ -1873,44 +1887,50 @@ function _t() {
|
|
|
1873
1887
|
attributeChangedCallback(e, t, n) {
|
|
1874
1888
|
if (t !== n) {
|
|
1875
1889
|
if (e === "open" && c(r, this)) {
|
|
1876
|
-
|
|
1890
|
+
pt(n) ? c(r, this).open() : c(r, this).close();
|
|
1877
1891
|
return;
|
|
1878
1892
|
}
|
|
1879
|
-
m(
|
|
1893
|
+
m(y, this, S).call(this);
|
|
1880
1894
|
}
|
|
1881
1895
|
}
|
|
1882
1896
|
get context() {
|
|
1883
|
-
return c(d, this) ??
|
|
1897
|
+
return c(d, this) ?? dt(this.getAttribute("context"));
|
|
1884
1898
|
}
|
|
1885
1899
|
set context(e) {
|
|
1886
|
-
s(d, this, e), m(
|
|
1900
|
+
s(d, this, e), m(y, this, S).call(this);
|
|
1887
1901
|
}
|
|
1888
1902
|
get embedKey() {
|
|
1889
|
-
return c(
|
|
1903
|
+
return c(v, this) ?? this.getAttribute("embed-key") ?? void 0;
|
|
1890
1904
|
}
|
|
1891
1905
|
set embedKey(e) {
|
|
1892
|
-
s(
|
|
1906
|
+
s(v, this, e), m(y, this, S).call(this);
|
|
1907
|
+
}
|
|
1908
|
+
get scope() {
|
|
1909
|
+
return c(h, this);
|
|
1910
|
+
}
|
|
1911
|
+
set scope(e) {
|
|
1912
|
+
s(h, this, e), m(y, this, S).call(this);
|
|
1893
1913
|
}
|
|
1894
1914
|
get user() {
|
|
1895
|
-
return c(p, this) ??
|
|
1915
|
+
return c(p, this) ?? ut(this.getAttribute("user"));
|
|
1896
1916
|
}
|
|
1897
1917
|
set user(e) {
|
|
1898
|
-
s(p, this, e), m(
|
|
1918
|
+
s(p, this, e), m(y, this, S).call(this);
|
|
1899
1919
|
}
|
|
1900
1920
|
get getSubjectToken() {
|
|
1901
|
-
return c(
|
|
1921
|
+
return c(g, this);
|
|
1902
1922
|
}
|
|
1903
1923
|
set getSubjectToken(e) {
|
|
1904
|
-
s(
|
|
1924
|
+
s(g, this, e), m(y, this, S).call(this);
|
|
1905
1925
|
}
|
|
1906
1926
|
get agent() {
|
|
1907
|
-
return c(
|
|
1927
|
+
return c(_, this) ?? this.getAttribute("agent") ?? void 0;
|
|
1908
1928
|
}
|
|
1909
1929
|
set agent(e) {
|
|
1910
|
-
s(
|
|
1930
|
+
s(_, this, e), m(y, this, S).call(this);
|
|
1911
1931
|
}
|
|
1912
1932
|
get open() {
|
|
1913
|
-
return c(r, this)?.isOpen() ??
|
|
1933
|
+
return c(r, this)?.isOpen() ?? pt(this.getAttribute("open")) ?? !1;
|
|
1914
1934
|
}
|
|
1915
1935
|
set open(e) {
|
|
1916
1936
|
e ? this.openChat() : this.closeChat();
|
|
@@ -1932,23 +1952,24 @@ function _t() {
|
|
|
1932
1952
|
}
|
|
1933
1953
|
sendMessage(e) {
|
|
1934
1954
|
if (!c(r, this)) {
|
|
1935
|
-
|
|
1955
|
+
lt("sendMessage() called before the component was mounted — ignored");
|
|
1936
1956
|
return;
|
|
1937
1957
|
}
|
|
1938
1958
|
c(r, this).send(e);
|
|
1939
1959
|
}
|
|
1940
|
-
},
|
|
1941
|
-
function
|
|
1960
|
+
}, F(e, "observedAttributes", ot), e;
|
|
1961
|
+
function S() {
|
|
1942
1962
|
c(i, this) || !c(a, this) || (s(i, this, !0), queueMicrotask(() => {
|
|
1943
|
-
s(i, this, !1), c(a, this) && m(
|
|
1963
|
+
s(i, this, !1), c(a, this) && m(y, this, C).call(this);
|
|
1944
1964
|
}));
|
|
1945
1965
|
}
|
|
1946
|
-
function
|
|
1966
|
+
function C() {
|
|
1947
1967
|
let e = (e) => this.getAttribute(e) ?? void 0;
|
|
1948
|
-
n(/* @__PURE__ */ l(
|
|
1968
|
+
n(/* @__PURE__ */ l(rt, {
|
|
1949
1969
|
embedKey: this.embedKey,
|
|
1950
1970
|
context: this.context,
|
|
1951
1971
|
user: this.user,
|
|
1972
|
+
scope: this.scope,
|
|
1952
1973
|
getSubjectToken: this.getSubjectToken,
|
|
1953
1974
|
agent: this.agent,
|
|
1954
1975
|
heading: e("heading"),
|
|
@@ -1956,29 +1977,29 @@ function _t() {
|
|
|
1956
1977
|
assistantName: e("assistant-name"),
|
|
1957
1978
|
placeholder: e("placeholder"),
|
|
1958
1979
|
greeting: e("greeting"),
|
|
1959
|
-
suggestions:
|
|
1980
|
+
suggestions: ft(this.getAttribute("suggestions")),
|
|
1960
1981
|
width: e("width"),
|
|
1961
1982
|
accent: e("accent"),
|
|
1962
|
-
theme:
|
|
1963
|
-
position:
|
|
1964
|
-
layout:
|
|
1965
|
-
defaultOpen:
|
|
1966
|
-
persistOpen:
|
|
1967
|
-
showContext:
|
|
1983
|
+
theme: mt(this.getAttribute("theme")),
|
|
1984
|
+
position: ht(this.getAttribute("position")),
|
|
1985
|
+
layout: gt(this.getAttribute("layout")),
|
|
1986
|
+
defaultOpen: pt(this.getAttribute("open")) ?? !1,
|
|
1987
|
+
persistOpen: pt(this.getAttribute("persist-open")) ?? !0,
|
|
1988
|
+
showContext: pt(this.getAttribute("show-context")) ?? !0,
|
|
1968
1989
|
locale: e("locale"),
|
|
1969
|
-
onEvent: c(
|
|
1970
|
-
bind: c(
|
|
1990
|
+
onEvent: c(b, this),
|
|
1991
|
+
bind: c(x, this)
|
|
1971
1992
|
}), c(t, this));
|
|
1972
1993
|
}
|
|
1973
1994
|
}
|
|
1974
|
-
var
|
|
1975
|
-
function
|
|
1976
|
-
typeof window > "u" || typeof HTMLElement > "u" || (
|
|
1995
|
+
var yt;
|
|
1996
|
+
function bt(e = at) {
|
|
1997
|
+
typeof window > "u" || typeof HTMLElement > "u" || (yt ?? (yt = vt()), window.customElements.get(e) || window.customElements.define(e, yt));
|
|
1977
1998
|
}
|
|
1978
1999
|
//#endregion
|
|
1979
2000
|
//#region src/index.ts
|
|
1980
|
-
|
|
2001
|
+
bt();
|
|
1981
2002
|
//#endregion
|
|
1982
|
-
export {
|
|
2003
|
+
export { L as a, R as i, bt as n, k as o, I as r, at as t };
|
|
1983
2004
|
|
|
1984
|
-
//# sourceMappingURL=src-
|
|
2005
|
+
//# sourceMappingURL=src-BWDC0W4O.js.map
|