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