@foisit/vue-wrapper 2.4.2 → 2.4.5
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 +63 -8
- package/index.mjs +999 -779
- package/lib/services/AssistantService.d.ts +10 -0
- package/package.json +23 -6
package/index.mjs
CHANGED
|
@@ -3,46 +3,46 @@
|
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
6
|
-
const
|
|
7
|
-
},
|
|
8
|
-
(
|
|
9
|
-
let
|
|
10
|
-
const Q = () =>
|
|
11
|
-
function
|
|
12
|
-
if (k(
|
|
6
|
+
const se = process.env.NODE_ENV !== "production" ? Object.freeze({}) : {}, ze = process.env.NODE_ENV !== "production" ? Object.freeze([]) : [], we = () => {
|
|
7
|
+
}, Be = (i) => i.charCodeAt(0) === 111 && i.charCodeAt(1) === 110 && // uppercase letter
|
|
8
|
+
(i.charCodeAt(2) > 122 || i.charCodeAt(2) < 97), z = Object.assign, k = Array.isArray, I = (i) => typeof i == "function", R = (i) => typeof i == "string", xe = (i) => typeof i == "symbol", T = (i) => i !== null && typeof i == "object";
|
|
9
|
+
let he;
|
|
10
|
+
const Q = () => he || (he = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof global < "u" ? global : {});
|
|
11
|
+
function le(i) {
|
|
12
|
+
if (k(i)) {
|
|
13
13
|
const e = {};
|
|
14
|
-
for (let
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
17
|
-
for (const o in
|
|
18
|
-
e[o] =
|
|
14
|
+
for (let t = 0; t < i.length; t++) {
|
|
15
|
+
const s = i[t], n = R(s) ? Ye(s) : le(s);
|
|
16
|
+
if (n)
|
|
17
|
+
for (const o in n)
|
|
18
|
+
e[o] = n[o];
|
|
19
19
|
}
|
|
20
20
|
return e;
|
|
21
|
-
} else if (
|
|
22
|
-
return
|
|
21
|
+
} else if (R(i) || T(i))
|
|
22
|
+
return i;
|
|
23
23
|
}
|
|
24
|
-
const Ue = /;(?![^(]*\))/g,
|
|
25
|
-
function
|
|
24
|
+
const Ue = /;(?![^(]*\))/g, We = /:([^]+)/, je = /\/\*[^]*?\*\//g;
|
|
25
|
+
function Ye(i) {
|
|
26
26
|
const e = {};
|
|
27
|
-
return
|
|
28
|
-
if (
|
|
29
|
-
const
|
|
30
|
-
|
|
27
|
+
return i.replace(je, "").split(Ue).forEach((t) => {
|
|
28
|
+
if (t) {
|
|
29
|
+
const s = t.split(We);
|
|
30
|
+
s.length > 1 && (e[s[0].trim()] = s[1].trim());
|
|
31
31
|
}
|
|
32
32
|
}), e;
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function ce(i) {
|
|
35
35
|
let e = "";
|
|
36
|
-
if (
|
|
37
|
-
e =
|
|
38
|
-
else if (k(
|
|
39
|
-
for (let
|
|
40
|
-
const
|
|
41
|
-
|
|
36
|
+
if (R(i))
|
|
37
|
+
e = i;
|
|
38
|
+
else if (k(i))
|
|
39
|
+
for (let t = 0; t < i.length; t++) {
|
|
40
|
+
const s = ce(i[t]);
|
|
41
|
+
s && (e += s + " ");
|
|
42
42
|
}
|
|
43
|
-
else if (
|
|
44
|
-
for (const
|
|
45
|
-
t
|
|
43
|
+
else if (T(i))
|
|
44
|
+
for (const t in i)
|
|
45
|
+
i[t] && (e += t + " ");
|
|
46
46
|
return e.trim();
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
@@ -54,111 +54,111 @@ process.env.NODE_ENV;
|
|
|
54
54
|
process.env.NODE_ENV;
|
|
55
55
|
process.env.NODE_ENV;
|
|
56
56
|
new Set(
|
|
57
|
-
/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((
|
|
57
|
+
/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((i) => i !== "arguments" && i !== "caller").map((i) => Symbol[i]).filter(xe)
|
|
58
58
|
);
|
|
59
|
-
function
|
|
60
|
-
return
|
|
59
|
+
function Ce(i) {
|
|
60
|
+
return ne(i) ? Ce(i.__v_raw) : !!(i && i.__v_isReactive);
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
return !!(
|
|
62
|
+
function ne(i) {
|
|
63
|
+
return !!(i && i.__v_isReadonly);
|
|
64
64
|
}
|
|
65
|
-
function Z(
|
|
66
|
-
return !!(
|
|
65
|
+
function Z(i) {
|
|
66
|
+
return !!(i && i.__v_isShallow);
|
|
67
67
|
}
|
|
68
|
-
function oe(
|
|
69
|
-
return
|
|
68
|
+
function oe(i) {
|
|
69
|
+
return i ? !!i.__v_raw : !1;
|
|
70
70
|
}
|
|
71
|
-
function
|
|
72
|
-
const e =
|
|
73
|
-
return e ?
|
|
71
|
+
function O(i) {
|
|
72
|
+
const e = i && i.__v_raw;
|
|
73
|
+
return e ? O(e) : i;
|
|
74
74
|
}
|
|
75
|
-
function
|
|
76
|
-
return
|
|
75
|
+
function de(i) {
|
|
76
|
+
return i ? i.__v_isRef === !0 : !1;
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
79
|
* @vue/runtime-core v3.5.26
|
|
80
80
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
81
81
|
* @license MIT
|
|
82
82
|
**/
|
|
83
|
-
const
|
|
84
|
-
function
|
|
85
|
-
|
|
83
|
+
const $ = [];
|
|
84
|
+
function Ge(i) {
|
|
85
|
+
$.push(i);
|
|
86
86
|
}
|
|
87
|
-
function
|
|
88
|
-
|
|
87
|
+
function Ke() {
|
|
88
|
+
$.pop();
|
|
89
89
|
}
|
|
90
90
|
let ee = !1;
|
|
91
|
-
function _(
|
|
91
|
+
function _(i, ...e) {
|
|
92
92
|
if (ee) return;
|
|
93
93
|
ee = !0;
|
|
94
|
-
const
|
|
95
|
-
if (
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
const t = $.length ? $[$.length - 1].component : null, s = t && t.appContext.config.warnHandler, n = Je();
|
|
95
|
+
if (s)
|
|
96
|
+
ue(
|
|
97
|
+
s,
|
|
98
|
+
t,
|
|
99
99
|
11,
|
|
100
100
|
[
|
|
101
101
|
// eslint-disable-next-line no-restricted-syntax
|
|
102
|
-
|
|
103
|
-
var
|
|
104
|
-
return (
|
|
102
|
+
i + e.map((o) => {
|
|
103
|
+
var a, r;
|
|
104
|
+
return (r = (a = o.toString) == null ? void 0 : a.call(o)) != null ? r : JSON.stringify(o);
|
|
105
105
|
}).join(""),
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
({ vnode: o }) => `at <${
|
|
106
|
+
t && t.proxy,
|
|
107
|
+
n.map(
|
|
108
|
+
({ vnode: o }) => `at <${Ve(t, o.type)}>`
|
|
109
109
|
).join(`
|
|
110
110
|
`),
|
|
111
|
-
|
|
111
|
+
n
|
|
112
112
|
]
|
|
113
113
|
);
|
|
114
114
|
else {
|
|
115
|
-
const o = [`[Vue warn]: ${
|
|
116
|
-
|
|
117
|
-
`, ...
|
|
115
|
+
const o = [`[Vue warn]: ${i}`, ...e];
|
|
116
|
+
n.length && o.push(`
|
|
117
|
+
`, ...Xe(n)), console.warn(...o);
|
|
118
118
|
}
|
|
119
119
|
ee = !1;
|
|
120
120
|
}
|
|
121
121
|
function Je() {
|
|
122
|
-
let
|
|
123
|
-
if (!
|
|
122
|
+
let i = $[$.length - 1];
|
|
123
|
+
if (!i)
|
|
124
124
|
return [];
|
|
125
125
|
const e = [];
|
|
126
|
-
for (;
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
vnode:
|
|
126
|
+
for (; i; ) {
|
|
127
|
+
const t = e[0];
|
|
128
|
+
t && t.vnode === i ? t.recurseCount++ : e.push({
|
|
129
|
+
vnode: i,
|
|
130
130
|
recurseCount: 0
|
|
131
131
|
});
|
|
132
|
-
const
|
|
133
|
-
|
|
132
|
+
const s = i.component && i.component.parent;
|
|
133
|
+
i = s && s.vnode;
|
|
134
134
|
}
|
|
135
135
|
return e;
|
|
136
136
|
}
|
|
137
|
-
function
|
|
137
|
+
function Xe(i) {
|
|
138
138
|
const e = [];
|
|
139
|
-
return
|
|
140
|
-
e.push(...
|
|
141
|
-
`], ...
|
|
139
|
+
return i.forEach((t, s) => {
|
|
140
|
+
e.push(...s === 0 ? [] : [`
|
|
141
|
+
`], ...Qe(t));
|
|
142
142
|
}), e;
|
|
143
143
|
}
|
|
144
|
-
function
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
)}`, o = ">" +
|
|
150
|
-
return
|
|
144
|
+
function Qe({ vnode: i, recurseCount: e }) {
|
|
145
|
+
const t = e > 0 ? `... (${e} recursive calls)` : "", s = i.component ? i.component.parent == null : !1, n = ` at <${Ve(
|
|
146
|
+
i.component,
|
|
147
|
+
i.type,
|
|
148
|
+
s
|
|
149
|
+
)}`, o = ">" + t;
|
|
150
|
+
return i.props ? [n, ...Ze(i.props), o] : [n + o];
|
|
151
151
|
}
|
|
152
|
-
function
|
|
153
|
-
const e = [],
|
|
154
|
-
return
|
|
155
|
-
e.push(...Se(
|
|
156
|
-
}),
|
|
152
|
+
function Ze(i) {
|
|
153
|
+
const e = [], t = Object.keys(i);
|
|
154
|
+
return t.slice(0, 3).forEach((s) => {
|
|
155
|
+
e.push(...Se(s, i[s]));
|
|
156
|
+
}), t.length > 3 && e.push(" ..."), e;
|
|
157
157
|
}
|
|
158
|
-
function Se(
|
|
159
|
-
return
|
|
158
|
+
function Se(i, e, t) {
|
|
159
|
+
return R(e) ? (e = JSON.stringify(e), t ? e : [`${i}=${e}`]) : typeof e == "number" || typeof e == "boolean" || e == null ? t ? e : [`${i}=${e}`] : de(e) ? (e = Se(i, O(e.value), !0), t ? e : [`${i}=Ref<`, e, ">"]) : I(e) ? [`${i}=fn${e.name ? `<${e.name}>` : ""}`] : (e = O(e), t ? e : [`${i}=`, e]);
|
|
160
160
|
}
|
|
161
|
-
const
|
|
161
|
+
const Ee = {
|
|
162
162
|
sp: "serverPrefetch hook",
|
|
163
163
|
bc: "beforeCreate hook",
|
|
164
164
|
c: "created hook",
|
|
@@ -191,312 +191,312 @@ const Ce = {
|
|
|
191
191
|
15: "component update",
|
|
192
192
|
16: "app unmount cleanup function"
|
|
193
193
|
};
|
|
194
|
-
function
|
|
194
|
+
function ue(i, e, t, s) {
|
|
195
195
|
try {
|
|
196
|
-
return
|
|
197
|
-
} catch (
|
|
198
|
-
|
|
196
|
+
return s ? i(...s) : i();
|
|
197
|
+
} catch (n) {
|
|
198
|
+
ke(n, e, t);
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
|
-
function
|
|
202
|
-
const
|
|
201
|
+
function ke(i, e, t, s = !0) {
|
|
202
|
+
const n = e ? e.vnode : null, { errorHandler: o, throwUnhandledErrorInProduction: a } = e && e.appContext.config || se;
|
|
203
203
|
if (e) {
|
|
204
|
-
let
|
|
205
|
-
const c = e.proxy, h = process.env.NODE_ENV !== "production" ?
|
|
206
|
-
for (;
|
|
207
|
-
const d =
|
|
204
|
+
let r = e.parent;
|
|
205
|
+
const c = e.proxy, h = process.env.NODE_ENV !== "production" ? Ee[t] : `https://vuejs.org/error-reference/#runtime-${t}`;
|
|
206
|
+
for (; r; ) {
|
|
207
|
+
const d = r.ec;
|
|
208
208
|
if (d) {
|
|
209
209
|
for (let l = 0; l < d.length; l++)
|
|
210
|
-
if (d[l](
|
|
210
|
+
if (d[l](i, c, h) === !1)
|
|
211
211
|
return;
|
|
212
212
|
}
|
|
213
|
-
|
|
213
|
+
r = r.parent;
|
|
214
214
|
}
|
|
215
215
|
if (o) {
|
|
216
|
-
|
|
217
|
-
|
|
216
|
+
ue(o, null, 10, [
|
|
217
|
+
i,
|
|
218
218
|
c,
|
|
219
219
|
h
|
|
220
220
|
]);
|
|
221
221
|
return;
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
|
-
|
|
224
|
+
et(i, t, n, s, a);
|
|
225
225
|
}
|
|
226
|
-
function
|
|
226
|
+
function et(i, e, t, s = !0, n = !1) {
|
|
227
227
|
if (process.env.NODE_ENV !== "production") {
|
|
228
|
-
const o =
|
|
229
|
-
if (
|
|
230
|
-
throw
|
|
231
|
-
console.error(
|
|
228
|
+
const o = Ee[e];
|
|
229
|
+
if (t && Ge(t), _(`Unhandled error${o ? ` during execution of ${o}` : ""}`), t && Ke(), s)
|
|
230
|
+
throw i;
|
|
231
|
+
console.error(i);
|
|
232
232
|
} else {
|
|
233
|
-
if (
|
|
234
|
-
throw
|
|
235
|
-
console.error(
|
|
233
|
+
if (n)
|
|
234
|
+
throw i;
|
|
235
|
+
console.error(i);
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
|
-
const
|
|
239
|
-
let
|
|
240
|
-
const
|
|
241
|
-
let
|
|
242
|
-
const
|
|
238
|
+
const S = [];
|
|
239
|
+
let A = -1;
|
|
240
|
+
const P = [];
|
|
241
|
+
let N = null, F = 0;
|
|
242
|
+
const tt = /* @__PURE__ */ Promise.resolve();
|
|
243
243
|
let re = null;
|
|
244
|
-
const
|
|
245
|
-
function
|
|
246
|
-
let e =
|
|
247
|
-
for (; e <
|
|
248
|
-
const
|
|
249
|
-
o <
|
|
244
|
+
const it = 100;
|
|
245
|
+
function st(i) {
|
|
246
|
+
let e = A + 1, t = S.length;
|
|
247
|
+
for (; e < t; ) {
|
|
248
|
+
const s = e + t >>> 1, n = S[s], o = D(n);
|
|
249
|
+
o < i || o === i && n.flags & 2 ? e = s + 1 : t = s;
|
|
250
250
|
}
|
|
251
251
|
return e;
|
|
252
252
|
}
|
|
253
|
-
function
|
|
254
|
-
if (!(
|
|
255
|
-
const e =
|
|
256
|
-
!
|
|
257
|
-
!(
|
|
253
|
+
function nt(i) {
|
|
254
|
+
if (!(i.flags & 1)) {
|
|
255
|
+
const e = D(i), t = S[S.length - 1];
|
|
256
|
+
!t || // fast path when the job id is larger than the tail
|
|
257
|
+
!(i.flags & 2) && e >= D(t) ? S.push(i) : S.splice(st(e), 0, i), i.flags |= 1, _e();
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
|
-
function
|
|
261
|
-
re || (re =
|
|
260
|
+
function _e() {
|
|
261
|
+
re || (re = tt.then(Ae));
|
|
262
262
|
}
|
|
263
|
-
function
|
|
264
|
-
k(
|
|
263
|
+
function ot(i) {
|
|
264
|
+
k(i) ? P.push(...i) : N && i.id === -1 ? N.splice(F + 1, 0, i) : i.flags & 1 || (P.push(i), i.flags |= 1), _e();
|
|
265
265
|
}
|
|
266
|
-
function
|
|
267
|
-
if (
|
|
268
|
-
const e = [...new Set(
|
|
269
|
-
(
|
|
266
|
+
function rt(i) {
|
|
267
|
+
if (P.length) {
|
|
268
|
+
const e = [...new Set(P)].sort(
|
|
269
|
+
(t, s) => D(t) - D(s)
|
|
270
270
|
);
|
|
271
|
-
if (
|
|
272
|
-
|
|
271
|
+
if (P.length = 0, N) {
|
|
272
|
+
N.push(...e);
|
|
273
273
|
return;
|
|
274
274
|
}
|
|
275
|
-
for (
|
|
276
|
-
const
|
|
277
|
-
process.env.NODE_ENV !== "production" &&
|
|
275
|
+
for (N = e, process.env.NODE_ENV !== "production" && (i = i || /* @__PURE__ */ new Map()), F = 0; F < N.length; F++) {
|
|
276
|
+
const t = N[F];
|
|
277
|
+
process.env.NODE_ENV !== "production" && Le(i, t) || (t.flags & 4 && (t.flags &= -2), t.flags & 8 || t(), t.flags &= -2);
|
|
278
278
|
}
|
|
279
|
-
|
|
279
|
+
N = null, F = 0;
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
|
-
const
|
|
283
|
-
function
|
|
284
|
-
process.env.NODE_ENV !== "production" && (
|
|
285
|
-
const e = process.env.NODE_ENV !== "production" ? (
|
|
282
|
+
const D = (i) => i.id == null ? i.flags & 2 ? -1 : 1 / 0 : i.id;
|
|
283
|
+
function Ae(i) {
|
|
284
|
+
process.env.NODE_ENV !== "production" && (i = i || /* @__PURE__ */ new Map());
|
|
285
|
+
const e = process.env.NODE_ENV !== "production" ? (t) => Le(i, t) : we;
|
|
286
286
|
try {
|
|
287
|
-
for (
|
|
288
|
-
const
|
|
289
|
-
if (
|
|
290
|
-
if (process.env.NODE_ENV !== "production" && e(
|
|
287
|
+
for (A = 0; A < S.length; A++) {
|
|
288
|
+
const t = S[A];
|
|
289
|
+
if (t && !(t.flags & 8)) {
|
|
290
|
+
if (process.env.NODE_ENV !== "production" && e(t))
|
|
291
291
|
continue;
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
),
|
|
292
|
+
t.flags & 4 && (t.flags &= -2), ue(
|
|
293
|
+
t,
|
|
294
|
+
t.i,
|
|
295
|
+
t.i ? 15 : 14
|
|
296
|
+
), t.flags & 4 || (t.flags &= -2);
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
} finally {
|
|
300
|
-
for (;
|
|
301
|
-
const
|
|
302
|
-
|
|
300
|
+
for (; A < S.length; A++) {
|
|
301
|
+
const t = S[A];
|
|
302
|
+
t && (t.flags &= -2);
|
|
303
303
|
}
|
|
304
|
-
|
|
304
|
+
A = -1, S.length = 0, rt(i), re = null, (S.length || P.length) && Ae(i);
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
|
-
function
|
|
308
|
-
const
|
|
309
|
-
if (
|
|
310
|
-
const
|
|
311
|
-
return
|
|
312
|
-
`Maximum recursive updates exceeded${
|
|
307
|
+
function Le(i, e) {
|
|
308
|
+
const t = i.get(e) || 0;
|
|
309
|
+
if (t > it) {
|
|
310
|
+
const s = e.i, n = s && Pe(s.type);
|
|
311
|
+
return ke(
|
|
312
|
+
`Maximum recursive updates exceeded${n ? ` in component <${n}>` : ""}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`,
|
|
313
313
|
null,
|
|
314
314
|
10
|
|
315
315
|
), !0;
|
|
316
316
|
}
|
|
317
|
-
return
|
|
317
|
+
return i.set(e, t + 1), !1;
|
|
318
318
|
}
|
|
319
319
|
const te = /* @__PURE__ */ new Map();
|
|
320
320
|
process.env.NODE_ENV !== "production" && (Q().__VUE_HMR_RUNTIME__ = {
|
|
321
|
-
createRecord:
|
|
322
|
-
rerender:
|
|
323
|
-
reload:
|
|
321
|
+
createRecord: ie(at),
|
|
322
|
+
rerender: ie(lt),
|
|
323
|
+
reload: ie(ct)
|
|
324
324
|
});
|
|
325
|
-
const
|
|
326
|
-
function
|
|
327
|
-
return
|
|
328
|
-
initialDef:
|
|
325
|
+
const K = /* @__PURE__ */ new Map();
|
|
326
|
+
function at(i, e) {
|
|
327
|
+
return K.has(i) ? !1 : (K.set(i, {
|
|
328
|
+
initialDef: J(e),
|
|
329
329
|
instances: /* @__PURE__ */ new Set()
|
|
330
330
|
}), !0);
|
|
331
331
|
}
|
|
332
|
-
function
|
|
333
|
-
return
|
|
332
|
+
function J(i) {
|
|
333
|
+
return De(i) ? i.__vccOpts : i;
|
|
334
334
|
}
|
|
335
|
-
function
|
|
336
|
-
const
|
|
337
|
-
|
|
338
|
-
e && (
|
|
335
|
+
function lt(i, e) {
|
|
336
|
+
const t = K.get(i);
|
|
337
|
+
t && (t.initialDef.render = e, [...t.instances].forEach((s) => {
|
|
338
|
+
e && (s.render = e, J(s.type).render = e), s.renderCache = [], s.job.flags & 8 || s.update();
|
|
339
339
|
}));
|
|
340
340
|
}
|
|
341
|
-
function
|
|
342
|
-
const
|
|
343
|
-
if (!
|
|
344
|
-
e =
|
|
345
|
-
const
|
|
346
|
-
for (let
|
|
347
|
-
const o =
|
|
348
|
-
let
|
|
349
|
-
|
|
350
|
-
o.job.flags & 8 || (o.parent.update(),
|
|
341
|
+
function ct(i, e) {
|
|
342
|
+
const t = K.get(i);
|
|
343
|
+
if (!t) return;
|
|
344
|
+
e = J(e), pe(t.initialDef, e);
|
|
345
|
+
const s = [...t.instances];
|
|
346
|
+
for (let n = 0; n < s.length; n++) {
|
|
347
|
+
const o = s[n], a = J(o.type);
|
|
348
|
+
let r = te.get(a);
|
|
349
|
+
r || (a !== t.initialDef && pe(a, e), te.set(a, r = /* @__PURE__ */ new Set())), r.add(o), o.appContext.propsCache.delete(o.type), o.appContext.emitsCache.delete(o.type), o.appContext.optionsCache.delete(o.type), o.ceReload ? (r.add(o), o.ceReload(e.styles), r.delete(o)) : o.parent ? nt(() => {
|
|
350
|
+
o.job.flags & 8 || (o.parent.update(), r.delete(o));
|
|
351
351
|
}) : o.appContext.reload ? o.appContext.reload() : typeof window < "u" ? window.location.reload() : console.warn(
|
|
352
352
|
"[HMR] Root or manually mounted instance modified. Full reload required."
|
|
353
|
-
), o.root.ce && o !== o.root && o.root.ce._removeChildStyle(
|
|
353
|
+
), o.root.ce && o !== o.root && o.root.ce._removeChildStyle(a);
|
|
354
354
|
}
|
|
355
|
-
|
|
355
|
+
ot(() => {
|
|
356
356
|
te.clear();
|
|
357
357
|
});
|
|
358
358
|
}
|
|
359
|
-
function
|
|
360
|
-
z(
|
|
361
|
-
for (const
|
|
362
|
-
|
|
359
|
+
function pe(i, e) {
|
|
360
|
+
z(i, e);
|
|
361
|
+
for (const t in i)
|
|
362
|
+
t !== "__file" && !(t in e) && delete i[t];
|
|
363
363
|
}
|
|
364
|
-
function
|
|
365
|
-
return (e,
|
|
364
|
+
function ie(i) {
|
|
365
|
+
return (e, t) => {
|
|
366
366
|
try {
|
|
367
|
-
return
|
|
368
|
-
} catch (
|
|
369
|
-
console.error(
|
|
367
|
+
return i(e, t);
|
|
368
|
+
} catch (s) {
|
|
369
|
+
console.error(s), console.warn(
|
|
370
370
|
"[HMR] Something went wrong during Vue component hot-reload. Full reload required."
|
|
371
371
|
);
|
|
372
372
|
}
|
|
373
373
|
};
|
|
374
374
|
}
|
|
375
|
-
let
|
|
376
|
-
function
|
|
377
|
-
var
|
|
378
|
-
|
|
375
|
+
let H, j = [];
|
|
376
|
+
function Me(i, e) {
|
|
377
|
+
var t, s;
|
|
378
|
+
H = i, H ? (H.enabled = !0, j.forEach(({ event: n, args: o }) => H.emit(n, ...o)), j = []) : /* handle late devtools injection - only do this if we are in an actual */ /* browser environment to avoid the timer handle stalling test runner exit */ /* (#4815) */ typeof window < "u" && // some envs mock window but not fully
|
|
379
379
|
window.HTMLElement && // also exclude jsdom
|
|
380
380
|
// eslint-disable-next-line no-restricted-syntax
|
|
381
|
-
!((
|
|
382
|
-
|
|
381
|
+
!((s = (t = window.navigator) == null ? void 0 : t.userAgent) != null && s.includes("jsdom")) ? ((e.__VUE_DEVTOOLS_HOOK_REPLAY__ = e.__VUE_DEVTOOLS_HOOK_REPLAY__ || []).push((o) => {
|
|
382
|
+
Me(o, e);
|
|
383
383
|
}), setTimeout(() => {
|
|
384
|
-
|
|
384
|
+
H || (e.__VUE_DEVTOOLS_HOOK_REPLAY__ = null, j = []);
|
|
385
385
|
}, 3e3)) : j = [];
|
|
386
386
|
}
|
|
387
|
-
let
|
|
388
|
-
function
|
|
389
|
-
if (process.env.NODE_ENV !== "production" && (!
|
|
390
|
-
let
|
|
391
|
-
const
|
|
392
|
-
|
|
387
|
+
let M = null, dt = null;
|
|
388
|
+
function ut(i, e) {
|
|
389
|
+
if (process.env.NODE_ENV !== "production" && (!L || L.isMounted) && _("provide() can only be used inside setup()."), L) {
|
|
390
|
+
let t = L.provides;
|
|
391
|
+
const s = L.parent && L.parent.provides;
|
|
392
|
+
s === t && (t = L.provides = Object.create(s)), t[i] = e;
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
|
-
function
|
|
396
|
-
const
|
|
397
|
-
if (
|
|
398
|
-
let
|
|
399
|
-
if (
|
|
400
|
-
return
|
|
395
|
+
function ft(i, e, t = !1) {
|
|
396
|
+
const s = It();
|
|
397
|
+
if (s || vt) {
|
|
398
|
+
let n = s ? s.parent == null || s.ce ? s.vnode.appContext && s.vnode.appContext.provides : s.parent.provides : void 0;
|
|
399
|
+
if (n && i in n)
|
|
400
|
+
return n[i];
|
|
401
401
|
if (arguments.length > 1)
|
|
402
|
-
return
|
|
403
|
-
process.env.NODE_ENV !== "production" && _(`injection "${String(
|
|
402
|
+
return t && I(e) ? e.call(s && s.proxy) : e;
|
|
403
|
+
process.env.NODE_ENV !== "production" && _(`injection "${String(i)}" not found.`);
|
|
404
404
|
} else process.env.NODE_ENV !== "production" && _("inject() can only be used inside setup() or functional components.");
|
|
405
405
|
}
|
|
406
|
-
const
|
|
407
|
-
function
|
|
408
|
-
|
|
406
|
+
const mt = (i) => i.__isTeleport;
|
|
407
|
+
function Ie(i, e) {
|
|
408
|
+
i.shapeFlag & 6 && i.component ? (i.transition = e, Ie(i.component.subTree, e)) : i.shapeFlag & 128 ? (i.ssContent.transition = e.clone(i.ssContent), i.ssFallback.transition = e.clone(i.ssFallback)) : i.transition = e;
|
|
409
409
|
}
|
|
410
410
|
// @__NO_SIDE_EFFECTS__
|
|
411
|
-
function
|
|
412
|
-
return
|
|
411
|
+
function ht(i, e) {
|
|
412
|
+
return I(i) ? (
|
|
413
413
|
// #8236: extend call and options.name access are considered side-effects
|
|
414
414
|
// by Rollup, so we have to wrap it in a pure-annotated IIFE.
|
|
415
|
-
z({ name:
|
|
416
|
-
) :
|
|
415
|
+
z({ name: i.name }, e, { setup: i })
|
|
416
|
+
) : i;
|
|
417
417
|
}
|
|
418
418
|
Q().requestIdleCallback;
|
|
419
419
|
Q().cancelIdleCallback;
|
|
420
|
-
const
|
|
421
|
-
function
|
|
422
|
-
if (
|
|
423
|
-
const h = Object.keys(
|
|
424
|
-
return
|
|
420
|
+
const pt = (i) => !!i.type.__asyncLoader, gt = /* @__PURE__ */ Symbol.for("v-ndc");
|
|
421
|
+
function yt(i, e, t = {}, s, n) {
|
|
422
|
+
if (M.ce || M.parent && pt(M.parent) && M.parent.ce) {
|
|
423
|
+
const h = Object.keys(t).length > 0;
|
|
424
|
+
return ge(), ye(
|
|
425
425
|
q,
|
|
426
426
|
null,
|
|
427
|
-
[
|
|
427
|
+
[fe("slot", t, s)],
|
|
428
428
|
h ? -2 : 64
|
|
429
429
|
);
|
|
430
430
|
}
|
|
431
|
-
let o =
|
|
431
|
+
let o = i[e];
|
|
432
432
|
process.env.NODE_ENV !== "production" && o && o.length > 1 && (_(
|
|
433
433
|
"SSR-optimized slot function detected in a non-SSR-optimized render function. You need to mark this component with $dynamic-slots in the parent template."
|
|
434
|
-
), o = () => []), o && o._c && (o._d = !1),
|
|
435
|
-
const
|
|
434
|
+
), o = () => []), o && o._c && (o._d = !1), ge();
|
|
435
|
+
const a = o && Ne(o(t)), r = t.key || // slot content array of a dynamic conditional slot may have a branch
|
|
436
436
|
// key attached in the `createSlots` helper, respect that
|
|
437
|
-
|
|
437
|
+
a && a.key, c = ye(
|
|
438
438
|
q,
|
|
439
439
|
{
|
|
440
|
-
key: (
|
|
441
|
-
(!
|
|
440
|
+
key: (r && !xe(r) ? r : `_${e}`) + // #7256 force differentiate fallback content from actual content
|
|
441
|
+
(!a && s ? "_fb" : "")
|
|
442
442
|
},
|
|
443
|
-
|
|
444
|
-
|
|
443
|
+
a || [],
|
|
444
|
+
a && i._ === 1 ? 64 : -2
|
|
445
445
|
);
|
|
446
446
|
return c.scopeId && (c.slotScopeIds = [c.scopeId + "-s"]), o && o._c && (o._d = !0), c;
|
|
447
447
|
}
|
|
448
|
-
function
|
|
449
|
-
return
|
|
448
|
+
function Ne(i) {
|
|
449
|
+
return i.some((e) => Oe(e) ? !(e.type === Te || e.type === q && !Ne(e.children)) : !0) ? i : null;
|
|
450
450
|
}
|
|
451
|
-
const
|
|
452
|
-
process.env.NODE_ENV !== "production" && (
|
|
451
|
+
const bt = {};
|
|
452
|
+
process.env.NODE_ENV !== "production" && (bt.ownKeys = (i) => (_(
|
|
453
453
|
"Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead."
|
|
454
|
-
), Reflect.ownKeys(
|
|
455
|
-
let
|
|
456
|
-
const
|
|
454
|
+
), Reflect.ownKeys(i)));
|
|
455
|
+
let vt = null;
|
|
456
|
+
const wt = {}, Re = (i) => Object.getPrototypeOf(i) === wt, xt = (i) => i.__isSuspense, q = /* @__PURE__ */ Symbol.for("v-fgt"), Ct = /* @__PURE__ */ Symbol.for("v-txt"), Te = /* @__PURE__ */ Symbol.for("v-cmt"), Y = [];
|
|
457
457
|
let E = null;
|
|
458
|
-
function
|
|
459
|
-
|
|
458
|
+
function ge(i = !1) {
|
|
459
|
+
Y.push(E = i ? null : []);
|
|
460
460
|
}
|
|
461
461
|
function St() {
|
|
462
|
-
|
|
462
|
+
Y.pop(), E = Y[Y.length - 1] || null;
|
|
463
463
|
}
|
|
464
|
-
function
|
|
465
|
-
return
|
|
464
|
+
function Et(i) {
|
|
465
|
+
return i.dynamicChildren = E || ze, St(), E && E.push(i), i;
|
|
466
466
|
}
|
|
467
|
-
function
|
|
468
|
-
return
|
|
469
|
-
|
|
470
|
-
t,
|
|
471
|
-
e,
|
|
472
|
-
n,
|
|
467
|
+
function ye(i, e, t, s, n) {
|
|
468
|
+
return Et(
|
|
469
|
+
fe(
|
|
473
470
|
i,
|
|
471
|
+
e,
|
|
472
|
+
t,
|
|
474
473
|
s,
|
|
474
|
+
n,
|
|
475
475
|
!0
|
|
476
476
|
)
|
|
477
477
|
);
|
|
478
478
|
}
|
|
479
|
-
function Oe(
|
|
480
|
-
return
|
|
479
|
+
function Oe(i) {
|
|
480
|
+
return i ? i.__v_isVNode === !0 : !1;
|
|
481
481
|
}
|
|
482
|
-
const
|
|
483
|
-
...
|
|
484
|
-
),
|
|
485
|
-
ref:
|
|
482
|
+
const kt = (...i) => Fe(
|
|
483
|
+
...i
|
|
484
|
+
), $e = ({ key: i }) => i ?? null, G = ({
|
|
485
|
+
ref: i,
|
|
486
486
|
ref_key: e,
|
|
487
|
-
ref_for:
|
|
488
|
-
}) => (typeof
|
|
489
|
-
function
|
|
487
|
+
ref_for: t
|
|
488
|
+
}) => (typeof i == "number" && (i = "" + i), i != null ? R(i) || de(i) || I(i) ? { i: M, r: i, k: e, f: !!t } : i : null);
|
|
489
|
+
function _t(i, e = null, t = null, s = 0, n = null, o = i === q ? 0 : 1, a = !1, r = !1) {
|
|
490
490
|
const c = {
|
|
491
491
|
__v_isVNode: !0,
|
|
492
492
|
__v_skip: !0,
|
|
493
|
-
type:
|
|
493
|
+
type: i,
|
|
494
494
|
props: e,
|
|
495
|
-
key: e &&
|
|
496
|
-
ref: e &&
|
|
497
|
-
scopeId:
|
|
495
|
+
key: e && $e(e),
|
|
496
|
+
ref: e && G(e),
|
|
497
|
+
scopeId: dt,
|
|
498
498
|
slotScopeIds: null,
|
|
499
|
-
children:
|
|
499
|
+
children: t,
|
|
500
500
|
component: null,
|
|
501
501
|
suspense: null,
|
|
502
502
|
ssContent: null,
|
|
@@ -510,14 +510,14 @@ function kt(t, e = null, n = null, i = 0, s = null, o = t === q ? 0 : 1, r = !1,
|
|
|
510
510
|
targetAnchor: null,
|
|
511
511
|
staticCount: 0,
|
|
512
512
|
shapeFlag: o,
|
|
513
|
-
patchFlag:
|
|
514
|
-
dynamicProps:
|
|
513
|
+
patchFlag: s,
|
|
514
|
+
dynamicProps: n,
|
|
515
515
|
dynamicChildren: null,
|
|
516
516
|
appContext: null,
|
|
517
|
-
ctx:
|
|
517
|
+
ctx: M
|
|
518
518
|
};
|
|
519
|
-
return
|
|
520
|
-
!
|
|
519
|
+
return r ? (me(c, t), o & 128 && i.normalize(c)) : t && (c.shapeFlag |= R(t) ? 8 : 16), process.env.NODE_ENV !== "production" && c.key !== c.key && _("VNode created with invalid key (NaN). VNode type:", c.type), // avoid a block node from tracking itself
|
|
520
|
+
!a && // has current parent block
|
|
521
521
|
E && // presence of a patch flag indicates this node needs patching on updates.
|
|
522
522
|
// component nodes also should always be patched, because even if the
|
|
523
523
|
// component doesn't need to update, it needs to persist the instance on to
|
|
@@ -526,212 +526,212 @@ function kt(t, e = null, n = null, i = 0, s = null, o = t === q ? 0 : 1, r = !1,
|
|
|
526
526
|
// vnode should not be considered dynamic due to handler caching.
|
|
527
527
|
c.patchFlag !== 32 && E.push(c), c;
|
|
528
528
|
}
|
|
529
|
-
const
|
|
530
|
-
function
|
|
531
|
-
if ((!
|
|
532
|
-
const
|
|
533
|
-
|
|
529
|
+
const fe = process.env.NODE_ENV !== "production" ? kt : Fe;
|
|
530
|
+
function Fe(i, e = null, t = null, s = 0, n = null, o = !1) {
|
|
531
|
+
if ((!i || i === gt) && (process.env.NODE_ENV !== "production" && !i && _(`Invalid vnode type when creating vnode: ${i}.`), i = Te), Oe(i)) {
|
|
532
|
+
const r = X(
|
|
533
|
+
i,
|
|
534
534
|
e,
|
|
535
535
|
!0
|
|
536
536
|
/* mergeRef: true */
|
|
537
537
|
);
|
|
538
|
-
return
|
|
538
|
+
return t && me(r, t), !o && E && (r.shapeFlag & 6 ? E[E.indexOf(i)] = r : E.push(r)), r.patchFlag = -2, r;
|
|
539
539
|
}
|
|
540
|
-
if (
|
|
541
|
-
e =
|
|
542
|
-
let { class:
|
|
543
|
-
|
|
540
|
+
if (De(i) && (i = i.__vccOpts), e) {
|
|
541
|
+
e = At(e);
|
|
542
|
+
let { class: r, style: c } = e;
|
|
543
|
+
r && !R(r) && (e.class = ce(r)), T(c) && (oe(c) && !k(c) && (c = z({}, c)), e.style = le(c));
|
|
544
544
|
}
|
|
545
|
-
const
|
|
546
|
-
return process.env.NODE_ENV !== "production" &&
|
|
545
|
+
const a = R(i) ? 1 : xt(i) ? 128 : mt(i) ? 64 : T(i) ? 4 : I(i) ? 2 : 0;
|
|
546
|
+
return process.env.NODE_ENV !== "production" && a & 4 && oe(i) && (i = O(i), _(
|
|
547
547
|
"Vue received a Component that was made a reactive object. This can lead to unnecessary performance overhead and should be avoided by marking the component with `markRaw` or using `shallowRef` instead of `ref`.",
|
|
548
548
|
`
|
|
549
549
|
Component that was made reactive: `,
|
|
550
|
-
|
|
551
|
-
)),
|
|
552
|
-
t,
|
|
553
|
-
e,
|
|
554
|
-
n,
|
|
550
|
+
i
|
|
551
|
+
)), _t(
|
|
555
552
|
i,
|
|
553
|
+
e,
|
|
554
|
+
t,
|
|
556
555
|
s,
|
|
557
|
-
|
|
556
|
+
n,
|
|
557
|
+
a,
|
|
558
558
|
o,
|
|
559
559
|
!0
|
|
560
560
|
);
|
|
561
561
|
}
|
|
562
|
-
function
|
|
563
|
-
return
|
|
562
|
+
function At(i) {
|
|
563
|
+
return i ? oe(i) || Re(i) ? z({}, i) : i : null;
|
|
564
564
|
}
|
|
565
|
-
function X(
|
|
566
|
-
const { props:
|
|
565
|
+
function X(i, e, t = !1, s = !1) {
|
|
566
|
+
const { props: n, ref: o, patchFlag: a, children: r, transition: c } = i, h = e ? Mt(n || {}, e) : n, d = {
|
|
567
567
|
__v_isVNode: !0,
|
|
568
568
|
__v_skip: !0,
|
|
569
|
-
type:
|
|
569
|
+
type: i.type,
|
|
570
570
|
props: h,
|
|
571
|
-
key: h &&
|
|
571
|
+
key: h && $e(h),
|
|
572
572
|
ref: e && e.ref ? (
|
|
573
573
|
// #2078 in the case of <component :is="vnode" ref="extra"/>
|
|
574
574
|
// if the vnode itself already has a ref, cloneVNode will need to merge
|
|
575
575
|
// the refs so the single vnode can be set on multiple refs
|
|
576
|
-
|
|
576
|
+
t && o ? k(o) ? o.concat(G(e)) : [o, G(e)] : G(e)
|
|
577
577
|
) : o,
|
|
578
|
-
scopeId:
|
|
579
|
-
slotScopeIds:
|
|
580
|
-
children: process.env.NODE_ENV !== "production" &&
|
|
581
|
-
target:
|
|
582
|
-
targetStart:
|
|
583
|
-
targetAnchor:
|
|
584
|
-
staticCount:
|
|
585
|
-
shapeFlag:
|
|
578
|
+
scopeId: i.scopeId,
|
|
579
|
+
slotScopeIds: i.slotScopeIds,
|
|
580
|
+
children: process.env.NODE_ENV !== "production" && a === -1 && k(r) ? r.map(He) : r,
|
|
581
|
+
target: i.target,
|
|
582
|
+
targetStart: i.targetStart,
|
|
583
|
+
targetAnchor: i.targetAnchor,
|
|
584
|
+
staticCount: i.staticCount,
|
|
585
|
+
shapeFlag: i.shapeFlag,
|
|
586
586
|
// if the vnode is cloned with extra props, we can no longer assume its
|
|
587
587
|
// existing patch flag to be reliable and need to add the FULL_PROPS flag.
|
|
588
588
|
// note: preserve flag for fragments since they use the flag for children
|
|
589
589
|
// fast paths only.
|
|
590
|
-
patchFlag: e &&
|
|
591
|
-
dynamicProps:
|
|
592
|
-
dynamicChildren:
|
|
593
|
-
appContext:
|
|
594
|
-
dirs:
|
|
590
|
+
patchFlag: e && i.type !== q ? a === -1 ? 16 : a | 16 : a,
|
|
591
|
+
dynamicProps: i.dynamicProps,
|
|
592
|
+
dynamicChildren: i.dynamicChildren,
|
|
593
|
+
appContext: i.appContext,
|
|
594
|
+
dirs: i.dirs,
|
|
595
595
|
transition: c,
|
|
596
596
|
// These should technically only be non-null on mounted VNodes. However,
|
|
597
597
|
// they *should* be copied for kept-alive vnodes. So we just always copy
|
|
598
598
|
// them since them being non-null during a mount doesn't affect the logic as
|
|
599
599
|
// they will simply be overwritten.
|
|
600
|
-
component:
|
|
601
|
-
suspense:
|
|
602
|
-
ssContent:
|
|
603
|
-
ssFallback:
|
|
604
|
-
placeholder:
|
|
605
|
-
el:
|
|
606
|
-
anchor:
|
|
607
|
-
ctx:
|
|
608
|
-
ce:
|
|
600
|
+
component: i.component,
|
|
601
|
+
suspense: i.suspense,
|
|
602
|
+
ssContent: i.ssContent && X(i.ssContent),
|
|
603
|
+
ssFallback: i.ssFallback && X(i.ssFallback),
|
|
604
|
+
placeholder: i.placeholder,
|
|
605
|
+
el: i.el,
|
|
606
|
+
anchor: i.anchor,
|
|
607
|
+
ctx: i.ctx,
|
|
608
|
+
ce: i.ce
|
|
609
609
|
};
|
|
610
|
-
return c &&
|
|
610
|
+
return c && s && Ie(
|
|
611
611
|
d,
|
|
612
612
|
c.clone(d)
|
|
613
613
|
), d;
|
|
614
614
|
}
|
|
615
|
-
function
|
|
616
|
-
const e = X(
|
|
617
|
-
return k(
|
|
615
|
+
function He(i) {
|
|
616
|
+
const e = X(i);
|
|
617
|
+
return k(i.children) && (e.children = i.children.map(He)), e;
|
|
618
618
|
}
|
|
619
|
-
function
|
|
620
|
-
return
|
|
619
|
+
function Lt(i = " ", e = 0) {
|
|
620
|
+
return fe(Ct, null, i, e);
|
|
621
621
|
}
|
|
622
|
-
function
|
|
623
|
-
let
|
|
624
|
-
const { shapeFlag:
|
|
622
|
+
function me(i, e) {
|
|
623
|
+
let t = 0;
|
|
624
|
+
const { shapeFlag: s } = i;
|
|
625
625
|
if (e == null)
|
|
626
626
|
e = null;
|
|
627
627
|
else if (k(e))
|
|
628
|
-
|
|
628
|
+
t = 16;
|
|
629
629
|
else if (typeof e == "object")
|
|
630
|
-
if (
|
|
631
|
-
const
|
|
632
|
-
|
|
630
|
+
if (s & 65) {
|
|
631
|
+
const n = e.default;
|
|
632
|
+
n && (n._c && (n._d = !1), me(i, n()), n._c && (n._d = !0));
|
|
633
633
|
return;
|
|
634
634
|
} else
|
|
635
|
-
|
|
636
|
-
else
|
|
637
|
-
|
|
635
|
+
t = 32, !e._ && !Re(e) && (e._ctx = M);
|
|
636
|
+
else I(e) ? (e = { default: e, _ctx: M }, t = 32) : (e = String(e), s & 64 ? (t = 16, e = [Lt(e)]) : t = 8);
|
|
637
|
+
i.children = e, i.shapeFlag |= t;
|
|
638
638
|
}
|
|
639
|
-
function
|
|
639
|
+
function Mt(...i) {
|
|
640
640
|
const e = {};
|
|
641
|
-
for (let
|
|
642
|
-
const
|
|
643
|
-
for (const
|
|
644
|
-
if (
|
|
645
|
-
e.class !==
|
|
646
|
-
else if (
|
|
647
|
-
e.style =
|
|
648
|
-
else if (
|
|
649
|
-
const o = e[
|
|
650
|
-
|
|
651
|
-
} else
|
|
641
|
+
for (let t = 0; t < i.length; t++) {
|
|
642
|
+
const s = i[t];
|
|
643
|
+
for (const n in s)
|
|
644
|
+
if (n === "class")
|
|
645
|
+
e.class !== s.class && (e.class = ce([e.class, s.class]));
|
|
646
|
+
else if (n === "style")
|
|
647
|
+
e.style = le([e.style, s.style]);
|
|
648
|
+
else if (Be(n)) {
|
|
649
|
+
const o = e[n], a = s[n];
|
|
650
|
+
a && o !== a && !(k(o) && o.includes(a)) && (e[n] = o ? [].concat(o, a) : a);
|
|
651
|
+
} else n !== "" && (e[n] = s[n]);
|
|
652
652
|
}
|
|
653
653
|
return e;
|
|
654
654
|
}
|
|
655
|
-
let
|
|
656
|
-
const
|
|
655
|
+
let L = null;
|
|
656
|
+
const It = () => L || M;
|
|
657
657
|
{
|
|
658
|
-
const
|
|
659
|
-
let
|
|
660
|
-
return (
|
|
661
|
-
|
|
658
|
+
const i = Q(), e = (t, s) => {
|
|
659
|
+
let n;
|
|
660
|
+
return (n = i[t]) || (n = i[t] = []), n.push(s), (o) => {
|
|
661
|
+
n.length > 1 ? n.forEach((a) => a(o)) : n[0](o);
|
|
662
662
|
};
|
|
663
663
|
};
|
|
664
664
|
e(
|
|
665
665
|
"__VUE_INSTANCE_SETTERS__",
|
|
666
|
-
(
|
|
666
|
+
(t) => L = t
|
|
667
667
|
), e(
|
|
668
668
|
"__VUE_SSR_SETTERS__",
|
|
669
|
-
(
|
|
669
|
+
(t) => t
|
|
670
670
|
);
|
|
671
671
|
}
|
|
672
672
|
process.env.NODE_ENV;
|
|
673
|
-
const
|
|
674
|
-
function
|
|
675
|
-
return
|
|
676
|
-
}
|
|
677
|
-
function
|
|
678
|
-
let
|
|
679
|
-
if (!
|
|
680
|
-
const
|
|
681
|
-
|
|
682
|
-
}
|
|
683
|
-
if (!
|
|
684
|
-
const
|
|
685
|
-
for (const
|
|
686
|
-
if (o[
|
|
687
|
-
return
|
|
673
|
+
const Nt = /(?:^|[-_])\w/g, Rt = (i) => i.replace(Nt, (e) => e.toUpperCase()).replace(/[-_]/g, "");
|
|
674
|
+
function Pe(i, e = !0) {
|
|
675
|
+
return I(i) ? i.displayName || i.name : i.name || e && i.__name;
|
|
676
|
+
}
|
|
677
|
+
function Ve(i, e, t = !1) {
|
|
678
|
+
let s = Pe(e);
|
|
679
|
+
if (!s && e.__file) {
|
|
680
|
+
const n = e.__file.match(/([^/\\]+)\.\w+$/);
|
|
681
|
+
n && (s = n[1]);
|
|
682
|
+
}
|
|
683
|
+
if (!s && i) {
|
|
684
|
+
const n = (o) => {
|
|
685
|
+
for (const a in o)
|
|
686
|
+
if (o[a] === e)
|
|
687
|
+
return a;
|
|
688
688
|
};
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
) ||
|
|
689
|
+
s = n(i.components) || i.parent && n(
|
|
690
|
+
i.parent.type.components
|
|
691
|
+
) || n(i.appContext.components);
|
|
692
692
|
}
|
|
693
|
-
return
|
|
693
|
+
return s ? Rt(s) : t ? "App" : "Anonymous";
|
|
694
694
|
}
|
|
695
|
-
function
|
|
696
|
-
return
|
|
695
|
+
function De(i) {
|
|
696
|
+
return I(i) && "__vccOpts" in i;
|
|
697
697
|
}
|
|
698
698
|
function Tt() {
|
|
699
699
|
if (process.env.NODE_ENV === "production" || typeof window > "u")
|
|
700
700
|
return;
|
|
701
|
-
const
|
|
701
|
+
const i = { style: "color:#3ba776" }, e = { style: "color:#1677ff" }, t = { style: "color:#f5222d" }, s = { style: "color:#eb2f96" }, n = {
|
|
702
702
|
__vue_custom_formatter: !0,
|
|
703
703
|
header(l) {
|
|
704
|
-
if (!
|
|
704
|
+
if (!T(l))
|
|
705
705
|
return null;
|
|
706
706
|
if (l.__isVue)
|
|
707
|
-
return ["div",
|
|
708
|
-
if (
|
|
707
|
+
return ["div", i, "VueInstance"];
|
|
708
|
+
if (de(l)) {
|
|
709
709
|
const f = l.value;
|
|
710
710
|
return [
|
|
711
711
|
"div",
|
|
712
712
|
{},
|
|
713
|
-
["span",
|
|
713
|
+
["span", i, d(l)],
|
|
714
714
|
"<",
|
|
715
|
-
|
|
715
|
+
r(f),
|
|
716
716
|
">"
|
|
717
717
|
];
|
|
718
718
|
} else {
|
|
719
|
-
if (
|
|
719
|
+
if (Ce(l))
|
|
720
720
|
return [
|
|
721
721
|
"div",
|
|
722
722
|
{},
|
|
723
|
-
["span",
|
|
723
|
+
["span", i, Z(l) ? "ShallowReactive" : "Reactive"],
|
|
724
724
|
"<",
|
|
725
|
-
|
|
726
|
-
`>${
|
|
725
|
+
r(l),
|
|
726
|
+
`>${ne(l) ? " (readonly)" : ""}`
|
|
727
727
|
];
|
|
728
|
-
if (
|
|
728
|
+
if (ne(l))
|
|
729
729
|
return [
|
|
730
730
|
"div",
|
|
731
731
|
{},
|
|
732
|
-
["span",
|
|
732
|
+
["span", i, Z(l) ? "ShallowReadonly" : "Readonly"],
|
|
733
733
|
"<",
|
|
734
|
-
|
|
734
|
+
r(l),
|
|
735
735
|
">"
|
|
736
736
|
];
|
|
737
737
|
}
|
|
@@ -751,24 +751,24 @@ function Tt() {
|
|
|
751
751
|
};
|
|
752
752
|
function o(l) {
|
|
753
753
|
const f = [];
|
|
754
|
-
l.type.props && l.props && f.push(
|
|
754
|
+
l.type.props && l.props && f.push(a("props", O(l.props))), l.setupState !== se && f.push(a("setup", l.setupState)), l.data !== se && f.push(a("data", O(l.data)));
|
|
755
755
|
const m = c(l, "computed");
|
|
756
|
-
m && f.push(
|
|
756
|
+
m && f.push(a("computed", m));
|
|
757
757
|
const y = c(l, "inject");
|
|
758
|
-
return y && f.push(
|
|
758
|
+
return y && f.push(a("injected", y)), f.push([
|
|
759
759
|
"div",
|
|
760
760
|
{},
|
|
761
761
|
[
|
|
762
762
|
"span",
|
|
763
763
|
{
|
|
764
|
-
style:
|
|
764
|
+
style: s.style + ";opacity:0.66"
|
|
765
765
|
},
|
|
766
766
|
"$ (internal): "
|
|
767
767
|
],
|
|
768
768
|
["object", { object: l }]
|
|
769
769
|
]), f;
|
|
770
770
|
}
|
|
771
|
-
function
|
|
771
|
+
function a(l, f) {
|
|
772
772
|
return f = z({}, f), Object.keys(f).length ? [
|
|
773
773
|
"div",
|
|
774
774
|
{ style: "line-height:1.25em;margin-bottom:0.6em" },
|
|
@@ -787,18 +787,18 @@ function Tt() {
|
|
|
787
787
|
...Object.keys(f).map((m) => [
|
|
788
788
|
"div",
|
|
789
789
|
{},
|
|
790
|
-
["span",
|
|
791
|
-
|
|
790
|
+
["span", s, m + ": "],
|
|
791
|
+
r(f[m], !1)
|
|
792
792
|
])
|
|
793
793
|
]
|
|
794
794
|
] : ["span", {}];
|
|
795
795
|
}
|
|
796
|
-
function
|
|
797
|
-
return typeof l == "number" ? ["span", e, l] : typeof l == "string" ? ["span",
|
|
796
|
+
function r(l, f = !0) {
|
|
797
|
+
return typeof l == "number" ? ["span", e, l] : typeof l == "string" ? ["span", t, JSON.stringify(l)] : typeof l == "boolean" ? ["span", s, l] : T(l) ? ["object", { object: f ? O(l) : l }] : ["span", t, String(l)];
|
|
798
798
|
}
|
|
799
799
|
function c(l, f) {
|
|
800
800
|
const m = l.type;
|
|
801
|
-
if (
|
|
801
|
+
if (I(m))
|
|
802
802
|
return;
|
|
803
803
|
const y = {};
|
|
804
804
|
for (const u in l.ctx)
|
|
@@ -807,13 +807,13 @@ function Tt() {
|
|
|
807
807
|
}
|
|
808
808
|
function h(l, f, m) {
|
|
809
809
|
const y = l[m];
|
|
810
|
-
if (k(y) && y.includes(f) ||
|
|
810
|
+
if (k(y) && y.includes(f) || T(y) && f in y || l.extends && h(l.extends, f, m) || l.mixins && l.mixins.some((u) => h(u, f, m)))
|
|
811
811
|
return !0;
|
|
812
812
|
}
|
|
813
813
|
function d(l) {
|
|
814
814
|
return Z(l) ? "ShallowRef" : l.effect ? "ComputedRef" : "Ref";
|
|
815
815
|
}
|
|
816
|
-
window.devtoolsFormatters ? window.devtoolsFormatters.push(
|
|
816
|
+
window.devtoolsFormatters ? window.devtoolsFormatters.push(n) : window.devtoolsFormatters = [n];
|
|
817
817
|
}
|
|
818
818
|
process.env.NODE_ENV;
|
|
819
819
|
process.env.NODE_ENV;
|
|
@@ -827,59 +827,59 @@ function Ot() {
|
|
|
827
827
|
Tt();
|
|
828
828
|
}
|
|
829
829
|
process.env.NODE_ENV !== "production" && Ot();
|
|
830
|
-
class
|
|
830
|
+
class be {
|
|
831
831
|
constructor(e) {
|
|
832
832
|
this.endpoint = e || "https://foisit-ninja.netlify.app/.netlify/functions/intent";
|
|
833
833
|
}
|
|
834
|
-
async determineIntent(e,
|
|
834
|
+
async determineIntent(e, t, s) {
|
|
835
835
|
try {
|
|
836
|
-
const
|
|
836
|
+
const n = {
|
|
837
837
|
userInput: e,
|
|
838
|
-
commands:
|
|
839
|
-
id:
|
|
840
|
-
command:
|
|
841
|
-
description:
|
|
842
|
-
parameters:
|
|
838
|
+
commands: t.map((r) => ({
|
|
839
|
+
id: r.id,
|
|
840
|
+
command: r.command,
|
|
841
|
+
description: r.description,
|
|
842
|
+
parameters: r.parameters
|
|
843
843
|
// Send param schemas to AI
|
|
844
844
|
})),
|
|
845
|
-
context:
|
|
845
|
+
context: s
|
|
846
846
|
}, o = await fetch(this.endpoint, {
|
|
847
847
|
method: "POST",
|
|
848
848
|
headers: {
|
|
849
849
|
"Content-Type": "application/json"
|
|
850
850
|
},
|
|
851
|
-
body: JSON.stringify(
|
|
851
|
+
body: JSON.stringify(n)
|
|
852
852
|
});
|
|
853
853
|
if (!o.ok)
|
|
854
854
|
throw new Error(`Proxy API Error: ${o.statusText}`);
|
|
855
855
|
return await o.json();
|
|
856
|
-
} catch (
|
|
857
|
-
return console.error("OpenAIService Error:",
|
|
856
|
+
} catch (n) {
|
|
857
|
+
return console.error("OpenAIService Error:", n), { type: "unknown" };
|
|
858
858
|
}
|
|
859
859
|
}
|
|
860
860
|
}
|
|
861
|
-
class
|
|
861
|
+
class $t {
|
|
862
862
|
constructor(e = !0) {
|
|
863
863
|
if (this.commands = /* @__PURE__ */ new Map(), this.openAIService = null, this.context = null, this.pendingConfirmation = null, this.enableSmartIntent = !0, this.selectOptionsCache = /* @__PURE__ */ new Map(), typeof e == "boolean") {
|
|
864
|
-
this.enableSmartIntent = e, this.enableSmartIntent && (this.openAIService = new
|
|
864
|
+
this.enableSmartIntent = e, this.enableSmartIntent && (this.openAIService = new be());
|
|
865
865
|
return;
|
|
866
866
|
}
|
|
867
|
-
this.enableSmartIntent = e.enableSmartIntent ?? !0, this.enableSmartIntent && (this.openAIService = new
|
|
867
|
+
this.enableSmartIntent = e.enableSmartIntent ?? !0, this.enableSmartIntent && (this.openAIService = new be(e.intentEndpoint));
|
|
868
868
|
}
|
|
869
869
|
/** Add a new command (string or object) */
|
|
870
|
-
addCommand(e,
|
|
871
|
-
let
|
|
870
|
+
addCommand(e, t) {
|
|
871
|
+
let s;
|
|
872
872
|
if (typeof e == "string") {
|
|
873
|
-
if (!
|
|
873
|
+
if (!t)
|
|
874
874
|
throw new Error("Action required when adding command by string.");
|
|
875
|
-
|
|
875
|
+
s = {
|
|
876
876
|
id: e.toLowerCase().replace(/\s+/g, "_"),
|
|
877
877
|
command: e.toLowerCase(),
|
|
878
|
-
action:
|
|
878
|
+
action: t
|
|
879
879
|
};
|
|
880
880
|
} else
|
|
881
|
-
|
|
882
|
-
this.commands.set(
|
|
881
|
+
s = { ...e }, s.id || (s.id = s.command.toLowerCase().replace(/\s+/g, "_"));
|
|
882
|
+
this.commands.set(s.command.toLowerCase(), s), s.id && (s.id, s.command);
|
|
883
883
|
}
|
|
884
884
|
/** Remove an existing command */
|
|
885
885
|
removeCommand(e) {
|
|
@@ -905,28 +905,28 @@ class Mt {
|
|
|
905
905
|
return this.context = null, { message: "Session expired or invalid context.", type: "error" };
|
|
906
906
|
if (Array.isArray(e))
|
|
907
907
|
return { message: "Invalid form payload.", type: "error" };
|
|
908
|
-
const
|
|
908
|
+
const a = {
|
|
909
909
|
...this.context.params,
|
|
910
910
|
...e
|
|
911
911
|
};
|
|
912
912
|
if (o.critical)
|
|
913
913
|
return this.context = null, this.pendingConfirmation = {
|
|
914
914
|
commandId: this.getCommandIdentifier(o),
|
|
915
|
-
params:
|
|
915
|
+
params: a
|
|
916
916
|
}, this.buildConfirmResponse(o);
|
|
917
|
-
const
|
|
918
|
-
return this.context = null, this.normalizeResponse(
|
|
917
|
+
const r = await this.safeRunAction(o, a);
|
|
918
|
+
return this.context = null, this.normalizeResponse(r);
|
|
919
919
|
}
|
|
920
|
-
const
|
|
920
|
+
const t = e.trim().toLowerCase();
|
|
921
921
|
if (this.pendingConfirmation) {
|
|
922
|
-
const o =
|
|
922
|
+
const o = t;
|
|
923
923
|
if (["yes", "y", "confirm", "ok", "okay"].includes(o)) {
|
|
924
|
-
const { commandId:
|
|
924
|
+
const { commandId: a, params: r } = this.pendingConfirmation;
|
|
925
925
|
this.pendingConfirmation = null;
|
|
926
|
-
const c = this.getCommandById(
|
|
927
|
-
return c ? this.safeRunAction(c,
|
|
926
|
+
const c = this.getCommandById(a);
|
|
927
|
+
return c ? this.safeRunAction(c, r) : { message: "That action is no longer available.", type: "error" };
|
|
928
928
|
}
|
|
929
|
-
return ["no", "n", "cancel", "stop"].includes(o) ? (this.pendingConfirmation = null, { message: "
|
|
929
|
+
return ["no", "n", "cancel", "stop"].includes(o) ? (this.pendingConfirmation = null, { message: "Cancelled.", type: "success" }) : {
|
|
930
930
|
message: "Please confirm: Yes or No.",
|
|
931
931
|
type: "confirm",
|
|
932
932
|
options: [
|
|
@@ -935,137 +935,142 @@ class Mt {
|
|
|
935
935
|
]
|
|
936
936
|
};
|
|
937
937
|
}
|
|
938
|
-
const
|
|
939
|
-
if (
|
|
940
|
-
const o =
|
|
941
|
-
|
|
938
|
+
const s = this.commands.get(t);
|
|
939
|
+
if (s) {
|
|
940
|
+
const o = s;
|
|
941
|
+
if (o.macro)
|
|
942
|
+
return this.safeRunAction(o, {});
|
|
943
|
+
const a = (o.parameters ?? []).filter((r) => r.required);
|
|
944
|
+
return a.length > 0 ? (this.context = { commandId: this.getCommandIdentifier(o), params: {} }, {
|
|
942
945
|
message: `Please provide the required details for "${o.command}".`,
|
|
943
946
|
type: "form",
|
|
944
|
-
fields:
|
|
947
|
+
fields: a
|
|
945
948
|
}) : o.critical ? (this.pendingConfirmation = { commandId: this.getCommandIdentifier(o), params: {} }, this.buildConfirmResponse(o)) : this.safeRunAction(o, {});
|
|
946
949
|
}
|
|
947
|
-
const
|
|
948
|
-
if (
|
|
950
|
+
const n = await this.tryDeterministicMatch(t);
|
|
951
|
+
if (n) return n;
|
|
949
952
|
if (this.enableSmartIntent && this.openAIService) {
|
|
950
|
-
const o = await this.getCommandsForAI(),
|
|
951
|
-
|
|
953
|
+
const o = await this.getCommandsForAI(), a = await this.openAIService.determineIntent(
|
|
954
|
+
t,
|
|
952
955
|
o,
|
|
953
956
|
this.context
|
|
954
957
|
);
|
|
955
|
-
return this.handleAIResult(
|
|
958
|
+
return this.handleAIResult(a);
|
|
956
959
|
}
|
|
957
960
|
return this.enableSmartIntent ? this.listAllCommands() : { message: "I'm not sure what you mean.", type: "error" };
|
|
958
961
|
}
|
|
959
962
|
async handleAIResult(e) {
|
|
960
963
|
if (e.type === "match" && e.match) {
|
|
961
|
-
const
|
|
962
|
-
if (!
|
|
964
|
+
const t = this.getCommandById(e.match);
|
|
965
|
+
if (!t)
|
|
963
966
|
return { message: "I'm not sure what you mean.", type: "error" };
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
967
|
+
if (t.macro)
|
|
968
|
+
return this.safeRunAction(t, {});
|
|
969
|
+
const s = e.params ?? {}, n = this.sanitizeParamsForCommand(t, s), o = t.allowAiParamExtraction === !1 ? {} : n, r = (t.parameters ?? []).filter((h) => h.required).filter((h) => o[h.name] == null || o[h.name] === "");
|
|
970
|
+
if (e.incomplete || r.length > 0) {
|
|
971
|
+
if (this.context = { commandId: this.getCommandIdentifier(t), params: o }, !(t.collectRequiredViaForm !== !1) && this.shouldAskSingleQuestion(r)) {
|
|
972
|
+
const l = r.map((f) => f.name).join(" and ");
|
|
968
973
|
return {
|
|
969
974
|
message: e.message || `Please provide ${l}.`,
|
|
970
975
|
type: "question"
|
|
971
976
|
};
|
|
972
977
|
}
|
|
973
978
|
return {
|
|
974
|
-
message: e.message || `Please fill in the missing details for "${
|
|
979
|
+
message: e.message || `Please fill in the missing details for "${t.command}".`,
|
|
975
980
|
type: "form",
|
|
976
|
-
fields:
|
|
981
|
+
fields: r
|
|
977
982
|
};
|
|
978
983
|
}
|
|
979
|
-
if (
|
|
984
|
+
if (t.critical)
|
|
980
985
|
return this.pendingConfirmation = {
|
|
981
|
-
commandId: this.getCommandIdentifier(
|
|
986
|
+
commandId: this.getCommandIdentifier(t),
|
|
982
987
|
params: o
|
|
983
|
-
}, this.buildConfirmResponse(
|
|
984
|
-
const c = await
|
|
988
|
+
}, this.buildConfirmResponse(t);
|
|
989
|
+
const c = await t.action(o);
|
|
985
990
|
return this.normalizeResponse(c);
|
|
986
991
|
}
|
|
987
992
|
return e.type === "ambiguous" && e.options && e.options.length ? {
|
|
988
993
|
message: e.message || "Did you mean one of these?",
|
|
989
994
|
type: "ambiguous",
|
|
990
|
-
options: e.options.map((
|
|
991
|
-
label:
|
|
992
|
-
value:
|
|
993
|
-
commandId:
|
|
995
|
+
options: e.options.map((t) => ({
|
|
996
|
+
label: t.label,
|
|
997
|
+
value: t.commandId ?? t.label,
|
|
998
|
+
commandId: t.commandId
|
|
994
999
|
}))
|
|
995
1000
|
} : this.listAllCommands();
|
|
996
1001
|
}
|
|
997
|
-
sanitizeParamsForCommand(e,
|
|
998
|
-
const
|
|
999
|
-
for (const
|
|
1000
|
-
const o =
|
|
1001
|
-
if (
|
|
1002
|
+
sanitizeParamsForCommand(e, t) {
|
|
1003
|
+
const s = { ...t ?? {} };
|
|
1004
|
+
for (const n of e.parameters ?? []) {
|
|
1005
|
+
const o = s[n.name];
|
|
1006
|
+
if (n.type === "string") {
|
|
1002
1007
|
if (typeof o != "string") {
|
|
1003
|
-
delete
|
|
1008
|
+
delete s[n.name];
|
|
1004
1009
|
continue;
|
|
1005
1010
|
}
|
|
1006
|
-
const
|
|
1007
|
-
if (!
|
|
1008
|
-
delete
|
|
1011
|
+
const a = o.trim();
|
|
1012
|
+
if (!a) {
|
|
1013
|
+
delete s[n.name];
|
|
1009
1014
|
continue;
|
|
1010
1015
|
}
|
|
1011
|
-
|
|
1016
|
+
s[n.name] = a;
|
|
1012
1017
|
}
|
|
1013
|
-
if (
|
|
1014
|
-
const
|
|
1015
|
-
if (Number.isNaN(
|
|
1016
|
-
delete
|
|
1018
|
+
if (n.type === "number") {
|
|
1019
|
+
const a = typeof o == "number" ? o : Number(o == null ? void 0 : o.toString().trim());
|
|
1020
|
+
if (Number.isNaN(a)) {
|
|
1021
|
+
delete s[n.name];
|
|
1017
1022
|
continue;
|
|
1018
1023
|
}
|
|
1019
|
-
if (typeof
|
|
1020
|
-
delete
|
|
1024
|
+
if (typeof n.min == "number" && a < n.min) {
|
|
1025
|
+
delete s[n.name];
|
|
1021
1026
|
continue;
|
|
1022
1027
|
}
|
|
1023
|
-
if (typeof
|
|
1024
|
-
delete
|
|
1028
|
+
if (typeof n.max == "number" && a > n.max) {
|
|
1029
|
+
delete s[n.name];
|
|
1025
1030
|
continue;
|
|
1026
1031
|
}
|
|
1027
|
-
|
|
1032
|
+
s[n.name] = a;
|
|
1028
1033
|
}
|
|
1029
|
-
if (
|
|
1030
|
-
const
|
|
1031
|
-
if (typeof
|
|
1032
|
-
const
|
|
1033
|
-
this.isIsoDateString(
|
|
1034
|
+
if (n.type === "date") {
|
|
1035
|
+
const a = s[n.name];
|
|
1036
|
+
if (typeof a == "string") {
|
|
1037
|
+
const r = a.trim();
|
|
1038
|
+
this.isIsoDateString(r) ? s[n.name] = r : delete s[n.name];
|
|
1034
1039
|
} else
|
|
1035
|
-
delete
|
|
1040
|
+
delete s[n.name];
|
|
1036
1041
|
}
|
|
1037
|
-
if (
|
|
1038
|
-
const
|
|
1039
|
-
if (!
|
|
1040
|
-
delete
|
|
1042
|
+
if (n.type === "select") {
|
|
1043
|
+
const a = typeof o == "string" ? o : o == null ? void 0 : o.toString();
|
|
1044
|
+
if (!a) {
|
|
1045
|
+
delete s[n.name];
|
|
1041
1046
|
continue;
|
|
1042
1047
|
}
|
|
1043
|
-
if (Array.isArray(
|
|
1044
|
-
delete
|
|
1048
|
+
if (Array.isArray(n.options) && n.options.length > 0 && !n.options.some((c) => String(c.value) === String(a))) {
|
|
1049
|
+
delete s[n.name];
|
|
1045
1050
|
continue;
|
|
1046
1051
|
}
|
|
1047
|
-
|
|
1052
|
+
s[n.name] = a;
|
|
1048
1053
|
}
|
|
1049
|
-
if (
|
|
1050
|
-
const
|
|
1051
|
-
(
|
|
1054
|
+
if (n.type === "file") {
|
|
1055
|
+
const a = s[n.name], r = a && typeof a == "object" && typeof a.name == "string" && typeof a.size == "number", c = typeof a == "string" && /^data:[^;]+;base64,/.test(a);
|
|
1056
|
+
(n.delivery ?? "file") === "base64" ? !c && !r && delete s[n.name] : r || delete s[n.name];
|
|
1052
1057
|
}
|
|
1053
1058
|
}
|
|
1054
|
-
return
|
|
1059
|
+
return s;
|
|
1055
1060
|
}
|
|
1056
1061
|
isIsoDateString(e) {
|
|
1057
1062
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(e)) return !1;
|
|
1058
|
-
const
|
|
1059
|
-
return !Number.isNaN(
|
|
1063
|
+
const t = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
|
|
1064
|
+
return !Number.isNaN(t.getTime());
|
|
1060
1065
|
}
|
|
1061
1066
|
shouldAskSingleQuestion(e) {
|
|
1062
1067
|
if (e.length !== 1) return !1;
|
|
1063
|
-
const
|
|
1064
|
-
return
|
|
1068
|
+
const t = e[0].type;
|
|
1069
|
+
return t === "string" || t === "number" || t === "date";
|
|
1065
1070
|
}
|
|
1066
1071
|
buildConfirmResponse(e) {
|
|
1067
1072
|
return {
|
|
1068
|
-
message:
|
|
1073
|
+
message: `Are you sure you want to run "${e.command}"?`,
|
|
1069
1074
|
type: "confirm",
|
|
1070
1075
|
options: [
|
|
1071
1076
|
{ label: "Yes", value: "yes" },
|
|
@@ -1074,64 +1079,64 @@ class Mt {
|
|
|
1074
1079
|
};
|
|
1075
1080
|
}
|
|
1076
1081
|
async tryDeterministicMatch(e) {
|
|
1077
|
-
const
|
|
1078
|
-
for (const
|
|
1082
|
+
const t = [];
|
|
1083
|
+
for (const r of this.commands.values()) {
|
|
1079
1084
|
let c = 0;
|
|
1080
|
-
const h =
|
|
1085
|
+
const h = r.command.toLowerCase();
|
|
1081
1086
|
e.includes(h) && (c += 5);
|
|
1082
|
-
const d =
|
|
1087
|
+
const d = r.keywords ?? [];
|
|
1083
1088
|
for (const l of d) {
|
|
1084
1089
|
const f = l.toLowerCase().trim();
|
|
1085
1090
|
f && (e === f ? c += 4 : e.includes(f) && (c += 3));
|
|
1086
1091
|
}
|
|
1087
|
-
c > 0 &&
|
|
1092
|
+
c > 0 && t.push({ cmd: r, score: c });
|
|
1088
1093
|
}
|
|
1089
|
-
if (
|
|
1090
|
-
|
|
1091
|
-
const
|
|
1092
|
-
if (
|
|
1094
|
+
if (t.length === 0) return null;
|
|
1095
|
+
t.sort((r, c) => c.score - r.score);
|
|
1096
|
+
const s = t[0].score, n = t.filter((r) => r.score === s).slice(0, 3);
|
|
1097
|
+
if (n.length > 1)
|
|
1093
1098
|
return {
|
|
1094
1099
|
message: "I think you mean one of these. Which one should I run?",
|
|
1095
1100
|
type: "ambiguous",
|
|
1096
|
-
options:
|
|
1097
|
-
label:
|
|
1098
|
-
value:
|
|
1099
|
-
commandId:
|
|
1101
|
+
options: n.map((r) => ({
|
|
1102
|
+
label: r.cmd.command,
|
|
1103
|
+
value: r.cmd.command,
|
|
1104
|
+
commandId: r.cmd.id
|
|
1100
1105
|
}))
|
|
1101
1106
|
};
|
|
1102
|
-
const o =
|
|
1103
|
-
return
|
|
1107
|
+
const o = n[0].cmd, a = (o.parameters ?? []).filter((r) => r.required);
|
|
1108
|
+
return a.length > 0 ? (this.context = { commandId: this.getCommandIdentifier(o), params: {} }, {
|
|
1104
1109
|
message: `Please provide the required details for "${o.command}".`,
|
|
1105
1110
|
type: "form",
|
|
1106
|
-
fields:
|
|
1111
|
+
fields: a
|
|
1107
1112
|
}) : o.critical ? (this.pendingConfirmation = { commandId: this.getCommandIdentifier(o), params: {} }, this.buildConfirmResponse(o)) : this.safeRunAction(o, {});
|
|
1108
1113
|
}
|
|
1109
|
-
async safeRunAction(e,
|
|
1114
|
+
async safeRunAction(e, t) {
|
|
1110
1115
|
try {
|
|
1111
|
-
const
|
|
1112
|
-
return this.normalizeResponse(
|
|
1116
|
+
const s = await e.action(t ?? {});
|
|
1117
|
+
return this.normalizeResponse(s);
|
|
1113
1118
|
} catch {
|
|
1114
1119
|
return { message: "Something went wrong while running that command.", type: "error" };
|
|
1115
1120
|
}
|
|
1116
1121
|
}
|
|
1117
1122
|
async getCommandsForAI() {
|
|
1118
|
-
const e = Array.from(this.commands.values()).map((
|
|
1119
|
-
...
|
|
1120
|
-
parameters:
|
|
1123
|
+
const e = Array.from(this.commands.values()).map((t) => ({
|
|
1124
|
+
...t,
|
|
1125
|
+
parameters: t.parameters ? t.parameters.map((s) => ({ ...s })) : void 0
|
|
1121
1126
|
}));
|
|
1122
1127
|
return await Promise.all(
|
|
1123
|
-
e.map(async (
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
if (
|
|
1127
|
-
const
|
|
1128
|
-
if (o &&
|
|
1129
|
-
|
|
1128
|
+
e.map(async (t) => {
|
|
1129
|
+
t.parameters && await Promise.all(
|
|
1130
|
+
t.parameters.map(async (s) => {
|
|
1131
|
+
if (s.type !== "select" || !s.getOptions || s.options && s.options.length) return;
|
|
1132
|
+
const n = `${t.id ?? t.command}:${s.name}`, o = this.selectOptionsCache.get(n), a = Date.now();
|
|
1133
|
+
if (o && a - o.ts < 6e4) {
|
|
1134
|
+
s.options = o.options;
|
|
1130
1135
|
return;
|
|
1131
1136
|
}
|
|
1132
1137
|
try {
|
|
1133
|
-
const
|
|
1134
|
-
this.selectOptionsCache.set(
|
|
1138
|
+
const r = await s.getOptions();
|
|
1139
|
+
this.selectOptionsCache.set(n, { options: r, ts: a }), s.options = r;
|
|
1135
1140
|
} catch {
|
|
1136
1141
|
}
|
|
1137
1142
|
})
|
|
@@ -1140,17 +1145,17 @@ class Mt {
|
|
|
1140
1145
|
), e;
|
|
1141
1146
|
}
|
|
1142
1147
|
getCommandById(e) {
|
|
1143
|
-
for (const
|
|
1144
|
-
if (
|
|
1148
|
+
for (const t of this.commands.values())
|
|
1149
|
+
if (t.id === e) return t;
|
|
1145
1150
|
}
|
|
1146
1151
|
listAllCommands() {
|
|
1147
1152
|
return {
|
|
1148
1153
|
message: "Here are the available commands:",
|
|
1149
1154
|
type: "ambiguous",
|
|
1150
|
-
options: Array.from(this.commands.values()).map((
|
|
1151
|
-
label:
|
|
1152
|
-
value:
|
|
1153
|
-
commandId:
|
|
1155
|
+
options: Array.from(this.commands.values()).map((t) => ({
|
|
1156
|
+
label: t.command,
|
|
1157
|
+
value: t.id ?? t.command,
|
|
1158
|
+
commandId: t.id ?? t.command
|
|
1154
1159
|
}))
|
|
1155
1160
|
};
|
|
1156
1161
|
}
|
|
@@ -1168,29 +1173,29 @@ class Mt {
|
|
|
1168
1173
|
return Array.from(this.commands.keys());
|
|
1169
1174
|
}
|
|
1170
1175
|
}
|
|
1171
|
-
class
|
|
1176
|
+
class qe {
|
|
1172
1177
|
constructor() {
|
|
1173
|
-
this.synth = window.speechSynthesis;
|
|
1178
|
+
this.synth = typeof window < "u" ? window.speechSynthesis : null;
|
|
1174
1179
|
}
|
|
1175
|
-
speak(e,
|
|
1180
|
+
speak(e, t) {
|
|
1176
1181
|
if (!this.synth) {
|
|
1177
|
-
console.error("SpeechSynthesis API is not supported in this
|
|
1182
|
+
console.error("SpeechSynthesis API is not supported in this environment.");
|
|
1178
1183
|
return;
|
|
1179
1184
|
}
|
|
1180
|
-
const
|
|
1181
|
-
|
|
1185
|
+
const s = new SpeechSynthesisUtterance(e);
|
|
1186
|
+
t && (s.pitch = t.pitch || 1, s.rate = t.rate || 1, s.volume = t.volume || 1), typeof window < "u" && (s.onstart = () => {
|
|
1182
1187
|
window.dispatchEvent(new CustomEvent("foisit:tts-start"));
|
|
1183
|
-
},
|
|
1188
|
+
}, s.onend = () => {
|
|
1184
1189
|
console.log("Speech finished."), window.dispatchEvent(new CustomEvent("foisit:tts-end"));
|
|
1185
|
-
},
|
|
1186
|
-
console.error("Error during speech synthesis:",
|
|
1187
|
-
}, this.synth.speak(
|
|
1190
|
+
}), s.onerror = (n) => {
|
|
1191
|
+
console.error("Error during speech synthesis:", n.error);
|
|
1192
|
+
}, this.synth.speak(s);
|
|
1188
1193
|
}
|
|
1189
1194
|
stopSpeaking() {
|
|
1190
1195
|
this.synth && this.synth.cancel();
|
|
1191
1196
|
}
|
|
1192
1197
|
}
|
|
1193
|
-
class
|
|
1198
|
+
class Ft {
|
|
1194
1199
|
constructor() {
|
|
1195
1200
|
this.fallbackMessage = "Sorry, I didn’t understand that.";
|
|
1196
1201
|
}
|
|
@@ -1198,48 +1203,49 @@ class Pt {
|
|
|
1198
1203
|
this.fallbackMessage = e;
|
|
1199
1204
|
}
|
|
1200
1205
|
handleFallback(e) {
|
|
1201
|
-
e && console.log(`Fallback triggered for: "${e}"`), console.log(this.fallbackMessage), new
|
|
1206
|
+
e && console.log(`Fallback triggered for: "${e}"`), console.log(this.fallbackMessage), new qe().speak(this.fallbackMessage);
|
|
1202
1207
|
}
|
|
1203
1208
|
getFallbackMessage() {
|
|
1204
1209
|
return this.fallbackMessage;
|
|
1205
1210
|
}
|
|
1206
1211
|
}
|
|
1207
|
-
const
|
|
1208
|
-
|
|
1209
|
-
|
|
1212
|
+
const ve = () => {
|
|
1213
|
+
if (typeof window > "u") return null;
|
|
1214
|
+
const i = window;
|
|
1215
|
+
return i.SpeechRecognition ?? i.webkitSpeechRecognition ?? null;
|
|
1210
1216
|
};
|
|
1211
|
-
class
|
|
1212
|
-
constructor(e = "en-US",
|
|
1217
|
+
class Ht {
|
|
1218
|
+
constructor(e = "en-US", t = {}) {
|
|
1213
1219
|
this.recognition = null, this.isListening = !1, this.engineActive = !1, this.intentionallyStopped = !1, this.restartAllowed = !0, this.lastStart = 0, this.backoffMs = 250, this.destroyed = !1, this.resultCallback = null, this.ttsSpeaking = !1, this.debugEnabled = !0, this.restartTimer = null, this.prewarmed = !1, this.hadResultThisSession = !1, this.onTTSStart = () => {
|
|
1214
|
-
var
|
|
1220
|
+
var n;
|
|
1215
1221
|
this.ttsSpeaking = !0;
|
|
1216
1222
|
try {
|
|
1217
|
-
(
|
|
1223
|
+
(n = this.recognition) == null || n.stop();
|
|
1218
1224
|
} catch {
|
|
1219
1225
|
}
|
|
1220
1226
|
this.isListening && this.emitStatus("speaking");
|
|
1221
1227
|
}, this.onTTSEnd = () => {
|
|
1222
1228
|
this.ttsSpeaking = !1, this.isListening && this.restartAllowed ? this.safeRestart() : this.emitStatus(this.isListening ? "listening" : "idle");
|
|
1223
1229
|
};
|
|
1224
|
-
const
|
|
1225
|
-
if (
|
|
1226
|
-
this.recognition = new
|
|
1230
|
+
const s = ve();
|
|
1231
|
+
if (s) {
|
|
1232
|
+
this.recognition = new s(), this.recognition.lang = e, this.recognition.interimResults = t.interimResults ?? !0, this.recognition.continuous = t.continuous ?? !0, this.recognition.onresult = (o) => this.handleResult(o, t), this.recognition.onend = () => this.handleEnd(), this.recognition.onstart = () => {
|
|
1227
1233
|
this.log("recognition onstart"), this.engineActive = !0, this.hadResultThisSession = !1, this.restartTimer && (clearTimeout(this.restartTimer), this.restartTimer = null), this.backoffMs = 250, this.isListening && !this.ttsSpeaking && this.emitStatus("listening");
|
|
1228
1234
|
};
|
|
1229
|
-
const
|
|
1230
|
-
|
|
1235
|
+
const n = this.recognition;
|
|
1236
|
+
n.onaudiostart = () => this.log("onaudiostart"), n.onsoundstart = () => this.log("onsoundstart"), n.onspeechstart = () => this.log("onspeechstart"), n.onspeechend = () => this.log("onspeechend"), n.onsoundend = () => this.log("onsoundend"), n.onaudioend = () => this.log("onaudioend"), this.recognition.onerror = (o) => this.handleError(o);
|
|
1231
1237
|
} else
|
|
1232
1238
|
this.recognition = null, this.emitStatus("unsupported");
|
|
1233
|
-
window.addEventListener("foisit:tts-start", this.onTTSStart), window.addEventListener("foisit:tts-end", this.onTTSEnd), this.visibilityHandler = () => {
|
|
1234
|
-
var
|
|
1235
|
-
if (document.hidden) {
|
|
1239
|
+
typeof window < "u" ? (window.addEventListener("foisit:tts-start", this.onTTSStart), window.addEventListener("foisit:tts-end", this.onTTSEnd), this.visibilityHandler = () => {
|
|
1240
|
+
var n;
|
|
1241
|
+
if (typeof document < "u" && document.hidden) {
|
|
1236
1242
|
try {
|
|
1237
|
-
(
|
|
1243
|
+
(n = this.recognition) == null || n.stop();
|
|
1238
1244
|
} catch {
|
|
1239
1245
|
}
|
|
1240
1246
|
this.emitStatus(this.ttsSpeaking ? "speaking" : "idle");
|
|
1241
1247
|
} else this.isListening && !this.ttsSpeaking && this.safeRestart();
|
|
1242
|
-
}, document.addEventListener("visibilitychange", this.visibilityHandler);
|
|
1248
|
+
}, typeof document < "u" && document.addEventListener("visibilitychange", this.visibilityHandler)) : this.visibilityHandler = void 0;
|
|
1243
1249
|
}
|
|
1244
1250
|
// Debug logger helpers
|
|
1245
1251
|
log(e) {
|
|
@@ -1253,7 +1259,7 @@ class Vt {
|
|
|
1253
1259
|
}
|
|
1254
1260
|
/** Check if SpeechRecognition is available */
|
|
1255
1261
|
isSupported() {
|
|
1256
|
-
return
|
|
1262
|
+
return ve() !== null;
|
|
1257
1263
|
}
|
|
1258
1264
|
/** Allow consumers (wrappers) to observe status changes */
|
|
1259
1265
|
onStatusChange(e) {
|
|
@@ -1287,15 +1293,15 @@ class Vt {
|
|
|
1287
1293
|
this.destroyed = !0, this.stopListening(), this.resultCallback = null, window.removeEventListener("foisit:tts-start", this.onTTSStart), window.removeEventListener("foisit:tts-end", this.onTTSEnd), this.visibilityHandler && (document.removeEventListener("visibilitychange", this.visibilityHandler), this.visibilityHandler = void 0);
|
|
1288
1294
|
}
|
|
1289
1295
|
/** Handle recognized speech results */
|
|
1290
|
-
handleResult(e,
|
|
1291
|
-
var
|
|
1296
|
+
handleResult(e, t) {
|
|
1297
|
+
var n, o;
|
|
1292
1298
|
if (!this.resultCallback) return;
|
|
1293
|
-
const
|
|
1294
|
-
for (let
|
|
1295
|
-
const
|
|
1296
|
-
if (h && !(!
|
|
1299
|
+
const s = t.confidenceThreshold ?? 0.6;
|
|
1300
|
+
for (let a = e.resultIndex; a < e.results.length; a++) {
|
|
1301
|
+
const r = e.results[a], c = r && r[0], h = ((o = (n = c == null ? void 0 : c.transcript) == null ? void 0 : n.trim) == null ? void 0 : o.call(n)) || "", d = (c == null ? void 0 : c.confidence) ?? 0;
|
|
1302
|
+
if (h && !(!r.isFinal && t.interimResults === !1) && !(r.isFinal && d < s))
|
|
1297
1303
|
try {
|
|
1298
|
-
this.hadResultThisSession = !0, this.resultCallback(h, !!
|
|
1304
|
+
this.hadResultThisSession = !0, this.resultCallback(h, !!r.isFinal);
|
|
1299
1305
|
} catch {
|
|
1300
1306
|
this.error("VoiceProcessor: result callback error");
|
|
1301
1307
|
}
|
|
@@ -1311,9 +1317,9 @@ class Vt {
|
|
|
1311
1317
|
}
|
|
1312
1318
|
/** Handle errors during speech recognition */
|
|
1313
1319
|
handleError(e) {
|
|
1314
|
-
const
|
|
1315
|
-
if (this.warn(`Error occurred: ${
|
|
1316
|
-
this.intentionallyStopped = !0, this.restartAllowed = !1, this.isListening = !1, this.emitStatus("error", { error:
|
|
1320
|
+
const t = e == null ? void 0 : e.error;
|
|
1321
|
+
if (this.warn(`Error occurred: ${t ?? "unknown"}`), t && ["not-allowed", "service-not-allowed", "bad-grammar", "language-not-supported"].includes(t)) {
|
|
1322
|
+
this.intentionallyStopped = !0, this.restartAllowed = !1, this.isListening = !1, this.emitStatus("error", { error: t });
|
|
1317
1323
|
return;
|
|
1318
1324
|
}
|
|
1319
1325
|
this.scheduleRestart();
|
|
@@ -1358,43 +1364,45 @@ class Vt {
|
|
|
1358
1364
|
const e = navigator.mediaDevices;
|
|
1359
1365
|
if (!(e != null && e.getUserMedia)) return;
|
|
1360
1366
|
this.log("prewarmAudio: requesting mic");
|
|
1361
|
-
const
|
|
1362
|
-
for (const
|
|
1367
|
+
const t = await e.getUserMedia({ audio: !0 });
|
|
1368
|
+
for (const s of t.getTracks()) s.stop();
|
|
1363
1369
|
this.prewarmed = !0, this.log("prewarmAudio: mic ready");
|
|
1364
1370
|
} catch {
|
|
1365
1371
|
this.warn("prewarmAudio: failed to get mic");
|
|
1366
1372
|
}
|
|
1367
1373
|
}
|
|
1368
|
-
emitStatus(e,
|
|
1374
|
+
emitStatus(e, t) {
|
|
1369
1375
|
if (this.statusCallback)
|
|
1370
1376
|
try {
|
|
1371
|
-
this.statusCallback(e,
|
|
1377
|
+
this.statusCallback(e, t);
|
|
1372
1378
|
} catch {
|
|
1373
1379
|
this.error("VoiceProcessor: status callback error");
|
|
1374
1380
|
}
|
|
1375
1381
|
}
|
|
1376
1382
|
}
|
|
1377
|
-
class
|
|
1383
|
+
class ae {
|
|
1378
1384
|
constructor() {
|
|
1379
|
-
this.lastTap = 0;
|
|
1385
|
+
this.lastTap = 0, this.tapCount = 0;
|
|
1380
1386
|
}
|
|
1381
1387
|
/**
|
|
1382
|
-
* Sets up
|
|
1383
|
-
* @param
|
|
1388
|
+
* Sets up triple-click and triple-tap listeners
|
|
1389
|
+
* @param onTripleClickOrTap Callback to execute when a triple-click or triple-tap is detected
|
|
1384
1390
|
*/
|
|
1385
|
-
|
|
1386
|
-
this.destroy(), this.
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
+
setupTripleTapListener(e) {
|
|
1392
|
+
this.destroy(), this.clickListener = () => {
|
|
1393
|
+
this.tapCount++, this.tapCount === 1 ? this.tapTimeout = window.setTimeout(() => {
|
|
1394
|
+
this.tapCount = 0;
|
|
1395
|
+
}, 500) : this.tapCount === 3 && (clearTimeout(this.tapTimeout), this.tapCount = 0, e());
|
|
1396
|
+
}, document.addEventListener("click", this.clickListener), this.touchEndListener = () => {
|
|
1397
|
+
const t = (/* @__PURE__ */ new Date()).getTime(), s = t - this.lastTap;
|
|
1398
|
+
s < 500 && s > 0 ? (this.tapCount++, this.tapCount === 3 && (this.tapCount = 0, e())) : this.tapCount = 1, this.lastTap = t;
|
|
1391
1399
|
}, document.addEventListener("touchend", this.touchEndListener);
|
|
1392
1400
|
}
|
|
1393
1401
|
destroy() {
|
|
1394
|
-
this.dblClickListener && document.removeEventListener("dblclick", this.dblClickListener), this.touchEndListener && document.removeEventListener("touchend", this.touchEndListener), this.dblClickListener = void 0, this.touchEndListener = void 0;
|
|
1402
|
+
this.dblClickListener && document.removeEventListener("dblclick", this.dblClickListener), this.touchEndListener && document.removeEventListener("touchend", this.touchEndListener), this.clickListener && document.removeEventListener("click", this.clickListener), this.tapTimeout && clearTimeout(this.tapTimeout), this.dblClickListener = void 0, this.touchEndListener = void 0, this.clickListener = void 0, this.tapTimeout = void 0, this.tapCount = 0;
|
|
1395
1403
|
}
|
|
1396
1404
|
}
|
|
1397
|
-
function
|
|
1405
|
+
function Pt() {
|
|
1398
1406
|
if (document.querySelector("#assistant-styles")) {
|
|
1399
1407
|
console.log("Styles already injected");
|
|
1400
1408
|
return;
|
|
@@ -1435,17 +1443,20 @@ function Dt() {
|
|
|
1435
1443
|
}
|
|
1436
1444
|
`, document.head.appendChild(e), console.log("Gradient styles injected");
|
|
1437
1445
|
}
|
|
1438
|
-
function
|
|
1446
|
+
function Vt() {
|
|
1439
1447
|
if (document.querySelector("#gradient-indicator"))
|
|
1440
1448
|
return;
|
|
1441
|
-
const
|
|
1442
|
-
|
|
1449
|
+
const i = document.createElement("div");
|
|
1450
|
+
i.id = "gradient-indicator", Pt(), i.classList.add("gradient-indicator"), document.body.appendChild(i), console.log("Gradient indicator added to the DOM");
|
|
1451
|
+
}
|
|
1452
|
+
function Dt() {
|
|
1453
|
+
const i = document.querySelector("#gradient-indicator");
|
|
1454
|
+
i && (i.remove(), console.log("Gradient indicator removed from the DOM"));
|
|
1443
1455
|
}
|
|
1444
|
-
function
|
|
1445
|
-
|
|
1446
|
-
t && (t.remove(), console.log("Gradient indicator removed from the DOM"));
|
|
1456
|
+
function qt() {
|
|
1457
|
+
return typeof window < "u" && typeof document < "u";
|
|
1447
1458
|
}
|
|
1448
|
-
class
|
|
1459
|
+
class zt {
|
|
1449
1460
|
constructor() {
|
|
1450
1461
|
this.state = "idle", this.subscribers = [];
|
|
1451
1462
|
}
|
|
@@ -1453,7 +1464,7 @@ class qt {
|
|
|
1453
1464
|
return this.state;
|
|
1454
1465
|
}
|
|
1455
1466
|
setState(e) {
|
|
1456
|
-
this.state = e, this.notifySubscribers(), console.log("State updated:", e), e === "listening" ?
|
|
1467
|
+
this.state = e, this.notifySubscribers(), console.log("State updated:", e), e === "listening" ? Vt() : Dt();
|
|
1457
1468
|
}
|
|
1458
1469
|
// eslint-disable-next-line no-unused-vars
|
|
1459
1470
|
subscribe(e) {
|
|
@@ -1463,27 +1474,84 @@ class qt {
|
|
|
1463
1474
|
this.subscribers.forEach((e) => e(this.state));
|
|
1464
1475
|
}
|
|
1465
1476
|
}
|
|
1466
|
-
class
|
|
1477
|
+
class Bt {
|
|
1467
1478
|
constructor(e) {
|
|
1468
|
-
this.container = null, this.chatWindow = null, this.messagesContainer = null, this.input = null, this.isOpen = !1, this.loadingEl = null, this.
|
|
1479
|
+
this.container = null, this.chatWindow = null, this.messagesContainer = null, this.input = null, this.isOpen = !1, this.loadingEl = null, this.commandHandlers = /* @__PURE__ */ new Map(), this.active = qt(), this.handleClickOutside = (t) => {
|
|
1480
|
+
const s = t.target;
|
|
1481
|
+
this.chatWindow && this.chatWindow.contains(s) || s.closest(".foisit-floating-btn") || this.toggle();
|
|
1482
|
+
}, this.config = e, this.active && this.init();
|
|
1483
|
+
}
|
|
1484
|
+
/** Register a command handler that can be invoked programmatically via `runCommand` */
|
|
1485
|
+
registerCommandHandler(e, t) {
|
|
1486
|
+
!e || typeof t != "function" || this.commandHandlers.set(e, t);
|
|
1487
|
+
}
|
|
1488
|
+
/** Check whether a programmatic handler is registered locally */
|
|
1489
|
+
hasCommandHandler(e) {
|
|
1490
|
+
return this.commandHandlers.has(e);
|
|
1491
|
+
}
|
|
1492
|
+
/** Set an external executor (used to run commands registered via CommandHandler) */
|
|
1493
|
+
setExternalCommandExecutor(e) {
|
|
1494
|
+
this.externalCommandExecutor = e;
|
|
1495
|
+
}
|
|
1496
|
+
/** Unregister a previously registered command handler */
|
|
1497
|
+
unregisterCommandHandler(e) {
|
|
1498
|
+
e && this.commandHandlers.delete(e);
|
|
1499
|
+
}
|
|
1500
|
+
/**
|
|
1501
|
+
* Run a registered command by id. Options:
|
|
1502
|
+
* - `params`: passed to the handler
|
|
1503
|
+
* - `openOverlay`: if true, open the overlay before running
|
|
1504
|
+
* - `showInvocation`: if true, show the invocation as a user message
|
|
1505
|
+
*/
|
|
1506
|
+
async runCommand(e) {
|
|
1507
|
+
if (!e || !e.commandId) throw new Error("runCommand requires a commandId");
|
|
1508
|
+
const { commandId: t, params: s, openOverlay: n = !0, showInvocation: o = !0 } = e;
|
|
1509
|
+
n && !this.isOpen && this.toggle();
|
|
1510
|
+
const a = this.commandHandlers.get(t);
|
|
1511
|
+
if (a && o && this.messagesContainer && this.addMessage(`Command: ${t}`, "user"), a)
|
|
1512
|
+
try {
|
|
1513
|
+
this.showLoading();
|
|
1514
|
+
const r = await a(s);
|
|
1515
|
+
if (this.hideLoading(), typeof r == "string")
|
|
1516
|
+
this.addMessage(r, "system");
|
|
1517
|
+
else if (r && typeof r == "object")
|
|
1518
|
+
try {
|
|
1519
|
+
this.addMessage(JSON.stringify(r, null, 2), "system");
|
|
1520
|
+
} catch {
|
|
1521
|
+
this.addMessage(String(r), "system");
|
|
1522
|
+
}
|
|
1523
|
+
else r == null || this.addMessage(String(r), "system");
|
|
1524
|
+
return r;
|
|
1525
|
+
} catch (r) {
|
|
1526
|
+
throw this.hideLoading(), this.addMessage(`Command "${t}" failed: ${String(r)}`, "system"), r;
|
|
1527
|
+
}
|
|
1528
|
+
if (this.externalCommandExecutor)
|
|
1529
|
+
try {
|
|
1530
|
+
this.showLoading();
|
|
1531
|
+
const r = await this.externalCommandExecutor({ commandId: t, params: s });
|
|
1532
|
+
return this.hideLoading(), r;
|
|
1533
|
+
} catch (r) {
|
|
1534
|
+
throw this.hideLoading(), this.addMessage(`Command "${t}" failed: ${String(r)}`, "system"), r;
|
|
1535
|
+
}
|
|
1536
|
+
this.addMessage(`No handler registered for command "${t}".`, "system");
|
|
1469
1537
|
}
|
|
1470
1538
|
init() {
|
|
1471
|
-
var
|
|
1539
|
+
var t, s;
|
|
1472
1540
|
if (this.container) return;
|
|
1473
1541
|
this.injectOverlayStyles();
|
|
1474
1542
|
const e = document.getElementById("foisit-overlay-container");
|
|
1475
1543
|
if (e && e instanceof HTMLElement) {
|
|
1476
|
-
this.container = e, this.chatWindow = e.querySelector(".foisit-chat"), this.messagesContainer = e.querySelector(".foisit-messages"), this.input = e.querySelector("input.foisit-input"), ((
|
|
1544
|
+
this.container = e, this.chatWindow = e.querySelector(".foisit-chat"), this.messagesContainer = e.querySelector(".foisit-messages"), this.input = e.querySelector("input.foisit-input"), ((t = this.config.floatingButton) == null ? void 0 : t.visible) !== !1 && !e.querySelector(".foisit-floating-btn") && this.renderFloatingButton(), this.chatWindow || this.renderChatWindow(), this.config.enableGestureActivation && (this.gestureHandler = new ae(), this.gestureHandler.setupTripleTapListener(() => this.toggle()));
|
|
1477
1545
|
return;
|
|
1478
1546
|
}
|
|
1479
|
-
this.container = document.createElement("div"), this.container.id = "foisit-overlay-container", this.container.className = "foisit-overlay-container", document.body.appendChild(this.container), ((
|
|
1547
|
+
this.container = document.createElement("div"), this.container.id = "foisit-overlay-container", this.container.className = "foisit-overlay-container", document.body.appendChild(this.container), ((s = this.config.floatingButton) == null ? void 0 : s.visible) !== !1 && this.renderFloatingButton(), this.renderChatWindow(), this.config.enableGestureActivation && (this.gestureHandler = new ae(), this.gestureHandler.setupTripleTapListener(() => this.toggle()));
|
|
1480
1548
|
}
|
|
1481
1549
|
renderFloatingButton() {
|
|
1482
|
-
var
|
|
1550
|
+
var n, o, a, r, c, h;
|
|
1483
1551
|
const e = document.createElement("button");
|
|
1484
|
-
e.innerHTML = ((
|
|
1485
|
-
const
|
|
1486
|
-
e.className = "foisit-floating-btn", e.style.bottom =
|
|
1552
|
+
e.innerHTML = ((n = this.config.floatingButton) == null ? void 0 : n.customHtml) || "🎙️";
|
|
1553
|
+
const t = ((a = (o = this.config.floatingButton) == null ? void 0 : o.position) == null ? void 0 : a.bottom) || "20px", s = ((c = (r = this.config.floatingButton) == null ? void 0 : r.position) == null ? void 0 : c.right) || "20px";
|
|
1554
|
+
e.className = "foisit-floating-btn", e.style.bottom = t, e.style.right = s, e.onclick = () => this.toggle(), e.onmouseenter = () => e.style.transform = "scale(1.05)", e.onmouseleave = () => e.style.transform = "scale(1)", (h = this.container) == null || h.appendChild(e);
|
|
1487
1555
|
}
|
|
1488
1556
|
renderChatWindow() {
|
|
1489
1557
|
var o;
|
|
@@ -1491,73 +1559,81 @@ class zt {
|
|
|
1491
1559
|
this.chatWindow = document.createElement("div"), this.chatWindow.className = "foisit-chat";
|
|
1492
1560
|
const e = document.createElement("div");
|
|
1493
1561
|
e.className = "foisit-header";
|
|
1494
|
-
const
|
|
1495
|
-
|
|
1496
|
-
const
|
|
1497
|
-
|
|
1498
|
-
const
|
|
1499
|
-
|
|
1500
|
-
var
|
|
1501
|
-
if (
|
|
1562
|
+
const t = document.createElement("span");
|
|
1563
|
+
t.className = "foisit-title", t.textContent = "Foisit";
|
|
1564
|
+
const s = document.createElement("button");
|
|
1565
|
+
s.type = "button", s.className = "foisit-close", s.setAttribute("aria-label", "Close"), s.innerHTML = "×", s.addEventListener("click", () => this.toggle()), e.appendChild(t), e.appendChild(s), this.messagesContainer = document.createElement("div"), this.messagesContainer.className = "foisit-messages";
|
|
1566
|
+
const n = document.createElement("div");
|
|
1567
|
+
n.className = "foisit-input-area", this.input = document.createElement("input"), this.input.placeholder = this.config.inputPlaceholder || "Type a command...", this.input.className = "foisit-input", this.input.addEventListener("keydown", (a) => {
|
|
1568
|
+
var r;
|
|
1569
|
+
if (a.key === "Enter" && ((r = this.input) != null && r.value.trim())) {
|
|
1502
1570
|
const c = this.input.value.trim();
|
|
1503
1571
|
this.input.value = "", this.onSubmit && this.onSubmit(c);
|
|
1504
1572
|
}
|
|
1505
|
-
}),
|
|
1573
|
+
}), n.appendChild(this.input), this.chatWindow.appendChild(e), this.chatWindow.appendChild(this.messagesContainer), this.chatWindow.appendChild(n), (o = this.container) == null || o.appendChild(this.chatWindow);
|
|
1506
1574
|
}
|
|
1507
|
-
registerCallbacks(e,
|
|
1508
|
-
this.onSubmit = e, this.onClose =
|
|
1575
|
+
registerCallbacks(e, t) {
|
|
1576
|
+
this.active && (this.onSubmit = e, this.onClose = t);
|
|
1509
1577
|
}
|
|
1510
|
-
toggle(e,
|
|
1511
|
-
e && (this.onSubmit = e),
|
|
1578
|
+
toggle(e, t) {
|
|
1579
|
+
this.active && (e && (this.onSubmit = e), t && (this.onClose = t), this.isOpen = !this.isOpen, this.chatWindow && (this.isOpen ? (this.container && (this.container.style.pointerEvents = "auto"), this.chatWindow.style.display = "flex", requestAnimationFrame(() => {
|
|
1512
1580
|
this.chatWindow && (this.chatWindow.style.opacity = "1", this.chatWindow.style.transform = "translateY(0) scale(1)");
|
|
1513
1581
|
}), setTimeout(() => {
|
|
1514
|
-
var
|
|
1515
|
-
return (
|
|
1516
|
-
}, 100)) : (this.chatWindow.style.opacity = "0", this.chatWindow.style.transform = "translateY(20px) scale(0.95)", setTimeout(() => {
|
|
1582
|
+
var s;
|
|
1583
|
+
return (s = this.input) == null ? void 0 : s.focus();
|
|
1584
|
+
}, 100), this.addClickOutsideListener()) : (this.chatWindow.style.opacity = "0", this.chatWindow.style.transform = "translateY(20px) scale(0.95)", setTimeout(() => {
|
|
1517
1585
|
this.chatWindow && !this.isOpen && (this.chatWindow.style.display = "none");
|
|
1518
|
-
}, 200), this.onClose && this.onClose()));
|
|
1586
|
+
}, 200), this.onClose && this.onClose(), this.removeClickOutsideListener(), this.container && (this.container.style.pointerEvents = "none"))));
|
|
1519
1587
|
}
|
|
1520
|
-
|
|
1588
|
+
addClickOutsideListener() {
|
|
1589
|
+
this.container && (this.removeClickOutsideListener(), this.container.addEventListener("click", this.handleClickOutside));
|
|
1590
|
+
}
|
|
1591
|
+
removeClickOutsideListener() {
|
|
1592
|
+
this.container && this.container.removeEventListener("click", this.handleClickOutside);
|
|
1593
|
+
}
|
|
1594
|
+
addMessage(e, t) {
|
|
1521
1595
|
if (!this.messagesContainer) return;
|
|
1522
|
-
const
|
|
1523
|
-
|
|
1596
|
+
const s = document.createElement("div");
|
|
1597
|
+
t === "system" ? s.innerHTML = this.renderMarkdown(e) : s.textContent = e, s.className = t === "user" ? "foisit-bubble user" : "foisit-bubble system";
|
|
1598
|
+
const n = (e || "").length || 0, o = Math.max(120, 700 - Math.min(600, Math.floor(n * 6)));
|
|
1599
|
+
s.style.opacity = "0", s.style.transform = "translateY(8px)", s.style.transition = "none", this.messagesContainer.appendChild(s), this.animateMessageEntrance(s, o), this.scrollToBottom();
|
|
1524
1600
|
}
|
|
1525
1601
|
addOptions(e) {
|
|
1526
1602
|
if (!this.messagesContainer) return;
|
|
1527
|
-
const
|
|
1528
|
-
|
|
1529
|
-
const
|
|
1530
|
-
|
|
1603
|
+
const t = document.createElement("div");
|
|
1604
|
+
t.className = "foisit-options-container", e.forEach((s) => {
|
|
1605
|
+
const n = document.createElement("button");
|
|
1606
|
+
n.textContent = s.label, n.className = "foisit-option-chip", n.setAttribute("type", "button"), n.setAttribute("aria-label", s.label);
|
|
1531
1607
|
const o = () => {
|
|
1532
|
-
if (
|
|
1533
|
-
this.onSubmit && this.onSubmit({ commandId:
|
|
1608
|
+
if (s.commandId) {
|
|
1609
|
+
this.onSubmit && this.onSubmit({ commandId: s.commandId });
|
|
1534
1610
|
return;
|
|
1535
1611
|
}
|
|
1536
|
-
const
|
|
1537
|
-
this.onSubmit && this.onSubmit(
|
|
1612
|
+
const a = s && typeof s.value == "string" && s.value.trim() ? s.value : s.label;
|
|
1613
|
+
this.onSubmit && this.onSubmit(a);
|
|
1538
1614
|
};
|
|
1539
|
-
|
|
1540
|
-
(
|
|
1541
|
-
},
|
|
1542
|
-
}), this.messagesContainer.appendChild(
|
|
1615
|
+
n.onclick = o, n.onkeydown = (a) => {
|
|
1616
|
+
(a.key === "Enter" || a.key === " ") && (a.preventDefault(), o());
|
|
1617
|
+
}, t.appendChild(n);
|
|
1618
|
+
}), this.messagesContainer.appendChild(t), this.scrollToBottom();
|
|
1543
1619
|
}
|
|
1544
|
-
addForm(e,
|
|
1620
|
+
addForm(e, t, s) {
|
|
1545
1621
|
if (!this.messagesContainer) return;
|
|
1546
1622
|
this.addMessage(e, "system");
|
|
1547
|
-
const
|
|
1548
|
-
|
|
1549
|
-
const o = [],
|
|
1623
|
+
const n = document.createElement("form");
|
|
1624
|
+
n.className = "foisit-form";
|
|
1625
|
+
const o = [], a = (d, l) => {
|
|
1550
1626
|
const f = document.createElement("div");
|
|
1551
1627
|
return f.className = "foisit-form-label", f.innerHTML = d + (l ? ' <span class="foisit-req-star">*</span>' : ""), f;
|
|
1552
|
-
},
|
|
1628
|
+
}, r = () => {
|
|
1553
1629
|
const d = document.createElement("div");
|
|
1554
1630
|
return d.className = "foisit-form-error", d.style.display = "none", d;
|
|
1555
1631
|
};
|
|
1556
|
-
(
|
|
1632
|
+
(t ?? []).forEach((d) => {
|
|
1557
1633
|
const l = document.createElement("div");
|
|
1558
1634
|
l.className = "foisit-form-group";
|
|
1559
1635
|
const f = d.description || d.name;
|
|
1560
|
-
l.appendChild(
|
|
1636
|
+
l.appendChild(a(f, d.required));
|
|
1561
1637
|
let m;
|
|
1562
1638
|
if (d.type === "select") {
|
|
1563
1639
|
const u = document.createElement("select");
|
|
@@ -1565,16 +1641,16 @@ class zt {
|
|
|
1565
1641
|
const v = document.createElement("option");
|
|
1566
1642
|
v.value = "", v.textContent = "Select...", u.appendChild(v);
|
|
1567
1643
|
const x = (p) => {
|
|
1568
|
-
(p ?? []).forEach((
|
|
1644
|
+
(p ?? []).forEach((C) => {
|
|
1569
1645
|
const b = document.createElement("option");
|
|
1570
|
-
b.value = String(
|
|
1646
|
+
b.value = String(C.value ?? C.label ?? ""), b.textContent = String(C.label ?? C.value ?? ""), u.appendChild(b);
|
|
1571
1647
|
});
|
|
1572
1648
|
};
|
|
1573
1649
|
if (Array.isArray(d.options) && d.options.length)
|
|
1574
1650
|
x(d.options);
|
|
1575
1651
|
else if (typeof d.getOptions == "function") {
|
|
1576
|
-
const p = d.getOptions,
|
|
1577
|
-
|
|
1652
|
+
const p = d.getOptions, C = document.createElement("option");
|
|
1653
|
+
C.value = "", C.textContent = "Loading...", u.appendChild(C), Promise.resolve().then(() => p()).then((b) => {
|
|
1578
1654
|
for (; u.options.length > 1; ) u.remove(1);
|
|
1579
1655
|
x(b);
|
|
1580
1656
|
}).catch(() => {
|
|
@@ -1589,24 +1665,24 @@ class zt {
|
|
|
1589
1665
|
v.className = "foisit-form-input", v.type = "file", u.accept && Array.isArray(u.accept) && (v.accept = u.accept.join(",")), u.multiple && (v.multiple = !0), u.capture && (u.capture === !0 ? v.setAttribute("capture", "") : v.setAttribute("capture", String(u.capture))), v.addEventListener("change", async () => {
|
|
1590
1666
|
const x = Array.from(v.files || []), p = y;
|
|
1591
1667
|
if (p.style.display = "none", p.textContent = "", x.length === 0) return;
|
|
1592
|
-
const
|
|
1593
|
-
if (x.length >
|
|
1594
|
-
p.textContent = `Please select at most ${
|
|
1668
|
+
const C = u.maxFiles ?? (u.multiple ? 10 : 1);
|
|
1669
|
+
if (x.length > C) {
|
|
1670
|
+
p.textContent = `Please select at most ${C} file(s).`, p.style.display = "block";
|
|
1595
1671
|
return;
|
|
1596
1672
|
}
|
|
1597
|
-
const b = u.maxSizeBytes ?? 1 / 0, g = x.reduce((w,
|
|
1673
|
+
const b = u.maxSizeBytes ?? 1 / 0, g = x.reduce((w, B) => w + B.size, 0);
|
|
1598
1674
|
if (x.some((w) => w.size > b)) {
|
|
1599
1675
|
p.textContent = `One or more files exceed the maximum size of ${Math.round(b / 1024)} KB.`, p.style.display = "block";
|
|
1600
1676
|
return;
|
|
1601
1677
|
}
|
|
1602
|
-
const
|
|
1603
|
-
if (g >
|
|
1604
|
-
p.textContent = `Total selected files exceed the maximum of ${Math.round(
|
|
1678
|
+
const V = u.maxTotalBytes ?? 1 / 0;
|
|
1679
|
+
if (g > V) {
|
|
1680
|
+
p.textContent = `Total selected files exceed the maximum of ${Math.round(V / 1024)} KB.`, p.style.display = "block";
|
|
1605
1681
|
return;
|
|
1606
1682
|
}
|
|
1607
1683
|
if (u.accept && Array.isArray(u.accept)) {
|
|
1608
1684
|
const w = u.accept;
|
|
1609
|
-
if (!x.every((
|
|
1685
|
+
if (!x.every((U) => U.type ? w.some((W) => W.startsWith(".") ? U.name.toLowerCase().endsWith(W.toLowerCase()) : U.type === W || U.type.startsWith(W.split("/")[0] + "/")) : !0)) {
|
|
1610
1686
|
p.textContent = "One or more files have an unsupported type.", p.style.display = "block";
|
|
1611
1687
|
return;
|
|
1612
1688
|
}
|
|
@@ -1616,35 +1692,35 @@ class zt {
|
|
|
1616
1692
|
const u = document.createElement("input");
|
|
1617
1693
|
u.className = "foisit-form-input", d.type === "string" && (u.placeholder = d.placeholder || "Type here..."), d.type === "number" ? (u.type = "number", typeof d.min == "number" && (u.min = String(d.min)), typeof d.max == "number" && (u.max = String(d.max)), typeof d.step == "number" && (u.step = String(d.step)), d.defaultValue != null && (u.value = String(d.defaultValue))) : d.type === "date" ? (u.type = "date", typeof d.min == "string" && (u.min = d.min), typeof d.max == "string" && (u.max = d.max), d.defaultValue != null && (u.value = String(d.defaultValue))) : (u.type = "text", d.defaultValue != null && (u.value = String(d.defaultValue))), m = u;
|
|
1618
1694
|
}
|
|
1619
|
-
const y =
|
|
1695
|
+
const y = r();
|
|
1620
1696
|
l.appendChild(m), l.appendChild(y), o.push({
|
|
1621
1697
|
name: d.name,
|
|
1622
1698
|
type: d.type,
|
|
1623
1699
|
el: m,
|
|
1624
1700
|
required: d.required
|
|
1625
|
-
}),
|
|
1701
|
+
}), n.appendChild(l);
|
|
1626
1702
|
});
|
|
1627
1703
|
const c = document.createElement("div");
|
|
1628
1704
|
c.className = "foisit-form-actions";
|
|
1629
1705
|
const h = document.createElement("button");
|
|
1630
|
-
h.type = "submit", h.textContent = "Submit", h.className = "foisit-option-chip", h.style.fontWeight = "600", c.appendChild(h),
|
|
1706
|
+
h.type = "submit", h.textContent = "Submit", h.className = "foisit-option-chip", h.style.fontWeight = "600", c.appendChild(h), n.appendChild(c), n.onsubmit = async (d) => {
|
|
1631
1707
|
d.preventDefault();
|
|
1632
1708
|
const l = {};
|
|
1633
1709
|
let f = !1;
|
|
1634
|
-
|
|
1710
|
+
n.querySelectorAll(".foisit-form-error").forEach((m) => {
|
|
1635
1711
|
m.style.display = "none", m.textContent = "";
|
|
1636
|
-
}),
|
|
1712
|
+
}), n.querySelectorAll(".foisit-form-input").forEach((m) => {
|
|
1637
1713
|
m.classList.remove("foisit-error-border");
|
|
1638
1714
|
});
|
|
1639
1715
|
for (const m of o) {
|
|
1640
1716
|
if (m.type === "file") {
|
|
1641
|
-
const x = m.el.parentElement, p = x == null ? void 0 : x.querySelector(".foisit-form-error"),
|
|
1717
|
+
const x = m.el.parentElement, p = x == null ? void 0 : x.querySelector(".foisit-form-error"), C = m.el, b = Array.from(C.files || []);
|
|
1642
1718
|
if (m.required && b.length === 0) {
|
|
1643
|
-
f = !0,
|
|
1719
|
+
f = !0, C.classList.add("foisit-error-border"), p && (p.textContent = "This file is required", p.style.display = "block");
|
|
1644
1720
|
continue;
|
|
1645
1721
|
}
|
|
1646
1722
|
if (b.length === 0) continue;
|
|
1647
|
-
const g = (
|
|
1723
|
+
const g = (t ?? []).find((w) => w.name === m.name), V = (g == null ? void 0 : g.delivery) ?? "file";
|
|
1648
1724
|
if (g != null && g.maxWidth || g != null && g.maxHeight)
|
|
1649
1725
|
try {
|
|
1650
1726
|
const w = await this.getImageDimensions(b[0]);
|
|
@@ -1667,11 +1743,11 @@ class zt {
|
|
|
1667
1743
|
}
|
|
1668
1744
|
} catch {
|
|
1669
1745
|
}
|
|
1670
|
-
if (
|
|
1746
|
+
if (V === "file")
|
|
1671
1747
|
l[m.name] = g != null && g.multiple ? b : b[0];
|
|
1672
|
-
else if (
|
|
1748
|
+
else if (V === "base64")
|
|
1673
1749
|
try {
|
|
1674
|
-
const w = await Promise.all(b.map((
|
|
1750
|
+
const w = await Promise.all(b.map((B) => this.readFileAsDataURL(B)));
|
|
1675
1751
|
l[m.name] = g != null && g.multiple ? w : w[0];
|
|
1676
1752
|
} catch {
|
|
1677
1753
|
f = !0, p && (p.textContent = "Failed to encode file(s) to base64.", p.style.display = "block");
|
|
@@ -1692,20 +1768,20 @@ class zt {
|
|
|
1692
1768
|
l[m.name] = y;
|
|
1693
1769
|
}
|
|
1694
1770
|
if (f) {
|
|
1695
|
-
|
|
1771
|
+
n.classList.add("foisit-shake"), setTimeout(() => n.classList.remove("foisit-shake"), 400);
|
|
1696
1772
|
return;
|
|
1697
1773
|
}
|
|
1698
1774
|
h.disabled = !0, h.style.opacity = "0.6", o.forEach((m) => {
|
|
1699
1775
|
m.el.disabled = !0;
|
|
1700
|
-
}),
|
|
1701
|
-
}, this.messagesContainer.appendChild(
|
|
1776
|
+
}), s(l);
|
|
1777
|
+
}, this.messagesContainer.appendChild(n), this.scrollToBottom();
|
|
1702
1778
|
}
|
|
1703
1779
|
showLoading() {
|
|
1704
1780
|
if (this.messagesContainer && !this.loadingEl) {
|
|
1705
1781
|
this.loadingEl = document.createElement("div"), this.loadingEl.className = "foisit-loading-dots foisit-bubble system";
|
|
1706
1782
|
for (let e = 0; e < 3; e++) {
|
|
1707
|
-
const
|
|
1708
|
-
|
|
1783
|
+
const t = document.createElement("div");
|
|
1784
|
+
t.className = "foisit-dot", t.style.animation = `foisitPulse 1.4s infinite ease-in-out ${e * 0.2}s`, this.loadingEl.appendChild(t);
|
|
1709
1785
|
}
|
|
1710
1786
|
this.messagesContainer.appendChild(this.loadingEl), this.scrollToBottom();
|
|
1711
1787
|
}
|
|
@@ -1717,49 +1793,94 @@ class zt {
|
|
|
1717
1793
|
scrollToBottom() {
|
|
1718
1794
|
this.messagesContainer && (this.messagesContainer.scrollTop = this.messagesContainer.scrollHeight);
|
|
1719
1795
|
}
|
|
1796
|
+
/** Subtle entrance animation for new messages */
|
|
1797
|
+
animateMessageEntrance(e, t) {
|
|
1798
|
+
if (!e) return;
|
|
1799
|
+
e.style.transition = `opacity ${t}ms cubic-bezier(0.22, 0.9, 0.32, 1), transform ${Math.max(120, t)}ms cubic-bezier(0.22, 0.9, 0.32, 1)`, requestAnimationFrame(() => {
|
|
1800
|
+
e.style.opacity = "1", e.style.transform = "translateY(0)";
|
|
1801
|
+
});
|
|
1802
|
+
const s = () => {
|
|
1803
|
+
try {
|
|
1804
|
+
e.style.transition = "";
|
|
1805
|
+
} catch {
|
|
1806
|
+
}
|
|
1807
|
+
e.removeEventListener("transitionend", s);
|
|
1808
|
+
};
|
|
1809
|
+
e.addEventListener("transitionend", s);
|
|
1810
|
+
}
|
|
1811
|
+
/** Smoothly scroll messages container to bottom over duration (ms) */
|
|
1812
|
+
animateScrollToBottom(e) {
|
|
1813
|
+
if (!this.messagesContainer) return;
|
|
1814
|
+
const t = this.messagesContainer, s = t.scrollTop, n = t.scrollHeight - t.clientHeight;
|
|
1815
|
+
if (n <= s || e <= 0) {
|
|
1816
|
+
t.scrollTop = n;
|
|
1817
|
+
return;
|
|
1818
|
+
}
|
|
1819
|
+
const o = n - s, a = performance.now(), r = (c) => {
|
|
1820
|
+
const h = Math.min(1, (c - a) / e), d = 1 - Math.pow(1 - h, 3);
|
|
1821
|
+
t.scrollTop = Math.round(s + o * d), h < 1 && requestAnimationFrame(r);
|
|
1822
|
+
};
|
|
1823
|
+
requestAnimationFrame(r);
|
|
1824
|
+
}
|
|
1720
1825
|
destroy() {
|
|
1721
1826
|
var e;
|
|
1722
|
-
(e = this.container) == null || e.remove(), this.container = null, this.chatWindow = null, this.messagesContainer = null, this.input = null, this.isOpen = !1;
|
|
1827
|
+
this.removeClickOutsideListener(), (e = this.container) == null || e.remove(), this.container = null, this.chatWindow = null, this.messagesContainer = null, this.input = null, this.isOpen = !1;
|
|
1828
|
+
}
|
|
1829
|
+
/** Escape HTML special characters to prevent XSS */
|
|
1830
|
+
escapeHtml(e) {
|
|
1831
|
+
const t = {
|
|
1832
|
+
"&": "&",
|
|
1833
|
+
"<": "<",
|
|
1834
|
+
">": ">",
|
|
1835
|
+
'"': """,
|
|
1836
|
+
"'": "'"
|
|
1837
|
+
};
|
|
1838
|
+
return e.replace(/[&<>"']/g, (s) => t[s]);
|
|
1839
|
+
}
|
|
1840
|
+
/** Simple markdown renderer for AI responses */
|
|
1841
|
+
renderMarkdown(e) {
|
|
1842
|
+
let t = this.escapeHtml(e);
|
|
1843
|
+
return t = t.replace(/```(\w*)\n([\s\S]*?)```/g, (s, n, o) => `<pre class="foisit-code-block"><code${n ? ` class="language-${n}"` : ""}>${o.trim()}</code></pre>`), t = t.replace(/`([^`]+)`/g, '<code class="foisit-inline-code">$1</code>'), t = t.replace(/^###### (.+)$/gm, '<h6 class="foisit-md-h6">$1</h6>'), t = t.replace(/^##### (.+)$/gm, '<h5 class="foisit-md-h5">$1</h5>'), t = t.replace(/^#### (.+)$/gm, '<h4 class="foisit-md-h4">$1</h4>'), t = t.replace(/^### (.+)$/gm, '<h3 class="foisit-md-h3">$1</h3>'), t = t.replace(/^## (.+)$/gm, '<h2 class="foisit-md-h2">$1</h2>'), t = t.replace(/^# (.+)$/gm, '<h1 class="foisit-md-h1">$1</h1>'), t = t.replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>"), t = t.replace(/__([^_]+)__/g, "<strong>$1</strong>"), t = t.replace(/\*([^*]+)\*/g, "<em>$1</em>"), t = t.replace(new RegExp("(?<!_)_([^_]+)_(?!_)", "g"), "<em>$1</em>"), t = t.replace(/~~([^~]+)~~/g, "<del>$1</del>"), t = t.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2" target="_blank" rel="noopener noreferrer" class="foisit-md-link">$1</a>'), t = t.replace(/^[\-\*] (.+)$/gm, '<li class="foisit-md-li">$1</li>'), t = t.replace(/(<li class="foisit-md-li">.*<\/li>\n?)+/g, (s) => `<ul class="foisit-md-ul">${s}</ul>`), t = t.replace(/^\d+\. (.+)$/gm, '<li class="foisit-md-li">$1</li>'), t = t.replace(new RegExp('(?<!<\\/ul>)(<li class="foisit-md-li">.*<\\/li>\\n?)+', "g"), (s) => s.includes("<ul") ? s : `<ol class="foisit-md-ol">${s}</ol>`), t = t.replace(/^> (.+)$/gm, '<blockquote class="foisit-md-blockquote">$1</blockquote>'), t = t.replace(/^(---|___|\*\*\*)$/gm, '<hr class="foisit-md-hr">'), t = t.replace(/\n\n+/g, '</p><p class="foisit-md-p">'), t = t.replace(/\n/g, "<br>"), t.match(/^<(h[1-6]|ul|ol|pre|blockquote|hr|p)/) || (t = `<p class="foisit-md-p">${t}</p>`), t;
|
|
1723
1844
|
}
|
|
1724
1845
|
readFileAsDataURL(e) {
|
|
1725
|
-
return new Promise((
|
|
1726
|
-
const
|
|
1727
|
-
|
|
1846
|
+
return new Promise((t, s) => {
|
|
1847
|
+
const n = new FileReader();
|
|
1848
|
+
n.onerror = () => s(new Error("Failed to read file")), n.onload = () => t(String(n.result)), n.readAsDataURL(e);
|
|
1728
1849
|
});
|
|
1729
1850
|
}
|
|
1730
1851
|
getImageDimensions(e) {
|
|
1731
|
-
return new Promise((
|
|
1852
|
+
return new Promise((t) => {
|
|
1732
1853
|
try {
|
|
1733
|
-
const
|
|
1734
|
-
|
|
1735
|
-
const o = { width:
|
|
1736
|
-
URL.revokeObjectURL(
|
|
1737
|
-
},
|
|
1738
|
-
URL.revokeObjectURL(
|
|
1739
|
-
},
|
|
1854
|
+
const s = URL.createObjectURL(e), n = new Image();
|
|
1855
|
+
n.onload = () => {
|
|
1856
|
+
const o = { width: n.naturalWidth || n.width, height: n.naturalHeight || n.height };
|
|
1857
|
+
URL.revokeObjectURL(s), t(o);
|
|
1858
|
+
}, n.onerror = () => {
|
|
1859
|
+
URL.revokeObjectURL(s), t({ width: 0, height: 0 });
|
|
1860
|
+
}, n.src = s;
|
|
1740
1861
|
} catch {
|
|
1741
|
-
|
|
1862
|
+
t({ width: 0, height: 0 });
|
|
1742
1863
|
}
|
|
1743
1864
|
});
|
|
1744
1865
|
}
|
|
1745
1866
|
getMediaDuration(e) {
|
|
1746
|
-
return new Promise((
|
|
1867
|
+
return new Promise((t) => {
|
|
1747
1868
|
try {
|
|
1748
|
-
const
|
|
1869
|
+
const s = URL.createObjectURL(e), n = e.type.startsWith("audio") ? document.createElement("audio") : document.createElement("video");
|
|
1749
1870
|
let o = !1;
|
|
1750
|
-
const
|
|
1751
|
-
o || (o = !0, URL.revokeObjectURL(
|
|
1871
|
+
const a = setTimeout(() => {
|
|
1872
|
+
o || (o = !0, URL.revokeObjectURL(s), t(0));
|
|
1752
1873
|
}, 5e3);
|
|
1753
|
-
|
|
1874
|
+
n.preload = "metadata", n.onloadedmetadata = () => {
|
|
1754
1875
|
if (o) return;
|
|
1755
|
-
o = !0, clearTimeout(
|
|
1756
|
-
const c =
|
|
1757
|
-
URL.revokeObjectURL(
|
|
1758
|
-
},
|
|
1759
|
-
o || (o = !0, clearTimeout(
|
|
1760
|
-
},
|
|
1876
|
+
o = !0, clearTimeout(a);
|
|
1877
|
+
const c = n.duration || 0;
|
|
1878
|
+
URL.revokeObjectURL(s), t(c);
|
|
1879
|
+
}, n.onerror = () => {
|
|
1880
|
+
o || (o = !0, clearTimeout(a), URL.revokeObjectURL(s), t(0));
|
|
1881
|
+
}, n.src = s;
|
|
1761
1882
|
} catch {
|
|
1762
|
-
|
|
1883
|
+
t(0);
|
|
1763
1884
|
}
|
|
1764
1885
|
});
|
|
1765
1886
|
}
|
|
@@ -2087,26 +2208,112 @@ class zt {
|
|
|
2087
2208
|
transition: transform 0.2s;
|
|
2088
2209
|
}
|
|
2089
2210
|
.foisit-floating-btn:hover { transform: scale(1.05); }
|
|
2211
|
+
|
|
2212
|
+
/* Markdown Styles */
|
|
2213
|
+
.foisit-bubble.system .foisit-md-p { margin: 0 0 0.5em 0; }
|
|
2214
|
+
.foisit-bubble.system .foisit-md-p:last-child { margin-bottom: 0; }
|
|
2215
|
+
|
|
2216
|
+
.foisit-bubble.system .foisit-md-h1,
|
|
2217
|
+
.foisit-bubble.system .foisit-md-h2,
|
|
2218
|
+
.foisit-bubble.system .foisit-md-h3,
|
|
2219
|
+
.foisit-bubble.system .foisit-md-h4,
|
|
2220
|
+
.foisit-bubble.system .foisit-md-h5,
|
|
2221
|
+
.foisit-bubble.system .foisit-md-h6 {
|
|
2222
|
+
margin: 0.8em 0 0.4em 0;
|
|
2223
|
+
font-weight: 600;
|
|
2224
|
+
line-height: 1.3;
|
|
2225
|
+
}
|
|
2226
|
+
.foisit-bubble.system .foisit-md-h1:first-child,
|
|
2227
|
+
.foisit-bubble.system .foisit-md-h2:first-child,
|
|
2228
|
+
.foisit-bubble.system .foisit-md-h3:first-child { margin-top: 0; }
|
|
2229
|
+
|
|
2230
|
+
.foisit-bubble.system .foisit-md-h1 { font-size: 1.4em; }
|
|
2231
|
+
.foisit-bubble.system .foisit-md-h2 { font-size: 1.25em; }
|
|
2232
|
+
.foisit-bubble.system .foisit-md-h3 { font-size: 1.1em; }
|
|
2233
|
+
.foisit-bubble.system .foisit-md-h4 { font-size: 1em; }
|
|
2234
|
+
.foisit-bubble.system .foisit-md-h5 { font-size: 0.95em; }
|
|
2235
|
+
.foisit-bubble.system .foisit-md-h6 { font-size: 0.9em; opacity: 0.85; }
|
|
2236
|
+
|
|
2237
|
+
.foisit-bubble.system .foisit-md-ul,
|
|
2238
|
+
.foisit-bubble.system .foisit-md-ol {
|
|
2239
|
+
margin: 0.5em 0;
|
|
2240
|
+
padding-left: 1.5em;
|
|
2241
|
+
}
|
|
2242
|
+
.foisit-bubble.system .foisit-md-li { margin: 0.25em 0; }
|
|
2243
|
+
|
|
2244
|
+
.foisit-bubble.system .foisit-code-block {
|
|
2245
|
+
background: rgba(0,0,0,0.15);
|
|
2246
|
+
border-radius: 6px;
|
|
2247
|
+
padding: 10px 12px;
|
|
2248
|
+
margin: 0.5em 0;
|
|
2249
|
+
overflow-x: auto;
|
|
2250
|
+
font-family: 'SF Mono', Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
|
|
2251
|
+
font-size: 0.85em;
|
|
2252
|
+
line-height: 1.4;
|
|
2253
|
+
}
|
|
2254
|
+
.foisit-bubble.system .foisit-code-block code {
|
|
2255
|
+
background: transparent;
|
|
2256
|
+
padding: 0;
|
|
2257
|
+
}
|
|
2258
|
+
|
|
2259
|
+
.foisit-bubble.system .foisit-inline-code {
|
|
2260
|
+
background: rgba(0,0,0,0.1);
|
|
2261
|
+
padding: 2px 6px;
|
|
2262
|
+
border-radius: 4px;
|
|
2263
|
+
font-family: 'SF Mono', Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
|
|
2264
|
+
font-size: 0.9em;
|
|
2265
|
+
}
|
|
2266
|
+
|
|
2267
|
+
.foisit-bubble.system .foisit-md-blockquote {
|
|
2268
|
+
border-left: 3px solid rgba(127,127,127,0.4);
|
|
2269
|
+
margin: 0.5em 0;
|
|
2270
|
+
padding-left: 12px;
|
|
2271
|
+
opacity: 0.9;
|
|
2272
|
+
font-style: italic;
|
|
2273
|
+
}
|
|
2274
|
+
|
|
2275
|
+
.foisit-bubble.system .foisit-md-link {
|
|
2276
|
+
color: inherit;
|
|
2277
|
+
text-decoration: underline;
|
|
2278
|
+
opacity: 0.9;
|
|
2279
|
+
}
|
|
2280
|
+
.foisit-bubble.system .foisit-md-link:hover { opacity: 1; }
|
|
2281
|
+
|
|
2282
|
+
.foisit-bubble.system .foisit-md-hr {
|
|
2283
|
+
border: none;
|
|
2284
|
+
border-top: 1px solid rgba(127,127,127,0.3);
|
|
2285
|
+
margin: 0.8em 0;
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
.foisit-bubble.system strong { font-weight: 600; }
|
|
2289
|
+
.foisit-bubble.system em { font-style: italic; }
|
|
2290
|
+
.foisit-bubble.system del { text-decoration: line-through; opacity: 0.7; }
|
|
2291
|
+
|
|
2292
|
+
@media (prefers-color-scheme: dark) {
|
|
2293
|
+
.foisit-bubble.system .foisit-code-block { background: rgba(255,255,255,0.08); }
|
|
2294
|
+
.foisit-bubble.system .foisit-inline-code { background: rgba(255,255,255,0.1); }
|
|
2295
|
+
}
|
|
2090
2296
|
`, document.head.appendChild(e);
|
|
2091
2297
|
}
|
|
2092
2298
|
}
|
|
2093
2299
|
class Ut {
|
|
2094
2300
|
constructor(e) {
|
|
2095
|
-
this.config = e, this.isActivated = !1, this.lastProcessedInput = "", this.processingLock = !1, this.defaultIntroMessage = "How can I help you?", this.commandHandler = new
|
|
2301
|
+
this.config = e, this.isActivated = !1, this.lastProcessedInput = "", this.processingLock = !1, this.defaultIntroMessage = "How can I help you?", this.commandHandler = new $t({
|
|
2096
2302
|
enableSmartIntent: this.config.enableSmartIntent !== !1,
|
|
2097
2303
|
intentEndpoint: this.config.intentEndpoint
|
|
2098
|
-
}), this.fallbackHandler = new
|
|
2304
|
+
}), this.fallbackHandler = new Ft(), this.voiceProcessor = new Ht(), this.textToSpeech = new qe(), this.stateManager = new zt(), this.gestureHandler = new ae(), this.overlayManager = new Bt({
|
|
2099
2305
|
floatingButton: this.config.floatingButton,
|
|
2100
|
-
inputPlaceholder: this.config.inputPlaceholder
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2306
|
+
inputPlaceholder: this.config.inputPlaceholder,
|
|
2307
|
+
enableGestureActivation: this.config.enableGestureActivation
|
|
2308
|
+
}), this.overlayManager.setExternalCommandExecutor(async (t) => this.commandHandler.executeCommand(t)), this.config.commands.forEach((t) => this.commandHandler.addCommand(t)), this.config.fallbackResponse && this.fallbackHandler.setFallbackMessage(this.config.fallbackResponse), this.overlayManager.registerCallbacks(
|
|
2309
|
+
async (t) => {
|
|
2310
|
+
if (typeof t == "string")
|
|
2311
|
+
this.overlayManager.addMessage(t, "user");
|
|
2312
|
+
else if (t && typeof t == "object") {
|
|
2313
|
+
const s = this.extractUserLabel(t);
|
|
2314
|
+
s && this.overlayManager.addMessage(s, "user");
|
|
2108
2315
|
}
|
|
2109
|
-
await this.handleCommand(
|
|
2316
|
+
await this.handleCommand(t);
|
|
2110
2317
|
},
|
|
2111
2318
|
() => console.log("AssistantService: Overlay closed.")
|
|
2112
2319
|
);
|
|
@@ -2129,48 +2336,48 @@ class Ut {
|
|
|
2129
2336
|
}
|
|
2130
2337
|
/** Process activation command */
|
|
2131
2338
|
async processActivation(e) {
|
|
2132
|
-
var
|
|
2133
|
-
const
|
|
2134
|
-
|
|
2339
|
+
var s;
|
|
2340
|
+
const t = (s = this.config.activationCommand) == null ? void 0 : s.toLowerCase();
|
|
2341
|
+
t && (e === t ? (console.log("AssistantService: Activation matched."), this.isActivated = !0, this.textToSpeech.speak(
|
|
2135
2342
|
this.config.introMessage || this.defaultIntroMessage
|
|
2136
2343
|
)) : console.log("AssistantService: Activation command not recognized."));
|
|
2137
2344
|
}
|
|
2138
2345
|
/** Handle recognized commands */
|
|
2139
2346
|
async handleCommand(e) {
|
|
2140
2347
|
this.overlayManager.showLoading();
|
|
2141
|
-
let
|
|
2348
|
+
let t;
|
|
2142
2349
|
try {
|
|
2143
|
-
|
|
2350
|
+
t = await this.commandHandler.executeCommand(e);
|
|
2144
2351
|
} finally {
|
|
2145
2352
|
this.overlayManager.hideLoading();
|
|
2146
2353
|
}
|
|
2147
|
-
if (
|
|
2354
|
+
if (t.type === "form" && t.fields) {
|
|
2148
2355
|
this.overlayManager.addForm(
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
async (
|
|
2356
|
+
t.message,
|
|
2357
|
+
t.fields,
|
|
2358
|
+
async (s) => {
|
|
2152
2359
|
this.overlayManager.showLoading();
|
|
2153
|
-
let
|
|
2360
|
+
let n;
|
|
2154
2361
|
try {
|
|
2155
|
-
|
|
2362
|
+
n = await this.commandHandler.executeCommand(s);
|
|
2156
2363
|
} finally {
|
|
2157
2364
|
this.overlayManager.hideLoading();
|
|
2158
2365
|
}
|
|
2159
|
-
this.processResponse(
|
|
2366
|
+
this.processResponse(n);
|
|
2160
2367
|
}
|
|
2161
2368
|
);
|
|
2162
2369
|
return;
|
|
2163
2370
|
}
|
|
2164
|
-
if (
|
|
2165
|
-
const
|
|
2166
|
-
|
|
2371
|
+
if (t.type === "error") {
|
|
2372
|
+
const s = typeof e == "string" ? e : "";
|
|
2373
|
+
s ? (this.fallbackHandler.handleFallback(s), this.overlayManager.addMessage(this.fallbackHandler.getFallbackMessage(), "system")) : t.message && this.overlayManager.addMessage(t.message, "system");
|
|
2167
2374
|
return;
|
|
2168
2375
|
}
|
|
2169
|
-
if ((
|
|
2170
|
-
|
|
2376
|
+
if ((t.type === "ambiguous" || t.type === "confirm") && t.options) {
|
|
2377
|
+
t.message && this.overlayManager.addMessage(t.message, "system"), this.overlayManager.addOptions(t.options);
|
|
2171
2378
|
return;
|
|
2172
2379
|
}
|
|
2173
|
-
|
|
2380
|
+
t.message && this.overlayManager.addMessage(t.message, "system");
|
|
2174
2381
|
}
|
|
2175
2382
|
/**
|
|
2176
2383
|
* Cleanup resources
|
|
@@ -2184,15 +2391,15 @@ class Ut {
|
|
|
2184
2391
|
this.overlayManager.addForm(
|
|
2185
2392
|
e.message,
|
|
2186
2393
|
e.fields,
|
|
2187
|
-
async (
|
|
2394
|
+
async (t) => {
|
|
2188
2395
|
this.overlayManager.showLoading();
|
|
2189
|
-
let
|
|
2396
|
+
let s;
|
|
2190
2397
|
try {
|
|
2191
|
-
|
|
2398
|
+
s = await this.commandHandler.executeCommand(t);
|
|
2192
2399
|
} finally {
|
|
2193
2400
|
this.overlayManager.hideLoading();
|
|
2194
2401
|
}
|
|
2195
|
-
this.processResponse(
|
|
2402
|
+
this.processResponse(s);
|
|
2196
2403
|
}
|
|
2197
2404
|
);
|
|
2198
2405
|
return;
|
|
@@ -2203,9 +2410,22 @@ class Ut {
|
|
|
2203
2410
|
}
|
|
2204
2411
|
e.message && this.overlayManager.addMessage(e.message, "system");
|
|
2205
2412
|
}
|
|
2413
|
+
/** Expose programmatic command handler registration to host apps */
|
|
2414
|
+
registerCommandHandler(e, t) {
|
|
2415
|
+
this.overlayManager && this.overlayManager.registerCommandHandler(e, t);
|
|
2416
|
+
}
|
|
2417
|
+
unregisterCommandHandler(e) {
|
|
2418
|
+
this.overlayManager && this.overlayManager.unregisterCommandHandler(e);
|
|
2419
|
+
}
|
|
2420
|
+
/** Programmatically run a registered command (proxies to OverlayManager) */
|
|
2421
|
+
async runCommand(e) {
|
|
2422
|
+
if (!this.overlayManager) throw new Error("Overlay manager not available.");
|
|
2423
|
+
const t = await this.overlayManager.runCommand(e);
|
|
2424
|
+
return t && typeof t == "object" && "type" in t && this.processResponse(t), t;
|
|
2425
|
+
}
|
|
2206
2426
|
/** Add a command dynamically (supports string or rich object) */
|
|
2207
|
-
addCommand(e,
|
|
2208
|
-
console.log(typeof e == "string" ? `AssistantService: Adding command "${e}".` : `AssistantService: Adding rich command "${e.command}".`), this.commandHandler.addCommand(e,
|
|
2427
|
+
addCommand(e, t) {
|
|
2428
|
+
console.log(typeof e == "string" ? `AssistantService: Adding command "${e}".` : `AssistantService: Adding rich command "${e.command}".`), this.commandHandler.addCommand(e, t);
|
|
2209
2429
|
}
|
|
2210
2430
|
/** Remove a command dynamically */
|
|
2211
2431
|
removeCommand(e) {
|
|
@@ -2216,30 +2436,30 @@ class Ut {
|
|
|
2216
2436
|
return this.commandHandler.getCommands();
|
|
2217
2437
|
}
|
|
2218
2438
|
/** Toggle the assistant overlay */
|
|
2219
|
-
toggle(e,
|
|
2439
|
+
toggle(e, t) {
|
|
2220
2440
|
console.log("AssistantService: Toggling overlay..."), this.overlayManager.toggle(
|
|
2221
|
-
async (
|
|
2222
|
-
if (typeof
|
|
2223
|
-
this.overlayManager.addMessage(
|
|
2224
|
-
else if (
|
|
2225
|
-
const
|
|
2226
|
-
|
|
2441
|
+
async (s) => {
|
|
2442
|
+
if (typeof s == "string")
|
|
2443
|
+
this.overlayManager.addMessage(s, "user");
|
|
2444
|
+
else if (s && typeof s == "object") {
|
|
2445
|
+
const n = this.extractUserLabel(s);
|
|
2446
|
+
n && this.overlayManager.addMessage(n, "user");
|
|
2227
2447
|
}
|
|
2228
|
-
e && e(
|
|
2448
|
+
e && e(s), await this.handleCommand(s);
|
|
2229
2449
|
},
|
|
2230
2450
|
() => {
|
|
2231
|
-
console.log("AssistantService: Overlay closed."),
|
|
2451
|
+
console.log("AssistantService: Overlay closed."), t && t();
|
|
2232
2452
|
}
|
|
2233
2453
|
);
|
|
2234
2454
|
}
|
|
2235
2455
|
extractUserLabel(e) {
|
|
2236
|
-
const
|
|
2237
|
-
if (typeof
|
|
2238
|
-
const
|
|
2239
|
-
return typeof
|
|
2456
|
+
const t = e.label;
|
|
2457
|
+
if (typeof t == "string" && t.trim()) return t.trim();
|
|
2458
|
+
const s = e.commandId;
|
|
2459
|
+
return typeof s == "string" && s.trim() ? s.trim() : null;
|
|
2240
2460
|
}
|
|
2241
2461
|
}
|
|
2242
|
-
const
|
|
2462
|
+
const Wt = /* @__PURE__ */ ht({
|
|
2243
2463
|
name: "AssistantProvider",
|
|
2244
2464
|
props: {
|
|
2245
2465
|
config: {
|
|
@@ -2247,30 +2467,30 @@ const Bt = /* @__PURE__ */ mt({
|
|
|
2247
2467
|
required: !0
|
|
2248
2468
|
}
|
|
2249
2469
|
},
|
|
2250
|
-
setup(
|
|
2251
|
-
const
|
|
2252
|
-
return
|
|
2253
|
-
var
|
|
2254
|
-
return (
|
|
2470
|
+
setup(i, { slots: e }) {
|
|
2471
|
+
const t = new Ut(i.config);
|
|
2472
|
+
return ut("assistantService", t), () => {
|
|
2473
|
+
var s;
|
|
2474
|
+
return (s = e.default) == null ? void 0 : s.call(e);
|
|
2255
2475
|
};
|
|
2256
2476
|
}
|
|
2257
|
-
}),
|
|
2258
|
-
const
|
|
2259
|
-
for (const [
|
|
2260
|
-
|
|
2261
|
-
return
|
|
2477
|
+
}), jt = (i, e) => {
|
|
2478
|
+
const t = i.__vccOpts || i;
|
|
2479
|
+
for (const [s, n] of e)
|
|
2480
|
+
t[s] = n;
|
|
2481
|
+
return t;
|
|
2262
2482
|
};
|
|
2263
|
-
function
|
|
2264
|
-
return
|
|
2483
|
+
function Yt(i, e, t, s, n, o) {
|
|
2484
|
+
return yt(i.$slots, "default");
|
|
2265
2485
|
}
|
|
2266
|
-
const
|
|
2267
|
-
const
|
|
2268
|
-
if (!
|
|
2486
|
+
const Gt = /* @__PURE__ */ jt(Wt, [["render", Yt]]), Kt = () => {
|
|
2487
|
+
const i = ft("assistantService");
|
|
2488
|
+
if (!i)
|
|
2269
2489
|
throw new Error("useAssistant must be used within an AssistantProvider");
|
|
2270
|
-
return
|
|
2490
|
+
return i;
|
|
2271
2491
|
};
|
|
2272
2492
|
export {
|
|
2273
|
-
|
|
2493
|
+
Gt as AssistantProvider,
|
|
2274
2494
|
Ut as AssistantService,
|
|
2275
|
-
|
|
2495
|
+
Kt as useAssistant
|
|
2276
2496
|
};
|