@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/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 ie = process.env.NODE_ENV !== "production" ? Object.freeze({}) : {}, qe = process.env.NODE_ENV !== "production" ? Object.freeze([]) : [], ve = () => {
7
- }, ze = (t) => t.charCodeAt(0) === 111 && t.charCodeAt(1) === 110 && // uppercase letter
8
- (t.charCodeAt(2) > 122 || t.charCodeAt(2) < 97), z = Object.assign, k = Array.isArray, R = (t) => typeof t == "function", T = (t) => typeof t == "string", we = (t) => typeof t == "symbol", O = (t) => t !== null && typeof t == "object";
9
- let me;
10
- const Q = () => me || (me = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof global < "u" ? global : {});
11
- function ae(t) {
12
- if (k(t)) {
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 n = 0; n < t.length; n++) {
15
- const i = t[n], s = T(i) ? je(i) : ae(i);
16
- if (s)
17
- for (const o in s)
18
- e[o] = s[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 (T(t) || O(t))
22
- return t;
21
+ } else if (R(i) || T(i))
22
+ return i;
23
23
  }
24
- const Ue = /;(?![^(]*\))/g, Be = /:([^]+)/, We = /\/\*[^]*?\*\//g;
25
- function je(t) {
24
+ const Ue = /;(?![^(]*\))/g, We = /:([^]+)/, je = /\/\*[^]*?\*\//g;
25
+ function Ye(i) {
26
26
  const e = {};
27
- return t.replace(We, "").split(Ue).forEach((n) => {
28
- if (n) {
29
- const i = n.split(Be);
30
- i.length > 1 && (e[i[0].trim()] = i[1].trim());
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 le(t) {
34
+ function ce(i) {
35
35
  let e = "";
36
- if (T(t))
37
- e = t;
38
- else if (k(t))
39
- for (let n = 0; n < t.length; n++) {
40
- const i = le(t[n]);
41
- i && (e += i + " ");
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 (O(t))
44
- for (const n in t)
45
- t[n] && (e += n + " ");
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((t) => t !== "arguments" && t !== "caller").map((t) => Symbol[t]).filter(we)
57
+ /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((i) => i !== "arguments" && i !== "caller").map((i) => Symbol[i]).filter(xe)
58
58
  );
59
- function xe(t) {
60
- return se(t) ? xe(t.__v_raw) : !!(t && t.__v_isReactive);
59
+ function Ce(i) {
60
+ return ne(i) ? Ce(i.__v_raw) : !!(i && i.__v_isReactive);
61
61
  }
62
- function se(t) {
63
- return !!(t && t.__v_isReadonly);
62
+ function ne(i) {
63
+ return !!(i && i.__v_isReadonly);
64
64
  }
65
- function Z(t) {
66
- return !!(t && t.__v_isShallow);
65
+ function Z(i) {
66
+ return !!(i && i.__v_isShallow);
67
67
  }
68
- function oe(t) {
69
- return t ? !!t.__v_raw : !1;
68
+ function oe(i) {
69
+ return i ? !!i.__v_raw : !1;
70
70
  }
71
- function M(t) {
72
- const e = t && t.__v_raw;
73
- return e ? M(e) : t;
71
+ function O(i) {
72
+ const e = i && i.__v_raw;
73
+ return e ? O(e) : i;
74
74
  }
75
- function ce(t) {
76
- return t ? t.__v_isRef === !0 : !1;
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 P = [];
84
- function Ke(t) {
85
- P.push(t);
83
+ const $ = [];
84
+ function Ge(i) {
85
+ $.push(i);
86
86
  }
87
- function Ye() {
88
- P.pop();
87
+ function Ke() {
88
+ $.pop();
89
89
  }
90
90
  let ee = !1;
91
- function _(t, ...e) {
91
+ function _(i, ...e) {
92
92
  if (ee) return;
93
93
  ee = !0;
94
- const n = P.length ? P[P.length - 1].component : null, i = n && n.appContext.config.warnHandler, s = Je();
95
- if (i)
96
- de(
97
- i,
98
- n,
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
- t + e.map((o) => {
103
- var r, a;
104
- return (a = (r = o.toString) == null ? void 0 : r.call(o)) != null ? a : JSON.stringify(o);
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
- n && n.proxy,
107
- s.map(
108
- ({ vnode: o }) => `at <${De(n, o.type)}>`
106
+ t && t.proxy,
107
+ n.map(
108
+ ({ vnode: o }) => `at <${Ve(t, o.type)}>`
109
109
  ).join(`
110
110
  `),
111
- s
111
+ n
112
112
  ]
113
113
  );
114
114
  else {
115
- const o = [`[Vue warn]: ${t}`, ...e];
116
- s.length && o.push(`
117
- `, ...Ge(s)), console.warn(...o);
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 t = P[P.length - 1];
123
- if (!t)
122
+ let i = $[$.length - 1];
123
+ if (!i)
124
124
  return [];
125
125
  const e = [];
126
- for (; t; ) {
127
- const n = e[0];
128
- n && n.vnode === t ? n.recurseCount++ : e.push({
129
- vnode: t,
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 i = t.component && t.component.parent;
133
- t = i && i.vnode;
132
+ const s = i.component && i.component.parent;
133
+ i = s && s.vnode;
134
134
  }
135
135
  return e;
136
136
  }
137
- function Ge(t) {
137
+ function Xe(i) {
138
138
  const e = [];
139
- return t.forEach((n, i) => {
140
- e.push(...i === 0 ? [] : [`
141
- `], ...Xe(n));
139
+ return i.forEach((t, s) => {
140
+ e.push(...s === 0 ? [] : [`
141
+ `], ...Qe(t));
142
142
  }), e;
143
143
  }
144
- function Xe({ vnode: t, recurseCount: e }) {
145
- const n = e > 0 ? `... (${e} recursive calls)` : "", i = t.component ? t.component.parent == null : !1, s = ` at <${De(
146
- t.component,
147
- t.type,
148
- i
149
- )}`, o = ">" + n;
150
- return t.props ? [s, ...Qe(t.props), o] : [s + o];
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 Qe(t) {
153
- const e = [], n = Object.keys(t);
154
- return n.slice(0, 3).forEach((i) => {
155
- e.push(...Se(i, t[i]));
156
- }), n.length > 3 && e.push(" ..."), e;
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(t, e, n) {
159
- return T(e) ? (e = JSON.stringify(e), n ? e : [`${t}=${e}`]) : typeof e == "number" || typeof e == "boolean" || e == null ? n ? e : [`${t}=${e}`] : ce(e) ? (e = Se(t, M(e.value), !0), n ? e : [`${t}=Ref<`, e, ">"]) : R(e) ? [`${t}=fn${e.name ? `<${e.name}>` : ""}`] : (e = M(e), n ? e : [`${t}=`, e]);
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 Ce = {
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 de(t, e, n, i) {
194
+ function ue(i, e, t, s) {
195
195
  try {
196
- return i ? t(...i) : t();
197
- } catch (s) {
198
- Ee(s, e, n);
196
+ return s ? i(...s) : i();
197
+ } catch (n) {
198
+ ke(n, e, t);
199
199
  }
200
200
  }
201
- function Ee(t, e, n, i = !0) {
202
- const s = e ? e.vnode : null, { errorHandler: o, throwUnhandledErrorInProduction: r } = e && e.appContext.config || ie;
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 a = e.parent;
205
- const c = e.proxy, h = process.env.NODE_ENV !== "production" ? Ce[n] : `https://vuejs.org/error-reference/#runtime-${n}`;
206
- for (; a; ) {
207
- const d = a.ec;
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](t, c, h) === !1)
210
+ if (d[l](i, c, h) === !1)
211
211
  return;
212
212
  }
213
- a = a.parent;
213
+ r = r.parent;
214
214
  }
215
215
  if (o) {
216
- de(o, null, 10, [
217
- t,
216
+ ue(o, null, 10, [
217
+ i,
218
218
  c,
219
219
  h
220
220
  ]);
221
221
  return;
222
222
  }
223
223
  }
224
- Ze(t, n, s, i, r);
224
+ et(i, t, n, s, a);
225
225
  }
226
- function Ze(t, e, n, i = !0, s = !1) {
226
+ function et(i, e, t, s = !0, n = !1) {
227
227
  if (process.env.NODE_ENV !== "production") {
228
- const o = Ce[e];
229
- if (n && Ke(n), _(`Unhandled error${o ? ` during execution of ${o}` : ""}`), n && Ye(), i)
230
- throw t;
231
- console.error(t);
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 (s)
234
- throw t;
235
- console.error(t);
233
+ if (n)
234
+ throw i;
235
+ console.error(i);
236
236
  }
237
237
  }
238
- const C = [];
239
- let I = -1;
240
- const D = [];
241
- let L = null, V = 0;
242
- const et = /* @__PURE__ */ Promise.resolve();
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 tt = 100;
245
- function nt(t) {
246
- let e = I + 1, n = C.length;
247
- for (; e < n; ) {
248
- const i = e + n >>> 1, s = C[i], o = H(s);
249
- o < t || o === t && s.flags & 2 ? e = i + 1 : n = i;
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 it(t) {
254
- if (!(t.flags & 1)) {
255
- const e = H(t), n = C[C.length - 1];
256
- !n || // fast path when the job id is larger than the tail
257
- !(t.flags & 2) && e >= H(n) ? C.push(t) : C.splice(nt(e), 0, t), t.flags |= 1, ke();
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 ke() {
261
- re || (re = et.then(_e));
260
+ function _e() {
261
+ re || (re = tt.then(Ae));
262
262
  }
263
- function st(t) {
264
- k(t) ? D.push(...t) : L && t.id === -1 ? L.splice(V + 1, 0, t) : t.flags & 1 || (D.push(t), t.flags |= 1), ke();
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 ot(t) {
267
- if (D.length) {
268
- const e = [...new Set(D)].sort(
269
- (n, i) => H(n) - H(i)
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 (D.length = 0, L) {
272
- L.push(...e);
271
+ if (P.length = 0, N) {
272
+ N.push(...e);
273
273
  return;
274
274
  }
275
- for (L = e, process.env.NODE_ENV !== "production" && (t = t || /* @__PURE__ */ new Map()), V = 0; V < L.length; V++) {
276
- const n = L[V];
277
- process.env.NODE_ENV !== "production" && Ie(t, n) || (n.flags & 4 && (n.flags &= -2), n.flags & 8 || n(), n.flags &= -2);
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
- L = null, V = 0;
279
+ N = null, F = 0;
280
280
  }
281
281
  }
282
- const H = (t) => t.id == null ? t.flags & 2 ? -1 : 1 / 0 : t.id;
283
- function _e(t) {
284
- process.env.NODE_ENV !== "production" && (t = t || /* @__PURE__ */ new Map());
285
- const e = process.env.NODE_ENV !== "production" ? (n) => Ie(t, n) : ve;
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 (I = 0; I < C.length; I++) {
288
- const n = C[I];
289
- if (n && !(n.flags & 8)) {
290
- if (process.env.NODE_ENV !== "production" && e(n))
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
- n.flags & 4 && (n.flags &= -2), de(
293
- n,
294
- n.i,
295
- n.i ? 15 : 14
296
- ), n.flags & 4 || (n.flags &= -2);
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 (; I < C.length; I++) {
301
- const n = C[I];
302
- n && (n.flags &= -2);
300
+ for (; A < S.length; A++) {
301
+ const t = S[A];
302
+ t && (t.flags &= -2);
303
303
  }
304
- I = -1, C.length = 0, ot(t), re = null, (C.length || D.length) && _e(t);
304
+ A = -1, S.length = 0, rt(i), re = null, (S.length || P.length) && Ae(i);
305
305
  }
306
306
  }
307
- function Ie(t, e) {
308
- const n = t.get(e) || 0;
309
- if (n > tt) {
310
- const i = e.i, s = i && Fe(i.type);
311
- return Ee(
312
- `Maximum recursive updates exceeded${s ? ` in component <${s}>` : ""}. 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.`,
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 t.set(e, n + 1), !1;
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: ne(rt),
322
- rerender: ne(at),
323
- reload: ne(lt)
321
+ createRecord: ie(at),
322
+ rerender: ie(lt),
323
+ reload: ie(ct)
324
324
  });
325
- const J = /* @__PURE__ */ new Map();
326
- function rt(t, e) {
327
- return J.has(t) ? !1 : (J.set(t, {
328
- initialDef: G(e),
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 G(t) {
333
- return $e(t) ? t.__vccOpts : t;
332
+ function J(i) {
333
+ return De(i) ? i.__vccOpts : i;
334
334
  }
335
- function at(t, e) {
336
- const n = J.get(t);
337
- n && (n.initialDef.render = e, [...n.instances].forEach((i) => {
338
- e && (i.render = e, G(i.type).render = e), i.renderCache = [], i.job.flags & 8 || i.update();
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 lt(t, e) {
342
- const n = J.get(t);
343
- if (!n) return;
344
- e = G(e), he(n.initialDef, e);
345
- const i = [...n.instances];
346
- for (let s = 0; s < i.length; s++) {
347
- const o = i[s], r = G(o.type);
348
- let a = te.get(r);
349
- a || (r !== n.initialDef && he(r, e), te.set(r, a = /* @__PURE__ */ new Set())), a.add(o), o.appContext.propsCache.delete(o.type), o.appContext.emitsCache.delete(o.type), o.appContext.optionsCache.delete(o.type), o.ceReload ? (a.add(o), o.ceReload(e.styles), a.delete(o)) : o.parent ? it(() => {
350
- o.job.flags & 8 || (o.parent.update(), a.delete(o));
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(r);
353
+ ), o.root.ce && o !== o.root && o.root.ce._removeChildStyle(a);
354
354
  }
355
- st(() => {
355
+ ot(() => {
356
356
  te.clear();
357
357
  });
358
358
  }
359
- function he(t, e) {
360
- z(t, e);
361
- for (const n in t)
362
- n !== "__file" && !(n in e) && delete t[n];
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 ne(t) {
365
- return (e, n) => {
364
+ function ie(i) {
365
+ return (e, t) => {
366
366
  try {
367
- return t(e, n);
368
- } catch (i) {
369
- console.error(i), console.warn(
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 F, j = [];
376
- function Ae(t, e) {
377
- var n, i;
378
- F = t, F ? (F.enabled = !0, j.forEach(({ event: s, args: o }) => F.emit(s, ...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
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
- !((i = (n = window.navigator) == null ? void 0 : n.userAgent) != null && i.includes("jsdom")) ? ((e.__VUE_DEVTOOLS_HOOK_REPLAY__ = e.__VUE_DEVTOOLS_HOOK_REPLAY__ || []).push((o) => {
382
- Ae(o, e);
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
- F || (e.__VUE_DEVTOOLS_HOOK_REPLAY__ = null, j = []);
384
+ H || (e.__VUE_DEVTOOLS_HOOK_REPLAY__ = null, j = []);
385
385
  }, 3e3)) : j = [];
386
386
  }
387
- let N = null, ct = null;
388
- function dt(t, e) {
389
- if (process.env.NODE_ENV !== "production" && (!A || A.isMounted) && _("provide() can only be used inside setup()."), A) {
390
- let n = A.provides;
391
- const i = A.parent && A.parent.provides;
392
- i === n && (n = A.provides = Object.create(i)), n[t] = e;
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 ut(t, e, n = !1) {
396
- const i = Nt();
397
- if (i || bt) {
398
- let s = i ? i.parent == null || i.ce ? i.vnode.appContext && i.vnode.appContext.provides : i.parent.provides : void 0;
399
- if (s && t in s)
400
- return s[t];
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 n && R(e) ? e.call(i && i.proxy) : e;
403
- process.env.NODE_ENV !== "production" && _(`injection "${String(t)}" not found.`);
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 ft = (t) => t.__isTeleport;
407
- function Ne(t, e) {
408
- t.shapeFlag & 6 && t.component ? (t.transition = e, Ne(t.component.subTree, e)) : t.shapeFlag & 128 ? (t.ssContent.transition = e.clone(t.ssContent), t.ssFallback.transition = e.clone(t.ssFallback)) : t.transition = e;
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 mt(t, e) {
412
- return R(t) ? (
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: t.name }, e, { setup: t })
416
- ) : t;
415
+ z({ name: i.name }, e, { setup: i })
416
+ ) : i;
417
417
  }
418
418
  Q().requestIdleCallback;
419
419
  Q().cancelIdleCallback;
420
- const ht = (t) => !!t.type.__asyncLoader, pt = /* @__PURE__ */ Symbol.for("v-ndc");
421
- function gt(t, e, n = {}, i, s) {
422
- if (N.ce || N.parent && ht(N.parent) && N.parent.ce) {
423
- const h = Object.keys(n).length > 0;
424
- return pe(), ge(
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
- [ue("slot", n, i)],
427
+ [fe("slot", t, s)],
428
428
  h ? -2 : 64
429
429
  );
430
430
  }
431
- let o = t[e];
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), pe();
435
- const r = o && Re(o(n)), a = n.key || // slot content array of a dynamic conditional slot may have a branch
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
- r && r.key, c = ge(
437
+ a && a.key, c = ye(
438
438
  q,
439
439
  {
440
- key: (a && !we(a) ? a : `_${e}`) + // #7256 force differentiate fallback content from actual content
441
- (!r && i ? "_fb" : "")
440
+ key: (r && !xe(r) ? r : `_${e}`) + // #7256 force differentiate fallback content from actual content
441
+ (!a && s ? "_fb" : "")
442
442
  },
443
- r || [],
444
- r && t._ === 1 ? 64 : -2
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 Re(t) {
449
- return t.some((e) => Oe(e) ? !(e.type === Te || e.type === q && !Re(e.children)) : !0) ? t : null;
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 yt = {};
452
- process.env.NODE_ENV !== "production" && (yt.ownKeys = (t) => (_(
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(t)));
455
- let bt = null;
456
- const vt = {}, Le = (t) => Object.getPrototypeOf(t) === vt, wt = (t) => t.__isSuspense, q = /* @__PURE__ */ Symbol.for("v-fgt"), xt = /* @__PURE__ */ Symbol.for("v-txt"), Te = /* @__PURE__ */ Symbol.for("v-cmt"), K = [];
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 pe(t = !1) {
459
- K.push(E = t ? null : []);
458
+ function ge(i = !1) {
459
+ Y.push(E = i ? null : []);
460
460
  }
461
461
  function St() {
462
- K.pop(), E = K[K.length - 1] || null;
462
+ Y.pop(), E = Y[Y.length - 1] || null;
463
463
  }
464
- function Ct(t) {
465
- return t.dynamicChildren = E || qe, St(), E && E.push(t), t;
464
+ function Et(i) {
465
+ return i.dynamicChildren = E || ze, St(), E && E.push(i), i;
466
466
  }
467
- function ge(t, e, n, i, s) {
468
- return Ct(
469
- ue(
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(t) {
480
- return t ? t.__v_isVNode === !0 : !1;
479
+ function Oe(i) {
480
+ return i ? i.__v_isVNode === !0 : !1;
481
481
  }
482
- const Et = (...t) => Pe(
483
- ...t
484
- ), Me = ({ key: t }) => t ?? null, Y = ({
485
- ref: t,
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: n
488
- }) => (typeof t == "number" && (t = "" + t), t != null ? T(t) || ce(t) || R(t) ? { i: N, r: t, k: e, f: !!n } : t : null);
489
- function kt(t, e = null, n = null, i = 0, s = null, o = t === q ? 0 : 1, r = !1, a = !1) {
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: t,
493
+ type: i,
494
494
  props: e,
495
- key: e && Me(e),
496
- ref: e && Y(e),
497
- scopeId: ct,
495
+ key: e && $e(e),
496
+ ref: e && G(e),
497
+ scopeId: dt,
498
498
  slotScopeIds: null,
499
- children: n,
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: i,
514
- dynamicProps: s,
513
+ patchFlag: s,
514
+ dynamicProps: n,
515
515
  dynamicChildren: null,
516
516
  appContext: null,
517
- ctx: N
517
+ ctx: M
518
518
  };
519
- return a ? (fe(c, n), o & 128 && t.normalize(c)) : n && (c.shapeFlag |= T(n) ? 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
- !r && // has current parent block
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 ue = process.env.NODE_ENV !== "production" ? Et : Pe;
530
- function Pe(t, e = null, n = null, i = 0, s = null, o = !1) {
531
- if ((!t || t === pt) && (process.env.NODE_ENV !== "production" && !t && _(`Invalid vnode type when creating vnode: ${t}.`), t = Te), Oe(t)) {
532
- const a = X(
533
- t,
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 n && fe(a, n), !o && E && (a.shapeFlag & 6 ? E[E.indexOf(t)] = a : E.push(a)), a.patchFlag = -2, a;
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 ($e(t) && (t = t.__vccOpts), e) {
541
- e = _t(e);
542
- let { class: a, style: c } = e;
543
- a && !T(a) && (e.class = le(a)), O(c) && (oe(c) && !k(c) && (c = z({}, c)), e.style = ae(c));
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 r = T(t) ? 1 : wt(t) ? 128 : ft(t) ? 64 : O(t) ? 4 : R(t) ? 2 : 0;
546
- return process.env.NODE_ENV !== "production" && r & 4 && oe(t) && (t = M(t), _(
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
- t
551
- )), kt(
552
- t,
553
- e,
554
- n,
550
+ i
551
+ )), _t(
555
552
  i,
553
+ e,
554
+ t,
556
555
  s,
557
- r,
556
+ n,
557
+ a,
558
558
  o,
559
559
  !0
560
560
  );
561
561
  }
562
- function _t(t) {
563
- return t ? oe(t) || Le(t) ? z({}, t) : t : null;
562
+ function At(i) {
563
+ return i ? oe(i) || Re(i) ? z({}, i) : i : null;
564
564
  }
565
- function X(t, e, n = !1, i = !1) {
566
- const { props: s, ref: o, patchFlag: r, children: a, transition: c } = t, h = e ? At(s || {}, e) : s, d = {
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: t.type,
569
+ type: i.type,
570
570
  props: h,
571
- key: h && Me(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
- n && o ? k(o) ? o.concat(Y(e)) : [o, Y(e)] : Y(e)
576
+ t && o ? k(o) ? o.concat(G(e)) : [o, G(e)] : G(e)
577
577
  ) : o,
578
- scopeId: t.scopeId,
579
- slotScopeIds: t.slotScopeIds,
580
- children: process.env.NODE_ENV !== "production" && r === -1 && k(a) ? a.map(Ve) : a,
581
- target: t.target,
582
- targetStart: t.targetStart,
583
- targetAnchor: t.targetAnchor,
584
- staticCount: t.staticCount,
585
- shapeFlag: t.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 && t.type !== q ? r === -1 ? 16 : r | 16 : r,
591
- dynamicProps: t.dynamicProps,
592
- dynamicChildren: t.dynamicChildren,
593
- appContext: t.appContext,
594
- dirs: t.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: t.component,
601
- suspense: t.suspense,
602
- ssContent: t.ssContent && X(t.ssContent),
603
- ssFallback: t.ssFallback && X(t.ssFallback),
604
- placeholder: t.placeholder,
605
- el: t.el,
606
- anchor: t.anchor,
607
- ctx: t.ctx,
608
- ce: t.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 && i && Ne(
610
+ return c && s && Ie(
611
611
  d,
612
612
  c.clone(d)
613
613
  ), d;
614
614
  }
615
- function Ve(t) {
616
- const e = X(t);
617
- return k(t.children) && (e.children = t.children.map(Ve)), e;
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 It(t = " ", e = 0) {
620
- return ue(xt, null, t, e);
619
+ function Lt(i = " ", e = 0) {
620
+ return fe(Ct, null, i, e);
621
621
  }
622
- function fe(t, e) {
623
- let n = 0;
624
- const { shapeFlag: i } = t;
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
- n = 16;
628
+ t = 16;
629
629
  else if (typeof e == "object")
630
- if (i & 65) {
631
- const s = e.default;
632
- s && (s._c && (s._d = !1), fe(t, s()), s._c && (s._d = !0));
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
- n = 32, !e._ && !Le(e) && (e._ctx = N);
636
- else R(e) ? (e = { default: e, _ctx: N }, n = 32) : (e = String(e), i & 64 ? (n = 16, e = [It(e)]) : n = 8);
637
- t.children = e, t.shapeFlag |= n;
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 At(...t) {
639
+ function Mt(...i) {
640
640
  const e = {};
641
- for (let n = 0; n < t.length; n++) {
642
- const i = t[n];
643
- for (const s in i)
644
- if (s === "class")
645
- e.class !== i.class && (e.class = le([e.class, i.class]));
646
- else if (s === "style")
647
- e.style = ae([e.style, i.style]);
648
- else if (ze(s)) {
649
- const o = e[s], r = i[s];
650
- r && o !== r && !(k(o) && o.includes(r)) && (e[s] = o ? [].concat(o, r) : r);
651
- } else s !== "" && (e[s] = i[s]);
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 A = null;
656
- const Nt = () => A || N;
655
+ let L = null;
656
+ const It = () => L || M;
657
657
  {
658
- const t = Q(), e = (n, i) => {
659
- let s;
660
- return (s = t[n]) || (s = t[n] = []), s.push(i), (o) => {
661
- s.length > 1 ? s.forEach((r) => r(o)) : s[0](o);
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
- (n) => A = n
666
+ (t) => L = t
667
667
  ), e(
668
668
  "__VUE_SSR_SETTERS__",
669
- (n) => n
669
+ (t) => t
670
670
  );
671
671
  }
672
672
  process.env.NODE_ENV;
673
- const Rt = /(?:^|[-_])\w/g, Lt = (t) => t.replace(Rt, (e) => e.toUpperCase()).replace(/[-_]/g, "");
674
- function Fe(t, e = !0) {
675
- return R(t) ? t.displayName || t.name : t.name || e && t.__name;
676
- }
677
- function De(t, e, n = !1) {
678
- let i = Fe(e);
679
- if (!i && e.__file) {
680
- const s = e.__file.match(/([^/\\]+)\.\w+$/);
681
- s && (i = s[1]);
682
- }
683
- if (!i && t) {
684
- const s = (o) => {
685
- for (const r in o)
686
- if (o[r] === e)
687
- return r;
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
- i = s(t.components) || t.parent && s(
690
- t.parent.type.components
691
- ) || s(t.appContext.components);
689
+ s = n(i.components) || i.parent && n(
690
+ i.parent.type.components
691
+ ) || n(i.appContext.components);
692
692
  }
693
- return i ? Lt(i) : n ? "App" : "Anonymous";
693
+ return s ? Rt(s) : t ? "App" : "Anonymous";
694
694
  }
695
- function $e(t) {
696
- return R(t) && "__vccOpts" in t;
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 t = { style: "color:#3ba776" }, e = { style: "color:#1677ff" }, n = { style: "color:#f5222d" }, i = { style: "color:#eb2f96" }, s = {
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 (!O(l))
704
+ if (!T(l))
705
705
  return null;
706
706
  if (l.__isVue)
707
- return ["div", t, "VueInstance"];
708
- if (ce(l)) {
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", t, d(l)],
713
+ ["span", i, d(l)],
714
714
  "<",
715
- a(f),
715
+ r(f),
716
716
  ">"
717
717
  ];
718
718
  } else {
719
- if (xe(l))
719
+ if (Ce(l))
720
720
  return [
721
721
  "div",
722
722
  {},
723
- ["span", t, Z(l) ? "ShallowReactive" : "Reactive"],
723
+ ["span", i, Z(l) ? "ShallowReactive" : "Reactive"],
724
724
  "<",
725
- a(l),
726
- `>${se(l) ? " (readonly)" : ""}`
725
+ r(l),
726
+ `>${ne(l) ? " (readonly)" : ""}`
727
727
  ];
728
- if (se(l))
728
+ if (ne(l))
729
729
  return [
730
730
  "div",
731
731
  {},
732
- ["span", t, Z(l) ? "ShallowReadonly" : "Readonly"],
732
+ ["span", i, Z(l) ? "ShallowReadonly" : "Readonly"],
733
733
  "<",
734
- a(l),
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(r("props", M(l.props))), l.setupState !== ie && f.push(r("setup", l.setupState)), l.data !== ie && f.push(r("data", M(l.data)));
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(r("computed", m));
756
+ m && f.push(a("computed", m));
757
757
  const y = c(l, "inject");
758
- return y && f.push(r("injected", 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: i.style + ";opacity:0.66"
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 r(l, f) {
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", i, m + ": "],
791
- a(f[m], !1)
790
+ ["span", s, m + ": "],
791
+ r(f[m], !1)
792
792
  ])
793
793
  ]
794
794
  ] : ["span", {}];
795
795
  }
796
- function a(l, f = !0) {
797
- return typeof l == "number" ? ["span", e, l] : typeof l == "string" ? ["span", n, JSON.stringify(l)] : typeof l == "boolean" ? ["span", i, l] : O(l) ? ["object", { object: f ? M(l) : l }] : ["span", n, String(l)];
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 (R(m))
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) || O(y) && f in y || l.extends && h(l.extends, f, m) || l.mixins && l.mixins.some((u) => h(u, f, m)))
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(s) : window.devtoolsFormatters = [s];
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 ye {
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, n, i) {
834
+ async determineIntent(e, t, s) {
835
835
  try {
836
- const s = {
836
+ const n = {
837
837
  userInput: e,
838
- commands: n.map((a) => ({
839
- id: a.id,
840
- command: a.command,
841
- description: a.description,
842
- parameters: a.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: i
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(s)
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 (s) {
857
- return console.error("OpenAIService Error:", s), { type: "unknown" };
856
+ } catch (n) {
857
+ return console.error("OpenAIService Error:", n), { type: "unknown" };
858
858
  }
859
859
  }
860
860
  }
861
- class Mt {
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 ye());
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 ye(e.intentEndpoint));
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, n) {
871
- let i;
870
+ addCommand(e, t) {
871
+ let s;
872
872
  if (typeof e == "string") {
873
- if (!n)
873
+ if (!t)
874
874
  throw new Error("Action required when adding command by string.");
875
- i = {
875
+ s = {
876
876
  id: e.toLowerCase().replace(/\s+/g, "_"),
877
877
  command: e.toLowerCase(),
878
- action: n
878
+ action: t
879
879
  };
880
880
  } else
881
- i = { ...e }, i.id || (i.id = i.command.toLowerCase().replace(/\s+/g, "_"));
882
- this.commands.set(i.command.toLowerCase(), i), i.id && (i.id, i.command);
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 r = {
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: r
915
+ params: a
916
916
  }, this.buildConfirmResponse(o);
917
- const a = await this.safeRunAction(o, r);
918
- return this.context = null, this.normalizeResponse(a);
917
+ const r = await this.safeRunAction(o, a);
918
+ return this.context = null, this.normalizeResponse(r);
919
919
  }
920
- const n = e.trim().toLowerCase();
920
+ const t = e.trim().toLowerCase();
921
921
  if (this.pendingConfirmation) {
922
- const o = n;
922
+ const o = t;
923
923
  if (["yes", "y", "confirm", "ok", "okay"].includes(o)) {
924
- const { commandId: r, params: a } = this.pendingConfirmation;
924
+ const { commandId: a, params: r } = this.pendingConfirmation;
925
925
  this.pendingConfirmation = null;
926
- const c = this.getCommandById(r);
927
- return c ? this.safeRunAction(c, a) : { message: "That action is no longer available.", type: "error" };
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: "Cancelled.", type: "success" }) : {
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 i = this.commands.get(n);
939
- if (i) {
940
- const o = i, r = (o.parameters ?? []).filter((a) => a.required);
941
- return r.length > 0 ? (this.context = { commandId: this.getCommandIdentifier(o), params: {} }, {
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: r
947
+ fields: a
945
948
  }) : o.critical ? (this.pendingConfirmation = { commandId: this.getCommandIdentifier(o), params: {} }, this.buildConfirmResponse(o)) : this.safeRunAction(o, {});
946
949
  }
947
- const s = await this.tryDeterministicMatch(n);
948
- if (s) return s;
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(), r = await this.openAIService.determineIntent(
951
- n,
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(r);
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 n = this.getCommandById(e.match);
962
- if (!n)
964
+ const t = this.getCommandById(e.match);
965
+ if (!t)
963
966
  return { message: "I'm not sure what you mean.", type: "error" };
964
- const i = e.params ?? {}, s = this.sanitizeParamsForCommand(n, i), o = n.allowAiParamExtraction === !1 ? {} : s, a = (n.parameters ?? []).filter((h) => h.required).filter((h) => o[h.name] == null || o[h.name] === "");
965
- if (e.incomplete || a.length > 0) {
966
- if (this.context = { commandId: this.getCommandIdentifier(n), params: o }, !(n.collectRequiredViaForm !== !1) && this.shouldAskSingleQuestion(a)) {
967
- const l = a.map((f) => f.name).join(" and ");
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 "${n.command}".`,
979
+ message: e.message || `Please fill in the missing details for "${t.command}".`,
975
980
  type: "form",
976
- fields: a
981
+ fields: r
977
982
  };
978
983
  }
979
- if (n.critical)
984
+ if (t.critical)
980
985
  return this.pendingConfirmation = {
981
- commandId: this.getCommandIdentifier(n),
986
+ commandId: this.getCommandIdentifier(t),
982
987
  params: o
983
- }, this.buildConfirmResponse(n);
984
- const c = await n.action(o);
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((n) => ({
991
- label: n.label,
992
- value: n.commandId ?? n.label,
993
- commandId: n.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, n) {
998
- const i = { ...n ?? {} };
999
- for (const s of e.parameters ?? []) {
1000
- const o = i[s.name];
1001
- if (s.type === "string") {
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 i[s.name];
1008
+ delete s[n.name];
1004
1009
  continue;
1005
1010
  }
1006
- const r = o.trim();
1007
- if (!r) {
1008
- delete i[s.name];
1011
+ const a = o.trim();
1012
+ if (!a) {
1013
+ delete s[n.name];
1009
1014
  continue;
1010
1015
  }
1011
- i[s.name] = r;
1016
+ s[n.name] = a;
1012
1017
  }
1013
- if (s.type === "number") {
1014
- const r = typeof o == "number" ? o : Number(o == null ? void 0 : o.toString().trim());
1015
- if (Number.isNaN(r)) {
1016
- delete i[s.name];
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 s.min == "number" && r < s.min) {
1020
- delete i[s.name];
1024
+ if (typeof n.min == "number" && a < n.min) {
1025
+ delete s[n.name];
1021
1026
  continue;
1022
1027
  }
1023
- if (typeof s.max == "number" && r > s.max) {
1024
- delete i[s.name];
1028
+ if (typeof n.max == "number" && a > n.max) {
1029
+ delete s[n.name];
1025
1030
  continue;
1026
1031
  }
1027
- i[s.name] = r;
1032
+ s[n.name] = a;
1028
1033
  }
1029
- if (s.type === "date") {
1030
- const r = i[s.name];
1031
- if (typeof r == "string") {
1032
- const a = r.trim();
1033
- this.isIsoDateString(a) ? i[s.name] = a : delete i[s.name];
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 i[s.name];
1040
+ delete s[n.name];
1036
1041
  }
1037
- if (s.type === "select") {
1038
- const r = typeof o == "string" ? o : o == null ? void 0 : o.toString();
1039
- if (!r) {
1040
- delete i[s.name];
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(s.options) && s.options.length > 0 && !s.options.some((c) => String(c.value) === String(r))) {
1044
- delete i[s.name];
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
- i[s.name] = r;
1052
+ s[n.name] = a;
1048
1053
  }
1049
- if (s.type === "file") {
1050
- const r = i[s.name], a = r && typeof r == "object" && typeof r.name == "string" && typeof r.size == "number", c = typeof r == "string" && /^data:[^;]+;base64,/.test(r);
1051
- (s.delivery ?? "file") === "base64" ? !c && !a && delete i[s.name] : a || delete i[s.name];
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 i;
1059
+ return s;
1055
1060
  }
1056
1061
  isIsoDateString(e) {
1057
1062
  if (!/^\d{4}-\d{2}-\d{2}$/.test(e)) return !1;
1058
- const n = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
1059
- return !Number.isNaN(n.getTime());
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 n = e[0].type;
1064
- return n === "string" || n === "number" || n === "date";
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: `⚠️ Are you sure you want to run "${e.command}"?`,
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 n = [];
1078
- for (const a of this.commands.values()) {
1082
+ const t = [];
1083
+ for (const r of this.commands.values()) {
1079
1084
  let c = 0;
1080
- const h = a.command.toLowerCase();
1085
+ const h = r.command.toLowerCase();
1081
1086
  e.includes(h) && (c += 5);
1082
- const d = a.keywords ?? [];
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 && n.push({ cmd: a, score: c });
1092
+ c > 0 && t.push({ cmd: r, score: c });
1088
1093
  }
1089
- if (n.length === 0) return null;
1090
- n.sort((a, c) => c.score - a.score);
1091
- const i = n[0].score, s = n.filter((a) => a.score === i).slice(0, 3);
1092
- if (s.length > 1)
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: s.map((a) => ({
1097
- label: a.cmd.command,
1098
- value: a.cmd.command,
1099
- commandId: a.cmd.id
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 = s[0].cmd, r = (o.parameters ?? []).filter((a) => a.required);
1103
- return r.length > 0 ? (this.context = { commandId: this.getCommandIdentifier(o), params: {} }, {
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: r
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, n) {
1114
+ async safeRunAction(e, t) {
1110
1115
  try {
1111
- const i = await e.action(n ?? {});
1112
- return this.normalizeResponse(i);
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((n) => ({
1119
- ...n,
1120
- parameters: n.parameters ? n.parameters.map((i) => ({ ...i })) : void 0
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 (n) => {
1124
- n.parameters && await Promise.all(
1125
- n.parameters.map(async (i) => {
1126
- if (i.type !== "select" || !i.getOptions || i.options && i.options.length) return;
1127
- const s = `${n.id ?? n.command}:${i.name}`, o = this.selectOptionsCache.get(s), r = Date.now();
1128
- if (o && r - o.ts < 6e4) {
1129
- i.options = o.options;
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 a = await i.getOptions();
1134
- this.selectOptionsCache.set(s, { options: a, ts: r }), i.options = a;
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 n of this.commands.values())
1144
- if (n.id === e) return n;
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((n) => ({
1151
- label: n.command,
1152
- value: n.id ?? n.command,
1153
- commandId: n.id ?? n.command
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 He {
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, n) {
1180
+ speak(e, t) {
1176
1181
  if (!this.synth) {
1177
- console.error("SpeechSynthesis API is not supported in this browser.");
1182
+ console.error("SpeechSynthesis API is not supported in this environment.");
1178
1183
  return;
1179
1184
  }
1180
- const i = new SpeechSynthesisUtterance(e);
1181
- n && (i.pitch = n.pitch || 1, i.rate = n.rate || 1, i.volume = n.volume || 1), i.onstart = () => {
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
- }, i.onend = () => {
1188
+ }, s.onend = () => {
1184
1189
  console.log("Speech finished."), window.dispatchEvent(new CustomEvent("foisit:tts-end"));
1185
- }, i.onerror = (s) => {
1186
- console.error("Error during speech synthesis:", s.error);
1187
- }, this.synth.speak(i);
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 Pt {
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 He().speak(this.fallbackMessage);
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 be = () => {
1208
- const t = window;
1209
- return t.SpeechRecognition ?? t.webkitSpeechRecognition ?? null;
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 Vt {
1212
- constructor(e = "en-US", n = {}) {
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 s;
1220
+ var n;
1215
1221
  this.ttsSpeaking = !0;
1216
1222
  try {
1217
- (s = this.recognition) == null || s.stop();
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 i = be();
1225
- if (i) {
1226
- this.recognition = new i(), this.recognition.lang = e, this.recognition.interimResults = n.interimResults ?? !0, this.recognition.continuous = n.continuous ?? !0, this.recognition.onresult = (o) => this.handleResult(o, n), this.recognition.onend = () => this.handleEnd(), this.recognition.onstart = () => {
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 s = this.recognition;
1230
- s.onaudiostart = () => this.log("onaudiostart"), s.onsoundstart = () => this.log("onsoundstart"), s.onspeechstart = () => this.log("onspeechstart"), s.onspeechend = () => this.log("onspeechend"), s.onsoundend = () => this.log("onsoundend"), s.onaudioend = () => this.log("onaudioend"), this.recognition.onerror = (o) => this.handleError(o);
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 s;
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
- (s = this.recognition) == null || s.stop();
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 be() !== null;
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, n) {
1291
- var s, o;
1296
+ handleResult(e, t) {
1297
+ var n, o;
1292
1298
  if (!this.resultCallback) return;
1293
- const i = n.confidenceThreshold ?? 0.6;
1294
- for (let r = e.resultIndex; r < e.results.length; r++) {
1295
- const a = e.results[r], c = a && a[0], h = ((o = (s = c == null ? void 0 : c.transcript) == null ? void 0 : s.trim) == null ? void 0 : o.call(s)) || "", d = (c == null ? void 0 : c.confidence) ?? 0;
1296
- if (h && !(!a.isFinal && n.interimResults === !1) && !(a.isFinal && d < i))
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, !!a.isFinal);
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 n = e == null ? void 0 : e.error;
1315
- if (this.warn(`Error occurred: ${n ?? "unknown"}`), n && ["not-allowed", "service-not-allowed", "bad-grammar", "language-not-supported"].includes(n)) {
1316
- this.intentionallyStopped = !0, this.restartAllowed = !1, this.isListening = !1, this.emitStatus("error", { error: n });
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 n = await e.getUserMedia({ audio: !0 });
1362
- for (const i of n.getTracks()) i.stop();
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, n) {
1374
+ emitStatus(e, t) {
1369
1375
  if (this.statusCallback)
1370
1376
  try {
1371
- this.statusCallback(e, n);
1377
+ this.statusCallback(e, t);
1372
1378
  } catch {
1373
1379
  this.error("VoiceProcessor: status callback error");
1374
1380
  }
1375
1381
  }
1376
1382
  }
1377
- class Ft {
1383
+ class ae {
1378
1384
  constructor() {
1379
- this.lastTap = 0;
1385
+ this.lastTap = 0, this.tapCount = 0;
1380
1386
  }
1381
1387
  /**
1382
- * Sets up double-click and double-tap listeners
1383
- * @param onDoubleClickOrTap Callback to execute when a double-click or double-tap is detected
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
- setupDoubleTapListener(e) {
1386
- this.destroy(), this.dblClickListener = () => {
1387
- e();
1388
- }, document.addEventListener("dblclick", this.dblClickListener), this.touchEndListener = () => {
1389
- const n = (/* @__PURE__ */ new Date()).getTime(), i = n - this.lastTap;
1390
- i < 300 && i > 0 && e(), this.lastTap = n;
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 Dt() {
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 $t() {
1446
+ function Vt() {
1439
1447
  if (document.querySelector("#gradient-indicator"))
1440
1448
  return;
1441
- const t = document.createElement("div");
1442
- t.id = "gradient-indicator", Dt(), t.classList.add("gradient-indicator"), document.body.appendChild(t), console.log("Gradient indicator added to the DOM");
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 Ht() {
1445
- const t = document.querySelector("#gradient-indicator");
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 qt {
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" ? $t() : Ht();
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 zt {
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.config = e, this.init();
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 n, i;
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"), ((n = this.config.floatingButton) == null ? void 0 : n.visible) !== !1 && !e.querySelector(".foisit-floating-btn") && this.renderFloatingButton(), this.chatWindow || this.renderChatWindow();
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), ((i = this.config.floatingButton) == null ? void 0 : i.visible) !== !1 && this.renderFloatingButton(), this.renderChatWindow();
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 s, o, r, a, c, h;
1550
+ var n, o, a, r, c, h;
1483
1551
  const e = document.createElement("button");
1484
- e.innerHTML = ((s = this.config.floatingButton) == null ? void 0 : s.customHtml) || "🎙️";
1485
- const n = ((r = (o = this.config.floatingButton) == null ? void 0 : o.position) == null ? void 0 : r.bottom) || "20px", i = ((c = (a = this.config.floatingButton) == null ? void 0 : a.position) == null ? void 0 : c.right) || "20px";
1486
- e.className = "foisit-floating-btn", e.style.bottom = n, e.style.right = i, 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);
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 n = document.createElement("span");
1495
- n.className = "foisit-title", n.textContent = "Foisit";
1496
- const i = document.createElement("button");
1497
- i.type = "button", i.className = "foisit-close", i.setAttribute("aria-label", "Close"), i.innerHTML = "&times;", i.addEventListener("click", () => this.toggle()), e.appendChild(n), e.appendChild(i), this.messagesContainer = document.createElement("div"), this.messagesContainer.className = "foisit-messages";
1498
- const s = document.createElement("div");
1499
- s.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", (r) => {
1500
- var a;
1501
- if (r.key === "Enter" && ((a = this.input) != null && a.value.trim())) {
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 = "&times;", 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
- }), s.appendChild(this.input), this.chatWindow.appendChild(e), this.chatWindow.appendChild(this.messagesContainer), this.chatWindow.appendChild(s), (o = this.container) == null || o.appendChild(this.chatWindow);
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, n) {
1508
- this.onSubmit = e, this.onClose = n;
1575
+ registerCallbacks(e, t) {
1576
+ this.active && (this.onSubmit = e, this.onClose = t);
1509
1577
  }
1510
- toggle(e, n) {
1511
- e && (this.onSubmit = e), n && (this.onClose = n), this.isOpen = !this.isOpen, this.chatWindow && (this.isOpen ? (this.chatWindow.style.display = "flex", requestAnimationFrame(() => {
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 i;
1515
- return (i = this.input) == null ? void 0 : i.focus();
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
- addMessage(e, n) {
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 i = document.createElement("div");
1523
- i.textContent = e, i.className = n === "user" ? "foisit-bubble user" : "foisit-bubble system", this.messagesContainer.appendChild(i), this.scrollToBottom();
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 n = document.createElement("div");
1528
- n.className = "foisit-options-container", e.forEach((i) => {
1529
- const s = document.createElement("button");
1530
- s.textContent = i.label, s.className = "foisit-option-chip", s.setAttribute("type", "button"), s.setAttribute("aria-label", i.label);
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 (i.commandId) {
1533
- this.onSubmit && this.onSubmit({ commandId: i.commandId });
1608
+ if (s.commandId) {
1609
+ this.onSubmit && this.onSubmit({ commandId: s.commandId });
1534
1610
  return;
1535
1611
  }
1536
- const r = i && typeof i.value == "string" && i.value.trim() ? i.value : i.label;
1537
- this.onSubmit && this.onSubmit(r);
1612
+ const a = s && typeof s.value == "string" && s.value.trim() ? s.value : s.label;
1613
+ this.onSubmit && this.onSubmit(a);
1538
1614
  };
1539
- s.onclick = o, s.onkeydown = (r) => {
1540
- (r.key === "Enter" || r.key === " ") && (r.preventDefault(), o());
1541
- }, n.appendChild(s);
1542
- }), this.messagesContainer.appendChild(n), this.scrollToBottom();
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, n, i) {
1620
+ addForm(e, t, s) {
1545
1621
  if (!this.messagesContainer) return;
1546
1622
  this.addMessage(e, "system");
1547
- const s = document.createElement("form");
1548
- s.className = "foisit-form";
1549
- const o = [], r = (d, l) => {
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
- }, a = () => {
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
- (n ?? []).forEach((d) => {
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(r(f, d.required));
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((S) => {
1644
+ (p ?? []).forEach((C) => {
1569
1645
  const b = document.createElement("option");
1570
- b.value = String(S.value ?? S.label ?? ""), b.textContent = String(S.label ?? S.value ?? ""), u.appendChild(b);
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, S = document.createElement("option");
1577
- S.value = "", S.textContent = "Loading...", u.appendChild(S), Promise.resolve().then(() => p()).then((b) => {
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 S = u.maxFiles ?? (u.multiple ? 10 : 1);
1593
- if (x.length > S) {
1594
- p.textContent = `Please select at most ${S} file(s).`, p.style.display = "block";
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, U) => w + U.size, 0);
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 $ = u.maxTotalBytes ?? 1 / 0;
1603
- if (g > $) {
1604
- p.textContent = `Total selected files exceed the maximum of ${Math.round($ / 1024)} KB.`, p.style.display = "block";
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((B) => B.type ? w.some((W) => W.startsWith(".") ? B.name.toLowerCase().endsWith(W.toLowerCase()) : B.type === W || B.type.startsWith(W.split("/")[0] + "/")) : !0)) {
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 = a();
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
- }), s.appendChild(l);
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), s.appendChild(c), s.onsubmit = async (d) => {
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
- s.querySelectorAll(".foisit-form-error").forEach((m) => {
1710
+ n.querySelectorAll(".foisit-form-error").forEach((m) => {
1635
1711
  m.style.display = "none", m.textContent = "";
1636
- }), s.querySelectorAll(".foisit-form-input").forEach((m) => {
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"), S = m.el, b = Array.from(S.files || []);
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, S.classList.add("foisit-error-border"), p && (p.textContent = "This file is required", p.style.display = "block");
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 = (n ?? []).find((w) => w.name === m.name), $ = (g == null ? void 0 : g.delivery) ?? "file";
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 ($ === "file")
1746
+ if (V === "file")
1671
1747
  l[m.name] = g != null && g.multiple ? b : b[0];
1672
- else if ($ === "base64")
1748
+ else if (V === "base64")
1673
1749
  try {
1674
- const w = await Promise.all(b.map((U) => this.readFileAsDataURL(U)));
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
- s.classList.add("foisit-shake"), setTimeout(() => s.classList.remove("foisit-shake"), 400);
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
- }), i(l);
1701
- }, this.messagesContainer.appendChild(s), this.scrollToBottom();
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 n = document.createElement("div");
1708
- n.className = "foisit-dot", n.style.animation = `foisitPulse 1.4s infinite ease-in-out ${e * 0.2}s`, this.loadingEl.appendChild(n);
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
+ "&": "&amp;",
1833
+ "<": "&lt;",
1834
+ ">": "&gt;",
1835
+ '"': "&quot;",
1836
+ "'": "&#039;"
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(/^&gt; (.+)$/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((n, i) => {
1726
- const s = new FileReader();
1727
- s.onerror = () => i(new Error("Failed to read file")), s.onload = () => n(String(s.result)), s.readAsDataURL(e);
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((n) => {
1852
+ return new Promise((t) => {
1732
1853
  try {
1733
- const i = URL.createObjectURL(e), s = new Image();
1734
- s.onload = () => {
1735
- const o = { width: s.naturalWidth || s.width, height: s.naturalHeight || s.height };
1736
- URL.revokeObjectURL(i), n(o);
1737
- }, s.onerror = () => {
1738
- URL.revokeObjectURL(i), n({ width: 0, height: 0 });
1739
- }, s.src = i;
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
- n({ width: 0, height: 0 });
1862
+ t({ width: 0, height: 0 });
1742
1863
  }
1743
1864
  });
1744
1865
  }
1745
1866
  getMediaDuration(e) {
1746
- return new Promise((n) => {
1867
+ return new Promise((t) => {
1747
1868
  try {
1748
- const i = URL.createObjectURL(e), s = e.type.startsWith("audio") ? document.createElement("audio") : document.createElement("video");
1869
+ const s = URL.createObjectURL(e), n = e.type.startsWith("audio") ? document.createElement("audio") : document.createElement("video");
1749
1870
  let o = !1;
1750
- const r = setTimeout(() => {
1751
- o || (o = !0, URL.revokeObjectURL(i), n(0));
1871
+ const a = setTimeout(() => {
1872
+ o || (o = !0, URL.revokeObjectURL(s), t(0));
1752
1873
  }, 5e3);
1753
- s.preload = "metadata", s.onloadedmetadata = () => {
1874
+ n.preload = "metadata", n.onloadedmetadata = () => {
1754
1875
  if (o) return;
1755
- o = !0, clearTimeout(r);
1756
- const c = s.duration || 0;
1757
- URL.revokeObjectURL(i), n(c);
1758
- }, s.onerror = () => {
1759
- o || (o = !0, clearTimeout(r), URL.revokeObjectURL(i), n(0));
1760
- }, s.src = i;
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
- n(0);
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 Mt({
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 Pt(), this.voiceProcessor = new Vt(), this.textToSpeech = new He(), this.stateManager = new qt(), this.gestureHandler = new Ft(), this.overlayManager = new zt({
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
- }), this.config.commands.forEach((n) => this.commandHandler.addCommand(n)), this.config.fallbackResponse && this.fallbackHandler.setFallbackMessage(this.config.fallbackResponse), this.gestureHandler.setupDoubleTapListener(() => this.toggle()), this.overlayManager.registerCallbacks(
2102
- async (n) => {
2103
- if (typeof n == "string")
2104
- this.overlayManager.addMessage(n, "user");
2105
- else if (n && typeof n == "object") {
2106
- const i = this.extractUserLabel(n);
2107
- i && this.overlayManager.addMessage(i, "user");
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(n);
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 i;
2133
- const n = (i = this.config.activationCommand) == null ? void 0 : i.toLowerCase();
2134
- n && (e === n ? (console.log("AssistantService: Activation matched."), this.isActivated = !0, this.textToSpeech.speak(
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 n;
2348
+ let t;
2142
2349
  try {
2143
- n = await this.commandHandler.executeCommand(e);
2350
+ t = await this.commandHandler.executeCommand(e);
2144
2351
  } finally {
2145
2352
  this.overlayManager.hideLoading();
2146
2353
  }
2147
- if (n.type === "form" && n.fields) {
2354
+ if (t.type === "form" && t.fields) {
2148
2355
  this.overlayManager.addForm(
2149
- n.message,
2150
- n.fields,
2151
- async (i) => {
2356
+ t.message,
2357
+ t.fields,
2358
+ async (s) => {
2152
2359
  this.overlayManager.showLoading();
2153
- let s;
2360
+ let n;
2154
2361
  try {
2155
- s = await this.commandHandler.executeCommand(i);
2362
+ n = await this.commandHandler.executeCommand(s);
2156
2363
  } finally {
2157
2364
  this.overlayManager.hideLoading();
2158
2365
  }
2159
- this.processResponse(s);
2366
+ this.processResponse(n);
2160
2367
  }
2161
2368
  );
2162
2369
  return;
2163
2370
  }
2164
- if (n.type === "error") {
2165
- const i = typeof e == "string" ? e : "";
2166
- i ? (this.fallbackHandler.handleFallback(i), this.overlayManager.addMessage(this.fallbackHandler.getFallbackMessage(), "system")) : n.message && this.overlayManager.addMessage(n.message, "system");
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 ((n.type === "ambiguous" || n.type === "confirm") && n.options) {
2170
- n.message && this.overlayManager.addMessage(n.message, "system"), this.overlayManager.addOptions(n.options);
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
- n.message && this.overlayManager.addMessage(n.message, "system");
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 (n) => {
2394
+ async (t) => {
2188
2395
  this.overlayManager.showLoading();
2189
- let i;
2396
+ let s;
2190
2397
  try {
2191
- i = await this.commandHandler.executeCommand(n);
2398
+ s = await this.commandHandler.executeCommand(t);
2192
2399
  } finally {
2193
2400
  this.overlayManager.hideLoading();
2194
2401
  }
2195
- this.processResponse(i);
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, n) {
2208
- console.log(typeof e == "string" ? `AssistantService: Adding command "${e}".` : `AssistantService: Adding rich command "${e.command}".`), this.commandHandler.addCommand(e, n);
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, n) {
2439
+ toggle(e, t) {
2220
2440
  console.log("AssistantService: Toggling overlay..."), this.overlayManager.toggle(
2221
- async (i) => {
2222
- if (typeof i == "string")
2223
- this.overlayManager.addMessage(i, "user");
2224
- else if (i && typeof i == "object") {
2225
- const s = this.extractUserLabel(i);
2226
- s && this.overlayManager.addMessage(s, "user");
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(i), await this.handleCommand(i);
2448
+ e && e(s), await this.handleCommand(s);
2229
2449
  },
2230
2450
  () => {
2231
- console.log("AssistantService: Overlay closed."), n && n();
2451
+ console.log("AssistantService: Overlay closed."), t && t();
2232
2452
  }
2233
2453
  );
2234
2454
  }
2235
2455
  extractUserLabel(e) {
2236
- const n = e.label;
2237
- if (typeof n == "string" && n.trim()) return n.trim();
2238
- const i = e.commandId;
2239
- return typeof i == "string" && i.trim() ? i.trim() : null;
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 Bt = /* @__PURE__ */ mt({
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(t, { slots: e }) {
2251
- const n = new Ut(t.config);
2252
- return dt("assistantService", n), () => {
2253
- var i;
2254
- return (i = e.default) == null ? void 0 : i.call(e);
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
- }), Wt = (t, e) => {
2258
- const n = t.__vccOpts || t;
2259
- for (const [i, s] of e)
2260
- n[i] = s;
2261
- return n;
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 jt(t, e, n, i, s, o) {
2264
- return gt(t.$slots, "default");
2483
+ function Yt(i, e, t, s, n, o) {
2484
+ return yt(i.$slots, "default");
2265
2485
  }
2266
- const Kt = /* @__PURE__ */ Wt(Bt, [["render", jt]]), Yt = () => {
2267
- const t = ut("assistantService");
2268
- if (!t)
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 t;
2490
+ return i;
2271
2491
  };
2272
2492
  export {
2273
- Kt as AssistantProvider,
2493
+ Gt as AssistantProvider,
2274
2494
  Ut as AssistantService,
2275
- Yt as useAssistant
2495
+ Kt as useAssistant
2276
2496
  };