@open-macaron/review 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/macaron-review.mjs +1283 -1213
  2. package/package.json +1 -1
@@ -9173,434 +9173,6 @@ import { mkdtemp, rm, writeFile } from "node:fs/promises";
9173
9173
  import { tmpdir } from "node:os";
9174
9174
  import { join } from "node:path";
9175
9175
 
9176
- // ../../node_modules/.pnpm/deepmerge-ts@8.0.2/node_modules/deepmerge-ts/dist/index.mjs
9177
- var actions = {
9178
- defaultMerge: /* @__PURE__ */ Symbol("deepmerge-ts: default merge"),
9179
- skip: /* @__PURE__ */ Symbol("deepmerge-ts: skip")
9180
- };
9181
- var actionsInto = {
9182
- defaultMerge: actions.defaultMerge
9183
- };
9184
- function defaultMetaDataUpdater(previousMeta, mergeInfo) {
9185
- const ancestor = {
9186
- key: mergeInfo.key,
9187
- parents: mergeInfo.parents,
9188
- values: mergeInfo.values,
9189
- result: mergeInfo.result
9190
- };
9191
- const prevHierarchy = previousMeta?.hierarchy;
9192
- return {
9193
- ...ancestor,
9194
- hierarchy: prevHierarchy === void 0 ? [ancestor] : [...prevHierarchy, ancestor]
9195
- };
9196
- }
9197
- function defaultFilterValues(values, meta3) {
9198
- return values.includes(void 0) ? values.filter((value) => value !== void 0) : values;
9199
- }
9200
- function shouldFallbackToDefault(utils, fallback, result) {
9201
- return result === actions.defaultMerge || utils.useImplicitDefaultMerging && result === void 0 && utils.mergeFunctions[fallback] !== utils.defaultMergeFunctions[fallback];
9202
- }
9203
- function resolveCustomMergeFunctions(options, defaultMergeFunctions) {
9204
- return {
9205
- ...defaultMergeFunctions,
9206
- ...Object.fromEntries(Object.entries(options).filter(([key]) => Object.hasOwn(defaultMergeFunctions, key)).map(([key, option]) => option === false ? [key, defaultMergeFunctions.mergeOthers] : typeof option === "function" ? [key, option] : [key, defaultMergeFunctions[key]]))
9207
- };
9208
- }
9209
- function mergeArrays$1(values, utils, meta3) {
9210
- return values.flat();
9211
- }
9212
- function mergeSets$1(values, utils, meta3) {
9213
- const result = /* @__PURE__ */ new Set();
9214
- for (const set2 of values) {
9215
- for (const element of set2) {
9216
- result.add(element);
9217
- }
9218
- }
9219
- return result;
9220
- }
9221
- function mergeOthers$1(values, utils, meta3) {
9222
- return values.at(-1);
9223
- }
9224
- var ObjectType;
9225
- (function(ObjectType2) {
9226
- ObjectType2[ObjectType2["NOT"] = 0] = "NOT";
9227
- ObjectType2[ObjectType2["RECORD"] = 1] = "RECORD";
9228
- ObjectType2[ObjectType2["ARRAY"] = 2] = "ARRAY";
9229
- ObjectType2[ObjectType2["SET"] = 3] = "SET";
9230
- ObjectType2[ObjectType2["MAP"] = 4] = "MAP";
9231
- ObjectType2[ObjectType2["OTHER"] = 5] = "OTHER";
9232
- })(ObjectType || (ObjectType = {}));
9233
- function getObjectType(object2) {
9234
- if (typeof object2 !== "object" || object2 === null) {
9235
- return ObjectType.NOT;
9236
- }
9237
- if (Array.isArray(object2)) {
9238
- return ObjectType.ARRAY;
9239
- }
9240
- if (isRecord(object2)) {
9241
- return ObjectType.RECORD;
9242
- }
9243
- if (object2 instanceof Set) {
9244
- return ObjectType.SET;
9245
- }
9246
- if (object2 instanceof Map) {
9247
- return ObjectType.MAP;
9248
- }
9249
- return ObjectType.OTHER;
9250
- }
9251
- function getKeysOfObjects(objects) {
9252
- const keys = /* @__PURE__ */ new Set();
9253
- for (const currentObject of objects) {
9254
- const stringKeys = Object.keys(currentObject);
9255
- for (const stringKey of stringKeys) {
9256
- keys.add(stringKey);
9257
- }
9258
- const symbols = Object.getOwnPropertySymbols(currentObject);
9259
- if (symbols.length > 0) {
9260
- for (const symbol2 of symbols) {
9261
- if (Object.prototype.propertyIsEnumerable.call(currentObject, symbol2)) {
9262
- keys.add(symbol2);
9263
- }
9264
- }
9265
- }
9266
- }
9267
- return keys;
9268
- }
9269
- function getKeysOfObject(object2) {
9270
- const symbols = Object.getOwnPropertySymbols(object2).filter((symbol2) => Object.prototype.propertyIsEnumerable.call(object2, symbol2));
9271
- return [...Object.keys(object2), ...symbols];
9272
- }
9273
- function objectHasProperty(object2, property) {
9274
- return typeof object2 === "object" && Object.prototype.propertyIsEnumerable.call(object2, property);
9275
- }
9276
- function isRecord(value) {
9277
- const prototype = Object.getPrototypeOf(value);
9278
- if (prototype === null || prototype === Object.prototype) {
9279
- return true;
9280
- }
9281
- const objectToString = Object.prototype.toString.call(value);
9282
- if (objectToString !== "[object Object]" && objectToString !== "[object Module]") {
9283
- return false;
9284
- }
9285
- const { constructor } = value;
9286
- if (constructor === void 0) {
9287
- return true;
9288
- }
9289
- const constructorPrototype = constructor.prototype;
9290
- if (constructorPrototype === null || typeof constructorPrototype !== "object") {
9291
- return false;
9292
- }
9293
- const constructorToString = Object.prototype.toString.call(constructorPrototype);
9294
- if (constructorToString !== "[object Object]" && constructorToString !== "[object Module]") {
9295
- return false;
9296
- }
9297
- if (!Object.hasOwn(constructorPrototype, "isPrototypeOf")) {
9298
- return false;
9299
- }
9300
- return true;
9301
- }
9302
- function getCyclicReferenceDepth(object2, hierarchy, index) {
9303
- if (hierarchy === void 0 || hierarchy.length === 0) {
9304
- return 0;
9305
- }
9306
- let mut_depth = 1;
9307
- for (let mut_index = hierarchy.length - 1; mut_index >= 0; mut_index--) {
9308
- const { parents } = hierarchy[mut_index];
9309
- if (parents[index] === object2 || parents.includes(object2)) {
9310
- return mut_depth;
9311
- }
9312
- mut_depth += 1;
9313
- }
9314
- return 0;
9315
- }
9316
- function getMetaDataHierarchy(meta3) {
9317
- return meta3?.hierarchy;
9318
- }
9319
- function mergeRecords$1(values, utils, meta3) {
9320
- if (values.length === 2) {
9321
- const result = {};
9322
- const mergeProperty = (key, propValues) => {
9323
- const updatedMeta = utils.metaDataUpdater(meta3, {
9324
- key,
9325
- parents: values,
9326
- values: propValues,
9327
- result
9328
- });
9329
- const propertyResult = mergeUnknowns(propValues, utils, updatedMeta);
9330
- if (propertyResult === actions.skip) {
9331
- return;
9332
- }
9333
- if (key === "__proto__") {
9334
- Object.defineProperty(result, key, {
9335
- value: propertyResult,
9336
- configurable: true,
9337
- enumerable: true,
9338
- writable: true
9339
- });
9340
- } else {
9341
- result[key] = propertyResult;
9342
- }
9343
- };
9344
- const firstValue = values[0];
9345
- const secondValue = values[1];
9346
- for (const key of getKeysOfObject(firstValue)) {
9347
- mergeProperty(key, objectHasProperty(secondValue, key) ? [firstValue[key], secondValue[key]] : [firstValue[key]]);
9348
- }
9349
- for (const key of getKeysOfObject(secondValue)) {
9350
- if (!objectHasProperty(firstValue, key)) {
9351
- mergeProperty(key, [secondValue[key]]);
9352
- }
9353
- }
9354
- return result;
9355
- }
9356
- return mergeRecordsGeneral(values, utils, meta3);
9357
- }
9358
- function mergeRecordsGeneral(values, utils, meta3) {
9359
- const result = {};
9360
- for (const key of getKeysOfObjects(values)) {
9361
- const propValues = [];
9362
- for (const value of values) {
9363
- if (objectHasProperty(value, key)) {
9364
- propValues.push(value[key]);
9365
- }
9366
- }
9367
- const updatedMeta = utils.metaDataUpdater(meta3, {
9368
- key,
9369
- parents: values,
9370
- values: propValues,
9371
- result
9372
- });
9373
- const propertyResult = mergeUnknowns(propValues, utils, updatedMeta);
9374
- if (propertyResult === actions.skip) {
9375
- continue;
9376
- }
9377
- if (key === "__proto__") {
9378
- Object.defineProperty(result, key, {
9379
- value: propertyResult,
9380
- configurable: true,
9381
- enumerable: true,
9382
- writable: true
9383
- });
9384
- } else {
9385
- result[key] = propertyResult;
9386
- }
9387
- }
9388
- return result;
9389
- }
9390
- function mergeMaps$1(values, utils, meta3) {
9391
- const result = /* @__PURE__ */ new Map();
9392
- const valuesByKey = /* @__PURE__ */ new Map();
9393
- for (const map2 of values) {
9394
- for (const [key, value] of map2) {
9395
- const mut_keyValues = valuesByKey.get(key);
9396
- if (mut_keyValues === void 0) {
9397
- valuesByKey.set(key, [value]);
9398
- } else {
9399
- mut_keyValues.push(value);
9400
- }
9401
- }
9402
- }
9403
- for (const [key, keyValues] of valuesByKey) {
9404
- const updatedMeta = utils.metaDataUpdater(meta3, {
9405
- key,
9406
- parents: values,
9407
- values: keyValues,
9408
- result
9409
- });
9410
- const keyResult = mergeUnknowns(keyValues, utils, updatedMeta);
9411
- if (keyResult === actions.skip) {
9412
- continue;
9413
- }
9414
- result.set(key, keyResult);
9415
- }
9416
- return result;
9417
- }
9418
- function resolveCyclicReferences(value, utils, meta3) {
9419
- if (typeof value !== "object" || value === null) {
9420
- return value;
9421
- }
9422
- const hierarchy = getMetaDataHierarchy(meta3);
9423
- const depth = getCyclicReferenceDepth(value, hierarchy, 0);
9424
- if (hierarchy !== void 0 && depth > 0) {
9425
- return hierarchy[hierarchy.length - depth]?.result;
9426
- }
9427
- const type = getObjectType(value);
9428
- if (type === ObjectType.RECORD) {
9429
- const record2 = value;
9430
- let mut_changed = false;
9431
- const result = {};
9432
- for (const key of getKeysOfObject(record2)) {
9433
- const propVal = record2[key];
9434
- const updatedMeta = utils.metaDataUpdater(meta3, {
9435
- key,
9436
- parents: [record2],
9437
- values: [propVal],
9438
- result
9439
- });
9440
- const resolvedProp = resolveCyclicReferences(propVal, utils, updatedMeta);
9441
- if (resolvedProp !== propVal) {
9442
- mut_changed = true;
9443
- }
9444
- if (key === "__proto__") {
9445
- Object.defineProperty(result, key, {
9446
- value: resolvedProp,
9447
- configurable: true,
9448
- enumerable: true,
9449
- writable: true
9450
- });
9451
- } else {
9452
- result[key] = resolvedProp;
9453
- }
9454
- }
9455
- return mut_changed ? result : value;
9456
- }
9457
- return value;
9458
- }
9459
- function mergeCircularReferences$1(values, cyclicDepths, utils, meta3) {
9460
- const depth = cyclicDepths[0];
9461
- const hierarchy = getMetaDataHierarchy(meta3);
9462
- for (let mut_index = 1; mut_index < values.length; mut_index++) {
9463
- if (cyclicDepths[mut_index] !== depth) {
9464
- const lastCyclicDepth = cyclicDepths.at(-1);
9465
- return lastCyclicDepth === 0 ? resolveCyclicReferences(values.at(-1), utils, meta3) : hierarchy?.[hierarchy.length - lastCyclicDepth]?.result;
9466
- }
9467
- }
9468
- return hierarchy?.[hierarchy.length - depth]?.result;
9469
- }
9470
- var mergeFunctions = {
9471
- mergeRecords: mergeRecords$1,
9472
- mergeArrays: mergeArrays$1,
9473
- mergeSets: mergeSets$1,
9474
- mergeMaps: mergeMaps$1,
9475
- mergeCircularReferences: mergeCircularReferences$1,
9476
- mergeOthers: mergeOthers$1
9477
- };
9478
- function deepmergeCustom(options = {}, rootMetaData) {
9479
- const utils = getUtils$1(options, customizedDeepmerge);
9480
- function customizedDeepmerge(...objects) {
9481
- return mergeUnknowns(objects, utils, rootMetaData ?? void 0);
9482
- }
9483
- return customizedDeepmerge;
9484
- }
9485
- function getUtils$1(options, customizedDeepmerge) {
9486
- const defaultMergeFns = mergeFunctions;
9487
- const defaultMetaDataUpd = defaultMetaDataUpdater;
9488
- return {
9489
- defaultMergeFunctions: defaultMergeFns,
9490
- mergeFunctions: resolveCustomMergeFunctions(options, defaultMergeFns),
9491
- metaDataUpdater: typeof options.metaDataUpdater === "function" ? options.metaDataUpdater : defaultMetaDataUpd,
9492
- deepmerge: customizedDeepmerge,
9493
- useImplicitDefaultMerging: options.enableImplicitDefaultMerging ?? false,
9494
- filterValues: options.filterValues === false ? void 0 : typeof options.filterValues === "function" ? options.filterValues : defaultFilterValues,
9495
- maxDepth: typeof options.maxDepth === "number" && !Number.isNaN(options.maxDepth) && options.maxDepth >= 0 ? options.maxDepth : 1e3,
9496
- actions
9497
- };
9498
- }
9499
- function mergeUnknowns(values, utils, meta3) {
9500
- const filteredValues = utils.filterValues?.(values, meta3) ?? values;
9501
- if (filteredValues.length === 0) {
9502
- return void 0;
9503
- }
9504
- const hierarchy = getMetaDataHierarchy(meta3);
9505
- const currentDepth = hierarchy?.length ?? (typeof meta3 === "number" ? meta3 : meta3?.depth ?? 0);
9506
- if (utils.maxDepth !== void 0 && currentDepth >= utils.maxDepth) {
9507
- return mergeOthers(filteredValues, utils, meta3);
9508
- }
9509
- if (filteredValues.length === 1) {
9510
- if (hierarchy !== void 0) {
9511
- const depth = getCyclicReferenceDepth(filteredValues[0], hierarchy, 0);
9512
- if (depth > 0) {
9513
- return hierarchy[hierarchy.length - depth]?.result ?? hierarchy[hierarchy.length - depth]?.parents[0];
9514
- }
9515
- }
9516
- return mergeOthers(filteredValues, utils, meta3);
9517
- }
9518
- const type = getObjectType(filteredValues[0]);
9519
- if (type !== ObjectType.NOT && type !== ObjectType.OTHER) {
9520
- if (filteredValues.length === 2) {
9521
- if (getObjectType(filteredValues[1]) !== type) {
9522
- return mergeOthers(filteredValues, utils, meta3);
9523
- }
9524
- const d0 = getCyclicReferenceDepth(filteredValues[0], hierarchy, 0);
9525
- const d1 = getCyclicReferenceDepth(filteredValues[1], hierarchy, 1);
9526
- if (d0 !== 0 || d1 !== 0) {
9527
- return mergeCircularReferences(filteredValues, [d0, d1], utils, meta3);
9528
- }
9529
- } else {
9530
- const cyclicDepths = new Array(filteredValues.length);
9531
- cyclicDepths[0] = getCyclicReferenceDepth(filteredValues[0], hierarchy, 0);
9532
- for (let mut_index = 1; mut_index < filteredValues.length; mut_index++) {
9533
- if (getObjectType(filteredValues[mut_index]) !== type) {
9534
- return mergeOthers(filteredValues, utils, meta3);
9535
- }
9536
- cyclicDepths[mut_index] = getCyclicReferenceDepth(filteredValues[mut_index], hierarchy, mut_index);
9537
- }
9538
- if (cyclicDepths.some((depth) => depth !== 0)) {
9539
- return mergeCircularReferences(filteredValues, cyclicDepths, utils, meta3);
9540
- }
9541
- }
9542
- }
9543
- switch (type) {
9544
- case ObjectType.RECORD: {
9545
- return mergeRecords(filteredValues, utils, meta3);
9546
- }
9547
- case ObjectType.ARRAY: {
9548
- return mergeArrays(filteredValues, utils, meta3);
9549
- }
9550
- case ObjectType.SET: {
9551
- return mergeSets(filteredValues, utils, meta3);
9552
- }
9553
- case ObjectType.MAP: {
9554
- return mergeMaps(filteredValues, utils, meta3);
9555
- }
9556
- default: {
9557
- return mergeOthers(filteredValues, utils, meta3);
9558
- }
9559
- }
9560
- }
9561
- function mergeRecords(values, utils, meta3) {
9562
- const result = utils.mergeFunctions.mergeRecords(values, utils, meta3);
9563
- if (shouldFallbackToDefault(utils, "mergeRecords", result)) {
9564
- return utils.defaultMergeFunctions.mergeRecords(values, utils, meta3);
9565
- }
9566
- return result;
9567
- }
9568
- function mergeArrays(values, utils, meta3) {
9569
- const result = utils.mergeFunctions.mergeArrays(values, utils, meta3);
9570
- if (shouldFallbackToDefault(utils, "mergeArrays", result)) {
9571
- return utils.defaultMergeFunctions.mergeArrays(values);
9572
- }
9573
- return result;
9574
- }
9575
- function mergeSets(values, utils, meta3) {
9576
- const result = utils.mergeFunctions.mergeSets(values, utils, meta3);
9577
- if (shouldFallbackToDefault(utils, "mergeSets", result)) {
9578
- return utils.defaultMergeFunctions.mergeSets(values);
9579
- }
9580
- return result;
9581
- }
9582
- function mergeMaps(values, utils, meta3) {
9583
- const result = utils.mergeFunctions.mergeMaps(values, utils, meta3);
9584
- if (shouldFallbackToDefault(utils, "mergeMaps", result)) {
9585
- return utils.defaultMergeFunctions.mergeMaps(values, utils, meta3);
9586
- }
9587
- return result;
9588
- }
9589
- function mergeCircularReferences(values, cyclicDepths, utils, meta3) {
9590
- const result = utils.mergeFunctions.mergeCircularReferences(values, cyclicDepths, utils, meta3);
9591
- if (shouldFallbackToDefault(utils, "mergeCircularReferences", result)) {
9592
- return utils.defaultMergeFunctions.mergeCircularReferences(values, cyclicDepths, utils, meta3);
9593
- }
9594
- return result;
9595
- }
9596
- function mergeOthers(values, utils, meta3) {
9597
- const result = utils.mergeFunctions.mergeOthers(values, utils, meta3);
9598
- if (shouldFallbackToDefault(utils, "mergeOthers", result)) {
9599
- return utils.defaultMergeFunctions.mergeOthers(values);
9600
- }
9601
- return result;
9602
- }
9603
-
9604
9176
  // ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/classic/external.js
9605
9177
  var external_exports = {};
9606
9178
  __export(external_exports, {
@@ -28448,885 +28020,1383 @@ function detectVersion(schema, defaultTarget) {
28448
28020
  if ($schema === "http://json-schema.org/draft-07/schema#") {
28449
28021
  return "draft-7";
28450
28022
  }
28451
- if ($schema === "http://json-schema.org/draft-04/schema#") {
28452
- return "draft-4";
28023
+ if ($schema === "http://json-schema.org/draft-04/schema#") {
28024
+ return "draft-4";
28025
+ }
28026
+ return defaultTarget ?? "draft-2020-12";
28027
+ }
28028
+ function applyMinItems(items, minItems) {
28029
+ return items.map((item, index) => index < minItems ? item : item.optional());
28030
+ }
28031
+ function decodeJSONPointerSegment(segment) {
28032
+ return segment.replace(/~1/g, "/").replace(/~0/g, "~");
28033
+ }
28034
+ function resolveRef(ref, ctx) {
28035
+ if (!ref.startsWith("#")) {
28036
+ throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
28037
+ }
28038
+ const path = ref.slice(1).split("/").filter(Boolean);
28039
+ if (path.length === 0) {
28040
+ return ctx.rootSchema;
28041
+ }
28042
+ const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
28043
+ if (path[0] === defsKey) {
28044
+ const key = path[1] === void 0 ? void 0 : decodeJSONPointerSegment(path[1]);
28045
+ if (!key || !ctx.defs[key]) {
28046
+ throw new Error(`Reference not found: ${ref}`);
28047
+ }
28048
+ return ctx.defs[key];
28049
+ }
28050
+ throw new Error(`Reference not found: ${ref}`);
28051
+ }
28052
+ function checkObjectGuards(objectSchema, guards) {
28053
+ const guard = z.transform((value) => value).check((payload) => {
28054
+ const value = payload.value;
28055
+ if (typeof value !== "object" || value === null || Array.isArray(value))
28056
+ return;
28057
+ const keys = Object.getOwnPropertyNames(value);
28058
+ if (guards.minProperties !== void 0 && keys.length < guards.minProperties) {
28059
+ payload.issues.push({
28060
+ origin: "object",
28061
+ code: "too_small",
28062
+ minimum: guards.minProperties,
28063
+ inclusive: true,
28064
+ message: `Too small: expected object to have >=${guards.minProperties} properties`,
28065
+ input: value,
28066
+ inst: objectSchema,
28067
+ continue: true
28068
+ });
28069
+ }
28070
+ if (guards.maxProperties !== void 0 && keys.length > guards.maxProperties) {
28071
+ payload.issues.push({
28072
+ origin: "object",
28073
+ code: "too_big",
28074
+ maximum: guards.maxProperties,
28075
+ inclusive: true,
28076
+ message: `Too big: expected object to have <=${guards.maxProperties} properties`,
28077
+ input: value,
28078
+ inst: objectSchema,
28079
+ continue: true
28080
+ });
28081
+ }
28082
+ if (guards.keySchema) {
28083
+ for (const key of keys) {
28084
+ const result = guards.keySchema.safeParse(key);
28085
+ if (result.success)
28086
+ continue;
28087
+ payload.issues.push({
28088
+ code: "invalid_key",
28089
+ origin: "record",
28090
+ issues: result.error.issues,
28091
+ input: key,
28092
+ path: [key],
28093
+ continue: true
28094
+ });
28095
+ }
28096
+ }
28097
+ });
28098
+ return guard.pipe(objectSchema);
28099
+ }
28100
+ function canonicalKey(value, seen) {
28101
+ if (value === null)
28102
+ return "z";
28103
+ const type = typeof value;
28104
+ if (type !== "object") {
28105
+ if (type === "number" && Number.isNaN(value))
28106
+ return null;
28107
+ const raw = String(value);
28108
+ return `${type[0]}${raw.length}:${raw}`;
28109
+ }
28110
+ if (seen.has(value))
28111
+ return null;
28112
+ seen.add(value);
28113
+ try {
28114
+ if (Array.isArray(value)) {
28115
+ const parts2 = [];
28116
+ for (const item of value) {
28117
+ const key = canonicalKey(item, seen);
28118
+ if (key === null)
28119
+ return null;
28120
+ parts2.push(key);
28121
+ }
28122
+ return `a${parts2.length}:[${parts2.join(",")}]`;
28123
+ }
28124
+ const keys = Object.keys(value).sort();
28125
+ const parts = [];
28126
+ for (const k of keys) {
28127
+ const key = canonicalKey(value[k], seen);
28128
+ if (key === null)
28129
+ return null;
28130
+ parts.push(`${k.length}:${k}=${key}`);
28131
+ }
28132
+ return `o${parts.length}:{${parts.join(",")}}`;
28133
+ } finally {
28134
+ seen.delete(value);
28135
+ }
28136
+ }
28137
+ var SCHEMA_KEYWORDS = /* @__PURE__ */ new Set([
28138
+ "items",
28139
+ "prefixItems",
28140
+ "additionalItems",
28141
+ "additionalProperties",
28142
+ "contains",
28143
+ "propertyNames",
28144
+ "not",
28145
+ "if",
28146
+ "then",
28147
+ "else",
28148
+ "allOf",
28149
+ "anyOf",
28150
+ "oneOf",
28151
+ "unevaluatedItems",
28152
+ "unevaluatedProperties",
28153
+ "contentSchema"
28154
+ ]);
28155
+ var SCHEMA_MAP_KEYWORDS = /* @__PURE__ */ new Set([
28156
+ "properties",
28157
+ "patternProperties",
28158
+ "dependentSchemas",
28159
+ "dependencies",
28160
+ "$defs",
28161
+ "definitions"
28162
+ ]);
28163
+ function containsRef(value) {
28164
+ if (typeof value !== "object" || value === null)
28165
+ return false;
28166
+ if (Array.isArray(value))
28167
+ return value.some(containsRef);
28168
+ if (typeof value.$ref === "string")
28169
+ return true;
28170
+ return Object.entries(value).some(([key, sub]) => {
28171
+ if (SCHEMA_KEYWORDS.has(key))
28172
+ return containsRef(sub);
28173
+ if (!SCHEMA_MAP_KEYWORDS.has(key) || typeof sub !== "object" || sub === null)
28174
+ return false;
28175
+ return Object.values(sub).some(containsRef);
28176
+ });
28177
+ }
28178
+ function plural(n) {
28179
+ return n === 1 ? "element" : "elements";
28180
+ }
28181
+ function checkArrayGuards(arraySchema, guards) {
28182
+ const guard = z.transform((value) => value).check((payload) => {
28183
+ const items = payload.value;
28184
+ if (!Array.isArray(items))
28185
+ return;
28186
+ if (guards.uniqueItems === true) {
28187
+ const firstSeen = /* @__PURE__ */ new Map();
28188
+ for (let i = 0; i < items.length; i++) {
28189
+ const key = canonicalKey(items[i], /* @__PURE__ */ new Set());
28190
+ if (key === null)
28191
+ continue;
28192
+ const first = firstSeen.get(key);
28193
+ if (first === void 0) {
28194
+ firstSeen.set(key, i);
28195
+ continue;
28196
+ }
28197
+ payload.issues.push({
28198
+ code: "custom",
28199
+ message: `Array items must be unique: element at index ${i} duplicates the one at index ${first}`,
28200
+ input: items,
28201
+ path: [i],
28202
+ continue: true
28203
+ });
28204
+ }
28205
+ }
28206
+ if (guards.containsSchema) {
28207
+ const minContains = guards.minContains ?? 1;
28208
+ const ceiling = guards.maxContains !== void 0 ? guards.maxContains + 1 : Number.POSITIVE_INFINITY;
28209
+ let matches = 0;
28210
+ for (const item of items) {
28211
+ if (guards.containsSchema.safeParse(item).success && ++matches >= ceiling)
28212
+ break;
28213
+ }
28214
+ if (matches < minContains) {
28215
+ payload.issues.push({
28216
+ code: "custom",
28217
+ message: `Array must contain at least ${minContains} matching ${plural(minContains)}; found ${matches}`,
28218
+ input: items,
28219
+ continue: true
28220
+ });
28221
+ }
28222
+ if (guards.maxContains !== void 0 && matches > guards.maxContains) {
28223
+ payload.issues.push({
28224
+ code: "custom",
28225
+ message: `Array must contain at most ${guards.maxContains} matching ${plural(guards.maxContains)}`,
28226
+ input: items,
28227
+ continue: true
28228
+ });
28229
+ }
28230
+ }
28231
+ });
28232
+ return guard.pipe(arraySchema);
28233
+ }
28234
+ function getTupleRest(restSchema, ctx) {
28235
+ if (restSchema === false) {
28236
+ return void 0;
28237
+ }
28238
+ if (restSchema === void 0 || restSchema === true) {
28239
+ return z.any();
28453
28240
  }
28454
- return defaultTarget ?? "draft-2020-12";
28455
- }
28456
- function applyMinItems(items, minItems) {
28457
- return items.map((item, index) => index < minItems ? item : item.optional());
28458
- }
28459
- function decodeJSONPointerSegment(segment) {
28460
- return segment.replace(/~1/g, "/").replace(/~0/g, "~");
28241
+ return convertSchema(restSchema, ctx);
28461
28242
  }
28462
- function resolveRef(ref, ctx) {
28463
- if (!ref.startsWith("#")) {
28464
- throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
28243
+ var fullTime = /^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;
28244
+ function convertBaseSchema(schema, ctx) {
28245
+ if (schema.not !== void 0) {
28246
+ if (typeof schema.not === "object" && Object.keys(schema.not).length === 0) {
28247
+ return z.never();
28248
+ }
28249
+ throw new Error("not is not supported in Zod (except { not: {} } for never)");
28465
28250
  }
28466
- const path = ref.slice(1).split("/").filter(Boolean);
28467
- if (path.length === 0) {
28468
- return ctx.rootSchema;
28251
+ if (schema.unevaluatedItems !== void 0) {
28252
+ throw new Error("unevaluatedItems is not supported");
28469
28253
  }
28470
- const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
28471
- if (path[0] === defsKey) {
28472
- const key = path[1] === void 0 ? void 0 : decodeJSONPointerSegment(path[1]);
28473
- if (!key || !ctx.defs[key]) {
28474
- throw new Error(`Reference not found: ${ref}`);
28475
- }
28476
- return ctx.defs[key];
28254
+ if (schema.unevaluatedProperties !== void 0) {
28255
+ throw new Error("unevaluatedProperties is not supported");
28477
28256
  }
28478
- throw new Error(`Reference not found: ${ref}`);
28479
- }
28480
- function checkObjectGuards(objectSchema, guards) {
28481
- const guard = z.transform((value) => value).check((payload) => {
28482
- const value = payload.value;
28483
- if (typeof value !== "object" || value === null || Array.isArray(value))
28484
- return;
28485
- const keys = Object.getOwnPropertyNames(value);
28486
- if (guards.minProperties !== void 0 && keys.length < guards.minProperties) {
28487
- payload.issues.push({
28488
- origin: "object",
28489
- code: "too_small",
28490
- minimum: guards.minProperties,
28491
- inclusive: true,
28492
- message: `Too small: expected object to have >=${guards.minProperties} properties`,
28493
- input: value,
28494
- inst: objectSchema,
28495
- continue: true
28496
- });
28257
+ if (schema.if !== void 0 || schema.then !== void 0 || schema.else !== void 0) {
28258
+ throw new Error("Conditional schemas (if/then/else) are not supported");
28259
+ }
28260
+ if (schema.dependentSchemas !== void 0 || schema.dependentRequired !== void 0) {
28261
+ throw new Error("dependentSchemas and dependentRequired are not supported");
28262
+ }
28263
+ if (schema.$ref) {
28264
+ const refPath = schema.$ref;
28265
+ if (ctx.refs.has(refPath)) {
28266
+ return ctx.refs.get(refPath);
28497
28267
  }
28498
- if (guards.maxProperties !== void 0 && keys.length > guards.maxProperties) {
28499
- payload.issues.push({
28500
- origin: "object",
28501
- code: "too_big",
28502
- maximum: guards.maxProperties,
28503
- inclusive: true,
28504
- message: `Too big: expected object to have <=${guards.maxProperties} properties`,
28505
- input: value,
28506
- inst: objectSchema,
28507
- continue: true
28268
+ if (ctx.processing.has(refPath)) {
28269
+ return z.lazy(() => {
28270
+ if (!ctx.refs.has(refPath)) {
28271
+ throw new Error(`Circular reference not resolved: ${refPath}`);
28272
+ }
28273
+ return ctx.refs.get(refPath);
28508
28274
  });
28509
28275
  }
28510
- if (guards.keySchema) {
28511
- for (const key of keys) {
28512
- const result = guards.keySchema.safeParse(key);
28513
- if (result.success)
28514
- continue;
28515
- payload.issues.push({
28516
- code: "invalid_key",
28517
- origin: "record",
28518
- issues: result.error.issues,
28519
- input: key,
28520
- path: [key],
28521
- continue: true
28522
- });
28523
- }
28276
+ ctx.processing.add(refPath);
28277
+ const resolved = resolveRef(refPath, ctx);
28278
+ const zodSchema2 = convertSchema(resolved, ctx);
28279
+ ctx.refs.set(refPath, zodSchema2);
28280
+ ctx.processing.delete(refPath);
28281
+ return zodSchema2;
28282
+ }
28283
+ if (schema.enum !== void 0) {
28284
+ const enumValues = schema.enum;
28285
+ if (ctx.version === "openapi-3.0" && schema.nullable === true && enumValues.length === 1 && enumValues[0] === null) {
28286
+ return z.null();
28524
28287
  }
28525
- });
28526
- return guard.pipe(objectSchema);
28527
- }
28528
- function canonicalKey(value, seen) {
28529
- if (value === null)
28530
- return "z";
28531
- const type = typeof value;
28532
- if (type !== "object") {
28533
- if (type === "number" && Number.isNaN(value))
28534
- return null;
28535
- const raw = String(value);
28536
- return `${type[0]}${raw.length}:${raw}`;
28288
+ if (enumValues.length === 0) {
28289
+ return z.never();
28290
+ }
28291
+ if (enumValues.length === 1) {
28292
+ return z.literal(enumValues[0]);
28293
+ }
28294
+ if (enumValues.every((v) => typeof v === "string")) {
28295
+ return z.enum(enumValues);
28296
+ }
28297
+ const literalSchemas = enumValues.map((v) => z.literal(v));
28298
+ if (literalSchemas.length < 2) {
28299
+ return literalSchemas[0];
28300
+ }
28301
+ return z.union([literalSchemas[0], literalSchemas[1], ...literalSchemas.slice(2)]);
28537
28302
  }
28538
- if (seen.has(value))
28539
- return null;
28540
- seen.add(value);
28541
- try {
28542
- if (Array.isArray(value)) {
28543
- const parts2 = [];
28544
- for (const item of value) {
28545
- const key = canonicalKey(item, seen);
28546
- if (key === null)
28547
- return null;
28548
- parts2.push(key);
28303
+ if (schema.const !== void 0) {
28304
+ return z.literal(schema.const);
28305
+ }
28306
+ const type = schema.type;
28307
+ if (Array.isArray(type)) {
28308
+ const typeSchemas = type.map((t) => {
28309
+ const typeSchema = { ...schema, type: t };
28310
+ return convertBaseSchema(typeSchema, ctx);
28311
+ });
28312
+ if (typeSchemas.length === 0) {
28313
+ return z.never();
28314
+ }
28315
+ if (typeSchemas.length === 1) {
28316
+ return typeSchemas[0];
28317
+ }
28318
+ return z.union(typeSchemas);
28319
+ }
28320
+ if (!type) {
28321
+ return z.any();
28322
+ }
28323
+ let zodSchema;
28324
+ switch (type) {
28325
+ case "string": {
28326
+ let stringSchema = z.string();
28327
+ if (schema.format) {
28328
+ const format = schema.format;
28329
+ if (format === "email") {
28330
+ stringSchema = stringSchema.check(z.email());
28331
+ } else if (format === "uri" || format === "uri-reference") {
28332
+ stringSchema = stringSchema.check(z.url());
28333
+ } else if (format === "uuid" || format === "guid") {
28334
+ stringSchema = stringSchema.check(z.uuid());
28335
+ } else if (format === "date-time") {
28336
+ stringSchema = stringSchema.check(z.iso.datetime({ offset: true }));
28337
+ } else if (format === "date") {
28338
+ stringSchema = stringSchema.check(z.iso.date());
28339
+ } else if (format === "time") {
28340
+ stringSchema = stringSchema.check(z.regex(fullTime));
28341
+ } else if (format === "duration") {
28342
+ stringSchema = stringSchema.check(z.iso.duration());
28343
+ } else if (format === "hostname") {
28344
+ stringSchema = stringSchema.check(z.hostname());
28345
+ } else if (format === "ipv4") {
28346
+ stringSchema = stringSchema.check(z.ipv4());
28347
+ } else if (format === "ipv6") {
28348
+ stringSchema = stringSchema.check(z.ipv6());
28349
+ } else if (format === "mac") {
28350
+ stringSchema = stringSchema.check(z.mac());
28351
+ } else if (format === "cidr") {
28352
+ stringSchema = stringSchema.check(z.cidrv4());
28353
+ } else if (format === "cidr-v6") {
28354
+ stringSchema = stringSchema.check(z.cidrv6());
28355
+ } else if (format === "base64") {
28356
+ stringSchema = stringSchema.check(z.base64());
28357
+ } else if (format === "base64url") {
28358
+ stringSchema = stringSchema.check(z.base64url());
28359
+ } else if (format === "e164") {
28360
+ stringSchema = stringSchema.check(z.e164());
28361
+ } else if (format === "credit_card") {
28362
+ stringSchema = stringSchema.check(z.creditCard());
28363
+ } else if (format === "iban") {
28364
+ stringSchema = stringSchema.check(z.iban());
28365
+ } else if (format === "jwt") {
28366
+ stringSchema = stringSchema.check(z.jwt());
28367
+ } else if (format === "emoji") {
28368
+ stringSchema = stringSchema.check(z.emoji());
28369
+ } else if (format === "nanoid") {
28370
+ stringSchema = stringSchema.check(z.nanoid());
28371
+ } else if (format === "cuid") {
28372
+ stringSchema = stringSchema.check(z.cuid());
28373
+ } else if (format === "cuid2") {
28374
+ stringSchema = stringSchema.check(z.cuid2());
28375
+ } else if (format === "ulid") {
28376
+ stringSchema = stringSchema.check(z.ulid());
28377
+ } else if (format === "xid") {
28378
+ stringSchema = stringSchema.check(z.xid());
28379
+ } else if (format === "ksuid") {
28380
+ stringSchema = stringSchema.check(z.ksuid());
28381
+ }
28382
+ }
28383
+ if (typeof schema.minLength === "number") {
28384
+ stringSchema = stringSchema.min(schema.minLength);
28385
+ }
28386
+ if (typeof schema.maxLength === "number") {
28387
+ stringSchema = stringSchema.max(schema.maxLength);
28388
+ }
28389
+ if (schema.pattern) {
28390
+ stringSchema = stringSchema.regex(new RegExp(schema.pattern));
28391
+ }
28392
+ zodSchema = stringSchema;
28393
+ break;
28394
+ }
28395
+ case "number":
28396
+ case "integer": {
28397
+ let numberSchema = type === "integer" ? z.number().int() : z.number();
28398
+ if (typeof schema.minimum === "number" && schema.exclusiveMinimum !== true) {
28399
+ numberSchema = numberSchema.min(schema.minimum);
28400
+ }
28401
+ if (typeof schema.maximum === "number" && schema.exclusiveMaximum !== true) {
28402
+ numberSchema = numberSchema.max(schema.maximum);
28403
+ }
28404
+ if (typeof schema.exclusiveMinimum === "number") {
28405
+ numberSchema = numberSchema.gt(schema.exclusiveMinimum);
28406
+ } else if (schema.exclusiveMinimum === true && typeof schema.minimum === "number") {
28407
+ numberSchema = numberSchema.gt(schema.minimum);
28408
+ }
28409
+ if (typeof schema.exclusiveMaximum === "number") {
28410
+ numberSchema = numberSchema.lt(schema.exclusiveMaximum);
28411
+ } else if (schema.exclusiveMaximum === true && typeof schema.maximum === "number") {
28412
+ numberSchema = numberSchema.lt(schema.maximum);
28413
+ }
28414
+ if (typeof schema.multipleOf === "number") {
28415
+ numberSchema = numberSchema.multipleOf(schema.multipleOf);
28549
28416
  }
28550
- return `a${parts2.length}:[${parts2.join(",")}]`;
28417
+ zodSchema = numberSchema;
28418
+ break;
28551
28419
  }
28552
- const keys = Object.keys(value).sort();
28553
- const parts = [];
28554
- for (const k of keys) {
28555
- const key = canonicalKey(value[k], seen);
28556
- if (key === null)
28557
- return null;
28558
- parts.push(`${k.length}:${k}=${key}`);
28420
+ case "boolean": {
28421
+ zodSchema = z.boolean();
28422
+ break;
28559
28423
  }
28560
- return `o${parts.length}:{${parts.join(",")}}`;
28561
- } finally {
28562
- seen.delete(value);
28563
- }
28564
- }
28565
- var SCHEMA_KEYWORDS = /* @__PURE__ */ new Set([
28566
- "items",
28567
- "prefixItems",
28568
- "additionalItems",
28569
- "additionalProperties",
28570
- "contains",
28571
- "propertyNames",
28572
- "not",
28573
- "if",
28574
- "then",
28575
- "else",
28576
- "allOf",
28577
- "anyOf",
28578
- "oneOf",
28579
- "unevaluatedItems",
28580
- "unevaluatedProperties",
28581
- "contentSchema"
28582
- ]);
28583
- var SCHEMA_MAP_KEYWORDS = /* @__PURE__ */ new Set([
28584
- "properties",
28585
- "patternProperties",
28586
- "dependentSchemas",
28587
- "dependencies",
28588
- "$defs",
28589
- "definitions"
28590
- ]);
28591
- function containsRef(value) {
28592
- if (typeof value !== "object" || value === null)
28593
- return false;
28594
- if (Array.isArray(value))
28595
- return value.some(containsRef);
28596
- if (typeof value.$ref === "string")
28597
- return true;
28598
- return Object.entries(value).some(([key, sub]) => {
28599
- if (SCHEMA_KEYWORDS.has(key))
28600
- return containsRef(sub);
28601
- if (!SCHEMA_MAP_KEYWORDS.has(key) || typeof sub !== "object" || sub === null)
28602
- return false;
28603
- return Object.values(sub).some(containsRef);
28604
- });
28605
- }
28606
- function plural(n) {
28607
- return n === 1 ? "element" : "elements";
28608
- }
28609
- function checkArrayGuards(arraySchema, guards) {
28610
- const guard = z.transform((value) => value).check((payload) => {
28611
- const items = payload.value;
28612
- if (!Array.isArray(items))
28613
- return;
28614
- if (guards.uniqueItems === true) {
28615
- const firstSeen = /* @__PURE__ */ new Map();
28616
- for (let i = 0; i < items.length; i++) {
28617
- const key = canonicalKey(items[i], /* @__PURE__ */ new Set());
28618
- if (key === null)
28619
- continue;
28620
- const first = firstSeen.get(key);
28621
- if (first === void 0) {
28622
- firstSeen.set(key, i);
28623
- continue;
28424
+ case "null": {
28425
+ zodSchema = z.null();
28426
+ break;
28427
+ }
28428
+ case "object": {
28429
+ const shape = {};
28430
+ const properties = schema.properties || {};
28431
+ const requiredSet = new Set(schema.required || []);
28432
+ const additionalSchema = typeof schema.additionalProperties === "object" ? convertSchema(schema.additionalProperties, ctx) : void 0;
28433
+ for (const [key, propSchema] of Object.entries(properties)) {
28434
+ const propZodSchema = convertSchema(propSchema, ctx);
28435
+ assignProp(shape, key, requiredSet.has(key) ? propZodSchema : propZodSchema.optional());
28436
+ }
28437
+ if (schema.patternProperties) {
28438
+ const patternProps = schema.patternProperties;
28439
+ const patternKeys = Object.keys(patternProps);
28440
+ const looseRecords = [];
28441
+ for (const pattern of patternKeys) {
28442
+ const patternValue = convertSchema(patternProps[pattern], ctx);
28443
+ const keySchema = z.string().regex(new RegExp(pattern));
28444
+ looseRecords.push(z.looseRecord(keySchema, patternValue));
28445
+ }
28446
+ const schemasToIntersect = [];
28447
+ if (Object.keys(shape).length > 0) {
28448
+ schemasToIntersect.push(z.object(shape).passthrough());
28449
+ }
28450
+ schemasToIntersect.push(...looseRecords);
28451
+ if (schemasToIntersect.length === 0) {
28452
+ zodSchema = z.object({}).passthrough();
28453
+ } else if (schemasToIntersect.length === 1) {
28454
+ zodSchema = schemasToIntersect[0];
28455
+ } else {
28456
+ let result = z.intersection(schemasToIntersect[0], schemasToIntersect[1]);
28457
+ for (let i = 2; i < schemasToIntersect.length; i++) {
28458
+ result = z.intersection(result, schemasToIntersect[i]);
28459
+ }
28460
+ zodSchema = result;
28461
+ }
28462
+ if (schema.additionalProperties === false) {
28463
+ const propertyKeys = Object.keys(shape);
28464
+ const patterns = patternKeys.map((p) => new RegExp(p));
28465
+ const basePatternSchema = zodSchema;
28466
+ zodSchema = zodSchema.check((payload) => {
28467
+ if (!isPlainObject(payload.value))
28468
+ return;
28469
+ const unrecognized = [];
28470
+ for (const key of Object.keys(payload.value)) {
28471
+ if (propertyKeys.includes(key))
28472
+ continue;
28473
+ if (patterns.some((regex) => regex.test(key)))
28474
+ continue;
28475
+ unrecognized.push(key);
28476
+ }
28477
+ if (unrecognized.length) {
28478
+ payload.issues.push({
28479
+ code: "unrecognized_keys",
28480
+ keys: unrecognized,
28481
+ input: payload.value,
28482
+ inst: basePatternSchema
28483
+ });
28484
+ }
28485
+ });
28486
+ }
28487
+ } else {
28488
+ const objectSchema = z.object(shape);
28489
+ if (schema.additionalProperties === false) {
28490
+ zodSchema = objectSchema.strict();
28491
+ } else if (additionalSchema) {
28492
+ zodSchema = objectSchema.catchall(additionalSchema);
28493
+ } else {
28494
+ zodSchema = objectSchema.passthrough();
28624
28495
  }
28625
- payload.issues.push({
28626
- code: "custom",
28627
- message: `Array items must be unique: element at index ${i} duplicates the one at index ${first}`,
28628
- input: items,
28629
- path: [i],
28630
- continue: true
28631
- });
28632
28496
  }
28633
- }
28634
- if (guards.containsSchema) {
28635
- const minContains = guards.minContains ?? 1;
28636
- const ceiling = guards.maxContains !== void 0 ? guards.maxContains + 1 : Number.POSITIVE_INFINITY;
28637
- let matches = 0;
28638
- for (const item of items) {
28639
- if (guards.containsSchema.safeParse(item).success && ++matches >= ceiling)
28640
- break;
28497
+ const hasKeyGuard = schema.propertyNames !== void 0 && schema.propertyNames !== true;
28498
+ const minProperties = typeof schema.minProperties === "number" ? schema.minProperties : void 0;
28499
+ const maxProperties = typeof schema.maxProperties === "number" ? schema.maxProperties : void 0;
28500
+ if (hasKeyGuard || minProperties !== void 0 || maxProperties !== void 0) {
28501
+ let keySchema;
28502
+ if (hasKeyGuard) {
28503
+ const keyJSONSchema = typeof schema.propertyNames === "object" && schema.propertyNames.type === void 0 ? { type: "string", ...schema.propertyNames } : schema.propertyNames;
28504
+ keySchema = convertSchema(keyJSONSchema, ctx);
28505
+ }
28506
+ zodSchema = checkObjectGuards(zodSchema, { keySchema, minProperties, maxProperties });
28641
28507
  }
28642
- if (matches < minContains) {
28643
- payload.issues.push({
28644
- code: "custom",
28645
- message: `Array must contain at least ${minContains} matching ${plural(minContains)}; found ${matches}`,
28646
- input: items,
28647
- continue: true
28648
- });
28508
+ break;
28509
+ }
28510
+ case "array": {
28511
+ const prefixItems = schema.prefixItems;
28512
+ const items = schema.items;
28513
+ if (prefixItems && Array.isArray(prefixItems)) {
28514
+ const minItems = typeof schema.minItems === "number" ? schema.minItems : 0;
28515
+ const tupleItems = prefixItems.map((item) => convertSchema(item, ctx));
28516
+ const positionalItems = applyMinItems(tupleItems, minItems);
28517
+ const rest = !Array.isArray(items) ? getTupleRest(items, ctx) : void 0;
28518
+ const tupleSchema = z.tuple(positionalItems);
28519
+ zodSchema = rest ? tupleSchema.rest(rest) : tupleSchema;
28520
+ if (typeof schema.minItems === "number") {
28521
+ zodSchema = zodSchema.check(z.minLength(schema.minItems));
28522
+ }
28523
+ if (typeof schema.maxItems === "number") {
28524
+ zodSchema = zodSchema.check(z.maxLength(schema.maxItems));
28525
+ }
28526
+ } else if (Array.isArray(items)) {
28527
+ const minItems = typeof schema.minItems === "number" ? schema.minItems : 0;
28528
+ const tupleItems = items.map((item) => convertSchema(item, ctx));
28529
+ const positionalItems = applyMinItems(tupleItems, minItems);
28530
+ const rest = getTupleRest(schema.additionalItems, ctx);
28531
+ const tupleSchema = z.tuple(positionalItems);
28532
+ zodSchema = rest ? tupleSchema.rest(rest) : tupleSchema;
28533
+ if (typeof schema.minItems === "number") {
28534
+ zodSchema = zodSchema.check(z.minLength(schema.minItems));
28535
+ }
28536
+ if (typeof schema.maxItems === "number") {
28537
+ zodSchema = zodSchema.check(z.maxLength(schema.maxItems));
28538
+ }
28539
+ } else if (items !== void 0) {
28540
+ const element = convertSchema(items, ctx);
28541
+ let arraySchema = z.array(element);
28542
+ if (typeof schema.minItems === "number") {
28543
+ arraySchema = arraySchema.min(schema.minItems);
28544
+ }
28545
+ if (typeof schema.maxItems === "number") {
28546
+ arraySchema = arraySchema.max(schema.maxItems);
28547
+ }
28548
+ zodSchema = arraySchema;
28549
+ } else {
28550
+ zodSchema = z.array(z.any());
28649
28551
  }
28650
- if (guards.maxContains !== void 0 && matches > guards.maxContains) {
28651
- payload.issues.push({
28652
- code: "custom",
28653
- message: `Array must contain at most ${guards.maxContains} matching ${plural(guards.maxContains)}`,
28654
- input: items,
28655
- continue: true
28552
+ if (schema.uniqueItems === true || schema.contains !== void 0) {
28553
+ zodSchema = checkArrayGuards(zodSchema, {
28554
+ uniqueItems: schema.uniqueItems === true,
28555
+ containsSchema: schema.contains !== void 0 ? convertSchema(schema.contains, ctx) : void 0,
28556
+ minContains: typeof schema.minContains === "number" ? schema.minContains : void 0,
28557
+ maxContains: typeof schema.maxContains === "number" ? schema.maxContains : void 0
28656
28558
  });
28657
28559
  }
28560
+ break;
28658
28561
  }
28659
- });
28660
- return guard.pipe(arraySchema);
28562
+ default:
28563
+ throw new Error(`Unsupported type: ${type}`);
28564
+ }
28565
+ return zodSchema;
28661
28566
  }
28662
- function getTupleRest(restSchema, ctx) {
28663
- if (restSchema === false) {
28664
- return void 0;
28567
+ function convertSchema(schema, ctx) {
28568
+ if (typeof schema === "boolean") {
28569
+ return schema ? z.any() : z.never();
28570
+ }
28571
+ let baseSchema = convertBaseSchema(schema, ctx);
28572
+ const hasExplicitType = schema.type || schema.enum !== void 0 || schema.const !== void 0;
28573
+ if (schema.anyOf && Array.isArray(schema.anyOf)) {
28574
+ const options = schema.anyOf.map((s) => convertSchema(s, ctx));
28575
+ const anyOfUnion = z.union(options);
28576
+ baseSchema = hasExplicitType ? z.intersection(baseSchema, anyOfUnion) : anyOfUnion;
28665
28577
  }
28666
- if (restSchema === void 0 || restSchema === true) {
28667
- return z.any();
28578
+ if (schema.oneOf && Array.isArray(schema.oneOf)) {
28579
+ const options = schema.oneOf.map((s) => convertSchema(s, ctx));
28580
+ const oneOfUnion = z.xor(options);
28581
+ baseSchema = hasExplicitType ? z.intersection(baseSchema, oneOfUnion) : oneOfUnion;
28668
28582
  }
28669
- return convertSchema(restSchema, ctx);
28670
- }
28671
- var fullTime = /^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;
28672
- function convertBaseSchema(schema, ctx) {
28673
- if (schema.not !== void 0) {
28674
- if (typeof schema.not === "object" && Object.keys(schema.not).length === 0) {
28675
- return z.never();
28583
+ if (schema.allOf && Array.isArray(schema.allOf)) {
28584
+ if (schema.allOf.length === 0) {
28585
+ baseSchema = hasExplicitType ? baseSchema : z.any();
28586
+ } else {
28587
+ let result = hasExplicitType ? baseSchema : convertSchema(schema.allOf[0], ctx);
28588
+ const startIdx = hasExplicitType ? 0 : 1;
28589
+ for (let i = startIdx; i < schema.allOf.length; i++) {
28590
+ result = z.intersection(result, convertSchema(schema.allOf[i], ctx));
28591
+ }
28592
+ baseSchema = result;
28676
28593
  }
28677
- throw new Error("not is not supported in Zod (except { not: {} } for never)");
28678
- }
28679
- if (schema.unevaluatedItems !== void 0) {
28680
- throw new Error("unevaluatedItems is not supported");
28681
28594
  }
28682
- if (schema.unevaluatedProperties !== void 0) {
28683
- throw new Error("unevaluatedProperties is not supported");
28595
+ if (schema.nullable === true && ctx.version === "openapi-3.0") {
28596
+ baseSchema = z.nullable(baseSchema);
28684
28597
  }
28685
- if (schema.if !== void 0 || schema.then !== void 0 || schema.else !== void 0) {
28686
- throw new Error("Conditional schemas (if/then/else) are not supported");
28598
+ if (schema.readOnly === true) {
28599
+ baseSchema = z.readonly(baseSchema);
28687
28600
  }
28688
- if (schema.dependentSchemas !== void 0 || schema.dependentRequired !== void 0) {
28689
- throw new Error("dependentSchemas and dependentRequired are not supported");
28601
+ if (schema.default !== void 0) {
28602
+ baseSchema = baseSchema.default(schema.default);
28690
28603
  }
28691
- if (schema.$ref) {
28692
- const refPath = schema.$ref;
28693
- if (ctx.refs.has(refPath)) {
28694
- return ctx.refs.get(refPath);
28604
+ const extraMeta = {};
28605
+ const coreMetadataKeys = ["$id", "id", "$comment", "$anchor", "$vocabulary", "$dynamicRef", "$dynamicAnchor"];
28606
+ for (const key of coreMetadataKeys) {
28607
+ if (key in schema) {
28608
+ extraMeta[key] = schema[key];
28695
28609
  }
28696
- if (ctx.processing.has(refPath)) {
28697
- return z.lazy(() => {
28698
- if (!ctx.refs.has(refPath)) {
28699
- throw new Error(`Circular reference not resolved: ${refPath}`);
28700
- }
28701
- return ctx.refs.get(refPath);
28702
- });
28610
+ }
28611
+ const contentMetadataKeys = ["contentEncoding", "contentMediaType", "contentSchema"];
28612
+ for (const key of contentMetadataKeys) {
28613
+ if (key in schema) {
28614
+ extraMeta[key] = schema[key];
28703
28615
  }
28704
- ctx.processing.add(refPath);
28705
- const resolved = resolveRef(refPath, ctx);
28706
- const zodSchema2 = convertSchema(resolved, ctx);
28707
- ctx.refs.set(refPath, zodSchema2);
28708
- ctx.processing.delete(refPath);
28709
- return zodSchema2;
28710
28616
  }
28711
- if (schema.enum !== void 0) {
28712
- const enumValues = schema.enum;
28713
- if (ctx.version === "openapi-3.0" && schema.nullable === true && enumValues.length === 1 && enumValues[0] === null) {
28714
- return z.null();
28617
+ if (schema.type === "object" && schema.$ref === void 0) {
28618
+ if (schema.propertyNames !== void 0 && !containsRef(schema.propertyNames)) {
28619
+ extraMeta.propertyNames = schema.propertyNames;
28715
28620
  }
28716
- if (enumValues.length === 0) {
28717
- return z.never();
28621
+ for (const key of ["minProperties", "maxProperties"]) {
28622
+ if (schema[key] !== void 0)
28623
+ extraMeta[key] = schema[key];
28718
28624
  }
28719
- if (enumValues.length === 1) {
28720
- return z.literal(enumValues[0]);
28625
+ }
28626
+ if (schema.type === "array" && schema.$ref === void 0) {
28627
+ if (schema.contains !== void 0 && !containsRef(schema.contains)) {
28628
+ extraMeta.contains = schema.contains;
28721
28629
  }
28722
- if (enumValues.every((v) => typeof v === "string")) {
28723
- return z.enum(enumValues);
28630
+ for (const key of ["uniqueItems", "minContains", "maxContains"]) {
28631
+ if (schema[key] !== void 0)
28632
+ extraMeta[key] = schema[key];
28724
28633
  }
28725
- const literalSchemas = enumValues.map((v) => z.literal(v));
28726
- if (literalSchemas.length < 2) {
28727
- return literalSchemas[0];
28634
+ }
28635
+ for (const key of Object.keys(schema)) {
28636
+ if (!RECOGNIZED_KEYS.has(key)) {
28637
+ assignProp(extraMeta, key, schema[key]);
28728
28638
  }
28729
- return z.union([literalSchemas[0], literalSchemas[1], ...literalSchemas.slice(2)]);
28730
28639
  }
28731
- if (schema.const !== void 0) {
28732
- return z.literal(schema.const);
28640
+ if (Object.keys(extraMeta).length > 0) {
28641
+ ctx.registry.add(baseSchema, extraMeta);
28733
28642
  }
28734
- const type = schema.type;
28735
- if (Array.isArray(type)) {
28736
- const typeSchemas = type.map((t) => {
28737
- const typeSchema = { ...schema, type: t };
28738
- return convertBaseSchema(typeSchema, ctx);
28739
- });
28740
- if (typeSchemas.length === 0) {
28741
- return z.never();
28742
- }
28743
- if (typeSchemas.length === 1) {
28744
- return typeSchemas[0];
28745
- }
28746
- return z.union(typeSchemas);
28643
+ if (schema.description) {
28644
+ baseSchema = baseSchema.describe(schema.description);
28747
28645
  }
28748
- if (!type) {
28749
- return z.any();
28646
+ return baseSchema;
28647
+ }
28648
+ function fromJSONSchema(schema, params) {
28649
+ if (typeof schema === "boolean") {
28650
+ return schema ? z.any() : z.never();
28750
28651
  }
28751
- let zodSchema;
28752
- switch (type) {
28753
- case "string": {
28754
- let stringSchema = z.string();
28755
- if (schema.format) {
28756
- const format = schema.format;
28757
- if (format === "email") {
28758
- stringSchema = stringSchema.check(z.email());
28759
- } else if (format === "uri" || format === "uri-reference") {
28760
- stringSchema = stringSchema.check(z.url());
28761
- } else if (format === "uuid" || format === "guid") {
28762
- stringSchema = stringSchema.check(z.uuid());
28763
- } else if (format === "date-time") {
28764
- stringSchema = stringSchema.check(z.iso.datetime({ offset: true }));
28765
- } else if (format === "date") {
28766
- stringSchema = stringSchema.check(z.iso.date());
28767
- } else if (format === "time") {
28768
- stringSchema = stringSchema.check(z.regex(fullTime));
28769
- } else if (format === "duration") {
28770
- stringSchema = stringSchema.check(z.iso.duration());
28771
- } else if (format === "hostname") {
28772
- stringSchema = stringSchema.check(z.hostname());
28773
- } else if (format === "ipv4") {
28774
- stringSchema = stringSchema.check(z.ipv4());
28775
- } else if (format === "ipv6") {
28776
- stringSchema = stringSchema.check(z.ipv6());
28777
- } else if (format === "mac") {
28778
- stringSchema = stringSchema.check(z.mac());
28779
- } else if (format === "cidr") {
28780
- stringSchema = stringSchema.check(z.cidrv4());
28781
- } else if (format === "cidr-v6") {
28782
- stringSchema = stringSchema.check(z.cidrv6());
28783
- } else if (format === "base64") {
28784
- stringSchema = stringSchema.check(z.base64());
28785
- } else if (format === "base64url") {
28786
- stringSchema = stringSchema.check(z.base64url());
28787
- } else if (format === "e164") {
28788
- stringSchema = stringSchema.check(z.e164());
28789
- } else if (format === "credit_card") {
28790
- stringSchema = stringSchema.check(z.creditCard());
28791
- } else if (format === "iban") {
28792
- stringSchema = stringSchema.check(z.iban());
28793
- } else if (format === "jwt") {
28794
- stringSchema = stringSchema.check(z.jwt());
28795
- } else if (format === "emoji") {
28796
- stringSchema = stringSchema.check(z.emoji());
28797
- } else if (format === "nanoid") {
28798
- stringSchema = stringSchema.check(z.nanoid());
28799
- } else if (format === "cuid") {
28800
- stringSchema = stringSchema.check(z.cuid());
28801
- } else if (format === "cuid2") {
28802
- stringSchema = stringSchema.check(z.cuid2());
28803
- } else if (format === "ulid") {
28804
- stringSchema = stringSchema.check(z.ulid());
28805
- } else if (format === "xid") {
28806
- stringSchema = stringSchema.check(z.xid());
28807
- } else if (format === "ksuid") {
28808
- stringSchema = stringSchema.check(z.ksuid());
28652
+ let normalized;
28653
+ try {
28654
+ normalized = JSON.parse(JSON.stringify(schema));
28655
+ } catch {
28656
+ throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas");
28657
+ }
28658
+ const version2 = detectVersion(normalized, params?.defaultTarget);
28659
+ const defs = normalized.$defs || normalized.definitions || {};
28660
+ const ctx = {
28661
+ version: version2,
28662
+ defs,
28663
+ refs: /* @__PURE__ */ new Map(),
28664
+ processing: /* @__PURE__ */ new Set(),
28665
+ rootSchema: normalized,
28666
+ registry: params?.registry ?? globalRegistry
28667
+ };
28668
+ return convertSchema(normalized, ctx);
28669
+ }
28670
+
28671
+ // ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/visit.js
28672
+ var RESOLVING = /* @__PURE__ */ Symbol("z.visit/resolving");
28673
+ function visit(schema, fnOrHandlers) {
28674
+ const fn = typeof fnOrHandlers === "function" ? fnOrHandlers : (node2, rewritten) => {
28675
+ const h = fnOrHandlers[node2._zod.def.type];
28676
+ return h ? h(node2, rewritten) : node2;
28677
+ };
28678
+ const cache = /* @__PURE__ */ new Map();
28679
+ function run2(s) {
28680
+ const cached2 = cache.get(s);
28681
+ if (cached2 === RESOLVING) {
28682
+ return new $ZodLazy({
28683
+ type: "lazy",
28684
+ getter: () => cache.get(s)
28685
+ });
28686
+ }
28687
+ if (cached2 !== void 0)
28688
+ return cached2;
28689
+ cache.set(s, RESOLVING);
28690
+ const inner = mapInner(s);
28691
+ const mapped = fn(inner, inner !== s);
28692
+ cache.set(s, mapped);
28693
+ return mapped;
28694
+ }
28695
+ function mapInner(s) {
28696
+ const def = s._zod.def;
28697
+ const kind = def.type;
28698
+ switch (kind) {
28699
+ case "object": {
28700
+ const oldShape = def.shape;
28701
+ const keys = Object.keys(oldShape);
28702
+ let changed = false;
28703
+ const newShape = {};
28704
+ for (const k of keys) {
28705
+ const mapped = run2(oldShape[k]);
28706
+ if (mapped !== oldShape[k])
28707
+ changed = true;
28708
+ newShape[k] = mapped;
28709
+ }
28710
+ let newCatchall = def.catchall;
28711
+ if (def.catchall) {
28712
+ newCatchall = run2(def.catchall);
28713
+ if (newCatchall !== def.catchall)
28714
+ changed = true;
28715
+ }
28716
+ return changed ? clone(s, { ...def, shape: newShape, catchall: newCatchall }) : s;
28717
+ }
28718
+ case "array": {
28719
+ const mapped = run2(def.element);
28720
+ return mapped === def.element ? s : clone(s, { ...def, element: mapped });
28721
+ }
28722
+ case "tuple": {
28723
+ const oldItems = def.items;
28724
+ let changed = false;
28725
+ const newItems = [];
28726
+ for (const item of oldItems) {
28727
+ const mapped = run2(item);
28728
+ if (mapped !== item)
28729
+ changed = true;
28730
+ newItems.push(mapped);
28809
28731
  }
28732
+ let newRest = def.rest;
28733
+ if (def.rest) {
28734
+ newRest = run2(def.rest);
28735
+ if (newRest !== def.rest)
28736
+ changed = true;
28737
+ }
28738
+ return changed ? clone(s, { ...def, items: newItems, rest: newRest }) : s;
28810
28739
  }
28811
- if (typeof schema.minLength === "number") {
28812
- stringSchema = stringSchema.min(schema.minLength);
28813
- }
28814
- if (typeof schema.maxLength === "number") {
28815
- stringSchema = stringSchema.max(schema.maxLength);
28816
- }
28817
- if (schema.pattern) {
28818
- stringSchema = stringSchema.regex(new RegExp(schema.pattern));
28740
+ case "record":
28741
+ case "map": {
28742
+ const newKey = run2(def.keyType);
28743
+ const newVal = run2(def.valueType);
28744
+ return newKey === def.keyType && newVal === def.valueType ? s : clone(s, { ...def, keyType: newKey, valueType: newVal });
28819
28745
  }
28820
- zodSchema = stringSchema;
28821
- break;
28822
- }
28823
- case "number":
28824
- case "integer": {
28825
- let numberSchema = type === "integer" ? z.number().int() : z.number();
28826
- if (typeof schema.minimum === "number" && schema.exclusiveMinimum !== true) {
28827
- numberSchema = numberSchema.min(schema.minimum);
28746
+ case "set": {
28747
+ const newVal = run2(def.valueType);
28748
+ return newVal === def.valueType ? s : clone(s, { ...def, valueType: newVal });
28828
28749
  }
28829
- if (typeof schema.maximum === "number" && schema.exclusiveMaximum !== true) {
28830
- numberSchema = numberSchema.max(schema.maximum);
28750
+ case "union": {
28751
+ const oldOptions = def.options;
28752
+ let changed = false;
28753
+ const newOptions = [];
28754
+ for (const opt of oldOptions) {
28755
+ const mapped = run2(opt);
28756
+ if (mapped !== opt)
28757
+ changed = true;
28758
+ newOptions.push(mapped);
28759
+ }
28760
+ return changed ? clone(s, { ...def, options: newOptions }) : s;
28831
28761
  }
28832
- if (typeof schema.exclusiveMinimum === "number") {
28833
- numberSchema = numberSchema.gt(schema.exclusiveMinimum);
28834
- } else if (schema.exclusiveMinimum === true && typeof schema.minimum === "number") {
28835
- numberSchema = numberSchema.gt(schema.minimum);
28762
+ case "intersection": {
28763
+ const newLeft = run2(def.left);
28764
+ const newRight = run2(def.right);
28765
+ return newLeft === def.left && newRight === def.right ? s : clone(s, { ...def, left: newLeft, right: newRight });
28836
28766
  }
28837
- if (typeof schema.exclusiveMaximum === "number") {
28838
- numberSchema = numberSchema.lt(schema.exclusiveMaximum);
28839
- } else if (schema.exclusiveMaximum === true && typeof schema.maximum === "number") {
28840
- numberSchema = numberSchema.lt(schema.maximum);
28767
+ case "optional":
28768
+ case "nullable":
28769
+ case "default":
28770
+ case "prefault":
28771
+ case "catch":
28772
+ case "readonly":
28773
+ case "nonoptional":
28774
+ case "promise":
28775
+ case "success": {
28776
+ const newInner = run2(def.innerType);
28777
+ return newInner === def.innerType ? s : clone(s, { ...def, innerType: newInner });
28841
28778
  }
28842
- if (typeof schema.multipleOf === "number") {
28843
- numberSchema = numberSchema.multipleOf(schema.multipleOf);
28779
+ case "pipe": {
28780
+ const newIn = run2(def.in);
28781
+ const newOut = run2(def.out);
28782
+ return newIn === def.in && newOut === def.out ? s : clone(s, { ...def, in: newIn, out: newOut });
28844
28783
  }
28845
- zodSchema = numberSchema;
28846
- break;
28847
- }
28848
- case "boolean": {
28849
- zodSchema = z.boolean();
28850
- break;
28851
- }
28852
- case "null": {
28853
- zodSchema = z.null();
28854
- break;
28855
- }
28856
- case "object": {
28857
- const shape = {};
28858
- const properties = schema.properties || {};
28859
- const requiredSet = new Set(schema.required || []);
28860
- const additionalSchema = typeof schema.additionalProperties === "object" ? convertSchema(schema.additionalProperties, ctx) : void 0;
28861
- for (const [key, propSchema] of Object.entries(properties)) {
28862
- const propZodSchema = convertSchema(propSchema, ctx);
28863
- assignProp(shape, key, requiredSet.has(key) ? propZodSchema : propZodSchema.optional());
28784
+ case "function": {
28785
+ const newInput = run2(def.input);
28786
+ const newOutput = run2(def.output);
28787
+ return newInput === def.input && newOutput === def.output ? s : clone(s, { ...def, input: newInput, output: newOutput });
28864
28788
  }
28865
- if (schema.patternProperties) {
28866
- const patternProps = schema.patternProperties;
28867
- const patternKeys = Object.keys(patternProps);
28868
- const looseRecords = [];
28869
- for (const pattern of patternKeys) {
28870
- const patternValue = convertSchema(patternProps[pattern], ctx);
28871
- const keySchema = z.string().regex(new RegExp(pattern));
28872
- looseRecords.push(z.looseRecord(keySchema, patternValue));
28873
- }
28874
- const schemasToIntersect = [];
28875
- if (Object.keys(shape).length > 0) {
28876
- schemasToIntersect.push(z.object(shape).passthrough());
28877
- }
28878
- schemasToIntersect.push(...looseRecords);
28879
- if (schemasToIntersect.length === 0) {
28880
- zodSchema = z.object({}).passthrough();
28881
- } else if (schemasToIntersect.length === 1) {
28882
- zodSchema = schemasToIntersect[0];
28883
- } else {
28884
- let result = z.intersection(schemasToIntersect[0], schemasToIntersect[1]);
28885
- for (let i = 2; i < schemasToIntersect.length; i++) {
28886
- result = z.intersection(result, schemasToIntersect[i]);
28887
- }
28888
- zodSchema = result;
28889
- }
28890
- if (schema.additionalProperties === false) {
28891
- const propertyKeys = Object.keys(shape);
28892
- const patterns = patternKeys.map((p) => new RegExp(p));
28893
- const basePatternSchema = zodSchema;
28894
- zodSchema = zodSchema.check((payload) => {
28895
- if (!isPlainObject(payload.value))
28896
- return;
28897
- const unrecognized = [];
28898
- for (const key of Object.keys(payload.value)) {
28899
- if (propertyKeys.includes(key))
28900
- continue;
28901
- if (patterns.some((regex) => regex.test(key)))
28902
- continue;
28903
- unrecognized.push(key);
28904
- }
28905
- if (unrecognized.length) {
28906
- payload.issues.push({
28907
- code: "unrecognized_keys",
28908
- keys: unrecognized,
28909
- input: payload.value,
28910
- inst: basePatternSchema
28911
- });
28912
- }
28913
- });
28914
- }
28915
- } else {
28916
- const objectSchema = z.object(shape);
28917
- if (schema.additionalProperties === false) {
28918
- zodSchema = objectSchema.strict();
28919
- } else if (additionalSchema) {
28920
- zodSchema = objectSchema.catchall(additionalSchema);
28921
- } else {
28922
- zodSchema = objectSchema.passthrough();
28923
- }
28789
+ case "lazy": {
28790
+ const original = def.getter;
28791
+ const { _cachedInner, ...rest } = def;
28792
+ return clone(s, { ...rest, getter: () => run2(original()) });
28924
28793
  }
28925
- const hasKeyGuard = schema.propertyNames !== void 0 && schema.propertyNames !== true;
28926
- const minProperties = typeof schema.minProperties === "number" ? schema.minProperties : void 0;
28927
- const maxProperties = typeof schema.maxProperties === "number" ? schema.maxProperties : void 0;
28928
- if (hasKeyGuard || minProperties !== void 0 || maxProperties !== void 0) {
28929
- let keySchema;
28930
- if (hasKeyGuard) {
28931
- const keyJSONSchema = typeof schema.propertyNames === "object" && schema.propertyNames.type === void 0 ? { type: "string", ...schema.propertyNames } : schema.propertyNames;
28932
- keySchema = convertSchema(keyJSONSchema, ctx);
28933
- }
28934
- zodSchema = checkObjectGuards(zodSchema, { keySchema, minProperties, maxProperties });
28794
+ // A leaf by choice: `parts` are regex fragments, not data positions.
28795
+ case "template_literal":
28796
+ // Leaves.
28797
+ case "string":
28798
+ case "number":
28799
+ case "int":
28800
+ case "boolean":
28801
+ case "bigint":
28802
+ case "symbol":
28803
+ case "undefined":
28804
+ case "null":
28805
+ case "void":
28806
+ case "never":
28807
+ case "any":
28808
+ case "unknown":
28809
+ case "date":
28810
+ case "nan":
28811
+ case "enum":
28812
+ case "literal":
28813
+ case "file":
28814
+ case "transform":
28815
+ case "custom":
28816
+ return s;
28817
+ default: {
28818
+ kind;
28819
+ return s;
28935
28820
  }
28936
- break;
28937
28821
  }
28938
- case "array": {
28939
- const prefixItems = schema.prefixItems;
28940
- const items = schema.items;
28941
- if (prefixItems && Array.isArray(prefixItems)) {
28942
- const minItems = typeof schema.minItems === "number" ? schema.minItems : 0;
28943
- const tupleItems = prefixItems.map((item) => convertSchema(item, ctx));
28944
- const positionalItems = applyMinItems(tupleItems, minItems);
28945
- const rest = !Array.isArray(items) ? getTupleRest(items, ctx) : void 0;
28946
- const tupleSchema = z.tuple(positionalItems);
28947
- zodSchema = rest ? tupleSchema.rest(rest) : tupleSchema;
28948
- if (typeof schema.minItems === "number") {
28949
- zodSchema = zodSchema.check(z.minLength(schema.minItems));
28950
- }
28951
- if (typeof schema.maxItems === "number") {
28952
- zodSchema = zodSchema.check(z.maxLength(schema.maxItems));
28953
- }
28954
- } else if (Array.isArray(items)) {
28955
- const minItems = typeof schema.minItems === "number" ? schema.minItems : 0;
28956
- const tupleItems = items.map((item) => convertSchema(item, ctx));
28957
- const positionalItems = applyMinItems(tupleItems, minItems);
28958
- const rest = getTupleRest(schema.additionalItems, ctx);
28959
- const tupleSchema = z.tuple(positionalItems);
28960
- zodSchema = rest ? tupleSchema.rest(rest) : tupleSchema;
28961
- if (typeof schema.minItems === "number") {
28962
- zodSchema = zodSchema.check(z.minLength(schema.minItems));
28963
- }
28964
- if (typeof schema.maxItems === "number") {
28965
- zodSchema = zodSchema.check(z.maxLength(schema.maxItems));
28966
- }
28967
- } else if (items !== void 0) {
28968
- const element = convertSchema(items, ctx);
28969
- let arraySchema = z.array(element);
28970
- if (typeof schema.minItems === "number") {
28971
- arraySchema = arraySchema.min(schema.minItems);
28972
- }
28973
- if (typeof schema.maxItems === "number") {
28974
- arraySchema = arraySchema.max(schema.maxItems);
28975
- }
28976
- zodSchema = arraySchema;
28977
- } else {
28978
- zodSchema = z.array(z.any());
28979
- }
28980
- if (schema.uniqueItems === true || schema.contains !== void 0) {
28981
- zodSchema = checkArrayGuards(zodSchema, {
28982
- uniqueItems: schema.uniqueItems === true,
28983
- containsSchema: schema.contains !== void 0 ? convertSchema(schema.contains, ctx) : void 0,
28984
- minContains: typeof schema.minContains === "number" ? schema.minContains : void 0,
28985
- maxContains: typeof schema.maxContains === "number" ? schema.maxContains : void 0
28986
- });
28987
- }
28988
- break;
28822
+ }
28823
+ return run2(schema);
28824
+ }
28825
+
28826
+ // ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/classic/deep-partial.js
28827
+ function deepPartial(schema) {
28828
+ return visit(schema, {
28829
+ object: (s) => s.partial(),
28830
+ // Every partialed option now admits `undefined`, which the constructor rejects as a duplicate.
28831
+ union: (s) => {
28832
+ const def = s._zod.def;
28833
+ return def.discriminator === void 0 ? s : union(def.options);
28989
28834
  }
28990
- default:
28991
- throw new Error(`Unsupported type: ${type}`);
28992
- }
28993
- return zodSchema;
28835
+ });
28994
28836
  }
28995
- function convertSchema(schema, ctx) {
28996
- if (typeof schema === "boolean") {
28997
- return schema ? z.any() : z.never();
28998
- }
28999
- let baseSchema = convertBaseSchema(schema, ctx);
29000
- const hasExplicitType = schema.type || schema.enum !== void 0 || schema.const !== void 0;
29001
- if (schema.anyOf && Array.isArray(schema.anyOf)) {
29002
- const options = schema.anyOf.map((s) => convertSchema(s, ctx));
29003
- const anyOfUnion = z.union(options);
29004
- baseSchema = hasExplicitType ? z.intersection(baseSchema, anyOfUnion) : anyOfUnion;
29005
- }
29006
- if (schema.oneOf && Array.isArray(schema.oneOf)) {
29007
- const options = schema.oneOf.map((s) => convertSchema(s, ctx));
29008
- const oneOfUnion = z.xor(options);
29009
- baseSchema = hasExplicitType ? z.intersection(baseSchema, oneOfUnion) : oneOfUnion;
29010
- }
29011
- if (schema.allOf && Array.isArray(schema.allOf)) {
29012
- if (schema.allOf.length === 0) {
29013
- baseSchema = hasExplicitType ? baseSchema : z.any();
29014
- } else {
29015
- let result = hasExplicitType ? baseSchema : convertSchema(schema.allOf[0], ctx);
29016
- const startIdx = hasExplicitType ? 0 : 1;
29017
- for (let i = startIdx; i < schema.allOf.length; i++) {
29018
- result = z.intersection(result, convertSchema(schema.allOf[i], ctx));
29019
- }
29020
- baseSchema = result;
28837
+
28838
+ // ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/classic/in-out.js
28839
+ function withChecks(side, checks) {
28840
+ if (!checks?.length)
28841
+ return side;
28842
+ const def = side._zod.def;
28843
+ return clone(side, mergeDefs(def, { checks: [...def.checks ?? [], ...checks] }), { parent: true });
28844
+ }
28845
+ function outSide(def) {
28846
+ return withChecks(def.out, def.checks);
28847
+ }
28848
+ function inSide(def) {
28849
+ return def.in._zod.traits.has("$ZodTransform") ? outSide(def) : def.in;
28850
+ }
28851
+ function input(schema) {
28852
+ return visit(schema, {
28853
+ pipe: (s) => inSide(s._zod.def),
28854
+ // A default value belongs to the output side, so a rewritten inner type leaves it stranded. `.default()` widens the declared input type with `undefined`, and `optional` is what carries that across.
28855
+ default: (s, rewritten) => rewritten ? optional(s._zod.def.innerType) : s,
28856
+ // A catch value is output-side too, but `.catch()` leaves the declared input type alone, so the inner schema stands on its own.
28857
+ catch: (s, rewritten) => rewritten ? s._zod.def.innerType : s
28858
+ });
28859
+ }
28860
+ function output(schema) {
28861
+ return visit(schema, {
28862
+ pipe: (s) => outSide(s._zod.def),
28863
+ // A prefault value is fed through the schema, which makes it input-side, so a rewritten inner type leaves it stranded.
28864
+ prefault: (s, rewritten) => rewritten ? s._zod.def.innerType : s
28865
+ });
28866
+ }
28867
+
28868
+ // ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/classic/coerce.js
28869
+ var coerce_exports = {};
28870
+ __export(coerce_exports, {
28871
+ bigint: () => bigint3,
28872
+ boolean: () => boolean3,
28873
+ date: () => date4,
28874
+ number: () => number3,
28875
+ string: () => string3
28876
+ });
28877
+ function string3(params) {
28878
+ return _coercedString(ZodString, params);
28879
+ }
28880
+ function number3(params) {
28881
+ return _coercedNumber(ZodNumber, params);
28882
+ }
28883
+ function boolean3(params) {
28884
+ return _coercedBoolean(ZodBoolean, params);
28885
+ }
28886
+ function bigint3(params) {
28887
+ return _coercedBigint(ZodBigInt, params);
28888
+ }
28889
+ function date4(params) {
28890
+ return _coercedDate(ZodDate, params);
28891
+ }
28892
+
28893
+ // ../contracts/src/capability.ts
28894
+ var Capability = external_exports.enum(["triage", "plan", "implement", "reproduce", "verify", "review", "remember"]);
28895
+
28896
+ // ../contracts/src/ids.ts
28897
+ var GitHubLogin = external_exports.string().regex(/^(?!-)[A-Za-z0-9-]{1,39}(?<!-)(\[bot\])?$/, "not a GitHub login").brand();
28898
+ var RepoSlug = external_exports.string().regex(/^[A-Za-z0-9-]{1,39}\/[A-Za-z0-9._-]{1,100}$/, "expected owner/name").brand();
28899
+ var CommitSha = external_exports.string().regex(/^[0-9a-f]{40}$/, "expected a full commit SHA").brand();
28900
+ var BotBranch = external_exports.string().regex(/^macaron\/[0-9]+-[a-z0-9-]{1,48}$/, "expected macaron/<number>-<slug>").brand();
28901
+ var Ticket = external_exports.string().regex(/^t_[A-Za-z0-9_-]{32,64}$/, "not a ticket").brand();
28902
+ var Slug = external_exports.string().regex(/^[a-z0-9]+(-[a-z0-9]+)*$/, "expected kebab-case").max(64).brand();
28903
+ var Usd = external_exports.number().nonnegative().max(1e3);
28904
+
28905
+ // ../contracts/src/accounts.ts
28906
+ var Timestamp = external_exports.iso.datetime({ offset: true });
28907
+ var Capabilities = external_exports.array(Capability).min(1, "grant at least one capability").refine((capabilities) => new Set(capabilities).size === capabilities.length, "a capability appears twice");
28908
+ var Me = external_exports.object({
28909
+ githubId: external_exports.int().positive(),
28910
+ githubLogin: GitHubLogin,
28911
+ name: external_exports.string(),
28912
+ avatarUrl: external_exports.url().nullable(),
28913
+ role: external_exports.enum(["user", "admin"]),
28914
+ capabilities: external_exports.array(Capability)
28915
+ });
28916
+ var InvitationStatus = external_exports.enum(["pending", "accepted", "revoked", "expired"]);
28917
+ var Invitation = external_exports.object({
28918
+ id: external_exports.uuid(),
28919
+ githubId: external_exports.int().positive(),
28920
+ githubLogin: GitHubLogin,
28921
+ capabilities: external_exports.array(Capability),
28922
+ invitedBy: GitHubLogin,
28923
+ createdAt: Timestamp,
28924
+ expiresAt: Timestamp,
28925
+ status: InvitationStatus
28926
+ });
28927
+ var Invitations = external_exports.object({ invitations: external_exports.array(Invitation) });
28928
+ var CreateInvitation = external_exports.object({ githubLogin: GitHubLogin, capabilities: Capabilities });
28929
+ var UserAccount = external_exports.object({
28930
+ id: external_exports.string().min(1),
28931
+ githubId: external_exports.int().positive(),
28932
+ githubLogin: GitHubLogin,
28933
+ name: external_exports.string(),
28934
+ avatarUrl: external_exports.url().nullable(),
28935
+ role: external_exports.enum(["user", "admin"]),
28936
+ capabilities: external_exports.array(Capability),
28937
+ createdAt: Timestamp,
28938
+ lastSignInAt: Timestamp.nullable()
28939
+ });
28940
+ var UserAccounts = external_exports.object({ users: external_exports.array(UserAccount) });
28941
+ var SetCapabilities = external_exports.object({ capabilities: Capabilities });
28942
+ var FieldError = external_exports.object({ error: external_exports.string(), field: external_exports.string(), message: external_exports.string() });
28943
+ var UsageRun = external_exports.object({
28944
+ id: external_exports.uuid(),
28945
+ repo: external_exports.string(),
28946
+ number: external_exports.int().positive(),
28947
+ kind: external_exports.enum(["issue", "pull"]),
28948
+ mode: external_exports.string(),
28949
+ status: external_exports.enum(["pending", "dispatched", "running", "completed", "failed", "aborted"]),
28950
+ model: external_exports.string(),
28951
+ /** Settled cost; null until the backend reported the run's final usage. */
28952
+ costUsd: external_exports.number().nonnegative().nullable(),
28953
+ createdAt: Timestamp
28954
+ });
28955
+ var UsagePage = external_exports.object({
28956
+ runs: external_exports.array(UsageRun),
28957
+ /** Pass as `before` for the next page; null on the last one. */
28958
+ nextCursor: external_exports.string().nullable(),
28959
+ /** This calendar month (UTC), settled runs only. */
28960
+ monthUsd: external_exports.number().nonnegative(),
28961
+ monthRuns: external_exports.int().nonnegative()
28962
+ });
28963
+ var UsageQuery = external_exports.object({
28964
+ before: external_exports.string().optional(),
28965
+ limit: external_exports.coerce.number().int().min(1).max(100).default(25)
28966
+ });
28967
+
28968
+ // ../contracts/src/auth-fields.ts
28969
+ var AUTH_COOKIE_PREFIX = "macaron";
28970
+ var SESSION_COOKIE = `__Secure-${AUTH_COOKIE_PREFIX}.session_token`;
28971
+
28972
+ // ../../node_modules/.pnpm/deepmerge-ts@8.0.2/node_modules/deepmerge-ts/dist/index.mjs
28973
+ var actions = {
28974
+ defaultMerge: /* @__PURE__ */ Symbol("deepmerge-ts: default merge"),
28975
+ skip: /* @__PURE__ */ Symbol("deepmerge-ts: skip")
28976
+ };
28977
+ var actionsInto = {
28978
+ defaultMerge: actions.defaultMerge
28979
+ };
28980
+ function defaultMetaDataUpdater(previousMeta, mergeInfo) {
28981
+ const ancestor = {
28982
+ key: mergeInfo.key,
28983
+ parents: mergeInfo.parents,
28984
+ values: mergeInfo.values,
28985
+ result: mergeInfo.result
28986
+ };
28987
+ const prevHierarchy = previousMeta?.hierarchy;
28988
+ return {
28989
+ ...ancestor,
28990
+ hierarchy: prevHierarchy === void 0 ? [ancestor] : [...prevHierarchy, ancestor]
28991
+ };
28992
+ }
28993
+ function defaultFilterValues(values, meta3) {
28994
+ return values.includes(void 0) ? values.filter((value) => value !== void 0) : values;
28995
+ }
28996
+ function shouldFallbackToDefault(utils, fallback, result) {
28997
+ return result === actions.defaultMerge || utils.useImplicitDefaultMerging && result === void 0 && utils.mergeFunctions[fallback] !== utils.defaultMergeFunctions[fallback];
28998
+ }
28999
+ function resolveCustomMergeFunctions(options, defaultMergeFunctions) {
29000
+ return {
29001
+ ...defaultMergeFunctions,
29002
+ ...Object.fromEntries(Object.entries(options).filter(([key]) => Object.hasOwn(defaultMergeFunctions, key)).map(([key, option]) => option === false ? [key, defaultMergeFunctions.mergeOthers] : typeof option === "function" ? [key, option] : [key, defaultMergeFunctions[key]]))
29003
+ };
29004
+ }
29005
+ function mergeArrays$1(values, utils, meta3) {
29006
+ return values.flat();
29007
+ }
29008
+ function mergeSets$1(values, utils, meta3) {
29009
+ const result = /* @__PURE__ */ new Set();
29010
+ for (const set2 of values) {
29011
+ for (const element of set2) {
29012
+ result.add(element);
29021
29013
  }
29022
29014
  }
29023
- if (schema.nullable === true && ctx.version === "openapi-3.0") {
29024
- baseSchema = z.nullable(baseSchema);
29015
+ return result;
29016
+ }
29017
+ function mergeOthers$1(values, utils, meta3) {
29018
+ return values.at(-1);
29019
+ }
29020
+ var ObjectType;
29021
+ (function(ObjectType2) {
29022
+ ObjectType2[ObjectType2["NOT"] = 0] = "NOT";
29023
+ ObjectType2[ObjectType2["RECORD"] = 1] = "RECORD";
29024
+ ObjectType2[ObjectType2["ARRAY"] = 2] = "ARRAY";
29025
+ ObjectType2[ObjectType2["SET"] = 3] = "SET";
29026
+ ObjectType2[ObjectType2["MAP"] = 4] = "MAP";
29027
+ ObjectType2[ObjectType2["OTHER"] = 5] = "OTHER";
29028
+ })(ObjectType || (ObjectType = {}));
29029
+ function getObjectType(object2) {
29030
+ if (typeof object2 !== "object" || object2 === null) {
29031
+ return ObjectType.NOT;
29025
29032
  }
29026
- if (schema.readOnly === true) {
29027
- baseSchema = z.readonly(baseSchema);
29033
+ if (Array.isArray(object2)) {
29034
+ return ObjectType.ARRAY;
29028
29035
  }
29029
- if (schema.default !== void 0) {
29030
- baseSchema = baseSchema.default(schema.default);
29036
+ if (isRecord(object2)) {
29037
+ return ObjectType.RECORD;
29031
29038
  }
29032
- const extraMeta = {};
29033
- const coreMetadataKeys = ["$id", "id", "$comment", "$anchor", "$vocabulary", "$dynamicRef", "$dynamicAnchor"];
29034
- for (const key of coreMetadataKeys) {
29035
- if (key in schema) {
29036
- extraMeta[key] = schema[key];
29037
- }
29039
+ if (object2 instanceof Set) {
29040
+ return ObjectType.SET;
29038
29041
  }
29039
- const contentMetadataKeys = ["contentEncoding", "contentMediaType", "contentSchema"];
29040
- for (const key of contentMetadataKeys) {
29041
- if (key in schema) {
29042
- extraMeta[key] = schema[key];
29043
- }
29042
+ if (object2 instanceof Map) {
29043
+ return ObjectType.MAP;
29044
29044
  }
29045
- if (schema.type === "object" && schema.$ref === void 0) {
29046
- if (schema.propertyNames !== void 0 && !containsRef(schema.propertyNames)) {
29047
- extraMeta.propertyNames = schema.propertyNames;
29045
+ return ObjectType.OTHER;
29046
+ }
29047
+ function getKeysOfObjects(objects) {
29048
+ const keys = /* @__PURE__ */ new Set();
29049
+ for (const currentObject of objects) {
29050
+ const stringKeys = Object.keys(currentObject);
29051
+ for (const stringKey of stringKeys) {
29052
+ keys.add(stringKey);
29048
29053
  }
29049
- for (const key of ["minProperties", "maxProperties"]) {
29050
- if (schema[key] !== void 0)
29051
- extraMeta[key] = schema[key];
29054
+ const symbols = Object.getOwnPropertySymbols(currentObject);
29055
+ if (symbols.length > 0) {
29056
+ for (const symbol2 of symbols) {
29057
+ if (Object.prototype.propertyIsEnumerable.call(currentObject, symbol2)) {
29058
+ keys.add(symbol2);
29059
+ }
29060
+ }
29052
29061
  }
29053
29062
  }
29054
- if (schema.type === "array" && schema.$ref === void 0) {
29055
- if (schema.contains !== void 0 && !containsRef(schema.contains)) {
29056
- extraMeta.contains = schema.contains;
29057
- }
29058
- for (const key of ["uniqueItems", "minContains", "maxContains"]) {
29059
- if (schema[key] !== void 0)
29060
- extraMeta[key] = schema[key];
29061
- }
29063
+ return keys;
29064
+ }
29065
+ function getKeysOfObject(object2) {
29066
+ const symbols = Object.getOwnPropertySymbols(object2).filter((symbol2) => Object.prototype.propertyIsEnumerable.call(object2, symbol2));
29067
+ return [...Object.keys(object2), ...symbols];
29068
+ }
29069
+ function objectHasProperty(object2, property) {
29070
+ return typeof object2 === "object" && Object.prototype.propertyIsEnumerable.call(object2, property);
29071
+ }
29072
+ function isRecord(value) {
29073
+ const prototype = Object.getPrototypeOf(value);
29074
+ if (prototype === null || prototype === Object.prototype) {
29075
+ return true;
29062
29076
  }
29063
- for (const key of Object.keys(schema)) {
29064
- if (!RECOGNIZED_KEYS.has(key)) {
29065
- assignProp(extraMeta, key, schema[key]);
29066
- }
29077
+ const objectToString = Object.prototype.toString.call(value);
29078
+ if (objectToString !== "[object Object]" && objectToString !== "[object Module]") {
29079
+ return false;
29067
29080
  }
29068
- if (Object.keys(extraMeta).length > 0) {
29069
- ctx.registry.add(baseSchema, extraMeta);
29081
+ const { constructor } = value;
29082
+ if (constructor === void 0) {
29083
+ return true;
29084
+ }
29085
+ const constructorPrototype = constructor.prototype;
29086
+ if (constructorPrototype === null || typeof constructorPrototype !== "object") {
29087
+ return false;
29088
+ }
29089
+ const constructorToString = Object.prototype.toString.call(constructorPrototype);
29090
+ if (constructorToString !== "[object Object]" && constructorToString !== "[object Module]") {
29091
+ return false;
29070
29092
  }
29071
- if (schema.description) {
29072
- baseSchema = baseSchema.describe(schema.description);
29093
+ if (!Object.hasOwn(constructorPrototype, "isPrototypeOf")) {
29094
+ return false;
29073
29095
  }
29074
- return baseSchema;
29096
+ return true;
29075
29097
  }
29076
- function fromJSONSchema(schema, params) {
29077
- if (typeof schema === "boolean") {
29078
- return schema ? z.any() : z.never();
29098
+ function getCyclicReferenceDepth(object2, hierarchy, index) {
29099
+ if (hierarchy === void 0 || hierarchy.length === 0) {
29100
+ return 0;
29079
29101
  }
29080
- let normalized;
29081
- try {
29082
- normalized = JSON.parse(JSON.stringify(schema));
29083
- } catch {
29084
- throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas");
29102
+ let mut_depth = 1;
29103
+ for (let mut_index = hierarchy.length - 1; mut_index >= 0; mut_index--) {
29104
+ const { parents } = hierarchy[mut_index];
29105
+ if (parents[index] === object2 || parents.includes(object2)) {
29106
+ return mut_depth;
29107
+ }
29108
+ mut_depth += 1;
29085
29109
  }
29086
- const version2 = detectVersion(normalized, params?.defaultTarget);
29087
- const defs = normalized.$defs || normalized.definitions || {};
29088
- const ctx = {
29089
- version: version2,
29090
- defs,
29091
- refs: /* @__PURE__ */ new Map(),
29092
- processing: /* @__PURE__ */ new Set(),
29093
- rootSchema: normalized,
29094
- registry: params?.registry ?? globalRegistry
29095
- };
29096
- return convertSchema(normalized, ctx);
29110
+ return 0;
29097
29111
  }
29098
-
29099
- // ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/visit.js
29100
- var RESOLVING = /* @__PURE__ */ Symbol("z.visit/resolving");
29101
- function visit(schema, fnOrHandlers) {
29102
- const fn = typeof fnOrHandlers === "function" ? fnOrHandlers : (node2, rewritten) => {
29103
- const h = fnOrHandlers[node2._zod.def.type];
29104
- return h ? h(node2, rewritten) : node2;
29105
- };
29106
- const cache = /* @__PURE__ */ new Map();
29107
- function run2(s) {
29108
- const cached2 = cache.get(s);
29109
- if (cached2 === RESOLVING) {
29110
- return new $ZodLazy({
29111
- type: "lazy",
29112
- getter: () => cache.get(s)
29112
+ function getMetaDataHierarchy(meta3) {
29113
+ return meta3?.hierarchy;
29114
+ }
29115
+ function mergeRecords$1(values, utils, meta3) {
29116
+ if (values.length === 2) {
29117
+ const result = {};
29118
+ const mergeProperty = (key, propValues) => {
29119
+ const updatedMeta = utils.metaDataUpdater(meta3, {
29120
+ key,
29121
+ parents: values,
29122
+ values: propValues,
29123
+ result
29113
29124
  });
29114
- }
29115
- if (cached2 !== void 0)
29116
- return cached2;
29117
- cache.set(s, RESOLVING);
29118
- const inner = mapInner(s);
29119
- const mapped = fn(inner, inner !== s);
29120
- cache.set(s, mapped);
29121
- return mapped;
29122
- }
29123
- function mapInner(s) {
29124
- const def = s._zod.def;
29125
- const kind = def.type;
29126
- switch (kind) {
29127
- case "object": {
29128
- const oldShape = def.shape;
29129
- const keys = Object.keys(oldShape);
29130
- let changed = false;
29131
- const newShape = {};
29132
- for (const k of keys) {
29133
- const mapped = run2(oldShape[k]);
29134
- if (mapped !== oldShape[k])
29135
- changed = true;
29136
- newShape[k] = mapped;
29137
- }
29138
- let newCatchall = def.catchall;
29139
- if (def.catchall) {
29140
- newCatchall = run2(def.catchall);
29141
- if (newCatchall !== def.catchall)
29142
- changed = true;
29143
- }
29144
- return changed ? clone(s, { ...def, shape: newShape, catchall: newCatchall }) : s;
29145
- }
29146
- case "array": {
29147
- const mapped = run2(def.element);
29148
- return mapped === def.element ? s : clone(s, { ...def, element: mapped });
29149
- }
29150
- case "tuple": {
29151
- const oldItems = def.items;
29152
- let changed = false;
29153
- const newItems = [];
29154
- for (const item of oldItems) {
29155
- const mapped = run2(item);
29156
- if (mapped !== item)
29157
- changed = true;
29158
- newItems.push(mapped);
29159
- }
29160
- let newRest = def.rest;
29161
- if (def.rest) {
29162
- newRest = run2(def.rest);
29163
- if (newRest !== def.rest)
29164
- changed = true;
29165
- }
29166
- return changed ? clone(s, { ...def, items: newItems, rest: newRest }) : s;
29167
- }
29168
- case "record":
29169
- case "map": {
29170
- const newKey = run2(def.keyType);
29171
- const newVal = run2(def.valueType);
29172
- return newKey === def.keyType && newVal === def.valueType ? s : clone(s, { ...def, keyType: newKey, valueType: newVal });
29173
- }
29174
- case "set": {
29175
- const newVal = run2(def.valueType);
29176
- return newVal === def.valueType ? s : clone(s, { ...def, valueType: newVal });
29177
- }
29178
- case "union": {
29179
- const oldOptions = def.options;
29180
- let changed = false;
29181
- const newOptions = [];
29182
- for (const opt of oldOptions) {
29183
- const mapped = run2(opt);
29184
- if (mapped !== opt)
29185
- changed = true;
29186
- newOptions.push(mapped);
29187
- }
29188
- return changed ? clone(s, { ...def, options: newOptions }) : s;
29189
- }
29190
- case "intersection": {
29191
- const newLeft = run2(def.left);
29192
- const newRight = run2(def.right);
29193
- return newLeft === def.left && newRight === def.right ? s : clone(s, { ...def, left: newLeft, right: newRight });
29194
- }
29195
- case "optional":
29196
- case "nullable":
29197
- case "default":
29198
- case "prefault":
29199
- case "catch":
29200
- case "readonly":
29201
- case "nonoptional":
29202
- case "promise":
29203
- case "success": {
29204
- const newInner = run2(def.innerType);
29205
- return newInner === def.innerType ? s : clone(s, { ...def, innerType: newInner });
29125
+ const propertyResult = mergeUnknowns(propValues, utils, updatedMeta);
29126
+ if (propertyResult === actions.skip) {
29127
+ return;
29206
29128
  }
29207
- case "pipe": {
29208
- const newIn = run2(def.in);
29209
- const newOut = run2(def.out);
29210
- return newIn === def.in && newOut === def.out ? s : clone(s, { ...def, in: newIn, out: newOut });
29129
+ if (key === "__proto__") {
29130
+ Object.defineProperty(result, key, {
29131
+ value: propertyResult,
29132
+ configurable: true,
29133
+ enumerable: true,
29134
+ writable: true
29135
+ });
29136
+ } else {
29137
+ result[key] = propertyResult;
29211
29138
  }
29212
- case "function": {
29213
- const newInput = run2(def.input);
29214
- const newOutput = run2(def.output);
29215
- return newInput === def.input && newOutput === def.output ? s : clone(s, { ...def, input: newInput, output: newOutput });
29139
+ };
29140
+ const firstValue = values[0];
29141
+ const secondValue = values[1];
29142
+ for (const key of getKeysOfObject(firstValue)) {
29143
+ mergeProperty(key, objectHasProperty(secondValue, key) ? [firstValue[key], secondValue[key]] : [firstValue[key]]);
29144
+ }
29145
+ for (const key of getKeysOfObject(secondValue)) {
29146
+ if (!objectHasProperty(firstValue, key)) {
29147
+ mergeProperty(key, [secondValue[key]]);
29216
29148
  }
29217
- case "lazy": {
29218
- const original = def.getter;
29219
- const { _cachedInner, ...rest } = def;
29220
- return clone(s, { ...rest, getter: () => run2(original()) });
29149
+ }
29150
+ return result;
29151
+ }
29152
+ return mergeRecordsGeneral(values, utils, meta3);
29153
+ }
29154
+ function mergeRecordsGeneral(values, utils, meta3) {
29155
+ const result = {};
29156
+ for (const key of getKeysOfObjects(values)) {
29157
+ const propValues = [];
29158
+ for (const value of values) {
29159
+ if (objectHasProperty(value, key)) {
29160
+ propValues.push(value[key]);
29221
29161
  }
29222
- // A leaf by choice: `parts` are regex fragments, not data positions.
29223
- case "template_literal":
29224
- // Leaves.
29225
- case "string":
29226
- case "number":
29227
- case "int":
29228
- case "boolean":
29229
- case "bigint":
29230
- case "symbol":
29231
- case "undefined":
29232
- case "null":
29233
- case "void":
29234
- case "never":
29235
- case "any":
29236
- case "unknown":
29237
- case "date":
29238
- case "nan":
29239
- case "enum":
29240
- case "literal":
29241
- case "file":
29242
- case "transform":
29243
- case "custom":
29244
- return s;
29245
- default: {
29246
- kind;
29247
- return s;
29162
+ }
29163
+ const updatedMeta = utils.metaDataUpdater(meta3, {
29164
+ key,
29165
+ parents: values,
29166
+ values: propValues,
29167
+ result
29168
+ });
29169
+ const propertyResult = mergeUnknowns(propValues, utils, updatedMeta);
29170
+ if (propertyResult === actions.skip) {
29171
+ continue;
29172
+ }
29173
+ if (key === "__proto__") {
29174
+ Object.defineProperty(result, key, {
29175
+ value: propertyResult,
29176
+ configurable: true,
29177
+ enumerable: true,
29178
+ writable: true
29179
+ });
29180
+ } else {
29181
+ result[key] = propertyResult;
29182
+ }
29183
+ }
29184
+ return result;
29185
+ }
29186
+ function mergeMaps$1(values, utils, meta3) {
29187
+ const result = /* @__PURE__ */ new Map();
29188
+ const valuesByKey = /* @__PURE__ */ new Map();
29189
+ for (const map2 of values) {
29190
+ for (const [key, value] of map2) {
29191
+ const mut_keyValues = valuesByKey.get(key);
29192
+ if (mut_keyValues === void 0) {
29193
+ valuesByKey.set(key, [value]);
29194
+ } else {
29195
+ mut_keyValues.push(value);
29248
29196
  }
29249
29197
  }
29250
29198
  }
29251
- return run2(schema);
29199
+ for (const [key, keyValues] of valuesByKey) {
29200
+ const updatedMeta = utils.metaDataUpdater(meta3, {
29201
+ key,
29202
+ parents: values,
29203
+ values: keyValues,
29204
+ result
29205
+ });
29206
+ const keyResult = mergeUnknowns(keyValues, utils, updatedMeta);
29207
+ if (keyResult === actions.skip) {
29208
+ continue;
29209
+ }
29210
+ result.set(key, keyResult);
29211
+ }
29212
+ return result;
29252
29213
  }
29253
-
29254
- // ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/classic/deep-partial.js
29255
- function deepPartial(schema) {
29256
- return visit(schema, {
29257
- object: (s) => s.partial(),
29258
- // Every partialed option now admits `undefined`, which the constructor rejects as a duplicate.
29259
- union: (s) => {
29260
- const def = s._zod.def;
29261
- return def.discriminator === void 0 ? s : union(def.options);
29214
+ function resolveCyclicReferences(value, utils, meta3) {
29215
+ if (typeof value !== "object" || value === null) {
29216
+ return value;
29217
+ }
29218
+ const hierarchy = getMetaDataHierarchy(meta3);
29219
+ const depth = getCyclicReferenceDepth(value, hierarchy, 0);
29220
+ if (hierarchy !== void 0 && depth > 0) {
29221
+ return hierarchy[hierarchy.length - depth]?.result;
29222
+ }
29223
+ const type = getObjectType(value);
29224
+ if (type === ObjectType.RECORD) {
29225
+ const record2 = value;
29226
+ let mut_changed = false;
29227
+ const result = {};
29228
+ for (const key of getKeysOfObject(record2)) {
29229
+ const propVal = record2[key];
29230
+ const updatedMeta = utils.metaDataUpdater(meta3, {
29231
+ key,
29232
+ parents: [record2],
29233
+ values: [propVal],
29234
+ result
29235
+ });
29236
+ const resolvedProp = resolveCyclicReferences(propVal, utils, updatedMeta);
29237
+ if (resolvedProp !== propVal) {
29238
+ mut_changed = true;
29239
+ }
29240
+ if (key === "__proto__") {
29241
+ Object.defineProperty(result, key, {
29242
+ value: resolvedProp,
29243
+ configurable: true,
29244
+ enumerable: true,
29245
+ writable: true
29246
+ });
29247
+ } else {
29248
+ result[key] = resolvedProp;
29249
+ }
29262
29250
  }
29263
- });
29251
+ return mut_changed ? result : value;
29252
+ }
29253
+ return value;
29264
29254
  }
29265
-
29266
- // ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/classic/in-out.js
29267
- function withChecks(side, checks) {
29268
- if (!checks?.length)
29269
- return side;
29270
- const def = side._zod.def;
29271
- return clone(side, mergeDefs(def, { checks: [...def.checks ?? [], ...checks] }), { parent: true });
29255
+ function mergeCircularReferences$1(values, cyclicDepths, utils, meta3) {
29256
+ const depth = cyclicDepths[0];
29257
+ const hierarchy = getMetaDataHierarchy(meta3);
29258
+ for (let mut_index = 1; mut_index < values.length; mut_index++) {
29259
+ if (cyclicDepths[mut_index] !== depth) {
29260
+ const lastCyclicDepth = cyclicDepths.at(-1);
29261
+ return lastCyclicDepth === 0 ? resolveCyclicReferences(values.at(-1), utils, meta3) : hierarchy?.[hierarchy.length - lastCyclicDepth]?.result;
29262
+ }
29263
+ }
29264
+ return hierarchy?.[hierarchy.length - depth]?.result;
29272
29265
  }
29273
- function outSide(def) {
29274
- return withChecks(def.out, def.checks);
29266
+ var mergeFunctions = {
29267
+ mergeRecords: mergeRecords$1,
29268
+ mergeArrays: mergeArrays$1,
29269
+ mergeSets: mergeSets$1,
29270
+ mergeMaps: mergeMaps$1,
29271
+ mergeCircularReferences: mergeCircularReferences$1,
29272
+ mergeOthers: mergeOthers$1
29273
+ };
29274
+ function deepmergeCustom(options = {}, rootMetaData) {
29275
+ const utils = getUtils$1(options, customizedDeepmerge);
29276
+ function customizedDeepmerge(...objects) {
29277
+ return mergeUnknowns(objects, utils, rootMetaData ?? void 0);
29278
+ }
29279
+ return customizedDeepmerge;
29275
29280
  }
29276
- function inSide(def) {
29277
- return def.in._zod.traits.has("$ZodTransform") ? outSide(def) : def.in;
29281
+ function getUtils$1(options, customizedDeepmerge) {
29282
+ const defaultMergeFns = mergeFunctions;
29283
+ const defaultMetaDataUpd = defaultMetaDataUpdater;
29284
+ return {
29285
+ defaultMergeFunctions: defaultMergeFns,
29286
+ mergeFunctions: resolveCustomMergeFunctions(options, defaultMergeFns),
29287
+ metaDataUpdater: typeof options.metaDataUpdater === "function" ? options.metaDataUpdater : defaultMetaDataUpd,
29288
+ deepmerge: customizedDeepmerge,
29289
+ useImplicitDefaultMerging: options.enableImplicitDefaultMerging ?? false,
29290
+ filterValues: options.filterValues === false ? void 0 : typeof options.filterValues === "function" ? options.filterValues : defaultFilterValues,
29291
+ maxDepth: typeof options.maxDepth === "number" && !Number.isNaN(options.maxDepth) && options.maxDepth >= 0 ? options.maxDepth : 1e3,
29292
+ actions
29293
+ };
29278
29294
  }
29279
- function input(schema) {
29280
- return visit(schema, {
29281
- pipe: (s) => inSide(s._zod.def),
29282
- // A default value belongs to the output side, so a rewritten inner type leaves it stranded. `.default()` widens the declared input type with `undefined`, and `optional` is what carries that across.
29283
- default: (s, rewritten) => rewritten ? optional(s._zod.def.innerType) : s,
29284
- // A catch value is output-side too, but `.catch()` leaves the declared input type alone, so the inner schema stands on its own.
29285
- catch: (s, rewritten) => rewritten ? s._zod.def.innerType : s
29286
- });
29295
+ function mergeUnknowns(values, utils, meta3) {
29296
+ const filteredValues = utils.filterValues?.(values, meta3) ?? values;
29297
+ if (filteredValues.length === 0) {
29298
+ return void 0;
29299
+ }
29300
+ const hierarchy = getMetaDataHierarchy(meta3);
29301
+ const currentDepth = hierarchy?.length ?? (typeof meta3 === "number" ? meta3 : meta3?.depth ?? 0);
29302
+ if (utils.maxDepth !== void 0 && currentDepth >= utils.maxDepth) {
29303
+ return mergeOthers(filteredValues, utils, meta3);
29304
+ }
29305
+ if (filteredValues.length === 1) {
29306
+ if (hierarchy !== void 0) {
29307
+ const depth = getCyclicReferenceDepth(filteredValues[0], hierarchy, 0);
29308
+ if (depth > 0) {
29309
+ return hierarchy[hierarchy.length - depth]?.result ?? hierarchy[hierarchy.length - depth]?.parents[0];
29310
+ }
29311
+ }
29312
+ return mergeOthers(filteredValues, utils, meta3);
29313
+ }
29314
+ const type = getObjectType(filteredValues[0]);
29315
+ if (type !== ObjectType.NOT && type !== ObjectType.OTHER) {
29316
+ if (filteredValues.length === 2) {
29317
+ if (getObjectType(filteredValues[1]) !== type) {
29318
+ return mergeOthers(filteredValues, utils, meta3);
29319
+ }
29320
+ const d0 = getCyclicReferenceDepth(filteredValues[0], hierarchy, 0);
29321
+ const d1 = getCyclicReferenceDepth(filteredValues[1], hierarchy, 1);
29322
+ if (d0 !== 0 || d1 !== 0) {
29323
+ return mergeCircularReferences(filteredValues, [d0, d1], utils, meta3);
29324
+ }
29325
+ } else {
29326
+ const cyclicDepths = new Array(filteredValues.length);
29327
+ cyclicDepths[0] = getCyclicReferenceDepth(filteredValues[0], hierarchy, 0);
29328
+ for (let mut_index = 1; mut_index < filteredValues.length; mut_index++) {
29329
+ if (getObjectType(filteredValues[mut_index]) !== type) {
29330
+ return mergeOthers(filteredValues, utils, meta3);
29331
+ }
29332
+ cyclicDepths[mut_index] = getCyclicReferenceDepth(filteredValues[mut_index], hierarchy, mut_index);
29333
+ }
29334
+ if (cyclicDepths.some((depth) => depth !== 0)) {
29335
+ return mergeCircularReferences(filteredValues, cyclicDepths, utils, meta3);
29336
+ }
29337
+ }
29338
+ }
29339
+ switch (type) {
29340
+ case ObjectType.RECORD: {
29341
+ return mergeRecords(filteredValues, utils, meta3);
29342
+ }
29343
+ case ObjectType.ARRAY: {
29344
+ return mergeArrays(filteredValues, utils, meta3);
29345
+ }
29346
+ case ObjectType.SET: {
29347
+ return mergeSets(filteredValues, utils, meta3);
29348
+ }
29349
+ case ObjectType.MAP: {
29350
+ return mergeMaps(filteredValues, utils, meta3);
29351
+ }
29352
+ default: {
29353
+ return mergeOthers(filteredValues, utils, meta3);
29354
+ }
29355
+ }
29287
29356
  }
29288
- function output(schema) {
29289
- return visit(schema, {
29290
- pipe: (s) => outSide(s._zod.def),
29291
- // A prefault value is fed through the schema, which makes it input-side, so a rewritten inner type leaves it stranded.
29292
- prefault: (s, rewritten) => rewritten ? s._zod.def.innerType : s
29293
- });
29357
+ function mergeRecords(values, utils, meta3) {
29358
+ const result = utils.mergeFunctions.mergeRecords(values, utils, meta3);
29359
+ if (shouldFallbackToDefault(utils, "mergeRecords", result)) {
29360
+ return utils.defaultMergeFunctions.mergeRecords(values, utils, meta3);
29361
+ }
29362
+ return result;
29294
29363
  }
29295
-
29296
- // ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/classic/coerce.js
29297
- var coerce_exports = {};
29298
- __export(coerce_exports, {
29299
- bigint: () => bigint3,
29300
- boolean: () => boolean3,
29301
- date: () => date4,
29302
- number: () => number3,
29303
- string: () => string3
29304
- });
29305
- function string3(params) {
29306
- return _coercedString(ZodString, params);
29364
+ function mergeArrays(values, utils, meta3) {
29365
+ const result = utils.mergeFunctions.mergeArrays(values, utils, meta3);
29366
+ if (shouldFallbackToDefault(utils, "mergeArrays", result)) {
29367
+ return utils.defaultMergeFunctions.mergeArrays(values);
29368
+ }
29369
+ return result;
29307
29370
  }
29308
- function number3(params) {
29309
- return _coercedNumber(ZodNumber, params);
29371
+ function mergeSets(values, utils, meta3) {
29372
+ const result = utils.mergeFunctions.mergeSets(values, utils, meta3);
29373
+ if (shouldFallbackToDefault(utils, "mergeSets", result)) {
29374
+ return utils.defaultMergeFunctions.mergeSets(values);
29375
+ }
29376
+ return result;
29310
29377
  }
29311
- function boolean3(params) {
29312
- return _coercedBoolean(ZodBoolean, params);
29378
+ function mergeMaps(values, utils, meta3) {
29379
+ const result = utils.mergeFunctions.mergeMaps(values, utils, meta3);
29380
+ if (shouldFallbackToDefault(utils, "mergeMaps", result)) {
29381
+ return utils.defaultMergeFunctions.mergeMaps(values, utils, meta3);
29382
+ }
29383
+ return result;
29313
29384
  }
29314
- function bigint3(params) {
29315
- return _coercedBigint(ZodBigInt, params);
29385
+ function mergeCircularReferences(values, cyclicDepths, utils, meta3) {
29386
+ const result = utils.mergeFunctions.mergeCircularReferences(values, cyclicDepths, utils, meta3);
29387
+ if (shouldFallbackToDefault(utils, "mergeCircularReferences", result)) {
29388
+ return utils.defaultMergeFunctions.mergeCircularReferences(values, cyclicDepths, utils, meta3);
29389
+ }
29390
+ return result;
29316
29391
  }
29317
- function date4(params) {
29318
- return _coercedDate(ZodDate, params);
29392
+ function mergeOthers(values, utils, meta3) {
29393
+ const result = utils.mergeFunctions.mergeOthers(values, utils, meta3);
29394
+ if (shouldFallbackToDefault(utils, "mergeOthers", result)) {
29395
+ return utils.defaultMergeFunctions.mergeOthers(values);
29396
+ }
29397
+ return result;
29319
29398
  }
29320
29399
 
29321
- // ../contracts/src/ids.ts
29322
- var GitHubLogin = external_exports.string().regex(/^(?!-)[A-Za-z0-9-]{1,39}(?<!-)(\[bot\])?$/, "not a GitHub login").brand();
29323
- var RepoSlug = external_exports.string().regex(/^[A-Za-z0-9-]{1,39}\/[A-Za-z0-9._-]{1,100}$/, "expected owner/name").brand();
29324
- var CommitSha = external_exports.string().regex(/^[0-9a-f]{40}$/, "expected a full commit SHA").brand();
29325
- var BotBranch = external_exports.string().regex(/^macaron\/[0-9]+-[a-z0-9-]{1,48}$/, "expected macaron/<number>-<slug>").brand();
29326
- var Ticket = external_exports.string().regex(/^t_[A-Za-z0-9_-]{32,64}$/, "not a ticket").brand();
29327
- var Slug = external_exports.string().regex(/^[a-z0-9]+(-[a-z0-9]+)*$/, "expected kebab-case").max(64).brand();
29328
- var Usd = external_exports.number().nonnegative().max(1e3);
29329
-
29330
29400
  // ../contracts/src/mode.ts
29331
29401
  var Mode = external_exports.enum(["triage", "plan", "implement", "address_review", "reproduce", "verify", "retro", "review"]);
29332
29402
  var Harness = external_exports.enum(["claude", "codex", "opencode"]);