clivly 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/README.md +54 -3
  2. package/adapter-Cd6D_3JD.d.mts +46 -0
  3. package/adapter-Cy4q2CLs.d.cts +46 -0
  4. package/auth-adapter-CBOKDhlc.cjs +11 -0
  5. package/auth-adapter-CRBW4elj.d.mts +30 -0
  6. package/auth-adapter-CdLODn2p.d.cts +30 -0
  7. package/auth-adapter-wqnnEjo3.mjs +6 -0
  8. package/auth-better-auth.cjs +28 -0
  9. package/auth-better-auth.d.cts +33 -0
  10. package/auth-better-auth.d.mts +33 -0
  11. package/auth-better-auth.mjs +26 -0
  12. package/auth-clerk.cjs +34 -0
  13. package/auth-clerk.d.cts +32 -0
  14. package/auth-clerk.d.mts +32 -0
  15. package/auth-clerk.mjs +32 -0
  16. package/auth-workos.cjs +47 -0
  17. package/auth-workos.d.cts +30 -0
  18. package/auth-workos.d.mts +30 -0
  19. package/auth-workos.mjs +45 -0
  20. package/core-adapter.cjs +0 -0
  21. package/core-adapter.d.cts +2 -0
  22. package/core-adapter.d.mts +2 -0
  23. package/core-adapter.mjs +1 -0
  24. package/core-auth-adapter.cjs +3 -0
  25. package/core-auth-adapter.d.cts +2 -0
  26. package/core-auth-adapter.d.mts +2 -0
  27. package/core-auth-adapter.mjs +2 -0
  28. package/core-drizzle.cjs +32 -0
  29. package/core-drizzle.d.cts +21 -0
  30. package/core-drizzle.d.mts +21 -0
  31. package/core-drizzle.mjs +31 -0
  32. package/core-entity-config.cjs +13 -0
  33. package/core-entity-config.d.cts +2 -0
  34. package/core-entity-config.d.mts +2 -0
  35. package/core-entity-config.mjs +2 -0
  36. package/core-entity-heuristics.cjs +442 -0
  37. package/core-entity-heuristics.d.cts +68 -0
  38. package/core-entity-heuristics.d.mts +68 -0
  39. package/core-entity-heuristics.mjs +431 -0
  40. package/core-mapping-form.cjs +5 -0
  41. package/core-mapping-form.d.cts +2 -0
  42. package/core-mapping-form.d.mts +2 -0
  43. package/core-mapping-form.mjs +2 -0
  44. package/core-mapping-score.cjs +12 -0
  45. package/core-mapping-score.d.cts +2 -0
  46. package/core-mapping-score.d.mts +2 -0
  47. package/core-mapping-score.mjs +2 -0
  48. package/core-mappings-config.cjs +3 -0
  49. package/core-mappings-config.d.cts +2 -0
  50. package/core-mappings-config.d.mts +2 -0
  51. package/core-mappings-config.mjs +2 -0
  52. package/core-sync-engine.cjs +6 -0
  53. package/core-sync-engine.d.cts +2 -0
  54. package/core-sync-engine.d.mts +2 -0
  55. package/core-sync-engine.mjs +2 -0
  56. package/core-types.cjs +0 -0
  57. package/core-types.d.cts +2 -0
  58. package/core-types.d.mts +2 -0
  59. package/core-types.mjs +1 -0
  60. package/core-view-compiler.cjs +5 -0
  61. package/core-view-compiler.d.cts +2 -0
  62. package/core-view-compiler.d.mts +2 -0
  63. package/core-view-compiler.mjs +2 -0
  64. package/core.cjs +27 -0
  65. package/core.d.cts +9 -0
  66. package/core.d.mts +9 -0
  67. package/core.mjs +7 -0
  68. package/drizzle-meta-BGn0BqGb.cjs +9 -0
  69. package/drizzle-meta-CnC336L-.mjs +4 -0
  70. package/drizzle.cjs +107 -0
  71. package/drizzle.d.cts +28 -0
  72. package/drizzle.d.mts +28 -0
  73. package/drizzle.mjs +105 -0
  74. package/entity-config-Cvjo1cpv.cjs +4598 -0
  75. package/entity-config-D1DFyeUp.d.mts +2403 -0
  76. package/entity-config-DoR0khce.mjs +4533 -0
  77. package/entity-config-GczjD3y8.d.cts +2403 -0
  78. package/index.cjs +961 -0
  79. package/index.d.cts +57 -0
  80. package/index.d.mts +57 -0
  81. package/index.mjs +960 -0
  82. package/mapping-form-BHtPexzI.mjs +47 -0
  83. package/mapping-form-CUlFVfG8.d.cts +35 -0
  84. package/mapping-form-DdmDebC3.cjs +64 -0
  85. package/mapping-form-kjSiJaCX.d.mts +35 -0
  86. package/mapping-score-A2lRnlpk.d.mts +49 -0
  87. package/mapping-score-BJNe0lFn.mjs +87 -0
  88. package/mapping-score-BcjC0ZQs.d.cts +49 -0
  89. package/mapping-score-D9gfhtRu.cjs +146 -0
  90. package/mappings-config-CYPrzB3K.mjs +99 -0
  91. package/mappings-config-DTu_2cyx.cjs +104 -0
  92. package/mappings-config-DjRLCb2Q.d.cts +42 -0
  93. package/mappings-config-GxiYsSBQ.d.mts +42 -0
  94. package/namespace-probe-BtS0nXcr.d.cts +299 -0
  95. package/namespace-probe-CYMie-BI.d.mts +299 -0
  96. package/package.json +244 -21
  97. package/sdk-BZUn6wzs.mjs +764 -0
  98. package/sdk-CP_mYZa5.cjs +793 -0
  99. package/sdk.cjs +7 -0
  100. package/sdk.d.cts +33 -0
  101. package/sdk.d.mts +33 -0
  102. package/sdk.mjs +2 -0
  103. package/sync-engine-DUc0qWgo.cjs +230 -0
  104. package/sync-engine-DWnQPjV3.d.mts +183 -0
  105. package/sync-engine-DedXngop.mjs +207 -0
  106. package/sync-engine-uhfzKM-e.d.cts +183 -0
  107. package/types-BpsKVccL.d.cts +159 -0
  108. package/types-_qbJXMt_.d.mts +159 -0
  109. package/view-compiler-B4UYTvRM.d.cts +71 -0
  110. package/view-compiler-BHzbI9b7.cjs +202 -0
  111. package/view-compiler-CosFGar8.mjs +185 -0
  112. package/view-compiler-i_xFf-L0.d.mts +71 -0
  113. package/vite.cjs +38 -0
  114. package/vite.d.cts +23 -0
  115. package/vite.d.mts +23 -0
  116. package/vite.mjs +37 -0
  117. package/dist/index.mjs +0 -542
@@ -0,0 +1,4598 @@
1
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/core.js
2
+ var _a$1;
3
+ function $constructor(name, initializer, params) {
4
+ function init(inst, def) {
5
+ if (!inst._zod) Object.defineProperty(inst, "_zod", {
6
+ value: {
7
+ def,
8
+ constr: _,
9
+ traits: /* @__PURE__ */ new Set()
10
+ },
11
+ enumerable: false
12
+ });
13
+ if (inst._zod.traits.has(name)) return;
14
+ inst._zod.traits.add(name);
15
+ initializer(inst, def);
16
+ const proto = _.prototype;
17
+ const keys = Object.keys(proto);
18
+ for (let i = 0; i < keys.length; i++) {
19
+ const k = keys[i];
20
+ if (!(k in inst)) inst[k] = proto[k].bind(inst);
21
+ }
22
+ }
23
+ const Parent = params?.Parent ?? Object;
24
+ class Definition extends Parent {}
25
+ Object.defineProperty(Definition, "name", { value: name });
26
+ function _(def) {
27
+ var _a;
28
+ const inst = params?.Parent ? new Definition() : this;
29
+ init(inst, def);
30
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
31
+ for (const fn of inst._zod.deferred) fn();
32
+ return inst;
33
+ }
34
+ Object.defineProperty(_, "init", { value: init });
35
+ Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
36
+ if (params?.Parent && inst instanceof params.Parent) return true;
37
+ return inst?._zod?.traits?.has(name);
38
+ } });
39
+ Object.defineProperty(_, "name", { value: name });
40
+ return _;
41
+ }
42
+ var $ZodAsyncError = class extends Error {
43
+ constructor() {
44
+ super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
45
+ }
46
+ };
47
+ var $ZodEncodeError = class extends Error {
48
+ constructor(name) {
49
+ super(`Encountered unidirectional transform during encode: ${name}`);
50
+ this.name = "ZodEncodeError";
51
+ }
52
+ };
53
+ (_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
54
+ const globalConfig = globalThis.__zod_globalConfig;
55
+ function config(newConfig) {
56
+ if (newConfig) Object.assign(globalConfig, newConfig);
57
+ return globalConfig;
58
+ }
59
+ //#endregion
60
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/util.js
61
+ function getEnumValues(entries) {
62
+ const numericValues = Object.values(entries).filter((v) => typeof v === "number");
63
+ return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
64
+ }
65
+ function jsonStringifyReplacer(_, value) {
66
+ if (typeof value === "bigint") return value.toString();
67
+ return value;
68
+ }
69
+ function cached(getter) {
70
+ return { get value() {
71
+ {
72
+ const value = getter();
73
+ Object.defineProperty(this, "value", { value });
74
+ return value;
75
+ }
76
+ throw new Error("cached value already set");
77
+ } };
78
+ }
79
+ function nullish(input) {
80
+ return input === null || input === void 0;
81
+ }
82
+ function cleanRegex(source) {
83
+ const start = source.startsWith("^") ? 1 : 0;
84
+ const end = source.endsWith("$") ? source.length - 1 : source.length;
85
+ return source.slice(start, end);
86
+ }
87
+ function floatSafeRemainder(val, step) {
88
+ const ratio = val / step;
89
+ const roundedRatio = Math.round(ratio);
90
+ const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
91
+ if (Math.abs(ratio - roundedRatio) < tolerance) return 0;
92
+ return ratio - roundedRatio;
93
+ }
94
+ const EVALUATING = /* @__PURE__ */ Symbol("evaluating");
95
+ function defineLazy(object, key, getter) {
96
+ let value = void 0;
97
+ Object.defineProperty(object, key, {
98
+ get() {
99
+ if (value === EVALUATING) return;
100
+ if (value === void 0) {
101
+ value = EVALUATING;
102
+ value = getter();
103
+ }
104
+ return value;
105
+ },
106
+ set(v) {
107
+ Object.defineProperty(object, key, { value: v });
108
+ },
109
+ configurable: true
110
+ });
111
+ }
112
+ function assignProp(target, prop, value) {
113
+ Object.defineProperty(target, prop, {
114
+ value,
115
+ writable: true,
116
+ enumerable: true,
117
+ configurable: true
118
+ });
119
+ }
120
+ function mergeDefs(...defs) {
121
+ const mergedDescriptors = {};
122
+ for (const def of defs) Object.assign(mergedDescriptors, Object.getOwnPropertyDescriptors(def));
123
+ return Object.defineProperties({}, mergedDescriptors);
124
+ }
125
+ function esc(str) {
126
+ return JSON.stringify(str);
127
+ }
128
+ function slugify(input) {
129
+ return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
130
+ }
131
+ const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
132
+ function isObject(data) {
133
+ return typeof data === "object" && data !== null && !Array.isArray(data);
134
+ }
135
+ const allowsEval = /* @__PURE__ */ cached(() => {
136
+ if (globalConfig.jitless) return false;
137
+ if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
138
+ try {
139
+ new Function("");
140
+ return true;
141
+ } catch (_) {
142
+ return false;
143
+ }
144
+ });
145
+ function isPlainObject(o) {
146
+ if (isObject(o) === false) return false;
147
+ const ctor = o.constructor;
148
+ if (ctor === void 0) return true;
149
+ if (typeof ctor !== "function") return true;
150
+ const prot = ctor.prototype;
151
+ if (isObject(prot) === false) return false;
152
+ if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
153
+ return true;
154
+ }
155
+ function shallowClone(o) {
156
+ if (isPlainObject(o)) return { ...o };
157
+ if (Array.isArray(o)) return [...o];
158
+ if (o instanceof Map) return new Map(o);
159
+ if (o instanceof Set) return new Set(o);
160
+ return o;
161
+ }
162
+ const propertyKeyTypes = /* @__PURE__ */ new Set([
163
+ "string",
164
+ "number",
165
+ "symbol"
166
+ ]);
167
+ function escapeRegex(str) {
168
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
169
+ }
170
+ function clone(inst, def, params) {
171
+ const cl = new inst._zod.constr(def ?? inst._zod.def);
172
+ if (!def || params?.parent) cl._zod.parent = inst;
173
+ return cl;
174
+ }
175
+ function normalizeParams(_params) {
176
+ const params = _params;
177
+ if (!params) return {};
178
+ if (typeof params === "string") return { error: () => params };
179
+ if (params?.message !== void 0) {
180
+ if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
181
+ params.error = params.message;
182
+ }
183
+ delete params.message;
184
+ if (typeof params.error === "string") return {
185
+ ...params,
186
+ error: () => params.error
187
+ };
188
+ return params;
189
+ }
190
+ function optionalKeys(shape) {
191
+ return Object.keys(shape).filter((k) => {
192
+ return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
193
+ });
194
+ }
195
+ const NUMBER_FORMAT_RANGES = {
196
+ safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
197
+ int32: [-2147483648, 2147483647],
198
+ uint32: [0, 4294967295],
199
+ float32: [-34028234663852886e22, 34028234663852886e22],
200
+ float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
201
+ };
202
+ function pick(schema, mask) {
203
+ const currDef = schema._zod.def;
204
+ const checks = currDef.checks;
205
+ if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
206
+ return clone(schema, mergeDefs(schema._zod.def, {
207
+ get shape() {
208
+ const newShape = {};
209
+ for (const key in mask) {
210
+ if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
211
+ if (!mask[key]) continue;
212
+ newShape[key] = currDef.shape[key];
213
+ }
214
+ assignProp(this, "shape", newShape);
215
+ return newShape;
216
+ },
217
+ checks: []
218
+ }));
219
+ }
220
+ function omit(schema, mask) {
221
+ const currDef = schema._zod.def;
222
+ const checks = currDef.checks;
223
+ if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
224
+ return clone(schema, mergeDefs(schema._zod.def, {
225
+ get shape() {
226
+ const newShape = { ...schema._zod.def.shape };
227
+ for (const key in mask) {
228
+ if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
229
+ if (!mask[key]) continue;
230
+ delete newShape[key];
231
+ }
232
+ assignProp(this, "shape", newShape);
233
+ return newShape;
234
+ },
235
+ checks: []
236
+ }));
237
+ }
238
+ function extend(schema, shape) {
239
+ if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
240
+ const checks = schema._zod.def.checks;
241
+ if (checks && checks.length > 0) {
242
+ const existingShape = schema._zod.def.shape;
243
+ for (const key in shape) if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
244
+ }
245
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
246
+ const _shape = {
247
+ ...schema._zod.def.shape,
248
+ ...shape
249
+ };
250
+ assignProp(this, "shape", _shape);
251
+ return _shape;
252
+ } }));
253
+ }
254
+ function safeExtend(schema, shape) {
255
+ if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
256
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
257
+ const _shape = {
258
+ ...schema._zod.def.shape,
259
+ ...shape
260
+ };
261
+ assignProp(this, "shape", _shape);
262
+ return _shape;
263
+ } }));
264
+ }
265
+ function merge(a, b) {
266
+ if (a._zod.def.checks?.length) throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
267
+ return clone(a, mergeDefs(a._zod.def, {
268
+ get shape() {
269
+ const _shape = {
270
+ ...a._zod.def.shape,
271
+ ...b._zod.def.shape
272
+ };
273
+ assignProp(this, "shape", _shape);
274
+ return _shape;
275
+ },
276
+ get catchall() {
277
+ return b._zod.def.catchall;
278
+ },
279
+ checks: b._zod.def.checks ?? []
280
+ }));
281
+ }
282
+ function partial(Class, schema, mask) {
283
+ const checks = schema._zod.def.checks;
284
+ if (checks && checks.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
285
+ return clone(schema, mergeDefs(schema._zod.def, {
286
+ get shape() {
287
+ const oldShape = schema._zod.def.shape;
288
+ const shape = { ...oldShape };
289
+ if (mask) for (const key in mask) {
290
+ if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
291
+ if (!mask[key]) continue;
292
+ shape[key] = Class ? new Class({
293
+ type: "optional",
294
+ innerType: oldShape[key]
295
+ }) : oldShape[key];
296
+ }
297
+ else for (const key in oldShape) shape[key] = Class ? new Class({
298
+ type: "optional",
299
+ innerType: oldShape[key]
300
+ }) : oldShape[key];
301
+ assignProp(this, "shape", shape);
302
+ return shape;
303
+ },
304
+ checks: []
305
+ }));
306
+ }
307
+ function required(Class, schema, mask) {
308
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
309
+ const oldShape = schema._zod.def.shape;
310
+ const shape = { ...oldShape };
311
+ if (mask) for (const key in mask) {
312
+ if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
313
+ if (!mask[key]) continue;
314
+ shape[key] = new Class({
315
+ type: "nonoptional",
316
+ innerType: oldShape[key]
317
+ });
318
+ }
319
+ else for (const key in oldShape) shape[key] = new Class({
320
+ type: "nonoptional",
321
+ innerType: oldShape[key]
322
+ });
323
+ assignProp(this, "shape", shape);
324
+ return shape;
325
+ } }));
326
+ }
327
+ function aborted(x, startIndex = 0) {
328
+ if (x.aborted === true) return true;
329
+ for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
330
+ return false;
331
+ }
332
+ function explicitlyAborted(x, startIndex = 0) {
333
+ if (x.aborted === true) return true;
334
+ for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue === false) return true;
335
+ return false;
336
+ }
337
+ function prefixIssues(path, issues) {
338
+ return issues.map((iss) => {
339
+ var _a;
340
+ (_a = iss).path ?? (_a.path = []);
341
+ iss.path.unshift(path);
342
+ return iss;
343
+ });
344
+ }
345
+ function unwrapMessage(message) {
346
+ return typeof message === "string" ? message : message?.message;
347
+ }
348
+ function finalizeIssue(iss, ctx, config) {
349
+ const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
350
+ const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
351
+ rest.path ?? (rest.path = []);
352
+ rest.message = message;
353
+ if (ctx?.reportInput) rest.input = _input;
354
+ return rest;
355
+ }
356
+ function getLengthableOrigin(input) {
357
+ if (Array.isArray(input)) return "array";
358
+ if (typeof input === "string") return "string";
359
+ return "unknown";
360
+ }
361
+ function issue(...args) {
362
+ const [iss, input, inst] = args;
363
+ if (typeof iss === "string") return {
364
+ message: iss,
365
+ code: "custom",
366
+ input,
367
+ inst
368
+ };
369
+ return { ...iss };
370
+ }
371
+ //#endregion
372
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/errors.js
373
+ const initializer$1 = (inst, def) => {
374
+ inst.name = "$ZodError";
375
+ Object.defineProperty(inst, "_zod", {
376
+ value: inst._zod,
377
+ enumerable: false
378
+ });
379
+ Object.defineProperty(inst, "issues", {
380
+ value: def,
381
+ enumerable: false
382
+ });
383
+ inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
384
+ Object.defineProperty(inst, "toString", {
385
+ value: () => inst.message,
386
+ enumerable: false
387
+ });
388
+ };
389
+ const $ZodError = $constructor("$ZodError", initializer$1);
390
+ const $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
391
+ function flattenError(error, mapper = (issue) => issue.message) {
392
+ const fieldErrors = {};
393
+ const formErrors = [];
394
+ for (const sub of error.issues) if (sub.path.length > 0) {
395
+ fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
396
+ fieldErrors[sub.path[0]].push(mapper(sub));
397
+ } else formErrors.push(mapper(sub));
398
+ return {
399
+ formErrors,
400
+ fieldErrors
401
+ };
402
+ }
403
+ function formatError(error, mapper = (issue) => issue.message) {
404
+ const fieldErrors = { _errors: [] };
405
+ const processError = (error, path = []) => {
406
+ for (const issue of error.issues) if (issue.code === "invalid_union" && issue.errors.length) issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
407
+ else if (issue.code === "invalid_key") processError({ issues: issue.issues }, [...path, ...issue.path]);
408
+ else if (issue.code === "invalid_element") processError({ issues: issue.issues }, [...path, ...issue.path]);
409
+ else {
410
+ const fullpath = [...path, ...issue.path];
411
+ if (fullpath.length === 0) fieldErrors._errors.push(mapper(issue));
412
+ else {
413
+ let curr = fieldErrors;
414
+ let i = 0;
415
+ while (i < fullpath.length) {
416
+ const el = fullpath[i];
417
+ if (!(i === fullpath.length - 1)) curr[el] = curr[el] || { _errors: [] };
418
+ else {
419
+ curr[el] = curr[el] || { _errors: [] };
420
+ curr[el]._errors.push(mapper(issue));
421
+ }
422
+ curr = curr[el];
423
+ i++;
424
+ }
425
+ }
426
+ }
427
+ };
428
+ processError(error);
429
+ return fieldErrors;
430
+ }
431
+ //#endregion
432
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/parse.js
433
+ const _parse = (_Err) => (schema, value, _ctx, _params) => {
434
+ const ctx = _ctx ? {
435
+ ..._ctx,
436
+ async: false
437
+ } : { async: false };
438
+ const result = schema._zod.run({
439
+ value,
440
+ issues: []
441
+ }, ctx);
442
+ if (result instanceof Promise) throw new $ZodAsyncError();
443
+ if (result.issues.length) {
444
+ const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
445
+ captureStackTrace(e, _params?.callee);
446
+ throw e;
447
+ }
448
+ return result.value;
449
+ };
450
+ const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
451
+ const ctx = _ctx ? {
452
+ ..._ctx,
453
+ async: true
454
+ } : { async: true };
455
+ let result = schema._zod.run({
456
+ value,
457
+ issues: []
458
+ }, ctx);
459
+ if (result instanceof Promise) result = await result;
460
+ if (result.issues.length) {
461
+ const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
462
+ captureStackTrace(e, params?.callee);
463
+ throw e;
464
+ }
465
+ return result.value;
466
+ };
467
+ const _safeParse = (_Err) => (schema, value, _ctx) => {
468
+ const ctx = _ctx ? {
469
+ ..._ctx,
470
+ async: false
471
+ } : { async: false };
472
+ const result = schema._zod.run({
473
+ value,
474
+ issues: []
475
+ }, ctx);
476
+ if (result instanceof Promise) throw new $ZodAsyncError();
477
+ return result.issues.length ? {
478
+ success: false,
479
+ error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
480
+ } : {
481
+ success: true,
482
+ data: result.value
483
+ };
484
+ };
485
+ const safeParse$1 = /* @__PURE__ */ _safeParse($ZodRealError);
486
+ const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
487
+ const ctx = _ctx ? {
488
+ ..._ctx,
489
+ async: true
490
+ } : { async: true };
491
+ let result = schema._zod.run({
492
+ value,
493
+ issues: []
494
+ }, ctx);
495
+ if (result instanceof Promise) result = await result;
496
+ return result.issues.length ? {
497
+ success: false,
498
+ error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
499
+ } : {
500
+ success: true,
501
+ data: result.value
502
+ };
503
+ };
504
+ const safeParseAsync$1 = /* @__PURE__ */ _safeParseAsync($ZodRealError);
505
+ const _encode = (_Err) => (schema, value, _ctx) => {
506
+ const ctx = _ctx ? {
507
+ ..._ctx,
508
+ direction: "backward"
509
+ } : { direction: "backward" };
510
+ return _parse(_Err)(schema, value, ctx);
511
+ };
512
+ const _decode = (_Err) => (schema, value, _ctx) => {
513
+ return _parse(_Err)(schema, value, _ctx);
514
+ };
515
+ const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
516
+ const ctx = _ctx ? {
517
+ ..._ctx,
518
+ direction: "backward"
519
+ } : { direction: "backward" };
520
+ return _parseAsync(_Err)(schema, value, ctx);
521
+ };
522
+ const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
523
+ return _parseAsync(_Err)(schema, value, _ctx);
524
+ };
525
+ const _safeEncode = (_Err) => (schema, value, _ctx) => {
526
+ const ctx = _ctx ? {
527
+ ..._ctx,
528
+ direction: "backward"
529
+ } : { direction: "backward" };
530
+ return _safeParse(_Err)(schema, value, ctx);
531
+ };
532
+ const _safeDecode = (_Err) => (schema, value, _ctx) => {
533
+ return _safeParse(_Err)(schema, value, _ctx);
534
+ };
535
+ const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
536
+ const ctx = _ctx ? {
537
+ ..._ctx,
538
+ direction: "backward"
539
+ } : { direction: "backward" };
540
+ return _safeParseAsync(_Err)(schema, value, ctx);
541
+ };
542
+ const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
543
+ return _safeParseAsync(_Err)(schema, value, _ctx);
544
+ };
545
+ //#endregion
546
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/regexes.js
547
+ /**
548
+ * @deprecated CUID v1 is deprecated by its authors due to information leakage
549
+ * (timestamps embedded in the id). Use {@link cuid2} instead.
550
+ * See https://github.com/paralleldrive/cuid.
551
+ */
552
+ const cuid = /^[cC][0-9a-z]{6,}$/;
553
+ const cuid2 = /^[0-9a-z]+$/;
554
+ const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
555
+ const xid = /^[0-9a-vA-V]{20}$/;
556
+ const ksuid = /^[A-Za-z0-9]{27}$/;
557
+ const nanoid = /^[a-zA-Z0-9_-]{21}$/;
558
+ /** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
559
+ const duration$1 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
560
+ /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
561
+ const guid = /^([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})$/;
562
+ /** Returns a regex for validating an RFC 9562/4122 UUID.
563
+ *
564
+ * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
565
+ const uuid = (version) => {
566
+ if (!version) return /^([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)$/;
567
+ return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
568
+ };
569
+ /** Practical email validation */
570
+ const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
571
+ const _emoji$1 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
572
+ function emoji() {
573
+ return new RegExp(_emoji$1, "u");
574
+ }
575
+ const ipv4 = /^(?:(?: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])$/;
576
+ const ipv6 = /^(([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}|:))$/;
577
+ const cidrv4 = /^((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])$/;
578
+ const cidrv6 = /^(([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])$/;
579
+ const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
580
+ const base64url = /^[A-Za-z0-9_-]*$/;
581
+ const httpProtocol = /^https?$/;
582
+ const e164 = /^\+[1-9]\d{6,14}$/;
583
+ const dateSource = `(?:(?:\\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])))`;
584
+ const date$1 = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
585
+ function timeSource(args) {
586
+ const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
587
+ return typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
588
+ }
589
+ function time$1(args) {
590
+ return new RegExp(`^${timeSource(args)}$`);
591
+ }
592
+ function datetime$1(args) {
593
+ const time = timeSource({ precision: args.precision });
594
+ const opts = ["Z"];
595
+ if (args.local) opts.push("");
596
+ if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
597
+ const timeRegex = `${time}(?:${opts.join("|")})`;
598
+ return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
599
+ }
600
+ const string$1 = (params) => {
601
+ const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
602
+ return new RegExp(`^${regex}$`);
603
+ };
604
+ const integer = /^-?\d+$/;
605
+ const number$1 = /^-?\d+(?:\.\d+)?$/;
606
+ const boolean$1 = /^(?:true|false)$/i;
607
+ const lowercase = /^[^A-Z]*$/;
608
+ const uppercase = /^[^a-z]*$/;
609
+ //#endregion
610
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/checks.js
611
+ const $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
612
+ var _a;
613
+ inst._zod ?? (inst._zod = {});
614
+ inst._zod.def = def;
615
+ (_a = inst._zod).onattach ?? (_a.onattach = []);
616
+ });
617
+ const numericOriginMap = {
618
+ number: "number",
619
+ bigint: "bigint",
620
+ object: "date"
621
+ };
622
+ const $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst, def) => {
623
+ $ZodCheck.init(inst, def);
624
+ const origin = numericOriginMap[typeof def.value];
625
+ inst._zod.onattach.push((inst) => {
626
+ const bag = inst._zod.bag;
627
+ const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
628
+ if (def.value < curr) if (def.inclusive) bag.maximum = def.value;
629
+ else bag.exclusiveMaximum = def.value;
630
+ });
631
+ inst._zod.check = (payload) => {
632
+ if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
633
+ payload.issues.push({
634
+ origin,
635
+ code: "too_big",
636
+ maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
637
+ input: payload.value,
638
+ inclusive: def.inclusive,
639
+ inst,
640
+ continue: !def.abort
641
+ });
642
+ };
643
+ });
644
+ const $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan", (inst, def) => {
645
+ $ZodCheck.init(inst, def);
646
+ const origin = numericOriginMap[typeof def.value];
647
+ inst._zod.onattach.push((inst) => {
648
+ const bag = inst._zod.bag;
649
+ const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
650
+ if (def.value > curr) if (def.inclusive) bag.minimum = def.value;
651
+ else bag.exclusiveMinimum = def.value;
652
+ });
653
+ inst._zod.check = (payload) => {
654
+ if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
655
+ payload.issues.push({
656
+ origin,
657
+ code: "too_small",
658
+ minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
659
+ input: payload.value,
660
+ inclusive: def.inclusive,
661
+ inst,
662
+ continue: !def.abort
663
+ });
664
+ };
665
+ });
666
+ const $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (inst, def) => {
667
+ $ZodCheck.init(inst, def);
668
+ inst._zod.onattach.push((inst) => {
669
+ var _a;
670
+ (_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
671
+ });
672
+ inst._zod.check = (payload) => {
673
+ if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
674
+ if (typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
675
+ payload.issues.push({
676
+ origin: typeof payload.value,
677
+ code: "not_multiple_of",
678
+ divisor: def.value,
679
+ input: payload.value,
680
+ inst,
681
+ continue: !def.abort
682
+ });
683
+ };
684
+ });
685
+ const $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat", (inst, def) => {
686
+ $ZodCheck.init(inst, def);
687
+ def.format = def.format || "float64";
688
+ const isInt = def.format?.includes("int");
689
+ const origin = isInt ? "int" : "number";
690
+ const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
691
+ inst._zod.onattach.push((inst) => {
692
+ const bag = inst._zod.bag;
693
+ bag.format = def.format;
694
+ bag.minimum = minimum;
695
+ bag.maximum = maximum;
696
+ if (isInt) bag.pattern = integer;
697
+ });
698
+ inst._zod.check = (payload) => {
699
+ const input = payload.value;
700
+ if (isInt) {
701
+ if (!Number.isInteger(input)) {
702
+ payload.issues.push({
703
+ expected: origin,
704
+ format: def.format,
705
+ code: "invalid_type",
706
+ continue: false,
707
+ input,
708
+ inst
709
+ });
710
+ return;
711
+ }
712
+ if (!Number.isSafeInteger(input)) {
713
+ if (input > 0) payload.issues.push({
714
+ input,
715
+ code: "too_big",
716
+ maximum: Number.MAX_SAFE_INTEGER,
717
+ note: "Integers must be within the safe integer range.",
718
+ inst,
719
+ origin,
720
+ inclusive: true,
721
+ continue: !def.abort
722
+ });
723
+ else payload.issues.push({
724
+ input,
725
+ code: "too_small",
726
+ minimum: Number.MIN_SAFE_INTEGER,
727
+ note: "Integers must be within the safe integer range.",
728
+ inst,
729
+ origin,
730
+ inclusive: true,
731
+ continue: !def.abort
732
+ });
733
+ return;
734
+ }
735
+ }
736
+ if (input < minimum) payload.issues.push({
737
+ origin: "number",
738
+ input,
739
+ code: "too_small",
740
+ minimum,
741
+ inclusive: true,
742
+ inst,
743
+ continue: !def.abort
744
+ });
745
+ if (input > maximum) payload.issues.push({
746
+ origin: "number",
747
+ input,
748
+ code: "too_big",
749
+ maximum,
750
+ inclusive: true,
751
+ inst,
752
+ continue: !def.abort
753
+ });
754
+ };
755
+ });
756
+ const $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
757
+ var _a;
758
+ $ZodCheck.init(inst, def);
759
+ (_a = inst._zod.def).when ?? (_a.when = (payload) => {
760
+ const val = payload.value;
761
+ return !nullish(val) && val.length !== void 0;
762
+ });
763
+ inst._zod.onattach.push((inst) => {
764
+ const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
765
+ if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
766
+ });
767
+ inst._zod.check = (payload) => {
768
+ const input = payload.value;
769
+ if (input.length <= def.maximum) return;
770
+ const origin = getLengthableOrigin(input);
771
+ payload.issues.push({
772
+ origin,
773
+ code: "too_big",
774
+ maximum: def.maximum,
775
+ inclusive: true,
776
+ input,
777
+ inst,
778
+ continue: !def.abort
779
+ });
780
+ };
781
+ });
782
+ const $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
783
+ var _a;
784
+ $ZodCheck.init(inst, def);
785
+ (_a = inst._zod.def).when ?? (_a.when = (payload) => {
786
+ const val = payload.value;
787
+ return !nullish(val) && val.length !== void 0;
788
+ });
789
+ inst._zod.onattach.push((inst) => {
790
+ const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
791
+ if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
792
+ });
793
+ inst._zod.check = (payload) => {
794
+ const input = payload.value;
795
+ if (input.length >= def.minimum) return;
796
+ const origin = getLengthableOrigin(input);
797
+ payload.issues.push({
798
+ origin,
799
+ code: "too_small",
800
+ minimum: def.minimum,
801
+ inclusive: true,
802
+ input,
803
+ inst,
804
+ continue: !def.abort
805
+ });
806
+ };
807
+ });
808
+ const $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
809
+ var _a;
810
+ $ZodCheck.init(inst, def);
811
+ (_a = inst._zod.def).when ?? (_a.when = (payload) => {
812
+ const val = payload.value;
813
+ return !nullish(val) && val.length !== void 0;
814
+ });
815
+ inst._zod.onattach.push((inst) => {
816
+ const bag = inst._zod.bag;
817
+ bag.minimum = def.length;
818
+ bag.maximum = def.length;
819
+ bag.length = def.length;
820
+ });
821
+ inst._zod.check = (payload) => {
822
+ const input = payload.value;
823
+ const length = input.length;
824
+ if (length === def.length) return;
825
+ const origin = getLengthableOrigin(input);
826
+ const tooBig = length > def.length;
827
+ payload.issues.push({
828
+ origin,
829
+ ...tooBig ? {
830
+ code: "too_big",
831
+ maximum: def.length
832
+ } : {
833
+ code: "too_small",
834
+ minimum: def.length
835
+ },
836
+ inclusive: true,
837
+ exact: true,
838
+ input: payload.value,
839
+ inst,
840
+ continue: !def.abort
841
+ });
842
+ };
843
+ });
844
+ const $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
845
+ var _a, _b;
846
+ $ZodCheck.init(inst, def);
847
+ inst._zod.onattach.push((inst) => {
848
+ const bag = inst._zod.bag;
849
+ bag.format = def.format;
850
+ if (def.pattern) {
851
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
852
+ bag.patterns.add(def.pattern);
853
+ }
854
+ });
855
+ if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => {
856
+ def.pattern.lastIndex = 0;
857
+ if (def.pattern.test(payload.value)) return;
858
+ payload.issues.push({
859
+ origin: "string",
860
+ code: "invalid_format",
861
+ format: def.format,
862
+ input: payload.value,
863
+ ...def.pattern ? { pattern: def.pattern.toString() } : {},
864
+ inst,
865
+ continue: !def.abort
866
+ });
867
+ });
868
+ else (_b = inst._zod).check ?? (_b.check = () => {});
869
+ });
870
+ const $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def) => {
871
+ $ZodCheckStringFormat.init(inst, def);
872
+ inst._zod.check = (payload) => {
873
+ def.pattern.lastIndex = 0;
874
+ if (def.pattern.test(payload.value)) return;
875
+ payload.issues.push({
876
+ origin: "string",
877
+ code: "invalid_format",
878
+ format: "regex",
879
+ input: payload.value,
880
+ pattern: def.pattern.toString(),
881
+ inst,
882
+ continue: !def.abort
883
+ });
884
+ };
885
+ });
886
+ const $ZodCheckLowerCase = /* @__PURE__ */ $constructor("$ZodCheckLowerCase", (inst, def) => {
887
+ def.pattern ?? (def.pattern = lowercase);
888
+ $ZodCheckStringFormat.init(inst, def);
889
+ });
890
+ const $ZodCheckUpperCase = /* @__PURE__ */ $constructor("$ZodCheckUpperCase", (inst, def) => {
891
+ def.pattern ?? (def.pattern = uppercase);
892
+ $ZodCheckStringFormat.init(inst, def);
893
+ });
894
+ const $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst, def) => {
895
+ $ZodCheck.init(inst, def);
896
+ const escapedRegex = escapeRegex(def.includes);
897
+ const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
898
+ def.pattern = pattern;
899
+ inst._zod.onattach.push((inst) => {
900
+ const bag = inst._zod.bag;
901
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
902
+ bag.patterns.add(pattern);
903
+ });
904
+ inst._zod.check = (payload) => {
905
+ if (payload.value.includes(def.includes, def.position)) return;
906
+ payload.issues.push({
907
+ origin: "string",
908
+ code: "invalid_format",
909
+ format: "includes",
910
+ includes: def.includes,
911
+ input: payload.value,
912
+ inst,
913
+ continue: !def.abort
914
+ });
915
+ };
916
+ });
917
+ const $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (inst, def) => {
918
+ $ZodCheck.init(inst, def);
919
+ const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
920
+ def.pattern ?? (def.pattern = pattern);
921
+ inst._zod.onattach.push((inst) => {
922
+ const bag = inst._zod.bag;
923
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
924
+ bag.patterns.add(pattern);
925
+ });
926
+ inst._zod.check = (payload) => {
927
+ if (payload.value.startsWith(def.prefix)) return;
928
+ payload.issues.push({
929
+ origin: "string",
930
+ code: "invalid_format",
931
+ format: "starts_with",
932
+ prefix: def.prefix,
933
+ input: payload.value,
934
+ inst,
935
+ continue: !def.abort
936
+ });
937
+ };
938
+ });
939
+ const $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (inst, def) => {
940
+ $ZodCheck.init(inst, def);
941
+ const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
942
+ def.pattern ?? (def.pattern = pattern);
943
+ inst._zod.onattach.push((inst) => {
944
+ const bag = inst._zod.bag;
945
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
946
+ bag.patterns.add(pattern);
947
+ });
948
+ inst._zod.check = (payload) => {
949
+ if (payload.value.endsWith(def.suffix)) return;
950
+ payload.issues.push({
951
+ origin: "string",
952
+ code: "invalid_format",
953
+ format: "ends_with",
954
+ suffix: def.suffix,
955
+ input: payload.value,
956
+ inst,
957
+ continue: !def.abort
958
+ });
959
+ };
960
+ });
961
+ const $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (inst, def) => {
962
+ $ZodCheck.init(inst, def);
963
+ inst._zod.check = (payload) => {
964
+ payload.value = def.tx(payload.value);
965
+ };
966
+ });
967
+ //#endregion
968
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/doc.js
969
+ var Doc = class {
970
+ constructor(args = []) {
971
+ this.content = [];
972
+ this.indent = 0;
973
+ if (this) this.args = args;
974
+ }
975
+ indented(fn) {
976
+ this.indent += 1;
977
+ fn(this);
978
+ this.indent -= 1;
979
+ }
980
+ write(arg) {
981
+ if (typeof arg === "function") {
982
+ arg(this, { execution: "sync" });
983
+ arg(this, { execution: "async" });
984
+ return;
985
+ }
986
+ const lines = arg.split("\n").filter((x) => x);
987
+ const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
988
+ const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
989
+ for (const line of dedented) this.content.push(line);
990
+ }
991
+ compile() {
992
+ const F = Function;
993
+ const args = this?.args;
994
+ const lines = [...(this?.content ?? [``]).map((x) => ` ${x}`)];
995
+ return new F(...args, lines.join("\n"));
996
+ }
997
+ };
998
+ //#endregion
999
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/versions.js
1000
+ const version = {
1001
+ major: 4,
1002
+ minor: 4,
1003
+ patch: 3
1004
+ };
1005
+ //#endregion
1006
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/schemas.js
1007
+ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
1008
+ var _a;
1009
+ inst ?? (inst = {});
1010
+ inst._zod.def = def;
1011
+ inst._zod.bag = inst._zod.bag || {};
1012
+ inst._zod.version = version;
1013
+ const checks = [...inst._zod.def.checks ?? []];
1014
+ if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
1015
+ for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
1016
+ if (checks.length === 0) {
1017
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
1018
+ inst._zod.deferred?.push(() => {
1019
+ inst._zod.run = inst._zod.parse;
1020
+ });
1021
+ } else {
1022
+ const runChecks = (payload, checks, ctx) => {
1023
+ let isAborted = aborted(payload);
1024
+ let asyncResult;
1025
+ for (const ch of checks) {
1026
+ if (ch._zod.def.when) {
1027
+ if (explicitlyAborted(payload)) continue;
1028
+ if (!ch._zod.def.when(payload)) continue;
1029
+ } else if (isAborted) continue;
1030
+ const currLen = payload.issues.length;
1031
+ const _ = ch._zod.check(payload);
1032
+ if (_ instanceof Promise && ctx?.async === false) throw new $ZodAsyncError();
1033
+ if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
1034
+ await _;
1035
+ if (payload.issues.length === currLen) return;
1036
+ if (!isAborted) isAborted = aborted(payload, currLen);
1037
+ });
1038
+ else {
1039
+ if (payload.issues.length === currLen) continue;
1040
+ if (!isAborted) isAborted = aborted(payload, currLen);
1041
+ }
1042
+ }
1043
+ if (asyncResult) return asyncResult.then(() => {
1044
+ return payload;
1045
+ });
1046
+ return payload;
1047
+ };
1048
+ const handleCanaryResult = (canary, payload, ctx) => {
1049
+ if (aborted(canary)) {
1050
+ canary.aborted = true;
1051
+ return canary;
1052
+ }
1053
+ const checkResult = runChecks(payload, checks, ctx);
1054
+ if (checkResult instanceof Promise) {
1055
+ if (ctx.async === false) throw new $ZodAsyncError();
1056
+ return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
1057
+ }
1058
+ return inst._zod.parse(checkResult, ctx);
1059
+ };
1060
+ inst._zod.run = (payload, ctx) => {
1061
+ if (ctx.skipChecks) return inst._zod.parse(payload, ctx);
1062
+ if (ctx.direction === "backward") {
1063
+ const canary = inst._zod.parse({
1064
+ value: payload.value,
1065
+ issues: []
1066
+ }, {
1067
+ ...ctx,
1068
+ skipChecks: true
1069
+ });
1070
+ if (canary instanceof Promise) return canary.then((canary) => {
1071
+ return handleCanaryResult(canary, payload, ctx);
1072
+ });
1073
+ return handleCanaryResult(canary, payload, ctx);
1074
+ }
1075
+ const result = inst._zod.parse(payload, ctx);
1076
+ if (result instanceof Promise) {
1077
+ if (ctx.async === false) throw new $ZodAsyncError();
1078
+ return result.then((result) => runChecks(result, checks, ctx));
1079
+ }
1080
+ return runChecks(result, checks, ctx);
1081
+ };
1082
+ }
1083
+ defineLazy(inst, "~standard", () => ({
1084
+ validate: (value) => {
1085
+ try {
1086
+ const r = safeParse$1(inst, value);
1087
+ return r.success ? { value: r.data } : { issues: r.error?.issues };
1088
+ } catch (_) {
1089
+ return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
1090
+ }
1091
+ },
1092
+ vendor: "zod",
1093
+ version: 1
1094
+ }));
1095
+ });
1096
+ const $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
1097
+ $ZodType.init(inst, def);
1098
+ inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag);
1099
+ inst._zod.parse = (payload, _) => {
1100
+ if (def.coerce) try {
1101
+ payload.value = String(payload.value);
1102
+ } catch (_) {}
1103
+ if (typeof payload.value === "string") return payload;
1104
+ payload.issues.push({
1105
+ expected: "string",
1106
+ code: "invalid_type",
1107
+ input: payload.value,
1108
+ inst
1109
+ });
1110
+ return payload;
1111
+ };
1112
+ });
1113
+ const $ZodStringFormat = /* @__PURE__ */ $constructor("$ZodStringFormat", (inst, def) => {
1114
+ $ZodCheckStringFormat.init(inst, def);
1115
+ $ZodString.init(inst, def);
1116
+ });
1117
+ const $ZodGUID = /* @__PURE__ */ $constructor("$ZodGUID", (inst, def) => {
1118
+ def.pattern ?? (def.pattern = guid);
1119
+ $ZodStringFormat.init(inst, def);
1120
+ });
1121
+ const $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
1122
+ if (def.version) {
1123
+ const v = {
1124
+ v1: 1,
1125
+ v2: 2,
1126
+ v3: 3,
1127
+ v4: 4,
1128
+ v5: 5,
1129
+ v6: 6,
1130
+ v7: 7,
1131
+ v8: 8
1132
+ }[def.version];
1133
+ if (v === void 0) throw new Error(`Invalid UUID version: "${def.version}"`);
1134
+ def.pattern ?? (def.pattern = uuid(v));
1135
+ } else def.pattern ?? (def.pattern = uuid());
1136
+ $ZodStringFormat.init(inst, def);
1137
+ });
1138
+ const $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
1139
+ def.pattern ?? (def.pattern = email);
1140
+ $ZodStringFormat.init(inst, def);
1141
+ });
1142
+ const $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
1143
+ $ZodStringFormat.init(inst, def);
1144
+ inst._zod.check = (payload) => {
1145
+ try {
1146
+ const trimmed = payload.value.trim();
1147
+ if (!def.normalize && def.protocol?.source === httpProtocol.source) {
1148
+ if (!/^https?:\/\//i.test(trimmed)) {
1149
+ payload.issues.push({
1150
+ code: "invalid_format",
1151
+ format: "url",
1152
+ note: "Invalid URL format",
1153
+ input: payload.value,
1154
+ inst,
1155
+ continue: !def.abort
1156
+ });
1157
+ return;
1158
+ }
1159
+ }
1160
+ const url = new URL(trimmed);
1161
+ if (def.hostname) {
1162
+ def.hostname.lastIndex = 0;
1163
+ if (!def.hostname.test(url.hostname)) payload.issues.push({
1164
+ code: "invalid_format",
1165
+ format: "url",
1166
+ note: "Invalid hostname",
1167
+ pattern: def.hostname.source,
1168
+ input: payload.value,
1169
+ inst,
1170
+ continue: !def.abort
1171
+ });
1172
+ }
1173
+ if (def.protocol) {
1174
+ def.protocol.lastIndex = 0;
1175
+ if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({
1176
+ code: "invalid_format",
1177
+ format: "url",
1178
+ note: "Invalid protocol",
1179
+ pattern: def.protocol.source,
1180
+ input: payload.value,
1181
+ inst,
1182
+ continue: !def.abort
1183
+ });
1184
+ }
1185
+ if (def.normalize) payload.value = url.href;
1186
+ else payload.value = trimmed;
1187
+ return;
1188
+ } catch (_) {
1189
+ payload.issues.push({
1190
+ code: "invalid_format",
1191
+ format: "url",
1192
+ input: payload.value,
1193
+ inst,
1194
+ continue: !def.abort
1195
+ });
1196
+ }
1197
+ };
1198
+ });
1199
+ const $ZodEmoji = /* @__PURE__ */ $constructor("$ZodEmoji", (inst, def) => {
1200
+ def.pattern ?? (def.pattern = emoji());
1201
+ $ZodStringFormat.init(inst, def);
1202
+ });
1203
+ const $ZodNanoID = /* @__PURE__ */ $constructor("$ZodNanoID", (inst, def) => {
1204
+ def.pattern ?? (def.pattern = nanoid);
1205
+ $ZodStringFormat.init(inst, def);
1206
+ });
1207
+ /**
1208
+ * @deprecated CUID v1 is deprecated by its authors due to information leakage
1209
+ * (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
1210
+ * See https://github.com/paralleldrive/cuid.
1211
+ */
1212
+ const $ZodCUID = /* @__PURE__ */ $constructor("$ZodCUID", (inst, def) => {
1213
+ def.pattern ?? (def.pattern = cuid);
1214
+ $ZodStringFormat.init(inst, def);
1215
+ });
1216
+ const $ZodCUID2 = /* @__PURE__ */ $constructor("$ZodCUID2", (inst, def) => {
1217
+ def.pattern ?? (def.pattern = cuid2);
1218
+ $ZodStringFormat.init(inst, def);
1219
+ });
1220
+ const $ZodULID = /* @__PURE__ */ $constructor("$ZodULID", (inst, def) => {
1221
+ def.pattern ?? (def.pattern = ulid);
1222
+ $ZodStringFormat.init(inst, def);
1223
+ });
1224
+ const $ZodXID = /* @__PURE__ */ $constructor("$ZodXID", (inst, def) => {
1225
+ def.pattern ?? (def.pattern = xid);
1226
+ $ZodStringFormat.init(inst, def);
1227
+ });
1228
+ const $ZodKSUID = /* @__PURE__ */ $constructor("$ZodKSUID", (inst, def) => {
1229
+ def.pattern ?? (def.pattern = ksuid);
1230
+ $ZodStringFormat.init(inst, def);
1231
+ });
1232
+ const $ZodISODateTime = /* @__PURE__ */ $constructor("$ZodISODateTime", (inst, def) => {
1233
+ def.pattern ?? (def.pattern = datetime$1(def));
1234
+ $ZodStringFormat.init(inst, def);
1235
+ });
1236
+ const $ZodISODate = /* @__PURE__ */ $constructor("$ZodISODate", (inst, def) => {
1237
+ def.pattern ?? (def.pattern = date$1);
1238
+ $ZodStringFormat.init(inst, def);
1239
+ });
1240
+ const $ZodISOTime = /* @__PURE__ */ $constructor("$ZodISOTime", (inst, def) => {
1241
+ def.pattern ?? (def.pattern = time$1(def));
1242
+ $ZodStringFormat.init(inst, def);
1243
+ });
1244
+ const $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, def) => {
1245
+ def.pattern ?? (def.pattern = duration$1);
1246
+ $ZodStringFormat.init(inst, def);
1247
+ });
1248
+ const $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
1249
+ def.pattern ?? (def.pattern = ipv4);
1250
+ $ZodStringFormat.init(inst, def);
1251
+ inst._zod.bag.format = `ipv4`;
1252
+ });
1253
+ const $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
1254
+ def.pattern ?? (def.pattern = ipv6);
1255
+ $ZodStringFormat.init(inst, def);
1256
+ inst._zod.bag.format = `ipv6`;
1257
+ inst._zod.check = (payload) => {
1258
+ try {
1259
+ new URL(`http://[${payload.value}]`);
1260
+ } catch {
1261
+ payload.issues.push({
1262
+ code: "invalid_format",
1263
+ format: "ipv6",
1264
+ input: payload.value,
1265
+ inst,
1266
+ continue: !def.abort
1267
+ });
1268
+ }
1269
+ };
1270
+ });
1271
+ const $ZodCIDRv4 = /* @__PURE__ */ $constructor("$ZodCIDRv4", (inst, def) => {
1272
+ def.pattern ?? (def.pattern = cidrv4);
1273
+ $ZodStringFormat.init(inst, def);
1274
+ });
1275
+ const $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
1276
+ def.pattern ?? (def.pattern = cidrv6);
1277
+ $ZodStringFormat.init(inst, def);
1278
+ inst._zod.check = (payload) => {
1279
+ const parts = payload.value.split("/");
1280
+ try {
1281
+ if (parts.length !== 2) throw new Error();
1282
+ const [address, prefix] = parts;
1283
+ if (!prefix) throw new Error();
1284
+ const prefixNum = Number(prefix);
1285
+ if (`${prefixNum}` !== prefix) throw new Error();
1286
+ if (prefixNum < 0 || prefixNum > 128) throw new Error();
1287
+ new URL(`http://[${address}]`);
1288
+ } catch {
1289
+ payload.issues.push({
1290
+ code: "invalid_format",
1291
+ format: "cidrv6",
1292
+ input: payload.value,
1293
+ inst,
1294
+ continue: !def.abort
1295
+ });
1296
+ }
1297
+ };
1298
+ });
1299
+ function isValidBase64(data) {
1300
+ if (data === "") return true;
1301
+ if (/\s/.test(data)) return false;
1302
+ if (data.length % 4 !== 0) return false;
1303
+ try {
1304
+ atob(data);
1305
+ return true;
1306
+ } catch {
1307
+ return false;
1308
+ }
1309
+ }
1310
+ const $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
1311
+ def.pattern ?? (def.pattern = base64);
1312
+ $ZodStringFormat.init(inst, def);
1313
+ inst._zod.bag.contentEncoding = "base64";
1314
+ inst._zod.check = (payload) => {
1315
+ if (isValidBase64(payload.value)) return;
1316
+ payload.issues.push({
1317
+ code: "invalid_format",
1318
+ format: "base64",
1319
+ input: payload.value,
1320
+ inst,
1321
+ continue: !def.abort
1322
+ });
1323
+ };
1324
+ });
1325
+ function isValidBase64URL(data) {
1326
+ if (!base64url.test(data)) return false;
1327
+ const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
1328
+ return isValidBase64(base64.padEnd(Math.ceil(base64.length / 4) * 4, "="));
1329
+ }
1330
+ const $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
1331
+ def.pattern ?? (def.pattern = base64url);
1332
+ $ZodStringFormat.init(inst, def);
1333
+ inst._zod.bag.contentEncoding = "base64url";
1334
+ inst._zod.check = (payload) => {
1335
+ if (isValidBase64URL(payload.value)) return;
1336
+ payload.issues.push({
1337
+ code: "invalid_format",
1338
+ format: "base64url",
1339
+ input: payload.value,
1340
+ inst,
1341
+ continue: !def.abort
1342
+ });
1343
+ };
1344
+ });
1345
+ const $ZodE164 = /* @__PURE__ */ $constructor("$ZodE164", (inst, def) => {
1346
+ def.pattern ?? (def.pattern = e164);
1347
+ $ZodStringFormat.init(inst, def);
1348
+ });
1349
+ function isValidJWT(token, algorithm = null) {
1350
+ try {
1351
+ const tokensParts = token.split(".");
1352
+ if (tokensParts.length !== 3) return false;
1353
+ const [header] = tokensParts;
1354
+ if (!header) return false;
1355
+ const parsedHeader = JSON.parse(atob(header));
1356
+ if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT") return false;
1357
+ if (!parsedHeader.alg) return false;
1358
+ if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm)) return false;
1359
+ return true;
1360
+ } catch {
1361
+ return false;
1362
+ }
1363
+ }
1364
+ const $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
1365
+ $ZodStringFormat.init(inst, def);
1366
+ inst._zod.check = (payload) => {
1367
+ if (isValidJWT(payload.value, def.alg)) return;
1368
+ payload.issues.push({
1369
+ code: "invalid_format",
1370
+ format: "jwt",
1371
+ input: payload.value,
1372
+ inst,
1373
+ continue: !def.abort
1374
+ });
1375
+ };
1376
+ });
1377
+ const $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
1378
+ $ZodType.init(inst, def);
1379
+ inst._zod.pattern = inst._zod.bag.pattern ?? number$1;
1380
+ inst._zod.parse = (payload, _ctx) => {
1381
+ if (def.coerce) try {
1382
+ payload.value = Number(payload.value);
1383
+ } catch (_) {}
1384
+ const input = payload.value;
1385
+ if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) return payload;
1386
+ const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
1387
+ payload.issues.push({
1388
+ expected: "number",
1389
+ code: "invalid_type",
1390
+ input,
1391
+ inst,
1392
+ ...received ? { received } : {}
1393
+ });
1394
+ return payload;
1395
+ };
1396
+ });
1397
+ const $ZodNumberFormat = /* @__PURE__ */ $constructor("$ZodNumberFormat", (inst, def) => {
1398
+ $ZodCheckNumberFormat.init(inst, def);
1399
+ $ZodNumber.init(inst, def);
1400
+ });
1401
+ const $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
1402
+ $ZodType.init(inst, def);
1403
+ inst._zod.pattern = boolean$1;
1404
+ inst._zod.parse = (payload, _ctx) => {
1405
+ if (def.coerce) try {
1406
+ payload.value = Boolean(payload.value);
1407
+ } catch (_) {}
1408
+ const input = payload.value;
1409
+ if (typeof input === "boolean") return payload;
1410
+ payload.issues.push({
1411
+ expected: "boolean",
1412
+ code: "invalid_type",
1413
+ input,
1414
+ inst
1415
+ });
1416
+ return payload;
1417
+ };
1418
+ });
1419
+ const $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
1420
+ $ZodType.init(inst, def);
1421
+ inst._zod.parse = (payload) => payload;
1422
+ });
1423
+ const $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
1424
+ $ZodType.init(inst, def);
1425
+ inst._zod.parse = (payload, _ctx) => {
1426
+ payload.issues.push({
1427
+ expected: "never",
1428
+ code: "invalid_type",
1429
+ input: payload.value,
1430
+ inst
1431
+ });
1432
+ return payload;
1433
+ };
1434
+ });
1435
+ function handleArrayResult(result, final, index) {
1436
+ if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
1437
+ final.value[index] = result.value;
1438
+ }
1439
+ const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
1440
+ $ZodType.init(inst, def);
1441
+ inst._zod.parse = (payload, ctx) => {
1442
+ const input = payload.value;
1443
+ if (!Array.isArray(input)) {
1444
+ payload.issues.push({
1445
+ expected: "array",
1446
+ code: "invalid_type",
1447
+ input,
1448
+ inst
1449
+ });
1450
+ return payload;
1451
+ }
1452
+ payload.value = Array(input.length);
1453
+ const proms = [];
1454
+ for (let i = 0; i < input.length; i++) {
1455
+ const item = input[i];
1456
+ const result = def.element._zod.run({
1457
+ value: item,
1458
+ issues: []
1459
+ }, ctx);
1460
+ if (result instanceof Promise) proms.push(result.then((result) => handleArrayResult(result, payload, i)));
1461
+ else handleArrayResult(result, payload, i);
1462
+ }
1463
+ if (proms.length) return Promise.all(proms).then(() => payload);
1464
+ return payload;
1465
+ };
1466
+ });
1467
+ function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
1468
+ const isPresent = key in input;
1469
+ if (result.issues.length) {
1470
+ if (isOptionalIn && isOptionalOut && !isPresent) return;
1471
+ final.issues.push(...prefixIssues(key, result.issues));
1472
+ }
1473
+ if (!isPresent && !isOptionalIn) {
1474
+ if (!result.issues.length) final.issues.push({
1475
+ code: "invalid_type",
1476
+ expected: "nonoptional",
1477
+ input: void 0,
1478
+ path: [key]
1479
+ });
1480
+ return;
1481
+ }
1482
+ if (result.value === void 0) {
1483
+ if (isPresent) final.value[key] = void 0;
1484
+ } else final.value[key] = result.value;
1485
+ }
1486
+ function normalizeDef(def) {
1487
+ const keys = Object.keys(def.shape);
1488
+ for (const k of keys) if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
1489
+ const okeys = optionalKeys(def.shape);
1490
+ return {
1491
+ ...def,
1492
+ keys,
1493
+ keySet: new Set(keys),
1494
+ numKeys: keys.length,
1495
+ optionalKeys: new Set(okeys)
1496
+ };
1497
+ }
1498
+ function handleCatchall(proms, input, payload, ctx, def, inst) {
1499
+ const unrecognized = [];
1500
+ const keySet = def.keySet;
1501
+ const _catchall = def.catchall._zod;
1502
+ const t = _catchall.def.type;
1503
+ const isOptionalIn = _catchall.optin === "optional";
1504
+ const isOptionalOut = _catchall.optout === "optional";
1505
+ for (const key in input) {
1506
+ if (key === "__proto__") continue;
1507
+ if (keySet.has(key)) continue;
1508
+ if (t === "never") {
1509
+ unrecognized.push(key);
1510
+ continue;
1511
+ }
1512
+ const r = _catchall.run({
1513
+ value: input[key],
1514
+ issues: []
1515
+ }, ctx);
1516
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
1517
+ else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
1518
+ }
1519
+ if (unrecognized.length) payload.issues.push({
1520
+ code: "unrecognized_keys",
1521
+ keys: unrecognized,
1522
+ input,
1523
+ inst
1524
+ });
1525
+ if (!proms.length) return payload;
1526
+ return Promise.all(proms).then(() => {
1527
+ return payload;
1528
+ });
1529
+ }
1530
+ const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
1531
+ $ZodType.init(inst, def);
1532
+ if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) {
1533
+ const sh = def.shape;
1534
+ Object.defineProperty(def, "shape", { get: () => {
1535
+ const newSh = { ...sh };
1536
+ Object.defineProperty(def, "shape", { value: newSh });
1537
+ return newSh;
1538
+ } });
1539
+ }
1540
+ const _normalized = cached(() => normalizeDef(def));
1541
+ defineLazy(inst._zod, "propValues", () => {
1542
+ const shape = def.shape;
1543
+ const propValues = {};
1544
+ for (const key in shape) {
1545
+ const field = shape[key]._zod;
1546
+ if (field.values) {
1547
+ propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
1548
+ for (const v of field.values) propValues[key].add(v);
1549
+ }
1550
+ }
1551
+ return propValues;
1552
+ });
1553
+ const isObject$1 = isObject;
1554
+ const catchall = def.catchall;
1555
+ let value;
1556
+ inst._zod.parse = (payload, ctx) => {
1557
+ value ?? (value = _normalized.value);
1558
+ const input = payload.value;
1559
+ if (!isObject$1(input)) {
1560
+ payload.issues.push({
1561
+ expected: "object",
1562
+ code: "invalid_type",
1563
+ input,
1564
+ inst
1565
+ });
1566
+ return payload;
1567
+ }
1568
+ payload.value = {};
1569
+ const proms = [];
1570
+ const shape = value.shape;
1571
+ for (const key of value.keys) {
1572
+ const el = shape[key];
1573
+ const isOptionalIn = el._zod.optin === "optional";
1574
+ const isOptionalOut = el._zod.optout === "optional";
1575
+ const r = el._zod.run({
1576
+ value: input[key],
1577
+ issues: []
1578
+ }, ctx);
1579
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
1580
+ else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
1581
+ }
1582
+ if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
1583
+ return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
1584
+ };
1585
+ });
1586
+ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
1587
+ $ZodObject.init(inst, def);
1588
+ const superParse = inst._zod.parse;
1589
+ const _normalized = cached(() => normalizeDef(def));
1590
+ const generateFastpass = (shape) => {
1591
+ const doc = new Doc([
1592
+ "shape",
1593
+ "payload",
1594
+ "ctx"
1595
+ ]);
1596
+ const normalized = _normalized.value;
1597
+ const parseStr = (key) => {
1598
+ const k = esc(key);
1599
+ return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
1600
+ };
1601
+ doc.write(`const input = payload.value;`);
1602
+ const ids = Object.create(null);
1603
+ let counter = 0;
1604
+ for (const key of normalized.keys) ids[key] = `key_${counter++}`;
1605
+ doc.write(`const newResult = {};`);
1606
+ for (const key of normalized.keys) {
1607
+ const id = ids[key];
1608
+ const k = esc(key);
1609
+ const schema = shape[key];
1610
+ const isOptionalIn = schema?._zod?.optin === "optional";
1611
+ const isOptionalOut = schema?._zod?.optout === "optional";
1612
+ doc.write(`const ${id} = ${parseStr(key)};`);
1613
+ if (isOptionalIn && isOptionalOut) doc.write(`
1614
+ if (${id}.issues.length) {
1615
+ if (${k} in input) {
1616
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1617
+ ...iss,
1618
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
1619
+ })));
1620
+ }
1621
+ }
1622
+
1623
+ if (${id}.value === undefined) {
1624
+ if (${k} in input) {
1625
+ newResult[${k}] = undefined;
1626
+ }
1627
+ } else {
1628
+ newResult[${k}] = ${id}.value;
1629
+ }
1630
+
1631
+ `);
1632
+ else if (!isOptionalIn) doc.write(`
1633
+ const ${id}_present = ${k} in input;
1634
+ if (${id}.issues.length) {
1635
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1636
+ ...iss,
1637
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
1638
+ })));
1639
+ }
1640
+ if (!${id}_present && !${id}.issues.length) {
1641
+ payload.issues.push({
1642
+ code: "invalid_type",
1643
+ expected: "nonoptional",
1644
+ input: undefined,
1645
+ path: [${k}]
1646
+ });
1647
+ }
1648
+
1649
+ if (${id}_present) {
1650
+ if (${id}.value === undefined) {
1651
+ newResult[${k}] = undefined;
1652
+ } else {
1653
+ newResult[${k}] = ${id}.value;
1654
+ }
1655
+ }
1656
+
1657
+ `);
1658
+ else doc.write(`
1659
+ if (${id}.issues.length) {
1660
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1661
+ ...iss,
1662
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
1663
+ })));
1664
+ }
1665
+
1666
+ if (${id}.value === undefined) {
1667
+ if (${k} in input) {
1668
+ newResult[${k}] = undefined;
1669
+ }
1670
+ } else {
1671
+ newResult[${k}] = ${id}.value;
1672
+ }
1673
+
1674
+ `);
1675
+ }
1676
+ doc.write(`payload.value = newResult;`);
1677
+ doc.write(`return payload;`);
1678
+ const fn = doc.compile();
1679
+ return (payload, ctx) => fn(shape, payload, ctx);
1680
+ };
1681
+ let fastpass;
1682
+ const isObject$2 = isObject;
1683
+ const jit = !globalConfig.jitless;
1684
+ const fastEnabled = jit && allowsEval.value;
1685
+ const catchall = def.catchall;
1686
+ let value;
1687
+ inst._zod.parse = (payload, ctx) => {
1688
+ value ?? (value = _normalized.value);
1689
+ const input = payload.value;
1690
+ if (!isObject$2(input)) {
1691
+ payload.issues.push({
1692
+ expected: "object",
1693
+ code: "invalid_type",
1694
+ input,
1695
+ inst
1696
+ });
1697
+ return payload;
1698
+ }
1699
+ if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
1700
+ if (!fastpass) fastpass = generateFastpass(def.shape);
1701
+ payload = fastpass(payload, ctx);
1702
+ if (!catchall) return payload;
1703
+ return handleCatchall([], input, payload, ctx, value, inst);
1704
+ }
1705
+ return superParse(payload, ctx);
1706
+ };
1707
+ });
1708
+ function handleUnionResults(results, final, inst, ctx) {
1709
+ for (const result of results) if (result.issues.length === 0) {
1710
+ final.value = result.value;
1711
+ return final;
1712
+ }
1713
+ const nonaborted = results.filter((r) => !aborted(r));
1714
+ if (nonaborted.length === 1) {
1715
+ final.value = nonaborted[0].value;
1716
+ return nonaborted[0];
1717
+ }
1718
+ final.issues.push({
1719
+ code: "invalid_union",
1720
+ input: final.value,
1721
+ inst,
1722
+ errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
1723
+ });
1724
+ return final;
1725
+ }
1726
+ const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
1727
+ $ZodType.init(inst, def);
1728
+ defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
1729
+ defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
1730
+ defineLazy(inst._zod, "values", () => {
1731
+ if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
1732
+ });
1733
+ defineLazy(inst._zod, "pattern", () => {
1734
+ if (def.options.every((o) => o._zod.pattern)) {
1735
+ const patterns = def.options.map((o) => o._zod.pattern);
1736
+ return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
1737
+ }
1738
+ });
1739
+ const first = def.options.length === 1 ? def.options[0]._zod.run : null;
1740
+ inst._zod.parse = (payload, ctx) => {
1741
+ if (first) return first(payload, ctx);
1742
+ let async = false;
1743
+ const results = [];
1744
+ for (const option of def.options) {
1745
+ const result = option._zod.run({
1746
+ value: payload.value,
1747
+ issues: []
1748
+ }, ctx);
1749
+ if (result instanceof Promise) {
1750
+ results.push(result);
1751
+ async = true;
1752
+ } else {
1753
+ if (result.issues.length === 0) return result;
1754
+ results.push(result);
1755
+ }
1756
+ }
1757
+ if (!async) return handleUnionResults(results, payload, inst, ctx);
1758
+ return Promise.all(results).then((results) => {
1759
+ return handleUnionResults(results, payload, inst, ctx);
1760
+ });
1761
+ };
1762
+ });
1763
+ const $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
1764
+ $ZodType.init(inst, def);
1765
+ inst._zod.parse = (payload, ctx) => {
1766
+ const input = payload.value;
1767
+ const left = def.left._zod.run({
1768
+ value: input,
1769
+ issues: []
1770
+ }, ctx);
1771
+ const right = def.right._zod.run({
1772
+ value: input,
1773
+ issues: []
1774
+ }, ctx);
1775
+ if (left instanceof Promise || right instanceof Promise) return Promise.all([left, right]).then(([left, right]) => {
1776
+ return handleIntersectionResults(payload, left, right);
1777
+ });
1778
+ return handleIntersectionResults(payload, left, right);
1779
+ };
1780
+ });
1781
+ function mergeValues(a, b) {
1782
+ if (a === b) return {
1783
+ valid: true,
1784
+ data: a
1785
+ };
1786
+ if (a instanceof Date && b instanceof Date && +a === +b) return {
1787
+ valid: true,
1788
+ data: a
1789
+ };
1790
+ if (isPlainObject(a) && isPlainObject(b)) {
1791
+ const bKeys = Object.keys(b);
1792
+ const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
1793
+ const newObj = {
1794
+ ...a,
1795
+ ...b
1796
+ };
1797
+ for (const key of sharedKeys) {
1798
+ const sharedValue = mergeValues(a[key], b[key]);
1799
+ if (!sharedValue.valid) return {
1800
+ valid: false,
1801
+ mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
1802
+ };
1803
+ newObj[key] = sharedValue.data;
1804
+ }
1805
+ return {
1806
+ valid: true,
1807
+ data: newObj
1808
+ };
1809
+ }
1810
+ if (Array.isArray(a) && Array.isArray(b)) {
1811
+ if (a.length !== b.length) return {
1812
+ valid: false,
1813
+ mergeErrorPath: []
1814
+ };
1815
+ const newArray = [];
1816
+ for (let index = 0; index < a.length; index++) {
1817
+ const itemA = a[index];
1818
+ const itemB = b[index];
1819
+ const sharedValue = mergeValues(itemA, itemB);
1820
+ if (!sharedValue.valid) return {
1821
+ valid: false,
1822
+ mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
1823
+ };
1824
+ newArray.push(sharedValue.data);
1825
+ }
1826
+ return {
1827
+ valid: true,
1828
+ data: newArray
1829
+ };
1830
+ }
1831
+ return {
1832
+ valid: false,
1833
+ mergeErrorPath: []
1834
+ };
1835
+ }
1836
+ function handleIntersectionResults(result, left, right) {
1837
+ const unrecKeys = /* @__PURE__ */ new Map();
1838
+ let unrecIssue;
1839
+ for (const iss of left.issues) if (iss.code === "unrecognized_keys") {
1840
+ unrecIssue ?? (unrecIssue = iss);
1841
+ for (const k of iss.keys) {
1842
+ if (!unrecKeys.has(k)) unrecKeys.set(k, {});
1843
+ unrecKeys.get(k).l = true;
1844
+ }
1845
+ } else result.issues.push(iss);
1846
+ for (const iss of right.issues) if (iss.code === "unrecognized_keys") for (const k of iss.keys) {
1847
+ if (!unrecKeys.has(k)) unrecKeys.set(k, {});
1848
+ unrecKeys.get(k).r = true;
1849
+ }
1850
+ else result.issues.push(iss);
1851
+ const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
1852
+ if (bothKeys.length && unrecIssue) result.issues.push({
1853
+ ...unrecIssue,
1854
+ keys: bothKeys
1855
+ });
1856
+ if (aborted(result)) return result;
1857
+ const merged = mergeValues(left.value, right.value);
1858
+ if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
1859
+ result.value = merged.data;
1860
+ return result;
1861
+ }
1862
+ const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
1863
+ $ZodType.init(inst, def);
1864
+ inst._zod.parse = (payload, ctx) => {
1865
+ const input = payload.value;
1866
+ if (!isPlainObject(input)) {
1867
+ payload.issues.push({
1868
+ expected: "record",
1869
+ code: "invalid_type",
1870
+ input,
1871
+ inst
1872
+ });
1873
+ return payload;
1874
+ }
1875
+ const proms = [];
1876
+ const values = def.keyType._zod.values;
1877
+ if (values) {
1878
+ payload.value = {};
1879
+ const recordKeys = /* @__PURE__ */ new Set();
1880
+ for (const key of values) if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
1881
+ recordKeys.add(typeof key === "number" ? key.toString() : key);
1882
+ const keyResult = def.keyType._zod.run({
1883
+ value: key,
1884
+ issues: []
1885
+ }, ctx);
1886
+ if (keyResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
1887
+ if (keyResult.issues.length) {
1888
+ payload.issues.push({
1889
+ code: "invalid_key",
1890
+ origin: "record",
1891
+ issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
1892
+ input: key,
1893
+ path: [key],
1894
+ inst
1895
+ });
1896
+ continue;
1897
+ }
1898
+ const outKey = keyResult.value;
1899
+ const result = def.valueType._zod.run({
1900
+ value: input[key],
1901
+ issues: []
1902
+ }, ctx);
1903
+ if (result instanceof Promise) proms.push(result.then((result) => {
1904
+ if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
1905
+ payload.value[outKey] = result.value;
1906
+ }));
1907
+ else {
1908
+ if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
1909
+ payload.value[outKey] = result.value;
1910
+ }
1911
+ }
1912
+ let unrecognized;
1913
+ for (const key in input) if (!recordKeys.has(key)) {
1914
+ unrecognized = unrecognized ?? [];
1915
+ unrecognized.push(key);
1916
+ }
1917
+ if (unrecognized && unrecognized.length > 0) payload.issues.push({
1918
+ code: "unrecognized_keys",
1919
+ input,
1920
+ inst,
1921
+ keys: unrecognized
1922
+ });
1923
+ } else {
1924
+ payload.value = {};
1925
+ for (const key of Reflect.ownKeys(input)) {
1926
+ if (key === "__proto__") continue;
1927
+ if (!Object.prototype.propertyIsEnumerable.call(input, key)) continue;
1928
+ let keyResult = def.keyType._zod.run({
1929
+ value: key,
1930
+ issues: []
1931
+ }, ctx);
1932
+ if (keyResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
1933
+ if (typeof key === "string" && number$1.test(key) && keyResult.issues.length) {
1934
+ const retryResult = def.keyType._zod.run({
1935
+ value: Number(key),
1936
+ issues: []
1937
+ }, ctx);
1938
+ if (retryResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
1939
+ if (retryResult.issues.length === 0) keyResult = retryResult;
1940
+ }
1941
+ if (keyResult.issues.length) {
1942
+ if (def.mode === "loose") payload.value[key] = input[key];
1943
+ else payload.issues.push({
1944
+ code: "invalid_key",
1945
+ origin: "record",
1946
+ issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
1947
+ input: key,
1948
+ path: [key],
1949
+ inst
1950
+ });
1951
+ continue;
1952
+ }
1953
+ const result = def.valueType._zod.run({
1954
+ value: input[key],
1955
+ issues: []
1956
+ }, ctx);
1957
+ if (result instanceof Promise) proms.push(result.then((result) => {
1958
+ if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
1959
+ payload.value[keyResult.value] = result.value;
1960
+ }));
1961
+ else {
1962
+ if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
1963
+ payload.value[keyResult.value] = result.value;
1964
+ }
1965
+ }
1966
+ }
1967
+ if (proms.length) return Promise.all(proms).then(() => payload);
1968
+ return payload;
1969
+ };
1970
+ });
1971
+ const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
1972
+ $ZodType.init(inst, def);
1973
+ const values = getEnumValues(def.entries);
1974
+ const valuesSet = new Set(values);
1975
+ inst._zod.values = valuesSet;
1976
+ inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
1977
+ inst._zod.parse = (payload, _ctx) => {
1978
+ const input = payload.value;
1979
+ if (valuesSet.has(input)) return payload;
1980
+ payload.issues.push({
1981
+ code: "invalid_value",
1982
+ values,
1983
+ input,
1984
+ inst
1985
+ });
1986
+ return payload;
1987
+ };
1988
+ });
1989
+ const $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
1990
+ $ZodType.init(inst, def);
1991
+ if (def.values.length === 0) throw new Error("Cannot create literal schema with no valid values");
1992
+ const values = new Set(def.values);
1993
+ inst._zod.values = values;
1994
+ inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
1995
+ inst._zod.parse = (payload, _ctx) => {
1996
+ const input = payload.value;
1997
+ if (values.has(input)) return payload;
1998
+ payload.issues.push({
1999
+ code: "invalid_value",
2000
+ values: def.values,
2001
+ input,
2002
+ inst
2003
+ });
2004
+ return payload;
2005
+ };
2006
+ });
2007
+ const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
2008
+ $ZodType.init(inst, def);
2009
+ inst._zod.optin = "optional";
2010
+ inst._zod.parse = (payload, ctx) => {
2011
+ if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
2012
+ const _out = def.transform(payload.value, payload);
2013
+ if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
2014
+ payload.value = output;
2015
+ payload.fallback = true;
2016
+ return payload;
2017
+ });
2018
+ if (_out instanceof Promise) throw new $ZodAsyncError();
2019
+ payload.value = _out;
2020
+ payload.fallback = true;
2021
+ return payload;
2022
+ };
2023
+ });
2024
+ function handleOptionalResult(result, input) {
2025
+ if (input === void 0 && (result.issues.length || result.fallback)) return {
2026
+ issues: [],
2027
+ value: void 0
2028
+ };
2029
+ return result;
2030
+ }
2031
+ const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
2032
+ $ZodType.init(inst, def);
2033
+ inst._zod.optin = "optional";
2034
+ inst._zod.optout = "optional";
2035
+ defineLazy(inst._zod, "values", () => {
2036
+ return def.innerType._zod.values ? new Set([...def.innerType._zod.values, void 0]) : void 0;
2037
+ });
2038
+ defineLazy(inst._zod, "pattern", () => {
2039
+ const pattern = def.innerType._zod.pattern;
2040
+ return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
2041
+ });
2042
+ inst._zod.parse = (payload, ctx) => {
2043
+ if (def.innerType._zod.optin === "optional") {
2044
+ const input = payload.value;
2045
+ const result = def.innerType._zod.run(payload, ctx);
2046
+ if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, input));
2047
+ return handleOptionalResult(result, input);
2048
+ }
2049
+ if (payload.value === void 0) return payload;
2050
+ return def.innerType._zod.run(payload, ctx);
2051
+ };
2052
+ });
2053
+ const $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
2054
+ $ZodOptional.init(inst, def);
2055
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2056
+ defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
2057
+ inst._zod.parse = (payload, ctx) => {
2058
+ return def.innerType._zod.run(payload, ctx);
2059
+ };
2060
+ });
2061
+ const $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
2062
+ $ZodType.init(inst, def);
2063
+ defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
2064
+ defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2065
+ defineLazy(inst._zod, "pattern", () => {
2066
+ const pattern = def.innerType._zod.pattern;
2067
+ return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
2068
+ });
2069
+ defineLazy(inst._zod, "values", () => {
2070
+ return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : void 0;
2071
+ });
2072
+ inst._zod.parse = (payload, ctx) => {
2073
+ if (payload.value === null) return payload;
2074
+ return def.innerType._zod.run(payload, ctx);
2075
+ };
2076
+ });
2077
+ const $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
2078
+ $ZodType.init(inst, def);
2079
+ inst._zod.optin = "optional";
2080
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2081
+ inst._zod.parse = (payload, ctx) => {
2082
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2083
+ if (payload.value === void 0) {
2084
+ payload.value = def.defaultValue;
2085
+ /**
2086
+ * $ZodDefault returns the default value immediately in forward direction.
2087
+ * It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
2088
+ return payload;
2089
+ }
2090
+ const result = def.innerType._zod.run(payload, ctx);
2091
+ if (result instanceof Promise) return result.then((result) => handleDefaultResult(result, def));
2092
+ return handleDefaultResult(result, def);
2093
+ };
2094
+ });
2095
+ function handleDefaultResult(payload, def) {
2096
+ if (payload.value === void 0) payload.value = def.defaultValue;
2097
+ return payload;
2098
+ }
2099
+ const $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
2100
+ $ZodType.init(inst, def);
2101
+ inst._zod.optin = "optional";
2102
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2103
+ inst._zod.parse = (payload, ctx) => {
2104
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2105
+ if (payload.value === void 0) payload.value = def.defaultValue;
2106
+ return def.innerType._zod.run(payload, ctx);
2107
+ };
2108
+ });
2109
+ const $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
2110
+ $ZodType.init(inst, def);
2111
+ defineLazy(inst._zod, "values", () => {
2112
+ const v = def.innerType._zod.values;
2113
+ return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
2114
+ });
2115
+ inst._zod.parse = (payload, ctx) => {
2116
+ const result = def.innerType._zod.run(payload, ctx);
2117
+ if (result instanceof Promise) return result.then((result) => handleNonOptionalResult(result, inst));
2118
+ return handleNonOptionalResult(result, inst);
2119
+ };
2120
+ });
2121
+ function handleNonOptionalResult(payload, inst) {
2122
+ if (!payload.issues.length && payload.value === void 0) payload.issues.push({
2123
+ code: "invalid_type",
2124
+ expected: "nonoptional",
2125
+ input: payload.value,
2126
+ inst
2127
+ });
2128
+ return payload;
2129
+ }
2130
+ const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
2131
+ $ZodType.init(inst, def);
2132
+ inst._zod.optin = "optional";
2133
+ defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2134
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2135
+ inst._zod.parse = (payload, ctx) => {
2136
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2137
+ const result = def.innerType._zod.run(payload, ctx);
2138
+ if (result instanceof Promise) return result.then((result) => {
2139
+ payload.value = result.value;
2140
+ if (result.issues.length) {
2141
+ payload.value = def.catchValue({
2142
+ ...payload,
2143
+ error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2144
+ input: payload.value
2145
+ });
2146
+ payload.issues = [];
2147
+ payload.fallback = true;
2148
+ }
2149
+ return payload;
2150
+ });
2151
+ payload.value = result.value;
2152
+ if (result.issues.length) {
2153
+ payload.value = def.catchValue({
2154
+ ...payload,
2155
+ error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2156
+ input: payload.value
2157
+ });
2158
+ payload.issues = [];
2159
+ payload.fallback = true;
2160
+ }
2161
+ return payload;
2162
+ };
2163
+ });
2164
+ const $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
2165
+ $ZodType.init(inst, def);
2166
+ defineLazy(inst._zod, "values", () => def.in._zod.values);
2167
+ defineLazy(inst._zod, "optin", () => def.in._zod.optin);
2168
+ defineLazy(inst._zod, "optout", () => def.out._zod.optout);
2169
+ defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
2170
+ inst._zod.parse = (payload, ctx) => {
2171
+ if (ctx.direction === "backward") {
2172
+ const right = def.out._zod.run(payload, ctx);
2173
+ if (right instanceof Promise) return right.then((right) => handlePipeResult(right, def.in, ctx));
2174
+ return handlePipeResult(right, def.in, ctx);
2175
+ }
2176
+ const left = def.in._zod.run(payload, ctx);
2177
+ if (left instanceof Promise) return left.then((left) => handlePipeResult(left, def.out, ctx));
2178
+ return handlePipeResult(left, def.out, ctx);
2179
+ };
2180
+ });
2181
+ function handlePipeResult(left, next, ctx) {
2182
+ if (left.issues.length) {
2183
+ left.aborted = true;
2184
+ return left;
2185
+ }
2186
+ return next._zod.run({
2187
+ value: left.value,
2188
+ issues: left.issues,
2189
+ fallback: left.fallback
2190
+ }, ctx);
2191
+ }
2192
+ const $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
2193
+ $ZodType.init(inst, def);
2194
+ defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
2195
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2196
+ defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
2197
+ defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
2198
+ inst._zod.parse = (payload, ctx) => {
2199
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2200
+ const result = def.innerType._zod.run(payload, ctx);
2201
+ if (result instanceof Promise) return result.then(handleReadonlyResult);
2202
+ return handleReadonlyResult(result);
2203
+ };
2204
+ });
2205
+ function handleReadonlyResult(payload) {
2206
+ payload.value = Object.freeze(payload.value);
2207
+ return payload;
2208
+ }
2209
+ const $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
2210
+ $ZodCheck.init(inst, def);
2211
+ $ZodType.init(inst, def);
2212
+ inst._zod.parse = (payload, _) => {
2213
+ return payload;
2214
+ };
2215
+ inst._zod.check = (payload) => {
2216
+ const input = payload.value;
2217
+ const r = def.fn(input);
2218
+ if (r instanceof Promise) return r.then((r) => handleRefineResult(r, payload, input, inst));
2219
+ handleRefineResult(r, payload, input, inst);
2220
+ };
2221
+ });
2222
+ function handleRefineResult(result, payload, input, inst) {
2223
+ if (!result) {
2224
+ const _iss = {
2225
+ code: "custom",
2226
+ input,
2227
+ inst,
2228
+ path: [...inst._zod.def.path ?? []],
2229
+ continue: !inst._zod.def.abort
2230
+ };
2231
+ if (inst._zod.def.params) _iss.params = inst._zod.def.params;
2232
+ payload.issues.push(issue(_iss));
2233
+ }
2234
+ }
2235
+ //#endregion
2236
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/registries.js
2237
+ var _a;
2238
+ var $ZodRegistry = class {
2239
+ constructor() {
2240
+ this._map = /* @__PURE__ */ new WeakMap();
2241
+ this._idmap = /* @__PURE__ */ new Map();
2242
+ }
2243
+ add(schema, ..._meta) {
2244
+ const meta = _meta[0];
2245
+ this._map.set(schema, meta);
2246
+ if (meta && typeof meta === "object" && "id" in meta) this._idmap.set(meta.id, schema);
2247
+ return this;
2248
+ }
2249
+ clear() {
2250
+ this._map = /* @__PURE__ */ new WeakMap();
2251
+ this._idmap = /* @__PURE__ */ new Map();
2252
+ return this;
2253
+ }
2254
+ remove(schema) {
2255
+ const meta = this._map.get(schema);
2256
+ if (meta && typeof meta === "object" && "id" in meta) this._idmap.delete(meta.id);
2257
+ this._map.delete(schema);
2258
+ return this;
2259
+ }
2260
+ get(schema) {
2261
+ const p = schema._zod.parent;
2262
+ if (p) {
2263
+ const pm = { ...this.get(p) ?? {} };
2264
+ delete pm.id;
2265
+ const f = {
2266
+ ...pm,
2267
+ ...this._map.get(schema)
2268
+ };
2269
+ return Object.keys(f).length ? f : void 0;
2270
+ }
2271
+ return this._map.get(schema);
2272
+ }
2273
+ has(schema) {
2274
+ return this._map.has(schema);
2275
+ }
2276
+ };
2277
+ function registry() {
2278
+ return new $ZodRegistry();
2279
+ }
2280
+ (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
2281
+ const globalRegistry = globalThis.__zod_globalRegistry;
2282
+ //#endregion
2283
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/api.js
2284
+ /* @__NO_SIDE_EFFECTS__ */
2285
+ function _string(Class, params) {
2286
+ return new Class({
2287
+ type: "string",
2288
+ ...normalizeParams(params)
2289
+ });
2290
+ }
2291
+ /* @__NO_SIDE_EFFECTS__ */
2292
+ function _email(Class, params) {
2293
+ return new Class({
2294
+ type: "string",
2295
+ format: "email",
2296
+ check: "string_format",
2297
+ abort: false,
2298
+ ...normalizeParams(params)
2299
+ });
2300
+ }
2301
+ /* @__NO_SIDE_EFFECTS__ */
2302
+ function _guid(Class, params) {
2303
+ return new Class({
2304
+ type: "string",
2305
+ format: "guid",
2306
+ check: "string_format",
2307
+ abort: false,
2308
+ ...normalizeParams(params)
2309
+ });
2310
+ }
2311
+ /* @__NO_SIDE_EFFECTS__ */
2312
+ function _uuid(Class, params) {
2313
+ return new Class({
2314
+ type: "string",
2315
+ format: "uuid",
2316
+ check: "string_format",
2317
+ abort: false,
2318
+ ...normalizeParams(params)
2319
+ });
2320
+ }
2321
+ /* @__NO_SIDE_EFFECTS__ */
2322
+ function _uuidv4(Class, params) {
2323
+ return new Class({
2324
+ type: "string",
2325
+ format: "uuid",
2326
+ check: "string_format",
2327
+ abort: false,
2328
+ version: "v4",
2329
+ ...normalizeParams(params)
2330
+ });
2331
+ }
2332
+ /* @__NO_SIDE_EFFECTS__ */
2333
+ function _uuidv6(Class, params) {
2334
+ return new Class({
2335
+ type: "string",
2336
+ format: "uuid",
2337
+ check: "string_format",
2338
+ abort: false,
2339
+ version: "v6",
2340
+ ...normalizeParams(params)
2341
+ });
2342
+ }
2343
+ /* @__NO_SIDE_EFFECTS__ */
2344
+ function _uuidv7(Class, params) {
2345
+ return new Class({
2346
+ type: "string",
2347
+ format: "uuid",
2348
+ check: "string_format",
2349
+ abort: false,
2350
+ version: "v7",
2351
+ ...normalizeParams(params)
2352
+ });
2353
+ }
2354
+ /* @__NO_SIDE_EFFECTS__ */
2355
+ function _url(Class, params) {
2356
+ return new Class({
2357
+ type: "string",
2358
+ format: "url",
2359
+ check: "string_format",
2360
+ abort: false,
2361
+ ...normalizeParams(params)
2362
+ });
2363
+ }
2364
+ /* @__NO_SIDE_EFFECTS__ */
2365
+ function _emoji(Class, params) {
2366
+ return new Class({
2367
+ type: "string",
2368
+ format: "emoji",
2369
+ check: "string_format",
2370
+ abort: false,
2371
+ ...normalizeParams(params)
2372
+ });
2373
+ }
2374
+ /* @__NO_SIDE_EFFECTS__ */
2375
+ function _nanoid(Class, params) {
2376
+ return new Class({
2377
+ type: "string",
2378
+ format: "nanoid",
2379
+ check: "string_format",
2380
+ abort: false,
2381
+ ...normalizeParams(params)
2382
+ });
2383
+ }
2384
+ /**
2385
+ * @deprecated CUID v1 is deprecated by its authors due to information leakage
2386
+ * (timestamps embedded in the id). Use {@link _cuid2} instead.
2387
+ * See https://github.com/paralleldrive/cuid.
2388
+ */
2389
+ /* @__NO_SIDE_EFFECTS__ */
2390
+ function _cuid(Class, params) {
2391
+ return new Class({
2392
+ type: "string",
2393
+ format: "cuid",
2394
+ check: "string_format",
2395
+ abort: false,
2396
+ ...normalizeParams(params)
2397
+ });
2398
+ }
2399
+ /* @__NO_SIDE_EFFECTS__ */
2400
+ function _cuid2(Class, params) {
2401
+ return new Class({
2402
+ type: "string",
2403
+ format: "cuid2",
2404
+ check: "string_format",
2405
+ abort: false,
2406
+ ...normalizeParams(params)
2407
+ });
2408
+ }
2409
+ /* @__NO_SIDE_EFFECTS__ */
2410
+ function _ulid(Class, params) {
2411
+ return new Class({
2412
+ type: "string",
2413
+ format: "ulid",
2414
+ check: "string_format",
2415
+ abort: false,
2416
+ ...normalizeParams(params)
2417
+ });
2418
+ }
2419
+ /* @__NO_SIDE_EFFECTS__ */
2420
+ function _xid(Class, params) {
2421
+ return new Class({
2422
+ type: "string",
2423
+ format: "xid",
2424
+ check: "string_format",
2425
+ abort: false,
2426
+ ...normalizeParams(params)
2427
+ });
2428
+ }
2429
+ /* @__NO_SIDE_EFFECTS__ */
2430
+ function _ksuid(Class, params) {
2431
+ return new Class({
2432
+ type: "string",
2433
+ format: "ksuid",
2434
+ check: "string_format",
2435
+ abort: false,
2436
+ ...normalizeParams(params)
2437
+ });
2438
+ }
2439
+ /* @__NO_SIDE_EFFECTS__ */
2440
+ function _ipv4(Class, params) {
2441
+ return new Class({
2442
+ type: "string",
2443
+ format: "ipv4",
2444
+ check: "string_format",
2445
+ abort: false,
2446
+ ...normalizeParams(params)
2447
+ });
2448
+ }
2449
+ /* @__NO_SIDE_EFFECTS__ */
2450
+ function _ipv6(Class, params) {
2451
+ return new Class({
2452
+ type: "string",
2453
+ format: "ipv6",
2454
+ check: "string_format",
2455
+ abort: false,
2456
+ ...normalizeParams(params)
2457
+ });
2458
+ }
2459
+ /* @__NO_SIDE_EFFECTS__ */
2460
+ function _cidrv4(Class, params) {
2461
+ return new Class({
2462
+ type: "string",
2463
+ format: "cidrv4",
2464
+ check: "string_format",
2465
+ abort: false,
2466
+ ...normalizeParams(params)
2467
+ });
2468
+ }
2469
+ /* @__NO_SIDE_EFFECTS__ */
2470
+ function _cidrv6(Class, params) {
2471
+ return new Class({
2472
+ type: "string",
2473
+ format: "cidrv6",
2474
+ check: "string_format",
2475
+ abort: false,
2476
+ ...normalizeParams(params)
2477
+ });
2478
+ }
2479
+ /* @__NO_SIDE_EFFECTS__ */
2480
+ function _base64(Class, params) {
2481
+ return new Class({
2482
+ type: "string",
2483
+ format: "base64",
2484
+ check: "string_format",
2485
+ abort: false,
2486
+ ...normalizeParams(params)
2487
+ });
2488
+ }
2489
+ /* @__NO_SIDE_EFFECTS__ */
2490
+ function _base64url(Class, params) {
2491
+ return new Class({
2492
+ type: "string",
2493
+ format: "base64url",
2494
+ check: "string_format",
2495
+ abort: false,
2496
+ ...normalizeParams(params)
2497
+ });
2498
+ }
2499
+ /* @__NO_SIDE_EFFECTS__ */
2500
+ function _e164(Class, params) {
2501
+ return new Class({
2502
+ type: "string",
2503
+ format: "e164",
2504
+ check: "string_format",
2505
+ abort: false,
2506
+ ...normalizeParams(params)
2507
+ });
2508
+ }
2509
+ /* @__NO_SIDE_EFFECTS__ */
2510
+ function _jwt(Class, params) {
2511
+ return new Class({
2512
+ type: "string",
2513
+ format: "jwt",
2514
+ check: "string_format",
2515
+ abort: false,
2516
+ ...normalizeParams(params)
2517
+ });
2518
+ }
2519
+ /* @__NO_SIDE_EFFECTS__ */
2520
+ function _isoDateTime(Class, params) {
2521
+ return new Class({
2522
+ type: "string",
2523
+ format: "datetime",
2524
+ check: "string_format",
2525
+ offset: false,
2526
+ local: false,
2527
+ precision: null,
2528
+ ...normalizeParams(params)
2529
+ });
2530
+ }
2531
+ /* @__NO_SIDE_EFFECTS__ */
2532
+ function _isoDate(Class, params) {
2533
+ return new Class({
2534
+ type: "string",
2535
+ format: "date",
2536
+ check: "string_format",
2537
+ ...normalizeParams(params)
2538
+ });
2539
+ }
2540
+ /* @__NO_SIDE_EFFECTS__ */
2541
+ function _isoTime(Class, params) {
2542
+ return new Class({
2543
+ type: "string",
2544
+ format: "time",
2545
+ check: "string_format",
2546
+ precision: null,
2547
+ ...normalizeParams(params)
2548
+ });
2549
+ }
2550
+ /* @__NO_SIDE_EFFECTS__ */
2551
+ function _isoDuration(Class, params) {
2552
+ return new Class({
2553
+ type: "string",
2554
+ format: "duration",
2555
+ check: "string_format",
2556
+ ...normalizeParams(params)
2557
+ });
2558
+ }
2559
+ /* @__NO_SIDE_EFFECTS__ */
2560
+ function _number(Class, params) {
2561
+ return new Class({
2562
+ type: "number",
2563
+ checks: [],
2564
+ ...normalizeParams(params)
2565
+ });
2566
+ }
2567
+ /* @__NO_SIDE_EFFECTS__ */
2568
+ function _int(Class, params) {
2569
+ return new Class({
2570
+ type: "number",
2571
+ check: "number_format",
2572
+ abort: false,
2573
+ format: "safeint",
2574
+ ...normalizeParams(params)
2575
+ });
2576
+ }
2577
+ /* @__NO_SIDE_EFFECTS__ */
2578
+ function _boolean(Class, params) {
2579
+ return new Class({
2580
+ type: "boolean",
2581
+ ...normalizeParams(params)
2582
+ });
2583
+ }
2584
+ /* @__NO_SIDE_EFFECTS__ */
2585
+ function _unknown(Class) {
2586
+ return new Class({ type: "unknown" });
2587
+ }
2588
+ /* @__NO_SIDE_EFFECTS__ */
2589
+ function _never(Class, params) {
2590
+ return new Class({
2591
+ type: "never",
2592
+ ...normalizeParams(params)
2593
+ });
2594
+ }
2595
+ /* @__NO_SIDE_EFFECTS__ */
2596
+ function _lt(value, params) {
2597
+ return new $ZodCheckLessThan({
2598
+ check: "less_than",
2599
+ ...normalizeParams(params),
2600
+ value,
2601
+ inclusive: false
2602
+ });
2603
+ }
2604
+ /* @__NO_SIDE_EFFECTS__ */
2605
+ function _lte(value, params) {
2606
+ return new $ZodCheckLessThan({
2607
+ check: "less_than",
2608
+ ...normalizeParams(params),
2609
+ value,
2610
+ inclusive: true
2611
+ });
2612
+ }
2613
+ /* @__NO_SIDE_EFFECTS__ */
2614
+ function _gt(value, params) {
2615
+ return new $ZodCheckGreaterThan({
2616
+ check: "greater_than",
2617
+ ...normalizeParams(params),
2618
+ value,
2619
+ inclusive: false
2620
+ });
2621
+ }
2622
+ /* @__NO_SIDE_EFFECTS__ */
2623
+ function _gte(value, params) {
2624
+ return new $ZodCheckGreaterThan({
2625
+ check: "greater_than",
2626
+ ...normalizeParams(params),
2627
+ value,
2628
+ inclusive: true
2629
+ });
2630
+ }
2631
+ /* @__NO_SIDE_EFFECTS__ */
2632
+ function _multipleOf(value, params) {
2633
+ return new $ZodCheckMultipleOf({
2634
+ check: "multiple_of",
2635
+ ...normalizeParams(params),
2636
+ value
2637
+ });
2638
+ }
2639
+ /* @__NO_SIDE_EFFECTS__ */
2640
+ function _maxLength(maximum, params) {
2641
+ return new $ZodCheckMaxLength({
2642
+ check: "max_length",
2643
+ ...normalizeParams(params),
2644
+ maximum
2645
+ });
2646
+ }
2647
+ /* @__NO_SIDE_EFFECTS__ */
2648
+ function _minLength(minimum, params) {
2649
+ return new $ZodCheckMinLength({
2650
+ check: "min_length",
2651
+ ...normalizeParams(params),
2652
+ minimum
2653
+ });
2654
+ }
2655
+ /* @__NO_SIDE_EFFECTS__ */
2656
+ function _length(length, params) {
2657
+ return new $ZodCheckLengthEquals({
2658
+ check: "length_equals",
2659
+ ...normalizeParams(params),
2660
+ length
2661
+ });
2662
+ }
2663
+ /* @__NO_SIDE_EFFECTS__ */
2664
+ function _regex(pattern, params) {
2665
+ return new $ZodCheckRegex({
2666
+ check: "string_format",
2667
+ format: "regex",
2668
+ ...normalizeParams(params),
2669
+ pattern
2670
+ });
2671
+ }
2672
+ /* @__NO_SIDE_EFFECTS__ */
2673
+ function _lowercase(params) {
2674
+ return new $ZodCheckLowerCase({
2675
+ check: "string_format",
2676
+ format: "lowercase",
2677
+ ...normalizeParams(params)
2678
+ });
2679
+ }
2680
+ /* @__NO_SIDE_EFFECTS__ */
2681
+ function _uppercase(params) {
2682
+ return new $ZodCheckUpperCase({
2683
+ check: "string_format",
2684
+ format: "uppercase",
2685
+ ...normalizeParams(params)
2686
+ });
2687
+ }
2688
+ /* @__NO_SIDE_EFFECTS__ */
2689
+ function _includes(includes, params) {
2690
+ return new $ZodCheckIncludes({
2691
+ check: "string_format",
2692
+ format: "includes",
2693
+ ...normalizeParams(params),
2694
+ includes
2695
+ });
2696
+ }
2697
+ /* @__NO_SIDE_EFFECTS__ */
2698
+ function _startsWith(prefix, params) {
2699
+ return new $ZodCheckStartsWith({
2700
+ check: "string_format",
2701
+ format: "starts_with",
2702
+ ...normalizeParams(params),
2703
+ prefix
2704
+ });
2705
+ }
2706
+ /* @__NO_SIDE_EFFECTS__ */
2707
+ function _endsWith(suffix, params) {
2708
+ return new $ZodCheckEndsWith({
2709
+ check: "string_format",
2710
+ format: "ends_with",
2711
+ ...normalizeParams(params),
2712
+ suffix
2713
+ });
2714
+ }
2715
+ /* @__NO_SIDE_EFFECTS__ */
2716
+ function _overwrite(tx) {
2717
+ return new $ZodCheckOverwrite({
2718
+ check: "overwrite",
2719
+ tx
2720
+ });
2721
+ }
2722
+ /* @__NO_SIDE_EFFECTS__ */
2723
+ function _normalize(form) {
2724
+ return /* @__PURE__ */ _overwrite((input) => input.normalize(form));
2725
+ }
2726
+ /* @__NO_SIDE_EFFECTS__ */
2727
+ function _trim() {
2728
+ return /* @__PURE__ */ _overwrite((input) => input.trim());
2729
+ }
2730
+ /* @__NO_SIDE_EFFECTS__ */
2731
+ function _toLowerCase() {
2732
+ return /* @__PURE__ */ _overwrite((input) => input.toLowerCase());
2733
+ }
2734
+ /* @__NO_SIDE_EFFECTS__ */
2735
+ function _toUpperCase() {
2736
+ return /* @__PURE__ */ _overwrite((input) => input.toUpperCase());
2737
+ }
2738
+ /* @__NO_SIDE_EFFECTS__ */
2739
+ function _slugify() {
2740
+ return /* @__PURE__ */ _overwrite((input) => slugify(input));
2741
+ }
2742
+ /* @__NO_SIDE_EFFECTS__ */
2743
+ function _array(Class, element, params) {
2744
+ return new Class({
2745
+ type: "array",
2746
+ element,
2747
+ ...normalizeParams(params)
2748
+ });
2749
+ }
2750
+ /* @__NO_SIDE_EFFECTS__ */
2751
+ function _refine(Class, fn, _params) {
2752
+ return new Class({
2753
+ type: "custom",
2754
+ check: "custom",
2755
+ fn,
2756
+ ...normalizeParams(_params)
2757
+ });
2758
+ }
2759
+ /* @__NO_SIDE_EFFECTS__ */
2760
+ function _superRefine(fn, params) {
2761
+ const ch = /* @__PURE__ */ _check((payload) => {
2762
+ payload.addIssue = (issue$2) => {
2763
+ if (typeof issue$2 === "string") payload.issues.push(issue(issue$2, payload.value, ch._zod.def));
2764
+ else {
2765
+ const _issue = issue$2;
2766
+ if (_issue.fatal) _issue.continue = false;
2767
+ _issue.code ?? (_issue.code = "custom");
2768
+ _issue.input ?? (_issue.input = payload.value);
2769
+ _issue.inst ?? (_issue.inst = ch);
2770
+ _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
2771
+ payload.issues.push(issue(_issue));
2772
+ }
2773
+ };
2774
+ return fn(payload.value, payload);
2775
+ }, params);
2776
+ return ch;
2777
+ }
2778
+ /* @__NO_SIDE_EFFECTS__ */
2779
+ function _check(fn, params) {
2780
+ const ch = new $ZodCheck({
2781
+ check: "custom",
2782
+ ...normalizeParams(params)
2783
+ });
2784
+ ch._zod.check = fn;
2785
+ return ch;
2786
+ }
2787
+ //#endregion
2788
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/to-json-schema.js
2789
+ function initializeContext(params) {
2790
+ let target = params?.target ?? "draft-2020-12";
2791
+ if (target === "draft-4") target = "draft-04";
2792
+ if (target === "draft-7") target = "draft-07";
2793
+ return {
2794
+ processors: params.processors ?? {},
2795
+ metadataRegistry: params?.metadata ?? globalRegistry,
2796
+ target,
2797
+ unrepresentable: params?.unrepresentable ?? "throw",
2798
+ override: params?.override ?? (() => {}),
2799
+ io: params?.io ?? "output",
2800
+ counter: 0,
2801
+ seen: /* @__PURE__ */ new Map(),
2802
+ cycles: params?.cycles ?? "ref",
2803
+ reused: params?.reused ?? "inline",
2804
+ external: params?.external ?? void 0
2805
+ };
2806
+ }
2807
+ function process(schema, ctx, _params = {
2808
+ path: [],
2809
+ schemaPath: []
2810
+ }) {
2811
+ var _a;
2812
+ const def = schema._zod.def;
2813
+ const seen = ctx.seen.get(schema);
2814
+ if (seen) {
2815
+ seen.count++;
2816
+ if (_params.schemaPath.includes(schema)) seen.cycle = _params.path;
2817
+ return seen.schema;
2818
+ }
2819
+ const result = {
2820
+ schema: {},
2821
+ count: 1,
2822
+ cycle: void 0,
2823
+ path: _params.path
2824
+ };
2825
+ ctx.seen.set(schema, result);
2826
+ const overrideSchema = schema._zod.toJSONSchema?.();
2827
+ if (overrideSchema) result.schema = overrideSchema;
2828
+ else {
2829
+ const params = {
2830
+ ..._params,
2831
+ schemaPath: [..._params.schemaPath, schema],
2832
+ path: _params.path
2833
+ };
2834
+ if (schema._zod.processJSONSchema) schema._zod.processJSONSchema(ctx, result.schema, params);
2835
+ else {
2836
+ const _json = result.schema;
2837
+ const processor = ctx.processors[def.type];
2838
+ if (!processor) throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
2839
+ processor(schema, ctx, _json, params);
2840
+ }
2841
+ const parent = schema._zod.parent;
2842
+ if (parent) {
2843
+ if (!result.ref) result.ref = parent;
2844
+ process(parent, ctx, params);
2845
+ ctx.seen.get(parent).isParent = true;
2846
+ }
2847
+ }
2848
+ const meta = ctx.metadataRegistry.get(schema);
2849
+ if (meta) Object.assign(result.schema, meta);
2850
+ if (ctx.io === "input" && isTransforming(schema)) {
2851
+ delete result.schema.examples;
2852
+ delete result.schema.default;
2853
+ }
2854
+ if (ctx.io === "input" && "_prefault" in result.schema) (_a = result.schema).default ?? (_a.default = result.schema._prefault);
2855
+ delete result.schema._prefault;
2856
+ return ctx.seen.get(schema).schema;
2857
+ }
2858
+ function extractDefs(ctx, schema) {
2859
+ const root = ctx.seen.get(schema);
2860
+ if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
2861
+ const idToSchema = /* @__PURE__ */ new Map();
2862
+ for (const entry of ctx.seen.entries()) {
2863
+ const id = ctx.metadataRegistry.get(entry[0])?.id;
2864
+ if (id) {
2865
+ const existing = idToSchema.get(id);
2866
+ if (existing && existing !== entry[0]) throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
2867
+ idToSchema.set(id, entry[0]);
2868
+ }
2869
+ }
2870
+ const makeURI = (entry) => {
2871
+ const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
2872
+ if (ctx.external) {
2873
+ const externalId = ctx.external.registry.get(entry[0])?.id;
2874
+ const uriGenerator = ctx.external.uri ?? ((id) => id);
2875
+ if (externalId) return { ref: uriGenerator(externalId) };
2876
+ const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
2877
+ entry[1].defId = id;
2878
+ return {
2879
+ defId: id,
2880
+ ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
2881
+ };
2882
+ }
2883
+ if (entry[1] === root) return { ref: "#" };
2884
+ const defUriPrefix = `#/${defsSegment}/`;
2885
+ const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
2886
+ return {
2887
+ defId,
2888
+ ref: defUriPrefix + defId
2889
+ };
2890
+ };
2891
+ const extractToDef = (entry) => {
2892
+ if (entry[1].schema.$ref) return;
2893
+ const seen = entry[1];
2894
+ const { ref, defId } = makeURI(entry);
2895
+ seen.def = { ...seen.schema };
2896
+ if (defId) seen.defId = defId;
2897
+ const schema = seen.schema;
2898
+ for (const key in schema) delete schema[key];
2899
+ schema.$ref = ref;
2900
+ };
2901
+ if (ctx.cycles === "throw") for (const entry of ctx.seen.entries()) {
2902
+ const seen = entry[1];
2903
+ if (seen.cycle) throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
2904
+
2905
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
2906
+ }
2907
+ for (const entry of ctx.seen.entries()) {
2908
+ const seen = entry[1];
2909
+ if (schema === entry[0]) {
2910
+ extractToDef(entry);
2911
+ continue;
2912
+ }
2913
+ if (ctx.external) {
2914
+ const ext = ctx.external.registry.get(entry[0])?.id;
2915
+ if (schema !== entry[0] && ext) {
2916
+ extractToDef(entry);
2917
+ continue;
2918
+ }
2919
+ }
2920
+ if (ctx.metadataRegistry.get(entry[0])?.id) {
2921
+ extractToDef(entry);
2922
+ continue;
2923
+ }
2924
+ if (seen.cycle) {
2925
+ extractToDef(entry);
2926
+ continue;
2927
+ }
2928
+ if (seen.count > 1) {
2929
+ if (ctx.reused === "ref") {
2930
+ extractToDef(entry);
2931
+ continue;
2932
+ }
2933
+ }
2934
+ }
2935
+ }
2936
+ function finalize(ctx, schema) {
2937
+ const root = ctx.seen.get(schema);
2938
+ if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
2939
+ const flattenRef = (zodSchema) => {
2940
+ const seen = ctx.seen.get(zodSchema);
2941
+ if (seen.ref === null) return;
2942
+ const schema = seen.def ?? seen.schema;
2943
+ const _cached = { ...schema };
2944
+ const ref = seen.ref;
2945
+ seen.ref = null;
2946
+ if (ref) {
2947
+ flattenRef(ref);
2948
+ const refSeen = ctx.seen.get(ref);
2949
+ const refSchema = refSeen.schema;
2950
+ if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
2951
+ schema.allOf = schema.allOf ?? [];
2952
+ schema.allOf.push(refSchema);
2953
+ } else Object.assign(schema, refSchema);
2954
+ Object.assign(schema, _cached);
2955
+ if (zodSchema._zod.parent === ref) for (const key in schema) {
2956
+ if (key === "$ref" || key === "allOf") continue;
2957
+ if (!(key in _cached)) delete schema[key];
2958
+ }
2959
+ if (refSchema.$ref && refSeen.def) for (const key in schema) {
2960
+ if (key === "$ref" || key === "allOf") continue;
2961
+ if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) delete schema[key];
2962
+ }
2963
+ }
2964
+ const parent = zodSchema._zod.parent;
2965
+ if (parent && parent !== ref) {
2966
+ flattenRef(parent);
2967
+ const parentSeen = ctx.seen.get(parent);
2968
+ if (parentSeen?.schema.$ref) {
2969
+ schema.$ref = parentSeen.schema.$ref;
2970
+ if (parentSeen.def) for (const key in schema) {
2971
+ if (key === "$ref" || key === "allOf") continue;
2972
+ if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) delete schema[key];
2973
+ }
2974
+ }
2975
+ }
2976
+ ctx.override({
2977
+ zodSchema,
2978
+ jsonSchema: schema,
2979
+ path: seen.path ?? []
2980
+ });
2981
+ };
2982
+ for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
2983
+ const result = {};
2984
+ if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
2985
+ else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
2986
+ else if (ctx.target === "draft-04") result.$schema = "http://json-schema.org/draft-04/schema#";
2987
+ else if (ctx.target === "openapi-3.0") {}
2988
+ if (ctx.external?.uri) {
2989
+ const id = ctx.external.registry.get(schema)?.id;
2990
+ if (!id) throw new Error("Schema is missing an `id` property");
2991
+ result.$id = ctx.external.uri(id);
2992
+ }
2993
+ Object.assign(result, root.def ?? root.schema);
2994
+ const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
2995
+ if (rootMetaId !== void 0 && result.id === rootMetaId) delete result.id;
2996
+ const defs = ctx.external?.defs ?? {};
2997
+ for (const entry of ctx.seen.entries()) {
2998
+ const seen = entry[1];
2999
+ if (seen.def && seen.defId) {
3000
+ if (seen.def.id === seen.defId) delete seen.def.id;
3001
+ defs[seen.defId] = seen.def;
3002
+ }
3003
+ }
3004
+ if (ctx.external) {} else if (Object.keys(defs).length > 0) if (ctx.target === "draft-2020-12") result.$defs = defs;
3005
+ else result.definitions = defs;
3006
+ try {
3007
+ const finalized = JSON.parse(JSON.stringify(result));
3008
+ Object.defineProperty(finalized, "~standard", {
3009
+ value: {
3010
+ ...schema["~standard"],
3011
+ jsonSchema: {
3012
+ input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
3013
+ output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
3014
+ }
3015
+ },
3016
+ enumerable: false,
3017
+ writable: false
3018
+ });
3019
+ return finalized;
3020
+ } catch (_err) {
3021
+ throw new Error("Error converting schema to JSON.");
3022
+ }
3023
+ }
3024
+ function isTransforming(_schema, _ctx) {
3025
+ const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
3026
+ if (ctx.seen.has(_schema)) return false;
3027
+ ctx.seen.add(_schema);
3028
+ const def = _schema._zod.def;
3029
+ if (def.type === "transform") return true;
3030
+ if (def.type === "array") return isTransforming(def.element, ctx);
3031
+ if (def.type === "set") return isTransforming(def.valueType, ctx);
3032
+ if (def.type === "lazy") return isTransforming(def.getter(), ctx);
3033
+ if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") return isTransforming(def.innerType, ctx);
3034
+ if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
3035
+ if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
3036
+ if (def.type === "pipe") {
3037
+ if (_schema._zod.traits.has("$ZodCodec")) return true;
3038
+ return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
3039
+ }
3040
+ if (def.type === "object") {
3041
+ for (const key in def.shape) if (isTransforming(def.shape[key], ctx)) return true;
3042
+ return false;
3043
+ }
3044
+ if (def.type === "union") {
3045
+ for (const option of def.options) if (isTransforming(option, ctx)) return true;
3046
+ return false;
3047
+ }
3048
+ if (def.type === "tuple") {
3049
+ for (const item of def.items) if (isTransforming(item, ctx)) return true;
3050
+ if (def.rest && isTransforming(def.rest, ctx)) return true;
3051
+ return false;
3052
+ }
3053
+ return false;
3054
+ }
3055
+ /**
3056
+ * Creates a toJSONSchema method for a schema instance.
3057
+ * This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
3058
+ */
3059
+ const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
3060
+ const ctx = initializeContext({
3061
+ ...params,
3062
+ processors
3063
+ });
3064
+ process(schema, ctx);
3065
+ extractDefs(ctx, schema);
3066
+ return finalize(ctx, schema);
3067
+ };
3068
+ const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
3069
+ const { libraryOptions, target } = params ?? {};
3070
+ const ctx = initializeContext({
3071
+ ...libraryOptions ?? {},
3072
+ target,
3073
+ io,
3074
+ processors
3075
+ });
3076
+ process(schema, ctx);
3077
+ extractDefs(ctx, schema);
3078
+ return finalize(ctx, schema);
3079
+ };
3080
+ //#endregion
3081
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/json-schema-processors.js
3082
+ const formatMap = {
3083
+ guid: "uuid",
3084
+ url: "uri",
3085
+ datetime: "date-time",
3086
+ json_string: "json-string",
3087
+ regex: ""
3088
+ };
3089
+ const stringProcessor = (schema, ctx, _json, _params) => {
3090
+ const json = _json;
3091
+ json.type = "string";
3092
+ const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
3093
+ if (typeof minimum === "number") json.minLength = minimum;
3094
+ if (typeof maximum === "number") json.maxLength = maximum;
3095
+ if (format) {
3096
+ json.format = formatMap[format] ?? format;
3097
+ if (json.format === "") delete json.format;
3098
+ if (format === "time") delete json.format;
3099
+ }
3100
+ if (contentEncoding) json.contentEncoding = contentEncoding;
3101
+ if (patterns && patterns.size > 0) {
3102
+ const regexes = [...patterns];
3103
+ if (regexes.length === 1) json.pattern = regexes[0].source;
3104
+ else if (regexes.length > 1) json.allOf = [...regexes.map((regex) => ({
3105
+ ...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
3106
+ pattern: regex.source
3107
+ }))];
3108
+ }
3109
+ };
3110
+ const numberProcessor = (schema, ctx, _json, _params) => {
3111
+ const json = _json;
3112
+ const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
3113
+ if (typeof format === "string" && format.includes("int")) json.type = "integer";
3114
+ else json.type = "number";
3115
+ const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
3116
+ const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
3117
+ const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
3118
+ if (exMin) if (legacy) {
3119
+ json.minimum = exclusiveMinimum;
3120
+ json.exclusiveMinimum = true;
3121
+ } else json.exclusiveMinimum = exclusiveMinimum;
3122
+ else if (typeof minimum === "number") json.minimum = minimum;
3123
+ if (exMax) if (legacy) {
3124
+ json.maximum = exclusiveMaximum;
3125
+ json.exclusiveMaximum = true;
3126
+ } else json.exclusiveMaximum = exclusiveMaximum;
3127
+ else if (typeof maximum === "number") json.maximum = maximum;
3128
+ if (typeof multipleOf === "number") json.multipleOf = multipleOf;
3129
+ };
3130
+ const booleanProcessor = (_schema, _ctx, json, _params) => {
3131
+ json.type = "boolean";
3132
+ };
3133
+ const neverProcessor = (_schema, _ctx, json, _params) => {
3134
+ json.not = {};
3135
+ };
3136
+ const unknownProcessor = (_schema, _ctx, _json, _params) => {};
3137
+ const enumProcessor = (schema, _ctx, json, _params) => {
3138
+ const def = schema._zod.def;
3139
+ const values = getEnumValues(def.entries);
3140
+ if (values.every((v) => typeof v === "number")) json.type = "number";
3141
+ if (values.every((v) => typeof v === "string")) json.type = "string";
3142
+ json.enum = values;
3143
+ };
3144
+ const literalProcessor = (schema, ctx, json, _params) => {
3145
+ const def = schema._zod.def;
3146
+ const vals = [];
3147
+ for (const val of def.values) if (val === void 0) {
3148
+ if (ctx.unrepresentable === "throw") throw new Error("Literal `undefined` cannot be represented in JSON Schema");
3149
+ } else if (typeof val === "bigint") if (ctx.unrepresentable === "throw") throw new Error("BigInt literals cannot be represented in JSON Schema");
3150
+ else vals.push(Number(val));
3151
+ else vals.push(val);
3152
+ if (vals.length === 0) {} else if (vals.length === 1) {
3153
+ const val = vals[0];
3154
+ json.type = val === null ? "null" : typeof val;
3155
+ if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") json.enum = [val];
3156
+ else json.const = val;
3157
+ } else {
3158
+ if (vals.every((v) => typeof v === "number")) json.type = "number";
3159
+ if (vals.every((v) => typeof v === "string")) json.type = "string";
3160
+ if (vals.every((v) => typeof v === "boolean")) json.type = "boolean";
3161
+ if (vals.every((v) => v === null)) json.type = "null";
3162
+ json.enum = vals;
3163
+ }
3164
+ };
3165
+ const customProcessor = (_schema, ctx, _json, _params) => {
3166
+ if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
3167
+ };
3168
+ const transformProcessor = (_schema, ctx, _json, _params) => {
3169
+ if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
3170
+ };
3171
+ const arrayProcessor = (schema, ctx, _json, params) => {
3172
+ const json = _json;
3173
+ const def = schema._zod.def;
3174
+ const { minimum, maximum } = schema._zod.bag;
3175
+ if (typeof minimum === "number") json.minItems = minimum;
3176
+ if (typeof maximum === "number") json.maxItems = maximum;
3177
+ json.type = "array";
3178
+ json.items = process(def.element, ctx, {
3179
+ ...params,
3180
+ path: [...params.path, "items"]
3181
+ });
3182
+ };
3183
+ const objectProcessor = (schema, ctx, _json, params) => {
3184
+ const json = _json;
3185
+ const def = schema._zod.def;
3186
+ json.type = "object";
3187
+ json.properties = {};
3188
+ const shape = def.shape;
3189
+ for (const key in shape) json.properties[key] = process(shape[key], ctx, {
3190
+ ...params,
3191
+ path: [
3192
+ ...params.path,
3193
+ "properties",
3194
+ key
3195
+ ]
3196
+ });
3197
+ const allKeys = new Set(Object.keys(shape));
3198
+ const requiredKeys = new Set([...allKeys].filter((key) => {
3199
+ const v = def.shape[key]._zod;
3200
+ if (ctx.io === "input") return v.optin === void 0;
3201
+ else return v.optout === void 0;
3202
+ }));
3203
+ if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
3204
+ if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
3205
+ else if (!def.catchall) {
3206
+ if (ctx.io === "output") json.additionalProperties = false;
3207
+ } else if (def.catchall) json.additionalProperties = process(def.catchall, ctx, {
3208
+ ...params,
3209
+ path: [...params.path, "additionalProperties"]
3210
+ });
3211
+ };
3212
+ const unionProcessor = (schema, ctx, json, params) => {
3213
+ const def = schema._zod.def;
3214
+ const isExclusive = def.inclusive === false;
3215
+ const options = def.options.map((x, i) => process(x, ctx, {
3216
+ ...params,
3217
+ path: [
3218
+ ...params.path,
3219
+ isExclusive ? "oneOf" : "anyOf",
3220
+ i
3221
+ ]
3222
+ }));
3223
+ if (isExclusive) json.oneOf = options;
3224
+ else json.anyOf = options;
3225
+ };
3226
+ const intersectionProcessor = (schema, ctx, json, params) => {
3227
+ const def = schema._zod.def;
3228
+ const a = process(def.left, ctx, {
3229
+ ...params,
3230
+ path: [
3231
+ ...params.path,
3232
+ "allOf",
3233
+ 0
3234
+ ]
3235
+ });
3236
+ const b = process(def.right, ctx, {
3237
+ ...params,
3238
+ path: [
3239
+ ...params.path,
3240
+ "allOf",
3241
+ 1
3242
+ ]
3243
+ });
3244
+ const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
3245
+ json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
3246
+ };
3247
+ const recordProcessor = (schema, ctx, _json, params) => {
3248
+ const json = _json;
3249
+ const def = schema._zod.def;
3250
+ json.type = "object";
3251
+ const keyType = def.keyType;
3252
+ const patterns = keyType._zod.bag?.patterns;
3253
+ if (def.mode === "loose" && patterns && patterns.size > 0) {
3254
+ const valueSchema = process(def.valueType, ctx, {
3255
+ ...params,
3256
+ path: [
3257
+ ...params.path,
3258
+ "patternProperties",
3259
+ "*"
3260
+ ]
3261
+ });
3262
+ json.patternProperties = {};
3263
+ for (const pattern of patterns) json.patternProperties[pattern.source] = valueSchema;
3264
+ } else {
3265
+ if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") json.propertyNames = process(def.keyType, ctx, {
3266
+ ...params,
3267
+ path: [...params.path, "propertyNames"]
3268
+ });
3269
+ json.additionalProperties = process(def.valueType, ctx, {
3270
+ ...params,
3271
+ path: [...params.path, "additionalProperties"]
3272
+ });
3273
+ }
3274
+ const keyValues = keyType._zod.values;
3275
+ if (keyValues) {
3276
+ const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
3277
+ if (validKeyValues.length > 0) json.required = validKeyValues;
3278
+ }
3279
+ };
3280
+ const nullableProcessor = (schema, ctx, json, params) => {
3281
+ const def = schema._zod.def;
3282
+ const inner = process(def.innerType, ctx, params);
3283
+ const seen = ctx.seen.get(schema);
3284
+ if (ctx.target === "openapi-3.0") {
3285
+ seen.ref = def.innerType;
3286
+ json.nullable = true;
3287
+ } else json.anyOf = [inner, { type: "null" }];
3288
+ };
3289
+ const nonoptionalProcessor = (schema, ctx, _json, params) => {
3290
+ const def = schema._zod.def;
3291
+ process(def.innerType, ctx, params);
3292
+ const seen = ctx.seen.get(schema);
3293
+ seen.ref = def.innerType;
3294
+ };
3295
+ const defaultProcessor = (schema, ctx, json, params) => {
3296
+ const def = schema._zod.def;
3297
+ process(def.innerType, ctx, params);
3298
+ const seen = ctx.seen.get(schema);
3299
+ seen.ref = def.innerType;
3300
+ json.default = JSON.parse(JSON.stringify(def.defaultValue));
3301
+ };
3302
+ const prefaultProcessor = (schema, ctx, json, params) => {
3303
+ const def = schema._zod.def;
3304
+ process(def.innerType, ctx, params);
3305
+ const seen = ctx.seen.get(schema);
3306
+ seen.ref = def.innerType;
3307
+ if (ctx.io === "input") json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
3308
+ };
3309
+ const catchProcessor = (schema, ctx, json, params) => {
3310
+ const def = schema._zod.def;
3311
+ process(def.innerType, ctx, params);
3312
+ const seen = ctx.seen.get(schema);
3313
+ seen.ref = def.innerType;
3314
+ let catchValue;
3315
+ try {
3316
+ catchValue = def.catchValue(void 0);
3317
+ } catch {
3318
+ throw new Error("Dynamic catch values are not supported in JSON Schema");
3319
+ }
3320
+ json.default = catchValue;
3321
+ };
3322
+ const pipeProcessor = (schema, ctx, _json, params) => {
3323
+ const def = schema._zod.def;
3324
+ const inIsTransform = def.in._zod.traits.has("$ZodTransform");
3325
+ const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
3326
+ process(innerType, ctx, params);
3327
+ const seen = ctx.seen.get(schema);
3328
+ seen.ref = innerType;
3329
+ };
3330
+ const readonlyProcessor = (schema, ctx, json, params) => {
3331
+ const def = schema._zod.def;
3332
+ process(def.innerType, ctx, params);
3333
+ const seen = ctx.seen.get(schema);
3334
+ seen.ref = def.innerType;
3335
+ json.readOnly = true;
3336
+ };
3337
+ const optionalProcessor = (schema, ctx, _json, params) => {
3338
+ const def = schema._zod.def;
3339
+ process(def.innerType, ctx, params);
3340
+ const seen = ctx.seen.get(schema);
3341
+ seen.ref = def.innerType;
3342
+ };
3343
+ //#endregion
3344
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/iso.js
3345
+ const ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
3346
+ $ZodISODateTime.init(inst, def);
3347
+ ZodStringFormat.init(inst, def);
3348
+ });
3349
+ function datetime(params) {
3350
+ return /* @__PURE__ */ _isoDateTime(ZodISODateTime, params);
3351
+ }
3352
+ const ZodISODate = /* @__PURE__ */ $constructor("ZodISODate", (inst, def) => {
3353
+ $ZodISODate.init(inst, def);
3354
+ ZodStringFormat.init(inst, def);
3355
+ });
3356
+ function date(params) {
3357
+ return /* @__PURE__ */ _isoDate(ZodISODate, params);
3358
+ }
3359
+ const ZodISOTime = /* @__PURE__ */ $constructor("ZodISOTime", (inst, def) => {
3360
+ $ZodISOTime.init(inst, def);
3361
+ ZodStringFormat.init(inst, def);
3362
+ });
3363
+ function time(params) {
3364
+ return /* @__PURE__ */ _isoTime(ZodISOTime, params);
3365
+ }
3366
+ const ZodISODuration = /* @__PURE__ */ $constructor("ZodISODuration", (inst, def) => {
3367
+ $ZodISODuration.init(inst, def);
3368
+ ZodStringFormat.init(inst, def);
3369
+ });
3370
+ function duration(params) {
3371
+ return /* @__PURE__ */ _isoDuration(ZodISODuration, params);
3372
+ }
3373
+ //#endregion
3374
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/errors.js
3375
+ const initializer = (inst, issues) => {
3376
+ $ZodError.init(inst, issues);
3377
+ inst.name = "ZodError";
3378
+ Object.defineProperties(inst, {
3379
+ format: { value: (mapper) => formatError(inst, mapper) },
3380
+ flatten: { value: (mapper) => flattenError(inst, mapper) },
3381
+ addIssue: { value: (issue) => {
3382
+ inst.issues.push(issue);
3383
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3384
+ } },
3385
+ addIssues: { value: (issues) => {
3386
+ inst.issues.push(...issues);
3387
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3388
+ } },
3389
+ isEmpty: { get() {
3390
+ return inst.issues.length === 0;
3391
+ } }
3392
+ });
3393
+ };
3394
+ const ZodRealError = /* @__PURE__ */ $constructor("ZodError", initializer, { Parent: Error });
3395
+ //#endregion
3396
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/parse.js
3397
+ const parse = /* @__PURE__ */ _parse(ZodRealError);
3398
+ const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
3399
+ const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
3400
+ const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
3401
+ const encode = /* @__PURE__ */ _encode(ZodRealError);
3402
+ const decode = /* @__PURE__ */ _decode(ZodRealError);
3403
+ const encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
3404
+ const decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
3405
+ const safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
3406
+ const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
3407
+ const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
3408
+ const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
3409
+ //#endregion
3410
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/schemas.js
3411
+ const _installedGroups = /* @__PURE__ */ new WeakMap();
3412
+ function _installLazyMethods(inst, group, methods) {
3413
+ const proto = Object.getPrototypeOf(inst);
3414
+ let installed = _installedGroups.get(proto);
3415
+ if (!installed) {
3416
+ installed = /* @__PURE__ */ new Set();
3417
+ _installedGroups.set(proto, installed);
3418
+ }
3419
+ if (installed.has(group)) return;
3420
+ installed.add(group);
3421
+ for (const key in methods) {
3422
+ const fn = methods[key];
3423
+ Object.defineProperty(proto, key, {
3424
+ configurable: true,
3425
+ enumerable: false,
3426
+ get() {
3427
+ const bound = fn.bind(this);
3428
+ Object.defineProperty(this, key, {
3429
+ configurable: true,
3430
+ writable: true,
3431
+ enumerable: true,
3432
+ value: bound
3433
+ });
3434
+ return bound;
3435
+ },
3436
+ set(v) {
3437
+ Object.defineProperty(this, key, {
3438
+ configurable: true,
3439
+ writable: true,
3440
+ enumerable: true,
3441
+ value: v
3442
+ });
3443
+ }
3444
+ });
3445
+ }
3446
+ }
3447
+ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
3448
+ $ZodType.init(inst, def);
3449
+ Object.assign(inst["~standard"], { jsonSchema: {
3450
+ input: createStandardJSONSchemaMethod(inst, "input"),
3451
+ output: createStandardJSONSchemaMethod(inst, "output")
3452
+ } });
3453
+ inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
3454
+ inst.def = def;
3455
+ inst.type = def.type;
3456
+ Object.defineProperty(inst, "_def", { value: def });
3457
+ inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
3458
+ inst.safeParse = (data, params) => safeParse(inst, data, params);
3459
+ inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
3460
+ inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
3461
+ inst.spa = inst.safeParseAsync;
3462
+ inst.encode = (data, params) => encode(inst, data, params);
3463
+ inst.decode = (data, params) => decode(inst, data, params);
3464
+ inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
3465
+ inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
3466
+ inst.safeEncode = (data, params) => safeEncode(inst, data, params);
3467
+ inst.safeDecode = (data, params) => safeDecode(inst, data, params);
3468
+ inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
3469
+ inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
3470
+ _installLazyMethods(inst, "ZodType", {
3471
+ check(...chks) {
3472
+ const def = this.def;
3473
+ return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
3474
+ check: ch,
3475
+ def: { check: "custom" },
3476
+ onattach: []
3477
+ } } : ch)] }), { parent: true });
3478
+ },
3479
+ with(...chks) {
3480
+ return this.check(...chks);
3481
+ },
3482
+ clone(def, params) {
3483
+ return clone(this, def, params);
3484
+ },
3485
+ brand() {
3486
+ return this;
3487
+ },
3488
+ register(reg, meta) {
3489
+ reg.add(this, meta);
3490
+ return this;
3491
+ },
3492
+ refine(check, params) {
3493
+ return this.check(refine(check, params));
3494
+ },
3495
+ superRefine(refinement, params) {
3496
+ return this.check(superRefine(refinement, params));
3497
+ },
3498
+ overwrite(fn) {
3499
+ return this.check(/* @__PURE__ */ _overwrite(fn));
3500
+ },
3501
+ optional() {
3502
+ return optional(this);
3503
+ },
3504
+ exactOptional() {
3505
+ return exactOptional(this);
3506
+ },
3507
+ nullable() {
3508
+ return nullable(this);
3509
+ },
3510
+ nullish() {
3511
+ return optional(nullable(this));
3512
+ },
3513
+ nonoptional(params) {
3514
+ return nonoptional(this, params);
3515
+ },
3516
+ array() {
3517
+ return array(this);
3518
+ },
3519
+ or(arg) {
3520
+ return union([this, arg]);
3521
+ },
3522
+ and(arg) {
3523
+ return intersection(this, arg);
3524
+ },
3525
+ transform(tx) {
3526
+ return pipe(this, transform(tx));
3527
+ },
3528
+ default(d) {
3529
+ return _default(this, d);
3530
+ },
3531
+ prefault(d) {
3532
+ return prefault(this, d);
3533
+ },
3534
+ catch(params) {
3535
+ return _catch(this, params);
3536
+ },
3537
+ pipe(target) {
3538
+ return pipe(this, target);
3539
+ },
3540
+ readonly() {
3541
+ return readonly(this);
3542
+ },
3543
+ describe(description) {
3544
+ const cl = this.clone();
3545
+ globalRegistry.add(cl, { description });
3546
+ return cl;
3547
+ },
3548
+ meta(...args) {
3549
+ if (args.length === 0) return globalRegistry.get(this);
3550
+ const cl = this.clone();
3551
+ globalRegistry.add(cl, args[0]);
3552
+ return cl;
3553
+ },
3554
+ isOptional() {
3555
+ return this.safeParse(void 0).success;
3556
+ },
3557
+ isNullable() {
3558
+ return this.safeParse(null).success;
3559
+ },
3560
+ apply(fn) {
3561
+ return fn(this);
3562
+ }
3563
+ });
3564
+ Object.defineProperty(inst, "description", {
3565
+ get() {
3566
+ return globalRegistry.get(inst)?.description;
3567
+ },
3568
+ configurable: true
3569
+ });
3570
+ return inst;
3571
+ });
3572
+ /** @internal */
3573
+ const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
3574
+ $ZodString.init(inst, def);
3575
+ ZodType.init(inst, def);
3576
+ inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
3577
+ const bag = inst._zod.bag;
3578
+ inst.format = bag.format ?? null;
3579
+ inst.minLength = bag.minimum ?? null;
3580
+ inst.maxLength = bag.maximum ?? null;
3581
+ _installLazyMethods(inst, "_ZodString", {
3582
+ regex(...args) {
3583
+ return this.check(/* @__PURE__ */ _regex(...args));
3584
+ },
3585
+ includes(...args) {
3586
+ return this.check(/* @__PURE__ */ _includes(...args));
3587
+ },
3588
+ startsWith(...args) {
3589
+ return this.check(/* @__PURE__ */ _startsWith(...args));
3590
+ },
3591
+ endsWith(...args) {
3592
+ return this.check(/* @__PURE__ */ _endsWith(...args));
3593
+ },
3594
+ min(...args) {
3595
+ return this.check(/* @__PURE__ */ _minLength(...args));
3596
+ },
3597
+ max(...args) {
3598
+ return this.check(/* @__PURE__ */ _maxLength(...args));
3599
+ },
3600
+ length(...args) {
3601
+ return this.check(/* @__PURE__ */ _length(...args));
3602
+ },
3603
+ nonempty(...args) {
3604
+ return this.check(/* @__PURE__ */ _minLength(1, ...args));
3605
+ },
3606
+ lowercase(params) {
3607
+ return this.check(/* @__PURE__ */ _lowercase(params));
3608
+ },
3609
+ uppercase(params) {
3610
+ return this.check(/* @__PURE__ */ _uppercase(params));
3611
+ },
3612
+ trim() {
3613
+ return this.check(/* @__PURE__ */ _trim());
3614
+ },
3615
+ normalize(...args) {
3616
+ return this.check(/* @__PURE__ */ _normalize(...args));
3617
+ },
3618
+ toLowerCase() {
3619
+ return this.check(/* @__PURE__ */ _toLowerCase());
3620
+ },
3621
+ toUpperCase() {
3622
+ return this.check(/* @__PURE__ */ _toUpperCase());
3623
+ },
3624
+ slugify() {
3625
+ return this.check(/* @__PURE__ */ _slugify());
3626
+ }
3627
+ });
3628
+ });
3629
+ const ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
3630
+ $ZodString.init(inst, def);
3631
+ _ZodString.init(inst, def);
3632
+ inst.email = (params) => inst.check(/* @__PURE__ */ _email(ZodEmail, params));
3633
+ inst.url = (params) => inst.check(/* @__PURE__ */ _url(ZodURL, params));
3634
+ inst.jwt = (params) => inst.check(/* @__PURE__ */ _jwt(ZodJWT, params));
3635
+ inst.emoji = (params) => inst.check(/* @__PURE__ */ _emoji(ZodEmoji, params));
3636
+ inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
3637
+ inst.uuid = (params) => inst.check(/* @__PURE__ */ _uuid(ZodUUID, params));
3638
+ inst.uuidv4 = (params) => inst.check(/* @__PURE__ */ _uuidv4(ZodUUID, params));
3639
+ inst.uuidv6 = (params) => inst.check(/* @__PURE__ */ _uuidv6(ZodUUID, params));
3640
+ inst.uuidv7 = (params) => inst.check(/* @__PURE__ */ _uuidv7(ZodUUID, params));
3641
+ inst.nanoid = (params) => inst.check(/* @__PURE__ */ _nanoid(ZodNanoID, params));
3642
+ inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
3643
+ inst.cuid = (params) => inst.check(/* @__PURE__ */ _cuid(ZodCUID, params));
3644
+ inst.cuid2 = (params) => inst.check(/* @__PURE__ */ _cuid2(ZodCUID2, params));
3645
+ inst.ulid = (params) => inst.check(/* @__PURE__ */ _ulid(ZodULID, params));
3646
+ inst.base64 = (params) => inst.check(/* @__PURE__ */ _base64(ZodBase64, params));
3647
+ inst.base64url = (params) => inst.check(/* @__PURE__ */ _base64url(ZodBase64URL, params));
3648
+ inst.xid = (params) => inst.check(/* @__PURE__ */ _xid(ZodXID, params));
3649
+ inst.ksuid = (params) => inst.check(/* @__PURE__ */ _ksuid(ZodKSUID, params));
3650
+ inst.ipv4 = (params) => inst.check(/* @__PURE__ */ _ipv4(ZodIPv4, params));
3651
+ inst.ipv6 = (params) => inst.check(/* @__PURE__ */ _ipv6(ZodIPv6, params));
3652
+ inst.cidrv4 = (params) => inst.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, params));
3653
+ inst.cidrv6 = (params) => inst.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, params));
3654
+ inst.e164 = (params) => inst.check(/* @__PURE__ */ _e164(ZodE164, params));
3655
+ inst.datetime = (params) => inst.check(datetime(params));
3656
+ inst.date = (params) => inst.check(date(params));
3657
+ inst.time = (params) => inst.check(time(params));
3658
+ inst.duration = (params) => inst.check(duration(params));
3659
+ });
3660
+ function string(params) {
3661
+ return /* @__PURE__ */ _string(ZodString, params);
3662
+ }
3663
+ const ZodStringFormat = /* @__PURE__ */ $constructor("ZodStringFormat", (inst, def) => {
3664
+ $ZodStringFormat.init(inst, def);
3665
+ _ZodString.init(inst, def);
3666
+ });
3667
+ const ZodEmail = /* @__PURE__ */ $constructor("ZodEmail", (inst, def) => {
3668
+ $ZodEmail.init(inst, def);
3669
+ ZodStringFormat.init(inst, def);
3670
+ });
3671
+ const ZodGUID = /* @__PURE__ */ $constructor("ZodGUID", (inst, def) => {
3672
+ $ZodGUID.init(inst, def);
3673
+ ZodStringFormat.init(inst, def);
3674
+ });
3675
+ const ZodUUID = /* @__PURE__ */ $constructor("ZodUUID", (inst, def) => {
3676
+ $ZodUUID.init(inst, def);
3677
+ ZodStringFormat.init(inst, def);
3678
+ });
3679
+ const ZodURL = /* @__PURE__ */ $constructor("ZodURL", (inst, def) => {
3680
+ $ZodURL.init(inst, def);
3681
+ ZodStringFormat.init(inst, def);
3682
+ });
3683
+ const ZodEmoji = /* @__PURE__ */ $constructor("ZodEmoji", (inst, def) => {
3684
+ $ZodEmoji.init(inst, def);
3685
+ ZodStringFormat.init(inst, def);
3686
+ });
3687
+ const ZodNanoID = /* @__PURE__ */ $constructor("ZodNanoID", (inst, def) => {
3688
+ $ZodNanoID.init(inst, def);
3689
+ ZodStringFormat.init(inst, def);
3690
+ });
3691
+ /**
3692
+ * @deprecated CUID v1 is deprecated by its authors due to information leakage
3693
+ * (timestamps embedded in the id). Use {@link ZodCUID2} instead.
3694
+ * See https://github.com/paralleldrive/cuid.
3695
+ */
3696
+ const ZodCUID = /* @__PURE__ */ $constructor("ZodCUID", (inst, def) => {
3697
+ $ZodCUID.init(inst, def);
3698
+ ZodStringFormat.init(inst, def);
3699
+ });
3700
+ const ZodCUID2 = /* @__PURE__ */ $constructor("ZodCUID2", (inst, def) => {
3701
+ $ZodCUID2.init(inst, def);
3702
+ ZodStringFormat.init(inst, def);
3703
+ });
3704
+ const ZodULID = /* @__PURE__ */ $constructor("ZodULID", (inst, def) => {
3705
+ $ZodULID.init(inst, def);
3706
+ ZodStringFormat.init(inst, def);
3707
+ });
3708
+ const ZodXID = /* @__PURE__ */ $constructor("ZodXID", (inst, def) => {
3709
+ $ZodXID.init(inst, def);
3710
+ ZodStringFormat.init(inst, def);
3711
+ });
3712
+ const ZodKSUID = /* @__PURE__ */ $constructor("ZodKSUID", (inst, def) => {
3713
+ $ZodKSUID.init(inst, def);
3714
+ ZodStringFormat.init(inst, def);
3715
+ });
3716
+ const ZodIPv4 = /* @__PURE__ */ $constructor("ZodIPv4", (inst, def) => {
3717
+ $ZodIPv4.init(inst, def);
3718
+ ZodStringFormat.init(inst, def);
3719
+ });
3720
+ const ZodIPv6 = /* @__PURE__ */ $constructor("ZodIPv6", (inst, def) => {
3721
+ $ZodIPv6.init(inst, def);
3722
+ ZodStringFormat.init(inst, def);
3723
+ });
3724
+ const ZodCIDRv4 = /* @__PURE__ */ $constructor("ZodCIDRv4", (inst, def) => {
3725
+ $ZodCIDRv4.init(inst, def);
3726
+ ZodStringFormat.init(inst, def);
3727
+ });
3728
+ const ZodCIDRv6 = /* @__PURE__ */ $constructor("ZodCIDRv6", (inst, def) => {
3729
+ $ZodCIDRv6.init(inst, def);
3730
+ ZodStringFormat.init(inst, def);
3731
+ });
3732
+ const ZodBase64 = /* @__PURE__ */ $constructor("ZodBase64", (inst, def) => {
3733
+ $ZodBase64.init(inst, def);
3734
+ ZodStringFormat.init(inst, def);
3735
+ });
3736
+ const ZodBase64URL = /* @__PURE__ */ $constructor("ZodBase64URL", (inst, def) => {
3737
+ $ZodBase64URL.init(inst, def);
3738
+ ZodStringFormat.init(inst, def);
3739
+ });
3740
+ const ZodE164 = /* @__PURE__ */ $constructor("ZodE164", (inst, def) => {
3741
+ $ZodE164.init(inst, def);
3742
+ ZodStringFormat.init(inst, def);
3743
+ });
3744
+ const ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
3745
+ $ZodJWT.init(inst, def);
3746
+ ZodStringFormat.init(inst, def);
3747
+ });
3748
+ const ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
3749
+ $ZodNumber.init(inst, def);
3750
+ ZodType.init(inst, def);
3751
+ inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
3752
+ _installLazyMethods(inst, "ZodNumber", {
3753
+ gt(value, params) {
3754
+ return this.check(/* @__PURE__ */ _gt(value, params));
3755
+ },
3756
+ gte(value, params) {
3757
+ return this.check(/* @__PURE__ */ _gte(value, params));
3758
+ },
3759
+ min(value, params) {
3760
+ return this.check(/* @__PURE__ */ _gte(value, params));
3761
+ },
3762
+ lt(value, params) {
3763
+ return this.check(/* @__PURE__ */ _lt(value, params));
3764
+ },
3765
+ lte(value, params) {
3766
+ return this.check(/* @__PURE__ */ _lte(value, params));
3767
+ },
3768
+ max(value, params) {
3769
+ return this.check(/* @__PURE__ */ _lte(value, params));
3770
+ },
3771
+ int(params) {
3772
+ return this.check(int(params));
3773
+ },
3774
+ safe(params) {
3775
+ return this.check(int(params));
3776
+ },
3777
+ positive(params) {
3778
+ return this.check(/* @__PURE__ */ _gt(0, params));
3779
+ },
3780
+ nonnegative(params) {
3781
+ return this.check(/* @__PURE__ */ _gte(0, params));
3782
+ },
3783
+ negative(params) {
3784
+ return this.check(/* @__PURE__ */ _lt(0, params));
3785
+ },
3786
+ nonpositive(params) {
3787
+ return this.check(/* @__PURE__ */ _lte(0, params));
3788
+ },
3789
+ multipleOf(value, params) {
3790
+ return this.check(/* @__PURE__ */ _multipleOf(value, params));
3791
+ },
3792
+ step(value, params) {
3793
+ return this.check(/* @__PURE__ */ _multipleOf(value, params));
3794
+ },
3795
+ finite() {
3796
+ return this;
3797
+ }
3798
+ });
3799
+ const bag = inst._zod.bag;
3800
+ inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
3801
+ inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
3802
+ inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? .5);
3803
+ inst.isFinite = true;
3804
+ inst.format = bag.format ?? null;
3805
+ });
3806
+ function number(params) {
3807
+ return /* @__PURE__ */ _number(ZodNumber, params);
3808
+ }
3809
+ const ZodNumberFormat = /* @__PURE__ */ $constructor("ZodNumberFormat", (inst, def) => {
3810
+ $ZodNumberFormat.init(inst, def);
3811
+ ZodNumber.init(inst, def);
3812
+ });
3813
+ function int(params) {
3814
+ return /* @__PURE__ */ _int(ZodNumberFormat, params);
3815
+ }
3816
+ const ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
3817
+ $ZodBoolean.init(inst, def);
3818
+ ZodType.init(inst, def);
3819
+ inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json, params);
3820
+ });
3821
+ function boolean(params) {
3822
+ return /* @__PURE__ */ _boolean(ZodBoolean, params);
3823
+ }
3824
+ const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
3825
+ $ZodUnknown.init(inst, def);
3826
+ ZodType.init(inst, def);
3827
+ inst._zod.processJSONSchema = (ctx, json, params) => unknownProcessor(inst, ctx, json, params);
3828
+ });
3829
+ function unknown() {
3830
+ return /* @__PURE__ */ _unknown(ZodUnknown);
3831
+ }
3832
+ const ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
3833
+ $ZodNever.init(inst, def);
3834
+ ZodType.init(inst, def);
3835
+ inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json, params);
3836
+ });
3837
+ function never(params) {
3838
+ return /* @__PURE__ */ _never(ZodNever, params);
3839
+ }
3840
+ const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
3841
+ $ZodArray.init(inst, def);
3842
+ ZodType.init(inst, def);
3843
+ inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
3844
+ inst.element = def.element;
3845
+ _installLazyMethods(inst, "ZodArray", {
3846
+ min(n, params) {
3847
+ return this.check(/* @__PURE__ */ _minLength(n, params));
3848
+ },
3849
+ nonempty(params) {
3850
+ return this.check(/* @__PURE__ */ _minLength(1, params));
3851
+ },
3852
+ max(n, params) {
3853
+ return this.check(/* @__PURE__ */ _maxLength(n, params));
3854
+ },
3855
+ length(n, params) {
3856
+ return this.check(/* @__PURE__ */ _length(n, params));
3857
+ },
3858
+ unwrap() {
3859
+ return this.element;
3860
+ }
3861
+ });
3862
+ });
3863
+ function array(element, params) {
3864
+ return /* @__PURE__ */ _array(ZodArray, element, params);
3865
+ }
3866
+ const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
3867
+ $ZodObjectJIT.init(inst, def);
3868
+ ZodType.init(inst, def);
3869
+ inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
3870
+ defineLazy(inst, "shape", () => {
3871
+ return def.shape;
3872
+ });
3873
+ _installLazyMethods(inst, "ZodObject", {
3874
+ keyof() {
3875
+ return _enum(Object.keys(this._zod.def.shape));
3876
+ },
3877
+ catchall(catchall) {
3878
+ return this.clone({
3879
+ ...this._zod.def,
3880
+ catchall
3881
+ });
3882
+ },
3883
+ passthrough() {
3884
+ return this.clone({
3885
+ ...this._zod.def,
3886
+ catchall: unknown()
3887
+ });
3888
+ },
3889
+ loose() {
3890
+ return this.clone({
3891
+ ...this._zod.def,
3892
+ catchall: unknown()
3893
+ });
3894
+ },
3895
+ strict() {
3896
+ return this.clone({
3897
+ ...this._zod.def,
3898
+ catchall: never()
3899
+ });
3900
+ },
3901
+ strip() {
3902
+ return this.clone({
3903
+ ...this._zod.def,
3904
+ catchall: void 0
3905
+ });
3906
+ },
3907
+ extend(incoming) {
3908
+ return extend(this, incoming);
3909
+ },
3910
+ safeExtend(incoming) {
3911
+ return safeExtend(this, incoming);
3912
+ },
3913
+ merge(other) {
3914
+ return merge(this, other);
3915
+ },
3916
+ pick(mask) {
3917
+ return pick(this, mask);
3918
+ },
3919
+ omit(mask) {
3920
+ return omit(this, mask);
3921
+ },
3922
+ partial(...args) {
3923
+ return partial(ZodOptional, this, args[0]);
3924
+ },
3925
+ required(...args) {
3926
+ return required(ZodNonOptional, this, args[0]);
3927
+ }
3928
+ });
3929
+ });
3930
+ function strictObject(shape, params) {
3931
+ return new ZodObject({
3932
+ type: "object",
3933
+ shape,
3934
+ catchall: never(),
3935
+ ...normalizeParams(params)
3936
+ });
3937
+ }
3938
+ const ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
3939
+ $ZodUnion.init(inst, def);
3940
+ ZodType.init(inst, def);
3941
+ inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
3942
+ inst.options = def.options;
3943
+ });
3944
+ function union(options, params) {
3945
+ return new ZodUnion({
3946
+ type: "union",
3947
+ options,
3948
+ ...normalizeParams(params)
3949
+ });
3950
+ }
3951
+ const ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
3952
+ $ZodIntersection.init(inst, def);
3953
+ ZodType.init(inst, def);
3954
+ inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
3955
+ });
3956
+ function intersection(left, right) {
3957
+ return new ZodIntersection({
3958
+ type: "intersection",
3959
+ left,
3960
+ right
3961
+ });
3962
+ }
3963
+ const ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
3964
+ $ZodRecord.init(inst, def);
3965
+ ZodType.init(inst, def);
3966
+ inst._zod.processJSONSchema = (ctx, json, params) => recordProcessor(inst, ctx, json, params);
3967
+ inst.keyType = def.keyType;
3968
+ inst.valueType = def.valueType;
3969
+ });
3970
+ function record(keyType, valueType, params) {
3971
+ if (!valueType || !valueType._zod) return new ZodRecord({
3972
+ type: "record",
3973
+ keyType: string(),
3974
+ valueType: keyType,
3975
+ ...normalizeParams(valueType)
3976
+ });
3977
+ return new ZodRecord({
3978
+ type: "record",
3979
+ keyType,
3980
+ valueType,
3981
+ ...normalizeParams(params)
3982
+ });
3983
+ }
3984
+ const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
3985
+ $ZodEnum.init(inst, def);
3986
+ ZodType.init(inst, def);
3987
+ inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
3988
+ inst.enum = def.entries;
3989
+ inst.options = Object.values(def.entries);
3990
+ const keys = new Set(Object.keys(def.entries));
3991
+ inst.extract = (values, params) => {
3992
+ const newEntries = {};
3993
+ for (const value of values) if (keys.has(value)) newEntries[value] = def.entries[value];
3994
+ else throw new Error(`Key ${value} not found in enum`);
3995
+ return new ZodEnum({
3996
+ ...def,
3997
+ checks: [],
3998
+ ...normalizeParams(params),
3999
+ entries: newEntries
4000
+ });
4001
+ };
4002
+ inst.exclude = (values, params) => {
4003
+ const newEntries = { ...def.entries };
4004
+ for (const value of values) if (keys.has(value)) delete newEntries[value];
4005
+ else throw new Error(`Key ${value} not found in enum`);
4006
+ return new ZodEnum({
4007
+ ...def,
4008
+ checks: [],
4009
+ ...normalizeParams(params),
4010
+ entries: newEntries
4011
+ });
4012
+ };
4013
+ });
4014
+ function _enum(values, params) {
4015
+ return new ZodEnum({
4016
+ type: "enum",
4017
+ entries: Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values,
4018
+ ...normalizeParams(params)
4019
+ });
4020
+ }
4021
+ const ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
4022
+ $ZodLiteral.init(inst, def);
4023
+ ZodType.init(inst, def);
4024
+ inst._zod.processJSONSchema = (ctx, json, params) => literalProcessor(inst, ctx, json, params);
4025
+ inst.values = new Set(def.values);
4026
+ Object.defineProperty(inst, "value", { get() {
4027
+ if (def.values.length > 1) throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
4028
+ return def.values[0];
4029
+ } });
4030
+ });
4031
+ function literal(value, params) {
4032
+ return new ZodLiteral({
4033
+ type: "literal",
4034
+ values: Array.isArray(value) ? value : [value],
4035
+ ...normalizeParams(params)
4036
+ });
4037
+ }
4038
+ const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
4039
+ $ZodTransform.init(inst, def);
4040
+ ZodType.init(inst, def);
4041
+ inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
4042
+ inst._zod.parse = (payload, _ctx) => {
4043
+ if (_ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
4044
+ payload.addIssue = (issue$1) => {
4045
+ if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, def));
4046
+ else {
4047
+ const _issue = issue$1;
4048
+ if (_issue.fatal) _issue.continue = false;
4049
+ _issue.code ?? (_issue.code = "custom");
4050
+ _issue.input ?? (_issue.input = payload.value);
4051
+ _issue.inst ?? (_issue.inst = inst);
4052
+ payload.issues.push(issue(_issue));
4053
+ }
4054
+ };
4055
+ const output = def.transform(payload.value, payload);
4056
+ if (output instanceof Promise) return output.then((output) => {
4057
+ payload.value = output;
4058
+ payload.fallback = true;
4059
+ return payload;
4060
+ });
4061
+ payload.value = output;
4062
+ payload.fallback = true;
4063
+ return payload;
4064
+ };
4065
+ });
4066
+ function transform(fn) {
4067
+ return new ZodTransform({
4068
+ type: "transform",
4069
+ transform: fn
4070
+ });
4071
+ }
4072
+ const ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
4073
+ $ZodOptional.init(inst, def);
4074
+ ZodType.init(inst, def);
4075
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
4076
+ inst.unwrap = () => inst._zod.def.innerType;
4077
+ });
4078
+ function optional(innerType) {
4079
+ return new ZodOptional({
4080
+ type: "optional",
4081
+ innerType
4082
+ });
4083
+ }
4084
+ const ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
4085
+ $ZodExactOptional.init(inst, def);
4086
+ ZodType.init(inst, def);
4087
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
4088
+ inst.unwrap = () => inst._zod.def.innerType;
4089
+ });
4090
+ function exactOptional(innerType) {
4091
+ return new ZodExactOptional({
4092
+ type: "optional",
4093
+ innerType
4094
+ });
4095
+ }
4096
+ const ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
4097
+ $ZodNullable.init(inst, def);
4098
+ ZodType.init(inst, def);
4099
+ inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
4100
+ inst.unwrap = () => inst._zod.def.innerType;
4101
+ });
4102
+ function nullable(innerType) {
4103
+ return new ZodNullable({
4104
+ type: "nullable",
4105
+ innerType
4106
+ });
4107
+ }
4108
+ const ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
4109
+ $ZodDefault.init(inst, def);
4110
+ ZodType.init(inst, def);
4111
+ inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
4112
+ inst.unwrap = () => inst._zod.def.innerType;
4113
+ inst.removeDefault = inst.unwrap;
4114
+ });
4115
+ function _default(innerType, defaultValue) {
4116
+ return new ZodDefault({
4117
+ type: "default",
4118
+ innerType,
4119
+ get defaultValue() {
4120
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
4121
+ }
4122
+ });
4123
+ }
4124
+ const ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
4125
+ $ZodPrefault.init(inst, def);
4126
+ ZodType.init(inst, def);
4127
+ inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
4128
+ inst.unwrap = () => inst._zod.def.innerType;
4129
+ });
4130
+ function prefault(innerType, defaultValue) {
4131
+ return new ZodPrefault({
4132
+ type: "prefault",
4133
+ innerType,
4134
+ get defaultValue() {
4135
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
4136
+ }
4137
+ });
4138
+ }
4139
+ const ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
4140
+ $ZodNonOptional.init(inst, def);
4141
+ ZodType.init(inst, def);
4142
+ inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
4143
+ inst.unwrap = () => inst._zod.def.innerType;
4144
+ });
4145
+ function nonoptional(innerType, params) {
4146
+ return new ZodNonOptional({
4147
+ type: "nonoptional",
4148
+ innerType,
4149
+ ...normalizeParams(params)
4150
+ });
4151
+ }
4152
+ const ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
4153
+ $ZodCatch.init(inst, def);
4154
+ ZodType.init(inst, def);
4155
+ inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
4156
+ inst.unwrap = () => inst._zod.def.innerType;
4157
+ inst.removeCatch = inst.unwrap;
4158
+ });
4159
+ function _catch(innerType, catchValue) {
4160
+ return new ZodCatch({
4161
+ type: "catch",
4162
+ innerType,
4163
+ catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
4164
+ });
4165
+ }
4166
+ const ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
4167
+ $ZodPipe.init(inst, def);
4168
+ ZodType.init(inst, def);
4169
+ inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
4170
+ inst.in = def.in;
4171
+ inst.out = def.out;
4172
+ });
4173
+ function pipe(in_, out) {
4174
+ return new ZodPipe({
4175
+ type: "pipe",
4176
+ in: in_,
4177
+ out
4178
+ });
4179
+ }
4180
+ const ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
4181
+ $ZodReadonly.init(inst, def);
4182
+ ZodType.init(inst, def);
4183
+ inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
4184
+ inst.unwrap = () => inst._zod.def.innerType;
4185
+ });
4186
+ function readonly(innerType) {
4187
+ return new ZodReadonly({
4188
+ type: "readonly",
4189
+ innerType
4190
+ });
4191
+ }
4192
+ const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
4193
+ $ZodCustom.init(inst, def);
4194
+ ZodType.init(inst, def);
4195
+ inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
4196
+ });
4197
+ function refine(fn, _params = {}) {
4198
+ return /* @__PURE__ */ _refine(ZodCustom, fn, _params);
4199
+ }
4200
+ function superRefine(fn, params) {
4201
+ return /* @__PURE__ */ _superRefine(fn, params);
4202
+ }
4203
+ //#endregion
4204
+ //#region ../core/src/entity-config.ts
4205
+ /**
4206
+ * Entity Config v2 — the declarative contract that turns Clivly's "schema-aware"
4207
+ * promise into a real capability.
4208
+ *
4209
+ * A CRM entity is no longer a flat table name. It is a *derived entity*: a
4210
+ * filtered slice of a host table (`source` + `filter`), a column allowlist
4211
+ * (`fields` + `readOnly`), and declared `relationships` to other entities. The
4212
+ * same host table can back several entities (e.g. `users` → owners + members)
4213
+ * distinguished by `role`.
4214
+ *
4215
+ * This module is the Phase 1 slice: types, schema, `defineClivlyConfig` (a
4216
+ * structural helper) and `validateEntitiesConfig` (semantic validation against
4217
+ * the host's discovered schema). It performs NO DB access and generates no SQL —
4218
+ * the view compiler (Phase 2) and sync engine (Phase 3) consume this contract.
4219
+ */
4220
+ /** Canonical CRM concepts a host entity can map onto. */
4221
+ const CRM_CONCEPTS = [
4222
+ "contact",
4223
+ "company",
4224
+ "deal",
4225
+ "activity",
4226
+ "conversation",
4227
+ "note"
4228
+ ];
4229
+ /**
4230
+ * The canonical `fields` keys the mirror actually persists, per concept — the
4231
+ * crm_* columns the sync store writes. An entity's `fields` map keys must be one
4232
+ * of these: a non-canonical key (e.g. `fullName` instead of `name`) validates
4233
+ * structurally but has no destination column, so the store silently writes an
4234
+ * empty value. `validateEntitiesConfig` flags those.
4235
+ *
4236
+ * This is the single source of truth — the Drizzle store imports it, so the
4237
+ * two can't drift (the drift is what made the silent-data-loss trap possible).
4238
+ * Concepts absent here aren't materialized yet, so their field keys are
4239
+ * unconstrained.
4240
+ */
4241
+ const CANONICAL_FIELDS = {
4242
+ contact: [
4243
+ "name",
4244
+ "email",
4245
+ "title",
4246
+ "status"
4247
+ ],
4248
+ company: [
4249
+ "name",
4250
+ "domain",
4251
+ "industry",
4252
+ "size"
4253
+ ],
4254
+ deal: [
4255
+ "name",
4256
+ "value",
4257
+ "stage"
4258
+ ]
4259
+ };
4260
+ /**
4261
+ * The concepts the mapping→sync pipeline can actually materialize into `crm_*`
4262
+ * tables. These are exactly the CANONICAL_FIELDS keys — the Drizzle sync store's
4263
+ * `persist()` throws for any other concept, so offering one (in the mapping
4264
+ * editor, in suggestions, or via the upsert API) is a broken affordance.
4265
+ *
4266
+ * The broader CRM_CONCEPTS set still validates structurally, so previously
4267
+ * stored rows for not-yet-materialized concepts keep rendering. When a concept
4268
+ * gains a sync-store path, add its canonical fields above and it joins this set
4269
+ * automatically (guarded by the MATERIALIZING_CONCEPTS drift test).
4270
+ */
4271
+ const MATERIALIZING_CONCEPTS = [
4272
+ "contact",
4273
+ "company",
4274
+ "deal"
4275
+ ];
4276
+ /**
4277
+ * The org-defined custom-object target. Deliberately NOT a member of
4278
+ * CRM_CONCEPTS / CANONICAL_FIELDS / MATERIALIZING_CONCEPTS — a custom object has
4279
+ * no fixed canonical columns; its mapping's fieldMap keys ARE its properties.
4280
+ * Handled as an explicit branch wherever concepts are switched on, so the
4281
+ * canonical-concept invariants (and their drift test) stay intact.
4282
+ */
4283
+ const CUSTOM_CONCEPT = "custom";
4284
+ /**
4285
+ * Operator forms for a single column predicate. All predicates on an entity are
4286
+ * AND-ed together. `$raw` (see FilterExpr) is the escape hatch for anything the
4287
+ * operators can't express.
4288
+ */
4289
+ const filterOperatorsSchema = union([
4290
+ strictObject({ eq: union([
4291
+ string(),
4292
+ number(),
4293
+ boolean()
4294
+ ]) }),
4295
+ strictObject({ ne: union([
4296
+ string(),
4297
+ number(),
4298
+ boolean()
4299
+ ]) }),
4300
+ strictObject({ in: array(union([
4301
+ string(),
4302
+ number(),
4303
+ boolean()
4304
+ ])).min(1) }),
4305
+ strictObject({ notIn: array(union([
4306
+ string(),
4307
+ number(),
4308
+ boolean()
4309
+ ])).min(1) }),
4310
+ strictObject({ isNull: literal(true) }),
4311
+ strictObject({ isNotNull: literal(true) })
4312
+ ]);
4313
+ const filterValueSchema = union([
4314
+ string(),
4315
+ number(),
4316
+ boolean(),
4317
+ filterOperatorsSchema
4318
+ ]);
4319
+ /** `$raw` is a reserved key; a column literally named `$raw` is not addressable. */
4320
+ const filterSchema = union([strictObject({ $raw: string().min(1) }), record(string(), filterValueSchema)]);
4321
+ /**
4322
+ * How the link between two entities is expressed in the host schema:
4323
+ * - `fkOn: "company"` — FK lives on the company table (e.g. organizations.owner_id)
4324
+ * - `fkOn: "contact"` — FK lives on the contact table (e.g. users.organization_id)
4325
+ * - `through` — a join table sits between them (many-to-many, role often here)
4326
+ * - `$raw` — opaque SQL join fragment (escape hatch; not schema-validated)
4327
+ *
4328
+ * `column` and the join-table keys are `table.column` or bare `column` strings.
4329
+ */
4330
+ const relationshipViaSchema = union([
4331
+ strictObject({
4332
+ fkOn: _enum(["company", "contact"]),
4333
+ column: string().min(1)
4334
+ }),
4335
+ strictObject({
4336
+ through: string().min(1),
4337
+ localKey: string().min(1),
4338
+ foreignKey: string().min(1)
4339
+ }),
4340
+ strictObject({ $raw: string().min(1) })
4341
+ ]);
4342
+ const relationshipSchema = strictObject({
4343
+ /** Key of the related entity in the `entities` map. */
4344
+ entity: string().min(1),
4345
+ via: relationshipViaSchema
4346
+ });
4347
+ /** A named map of relationships, as stored on an entity / in the mappings row. */
4348
+ const relationshipsSchema = record(string(), relationshipSchema);
4349
+ const entitySchema = strictObject({
4350
+ /** Which CRM concept this entity maps onto — a canonical concept or "custom". */
4351
+ concept: union([_enum(CRM_CONCEPTS), literal(CUSTOM_CONCEPT)]),
4352
+ /** Host table (or view) this entity is derived from. */
4353
+ source: string().min(1),
4354
+ /**
4355
+ * Distinguishes multiple entities backed by the same table (e.g. "primary"
4356
+ * for owners, "secondary" for members). Free text; defaults to "primary".
4357
+ */
4358
+ role: string().min(1).optional(),
4359
+ /** Predicate that narrows `source` into this entity's rows. Omit = whole table. */
4360
+ filter: filterSchema.optional(),
4361
+ /** clivlyField → sourceColumn. At least one field is required. */
4362
+ fields: record(string(), string()).refine((f) => Object.keys(f).length > 0, { message: "at least one field must be mapped" }),
4363
+ /**
4364
+ * Host-owned identity fields. Sync overwrites them; the CRM UI cannot edit
4365
+ * them. Must be a subset of `fields` keys.
4366
+ */
4367
+ readOnly: array(string()).optional(),
4368
+ /** Named relationships to other entities in this config. */
4369
+ relationships: record(string(), relationshipSchema).optional(),
4370
+ /**
4371
+ * For a "custom" entity, the crm_object_types row this materializes into.
4372
+ * Required for custom (enforced at the API layer), unused for standard concepts.
4373
+ */
4374
+ targetObjectTypeId: string().min(1).optional()
4375
+ });
4376
+ const entitiesConfigSchema = strictObject({ entities: record(string(), entitySchema).refine((e) => Object.keys(e).length > 0, { message: "at least one entity must be defined" }) });
4377
+ /** Thrown by `defineClivlyConfig({ strict: true })` on non-canonical field keys. */
4378
+ var ClivlyConfigError = class extends Error {
4379
+ issues;
4380
+ constructor(issues) {
4381
+ super(`Clivly config has ${issues.length} non-canonical field mapping(s) that would write empty values at sync time:\n${issues.map((issue) => ` - ${issue.path}: ${issue.message}`).join("\n")}`);
4382
+ this.name = "ClivlyConfigError";
4383
+ this.issues = issues;
4384
+ }
4385
+ };
4386
+ function nonCanonicalFieldKeys(entity) {
4387
+ const canonical = CANONICAL_FIELDS[entity.concept];
4388
+ if (!canonical) return [];
4389
+ return Object.keys(entity.fields).filter((key) => !canonical.includes(key));
4390
+ }
4391
+ function nonCanonicalMessage(entity, field) {
4392
+ const canonical = CANONICAL_FIELDS[entity.concept] ?? [];
4393
+ return `"${field}" is not a canonical ${entity.concept} field (expected one of: ${canonical.join(", ")})`;
4394
+ }
4395
+ function canonicalFieldIssues(config) {
4396
+ const issues = [];
4397
+ for (const [key, entity] of Object.entries(config.entities)) for (const field of nonCanonicalFieldKeys(entity)) issues.push({
4398
+ path: `entities.${key}.fields.${field}`,
4399
+ message: nonCanonicalMessage(entity, field)
4400
+ });
4401
+ return issues;
4402
+ }
4403
+ function defaultWarn(message) {
4404
+ console.warn(message);
4405
+ }
4406
+ /**
4407
+ * Structural helper for `clivly.config.ts`. Gives full type inference on the
4408
+ * literal you pass and eagerly parses it, so shape errors surface at config
4409
+ * load rather than at sync time.
4410
+ *
4411
+ * It also catches the silent-data-loss footgun: a non-canonical field key for a
4412
+ * materialised concept (e.g. `fullName` instead of `name` on a `contact`) has no
4413
+ * destination column, so the store would write an empty value. By default these
4414
+ * are reported via `onWarn` (a `console.warn`); pass `{ strict: true }` to throw
4415
+ * a `ClivlyConfigError` instead. Does NOT validate against the host schema — that
4416
+ * needs the discovered schema; see `validateEntitiesConfig`.
4417
+ */
4418
+ function defineClivlyConfig(config, options) {
4419
+ const parsed = entitiesConfigSchema.parse(config);
4420
+ const issues = canonicalFieldIssues(parsed);
4421
+ if (issues.length > 0) {
4422
+ if (options?.strict) throw new ClivlyConfigError(issues);
4423
+ const warn = options?.onWarn ?? defaultWarn;
4424
+ for (const issue of issues) warn(`⚠ Clivly config: ${issue.message} (${issue.path}) — this field would write an empty value at sync time. Pass { strict: true } to make this throw.`);
4425
+ }
4426
+ return parsed;
4427
+ }
4428
+ /** Split a `table.column` / bare `column` ref into its parts. */
4429
+ function parseColumnRef(ref) {
4430
+ const dot = ref.indexOf(".");
4431
+ if (dot === -1) return { column: ref };
4432
+ return {
4433
+ table: ref.slice(0, dot),
4434
+ column: ref.slice(dot + 1)
4435
+ };
4436
+ }
4437
+ /** Shared lookup + error-collection state threaded through the validators. */
4438
+ var SchemaValidator = class {
4439
+ errors = [];
4440
+ columnsByTable = /* @__PURE__ */ new Map();
4441
+ constructor(schema) {
4442
+ for (const table of schema) this.columnsByTable.set(table.name, new Set(table.columns));
4443
+ }
4444
+ tableExists(name) {
4445
+ return this.columnsByTable.has(name);
4446
+ }
4447
+ columnExists(table, column) {
4448
+ return this.columnsByTable.get(table)?.has(column) ?? false;
4449
+ }
4450
+ report(path, message) {
4451
+ this.errors.push({
4452
+ path,
4453
+ message
4454
+ });
4455
+ }
4456
+ /** Report if `column` is absent from `table`. Returns whether it existed. */
4457
+ requireColumn(path, table, column) {
4458
+ if (this.columnExists(table, column)) return true;
4459
+ this.report(path, `column "${column}" does not exist on "${table}"`);
4460
+ return false;
4461
+ }
4462
+ };
4463
+ function validateFields(v, base, entity) {
4464
+ for (const [field, column] of Object.entries(entity.fields)) v.requireColumn(`${base}.fields.${field}`, entity.source, column);
4465
+ for (const field of nonCanonicalFieldKeys(entity)) v.report(`${base}.fields.${field}`, nonCanonicalMessage(entity, field));
4466
+ }
4467
+ function validateReadOnly(v, base, entity) {
4468
+ for (const field of entity.readOnly ?? []) if (!(field in entity.fields)) v.report(`${base}.readOnly`, `"${field}" is not one of this entity's fields`);
4469
+ }
4470
+ function validateFilter(v, base, entity) {
4471
+ if (!entity.filter || "$raw" in entity.filter) return;
4472
+ for (const column of Object.keys(entity.filter)) v.requireColumn(`${base}.filter.${column}`, entity.source, column);
4473
+ }
4474
+ function validateFkVia(v, relBase, via, entity, related) {
4475
+ const { table, column } = parseColumnRef(via.column);
4476
+ const fkTable = table ?? (via.fkOn === "contact" ? entity.source : related?.source);
4477
+ const path = `${relBase}.via.column`;
4478
+ if (!fkTable) {
4479
+ v.report(path, `cannot resolve table for FK column "${via.column}"`);
4480
+ return;
4481
+ }
4482
+ if (!v.tableExists(fkTable)) {
4483
+ v.report(path, `table "${fkTable}" is not in the discovered schema`);
4484
+ return;
4485
+ }
4486
+ v.requireColumn(path, fkTable, column);
4487
+ }
4488
+ function validateThroughVia(v, relBase, via) {
4489
+ if (!v.tableExists(via.through)) {
4490
+ v.report(`${relBase}.via.through`, `join table "${via.through}" is not in the discovered schema`);
4491
+ return;
4492
+ }
4493
+ v.requireColumn(`${relBase}.via.localKey`, via.through, via.localKey);
4494
+ v.requireColumn(`${relBase}.via.foreignKey`, via.through, via.foreignKey);
4495
+ }
4496
+ function validateRelationship(v, base, config, entity, relName, rel) {
4497
+ const relBase = `${base}.relationships.${relName}`;
4498
+ const related = config.entities[rel.entity];
4499
+ if (!related) v.report(`${relBase}.entity`, `"${rel.entity}" is not a defined entity`);
4500
+ const { via } = rel;
4501
+ if ("fkOn" in via) validateFkVia(v, relBase, via, entity, related);
4502
+ else if ("through" in via) validateThroughVia(v, relBase, via);
4503
+ }
4504
+ function validateEntity(v, config, key, entity) {
4505
+ const base = `entities.${key}`;
4506
+ if (!v.tableExists(entity.source)) {
4507
+ v.report(`${base}.source`, `table "${entity.source}" is not in the discovered schema`);
4508
+ return;
4509
+ }
4510
+ validateFields(v, base, entity);
4511
+ validateReadOnly(v, base, entity);
4512
+ validateFilter(v, base, entity);
4513
+ for (const [relName, rel] of Object.entries(entity.relationships ?? {})) validateRelationship(v, base, config, entity, relName, rel);
4514
+ }
4515
+ /**
4516
+ * Validate a (structurally valid) config against the host's discovered schema:
4517
+ * source tables exist, mapped columns exist, `readOnly` ⊆ `fields`, filter
4518
+ * columns exist, and relationships point at real entities/tables/columns.
4519
+ *
4520
+ * `$raw` filters and `$raw` relationship joins are opaque and skipped. Returns
4521
+ * every error found (not just the first) so a mapping UI or CLI can show them
4522
+ * all at once.
4523
+ */
4524
+ function validateEntitiesConfig(config, schema) {
4525
+ const validator = new SchemaValidator(schema);
4526
+ for (const [key, entity] of Object.entries(config.entities)) validateEntity(validator, config, key, entity);
4527
+ return {
4528
+ valid: validator.errors.length === 0,
4529
+ errors: validator.errors
4530
+ };
4531
+ }
4532
+ //#endregion
4533
+ Object.defineProperty(exports, "CANONICAL_FIELDS", {
4534
+ enumerable: true,
4535
+ get: function() {
4536
+ return CANONICAL_FIELDS;
4537
+ }
4538
+ });
4539
+ Object.defineProperty(exports, "CRM_CONCEPTS", {
4540
+ enumerable: true,
4541
+ get: function() {
4542
+ return CRM_CONCEPTS;
4543
+ }
4544
+ });
4545
+ Object.defineProperty(exports, "CUSTOM_CONCEPT", {
4546
+ enumerable: true,
4547
+ get: function() {
4548
+ return CUSTOM_CONCEPT;
4549
+ }
4550
+ });
4551
+ Object.defineProperty(exports, "ClivlyConfigError", {
4552
+ enumerable: true,
4553
+ get: function() {
4554
+ return ClivlyConfigError;
4555
+ }
4556
+ });
4557
+ Object.defineProperty(exports, "MATERIALIZING_CONCEPTS", {
4558
+ enumerable: true,
4559
+ get: function() {
4560
+ return MATERIALIZING_CONCEPTS;
4561
+ }
4562
+ });
4563
+ Object.defineProperty(exports, "defineClivlyConfig", {
4564
+ enumerable: true,
4565
+ get: function() {
4566
+ return defineClivlyConfig;
4567
+ }
4568
+ });
4569
+ Object.defineProperty(exports, "entitiesConfigSchema", {
4570
+ enumerable: true,
4571
+ get: function() {
4572
+ return entitiesConfigSchema;
4573
+ }
4574
+ });
4575
+ Object.defineProperty(exports, "filterSchema", {
4576
+ enumerable: true,
4577
+ get: function() {
4578
+ return filterSchema;
4579
+ }
4580
+ });
4581
+ Object.defineProperty(exports, "relationshipSchema", {
4582
+ enumerable: true,
4583
+ get: function() {
4584
+ return relationshipSchema;
4585
+ }
4586
+ });
4587
+ Object.defineProperty(exports, "relationshipsSchema", {
4588
+ enumerable: true,
4589
+ get: function() {
4590
+ return relationshipsSchema;
4591
+ }
4592
+ });
4593
+ Object.defineProperty(exports, "validateEntitiesConfig", {
4594
+ enumerable: true,
4595
+ get: function() {
4596
+ return validateEntitiesConfig;
4597
+ }
4598
+ });