@inploi/plugin-chatbot 14.13.2 → 14.14.0

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