@inploi/plugin-chatbot 14.17.3 → 14.18.1

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