@dolard.eu/versiq-widget 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +55 -0
- package/README.md +401 -0
- package/dist/config.d.ts +6 -0
- package/dist/index.d.ts +64 -0
- package/dist/loader.d.ts +106 -0
- package/dist/logger.d.ts +26 -0
- package/dist/postmessage.d.ts +47 -0
- package/dist/types.d.ts +185 -0
- package/dist/widget.es.js +3352 -0
- package/dist/widget.umd.js +39 -0
- package/package.json +84 -0
|
@@ -0,0 +1,3352 @@
|
|
|
1
|
+
var re = "[Versiq]";
|
|
2
|
+
function fe(e, ...t) {
|
|
3
|
+
console.error(re, e, ...t);
|
|
4
|
+
}
|
|
5
|
+
function Te(e, ...t) {
|
|
6
|
+
console.warn(re, e, ...t);
|
|
7
|
+
}
|
|
8
|
+
function he(e, ...t) {
|
|
9
|
+
console.info(re, e, ...t);
|
|
10
|
+
}
|
|
11
|
+
function X(e, ...t) {
|
|
12
|
+
console.debug(re, e, ...t);
|
|
13
|
+
}
|
|
14
|
+
function Ut(e) {
|
|
15
|
+
return e ? X : () => {
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
var Dt = "versiq:", Ft = [
|
|
19
|
+
"https://versiq.io",
|
|
20
|
+
"https://www.versiq.io",
|
|
21
|
+
"https://app.versiq.io"
|
|
22
|
+
];
|
|
23
|
+
function Lt(e, t) {
|
|
24
|
+
return t.some((r) => e === r || e.endsWith(`.${new URL(r).host}`));
|
|
25
|
+
}
|
|
26
|
+
function Vt(e) {
|
|
27
|
+
const t = e.data;
|
|
28
|
+
return typeof t == "object" && t !== null && typeof t.type == "string" && t.type.startsWith(Dt);
|
|
29
|
+
}
|
|
30
|
+
function x(e, t, r) {
|
|
31
|
+
if (!e.contentWindow) {
|
|
32
|
+
Te("Cannot send command: iframe not ready");
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
e.contentWindow.postMessage(t, r);
|
|
37
|
+
} catch {
|
|
38
|
+
Te("Failed to post message to iframe");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function Jt(e) {
|
|
42
|
+
const { allowedOrigins: t = Ft, onMessage: r, debug: n, sourceWindow: o } = e, a = (i) => {
|
|
43
|
+
if (!(o && i.source && i.source !== o)) {
|
|
44
|
+
if (!Lt(i.origin, t)) {
|
|
45
|
+
n && X("Ignored message from untrusted origin:", i.origin);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (Vt(i)) {
|
|
49
|
+
if (n) try {
|
|
50
|
+
X("Received message:", JSON.parse(JSON.stringify(i.data)));
|
|
51
|
+
} catch {
|
|
52
|
+
X("Received message:", i.data?.type ?? "[Unserializable]");
|
|
53
|
+
}
|
|
54
|
+
r(i.data, i.origin);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
return window.addEventListener("message", a), () => {
|
|
59
|
+
window.removeEventListener("message", a);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function qt(e) {
|
|
63
|
+
return btoa(JSON.stringify(e));
|
|
64
|
+
}
|
|
65
|
+
var Ha = Object.freeze({ status: "aborted" });
|
|
66
|
+
function c(e, t, r) {
|
|
67
|
+
function n(s, u) {
|
|
68
|
+
if (s._zod || Object.defineProperty(s, "_zod", {
|
|
69
|
+
value: {
|
|
70
|
+
def: u,
|
|
71
|
+
constr: i,
|
|
72
|
+
traits: /* @__PURE__ */ new Set()
|
|
73
|
+
},
|
|
74
|
+
enumerable: !1
|
|
75
|
+
}), s._zod.traits.has(e)) return;
|
|
76
|
+
s._zod.traits.add(e), t(s, u);
|
|
77
|
+
const l = i.prototype, d = Object.keys(l);
|
|
78
|
+
for (let p = 0; p < d.length; p++) {
|
|
79
|
+
const h = d[p];
|
|
80
|
+
h in s || (s[h] = l[h].bind(s));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const o = r?.Parent ?? Object;
|
|
84
|
+
class a extends o {
|
|
85
|
+
}
|
|
86
|
+
Object.defineProperty(a, "name", { value: e });
|
|
87
|
+
function i(s) {
|
|
88
|
+
var u;
|
|
89
|
+
const l = r?.Parent ? new a() : this;
|
|
90
|
+
n(l, s), (u = l._zod).deferred ?? (u.deferred = []);
|
|
91
|
+
for (const d of l._zod.deferred) d();
|
|
92
|
+
return l;
|
|
93
|
+
}
|
|
94
|
+
return Object.defineProperty(i, "init", { value: n }), Object.defineProperty(i, Symbol.hasInstance, { value: (s) => r?.Parent && s instanceof r.Parent ? !0 : s?._zod?.traits?.has(e) }), Object.defineProperty(i, "name", { value: e }), i;
|
|
95
|
+
}
|
|
96
|
+
var L = class extends Error {
|
|
97
|
+
constructor() {
|
|
98
|
+
super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");
|
|
99
|
+
}
|
|
100
|
+
}, nt = class extends Error {
|
|
101
|
+
constructor(e) {
|
|
102
|
+
super(`Encountered unidirectional transform during encode: ${e}`), this.name = "ZodEncodeError";
|
|
103
|
+
}
|
|
104
|
+
}, pe = {};
|
|
105
|
+
function j(e) {
|
|
106
|
+
return e && Object.assign(pe, e), pe;
|
|
107
|
+
}
|
|
108
|
+
function ot(e) {
|
|
109
|
+
const t = Object.values(e).filter((r) => typeof r == "number");
|
|
110
|
+
return Object.entries(e).filter(([r, n]) => t.indexOf(+r) === -1).map(([r, n]) => n);
|
|
111
|
+
}
|
|
112
|
+
function me(e, t) {
|
|
113
|
+
return typeof t == "bigint" ? t.toString() : t;
|
|
114
|
+
}
|
|
115
|
+
function we(e) {
|
|
116
|
+
return { get value() {
|
|
117
|
+
{
|
|
118
|
+
const t = e();
|
|
119
|
+
return Object.defineProperty(this, "value", { value: t }), t;
|
|
120
|
+
}
|
|
121
|
+
throw new Error("cached value already set");
|
|
122
|
+
} };
|
|
123
|
+
}
|
|
124
|
+
function ye(e) {
|
|
125
|
+
return e == null;
|
|
126
|
+
}
|
|
127
|
+
function ze(e) {
|
|
128
|
+
const t = e.startsWith("^") ? 1 : 0, r = e.endsWith("$") ? e.length - 1 : e.length;
|
|
129
|
+
return e.slice(t, r);
|
|
130
|
+
}
|
|
131
|
+
function Wt(e, t) {
|
|
132
|
+
const r = (e.toString().split(".")[1] || "").length, n = t.toString();
|
|
133
|
+
let o = (n.split(".")[1] || "").length;
|
|
134
|
+
if (o === 0 && /\d?e-\d?/.test(n)) {
|
|
135
|
+
const i = n.match(/\d?e-(\d?)/);
|
|
136
|
+
i?.[1] && (o = Number.parseInt(i[1]));
|
|
137
|
+
}
|
|
138
|
+
const a = r > o ? r : o;
|
|
139
|
+
return Number.parseInt(e.toFixed(a).replace(".", "")) % Number.parseInt(t.toFixed(a).replace(".", "")) / 10 ** a;
|
|
140
|
+
}
|
|
141
|
+
var Pe = /* @__PURE__ */ Symbol("evaluating");
|
|
142
|
+
function g(e, t, r) {
|
|
143
|
+
let n;
|
|
144
|
+
Object.defineProperty(e, t, {
|
|
145
|
+
get() {
|
|
146
|
+
if (n !== Pe)
|
|
147
|
+
return n === void 0 && (n = Pe, n = r()), n;
|
|
148
|
+
},
|
|
149
|
+
set(o) {
|
|
150
|
+
Object.defineProperty(e, t, { value: o });
|
|
151
|
+
},
|
|
152
|
+
configurable: !0
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
function U(e, t, r) {
|
|
156
|
+
Object.defineProperty(e, t, {
|
|
157
|
+
value: r,
|
|
158
|
+
writable: !0,
|
|
159
|
+
enumerable: !0,
|
|
160
|
+
configurable: !0
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
function N(...e) {
|
|
164
|
+
const t = {};
|
|
165
|
+
for (const r of e) Object.assign(t, Object.getOwnPropertyDescriptors(r));
|
|
166
|
+
return Object.defineProperties({}, t);
|
|
167
|
+
}
|
|
168
|
+
function Ae(e) {
|
|
169
|
+
return JSON.stringify(e);
|
|
170
|
+
}
|
|
171
|
+
function Bt(e) {
|
|
172
|
+
return e.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
173
|
+
}
|
|
174
|
+
var it = "captureStackTrace" in Error ? Error.captureStackTrace : (...e) => {
|
|
175
|
+
};
|
|
176
|
+
function Q(e) {
|
|
177
|
+
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
178
|
+
}
|
|
179
|
+
var Ht = we(() => {
|
|
180
|
+
if (typeof navigator < "u" && navigator?.userAgent?.includes("Cloudflare")) return !1;
|
|
181
|
+
try {
|
|
182
|
+
return new Function(""), !0;
|
|
183
|
+
} catch {
|
|
184
|
+
return !1;
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
function q(e) {
|
|
188
|
+
if (Q(e) === !1) return !1;
|
|
189
|
+
const t = e.constructor;
|
|
190
|
+
if (t === void 0 || typeof t != "function") return !0;
|
|
191
|
+
const r = t.prototype;
|
|
192
|
+
return !(Q(r) === !1 || Object.prototype.hasOwnProperty.call(r, "isPrototypeOf") === !1);
|
|
193
|
+
}
|
|
194
|
+
function at(e) {
|
|
195
|
+
return q(e) ? { ...e } : Array.isArray(e) ? [...e] : e;
|
|
196
|
+
}
|
|
197
|
+
var Kt = /* @__PURE__ */ new Set([
|
|
198
|
+
"string",
|
|
199
|
+
"number",
|
|
200
|
+
"symbol"
|
|
201
|
+
]);
|
|
202
|
+
function ne(e) {
|
|
203
|
+
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
204
|
+
}
|
|
205
|
+
function R(e, t, r) {
|
|
206
|
+
const n = new e._zod.constr(t ?? e._zod.def);
|
|
207
|
+
return (!t || r?.parent) && (n._zod.parent = e), n;
|
|
208
|
+
}
|
|
209
|
+
function f(e) {
|
|
210
|
+
const t = e;
|
|
211
|
+
if (!t) return {};
|
|
212
|
+
if (typeof t == "string") return { error: () => t };
|
|
213
|
+
if (t?.message !== void 0) {
|
|
214
|
+
if (t?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
|
|
215
|
+
t.error = t.message;
|
|
216
|
+
}
|
|
217
|
+
return delete t.message, typeof t.error == "string" ? {
|
|
218
|
+
...t,
|
|
219
|
+
error: () => t.error
|
|
220
|
+
} : t;
|
|
221
|
+
}
|
|
222
|
+
function Gt(e) {
|
|
223
|
+
return Object.keys(e).filter((t) => e[t]._zod.optin === "optional" && e[t]._zod.optout === "optional");
|
|
224
|
+
}
|
|
225
|
+
var Xt = {
|
|
226
|
+
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
227
|
+
int32: [-2147483648, 2147483647],
|
|
228
|
+
uint32: [0, 4294967295],
|
|
229
|
+
float32: [-34028234663852886e22, 34028234663852886e22],
|
|
230
|
+
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
231
|
+
};
|
|
232
|
+
function Qt(e, t) {
|
|
233
|
+
const r = e._zod.def, n = r.checks;
|
|
234
|
+
if (n && n.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
235
|
+
return R(e, N(e._zod.def, {
|
|
236
|
+
get shape() {
|
|
237
|
+
const o = {};
|
|
238
|
+
for (const a in t) {
|
|
239
|
+
if (!(a in r.shape)) throw new Error(`Unrecognized key: "${a}"`);
|
|
240
|
+
t[a] && (o[a] = r.shape[a]);
|
|
241
|
+
}
|
|
242
|
+
return U(this, "shape", o), o;
|
|
243
|
+
},
|
|
244
|
+
checks: []
|
|
245
|
+
}));
|
|
246
|
+
}
|
|
247
|
+
function Yt(e, t) {
|
|
248
|
+
const r = e._zod.def, n = r.checks;
|
|
249
|
+
if (n && n.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
250
|
+
return R(e, N(e._zod.def, {
|
|
251
|
+
get shape() {
|
|
252
|
+
const o = { ...e._zod.def.shape };
|
|
253
|
+
for (const a in t) {
|
|
254
|
+
if (!(a in r.shape)) throw new Error(`Unrecognized key: "${a}"`);
|
|
255
|
+
t[a] && delete o[a];
|
|
256
|
+
}
|
|
257
|
+
return U(this, "shape", o), o;
|
|
258
|
+
},
|
|
259
|
+
checks: []
|
|
260
|
+
}));
|
|
261
|
+
}
|
|
262
|
+
function er(e, t) {
|
|
263
|
+
if (!q(t)) throw new Error("Invalid input to extend: expected a plain object");
|
|
264
|
+
const r = e._zod.def.checks;
|
|
265
|
+
if (r && r.length > 0) {
|
|
266
|
+
const n = e._zod.def.shape;
|
|
267
|
+
for (const o in t) if (Object.getOwnPropertyDescriptor(n, o) !== void 0) throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
268
|
+
}
|
|
269
|
+
return R(e, N(e._zod.def, { get shape() {
|
|
270
|
+
const n = {
|
|
271
|
+
...e._zod.def.shape,
|
|
272
|
+
...t
|
|
273
|
+
};
|
|
274
|
+
return U(this, "shape", n), n;
|
|
275
|
+
} }));
|
|
276
|
+
}
|
|
277
|
+
function tr(e, t) {
|
|
278
|
+
if (!q(t)) throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
279
|
+
return R(e, N(e._zod.def, { get shape() {
|
|
280
|
+
const r = {
|
|
281
|
+
...e._zod.def.shape,
|
|
282
|
+
...t
|
|
283
|
+
};
|
|
284
|
+
return U(this, "shape", r), r;
|
|
285
|
+
} }));
|
|
286
|
+
}
|
|
287
|
+
function rr(e, t) {
|
|
288
|
+
return R(e, N(e._zod.def, {
|
|
289
|
+
get shape() {
|
|
290
|
+
const r = {
|
|
291
|
+
...e._zod.def.shape,
|
|
292
|
+
...t._zod.def.shape
|
|
293
|
+
};
|
|
294
|
+
return U(this, "shape", r), r;
|
|
295
|
+
},
|
|
296
|
+
get catchall() {
|
|
297
|
+
return t._zod.def.catchall;
|
|
298
|
+
},
|
|
299
|
+
checks: []
|
|
300
|
+
}));
|
|
301
|
+
}
|
|
302
|
+
function nr(e, t, r) {
|
|
303
|
+
const n = t._zod.def.checks;
|
|
304
|
+
if (n && n.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
|
|
305
|
+
return R(t, N(t._zod.def, {
|
|
306
|
+
get shape() {
|
|
307
|
+
const o = t._zod.def.shape, a = { ...o };
|
|
308
|
+
if (r) for (const i in r) {
|
|
309
|
+
if (!(i in o)) throw new Error(`Unrecognized key: "${i}"`);
|
|
310
|
+
r[i] && (a[i] = e ? new e({
|
|
311
|
+
type: "optional",
|
|
312
|
+
innerType: o[i]
|
|
313
|
+
}) : o[i]);
|
|
314
|
+
}
|
|
315
|
+
else for (const i in o) a[i] = e ? new e({
|
|
316
|
+
type: "optional",
|
|
317
|
+
innerType: o[i]
|
|
318
|
+
}) : o[i];
|
|
319
|
+
return U(this, "shape", a), a;
|
|
320
|
+
},
|
|
321
|
+
checks: []
|
|
322
|
+
}));
|
|
323
|
+
}
|
|
324
|
+
function or(e, t, r) {
|
|
325
|
+
return R(t, N(t._zod.def, { get shape() {
|
|
326
|
+
const n = t._zod.def.shape, o = { ...n };
|
|
327
|
+
if (r) for (const a in r) {
|
|
328
|
+
if (!(a in o)) throw new Error(`Unrecognized key: "${a}"`);
|
|
329
|
+
r[a] && (o[a] = new e({
|
|
330
|
+
type: "nonoptional",
|
|
331
|
+
innerType: n[a]
|
|
332
|
+
}));
|
|
333
|
+
}
|
|
334
|
+
else for (const a in n) o[a] = new e({
|
|
335
|
+
type: "nonoptional",
|
|
336
|
+
innerType: n[a]
|
|
337
|
+
});
|
|
338
|
+
return U(this, "shape", o), o;
|
|
339
|
+
} }));
|
|
340
|
+
}
|
|
341
|
+
function F(e, t = 0) {
|
|
342
|
+
if (e.aborted === !0) return !0;
|
|
343
|
+
for (let r = t; r < e.issues.length; r++) if (e.issues[r]?.continue !== !0) return !0;
|
|
344
|
+
return !1;
|
|
345
|
+
}
|
|
346
|
+
function st(e, t) {
|
|
347
|
+
return t.map((r) => {
|
|
348
|
+
var n;
|
|
349
|
+
return (n = r).path ?? (n.path = []), r.path.unshift(e), r;
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
function B(e) {
|
|
353
|
+
return typeof e == "string" ? e : e?.message;
|
|
354
|
+
}
|
|
355
|
+
function M(e, t, r) {
|
|
356
|
+
const n = {
|
|
357
|
+
...e,
|
|
358
|
+
path: e.path ?? []
|
|
359
|
+
};
|
|
360
|
+
return e.message || (n.message = B(e.inst?._zod.def?.error?.(e)) ?? B(t?.error?.(e)) ?? B(r.customError?.(e)) ?? B(r.localeError?.(e)) ?? "Invalid input"), delete n.inst, delete n.continue, t?.reportInput || delete n.input, n;
|
|
361
|
+
}
|
|
362
|
+
function ke(e) {
|
|
363
|
+
return Array.isArray(e) ? "array" : typeof e == "string" ? "string" : "unknown";
|
|
364
|
+
}
|
|
365
|
+
function W(...e) {
|
|
366
|
+
const [t, r, n] = e;
|
|
367
|
+
return typeof t == "string" ? {
|
|
368
|
+
message: t,
|
|
369
|
+
code: "custom",
|
|
370
|
+
input: r,
|
|
371
|
+
inst: n
|
|
372
|
+
} : { ...t };
|
|
373
|
+
}
|
|
374
|
+
var ct = (e, t) => {
|
|
375
|
+
e.name = "$ZodError", Object.defineProperty(e, "_zod", {
|
|
376
|
+
value: e._zod,
|
|
377
|
+
enumerable: !1
|
|
378
|
+
}), Object.defineProperty(e, "issues", {
|
|
379
|
+
value: t,
|
|
380
|
+
enumerable: !1
|
|
381
|
+
}), e.message = JSON.stringify(t, me, 2), Object.defineProperty(e, "toString", {
|
|
382
|
+
value: () => e.message,
|
|
383
|
+
enumerable: !1
|
|
384
|
+
});
|
|
385
|
+
}, ut = c("$ZodError", ct), lt = c("$ZodError", ct, { Parent: Error });
|
|
386
|
+
function ir(e, t = (r) => r.message) {
|
|
387
|
+
const r = {}, n = [];
|
|
388
|
+
for (const o of e.issues) o.path.length > 0 ? (r[o.path[0]] = r[o.path[0]] || [], r[o.path[0]].push(t(o))) : n.push(t(o));
|
|
389
|
+
return {
|
|
390
|
+
formErrors: n,
|
|
391
|
+
fieldErrors: r
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
function ar(e, t = (r) => r.message) {
|
|
395
|
+
const r = { _errors: [] }, n = (o) => {
|
|
396
|
+
for (const a of o.issues) if (a.code === "invalid_union" && a.errors.length) a.errors.map((i) => n({ issues: i }));
|
|
397
|
+
else if (a.code === "invalid_key") n({ issues: a.issues });
|
|
398
|
+
else if (a.code === "invalid_element") n({ issues: a.issues });
|
|
399
|
+
else if (a.path.length === 0) r._errors.push(t(a));
|
|
400
|
+
else {
|
|
401
|
+
let i = r, s = 0;
|
|
402
|
+
for (; s < a.path.length; ) {
|
|
403
|
+
const u = a.path[s];
|
|
404
|
+
s !== a.path.length - 1 ? i[u] = i[u] || { _errors: [] } : (i[u] = i[u] || { _errors: [] }, i[u]._errors.push(t(a))), i = i[u], s++;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
return n(e), r;
|
|
409
|
+
}
|
|
410
|
+
var $e = (e) => (t, r, n, o) => {
|
|
411
|
+
const a = n ? Object.assign(n, { async: !1 }) : { async: !1 }, i = t._zod.run({
|
|
412
|
+
value: r,
|
|
413
|
+
issues: []
|
|
414
|
+
}, a);
|
|
415
|
+
if (i instanceof Promise) throw new L();
|
|
416
|
+
if (i.issues.length) {
|
|
417
|
+
const s = new (o?.Err ?? e)(i.issues.map((u) => M(u, a, j())));
|
|
418
|
+
throw it(s, o?.callee), s;
|
|
419
|
+
}
|
|
420
|
+
return i.value;
|
|
421
|
+
};
|
|
422
|
+
var Se = (e) => async (t, r, n, o) => {
|
|
423
|
+
const a = n ? Object.assign(n, { async: !0 }) : { async: !0 };
|
|
424
|
+
let i = t._zod.run({
|
|
425
|
+
value: r,
|
|
426
|
+
issues: []
|
|
427
|
+
}, a);
|
|
428
|
+
if (i instanceof Promise && (i = await i), i.issues.length) {
|
|
429
|
+
const s = new (o?.Err ?? e)(i.issues.map((u) => M(u, a, j())));
|
|
430
|
+
throw it(s, o?.callee), s;
|
|
431
|
+
}
|
|
432
|
+
return i.value;
|
|
433
|
+
};
|
|
434
|
+
var oe = (e) => (t, r, n) => {
|
|
435
|
+
const o = n ? {
|
|
436
|
+
...n,
|
|
437
|
+
async: !1
|
|
438
|
+
} : { async: !1 }, a = t._zod.run({
|
|
439
|
+
value: r,
|
|
440
|
+
issues: []
|
|
441
|
+
}, o);
|
|
442
|
+
if (a instanceof Promise) throw new L();
|
|
443
|
+
return a.issues.length ? {
|
|
444
|
+
success: !1,
|
|
445
|
+
error: new (e ?? ut)(a.issues.map((i) => M(i, o, j())))
|
|
446
|
+
} : {
|
|
447
|
+
success: !0,
|
|
448
|
+
data: a.value
|
|
449
|
+
};
|
|
450
|
+
}, sr = /* @__PURE__ */ oe(lt), ie = (e) => async (t, r, n) => {
|
|
451
|
+
const o = n ? Object.assign(n, { async: !0 }) : { async: !0 };
|
|
452
|
+
let a = t._zod.run({
|
|
453
|
+
value: r,
|
|
454
|
+
issues: []
|
|
455
|
+
}, o);
|
|
456
|
+
return a instanceof Promise && (a = await a), a.issues.length ? {
|
|
457
|
+
success: !1,
|
|
458
|
+
error: new e(a.issues.map((i) => M(i, o, j())))
|
|
459
|
+
} : {
|
|
460
|
+
success: !0,
|
|
461
|
+
data: a.value
|
|
462
|
+
};
|
|
463
|
+
}, cr = /* @__PURE__ */ ie(lt), ur = (e) => (t, r, n) => {
|
|
464
|
+
const o = n ? Object.assign(n, { direction: "backward" }) : { direction: "backward" };
|
|
465
|
+
return $e(e)(t, r, o);
|
|
466
|
+
};
|
|
467
|
+
var lr = (e) => (t, r, n) => $e(e)(t, r, n);
|
|
468
|
+
var dr = (e) => async (t, r, n) => {
|
|
469
|
+
const o = n ? Object.assign(n, { direction: "backward" }) : { direction: "backward" };
|
|
470
|
+
return Se(e)(t, r, o);
|
|
471
|
+
};
|
|
472
|
+
var fr = (e) => async (t, r, n) => Se(e)(t, r, n);
|
|
473
|
+
var hr = (e) => (t, r, n) => {
|
|
474
|
+
const o = n ? Object.assign(n, { direction: "backward" }) : { direction: "backward" };
|
|
475
|
+
return oe(e)(t, r, o);
|
|
476
|
+
};
|
|
477
|
+
var pr = (e) => (t, r, n) => oe(e)(t, r, n);
|
|
478
|
+
var mr = (e) => async (t, r, n) => {
|
|
479
|
+
const o = n ? Object.assign(n, { direction: "backward" }) : { direction: "backward" };
|
|
480
|
+
return ie(e)(t, r, o);
|
|
481
|
+
};
|
|
482
|
+
var gr = (e) => async (t, r, n) => ie(e)(t, r, n);
|
|
483
|
+
var vr = /^[cC][^\s-]{8,}$/, br = /^[0-9a-z]+$/, _r = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/, wr = /^[0-9a-vA-V]{20}$/, yr = /^[A-Za-z0-9]{27}$/, zr = /^[a-zA-Z0-9_-]{21}$/, kr = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/, $r = /^([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})$/, Ce = (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)$/, Sr = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/, Zr = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
484
|
+
function Or() {
|
|
485
|
+
return new RegExp(Zr, "u");
|
|
486
|
+
}
|
|
487
|
+
var Er = /^(?:(?: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])$/, Ir = /^(([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}|:))$/, Tr = /^((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])$/, Pr = /^(([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])$/, Ar = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/, dt = /^[A-Za-z0-9_-]*$/, Cr = /^\+[1-9]\d{6,14}$/, ft = "(?:(?:\\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])))", Nr = /* @__PURE__ */ new RegExp(`^${ft}$`);
|
|
488
|
+
function ht(e) {
|
|
489
|
+
const t = "(?:[01]\\d|2[0-3]):[0-5]\\d";
|
|
490
|
+
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+)?)?`;
|
|
491
|
+
}
|
|
492
|
+
function Rr(e) {
|
|
493
|
+
return new RegExp(`^${ht(e)}$`);
|
|
494
|
+
}
|
|
495
|
+
function xr(e) {
|
|
496
|
+
const t = ht({ precision: e.precision }), r = ["Z"];
|
|
497
|
+
e.local && r.push(""), e.offset && r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");
|
|
498
|
+
const n = `${t}(?:${r.join("|")})`;
|
|
499
|
+
return new RegExp(`^${ft}T(?:${n})$`);
|
|
500
|
+
}
|
|
501
|
+
var jr = (e) => {
|
|
502
|
+
const t = e ? `[\\s\\S]{${e?.minimum ?? 0},${e?.maximum ?? ""}}` : "[\\s\\S]*";
|
|
503
|
+
return new RegExp(`^${t}$`);
|
|
504
|
+
}, Mr = /^-?\d+$/, Ur = /^-?\d+(?:\.\d+)?$/, Dr = /^(?:true|false)$/i, Fr = /^[^A-Z]*$/, Lr = /^[^a-z]*$/, Z = /* @__PURE__ */ c("$ZodCheck", (e, t) => {
|
|
505
|
+
var r;
|
|
506
|
+
e._zod ?? (e._zod = {}), e._zod.def = t, (r = e._zod).onattach ?? (r.onattach = []);
|
|
507
|
+
}), pt = {
|
|
508
|
+
number: "number",
|
|
509
|
+
bigint: "bigint",
|
|
510
|
+
object: "date"
|
|
511
|
+
}, mt = /* @__PURE__ */ c("$ZodCheckLessThan", (e, t) => {
|
|
512
|
+
Z.init(e, t);
|
|
513
|
+
const r = pt[typeof t.value];
|
|
514
|
+
e._zod.onattach.push((n) => {
|
|
515
|
+
const o = n._zod.bag, a = (t.inclusive ? o.maximum : o.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
|
|
516
|
+
t.value < a && (t.inclusive ? o.maximum = t.value : o.exclusiveMaximum = t.value);
|
|
517
|
+
}), e._zod.check = (n) => {
|
|
518
|
+
(t.inclusive ? n.value <= t.value : n.value < t.value) || n.issues.push({
|
|
519
|
+
origin: r,
|
|
520
|
+
code: "too_big",
|
|
521
|
+
maximum: typeof t.value == "object" ? t.value.getTime() : t.value,
|
|
522
|
+
input: n.value,
|
|
523
|
+
inclusive: t.inclusive,
|
|
524
|
+
inst: e,
|
|
525
|
+
continue: !t.abort
|
|
526
|
+
});
|
|
527
|
+
};
|
|
528
|
+
}), gt = /* @__PURE__ */ c("$ZodCheckGreaterThan", (e, t) => {
|
|
529
|
+
Z.init(e, t);
|
|
530
|
+
const r = pt[typeof t.value];
|
|
531
|
+
e._zod.onattach.push((n) => {
|
|
532
|
+
const o = n._zod.bag, a = (t.inclusive ? o.minimum : o.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
|
|
533
|
+
t.value > a && (t.inclusive ? o.minimum = t.value : o.exclusiveMinimum = t.value);
|
|
534
|
+
}), e._zod.check = (n) => {
|
|
535
|
+
(t.inclusive ? n.value >= t.value : n.value > t.value) || n.issues.push({
|
|
536
|
+
origin: r,
|
|
537
|
+
code: "too_small",
|
|
538
|
+
minimum: typeof t.value == "object" ? t.value.getTime() : t.value,
|
|
539
|
+
input: n.value,
|
|
540
|
+
inclusive: t.inclusive,
|
|
541
|
+
inst: e,
|
|
542
|
+
continue: !t.abort
|
|
543
|
+
});
|
|
544
|
+
};
|
|
545
|
+
}), Vr = /* @__PURE__ */ c("$ZodCheckMultipleOf", (e, t) => {
|
|
546
|
+
Z.init(e, t), e._zod.onattach.push((r) => {
|
|
547
|
+
var n;
|
|
548
|
+
(n = r._zod.bag).multipleOf ?? (n.multipleOf = t.value);
|
|
549
|
+
}), e._zod.check = (r) => {
|
|
550
|
+
if (typeof r.value != typeof t.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
|
|
551
|
+
(typeof r.value == "bigint" ? r.value % t.value === BigInt(0) : Wt(r.value, t.value) === 0) || r.issues.push({
|
|
552
|
+
origin: typeof r.value,
|
|
553
|
+
code: "not_multiple_of",
|
|
554
|
+
divisor: t.value,
|
|
555
|
+
input: r.value,
|
|
556
|
+
inst: e,
|
|
557
|
+
continue: !t.abort
|
|
558
|
+
});
|
|
559
|
+
};
|
|
560
|
+
}), Jr = /* @__PURE__ */ c("$ZodCheckNumberFormat", (e, t) => {
|
|
561
|
+
Z.init(e, t), t.format = t.format || "float64";
|
|
562
|
+
const r = t.format?.includes("int"), n = r ? "int" : "number", [o, a] = Xt[t.format];
|
|
563
|
+
e._zod.onattach.push((i) => {
|
|
564
|
+
const s = i._zod.bag;
|
|
565
|
+
s.format = t.format, s.minimum = o, s.maximum = a, r && (s.pattern = Mr);
|
|
566
|
+
}), e._zod.check = (i) => {
|
|
567
|
+
const s = i.value;
|
|
568
|
+
if (r) {
|
|
569
|
+
if (!Number.isInteger(s)) {
|
|
570
|
+
i.issues.push({
|
|
571
|
+
expected: n,
|
|
572
|
+
format: t.format,
|
|
573
|
+
code: "invalid_type",
|
|
574
|
+
continue: !1,
|
|
575
|
+
input: s,
|
|
576
|
+
inst: e
|
|
577
|
+
});
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
if (!Number.isSafeInteger(s)) {
|
|
581
|
+
s > 0 ? i.issues.push({
|
|
582
|
+
input: s,
|
|
583
|
+
code: "too_big",
|
|
584
|
+
maximum: Number.MAX_SAFE_INTEGER,
|
|
585
|
+
note: "Integers must be within the safe integer range.",
|
|
586
|
+
inst: e,
|
|
587
|
+
origin: n,
|
|
588
|
+
inclusive: !0,
|
|
589
|
+
continue: !t.abort
|
|
590
|
+
}) : i.issues.push({
|
|
591
|
+
input: s,
|
|
592
|
+
code: "too_small",
|
|
593
|
+
minimum: Number.MIN_SAFE_INTEGER,
|
|
594
|
+
note: "Integers must be within the safe integer range.",
|
|
595
|
+
inst: e,
|
|
596
|
+
origin: n,
|
|
597
|
+
inclusive: !0,
|
|
598
|
+
continue: !t.abort
|
|
599
|
+
});
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
s < o && i.issues.push({
|
|
604
|
+
origin: "number",
|
|
605
|
+
input: s,
|
|
606
|
+
code: "too_small",
|
|
607
|
+
minimum: o,
|
|
608
|
+
inclusive: !0,
|
|
609
|
+
inst: e,
|
|
610
|
+
continue: !t.abort
|
|
611
|
+
}), s > a && i.issues.push({
|
|
612
|
+
origin: "number",
|
|
613
|
+
input: s,
|
|
614
|
+
code: "too_big",
|
|
615
|
+
maximum: a,
|
|
616
|
+
inclusive: !0,
|
|
617
|
+
inst: e,
|
|
618
|
+
continue: !t.abort
|
|
619
|
+
});
|
|
620
|
+
};
|
|
621
|
+
}), qr = /* @__PURE__ */ c("$ZodCheckMaxLength", (e, t) => {
|
|
622
|
+
var r;
|
|
623
|
+
Z.init(e, t), (r = e._zod.def).when ?? (r.when = (n) => {
|
|
624
|
+
const o = n.value;
|
|
625
|
+
return !ye(o) && o.length !== void 0;
|
|
626
|
+
}), e._zod.onattach.push((n) => {
|
|
627
|
+
const o = n._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
|
|
628
|
+
t.maximum < o && (n._zod.bag.maximum = t.maximum);
|
|
629
|
+
}), e._zod.check = (n) => {
|
|
630
|
+
const o = n.value;
|
|
631
|
+
if (o.length <= t.maximum) return;
|
|
632
|
+
const a = ke(o);
|
|
633
|
+
n.issues.push({
|
|
634
|
+
origin: a,
|
|
635
|
+
code: "too_big",
|
|
636
|
+
maximum: t.maximum,
|
|
637
|
+
inclusive: !0,
|
|
638
|
+
input: o,
|
|
639
|
+
inst: e,
|
|
640
|
+
continue: !t.abort
|
|
641
|
+
});
|
|
642
|
+
};
|
|
643
|
+
}), Wr = /* @__PURE__ */ c("$ZodCheckMinLength", (e, t) => {
|
|
644
|
+
var r;
|
|
645
|
+
Z.init(e, t), (r = e._zod.def).when ?? (r.when = (n) => {
|
|
646
|
+
const o = n.value;
|
|
647
|
+
return !ye(o) && o.length !== void 0;
|
|
648
|
+
}), e._zod.onattach.push((n) => {
|
|
649
|
+
const o = n._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
|
|
650
|
+
t.minimum > o && (n._zod.bag.minimum = t.minimum);
|
|
651
|
+
}), e._zod.check = (n) => {
|
|
652
|
+
const o = n.value;
|
|
653
|
+
if (o.length >= t.minimum) return;
|
|
654
|
+
const a = ke(o);
|
|
655
|
+
n.issues.push({
|
|
656
|
+
origin: a,
|
|
657
|
+
code: "too_small",
|
|
658
|
+
minimum: t.minimum,
|
|
659
|
+
inclusive: !0,
|
|
660
|
+
input: o,
|
|
661
|
+
inst: e,
|
|
662
|
+
continue: !t.abort
|
|
663
|
+
});
|
|
664
|
+
};
|
|
665
|
+
}), Br = /* @__PURE__ */ c("$ZodCheckLengthEquals", (e, t) => {
|
|
666
|
+
var r;
|
|
667
|
+
Z.init(e, t), (r = e._zod.def).when ?? (r.when = (n) => {
|
|
668
|
+
const o = n.value;
|
|
669
|
+
return !ye(o) && o.length !== void 0;
|
|
670
|
+
}), e._zod.onattach.push((n) => {
|
|
671
|
+
const o = n._zod.bag;
|
|
672
|
+
o.minimum = t.length, o.maximum = t.length, o.length = t.length;
|
|
673
|
+
}), e._zod.check = (n) => {
|
|
674
|
+
const o = n.value, a = o.length;
|
|
675
|
+
if (a === t.length) return;
|
|
676
|
+
const i = ke(o), s = a > t.length;
|
|
677
|
+
n.issues.push({
|
|
678
|
+
origin: i,
|
|
679
|
+
...s ? {
|
|
680
|
+
code: "too_big",
|
|
681
|
+
maximum: t.length
|
|
682
|
+
} : {
|
|
683
|
+
code: "too_small",
|
|
684
|
+
minimum: t.length
|
|
685
|
+
},
|
|
686
|
+
inclusive: !0,
|
|
687
|
+
exact: !0,
|
|
688
|
+
input: n.value,
|
|
689
|
+
inst: e,
|
|
690
|
+
continue: !t.abort
|
|
691
|
+
});
|
|
692
|
+
};
|
|
693
|
+
}), ae = /* @__PURE__ */ c("$ZodCheckStringFormat", (e, t) => {
|
|
694
|
+
var r, n;
|
|
695
|
+
Z.init(e, t), e._zod.onattach.push((o) => {
|
|
696
|
+
const a = o._zod.bag;
|
|
697
|
+
a.format = t.format, t.pattern && (a.patterns ?? (a.patterns = /* @__PURE__ */ new Set()), a.patterns.add(t.pattern));
|
|
698
|
+
}), t.pattern ? (r = e._zod).check ?? (r.check = (o) => {
|
|
699
|
+
t.pattern.lastIndex = 0, !t.pattern.test(o.value) && o.issues.push({
|
|
700
|
+
origin: "string",
|
|
701
|
+
code: "invalid_format",
|
|
702
|
+
format: t.format,
|
|
703
|
+
input: o.value,
|
|
704
|
+
...t.pattern ? { pattern: t.pattern.toString() } : {},
|
|
705
|
+
inst: e,
|
|
706
|
+
continue: !t.abort
|
|
707
|
+
});
|
|
708
|
+
}) : (n = e._zod).check ?? (n.check = () => {
|
|
709
|
+
});
|
|
710
|
+
}), Hr = /* @__PURE__ */ c("$ZodCheckRegex", (e, t) => {
|
|
711
|
+
ae.init(e, t), e._zod.check = (r) => {
|
|
712
|
+
t.pattern.lastIndex = 0, !t.pattern.test(r.value) && r.issues.push({
|
|
713
|
+
origin: "string",
|
|
714
|
+
code: "invalid_format",
|
|
715
|
+
format: "regex",
|
|
716
|
+
input: r.value,
|
|
717
|
+
pattern: t.pattern.toString(),
|
|
718
|
+
inst: e,
|
|
719
|
+
continue: !t.abort
|
|
720
|
+
});
|
|
721
|
+
};
|
|
722
|
+
}), Kr = /* @__PURE__ */ c("$ZodCheckLowerCase", (e, t) => {
|
|
723
|
+
t.pattern ?? (t.pattern = Fr), ae.init(e, t);
|
|
724
|
+
}), Gr = /* @__PURE__ */ c("$ZodCheckUpperCase", (e, t) => {
|
|
725
|
+
t.pattern ?? (t.pattern = Lr), ae.init(e, t);
|
|
726
|
+
}), Xr = /* @__PURE__ */ c("$ZodCheckIncludes", (e, t) => {
|
|
727
|
+
Z.init(e, t);
|
|
728
|
+
const r = ne(t.includes), n = new RegExp(typeof t.position == "number" ? `^.{${t.position}}${r}` : r);
|
|
729
|
+
t.pattern = n, e._zod.onattach.push((o) => {
|
|
730
|
+
const a = o._zod.bag;
|
|
731
|
+
a.patterns ?? (a.patterns = /* @__PURE__ */ new Set()), a.patterns.add(n);
|
|
732
|
+
}), e._zod.check = (o) => {
|
|
733
|
+
o.value.includes(t.includes, t.position) || o.issues.push({
|
|
734
|
+
origin: "string",
|
|
735
|
+
code: "invalid_format",
|
|
736
|
+
format: "includes",
|
|
737
|
+
includes: t.includes,
|
|
738
|
+
input: o.value,
|
|
739
|
+
inst: e,
|
|
740
|
+
continue: !t.abort
|
|
741
|
+
});
|
|
742
|
+
};
|
|
743
|
+
}), Qr = /* @__PURE__ */ c("$ZodCheckStartsWith", (e, t) => {
|
|
744
|
+
Z.init(e, t);
|
|
745
|
+
const r = new RegExp(`^${ne(t.prefix)}.*`);
|
|
746
|
+
t.pattern ?? (t.pattern = r), e._zod.onattach.push((n) => {
|
|
747
|
+
const o = n._zod.bag;
|
|
748
|
+
o.patterns ?? (o.patterns = /* @__PURE__ */ new Set()), o.patterns.add(r);
|
|
749
|
+
}), e._zod.check = (n) => {
|
|
750
|
+
n.value.startsWith(t.prefix) || n.issues.push({
|
|
751
|
+
origin: "string",
|
|
752
|
+
code: "invalid_format",
|
|
753
|
+
format: "starts_with",
|
|
754
|
+
prefix: t.prefix,
|
|
755
|
+
input: n.value,
|
|
756
|
+
inst: e,
|
|
757
|
+
continue: !t.abort
|
|
758
|
+
});
|
|
759
|
+
};
|
|
760
|
+
}), Yr = /* @__PURE__ */ c("$ZodCheckEndsWith", (e, t) => {
|
|
761
|
+
Z.init(e, t);
|
|
762
|
+
const r = new RegExp(`.*${ne(t.suffix)}$`);
|
|
763
|
+
t.pattern ?? (t.pattern = r), e._zod.onattach.push((n) => {
|
|
764
|
+
const o = n._zod.bag;
|
|
765
|
+
o.patterns ?? (o.patterns = /* @__PURE__ */ new Set()), o.patterns.add(r);
|
|
766
|
+
}), e._zod.check = (n) => {
|
|
767
|
+
n.value.endsWith(t.suffix) || n.issues.push({
|
|
768
|
+
origin: "string",
|
|
769
|
+
code: "invalid_format",
|
|
770
|
+
format: "ends_with",
|
|
771
|
+
suffix: t.suffix,
|
|
772
|
+
input: n.value,
|
|
773
|
+
inst: e,
|
|
774
|
+
continue: !t.abort
|
|
775
|
+
});
|
|
776
|
+
};
|
|
777
|
+
}), en = /* @__PURE__ */ c("$ZodCheckOverwrite", (e, t) => {
|
|
778
|
+
Z.init(e, t), e._zod.check = (r) => {
|
|
779
|
+
r.value = t.tx(r.value);
|
|
780
|
+
};
|
|
781
|
+
}), tn = class {
|
|
782
|
+
constructor(e = []) {
|
|
783
|
+
this.content = [], this.indent = 0, this && (this.args = e);
|
|
784
|
+
}
|
|
785
|
+
indented(e) {
|
|
786
|
+
this.indent += 1, e(this), this.indent -= 1;
|
|
787
|
+
}
|
|
788
|
+
write(e) {
|
|
789
|
+
if (typeof e == "function") {
|
|
790
|
+
e(this, { execution: "sync" }), e(this, { execution: "async" });
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
const t = e.split(`
|
|
794
|
+
`).filter((o) => o), r = Math.min(...t.map((o) => o.length - o.trimStart().length)), n = t.map((o) => o.slice(r)).map((o) => " ".repeat(this.indent * 2) + o);
|
|
795
|
+
for (const o of n) this.content.push(o);
|
|
796
|
+
}
|
|
797
|
+
compile() {
|
|
798
|
+
const e = Function, t = this?.args, r = [...(this?.content ?? [""]).map((n) => ` ${n}`)];
|
|
799
|
+
return new e(...t, r.join(`
|
|
800
|
+
`));
|
|
801
|
+
}
|
|
802
|
+
}, rn = {
|
|
803
|
+
major: 4,
|
|
804
|
+
minor: 3,
|
|
805
|
+
patch: 6
|
|
806
|
+
}, y = /* @__PURE__ */ c("$ZodType", (e, t) => {
|
|
807
|
+
var r;
|
|
808
|
+
e ?? (e = {}), e._zod.def = t, e._zod.bag = e._zod.bag || {}, e._zod.version = rn;
|
|
809
|
+
const n = [...e._zod.def.checks ?? []];
|
|
810
|
+
e._zod.traits.has("$ZodCheck") && n.unshift(e);
|
|
811
|
+
for (const o of n) for (const a of o._zod.onattach) a(e);
|
|
812
|
+
if (n.length === 0)
|
|
813
|
+
(r = e._zod).deferred ?? (r.deferred = []), e._zod.deferred?.push(() => {
|
|
814
|
+
e._zod.run = e._zod.parse;
|
|
815
|
+
});
|
|
816
|
+
else {
|
|
817
|
+
const o = (i, s, u) => {
|
|
818
|
+
let l = F(i), d;
|
|
819
|
+
for (const p of s) {
|
|
820
|
+
if (p._zod.def.when) {
|
|
821
|
+
if (!p._zod.def.when(i)) continue;
|
|
822
|
+
} else if (l) continue;
|
|
823
|
+
const h = i.issues.length, m = p._zod.check(i);
|
|
824
|
+
if (m instanceof Promise && u?.async === !1) throw new L();
|
|
825
|
+
if (d || m instanceof Promise) d = (d ?? Promise.resolve()).then(async () => {
|
|
826
|
+
await m, i.issues.length !== h && (l || (l = F(i, h)));
|
|
827
|
+
});
|
|
828
|
+
else {
|
|
829
|
+
if (i.issues.length === h) continue;
|
|
830
|
+
l || (l = F(i, h));
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
return d ? d.then(() => i) : i;
|
|
834
|
+
}, a = (i, s, u) => {
|
|
835
|
+
if (F(i))
|
|
836
|
+
return i.aborted = !0, i;
|
|
837
|
+
const l = o(s, n, u);
|
|
838
|
+
if (l instanceof Promise) {
|
|
839
|
+
if (u.async === !1) throw new L();
|
|
840
|
+
return l.then((d) => e._zod.parse(d, u));
|
|
841
|
+
}
|
|
842
|
+
return e._zod.parse(l, u);
|
|
843
|
+
};
|
|
844
|
+
e._zod.run = (i, s) => {
|
|
845
|
+
if (s.skipChecks) return e._zod.parse(i, s);
|
|
846
|
+
if (s.direction === "backward") {
|
|
847
|
+
const l = e._zod.parse({
|
|
848
|
+
value: i.value,
|
|
849
|
+
issues: []
|
|
850
|
+
}, {
|
|
851
|
+
...s,
|
|
852
|
+
skipChecks: !0
|
|
853
|
+
});
|
|
854
|
+
return l instanceof Promise ? l.then((d) => a(d, i, s)) : a(l, i, s);
|
|
855
|
+
}
|
|
856
|
+
const u = e._zod.parse(i, s);
|
|
857
|
+
if (u instanceof Promise) {
|
|
858
|
+
if (s.async === !1) throw new L();
|
|
859
|
+
return u.then((l) => o(l, n, s));
|
|
860
|
+
}
|
|
861
|
+
return o(u, n, s);
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
g(e, "~standard", () => ({
|
|
865
|
+
validate: (o) => {
|
|
866
|
+
try {
|
|
867
|
+
const a = sr(e, o);
|
|
868
|
+
return a.success ? { value: a.data } : { issues: a.error?.issues };
|
|
869
|
+
} catch {
|
|
870
|
+
return cr(e, o).then((i) => i.success ? { value: i.data } : { issues: i.error?.issues });
|
|
871
|
+
}
|
|
872
|
+
},
|
|
873
|
+
vendor: "zod",
|
|
874
|
+
version: 1
|
|
875
|
+
}));
|
|
876
|
+
}), Ze = /* @__PURE__ */ c("$ZodString", (e, t) => {
|
|
877
|
+
y.init(e, t), e._zod.pattern = [...e?._zod.bag?.patterns ?? []].pop() ?? jr(e._zod.bag), e._zod.parse = (r, n) => {
|
|
878
|
+
if (t.coerce) try {
|
|
879
|
+
r.value = String(r.value);
|
|
880
|
+
} catch {
|
|
881
|
+
}
|
|
882
|
+
return typeof r.value == "string" || r.issues.push({
|
|
883
|
+
expected: "string",
|
|
884
|
+
code: "invalid_type",
|
|
885
|
+
input: r.value,
|
|
886
|
+
inst: e
|
|
887
|
+
}), r;
|
|
888
|
+
};
|
|
889
|
+
}), b = /* @__PURE__ */ c("$ZodStringFormat", (e, t) => {
|
|
890
|
+
ae.init(e, t), Ze.init(e, t);
|
|
891
|
+
}), nn = /* @__PURE__ */ c("$ZodGUID", (e, t) => {
|
|
892
|
+
t.pattern ?? (t.pattern = $r), b.init(e, t);
|
|
893
|
+
}), on = /* @__PURE__ */ c("$ZodUUID", (e, t) => {
|
|
894
|
+
if (t.version) {
|
|
895
|
+
const r = {
|
|
896
|
+
v1: 1,
|
|
897
|
+
v2: 2,
|
|
898
|
+
v3: 3,
|
|
899
|
+
v4: 4,
|
|
900
|
+
v5: 5,
|
|
901
|
+
v6: 6,
|
|
902
|
+
v7: 7,
|
|
903
|
+
v8: 8
|
|
904
|
+
}[t.version];
|
|
905
|
+
if (r === void 0) throw new Error(`Invalid UUID version: "${t.version}"`);
|
|
906
|
+
t.pattern ?? (t.pattern = Ce(r));
|
|
907
|
+
} else t.pattern ?? (t.pattern = Ce());
|
|
908
|
+
b.init(e, t);
|
|
909
|
+
}), an = /* @__PURE__ */ c("$ZodEmail", (e, t) => {
|
|
910
|
+
t.pattern ?? (t.pattern = Sr), b.init(e, t);
|
|
911
|
+
}), sn = /* @__PURE__ */ c("$ZodURL", (e, t) => {
|
|
912
|
+
b.init(e, t), e._zod.check = (r) => {
|
|
913
|
+
try {
|
|
914
|
+
const n = r.value.trim(), o = new URL(n);
|
|
915
|
+
t.hostname && (t.hostname.lastIndex = 0, t.hostname.test(o.hostname) || r.issues.push({
|
|
916
|
+
code: "invalid_format",
|
|
917
|
+
format: "url",
|
|
918
|
+
note: "Invalid hostname",
|
|
919
|
+
pattern: t.hostname.source,
|
|
920
|
+
input: r.value,
|
|
921
|
+
inst: e,
|
|
922
|
+
continue: !t.abort
|
|
923
|
+
})), t.protocol && (t.protocol.lastIndex = 0, t.protocol.test(o.protocol.endsWith(":") ? o.protocol.slice(0, -1) : o.protocol) || r.issues.push({
|
|
924
|
+
code: "invalid_format",
|
|
925
|
+
format: "url",
|
|
926
|
+
note: "Invalid protocol",
|
|
927
|
+
pattern: t.protocol.source,
|
|
928
|
+
input: r.value,
|
|
929
|
+
inst: e,
|
|
930
|
+
continue: !t.abort
|
|
931
|
+
})), t.normalize ? r.value = o.href : r.value = n;
|
|
932
|
+
return;
|
|
933
|
+
} catch {
|
|
934
|
+
r.issues.push({
|
|
935
|
+
code: "invalid_format",
|
|
936
|
+
format: "url",
|
|
937
|
+
input: r.value,
|
|
938
|
+
inst: e,
|
|
939
|
+
continue: !t.abort
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
};
|
|
943
|
+
}), cn = /* @__PURE__ */ c("$ZodEmoji", (e, t) => {
|
|
944
|
+
t.pattern ?? (t.pattern = Or()), b.init(e, t);
|
|
945
|
+
}), un = /* @__PURE__ */ c("$ZodNanoID", (e, t) => {
|
|
946
|
+
t.pattern ?? (t.pattern = zr), b.init(e, t);
|
|
947
|
+
}), ln = /* @__PURE__ */ c("$ZodCUID", (e, t) => {
|
|
948
|
+
t.pattern ?? (t.pattern = vr), b.init(e, t);
|
|
949
|
+
}), dn = /* @__PURE__ */ c("$ZodCUID2", (e, t) => {
|
|
950
|
+
t.pattern ?? (t.pattern = br), b.init(e, t);
|
|
951
|
+
}), fn = /* @__PURE__ */ c("$ZodULID", (e, t) => {
|
|
952
|
+
t.pattern ?? (t.pattern = _r), b.init(e, t);
|
|
953
|
+
}), hn = /* @__PURE__ */ c("$ZodXID", (e, t) => {
|
|
954
|
+
t.pattern ?? (t.pattern = wr), b.init(e, t);
|
|
955
|
+
}), pn = /* @__PURE__ */ c("$ZodKSUID", (e, t) => {
|
|
956
|
+
t.pattern ?? (t.pattern = yr), b.init(e, t);
|
|
957
|
+
}), mn = /* @__PURE__ */ c("$ZodISODateTime", (e, t) => {
|
|
958
|
+
t.pattern ?? (t.pattern = xr(t)), b.init(e, t);
|
|
959
|
+
}), gn = /* @__PURE__ */ c("$ZodISODate", (e, t) => {
|
|
960
|
+
t.pattern ?? (t.pattern = Nr), b.init(e, t);
|
|
961
|
+
}), vn = /* @__PURE__ */ c("$ZodISOTime", (e, t) => {
|
|
962
|
+
t.pattern ?? (t.pattern = Rr(t)), b.init(e, t);
|
|
963
|
+
}), bn = /* @__PURE__ */ c("$ZodISODuration", (e, t) => {
|
|
964
|
+
t.pattern ?? (t.pattern = kr), b.init(e, t);
|
|
965
|
+
}), _n = /* @__PURE__ */ c("$ZodIPv4", (e, t) => {
|
|
966
|
+
t.pattern ?? (t.pattern = Er), b.init(e, t), e._zod.bag.format = "ipv4";
|
|
967
|
+
}), wn = /* @__PURE__ */ c("$ZodIPv6", (e, t) => {
|
|
968
|
+
t.pattern ?? (t.pattern = Ir), b.init(e, t), e._zod.bag.format = "ipv6", e._zod.check = (r) => {
|
|
969
|
+
try {
|
|
970
|
+
new URL(`http://[${r.value}]`);
|
|
971
|
+
} catch {
|
|
972
|
+
r.issues.push({
|
|
973
|
+
code: "invalid_format",
|
|
974
|
+
format: "ipv6",
|
|
975
|
+
input: r.value,
|
|
976
|
+
inst: e,
|
|
977
|
+
continue: !t.abort
|
|
978
|
+
});
|
|
979
|
+
}
|
|
980
|
+
};
|
|
981
|
+
}), yn = /* @__PURE__ */ c("$ZodCIDRv4", (e, t) => {
|
|
982
|
+
t.pattern ?? (t.pattern = Tr), b.init(e, t);
|
|
983
|
+
}), zn = /* @__PURE__ */ c("$ZodCIDRv6", (e, t) => {
|
|
984
|
+
t.pattern ?? (t.pattern = Pr), b.init(e, t), e._zod.check = (r) => {
|
|
985
|
+
const n = r.value.split("/");
|
|
986
|
+
try {
|
|
987
|
+
if (n.length !== 2) throw new Error();
|
|
988
|
+
const [o, a] = n;
|
|
989
|
+
if (!a) throw new Error();
|
|
990
|
+
const i = Number(a);
|
|
991
|
+
if (`${i}` !== a) throw new Error();
|
|
992
|
+
if (i < 0 || i > 128) throw new Error();
|
|
993
|
+
new URL(`http://[${o}]`);
|
|
994
|
+
} catch {
|
|
995
|
+
r.issues.push({
|
|
996
|
+
code: "invalid_format",
|
|
997
|
+
format: "cidrv6",
|
|
998
|
+
input: r.value,
|
|
999
|
+
inst: e,
|
|
1000
|
+
continue: !t.abort
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
};
|
|
1004
|
+
});
|
|
1005
|
+
function vt(e) {
|
|
1006
|
+
if (e === "") return !0;
|
|
1007
|
+
if (e.length % 4 !== 0) return !1;
|
|
1008
|
+
try {
|
|
1009
|
+
return atob(e), !0;
|
|
1010
|
+
} catch {
|
|
1011
|
+
return !1;
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
var kn = /* @__PURE__ */ c("$ZodBase64", (e, t) => {
|
|
1015
|
+
t.pattern ?? (t.pattern = Ar), b.init(e, t), e._zod.bag.contentEncoding = "base64", e._zod.check = (r) => {
|
|
1016
|
+
vt(r.value) || r.issues.push({
|
|
1017
|
+
code: "invalid_format",
|
|
1018
|
+
format: "base64",
|
|
1019
|
+
input: r.value,
|
|
1020
|
+
inst: e,
|
|
1021
|
+
continue: !t.abort
|
|
1022
|
+
});
|
|
1023
|
+
};
|
|
1024
|
+
});
|
|
1025
|
+
function $n(e) {
|
|
1026
|
+
if (!dt.test(e)) return !1;
|
|
1027
|
+
const t = e.replace(/[-_]/g, (r) => r === "-" ? "+" : "/");
|
|
1028
|
+
return vt(t.padEnd(Math.ceil(t.length / 4) * 4, "="));
|
|
1029
|
+
}
|
|
1030
|
+
var Sn = /* @__PURE__ */ c("$ZodBase64URL", (e, t) => {
|
|
1031
|
+
t.pattern ?? (t.pattern = dt), b.init(e, t), e._zod.bag.contentEncoding = "base64url", e._zod.check = (r) => {
|
|
1032
|
+
$n(r.value) || r.issues.push({
|
|
1033
|
+
code: "invalid_format",
|
|
1034
|
+
format: "base64url",
|
|
1035
|
+
input: r.value,
|
|
1036
|
+
inst: e,
|
|
1037
|
+
continue: !t.abort
|
|
1038
|
+
});
|
|
1039
|
+
};
|
|
1040
|
+
}), Zn = /* @__PURE__ */ c("$ZodE164", (e, t) => {
|
|
1041
|
+
t.pattern ?? (t.pattern = Cr), b.init(e, t);
|
|
1042
|
+
});
|
|
1043
|
+
function On(e, t = null) {
|
|
1044
|
+
try {
|
|
1045
|
+
const r = e.split(".");
|
|
1046
|
+
if (r.length !== 3) return !1;
|
|
1047
|
+
const [n] = r;
|
|
1048
|
+
if (!n) return !1;
|
|
1049
|
+
const o = JSON.parse(atob(n));
|
|
1050
|
+
return !("typ" in o && o?.typ !== "JWT" || !o.alg || t && (!("alg" in o) || o.alg !== t));
|
|
1051
|
+
} catch {
|
|
1052
|
+
return !1;
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
var En = /* @__PURE__ */ c("$ZodJWT", (e, t) => {
|
|
1056
|
+
b.init(e, t), e._zod.check = (r) => {
|
|
1057
|
+
On(r.value, t.alg) || r.issues.push({
|
|
1058
|
+
code: "invalid_format",
|
|
1059
|
+
format: "jwt",
|
|
1060
|
+
input: r.value,
|
|
1061
|
+
inst: e,
|
|
1062
|
+
continue: !t.abort
|
|
1063
|
+
});
|
|
1064
|
+
};
|
|
1065
|
+
}), bt = /* @__PURE__ */ c("$ZodNumber", (e, t) => {
|
|
1066
|
+
y.init(e, t), e._zod.pattern = e._zod.bag.pattern ?? Ur, e._zod.parse = (r, n) => {
|
|
1067
|
+
if (t.coerce) try {
|
|
1068
|
+
r.value = Number(r.value);
|
|
1069
|
+
} catch {
|
|
1070
|
+
}
|
|
1071
|
+
const o = r.value;
|
|
1072
|
+
if (typeof o == "number" && !Number.isNaN(o) && Number.isFinite(o)) return r;
|
|
1073
|
+
const a = typeof o == "number" ? Number.isNaN(o) ? "NaN" : Number.isFinite(o) ? void 0 : "Infinity" : void 0;
|
|
1074
|
+
return r.issues.push({
|
|
1075
|
+
expected: "number",
|
|
1076
|
+
code: "invalid_type",
|
|
1077
|
+
input: o,
|
|
1078
|
+
inst: e,
|
|
1079
|
+
...a ? { received: a } : {}
|
|
1080
|
+
}), r;
|
|
1081
|
+
};
|
|
1082
|
+
}), In = /* @__PURE__ */ c("$ZodNumberFormat", (e, t) => {
|
|
1083
|
+
Jr.init(e, t), bt.init(e, t);
|
|
1084
|
+
}), Tn = /* @__PURE__ */ c("$ZodBoolean", (e, t) => {
|
|
1085
|
+
y.init(e, t), e._zod.pattern = Dr, e._zod.parse = (r, n) => {
|
|
1086
|
+
if (t.coerce) try {
|
|
1087
|
+
r.value = !!r.value;
|
|
1088
|
+
} catch {
|
|
1089
|
+
}
|
|
1090
|
+
const o = r.value;
|
|
1091
|
+
return typeof o == "boolean" || r.issues.push({
|
|
1092
|
+
expected: "boolean",
|
|
1093
|
+
code: "invalid_type",
|
|
1094
|
+
input: o,
|
|
1095
|
+
inst: e
|
|
1096
|
+
}), r;
|
|
1097
|
+
};
|
|
1098
|
+
}), Pn = /* @__PURE__ */ c("$ZodUnknown", (e, t) => {
|
|
1099
|
+
y.init(e, t), e._zod.parse = (r) => r;
|
|
1100
|
+
}), An = /* @__PURE__ */ c("$ZodNever", (e, t) => {
|
|
1101
|
+
y.init(e, t), e._zod.parse = (r, n) => (r.issues.push({
|
|
1102
|
+
expected: "never",
|
|
1103
|
+
code: "invalid_type",
|
|
1104
|
+
input: r.value,
|
|
1105
|
+
inst: e
|
|
1106
|
+
}), r);
|
|
1107
|
+
});
|
|
1108
|
+
function Ne(e, t, r) {
|
|
1109
|
+
e.issues.length && t.issues.push(...st(r, e.issues)), t.value[r] = e.value;
|
|
1110
|
+
}
|
|
1111
|
+
var Cn = /* @__PURE__ */ c("$ZodArray", (e, t) => {
|
|
1112
|
+
y.init(e, t), e._zod.parse = (r, n) => {
|
|
1113
|
+
const o = r.value;
|
|
1114
|
+
if (!Array.isArray(o))
|
|
1115
|
+
return r.issues.push({
|
|
1116
|
+
expected: "array",
|
|
1117
|
+
code: "invalid_type",
|
|
1118
|
+
input: o,
|
|
1119
|
+
inst: e
|
|
1120
|
+
}), r;
|
|
1121
|
+
r.value = Array(o.length);
|
|
1122
|
+
const a = [];
|
|
1123
|
+
for (let i = 0; i < o.length; i++) {
|
|
1124
|
+
const s = o[i], u = t.element._zod.run({
|
|
1125
|
+
value: s,
|
|
1126
|
+
issues: []
|
|
1127
|
+
}, n);
|
|
1128
|
+
u instanceof Promise ? a.push(u.then((l) => Ne(l, r, i))) : Ne(u, r, i);
|
|
1129
|
+
}
|
|
1130
|
+
return a.length ? Promise.all(a).then(() => r) : r;
|
|
1131
|
+
};
|
|
1132
|
+
});
|
|
1133
|
+
function Y(e, t, r, n, o) {
|
|
1134
|
+
if (e.issues.length) {
|
|
1135
|
+
if (o && !(r in n)) return;
|
|
1136
|
+
t.issues.push(...st(r, e.issues));
|
|
1137
|
+
}
|
|
1138
|
+
e.value === void 0 ? r in n && (t.value[r] = void 0) : t.value[r] = e.value;
|
|
1139
|
+
}
|
|
1140
|
+
function _t(e) {
|
|
1141
|
+
const t = Object.keys(e.shape);
|
|
1142
|
+
for (const n of t) if (!e.shape?.[n]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${n}": expected a Zod schema`);
|
|
1143
|
+
const r = Gt(e.shape);
|
|
1144
|
+
return {
|
|
1145
|
+
...e,
|
|
1146
|
+
keys: t,
|
|
1147
|
+
keySet: new Set(t),
|
|
1148
|
+
numKeys: t.length,
|
|
1149
|
+
optionalKeys: new Set(r)
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1152
|
+
function wt(e, t, r, n, o, a) {
|
|
1153
|
+
const i = [], s = o.keySet, u = o.catchall._zod, l = u.def.type, d = u.optout === "optional";
|
|
1154
|
+
for (const p in t) {
|
|
1155
|
+
if (s.has(p)) continue;
|
|
1156
|
+
if (l === "never") {
|
|
1157
|
+
i.push(p);
|
|
1158
|
+
continue;
|
|
1159
|
+
}
|
|
1160
|
+
const h = u.run({
|
|
1161
|
+
value: t[p],
|
|
1162
|
+
issues: []
|
|
1163
|
+
}, n);
|
|
1164
|
+
h instanceof Promise ? e.push(h.then((m) => Y(m, r, p, t, d))) : Y(h, r, p, t, d);
|
|
1165
|
+
}
|
|
1166
|
+
return i.length && r.issues.push({
|
|
1167
|
+
code: "unrecognized_keys",
|
|
1168
|
+
keys: i,
|
|
1169
|
+
input: t,
|
|
1170
|
+
inst: a
|
|
1171
|
+
}), e.length ? Promise.all(e).then(() => r) : r;
|
|
1172
|
+
}
|
|
1173
|
+
var Nn = /* @__PURE__ */ c("$ZodObject", (e, t) => {
|
|
1174
|
+
if (y.init(e, t), !Object.getOwnPropertyDescriptor(t, "shape")?.get) {
|
|
1175
|
+
const i = t.shape;
|
|
1176
|
+
Object.defineProperty(t, "shape", { get: () => {
|
|
1177
|
+
const s = { ...i };
|
|
1178
|
+
return Object.defineProperty(t, "shape", { value: s }), s;
|
|
1179
|
+
} });
|
|
1180
|
+
}
|
|
1181
|
+
const r = we(() => _t(t));
|
|
1182
|
+
g(e._zod, "propValues", () => {
|
|
1183
|
+
const i = t.shape, s = {};
|
|
1184
|
+
for (const u in i) {
|
|
1185
|
+
const l = i[u]._zod;
|
|
1186
|
+
if (l.values) {
|
|
1187
|
+
s[u] ?? (s[u] = /* @__PURE__ */ new Set());
|
|
1188
|
+
for (const d of l.values) s[u].add(d);
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
return s;
|
|
1192
|
+
});
|
|
1193
|
+
const n = Q, o = t.catchall;
|
|
1194
|
+
let a;
|
|
1195
|
+
e._zod.parse = (i, s) => {
|
|
1196
|
+
a ?? (a = r.value);
|
|
1197
|
+
const u = i.value;
|
|
1198
|
+
if (!n(u))
|
|
1199
|
+
return i.issues.push({
|
|
1200
|
+
expected: "object",
|
|
1201
|
+
code: "invalid_type",
|
|
1202
|
+
input: u,
|
|
1203
|
+
inst: e
|
|
1204
|
+
}), i;
|
|
1205
|
+
i.value = {};
|
|
1206
|
+
const l = [], d = a.shape;
|
|
1207
|
+
for (const p of a.keys) {
|
|
1208
|
+
const h = d[p], m = h._zod.optout === "optional", w = h._zod.run({
|
|
1209
|
+
value: u[p],
|
|
1210
|
+
issues: []
|
|
1211
|
+
}, s);
|
|
1212
|
+
w instanceof Promise ? l.push(w.then((se) => Y(se, i, p, u, m))) : Y(w, i, p, u, m);
|
|
1213
|
+
}
|
|
1214
|
+
return o ? wt(l, u, i, s, r.value, e) : l.length ? Promise.all(l).then(() => i) : i;
|
|
1215
|
+
};
|
|
1216
|
+
}), Rn = /* @__PURE__ */ c("$ZodObjectJIT", (e, t) => {
|
|
1217
|
+
Nn.init(e, t);
|
|
1218
|
+
const r = e._zod.parse, n = we(() => _t(t)), o = (h) => {
|
|
1219
|
+
const m = new tn([
|
|
1220
|
+
"shape",
|
|
1221
|
+
"payload",
|
|
1222
|
+
"ctx"
|
|
1223
|
+
]), w = n.value, se = (T) => {
|
|
1224
|
+
const S = Ae(T);
|
|
1225
|
+
return `shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`;
|
|
1226
|
+
};
|
|
1227
|
+
m.write("const input = payload.value;");
|
|
1228
|
+
const Ie = /* @__PURE__ */ Object.create(null);
|
|
1229
|
+
let xt = 0;
|
|
1230
|
+
for (const T of w.keys) Ie[T] = `key_${xt++}`;
|
|
1231
|
+
m.write("const newResult = {};");
|
|
1232
|
+
for (const T of w.keys) {
|
|
1233
|
+
const S = Ie[T], I = Ae(T), Mt = h[T]?._zod?.optout === "optional";
|
|
1234
|
+
m.write(`const ${S} = ${se(T)};`), Mt ? m.write(`
|
|
1235
|
+
if (${S}.issues.length) {
|
|
1236
|
+
if (${I} in input) {
|
|
1237
|
+
payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
|
|
1238
|
+
...iss,
|
|
1239
|
+
path: iss.path ? [${I}, ...iss.path] : [${I}]
|
|
1240
|
+
})));
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
if (${S}.value === undefined) {
|
|
1245
|
+
if (${I} in input) {
|
|
1246
|
+
newResult[${I}] = undefined;
|
|
1247
|
+
}
|
|
1248
|
+
} else {
|
|
1249
|
+
newResult[${I}] = ${S}.value;
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
`) : m.write(`
|
|
1253
|
+
if (${S}.issues.length) {
|
|
1254
|
+
payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
|
|
1255
|
+
...iss,
|
|
1256
|
+
path: iss.path ? [${I}, ...iss.path] : [${I}]
|
|
1257
|
+
})));
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
if (${S}.value === undefined) {
|
|
1261
|
+
if (${I} in input) {
|
|
1262
|
+
newResult[${I}] = undefined;
|
|
1263
|
+
}
|
|
1264
|
+
} else {
|
|
1265
|
+
newResult[${I}] = ${S}.value;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
`);
|
|
1269
|
+
}
|
|
1270
|
+
m.write("payload.value = newResult;"), m.write("return payload;");
|
|
1271
|
+
const jt = m.compile();
|
|
1272
|
+
return (T, S) => jt(h, T, S);
|
|
1273
|
+
};
|
|
1274
|
+
let a;
|
|
1275
|
+
const i = Q, s = !pe.jitless, l = s && Ht.value, d = t.catchall;
|
|
1276
|
+
let p;
|
|
1277
|
+
e._zod.parse = (h, m) => {
|
|
1278
|
+
p ?? (p = n.value);
|
|
1279
|
+
const w = h.value;
|
|
1280
|
+
return i(w) ? s && l && m?.async === !1 && m.jitless !== !0 ? (a || (a = o(t.shape)), h = a(h, m), d ? wt([], w, h, m, p, e) : h) : r(h, m) : (h.issues.push({
|
|
1281
|
+
expected: "object",
|
|
1282
|
+
code: "invalid_type",
|
|
1283
|
+
input: w,
|
|
1284
|
+
inst: e
|
|
1285
|
+
}), h);
|
|
1286
|
+
};
|
|
1287
|
+
});
|
|
1288
|
+
function Re(e, t, r, n) {
|
|
1289
|
+
for (const a of e) if (a.issues.length === 0)
|
|
1290
|
+
return t.value = a.value, t;
|
|
1291
|
+
const o = e.filter((a) => !F(a));
|
|
1292
|
+
return o.length === 1 ? (t.value = o[0].value, o[0]) : (t.issues.push({
|
|
1293
|
+
code: "invalid_union",
|
|
1294
|
+
input: t.value,
|
|
1295
|
+
inst: r,
|
|
1296
|
+
errors: e.map((a) => a.issues.map((i) => M(i, n, j())))
|
|
1297
|
+
}), t);
|
|
1298
|
+
}
|
|
1299
|
+
var xn = /* @__PURE__ */ c("$ZodUnion", (e, t) => {
|
|
1300
|
+
y.init(e, t), g(e._zod, "optin", () => t.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0), g(e._zod, "optout", () => t.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0), g(e._zod, "values", () => {
|
|
1301
|
+
if (t.options.every((o) => o._zod.values)) return new Set(t.options.flatMap((o) => Array.from(o._zod.values)));
|
|
1302
|
+
}), g(e._zod, "pattern", () => {
|
|
1303
|
+
if (t.options.every((o) => o._zod.pattern)) {
|
|
1304
|
+
const o = t.options.map((a) => a._zod.pattern);
|
|
1305
|
+
return new RegExp(`^(${o.map((a) => ze(a.source)).join("|")})$`);
|
|
1306
|
+
}
|
|
1307
|
+
});
|
|
1308
|
+
const r = t.options.length === 1, n = t.options[0]._zod.run;
|
|
1309
|
+
e._zod.parse = (o, a) => {
|
|
1310
|
+
if (r) return n(o, a);
|
|
1311
|
+
let i = !1;
|
|
1312
|
+
const s = [];
|
|
1313
|
+
for (const u of t.options) {
|
|
1314
|
+
const l = u._zod.run({
|
|
1315
|
+
value: o.value,
|
|
1316
|
+
issues: []
|
|
1317
|
+
}, a);
|
|
1318
|
+
if (l instanceof Promise)
|
|
1319
|
+
s.push(l), i = !0;
|
|
1320
|
+
else {
|
|
1321
|
+
if (l.issues.length === 0) return l;
|
|
1322
|
+
s.push(l);
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
return i ? Promise.all(s).then((u) => Re(u, o, e, a)) : Re(s, o, e, a);
|
|
1326
|
+
};
|
|
1327
|
+
}), jn = /* @__PURE__ */ c("$ZodIntersection", (e, t) => {
|
|
1328
|
+
y.init(e, t), e._zod.parse = (r, n) => {
|
|
1329
|
+
const o = r.value, a = t.left._zod.run({
|
|
1330
|
+
value: o,
|
|
1331
|
+
issues: []
|
|
1332
|
+
}, n), i = t.right._zod.run({
|
|
1333
|
+
value: o,
|
|
1334
|
+
issues: []
|
|
1335
|
+
}, n);
|
|
1336
|
+
return a instanceof Promise || i instanceof Promise ? Promise.all([a, i]).then(([s, u]) => xe(r, s, u)) : xe(r, a, i);
|
|
1337
|
+
};
|
|
1338
|
+
});
|
|
1339
|
+
function ge(e, t) {
|
|
1340
|
+
if (e === t) return {
|
|
1341
|
+
valid: !0,
|
|
1342
|
+
data: e
|
|
1343
|
+
};
|
|
1344
|
+
if (e instanceof Date && t instanceof Date && +e == +t) return {
|
|
1345
|
+
valid: !0,
|
|
1346
|
+
data: e
|
|
1347
|
+
};
|
|
1348
|
+
if (q(e) && q(t)) {
|
|
1349
|
+
const r = Object.keys(t), n = Object.keys(e).filter((a) => r.indexOf(a) !== -1), o = {
|
|
1350
|
+
...e,
|
|
1351
|
+
...t
|
|
1352
|
+
};
|
|
1353
|
+
for (const a of n) {
|
|
1354
|
+
const i = ge(e[a], t[a]);
|
|
1355
|
+
if (!i.valid) return {
|
|
1356
|
+
valid: !1,
|
|
1357
|
+
mergeErrorPath: [a, ...i.mergeErrorPath]
|
|
1358
|
+
};
|
|
1359
|
+
o[a] = i.data;
|
|
1360
|
+
}
|
|
1361
|
+
return {
|
|
1362
|
+
valid: !0,
|
|
1363
|
+
data: o
|
|
1364
|
+
};
|
|
1365
|
+
}
|
|
1366
|
+
if (Array.isArray(e) && Array.isArray(t)) {
|
|
1367
|
+
if (e.length !== t.length) return {
|
|
1368
|
+
valid: !1,
|
|
1369
|
+
mergeErrorPath: []
|
|
1370
|
+
};
|
|
1371
|
+
const r = [];
|
|
1372
|
+
for (let n = 0; n < e.length; n++) {
|
|
1373
|
+
const o = e[n], a = t[n], i = ge(o, a);
|
|
1374
|
+
if (!i.valid) return {
|
|
1375
|
+
valid: !1,
|
|
1376
|
+
mergeErrorPath: [n, ...i.mergeErrorPath]
|
|
1377
|
+
};
|
|
1378
|
+
r.push(i.data);
|
|
1379
|
+
}
|
|
1380
|
+
return {
|
|
1381
|
+
valid: !0,
|
|
1382
|
+
data: r
|
|
1383
|
+
};
|
|
1384
|
+
}
|
|
1385
|
+
return {
|
|
1386
|
+
valid: !1,
|
|
1387
|
+
mergeErrorPath: []
|
|
1388
|
+
};
|
|
1389
|
+
}
|
|
1390
|
+
function xe(e, t, r) {
|
|
1391
|
+
const n = /* @__PURE__ */ new Map();
|
|
1392
|
+
let o;
|
|
1393
|
+
for (const s of t.issues) if (s.code === "unrecognized_keys") {
|
|
1394
|
+
o ?? (o = s);
|
|
1395
|
+
for (const u of s.keys)
|
|
1396
|
+
n.has(u) || n.set(u, {}), n.get(u).l = !0;
|
|
1397
|
+
} else e.issues.push(s);
|
|
1398
|
+
for (const s of r.issues) if (s.code === "unrecognized_keys") for (const u of s.keys)
|
|
1399
|
+
n.has(u) || n.set(u, {}), n.get(u).r = !0;
|
|
1400
|
+
else e.issues.push(s);
|
|
1401
|
+
const a = [...n].filter(([, s]) => s.l && s.r).map(([s]) => s);
|
|
1402
|
+
if (a.length && o && e.issues.push({
|
|
1403
|
+
...o,
|
|
1404
|
+
keys: a
|
|
1405
|
+
}), F(e)) return e;
|
|
1406
|
+
const i = ge(t.value, r.value);
|
|
1407
|
+
if (!i.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);
|
|
1408
|
+
return e.value = i.data, e;
|
|
1409
|
+
}
|
|
1410
|
+
var Mn = /* @__PURE__ */ c("$ZodEnum", (e, t) => {
|
|
1411
|
+
y.init(e, t);
|
|
1412
|
+
const r = ot(t.entries), n = new Set(r);
|
|
1413
|
+
e._zod.values = n, e._zod.pattern = new RegExp(`^(${r.filter((o) => Kt.has(typeof o)).map((o) => typeof o == "string" ? ne(o) : o.toString()).join("|")})$`), e._zod.parse = (o, a) => {
|
|
1414
|
+
const i = o.value;
|
|
1415
|
+
return n.has(i) || o.issues.push({
|
|
1416
|
+
code: "invalid_value",
|
|
1417
|
+
values: r,
|
|
1418
|
+
input: i,
|
|
1419
|
+
inst: e
|
|
1420
|
+
}), o;
|
|
1421
|
+
};
|
|
1422
|
+
}), Un = /* @__PURE__ */ c("$ZodTransform", (e, t) => {
|
|
1423
|
+
y.init(e, t), e._zod.parse = (r, n) => {
|
|
1424
|
+
if (n.direction === "backward") throw new nt(e.constructor.name);
|
|
1425
|
+
const o = t.transform(r.value, r);
|
|
1426
|
+
if (n.async) return (o instanceof Promise ? o : Promise.resolve(o)).then((a) => (r.value = a, r));
|
|
1427
|
+
if (o instanceof Promise) throw new L();
|
|
1428
|
+
return r.value = o, r;
|
|
1429
|
+
};
|
|
1430
|
+
});
|
|
1431
|
+
function je(e, t) {
|
|
1432
|
+
return e.issues.length && t === void 0 ? {
|
|
1433
|
+
issues: [],
|
|
1434
|
+
value: void 0
|
|
1435
|
+
} : e;
|
|
1436
|
+
}
|
|
1437
|
+
var yt = /* @__PURE__ */ c("$ZodOptional", (e, t) => {
|
|
1438
|
+
y.init(e, t), e._zod.optin = "optional", e._zod.optout = "optional", g(e._zod, "values", () => t.innerType._zod.values ? /* @__PURE__ */ new Set([...t.innerType._zod.values, void 0]) : void 0), g(e._zod, "pattern", () => {
|
|
1439
|
+
const r = t.innerType._zod.pattern;
|
|
1440
|
+
return r ? new RegExp(`^(${ze(r.source)})?$`) : void 0;
|
|
1441
|
+
}), e._zod.parse = (r, n) => {
|
|
1442
|
+
if (t.innerType._zod.optin === "optional") {
|
|
1443
|
+
const o = t.innerType._zod.run(r, n);
|
|
1444
|
+
return o instanceof Promise ? o.then((a) => je(a, r.value)) : je(o, r.value);
|
|
1445
|
+
}
|
|
1446
|
+
return r.value === void 0 ? r : t.innerType._zod.run(r, n);
|
|
1447
|
+
};
|
|
1448
|
+
}), Dn = /* @__PURE__ */ c("$ZodExactOptional", (e, t) => {
|
|
1449
|
+
yt.init(e, t), g(e._zod, "values", () => t.innerType._zod.values), g(e._zod, "pattern", () => t.innerType._zod.pattern), e._zod.parse = (r, n) => t.innerType._zod.run(r, n);
|
|
1450
|
+
}), Fn = /* @__PURE__ */ c("$ZodNullable", (e, t) => {
|
|
1451
|
+
y.init(e, t), g(e._zod, "optin", () => t.innerType._zod.optin), g(e._zod, "optout", () => t.innerType._zod.optout), g(e._zod, "pattern", () => {
|
|
1452
|
+
const r = t.innerType._zod.pattern;
|
|
1453
|
+
return r ? new RegExp(`^(${ze(r.source)}|null)$`) : void 0;
|
|
1454
|
+
}), g(e._zod, "values", () => t.innerType._zod.values ? /* @__PURE__ */ new Set([...t.innerType._zod.values, null]) : void 0), e._zod.parse = (r, n) => r.value === null ? r : t.innerType._zod.run(r, n);
|
|
1455
|
+
}), Ln = /* @__PURE__ */ c("$ZodDefault", (e, t) => {
|
|
1456
|
+
y.init(e, t), e._zod.optin = "optional", g(e._zod, "values", () => t.innerType._zod.values), e._zod.parse = (r, n) => {
|
|
1457
|
+
if (n.direction === "backward") return t.innerType._zod.run(r, n);
|
|
1458
|
+
if (r.value === void 0)
|
|
1459
|
+
return r.value = t.defaultValue, r;
|
|
1460
|
+
const o = t.innerType._zod.run(r, n);
|
|
1461
|
+
return o instanceof Promise ? o.then((a) => Me(a, t)) : Me(o, t);
|
|
1462
|
+
};
|
|
1463
|
+
});
|
|
1464
|
+
function Me(e, t) {
|
|
1465
|
+
return e.value === void 0 && (e.value = t.defaultValue), e;
|
|
1466
|
+
}
|
|
1467
|
+
var Vn = /* @__PURE__ */ c("$ZodPrefault", (e, t) => {
|
|
1468
|
+
y.init(e, t), e._zod.optin = "optional", g(e._zod, "values", () => t.innerType._zod.values), e._zod.parse = (r, n) => (n.direction === "backward" || r.value === void 0 && (r.value = t.defaultValue), t.innerType._zod.run(r, n));
|
|
1469
|
+
}), Jn = /* @__PURE__ */ c("$ZodNonOptional", (e, t) => {
|
|
1470
|
+
y.init(e, t), g(e._zod, "values", () => {
|
|
1471
|
+
const r = t.innerType._zod.values;
|
|
1472
|
+
return r ? new Set([...r].filter((n) => n !== void 0)) : void 0;
|
|
1473
|
+
}), e._zod.parse = (r, n) => {
|
|
1474
|
+
const o = t.innerType._zod.run(r, n);
|
|
1475
|
+
return o instanceof Promise ? o.then((a) => Ue(a, e)) : Ue(o, e);
|
|
1476
|
+
};
|
|
1477
|
+
});
|
|
1478
|
+
function Ue(e, t) {
|
|
1479
|
+
return !e.issues.length && e.value === void 0 && e.issues.push({
|
|
1480
|
+
code: "invalid_type",
|
|
1481
|
+
expected: "nonoptional",
|
|
1482
|
+
input: e.value,
|
|
1483
|
+
inst: t
|
|
1484
|
+
}), e;
|
|
1485
|
+
}
|
|
1486
|
+
var qn = /* @__PURE__ */ c("$ZodCatch", (e, t) => {
|
|
1487
|
+
y.init(e, t), g(e._zod, "optin", () => t.innerType._zod.optin), g(e._zod, "optout", () => t.innerType._zod.optout), g(e._zod, "values", () => t.innerType._zod.values), e._zod.parse = (r, n) => {
|
|
1488
|
+
if (n.direction === "backward") return t.innerType._zod.run(r, n);
|
|
1489
|
+
const o = t.innerType._zod.run(r, n);
|
|
1490
|
+
return o instanceof Promise ? o.then((a) => (r.value = a.value, a.issues.length && (r.value = t.catchValue({
|
|
1491
|
+
...r,
|
|
1492
|
+
error: { issues: a.issues.map((i) => M(i, n, j())) },
|
|
1493
|
+
input: r.value
|
|
1494
|
+
}), r.issues = []), r)) : (r.value = o.value, o.issues.length && (r.value = t.catchValue({
|
|
1495
|
+
...r,
|
|
1496
|
+
error: { issues: o.issues.map((a) => M(a, n, j())) },
|
|
1497
|
+
input: r.value
|
|
1498
|
+
}), r.issues = []), r);
|
|
1499
|
+
};
|
|
1500
|
+
}), Wn = /* @__PURE__ */ c("$ZodPipe", (e, t) => {
|
|
1501
|
+
y.init(e, t), g(e._zod, "values", () => t.in._zod.values), g(e._zod, "optin", () => t.in._zod.optin), g(e._zod, "optout", () => t.out._zod.optout), g(e._zod, "propValues", () => t.in._zod.propValues), e._zod.parse = (r, n) => {
|
|
1502
|
+
if (n.direction === "backward") {
|
|
1503
|
+
const a = t.out._zod.run(r, n);
|
|
1504
|
+
return a instanceof Promise ? a.then((i) => H(i, t.in, n)) : H(a, t.in, n);
|
|
1505
|
+
}
|
|
1506
|
+
const o = t.in._zod.run(r, n);
|
|
1507
|
+
return o instanceof Promise ? o.then((a) => H(a, t.out, n)) : H(o, t.out, n);
|
|
1508
|
+
};
|
|
1509
|
+
});
|
|
1510
|
+
function H(e, t, r) {
|
|
1511
|
+
return e.issues.length ? (e.aborted = !0, e) : t._zod.run({
|
|
1512
|
+
value: e.value,
|
|
1513
|
+
issues: e.issues
|
|
1514
|
+
}, r);
|
|
1515
|
+
}
|
|
1516
|
+
var Bn = /* @__PURE__ */ c("$ZodReadonly", (e, t) => {
|
|
1517
|
+
y.init(e, t), g(e._zod, "propValues", () => t.innerType._zod.propValues), g(e._zod, "values", () => t.innerType._zod.values), g(e._zod, "optin", () => t.innerType?._zod?.optin), g(e._zod, "optout", () => t.innerType?._zod?.optout), e._zod.parse = (r, n) => {
|
|
1518
|
+
if (n.direction === "backward") return t.innerType._zod.run(r, n);
|
|
1519
|
+
const o = t.innerType._zod.run(r, n);
|
|
1520
|
+
return o instanceof Promise ? o.then(De) : De(o);
|
|
1521
|
+
};
|
|
1522
|
+
});
|
|
1523
|
+
function De(e) {
|
|
1524
|
+
return e.value = Object.freeze(e.value), e;
|
|
1525
|
+
}
|
|
1526
|
+
var Hn = /* @__PURE__ */ c("$ZodCustom", (e, t) => {
|
|
1527
|
+
Z.init(e, t), y.init(e, t), e._zod.parse = (r, n) => r, e._zod.check = (r) => {
|
|
1528
|
+
const n = r.value, o = t.fn(n);
|
|
1529
|
+
if (o instanceof Promise) return o.then((a) => Fe(a, r, n, e));
|
|
1530
|
+
Fe(o, r, n, e);
|
|
1531
|
+
};
|
|
1532
|
+
});
|
|
1533
|
+
function Fe(e, t, r, n) {
|
|
1534
|
+
if (!e) {
|
|
1535
|
+
const o = {
|
|
1536
|
+
code: "custom",
|
|
1537
|
+
input: r,
|
|
1538
|
+
inst: n,
|
|
1539
|
+
path: [...n._zod.def.path ?? []],
|
|
1540
|
+
continue: !n._zod.def.abort
|
|
1541
|
+
};
|
|
1542
|
+
n._zod.def.params && (o.params = n._zod.def.params), t.issues.push(W(o));
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
var Le, Kn = class {
|
|
1546
|
+
constructor() {
|
|
1547
|
+
this._map = /* @__PURE__ */ new WeakMap(), this._idmap = /* @__PURE__ */ new Map();
|
|
1548
|
+
}
|
|
1549
|
+
add(e, ...t) {
|
|
1550
|
+
const r = t[0];
|
|
1551
|
+
return this._map.set(e, r), r && typeof r == "object" && "id" in r && this._idmap.set(r.id, e), this;
|
|
1552
|
+
}
|
|
1553
|
+
clear() {
|
|
1554
|
+
return this._map = /* @__PURE__ */ new WeakMap(), this._idmap = /* @__PURE__ */ new Map(), this;
|
|
1555
|
+
}
|
|
1556
|
+
remove(e) {
|
|
1557
|
+
const t = this._map.get(e);
|
|
1558
|
+
return t && typeof t == "object" && "id" in t && this._idmap.delete(t.id), this._map.delete(e), this;
|
|
1559
|
+
}
|
|
1560
|
+
get(e) {
|
|
1561
|
+
const t = e._zod.parent;
|
|
1562
|
+
if (t) {
|
|
1563
|
+
const r = { ...this.get(t) ?? {} };
|
|
1564
|
+
delete r.id;
|
|
1565
|
+
const n = {
|
|
1566
|
+
...r,
|
|
1567
|
+
...this._map.get(e)
|
|
1568
|
+
};
|
|
1569
|
+
return Object.keys(n).length ? n : void 0;
|
|
1570
|
+
}
|
|
1571
|
+
return this._map.get(e);
|
|
1572
|
+
}
|
|
1573
|
+
has(e) {
|
|
1574
|
+
return this._map.has(e);
|
|
1575
|
+
}
|
|
1576
|
+
};
|
|
1577
|
+
function Gn() {
|
|
1578
|
+
return new Kn();
|
|
1579
|
+
}
|
|
1580
|
+
(Le = globalThis).__zod_globalRegistry ?? (Le.__zod_globalRegistry = Gn());
|
|
1581
|
+
var J = globalThis.__zod_globalRegistry;
|
|
1582
|
+
// @__NO_SIDE_EFFECTS__
|
|
1583
|
+
function Xn(e, t) {
|
|
1584
|
+
return new e({
|
|
1585
|
+
type: "string",
|
|
1586
|
+
...f(t)
|
|
1587
|
+
});
|
|
1588
|
+
}
|
|
1589
|
+
// @__NO_SIDE_EFFECTS__
|
|
1590
|
+
function Qn(e, t) {
|
|
1591
|
+
return new e({
|
|
1592
|
+
type: "string",
|
|
1593
|
+
format: "email",
|
|
1594
|
+
check: "string_format",
|
|
1595
|
+
abort: !1,
|
|
1596
|
+
...f(t)
|
|
1597
|
+
});
|
|
1598
|
+
}
|
|
1599
|
+
// @__NO_SIDE_EFFECTS__
|
|
1600
|
+
function Ve(e, t) {
|
|
1601
|
+
return new e({
|
|
1602
|
+
type: "string",
|
|
1603
|
+
format: "guid",
|
|
1604
|
+
check: "string_format",
|
|
1605
|
+
abort: !1,
|
|
1606
|
+
...f(t)
|
|
1607
|
+
});
|
|
1608
|
+
}
|
|
1609
|
+
// @__NO_SIDE_EFFECTS__
|
|
1610
|
+
function Yn(e, t) {
|
|
1611
|
+
return new e({
|
|
1612
|
+
type: "string",
|
|
1613
|
+
format: "uuid",
|
|
1614
|
+
check: "string_format",
|
|
1615
|
+
abort: !1,
|
|
1616
|
+
...f(t)
|
|
1617
|
+
});
|
|
1618
|
+
}
|
|
1619
|
+
// @__NO_SIDE_EFFECTS__
|
|
1620
|
+
function eo(e, t) {
|
|
1621
|
+
return new e({
|
|
1622
|
+
type: "string",
|
|
1623
|
+
format: "uuid",
|
|
1624
|
+
check: "string_format",
|
|
1625
|
+
abort: !1,
|
|
1626
|
+
version: "v4",
|
|
1627
|
+
...f(t)
|
|
1628
|
+
});
|
|
1629
|
+
}
|
|
1630
|
+
// @__NO_SIDE_EFFECTS__
|
|
1631
|
+
function to(e, t) {
|
|
1632
|
+
return new e({
|
|
1633
|
+
type: "string",
|
|
1634
|
+
format: "uuid",
|
|
1635
|
+
check: "string_format",
|
|
1636
|
+
abort: !1,
|
|
1637
|
+
version: "v6",
|
|
1638
|
+
...f(t)
|
|
1639
|
+
});
|
|
1640
|
+
}
|
|
1641
|
+
// @__NO_SIDE_EFFECTS__
|
|
1642
|
+
function ro(e, t) {
|
|
1643
|
+
return new e({
|
|
1644
|
+
type: "string",
|
|
1645
|
+
format: "uuid",
|
|
1646
|
+
check: "string_format",
|
|
1647
|
+
abort: !1,
|
|
1648
|
+
version: "v7",
|
|
1649
|
+
...f(t)
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
// @__NO_SIDE_EFFECTS__
|
|
1653
|
+
function no(e, t) {
|
|
1654
|
+
return new e({
|
|
1655
|
+
type: "string",
|
|
1656
|
+
format: "url",
|
|
1657
|
+
check: "string_format",
|
|
1658
|
+
abort: !1,
|
|
1659
|
+
...f(t)
|
|
1660
|
+
});
|
|
1661
|
+
}
|
|
1662
|
+
// @__NO_SIDE_EFFECTS__
|
|
1663
|
+
function oo(e, t) {
|
|
1664
|
+
return new e({
|
|
1665
|
+
type: "string",
|
|
1666
|
+
format: "emoji",
|
|
1667
|
+
check: "string_format",
|
|
1668
|
+
abort: !1,
|
|
1669
|
+
...f(t)
|
|
1670
|
+
});
|
|
1671
|
+
}
|
|
1672
|
+
// @__NO_SIDE_EFFECTS__
|
|
1673
|
+
function io(e, t) {
|
|
1674
|
+
return new e({
|
|
1675
|
+
type: "string",
|
|
1676
|
+
format: "nanoid",
|
|
1677
|
+
check: "string_format",
|
|
1678
|
+
abort: !1,
|
|
1679
|
+
...f(t)
|
|
1680
|
+
});
|
|
1681
|
+
}
|
|
1682
|
+
// @__NO_SIDE_EFFECTS__
|
|
1683
|
+
function ao(e, t) {
|
|
1684
|
+
return new e({
|
|
1685
|
+
type: "string",
|
|
1686
|
+
format: "cuid",
|
|
1687
|
+
check: "string_format",
|
|
1688
|
+
abort: !1,
|
|
1689
|
+
...f(t)
|
|
1690
|
+
});
|
|
1691
|
+
}
|
|
1692
|
+
// @__NO_SIDE_EFFECTS__
|
|
1693
|
+
function so(e, t) {
|
|
1694
|
+
return new e({
|
|
1695
|
+
type: "string",
|
|
1696
|
+
format: "cuid2",
|
|
1697
|
+
check: "string_format",
|
|
1698
|
+
abort: !1,
|
|
1699
|
+
...f(t)
|
|
1700
|
+
});
|
|
1701
|
+
}
|
|
1702
|
+
// @__NO_SIDE_EFFECTS__
|
|
1703
|
+
function co(e, t) {
|
|
1704
|
+
return new e({
|
|
1705
|
+
type: "string",
|
|
1706
|
+
format: "ulid",
|
|
1707
|
+
check: "string_format",
|
|
1708
|
+
abort: !1,
|
|
1709
|
+
...f(t)
|
|
1710
|
+
});
|
|
1711
|
+
}
|
|
1712
|
+
// @__NO_SIDE_EFFECTS__
|
|
1713
|
+
function uo(e, t) {
|
|
1714
|
+
return new e({
|
|
1715
|
+
type: "string",
|
|
1716
|
+
format: "xid",
|
|
1717
|
+
check: "string_format",
|
|
1718
|
+
abort: !1,
|
|
1719
|
+
...f(t)
|
|
1720
|
+
});
|
|
1721
|
+
}
|
|
1722
|
+
// @__NO_SIDE_EFFECTS__
|
|
1723
|
+
function lo(e, t) {
|
|
1724
|
+
return new e({
|
|
1725
|
+
type: "string",
|
|
1726
|
+
format: "ksuid",
|
|
1727
|
+
check: "string_format",
|
|
1728
|
+
abort: !1,
|
|
1729
|
+
...f(t)
|
|
1730
|
+
});
|
|
1731
|
+
}
|
|
1732
|
+
// @__NO_SIDE_EFFECTS__
|
|
1733
|
+
function fo(e, t) {
|
|
1734
|
+
return new e({
|
|
1735
|
+
type: "string",
|
|
1736
|
+
format: "ipv4",
|
|
1737
|
+
check: "string_format",
|
|
1738
|
+
abort: !1,
|
|
1739
|
+
...f(t)
|
|
1740
|
+
});
|
|
1741
|
+
}
|
|
1742
|
+
// @__NO_SIDE_EFFECTS__
|
|
1743
|
+
function ho(e, t) {
|
|
1744
|
+
return new e({
|
|
1745
|
+
type: "string",
|
|
1746
|
+
format: "ipv6",
|
|
1747
|
+
check: "string_format",
|
|
1748
|
+
abort: !1,
|
|
1749
|
+
...f(t)
|
|
1750
|
+
});
|
|
1751
|
+
}
|
|
1752
|
+
// @__NO_SIDE_EFFECTS__
|
|
1753
|
+
function po(e, t) {
|
|
1754
|
+
return new e({
|
|
1755
|
+
type: "string",
|
|
1756
|
+
format: "cidrv4",
|
|
1757
|
+
check: "string_format",
|
|
1758
|
+
abort: !1,
|
|
1759
|
+
...f(t)
|
|
1760
|
+
});
|
|
1761
|
+
}
|
|
1762
|
+
// @__NO_SIDE_EFFECTS__
|
|
1763
|
+
function mo(e, t) {
|
|
1764
|
+
return new e({
|
|
1765
|
+
type: "string",
|
|
1766
|
+
format: "cidrv6",
|
|
1767
|
+
check: "string_format",
|
|
1768
|
+
abort: !1,
|
|
1769
|
+
...f(t)
|
|
1770
|
+
});
|
|
1771
|
+
}
|
|
1772
|
+
// @__NO_SIDE_EFFECTS__
|
|
1773
|
+
function go(e, t) {
|
|
1774
|
+
return new e({
|
|
1775
|
+
type: "string",
|
|
1776
|
+
format: "base64",
|
|
1777
|
+
check: "string_format",
|
|
1778
|
+
abort: !1,
|
|
1779
|
+
...f(t)
|
|
1780
|
+
});
|
|
1781
|
+
}
|
|
1782
|
+
// @__NO_SIDE_EFFECTS__
|
|
1783
|
+
function vo(e, t) {
|
|
1784
|
+
return new e({
|
|
1785
|
+
type: "string",
|
|
1786
|
+
format: "base64url",
|
|
1787
|
+
check: "string_format",
|
|
1788
|
+
abort: !1,
|
|
1789
|
+
...f(t)
|
|
1790
|
+
});
|
|
1791
|
+
}
|
|
1792
|
+
// @__NO_SIDE_EFFECTS__
|
|
1793
|
+
function bo(e, t) {
|
|
1794
|
+
return new e({
|
|
1795
|
+
type: "string",
|
|
1796
|
+
format: "e164",
|
|
1797
|
+
check: "string_format",
|
|
1798
|
+
abort: !1,
|
|
1799
|
+
...f(t)
|
|
1800
|
+
});
|
|
1801
|
+
}
|
|
1802
|
+
// @__NO_SIDE_EFFECTS__
|
|
1803
|
+
function _o(e, t) {
|
|
1804
|
+
return new e({
|
|
1805
|
+
type: "string",
|
|
1806
|
+
format: "jwt",
|
|
1807
|
+
check: "string_format",
|
|
1808
|
+
abort: !1,
|
|
1809
|
+
...f(t)
|
|
1810
|
+
});
|
|
1811
|
+
}
|
|
1812
|
+
// @__NO_SIDE_EFFECTS__
|
|
1813
|
+
function wo(e, t) {
|
|
1814
|
+
return new e({
|
|
1815
|
+
type: "string",
|
|
1816
|
+
format: "datetime",
|
|
1817
|
+
check: "string_format",
|
|
1818
|
+
offset: !1,
|
|
1819
|
+
local: !1,
|
|
1820
|
+
precision: null,
|
|
1821
|
+
...f(t)
|
|
1822
|
+
});
|
|
1823
|
+
}
|
|
1824
|
+
// @__NO_SIDE_EFFECTS__
|
|
1825
|
+
function yo(e, t) {
|
|
1826
|
+
return new e({
|
|
1827
|
+
type: "string",
|
|
1828
|
+
format: "date",
|
|
1829
|
+
check: "string_format",
|
|
1830
|
+
...f(t)
|
|
1831
|
+
});
|
|
1832
|
+
}
|
|
1833
|
+
// @__NO_SIDE_EFFECTS__
|
|
1834
|
+
function zo(e, t) {
|
|
1835
|
+
return new e({
|
|
1836
|
+
type: "string",
|
|
1837
|
+
format: "time",
|
|
1838
|
+
check: "string_format",
|
|
1839
|
+
precision: null,
|
|
1840
|
+
...f(t)
|
|
1841
|
+
});
|
|
1842
|
+
}
|
|
1843
|
+
// @__NO_SIDE_EFFECTS__
|
|
1844
|
+
function ko(e, t) {
|
|
1845
|
+
return new e({
|
|
1846
|
+
type: "string",
|
|
1847
|
+
format: "duration",
|
|
1848
|
+
check: "string_format",
|
|
1849
|
+
...f(t)
|
|
1850
|
+
});
|
|
1851
|
+
}
|
|
1852
|
+
// @__NO_SIDE_EFFECTS__
|
|
1853
|
+
function $o(e, t) {
|
|
1854
|
+
return new e({
|
|
1855
|
+
type: "number",
|
|
1856
|
+
checks: [],
|
|
1857
|
+
...f(t)
|
|
1858
|
+
});
|
|
1859
|
+
}
|
|
1860
|
+
// @__NO_SIDE_EFFECTS__
|
|
1861
|
+
function So(e, t) {
|
|
1862
|
+
return new e({
|
|
1863
|
+
type: "number",
|
|
1864
|
+
check: "number_format",
|
|
1865
|
+
abort: !1,
|
|
1866
|
+
format: "safeint",
|
|
1867
|
+
...f(t)
|
|
1868
|
+
});
|
|
1869
|
+
}
|
|
1870
|
+
// @__NO_SIDE_EFFECTS__
|
|
1871
|
+
function Zo(e, t) {
|
|
1872
|
+
return new e({
|
|
1873
|
+
type: "boolean",
|
|
1874
|
+
...f(t)
|
|
1875
|
+
});
|
|
1876
|
+
}
|
|
1877
|
+
// @__NO_SIDE_EFFECTS__
|
|
1878
|
+
function Oo(e) {
|
|
1879
|
+
return new e({ type: "unknown" });
|
|
1880
|
+
}
|
|
1881
|
+
// @__NO_SIDE_EFFECTS__
|
|
1882
|
+
function Eo(e, t) {
|
|
1883
|
+
return new e({
|
|
1884
|
+
type: "never",
|
|
1885
|
+
...f(t)
|
|
1886
|
+
});
|
|
1887
|
+
}
|
|
1888
|
+
// @__NO_SIDE_EFFECTS__
|
|
1889
|
+
function Je(e, t) {
|
|
1890
|
+
return new mt({
|
|
1891
|
+
check: "less_than",
|
|
1892
|
+
...f(t),
|
|
1893
|
+
value: e,
|
|
1894
|
+
inclusive: !1
|
|
1895
|
+
});
|
|
1896
|
+
}
|
|
1897
|
+
// @__NO_SIDE_EFFECTS__
|
|
1898
|
+
function ce(e, t) {
|
|
1899
|
+
return new mt({
|
|
1900
|
+
check: "less_than",
|
|
1901
|
+
...f(t),
|
|
1902
|
+
value: e,
|
|
1903
|
+
inclusive: !0
|
|
1904
|
+
});
|
|
1905
|
+
}
|
|
1906
|
+
// @__NO_SIDE_EFFECTS__
|
|
1907
|
+
function qe(e, t) {
|
|
1908
|
+
return new gt({
|
|
1909
|
+
check: "greater_than",
|
|
1910
|
+
...f(t),
|
|
1911
|
+
value: e,
|
|
1912
|
+
inclusive: !1
|
|
1913
|
+
});
|
|
1914
|
+
}
|
|
1915
|
+
// @__NO_SIDE_EFFECTS__
|
|
1916
|
+
function ue(e, t) {
|
|
1917
|
+
return new gt({
|
|
1918
|
+
check: "greater_than",
|
|
1919
|
+
...f(t),
|
|
1920
|
+
value: e,
|
|
1921
|
+
inclusive: !0
|
|
1922
|
+
});
|
|
1923
|
+
}
|
|
1924
|
+
// @__NO_SIDE_EFFECTS__
|
|
1925
|
+
function We(e, t) {
|
|
1926
|
+
return new Vr({
|
|
1927
|
+
check: "multiple_of",
|
|
1928
|
+
...f(t),
|
|
1929
|
+
value: e
|
|
1930
|
+
});
|
|
1931
|
+
}
|
|
1932
|
+
// @__NO_SIDE_EFFECTS__
|
|
1933
|
+
function zt(e, t) {
|
|
1934
|
+
return new qr({
|
|
1935
|
+
check: "max_length",
|
|
1936
|
+
...f(t),
|
|
1937
|
+
maximum: e
|
|
1938
|
+
});
|
|
1939
|
+
}
|
|
1940
|
+
// @__NO_SIDE_EFFECTS__
|
|
1941
|
+
function ee(e, t) {
|
|
1942
|
+
return new Wr({
|
|
1943
|
+
check: "min_length",
|
|
1944
|
+
...f(t),
|
|
1945
|
+
minimum: e
|
|
1946
|
+
});
|
|
1947
|
+
}
|
|
1948
|
+
// @__NO_SIDE_EFFECTS__
|
|
1949
|
+
function kt(e, t) {
|
|
1950
|
+
return new Br({
|
|
1951
|
+
check: "length_equals",
|
|
1952
|
+
...f(t),
|
|
1953
|
+
length: e
|
|
1954
|
+
});
|
|
1955
|
+
}
|
|
1956
|
+
// @__NO_SIDE_EFFECTS__
|
|
1957
|
+
function Io(e, t) {
|
|
1958
|
+
return new Hr({
|
|
1959
|
+
check: "string_format",
|
|
1960
|
+
format: "regex",
|
|
1961
|
+
...f(t),
|
|
1962
|
+
pattern: e
|
|
1963
|
+
});
|
|
1964
|
+
}
|
|
1965
|
+
// @__NO_SIDE_EFFECTS__
|
|
1966
|
+
function To(e) {
|
|
1967
|
+
return new Kr({
|
|
1968
|
+
check: "string_format",
|
|
1969
|
+
format: "lowercase",
|
|
1970
|
+
...f(e)
|
|
1971
|
+
});
|
|
1972
|
+
}
|
|
1973
|
+
// @__NO_SIDE_EFFECTS__
|
|
1974
|
+
function Po(e) {
|
|
1975
|
+
return new Gr({
|
|
1976
|
+
check: "string_format",
|
|
1977
|
+
format: "uppercase",
|
|
1978
|
+
...f(e)
|
|
1979
|
+
});
|
|
1980
|
+
}
|
|
1981
|
+
// @__NO_SIDE_EFFECTS__
|
|
1982
|
+
function Ao(e, t) {
|
|
1983
|
+
return new Xr({
|
|
1984
|
+
check: "string_format",
|
|
1985
|
+
format: "includes",
|
|
1986
|
+
...f(t),
|
|
1987
|
+
includes: e
|
|
1988
|
+
});
|
|
1989
|
+
}
|
|
1990
|
+
// @__NO_SIDE_EFFECTS__
|
|
1991
|
+
function Co(e, t) {
|
|
1992
|
+
return new Qr({
|
|
1993
|
+
check: "string_format",
|
|
1994
|
+
format: "starts_with",
|
|
1995
|
+
...f(t),
|
|
1996
|
+
prefix: e
|
|
1997
|
+
});
|
|
1998
|
+
}
|
|
1999
|
+
// @__NO_SIDE_EFFECTS__
|
|
2000
|
+
function No(e, t) {
|
|
2001
|
+
return new Yr({
|
|
2002
|
+
check: "string_format",
|
|
2003
|
+
format: "ends_with",
|
|
2004
|
+
...f(t),
|
|
2005
|
+
suffix: e
|
|
2006
|
+
});
|
|
2007
|
+
}
|
|
2008
|
+
// @__NO_SIDE_EFFECTS__
|
|
2009
|
+
function V(e) {
|
|
2010
|
+
return new en({
|
|
2011
|
+
check: "overwrite",
|
|
2012
|
+
tx: e
|
|
2013
|
+
});
|
|
2014
|
+
}
|
|
2015
|
+
// @__NO_SIDE_EFFECTS__
|
|
2016
|
+
function Ro(e) {
|
|
2017
|
+
return /* @__PURE__ */ V((t) => t.normalize(e));
|
|
2018
|
+
}
|
|
2019
|
+
// @__NO_SIDE_EFFECTS__
|
|
2020
|
+
function xo() {
|
|
2021
|
+
return /* @__PURE__ */ V((e) => e.trim());
|
|
2022
|
+
}
|
|
2023
|
+
// @__NO_SIDE_EFFECTS__
|
|
2024
|
+
function jo() {
|
|
2025
|
+
return /* @__PURE__ */ V((e) => e.toLowerCase());
|
|
2026
|
+
}
|
|
2027
|
+
// @__NO_SIDE_EFFECTS__
|
|
2028
|
+
function Mo() {
|
|
2029
|
+
return /* @__PURE__ */ V((e) => e.toUpperCase());
|
|
2030
|
+
}
|
|
2031
|
+
// @__NO_SIDE_EFFECTS__
|
|
2032
|
+
function Uo() {
|
|
2033
|
+
return /* @__PURE__ */ V((e) => Bt(e));
|
|
2034
|
+
}
|
|
2035
|
+
// @__NO_SIDE_EFFECTS__
|
|
2036
|
+
function Do(e, t, r) {
|
|
2037
|
+
return new e({
|
|
2038
|
+
type: "array",
|
|
2039
|
+
element: t,
|
|
2040
|
+
...f(r)
|
|
2041
|
+
});
|
|
2042
|
+
}
|
|
2043
|
+
// @__NO_SIDE_EFFECTS__
|
|
2044
|
+
function Fo(e, t, r) {
|
|
2045
|
+
const n = f(r);
|
|
2046
|
+
return n.abort ?? (n.abort = !0), new e({
|
|
2047
|
+
type: "custom",
|
|
2048
|
+
check: "custom",
|
|
2049
|
+
fn: t,
|
|
2050
|
+
...n
|
|
2051
|
+
});
|
|
2052
|
+
}
|
|
2053
|
+
// @__NO_SIDE_EFFECTS__
|
|
2054
|
+
function Lo(e, t, r) {
|
|
2055
|
+
return new e({
|
|
2056
|
+
type: "custom",
|
|
2057
|
+
check: "custom",
|
|
2058
|
+
fn: t,
|
|
2059
|
+
...f(r)
|
|
2060
|
+
});
|
|
2061
|
+
}
|
|
2062
|
+
// @__NO_SIDE_EFFECTS__
|
|
2063
|
+
function Vo(e) {
|
|
2064
|
+
const t = /* @__PURE__ */ Jo((r) => (r.addIssue = (n) => {
|
|
2065
|
+
if (typeof n == "string") r.issues.push(W(n, r.value, t._zod.def));
|
|
2066
|
+
else {
|
|
2067
|
+
const o = n;
|
|
2068
|
+
o.fatal && (o.continue = !1), o.code ?? (o.code = "custom"), o.input ?? (o.input = r.value), o.inst ?? (o.inst = t), o.continue ?? (o.continue = !t._zod.def.abort), r.issues.push(W(o));
|
|
2069
|
+
}
|
|
2070
|
+
}, e(r.value, r)));
|
|
2071
|
+
return t;
|
|
2072
|
+
}
|
|
2073
|
+
// @__NO_SIDE_EFFECTS__
|
|
2074
|
+
function Jo(e, t) {
|
|
2075
|
+
const r = new Z({
|
|
2076
|
+
check: "custom",
|
|
2077
|
+
...f(t)
|
|
2078
|
+
});
|
|
2079
|
+
return r._zod.check = e, r;
|
|
2080
|
+
}
|
|
2081
|
+
function $t(e) {
|
|
2082
|
+
let t = e?.target ?? "draft-2020-12";
|
|
2083
|
+
return t === "draft-4" && (t = "draft-04"), t === "draft-7" && (t = "draft-07"), {
|
|
2084
|
+
processors: e.processors ?? {},
|
|
2085
|
+
metadataRegistry: e?.metadata ?? J,
|
|
2086
|
+
target: t,
|
|
2087
|
+
unrepresentable: e?.unrepresentable ?? "throw",
|
|
2088
|
+
override: e?.override ?? (() => {
|
|
2089
|
+
}),
|
|
2090
|
+
io: e?.io ?? "output",
|
|
2091
|
+
counter: 0,
|
|
2092
|
+
seen: /* @__PURE__ */ new Map(),
|
|
2093
|
+
cycles: e?.cycles ?? "ref",
|
|
2094
|
+
reused: e?.reused ?? "inline",
|
|
2095
|
+
external: e?.external ?? void 0
|
|
2096
|
+
};
|
|
2097
|
+
}
|
|
2098
|
+
function k(e, t, r = {
|
|
2099
|
+
path: [],
|
|
2100
|
+
schemaPath: []
|
|
2101
|
+
}) {
|
|
2102
|
+
var n;
|
|
2103
|
+
const o = e._zod.def, a = t.seen.get(e);
|
|
2104
|
+
if (a)
|
|
2105
|
+
return a.count++, r.schemaPath.includes(e) && (a.cycle = r.path), a.schema;
|
|
2106
|
+
const i = {
|
|
2107
|
+
schema: {},
|
|
2108
|
+
count: 1,
|
|
2109
|
+
cycle: void 0,
|
|
2110
|
+
path: r.path
|
|
2111
|
+
};
|
|
2112
|
+
t.seen.set(e, i);
|
|
2113
|
+
const s = e._zod.toJSONSchema?.();
|
|
2114
|
+
if (s) i.schema = s;
|
|
2115
|
+
else {
|
|
2116
|
+
const l = {
|
|
2117
|
+
...r,
|
|
2118
|
+
schemaPath: [...r.schemaPath, e],
|
|
2119
|
+
path: r.path
|
|
2120
|
+
};
|
|
2121
|
+
if (e._zod.processJSONSchema) e._zod.processJSONSchema(t, i.schema, l);
|
|
2122
|
+
else {
|
|
2123
|
+
const p = i.schema, h = t.processors[o.type];
|
|
2124
|
+
if (!h) throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);
|
|
2125
|
+
h(e, t, p, l);
|
|
2126
|
+
}
|
|
2127
|
+
const d = e._zod.parent;
|
|
2128
|
+
d && (i.ref || (i.ref = d), k(d, t, l), t.seen.get(d).isParent = !0);
|
|
2129
|
+
}
|
|
2130
|
+
const u = t.metadataRegistry.get(e);
|
|
2131
|
+
return u && Object.assign(i.schema, u), t.io === "input" && $(e) && (delete i.schema.examples, delete i.schema.default), t.io === "input" && i.schema._prefault && ((n = i.schema).default ?? (n.default = i.schema._prefault)), delete i.schema._prefault, t.seen.get(e).schema;
|
|
2132
|
+
}
|
|
2133
|
+
function St(e, t) {
|
|
2134
|
+
const r = e.seen.get(t);
|
|
2135
|
+
if (!r) throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
2136
|
+
const n = /* @__PURE__ */ new Map();
|
|
2137
|
+
for (const i of e.seen.entries()) {
|
|
2138
|
+
const s = e.metadataRegistry.get(i[0])?.id;
|
|
2139
|
+
if (s) {
|
|
2140
|
+
const u = n.get(s);
|
|
2141
|
+
if (u && u !== i[0]) throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
|
|
2142
|
+
n.set(s, i[0]);
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
const o = (i) => {
|
|
2146
|
+
const s = e.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
2147
|
+
if (e.external) {
|
|
2148
|
+
const d = e.external.registry.get(i[0])?.id, p = e.external.uri ?? ((m) => m);
|
|
2149
|
+
if (d) return { ref: p(d) };
|
|
2150
|
+
const h = i[1].defId ?? i[1].schema.id ?? `schema${e.counter++}`;
|
|
2151
|
+
return i[1].defId = h, {
|
|
2152
|
+
defId: h,
|
|
2153
|
+
ref: `${p("__shared")}#/${s}/${h}`
|
|
2154
|
+
};
|
|
2155
|
+
}
|
|
2156
|
+
if (i[1] === r) return { ref: "#" };
|
|
2157
|
+
const u = `#/${s}/`, l = i[1].schema.id ?? `__schema${e.counter++}`;
|
|
2158
|
+
return {
|
|
2159
|
+
defId: l,
|
|
2160
|
+
ref: u + l
|
|
2161
|
+
};
|
|
2162
|
+
}, a = (i) => {
|
|
2163
|
+
if (i[1].schema.$ref) return;
|
|
2164
|
+
const s = i[1], { ref: u, defId: l } = o(i);
|
|
2165
|
+
s.def = { ...s.schema }, l && (s.defId = l);
|
|
2166
|
+
const d = s.schema;
|
|
2167
|
+
for (const p in d) delete d[p];
|
|
2168
|
+
d.$ref = u;
|
|
2169
|
+
};
|
|
2170
|
+
if (e.cycles === "throw") for (const i of e.seen.entries()) {
|
|
2171
|
+
const s = i[1];
|
|
2172
|
+
if (s.cycle) throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
|
|
2173
|
+
|
|
2174
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
|
|
2175
|
+
}
|
|
2176
|
+
for (const i of e.seen.entries()) {
|
|
2177
|
+
const s = i[1];
|
|
2178
|
+
if (t === i[0]) {
|
|
2179
|
+
a(i);
|
|
2180
|
+
continue;
|
|
2181
|
+
}
|
|
2182
|
+
if (e.external) {
|
|
2183
|
+
const u = e.external.registry.get(i[0])?.id;
|
|
2184
|
+
if (t !== i[0] && u) {
|
|
2185
|
+
a(i);
|
|
2186
|
+
continue;
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
if (e.metadataRegistry.get(i[0])?.id) {
|
|
2190
|
+
a(i);
|
|
2191
|
+
continue;
|
|
2192
|
+
}
|
|
2193
|
+
if (s.cycle) {
|
|
2194
|
+
a(i);
|
|
2195
|
+
continue;
|
|
2196
|
+
}
|
|
2197
|
+
if (s.count > 1 && e.reused === "ref") {
|
|
2198
|
+
a(i);
|
|
2199
|
+
continue;
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
function Zt(e, t) {
|
|
2204
|
+
const r = e.seen.get(t);
|
|
2205
|
+
if (!r) throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
2206
|
+
const n = (i) => {
|
|
2207
|
+
const s = e.seen.get(i);
|
|
2208
|
+
if (s.ref === null) return;
|
|
2209
|
+
const u = s.def ?? s.schema, l = { ...u }, d = s.ref;
|
|
2210
|
+
if (s.ref = null, d) {
|
|
2211
|
+
n(d);
|
|
2212
|
+
const h = e.seen.get(d), m = h.schema;
|
|
2213
|
+
if (m.$ref && (e.target === "draft-07" || e.target === "draft-04" || e.target === "openapi-3.0") ? (u.allOf = u.allOf ?? [], u.allOf.push(m)) : Object.assign(u, m), Object.assign(u, l), i._zod.parent === d) for (const w in u)
|
|
2214
|
+
w === "$ref" || w === "allOf" || w in l || delete u[w];
|
|
2215
|
+
if (m.$ref && h.def) for (const w in u)
|
|
2216
|
+
w === "$ref" || w === "allOf" || w in h.def && JSON.stringify(u[w]) === JSON.stringify(h.def[w]) && delete u[w];
|
|
2217
|
+
}
|
|
2218
|
+
const p = i._zod.parent;
|
|
2219
|
+
if (p && p !== d) {
|
|
2220
|
+
n(p);
|
|
2221
|
+
const h = e.seen.get(p);
|
|
2222
|
+
if (h?.schema.$ref && (u.$ref = h.schema.$ref, h.def))
|
|
2223
|
+
for (const m in u)
|
|
2224
|
+
m === "$ref" || m === "allOf" || m in h.def && JSON.stringify(u[m]) === JSON.stringify(h.def[m]) && delete u[m];
|
|
2225
|
+
}
|
|
2226
|
+
e.override({
|
|
2227
|
+
zodSchema: i,
|
|
2228
|
+
jsonSchema: u,
|
|
2229
|
+
path: s.path ?? []
|
|
2230
|
+
});
|
|
2231
|
+
};
|
|
2232
|
+
for (const i of [...e.seen.entries()].reverse()) n(i[0]);
|
|
2233
|
+
const o = {};
|
|
2234
|
+
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) {
|
|
2235
|
+
const i = e.external.registry.get(t)?.id;
|
|
2236
|
+
if (!i) throw new Error("Schema is missing an `id` property");
|
|
2237
|
+
o.$id = e.external.uri(i);
|
|
2238
|
+
}
|
|
2239
|
+
Object.assign(o, r.def ?? r.schema);
|
|
2240
|
+
const a = e.external?.defs ?? {};
|
|
2241
|
+
for (const i of e.seen.entries()) {
|
|
2242
|
+
const s = i[1];
|
|
2243
|
+
s.def && s.defId && (a[s.defId] = s.def);
|
|
2244
|
+
}
|
|
2245
|
+
e.external || Object.keys(a).length > 0 && (e.target === "draft-2020-12" ? o.$defs = a : o.definitions = a);
|
|
2246
|
+
try {
|
|
2247
|
+
const i = JSON.parse(JSON.stringify(o));
|
|
2248
|
+
return Object.defineProperty(i, "~standard", {
|
|
2249
|
+
value: {
|
|
2250
|
+
...t["~standard"],
|
|
2251
|
+
jsonSchema: {
|
|
2252
|
+
input: te(t, "input", e.processors),
|
|
2253
|
+
output: te(t, "output", e.processors)
|
|
2254
|
+
}
|
|
2255
|
+
},
|
|
2256
|
+
enumerable: !1,
|
|
2257
|
+
writable: !1
|
|
2258
|
+
}), i;
|
|
2259
|
+
} catch {
|
|
2260
|
+
throw new Error("Error converting schema to JSON.");
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
function $(e, t) {
|
|
2264
|
+
const r = t ?? { seen: /* @__PURE__ */ new Set() };
|
|
2265
|
+
if (r.seen.has(e)) return !1;
|
|
2266
|
+
r.seen.add(e);
|
|
2267
|
+
const n = e._zod.def;
|
|
2268
|
+
if (n.type === "transform") return !0;
|
|
2269
|
+
if (n.type === "array") return $(n.element, r);
|
|
2270
|
+
if (n.type === "set") return $(n.valueType, r);
|
|
2271
|
+
if (n.type === "lazy") return $(n.getter(), r);
|
|
2272
|
+
if (n.type === "promise" || n.type === "optional" || n.type === "nonoptional" || n.type === "nullable" || n.type === "readonly" || n.type === "default" || n.type === "prefault") return $(n.innerType, r);
|
|
2273
|
+
if (n.type === "intersection") return $(n.left, r) || $(n.right, r);
|
|
2274
|
+
if (n.type === "record" || n.type === "map") return $(n.keyType, r) || $(n.valueType, r);
|
|
2275
|
+
if (n.type === "pipe") return $(n.in, r) || $(n.out, r);
|
|
2276
|
+
if (n.type === "object") {
|
|
2277
|
+
for (const o in n.shape) if ($(n.shape[o], r)) return !0;
|
|
2278
|
+
return !1;
|
|
2279
|
+
}
|
|
2280
|
+
if (n.type === "union") {
|
|
2281
|
+
for (const o of n.options) if ($(o, r)) return !0;
|
|
2282
|
+
return !1;
|
|
2283
|
+
}
|
|
2284
|
+
if (n.type === "tuple") {
|
|
2285
|
+
for (const o of n.items) if ($(o, r)) return !0;
|
|
2286
|
+
return !!(n.rest && $(n.rest, r));
|
|
2287
|
+
}
|
|
2288
|
+
return !1;
|
|
2289
|
+
}
|
|
2290
|
+
var qo = (e, t = {}) => (r) => {
|
|
2291
|
+
const n = $t({
|
|
2292
|
+
...r,
|
|
2293
|
+
processors: t
|
|
2294
|
+
});
|
|
2295
|
+
return k(e, n), St(n, e), Zt(n, e);
|
|
2296
|
+
}, te = (e, t, r = {}) => (n) => {
|
|
2297
|
+
const { libraryOptions: o, target: a } = n ?? {}, i = $t({
|
|
2298
|
+
...o ?? {},
|
|
2299
|
+
target: a,
|
|
2300
|
+
io: t,
|
|
2301
|
+
processors: r
|
|
2302
|
+
});
|
|
2303
|
+
return k(e, i), St(i, e), Zt(i, e);
|
|
2304
|
+
}, Wo = {
|
|
2305
|
+
guid: "uuid",
|
|
2306
|
+
url: "uri",
|
|
2307
|
+
datetime: "date-time",
|
|
2308
|
+
json_string: "json-string",
|
|
2309
|
+
regex: ""
|
|
2310
|
+
}, Bo = (e, t, r, n) => {
|
|
2311
|
+
const o = r;
|
|
2312
|
+
o.type = "string";
|
|
2313
|
+
const { minimum: a, maximum: i, format: s, patterns: u, contentEncoding: l } = e._zod.bag;
|
|
2314
|
+
if (typeof a == "number" && (o.minLength = a), typeof i == "number" && (o.maxLength = i), s && (o.format = Wo[s] ?? s, o.format === "" && delete o.format, s === "time" && delete o.format), l && (o.contentEncoding = l), u && u.size > 0) {
|
|
2315
|
+
const d = [...u];
|
|
2316
|
+
d.length === 1 ? o.pattern = d[0].source : d.length > 1 && (o.allOf = [...d.map((p) => ({
|
|
2317
|
+
...t.target === "draft-07" || t.target === "draft-04" || t.target === "openapi-3.0" ? { type: "string" } : {},
|
|
2318
|
+
pattern: p.source
|
|
2319
|
+
}))]);
|
|
2320
|
+
}
|
|
2321
|
+
}, Ho = (e, t, r, n) => {
|
|
2322
|
+
const o = r, { minimum: a, maximum: i, format: s, multipleOf: u, exclusiveMaximum: l, exclusiveMinimum: d } = e._zod.bag;
|
|
2323
|
+
typeof s == "string" && s.includes("int") ? o.type = "integer" : o.type = "number", typeof d == "number" && (t.target === "draft-04" || t.target === "openapi-3.0" ? (o.minimum = d, o.exclusiveMinimum = !0) : o.exclusiveMinimum = d), typeof a == "number" && (o.minimum = a, typeof d == "number" && t.target !== "draft-04" && (d >= a ? delete o.minimum : delete o.exclusiveMinimum)), typeof l == "number" && (t.target === "draft-04" || t.target === "openapi-3.0" ? (o.maximum = l, o.exclusiveMaximum = !0) : o.exclusiveMaximum = l), typeof i == "number" && (o.maximum = i, typeof l == "number" && t.target !== "draft-04" && (l <= i ? delete o.maximum : delete o.exclusiveMaximum)), typeof u == "number" && (o.multipleOf = u);
|
|
2324
|
+
}, Ko = (e, t, r, n) => {
|
|
2325
|
+
r.type = "boolean";
|
|
2326
|
+
}, Go = (e, t, r, n) => {
|
|
2327
|
+
r.not = {};
|
|
2328
|
+
}, Xo = (e, t, r, n) => {
|
|
2329
|
+
}, Qo = (e, t, r, n) => {
|
|
2330
|
+
const o = e._zod.def, a = ot(o.entries);
|
|
2331
|
+
a.every((i) => typeof i == "number") && (r.type = "number"), a.every((i) => typeof i == "string") && (r.type = "string"), r.enum = a;
|
|
2332
|
+
}, Yo = (e, t, r, n) => {
|
|
2333
|
+
if (t.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
|
|
2334
|
+
}, ei = (e, t, r, n) => {
|
|
2335
|
+
if (t.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
|
|
2336
|
+
}, ti = (e, t, r, n) => {
|
|
2337
|
+
const o = r, a = e._zod.def, { minimum: i, maximum: s } = e._zod.bag;
|
|
2338
|
+
typeof i == "number" && (o.minItems = i), typeof s == "number" && (o.maxItems = s), o.type = "array", o.items = k(a.element, t, {
|
|
2339
|
+
...n,
|
|
2340
|
+
path: [...n.path, "items"]
|
|
2341
|
+
});
|
|
2342
|
+
}, ri = (e, t, r, n) => {
|
|
2343
|
+
const o = r, a = e._zod.def;
|
|
2344
|
+
o.type = "object", o.properties = {};
|
|
2345
|
+
const i = a.shape;
|
|
2346
|
+
for (const l in i) o.properties[l] = k(i[l], t, {
|
|
2347
|
+
...n,
|
|
2348
|
+
path: [
|
|
2349
|
+
...n.path,
|
|
2350
|
+
"properties",
|
|
2351
|
+
l
|
|
2352
|
+
]
|
|
2353
|
+
});
|
|
2354
|
+
const s = new Set(Object.keys(i)), u = new Set([...s].filter((l) => {
|
|
2355
|
+
const d = a.shape[l]._zod;
|
|
2356
|
+
return t.io === "input" ? d.optin === void 0 : d.optout === void 0;
|
|
2357
|
+
}));
|
|
2358
|
+
u.size > 0 && (o.required = Array.from(u)), a.catchall?._zod.def.type === "never" ? o.additionalProperties = !1 : a.catchall ? a.catchall && (o.additionalProperties = k(a.catchall, t, {
|
|
2359
|
+
...n,
|
|
2360
|
+
path: [...n.path, "additionalProperties"]
|
|
2361
|
+
})) : t.io === "output" && (o.additionalProperties = !1);
|
|
2362
|
+
}, ni = (e, t, r, n) => {
|
|
2363
|
+
const o = e._zod.def, a = o.inclusive === !1, i = o.options.map((s, u) => k(s, t, {
|
|
2364
|
+
...n,
|
|
2365
|
+
path: [
|
|
2366
|
+
...n.path,
|
|
2367
|
+
a ? "oneOf" : "anyOf",
|
|
2368
|
+
u
|
|
2369
|
+
]
|
|
2370
|
+
}));
|
|
2371
|
+
a ? r.oneOf = i : r.anyOf = i;
|
|
2372
|
+
}, oi = (e, t, r, n) => {
|
|
2373
|
+
const o = e._zod.def, a = k(o.left, t, {
|
|
2374
|
+
...n,
|
|
2375
|
+
path: [
|
|
2376
|
+
...n.path,
|
|
2377
|
+
"allOf",
|
|
2378
|
+
0
|
|
2379
|
+
]
|
|
2380
|
+
}), i = k(o.right, t, {
|
|
2381
|
+
...n,
|
|
2382
|
+
path: [
|
|
2383
|
+
...n.path,
|
|
2384
|
+
"allOf",
|
|
2385
|
+
1
|
|
2386
|
+
]
|
|
2387
|
+
}), s = (u) => "allOf" in u && Object.keys(u).length === 1;
|
|
2388
|
+
r.allOf = [...s(a) ? a.allOf : [a], ...s(i) ? i.allOf : [i]];
|
|
2389
|
+
}, ii = (e, t, r, n) => {
|
|
2390
|
+
const o = e._zod.def, a = k(o.innerType, t, n), i = t.seen.get(e);
|
|
2391
|
+
t.target === "openapi-3.0" ? (i.ref = o.innerType, r.nullable = !0) : r.anyOf = [a, { type: "null" }];
|
|
2392
|
+
}, ai = (e, t, r, n) => {
|
|
2393
|
+
const o = e._zod.def;
|
|
2394
|
+
k(o.innerType, t, n);
|
|
2395
|
+
const a = t.seen.get(e);
|
|
2396
|
+
a.ref = o.innerType;
|
|
2397
|
+
}, si = (e, t, r, n) => {
|
|
2398
|
+
const o = e._zod.def;
|
|
2399
|
+
k(o.innerType, t, n);
|
|
2400
|
+
const a = t.seen.get(e);
|
|
2401
|
+
a.ref = o.innerType, r.default = JSON.parse(JSON.stringify(o.defaultValue));
|
|
2402
|
+
}, ci = (e, t, r, n) => {
|
|
2403
|
+
const o = e._zod.def;
|
|
2404
|
+
k(o.innerType, t, n);
|
|
2405
|
+
const a = t.seen.get(e);
|
|
2406
|
+
a.ref = o.innerType, t.io === "input" && (r._prefault = JSON.parse(JSON.stringify(o.defaultValue)));
|
|
2407
|
+
}, ui = (e, t, r, n) => {
|
|
2408
|
+
const o = e._zod.def;
|
|
2409
|
+
k(o.innerType, t, n);
|
|
2410
|
+
const a = t.seen.get(e);
|
|
2411
|
+
a.ref = o.innerType;
|
|
2412
|
+
let i;
|
|
2413
|
+
try {
|
|
2414
|
+
i = o.catchValue(void 0);
|
|
2415
|
+
} catch {
|
|
2416
|
+
throw new Error("Dynamic catch values are not supported in JSON Schema");
|
|
2417
|
+
}
|
|
2418
|
+
r.default = i;
|
|
2419
|
+
}, li = (e, t, r, n) => {
|
|
2420
|
+
const o = e._zod.def, a = t.io === "input" ? o.in._zod.def.type === "transform" ? o.out : o.in : o.out;
|
|
2421
|
+
k(a, t, n);
|
|
2422
|
+
const i = t.seen.get(e);
|
|
2423
|
+
i.ref = a;
|
|
2424
|
+
}, di = (e, t, r, n) => {
|
|
2425
|
+
const o = e._zod.def;
|
|
2426
|
+
k(o.innerType, t, n);
|
|
2427
|
+
const a = t.seen.get(e);
|
|
2428
|
+
a.ref = o.innerType, r.readOnly = !0;
|
|
2429
|
+
}, Ot = (e, t, r, n) => {
|
|
2430
|
+
const o = e._zod.def;
|
|
2431
|
+
k(o.innerType, t, n);
|
|
2432
|
+
const a = t.seen.get(e);
|
|
2433
|
+
a.ref = o.innerType;
|
|
2434
|
+
}, fi = /* @__PURE__ */ c("ZodISODateTime", (e, t) => {
|
|
2435
|
+
mn.init(e, t), _.init(e, t);
|
|
2436
|
+
});
|
|
2437
|
+
function hi(e) {
|
|
2438
|
+
return /* @__PURE__ */ wo(fi, e);
|
|
2439
|
+
}
|
|
2440
|
+
var pi = /* @__PURE__ */ c("ZodISODate", (e, t) => {
|
|
2441
|
+
gn.init(e, t), _.init(e, t);
|
|
2442
|
+
});
|
|
2443
|
+
function mi(e) {
|
|
2444
|
+
return /* @__PURE__ */ yo(pi, e);
|
|
2445
|
+
}
|
|
2446
|
+
var gi = /* @__PURE__ */ c("ZodISOTime", (e, t) => {
|
|
2447
|
+
vn.init(e, t), _.init(e, t);
|
|
2448
|
+
});
|
|
2449
|
+
function vi(e) {
|
|
2450
|
+
return /* @__PURE__ */ zo(gi, e);
|
|
2451
|
+
}
|
|
2452
|
+
var bi = /* @__PURE__ */ c("ZodISODuration", (e, t) => {
|
|
2453
|
+
bn.init(e, t), _.init(e, t);
|
|
2454
|
+
});
|
|
2455
|
+
function _i(e) {
|
|
2456
|
+
return /* @__PURE__ */ ko(bi, e);
|
|
2457
|
+
}
|
|
2458
|
+
var Et = (e, t) => {
|
|
2459
|
+
ut.init(e, t), e.name = "ZodError", Object.defineProperties(e, {
|
|
2460
|
+
format: { value: (r) => ar(e, r) },
|
|
2461
|
+
flatten: { value: (r) => ir(e, r) },
|
|
2462
|
+
addIssue: { value: (r) => {
|
|
2463
|
+
e.issues.push(r), e.message = JSON.stringify(e.issues, me, 2);
|
|
2464
|
+
} },
|
|
2465
|
+
addIssues: { value: (r) => {
|
|
2466
|
+
e.issues.push(...r), e.message = JSON.stringify(e.issues, me, 2);
|
|
2467
|
+
} },
|
|
2468
|
+
isEmpty: { get() {
|
|
2469
|
+
return e.issues.length === 0;
|
|
2470
|
+
} }
|
|
2471
|
+
});
|
|
2472
|
+
}, Ka = c("ZodError", Et), E = c("ZodError", Et, { Parent: Error }), wi = /* @__PURE__ */ $e(E), yi = /* @__PURE__ */ Se(E), zi = /* @__PURE__ */ oe(E), ki = /* @__PURE__ */ ie(E), $i = /* @__PURE__ */ ur(E), Si = /* @__PURE__ */ lr(E), Zi = /* @__PURE__ */ dr(E), Oi = /* @__PURE__ */ fr(E), Ei = /* @__PURE__ */ hr(E), Ii = /* @__PURE__ */ pr(E), Ti = /* @__PURE__ */ mr(E), Pi = /* @__PURE__ */ gr(E), z = /* @__PURE__ */ c("ZodType", (e, t) => (y.init(e, t), Object.assign(e["~standard"], { jsonSchema: {
|
|
2473
|
+
input: te(e, "input"),
|
|
2474
|
+
output: te(e, "output")
|
|
2475
|
+
} }), e.toJSONSchema = qo(e, {}), e.def = t, e.type = t.type, Object.defineProperty(e, "_def", { value: t }), e.check = (...r) => e.clone(N(t, { checks: [...t.checks ?? [], ...r.map((n) => typeof n == "function" ? { _zod: {
|
|
2476
|
+
check: n,
|
|
2477
|
+
def: { check: "custom" },
|
|
2478
|
+
onattach: []
|
|
2479
|
+
} } : n)] }), { parent: !0 }), e.with = e.check, e.clone = (r, n) => R(e, r, n), e.brand = () => e, e.register = ((r, n) => (r.add(e, n), e)), e.parse = (r, n) => wi(e, r, n, { callee: e.parse }), e.safeParse = (r, n) => zi(e, r, n), e.parseAsync = async (r, n) => yi(e, r, n, { callee: e.parseAsync }), e.safeParseAsync = async (r, n) => ki(e, r, n), e.spa = e.safeParseAsync, e.encode = (r, n) => $i(e, r, n), e.decode = (r, n) => Si(e, r, n), e.encodeAsync = async (r, n) => Zi(e, r, n), e.decodeAsync = async (r, n) => Oi(e, r, n), e.safeEncode = (r, n) => Ei(e, r, n), e.safeDecode = (r, n) => Ii(e, r, n), e.safeEncodeAsync = async (r, n) => Ti(e, r, n), e.safeDecodeAsync = async (r, n) => Pi(e, r, n), e.refine = (r, n) => e.check(za(r, n)), e.superRefine = (r) => e.check(ka(r)), e.overwrite = (r) => e.check(/* @__PURE__ */ V(r)), e.optional = () => Ge(e), e.exactOptional = () => ua(e), e.nullable = () => Xe(e), e.nullish = () => Ge(Xe(e)), e.nonoptional = (r) => ma(e, r), e.array = () => Oe(e), e.or = (r) => Pt([e, r]), e.and = (r) => ia(e, r), e.transform = (r) => Qe(e, sa(r)), e.default = (r) => fa(e, r), e.prefault = (r) => pa(e, r), e.catch = (r) => va(e, r), e.pipe = (r) => Qe(e, r), e.readonly = () => wa(e), e.describe = (r) => {
|
|
2480
|
+
const n = e.clone();
|
|
2481
|
+
return J.add(n, { description: r }), n;
|
|
2482
|
+
}, Object.defineProperty(e, "description", {
|
|
2483
|
+
get() {
|
|
2484
|
+
return J.get(e)?.description;
|
|
2485
|
+
},
|
|
2486
|
+
configurable: !0
|
|
2487
|
+
}), e.meta = (...r) => {
|
|
2488
|
+
if (r.length === 0) return J.get(e);
|
|
2489
|
+
const n = e.clone();
|
|
2490
|
+
return J.add(n, r[0]), n;
|
|
2491
|
+
}, e.isOptional = () => e.safeParse(void 0).success, e.isNullable = () => e.safeParse(null).success, e.apply = (r) => r(e), e)), It = /* @__PURE__ */ c("_ZodString", (e, t) => {
|
|
2492
|
+
Ze.init(e, t), z.init(e, t), e._zod.processJSONSchema = (n, o, a) => Bo(e, n, o, a);
|
|
2493
|
+
const r = e._zod.bag;
|
|
2494
|
+
e.format = r.format ?? null, e.minLength = r.minimum ?? null, e.maxLength = r.maximum ?? null, e.regex = (...n) => e.check(/* @__PURE__ */ Io(...n)), e.includes = (...n) => e.check(/* @__PURE__ */ Ao(...n)), e.startsWith = (...n) => e.check(/* @__PURE__ */ Co(...n)), e.endsWith = (...n) => e.check(/* @__PURE__ */ No(...n)), e.min = (...n) => e.check(/* @__PURE__ */ ee(...n)), e.max = (...n) => e.check(/* @__PURE__ */ zt(...n)), e.length = (...n) => e.check(/* @__PURE__ */ kt(...n)), e.nonempty = (...n) => e.check(/* @__PURE__ */ ee(1, ...n)), e.lowercase = (n) => e.check(/* @__PURE__ */ To(n)), e.uppercase = (n) => e.check(/* @__PURE__ */ Po(n)), e.trim = () => e.check(/* @__PURE__ */ xo()), e.normalize = (...n) => e.check(/* @__PURE__ */ Ro(...n)), e.toLowerCase = () => e.check(/* @__PURE__ */ jo()), e.toUpperCase = () => e.check(/* @__PURE__ */ Mo()), e.slugify = () => e.check(/* @__PURE__ */ Uo());
|
|
2495
|
+
}), Ai = /* @__PURE__ */ c("ZodString", (e, t) => {
|
|
2496
|
+
Ze.init(e, t), It.init(e, t), e.email = (r) => e.check(/* @__PURE__ */ Qn(Ci, r)), e.url = (r) => e.check(/* @__PURE__ */ no(Ni, r)), e.jwt = (r) => e.check(/* @__PURE__ */ _o(Ki, r)), e.emoji = (r) => e.check(/* @__PURE__ */ oo(Ri, r)), e.guid = (r) => e.check(/* @__PURE__ */ Ve(Be, r)), e.uuid = (r) => e.check(/* @__PURE__ */ Yn(K, r)), e.uuidv4 = (r) => e.check(/* @__PURE__ */ eo(K, r)), e.uuidv6 = (r) => e.check(/* @__PURE__ */ to(K, r)), e.uuidv7 = (r) => e.check(/* @__PURE__ */ ro(K, r)), e.nanoid = (r) => e.check(/* @__PURE__ */ io(xi, r)), e.guid = (r) => e.check(/* @__PURE__ */ Ve(Be, r)), e.cuid = (r) => e.check(/* @__PURE__ */ ao(ji, r)), e.cuid2 = (r) => e.check(/* @__PURE__ */ so(Mi, r)), e.ulid = (r) => e.check(/* @__PURE__ */ co(Ui, r)), e.base64 = (r) => e.check(/* @__PURE__ */ go(Wi, r)), e.base64url = (r) => e.check(/* @__PURE__ */ vo(Bi, r)), e.xid = (r) => e.check(/* @__PURE__ */ uo(Di, r)), e.ksuid = (r) => e.check(/* @__PURE__ */ lo(Fi, r)), e.ipv4 = (r) => e.check(/* @__PURE__ */ fo(Li, r)), e.ipv6 = (r) => e.check(/* @__PURE__ */ ho(Vi, r)), e.cidrv4 = (r) => e.check(/* @__PURE__ */ po(Ji, r)), e.cidrv6 = (r) => e.check(/* @__PURE__ */ mo(qi, r)), e.e164 = (r) => e.check(/* @__PURE__ */ bo(Hi, r)), e.datetime = (r) => e.check(hi(r)), e.date = (r) => e.check(mi(r)), e.time = (r) => e.check(vi(r)), e.duration = (r) => e.check(_i(r));
|
|
2497
|
+
});
|
|
2498
|
+
function v(e) {
|
|
2499
|
+
return /* @__PURE__ */ Xn(Ai, e);
|
|
2500
|
+
}
|
|
2501
|
+
var _ = /* @__PURE__ */ c("ZodStringFormat", (e, t) => {
|
|
2502
|
+
b.init(e, t), It.init(e, t);
|
|
2503
|
+
}), Ci = /* @__PURE__ */ c("ZodEmail", (e, t) => {
|
|
2504
|
+
an.init(e, t), _.init(e, t);
|
|
2505
|
+
}), Be = /* @__PURE__ */ c("ZodGUID", (e, t) => {
|
|
2506
|
+
nn.init(e, t), _.init(e, t);
|
|
2507
|
+
}), K = /* @__PURE__ */ c("ZodUUID", (e, t) => {
|
|
2508
|
+
on.init(e, t), _.init(e, t);
|
|
2509
|
+
}), Ni = /* @__PURE__ */ c("ZodURL", (e, t) => {
|
|
2510
|
+
sn.init(e, t), _.init(e, t);
|
|
2511
|
+
}), Ri = /* @__PURE__ */ c("ZodEmoji", (e, t) => {
|
|
2512
|
+
cn.init(e, t), _.init(e, t);
|
|
2513
|
+
}), xi = /* @__PURE__ */ c("ZodNanoID", (e, t) => {
|
|
2514
|
+
un.init(e, t), _.init(e, t);
|
|
2515
|
+
}), ji = /* @__PURE__ */ c("ZodCUID", (e, t) => {
|
|
2516
|
+
ln.init(e, t), _.init(e, t);
|
|
2517
|
+
}), Mi = /* @__PURE__ */ c("ZodCUID2", (e, t) => {
|
|
2518
|
+
dn.init(e, t), _.init(e, t);
|
|
2519
|
+
}), Ui = /* @__PURE__ */ c("ZodULID", (e, t) => {
|
|
2520
|
+
fn.init(e, t), _.init(e, t);
|
|
2521
|
+
}), Di = /* @__PURE__ */ c("ZodXID", (e, t) => {
|
|
2522
|
+
hn.init(e, t), _.init(e, t);
|
|
2523
|
+
}), Fi = /* @__PURE__ */ c("ZodKSUID", (e, t) => {
|
|
2524
|
+
pn.init(e, t), _.init(e, t);
|
|
2525
|
+
}), Li = /* @__PURE__ */ c("ZodIPv4", (e, t) => {
|
|
2526
|
+
_n.init(e, t), _.init(e, t);
|
|
2527
|
+
}), Vi = /* @__PURE__ */ c("ZodIPv6", (e, t) => {
|
|
2528
|
+
wn.init(e, t), _.init(e, t);
|
|
2529
|
+
}), Ji = /* @__PURE__ */ c("ZodCIDRv4", (e, t) => {
|
|
2530
|
+
yn.init(e, t), _.init(e, t);
|
|
2531
|
+
}), qi = /* @__PURE__ */ c("ZodCIDRv6", (e, t) => {
|
|
2532
|
+
zn.init(e, t), _.init(e, t);
|
|
2533
|
+
}), Wi = /* @__PURE__ */ c("ZodBase64", (e, t) => {
|
|
2534
|
+
kn.init(e, t), _.init(e, t);
|
|
2535
|
+
}), Bi = /* @__PURE__ */ c("ZodBase64URL", (e, t) => {
|
|
2536
|
+
Sn.init(e, t), _.init(e, t);
|
|
2537
|
+
}), Hi = /* @__PURE__ */ c("ZodE164", (e, t) => {
|
|
2538
|
+
Zn.init(e, t), _.init(e, t);
|
|
2539
|
+
}), Ki = /* @__PURE__ */ c("ZodJWT", (e, t) => {
|
|
2540
|
+
En.init(e, t), _.init(e, t);
|
|
2541
|
+
}), Tt = /* @__PURE__ */ c("ZodNumber", (e, t) => {
|
|
2542
|
+
bt.init(e, t), z.init(e, t), e._zod.processJSONSchema = (n, o, a) => Ho(e, n, o, a), e.gt = (n, o) => e.check(/* @__PURE__ */ qe(n, o)), e.gte = (n, o) => e.check(/* @__PURE__ */ ue(n, o)), e.min = (n, o) => e.check(/* @__PURE__ */ ue(n, o)), e.lt = (n, o) => e.check(/* @__PURE__ */ Je(n, o)), e.lte = (n, o) => e.check(/* @__PURE__ */ ce(n, o)), e.max = (n, o) => e.check(/* @__PURE__ */ ce(n, o)), e.int = (n) => e.check(He(n)), e.safe = (n) => e.check(He(n)), e.positive = (n) => e.check(/* @__PURE__ */ qe(0, n)), e.nonnegative = (n) => e.check(/* @__PURE__ */ ue(0, n)), e.negative = (n) => e.check(/* @__PURE__ */ Je(0, n)), e.nonpositive = (n) => e.check(/* @__PURE__ */ ce(0, n)), e.multipleOf = (n, o) => e.check(/* @__PURE__ */ We(n, o)), e.step = (n, o) => e.check(/* @__PURE__ */ We(n, o)), e.finite = () => e;
|
|
2543
|
+
const r = e._zod.bag;
|
|
2544
|
+
e.minValue = Math.max(r.minimum ?? Number.NEGATIVE_INFINITY, r.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null, e.maxValue = Math.min(r.maximum ?? Number.POSITIVE_INFINITY, r.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null, e.isInt = (r.format ?? "").includes("int") || Number.isSafeInteger(r.multipleOf ?? 0.5), e.isFinite = !0, e.format = r.format ?? null;
|
|
2545
|
+
});
|
|
2546
|
+
function ve(e) {
|
|
2547
|
+
return /* @__PURE__ */ $o(Tt, e);
|
|
2548
|
+
}
|
|
2549
|
+
var Gi = /* @__PURE__ */ c("ZodNumberFormat", (e, t) => {
|
|
2550
|
+
In.init(e, t), Tt.init(e, t);
|
|
2551
|
+
});
|
|
2552
|
+
function He(e) {
|
|
2553
|
+
return /* @__PURE__ */ So(Gi, e);
|
|
2554
|
+
}
|
|
2555
|
+
var Xi = /* @__PURE__ */ c("ZodBoolean", (e, t) => {
|
|
2556
|
+
Tn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => Ko(e, r, n, o);
|
|
2557
|
+
});
|
|
2558
|
+
function C(e) {
|
|
2559
|
+
return /* @__PURE__ */ Zo(Xi, e);
|
|
2560
|
+
}
|
|
2561
|
+
var Qi = /* @__PURE__ */ c("ZodUnknown", (e, t) => {
|
|
2562
|
+
Pn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => Xo(e, r, n, o);
|
|
2563
|
+
});
|
|
2564
|
+
function Ke() {
|
|
2565
|
+
return /* @__PURE__ */ Oo(Qi);
|
|
2566
|
+
}
|
|
2567
|
+
var Yi = /* @__PURE__ */ c("ZodNever", (e, t) => {
|
|
2568
|
+
An.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => Go(e, r, n, o);
|
|
2569
|
+
});
|
|
2570
|
+
function ea(e) {
|
|
2571
|
+
return /* @__PURE__ */ Eo(Yi, e);
|
|
2572
|
+
}
|
|
2573
|
+
var ta = /* @__PURE__ */ c("ZodArray", (e, t) => {
|
|
2574
|
+
Cn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => ti(e, r, n, o), e.element = t.element, e.min = (r, n) => e.check(/* @__PURE__ */ ee(r, n)), e.nonempty = (r) => e.check(/* @__PURE__ */ ee(1, r)), e.max = (r, n) => e.check(/* @__PURE__ */ zt(r, n)), e.length = (r, n) => e.check(/* @__PURE__ */ kt(r, n)), e.unwrap = () => e.element;
|
|
2575
|
+
});
|
|
2576
|
+
function Oe(e, t) {
|
|
2577
|
+
return /* @__PURE__ */ Do(ta, e, t);
|
|
2578
|
+
}
|
|
2579
|
+
var ra = /* @__PURE__ */ c("ZodObject", (e, t) => {
|
|
2580
|
+
Rn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => ri(e, r, n, o), g(e, "shape", () => t.shape), e.keyof = () => O(Object.keys(e._zod.def.shape)), e.catchall = (r) => e.clone({
|
|
2581
|
+
...e._zod.def,
|
|
2582
|
+
catchall: r
|
|
2583
|
+
}), e.passthrough = () => e.clone({
|
|
2584
|
+
...e._zod.def,
|
|
2585
|
+
catchall: Ke()
|
|
2586
|
+
}), e.loose = () => e.clone({
|
|
2587
|
+
...e._zod.def,
|
|
2588
|
+
catchall: Ke()
|
|
2589
|
+
}), e.strict = () => e.clone({
|
|
2590
|
+
...e._zod.def,
|
|
2591
|
+
catchall: ea()
|
|
2592
|
+
}), e.strip = () => e.clone({
|
|
2593
|
+
...e._zod.def,
|
|
2594
|
+
catchall: void 0
|
|
2595
|
+
}), e.extend = (r) => er(e, r), e.safeExtend = (r) => tr(e, r), e.merge = (r) => rr(e, r), e.pick = (r) => Qt(e, r), e.omit = (r) => Yt(e, r), e.partial = (...r) => nr(At, e, r[0]), e.required = (...r) => or(Ct, e, r[0]);
|
|
2596
|
+
});
|
|
2597
|
+
function A(e, t) {
|
|
2598
|
+
return new ra({
|
|
2599
|
+
type: "object",
|
|
2600
|
+
shape: e ?? {},
|
|
2601
|
+
...f(t)
|
|
2602
|
+
});
|
|
2603
|
+
}
|
|
2604
|
+
var na = /* @__PURE__ */ c("ZodUnion", (e, t) => {
|
|
2605
|
+
xn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => ni(e, r, n, o), e.options = t.options;
|
|
2606
|
+
});
|
|
2607
|
+
function Pt(e, t) {
|
|
2608
|
+
return new na({
|
|
2609
|
+
type: "union",
|
|
2610
|
+
options: e,
|
|
2611
|
+
...f(t)
|
|
2612
|
+
});
|
|
2613
|
+
}
|
|
2614
|
+
var oa = /* @__PURE__ */ c("ZodIntersection", (e, t) => {
|
|
2615
|
+
jn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => oi(e, r, n, o);
|
|
2616
|
+
});
|
|
2617
|
+
function ia(e, t) {
|
|
2618
|
+
return new oa({
|
|
2619
|
+
type: "intersection",
|
|
2620
|
+
left: e,
|
|
2621
|
+
right: t
|
|
2622
|
+
});
|
|
2623
|
+
}
|
|
2624
|
+
var be = /* @__PURE__ */ c("ZodEnum", (e, t) => {
|
|
2625
|
+
Mn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (n, o, a) => Qo(e, n, o, a), e.enum = t.entries, e.options = Object.values(t.entries);
|
|
2626
|
+
const r = new Set(Object.keys(t.entries));
|
|
2627
|
+
e.extract = (n, o) => {
|
|
2628
|
+
const a = {};
|
|
2629
|
+
for (const i of n) if (r.has(i)) a[i] = t.entries[i];
|
|
2630
|
+
else throw new Error(`Key ${i} not found in enum`);
|
|
2631
|
+
return new be({
|
|
2632
|
+
...t,
|
|
2633
|
+
checks: [],
|
|
2634
|
+
...f(o),
|
|
2635
|
+
entries: a
|
|
2636
|
+
});
|
|
2637
|
+
}, e.exclude = (n, o) => {
|
|
2638
|
+
const a = { ...t.entries };
|
|
2639
|
+
for (const i of n) if (r.has(i)) delete a[i];
|
|
2640
|
+
else throw new Error(`Key ${i} not found in enum`);
|
|
2641
|
+
return new be({
|
|
2642
|
+
...t,
|
|
2643
|
+
checks: [],
|
|
2644
|
+
...f(o),
|
|
2645
|
+
entries: a
|
|
2646
|
+
});
|
|
2647
|
+
};
|
|
2648
|
+
});
|
|
2649
|
+
function O(e, t) {
|
|
2650
|
+
return new be({
|
|
2651
|
+
type: "enum",
|
|
2652
|
+
entries: Array.isArray(e) ? Object.fromEntries(e.map((r) => [r, r])) : e,
|
|
2653
|
+
...f(t)
|
|
2654
|
+
});
|
|
2655
|
+
}
|
|
2656
|
+
var aa = /* @__PURE__ */ c("ZodTransform", (e, t) => {
|
|
2657
|
+
Un.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => ei(e, r, n, o), e._zod.parse = (r, n) => {
|
|
2658
|
+
if (n.direction === "backward") throw new nt(e.constructor.name);
|
|
2659
|
+
r.addIssue = (a) => {
|
|
2660
|
+
if (typeof a == "string") r.issues.push(W(a, r.value, t));
|
|
2661
|
+
else {
|
|
2662
|
+
const i = a;
|
|
2663
|
+
i.fatal && (i.continue = !1), i.code ?? (i.code = "custom"), i.input ?? (i.input = r.value), i.inst ?? (i.inst = e), r.issues.push(W(i));
|
|
2664
|
+
}
|
|
2665
|
+
};
|
|
2666
|
+
const o = t.transform(r.value, r);
|
|
2667
|
+
return o instanceof Promise ? o.then((a) => (r.value = a, r)) : (r.value = o, r);
|
|
2668
|
+
};
|
|
2669
|
+
});
|
|
2670
|
+
function sa(e) {
|
|
2671
|
+
return new aa({
|
|
2672
|
+
type: "transform",
|
|
2673
|
+
transform: e
|
|
2674
|
+
});
|
|
2675
|
+
}
|
|
2676
|
+
var At = /* @__PURE__ */ c("ZodOptional", (e, t) => {
|
|
2677
|
+
yt.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => Ot(e, r, n, o), e.unwrap = () => e._zod.def.innerType;
|
|
2678
|
+
});
|
|
2679
|
+
function Ge(e) {
|
|
2680
|
+
return new At({
|
|
2681
|
+
type: "optional",
|
|
2682
|
+
innerType: e
|
|
2683
|
+
});
|
|
2684
|
+
}
|
|
2685
|
+
var ca = /* @__PURE__ */ c("ZodExactOptional", (e, t) => {
|
|
2686
|
+
Dn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => Ot(e, r, n, o), e.unwrap = () => e._zod.def.innerType;
|
|
2687
|
+
});
|
|
2688
|
+
function ua(e) {
|
|
2689
|
+
return new ca({
|
|
2690
|
+
type: "optional",
|
|
2691
|
+
innerType: e
|
|
2692
|
+
});
|
|
2693
|
+
}
|
|
2694
|
+
var la = /* @__PURE__ */ c("ZodNullable", (e, t) => {
|
|
2695
|
+
Fn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => ii(e, r, n, o), e.unwrap = () => e._zod.def.innerType;
|
|
2696
|
+
});
|
|
2697
|
+
function Xe(e) {
|
|
2698
|
+
return new la({
|
|
2699
|
+
type: "nullable",
|
|
2700
|
+
innerType: e
|
|
2701
|
+
});
|
|
2702
|
+
}
|
|
2703
|
+
var da = /* @__PURE__ */ c("ZodDefault", (e, t) => {
|
|
2704
|
+
Ln.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => si(e, r, n, o), e.unwrap = () => e._zod.def.innerType, e.removeDefault = e.unwrap;
|
|
2705
|
+
});
|
|
2706
|
+
function fa(e, t) {
|
|
2707
|
+
return new da({
|
|
2708
|
+
type: "default",
|
|
2709
|
+
innerType: e,
|
|
2710
|
+
get defaultValue() {
|
|
2711
|
+
return typeof t == "function" ? t() : at(t);
|
|
2712
|
+
}
|
|
2713
|
+
});
|
|
2714
|
+
}
|
|
2715
|
+
var ha = /* @__PURE__ */ c("ZodPrefault", (e, t) => {
|
|
2716
|
+
Vn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => ci(e, r, n, o), e.unwrap = () => e._zod.def.innerType;
|
|
2717
|
+
});
|
|
2718
|
+
function pa(e, t) {
|
|
2719
|
+
return new ha({
|
|
2720
|
+
type: "prefault",
|
|
2721
|
+
innerType: e,
|
|
2722
|
+
get defaultValue() {
|
|
2723
|
+
return typeof t == "function" ? t() : at(t);
|
|
2724
|
+
}
|
|
2725
|
+
});
|
|
2726
|
+
}
|
|
2727
|
+
var Ct = /* @__PURE__ */ c("ZodNonOptional", (e, t) => {
|
|
2728
|
+
Jn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => ai(e, r, n, o), e.unwrap = () => e._zod.def.innerType;
|
|
2729
|
+
});
|
|
2730
|
+
function ma(e, t) {
|
|
2731
|
+
return new Ct({
|
|
2732
|
+
type: "nonoptional",
|
|
2733
|
+
innerType: e,
|
|
2734
|
+
...f(t)
|
|
2735
|
+
});
|
|
2736
|
+
}
|
|
2737
|
+
var ga = /* @__PURE__ */ c("ZodCatch", (e, t) => {
|
|
2738
|
+
qn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => ui(e, r, n, o), e.unwrap = () => e._zod.def.innerType, e.removeCatch = e.unwrap;
|
|
2739
|
+
});
|
|
2740
|
+
function va(e, t) {
|
|
2741
|
+
return new ga({
|
|
2742
|
+
type: "catch",
|
|
2743
|
+
innerType: e,
|
|
2744
|
+
catchValue: typeof t == "function" ? t : () => t
|
|
2745
|
+
});
|
|
2746
|
+
}
|
|
2747
|
+
var ba = /* @__PURE__ */ c("ZodPipe", (e, t) => {
|
|
2748
|
+
Wn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => li(e, r, n, o), e.in = t.in, e.out = t.out;
|
|
2749
|
+
});
|
|
2750
|
+
function Qe(e, t) {
|
|
2751
|
+
return new ba({
|
|
2752
|
+
type: "pipe",
|
|
2753
|
+
in: e,
|
|
2754
|
+
out: t
|
|
2755
|
+
});
|
|
2756
|
+
}
|
|
2757
|
+
var _a = /* @__PURE__ */ c("ZodReadonly", (e, t) => {
|
|
2758
|
+
Bn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => di(e, r, n, o), e.unwrap = () => e._zod.def.innerType;
|
|
2759
|
+
});
|
|
2760
|
+
function wa(e) {
|
|
2761
|
+
return new _a({
|
|
2762
|
+
type: "readonly",
|
|
2763
|
+
innerType: e
|
|
2764
|
+
});
|
|
2765
|
+
}
|
|
2766
|
+
var Nt = /* @__PURE__ */ c("ZodCustom", (e, t) => {
|
|
2767
|
+
Hn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => Yo(e, r, n, o);
|
|
2768
|
+
});
|
|
2769
|
+
function ya(e, t) {
|
|
2770
|
+
return /* @__PURE__ */ Fo(Nt, e ?? (() => !0), t);
|
|
2771
|
+
}
|
|
2772
|
+
function za(e, t = {}) {
|
|
2773
|
+
return /* @__PURE__ */ Lo(Nt, e, t);
|
|
2774
|
+
}
|
|
2775
|
+
function ka(e) {
|
|
2776
|
+
return /* @__PURE__ */ Vo(e);
|
|
2777
|
+
}
|
|
2778
|
+
var le = /^#[0-9a-fA-F]{6}$/, de = "Color must be a 6-digit hex code (e.g. '#3B82F6'). Short hex, rgb(), and named colors are not supported.", Ee = A({
|
|
2779
|
+
primaryColor: v().max(20).regex(le, de).describe("Primary brand color (hex format, e.g., '#3B82F6')").optional(),
|
|
2780
|
+
backgroundColor: v().max(20).regex(le, de).describe("Background color for the widget container").optional(),
|
|
2781
|
+
textColor: v().max(20).regex(le, de).describe("Text color").optional(),
|
|
2782
|
+
borderRadius: ve().describe("Border radius in pixels").optional(),
|
|
2783
|
+
fontFamily: v().max(100).describe("Font family").optional(),
|
|
2784
|
+
colorScheme: O([
|
|
2785
|
+
"light",
|
|
2786
|
+
"dark",
|
|
2787
|
+
"auto"
|
|
2788
|
+
]).describe("Widget color scheme: 'light' (default), 'dark', or 'auto' (follows the visitor's prefers-color-scheme).").optional()
|
|
2789
|
+
}), Ga = O([
|
|
2790
|
+
"mobile",
|
|
2791
|
+
"tablet",
|
|
2792
|
+
"desktop"
|
|
2793
|
+
]).describe("Viewport mode: mobile (<480px), tablet (480-768px), desktop (>768px)"), Rt = O([
|
|
2794
|
+
"bottom-right",
|
|
2795
|
+
"bottom-left",
|
|
2796
|
+
"inline"
|
|
2797
|
+
]).describe("Widget position on the page"), $a = A({
|
|
2798
|
+
mobile: ve().min(0).max(1e3).describe("Max width for mobile viewport (default: 480)").optional(),
|
|
2799
|
+
tablet: ve().min(0).max(2e3).describe("Max width for tablet viewport (default: 768)").optional()
|
|
2800
|
+
}), Sa = A({
|
|
2801
|
+
enabled: C().describe("Enable responsive behavior (default: true)").optional(),
|
|
2802
|
+
breakpoints: $a.describe("Custom breakpoint values").optional()
|
|
2803
|
+
}), Xa = A({
|
|
2804
|
+
theme: Ee.describe("Custom theme configuration").optional(),
|
|
2805
|
+
position: Rt.describe("Widget position (default: 'bottom-right')").optional(),
|
|
2806
|
+
open: C().describe("Initial open state (default: false)").optional(),
|
|
2807
|
+
container: Pt([ya((e) => e instanceof HTMLElement), v().max(200)]).describe("Container element for inline mode").optional(),
|
|
2808
|
+
baseUrl: v().url().max(200).describe("Base URL for the widget embed (default: production URL)").optional(),
|
|
2809
|
+
debug: C().describe("Enable debug logging").optional(),
|
|
2810
|
+
responsive: Sa.describe("Responsive behavior configuration").optional(),
|
|
2811
|
+
showProfile: C().describe("Show profile panel in widget header (default: false)").optional(),
|
|
2812
|
+
language: v().max(10).describe("Language for UI labels (e.g., 'fr', 'en'). Defaults to browser language.").optional(),
|
|
2813
|
+
apiKey: v().max(100).describe("Publishable API key (pk_*) for application authentication"),
|
|
2814
|
+
email: v().email().max(255).describe("Pre-identified user email (host-attested identity)").optional(),
|
|
2815
|
+
userId: v().max(255).describe("Host-side unique user identifier").optional(),
|
|
2816
|
+
userHash: v().max(128).describe("HMAC-SHA256 of email (or userId), signed with identity secret").optional()
|
|
2817
|
+
}), Za = A({
|
|
2818
|
+
theme: Ee.describe("Full visual theme palette applied by the widget. Admin-configured, no client-side override.").optional(),
|
|
2819
|
+
position: Rt.describe("Default launcher position. `inline` only applies when integrator supplies `data-container`.").optional(),
|
|
2820
|
+
language: v().max(10).describe("Locale forced for widget UI labels (ISO 639-1). Falls back to browser language when null.").optional(),
|
|
2821
|
+
showProfile: C().describe("Whether the widget header exposes the profile panel to end-users.").optional(),
|
|
2822
|
+
open: C().describe("Default open state on load. Host can still call `window.Versiq.open()` programmatically.").optional(),
|
|
2823
|
+
brand: A({
|
|
2824
|
+
title: v().max(60).describe("Custom widget header title. Falls back to a vertical-specific default (e.g. 'Versiq Chat' for B2B) when unset.").optional(),
|
|
2825
|
+
avatarUrl: v().url().max(2048).describe("Public URL of the custom widget avatar (PNG or JPEG). MUST originate from the branding-upload endpoint — arbitrary external URLs are rejected at the API boundary.").optional()
|
|
2826
|
+
}).strict().describe("White-label branding overrides (issue #1083 Piste 5). Both fields are optional.").optional()
|
|
2827
|
+
}).strict(), Oa = A({
|
|
2828
|
+
applicationId: v().uuid().describe("Application UUID"),
|
|
2829
|
+
applicationSlug: v().max(100).describe("Application slug (kebab-case)"),
|
|
2830
|
+
applicationName: v().max(200).describe("Application display name"),
|
|
2831
|
+
vertical: v().max(50).describe("Vertical resolved from Application config"),
|
|
2832
|
+
theme: Ee.nullable().describe("Application theme"),
|
|
2833
|
+
allowedOrigins: Oe(v().max(200)).max(50).describe("Allowed origins for this application"),
|
|
2834
|
+
monitoring: C().describe("Monitoring enabled flag"),
|
|
2835
|
+
primaryObjective: A({
|
|
2836
|
+
id: v().uuid(),
|
|
2837
|
+
type: v(),
|
|
2838
|
+
label: v(),
|
|
2839
|
+
ctaLabel: v().nullable()
|
|
2840
|
+
}).nullable().describe("Primary conversion objective"),
|
|
2841
|
+
identityVerificationRequired: C().describe("Whether HMAC identity verification is required"),
|
|
2842
|
+
widget: Za.nullable().describe("Admin-configured widget runtime config (theme, position, language, showProfile, open). Null when the application has not yet persisted a widget_config JSONB.")
|
|
2843
|
+
}), Ea = O(["user", "assistant"]).describe("Message sender role"), Qa = A({
|
|
2844
|
+
role: Ea.describe("Message sender role"),
|
|
2845
|
+
content: v().max(1e4).describe("Message content (max 10000 characters)")
|
|
2846
|
+
}), Ia = O([
|
|
2847
|
+
"prospect",
|
|
2848
|
+
"partner",
|
|
2849
|
+
"unknown"
|
|
2850
|
+
]).describe("Type of user"), Ta = O([
|
|
2851
|
+
"ecommerce",
|
|
2852
|
+
"real-estate",
|
|
2853
|
+
"automotive",
|
|
2854
|
+
"travel",
|
|
2855
|
+
"recruitment",
|
|
2856
|
+
"other"
|
|
2857
|
+
]).describe("Business sector"), Pa = O([
|
|
2858
|
+
"startup",
|
|
2859
|
+
"pme",
|
|
2860
|
+
"eti",
|
|
2861
|
+
"grand-groupe"
|
|
2862
|
+
]).describe("Company size category"), Aa = O([
|
|
2863
|
+
"< 10k",
|
|
2864
|
+
"10k-50k",
|
|
2865
|
+
"50k-200k",
|
|
2866
|
+
"> 200k"
|
|
2867
|
+
]).describe("Monthly website traffic"), Ca = O([
|
|
2868
|
+
"lead-qualification",
|
|
2869
|
+
"personalization",
|
|
2870
|
+
"cart-abandonment",
|
|
2871
|
+
"conversion",
|
|
2872
|
+
"other"
|
|
2873
|
+
]).describe("Business objective"), Na = O([
|
|
2874
|
+
"shopify",
|
|
2875
|
+
"woocommerce",
|
|
2876
|
+
"prestashop",
|
|
2877
|
+
"custom",
|
|
2878
|
+
"none"
|
|
2879
|
+
]).describe("E-commerce platform"), Ra = O([
|
|
2880
|
+
"immediate",
|
|
2881
|
+
"1-month",
|
|
2882
|
+
"3-months",
|
|
2883
|
+
"exploring"
|
|
2884
|
+
]).describe("Implementation timeline"), xa = O([
|
|
2885
|
+
"< 500",
|
|
2886
|
+
"500-2000",
|
|
2887
|
+
"2000-5000",
|
|
2888
|
+
"> 5000"
|
|
2889
|
+
]).describe("Monthly budget range in EUR"), Ya = A({
|
|
2890
|
+
userType: Ia.optional().describe("User type: prospect, partner, or unknown"),
|
|
2891
|
+
sector: Ta.optional().describe("Business sector"),
|
|
2892
|
+
companySize: Pa.optional().describe("Company size range"),
|
|
2893
|
+
monthlyTraffic: Aa.optional().describe("Monthly website traffic"),
|
|
2894
|
+
objectives: Oe(Ca).max(5).describe("List of business objectives (max 5)").optional(),
|
|
2895
|
+
platform: Na.optional().describe("E-commerce platform"),
|
|
2896
|
+
timeline: Ra.optional().describe("Project timeline"),
|
|
2897
|
+
budgetRange: xa.optional().describe("Monthly budget range")
|
|
2898
|
+
}), D = class extends Error {
|
|
2899
|
+
constructor(e, t) {
|
|
2900
|
+
super(e), this.code = t, this.name = "ConfigFetchError";
|
|
2901
|
+
}
|
|
2902
|
+
}, Ye = 1e4;
|
|
2903
|
+
async function ja(e, t, r) {
|
|
2904
|
+
const n = t.endsWith("/") ? t : `${t}/`, o = new URL("api/application/config", n), a = new AbortController(), i = setTimeout(() => a.abort(), Ye), s = r ? AbortSignal.any([a.signal, r]) : a.signal;
|
|
2905
|
+
let u;
|
|
2906
|
+
try {
|
|
2907
|
+
u = await fetch(o.toString(), {
|
|
2908
|
+
signal: s,
|
|
2909
|
+
headers: { "x-versiq-key": e }
|
|
2910
|
+
});
|
|
2911
|
+
} catch (p) {
|
|
2912
|
+
throw clearTimeout(i), r?.aborted ? new D("Config fetch aborted by caller", "ABORTED") : p instanceof DOMException && p.name === "AbortError" ? new D(`Config fetch timed out after ${Ye}ms`, "TIMEOUT") : new D(`Network error fetching application config: ${p instanceof Error ? p.message : String(p)}`, "NETWORK_ERROR");
|
|
2913
|
+
}
|
|
2914
|
+
if (clearTimeout(i), !u.ok) {
|
|
2915
|
+
const p = await u.text().catch(() => "");
|
|
2916
|
+
throw new D(`HTTP ${u.status} fetching application config: ${p}`, `HTTP_${u.status}`);
|
|
2917
|
+
}
|
|
2918
|
+
const l = await u.json(), d = Oa.safeParse(l);
|
|
2919
|
+
if (!d.success) throw new D(`Invalid application config response: ${d.error.message}`, "PARSE_ERROR");
|
|
2920
|
+
return d.data;
|
|
2921
|
+
}
|
|
2922
|
+
var Ma = "0.1.0", P = "https://app.versiq.io", Ua = 0, Da = {
|
|
2923
|
+
mobile: 480,
|
|
2924
|
+
tablet: 768
|
|
2925
|
+
}, et = {
|
|
2926
|
+
mobile: {
|
|
2927
|
+
width: "100vw",
|
|
2928
|
+
height: "100vh"
|
|
2929
|
+
},
|
|
2930
|
+
tablet: {
|
|
2931
|
+
width: "90vw",
|
|
2932
|
+
height: "80vh"
|
|
2933
|
+
},
|
|
2934
|
+
desktop: {
|
|
2935
|
+
width: "380px",
|
|
2936
|
+
height: "600px"
|
|
2937
|
+
}
|
|
2938
|
+
}, Fa = 100, La = {
|
|
2939
|
+
position: "fixed",
|
|
2940
|
+
zIndex: "999999",
|
|
2941
|
+
border: "none",
|
|
2942
|
+
overflow: "hidden",
|
|
2943
|
+
transition: "all 0.3s ease-in-out"
|
|
2944
|
+
}, G = {
|
|
2945
|
+
"bottom-right": {
|
|
2946
|
+
bottom: "20px",
|
|
2947
|
+
right: "20px"
|
|
2948
|
+
},
|
|
2949
|
+
"bottom-left": {
|
|
2950
|
+
bottom: "20px",
|
|
2951
|
+
left: "20px"
|
|
2952
|
+
}
|
|
2953
|
+
}, Va = {
|
|
2954
|
+
width: "100%",
|
|
2955
|
+
height: "100%",
|
|
2956
|
+
border: "none",
|
|
2957
|
+
backgroundColor: "transparent"
|
|
2958
|
+
}, Ja = class {
|
|
2959
|
+
get applicationId() {
|
|
2960
|
+
return this._applicationId;
|
|
2961
|
+
}
|
|
2962
|
+
constructor(e) {
|
|
2963
|
+
this.version = Ma, this.iframe = null, this.container = null, this.skeletonButton = null, this.isOpen = !1, this.isReady = !1, this.isInitialized = !1, this.isDestroyed = !1, this.fetchAbortController = null, this._applicationId = "", this.vertical = "", this.pendingCommands = [], this.eventHandlers = /* @__PURE__ */ new Map(), this.cleanupListener = null, this.currentViewportMode = "desktop", this.mobileMediaQuery = null, this.tabletMediaQuery = null, this.debounceTimer = null, this.viewportChangeHandler = null, this.originalConfig = { ...e }, this.config = {
|
|
2964
|
+
position: "bottom-right",
|
|
2965
|
+
open: !1,
|
|
2966
|
+
baseUrl: P,
|
|
2967
|
+
debug: !1,
|
|
2968
|
+
...e
|
|
2969
|
+
}, this.instanceId = ++Ua, this.debugLog = Ut(this.config.debug ?? !1), this.renderSkeleton(), this.resolveConfig();
|
|
2970
|
+
}
|
|
2971
|
+
renderSkeleton() {
|
|
2972
|
+
this.config.position !== "inline" && (this.container = this.createContainer(), this.skeletonButton = document.createElement("button"), this.skeletonButton.type = "button", this.skeletonButton.setAttribute("aria-label", "Loading widget…"), this.skeletonButton.style.cssText = [
|
|
2973
|
+
"width: 100%",
|
|
2974
|
+
"height: 100%",
|
|
2975
|
+
"border: none",
|
|
2976
|
+
"border-radius: 50%",
|
|
2977
|
+
"background: #9ca3af",
|
|
2978
|
+
"cursor: default",
|
|
2979
|
+
"opacity: 0.6",
|
|
2980
|
+
"transition: opacity 0.3s ease-in-out, background 0.3s ease-in-out"
|
|
2981
|
+
].join(";"), this.container.appendChild(this.skeletonButton), document.body.appendChild(this.container));
|
|
2982
|
+
}
|
|
2983
|
+
resolveConfig() {
|
|
2984
|
+
const e = this.config.baseUrl ?? P;
|
|
2985
|
+
this.fetchAbortController = new AbortController();
|
|
2986
|
+
const t = (r) => ja(this.config.apiKey, e, this.fetchAbortController?.signal).then((n) => this.applyServerConfig(n)).catch((n) => {
|
|
2987
|
+
const o = n instanceof D ? n.code : "UNKNOWN_ERROR", a = n instanceof Error ? n.message : "Unknown config fetch error";
|
|
2988
|
+
if (!(o === "ABORTED" || this.isDestroyed)) {
|
|
2989
|
+
if (r === 0 && this.isTransientFetchError(o))
|
|
2990
|
+
return he(`Config fetch failed transiently (${o}), retrying after 1s backoff`), new Promise((i) => setTimeout(() => {
|
|
2991
|
+
this.isDestroyed || i(t(1));
|
|
2992
|
+
}, 1e3));
|
|
2993
|
+
fe(`Config fetch failed — widget stays in degraded mode: ${a}`), this.emit("error", {
|
|
2994
|
+
code: o,
|
|
2995
|
+
message: a
|
|
2996
|
+
});
|
|
2997
|
+
}
|
|
2998
|
+
});
|
|
2999
|
+
t(0);
|
|
3000
|
+
}
|
|
3001
|
+
isTransientFetchError(e) {
|
|
3002
|
+
return e === "NETWORK_ERROR" || e === "TIMEOUT" || e.startsWith("HTTP_5");
|
|
3003
|
+
}
|
|
3004
|
+
applyServerConfig(e) {
|
|
3005
|
+
if (this.isDestroyed) return;
|
|
3006
|
+
this._applicationId = e.applicationId, this.vertical = e.vertical;
|
|
3007
|
+
const t = e.widget ?? {};
|
|
3008
|
+
this.config = {
|
|
3009
|
+
...this.config,
|
|
3010
|
+
theme: {
|
|
3011
|
+
...e.theme ?? {},
|
|
3012
|
+
...t.theme ?? {},
|
|
3013
|
+
...this.originalConfig.theme ?? {}
|
|
3014
|
+
},
|
|
3015
|
+
position: this.originalConfig.position ?? t.position ?? this.config.position,
|
|
3016
|
+
language: this.originalConfig.language ?? t.language ?? this.config.language,
|
|
3017
|
+
showProfile: this.originalConfig.showProfile ?? t.showProfile ?? this.config.showProfile,
|
|
3018
|
+
open: this.originalConfig.open ?? t.open ?? this.config.open
|
|
3019
|
+
}, this.init(), this.flushPendingCommands(), he(`Widget v${this.version} ready (app: ${e.applicationSlug})`);
|
|
3020
|
+
}
|
|
3021
|
+
flushPendingCommands() {
|
|
3022
|
+
const e = this.pendingCommands;
|
|
3023
|
+
this.pendingCommands = [], e.forEach((t) => t());
|
|
3024
|
+
}
|
|
3025
|
+
init() {
|
|
3026
|
+
this.isDestroyed || (this.isInitialized = !0, this.container?.remove(), this.skeletonButton = null, this.container = this.createContainer(), this.iframe = this.createIframe(), this.container.appendChild(this.iframe), this.config.position === "inline" && this.config.container ? (typeof this.config.container == "string" ? document.querySelector(this.config.container) : this.config.container)?.appendChild(this.container) : document.body.appendChild(this.container), this.cleanupListener = Jt({
|
|
3027
|
+
onMessage: (e) => this.handleMessage(e),
|
|
3028
|
+
debug: this.config.debug,
|
|
3029
|
+
sourceWindow: this.iframe.contentWindow
|
|
3030
|
+
}), this.config.open && (this.isOpen = !0, this.updateVisibility()), this.setupViewportListener(), this.log("Widget initialized", this.config));
|
|
3031
|
+
}
|
|
3032
|
+
createContainer() {
|
|
3033
|
+
const e = document.createElement("div");
|
|
3034
|
+
if (e.id = `versiq-widget-container-${this.instanceId}`, this.config.position === "inline") Object.assign(e.style, {
|
|
3035
|
+
position: "relative",
|
|
3036
|
+
width: "100%",
|
|
3037
|
+
height: "100%",
|
|
3038
|
+
border: "none",
|
|
3039
|
+
borderRadius: "16px",
|
|
3040
|
+
overflow: "hidden",
|
|
3041
|
+
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)"
|
|
3042
|
+
});
|
|
3043
|
+
else {
|
|
3044
|
+
Object.assign(e.style, La);
|
|
3045
|
+
const t = G[this.config.position ?? "bottom-right"];
|
|
3046
|
+
Object.assign(e.style, t), e.style.width = "60px", e.style.height = "60px", e.style.borderRadius = "50%";
|
|
3047
|
+
}
|
|
3048
|
+
return e;
|
|
3049
|
+
}
|
|
3050
|
+
createIframe() {
|
|
3051
|
+
const e = document.createElement("iframe");
|
|
3052
|
+
return e.id = `versiq-widget-iframe-${this.instanceId}`, e.src = this.buildIframeUrl(), e.setAttribute("title", "Versiq Chat Widget"), e.setAttribute("allow", "clipboard-write; geolocation"), Object.assign(e.style, Va), e;
|
|
3053
|
+
}
|
|
3054
|
+
buildIframeUrl() {
|
|
3055
|
+
const e = this.config.baseUrl ?? P, t = new URL("/app/widget/embed", e);
|
|
3056
|
+
return this.vertical && t.searchParams.set("vertical", this.vertical), this.config.theme && t.searchParams.set("theme", qt(this.config.theme)), this.config.position === "inline" && t.searchParams.set("mode", "inline"), this.config.open && t.searchParams.set("open", "true"), this.config.showProfile && t.searchParams.set("showProfile", "true"), this.config.language && t.searchParams.set("language", this.config.language), this.config.apiKey && t.searchParams.set("apiKey", this.config.apiKey), t.toString();
|
|
3057
|
+
}
|
|
3058
|
+
setupViewportListener() {
|
|
3059
|
+
if (this.config.position === "inline" || this.config.responsive?.enabled === !1) return;
|
|
3060
|
+
const e = {
|
|
3061
|
+
...Da,
|
|
3062
|
+
...this.config.responsive?.breakpoints
|
|
3063
|
+
};
|
|
3064
|
+
this.mobileMediaQuery = window.matchMedia(`(max-width: ${e.mobile}px)`), this.tabletMediaQuery = window.matchMedia(`(max-width: ${e.tablet}px)`), this.viewportChangeHandler = () => this.handleViewportChange(), this.mobileMediaQuery.addEventListener("change", this.viewportChangeHandler), this.tabletMediaQuery.addEventListener("change", this.viewportChangeHandler), this.currentViewportMode = this.getViewportMode(), this.log("Initial viewport mode:", this.currentViewportMode);
|
|
3065
|
+
}
|
|
3066
|
+
handleViewportChange() {
|
|
3067
|
+
this.debounceTimer && clearTimeout(this.debounceTimer), this.debounceTimer = setTimeout(() => {
|
|
3068
|
+
const e = this.getViewportMode();
|
|
3069
|
+
e !== this.currentViewportMode && (this.currentViewportMode = e, this.log("Viewport changed:", e), this.isOpen && this.updateContainerForViewport(e), this.iframe && this.isReady && x(this.iframe, {
|
|
3070
|
+
type: "versiq:viewport",
|
|
3071
|
+
mode: e
|
|
3072
|
+
}, this.config.baseUrl ?? P));
|
|
3073
|
+
}, Fa);
|
|
3074
|
+
}
|
|
3075
|
+
getViewportMode() {
|
|
3076
|
+
return this.mobileMediaQuery?.matches ? "mobile" : this.tabletMediaQuery?.matches ? "tablet" : "desktop";
|
|
3077
|
+
}
|
|
3078
|
+
updateContainerForViewport(e) {
|
|
3079
|
+
if (!this.container) return;
|
|
3080
|
+
const t = et[e];
|
|
3081
|
+
if (e === "mobile") Object.assign(this.container.style, {
|
|
3082
|
+
width: t.width,
|
|
3083
|
+
height: t.height,
|
|
3084
|
+
inset: "0",
|
|
3085
|
+
bottom: "auto",
|
|
3086
|
+
right: "auto",
|
|
3087
|
+
left: "auto",
|
|
3088
|
+
borderRadius: "0",
|
|
3089
|
+
maxWidth: "none",
|
|
3090
|
+
transform: "none"
|
|
3091
|
+
});
|
|
3092
|
+
else if (e === "tablet") {
|
|
3093
|
+
const r = G[this.config.position ?? "bottom-right"];
|
|
3094
|
+
Object.assign(this.container.style, {
|
|
3095
|
+
width: t.width,
|
|
3096
|
+
height: t.height,
|
|
3097
|
+
inset: "auto",
|
|
3098
|
+
maxWidth: "500px",
|
|
3099
|
+
borderRadius: "16px",
|
|
3100
|
+
left: "50%",
|
|
3101
|
+
right: "auto",
|
|
3102
|
+
transform: "translateX(-50%)",
|
|
3103
|
+
bottom: r.bottom ?? "20px"
|
|
3104
|
+
});
|
|
3105
|
+
} else {
|
|
3106
|
+
const r = G[this.config.position ?? "bottom-right"];
|
|
3107
|
+
Object.assign(this.container.style, {
|
|
3108
|
+
width: t.width,
|
|
3109
|
+
height: t.height,
|
|
3110
|
+
inset: "auto",
|
|
3111
|
+
maxWidth: "none",
|
|
3112
|
+
borderRadius: "16px",
|
|
3113
|
+
transform: "none",
|
|
3114
|
+
...r
|
|
3115
|
+
});
|
|
3116
|
+
}
|
|
3117
|
+
}
|
|
3118
|
+
handleMessage(e) {
|
|
3119
|
+
switch (this.log("Received event:", e), e.type) {
|
|
3120
|
+
case "versiq:ready":
|
|
3121
|
+
this.isReady = !0, this.sendConfig(), this.emit("ready", void 0);
|
|
3122
|
+
break;
|
|
3123
|
+
case "versiq:profile-update":
|
|
3124
|
+
this.emit("profile-update", e.profile);
|
|
3125
|
+
break;
|
|
3126
|
+
case "versiq:message":
|
|
3127
|
+
this.emit("message", e.message);
|
|
3128
|
+
break;
|
|
3129
|
+
case "versiq:qualified":
|
|
3130
|
+
this.emit("qualified", {
|
|
3131
|
+
profile: e.profile,
|
|
3132
|
+
score: e.score
|
|
3133
|
+
});
|
|
3134
|
+
break;
|
|
3135
|
+
case "versiq:error":
|
|
3136
|
+
this.emit("error", {
|
|
3137
|
+
code: e.code,
|
|
3138
|
+
message: e.message
|
|
3139
|
+
});
|
|
3140
|
+
break;
|
|
3141
|
+
case "versiq:open":
|
|
3142
|
+
this.isOpen = !0, this.updateVisibility(), this.emit("open", void 0);
|
|
3143
|
+
break;
|
|
3144
|
+
case "versiq:close":
|
|
3145
|
+
this.isOpen = !1, this.updateVisibility(), this.emit("close", void 0);
|
|
3146
|
+
break;
|
|
3147
|
+
case "versiq:quota-warning":
|
|
3148
|
+
this.emit("quota-warning", {
|
|
3149
|
+
remaining: e.remaining,
|
|
3150
|
+
limit: e.limit
|
|
3151
|
+
});
|
|
3152
|
+
break;
|
|
3153
|
+
case "versiq:quota-exceeded":
|
|
3154
|
+
this.emit("quota-exceeded", void 0);
|
|
3155
|
+
break;
|
|
3156
|
+
case "versiq:identity-verified":
|
|
3157
|
+
this.emit("identity-verified", {
|
|
3158
|
+
email: e.email,
|
|
3159
|
+
userId: e.userId
|
|
3160
|
+
});
|
|
3161
|
+
break;
|
|
3162
|
+
}
|
|
3163
|
+
}
|
|
3164
|
+
sendConfig() {
|
|
3165
|
+
if (!this.iframe || !this.isReady) return;
|
|
3166
|
+
const { container: e, ...t } = this.config, r = {
|
|
3167
|
+
type: "versiq:init",
|
|
3168
|
+
config: t
|
|
3169
|
+
};
|
|
3170
|
+
x(this.iframe, r, this.config.baseUrl ?? P);
|
|
3171
|
+
}
|
|
3172
|
+
updateVisibility() {
|
|
3173
|
+
if (this.container && this.config.position !== "inline")
|
|
3174
|
+
if (this.isOpen) {
|
|
3175
|
+
if (this.config.responsive?.enabled !== !1) this.updateContainerForViewport(this.currentViewportMode);
|
|
3176
|
+
else {
|
|
3177
|
+
const e = et.desktop;
|
|
3178
|
+
this.container.style.width = e.width, this.container.style.height = e.height, this.container.style.borderRadius = "16px";
|
|
3179
|
+
}
|
|
3180
|
+
this.container.style.boxShadow = "0 10px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05)";
|
|
3181
|
+
} else {
|
|
3182
|
+
const e = G[this.config.position ?? "bottom-right"];
|
|
3183
|
+
Object.assign(this.container.style, {
|
|
3184
|
+
width: "60px",
|
|
3185
|
+
height: "60px",
|
|
3186
|
+
borderRadius: "50%",
|
|
3187
|
+
boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)",
|
|
3188
|
+
inset: "auto",
|
|
3189
|
+
maxWidth: "none",
|
|
3190
|
+
transform: "none",
|
|
3191
|
+
...e
|
|
3192
|
+
});
|
|
3193
|
+
}
|
|
3194
|
+
}
|
|
3195
|
+
emit(e, t) {
|
|
3196
|
+
const r = this.eventHandlers.get(e);
|
|
3197
|
+
r && r.forEach((n) => {
|
|
3198
|
+
try {
|
|
3199
|
+
n(t);
|
|
3200
|
+
} catch (o) {
|
|
3201
|
+
fe(`Error in event handler for "${e}":`, o);
|
|
3202
|
+
}
|
|
3203
|
+
});
|
|
3204
|
+
}
|
|
3205
|
+
open() {
|
|
3206
|
+
if (!this.isInitialized) {
|
|
3207
|
+
this.pendingCommands.push(() => this.open());
|
|
3208
|
+
return;
|
|
3209
|
+
}
|
|
3210
|
+
this.iframe && (this.isOpen = !0, this.updateVisibility(), this.isReady && x(this.iframe, { type: "versiq:open" }, this.config.baseUrl ?? P));
|
|
3211
|
+
}
|
|
3212
|
+
close() {
|
|
3213
|
+
if (!this.isInitialized) {
|
|
3214
|
+
this.pendingCommands.push(() => this.close());
|
|
3215
|
+
return;
|
|
3216
|
+
}
|
|
3217
|
+
this.iframe && (this.isOpen = !1, this.updateVisibility(), this.isReady && x(this.iframe, { type: "versiq:close" }, this.config.baseUrl ?? P));
|
|
3218
|
+
}
|
|
3219
|
+
reset() {
|
|
3220
|
+
if (!this.isInitialized) {
|
|
3221
|
+
this.pendingCommands.push(() => this.reset());
|
|
3222
|
+
return;
|
|
3223
|
+
}
|
|
3224
|
+
!this.iframe || !this.isReady || x(this.iframe, { type: "versiq:reset" }, this.config.baseUrl ?? P);
|
|
3225
|
+
}
|
|
3226
|
+
identify(e) {
|
|
3227
|
+
if (this.config = {
|
|
3228
|
+
...this.config,
|
|
3229
|
+
email: e.email,
|
|
3230
|
+
userId: e.userId,
|
|
3231
|
+
userHash: e.userHash
|
|
3232
|
+
}, !this.isInitialized) {
|
|
3233
|
+
this.pendingCommands.push(() => this.identify(e));
|
|
3234
|
+
return;
|
|
3235
|
+
}
|
|
3236
|
+
this.iframe && this.isReady && x(this.iframe, {
|
|
3237
|
+
type: "versiq:identify",
|
|
3238
|
+
email: e.email,
|
|
3239
|
+
userId: e.userId,
|
|
3240
|
+
userHash: e.userHash
|
|
3241
|
+
}, this.config.baseUrl ?? P);
|
|
3242
|
+
}
|
|
3243
|
+
setTheme(e) {
|
|
3244
|
+
if (this.config.theme = {
|
|
3245
|
+
...this.config.theme,
|
|
3246
|
+
...e
|
|
3247
|
+
}, !this.isInitialized) {
|
|
3248
|
+
this.pendingCommands.push(() => this.setTheme(e));
|
|
3249
|
+
return;
|
|
3250
|
+
}
|
|
3251
|
+
this.iframe && this.isReady && x(this.iframe, {
|
|
3252
|
+
type: "versiq:setTheme",
|
|
3253
|
+
theme: this.config.theme
|
|
3254
|
+
}, this.config.baseUrl ?? P);
|
|
3255
|
+
}
|
|
3256
|
+
setColorScheme(e) {
|
|
3257
|
+
this.setTheme({ colorScheme: e });
|
|
3258
|
+
}
|
|
3259
|
+
on(e, t) {
|
|
3260
|
+
this.eventHandlers.has(e) || this.eventHandlers.set(e, /* @__PURE__ */ new Set()), this.eventHandlers.get(e).add(t);
|
|
3261
|
+
}
|
|
3262
|
+
off(e, t) {
|
|
3263
|
+
const r = this.eventHandlers.get(e);
|
|
3264
|
+
r && r.delete(t);
|
|
3265
|
+
}
|
|
3266
|
+
destroy() {
|
|
3267
|
+
this.isDestroyed || (this.isDestroyed = !0, this.fetchAbortController?.abort(), this.fetchAbortController = null, this.cleanupListener?.(), this.viewportChangeHandler && (this.mobileMediaQuery?.removeEventListener("change", this.viewportChangeHandler), this.tabletMediaQuery?.removeEventListener("change", this.viewportChangeHandler), this.viewportChangeHandler = null), this.debounceTimer && (clearTimeout(this.debounceTimer), this.debounceTimer = null), this.container?.remove(), this.iframe = null, this.container = null, this.skeletonButton = null, this.mobileMediaQuery = null, this.tabletMediaQuery = null, this.eventHandlers.clear(), this.pendingCommands = []);
|
|
3268
|
+
}
|
|
3269
|
+
log(e, ...t) {
|
|
3270
|
+
const r = t.map((n) => {
|
|
3271
|
+
if (n == null || typeof n != "object") return n;
|
|
3272
|
+
if (n instanceof HTMLElement) return `[HTMLElement: ${n.tagName}]`;
|
|
3273
|
+
try {
|
|
3274
|
+
const o = /* @__PURE__ */ new WeakSet();
|
|
3275
|
+
return JSON.parse(JSON.stringify(n, (a, i) => {
|
|
3276
|
+
if (i instanceof HTMLElement) return `[HTMLElement: ${i.tagName}]`;
|
|
3277
|
+
if (typeof i == "object" && i !== null) {
|
|
3278
|
+
if (o.has(i)) return "[Circular]";
|
|
3279
|
+
o.add(i);
|
|
3280
|
+
}
|
|
3281
|
+
return i;
|
|
3282
|
+
}));
|
|
3283
|
+
} catch {
|
|
3284
|
+
return "[Unserializable]";
|
|
3285
|
+
}
|
|
3286
|
+
});
|
|
3287
|
+
this.debugLog(e, ...r);
|
|
3288
|
+
}
|
|
3289
|
+
};
|
|
3290
|
+
function qa(e) {
|
|
3291
|
+
return new Ja(e);
|
|
3292
|
+
}
|
|
3293
|
+
var _e = /* @__PURE__ */ new WeakSet();
|
|
3294
|
+
function Wa(e) {
|
|
3295
|
+
const t = e.getAttribute("data-api-key") ?? void 0;
|
|
3296
|
+
if (!t)
|
|
3297
|
+
return fe("Missing required data-api-key attribute on script tag"), null;
|
|
3298
|
+
const r = e.dataset.container, n = e.dataset.baseUrl, o = e.dataset.debug === "true", a = e.dataset.email, i = e.getAttribute("data-user-id") ?? void 0, s = e.getAttribute("data-user-hash") ?? void 0;
|
|
3299
|
+
return {
|
|
3300
|
+
apiKey: t,
|
|
3301
|
+
container: r,
|
|
3302
|
+
baseUrl: n,
|
|
3303
|
+
debug: o,
|
|
3304
|
+
...a && { email: a },
|
|
3305
|
+
...i && { userId: i },
|
|
3306
|
+
...s && { userHash: s }
|
|
3307
|
+
};
|
|
3308
|
+
}
|
|
3309
|
+
function Ba() {
|
|
3310
|
+
if (document.currentScript instanceof HTMLScriptElement) return document.currentScript;
|
|
3311
|
+
const e = document.querySelectorAll("script[src]");
|
|
3312
|
+
for (const t of e) {
|
|
3313
|
+
const r = t.src.toLowerCase();
|
|
3314
|
+
if (r.includes("versiq") || r.includes("widget")) return t;
|
|
3315
|
+
}
|
|
3316
|
+
return null;
|
|
3317
|
+
}
|
|
3318
|
+
function tt() {
|
|
3319
|
+
const e = document.querySelectorAll("script[data-api-key]");
|
|
3320
|
+
if (e.length === 0) {
|
|
3321
|
+
const t = Ba();
|
|
3322
|
+
t && t.hasAttribute("data-api-key") && !_e.has(t) && rt(t);
|
|
3323
|
+
return;
|
|
3324
|
+
}
|
|
3325
|
+
for (const t of e) rt(t);
|
|
3326
|
+
}
|
|
3327
|
+
function rt(e) {
|
|
3328
|
+
if (_e.has(e)) return;
|
|
3329
|
+
_e.add(e);
|
|
3330
|
+
const t = Wa(e);
|
|
3331
|
+
if (!t) return;
|
|
3332
|
+
const r = qa(t);
|
|
3333
|
+
window.Versiq || (window.Versiq = r), window.VersiqApps || (window.VersiqApps = /* @__PURE__ */ new Map()), r.on("ready", () => {
|
|
3334
|
+
r.applicationId && window.VersiqApps && window.VersiqApps.set(r.applicationId, r);
|
|
3335
|
+
}), he(`Widget v${r.version} initializing...`);
|
|
3336
|
+
}
|
|
3337
|
+
typeof document < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", tt) : tt());
|
|
3338
|
+
export {
|
|
3339
|
+
D as ConfigFetchError,
|
|
3340
|
+
Ja as VersiqWidget,
|
|
3341
|
+
tt as __autoInit,
|
|
3342
|
+
Ba as __getCurrentScript,
|
|
3343
|
+
Wa as __parseScriptAttributes,
|
|
3344
|
+
Oa as applicationConfigResponseSchema,
|
|
3345
|
+
Ya as b2bProfileSchema,
|
|
3346
|
+
qa as createWidget,
|
|
3347
|
+
ja as fetchApplicationConfig,
|
|
3348
|
+
Ee as themeConfigSchema,
|
|
3349
|
+
Xa as widgetConfigSchema,
|
|
3350
|
+
Qa as widgetMessageSchema,
|
|
3351
|
+
Rt as widgetPositionSchema
|
|
3352
|
+
};
|