@inploi/plugin-chatbot 11.0.0 → 12.0.1

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