@betternotify/zapier 0.0.2-alpha.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.js ADDED
@@ -0,0 +1,2651 @@
1
+ import { NotifyRpcError, NotifyRpcProviderError, consoleLogger, defineChannel, slot } from "@betternotify/core";
2
+ import { createHttpClient, createMockTransport, createTransport } from "@betternotify/core/transports";
3
+ import { createTransport as createTransport$1, normalizeAddress } from "@betternotify/email/transports";
4
+ Object.freeze({ status: "aborted" });
5
+ function $constructor(name, initializer, params) {
6
+ function init(inst, def) {
7
+ if (!inst._zod) Object.defineProperty(inst, "_zod", {
8
+ value: {
9
+ def,
10
+ constr: _,
11
+ traits: /* @__PURE__ */ new Set()
12
+ },
13
+ enumerable: false
14
+ });
15
+ if (inst._zod.traits.has(name)) return;
16
+ inst._zod.traits.add(name);
17
+ initializer(inst, def);
18
+ const proto = _.prototype;
19
+ const keys = Object.keys(proto);
20
+ for (let i = 0; i < keys.length; i++) {
21
+ const k = keys[i];
22
+ if (!(k in inst)) inst[k] = proto[k].bind(inst);
23
+ }
24
+ }
25
+ const Parent = params?.Parent ?? Object;
26
+ class Definition extends Parent {}
27
+ Object.defineProperty(Definition, "name", { value: name });
28
+ function _(def) {
29
+ var _a;
30
+ const inst = params?.Parent ? new Definition() : this;
31
+ init(inst, def);
32
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
33
+ for (const fn of inst._zod.deferred) fn();
34
+ return inst;
35
+ }
36
+ Object.defineProperty(_, "init", { value: init });
37
+ Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
38
+ if (params?.Parent && inst instanceof params.Parent) return true;
39
+ return inst?._zod?.traits?.has(name);
40
+ } });
41
+ Object.defineProperty(_, "name", { value: name });
42
+ return _;
43
+ }
44
+ var $ZodAsyncError = class extends Error {
45
+ constructor() {
46
+ super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
47
+ }
48
+ };
49
+ var $ZodEncodeError = class extends Error {
50
+ constructor(name) {
51
+ super(`Encountered unidirectional transform during encode: ${name}`);
52
+ this.name = "ZodEncodeError";
53
+ }
54
+ };
55
+ const globalConfig = {};
56
+ function config(newConfig) {
57
+ if (newConfig) Object.assign(globalConfig, newConfig);
58
+ return globalConfig;
59
+ }
60
+ //#endregion
61
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.js
62
+ function getEnumValues(entries) {
63
+ const numericValues = Object.values(entries).filter((v) => typeof v === "number");
64
+ return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
65
+ }
66
+ function jsonStringifyReplacer(_, value) {
67
+ if (typeof value === "bigint") return value.toString();
68
+ return value;
69
+ }
70
+ function cached(getter) {
71
+ return { get value() {
72
+ {
73
+ const value = getter();
74
+ Object.defineProperty(this, "value", { value });
75
+ return value;
76
+ }
77
+ throw new Error("cached value already set");
78
+ } };
79
+ }
80
+ function nullish(input) {
81
+ return input === null || input === void 0;
82
+ }
83
+ function cleanRegex(source) {
84
+ const start = source.startsWith("^") ? 1 : 0;
85
+ const end = source.endsWith("$") ? source.length - 1 : source.length;
86
+ return source.slice(start, end);
87
+ }
88
+ const EVALUATING = Symbol("evaluating");
89
+ function defineLazy(object, key, getter) {
90
+ let value = void 0;
91
+ Object.defineProperty(object, key, {
92
+ get() {
93
+ if (value === EVALUATING) return;
94
+ if (value === void 0) {
95
+ value = EVALUATING;
96
+ value = getter();
97
+ }
98
+ return value;
99
+ },
100
+ set(v) {
101
+ Object.defineProperty(object, key, { value: v });
102
+ },
103
+ configurable: true
104
+ });
105
+ }
106
+ function assignProp(target, prop, value) {
107
+ Object.defineProperty(target, prop, {
108
+ value,
109
+ writable: true,
110
+ enumerable: true,
111
+ configurable: true
112
+ });
113
+ }
114
+ function mergeDefs(...defs) {
115
+ const mergedDescriptors = {};
116
+ for (const def of defs) Object.assign(mergedDescriptors, Object.getOwnPropertyDescriptors(def));
117
+ return Object.defineProperties({}, mergedDescriptors);
118
+ }
119
+ function esc(str) {
120
+ return JSON.stringify(str);
121
+ }
122
+ const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
123
+ function isObject(data) {
124
+ return typeof data === "object" && data !== null && !Array.isArray(data);
125
+ }
126
+ const allowsEval = cached(() => {
127
+ if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
128
+ try {
129
+ new Function("");
130
+ return true;
131
+ } catch (_) {
132
+ return false;
133
+ }
134
+ });
135
+ function isPlainObject(o) {
136
+ if (isObject(o) === false) return false;
137
+ const ctor = o.constructor;
138
+ if (ctor === void 0) return true;
139
+ if (typeof ctor !== "function") return true;
140
+ const prot = ctor.prototype;
141
+ if (isObject(prot) === false) return false;
142
+ if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
143
+ return true;
144
+ }
145
+ function shallowClone(o) {
146
+ if (isPlainObject(o)) return { ...o };
147
+ if (Array.isArray(o)) return [...o];
148
+ return o;
149
+ }
150
+ const propertyKeyTypes = new Set([
151
+ "string",
152
+ "number",
153
+ "symbol"
154
+ ]);
155
+ function escapeRegex(str) {
156
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
157
+ }
158
+ function clone(inst, def, params) {
159
+ const cl = new inst._zod.constr(def ?? inst._zod.def);
160
+ if (!def || params?.parent) cl._zod.parent = inst;
161
+ return cl;
162
+ }
163
+ function normalizeParams(_params) {
164
+ const params = _params;
165
+ if (!params) return {};
166
+ if (typeof params === "string") return { error: () => params };
167
+ if (params?.message !== void 0) {
168
+ if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
169
+ params.error = params.message;
170
+ }
171
+ delete params.message;
172
+ if (typeof params.error === "string") return {
173
+ ...params,
174
+ error: () => params.error
175
+ };
176
+ return params;
177
+ }
178
+ function optionalKeys(shape) {
179
+ return Object.keys(shape).filter((k) => {
180
+ return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
181
+ });
182
+ }
183
+ Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, -Number.MAX_VALUE, Number.MAX_VALUE;
184
+ function pick(schema, mask) {
185
+ const currDef = schema._zod.def;
186
+ const checks = currDef.checks;
187
+ if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
188
+ return clone(schema, mergeDefs(schema._zod.def, {
189
+ get shape() {
190
+ const newShape = {};
191
+ for (const key in mask) {
192
+ if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
193
+ if (!mask[key]) continue;
194
+ newShape[key] = currDef.shape[key];
195
+ }
196
+ assignProp(this, "shape", newShape);
197
+ return newShape;
198
+ },
199
+ checks: []
200
+ }));
201
+ }
202
+ function omit(schema, mask) {
203
+ const currDef = schema._zod.def;
204
+ const checks = currDef.checks;
205
+ if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
206
+ return clone(schema, mergeDefs(schema._zod.def, {
207
+ get shape() {
208
+ const newShape = { ...schema._zod.def.shape };
209
+ for (const key in mask) {
210
+ if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
211
+ if (!mask[key]) continue;
212
+ delete newShape[key];
213
+ }
214
+ assignProp(this, "shape", newShape);
215
+ return newShape;
216
+ },
217
+ checks: []
218
+ }));
219
+ }
220
+ function extend(schema, shape) {
221
+ if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
222
+ const checks = schema._zod.def.checks;
223
+ if (checks && checks.length > 0) {
224
+ const existingShape = schema._zod.def.shape;
225
+ 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.");
226
+ }
227
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
228
+ const _shape = {
229
+ ...schema._zod.def.shape,
230
+ ...shape
231
+ };
232
+ assignProp(this, "shape", _shape);
233
+ return _shape;
234
+ } }));
235
+ }
236
+ function safeExtend(schema, shape) {
237
+ if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
238
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
239
+ const _shape = {
240
+ ...schema._zod.def.shape,
241
+ ...shape
242
+ };
243
+ assignProp(this, "shape", _shape);
244
+ return _shape;
245
+ } }));
246
+ }
247
+ function merge(a, b) {
248
+ return clone(a, mergeDefs(a._zod.def, {
249
+ get shape() {
250
+ const _shape = {
251
+ ...a._zod.def.shape,
252
+ ...b._zod.def.shape
253
+ };
254
+ assignProp(this, "shape", _shape);
255
+ return _shape;
256
+ },
257
+ get catchall() {
258
+ return b._zod.def.catchall;
259
+ },
260
+ checks: []
261
+ }));
262
+ }
263
+ function partial(Class, schema, mask) {
264
+ const checks = schema._zod.def.checks;
265
+ if (checks && checks.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
266
+ return clone(schema, mergeDefs(schema._zod.def, {
267
+ get shape() {
268
+ const oldShape = schema._zod.def.shape;
269
+ const shape = { ...oldShape };
270
+ if (mask) for (const key in mask) {
271
+ if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
272
+ if (!mask[key]) continue;
273
+ shape[key] = Class ? new Class({
274
+ type: "optional",
275
+ innerType: oldShape[key]
276
+ }) : oldShape[key];
277
+ }
278
+ else for (const key in oldShape) shape[key] = Class ? new Class({
279
+ type: "optional",
280
+ innerType: oldShape[key]
281
+ }) : oldShape[key];
282
+ assignProp(this, "shape", shape);
283
+ return shape;
284
+ },
285
+ checks: []
286
+ }));
287
+ }
288
+ function required(Class, schema, mask) {
289
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
290
+ const oldShape = schema._zod.def.shape;
291
+ const shape = { ...oldShape };
292
+ if (mask) for (const key in mask) {
293
+ if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
294
+ if (!mask[key]) continue;
295
+ shape[key] = new Class({
296
+ type: "nonoptional",
297
+ innerType: oldShape[key]
298
+ });
299
+ }
300
+ else for (const key in oldShape) shape[key] = new Class({
301
+ type: "nonoptional",
302
+ innerType: oldShape[key]
303
+ });
304
+ assignProp(this, "shape", shape);
305
+ return shape;
306
+ } }));
307
+ }
308
+ function aborted(x, startIndex = 0) {
309
+ if (x.aborted === true) return true;
310
+ for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
311
+ return false;
312
+ }
313
+ function prefixIssues(path, issues) {
314
+ return issues.map((iss) => {
315
+ var _a;
316
+ (_a = iss).path ?? (_a.path = []);
317
+ iss.path.unshift(path);
318
+ return iss;
319
+ });
320
+ }
321
+ function unwrapMessage(message) {
322
+ return typeof message === "string" ? message : message?.message;
323
+ }
324
+ function finalizeIssue(iss, ctx, config) {
325
+ const full = {
326
+ ...iss,
327
+ path: iss.path ?? []
328
+ };
329
+ if (!iss.message) full.message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
330
+ delete full.inst;
331
+ delete full.continue;
332
+ if (!ctx?.reportInput) delete full.input;
333
+ return full;
334
+ }
335
+ function getLengthableOrigin(input) {
336
+ if (Array.isArray(input)) return "array";
337
+ if (typeof input === "string") return "string";
338
+ return "unknown";
339
+ }
340
+ function issue(...args) {
341
+ const [iss, input, inst] = args;
342
+ if (typeof iss === "string") return {
343
+ message: iss,
344
+ code: "custom",
345
+ input,
346
+ inst
347
+ };
348
+ return { ...iss };
349
+ }
350
+ //#endregion
351
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.js
352
+ const initializer$1 = (inst, def) => {
353
+ inst.name = "$ZodError";
354
+ Object.defineProperty(inst, "_zod", {
355
+ value: inst._zod,
356
+ enumerable: false
357
+ });
358
+ Object.defineProperty(inst, "issues", {
359
+ value: def,
360
+ enumerable: false
361
+ });
362
+ inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
363
+ Object.defineProperty(inst, "toString", {
364
+ value: () => inst.message,
365
+ enumerable: false
366
+ });
367
+ };
368
+ const $ZodError = $constructor("$ZodError", initializer$1);
369
+ const $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
370
+ function flattenError(error, mapper = (issue) => issue.message) {
371
+ const fieldErrors = {};
372
+ const formErrors = [];
373
+ for (const sub of error.issues) if (sub.path.length > 0) {
374
+ fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
375
+ fieldErrors[sub.path[0]].push(mapper(sub));
376
+ } else formErrors.push(mapper(sub));
377
+ return {
378
+ formErrors,
379
+ fieldErrors
380
+ };
381
+ }
382
+ function formatError(error, mapper = (issue) => issue.message) {
383
+ const fieldErrors = { _errors: [] };
384
+ const processError = (error) => {
385
+ for (const issue of error.issues) if (issue.code === "invalid_union" && issue.errors.length) issue.errors.map((issues) => processError({ issues }));
386
+ else if (issue.code === "invalid_key") processError({ issues: issue.issues });
387
+ else if (issue.code === "invalid_element") processError({ issues: issue.issues });
388
+ else if (issue.path.length === 0) fieldErrors._errors.push(mapper(issue));
389
+ else {
390
+ let curr = fieldErrors;
391
+ let i = 0;
392
+ while (i < issue.path.length) {
393
+ const el = issue.path[i];
394
+ if (!(i === issue.path.length - 1)) curr[el] = curr[el] || { _errors: [] };
395
+ else {
396
+ curr[el] = curr[el] || { _errors: [] };
397
+ curr[el]._errors.push(mapper(issue));
398
+ }
399
+ curr = curr[el];
400
+ i++;
401
+ }
402
+ }
403
+ };
404
+ processError(error);
405
+ return fieldErrors;
406
+ }
407
+ //#endregion
408
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/parse.js
409
+ const _parse = (_Err) => (schema, value, _ctx, _params) => {
410
+ const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
411
+ const result = schema._zod.run({
412
+ value,
413
+ issues: []
414
+ }, ctx);
415
+ if (result instanceof Promise) throw new $ZodAsyncError();
416
+ if (result.issues.length) {
417
+ const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
418
+ captureStackTrace(e, _params?.callee);
419
+ throw e;
420
+ }
421
+ return result.value;
422
+ };
423
+ const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
424
+ const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
425
+ let result = schema._zod.run({
426
+ value,
427
+ issues: []
428
+ }, ctx);
429
+ if (result instanceof Promise) result = await result;
430
+ if (result.issues.length) {
431
+ const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
432
+ captureStackTrace(e, params?.callee);
433
+ throw e;
434
+ }
435
+ return result.value;
436
+ };
437
+ const _safeParse = (_Err) => (schema, value, _ctx) => {
438
+ const ctx = _ctx ? {
439
+ ..._ctx,
440
+ async: false
441
+ } : { async: false };
442
+ const result = schema._zod.run({
443
+ value,
444
+ issues: []
445
+ }, ctx);
446
+ if (result instanceof Promise) throw new $ZodAsyncError();
447
+ return result.issues.length ? {
448
+ success: false,
449
+ error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
450
+ } : {
451
+ success: true,
452
+ data: result.value
453
+ };
454
+ };
455
+ const safeParse$1 = /* @__PURE__ */ _safeParse($ZodRealError);
456
+ const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
457
+ const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
458
+ let result = schema._zod.run({
459
+ value,
460
+ issues: []
461
+ }, ctx);
462
+ if (result instanceof Promise) result = await result;
463
+ return result.issues.length ? {
464
+ success: false,
465
+ error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
466
+ } : {
467
+ success: true,
468
+ data: result.value
469
+ };
470
+ };
471
+ const safeParseAsync$1 = /* @__PURE__ */ _safeParseAsync($ZodRealError);
472
+ const _encode = (_Err) => (schema, value, _ctx) => {
473
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
474
+ return _parse(_Err)(schema, value, ctx);
475
+ };
476
+ const _decode = (_Err) => (schema, value, _ctx) => {
477
+ return _parse(_Err)(schema, value, _ctx);
478
+ };
479
+ const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
480
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
481
+ return _parseAsync(_Err)(schema, value, ctx);
482
+ };
483
+ const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
484
+ return _parseAsync(_Err)(schema, value, _ctx);
485
+ };
486
+ const _safeEncode = (_Err) => (schema, value, _ctx) => {
487
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
488
+ return _safeParse(_Err)(schema, value, ctx);
489
+ };
490
+ const _safeDecode = (_Err) => (schema, value, _ctx) => {
491
+ return _safeParse(_Err)(schema, value, _ctx);
492
+ };
493
+ const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
494
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
495
+ return _safeParseAsync(_Err)(schema, value, ctx);
496
+ };
497
+ const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
498
+ return _safeParseAsync(_Err)(schema, value, _ctx);
499
+ };
500
+ //#endregion
501
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/checks.js
502
+ const $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
503
+ var _a;
504
+ inst._zod ?? (inst._zod = {});
505
+ inst._zod.def = def;
506
+ (_a = inst._zod).onattach ?? (_a.onattach = []);
507
+ });
508
+ const $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
509
+ var _a;
510
+ $ZodCheck.init(inst, def);
511
+ (_a = inst._zod.def).when ?? (_a.when = (payload) => {
512
+ const val = payload.value;
513
+ return !nullish(val) && val.length !== void 0;
514
+ });
515
+ inst._zod.onattach.push((inst) => {
516
+ const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
517
+ if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
518
+ });
519
+ inst._zod.check = (payload) => {
520
+ const input = payload.value;
521
+ if (input.length <= def.maximum) return;
522
+ const origin = getLengthableOrigin(input);
523
+ payload.issues.push({
524
+ origin,
525
+ code: "too_big",
526
+ maximum: def.maximum,
527
+ inclusive: true,
528
+ input,
529
+ inst,
530
+ continue: !def.abort
531
+ });
532
+ };
533
+ });
534
+ const $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
535
+ var _a;
536
+ $ZodCheck.init(inst, def);
537
+ (_a = inst._zod.def).when ?? (_a.when = (payload) => {
538
+ const val = payload.value;
539
+ return !nullish(val) && val.length !== void 0;
540
+ });
541
+ inst._zod.onattach.push((inst) => {
542
+ const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
543
+ if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
544
+ });
545
+ inst._zod.check = (payload) => {
546
+ const input = payload.value;
547
+ if (input.length >= def.minimum) return;
548
+ const origin = getLengthableOrigin(input);
549
+ payload.issues.push({
550
+ origin,
551
+ code: "too_small",
552
+ minimum: def.minimum,
553
+ inclusive: true,
554
+ input,
555
+ inst,
556
+ continue: !def.abort
557
+ });
558
+ };
559
+ });
560
+ const $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
561
+ var _a;
562
+ $ZodCheck.init(inst, def);
563
+ (_a = inst._zod.def).when ?? (_a.when = (payload) => {
564
+ const val = payload.value;
565
+ return !nullish(val) && val.length !== void 0;
566
+ });
567
+ inst._zod.onattach.push((inst) => {
568
+ const bag = inst._zod.bag;
569
+ bag.minimum = def.length;
570
+ bag.maximum = def.length;
571
+ bag.length = def.length;
572
+ });
573
+ inst._zod.check = (payload) => {
574
+ const input = payload.value;
575
+ const length = input.length;
576
+ if (length === def.length) return;
577
+ const origin = getLengthableOrigin(input);
578
+ const tooBig = length > def.length;
579
+ payload.issues.push({
580
+ origin,
581
+ ...tooBig ? {
582
+ code: "too_big",
583
+ maximum: def.length
584
+ } : {
585
+ code: "too_small",
586
+ minimum: def.length
587
+ },
588
+ inclusive: true,
589
+ exact: true,
590
+ input: payload.value,
591
+ inst,
592
+ continue: !def.abort
593
+ });
594
+ };
595
+ });
596
+ const $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (inst, def) => {
597
+ $ZodCheck.init(inst, def);
598
+ inst._zod.check = (payload) => {
599
+ payload.value = def.tx(payload.value);
600
+ };
601
+ });
602
+ //#endregion
603
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/doc.js
604
+ var Doc = class {
605
+ constructor(args = []) {
606
+ this.content = [];
607
+ this.indent = 0;
608
+ if (this) this.args = args;
609
+ }
610
+ indented(fn) {
611
+ this.indent += 1;
612
+ fn(this);
613
+ this.indent -= 1;
614
+ }
615
+ write(arg) {
616
+ if (typeof arg === "function") {
617
+ arg(this, { execution: "sync" });
618
+ arg(this, { execution: "async" });
619
+ return;
620
+ }
621
+ const lines = arg.split("\n").filter((x) => x);
622
+ const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
623
+ const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
624
+ for (const line of dedented) this.content.push(line);
625
+ }
626
+ compile() {
627
+ const F = Function;
628
+ const args = this?.args;
629
+ const lines = [...(this?.content ?? [``]).map((x) => ` ${x}`)];
630
+ return new F(...args, lines.join("\n"));
631
+ }
632
+ };
633
+ //#endregion
634
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/versions.js
635
+ const version = {
636
+ major: 4,
637
+ minor: 3,
638
+ patch: 6
639
+ };
640
+ //#endregion
641
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/schemas.js
642
+ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
643
+ var _a;
644
+ inst ?? (inst = {});
645
+ inst._zod.def = def;
646
+ inst._zod.bag = inst._zod.bag || {};
647
+ inst._zod.version = version;
648
+ const checks = [...inst._zod.def.checks ?? []];
649
+ if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
650
+ for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
651
+ if (checks.length === 0) {
652
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
653
+ inst._zod.deferred?.push(() => {
654
+ inst._zod.run = inst._zod.parse;
655
+ });
656
+ } else {
657
+ const runChecks = (payload, checks, ctx) => {
658
+ let isAborted = aborted(payload);
659
+ let asyncResult;
660
+ for (const ch of checks) {
661
+ if (ch._zod.def.when) {
662
+ if (!ch._zod.def.when(payload)) continue;
663
+ } else if (isAborted) continue;
664
+ const currLen = payload.issues.length;
665
+ const _ = ch._zod.check(payload);
666
+ if (_ instanceof Promise && ctx?.async === false) throw new $ZodAsyncError();
667
+ if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
668
+ await _;
669
+ if (payload.issues.length === currLen) return;
670
+ if (!isAborted) isAborted = aborted(payload, currLen);
671
+ });
672
+ else {
673
+ if (payload.issues.length === currLen) continue;
674
+ if (!isAborted) isAborted = aborted(payload, currLen);
675
+ }
676
+ }
677
+ if (asyncResult) return asyncResult.then(() => {
678
+ return payload;
679
+ });
680
+ return payload;
681
+ };
682
+ const handleCanaryResult = (canary, payload, ctx) => {
683
+ if (aborted(canary)) {
684
+ canary.aborted = true;
685
+ return canary;
686
+ }
687
+ const checkResult = runChecks(payload, checks, ctx);
688
+ if (checkResult instanceof Promise) {
689
+ if (ctx.async === false) throw new $ZodAsyncError();
690
+ return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
691
+ }
692
+ return inst._zod.parse(checkResult, ctx);
693
+ };
694
+ inst._zod.run = (payload, ctx) => {
695
+ if (ctx.skipChecks) return inst._zod.parse(payload, ctx);
696
+ if (ctx.direction === "backward") {
697
+ const canary = inst._zod.parse({
698
+ value: payload.value,
699
+ issues: []
700
+ }, {
701
+ ...ctx,
702
+ skipChecks: true
703
+ });
704
+ if (canary instanceof Promise) return canary.then((canary) => {
705
+ return handleCanaryResult(canary, payload, ctx);
706
+ });
707
+ return handleCanaryResult(canary, payload, ctx);
708
+ }
709
+ const result = inst._zod.parse(payload, ctx);
710
+ if (result instanceof Promise) {
711
+ if (ctx.async === false) throw new $ZodAsyncError();
712
+ return result.then((result) => runChecks(result, checks, ctx));
713
+ }
714
+ return runChecks(result, checks, ctx);
715
+ };
716
+ }
717
+ defineLazy(inst, "~standard", () => ({
718
+ validate: (value) => {
719
+ try {
720
+ const r = safeParse$1(inst, value);
721
+ return r.success ? { value: r.data } : { issues: r.error?.issues };
722
+ } catch (_) {
723
+ return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
724
+ }
725
+ },
726
+ vendor: "zod",
727
+ version: 1
728
+ }));
729
+ });
730
+ const $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
731
+ $ZodType.init(inst, def);
732
+ inst._zod.parse = (payload) => payload;
733
+ });
734
+ const $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
735
+ $ZodType.init(inst, def);
736
+ inst._zod.parse = (payload, _ctx) => {
737
+ payload.issues.push({
738
+ expected: "never",
739
+ code: "invalid_type",
740
+ input: payload.value,
741
+ inst
742
+ });
743
+ return payload;
744
+ };
745
+ });
746
+ function handleArrayResult(result, final, index) {
747
+ if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
748
+ final.value[index] = result.value;
749
+ }
750
+ const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
751
+ $ZodType.init(inst, def);
752
+ inst._zod.parse = (payload, ctx) => {
753
+ const input = payload.value;
754
+ if (!Array.isArray(input)) {
755
+ payload.issues.push({
756
+ expected: "array",
757
+ code: "invalid_type",
758
+ input,
759
+ inst
760
+ });
761
+ return payload;
762
+ }
763
+ payload.value = Array(input.length);
764
+ const proms = [];
765
+ for (let i = 0; i < input.length; i++) {
766
+ const item = input[i];
767
+ const result = def.element._zod.run({
768
+ value: item,
769
+ issues: []
770
+ }, ctx);
771
+ if (result instanceof Promise) proms.push(result.then((result) => handleArrayResult(result, payload, i)));
772
+ else handleArrayResult(result, payload, i);
773
+ }
774
+ if (proms.length) return Promise.all(proms).then(() => payload);
775
+ return payload;
776
+ };
777
+ });
778
+ function handlePropertyResult(result, final, key, input, isOptionalOut) {
779
+ if (result.issues.length) {
780
+ if (isOptionalOut && !(key in input)) return;
781
+ final.issues.push(...prefixIssues(key, result.issues));
782
+ }
783
+ if (result.value === void 0) {
784
+ if (key in input) final.value[key] = void 0;
785
+ } else final.value[key] = result.value;
786
+ }
787
+ function normalizeDef(def) {
788
+ const keys = Object.keys(def.shape);
789
+ 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`);
790
+ const okeys = optionalKeys(def.shape);
791
+ return {
792
+ ...def,
793
+ keys,
794
+ keySet: new Set(keys),
795
+ numKeys: keys.length,
796
+ optionalKeys: new Set(okeys)
797
+ };
798
+ }
799
+ function handleCatchall(proms, input, payload, ctx, def, inst) {
800
+ const unrecognized = [];
801
+ const keySet = def.keySet;
802
+ const _catchall = def.catchall._zod;
803
+ const t = _catchall.def.type;
804
+ const isOptionalOut = _catchall.optout === "optional";
805
+ for (const key in input) {
806
+ if (keySet.has(key)) continue;
807
+ if (t === "never") {
808
+ unrecognized.push(key);
809
+ continue;
810
+ }
811
+ const r = _catchall.run({
812
+ value: input[key],
813
+ issues: []
814
+ }, ctx);
815
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
816
+ else handlePropertyResult(r, payload, key, input, isOptionalOut);
817
+ }
818
+ if (unrecognized.length) payload.issues.push({
819
+ code: "unrecognized_keys",
820
+ keys: unrecognized,
821
+ input,
822
+ inst
823
+ });
824
+ if (!proms.length) return payload;
825
+ return Promise.all(proms).then(() => {
826
+ return payload;
827
+ });
828
+ }
829
+ const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
830
+ $ZodType.init(inst, def);
831
+ if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) {
832
+ const sh = def.shape;
833
+ Object.defineProperty(def, "shape", { get: () => {
834
+ const newSh = { ...sh };
835
+ Object.defineProperty(def, "shape", { value: newSh });
836
+ return newSh;
837
+ } });
838
+ }
839
+ const _normalized = cached(() => normalizeDef(def));
840
+ defineLazy(inst._zod, "propValues", () => {
841
+ const shape = def.shape;
842
+ const propValues = {};
843
+ for (const key in shape) {
844
+ const field = shape[key]._zod;
845
+ if (field.values) {
846
+ propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
847
+ for (const v of field.values) propValues[key].add(v);
848
+ }
849
+ }
850
+ return propValues;
851
+ });
852
+ const isObject$2 = isObject;
853
+ const catchall = def.catchall;
854
+ let value;
855
+ inst._zod.parse = (payload, ctx) => {
856
+ value ?? (value = _normalized.value);
857
+ const input = payload.value;
858
+ if (!isObject$2(input)) {
859
+ payload.issues.push({
860
+ expected: "object",
861
+ code: "invalid_type",
862
+ input,
863
+ inst
864
+ });
865
+ return payload;
866
+ }
867
+ payload.value = {};
868
+ const proms = [];
869
+ const shape = value.shape;
870
+ for (const key of value.keys) {
871
+ const el = shape[key];
872
+ const isOptionalOut = el._zod.optout === "optional";
873
+ const r = el._zod.run({
874
+ value: input[key],
875
+ issues: []
876
+ }, ctx);
877
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
878
+ else handlePropertyResult(r, payload, key, input, isOptionalOut);
879
+ }
880
+ if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
881
+ return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
882
+ };
883
+ });
884
+ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
885
+ $ZodObject.init(inst, def);
886
+ const superParse = inst._zod.parse;
887
+ const _normalized = cached(() => normalizeDef(def));
888
+ const generateFastpass = (shape) => {
889
+ const doc = new Doc([
890
+ "shape",
891
+ "payload",
892
+ "ctx"
893
+ ]);
894
+ const normalized = _normalized.value;
895
+ const parseStr = (key) => {
896
+ const k = esc(key);
897
+ return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
898
+ };
899
+ doc.write(`const input = payload.value;`);
900
+ const ids = Object.create(null);
901
+ let counter = 0;
902
+ for (const key of normalized.keys) ids[key] = `key_${counter++}`;
903
+ doc.write(`const newResult = {};`);
904
+ for (const key of normalized.keys) {
905
+ const id = ids[key];
906
+ const k = esc(key);
907
+ const isOptionalOut = shape[key]?._zod?.optout === "optional";
908
+ doc.write(`const ${id} = ${parseStr(key)};`);
909
+ if (isOptionalOut) doc.write(`
910
+ if (${id}.issues.length) {
911
+ if (${k} in input) {
912
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
913
+ ...iss,
914
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
915
+ })));
916
+ }
917
+ }
918
+
919
+ if (${id}.value === undefined) {
920
+ if (${k} in input) {
921
+ newResult[${k}] = undefined;
922
+ }
923
+ } else {
924
+ newResult[${k}] = ${id}.value;
925
+ }
926
+
927
+ `);
928
+ else doc.write(`
929
+ if (${id}.issues.length) {
930
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
931
+ ...iss,
932
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
933
+ })));
934
+ }
935
+
936
+ if (${id}.value === undefined) {
937
+ if (${k} in input) {
938
+ newResult[${k}] = undefined;
939
+ }
940
+ } else {
941
+ newResult[${k}] = ${id}.value;
942
+ }
943
+
944
+ `);
945
+ }
946
+ doc.write(`payload.value = newResult;`);
947
+ doc.write(`return payload;`);
948
+ const fn = doc.compile();
949
+ return (payload, ctx) => fn(shape, payload, ctx);
950
+ };
951
+ let fastpass;
952
+ const isObject$1 = isObject;
953
+ const jit = !globalConfig.jitless;
954
+ const fastEnabled = jit && allowsEval.value;
955
+ const catchall = def.catchall;
956
+ let value;
957
+ inst._zod.parse = (payload, ctx) => {
958
+ value ?? (value = _normalized.value);
959
+ const input = payload.value;
960
+ if (!isObject$1(input)) {
961
+ payload.issues.push({
962
+ expected: "object",
963
+ code: "invalid_type",
964
+ input,
965
+ inst
966
+ });
967
+ return payload;
968
+ }
969
+ if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
970
+ if (!fastpass) fastpass = generateFastpass(def.shape);
971
+ payload = fastpass(payload, ctx);
972
+ if (!catchall) return payload;
973
+ return handleCatchall([], input, payload, ctx, value, inst);
974
+ }
975
+ return superParse(payload, ctx);
976
+ };
977
+ });
978
+ function handleUnionResults(results, final, inst, ctx) {
979
+ for (const result of results) if (result.issues.length === 0) {
980
+ final.value = result.value;
981
+ return final;
982
+ }
983
+ const nonaborted = results.filter((r) => !aborted(r));
984
+ if (nonaborted.length === 1) {
985
+ final.value = nonaborted[0].value;
986
+ return nonaborted[0];
987
+ }
988
+ final.issues.push({
989
+ code: "invalid_union",
990
+ input: final.value,
991
+ inst,
992
+ errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
993
+ });
994
+ return final;
995
+ }
996
+ const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
997
+ $ZodType.init(inst, def);
998
+ defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
999
+ defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
1000
+ defineLazy(inst._zod, "values", () => {
1001
+ if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
1002
+ });
1003
+ defineLazy(inst._zod, "pattern", () => {
1004
+ if (def.options.every((o) => o._zod.pattern)) {
1005
+ const patterns = def.options.map((o) => o._zod.pattern);
1006
+ return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
1007
+ }
1008
+ });
1009
+ const single = def.options.length === 1;
1010
+ const first = def.options[0]._zod.run;
1011
+ inst._zod.parse = (payload, ctx) => {
1012
+ if (single) return first(payload, ctx);
1013
+ let async = false;
1014
+ const results = [];
1015
+ for (const option of def.options) {
1016
+ const result = option._zod.run({
1017
+ value: payload.value,
1018
+ issues: []
1019
+ }, ctx);
1020
+ if (result instanceof Promise) {
1021
+ results.push(result);
1022
+ async = true;
1023
+ } else {
1024
+ if (result.issues.length === 0) return result;
1025
+ results.push(result);
1026
+ }
1027
+ }
1028
+ if (!async) return handleUnionResults(results, payload, inst, ctx);
1029
+ return Promise.all(results).then((results) => {
1030
+ return handleUnionResults(results, payload, inst, ctx);
1031
+ });
1032
+ };
1033
+ });
1034
+ const $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
1035
+ $ZodType.init(inst, def);
1036
+ inst._zod.parse = (payload, ctx) => {
1037
+ const input = payload.value;
1038
+ const left = def.left._zod.run({
1039
+ value: input,
1040
+ issues: []
1041
+ }, ctx);
1042
+ const right = def.right._zod.run({
1043
+ value: input,
1044
+ issues: []
1045
+ }, ctx);
1046
+ if (left instanceof Promise || right instanceof Promise) return Promise.all([left, right]).then(([left, right]) => {
1047
+ return handleIntersectionResults(payload, left, right);
1048
+ });
1049
+ return handleIntersectionResults(payload, left, right);
1050
+ };
1051
+ });
1052
+ function mergeValues(a, b) {
1053
+ if (a === b) return {
1054
+ valid: true,
1055
+ data: a
1056
+ };
1057
+ if (a instanceof Date && b instanceof Date && +a === +b) return {
1058
+ valid: true,
1059
+ data: a
1060
+ };
1061
+ if (isPlainObject(a) && isPlainObject(b)) {
1062
+ const bKeys = Object.keys(b);
1063
+ const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
1064
+ const newObj = {
1065
+ ...a,
1066
+ ...b
1067
+ };
1068
+ for (const key of sharedKeys) {
1069
+ const sharedValue = mergeValues(a[key], b[key]);
1070
+ if (!sharedValue.valid) return {
1071
+ valid: false,
1072
+ mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
1073
+ };
1074
+ newObj[key] = sharedValue.data;
1075
+ }
1076
+ return {
1077
+ valid: true,
1078
+ data: newObj
1079
+ };
1080
+ }
1081
+ if (Array.isArray(a) && Array.isArray(b)) {
1082
+ if (a.length !== b.length) return {
1083
+ valid: false,
1084
+ mergeErrorPath: []
1085
+ };
1086
+ const newArray = [];
1087
+ for (let index = 0; index < a.length; index++) {
1088
+ const itemA = a[index];
1089
+ const itemB = b[index];
1090
+ const sharedValue = mergeValues(itemA, itemB);
1091
+ if (!sharedValue.valid) return {
1092
+ valid: false,
1093
+ mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
1094
+ };
1095
+ newArray.push(sharedValue.data);
1096
+ }
1097
+ return {
1098
+ valid: true,
1099
+ data: newArray
1100
+ };
1101
+ }
1102
+ return {
1103
+ valid: false,
1104
+ mergeErrorPath: []
1105
+ };
1106
+ }
1107
+ function handleIntersectionResults(result, left, right) {
1108
+ const unrecKeys = /* @__PURE__ */ new Map();
1109
+ let unrecIssue;
1110
+ for (const iss of left.issues) if (iss.code === "unrecognized_keys") {
1111
+ unrecIssue ?? (unrecIssue = iss);
1112
+ for (const k of iss.keys) {
1113
+ if (!unrecKeys.has(k)) unrecKeys.set(k, {});
1114
+ unrecKeys.get(k).l = true;
1115
+ }
1116
+ } else result.issues.push(iss);
1117
+ for (const iss of right.issues) if (iss.code === "unrecognized_keys") for (const k of iss.keys) {
1118
+ if (!unrecKeys.has(k)) unrecKeys.set(k, {});
1119
+ unrecKeys.get(k).r = true;
1120
+ }
1121
+ else result.issues.push(iss);
1122
+ const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
1123
+ if (bothKeys.length && unrecIssue) result.issues.push({
1124
+ ...unrecIssue,
1125
+ keys: bothKeys
1126
+ });
1127
+ if (aborted(result)) return result;
1128
+ const merged = mergeValues(left.value, right.value);
1129
+ if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
1130
+ result.value = merged.data;
1131
+ return result;
1132
+ }
1133
+ const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
1134
+ $ZodType.init(inst, def);
1135
+ const values = getEnumValues(def.entries);
1136
+ const valuesSet = new Set(values);
1137
+ inst._zod.values = valuesSet;
1138
+ inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
1139
+ inst._zod.parse = (payload, _ctx) => {
1140
+ const input = payload.value;
1141
+ if (valuesSet.has(input)) return payload;
1142
+ payload.issues.push({
1143
+ code: "invalid_value",
1144
+ values,
1145
+ input,
1146
+ inst
1147
+ });
1148
+ return payload;
1149
+ };
1150
+ });
1151
+ const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
1152
+ $ZodType.init(inst, def);
1153
+ inst._zod.parse = (payload, ctx) => {
1154
+ if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
1155
+ const _out = def.transform(payload.value, payload);
1156
+ if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
1157
+ payload.value = output;
1158
+ return payload;
1159
+ });
1160
+ if (_out instanceof Promise) throw new $ZodAsyncError();
1161
+ payload.value = _out;
1162
+ return payload;
1163
+ };
1164
+ });
1165
+ function handleOptionalResult(result, input) {
1166
+ if (result.issues.length && input === void 0) return {
1167
+ issues: [],
1168
+ value: void 0
1169
+ };
1170
+ return result;
1171
+ }
1172
+ const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
1173
+ $ZodType.init(inst, def);
1174
+ inst._zod.optin = "optional";
1175
+ inst._zod.optout = "optional";
1176
+ defineLazy(inst._zod, "values", () => {
1177
+ return def.innerType._zod.values ? new Set([...def.innerType._zod.values, void 0]) : void 0;
1178
+ });
1179
+ defineLazy(inst._zod, "pattern", () => {
1180
+ const pattern = def.innerType._zod.pattern;
1181
+ return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
1182
+ });
1183
+ inst._zod.parse = (payload, ctx) => {
1184
+ if (def.innerType._zod.optin === "optional") {
1185
+ const result = def.innerType._zod.run(payload, ctx);
1186
+ if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, payload.value));
1187
+ return handleOptionalResult(result, payload.value);
1188
+ }
1189
+ if (payload.value === void 0) return payload;
1190
+ return def.innerType._zod.run(payload, ctx);
1191
+ };
1192
+ });
1193
+ const $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
1194
+ $ZodOptional.init(inst, def);
1195
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1196
+ defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
1197
+ inst._zod.parse = (payload, ctx) => {
1198
+ return def.innerType._zod.run(payload, ctx);
1199
+ };
1200
+ });
1201
+ const $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
1202
+ $ZodType.init(inst, def);
1203
+ defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
1204
+ defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1205
+ defineLazy(inst._zod, "pattern", () => {
1206
+ const pattern = def.innerType._zod.pattern;
1207
+ return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
1208
+ });
1209
+ defineLazy(inst._zod, "values", () => {
1210
+ return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : void 0;
1211
+ });
1212
+ inst._zod.parse = (payload, ctx) => {
1213
+ if (payload.value === null) return payload;
1214
+ return def.innerType._zod.run(payload, ctx);
1215
+ };
1216
+ });
1217
+ const $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
1218
+ $ZodType.init(inst, def);
1219
+ inst._zod.optin = "optional";
1220
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1221
+ inst._zod.parse = (payload, ctx) => {
1222
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
1223
+ if (payload.value === void 0) {
1224
+ payload.value = def.defaultValue;
1225
+ /**
1226
+ * $ZodDefault returns the default value immediately in forward direction.
1227
+ * 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. */
1228
+ return payload;
1229
+ }
1230
+ const result = def.innerType._zod.run(payload, ctx);
1231
+ if (result instanceof Promise) return result.then((result) => handleDefaultResult(result, def));
1232
+ return handleDefaultResult(result, def);
1233
+ };
1234
+ });
1235
+ function handleDefaultResult(payload, def) {
1236
+ if (payload.value === void 0) payload.value = def.defaultValue;
1237
+ return payload;
1238
+ }
1239
+ const $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
1240
+ $ZodType.init(inst, def);
1241
+ inst._zod.optin = "optional";
1242
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1243
+ inst._zod.parse = (payload, ctx) => {
1244
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
1245
+ if (payload.value === void 0) payload.value = def.defaultValue;
1246
+ return def.innerType._zod.run(payload, ctx);
1247
+ };
1248
+ });
1249
+ const $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
1250
+ $ZodType.init(inst, def);
1251
+ defineLazy(inst._zod, "values", () => {
1252
+ const v = def.innerType._zod.values;
1253
+ return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
1254
+ });
1255
+ inst._zod.parse = (payload, ctx) => {
1256
+ const result = def.innerType._zod.run(payload, ctx);
1257
+ if (result instanceof Promise) return result.then((result) => handleNonOptionalResult(result, inst));
1258
+ return handleNonOptionalResult(result, inst);
1259
+ };
1260
+ });
1261
+ function handleNonOptionalResult(payload, inst) {
1262
+ if (!payload.issues.length && payload.value === void 0) payload.issues.push({
1263
+ code: "invalid_type",
1264
+ expected: "nonoptional",
1265
+ input: payload.value,
1266
+ inst
1267
+ });
1268
+ return payload;
1269
+ }
1270
+ const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
1271
+ $ZodType.init(inst, def);
1272
+ defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
1273
+ defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1274
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1275
+ inst._zod.parse = (payload, ctx) => {
1276
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
1277
+ const result = def.innerType._zod.run(payload, ctx);
1278
+ if (result instanceof Promise) return result.then((result) => {
1279
+ payload.value = result.value;
1280
+ if (result.issues.length) {
1281
+ payload.value = def.catchValue({
1282
+ ...payload,
1283
+ error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
1284
+ input: payload.value
1285
+ });
1286
+ payload.issues = [];
1287
+ }
1288
+ return payload;
1289
+ });
1290
+ payload.value = result.value;
1291
+ if (result.issues.length) {
1292
+ payload.value = def.catchValue({
1293
+ ...payload,
1294
+ error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
1295
+ input: payload.value
1296
+ });
1297
+ payload.issues = [];
1298
+ }
1299
+ return payload;
1300
+ };
1301
+ });
1302
+ const $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
1303
+ $ZodType.init(inst, def);
1304
+ defineLazy(inst._zod, "values", () => def.in._zod.values);
1305
+ defineLazy(inst._zod, "optin", () => def.in._zod.optin);
1306
+ defineLazy(inst._zod, "optout", () => def.out._zod.optout);
1307
+ defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
1308
+ inst._zod.parse = (payload, ctx) => {
1309
+ if (ctx.direction === "backward") {
1310
+ const right = def.out._zod.run(payload, ctx);
1311
+ if (right instanceof Promise) return right.then((right) => handlePipeResult(right, def.in, ctx));
1312
+ return handlePipeResult(right, def.in, ctx);
1313
+ }
1314
+ const left = def.in._zod.run(payload, ctx);
1315
+ if (left instanceof Promise) return left.then((left) => handlePipeResult(left, def.out, ctx));
1316
+ return handlePipeResult(left, def.out, ctx);
1317
+ };
1318
+ });
1319
+ function handlePipeResult(left, next, ctx) {
1320
+ if (left.issues.length) {
1321
+ left.aborted = true;
1322
+ return left;
1323
+ }
1324
+ return next._zod.run({
1325
+ value: left.value,
1326
+ issues: left.issues
1327
+ }, ctx);
1328
+ }
1329
+ const $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
1330
+ $ZodType.init(inst, def);
1331
+ defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
1332
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1333
+ defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
1334
+ defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
1335
+ inst._zod.parse = (payload, ctx) => {
1336
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
1337
+ const result = def.innerType._zod.run(payload, ctx);
1338
+ if (result instanceof Promise) return result.then(handleReadonlyResult);
1339
+ return handleReadonlyResult(result);
1340
+ };
1341
+ });
1342
+ function handleReadonlyResult(payload) {
1343
+ payload.value = Object.freeze(payload.value);
1344
+ return payload;
1345
+ }
1346
+ const $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
1347
+ $ZodCheck.init(inst, def);
1348
+ $ZodType.init(inst, def);
1349
+ inst._zod.parse = (payload, _) => {
1350
+ return payload;
1351
+ };
1352
+ inst._zod.check = (payload) => {
1353
+ const input = payload.value;
1354
+ const r = def.fn(input);
1355
+ if (r instanceof Promise) return r.then((r) => handleRefineResult(r, payload, input, inst));
1356
+ handleRefineResult(r, payload, input, inst);
1357
+ };
1358
+ });
1359
+ function handleRefineResult(result, payload, input, inst) {
1360
+ if (!result) {
1361
+ const _iss = {
1362
+ code: "custom",
1363
+ input,
1364
+ inst,
1365
+ path: [...inst._zod.def.path ?? []],
1366
+ continue: !inst._zod.def.abort
1367
+ };
1368
+ if (inst._zod.def.params) _iss.params = inst._zod.def.params;
1369
+ payload.issues.push(issue(_iss));
1370
+ }
1371
+ }
1372
+ //#endregion
1373
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/registries.js
1374
+ var _a;
1375
+ var $ZodRegistry = class {
1376
+ constructor() {
1377
+ this._map = /* @__PURE__ */ new WeakMap();
1378
+ this._idmap = /* @__PURE__ */ new Map();
1379
+ }
1380
+ add(schema, ..._meta) {
1381
+ const meta = _meta[0];
1382
+ this._map.set(schema, meta);
1383
+ if (meta && typeof meta === "object" && "id" in meta) this._idmap.set(meta.id, schema);
1384
+ return this;
1385
+ }
1386
+ clear() {
1387
+ this._map = /* @__PURE__ */ new WeakMap();
1388
+ this._idmap = /* @__PURE__ */ new Map();
1389
+ return this;
1390
+ }
1391
+ remove(schema) {
1392
+ const meta = this._map.get(schema);
1393
+ if (meta && typeof meta === "object" && "id" in meta) this._idmap.delete(meta.id);
1394
+ this._map.delete(schema);
1395
+ return this;
1396
+ }
1397
+ get(schema) {
1398
+ const p = schema._zod.parent;
1399
+ if (p) {
1400
+ const pm = { ...this.get(p) ?? {} };
1401
+ delete pm.id;
1402
+ const f = {
1403
+ ...pm,
1404
+ ...this._map.get(schema)
1405
+ };
1406
+ return Object.keys(f).length ? f : void 0;
1407
+ }
1408
+ return this._map.get(schema);
1409
+ }
1410
+ has(schema) {
1411
+ return this._map.has(schema);
1412
+ }
1413
+ };
1414
+ function registry() {
1415
+ return new $ZodRegistry();
1416
+ }
1417
+ (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
1418
+ const globalRegistry = globalThis.__zod_globalRegistry;
1419
+ //#endregion
1420
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/api.js
1421
+ /* @__NO_SIDE_EFFECTS__ */
1422
+ function _unknown(Class) {
1423
+ return new Class({ type: "unknown" });
1424
+ }
1425
+ /* @__NO_SIDE_EFFECTS__ */
1426
+ function _never(Class, params) {
1427
+ return new Class({
1428
+ type: "never",
1429
+ ...normalizeParams(params)
1430
+ });
1431
+ }
1432
+ /* @__NO_SIDE_EFFECTS__ */
1433
+ function _maxLength(maximum, params) {
1434
+ return new $ZodCheckMaxLength({
1435
+ check: "max_length",
1436
+ ...normalizeParams(params),
1437
+ maximum
1438
+ });
1439
+ }
1440
+ /* @__NO_SIDE_EFFECTS__ */
1441
+ function _minLength(minimum, params) {
1442
+ return new $ZodCheckMinLength({
1443
+ check: "min_length",
1444
+ ...normalizeParams(params),
1445
+ minimum
1446
+ });
1447
+ }
1448
+ /* @__NO_SIDE_EFFECTS__ */
1449
+ function _length(length, params) {
1450
+ return new $ZodCheckLengthEquals({
1451
+ check: "length_equals",
1452
+ ...normalizeParams(params),
1453
+ length
1454
+ });
1455
+ }
1456
+ /* @__NO_SIDE_EFFECTS__ */
1457
+ function _overwrite(tx) {
1458
+ return new $ZodCheckOverwrite({
1459
+ check: "overwrite",
1460
+ tx
1461
+ });
1462
+ }
1463
+ /* @__NO_SIDE_EFFECTS__ */
1464
+ function _array(Class, element, params) {
1465
+ return new Class({
1466
+ type: "array",
1467
+ element,
1468
+ ...normalizeParams(params)
1469
+ });
1470
+ }
1471
+ /* @__NO_SIDE_EFFECTS__ */
1472
+ function _refine(Class, fn, _params) {
1473
+ return new Class({
1474
+ type: "custom",
1475
+ check: "custom",
1476
+ fn,
1477
+ ...normalizeParams(_params)
1478
+ });
1479
+ }
1480
+ /* @__NO_SIDE_EFFECTS__ */
1481
+ function _superRefine(fn) {
1482
+ const ch = /* @__PURE__ */ _check((payload) => {
1483
+ payload.addIssue = (issue$2) => {
1484
+ if (typeof issue$2 === "string") payload.issues.push(issue(issue$2, payload.value, ch._zod.def));
1485
+ else {
1486
+ const _issue = issue$2;
1487
+ if (_issue.fatal) _issue.continue = false;
1488
+ _issue.code ?? (_issue.code = "custom");
1489
+ _issue.input ?? (_issue.input = payload.value);
1490
+ _issue.inst ?? (_issue.inst = ch);
1491
+ _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
1492
+ payload.issues.push(issue(_issue));
1493
+ }
1494
+ };
1495
+ return fn(payload.value, payload);
1496
+ });
1497
+ return ch;
1498
+ }
1499
+ /* @__NO_SIDE_EFFECTS__ */
1500
+ function _check(fn, params) {
1501
+ const ch = new $ZodCheck({
1502
+ check: "custom",
1503
+ ...normalizeParams(params)
1504
+ });
1505
+ ch._zod.check = fn;
1506
+ return ch;
1507
+ }
1508
+ //#endregion
1509
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/to-json-schema.js
1510
+ function initializeContext(params) {
1511
+ let target = params?.target ?? "draft-2020-12";
1512
+ if (target === "draft-4") target = "draft-04";
1513
+ if (target === "draft-7") target = "draft-07";
1514
+ return {
1515
+ processors: params.processors ?? {},
1516
+ metadataRegistry: params?.metadata ?? globalRegistry,
1517
+ target,
1518
+ unrepresentable: params?.unrepresentable ?? "throw",
1519
+ override: params?.override ?? (() => {}),
1520
+ io: params?.io ?? "output",
1521
+ counter: 0,
1522
+ seen: /* @__PURE__ */ new Map(),
1523
+ cycles: params?.cycles ?? "ref",
1524
+ reused: params?.reused ?? "inline",
1525
+ external: params?.external ?? void 0
1526
+ };
1527
+ }
1528
+ function process(schema, ctx, _params = {
1529
+ path: [],
1530
+ schemaPath: []
1531
+ }) {
1532
+ var _a;
1533
+ const def = schema._zod.def;
1534
+ const seen = ctx.seen.get(schema);
1535
+ if (seen) {
1536
+ seen.count++;
1537
+ if (_params.schemaPath.includes(schema)) seen.cycle = _params.path;
1538
+ return seen.schema;
1539
+ }
1540
+ const result = {
1541
+ schema: {},
1542
+ count: 1,
1543
+ cycle: void 0,
1544
+ path: _params.path
1545
+ };
1546
+ ctx.seen.set(schema, result);
1547
+ const overrideSchema = schema._zod.toJSONSchema?.();
1548
+ if (overrideSchema) result.schema = overrideSchema;
1549
+ else {
1550
+ const params = {
1551
+ ..._params,
1552
+ schemaPath: [..._params.schemaPath, schema],
1553
+ path: _params.path
1554
+ };
1555
+ if (schema._zod.processJSONSchema) schema._zod.processJSONSchema(ctx, result.schema, params);
1556
+ else {
1557
+ const _json = result.schema;
1558
+ const processor = ctx.processors[def.type];
1559
+ if (!processor) throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
1560
+ processor(schema, ctx, _json, params);
1561
+ }
1562
+ const parent = schema._zod.parent;
1563
+ if (parent) {
1564
+ if (!result.ref) result.ref = parent;
1565
+ process(parent, ctx, params);
1566
+ ctx.seen.get(parent).isParent = true;
1567
+ }
1568
+ }
1569
+ const meta = ctx.metadataRegistry.get(schema);
1570
+ if (meta) Object.assign(result.schema, meta);
1571
+ if (ctx.io === "input" && isTransforming(schema)) {
1572
+ delete result.schema.examples;
1573
+ delete result.schema.default;
1574
+ }
1575
+ if (ctx.io === "input" && result.schema._prefault) (_a = result.schema).default ?? (_a.default = result.schema._prefault);
1576
+ delete result.schema._prefault;
1577
+ return ctx.seen.get(schema).schema;
1578
+ }
1579
+ function extractDefs(ctx, schema) {
1580
+ const root = ctx.seen.get(schema);
1581
+ if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
1582
+ const idToSchema = /* @__PURE__ */ new Map();
1583
+ for (const entry of ctx.seen.entries()) {
1584
+ const id = ctx.metadataRegistry.get(entry[0])?.id;
1585
+ if (id) {
1586
+ const existing = idToSchema.get(id);
1587
+ 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.`);
1588
+ idToSchema.set(id, entry[0]);
1589
+ }
1590
+ }
1591
+ const makeURI = (entry) => {
1592
+ const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
1593
+ if (ctx.external) {
1594
+ const externalId = ctx.external.registry.get(entry[0])?.id;
1595
+ const uriGenerator = ctx.external.uri ?? ((id) => id);
1596
+ if (externalId) return { ref: uriGenerator(externalId) };
1597
+ const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
1598
+ entry[1].defId = id;
1599
+ return {
1600
+ defId: id,
1601
+ ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
1602
+ };
1603
+ }
1604
+ if (entry[1] === root) return { ref: "#" };
1605
+ const defUriPrefix = `#/${defsSegment}/`;
1606
+ const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
1607
+ return {
1608
+ defId,
1609
+ ref: defUriPrefix + defId
1610
+ };
1611
+ };
1612
+ const extractToDef = (entry) => {
1613
+ if (entry[1].schema.$ref) return;
1614
+ const seen = entry[1];
1615
+ const { ref, defId } = makeURI(entry);
1616
+ seen.def = { ...seen.schema };
1617
+ if (defId) seen.defId = defId;
1618
+ const schema = seen.schema;
1619
+ for (const key in schema) delete schema[key];
1620
+ schema.$ref = ref;
1621
+ };
1622
+ if (ctx.cycles === "throw") for (const entry of ctx.seen.entries()) {
1623
+ const seen = entry[1];
1624
+ if (seen.cycle) throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
1625
+
1626
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
1627
+ }
1628
+ for (const entry of ctx.seen.entries()) {
1629
+ const seen = entry[1];
1630
+ if (schema === entry[0]) {
1631
+ extractToDef(entry);
1632
+ continue;
1633
+ }
1634
+ if (ctx.external) {
1635
+ const ext = ctx.external.registry.get(entry[0])?.id;
1636
+ if (schema !== entry[0] && ext) {
1637
+ extractToDef(entry);
1638
+ continue;
1639
+ }
1640
+ }
1641
+ if (ctx.metadataRegistry.get(entry[0])?.id) {
1642
+ extractToDef(entry);
1643
+ continue;
1644
+ }
1645
+ if (seen.cycle) {
1646
+ extractToDef(entry);
1647
+ continue;
1648
+ }
1649
+ if (seen.count > 1) {
1650
+ if (ctx.reused === "ref") {
1651
+ extractToDef(entry);
1652
+ continue;
1653
+ }
1654
+ }
1655
+ }
1656
+ }
1657
+ function finalize(ctx, schema) {
1658
+ const root = ctx.seen.get(schema);
1659
+ if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
1660
+ const flattenRef = (zodSchema) => {
1661
+ const seen = ctx.seen.get(zodSchema);
1662
+ if (seen.ref === null) return;
1663
+ const schema = seen.def ?? seen.schema;
1664
+ const _cached = { ...schema };
1665
+ const ref = seen.ref;
1666
+ seen.ref = null;
1667
+ if (ref) {
1668
+ flattenRef(ref);
1669
+ const refSeen = ctx.seen.get(ref);
1670
+ const refSchema = refSeen.schema;
1671
+ if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
1672
+ schema.allOf = schema.allOf ?? [];
1673
+ schema.allOf.push(refSchema);
1674
+ } else Object.assign(schema, refSchema);
1675
+ Object.assign(schema, _cached);
1676
+ if (zodSchema._zod.parent === ref) for (const key in schema) {
1677
+ if (key === "$ref" || key === "allOf") continue;
1678
+ if (!(key in _cached)) delete schema[key];
1679
+ }
1680
+ if (refSchema.$ref && refSeen.def) for (const key in schema) {
1681
+ if (key === "$ref" || key === "allOf") continue;
1682
+ if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) delete schema[key];
1683
+ }
1684
+ }
1685
+ const parent = zodSchema._zod.parent;
1686
+ if (parent && parent !== ref) {
1687
+ flattenRef(parent);
1688
+ const parentSeen = ctx.seen.get(parent);
1689
+ if (parentSeen?.schema.$ref) {
1690
+ schema.$ref = parentSeen.schema.$ref;
1691
+ if (parentSeen.def) for (const key in schema) {
1692
+ if (key === "$ref" || key === "allOf") continue;
1693
+ if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) delete schema[key];
1694
+ }
1695
+ }
1696
+ }
1697
+ ctx.override({
1698
+ zodSchema,
1699
+ jsonSchema: schema,
1700
+ path: seen.path ?? []
1701
+ });
1702
+ };
1703
+ for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
1704
+ const result = {};
1705
+ if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
1706
+ else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
1707
+ else if (ctx.target === "draft-04") result.$schema = "http://json-schema.org/draft-04/schema#";
1708
+ else if (ctx.target === "openapi-3.0") {}
1709
+ if (ctx.external?.uri) {
1710
+ const id = ctx.external.registry.get(schema)?.id;
1711
+ if (!id) throw new Error("Schema is missing an `id` property");
1712
+ result.$id = ctx.external.uri(id);
1713
+ }
1714
+ Object.assign(result, root.def ?? root.schema);
1715
+ const defs = ctx.external?.defs ?? {};
1716
+ for (const entry of ctx.seen.entries()) {
1717
+ const seen = entry[1];
1718
+ if (seen.def && seen.defId) defs[seen.defId] = seen.def;
1719
+ }
1720
+ if (ctx.external) {} else if (Object.keys(defs).length > 0) if (ctx.target === "draft-2020-12") result.$defs = defs;
1721
+ else result.definitions = defs;
1722
+ try {
1723
+ const finalized = JSON.parse(JSON.stringify(result));
1724
+ Object.defineProperty(finalized, "~standard", {
1725
+ value: {
1726
+ ...schema["~standard"],
1727
+ jsonSchema: {
1728
+ input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
1729
+ output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
1730
+ }
1731
+ },
1732
+ enumerable: false,
1733
+ writable: false
1734
+ });
1735
+ return finalized;
1736
+ } catch (_err) {
1737
+ throw new Error("Error converting schema to JSON.");
1738
+ }
1739
+ }
1740
+ function isTransforming(_schema, _ctx) {
1741
+ const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
1742
+ if (ctx.seen.has(_schema)) return false;
1743
+ ctx.seen.add(_schema);
1744
+ const def = _schema._zod.def;
1745
+ if (def.type === "transform") return true;
1746
+ if (def.type === "array") return isTransforming(def.element, ctx);
1747
+ if (def.type === "set") return isTransforming(def.valueType, ctx);
1748
+ if (def.type === "lazy") return isTransforming(def.getter(), ctx);
1749
+ 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);
1750
+ if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
1751
+ if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
1752
+ if (def.type === "pipe") return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
1753
+ if (def.type === "object") {
1754
+ for (const key in def.shape) if (isTransforming(def.shape[key], ctx)) return true;
1755
+ return false;
1756
+ }
1757
+ if (def.type === "union") {
1758
+ for (const option of def.options) if (isTransforming(option, ctx)) return true;
1759
+ return false;
1760
+ }
1761
+ if (def.type === "tuple") {
1762
+ for (const item of def.items) if (isTransforming(item, ctx)) return true;
1763
+ if (def.rest && isTransforming(def.rest, ctx)) return true;
1764
+ return false;
1765
+ }
1766
+ return false;
1767
+ }
1768
+ /**
1769
+ * Creates a toJSONSchema method for a schema instance.
1770
+ * This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
1771
+ */
1772
+ const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
1773
+ const ctx = initializeContext({
1774
+ ...params,
1775
+ processors
1776
+ });
1777
+ process(schema, ctx);
1778
+ extractDefs(ctx, schema);
1779
+ return finalize(ctx, schema);
1780
+ };
1781
+ const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
1782
+ const { libraryOptions, target } = params ?? {};
1783
+ const ctx = initializeContext({
1784
+ ...libraryOptions ?? {},
1785
+ target,
1786
+ io,
1787
+ processors
1788
+ });
1789
+ process(schema, ctx);
1790
+ extractDefs(ctx, schema);
1791
+ return finalize(ctx, schema);
1792
+ };
1793
+ //#endregion
1794
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema-processors.js
1795
+ const neverProcessor = (_schema, _ctx, json, _params) => {
1796
+ json.not = {};
1797
+ };
1798
+ const unknownProcessor = (_schema, _ctx, _json, _params) => {};
1799
+ const enumProcessor = (schema, _ctx, json, _params) => {
1800
+ const def = schema._zod.def;
1801
+ const values = getEnumValues(def.entries);
1802
+ if (values.every((v) => typeof v === "number")) json.type = "number";
1803
+ if (values.every((v) => typeof v === "string")) json.type = "string";
1804
+ json.enum = values;
1805
+ };
1806
+ const customProcessor = (_schema, ctx, _json, _params) => {
1807
+ if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
1808
+ };
1809
+ const transformProcessor = (_schema, ctx, _json, _params) => {
1810
+ if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
1811
+ };
1812
+ const arrayProcessor = (schema, ctx, _json, params) => {
1813
+ const json = _json;
1814
+ const def = schema._zod.def;
1815
+ const { minimum, maximum } = schema._zod.bag;
1816
+ if (typeof minimum === "number") json.minItems = minimum;
1817
+ if (typeof maximum === "number") json.maxItems = maximum;
1818
+ json.type = "array";
1819
+ json.items = process(def.element, ctx, {
1820
+ ...params,
1821
+ path: [...params.path, "items"]
1822
+ });
1823
+ };
1824
+ const objectProcessor = (schema, ctx, _json, params) => {
1825
+ const json = _json;
1826
+ const def = schema._zod.def;
1827
+ json.type = "object";
1828
+ json.properties = {};
1829
+ const shape = def.shape;
1830
+ for (const key in shape) json.properties[key] = process(shape[key], ctx, {
1831
+ ...params,
1832
+ path: [
1833
+ ...params.path,
1834
+ "properties",
1835
+ key
1836
+ ]
1837
+ });
1838
+ const allKeys = new Set(Object.keys(shape));
1839
+ const requiredKeys = new Set([...allKeys].filter((key) => {
1840
+ const v = def.shape[key]._zod;
1841
+ if (ctx.io === "input") return v.optin === void 0;
1842
+ else return v.optout === void 0;
1843
+ }));
1844
+ if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
1845
+ if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
1846
+ else if (!def.catchall) {
1847
+ if (ctx.io === "output") json.additionalProperties = false;
1848
+ } else if (def.catchall) json.additionalProperties = process(def.catchall, ctx, {
1849
+ ...params,
1850
+ path: [...params.path, "additionalProperties"]
1851
+ });
1852
+ };
1853
+ const unionProcessor = (schema, ctx, json, params) => {
1854
+ const def = schema._zod.def;
1855
+ const isExclusive = def.inclusive === false;
1856
+ const options = def.options.map((x, i) => process(x, ctx, {
1857
+ ...params,
1858
+ path: [
1859
+ ...params.path,
1860
+ isExclusive ? "oneOf" : "anyOf",
1861
+ i
1862
+ ]
1863
+ }));
1864
+ if (isExclusive) json.oneOf = options;
1865
+ else json.anyOf = options;
1866
+ };
1867
+ const intersectionProcessor = (schema, ctx, json, params) => {
1868
+ const def = schema._zod.def;
1869
+ const a = process(def.left, ctx, {
1870
+ ...params,
1871
+ path: [
1872
+ ...params.path,
1873
+ "allOf",
1874
+ 0
1875
+ ]
1876
+ });
1877
+ const b = process(def.right, ctx, {
1878
+ ...params,
1879
+ path: [
1880
+ ...params.path,
1881
+ "allOf",
1882
+ 1
1883
+ ]
1884
+ });
1885
+ const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
1886
+ json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
1887
+ };
1888
+ const nullableProcessor = (schema, ctx, json, params) => {
1889
+ const def = schema._zod.def;
1890
+ const inner = process(def.innerType, ctx, params);
1891
+ const seen = ctx.seen.get(schema);
1892
+ if (ctx.target === "openapi-3.0") {
1893
+ seen.ref = def.innerType;
1894
+ json.nullable = true;
1895
+ } else json.anyOf = [inner, { type: "null" }];
1896
+ };
1897
+ const nonoptionalProcessor = (schema, ctx, _json, params) => {
1898
+ const def = schema._zod.def;
1899
+ process(def.innerType, ctx, params);
1900
+ const seen = ctx.seen.get(schema);
1901
+ seen.ref = def.innerType;
1902
+ };
1903
+ const defaultProcessor = (schema, ctx, json, params) => {
1904
+ const def = schema._zod.def;
1905
+ process(def.innerType, ctx, params);
1906
+ const seen = ctx.seen.get(schema);
1907
+ seen.ref = def.innerType;
1908
+ json.default = JSON.parse(JSON.stringify(def.defaultValue));
1909
+ };
1910
+ const prefaultProcessor = (schema, ctx, json, params) => {
1911
+ const def = schema._zod.def;
1912
+ process(def.innerType, ctx, params);
1913
+ const seen = ctx.seen.get(schema);
1914
+ seen.ref = def.innerType;
1915
+ if (ctx.io === "input") json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
1916
+ };
1917
+ const catchProcessor = (schema, ctx, json, params) => {
1918
+ const def = schema._zod.def;
1919
+ process(def.innerType, ctx, params);
1920
+ const seen = ctx.seen.get(schema);
1921
+ seen.ref = def.innerType;
1922
+ let catchValue;
1923
+ try {
1924
+ catchValue = def.catchValue(void 0);
1925
+ } catch {
1926
+ throw new Error("Dynamic catch values are not supported in JSON Schema");
1927
+ }
1928
+ json.default = catchValue;
1929
+ };
1930
+ const pipeProcessor = (schema, ctx, _json, params) => {
1931
+ const def = schema._zod.def;
1932
+ const innerType = ctx.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
1933
+ process(innerType, ctx, params);
1934
+ const seen = ctx.seen.get(schema);
1935
+ seen.ref = innerType;
1936
+ };
1937
+ const readonlyProcessor = (schema, ctx, json, params) => {
1938
+ const def = schema._zod.def;
1939
+ process(def.innerType, ctx, params);
1940
+ const seen = ctx.seen.get(schema);
1941
+ seen.ref = def.innerType;
1942
+ json.readOnly = true;
1943
+ };
1944
+ const optionalProcessor = (schema, ctx, _json, params) => {
1945
+ const def = schema._zod.def;
1946
+ process(def.innerType, ctx, params);
1947
+ const seen = ctx.seen.get(schema);
1948
+ seen.ref = def.innerType;
1949
+ };
1950
+ //#endregion
1951
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/errors.js
1952
+ const initializer = (inst, issues) => {
1953
+ $ZodError.init(inst, issues);
1954
+ inst.name = "ZodError";
1955
+ Object.defineProperties(inst, {
1956
+ format: { value: (mapper) => formatError(inst, mapper) },
1957
+ flatten: { value: (mapper) => flattenError(inst, mapper) },
1958
+ addIssue: { value: (issue) => {
1959
+ inst.issues.push(issue);
1960
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
1961
+ } },
1962
+ addIssues: { value: (issues) => {
1963
+ inst.issues.push(...issues);
1964
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
1965
+ } },
1966
+ isEmpty: { get() {
1967
+ return inst.issues.length === 0;
1968
+ } }
1969
+ });
1970
+ };
1971
+ $constructor("ZodError", initializer);
1972
+ const ZodRealError = $constructor("ZodError", initializer, { Parent: Error });
1973
+ //#endregion
1974
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/parse.js
1975
+ const parse = /* @__PURE__ */ _parse(ZodRealError);
1976
+ const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
1977
+ const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
1978
+ const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
1979
+ const encode = /* @__PURE__ */ _encode(ZodRealError);
1980
+ const decode = /* @__PURE__ */ _decode(ZodRealError);
1981
+ const encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
1982
+ const decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
1983
+ const safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
1984
+ const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
1985
+ const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
1986
+ const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
1987
+ //#endregion
1988
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/schemas.js
1989
+ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
1990
+ $ZodType.init(inst, def);
1991
+ Object.assign(inst["~standard"], { jsonSchema: {
1992
+ input: createStandardJSONSchemaMethod(inst, "input"),
1993
+ output: createStandardJSONSchemaMethod(inst, "output")
1994
+ } });
1995
+ inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
1996
+ inst.def = def;
1997
+ inst.type = def.type;
1998
+ Object.defineProperty(inst, "_def", { value: def });
1999
+ inst.check = (...checks) => {
2000
+ return inst.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...checks.map((ch) => typeof ch === "function" ? { _zod: {
2001
+ check: ch,
2002
+ def: { check: "custom" },
2003
+ onattach: []
2004
+ } } : ch)] }), { parent: true });
2005
+ };
2006
+ inst.with = inst.check;
2007
+ inst.clone = (def, params) => clone(inst, def, params);
2008
+ inst.brand = () => inst;
2009
+ inst.register = ((reg, meta) => {
2010
+ reg.add(inst, meta);
2011
+ return inst;
2012
+ });
2013
+ inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
2014
+ inst.safeParse = (data, params) => safeParse(inst, data, params);
2015
+ inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
2016
+ inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
2017
+ inst.spa = inst.safeParseAsync;
2018
+ inst.encode = (data, params) => encode(inst, data, params);
2019
+ inst.decode = (data, params) => decode(inst, data, params);
2020
+ inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
2021
+ inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
2022
+ inst.safeEncode = (data, params) => safeEncode(inst, data, params);
2023
+ inst.safeDecode = (data, params) => safeDecode(inst, data, params);
2024
+ inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
2025
+ inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
2026
+ inst.refine = (check, params) => inst.check(refine(check, params));
2027
+ inst.superRefine = (refinement) => inst.check(superRefine(refinement));
2028
+ inst.overwrite = (fn) => inst.check(/* @__PURE__ */ _overwrite(fn));
2029
+ inst.optional = () => optional(inst);
2030
+ inst.exactOptional = () => exactOptional(inst);
2031
+ inst.nullable = () => nullable(inst);
2032
+ inst.nullish = () => optional(nullable(inst));
2033
+ inst.nonoptional = (params) => nonoptional(inst, params);
2034
+ inst.array = () => array(inst);
2035
+ inst.or = (arg) => union([inst, arg]);
2036
+ inst.and = (arg) => intersection(inst, arg);
2037
+ inst.transform = (tx) => pipe(inst, transform(tx));
2038
+ inst.default = (def) => _default(inst, def);
2039
+ inst.prefault = (def) => prefault(inst, def);
2040
+ inst.catch = (params) => _catch(inst, params);
2041
+ inst.pipe = (target) => pipe(inst, target);
2042
+ inst.readonly = () => readonly(inst);
2043
+ inst.describe = (description) => {
2044
+ const cl = inst.clone();
2045
+ globalRegistry.add(cl, { description });
2046
+ return cl;
2047
+ };
2048
+ Object.defineProperty(inst, "description", {
2049
+ get() {
2050
+ return globalRegistry.get(inst)?.description;
2051
+ },
2052
+ configurable: true
2053
+ });
2054
+ inst.meta = (...args) => {
2055
+ if (args.length === 0) return globalRegistry.get(inst);
2056
+ const cl = inst.clone();
2057
+ globalRegistry.add(cl, args[0]);
2058
+ return cl;
2059
+ };
2060
+ inst.isOptional = () => inst.safeParse(void 0).success;
2061
+ inst.isNullable = () => inst.safeParse(null).success;
2062
+ inst.apply = (fn) => fn(inst);
2063
+ return inst;
2064
+ });
2065
+ const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
2066
+ $ZodUnknown.init(inst, def);
2067
+ ZodType.init(inst, def);
2068
+ inst._zod.processJSONSchema = (ctx, json, params) => unknownProcessor(inst, ctx, json, params);
2069
+ });
2070
+ function unknown() {
2071
+ return /* @__PURE__ */ _unknown(ZodUnknown);
2072
+ }
2073
+ const ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
2074
+ $ZodNever.init(inst, def);
2075
+ ZodType.init(inst, def);
2076
+ inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json, params);
2077
+ });
2078
+ function never(params) {
2079
+ return /* @__PURE__ */ _never(ZodNever, params);
2080
+ }
2081
+ const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
2082
+ $ZodArray.init(inst, def);
2083
+ ZodType.init(inst, def);
2084
+ inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
2085
+ inst.element = def.element;
2086
+ inst.min = (minLength, params) => inst.check(/* @__PURE__ */ _minLength(minLength, params));
2087
+ inst.nonempty = (params) => inst.check(/* @__PURE__ */ _minLength(1, params));
2088
+ inst.max = (maxLength, params) => inst.check(/* @__PURE__ */ _maxLength(maxLength, params));
2089
+ inst.length = (len, params) => inst.check(/* @__PURE__ */ _length(len, params));
2090
+ inst.unwrap = () => inst.element;
2091
+ });
2092
+ function array(element, params) {
2093
+ return /* @__PURE__ */ _array(ZodArray, element, params);
2094
+ }
2095
+ const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
2096
+ $ZodObjectJIT.init(inst, def);
2097
+ ZodType.init(inst, def);
2098
+ inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
2099
+ defineLazy(inst, "shape", () => {
2100
+ return def.shape;
2101
+ });
2102
+ inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
2103
+ inst.catchall = (catchall) => inst.clone({
2104
+ ...inst._zod.def,
2105
+ catchall
2106
+ });
2107
+ inst.passthrough = () => inst.clone({
2108
+ ...inst._zod.def,
2109
+ catchall: unknown()
2110
+ });
2111
+ inst.loose = () => inst.clone({
2112
+ ...inst._zod.def,
2113
+ catchall: unknown()
2114
+ });
2115
+ inst.strict = () => inst.clone({
2116
+ ...inst._zod.def,
2117
+ catchall: never()
2118
+ });
2119
+ inst.strip = () => inst.clone({
2120
+ ...inst._zod.def,
2121
+ catchall: void 0
2122
+ });
2123
+ inst.extend = (incoming) => {
2124
+ return extend(inst, incoming);
2125
+ };
2126
+ inst.safeExtend = (incoming) => {
2127
+ return safeExtend(inst, incoming);
2128
+ };
2129
+ inst.merge = (other) => merge(inst, other);
2130
+ inst.pick = (mask) => pick(inst, mask);
2131
+ inst.omit = (mask) => omit(inst, mask);
2132
+ inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
2133
+ inst.required = (...args) => required(ZodNonOptional, inst, args[0]);
2134
+ });
2135
+ function object(shape, params) {
2136
+ return new ZodObject({
2137
+ type: "object",
2138
+ shape: shape ?? {},
2139
+ ...normalizeParams(params)
2140
+ });
2141
+ }
2142
+ const ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
2143
+ $ZodUnion.init(inst, def);
2144
+ ZodType.init(inst, def);
2145
+ inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
2146
+ inst.options = def.options;
2147
+ });
2148
+ function union(options, params) {
2149
+ return new ZodUnion({
2150
+ type: "union",
2151
+ options,
2152
+ ...normalizeParams(params)
2153
+ });
2154
+ }
2155
+ const ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
2156
+ $ZodIntersection.init(inst, def);
2157
+ ZodType.init(inst, def);
2158
+ inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
2159
+ });
2160
+ function intersection(left, right) {
2161
+ return new ZodIntersection({
2162
+ type: "intersection",
2163
+ left,
2164
+ right
2165
+ });
2166
+ }
2167
+ const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
2168
+ $ZodEnum.init(inst, def);
2169
+ ZodType.init(inst, def);
2170
+ inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
2171
+ inst.enum = def.entries;
2172
+ inst.options = Object.values(def.entries);
2173
+ const keys = new Set(Object.keys(def.entries));
2174
+ inst.extract = (values, params) => {
2175
+ const newEntries = {};
2176
+ for (const value of values) if (keys.has(value)) newEntries[value] = def.entries[value];
2177
+ else throw new Error(`Key ${value} not found in enum`);
2178
+ return new ZodEnum({
2179
+ ...def,
2180
+ checks: [],
2181
+ ...normalizeParams(params),
2182
+ entries: newEntries
2183
+ });
2184
+ };
2185
+ inst.exclude = (values, params) => {
2186
+ const newEntries = { ...def.entries };
2187
+ for (const value of values) if (keys.has(value)) delete newEntries[value];
2188
+ else throw new Error(`Key ${value} not found in enum`);
2189
+ return new ZodEnum({
2190
+ ...def,
2191
+ checks: [],
2192
+ ...normalizeParams(params),
2193
+ entries: newEntries
2194
+ });
2195
+ };
2196
+ });
2197
+ function _enum(values, params) {
2198
+ return new ZodEnum({
2199
+ type: "enum",
2200
+ entries: Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values,
2201
+ ...normalizeParams(params)
2202
+ });
2203
+ }
2204
+ const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
2205
+ $ZodTransform.init(inst, def);
2206
+ ZodType.init(inst, def);
2207
+ inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
2208
+ inst._zod.parse = (payload, _ctx) => {
2209
+ if (_ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
2210
+ payload.addIssue = (issue$1) => {
2211
+ if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, def));
2212
+ else {
2213
+ const _issue = issue$1;
2214
+ if (_issue.fatal) _issue.continue = false;
2215
+ _issue.code ?? (_issue.code = "custom");
2216
+ _issue.input ?? (_issue.input = payload.value);
2217
+ _issue.inst ?? (_issue.inst = inst);
2218
+ payload.issues.push(issue(_issue));
2219
+ }
2220
+ };
2221
+ const output = def.transform(payload.value, payload);
2222
+ if (output instanceof Promise) return output.then((output) => {
2223
+ payload.value = output;
2224
+ return payload;
2225
+ });
2226
+ payload.value = output;
2227
+ return payload;
2228
+ };
2229
+ });
2230
+ function transform(fn) {
2231
+ return new ZodTransform({
2232
+ type: "transform",
2233
+ transform: fn
2234
+ });
2235
+ }
2236
+ const ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
2237
+ $ZodOptional.init(inst, def);
2238
+ ZodType.init(inst, def);
2239
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
2240
+ inst.unwrap = () => inst._zod.def.innerType;
2241
+ });
2242
+ function optional(innerType) {
2243
+ return new ZodOptional({
2244
+ type: "optional",
2245
+ innerType
2246
+ });
2247
+ }
2248
+ const ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
2249
+ $ZodExactOptional.init(inst, def);
2250
+ ZodType.init(inst, def);
2251
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
2252
+ inst.unwrap = () => inst._zod.def.innerType;
2253
+ });
2254
+ function exactOptional(innerType) {
2255
+ return new ZodExactOptional({
2256
+ type: "optional",
2257
+ innerType
2258
+ });
2259
+ }
2260
+ const ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
2261
+ $ZodNullable.init(inst, def);
2262
+ ZodType.init(inst, def);
2263
+ inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
2264
+ inst.unwrap = () => inst._zod.def.innerType;
2265
+ });
2266
+ function nullable(innerType) {
2267
+ return new ZodNullable({
2268
+ type: "nullable",
2269
+ innerType
2270
+ });
2271
+ }
2272
+ const ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
2273
+ $ZodDefault.init(inst, def);
2274
+ ZodType.init(inst, def);
2275
+ inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
2276
+ inst.unwrap = () => inst._zod.def.innerType;
2277
+ inst.removeDefault = inst.unwrap;
2278
+ });
2279
+ function _default(innerType, defaultValue) {
2280
+ return new ZodDefault({
2281
+ type: "default",
2282
+ innerType,
2283
+ get defaultValue() {
2284
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
2285
+ }
2286
+ });
2287
+ }
2288
+ const ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
2289
+ $ZodPrefault.init(inst, def);
2290
+ ZodType.init(inst, def);
2291
+ inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
2292
+ inst.unwrap = () => inst._zod.def.innerType;
2293
+ });
2294
+ function prefault(innerType, defaultValue) {
2295
+ return new ZodPrefault({
2296
+ type: "prefault",
2297
+ innerType,
2298
+ get defaultValue() {
2299
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
2300
+ }
2301
+ });
2302
+ }
2303
+ const ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
2304
+ $ZodNonOptional.init(inst, def);
2305
+ ZodType.init(inst, def);
2306
+ inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
2307
+ inst.unwrap = () => inst._zod.def.innerType;
2308
+ });
2309
+ function nonoptional(innerType, params) {
2310
+ return new ZodNonOptional({
2311
+ type: "nonoptional",
2312
+ innerType,
2313
+ ...normalizeParams(params)
2314
+ });
2315
+ }
2316
+ const ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
2317
+ $ZodCatch.init(inst, def);
2318
+ ZodType.init(inst, def);
2319
+ inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
2320
+ inst.unwrap = () => inst._zod.def.innerType;
2321
+ inst.removeCatch = inst.unwrap;
2322
+ });
2323
+ function _catch(innerType, catchValue) {
2324
+ return new ZodCatch({
2325
+ type: "catch",
2326
+ innerType,
2327
+ catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
2328
+ });
2329
+ }
2330
+ const ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
2331
+ $ZodPipe.init(inst, def);
2332
+ ZodType.init(inst, def);
2333
+ inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
2334
+ inst.in = def.in;
2335
+ inst.out = def.out;
2336
+ });
2337
+ function pipe(in_, out) {
2338
+ return new ZodPipe({
2339
+ type: "pipe",
2340
+ in: in_,
2341
+ out
2342
+ });
2343
+ }
2344
+ const ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
2345
+ $ZodReadonly.init(inst, def);
2346
+ ZodType.init(inst, def);
2347
+ inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
2348
+ inst.unwrap = () => inst._zod.def.innerType;
2349
+ });
2350
+ function readonly(innerType) {
2351
+ return new ZodReadonly({
2352
+ type: "readonly",
2353
+ innerType
2354
+ });
2355
+ }
2356
+ const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
2357
+ $ZodCustom.init(inst, def);
2358
+ ZodType.init(inst, def);
2359
+ inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
2360
+ });
2361
+ function refine(fn, _params = {}) {
2362
+ return /* @__PURE__ */ _refine(ZodCustom, fn, _params);
2363
+ }
2364
+ function superRefine(fn) {
2365
+ return /* @__PURE__ */ _superRefine(fn);
2366
+ }
2367
+ //#endregion
2368
+ //#region src/channel.ts
2369
+ const zapierArgsSchema = object({ input: unknown() });
2370
+ const validateZapierArgs = (args) => zapierArgsSchema.parse(args);
2371
+ /**
2372
+ * Zapier notification channel with event, data, meta, and webhookUrl slots.
2373
+ *
2374
+ * Pass a string union generic to constrain allowed event names:
2375
+ * ```ts
2376
+ * const zapier = zapierChannel<'order.created' | 'payment.failed'>();
2377
+ * ```
2378
+ */
2379
+ const zapierChannel = () => defineChannel({
2380
+ name: "zapier",
2381
+ slots: {
2382
+ event: slot.resolver(),
2383
+ data: slot.resolver(),
2384
+ meta: slot.resolver().optional(),
2385
+ webhookUrl: slot.resolver().optional()
2386
+ },
2387
+ validateArgs: validateZapierArgs,
2388
+ render: ({ runtime, args: _args }) => {
2389
+ const result = {
2390
+ event: runtime.event,
2391
+ data: runtime.data
2392
+ };
2393
+ if (runtime.meta !== void 0) result.meta = runtime.meta;
2394
+ if (runtime.webhookUrl !== void 0) result.webhookUrl = runtime.webhookUrl;
2395
+ return result;
2396
+ }
2397
+ });
2398
+ //#endregion
2399
+ //#region src/lib/post-webhook.ts
2400
+ const postWebhook = async (opts) => {
2401
+ const result = await createHttpClient({
2402
+ ...opts.http,
2403
+ timeoutMs: opts.timeoutMs
2404
+ }).request(opts.url, {
2405
+ method: "POST",
2406
+ headers: { "Content-Type": "application/json" },
2407
+ body: JSON.stringify(opts.body)
2408
+ });
2409
+ if (!result.ok) {
2410
+ if (result.kind === "network") return {
2411
+ ok: false,
2412
+ error: new NotifyRpcProviderError({
2413
+ message: `Zapier: ${result.timedOut ? "request timed out" : `network error: ${result.cause.message}`}`,
2414
+ code: result.timedOut ? "TIMEOUT" : "PROVIDER",
2415
+ provider: "zapier",
2416
+ retriable: true,
2417
+ route: opts.route,
2418
+ messageId: opts.messageId,
2419
+ cause: result.cause
2420
+ })
2421
+ };
2422
+ const code = result.status === 410 ? "CONFIG" : "PROVIDER";
2423
+ return {
2424
+ ok: false,
2425
+ error: new NotifyRpcProviderError({
2426
+ message: `Zapier: ${result.status === 410 ? "webhook URL expired or deleted" : `HTTP ${result.status}`}`,
2427
+ code,
2428
+ provider: "zapier",
2429
+ httpStatus: result.status,
2430
+ retriable: result.status >= 500,
2431
+ route: opts.route,
2432
+ messageId: opts.messageId
2433
+ })
2434
+ };
2435
+ }
2436
+ return {
2437
+ ok: true,
2438
+ status: 200,
2439
+ data: result.data ?? null
2440
+ };
2441
+ };
2442
+ //#endregion
2443
+ //#region src/lib/validate-url.ts
2444
+ const validateWebhookUrl = (url) => {
2445
+ let parsed;
2446
+ try {
2447
+ parsed = new URL(url);
2448
+ } catch {
2449
+ throw new NotifyRpcError({
2450
+ message: "Zapier: invalid webhook URL",
2451
+ code: "CONFIG"
2452
+ });
2453
+ }
2454
+ if (parsed.protocol !== "https:") throw new NotifyRpcError({
2455
+ message: `Zapier: webhook URL must use HTTPS (got ${parsed.protocol} for ${parsed.origin}/***)`,
2456
+ code: "CONFIG"
2457
+ });
2458
+ };
2459
+ //#endregion
2460
+ //#region src/transports/channel-transport.ts
2461
+ const DEFAULT_TIMEOUT_MS$1 = 1e4;
2462
+ /** Zapier channel transport — posts structured webhook payloads to Zapier catch hooks. */
2463
+ const zapierChannelTransport = (opts) => {
2464
+ validateWebhookUrl(opts.webhookUrl);
2465
+ const timeoutMs = opts.timeoutMs ?? opts.http?.timeoutMs ?? DEFAULT_TIMEOUT_MS$1;
2466
+ const log = (opts.logger ?? consoleLogger()).child({ component: "zapier-channel" });
2467
+ return createTransport({
2468
+ name: "zapier-channel",
2469
+ async send(rendered, ctx) {
2470
+ const url = rendered.webhookUrl ?? opts.webhookUrl;
2471
+ if (!url) return {
2472
+ ok: false,
2473
+ error: new NotifyRpcError({
2474
+ message: "Zapier channel: no webhook URL — set in slot or transport options",
2475
+ code: "CONFIG",
2476
+ route: ctx.route,
2477
+ messageId: ctx.messageId
2478
+ })
2479
+ };
2480
+ if (rendered.webhookUrl) validateWebhookUrl(rendered.webhookUrl);
2481
+ if (!rendered.event) return {
2482
+ ok: false,
2483
+ error: new NotifyRpcError({
2484
+ message: "Zapier channel: event name is required",
2485
+ code: "VALIDATION",
2486
+ route: ctx.route,
2487
+ messageId: ctx.messageId
2488
+ })
2489
+ };
2490
+ const payload = {
2491
+ event: rendered.event,
2492
+ route: ctx.route,
2493
+ messageId: ctx.messageId,
2494
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2495
+ data: rendered.data
2496
+ };
2497
+ if (rendered.meta) payload.meta = rendered.meta;
2498
+ log.debug("posting to Zapier webhook", {
2499
+ event: rendered.event,
2500
+ route: ctx.route
2501
+ });
2502
+ const result = await postWebhook({
2503
+ url,
2504
+ body: payload,
2505
+ timeoutMs,
2506
+ http: opts.http,
2507
+ route: ctx.route,
2508
+ messageId: ctx.messageId
2509
+ });
2510
+ if (!result.ok) {
2511
+ log.error("Zapier webhook failed", {
2512
+ err: result.error,
2513
+ route: ctx.route
2514
+ });
2515
+ return result;
2516
+ }
2517
+ return {
2518
+ ok: true,
2519
+ data: {
2520
+ status: result.status,
2521
+ raw: result.data
2522
+ }
2523
+ };
2524
+ }
2525
+ });
2526
+ };
2527
+ //#endregion
2528
+ //#region src/transports/zapier.ts
2529
+ const DEFAULT_TIMEOUT_MS = 1e4;
2530
+ const toAddressObject = (addr) => {
2531
+ if (typeof addr === "string") return { email: addr };
2532
+ return addr.name ? {
2533
+ name: addr.name,
2534
+ email: addr.email
2535
+ } : { email: addr.email };
2536
+ };
2537
+ /** Email transport that posts rendered messages to a Zapier catch hook webhook. */
2538
+ const zapierTransport = (opts) => {
2539
+ validateWebhookUrl(opts.webhookUrl);
2540
+ const timeoutMs = opts.timeoutMs ?? opts.http?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
2541
+ const log = (opts.logger ?? consoleLogger()).child({ component: "zapier" });
2542
+ return createTransport$1({
2543
+ name: "zapier",
2544
+ async send(message, ctx) {
2545
+ if (!message.from) return {
2546
+ ok: false,
2547
+ error: new NotifyRpcError({
2548
+ message: "Zapier transport: no \"from\" address configured",
2549
+ code: "CONFIG",
2550
+ route: ctx.route,
2551
+ messageId: ctx.messageId
2552
+ })
2553
+ };
2554
+ if (!message.to.length) return {
2555
+ ok: false,
2556
+ error: new NotifyRpcError({
2557
+ message: "Zapier transport: \"to\" must have at least one recipient",
2558
+ code: "VALIDATION",
2559
+ route: ctx.route,
2560
+ messageId: ctx.messageId
2561
+ })
2562
+ };
2563
+ const payload = {
2564
+ type: "email",
2565
+ route: ctx.route,
2566
+ messageId: ctx.messageId,
2567
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2568
+ from: toAddressObject(message.from),
2569
+ to: message.to.map(toAddressObject),
2570
+ cc: (message.cc ?? []).map(toAddressObject),
2571
+ bcc: (message.bcc ?? []).map(toAddressObject),
2572
+ replyTo: message.replyTo ? toAddressObject(message.replyTo) : null,
2573
+ subject: message.subject,
2574
+ html: message.html,
2575
+ text: message.text ?? null,
2576
+ headers: message.headers ?? {},
2577
+ tags: message.tags ?? {},
2578
+ attachments: (message.attachments ?? []).map((att) => ({
2579
+ filename: att.filename,
2580
+ content: typeof att.content === "string" ? att.content : Buffer.from(att.content).toString("base64"),
2581
+ ...att.contentType ? { contentType: att.contentType } : {}
2582
+ }))
2583
+ };
2584
+ log.debug("posting email to Zapier webhook", { route: ctx.route });
2585
+ const result = await postWebhook({
2586
+ url: opts.webhookUrl,
2587
+ body: payload,
2588
+ timeoutMs,
2589
+ http: opts.http,
2590
+ route: ctx.route,
2591
+ messageId: ctx.messageId
2592
+ });
2593
+ if (!result.ok) {
2594
+ log.error("Zapier email webhook failed", {
2595
+ err: result.error,
2596
+ route: ctx.route
2597
+ });
2598
+ return result;
2599
+ }
2600
+ return {
2601
+ ok: true,
2602
+ data: {
2603
+ transportMessageId: void 0,
2604
+ accepted: message.to.map(normalizeAddress),
2605
+ rejected: [],
2606
+ raw: result.data
2607
+ }
2608
+ };
2609
+ }
2610
+ });
2611
+ };
2612
+ //#endregion
2613
+ //#region src/transports/mock.ts
2614
+ const mockZapierTransport = () => {
2615
+ let counter = 0;
2616
+ const payloads = [];
2617
+ const base = createMockTransport({
2618
+ name: "mock-zapier",
2619
+ reply: (rendered) => {
2620
+ counter += 1;
2621
+ const id = `zapier-mock-${counter}`;
2622
+ payloads.push({
2623
+ ...rendered,
2624
+ id
2625
+ });
2626
+ return {
2627
+ status: 200,
2628
+ raw: {}
2629
+ };
2630
+ }
2631
+ });
2632
+ const originalReset = base.reset.bind(base);
2633
+ return Object.assign(base, {
2634
+ get payloads() {
2635
+ return payloads;
2636
+ },
2637
+ reset() {
2638
+ originalReset();
2639
+ payloads.length = 0;
2640
+ counter = 0;
2641
+ }
2642
+ });
2643
+ };
2644
+ //#endregion
2645
+ //#region src/is-retriable.ts
2646
+ const isZapierRetriable = (err) => {
2647
+ if (err instanceof NotifyRpcProviderError) return err.retriable;
2648
+ return true;
2649
+ };
2650
+ //#endregion
2651
+ export { isZapierRetriable, mockZapierTransport, zapierChannel, zapierChannelTransport, zapierTransport };