@inploi/plugin-chatbot 14.10.0 → 14.10.2

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