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