@inploi/plugin-chatbot 14.9.0 → 14.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/cdn/index.js +6 -6
  2. package/dist/chatbot-body-3e08ab1b.js +4073 -0
  3. package/dist/chatbot-body-d0635102.cjs +5 -0
  4. package/dist/chatbot.d.ts +6 -0
  5. package/dist/chatbot.idb.d.ts +2 -2
  6. package/dist/chatbot.resume.d.ts +15 -0
  7. package/dist/chatbot.resume.test.d.ts +1 -0
  8. package/dist/chatbot.state.d.ts +24 -406
  9. package/dist/chatbot.storage.test.d.ts +1 -0
  10. package/dist/chatbot.utils.d.ts +1 -255
  11. package/dist/components/chat-input/chat-input.address.d.ts +1 -14
  12. package/dist/components/chat-input/chat-input.boolean.d.ts +1 -13
  13. package/dist/components/chat-input/chat-input.d.ts +1 -12
  14. package/dist/components/chat-input/chat-input.file.d.ts +1 -12
  15. package/dist/components/chat-input/chat-input.multiple-choice.d.ts +1 -14
  16. package/dist/components/chat-input/chat-input.number.d.ts +1 -14
  17. package/dist/components/chat-input/chat-input.phone-number.d.ts +1 -17
  18. package/dist/components/chat-input/chat-input.submit.d.ts +1 -10
  19. package/dist/components/chat-input/chat-input.text.d.ts +1 -16
  20. package/dist/components/chatbot-body.lifecycle.test.d.ts +1 -0
  21. package/dist/components/message.link.d.ts +1 -1
  22. package/dist/components/useChatService.d.ts +1 -1
  23. package/dist/components/useChatService.test.d.ts +1 -0
  24. package/dist/i18n.d.ts +42 -0
  25. package/dist/{index-75330fed.js → index-5de8da64.js} +1047 -1001
  26. package/dist/index-d28fa66d.cjs +5 -0
  27. package/dist/plugin-chatbot.cjs +1 -1
  28. package/dist/plugin-chatbot.js +1 -1
  29. package/dist/style/tokens.d.ts +4 -4
  30. package/package.json +2 -2
  31. package/dist/chatbot-body-45ccac19.js +0 -4695
  32. package/dist/chatbot-body-b6a4eef8.cjs +0 -5
  33. package/dist/index-47f31542.cjs +0 -5
  34. package/dist/interpreter.d.ts +0 -67
@@ -0,0 +1,4073 @@
1
+ import { i as _r, c as ut, P as Ct, u as $e, l as kr, T as Cr, s as fn, N as hn, M as Sr, z as pn, X as Ir, W as mn, C as yn, o as gn, d as bn, h as vn, U as Wt, $ as xn, x as wn, g as zt, m as _n, f as Ar, w as kn, b as Cn, v as Sn, y as In, a as j, e as Q, j as u, k as qe, n as ct, p as ve, _ as de, q as Ne, r as Ae, t as we, L as Et, F as An, A as Er, B as Fr, D as En, E as Ue, G as Kt, H as te, I as se, J as Fn, K as Vn, O as Mn, Q as Ln, S as Vr, R as Nn } from "./index-5de8da64.js";
2
+ import { isApiErrorWithData as Rn, ApiError as Dn } from "@inploi/sdk";
3
+ var Tn = "9.7.0", Mr = `https://sdk.inploi.com/@inploi/flows@${Tn}/cdn/captcha/index.html`, On = new URL(Mr).origin, Gt = 3e4, $n = 5 * 6e4, Bn = (e) => typeof e == "object" && e !== null && e.source === "inploi-captcha", bt = /* @__PURE__ */ new WeakMap(), jn = (e) => {
4
+ let r = bt.get(e);
5
+ return r || (r = e.fetch("/flow/captcha").then((t) => {
6
+ let n = t == null ? void 0 : t.site_key;
7
+ return typeof n == "string" && n !== "" ? n : void 0;
8
+ }).catch((t) => {
9
+ throw bt.delete(e), t;
10
+ }), bt.set(e, r)), r;
11
+ }, Pn = (e, r = {}) => new Promise((t, n) => {
12
+ let { signal: s, container: i = null, theme: a, onInteractive: o } = r instanceof AbortSignal ? { signal: r } : r, c = !1, p = () => {
13
+ }, g = (S) => {
14
+ c || (c = !0, clearTimeout(m), s == null || s.removeEventListener("abort", h), p(), S());
15
+ }, b = (S) => g(() => n(new Error(S))), h = () => b("Captcha aborted"), m, w = (S) => {
16
+ clearTimeout(m), m = setTimeout(() => b("Captcha timed out"), S);
17
+ };
18
+ if (w(Gt), s == null ? void 0 : s.aborted)
19
+ return h();
20
+ s == null || s.addEventListener("abort", h), (async () => {
21
+ let S = await jn(e);
22
+ if (S === void 0)
23
+ return g(() => t(void 0));
24
+ if (c)
25
+ return;
26
+ let C = document.createElement("iframe");
27
+ C.src = `${Mr}?${new URLSearchParams({ sitekey: S, origin: window.location.origin, ...a && { theme: a } }).toString()}`, C.title = "Cloudflare security check", C.style.cssText = `display:block;border:0;width:${i ? "100%" : "300px"};height:0;color-scheme:normal`, i ? i.appendChild(C) : (C.style.cssText += ";position:fixed;bottom:16px;right:16px;z-index:2147483647", document.body.appendChild(C));
28
+ let _ = !1, y = (E) => {
29
+ if (!C.contentWindow || E.source !== C.contentWindow || E.origin !== On || !Bn(E.data))
30
+ return;
31
+ let A = E.data;
32
+ switch (A.type) {
33
+ case "token":
34
+ return g(() => t(A.token));
35
+ case "resize":
36
+ C.style.height = `${Math.max(0, Math.ceil(A.height))}px`;
37
+ return;
38
+ case "before-interactive":
39
+ return _ = !0, w($n), o == null ? void 0 : o();
40
+ case "after-interactive":
41
+ return _ = !1, w(Gt);
42
+ case "error":
43
+ !_ && !A.interactive && b("Captcha failed");
44
+ return;
45
+ case "expired":
46
+ return b("Captcha expired");
47
+ case "timeout":
48
+ return b("Captcha timed out");
49
+ }
50
+ };
51
+ window.addEventListener("message", y), p = () => {
52
+ window.removeEventListener("message", y), C.remove();
53
+ };
54
+ })().catch((S) => g(() => n(S)));
55
+ }), Ht = ({ condition: e, context: r, submissions: t, ifBlock: n }) => {
56
+ let [s, ...i] = e.compareKey.split(".");
57
+ if (!s)
58
+ return !1;
59
+ let a = _r({ context: r, key: s, path: i, submissions: t });
60
+ if (!a)
61
+ return !1;
62
+ switch (a.type) {
63
+ case "address": {
64
+ let o = Ct(a.value, i);
65
+ switch (e.compare) {
66
+ case "equals":
67
+ return o === e.compareValue;
68
+ case "contains":
69
+ return typeof o != "string" ? !1 : o.includes(e.compareValue);
70
+ case "notEquals":
71
+ return o !== e.compareValue;
72
+ case "notContains":
73
+ return typeof o != "string" ? !0 : !o.includes(e.compareValue);
74
+ }
75
+ break;
76
+ }
77
+ case "integration": {
78
+ if (typeof a.value != "object" || Array.isArray(a.value))
79
+ return !1;
80
+ let o = Ct(a.value, i), c = { ...n, data: { compareKey: "_temp", compare: e.compare, compareValue: e.compareValue } };
81
+ switch (typeof o) {
82
+ case "boolean":
83
+ return Ze(c, { submissions: { _temp: { value: o, type: "boolean" } }, context: r });
84
+ case "string":
85
+ return Ze(c, { submissions: { _temp: { value: o, type: "string" } }, context: r });
86
+ case "number":
87
+ return Ze(c, { submissions: { _temp: { value: o, type: "number" } }, context: r });
88
+ case "object":
89
+ return Array.isArray(o) && o.every((p) => typeof p == "string") ? Ze(c, { submissions: { _temp: { value: o, type: "enum" } }, context: r }) : !1;
90
+ }
91
+ break;
92
+ }
93
+ case "boolean": {
94
+ let o = e.compareValue === "true";
95
+ switch (e.compare) {
96
+ case "equals":
97
+ return a.value === o;
98
+ case "notEquals":
99
+ return a.value !== o;
100
+ }
101
+ break;
102
+ }
103
+ case "phone":
104
+ case "string": {
105
+ let o = a.type === "phone" ? ut(a.value) : a.value;
106
+ switch (e.compare) {
107
+ case "equals":
108
+ return o === e.compareValue;
109
+ case "contains":
110
+ return o ? o.includes(e.compareValue) : !1;
111
+ case "notEquals":
112
+ return o !== e.compareValue;
113
+ case "notContains":
114
+ return o ? !o.includes(e.compareValue) : !0;
115
+ }
116
+ break;
117
+ }
118
+ case "number": {
119
+ try {
120
+ let o = Number(e.compareValue);
121
+ switch (e.compare) {
122
+ case "equals":
123
+ return a.value === o;
124
+ case "notEquals":
125
+ return a.value !== o;
126
+ case "greaterThan":
127
+ return a.value > o;
128
+ case "greaterThanOrEqualTo":
129
+ return a.value >= o;
130
+ case "lessThan":
131
+ return a.value < o;
132
+ case "lessThanOrEqualTo":
133
+ return a.value <= o;
134
+ }
135
+ } catch {
136
+ return console.error(`Failed to parse number in if-block ${n.id}`, a.value), !1;
137
+ }
138
+ break;
139
+ }
140
+ case "enum":
141
+ switch (e.compare) {
142
+ case "equals":
143
+ return a.value.length === 1 && a.value[0] === e.compareValue;
144
+ case "notEquals":
145
+ return a.value.length === 1 && a.value[0] !== e.compareValue;
146
+ case "contains":
147
+ return a.value.includes(e.compareValue);
148
+ case "notContains":
149
+ return !a.value.includes(e.compareValue);
150
+ }
151
+ break;
152
+ }
153
+ }, Ze = (e, { context: r, submissions: t }) => {
154
+ let n = "combinator" in e.data ? e.data.conditions : [e.data];
155
+ if (("combinator" in e.data ? e.data.combinator : "and") === "or") {
156
+ for (let s of n)
157
+ if (Ht({ condition: s, context: r, submissions: t, ifBlock: e }))
158
+ return !0;
159
+ return !1;
160
+ } else {
161
+ for (let s of n)
162
+ if (!Ht({ condition: s, context: r, submissions: t, ifBlock: e }))
163
+ return !1;
164
+ return !0;
165
+ }
166
+ }, qn = /{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g, Un = (e, { context: r, submissions: t }) => e.replace(qn, (n, s, i = "") => {
167
+ let [a, ...o] = s.trim().split("."), c = _r({ key: a, path: o, submissions: t, context: r });
168
+ if (!c)
169
+ return i;
170
+ switch (c.type) {
171
+ case "boolean":
172
+ return c.value === !0 ? "true" : "false";
173
+ case "file":
174
+ return c.value.map((p) => `${p.name} (${$e(p.sizeKb)})`).join(", ");
175
+ case "enum":
176
+ return c.value.join(", ");
177
+ case "address":
178
+ return Object.values(c.value).filter((p) => p && p.trim().length > 0).join(", ");
179
+ case "number":
180
+ case "string":
181
+ return c.value ? c.value.toString() : i;
182
+ case "phone":
183
+ return ut(c.value);
184
+ case "integration": {
185
+ if (typeof c.value != "object" || Array.isArray(c.value))
186
+ break;
187
+ let p = Ct(c.value, o);
188
+ switch (typeof p) {
189
+ case "boolean":
190
+ return p === !0 ? "true" : "false";
191
+ case "string":
192
+ return p;
193
+ case "number":
194
+ return p.toString();
195
+ case "object":
196
+ if (Array.isArray(p) && p.every((g) => typeof g == "string"))
197
+ return p.join(", ");
198
+ }
199
+ break;
200
+ }
201
+ }
202
+ return i;
203
+ }), Lr = (e) => {
204
+ let r = e.find((t) => t.isHead);
205
+ if (!r)
206
+ throw new Error("No head node found");
207
+ return r;
208
+ }, Ft = (e) => {
209
+ var r, t;
210
+ if (!(e.data.isFinished || (r = e.data.startedWriteNodeIds) != null && r.length))
211
+ return (t = [...e.data.messages].reverse().find((n) => n.groupId && e.nodes.some((s) => s.id === n.groupId && s.type.startsWith("question-")) && (n.type === "system" || "author" in n && n.author === "user"))) == null ? void 0 : t.groupId;
212
+ }, Nr = ({ context: e, submissions: r }) => ({ context: e, submissions: r ?? {} }), fe = (e, r) => Un(e, Nr(r)), Wn = (e, r) => Ze(e, Nr(r)), Rr = ({ node: e, nodes: r, stopWhen: t }) => {
213
+ if ((t == null ? void 0 : t(e)) === !0)
214
+ return e;
215
+ let n = e.nextId ? r.find((s) => s.id === e.nextId) : void 0;
216
+ if (n)
217
+ return Rr({ node: n, nodes: r, stopWhen: t });
218
+ }, zn = ({ childNode: e, nodes: r }) => {
219
+ let t = r.filter((n) => n.type === "if-block").find((n) => {
220
+ if (!n.branchId)
221
+ return !1;
222
+ let s = r.find((a) => a.id === n.branchId);
223
+ if (!s)
224
+ return !1;
225
+ let i = Rr({ node: s, nodes: r, stopWhen: (a) => a.id === e.id });
226
+ return !(!i || i.id !== e.id);
227
+ });
228
+ if (t != null && t.nextId)
229
+ return r.find((n) => n.id === t.nextId);
230
+ }, Kn = 3, Gn = ({ flow: e, analytics: r, logger: t, talentBankClient: n, context: s, apiClient: i, getSubmissions: a, getApplicationRecovery: o, setApplicationRecovery: c, chatService: p, persistWriteBarrier: g, onFlowEnd: b, onInterpret: h, t: m }) => {
231
+ var w;
232
+ let S = new AbortController();
233
+ (w = e.data).startedWriteNodeIds ?? (w.startedWriteNodeIds = e.nodes.flatMap((y) => {
234
+ var A, V;
235
+ if (y.type !== "integration-application-submit" || !e.data.nodeHistory.includes(y.id))
236
+ return [];
237
+ let E = y.data.key ? (A = a()) == null ? void 0 : A[y.data.key] : void 0;
238
+ return (E == null ? void 0 : E.type) === "integration" && ((V = kr(E.value)) == null ? void 0 : V.verdict) === "not_submitted" ? [] : [y.id];
239
+ }));
240
+ let C = { ...r.service, log: (y) => r.service.log({ ...y, customProperties: { ...y.customProperties, ...r.customProperties } }) }, _ = async (y, E) => {
241
+ let A = S.signal;
242
+ if (A.aborted)
243
+ return;
244
+ let V = a(), L = o(), U = (L == null ? void 0 : L.submitNodeId) === y.id ? e.nodes.find((T) => {
245
+ var q;
246
+ return T.id === L.fileQuestionNodeId && T.type === "question-file" && ((q = V == null ? void 0 : V[T.data.key]) == null ? void 0 : q.type) !== "file";
247
+ }) : void 0;
248
+ if (U)
249
+ return _(U, E);
250
+ h == null || h(y, E);
251
+ try {
252
+ await Hn({ flow: e, analytics: C, logger: t, talentBankClient: n, apiClient: i, context: s, node: y, submissions: V, applicationRecovery: L, setApplicationRecovery: async (T) => {
253
+ if (!A.aborted)
254
+ try {
255
+ await c(T);
256
+ } catch (q) {
257
+ t.error("Failed to persist application recovery", q);
258
+ }
259
+ }, forceSubmitConfirmation: (L == null ? void 0 : L.submitNodeId) === y.id, persistWriteBarrier: g, signal: A, t: m, chat: { sendMessage: async (T) => p.send({ groupId: y.id, message: T, signal: A }), userInput: async (T) => p.input({ input: T, signal: A }), setSubmission: (T, q) => {
260
+ A.aborted || p.setSubmission(T, q);
261
+ }, captcha: p.captcha }, next: (T) => {
262
+ if (A.aborted)
263
+ return;
264
+ let q = (L == null ? void 0 : L.fileQuestionNodeId) === y.id ? L.submitNodeId : T, O = q ? e.nodes.find((J) => J.id === q) : zn({ childNode: y, nodes: e.nodes });
265
+ return O ? _(O, y) : b == null ? void 0 : b(y);
266
+ }, end: () => {
267
+ A.aborted || (b == null || b(y));
268
+ } });
269
+ } catch (T) {
270
+ if (T instanceof Cr)
271
+ return;
272
+ throw T;
273
+ }
274
+ };
275
+ return { interpret: async (y) => {
276
+ let E = e.nodes.find((A) => A.id === y) ?? Lr(e.nodes);
277
+ return _(E);
278
+ }, undo: (y) => {
279
+ var q;
280
+ if ((q = e.data.startedWriteNodeIds) != null && q.length || e.data.isFinished)
281
+ return { removed: 0 };
282
+ let E = Ft(e), A = E ? y.lastIndexOf(E) : -1, V = e.nodes.find((O) => O.id === E);
283
+ if (A === -1 || !V)
284
+ return { removed: 0 };
285
+ let L = e.nodes.find((O) => O.id === y[y.length - 1]);
286
+ S.abort();
287
+ let U = y.splice(A);
288
+ e.data.messages = e.data.messages.filter((O) => !O.groupId || !U.includes(O.groupId)), e.data.currentInput = null;
289
+ let T = a();
290
+ for (let O of U.slice(1)) {
291
+ let J = e.nodes.find((N) => N.id === O);
292
+ if (!(!J || !T || J.id === E) && ("key" in J.data && J.data.key && delete T[J.data.key], "keys" in J.data))
293
+ for (let N of Object.values(J.data.keys))
294
+ typeof N == "string" && delete T[N];
295
+ }
296
+ return S = new AbortController(), _(V, L), { removed: U.length };
297
+ }, abort: () => {
298
+ S.abort();
299
+ } };
300
+ };
301
+ async function Hn(e) {
302
+ let r = e.node;
303
+ switch (r.type) {
304
+ case "flow-section":
305
+ return await e.chat.sendMessage({ type: "system", variant: "info", text: r.data.title }), e.next(r.nextId);
306
+ case "pre-apply-result":
307
+ return ps({ ...e, node: r });
308
+ case "text":
309
+ return ss({ ...e, node: r });
310
+ case "image":
311
+ return as({ ...e, node: r });
312
+ case "question-text":
313
+ return is({ ...e, node: r });
314
+ case "question-enum":
315
+ return us({ ...e, node: r });
316
+ case "question-number":
317
+ return os({ ...e, node: r });
318
+ case "question-phone":
319
+ return ls({ ...e, node: r });
320
+ case "question-boolean":
321
+ return cs({ ...e, node: r });
322
+ case "question-file":
323
+ return fs({ ...e, node: r });
324
+ case "question-address":
325
+ return ds({ ...e, node: r });
326
+ case "end-flow":
327
+ return hs({ ...e, node: r });
328
+ case "if-block":
329
+ return ns({ ...e, node: r });
330
+ case "jump":
331
+ return Zn({ ...e, node: r });
332
+ case "link":
333
+ return rs({ ...e, node: r });
334
+ case "integration-application-submit":
335
+ return ts({ ...e, node: r });
336
+ case "add-submission":
337
+ return Yn({ ...e, node: r });
338
+ case "integration-workflow-get":
339
+ throw Error("Workflow should be unreachable");
340
+ case "check-duplicate":
341
+ return Xn({ ...e, node: r });
342
+ case "feedback":
343
+ return Jn({ ...e, node: r });
344
+ default:
345
+ throw new Error(`Unknown node: ${JSON.stringify(r)}`);
346
+ }
347
+ }
348
+ async function Jn({ next: e, node: r }) {
349
+ e(r.nextId);
350
+ }
351
+ async function Xn({ next: e, node: r, talentBankClient: t, submissions: n, flow: s, logger: i, chat: a }) {
352
+ var c;
353
+ let o = { isDuplicate: !1 };
354
+ if (n && t) {
355
+ let p = r.data.scope === "job" ? (c = s.job) == null ? void 0 : c.id : void 0;
356
+ if (r.data.scope === "company" || p != null)
357
+ try {
358
+ o = await t.checkDuplicate({ email: fn({ key: r.data.email, submissions: n }).toString(), jobId: p, scope: r.data.scope });
359
+ } catch (g) {
360
+ i.error("[check-duplicate]", g);
361
+ }
362
+ }
363
+ a.setSubmission(r.data.key, { type: "integration", value: o }), e(r.nextId);
364
+ }
365
+ async function Zn({ next: e, node: r }) {
366
+ e(r.data.targetId);
367
+ }
368
+ async function Yn({ next: e, node: r, logger: t, submissions: n, context: s }) {
369
+ if (!n) {
370
+ t.error("Submissions not found");
371
+ return;
372
+ }
373
+ n[r.data.key] = { type: "string", value: fe(r.data.value, { submissions: n, context: s }) }, e(r.nextId);
374
+ }
375
+ var Qn = 5e3, es = (e, r, t) => {
376
+ let { waitMs: n, throttles: s, maintenance: i } = In(r == null ? void 0 : r.throttles, t);
377
+ return { key: e, until: Date.now() + n, ...s !== void 0 && { throttles: s }, ...i && { maintenance: i } };
378
+ };
379
+ async function ts({ chat: e, next: r, end: t, node: n, logger: s, apiClient: i, submissions: a, analytics: o, flow: c, applicationRecovery: p, setApplicationRecovery: g, forceSubmitConfirmation: b, persistWriteBarrier: h, signal: m, t: w }) {
380
+ var y;
381
+ if ((y = c.data.startedWriteNodeIds) != null && y.includes(n.id) && (p == null ? void 0 : p.submitNodeId) !== n.id)
382
+ return await e.sendMessage({ type: "system", variant: "warning", text: w("submission_unknown") }), t();
383
+ let S = c.job ? `${n.id}@${c.job.id_type}:${c.job.id}` : n.id, C = 0, _ = async (E) => {
384
+ var nt, ze, st, Ke, at, De, Ge;
385
+ let A = ((nt = c.data.submitCooldown) == null ? void 0 : nt.key) === S ? c.data.submitCooldown : void 0;
386
+ A && (A.until = Math.min(A.until, Date.now() + (A.maintenance ? pn : A.throttles ? Ir : mn)));
387
+ let V = A == null ? void 0 : A.until;
388
+ (E !== !0 || V !== void 0 && V > Date.now()) && await e.userInput({ type: "submit", key: void 0, config: { label: n.data.submitLabel, ...V !== void 0 && { availableAt: V } } });
389
+ let L;
390
+ if (n.data.captcha) {
391
+ let D = e.captcha, ke = !0;
392
+ try {
393
+ L = await Pn(i, { signal: m, container: (D == null ? void 0 : D.container()) ?? null, theme: D == null ? void 0 : D.theme, onInteractive: () => {
394
+ e.sendMessage({ type: "text", author: "bot", text: w("captcha_check") }).catch(() => {
395
+ }).then(() => {
396
+ ke && (D == null || D.reveal(!0));
397
+ });
398
+ } });
399
+ } catch (He) {
400
+ if (s.error("Captcha check failed", He), m.aborted)
401
+ return;
402
+ } finally {
403
+ ke = !1, D == null || D.reveal(!1);
404
+ }
405
+ }
406
+ await e.sendMessage({ type: "loading", text: w("submitting") });
407
+ let { anonymous_id: U, session_id: T } = o.getSessionInfo();
408
+ if (m.aborted)
409
+ return;
410
+ let q = ((ze = c.data.startedWriteNodeIds) == null ? void 0 : ze.includes(n.id)) === !0;
411
+ if ((p == null ? void 0 : p.submitNodeId) === n.id && await g(void 0), q || (c.data.startedWriteNodeIds = [...c.data.startedWriteNodeIds ?? [], n.id]), await h().catch((D) => s.error("Failed to persist application write barrier", D)), m.aborted)
412
+ return;
413
+ let O, J = setTimeout(() => {
414
+ O = (async () => {
415
+ await e.sendMessage({ type: "text", author: "bot", text: w("submission_still_working") }), await e.sendMessage({ type: "loading", text: w("submitting") });
416
+ })().catch((D) => s.error("Failed to send submission progress message", D));
417
+ }, Qn), N, R = await i.fetch("/flow/submit", { method: "POST", body: JSON.stringify({ log_submit: !1, integration_id: n.data.integrationId, anonymous_id: U, session_id: T, job: c.job, flow_build: c.build, ...L !== void 0 && { captcha_token: L }, submissions: yn(c.nodes, gn(a || {}, n.data.submitKeys)), pre_apply: Sr(c.nodes, a || {}, c.data.flowSessionId) }) }).catch((D) => (N = D, Rn(D) ? D.data : D));
418
+ if (clearTimeout(J), await O, m.aborted)
419
+ return;
420
+ n.data.key && e.setSubmission(n.data.key, { type: "integration", value: R });
421
+ let M = kr(R, N instanceof Dn ? N.status : void 0), z = c.data.failedAttemptAt, X = z == null ? void 0 : z[S];
422
+ z && X !== void 0 && X > Date.now() && (X = z[S] = Date.now());
423
+ let Z = X !== void 0 && Date.now() - X < bn || ((st = c.data.unconfirmedAttemptKeys) == null ? void 0 : st.includes(S)) === !0, oe = vn(R);
424
+ if (oe && o.log({ event: "FLOW_SUBMIT", properties: { flow_id: c.id, flow_version: c.version, flow_session_id: c.data.flowSessionId, flow_build: c.build, service: oe.service, response: oe.response, flow_type: "CHATBOT_DRAWER", job: c.job, ...(M == null ? void 0 : M.outcome) === "duplicate" && { outcome: Z ? "duplicate_after_own_attempt" : "duplicate" }, ...oe.outcome && { outcome: oe.outcome } } }), (Wt(R) || (R == null ? void 0 : R.success) === !0) && ((Ke = c.data.submitCooldown) == null ? void 0 : Ke.throttles) !== void 0 && (delete c.data.submitCooldown.throttles, await h().catch((D) => s.error("Failed to persist submit cooldown reset", D))), Wt(R)) {
425
+ let { redirect_url: D, message: ke, button_text: He } = R.integration_response.data;
426
+ await e.sendMessage({ type: "text", author: "bot", text: ke ?? w("submission_redirect_message") });
427
+ try {
428
+ let me = new URL(D);
429
+ U && !me.searchParams.has("anonymous_id") && me.searchParams.set("anonymous_id", U), await e.sendMessage({ type: "link", href: me.toString(), text: He ?? w("complete_submission"), onClick: () => {
430
+ if (!T) {
431
+ s.error("session_id not set, cannot log FLOW_REDIRECT event");
432
+ return;
433
+ }
434
+ o.log({ event: "FLOW_REDIRECT", properties: { flow_build: c.build, flow_id: c.id, flow_session_id: T, flow_version: c.version, href: me.toString(), job: c.job } });
435
+ } });
436
+ } catch (me) {
437
+ s.error(`Invalid redirect URL: ${D}`, me), e.sendMessage({ type: "system", variant: "error", text: w("redirect_url_error") });
438
+ }
439
+ return r(n.nextId);
440
+ }
441
+ let _e = xn(R);
442
+ if (_e)
443
+ return await e.sendMessage({ type: "system", variant: "success", text: _e.message ?? w("submission_pending") }), r(n.nextId);
444
+ if ((R == null ? void 0 : R.success) === !0)
445
+ return n.data.skipConfirmation !== !0 && await e.sendMessage({ type: "system", variant: "success", text: w("submission_completed") }), r(n.nextId);
446
+ let pe = wn(M), Fe = pe !== void 0 && ((at = a == null ? void 0 : a[pe]) == null ? void 0 : at.type) === "file" ? pe : void 0, Ve = Fe === void 0 ? void 0 : c.nodes.find((D) => D.type === "question-file" && D.data.key === Fe);
447
+ if (!Ve && !zt(M) && (c.data.submitCooldown = es(S, A, M)), (M == null ? void 0 : M.outcome) !== "duplicate" && (c.data.failedAttemptAt = { ...c.data.failedAttemptAt, [S]: Date.now() }, (De = c.data.unconfirmedAttemptKeys) != null && De.includes(S) && (c.data.unconfirmedAttemptKeys = c.data.unconfirmedAttemptKeys.filter((D) => D !== S))), (M == null ? void 0 : M.verdict) === "not_submitted" || (M == null ? void 0 : M.outcome) === "duplicate" || (M == null ? void 0 : M.outcome) === "closed" ? (q || (c.data.startedWriteNodeIds = (Ge = c.data.startedWriteNodeIds) == null ? void 0 : Ge.filter((D) => D !== n.id)), (p == null ? void 0 : p.submitNodeId) === n.id && await g(p), await h().catch((D) => s.error("Failed to persist application write barrier release", D))) : await h().catch((D) => s.error("Failed to persist submit cooldown", D)), M) {
448
+ if (s.error(N ?? M.message), Ve && Fe !== void 0)
449
+ return e.setSubmission(Fe, null), await g({ fileQuestionNodeId: Ve.id, submitNodeId: n.id }), await e.sendMessage({ type: "system", variant: "error", text: w("submission_unreadable_document") }), r(Ve.id);
450
+ if (M.outcome === "duplicate")
451
+ return await e.sendMessage({ type: "system", variant: "info", text: w(Z ? "submission_duplicate_earlier_attempt" : "submission_duplicate") }), _(!1);
452
+ if (M.outcome === "closed")
453
+ return await e.sendMessage({ type: "system", variant: "info", text: w("submission_closed") }), _(!1);
454
+ let D = _n(M);
455
+ return D ? (await e.sendMessage({ type: "system", variant: "warning", text: D.until === void 0 ? w("submission_provider_maintenance_later") : w("submission_provider_maintenance", { time: Ar(D.until, void 0) }) }), _(!1)) : M.outcome === "unknown" ? (await e.sendMessage({ type: "system", variant: "warning", text: w(kn(M) ? "submission_unknown_do_not_resubmit" : "submission_unknown") }), _(!1)) : zt(M) ? Cn(R) ? (await e.sendMessage({ type: "text", author: "bot", text: M.message }), _(!1)) : (C === 0 && await e.sendMessage({ type: "system", variant: "warning", text: w("captcha_failed") }), C++, _(C <= Kn)) : Sn(M) ? (await e.sendMessage({ type: "system", variant: "error", text: w("submission_retryable") }), _(!1)) : (await e.sendMessage({ type: "system", variant: "error", text: w("submission_failed") }), t());
456
+ }
457
+ return s.error(N ?? R), await e.sendMessage({ type: "system", variant: "error", text: w("submission_failed") }), t();
458
+ };
459
+ await _(b === !0 ? !1 : n.data.skipConfirmation);
460
+ }
461
+ async function rs({ chat: e, next: r, node: t, submissions: n, context: s }) {
462
+ await e.sendMessage({ type: "link", href: fe(t.data.href, { submissions: n, context: s }), text: fe(t.data.cta, { submissions: n, context: s }) }), r(t.nextId);
463
+ }
464
+ async function ns({ submissions: e, next: r, node: t, context: n }) {
465
+ r(Wn(t, { submissions: e, context: n }) ? t.branchId : t.nextId);
466
+ }
467
+ async function ss({ chat: e, next: r, node: t, submissions: n, context: s }) {
468
+ await e.sendMessage({ author: "bot", type: "text", text: fe(t.data.text, { submissions: n, context: s }) }), r(t.nextId);
469
+ }
470
+ async function as({ chat: e, next: r, node: t }) {
471
+ await e.sendMessage({ author: "bot", type: "image", url: t.data.url, height: t.data.height, width: t.data.width }), r(t.nextId);
472
+ }
473
+ async function is({ chat: e, next: r, node: t, submissions: n, context: s, t: i }) {
474
+ await e.sendMessage({ author: "bot", type: "text", text: fe(t.data.question, { submissions: n, context: s }) });
475
+ let a = t.data.format === "phone" ? await e.userInput({ key: t.data.key, type: "phone", config: { optional: t.data.optional, placeholder: t.data.placeholder, minChars: t.data.minChars, maxChars: t.data.maxChars, submissionFormat: "text", defaultValue: {} } }) : await e.userInput({ key: t.data.key, type: "text", config: { optional: t.data.optional, placeholder: t.data.placeholder, format: t.data.format, maxChars: t.data.maxChars, minChars: t.data.minChars, multiline: t.data.format === "text" && t.data.multiline === !0 } });
476
+ a === null ? await e.sendMessage({ type: "system", variant: "info", text: i("skipped") }) : await e.sendMessage({ author: "user", type: "text", text: a.type === "phone" ? ut(a.value) : a.value }), r(t.nextId);
477
+ }
478
+ async function os({ chat: e, next: r, node: t, submissions: n, context: s, t: i }) {
479
+ await e.sendMessage({ author: "bot", type: "text", text: fe(t.data.question, { submissions: n, context: s }) });
480
+ let a = await e.userInput({ key: t.data.key, type: "number", config: { max: t.data.max, min: t.data.min, optional: t.data.optional, placeholder: t.data.placeholder, decimalCases: t.data.decimalCases } });
481
+ a === null ? await e.sendMessage({ type: "system", variant: "info", text: i("skipped") }) : await e.sendMessage({ author: "user", type: "text", text: a.value.toString() }), r(t.nextId);
482
+ }
483
+ async function ls({ chat: e, next: r, node: t, submissions: n, context: s, t: i }) {
484
+ await e.sendMessage({ author: "bot", type: "text", text: fe(t.data.question, { submissions: n, context: s }) });
485
+ let a = await e.userInput({ key: t.data.key, type: "phone", config: { minChars: t.data.minChars, defaultValue: { countryCode: t.data.defaultCountryCode }, placeholder: t.data.placeholder, submissionFormat: "phone", optional: t.data.optional } });
486
+ a === null ? await e.sendMessage({ type: "system", variant: "info", text: i("skipped") }) : await e.sendMessage({ author: "user", type: "text", text: a.type === "phone" ? ut(a.value) : a.value }), r(t.nextId);
487
+ }
488
+ async function us({ chat: e, next: r, node: t, submissions: n, context: s, t: i }) {
489
+ await e.sendMessage({ author: "bot", type: "text", text: fe(t.data.question, { submissions: n, context: s }) });
490
+ let a = await e.userInput({ key: t.data.key, type: "multiple-choice", config: t.data });
491
+ a.value.length === 0 ? await e.sendMessage({ type: "system", variant: "info", text: i("skipped") }) : await e.sendMessage({ author: "user", type: "text", text: t.data.options.filter((o) => a.value.includes(o.value)).map((o) => o.label).join(", ") }), r(t.nextId);
492
+ }
493
+ async function cs({ chat: e, next: r, node: t, submissions: n, context: s, t: i }) {
494
+ await e.sendMessage({ author: "bot", type: "text", text: fe(t.data.question, { submissions: n, context: s }) });
495
+ let a = await e.userInput({ key: t.data.key, type: "boolean", config: { optional: t.data.optional, labels: { true: t.data.trueLabel, false: t.data.falseLabel } } });
496
+ a === null ? await e.sendMessage({ type: "system", variant: "info", text: i("skipped") }) : await e.sendMessage({ author: "user", type: "text", text: a.value === !0 ? t.data.trueLabel : t.data.falseLabel }), r(t.nextId);
497
+ }
498
+ async function ds({ chat: e, next: r, node: t, t: n }) {
499
+ await e.sendMessage({ author: "bot", type: "text", text: t.data.question });
500
+ let s = await e.userInput({ type: "address", key: t.data.key, config: { optional: t.data.optional, keys: t.data.keys, line2Required: t.data.line2Required, placeholder: t.data.placeholder } });
501
+ if (s === null)
502
+ await e.sendMessage({ type: "system", variant: "info", text: n("skipped") });
503
+ else {
504
+ let i = Object.values(s.value).filter((a) => a && a.trim().length > 0).join(", ");
505
+ await e.sendMessage({ author: "user", type: "text", text: i });
506
+ }
507
+ return r(t.nextId);
508
+ }
509
+ async function fs({ node: e, chat: r, next: t, submissions: n, context: s, t: i }) {
510
+ await r.sendMessage({ author: "bot", type: "text", text: fe(e.data.question, { submissions: n, context: s }) });
511
+ let a = await r.userInput({ key: e.data.key, type: "file", config: { optional: e.data.optional, extensions: e.data.extensions, fileSizeLimitKib: e.data.maxSizeKb ?? 10 * 1024, allowMultiple: e.data.multiple === !0 } });
512
+ if (a === null)
513
+ await r.sendMessage({ type: "system", variant: "info", text: i("skipped") });
514
+ else
515
+ for (let o of a.value)
516
+ await r.sendMessage({ author: "user", type: "file", fileName: o.name, fileSizeKb: o.sizeKb });
517
+ return t(e.nextId);
518
+ }
519
+ async function hs({ chat: e, end: r, node: t }) {
520
+ await e.sendMessage({ type: "system", variant: "info", text: t.data.systemMessage }), r();
521
+ }
522
+ async function ps({ node: e, flow: r, submissions: t, chat: n, next: s, apiClient: i, analytics: a }) {
523
+ let o = hn(r.nodes, t || {}), { answers: c, ...p } = o;
524
+ n.setSubmission(e.data.key, { type: "integration", value: p });
525
+ let g = new AbortController(), b = setTimeout(() => g.abort(), 5e3);
526
+ if (i.fetch("/flow/pre-apply", { method: "POST", signal: g.signal, body: JSON.stringify({ ...a.getSessionInfo(), job: r.job, flow_build: r.build, pre_apply: Sr(r.nodes, t || {}, r.data.flowSessionId) }) }).catch(() => {
527
+ }).finally(() => clearTimeout(b)), o.status !== "skipped") {
528
+ let h = [o.status === "unavailable" ? "We could not prepare your pre-apply summary. You can still continue to your application." : o.hasHardConcerns ? e.data.messages.hard : o.hasAdvisoryConcerns ? e.data.messages.advisory : e.data.messages.matched];
529
+ for (let m of ["hard", "advisory"]) {
530
+ let w = c.filter((S) => !S.matched && S.severity === m);
531
+ w.length && h.push((m === "hard" ? "Role requirements" : "Other things to consider") + `
532
+ ` + w.map((S) => `• ${S.message}`).join(`
533
+ `));
534
+ }
535
+ await n.sendMessage({ type: "text", author: "bot", text: h.join(`
536
+
537
+ `) }), o.hasHardConcerns && e.data.alternativeLink && await n.sendMessage({ type: "link", href: e.data.alternativeLink.href, text: e.data.alternativeLink.label }), await n.userInput({ type: "submit", key: void 0, config: { label: e.data.continueLabel } });
538
+ }
539
+ return s(e.nextId);
540
+ }
541
+ const Jt = (e, r, t) => {
542
+ var n;
543
+ return e.log({
544
+ event: t,
545
+ properties: {
546
+ flow_id: r.id,
547
+ flow_version: r.version,
548
+ flow_session_id: r.data.flowSessionId,
549
+ flow_build: r.build,
550
+ flow_type: "CHATBOT_DRAWER",
551
+ job: r.job
552
+ },
553
+ customProperties: (n = r.analytics) == null ? void 0 : n.customProperties
554
+ });
555
+ }, St = "resume-prompt", ms = async ({
556
+ chatService: e,
557
+ t: r,
558
+ signal: t
559
+ }) => {
560
+ await e.send({
561
+ message: {
562
+ type: "text",
563
+ author: "bot",
564
+ text: r("resume_prompt")
565
+ },
566
+ groupId: St,
567
+ signal: t
568
+ });
569
+ const n = await e.input({
570
+ input: {
571
+ type: "boolean",
572
+ key: void 0,
573
+ config: {
574
+ labels: {
575
+ true: r("resume_continue"),
576
+ false: r("resume_start_again")
577
+ },
578
+ optional: !1
579
+ }
580
+ },
581
+ signal: t
582
+ });
583
+ return j.removeMessagesSentByNodeIds([St]), (n == null ? void 0 : n.value) !== !1;
584
+ }, Re = ({
585
+ class: e,
586
+ ...r
587
+ }) => {
588
+ const {
589
+ t
590
+ } = Q();
591
+ return u("button", {
592
+ class: qe("bg-accent-9 active:bg-accent-10 pointer-coarse:touch-hitbox fr flex-shrink-0 rounded-full p-2 text-white transition-all disabled:cursor-not-allowed disabled:opacity-50", e),
593
+ type: "submit",
594
+ ...r,
595
+ children: u("svg", {
596
+ class: "block",
597
+ width: "16",
598
+ height: "16",
599
+ viewBox: "0 0 16 16",
600
+ fill: "transparent",
601
+ stroke: "currentColor",
602
+ "stroke-linecap": "round",
603
+ "stroke-width": "2",
604
+ children: [u("title", {
605
+ children: t("send")
606
+ }), u("path", {
607
+ d: "M3.5 7.5L8 3L12.5 7.5"
608
+ }), u("path", {
609
+ d: "M8 4V13"
610
+ })]
611
+ })
612
+ });
613
+ };
614
+ var ye;
615
+ // @__NO_SIDE_EFFECTS__
616
+ function dt(e) {
617
+ return {
618
+ lang: (e == null ? void 0 : e.lang) ?? (ye == null ? void 0 : ye.lang),
619
+ message: e == null ? void 0 : e.message,
620
+ abortEarly: (e == null ? void 0 : e.abortEarly) ?? (ye == null ? void 0 : ye.abortEarly),
621
+ abortPipeEarly: (e == null ? void 0 : e.abortPipeEarly) ?? (ye == null ? void 0 : ye.abortPipeEarly)
622
+ };
623
+ }
624
+ var vt;
625
+ // @__NO_SIDE_EFFECTS__
626
+ function ys(e) {
627
+ return vt == null ? void 0 : vt.get(e);
628
+ }
629
+ var xt;
630
+ // @__NO_SIDE_EFFECTS__
631
+ function gs(e) {
632
+ return xt == null ? void 0 : xt.get(e);
633
+ }
634
+ var wt;
635
+ // @__NO_SIDE_EFFECTS__
636
+ function bs(e, r) {
637
+ var t;
638
+ return (t = wt == null ? void 0 : wt.get(e)) == null ? void 0 : t.get(r);
639
+ }
640
+ // @__NO_SIDE_EFFECTS__
641
+ function je(e) {
642
+ var t, n;
643
+ const r = typeof e;
644
+ return r === "string" ? `"${e}"` : r === "number" || r === "bigint" || r === "boolean" ? `${e}` : r === "object" || r === "function" ? (e && ((n = (t = Object.getPrototypeOf(e)) == null ? void 0 : t.constructor) == null ? void 0 : n.name)) ?? "null" : r;
645
+ }
646
+ function Y(e, r, t, n, s) {
647
+ const i = s && "input" in s ? s.input : t.value, a = (s == null ? void 0 : s.expected) ?? e.expects ?? null, o = (s == null ? void 0 : s.received) ?? /* @__PURE__ */ je(i), c = {
648
+ kind: e.kind,
649
+ type: e.type,
650
+ input: i,
651
+ expected: a,
652
+ received: o,
653
+ message: `Invalid ${r}: ${a ? `Expected ${a} but r` : "R"}eceived ${o}`,
654
+ requirement: e.requirement,
655
+ path: s == null ? void 0 : s.path,
656
+ issues: s == null ? void 0 : s.issues,
657
+ lang: n.lang,
658
+ abortEarly: n.abortEarly,
659
+ abortPipeEarly: n.abortPipeEarly
660
+ }, p = e.kind === "schema", g = (s == null ? void 0 : s.message) ?? e.message ?? /* @__PURE__ */ bs(e.reference, c.lang) ?? (p ? /* @__PURE__ */ gs(c.lang) : null) ?? n.message ?? /* @__PURE__ */ ys(c.lang);
661
+ g !== void 0 && (c.message = typeof g == "function" ? (
662
+ // @ts-expect-error
663
+ g(c)
664
+ ) : g), p && (t.typed = !1), t.issues ? t.issues.push(c) : t.issues = [c];
665
+ }
666
+ // @__NO_SIDE_EFFECTS__
667
+ function he(e) {
668
+ return {
669
+ version: 1,
670
+ vendor: "valibot",
671
+ validate(r) {
672
+ return e["~run"]({ value: r }, /* @__PURE__ */ dt());
673
+ }
674
+ };
675
+ }
676
+ // @__NO_SIDE_EFFECTS__
677
+ function vs(e, r) {
678
+ return Object.hasOwn(e, r) && r !== "__proto__" && r !== "prototype" && r !== "constructor";
679
+ }
680
+ // @__NO_SIDE_EFFECTS__
681
+ function xs(e, r) {
682
+ const t = [...new Set(e)];
683
+ return t.length > 1 ? `(${t.join(` ${r} `)})` : t[0] ?? "never";
684
+ }
685
+ // @__NO_SIDE_EFFECTS__
686
+ function ws(e) {
687
+ if (e.path) {
688
+ let r = "";
689
+ for (const t of e.path)
690
+ if (typeof t.key == "string" || typeof t.key == "number")
691
+ r ? r += `.${t.key}` : r += t.key;
692
+ else
693
+ return null;
694
+ return r;
695
+ }
696
+ return null;
697
+ }
698
+ var _s = class extends Error {
699
+ /**
700
+ * Creates a Valibot error with useful information.
701
+ *
702
+ * @param issues The error issues.
703
+ */
704
+ constructor(e) {
705
+ super(e[0].message), this.name = "ValiError", this.issues = e;
706
+ }
707
+ }, ks = /^[\w+-]+(?:\.[\w+-]+)*@[\da-z]+(?:[.-][\da-z]+)*\.[a-z]{2,}$/iu;
708
+ // @__NO_SIDE_EFFECTS__
709
+ function Dr(e, r) {
710
+ return {
711
+ kind: "validation",
712
+ type: "check",
713
+ reference: Dr,
714
+ async: !1,
715
+ expects: null,
716
+ requirement: e,
717
+ message: r,
718
+ "~run"(t, n) {
719
+ return t.typed && !this.requirement(t.value) && Y(this, "input", t, n), t;
720
+ }
721
+ };
722
+ }
723
+ // @__NO_SIDE_EFFECTS__
724
+ function Tr(e) {
725
+ return {
726
+ kind: "validation",
727
+ type: "email",
728
+ reference: Tr,
729
+ expects: null,
730
+ async: !1,
731
+ requirement: ks,
732
+ message: e,
733
+ "~run"(r, t) {
734
+ return r.typed && !this.requirement.test(r.value) && Y(this, "email", r, t), r;
735
+ }
736
+ };
737
+ }
738
+ // @__NO_SIDE_EFFECTS__
739
+ function Ye(e, r) {
740
+ return {
741
+ kind: "validation",
742
+ type: "max_length",
743
+ reference: Ye,
744
+ async: !1,
745
+ expects: `<=${e}`,
746
+ requirement: e,
747
+ message: r,
748
+ "~run"(t, n) {
749
+ return t.typed && t.value.length > this.requirement && Y(this, "length", t, n, {
750
+ received: `${t.value.length}`
751
+ }), t;
752
+ }
753
+ };
754
+ }
755
+ // @__NO_SIDE_EFFECTS__
756
+ function Or(e, r) {
757
+ return {
758
+ kind: "validation",
759
+ type: "max_value",
760
+ reference: Or,
761
+ async: !1,
762
+ expects: `<=${e instanceof Date ? e.toJSON() : /* @__PURE__ */ je(e)}`,
763
+ requirement: e,
764
+ message: r,
765
+ "~run"(t, n) {
766
+ return t.typed && !(t.value <= this.requirement) && Y(this, "value", t, n, {
767
+ received: t.value instanceof Date ? t.value.toJSON() : /* @__PURE__ */ je(t.value)
768
+ }), t;
769
+ }
770
+ };
771
+ }
772
+ // @__NO_SIDE_EFFECTS__
773
+ function Be(e, r) {
774
+ return {
775
+ kind: "validation",
776
+ type: "min_length",
777
+ reference: Be,
778
+ async: !1,
779
+ expects: `>=${e}`,
780
+ requirement: e,
781
+ message: r,
782
+ "~run"(t, n) {
783
+ return t.typed && t.value.length < this.requirement && Y(this, "length", t, n, {
784
+ received: `${t.value.length}`
785
+ }), t;
786
+ }
787
+ };
788
+ }
789
+ // @__NO_SIDE_EFFECTS__
790
+ function $r(e, r) {
791
+ return {
792
+ kind: "validation",
793
+ type: "min_value",
794
+ reference: $r,
795
+ async: !1,
796
+ expects: `>=${e instanceof Date ? e.toJSON() : /* @__PURE__ */ je(e)}`,
797
+ requirement: e,
798
+ message: r,
799
+ "~run"(t, n) {
800
+ return t.typed && !(t.value >= this.requirement) && Y(this, "value", t, n, {
801
+ received: t.value instanceof Date ? t.value.toJSON() : /* @__PURE__ */ je(t.value)
802
+ }), t;
803
+ }
804
+ };
805
+ }
806
+ // @__NO_SIDE_EFFECTS__
807
+ function Vt(e, r) {
808
+ return {
809
+ kind: "validation",
810
+ type: "regex",
811
+ reference: Vt,
812
+ async: !1,
813
+ expects: `${e}`,
814
+ requirement: e,
815
+ message: r,
816
+ "~run"(t, n) {
817
+ return t.typed && !this.requirement.test(t.value) && Y(this, "format", t, n), t;
818
+ }
819
+ };
820
+ }
821
+ // @__NO_SIDE_EFFECTS__
822
+ function Mt(e) {
823
+ return {
824
+ kind: "transformation",
825
+ type: "transform",
826
+ reference: Mt,
827
+ async: !1,
828
+ operation: e,
829
+ "~run"(r) {
830
+ return r.value = this.operation(r.value), r;
831
+ }
832
+ };
833
+ }
834
+ // @__NO_SIDE_EFFECTS__
835
+ function Br(e) {
836
+ return {
837
+ kind: "validation",
838
+ type: "url",
839
+ reference: Br,
840
+ async: !1,
841
+ expects: null,
842
+ requirement(r) {
843
+ try {
844
+ return new URL(r), !0;
845
+ } catch {
846
+ return !1;
847
+ }
848
+ },
849
+ message: e,
850
+ "~run"(r, t) {
851
+ return r.typed && !this.requirement(r.value) && Y(this, "URL", r, t), r;
852
+ }
853
+ };
854
+ }
855
+ // @__NO_SIDE_EFFECTS__
856
+ function Cs(e, r, t) {
857
+ return typeof e.fallback == "function" ? (
858
+ // @ts-expect-error
859
+ e.fallback(r, t)
860
+ ) : (
861
+ // @ts-expect-error
862
+ e.fallback
863
+ );
864
+ }
865
+ // @__NO_SIDE_EFFECTS__
866
+ function jr(e, r, t) {
867
+ return typeof e.default == "function" ? (
868
+ // @ts-expect-error
869
+ e.default(r, t)
870
+ ) : (
871
+ // @ts-expect-error
872
+ e.default
873
+ );
874
+ }
875
+ // @__NO_SIDE_EFFECTS__
876
+ function Pr(e, r) {
877
+ return {
878
+ kind: "schema",
879
+ type: "array",
880
+ reference: Pr,
881
+ expects: "Array",
882
+ async: !1,
883
+ item: e,
884
+ message: r,
885
+ get "~standard"() {
886
+ return /* @__PURE__ */ he(this);
887
+ },
888
+ "~run"(t, n) {
889
+ var i;
890
+ const s = t.value;
891
+ if (Array.isArray(s)) {
892
+ t.typed = !0, t.value = [];
893
+ for (let a = 0; a < s.length; a++) {
894
+ const o = s[a], c = this.item["~run"]({ value: o }, n);
895
+ if (c.issues) {
896
+ const p = {
897
+ type: "array",
898
+ origin: "value",
899
+ input: s,
900
+ key: a,
901
+ value: o
902
+ };
903
+ for (const g of c.issues)
904
+ g.path ? g.path.unshift(p) : g.path = [p], (i = t.issues) == null || i.push(g);
905
+ if (t.issues || (t.issues = c.issues), n.abortEarly) {
906
+ t.typed = !1;
907
+ break;
908
+ }
909
+ }
910
+ c.typed || (t.typed = !1), t.value.push(c.value);
911
+ }
912
+ } else
913
+ Y(this, "type", t, n);
914
+ return t;
915
+ }
916
+ };
917
+ }
918
+ // @__NO_SIDE_EFFECTS__
919
+ function qr(e) {
920
+ return {
921
+ kind: "schema",
922
+ type: "boolean",
923
+ reference: qr,
924
+ expects: "boolean",
925
+ async: !1,
926
+ message: e,
927
+ get "~standard"() {
928
+ return /* @__PURE__ */ he(this);
929
+ },
930
+ "~run"(r, t) {
931
+ return typeof r.value == "boolean" ? r.typed = !0 : Y(this, "type", r, t), r;
932
+ }
933
+ };
934
+ }
935
+ // @__NO_SIDE_EFFECTS__
936
+ function Ur(e) {
937
+ return {
938
+ kind: "schema",
939
+ type: "number",
940
+ reference: Ur,
941
+ expects: "number",
942
+ async: !1,
943
+ message: e,
944
+ get "~standard"() {
945
+ return /* @__PURE__ */ he(this);
946
+ },
947
+ "~run"(r, t) {
948
+ return typeof r.value == "number" && !isNaN(r.value) ? r.typed = !0 : Y(this, "type", r, t), r;
949
+ }
950
+ };
951
+ }
952
+ // @__NO_SIDE_EFFECTS__
953
+ function xe(e, r) {
954
+ return {
955
+ kind: "schema",
956
+ type: "object",
957
+ reference: xe,
958
+ expects: "Object",
959
+ async: !1,
960
+ entries: e,
961
+ message: r,
962
+ get "~standard"() {
963
+ return /* @__PURE__ */ he(this);
964
+ },
965
+ "~run"(t, n) {
966
+ var i;
967
+ const s = t.value;
968
+ if (s && typeof s == "object") {
969
+ t.typed = !0, t.value = {};
970
+ for (const a in this.entries) {
971
+ const o = this.entries[a];
972
+ if (a in s || (o.type === "exact_optional" || o.type === "optional" || o.type === "nullish") && // @ts-expect-error
973
+ o.default !== void 0) {
974
+ const c = a in s ? (
975
+ // @ts-expect-error
976
+ s[a]
977
+ ) : /* @__PURE__ */ jr(o), p = o["~run"]({ value: c }, n);
978
+ if (p.issues) {
979
+ const g = {
980
+ type: "object",
981
+ origin: "value",
982
+ input: s,
983
+ key: a,
984
+ value: c
985
+ };
986
+ for (const b of p.issues)
987
+ b.path ? b.path.unshift(g) : b.path = [g], (i = t.issues) == null || i.push(b);
988
+ if (t.issues || (t.issues = p.issues), n.abortEarly) {
989
+ t.typed = !1;
990
+ break;
991
+ }
992
+ }
993
+ p.typed || (t.typed = !1), t.value[a] = p.value;
994
+ } else if (o.fallback !== void 0)
995
+ t.value[a] = /* @__PURE__ */ Cs(o);
996
+ else if (o.type !== "exact_optional" && o.type !== "optional" && o.type !== "nullish" && (Y(this, "key", t, n, {
997
+ input: void 0,
998
+ expected: `"${a}"`,
999
+ path: [
1000
+ {
1001
+ type: "object",
1002
+ origin: "key",
1003
+ input: s,
1004
+ key: a,
1005
+ // @ts-expect-error
1006
+ value: s[a]
1007
+ }
1008
+ ]
1009
+ }), n.abortEarly))
1010
+ break;
1011
+ }
1012
+ } else
1013
+ Y(this, "type", t, n);
1014
+ return t;
1015
+ }
1016
+ };
1017
+ }
1018
+ // @__NO_SIDE_EFFECTS__
1019
+ function Qe(e, r) {
1020
+ return {
1021
+ kind: "schema",
1022
+ type: "optional",
1023
+ reference: Qe,
1024
+ expects: `(${e.expects} | undefined)`,
1025
+ async: !1,
1026
+ wrapped: e,
1027
+ default: r,
1028
+ get "~standard"() {
1029
+ return /* @__PURE__ */ he(this);
1030
+ },
1031
+ "~run"(t, n) {
1032
+ return t.value === void 0 && (this.default !== void 0 && (t.value = /* @__PURE__ */ jr(this, t, n)), t.value === void 0) ? (t.typed = !0, t) : this.wrapped["~run"](t, n);
1033
+ }
1034
+ };
1035
+ }
1036
+ // @__NO_SIDE_EFFECTS__
1037
+ function Wr(e, r) {
1038
+ return {
1039
+ kind: "schema",
1040
+ type: "picklist",
1041
+ reference: Wr,
1042
+ expects: /* @__PURE__ */ xs(e.map(je), "|"),
1043
+ async: !1,
1044
+ options: e,
1045
+ message: r,
1046
+ get "~standard"() {
1047
+ return /* @__PURE__ */ he(this);
1048
+ },
1049
+ "~run"(t, n) {
1050
+ return this.options.includes(t.value) ? t.typed = !0 : Y(this, "type", t, n), t;
1051
+ }
1052
+ };
1053
+ }
1054
+ // @__NO_SIDE_EFFECTS__
1055
+ function zr(e, r, t) {
1056
+ return {
1057
+ kind: "schema",
1058
+ type: "record",
1059
+ reference: zr,
1060
+ expects: "Object",
1061
+ async: !1,
1062
+ key: e,
1063
+ value: r,
1064
+ message: t,
1065
+ get "~standard"() {
1066
+ return /* @__PURE__ */ he(this);
1067
+ },
1068
+ "~run"(n, s) {
1069
+ var a, o;
1070
+ const i = n.value;
1071
+ if (i && typeof i == "object") {
1072
+ n.typed = !0, n.value = {};
1073
+ for (const c in i)
1074
+ if (/* @__PURE__ */ vs(i, c)) {
1075
+ const p = i[c], g = this.key["~run"]({ value: c }, s);
1076
+ if (g.issues) {
1077
+ const h = {
1078
+ type: "object",
1079
+ origin: "key",
1080
+ input: i,
1081
+ key: c,
1082
+ value: p
1083
+ };
1084
+ for (const m of g.issues)
1085
+ m.path = [h], (a = n.issues) == null || a.push(m);
1086
+ if (n.issues || (n.issues = g.issues), s.abortEarly) {
1087
+ n.typed = !1;
1088
+ break;
1089
+ }
1090
+ }
1091
+ const b = this.value["~run"](
1092
+ { value: p },
1093
+ s
1094
+ );
1095
+ if (b.issues) {
1096
+ const h = {
1097
+ type: "object",
1098
+ origin: "value",
1099
+ input: i,
1100
+ key: c,
1101
+ value: p
1102
+ };
1103
+ for (const m of b.issues)
1104
+ m.path ? m.path.unshift(h) : m.path = [h], (o = n.issues) == null || o.push(m);
1105
+ if (n.issues || (n.issues = b.issues), s.abortEarly) {
1106
+ n.typed = !1;
1107
+ break;
1108
+ }
1109
+ }
1110
+ (!g.typed || !b.typed) && (n.typed = !1), g.typed && (n.value[g.value] = b.value);
1111
+ }
1112
+ } else
1113
+ Y(this, "type", n, s);
1114
+ return n;
1115
+ }
1116
+ };
1117
+ }
1118
+ // @__NO_SIDE_EFFECTS__
1119
+ function ie(e) {
1120
+ return {
1121
+ kind: "schema",
1122
+ type: "string",
1123
+ reference: ie,
1124
+ expects: "string",
1125
+ async: !1,
1126
+ message: e,
1127
+ get "~standard"() {
1128
+ return /* @__PURE__ */ he(this);
1129
+ },
1130
+ "~run"(r, t) {
1131
+ return typeof r.value == "string" ? r.typed = !0 : Y(this, "type", r, t), r;
1132
+ }
1133
+ };
1134
+ }
1135
+ function Ss(e, r, t) {
1136
+ const n = e["~run"]({ value: r }, /* @__PURE__ */ dt(t));
1137
+ if (n.issues)
1138
+ throw new _s(n.issues);
1139
+ return n.value;
1140
+ }
1141
+ // @__NO_SIDE_EFFECTS__
1142
+ function Is(e, r) {
1143
+ const t = {};
1144
+ for (const n in e.entries)
1145
+ t[n] = !r || r.includes(n) ? /* @__PURE__ */ Qe(e.entries[n]) : e.entries[n];
1146
+ return {
1147
+ ...e,
1148
+ entries: t,
1149
+ get "~standard"() {
1150
+ return /* @__PURE__ */ he(this);
1151
+ }
1152
+ };
1153
+ }
1154
+ // @__NO_SIDE_EFFECTS__
1155
+ function Ie(...e) {
1156
+ return {
1157
+ ...e[0],
1158
+ pipe: e,
1159
+ get "~standard"() {
1160
+ return /* @__PURE__ */ he(this);
1161
+ },
1162
+ "~run"(r, t) {
1163
+ for (const n of e)
1164
+ if (n.kind !== "metadata") {
1165
+ if (r.issues && (n.kind === "schema" || n.kind === "transformation")) {
1166
+ r.typed = !1;
1167
+ break;
1168
+ }
1169
+ (!r.issues || !t.abortEarly && !t.abortPipeEarly) && (r = n["~run"](r, t));
1170
+ }
1171
+ return r;
1172
+ }
1173
+ };
1174
+ }
1175
+ // @__NO_SIDE_EFFECTS__
1176
+ function As(e, r, t) {
1177
+ const n = e["~run"]({ value: r }, /* @__PURE__ */ dt(t));
1178
+ return {
1179
+ typed: n.typed,
1180
+ success: !n.issues,
1181
+ output: n.value,
1182
+ issues: n.issues
1183
+ };
1184
+ }
1185
+ // @__NO_SIDE_EFFECTS__
1186
+ async function Es(e, r, t) {
1187
+ const n = await e["~run"](
1188
+ { value: r },
1189
+ /* @__PURE__ */ dt(t)
1190
+ );
1191
+ return {
1192
+ typed: n.typed,
1193
+ success: !n.issues,
1194
+ output: n.value,
1195
+ issues: n.issues
1196
+ };
1197
+ }
1198
+ const We = ({
1199
+ error: e
1200
+ }) => !e || !e.message ? null : u("div", {
1201
+ role: "alert",
1202
+ class: "text-error-11 flex max-w-full items-start gap-1 overflow-hidden rounded-2xl px-2 py-2",
1203
+ children: [u("svg", {
1204
+ class: "text-error-9 mt-0.5 h-4 w-4 shrink-0",
1205
+ viewBox: "0 0 16 16",
1206
+ fill: "none",
1207
+ xmlns: "http://www.w3.org/2000/svg",
1208
+ children: [u("circle", {
1209
+ cx: "8",
1210
+ cy: "8",
1211
+ r: "6.3",
1212
+ stroke: "currentColor",
1213
+ "stroke-width": "1.4"
1214
+ }), u("rect", {
1215
+ x: "7",
1216
+ y: "4",
1217
+ width: "2",
1218
+ height: "5",
1219
+ fill: "currentColor"
1220
+ }), u("rect", {
1221
+ x: "7",
1222
+ y: "10",
1223
+ width: "2",
1224
+ height: "2",
1225
+ fill: "currentColor"
1226
+ })]
1227
+ }), u("p", {
1228
+ class: "break-words pr-1 text-sm",
1229
+ children: e.message
1230
+ })]
1231
+ }), Ee = ({
1232
+ class: e,
1233
+ ...r
1234
+ }) => {
1235
+ const {
1236
+ t
1237
+ } = Q();
1238
+ return u("button", {
1239
+ type: "button",
1240
+ class: qe("fr touch-hitbox text-neutral-11 bg-neutral-1 ring-divider hover:ring-divider active:ring-interactive-bg-hover hover:text-neutral-12 active:text-neutral-12 hover:bg-divider active:bg-interactive-bg-hover flex flex-shrink-0 items-center justify-center gap-1 self-center rounded-full py-1 pl-2 pr-2.5 text-sm ring-1 transition-all", e),
1241
+ ...r,
1242
+ children: [u("svg", {
1243
+ "aria-hidden": !0,
1244
+ class: "block",
1245
+ width: "16",
1246
+ height: "16",
1247
+ viewBox: "0 0 16 16",
1248
+ fill: "transparent",
1249
+ stroke: "currentColor",
1250
+ "stroke-linecap": "round",
1251
+ "stroke-width": "1.5",
1252
+ children: [u("title", {
1253
+ children: t("skip")
1254
+ }), u("path", {
1255
+ d: "M3.25 11.25A5 5 0 0 1 12 7"
1256
+ }), u("path", {
1257
+ d: "M13.25 4.5V8.25H9.5"
1258
+ })]
1259
+ }), t("skip")]
1260
+ });
1261
+ };
1262
+ var Lt = { Afghanistan: "93", Albania: "355", Algeria: "213", "American Samoa": "1 684", Andorra: "376", Angola: "244", Anguilla: "1 264", Antarctica: "672", "Antigua and Barbuda": "1 268", Argentina: "54", Armenia: "374", Aruba: "297", Australia: "61", Austria: "43", Azerbaijan: "994", Bahrain: "973", Bangladesh: "880", Barbados: "1 246", Belarus: "375", Belgium: "32", Belize: "501", Benin: "229", Bermuda: "1 441", Bhutan: "975", Bolivia: "591", "Bosnia and Herzegovina": "387", Botswana: "267", "Bouvet Island": "47", Brazil: "55", "British Indian Ocean Territory": "246", "British Virgin Islands": "1 284", Brunei: "673", Bulgaria: "359", "Burkina Faso": "226", Burundi: "257", "Cabo Verde": "238", Cambodia: "855", Cameroon: "237", Canada: "1", "Caribbean Netherlands": "599", "Cayman Islands": "1 345", "Central African Republic": "236", Chad: "235", Chile: "56", China: "86", "Christmas Island": "61", "Cocos (Keeling) Islands": "61", Colombia: "57", Comoros: "269", "Cook Islands": "682", "Costa Rica": "506", Croatia: "385", Cuba: "53", Curaçao: "599", Cyprus: "357", Czechia: "420", "Côte d'Ivoire": "225", "Democratic Republic of the Congo": "243", Denmark: "45", Djibouti: "253", "Dominican Republic": "1 809", Ecuador: "593", Egypt: "20", "El Salvador": "503", "Equatorial Guinea": "240", Eritrea: "291", Estonia: "372", Eswatini: "268", Ethiopia: "251", "Falkland Islands (Islas Malvinas)": "500", "Faroe Islands": "298", Fiji: "679", Finland: "358", France: "33", "French Guiana": "594", "French Polynesia": "689", "French Southern and Antarctic Lands": "262", Gabon: "241", Georgia: "995", Germany: "49", Ghana: "233", Gibraltar: "350", Greece: "30", Greenland: "299", Grenada: "1 473", Guadeloupe: "590", Guam: "1 671", Guatemala: "502", Guernsey: "44", Guinea: "224", "Guinea-Bissau": "245", Guyana: "592", Haiti: "509", Honduras: "504", "Hong Kong": "852", Hungary: "36", Iceland: "354", India: "91", Indonesia: "62", Iran: "98", Iraq: "964", Ireland: "353", "Isle of Man": "44", Israel: "972", Italy: "39", Jamaica: "1 876", Japan: "81", Jersey: "44", Jordan: "962", Kazakhstan: "7", Kenya: "254", Kiribati: "686", Kosovo: "383", Kuwait: "965", Kyrgyzstan: "996", Laos: "856", Latvia: "371", Lebanon: "961", Lesotho: "266", Liberia: "231", Libya: "218", Liechtenstein: "423", Lithuania: "370", Luxembourg: "352", Macao: "853", Madagascar: "261", Malawi: "265", Malaysia: "60", Maldives: "960", Mali: "223", Malta: "356", "Marshall Islands": "692", Martinique: "596", Mauritania: "222", Mauritius: "230", Mayotte: "262", Mexico: "52", Micronesia: "691", Moldova: "373", Monaco: "377", Mongolia: "976", Montenegro: "382", Montserrat: "1 664", Morocco: "212", Mozambique: "258", "Myanmar (Burma)": "95", Namibia: "264", Nauru: "674", Nepal: "977", Netherlands: "31", "New Caledonia": "687", "New Zealand": "64", Nicaragua: "505", Niger: "227", Nigeria: "234", Niue: "683", "Norfolk Island": "672", "North Korea": "850", "North Macedonia": "389", "Northern Mariana Islands": "1 670", Norway: "47", Oman: "968", Pakistan: "92", Palau: "680", Palestine: "970", Panama: "507", "Papua New Guinea": "675", Paraguay: "595", Peru: "51", Philippines: "63", "Pitcairn Islands": "64", Poland: "48", Portugal: "351", "Puerto Rico": "1 787", Qatar: "974", Romania: "40", Russia: "7", Rwanda: "250", Réunion: "262", "Saint Barthélemy": "590", "Saint Helena, Ascension and Tristan da Cunha": "290", "Saint Kitts and Nevis": "1 869", "Saint Lucia": "1 758", "Saint Martin": "590", "Saint Pierre and Miquelon": "508", "Saint Vincent and the Grenadines": "1 784", Samoa: "685", "San Marino": "378", "Saudi Arabia": "966", Senegal: "221", Serbia: "381", Seychelles: "248", "Sierra Leone": "232", Singapore: "65", "Sint Maarten": "1 721", Slovakia: "421", Slovenia: "386", "Solomon Islands": "677", Somalia: "252", "South Africa": "27", "South Georgia and the South Sandwich Islands": "500", "South Korea": "82", "South Sudan": "211", Spain: "34", "Sri Lanka": "94", Sudan: "249", Suriname: "597", "Svalbard and Jan Mayen": "47", Sweden: "46", Switzerland: "41", Syria: "963", "São Tomé and Príncipe": "239", Taiwan: "886", Tajikistan: "992", Tanzania: "255", Thailand: "66", "The Bahamas": "1 242", "The Gambia": "220", "Timor-Leste": "670", Togo: "228", Tokelau: "690", Tonga: "676", "Trinidad and Tobago": "1 868", Tunisia: "216", Turkmenistan: "993", "Turks and Caicos Islands": "1 649", Tuvalu: "688", Türkiye: "90", "U.S. Virgin Islands": "1 340", Uganda: "256", Ukraine: "380", "United Arab Emirates": "971", "United Kingdom": "44", "United States": "1", "United States Minor Outlying Islands": "1", Uruguay: "598", Uzbekistan: "998", Vanuatu: "678", "Vatican City": "379", Venezuela: "58", Vietnam: "84", "Wallis and Futuna": "681", "Western Sahara": "212", Yemen: "967", Zambia: "260", Zimbabwe: "263", "Åland Islands": "358" };
1263
+ const Pe = ct("outline-divider ease-expo-out placeholder:text-neutral-10 text-neutral-12 focus-visible:outline-accent-7 caret-accent-9 bg-lowest py-1 text-base outline outline-2 transition-all", {
1264
+ variants: {
1265
+ optional: {
1266
+ true: "pr-16 pl-3",
1267
+ false: "pl-3 pr-3"
1268
+ }
1269
+ },
1270
+ defaultVariants: {
1271
+ optional: !1
1272
+ }
1273
+ }), Fs = "https://api.mapbox.com/search/searchbox/v1/suggest", Vs = "ZzRDWFU0dTZ3SF9aWk9RNGl6QzZaWS5RZmlFak13a0hPbGxXZXlNSGN5RUhObUJ6TXpSV08yUW5OdE5tSTZJU1lpd2lJb1JYYXRObmJ2Tm5iaGhHZWx4V1lpb2pJMUp5ZS5rcA==", Ms = (e) => atob(e).split("").reverse().join(""), ge = /* @__PURE__ */ xe({
1274
+ name: /* @__PURE__ */ ie()
1275
+ }), Ls = /* @__PURE__ */ xe({
1276
+ suggestions: /* @__PURE__ */ Pr(/* @__PURE__ */ xe({
1277
+ full_address: /* @__PURE__ */ Qe(/* @__PURE__ */ ie()),
1278
+ place_formatted: /* @__PURE__ */ Qe(/* @__PURE__ */ ie()),
1279
+ name: /* @__PURE__ */ Qe(/* @__PURE__ */ ie()),
1280
+ mapbox_id: /* @__PURE__ */ ie(),
1281
+ context: /* @__PURE__ */ Is(/* @__PURE__ */ xe({
1282
+ address: ge,
1283
+ street: ge,
1284
+ neighborhood: ge,
1285
+ locality: ge,
1286
+ district: ge,
1287
+ place: ge,
1288
+ region: ge,
1289
+ postcode: ge,
1290
+ country: ge
1291
+ }))
1292
+ }))
1293
+ }), Ns = ({
1294
+ logger: e,
1295
+ t: r
1296
+ }) => An(() => {
1297
+ var n;
1298
+ const t = (n = j.current$.peek().flow) == null ? void 0 : n.data.flowSessionId;
1299
+ return t ? {
1300
+ enabled: !0,
1301
+ getPredictions: async (s) => {
1302
+ var b;
1303
+ const i = new URL(Fs);
1304
+ i.searchParams.set("q", s), i.searchParams.set("session_token", t);
1305
+ const a = (b = j.current$.peek().flow) == null ? void 0 : b.locationOrigin;
1306
+ a && a.lat !== void 0 && a.lng !== void 0 && a.lat >= -90 && a.lat <= 90 && a.lng >= -180 && a.lng <= 180 && i.searchParams.set("proximity", `${a.lng},${a.lat}`), i.searchParams.set("access_token", Ms(Vs));
1307
+ const c = await fetch(i);
1308
+ if (!c.ok)
1309
+ return e.error("Failed to get address details", c), {
1310
+ ok: !1,
1311
+ error: r("address_error")
1312
+ };
1313
+ const p = /* @__PURE__ */ As(Ls, await c.json());
1314
+ if (p.success === !1)
1315
+ return e.error("Failed to parse address details", p.issues), {
1316
+ ok: !1,
1317
+ error: r("address_error")
1318
+ };
1319
+ const {
1320
+ suggestions: g
1321
+ } = p.output;
1322
+ return {
1323
+ ok: !0,
1324
+ data: g.map((h) => {
1325
+ var m, w, S, C, _, y, E, A, V;
1326
+ return {
1327
+ label: h.full_address ?? h.place_formatted ?? h.name ?? h.mapbox_id,
1328
+ id: h.mapbox_id,
1329
+ address: {
1330
+ line1: ((m = h.context.address) == null ? void 0 : m.name) ?? ((w = h.context.street) == null ? void 0 : w.name),
1331
+ line2: void 0,
1332
+ line3: ((S = h.context.neighborhood) == null ? void 0 : S.name) ?? ((C = h.context.locality) == null ? void 0 : C.name),
1333
+ city: ((_ = h.context.place) == null ? void 0 : _.name) ?? ((y = h.context.district) == null ? void 0 : y.name),
1334
+ state: (E = h.context.region) == null ? void 0 : E.name,
1335
+ postcode: (A = h.context.postcode) == null ? void 0 : A.name,
1336
+ country: (V = h.context.country) == null ? void 0 : V.name
1337
+ }
1338
+ };
1339
+ })
1340
+ };
1341
+ }
1342
+ } : {
1343
+ enabled: !1
1344
+ };
1345
+ }, [e, r]), Xt = (e) => {
1346
+ const {
1347
+ t: r
1348
+ } = Q();
1349
+ return u("button", {
1350
+ type: "button",
1351
+ class: "touch-hitbox text-neutral-11 hover:bg-neutral-4 hover:text-neutral-12 hover:border-neutral-5 relative flex items-center gap-1 rounded-[18px] border border-solid border-transparent px-3 py-1 pl-1.5 text-sm transition-colors",
1352
+ ...e,
1353
+ children: [u("svg", {
1354
+ width: "16",
1355
+ height: "16",
1356
+ viewBox: "0 0 16 16",
1357
+ stroke: "currentColor",
1358
+ "stroke-width": "1.5",
1359
+ fill: "none",
1360
+ xmlns: "http://www.w3.org/2000/svg",
1361
+ children: u("path", {
1362
+ d: "M10 3L5 8L10 13"
1363
+ })
1364
+ }), u("span", {
1365
+ children: r("back")
1366
+ })]
1367
+ });
1368
+ }, Rs = ({
1369
+ input: e,
1370
+ onSubmitSuccess: r,
1371
+ logger: t
1372
+ }) => {
1373
+ const {
1374
+ t: n
1375
+ } = Q(), [s, i] = ve(), {
1376
+ enabled: a,
1377
+ getPredictions: o
1378
+ } = Ns({
1379
+ logger: t,
1380
+ t: n
1381
+ }), [c, p] = ve(a ? "query" : "manual"), [g, b] = ve(""), [h, m] = ve(), w = de(), S = de(), C = (y) => {
1382
+ var A;
1383
+ if (Ne(a, "Query state should not be enabled"), y = y.trim(), y === ((A = w.current) == null ? void 0 : A.query) || y === (h == null ? void 0 : h.query) && h.status === "done")
1384
+ return;
1385
+ if (b(y), y === "") {
1386
+ w.current = void 0, m(void 0);
1387
+ return;
1388
+ }
1389
+ const E = w.current = {
1390
+ query: y
1391
+ };
1392
+ m({
1393
+ query: y,
1394
+ status: "pending"
1395
+ }), o(y).then((V) => {
1396
+ w.current === E && (w.current = void 0, m(V.ok ? {
1397
+ query: y,
1398
+ status: "done",
1399
+ items: V.data
1400
+ } : {
1401
+ query: y,
1402
+ status: "failed",
1403
+ error: V.error
1404
+ }));
1405
+ }, (V) => {
1406
+ w.current === E && (w.current = void 0, t.error("Failed to get address details", V), m({
1407
+ query: y,
1408
+ status: "failed",
1409
+ error: n("address_error")
1410
+ }));
1411
+ });
1412
+ }, _ = (y, E) => {
1413
+ i((A) => ({
1414
+ ...A,
1415
+ [y]: E
1416
+ }));
1417
+ };
1418
+ switch (c) {
1419
+ case "query":
1420
+ return Ne(a, "Query state should not be enabled"), u(Ds, {
1421
+ input: e,
1422
+ onSkip: () => r(null),
1423
+ onAddressSelect: (y) => {
1424
+ if (y === "") {
1425
+ w.current && (w.current = void 0, m(void 0)), p("manual");
1426
+ return;
1427
+ }
1428
+ const E = (h == null ? void 0 : h.status) === "done" ? h.items.find((A) => A.id === y) : void 0;
1429
+ E && (S.current !== y && i(E.address), S.current = y, p("details"));
1430
+ },
1431
+ onAddressSearch: C,
1432
+ lookup: h,
1433
+ query: g
1434
+ });
1435
+ case "details":
1436
+ return Ne(s !== void 0), u(Zt, {
1437
+ input: e,
1438
+ logger: t,
1439
+ onSubmitSuccess: r,
1440
+ addressFields: s,
1441
+ onFieldChange: _,
1442
+ actions: u(Xt, {
1443
+ onClick: () => {
1444
+ p("query");
1445
+ }
1446
+ })
1447
+ });
1448
+ case "manual":
1449
+ return u(Zt, {
1450
+ logger: t,
1451
+ input: e,
1452
+ onSubmitSuccess: r,
1453
+ addressFields: s ?? {},
1454
+ onFieldChange: _,
1455
+ actions: a ? u(Xt, {
1456
+ onClick: () => {
1457
+ p("query");
1458
+ }
1459
+ }) : e.config.optional ? (
1460
+ // Without address search this is the only screen, so an optional question needs its own way past.
1461
+ u(Ee, {
1462
+ onClick: () => r(null)
1463
+ })
1464
+ ) : void 0
1465
+ });
1466
+ }
1467
+ }, Ds = ({
1468
+ input: e,
1469
+ onSkip: r,
1470
+ lookup: t,
1471
+ onAddressSelect: n,
1472
+ query: s,
1473
+ onAddressSearch: i
1474
+ }) => {
1475
+ const {
1476
+ t: a
1477
+ } = Q(), o = de(null);
1478
+ return Ae(() => {
1479
+ o.current && (o.current.focus(), o.current.select());
1480
+ }, []), u(we, {
1481
+ children: [u("form", {
1482
+ noValidate: !0,
1483
+ onSubmit: (c) => {
1484
+ c.preventDefault();
1485
+ const g = new FormData(c.currentTarget).get("address");
1486
+ typeof g == "string" && i(g);
1487
+ },
1488
+ class: "flex gap-2 p-2.5",
1489
+ children: [u("div", {
1490
+ class: "group relative flex-1",
1491
+ children: [u("input", {
1492
+ ref: o,
1493
+ name: "address",
1494
+ id: "chat-address",
1495
+ autocomplete: "address-line1",
1496
+ autoFocus: !0,
1497
+ placeholder: e.config.placeholder || a("address_search"),
1498
+ defaultValue: s,
1499
+ class: Pe({
1500
+ optional: !!e.config.optional,
1501
+ className: "w-full rounded-full"
1502
+ })
1503
+ }), u("button", {
1504
+ type: "submit",
1505
+ class: "touch-hitbox text-neutral-12 hover:bg-neutral-3 fr absolute bottom-0 right-0 top-0 flex cursor-pointer items-center gap-1 rounded-full px-3 transition-all",
1506
+ children: [u("svg", {
1507
+ "aria-hidden": "true",
1508
+ width: "16",
1509
+ height: "16",
1510
+ viewBox: "0 0 16 16",
1511
+ fill: "none",
1512
+ xmlns: "http://www.w3.org/2000/svg",
1513
+ children: u("g", {
1514
+ id: "inploi",
1515
+ stroke: "currentColor",
1516
+ "stroke-linecap": "round",
1517
+ "stroke-linejoin": "round",
1518
+ strokeWidth: "1.5",
1519
+ children: [u("circle", {
1520
+ cx: "7",
1521
+ cy: "7",
1522
+ r: "4"
1523
+ }), u("path", {
1524
+ d: "M10 10L13 13"
1525
+ })]
1526
+ })
1527
+ }), u("span", {
1528
+ class: "sr-only",
1529
+ children: a("search")
1530
+ })]
1531
+ })]
1532
+ }), e.config.optional && u(Ee, {
1533
+ class: "relative",
1534
+ onClick: r
1535
+ })]
1536
+ }), (t == null ? void 0 : t.status) === "failed" ? u(We, {
1537
+ error: {
1538
+ message: t.error
1539
+ }
1540
+ }) : null, u("p", {
1541
+ role: "status",
1542
+ class: (t == null ? void 0 : t.status) === "pending" || (t == null ? void 0 : t.status) === "done" && t.items.length === 0 ? "text-neutral-11 flex items-center gap-2 px-4 py-2 text-sm" : "sr-only",
1543
+ children: (t == null ? void 0 : t.status) === "pending" ? u(we, {
1544
+ children: [u(Et, {
1545
+ "aria-hidden": "true",
1546
+ class: "h-4 w-4 shrink-0"
1547
+ }), a("address_searching")]
1548
+ }) : (t == null ? void 0 : t.status) === "done" && t.items.length === 0 ? a("address_no_results") : null
1549
+ }), u("ul", {
1550
+ children: [((t == null ? void 0 : t.status) === "done" ? t.items : []).map((c) => u("li", {
1551
+ children: u("button", {
1552
+ class: "text-neutral-11 fr hover:bg-neutral-3 focus-visible:bg-neutral-3 hover:text-neutral-12 border-b-neutral-3 flex w-full items-center border border-b border-solid border-transparent px-4 py-3 text-sm transition-colors duration-100",
1553
+ onClick: () => {
1554
+ n(c.id);
1555
+ },
1556
+ children: [u("span", {
1557
+ class: "flex-grow",
1558
+ children: c.label
1559
+ }), u("svg", {
1560
+ class: "flex-none",
1561
+ width: "16",
1562
+ height: "16",
1563
+ viewBox: "0 0 16 16",
1564
+ stroke: "currentColor",
1565
+ "stroke-width": "1.5",
1566
+ fill: "none",
1567
+ xmlns: "http://www.w3.org/2000/svg",
1568
+ children: u("path", {
1569
+ d: "M6 3L11 8L6 13"
1570
+ })
1571
+ })]
1572
+ })
1573
+ }, c.id)), u("li", {
1574
+ children: u("button", {
1575
+ class: "text-neutral-11 fr hover:bg-neutral-3 focus-visible:bg-neutral-3 hover:text-neutral-12 border-b-neutral-3 flex w-full items-center border border-b border-solid border-transparent px-4 py-3 text-sm transition-colors duration-100",
1576
+ onClick: () => {
1577
+ n("");
1578
+ },
1579
+ children: u("span", {
1580
+ class: "flex-grow",
1581
+ children: a("address_manual")
1582
+ })
1583
+ })
1584
+ }, "")]
1585
+ })]
1586
+ });
1587
+ }, _t = ["line1", "line2", "line3", "city", "state", "postcode", "country"], Zt = ({
1588
+ addressFields: e,
1589
+ onFieldChange: r,
1590
+ onSubmitSuccess: t,
1591
+ actions: n,
1592
+ input: s
1593
+ }) => {
1594
+ const i = de(null);
1595
+ Ae(() => {
1596
+ if (i.current) {
1597
+ const c = i.current.querySelector("input");
1598
+ c && (c.focus(), c.select());
1599
+ }
1600
+ }, []);
1601
+ const a = Object.keys(Lt), {
1602
+ t: o
1603
+ } = Q();
1604
+ return u("form", {
1605
+ class: "flex flex-col px-2 pt-2",
1606
+ onSubmit: (c) => {
1607
+ const p = c.currentTarget, g = [...p.querySelectorAll("input")].filter((m) => m.value !== "" && !m.value.trim());
1608
+ for (const m of g) {
1609
+ m.value = "";
1610
+ const w = _t.find((S) => s.config.keys[S] === m.name);
1611
+ w && r(w, "");
1612
+ }
1613
+ if (g.length > 0 && !p.checkValidity()) {
1614
+ c.preventDefault(), p.reportValidity();
1615
+ return;
1616
+ }
1617
+ const b = new FormData(p), h = Object.fromEntries(b.entries());
1618
+ t({
1619
+ type: "address",
1620
+ value: h
1621
+ });
1622
+ },
1623
+ children: [u("div", {
1624
+ class: "bg-neutral-3 border-neutral-5 grid items-center gap-1.5 rounded-2xl border pb-2 pl-4 pr-3 pt-3 [grid-template-columns:min-content_1fr]",
1625
+ ref: i,
1626
+ children: _t.map((c, p) => {
1627
+ const g = `isdk_${c}`, b = s.config.keys[c];
1628
+ return b ? u(we, {
1629
+ children: [u("label", {
1630
+ for: g,
1631
+ class: "text-neutral-11 [&:has(+*>input:focus)]:text-neutral-12 w-24 pb-2 text-xs uppercase leading-3 tracking-widest transition-colors",
1632
+ children: o(c)
1633
+ }), u("div", {
1634
+ class: "flex flex-col items-stretch gap-1.5",
1635
+ children: [c === "country" ? u("div", {
1636
+ class: "relative",
1637
+ children: [u("select", {
1638
+ class: "text-neutral-12 hover:bg-neutral-4 placeholder:text-neutral-8 focus:bg-neutral-5 w-full flex-1 appearance-none rounded-lg border-solid bg-transparent bg-none px-3 py-1.5 text-base transition-colors focus:outline-none",
1639
+ name: b,
1640
+ id: g,
1641
+ defaultValue: e[c],
1642
+ onChange: (h) => r(c, h.currentTarget.value),
1643
+ required: !0,
1644
+ children: [e.country && !a.includes(e.country) ? u("option", {
1645
+ value: e[c],
1646
+ children: e[c]
1647
+ }) : u("option", {
1648
+ value: "",
1649
+ children: o("select_country")
1650
+ }), a.map((h) => u("option", {
1651
+ value: h,
1652
+ children: h
1653
+ }, h))]
1654
+ }), u("svg", {
1655
+ class: "text-neutral-12 absolute bottom-2.5 right-2 flex items-center justify-center",
1656
+ width: "16",
1657
+ height: "16",
1658
+ stroke: "currentColor",
1659
+ "stroke-width": "1.5",
1660
+ "stroke-linecap": "round",
1661
+ "stroke-linejoin": "round",
1662
+ viewBox: "0 0 16 16",
1663
+ fill: "none",
1664
+ xmlns: "http://www.w3.org/2000/svg",
1665
+ children: u("path", {
1666
+ d: "M4 6.5L8 10.5L12 6.5"
1667
+ })
1668
+ })]
1669
+ }) : u("input", {
1670
+ autoFocus: p === 0 ? !0 : void 0,
1671
+ class: "text-neutral-12 hover:bg-neutral-4 placeholder:text-neutral-8 focus:bg-neutral-5 flex-1 rounded-lg border-solid bg-transparent px-3 py-1.5 text-base transition-colors autofill:shadow-[inset_0_0_0_1000px_hsl(210_16.7%_97.6%)] focus:outline-none",
1672
+ name: b,
1673
+ id: g,
1674
+ defaultValue: e[c],
1675
+ onInput: (h) => r(c, h.currentTarget.value),
1676
+ required: c !== "line2" || s.config.line2Required === !0
1677
+ }), p === _t.length - 1 ? u("hr", {
1678
+ class: "m-0 w-full border-b border-b-transparent"
1679
+ }) : u("hr", {
1680
+ class: "border-b-neutral-5 m-0 w-full border-b border-solid"
1681
+ })]
1682
+ })]
1683
+ }) : null;
1684
+ })
1685
+ }), u("div", {
1686
+ class: "bg-neutral-1 sticky bottom-0 flex items-center py-2",
1687
+ children: [n, u(Re, {
1688
+ class: "ml-auto"
1689
+ })]
1690
+ })]
1691
+ });
1692
+ }, Nt = () => {
1693
+ const e = de(null);
1694
+ return Er(() => {
1695
+ var r;
1696
+ (r = e.current) == null || r.focus();
1697
+ }, []), e;
1698
+ }, Kr = ["true", "false"], Ts = /* @__PURE__ */ Wr(Kr), Os = "answer", Gr = "flex items-center flex-wrap gap-2 p-2.5", Hr = "min-w-0 max-w-full flex-auto", Jr = Fr(({
1699
+ label: e,
1700
+ ...r
1701
+ }, t) => u("button", {
1702
+ class: "bg-lowest ease-expo-out ring-divider text-neutral-12 active:ring-accent-7 active:bg-accent-2 active:text-accent-11 fr block w-full overflow-hidden rounded-2xl px-2 py-2.5 ring-2 transition-all selection:bg-transparent",
1703
+ ...r,
1704
+ ref: t,
1705
+ children: u("p", {
1706
+ class: "text-center text-base",
1707
+ children: e
1708
+ })
1709
+ })), $s = ({
1710
+ input: e,
1711
+ onSubmitSuccess: r
1712
+ }) => {
1713
+ const t = Nt();
1714
+ return u("form", {
1715
+ noValidate: !0,
1716
+ class: "",
1717
+ onSubmit: (n) => {
1718
+ n.preventDefault();
1719
+ const s = En(n).value, i = Ss(Ts, s);
1720
+ r({
1721
+ type: "boolean",
1722
+ value: i === "true"
1723
+ });
1724
+ },
1725
+ children: [u("ul", {
1726
+ class: Gr,
1727
+ children: Kr.map((n, s) => u("li", {
1728
+ class: Hr,
1729
+ children: u(Jr, {
1730
+ ref: s === 0 ? t : null,
1731
+ type: "submit",
1732
+ name: Os,
1733
+ value: n,
1734
+ label: e.config.labels[n]
1735
+ }, n)
1736
+ }))
1737
+ }), e.config.optional && u("div", {
1738
+ class: "px-2 pb-2",
1739
+ children: u(Ee, {
1740
+ class: "relative w-full",
1741
+ type: "button",
1742
+ onClick: () => r(null)
1743
+ })
1744
+ })]
1745
+ });
1746
+ }, Bs = (e) => new Promise((r, t) => {
1747
+ const n = new FileReader();
1748
+ n.onload = () => {
1749
+ if (typeof n.result != "string" || !n.result)
1750
+ return t(new Error("Invalid file"));
1751
+ r(n.result);
1752
+ }, n.onerror = t, n.readAsDataURL(e);
1753
+ }), Yt = (e) => e.reduce((r, t) => r + t.sizeKb, 0), js = Ue("file"), Qt = 3, ft = (e) => {
1754
+ const r = e.lastIndexOf(".");
1755
+ return r === -1 ? [e, ""] : [e.slice(0, r), e.slice(r)];
1756
+ }, Ps = ({
1757
+ file: e,
1758
+ class: r,
1759
+ ...t
1760
+ }) => {
1761
+ const {
1762
+ t: n
1763
+ } = Q(), [s, i] = ft(e.name);
1764
+ return u("div", {
1765
+ class: qe("bg-accent-1 outline-accent-4 flex max-w-full gap-2 overflow-hidden rounded-lg px-3 py-2 text-sm outline", r),
1766
+ ...t,
1767
+ children: [u("p", {
1768
+ class: "text-accent-12 flex flex-grow overflow-hidden",
1769
+ children: [u("span", {
1770
+ class: "sr-only",
1771
+ children: [n("file_name"), ": "]
1772
+ }), u("span", {
1773
+ class: "block truncate",
1774
+ children: s
1775
+ }), u("span", {
1776
+ children: i
1777
+ })]
1778
+ }), u("p", {
1779
+ class: "text-accent-11",
1780
+ children: [u("span", {
1781
+ class: "sr-only",
1782
+ children: [n("file_size"), ": "]
1783
+ }), $e(e.sizeKb)]
1784
+ })]
1785
+ });
1786
+ }, er = ({
1787
+ class: e,
1788
+ ...r
1789
+ }) => u("li", {
1790
+ class: qe("outline-neutral-6 text-neutral-11 bg-neutral-1 block rounded-md px-1 py-0.5 text-xs outline outline-1", e),
1791
+ ...r
1792
+ }), qs = (e, r) => {
1793
+ const [t, n] = ft(e);
1794
+ return `${t.slice(0, r)}${n}`;
1795
+ }, tr = (e) => ({
1796
+ name: qs(e.name, 42),
1797
+ sizeKb: e.size / 1e3
1798
+ }), Us = [".heic", ".heif", ".jpg", ".jpeg", ".png", ".gif", ".webp", ".txt", ".rtf", ".odt", ".pages", ".zip"], Ws = (e, r, t) => {
1799
+ const n = ft(r.name)[1].toLowerCase(), s = [...t.map((a) => a.toLowerCase()), ...Us], i = n === "" ? "none" : s.includes(n) ? n : "other";
1800
+ return `chatbot-file-refused:${e}:${i}`;
1801
+ }, zs = ({
1802
+ input: e,
1803
+ onSubmitSuccess: r,
1804
+ analytics: t
1805
+ }) => {
1806
+ var C;
1807
+ const n = (C = j.current$.value.flow) == null ? void 0 : C.data.submissions[e.key], [s, i] = ve(js(n) && n.value.length ? {
1808
+ status: "ready",
1809
+ files: n.value
1810
+ } : {
1811
+ status: "empty"
1812
+ }), a = de(0), o = s.status === "ready" ? s.files : [], c = s.status === "ready" || s.status === "pending" ? s.files : [], p = s.status === "error" ? s.error : void 0, g = c.length - Qt, b = Yt(c), h = Nt(), {
1813
+ t: m
1814
+ } = Q(), w = (_) => {
1815
+ if (!_.length)
1816
+ return {
1817
+ reason: "required",
1818
+ error: {
1819
+ type: "required",
1820
+ message: m("validation_file")
1821
+ }
1822
+ };
1823
+ if (!Kt(_, e.config.extensions))
1824
+ return {
1825
+ reason: "type",
1826
+ file: _.find((y) => !Kt([y], e.config.extensions)),
1827
+ error: {
1828
+ type: "validate",
1829
+ message: m("validation_file_ext", {
1830
+ ext: e.config.extensions.join(", ")
1831
+ })
1832
+ }
1833
+ };
1834
+ if (_.some((y) => y.sizeKb === 0))
1835
+ return {
1836
+ reason: "empty",
1837
+ file: _.find((y) => y.sizeKb === 0),
1838
+ error: {
1839
+ type: "validate",
1840
+ message: m("validation_file_empty")
1841
+ }
1842
+ };
1843
+ if (e.config.fileSizeLimitKib && Yt(_) > e.config.fileSizeLimitKib)
1844
+ return {
1845
+ reason: "size",
1846
+ error: {
1847
+ type: "max",
1848
+ message: m("validation_file_size", {
1849
+ size: $e(e.config.fileSizeLimitKib)
1850
+ })
1851
+ }
1852
+ };
1853
+ if (!e.config.allowMultiple && _.length > 1)
1854
+ return {
1855
+ reason: "count",
1856
+ error: {
1857
+ type: "invalid",
1858
+ message: m("validation_file_max", {
1859
+ count: 1
1860
+ })
1861
+ }
1862
+ };
1863
+ }, S = (_, y) => {
1864
+ var E, A;
1865
+ return t.log({
1866
+ event: "INTERACTION",
1867
+ properties: {
1868
+ tag: Ws(_, y, e.config.extensions)
1869
+ },
1870
+ customProperties: (A = (E = j.current$.peek().flow) == null ? void 0 : E.analytics) == null ? void 0 : A.customProperties
1871
+ });
1872
+ };
1873
+ return u("form", {
1874
+ class: "flex flex-col gap-1 p-2.5",
1875
+ onSubmit: (_) => {
1876
+ if (_.preventDefault(), s.status === "pending" || s.status === "error")
1877
+ return;
1878
+ const y = w(o);
1879
+ y ? i({
1880
+ status: "error",
1881
+ error: y.error
1882
+ }) : r({
1883
+ type: "file",
1884
+ value: o
1885
+ });
1886
+ },
1887
+ children: [u("div", {
1888
+ class: "flex items-center gap-2",
1889
+ children: [u("label", {
1890
+ ref: h,
1891
+ for: "dropzone-file",
1892
+ class: "border-neutral-8 bg-neutral-2 flex h-48 w-full cursor-pointer flex-col items-center justify-center overflow-hidden rounded-2xl border border-dashed p-4",
1893
+ children: [c.length > 0 ? u("ul", {
1894
+ class: "flex max-w-full flex-wrap justify-center gap-1 overflow-hidden p-1",
1895
+ children: [c.slice(0, Qt).map((_) => {
1896
+ const [y, E] = ft(_.name);
1897
+ return u(er, {
1898
+ class: "flex overflow-hidden",
1899
+ children: [u("span", {
1900
+ class: "block truncate",
1901
+ children: y
1902
+ }), u("span", {
1903
+ children: E
1904
+ })]
1905
+ });
1906
+ }), g > 0 ? u(er, {
1907
+ children: m("file_more", {
1908
+ count: g
1909
+ })
1910
+ }) : null]
1911
+ }) : u("div", {
1912
+ class: "flex flex-col justify-center gap-4 pb-6 pt-5",
1913
+ children: [u("header", {
1914
+ class: "flex flex-col items-center gap-0",
1915
+ children: [u("svg", {
1916
+ class: "text-neutral-11 mb-1 h-8 w-8",
1917
+ "aria-hidden": "true",
1918
+ xmlns: "http://www.w3.org/2000/svg",
1919
+ fill: "none",
1920
+ viewBox: "0 0 20 16",
1921
+ children: u("path", {
1922
+ stroke: "currentColor",
1923
+ "stroke-linecap": "round",
1924
+ "stroke-linejoin": "round",
1925
+ "stroke-width": "1.5",
1926
+ d: "M13 13h3a3 3 0 0 0 0-6h-.025A5.56 5.56 0 0 0 16 6.5 5.5 5.5 0 0 0 5.207 5.021C5.137 5.017 5.071 5 5 5a4 4 0 0 0 0 8h2.167M10 15V6m0 0L8 8m2-2 2 2"
1927
+ })
1928
+ }), u("p", {
1929
+ class: "text-neutral-12 tracking-[-0.01em]",
1930
+ children: m("upload_file", {
1931
+ count: e.config.allowMultiple ? 2 : 1
1932
+ })
1933
+ }), e.config.fileSizeLimitKib ? u("p", {
1934
+ class: "text-neutral-11 text-xs",
1935
+ children: ["(", m("file_max_size", {
1936
+ size: $e(e.config.fileSizeLimitKib)
1937
+ }), ")"]
1938
+ }) : null]
1939
+ }), u("aside", {
1940
+ class: "flex flex-col items-center gap-2",
1941
+ children: [u("p", {
1942
+ id: "accepted-filetypes",
1943
+ class: "sr-only",
1944
+ children: m("file_extensions")
1945
+ }), u("ul", {
1946
+ "aria-describedby": "accepted-filetypes",
1947
+ class: "flex flex-wrap justify-center gap-2",
1948
+ children: e.config.extensions.map((_) => u("li", {
1949
+ class: "ring-lowest outline-neutral-6 text-neutral-11 bg-neutral-1 rounded-md px-1 py-0.5 text-[11px] uppercase tracking-wide outline outline-1 ring-2",
1950
+ children: _.replace(".", "")
1951
+ }))
1952
+ })]
1953
+ })]
1954
+ }), u("p", {
1955
+ role: "status",
1956
+ class: qe("text-neutral-11 flex items-center gap-1.5 text-xs", c.length === 0 && "sr-only"),
1957
+ children: s.status === "pending" ? u(we, {
1958
+ children: [u(Et, {
1959
+ "aria-hidden": "true",
1960
+ class: "h-4 w-4"
1961
+ }), m("file_preparing", {
1962
+ count: c.length
1963
+ })]
1964
+ }) : s.status === "ready" ? u(we, {
1965
+ children: [o.length > 1 ? m("file_total_size", {
1966
+ size: $e(b)
1967
+ }) : $e(b), u("span", {
1968
+ class: "sr-only",
1969
+ children: [". ", m("file_ready", {
1970
+ count: o.length
1971
+ })]
1972
+ })]
1973
+ }) : null
1974
+ }), u("input", {
1975
+ id: "dropzone-file",
1976
+ "aria-label": m("upload_file", {
1977
+ count: e.config.allowMultiple ? 2 : 1
1978
+ }),
1979
+ onInput: async (_) => {
1980
+ Ne(_.target instanceof HTMLInputElement);
1981
+ const y = _.target.files ? Array.from(_.target.files) : [];
1982
+ _.target.value = "";
1983
+ const [E] = y;
1984
+ if (!E)
1985
+ return;
1986
+ const A = ++a.current, V = s.status === "ready", L = y.map(tr), U = w(L);
1987
+ if (U)
1988
+ return S(U.reason, U.file ?? E), i({
1989
+ status: "error",
1990
+ error: U.error
1991
+ });
1992
+ i({
1993
+ status: "pending",
1994
+ files: L
1995
+ });
1996
+ let T;
1997
+ try {
1998
+ const q = await Promise.all(y.map(async (O) => {
1999
+ try {
2000
+ return {
2001
+ ...tr(O),
2002
+ data: await Bs(O)
2003
+ };
2004
+ } catch (J) {
2005
+ throw T ?? (T = O), J;
2006
+ }
2007
+ }));
2008
+ a.current === A && i({
2009
+ status: "ready",
2010
+ files: q
2011
+ });
2012
+ } catch {
2013
+ if (a.current !== A)
2014
+ return;
2015
+ S("unreadable", T ?? E), i({
2016
+ status: "error",
2017
+ error: {
2018
+ type: "invalid",
2019
+ message: m(V ? "file_read_error_replacement" : "file_read_error")
2020
+ }
2021
+ });
2022
+ }
2023
+ },
2024
+ multiple: e.config.allowMultiple,
2025
+ accept: e.config.extensions.join(","),
2026
+ type: "file",
2027
+ class: "sr-only"
2028
+ })]
2029
+ }), u("div", {
2030
+ class: "flex h-full flex-col items-center gap-2",
2031
+ children: [u(Re, {
2032
+ disabled: o.length === 0
2033
+ }), e.config.optional && u(Ee, {
2034
+ class: "relative",
2035
+ onClick: () => r(null)
2036
+ })]
2037
+ })]
2038
+ }), u(We, {
2039
+ error: p
2040
+ })]
2041
+ });
2042
+ };
2043
+ var rt = (e) => e.type === "checkbox", Le = (e) => e instanceof Date, ne = (e) => e == null;
2044
+ const Xr = (e) => typeof e == "object";
2045
+ var G = (e) => !ne(e) && !Array.isArray(e) && Xr(e) && !Le(e), Ks = (e) => G(e) && e.target ? rt(e.target) ? e.target.checked : e.target.value : e, Gs = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, Hs = (e, r) => e.has(Gs(r)), Js = (e) => {
2046
+ const r = e.constructor && e.constructor.prototype;
2047
+ return G(r) && r.hasOwnProperty("isPrototypeOf");
2048
+ }, Rt = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
2049
+ function H(e) {
2050
+ if (e instanceof Date)
2051
+ return new Date(e);
2052
+ const r = typeof FileList < "u" && e instanceof FileList;
2053
+ if (Rt && (e instanceof Blob || r))
2054
+ return e;
2055
+ const t = Array.isArray(e);
2056
+ if (!t && !(G(e) && Js(e)))
2057
+ return e;
2058
+ const n = t ? [] : Object.create(Object.getPrototypeOf(e));
2059
+ for (const s in e)
2060
+ Object.prototype.hasOwnProperty.call(e, s) && (n[s] = H(e[s]));
2061
+ return n;
2062
+ }
2063
+ var ht = (e) => /^\w*$/.test(e), W = (e) => e === void 0, Dt = (e) => Array.isArray(e) ? e.filter(Boolean) : [], Tt = (e) => Dt(e.replace(/["|']|\]/g, "").split(/\.|\[/)), I = (e, r, t) => {
2064
+ if (!r || !G(e))
2065
+ return t;
2066
+ const n = (ht(r) ? [r] : Tt(r)).reduce((s, i) => ne(s) ? s : s[i], e);
2067
+ return W(n) || n === e ? W(e[r]) ? t : e[r] : n;
2068
+ }, ce = (e) => typeof e == "boolean", le = (e) => typeof e == "function", P = (e, r, t) => {
2069
+ let n = -1;
2070
+ const s = ht(r) ? [r] : Tt(r), i = s.length, a = i - 1;
2071
+ for (; ++n < i; ) {
2072
+ const o = s[n];
2073
+ let c = t;
2074
+ if (n !== a) {
2075
+ const p = e[o];
2076
+ c = G(p) || Array.isArray(p) ? p : isNaN(+s[n + 1]) ? {} : [];
2077
+ }
2078
+ if (o === "__proto__" || o === "constructor" || o === "prototype")
2079
+ return;
2080
+ e[o] = c, e = e[o];
2081
+ }
2082
+ };
2083
+ const rr = {
2084
+ BLUR: "blur",
2085
+ FOCUS_OUT: "focusout",
2086
+ CHANGE: "change"
2087
+ }, ue = {
2088
+ onBlur: "onBlur",
2089
+ onChange: "onChange",
2090
+ onSubmit: "onSubmit",
2091
+ onTouched: "onTouched",
2092
+ all: "all"
2093
+ }, be = {
2094
+ max: "max",
2095
+ min: "min",
2096
+ maxLength: "maxLength",
2097
+ minLength: "minLength",
2098
+ pattern: "pattern",
2099
+ required: "required",
2100
+ validate: "validate"
2101
+ }, Xs = te.createContext(null);
2102
+ Xs.displayName = "HookFormControlContext";
2103
+ var Zs = (e, r, t, n = !0) => {
2104
+ const s = {
2105
+ defaultValues: r._defaultValues
2106
+ };
2107
+ for (const i in e)
2108
+ Object.defineProperty(s, i, {
2109
+ get: () => {
2110
+ const a = i;
2111
+ return r._proxyFormState[a] !== ue.all && (r._proxyFormState[a] = !n || ue.all), t && (t[a] = !0), e[a];
2112
+ }
2113
+ });
2114
+ return s;
2115
+ };
2116
+ const Ys = typeof window < "u" ? te.useLayoutEffect : te.useEffect;
2117
+ var ae = (e) => typeof e == "string", Qs = (e, r, t, n, s) => ae(e) ? (n && r.watch.add(e), I(t, e, s)) : Array.isArray(e) ? e.map((i) => (n && r.watch.add(i), I(t, i))) : (n && (r.watchAll = !0), t), It = (e) => ne(e) || !Xr(e);
2118
+ function Se(e, r, t = /* @__PURE__ */ new WeakSet()) {
2119
+ if (It(e) || It(r))
2120
+ return Object.is(e, r);
2121
+ if (Le(e) && Le(r))
2122
+ return Object.is(e.getTime(), r.getTime());
2123
+ const n = Object.keys(e), s = Object.keys(r);
2124
+ if (n.length !== s.length)
2125
+ return !1;
2126
+ if (t.has(e) || t.has(r))
2127
+ return !0;
2128
+ t.add(e), t.add(r);
2129
+ for (const i of n) {
2130
+ const a = e[i];
2131
+ if (!s.includes(i))
2132
+ return !1;
2133
+ if (i !== "ref") {
2134
+ const o = r[i];
2135
+ if (Le(a) && Le(o) || G(a) && G(o) || Array.isArray(a) && Array.isArray(o) ? !Se(a, o, t) : !Object.is(a, o))
2136
+ return !1;
2137
+ }
2138
+ }
2139
+ return !0;
2140
+ }
2141
+ const ea = te.createContext(null);
2142
+ ea.displayName = "HookFormContext";
2143
+ var Zr = (e, r, t, n, s) => r ? {
2144
+ ...t[e],
2145
+ types: {
2146
+ ...t[e] && t[e].types ? t[e].types : {},
2147
+ [n]: s || !0
2148
+ }
2149
+ } : {}, et = (e) => Array.isArray(e) ? e : [e], nr = () => {
2150
+ let e = [];
2151
+ return {
2152
+ get observers() {
2153
+ return e;
2154
+ },
2155
+ next: (s) => {
2156
+ for (const i of e)
2157
+ i.next && i.next(s);
2158
+ },
2159
+ subscribe: (s) => (e.push(s), {
2160
+ unsubscribe: () => {
2161
+ e = e.filter((i) => i !== s);
2162
+ }
2163
+ }),
2164
+ unsubscribe: () => {
2165
+ e = [];
2166
+ }
2167
+ };
2168
+ };
2169
+ function Yr(e, r) {
2170
+ const t = {};
2171
+ for (const n in e)
2172
+ if (e.hasOwnProperty(n)) {
2173
+ const s = e[n], i = r[n];
2174
+ if (s && G(s) && i) {
2175
+ const a = Yr(s, i);
2176
+ G(a) && (t[n] = a);
2177
+ } else
2178
+ e[n] && (t[n] = i);
2179
+ }
2180
+ return t;
2181
+ }
2182
+ var re = (e) => G(e) && !Object.keys(e).length, Ot = (e) => e.type === "file", ot = (e) => {
2183
+ if (!Rt)
2184
+ return !1;
2185
+ const r = e ? e.ownerDocument : 0;
2186
+ return e instanceof (r && r.defaultView ? r.defaultView.HTMLElement : HTMLElement);
2187
+ }, Qr = (e) => e.type === "select-multiple", $t = (e) => e.type === "radio", ta = (e) => $t(e) || rt(e), kt = (e) => ot(e) && e.isConnected;
2188
+ function ra(e, r) {
2189
+ const t = r.slice(0, -1).length;
2190
+ let n = 0;
2191
+ for (; n < t; )
2192
+ e = W(e) ? n++ : e[r[n++]];
2193
+ return e;
2194
+ }
2195
+ function na(e) {
2196
+ for (const r in e)
2197
+ if (e.hasOwnProperty(r) && !W(e[r]))
2198
+ return !1;
2199
+ return !0;
2200
+ }
2201
+ function K(e, r) {
2202
+ const t = Array.isArray(r) ? r : ht(r) ? [r] : Tt(r), n = t.length === 1 ? e : ra(e, t), s = t.length - 1, i = t[s];
2203
+ return n && delete n[i], s !== 0 && (G(n) && re(n) || Array.isArray(n) && na(n)) && K(e, t.slice(0, -1)), e;
2204
+ }
2205
+ var sa = (e) => {
2206
+ for (const r in e)
2207
+ if (le(e[r]))
2208
+ return !0;
2209
+ return !1;
2210
+ };
2211
+ function en(e) {
2212
+ return Array.isArray(e) || G(e) && !sa(e);
2213
+ }
2214
+ function At(e, r = {}) {
2215
+ for (const t in e) {
2216
+ const n = e[t];
2217
+ en(n) ? (r[t] = Array.isArray(n) ? [] : {}, At(n, r[t])) : W(n) || (r[t] = !0);
2218
+ }
2219
+ return r;
2220
+ }
2221
+ function Oe(e, r, t) {
2222
+ t || (t = At(r));
2223
+ for (const n in e) {
2224
+ const s = e[n];
2225
+ if (en(s))
2226
+ W(r) || It(t[n]) ? t[n] = At(s, Array.isArray(s) ? [] : {}) : Oe(s, ne(r) ? {} : r[n], t[n]);
2227
+ else {
2228
+ const i = r[n];
2229
+ t[n] = !Se(s, i);
2230
+ }
2231
+ }
2232
+ return t;
2233
+ }
2234
+ const sr = {
2235
+ value: !1,
2236
+ isValid: !1
2237
+ }, ar = { value: !0, isValid: !0 };
2238
+ var tn = (e) => {
2239
+ if (Array.isArray(e)) {
2240
+ if (e.length > 1) {
2241
+ const r = e.filter((t) => t && t.checked && !t.disabled).map((t) => t.value);
2242
+ return { value: r, isValid: !!r.length };
2243
+ }
2244
+ return e[0].checked && !e[0].disabled ? (
2245
+ // @ts-expect-error expected to work in the browser
2246
+ e[0].attributes && !W(e[0].attributes.value) ? W(e[0].value) || e[0].value === "" ? ar : { value: e[0].value, isValid: !0 } : ar
2247
+ ) : sr;
2248
+ }
2249
+ return sr;
2250
+ }, rn = (e, { valueAsNumber: r, valueAsDate: t, setValueAs: n }) => W(e) ? e : r ? e === "" ? NaN : e && +e : t && ae(e) ? new Date(e) : n ? n(e) : e;
2251
+ const ir = {
2252
+ isValid: !1,
2253
+ value: null
2254
+ };
2255
+ var nn = (e) => Array.isArray(e) ? e.reduce((r, t) => t && t.checked && !t.disabled ? {
2256
+ isValid: !0,
2257
+ value: t.value
2258
+ } : r, ir) : ir;
2259
+ function or(e) {
2260
+ const r = e.ref;
2261
+ return Ot(r) ? r.files : $t(r) ? nn(e.refs).value : Qr(r) ? [...r.selectedOptions].map(({ value: t }) => t) : rt(r) ? tn(e.refs).value : rn(W(r.value) ? e.ref.value : r.value, e);
2262
+ }
2263
+ var aa = (e, r, t, n) => {
2264
+ const s = {};
2265
+ for (const i of e) {
2266
+ const a = I(r, i);
2267
+ a && P(s, i, a._f);
2268
+ }
2269
+ return {
2270
+ criteriaMode: t,
2271
+ names: [...e],
2272
+ fields: s,
2273
+ shouldUseNativeValidation: n
2274
+ };
2275
+ }, lt = (e) => e instanceof RegExp, Je = (e) => W(e) ? e : lt(e) ? e.source : G(e) ? lt(e.value) ? e.value.source : e.value : e, lr = (e) => ({
2276
+ isOnSubmit: !e || e === ue.onSubmit,
2277
+ isOnBlur: e === ue.onBlur,
2278
+ isOnChange: e === ue.onChange,
2279
+ isOnAll: e === ue.all,
2280
+ isOnTouch: e === ue.onTouched
2281
+ });
2282
+ const ur = "AsyncFunction";
2283
+ var ia = (e) => !!e && !!e.validate && !!(le(e.validate) && e.validate.constructor.name === ur || G(e.validate) && Object.values(e.validate).find((r) => r.constructor.name === ur)), oa = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate), cr = (e, r, t) => !t && (r.watchAll || r.watch.has(e) || [...r.watch].some((n) => e.startsWith(n) && /^\.\w+/.test(e.slice(n.length))));
2284
+ const tt = (e, r, t, n) => {
2285
+ for (const s of t || Object.keys(e)) {
2286
+ const i = I(e, s);
2287
+ if (i) {
2288
+ const { _f: a, ...o } = i;
2289
+ if (a) {
2290
+ if (a.refs && a.refs[0] && r(a.refs[0], s) && !n)
2291
+ return !0;
2292
+ if (a.ref && r(a.ref, a.name) && !n)
2293
+ return !0;
2294
+ if (tt(o, r))
2295
+ break;
2296
+ } else if (G(o) && tt(o, r))
2297
+ break;
2298
+ }
2299
+ }
2300
+ };
2301
+ function dr(e, r, t) {
2302
+ const n = I(e, t);
2303
+ if (n || ht(t))
2304
+ return {
2305
+ error: n,
2306
+ name: t
2307
+ };
2308
+ const s = t.split(".");
2309
+ for (; s.length; ) {
2310
+ const i = s.join("."), a = I(r, i), o = I(e, i);
2311
+ if (a && !Array.isArray(a) && t !== i)
2312
+ return { name: t };
2313
+ if (o && o.type)
2314
+ return {
2315
+ name: i,
2316
+ error: o
2317
+ };
2318
+ if (o && o.root && o.root.type)
2319
+ return {
2320
+ name: `${i}.root`,
2321
+ error: o.root
2322
+ };
2323
+ s.pop();
2324
+ }
2325
+ return {
2326
+ name: t
2327
+ };
2328
+ }
2329
+ var la = (e, r, t, n) => {
2330
+ t(e);
2331
+ const { name: s, ...i } = e;
2332
+ return re(i) || Object.keys(i).length >= Object.keys(r).length || Object.keys(i).find((a) => r[a] === (!n || ue.all));
2333
+ }, ua = (e, r, t) => !e || !r || e === r || et(e).some((n) => n && (t ? n === r : n.startsWith(r) || r.startsWith(n))), ca = (e, r, t, n, s) => s.isOnAll ? !1 : !t && s.isOnTouch ? !(r || e) : (t ? n.isOnBlur : s.isOnBlur) ? !e : (t ? n.isOnChange : s.isOnChange) ? e : !0, da = (e, r) => !Dt(I(e, r)).length && K(e, r), fa = (e, r, t) => {
2334
+ const n = et(I(e, t));
2335
+ return P(n, "root", r[t]), P(e, t, n), e;
2336
+ };
2337
+ function fr(e, r, t = "validate") {
2338
+ if (ae(e) || Array.isArray(e) && e.every(ae) || ce(e) && !e)
2339
+ return {
2340
+ type: t,
2341
+ message: ae(e) ? e : "",
2342
+ ref: r
2343
+ };
2344
+ }
2345
+ var Te = (e) => G(e) && !lt(e) ? e : {
2346
+ value: e,
2347
+ message: ""
2348
+ }, hr = async (e, r, t, n, s, i) => {
2349
+ const { ref: a, refs: o, required: c, maxLength: p, minLength: g, min: b, max: h, pattern: m, validate: w, name: S, valueAsNumber: C, mount: _ } = e._f, y = I(t, S);
2350
+ if (!_ || r.has(S))
2351
+ return {};
2352
+ const E = o ? o[0] : a, A = (N) => {
2353
+ s && E.reportValidity && (E.setCustomValidity(ce(N) ? "" : N || ""), E.reportValidity());
2354
+ }, V = {}, L = $t(a), U = rt(a), T = L || U, q = (C || Ot(a)) && W(a.value) && W(y) || ot(a) && a.value === "" || y === "" || Array.isArray(y) && !y.length, O = Zr.bind(null, S, n, V), J = (N, R, M, z = be.maxLength, X = be.minLength) => {
2355
+ const Z = N ? R : M;
2356
+ V[S] = {
2357
+ type: N ? z : X,
2358
+ message: Z,
2359
+ ref: a,
2360
+ ...O(N ? z : X, Z)
2361
+ };
2362
+ };
2363
+ if (i ? !Array.isArray(y) || !y.length : c && (!T && (q || ne(y)) || ce(y) && !y || U && !tn(o).isValid || L && !nn(o).isValid)) {
2364
+ const { value: N, message: R } = ae(c) ? { value: !!c, message: c } : Te(c);
2365
+ if (N && (V[S] = {
2366
+ type: be.required,
2367
+ message: R,
2368
+ ref: E,
2369
+ ...O(be.required, R)
2370
+ }, !n))
2371
+ return A(R), V;
2372
+ }
2373
+ if (!q && (!ne(b) || !ne(h))) {
2374
+ let N, R;
2375
+ const M = Te(h), z = Te(b);
2376
+ if (!ne(y) && !isNaN(y)) {
2377
+ const X = a.valueAsNumber || y && +y;
2378
+ ne(M.value) || (N = X > M.value), ne(z.value) || (R = X < z.value);
2379
+ } else {
2380
+ const X = a.valueAsDate || new Date(y), Z = (pe) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + pe), oe = a.type == "time", _e = a.type == "week";
2381
+ ae(M.value) && y && (N = oe ? Z(y) > Z(M.value) : _e ? y > M.value : X > new Date(M.value)), ae(z.value) && y && (R = oe ? Z(y) < Z(z.value) : _e ? y < z.value : X < new Date(z.value));
2382
+ }
2383
+ if ((N || R) && (J(!!N, M.message, z.message, be.max, be.min), !n))
2384
+ return A(V[S].message), V;
2385
+ }
2386
+ if ((p || g) && !q && (ae(y) || i && Array.isArray(y))) {
2387
+ const N = Te(p), R = Te(g), M = !ne(N.value) && y.length > +N.value, z = !ne(R.value) && y.length < +R.value;
2388
+ if ((M || z) && (J(M, N.message, R.message), !n))
2389
+ return A(V[S].message), V;
2390
+ }
2391
+ if (m && !q && ae(y)) {
2392
+ const { value: N, message: R } = Te(m);
2393
+ if (lt(N) && !y.match(N) && (V[S] = {
2394
+ type: be.pattern,
2395
+ message: R,
2396
+ ref: a,
2397
+ ...O(be.pattern, R)
2398
+ }, !n))
2399
+ return A(R), V;
2400
+ }
2401
+ if (w) {
2402
+ if (le(w)) {
2403
+ const N = await w(y, t), R = fr(N, E);
2404
+ if (R && (V[S] = {
2405
+ ...R,
2406
+ ...O(be.validate, R.message)
2407
+ }, !n))
2408
+ return A(R.message), V;
2409
+ } else if (G(w)) {
2410
+ let N = {};
2411
+ for (const R in w) {
2412
+ if (!re(N) && !n)
2413
+ break;
2414
+ const M = fr(await w[R](y, t), E, R);
2415
+ M && (N = {
2416
+ ...M,
2417
+ ...O(R, M.message)
2418
+ }, A(M.message), n && (V[S] = N));
2419
+ }
2420
+ if (!re(N) && (V[S] = {
2421
+ ref: E,
2422
+ ...N
2423
+ }, !n))
2424
+ return V;
2425
+ }
2426
+ }
2427
+ return A(!0), V;
2428
+ };
2429
+ const ha = {
2430
+ mode: ue.onSubmit,
2431
+ reValidateMode: ue.onChange,
2432
+ shouldFocusError: !0
2433
+ };
2434
+ function pa(e = {}) {
2435
+ let r = {
2436
+ ...ha,
2437
+ ...e
2438
+ }, t = {
2439
+ submitCount: 0,
2440
+ isDirty: !1,
2441
+ isReady: !1,
2442
+ isLoading: le(r.defaultValues),
2443
+ isValidating: !1,
2444
+ isSubmitted: !1,
2445
+ isSubmitting: !1,
2446
+ isSubmitSuccessful: !1,
2447
+ isValid: !1,
2448
+ touchedFields: {},
2449
+ dirtyFields: {},
2450
+ validatingFields: {},
2451
+ errors: r.errors || {},
2452
+ disabled: r.disabled || !1
2453
+ }, n = {}, s = G(r.defaultValues) || G(r.values) ? H(r.defaultValues || r.values) || {} : {}, i = r.shouldUnregister ? {} : H(s), a = {
2454
+ action: !1,
2455
+ mount: !1,
2456
+ watch: !1,
2457
+ keepIsValid: !1
2458
+ }, o = {
2459
+ mount: /* @__PURE__ */ new Set(),
2460
+ disabled: /* @__PURE__ */ new Set(),
2461
+ unMount: /* @__PURE__ */ new Set(),
2462
+ array: /* @__PURE__ */ new Set(),
2463
+ watch: /* @__PURE__ */ new Set()
2464
+ }, c, p = 0;
2465
+ const g = {
2466
+ isDirty: !1,
2467
+ dirtyFields: !1,
2468
+ validatingFields: !1,
2469
+ touchedFields: !1,
2470
+ isValidating: !1,
2471
+ isValid: !1,
2472
+ errors: !1
2473
+ }, b = {
2474
+ ...g
2475
+ };
2476
+ let h = {
2477
+ ...b
2478
+ };
2479
+ const m = {
2480
+ array: nr(),
2481
+ state: nr()
2482
+ }, w = r.criteriaMode === ue.all, S = (l) => (d) => {
2483
+ clearTimeout(p), p = setTimeout(l, d);
2484
+ }, C = async (l) => {
2485
+ if (!a.keepIsValid && !r.disabled && (b.isValid || h.isValid || l)) {
2486
+ let d;
2487
+ r.resolver ? (d = re((await T()).errors), _()) : d = await O(n, !0), d !== t.isValid && m.state.next({
2488
+ isValid: d
2489
+ });
2490
+ }
2491
+ }, _ = (l, d) => {
2492
+ !r.disabled && (b.isValidating || b.validatingFields || h.isValidating || h.validatingFields) && ((l || Array.from(o.mount)).forEach((f) => {
2493
+ f && (d ? P(t.validatingFields, f, d) : K(t.validatingFields, f));
2494
+ }), m.state.next({
2495
+ validatingFields: t.validatingFields,
2496
+ isValidating: !re(t.validatingFields)
2497
+ }));
2498
+ }, y = (l, d = [], f, k, x = !0, v = !0) => {
2499
+ if (k && f && !r.disabled) {
2500
+ if (a.action = !0, v && Array.isArray(I(n, l))) {
2501
+ const F = f(I(n, l), k.argA, k.argB);
2502
+ x && P(n, l, F);
2503
+ }
2504
+ if (v && Array.isArray(I(t.errors, l))) {
2505
+ const F = f(I(t.errors, l), k.argA, k.argB);
2506
+ x && P(t.errors, l, F), da(t.errors, l);
2507
+ }
2508
+ if ((b.touchedFields || h.touchedFields) && v && Array.isArray(I(t.touchedFields, l))) {
2509
+ const F = f(I(t.touchedFields, l), k.argA, k.argB);
2510
+ x && P(t.touchedFields, l, F);
2511
+ }
2512
+ (b.dirtyFields || h.dirtyFields) && (t.dirtyFields = Oe(s, i)), m.state.next({
2513
+ name: l,
2514
+ isDirty: N(l, d),
2515
+ dirtyFields: t.dirtyFields,
2516
+ errors: t.errors,
2517
+ isValid: t.isValid
2518
+ });
2519
+ } else
2520
+ P(i, l, d);
2521
+ }, E = (l, d) => {
2522
+ P(t.errors, l, d), m.state.next({
2523
+ errors: t.errors
2524
+ });
2525
+ }, A = (l) => {
2526
+ t.errors = l, m.state.next({
2527
+ errors: t.errors,
2528
+ isValid: !1
2529
+ });
2530
+ }, V = (l, d, f, k) => {
2531
+ const x = I(n, l);
2532
+ if (x) {
2533
+ const v = I(i, l, W(f) ? I(s, l) : f);
2534
+ W(v) || k && k.defaultChecked || d ? P(i, l, d ? v : or(x._f)) : z(l, v), a.mount && !a.action && C();
2535
+ }
2536
+ }, L = (l, d, f, k, x) => {
2537
+ let v = !1, F = !1;
2538
+ const $ = {
2539
+ name: l
2540
+ };
2541
+ if (!r.disabled) {
2542
+ if (!f || k) {
2543
+ (b.isDirty || h.isDirty) && (F = t.isDirty, t.isDirty = $.isDirty = N(), v = F !== $.isDirty);
2544
+ const B = Se(I(s, l), d);
2545
+ F = !!I(t.dirtyFields, l), B ? K(t.dirtyFields, l) : P(t.dirtyFields, l, !0), $.dirtyFields = t.dirtyFields, v = v || (b.dirtyFields || h.dirtyFields) && F !== !B;
2546
+ }
2547
+ if (f) {
2548
+ const B = I(t.touchedFields, l);
2549
+ B || (P(t.touchedFields, l, f), $.touchedFields = t.touchedFields, v = v || (b.touchedFields || h.touchedFields) && B !== f);
2550
+ }
2551
+ v && x && m.state.next($);
2552
+ }
2553
+ return v ? $ : {};
2554
+ }, U = (l, d, f, k) => {
2555
+ const x = I(t.errors, l), v = (b.isValid || h.isValid) && ce(d) && t.isValid !== d;
2556
+ if (r.delayError && f ? (c = S(() => E(l, f)), c(r.delayError)) : (clearTimeout(p), c = null, f ? P(t.errors, l, f) : K(t.errors, l)), (f ? !Se(x, f) : x) || !re(k) || v) {
2557
+ const F = {
2558
+ ...k,
2559
+ ...v && ce(d) ? { isValid: d } : {},
2560
+ errors: t.errors,
2561
+ name: l
2562
+ };
2563
+ t = {
2564
+ ...t,
2565
+ ...F
2566
+ }, m.state.next(F);
2567
+ }
2568
+ }, T = async (l) => (_(l, !0), await r.resolver(i, r.context, aa(l || o.mount, n, r.criteriaMode, r.shouldUseNativeValidation))), q = async (l) => {
2569
+ const { errors: d } = await T(l);
2570
+ if (_(l), l)
2571
+ for (const f of l) {
2572
+ const k = I(d, f);
2573
+ k ? P(t.errors, f, k) : K(t.errors, f);
2574
+ }
2575
+ else
2576
+ t.errors = d;
2577
+ return d;
2578
+ }, O = async (l, d, f = {
2579
+ valid: !0
2580
+ }) => {
2581
+ for (const k in l) {
2582
+ const x = l[k];
2583
+ if (x) {
2584
+ const { _f: v, ...F } = x;
2585
+ if (v) {
2586
+ const $ = o.array.has(v.name), B = x._f && ia(x._f);
2587
+ B && b.validatingFields && _([v.name], !0);
2588
+ const ee = await hr(x, o.disabled, i, w, r.shouldUseNativeValidation && !d, $);
2589
+ if (B && b.validatingFields && _([v.name]), ee[v.name] && (f.valid = !1, d || e.shouldUseNativeValidation))
2590
+ break;
2591
+ !d && (I(ee, v.name) ? $ ? fa(t.errors, ee, v.name) : P(t.errors, v.name, ee[v.name]) : K(t.errors, v.name));
2592
+ }
2593
+ !re(F) && await O(F, d, f);
2594
+ }
2595
+ }
2596
+ return f.valid;
2597
+ }, J = () => {
2598
+ for (const l of o.unMount) {
2599
+ const d = I(n, l);
2600
+ d && (d._f.refs ? d._f.refs.every((f) => !kt(f)) : !kt(d._f.ref)) && De(l);
2601
+ }
2602
+ o.unMount = /* @__PURE__ */ new Set();
2603
+ }, N = (l, d) => !r.disabled && (l && d && P(i, l, d), !Se(Fe(), s)), R = (l, d, f) => Qs(l, o, {
2604
+ ...a.mount ? i : W(d) ? s : ae(l) ? { [l]: d } : d
2605
+ }, f, d), M = (l) => Dt(I(a.mount ? i : s, l, r.shouldUnregister ? I(s, l, []) : [])), z = (l, d, f = {}) => {
2606
+ const k = I(n, l);
2607
+ let x = d;
2608
+ if (k) {
2609
+ const v = k._f;
2610
+ v && (!v.disabled && P(i, l, rn(d, v)), x = ot(v.ref) && ne(d) ? "" : d, Qr(v.ref) ? [...v.ref.options].forEach((F) => F.selected = x.includes(F.value)) : v.refs ? rt(v.ref) ? v.refs.forEach((F) => {
2611
+ (!F.defaultChecked || !F.disabled) && (Array.isArray(x) ? F.checked = !!x.find(($) => $ === F.value) : F.checked = x === F.value || !!x);
2612
+ }) : v.refs.forEach((F) => F.checked = F.value === x) : Ot(v.ref) ? v.ref.value = "" : (v.ref.value = x, v.ref.type || m.state.next({
2613
+ name: l,
2614
+ values: H(i)
2615
+ })));
2616
+ }
2617
+ (f.shouldDirty || f.shouldTouch) && L(l, x, f.shouldTouch, f.shouldDirty, !0), f.shouldValidate && pe(l);
2618
+ }, X = (l, d, f) => {
2619
+ for (const k in d) {
2620
+ if (!d.hasOwnProperty(k))
2621
+ return;
2622
+ const x = d[k], v = l + "." + k, F = I(n, v);
2623
+ (o.array.has(l) || G(x) || F && !F._f) && !Le(x) ? X(v, x, f) : z(v, x, f);
2624
+ }
2625
+ }, Z = (l, d, f = {}) => {
2626
+ const k = I(n, l), x = o.array.has(l), v = H(d);
2627
+ P(i, l, v), x ? (m.array.next({
2628
+ name: l,
2629
+ values: H(i)
2630
+ }), (b.isDirty || b.dirtyFields || h.isDirty || h.dirtyFields) && f.shouldDirty && m.state.next({
2631
+ name: l,
2632
+ dirtyFields: Oe(s, i),
2633
+ isDirty: N(l, v)
2634
+ })) : k && !k._f && !ne(v) ? X(l, v, f) : z(l, v, f), cr(l, o) ? m.state.next({
2635
+ ...t,
2636
+ name: l,
2637
+ values: H(i)
2638
+ }) : m.state.next({
2639
+ name: a.mount ? l : void 0,
2640
+ values: H(i)
2641
+ });
2642
+ }, oe = async (l) => {
2643
+ a.mount = !0;
2644
+ const d = l.target;
2645
+ let f = d.name, k = !0;
2646
+ const x = I(n, f), v = (B) => {
2647
+ k = Number.isNaN(B) || Le(B) && isNaN(B.getTime()) || Se(B, I(i, f, B));
2648
+ }, F = lr(r.mode), $ = lr(r.reValidateMode);
2649
+ if (x) {
2650
+ let B, ee;
2651
+ const Me = d.type ? or(x._f) : Ks(l), Ce = l.type === rr.BLUR || l.type === rr.FOCUS_OUT, un = !oa(x._f) && !r.resolver && !I(t.errors, f) && !x._f.deps || ca(Ce, I(t.touchedFields, f), t.isSubmitted, $, F), yt = cr(f, o, Ce);
2652
+ P(i, f, Me), Ce ? (!d || !d.readOnly) && (x._f.onBlur && x._f.onBlur(l), c && c(0)) : x._f.onChange && x._f.onChange(l);
2653
+ const gt = L(f, Me, Ce), cn = !re(gt) || yt;
2654
+ if (!Ce && m.state.next({
2655
+ name: f,
2656
+ type: l.type,
2657
+ values: H(i)
2658
+ }), un)
2659
+ return (b.isValid || h.isValid) && (r.mode === "onBlur" ? Ce && C() : Ce || C()), cn && m.state.next({ name: f, ...yt ? {} : gt });
2660
+ if (!Ce && yt && m.state.next({ ...t }), r.resolver) {
2661
+ const { errors: qt } = await T([f]);
2662
+ if (_([f]), v(Me), k) {
2663
+ const dn = dr(t.errors, n, f), Ut = dr(qt, n, dn.name || f);
2664
+ B = Ut.error, f = Ut.name, ee = re(qt);
2665
+ }
2666
+ } else
2667
+ _([f], !0), B = (await hr(x, o.disabled, i, w, r.shouldUseNativeValidation))[f], _([f]), v(Me), k && (B ? ee = !1 : (b.isValid || h.isValid) && (ee = await O(n, !0)));
2668
+ k && (x._f.deps && (!Array.isArray(x._f.deps) || x._f.deps.length > 0) && pe(x._f.deps), U(f, ee, B, gt));
2669
+ }
2670
+ }, _e = (l, d) => {
2671
+ if (I(t.errors, d) && l.focus)
2672
+ return l.focus(), 1;
2673
+ }, pe = async (l, d = {}) => {
2674
+ let f, k;
2675
+ const x = et(l);
2676
+ if (r.resolver) {
2677
+ const v = await q(W(l) ? l : x);
2678
+ f = re(v), k = l ? !x.some((F) => I(v, F)) : f;
2679
+ } else
2680
+ l ? (k = (await Promise.all(x.map(async (v) => {
2681
+ const F = I(n, v);
2682
+ return await O(F && F._f ? { [v]: F } : F);
2683
+ }))).every(Boolean), !(!k && !t.isValid) && C()) : k = f = await O(n);
2684
+ return m.state.next({
2685
+ ...!ae(l) || (b.isValid || h.isValid) && f !== t.isValid ? {} : { name: l },
2686
+ ...r.resolver || !l ? { isValid: f } : {},
2687
+ errors: t.errors
2688
+ }), d.shouldFocus && !k && tt(n, _e, l ? x : o.mount), k;
2689
+ }, Fe = (l, d) => {
2690
+ let f = {
2691
+ ...a.mount ? i : s
2692
+ };
2693
+ return d && (f = Yr(d.dirtyFields ? t.dirtyFields : t.touchedFields, f)), W(l) ? f : ae(l) ? I(f, l) : l.map((k) => I(f, k));
2694
+ }, Ve = (l, d) => ({
2695
+ invalid: !!I((d || t).errors, l),
2696
+ isDirty: !!I((d || t).dirtyFields, l),
2697
+ error: I((d || t).errors, l),
2698
+ isValidating: !!I(t.validatingFields, l),
2699
+ isTouched: !!I((d || t).touchedFields, l)
2700
+ }), nt = (l) => {
2701
+ const d = l ? et(l) : void 0;
2702
+ d == null || d.forEach((f) => K(t.errors, f)), d ? d.forEach((f) => {
2703
+ m.state.next({
2704
+ name: f,
2705
+ errors: t.errors
2706
+ });
2707
+ }) : m.state.next({
2708
+ errors: {}
2709
+ });
2710
+ }, ze = (l, d, f) => {
2711
+ const k = (I(n, l, { _f: {} })._f || {}).ref, x = I(t.errors, l) || {}, { ref: v, message: F, type: $, ...B } = x;
2712
+ P(t.errors, l, {
2713
+ ...B,
2714
+ ...d,
2715
+ ref: k
2716
+ }), m.state.next({
2717
+ name: l,
2718
+ errors: t.errors,
2719
+ isValid: !1
2720
+ }), f && f.shouldFocus && k && k.focus && k.focus();
2721
+ }, st = (l, d) => le(l) ? m.state.subscribe({
2722
+ next: (f) => "values" in f && l(R(void 0, d), f)
2723
+ }) : R(l, d, !0), Ke = (l) => m.state.subscribe({
2724
+ next: (d) => {
2725
+ ua(l.name, d.name, l.exact) && la(d, l.formState || b, ln, l.reRenderRoot) && l.callback({
2726
+ values: { ...i },
2727
+ ...t,
2728
+ ...d,
2729
+ defaultValues: s
2730
+ });
2731
+ }
2732
+ }).unsubscribe, at = (l) => (a.mount = !0, h = {
2733
+ ...h,
2734
+ ...l.formState
2735
+ }, Ke({
2736
+ ...l,
2737
+ formState: {
2738
+ ...g,
2739
+ ...l.formState
2740
+ }
2741
+ })), De = (l, d = {}) => {
2742
+ for (const f of l ? et(l) : o.mount)
2743
+ o.mount.delete(f), o.array.delete(f), d.keepValue || (K(n, f), K(i, f)), !d.keepError && K(t.errors, f), !d.keepDirty && K(t.dirtyFields, f), !d.keepTouched && K(t.touchedFields, f), !d.keepIsValidating && K(t.validatingFields, f), !r.shouldUnregister && !d.keepDefaultValue && K(s, f);
2744
+ m.state.next({
2745
+ values: H(i)
2746
+ }), m.state.next({
2747
+ ...t,
2748
+ ...d.keepDirty ? { isDirty: N() } : {}
2749
+ }), !d.keepIsValid && C();
2750
+ }, Ge = ({ disabled: l, name: d }) => {
2751
+ if (ce(l) && a.mount || l || o.disabled.has(d)) {
2752
+ const x = o.disabled.has(d) !== !!l;
2753
+ l ? o.disabled.add(d) : o.disabled.delete(d), x && a.mount && !a.action && C();
2754
+ }
2755
+ }, D = (l, d = {}) => {
2756
+ let f = I(n, l);
2757
+ const k = ce(d.disabled) || ce(r.disabled);
2758
+ return P(n, l, {
2759
+ ...f || {},
2760
+ _f: {
2761
+ ...f && f._f ? f._f : { ref: { name: l } },
2762
+ name: l,
2763
+ mount: !0,
2764
+ ...d
2765
+ }
2766
+ }), o.mount.add(l), f ? Ge({
2767
+ disabled: ce(d.disabled) ? d.disabled : r.disabled,
2768
+ name: l
2769
+ }) : V(l, !0, d.value), {
2770
+ ...k ? { disabled: d.disabled || r.disabled } : {},
2771
+ ...r.progressive ? {
2772
+ required: !!d.required,
2773
+ min: Je(d.min),
2774
+ max: Je(d.max),
2775
+ minLength: Je(d.minLength),
2776
+ maxLength: Je(d.maxLength),
2777
+ pattern: Je(d.pattern)
2778
+ } : {},
2779
+ name: l,
2780
+ onChange: oe,
2781
+ onBlur: oe,
2782
+ ref: (x) => {
2783
+ if (x) {
2784
+ D(l, d), f = I(n, l);
2785
+ const v = W(x.value) && x.querySelectorAll && x.querySelectorAll("input,select,textarea")[0] || x, F = ta(v), $ = f._f.refs || [];
2786
+ if (F ? $.find((B) => B === v) : v === f._f.ref)
2787
+ return;
2788
+ P(n, l, {
2789
+ _f: {
2790
+ ...f._f,
2791
+ ...F ? {
2792
+ refs: [
2793
+ ...$.filter(kt),
2794
+ v,
2795
+ ...Array.isArray(I(s, l)) ? [{}] : []
2796
+ ],
2797
+ ref: { type: v.type, name: l }
2798
+ } : { ref: v }
2799
+ }
2800
+ }), V(l, !1, void 0, v);
2801
+ } else
2802
+ f = I(n, l, {}), f._f && (f._f.mount = !1), (r.shouldUnregister || d.shouldUnregister) && !(Hs(o.array, l) && a.action) && o.unMount.add(l);
2803
+ }
2804
+ };
2805
+ }, ke = () => r.shouldFocusError && tt(n, _e, o.mount), He = (l) => {
2806
+ ce(l) && (m.state.next({ disabled: l }), tt(n, (d, f) => {
2807
+ const k = I(n, f);
2808
+ k && (d.disabled = k._f.disabled || l, Array.isArray(k._f.refs) && k._f.refs.forEach((x) => {
2809
+ x.disabled = k._f.disabled || l;
2810
+ }));
2811
+ }, 0, !1));
2812
+ }, me = (l, d) => async (f) => {
2813
+ let k;
2814
+ f && (f.preventDefault && f.preventDefault(), f.persist && f.persist());
2815
+ let x = H(i);
2816
+ if (m.state.next({
2817
+ isSubmitting: !0
2818
+ }), r.resolver) {
2819
+ const { errors: v, values: F } = await T();
2820
+ _(), t.errors = v, x = H(F);
2821
+ } else
2822
+ await O(n);
2823
+ if (o.disabled.size)
2824
+ for (const v of o.disabled)
2825
+ K(x, v);
2826
+ if (K(t.errors, "root"), re(t.errors)) {
2827
+ m.state.next({
2828
+ errors: {}
2829
+ });
2830
+ try {
2831
+ await l(x, f);
2832
+ } catch (v) {
2833
+ k = v;
2834
+ }
2835
+ } else
2836
+ d && await d({ ...t.errors }, f), ke(), setTimeout(ke);
2837
+ if (m.state.next({
2838
+ isSubmitted: !0,
2839
+ isSubmitting: !1,
2840
+ isSubmitSuccessful: re(t.errors) && !k,
2841
+ submitCount: t.submitCount + 1,
2842
+ errors: t.errors
2843
+ }), k)
2844
+ throw k;
2845
+ }, an = (l, d = {}) => {
2846
+ I(n, l) && (W(d.defaultValue) ? Z(l, H(I(s, l))) : (Z(l, d.defaultValue), P(s, l, H(d.defaultValue))), d.keepTouched || K(t.touchedFields, l), d.keepDirty || (K(t.dirtyFields, l), t.isDirty = d.defaultValue ? N(l, H(I(s, l))) : N()), d.keepError || (K(t.errors, l), b.isValid && C()), m.state.next({ ...t }));
2847
+ }, Bt = (l, d = {}) => {
2848
+ const f = l ? H(l) : s, k = H(f), x = re(l), v = x ? s : k;
2849
+ if (d.keepDefaultValues || (s = f), !d.keepValues) {
2850
+ if (d.keepDirtyValues) {
2851
+ const F = /* @__PURE__ */ new Set([
2852
+ ...o.mount,
2853
+ ...Object.keys(Oe(s, i))
2854
+ ]);
2855
+ for (const $ of Array.from(F)) {
2856
+ const B = I(t.dirtyFields, $), ee = I(i, $), Me = I(v, $);
2857
+ B && !W(ee) ? P(v, $, ee) : !B && !W(Me) && Z($, Me);
2858
+ }
2859
+ } else {
2860
+ if (Rt && W(l))
2861
+ for (const F of o.mount) {
2862
+ const $ = I(n, F);
2863
+ if ($ && $._f) {
2864
+ const B = Array.isArray($._f.refs) ? $._f.refs[0] : $._f.ref;
2865
+ if (ot(B)) {
2866
+ const ee = B.closest("form");
2867
+ if (ee) {
2868
+ ee.reset();
2869
+ break;
2870
+ }
2871
+ }
2872
+ }
2873
+ }
2874
+ if (d.keepFieldsRef)
2875
+ for (const F of o.mount)
2876
+ Z(F, I(v, F));
2877
+ else
2878
+ n = {};
2879
+ }
2880
+ i = r.shouldUnregister ? d.keepDefaultValues ? H(s) : {} : H(v), m.array.next({
2881
+ values: { ...v }
2882
+ }), m.state.next({
2883
+ values: { ...v }
2884
+ });
2885
+ }
2886
+ o = {
2887
+ mount: d.keepDirtyValues ? o.mount : /* @__PURE__ */ new Set(),
2888
+ unMount: /* @__PURE__ */ new Set(),
2889
+ array: /* @__PURE__ */ new Set(),
2890
+ disabled: /* @__PURE__ */ new Set(),
2891
+ watch: /* @__PURE__ */ new Set(),
2892
+ watchAll: !1,
2893
+ focus: ""
2894
+ }, a.mount = !b.isValid || !!d.keepIsValid || !!d.keepDirtyValues || !r.shouldUnregister && !re(v), a.watch = !!r.shouldUnregister, a.keepIsValid = !!d.keepIsValid, a.action = !1, d.keepErrors || (t.errors = {}), m.state.next({
2895
+ submitCount: d.keepSubmitCount ? t.submitCount : 0,
2896
+ isDirty: x ? !1 : d.keepDirty ? t.isDirty : !!(d.keepDefaultValues && !Se(l, s)),
2897
+ isSubmitted: d.keepIsSubmitted ? t.isSubmitted : !1,
2898
+ dirtyFields: x ? {} : d.keepDirtyValues ? d.keepDefaultValues && i ? Oe(s, i) : t.dirtyFields : d.keepDefaultValues && l ? Oe(s, l) : d.keepDirty ? t.dirtyFields : {},
2899
+ touchedFields: d.keepTouched ? t.touchedFields : {},
2900
+ errors: d.keepErrors ? t.errors : {},
2901
+ isSubmitSuccessful: d.keepIsSubmitSuccessful ? t.isSubmitSuccessful : !1,
2902
+ isSubmitting: !1,
2903
+ defaultValues: s
2904
+ });
2905
+ }, jt = (l, d) => Bt(le(l) ? l(i) : l, { ...r.resetOptions, ...d }), on = (l, d = {}) => {
2906
+ const f = I(n, l), k = f && f._f;
2907
+ if (k) {
2908
+ const x = k.refs ? k.refs[0] : k.ref;
2909
+ x.focus && setTimeout(() => {
2910
+ x.focus(), d.shouldSelect && le(x.select) && x.select();
2911
+ });
2912
+ }
2913
+ }, ln = (l) => {
2914
+ t = {
2915
+ ...t,
2916
+ ...l
2917
+ };
2918
+ }, Pt = {
2919
+ control: {
2920
+ register: D,
2921
+ unregister: De,
2922
+ getFieldState: Ve,
2923
+ handleSubmit: me,
2924
+ setError: ze,
2925
+ _subscribe: Ke,
2926
+ _runSchema: T,
2927
+ _updateIsValidating: _,
2928
+ _focusError: ke,
2929
+ _getWatch: R,
2930
+ _getDirty: N,
2931
+ _setValid: C,
2932
+ _setFieldArray: y,
2933
+ _setDisabledField: Ge,
2934
+ _setErrors: A,
2935
+ _getFieldArray: M,
2936
+ _reset: Bt,
2937
+ _resetDefaultValues: () => le(r.defaultValues) && r.defaultValues().then((l) => {
2938
+ jt(l, r.resetOptions), m.state.next({
2939
+ isLoading: !1
2940
+ });
2941
+ }),
2942
+ _removeUnmounted: J,
2943
+ _disableForm: He,
2944
+ _subjects: m,
2945
+ _proxyFormState: b,
2946
+ get _fields() {
2947
+ return n;
2948
+ },
2949
+ get _formValues() {
2950
+ return i;
2951
+ },
2952
+ get _state() {
2953
+ return a;
2954
+ },
2955
+ set _state(l) {
2956
+ a = l;
2957
+ },
2958
+ get _defaultValues() {
2959
+ return s;
2960
+ },
2961
+ get _names() {
2962
+ return o;
2963
+ },
2964
+ set _names(l) {
2965
+ o = l;
2966
+ },
2967
+ get _formState() {
2968
+ return t;
2969
+ },
2970
+ get _options() {
2971
+ return r;
2972
+ },
2973
+ set _options(l) {
2974
+ r = {
2975
+ ...r,
2976
+ ...l
2977
+ };
2978
+ }
2979
+ },
2980
+ subscribe: at,
2981
+ trigger: pe,
2982
+ register: D,
2983
+ handleSubmit: me,
2984
+ watch: st,
2985
+ setValue: Z,
2986
+ getValues: Fe,
2987
+ reset: jt,
2988
+ resetField: an,
2989
+ clearErrors: nt,
2990
+ unregister: De,
2991
+ setError: ze,
2992
+ setFocus: on,
2993
+ getFieldState: Ve
2994
+ };
2995
+ return {
2996
+ ...Pt,
2997
+ formControl: Pt
2998
+ };
2999
+ }
3000
+ function pt(e = {}) {
3001
+ const r = te.useRef(void 0), t = te.useRef(void 0), [n, s] = te.useState({
3002
+ isDirty: !1,
3003
+ isValidating: !1,
3004
+ isLoading: le(e.defaultValues),
3005
+ isSubmitted: !1,
3006
+ isSubmitting: !1,
3007
+ isSubmitSuccessful: !1,
3008
+ isValid: !1,
3009
+ submitCount: 0,
3010
+ dirtyFields: {},
3011
+ touchedFields: {},
3012
+ validatingFields: {},
3013
+ errors: e.errors || {},
3014
+ disabled: e.disabled || !1,
3015
+ isReady: !1,
3016
+ defaultValues: le(e.defaultValues) ? void 0 : e.defaultValues
3017
+ });
3018
+ if (!r.current)
3019
+ if (e.formControl)
3020
+ r.current = {
3021
+ ...e.formControl,
3022
+ formState: n
3023
+ }, e.defaultValues && !le(e.defaultValues) && e.formControl.reset(e.defaultValues, e.resetOptions);
3024
+ else {
3025
+ const { formControl: a, ...o } = pa(e);
3026
+ r.current = {
3027
+ ...o,
3028
+ formState: n
3029
+ };
3030
+ }
3031
+ const i = r.current.control;
3032
+ return i._options = e, Ys(() => {
3033
+ const a = i._subscribe({
3034
+ formState: i._proxyFormState,
3035
+ callback: () => s({ ...i._formState }),
3036
+ reRenderRoot: !0
3037
+ });
3038
+ return s((o) => ({
3039
+ ...o,
3040
+ isReady: !0
3041
+ })), i._formState.isReady = !0, a;
3042
+ }, [i]), te.useEffect(() => i._disableForm(e.disabled), [i, e.disabled]), te.useEffect(() => {
3043
+ e.mode && (i._options.mode = e.mode), e.reValidateMode && (i._options.reValidateMode = e.reValidateMode);
3044
+ }, [i, e.mode, e.reValidateMode]), te.useEffect(() => {
3045
+ e.errors && (i._setErrors(e.errors), i._focusError());
3046
+ }, [i, e.errors]), te.useEffect(() => {
3047
+ e.shouldUnregister && i._subjects.state.next({
3048
+ values: i._getWatch()
3049
+ });
3050
+ }, [i, e.shouldUnregister]), te.useEffect(() => {
3051
+ if (i._proxyFormState.isDirty) {
3052
+ const a = i._getDirty();
3053
+ a !== n.isDirty && i._subjects.state.next({
3054
+ isDirty: a
3055
+ });
3056
+ }
3057
+ }, [i, n.isDirty]), te.useEffect(() => {
3058
+ var a;
3059
+ e.values && !Se(e.values, t.current) ? (i._reset(e.values, {
3060
+ keepFieldsRef: !0,
3061
+ ...i._options.resetOptions
3062
+ }), !((a = i._options.resetOptions) === null || a === void 0) && a.keepIsValid || i._setValid(), t.current = e.values, s((o) => ({ ...o }))) : i._resetDefaultValues();
3063
+ }, [i, e.values]), te.useEffect(() => {
3064
+ i._state.mount || (i._setValid(), i._state.mount = !0), i._state.watch && (i._state.watch = !1, i._subjects.state.next({ ...i._formState })), i._removeUnmounted();
3065
+ }), r.current.formState = te.useMemo(() => Zs(n, i), [i, n]), r.current;
3066
+ }
3067
+ const pr = (e, r, t) => {
3068
+ if (e && "reportValidity" in e) {
3069
+ const n = I(t, r);
3070
+ e.setCustomValidity(n && n.message || ""), e.reportValidity();
3071
+ }
3072
+ }, ma = (e, r) => {
3073
+ for (const t in r.fields) {
3074
+ const n = r.fields[t];
3075
+ n && n.ref && "reportValidity" in n.ref ? pr(n.ref, t, e) : n.refs && n.refs.forEach((s) => pr(s, t, e));
3076
+ }
3077
+ }, ya = (e, r) => {
3078
+ r.shouldUseNativeValidation && ma(e, r);
3079
+ const t = {};
3080
+ for (const n in e) {
3081
+ const s = I(r.fields, n), i = Object.assign(e[n] || {}, { ref: s && s.ref });
3082
+ if (ga(r.names || Object.keys(e), n)) {
3083
+ const a = Object.assign({}, I(t, n));
3084
+ P(a, "root", i), P(t, n, a);
3085
+ } else
3086
+ P(t, n, i);
3087
+ }
3088
+ return t;
3089
+ }, ga = (e, r) => e.some((t) => t.startsWith(r + "."));
3090
+ var mt = function(e, r, t) {
3091
+ return t === void 0 && (t = {}), function(n, s, i) {
3092
+ try {
3093
+ var a = !i.shouldUseNativeValidation && i.criteriaMode === "all";
3094
+ return Promise.resolve(/* @__PURE__ */ Es(e, n, Object.assign({}, r, { abortPipeEarly: !a }))).then(function(o) {
3095
+ if (o.issues) {
3096
+ for (var c = {}; o.issues.length; ) {
3097
+ var p = o.issues[0], g = /* @__PURE__ */ ws(p);
3098
+ if (g && (c[g] || (c[g] = { message: p.message, type: p.type }), a)) {
3099
+ var b = c[g].types, h = b && b[p.type];
3100
+ c[g] = Zr(g, a, c, p.type, h ? [].concat(h, p.message) : p.message);
3101
+ }
3102
+ o.issues.shift();
3103
+ }
3104
+ return { values: {}, errors: ya(c, i) };
3105
+ }
3106
+ return { values: t.raw ? n : o.output, errors: {} };
3107
+ });
3108
+ } catch (o) {
3109
+ return Promise.reject(o);
3110
+ }
3111
+ };
3112
+ };
3113
+ const mr = 27, yr = 12, gr = 10, ba = Ue("enum"), va = (e, r) => {
3114
+ const t = {
3115
+ min: e.minSelected ?? 0,
3116
+ max: e.maxSelected ?? e.options.length
3117
+ };
3118
+ return mt(/* @__PURE__ */ xe({
3119
+ checked: /* @__PURE__ */ Ie(/* @__PURE__ */ zr(/* @__PURE__ */ ie(), /* @__PURE__ */ qr()), /* @__PURE__ */ Mt((n) => Object.entries(n).filter(([s, i]) => i).map(([s, i]) => s)), /* @__PURE__ */ Ye(t.max, r("validation_multiple_choice_max", {
3120
+ count: t.max
3121
+ })), /* @__PURE__ */ Be(t.min, r("validation_multiple_choice_min", {
3122
+ count: t.min
3123
+ })))
3124
+ }));
3125
+ }, xa = Fr(({
3126
+ option: e,
3127
+ ...r
3128
+ }, t) => u(we, {
3129
+ children: [u("input", {
3130
+ class: "peer sr-only h-full",
3131
+ type: "checkbox",
3132
+ ...r,
3133
+ ref: t
3134
+ }), u("label", {
3135
+ class: "bg-lowest hover:bg-neutral-2 active:outline-neutral-8 ease-expo-out outline-divider text-neutral-11 peer-checked:outline-accent-7 peer-checked:bg-accent-2 peer-checked:text-accent-9 peer-focus-visible:ring-accent-9 peer-focus-visible:ring-offset-accent-7 block cursor-pointer select-none rounded-2xl px-3 py-1.5 outline outline-1 ring-0 ring-transparent transition-all selection:bg-transparent peer-focus-visible:ring-4",
3136
+ htmlFor: r.id,
3137
+ children: e.label
3138
+ })]
3139
+ })), br = ct("gutter-stable flex w-full flex-1 flex-wrap gap-2 overflow-y-auto rounded-xl p-2.5 pr-4", {
3140
+ variants: {
3141
+ variant: {
3142
+ // In cases where there is only one option, we want to center it
3143
+ singleOption: "justify-center",
3144
+ // Two choices with exactly 1 min 1 max
3145
+ booleanLike: Gr
3146
+ }
3147
+ }
3148
+ }), wa = ({
3149
+ input: e,
3150
+ onSubmitSuccess: r
3151
+ }) => {
3152
+ var g, b;
3153
+ const t = e.key ? (g = j.current$.value.flow) == null ? void 0 : g.data.submissions[e.key] : void 0, n = (e.config.minSelected === 1 || e.config.minSelected === void 0) && e.config.maxSelected === 1, s = n && e.config.options.length === 2, {
3154
+ t: i
3155
+ } = Q(), {
3156
+ register: a,
3157
+ handleSubmit: o,
3158
+ formState: {
3159
+ errors: c
3160
+ }
3161
+ } = pt({
3162
+ defaultValues: {
3163
+ checked: n ? {} : ba(t) ? Object.fromEntries(t.value.map((h) => [h, !0])) : {}
3164
+ },
3165
+ resolver: va(e.config, i)
3166
+ }), p = Nt();
3167
+ return s ? u("ul", {
3168
+ style: {
3169
+ maxHeight: 6.5 * mr + 5 * yr + 2 * gr
3170
+ },
3171
+ class: br({
3172
+ variant: "booleanLike"
3173
+ }),
3174
+ children: e.config.options.map((h, m) => u("li", {
3175
+ class: Hr,
3176
+ children: u(Jr, {
3177
+ type: "submit",
3178
+ ref: (w) => {
3179
+ w && m === 0 && (p.current = w);
3180
+ },
3181
+ label: h.label,
3182
+ value: "true",
3183
+ onClick: () => r({
3184
+ type: "enum",
3185
+ value: [h.value]
3186
+ })
3187
+ })
3188
+ }, h.value))
3189
+ }) : u("form", {
3190
+ noValidate: !0,
3191
+ onSubmit: (h) => o((m) => {
3192
+ const w = m.checked;
3193
+ r({
3194
+ type: "enum",
3195
+ value: w
3196
+ });
3197
+ })(h),
3198
+ children: [u("div", {
3199
+ class: "flex items-center gap-1",
3200
+ children: [u("ul", {
3201
+ style: {
3202
+ maxHeight: 6.5 * mr + 5 * yr + 2 * gr
3203
+ },
3204
+ class: br({
3205
+ variant: e.config.options.length === 1 ? "singleOption" : void 0
3206
+ }),
3207
+ children: e.config.options.map((h, m) => {
3208
+ const w = `checked.${h.value}`, {
3209
+ ref: S,
3210
+ ...C
3211
+ } = a(w);
3212
+ return u("li", {
3213
+ class: "relative",
3214
+ children: u(xa, {
3215
+ option: h,
3216
+ autoFocus: m === 0,
3217
+ ref: (_) => {
3218
+ _ && m === 0 && (p.current = _), S(_);
3219
+ },
3220
+ id: w,
3221
+ ...C,
3222
+ onClick: n ? () => r({
3223
+ type: "enum",
3224
+ value: [h.value]
3225
+ }) : void 0
3226
+ })
3227
+ }, h.value);
3228
+ })
3229
+ }), u("div", {
3230
+ class: "flex flex-col items-center gap-2 pr-2.5 pt-2.5",
3231
+ children: [n ? null : u(Re, {}), e.config.minSelected === 0 && u(Ee, {
3232
+ class: "relative",
3233
+ type: "button",
3234
+ onClick: () => r({
3235
+ type: "enum",
3236
+ value: []
3237
+ })
3238
+ })]
3239
+ })]
3240
+ }), u("div", {
3241
+ class: "px-1",
3242
+ children: u(We, {
3243
+ error: (b = c.checked) == null ? void 0 : b.root
3244
+ })
3245
+ })]
3246
+ });
3247
+ }, _a = Ue("number"), ka = (e, r) => {
3248
+ const t = e.min ?? Number.MIN_SAFE_INTEGER, n = e.max ?? Number.MAX_SAFE_INTEGER, s = e.decimalCases ?? 0;
3249
+ return mt(/* @__PURE__ */ xe({
3250
+ number: /* @__PURE__ */ Ie(/* @__PURE__ */ Ur(r("validation_number")), /* @__PURE__ */ $r(t, r("validation_number_min", {
3251
+ min: t
3252
+ })), /* @__PURE__ */ Or(n, r("validation_number_max", {
3253
+ max: n
3254
+ })), /* @__PURE__ */ Dr((i) => i === Number(i.toFixed(s)), r("validation_number_decimal_cases", {
3255
+ count: s
3256
+ })))
3257
+ }));
3258
+ }, Ca = ({
3259
+ input: e,
3260
+ onSubmitSuccess: r
3261
+ }) => {
3262
+ var b;
3263
+ const t = e.config.defaultValue, n = e.key ? (b = j.current$.value.flow) == null ? void 0 : b.data.submissions[e.key] : void 0, {
3264
+ t: s
3265
+ } = Q(), {
3266
+ register: i,
3267
+ handleSubmit: a,
3268
+ formState: {
3269
+ errors: o
3270
+ }
3271
+ } = pt({
3272
+ defaultValues: {
3273
+ number: _a(n) ? n.value : t ? Number(t) : void 0
3274
+ },
3275
+ resolver: ka(e.config, s)
3276
+ }), {
3277
+ ref: c,
3278
+ ...p
3279
+ } = i("number", {
3280
+ required: !e.config.optional,
3281
+ valueAsNumber: !0
3282
+ }), g = de();
3283
+ return Ae(() => {
3284
+ g.current && (g.current.focus(), g.current.select());
3285
+ }, []), u("form", {
3286
+ class: "flex flex-col gap-1 p-2.5",
3287
+ onSubmit: a((h) => {
3288
+ h.number !== void 0 && r({
3289
+ type: "number",
3290
+ value: h.number
3291
+ });
3292
+ }),
3293
+ children: [u("div", {
3294
+ class: "flex items-center gap-2",
3295
+ children: [u("div", {
3296
+ class: "relative min-w-0 flex-grow",
3297
+ children: [u("input", {
3298
+ ...p,
3299
+ id: "chat-input",
3300
+ autocomplete: "off",
3301
+ autoCapitalize: "off",
3302
+ autoCorrect: "off",
3303
+ autoFocus: !0,
3304
+ ref: (h) => {
3305
+ h && (g.current = h), c(h);
3306
+ },
3307
+ type: "text",
3308
+ min: e.config.min,
3309
+ max: e.config.max,
3310
+ class: Pe({
3311
+ optional: e.config.optional,
3312
+ className: "[type=number:-webkit-inner-spin-button] w-full rounded-full [-webkit-outer-spin-button:none]"
3313
+ }),
3314
+ placeholder: e.config.placeholder
3315
+ }), e.config.optional && u(Ee, {
3316
+ class: "absolute bottom-0 right-0.5 top-0",
3317
+ onClick: () => r(null)
3318
+ })]
3319
+ }), u(Re, {})]
3320
+ }), u(We, {
3321
+ error: o.number
3322
+ })]
3323
+ });
3324
+ }, Sa = (e) => {
3325
+ if (e === "")
3326
+ return {
3327
+ countryCode: "",
3328
+ phoneNumber: ""
3329
+ };
3330
+ const r = Object.entries(Lt).find((s) => e.startsWith(s[1])), t = r ? r[1] : "", n = e.replace(t, "");
3331
+ return /^\d+$/.test(n) ? {
3332
+ countryCode: t,
3333
+ phoneNumber: n
3334
+ } : {
3335
+ countryCode: "",
3336
+ phoneNumber: ""
3337
+ };
3338
+ }, Ia = "44", Aa = /^[0-9 ]+$/, Ea = Ue("string"), Fa = Ue("phone"), Va = (e) => {
3339
+ const r = /* @__PURE__ */ Ie(/* @__PURE__ */ ie(e("validation_country_code")), /* @__PURE__ */ Vt(Aa, e("validation_country_code"))), t = /* @__PURE__ */ Ie(/* @__PURE__ */ ie(e("validation_phone")), /* @__PURE__ */ Be(1, e("validation_phone")), /* @__PURE__ */ Mt((n) => n.replace(/[^0-9]/g, "")));
3340
+ return mt(/* @__PURE__ */ xe({
3341
+ countryCode: r,
3342
+ phoneNumber: t
3343
+ }));
3344
+ }, Ma = ({
3345
+ input: e,
3346
+ onSubmitSuccess: r
3347
+ }) => {
3348
+ var S;
3349
+ const t = e.key ? (S = j.current$.value.flow) == null ? void 0 : S.data.submissions[e.key] : void 0, {
3350
+ t: n
3351
+ } = Q(), [s, i] = ve(), a = Ea(t) ? Sa(t.value) : Fa(t) ? t.value : void 0, {
3352
+ register: o,
3353
+ handleSubmit: c,
3354
+ formState: {
3355
+ errors: p
3356
+ },
3357
+ watch: g
3358
+ } = pt({
3359
+ defaultValues: {
3360
+ countryCode: (a == null ? void 0 : a.countryCode) ?? e.config.defaultValue.countryCode ?? Ia,
3361
+ phoneNumber: (a == null ? void 0 : a.phoneNumber) ?? e.config.defaultValue.phoneNumber ?? ""
3362
+ },
3363
+ resolver: Va(n)
3364
+ }), {
3365
+ ref: b,
3366
+ ...h
3367
+ } = o("phoneNumber", {
3368
+ required: !e.config.optional
3369
+ }), m = de(), w = g("countryCode");
3370
+ return Ae(() => {
3371
+ m.current && (m.current.focus(), m.current.select());
3372
+ }, []), u("form", {
3373
+ noValidate: !0,
3374
+ class: "flex flex-col gap-1 p-2.5",
3375
+ onSubmit: c((C) => {
3376
+ const _ = C.phoneNumber.replace(/[^0-9]/g, ""), y = C.countryCode.replace(/[^0-9]/g, "");
3377
+ i(void 0);
3378
+ const E = e.config.minChars ?? 7, A = _.length + y.length;
3379
+ if (A < E)
3380
+ return i(n("validation_phone_min_chars", {
3381
+ count: E
3382
+ }));
3383
+ const V = e.config.maxChars;
3384
+ if (V != null && A > V)
3385
+ return i(n("validation_max_chars", {
3386
+ count: V
3387
+ }));
3388
+ e.config.submissionFormat === "phone" ? r({
3389
+ type: "phone",
3390
+ value: {
3391
+ countryCode: y,
3392
+ phoneNumber: _
3393
+ }
3394
+ }) : r({
3395
+ type: "string",
3396
+ value: w + C.phoneNumber
3397
+ });
3398
+ }),
3399
+ children: [u("div", {
3400
+ class: "flex items-center gap-2",
3401
+ children: [u("div", {
3402
+ class: "relative flex min-w-0 flex-1 flex-grow gap-2",
3403
+ children: [u("label", {
3404
+ class: "text-neutral-12 bg-lowest hover:bg-neutral-5 placeholder:text-neutral-8 focus-visible:outline-accent-7 focus-within:bg-neutral-5 focus-within:outline-accent-7 outline-divider relative flex h-full cursor-pointer appearance-none items-center justify-center overflow-hidden text-ellipsis whitespace-nowrap rounded-l-full border-solid px-3 py-1.5 text-center text-base outline outline-2 transition-all focus-within:outline-none",
3405
+ htmlFor: `isdk_phone_${e.key}`,
3406
+ children: [u("span", {
3407
+ children: ["+", w]
3408
+ }), u("select", {
3409
+ ...o("countryCode", {}),
3410
+ id: `isdk_phone_${e.key}`,
3411
+ class: "absolute inset-0 opacity-0",
3412
+ children: Object.entries(Lt).map(([C, _]) => u("option", {
3413
+ value: _,
3414
+ children: [C, " (+", _, ")"]
3415
+ }, C))
3416
+ })]
3417
+ }), u("input", {
3418
+ ...h,
3419
+ id: "chat-input",
3420
+ type: "tel",
3421
+ inputMode: "tel",
3422
+ autocomplete: "off",
3423
+ autoCapitalize: "off",
3424
+ autoCorrect: "off",
3425
+ autoFocus: !0,
3426
+ ref: (C) => {
3427
+ C && (m.current = C), b(C);
3428
+ },
3429
+ class: Pe({
3430
+ optional: e.config.optional,
3431
+ className: "min-w-0 flex-1 rounded-r-full"
3432
+ }),
3433
+ placeholder: e.config.placeholder
3434
+ }), e.config.optional && u(Ee, {
3435
+ class: "absolute bottom-0 right-1 top-0",
3436
+ onClick: () => r(null)
3437
+ })]
3438
+ }), u(Re, {})]
3439
+ }), u(We, {
3440
+ error: p.countryCode || p.phoneNumber || {
3441
+ message: s
3442
+ }
3443
+ })]
3444
+ });
3445
+ }, it = (e) => e === void 0 ? 0 : Math.max(0, Math.ceil((e - Date.now()) / 1e3)), vr = (e, r, t, n) => t !== void 0 && n * 1e3 > Ir ? e("submission_available_at", {
3446
+ time: Ar(t, r)
3447
+ }) : e("submission_cooldown", {
3448
+ count: n
3449
+ }), La = ({
3450
+ input: e,
3451
+ onSubmitSuccess: r
3452
+ }) => {
3453
+ const {
3454
+ t,
3455
+ locale: n
3456
+ } = Q(), {
3457
+ availableAt: s
3458
+ } = e.config, [i, a] = ve(() => it(s)), [o, c] = ve("");
3459
+ Er(() => {
3460
+ const g = it(s);
3461
+ if (a(g), g === 0)
3462
+ return;
3463
+ c(vr(t, n, s, g));
3464
+ const b = setInterval(() => {
3465
+ const h = it(s);
3466
+ a(h), !(h > 0) && (clearInterval(b), c(t("submission_cooldown_ready")));
3467
+ }, 250);
3468
+ return () => clearInterval(b);
3469
+ }, [s, n, t]);
3470
+ const p = i > 0;
3471
+ return u("div", {
3472
+ class: "flex flex-col items-center gap-2 py-3",
3473
+ children: [u("button", {
3474
+ class: "bg-accent-9 hover:bg-accent-10 active:bg-submit-bg-active hover:border-accent-10 active:border-submit-bg-active border-accent-9 ring-accent-6 focus-visible:outline-accent-8 ring-offset-neutral-1 aria-disabled:hover:bg-accent-9 aria-disabled:hover:border-accent-9 flex cursor-pointer rounded-full border border-solid px-5 py-3 pr-4 text-white outline-none ring-1 ring-offset-[1.5px] transition-all duration-300 focus-visible:outline-2 active:ring-2 active:ring-offset-2 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:active:ring-1 aria-disabled:active:ring-offset-[1.5px]",
3475
+ name: e.key,
3476
+ "aria-disabled": p,
3477
+ "aria-describedby": p ? "submit-cooldown" : void 0,
3478
+ onClick: () => {
3479
+ it(s) > 0 || r(null);
3480
+ },
3481
+ children: u("span", {
3482
+ class: "flex items-center gap-1.5",
3483
+ children: [u("span", {
3484
+ class: "inline-flex items-center text-sm font-medium",
3485
+ children: e.config.label || "Submit"
3486
+ }), u("svg", {
3487
+ stroke: "currentColor",
3488
+ "stroke-width": "1.5",
3489
+ width: "16",
3490
+ height: "16",
3491
+ viewBox: "0 0 16 16",
3492
+ fill: "none",
3493
+ xmlns: "http://www.w3.org/2000/svg",
3494
+ children: [u("path", {
3495
+ d: "M4 8L8 4L12 8"
3496
+ }), u("path", {
3497
+ d: "M8 4V13"
3498
+ })]
3499
+ })]
3500
+ })
3501
+ }), p && u("p", {
3502
+ id: "submit-cooldown",
3503
+ "aria-hidden": "true",
3504
+ class: "text-neutral-11 text-xs",
3505
+ children: vr(t, n, s, i)
3506
+ }), u("p", {
3507
+ role: "status",
3508
+ class: "sr-only",
3509
+ children: o
3510
+ })]
3511
+ });
3512
+ }, Na = 160, xr = (e) => {
3513
+ e.style.height = "auto", e.style.height = `${Math.min(e.scrollHeight, Na)}px`;
3514
+ }, Ra = {
3515
+ date: {
3516
+ type: "date",
3517
+ inputMode: "text"
3518
+ },
3519
+ email: {
3520
+ type: "email",
3521
+ inputMode: "email",
3522
+ formNoValidate: !0
3523
+ },
3524
+ text: {
3525
+ type: "text",
3526
+ inputMode: "text"
3527
+ },
3528
+ url: {
3529
+ type: "url",
3530
+ inputMode: "url",
3531
+ formNoValidate: !0
3532
+ }
3533
+ }, Da = Ue("string"), Ta = (e, r) => {
3534
+ const t = {
3535
+ maxLength: r("validation_max_chars", {
3536
+ count: e.maxChars ?? 999
3537
+ }),
3538
+ minLength: r("validation_min_chars", {
3539
+ count: e.minChars ?? 1
3540
+ })
3541
+ };
3542
+ return mt(/* @__PURE__ */ xe({
3543
+ text: {
3544
+ date: /* @__PURE__ */ Ie(/* @__PURE__ */ ie(r("validation_date")), /* @__PURE__ */ Vt(/^\d{4}-\d{2}-\d{2}$/, r("validation_date"))),
3545
+ email: /* @__PURE__ */ Ie(/* @__PURE__ */ ie(r("validation_email")), /* @__PURE__ */ Tr(r("validation_email")), /* @__PURE__ */ Be(e.minChars ?? 1, t.minLength), /* @__PURE__ */ Ye(e.maxChars ?? 1 / 0, t.maxLength)),
3546
+ text: /* @__PURE__ */ Ie(/* @__PURE__ */ ie(), /* @__PURE__ */ Be(e.minChars ?? 1, t.minLength), /* @__PURE__ */ Ye(e.maxChars ?? 1 / 0, t.maxLength)),
3547
+ url: /* @__PURE__ */ Ie(/* @__PURE__ */ ie(r("validation_url")), /* @__PURE__ */ Br(r("validation_url")), /* @__PURE__ */ Be(e.minChars ?? 1, t.minLength), /* @__PURE__ */ Ye(e.maxChars ?? 1 / 0, t.maxLength))
3548
+ }[e.format]
3549
+ }));
3550
+ }, Oa = ({
3551
+ input: e,
3552
+ onSubmitSuccess: r
3553
+ }) => {
3554
+ var S;
3555
+ const {
3556
+ t
3557
+ } = Q(), n = e.key ? (S = j.current$.value.flow) == null ? void 0 : S.data.submissions[e.key] : void 0, s = e.config.defaultValue, i = e.config.multiline === !0 && e.config.format === "text", {
3558
+ register: a,
3559
+ handleSubmit: o,
3560
+ watch: c,
3561
+ formState: {
3562
+ errors: p
3563
+ }
3564
+ } = pt({
3565
+ defaultValues: {
3566
+ text: Da(n) ? n.value : s ?? ""
3567
+ },
3568
+ resolver: Ta(e.config, t)
3569
+ }), {
3570
+ ref: g,
3571
+ ...b
3572
+ } = a("text", {
3573
+ required: !e.config.optional
3574
+ }), h = de();
3575
+ Ae(() => {
3576
+ h.current && (h.current instanceof HTMLTextAreaElement && xr(h.current), h.current.focus(), h.current.select());
3577
+ }, []);
3578
+ const m = e.config.maxChars, w = i && m !== void 0 ? c("text").length : void 0;
3579
+ return u("form", {
3580
+ noValidate: !0,
3581
+ class: "flex flex-col gap-1 p-2.5",
3582
+ onSubmit: o((C) => {
3583
+ r({
3584
+ type: "string",
3585
+ value: C.text
3586
+ });
3587
+ }),
3588
+ children: [u("div", {
3589
+ class: i ? "flex items-end gap-2" : "flex items-center gap-2",
3590
+ children: [u("div", {
3591
+ class: "relative min-w-0 flex-1",
3592
+ children: [i ? u("textarea", {
3593
+ id: "chat-input",
3594
+ ...b,
3595
+ rows: 2,
3596
+ maxLength: m,
3597
+ autoFocus: !0,
3598
+ "aria-describedby": w !== void 0 ? "chat-input-count" : void 0,
3599
+ onInput: (C) => xr(C.currentTarget),
3600
+ onKeyDown: (C) => {
3601
+ var _;
3602
+ C.key === "Enter" && (C.ctrlKey || C.metaKey) && (C.preventDefault(), (_ = C.currentTarget.form) == null || _.requestSubmit());
3603
+ },
3604
+ ref: (C) => {
3605
+ C && (h.current = C), g(C);
3606
+ },
3607
+ placeholder: e.config.placeholder,
3608
+ class: Pe({
3609
+ optional: !!e.config.optional,
3610
+ className: "block w-full resize-none overflow-y-auto rounded-2xl"
3611
+ })
3612
+ }) : u("input", {
3613
+ id: "chat-input",
3614
+ ...b,
3615
+ ...Ra[e.config.format],
3616
+ autocomplete: "off",
3617
+ autoCapitalize: "off",
3618
+ autoCorrect: "off",
3619
+ autoFocus: !0,
3620
+ ref: (C) => {
3621
+ C && (h.current = C), g(C);
3622
+ },
3623
+ placeholder: e.config.placeholder,
3624
+ class: Pe({
3625
+ optional: !!e.config.optional,
3626
+ className: "w-full rounded-full"
3627
+ })
3628
+ }), e.config.optional && u(
3629
+ Ee,
3630
+ {
3631
+ class: i ? "absolute bottom-1 right-0.5" : "absolute bottom-0 right-0.5 top-0",
3632
+ onClick: () => r(null)
3633
+ }
3634
+ )]
3635
+ }), u(Re, {})]
3636
+ }), w !== void 0 && m !== void 0 && u("p", {
3637
+ id: "chat-input-count",
3638
+ class: "text-neutral-10 px-3 text-right text-xs",
3639
+ children: [w, "/", m]
3640
+ }), u(We, {
3641
+ error: p.text
3642
+ })]
3643
+ });
3644
+ }, $a = {
3645
+ text: Oa,
3646
+ phone: Ma,
3647
+ "multiple-choice": wa,
3648
+ boolean: $s,
3649
+ file: zs,
3650
+ submit: La,
3651
+ address: Rs,
3652
+ number: Ca
3653
+ }, Ba = ({
3654
+ logger: e,
3655
+ analytics: r
3656
+ }) => {
3657
+ var i;
3658
+ const t = (i = j.current$.value.flow) == null ? void 0 : i.data.currentInput, n = de(null), s = () => se.onInteractionFn$.value();
3659
+ return Ae(() => {
3660
+ var a;
3661
+ (a = n.current) == null || a.scrollTo({
3662
+ top: 0
3663
+ });
3664
+ }, [t]), u("div", {
3665
+ ref: n,
3666
+ class: "border-divider max-h-[calc(100%-var(--header-height)-4rem)] w-full shrink-0 scroll-pb-12 overflow-y-auto overscroll-contain border-t",
3667
+ children: u("div", {
3668
+ class: "flex flex-col",
3669
+ onPointerDownCapture: t ? s : void 0,
3670
+ onKeyDownCapture: t ? s : void 0,
3671
+ children: t ? (() => {
3672
+ const a = $a[t.type];
3673
+ return u(a, {
3674
+ logger: e,
3675
+ analytics: r,
3676
+ onSubmitSuccess: se.onSubmitSuccessFn$.value,
3677
+ input: t
3678
+ });
3679
+ })() : u("div", {
3680
+ class: "flex items-center gap-2 p-2.5",
3681
+ children: [u("input", {
3682
+ "aria-hidden": "true",
3683
+ id: "chat-input",
3684
+ class: Pe({
3685
+ optional: !1,
3686
+ className: "flex-grow rounded-full"
3687
+ }),
3688
+ disabled: !0
3689
+ }), u(Re, {
3690
+ disabled: !0,
3691
+ "aria-hidden": "true",
3692
+ tabIndex: -1
3693
+ })]
3694
+ })
3695
+ })
3696
+ });
3697
+ };
3698
+ function ja(e) {
3699
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
3700
+ }
3701
+ var Pa = function(e) {
3702
+ return e instanceof RegExp;
3703
+ }, qa = function(r) {
3704
+ var t = /[\\^$.*+?()[\]{}|]/g, n = RegExp(t.source);
3705
+ return r && n.test(r) ? r.replace(t, "\\$&") : r;
3706
+ }, sn = function(e) {
3707
+ return typeof e == "string";
3708
+ }, Ua = function(e) {
3709
+ var r = [];
3710
+ return e.forEach(function(t) {
3711
+ Array.isArray(t) ? r = r.concat(t) : r.push(t);
3712
+ }), r;
3713
+ };
3714
+ function Wa(e, r, t) {
3715
+ var n = 0, s = 0;
3716
+ if (e === "")
3717
+ return e;
3718
+ if (!e || !sn(e))
3719
+ throw new TypeError("First argument to react-string-replace#replaceString must be a string");
3720
+ var i = r;
3721
+ Pa(i) || (i = new RegExp("(" + qa(i) + ")", "gi"));
3722
+ for (var a = e.split(i), o = 1, c = a.length; o < c; o += 2) {
3723
+ if (a[o] === void 0 || a[o - 1] === void 0) {
3724
+ console.warn("reactStringReplace: Encountered undefined value during string replacement. Your RegExp may not be working the way you expect.");
3725
+ continue;
3726
+ }
3727
+ s = a[o].length, n += a[o - 1].length, a[o] = t(a[o], o, n), n += s;
3728
+ }
3729
+ return a;
3730
+ }
3731
+ var za = function(r, t, n) {
3732
+ return Array.isArray(r) || (r = [r]), Ua(r.map(function(s) {
3733
+ return sn(s) ? Wa(s, t, n) : s;
3734
+ }));
3735
+ };
3736
+ const Xe = /* @__PURE__ */ ja(za), Ka = /(\[[^\]]+\]\([^)]+\))/g, Ga = /\[([^\]]+)\]\(([^)]+)\)/, Ha = /(https?:\/\/[^\s]+)/g, Ja = /_(.*?)_/g, Xa = /\*\*(.*?)\*\*/g, Za = /\\n|\n/g, wr = "text-accent-10 hover:text-accent-11 no-underline underline-offset-2 hover:underline", Ya = (e) => {
3737
+ const r = Xe(e, Ka, (a, o) => {
3738
+ const [, c, p] = a.match(Ga) ?? [];
3739
+ return p ? u("a", {
3740
+ class: wr,
3741
+ href: p,
3742
+ children: c ?? p
3743
+ }, p + o) : u("span", {
3744
+ children: "INVALID LINK"
3745
+ });
3746
+ }), t = Xe(r, Ha, (a, o) => u("a", {
3747
+ class: wr,
3748
+ href: a,
3749
+ children: a
3750
+ }, a + o)), n = Xe(t, Ja, (a, o) => u("em", {
3751
+ children: a
3752
+ }, a + o)), s = Xe(n, Xa, (a, o) => u("strong", {
3753
+ children: a
3754
+ }, a + o));
3755
+ return Xe(s, Za, (a, o) => u("br", {}, `br-${o}`));
3756
+ }, Qa = ct("select-text max-w-[min(100%,24rem)] [text-wrap:pretty] leading-snug flex-shrink min-w-[2rem] py-2 px-3 rounded-[18px] min-h-[36px] break-words relative", {
3757
+ variants: {
3758
+ side: {
3759
+ left: "bg-bubble-weak-bg text-neutral-12 shadow-surface-sm outline outline-1 outline-bubble-weak rounded-bl-md",
3760
+ right: "ml-auto bg-accent-9 text-white rounded-br-md shadow-surface-sm shadow-bubble-strong-shadow"
3761
+ },
3762
+ animate: {
3763
+ true: "animate-bubble-in",
3764
+ false: ""
3765
+ }
3766
+ },
3767
+ defaultVariants: {
3768
+ side: "left"
3769
+ }
3770
+ }), ei = ({
3771
+ children: e,
3772
+ className: r,
3773
+ animate: t,
3774
+ side: n,
3775
+ ...s
3776
+ }) => u("p", {
3777
+ style: {
3778
+ transformOrigin: n === "left" ? "0% 50%" : "100% 50%"
3779
+ },
3780
+ class: Qa({
3781
+ className: r,
3782
+ side: n,
3783
+ animate: t
3784
+ }),
3785
+ ...s,
3786
+ children: e
3787
+ }), ti = ({
3788
+ message: e
3789
+ }) => u("div", {
3790
+ class: "bg-accent-3 flex w-full items-center justify-center overflow-hidden rounded-xl px-2 py-2",
3791
+ children: u("a", {
3792
+ onClick: e.onClick,
3793
+ class: "bg-lowest shadow-surface-sm ring-accent-6 hover:ring-accent-8 active:bg-accent-2 active:text-accent-10 text-accent-9 focus-visible:ring-accent-7/50 text-wrap-balance flex items-center gap-1.5 rounded-full py-2 pl-4 pr-2.5 text-center no-underline ring-1 transition-all focus:outline-none focus-visible:ring-4 focus-visible:ring-offset-2",
3794
+ target: "_blank",
3795
+ href: e.href,
3796
+ children: [e.text, u("svg", {
3797
+ class: "flex-none",
3798
+ width: "15",
3799
+ height: "15",
3800
+ viewBox: "0 0 15 15",
3801
+ fill: "none",
3802
+ xmlns: "http://www.w3.org/2000/svg",
3803
+ children: u("path", {
3804
+ d: "M3.64645 11.3536C3.45118 11.1583 3.45118 10.8417 3.64645 10.6465L10.2929 4L6 4C5.72386 4 5.5 3.77614 5.5 3.5C5.5 3.22386 5.72386 3 6 3L11.5 3C11.6326 3 11.7598 3.05268 11.8536 3.14645C11.9473 3.24022 12 3.36739 12 3.5L12 9.00001C12 9.27615 11.7761 9.50001 11.5 9.50001C11.2239 9.50001 11 9.27615 11 9.00001V4.70711L4.35355 11.3536C4.15829 11.5488 3.84171 11.5488 3.64645 11.3536Z",
3805
+ fill: "currentColor",
3806
+ "fill-rule": "evenodd",
3807
+ "clip-rule": "evenodd"
3808
+ })
3809
+ })]
3810
+ })
3811
+ }), ri = ({
3812
+ className: e,
3813
+ ...r
3814
+ }) => u("div", {
3815
+ "aria-hidden": !0,
3816
+ children: se.isBotTyping$.value === !0 ? u("div", {
3817
+ "data-testid": "typing-indicator",
3818
+ class: qe("flex gap-1 p-4", e),
3819
+ ...r,
3820
+ children: Array.from({
3821
+ length: 3
3822
+ }, (t, n) => u("div", {
3823
+ class: "bg-accent-9 h-1.5 w-1.5 animate-bounce rounded-full",
3824
+ style: {
3825
+ animationDelay: `${-n * 200}ms`
3826
+ }
3827
+ }))
3828
+ }) : void 0
3829
+ }), ni = {
3830
+ bot: "left",
3831
+ user: "right"
3832
+ }, si = ct("w-full select-none py-2 text-wrap-balance text-center text-[10px] uppercase tracking-widest drop-shadow-[0_1.5px_var(--i-color-n-1)]", {
3833
+ variants: {
3834
+ variant: {
3835
+ info: "text-neutral-11",
3836
+ warning: "text-system-warning",
3837
+ error: "text-error-11",
3838
+ success: "text-system-success"
3839
+ }
3840
+ }
3841
+ }), ai = ({
3842
+ lastSentMessageFooter: e
3843
+ }) => {
3844
+ const {
3845
+ t: r
3846
+ } = Q(), t = j.current$.value.flow, n = (t == null ? void 0 : t.data.messages) ?? [], s = t ? Ft(t) : void 0;
3847
+ return u("ol", {
3848
+ "aria-label": r("chat_messages"),
3849
+ "aria-live": "polite",
3850
+ class: "mt-auto flex flex-col justify-end gap-2 p-2 pt-[calc(var(--header-height)+1rem)]",
3851
+ children: [n.map((i, a) => u(we, {
3852
+ children: u("li", {
3853
+ class: "flex",
3854
+ tabIndex: a === n.length - 1 ? -1 : void 0,
3855
+ children: [s && i.groupId === s && !n.slice(a + 1).some((o) => o.groupId === s) ? e : null, Fn(i).with({
3856
+ type: "system"
3857
+ }, (o) => u("p", {
3858
+ class: si({
3859
+ variant: o.variant
3860
+ }),
3861
+ children: o.text
3862
+ })).with({
3863
+ type: "text",
3864
+ author: Vn.union("bot", "user")
3865
+ }, (o) => {
3866
+ const c = a === n.length - 1, p = o.author === "bot" ? Ya(o.text) : o.text;
3867
+ return u(we, {
3868
+ children: u(ei, {
3869
+ animate: c,
3870
+ side: ni[o.author],
3871
+ children: p
3872
+ }, a)
3873
+ });
3874
+ }).with({
3875
+ type: "link"
3876
+ }, (o) => u(ti, {
3877
+ message: o
3878
+ })).with({
3879
+ type: "image"
3880
+ }, (o) => u("img", {
3881
+ class: "shadow-surface-md w-full max-w-[min(100%,24rem)] rounded-2xl",
3882
+ src: o.url,
3883
+ style: {
3884
+ aspectRatio: o.width / o.height
3885
+ }
3886
+ })).with({
3887
+ type: "file"
3888
+ }, (o) => u(Ps, {
3889
+ class: o.author === "bot" ? void 0 : "ml-auto",
3890
+ file: {
3891
+ name: o.fileName,
3892
+ sizeKb: o.fileSizeKb
3893
+ }
3894
+ })).with({
3895
+ type: "loading"
3896
+ }, (o) => {
3897
+ const c = n[n.length - 1];
3898
+ return !(o === c) || se.isBotTyping$.value ? null : u("div", {
3899
+ class: "flex flex-grow flex-col items-center justify-center gap-2",
3900
+ children: [u(Et, {
3901
+ "aria-hidden": o.text ? "true" : void 0,
3902
+ class: "text-neutral-6 h-8 w-8"
3903
+ }), o.text ? u("p", {
3904
+ role: "status",
3905
+ class: "text-neutral-11 text-sm",
3906
+ children: o.text
3907
+ }) : null]
3908
+ });
3909
+ }).exhaustive()]
3910
+ })
3911
+ }, a)), u("li", {
3912
+ class: se.captchaVisible$.value ? "flex" : "hidden",
3913
+ children: u("div", {
3914
+ "data-captcha-slot": !0,
3915
+ tabIndex: -1,
3916
+ role: "group",
3917
+ "aria-label": r("captcha_check"),
3918
+ class: "w-full max-w-[min(100%,24rem)] rounded-md"
3919
+ })
3920
+ }, "captcha"), u(ri, {}, "typing")]
3921
+ });
3922
+ }, ci = ({
3923
+ logger: e,
3924
+ apiClient: r,
3925
+ analytics: t,
3926
+ talentBankClient: n
3927
+ }) => {
3928
+ const {
3929
+ flow: s
3930
+ } = j.current$.value;
3931
+ Ne(s, "Flow is required to exist to show chatbot body");
3932
+ const i = j.viewState$.value, {
3933
+ chatRef: a,
3934
+ chatService: o
3935
+ } = Mn(), {
3936
+ t: c
3937
+ } = Q(), [p, g] = ve();
3938
+ return Ae(() => {
3939
+ i === "maximised" && se.scrollToEnd();
3940
+ }, [i]), Ae(() => {
3941
+ var V;
3942
+ const {
3943
+ state: b,
3944
+ flow: h
3945
+ } = j.current$.peek();
3946
+ if (b !== "loaded")
3947
+ throw new Error(c("invalid_state"));
3948
+ let m = h.data.nodeHistory.at(-1);
3949
+ if (se.scrollToEnd(), j.setInput(void 0), h.data.isFinished)
3950
+ return;
3951
+ const w = () => {
3952
+ const L = j.current$.peek().flow;
3953
+ !L || L.data.hasInteracted || (j.markAsInteracted(), Jt(t, L, "FLOW_INTERACT"));
3954
+ };
3955
+ se.onInteractionFn$.value = w, m === void 0 ? (m = Lr(s.nodes).id, j.setCurrentNodeId(m), Jt(t, h, "FLOW_START")) : j.removeMessagesSentByNodeIds([m, St]);
3956
+ const {
3957
+ interpret: S,
3958
+ abort: C,
3959
+ undo: _
3960
+ } = Gn({
3961
+ context: s.context,
3962
+ analytics: {
3963
+ service: t,
3964
+ customProperties: (V = s.analytics) == null ? void 0 : V.customProperties
3965
+ },
3966
+ apiClient: r,
3967
+ logger: e,
3968
+ talentBankClient: n,
3969
+ flow: s,
3970
+ chatService: o,
3971
+ t: c,
3972
+ getApplicationRecovery: () => {
3973
+ var L;
3974
+ return (L = j.current$.peek().flow) == null ? void 0 : L.data.applicationRecovery;
3975
+ },
3976
+ setApplicationRecovery: j.setApplicationRecovery,
3977
+ persistWriteBarrier: () => j.persistWriteBarrier(h),
3978
+ // We need to get fresh submissions, that’s why we call `peek` here.
3979
+ getSubmissions: () => {
3980
+ var L;
3981
+ return (L = j.current$.peek().flow) == null ? void 0 : L.data.submissions;
3982
+ },
3983
+ onInterpret: (L) => j.setCurrentNodeId(L.id),
3984
+ onFlowEnd: async () => {
3985
+ var U;
3986
+ j.markAsFinished();
3987
+ const L = j.current$.peek().flow;
3988
+ Ne(L), t.log({
3989
+ event: "FLOW_END",
3990
+ properties: {
3991
+ flow_id: s.id,
3992
+ flow_version: s.version,
3993
+ flow_session_id: L.data.flowSessionId,
3994
+ flow_build: s.build,
3995
+ job: s.job
3996
+ },
3997
+ customProperties: (U = s.analytics) == null ? void 0 : U.customProperties
3998
+ });
3999
+ }
4000
+ }), y = m, E = () => {
4001
+ g(() => _), S(y);
4002
+ }, A = new AbortController();
4003
+ return h.offerResume ? ms({
4004
+ chatService: o,
4005
+ t: c,
4006
+ signal: A.signal
4007
+ }).then((L) => (j.settleResume(h), L ? E() : (j.restart(), Ln.flushStateData()))).catch((L) => {
4008
+ L instanceof Cr || e.error("Resume prompt failed", L);
4009
+ }) : E(), () => {
4010
+ A.abort(), se.onInteractionFn$.value === w && (se.onInteractionFn$.value = () => {
4011
+ }), C();
4012
+ };
4013
+ }, [t, r, o, e, s, n, c]), u(we, {
4014
+ children: [u("div", {
4015
+ class: "relative flex min-h-0 w-full max-w-full flex-grow flex-col",
4016
+ children: [u("div", {
4017
+ ref: a,
4018
+ role: "region",
4019
+ "aria-label": c("conversation_history"),
4020
+ tabIndex: 0,
4021
+ className: "hide-scrollbars fr flex min-h-0 w-full max-w-full flex-grow flex-col overflow-y-auto ring-inset",
4022
+ style: {
4023
+ WebkitOverflowScrolling: "touch"
4024
+ },
4025
+ children: u(ai, {
4026
+ lastSentMessageFooter: !Ft(s) || !p ? null : u(ii, {
4027
+ undoFn: p
4028
+ })
4029
+ })
4030
+ }), se.isReadingHistory$.value && !s.data.isFinished && !se.isBotTyping$.value && u("div", {
4031
+ class: "absolute bottom-2 left-1/2 -translate-x-1/2",
4032
+ children: u(Vr, {
4033
+ class: "bg-neutral-1 ring-divider shadow-surface-md ring-1",
4034
+ "aria-label": c("jump_to_current"),
4035
+ onClick: () => {
4036
+ var h, m;
4037
+ se.scrollToEnd(), (m = ((h = a.current) == null ? void 0 : h.querySelector('li[tabindex="-1"]')) ?? a.current) == null || m.focus({
4038
+ preventScroll: !0
4039
+ });
4040
+ },
4041
+ children: u(Nn, {})
4042
+ })
4043
+ })]
4044
+ }), u(Ba, {
4045
+ logger: e,
4046
+ analytics: t
4047
+ })]
4048
+ });
4049
+ }, ii = ({
4050
+ undoFn: e
4051
+ }) => {
4052
+ const {
4053
+ t: r
4054
+ } = Q();
4055
+ return u("div", {
4056
+ class: "flex flex-1 items-center justify-end px-1",
4057
+ children: u(Vr, {
4058
+ "aria-label": r("undo"),
4059
+ onClick: async () => {
4060
+ const {
4061
+ flow: t
4062
+ } = j.current$.peek();
4063
+ Ne(t), e(t.data.nodeHistory);
4064
+ },
4065
+ children: u("path", {
4066
+ d: "M3 13h2.67l6.66-6.67a1.9 1.9 0 0 0 0-2.66 1.91 1.91 0 0 0-2.66 0L3 10.33V13Zm4.6-7.25 2.67 2.67"
4067
+ })
4068
+ })
4069
+ });
4070
+ };
4071
+ export {
4072
+ ci as ChatbotBody
4073
+ };