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