@inploi/plugin-chatbot 11.0.0 → 12.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cdn/index.js +3 -3
- package/dist/chatbot-body-0a83b49f.cjs +1 -0
- package/dist/chatbot-body-6bcdaff5.js +4195 -0
- package/dist/chatbot.analytics.d.ts +37 -0
- package/dist/chatbot.analytics.test.d.ts +1 -0
- package/dist/chatbot.api.d.ts +2 -718
- package/dist/chatbot.idb.d.ts +1 -0
- package/dist/chatbot.state.d.ts +3 -16
- package/dist/chatbot.utils.d.ts +1 -16
- package/dist/components/useChatService.d.ts +1 -0
- package/dist/index-0295b2b0.cjs +5 -0
- package/dist/{index-523342dc.js → index-8ab77244.js} +1289 -1850
- package/dist/interpreter.d.ts +1 -2
- package/dist/plugin-chatbot.cjs +1 -1
- package/dist/plugin-chatbot.js +1 -1
- package/dist/rpc.d.ts +1 -493
- package/dist/style/tokens.d.ts +4 -4
- package/package.json +6 -6
- package/dist/chatbot-body-5d5ea35e.cjs +0 -1
- package/dist/chatbot-body-e9d58f57.js +0 -3667
- package/dist/index-da8d6977.cjs +0 -5
|
@@ -1,3667 +0,0 @@
|
|
|
1
|
-
import { $ as Xt, C as Qt, v as st, A as Re, g as Yt, i as me, a as Mr, T as Nr, M as at, z as R, h as se, _ as ue, p as ce, F as er, u as Q, o as c, c as je, b as Ge, y as xe, k as we, s as D, d as Tr, e as ge, f as Dr, j as rt, l as Y, m as Rr, n as tr, q as Or, r as Br, t as Pr, w as Fe, x as H, B as jr, D as $r, E as pe, G as Oe, H as qe, I as rr, J as Ur, K as zr, L as qr, N as Kr, O as Hr, P as Gr, Q as nr, R as Wr, S as Jr, U as Z, V as Zr, W as Xr, X as Qr } from "./index-523342dc.js";
|
|
2
|
-
import "@inploi/sdk";
|
|
3
|
-
var Vt = ({ condition: e, context: t, submissions: r, ifBlock: n }) => {
|
|
4
|
-
let [i, ...s] = e.compareKey.split(".");
|
|
5
|
-
if (!i)
|
|
6
|
-
return !1;
|
|
7
|
-
let o = Xt({ context: t, key: i, path: s, submissions: r });
|
|
8
|
-
if (!o)
|
|
9
|
-
return !1;
|
|
10
|
-
switch (o.type) {
|
|
11
|
-
case "address": {
|
|
12
|
-
let a = st(o.value, s);
|
|
13
|
-
switch (e.compare) {
|
|
14
|
-
case "equals":
|
|
15
|
-
return a === e.compareValue;
|
|
16
|
-
case "contains":
|
|
17
|
-
return typeof a != "string" ? !1 : a.includes(e.compareValue);
|
|
18
|
-
case "notEquals":
|
|
19
|
-
return a !== e.compareValue;
|
|
20
|
-
case "notContains":
|
|
21
|
-
return typeof a != "string" ? !0 : !a.includes(e.compareValue);
|
|
22
|
-
}
|
|
23
|
-
break;
|
|
24
|
-
}
|
|
25
|
-
case "integration": {
|
|
26
|
-
if (typeof o.value != "object" || Array.isArray(o.value))
|
|
27
|
-
return !1;
|
|
28
|
-
let a = st(o.value, s), f = { ...n, data: { compareKey: "_temp", compare: e.compare, compareValue: e.compareValue } };
|
|
29
|
-
switch (typeof a) {
|
|
30
|
-
case "boolean":
|
|
31
|
-
return De(f, { submissions: { _temp: { value: a, type: "boolean" } }, context: t });
|
|
32
|
-
case "string":
|
|
33
|
-
return De(f, { submissions: { _temp: { value: a, type: "string" } }, context: t });
|
|
34
|
-
case "number":
|
|
35
|
-
return De(f, { submissions: { _temp: { value: a, type: "number" } }, context: t });
|
|
36
|
-
case "object":
|
|
37
|
-
return Array.isArray(a) && a.every((p) => typeof p == "string") ? De(f, { submissions: { _temp: { value: a, type: "enum" } }, context: t }) : !1;
|
|
38
|
-
}
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
case "boolean": {
|
|
42
|
-
let a = e.compareValue === "true";
|
|
43
|
-
switch (e.compare) {
|
|
44
|
-
case "equals":
|
|
45
|
-
return o.value === a;
|
|
46
|
-
case "notEquals":
|
|
47
|
-
return o.value !== a;
|
|
48
|
-
}
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
case "phone":
|
|
52
|
-
case "string": {
|
|
53
|
-
let a = o.type === "phone" ? Qt(o.value) : o.value;
|
|
54
|
-
switch (e.compare) {
|
|
55
|
-
case "equals":
|
|
56
|
-
return a === e.compareValue;
|
|
57
|
-
case "contains":
|
|
58
|
-
return a ? a.includes(e.compareValue) : !1;
|
|
59
|
-
case "notEquals":
|
|
60
|
-
return a !== e.compareValue;
|
|
61
|
-
case "notContains":
|
|
62
|
-
return a ? !a.includes(e.compareValue) : !0;
|
|
63
|
-
}
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
case "number": {
|
|
67
|
-
try {
|
|
68
|
-
let a = Number(e.compareValue);
|
|
69
|
-
switch (e.compare) {
|
|
70
|
-
case "equals":
|
|
71
|
-
return o.value === a;
|
|
72
|
-
case "notEquals":
|
|
73
|
-
return o.value !== a;
|
|
74
|
-
case "greaterThan":
|
|
75
|
-
return o.value > a;
|
|
76
|
-
case "greaterThanOrEqualTo":
|
|
77
|
-
return o.value >= a;
|
|
78
|
-
case "lessThan":
|
|
79
|
-
return o.value < a;
|
|
80
|
-
case "lessThanOrEqualTo":
|
|
81
|
-
return o.value <= a;
|
|
82
|
-
}
|
|
83
|
-
} catch {
|
|
84
|
-
return console.error(`Failed to parse number in if-block ${n.id}`, o.value), !1;
|
|
85
|
-
}
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
case "enum":
|
|
89
|
-
switch (e.compare) {
|
|
90
|
-
case "equals":
|
|
91
|
-
return o.value.length === 1 && o.value[0] === e.compareValue;
|
|
92
|
-
case "notEquals":
|
|
93
|
-
return o.value.length === 1 && o.value[0] !== e.compareValue;
|
|
94
|
-
case "contains":
|
|
95
|
-
return o.value.includes(e.compareValue);
|
|
96
|
-
case "notContains":
|
|
97
|
-
return !o.value.includes(e.compareValue);
|
|
98
|
-
}
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
}, De = (e, { context: t, submissions: r }) => {
|
|
102
|
-
let n = "combinator" in e.data ? e.data.conditions : [e.data];
|
|
103
|
-
if (("combinator" in e.data ? e.data.combinator : "and") === "or") {
|
|
104
|
-
for (let i of n)
|
|
105
|
-
if (Vt({ condition: i, context: t, submissions: r, ifBlock: e }))
|
|
106
|
-
return !0;
|
|
107
|
-
return !1;
|
|
108
|
-
} else {
|
|
109
|
-
for (let i of n)
|
|
110
|
-
if (!Vt({ condition: i, context: t, submissions: r, ifBlock: e }))
|
|
111
|
-
return !1;
|
|
112
|
-
return !0;
|
|
113
|
-
}
|
|
114
|
-
}, Yr = /{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g, en = (e, { context: t, submissions: r }) => e.replace(Yr, (n, i, s = "") => {
|
|
115
|
-
let [o, ...a] = i.trim().split("."), f = Xt({ key: o, path: a, submissions: r, context: t });
|
|
116
|
-
if (!f)
|
|
117
|
-
return s;
|
|
118
|
-
switch (f.type) {
|
|
119
|
-
case "boolean":
|
|
120
|
-
return f.value === !0 ? "true" : "false";
|
|
121
|
-
case "file":
|
|
122
|
-
return f.value.map((p) => `${p.name} (${Re(p.sizeKb)})`).join(", ");
|
|
123
|
-
case "enum":
|
|
124
|
-
return f.value.join(", ");
|
|
125
|
-
case "address":
|
|
126
|
-
return Object.values(f.value).filter((p) => p && p.trim().length > 0).join(", ");
|
|
127
|
-
case "number":
|
|
128
|
-
case "string":
|
|
129
|
-
return f.value ? f.value.toString() : s;
|
|
130
|
-
case "phone":
|
|
131
|
-
return Qt(f.value);
|
|
132
|
-
case "integration": {
|
|
133
|
-
if (typeof f.value != "object" || Array.isArray(f.value))
|
|
134
|
-
break;
|
|
135
|
-
let p = st(f.value, a);
|
|
136
|
-
switch (typeof p) {
|
|
137
|
-
case "boolean":
|
|
138
|
-
return p === !0 ? "true" : "false";
|
|
139
|
-
case "string":
|
|
140
|
-
return p;
|
|
141
|
-
case "number":
|
|
142
|
-
return p.toString();
|
|
143
|
-
case "object":
|
|
144
|
-
if (Array.isArray(p) && p.every((C) => typeof C == "string"))
|
|
145
|
-
return p.join(", ");
|
|
146
|
-
}
|
|
147
|
-
break;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return s;
|
|
151
|
-
});
|
|
152
|
-
const sr = ({
|
|
153
|
-
context: e,
|
|
154
|
-
submissions: t
|
|
155
|
-
}) => ({
|
|
156
|
-
context: e,
|
|
157
|
-
submissions: t ?? {}
|
|
158
|
-
}), ae = (e, t) => en(e, sr(t)), tn = (e, t) => De(e, sr(t)), ar = ({
|
|
159
|
-
node: e,
|
|
160
|
-
nodes: t,
|
|
161
|
-
stopWhen: r
|
|
162
|
-
}) => {
|
|
163
|
-
if ((r == null ? void 0 : r(e)) === !0)
|
|
164
|
-
return e;
|
|
165
|
-
const n = e.nextId ? t.find((i) => i.id === e.nextId) : void 0;
|
|
166
|
-
if (n)
|
|
167
|
-
return ar({
|
|
168
|
-
node: n,
|
|
169
|
-
nodes: t,
|
|
170
|
-
stopWhen: r
|
|
171
|
-
});
|
|
172
|
-
}, rn = ({
|
|
173
|
-
childNode: e,
|
|
174
|
-
nodes: t
|
|
175
|
-
}) => {
|
|
176
|
-
const n = t.filter((i) => i.type === "if-block").find((i) => {
|
|
177
|
-
if (!i.branchId)
|
|
178
|
-
return !1;
|
|
179
|
-
const s = t.find((a) => a.id === i.branchId);
|
|
180
|
-
if (!s)
|
|
181
|
-
return !1;
|
|
182
|
-
const o = ar({
|
|
183
|
-
node: s,
|
|
184
|
-
nodes: t,
|
|
185
|
-
stopWhen: (a) => a.id === e.id
|
|
186
|
-
});
|
|
187
|
-
return !(!o || o.id !== e.id);
|
|
188
|
-
});
|
|
189
|
-
if (n != null && n.nextId)
|
|
190
|
-
return t.find((i) => i.id === n.nextId);
|
|
191
|
-
}, nn = ({
|
|
192
|
-
flow: e,
|
|
193
|
-
analytics: t,
|
|
194
|
-
logger: r,
|
|
195
|
-
talentBankClient: n,
|
|
196
|
-
context: i,
|
|
197
|
-
apiClient: s,
|
|
198
|
-
getSubmissions: o,
|
|
199
|
-
chatService: a,
|
|
200
|
-
onFlowEnd: f,
|
|
201
|
-
onInterpret: p,
|
|
202
|
-
t: C
|
|
203
|
-
}) => {
|
|
204
|
-
let v = new AbortController();
|
|
205
|
-
const h = {
|
|
206
|
-
...t.service,
|
|
207
|
-
log: (b) => t.service.log({
|
|
208
|
-
...b,
|
|
209
|
-
customProperties: {
|
|
210
|
-
...b.customProperties,
|
|
211
|
-
...t.customProperties
|
|
212
|
-
}
|
|
213
|
-
})
|
|
214
|
-
}, y = async (b, E) => {
|
|
215
|
-
if (v.signal.aborted)
|
|
216
|
-
return;
|
|
217
|
-
const V = o();
|
|
218
|
-
p == null || p(b, E);
|
|
219
|
-
try {
|
|
220
|
-
await sn({
|
|
221
|
-
flow: e,
|
|
222
|
-
analytics: h,
|
|
223
|
-
logger: r,
|
|
224
|
-
talentBankClient: n,
|
|
225
|
-
apiClient: s,
|
|
226
|
-
context: i,
|
|
227
|
-
node: b,
|
|
228
|
-
submissions: V,
|
|
229
|
-
t: C,
|
|
230
|
-
chat: {
|
|
231
|
-
sendMessage: async (x) => a.send({
|
|
232
|
-
groupId: b.id,
|
|
233
|
-
message: x,
|
|
234
|
-
signal: v.signal
|
|
235
|
-
}),
|
|
236
|
-
userInput: async (x) => a.input({
|
|
237
|
-
input: x,
|
|
238
|
-
signal: v.signal
|
|
239
|
-
}),
|
|
240
|
-
addToSubmissions: (x, _) => {
|
|
241
|
-
v.signal.aborted || a.addToSubmissions(x, _);
|
|
242
|
-
}
|
|
243
|
-
},
|
|
244
|
-
next: (x) => {
|
|
245
|
-
const _ = x ? e.nodes.find((I) => I.id === x) : rn({
|
|
246
|
-
childNode: b,
|
|
247
|
-
nodes: e.nodes
|
|
248
|
-
});
|
|
249
|
-
return _ ? y(_, b) : f == null ? void 0 : f(b);
|
|
250
|
-
},
|
|
251
|
-
end: () => f == null ? void 0 : f(b)
|
|
252
|
-
});
|
|
253
|
-
} catch (x) {
|
|
254
|
-
if (x instanceof Mr)
|
|
255
|
-
return;
|
|
256
|
-
throw x;
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
return {
|
|
260
|
-
interpret: async (b) => {
|
|
261
|
-
const E = e.nodes.find((V) => V.id === b) ?? Yt(e.nodes);
|
|
262
|
-
return y(E);
|
|
263
|
-
},
|
|
264
|
-
undo: (b) => {
|
|
265
|
-
let E = 1;
|
|
266
|
-
const V = e.nodes.find((_) => _.id === b[b.length - 1]);
|
|
267
|
-
for (let _ = b.length - 2; _ > 0; _--) {
|
|
268
|
-
const I = b[_], O = e.nodes.find((A) => A.id === I);
|
|
269
|
-
if (!O || (E++, O.type.startsWith("question-")))
|
|
270
|
-
break;
|
|
271
|
-
}
|
|
272
|
-
v.abort(), v = new AbortController();
|
|
273
|
-
const x = e.nodes.find((_) => _.id === b[b.length - E]);
|
|
274
|
-
return me(x, "Undo failed: new start node not found"), y(x, V), {
|
|
275
|
-
removed: E
|
|
276
|
-
};
|
|
277
|
-
},
|
|
278
|
-
abort: () => {
|
|
279
|
-
v.abort();
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
}, ir = (e) => `+${e.countryCode} ${e.phoneNumber}`;
|
|
283
|
-
async function sn(e) {
|
|
284
|
-
const t = e.node;
|
|
285
|
-
switch (t.type) {
|
|
286
|
-
case "text":
|
|
287
|
-
return pn({
|
|
288
|
-
...e,
|
|
289
|
-
node: t
|
|
290
|
-
});
|
|
291
|
-
case "image":
|
|
292
|
-
return mn({
|
|
293
|
-
...e,
|
|
294
|
-
node: t
|
|
295
|
-
});
|
|
296
|
-
case "question-text":
|
|
297
|
-
return gn({
|
|
298
|
-
...e,
|
|
299
|
-
node: t
|
|
300
|
-
});
|
|
301
|
-
case "question-enum":
|
|
302
|
-
return vn({
|
|
303
|
-
...e,
|
|
304
|
-
node: t
|
|
305
|
-
});
|
|
306
|
-
case "question-number":
|
|
307
|
-
return yn({
|
|
308
|
-
...e,
|
|
309
|
-
node: t
|
|
310
|
-
});
|
|
311
|
-
case "question-phone":
|
|
312
|
-
return bn({
|
|
313
|
-
...e,
|
|
314
|
-
node: t
|
|
315
|
-
});
|
|
316
|
-
case "question-boolean":
|
|
317
|
-
return xn({
|
|
318
|
-
...e,
|
|
319
|
-
node: t
|
|
320
|
-
});
|
|
321
|
-
case "question-file":
|
|
322
|
-
return kn({
|
|
323
|
-
...e,
|
|
324
|
-
node: t
|
|
325
|
-
});
|
|
326
|
-
case "question-address":
|
|
327
|
-
return wn({
|
|
328
|
-
...e,
|
|
329
|
-
node: t
|
|
330
|
-
});
|
|
331
|
-
case "end-flow":
|
|
332
|
-
return _n({
|
|
333
|
-
...e,
|
|
334
|
-
node: t
|
|
335
|
-
});
|
|
336
|
-
case "if-block":
|
|
337
|
-
return hn({
|
|
338
|
-
...e,
|
|
339
|
-
node: t
|
|
340
|
-
});
|
|
341
|
-
case "jump":
|
|
342
|
-
return cn({
|
|
343
|
-
...e,
|
|
344
|
-
node: t
|
|
345
|
-
});
|
|
346
|
-
case "link":
|
|
347
|
-
return fn({
|
|
348
|
-
...e,
|
|
349
|
-
node: t
|
|
350
|
-
});
|
|
351
|
-
case "integration-application-submit":
|
|
352
|
-
return dn({
|
|
353
|
-
...e,
|
|
354
|
-
node: t
|
|
355
|
-
});
|
|
356
|
-
case "add-submission":
|
|
357
|
-
return un({
|
|
358
|
-
...e,
|
|
359
|
-
node: t
|
|
360
|
-
});
|
|
361
|
-
case "integration-workflow-get":
|
|
362
|
-
throw Error("Workflow should be unreachable");
|
|
363
|
-
case "identify":
|
|
364
|
-
return on({
|
|
365
|
-
...e,
|
|
366
|
-
node: t
|
|
367
|
-
});
|
|
368
|
-
case "check-duplicate":
|
|
369
|
-
return ln({
|
|
370
|
-
...e,
|
|
371
|
-
node: t
|
|
372
|
-
});
|
|
373
|
-
case "feedback":
|
|
374
|
-
return an({
|
|
375
|
-
...e,
|
|
376
|
-
node: t
|
|
377
|
-
});
|
|
378
|
-
default:
|
|
379
|
-
throw new Error(`Unknown node: ${JSON.stringify(t)}`);
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
const Ve = (e, t) => {
|
|
383
|
-
var n;
|
|
384
|
-
const r = (n = e[t]) == null ? void 0 : n.value;
|
|
385
|
-
if (typeof r != "string" && typeof r != "number")
|
|
386
|
-
throw new Error(`Submission at “${t}” is not a string or number`);
|
|
387
|
-
return r;
|
|
388
|
-
};
|
|
389
|
-
async function an({
|
|
390
|
-
next: e,
|
|
391
|
-
node: t
|
|
392
|
-
}) {
|
|
393
|
-
e(t.nextId);
|
|
394
|
-
}
|
|
395
|
-
async function on({
|
|
396
|
-
next: e,
|
|
397
|
-
node: t,
|
|
398
|
-
analytics: r,
|
|
399
|
-
submissions: n,
|
|
400
|
-
logger: i
|
|
401
|
-
}) {
|
|
402
|
-
if (!n)
|
|
403
|
-
return e(t.nextId);
|
|
404
|
-
try {
|
|
405
|
-
r.log({
|
|
406
|
-
event: "IDENTIFY",
|
|
407
|
-
properties: {
|
|
408
|
-
identifier: Ve(n, t.data.key).toString(),
|
|
409
|
-
first_name: t.data.firstName ? Ve(n, t.data.firstName).toString() : void 0,
|
|
410
|
-
last_name: t.data.lastName ? Ve(n, t.data.lastName).toString() : void 0,
|
|
411
|
-
email: t.data.email ? Ve(n, t.data.email).toString() : void 0,
|
|
412
|
-
phone_number: t.data.phoneNumber ? Ve(n, t.data.phoneNumber).toString() : void 0,
|
|
413
|
-
custom_traits: t.data.customTraits ? Object.fromEntries(t.data.customTraits.map(({
|
|
414
|
-
key: s,
|
|
415
|
-
value: o
|
|
416
|
-
}) => {
|
|
417
|
-
var a;
|
|
418
|
-
return [s, (a = n[o]) == null ? void 0 : a.value];
|
|
419
|
-
})) : void 0
|
|
420
|
-
}
|
|
421
|
-
});
|
|
422
|
-
} catch (s) {
|
|
423
|
-
i.error(s);
|
|
424
|
-
} finally {
|
|
425
|
-
e(t.nextId);
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
async function ln({
|
|
429
|
-
next: e,
|
|
430
|
-
node: t,
|
|
431
|
-
talentBankClient: r,
|
|
432
|
-
submissions: n,
|
|
433
|
-
flow: i,
|
|
434
|
-
logger: s,
|
|
435
|
-
chat: o
|
|
436
|
-
}) {
|
|
437
|
-
var f;
|
|
438
|
-
let a = {
|
|
439
|
-
isDuplicate: !1
|
|
440
|
-
};
|
|
441
|
-
if (n && r) {
|
|
442
|
-
const p = t.data.scope === "job" ? (f = i.job) == null ? void 0 : f.id : void 0;
|
|
443
|
-
if (t.data.scope === "company" || p != null)
|
|
444
|
-
try {
|
|
445
|
-
a = await r.checkDuplicate({
|
|
446
|
-
email: Ve(n, t.data.email).toString(),
|
|
447
|
-
jobId: p,
|
|
448
|
-
scope: t.data.scope
|
|
449
|
-
});
|
|
450
|
-
} catch (C) {
|
|
451
|
-
s.error("[check-duplicate]", C);
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
o.addToSubmissions(t.data.key, {
|
|
455
|
-
type: "integration",
|
|
456
|
-
value: a
|
|
457
|
-
}), e(t.nextId);
|
|
458
|
-
}
|
|
459
|
-
async function cn({
|
|
460
|
-
next: e,
|
|
461
|
-
node: t
|
|
462
|
-
}) {
|
|
463
|
-
e(t.data.targetId);
|
|
464
|
-
}
|
|
465
|
-
async function un({
|
|
466
|
-
next: e,
|
|
467
|
-
node: t,
|
|
468
|
-
logger: r,
|
|
469
|
-
submissions: n,
|
|
470
|
-
context: i
|
|
471
|
-
}) {
|
|
472
|
-
if (!n) {
|
|
473
|
-
r.error("Submissions not found");
|
|
474
|
-
return;
|
|
475
|
-
}
|
|
476
|
-
n[t.data.key] = {
|
|
477
|
-
type: "string",
|
|
478
|
-
value: ae(t.data.value, {
|
|
479
|
-
submissions: n,
|
|
480
|
-
context: i
|
|
481
|
-
})
|
|
482
|
-
}, e(t.nextId);
|
|
483
|
-
}
|
|
484
|
-
async function dn({
|
|
485
|
-
chat: e,
|
|
486
|
-
next: t,
|
|
487
|
-
node: r,
|
|
488
|
-
logger: n,
|
|
489
|
-
apiClient: i,
|
|
490
|
-
submissions: s,
|
|
491
|
-
analytics: o,
|
|
492
|
-
flow: a,
|
|
493
|
-
t: f
|
|
494
|
-
}) {
|
|
495
|
-
const p = async (C) => {
|
|
496
|
-
C !== !0 && await e.userInput({
|
|
497
|
-
type: "submit",
|
|
498
|
-
key: void 0,
|
|
499
|
-
config: {
|
|
500
|
-
label: r.data.submitLabel
|
|
501
|
-
}
|
|
502
|
-
}), await e.sendMessage({
|
|
503
|
-
type: "loading"
|
|
504
|
-
});
|
|
505
|
-
const {
|
|
506
|
-
anonymous_id: v,
|
|
507
|
-
session_id: h
|
|
508
|
-
} = o.getSessionInfo(), y = await i.fetch("/flow/submit", {
|
|
509
|
-
method: "POST",
|
|
510
|
-
body: JSON.stringify({
|
|
511
|
-
log_submit: !1,
|
|
512
|
-
integration_id: r.data.integrationId,
|
|
513
|
-
anonymous_id: v,
|
|
514
|
-
session_id: h,
|
|
515
|
-
job: a.job,
|
|
516
|
-
submissions: Nr(s || {})
|
|
517
|
-
})
|
|
518
|
-
}).catch((b) => b);
|
|
519
|
-
r.data.key && e.addToSubmissions(r.data.key, {
|
|
520
|
-
type: "integration",
|
|
521
|
-
value: y
|
|
522
|
-
}), at(y).with({
|
|
523
|
-
integration_response: R.select(R.union({
|
|
524
|
-
service: R.optional(R.string),
|
|
525
|
-
status: R.number,
|
|
526
|
-
data: R.any
|
|
527
|
-
}, {
|
|
528
|
-
service: R.optional(R.string),
|
|
529
|
-
status: R.number,
|
|
530
|
-
error: {
|
|
531
|
-
message: R.string,
|
|
532
|
-
data: R.any
|
|
533
|
-
}
|
|
534
|
-
}))
|
|
535
|
-
}, (b) => {
|
|
536
|
-
o.log({
|
|
537
|
-
event: "FLOW_SUBMIT",
|
|
538
|
-
properties: {
|
|
539
|
-
flow_id: a.id,
|
|
540
|
-
flow_version: a.version,
|
|
541
|
-
flow_session_id: a.data.flowSessionId,
|
|
542
|
-
flow_build: a.build,
|
|
543
|
-
service: b.service ?? "INVALID_SERVICE",
|
|
544
|
-
response: {
|
|
545
|
-
status: b.status,
|
|
546
|
-
payload: "data" in b ? b.data : b.error.data ?? null
|
|
547
|
-
},
|
|
548
|
-
job: a.job
|
|
549
|
-
}
|
|
550
|
-
});
|
|
551
|
-
}).otherwise(() => {
|
|
552
|
-
}), await at(y).with({
|
|
553
|
-
integration_response: {
|
|
554
|
-
data: R.select("redirect", {
|
|
555
|
-
redirect_url: R.string,
|
|
556
|
-
message: R.optional(R.union(R.string, R.nullish)),
|
|
557
|
-
button_text: R.optional(R.union(R.string, R.nullish))
|
|
558
|
-
})
|
|
559
|
-
}
|
|
560
|
-
}, async (b) => {
|
|
561
|
-
await e.sendMessage({
|
|
562
|
-
type: "text",
|
|
563
|
-
author: "bot",
|
|
564
|
-
text: b.redirect.message ?? f("submission_redirect_message")
|
|
565
|
-
});
|
|
566
|
-
try {
|
|
567
|
-
const E = new URL(b.redirect.redirect_url);
|
|
568
|
-
v && !E.searchParams.has("anonymous_id") && E.searchParams.set("anonymous_id", v), await e.sendMessage({
|
|
569
|
-
type: "link",
|
|
570
|
-
href: E.toString(),
|
|
571
|
-
text: b.redirect.button_text ?? f("complete_submission"),
|
|
572
|
-
onClick: () => {
|
|
573
|
-
if (!h) {
|
|
574
|
-
n.error("session_id not set, cannot log FLOW_REDIRECT event");
|
|
575
|
-
return;
|
|
576
|
-
}
|
|
577
|
-
o.log({
|
|
578
|
-
event: "FLOW_REDIRECT",
|
|
579
|
-
properties: {
|
|
580
|
-
flow_build: a.build,
|
|
581
|
-
flow_id: a.id,
|
|
582
|
-
flow_session_id: h,
|
|
583
|
-
flow_version: a.version,
|
|
584
|
-
href: E.toString(),
|
|
585
|
-
job: a.job
|
|
586
|
-
}
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
|
-
});
|
|
590
|
-
} catch (E) {
|
|
591
|
-
n.error(`Invalid redirect URL: ${b.redirect.redirect_url}`, E), e.sendMessage({
|
|
592
|
-
type: "system",
|
|
593
|
-
variant: "error",
|
|
594
|
-
text: f("redirect_url_error")
|
|
595
|
-
});
|
|
596
|
-
}
|
|
597
|
-
t(r.nextId);
|
|
598
|
-
}).with({
|
|
599
|
-
success: !0
|
|
600
|
-
}, async () => {
|
|
601
|
-
r.data.skipConfirmation !== !0 && await e.sendMessage({
|
|
602
|
-
type: "system",
|
|
603
|
-
variant: "success",
|
|
604
|
-
text: f("submission_completed")
|
|
605
|
-
}), t(r.nextId);
|
|
606
|
-
}).with({
|
|
607
|
-
integration_response: {
|
|
608
|
-
error: R.select("error", {
|
|
609
|
-
message: R.string
|
|
610
|
-
})
|
|
611
|
-
}
|
|
612
|
-
}, async (b) => {
|
|
613
|
-
n.error(b.error), await e.sendMessage({
|
|
614
|
-
type: "system",
|
|
615
|
-
variant: "error",
|
|
616
|
-
text: b.error.message || f("submission_failed")
|
|
617
|
-
}), await p(!1);
|
|
618
|
-
}).otherwise(async (b) => {
|
|
619
|
-
n.error(b), await e.sendMessage({
|
|
620
|
-
type: "system",
|
|
621
|
-
variant: "error",
|
|
622
|
-
text: f("submission_failed")
|
|
623
|
-
}), await p(!1);
|
|
624
|
-
});
|
|
625
|
-
};
|
|
626
|
-
await p(r.data.skipConfirmation);
|
|
627
|
-
}
|
|
628
|
-
async function fn({
|
|
629
|
-
chat: e,
|
|
630
|
-
next: t,
|
|
631
|
-
node: r,
|
|
632
|
-
submissions: n,
|
|
633
|
-
context: i
|
|
634
|
-
}) {
|
|
635
|
-
await e.sendMessage({
|
|
636
|
-
type: "link",
|
|
637
|
-
href: ae(r.data.href, {
|
|
638
|
-
submissions: n,
|
|
639
|
-
context: i
|
|
640
|
-
}),
|
|
641
|
-
text: ae(r.data.cta, {
|
|
642
|
-
submissions: n,
|
|
643
|
-
context: i
|
|
644
|
-
})
|
|
645
|
-
}), t(r.nextId);
|
|
646
|
-
}
|
|
647
|
-
async function hn({
|
|
648
|
-
submissions: e,
|
|
649
|
-
next: t,
|
|
650
|
-
node: r,
|
|
651
|
-
context: n
|
|
652
|
-
}) {
|
|
653
|
-
t(tn(r, {
|
|
654
|
-
submissions: e,
|
|
655
|
-
context: n
|
|
656
|
-
}) ? r.branchId : r.nextId);
|
|
657
|
-
}
|
|
658
|
-
async function pn({
|
|
659
|
-
chat: e,
|
|
660
|
-
next: t,
|
|
661
|
-
node: r,
|
|
662
|
-
submissions: n,
|
|
663
|
-
context: i
|
|
664
|
-
}) {
|
|
665
|
-
await e.sendMessage({
|
|
666
|
-
author: "bot",
|
|
667
|
-
type: "text",
|
|
668
|
-
text: ae(r.data.text, {
|
|
669
|
-
submissions: n,
|
|
670
|
-
context: i
|
|
671
|
-
})
|
|
672
|
-
}), t(r.nextId);
|
|
673
|
-
}
|
|
674
|
-
async function mn({
|
|
675
|
-
chat: e,
|
|
676
|
-
next: t,
|
|
677
|
-
node: r
|
|
678
|
-
}) {
|
|
679
|
-
await e.sendMessage({
|
|
680
|
-
author: "bot",
|
|
681
|
-
type: "image",
|
|
682
|
-
url: r.data.url,
|
|
683
|
-
height: r.data.height,
|
|
684
|
-
width: r.data.width
|
|
685
|
-
}), t(r.nextId);
|
|
686
|
-
}
|
|
687
|
-
async function gn({
|
|
688
|
-
chat: e,
|
|
689
|
-
next: t,
|
|
690
|
-
node: r,
|
|
691
|
-
submissions: n,
|
|
692
|
-
context: i,
|
|
693
|
-
t: s
|
|
694
|
-
}) {
|
|
695
|
-
await e.sendMessage({
|
|
696
|
-
author: "bot",
|
|
697
|
-
type: "text",
|
|
698
|
-
text: ae(r.data.question, {
|
|
699
|
-
submissions: n,
|
|
700
|
-
context: i
|
|
701
|
-
})
|
|
702
|
-
});
|
|
703
|
-
const o = r.data.format === "phone" ? await e.userInput({
|
|
704
|
-
key: r.data.key,
|
|
705
|
-
type: "phone",
|
|
706
|
-
config: {
|
|
707
|
-
optional: r.data.optional,
|
|
708
|
-
placeholder: r.data.placeholder,
|
|
709
|
-
minChars: r.data.minChars,
|
|
710
|
-
maxChars: r.data.maxChars,
|
|
711
|
-
submissionFormat: "text",
|
|
712
|
-
defaultValue: {}
|
|
713
|
-
}
|
|
714
|
-
}) : await e.userInput({
|
|
715
|
-
key: r.data.key,
|
|
716
|
-
type: "text",
|
|
717
|
-
config: {
|
|
718
|
-
optional: r.data.optional,
|
|
719
|
-
placeholder: r.data.placeholder,
|
|
720
|
-
format: r.data.format,
|
|
721
|
-
maxChars: r.data.maxChars,
|
|
722
|
-
minChars: r.data.minChars
|
|
723
|
-
}
|
|
724
|
-
});
|
|
725
|
-
o === null ? await e.sendMessage({
|
|
726
|
-
type: "system",
|
|
727
|
-
variant: "info",
|
|
728
|
-
text: s("skipped")
|
|
729
|
-
}) : await e.sendMessage({
|
|
730
|
-
author: "user",
|
|
731
|
-
type: "text",
|
|
732
|
-
text: o.type === "phone" ? ir(o.value) : o.value
|
|
733
|
-
}), t(r.nextId);
|
|
734
|
-
}
|
|
735
|
-
async function yn({
|
|
736
|
-
chat: e,
|
|
737
|
-
next: t,
|
|
738
|
-
node: r,
|
|
739
|
-
submissions: n,
|
|
740
|
-
context: i,
|
|
741
|
-
t: s
|
|
742
|
-
}) {
|
|
743
|
-
await e.sendMessage({
|
|
744
|
-
author: "bot",
|
|
745
|
-
type: "text",
|
|
746
|
-
text: ae(r.data.question, {
|
|
747
|
-
submissions: n,
|
|
748
|
-
context: i
|
|
749
|
-
})
|
|
750
|
-
});
|
|
751
|
-
const o = await e.userInput({
|
|
752
|
-
key: r.data.key,
|
|
753
|
-
type: "number",
|
|
754
|
-
config: {
|
|
755
|
-
max: r.data.max,
|
|
756
|
-
min: r.data.min,
|
|
757
|
-
optional: r.data.optional,
|
|
758
|
-
placeholder: r.data.placeholder,
|
|
759
|
-
decimalCases: r.data.decimalCases
|
|
760
|
-
}
|
|
761
|
-
});
|
|
762
|
-
o === null ? await e.sendMessage({
|
|
763
|
-
type: "system",
|
|
764
|
-
variant: "info",
|
|
765
|
-
text: s("skipped")
|
|
766
|
-
}) : await e.sendMessage({
|
|
767
|
-
author: "user",
|
|
768
|
-
type: "text",
|
|
769
|
-
text: o.value.toString()
|
|
770
|
-
}), t(r.nextId);
|
|
771
|
-
}
|
|
772
|
-
async function bn({
|
|
773
|
-
chat: e,
|
|
774
|
-
next: t,
|
|
775
|
-
node: r,
|
|
776
|
-
submissions: n,
|
|
777
|
-
context: i
|
|
778
|
-
}) {
|
|
779
|
-
await e.sendMessage({
|
|
780
|
-
author: "bot",
|
|
781
|
-
type: "text",
|
|
782
|
-
text: ae(r.data.question, {
|
|
783
|
-
submissions: n,
|
|
784
|
-
context: i
|
|
785
|
-
})
|
|
786
|
-
});
|
|
787
|
-
const s = await e.userInput({
|
|
788
|
-
key: r.data.key,
|
|
789
|
-
type: "phone",
|
|
790
|
-
config: {
|
|
791
|
-
minChars: r.data.minChars,
|
|
792
|
-
defaultValue: {
|
|
793
|
-
countryCode: r.data.defaultCountryCode
|
|
794
|
-
},
|
|
795
|
-
placeholder: r.data.placeholder,
|
|
796
|
-
submissionFormat: "phone",
|
|
797
|
-
optional: r.data.optional
|
|
798
|
-
}
|
|
799
|
-
});
|
|
800
|
-
s === null ? await e.sendMessage({
|
|
801
|
-
type: "system",
|
|
802
|
-
variant: "info",
|
|
803
|
-
text: "Skipped"
|
|
804
|
-
}) : await e.sendMessage({
|
|
805
|
-
author: "user",
|
|
806
|
-
type: "text",
|
|
807
|
-
text: s.type === "phone" ? ir(s.value) : s.value
|
|
808
|
-
}), t(r.nextId);
|
|
809
|
-
}
|
|
810
|
-
async function vn({
|
|
811
|
-
chat: e,
|
|
812
|
-
next: t,
|
|
813
|
-
node: r,
|
|
814
|
-
submissions: n,
|
|
815
|
-
context: i,
|
|
816
|
-
t: s
|
|
817
|
-
}) {
|
|
818
|
-
await e.sendMessage({
|
|
819
|
-
author: "bot",
|
|
820
|
-
type: "text",
|
|
821
|
-
text: ae(r.data.question, {
|
|
822
|
-
submissions: n,
|
|
823
|
-
context: i
|
|
824
|
-
})
|
|
825
|
-
});
|
|
826
|
-
const o = await e.userInput({
|
|
827
|
-
key: r.data.key,
|
|
828
|
-
type: "multiple-choice",
|
|
829
|
-
config: r.data
|
|
830
|
-
});
|
|
831
|
-
o.value.length === 0 ? await e.sendMessage({
|
|
832
|
-
type: "system",
|
|
833
|
-
variant: "info",
|
|
834
|
-
text: s("skipped")
|
|
835
|
-
}) : await e.sendMessage({
|
|
836
|
-
author: "user",
|
|
837
|
-
type: "text",
|
|
838
|
-
text: r.data.options.filter((a) => o.value.includes(a.value)).map((a) => a.label).join(", ")
|
|
839
|
-
}), t(r.nextId);
|
|
840
|
-
}
|
|
841
|
-
async function xn({
|
|
842
|
-
chat: e,
|
|
843
|
-
next: t,
|
|
844
|
-
node: r,
|
|
845
|
-
submissions: n,
|
|
846
|
-
context: i,
|
|
847
|
-
t: s
|
|
848
|
-
}) {
|
|
849
|
-
await e.sendMessage({
|
|
850
|
-
author: "bot",
|
|
851
|
-
type: "text",
|
|
852
|
-
text: ae(r.data.question, {
|
|
853
|
-
submissions: n,
|
|
854
|
-
context: i
|
|
855
|
-
})
|
|
856
|
-
});
|
|
857
|
-
const o = await e.userInput({
|
|
858
|
-
key: r.data.key,
|
|
859
|
-
type: "boolean",
|
|
860
|
-
config: {
|
|
861
|
-
optional: r.data.optional,
|
|
862
|
-
labels: {
|
|
863
|
-
true: r.data.trueLabel,
|
|
864
|
-
false: r.data.falseLabel
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
});
|
|
868
|
-
o === null ? await e.sendMessage({
|
|
869
|
-
type: "system",
|
|
870
|
-
variant: "info",
|
|
871
|
-
text: s("skipped")
|
|
872
|
-
}) : await e.sendMessage({
|
|
873
|
-
author: "user",
|
|
874
|
-
type: "text",
|
|
875
|
-
text: o.value === !0 ? r.data.trueLabel : r.data.falseLabel
|
|
876
|
-
}), t(r.nextId);
|
|
877
|
-
}
|
|
878
|
-
async function wn({
|
|
879
|
-
chat: e,
|
|
880
|
-
next: t,
|
|
881
|
-
node: r,
|
|
882
|
-
t: n
|
|
883
|
-
}) {
|
|
884
|
-
await e.sendMessage({
|
|
885
|
-
author: "bot",
|
|
886
|
-
type: "text",
|
|
887
|
-
text: r.data.question
|
|
888
|
-
});
|
|
889
|
-
const i = await e.userInput({
|
|
890
|
-
type: "address",
|
|
891
|
-
key: r.data.key,
|
|
892
|
-
config: {
|
|
893
|
-
optional: r.data.optional,
|
|
894
|
-
keys: r.data.keys,
|
|
895
|
-
placeholder: r.data.placeholder
|
|
896
|
-
}
|
|
897
|
-
});
|
|
898
|
-
if (i === null)
|
|
899
|
-
await e.sendMessage({
|
|
900
|
-
type: "system",
|
|
901
|
-
variant: "info",
|
|
902
|
-
text: n("skipped")
|
|
903
|
-
});
|
|
904
|
-
else {
|
|
905
|
-
const s = Object.values(i.value).filter((o) => o && o.trim().length > 0).join(", ");
|
|
906
|
-
await e.sendMessage({
|
|
907
|
-
author: "user",
|
|
908
|
-
type: "text",
|
|
909
|
-
text: s
|
|
910
|
-
});
|
|
911
|
-
}
|
|
912
|
-
return t(r.nextId);
|
|
913
|
-
}
|
|
914
|
-
async function kn({
|
|
915
|
-
node: e,
|
|
916
|
-
chat: t,
|
|
917
|
-
next: r,
|
|
918
|
-
submissions: n,
|
|
919
|
-
context: i,
|
|
920
|
-
t: s
|
|
921
|
-
}) {
|
|
922
|
-
await t.sendMessage({
|
|
923
|
-
author: "bot",
|
|
924
|
-
type: "text",
|
|
925
|
-
text: ae(e.data.question, {
|
|
926
|
-
submissions: n,
|
|
927
|
-
context: i
|
|
928
|
-
})
|
|
929
|
-
});
|
|
930
|
-
const o = await t.userInput({
|
|
931
|
-
key: e.data.key,
|
|
932
|
-
type: "file",
|
|
933
|
-
config: {
|
|
934
|
-
optional: e.data.optional,
|
|
935
|
-
extensions: e.data.extensions,
|
|
936
|
-
// default value for fileSizeLimitKib is 10MB
|
|
937
|
-
fileSizeLimitKib: e.data.maxSizeKb ?? 10 * 1024,
|
|
938
|
-
allowMultiple: e.data.multiple === !0
|
|
939
|
-
}
|
|
940
|
-
});
|
|
941
|
-
if (o === null)
|
|
942
|
-
await t.sendMessage({
|
|
943
|
-
type: "system",
|
|
944
|
-
variant: "info",
|
|
945
|
-
text: s("skipped")
|
|
946
|
-
});
|
|
947
|
-
else
|
|
948
|
-
for (const a of o.value)
|
|
949
|
-
await t.sendMessage({
|
|
950
|
-
author: "user",
|
|
951
|
-
type: "file",
|
|
952
|
-
fileName: a.name,
|
|
953
|
-
fileSizeKb: a.sizeKb
|
|
954
|
-
});
|
|
955
|
-
r(e.nextId);
|
|
956
|
-
}
|
|
957
|
-
async function _n({
|
|
958
|
-
chat: e,
|
|
959
|
-
end: t,
|
|
960
|
-
node: r
|
|
961
|
-
}) {
|
|
962
|
-
await e.sendMessage({
|
|
963
|
-
type: "system",
|
|
964
|
-
variant: "info",
|
|
965
|
-
text: r.data.systemMessage
|
|
966
|
-
}), t();
|
|
967
|
-
}
|
|
968
|
-
function Et(e, t) {
|
|
969
|
-
let r;
|
|
970
|
-
return (...n) => {
|
|
971
|
-
window.clearTimeout(r), r = window.setTimeout(() => e(...n), t);
|
|
972
|
-
};
|
|
973
|
-
}
|
|
974
|
-
function Cn({ debounce: e, scroll: t, polyfill: r, offsetSize: n } = { debounce: 0, scroll: !1, offsetSize: !1 }) {
|
|
975
|
-
const i = r || (typeof window > "u" ? class {
|
|
976
|
-
} : window.ResizeObserver);
|
|
977
|
-
if (!i)
|
|
978
|
-
throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");
|
|
979
|
-
const [s, o] = se({ left: 0, top: 0, width: 0, height: 0, bottom: 0, right: 0, x: 0, y: 0 }), a = ue({ element: null, scrollContainers: null, resizeObserver: null, lastBounds: s, orientationHandler: null }), f = e ? typeof e == "number" ? e : e.scroll : null, p = e ? typeof e == "number" ? e : e.resize : null, C = ue(!1);
|
|
980
|
-
ce(() => (C.current = !0, () => void (C.current = !1)));
|
|
981
|
-
const [v, h, y] = er(() => {
|
|
982
|
-
const x = () => {
|
|
983
|
-
if (!a.current.element)
|
|
984
|
-
return;
|
|
985
|
-
const { left: _, top: I, width: O, height: A, bottom: ye, right: Ce, x: ie, y: de } = a.current.element.getBoundingClientRect(), z = { left: _, top: I, width: O, height: A, bottom: ye, right: Ce, x: ie, y: de };
|
|
986
|
-
a.current.element instanceof HTMLElement && n && (z.height = a.current.element.offsetHeight, z.width = a.current.element.offsetWidth), Object.freeze(z), C.current && !Fn(a.current.lastBounds, z) && o(a.current.lastBounds = z);
|
|
987
|
-
};
|
|
988
|
-
return [x, p ? Et(x, p) : x, f ? Et(x, f) : x];
|
|
989
|
-
}, [o, n, f, p]);
|
|
990
|
-
function b() {
|
|
991
|
-
a.current.scrollContainers && (a.current.scrollContainers.forEach((x) => x.removeEventListener("scroll", y, !0)), a.current.scrollContainers = null), a.current.resizeObserver && (a.current.resizeObserver.disconnect(), a.current.resizeObserver = null), a.current.orientationHandler && ("orientation" in screen && "removeEventListener" in screen.orientation ? screen.orientation.removeEventListener("change", a.current.orientationHandler) : "onorientationchange" in window && window.removeEventListener("orientationchange", a.current.orientationHandler));
|
|
992
|
-
}
|
|
993
|
-
function E() {
|
|
994
|
-
a.current.element && (a.current.resizeObserver = new i(y), a.current.resizeObserver.observe(a.current.element), t && a.current.scrollContainers && a.current.scrollContainers.forEach((x) => x.addEventListener("scroll", y, { capture: !0, passive: !0 })), a.current.orientationHandler = () => {
|
|
995
|
-
y();
|
|
996
|
-
}, "orientation" in screen && "addEventListener" in screen.orientation ? screen.orientation.addEventListener("change", a.current.orientationHandler) : "onorientationchange" in window && window.addEventListener("orientationchange", a.current.orientationHandler));
|
|
997
|
-
}
|
|
998
|
-
const V = (x) => {
|
|
999
|
-
!x || x === a.current.element || (b(), a.current.element = x, a.current.scrollContainers = or(x), E());
|
|
1000
|
-
};
|
|
1001
|
-
return Vn(y, !!t), Sn(h), ce(() => {
|
|
1002
|
-
b(), E();
|
|
1003
|
-
}, [t, y, h]), ce(() => b, []), [V, s, v];
|
|
1004
|
-
}
|
|
1005
|
-
function Sn(e) {
|
|
1006
|
-
ce(() => {
|
|
1007
|
-
const t = e;
|
|
1008
|
-
return window.addEventListener("resize", t), () => void window.removeEventListener("resize", t);
|
|
1009
|
-
}, [e]);
|
|
1010
|
-
}
|
|
1011
|
-
function Vn(e, t) {
|
|
1012
|
-
ce(() => {
|
|
1013
|
-
if (t) {
|
|
1014
|
-
const r = e;
|
|
1015
|
-
return window.addEventListener("scroll", r, { capture: !0, passive: !0 }), () => void window.removeEventListener("scroll", r, !0);
|
|
1016
|
-
}
|
|
1017
|
-
}, [e, t]);
|
|
1018
|
-
}
|
|
1019
|
-
function or(e) {
|
|
1020
|
-
const t = [];
|
|
1021
|
-
if (!e || e === document.body)
|
|
1022
|
-
return t;
|
|
1023
|
-
const { overflow: r, overflowX: n, overflowY: i } = window.getComputedStyle(e);
|
|
1024
|
-
return [r, n, i].some((s) => s === "auto" || s === "scroll") && t.push(e), [...t, ...or(e.parentElement)];
|
|
1025
|
-
}
|
|
1026
|
-
const En = ["x", "y", "top", "bottom", "left", "right", "width", "height"], Fn = (e, t) => En.every((r) => e[r] === t[r]), ke = ({
|
|
1027
|
-
class: e,
|
|
1028
|
-
...t
|
|
1029
|
-
}) => {
|
|
1030
|
-
const {
|
|
1031
|
-
t: r
|
|
1032
|
-
} = Q();
|
|
1033
|
-
return c("button", {
|
|
1034
|
-
class: je("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),
|
|
1035
|
-
type: "submit",
|
|
1036
|
-
...t,
|
|
1037
|
-
children: c("svg", {
|
|
1038
|
-
class: "block",
|
|
1039
|
-
width: "16",
|
|
1040
|
-
height: "16",
|
|
1041
|
-
viewBox: "0 0 16 16",
|
|
1042
|
-
fill: "transparent",
|
|
1043
|
-
stroke: "currentColor",
|
|
1044
|
-
"stroke-linecap": "round",
|
|
1045
|
-
"stroke-width": "2",
|
|
1046
|
-
children: [c("title", {
|
|
1047
|
-
children: r("send")
|
|
1048
|
-
}), c("path", {
|
|
1049
|
-
d: "M3.5 7.5L8 3L12.5 7.5"
|
|
1050
|
-
}), c("path", {
|
|
1051
|
-
d: "M8 4V13"
|
|
1052
|
-
})]
|
|
1053
|
-
})
|
|
1054
|
-
});
|
|
1055
|
-
}, Ie = ({
|
|
1056
|
-
error: e
|
|
1057
|
-
}) => !e || !e.message ? null : c("div", {
|
|
1058
|
-
role: "alert",
|
|
1059
|
-
class: "text-error-11 flex max-w-full items-center gap-1 overflow-hidden rounded-full px-2 py-2",
|
|
1060
|
-
children: [c("svg", {
|
|
1061
|
-
class: "text-error-9 h-4 w-4",
|
|
1062
|
-
viewBox: "0 0 16 16",
|
|
1063
|
-
fill: "none",
|
|
1064
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1065
|
-
children: [c("circle", {
|
|
1066
|
-
cx: "8",
|
|
1067
|
-
cy: "8",
|
|
1068
|
-
r: "6.3",
|
|
1069
|
-
stroke: "currentColor",
|
|
1070
|
-
"stroke-width": "1.4"
|
|
1071
|
-
}), c("rect", {
|
|
1072
|
-
x: "7",
|
|
1073
|
-
y: "4",
|
|
1074
|
-
width: "2",
|
|
1075
|
-
height: "5",
|
|
1076
|
-
fill: "currentColor"
|
|
1077
|
-
}), c("rect", {
|
|
1078
|
-
x: "7",
|
|
1079
|
-
y: "10",
|
|
1080
|
-
width: "2",
|
|
1081
|
-
height: "2",
|
|
1082
|
-
fill: "currentColor"
|
|
1083
|
-
})]
|
|
1084
|
-
}), c("p", {
|
|
1085
|
-
class: "truncate pr-1 text-sm",
|
|
1086
|
-
children: e.message
|
|
1087
|
-
})]
|
|
1088
|
-
}), _e = ({
|
|
1089
|
-
class: e,
|
|
1090
|
-
...t
|
|
1091
|
-
}) => {
|
|
1092
|
-
const {
|
|
1093
|
-
t: r
|
|
1094
|
-
} = Q();
|
|
1095
|
-
return c("button", {
|
|
1096
|
-
type: "button",
|
|
1097
|
-
class: je("fr touch-hitbox text-neutral-10 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),
|
|
1098
|
-
...t,
|
|
1099
|
-
children: [c("svg", {
|
|
1100
|
-
"aria-hidden": !0,
|
|
1101
|
-
class: "block",
|
|
1102
|
-
width: "16",
|
|
1103
|
-
height: "16",
|
|
1104
|
-
viewBox: "0 0 16 16",
|
|
1105
|
-
fill: "transparent",
|
|
1106
|
-
stroke: "currentColor",
|
|
1107
|
-
"stroke-linecap": "round",
|
|
1108
|
-
"stroke-width": "1.5",
|
|
1109
|
-
children: [c("title", {
|
|
1110
|
-
children: r("skip")
|
|
1111
|
-
}), c("path", {
|
|
1112
|
-
d: "M3.25 11.25A5 5 0 0 1 12 7"
|
|
1113
|
-
}), c("path", {
|
|
1114
|
-
d: "M13.25 4.5V8.25H9.5"
|
|
1115
|
-
})]
|
|
1116
|
-
}), r("skip")]
|
|
1117
|
-
});
|
|
1118
|
-
};
|
|
1119
|
-
var lt = { 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" };
|
|
1120
|
-
const $e = Ge("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", {
|
|
1121
|
-
variants: {
|
|
1122
|
-
optional: {
|
|
1123
|
-
true: "pr-16 pl-3",
|
|
1124
|
-
false: "pl-3 pr-3"
|
|
1125
|
-
}
|
|
1126
|
-
},
|
|
1127
|
-
defaultVariants: {
|
|
1128
|
-
optional: !1
|
|
1129
|
-
}
|
|
1130
|
-
}), In = "https://api.mapbox.com/search/searchbox/v1/suggest", An = "ZzRDWFU0dTZ3SF9aWk9RNGl6QzZaWS5RZmlFak13a0hPbGxXZXlNSGN5RUhObUJ6TXpSV08yUW5OdE5tSTZJU1lpd2lJb1JYYXRObmJ2Tm5iaGhHZWx4V1lpb2pJMUp5ZS5rcA==", Ln = (e) => atob(e).split("").reverse().join(""), oe = ge({
|
|
1131
|
-
name: Y()
|
|
1132
|
-
}), Mn = ge({
|
|
1133
|
-
suggestions: Dr(ge({
|
|
1134
|
-
full_address: rt(Y()),
|
|
1135
|
-
place_formatted: rt(Y()),
|
|
1136
|
-
name: rt(Y()),
|
|
1137
|
-
mapbox_id: Y(),
|
|
1138
|
-
context: Rr(ge({
|
|
1139
|
-
address: oe,
|
|
1140
|
-
street: oe,
|
|
1141
|
-
neighborhood: oe,
|
|
1142
|
-
locality: oe,
|
|
1143
|
-
district: oe,
|
|
1144
|
-
place: oe,
|
|
1145
|
-
region: oe,
|
|
1146
|
-
postcode: oe,
|
|
1147
|
-
country: oe
|
|
1148
|
-
}))
|
|
1149
|
-
}))
|
|
1150
|
-
}), Nn = ({
|
|
1151
|
-
logger: e,
|
|
1152
|
-
t
|
|
1153
|
-
}) => er(() => {
|
|
1154
|
-
var n;
|
|
1155
|
-
const r = (n = D.current$.peek().flow) == null ? void 0 : n.data.flowSessionId;
|
|
1156
|
-
return r ? {
|
|
1157
|
-
enabled: !0,
|
|
1158
|
-
getPredictions: async (i) => {
|
|
1159
|
-
var v;
|
|
1160
|
-
const s = new URL(In);
|
|
1161
|
-
s.searchParams.set("q", i), s.searchParams.set("session_token", r);
|
|
1162
|
-
const o = (v = D.current$.peek().flow) == null ? void 0 : v.locationOrigin;
|
|
1163
|
-
o && o.lat !== void 0 && o.lng !== void 0 && o.lat >= -90 && o.lat <= 90 && o.lng >= -180 && o.lng <= 180 && s.searchParams.set("proximity", `${o.lng},${o.lat}`), s.searchParams.set("access_token", Ln(An));
|
|
1164
|
-
const f = await fetch(s);
|
|
1165
|
-
if (!f.ok)
|
|
1166
|
-
return e.error("Failed to get address details", f), {
|
|
1167
|
-
ok: !1,
|
|
1168
|
-
error: t("address_error")
|
|
1169
|
-
};
|
|
1170
|
-
const p = Tr(Mn, await f.json());
|
|
1171
|
-
if (p.success === !1)
|
|
1172
|
-
return e.error("Failed to parse address details", p.issues), {
|
|
1173
|
-
ok: !1,
|
|
1174
|
-
error: t("address_error")
|
|
1175
|
-
};
|
|
1176
|
-
const {
|
|
1177
|
-
suggestions: C
|
|
1178
|
-
} = p.output;
|
|
1179
|
-
return {
|
|
1180
|
-
ok: !0,
|
|
1181
|
-
data: C.map((h) => {
|
|
1182
|
-
var y, b, E, V, x, _, I, O, A;
|
|
1183
|
-
return {
|
|
1184
|
-
label: h.full_address ?? h.place_formatted ?? h.name ?? h.mapbox_id,
|
|
1185
|
-
id: h.mapbox_id,
|
|
1186
|
-
address: {
|
|
1187
|
-
line1: ((y = h.context.address) == null ? void 0 : y.name) ?? ((b = h.context.street) == null ? void 0 : b.name),
|
|
1188
|
-
line2: void 0,
|
|
1189
|
-
line3: ((E = h.context.neighborhood) == null ? void 0 : E.name) ?? ((V = h.context.locality) == null ? void 0 : V.name),
|
|
1190
|
-
city: ((x = h.context.place) == null ? void 0 : x.name) ?? ((_ = h.context.district) == null ? void 0 : _.name),
|
|
1191
|
-
state: (I = h.context.region) == null ? void 0 : I.name,
|
|
1192
|
-
postcode: (O = h.context.postcode) == null ? void 0 : O.name,
|
|
1193
|
-
country: (A = h.context.country) == null ? void 0 : A.name
|
|
1194
|
-
}
|
|
1195
|
-
};
|
|
1196
|
-
})
|
|
1197
|
-
};
|
|
1198
|
-
}
|
|
1199
|
-
} : {
|
|
1200
|
-
enabled: !1
|
|
1201
|
-
};
|
|
1202
|
-
}, [e, t]), Ft = (e) => {
|
|
1203
|
-
const {
|
|
1204
|
-
t
|
|
1205
|
-
} = Q();
|
|
1206
|
-
return c("button", {
|
|
1207
|
-
type: "button",
|
|
1208
|
-
class: "text-neutral-10 hover:bg-neutral-4 hover:text-neutral-12 hover:border-neutral-5 flex items-center gap-1 rounded-[18px] border border-solid border-transparent px-3 py-1 pl-1.5 text-sm transition-colors",
|
|
1209
|
-
...e,
|
|
1210
|
-
children: [c("svg", {
|
|
1211
|
-
width: "16",
|
|
1212
|
-
height: "16",
|
|
1213
|
-
viewBox: "0 0 16 16",
|
|
1214
|
-
stroke: "currentColor",
|
|
1215
|
-
"stroke-width": "1.5",
|
|
1216
|
-
fill: "none",
|
|
1217
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1218
|
-
children: c("path", {
|
|
1219
|
-
d: "M10 3L5 8L10 13"
|
|
1220
|
-
})
|
|
1221
|
-
}), c("span", {
|
|
1222
|
-
children: t("back")
|
|
1223
|
-
})]
|
|
1224
|
-
});
|
|
1225
|
-
}, Tn = ({
|
|
1226
|
-
input: e,
|
|
1227
|
-
onSubmitSuccess: t,
|
|
1228
|
-
logger: r
|
|
1229
|
-
}) => {
|
|
1230
|
-
const {
|
|
1231
|
-
t: n
|
|
1232
|
-
} = Q(), [i, s] = se(), [o, a] = se([]), {
|
|
1233
|
-
enabled: f,
|
|
1234
|
-
getPredictions: p
|
|
1235
|
-
} = Nn({
|
|
1236
|
-
logger: r,
|
|
1237
|
-
t: n
|
|
1238
|
-
}), [C, v] = se(f ? "query" : "manual"), [h, y] = se(""), [b, E] = se(), V = (x) => {
|
|
1239
|
-
me(f, "Query state should not be enabled"), x = x.trim(), x !== (h == null ? void 0 : h.trim()) && (y(x), x === "" && a([]), E(void 0), p(x).then((_) => {
|
|
1240
|
-
if (_.ok === !1) {
|
|
1241
|
-
a([]), E(_.error);
|
|
1242
|
-
return;
|
|
1243
|
-
}
|
|
1244
|
-
a(_.data);
|
|
1245
|
-
}));
|
|
1246
|
-
};
|
|
1247
|
-
switch (C) {
|
|
1248
|
-
case "query":
|
|
1249
|
-
return me(f, "Query state should not be enabled"), c(Dn, {
|
|
1250
|
-
input: e,
|
|
1251
|
-
onSkip: () => t(null),
|
|
1252
|
-
onAddressSelect: (x) => {
|
|
1253
|
-
if (x === "") {
|
|
1254
|
-
s(void 0), v("manual");
|
|
1255
|
-
return;
|
|
1256
|
-
}
|
|
1257
|
-
const _ = o.find((I) => I.id === x);
|
|
1258
|
-
_ && (s(_.address), v("details"));
|
|
1259
|
-
},
|
|
1260
|
-
onAddressSearch: (x) => {
|
|
1261
|
-
V(x);
|
|
1262
|
-
},
|
|
1263
|
-
suggestions: o,
|
|
1264
|
-
query: h,
|
|
1265
|
-
error: b
|
|
1266
|
-
});
|
|
1267
|
-
case "details":
|
|
1268
|
-
return me(i !== void 0), c(At, {
|
|
1269
|
-
input: e,
|
|
1270
|
-
logger: r,
|
|
1271
|
-
onSubmitSuccess: t,
|
|
1272
|
-
addressFields: i,
|
|
1273
|
-
actions: c(Ft, {
|
|
1274
|
-
onClick: () => {
|
|
1275
|
-
v("query");
|
|
1276
|
-
}
|
|
1277
|
-
})
|
|
1278
|
-
});
|
|
1279
|
-
case "manual":
|
|
1280
|
-
return c(At, {
|
|
1281
|
-
logger: r,
|
|
1282
|
-
input: e,
|
|
1283
|
-
onSubmitSuccess: t,
|
|
1284
|
-
addressFields: {},
|
|
1285
|
-
actions: f ? c(Ft, {
|
|
1286
|
-
onClick: () => {
|
|
1287
|
-
v("query");
|
|
1288
|
-
}
|
|
1289
|
-
}) : void 0
|
|
1290
|
-
});
|
|
1291
|
-
}
|
|
1292
|
-
}, Dn = ({
|
|
1293
|
-
input: e,
|
|
1294
|
-
onSkip: t,
|
|
1295
|
-
suggestions: r,
|
|
1296
|
-
onAddressSelect: n,
|
|
1297
|
-
query: i,
|
|
1298
|
-
onAddressSearch: s,
|
|
1299
|
-
error: o
|
|
1300
|
-
}) => {
|
|
1301
|
-
const {
|
|
1302
|
-
t: a
|
|
1303
|
-
} = Q(), f = ue(null);
|
|
1304
|
-
return xe(() => {
|
|
1305
|
-
f.current && (f.current.focus(), f.current.select());
|
|
1306
|
-
}, []), c(we, {
|
|
1307
|
-
children: [c("form", {
|
|
1308
|
-
noValidate: !0,
|
|
1309
|
-
onSubmit: (p) => {
|
|
1310
|
-
p.preventDefault();
|
|
1311
|
-
const v = new FormData(p.currentTarget).get("address");
|
|
1312
|
-
typeof v == "string" && s(v);
|
|
1313
|
-
},
|
|
1314
|
-
class: "flex gap-2 p-2.5",
|
|
1315
|
-
children: [c("div", {
|
|
1316
|
-
class: "group relative flex-1",
|
|
1317
|
-
children: [c("input", {
|
|
1318
|
-
ref: f,
|
|
1319
|
-
name: "address",
|
|
1320
|
-
id: "chat-address",
|
|
1321
|
-
autocomplete: "address-line1 country-name postal-code",
|
|
1322
|
-
autoFocus: !0,
|
|
1323
|
-
placeholder: e.config.placeholder || a("address_search"),
|
|
1324
|
-
defaultValue: i,
|
|
1325
|
-
class: $e({
|
|
1326
|
-
optional: !!e.config.optional,
|
|
1327
|
-
className: "w-full rounded-full"
|
|
1328
|
-
})
|
|
1329
|
-
}), c("button", {
|
|
1330
|
-
type: "submit",
|
|
1331
|
-
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",
|
|
1332
|
-
children: c("svg", {
|
|
1333
|
-
width: "16",
|
|
1334
|
-
height: "16",
|
|
1335
|
-
viewBox: "0 0 16 16",
|
|
1336
|
-
fill: "none",
|
|
1337
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1338
|
-
children: [c("g", {
|
|
1339
|
-
id: "inploi",
|
|
1340
|
-
stroke: "currentColor",
|
|
1341
|
-
"stroke-linecap": "round",
|
|
1342
|
-
"stroke-linejoin": "round",
|
|
1343
|
-
strokeWidth: "1.5",
|
|
1344
|
-
children: [c("circle", {
|
|
1345
|
-
cx: "7",
|
|
1346
|
-
cy: "7",
|
|
1347
|
-
r: "4"
|
|
1348
|
-
}), c("path", {
|
|
1349
|
-
d: "M10 10L13 13"
|
|
1350
|
-
})]
|
|
1351
|
-
}), c("span", {
|
|
1352
|
-
class: "sr-only",
|
|
1353
|
-
children: a("search")
|
|
1354
|
-
})]
|
|
1355
|
-
})
|
|
1356
|
-
})]
|
|
1357
|
-
}), e.config.optional && c(_e, {
|
|
1358
|
-
class: "relative",
|
|
1359
|
-
onClick: t
|
|
1360
|
-
})]
|
|
1361
|
-
}), o ? c(Ie, {
|
|
1362
|
-
error: {
|
|
1363
|
-
message: o
|
|
1364
|
-
}
|
|
1365
|
-
}) : null, c("ul", {
|
|
1366
|
-
children: [r.map((p) => c("li", {
|
|
1367
|
-
children: c("button", {
|
|
1368
|
-
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",
|
|
1369
|
-
onClick: () => {
|
|
1370
|
-
n(p.id);
|
|
1371
|
-
},
|
|
1372
|
-
children: [c("span", {
|
|
1373
|
-
class: "flex-grow",
|
|
1374
|
-
children: p.label
|
|
1375
|
-
}), c("svg", {
|
|
1376
|
-
class: "flex-none",
|
|
1377
|
-
width: "16",
|
|
1378
|
-
height: "16",
|
|
1379
|
-
viewBox: "0 0 16 16",
|
|
1380
|
-
stroke: "currentColor",
|
|
1381
|
-
"stroke-width": "1.5",
|
|
1382
|
-
fill: "none",
|
|
1383
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1384
|
-
children: c("path", {
|
|
1385
|
-
d: "M6 3L11 8L6 13"
|
|
1386
|
-
})
|
|
1387
|
-
})]
|
|
1388
|
-
})
|
|
1389
|
-
}, p.id)), c("li", {
|
|
1390
|
-
children: c("button", {
|
|
1391
|
-
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",
|
|
1392
|
-
onClick: () => {
|
|
1393
|
-
n("");
|
|
1394
|
-
},
|
|
1395
|
-
children: c("span", {
|
|
1396
|
-
class: "flex-grow",
|
|
1397
|
-
children: a("address_manual")
|
|
1398
|
-
})
|
|
1399
|
-
})
|
|
1400
|
-
}, "")]
|
|
1401
|
-
})]
|
|
1402
|
-
});
|
|
1403
|
-
}, It = ["line1", "line2", "line3", "city", "state", "postcode", "country"], At = ({
|
|
1404
|
-
addressFields: e,
|
|
1405
|
-
onSubmitSuccess: t,
|
|
1406
|
-
actions: r,
|
|
1407
|
-
input: n
|
|
1408
|
-
}) => {
|
|
1409
|
-
const i = ue(null);
|
|
1410
|
-
xe(() => {
|
|
1411
|
-
if (i.current) {
|
|
1412
|
-
const a = i.current.querySelector("input");
|
|
1413
|
-
a && (a.focus(), a.select());
|
|
1414
|
-
}
|
|
1415
|
-
}, []);
|
|
1416
|
-
const s = Object.keys(lt), {
|
|
1417
|
-
t: o
|
|
1418
|
-
} = Q();
|
|
1419
|
-
return c("form", {
|
|
1420
|
-
class: "bg-neutral-1/90 flex flex-col justify-end gap-2 p-2",
|
|
1421
|
-
onSubmit: (a) => {
|
|
1422
|
-
const f = new FormData(a.currentTarget), p = Object.fromEntries(f.entries());
|
|
1423
|
-
t({
|
|
1424
|
-
type: "address",
|
|
1425
|
-
value: p
|
|
1426
|
-
});
|
|
1427
|
-
},
|
|
1428
|
-
children: [c("div", {
|
|
1429
|
-
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]",
|
|
1430
|
-
ref: i,
|
|
1431
|
-
children: It.map((a, f) => {
|
|
1432
|
-
const p = `isdk_${a}`, C = n.config.keys[a];
|
|
1433
|
-
return C ? c(we, {
|
|
1434
|
-
children: [c("label", {
|
|
1435
|
-
for: p,
|
|
1436
|
-
class: "text-neutral-9 [&:has(+*>input:focus)]:text-neutral-11 w-24 pb-2 text-xs uppercase leading-3 tracking-widest transition-colors",
|
|
1437
|
-
children: o(a)
|
|
1438
|
-
}), c("div", {
|
|
1439
|
-
class: "flex flex-col items-stretch gap-1.5",
|
|
1440
|
-
children: [a === "country" ? c("div", {
|
|
1441
|
-
class: "relative",
|
|
1442
|
-
children: [c("select", {
|
|
1443
|
-
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",
|
|
1444
|
-
name: C,
|
|
1445
|
-
id: p,
|
|
1446
|
-
defaultValue: e[a],
|
|
1447
|
-
required: !0,
|
|
1448
|
-
children: [e.country && !s.includes(e.country) ? c("option", {
|
|
1449
|
-
value: e[a],
|
|
1450
|
-
children: e[a]
|
|
1451
|
-
}) : c("option", {
|
|
1452
|
-
value: "",
|
|
1453
|
-
children: o("select_country")
|
|
1454
|
-
}), s.map((v) => c("option", {
|
|
1455
|
-
value: v,
|
|
1456
|
-
children: v
|
|
1457
|
-
}, v))]
|
|
1458
|
-
}), c("svg", {
|
|
1459
|
-
class: "text-neutral-12 absolute bottom-2.5 right-2 flex items-center justify-center",
|
|
1460
|
-
width: "16",
|
|
1461
|
-
height: "16",
|
|
1462
|
-
stroke: "currentColor",
|
|
1463
|
-
"stroke-width": "1.5",
|
|
1464
|
-
"stroke-linecap": "round",
|
|
1465
|
-
"stroke-linejoin": "round",
|
|
1466
|
-
viewBox: "0 0 16 16",
|
|
1467
|
-
fill: "none",
|
|
1468
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1469
|
-
children: c("path", {
|
|
1470
|
-
d: "M4 6.5L8 10.5L12 6.5"
|
|
1471
|
-
})
|
|
1472
|
-
})]
|
|
1473
|
-
}) : c("input", {
|
|
1474
|
-
autoFocus: f === 0 ? !0 : void 0,
|
|
1475
|
-
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",
|
|
1476
|
-
name: C,
|
|
1477
|
-
id: p,
|
|
1478
|
-
defaultValue: e[a],
|
|
1479
|
-
required: !0
|
|
1480
|
-
}), f === It.length - 1 ? c("hr", {
|
|
1481
|
-
class: "m-0 w-full border-b border-b-transparent"
|
|
1482
|
-
}) : c("hr", {
|
|
1483
|
-
class: "border-b-neutral-5 m-0 w-full border-b border-solid"
|
|
1484
|
-
})]
|
|
1485
|
-
})]
|
|
1486
|
-
}) : null;
|
|
1487
|
-
})
|
|
1488
|
-
}), c("div", {
|
|
1489
|
-
class: "flex w-full flex-1 ",
|
|
1490
|
-
children: [c("div", {
|
|
1491
|
-
class: "flex-grow",
|
|
1492
|
-
children: r
|
|
1493
|
-
}), c(ke, {
|
|
1494
|
-
class: "flex items-center justify-center"
|
|
1495
|
-
})]
|
|
1496
|
-
})]
|
|
1497
|
-
});
|
|
1498
|
-
}, ct = () => {
|
|
1499
|
-
const e = ue(null);
|
|
1500
|
-
return ce(() => {
|
|
1501
|
-
var t;
|
|
1502
|
-
(t = e.current) == null || t.focus();
|
|
1503
|
-
}, []), e;
|
|
1504
|
-
}, lr = ["true", "false"], Rn = Pr(lr), On = "answer", cr = "flex items-center flex-wrap gap-2 p-2.5", ur = "min-w-0 max-w-full flex-auto", dr = tr(({
|
|
1505
|
-
label: e,
|
|
1506
|
-
...t
|
|
1507
|
-
}, r) => c("button", {
|
|
1508
|
-
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",
|
|
1509
|
-
...t,
|
|
1510
|
-
ref: r,
|
|
1511
|
-
children: c("p", {
|
|
1512
|
-
class: "text-center text-base",
|
|
1513
|
-
children: e
|
|
1514
|
-
})
|
|
1515
|
-
})), Bn = ({
|
|
1516
|
-
input: e,
|
|
1517
|
-
onSubmitSuccess: t
|
|
1518
|
-
}) => {
|
|
1519
|
-
const r = ct();
|
|
1520
|
-
return c("form", {
|
|
1521
|
-
noValidate: !0,
|
|
1522
|
-
class: "",
|
|
1523
|
-
onSubmit: (n) => {
|
|
1524
|
-
n.preventDefault();
|
|
1525
|
-
const i = Or(n).value, s = Br(Rn, i);
|
|
1526
|
-
t({
|
|
1527
|
-
type: "boolean",
|
|
1528
|
-
value: s === "true"
|
|
1529
|
-
});
|
|
1530
|
-
},
|
|
1531
|
-
children: [c("ul", {
|
|
1532
|
-
class: cr,
|
|
1533
|
-
children: lr.map((n, i) => c("li", {
|
|
1534
|
-
class: ur,
|
|
1535
|
-
children: c(dr, {
|
|
1536
|
-
ref: i === 0 ? r : null,
|
|
1537
|
-
type: "submit",
|
|
1538
|
-
name: On,
|
|
1539
|
-
value: n,
|
|
1540
|
-
label: e.config.labels[n]
|
|
1541
|
-
}, n)
|
|
1542
|
-
}))
|
|
1543
|
-
}), e.config.optional && c("div", {
|
|
1544
|
-
class: "px-2 pb-2",
|
|
1545
|
-
children: c(_e, {
|
|
1546
|
-
class: "relative w-full",
|
|
1547
|
-
type: "button",
|
|
1548
|
-
onClick: () => t(null)
|
|
1549
|
-
})
|
|
1550
|
-
})]
|
|
1551
|
-
});
|
|
1552
|
-
}, Pn = (e) => new Promise((t, r) => {
|
|
1553
|
-
const n = new FileReader();
|
|
1554
|
-
n.readAsDataURL(e), n.onload = () => n.result ? t(n.result.toString()) : r("No result from reader"), n.onerror = r;
|
|
1555
|
-
}), jn = (e) => e.reduce((t, r) => t + r.sizeKb, 0), $n = Fe("file"), Lt = 3, Un = ({
|
|
1556
|
-
file: e,
|
|
1557
|
-
class: t,
|
|
1558
|
-
...r
|
|
1559
|
-
}) => {
|
|
1560
|
-
const n = e.name.split(".").pop(), i = e.name.replace(new RegExp(`.${n}$`), "");
|
|
1561
|
-
return c("div", {
|
|
1562
|
-
class: je("bg-accent-1 outline-accent-4 flex max-w-full gap-2 overflow-hidden rounded-lg px-3 py-2 text-sm outline", t),
|
|
1563
|
-
...r,
|
|
1564
|
-
children: [c("p", {
|
|
1565
|
-
"aria-label": "File name",
|
|
1566
|
-
class: "text-accent-12 flex flex-grow overflow-hidden",
|
|
1567
|
-
children: [c("span", {
|
|
1568
|
-
class: "block truncate",
|
|
1569
|
-
children: i
|
|
1570
|
-
}), c("span", {
|
|
1571
|
-
children: [".", n]
|
|
1572
|
-
})]
|
|
1573
|
-
}), c("p", {
|
|
1574
|
-
"aria-label": "File size",
|
|
1575
|
-
class: "text-accent-11",
|
|
1576
|
-
children: Re(e.sizeKb)
|
|
1577
|
-
})]
|
|
1578
|
-
});
|
|
1579
|
-
}, Mt = ({
|
|
1580
|
-
class: e,
|
|
1581
|
-
...t
|
|
1582
|
-
}) => c("li", {
|
|
1583
|
-
class: je("outline-neutral-6 text-neutral-11 bg-neutral-1 block rounded-md px-1 py-0.5 text-xs outline outline-1", e),
|
|
1584
|
-
...t
|
|
1585
|
-
}), fr = (e) => {
|
|
1586
|
-
const t = e.split(".").pop();
|
|
1587
|
-
if (!t)
|
|
1588
|
-
throw new Error("No file extension found");
|
|
1589
|
-
return t ? "." + t : "";
|
|
1590
|
-
}, zn = ({
|
|
1591
|
-
allowedExtensions: e,
|
|
1592
|
-
files: t
|
|
1593
|
-
}) => {
|
|
1594
|
-
const r = e.map((n) => n.toLowerCase());
|
|
1595
|
-
return t.every((n) => r.includes(fr(n.name).toLowerCase()));
|
|
1596
|
-
}, qn = (e, t) => {
|
|
1597
|
-
const r = fr(e);
|
|
1598
|
-
return `${e.replace(new RegExp(`${r}$`), "").slice(0, t)}${r}`;
|
|
1599
|
-
}, Kn = ({
|
|
1600
|
-
input: e,
|
|
1601
|
-
onSubmitSuccess: t
|
|
1602
|
-
}) => {
|
|
1603
|
-
var v;
|
|
1604
|
-
const r = (v = D.current$.value.flow) == null ? void 0 : v.data.submissions[e.key], [n, i] = se($n(r) ? r.value : []), [s, o] = se(), a = n.length - Lt, f = jn(n), p = ct(), {
|
|
1605
|
-
t: C
|
|
1606
|
-
} = Q();
|
|
1607
|
-
return c("form", {
|
|
1608
|
-
class: "flex flex-col gap-1 p-2.5",
|
|
1609
|
-
onSubmit: (h) => (h.preventDefault(), o(void 0), n.length === 0 ? o({
|
|
1610
|
-
type: "required",
|
|
1611
|
-
message: C("validation_file")
|
|
1612
|
-
}) : e.config.extensions.length > 0 && !zn({
|
|
1613
|
-
allowedExtensions: e.config.extensions,
|
|
1614
|
-
files: n
|
|
1615
|
-
}) ? o({
|
|
1616
|
-
type: "validate",
|
|
1617
|
-
message: `${C("validation_file_ext", {
|
|
1618
|
-
ext: e.config.extensions.join(", ")
|
|
1619
|
-
})}`
|
|
1620
|
-
}) : e.config.fileSizeLimitKib && f > e.config.fileSizeLimitKib ? o({
|
|
1621
|
-
type: "max",
|
|
1622
|
-
message: `File size exceeds limit of ${Re(e.config.fileSizeLimitKib)}`
|
|
1623
|
-
}) : e.config.allowMultiple === !1 && n.length > 1 ? o({
|
|
1624
|
-
type: "invalid",
|
|
1625
|
-
message: C("validation_file_max", {
|
|
1626
|
-
count: 1
|
|
1627
|
-
})
|
|
1628
|
-
}) : t({
|
|
1629
|
-
type: "file",
|
|
1630
|
-
value: n
|
|
1631
|
-
})),
|
|
1632
|
-
children: [c("div", {
|
|
1633
|
-
class: "flex items-center gap-2",
|
|
1634
|
-
children: [c("label", {
|
|
1635
|
-
ref: p,
|
|
1636
|
-
for: "dropzone-file",
|
|
1637
|
-
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",
|
|
1638
|
-
children: [n.length > 0 ? c(we, {
|
|
1639
|
-
children: [c("ul", {
|
|
1640
|
-
class: "flex max-w-full flex-wrap justify-center gap-1 overflow-hidden p-1",
|
|
1641
|
-
children: [n.slice(0, Lt).map((h) => {
|
|
1642
|
-
const y = h.name.split(".").pop(), b = h.name.replace(new RegExp(`.${y}$`), "");
|
|
1643
|
-
return c(Mt, {
|
|
1644
|
-
class: "flex overflow-hidden",
|
|
1645
|
-
children: [c("span", {
|
|
1646
|
-
class: "block truncate",
|
|
1647
|
-
children: b
|
|
1648
|
-
}), c("span", {
|
|
1649
|
-
children: [".", y]
|
|
1650
|
-
})]
|
|
1651
|
-
});
|
|
1652
|
-
}), a > 0 ? c(Mt, {
|
|
1653
|
-
children: ["+", a, " file", a !== 1 ? "s" : ""]
|
|
1654
|
-
}) : null]
|
|
1655
|
-
}), c("p", {
|
|
1656
|
-
class: "text-neutral-11 text-xs",
|
|
1657
|
-
children: [Re(f), " ", n.length > 1 ? "total" : ""]
|
|
1658
|
-
})]
|
|
1659
|
-
}) : c("div", {
|
|
1660
|
-
class: "flex flex-col justify-center gap-4 pb-6 pt-5",
|
|
1661
|
-
children: [c("header", {
|
|
1662
|
-
class: "flex flex-col items-center gap-0",
|
|
1663
|
-
children: [c("svg", {
|
|
1664
|
-
class: "text-neutral-11 mb-1 h-8 w-8",
|
|
1665
|
-
"aria-hidden": "true",
|
|
1666
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1667
|
-
fill: "none",
|
|
1668
|
-
viewBox: "0 0 20 16",
|
|
1669
|
-
children: c("path", {
|
|
1670
|
-
stroke: "currentColor",
|
|
1671
|
-
"stroke-linecap": "round",
|
|
1672
|
-
"stroke-linejoin": "round",
|
|
1673
|
-
"stroke-width": "1.5",
|
|
1674
|
-
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"
|
|
1675
|
-
})
|
|
1676
|
-
}), c("p", {
|
|
1677
|
-
class: "text-neutral-12 tracking-[-0.01em]",
|
|
1678
|
-
children: C("upload_file", {
|
|
1679
|
-
count: e.config.allowMultiple ? 2 : 1
|
|
1680
|
-
})
|
|
1681
|
-
}), e.config.fileSizeLimitKib ? c("p", {
|
|
1682
|
-
class: "text-neutral-10 text-xs",
|
|
1683
|
-
children: ["(", C("file_max_size", {
|
|
1684
|
-
size: Re(e.config.fileSizeLimitKib)
|
|
1685
|
-
}), ")"]
|
|
1686
|
-
}) : null]
|
|
1687
|
-
}), c("aside", {
|
|
1688
|
-
class: "flex flex-col items-center gap-2",
|
|
1689
|
-
children: [c("p", {
|
|
1690
|
-
id: "accepted-filetypes",
|
|
1691
|
-
class: "sr-only",
|
|
1692
|
-
children: C("file_extensions")
|
|
1693
|
-
}), c("ul", {
|
|
1694
|
-
"aria-describedby": "accepted-filetypes",
|
|
1695
|
-
class: "flex flex-wrap justify-center gap-2",
|
|
1696
|
-
children: e.config.extensions.map((h) => c("li", {
|
|
1697
|
-
class: "ring-lowest outline-neutral-6 text-neutral-9 bg-neutral-1 rounded-md px-1 py-0.5 text-[11px] uppercase tracking-wide outline outline-1 ring-2",
|
|
1698
|
-
children: h.replace(".", "")
|
|
1699
|
-
}))
|
|
1700
|
-
})]
|
|
1701
|
-
})]
|
|
1702
|
-
}), c("input", {
|
|
1703
|
-
id: "dropzone-file",
|
|
1704
|
-
onInput: async (h) => {
|
|
1705
|
-
me(h.target instanceof HTMLInputElement);
|
|
1706
|
-
const y = h.target.files ? Array.from(h.target.files) : [], b = await Promise.allSettled(y.map(async (V) => {
|
|
1707
|
-
const x = await Pn(V);
|
|
1708
|
-
return {
|
|
1709
|
-
name: qn(V.name, 42),
|
|
1710
|
-
data: x,
|
|
1711
|
-
sizeKb: V.size / 1e3
|
|
1712
|
-
};
|
|
1713
|
-
}));
|
|
1714
|
-
if (b.some(({
|
|
1715
|
-
status: V
|
|
1716
|
-
}) => V === "rejected"))
|
|
1717
|
-
return o({
|
|
1718
|
-
type: "invalid",
|
|
1719
|
-
message: "Invalid file"
|
|
1720
|
-
});
|
|
1721
|
-
const E = b.map((V) => V.status === "fulfilled" ? V.value : null).filter(Boolean);
|
|
1722
|
-
i(E);
|
|
1723
|
-
},
|
|
1724
|
-
multiple: e.config.allowMultiple,
|
|
1725
|
-
type: "file",
|
|
1726
|
-
class: "sr-only"
|
|
1727
|
-
})]
|
|
1728
|
-
}), c("div", {
|
|
1729
|
-
class: "flex h-full flex-col items-center gap-2",
|
|
1730
|
-
children: [c(ke, {
|
|
1731
|
-
disabled: n.length === 0
|
|
1732
|
-
}), e.config.optional && c(_e, {
|
|
1733
|
-
class: "relative",
|
|
1734
|
-
onClick: () => t(null)
|
|
1735
|
-
})]
|
|
1736
|
-
})]
|
|
1737
|
-
}), c(Ie, {
|
|
1738
|
-
error: s
|
|
1739
|
-
})]
|
|
1740
|
-
});
|
|
1741
|
-
};
|
|
1742
|
-
var Ue = (e) => e.type === "checkbox", ve = (e) => e instanceof Date, W = (e) => e == null;
|
|
1743
|
-
const hr = (e) => typeof e == "object";
|
|
1744
|
-
var j = (e) => !W(e) && !Array.isArray(e) && hr(e) && !ve(e), Hn = (e) => j(e) && e.target ? Ue(e.target) ? e.target.checked : e.target.value : e, Gn = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, Wn = (e, t) => e.has(Gn(t)), Jn = (e) => {
|
|
1745
|
-
const t = e.constructor && e.constructor.prototype;
|
|
1746
|
-
return j(t) && t.hasOwnProperty("isPrototypeOf");
|
|
1747
|
-
}, ut = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
|
|
1748
|
-
function U(e) {
|
|
1749
|
-
if (e instanceof Date)
|
|
1750
|
-
return new Date(e);
|
|
1751
|
-
const t = typeof FileList < "u" && e instanceof FileList;
|
|
1752
|
-
if (ut && (e instanceof Blob || t))
|
|
1753
|
-
return e;
|
|
1754
|
-
const r = Array.isArray(e);
|
|
1755
|
-
if (!r && !(j(e) && Jn(e)))
|
|
1756
|
-
return e;
|
|
1757
|
-
const n = r ? [] : Object.create(Object.getPrototypeOf(e));
|
|
1758
|
-
for (const i in e)
|
|
1759
|
-
Object.prototype.hasOwnProperty.call(e, i) && (n[i] = U(e[i]));
|
|
1760
|
-
return n;
|
|
1761
|
-
}
|
|
1762
|
-
var We = (e) => /^\w*$/.test(e), B = (e) => e === void 0, dt = (e) => Array.isArray(e) ? e.filter(Boolean) : [], ft = (e) => dt(e.replace(/["|']|\]/g, "").split(/\.|\[/)), k = (e, t, r) => {
|
|
1763
|
-
if (!t || !j(e))
|
|
1764
|
-
return r;
|
|
1765
|
-
const n = (We(t) ? [t] : ft(t)).reduce((i, s) => W(i) ? i : i[s], e);
|
|
1766
|
-
return B(n) || n === e ? B(e[t]) ? r : e[t] : n;
|
|
1767
|
-
}, ne = (e) => typeof e == "boolean", te = (e) => typeof e == "function", T = (e, t, r) => {
|
|
1768
|
-
let n = -1;
|
|
1769
|
-
const i = We(t) ? [t] : ft(t), s = i.length, o = s - 1;
|
|
1770
|
-
for (; ++n < s; ) {
|
|
1771
|
-
const a = i[n];
|
|
1772
|
-
let f = r;
|
|
1773
|
-
if (n !== o) {
|
|
1774
|
-
const p = e[a];
|
|
1775
|
-
f = j(p) || Array.isArray(p) ? p : isNaN(+i[n + 1]) ? {} : [];
|
|
1776
|
-
}
|
|
1777
|
-
if (a === "__proto__" || a === "constructor" || a === "prototype")
|
|
1778
|
-
return;
|
|
1779
|
-
e[a] = f, e = e[a];
|
|
1780
|
-
}
|
|
1781
|
-
};
|
|
1782
|
-
const Nt = {
|
|
1783
|
-
BLUR: "blur",
|
|
1784
|
-
FOCUS_OUT: "focusout",
|
|
1785
|
-
CHANGE: "change"
|
|
1786
|
-
}, re = {
|
|
1787
|
-
onBlur: "onBlur",
|
|
1788
|
-
onChange: "onChange",
|
|
1789
|
-
onSubmit: "onSubmit",
|
|
1790
|
-
onTouched: "onTouched",
|
|
1791
|
-
all: "all"
|
|
1792
|
-
}, le = {
|
|
1793
|
-
max: "max",
|
|
1794
|
-
min: "min",
|
|
1795
|
-
maxLength: "maxLength",
|
|
1796
|
-
minLength: "minLength",
|
|
1797
|
-
pattern: "pattern",
|
|
1798
|
-
required: "required",
|
|
1799
|
-
validate: "validate"
|
|
1800
|
-
}, Zn = H.createContext(null);
|
|
1801
|
-
Zn.displayName = "HookFormControlContext";
|
|
1802
|
-
var Xn = (e, t, r, n = !0) => {
|
|
1803
|
-
const i = {
|
|
1804
|
-
defaultValues: t._defaultValues
|
|
1805
|
-
};
|
|
1806
|
-
for (const s in e)
|
|
1807
|
-
Object.defineProperty(i, s, {
|
|
1808
|
-
get: () => {
|
|
1809
|
-
const o = s;
|
|
1810
|
-
return t._proxyFormState[o] !== re.all && (t._proxyFormState[o] = !n || re.all), r && (r[o] = !0), e[o];
|
|
1811
|
-
}
|
|
1812
|
-
});
|
|
1813
|
-
return i;
|
|
1814
|
-
};
|
|
1815
|
-
const Qn = typeof window < "u" ? H.useLayoutEffect : H.useEffect;
|
|
1816
|
-
var X = (e) => typeof e == "string", Yn = (e, t, r, n, i) => X(e) ? (n && t.watch.add(e), k(r, e, i)) : Array.isArray(e) ? e.map((s) => (n && t.watch.add(s), k(r, s))) : (n && (t.watchAll = !0), r), it = (e) => W(e) || !hr(e);
|
|
1817
|
-
function he(e, t, r = /* @__PURE__ */ new WeakSet()) {
|
|
1818
|
-
if (it(e) || it(t))
|
|
1819
|
-
return Object.is(e, t);
|
|
1820
|
-
if (ve(e) && ve(t))
|
|
1821
|
-
return Object.is(e.getTime(), t.getTime());
|
|
1822
|
-
const n = Object.keys(e), i = Object.keys(t);
|
|
1823
|
-
if (n.length !== i.length)
|
|
1824
|
-
return !1;
|
|
1825
|
-
if (r.has(e) || r.has(t))
|
|
1826
|
-
return !0;
|
|
1827
|
-
r.add(e), r.add(t);
|
|
1828
|
-
for (const s of n) {
|
|
1829
|
-
const o = e[s];
|
|
1830
|
-
if (!i.includes(s))
|
|
1831
|
-
return !1;
|
|
1832
|
-
if (s !== "ref") {
|
|
1833
|
-
const a = t[s];
|
|
1834
|
-
if (ve(o) && ve(a) || j(o) && j(a) || Array.isArray(o) && Array.isArray(a) ? !he(o, a, r) : !Object.is(o, a))
|
|
1835
|
-
return !1;
|
|
1836
|
-
}
|
|
1837
|
-
}
|
|
1838
|
-
return !0;
|
|
1839
|
-
}
|
|
1840
|
-
const es = H.createContext(null);
|
|
1841
|
-
es.displayName = "HookFormContext";
|
|
1842
|
-
var pr = (e, t, r, n, i) => t ? {
|
|
1843
|
-
...r[e],
|
|
1844
|
-
types: {
|
|
1845
|
-
...r[e] && r[e].types ? r[e].types : {},
|
|
1846
|
-
[n]: i || !0
|
|
1847
|
-
}
|
|
1848
|
-
} : {}, Be = (e) => Array.isArray(e) ? e : [e], Tt = () => {
|
|
1849
|
-
let e = [];
|
|
1850
|
-
return {
|
|
1851
|
-
get observers() {
|
|
1852
|
-
return e;
|
|
1853
|
-
},
|
|
1854
|
-
next: (i) => {
|
|
1855
|
-
for (const s of e)
|
|
1856
|
-
s.next && s.next(i);
|
|
1857
|
-
},
|
|
1858
|
-
subscribe: (i) => (e.push(i), {
|
|
1859
|
-
unsubscribe: () => {
|
|
1860
|
-
e = e.filter((s) => s !== i);
|
|
1861
|
-
}
|
|
1862
|
-
}),
|
|
1863
|
-
unsubscribe: () => {
|
|
1864
|
-
e = [];
|
|
1865
|
-
}
|
|
1866
|
-
};
|
|
1867
|
-
};
|
|
1868
|
-
function mr(e, t) {
|
|
1869
|
-
const r = {};
|
|
1870
|
-
for (const n in e)
|
|
1871
|
-
if (e.hasOwnProperty(n)) {
|
|
1872
|
-
const i = e[n], s = t[n];
|
|
1873
|
-
if (i && j(i) && s) {
|
|
1874
|
-
const o = mr(i, s);
|
|
1875
|
-
j(o) && (r[n] = o);
|
|
1876
|
-
} else
|
|
1877
|
-
e[n] && (r[n] = s);
|
|
1878
|
-
}
|
|
1879
|
-
return r;
|
|
1880
|
-
}
|
|
1881
|
-
var G = (e) => j(e) && !Object.keys(e).length, ht = (e) => e.type === "file", Ke = (e) => {
|
|
1882
|
-
if (!ut)
|
|
1883
|
-
return !1;
|
|
1884
|
-
const t = e ? e.ownerDocument : 0;
|
|
1885
|
-
return e instanceof (t && t.defaultView ? t.defaultView.HTMLElement : HTMLElement);
|
|
1886
|
-
}, gr = (e) => e.type === "select-multiple", pt = (e) => e.type === "radio", ts = (e) => pt(e) || Ue(e), nt = (e) => Ke(e) && e.isConnected;
|
|
1887
|
-
function rs(e, t) {
|
|
1888
|
-
const r = t.slice(0, -1).length;
|
|
1889
|
-
let n = 0;
|
|
1890
|
-
for (; n < r; )
|
|
1891
|
-
e = B(e) ? n++ : e[t[n++]];
|
|
1892
|
-
return e;
|
|
1893
|
-
}
|
|
1894
|
-
function ns(e) {
|
|
1895
|
-
for (const t in e)
|
|
1896
|
-
if (e.hasOwnProperty(t) && !B(e[t]))
|
|
1897
|
-
return !1;
|
|
1898
|
-
return !0;
|
|
1899
|
-
}
|
|
1900
|
-
function P(e, t) {
|
|
1901
|
-
const r = Array.isArray(t) ? t : We(t) ? [t] : ft(t), n = r.length === 1 ? e : rs(e, r), i = r.length - 1, s = r[i];
|
|
1902
|
-
return n && delete n[s], i !== 0 && (j(n) && G(n) || Array.isArray(n) && ns(n)) && P(e, r.slice(0, -1)), e;
|
|
1903
|
-
}
|
|
1904
|
-
var ss = (e) => {
|
|
1905
|
-
for (const t in e)
|
|
1906
|
-
if (te(e[t]))
|
|
1907
|
-
return !0;
|
|
1908
|
-
return !1;
|
|
1909
|
-
};
|
|
1910
|
-
function yr(e) {
|
|
1911
|
-
return Array.isArray(e) || j(e) && !ss(e);
|
|
1912
|
-
}
|
|
1913
|
-
function ot(e, t = {}) {
|
|
1914
|
-
for (const r in e) {
|
|
1915
|
-
const n = e[r];
|
|
1916
|
-
yr(n) ? (t[r] = Array.isArray(n) ? [] : {}, ot(n, t[r])) : B(n) || (t[r] = !0);
|
|
1917
|
-
}
|
|
1918
|
-
return t;
|
|
1919
|
-
}
|
|
1920
|
-
function Ee(e, t, r) {
|
|
1921
|
-
r || (r = ot(t));
|
|
1922
|
-
for (const n in e) {
|
|
1923
|
-
const i = e[n];
|
|
1924
|
-
if (yr(i))
|
|
1925
|
-
B(t) || it(r[n]) ? r[n] = ot(i, Array.isArray(i) ? [] : {}) : Ee(i, W(t) ? {} : t[n], r[n]);
|
|
1926
|
-
else {
|
|
1927
|
-
const s = t[n];
|
|
1928
|
-
r[n] = !he(i, s);
|
|
1929
|
-
}
|
|
1930
|
-
}
|
|
1931
|
-
return r;
|
|
1932
|
-
}
|
|
1933
|
-
const Dt = {
|
|
1934
|
-
value: !1,
|
|
1935
|
-
isValid: !1
|
|
1936
|
-
}, Rt = { value: !0, isValid: !0 };
|
|
1937
|
-
var br = (e) => {
|
|
1938
|
-
if (Array.isArray(e)) {
|
|
1939
|
-
if (e.length > 1) {
|
|
1940
|
-
const t = e.filter((r) => r && r.checked && !r.disabled).map((r) => r.value);
|
|
1941
|
-
return { value: t, isValid: !!t.length };
|
|
1942
|
-
}
|
|
1943
|
-
return e[0].checked && !e[0].disabled ? (
|
|
1944
|
-
// @ts-expect-error expected to work in the browser
|
|
1945
|
-
e[0].attributes && !B(e[0].attributes.value) ? B(e[0].value) || e[0].value === "" ? Rt : { value: e[0].value, isValid: !0 } : Rt
|
|
1946
|
-
) : Dt;
|
|
1947
|
-
}
|
|
1948
|
-
return Dt;
|
|
1949
|
-
}, vr = (e, { valueAsNumber: t, valueAsDate: r, setValueAs: n }) => B(e) ? e : t ? e === "" ? NaN : e && +e : r && X(e) ? new Date(e) : n ? n(e) : e;
|
|
1950
|
-
const Ot = {
|
|
1951
|
-
isValid: !1,
|
|
1952
|
-
value: null
|
|
1953
|
-
};
|
|
1954
|
-
var xr = (e) => Array.isArray(e) ? e.reduce((t, r) => r && r.checked && !r.disabled ? {
|
|
1955
|
-
isValid: !0,
|
|
1956
|
-
value: r.value
|
|
1957
|
-
} : t, Ot) : Ot;
|
|
1958
|
-
function Bt(e) {
|
|
1959
|
-
const t = e.ref;
|
|
1960
|
-
return ht(t) ? t.files : pt(t) ? xr(e.refs).value : gr(t) ? [...t.selectedOptions].map(({ value: r }) => r) : Ue(t) ? br(e.refs).value : vr(B(t.value) ? e.ref.value : t.value, e);
|
|
1961
|
-
}
|
|
1962
|
-
var as = (e, t, r, n) => {
|
|
1963
|
-
const i = {};
|
|
1964
|
-
for (const s of e) {
|
|
1965
|
-
const o = k(t, s);
|
|
1966
|
-
o && T(i, s, o._f);
|
|
1967
|
-
}
|
|
1968
|
-
return {
|
|
1969
|
-
criteriaMode: r,
|
|
1970
|
-
names: [...e],
|
|
1971
|
-
fields: i,
|
|
1972
|
-
shouldUseNativeValidation: n
|
|
1973
|
-
};
|
|
1974
|
-
}, He = (e) => e instanceof RegExp, Ne = (e) => B(e) ? e : He(e) ? e.source : j(e) ? He(e.value) ? e.value.source : e.value : e, Pt = (e) => ({
|
|
1975
|
-
isOnSubmit: !e || e === re.onSubmit,
|
|
1976
|
-
isOnBlur: e === re.onBlur,
|
|
1977
|
-
isOnChange: e === re.onChange,
|
|
1978
|
-
isOnAll: e === re.all,
|
|
1979
|
-
isOnTouch: e === re.onTouched
|
|
1980
|
-
});
|
|
1981
|
-
const jt = "AsyncFunction";
|
|
1982
|
-
var is = (e) => !!e && !!e.validate && !!(te(e.validate) && e.validate.constructor.name === jt || j(e.validate) && Object.values(e.validate).find((t) => t.constructor.name === jt)), os = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate), $t = (e, t, r) => !r && (t.watchAll || t.watch.has(e) || [...t.watch].some((n) => e.startsWith(n) && /^\.\w+/.test(e.slice(n.length))));
|
|
1983
|
-
const Pe = (e, t, r, n) => {
|
|
1984
|
-
for (const i of r || Object.keys(e)) {
|
|
1985
|
-
const s = k(e, i);
|
|
1986
|
-
if (s) {
|
|
1987
|
-
const { _f: o, ...a } = s;
|
|
1988
|
-
if (o) {
|
|
1989
|
-
if (o.refs && o.refs[0] && t(o.refs[0], i) && !n)
|
|
1990
|
-
return !0;
|
|
1991
|
-
if (o.ref && t(o.ref, o.name) && !n)
|
|
1992
|
-
return !0;
|
|
1993
|
-
if (Pe(a, t))
|
|
1994
|
-
break;
|
|
1995
|
-
} else if (j(a) && Pe(a, t))
|
|
1996
|
-
break;
|
|
1997
|
-
}
|
|
1998
|
-
}
|
|
1999
|
-
};
|
|
2000
|
-
function Ut(e, t, r) {
|
|
2001
|
-
const n = k(e, r);
|
|
2002
|
-
if (n || We(r))
|
|
2003
|
-
return {
|
|
2004
|
-
error: n,
|
|
2005
|
-
name: r
|
|
2006
|
-
};
|
|
2007
|
-
const i = r.split(".");
|
|
2008
|
-
for (; i.length; ) {
|
|
2009
|
-
const s = i.join("."), o = k(t, s), a = k(e, s);
|
|
2010
|
-
if (o && !Array.isArray(o) && r !== s)
|
|
2011
|
-
return { name: r };
|
|
2012
|
-
if (a && a.type)
|
|
2013
|
-
return {
|
|
2014
|
-
name: s,
|
|
2015
|
-
error: a
|
|
2016
|
-
};
|
|
2017
|
-
if (a && a.root && a.root.type)
|
|
2018
|
-
return {
|
|
2019
|
-
name: `${s}.root`,
|
|
2020
|
-
error: a.root
|
|
2021
|
-
};
|
|
2022
|
-
i.pop();
|
|
2023
|
-
}
|
|
2024
|
-
return {
|
|
2025
|
-
name: r
|
|
2026
|
-
};
|
|
2027
|
-
}
|
|
2028
|
-
var ls = (e, t, r, n) => {
|
|
2029
|
-
r(e);
|
|
2030
|
-
const { name: i, ...s } = e;
|
|
2031
|
-
return G(s) || Object.keys(s).length >= Object.keys(t).length || Object.keys(s).find((o) => t[o] === (!n || re.all));
|
|
2032
|
-
}, cs = (e, t, r) => !e || !t || e === t || Be(e).some((n) => n && (r ? n === t : n.startsWith(t) || t.startsWith(n))), us = (e, t, r, n, i) => i.isOnAll ? !1 : !r && i.isOnTouch ? !(t || e) : (r ? n.isOnBlur : i.isOnBlur) ? !e : (r ? n.isOnChange : i.isOnChange) ? e : !0, ds = (e, t) => !dt(k(e, t)).length && P(e, t), fs = (e, t, r) => {
|
|
2033
|
-
const n = Be(k(e, r));
|
|
2034
|
-
return T(n, "root", t[r]), T(e, r, n), e;
|
|
2035
|
-
};
|
|
2036
|
-
function zt(e, t, r = "validate") {
|
|
2037
|
-
if (X(e) || Array.isArray(e) && e.every(X) || ne(e) && !e)
|
|
2038
|
-
return {
|
|
2039
|
-
type: r,
|
|
2040
|
-
message: X(e) ? e : "",
|
|
2041
|
-
ref: t
|
|
2042
|
-
};
|
|
2043
|
-
}
|
|
2044
|
-
var Se = (e) => j(e) && !He(e) ? e : {
|
|
2045
|
-
value: e,
|
|
2046
|
-
message: ""
|
|
2047
|
-
}, qt = async (e, t, r, n, i, s) => {
|
|
2048
|
-
const { ref: o, refs: a, required: f, maxLength: p, minLength: C, min: v, max: h, pattern: y, validate: b, name: E, valueAsNumber: V, mount: x } = e._f, _ = k(r, E);
|
|
2049
|
-
if (!x || t.has(E))
|
|
2050
|
-
return {};
|
|
2051
|
-
const I = a ? a[0] : o, O = (F) => {
|
|
2052
|
-
i && I.reportValidity && (I.setCustomValidity(ne(F) ? "" : F || ""), I.reportValidity());
|
|
2053
|
-
}, A = {}, ye = pt(o), Ce = Ue(o), ie = ye || Ce, de = (V || ht(o)) && B(o.value) && B(_) || Ke(o) && o.value === "" || _ === "" || Array.isArray(_) && !_.length, z = pr.bind(null, E, n, A), ze = (F, L, $, q = le.maxLength, ee = le.minLength) => {
|
|
2054
|
-
const J = F ? L : $;
|
|
2055
|
-
A[E] = {
|
|
2056
|
-
type: F ? q : ee,
|
|
2057
|
-
message: J,
|
|
2058
|
-
ref: o,
|
|
2059
|
-
...z(F ? q : ee, J)
|
|
2060
|
-
};
|
|
2061
|
-
};
|
|
2062
|
-
if (s ? !Array.isArray(_) || !_.length : f && (!ie && (de || W(_)) || ne(_) && !_ || Ce && !br(a).isValid || ye && !xr(a).isValid)) {
|
|
2063
|
-
const { value: F, message: L } = X(f) ? { value: !!f, message: f } : Se(f);
|
|
2064
|
-
if (F && (A[E] = {
|
|
2065
|
-
type: le.required,
|
|
2066
|
-
message: L,
|
|
2067
|
-
ref: I,
|
|
2068
|
-
...z(le.required, L)
|
|
2069
|
-
}, !n))
|
|
2070
|
-
return O(L), A;
|
|
2071
|
-
}
|
|
2072
|
-
if (!de && (!W(v) || !W(h))) {
|
|
2073
|
-
let F, L;
|
|
2074
|
-
const $ = Se(h), q = Se(v);
|
|
2075
|
-
if (!W(_) && !isNaN(_)) {
|
|
2076
|
-
const ee = o.valueAsNumber || _ && +_;
|
|
2077
|
-
W($.value) || (F = ee > $.value), W(q.value) || (L = ee < q.value);
|
|
2078
|
-
} else {
|
|
2079
|
-
const ee = o.valueAsDate || new Date(_), J = (Me) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + Me), Ae = o.type == "time", Le = o.type == "week";
|
|
2080
|
-
X($.value) && _ && (F = Ae ? J(_) > J($.value) : Le ? _ > $.value : ee > new Date($.value)), X(q.value) && _ && (L = Ae ? J(_) < J(q.value) : Le ? _ < q.value : ee < new Date(q.value));
|
|
2081
|
-
}
|
|
2082
|
-
if ((F || L) && (ze(!!F, $.message, q.message, le.max, le.min), !n))
|
|
2083
|
-
return O(A[E].message), A;
|
|
2084
|
-
}
|
|
2085
|
-
if ((p || C) && !de && (X(_) || s && Array.isArray(_))) {
|
|
2086
|
-
const F = Se(p), L = Se(C), $ = !W(F.value) && _.length > +F.value, q = !W(L.value) && _.length < +L.value;
|
|
2087
|
-
if (($ || q) && (ze($, F.message, L.message), !n))
|
|
2088
|
-
return O(A[E].message), A;
|
|
2089
|
-
}
|
|
2090
|
-
if (y && !de && X(_)) {
|
|
2091
|
-
const { value: F, message: L } = Se(y);
|
|
2092
|
-
if (He(F) && !_.match(F) && (A[E] = {
|
|
2093
|
-
type: le.pattern,
|
|
2094
|
-
message: L,
|
|
2095
|
-
ref: o,
|
|
2096
|
-
...z(le.pattern, L)
|
|
2097
|
-
}, !n))
|
|
2098
|
-
return O(L), A;
|
|
2099
|
-
}
|
|
2100
|
-
if (b) {
|
|
2101
|
-
if (te(b)) {
|
|
2102
|
-
const F = await b(_, r), L = zt(F, I);
|
|
2103
|
-
if (L && (A[E] = {
|
|
2104
|
-
...L,
|
|
2105
|
-
...z(le.validate, L.message)
|
|
2106
|
-
}, !n))
|
|
2107
|
-
return O(L.message), A;
|
|
2108
|
-
} else if (j(b)) {
|
|
2109
|
-
let F = {};
|
|
2110
|
-
for (const L in b) {
|
|
2111
|
-
if (!G(F) && !n)
|
|
2112
|
-
break;
|
|
2113
|
-
const $ = zt(await b[L](_, r), I, L);
|
|
2114
|
-
$ && (F = {
|
|
2115
|
-
...$,
|
|
2116
|
-
...z(L, $.message)
|
|
2117
|
-
}, O($.message), n && (A[E] = F));
|
|
2118
|
-
}
|
|
2119
|
-
if (!G(F) && (A[E] = {
|
|
2120
|
-
ref: I,
|
|
2121
|
-
...F
|
|
2122
|
-
}, !n))
|
|
2123
|
-
return A;
|
|
2124
|
-
}
|
|
2125
|
-
}
|
|
2126
|
-
return O(!0), A;
|
|
2127
|
-
};
|
|
2128
|
-
const hs = {
|
|
2129
|
-
mode: re.onSubmit,
|
|
2130
|
-
reValidateMode: re.onChange,
|
|
2131
|
-
shouldFocusError: !0
|
|
2132
|
-
};
|
|
2133
|
-
function ps(e = {}) {
|
|
2134
|
-
let t = {
|
|
2135
|
-
...hs,
|
|
2136
|
-
...e
|
|
2137
|
-
}, r = {
|
|
2138
|
-
submitCount: 0,
|
|
2139
|
-
isDirty: !1,
|
|
2140
|
-
isReady: !1,
|
|
2141
|
-
isLoading: te(t.defaultValues),
|
|
2142
|
-
isValidating: !1,
|
|
2143
|
-
isSubmitted: !1,
|
|
2144
|
-
isSubmitting: !1,
|
|
2145
|
-
isSubmitSuccessful: !1,
|
|
2146
|
-
isValid: !1,
|
|
2147
|
-
touchedFields: {},
|
|
2148
|
-
dirtyFields: {},
|
|
2149
|
-
validatingFields: {},
|
|
2150
|
-
errors: t.errors || {},
|
|
2151
|
-
disabled: t.disabled || !1
|
|
2152
|
-
}, n = {}, i = j(t.defaultValues) || j(t.values) ? U(t.defaultValues || t.values) || {} : {}, s = t.shouldUnregister ? {} : U(i), o = {
|
|
2153
|
-
action: !1,
|
|
2154
|
-
mount: !1,
|
|
2155
|
-
watch: !1,
|
|
2156
|
-
keepIsValid: !1
|
|
2157
|
-
}, a = {
|
|
2158
|
-
mount: /* @__PURE__ */ new Set(),
|
|
2159
|
-
disabled: /* @__PURE__ */ new Set(),
|
|
2160
|
-
unMount: /* @__PURE__ */ new Set(),
|
|
2161
|
-
array: /* @__PURE__ */ new Set(),
|
|
2162
|
-
watch: /* @__PURE__ */ new Set()
|
|
2163
|
-
}, f, p = 0;
|
|
2164
|
-
const C = {
|
|
2165
|
-
isDirty: !1,
|
|
2166
|
-
dirtyFields: !1,
|
|
2167
|
-
validatingFields: !1,
|
|
2168
|
-
touchedFields: !1,
|
|
2169
|
-
isValidating: !1,
|
|
2170
|
-
isValid: !1,
|
|
2171
|
-
errors: !1
|
|
2172
|
-
}, v = {
|
|
2173
|
-
...C
|
|
2174
|
-
};
|
|
2175
|
-
let h = {
|
|
2176
|
-
...v
|
|
2177
|
-
};
|
|
2178
|
-
const y = {
|
|
2179
|
-
array: Tt(),
|
|
2180
|
-
state: Tt()
|
|
2181
|
-
}, b = t.criteriaMode === re.all, E = (l) => (u) => {
|
|
2182
|
-
clearTimeout(p), p = setTimeout(l, u);
|
|
2183
|
-
}, V = async (l) => {
|
|
2184
|
-
if (!o.keepIsValid && !t.disabled && (v.isValid || h.isValid || l)) {
|
|
2185
|
-
let u;
|
|
2186
|
-
t.resolver ? (u = G((await ie()).errors), x()) : u = await z(n, !0), u !== r.isValid && y.state.next({
|
|
2187
|
-
isValid: u
|
|
2188
|
-
});
|
|
2189
|
-
}
|
|
2190
|
-
}, x = (l, u) => {
|
|
2191
|
-
!t.disabled && (v.isValidating || v.validatingFields || h.isValidating || h.validatingFields) && ((l || Array.from(a.mount)).forEach((d) => {
|
|
2192
|
-
d && (u ? T(r.validatingFields, d, u) : P(r.validatingFields, d));
|
|
2193
|
-
}), y.state.next({
|
|
2194
|
-
validatingFields: r.validatingFields,
|
|
2195
|
-
isValidating: !G(r.validatingFields)
|
|
2196
|
-
}));
|
|
2197
|
-
}, _ = (l, u = [], d, w, g = !0, m = !0) => {
|
|
2198
|
-
if (w && d && !t.disabled) {
|
|
2199
|
-
if (o.action = !0, m && Array.isArray(k(n, l))) {
|
|
2200
|
-
const S = d(k(n, l), w.argA, w.argB);
|
|
2201
|
-
g && T(n, l, S);
|
|
2202
|
-
}
|
|
2203
|
-
if (m && Array.isArray(k(r.errors, l))) {
|
|
2204
|
-
const S = d(k(r.errors, l), w.argA, w.argB);
|
|
2205
|
-
g && T(r.errors, l, S), ds(r.errors, l);
|
|
2206
|
-
}
|
|
2207
|
-
if ((v.touchedFields || h.touchedFields) && m && Array.isArray(k(r.touchedFields, l))) {
|
|
2208
|
-
const S = d(k(r.touchedFields, l), w.argA, w.argB);
|
|
2209
|
-
g && T(r.touchedFields, l, S);
|
|
2210
|
-
}
|
|
2211
|
-
(v.dirtyFields || h.dirtyFields) && (r.dirtyFields = Ee(i, s)), y.state.next({
|
|
2212
|
-
name: l,
|
|
2213
|
-
isDirty: F(l, u),
|
|
2214
|
-
dirtyFields: r.dirtyFields,
|
|
2215
|
-
errors: r.errors,
|
|
2216
|
-
isValid: r.isValid
|
|
2217
|
-
});
|
|
2218
|
-
} else
|
|
2219
|
-
T(s, l, u);
|
|
2220
|
-
}, I = (l, u) => {
|
|
2221
|
-
T(r.errors, l, u), y.state.next({
|
|
2222
|
-
errors: r.errors
|
|
2223
|
-
});
|
|
2224
|
-
}, O = (l) => {
|
|
2225
|
-
r.errors = l, y.state.next({
|
|
2226
|
-
errors: r.errors,
|
|
2227
|
-
isValid: !1
|
|
2228
|
-
});
|
|
2229
|
-
}, A = (l, u, d, w) => {
|
|
2230
|
-
const g = k(n, l);
|
|
2231
|
-
if (g) {
|
|
2232
|
-
const m = k(s, l, B(d) ? k(i, l) : d);
|
|
2233
|
-
B(m) || w && w.defaultChecked || u ? T(s, l, u ? m : Bt(g._f)) : q(l, m), o.mount && !o.action && V();
|
|
2234
|
-
}
|
|
2235
|
-
}, ye = (l, u, d, w, g) => {
|
|
2236
|
-
let m = !1, S = !1;
|
|
2237
|
-
const M = {
|
|
2238
|
-
name: l
|
|
2239
|
-
};
|
|
2240
|
-
if (!t.disabled) {
|
|
2241
|
-
if (!d || w) {
|
|
2242
|
-
(v.isDirty || h.isDirty) && (S = r.isDirty, r.isDirty = M.isDirty = F(), m = S !== M.isDirty);
|
|
2243
|
-
const N = he(k(i, l), u);
|
|
2244
|
-
S = !!k(r.dirtyFields, l), N ? P(r.dirtyFields, l) : T(r.dirtyFields, l, !0), M.dirtyFields = r.dirtyFields, m = m || (v.dirtyFields || h.dirtyFields) && S !== !N;
|
|
2245
|
-
}
|
|
2246
|
-
if (d) {
|
|
2247
|
-
const N = k(r.touchedFields, l);
|
|
2248
|
-
N || (T(r.touchedFields, l, d), M.touchedFields = r.touchedFields, m = m || (v.touchedFields || h.touchedFields) && N !== d);
|
|
2249
|
-
}
|
|
2250
|
-
m && g && y.state.next(M);
|
|
2251
|
-
}
|
|
2252
|
-
return m ? M : {};
|
|
2253
|
-
}, Ce = (l, u, d, w) => {
|
|
2254
|
-
const g = k(r.errors, l), m = (v.isValid || h.isValid) && ne(u) && r.isValid !== u;
|
|
2255
|
-
if (t.delayError && d ? (f = E(() => I(l, d)), f(t.delayError)) : (clearTimeout(p), f = null, d ? T(r.errors, l, d) : P(r.errors, l)), (d ? !he(g, d) : g) || !G(w) || m) {
|
|
2256
|
-
const S = {
|
|
2257
|
-
...w,
|
|
2258
|
-
...m && ne(u) ? { isValid: u } : {},
|
|
2259
|
-
errors: r.errors,
|
|
2260
|
-
name: l
|
|
2261
|
-
};
|
|
2262
|
-
r = {
|
|
2263
|
-
...r,
|
|
2264
|
-
...S
|
|
2265
|
-
}, y.state.next(S);
|
|
2266
|
-
}
|
|
2267
|
-
}, ie = async (l) => (x(l, !0), await t.resolver(s, t.context, as(l || a.mount, n, t.criteriaMode, t.shouldUseNativeValidation))), de = async (l) => {
|
|
2268
|
-
const { errors: u } = await ie(l);
|
|
2269
|
-
if (x(l), l)
|
|
2270
|
-
for (const d of l) {
|
|
2271
|
-
const w = k(u, d);
|
|
2272
|
-
w ? T(r.errors, d, w) : P(r.errors, d);
|
|
2273
|
-
}
|
|
2274
|
-
else
|
|
2275
|
-
r.errors = u;
|
|
2276
|
-
return u;
|
|
2277
|
-
}, z = async (l, u, d = {
|
|
2278
|
-
valid: !0
|
|
2279
|
-
}) => {
|
|
2280
|
-
for (const w in l) {
|
|
2281
|
-
const g = l[w];
|
|
2282
|
-
if (g) {
|
|
2283
|
-
const { _f: m, ...S } = g;
|
|
2284
|
-
if (m) {
|
|
2285
|
-
const M = a.array.has(m.name), N = g._f && is(g._f);
|
|
2286
|
-
N && v.validatingFields && x([m.name], !0);
|
|
2287
|
-
const K = await qt(g, a.disabled, s, b, t.shouldUseNativeValidation && !u, M);
|
|
2288
|
-
if (N && v.validatingFields && x([m.name]), K[m.name] && (d.valid = !1, u || e.shouldUseNativeValidation))
|
|
2289
|
-
break;
|
|
2290
|
-
!u && (k(K, m.name) ? M ? fs(r.errors, K, m.name) : T(r.errors, m.name, K[m.name]) : P(r.errors, m.name));
|
|
2291
|
-
}
|
|
2292
|
-
!G(S) && await z(S, u, d);
|
|
2293
|
-
}
|
|
2294
|
-
}
|
|
2295
|
-
return d.valid;
|
|
2296
|
-
}, ze = () => {
|
|
2297
|
-
for (const l of a.unMount) {
|
|
2298
|
-
const u = k(n, l);
|
|
2299
|
-
u && (u._f.refs ? u._f.refs.every((d) => !nt(d)) : !nt(u._f.ref)) && Xe(l);
|
|
2300
|
-
}
|
|
2301
|
-
a.unMount = /* @__PURE__ */ new Set();
|
|
2302
|
-
}, F = (l, u) => !t.disabled && (l && u && T(s, l, u), !he(mt(), i)), L = (l, u, d) => Yn(l, a, {
|
|
2303
|
-
...o.mount ? s : B(u) ? i : X(l) ? { [l]: u } : u
|
|
2304
|
-
}, d, u), $ = (l) => dt(k(o.mount ? s : i, l, t.shouldUnregister ? k(i, l, []) : [])), q = (l, u, d = {}) => {
|
|
2305
|
-
const w = k(n, l);
|
|
2306
|
-
let g = u;
|
|
2307
|
-
if (w) {
|
|
2308
|
-
const m = w._f;
|
|
2309
|
-
m && (!m.disabled && T(s, l, vr(u, m)), g = Ke(m.ref) && W(u) ? "" : u, gr(m.ref) ? [...m.ref.options].forEach((S) => S.selected = g.includes(S.value)) : m.refs ? Ue(m.ref) ? m.refs.forEach((S) => {
|
|
2310
|
-
(!S.defaultChecked || !S.disabled) && (Array.isArray(g) ? S.checked = !!g.find((M) => M === S.value) : S.checked = g === S.value || !!g);
|
|
2311
|
-
}) : m.refs.forEach((S) => S.checked = S.value === g) : ht(m.ref) ? m.ref.value = "" : (m.ref.value = g, m.ref.type || y.state.next({
|
|
2312
|
-
name: l,
|
|
2313
|
-
values: U(s)
|
|
2314
|
-
})));
|
|
2315
|
-
}
|
|
2316
|
-
(d.shouldDirty || d.shouldTouch) && ye(l, g, d.shouldTouch, d.shouldDirty, !0), d.shouldValidate && Me(l);
|
|
2317
|
-
}, ee = (l, u, d) => {
|
|
2318
|
-
for (const w in u) {
|
|
2319
|
-
if (!u.hasOwnProperty(w))
|
|
2320
|
-
return;
|
|
2321
|
-
const g = u[w], m = l + "." + w, S = k(n, m);
|
|
2322
|
-
(a.array.has(l) || j(g) || S && !S._f) && !ve(g) ? ee(m, g, d) : q(m, g, d);
|
|
2323
|
-
}
|
|
2324
|
-
}, J = (l, u, d = {}) => {
|
|
2325
|
-
const w = k(n, l), g = a.array.has(l), m = U(u);
|
|
2326
|
-
T(s, l, m), g ? (y.array.next({
|
|
2327
|
-
name: l,
|
|
2328
|
-
values: U(s)
|
|
2329
|
-
}), (v.isDirty || v.dirtyFields || h.isDirty || h.dirtyFields) && d.shouldDirty && y.state.next({
|
|
2330
|
-
name: l,
|
|
2331
|
-
dirtyFields: Ee(i, s),
|
|
2332
|
-
isDirty: F(l, m)
|
|
2333
|
-
})) : w && !w._f && !W(m) ? ee(l, m, d) : q(l, m, d), $t(l, a) ? y.state.next({
|
|
2334
|
-
...r,
|
|
2335
|
-
name: l,
|
|
2336
|
-
values: U(s)
|
|
2337
|
-
}) : y.state.next({
|
|
2338
|
-
name: o.mount ? l : void 0,
|
|
2339
|
-
values: U(s)
|
|
2340
|
-
});
|
|
2341
|
-
}, Ae = async (l) => {
|
|
2342
|
-
o.mount = !0;
|
|
2343
|
-
const u = l.target;
|
|
2344
|
-
let d = u.name, w = !0;
|
|
2345
|
-
const g = k(n, d), m = (N) => {
|
|
2346
|
-
w = Number.isNaN(N) || ve(N) && isNaN(N.getTime()) || he(N, k(s, d, N));
|
|
2347
|
-
}, S = Pt(t.mode), M = Pt(t.reValidateMode);
|
|
2348
|
-
if (g) {
|
|
2349
|
-
let N, K;
|
|
2350
|
-
const be = u.type ? Bt(g._f) : Hn(l), fe = l.type === Nt.BLUR || l.type === Nt.FOCUS_OUT, Ir = !os(g._f) && !t.resolver && !k(r.errors, d) && !g._f.deps || us(fe, k(r.touchedFields, d), r.isSubmitted, M, S), et = $t(d, a, fe);
|
|
2351
|
-
T(s, d, be), fe ? (!u || !u.readOnly) && (g._f.onBlur && g._f.onBlur(l), f && f(0)) : g._f.onChange && g._f.onChange(l);
|
|
2352
|
-
const tt = ye(d, be, fe), Ar = !G(tt) || et;
|
|
2353
|
-
if (!fe && y.state.next({
|
|
2354
|
-
name: d,
|
|
2355
|
-
type: l.type,
|
|
2356
|
-
values: U(s)
|
|
2357
|
-
}), Ir)
|
|
2358
|
-
return (v.isValid || h.isValid) && (t.mode === "onBlur" ? fe && V() : fe || V()), Ar && y.state.next({ name: d, ...et ? {} : tt });
|
|
2359
|
-
if (!fe && et && y.state.next({ ...r }), t.resolver) {
|
|
2360
|
-
const { errors: Ct } = await ie([d]);
|
|
2361
|
-
if (x([d]), m(be), w) {
|
|
2362
|
-
const Lr = Ut(r.errors, n, d), St = Ut(Ct, n, Lr.name || d);
|
|
2363
|
-
N = St.error, d = St.name, K = G(Ct);
|
|
2364
|
-
}
|
|
2365
|
-
} else
|
|
2366
|
-
x([d], !0), N = (await qt(g, a.disabled, s, b, t.shouldUseNativeValidation))[d], x([d]), m(be), w && (N ? K = !1 : (v.isValid || h.isValid) && (K = await z(n, !0)));
|
|
2367
|
-
w && (g._f.deps && (!Array.isArray(g._f.deps) || g._f.deps.length > 0) && Me(g._f.deps), Ce(d, K, N, tt));
|
|
2368
|
-
}
|
|
2369
|
-
}, Le = (l, u) => {
|
|
2370
|
-
if (k(r.errors, u) && l.focus)
|
|
2371
|
-
return l.focus(), 1;
|
|
2372
|
-
}, Me = async (l, u = {}) => {
|
|
2373
|
-
let d, w;
|
|
2374
|
-
const g = Be(l);
|
|
2375
|
-
if (t.resolver) {
|
|
2376
|
-
const m = await de(B(l) ? l : g);
|
|
2377
|
-
d = G(m), w = l ? !g.some((S) => k(m, S)) : d;
|
|
2378
|
-
} else
|
|
2379
|
-
l ? (w = (await Promise.all(g.map(async (m) => {
|
|
2380
|
-
const S = k(n, m);
|
|
2381
|
-
return await z(S && S._f ? { [m]: S } : S);
|
|
2382
|
-
}))).every(Boolean), !(!w && !r.isValid) && V()) : w = d = await z(n);
|
|
2383
|
-
return y.state.next({
|
|
2384
|
-
...!X(l) || (v.isValid || h.isValid) && d !== r.isValid ? {} : { name: l },
|
|
2385
|
-
...t.resolver || !l ? { isValid: d } : {},
|
|
2386
|
-
errors: r.errors
|
|
2387
|
-
}), u.shouldFocus && !w && Pe(n, Le, l ? g : a.mount), w;
|
|
2388
|
-
}, mt = (l, u) => {
|
|
2389
|
-
let d = {
|
|
2390
|
-
...o.mount ? s : i
|
|
2391
|
-
};
|
|
2392
|
-
return u && (d = mr(u.dirtyFields ? r.dirtyFields : r.touchedFields, d)), B(l) ? d : X(l) ? k(d, l) : l.map((w) => k(d, w));
|
|
2393
|
-
}, gt = (l, u) => ({
|
|
2394
|
-
invalid: !!k((u || r).errors, l),
|
|
2395
|
-
isDirty: !!k((u || r).dirtyFields, l),
|
|
2396
|
-
error: k((u || r).errors, l),
|
|
2397
|
-
isValidating: !!k(r.validatingFields, l),
|
|
2398
|
-
isTouched: !!k((u || r).touchedFields, l)
|
|
2399
|
-
}), kr = (l) => {
|
|
2400
|
-
const u = l ? Be(l) : void 0;
|
|
2401
|
-
u == null || u.forEach((d) => P(r.errors, d)), u ? u.forEach((d) => {
|
|
2402
|
-
y.state.next({
|
|
2403
|
-
name: d,
|
|
2404
|
-
errors: r.errors
|
|
2405
|
-
});
|
|
2406
|
-
}) : y.state.next({
|
|
2407
|
-
errors: {}
|
|
2408
|
-
});
|
|
2409
|
-
}, yt = (l, u, d) => {
|
|
2410
|
-
const w = (k(n, l, { _f: {} })._f || {}).ref, g = k(r.errors, l) || {}, { ref: m, message: S, type: M, ...N } = g;
|
|
2411
|
-
T(r.errors, l, {
|
|
2412
|
-
...N,
|
|
2413
|
-
...u,
|
|
2414
|
-
ref: w
|
|
2415
|
-
}), y.state.next({
|
|
2416
|
-
name: l,
|
|
2417
|
-
errors: r.errors,
|
|
2418
|
-
isValid: !1
|
|
2419
|
-
}), d && d.shouldFocus && w && w.focus && w.focus();
|
|
2420
|
-
}, _r = (l, u) => te(l) ? y.state.subscribe({
|
|
2421
|
-
next: (d) => "values" in d && l(L(void 0, u), d)
|
|
2422
|
-
}) : L(l, u, !0), bt = (l) => y.state.subscribe({
|
|
2423
|
-
next: (u) => {
|
|
2424
|
-
cs(l.name, u.name, l.exact) && ls(u, l.formState || v, Fr, l.reRenderRoot) && l.callback({
|
|
2425
|
-
values: { ...s },
|
|
2426
|
-
...r,
|
|
2427
|
-
...u,
|
|
2428
|
-
defaultValues: i
|
|
2429
|
-
});
|
|
2430
|
-
}
|
|
2431
|
-
}).unsubscribe, Cr = (l) => (o.mount = !0, h = {
|
|
2432
|
-
...h,
|
|
2433
|
-
...l.formState
|
|
2434
|
-
}, bt({
|
|
2435
|
-
...l,
|
|
2436
|
-
formState: {
|
|
2437
|
-
...C,
|
|
2438
|
-
...l.formState
|
|
2439
|
-
}
|
|
2440
|
-
})), Xe = (l, u = {}) => {
|
|
2441
|
-
for (const d of l ? Be(l) : a.mount)
|
|
2442
|
-
a.mount.delete(d), a.array.delete(d), u.keepValue || (P(n, d), P(s, d)), !u.keepError && P(r.errors, d), !u.keepDirty && P(r.dirtyFields, d), !u.keepTouched && P(r.touchedFields, d), !u.keepIsValidating && P(r.validatingFields, d), !t.shouldUnregister && !u.keepDefaultValue && P(i, d);
|
|
2443
|
-
y.state.next({
|
|
2444
|
-
values: U(s)
|
|
2445
|
-
}), y.state.next({
|
|
2446
|
-
...r,
|
|
2447
|
-
...u.keepDirty ? { isDirty: F() } : {}
|
|
2448
|
-
}), !u.keepIsValid && V();
|
|
2449
|
-
}, vt = ({ disabled: l, name: u }) => {
|
|
2450
|
-
if (ne(l) && o.mount || l || a.disabled.has(u)) {
|
|
2451
|
-
const g = a.disabled.has(u) !== !!l;
|
|
2452
|
-
l ? a.disabled.add(u) : a.disabled.delete(u), g && o.mount && !o.action && V();
|
|
2453
|
-
}
|
|
2454
|
-
}, Qe = (l, u = {}) => {
|
|
2455
|
-
let d = k(n, l);
|
|
2456
|
-
const w = ne(u.disabled) || ne(t.disabled);
|
|
2457
|
-
return T(n, l, {
|
|
2458
|
-
...d || {},
|
|
2459
|
-
_f: {
|
|
2460
|
-
...d && d._f ? d._f : { ref: { name: l } },
|
|
2461
|
-
name: l,
|
|
2462
|
-
mount: !0,
|
|
2463
|
-
...u
|
|
2464
|
-
}
|
|
2465
|
-
}), a.mount.add(l), d ? vt({
|
|
2466
|
-
disabled: ne(u.disabled) ? u.disabled : t.disabled,
|
|
2467
|
-
name: l
|
|
2468
|
-
}) : A(l, !0, u.value), {
|
|
2469
|
-
...w ? { disabled: u.disabled || t.disabled } : {},
|
|
2470
|
-
...t.progressive ? {
|
|
2471
|
-
required: !!u.required,
|
|
2472
|
-
min: Ne(u.min),
|
|
2473
|
-
max: Ne(u.max),
|
|
2474
|
-
minLength: Ne(u.minLength),
|
|
2475
|
-
maxLength: Ne(u.maxLength),
|
|
2476
|
-
pattern: Ne(u.pattern)
|
|
2477
|
-
} : {},
|
|
2478
|
-
name: l,
|
|
2479
|
-
onChange: Ae,
|
|
2480
|
-
onBlur: Ae,
|
|
2481
|
-
ref: (g) => {
|
|
2482
|
-
if (g) {
|
|
2483
|
-
Qe(l, u), d = k(n, l);
|
|
2484
|
-
const m = B(g.value) && g.querySelectorAll && g.querySelectorAll("input,select,textarea")[0] || g, S = ts(m), M = d._f.refs || [];
|
|
2485
|
-
if (S ? M.find((N) => N === m) : m === d._f.ref)
|
|
2486
|
-
return;
|
|
2487
|
-
T(n, l, {
|
|
2488
|
-
_f: {
|
|
2489
|
-
...d._f,
|
|
2490
|
-
...S ? {
|
|
2491
|
-
refs: [
|
|
2492
|
-
...M.filter(nt),
|
|
2493
|
-
m,
|
|
2494
|
-
...Array.isArray(k(i, l)) ? [{}] : []
|
|
2495
|
-
],
|
|
2496
|
-
ref: { type: m.type, name: l }
|
|
2497
|
-
} : { ref: m }
|
|
2498
|
-
}
|
|
2499
|
-
}), A(l, !1, void 0, m);
|
|
2500
|
-
} else
|
|
2501
|
-
d = k(n, l, {}), d._f && (d._f.mount = !1), (t.shouldUnregister || u.shouldUnregister) && !(Wn(a.array, l) && o.action) && a.unMount.add(l);
|
|
2502
|
-
}
|
|
2503
|
-
};
|
|
2504
|
-
}, Ye = () => t.shouldFocusError && Pe(n, Le, a.mount), Sr = (l) => {
|
|
2505
|
-
ne(l) && (y.state.next({ disabled: l }), Pe(n, (u, d) => {
|
|
2506
|
-
const w = k(n, d);
|
|
2507
|
-
w && (u.disabled = w._f.disabled || l, Array.isArray(w._f.refs) && w._f.refs.forEach((g) => {
|
|
2508
|
-
g.disabled = w._f.disabled || l;
|
|
2509
|
-
}));
|
|
2510
|
-
}, 0, !1));
|
|
2511
|
-
}, xt = (l, u) => async (d) => {
|
|
2512
|
-
let w;
|
|
2513
|
-
d && (d.preventDefault && d.preventDefault(), d.persist && d.persist());
|
|
2514
|
-
let g = U(s);
|
|
2515
|
-
if (y.state.next({
|
|
2516
|
-
isSubmitting: !0
|
|
2517
|
-
}), t.resolver) {
|
|
2518
|
-
const { errors: m, values: S } = await ie();
|
|
2519
|
-
x(), r.errors = m, g = U(S);
|
|
2520
|
-
} else
|
|
2521
|
-
await z(n);
|
|
2522
|
-
if (a.disabled.size)
|
|
2523
|
-
for (const m of a.disabled)
|
|
2524
|
-
P(g, m);
|
|
2525
|
-
if (P(r.errors, "root"), G(r.errors)) {
|
|
2526
|
-
y.state.next({
|
|
2527
|
-
errors: {}
|
|
2528
|
-
});
|
|
2529
|
-
try {
|
|
2530
|
-
await l(g, d);
|
|
2531
|
-
} catch (m) {
|
|
2532
|
-
w = m;
|
|
2533
|
-
}
|
|
2534
|
-
} else
|
|
2535
|
-
u && await u({ ...r.errors }, d), Ye(), setTimeout(Ye);
|
|
2536
|
-
if (y.state.next({
|
|
2537
|
-
isSubmitted: !0,
|
|
2538
|
-
isSubmitting: !1,
|
|
2539
|
-
isSubmitSuccessful: G(r.errors) && !w,
|
|
2540
|
-
submitCount: r.submitCount + 1,
|
|
2541
|
-
errors: r.errors
|
|
2542
|
-
}), w)
|
|
2543
|
-
throw w;
|
|
2544
|
-
}, Vr = (l, u = {}) => {
|
|
2545
|
-
k(n, l) && (B(u.defaultValue) ? J(l, U(k(i, l))) : (J(l, u.defaultValue), T(i, l, U(u.defaultValue))), u.keepTouched || P(r.touchedFields, l), u.keepDirty || (P(r.dirtyFields, l), r.isDirty = u.defaultValue ? F(l, U(k(i, l))) : F()), u.keepError || (P(r.errors, l), v.isValid && V()), y.state.next({ ...r }));
|
|
2546
|
-
}, wt = (l, u = {}) => {
|
|
2547
|
-
const d = l ? U(l) : i, w = U(d), g = G(l), m = g ? i : w;
|
|
2548
|
-
if (u.keepDefaultValues || (i = d), !u.keepValues) {
|
|
2549
|
-
if (u.keepDirtyValues) {
|
|
2550
|
-
const S = /* @__PURE__ */ new Set([
|
|
2551
|
-
...a.mount,
|
|
2552
|
-
...Object.keys(Ee(i, s))
|
|
2553
|
-
]);
|
|
2554
|
-
for (const M of Array.from(S)) {
|
|
2555
|
-
const N = k(r.dirtyFields, M), K = k(s, M), be = k(m, M);
|
|
2556
|
-
N && !B(K) ? T(m, M, K) : !N && !B(be) && J(M, be);
|
|
2557
|
-
}
|
|
2558
|
-
} else {
|
|
2559
|
-
if (ut && B(l))
|
|
2560
|
-
for (const S of a.mount) {
|
|
2561
|
-
const M = k(n, S);
|
|
2562
|
-
if (M && M._f) {
|
|
2563
|
-
const N = Array.isArray(M._f.refs) ? M._f.refs[0] : M._f.ref;
|
|
2564
|
-
if (Ke(N)) {
|
|
2565
|
-
const K = N.closest("form");
|
|
2566
|
-
if (K) {
|
|
2567
|
-
K.reset();
|
|
2568
|
-
break;
|
|
2569
|
-
}
|
|
2570
|
-
}
|
|
2571
|
-
}
|
|
2572
|
-
}
|
|
2573
|
-
if (u.keepFieldsRef)
|
|
2574
|
-
for (const S of a.mount)
|
|
2575
|
-
J(S, k(m, S));
|
|
2576
|
-
else
|
|
2577
|
-
n = {};
|
|
2578
|
-
}
|
|
2579
|
-
s = t.shouldUnregister ? u.keepDefaultValues ? U(i) : {} : U(m), y.array.next({
|
|
2580
|
-
values: { ...m }
|
|
2581
|
-
}), y.state.next({
|
|
2582
|
-
values: { ...m }
|
|
2583
|
-
});
|
|
2584
|
-
}
|
|
2585
|
-
a = {
|
|
2586
|
-
mount: u.keepDirtyValues ? a.mount : /* @__PURE__ */ new Set(),
|
|
2587
|
-
unMount: /* @__PURE__ */ new Set(),
|
|
2588
|
-
array: /* @__PURE__ */ new Set(),
|
|
2589
|
-
disabled: /* @__PURE__ */ new Set(),
|
|
2590
|
-
watch: /* @__PURE__ */ new Set(),
|
|
2591
|
-
watchAll: !1,
|
|
2592
|
-
focus: ""
|
|
2593
|
-
}, o.mount = !v.isValid || !!u.keepIsValid || !!u.keepDirtyValues || !t.shouldUnregister && !G(m), o.watch = !!t.shouldUnregister, o.keepIsValid = !!u.keepIsValid, o.action = !1, u.keepErrors || (r.errors = {}), y.state.next({
|
|
2594
|
-
submitCount: u.keepSubmitCount ? r.submitCount : 0,
|
|
2595
|
-
isDirty: g ? !1 : u.keepDirty ? r.isDirty : !!(u.keepDefaultValues && !he(l, i)),
|
|
2596
|
-
isSubmitted: u.keepIsSubmitted ? r.isSubmitted : !1,
|
|
2597
|
-
dirtyFields: g ? {} : u.keepDirtyValues ? u.keepDefaultValues && s ? Ee(i, s) : r.dirtyFields : u.keepDefaultValues && l ? Ee(i, l) : u.keepDirty ? r.dirtyFields : {},
|
|
2598
|
-
touchedFields: u.keepTouched ? r.touchedFields : {},
|
|
2599
|
-
errors: u.keepErrors ? r.errors : {},
|
|
2600
|
-
isSubmitSuccessful: u.keepIsSubmitSuccessful ? r.isSubmitSuccessful : !1,
|
|
2601
|
-
isSubmitting: !1,
|
|
2602
|
-
defaultValues: i
|
|
2603
|
-
});
|
|
2604
|
-
}, kt = (l, u) => wt(te(l) ? l(s) : l, { ...t.resetOptions, ...u }), Er = (l, u = {}) => {
|
|
2605
|
-
const d = k(n, l), w = d && d._f;
|
|
2606
|
-
if (w) {
|
|
2607
|
-
const g = w.refs ? w.refs[0] : w.ref;
|
|
2608
|
-
g.focus && setTimeout(() => {
|
|
2609
|
-
g.focus(), u.shouldSelect && te(g.select) && g.select();
|
|
2610
|
-
});
|
|
2611
|
-
}
|
|
2612
|
-
}, Fr = (l) => {
|
|
2613
|
-
r = {
|
|
2614
|
-
...r,
|
|
2615
|
-
...l
|
|
2616
|
-
};
|
|
2617
|
-
}, _t = {
|
|
2618
|
-
control: {
|
|
2619
|
-
register: Qe,
|
|
2620
|
-
unregister: Xe,
|
|
2621
|
-
getFieldState: gt,
|
|
2622
|
-
handleSubmit: xt,
|
|
2623
|
-
setError: yt,
|
|
2624
|
-
_subscribe: bt,
|
|
2625
|
-
_runSchema: ie,
|
|
2626
|
-
_updateIsValidating: x,
|
|
2627
|
-
_focusError: Ye,
|
|
2628
|
-
_getWatch: L,
|
|
2629
|
-
_getDirty: F,
|
|
2630
|
-
_setValid: V,
|
|
2631
|
-
_setFieldArray: _,
|
|
2632
|
-
_setDisabledField: vt,
|
|
2633
|
-
_setErrors: O,
|
|
2634
|
-
_getFieldArray: $,
|
|
2635
|
-
_reset: wt,
|
|
2636
|
-
_resetDefaultValues: () => te(t.defaultValues) && t.defaultValues().then((l) => {
|
|
2637
|
-
kt(l, t.resetOptions), y.state.next({
|
|
2638
|
-
isLoading: !1
|
|
2639
|
-
});
|
|
2640
|
-
}),
|
|
2641
|
-
_removeUnmounted: ze,
|
|
2642
|
-
_disableForm: Sr,
|
|
2643
|
-
_subjects: y,
|
|
2644
|
-
_proxyFormState: v,
|
|
2645
|
-
get _fields() {
|
|
2646
|
-
return n;
|
|
2647
|
-
},
|
|
2648
|
-
get _formValues() {
|
|
2649
|
-
return s;
|
|
2650
|
-
},
|
|
2651
|
-
get _state() {
|
|
2652
|
-
return o;
|
|
2653
|
-
},
|
|
2654
|
-
set _state(l) {
|
|
2655
|
-
o = l;
|
|
2656
|
-
},
|
|
2657
|
-
get _defaultValues() {
|
|
2658
|
-
return i;
|
|
2659
|
-
},
|
|
2660
|
-
get _names() {
|
|
2661
|
-
return a;
|
|
2662
|
-
},
|
|
2663
|
-
set _names(l) {
|
|
2664
|
-
a = l;
|
|
2665
|
-
},
|
|
2666
|
-
get _formState() {
|
|
2667
|
-
return r;
|
|
2668
|
-
},
|
|
2669
|
-
get _options() {
|
|
2670
|
-
return t;
|
|
2671
|
-
},
|
|
2672
|
-
set _options(l) {
|
|
2673
|
-
t = {
|
|
2674
|
-
...t,
|
|
2675
|
-
...l
|
|
2676
|
-
};
|
|
2677
|
-
}
|
|
2678
|
-
},
|
|
2679
|
-
subscribe: Cr,
|
|
2680
|
-
trigger: Me,
|
|
2681
|
-
register: Qe,
|
|
2682
|
-
handleSubmit: xt,
|
|
2683
|
-
watch: _r,
|
|
2684
|
-
setValue: J,
|
|
2685
|
-
getValues: mt,
|
|
2686
|
-
reset: kt,
|
|
2687
|
-
resetField: Vr,
|
|
2688
|
-
clearErrors: kr,
|
|
2689
|
-
unregister: Xe,
|
|
2690
|
-
setError: yt,
|
|
2691
|
-
setFocus: Er,
|
|
2692
|
-
getFieldState: gt
|
|
2693
|
-
};
|
|
2694
|
-
return {
|
|
2695
|
-
..._t,
|
|
2696
|
-
formControl: _t
|
|
2697
|
-
};
|
|
2698
|
-
}
|
|
2699
|
-
function Je(e = {}) {
|
|
2700
|
-
const t = H.useRef(void 0), r = H.useRef(void 0), [n, i] = H.useState({
|
|
2701
|
-
isDirty: !1,
|
|
2702
|
-
isValidating: !1,
|
|
2703
|
-
isLoading: te(e.defaultValues),
|
|
2704
|
-
isSubmitted: !1,
|
|
2705
|
-
isSubmitting: !1,
|
|
2706
|
-
isSubmitSuccessful: !1,
|
|
2707
|
-
isValid: !1,
|
|
2708
|
-
submitCount: 0,
|
|
2709
|
-
dirtyFields: {},
|
|
2710
|
-
touchedFields: {},
|
|
2711
|
-
validatingFields: {},
|
|
2712
|
-
errors: e.errors || {},
|
|
2713
|
-
disabled: e.disabled || !1,
|
|
2714
|
-
isReady: !1,
|
|
2715
|
-
defaultValues: te(e.defaultValues) ? void 0 : e.defaultValues
|
|
2716
|
-
});
|
|
2717
|
-
if (!t.current)
|
|
2718
|
-
if (e.formControl)
|
|
2719
|
-
t.current = {
|
|
2720
|
-
...e.formControl,
|
|
2721
|
-
formState: n
|
|
2722
|
-
}, e.defaultValues && !te(e.defaultValues) && e.formControl.reset(e.defaultValues, e.resetOptions);
|
|
2723
|
-
else {
|
|
2724
|
-
const { formControl: o, ...a } = ps(e);
|
|
2725
|
-
t.current = {
|
|
2726
|
-
...a,
|
|
2727
|
-
formState: n
|
|
2728
|
-
};
|
|
2729
|
-
}
|
|
2730
|
-
const s = t.current.control;
|
|
2731
|
-
return s._options = e, Qn(() => {
|
|
2732
|
-
const o = s._subscribe({
|
|
2733
|
-
formState: s._proxyFormState,
|
|
2734
|
-
callback: () => i({ ...s._formState }),
|
|
2735
|
-
reRenderRoot: !0
|
|
2736
|
-
});
|
|
2737
|
-
return i((a) => ({
|
|
2738
|
-
...a,
|
|
2739
|
-
isReady: !0
|
|
2740
|
-
})), s._formState.isReady = !0, o;
|
|
2741
|
-
}, [s]), H.useEffect(() => s._disableForm(e.disabled), [s, e.disabled]), H.useEffect(() => {
|
|
2742
|
-
e.mode && (s._options.mode = e.mode), e.reValidateMode && (s._options.reValidateMode = e.reValidateMode);
|
|
2743
|
-
}, [s, e.mode, e.reValidateMode]), H.useEffect(() => {
|
|
2744
|
-
e.errors && (s._setErrors(e.errors), s._focusError());
|
|
2745
|
-
}, [s, e.errors]), H.useEffect(() => {
|
|
2746
|
-
e.shouldUnregister && s._subjects.state.next({
|
|
2747
|
-
values: s._getWatch()
|
|
2748
|
-
});
|
|
2749
|
-
}, [s, e.shouldUnregister]), H.useEffect(() => {
|
|
2750
|
-
if (s._proxyFormState.isDirty) {
|
|
2751
|
-
const o = s._getDirty();
|
|
2752
|
-
o !== n.isDirty && s._subjects.state.next({
|
|
2753
|
-
isDirty: o
|
|
2754
|
-
});
|
|
2755
|
-
}
|
|
2756
|
-
}, [s, n.isDirty]), H.useEffect(() => {
|
|
2757
|
-
var o;
|
|
2758
|
-
e.values && !he(e.values, r.current) ? (s._reset(e.values, {
|
|
2759
|
-
keepFieldsRef: !0,
|
|
2760
|
-
...s._options.resetOptions
|
|
2761
|
-
}), !((o = s._options.resetOptions) === null || o === void 0) && o.keepIsValid || s._setValid(), r.current = e.values, i((a) => ({ ...a }))) : s._resetDefaultValues();
|
|
2762
|
-
}, [s, e.values]), H.useEffect(() => {
|
|
2763
|
-
s._state.mount || (s._setValid(), s._state.mount = !0), s._state.watch && (s._state.watch = !1, s._subjects.state.next({ ...s._formState })), s._removeUnmounted();
|
|
2764
|
-
}), t.current.formState = H.useMemo(() => Xn(n, s), [s, n]), t.current;
|
|
2765
|
-
}
|
|
2766
|
-
const Kt = (e, t, r) => {
|
|
2767
|
-
if (e && "reportValidity" in e) {
|
|
2768
|
-
const n = k(r, t);
|
|
2769
|
-
e.setCustomValidity(n && n.message || ""), e.reportValidity();
|
|
2770
|
-
}
|
|
2771
|
-
}, ms = (e, t) => {
|
|
2772
|
-
for (const r in t.fields) {
|
|
2773
|
-
const n = t.fields[r];
|
|
2774
|
-
n && n.ref && "reportValidity" in n.ref ? Kt(n.ref, r, e) : n.refs && n.refs.forEach((i) => Kt(i, r, e));
|
|
2775
|
-
}
|
|
2776
|
-
}, gs = (e, t) => {
|
|
2777
|
-
t.shouldUseNativeValidation && ms(e, t);
|
|
2778
|
-
const r = {};
|
|
2779
|
-
for (const n in e) {
|
|
2780
|
-
const i = k(t.fields, n), s = Object.assign(e[n] || {}, { ref: i && i.ref });
|
|
2781
|
-
if (ys(t.names || Object.keys(e), n)) {
|
|
2782
|
-
const o = Object.assign({}, k(r, n));
|
|
2783
|
-
T(o, "root", s), T(r, n, o);
|
|
2784
|
-
} else
|
|
2785
|
-
T(r, n, s);
|
|
2786
|
-
}
|
|
2787
|
-
return r;
|
|
2788
|
-
}, ys = (e, t) => e.some((r) => r.startsWith(t + "."));
|
|
2789
|
-
var Ze = function(e, t, r) {
|
|
2790
|
-
return r === void 0 && (r = {}), function(n, i, s) {
|
|
2791
|
-
try {
|
|
2792
|
-
var o = !s.shouldUseNativeValidation && s.criteriaMode === "all";
|
|
2793
|
-
return Promise.resolve(jr(e, n, Object.assign({}, t, { abortPipeEarly: !o }))).then(function(a) {
|
|
2794
|
-
if (a.issues) {
|
|
2795
|
-
for (var f = {}; a.issues.length; ) {
|
|
2796
|
-
var p = a.issues[0], C = $r(p);
|
|
2797
|
-
if (C && (f[C] || (f[C] = { message: p.message, type: p.type }), o)) {
|
|
2798
|
-
var v = f[C].types, h = v && v[p.type];
|
|
2799
|
-
f[C] = pr(C, o, f, p.type, h ? [].concat(h, p.message) : p.message);
|
|
2800
|
-
}
|
|
2801
|
-
a.issues.shift();
|
|
2802
|
-
}
|
|
2803
|
-
return { values: {}, errors: gs(f, s) };
|
|
2804
|
-
}
|
|
2805
|
-
return { values: r.raw ? n : a.output, errors: {} };
|
|
2806
|
-
});
|
|
2807
|
-
} catch (a) {
|
|
2808
|
-
return Promise.reject(a);
|
|
2809
|
-
}
|
|
2810
|
-
};
|
|
2811
|
-
};
|
|
2812
|
-
const Ht = 27, Gt = 12, Wt = 10, bs = Fe("enum"), vs = (e, t) => {
|
|
2813
|
-
const r = {
|
|
2814
|
-
min: e.minSelected ?? 0,
|
|
2815
|
-
max: e.maxSelected ?? e.options.length
|
|
2816
|
-
};
|
|
2817
|
-
return Ze(ge({
|
|
2818
|
-
checked: pe(Ur(Y(), zr()), rr((n) => Object.entries(n).filter(([i, s]) => s).map(([i, s]) => i)), qe(r.max, t("validation_multiple_choice_max", {
|
|
2819
|
-
count: r.max
|
|
2820
|
-
})), Oe(r.min, t("validation_multiple_choice_min", {
|
|
2821
|
-
count: r.min
|
|
2822
|
-
})))
|
|
2823
|
-
}));
|
|
2824
|
-
}, xs = tr(({
|
|
2825
|
-
option: e,
|
|
2826
|
-
...t
|
|
2827
|
-
}, r) => c(we, {
|
|
2828
|
-
children: [c("input", {
|
|
2829
|
-
class: "peer sr-only h-full",
|
|
2830
|
-
type: "checkbox",
|
|
2831
|
-
...t,
|
|
2832
|
-
ref: r
|
|
2833
|
-
}), c("label", {
|
|
2834
|
-
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",
|
|
2835
|
-
htmlFor: t.id,
|
|
2836
|
-
children: e.label
|
|
2837
|
-
})]
|
|
2838
|
-
})), Jt = Ge("gutter-stable flex w-full flex-1 flex-wrap gap-2 overflow-y-auto rounded-xl p-2.5 pr-4", {
|
|
2839
|
-
variants: {
|
|
2840
|
-
variant: {
|
|
2841
|
-
// In cases where there is only one option, we want to center it
|
|
2842
|
-
singleOption: "justify-center",
|
|
2843
|
-
// Two choices with exactly 1 min 1 max
|
|
2844
|
-
booleanLike: cr
|
|
2845
|
-
}
|
|
2846
|
-
}
|
|
2847
|
-
}), ws = ({
|
|
2848
|
-
input: e,
|
|
2849
|
-
onSubmitSuccess: t
|
|
2850
|
-
}) => {
|
|
2851
|
-
var C, v;
|
|
2852
|
-
const r = e.key ? (C = D.current$.value.flow) == null ? void 0 : C.data.submissions[e.key] : void 0, n = (e.config.minSelected === 1 || e.config.minSelected === void 0) && e.config.maxSelected === 1, i = n && e.config.options.length === 2, {
|
|
2853
|
-
t: s
|
|
2854
|
-
} = Q(), {
|
|
2855
|
-
register: o,
|
|
2856
|
-
handleSubmit: a,
|
|
2857
|
-
formState: {
|
|
2858
|
-
errors: f
|
|
2859
|
-
}
|
|
2860
|
-
} = Je({
|
|
2861
|
-
defaultValues: {
|
|
2862
|
-
checked: n ? {} : bs(r) ? Object.fromEntries(r.value.map((h) => [h, !0])) : {}
|
|
2863
|
-
},
|
|
2864
|
-
resolver: vs(e.config, s)
|
|
2865
|
-
}), p = ct();
|
|
2866
|
-
return i ? c("ul", {
|
|
2867
|
-
style: {
|
|
2868
|
-
maxHeight: 6.5 * Ht + 5 * Gt + 2 * Wt
|
|
2869
|
-
},
|
|
2870
|
-
class: Jt({
|
|
2871
|
-
variant: "booleanLike"
|
|
2872
|
-
}),
|
|
2873
|
-
children: e.config.options.map((h, y) => c("li", {
|
|
2874
|
-
class: ur,
|
|
2875
|
-
children: c(dr, {
|
|
2876
|
-
type: "submit",
|
|
2877
|
-
ref: (b) => {
|
|
2878
|
-
b && y === 0 && (p.current = b);
|
|
2879
|
-
},
|
|
2880
|
-
label: h.label,
|
|
2881
|
-
value: "true",
|
|
2882
|
-
onClick: () => t({
|
|
2883
|
-
type: "enum",
|
|
2884
|
-
value: [h.value]
|
|
2885
|
-
})
|
|
2886
|
-
})
|
|
2887
|
-
}, h.value))
|
|
2888
|
-
}) : c("form", {
|
|
2889
|
-
noValidate: !0,
|
|
2890
|
-
onSubmit: (h) => a((y) => {
|
|
2891
|
-
const b = y.checked;
|
|
2892
|
-
t({
|
|
2893
|
-
type: "enum",
|
|
2894
|
-
value: b
|
|
2895
|
-
});
|
|
2896
|
-
})(h),
|
|
2897
|
-
children: [c("div", {
|
|
2898
|
-
class: "flex items-center gap-1",
|
|
2899
|
-
children: [c("ul", {
|
|
2900
|
-
style: {
|
|
2901
|
-
maxHeight: 6.5 * Ht + 5 * Gt + 2 * Wt
|
|
2902
|
-
},
|
|
2903
|
-
class: Jt({
|
|
2904
|
-
variant: e.config.options.length === 1 ? "singleOption" : void 0
|
|
2905
|
-
}),
|
|
2906
|
-
children: e.config.options.map((h, y) => {
|
|
2907
|
-
const b = `checked.${h.value}`, {
|
|
2908
|
-
ref: E,
|
|
2909
|
-
...V
|
|
2910
|
-
} = o(b);
|
|
2911
|
-
return c("li", {
|
|
2912
|
-
class: "relative",
|
|
2913
|
-
children: c(xs, {
|
|
2914
|
-
option: h,
|
|
2915
|
-
autoFocus: y === 0,
|
|
2916
|
-
ref: (x) => {
|
|
2917
|
-
x && y === 0 && (p.current = x), E(x);
|
|
2918
|
-
},
|
|
2919
|
-
id: b,
|
|
2920
|
-
...V,
|
|
2921
|
-
onClick: n ? () => t({
|
|
2922
|
-
type: "enum",
|
|
2923
|
-
value: [h.value]
|
|
2924
|
-
}) : void 0
|
|
2925
|
-
})
|
|
2926
|
-
}, h.value);
|
|
2927
|
-
})
|
|
2928
|
-
}), c("div", {
|
|
2929
|
-
class: "flex flex-col items-center gap-2 pr-2.5 pt-2.5",
|
|
2930
|
-
children: [n ? null : c(ke, {}), e.config.minSelected === 0 && c(_e, {
|
|
2931
|
-
class: "relative",
|
|
2932
|
-
type: "button",
|
|
2933
|
-
onClick: () => t({
|
|
2934
|
-
type: "enum",
|
|
2935
|
-
value: []
|
|
2936
|
-
})
|
|
2937
|
-
})]
|
|
2938
|
-
})]
|
|
2939
|
-
}), c("div", {
|
|
2940
|
-
class: "px-1",
|
|
2941
|
-
children: c(Ie, {
|
|
2942
|
-
error: (v = f.checked) == null ? void 0 : v.root
|
|
2943
|
-
})
|
|
2944
|
-
})]
|
|
2945
|
-
});
|
|
2946
|
-
}, ks = Fe("number"), _s = (e, t) => {
|
|
2947
|
-
const r = e.min ?? Number.MIN_SAFE_INTEGER, n = e.max ?? Number.MAX_SAFE_INTEGER, i = e.decimalCases ?? 0;
|
|
2948
|
-
return Ze(ge({
|
|
2949
|
-
number: pe(Gr(t("validation_number")), Hr(r, t("validation_number_min", {
|
|
2950
|
-
min: r
|
|
2951
|
-
})), Kr(n, t("validation_number_max", {
|
|
2952
|
-
max: n
|
|
2953
|
-
})), qr((s) => s === Number(s.toFixed(i)), t("validation_number_decimal_cases", {
|
|
2954
|
-
count: i
|
|
2955
|
-
})))
|
|
2956
|
-
}));
|
|
2957
|
-
}, Cs = ({
|
|
2958
|
-
input: e,
|
|
2959
|
-
onSubmitSuccess: t
|
|
2960
|
-
}) => {
|
|
2961
|
-
var v;
|
|
2962
|
-
const r = e.config.defaultValue, n = e.key ? (v = D.current$.value.flow) == null ? void 0 : v.data.submissions[e.key] : void 0, {
|
|
2963
|
-
t: i
|
|
2964
|
-
} = Q(), {
|
|
2965
|
-
register: s,
|
|
2966
|
-
handleSubmit: o,
|
|
2967
|
-
formState: {
|
|
2968
|
-
errors: a
|
|
2969
|
-
}
|
|
2970
|
-
} = Je({
|
|
2971
|
-
defaultValues: {
|
|
2972
|
-
number: r ? Number(r) : ks(n) ? n.value : void 0
|
|
2973
|
-
},
|
|
2974
|
-
resolver: _s(e.config, i)
|
|
2975
|
-
}), {
|
|
2976
|
-
ref: f,
|
|
2977
|
-
...p
|
|
2978
|
-
} = s("number", {
|
|
2979
|
-
required: !e.config.optional,
|
|
2980
|
-
valueAsNumber: !0
|
|
2981
|
-
}), C = ue();
|
|
2982
|
-
return xe(() => {
|
|
2983
|
-
C.current && (C.current.focus(), C.current.select());
|
|
2984
|
-
}, []), c("form", {
|
|
2985
|
-
class: "flex flex-col gap-1 p-2.5",
|
|
2986
|
-
onSubmit: o((h) => {
|
|
2987
|
-
h.number !== void 0 && t({
|
|
2988
|
-
type: "number",
|
|
2989
|
-
value: h.number
|
|
2990
|
-
});
|
|
2991
|
-
}),
|
|
2992
|
-
children: [c("div", {
|
|
2993
|
-
class: "flex items-center gap-2",
|
|
2994
|
-
children: [c("div", {
|
|
2995
|
-
class: "relative min-w-0 flex-grow",
|
|
2996
|
-
children: [c("input", {
|
|
2997
|
-
...p,
|
|
2998
|
-
id: "chat-input",
|
|
2999
|
-
autocomplete: "off",
|
|
3000
|
-
autoCapitalize: "off",
|
|
3001
|
-
autoCorrect: "off",
|
|
3002
|
-
autoFocus: !0,
|
|
3003
|
-
ref: (h) => {
|
|
3004
|
-
h && (C.current = h), f(h);
|
|
3005
|
-
},
|
|
3006
|
-
type: "text",
|
|
3007
|
-
min: e.config.min,
|
|
3008
|
-
max: e.config.max,
|
|
3009
|
-
class: $e({
|
|
3010
|
-
optional: e.config.optional,
|
|
3011
|
-
className: "[type=number:-webkit-inner-spin-button] w-full rounded-full [-webkit-outer-spin-button:none]"
|
|
3012
|
-
}),
|
|
3013
|
-
placeholder: e.config.placeholder
|
|
3014
|
-
}), e.config.optional && c(_e, {
|
|
3015
|
-
class: "absolute bottom-0 right-0.5 top-0",
|
|
3016
|
-
onClick: () => t(null)
|
|
3017
|
-
})]
|
|
3018
|
-
}), c(ke, {})]
|
|
3019
|
-
}), c(Ie, {
|
|
3020
|
-
error: a.number
|
|
3021
|
-
})]
|
|
3022
|
-
});
|
|
3023
|
-
}, Ss = (e) => {
|
|
3024
|
-
if (e === "")
|
|
3025
|
-
return {
|
|
3026
|
-
countryCode: "",
|
|
3027
|
-
phoneNumber: ""
|
|
3028
|
-
};
|
|
3029
|
-
const t = Object.entries(lt).find((i) => e.startsWith(i[1])), r = t ? t[1] : "", n = e.replace(r, "");
|
|
3030
|
-
return /^\d+$/.test(n) ? {
|
|
3031
|
-
countryCode: r,
|
|
3032
|
-
phoneNumber: n
|
|
3033
|
-
} : {
|
|
3034
|
-
countryCode: "",
|
|
3035
|
-
phoneNumber: ""
|
|
3036
|
-
};
|
|
3037
|
-
}, Vs = "44", Es = /^[0-9 ]+$/, Fs = Fe("string"), Is = Fe("phone"), As = (e) => {
|
|
3038
|
-
const t = pe(Y(e("validation_country_code")), nr(Es, e("validation_country_code"))), r = pe(Y(e("validation_phone")), Oe(1, e("validation_phone")), rr((n) => n.replace(/[^0-9]/g, "")));
|
|
3039
|
-
return Ze(ge({
|
|
3040
|
-
countryCode: t,
|
|
3041
|
-
phoneNumber: r
|
|
3042
|
-
}));
|
|
3043
|
-
}, Ls = ({
|
|
3044
|
-
input: e,
|
|
3045
|
-
onSubmitSuccess: t
|
|
3046
|
-
}) => {
|
|
3047
|
-
var E;
|
|
3048
|
-
const r = e.key ? (E = D.current$.value.flow) == null ? void 0 : E.data.submissions[e.key] : void 0, {
|
|
3049
|
-
t: n
|
|
3050
|
-
} = Q(), [i, s] = se(), o = Fs(r) ? Ss(r.value) : Is(r) ? r.value : void 0, {
|
|
3051
|
-
register: a,
|
|
3052
|
-
handleSubmit: f,
|
|
3053
|
-
formState: {
|
|
3054
|
-
errors: p
|
|
3055
|
-
},
|
|
3056
|
-
watch: C
|
|
3057
|
-
} = Je({
|
|
3058
|
-
defaultValues: {
|
|
3059
|
-
countryCode: (o == null ? void 0 : o.countryCode) ?? e.config.defaultValue.countryCode ?? Vs,
|
|
3060
|
-
phoneNumber: (o == null ? void 0 : o.phoneNumber) ?? e.config.defaultValue.phoneNumber ?? ""
|
|
3061
|
-
},
|
|
3062
|
-
resolver: As(n)
|
|
3063
|
-
}), {
|
|
3064
|
-
ref: v,
|
|
3065
|
-
...h
|
|
3066
|
-
} = a("phoneNumber", {
|
|
3067
|
-
required: !e.config.optional
|
|
3068
|
-
}), y = ue(), b = C("countryCode");
|
|
3069
|
-
return xe(() => {
|
|
3070
|
-
y.current && (y.current.focus(), y.current.select());
|
|
3071
|
-
}, []), c("form", {
|
|
3072
|
-
noValidate: !0,
|
|
3073
|
-
class: "flex flex-col gap-1 p-2.5",
|
|
3074
|
-
onSubmit: f((V) => {
|
|
3075
|
-
const x = V.phoneNumber.replace(/[^0-9]/g, ""), _ = V.countryCode.replace(/[^0-9]/g, "");
|
|
3076
|
-
s(void 0);
|
|
3077
|
-
const I = e.config.minChars ?? 7, O = x.length + _.length;
|
|
3078
|
-
if (O < I)
|
|
3079
|
-
return s(n("validation_phone_min_chars", {
|
|
3080
|
-
count: I
|
|
3081
|
-
}));
|
|
3082
|
-
const A = e.config.maxChars;
|
|
3083
|
-
if (A != null && O > A)
|
|
3084
|
-
return s(n("validation_max_chars", {
|
|
3085
|
-
count: A
|
|
3086
|
-
}));
|
|
3087
|
-
e.config.submissionFormat === "phone" ? t({
|
|
3088
|
-
type: "phone",
|
|
3089
|
-
value: {
|
|
3090
|
-
countryCode: _,
|
|
3091
|
-
phoneNumber: x
|
|
3092
|
-
}
|
|
3093
|
-
}) : t({
|
|
3094
|
-
type: "string",
|
|
3095
|
-
value: b + V.phoneNumber
|
|
3096
|
-
});
|
|
3097
|
-
}),
|
|
3098
|
-
children: [c("div", {
|
|
3099
|
-
class: "flex items-center gap-2",
|
|
3100
|
-
children: [c("div", {
|
|
3101
|
-
class: "relative flex min-w-0 flex-1 flex-grow gap-2",
|
|
3102
|
-
children: [c("label", {
|
|
3103
|
-
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",
|
|
3104
|
-
htmlFor: `isdk_phone_${e.key}`,
|
|
3105
|
-
children: [c("span", {
|
|
3106
|
-
children: ["+", b]
|
|
3107
|
-
}), c("select", {
|
|
3108
|
-
...a("countryCode", {}),
|
|
3109
|
-
id: `isdk_phone_${e.key}`,
|
|
3110
|
-
class: "absolute inset-0 opacity-0",
|
|
3111
|
-
children: Object.entries(lt).map(([V, x]) => c("option", {
|
|
3112
|
-
value: x,
|
|
3113
|
-
children: [V, " (+", x, ")"]
|
|
3114
|
-
}, V))
|
|
3115
|
-
})]
|
|
3116
|
-
}), c("input", {
|
|
3117
|
-
...h,
|
|
3118
|
-
id: "chat-input",
|
|
3119
|
-
type: "tel",
|
|
3120
|
-
inputMode: "tel",
|
|
3121
|
-
autocomplete: "off",
|
|
3122
|
-
autoCapitalize: "off",
|
|
3123
|
-
autoCorrect: "off",
|
|
3124
|
-
autoFocus: !0,
|
|
3125
|
-
ref: (V) => {
|
|
3126
|
-
V && (y.current = V), v(V);
|
|
3127
|
-
},
|
|
3128
|
-
class: $e({
|
|
3129
|
-
optional: e.config.optional,
|
|
3130
|
-
className: "min-w-0 flex-1 rounded-r-full"
|
|
3131
|
-
}),
|
|
3132
|
-
placeholder: e.config.placeholder
|
|
3133
|
-
}), e.config.optional && c(_e, {
|
|
3134
|
-
class: "absolute bottom-0 right-1 top-0",
|
|
3135
|
-
onClick: () => t(null)
|
|
3136
|
-
})]
|
|
3137
|
-
}), c(ke, {})]
|
|
3138
|
-
}), c(Ie, {
|
|
3139
|
-
error: p.countryCode || p.phoneNumber || {
|
|
3140
|
-
message: i
|
|
3141
|
-
}
|
|
3142
|
-
})]
|
|
3143
|
-
});
|
|
3144
|
-
}, Ms = ({
|
|
3145
|
-
input: e,
|
|
3146
|
-
onSubmitSuccess: t
|
|
3147
|
-
}) => c("div", {
|
|
3148
|
-
class: "flex flex-col items-center py-3",
|
|
3149
|
-
children: c("button", {
|
|
3150
|
-
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 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",
|
|
3151
|
-
name: e.key,
|
|
3152
|
-
onClick: () => {
|
|
3153
|
-
t(null);
|
|
3154
|
-
},
|
|
3155
|
-
children: c("span", {
|
|
3156
|
-
class: "flex items-center gap-1.5",
|
|
3157
|
-
children: [c("span", {
|
|
3158
|
-
class: "inline-flex items-center text-sm font-medium",
|
|
3159
|
-
children: e.config.label || "Submit"
|
|
3160
|
-
}), c("svg", {
|
|
3161
|
-
stroke: "currentColor",
|
|
3162
|
-
"stroke-width": "1.5",
|
|
3163
|
-
width: "16",
|
|
3164
|
-
height: "16",
|
|
3165
|
-
viewBox: "0 0 16 16",
|
|
3166
|
-
fill: "none",
|
|
3167
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
3168
|
-
children: [c("path", {
|
|
3169
|
-
d: "M4 8L8 4L12 8"
|
|
3170
|
-
}), c("path", {
|
|
3171
|
-
d: "M8 4V13"
|
|
3172
|
-
})]
|
|
3173
|
-
})]
|
|
3174
|
-
})
|
|
3175
|
-
})
|
|
3176
|
-
}), Ns = {
|
|
3177
|
-
date: {
|
|
3178
|
-
type: "date",
|
|
3179
|
-
inputMode: "text"
|
|
3180
|
-
},
|
|
3181
|
-
email: {
|
|
3182
|
-
type: "email",
|
|
3183
|
-
inputMode: "email",
|
|
3184
|
-
formNoValidate: !0
|
|
3185
|
-
},
|
|
3186
|
-
text: {
|
|
3187
|
-
type: "text",
|
|
3188
|
-
inputMode: "text"
|
|
3189
|
-
},
|
|
3190
|
-
url: {
|
|
3191
|
-
type: "url",
|
|
3192
|
-
inputMode: "url",
|
|
3193
|
-
formNoValidate: !0
|
|
3194
|
-
}
|
|
3195
|
-
}, Ts = Fe("string"), Ds = (e, t) => {
|
|
3196
|
-
const r = {
|
|
3197
|
-
maxLength: t("validation_max_chars", {
|
|
3198
|
-
count: e.maxChars ?? 999
|
|
3199
|
-
}),
|
|
3200
|
-
minLength: t("validation_min_chars", {
|
|
3201
|
-
count: e.minChars ?? 1
|
|
3202
|
-
})
|
|
3203
|
-
};
|
|
3204
|
-
return Ze(ge({
|
|
3205
|
-
text: {
|
|
3206
|
-
date: pe(Y(t("validation_date")), nr(/^\d{4}-\d{2}-\d{2}$/, t("validation_date"))),
|
|
3207
|
-
email: pe(Y(t("validation_email")), Wr(t("validation_email")), Oe(e.minChars ?? 1, r.minLength), qe(e.maxChars ?? 1 / 0, r.maxLength)),
|
|
3208
|
-
text: pe(Y(), Oe(e.minChars ?? 1, r.minLength), qe(e.maxChars ?? 1 / 0, r.maxLength)),
|
|
3209
|
-
url: pe(Y(t("validation_url")), Jr(t("validation_url")), Oe(e.minChars ?? 1, r.minLength), qe(e.maxChars ?? 1 / 0, r.maxLength))
|
|
3210
|
-
}[e.format]
|
|
3211
|
-
}));
|
|
3212
|
-
}, Rs = ({
|
|
3213
|
-
input: e,
|
|
3214
|
-
onSubmitSuccess: t
|
|
3215
|
-
}) => {
|
|
3216
|
-
var v;
|
|
3217
|
-
const {
|
|
3218
|
-
t: r
|
|
3219
|
-
} = Q(), n = e.key ? (v = D.current$.value.flow) == null ? void 0 : v.data.submissions[e.key] : void 0, i = e.config.defaultValue, {
|
|
3220
|
-
register: s,
|
|
3221
|
-
handleSubmit: o,
|
|
3222
|
-
formState: {
|
|
3223
|
-
errors: a
|
|
3224
|
-
}
|
|
3225
|
-
} = Je({
|
|
3226
|
-
defaultValues: {
|
|
3227
|
-
text: i || (Ts(n) ? n.value : "")
|
|
3228
|
-
},
|
|
3229
|
-
resolver: Ds(e.config, r)
|
|
3230
|
-
}), {
|
|
3231
|
-
ref: f,
|
|
3232
|
-
...p
|
|
3233
|
-
} = s("text", {
|
|
3234
|
-
required: !e.config.optional
|
|
3235
|
-
}), C = ue();
|
|
3236
|
-
return xe(() => {
|
|
3237
|
-
C.current && (C.current.focus(), C.current.select());
|
|
3238
|
-
}, []), c("form", {
|
|
3239
|
-
noValidate: !0,
|
|
3240
|
-
class: "flex flex-col gap-1 p-2.5",
|
|
3241
|
-
onSubmit: o((h) => {
|
|
3242
|
-
t({
|
|
3243
|
-
type: "string",
|
|
3244
|
-
value: h.text
|
|
3245
|
-
});
|
|
3246
|
-
}),
|
|
3247
|
-
children: [c("div", {
|
|
3248
|
-
class: "flex items-center gap-2",
|
|
3249
|
-
children: [c("div", {
|
|
3250
|
-
class: "relative min-w-0 flex-1",
|
|
3251
|
-
children: [c("input", {
|
|
3252
|
-
id: "chat-input",
|
|
3253
|
-
...p,
|
|
3254
|
-
...Ns[e.config.format],
|
|
3255
|
-
autocomplete: "off",
|
|
3256
|
-
autoCapitalize: "off",
|
|
3257
|
-
autoCorrect: "off",
|
|
3258
|
-
autoFocus: !0,
|
|
3259
|
-
ref: (h) => {
|
|
3260
|
-
h && (C.current = h), f(h);
|
|
3261
|
-
},
|
|
3262
|
-
placeholder: e.config.placeholder,
|
|
3263
|
-
class: $e({
|
|
3264
|
-
optional: !!e.config.optional,
|
|
3265
|
-
className: "w-full rounded-full"
|
|
3266
|
-
})
|
|
3267
|
-
}), e.config.optional && c(_e, {
|
|
3268
|
-
class: "absolute bottom-0 right-0.5 top-0",
|
|
3269
|
-
onClick: () => t(null)
|
|
3270
|
-
})]
|
|
3271
|
-
}), c(ke, {})]
|
|
3272
|
-
}), c(Ie, {
|
|
3273
|
-
error: a.text
|
|
3274
|
-
})]
|
|
3275
|
-
});
|
|
3276
|
-
}, Os = {
|
|
3277
|
-
text: Rs,
|
|
3278
|
-
phone: Ls,
|
|
3279
|
-
"multiple-choice": ws,
|
|
3280
|
-
boolean: Bn,
|
|
3281
|
-
file: Kn,
|
|
3282
|
-
submit: Ms,
|
|
3283
|
-
address: Tn,
|
|
3284
|
-
number: Cs
|
|
3285
|
-
}, Bs = ({
|
|
3286
|
-
logger: e
|
|
3287
|
-
}) => {
|
|
3288
|
-
var s;
|
|
3289
|
-
const t = (s = D.current$.value.flow) == null ? void 0 : s.data.currentInput, [r, n] = Cn(), i = ue(null);
|
|
3290
|
-
return D.inputHeight$.value = n.height, ce(() => {
|
|
3291
|
-
const o = i.current;
|
|
3292
|
-
if (o)
|
|
3293
|
-
return o.addEventListener("transitionstart", Z.scrollToEnd.smooth), o.addEventListener("transitioncancel", Z.scrollToEnd.smooth), o.addEventListener("transitionend", Z.scrollToEnd.smooth), () => {
|
|
3294
|
-
o.removeEventListener("transitionstart", Z.scrollToEnd.smooth), o.removeEventListener("transitioncancel", Z.scrollToEnd.smooth), o.removeEventListener("transitionend", Z.scrollToEnd.smooth);
|
|
3295
|
-
};
|
|
3296
|
-
}, []), c("div", {
|
|
3297
|
-
ref: i,
|
|
3298
|
-
class: "ease-expo-out absolute bottom-0 w-full overflow-hidden rounded-b-3xl backdrop-blur-xl transition-all duration-700 will-change-[height]",
|
|
3299
|
-
style: {
|
|
3300
|
-
height: n.height
|
|
3301
|
-
},
|
|
3302
|
-
children: c("div", {
|
|
3303
|
-
ref: r,
|
|
3304
|
-
class: "border-divider flex flex-col justify-end border-t",
|
|
3305
|
-
children: t ? (() => {
|
|
3306
|
-
const o = Os[t.type];
|
|
3307
|
-
return c(o, {
|
|
3308
|
-
logger: e,
|
|
3309
|
-
onSubmitSuccess: Z.onSubmitSuccessFn$.value,
|
|
3310
|
-
input: t
|
|
3311
|
-
});
|
|
3312
|
-
})() : c("div", {
|
|
3313
|
-
class: "flex items-center gap-2 p-2.5",
|
|
3314
|
-
children: [c("input", {
|
|
3315
|
-
"aria-hidden": "true",
|
|
3316
|
-
id: "chat-input",
|
|
3317
|
-
class: $e({
|
|
3318
|
-
optional: !1,
|
|
3319
|
-
className: "flex-grow rounded-full"
|
|
3320
|
-
}),
|
|
3321
|
-
disabled: !0
|
|
3322
|
-
}), c(ke, {
|
|
3323
|
-
disabled: !0,
|
|
3324
|
-
"aria-hidden": "true",
|
|
3325
|
-
tabIndex: -1
|
|
3326
|
-
})]
|
|
3327
|
-
})
|
|
3328
|
-
})
|
|
3329
|
-
});
|
|
3330
|
-
};
|
|
3331
|
-
function Ps(e) {
|
|
3332
|
-
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
3333
|
-
}
|
|
3334
|
-
var js = function(e) {
|
|
3335
|
-
return e instanceof RegExp;
|
|
3336
|
-
}, $s = function(t) {
|
|
3337
|
-
var r = /[\\^$.*+?()[\]{}|]/g, n = RegExp(r.source);
|
|
3338
|
-
return t && n.test(t) ? t.replace(r, "\\$&") : t;
|
|
3339
|
-
}, wr = function(e) {
|
|
3340
|
-
return typeof e == "string";
|
|
3341
|
-
}, Us = function(e) {
|
|
3342
|
-
var t = [];
|
|
3343
|
-
return e.forEach(function(r) {
|
|
3344
|
-
Array.isArray(r) ? t = t.concat(r) : t.push(r);
|
|
3345
|
-
}), t;
|
|
3346
|
-
};
|
|
3347
|
-
function zs(e, t, r) {
|
|
3348
|
-
var n = 0, i = 0;
|
|
3349
|
-
if (e === "")
|
|
3350
|
-
return e;
|
|
3351
|
-
if (!e || !wr(e))
|
|
3352
|
-
throw new TypeError("First argument to react-string-replace#replaceString must be a string");
|
|
3353
|
-
var s = t;
|
|
3354
|
-
js(s) || (s = new RegExp("(" + $s(s) + ")", "gi"));
|
|
3355
|
-
for (var o = e.split(s), a = 1, f = o.length; a < f; a += 2) {
|
|
3356
|
-
if (o[a] === void 0 || o[a - 1] === void 0) {
|
|
3357
|
-
console.warn("reactStringReplace: Encountered undefined value during string replacement. Your RegExp may not be working the way you expect.");
|
|
3358
|
-
continue;
|
|
3359
|
-
}
|
|
3360
|
-
i = o[a].length, n += o[a - 1].length, o[a] = r(o[a], a, n), n += i;
|
|
3361
|
-
}
|
|
3362
|
-
return o;
|
|
3363
|
-
}
|
|
3364
|
-
var qs = function(t, r, n) {
|
|
3365
|
-
return Array.isArray(t) || (t = [t]), Us(t.map(function(i) {
|
|
3366
|
-
return wr(i) ? zs(i, r, n) : i;
|
|
3367
|
-
}));
|
|
3368
|
-
};
|
|
3369
|
-
const Te = /* @__PURE__ */ Ps(qs), Ks = /(\[[^\]]+\]\([^)]+\))/g, Hs = /\[([^\]]+)\]\(([^)]+)\)/, Gs = /(https?:\/\/[^\s]+)/g, Ws = /_(.*?)_/g, Js = /\*\*(.*?)\*\*/g, Zs = /\\n|\n/g, Zt = "text-accent-10 hover:text-accent-11 no-underline underline-offset-2 hover:underline", Xs = (e) => {
|
|
3370
|
-
const t = Te(e, Ks, (o, a) => {
|
|
3371
|
-
const [, f, p] = o.match(Hs) ?? [];
|
|
3372
|
-
return p ? c("a", {
|
|
3373
|
-
class: Zt,
|
|
3374
|
-
href: p,
|
|
3375
|
-
children: f ?? p
|
|
3376
|
-
}, p + a) : c("span", {
|
|
3377
|
-
children: "INVALID LINK"
|
|
3378
|
-
});
|
|
3379
|
-
}), r = Te(t, Gs, (o, a) => c("a", {
|
|
3380
|
-
class: Zt,
|
|
3381
|
-
href: o,
|
|
3382
|
-
children: o
|
|
3383
|
-
}, o + a)), n = Te(r, Ws, (o, a) => c("em", {
|
|
3384
|
-
children: o
|
|
3385
|
-
}, o + a)), i = Te(n, Js, (o, a) => c("strong", {
|
|
3386
|
-
children: o
|
|
3387
|
-
}, o + a));
|
|
3388
|
-
return Te(i, Zs, (o, a) => c("br", {}, `br-${a}`));
|
|
3389
|
-
}, Qs = Ge("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", {
|
|
3390
|
-
variants: {
|
|
3391
|
-
side: {
|
|
3392
|
-
left: "bg-bubble-weak-bg text-neutral-12 shadow-surface-sm outline outline-1 outline-bubble-weak rounded-bl-md",
|
|
3393
|
-
right: "ml-auto bg-accent-9 text-white rounded-br-md shadow-surface-sm shadow-bubble-strong-shadow"
|
|
3394
|
-
},
|
|
3395
|
-
animate: {
|
|
3396
|
-
true: "animate-bubble-in",
|
|
3397
|
-
false: ""
|
|
3398
|
-
}
|
|
3399
|
-
},
|
|
3400
|
-
defaultVariants: {
|
|
3401
|
-
side: "left"
|
|
3402
|
-
}
|
|
3403
|
-
}), Ys = ({
|
|
3404
|
-
children: e,
|
|
3405
|
-
className: t,
|
|
3406
|
-
animate: r,
|
|
3407
|
-
side: n,
|
|
3408
|
-
...i
|
|
3409
|
-
}) => c("p", {
|
|
3410
|
-
style: {
|
|
3411
|
-
transformOrigin: n === "left" ? "0% 50%" : "100% 50%"
|
|
3412
|
-
},
|
|
3413
|
-
class: Qs({
|
|
3414
|
-
className: t,
|
|
3415
|
-
side: n,
|
|
3416
|
-
animate: r
|
|
3417
|
-
}),
|
|
3418
|
-
...i,
|
|
3419
|
-
children: e
|
|
3420
|
-
}), ea = ({
|
|
3421
|
-
message: e
|
|
3422
|
-
}) => c("div", {
|
|
3423
|
-
class: "bg-accent-3 flex w-full items-center justify-center overflow-hidden rounded-xl px-2 py-2",
|
|
3424
|
-
children: c("a", {
|
|
3425
|
-
onClick: e.onClick,
|
|
3426
|
-
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",
|
|
3427
|
-
target: "_blank",
|
|
3428
|
-
href: e.href,
|
|
3429
|
-
children: [e.text, c("svg", {
|
|
3430
|
-
class: "flex-none",
|
|
3431
|
-
width: "15",
|
|
3432
|
-
height: "15",
|
|
3433
|
-
viewBox: "0 0 15 15",
|
|
3434
|
-
fill: "none",
|
|
3435
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
3436
|
-
children: c("path", {
|
|
3437
|
-
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",
|
|
3438
|
-
fill: "currentColor",
|
|
3439
|
-
"fill-rule": "evenodd",
|
|
3440
|
-
"clip-rule": "evenodd"
|
|
3441
|
-
})
|
|
3442
|
-
})]
|
|
3443
|
-
})
|
|
3444
|
-
}), ta = ({
|
|
3445
|
-
className: e,
|
|
3446
|
-
...t
|
|
3447
|
-
}) => (ce(() => {
|
|
3448
|
-
Z.scrollToEnd.smooth();
|
|
3449
|
-
}), c("div", {
|
|
3450
|
-
"aria-hidden": !0,
|
|
3451
|
-
children: Z.isBotTyping$.value === !0 ? c("div", {
|
|
3452
|
-
"aria-label": "Typing…",
|
|
3453
|
-
class: je("flex gap-1 p-4", e),
|
|
3454
|
-
...t,
|
|
3455
|
-
children: Array.from({
|
|
3456
|
-
length: 3
|
|
3457
|
-
}, (r, n) => c("div", {
|
|
3458
|
-
class: "bg-accent-9 h-1.5 w-1.5 animate-bounce rounded-full",
|
|
3459
|
-
style: {
|
|
3460
|
-
animationDelay: `${-n * 200}ms`
|
|
3461
|
-
}
|
|
3462
|
-
}))
|
|
3463
|
-
}) : void 0
|
|
3464
|
-
})), ra = {
|
|
3465
|
-
bot: "left",
|
|
3466
|
-
user: "right"
|
|
3467
|
-
}, na = Ge("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)]", {
|
|
3468
|
-
variants: {
|
|
3469
|
-
variant: {
|
|
3470
|
-
info: "text-neutral-8",
|
|
3471
|
-
warning: "text-[#FFC107]",
|
|
3472
|
-
error: "text-error-9",
|
|
3473
|
-
success: "text-[#4CAF50]"
|
|
3474
|
-
}
|
|
3475
|
-
}
|
|
3476
|
-
}), sa = ({
|
|
3477
|
-
lastSentMessageFooter: e
|
|
3478
|
-
}) => {
|
|
3479
|
-
var r;
|
|
3480
|
-
const t = ((r = D.current$.value.flow) == null ? void 0 : r.data.messages) ?? [];
|
|
3481
|
-
return ce(() => {
|
|
3482
|
-
Z.scrollToEnd.smooth();
|
|
3483
|
-
}, [t.length]), c("ol", {
|
|
3484
|
-
"aria-label": "Chat messages",
|
|
3485
|
-
class: "mt-auto flex flex-col justify-end gap-2 p-2 pt-[calc(var(--header-height)+1rem)]",
|
|
3486
|
-
children: [t.map((n, i) => c(we, {
|
|
3487
|
-
children: c("li", {
|
|
3488
|
-
class: "flex",
|
|
3489
|
-
children: at(n).with({
|
|
3490
|
-
type: "system"
|
|
3491
|
-
}, (s) => c("p", {
|
|
3492
|
-
class: na({
|
|
3493
|
-
variant: s.variant
|
|
3494
|
-
}),
|
|
3495
|
-
children: s.text
|
|
3496
|
-
})).with({
|
|
3497
|
-
type: "text",
|
|
3498
|
-
author: R.union("bot", "user")
|
|
3499
|
-
}, (s) => {
|
|
3500
|
-
const o = s.author === "user" && !t.slice(i + 1).some((p) => p.type === "text" && p.author === "user"), a = i === t.length - 1, f = s.author === "bot" ? Xs(s.text) : s.text;
|
|
3501
|
-
return c(we, {
|
|
3502
|
-
children: [o ? e : null, c(Ys, {
|
|
3503
|
-
animate: a,
|
|
3504
|
-
side: ra[s.author],
|
|
3505
|
-
children: f
|
|
3506
|
-
}, i)]
|
|
3507
|
-
});
|
|
3508
|
-
}).with({
|
|
3509
|
-
type: "link"
|
|
3510
|
-
}, (s) => c(ea, {
|
|
3511
|
-
message: s
|
|
3512
|
-
})).with({
|
|
3513
|
-
type: "image"
|
|
3514
|
-
}, (s) => c("img", {
|
|
3515
|
-
class: "shadow-surface-md w-full max-w-[min(100%,24rem)] rounded-2xl",
|
|
3516
|
-
src: s.url,
|
|
3517
|
-
style: {
|
|
3518
|
-
aspectRatio: s.width / s.height
|
|
3519
|
-
}
|
|
3520
|
-
})).with({
|
|
3521
|
-
type: "file"
|
|
3522
|
-
}, (s) => c(Un, {
|
|
3523
|
-
class: s.author === "bot" ? void 0 : "ml-auto",
|
|
3524
|
-
file: {
|
|
3525
|
-
name: s.fileName,
|
|
3526
|
-
sizeKb: s.fileSizeKb
|
|
3527
|
-
}
|
|
3528
|
-
})).with({
|
|
3529
|
-
type: "loading"
|
|
3530
|
-
}, (s) => {
|
|
3531
|
-
const o = t[t.length - 1];
|
|
3532
|
-
return !(s === o) || Z.isBotTyping$.value ? null : c("div", {
|
|
3533
|
-
class: "flex flex-grow flex-col items-center justify-center",
|
|
3534
|
-
children: c(Zr, {
|
|
3535
|
-
class: "text-neutral-6 h-8 w-8"
|
|
3536
|
-
})
|
|
3537
|
-
});
|
|
3538
|
-
}).exhaustive()
|
|
3539
|
-
})
|
|
3540
|
-
}, i)), c(ta, {}, "typing")]
|
|
3541
|
-
});
|
|
3542
|
-
}, ua = ({
|
|
3543
|
-
logger: e,
|
|
3544
|
-
apiClient: t,
|
|
3545
|
-
analytics: r,
|
|
3546
|
-
talentBankClient: n
|
|
3547
|
-
}) => {
|
|
3548
|
-
const {
|
|
3549
|
-
flow: i
|
|
3550
|
-
} = D.current$.value;
|
|
3551
|
-
me(i, "Flow is required to exist to show chatbot body");
|
|
3552
|
-
const s = D.viewState$.value, {
|
|
3553
|
-
chatRef: o,
|
|
3554
|
-
chatService: a
|
|
3555
|
-
} = Xr(), {
|
|
3556
|
-
t: f
|
|
3557
|
-
} = Q(), [p, C] = se();
|
|
3558
|
-
return xe(() => {
|
|
3559
|
-
s === "maximised" && Z.scrollToEnd.instant();
|
|
3560
|
-
}, [s]), xe(() => {
|
|
3561
|
-
var x, _;
|
|
3562
|
-
const {
|
|
3563
|
-
state: v,
|
|
3564
|
-
flow: h
|
|
3565
|
-
} = D.current$.peek();
|
|
3566
|
-
if (v !== "loaded")
|
|
3567
|
-
throw new Error(f("invalid_state"));
|
|
3568
|
-
let y = h.data.nodeHistory.at(-1);
|
|
3569
|
-
if (Z.scrollToEnd.instant(), D.setInput(void 0), h.data.isFinished)
|
|
3570
|
-
return;
|
|
3571
|
-
y === void 0 ? (y = Yt(i.nodes).id, D.setCurrentNodeId(y), r.log({
|
|
3572
|
-
event: "FLOW_START",
|
|
3573
|
-
properties: {
|
|
3574
|
-
flow_id: i.id,
|
|
3575
|
-
flow_version: i.version,
|
|
3576
|
-
flow_session_id: h.data.flowSessionId,
|
|
3577
|
-
flow_build: i.build,
|
|
3578
|
-
job: i.job
|
|
3579
|
-
},
|
|
3580
|
-
customProperties: (x = i.analytics) == null ? void 0 : x.customProperties
|
|
3581
|
-
})) : D.removeMessagesSentByNodeIds([y]);
|
|
3582
|
-
const {
|
|
3583
|
-
interpret: b,
|
|
3584
|
-
abort: E,
|
|
3585
|
-
undo: V
|
|
3586
|
-
} = nn({
|
|
3587
|
-
context: i.context,
|
|
3588
|
-
analytics: {
|
|
3589
|
-
service: r,
|
|
3590
|
-
customProperties: (_ = i.analytics) == null ? void 0 : _.customProperties
|
|
3591
|
-
},
|
|
3592
|
-
apiClient: t,
|
|
3593
|
-
logger: e,
|
|
3594
|
-
talentBankClient: n,
|
|
3595
|
-
flow: i,
|
|
3596
|
-
chatService: a,
|
|
3597
|
-
t: f,
|
|
3598
|
-
// We need to get fresh submissions, that’s why we call `peek` here.
|
|
3599
|
-
getSubmissions: () => {
|
|
3600
|
-
var I;
|
|
3601
|
-
return (I = D.current$.peek().flow) == null ? void 0 : I.data.submissions;
|
|
3602
|
-
},
|
|
3603
|
-
onInterpret: (I) => D.setCurrentNodeId(I.id),
|
|
3604
|
-
onFlowEnd: async () => {
|
|
3605
|
-
var O;
|
|
3606
|
-
D.markAsFinished();
|
|
3607
|
-
const I = D.current$.peek().flow;
|
|
3608
|
-
me(I), r.log({
|
|
3609
|
-
event: "FLOW_END",
|
|
3610
|
-
properties: {
|
|
3611
|
-
flow_id: i.id,
|
|
3612
|
-
flow_version: i.version,
|
|
3613
|
-
flow_session_id: I.data.flowSessionId,
|
|
3614
|
-
flow_build: i.build,
|
|
3615
|
-
job: i.job
|
|
3616
|
-
},
|
|
3617
|
-
customProperties: (O = i.analytics) == null ? void 0 : O.customProperties
|
|
3618
|
-
});
|
|
3619
|
-
}
|
|
3620
|
-
});
|
|
3621
|
-
return C(() => V), b(y), E;
|
|
3622
|
-
}, [r, t, a, e, i, n, f]), c(we, {
|
|
3623
|
-
children: [c("div", {
|
|
3624
|
-
ref: o,
|
|
3625
|
-
className: "hide-scrollbars relative flex w-full max-w-full flex-grow flex-col overflow-y-scroll",
|
|
3626
|
-
style: {
|
|
3627
|
-
WebkitOverflowScrolling: "touch",
|
|
3628
|
-
paddingBottom: D.inputHeight$.value
|
|
3629
|
-
},
|
|
3630
|
-
children: c(sa, {
|
|
3631
|
-
lastSentMessageFooter: i.data.isFinished || !p ? null : c(ia, {
|
|
3632
|
-
undoFn: p
|
|
3633
|
-
})
|
|
3634
|
-
})
|
|
3635
|
-
}), c(Bs, {
|
|
3636
|
-
logger: e
|
|
3637
|
-
})]
|
|
3638
|
-
});
|
|
3639
|
-
}, aa = (e) => e.type === "identify" ? [] : "key" in e.data && e.data.key ? [e.data.key] : "keys" in e.data ? Object.values(e.data.keys).filter((t) => typeof t == "string") : [], ia = ({
|
|
3640
|
-
undoFn: e
|
|
3641
|
-
}) => {
|
|
3642
|
-
const {
|
|
3643
|
-
t
|
|
3644
|
-
} = Q();
|
|
3645
|
-
return c(Qr, {
|
|
3646
|
-
onClick: async () => {
|
|
3647
|
-
const {
|
|
3648
|
-
flow: r
|
|
3649
|
-
} = D.current$.peek();
|
|
3650
|
-
me(r);
|
|
3651
|
-
const {
|
|
3652
|
-
removed: n
|
|
3653
|
-
} = e(r.data.nodeHistory), i = r.data.nodeHistory.splice(-n);
|
|
3654
|
-
i.length !== 0 && (D.removeMessagesSentByNodeIds(i), D.setInput(void 0), i.pop(), i.map((s) => r.nodes.find((o) => o.id === s)).filter(Boolean).flatMap(aa).forEach((s) => delete r.data.submissions[s]), D.current$.value = {
|
|
3655
|
-
...D.current$.value
|
|
3656
|
-
});
|
|
3657
|
-
},
|
|
3658
|
-
children: [c("title", {
|
|
3659
|
-
children: t("undo")
|
|
3660
|
-
}), c("path", {
|
|
3661
|
-
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"
|
|
3662
|
-
})]
|
|
3663
|
-
});
|
|
3664
|
-
};
|
|
3665
|
-
export {
|
|
3666
|
-
ua as ChatbotBody
|
|
3667
|
-
};
|