@aiden-voice/widget 0.7.2 → 0.8.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 +103 -11
- package/dist/components/Composer.d.ts +3 -1
- package/dist/components/Launcher.d.ts +3 -1
- package/dist/components/MessageFeedback.d.ts +3 -1
- package/dist/components/MessageList.d.ts +3 -1
- package/dist/config.d.ts +3 -0
- package/dist/controller.d.ts +14 -0
- package/dist/i18n/index.d.ts +26 -0
- package/dist/i18n/locales/ar.d.ts +2 -0
- package/dist/i18n/locales/de.d.ts +2 -0
- package/dist/i18n/locales/es.d.ts +2 -0
- package/dist/i18n/locales/fr.d.ts +2 -0
- package/dist/i18n/locales/hi.d.ts +2 -0
- package/dist/i18n/locales/it.d.ts +2 -0
- package/dist/i18n/locales/ja.d.ts +2 -0
- package/dist/i18n/locales/pt.d.ts +2 -0
- package/dist/i18n/locales/ru.d.ts +2 -0
- package/dist/i18n/locales/zh.d.ts +2 -0
- package/dist/i18n/messages.d.ts +30 -0
- package/dist/index.d.ts +2 -0
- package/dist/sessionToken.d.ts +2 -0
- package/dist/types.d.ts +22 -0
- package/dist/version.d.ts +1 -1
- package/dist/viewport.d.ts +5 -0
- package/dist/widget.iife.js +7 -7
- package/dist/widget.js +1117 -572
- package/package.json +1 -1
package/dist/widget.js
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
|
+
//#region src/i18n/messages.ts
|
|
2
|
+
var e = {
|
|
3
|
+
openChat: "Open chat",
|
|
4
|
+
closeChat: "Close chat",
|
|
5
|
+
chatWith: "Chat with {name}",
|
|
6
|
+
newConversation: "New conversation",
|
|
7
|
+
conversation: "Conversation",
|
|
8
|
+
you: "You",
|
|
9
|
+
message: "Message",
|
|
10
|
+
send: "Send",
|
|
11
|
+
lookingItUp: "Looking that up for you…",
|
|
12
|
+
goodResponse: "Good response",
|
|
13
|
+
badResponse: "Bad response",
|
|
14
|
+
additionalFeedback: "Additional feedback",
|
|
15
|
+
feedbackPlaceholder: "What was wrong? (optional)",
|
|
16
|
+
feedbackCategory: "Feedback category",
|
|
17
|
+
selectReason: "Select a reason (optional)",
|
|
18
|
+
categoryFactual: "Factual error",
|
|
19
|
+
categoryIncomplete: "Incomplete",
|
|
20
|
+
categoryTone: "Off tone",
|
|
21
|
+
categoryOther: "Other",
|
|
22
|
+
submit: "Submit",
|
|
23
|
+
cancel: "Cancel",
|
|
24
|
+
feedbackThanks: "Thanks for the feedback",
|
|
25
|
+
feedbackFailed: "Couldn't send feedback",
|
|
26
|
+
conversationCleared: "Conversation cleared",
|
|
27
|
+
genericError: "Something went wrong, please try again.",
|
|
28
|
+
sessionExpired: "This chat session has expired. Reload the page to continue."
|
|
29
|
+
}, t = Object.keys(e);
|
|
30
|
+
//#endregion
|
|
1
31
|
//#region src/imageUrl.ts
|
|
2
|
-
function
|
|
32
|
+
function n(e, t) {
|
|
3
33
|
if (e != null && e !== "") {
|
|
4
34
|
if (typeof e == "string") try {
|
|
5
35
|
let t = new URL(e);
|
|
@@ -10,7 +40,7 @@ function e(e, t) {
|
|
|
10
40
|
}
|
|
11
41
|
//#endregion
|
|
12
42
|
//#region src/themeRoles.ts
|
|
13
|
-
var
|
|
43
|
+
var r = [
|
|
14
44
|
"primary",
|
|
15
45
|
"onPrimary",
|
|
16
46
|
"primaryText",
|
|
@@ -27,7 +57,7 @@ var t = [
|
|
|
27
57
|
"errorText",
|
|
28
58
|
"inputBorder",
|
|
29
59
|
"focusRing"
|
|
30
|
-
],
|
|
60
|
+
], i = {
|
|
31
61
|
primary: "#4f46e5",
|
|
32
62
|
onPrimary: "#ffffff",
|
|
33
63
|
primaryText: "#4f46e5",
|
|
@@ -44,7 +74,7 @@ var t = [
|
|
|
44
74
|
errorText: "#991b1b",
|
|
45
75
|
inputBorder: "#6b7280",
|
|
46
76
|
focusRing: "#111827"
|
|
47
|
-
},
|
|
77
|
+
}, a = {
|
|
48
78
|
primary: "--whoo-widget-color",
|
|
49
79
|
onPrimary: "--whoo-widget-text-on-color",
|
|
50
80
|
primaryText: "--whoo-widget-color-text",
|
|
@@ -61,22 +91,36 @@ var t = [
|
|
|
61
91
|
errorText: "--whoo-widget-error-text",
|
|
62
92
|
inputBorder: "--whoo-widget-input-border",
|
|
63
93
|
focusRing: "--whoo-widget-focus-ring"
|
|
64
|
-
},
|
|
65
|
-
function o(e) {
|
|
66
|
-
return e === void 0 ? i : Number.isInteger(e) && Math.abs(e) <= a ? e : (console.warn(`whoo-aiden-widget: ignoring zIndex ${String(e)} (expected an integer between -${a} and ${a}); using ${i}.`), i);
|
|
67
|
-
}
|
|
68
|
-
var s = "Aiden";
|
|
94
|
+
}, o = 2147483e3, s = 2147483647;
|
|
69
95
|
function c(e) {
|
|
96
|
+
return e === void 0 ? o : Number.isInteger(e) && Math.abs(e) <= s ? e : (console.warn(`whoo-aiden-widget: ignoring zIndex ${String(e)} (expected an integer between -${s} and ${s}); using ${o}.`), o);
|
|
97
|
+
}
|
|
98
|
+
var l = "Aiden";
|
|
99
|
+
function u(e) {
|
|
70
100
|
return typeof e == "string" ? e.trim() : "";
|
|
71
101
|
}
|
|
72
|
-
function
|
|
102
|
+
function d(e) {
|
|
73
103
|
if ((typeof e.publishableKey == "string" && e.publishableKey.length > 0) == (typeof e.sessionToken == "string" && e.sessionToken.length > 0)) throw Error("whoo-aiden-widget: init() requires exactly one of `publishableKey` or `sessionToken`, not both or neither.");
|
|
74
104
|
}
|
|
75
|
-
function
|
|
105
|
+
function f(e) {
|
|
76
106
|
console.warn(`whoo-aiden-widget: ${e}`);
|
|
77
107
|
}
|
|
78
|
-
|
|
79
|
-
|
|
108
|
+
function p(e) {
|
|
109
|
+
let { getSessionToken: t } = e;
|
|
110
|
+
if (t !== void 0) {
|
|
111
|
+
if (typeof t != "function") {
|
|
112
|
+
f("ignoring `getSessionToken` -- expected a function that returns a session token.");
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (!e.sessionToken) {
|
|
116
|
+
f("ignoring `getSessionToken` -- it is only used with `sessionToken`; with `publishableKey` the widget renews its session by itself.");
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
return t;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
var m = 20;
|
|
123
|
+
function h(e) {
|
|
80
124
|
let t = /* @__PURE__ */ new WeakSet(), n = /* @__PURE__ */ new Set();
|
|
81
125
|
return (r) => {
|
|
82
126
|
if (typeof r == "object" && r || typeof r == "function") {
|
|
@@ -84,120 +128,139 @@ function f(e) {
|
|
|
84
128
|
t.add(r);
|
|
85
129
|
} else {
|
|
86
130
|
if (n.has(r)) return;
|
|
87
|
-
n.size >=
|
|
131
|
+
n.size >= m && n.delete(n.values().next().value), n.add(r);
|
|
88
132
|
}
|
|
89
|
-
|
|
133
|
+
f(e);
|
|
90
134
|
};
|
|
91
135
|
}
|
|
92
|
-
var
|
|
93
|
-
function
|
|
136
|
+
var g = h("ignoring `theme` -- expected an object."), _ = h("ignoring `layout` -- expected an object."), v = h("ignoring `messages` -- expected an object.");
|
|
137
|
+
function y(e) {
|
|
138
|
+
if (e == null) return {};
|
|
139
|
+
if (!b(e)) return v(e), {};
|
|
140
|
+
let n = {};
|
|
141
|
+
for (let r of Object.keys(e)) {
|
|
142
|
+
if (!t.includes(r)) {
|
|
143
|
+
f(`ignoring unknown option \`messages.${r}\`.`);
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
let i = e[r];
|
|
147
|
+
if (typeof i != "string" || i.trim() === "") {
|
|
148
|
+
f(`ignoring \`messages.${r}\` -- expected a non-blank string.`);
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
r === "chatWith" && !i.includes("{name}") && f("`messages.chatWith` has no {name}, so the agent name is not shown in the title. For a fixed title, use the `title` option."), n[r] = i;
|
|
152
|
+
}
|
|
153
|
+
for (let t in e) Object.hasOwn(e, t) || f(`ignoring inherited option \`messages.${t}\` -- only the object's own keys are used.`);
|
|
154
|
+
return n;
|
|
155
|
+
}
|
|
156
|
+
function b(e) {
|
|
94
157
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
95
158
|
}
|
|
96
|
-
var
|
|
97
|
-
function
|
|
159
|
+
var x = (e) => e == null || e === "";
|
|
160
|
+
function S(e, t, n) {
|
|
98
161
|
let r = e[t];
|
|
99
|
-
return r == null ? null :
|
|
162
|
+
return r == null ? null : b(r) ? r : (f(`ignoring \`${n}\` -- expected an object.`), null);
|
|
100
163
|
}
|
|
101
|
-
function
|
|
102
|
-
for (let r of Object.keys(e)) t.includes(r) ||
|
|
164
|
+
function C(e, t, n) {
|
|
165
|
+
for (let r of Object.keys(e)) t.includes(r) || f(`ignoring unknown option \`${n}.${r}\`.`);
|
|
103
166
|
}
|
|
104
|
-
function
|
|
105
|
-
if (!
|
|
167
|
+
function ee(e, t, n) {
|
|
168
|
+
if (!x(e)) {
|
|
106
169
|
if (typeof e == "string" && t.includes(e)) return e;
|
|
107
|
-
|
|
170
|
+
f(`ignoring \`${n}\` -- expected one of ${t.join(", ")}.`);
|
|
108
171
|
}
|
|
109
172
|
}
|
|
110
|
-
var
|
|
111
|
-
function
|
|
112
|
-
if (!
|
|
173
|
+
var w = 200, T = /url\(|[@;{}\\]/i;
|
|
174
|
+
function E(e) {
|
|
175
|
+
if (!x(e)) {
|
|
113
176
|
if (typeof e == "string") {
|
|
114
177
|
let t = e.trim();
|
|
115
|
-
if (t && t.length <=
|
|
178
|
+
if (t && t.length <= w && !T.test(t)) return t;
|
|
116
179
|
}
|
|
117
|
-
|
|
180
|
+
f(`ignoring \`theme.fonts.family\` -- expected a font-family stack of at most ${w} characters, without url(), @, ;, {, } or \\.`);
|
|
118
181
|
}
|
|
119
182
|
}
|
|
120
|
-
var
|
|
183
|
+
var D = [
|
|
121
184
|
"chat",
|
|
122
185
|
"message",
|
|
123
186
|
"sparkle"
|
|
124
|
-
],
|
|
125
|
-
function
|
|
126
|
-
let
|
|
187
|
+
], O = ["chevron-down", "close"], k = /* @__PURE__ */ new WeakMap();
|
|
188
|
+
function te(e) {
|
|
189
|
+
let t = {
|
|
127
190
|
colors: {},
|
|
128
191
|
fontFamily: void 0,
|
|
129
192
|
launcher: {}
|
|
130
193
|
};
|
|
131
|
-
if (
|
|
132
|
-
if (!
|
|
133
|
-
let i =
|
|
194
|
+
if (e == null) return t;
|
|
195
|
+
if (!b(e)) return g(e), t;
|
|
196
|
+
let i = k.get(e);
|
|
134
197
|
if (i) return i;
|
|
135
|
-
|
|
198
|
+
C(e, [
|
|
136
199
|
"colors",
|
|
137
200
|
"fonts",
|
|
138
201
|
"launcher"
|
|
139
202
|
], "theme");
|
|
140
|
-
let a =
|
|
203
|
+
let a = S(e, "colors", "theme.colors");
|
|
141
204
|
if (a) {
|
|
142
|
-
|
|
143
|
-
for (let e of
|
|
144
|
-
let
|
|
145
|
-
|
|
205
|
+
C(a, r, "theme.colors");
|
|
206
|
+
for (let e of r) {
|
|
207
|
+
let n = a[e];
|
|
208
|
+
x(n) || (typeof n == "string" ? t.colors[e] = n : f(`ignoring \`theme.colors.${e}\` -- expected a CSS color string.`));
|
|
146
209
|
}
|
|
147
210
|
}
|
|
148
|
-
let o =
|
|
149
|
-
o && (
|
|
150
|
-
let s =
|
|
211
|
+
let o = S(e, "fonts", "theme.fonts");
|
|
212
|
+
o && (C(o, ["family"], "theme.fonts"), t.fontFamily = E(o.family));
|
|
213
|
+
let s = S(e, "launcher", "theme.launcher");
|
|
151
214
|
if (s) {
|
|
152
|
-
|
|
215
|
+
C(s, [
|
|
153
216
|
"icon",
|
|
154
217
|
"iconUrl",
|
|
155
218
|
"openIcon",
|
|
156
219
|
"openIconUrl"
|
|
157
220
|
], "theme.launcher");
|
|
158
|
-
let
|
|
159
|
-
|
|
221
|
+
let e = ee(s.icon, D, "theme.launcher.icon"), r = n(s.iconUrl, "theme.launcher.iconUrl"), i = ee(s.openIcon, O, "theme.launcher.openIcon"), a = n(s.openIconUrl, "theme.launcher.openIconUrl");
|
|
222
|
+
e && (t.launcher.icon = e), r && (t.launcher.iconUrl = r), i && (t.launcher.openIcon = i), a && (t.launcher.openIconUrl = a);
|
|
160
223
|
}
|
|
161
|
-
return
|
|
224
|
+
return k.set(e, t), t;
|
|
162
225
|
}
|
|
163
|
-
var
|
|
226
|
+
var A = {
|
|
164
227
|
offsetX: 20,
|
|
165
228
|
offsetY: 20,
|
|
166
229
|
launcherSize: 56,
|
|
167
230
|
panelWidth: 360,
|
|
168
231
|
panelHeight: 480
|
|
169
232
|
};
|
|
170
|
-
function
|
|
171
|
-
return e == null ? n : typeof e == "number" && Number.isFinite(e) && e >= 0 ? e : (
|
|
233
|
+
function j(e, t, n) {
|
|
234
|
+
return e == null ? n : typeof e == "number" && Number.isFinite(e) && e >= 0 ? e : (f(`ignoring \`${t}\` -- expected a non-negative number of pixels; using ${n}.`), n);
|
|
172
235
|
}
|
|
173
|
-
function
|
|
236
|
+
function ne(e, t, n, r) {
|
|
174
237
|
let i = Math.min(r, Math.max(n, e));
|
|
175
|
-
return i !== e &&
|
|
238
|
+
return i !== e && f(`\`${t}\` ${e} is out of range (${r === Infinity ? `at least ${n}` : `${n}-${r}`}); using ${i}.`), i;
|
|
176
239
|
}
|
|
177
|
-
var
|
|
178
|
-
function
|
|
179
|
-
let t = { ...
|
|
240
|
+
var re = /* @__PURE__ */ new WeakMap();
|
|
241
|
+
function ie(e) {
|
|
242
|
+
let t = { ...A };
|
|
180
243
|
if (e == null) return t;
|
|
181
|
-
if (!
|
|
182
|
-
let n =
|
|
244
|
+
if (!b(e)) return _(e), t;
|
|
245
|
+
let n = re.get(e);
|
|
183
246
|
if (n) return n;
|
|
184
|
-
|
|
247
|
+
C(e, [
|
|
185
248
|
"offset",
|
|
186
249
|
"launcherSize",
|
|
187
250
|
"panel"
|
|
188
251
|
], "layout");
|
|
189
|
-
let r =
|
|
190
|
-
r && (
|
|
191
|
-
let i =
|
|
192
|
-
return i && (
|
|
252
|
+
let r = S(e, "offset", "layout.offset");
|
|
253
|
+
r && (C(r, ["x", "y"], "layout.offset"), t.offsetX = j(r.x, "layout.offset.x", A.offsetX), t.offsetY = j(r.y, "layout.offset.y", A.offsetY)), t.launcherSize = ne(j(e.launcherSize, "layout.launcherSize", A.launcherSize), "layout.launcherSize", 24, 120);
|
|
254
|
+
let i = S(e, "panel", "layout.panel");
|
|
255
|
+
return i && (C(i, ["width", "height"], "layout.panel"), t.panelWidth = ne(j(i.width, "layout.panel.width", A.panelWidth), "layout.panel.width", 280, Infinity), t.panelHeight = ne(j(i.height, "layout.panel.height", A.panelHeight), "layout.panel.height", 320, Infinity)), re.set(e, t), t;
|
|
193
256
|
}
|
|
194
257
|
//#endregion
|
|
195
258
|
//#region node_modules/.pnpm/preact@11.0.0/node_modules/preact/dist/preact.mjs
|
|
196
|
-
var
|
|
197
|
-
function
|
|
259
|
+
var M, ae, N, oe, se, ce, le, P, ue, de, fe, pe, me = {}, he = [], ge = /^m(i|n|o|s|text|space)$/, _e = Array.isArray, ve = he.slice, F = Object.assign;
|
|
260
|
+
function ye(e) {
|
|
198
261
|
e && e.parentNode && e.remove();
|
|
199
262
|
}
|
|
200
|
-
function
|
|
263
|
+
function be(e, t, n, r, i) {
|
|
201
264
|
var a = {
|
|
202
265
|
type: e,
|
|
203
266
|
props: t,
|
|
@@ -209,47 +272,47 @@ function _e(e, t, n, r, i) {
|
|
|
209
272
|
__e: null,
|
|
210
273
|
__c: null,
|
|
211
274
|
constructor: void 0,
|
|
212
|
-
__v: i || ++
|
|
275
|
+
__v: i || ++ae,
|
|
213
276
|
__i: -1,
|
|
214
277
|
__u: 0
|
|
215
278
|
};
|
|
216
|
-
return !i &&
|
|
279
|
+
return !i && M.vnode && M.vnode(a), a;
|
|
217
280
|
}
|
|
218
|
-
function
|
|
281
|
+
function I(e) {
|
|
219
282
|
return e.children;
|
|
220
283
|
}
|
|
221
|
-
function
|
|
284
|
+
function xe(e, t) {
|
|
222
285
|
this.props = e, this.context = t, this.__g = 0;
|
|
223
286
|
}
|
|
224
|
-
function
|
|
225
|
-
if (t == null) return e.__ ?
|
|
287
|
+
function L(e, t) {
|
|
288
|
+
if (t == null) return e.__ ? L(e.__, e.__i + 1) : null;
|
|
226
289
|
for (var n; t < e.__k.length; t++) if ((n = e.__k[t]) && n.__e) return n.__e;
|
|
227
|
-
return typeof e.type != "function" || e.props.__P ? null :
|
|
290
|
+
return typeof e.type != "function" || e.props.__P ? null : L(e);
|
|
228
291
|
}
|
|
229
|
-
function
|
|
292
|
+
function Se(e) {
|
|
230
293
|
if ((e = e.__) && e.__c && !e.props.__P) return e.__e = null, e.__k.some(function(t) {
|
|
231
294
|
return t && (e.__e = t.__e);
|
|
232
|
-
}),
|
|
295
|
+
}), Se(e);
|
|
233
296
|
}
|
|
234
|
-
function
|
|
235
|
-
(8 & e.__g || !(e.__g |= 8) || !
|
|
297
|
+
function Ce(e) {
|
|
298
|
+
(8 & e.__g || !(e.__g |= 8) || !N.push(e) || se++) && oe == M.debounceRendering || ((oe = M.debounceRendering) || queueMicrotask)(we);
|
|
236
299
|
}
|
|
237
|
-
function
|
|
300
|
+
function we() {
|
|
238
301
|
var e, t, n, r, i, a, o, s, c;
|
|
239
302
|
try {
|
|
240
|
-
for (t = 1;
|
|
303
|
+
for (t = 1; N.length;) N.length > t && N.sort(ce), e = N.shift(), t = N.length, 8 & e.__g && (r = void 0, i = void 0, a = (i = (n = e).__v).__e, o = [], s = [], (c = n.__P) && ((r = F({ constructor: void 0 }, i)).__v = i.__v + 1, M.vnode && M.vnode(r), Me(c, r, i, n.__n, c.namespaceURI, 32 & i.__u ? [a] : null, o, a || L(i), 32 & i.__u, s), r.__v = i.__v, r.__.__k[r.__i] = r, Pe(o, r, s), i.__ = i.__e = null, r.__e != a && Se(r)));
|
|
241
304
|
} finally {
|
|
242
|
-
|
|
305
|
+
N.length = se = 0;
|
|
243
306
|
}
|
|
244
307
|
}
|
|
245
|
-
function
|
|
246
|
-
var d, f, p, m, h, g, _ = r.__k ||
|
|
247
|
-
for (c =
|
|
308
|
+
function Te(e, t, n, r, i, a, o, s, c, l, u) {
|
|
309
|
+
var d, f, p, m, h, g, _ = r.__k || he, v = t.length;
|
|
310
|
+
for (c = Ee(n, t, _, c, v), d = 0; d < v; d++) (p = n.__k[d]) != null && (f = ~p.__i && _[p.__i] || me, p.__i = d, g = Me(e, p, f, i, a, o, s, c, l, u), m = p.__e, p.ref && (f.ref != p.ref || 8 & f.__u) && (f.ref != p.ref && f.ref && Ie(f.ref, null, p), u.push(p.ref, p.__c || m, p)), h ||= m, 4 & p.__u ? (c = De(p, c, e, !f.__v), f.__e && (f.__e = null)) : typeof p.type == "function" && g !== void 0 ? c = g : m && (c = m.nextSibling), p.__u &= -7);
|
|
248
311
|
return n.__e = h, c;
|
|
249
312
|
}
|
|
250
|
-
function
|
|
313
|
+
function Ee(e, t, n, r, i) {
|
|
251
314
|
var a, o, s, c, l, u, d, f, p, m, h = n.length, g = h, _ = 0, v = !1, y = e.__k = Array(i);
|
|
252
|
-
for (a = 0; a < i; a++) (o = t[a]) != null && typeof o != "boolean" && typeof o != "function" ? (typeof o != "object" || o.constructor == String ? o = y[a] =
|
|
315
|
+
for (a = 0; a < i; a++) (o = t[a]) != null && typeof o != "boolean" && typeof o != "function" ? (typeof o != "object" || o.constructor == String ? o = y[a] = be(null, o) : _e(o) ? o = y[a] = be(I, { children: o }) : o.constructor === void 0 && o.__b ? o = y[a] = be(o.type, o.props, o.key, o.ref, o.__v) : y[a] = o, c = a + _, o.__ = e, o.__b = e.__b + 1, s = null, ~(l = o.__i = Oe(o, n, c, g)) && (g--, (s = n[l]) && (s.__u |= 2)), s && s.__v ? (o.__u |= 2, l == c - 1 ? _-- : l == c + 1 ? _++ : l != c && (l > c ? _-- : _++, v = !0)) : (~l || (i > h ? _-- : i < h && _++), typeof o.type != "function" && (o.__u |= 4))) : y[a] = null;
|
|
253
316
|
if (v) {
|
|
254
317
|
for (u = [], d = [], a = 0; a < i; a++) if ((o = y[a]) && 2 & o.__u) {
|
|
255
318
|
for (f = 0, p = u.length; f < p;) u[m = f + p >> 1] < o.__i ? f = m + 1 : p = m;
|
|
@@ -257,20 +320,20 @@ function Ce(e, t, n, r, i) {
|
|
|
257
320
|
}
|
|
258
321
|
for (_ = u.length; a--;) d[a] && (d[a] == _ ? _-- : y[a].__u |= 4);
|
|
259
322
|
}
|
|
260
|
-
if (g) for (a = 0; a < h; a++) !(s = n[a]) || 2 & s.__u || (s.__e == r && (r =
|
|
323
|
+
if (g) for (a = 0; a < h; a++) !(s = n[a]) || 2 & s.__u || (s.__e == r && (r = L(s)), Le(s, s));
|
|
261
324
|
return r;
|
|
262
325
|
}
|
|
263
|
-
function
|
|
326
|
+
function De(e, t, n, r) {
|
|
264
327
|
var i, a;
|
|
265
328
|
if (typeof e.type == "function") {
|
|
266
329
|
if (e.props.__P) return t;
|
|
267
|
-
if (i = e.__k) for (a = 0; a < i.length; a++) i[a] && (i[a].__ = e, t =
|
|
330
|
+
if (i = e.__k) for (a = 0; a < i.length; a++) i[a] && (i[a].__ = e, t = De(i[a], t, n, !1));
|
|
268
331
|
return t;
|
|
269
332
|
}
|
|
270
|
-
for (t && !t.parentNode && (t =
|
|
333
|
+
for (t && !t.parentNode && (t = L(e)) && !t.parentNode && (t = null), e.__e != t && (!r && n.moveBefore && e.__e.parentNode ? n.moveBefore(e.__e, t) : n.insertBefore(e.__e, t || null)), t = e.__e; (t &&= t.nextSibling) && t.nodeType == 8;);
|
|
271
334
|
return t;
|
|
272
335
|
}
|
|
273
|
-
function
|
|
336
|
+
function Oe(e, t, n, r) {
|
|
274
337
|
var i, a, o, s = e.key, c = e.type, l = t[n], u = l && !(2 & l.__u);
|
|
275
338
|
if (l === null && s == null || u && s == l.key && c == l.type) return n;
|
|
276
339
|
if (r > +!!u) {
|
|
@@ -278,18 +341,18 @@ function Te(e, t, n, r) {
|
|
|
278
341
|
}
|
|
279
342
|
return -1;
|
|
280
343
|
}
|
|
281
|
-
function
|
|
344
|
+
function ke(e, t, n) {
|
|
282
345
|
n ??= "", t[0] == "-" ? e.setProperty(t, n) : e[t] = n;
|
|
283
346
|
}
|
|
284
|
-
function
|
|
347
|
+
function Ae(e, t, n, r, i) {
|
|
285
348
|
var a;
|
|
286
349
|
n: if (t == "style") {
|
|
287
350
|
if (typeof n == "string") e.style.cssText = n;
|
|
288
351
|
else {
|
|
289
|
-
if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n ||
|
|
290
|
-
if (n) for (t in n) r && n[t] == r[t] ||
|
|
352
|
+
if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n || ke(e.style, t, "");
|
|
353
|
+
if (n) for (t in n) r && n[t] == r[t] || ke(e.style, t, n[t]);
|
|
291
354
|
}
|
|
292
|
-
} else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(
|
|
355
|
+
} else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(ue, "$1")), (t = t.slice(2))[0] < "a" && (t = t.toLowerCase()), (e.__e ||= {})[t + a] = n, n ? r ? n[P] = r[P] : (n[P] = de, e.addEventListener(t, a ? pe : fe, a)) : e.removeEventListener(t, a ? pe : fe, a);
|
|
293
356
|
else {
|
|
294
357
|
if (i == "http://www.w3.org/2000/svg") t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
|
|
295
358
|
else if (t != "width" && t != "height" && t != "href" && t != "list" && t != "form" && t != "tabIndex" && t != "download" && t != "rowSpan" && t != "colSpan" && t != "role" && t != "popover" && t in e) try {
|
|
@@ -299,17 +362,17 @@ function De(e, t, n, r, i) {
|
|
|
299
362
|
typeof n == "function" || (n == null || !1 === n && t[4] != "-" ? e.removeAttribute(t) : e.setAttribute(t, t == "popover" && n == 1 ? "" : n));
|
|
300
363
|
}
|
|
301
364
|
}
|
|
302
|
-
function
|
|
365
|
+
function je(e) {
|
|
303
366
|
return function(t) {
|
|
304
367
|
if (this.__e) {
|
|
305
368
|
var n = this.__e[t.type + e];
|
|
306
|
-
if (t[
|
|
307
|
-
else if (t[
|
|
308
|
-
return n(
|
|
369
|
+
if (t[le] == null) t[le] = de++;
|
|
370
|
+
else if (t[le] < n[P]) return;
|
|
371
|
+
return n(M.event ? M.event(t) : t);
|
|
309
372
|
}
|
|
310
373
|
};
|
|
311
374
|
}
|
|
312
|
-
function
|
|
375
|
+
function Me(e, t, n, r, i, a, o, s, c, l) {
|
|
313
376
|
var u, d, f, p, m, h, g, _, v, y, b, x, S, C, ee, w, T, E, D, O, k = t.type;
|
|
314
377
|
if (t.constructor !== void 0) return null;
|
|
315
378
|
if (128 & n.__u && (c = 32 & n.__u, u = n.__c.__z)) {
|
|
@@ -323,28 +386,28 @@ function ke(e, t, n, r, i, a, o, s, c, l) {
|
|
|
323
386
|
else a.push(u);
|
|
324
387
|
s = a[0];
|
|
325
388
|
}
|
|
326
|
-
(u =
|
|
389
|
+
(u = M.__b) && u(t);
|
|
327
390
|
n: if (typeof k == "function") {
|
|
328
391
|
m = o.length;
|
|
329
392
|
try {
|
|
330
|
-
if (y = t.props, b = (u = k.prototype) && u.render, x = (u = k.contextType) && r[u.__c], S = u ? x ? x.props.value : u.__ : r, n.__c ? 2 & (h = t.__c = n.__c).__g && (h.__g |= 1) : (b ? t.__c = h = new k(y, S) : (t.__c = h = new
|
|
393
|
+
if (y = t.props, b = (u = k.prototype) && u.render, x = (u = k.contextType) && r[u.__c], S = u ? x ? x.props.value : u.__ : r, n.__c ? 2 & (h = t.__c = n.__c).__g && (h.__g |= 1) : (b ? t.__c = h = new k(y, S) : (t.__c = h = new xe(y, S), h.constructor = k, h.render = Re), x && x.sub(h), h.state || (h.state = {}), h.__n = r, h.__g |= 8, h.__h = [], h.__k = []), b && (h.__s || (h.__s = h.state), k.getDerivedStateFromProps && (h.__s == h.state && (h.__s = F({}, h.__s)), F(h.__s, k.getDerivedStateFromProps(y, h.__s)))), g = h.props, _ = h.state, h.__v = t, n.__c) {
|
|
331
394
|
if (b && !k.getDerivedStateFromProps && y !== g && h.componentWillReceiveProps && h.componentWillReceiveProps(y, S), t.__v == n.__v && !(8 & h.__g) || !(4 & h.__g) && h.shouldComponentUpdate && !1 === h.shouldComponentUpdate(y, h.__s, S)) {
|
|
332
395
|
t.__v != n.__v && (h.props = y, h.state = h.__s, h.__g &= -9), t.__e = n.__e, t.__k = n.__k, t.__k.some(function(e) {
|
|
333
396
|
e && (e.__ = t);
|
|
334
|
-
}),
|
|
397
|
+
}), he.push.apply(h.__h, h.__k), h.__k = [], h.__h.length && o.push(h), s = L(n);
|
|
335
398
|
break n;
|
|
336
399
|
}
|
|
337
400
|
h.componentWillUpdate && h.componentWillUpdate(y, h.__s, S), b && h.componentDidUpdate && h.__h.push(function() {
|
|
338
401
|
h.componentDidUpdate(g, _, v);
|
|
339
402
|
});
|
|
340
403
|
} else b && !k.getDerivedStateFromProps && h.componentWillMount && h.componentWillMount(), b && h.componentDidMount && h.__h.push(h.componentDidMount);
|
|
341
|
-
if (h.context = S, h.props = y, h.__P = e, h.__g &= -5, C =
|
|
404
|
+
if (h.context = S, h.props = y, h.__P = e, h.__g &= -5, C = M.__r, ee = 0, b) h.state = h.__s, h.__g &= -9, C && C(t), u = h.render(h.props, h.state, h.context), he.push.apply(h.__h, h.__k), h.__k = [];
|
|
342
405
|
else do
|
|
343
406
|
h.__g &= -9, C && C(t), u = h.render(h.props, h.state, h.context), h.state = h.__s;
|
|
344
407
|
while (8 & h.__g && ++ee < 25);
|
|
345
|
-
h.state = h.__s, h.getChildContext && (r =
|
|
346
|
-
e &&
|
|
347
|
-
}), n.__k = null), s = n.__k ?
|
|
408
|
+
h.state = h.__s, h.getChildContext && (r = F({}, r, h.getChildContext())), b && n.__c && h.getSnapshotBeforeUpdate && (v = h.getSnapshotBeforeUpdate(g, _)), w = u && u.type === I && u.key == null ? u.props.children : u, y.__P && (u = s, i = (e = y.__P).namespaceURI, c = a = null, n.props && n.props.__P != e && (n.__k.some(function(e) {
|
|
409
|
+
e && Le(e, e);
|
|
410
|
+
}), n.__k = null), s = n.__k ? L(n, 0) : null), s = Te(e, _e(w) ? w : [w], t, n, r, i, a, o, s, c, l), y.__P && (t.__e = null, s = u), t.__u &= -161, 128 & n.__u && (h.__z = null), d && d.some(ye), h.__h.length && o.push(h), 1 & h.__g && (h.__g &= -4);
|
|
348
411
|
} catch (e) {
|
|
349
412
|
if (o.length = m, t.__v = null, c || a) {
|
|
350
413
|
if (e.then) {
|
|
@@ -364,30 +427,30 @@ function ke(e, t, n, r, i, a, o, s, c, l) {
|
|
|
364
427
|
a && (a[a.indexOf(s)] = null), E = s;
|
|
365
428
|
}
|
|
366
429
|
t.__c.__z || (t.__c.__z = E), t.__e = s;
|
|
367
|
-
} else a && a.some(
|
|
430
|
+
} else a && a.some(ye);
|
|
368
431
|
} else t.__e = n.__e;
|
|
369
|
-
t.__k ||= n.__k || [], e.then ||
|
|
432
|
+
t.__k ||= n.__k || [], e.then || Ne(t), M.__e(e, t, n);
|
|
370
433
|
}
|
|
371
|
-
} else s = t.__e =
|
|
372
|
-
return (u =
|
|
434
|
+
} else s = t.__e = Fe(n.__e, t, n, r, i, a, o, c, l, e);
|
|
435
|
+
return (u = M.diffed) && u(t), 128 & t.__u ? void 0 : s;
|
|
373
436
|
}
|
|
374
|
-
function
|
|
375
|
-
e && (e.__c && (e.__c.__g |= 4), e.__k && e.__k.some(
|
|
437
|
+
function Ne(e) {
|
|
438
|
+
e && (e.__c && (e.__c.__g |= 4), e.__k && e.__k.some(Ne));
|
|
376
439
|
}
|
|
377
|
-
function
|
|
378
|
-
for (var r = 0; r < n.length;)
|
|
379
|
-
|
|
440
|
+
function Pe(e, t, n) {
|
|
441
|
+
for (var r = 0; r < n.length;) Ie(n[r++], n[r++], n[r++]);
|
|
442
|
+
M.__c && M.__c(t, e), e.some(function(t) {
|
|
380
443
|
try {
|
|
381
444
|
e = t.__h, t.__h = [], e.some(function(e) {
|
|
382
445
|
e.call(t);
|
|
383
446
|
});
|
|
384
447
|
} catch (e) {
|
|
385
|
-
|
|
448
|
+
M.__e(e, t.__v);
|
|
386
449
|
}
|
|
387
450
|
});
|
|
388
451
|
}
|
|
389
|
-
function
|
|
390
|
-
var u, d, f, p, m, h, g, _, v, y = n.props ||
|
|
452
|
+
function Fe(e, t, n, r, i, a, o, s, c, l) {
|
|
453
|
+
var u, d, f, p, m, h, g, _, v, y = n.props || me, b = t.props, x = t.type;
|
|
391
454
|
if (x == "svg" ? i = "http://www.w3.org/2000/svg" : x == "math" ? i = "http://www.w3.org/1998/Math/MathML" : i ||= "http://www.w3.org/1999/xhtml", a) {
|
|
392
455
|
for (u = 0; u < a.length; u++) if ((m = a[u]) && (x ? m.localName == x : m.nodeType == 3)) {
|
|
393
456
|
e = m, a[u] = null;
|
|
@@ -396,44 +459,44 @@ function Me(e, t, n, r, i, a, o, s, c, l) {
|
|
|
396
459
|
}
|
|
397
460
|
if (!e) {
|
|
398
461
|
if (_ = l.ownerDocument || document, !x) return _.createTextNode(b);
|
|
399
|
-
e = _.createElementNS(i, x, b.is && b), s &&= (
|
|
462
|
+
e = _.createElementNS(i, x, b.is && b), s &&= (M.__m && M.__m(t, a), !1), a = null;
|
|
400
463
|
}
|
|
401
464
|
if (x) {
|
|
402
|
-
if (l = x == "template" ? e.content : e, a = x == "textarea" && b.defaultValue != null ? null : a &&
|
|
403
|
-
for (u in y) m = y[u], u == "dangerouslySetInnerHTML" ? f = m : u == "children" || u in b || u == "value" && "defaultValue" in b || u == "checked" && "defaultChecked" in b ||
|
|
404
|
-
for (u in v = 1 & n.__u, b) m = b[u], u == "children" ? p = m : u == "dangerouslySetInnerHTML" ? d = m : u == "value" ? h = m : u == "checked" ? g = m : s && typeof m != "function" || !(y[u] !== m || v && m != null) ||
|
|
405
|
-
d ? (s || f && (d.__html == f.__html || d.__html == e.innerHTML) || (e.innerHTML = d.__html), t.__k = []) : (f && (e.textContent = ""), (x == "foreignObject" || i == "http://www.w3.org/1998/Math/MathML" &&
|
|
465
|
+
if (l = x == "template" ? e.content : e, a = x == "textarea" && b.defaultValue != null ? null : a && ve.call(l.childNodes), !s && a) for (y = {}, u = 0; u < e.attributes.length; u++) y[(m = e.attributes[u]).name] = m.value;
|
|
466
|
+
for (u in y) m = y[u], u == "dangerouslySetInnerHTML" ? f = m : u == "children" || u in b || u == "value" && "defaultValue" in b || u == "checked" && "defaultChecked" in b || Ae(e, u, null, m, i);
|
|
467
|
+
for (u in v = 1 & n.__u, b) m = b[u], u == "children" ? p = m : u == "dangerouslySetInnerHTML" ? d = m : u == "value" ? h = m : u == "checked" ? g = m : s && typeof m != "function" || !(y[u] !== m || v && m != null) || Ae(e, u, m, y[u], i);
|
|
468
|
+
d ? (s || f && (d.__html == f.__html || d.__html == e.innerHTML) || (e.innerHTML = d.__html), t.__k = []) : (f && (e.textContent = ""), (x == "foreignObject" || i == "http://www.w3.org/1998/Math/MathML" && ge.test(x)) && (i = "http://www.w3.org/1999/xhtml"), Te(l, _e(p) ? p : [p], t, n, r, i, a, o, a ? a[0] : n.__k && L(n, 0), s, c), a && a.some(ye)), s && x != "textarea" || (u = "value", x == "progress" && h == null ? e.removeAttribute(u) : h == null || h === e[u] && (x != "progress" || h) || Ae(e, u, h, y[u], i), u = "checked", g != null && g != e[u] && Ae(e, u, g, y[u], i));
|
|
406
469
|
} else y === b || s && e.data == b || (e.data = b);
|
|
407
470
|
return e;
|
|
408
471
|
}
|
|
409
|
-
function
|
|
472
|
+
function Ie(e, t, n) {
|
|
410
473
|
try {
|
|
411
474
|
typeof e == "function" ? (typeof e.__u == "function" && e.__u(), (typeof e.__u != "function" || t) && (e.__u = e(t))) : e.current = t;
|
|
412
475
|
} catch (e) {
|
|
413
|
-
|
|
476
|
+
M.__e(e, n);
|
|
414
477
|
}
|
|
415
478
|
}
|
|
416
|
-
function
|
|
479
|
+
function Le(e, t, n) {
|
|
417
480
|
var r, i;
|
|
418
|
-
if (
|
|
481
|
+
if (M.unmount && M.unmount(e), !(r = e.ref) || r.current && r.current != e.__e || Ie(r, null, t), r = e.__c) {
|
|
419
482
|
if (r.componentWillUnmount) try {
|
|
420
483
|
r.componentWillUnmount();
|
|
421
484
|
} catch (e) {
|
|
422
|
-
|
|
485
|
+
M.__e(e, t);
|
|
423
486
|
}
|
|
424
487
|
r.__P = r.__n = null;
|
|
425
488
|
}
|
|
426
|
-
if (r = e.__k) for (i = 0; i < r.length; i++) r[i] &&
|
|
427
|
-
(r = e.__e) && (n ||
|
|
489
|
+
if (r = e.__k) for (i = 0; i < r.length; i++) r[i] && Le(r[i], t, typeof e.type != "function" || n && !e.props.__P);
|
|
490
|
+
(r = e.__e) && (n || ye(r), r.__e && (r.__e = null)), e.__e = e.__c = e.__ = null;
|
|
428
491
|
}
|
|
429
|
-
function
|
|
492
|
+
function Re(e, t, n) {
|
|
430
493
|
return this.constructor(e, n);
|
|
431
494
|
}
|
|
432
|
-
function
|
|
495
|
+
function ze(e, t) {
|
|
433
496
|
var n, r, i, a;
|
|
434
|
-
|
|
497
|
+
M.__ && M.__(e, t), t.nodeType == 9 && (t = t.documentElement), r = (n = e && 32 & e.__u) ? null : t.__k, t.__k = be(I, { children: [e] }), i = [], a = [], Me(t, t.__k, r || me, me, t.namespaceURI, r ? null : t.firstChild ? ve.call(t.childNodes) : null, i, r ? r.__e : t.firstChild, n, a), Pe(i, t.__k, a), t.__k.props.children = null;
|
|
435
498
|
}
|
|
436
|
-
|
|
499
|
+
M = { __e: function(e, t, n, r) {
|
|
437
500
|
for (var i, a, o; t = t.__;) if ((i = t.__c) && !(1 & i.__g)) {
|
|
438
501
|
i.__g |= 4;
|
|
439
502
|
try {
|
|
@@ -442,43 +505,43 @@ A = { __e: function(e, t, n, r) {
|
|
|
442
505
|
e = t, o = 0;
|
|
443
506
|
}
|
|
444
507
|
}
|
|
445
|
-
throw
|
|
446
|
-
} },
|
|
508
|
+
throw se = 0, e;
|
|
509
|
+
} }, ae = 0, xe.prototype.setState = function(e, t) {
|
|
447
510
|
var n = this.__s;
|
|
448
|
-
n && n != this.state || (n = this.__s =
|
|
449
|
-
},
|
|
450
|
-
this.__v && (this.__g |= 4, e && this.__h.push(e),
|
|
451
|
-
},
|
|
511
|
+
n && n != this.state || (n = this.__s = F({}, this.state)), typeof e == "function" && (e = e(F({}, n), this.props)), e && (F(n, e), this.__v && (t && this.__k.push(t), Ce(this)));
|
|
512
|
+
}, xe.prototype.forceUpdate = function(e) {
|
|
513
|
+
this.__v && (this.__g |= 4, e && this.__h.push(e), Ce(this));
|
|
514
|
+
}, xe.prototype.render = I, N = [], se = 0, ce = function(e, t) {
|
|
452
515
|
return e.__v.__b - t.__v.__b;
|
|
453
|
-
},
|
|
516
|
+
}, le = Symbol(), P = Symbol(), ue = /(PointerCapture)$|Capture$/i, de = 0, fe = je(!1), pe = je(!0);
|
|
454
517
|
//#endregion
|
|
455
518
|
//#region node_modules/.pnpm/preact@11.0.0/node_modules/preact/hooks/dist/hooks.mjs
|
|
456
|
-
var
|
|
457
|
-
function
|
|
458
|
-
|
|
459
|
-
var n =
|
|
519
|
+
var R, z, Be, Ve, He = Object.is, Ue = 0, We = [], Ge = [], B = M, Ke = B.__b, qe = B.__r, Je = B.diffed, Ye = B.__c, Xe = B.unmount, Ze = B.__;
|
|
520
|
+
function Qe(e, t) {
|
|
521
|
+
B.__h && B.__h(z, e, Ue || t), Ue = 0;
|
|
522
|
+
var n = z.__H || (z.__H = {
|
|
460
523
|
__: [],
|
|
461
524
|
__h: []
|
|
462
525
|
});
|
|
463
526
|
return e >= n.__.length && n.__.push({}), n.__[e];
|
|
464
527
|
}
|
|
465
|
-
function
|
|
466
|
-
return
|
|
528
|
+
function $e(e) {
|
|
529
|
+
return Ue = 1, et(ut, e);
|
|
467
530
|
}
|
|
468
|
-
function
|
|
469
|
-
var r =
|
|
470
|
-
if (r.t = e, !r.__c && (r.__ = [n ? n(t) :
|
|
531
|
+
function et(e, t, n) {
|
|
532
|
+
var r = Qe(R++, 2);
|
|
533
|
+
if (r.t = e, !r.__c && (r.__ = [n ? n(t) : ut(void 0, t), function(e) {
|
|
471
534
|
var t = r.__N ? r.__N[0] : r.__[0], n = r.t(t, e);
|
|
472
|
-
|
|
473
|
-
}], r.__c =
|
|
474
|
-
|
|
475
|
-
var i =
|
|
476
|
-
|
|
535
|
+
He(t, n) || (r.__N = [n, r.__[1]], r.__c.setState({}));
|
|
536
|
+
}], r.__c = z, !z.__f)) {
|
|
537
|
+
z.__f = !0;
|
|
538
|
+
var i = z.shouldComponentUpdate;
|
|
539
|
+
z.shouldComponentUpdate = function(e, t, n) {
|
|
477
540
|
var r = this.__H;
|
|
478
541
|
if (!r) return !0;
|
|
479
542
|
var a = !1, o = this.props != e;
|
|
480
543
|
if (r.__.some(function(e) {
|
|
481
|
-
e.__N && (a = !0,
|
|
544
|
+
e.__N && (a = !0, He(e.__[0], e.__N[0]) || (o = !0));
|
|
482
545
|
}), i) {
|
|
483
546
|
var s = i.call(this, e, t, n);
|
|
484
547
|
return a ? s || o : s;
|
|
@@ -488,67 +551,71 @@ function Xe(e, t, n) {
|
|
|
488
551
|
}
|
|
489
552
|
return r.__;
|
|
490
553
|
}
|
|
491
|
-
function
|
|
492
|
-
var n =
|
|
493
|
-
!
|
|
554
|
+
function tt(e, t) {
|
|
555
|
+
var n = Qe(R++, 3);
|
|
556
|
+
!B.__s && lt(n.__H, t) && (n.__P = !0, n.__ = e, n.u = t, z.__H.__h.push(n));
|
|
557
|
+
}
|
|
558
|
+
function nt(e, t) {
|
|
559
|
+
var n = Qe(R++, 4);
|
|
560
|
+
!B.__s && lt(n.__H, t) && (n.__P = !1, n.__ = e, n.u = t, z.__h.push(n));
|
|
494
561
|
}
|
|
495
562
|
function V(e) {
|
|
496
|
-
return
|
|
563
|
+
return Ue = 5, rt(function() {
|
|
497
564
|
return { current: e };
|
|
498
565
|
}, []);
|
|
499
566
|
}
|
|
500
|
-
function
|
|
501
|
-
var n =
|
|
502
|
-
return
|
|
567
|
+
function rt(e, t) {
|
|
568
|
+
var n = Qe(R++, 7);
|
|
569
|
+
return lt(n.__H, t) && (n.__ = e(), n.__H = t), n.__;
|
|
503
570
|
}
|
|
504
|
-
function
|
|
571
|
+
function it() {
|
|
505
572
|
var e;
|
|
506
573
|
do {
|
|
507
|
-
for (; e =
|
|
574
|
+
for (; e = Ge.shift();) try {
|
|
508
575
|
H(e);
|
|
509
576
|
} catch (t) {
|
|
510
|
-
|
|
577
|
+
B.__e(t, { __: (e = e.__P) && e.__v });
|
|
511
578
|
}
|
|
512
|
-
for (; e =
|
|
579
|
+
for (; e = We.shift();) {
|
|
513
580
|
var t = e.__H;
|
|
514
581
|
if (e.__P && t) try {
|
|
515
|
-
t.__h.some(H), t.__h.some(
|
|
582
|
+
t.__h.some(H), t.__h.some(ct), t.__h = [];
|
|
516
583
|
} catch (n) {
|
|
517
|
-
t.__h = [],
|
|
584
|
+
t.__h = [], B.__e(n, e.__v);
|
|
518
585
|
}
|
|
519
586
|
}
|
|
520
|
-
} while (
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
},
|
|
525
|
-
e && t.__k && t.__k.__m && (e.__m = t.__k.__m),
|
|
526
|
-
},
|
|
527
|
-
|
|
528
|
-
var t = (
|
|
529
|
-
t && (
|
|
587
|
+
} while (Ge.length);
|
|
588
|
+
}
|
|
589
|
+
B.__b = function(e) {
|
|
590
|
+
z = null, Ke && Ke(e);
|
|
591
|
+
}, B.__ = function(e, t) {
|
|
592
|
+
e && t.__k && t.__k.__m && (e.__m = t.__k.__m), Ze && Ze(e, t);
|
|
593
|
+
}, B.__r = function(e) {
|
|
594
|
+
qe && qe(e), R = 0;
|
|
595
|
+
var t = (z = e.__c).__H;
|
|
596
|
+
t && (Be == z ? z.__h = [] : (t.__h.some(H), t.__h.some(ct), R = 0), t.__h = [], t.__.some(function(e) {
|
|
530
597
|
e.__N && (e.__ = e.__N), e.u = e.__N = void 0;
|
|
531
|
-
})),
|
|
532
|
-
},
|
|
533
|
-
|
|
598
|
+
})), Be = z;
|
|
599
|
+
}, B.diffed = function(e) {
|
|
600
|
+
Je && Je(e);
|
|
534
601
|
var t = e.__c;
|
|
535
|
-
t && t.__H && (t.__H.__h.length &&
|
|
602
|
+
t && t.__H && (t.__H.__h.length && st(We.push(t)), t.__H.__.some(function(e) {
|
|
536
603
|
e.u && (e.__H = e.u);
|
|
537
|
-
})),
|
|
538
|
-
},
|
|
604
|
+
})), Be = z = null;
|
|
605
|
+
}, B.__c = function(e, t) {
|
|
539
606
|
t.some(function(e) {
|
|
540
607
|
try {
|
|
541
608
|
e.__h.some(H), e.__h = e.__h.filter(function(e) {
|
|
542
|
-
return !e.__ ||
|
|
609
|
+
return !e.__ || ct(e);
|
|
543
610
|
});
|
|
544
611
|
} catch (n) {
|
|
545
612
|
t.some(function(e) {
|
|
546
613
|
e.__h &&= [];
|
|
547
|
-
}), t = [],
|
|
614
|
+
}), t = [], B.__e(n, e.__v);
|
|
548
615
|
}
|
|
549
|
-
}),
|
|
550
|
-
},
|
|
551
|
-
|
|
616
|
+
}), Ye && Ye(e, t);
|
|
617
|
+
}, B.unmount = function(e) {
|
|
618
|
+
Xe && Xe(e);
|
|
552
619
|
var t, n, r = e.__c;
|
|
553
620
|
r && r.__H && (r.__H.__.some(function(r) {
|
|
554
621
|
try {
|
|
@@ -557,42 +624,42 @@ z.__b = function(e) {
|
|
|
557
624
|
for (n = e.__; n && (!n.__c || !n.__c.__P);) n = n.__;
|
|
558
625
|
n &&= n.__c;
|
|
559
626
|
}
|
|
560
|
-
r.__P = n,
|
|
627
|
+
r.__P = n, st(Ge.push(r));
|
|
561
628
|
} else H(r);
|
|
562
629
|
} catch (e) {
|
|
563
630
|
t = e;
|
|
564
631
|
}
|
|
565
|
-
}), r.__H = void 0, t &&
|
|
632
|
+
}), r.__H = void 0, t && B.__e(t, r.__v));
|
|
566
633
|
};
|
|
567
|
-
var
|
|
568
|
-
function
|
|
634
|
+
var at = typeof requestAnimationFrame == "function";
|
|
635
|
+
function ot(e) {
|
|
569
636
|
var t, n = function() {
|
|
570
|
-
clearTimeout(r),
|
|
637
|
+
clearTimeout(r), at && cancelAnimationFrame(t), setTimeout(e);
|
|
571
638
|
}, r = setTimeout(n, 35);
|
|
572
|
-
|
|
639
|
+
at && (t = requestAnimationFrame(n));
|
|
573
640
|
}
|
|
574
|
-
function
|
|
575
|
-
e != 1 &&
|
|
641
|
+
function st(e) {
|
|
642
|
+
e != 1 && Ve == B.requestAnimationFrame || ((Ve = B.requestAnimationFrame) || ot)(it);
|
|
576
643
|
}
|
|
577
644
|
function H(e) {
|
|
578
|
-
var t =
|
|
579
|
-
typeof n == "function" && (e.__c = void 0, n()),
|
|
645
|
+
var t = z, n = e.__c;
|
|
646
|
+
typeof n == "function" && (e.__c = void 0, n()), z = t;
|
|
580
647
|
}
|
|
581
|
-
function
|
|
582
|
-
var t =
|
|
583
|
-
e.__c = e.__(),
|
|
648
|
+
function ct(e) {
|
|
649
|
+
var t = z;
|
|
650
|
+
e.__c = e.__(), z = t;
|
|
584
651
|
}
|
|
585
|
-
function
|
|
652
|
+
function lt(e, t) {
|
|
586
653
|
return !e || e.length != t.length || t.some(function(t, n) {
|
|
587
|
-
return !
|
|
654
|
+
return !He(t, e[n]);
|
|
588
655
|
});
|
|
589
656
|
}
|
|
590
|
-
function
|
|
657
|
+
function ut(e, t) {
|
|
591
658
|
return typeof t == "function" ? t(e) : t;
|
|
592
659
|
}
|
|
593
660
|
//#endregion
|
|
594
661
|
//#region node_modules/.pnpm/preact@11.0.0/node_modules/preact/jsx-runtime/dist/jsxRuntime.mjs
|
|
595
|
-
var
|
|
662
|
+
var dt = 0;
|
|
596
663
|
Array.isArray;
|
|
597
664
|
function U(e, t, n, r, i, a) {
|
|
598
665
|
t ||= {};
|
|
@@ -609,11 +676,11 @@ function U(e, t, n, r, i, a) {
|
|
|
609
676
|
__e: null,
|
|
610
677
|
__c: null,
|
|
611
678
|
constructor: void 0,
|
|
612
|
-
__v: --
|
|
679
|
+
__v: --dt,
|
|
613
680
|
__i: -1,
|
|
614
681
|
__u: 0
|
|
615
682
|
};
|
|
616
|
-
return (i || a) && (l.__source = i, l.__self = a),
|
|
683
|
+
return (i || a) && (l.__source = i, l.__self = a), M.vnode && M.vnode(l), l;
|
|
617
684
|
}
|
|
618
685
|
//#endregion
|
|
619
686
|
//#region src/components/icons.tsx
|
|
@@ -633,7 +700,7 @@ function W({ name: e, size: t, children: n }) {
|
|
|
633
700
|
children: n
|
|
634
701
|
});
|
|
635
702
|
}
|
|
636
|
-
function
|
|
703
|
+
function ft({ size: e = 26 }) {
|
|
637
704
|
return /* @__PURE__ */ U(W, {
|
|
638
705
|
name: "chat",
|
|
639
706
|
size: e,
|
|
@@ -643,131 +710,494 @@ function ot({ size: e = 26 }) {
|
|
|
643
710
|
})]
|
|
644
711
|
});
|
|
645
712
|
}
|
|
646
|
-
function
|
|
713
|
+
function pt({ size: e = 26 }) {
|
|
647
714
|
return /* @__PURE__ */ U(W, {
|
|
648
715
|
name: "message",
|
|
649
716
|
size: e,
|
|
650
717
|
children: /* @__PURE__ */ U("path", { d: "M21 11.5a8.5 8.5 0 0 1-12.4 7.5L3 20.5l1.6-5.1A8.5 8.5 0 1 1 21 11.5z" })
|
|
651
718
|
});
|
|
652
719
|
}
|
|
653
|
-
function
|
|
720
|
+
function mt({ size: e = 26 }) {
|
|
654
721
|
return /* @__PURE__ */ U(W, {
|
|
655
722
|
name: "sparkle",
|
|
656
723
|
size: e,
|
|
657
724
|
children: [/* @__PURE__ */ U("path", { d: "M11 3l1.9 5.1L18 10l-5.1 1.9L11 17l-1.9-5.1L4 10l5.1-1.9z" }), /* @__PURE__ */ U("path", { d: "M19 15l.7 1.8 1.8.7-1.8.7L19 20l-.7-1.8-1.8-.7 1.8-.7z" })]
|
|
658
725
|
});
|
|
659
726
|
}
|
|
660
|
-
function
|
|
727
|
+
function ht({ size: e = 26 }) {
|
|
661
728
|
return /* @__PURE__ */ U(W, {
|
|
662
729
|
name: "chevron-down",
|
|
663
730
|
size: e,
|
|
664
731
|
children: /* @__PURE__ */ U("path", { d: "M6 9l6 6 6-6" })
|
|
665
732
|
});
|
|
666
733
|
}
|
|
667
|
-
function
|
|
734
|
+
function gt({ size: e = 18 }) {
|
|
668
735
|
return /* @__PURE__ */ U(W, {
|
|
669
736
|
name: "close",
|
|
670
737
|
size: e,
|
|
671
738
|
children: /* @__PURE__ */ U("path", { d: "M6 6l12 12M18 6L6 18" })
|
|
672
739
|
});
|
|
673
740
|
}
|
|
674
|
-
var
|
|
675
|
-
function
|
|
741
|
+
var _t = "M7 11v9M7 11l3.5-7.2A1.8 1.8 0 0 1 14 4.6V9h4.6a2 2 0 0 1 2 2.3l-1.2 7A2 2 0 0 1 17.4 20H7M7 11H4.5A1.5 1.5 0 0 0 3 12.5v6A1.5 1.5 0 0 0 4.5 20H7";
|
|
742
|
+
function vt({ size: e = 16 }) {
|
|
676
743
|
return /* @__PURE__ */ U(W, {
|
|
677
744
|
name: "thumb-up",
|
|
678
745
|
size: e,
|
|
679
|
-
children: /* @__PURE__ */ U("path", { d:
|
|
746
|
+
children: /* @__PURE__ */ U("path", { d: _t })
|
|
680
747
|
});
|
|
681
748
|
}
|
|
682
|
-
function
|
|
749
|
+
function yt({ size: e = 16 }) {
|
|
683
750
|
return /* @__PURE__ */ U(W, {
|
|
684
751
|
name: "thumb-down",
|
|
685
752
|
size: e,
|
|
686
753
|
children: /* @__PURE__ */ U("path", {
|
|
687
|
-
d:
|
|
754
|
+
d: _t,
|
|
688
755
|
transform: "matrix(1 0 0 -1 0 24)"
|
|
689
756
|
})
|
|
690
757
|
});
|
|
691
758
|
}
|
|
692
759
|
//#endregion
|
|
693
760
|
//#region src/components/Launcher.tsx
|
|
694
|
-
var
|
|
695
|
-
chat:
|
|
696
|
-
message:
|
|
697
|
-
sparkle:
|
|
698
|
-
},
|
|
699
|
-
"chevron-down":
|
|
700
|
-
close:
|
|
761
|
+
var bt = {
|
|
762
|
+
chat: ft,
|
|
763
|
+
message: pt,
|
|
764
|
+
sparkle: mt
|
|
765
|
+
}, xt = {
|
|
766
|
+
"chevron-down": ht,
|
|
767
|
+
close: gt
|
|
701
768
|
};
|
|
702
|
-
function
|
|
703
|
-
let [
|
|
769
|
+
function St({ isOpen: t, onClick: n, iconUrl: r, icon: i = "chat", openIconUrl: a, openIcon: o = "chevron-down", buttonRef: s, text: c = e }) {
|
|
770
|
+
let [l, u] = $e("loading"), [d, f] = $e("loading"), p = r !== void 0 && l !== "failed", m = a !== void 0 && d !== "failed", h = p && !t && l === "loaded", g = m && t && d === "loaded", _ = bt[i] ?? ft, v = xt[o] ?? ht;
|
|
704
771
|
return /* @__PURE__ */ U("button", {
|
|
705
772
|
type: "button",
|
|
706
773
|
class: "whoo-widget-launcher",
|
|
707
|
-
onClick:
|
|
708
|
-
"aria-label":
|
|
709
|
-
ref:
|
|
774
|
+
onClick: n,
|
|
775
|
+
"aria-label": t ? c.closeChat : c.openChat,
|
|
776
|
+
ref: s,
|
|
710
777
|
children: [
|
|
711
|
-
|
|
712
|
-
|
|
778
|
+
t ? g ? null : /* @__PURE__ */ U(v, {}) : h ? null : /* @__PURE__ */ U(_, {}),
|
|
779
|
+
p ? /* @__PURE__ */ U("img", {
|
|
713
780
|
class: "whoo-widget-launcher-icon-image",
|
|
714
|
-
src:
|
|
781
|
+
src: r,
|
|
715
782
|
alt: "",
|
|
716
783
|
referrerpolicy: "no-referrer",
|
|
717
|
-
hidden: !
|
|
718
|
-
onLoad: () =>
|
|
719
|
-
onError: () =>
|
|
784
|
+
hidden: !h,
|
|
785
|
+
onLoad: () => u("loaded"),
|
|
786
|
+
onError: () => u("failed")
|
|
720
787
|
}) : null,
|
|
721
|
-
|
|
788
|
+
m ? /* @__PURE__ */ U("img", {
|
|
722
789
|
class: "whoo-widget-launcher-icon-image",
|
|
723
|
-
src:
|
|
790
|
+
src: a,
|
|
724
791
|
alt: "",
|
|
725
792
|
referrerpolicy: "no-referrer",
|
|
726
|
-
hidden: !
|
|
727
|
-
onLoad: () =>
|
|
728
|
-
onError: () =>
|
|
793
|
+
hidden: !g,
|
|
794
|
+
onLoad: () => f("loaded"),
|
|
795
|
+
onError: () => f("failed")
|
|
729
796
|
}) : null
|
|
730
797
|
]
|
|
731
798
|
});
|
|
732
799
|
}
|
|
733
800
|
//#endregion
|
|
801
|
+
//#region src/i18n/index.ts
|
|
802
|
+
var Ct = {
|
|
803
|
+
en: e,
|
|
804
|
+
fr: {
|
|
805
|
+
openChat: "Ouvrir le chat",
|
|
806
|
+
closeChat: "Fermer le chat",
|
|
807
|
+
chatWith: "Discuter avec {name}",
|
|
808
|
+
newConversation: "Nouvelle conversation",
|
|
809
|
+
conversation: "Conversation",
|
|
810
|
+
you: "Vous",
|
|
811
|
+
message: "Message",
|
|
812
|
+
send: "Envoyer",
|
|
813
|
+
lookingItUp: "Je recherche l’information pour vous…",
|
|
814
|
+
goodResponse: "Réponse utile",
|
|
815
|
+
badResponse: "Réponse peu utile",
|
|
816
|
+
additionalFeedback: "Commentaire supplémentaire",
|
|
817
|
+
feedbackPlaceholder: "Qu’est-ce qui n’allait pas ? (facultatif)",
|
|
818
|
+
feedbackCategory: "Catégorie du commentaire",
|
|
819
|
+
selectReason: "Choisissez un motif (facultatif)",
|
|
820
|
+
categoryFactual: "Erreur factuelle",
|
|
821
|
+
categoryIncomplete: "Réponse incomplète",
|
|
822
|
+
categoryTone: "Ton inapproprié",
|
|
823
|
+
categoryOther: "Autre",
|
|
824
|
+
submit: "Envoyer le commentaire",
|
|
825
|
+
cancel: "Annuler",
|
|
826
|
+
feedbackThanks: "Merci pour votre commentaire",
|
|
827
|
+
feedbackFailed: "Impossible d’envoyer votre commentaire",
|
|
828
|
+
conversationCleared: "Conversation effacée",
|
|
829
|
+
genericError: "Une erreur s’est produite. Veuillez réessayer.",
|
|
830
|
+
sessionExpired: "Cette session de chat a expiré. Rechargez la page pour continuer."
|
|
831
|
+
},
|
|
832
|
+
es: {
|
|
833
|
+
openChat: "Abrir chat",
|
|
834
|
+
closeChat: "Cerrar chat",
|
|
835
|
+
chatWith: "Chat con {name}",
|
|
836
|
+
newConversation: "Nueva conversación",
|
|
837
|
+
conversation: "Conversación",
|
|
838
|
+
you: "Usted",
|
|
839
|
+
message: "Mensaje",
|
|
840
|
+
send: "Enviar",
|
|
841
|
+
lookingItUp: "Estoy buscando esa información…",
|
|
842
|
+
goodResponse: "Buena respuesta",
|
|
843
|
+
badResponse: "Mala respuesta",
|
|
844
|
+
additionalFeedback: "Comentarios adicionales",
|
|
845
|
+
feedbackPlaceholder: "¿Qué estuvo mal? (opcional)",
|
|
846
|
+
feedbackCategory: "Tipo de problema",
|
|
847
|
+
selectReason: "Seleccione un motivo (opcional)",
|
|
848
|
+
categoryFactual: "Información incorrecta",
|
|
849
|
+
categoryIncomplete: "Respuesta incompleta",
|
|
850
|
+
categoryTone: "Tono inadecuado",
|
|
851
|
+
categoryOther: "Otro",
|
|
852
|
+
submit: "Enviar comentarios",
|
|
853
|
+
cancel: "Cancelar",
|
|
854
|
+
feedbackThanks: "Gracias por sus comentarios",
|
|
855
|
+
feedbackFailed: "No se pudieron enviar sus comentarios",
|
|
856
|
+
conversationCleared: "Se inició una nueva conversación",
|
|
857
|
+
genericError: "Algo salió mal. Inténtelo de nuevo.",
|
|
858
|
+
sessionExpired: "Esta sesión de chat expiró. Vuelva a cargar la página para continuar."
|
|
859
|
+
},
|
|
860
|
+
pt: {
|
|
861
|
+
openChat: "Abrir chat",
|
|
862
|
+
closeChat: "Fechar chat",
|
|
863
|
+
chatWith: "Conversa com {name}",
|
|
864
|
+
newConversation: "Nova conversa",
|
|
865
|
+
conversation: "Conversa",
|
|
866
|
+
you: "Você",
|
|
867
|
+
message: "Mensagem",
|
|
868
|
+
send: "Enviar",
|
|
869
|
+
lookingItUp: "Estou buscando essa informação…",
|
|
870
|
+
goodResponse: "Boa resposta",
|
|
871
|
+
badResponse: "Resposta ruim",
|
|
872
|
+
additionalFeedback: "Comentários adicionais",
|
|
873
|
+
feedbackPlaceholder: "O que estava errado? (opcional)",
|
|
874
|
+
feedbackCategory: "Categoria do feedback",
|
|
875
|
+
selectReason: "Selecione um motivo (opcional)",
|
|
876
|
+
categoryFactual: "Informação incorreta",
|
|
877
|
+
categoryIncomplete: "Resposta incompleta",
|
|
878
|
+
categoryTone: "Tom inadequado",
|
|
879
|
+
categoryOther: "Outro",
|
|
880
|
+
submit: "Enviar feedback",
|
|
881
|
+
cancel: "Cancelar",
|
|
882
|
+
feedbackThanks: "Agradecemos seu feedback",
|
|
883
|
+
feedbackFailed: "Não foi possível enviar o feedback",
|
|
884
|
+
conversationCleared: "Nova conversa iniciada",
|
|
885
|
+
genericError: "Algo deu errado. Tente novamente.",
|
|
886
|
+
sessionExpired: "Esta sessão de chat expirou. Recarregue a página para continuar."
|
|
887
|
+
},
|
|
888
|
+
de: {
|
|
889
|
+
openChat: "Chat öffnen",
|
|
890
|
+
closeChat: "Chat schließen",
|
|
891
|
+
chatWith: "Chat mit {name}",
|
|
892
|
+
newConversation: "Neue Unterhaltung",
|
|
893
|
+
conversation: "Unterhaltung",
|
|
894
|
+
you: "Sie",
|
|
895
|
+
message: "Nachricht",
|
|
896
|
+
send: "Senden",
|
|
897
|
+
lookingItUp: "Ich suche die Informationen für Sie heraus…",
|
|
898
|
+
goodResponse: "Gute Antwort",
|
|
899
|
+
badResponse: "Schlechte Antwort",
|
|
900
|
+
additionalFeedback: "Zusätzliches Feedback",
|
|
901
|
+
feedbackPlaceholder: "Was war falsch? (optional)",
|
|
902
|
+
feedbackCategory: "Feedback-Kategorie",
|
|
903
|
+
selectReason: "Grund auswählen (optional)",
|
|
904
|
+
categoryFactual: "Faktenfehler",
|
|
905
|
+
categoryIncomplete: "Unvollständig",
|
|
906
|
+
categoryTone: "Unpassender Ton",
|
|
907
|
+
categoryOther: "Sonstiges",
|
|
908
|
+
submit: "Absenden",
|
|
909
|
+
cancel: "Abbrechen",
|
|
910
|
+
feedbackThanks: "Danke für Ihr Feedback",
|
|
911
|
+
feedbackFailed: "Feedback konnte nicht gesendet werden",
|
|
912
|
+
conversationCleared: "Neue Unterhaltung gestartet",
|
|
913
|
+
genericError: "Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut.",
|
|
914
|
+
sessionExpired: "Diese Chat-Sitzung ist abgelaufen. Laden Sie die Seite neu, um fortzufahren."
|
|
915
|
+
},
|
|
916
|
+
it: {
|
|
917
|
+
openChat: "Apri la chat",
|
|
918
|
+
closeChat: "Chiudi la chat",
|
|
919
|
+
chatWith: "Chat con {name}",
|
|
920
|
+
newConversation: "Nuova conversazione",
|
|
921
|
+
conversation: "Conversazione",
|
|
922
|
+
you: "Tu",
|
|
923
|
+
message: "Messaggio",
|
|
924
|
+
send: "Invia",
|
|
925
|
+
lookingItUp: "Sto cercando le informazioni richieste…",
|
|
926
|
+
goodResponse: "Risposta utile",
|
|
927
|
+
badResponse: "Risposta non utile",
|
|
928
|
+
additionalFeedback: "Commenti aggiuntivi",
|
|
929
|
+
feedbackPlaceholder: "Che cosa non andava? (facoltativo)",
|
|
930
|
+
feedbackCategory: "Categoria del feedback",
|
|
931
|
+
selectReason: "Seleziona un motivo (facoltativo)",
|
|
932
|
+
categoryFactual: "Informazione errata",
|
|
933
|
+
categoryIncomplete: "Risposta incompleta",
|
|
934
|
+
categoryTone: "Tono non adeguato",
|
|
935
|
+
categoryOther: "Altro",
|
|
936
|
+
submit: "Invia feedback",
|
|
937
|
+
cancel: "Annulla",
|
|
938
|
+
feedbackThanks: "Grazie per il feedback",
|
|
939
|
+
feedbackFailed: "Impossibile inviare il feedback",
|
|
940
|
+
conversationCleared: "Nuova conversazione avviata",
|
|
941
|
+
genericError: "Si è verificato un errore. Riprovi.",
|
|
942
|
+
sessionExpired: "Questa sessione di chat è scaduta. Ricarichi la pagina per continuare."
|
|
943
|
+
},
|
|
944
|
+
ja: {
|
|
945
|
+
openChat: "チャットを開く",
|
|
946
|
+
closeChat: "チャットを閉じる",
|
|
947
|
+
chatWith: "{name}とチャット",
|
|
948
|
+
newConversation: "新しい会話",
|
|
949
|
+
conversation: "会話",
|
|
950
|
+
you: "あなた",
|
|
951
|
+
message: "メッセージ",
|
|
952
|
+
send: "送信",
|
|
953
|
+
lookingItUp: "確認しています…",
|
|
954
|
+
goodResponse: "良い回答",
|
|
955
|
+
badResponse: "良くない回答",
|
|
956
|
+
additionalFeedback: "追加のフィードバック",
|
|
957
|
+
feedbackPlaceholder: "何が問題でしたか?(任意)",
|
|
958
|
+
feedbackCategory: "フィードバックの種類",
|
|
959
|
+
selectReason: "理由を選択(任意)",
|
|
960
|
+
categoryFactual: "事実の誤り",
|
|
961
|
+
categoryIncomplete: "回答が不十分",
|
|
962
|
+
categoryTone: "不適切な口調",
|
|
963
|
+
categoryOther: "その他",
|
|
964
|
+
submit: "フィードバックを送信",
|
|
965
|
+
cancel: "キャンセル",
|
|
966
|
+
feedbackThanks: "フィードバックありがとうございます",
|
|
967
|
+
feedbackFailed: "フィードバックを送信できませんでした",
|
|
968
|
+
conversationCleared: "会話を消去しました",
|
|
969
|
+
genericError: "エラーが発生しました。もう一度お試しください。",
|
|
970
|
+
sessionExpired: "このチャットセッションの有効期限が切れました。続けるにはページを再読み込みしてください。"
|
|
971
|
+
},
|
|
972
|
+
zh: {
|
|
973
|
+
openChat: "打开聊天",
|
|
974
|
+
closeChat: "关闭聊天",
|
|
975
|
+
chatWith: "与{name}聊天",
|
|
976
|
+
newConversation: "新对话",
|
|
977
|
+
conversation: "对话",
|
|
978
|
+
you: "您",
|
|
979
|
+
message: "消息",
|
|
980
|
+
send: "发送",
|
|
981
|
+
lookingItUp: "正在为您查找……",
|
|
982
|
+
goodResponse: "回答很好",
|
|
983
|
+
badResponse: "回答不好",
|
|
984
|
+
additionalFeedback: "补充反馈",
|
|
985
|
+
feedbackPlaceholder: "哪里有问题?(可选)",
|
|
986
|
+
feedbackCategory: "反馈类别",
|
|
987
|
+
selectReason: "选择原因(可选)",
|
|
988
|
+
categoryFactual: "事实错误",
|
|
989
|
+
categoryIncomplete: "回答不完整",
|
|
990
|
+
categoryTone: "语气不当",
|
|
991
|
+
categoryOther: "其他",
|
|
992
|
+
submit: "提交",
|
|
993
|
+
cancel: "取消",
|
|
994
|
+
feedbackThanks: "感谢您的反馈",
|
|
995
|
+
feedbackFailed: "反馈提交失败",
|
|
996
|
+
conversationCleared: "对话已清除",
|
|
997
|
+
genericError: "出了点问题,请重试。",
|
|
998
|
+
sessionExpired: "此聊天会话已过期。请刷新页面后继续。"
|
|
999
|
+
},
|
|
1000
|
+
ru: {
|
|
1001
|
+
openChat: "Открыть чат",
|
|
1002
|
+
closeChat: "Закрыть чат",
|
|
1003
|
+
chatWith: "Чат с ассистентом {name}",
|
|
1004
|
+
newConversation: "Новый диалог",
|
|
1005
|
+
conversation: "Диалог",
|
|
1006
|
+
you: "Вы",
|
|
1007
|
+
message: "Сообщение",
|
|
1008
|
+
send: "Отправить",
|
|
1009
|
+
lookingItUp: "Ищу информацию…",
|
|
1010
|
+
goodResponse: "Хороший ответ",
|
|
1011
|
+
badResponse: "Плохой ответ",
|
|
1012
|
+
additionalFeedback: "Дополнительный комментарий",
|
|
1013
|
+
feedbackPlaceholder: "Что было не так? (необязательно)",
|
|
1014
|
+
feedbackCategory: "Категория отзыва",
|
|
1015
|
+
selectReason: "Выберите причину (необязательно)",
|
|
1016
|
+
categoryFactual: "Фактическая ошибка",
|
|
1017
|
+
categoryIncomplete: "Неполный ответ",
|
|
1018
|
+
categoryTone: "Неподходящий тон",
|
|
1019
|
+
categoryOther: "Другое",
|
|
1020
|
+
submit: "Отправить отзыв",
|
|
1021
|
+
cancel: "Отмена",
|
|
1022
|
+
feedbackThanks: "Спасибо за отзыв",
|
|
1023
|
+
feedbackFailed: "Не удалось отправить отзыв",
|
|
1024
|
+
conversationCleared: "Диалог очищен",
|
|
1025
|
+
genericError: "Что-то пошло не так. Попробуйте ещё раз.",
|
|
1026
|
+
sessionExpired: "Срок действия сеанса чата истёк. Перезагрузите страницу, чтобы продолжить."
|
|
1027
|
+
},
|
|
1028
|
+
hi: {
|
|
1029
|
+
openChat: "चैट खोलें",
|
|
1030
|
+
closeChat: "चैट बंद करें",
|
|
1031
|
+
chatWith: "{name} से चैट करें",
|
|
1032
|
+
newConversation: "नई बातचीत",
|
|
1033
|
+
conversation: "बातचीत",
|
|
1034
|
+
you: "आप",
|
|
1035
|
+
message: "संदेश",
|
|
1036
|
+
send: "भेजें",
|
|
1037
|
+
lookingItUp: "आपके लिए जानकारी खोजी जा रही है…",
|
|
1038
|
+
goodResponse: "अच्छा जवाब",
|
|
1039
|
+
badResponse: "ख़राब जवाब",
|
|
1040
|
+
additionalFeedback: "अतिरिक्त फ़ीडबैक",
|
|
1041
|
+
feedbackPlaceholder: "क्या ग़लत था? (वैकल्पिक)",
|
|
1042
|
+
feedbackCategory: "फ़ीडबैक की श्रेणी",
|
|
1043
|
+
selectReason: "कारण चुनें (वैकल्पिक)",
|
|
1044
|
+
categoryFactual: "तथ्यात्मक त्रुटि",
|
|
1045
|
+
categoryIncomplete: "अधूरा जवाब",
|
|
1046
|
+
categoryTone: "अनुचित लहजा",
|
|
1047
|
+
categoryOther: "अन्य",
|
|
1048
|
+
submit: "सबमिट करें",
|
|
1049
|
+
cancel: "रद्द करें",
|
|
1050
|
+
feedbackThanks: "आपके फ़ीडबैक के लिए धन्यवाद",
|
|
1051
|
+
feedbackFailed: "फ़ीडबैक नहीं भेजा जा सका",
|
|
1052
|
+
conversationCleared: "बातचीत मिटा दी गई",
|
|
1053
|
+
genericError: "कुछ ग़लत हो गया। कृपया फिर से कोशिश करें।",
|
|
1054
|
+
sessionExpired: "यह चैट सत्र समाप्त हो गया है। जारी रखने के लिए पेज को फिर से लोड करें।"
|
|
1055
|
+
},
|
|
1056
|
+
ar: {
|
|
1057
|
+
openChat: "فتح الدردشة",
|
|
1058
|
+
closeChat: "إغلاق الدردشة",
|
|
1059
|
+
chatWith: "الدردشة مع {name}",
|
|
1060
|
+
newConversation: "محادثة جديدة",
|
|
1061
|
+
conversation: "المحادثة",
|
|
1062
|
+
you: "أنت",
|
|
1063
|
+
message: "الرسالة",
|
|
1064
|
+
send: "إرسال",
|
|
1065
|
+
lookingItUp: "جارٍ البحث عن المعلومات…",
|
|
1066
|
+
goodResponse: "إجابة جيدة",
|
|
1067
|
+
badResponse: "إجابة سيئة",
|
|
1068
|
+
additionalFeedback: "ملاحظات إضافية",
|
|
1069
|
+
feedbackPlaceholder: "ما المشكلة؟ (اختياري)",
|
|
1070
|
+
feedbackCategory: "فئة الملاحظات",
|
|
1071
|
+
selectReason: "اختر سببًا (اختياري)",
|
|
1072
|
+
categoryFactual: "معلومات غير صحيحة",
|
|
1073
|
+
categoryIncomplete: "إجابة غير مكتملة",
|
|
1074
|
+
categoryTone: "أسلوب غير مناسب",
|
|
1075
|
+
categoryOther: "أخرى",
|
|
1076
|
+
submit: "إرسال الملاحظات",
|
|
1077
|
+
cancel: "إلغاء",
|
|
1078
|
+
feedbackThanks: "شكرًا على ملاحظاتك",
|
|
1079
|
+
feedbackFailed: "تعذّر إرسال الملاحظات",
|
|
1080
|
+
conversationCleared: "تم مسح المحادثة",
|
|
1081
|
+
genericError: "حدث خطأ ما. يُرجى المحاولة مرة أخرى.",
|
|
1082
|
+
sessionExpired: "انتهت صلاحية جلسة الدردشة هذه. يُرجى إعادة تحميل الصفحة للمتابعة."
|
|
1083
|
+
}
|
|
1084
|
+
}, wt = Object.freeze(Object.keys(Ct)), Tt = {
|
|
1085
|
+
pt: "pt-BR",
|
|
1086
|
+
es: "es-419",
|
|
1087
|
+
zh: "zh-Hans"
|
|
1088
|
+
}, Et = /* @__PURE__ */ new Set(["ar"]), Dt = /^[a-z]{2,8}([-_][a-z0-9]{1,8})*$/i, Ot = /^zh[-_](hant|tw|hk|mo)(?=$|[-_])/i;
|
|
1089
|
+
function kt(e) {
|
|
1090
|
+
return Ct[e];
|
|
1091
|
+
}
|
|
1092
|
+
function At(e) {
|
|
1093
|
+
let t = e.trim();
|
|
1094
|
+
if (!Dt.test(t) || Ot.test(t)) return null;
|
|
1095
|
+
let n = t.split(/[-_]/)[0].toLowerCase();
|
|
1096
|
+
return Object.hasOwn(Ct, n) ? n : null;
|
|
1097
|
+
}
|
|
1098
|
+
function jt(e, t) {
|
|
1099
|
+
let n = null;
|
|
1100
|
+
return e != null && e !== "" && (n = typeof e == "string" ? At(e) : null, n || console.warn(`whoo-aiden-widget: ignoring \`language\` ${Mt(e)} -- expected one of ${wt.join(", ")} (or a regional tag like pt-BR). Using the page's language instead.`)), n ??= typeof t == "string" ? At(t) : null, n ??= "en", {
|
|
1101
|
+
language: n,
|
|
1102
|
+
tag: Tt[n] ?? n,
|
|
1103
|
+
dir: Et.has(n) ? "rtl" : "ltr"
|
|
1104
|
+
};
|
|
1105
|
+
}
|
|
1106
|
+
function Mt(e) {
|
|
1107
|
+
return typeof e == "string" ? JSON.stringify(e) : `(a ${typeof e})`;
|
|
1108
|
+
}
|
|
1109
|
+
function Nt(e, t) {
|
|
1110
|
+
return e.split("{name}").join(t.name);
|
|
1111
|
+
}
|
|
1112
|
+
//#endregion
|
|
1113
|
+
//#region src/viewport.ts
|
|
1114
|
+
var Pt = "(max-width: 400px), (max-height: 420px)", Ft = "data-fit-visible", It = 40;
|
|
1115
|
+
function Lt(e) {
|
|
1116
|
+
let t = typeof window < "u" ? window.visualViewport : null;
|
|
1117
|
+
if (!t) return () => {};
|
|
1118
|
+
let n = () => {
|
|
1119
|
+
e.removeAttribute(Ft), e.style.removeProperty("--whoo-widget-visible-top"), e.style.removeProperty("--whoo-widget-visible-height");
|
|
1120
|
+
}, r = () => {
|
|
1121
|
+
let r = document.documentElement.clientHeight, i = Math.abs(t.scale - 1) > .01, a = r - t.height;
|
|
1122
|
+
if (i || r === 0 || a < It) {
|
|
1123
|
+
n();
|
|
1124
|
+
return;
|
|
1125
|
+
}
|
|
1126
|
+
e.setAttribute(Ft, ""), e.style.setProperty("--whoo-widget-visible-top", `${Math.max(0, t.offsetTop)}px`), e.style.setProperty("--whoo-widget-visible-height", `${t.height}px`);
|
|
1127
|
+
};
|
|
1128
|
+
return r(), t.addEventListener("resize", r), t.addEventListener("scroll", r), () => {
|
|
1129
|
+
t.removeEventListener("resize", r), t.removeEventListener("scroll", r), n();
|
|
1130
|
+
};
|
|
1131
|
+
}
|
|
1132
|
+
function Rt(e, t) {
|
|
1133
|
+
return typeof e.addEventListener == "function" ? (e.addEventListener("change", t), () => e.removeEventListener("change", t)) : typeof e.addListener == "function" ? (e.addListener(t), () => e.removeListener(t)) : () => {};
|
|
1134
|
+
}
|
|
1135
|
+
var zt = 0, Bt = "";
|
|
1136
|
+
function Vt() {
|
|
1137
|
+
zt++ === 0 && (Bt = document.documentElement.style.overflow, document.documentElement.style.overflow = "hidden");
|
|
1138
|
+
}
|
|
1139
|
+
function Ht() {
|
|
1140
|
+
--zt === 0 && (document.documentElement.style.overflow = Bt);
|
|
1141
|
+
}
|
|
1142
|
+
function Ut() {
|
|
1143
|
+
if (typeof window > "u" || typeof window.matchMedia != "function") return () => {};
|
|
1144
|
+
let e = window.matchMedia(Pt), t = !1, n = () => {
|
|
1145
|
+
e.matches && !t ? (t = !0, Vt()) : !e.matches && t && (t = !1, Ht());
|
|
1146
|
+
};
|
|
1147
|
+
n();
|
|
1148
|
+
let r = Rt(e, n);
|
|
1149
|
+
return () => {
|
|
1150
|
+
r(), t && (t = !1, Ht());
|
|
1151
|
+
};
|
|
1152
|
+
}
|
|
1153
|
+
function Wt(e) {
|
|
1154
|
+
if (typeof window > "u" || typeof window.matchMedia != "function" || typeof e.showModal != "function") return () => {};
|
|
1155
|
+
let t = window.matchMedia(Pt), n = !1, r = () => {
|
|
1156
|
+
if (t.matches === n || !e.isConnected) return;
|
|
1157
|
+
n = t.matches;
|
|
1158
|
+
let r = e.getRootNode().activeElement;
|
|
1159
|
+
e.close(), n ? e.showModal() : e.show(), r && e.contains(r) && r.focus({ preventScroll: !0 });
|
|
1160
|
+
};
|
|
1161
|
+
return r(), Rt(t, r);
|
|
1162
|
+
}
|
|
1163
|
+
//#endregion
|
|
734
1164
|
//#region src/components/Composer.tsx
|
|
735
|
-
function
|
|
1165
|
+
function Gt({ value: t, onChange: n, onSend: r, disabled: i, inputRef: a, text: o = e }) {
|
|
736
1166
|
return /* @__PURE__ */ U("div", {
|
|
737
1167
|
class: "whoo-widget-composer",
|
|
738
1168
|
children: [
|
|
739
1169
|
/* @__PURE__ */ U("label", {
|
|
740
1170
|
class: "whoo-widget-sr-only",
|
|
741
1171
|
for: "whoo-widget-composer-input",
|
|
742
|
-
children:
|
|
1172
|
+
children: o.message
|
|
743
1173
|
}),
|
|
744
1174
|
/* @__PURE__ */ U("input", {
|
|
745
1175
|
id: "whoo-widget-composer-input",
|
|
746
1176
|
class: "whoo-widget-composer-input",
|
|
747
|
-
value:
|
|
748
|
-
readOnly:
|
|
749
|
-
"aria-disabled":
|
|
750
|
-
ref:
|
|
751
|
-
onInput: (e) =>
|
|
1177
|
+
value: t,
|
|
1178
|
+
readOnly: i,
|
|
1179
|
+
"aria-disabled": i,
|
|
1180
|
+
ref: a,
|
|
1181
|
+
onInput: (e) => n(e.target.value),
|
|
752
1182
|
onKeyDown: (e) => {
|
|
753
|
-
e.key === "Enter" &&
|
|
1183
|
+
e.key === "Enter" && r();
|
|
754
1184
|
}
|
|
755
1185
|
}),
|
|
756
1186
|
/* @__PURE__ */ U("button", {
|
|
757
1187
|
type: "button",
|
|
758
1188
|
class: "whoo-widget-composer-send",
|
|
759
|
-
"aria-disabled":
|
|
1189
|
+
"aria-disabled": i,
|
|
760
1190
|
onClick: () => {
|
|
761
|
-
|
|
1191
|
+
i || r();
|
|
762
1192
|
},
|
|
763
|
-
children:
|
|
1193
|
+
children: o.send
|
|
764
1194
|
})
|
|
765
1195
|
]
|
|
766
1196
|
});
|
|
767
1197
|
}
|
|
768
1198
|
//#endregion
|
|
769
1199
|
//#region src/components/ErrorBanner.tsx
|
|
770
|
-
function
|
|
1200
|
+
function Kt({ message: e }) {
|
|
771
1201
|
return /* @__PURE__ */ U("div", {
|
|
772
1202
|
class: "whoo-widget-error-banner",
|
|
773
1203
|
role: "alert",
|
|
@@ -776,8 +1206,8 @@ function vt({ message: e }) {
|
|
|
776
1206
|
}
|
|
777
1207
|
//#endregion
|
|
778
1208
|
//#region src/markdown/tokenizer.ts
|
|
779
|
-
var
|
|
780
|
-
function
|
|
1209
|
+
var qt = /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y, Jt = /\*\*([^*\s](?:[^*]*[^*\s])?)\*\*/y, Yt = /(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y, Xt = /\*([^*\s](?:[^*]*[^*\s])?)\*/y, Zt = /[ \t]*[*+-][ \t]+/y, Qt = /https?:\/\/\S+/y, $t = /[.,;:!?)\]}>]+$/;
|
|
1210
|
+
function en(e) {
|
|
781
1211
|
let t = [], n = 0, r = 0, i = (n) => {
|
|
782
1212
|
n > r && t.push({
|
|
783
1213
|
type: "text",
|
|
@@ -787,13 +1217,13 @@ function Et(e) {
|
|
|
787
1217
|
});
|
|
788
1218
|
};
|
|
789
1219
|
for (; n < e.length;) {
|
|
790
|
-
if ((n === 0 || e[n - 1] === "\n") && (
|
|
1220
|
+
if ((n === 0 || e[n - 1] === "\n") && (Zt.lastIndex = n, Zt.exec(e))) {
|
|
791
1221
|
i(n), t.push({
|
|
792
1222
|
type: "text",
|
|
793
1223
|
value: "• ",
|
|
794
1224
|
start: n,
|
|
795
|
-
end:
|
|
796
|
-
}), n =
|
|
1225
|
+
end: Zt.lastIndex
|
|
1226
|
+
}), n = Zt.lastIndex, r = n;
|
|
797
1227
|
continue;
|
|
798
1228
|
}
|
|
799
1229
|
if (e[n] === "!" && n + 1 < e.length && e[n + 1] === "[") {
|
|
@@ -806,56 +1236,56 @@ function Et(e) {
|
|
|
806
1236
|
}
|
|
807
1237
|
}
|
|
808
1238
|
if (e[n - 1] !== "!") {
|
|
809
|
-
|
|
810
|
-
let a =
|
|
1239
|
+
qt.lastIndex = n;
|
|
1240
|
+
let a = qt.exec(e);
|
|
811
1241
|
if (a) {
|
|
812
1242
|
i(n), t.push({
|
|
813
1243
|
type: "link",
|
|
814
1244
|
text: a[1],
|
|
815
1245
|
url: a[2],
|
|
816
1246
|
start: n,
|
|
817
|
-
end:
|
|
818
|
-
}), n =
|
|
1247
|
+
end: qt.lastIndex
|
|
1248
|
+
}), n = qt.lastIndex, r = n;
|
|
819
1249
|
continue;
|
|
820
1250
|
}
|
|
821
1251
|
}
|
|
822
|
-
|
|
823
|
-
let a =
|
|
1252
|
+
Jt.lastIndex = n;
|
|
1253
|
+
let a = Jt.exec(e);
|
|
824
1254
|
if (a) {
|
|
825
1255
|
i(n), t.push({
|
|
826
1256
|
type: "bold",
|
|
827
1257
|
value: a[1],
|
|
828
1258
|
start: n,
|
|
829
|
-
end:
|
|
830
|
-
}), n =
|
|
1259
|
+
end: Jt.lastIndex
|
|
1260
|
+
}), n = Jt.lastIndex, r = n;
|
|
831
1261
|
continue;
|
|
832
1262
|
}
|
|
833
|
-
|
|
834
|
-
let o =
|
|
1263
|
+
Yt.lastIndex = n;
|
|
1264
|
+
let o = Yt.exec(e);
|
|
835
1265
|
if (o) {
|
|
836
1266
|
i(n), t.push({
|
|
837
1267
|
type: "italic",
|
|
838
1268
|
value: o[1],
|
|
839
1269
|
start: n,
|
|
840
|
-
end:
|
|
841
|
-
}), n =
|
|
1270
|
+
end: Yt.lastIndex
|
|
1271
|
+
}), n = Yt.lastIndex, r = n;
|
|
842
1272
|
continue;
|
|
843
1273
|
}
|
|
844
|
-
|
|
845
|
-
let s =
|
|
1274
|
+
Xt.lastIndex = n;
|
|
1275
|
+
let s = Xt.exec(e);
|
|
846
1276
|
if (s) {
|
|
847
1277
|
i(n), t.push({
|
|
848
1278
|
type: "italic",
|
|
849
1279
|
value: s[1],
|
|
850
1280
|
start: n,
|
|
851
|
-
end:
|
|
852
|
-
}), n =
|
|
1281
|
+
end: Xt.lastIndex
|
|
1282
|
+
}), n = Xt.lastIndex, r = n;
|
|
853
1283
|
continue;
|
|
854
1284
|
}
|
|
855
|
-
|
|
856
|
-
let c =
|
|
1285
|
+
Qt.lastIndex = n;
|
|
1286
|
+
let c = Qt.exec(e);
|
|
857
1287
|
if (c) {
|
|
858
|
-
let e = c[0].match(
|
|
1288
|
+
let e = c[0].match($t), a = e ? c[0].slice(0, c[0].length - e[0].length) : c[0];
|
|
859
1289
|
if (a.length > 0) {
|
|
860
1290
|
i(n), t.push({
|
|
861
1291
|
type: "link",
|
|
@@ -873,8 +1303,8 @@ function Et(e) {
|
|
|
873
1303
|
}
|
|
874
1304
|
//#endregion
|
|
875
1305
|
//#region src/markdown/render.tsx
|
|
876
|
-
var
|
|
877
|
-
function
|
|
1306
|
+
var tn = /^[ \t]*[*+-][ \t]+(.*)$/;
|
|
1307
|
+
function nn(e) {
|
|
878
1308
|
let t = [], n = [], r = [], i = () => {
|
|
879
1309
|
n.length > 0 && t.push({
|
|
880
1310
|
type: "text",
|
|
@@ -887,7 +1317,7 @@ function Ot(e) {
|
|
|
887
1317
|
}), r = [];
|
|
888
1318
|
};
|
|
889
1319
|
for (let t of e.split("\n")) {
|
|
890
|
-
let e = t.match(
|
|
1320
|
+
let e = t.match(tn);
|
|
891
1321
|
e ? (i(), r.push(e[1])) : (a(), n.push(t));
|
|
892
1322
|
}
|
|
893
1323
|
return i(), a(), t.some((e) => e.type === "list") ? t.flatMap((e, n) => {
|
|
@@ -900,7 +1330,7 @@ function Ot(e) {
|
|
|
900
1330
|
}) : null;
|
|
901
1331
|
}
|
|
902
1332
|
function G(e) {
|
|
903
|
-
return
|
|
1333
|
+
return en(e).map((e, t) => {
|
|
904
1334
|
switch (e.type) {
|
|
905
1335
|
case "bold": return /* @__PURE__ */ U("strong", { children: G(e.value) }, t);
|
|
906
1336
|
case "italic": return /* @__PURE__ */ U("em", { children: G(e.value) }, t);
|
|
@@ -917,8 +1347,8 @@ function G(e) {
|
|
|
917
1347
|
}
|
|
918
1348
|
});
|
|
919
1349
|
}
|
|
920
|
-
function
|
|
921
|
-
let t = e.replace(/\r\n?/g, "\n"), n =
|
|
1350
|
+
function rn(e) {
|
|
1351
|
+
let t = e.replace(/\r\n?/g, "\n"), n = nn(t);
|
|
922
1352
|
return n ? n.map((e, t) => e.type === "list" ? /* @__PURE__ */ U("ul", {
|
|
923
1353
|
class: "whoo-widget-list",
|
|
924
1354
|
children: e.items.map((e, t) => /* @__PURE__ */ U("li", { children: G(e) }, t))
|
|
@@ -926,64 +1356,66 @@ function kt(e) {
|
|
|
926
1356
|
}
|
|
927
1357
|
//#endregion
|
|
928
1358
|
//#region src/components/MessageFeedback.tsx
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
1359
|
+
function an(e) {
|
|
1360
|
+
return [
|
|
1361
|
+
{
|
|
1362
|
+
value: "",
|
|
1363
|
+
label: e.selectReason
|
|
1364
|
+
},
|
|
1365
|
+
{
|
|
1366
|
+
value: "factual",
|
|
1367
|
+
label: e.categoryFactual
|
|
1368
|
+
},
|
|
1369
|
+
{
|
|
1370
|
+
value: "incomplete",
|
|
1371
|
+
label: e.categoryIncomplete
|
|
1372
|
+
},
|
|
1373
|
+
{
|
|
1374
|
+
value: "tone",
|
|
1375
|
+
label: e.categoryTone
|
|
1376
|
+
},
|
|
1377
|
+
{
|
|
1378
|
+
value: "other",
|
|
1379
|
+
label: e.categoryOther
|
|
1380
|
+
}
|
|
1381
|
+
];
|
|
1382
|
+
}
|
|
1383
|
+
function on({ state: t, containerRef: n, onThumbsUp: r, onThumbsDown: i, onDraftChange: a, onSubmitDetailed: o, onCancel: s, text: c = e }) {
|
|
1384
|
+
let l = t.correction ?? "", u = t.category ?? "", d = V(t.status), f = V(null), p = V(null);
|
|
1385
|
+
if (nt(() => {
|
|
1386
|
+
let e = d.current;
|
|
1387
|
+
if (d.current = t.status, e === t.status) return;
|
|
1388
|
+
if (t.status === "expanded") {
|
|
1389
|
+
f.current?.focus();
|
|
958
1390
|
return;
|
|
959
1391
|
}
|
|
960
|
-
if (
|
|
961
|
-
|
|
1392
|
+
if (e === "expanded" && t.status === "idle") {
|
|
1393
|
+
p.current?.focus();
|
|
962
1394
|
return;
|
|
963
1395
|
}
|
|
964
|
-
let r =
|
|
1396
|
+
let r = n?.current;
|
|
965
1397
|
if (!r) return;
|
|
966
1398
|
let i = r.getRootNode();
|
|
967
1399
|
r.contains(i.activeElement) || r.focus();
|
|
968
|
-
}, [
|
|
1400
|
+
}, [t.status, n]), t.status === "expanded") return /* @__PURE__ */ U("div", {
|
|
969
1401
|
class: "whoo-widget-feedback-form",
|
|
970
1402
|
children: [
|
|
971
1403
|
/* @__PURE__ */ U("label", { children: [/* @__PURE__ */ U("span", {
|
|
972
1404
|
class: "whoo-widget-sr-only",
|
|
973
|
-
children:
|
|
1405
|
+
children: c.additionalFeedback
|
|
974
1406
|
}), /* @__PURE__ */ U("textarea", {
|
|
975
|
-
ref:
|
|
1407
|
+
ref: f,
|
|
976
1408
|
class: "whoo-widget-feedback-textarea",
|
|
977
|
-
value:
|
|
978
|
-
onInput: (e) =>
|
|
979
|
-
placeholder:
|
|
1409
|
+
value: l,
|
|
1410
|
+
onInput: (e) => a(e.target.value, u),
|
|
1411
|
+
placeholder: c.feedbackPlaceholder
|
|
980
1412
|
})] }),
|
|
981
1413
|
/* @__PURE__ */ U("select", {
|
|
982
1414
|
class: "whoo-widget-feedback-select",
|
|
983
|
-
"aria-label":
|
|
984
|
-
value:
|
|
985
|
-
onChange: (e) =>
|
|
986
|
-
children:
|
|
1415
|
+
"aria-label": c.feedbackCategory,
|
|
1416
|
+
value: u,
|
|
1417
|
+
onChange: (e) => a(l, e.target.value),
|
|
1418
|
+
children: an(c).map((e) => /* @__PURE__ */ U("option", {
|
|
987
1419
|
value: e.value,
|
|
988
1420
|
children: e.label
|
|
989
1421
|
}, e.value))
|
|
@@ -993,46 +1425,46 @@ function jt({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onDraft
|
|
|
993
1425
|
children: [/* @__PURE__ */ U("button", {
|
|
994
1426
|
type: "button",
|
|
995
1427
|
class: "whoo-widget-feedback-submit",
|
|
996
|
-
onClick: () =>
|
|
997
|
-
children:
|
|
1428
|
+
onClick: () => o(l, u),
|
|
1429
|
+
children: c.submit
|
|
998
1430
|
}), /* @__PURE__ */ U("button", {
|
|
999
1431
|
type: "button",
|
|
1000
1432
|
class: "whoo-widget-feedback-cancel",
|
|
1001
|
-
onClick:
|
|
1002
|
-
children:
|
|
1433
|
+
onClick: s,
|
|
1434
|
+
children: c.cancel
|
|
1003
1435
|
})]
|
|
1004
1436
|
})
|
|
1005
1437
|
]
|
|
1006
1438
|
});
|
|
1007
|
-
let
|
|
1439
|
+
let m = t.status === "submitting", h = t.status === "submitted";
|
|
1008
1440
|
return /* @__PURE__ */ U("div", {
|
|
1009
1441
|
class: "whoo-widget-feedback",
|
|
1010
|
-
children: [
|
|
1442
|
+
children: [h ? null : /* @__PURE__ */ U("div", {
|
|
1011
1443
|
class: "whoo-widget-feedback-buttons",
|
|
1012
1444
|
children: [/* @__PURE__ */ U("button", {
|
|
1013
1445
|
type: "button",
|
|
1014
|
-
"aria-label":
|
|
1015
|
-
disabled:
|
|
1016
|
-
onClick:
|
|
1017
|
-
children: /* @__PURE__ */ U(
|
|
1446
|
+
"aria-label": c.goodResponse,
|
|
1447
|
+
disabled: m,
|
|
1448
|
+
onClick: r,
|
|
1449
|
+
children: /* @__PURE__ */ U(vt, {})
|
|
1018
1450
|
}), /* @__PURE__ */ U("button", {
|
|
1019
|
-
ref:
|
|
1451
|
+
ref: p,
|
|
1020
1452
|
type: "button",
|
|
1021
|
-
"aria-label":
|
|
1022
|
-
disabled:
|
|
1023
|
-
onClick:
|
|
1024
|
-
children: /* @__PURE__ */ U(
|
|
1453
|
+
"aria-label": c.badResponse,
|
|
1454
|
+
disabled: m,
|
|
1455
|
+
onClick: i,
|
|
1456
|
+
children: /* @__PURE__ */ U(yt, {})
|
|
1025
1457
|
})]
|
|
1026
1458
|
}), /* @__PURE__ */ U("div", {
|
|
1027
1459
|
role: "status",
|
|
1028
|
-
class:
|
|
1029
|
-
children:
|
|
1460
|
+
class: h ? "whoo-widget-feedback-submitted" : t.status === "error" ? "whoo-widget-feedback-error" : void 0,
|
|
1461
|
+
children: h ? c.feedbackThanks : t.status === "error" ? c.feedbackFailed : null
|
|
1030
1462
|
})]
|
|
1031
1463
|
});
|
|
1032
1464
|
}
|
|
1033
1465
|
//#endregion
|
|
1034
1466
|
//#region src/components/MessageList.tsx
|
|
1035
|
-
function
|
|
1467
|
+
function sn({ isSlowResponse: e, text: t }) {
|
|
1036
1468
|
return /* @__PURE__ */ U("div", {
|
|
1037
1469
|
class: "whoo-widget-pending",
|
|
1038
1470
|
role: "status",
|
|
@@ -1046,12 +1478,12 @@ function Mt({ isSlowResponse: e }) {
|
|
|
1046
1478
|
]
|
|
1047
1479
|
}), e ? /* @__PURE__ */ U("span", {
|
|
1048
1480
|
class: "whoo-widget-pending-text",
|
|
1049
|
-
children:
|
|
1481
|
+
children: t.lookingItUp
|
|
1050
1482
|
}) : null]
|
|
1051
1483
|
});
|
|
1052
1484
|
}
|
|
1053
|
-
function
|
|
1054
|
-
let [n, r] =
|
|
1485
|
+
function cn({ url: e, alt: t }) {
|
|
1486
|
+
let [n, r] = $e(!1);
|
|
1055
1487
|
return n ? null : /* @__PURE__ */ U("img", {
|
|
1056
1488
|
class: "whoo-widget-empty-state-image",
|
|
1057
1489
|
src: e,
|
|
@@ -1060,10 +1492,10 @@ function Nt({ url: e, alt: t }) {
|
|
|
1060
1492
|
onError: () => r(!0)
|
|
1061
1493
|
});
|
|
1062
1494
|
}
|
|
1063
|
-
function
|
|
1064
|
-
let
|
|
1495
|
+
function ln({ message: e, speaker: t, feedbackState: n, showFeedback: r, pending: i, isSlowResponse: a, onThumbsUp: o, onThumbsDown: s, onDraftChange: c, onSubmitDetailed: l, onCancelFeedback: u, text: d }) {
|
|
1496
|
+
let f = V(null), p = e.id;
|
|
1065
1497
|
return /* @__PURE__ */ U("div", {
|
|
1066
|
-
ref:
|
|
1498
|
+
ref: f,
|
|
1067
1499
|
tabIndex: -1,
|
|
1068
1500
|
class: `whoo-widget-message whoo-widget-message--${e.role}`,
|
|
1069
1501
|
children: [
|
|
@@ -1071,72 +1503,86 @@ function Pt({ message: e, speaker: t, feedbackState: n, showFeedback: r, pending
|
|
|
1071
1503
|
class: "whoo-widget-sr-only",
|
|
1072
1504
|
children: [t, ": "]
|
|
1073
1505
|
}),
|
|
1074
|
-
i ? /* @__PURE__ */ U(
|
|
1075
|
-
|
|
1506
|
+
i ? /* @__PURE__ */ U(sn, {
|
|
1507
|
+
isSlowResponse: a,
|
|
1508
|
+
text: d
|
|
1509
|
+
}) : /* @__PURE__ */ U("div", {
|
|
1510
|
+
class: "whoo-widget-message-text",
|
|
1511
|
+
dir: "auto",
|
|
1512
|
+
children: rn(e.content)
|
|
1513
|
+
}),
|
|
1514
|
+
r && e.role === "assistant" && p ? /* @__PURE__ */ U(on, {
|
|
1076
1515
|
state: n,
|
|
1077
|
-
containerRef:
|
|
1078
|
-
onThumbsUp: () => o(
|
|
1079
|
-
onThumbsDown: () => s(
|
|
1080
|
-
onDraftChange: (e, t) => c(
|
|
1081
|
-
onSubmitDetailed: (e, t) => l(
|
|
1082
|
-
onCancel: () => u(
|
|
1516
|
+
containerRef: f,
|
|
1517
|
+
onThumbsUp: () => o(p),
|
|
1518
|
+
onThumbsDown: () => s(p),
|
|
1519
|
+
onDraftChange: (e, t) => c(p, e, t),
|
|
1520
|
+
onSubmitDetailed: (e, t) => l(p, e, t),
|
|
1521
|
+
onCancel: () => u(p),
|
|
1522
|
+
text: d
|
|
1083
1523
|
}) : null
|
|
1084
1524
|
]
|
|
1085
1525
|
});
|
|
1086
1526
|
}
|
|
1087
|
-
function
|
|
1088
|
-
let
|
|
1089
|
-
return
|
|
1090
|
-
let e =
|
|
1527
|
+
function un({ messages: t, messageFeedback: n, announcement: r, emptyStateImage: i, agentName: a = l, showFeedback: o = !1, isStreaming: s = !1, isSlowResponse: c = !1, onThumbsUp: u, onThumbsDown: d, onDraftChange: f = () => {}, onSubmitDetailed: p, onCancelFeedback: m, text: h = e }) {
|
|
1528
|
+
let g = V(null);
|
|
1529
|
+
return tt(() => {
|
|
1530
|
+
let e = g.current;
|
|
1091
1531
|
e && (e.scrollTop = e.scrollHeight);
|
|
1092
|
-
}, [
|
|
1532
|
+
}, [t, c]), /* @__PURE__ */ U(I, { children: [/* @__PURE__ */ U("section", {
|
|
1093
1533
|
class: "whoo-widget-message-list",
|
|
1094
|
-
ref:
|
|
1095
|
-
"aria-label":
|
|
1534
|
+
ref: g,
|
|
1535
|
+
"aria-label": h.conversation,
|
|
1096
1536
|
tabIndex: 0,
|
|
1097
|
-
children: [
|
|
1098
|
-
message:
|
|
1099
|
-
speaker:
|
|
1100
|
-
showFeedback:
|
|
1101
|
-
feedbackState:
|
|
1102
|
-
pending:
|
|
1537
|
+
children: [i ? /* @__PURE__ */ U(cn, { ...i }) : null, t.map((e, r) => /* @__PURE__ */ U(ln, {
|
|
1538
|
+
message: e,
|
|
1539
|
+
speaker: e.role === "user" ? h.you : a,
|
|
1540
|
+
showFeedback: o,
|
|
1541
|
+
feedbackState: e.id ? n[e.id] ?? { status: "idle" } : { status: "idle" },
|
|
1542
|
+
pending: s && r === t.length - 1 && e.role === "assistant" && e.content === "",
|
|
1103
1543
|
isSlowResponse: c,
|
|
1104
|
-
onThumbsUp:
|
|
1105
|
-
onThumbsDown:
|
|
1106
|
-
onDraftChange:
|
|
1107
|
-
onSubmitDetailed:
|
|
1108
|
-
onCancelFeedback:
|
|
1109
|
-
|
|
1544
|
+
onThumbsUp: u,
|
|
1545
|
+
onThumbsDown: d,
|
|
1546
|
+
onDraftChange: f,
|
|
1547
|
+
onSubmitDetailed: p,
|
|
1548
|
+
onCancelFeedback: m,
|
|
1549
|
+
text: h
|
|
1550
|
+
}, e.id ?? r))]
|
|
1110
1551
|
}), /* @__PURE__ */ U("div", {
|
|
1111
1552
|
class: "whoo-widget-sr-only",
|
|
1112
1553
|
"aria-live": "polite",
|
|
1113
1554
|
"aria-atomic": "true",
|
|
1114
|
-
children:
|
|
1555
|
+
children: r ?? ""
|
|
1115
1556
|
})] });
|
|
1116
1557
|
}
|
|
1117
1558
|
//#endregion
|
|
1118
1559
|
//#region src/components/Panel.tsx
|
|
1119
|
-
var
|
|
1120
|
-
function
|
|
1121
|
-
return Array.from(e.querySelectorAll(
|
|
1560
|
+
var dn = "button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
|
|
1561
|
+
function fn(e) {
|
|
1562
|
+
return Array.from(e.querySelectorAll(dn)).filter((e) => {
|
|
1122
1563
|
let t = getComputedStyle(e);
|
|
1123
1564
|
return t.display !== "none" && t.visibility !== "hidden";
|
|
1124
1565
|
});
|
|
1125
1566
|
}
|
|
1126
|
-
function
|
|
1567
|
+
function pn({ state: e, controller: t, greeting: n }) {
|
|
1127
1568
|
let r = V(null), i = V(null);
|
|
1128
|
-
|
|
1569
|
+
nt(() => {
|
|
1129
1570
|
i.current?.focus();
|
|
1571
|
+
}, []), nt(() => {
|
|
1572
|
+
let e = r.current, t = e ? Lt(e) : () => {}, n = e ? Wt(e) : () => {}, i = Ut();
|
|
1573
|
+
return () => {
|
|
1574
|
+
t(), n(), i();
|
|
1575
|
+
};
|
|
1130
1576
|
}, []);
|
|
1131
1577
|
let a = (e) => {
|
|
1132
1578
|
if (e.key === "Escape") {
|
|
1133
|
-
t.close();
|
|
1579
|
+
e.preventDefault(), t.close();
|
|
1134
1580
|
return;
|
|
1135
1581
|
}
|
|
1136
1582
|
if (e.key !== "Tab") return;
|
|
1137
1583
|
let n = r.current;
|
|
1138
1584
|
if (!n) return;
|
|
1139
|
-
let i =
|
|
1585
|
+
let i = fn(n);
|
|
1140
1586
|
if (i.length === 0) return;
|
|
1141
1587
|
let a = i[0], o = i[i.length - 1], s = n.getRootNode().activeElement;
|
|
1142
1588
|
if (!n.contains(s)) {
|
|
@@ -1147,7 +1593,7 @@ function Rt({ state: e, controller: t, greeting: n }) {
|
|
|
1147
1593
|
}, o = () => {
|
|
1148
1594
|
let n = e.draft.trim();
|
|
1149
1595
|
n && !e.isStreaming && (t.setDraft(""), t.sendMessage(n));
|
|
1150
|
-
}, s =
|
|
1596
|
+
}, s = u(t.config.name) || e.agentName || "Aiden", c = u(t.config.title) || Nt(t.text.chatWith, { name: s }), l = e.messages.length === 0 && n ? [{
|
|
1151
1597
|
role: "assistant",
|
|
1152
1598
|
content: n,
|
|
1153
1599
|
id: null
|
|
@@ -1155,19 +1601,22 @@ function Rt({ state: e, controller: t, greeting: n }) {
|
|
|
1155
1601
|
url: d,
|
|
1156
1602
|
alt: t.emptyStateImageAlt
|
|
1157
1603
|
} : void 0;
|
|
1158
|
-
return /* @__PURE__ */ U("
|
|
1604
|
+
return /* @__PURE__ */ U("dialog", {
|
|
1605
|
+
open: !0,
|
|
1159
1606
|
class: "whoo-widget-panel",
|
|
1160
|
-
role: "dialog",
|
|
1161
1607
|
"aria-modal": "true",
|
|
1162
|
-
"aria-label":
|
|
1608
|
+
"aria-label": c,
|
|
1163
1609
|
ref: r,
|
|
1164
1610
|
onKeyDown: a,
|
|
1611
|
+
onCancel: (e) => {
|
|
1612
|
+
e.preventDefault(), t.close();
|
|
1613
|
+
},
|
|
1165
1614
|
children: [
|
|
1166
1615
|
/* @__PURE__ */ U("div", {
|
|
1167
1616
|
class: "whoo-widget-header",
|
|
1168
1617
|
children: [/* @__PURE__ */ U("h2", {
|
|
1169
1618
|
class: "whoo-widget-header-title",
|
|
1170
|
-
children:
|
|
1619
|
+
children: c
|
|
1171
1620
|
}), /* @__PURE__ */ U("div", {
|
|
1172
1621
|
class: "whoo-widget-header-actions",
|
|
1173
1622
|
children: [e.messages.length > 0 && /* @__PURE__ */ U("button", {
|
|
@@ -1176,18 +1625,18 @@ function Rt({ state: e, controller: t, greeting: n }) {
|
|
|
1176
1625
|
onClick: () => {
|
|
1177
1626
|
t.resetConversation(), i.current?.focus();
|
|
1178
1627
|
},
|
|
1179
|
-
children:
|
|
1628
|
+
children: t.text.newConversation
|
|
1180
1629
|
}), /* @__PURE__ */ U("button", {
|
|
1181
1630
|
type: "button",
|
|
1182
1631
|
class: "whoo-widget-header-close",
|
|
1183
|
-
"aria-label":
|
|
1632
|
+
"aria-label": t.text.closeChat,
|
|
1184
1633
|
onClick: () => t.close(),
|
|
1185
|
-
children: /* @__PURE__ */ U(
|
|
1634
|
+
children: /* @__PURE__ */ U(gt, {})
|
|
1186
1635
|
})]
|
|
1187
1636
|
})]
|
|
1188
1637
|
}),
|
|
1189
|
-
/* @__PURE__ */ U(
|
|
1190
|
-
messages:
|
|
1638
|
+
/* @__PURE__ */ U(un, {
|
|
1639
|
+
messages: l,
|
|
1191
1640
|
messageFeedback: e.messageFeedback,
|
|
1192
1641
|
announcement: e.announcement,
|
|
1193
1642
|
emptyStateImage: f,
|
|
@@ -1199,34 +1648,37 @@ function Rt({ state: e, controller: t, greeting: n }) {
|
|
|
1199
1648
|
onThumbsDown: (e) => t.expandFeedback(e),
|
|
1200
1649
|
onDraftChange: (e, n, r) => t.setFeedbackDraft(e, n, r),
|
|
1201
1650
|
onSubmitDetailed: (e, n, r) => t.submitFeedback(e, "down", n || void 0, r || void 0),
|
|
1202
|
-
onCancelFeedback: (e) => t.cancelFeedback(e)
|
|
1651
|
+
onCancelFeedback: (e) => t.cancelFeedback(e),
|
|
1652
|
+
text: t.text
|
|
1203
1653
|
}),
|
|
1204
|
-
e.runtimeError && /* @__PURE__ */ U(
|
|
1205
|
-
/* @__PURE__ */ U(
|
|
1654
|
+
e.runtimeError && /* @__PURE__ */ U(Kt, { message: e.runtimeError }),
|
|
1655
|
+
/* @__PURE__ */ U(Gt, {
|
|
1206
1656
|
value: e.draft,
|
|
1207
1657
|
onChange: (e) => t.setDraft(e),
|
|
1208
1658
|
onSend: o,
|
|
1209
1659
|
disabled: e.isStreaming,
|
|
1210
|
-
inputRef: i
|
|
1660
|
+
inputRef: i,
|
|
1661
|
+
text: t.text
|
|
1211
1662
|
})
|
|
1212
1663
|
]
|
|
1213
1664
|
});
|
|
1214
1665
|
}
|
|
1215
1666
|
//#endregion
|
|
1216
1667
|
//#region src/components/App.tsx
|
|
1217
|
-
function
|
|
1218
|
-
let [t, n] =
|
|
1219
|
-
return
|
|
1668
|
+
function mn({ controller: e }) {
|
|
1669
|
+
let [t, n] = $e(e.getState()), r = V(null), i = V(t.isOpen);
|
|
1670
|
+
return tt(() => (n(e.getState()), e.subscribe(n)), [e]), tt(() => {
|
|
1220
1671
|
i.current && !t.isOpen && r.current?.focus(), i.current = t.isOpen;
|
|
1221
|
-
}, [t.isOpen]), t.initError || t.isInitializing ? null : /* @__PURE__ */ U(
|
|
1672
|
+
}, [t.isOpen]), t.initError || t.isInitializing ? null : /* @__PURE__ */ U(I, { children: [/* @__PURE__ */ U(St, {
|
|
1222
1673
|
isOpen: t.isOpen,
|
|
1223
1674
|
onClick: () => t.isOpen ? e.close() : e.open(),
|
|
1224
1675
|
iconUrl: e.launcher.iconUrl,
|
|
1225
1676
|
icon: e.launcher.icon,
|
|
1226
1677
|
openIconUrl: e.launcher.openIconUrl,
|
|
1227
1678
|
openIcon: e.launcher.openIcon,
|
|
1228
|
-
buttonRef: r
|
|
1229
|
-
|
|
1679
|
+
buttonRef: r,
|
|
1680
|
+
text: e.text
|
|
1681
|
+
}), t.isOpen && /* @__PURE__ */ U(pn, {
|
|
1230
1682
|
state: t,
|
|
1231
1683
|
controller: e,
|
|
1232
1684
|
greeting: e.config.greeting
|
|
@@ -1234,44 +1686,44 @@ function zt({ controller: e }) {
|
|
|
1234
1686
|
}
|
|
1235
1687
|
//#endregion
|
|
1236
1688
|
//#region src/api/client.ts
|
|
1237
|
-
var
|
|
1689
|
+
var hn = class extends Error {
|
|
1238
1690
|
status;
|
|
1239
1691
|
constructor(e, t) {
|
|
1240
1692
|
super(e), this.name = "WidgetApiError", this.status = t;
|
|
1241
1693
|
}
|
|
1242
1694
|
};
|
|
1243
|
-
function
|
|
1695
|
+
function gn(e) {
|
|
1244
1696
|
if (typeof e != "string") return null;
|
|
1245
1697
|
let t = e.trim();
|
|
1246
1698
|
return t === "" ? null : t;
|
|
1247
1699
|
}
|
|
1248
|
-
async function
|
|
1700
|
+
async function _n(e, t) {
|
|
1249
1701
|
let n = await fetch(`${e}/api/v1/widget/session`, {
|
|
1250
1702
|
method: "POST",
|
|
1251
1703
|
headers: { "Content-Type": "application/json" },
|
|
1252
1704
|
body: JSON.stringify({ publishable_key: t })
|
|
1253
1705
|
});
|
|
1254
|
-
if (!n.ok) throw new
|
|
1706
|
+
if (!n.ok) throw new hn(`Failed to create widget session (${n.status})`, n.status);
|
|
1255
1707
|
let r = await n.json();
|
|
1256
1708
|
return {
|
|
1257
1709
|
token: r.token,
|
|
1258
|
-
...
|
|
1710
|
+
...vn(r)
|
|
1259
1711
|
};
|
|
1260
1712
|
}
|
|
1261
|
-
function
|
|
1713
|
+
function vn(e) {
|
|
1262
1714
|
return {
|
|
1263
|
-
primaryColor:
|
|
1264
|
-
name:
|
|
1265
|
-
accentColor:
|
|
1266
|
-
inkColor:
|
|
1715
|
+
primaryColor: gn(e.primary_color),
|
|
1716
|
+
name: gn(e.name),
|
|
1717
|
+
accentColor: gn(e.accent_color),
|
|
1718
|
+
inkColor: gn(e.ink_color)
|
|
1267
1719
|
};
|
|
1268
1720
|
}
|
|
1269
|
-
async function
|
|
1721
|
+
async function yn(e, t) {
|
|
1270
1722
|
let n = await fetch(`${e}/api/v1/widget/branding`, { headers: { Authorization: `Bearer ${t}` } });
|
|
1271
|
-
if (!n.ok) throw new
|
|
1272
|
-
return
|
|
1723
|
+
if (!n.ok) throw new hn(`Failed to load widget branding (${n.status})`, n.status);
|
|
1724
|
+
return vn(await n.json());
|
|
1273
1725
|
}
|
|
1274
|
-
async function
|
|
1726
|
+
async function bn(e, t, n) {
|
|
1275
1727
|
let r = await fetch(`${e}/api/v1/widget/feedback`, {
|
|
1276
1728
|
method: "POST",
|
|
1277
1729
|
headers: {
|
|
@@ -1285,11 +1737,11 @@ async function Gt(e, t, n) {
|
|
|
1285
1737
|
category: n.category ?? null
|
|
1286
1738
|
})
|
|
1287
1739
|
});
|
|
1288
|
-
if (!r.ok) throw new
|
|
1740
|
+
if (!r.ok) throw new hn(`Feedback submission failed (${r.status})`, r.status);
|
|
1289
1741
|
}
|
|
1290
1742
|
//#endregion
|
|
1291
1743
|
//#region src/api/sse.ts
|
|
1292
|
-
async function*
|
|
1744
|
+
async function* xn(e, t, n, r, i) {
|
|
1293
1745
|
let a = await fetch(`${e}/api/v1/widget/chat`, {
|
|
1294
1746
|
method: "POST",
|
|
1295
1747
|
headers: {
|
|
@@ -1302,7 +1754,7 @@ async function* Kt(e, t, n, r, i) {
|
|
|
1302
1754
|
}),
|
|
1303
1755
|
signal: i
|
|
1304
1756
|
});
|
|
1305
|
-
if (!a.ok || !a.body) throw new
|
|
1757
|
+
if (!a.ok || !a.body) throw new hn(`Chat request failed (${a.status})`, a.status);
|
|
1306
1758
|
let o = a.body.getReader(), s = new TextDecoder(), c = "";
|
|
1307
1759
|
for (;;) {
|
|
1308
1760
|
let { done: e, value: t } = await o.read();
|
|
@@ -1313,11 +1765,11 @@ async function* Kt(e, t, n, r, i) {
|
|
|
1313
1765
|
let e = c.slice(0, n);
|
|
1314
1766
|
c = c.slice(n + 2);
|
|
1315
1767
|
let t = e.split("\n").find((e) => e.startsWith("data: "));
|
|
1316
|
-
t && (yield
|
|
1768
|
+
t && (yield Sn(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
|
|
1317
1769
|
}
|
|
1318
1770
|
}
|
|
1319
1771
|
}
|
|
1320
|
-
function
|
|
1772
|
+
function Sn(e) {
|
|
1321
1773
|
return typeof e.error == "string" ? {
|
|
1322
1774
|
type: "error",
|
|
1323
1775
|
error: e.error,
|
|
@@ -1340,11 +1792,11 @@ function qt(e) {
|
|
|
1340
1792
|
}
|
|
1341
1793
|
//#endregion
|
|
1342
1794
|
//#region src/markdown/plainText.ts
|
|
1343
|
-
function
|
|
1344
|
-
return
|
|
1795
|
+
function Cn(e) {
|
|
1796
|
+
return en(e.replace(/\r\n?/g, "\n")).map((e) => {
|
|
1345
1797
|
switch (e.type) {
|
|
1346
1798
|
case "bold":
|
|
1347
|
-
case "italic": return
|
|
1799
|
+
case "italic": return Cn(e.value);
|
|
1348
1800
|
case "link": return e.text;
|
|
1349
1801
|
default: return e.value;
|
|
1350
1802
|
}
|
|
@@ -1352,16 +1804,16 @@ function Jt(e) {
|
|
|
1352
1804
|
}
|
|
1353
1805
|
//#endregion
|
|
1354
1806
|
//#region src/markdown/reveal.ts
|
|
1355
|
-
var
|
|
1356
|
-
function
|
|
1807
|
+
var wn = 40, Tn = 120;
|
|
1808
|
+
function En(e) {
|
|
1357
1809
|
let t = [];
|
|
1358
|
-
for (let n of
|
|
1810
|
+
for (let n of en(e)) if (n.type === "text") {
|
|
1359
1811
|
let e = n.value.split(/(\s+)/), r = n.start;
|
|
1360
1812
|
for (let n of e) r += n.length, n.trim().length > 0 && t.push(r);
|
|
1361
1813
|
} else t.push(n.end);
|
|
1362
1814
|
return t;
|
|
1363
1815
|
}
|
|
1364
|
-
function
|
|
1816
|
+
function Dn(e) {
|
|
1365
1817
|
let t = null;
|
|
1366
1818
|
return e?.addEventListener("abort", () => {
|
|
1367
1819
|
t?.();
|
|
@@ -1376,51 +1828,66 @@ function Qt(e) {
|
|
|
1376
1828
|
});
|
|
1377
1829
|
};
|
|
1378
1830
|
}
|
|
1379
|
-
async function
|
|
1380
|
-
let r = n?.wordIntervalMs ??
|
|
1381
|
-
for (let n of
|
|
1831
|
+
async function On(e, t, n) {
|
|
1832
|
+
let r = n?.wordIntervalMs ?? wn, i = n?.tokenIntervalMs ?? Tn, a = n?.signal, o = en(e), s = new Set(o.filter((e) => e.type !== "text").map((e) => e.end)), c = Dn(a), l = "";
|
|
1833
|
+
for (let n of En(e)) if (a?.aborted || (l = e.slice(0, n), t(l), await c(s.has(n) ? i : r), a?.aborted)) return;
|
|
1382
1834
|
l !== e && t(e);
|
|
1383
1835
|
}
|
|
1384
1836
|
//#endregion
|
|
1385
1837
|
//#region src/sessionToken.ts
|
|
1386
|
-
function
|
|
1387
|
-
let
|
|
1388
|
-
if (
|
|
1389
|
-
let
|
|
1838
|
+
function kn(e) {
|
|
1839
|
+
let t = e.split(".");
|
|
1840
|
+
if (t.length !== 3 || t.some((e) => e === "")) return null;
|
|
1841
|
+
let n = t[1];
|
|
1390
1842
|
try {
|
|
1391
|
-
let e =
|
|
1392
|
-
return
|
|
1843
|
+
let e = n.replace(/-/g, "+").replace(/_/g, "/"), t = JSON.parse(atob(e.padEnd(Math.ceil(e.length / 4) * 4, "="))), r = (e) => typeof e == "number" && Number.isFinite(e) ? e : null, { exp: i, iat: a } = t ?? {};
|
|
1844
|
+
return {
|
|
1845
|
+
exp: r(i),
|
|
1846
|
+
iat: r(a)
|
|
1847
|
+
};
|
|
1393
1848
|
} catch {
|
|
1394
|
-
return
|
|
1849
|
+
return null;
|
|
1395
1850
|
}
|
|
1396
1851
|
}
|
|
1852
|
+
function An(e) {
|
|
1853
|
+
let t = kn(e)?.exp;
|
|
1854
|
+
return typeof t == "number" ? t * 1e3 : null;
|
|
1855
|
+
}
|
|
1856
|
+
function jn(e, t = Date.now()) {
|
|
1857
|
+
let n = An(e);
|
|
1858
|
+
return n !== null && n <= t;
|
|
1859
|
+
}
|
|
1860
|
+
function Mn(e, t = Date.now()) {
|
|
1861
|
+
let n = kn(e);
|
|
1862
|
+
return n?.exp == null ? null : n.iat != null && n.exp > n.iat ? t + (n.exp - n.iat) * 1e3 : n.exp * 1e3;
|
|
1863
|
+
}
|
|
1397
1864
|
//#endregion
|
|
1398
1865
|
//#region src/storage.ts
|
|
1399
|
-
function
|
|
1866
|
+
function Nn(e) {
|
|
1400
1867
|
return `whoo-aiden-widget:conversation:${e}`;
|
|
1401
1868
|
}
|
|
1402
|
-
function
|
|
1869
|
+
function Pn(e) {
|
|
1403
1870
|
try {
|
|
1404
|
-
return window.sessionStorage.getItem(
|
|
1871
|
+
return window.sessionStorage.getItem(Nn(e));
|
|
1405
1872
|
} catch {
|
|
1406
1873
|
return null;
|
|
1407
1874
|
}
|
|
1408
1875
|
}
|
|
1409
|
-
function
|
|
1876
|
+
function Fn(e, t) {
|
|
1410
1877
|
try {
|
|
1411
|
-
window.sessionStorage.setItem(
|
|
1878
|
+
window.sessionStorage.setItem(Nn(e), t);
|
|
1412
1879
|
} catch {}
|
|
1413
1880
|
}
|
|
1414
|
-
function
|
|
1881
|
+
function In(e) {
|
|
1415
1882
|
try {
|
|
1416
|
-
window.sessionStorage.removeItem(
|
|
1883
|
+
window.sessionStorage.removeItem(Nn(e));
|
|
1417
1884
|
} catch {}
|
|
1418
1885
|
}
|
|
1419
1886
|
//#endregion
|
|
1420
1887
|
//#region src/theme.ts
|
|
1421
|
-
var
|
|
1422
|
-
function
|
|
1423
|
-
if (
|
|
1888
|
+
var Ln = /^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;
|
|
1889
|
+
function Rn(e) {
|
|
1890
|
+
if (Ln.test(e.trim())) return null;
|
|
1424
1891
|
let t = document.createElement("div");
|
|
1425
1892
|
if (t.style.color = e, t.style.color === "") return null;
|
|
1426
1893
|
let n = document.createElement("div");
|
|
@@ -1439,69 +1906,69 @@ function K(e) {
|
|
|
1439
1906
|
translucent: a < 1
|
|
1440
1907
|
};
|
|
1441
1908
|
}
|
|
1442
|
-
function
|
|
1443
|
-
return
|
|
1909
|
+
function K(e) {
|
|
1910
|
+
return Rn(e)?.rgb ?? null;
|
|
1444
1911
|
}
|
|
1445
|
-
function
|
|
1912
|
+
function q([e, t, n]) {
|
|
1446
1913
|
let r = (e) => {
|
|
1447
1914
|
let t = e / 255;
|
|
1448
1915
|
return t <= .03928 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
|
|
1449
1916
|
};
|
|
1450
1917
|
return .2126 * r(e) + .7152 * r(t) + .0722 * r(n);
|
|
1451
1918
|
}
|
|
1452
|
-
function
|
|
1919
|
+
function zn(e, t) {
|
|
1453
1920
|
let n = Math.max(e, t), r = Math.min(e, t);
|
|
1454
1921
|
return (n + .05) / (r + .05);
|
|
1455
1922
|
}
|
|
1456
|
-
function
|
|
1457
|
-
let t =
|
|
1923
|
+
function Bn(e) {
|
|
1924
|
+
let t = K(e);
|
|
1458
1925
|
if (!t) return console.warn(`[whoo-aiden-widget] Could not parse color "${e}" for contrast calculation; defaulting to white text.`), "#ffffff";
|
|
1459
|
-
let n =
|
|
1460
|
-
return
|
|
1926
|
+
let n = q(t);
|
|
1927
|
+
return zn(n, q([
|
|
1461
1928
|
0,
|
|
1462
1929
|
0,
|
|
1463
1930
|
0
|
|
1464
|
-
])) >=
|
|
1931
|
+
])) >= zn(n, q([
|
|
1465
1932
|
255,
|
|
1466
1933
|
255,
|
|
1467
1934
|
255
|
|
1468
1935
|
])) ? "#000000" : "#ffffff";
|
|
1469
1936
|
}
|
|
1470
|
-
function
|
|
1471
|
-
let n =
|
|
1472
|
-
return !n || !r ? NaN :
|
|
1937
|
+
function Vn(e, t) {
|
|
1938
|
+
let n = K(e), r = K(t);
|
|
1939
|
+
return !n || !r ? NaN : zn(q(n), q(r));
|
|
1473
1940
|
}
|
|
1474
|
-
var
|
|
1475
|
-
function
|
|
1941
|
+
var Hn = i.primary, Un = i.panel, Wn = i.assistantBubble, Gn = i.headerHover, Kn = 4.5;
|
|
1942
|
+
function J([e, t, n]) {
|
|
1476
1943
|
return `#${[
|
|
1477
1944
|
e,
|
|
1478
1945
|
t,
|
|
1479
1946
|
n
|
|
1480
1947
|
].map((e) => e.toString(16).padStart(2, "0")).join("")}`;
|
|
1481
1948
|
}
|
|
1482
|
-
function
|
|
1483
|
-
let n =
|
|
1484
|
-
if (!n || !r) return
|
|
1485
|
-
let i =
|
|
1486
|
-
if (a(n)) return
|
|
1949
|
+
function qn(e, t = Un) {
|
|
1950
|
+
let n = K(e), r = K(t);
|
|
1951
|
+
if (!n || !r) return Hn;
|
|
1952
|
+
let i = q(r), a = (e) => zn(q(e), i) >= Kn;
|
|
1953
|
+
if (a(n)) return J(n);
|
|
1487
1954
|
for (let e = .99; e > 0; e -= .01) {
|
|
1488
1955
|
let t = n.map((t) => Math.round(t * e));
|
|
1489
|
-
if (a(t)) return
|
|
1956
|
+
if (a(t)) return J(t);
|
|
1490
1957
|
}
|
|
1491
1958
|
return "#000000";
|
|
1492
1959
|
}
|
|
1493
|
-
var
|
|
1494
|
-
function
|
|
1960
|
+
var Jn = i.ink, Yn = i.link;
|
|
1961
|
+
function Y(e) {
|
|
1495
1962
|
if (typeof e != "string" || !e) return null;
|
|
1496
|
-
let t =
|
|
1497
|
-
return t ?
|
|
1963
|
+
let t = Rn(e);
|
|
1964
|
+
return t ? J(t.rgb) : null;
|
|
1498
1965
|
}
|
|
1499
|
-
function
|
|
1966
|
+
function Xn(e) {
|
|
1500
1967
|
if (typeof e != "string" || !e) return null;
|
|
1501
|
-
let t =
|
|
1502
|
-
return t ? t.translucent ? e.trim() :
|
|
1968
|
+
let t = Rn(e);
|
|
1969
|
+
return t ? t.translucent ? e.trim() : J(t.rgb) : null;
|
|
1503
1970
|
}
|
|
1504
|
-
var
|
|
1971
|
+
var Zn = [
|
|
1505
1972
|
{
|
|
1506
1973
|
role: "onPrimary",
|
|
1507
1974
|
against: ["primary"],
|
|
@@ -1553,8 +2020,8 @@ var yn = [
|
|
|
1553
2020
|
required: 3
|
|
1554
2021
|
}
|
|
1555
2022
|
];
|
|
1556
|
-
function
|
|
1557
|
-
let o = typeof a == "object" && a && !Array.isArray(a) ? a : {}, s = (e) =>
|
|
2023
|
+
function X({ color: e, inkColor: t, accentColor: n, overrides: a }) {
|
|
2024
|
+
let o = typeof a == "object" && a && !Array.isArray(a) ? a : {}, s = (e) => Xn(o[e]), c = Y(e), l = s("primary"), u = l ?? c ?? Hn, d = s("primaryText"), f = d ?? qn(u, Gn), p = s("onPrimary") ?? Bn(u), m = Y(t), h = s("ink") ?? (m ? qn(m, Wn) : Jn), g = Y(n), _ = s("link") ?? (g ? qn(g, Wn) : Yn), v = (e) => s(e) ?? i[e], y = {
|
|
1558
2025
|
primary: u,
|
|
1559
2026
|
onPrimary: p,
|
|
1560
2027
|
primaryText: f,
|
|
@@ -1571,10 +2038,10 @@ function Z({ color: e, inkColor: r, accentColor: i, overrides: a }) {
|
|
|
1571
2038
|
errorText: v("errorText"),
|
|
1572
2039
|
inputBorder: v("inputBorder"),
|
|
1573
2040
|
focusRing: v("focusRing")
|
|
1574
|
-
}, b = Object.fromEntries(
|
|
1575
|
-
for (let { role: e, against: t, required: n } of
|
|
2041
|
+
}, b = Object.fromEntries(r.map((e) => [e, s(e) !== null])), x = [];
|
|
2042
|
+
for (let { role: e, against: t, required: n } of Zn) for (let r of t) {
|
|
1576
2043
|
if (!b[e] && !b[r]) continue;
|
|
1577
|
-
let t =
|
|
2044
|
+
let t = Vn(y[e], y[r]);
|
|
1578
2045
|
Number.isFinite(t) && t < n && x.push({
|
|
1579
2046
|
role: e,
|
|
1580
2047
|
against: r,
|
|
@@ -1600,63 +2067,71 @@ function Z({ color: e, inkColor: r, accentColor: i, overrides: a }) {
|
|
|
1600
2067
|
contrastWarnings: x
|
|
1601
2068
|
};
|
|
1602
2069
|
}
|
|
1603
|
-
function
|
|
2070
|
+
function Z(e) {
|
|
1604
2071
|
return typeof e == "string" ? `"${e}"` : `a ${typeof e} value`;
|
|
1605
2072
|
}
|
|
1606
|
-
function
|
|
2073
|
+
function Qn(e, t, n = Hn) {
|
|
1607
2074
|
let r = t;
|
|
1608
|
-
|
|
1609
|
-
let i =
|
|
2075
|
+
Y(t) === null && (console.warn(`[whoo-aiden-widget] Could not use ${Z(t)} as the theme color; falling back to ${Z(n)}.`), r = n);
|
|
2076
|
+
let i = X({ color: r });
|
|
1610
2077
|
e.style.setProperty("--whoo-widget-color", i.primary), e.style.setProperty("--whoo-widget-text-on-color", i.textOnPrimary), e.style.setProperty("--whoo-widget-color-text", i.primaryAsText);
|
|
1611
2078
|
}
|
|
1612
|
-
function
|
|
1613
|
-
let r =
|
|
2079
|
+
function $n(e, { inkColor: t, accentColor: n }) {
|
|
2080
|
+
let r = X({
|
|
1614
2081
|
inkColor: t,
|
|
1615
2082
|
accentColor: n
|
|
1616
2083
|
});
|
|
1617
2084
|
e.style.setProperty("--whoo-widget-ink", r.ink), e.style.setProperty("--whoo-widget-link-color", r.link);
|
|
1618
2085
|
}
|
|
1619
|
-
function
|
|
1620
|
-
let
|
|
1621
|
-
for (let
|
|
1622
|
-
let
|
|
1623
|
-
(
|
|
2086
|
+
function er(e, t) {
|
|
2087
|
+
let n = X({ overrides: t });
|
|
2088
|
+
for (let t of r) {
|
|
2089
|
+
let r = n.overridden.primary && (t === "onPrimary" || t === "primaryText");
|
|
2090
|
+
(n.overridden[t] || r) && e.style.setProperty(a[t], n.roles[t]);
|
|
1624
2091
|
}
|
|
1625
2092
|
}
|
|
1626
|
-
function
|
|
1627
|
-
e &&
|
|
2093
|
+
function tr(e, t) {
|
|
2094
|
+
e && Y(e) === null && console.warn(`[whoo-aiden-widget] Could not use ${Z(e)} as the ${t}; using the default.`);
|
|
1628
2095
|
}
|
|
1629
|
-
function
|
|
1630
|
-
for (let e of
|
|
1631
|
-
let
|
|
1632
|
-
|
|
2096
|
+
function nr(e, t, n) {
|
|
2097
|
+
for (let e of r) {
|
|
2098
|
+
let n = t[e];
|
|
2099
|
+
n && Y(n) === null && console.warn(`[whoo-aiden-widget] Could not use ${Z(n)} as theme.colors.${e}; using the calculated color.`);
|
|
1633
2100
|
}
|
|
1634
|
-
let i =
|
|
1635
|
-
typeof i == "string" &&
|
|
2101
|
+
let i = t.primary;
|
|
2102
|
+
typeof i == "string" && Rn(i)?.translucent && console.warn(`[whoo-aiden-widget] theme.colors.primary ${Z(i)} is translucent. The launcher shows your page through it, so its icon may be unreadable over dark content; pass a solid color.`), rr({
|
|
1636
2103
|
color: e.color,
|
|
1637
2104
|
inkColor: e.inkColor,
|
|
1638
2105
|
accentColor: e.accentColor,
|
|
1639
|
-
overrides:
|
|
1640
|
-
},
|
|
2106
|
+
overrides: t
|
|
2107
|
+
}, n);
|
|
1641
2108
|
}
|
|
1642
|
-
function
|
|
1643
|
-
for (let n of
|
|
2109
|
+
function rr(e, t) {
|
|
2110
|
+
for (let n of X(e).contrastWarnings) {
|
|
1644
2111
|
let { role: e, against: r, value: i, ratio: a, required: o, overridden: s } = n, c = `${e}|${r}|${i}`;
|
|
1645
2112
|
t.has(c) || (t.add(c), console.warn(s ? `[whoo-aiden-widget] theme.colors.${e} (${i}) has ${a.toFixed(2)}:1 contrast against the ${r} color; ${o}:1 is recommended. Using it as given.` : `[whoo-aiden-widget] the ${e} color (${i}) has ${a.toFixed(2)}:1 contrast against your theme.colors.${r}; ${o}:1 is recommended. Override theme.colors.${e} too.`));
|
|
1646
2113
|
}
|
|
1647
2114
|
}
|
|
1648
|
-
function
|
|
1649
|
-
|
|
2115
|
+
function ir(e, t, n = /* @__PURE__ */ new Set()) {
|
|
2116
|
+
Qn(e, t.color ?? Hn), tr(t.inkColor, "ink color"), tr(t.accentColor, "accent color"), $n(e, {
|
|
1650
2117
|
inkColor: t.inkColor,
|
|
1651
2118
|
accentColor: t.accentColor
|
|
1652
2119
|
});
|
|
1653
|
-
let r =
|
|
1654
|
-
|
|
2120
|
+
let r = te(t.theme);
|
|
2121
|
+
nr(t, r.colors, n), er(e, r.colors), r.fontFamily && e.style.setProperty("--whoo-widget-font", r.fontFamily);
|
|
1655
2122
|
}
|
|
1656
2123
|
//#endregion
|
|
1657
2124
|
//#region src/controller.ts
|
|
1658
|
-
var
|
|
1659
|
-
|
|
2125
|
+
var ar = 8e3, or = 3e3, Q = class extends Error {
|
|
2126
|
+
name = "SessionExpiredError";
|
|
2127
|
+
constructor(e) {
|
|
2128
|
+
super(e instanceof Error ? e.message : "The session has expired.");
|
|
2129
|
+
}
|
|
2130
|
+
};
|
|
2131
|
+
function sr(e) {
|
|
2132
|
+
return e?.status === 401;
|
|
2133
|
+
}
|
|
2134
|
+
function cr(e, t) {
|
|
1660
2135
|
return new Promise((n) => {
|
|
1661
2136
|
let r = setTimeout(n, t);
|
|
1662
2137
|
e.then(() => {
|
|
@@ -1664,11 +2139,14 @@ function kn(e, t) {
|
|
|
1664
2139
|
});
|
|
1665
2140
|
});
|
|
1666
2141
|
}
|
|
1667
|
-
var
|
|
2142
|
+
var lr = class {
|
|
1668
2143
|
config;
|
|
1669
2144
|
state;
|
|
1670
2145
|
listeners = /* @__PURE__ */ new Set();
|
|
1671
2146
|
sessionToken = null;
|
|
2147
|
+
sessionTokenExpiresAt = null;
|
|
2148
|
+
tokenRenewal = null;
|
|
2149
|
+
getSessionToken;
|
|
1672
2150
|
conversationId = null;
|
|
1673
2151
|
storageIdentifier;
|
|
1674
2152
|
activeRequestController = null;
|
|
@@ -1679,13 +2157,22 @@ var An = class {
|
|
|
1679
2157
|
emptyStateImageUrl;
|
|
1680
2158
|
emptyStateImageAlt;
|
|
1681
2159
|
showFeedback;
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
2160
|
+
text;
|
|
2161
|
+
language;
|
|
2162
|
+
languageTag;
|
|
2163
|
+
dir;
|
|
2164
|
+
constructor(e) {
|
|
2165
|
+
this.config = e;
|
|
2166
|
+
let t = te(e.theme).launcher, r = t.iconUrl ?? n(e.launcherIconUrl, "launcherIconUrl");
|
|
1685
2167
|
this.launcher = {
|
|
1686
|
-
...
|
|
2168
|
+
...t,
|
|
1687
2169
|
...r ? { iconUrl: r } : {}
|
|
1688
|
-
}, this.launcherIconUrl = r, this.emptyStateImageUrl = e
|
|
2170
|
+
}, this.launcherIconUrl = r, this.emptyStateImageUrl = n(e.emptyStateImageUrl, "emptyStateImageUrl"), this.emptyStateImageAlt = typeof e.emptyStateImageAlt == "string" ? e.emptyStateImageAlt.trim() : "", this.showFeedback = e.showFeedback === !0, this.storageIdentifier = e.publishableKey ?? "session-token-mode", this.getSessionToken = p(e);
|
|
2171
|
+
let { language: i, tag: a, dir: o } = jt(e.language, typeof document > "u" ? void 0 : document.documentElement.lang);
|
|
2172
|
+
this.language = i, this.languageTag = a, this.dir = o, this.text = {
|
|
2173
|
+
...kt(i),
|
|
2174
|
+
...y(e.messages)
|
|
2175
|
+
}, this.prefersReducedMotion = typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.state = {
|
|
1689
2176
|
isOpen: !1,
|
|
1690
2177
|
messages: [],
|
|
1691
2178
|
isStreaming: !1,
|
|
@@ -1730,11 +2217,12 @@ var An = class {
|
|
|
1730
2217
|
let e = this.config.apiBaseUrl ?? "https://api.aidenvoice.com";
|
|
1731
2218
|
try {
|
|
1732
2219
|
if (this.config.sessionToken) {
|
|
1733
|
-
if (
|
|
1734
|
-
|
|
2220
|
+
if (jn(this.config.sessionToken)) {
|
|
2221
|
+
if (!await this.renewToken()) throw Error("The sessionToken has expired.");
|
|
2222
|
+
} else this.sessionToken = this.config.sessionToken, this.sessionTokenExpiresAt = An(this.config.sessionToken);
|
|
1735
2223
|
} else if (this.config.publishableKey) {
|
|
1736
|
-
let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await
|
|
1737
|
-
this.sessionToken = t, this.setState({
|
|
2224
|
+
let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await _n(e, this.config.publishableKey);
|
|
2225
|
+
this.sessionToken = t, this.sessionTokenExpiresAt = Mn(t), this.setState({
|
|
1738
2226
|
primaryColor: n,
|
|
1739
2227
|
agentName: r,
|
|
1740
2228
|
accentColor: i,
|
|
@@ -1745,34 +2233,34 @@ var An = class {
|
|
|
1745
2233
|
console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) });
|
|
1746
2234
|
return;
|
|
1747
2235
|
}
|
|
1748
|
-
this.conversationId =
|
|
2236
|
+
this.conversationId = Pn(this.storageIdentifier), this.config.sessionToken && await cr(this.loadBranding(e), or);
|
|
1749
2237
|
}
|
|
1750
|
-
async loadBranding(e
|
|
2238
|
+
async loadBranding(e) {
|
|
1751
2239
|
try {
|
|
1752
|
-
let
|
|
1753
|
-
if (
|
|
1754
|
-
let { primaryColor:
|
|
2240
|
+
let t = this.config;
|
|
2241
|
+
if (Y(t.color) && Y(t.inkColor) && Y(t.accentColor) && u(t.name)) return;
|
|
2242
|
+
let { primaryColor: n, name: r, accentColor: i, inkColor: a } = await this.withSession((t) => yn(e, t));
|
|
1755
2243
|
this.setState({
|
|
1756
|
-
primaryColor:
|
|
1757
|
-
agentName:
|
|
1758
|
-
accentColor:
|
|
1759
|
-
inkColor:
|
|
2244
|
+
primaryColor: n,
|
|
2245
|
+
agentName: r,
|
|
2246
|
+
accentColor: i,
|
|
2247
|
+
inkColor: a
|
|
1760
2248
|
});
|
|
1761
2249
|
} catch (e) {
|
|
1762
2250
|
let t = e?.status;
|
|
1763
|
-
(t === 401 || t === 403) && (console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) }));
|
|
2251
|
+
(e instanceof Q || t === 401 || t === 403) && (console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) }));
|
|
1764
2252
|
}
|
|
1765
2253
|
}
|
|
1766
2254
|
open() {
|
|
1767
2255
|
this.setState({ isOpen: !0 });
|
|
1768
2256
|
}
|
|
1769
2257
|
resetConversation() {
|
|
1770
|
-
this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null,
|
|
2258
|
+
this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null, In(this.storageIdentifier), this.setState({
|
|
1771
2259
|
messages: [],
|
|
1772
2260
|
messageFeedback: {},
|
|
1773
2261
|
runtimeError: null,
|
|
1774
2262
|
isStreaming: !1,
|
|
1775
|
-
announcement:
|
|
2263
|
+
announcement: this.text.conversationCleared
|
|
1776
2264
|
});
|
|
1777
2265
|
}
|
|
1778
2266
|
setDraft(e) {
|
|
@@ -1813,23 +2301,33 @@ var An = class {
|
|
|
1813
2301
|
let { signal: s } = this.activeRequestController;
|
|
1814
2302
|
this.slowResponseTimer = setTimeout(() => {
|
|
1815
2303
|
this.slowResponseTimer = null, this.setState({ isSlowResponse: !0 });
|
|
1816
|
-
},
|
|
1817
|
-
let c = () => {
|
|
2304
|
+
}, ar);
|
|
2305
|
+
let c = (t = this.text.genericError) => {
|
|
1818
2306
|
this.setState({
|
|
1819
|
-
runtimeError:
|
|
2307
|
+
runtimeError: t,
|
|
1820
2308
|
...this.state.draft === "" ? { draft: e } : {}
|
|
1821
2309
|
});
|
|
1822
2310
|
}, l = "";
|
|
1823
2311
|
try {
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
2312
|
+
let { stream: n, first: r } = await this.withSession(async (n) => {
|
|
2313
|
+
let r = xn(t, n, this.conversationId, e, s);
|
|
2314
|
+
return {
|
|
2315
|
+
stream: r,
|
|
2316
|
+
first: await r.next()
|
|
2317
|
+
};
|
|
2318
|
+
});
|
|
2319
|
+
for (let e = r; !e.done; e = await n.next()) {
|
|
2320
|
+
let t = e.value;
|
|
2321
|
+
if (t.type === "conversation_id") this.conversationId = t.conversationId, Fn(this.storageIdentifier, t.conversationId);
|
|
2322
|
+
else if (t.type === "delta") this.clearSlowResponse(), t.verbatim && !this.prefersReducedMotion ? (await On(t.delta, (e) => o(e), { signal: s }), l = t.delta) : t.verbatim ? (l = t.delta, o(l)) : (l += t.delta, o(l));
|
|
2323
|
+
else if (t.type === "done") t.conversationId && (this.conversationId = t.conversationId, Fn(this.storageIdentifier, t.conversationId)), t.messageId && a({ id: t.messageId }), this.setState({ announcement: Cn(l) });
|
|
2324
|
+
else if (t.type === "error") {
|
|
2325
|
+
console.error("[whoo-aiden-widget] chat error:", t.error), c(), this.activeRequestController?.abort();
|
|
2326
|
+
break;
|
|
2327
|
+
}
|
|
1830
2328
|
}
|
|
1831
2329
|
} catch (e) {
|
|
1832
|
-
e?.name === "AbortError" || (console.error("[whoo-aiden-widget] chat request failed:", e), c());
|
|
2330
|
+
e?.name === "AbortError" || (e instanceof Q ? (console.error("[whoo-aiden-widget] chat request failed: the session has expired.", e), c(this.text.sessionExpired)) : (console.error("[whoo-aiden-widget] chat request failed:", e), c()));
|
|
1833
2331
|
} finally {
|
|
1834
2332
|
this.activeRequestController = null, this.clearSlowResponse();
|
|
1835
2333
|
let e = i.id === null && i.content.trim() === "" ? this.state.messages.filter((e) => e !== i) : this.state.messages;
|
|
@@ -1877,12 +2375,12 @@ var An = class {
|
|
|
1877
2375
|
}
|
|
1878
2376
|
} });
|
|
1879
2377
|
try {
|
|
1880
|
-
await
|
|
2378
|
+
await this.withSession((a) => bn(i, a, {
|
|
1881
2379
|
messageId: e,
|
|
1882
2380
|
rating: t,
|
|
1883
2381
|
correction: n,
|
|
1884
2382
|
category: r
|
|
1885
|
-
}), this.setState({ messageFeedback: {
|
|
2383
|
+
})), this.setState({ messageFeedback: {
|
|
1886
2384
|
...this.state.messageFeedback,
|
|
1887
2385
|
[e]: {
|
|
1888
2386
|
status: "submitted",
|
|
@@ -1901,46 +2399,93 @@ var An = class {
|
|
|
1901
2399
|
} });
|
|
1902
2400
|
}
|
|
1903
2401
|
}
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
2402
|
+
async currentToken() {
|
|
2403
|
+
let e = this.sessionToken, t = this.sessionTokenExpiresAt;
|
|
2404
|
+
return e && (t === null || t - Date.now() > 6e4) ? e : this.renewToken();
|
|
2405
|
+
}
|
|
2406
|
+
renewToken() {
|
|
2407
|
+
return this.tokenRenewal ??= this.fetchNewToken().finally(() => {
|
|
2408
|
+
this.tokenRenewal = null;
|
|
2409
|
+
}), this.tokenRenewal;
|
|
2410
|
+
}
|
|
2411
|
+
async fetchNewToken() {
|
|
2412
|
+
let e = this.config.apiBaseUrl ?? "https://api.aidenvoice.com";
|
|
2413
|
+
try {
|
|
2414
|
+
let t;
|
|
2415
|
+
if (this.config.publishableKey) t = (await _n(e, this.config.publishableKey)).token;
|
|
2416
|
+
else if (this.getSessionToken) t = await this.getSessionToken();
|
|
2417
|
+
else return null;
|
|
2418
|
+
let n = typeof t == "string" ? Mn(t) : null;
|
|
2419
|
+
return typeof t != "string" || t === "" || n !== null && n <= Date.now() ? (console.error("[whoo-aiden-widget] could not renew the session: no usable token was returned."), null) : (this.sessionToken = t, this.sessionTokenExpiresAt = n, t);
|
|
2420
|
+
} catch (e) {
|
|
2421
|
+
return console.error("[whoo-aiden-widget] could not renew the session:", e), null;
|
|
2422
|
+
}
|
|
2423
|
+
}
|
|
2424
|
+
async withSession(e) {
|
|
2425
|
+
let t = await this.currentToken();
|
|
2426
|
+
if (!t) throw new Q();
|
|
2427
|
+
try {
|
|
2428
|
+
return await e(t);
|
|
2429
|
+
} catch (n) {
|
|
2430
|
+
if (!sr(n)) throw n;
|
|
2431
|
+
let r = this.sessionToken && this.sessionToken !== t ? this.sessionToken : await this.renewToken();
|
|
2432
|
+
if (!r) throw new Q(n);
|
|
2433
|
+
try {
|
|
2434
|
+
return await e(r);
|
|
2435
|
+
} catch (e) {
|
|
2436
|
+
throw sr(e) ? new Q(e) : e;
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
2440
|
+
}, $ = 20, ur = 12, dr = 300, fr = 352;
|
|
2441
|
+
function pr() {
|
|
2442
|
+
try {
|
|
2443
|
+
return typeof CSS < "u" && CSS.supports?.("height", "100dvh") ? "dvh" : "vh";
|
|
2444
|
+
} catch {
|
|
2445
|
+
return "vh";
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2448
|
+
function mr(e, t) {
|
|
2449
|
+
let { offsetX: n, offsetY: r, launcherSize: i, panelWidth: a, panelHeight: o } = ie(t.layout), s = (e) => typeof t.layout?.offset?.[e] == "number";
|
|
1907
2450
|
if (typeof window < "u" && window.innerWidth > 0 && window.innerHeight > 0) {
|
|
1908
|
-
let e = Math.max($, window.innerWidth -
|
|
2451
|
+
let e = Math.max($, window.innerWidth - dr), t = Math.max($, window.innerHeight - i - fr);
|
|
1909
2452
|
s("x") && (n > e || n > window.innerWidth - i) && console.warn(`whoo-aiden-widget: \`layout.offset.x\` ${n} leaves no room for the launcher and panel in this viewport; it is held back.`), s("y") && (r > t || r > window.innerHeight - i) && console.warn(`whoo-aiden-widget: \`layout.offset.y\` ${r} leaves no room for the launcher and panel in this viewport; it is held back.`);
|
|
1910
2453
|
}
|
|
1911
|
-
let c = `min(${n}px, max(${$}px, calc(100vw - ${
|
|
1912
|
-
|
|
2454
|
+
let c = `100${pr()}`, l = `min(${n}px, max(${$}px, calc(100vw - ${dr}px)), calc(100vw - ${i}px))`, u = `min(${r}px, max(${$}px, calc(${c} - ${i + fr}px)), calc(${c} - ${i}px))`, d = `calc(${u} + ${i}px + ${ur}px)`, f = t.position === "bottom-left", p = (t, n) => e.style.setProperty(t, n);
|
|
2455
|
+
p("--whoo-widget-inset-left", f ? l : "auto"), p("--whoo-widget-inset-right", f ? "auto" : l), p("--whoo-widget-inset-bottom", u), p("--whoo-widget-launcher-size", `${i}px`), p("--whoo-widget-panel-bottom", d), p("--whoo-widget-panel-width", `${a}px`), p("--whoo-widget-panel-height", `${o}px`), p("--whoo-widget-panel-max-width", `calc(100vw - ${l} - ${$}px)`), p("--whoo-widget-panel-max-height", `calc(${c} - ${d} - ${$}px)`);
|
|
1913
2456
|
}
|
|
1914
2457
|
//#endregion
|
|
1915
2458
|
//#region src/styles.css?inline
|
|
1916
|
-
var
|
|
2459
|
+
var hr = ":host,.whoo-widget-root{all:initial;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.whoo-widget-launcher{bottom:var(--whoo-widget-inset-bottom,20px);left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);width:var(--whoo-widget-launcher-size,56px);height:var(--whoo-widget-launcher-size,56px);background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:50%;justify-content:center;align-items:center;padding:0;font-size:24px;display:flex;position:fixed;box-shadow:0 2px 8px #0003}.whoo-widget-launcher:focus-visible{box-shadow:0 2px 8px #0003,0 0 0 4px #fff}.whoo-widget-launcher svg{width:calc(var(--whoo-widget-launcher-size,56px) * 13 / 28);height:calc(var(--whoo-widget-launcher-size,56px) * 13 / 28);display:block}.whoo-widget-launcher-icon-image{width:calc(var(--whoo-widget-launcher-size,56px) * 4 / 7);height:calc(var(--whoo-widget-launcher-size,56px) * 4 / 7);object-fit:cover;border-radius:50%}.whoo-widget-launcher-icon-image[hidden]{display:none}.whoo-widget-panel{bottom:var(--whoo-widget-panel-bottom,88px);left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);width:var(--whoo-widget-panel-width,360px);height:var(--whoo-widget-panel-height,480px);max-width:var(--whoo-widget-panel-max-width,calc(100vw - 40px));max-height:var(--whoo-widget-panel-max-height,calc(100vh - 108px));background:var(--whoo-widget-panel,#fff);font-family:var(--whoo-widget-font,-apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif);color:inherit;border:none;border-radius:12px;flex-direction:column;margin:0;padding:0;display:flex;position:fixed;overflow:hidden;box-shadow:0 4px 16px #0003}button,input,textarea,select{font-family:inherit}.whoo-widget-panel::backdrop{background:0 0}@media (width<=400px),(height<=420px){.whoo-widget-panel{width:auto;max-width:none;height:auto;max-height:none;inset:8px}}.whoo-widget-panel[data-fit-visible]{top:calc(var(--whoo-widget-visible-top,0px) + max(8px, var(--whoo-widget-visible-height,100%) - 8px - var(--whoo-widget-panel-height,480px)));height:min(var(--whoo-widget-panel-height,480px), calc(var(--whoo-widget-visible-height,100%) - 16px));max-height:none;bottom:auto}@media (width<=400px),(height<=420px){.whoo-widget-panel[data-fit-visible]{top:calc(var(--whoo-widget-visible-top,0px) + 8px);height:calc(var(--whoo-widget-visible-height,100%) - 16px)}}.whoo-widget-header{border-bottom:1px solid var(--whoo-widget-border,#e5e5e5);flex-wrap:wrap;flex-shrink:0;justify-content:space-between;align-items:center;gap:8px;max-height:50%;padding-block:8px;padding-inline:16px 8px;display:flex;overflow-y:auto}.whoo-widget-header-title{color:var(--whoo-widget-ink,#111);overflow-wrap:anywhere;flex:auto;min-width:0;margin:0;font-size:15px;font-weight:600}.whoo-widget-header-actions{background:var(--whoo-widget-panel,#fff);flex-shrink:0;align-items:center;gap:4px;margin-inline-start:auto;display:flex;position:sticky;bottom:0}.whoo-widget-header-close,.whoo-widget-header-reset{color:var(--whoo-widget-color-text,#4f46e5);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px 8px;font-size:13px;display:inline-flex}.whoo-widget-header-close{width:32px;height:32px;padding:0}.whoo-widget-header-close:hover,.whoo-widget-header-reset:hover{background:var(--whoo-widget-header-hover,#f3f4f6)}.whoo-widget-message-list{overscroll-behavior:contain;flex:1;min-height:0;padding:12px;overflow-y:auto}.whoo-widget-message-list:focus-visible{outline:2px solid var(--whoo-widget-focus-ring,#111827);outline-offset:-2px;box-shadow:inset 0 0 0 4px var(--whoo-widget-panel,#fff)}.whoo-widget-empty-state-image{object-fit:contain;max-width:min(160px,100%);height:auto;max-height:160px;margin:8px auto 16px;display:block}@media (width<=400px),(height<=420px){.whoo-widget-empty-state-image{max-height:64px;margin:0 auto 8px}}.whoo-widget-message{overflow-wrap:anywhere;white-space:pre-line;border-radius:8px;max-width:80%;margin-bottom:8px;padding:8px 12px}.whoo-widget-list{margin:4px 0;padding-inline-start:20px}.whoo-widget-message--user{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);margin-inline-start:auto}.whoo-widget-message--user a{color:inherit}.whoo-widget-message--assistant{background:var(--whoo-widget-assistant-bubble,#f0f0f0);color:var(--whoo-widget-ink,#111)}.whoo-widget-message--assistant a{color:var(--whoo-widget-link-color,#00e)}.whoo-widget-pending{flex-wrap:wrap;align-items:center;gap:8px;min-height:1.2em;display:flex}.whoo-widget-typing{align-items:center;gap:4px;display:inline-flex}.whoo-widget-typing span{background:var(--whoo-widget-typing-dots,#6b7280);border-radius:50%;width:6px;height:6px;animation:1.2s ease-in-out infinite whoo-widget-typing-bounce}.whoo-widget-typing span:nth-child(2){animation-delay:.2s}.whoo-widget-typing span:nth-child(3){animation-delay:.4s}@keyframes whoo-widget-typing-bounce{0%,80%,to{transform:translateY(0)}40%{transform:translateY(-4px)}}@media (prefers-reduced-motion:reduce){.whoo-widget-typing span{animation:none}}.whoo-widget-error-banner{background:var(--whoo-widget-error-bg,#fee2e2);color:var(--whoo-widget-error-text,#991b1b);padding:8px 12px;font-size:13px}.whoo-widget-composer{border-top:1px solid var(--whoo-widget-border,#e5e5e5);gap:8px;padding:12px;display:flex}.whoo-widget-composer-input{border:1px solid var(--whoo-widget-input-border,#6b7280);unicode-bidi:plaintext;border-radius:6px;flex:1;min-width:0;padding:8px;font-size:16px}.whoo-widget-composer-send{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px}.whoo-widget-composer-send[aria-disabled=true],.whoo-widget-composer-input[aria-disabled=true]{opacity:.6;cursor:not-allowed}.whoo-widget-feedback{align-items:center;gap:6px;margin-top:4px;display:flex}.whoo-widget-feedback-buttons{gap:6px;display:flex}.whoo-widget-feedback-buttons button{cursor:pointer;color:var(--whoo-widget-muted,#4b5563);background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px;display:inline-flex}.whoo-widget-feedback-buttons button:hover:not(:disabled){color:var(--whoo-widget-text,#111);background:#0000000f}.whoo-widget-feedback-buttons button:disabled{opacity:.3;cursor:not-allowed}.whoo-widget-feedback-form{flex-direction:column;gap:6px;margin-top:6px;display:flex}.whoo-widget-feedback-textarea{box-sizing:border-box;border:1px solid var(--whoo-widget-input-border,#6b7280);resize:vertical;unicode-bidi:plaintext;border-radius:6px;width:100%;padding:6px;font-size:16px}.whoo-widget-feedback-select{border:1px solid var(--whoo-widget-input-border,#6b7280);border-radius:6px;height:2em;min-height:24px;padding:4px;font-size:16px}.whoo-widget-feedback-form-buttons{gap:6px;display:flex}.whoo-widget-feedback-submit{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-cancel{border:1px solid var(--whoo-widget-input-border,#6b7280);background:var(--whoo-widget-panel,#fff);color:var(--whoo-widget-text,#111);cursor:pointer;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-submitted{color:var(--whoo-widget-muted,#4b5563);margin-top:4px;font-size:12px}.whoo-widget-feedback-error{color:var(--whoo-widget-error-text,#991b1b);font-size:12px}.whoo-widget-sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible,a:focus-visible{outline:2px solid var(--whoo-widget-focus-ring,#111827);outline-offset:2px;box-shadow:0 0 0 4px var(--whoo-widget-panel,#fff)}@media (forced-colors:active){.whoo-widget-launcher,.whoo-widget-header-close,.whoo-widget-header-reset,.whoo-widget-composer-send,.whoo-widget-feedback-submit,.whoo-widget-feedback-buttons button{border:1px solid buttontext}.whoo-widget-panel{box-sizing:border-box;border:1px solid canvastext}}";
|
|
1917
2460
|
//#endregion
|
|
1918
2461
|
//#region src/mount.tsx
|
|
1919
|
-
function
|
|
2462
|
+
function gr(e) {
|
|
1920
2463
|
let t = document.createElement("div");
|
|
1921
|
-
t.id = "whoo-aiden-widget-host", t.style.position = "relative", t.style.zIndex = String(
|
|
2464
|
+
t.id = "whoo-aiden-widget-host", t.style.position = "relative", t.style.zIndex = String(c(e.zIndex));
|
|
1922
2465
|
let n = t.attachShadow({ mode: "open" }), r = document.createElement("style");
|
|
1923
|
-
r.textContent =
|
|
2466
|
+
r.textContent = hr, n.appendChild(r);
|
|
1924
2467
|
let i = document.createElement("div");
|
|
1925
2468
|
n.appendChild(i);
|
|
1926
2469
|
let a = /* @__PURE__ */ new Set();
|
|
1927
|
-
|
|
1928
|
-
let
|
|
2470
|
+
ir(i, e, a), mr(i, e);
|
|
2471
|
+
let o = new lr(e);
|
|
2472
|
+
i.setAttribute("lang", o.languageTag), i.setAttribute("dir", o.dir);
|
|
2473
|
+
let s = Y(e.color) !== null, l = null, u = "", d = te(e.theme).colors, f = Object.keys(d).length > 0, p = {
|
|
1929
2474
|
color: e.color,
|
|
1930
2475
|
inkColor: e.inkColor,
|
|
1931
2476
|
accentColor: e.accentColor
|
|
1932
2477
|
};
|
|
1933
|
-
return
|
|
2478
|
+
return o.subscribe((t) => {
|
|
1934
2479
|
let n = !1;
|
|
1935
|
-
!
|
|
2480
|
+
!s && t.primaryColor && t.primaryColor !== l && (l = t.primaryColor, Qn(i, t.primaryColor, e.color), Y(t.primaryColor) && (p = {
|
|
1936
2481
|
...p,
|
|
1937
2482
|
color: t.primaryColor
|
|
1938
2483
|
}), n = !0);
|
|
1939
2484
|
let r = `${t.inkColor}|${t.accentColor}`;
|
|
1940
2485
|
if ((t.inkColor || t.accentColor) && r !== u) {
|
|
1941
2486
|
u = r;
|
|
1942
|
-
let a =
|
|
1943
|
-
|
|
2487
|
+
let a = Y(e.inkColor) ? e.inkColor : t.inkColor, o = Y(e.accentColor) ? e.accentColor : t.accentColor;
|
|
2488
|
+
$n(i, {
|
|
1944
2489
|
inkColor: a,
|
|
1945
2490
|
accentColor: o
|
|
1946
2491
|
}), p = {
|
|
@@ -1949,18 +2494,18 @@ function In(e) {
|
|
|
1949
2494
|
accentColor: o
|
|
1950
2495
|
}, n = !0;
|
|
1951
2496
|
}
|
|
1952
|
-
n && (
|
|
2497
|
+
n && (er(i, d), f && rr({
|
|
1953
2498
|
...p,
|
|
1954
2499
|
overrides: d
|
|
1955
2500
|
}, a));
|
|
1956
|
-
}),
|
|
1957
|
-
|
|
2501
|
+
}), o.init(), ze(/* @__PURE__ */ U(mn, { controller: o }), i), document.body.appendChild(t), { unmount() {
|
|
2502
|
+
ze(null, i), t.remove();
|
|
1958
2503
|
} };
|
|
1959
2504
|
}
|
|
1960
2505
|
//#endregion
|
|
1961
2506
|
//#region src/index.ts
|
|
1962
|
-
function
|
|
1963
|
-
return
|
|
2507
|
+
function _r(e) {
|
|
2508
|
+
return d(e), gr(e);
|
|
1964
2509
|
}
|
|
1965
2510
|
//#endregion
|
|
1966
|
-
export {
|
|
2511
|
+
export { wt as SUPPORTED_LANGUAGES, _r as init, X as resolveTheme };
|