@gengage/assistant-fe 0.2.8 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/assistant-fe.css +2 -1
  2. package/dist/chat-C1_48HTk.js +4867 -0
  3. package/dist/chat-C1_48HTk.js.map +1 -0
  4. package/dist/chat-DJpVCmRT.cjs +13 -0
  5. package/dist/chat-DJpVCmRT.cjs.map +1 -0
  6. package/dist/chat.cjs +1 -2
  7. package/dist/chat.iife.js +31 -31
  8. package/dist/chat.iife.js.map +1 -1
  9. package/dist/chat.js +2 -15
  10. package/dist/common--5smIEwc.js +390 -0
  11. package/dist/common--5smIEwc.js.map +1 -0
  12. package/dist/common-DTY__1sq.cjs +2 -0
  13. package/dist/common-DTY__1sq.cjs.map +1 -0
  14. package/dist/common.cjs +1 -2
  15. package/dist/common.js +5 -448
  16. package/dist/index.cjs +1 -2
  17. package/dist/index.js +7 -70
  18. package/dist/native-webview-D1v6n8kJ.cjs +2 -0
  19. package/dist/native-webview-D1v6n8kJ.cjs.map +1 -0
  20. package/dist/native-webview-DlY9mxqG.js +521 -0
  21. package/dist/native-webview-DlY9mxqG.js.map +1 -0
  22. package/dist/native.cjs +1 -2
  23. package/dist/native.iife.js +31 -31
  24. package/dist/native.iife.js.map +1 -1
  25. package/dist/native.js +2 -9
  26. package/dist/qna-C-ZboudC.cjs +2 -0
  27. package/dist/qna-C-ZboudC.cjs.map +1 -0
  28. package/dist/qna-CDfFy61x.js +442 -0
  29. package/dist/qna-CDfFy61x.js.map +1 -0
  30. package/dist/qna.cjs +1 -2
  31. package/dist/qna.css +1 -1
  32. package/dist/qna.iife.js +29 -29
  33. package/dist/qna.iife.js.map +1 -1
  34. package/dist/qna.js +2 -463
  35. package/dist/quantity-stepper-BuwCXbPt.cjs +2 -0
  36. package/dist/quantity-stepper-BuwCXbPt.cjs.map +1 -0
  37. package/dist/quantity-stepper-CTEOqVS6.js +74 -0
  38. package/dist/quantity-stepper-CTEOqVS6.js.map +1 -0
  39. package/dist/schemas-BNc2hTff.cjs +86 -0
  40. package/dist/schemas-BNc2hTff.cjs.map +1 -0
  41. package/dist/schemas-ClU0oPbf.js +4625 -0
  42. package/dist/schemas-ClU0oPbf.js.map +1 -0
  43. package/dist/simrel-B2UMdZ9p.cjs +2 -0
  44. package/dist/simrel-B2UMdZ9p.cjs.map +1 -0
  45. package/dist/simrel-BjL12luk.js +657 -0
  46. package/dist/simrel-BjL12luk.js.map +1 -0
  47. package/dist/simrel.cjs +1 -2
  48. package/dist/simrel.css +1 -1
  49. package/dist/simrel.iife.js +29 -29
  50. package/dist/simrel.iife.js.map +1 -1
  51. package/dist/simrel.js +2 -689
  52. package/package.json +13 -13
  53. package/dist/chat.cjs.map +0 -1
  54. package/dist/chat.js.map +0 -1
  55. package/dist/common.cjs.map +0 -1
  56. package/dist/common.js.map +0 -1
  57. package/dist/index-BAQXPosE.cjs +0 -2
  58. package/dist/index-BAQXPosE.cjs.map +0 -1
  59. package/dist/index-CUBMZpGs.js +0 -5111
  60. package/dist/index-CUBMZpGs.js.map +0 -1
  61. package/dist/index-Dco2Aw73.cjs +0 -13
  62. package/dist/index-Dco2Aw73.cjs.map +0 -1
  63. package/dist/index-DvSU2I9u.js +0 -506
  64. package/dist/index-DvSU2I9u.js.map +0 -1
  65. package/dist/index.cjs.map +0 -1
  66. package/dist/index.js.map +0 -1
  67. package/dist/native.cjs.map +0 -1
  68. package/dist/native.js.map +0 -1
  69. package/dist/qna.cjs.map +0 -1
  70. package/dist/qna.js.map +0 -1
  71. package/dist/quantity-stepper-CQWgexMO.cjs +0 -2
  72. package/dist/quantity-stepper-CQWgexMO.cjs.map +0 -1
  73. package/dist/quantity-stepper-CjY_cpgJ.js +0 -80
  74. package/dist/quantity-stepper-CjY_cpgJ.js.map +0 -1
  75. package/dist/schemas-5lXjLjwW.js +0 -4944
  76. package/dist/schemas-5lXjLjwW.js.map +0 -1
  77. package/dist/schemas-DqUVzVDf.cjs +0 -86
  78. package/dist/schemas-DqUVzVDf.cjs.map +0 -1
  79. package/dist/simrel.cjs.map +0 -1
  80. package/dist/simrel.js.map +0 -1
@@ -1,4944 +0,0 @@
1
- const qt = ({ element: e, renderElement: t }) => {
2
- if (!e.children || e.children.length === 0)
3
- return null;
4
- const n = document.createElement("div");
5
- for (const r of e.children) {
6
- const o = t(r);
7
- o && n.appendChild(o);
8
- }
9
- return n;
10
- };
11
- function ic(e) {
12
- const t = document.createElement("div");
13
- if (t.className = e.containerClassName, !e.spec.elements[e.spec.root]) return t;
14
- const r = e.unknownRenderer ?? qt, o = (s) => {
15
- const a = e.spec.elements[s];
16
- if (!a) return null;
17
- const c = e.registry[a.type];
18
- return c ? c({
19
- elementId: s,
20
- element: a,
21
- spec: e.spec,
22
- context: e.context,
23
- renderElement: o
24
- }) : r({
25
- elementId: s,
26
- element: a,
27
- spec: e.spec,
28
- context: e.context,
29
- renderElement: o
30
- });
31
- }, i = o(e.spec.root);
32
- return i && t.appendChild(i), t;
33
- }
34
- function sc(e, t) {
35
- if (!t) return e;
36
- const n = { ...e };
37
- for (const [r, o] of Object.entries(t))
38
- o && (n[r] = o);
39
- return n;
40
- }
41
- function ac(e, t) {
42
- const n = {
43
- event_name: "stream.start",
44
- account_id: e.account_id,
45
- session_id: e.session_id,
46
- correlation_id: e.correlation_id,
47
- payload: {
48
- endpoint: t.endpoint,
49
- request_id: t.request_id
50
- }
51
- };
52
- return e.view_id !== void 0 && (n.view_id = e.view_id), e.user_id !== void 0 && (n.user_id = e.user_id), t.widget !== void 0 && (n.widget = t.widget), e.page_type !== void 0 && (n.page_type = e.page_type), e.sku !== void 0 && (n.sku = e.sku), n;
53
- }
54
- function cc(e, t) {
55
- const n = {
56
- request_id: t.request_id,
57
- chunk_index: t.chunk_index
58
- };
59
- t.latency_ms !== void 0 && (n.latency_ms = t.latency_ms);
60
- const r = {
61
- event_name: "stream.chunk",
62
- account_id: e.account_id,
63
- session_id: e.session_id,
64
- correlation_id: e.correlation_id,
65
- payload: n
66
- };
67
- return e.view_id !== void 0 && (r.view_id = e.view_id), e.user_id !== void 0 && (r.user_id = e.user_id), t.widget !== void 0 && (r.widget = t.widget), e.page_type !== void 0 && (r.page_type = e.page_type), e.sku !== void 0 && (r.sku = e.sku), r;
68
- }
69
- function uc(e, t) {
70
- const n = {
71
- event_name: "stream.ui_spec",
72
- account_id: e.account_id,
73
- session_id: e.session_id,
74
- correlation_id: e.correlation_id,
75
- payload: {
76
- request_id: t.request_id,
77
- chunk_index: t.chunk_index,
78
- component_type: t.component_type
79
- }
80
- };
81
- return e.view_id !== void 0 && (n.view_id = e.view_id), e.user_id !== void 0 && (n.user_id = e.user_id), t.widget !== void 0 && (n.widget = t.widget), e.page_type !== void 0 && (n.page_type = e.page_type), e.sku !== void 0 && (n.sku = e.sku), n;
82
- }
83
- function dc(e, t) {
84
- const n = {
85
- event_name: "stream.done",
86
- account_id: e.account_id,
87
- session_id: e.session_id,
88
- correlation_id: e.correlation_id,
89
- payload: {
90
- request_id: t.request_id,
91
- latency_ms: t.latency_ms,
92
- chunk_count: t.chunk_count
93
- }
94
- };
95
- return e.view_id !== void 0 && (n.view_id = e.view_id), e.user_id !== void 0 && (n.user_id = e.user_id), t.widget !== void 0 && (n.widget = t.widget), e.page_type !== void 0 && (n.page_type = e.page_type), e.sku !== void 0 && (n.sku = e.sku), n;
96
- }
97
- function lc(e, t) {
98
- const n = {
99
- event_name: "stream.error",
100
- account_id: e.account_id,
101
- session_id: e.session_id,
102
- correlation_id: e.correlation_id,
103
- payload: {
104
- request_id: t.request_id,
105
- error_code: t.error_code,
106
- error_message: t.error_message
107
- }
108
- };
109
- return e.view_id !== void 0 && (n.view_id = e.view_id), e.user_id !== void 0 && (n.user_id = e.user_id), t.widget !== void 0 && (n.widget = t.widget), e.page_type !== void 0 && (n.page_type = e.page_type), e.sku !== void 0 && (n.sku = e.sku), n;
110
- }
111
- function fc(e, t) {
112
- const n = {
113
- model: t.model,
114
- prompt_tokens: t.prompt_tokens,
115
- completion_tokens: t.completion_tokens,
116
- total_tokens: t.total_tokens
117
- };
118
- t.provider !== void 0 && (n.provider = t.provider);
119
- const r = {
120
- event_name: "llm.usage",
121
- account_id: e.account_id,
122
- session_id: e.session_id,
123
- correlation_id: e.correlation_id,
124
- payload: n
125
- };
126
- return e.view_id !== void 0 && (r.view_id = e.view_id), e.user_id !== void 0 && (r.user_id = e.user_id), e.page_type !== void 0 && (r.page_type = e.page_type), e.sku !== void 0 && (r.sku = e.sku), r;
127
- }
128
- function pc(e, t) {
129
- const n = {
130
- event_name: "metering.increment",
131
- account_id: e.account_id,
132
- session_id: e.session_id,
133
- correlation_id: e.correlation_id,
134
- payload: {
135
- meter_key: t.meter_key,
136
- quantity: t.quantity,
137
- unit: t.unit
138
- }
139
- };
140
- return e.view_id !== void 0 && (n.view_id = e.view_id), e.user_id !== void 0 && (n.user_id = e.user_id), e.page_type !== void 0 && (n.page_type = e.page_type), e.sku !== void 0 && (n.sku = e.sku), n;
141
- }
142
- function Vt(e, t) {
143
- const n = {
144
- event_name: "metering.summary",
145
- account_id: e.account_id,
146
- session_id: e.session_id,
147
- correlation_id: e.correlation_id,
148
- payload: {
149
- meter_key: t.meter_key,
150
- quantity: t.quantity,
151
- unit: t.unit
152
- }
153
- };
154
- return e.view_id !== void 0 && (n.view_id = e.view_id), e.user_id !== void 0 && (n.user_id = e.user_id), e.page_type !== void 0 && (n.page_type = e.page_type), e.sku !== void 0 && (n.sku = e.sku), n;
155
- }
156
- function gc(e, t) {
157
- const n = {
158
- event_name: "chat.history.snapshot",
159
- account_id: e.account_id,
160
- session_id: e.session_id,
161
- correlation_id: e.correlation_id,
162
- payload: {
163
- message_count: t.message_count,
164
- history_ref: t.history_ref,
165
- redaction_level: t.redaction_level
166
- }
167
- };
168
- return e.view_id !== void 0 && (n.view_id = e.view_id), e.user_id !== void 0 && (n.user_id = e.user_id), e.page_type !== void 0 && (n.page_type = e.page_type), e.sku !== void 0 && (n.sku = e.sku), n;
169
- }
170
- function hc(e, t) {
171
- const n = {
172
- event_name: "widget.history.snapshot",
173
- account_id: e.account_id,
174
- session_id: e.session_id,
175
- correlation_id: e.correlation_id,
176
- widget: t.widget,
177
- payload: {
178
- message_count: t.message_count,
179
- history_ref: t.history_ref,
180
- redaction_level: t.redaction_level
181
- }
182
- };
183
- return e.view_id !== void 0 && (n.view_id = e.view_id), e.user_id !== void 0 && (n.user_id = e.user_id), e.page_type !== void 0 && (n.page_type = e.page_type), e.sku !== void 0 && (n.sku = e.sku), n;
184
- }
185
- function mc(e, t) {
186
- const n = {
187
- event_name: "basket.add",
188
- account_id: e.account_id,
189
- session_id: e.session_id,
190
- correlation_id: e.correlation_id,
191
- widget: t.attribution_source,
192
- payload: {
193
- attribution_source: t.attribution_source,
194
- attribution_action_id: t.attribution_action_id,
195
- cart_value: t.cart_value,
196
- currency: t.currency,
197
- line_items: t.line_items,
198
- sku: t.sku
199
- }
200
- };
201
- return e.view_id !== void 0 && (n.view_id = e.view_id), e.user_id !== void 0 && (n.user_id = e.user_id), e.page_type !== void 0 && (n.page_type = e.page_type), e.sku !== void 0 && (n.sku = e.sku), n;
202
- }
203
- function Wt(e, t) {
204
- const n = {
205
- event_name: "checkout.start",
206
- account_id: e.account_id,
207
- session_id: e.session_id,
208
- correlation_id: e.correlation_id,
209
- widget: t.attribution_source,
210
- payload: {
211
- attribution_source: t.attribution_source,
212
- attribution_action_id: t.attribution_action_id,
213
- cart_value: t.cart_value,
214
- currency: t.currency,
215
- line_items: t.line_items
216
- }
217
- };
218
- return e.view_id !== void 0 && (n.view_id = e.view_id), e.user_id !== void 0 && (n.user_id = e.user_id), e.page_type !== void 0 && (n.page_type = e.page_type), e.sku !== void 0 && (n.sku = e.sku), n;
219
- }
220
- function Gt(e, t) {
221
- const n = {
222
- event_name: "checkout.complete",
223
- account_id: e.account_id,
224
- session_id: e.session_id,
225
- correlation_id: e.correlation_id,
226
- widget: t.attribution_source,
227
- payload: {
228
- attribution_source: t.attribution_source,
229
- attribution_action_id: t.attribution_action_id,
230
- cart_value: t.cart_value,
231
- currency: t.currency,
232
- line_items: t.line_items
233
- }
234
- };
235
- return e.view_id !== void 0 && (n.view_id = e.view_id), e.user_id !== void 0 && (n.user_id = e.user_id), e.page_type !== void 0 && (n.page_type = e.page_type), e.sku !== void 0 && (n.sku = e.sku), n;
236
- }
237
- const Bt = /* @__PURE__ */ new Set([
238
- "p",
239
- "br",
240
- "a",
241
- "strong",
242
- "b",
243
- "em",
244
- "i",
245
- "u",
246
- "ul",
247
- "ol",
248
- "li",
249
- "h1",
250
- "h2",
251
- "h3",
252
- "h4",
253
- "h5",
254
- "h6",
255
- "span",
256
- "div",
257
- "table",
258
- "thead",
259
- "tbody",
260
- "tr",
261
- "th",
262
- "td",
263
- "hr",
264
- "code",
265
- "pre",
266
- "blockquote",
267
- "img",
268
- "sup",
269
- "sub"
270
- ]), Kt = /* @__PURE__ */ new Set([
271
- "script",
272
- "iframe",
273
- "object",
274
- "embed",
275
- "form",
276
- "input",
277
- "textarea",
278
- "select",
279
- "button",
280
- "style",
281
- "link",
282
- "meta",
283
- "template",
284
- "noscript"
285
- ]), Ie = {
286
- "*": /* @__PURE__ */ new Set(["class"]),
287
- a: /* @__PURE__ */ new Set(["href", "target", "rel"]),
288
- img: /* @__PURE__ */ new Set(["src", "alt", "width", "height"]),
289
- div: /* @__PURE__ */ new Set(["style"]),
290
- span: /* @__PURE__ */ new Set(["style"]),
291
- p: /* @__PURE__ */ new Set(["style"])
292
- };
293
- function Ht(e) {
294
- return /^\s*javascript\s*:/i.test(e);
295
- }
296
- const Yt = /* @__PURE__ */ new Set([
297
- "color",
298
- "background-color",
299
- "font-size",
300
- "font-weight",
301
- "font-style",
302
- "font-family",
303
- "text-align",
304
- "text-decoration",
305
- "line-height",
306
- "letter-spacing",
307
- "margin",
308
- "margin-top",
309
- "margin-right",
310
- "margin-bottom",
311
- "margin-left",
312
- "padding",
313
- "padding-top",
314
- "padding-right",
315
- "padding-bottom",
316
- "padding-left",
317
- "border",
318
- "border-top",
319
- "border-right",
320
- "border-bottom",
321
- "border-left",
322
- "border-radius",
323
- "border-color",
324
- "border-width",
325
- "border-style",
326
- "width",
327
- "max-width",
328
- "min-width",
329
- "height",
330
- "max-height",
331
- "min-height",
332
- "display",
333
- "vertical-align",
334
- "white-space",
335
- "word-break",
336
- "overflow",
337
- "opacity",
338
- "visibility",
339
- "list-style",
340
- "list-style-type",
341
- "text-transform",
342
- "text-indent",
343
- "text-overflow",
344
- "box-sizing",
345
- "flex",
346
- "flex-direction",
347
- "flex-wrap",
348
- "justify-content",
349
- "align-items",
350
- "gap"
351
- ]), Xt = /url\s*\(|expression\s*\(|javascript\s*:|\bimport\b|-moz-binding|behavior\s*:/i;
352
- function Qt(e) {
353
- const t = [];
354
- for (const n of e.split(";")) {
355
- const r = n.trim();
356
- if (!r) continue;
357
- const o = r.indexOf(":");
358
- if (o === -1) continue;
359
- const i = r.slice(0, o).trim().toLowerCase(), s = r.slice(o + 1).trim();
360
- Yt.has(i) && (Xt.test(s) || t.push(r));
361
- }
362
- return t.join("; ");
363
- }
364
- function me(e, t) {
365
- if (e.nodeType === Node.TEXT_NODE) return;
366
- if (e.nodeType !== Node.ELEMENT_NODE) {
367
- e.parentNode?.removeChild(e);
368
- return;
369
- }
370
- const n = e, r = n.tagName.toLowerCase();
371
- if (Kt.has(r)) {
372
- n.parentNode?.removeChild(n);
373
- return;
374
- }
375
- if (!Bt.has(r)) {
376
- const c = Array.from(n.childNodes);
377
- for (const u of c)
378
- t.insertBefore(u, n);
379
- t.removeChild(n);
380
- for (const u of c)
381
- me(u, t);
382
- return;
383
- }
384
- const o = Ie["*"] ?? /* @__PURE__ */ new Set(), i = Ie[r] ?? /* @__PURE__ */ new Set(), s = Array.from(n.attributes);
385
- for (const c of s) {
386
- const u = c.name.toLowerCase();
387
- if (!o.has(u) && !i.has(u)) {
388
- n.removeAttribute(c.name);
389
- continue;
390
- }
391
- if (Ht(c.value)) {
392
- n.removeAttribute(c.name);
393
- continue;
394
- }
395
- if (u === "style") {
396
- const l = Qt(c.value);
397
- l ? n.setAttribute("style", l) : n.removeAttribute("style");
398
- continue;
399
- }
400
- }
401
- if (r === "a") {
402
- const c = n.getAttribute("href");
403
- if (c !== null) {
404
- const u = c.trim().toLowerCase();
405
- !u.startsWith("http://") && !u.startsWith("https://") && !u.startsWith("mailto:") && n.removeAttribute("href");
406
- }
407
- n.setAttribute("target", "_blank"), n.setAttribute("rel", "noopener noreferrer");
408
- }
409
- if (r === "img") {
410
- const c = n.getAttribute("src");
411
- c !== null && (c.trim().toLowerCase().startsWith("https://") || n.removeAttribute("src"));
412
- }
413
- const a = Array.from(n.childNodes);
414
- for (const c of a)
415
- me(c, n);
416
- }
417
- const st = ["http:", "https:"];
418
- function _c(e) {
419
- try {
420
- return st.includes(new URL(e).protocol);
421
- } catch {
422
- return !1;
423
- }
424
- }
425
- function at(e) {
426
- if (e.startsWith("/") && !e.startsWith("//")) return !0;
427
- try {
428
- const t = new URL(e);
429
- return st.includes(t.protocol);
430
- } catch {
431
- return !1;
432
- }
433
- }
434
- function yc(e, t, n) {
435
- (t === "href" || t === "src") && !at(n) || e.setAttribute(t, n);
436
- }
437
- function vc(e) {
438
- if (!e) return "";
439
- const n = new DOMParser().parseFromString(e, "text/html").body, r = Array.from(n.childNodes);
440
- for (const o of r)
441
- me(o, n);
442
- return n.innerHTML;
443
- }
444
- function wc(e, t) {
445
- window.dispatchEvent(new CustomEvent(e, { detail: t, bubbles: !1 }));
446
- }
447
- function te(e, t) {
448
- const n = (r) => {
449
- t(r.detail);
450
- };
451
- return window.addEventListener(e, n), () => window.removeEventListener(e, n);
452
- }
453
- function en(e) {
454
- if (e.type !== "user_message" && e.type !== "inputText") return null;
455
- if (typeof e.payload == "string" && e.payload.trim().length > 0)
456
- return e.payload.trim();
457
- if (typeof e.payload == "object" && e.payload !== null) {
458
- const t = e.payload;
459
- if (typeof t.text == "string") {
460
- const n = t.text.trim();
461
- if (n.length > 0) return n;
462
- }
463
- }
464
- return typeof e.title == "string" && e.title.trim().length > 0 ? e.title.trim() : null;
465
- }
466
- function bc(e) {
467
- let t = !1;
468
- const n = [];
469
- let r = 0, o = null, i = 0;
470
- const s = 100, a = 5e3;
471
- function c() {
472
- return window.gengage?.chat ?? null;
473
- }
474
- function u() {
475
- t || (console.warn(
476
- "[gengage] QNA tried to open chat, but chat widget is not initialized. Ensure GengageChat is initialized before calling wireQNAToChat()."
477
- ), t = !0), e?.onChatUnavailable?.();
478
- }
479
- function l(m, b) {
480
- const Z = en(b);
481
- if (Z && m.sendMessage) {
482
- m.open?.(), m.sendMessage(Z);
483
- return;
484
- }
485
- m.openWithAction?.(b);
486
- }
487
- function f() {
488
- o !== null && (window.clearInterval(o), o = null);
489
- }
490
- function p() {
491
- const m = c();
492
- if (!m) return !1;
493
- if (r > 0 && (m.open?.(), r = 0), n.length > 0) {
494
- const b = n.splice(0, n.length);
495
- for (const Z of b)
496
- l(m, Z);
497
- }
498
- return f(), !0;
499
- }
500
- function g() {
501
- o === null && (i = Date.now(), o = window.setInterval(() => {
502
- p() || Date.now() - i >= a && (n.length = 0, r = 0, f());
503
- }, s));
504
- }
505
- const y = te("gengage:qna:action", (m) => {
506
- const b = c();
507
- if (b) {
508
- l(b, m);
509
- return;
510
- }
511
- u(), n.length >= 20 && n.shift(), n.push(m), g();
512
- }), _ = te("gengage:qna:open-chat", () => {
513
- const m = c();
514
- if (m) {
515
- m.open?.();
516
- return;
517
- }
518
- u(), r += 1, g();
519
- });
520
- return () => {
521
- y(), _(), n.length = 0, r = 0, f();
522
- };
523
- }
524
- function kc() {
525
- return te("gengage:similar:product-click", ({ sku: e, url: t, sessionId: n }) => {
526
- n && window.gengage?.chat?.saveSession(n, e), at(t) && (window.location.href = t);
527
- });
528
- }
529
- function tn() {
530
- const t = window.__gengageSessionId ?? sessionStorage.getItem("gengage_session_id") ?? null ?? crypto.randomUUID();
531
- return window.__gengageSessionId = t, sessionStorage.setItem("gengage_session_id", t), window.gengage || (window.gengage = {}), window.gengage.sessionId = t, t;
532
- }
533
- function zc() {
534
- return window.gengage?.pageContext ?? null;
535
- }
536
- function Sc(e) {
537
- window.gengage || (window.gengage = {}), window.gengage.pageContext = {
538
- pageType: "other",
539
- ...window.gengage.pageContext,
540
- ...e
541
- }, window.dispatchEvent(new CustomEvent("gengage:context:update", { detail: e }));
542
- }
543
- function nn(e) {
544
- return {
545
- sessionId: e?.sessionId ?? tn(),
546
- ...e
547
- };
548
- }
549
- const Ae = {
550
- "--gengage-chat-offset": "20px",
551
- "--gengage-chat-launcher-size": "56px",
552
- "--gengage-chat-width": "400px",
553
- "--gengage-chat-shell-radius": "1rem",
554
- "--gengage-chat-header-height": "60px",
555
- "--gengage-chat-conversation-width": "396px",
556
- "--gengage-chat-panel-min-width": "320px",
557
- "--gengage-chat-panel-max-width": "860px",
558
- "--gengage-chat-input-height": "48px",
559
- "--gengage-qna-pill-radius": "999px",
560
- "--gengage-qna-input-radius": "0.75rem",
561
- "--gengage-simrel-card-radius": "0.75rem"
562
- };
563
- function rn(e) {
564
- return e ? { ...Ae, ...e } : { ...Ae };
565
- }
566
- const D = "gengage-global-toast-root", Pe = "gengage-global-toast-style", be = "gengage-global-toast-root--visible", on = 4200, sn = 1500, an = 15e3;
567
- let Ne = !1, J = null;
568
- function $c(e) {
569
- return typeof e == "string" && e.toLowerCase().startsWith("tr") ? "Bağlantı sorunu oluştu. Lütfen tekrar deneyin." : "Connection issue. Please try again.";
570
- }
571
- function cn() {
572
- Ne || typeof window > "u" || typeof document > "u" || (Ne = !0, te("gengage:global:error", (e) => {
573
- un(e);
574
- }));
575
- }
576
- function un(e) {
577
- if (typeof document > "u") return;
578
- const t = e.message.trim();
579
- if (!t) return;
580
- gn();
581
- const n = fn();
582
- n.innerHTML = "";
583
- const r = document.createElement("section");
584
- r.className = "gengage-global-toast gengage-global-toast--error", r.setAttribute("role", "status"), r.setAttribute("aria-live", "polite");
585
- const o = document.createElement("div");
586
- o.className = "gengage-global-toast-title", o.textContent = ln(e.source);
587
- const i = document.createElement("div");
588
- i.className = "gengage-global-toast-message", i.textContent = t, r.appendChild(o), r.appendChild(i), n.appendChild(r), n.classList.add(be), J && (clearTimeout(J), J = null), J = setTimeout(() => {
589
- dn();
590
- }, pn(e.durationMs));
591
- }
592
- function dn() {
593
- if (typeof document > "u") return;
594
- const e = document.getElementById(D);
595
- e && (e.classList.remove(be), e.innerHTML = "", J && (clearTimeout(J), J = null));
596
- }
597
- function ln(e) {
598
- switch (e) {
599
- case "chat":
600
- return "Chat warning";
601
- case "qna":
602
- return "QnA warning";
603
- case "simrel":
604
- return "Widget warning";
605
- default:
606
- return "Connection warning";
607
- }
608
- }
609
- function fn() {
610
- const e = document.getElementById(D);
611
- if (e instanceof HTMLElement) return e;
612
- const t = document.createElement("div");
613
- return t.id = D, t.className = "gengage-global-toast-root", document.body.appendChild(t), t;
614
- }
615
- function pn(e) {
616
- return typeof e != "number" || !Number.isFinite(e) ? on : Math.min(an, Math.max(sn, Math.round(e)));
617
- }
618
- function gn() {
619
- if (document.getElementById(Pe)) return;
620
- const e = document.createElement("style");
621
- e.id = Pe, e.textContent = `
622
- #${D} {
623
- position: fixed;
624
- top: 16px;
625
- right: 16px;
626
- z-index: 2147483646;
627
- pointer-events: none;
628
- }
629
- #${D}.${be} {
630
- pointer-events: auto;
631
- }
632
- #${D} .gengage-global-toast {
633
- min-width: 260px;
634
- max-width: min(92vw, 420px);
635
- border-radius: 12px;
636
- border: 1px solid #f5c2c7;
637
- border-left: 4px solid #d93025;
638
- background: #fff9f9;
639
- color: #4a1f21;
640
- box-shadow: 0 10px 30px rgba(38, 18, 18, 0.18);
641
- padding: 10px 12px;
642
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
643
- font-size: 13px;
644
- line-height: 1.4;
645
- animation: gengage-global-toast-in 180ms ease-out forwards;
646
- }
647
- #${D} .gengage-global-toast-title {
648
- margin: 0 0 4px;
649
- font-size: 12px;
650
- font-weight: 700;
651
- }
652
- #${D} .gengage-global-toast-message {
653
- margin: 0;
654
- font-weight: 500;
655
- }
656
- @keyframes gengage-global-toast-in {
657
- from {
658
- opacity: 0;
659
- transform: translateY(-8px);
660
- }
661
- to {
662
- opacity: 1;
663
- transform: translateY(0);
664
- }
665
- }
666
- `, document.head.appendChild(e);
667
- }
668
- let Y = null;
669
- function hn() {
670
- if (Y !== null) return Y;
671
- try {
672
- Y = localStorage.getItem("gengage:debug") === "1";
673
- } catch {
674
- Y = !1;
675
- }
676
- return Y;
677
- }
678
- function _e(e, t, n) {
679
- if (!hn()) return;
680
- const r = [`[gengage:${e}]`, t];
681
- n !== void 0 && r.push(n), console.debug(...r);
682
- }
683
- class Ec {
684
- constructor() {
685
- this.isVisible = !1, this.isInitialised = !1, this._handlers = /* @__PURE__ */ new Map(), this._cleanups = [], this._ownsRoot = !1, this._destroying = !1;
686
- }
687
- // ---------------------------------------------------------------------------
688
- // Public API
689
- // ---------------------------------------------------------------------------
690
- async init(t) {
691
- if (this.isInitialised) {
692
- console.warn("[gengage] Widget already initialised. Call update() instead.");
693
- return;
694
- }
695
- const n = rn(t.theme);
696
- this.config = {
697
- ...t,
698
- theme: n,
699
- session: nn(t.session)
700
- }, this.root = this._resolveMount(t.mountTarget), this._applyTheme(n), cn();
701
- const r = te("gengage:context:update", (o) => this.update(o));
702
- this._cleanups.push(r), _e("lifecycle", `${this.constructor.name}.init`, {
703
- accountId: t.accountId,
704
- sku: t.pageContext?.sku
705
- });
706
- try {
707
- await this.onInit(this.config);
708
- } catch (o) {
709
- throw this.destroy(), o;
710
- }
711
- this._destroying || (this.isInitialised = !0, _e("lifecycle", `${this.constructor.name} ready`), this.emit("ready"));
712
- }
713
- update(t) {
714
- this.isInitialised && (this.config.pageContext ? this.config = {
715
- ...this.config,
716
- pageContext: { ...this.config.pageContext, ...t }
717
- } : t.pageType !== void 0 && (this.config = { ...this.config, pageContext: t }), this.onUpdate(t), this.emit("context-update", this.config.pageContext));
718
- }
719
- show() {
720
- this.isVisible || (this.isVisible = !0, this.root.style.display = "", this.onShow(), this.emit("show"));
721
- }
722
- hide() {
723
- this.isVisible && (this.isVisible = !1, this.root.style.display = "none", this.onHide(), this.emit("hide"));
724
- }
725
- destroy() {
726
- this._destroying || (this._destroying = !0, this.emit("destroy"), this._cleanups.forEach((t) => t()), this._cleanups.length = 0, this._handlers.clear(), this.onDestroy(), this.config.analyticsClient?.destroy(), this._ownsRoot ? this.root.remove() : this.root.innerHTML = "", this.isInitialised = !1);
727
- }
728
- on(t, n) {
729
- return this._handlers.has(t) || this._handlers.set(t, /* @__PURE__ */ new Set()), this._handlers.get(t).add(n), () => this._handlers.get(t)?.delete(n);
730
- }
731
- /** Track a checkout start event. Called by host page to attribute checkout to widget interaction. */
732
- trackCheckout(t, n) {
733
- const r = t === "start" ? Wt : Gt;
734
- this.track(r(this.analyticsContext(), n));
735
- }
736
- /** Track a metering summary event. Called by host page for session-level aggregation. */
737
- flushMeteringSummary(t) {
738
- this.track(Vt(this.analyticsContext(), t));
739
- }
740
- // ---------------------------------------------------------------------------
741
- // Protected helpers
742
- // ---------------------------------------------------------------------------
743
- /** Emit a widget event to all registered handlers. */
744
- emit(t, ...n) {
745
- this._handlers.get(t)?.forEach((r) => r(...n));
746
- }
747
- /** Register a cleanup function to run on destroy(). */
748
- addCleanup(t) {
749
- this._cleanups.push(t);
750
- }
751
- /** Track an analytics event (no-op if analyticsClient is not configured). */
752
- track(t) {
753
- this.config.analyticsClient?.track(t);
754
- }
755
- /** Build the shared analytics context from widget config. */
756
- analyticsContext() {
757
- const t = {
758
- account_id: this.config.accountId,
759
- session_id: this.config.session?.sessionId ?? "",
760
- correlation_id: this.config.session?.sessionId ?? ""
761
- };
762
- return this.config.session?.viewId !== void 0 && (t.view_id = this.config.session.viewId), this.config.session?.userId !== void 0 && (t.user_id = this.config.session.userId), this.config.pageContext?.pageType !== void 0 && (t.page_type = this.config.pageContext.pageType), this.config.pageContext?.sku !== void 0 && (t.sku = this.config.pageContext.sku), this.config.session?.abTestVariant !== void 0 && (t.ab_test_variant = this.config.session.abTestVariant), this.config.session?.abTestExperimentId !== void 0 && (t.ab_test_experiment_id = this.config.session.abTestExperimentId), t;
763
- }
764
- // ---------------------------------------------------------------------------
765
- // Private helpers
766
- // ---------------------------------------------------------------------------
767
- _resolveMount(t) {
768
- if (t instanceof HTMLElement) return t;
769
- if (typeof t == "string") {
770
- const r = document.querySelector(t);
771
- if (!r) throw new Error(`[gengage] Mount target not found: "${t}"`);
772
- return r;
773
- }
774
- const n = document.createElement("div");
775
- return n.dataset.gengageWidget = this.constructor.name.toLowerCase(), document.body.appendChild(n), this._ownsRoot = !0, n;
776
- }
777
- _applyTheme(t) {
778
- if (t) {
779
- for (const [n, r] of Object.entries(t))
780
- if (r !== void 0) {
781
- const o = n.startsWith("--") ? n : `--gengage-${mn(n)}`;
782
- this.root.style.setProperty(o, r);
783
- }
784
- }
785
- }
786
- }
787
- function mn(e) {
788
- return e.replace(/([A-Z])/g, "-$1").toLowerCase();
789
- }
790
- function Ce(e) {
791
- return typeof e == "object" && e !== null && typeof e.type == "string";
792
- }
793
- function _n(e) {
794
- const t = [];
795
- let n = 0, r = !1, o = !1, i = 0;
796
- for (let s = 0; s < e.length; s++) {
797
- const a = e[s];
798
- if (o) {
799
- o = !1;
800
- continue;
801
- }
802
- if (a === "\\" && r) {
803
- o = !0;
804
- continue;
805
- }
806
- if (a === '"') {
807
- r = !r;
808
- continue;
809
- }
810
- r || (a === "{" && n++, a === "}" && (n--, n === 0 && (t.push(e.slice(i, s + 1)), i = s + 1)));
811
- }
812
- return t.length > 0 ? t : [e];
813
- }
814
- function Re(e, t) {
815
- const n = e.trim();
816
- if (!n || n.startsWith(":")) return !1;
817
- const r = n.startsWith("data: ") ? n.slice(6) : n;
818
- if (r === "[DONE]")
819
- return t.onDone?.(), !0;
820
- try {
821
- const o = JSON.parse(r);
822
- return Ce(o) ? (_e("stream", `event: ${o.type}`, o), t.onEvent(o), o.type === "done" ? (t.onDone?.(), !0) : !1) : !1;
823
- } catch {
824
- const o = _n(r);
825
- if (o.length > 1) {
826
- for (const i of o)
827
- try {
828
- const s = JSON.parse(i);
829
- if (!Ce(s)) continue;
830
- if (t.onEvent(s), s.type === "done")
831
- return t.onDone?.(), !0;
832
- } catch {
833
- }
834
- return !1;
835
- }
836
- return !1;
837
- }
838
- }
839
- async function yn(e, t) {
840
- if (!e.ok) {
841
- t.onError?.(new Error(`HTTP ${e.status}: ${e.statusText}`));
842
- return;
843
- }
844
- if (!e.body) {
845
- t.onError?.(new Error("Response body is null — streaming not supported"));
846
- return;
847
- }
848
- const n = e.body.getReader(), r = new TextDecoder("utf-8");
849
- let o = "";
850
- const i = t.idleTimeoutMs ?? 6e4, s = /* @__PURE__ */ Symbol("idle-timeout");
851
- let a = !1;
852
- try {
853
- for (; ; ) {
854
- const c = n.read();
855
- let u;
856
- const l = await (i > 0 ? Promise.race([
857
- c.then((y) => (clearTimeout(u), y)),
858
- new Promise((y) => {
859
- u = setTimeout(() => y(s), i);
860
- })
861
- ]) : c);
862
- if (l === s) {
863
- a = !0, await n.cancel();
864
- break;
865
- }
866
- const { done: f, value: p } = l;
867
- if (f) break;
868
- o += r.decode(p, { stream: !0 });
869
- const g = o.split(`
870
- `);
871
- o = g.pop() ?? "";
872
- for (const y of g)
873
- if (Re(y, t)) return;
874
- }
875
- if (o.trim() && Re(o, t))
876
- return;
877
- } catch (c) {
878
- if (c instanceof DOMException && c.name === "AbortError") return;
879
- t.onError?.(c instanceof Error ? c : new Error(String(c)));
880
- } finally {
881
- a || n.releaseLock();
882
- }
883
- t.onDone?.();
884
- }
885
- function Tc(e, t, n) {
886
- const r = new AbortController(), o = n.signal ? vn([n.signal, r.signal]) : r.signal;
887
- return fetch(e, {
888
- method: "POST",
889
- headers: {
890
- "Content-Type": "application/json",
891
- ...n.headers
892
- },
893
- body: JSON.stringify(t),
894
- signal: o
895
- }).then((i) => yn(i, { ...n, signal: o })).catch((i) => {
896
- i instanceof DOMException && i.name === "AbortError" || n.onError?.(i instanceof Error ? i : new Error(String(i)));
897
- }), r;
898
- }
899
- function vn(e) {
900
- const t = new AbortController(), n = [];
901
- for (const r of e) {
902
- if (r.aborted)
903
- return t.abort(r.reason), t.signal;
904
- const o = () => t.abort(r.reason);
905
- r.addEventListener("abort", o, { once: !0 }), n.push(() => r.removeEventListener("abort", o));
906
- }
907
- return t.signal.addEventListener(
908
- "abort",
909
- () => {
910
- for (const r of n) r();
911
- },
912
- { once: !0 }
913
- ), t.signal;
914
- }
915
- const je = 3, wn = (e, t) => {
916
- const n = e.replace(/\s+/g, " ").trim().replace(/^[,.;:!?•-]+|[,.;:!?•-]+$/g, "");
917
- if (!n)
918
- return "";
919
- const r = t?.stripLeadingStopWords ? n.replace(/^(?:daha|için)\s+/i, "").trim() : n;
920
- return r ? r.split(/\s+/).slice(0, 3).join(" ").trim() : "";
921
- }, pe = (e, t) => e ? e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map((n) => wn(n, t)).filter(Boolean) : [];
922
- function bn(e) {
923
- const t = (e.display_keywords ?? []).flatMap(
924
- (o) => pe(o, { stripLeadingStopWords: !0 })
925
- ), n = t.filter((o, i) => t.indexOf(o) === i);
926
- if (n.length > 0)
927
- return n.slice(0, je);
928
- const r = [
929
- ...pe(e.chosen_attribute, { stripLeadingStopWords: !0 }),
930
- ...pe(e.short_name)
931
- ];
932
- return r.filter((o, i) => r.indexOf(o) === i).slice(0, je);
933
- }
934
- function kn(e) {
935
- return bn(e).join(" • ");
936
- }
937
- function Zc(e) {
938
- if (typeof e.type != "string") return null;
939
- if (zn(e))
940
- return e;
941
- const n = e;
942
- switch (n.type) {
943
- case "outputText":
944
- return Sn(n);
945
- case "suggestedActions":
946
- return $n(n);
947
- case "productList":
948
- return En(n);
949
- case "productDetails":
950
- return Tn(n);
951
- case "productDetailsSimilars":
952
- return Zn(n);
953
- case "comparisonTable":
954
- return On(n);
955
- case "context":
956
- return Nn(n);
957
- case "chatStreamEnd":
958
- return Cn();
959
- case "loading":
960
- return Rn(n);
961
- case "panelLoading":
962
- return jn(n);
963
- case "similarLoading":
964
- return Dn(n);
965
- case "redirect":
966
- return Ln(n);
967
- case "error":
968
- return Un(n);
969
- case "dummy":
970
- return Mn();
971
- case "launcherAction":
972
- return xn(n);
973
- case "text":
974
- return ke(n);
975
- case "productItem":
976
- return Fn(n);
977
- case "text_image":
978
- return ct(n);
979
- case "quick_qna":
980
- return ut(n);
981
- case "reviewHighlights":
982
- return Jn(n);
983
- case "aiProductSuggestions":
984
- return Wn(n);
985
- case "aiProductGroupings":
986
- return Gn(n);
987
- case "aiSuggestedSearches":
988
- return Bn(n);
989
- case "prosAndCons":
990
- return qn(n);
991
- case "getGroundingReview":
992
- return Kn(n);
993
- case "voice":
994
- return Yn(n);
995
- case "visitorDataResponse":
996
- return Vn(n);
997
- case "productListPreview":
998
- return Hn();
999
- case "groupList":
1000
- return Xn(n);
1001
- case "formGetInfo":
1002
- case "formTestDrive":
1003
- case "formServiceRequest":
1004
- case "launchFormPage":
1005
- return Qn(n);
1006
- case "launcherContent":
1007
- return tr(n);
1008
- case "handoff":
1009
- return er(n);
1010
- default:
1011
- return null;
1012
- }
1013
- }
1014
- function zn(e) {
1015
- const t = e.type;
1016
- if (typeof t != "string") return !1;
1017
- switch (t) {
1018
- case "metadata":
1019
- return typeof e.sessionId == "string" && typeof e.model == "string";
1020
- case "text_chunk":
1021
- return typeof e.content == "string";
1022
- case "ui_spec": {
1023
- const n = e.widget;
1024
- if (n !== "chat" && n !== "qna" && n !== "simrel") return !1;
1025
- const r = j(e.spec);
1026
- return r ? typeof r.root == "string" && j(r.elements) !== null : !1;
1027
- }
1028
- case "action": {
1029
- const n = j(e.action);
1030
- return n !== null && typeof n.kind == "string";
1031
- }
1032
- case "error":
1033
- return typeof e.code == "string" && typeof e.message == "string";
1034
- case "done":
1035
- return !0;
1036
- default:
1037
- return !1;
1038
- }
1039
- }
1040
- function Sn(e) {
1041
- const t = w(e.payload.text, e.payload.plain_text) ?? "", n = w(e.payload.plain_text, e.payload.text) ?? t;
1042
- if (e.payload.is_error)
1043
- return {
1044
- type: "error",
1045
- code: "BACKEND_ERROR",
1046
- message: n || "Backend returned an error"
1047
- };
1048
- const r = {
1049
- type: "text_chunk",
1050
- content: t,
1051
- final: !0
1052
- }, o = e.payload.product_mentions;
1053
- Array.isArray(o) && o.length > 0 && (r.productMentions = o.filter(
1054
- (a) => typeof a == "object" && a !== null && typeof a.sku == "string" && typeof a.short_name == "string"
1055
- ));
1056
- const i = e.payload.sku_to_product_item;
1057
- i && typeof i == "object" && !Array.isArray(i) && (r.skuToProductItem = i);
1058
- const s = e.payload.conversation_mode;
1059
- return typeof s == "string" && s && (r.conversationMode = s), r;
1060
- }
1061
- function $n(e) {
1062
- const t = (e.payload.actions ?? []).map((n) => {
1063
- const r = w(n.title) ?? "", o = R(n.requestDetails, r), i = o ? {
1064
- label: r,
1065
- action: o
1066
- } : null;
1067
- return i ? (typeof n.icon == "string" && (i.icon = n.icon), typeof n.image == "string" && (i.image = n.image), i) : null;
1068
- });
1069
- return dt(t.filter(ft), "chat");
1070
- }
1071
- function En(e) {
1072
- const t = lt(e.payload.product_list ?? [], "chat");
1073
- t.panelHint = "panel";
1074
- const n = t.spec.elements[t.spec.root];
1075
- return n && (typeof e.payload.offset == "number" && (n.props = { ...n.props, offset: e.payload.offset }), typeof e.payload.end_of_list == "boolean" && (n.props = { ...n.props, endOfList: e.payload.end_of_list }), typeof e.payload.title == "string" && (n.props = { ...n.props, panelTitle: e.payload.title })), t;
1076
- }
1077
- function Tn(e) {
1078
- const t = e.payload.productDetails;
1079
- return t ? {
1080
- type: "ui_spec",
1081
- widget: "chat",
1082
- spec: {
1083
- root: "root",
1084
- elements: {
1085
- root: {
1086
- type: "ProductDetailsPanel",
1087
- props: { product: M(t) }
1088
- }
1089
- }
1090
- },
1091
- panelHint: "panel"
1092
- } : rr("chat");
1093
- }
1094
- function Zn(e) {
1095
- const t = lt(e.payload.similarProducts ?? [], "chat"), n = t.spec.elements[t.spec.root];
1096
- return n && (n.props = { ...n.props, similarsAppend: !0 }), { ...t, panelHint: "panel" };
1097
- }
1098
- function On(e) {
1099
- const t = e.payload.multiple_product_details ?? [], n = e.payload, r = {
1100
- key_differences: n.key_differences,
1101
- recommended_choice: n.recommended_choice,
1102
- recommended_choice_sku: n.recommended_choice_sku,
1103
- special_considerations: n.special_considerations,
1104
- criteria_view: n.criteria_view,
1105
- criteria_view_short: n.criteria_view_short,
1106
- compared_field_names: n.compared_field_names,
1107
- winner_product: n.winner_product,
1108
- winner_hits: n.winner_hits,
1109
- ...e.payload.product_comparison_framework ?? {}
1110
- }, o = e.payload.table, i = e.payload.features_list, s = [];
1111
- for (const m of t) {
1112
- const b = M(m);
1113
- s.push(b);
1114
- }
1115
- const a = In(o, s, r, i);
1116
- let c;
1117
- r?.recommended_choice_sku ? c = r.recommended_choice_sku : r?.winner_product && r.winner_product.length > 0 && (c = r.winner_product[0]?.product_detail?.sku ?? r.winner_product[0]?.sku);
1118
- const u = c ? s.find((m) => m.sku === c) ?? s[0] : s[0], l = [];
1119
- if (Array.isArray(r?.key_differences))
1120
- for (const m of r.key_differences)
1121
- typeof m == "string" && l.push(m);
1122
- const f = ar(r?.special_considerations), p = r?.recommended_choice, g = r?.winner_hits, y = {};
1123
- for (const m of s) {
1124
- const b = m.sku;
1125
- b && (y[b] = {
1126
- title: m.name ?? b,
1127
- type: "launchSingleProduct",
1128
- payload: { sku: b }
1129
- });
1130
- }
1131
- const _ = {
1132
- products: s,
1133
- attributes: a,
1134
- highlights: l,
1135
- productActions: y
1136
- };
1137
- return u && (_.recommended = u), f.length > 0 && (_.specialCases = f), p && (_.recommendedText = p), g && (_.winnerHits = g), typeof r?.key_differences == "string" && (_.keyDifferencesHtml = r.key_differences), r?.special_considerations && (_.specialConsiderations = r.special_considerations), {
1138
- type: "ui_spec",
1139
- widget: "chat",
1140
- spec: {
1141
- root: "root",
1142
- elements: {
1143
- root: {
1144
- type: "ComparisonTable",
1145
- props: _
1146
- }
1147
- }
1148
- },
1149
- panelHint: "panel"
1150
- };
1151
- }
1152
- function In(e, t, n, r) {
1153
- if (!e) return [];
1154
- const o = Object.entries(e);
1155
- if (o.length === 0) return [];
1156
- const i = o[0]?.[1];
1157
- if (Array.isArray(i)) {
1158
- const p = n.criteria_view ?? n.criteria_view_short ?? {}, g = n.compared_field_names ?? Object.keys(e), y = [];
1159
- for (const _ of g) {
1160
- const m = e[_];
1161
- if (!m || !Array.isArray(m)) continue;
1162
- const b = p[_] ?? _;
1163
- y.push({ label: b, values: m.map((Z) => typeof Z == "string" ? Z : String(Z ?? "")) });
1164
- }
1165
- return y;
1166
- }
1167
- const s = e, a = t.map((p) => String(p.sku ?? "")).filter((p) => p.length > 0), c = n.criteria_view ?? n.criteria_view_short ?? {}, l = (r && r.length > 0 ? r : n.compared_field_names && n.compared_field_names.length > 0 ? n.compared_field_names : An(s)).filter(
1168
- (p) => p !== "name" && p !== "name_short" && !p.endsWith("_short")
1169
- ), f = [];
1170
- for (const p of l) {
1171
- const g = a.map((_) => {
1172
- const m = s[_];
1173
- if (!m || typeof m != "object") return "";
1174
- const b = m[`${p}_short`], Z = m[p];
1175
- return Pn(b ?? Z);
1176
- });
1177
- if (g.every((_) => _.length === 0)) continue;
1178
- const y = c[p] ?? p;
1179
- f.push({ label: y, values: g });
1180
- }
1181
- return f;
1182
- }
1183
- function An(e) {
1184
- const t = [], n = /* @__PURE__ */ new Set();
1185
- for (const r of Object.values(e))
1186
- if (!(!r || typeof r != "object"))
1187
- for (const o of Object.keys(r))
1188
- n.has(o) || (n.add(o), t.push(o));
1189
- return t;
1190
- }
1191
- function Pn(e) {
1192
- return typeof e == "string" ? e : typeof e == "number" || typeof e == "boolean" ? String(e) : "";
1193
- }
1194
- function Nn(e) {
1195
- return {
1196
- type: "metadata",
1197
- sessionId: "",
1198
- model: "",
1199
- meta: {
1200
- panel: e.payload.panel,
1201
- messages: e.payload.messages,
1202
- message_id: e.payload.message_id
1203
- }
1204
- };
1205
- }
1206
- function Cn() {
1207
- return { type: "done" };
1208
- }
1209
- function Rn(e) {
1210
- return {
1211
- type: "metadata",
1212
- sessionId: "",
1213
- model: "",
1214
- meta: {
1215
- loading: !0,
1216
- loadingText: e.payload.text,
1217
- thinkingMessages: e.payload.thinking_messages,
1218
- dynamicLoading: e.payload.is_dynamic === !0
1219
- }
1220
- };
1221
- }
1222
- function jn(e) {
1223
- return {
1224
- type: "metadata",
1225
- sessionId: "",
1226
- model: "",
1227
- meta: {
1228
- loading: !0,
1229
- panelLoading: !0,
1230
- panelPendingType: e.payload?.pending_type,
1231
- loadingText: e.payload?.text
1232
- }
1233
- };
1234
- }
1235
- function Dn(e) {
1236
- return {
1237
- type: "metadata",
1238
- sessionId: "",
1239
- model: "",
1240
- meta: {
1241
- loading: !0,
1242
- similarPanelLoading: !0,
1243
- panelPendingType: e.payload?.pending_type,
1244
- loadingText: e.payload?.text
1245
- }
1246
- };
1247
- }
1248
- function Ln(e) {
1249
- const t = w(e.payload.url);
1250
- return t ? {
1251
- type: "action",
1252
- action: {
1253
- kind: "navigate",
1254
- url: t,
1255
- newTab: e.payload.new_tab === !0
1256
- }
1257
- } : {
1258
- type: "metadata",
1259
- sessionId: "",
1260
- model: "",
1261
- meta: {
1262
- redirect: e.payload,
1263
- redirectTarget: w(e.payload.to)
1264
- }
1265
- };
1266
- }
1267
- function Un(e) {
1268
- return {
1269
- type: "error",
1270
- code: "BACKEND_ERROR",
1271
- message: w(e.payload?.text, e.payload?.message, e.payload?.error) ?? "Backend returned an error"
1272
- };
1273
- }
1274
- function Mn(e) {
1275
- return {
1276
- type: "metadata",
1277
- sessionId: "",
1278
- model: "",
1279
- meta: {
1280
- noop: !0
1281
- }
1282
- };
1283
- }
1284
- function xn(e) {
1285
- const t = e.payload ?? {};
1286
- if (Array.isArray(t.action_list)) {
1287
- const i = {
1288
- action_list: t.action_list
1289
- }, s = typeof t.type == "string" ? t.type : void 0, a = typeof t.theme == "string" ? t.theme : void 0;
1290
- return s !== void 0 && (i.type = s), a !== void 0 && (i.theme = a), ut({
1291
- payload: i
1292
- });
1293
- }
1294
- const r = j(t.action);
1295
- if (r) {
1296
- const i = {
1297
- action: r
1298
- }, s = typeof t.text == "string" ? t.text : void 0, a = typeof t.image_url == "string" ? t.image_url : void 0, c = typeof t.theme == "string" ? t.theme : void 0;
1299
- return s !== void 0 && (i.text = s), a !== void 0 && (i.image_url = a), c !== void 0 && (i.theme = c), ct({
1300
- payload: i
1301
- });
1302
- }
1303
- const o = typeof t.text == "string" ? t.text : "";
1304
- if (o) {
1305
- const i = { text: o }, s = typeof t.type == "string" ? t.type : void 0, a = typeof t.theme == "string" ? t.theme : void 0, c = j(t.payload) ?? void 0;
1306
- return s !== void 0 && (i.type = s), c !== void 0 && (i.payload = c), a !== void 0 && (i.theme = a), ke({
1307
- payload: i
1308
- });
1309
- }
1310
- return {
1311
- type: "metadata",
1312
- sessionId: "",
1313
- model: "",
1314
- meta: {
1315
- launcherAction: t
1316
- }
1317
- };
1318
- }
1319
- function ke(e) {
1320
- const t = {
1321
- text: w(e.payload.text) ?? ""
1322
- };
1323
- return typeof e.payload.theme == "string" && (t.theme = e.payload.theme), e.payload.payload !== void 0 && (t.payload = e.payload.payload), {
1324
- type: "ui_spec",
1325
- widget: "qna",
1326
- spec: {
1327
- root: "root",
1328
- elements: {
1329
- root: {
1330
- type: "QuestionHeading",
1331
- props: t
1332
- }
1333
- }
1334
- }
1335
- };
1336
- }
1337
- function Fn(e) {
1338
- return nr(e.payload, "qna");
1339
- }
1340
- function ct(e) {
1341
- const t = w(e.payload.text) ?? "", n = R(e.payload.action, t);
1342
- if (n) {
1343
- const o = {
1344
- label: t || n.title,
1345
- action: n
1346
- };
1347
- return typeof e.payload.image_url == "string" && (o.image = e.payload.image_url), typeof e.payload.theme == "string" && (o.theme = e.payload.theme), {
1348
- type: "ui_spec",
1349
- widget: "qna",
1350
- spec: {
1351
- root: "root",
1352
- elements: {
1353
- root: {
1354
- type: "ActionButton",
1355
- props: o
1356
- }
1357
- }
1358
- }
1359
- };
1360
- }
1361
- const r = {
1362
- text: t
1363
- };
1364
- return typeof e.payload.theme == "string" && (r.theme = e.payload.theme), ke({
1365
- payload: r
1366
- });
1367
- }
1368
- function ut(e) {
1369
- const t = (e.payload.action_list ?? []).map((n) => {
1370
- const r = w(n.title) ?? "", o = R(n.requestDetails, r), i = o ? {
1371
- label: r,
1372
- action: o
1373
- } : null;
1374
- return i ? (typeof n.icon == "string" && (i.icon = n.icon), typeof n.image == "string" && (i.image = n.image), i) : null;
1375
- });
1376
- return dt(t.filter(ft), "qna");
1377
- }
1378
- function Jn(e) {
1379
- const n = { reviews: (e.payload.reviews ?? []).map((r) => {
1380
- const o = {};
1381
- return typeof r.review_class == "string" && (o.review_class = r.review_class), typeof r.review_text == "string" && (o.review_text = r.review_text), (typeof r.review_rating == "string" || typeof r.review_rating == "number") && (o.review_rating = r.review_rating), typeof r.review_tag == "string" && (o.review_tag = r.review_tag), o;
1382
- }) };
1383
- return typeof e.payload.sku == "string" && (n.sku = e.payload.sku), {
1384
- type: "ui_spec",
1385
- widget: "chat",
1386
- spec: {
1387
- root: "root",
1388
- elements: {
1389
- root: {
1390
- type: "ReviewHighlights",
1391
- props: n
1392
- }
1393
- }
1394
- }
1395
- };
1396
- }
1397
- function qn(e) {
1398
- const t = {};
1399
- return Array.isArray(e.payload.pros) && (t.pros = e.payload.pros), Array.isArray(e.payload.cons) && (t.cons = e.payload.cons), typeof e.payload.product_name == "string" && (t.productName = e.payload.product_name), {
1400
- type: "ui_spec",
1401
- widget: "chat",
1402
- spec: {
1403
- root: "root",
1404
- elements: {
1405
- root: {
1406
- type: "ProsAndCons",
1407
- props: t
1408
- }
1409
- }
1410
- }
1411
- };
1412
- }
1413
- function Vn(e) {
1414
- return {
1415
- type: "metadata",
1416
- sessionId: "",
1417
- model: "",
1418
- meta: {
1419
- visitorDataResponse: e.payload
1420
- }
1421
- };
1422
- }
1423
- function Wn(e) {
1424
- const t = e.payload.product_suggestions ?? [], n = [];
1425
- for (let r = 0; r < t.length; r++) {
1426
- const o = t[r];
1427
- if (!o) continue;
1428
- const i = or(o);
1429
- if (!i) continue;
1430
- const s = { product: i }, a = R(o.requestDetails, i.name);
1431
- a && (s.action = a), typeof o.role == "string" && (s.role = o.role), typeof o.reason == "string" && (s.reason = o.reason), typeof o.review_highlight == "string" && (s.reviewHighlight = o.review_highlight), Array.isArray(o.labels) && (s.labels = o.labels), typeof o.expert_quality_score == "number" && (s.expertQualityScore = o.expert_quality_score), n.push(s);
1432
- }
1433
- return n.length === 0 ? {
1434
- type: "metadata",
1435
- sessionId: "",
1436
- model: "",
1437
- meta: {
1438
- aiProductSuggestions: e.payload.product_suggestions ?? []
1439
- }
1440
- } : {
1441
- type: "ui_spec",
1442
- widget: "chat",
1443
- spec: {
1444
- root: "root",
1445
- elements: {
1446
- root: {
1447
- type: "AITopPicks",
1448
- props: { suggestions: n }
1449
- }
1450
- }
1451
- }
1452
- };
1453
- }
1454
- function Gn(e) {
1455
- const t = e.payload.product_groupings ?? [], n = [];
1456
- for (let r = 0; r < t.length; r++) {
1457
- const o = t[r];
1458
- if (!o) continue;
1459
- const i = w(o.name) ?? "", s = o.sku && o.sku.length > 0 ? { type: "findSimilar", payload: { sku: o.sku } } : void 0, a = R(o.requestDetails ?? s, i);
1460
- if (!a) continue;
1461
- const c = { name: i, action: a };
1462
- if (Array.isArray(o.labels)) {
1463
- const u = o.labels.filter((l) => typeof l == "string");
1464
- u.length > 0 && (c.labels = u);
1465
- }
1466
- typeof o.image == "string" && (c.image = o.image), n.push(c);
1467
- }
1468
- return n.length === 0 ? {
1469
- type: "metadata",
1470
- sessionId: "",
1471
- model: "",
1472
- meta: {
1473
- aiProductGroupings: e.payload.product_groupings ?? []
1474
- }
1475
- } : {
1476
- type: "ui_spec",
1477
- widget: "chat",
1478
- spec: {
1479
- root: "root",
1480
- elements: {
1481
- root: {
1482
- type: "AIGroupingCards",
1483
- props: { entries: n }
1484
- }
1485
- }
1486
- }
1487
- };
1488
- }
1489
- function Bn(e) {
1490
- const t = e.payload.suggested_searches ?? [], n = [];
1491
- for (let r = 0; r < t.length; r++) {
1492
- const o = t[r];
1493
- if (!o) continue;
1494
- const i = w(o.short_name, o.chosen_attribute, o.detailed_user_message) ?? `Search ${r + 1}`, s = {}, a = w(o.detailed_user_message);
1495
- a && (s.text = a);
1496
- const c = j(o.requestDetails), u = j(c?.payload), l = u?.group_skus;
1497
- o.group_skus && Array.isArray(o.group_skus) ? s.group_skus = o.group_skus : Array.isArray(l) && (s.group_skus = l.filter((Z) => typeof Z == "string"));
1498
- const f = w(o.sku, o.representative_product_sku, u?.sku);
1499
- f && (s.sku = f), s.is_suggested_text = 1;
1500
- const p = { type: "inputText", payload: s }, g = R(o.requestDetails, i), y = g?.type === "findSimilar" && typeof s.text == "string" ? R(p, i) : g ?? R(p, i);
1501
- if (!y) continue;
1502
- const _ = { shortName: i, action: y }, m = w(o.detailed_user_message);
1503
- m && m !== i && (_.detailedMessage = m);
1504
- const b = kn(o);
1505
- b && b !== i && b !== (m ?? "") && (_.whyDifferent = b), typeof o.image == "string" && (_.image = o.image), n.push(_);
1506
- }
1507
- return n.length === 0 ? {
1508
- type: "metadata",
1509
- sessionId: "",
1510
- model: "",
1511
- meta: {
1512
- aiSuggestedSearches: e.payload.suggested_searches ?? []
1513
- }
1514
- } : {
1515
- type: "ui_spec",
1516
- widget: "chat",
1517
- spec: {
1518
- root: "root",
1519
- elements: {
1520
- root: {
1521
- type: "AISuggestedSearchCards",
1522
- props: { entries: n }
1523
- }
1524
- }
1525
- }
1526
- };
1527
- }
1528
- function Kn(e) {
1529
- const t = R(
1530
- e.payload.requestDetails,
1531
- w(e.payload.review_count, e.payload.text, e.payload.title) ?? "Show product reviews"
1532
- );
1533
- if (!t)
1534
- return {
1535
- type: "metadata",
1536
- sessionId: "",
1537
- model: "",
1538
- meta: {
1539
- groundingReview: e.payload
1540
- }
1541
- };
1542
- const n = { action: t };
1543
- return e.payload.title && (n.title = e.payload.title), e.payload.text && (n.text = e.payload.text), e.payload.review_count && (n.reviewCount = e.payload.review_count), {
1544
- type: "ui_spec",
1545
- widget: "chat",
1546
- spec: {
1547
- root: "root",
1548
- elements: {
1549
- root: {
1550
- type: "GroundingReviewCard",
1551
- props: n
1552
- }
1553
- }
1554
- }
1555
- };
1556
- }
1557
- function Hn() {
1558
- return {
1559
- type: "metadata",
1560
- sessionId: "",
1561
- model: "",
1562
- meta: {
1563
- analyzeAnimation: !0
1564
- }
1565
- };
1566
- }
1567
- function Yn(e) {
1568
- return {
1569
- type: "metadata",
1570
- sessionId: "",
1571
- model: "",
1572
- meta: {
1573
- voice: e.payload
1574
- }
1575
- };
1576
- }
1577
- function Xn(e) {
1578
- const t = e.payload.group_list ?? [], n = [];
1579
- for (const o of t) {
1580
- const i = o.group_name ?? "", s = (o.product_list ?? []).map(M);
1581
- n.push({ groupName: i, products: s });
1582
- }
1583
- const r = [];
1584
- for (const o of e.payload.filter_tags ?? []) {
1585
- const i = o.title ?? "";
1586
- if (!i) continue;
1587
- const s = R(o.requestDetails, i), a = { title: i };
1588
- s && (a.action = s), r.push(a);
1589
- }
1590
- return {
1591
- type: "ui_spec",
1592
- widget: "chat",
1593
- spec: {
1594
- root: "root",
1595
- elements: {
1596
- root: {
1597
- type: "CategoriesContainer",
1598
- props: { groups: n, filterTags: r }
1599
- }
1600
- }
1601
- },
1602
- panelHint: "panel"
1603
- };
1604
- }
1605
- function Qn(e) {
1606
- return {
1607
- type: "metadata",
1608
- sessionId: "",
1609
- model: "",
1610
- meta: {
1611
- formType: e.type,
1612
- formPayload: e.payload ?? {}
1613
- }
1614
- };
1615
- }
1616
- function er(e) {
1617
- const t = {};
1618
- return typeof e.payload?.summary == "string" && (t.summary = e.payload.summary), Array.isArray(e.payload?.products_discussed) && (t.products_discussed = e.payload.products_discussed), typeof e.payload?.user_sentiment == "string" && (t.user_sentiment = e.payload.user_sentiment), {
1619
- type: "ui_spec",
1620
- widget: "chat",
1621
- spec: {
1622
- root: "root",
1623
- elements: {
1624
- root: {
1625
- type: "HandoffNotice",
1626
- props: t
1627
- }
1628
- }
1629
- }
1630
- };
1631
- }
1632
- function tr(e) {
1633
- return {
1634
- type: "metadata",
1635
- sessionId: "",
1636
- model: "",
1637
- meta: {
1638
- launcherContent: e.payload ?? {}
1639
- }
1640
- };
1641
- }
1642
- function dt(e, t) {
1643
- const n = {}, r = [];
1644
- for (let o = 0; o < e.length; o++) {
1645
- const i = e[o];
1646
- if (!i) continue;
1647
- const s = `action-${o}`;
1648
- r.push(s);
1649
- const a = {
1650
- label: i.label,
1651
- action: i.action
1652
- };
1653
- i.icon !== void 0 && (a.icon = i.icon), i.image !== void 0 && (a.image = i.image), i.description !== void 0 && (a.description = i.description), n[s] = {
1654
- type: "ActionButton",
1655
- props: a
1656
- };
1657
- }
1658
- return n.root = {
1659
- type: "ActionButtons",
1660
- props: {
1661
- buttons: e.map((o) => {
1662
- const i = {
1663
- label: o.label,
1664
- action: o.action
1665
- };
1666
- return o.image !== void 0 && (i.image = o.image), o.description !== void 0 && (i.description = o.description), o.icon !== void 0 && (i.icon = o.icon), i;
1667
- })
1668
- },
1669
- children: r
1670
- }, {
1671
- type: "ui_spec",
1672
- widget: t,
1673
- spec: { root: "root", elements: n }
1674
- };
1675
- }
1676
- function lt(e, t) {
1677
- const n = {}, r = [];
1678
- for (let o = 0; o < e.length; o++) {
1679
- const i = e[o];
1680
- if (!i) continue;
1681
- const s = `product-${o}`;
1682
- r.push(s), n[s] = {
1683
- type: "ProductCard",
1684
- props: { product: M(i), index: o }
1685
- };
1686
- }
1687
- return n.root = {
1688
- type: "ProductGrid",
1689
- props: { layout: "grid" },
1690
- children: r
1691
- }, {
1692
- type: "ui_spec",
1693
- widget: t,
1694
- spec: { root: "root", elements: n }
1695
- };
1696
- }
1697
- function nr(e, t) {
1698
- return {
1699
- type: "ui_spec",
1700
- widget: t,
1701
- spec: {
1702
- root: "root",
1703
- elements: {
1704
- root: {
1705
- type: "ProductCard",
1706
- props: { product: M(e), index: 0 }
1707
- }
1708
- }
1709
- }
1710
- };
1711
- }
1712
- function rr(e) {
1713
- return {
1714
- type: "ui_spec",
1715
- widget: e,
1716
- spec: {
1717
- root: "root",
1718
- elements: {
1719
- root: {
1720
- type: "ActionButtons",
1721
- props: { buttons: [] },
1722
- children: []
1723
- }
1724
- }
1725
- }
1726
- };
1727
- }
1728
- function or(e) {
1729
- const t = w(e.sku), n = w(e.short_name), r = j(e.product_item) ?? e;
1730
- return ir(r, t, n);
1731
- }
1732
- function ir(e, t, n) {
1733
- const r = w(e.sku, t), o = w(e.name, n);
1734
- if (!r || !o) return null;
1735
- const i = {
1736
- sku: r,
1737
- name: o
1738
- }, s = w(e.brand);
1739
- s && (i.brand = s);
1740
- const a = w(e.url);
1741
- a && (i.url = a);
1742
- const c = sr(e.images);
1743
- if (c.length > 0)
1744
- i.images = c;
1745
- else {
1746
- const y = w(e.image, e.image_url, e.imageUrl);
1747
- y && (i.images = [y]);
1748
- }
1749
- const u = X(e.price_discounted);
1750
- u !== void 0 && (i.price_discounted = u);
1751
- const l = X(e.price);
1752
- l !== void 0 && (i.price = l);
1753
- const f = X(e.rating);
1754
- f !== void 0 && (i.rating = f);
1755
- const p = X(e.review_count) ?? X(e.reviewCount);
1756
- p !== void 0 && (i.review_count = p);
1757
- const g = w(e.cart_code, e.cartCode);
1758
- return g && (i.cart_code = g), typeof e.in_stock == "boolean" && (i.in_stock = e.in_stock), typeof e.inStock == "boolean" && (i.in_stock = e.inStock), M(i);
1759
- }
1760
- function R(e, t) {
1761
- const n = j(e);
1762
- if (!n) return null;
1763
- const r = n.type;
1764
- if (typeof r != "string" || r.length === 0) return null;
1765
- const o = {
1766
- title: t || r,
1767
- type: r
1768
- };
1769
- return n.payload !== void 0 && (o.payload = n.payload), o;
1770
- }
1771
- function j(e) {
1772
- return !e || typeof e != "object" || Array.isArray(e) ? null : e;
1773
- }
1774
- function w(...e) {
1775
- for (const t of e)
1776
- if (typeof t == "string") {
1777
- const n = t.trim();
1778
- if (n.length > 0) return n;
1779
- }
1780
- }
1781
- function sr(e) {
1782
- return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.length > 0) : [];
1783
- }
1784
- function ar(e) {
1785
- if (typeof e == "string") {
1786
- const t = e.trim();
1787
- return t ? [t] : [];
1788
- }
1789
- return Array.isArray(e) ? e.filter((t) => typeof t == "string").map((t) => t.trim()).filter((t) => t.length > 0) : [];
1790
- }
1791
- function X(e) {
1792
- if (typeof e == "number" && Number.isFinite(e)) return e;
1793
- if (typeof e == "string") {
1794
- let t;
1795
- e.includes(".") && e.includes(",") ? t = e.replace(/\./g, "").replace(",", ".") : t = e.replace(",", ".");
1796
- const n = Number(t);
1797
- if (Number.isFinite(n)) return n;
1798
- }
1799
- }
1800
- function ft(e) {
1801
- return e != null;
1802
- }
1803
- const cr = /* @__PURE__ */ new Set([
1804
- "sku",
1805
- "name",
1806
- "brand",
1807
- "images",
1808
- "price",
1809
- "price_discounted",
1810
- "price_currency",
1811
- "discount_reason",
1812
- "url",
1813
- "rating",
1814
- "review_count",
1815
- "cart_code",
1816
- "in_stock",
1817
- "category_ids",
1818
- "category_names",
1819
- "variants",
1820
- "facet_hits",
1821
- "promotions"
1822
- ]);
1823
- function M(e) {
1824
- const t = e.price_discounted != null && e.price_discounted > 0, n = t ? e.price_discounted : e.price, r = t && e.price != null ? e.price : void 0;
1825
- let o;
1826
- r != null && n != null && r > 0 && (o = Math.round((r - n) / r * 100));
1827
- const i = w(e.brand), s = w(e.name) ?? e.sku, a = i && !s.toLowerCase().startsWith(i.toLowerCase()) ? `${i} ${s}` : s, c = {
1828
- sku: e.sku,
1829
- name: a,
1830
- url: w(e.url) ?? ""
1831
- }, u = e.images?.[0];
1832
- u && (c.imageUrl = u), e.images && e.images.length > 1 && (c.images = e.images), n != null && (c.price = String(n)), r != null && (c.originalPrice = String(r)), o !== void 0 && (c.discountPercent = o), i !== void 0 && (c.brand = i), e.rating !== void 0 && (c.rating = e.rating), e.review_count !== void 0 && (c.reviewCount = e.review_count), e.cart_code !== void 0 && (c.cartCode = e.cart_code), e.in_stock !== void 0 && (c.inStock = e.in_stock), e.variants && e.variants.length > 0 && (c.variants = e.variants), e.discount_reason !== void 0 && (c.discountReason = e.discount_reason), e.promotions && e.promotions.length > 0 && (c.promotions = e.promotions);
1833
- const l = e, f = {};
1834
- let p = !1;
1835
- for (const g of Object.keys(l))
1836
- cr.has(g) || (f[g] = l[g], p = !0);
1837
- return p && (c.extras = f), c;
1838
- }
1839
- function Oc(e) {
1840
- return e.results.map(M);
1841
- }
1842
- function Ic(e) {
1843
- return e.product_groupings.map((t) => {
1844
- const n = {
1845
- name: t.name,
1846
- products: (t.group_products ?? []).map(M)
1847
- };
1848
- return t.highlight !== void 0 && (n.highlight = t.highlight), n;
1849
- });
1850
- }
1851
- const ur = {
1852
- process_action: "/process_action",
1853
- launcher_action: "/launcher_action",
1854
- similar_products: "/similar_products",
1855
- product_groupings: "/product_groupings"
1856
- };
1857
- function dr(e) {
1858
- if (e === void 0)
1859
- throw new Error("[gengage] middlewareUrl is required. Pass your Gengage backend URL in widget config.");
1860
- const t = e.trim();
1861
- return t === "" ? "" : t.replace(/\/+$/, "");
1862
- }
1863
- function Ac(e, t) {
1864
- return `${dr(t?.middlewareUrl)}/chat${ur[e]}`;
1865
- }
1866
- function lr() {
1867
- return typeof window < "u" && Array.isArray(window.dataLayer);
1868
- }
1869
- function T(e, t) {
1870
- const n = {
1871
- event: e,
1872
- ...t
1873
- };
1874
- lr() && window.dataLayer.push(n);
1875
- }
1876
- function fr(e) {
1877
- T("gengage-on-init", { gengage_widget: e });
1878
- }
1879
- function De(e) {
1880
- T("gengage-show", { gengage_widget: e });
1881
- }
1882
- function pr(e) {
1883
- T("gengage-hide", { gengage_widget: e });
1884
- }
1885
- function gr(e, t) {
1886
- T("gengage-suggested-question", {
1887
- gengage_question_title: e,
1888
- gengage_action_type: t
1889
- });
1890
- }
1891
- function Pc(e) {
1892
- T("gengage-find-similars", { gengage_sku: e });
1893
- }
1894
- function Nc(e) {
1895
- T("gengage-compare-preselection", { gengage_sku: e });
1896
- }
1897
- function Cc(e) {
1898
- T("gengage-compare-selected", {
1899
- gengage_skus: e,
1900
- gengage_product_count: e.length
1901
- });
1902
- }
1903
- function Rc() {
1904
- T("gengage-compare-clear");
1905
- }
1906
- function jc(e) {
1907
- T("gengage-compare-received", {
1908
- gengage_product_count: e
1909
- });
1910
- }
1911
- function Dc(e) {
1912
- T("gengage-like-product", { gengage_sku: e });
1913
- }
1914
- function Lc() {
1915
- T("gengage-like-list");
1916
- }
1917
- function Uc(e, t) {
1918
- T("gengage-search", {
1919
- gengage_search_query: e,
1920
- gengage_result_count: t
1921
- });
1922
- }
1923
- function hr(e, t) {
1924
- T("gengage-product-detail", {
1925
- gengage_sku: e,
1926
- gengage_product_name: t
1927
- });
1928
- }
1929
- function mr(e, t) {
1930
- T("gengage-cart-add", {
1931
- gengage_sku: e,
1932
- gengage_quantity: t
1933
- });
1934
- }
1935
- function Mc() {
1936
- T("gengage-message-sent");
1937
- }
1938
- function xc() {
1939
- T("gengage-message-received");
1940
- }
1941
- function Fc() {
1942
- T("gengage-conversation-start");
1943
- }
1944
- function _r() {
1945
- T("gengage-voice-input");
1946
- }
1947
- function yr(e, t) {
1948
- T("gengage-error", { gengage_widget: e, gengage_error: t });
1949
- }
1950
- let Q = null;
1951
- function Jc() {
1952
- if (typeof window > "u") return () => {
1953
- };
1954
- if (Q) return Q;
1955
- const e = [];
1956
- function t(n, r) {
1957
- const o = (i) => r(i.detail);
1958
- window.addEventListener(n, o), e.push(() => window.removeEventListener(n, o));
1959
- }
1960
- return t("gengage:chat:open", () => De("chat")), t("gengage:chat:close", () => pr("chat")), t("gengage:chat:ready", () => fr("chat")), t("gengage:similar:add-to-cart", ({ sku: n, quantity: r }) => {
1961
- mr(n, r);
1962
- }), t("gengage:similar:product-click", ({ sku: n }) => {
1963
- hr(n);
1964
- }), t("gengage:qna:action", ({ title: n, type: r }) => {
1965
- gr(n, r);
1966
- }), t("gengage:chat:voice", () => _r()), t("gengage:qna:open-chat", () => De("chat")), t("gengage:global:error", ({ source: n, message: r }) => {
1967
- yr(n, r);
1968
- }), Q = () => {
1969
- for (const n of e) n();
1970
- e.length = 0, Q = null;
1971
- }, Q;
1972
- }
1973
- function d(e, t, n) {
1974
- function r(a, c) {
1975
- if (a._zod || Object.defineProperty(a, "_zod", {
1976
- value: {
1977
- def: c,
1978
- constr: s,
1979
- traits: /* @__PURE__ */ new Set()
1980
- },
1981
- enumerable: !1
1982
- }), a._zod.traits.has(e))
1983
- return;
1984
- a._zod.traits.add(e), t(a, c);
1985
- const u = s.prototype, l = Object.keys(u);
1986
- for (let f = 0; f < l.length; f++) {
1987
- const p = l[f];
1988
- p in a || (a[p] = u[p].bind(a));
1989
- }
1990
- }
1991
- const o = n?.Parent ?? Object;
1992
- class i extends o {
1993
- }
1994
- Object.defineProperty(i, "name", { value: e });
1995
- function s(a) {
1996
- var c;
1997
- const u = n?.Parent ? new i() : this;
1998
- r(u, a), (c = u._zod).deferred ?? (c.deferred = []);
1999
- for (const l of u._zod.deferred)
2000
- l();
2001
- return u;
2002
- }
2003
- return Object.defineProperty(s, "init", { value: r }), Object.defineProperty(s, Symbol.hasInstance, {
2004
- value: (a) => n?.Parent && a instanceof n.Parent ? !0 : a?._zod?.traits?.has(e)
2005
- }), Object.defineProperty(s, "name", { value: e }), s;
2006
- }
2007
- class G extends Error {
2008
- constructor() {
2009
- super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");
2010
- }
2011
- }
2012
- class pt extends Error {
2013
- constructor(t) {
2014
- super(`Encountered unidirectional transform during encode: ${t}`), this.name = "ZodEncodeError";
2015
- }
2016
- }
2017
- const gt = {};
2018
- function L(e) {
2019
- return gt;
2020
- }
2021
- function ht(e) {
2022
- const t = Object.values(e).filter((r) => typeof r == "number");
2023
- return Object.entries(e).filter(([r, o]) => t.indexOf(+r) === -1).map(([r, o]) => o);
2024
- }
2025
- function ye(e, t) {
2026
- return typeof t == "bigint" ? t.toString() : t;
2027
- }
2028
- function ze(e) {
2029
- return {
2030
- get value() {
2031
- {
2032
- const t = e();
2033
- return Object.defineProperty(this, "value", { value: t }), t;
2034
- }
2035
- }
2036
- };
2037
- }
2038
- function Se(e) {
2039
- return e == null;
2040
- }
2041
- function $e(e) {
2042
- const t = e.startsWith("^") ? 1 : 0, n = e.endsWith("$") ? e.length - 1 : e.length;
2043
- return e.slice(t, n);
2044
- }
2045
- function vr(e, t) {
2046
- const n = (e.toString().split(".")[1] || "").length, r = t.toString();
2047
- let o = (r.split(".")[1] || "").length;
2048
- if (o === 0 && /\d?e-\d?/.test(r)) {
2049
- const c = r.match(/\d?e-(\d?)/);
2050
- c?.[1] && (o = Number.parseInt(c[1]));
2051
- }
2052
- const i = n > o ? n : o, s = Number.parseInt(e.toFixed(i).replace(".", "")), a = Number.parseInt(t.toFixed(i).replace(".", ""));
2053
- return s % a / 10 ** i;
2054
- }
2055
- const Le = /* @__PURE__ */ Symbol("evaluating");
2056
- function v(e, t, n) {
2057
- let r;
2058
- Object.defineProperty(e, t, {
2059
- get() {
2060
- if (r !== Le)
2061
- return r === void 0 && (r = Le, r = n()), r;
2062
- },
2063
- set(o) {
2064
- Object.defineProperty(e, t, {
2065
- value: o
2066
- // configurable: true,
2067
- });
2068
- },
2069
- configurable: !0
2070
- });
2071
- }
2072
- function q(e, t, n) {
2073
- Object.defineProperty(e, t, {
2074
- value: n,
2075
- writable: !0,
2076
- enumerable: !0,
2077
- configurable: !0
2078
- });
2079
- }
2080
- function x(...e) {
2081
- const t = {};
2082
- for (const n of e) {
2083
- const r = Object.getOwnPropertyDescriptors(n);
2084
- Object.assign(t, r);
2085
- }
2086
- return Object.defineProperties({}, t);
2087
- }
2088
- function Ue(e) {
2089
- return JSON.stringify(e);
2090
- }
2091
- function wr(e) {
2092
- return e.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
2093
- }
2094
- const mt = "captureStackTrace" in Error ? Error.captureStackTrace : (...e) => {
2095
- };
2096
- function se(e) {
2097
- return typeof e == "object" && e !== null && !Array.isArray(e);
2098
- }
2099
- const br = ze(() => {
2100
- if (typeof navigator < "u" && navigator?.userAgent?.includes("Cloudflare"))
2101
- return !1;
2102
- try {
2103
- const e = Function;
2104
- return new e(""), !0;
2105
- } catch {
2106
- return !1;
2107
- }
2108
- });
2109
- function B(e) {
2110
- if (se(e) === !1)
2111
- return !1;
2112
- const t = e.constructor;
2113
- if (t === void 0 || typeof t != "function")
2114
- return !0;
2115
- const n = t.prototype;
2116
- return !(se(n) === !1 || Object.prototype.hasOwnProperty.call(n, "isPrototypeOf") === !1);
2117
- }
2118
- function _t(e) {
2119
- return B(e) ? { ...e } : Array.isArray(e) ? [...e] : e;
2120
- }
2121
- const kr = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
2122
- function K(e) {
2123
- return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2124
- }
2125
- function F(e, t, n) {
2126
- const r = new e._zod.constr(t ?? e._zod.def);
2127
- return (!t || n?.parent) && (r._zod.parent = e), r;
2128
- }
2129
- function h(e) {
2130
- const t = e;
2131
- if (!t)
2132
- return {};
2133
- if (typeof t == "string")
2134
- return { error: () => t };
2135
- if (t?.message !== void 0) {
2136
- if (t?.error !== void 0)
2137
- throw new Error("Cannot specify both `message` and `error` params");
2138
- t.error = t.message;
2139
- }
2140
- return delete t.message, typeof t.error == "string" ? { ...t, error: () => t.error } : t;
2141
- }
2142
- function zr(e) {
2143
- return Object.keys(e).filter((t) => e[t]._zod.optin === "optional" && e[t]._zod.optout === "optional");
2144
- }
2145
- const Sr = {
2146
- safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
2147
- int32: [-2147483648, 2147483647],
2148
- uint32: [0, 4294967295],
2149
- float32: [-34028234663852886e22, 34028234663852886e22],
2150
- float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
2151
- };
2152
- function $r(e, t) {
2153
- const n = e._zod.def, r = n.checks;
2154
- if (r && r.length > 0)
2155
- throw new Error(".pick() cannot be used on object schemas containing refinements");
2156
- const i = x(e._zod.def, {
2157
- get shape() {
2158
- const s = {};
2159
- for (const a in t) {
2160
- if (!(a in n.shape))
2161
- throw new Error(`Unrecognized key: "${a}"`);
2162
- t[a] && (s[a] = n.shape[a]);
2163
- }
2164
- return q(this, "shape", s), s;
2165
- },
2166
- checks: []
2167
- });
2168
- return F(e, i);
2169
- }
2170
- function Er(e, t) {
2171
- const n = e._zod.def, r = n.checks;
2172
- if (r && r.length > 0)
2173
- throw new Error(".omit() cannot be used on object schemas containing refinements");
2174
- const i = x(e._zod.def, {
2175
- get shape() {
2176
- const s = { ...e._zod.def.shape };
2177
- for (const a in t) {
2178
- if (!(a in n.shape))
2179
- throw new Error(`Unrecognized key: "${a}"`);
2180
- t[a] && delete s[a];
2181
- }
2182
- return q(this, "shape", s), s;
2183
- },
2184
- checks: []
2185
- });
2186
- return F(e, i);
2187
- }
2188
- function Tr(e, t) {
2189
- if (!B(t))
2190
- throw new Error("Invalid input to extend: expected a plain object");
2191
- const n = e._zod.def.checks;
2192
- if (n && n.length > 0) {
2193
- const i = e._zod.def.shape;
2194
- for (const s in t)
2195
- if (Object.getOwnPropertyDescriptor(i, s) !== void 0)
2196
- throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
2197
- }
2198
- const o = x(e._zod.def, {
2199
- get shape() {
2200
- const i = { ...e._zod.def.shape, ...t };
2201
- return q(this, "shape", i), i;
2202
- }
2203
- });
2204
- return F(e, o);
2205
- }
2206
- function Zr(e, t) {
2207
- if (!B(t))
2208
- throw new Error("Invalid input to safeExtend: expected a plain object");
2209
- const n = x(e._zod.def, {
2210
- get shape() {
2211
- const r = { ...e._zod.def.shape, ...t };
2212
- return q(this, "shape", r), r;
2213
- }
2214
- });
2215
- return F(e, n);
2216
- }
2217
- function Or(e, t) {
2218
- const n = x(e._zod.def, {
2219
- get shape() {
2220
- const r = { ...e._zod.def.shape, ...t._zod.def.shape };
2221
- return q(this, "shape", r), r;
2222
- },
2223
- get catchall() {
2224
- return t._zod.def.catchall;
2225
- },
2226
- checks: []
2227
- // delete existing checks
2228
- });
2229
- return F(e, n);
2230
- }
2231
- function Ir(e, t, n) {
2232
- const o = t._zod.def.checks;
2233
- if (o && o.length > 0)
2234
- throw new Error(".partial() cannot be used on object schemas containing refinements");
2235
- const s = x(t._zod.def, {
2236
- get shape() {
2237
- const a = t._zod.def.shape, c = { ...a };
2238
- if (n)
2239
- for (const u in n) {
2240
- if (!(u in a))
2241
- throw new Error(`Unrecognized key: "${u}"`);
2242
- n[u] && (c[u] = e ? new e({
2243
- type: "optional",
2244
- innerType: a[u]
2245
- }) : a[u]);
2246
- }
2247
- else
2248
- for (const u in a)
2249
- c[u] = e ? new e({
2250
- type: "optional",
2251
- innerType: a[u]
2252
- }) : a[u];
2253
- return q(this, "shape", c), c;
2254
- },
2255
- checks: []
2256
- });
2257
- return F(t, s);
2258
- }
2259
- function Ar(e, t, n) {
2260
- const r = x(t._zod.def, {
2261
- get shape() {
2262
- const o = t._zod.def.shape, i = { ...o };
2263
- if (n)
2264
- for (const s in n) {
2265
- if (!(s in i))
2266
- throw new Error(`Unrecognized key: "${s}"`);
2267
- n[s] && (i[s] = new e({
2268
- type: "nonoptional",
2269
- innerType: o[s]
2270
- }));
2271
- }
2272
- else
2273
- for (const s in o)
2274
- i[s] = new e({
2275
- type: "nonoptional",
2276
- innerType: o[s]
2277
- });
2278
- return q(this, "shape", i), i;
2279
- }
2280
- });
2281
- return F(t, r);
2282
- }
2283
- function V(e, t = 0) {
2284
- if (e.aborted === !0)
2285
- return !0;
2286
- for (let n = t; n < e.issues.length; n++)
2287
- if (e.issues[n]?.continue !== !0)
2288
- return !0;
2289
- return !1;
2290
- }
2291
- function W(e, t) {
2292
- return t.map((n) => {
2293
- var r;
2294
- return (r = n).path ?? (r.path = []), n.path.unshift(e), n;
2295
- });
2296
- }
2297
- function re(e) {
2298
- return typeof e == "string" ? e : e?.message;
2299
- }
2300
- function U(e, t, n) {
2301
- const r = { ...e, path: e.path ?? [] };
2302
- if (!e.message) {
2303
- const o = re(e.inst?._zod.def?.error?.(e)) ?? re(t?.error?.(e)) ?? re(n.customError?.(e)) ?? re(n.localeError?.(e)) ?? "Invalid input";
2304
- r.message = o;
2305
- }
2306
- return delete r.inst, delete r.continue, t?.reportInput || delete r.input, r;
2307
- }
2308
- function Ee(e) {
2309
- return Array.isArray(e) ? "array" : typeof e == "string" ? "string" : "unknown";
2310
- }
2311
- function ne(...e) {
2312
- const [t, n, r] = e;
2313
- return typeof t == "string" ? {
2314
- message: t,
2315
- code: "custom",
2316
- input: n,
2317
- inst: r
2318
- } : { ...t };
2319
- }
2320
- const yt = (e, t) => {
2321
- e.name = "$ZodError", Object.defineProperty(e, "_zod", {
2322
- value: e._zod,
2323
- enumerable: !1
2324
- }), Object.defineProperty(e, "issues", {
2325
- value: t,
2326
- enumerable: !1
2327
- }), e.message = JSON.stringify(t, ye, 2), Object.defineProperty(e, "toString", {
2328
- value: () => e.message,
2329
- enumerable: !1
2330
- });
2331
- }, vt = d("$ZodError", yt), wt = d("$ZodError", yt, { Parent: Error });
2332
- function Pr(e, t = (n) => n.message) {
2333
- const n = {}, r = [];
2334
- for (const o of e.issues)
2335
- o.path.length > 0 ? (n[o.path[0]] = n[o.path[0]] || [], n[o.path[0]].push(t(o))) : r.push(t(o));
2336
- return { formErrors: r, fieldErrors: n };
2337
- }
2338
- function Nr(e, t = (n) => n.message) {
2339
- const n = { _errors: [] }, r = (o) => {
2340
- for (const i of o.issues)
2341
- if (i.code === "invalid_union" && i.errors.length)
2342
- i.errors.map((s) => r({ issues: s }));
2343
- else if (i.code === "invalid_key")
2344
- r({ issues: i.issues });
2345
- else if (i.code === "invalid_element")
2346
- r({ issues: i.issues });
2347
- else if (i.path.length === 0)
2348
- n._errors.push(t(i));
2349
- else {
2350
- let s = n, a = 0;
2351
- for (; a < i.path.length; ) {
2352
- const c = i.path[a];
2353
- a === i.path.length - 1 ? (s[c] = s[c] || { _errors: [] }, s[c]._errors.push(t(i))) : s[c] = s[c] || { _errors: [] }, s = s[c], a++;
2354
- }
2355
- }
2356
- };
2357
- return r(e), n;
2358
- }
2359
- const Te = (e) => (t, n, r, o) => {
2360
- const i = r ? Object.assign(r, { async: !1 }) : { async: !1 }, s = t._zod.run({ value: n, issues: [] }, i);
2361
- if (s instanceof Promise)
2362
- throw new G();
2363
- if (s.issues.length) {
2364
- const a = new (o?.Err ?? e)(s.issues.map((c) => U(c, i, L())));
2365
- throw mt(a, o?.callee), a;
2366
- }
2367
- return s.value;
2368
- }, Ze = (e) => async (t, n, r, o) => {
2369
- const i = r ? Object.assign(r, { async: !0 }) : { async: !0 };
2370
- let s = t._zod.run({ value: n, issues: [] }, i);
2371
- if (s instanceof Promise && (s = await s), s.issues.length) {
2372
- const a = new (o?.Err ?? e)(s.issues.map((c) => U(c, i, L())));
2373
- throw mt(a, o?.callee), a;
2374
- }
2375
- return s.value;
2376
- }, de = (e) => (t, n, r) => {
2377
- const o = r ? { ...r, async: !1 } : { async: !1 }, i = t._zod.run({ value: n, issues: [] }, o);
2378
- if (i instanceof Promise)
2379
- throw new G();
2380
- return i.issues.length ? {
2381
- success: !1,
2382
- error: new (e ?? vt)(i.issues.map((s) => U(s, o, L())))
2383
- } : { success: !0, data: i.value };
2384
- }, Cr = /* @__PURE__ */ de(wt), le = (e) => async (t, n, r) => {
2385
- const o = r ? Object.assign(r, { async: !0 }) : { async: !0 };
2386
- let i = t._zod.run({ value: n, issues: [] }, o);
2387
- return i instanceof Promise && (i = await i), i.issues.length ? {
2388
- success: !1,
2389
- error: new e(i.issues.map((s) => U(s, o, L())))
2390
- } : { success: !0, data: i.value };
2391
- }, Rr = /* @__PURE__ */ le(wt), jr = (e) => (t, n, r) => {
2392
- const o = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
2393
- return Te(e)(t, n, o);
2394
- }, Dr = (e) => (t, n, r) => Te(e)(t, n, r), Lr = (e) => async (t, n, r) => {
2395
- const o = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
2396
- return Ze(e)(t, n, o);
2397
- }, Ur = (e) => async (t, n, r) => Ze(e)(t, n, r), Mr = (e) => (t, n, r) => {
2398
- const o = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
2399
- return de(e)(t, n, o);
2400
- }, xr = (e) => (t, n, r) => de(e)(t, n, r), Fr = (e) => async (t, n, r) => {
2401
- const o = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
2402
- return le(e)(t, n, o);
2403
- }, Jr = (e) => async (t, n, r) => le(e)(t, n, r), qr = /^[cC][^\s-]{8,}$/, Vr = /^[0-9a-z]+$/, Wr = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/, Gr = /^[0-9a-vA-V]{20}$/, Br = /^[A-Za-z0-9]{27}$/, Kr = /^[a-zA-Z0-9_-]{21}$/, Hr = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/, Yr = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/, Me = (e) => e ? new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`) : /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/, Xr = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/, Qr = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
2404
- function eo() {
2405
- return new RegExp(Qr, "u");
2406
- }
2407
- const to = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, no = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/, ro = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/, oo = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, io = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/, bt = /^[A-Za-z0-9_-]*$/, so = /^\+[1-9]\d{6,14}$/, kt = "(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))", ao = /* @__PURE__ */ new RegExp(`^${kt}$`);
2408
- function zt(e) {
2409
- const t = "(?:[01]\\d|2[0-3]):[0-5]\\d";
2410
- return typeof e.precision == "number" ? e.precision === -1 ? `${t}` : e.precision === 0 ? `${t}:[0-5]\\d` : `${t}:[0-5]\\d\\.\\d{${e.precision}}` : `${t}(?::[0-5]\\d(?:\\.\\d+)?)?`;
2411
- }
2412
- function co(e) {
2413
- return new RegExp(`^${zt(e)}$`);
2414
- }
2415
- function uo(e) {
2416
- const t = zt({ precision: e.precision }), n = ["Z"];
2417
- e.local && n.push(""), e.offset && n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");
2418
- const r = `${t}(?:${n.join("|")})`;
2419
- return new RegExp(`^${kt}T(?:${r})$`);
2420
- }
2421
- const lo = (e) => {
2422
- const t = e ? `[\\s\\S]{${e?.minimum ?? 0},${e?.maximum ?? ""}}` : "[\\s\\S]*";
2423
- return new RegExp(`^${t}$`);
2424
- }, fo = /^-?\d+$/, St = /^-?\d+(?:\.\d+)?$/, po = /^(?:true|false)$/i, go = /^[^A-Z]*$/, ho = /^[^a-z]*$/, A = /* @__PURE__ */ d("$ZodCheck", (e, t) => {
2425
- var n;
2426
- e._zod ?? (e._zod = {}), e._zod.def = t, (n = e._zod).onattach ?? (n.onattach = []);
2427
- }), $t = {
2428
- number: "number",
2429
- bigint: "bigint",
2430
- object: "date"
2431
- }, Et = /* @__PURE__ */ d("$ZodCheckLessThan", (e, t) => {
2432
- A.init(e, t);
2433
- const n = $t[typeof t.value];
2434
- e._zod.onattach.push((r) => {
2435
- const o = r._zod.bag, i = (t.inclusive ? o.maximum : o.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
2436
- t.value < i && (t.inclusive ? o.maximum = t.value : o.exclusiveMaximum = t.value);
2437
- }), e._zod.check = (r) => {
2438
- (t.inclusive ? r.value <= t.value : r.value < t.value) || r.issues.push({
2439
- origin: n,
2440
- code: "too_big",
2441
- maximum: typeof t.value == "object" ? t.value.getTime() : t.value,
2442
- input: r.value,
2443
- inclusive: t.inclusive,
2444
- inst: e,
2445
- continue: !t.abort
2446
- });
2447
- };
2448
- }), Tt = /* @__PURE__ */ d("$ZodCheckGreaterThan", (e, t) => {
2449
- A.init(e, t);
2450
- const n = $t[typeof t.value];
2451
- e._zod.onattach.push((r) => {
2452
- const o = r._zod.bag, i = (t.inclusive ? o.minimum : o.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
2453
- t.value > i && (t.inclusive ? o.minimum = t.value : o.exclusiveMinimum = t.value);
2454
- }), e._zod.check = (r) => {
2455
- (t.inclusive ? r.value >= t.value : r.value > t.value) || r.issues.push({
2456
- origin: n,
2457
- code: "too_small",
2458
- minimum: typeof t.value == "object" ? t.value.getTime() : t.value,
2459
- input: r.value,
2460
- inclusive: t.inclusive,
2461
- inst: e,
2462
- continue: !t.abort
2463
- });
2464
- };
2465
- }), mo = /* @__PURE__ */ d("$ZodCheckMultipleOf", (e, t) => {
2466
- A.init(e, t), e._zod.onattach.push((n) => {
2467
- var r;
2468
- (r = n._zod.bag).multipleOf ?? (r.multipleOf = t.value);
2469
- }), e._zod.check = (n) => {
2470
- if (typeof n.value != typeof t.value)
2471
- throw new Error("Cannot mix number and bigint in multiple_of check.");
2472
- (typeof n.value == "bigint" ? n.value % t.value === BigInt(0) : vr(n.value, t.value) === 0) || n.issues.push({
2473
- origin: typeof n.value,
2474
- code: "not_multiple_of",
2475
- divisor: t.value,
2476
- input: n.value,
2477
- inst: e,
2478
- continue: !t.abort
2479
- });
2480
- };
2481
- }), _o = /* @__PURE__ */ d("$ZodCheckNumberFormat", (e, t) => {
2482
- A.init(e, t), t.format = t.format || "float64";
2483
- const n = t.format?.includes("int"), r = n ? "int" : "number", [o, i] = Sr[t.format];
2484
- e._zod.onattach.push((s) => {
2485
- const a = s._zod.bag;
2486
- a.format = t.format, a.minimum = o, a.maximum = i, n && (a.pattern = fo);
2487
- }), e._zod.check = (s) => {
2488
- const a = s.value;
2489
- if (n) {
2490
- if (!Number.isInteger(a)) {
2491
- s.issues.push({
2492
- expected: r,
2493
- format: t.format,
2494
- code: "invalid_type",
2495
- continue: !1,
2496
- input: a,
2497
- inst: e
2498
- });
2499
- return;
2500
- }
2501
- if (!Number.isSafeInteger(a)) {
2502
- a > 0 ? s.issues.push({
2503
- input: a,
2504
- code: "too_big",
2505
- maximum: Number.MAX_SAFE_INTEGER,
2506
- note: "Integers must be within the safe integer range.",
2507
- inst: e,
2508
- origin: r,
2509
- inclusive: !0,
2510
- continue: !t.abort
2511
- }) : s.issues.push({
2512
- input: a,
2513
- code: "too_small",
2514
- minimum: Number.MIN_SAFE_INTEGER,
2515
- note: "Integers must be within the safe integer range.",
2516
- inst: e,
2517
- origin: r,
2518
- inclusive: !0,
2519
- continue: !t.abort
2520
- });
2521
- return;
2522
- }
2523
- }
2524
- a < o && s.issues.push({
2525
- origin: "number",
2526
- input: a,
2527
- code: "too_small",
2528
- minimum: o,
2529
- inclusive: !0,
2530
- inst: e,
2531
- continue: !t.abort
2532
- }), a > i && s.issues.push({
2533
- origin: "number",
2534
- input: a,
2535
- code: "too_big",
2536
- maximum: i,
2537
- inclusive: !0,
2538
- inst: e,
2539
- continue: !t.abort
2540
- });
2541
- };
2542
- }), yo = /* @__PURE__ */ d("$ZodCheckMaxLength", (e, t) => {
2543
- var n;
2544
- A.init(e, t), (n = e._zod.def).when ?? (n.when = (r) => {
2545
- const o = r.value;
2546
- return !Se(o) && o.length !== void 0;
2547
- }), e._zod.onattach.push((r) => {
2548
- const o = r._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
2549
- t.maximum < o && (r._zod.bag.maximum = t.maximum);
2550
- }), e._zod.check = (r) => {
2551
- const o = r.value;
2552
- if (o.length <= t.maximum)
2553
- return;
2554
- const s = Ee(o);
2555
- r.issues.push({
2556
- origin: s,
2557
- code: "too_big",
2558
- maximum: t.maximum,
2559
- inclusive: !0,
2560
- input: o,
2561
- inst: e,
2562
- continue: !t.abort
2563
- });
2564
- };
2565
- }), vo = /* @__PURE__ */ d("$ZodCheckMinLength", (e, t) => {
2566
- var n;
2567
- A.init(e, t), (n = e._zod.def).when ?? (n.when = (r) => {
2568
- const o = r.value;
2569
- return !Se(o) && o.length !== void 0;
2570
- }), e._zod.onattach.push((r) => {
2571
- const o = r._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
2572
- t.minimum > o && (r._zod.bag.minimum = t.minimum);
2573
- }), e._zod.check = (r) => {
2574
- const o = r.value;
2575
- if (o.length >= t.minimum)
2576
- return;
2577
- const s = Ee(o);
2578
- r.issues.push({
2579
- origin: s,
2580
- code: "too_small",
2581
- minimum: t.minimum,
2582
- inclusive: !0,
2583
- input: o,
2584
- inst: e,
2585
- continue: !t.abort
2586
- });
2587
- };
2588
- }), wo = /* @__PURE__ */ d("$ZodCheckLengthEquals", (e, t) => {
2589
- var n;
2590
- A.init(e, t), (n = e._zod.def).when ?? (n.when = (r) => {
2591
- const o = r.value;
2592
- return !Se(o) && o.length !== void 0;
2593
- }), e._zod.onattach.push((r) => {
2594
- const o = r._zod.bag;
2595
- o.minimum = t.length, o.maximum = t.length, o.length = t.length;
2596
- }), e._zod.check = (r) => {
2597
- const o = r.value, i = o.length;
2598
- if (i === t.length)
2599
- return;
2600
- const s = Ee(o), a = i > t.length;
2601
- r.issues.push({
2602
- origin: s,
2603
- ...a ? { code: "too_big", maximum: t.length } : { code: "too_small", minimum: t.length },
2604
- inclusive: !0,
2605
- exact: !0,
2606
- input: r.value,
2607
- inst: e,
2608
- continue: !t.abort
2609
- });
2610
- };
2611
- }), fe = /* @__PURE__ */ d("$ZodCheckStringFormat", (e, t) => {
2612
- var n, r;
2613
- A.init(e, t), e._zod.onattach.push((o) => {
2614
- const i = o._zod.bag;
2615
- i.format = t.format, t.pattern && (i.patterns ?? (i.patterns = /* @__PURE__ */ new Set()), i.patterns.add(t.pattern));
2616
- }), t.pattern ? (n = e._zod).check ?? (n.check = (o) => {
2617
- t.pattern.lastIndex = 0, !t.pattern.test(o.value) && o.issues.push({
2618
- origin: "string",
2619
- code: "invalid_format",
2620
- format: t.format,
2621
- input: o.value,
2622
- ...t.pattern ? { pattern: t.pattern.toString() } : {},
2623
- inst: e,
2624
- continue: !t.abort
2625
- });
2626
- }) : (r = e._zod).check ?? (r.check = () => {
2627
- });
2628
- }), bo = /* @__PURE__ */ d("$ZodCheckRegex", (e, t) => {
2629
- fe.init(e, t), e._zod.check = (n) => {
2630
- t.pattern.lastIndex = 0, !t.pattern.test(n.value) && n.issues.push({
2631
- origin: "string",
2632
- code: "invalid_format",
2633
- format: "regex",
2634
- input: n.value,
2635
- pattern: t.pattern.toString(),
2636
- inst: e,
2637
- continue: !t.abort
2638
- });
2639
- };
2640
- }), ko = /* @__PURE__ */ d("$ZodCheckLowerCase", (e, t) => {
2641
- t.pattern ?? (t.pattern = go), fe.init(e, t);
2642
- }), zo = /* @__PURE__ */ d("$ZodCheckUpperCase", (e, t) => {
2643
- t.pattern ?? (t.pattern = ho), fe.init(e, t);
2644
- }), So = /* @__PURE__ */ d("$ZodCheckIncludes", (e, t) => {
2645
- A.init(e, t);
2646
- const n = K(t.includes), r = new RegExp(typeof t.position == "number" ? `^.{${t.position}}${n}` : n);
2647
- t.pattern = r, e._zod.onattach.push((o) => {
2648
- const i = o._zod.bag;
2649
- i.patterns ?? (i.patterns = /* @__PURE__ */ new Set()), i.patterns.add(r);
2650
- }), e._zod.check = (o) => {
2651
- o.value.includes(t.includes, t.position) || o.issues.push({
2652
- origin: "string",
2653
- code: "invalid_format",
2654
- format: "includes",
2655
- includes: t.includes,
2656
- input: o.value,
2657
- inst: e,
2658
- continue: !t.abort
2659
- });
2660
- };
2661
- }), $o = /* @__PURE__ */ d("$ZodCheckStartsWith", (e, t) => {
2662
- A.init(e, t);
2663
- const n = new RegExp(`^${K(t.prefix)}.*`);
2664
- t.pattern ?? (t.pattern = n), e._zod.onattach.push((r) => {
2665
- const o = r._zod.bag;
2666
- o.patterns ?? (o.patterns = /* @__PURE__ */ new Set()), o.patterns.add(n);
2667
- }), e._zod.check = (r) => {
2668
- r.value.startsWith(t.prefix) || r.issues.push({
2669
- origin: "string",
2670
- code: "invalid_format",
2671
- format: "starts_with",
2672
- prefix: t.prefix,
2673
- input: r.value,
2674
- inst: e,
2675
- continue: !t.abort
2676
- });
2677
- };
2678
- }), Eo = /* @__PURE__ */ d("$ZodCheckEndsWith", (e, t) => {
2679
- A.init(e, t);
2680
- const n = new RegExp(`.*${K(t.suffix)}$`);
2681
- t.pattern ?? (t.pattern = n), e._zod.onattach.push((r) => {
2682
- const o = r._zod.bag;
2683
- o.patterns ?? (o.patterns = /* @__PURE__ */ new Set()), o.patterns.add(n);
2684
- }), e._zod.check = (r) => {
2685
- r.value.endsWith(t.suffix) || r.issues.push({
2686
- origin: "string",
2687
- code: "invalid_format",
2688
- format: "ends_with",
2689
- suffix: t.suffix,
2690
- input: r.value,
2691
- inst: e,
2692
- continue: !t.abort
2693
- });
2694
- };
2695
- }), To = /* @__PURE__ */ d("$ZodCheckOverwrite", (e, t) => {
2696
- A.init(e, t), e._zod.check = (n) => {
2697
- n.value = t.tx(n.value);
2698
- };
2699
- });
2700
- class Zo {
2701
- constructor(t = []) {
2702
- this.content = [], this.indent = 0, this && (this.args = t);
2703
- }
2704
- indented(t) {
2705
- this.indent += 1, t(this), this.indent -= 1;
2706
- }
2707
- write(t) {
2708
- if (typeof t == "function") {
2709
- t(this, { execution: "sync" }), t(this, { execution: "async" });
2710
- return;
2711
- }
2712
- const r = t.split(`
2713
- `).filter((s) => s), o = Math.min(...r.map((s) => s.length - s.trimStart().length)), i = r.map((s) => s.slice(o)).map((s) => " ".repeat(this.indent * 2) + s);
2714
- for (const s of i)
2715
- this.content.push(s);
2716
- }
2717
- compile() {
2718
- const t = Function, n = this?.args, o = [...(this?.content ?? [""]).map((i) => ` ${i}`)];
2719
- return new t(...n, o.join(`
2720
- `));
2721
- }
2722
- }
2723
- const Oo = {
2724
- major: 4,
2725
- minor: 3,
2726
- patch: 6
2727
- }, z = /* @__PURE__ */ d("$ZodType", (e, t) => {
2728
- var n;
2729
- e ?? (e = {}), e._zod.def = t, e._zod.bag = e._zod.bag || {}, e._zod.version = Oo;
2730
- const r = [...e._zod.def.checks ?? []];
2731
- e._zod.traits.has("$ZodCheck") && r.unshift(e);
2732
- for (const o of r)
2733
- for (const i of o._zod.onattach)
2734
- i(e);
2735
- if (r.length === 0)
2736
- (n = e._zod).deferred ?? (n.deferred = []), e._zod.deferred?.push(() => {
2737
- e._zod.run = e._zod.parse;
2738
- });
2739
- else {
2740
- const o = (s, a, c) => {
2741
- let u = V(s), l;
2742
- for (const f of a) {
2743
- if (f._zod.def.when) {
2744
- if (!f._zod.def.when(s))
2745
- continue;
2746
- } else if (u)
2747
- continue;
2748
- const p = s.issues.length, g = f._zod.check(s);
2749
- if (g instanceof Promise && c?.async === !1)
2750
- throw new G();
2751
- if (l || g instanceof Promise)
2752
- l = (l ?? Promise.resolve()).then(async () => {
2753
- await g, s.issues.length !== p && (u || (u = V(s, p)));
2754
- });
2755
- else {
2756
- if (s.issues.length === p)
2757
- continue;
2758
- u || (u = V(s, p));
2759
- }
2760
- }
2761
- return l ? l.then(() => s) : s;
2762
- }, i = (s, a, c) => {
2763
- if (V(s))
2764
- return s.aborted = !0, s;
2765
- const u = o(a, r, c);
2766
- if (u instanceof Promise) {
2767
- if (c.async === !1)
2768
- throw new G();
2769
- return u.then((l) => e._zod.parse(l, c));
2770
- }
2771
- return e._zod.parse(u, c);
2772
- };
2773
- e._zod.run = (s, a) => {
2774
- if (a.skipChecks)
2775
- return e._zod.parse(s, a);
2776
- if (a.direction === "backward") {
2777
- const u = e._zod.parse({ value: s.value, issues: [] }, { ...a, skipChecks: !0 });
2778
- return u instanceof Promise ? u.then((l) => i(l, s, a)) : i(u, s, a);
2779
- }
2780
- const c = e._zod.parse(s, a);
2781
- if (c instanceof Promise) {
2782
- if (a.async === !1)
2783
- throw new G();
2784
- return c.then((u) => o(u, r, a));
2785
- }
2786
- return o(c, r, a);
2787
- };
2788
- }
2789
- v(e, "~standard", () => ({
2790
- validate: (o) => {
2791
- try {
2792
- const i = Cr(e, o);
2793
- return i.success ? { value: i.data } : { issues: i.error?.issues };
2794
- } catch {
2795
- return Rr(e, o).then((s) => s.success ? { value: s.data } : { issues: s.error?.issues });
2796
- }
2797
- },
2798
- vendor: "zod",
2799
- version: 1
2800
- }));
2801
- }), Oe = /* @__PURE__ */ d("$ZodString", (e, t) => {
2802
- z.init(e, t), e._zod.pattern = [...e?._zod.bag?.patterns ?? []].pop() ?? lo(e._zod.bag), e._zod.parse = (n, r) => {
2803
- if (t.coerce)
2804
- try {
2805
- n.value = String(n.value);
2806
- } catch {
2807
- }
2808
- return typeof n.value == "string" || n.issues.push({
2809
- expected: "string",
2810
- code: "invalid_type",
2811
- input: n.value,
2812
- inst: e
2813
- }), n;
2814
- };
2815
- }), k = /* @__PURE__ */ d("$ZodStringFormat", (e, t) => {
2816
- fe.init(e, t), Oe.init(e, t);
2817
- }), Io = /* @__PURE__ */ d("$ZodGUID", (e, t) => {
2818
- t.pattern ?? (t.pattern = Yr), k.init(e, t);
2819
- }), Ao = /* @__PURE__ */ d("$ZodUUID", (e, t) => {
2820
- if (t.version) {
2821
- const r = {
2822
- v1: 1,
2823
- v2: 2,
2824
- v3: 3,
2825
- v4: 4,
2826
- v5: 5,
2827
- v6: 6,
2828
- v7: 7,
2829
- v8: 8
2830
- }[t.version];
2831
- if (r === void 0)
2832
- throw new Error(`Invalid UUID version: "${t.version}"`);
2833
- t.pattern ?? (t.pattern = Me(r));
2834
- } else
2835
- t.pattern ?? (t.pattern = Me());
2836
- k.init(e, t);
2837
- }), Po = /* @__PURE__ */ d("$ZodEmail", (e, t) => {
2838
- t.pattern ?? (t.pattern = Xr), k.init(e, t);
2839
- }), No = /* @__PURE__ */ d("$ZodURL", (e, t) => {
2840
- k.init(e, t), e._zod.check = (n) => {
2841
- try {
2842
- const r = n.value.trim(), o = new URL(r);
2843
- t.hostname && (t.hostname.lastIndex = 0, t.hostname.test(o.hostname) || n.issues.push({
2844
- code: "invalid_format",
2845
- format: "url",
2846
- note: "Invalid hostname",
2847
- pattern: t.hostname.source,
2848
- input: n.value,
2849
- inst: e,
2850
- continue: !t.abort
2851
- })), t.protocol && (t.protocol.lastIndex = 0, t.protocol.test(o.protocol.endsWith(":") ? o.protocol.slice(0, -1) : o.protocol) || n.issues.push({
2852
- code: "invalid_format",
2853
- format: "url",
2854
- note: "Invalid protocol",
2855
- pattern: t.protocol.source,
2856
- input: n.value,
2857
- inst: e,
2858
- continue: !t.abort
2859
- })), t.normalize ? n.value = o.href : n.value = r;
2860
- return;
2861
- } catch {
2862
- n.issues.push({
2863
- code: "invalid_format",
2864
- format: "url",
2865
- input: n.value,
2866
- inst: e,
2867
- continue: !t.abort
2868
- });
2869
- }
2870
- };
2871
- }), Co = /* @__PURE__ */ d("$ZodEmoji", (e, t) => {
2872
- t.pattern ?? (t.pattern = eo()), k.init(e, t);
2873
- }), Ro = /* @__PURE__ */ d("$ZodNanoID", (e, t) => {
2874
- t.pattern ?? (t.pattern = Kr), k.init(e, t);
2875
- }), jo = /* @__PURE__ */ d("$ZodCUID", (e, t) => {
2876
- t.pattern ?? (t.pattern = qr), k.init(e, t);
2877
- }), Do = /* @__PURE__ */ d("$ZodCUID2", (e, t) => {
2878
- t.pattern ?? (t.pattern = Vr), k.init(e, t);
2879
- }), Lo = /* @__PURE__ */ d("$ZodULID", (e, t) => {
2880
- t.pattern ?? (t.pattern = Wr), k.init(e, t);
2881
- }), Uo = /* @__PURE__ */ d("$ZodXID", (e, t) => {
2882
- t.pattern ?? (t.pattern = Gr), k.init(e, t);
2883
- }), Mo = /* @__PURE__ */ d("$ZodKSUID", (e, t) => {
2884
- t.pattern ?? (t.pattern = Br), k.init(e, t);
2885
- }), xo = /* @__PURE__ */ d("$ZodISODateTime", (e, t) => {
2886
- t.pattern ?? (t.pattern = uo(t)), k.init(e, t);
2887
- }), Fo = /* @__PURE__ */ d("$ZodISODate", (e, t) => {
2888
- t.pattern ?? (t.pattern = ao), k.init(e, t);
2889
- }), Jo = /* @__PURE__ */ d("$ZodISOTime", (e, t) => {
2890
- t.pattern ?? (t.pattern = co(t)), k.init(e, t);
2891
- }), qo = /* @__PURE__ */ d("$ZodISODuration", (e, t) => {
2892
- t.pattern ?? (t.pattern = Hr), k.init(e, t);
2893
- }), Vo = /* @__PURE__ */ d("$ZodIPv4", (e, t) => {
2894
- t.pattern ?? (t.pattern = to), k.init(e, t), e._zod.bag.format = "ipv4";
2895
- }), Wo = /* @__PURE__ */ d("$ZodIPv6", (e, t) => {
2896
- t.pattern ?? (t.pattern = no), k.init(e, t), e._zod.bag.format = "ipv6", e._zod.check = (n) => {
2897
- try {
2898
- new URL(`http://[${n.value}]`);
2899
- } catch {
2900
- n.issues.push({
2901
- code: "invalid_format",
2902
- format: "ipv6",
2903
- input: n.value,
2904
- inst: e,
2905
- continue: !t.abort
2906
- });
2907
- }
2908
- };
2909
- }), Go = /* @__PURE__ */ d("$ZodCIDRv4", (e, t) => {
2910
- t.pattern ?? (t.pattern = ro), k.init(e, t);
2911
- }), Bo = /* @__PURE__ */ d("$ZodCIDRv6", (e, t) => {
2912
- t.pattern ?? (t.pattern = oo), k.init(e, t), e._zod.check = (n) => {
2913
- const r = n.value.split("/");
2914
- try {
2915
- if (r.length !== 2)
2916
- throw new Error();
2917
- const [o, i] = r;
2918
- if (!i)
2919
- throw new Error();
2920
- const s = Number(i);
2921
- if (`${s}` !== i)
2922
- throw new Error();
2923
- if (s < 0 || s > 128)
2924
- throw new Error();
2925
- new URL(`http://[${o}]`);
2926
- } catch {
2927
- n.issues.push({
2928
- code: "invalid_format",
2929
- format: "cidrv6",
2930
- input: n.value,
2931
- inst: e,
2932
- continue: !t.abort
2933
- });
2934
- }
2935
- };
2936
- });
2937
- function Zt(e) {
2938
- if (e === "")
2939
- return !0;
2940
- if (e.length % 4 !== 0)
2941
- return !1;
2942
- try {
2943
- return atob(e), !0;
2944
- } catch {
2945
- return !1;
2946
- }
2947
- }
2948
- const Ko = /* @__PURE__ */ d("$ZodBase64", (e, t) => {
2949
- t.pattern ?? (t.pattern = io), k.init(e, t), e._zod.bag.contentEncoding = "base64", e._zod.check = (n) => {
2950
- Zt(n.value) || n.issues.push({
2951
- code: "invalid_format",
2952
- format: "base64",
2953
- input: n.value,
2954
- inst: e,
2955
- continue: !t.abort
2956
- });
2957
- };
2958
- });
2959
- function Ho(e) {
2960
- if (!bt.test(e))
2961
- return !1;
2962
- const t = e.replace(/[-_]/g, (r) => r === "-" ? "+" : "/"), n = t.padEnd(Math.ceil(t.length / 4) * 4, "=");
2963
- return Zt(n);
2964
- }
2965
- const Yo = /* @__PURE__ */ d("$ZodBase64URL", (e, t) => {
2966
- t.pattern ?? (t.pattern = bt), k.init(e, t), e._zod.bag.contentEncoding = "base64url", e._zod.check = (n) => {
2967
- Ho(n.value) || n.issues.push({
2968
- code: "invalid_format",
2969
- format: "base64url",
2970
- input: n.value,
2971
- inst: e,
2972
- continue: !t.abort
2973
- });
2974
- };
2975
- }), Xo = /* @__PURE__ */ d("$ZodE164", (e, t) => {
2976
- t.pattern ?? (t.pattern = so), k.init(e, t);
2977
- });
2978
- function Qo(e, t = null) {
2979
- try {
2980
- const n = e.split(".");
2981
- if (n.length !== 3)
2982
- return !1;
2983
- const [r] = n;
2984
- if (!r)
2985
- return !1;
2986
- const o = JSON.parse(atob(r));
2987
- return !("typ" in o && o?.typ !== "JWT" || !o.alg || t && (!("alg" in o) || o.alg !== t));
2988
- } catch {
2989
- return !1;
2990
- }
2991
- }
2992
- const ei = /* @__PURE__ */ d("$ZodJWT", (e, t) => {
2993
- k.init(e, t), e._zod.check = (n) => {
2994
- Qo(n.value, t.alg) || n.issues.push({
2995
- code: "invalid_format",
2996
- format: "jwt",
2997
- input: n.value,
2998
- inst: e,
2999
- continue: !t.abort
3000
- });
3001
- };
3002
- }), Ot = /* @__PURE__ */ d("$ZodNumber", (e, t) => {
3003
- z.init(e, t), e._zod.pattern = e._zod.bag.pattern ?? St, e._zod.parse = (n, r) => {
3004
- if (t.coerce)
3005
- try {
3006
- n.value = Number(n.value);
3007
- } catch {
3008
- }
3009
- const o = n.value;
3010
- if (typeof o == "number" && !Number.isNaN(o) && Number.isFinite(o))
3011
- return n;
3012
- const i = typeof o == "number" ? Number.isNaN(o) ? "NaN" : Number.isFinite(o) ? void 0 : "Infinity" : void 0;
3013
- return n.issues.push({
3014
- expected: "number",
3015
- code: "invalid_type",
3016
- input: o,
3017
- inst: e,
3018
- ...i ? { received: i } : {}
3019
- }), n;
3020
- };
3021
- }), ti = /* @__PURE__ */ d("$ZodNumberFormat", (e, t) => {
3022
- _o.init(e, t), Ot.init(e, t);
3023
- }), ni = /* @__PURE__ */ d("$ZodBoolean", (e, t) => {
3024
- z.init(e, t), e._zod.pattern = po, e._zod.parse = (n, r) => {
3025
- if (t.coerce)
3026
- try {
3027
- n.value = !!n.value;
3028
- } catch {
3029
- }
3030
- const o = n.value;
3031
- return typeof o == "boolean" || n.issues.push({
3032
- expected: "boolean",
3033
- code: "invalid_type",
3034
- input: o,
3035
- inst: e
3036
- }), n;
3037
- };
3038
- }), ri = /* @__PURE__ */ d("$ZodUnknown", (e, t) => {
3039
- z.init(e, t), e._zod.parse = (n) => n;
3040
- }), oi = /* @__PURE__ */ d("$ZodNever", (e, t) => {
3041
- z.init(e, t), e._zod.parse = (n, r) => (n.issues.push({
3042
- expected: "never",
3043
- code: "invalid_type",
3044
- input: n.value,
3045
- inst: e
3046
- }), n);
3047
- });
3048
- function xe(e, t, n) {
3049
- e.issues.length && t.issues.push(...W(n, e.issues)), t.value[n] = e.value;
3050
- }
3051
- const ii = /* @__PURE__ */ d("$ZodArray", (e, t) => {
3052
- z.init(e, t), e._zod.parse = (n, r) => {
3053
- const o = n.value;
3054
- if (!Array.isArray(o))
3055
- return n.issues.push({
3056
- expected: "array",
3057
- code: "invalid_type",
3058
- input: o,
3059
- inst: e
3060
- }), n;
3061
- n.value = Array(o.length);
3062
- const i = [];
3063
- for (let s = 0; s < o.length; s++) {
3064
- const a = o[s], c = t.element._zod.run({
3065
- value: a,
3066
- issues: []
3067
- }, r);
3068
- c instanceof Promise ? i.push(c.then((u) => xe(u, n, s))) : xe(c, n, s);
3069
- }
3070
- return i.length ? Promise.all(i).then(() => n) : n;
3071
- };
3072
- });
3073
- function ae(e, t, n, r, o) {
3074
- if (e.issues.length) {
3075
- if (o && !(n in r))
3076
- return;
3077
- t.issues.push(...W(n, e.issues));
3078
- }
3079
- e.value === void 0 ? n in r && (t.value[n] = void 0) : t.value[n] = e.value;
3080
- }
3081
- function It(e) {
3082
- const t = Object.keys(e.shape);
3083
- for (const r of t)
3084
- if (!e.shape?.[r]?._zod?.traits?.has("$ZodType"))
3085
- throw new Error(`Invalid element at key "${r}": expected a Zod schema`);
3086
- const n = zr(e.shape);
3087
- return {
3088
- ...e,
3089
- keys: t,
3090
- keySet: new Set(t),
3091
- numKeys: t.length,
3092
- optionalKeys: new Set(n)
3093
- };
3094
- }
3095
- function At(e, t, n, r, o, i) {
3096
- const s = [], a = o.keySet, c = o.catchall._zod, u = c.def.type, l = c.optout === "optional";
3097
- for (const f in t) {
3098
- if (a.has(f))
3099
- continue;
3100
- if (u === "never") {
3101
- s.push(f);
3102
- continue;
3103
- }
3104
- const p = c.run({ value: t[f], issues: [] }, r);
3105
- p instanceof Promise ? e.push(p.then((g) => ae(g, n, f, t, l))) : ae(p, n, f, t, l);
3106
- }
3107
- return s.length && n.issues.push({
3108
- code: "unrecognized_keys",
3109
- keys: s,
3110
- input: t,
3111
- inst: i
3112
- }), e.length ? Promise.all(e).then(() => n) : n;
3113
- }
3114
- const si = /* @__PURE__ */ d("$ZodObject", (e, t) => {
3115
- if (z.init(e, t), !Object.getOwnPropertyDescriptor(t, "shape")?.get) {
3116
- const a = t.shape;
3117
- Object.defineProperty(t, "shape", {
3118
- get: () => {
3119
- const c = { ...a };
3120
- return Object.defineProperty(t, "shape", {
3121
- value: c
3122
- }), c;
3123
- }
3124
- });
3125
- }
3126
- const r = ze(() => It(t));
3127
- v(e._zod, "propValues", () => {
3128
- const a = t.shape, c = {};
3129
- for (const u in a) {
3130
- const l = a[u]._zod;
3131
- if (l.values) {
3132
- c[u] ?? (c[u] = /* @__PURE__ */ new Set());
3133
- for (const f of l.values)
3134
- c[u].add(f);
3135
- }
3136
- }
3137
- return c;
3138
- });
3139
- const o = se, i = t.catchall;
3140
- let s;
3141
- e._zod.parse = (a, c) => {
3142
- s ?? (s = r.value);
3143
- const u = a.value;
3144
- if (!o(u))
3145
- return a.issues.push({
3146
- expected: "object",
3147
- code: "invalid_type",
3148
- input: u,
3149
- inst: e
3150
- }), a;
3151
- a.value = {};
3152
- const l = [], f = s.shape;
3153
- for (const p of s.keys) {
3154
- const g = f[p], y = g._zod.optout === "optional", _ = g._zod.run({ value: u[p], issues: [] }, c);
3155
- _ instanceof Promise ? l.push(_.then((m) => ae(m, a, p, u, y))) : ae(_, a, p, u, y);
3156
- }
3157
- return i ? At(l, u, a, c, r.value, e) : l.length ? Promise.all(l).then(() => a) : a;
3158
- };
3159
- }), ai = /* @__PURE__ */ d("$ZodObjectJIT", (e, t) => {
3160
- si.init(e, t);
3161
- const n = e._zod.parse, r = ze(() => It(t)), o = (p) => {
3162
- const g = new Zo(["shape", "payload", "ctx"]), y = r.value, _ = (C) => {
3163
- const I = Ue(C);
3164
- return `shape[${I}]._zod.run({ value: input[${I}], issues: [] }, ctx)`;
3165
- };
3166
- g.write("const input = payload.value;");
3167
- const m = /* @__PURE__ */ Object.create(null);
3168
- let b = 0;
3169
- for (const C of y.keys)
3170
- m[C] = `key_${b++}`;
3171
- g.write("const newResult = {};");
3172
- for (const C of y.keys) {
3173
- const I = m[C], N = Ue(C), Jt = p[C]?._zod?.optout === "optional";
3174
- g.write(`const ${I} = ${_(C)};`), Jt ? g.write(`
3175
- if (${I}.issues.length) {
3176
- if (${N} in input) {
3177
- payload.issues = payload.issues.concat(${I}.issues.map(iss => ({
3178
- ...iss,
3179
- path: iss.path ? [${N}, ...iss.path] : [${N}]
3180
- })));
3181
- }
3182
- }
3183
-
3184
- if (${I}.value === undefined) {
3185
- if (${N} in input) {
3186
- newResult[${N}] = undefined;
3187
- }
3188
- } else {
3189
- newResult[${N}] = ${I}.value;
3190
- }
3191
-
3192
- `) : g.write(`
3193
- if (${I}.issues.length) {
3194
- payload.issues = payload.issues.concat(${I}.issues.map(iss => ({
3195
- ...iss,
3196
- path: iss.path ? [${N}, ...iss.path] : [${N}]
3197
- })));
3198
- }
3199
-
3200
- if (${I}.value === undefined) {
3201
- if (${N} in input) {
3202
- newResult[${N}] = undefined;
3203
- }
3204
- } else {
3205
- newResult[${N}] = ${I}.value;
3206
- }
3207
-
3208
- `);
3209
- }
3210
- g.write("payload.value = newResult;"), g.write("return payload;");
3211
- const Z = g.compile();
3212
- return (C, I) => Z(p, C, I);
3213
- };
3214
- let i;
3215
- const s = se, a = !gt.jitless, u = a && br.value, l = t.catchall;
3216
- let f;
3217
- e._zod.parse = (p, g) => {
3218
- f ?? (f = r.value);
3219
- const y = p.value;
3220
- return s(y) ? a && u && g?.async === !1 && g.jitless !== !0 ? (i || (i = o(t.shape)), p = i(p, g), l ? At([], y, p, g, f, e) : p) : n(p, g) : (p.issues.push({
3221
- expected: "object",
3222
- code: "invalid_type",
3223
- input: y,
3224
- inst: e
3225
- }), p);
3226
- };
3227
- });
3228
- function Fe(e, t, n, r) {
3229
- for (const i of e)
3230
- if (i.issues.length === 0)
3231
- return t.value = i.value, t;
3232
- const o = e.filter((i) => !V(i));
3233
- return o.length === 1 ? (t.value = o[0].value, o[0]) : (t.issues.push({
3234
- code: "invalid_union",
3235
- input: t.value,
3236
- inst: n,
3237
- errors: e.map((i) => i.issues.map((s) => U(s, r, L())))
3238
- }), t);
3239
- }
3240
- const ci = /* @__PURE__ */ d("$ZodUnion", (e, t) => {
3241
- z.init(e, t), v(e._zod, "optin", () => t.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0), v(e._zod, "optout", () => t.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0), v(e._zod, "values", () => {
3242
- if (t.options.every((o) => o._zod.values))
3243
- return new Set(t.options.flatMap((o) => Array.from(o._zod.values)));
3244
- }), v(e._zod, "pattern", () => {
3245
- if (t.options.every((o) => o._zod.pattern)) {
3246
- const o = t.options.map((i) => i._zod.pattern);
3247
- return new RegExp(`^(${o.map((i) => $e(i.source)).join("|")})$`);
3248
- }
3249
- });
3250
- const n = t.options.length === 1, r = t.options[0]._zod.run;
3251
- e._zod.parse = (o, i) => {
3252
- if (n)
3253
- return r(o, i);
3254
- let s = !1;
3255
- const a = [];
3256
- for (const c of t.options) {
3257
- const u = c._zod.run({
3258
- value: o.value,
3259
- issues: []
3260
- }, i);
3261
- if (u instanceof Promise)
3262
- a.push(u), s = !0;
3263
- else {
3264
- if (u.issues.length === 0)
3265
- return u;
3266
- a.push(u);
3267
- }
3268
- }
3269
- return s ? Promise.all(a).then((c) => Fe(c, o, e, i)) : Fe(a, o, e, i);
3270
- };
3271
- }), ui = /* @__PURE__ */ d("$ZodIntersection", (e, t) => {
3272
- z.init(e, t), e._zod.parse = (n, r) => {
3273
- const o = n.value, i = t.left._zod.run({ value: o, issues: [] }, r), s = t.right._zod.run({ value: o, issues: [] }, r);
3274
- return i instanceof Promise || s instanceof Promise ? Promise.all([i, s]).then(([c, u]) => Je(n, c, u)) : Je(n, i, s);
3275
- };
3276
- });
3277
- function ve(e, t) {
3278
- if (e === t)
3279
- return { valid: !0, data: e };
3280
- if (e instanceof Date && t instanceof Date && +e == +t)
3281
- return { valid: !0, data: e };
3282
- if (B(e) && B(t)) {
3283
- const n = Object.keys(t), r = Object.keys(e).filter((i) => n.indexOf(i) !== -1), o = { ...e, ...t };
3284
- for (const i of r) {
3285
- const s = ve(e[i], t[i]);
3286
- if (!s.valid)
3287
- return {
3288
- valid: !1,
3289
- mergeErrorPath: [i, ...s.mergeErrorPath]
3290
- };
3291
- o[i] = s.data;
3292
- }
3293
- return { valid: !0, data: o };
3294
- }
3295
- if (Array.isArray(e) && Array.isArray(t)) {
3296
- if (e.length !== t.length)
3297
- return { valid: !1, mergeErrorPath: [] };
3298
- const n = [];
3299
- for (let r = 0; r < e.length; r++) {
3300
- const o = e[r], i = t[r], s = ve(o, i);
3301
- if (!s.valid)
3302
- return {
3303
- valid: !1,
3304
- mergeErrorPath: [r, ...s.mergeErrorPath]
3305
- };
3306
- n.push(s.data);
3307
- }
3308
- return { valid: !0, data: n };
3309
- }
3310
- return { valid: !1, mergeErrorPath: [] };
3311
- }
3312
- function Je(e, t, n) {
3313
- const r = /* @__PURE__ */ new Map();
3314
- let o;
3315
- for (const a of t.issues)
3316
- if (a.code === "unrecognized_keys") {
3317
- o ?? (o = a);
3318
- for (const c of a.keys)
3319
- r.has(c) || r.set(c, {}), r.get(c).l = !0;
3320
- } else
3321
- e.issues.push(a);
3322
- for (const a of n.issues)
3323
- if (a.code === "unrecognized_keys")
3324
- for (const c of a.keys)
3325
- r.has(c) || r.set(c, {}), r.get(c).r = !0;
3326
- else
3327
- e.issues.push(a);
3328
- const i = [...r].filter(([, a]) => a.l && a.r).map(([a]) => a);
3329
- if (i.length && o && e.issues.push({ ...o, keys: i }), V(e))
3330
- return e;
3331
- const s = ve(t.value, n.value);
3332
- if (!s.valid)
3333
- throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);
3334
- return e.value = s.data, e;
3335
- }
3336
- const di = /* @__PURE__ */ d("$ZodRecord", (e, t) => {
3337
- z.init(e, t), e._zod.parse = (n, r) => {
3338
- const o = n.value;
3339
- if (!B(o))
3340
- return n.issues.push({
3341
- expected: "record",
3342
- code: "invalid_type",
3343
- input: o,
3344
- inst: e
3345
- }), n;
3346
- const i = [], s = t.keyType._zod.values;
3347
- if (s) {
3348
- n.value = {};
3349
- const a = /* @__PURE__ */ new Set();
3350
- for (const u of s)
3351
- if (typeof u == "string" || typeof u == "number" || typeof u == "symbol") {
3352
- a.add(typeof u == "number" ? u.toString() : u);
3353
- const l = t.valueType._zod.run({ value: o[u], issues: [] }, r);
3354
- l instanceof Promise ? i.push(l.then((f) => {
3355
- f.issues.length && n.issues.push(...W(u, f.issues)), n.value[u] = f.value;
3356
- })) : (l.issues.length && n.issues.push(...W(u, l.issues)), n.value[u] = l.value);
3357
- }
3358
- let c;
3359
- for (const u in o)
3360
- a.has(u) || (c = c ?? [], c.push(u));
3361
- c && c.length > 0 && n.issues.push({
3362
- code: "unrecognized_keys",
3363
- input: o,
3364
- inst: e,
3365
- keys: c
3366
- });
3367
- } else {
3368
- n.value = {};
3369
- for (const a of Reflect.ownKeys(o)) {
3370
- if (a === "__proto__")
3371
- continue;
3372
- let c = t.keyType._zod.run({ value: a, issues: [] }, r);
3373
- if (c instanceof Promise)
3374
- throw new Error("Async schemas not supported in object keys currently");
3375
- if (typeof a == "string" && St.test(a) && c.issues.length) {
3376
- const f = t.keyType._zod.run({ value: Number(a), issues: [] }, r);
3377
- if (f instanceof Promise)
3378
- throw new Error("Async schemas not supported in object keys currently");
3379
- f.issues.length === 0 && (c = f);
3380
- }
3381
- if (c.issues.length) {
3382
- t.mode === "loose" ? n.value[a] = o[a] : n.issues.push({
3383
- code: "invalid_key",
3384
- origin: "record",
3385
- issues: c.issues.map((f) => U(f, r, L())),
3386
- input: a,
3387
- path: [a],
3388
- inst: e
3389
- });
3390
- continue;
3391
- }
3392
- const l = t.valueType._zod.run({ value: o[a], issues: [] }, r);
3393
- l instanceof Promise ? i.push(l.then((f) => {
3394
- f.issues.length && n.issues.push(...W(a, f.issues)), n.value[c.value] = f.value;
3395
- })) : (l.issues.length && n.issues.push(...W(a, l.issues)), n.value[c.value] = l.value);
3396
- }
3397
- }
3398
- return i.length ? Promise.all(i).then(() => n) : n;
3399
- };
3400
- }), li = /* @__PURE__ */ d("$ZodEnum", (e, t) => {
3401
- z.init(e, t);
3402
- const n = ht(t.entries), r = new Set(n);
3403
- e._zod.values = r, e._zod.pattern = new RegExp(`^(${n.filter((o) => kr.has(typeof o)).map((o) => typeof o == "string" ? K(o) : o.toString()).join("|")})$`), e._zod.parse = (o, i) => {
3404
- const s = o.value;
3405
- return r.has(s) || o.issues.push({
3406
- code: "invalid_value",
3407
- values: n,
3408
- input: s,
3409
- inst: e
3410
- }), o;
3411
- };
3412
- }), fi = /* @__PURE__ */ d("$ZodLiteral", (e, t) => {
3413
- if (z.init(e, t), t.values.length === 0)
3414
- throw new Error("Cannot create literal schema with no valid values");
3415
- const n = new Set(t.values);
3416
- e._zod.values = n, e._zod.pattern = new RegExp(`^(${t.values.map((r) => typeof r == "string" ? K(r) : r ? K(r.toString()) : String(r)).join("|")})$`), e._zod.parse = (r, o) => {
3417
- const i = r.value;
3418
- return n.has(i) || r.issues.push({
3419
- code: "invalid_value",
3420
- values: t.values,
3421
- input: i,
3422
- inst: e
3423
- }), r;
3424
- };
3425
- }), pi = /* @__PURE__ */ d("$ZodTransform", (e, t) => {
3426
- z.init(e, t), e._zod.parse = (n, r) => {
3427
- if (r.direction === "backward")
3428
- throw new pt(e.constructor.name);
3429
- const o = t.transform(n.value, n);
3430
- if (r.async)
3431
- return (o instanceof Promise ? o : Promise.resolve(o)).then((s) => (n.value = s, n));
3432
- if (o instanceof Promise)
3433
- throw new G();
3434
- return n.value = o, n;
3435
- };
3436
- });
3437
- function qe(e, t) {
3438
- return e.issues.length && t === void 0 ? { issues: [], value: void 0 } : e;
3439
- }
3440
- const Pt = /* @__PURE__ */ d("$ZodOptional", (e, t) => {
3441
- z.init(e, t), e._zod.optin = "optional", e._zod.optout = "optional", v(e._zod, "values", () => t.innerType._zod.values ? /* @__PURE__ */ new Set([...t.innerType._zod.values, void 0]) : void 0), v(e._zod, "pattern", () => {
3442
- const n = t.innerType._zod.pattern;
3443
- return n ? new RegExp(`^(${$e(n.source)})?$`) : void 0;
3444
- }), e._zod.parse = (n, r) => {
3445
- if (t.innerType._zod.optin === "optional") {
3446
- const o = t.innerType._zod.run(n, r);
3447
- return o instanceof Promise ? o.then((i) => qe(i, n.value)) : qe(o, n.value);
3448
- }
3449
- return n.value === void 0 ? n : t.innerType._zod.run(n, r);
3450
- };
3451
- }), gi = /* @__PURE__ */ d("$ZodExactOptional", (e, t) => {
3452
- Pt.init(e, t), v(e._zod, "values", () => t.innerType._zod.values), v(e._zod, "pattern", () => t.innerType._zod.pattern), e._zod.parse = (n, r) => t.innerType._zod.run(n, r);
3453
- }), hi = /* @__PURE__ */ d("$ZodNullable", (e, t) => {
3454
- z.init(e, t), v(e._zod, "optin", () => t.innerType._zod.optin), v(e._zod, "optout", () => t.innerType._zod.optout), v(e._zod, "pattern", () => {
3455
- const n = t.innerType._zod.pattern;
3456
- return n ? new RegExp(`^(${$e(n.source)}|null)$`) : void 0;
3457
- }), v(e._zod, "values", () => t.innerType._zod.values ? /* @__PURE__ */ new Set([...t.innerType._zod.values, null]) : void 0), e._zod.parse = (n, r) => n.value === null ? n : t.innerType._zod.run(n, r);
3458
- }), mi = /* @__PURE__ */ d("$ZodDefault", (e, t) => {
3459
- z.init(e, t), e._zod.optin = "optional", v(e._zod, "values", () => t.innerType._zod.values), e._zod.parse = (n, r) => {
3460
- if (r.direction === "backward")
3461
- return t.innerType._zod.run(n, r);
3462
- if (n.value === void 0)
3463
- return n.value = t.defaultValue, n;
3464
- const o = t.innerType._zod.run(n, r);
3465
- return o instanceof Promise ? o.then((i) => Ve(i, t)) : Ve(o, t);
3466
- };
3467
- });
3468
- function Ve(e, t) {
3469
- return e.value === void 0 && (e.value = t.defaultValue), e;
3470
- }
3471
- const _i = /* @__PURE__ */ d("$ZodPrefault", (e, t) => {
3472
- z.init(e, t), e._zod.optin = "optional", v(e._zod, "values", () => t.innerType._zod.values), e._zod.parse = (n, r) => (r.direction === "backward" || n.value === void 0 && (n.value = t.defaultValue), t.innerType._zod.run(n, r));
3473
- }), yi = /* @__PURE__ */ d("$ZodNonOptional", (e, t) => {
3474
- z.init(e, t), v(e._zod, "values", () => {
3475
- const n = t.innerType._zod.values;
3476
- return n ? new Set([...n].filter((r) => r !== void 0)) : void 0;
3477
- }), e._zod.parse = (n, r) => {
3478
- const o = t.innerType._zod.run(n, r);
3479
- return o instanceof Promise ? o.then((i) => We(i, e)) : We(o, e);
3480
- };
3481
- });
3482
- function We(e, t) {
3483
- return !e.issues.length && e.value === void 0 && e.issues.push({
3484
- code: "invalid_type",
3485
- expected: "nonoptional",
3486
- input: e.value,
3487
- inst: t
3488
- }), e;
3489
- }
3490
- const vi = /* @__PURE__ */ d("$ZodCatch", (e, t) => {
3491
- z.init(e, t), v(e._zod, "optin", () => t.innerType._zod.optin), v(e._zod, "optout", () => t.innerType._zod.optout), v(e._zod, "values", () => t.innerType._zod.values), e._zod.parse = (n, r) => {
3492
- if (r.direction === "backward")
3493
- return t.innerType._zod.run(n, r);
3494
- const o = t.innerType._zod.run(n, r);
3495
- return o instanceof Promise ? o.then((i) => (n.value = i.value, i.issues.length && (n.value = t.catchValue({
3496
- ...n,
3497
- error: {
3498
- issues: i.issues.map((s) => U(s, r, L()))
3499
- },
3500
- input: n.value
3501
- }), n.issues = []), n)) : (n.value = o.value, o.issues.length && (n.value = t.catchValue({
3502
- ...n,
3503
- error: {
3504
- issues: o.issues.map((i) => U(i, r, L()))
3505
- },
3506
- input: n.value
3507
- }), n.issues = []), n);
3508
- };
3509
- }), wi = /* @__PURE__ */ d("$ZodPipe", (e, t) => {
3510
- z.init(e, t), v(e._zod, "values", () => t.in._zod.values), v(e._zod, "optin", () => t.in._zod.optin), v(e._zod, "optout", () => t.out._zod.optout), v(e._zod, "propValues", () => t.in._zod.propValues), e._zod.parse = (n, r) => {
3511
- if (r.direction === "backward") {
3512
- const i = t.out._zod.run(n, r);
3513
- return i instanceof Promise ? i.then((s) => oe(s, t.in, r)) : oe(i, t.in, r);
3514
- }
3515
- const o = t.in._zod.run(n, r);
3516
- return o instanceof Promise ? o.then((i) => oe(i, t.out, r)) : oe(o, t.out, r);
3517
- };
3518
- });
3519
- function oe(e, t, n) {
3520
- return e.issues.length ? (e.aborted = !0, e) : t._zod.run({ value: e.value, issues: e.issues }, n);
3521
- }
3522
- const bi = /* @__PURE__ */ d("$ZodReadonly", (e, t) => {
3523
- z.init(e, t), v(e._zod, "propValues", () => t.innerType._zod.propValues), v(e._zod, "values", () => t.innerType._zod.values), v(e._zod, "optin", () => t.innerType?._zod?.optin), v(e._zod, "optout", () => t.innerType?._zod?.optout), e._zod.parse = (n, r) => {
3524
- if (r.direction === "backward")
3525
- return t.innerType._zod.run(n, r);
3526
- const o = t.innerType._zod.run(n, r);
3527
- return o instanceof Promise ? o.then(Ge) : Ge(o);
3528
- };
3529
- });
3530
- function Ge(e) {
3531
- return e.value = Object.freeze(e.value), e;
3532
- }
3533
- const ki = /* @__PURE__ */ d("$ZodCustom", (e, t) => {
3534
- A.init(e, t), z.init(e, t), e._zod.parse = (n, r) => n, e._zod.check = (n) => {
3535
- const r = n.value, o = t.fn(r);
3536
- if (o instanceof Promise)
3537
- return o.then((i) => Be(i, n, r, e));
3538
- Be(o, n, r, e);
3539
- };
3540
- });
3541
- function Be(e, t, n, r) {
3542
- if (!e) {
3543
- const o = {
3544
- code: "custom",
3545
- input: n,
3546
- inst: r,
3547
- // incorporates params.error into issue reporting
3548
- path: [...r._zod.def.path ?? []],
3549
- // incorporates params.error into issue reporting
3550
- continue: !r._zod.def.abort
3551
- // params: inst._zod.def.params,
3552
- };
3553
- r._zod.def.params && (o.params = r._zod.def.params), t.issues.push(ne(o));
3554
- }
3555
- }
3556
- var Ke;
3557
- class zi {
3558
- constructor() {
3559
- this._map = /* @__PURE__ */ new WeakMap(), this._idmap = /* @__PURE__ */ new Map();
3560
- }
3561
- add(t, ...n) {
3562
- const r = n[0];
3563
- return this._map.set(t, r), r && typeof r == "object" && "id" in r && this._idmap.set(r.id, t), this;
3564
- }
3565
- clear() {
3566
- return this._map = /* @__PURE__ */ new WeakMap(), this._idmap = /* @__PURE__ */ new Map(), this;
3567
- }
3568
- remove(t) {
3569
- const n = this._map.get(t);
3570
- return n && typeof n == "object" && "id" in n && this._idmap.delete(n.id), this._map.delete(t), this;
3571
- }
3572
- get(t) {
3573
- const n = t._zod.parent;
3574
- if (n) {
3575
- const r = { ...this.get(n) ?? {} };
3576
- delete r.id;
3577
- const o = { ...r, ...this._map.get(t) };
3578
- return Object.keys(o).length ? o : void 0;
3579
- }
3580
- return this._map.get(t);
3581
- }
3582
- has(t) {
3583
- return this._map.has(t);
3584
- }
3585
- }
3586
- function Si() {
3587
- return new zi();
3588
- }
3589
- (Ke = globalThis).__zod_globalRegistry ?? (Ke.__zod_globalRegistry = Si());
3590
- const ee = globalThis.__zod_globalRegistry;
3591
- // @__NO_SIDE_EFFECTS__
3592
- function $i(e, t) {
3593
- return new e({
3594
- type: "string",
3595
- ...h(t)
3596
- });
3597
- }
3598
- // @__NO_SIDE_EFFECTS__
3599
- function Ei(e, t) {
3600
- return new e({
3601
- type: "string",
3602
- format: "email",
3603
- check: "string_format",
3604
- abort: !1,
3605
- ...h(t)
3606
- });
3607
- }
3608
- // @__NO_SIDE_EFFECTS__
3609
- function He(e, t) {
3610
- return new e({
3611
- type: "string",
3612
- format: "guid",
3613
- check: "string_format",
3614
- abort: !1,
3615
- ...h(t)
3616
- });
3617
- }
3618
- // @__NO_SIDE_EFFECTS__
3619
- function Ti(e, t) {
3620
- return new e({
3621
- type: "string",
3622
- format: "uuid",
3623
- check: "string_format",
3624
- abort: !1,
3625
- ...h(t)
3626
- });
3627
- }
3628
- // @__NO_SIDE_EFFECTS__
3629
- function Zi(e, t) {
3630
- return new e({
3631
- type: "string",
3632
- format: "uuid",
3633
- check: "string_format",
3634
- abort: !1,
3635
- version: "v4",
3636
- ...h(t)
3637
- });
3638
- }
3639
- // @__NO_SIDE_EFFECTS__
3640
- function Oi(e, t) {
3641
- return new e({
3642
- type: "string",
3643
- format: "uuid",
3644
- check: "string_format",
3645
- abort: !1,
3646
- version: "v6",
3647
- ...h(t)
3648
- });
3649
- }
3650
- // @__NO_SIDE_EFFECTS__
3651
- function Ii(e, t) {
3652
- return new e({
3653
- type: "string",
3654
- format: "uuid",
3655
- check: "string_format",
3656
- abort: !1,
3657
- version: "v7",
3658
- ...h(t)
3659
- });
3660
- }
3661
- // @__NO_SIDE_EFFECTS__
3662
- function Ai(e, t) {
3663
- return new e({
3664
- type: "string",
3665
- format: "url",
3666
- check: "string_format",
3667
- abort: !1,
3668
- ...h(t)
3669
- });
3670
- }
3671
- // @__NO_SIDE_EFFECTS__
3672
- function Pi(e, t) {
3673
- return new e({
3674
- type: "string",
3675
- format: "emoji",
3676
- check: "string_format",
3677
- abort: !1,
3678
- ...h(t)
3679
- });
3680
- }
3681
- // @__NO_SIDE_EFFECTS__
3682
- function Ni(e, t) {
3683
- return new e({
3684
- type: "string",
3685
- format: "nanoid",
3686
- check: "string_format",
3687
- abort: !1,
3688
- ...h(t)
3689
- });
3690
- }
3691
- // @__NO_SIDE_EFFECTS__
3692
- function Ci(e, t) {
3693
- return new e({
3694
- type: "string",
3695
- format: "cuid",
3696
- check: "string_format",
3697
- abort: !1,
3698
- ...h(t)
3699
- });
3700
- }
3701
- // @__NO_SIDE_EFFECTS__
3702
- function Ri(e, t) {
3703
- return new e({
3704
- type: "string",
3705
- format: "cuid2",
3706
- check: "string_format",
3707
- abort: !1,
3708
- ...h(t)
3709
- });
3710
- }
3711
- // @__NO_SIDE_EFFECTS__
3712
- function ji(e, t) {
3713
- return new e({
3714
- type: "string",
3715
- format: "ulid",
3716
- check: "string_format",
3717
- abort: !1,
3718
- ...h(t)
3719
- });
3720
- }
3721
- // @__NO_SIDE_EFFECTS__
3722
- function Di(e, t) {
3723
- return new e({
3724
- type: "string",
3725
- format: "xid",
3726
- check: "string_format",
3727
- abort: !1,
3728
- ...h(t)
3729
- });
3730
- }
3731
- // @__NO_SIDE_EFFECTS__
3732
- function Li(e, t) {
3733
- return new e({
3734
- type: "string",
3735
- format: "ksuid",
3736
- check: "string_format",
3737
- abort: !1,
3738
- ...h(t)
3739
- });
3740
- }
3741
- // @__NO_SIDE_EFFECTS__
3742
- function Ui(e, t) {
3743
- return new e({
3744
- type: "string",
3745
- format: "ipv4",
3746
- check: "string_format",
3747
- abort: !1,
3748
- ...h(t)
3749
- });
3750
- }
3751
- // @__NO_SIDE_EFFECTS__
3752
- function Mi(e, t) {
3753
- return new e({
3754
- type: "string",
3755
- format: "ipv6",
3756
- check: "string_format",
3757
- abort: !1,
3758
- ...h(t)
3759
- });
3760
- }
3761
- // @__NO_SIDE_EFFECTS__
3762
- function xi(e, t) {
3763
- return new e({
3764
- type: "string",
3765
- format: "cidrv4",
3766
- check: "string_format",
3767
- abort: !1,
3768
- ...h(t)
3769
- });
3770
- }
3771
- // @__NO_SIDE_EFFECTS__
3772
- function Fi(e, t) {
3773
- return new e({
3774
- type: "string",
3775
- format: "cidrv6",
3776
- check: "string_format",
3777
- abort: !1,
3778
- ...h(t)
3779
- });
3780
- }
3781
- // @__NO_SIDE_EFFECTS__
3782
- function Ji(e, t) {
3783
- return new e({
3784
- type: "string",
3785
- format: "base64",
3786
- check: "string_format",
3787
- abort: !1,
3788
- ...h(t)
3789
- });
3790
- }
3791
- // @__NO_SIDE_EFFECTS__
3792
- function qi(e, t) {
3793
- return new e({
3794
- type: "string",
3795
- format: "base64url",
3796
- check: "string_format",
3797
- abort: !1,
3798
- ...h(t)
3799
- });
3800
- }
3801
- // @__NO_SIDE_EFFECTS__
3802
- function Vi(e, t) {
3803
- return new e({
3804
- type: "string",
3805
- format: "e164",
3806
- check: "string_format",
3807
- abort: !1,
3808
- ...h(t)
3809
- });
3810
- }
3811
- // @__NO_SIDE_EFFECTS__
3812
- function Wi(e, t) {
3813
- return new e({
3814
- type: "string",
3815
- format: "jwt",
3816
- check: "string_format",
3817
- abort: !1,
3818
- ...h(t)
3819
- });
3820
- }
3821
- // @__NO_SIDE_EFFECTS__
3822
- function Gi(e, t) {
3823
- return new e({
3824
- type: "string",
3825
- format: "datetime",
3826
- check: "string_format",
3827
- offset: !1,
3828
- local: !1,
3829
- precision: null,
3830
- ...h(t)
3831
- });
3832
- }
3833
- // @__NO_SIDE_EFFECTS__
3834
- function Bi(e, t) {
3835
- return new e({
3836
- type: "string",
3837
- format: "date",
3838
- check: "string_format",
3839
- ...h(t)
3840
- });
3841
- }
3842
- // @__NO_SIDE_EFFECTS__
3843
- function Ki(e, t) {
3844
- return new e({
3845
- type: "string",
3846
- format: "time",
3847
- check: "string_format",
3848
- precision: null,
3849
- ...h(t)
3850
- });
3851
- }
3852
- // @__NO_SIDE_EFFECTS__
3853
- function Hi(e, t) {
3854
- return new e({
3855
- type: "string",
3856
- format: "duration",
3857
- check: "string_format",
3858
- ...h(t)
3859
- });
3860
- }
3861
- // @__NO_SIDE_EFFECTS__
3862
- function Yi(e, t) {
3863
- return new e({
3864
- type: "number",
3865
- checks: [],
3866
- ...h(t)
3867
- });
3868
- }
3869
- // @__NO_SIDE_EFFECTS__
3870
- function Xi(e, t) {
3871
- return new e({
3872
- type: "number",
3873
- check: "number_format",
3874
- abort: !1,
3875
- format: "safeint",
3876
- ...h(t)
3877
- });
3878
- }
3879
- // @__NO_SIDE_EFFECTS__
3880
- function Qi(e, t) {
3881
- return new e({
3882
- type: "boolean",
3883
- ...h(t)
3884
- });
3885
- }
3886
- // @__NO_SIDE_EFFECTS__
3887
- function es(e) {
3888
- return new e({
3889
- type: "unknown"
3890
- });
3891
- }
3892
- // @__NO_SIDE_EFFECTS__
3893
- function ts(e, t) {
3894
- return new e({
3895
- type: "never",
3896
- ...h(t)
3897
- });
3898
- }
3899
- // @__NO_SIDE_EFFECTS__
3900
- function Ye(e, t) {
3901
- return new Et({
3902
- check: "less_than",
3903
- ...h(t),
3904
- value: e,
3905
- inclusive: !1
3906
- });
3907
- }
3908
- // @__NO_SIDE_EFFECTS__
3909
- function ge(e, t) {
3910
- return new Et({
3911
- check: "less_than",
3912
- ...h(t),
3913
- value: e,
3914
- inclusive: !0
3915
- });
3916
- }
3917
- // @__NO_SIDE_EFFECTS__
3918
- function Xe(e, t) {
3919
- return new Tt({
3920
- check: "greater_than",
3921
- ...h(t),
3922
- value: e,
3923
- inclusive: !1
3924
- });
3925
- }
3926
- // @__NO_SIDE_EFFECTS__
3927
- function he(e, t) {
3928
- return new Tt({
3929
- check: "greater_than",
3930
- ...h(t),
3931
- value: e,
3932
- inclusive: !0
3933
- });
3934
- }
3935
- // @__NO_SIDE_EFFECTS__
3936
- function Qe(e, t) {
3937
- return new mo({
3938
- check: "multiple_of",
3939
- ...h(t),
3940
- value: e
3941
- });
3942
- }
3943
- // @__NO_SIDE_EFFECTS__
3944
- function Nt(e, t) {
3945
- return new yo({
3946
- check: "max_length",
3947
- ...h(t),
3948
- maximum: e
3949
- });
3950
- }
3951
- // @__NO_SIDE_EFFECTS__
3952
- function ce(e, t) {
3953
- return new vo({
3954
- check: "min_length",
3955
- ...h(t),
3956
- minimum: e
3957
- });
3958
- }
3959
- // @__NO_SIDE_EFFECTS__
3960
- function Ct(e, t) {
3961
- return new wo({
3962
- check: "length_equals",
3963
- ...h(t),
3964
- length: e
3965
- });
3966
- }
3967
- // @__NO_SIDE_EFFECTS__
3968
- function ns(e, t) {
3969
- return new bo({
3970
- check: "string_format",
3971
- format: "regex",
3972
- ...h(t),
3973
- pattern: e
3974
- });
3975
- }
3976
- // @__NO_SIDE_EFFECTS__
3977
- function rs(e) {
3978
- return new ko({
3979
- check: "string_format",
3980
- format: "lowercase",
3981
- ...h(e)
3982
- });
3983
- }
3984
- // @__NO_SIDE_EFFECTS__
3985
- function os(e) {
3986
- return new zo({
3987
- check: "string_format",
3988
- format: "uppercase",
3989
- ...h(e)
3990
- });
3991
- }
3992
- // @__NO_SIDE_EFFECTS__
3993
- function is(e, t) {
3994
- return new So({
3995
- check: "string_format",
3996
- format: "includes",
3997
- ...h(t),
3998
- includes: e
3999
- });
4000
- }
4001
- // @__NO_SIDE_EFFECTS__
4002
- function ss(e, t) {
4003
- return new $o({
4004
- check: "string_format",
4005
- format: "starts_with",
4006
- ...h(t),
4007
- prefix: e
4008
- });
4009
- }
4010
- // @__NO_SIDE_EFFECTS__
4011
- function as(e, t) {
4012
- return new Eo({
4013
- check: "string_format",
4014
- format: "ends_with",
4015
- ...h(t),
4016
- suffix: e
4017
- });
4018
- }
4019
- // @__NO_SIDE_EFFECTS__
4020
- function H(e) {
4021
- return new To({
4022
- check: "overwrite",
4023
- tx: e
4024
- });
4025
- }
4026
- // @__NO_SIDE_EFFECTS__
4027
- function cs(e) {
4028
- return /* @__PURE__ */ H((t) => t.normalize(e));
4029
- }
4030
- // @__NO_SIDE_EFFECTS__
4031
- function us() {
4032
- return /* @__PURE__ */ H((e) => e.trim());
4033
- }
4034
- // @__NO_SIDE_EFFECTS__
4035
- function ds() {
4036
- return /* @__PURE__ */ H((e) => e.toLowerCase());
4037
- }
4038
- // @__NO_SIDE_EFFECTS__
4039
- function ls() {
4040
- return /* @__PURE__ */ H((e) => e.toUpperCase());
4041
- }
4042
- // @__NO_SIDE_EFFECTS__
4043
- function fs() {
4044
- return /* @__PURE__ */ H((e) => wr(e));
4045
- }
4046
- // @__NO_SIDE_EFFECTS__
4047
- function ps(e, t, n) {
4048
- return new e({
4049
- type: "array",
4050
- element: t,
4051
- // get element() {
4052
- // return element;
4053
- // },
4054
- ...h(n)
4055
- });
4056
- }
4057
- // @__NO_SIDE_EFFECTS__
4058
- function gs(e, t, n) {
4059
- return new e({
4060
- type: "custom",
4061
- check: "custom",
4062
- fn: t,
4063
- ...h(n)
4064
- });
4065
- }
4066
- // @__NO_SIDE_EFFECTS__
4067
- function hs(e) {
4068
- const t = /* @__PURE__ */ ms((n) => (n.addIssue = (r) => {
4069
- if (typeof r == "string")
4070
- n.issues.push(ne(r, n.value, t._zod.def));
4071
- else {
4072
- const o = r;
4073
- o.fatal && (o.continue = !1), o.code ?? (o.code = "custom"), o.input ?? (o.input = n.value), o.inst ?? (o.inst = t), o.continue ?? (o.continue = !t._zod.def.abort), n.issues.push(ne(o));
4074
- }
4075
- }, e(n.value, n)));
4076
- return t;
4077
- }
4078
- // @__NO_SIDE_EFFECTS__
4079
- function ms(e, t) {
4080
- const n = new A({
4081
- check: "custom",
4082
- ...h(t)
4083
- });
4084
- return n._zod.check = e, n;
4085
- }
4086
- function Rt(e) {
4087
- let t = e?.target ?? "draft-2020-12";
4088
- return t === "draft-4" && (t = "draft-04"), t === "draft-7" && (t = "draft-07"), {
4089
- processors: e.processors ?? {},
4090
- metadataRegistry: e?.metadata ?? ee,
4091
- target: t,
4092
- unrepresentable: e?.unrepresentable ?? "throw",
4093
- override: e?.override ?? (() => {
4094
- }),
4095
- io: e?.io ?? "output",
4096
- counter: 0,
4097
- seen: /* @__PURE__ */ new Map(),
4098
- cycles: e?.cycles ?? "ref",
4099
- reused: e?.reused ?? "inline",
4100
- external: e?.external ?? void 0
4101
- };
4102
- }
4103
- function E(e, t, n = { path: [], schemaPath: [] }) {
4104
- var r;
4105
- const o = e._zod.def, i = t.seen.get(e);
4106
- if (i)
4107
- return i.count++, n.schemaPath.includes(e) && (i.cycle = n.path), i.schema;
4108
- const s = { schema: {}, count: 1, cycle: void 0, path: n.path };
4109
- t.seen.set(e, s);
4110
- const a = e._zod.toJSONSchema?.();
4111
- if (a)
4112
- s.schema = a;
4113
- else {
4114
- const l = {
4115
- ...n,
4116
- schemaPath: [...n.schemaPath, e],
4117
- path: n.path
4118
- };
4119
- if (e._zod.processJSONSchema)
4120
- e._zod.processJSONSchema(t, s.schema, l);
4121
- else {
4122
- const p = s.schema, g = t.processors[o.type];
4123
- if (!g)
4124
- throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);
4125
- g(e, t, p, l);
4126
- }
4127
- const f = e._zod.parent;
4128
- f && (s.ref || (s.ref = f), E(f, t, l), t.seen.get(f).isParent = !0);
4129
- }
4130
- const c = t.metadataRegistry.get(e);
4131
- return c && Object.assign(s.schema, c), t.io === "input" && O(e) && (delete s.schema.examples, delete s.schema.default), t.io === "input" && s.schema._prefault && ((r = s.schema).default ?? (r.default = s.schema._prefault)), delete s.schema._prefault, t.seen.get(e).schema;
4132
- }
4133
- function jt(e, t) {
4134
- const n = e.seen.get(t);
4135
- if (!n)
4136
- throw new Error("Unprocessed schema. This is a bug in Zod.");
4137
- const r = /* @__PURE__ */ new Map();
4138
- for (const s of e.seen.entries()) {
4139
- const a = e.metadataRegistry.get(s[0])?.id;
4140
- if (a) {
4141
- const c = r.get(a);
4142
- if (c && c !== s[0])
4143
- throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
4144
- r.set(a, s[0]);
4145
- }
4146
- }
4147
- const o = (s) => {
4148
- const a = e.target === "draft-2020-12" ? "$defs" : "definitions";
4149
- if (e.external) {
4150
- const f = e.external.registry.get(s[0])?.id, p = e.external.uri ?? ((y) => y);
4151
- if (f)
4152
- return { ref: p(f) };
4153
- const g = s[1].defId ?? s[1].schema.id ?? `schema${e.counter++}`;
4154
- return s[1].defId = g, { defId: g, ref: `${p("__shared")}#/${a}/${g}` };
4155
- }
4156
- if (s[1] === n)
4157
- return { ref: "#" };
4158
- const u = `#/${a}/`, l = s[1].schema.id ?? `__schema${e.counter++}`;
4159
- return { defId: l, ref: u + l };
4160
- }, i = (s) => {
4161
- if (s[1].schema.$ref)
4162
- return;
4163
- const a = s[1], { ref: c, defId: u } = o(s);
4164
- a.def = { ...a.schema }, u && (a.defId = u);
4165
- const l = a.schema;
4166
- for (const f in l)
4167
- delete l[f];
4168
- l.$ref = c;
4169
- };
4170
- if (e.cycles === "throw")
4171
- for (const s of e.seen.entries()) {
4172
- const a = s[1];
4173
- if (a.cycle)
4174
- throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
4175
-
4176
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
4177
- }
4178
- for (const s of e.seen.entries()) {
4179
- const a = s[1];
4180
- if (t === s[0]) {
4181
- i(s);
4182
- continue;
4183
- }
4184
- if (e.external) {
4185
- const u = e.external.registry.get(s[0])?.id;
4186
- if (t !== s[0] && u) {
4187
- i(s);
4188
- continue;
4189
- }
4190
- }
4191
- if (e.metadataRegistry.get(s[0])?.id) {
4192
- i(s);
4193
- continue;
4194
- }
4195
- if (a.cycle) {
4196
- i(s);
4197
- continue;
4198
- }
4199
- if (a.count > 1 && e.reused === "ref") {
4200
- i(s);
4201
- continue;
4202
- }
4203
- }
4204
- }
4205
- function Dt(e, t) {
4206
- const n = e.seen.get(t);
4207
- if (!n)
4208
- throw new Error("Unprocessed schema. This is a bug in Zod.");
4209
- const r = (s) => {
4210
- const a = e.seen.get(s);
4211
- if (a.ref === null)
4212
- return;
4213
- const c = a.def ?? a.schema, u = { ...c }, l = a.ref;
4214
- if (a.ref = null, l) {
4215
- r(l);
4216
- const p = e.seen.get(l), g = p.schema;
4217
- if (g.$ref && (e.target === "draft-07" || e.target === "draft-04" || e.target === "openapi-3.0") ? (c.allOf = c.allOf ?? [], c.allOf.push(g)) : Object.assign(c, g), Object.assign(c, u), s._zod.parent === l)
4218
- for (const _ in c)
4219
- _ === "$ref" || _ === "allOf" || _ in u || delete c[_];
4220
- if (g.$ref && p.def)
4221
- for (const _ in c)
4222
- _ === "$ref" || _ === "allOf" || _ in p.def && JSON.stringify(c[_]) === JSON.stringify(p.def[_]) && delete c[_];
4223
- }
4224
- const f = s._zod.parent;
4225
- if (f && f !== l) {
4226
- r(f);
4227
- const p = e.seen.get(f);
4228
- if (p?.schema.$ref && (c.$ref = p.schema.$ref, p.def))
4229
- for (const g in c)
4230
- g === "$ref" || g === "allOf" || g in p.def && JSON.stringify(c[g]) === JSON.stringify(p.def[g]) && delete c[g];
4231
- }
4232
- e.override({
4233
- zodSchema: s,
4234
- jsonSchema: c,
4235
- path: a.path ?? []
4236
- });
4237
- };
4238
- for (const s of [...e.seen.entries()].reverse())
4239
- r(s[0]);
4240
- const o = {};
4241
- if (e.target === "draft-2020-12" ? o.$schema = "https://json-schema.org/draft/2020-12/schema" : e.target === "draft-07" ? o.$schema = "http://json-schema.org/draft-07/schema#" : e.target === "draft-04" ? o.$schema = "http://json-schema.org/draft-04/schema#" : e.target, e.external?.uri) {
4242
- const s = e.external.registry.get(t)?.id;
4243
- if (!s)
4244
- throw new Error("Schema is missing an `id` property");
4245
- o.$id = e.external.uri(s);
4246
- }
4247
- Object.assign(o, n.def ?? n.schema);
4248
- const i = e.external?.defs ?? {};
4249
- for (const s of e.seen.entries()) {
4250
- const a = s[1];
4251
- a.def && a.defId && (i[a.defId] = a.def);
4252
- }
4253
- e.external || Object.keys(i).length > 0 && (e.target === "draft-2020-12" ? o.$defs = i : o.definitions = i);
4254
- try {
4255
- const s = JSON.parse(JSON.stringify(o));
4256
- return Object.defineProperty(s, "~standard", {
4257
- value: {
4258
- ...t["~standard"],
4259
- jsonSchema: {
4260
- input: ue(t, "input", e.processors),
4261
- output: ue(t, "output", e.processors)
4262
- }
4263
- },
4264
- enumerable: !1,
4265
- writable: !1
4266
- }), s;
4267
- } catch {
4268
- throw new Error("Error converting schema to JSON.");
4269
- }
4270
- }
4271
- function O(e, t) {
4272
- const n = t ?? { seen: /* @__PURE__ */ new Set() };
4273
- if (n.seen.has(e))
4274
- return !1;
4275
- n.seen.add(e);
4276
- const r = e._zod.def;
4277
- if (r.type === "transform")
4278
- return !0;
4279
- if (r.type === "array")
4280
- return O(r.element, n);
4281
- if (r.type === "set")
4282
- return O(r.valueType, n);
4283
- if (r.type === "lazy")
4284
- return O(r.getter(), n);
4285
- if (r.type === "promise" || r.type === "optional" || r.type === "nonoptional" || r.type === "nullable" || r.type === "readonly" || r.type === "default" || r.type === "prefault")
4286
- return O(r.innerType, n);
4287
- if (r.type === "intersection")
4288
- return O(r.left, n) || O(r.right, n);
4289
- if (r.type === "record" || r.type === "map")
4290
- return O(r.keyType, n) || O(r.valueType, n);
4291
- if (r.type === "pipe")
4292
- return O(r.in, n) || O(r.out, n);
4293
- if (r.type === "object") {
4294
- for (const o in r.shape)
4295
- if (O(r.shape[o], n))
4296
- return !0;
4297
- return !1;
4298
- }
4299
- if (r.type === "union") {
4300
- for (const o of r.options)
4301
- if (O(o, n))
4302
- return !0;
4303
- return !1;
4304
- }
4305
- if (r.type === "tuple") {
4306
- for (const o of r.items)
4307
- if (O(o, n))
4308
- return !0;
4309
- return !!(r.rest && O(r.rest, n));
4310
- }
4311
- return !1;
4312
- }
4313
- const _s = (e, t = {}) => (n) => {
4314
- const r = Rt({ ...n, processors: t });
4315
- return E(e, r), jt(r, e), Dt(r, e);
4316
- }, ue = (e, t, n = {}) => (r) => {
4317
- const { libraryOptions: o, target: i } = r ?? {}, s = Rt({ ...o ?? {}, target: i, io: t, processors: n });
4318
- return E(e, s), jt(s, e), Dt(s, e);
4319
- }, ys = {
4320
- guid: "uuid",
4321
- url: "uri",
4322
- datetime: "date-time",
4323
- json_string: "json-string",
4324
- regex: ""
4325
- // do not set
4326
- }, vs = (e, t, n, r) => {
4327
- const o = n;
4328
- o.type = "string";
4329
- const { minimum: i, maximum: s, format: a, patterns: c, contentEncoding: u } = e._zod.bag;
4330
- if (typeof i == "number" && (o.minLength = i), typeof s == "number" && (o.maxLength = s), a && (o.format = ys[a] ?? a, o.format === "" && delete o.format, a === "time" && delete o.format), u && (o.contentEncoding = u), c && c.size > 0) {
4331
- const l = [...c];
4332
- l.length === 1 ? o.pattern = l[0].source : l.length > 1 && (o.allOf = [
4333
- ...l.map((f) => ({
4334
- ...t.target === "draft-07" || t.target === "draft-04" || t.target === "openapi-3.0" ? { type: "string" } : {},
4335
- pattern: f.source
4336
- }))
4337
- ]);
4338
- }
4339
- }, ws = (e, t, n, r) => {
4340
- const o = n, { minimum: i, maximum: s, format: a, multipleOf: c, exclusiveMaximum: u, exclusiveMinimum: l } = e._zod.bag;
4341
- typeof a == "string" && a.includes("int") ? o.type = "integer" : o.type = "number", typeof l == "number" && (t.target === "draft-04" || t.target === "openapi-3.0" ? (o.minimum = l, o.exclusiveMinimum = !0) : o.exclusiveMinimum = l), typeof i == "number" && (o.minimum = i, typeof l == "number" && t.target !== "draft-04" && (l >= i ? delete o.minimum : delete o.exclusiveMinimum)), typeof u == "number" && (t.target === "draft-04" || t.target === "openapi-3.0" ? (o.maximum = u, o.exclusiveMaximum = !0) : o.exclusiveMaximum = u), typeof s == "number" && (o.maximum = s, typeof u == "number" && t.target !== "draft-04" && (u <= s ? delete o.maximum : delete o.exclusiveMaximum)), typeof c == "number" && (o.multipleOf = c);
4342
- }, bs = (e, t, n, r) => {
4343
- n.type = "boolean";
4344
- }, ks = (e, t, n, r) => {
4345
- n.not = {};
4346
- }, zs = (e, t, n, r) => {
4347
- }, Ss = (e, t, n, r) => {
4348
- const o = e._zod.def, i = ht(o.entries);
4349
- i.every((s) => typeof s == "number") && (n.type = "number"), i.every((s) => typeof s == "string") && (n.type = "string"), n.enum = i;
4350
- }, $s = (e, t, n, r) => {
4351
- const o = e._zod.def, i = [];
4352
- for (const s of o.values)
4353
- if (s === void 0) {
4354
- if (t.unrepresentable === "throw")
4355
- throw new Error("Literal `undefined` cannot be represented in JSON Schema");
4356
- } else if (typeof s == "bigint") {
4357
- if (t.unrepresentable === "throw")
4358
- throw new Error("BigInt literals cannot be represented in JSON Schema");
4359
- i.push(Number(s));
4360
- } else
4361
- i.push(s);
4362
- if (i.length !== 0) if (i.length === 1) {
4363
- const s = i[0];
4364
- n.type = s === null ? "null" : typeof s, t.target === "draft-04" || t.target === "openapi-3.0" ? n.enum = [s] : n.const = s;
4365
- } else
4366
- i.every((s) => typeof s == "number") && (n.type = "number"), i.every((s) => typeof s == "string") && (n.type = "string"), i.every((s) => typeof s == "boolean") && (n.type = "boolean"), i.every((s) => s === null) && (n.type = "null"), n.enum = i;
4367
- }, Es = (e, t, n, r) => {
4368
- if (t.unrepresentable === "throw")
4369
- throw new Error("Custom types cannot be represented in JSON Schema");
4370
- }, Ts = (e, t, n, r) => {
4371
- if (t.unrepresentable === "throw")
4372
- throw new Error("Transforms cannot be represented in JSON Schema");
4373
- }, Zs = (e, t, n, r) => {
4374
- const o = n, i = e._zod.def, { minimum: s, maximum: a } = e._zod.bag;
4375
- typeof s == "number" && (o.minItems = s), typeof a == "number" && (o.maxItems = a), o.type = "array", o.items = E(i.element, t, { ...r, path: [...r.path, "items"] });
4376
- }, Os = (e, t, n, r) => {
4377
- const o = n, i = e._zod.def;
4378
- o.type = "object", o.properties = {};
4379
- const s = i.shape;
4380
- for (const u in s)
4381
- o.properties[u] = E(s[u], t, {
4382
- ...r,
4383
- path: [...r.path, "properties", u]
4384
- });
4385
- const a = new Set(Object.keys(s)), c = new Set([...a].filter((u) => {
4386
- const l = i.shape[u]._zod;
4387
- return t.io === "input" ? l.optin === void 0 : l.optout === void 0;
4388
- }));
4389
- c.size > 0 && (o.required = Array.from(c)), i.catchall?._zod.def.type === "never" ? o.additionalProperties = !1 : i.catchall ? i.catchall && (o.additionalProperties = E(i.catchall, t, {
4390
- ...r,
4391
- path: [...r.path, "additionalProperties"]
4392
- })) : t.io === "output" && (o.additionalProperties = !1);
4393
- }, Is = (e, t, n, r) => {
4394
- const o = e._zod.def, i = o.inclusive === !1, s = o.options.map((a, c) => E(a, t, {
4395
- ...r,
4396
- path: [...r.path, i ? "oneOf" : "anyOf", c]
4397
- }));
4398
- i ? n.oneOf = s : n.anyOf = s;
4399
- }, As = (e, t, n, r) => {
4400
- const o = e._zod.def, i = E(o.left, t, {
4401
- ...r,
4402
- path: [...r.path, "allOf", 0]
4403
- }), s = E(o.right, t, {
4404
- ...r,
4405
- path: [...r.path, "allOf", 1]
4406
- }), a = (u) => "allOf" in u && Object.keys(u).length === 1, c = [
4407
- ...a(i) ? i.allOf : [i],
4408
- ...a(s) ? s.allOf : [s]
4409
- ];
4410
- n.allOf = c;
4411
- }, Ps = (e, t, n, r) => {
4412
- const o = n, i = e._zod.def;
4413
- o.type = "object";
4414
- const s = i.keyType, c = s._zod.bag?.patterns;
4415
- if (i.mode === "loose" && c && c.size > 0) {
4416
- const l = E(i.valueType, t, {
4417
- ...r,
4418
- path: [...r.path, "patternProperties", "*"]
4419
- });
4420
- o.patternProperties = {};
4421
- for (const f of c)
4422
- o.patternProperties[f.source] = l;
4423
- } else
4424
- (t.target === "draft-07" || t.target === "draft-2020-12") && (o.propertyNames = E(i.keyType, t, {
4425
- ...r,
4426
- path: [...r.path, "propertyNames"]
4427
- })), o.additionalProperties = E(i.valueType, t, {
4428
- ...r,
4429
- path: [...r.path, "additionalProperties"]
4430
- });
4431
- const u = s._zod.values;
4432
- if (u) {
4433
- const l = [...u].filter((f) => typeof f == "string" || typeof f == "number");
4434
- l.length > 0 && (o.required = l);
4435
- }
4436
- }, Ns = (e, t, n, r) => {
4437
- const o = e._zod.def, i = E(o.innerType, t, r), s = t.seen.get(e);
4438
- t.target === "openapi-3.0" ? (s.ref = o.innerType, n.nullable = !0) : n.anyOf = [i, { type: "null" }];
4439
- }, Cs = (e, t, n, r) => {
4440
- const o = e._zod.def;
4441
- E(o.innerType, t, r);
4442
- const i = t.seen.get(e);
4443
- i.ref = o.innerType;
4444
- }, Rs = (e, t, n, r) => {
4445
- const o = e._zod.def;
4446
- E(o.innerType, t, r);
4447
- const i = t.seen.get(e);
4448
- i.ref = o.innerType, n.default = JSON.parse(JSON.stringify(o.defaultValue));
4449
- }, js = (e, t, n, r) => {
4450
- const o = e._zod.def;
4451
- E(o.innerType, t, r);
4452
- const i = t.seen.get(e);
4453
- i.ref = o.innerType, t.io === "input" && (n._prefault = JSON.parse(JSON.stringify(o.defaultValue)));
4454
- }, Ds = (e, t, n, r) => {
4455
- const o = e._zod.def;
4456
- E(o.innerType, t, r);
4457
- const i = t.seen.get(e);
4458
- i.ref = o.innerType;
4459
- let s;
4460
- try {
4461
- s = o.catchValue(void 0);
4462
- } catch {
4463
- throw new Error("Dynamic catch values are not supported in JSON Schema");
4464
- }
4465
- n.default = s;
4466
- }, Ls = (e, t, n, r) => {
4467
- const o = e._zod.def, i = t.io === "input" ? o.in._zod.def.type === "transform" ? o.out : o.in : o.out;
4468
- E(i, t, r);
4469
- const s = t.seen.get(e);
4470
- s.ref = i;
4471
- }, Us = (e, t, n, r) => {
4472
- const o = e._zod.def;
4473
- E(o.innerType, t, r);
4474
- const i = t.seen.get(e);
4475
- i.ref = o.innerType, n.readOnly = !0;
4476
- }, Lt = (e, t, n, r) => {
4477
- const o = e._zod.def;
4478
- E(o.innerType, t, r);
4479
- const i = t.seen.get(e);
4480
- i.ref = o.innerType;
4481
- }, Ms = /* @__PURE__ */ d("ZodISODateTime", (e, t) => {
4482
- xo.init(e, t), $.init(e, t);
4483
- });
4484
- function xs(e) {
4485
- return /* @__PURE__ */ Gi(Ms, e);
4486
- }
4487
- const Fs = /* @__PURE__ */ d("ZodISODate", (e, t) => {
4488
- Fo.init(e, t), $.init(e, t);
4489
- });
4490
- function Js(e) {
4491
- return /* @__PURE__ */ Bi(Fs, e);
4492
- }
4493
- const qs = /* @__PURE__ */ d("ZodISOTime", (e, t) => {
4494
- Jo.init(e, t), $.init(e, t);
4495
- });
4496
- function Vs(e) {
4497
- return /* @__PURE__ */ Ki(qs, e);
4498
- }
4499
- const Ws = /* @__PURE__ */ d("ZodISODuration", (e, t) => {
4500
- qo.init(e, t), $.init(e, t);
4501
- });
4502
- function Gs(e) {
4503
- return /* @__PURE__ */ Hi(Ws, e);
4504
- }
4505
- const Bs = (e, t) => {
4506
- vt.init(e, t), e.name = "ZodError", Object.defineProperties(e, {
4507
- format: {
4508
- value: (n) => Nr(e, n)
4509
- // enumerable: false,
4510
- },
4511
- flatten: {
4512
- value: (n) => Pr(e, n)
4513
- // enumerable: false,
4514
- },
4515
- addIssue: {
4516
- value: (n) => {
4517
- e.issues.push(n), e.message = JSON.stringify(e.issues, ye, 2);
4518
- }
4519
- // enumerable: false,
4520
- },
4521
- addIssues: {
4522
- value: (n) => {
4523
- e.issues.push(...n), e.message = JSON.stringify(e.issues, ye, 2);
4524
- }
4525
- // enumerable: false,
4526
- },
4527
- isEmpty: {
4528
- get() {
4529
- return e.issues.length === 0;
4530
- }
4531
- // enumerable: false,
4532
- }
4533
- });
4534
- }, P = d("ZodError", Bs, {
4535
- Parent: Error
4536
- }), Ks = /* @__PURE__ */ Te(P), Hs = /* @__PURE__ */ Ze(P), Ys = /* @__PURE__ */ de(P), Xs = /* @__PURE__ */ le(P), Qs = /* @__PURE__ */ jr(P), ea = /* @__PURE__ */ Dr(P), ta = /* @__PURE__ */ Lr(P), na = /* @__PURE__ */ Ur(P), ra = /* @__PURE__ */ Mr(P), oa = /* @__PURE__ */ xr(P), ia = /* @__PURE__ */ Fr(P), sa = /* @__PURE__ */ Jr(P), S = /* @__PURE__ */ d("ZodType", (e, t) => (z.init(e, t), Object.assign(e["~standard"], {
4537
- jsonSchema: {
4538
- input: ue(e, "input"),
4539
- output: ue(e, "output")
4540
- }
4541
- }), e.toJSONSchema = _s(e, {}), e.def = t, e.type = t.type, Object.defineProperty(e, "_def", { value: t }), e.check = (...n) => e.clone(x(t, {
4542
- checks: [
4543
- ...t.checks ?? [],
4544
- ...n.map((r) => typeof r == "function" ? { _zod: { check: r, def: { check: "custom" }, onattach: [] } } : r)
4545
- ]
4546
- }), {
4547
- parent: !0
4548
- }), e.with = e.check, e.clone = (n, r) => F(e, n, r), e.brand = () => e, e.register = ((n, r) => (n.add(e, r), e)), e.parse = (n, r) => Ks(e, n, r, { callee: e.parse }), e.safeParse = (n, r) => Ys(e, n, r), e.parseAsync = async (n, r) => Hs(e, n, r, { callee: e.parseAsync }), e.safeParseAsync = async (n, r) => Xs(e, n, r), e.spa = e.safeParseAsync, e.encode = (n, r) => Qs(e, n, r), e.decode = (n, r) => ea(e, n, r), e.encodeAsync = async (n, r) => ta(e, n, r), e.decodeAsync = async (n, r) => na(e, n, r), e.safeEncode = (n, r) => ra(e, n, r), e.safeDecode = (n, r) => oa(e, n, r), e.safeEncodeAsync = async (n, r) => ia(e, n, r), e.safeDecodeAsync = async (n, r) => sa(e, n, r), e.refine = (n, r) => e.check(nc(n, r)), e.superRefine = (n) => e.check(rc(n)), e.overwrite = (n) => e.check(/* @__PURE__ */ H(n)), e.optional = () => rt(e), e.exactOptional = () => Ja(e), e.nullable = () => ot(e), e.nullish = () => rt(ot(e)), e.nonoptional = (n) => Ka(e, n), e.array = () => Aa(e), e.or = (n) => Ca([e, n]), e.and = (n) => ja(e, n), e.transform = (n) => it(e, xa(n)), e.default = (n) => Wa(e, n), e.prefault = (n) => Ba(e, n), e.catch = (n) => Ya(e, n), e.pipe = (n) => it(e, n), e.readonly = () => ec(e), e.describe = (n) => {
4549
- const r = e.clone();
4550
- return ee.add(r, { description: n }), r;
4551
- }, Object.defineProperty(e, "description", {
4552
- get() {
4553
- return ee.get(e)?.description;
4554
- },
4555
- configurable: !0
4556
- }), e.meta = (...n) => {
4557
- if (n.length === 0)
4558
- return ee.get(e);
4559
- const r = e.clone();
4560
- return ee.add(r, n[0]), r;
4561
- }, e.isOptional = () => e.safeParse(void 0).success, e.isNullable = () => e.safeParse(null).success, e.apply = (n) => n(e), e)), Ut = /* @__PURE__ */ d("_ZodString", (e, t) => {
4562
- Oe.init(e, t), S.init(e, t), e._zod.processJSONSchema = (r, o, i) => vs(e, r, o);
4563
- const n = e._zod.bag;
4564
- e.format = n.format ?? null, e.minLength = n.minimum ?? null, e.maxLength = n.maximum ?? null, e.regex = (...r) => e.check(/* @__PURE__ */ ns(...r)), e.includes = (...r) => e.check(/* @__PURE__ */ is(...r)), e.startsWith = (...r) => e.check(/* @__PURE__ */ ss(...r)), e.endsWith = (...r) => e.check(/* @__PURE__ */ as(...r)), e.min = (...r) => e.check(/* @__PURE__ */ ce(...r)), e.max = (...r) => e.check(/* @__PURE__ */ Nt(...r)), e.length = (...r) => e.check(/* @__PURE__ */ Ct(...r)), e.nonempty = (...r) => e.check(/* @__PURE__ */ ce(1, ...r)), e.lowercase = (r) => e.check(/* @__PURE__ */ rs(r)), e.uppercase = (r) => e.check(/* @__PURE__ */ os(r)), e.trim = () => e.check(/* @__PURE__ */ us()), e.normalize = (...r) => e.check(/* @__PURE__ */ cs(...r)), e.toLowerCase = () => e.check(/* @__PURE__ */ ds()), e.toUpperCase = () => e.check(/* @__PURE__ */ ls()), e.slugify = () => e.check(/* @__PURE__ */ fs());
4565
- }), aa = /* @__PURE__ */ d("ZodString", (e, t) => {
4566
- Oe.init(e, t), Ut.init(e, t), e.email = (n) => e.check(/* @__PURE__ */ Ei(ca, n)), e.url = (n) => e.check(/* @__PURE__ */ Ai(ua, n)), e.jwt = (n) => e.check(/* @__PURE__ */ Wi(Sa, n)), e.emoji = (n) => e.check(/* @__PURE__ */ Pi(da, n)), e.guid = (n) => e.check(/* @__PURE__ */ He(et, n)), e.uuid = (n) => e.check(/* @__PURE__ */ Ti(ie, n)), e.uuidv4 = (n) => e.check(/* @__PURE__ */ Zi(ie, n)), e.uuidv6 = (n) => e.check(/* @__PURE__ */ Oi(ie, n)), e.uuidv7 = (n) => e.check(/* @__PURE__ */ Ii(ie, n)), e.nanoid = (n) => e.check(/* @__PURE__ */ Ni(la, n)), e.guid = (n) => e.check(/* @__PURE__ */ He(et, n)), e.cuid = (n) => e.check(/* @__PURE__ */ Ci(fa, n)), e.cuid2 = (n) => e.check(/* @__PURE__ */ Ri(pa, n)), e.ulid = (n) => e.check(/* @__PURE__ */ ji(ga, n)), e.base64 = (n) => e.check(/* @__PURE__ */ Ji(ba, n)), e.base64url = (n) => e.check(/* @__PURE__ */ qi(ka, n)), e.xid = (n) => e.check(/* @__PURE__ */ Di(ha, n)), e.ksuid = (n) => e.check(/* @__PURE__ */ Li(ma, n)), e.ipv4 = (n) => e.check(/* @__PURE__ */ Ui(_a, n)), e.ipv6 = (n) => e.check(/* @__PURE__ */ Mi(ya, n)), e.cidrv4 = (n) => e.check(/* @__PURE__ */ xi(va, n)), e.cidrv6 = (n) => e.check(/* @__PURE__ */ Fi(wa, n)), e.e164 = (n) => e.check(/* @__PURE__ */ Vi(za, n)), e.datetime = (n) => e.check(xs(n)), e.date = (n) => e.check(Js(n)), e.time = (n) => e.check(Vs(n)), e.duration = (n) => e.check(Gs(n));
4567
- });
4568
- function qc(e) {
4569
- return /* @__PURE__ */ $i(aa, e);
4570
- }
4571
- const $ = /* @__PURE__ */ d("ZodStringFormat", (e, t) => {
4572
- k.init(e, t), Ut.init(e, t);
4573
- }), ca = /* @__PURE__ */ d("ZodEmail", (e, t) => {
4574
- Po.init(e, t), $.init(e, t);
4575
- }), et = /* @__PURE__ */ d("ZodGUID", (e, t) => {
4576
- Io.init(e, t), $.init(e, t);
4577
- }), ie = /* @__PURE__ */ d("ZodUUID", (e, t) => {
4578
- Ao.init(e, t), $.init(e, t);
4579
- }), ua = /* @__PURE__ */ d("ZodURL", (e, t) => {
4580
- No.init(e, t), $.init(e, t);
4581
- }), da = /* @__PURE__ */ d("ZodEmoji", (e, t) => {
4582
- Co.init(e, t), $.init(e, t);
4583
- }), la = /* @__PURE__ */ d("ZodNanoID", (e, t) => {
4584
- Ro.init(e, t), $.init(e, t);
4585
- }), fa = /* @__PURE__ */ d("ZodCUID", (e, t) => {
4586
- jo.init(e, t), $.init(e, t);
4587
- }), pa = /* @__PURE__ */ d("ZodCUID2", (e, t) => {
4588
- Do.init(e, t), $.init(e, t);
4589
- }), ga = /* @__PURE__ */ d("ZodULID", (e, t) => {
4590
- Lo.init(e, t), $.init(e, t);
4591
- }), ha = /* @__PURE__ */ d("ZodXID", (e, t) => {
4592
- Uo.init(e, t), $.init(e, t);
4593
- }), ma = /* @__PURE__ */ d("ZodKSUID", (e, t) => {
4594
- Mo.init(e, t), $.init(e, t);
4595
- }), _a = /* @__PURE__ */ d("ZodIPv4", (e, t) => {
4596
- Vo.init(e, t), $.init(e, t);
4597
- }), ya = /* @__PURE__ */ d("ZodIPv6", (e, t) => {
4598
- Wo.init(e, t), $.init(e, t);
4599
- }), va = /* @__PURE__ */ d("ZodCIDRv4", (e, t) => {
4600
- Go.init(e, t), $.init(e, t);
4601
- }), wa = /* @__PURE__ */ d("ZodCIDRv6", (e, t) => {
4602
- Bo.init(e, t), $.init(e, t);
4603
- }), ba = /* @__PURE__ */ d("ZodBase64", (e, t) => {
4604
- Ko.init(e, t), $.init(e, t);
4605
- }), ka = /* @__PURE__ */ d("ZodBase64URL", (e, t) => {
4606
- Yo.init(e, t), $.init(e, t);
4607
- }), za = /* @__PURE__ */ d("ZodE164", (e, t) => {
4608
- Xo.init(e, t), $.init(e, t);
4609
- }), Sa = /* @__PURE__ */ d("ZodJWT", (e, t) => {
4610
- ei.init(e, t), $.init(e, t);
4611
- }), Mt = /* @__PURE__ */ d("ZodNumber", (e, t) => {
4612
- Ot.init(e, t), S.init(e, t), e._zod.processJSONSchema = (r, o, i) => ws(e, r, o), e.gt = (r, o) => e.check(/* @__PURE__ */ Xe(r, o)), e.gte = (r, o) => e.check(/* @__PURE__ */ he(r, o)), e.min = (r, o) => e.check(/* @__PURE__ */ he(r, o)), e.lt = (r, o) => e.check(/* @__PURE__ */ Ye(r, o)), e.lte = (r, o) => e.check(/* @__PURE__ */ ge(r, o)), e.max = (r, o) => e.check(/* @__PURE__ */ ge(r, o)), e.int = (r) => e.check(tt(r)), e.safe = (r) => e.check(tt(r)), e.positive = (r) => e.check(/* @__PURE__ */ Xe(0, r)), e.nonnegative = (r) => e.check(/* @__PURE__ */ he(0, r)), e.negative = (r) => e.check(/* @__PURE__ */ Ye(0, r)), e.nonpositive = (r) => e.check(/* @__PURE__ */ ge(0, r)), e.multipleOf = (r, o) => e.check(/* @__PURE__ */ Qe(r, o)), e.step = (r, o) => e.check(/* @__PURE__ */ Qe(r, o)), e.finite = () => e;
4613
- const n = e._zod.bag;
4614
- e.minValue = Math.max(n.minimum ?? Number.NEGATIVE_INFINITY, n.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null, e.maxValue = Math.min(n.maximum ?? Number.POSITIVE_INFINITY, n.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null, e.isInt = (n.format ?? "").includes("int") || Number.isSafeInteger(n.multipleOf ?? 0.5), e.isFinite = !0, e.format = n.format ?? null;
4615
- });
4616
- function Vc(e) {
4617
- return /* @__PURE__ */ Yi(Mt, e);
4618
- }
4619
- const $a = /* @__PURE__ */ d("ZodNumberFormat", (e, t) => {
4620
- ti.init(e, t), Mt.init(e, t);
4621
- });
4622
- function tt(e) {
4623
- return /* @__PURE__ */ Xi($a, e);
4624
- }
4625
- const Ea = /* @__PURE__ */ d("ZodBoolean", (e, t) => {
4626
- ni.init(e, t), S.init(e, t), e._zod.processJSONSchema = (n, r, o) => bs(e, n, r);
4627
- });
4628
- function Wc(e) {
4629
- return /* @__PURE__ */ Qi(Ea, e);
4630
- }
4631
- const Ta = /* @__PURE__ */ d("ZodUnknown", (e, t) => {
4632
- ri.init(e, t), S.init(e, t), e._zod.processJSONSchema = (n, r, o) => zs();
4633
- });
4634
- function nt() {
4635
- return /* @__PURE__ */ es(Ta);
4636
- }
4637
- const Za = /* @__PURE__ */ d("ZodNever", (e, t) => {
4638
- oi.init(e, t), S.init(e, t), e._zod.processJSONSchema = (n, r, o) => ks(e, n, r);
4639
- });
4640
- function Oa(e) {
4641
- return /* @__PURE__ */ ts(Za, e);
4642
- }
4643
- const Ia = /* @__PURE__ */ d("ZodArray", (e, t) => {
4644
- ii.init(e, t), S.init(e, t), e._zod.processJSONSchema = (n, r, o) => Zs(e, n, r, o), e.element = t.element, e.min = (n, r) => e.check(/* @__PURE__ */ ce(n, r)), e.nonempty = (n) => e.check(/* @__PURE__ */ ce(1, n)), e.max = (n, r) => e.check(/* @__PURE__ */ Nt(n, r)), e.length = (n, r) => e.check(/* @__PURE__ */ Ct(n, r)), e.unwrap = () => e.element;
4645
- });
4646
- function Aa(e, t) {
4647
- return /* @__PURE__ */ ps(Ia, e, t);
4648
- }
4649
- const Pa = /* @__PURE__ */ d("ZodObject", (e, t) => {
4650
- ai.init(e, t), S.init(e, t), e._zod.processJSONSchema = (n, r, o) => Os(e, n, r, o), v(e, "shape", () => t.shape), e.keyof = () => La(Object.keys(e._zod.def.shape)), e.catchall = (n) => e.clone({ ...e._zod.def, catchall: n }), e.passthrough = () => e.clone({ ...e._zod.def, catchall: nt() }), e.loose = () => e.clone({ ...e._zod.def, catchall: nt() }), e.strict = () => e.clone({ ...e._zod.def, catchall: Oa() }), e.strip = () => e.clone({ ...e._zod.def, catchall: void 0 }), e.extend = (n) => Tr(e, n), e.safeExtend = (n) => Zr(e, n), e.merge = (n) => Or(e, n), e.pick = (n) => $r(e, n), e.omit = (n) => Er(e, n), e.partial = (...n) => Ir(xt, e, n[0]), e.required = (...n) => Ar(Ft, e, n[0]);
4651
- });
4652
- function Gc(e, t) {
4653
- const n = {
4654
- type: "object",
4655
- shape: e ?? {},
4656
- ...h(t)
4657
- };
4658
- return new Pa(n);
4659
- }
4660
- const Na = /* @__PURE__ */ d("ZodUnion", (e, t) => {
4661
- ci.init(e, t), S.init(e, t), e._zod.processJSONSchema = (n, r, o) => Is(e, n, r, o), e.options = t.options;
4662
- });
4663
- function Ca(e, t) {
4664
- return new Na({
4665
- type: "union",
4666
- options: e,
4667
- ...h(t)
4668
- });
4669
- }
4670
- const Ra = /* @__PURE__ */ d("ZodIntersection", (e, t) => {
4671
- ui.init(e, t), S.init(e, t), e._zod.processJSONSchema = (n, r, o) => As(e, n, r, o);
4672
- });
4673
- function ja(e, t) {
4674
- return new Ra({
4675
- type: "intersection",
4676
- left: e,
4677
- right: t
4678
- });
4679
- }
4680
- const Da = /* @__PURE__ */ d("ZodRecord", (e, t) => {
4681
- di.init(e, t), S.init(e, t), e._zod.processJSONSchema = (n, r, o) => Ps(e, n, r, o), e.keyType = t.keyType, e.valueType = t.valueType;
4682
- });
4683
- function Bc(e, t, n) {
4684
- return new Da({
4685
- type: "record",
4686
- keyType: e,
4687
- valueType: t,
4688
- ...h(n)
4689
- });
4690
- }
4691
- const we = /* @__PURE__ */ d("ZodEnum", (e, t) => {
4692
- li.init(e, t), S.init(e, t), e._zod.processJSONSchema = (r, o, i) => Ss(e, r, o), e.enum = t.entries, e.options = Object.values(t.entries);
4693
- const n = new Set(Object.keys(t.entries));
4694
- e.extract = (r, o) => {
4695
- const i = {};
4696
- for (const s of r)
4697
- if (n.has(s))
4698
- i[s] = t.entries[s];
4699
- else
4700
- throw new Error(`Key ${s} not found in enum`);
4701
- return new we({
4702
- ...t,
4703
- checks: [],
4704
- ...h(o),
4705
- entries: i
4706
- });
4707
- }, e.exclude = (r, o) => {
4708
- const i = { ...t.entries };
4709
- for (const s of r)
4710
- if (n.has(s))
4711
- delete i[s];
4712
- else
4713
- throw new Error(`Key ${s} not found in enum`);
4714
- return new we({
4715
- ...t,
4716
- checks: [],
4717
- ...h(o),
4718
- entries: i
4719
- });
4720
- };
4721
- });
4722
- function La(e, t) {
4723
- const n = Array.isArray(e) ? Object.fromEntries(e.map((r) => [r, r])) : e;
4724
- return new we({
4725
- type: "enum",
4726
- entries: n,
4727
- ...h(t)
4728
- });
4729
- }
4730
- const Ua = /* @__PURE__ */ d("ZodLiteral", (e, t) => {
4731
- fi.init(e, t), S.init(e, t), e._zod.processJSONSchema = (n, r, o) => $s(e, n, r), e.values = new Set(t.values), Object.defineProperty(e, "value", {
4732
- get() {
4733
- if (t.values.length > 1)
4734
- throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
4735
- return t.values[0];
4736
- }
4737
- });
4738
- });
4739
- function Kc(e, t) {
4740
- return new Ua({
4741
- type: "literal",
4742
- values: Array.isArray(e) ? e : [e],
4743
- ...h(t)
4744
- });
4745
- }
4746
- const Ma = /* @__PURE__ */ d("ZodTransform", (e, t) => {
4747
- pi.init(e, t), S.init(e, t), e._zod.processJSONSchema = (n, r, o) => Ts(e, n), e._zod.parse = (n, r) => {
4748
- if (r.direction === "backward")
4749
- throw new pt(e.constructor.name);
4750
- n.addIssue = (i) => {
4751
- if (typeof i == "string")
4752
- n.issues.push(ne(i, n.value, t));
4753
- else {
4754
- const s = i;
4755
- s.fatal && (s.continue = !1), s.code ?? (s.code = "custom"), s.input ?? (s.input = n.value), s.inst ?? (s.inst = e), n.issues.push(ne(s));
4756
- }
4757
- };
4758
- const o = t.transform(n.value, n);
4759
- return o instanceof Promise ? o.then((i) => (n.value = i, n)) : (n.value = o, n);
4760
- };
4761
- });
4762
- function xa(e) {
4763
- return new Ma({
4764
- type: "transform",
4765
- transform: e
4766
- });
4767
- }
4768
- const xt = /* @__PURE__ */ d("ZodOptional", (e, t) => {
4769
- Pt.init(e, t), S.init(e, t), e._zod.processJSONSchema = (n, r, o) => Lt(e, n, r, o), e.unwrap = () => e._zod.def.innerType;
4770
- });
4771
- function rt(e) {
4772
- return new xt({
4773
- type: "optional",
4774
- innerType: e
4775
- });
4776
- }
4777
- const Fa = /* @__PURE__ */ d("ZodExactOptional", (e, t) => {
4778
- gi.init(e, t), S.init(e, t), e._zod.processJSONSchema = (n, r, o) => Lt(e, n, r, o), e.unwrap = () => e._zod.def.innerType;
4779
- });
4780
- function Ja(e) {
4781
- return new Fa({
4782
- type: "optional",
4783
- innerType: e
4784
- });
4785
- }
4786
- const qa = /* @__PURE__ */ d("ZodNullable", (e, t) => {
4787
- hi.init(e, t), S.init(e, t), e._zod.processJSONSchema = (n, r, o) => Ns(e, n, r, o), e.unwrap = () => e._zod.def.innerType;
4788
- });
4789
- function ot(e) {
4790
- return new qa({
4791
- type: "nullable",
4792
- innerType: e
4793
- });
4794
- }
4795
- const Va = /* @__PURE__ */ d("ZodDefault", (e, t) => {
4796
- mi.init(e, t), S.init(e, t), e._zod.processJSONSchema = (n, r, o) => Rs(e, n, r, o), e.unwrap = () => e._zod.def.innerType, e.removeDefault = e.unwrap;
4797
- });
4798
- function Wa(e, t) {
4799
- return new Va({
4800
- type: "default",
4801
- innerType: e,
4802
- get defaultValue() {
4803
- return typeof t == "function" ? t() : _t(t);
4804
- }
4805
- });
4806
- }
4807
- const Ga = /* @__PURE__ */ d("ZodPrefault", (e, t) => {
4808
- _i.init(e, t), S.init(e, t), e._zod.processJSONSchema = (n, r, o) => js(e, n, r, o), e.unwrap = () => e._zod.def.innerType;
4809
- });
4810
- function Ba(e, t) {
4811
- return new Ga({
4812
- type: "prefault",
4813
- innerType: e,
4814
- get defaultValue() {
4815
- return typeof t == "function" ? t() : _t(t);
4816
- }
4817
- });
4818
- }
4819
- const Ft = /* @__PURE__ */ d("ZodNonOptional", (e, t) => {
4820
- yi.init(e, t), S.init(e, t), e._zod.processJSONSchema = (n, r, o) => Cs(e, n, r, o), e.unwrap = () => e._zod.def.innerType;
4821
- });
4822
- function Ka(e, t) {
4823
- return new Ft({
4824
- type: "nonoptional",
4825
- innerType: e,
4826
- ...h(t)
4827
- });
4828
- }
4829
- const Ha = /* @__PURE__ */ d("ZodCatch", (e, t) => {
4830
- vi.init(e, t), S.init(e, t), e._zod.processJSONSchema = (n, r, o) => Ds(e, n, r, o), e.unwrap = () => e._zod.def.innerType, e.removeCatch = e.unwrap;
4831
- });
4832
- function Ya(e, t) {
4833
- return new Ha({
4834
- type: "catch",
4835
- innerType: e,
4836
- catchValue: typeof t == "function" ? t : () => t
4837
- });
4838
- }
4839
- const Xa = /* @__PURE__ */ d("ZodPipe", (e, t) => {
4840
- wi.init(e, t), S.init(e, t), e._zod.processJSONSchema = (n, r, o) => Ls(e, n, r, o), e.in = t.in, e.out = t.out;
4841
- });
4842
- function it(e, t) {
4843
- return new Xa({
4844
- type: "pipe",
4845
- in: e,
4846
- out: t
4847
- // ...util.normalizeParams(params),
4848
- });
4849
- }
4850
- const Qa = /* @__PURE__ */ d("ZodReadonly", (e, t) => {
4851
- bi.init(e, t), S.init(e, t), e._zod.processJSONSchema = (n, r, o) => Us(e, n, r, o), e.unwrap = () => e._zod.def.innerType;
4852
- });
4853
- function ec(e) {
4854
- return new Qa({
4855
- type: "readonly",
4856
- innerType: e
4857
- });
4858
- }
4859
- const tc = /* @__PURE__ */ d("ZodCustom", (e, t) => {
4860
- ki.init(e, t), S.init(e, t), e._zod.processJSONSchema = (n, r, o) => Es(e, n);
4861
- });
4862
- function nc(e, t = {}) {
4863
- return /* @__PURE__ */ gs(tc, e, t);
4864
- }
4865
- function rc(e) {
4866
- return /* @__PURE__ */ hs(e);
4867
- }
4868
- export {
4869
- bc as $,
4870
- mr as A,
4871
- Ec as B,
4872
- mc as C,
4873
- _e as D,
4874
- at as E,
4875
- yc as F,
4876
- Bc as G,
4877
- Lc as H,
4878
- Mc as I,
4879
- Fc as J,
4880
- Rc as K,
4881
- Nc as L,
4882
- Cc as M,
4883
- Dc as N,
4884
- Pc as O,
4885
- xc as P,
4886
- pc as Q,
4887
- gc as R,
4888
- _r as S,
4889
- fc as T,
4890
- uc as U,
4891
- jc as V,
4892
- Uc as W,
4893
- cc as X,
4894
- Kc as Y,
4895
- nn as Z,
4896
- La as _,
4897
- Zc as a,
4898
- dr as a0,
4899
- Ae as a1,
4900
- tn as a2,
4901
- Gt as a3,
4902
- Wt as a4,
4903
- qt as a5,
4904
- dn as a6,
4905
- bn as a7,
4906
- kn as a8,
4907
- zc as a9,
4908
- te as aa,
4909
- Vt as ab,
4910
- M as ac,
4911
- cn as ad,
4912
- un as ae,
4913
- Tc as af,
4914
- Sc as ag,
4915
- Jc as ah,
4916
- kc as ai,
4917
- rn as aj,
4918
- Ac as b,
4919
- yn as c,
4920
- Wc as d,
4921
- nt as e,
4922
- Aa as f,
4923
- ac as g,
4924
- dc as h,
4925
- De as i,
4926
- wc as j,
4927
- $c as k,
4928
- lc as l,
4929
- sc as m,
4930
- gr as n,
4931
- Gc as o,
4932
- Oc as p,
4933
- Ic as q,
4934
- ic as r,
4935
- qc as s,
4936
- fr as t,
4937
- Ca as u,
4938
- vc as v,
4939
- hc as w,
4940
- _c as x,
4941
- Vc as y,
4942
- hr as z
4943
- };
4944
- //# sourceMappingURL=schemas-5lXjLjwW.js.map