@inploi/plugin-chatbot 14.13.3 → 14.14.0

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