@repome/sdk 0.1.9 → 0.3.0

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