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