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