limina 0.0.5 → 0.1.1

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.
@@ -0,0 +1,4125 @@
1
+ import { createRequire } from "node:module";
2
+ import { existsSync, statSync } from "node:fs";
3
+ import ts from "typescript";
4
+ import { pathToFileURL } from "node:url";
5
+
6
+ //#region src/utils/collections.ts
7
+ function uniqueValues(values) {
8
+ return [...new Set(values)];
9
+ }
10
+ function uniqueBy(values, getKey) {
11
+ const seen = /* @__PURE__ */ new Set();
12
+ const result = [];
13
+ for (const value of values) {
14
+ const key = getKey(value);
15
+ if (seen.has(key)) continue;
16
+ seen.add(key);
17
+ result.push(value);
18
+ }
19
+ return result;
20
+ }
21
+ function uniqueSortedStrings(values) {
22
+ return uniqueValues(values).sort((left, right) => left.localeCompare(right));
23
+ }
24
+ function uniqueTrimmedNonEmptySortedStrings(values) {
25
+ return uniqueSortedStrings([...values].map((value) => value?.trim()).filter((value) => Boolean(value)));
26
+ }
27
+
28
+ //#endregion
29
+ //#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
30
+ let _lazyMatch = () => {
31
+ var __lib__ = (() => {
32
+ var m = Object.defineProperty, V = Object.getOwnPropertyDescriptor, G = Object.getOwnPropertyNames, T = Object.prototype.hasOwnProperty, q = (r, e) => {
33
+ for (var n in e) m(r, n, {
34
+ get: e[n],
35
+ enumerable: true
36
+ });
37
+ }, H = (r, e, n, a) => {
38
+ if (e && typeof e == "object" || typeof e == "function") for (let t of G(e)) !T.call(r, t) && t !== n && m(r, t, {
39
+ get: () => e[t],
40
+ enumerable: !(a = V(e, t)) || a.enumerable
41
+ });
42
+ return r;
43
+ }, J = (r) => H(m({}, "__esModule", { value: true }), r), w = {};
44
+ q(w, { default: () => re });
45
+ var A = (r) => Array.isArray(r), d = (r) => typeof r == "function", Q = (r) => r.length === 0, W = (r) => typeof r == "number", K = (r) => typeof r == "object" && r !== null, X = (r) => r instanceof RegExp, b = (r) => typeof r == "string", h = (r) => r === void 0, Y = (r) => {
46
+ const e = /* @__PURE__ */ new Map();
47
+ return (n) => {
48
+ const a = e.get(n);
49
+ if (a) return a;
50
+ const t = r(n);
51
+ return e.set(n, t), t;
52
+ };
53
+ }, rr = (r, e, n = {}) => {
54
+ const a = {
55
+ cache: {},
56
+ input: r,
57
+ index: 0,
58
+ indexMax: 0,
59
+ options: n,
60
+ output: []
61
+ };
62
+ if (v(e)(a) && a.index === r.length) return a.output;
63
+ throw new Error(`Failed to parse at index ${a.indexMax}`);
64
+ }, i = (r, e) => A(r) ? er(r, e) : b(r) ? ar(r, e) : nr(r, e), er = (r, e) => {
65
+ const n = {};
66
+ for (const a of r) {
67
+ if (a.length !== 1) throw new Error(`Invalid character: "${a}"`);
68
+ const t = a.charCodeAt(0);
69
+ n[t] = true;
70
+ }
71
+ return (a) => {
72
+ const t = a.index, o = a.input;
73
+ for (; a.index < o.length && o.charCodeAt(a.index) in n;) a.index += 1;
74
+ const u = a.index;
75
+ if (u > t) {
76
+ if (!h(e) && !a.options.silent) {
77
+ const s = a.input.slice(t, u), c = d(e) ? e(s, o, String(t)) : e;
78
+ h(c) || a.output.push(c);
79
+ }
80
+ a.indexMax = Math.max(a.indexMax, a.index);
81
+ }
82
+ return true;
83
+ };
84
+ }, nr = (r, e) => {
85
+ const n = r.source, a = r.flags.replace(/y|$/, "y"), t = new RegExp(n, a);
86
+ return g((o) => {
87
+ t.lastIndex = o.index;
88
+ const u = t.exec(o.input);
89
+ if (u) {
90
+ if (!h(e) && !o.options.silent) {
91
+ const s = d(e) ? e(...u, o.input, String(o.index)) : e;
92
+ h(s) || o.output.push(s);
93
+ }
94
+ return o.index += u[0].length, o.indexMax = Math.max(o.indexMax, o.index), true;
95
+ } else return false;
96
+ });
97
+ }, ar = (r, e) => (n) => {
98
+ if (n.input.startsWith(r, n.index)) {
99
+ if (!h(e) && !n.options.silent) {
100
+ const t = d(e) ? e(r, n.input, String(n.index)) : e;
101
+ h(t) || n.output.push(t);
102
+ }
103
+ return n.index += r.length, n.indexMax = Math.max(n.indexMax, n.index), true;
104
+ } else return false;
105
+ }, C = (r, e, n, a) => {
106
+ const t = v(r);
107
+ return g(_(M((o) => {
108
+ let u = 0;
109
+ for (; u < n;) {
110
+ const s = o.index;
111
+ if (!t(o) || (u += 1, o.index === s)) break;
112
+ }
113
+ return u >= e;
114
+ })));
115
+ }, tr = (r, e) => C(r, 0, 1), f = (r, e) => C(r, 0, Infinity), x = (r, e) => {
116
+ const n = r.map(v);
117
+ return g(_(M((a) => {
118
+ for (let t = 0, o = n.length; t < o; t++) if (!n[t](a)) return false;
119
+ return true;
120
+ })));
121
+ }, l = (r, e) => {
122
+ const n = r.map(v);
123
+ return g(_((a) => {
124
+ for (let t = 0, o = n.length; t < o; t++) if (n[t](a)) return true;
125
+ return false;
126
+ }));
127
+ }, M = (r, e = false) => {
128
+ const n = v(r);
129
+ return (a) => {
130
+ const t = a.index, o = a.output.length, u = n(a);
131
+ return (!u || e) && (a.index = t, a.output.length !== o && (a.output.length = o)), u;
132
+ };
133
+ }, _ = (r, e) => {
134
+ return v(r);
135
+ }, g = (() => {
136
+ let r = 0;
137
+ return (e) => {
138
+ const n = v(e), a = r += 1;
139
+ return (t) => {
140
+ var o;
141
+ if (t.options.memoization === false) return n(t);
142
+ const u = t.index, s = (o = t.cache)[a] || (o[a] = /* @__PURE__ */ new Map()), c = s.get(u);
143
+ if (c === false) return false;
144
+ if (W(c)) return t.index = c, true;
145
+ if (c) return t.index = c.index, c.output?.length && t.output.push(...c.output), true;
146
+ {
147
+ const Z = t.output.length;
148
+ if (n(t)) {
149
+ const D = t.index, U = t.output.length;
150
+ if (U > Z) {
151
+ const ee = t.output.slice(Z, U);
152
+ s.set(u, {
153
+ index: D,
154
+ output: ee
155
+ });
156
+ } else s.set(u, D);
157
+ return true;
158
+ } else return s.set(u, false), false;
159
+ }
160
+ };
161
+ };
162
+ })(), E = (r) => {
163
+ let e;
164
+ return (n) => (e || (e = v(r())), e(n));
165
+ }, v = Y((r) => {
166
+ if (d(r)) return Q(r) ? E(r) : r;
167
+ if (b(r) || X(r)) return i(r);
168
+ if (A(r)) return x(r);
169
+ if (K(r)) return l(Object.values(r));
170
+ throw new Error("Invalid rule");
171
+ }), P = "abcdefghijklmnopqrstuvwxyz", ir = (r) => {
172
+ let e = "";
173
+ for (; r > 0;) e = P[(r - 1) % 26] + e, r = Math.floor((r - 1) / 26);
174
+ return e;
175
+ }, O = (r) => {
176
+ let e = 0;
177
+ for (let n = 0, a = r.length; n < a; n++) e = e * 26 + P.indexOf(r[n]) + 1;
178
+ return e;
179
+ }, S = (r, e) => {
180
+ if (e < r) return S(e, r);
181
+ const n = [];
182
+ for (; r <= e;) n.push(r++);
183
+ return n;
184
+ }, or = (r, e, n) => S(r, e).map((a) => String(a).padStart(n, "0")), R = (r, e) => S(O(r), O(e)).map(ir), p = (r) => r, z = (r) => ur((e) => rr(e, r, { memoization: false }).join("")), ur = (r) => {
185
+ const e = {};
186
+ return (n) => e[n] ?? (e[n] = r(n));
187
+ }, sr = i(/^\*\*\/\*$/, ".*"), cr = i(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/, (r, e, n) => `.*${e ? "" : "(?:^|/)"}${n.replaceAll(".", "\\.")}`), lr = i(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/, (r, e, n, a) => `.*${e ? "" : "(?:^|/)"}${n.replaceAll(".", "\\.")}(?:${a.replaceAll(",", "|").replaceAll(".", "\\.")})`), y = i(/\\./, p), pr = i(/[$.*+?^(){}[\]\|]/, (r) => `\\${r}`), vr = i(/./, p), fr = l([i(/^(?:!!)*!(.*)$/, (r, e) => `(?!^${L(e)}$).*?`), i(/^(!!)+/, "")]), j = l([
188
+ i(/\/(\*\*\/)+/, "(?:/.+/|/)"),
189
+ i(/^(\*\*\/)+/, "(?:^|.*/)"),
190
+ i(/\/(\*\*)$/, "(?:/.*|$)"),
191
+ i(/\*\*/, ".*")
192
+ ]), N = l([i(/\*\/(?!\*\*\/)/, "[^/]*/"), i(/\*/, "[^/]*")]), k = i("?", "[^/]"), $r = i("[", p), wr = i("]", p), Ar = i(/[!^]/, "^/"), br = i(/[a-z]-[a-z]|[0-9]-[0-9]/i, p), Er = l([
193
+ y,
194
+ i(/[$.*+?^(){}[\|]/, (r) => `\\${r}`),
195
+ br,
196
+ i(/[^\]]/, p)
197
+ ]), B = x([
198
+ $r,
199
+ tr(Ar),
200
+ f(Er),
201
+ wr
202
+ ]), Pr = i("{", "(?:"), Or = i("}", ")"), I = x([
203
+ Pr,
204
+ l([
205
+ i(/(\d+)\.\.(\d+)/, (r, e, n) => or(+e, +n, Math.min(e.length, n.length)).join("|")),
206
+ i(/([a-z]+)\.\.([a-z]+)/, (r, e, n) => R(e, n).join("|")),
207
+ i(/([A-Z]+)\.\.([A-Z]+)/, (r, e, n) => R(e.toLowerCase(), n.toLowerCase()).join("|").toUpperCase())
208
+ ]),
209
+ Or
210
+ ]), kr = i("{", "(?:"), Br = i("}", ")"), Ir = i(",", "|"), Fr = i(/[$.*+?^(){[\]\|]/, (r) => `\\${r}`), Lr = i(/[^}]/, p), F = x([
211
+ kr,
212
+ f(l([
213
+ j,
214
+ N,
215
+ k,
216
+ B,
217
+ I,
218
+ E(() => F),
219
+ y,
220
+ Fr,
221
+ Ir,
222
+ Lr
223
+ ])),
224
+ Br
225
+ ]), L = z(f(l([
226
+ sr,
227
+ cr,
228
+ lr,
229
+ fr,
230
+ j,
231
+ N,
232
+ k,
233
+ B,
234
+ I,
235
+ F,
236
+ y,
237
+ pr,
238
+ vr
239
+ ]))), Tr = i(/\\./, p), qr = i(/./, p), Yr = z(f(l([
240
+ Tr,
241
+ i(/\*\*\*+/, "*"),
242
+ i(/([^/{[(!])\*\*/, (r, e) => `${e}*`),
243
+ i(/(^|.)\*\*(?=[^*/)\]}])/, (r, e) => `${e}*`),
244
+ qr
245
+ ]))), $ = (r, e) => {
246
+ const n = Array.isArray(r) ? r : [r];
247
+ if (!n.length) return false;
248
+ const a = n.map($.compile), t = n.every((s) => /(\/(?:\*\*)?|\[\/\])$/.test(s)), o = e.replace(/[\\\/]+/g, "/").replace(/\/$/, t ? "/" : "");
249
+ return a.some((s) => s.test(o));
250
+ };
251
+ $.compile = (r) => new RegExp(`^${L(Yr(r))}$`, "s");
252
+ var re = $;
253
+ return J(w);
254
+ })();
255
+ return __lib__.default || __lib__;
256
+ };
257
+ let _match;
258
+ const zeptomatch = (path, pattern) => {
259
+ if (!_match) {
260
+ _match = _lazyMatch();
261
+ _lazyMatch = null;
262
+ }
263
+ return _match(path, pattern);
264
+ };
265
+ const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
266
+ function normalizeWindowsPath(input = "") {
267
+ if (!input) return input;
268
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
269
+ }
270
+ const _UNC_REGEX = /^[/\\]{2}/;
271
+ const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
272
+ const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
273
+ const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
274
+ const _EXTNAME_RE = /.(\.[^./]+|\.)$/;
275
+ const _PATH_ROOT_RE = /^[/\\]|^[a-zA-Z]:[/\\]/;
276
+ const sep = "/";
277
+ const normalize = function(path) {
278
+ if (path.length === 0) return ".";
279
+ path = normalizeWindowsPath(path);
280
+ const isUNCPath = path.match(_UNC_REGEX);
281
+ const isPathAbsolute = isAbsolute(path);
282
+ const trailingSeparator = path[path.length - 1] === "/";
283
+ path = normalizeString(path, !isPathAbsolute);
284
+ if (path.length === 0) {
285
+ if (isPathAbsolute) return "/";
286
+ return trailingSeparator ? "./" : ".";
287
+ }
288
+ if (trailingSeparator) path += "/";
289
+ if (_DRIVE_LETTER_RE.test(path)) path += "/";
290
+ if (isUNCPath) {
291
+ if (!isPathAbsolute) return `//./${path}`;
292
+ return `//${path}`;
293
+ }
294
+ return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
295
+ };
296
+ const join = function(...segments) {
297
+ let path = "";
298
+ for (const seg of segments) {
299
+ if (!seg) continue;
300
+ if (path.length > 0) {
301
+ const pathTrailing = path[path.length - 1] === "/";
302
+ const segLeading = seg[0] === "/";
303
+ if (pathTrailing && segLeading) path += seg.slice(1);
304
+ else path += pathTrailing || segLeading ? seg : `/${seg}`;
305
+ } else path += seg;
306
+ }
307
+ return normalize(path);
308
+ };
309
+ function cwd() {
310
+ if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
311
+ return "/";
312
+ }
313
+ const resolve = function(...arguments_) {
314
+ arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
315
+ let resolvedPath = "";
316
+ let resolvedAbsolute = false;
317
+ for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
318
+ const path = index >= 0 ? arguments_[index] : cwd();
319
+ if (!path || path.length === 0) continue;
320
+ resolvedPath = `${path}/${resolvedPath}`;
321
+ resolvedAbsolute = isAbsolute(path);
322
+ }
323
+ resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
324
+ if (resolvedAbsolute && !isAbsolute(resolvedPath)) return `/${resolvedPath}`;
325
+ return resolvedPath.length > 0 ? resolvedPath : ".";
326
+ };
327
+ function normalizeString(path, allowAboveRoot) {
328
+ let res = "";
329
+ let lastSegmentLength = 0;
330
+ let lastSlash = -1;
331
+ let dots = 0;
332
+ let char = null;
333
+ for (let index = 0; index <= path.length; ++index) {
334
+ if (index < path.length) char = path[index];
335
+ else if (char === "/") break;
336
+ else char = "/";
337
+ if (char === "/") {
338
+ if (lastSlash === index - 1 || dots === 1);
339
+ else if (dots === 2) {
340
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
341
+ if (res.length > 2) {
342
+ const lastSlashIndex = res.lastIndexOf("/");
343
+ if (lastSlashIndex === -1) {
344
+ res = "";
345
+ lastSegmentLength = 0;
346
+ } else {
347
+ res = res.slice(0, lastSlashIndex);
348
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
349
+ }
350
+ lastSlash = index;
351
+ dots = 0;
352
+ continue;
353
+ } else if (res.length > 0) {
354
+ res = "";
355
+ lastSegmentLength = 0;
356
+ lastSlash = index;
357
+ dots = 0;
358
+ continue;
359
+ }
360
+ }
361
+ if (allowAboveRoot) {
362
+ res += res.length > 0 ? "/.." : "..";
363
+ lastSegmentLength = 2;
364
+ }
365
+ } else {
366
+ if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
367
+ else res = path.slice(lastSlash + 1, index);
368
+ lastSegmentLength = index - lastSlash - 1;
369
+ }
370
+ lastSlash = index;
371
+ dots = 0;
372
+ } else if (char === "." && dots !== -1) ++dots;
373
+ else dots = -1;
374
+ }
375
+ return res;
376
+ }
377
+ const isAbsolute = function(p) {
378
+ return _IS_ABSOLUTE_RE.test(p);
379
+ };
380
+ const toNamespacedPath = function(p) {
381
+ return normalizeWindowsPath(p);
382
+ };
383
+ const extname = function(p) {
384
+ if (p === "..") return "";
385
+ const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
386
+ return match && match[1] || "";
387
+ };
388
+ const relative = function(from, to) {
389
+ const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
390
+ const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
391
+ if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) return _to.join("/");
392
+ const _fromCopy = [..._from];
393
+ for (const segment of _fromCopy) {
394
+ if (_to[0] !== segment) break;
395
+ _from.shift();
396
+ _to.shift();
397
+ }
398
+ return [..._from.map(() => ".."), ..._to].join("/");
399
+ };
400
+ const dirname = function(p) {
401
+ const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
402
+ if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) segments[0] += "/";
403
+ return segments.join("/") || (isAbsolute(p) ? "/" : ".");
404
+ };
405
+ const format = function(p) {
406
+ const ext = p.ext ? p.ext.startsWith(".") ? p.ext : `.${p.ext}` : "";
407
+ const segments = [
408
+ p.root,
409
+ p.dir,
410
+ p.base ?? (p.name ?? "") + ext
411
+ ].filter(Boolean);
412
+ return normalizeWindowsPath(p.root ? resolve(...segments) : segments.join("/"));
413
+ };
414
+ const basename = function(p, extension) {
415
+ const segments = normalizeWindowsPath(p).split("/");
416
+ let lastSegment = "";
417
+ for (let i = segments.length - 1; i >= 0; i--) {
418
+ const val = segments[i];
419
+ if (val) {
420
+ lastSegment = val;
421
+ break;
422
+ }
423
+ }
424
+ return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
425
+ };
426
+ const parse$2 = function(p) {
427
+ const root = _PATH_ROOT_RE.exec(p)?.[0]?.replace(/\\/g, "/") || "";
428
+ const base = basename(p);
429
+ const extension = extname(base);
430
+ return {
431
+ root,
432
+ dir: dirname(p),
433
+ base,
434
+ ext: extension,
435
+ name: base.slice(0, base.length - extension.length)
436
+ };
437
+ };
438
+ const matchesGlob = (path, pattern) => {
439
+ return zeptomatch(pattern, normalize(path));
440
+ };
441
+ const _path = {
442
+ __proto__: null,
443
+ basename,
444
+ dirname,
445
+ extname,
446
+ format,
447
+ isAbsolute,
448
+ join,
449
+ matchesGlob,
450
+ normalize,
451
+ normalizeString,
452
+ parse: parse$2,
453
+ relative,
454
+ resolve,
455
+ sep,
456
+ toNamespacedPath
457
+ };
458
+
459
+ //#endregion
460
+ //#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.mjs
461
+ const delimiter = globalThis.process?.platform === "win32" ? ";" : ":";
462
+ const _platforms = {
463
+ posix: void 0,
464
+ win32: void 0
465
+ };
466
+ const mix = (del = delimiter) => {
467
+ return new Proxy(_path, { get(_, prop) {
468
+ if (prop === "delimiter") return del;
469
+ if (prop === "posix") return posix;
470
+ if (prop === "win32") return win32;
471
+ return _platforms[prop] || _path[prop];
472
+ } });
473
+ };
474
+ const posix = /* @__PURE__ */ mix(":");
475
+ const win32 = /* @__PURE__ */ mix(";");
476
+
477
+ //#endregion
478
+ //#region src/utils/module-specifier.ts
479
+ function isRelativeSpecifier(specifier) {
480
+ return specifier === "." || specifier === ".." || specifier.startsWith("./") || specifier.startsWith("../");
481
+ }
482
+ function isUrlOrDataOrFileSpecifier(specifier) {
483
+ return specifier.startsWith("data:") || specifier.startsWith("file:") || specifier.startsWith("http:") || specifier.startsWith("https:");
484
+ }
485
+ function isVirtualModuleSpecifier(specifier) {
486
+ return specifier.startsWith("virtual:");
487
+ }
488
+ function isPackageImportSpecifier(specifier) {
489
+ return specifier.startsWith("#");
490
+ }
491
+ function isBarePackageSpecifier(specifier) {
492
+ return !isRelativeSpecifier(specifier) && !isPackageImportSpecifier(specifier) && !isUrlOrDataOrFileSpecifier(specifier) && !isVirtualModuleSpecifier(specifier) && !posix.isAbsolute(specifier);
493
+ }
494
+
495
+ //#endregion
496
+ //#region src/utils/path.ts
497
+ function toPosixPath(value) {
498
+ return normalizeSlashes(value);
499
+ }
500
+ function normalizeAbsolutePath(value) {
501
+ return resolve(value);
502
+ }
503
+ function toRelativePath(rootDir, absolutePath) {
504
+ const relativePath = relative(rootDir, resolve(absolutePath));
505
+ return relativePath.length === 0 ? "." : relativePath;
506
+ }
507
+ function normalizeSlashes(value) {
508
+ return value.replaceAll("\\", "/");
509
+ }
510
+ function isPathInsideDirectory(filePath, directoryPath) {
511
+ const normalizedFilePath = normalizeAbsolutePath(filePath);
512
+ const normalizedDirectoryPath = normalizeAbsolutePath(directoryPath);
513
+ return normalizedFilePath === normalizedDirectoryPath || normalizedFilePath.startsWith(`${normalizedDirectoryPath}/`);
514
+ }
515
+
516
+ //#endregion
517
+ //#region src/utils/module-resolution.ts
518
+ function pathHasExtension(value) {
519
+ return posix.extname(value).length > 0;
520
+ }
521
+ function candidatePathsForBasePath(basePath, extensions) {
522
+ if (pathHasExtension(basePath)) return [basePath];
523
+ return extensions.flatMap((extension) => [`${basePath}${extension}`, posix.join(basePath, `index${extension}`)]);
524
+ }
525
+ function resolveExistingFilePath(candidatePath) {
526
+ if (!existsSync(candidatePath)) return null;
527
+ if (!statSync(candidatePath).isFile()) return null;
528
+ return normalizeAbsolutePath(candidatePath);
529
+ }
530
+ function matchPathPattern(pattern, specifier) {
531
+ const wildcardIndex = pattern.indexOf("*");
532
+ if (wildcardIndex === -1) return pattern === specifier ? "" : null;
533
+ const prefix = pattern.slice(0, wildcardIndex);
534
+ const suffix = pattern.slice(wildcardIndex + 1);
535
+ if (!specifier.startsWith(prefix) || !specifier.endsWith(suffix)) return null;
536
+ return specifier.slice(prefix.length, specifier.length - suffix.length);
537
+ }
538
+ function resolveRelativeModuleCandidate(options) {
539
+ if (!isRelativeSpecifier(options.specifier)) return null;
540
+ const resolvedSpecifierPath = posix.resolve(posix.dirname(options.containingFile), options.specifier);
541
+ for (const candidatePath of candidatePathsForBasePath(resolvedSpecifierPath, options.extensions)) {
542
+ const resolvedPath = resolveExistingFilePath(candidatePath);
543
+ if (resolvedPath) return resolvedPath;
544
+ }
545
+ return null;
546
+ }
547
+ function resolvePathMappedModuleCandidate(options) {
548
+ const paths = options.compilerOptions.paths;
549
+ const pathsBasePath = getPathsBasePath(options.compilerOptions);
550
+ if (!paths || !pathsBasePath) return null;
551
+ const pathEntries = Object.entries(paths).sort(([left], [right]) => {
552
+ const leftPrefixLength = left.split("*")[0]?.length ?? left.length;
553
+ return (right.split("*")[0]?.length ?? right.length) - leftPrefixLength;
554
+ });
555
+ for (const [alias, targets] of pathEntries) {
556
+ const matchedText = matchPathPattern(alias, options.specifier);
557
+ if (matchedText === null) continue;
558
+ for (const target of targets) {
559
+ const resolvedTargetPath = posix.resolve(pathsBasePath, applyPathPattern(target, matchedText));
560
+ for (const candidatePath of candidatePathsForBasePath(resolvedTargetPath, options.extensions)) {
561
+ const resolvedPath = resolveExistingFilePath(candidatePath);
562
+ if (resolvedPath) return resolvedPath;
563
+ }
564
+ }
565
+ }
566
+ return null;
567
+ }
568
+ function resolveBaseUrlModuleCandidate(options) {
569
+ if (isRelativeSpecifier(options.specifier) || !options.compilerOptions.baseUrl) return null;
570
+ const baseUrlPath = posix.resolve(options.compilerOptions.baseUrl, options.specifier);
571
+ for (const candidatePath of candidatePathsForBasePath(baseUrlPath, options.extensions)) {
572
+ const resolvedPath = resolveExistingFilePath(candidatePath);
573
+ if (resolvedPath) return resolvedPath;
574
+ }
575
+ return null;
576
+ }
577
+ function applyPathPattern(pattern, matchedText) {
578
+ return pattern.includes("*") ? pattern.replace("*", matchedText) : pattern;
579
+ }
580
+ function getPathsBasePath(compilerOptions) {
581
+ const pathsBasePath = compilerOptions.pathsBasePath;
582
+ if (typeof pathsBasePath === "string") return pathsBasePath;
583
+ return compilerOptions.baseUrl ?? null;
584
+ }
585
+
586
+ //#endregion
587
+ //#region src/checkers.ts
588
+ function getTypeScriptExtensionApi() {
589
+ const api = ts;
590
+ if (typeof api.getSupportedExtensions !== "function" || typeof api.getSupportedExtensionsWithJsonIfResolveJsonModule !== "function") throw new TypeError("Unable to resolve TypeScript checker extensions: the TypeScript compiler API does not expose supported extension metadata.");
591
+ return api;
592
+ }
593
+ function flattenTypeScriptExtensionGroups(groups) {
594
+ return groups.flatMap((group) => [...group]);
595
+ }
596
+ function getTypeScriptCheckerExtensions() {
597
+ const api = getTypeScriptExtensionApi();
598
+ const options = { resolveJsonModule: true };
599
+ return normalizeExtensions(flattenTypeScriptExtensionGroups(api.getSupportedExtensionsWithJsonIfResolveJsonModule(options, api.getSupportedExtensions(options))));
600
+ }
601
+ function getNativeTypeScriptProjectExtensions() {
602
+ const api = getTypeScriptExtensionApi();
603
+ const options = {
604
+ allowJs: true,
605
+ resolveJsonModule: true
606
+ };
607
+ return normalizeExtensions(flattenTypeScriptExtensionGroups(api.getSupportedExtensionsWithJsonIfResolveJsonModule(options, api.getSupportedExtensions(options))));
608
+ }
609
+ function getBuildCheckerSupportedExtensions(preset) {
610
+ const adapter = getCheckerAdapter(preset);
611
+ if (!adapter || adapter.execution !== "build") return [];
612
+ const nativeExtensions = getNativeTypeScriptProjectExtensions();
613
+ return preset === "vue-tsc" ? normalizeExtensions([...nativeExtensions, ".vue"]) : nativeExtensions;
614
+ }
615
+ function getSvelteCheckerExtensions() {
616
+ return normalizeExtensions([...getTypeScriptCheckerExtensions(), ".svelte"]);
617
+ }
618
+ const parsedProjectConfigCache = /* @__PURE__ */ new Map();
619
+ function createFormatHost(rootDir) {
620
+ return {
621
+ getCanonicalFileName: (fileName) => fileName,
622
+ getCurrentDirectory: () => rootDir,
623
+ getNewLine: () => "\n"
624
+ };
625
+ }
626
+ function readTypeScriptProjectConfig(options) {
627
+ const diagnostics = [];
628
+ const parsed = ts.getParsedCommandLineOfConfigFile(options.configPath, {}, {
629
+ ...ts.sys,
630
+ onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
631
+ diagnostics.push(diagnostic);
632
+ }
633
+ });
634
+ if (!parsed) throw new Error(ts.formatDiagnosticsWithColorAndContext(diagnostics, createFormatHost(options.projectRootDir)));
635
+ return {
636
+ diagnostics,
637
+ parsed
638
+ };
639
+ }
640
+ function createParsedCheckerProjectConfig(options) {
641
+ return {
642
+ extensions: normalizeExtensions(options.extensions),
643
+ fileNames: options.fileNames.map(normalizeAbsolutePath).sort(),
644
+ options: options.parsed.options
645
+ };
646
+ }
647
+ function cloneParsedCheckerProjectConfig(parsedConfig) {
648
+ return {
649
+ extensions: [...parsedConfig.extensions],
650
+ fileNames: [...parsedConfig.fileNames],
651
+ options: { ...parsedConfig.options }
652
+ };
653
+ }
654
+ function resolveContextCheckerPresets(context) {
655
+ return context.checkerPresets.length > 0 ? uniqueSortedStrings(context.checkerPresets) : ["tsc"];
656
+ }
657
+ function createParsedProjectConfigCacheKey(options) {
658
+ const configStat = statSync(options.configPath);
659
+ return JSON.stringify({
660
+ checkerPresets: options.checkerPresets,
661
+ configPath: normalizeAbsolutePath(options.configPath),
662
+ configSize: configStat.size,
663
+ configTime: configStat.mtimeMs,
664
+ extensions: normalizeExtensions(options.extensions),
665
+ projectRootDir: normalizeAbsolutePath(options.projectRootDir)
666
+ });
667
+ }
668
+ function clearCheckerProjectConfigCache() {
669
+ parsedProjectConfigCache.clear();
670
+ }
671
+ function createExtraFileExtensions(extensions) {
672
+ const nativeExtensions = new Set(getNativeTypeScriptProjectExtensions());
673
+ return extensions.filter((extension) => !nativeExtensions.has(extension)).map((extension) => ({
674
+ extension: extension.startsWith(".") ? extension.slice(1) : extension,
675
+ isMixedContent: true,
676
+ scriptKind: ts.ScriptKind.Deferred
677
+ }));
678
+ }
679
+ function parseProjectConfigWithExtraFileExtensions(options, extensions) {
680
+ const diagnostics = [];
681
+ const parsed = ts.getParsedCommandLineOfConfigFile(options.configPath, {}, {
682
+ ...ts.sys,
683
+ onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
684
+ diagnostics.push(diagnostic);
685
+ }
686
+ }, void 0, void 0, createExtraFileExtensions(extensions));
687
+ if (!parsed) throw new Error(ts.formatDiagnosticsWithColorAndContext(diagnostics, createFormatHost(options.projectRootDir)));
688
+ const errors = [...diagnostics, ...parsed.errors];
689
+ if (errors.length > 0) throw new Error(ts.formatDiagnosticsWithColorAndContext(errors, createFormatHost(options.projectRootDir)));
690
+ return createParsedCheckerProjectConfig({
691
+ extensions,
692
+ fileNames: parsed.fileNames,
693
+ parsed
694
+ });
695
+ }
696
+ function parseTypeScriptProjectConfig(options, extensions) {
697
+ const { diagnostics, parsed } = readTypeScriptProjectConfig(options);
698
+ const errors = [...diagnostics, ...parsed.errors];
699
+ if (errors.length > 0) throw new Error(ts.formatDiagnosticsWithColorAndContext(errors, createFormatHost(options.projectRootDir)));
700
+ return createParsedCheckerProjectConfig({
701
+ extensions,
702
+ fileNames: parsed.fileNames,
703
+ parsed
704
+ });
705
+ }
706
+ function isModuleNotFoundError(error) {
707
+ return error !== null && typeof error === "object" && "code" in error && error.code === "MODULE_NOT_FOUND";
708
+ }
709
+ function createCheckerPackageRequire(options) {
710
+ for (const basePath of [posix.join(options.projectRootDir, "package.json"), import.meta.url]) {
711
+ const requireFromBase = createRequire(basePath);
712
+ try {
713
+ return createRequire(requireFromBase.resolve(`${options.packageName}/package.json`));
714
+ } catch (error) {
715
+ if (error && typeof error === "object" && "code" in error && error.code === "ERR_PACKAGE_PATH_NOT_EXPORTED") return createRequire(requireFromBase.resolve(options.packageName));
716
+ if (isModuleNotFoundError(error)) continue;
717
+ throw error;
718
+ }
719
+ }
720
+ return null;
721
+ }
722
+ function getVueLanguageCore(options) {
723
+ const requireFromChecker = createCheckerPackageRequire(options);
724
+ if (!requireFromChecker) throw new Error([
725
+ "Unable to resolve Vue checker package:",
726
+ ` package: ${options.packageName}`,
727
+ ` root: ${options.projectRootDir}`
728
+ ].join("\n"));
729
+ try {
730
+ return requireFromChecker("@vue/language-core");
731
+ } catch (error) {
732
+ if (isModuleNotFoundError(error)) throw new Error([
733
+ "Unable to resolve Vue checker language core:",
734
+ ` checker package: ${options.packageName}`,
735
+ " required package: @vue/language-core"
736
+ ].join("\n"));
737
+ throw error;
738
+ }
739
+ }
740
+ function createVueParsedCommandLine(options) {
741
+ const vueLanguageCore = getVueLanguageCore({
742
+ packageName: options.packageName,
743
+ projectRootDir: options.projectRootDir
744
+ });
745
+ const configPath = normalizeAbsolutePath(options.configPath);
746
+ return {
747
+ commandLine: vueLanguageCore.createParsedCommandLine(ts, ts.sys, configPath),
748
+ configPath,
749
+ vueLanguageCore
750
+ };
751
+ }
752
+ function resolveVueProjectExtensions(options, packageName) {
753
+ const { commandLine, vueLanguageCore } = createVueParsedCommandLine({
754
+ configPath: options.configPath,
755
+ packageName,
756
+ projectRootDir: options.projectRootDir
757
+ });
758
+ try {
759
+ return normalizeExtensions([...getTypeScriptCheckerExtensions(), ...vueLanguageCore.getAllExtensions(commandLine.vueOptions)]);
760
+ } catch (error) {
761
+ throw new Error([
762
+ "Unable to resolve Vue checker extensions:",
763
+ ` checker package: ${packageName}`,
764
+ ` config: ${toRelativePath(options.projectRootDir, options.configPath)}`,
765
+ ` reason: ${String(error)}`
766
+ ].join("\n"));
767
+ }
768
+ }
769
+ function parseProjectConfigWithExtensions(options, extensions) {
770
+ const resolvedExtensions = options.extensions && options.extensions.length > 0 ? options.extensions : extensions;
771
+ return createExtraFileExtensions(resolvedExtensions).length > 0 ? parseProjectConfigWithExtraFileExtensions(options, resolvedExtensions) : parseTypeScriptProjectConfig(options, resolvedExtensions);
772
+ }
773
+ function parseVueProjectConfig(options, packageName) {
774
+ const { commandLine, configPath, vueLanguageCore } = createVueParsedCommandLine({
775
+ configPath: options.configPath,
776
+ packageName,
777
+ projectRootDir: options.projectRootDir
778
+ });
779
+ const extensions = normalizeExtensions([
780
+ ...options.extensions ?? [],
781
+ ...getTypeScriptCheckerExtensions(),
782
+ ...vueLanguageCore.getAllExtensions(commandLine.vueOptions)
783
+ ]);
784
+ const configFile = ts.readJsonConfigFile(configPath, ts.sys.readFile);
785
+ const parsed = ts.parseJsonSourceFileConfigFileContent(configFile, ts.sys, posix.dirname(configPath), {}, configPath, void 0, createExtraFileExtensions(extensions));
786
+ const errors = parsed.errors;
787
+ if (errors.length > 0) throw new Error(ts.formatDiagnosticsWithColorAndContext(errors, createFormatHost(options.projectRootDir)));
788
+ return createParsedCheckerProjectConfig({
789
+ extensions,
790
+ fileNames: parsed.fileNames,
791
+ parsed
792
+ });
793
+ }
794
+ function resolveExtensionsForChecker(options, extensions) {
795
+ return normalizeExtensions(options.extensions && options.extensions.length > 0 ? options.extensions : extensions);
796
+ }
797
+ function resolveVueProjectExtensionsForChecker(options, packageName) {
798
+ return normalizeExtensions([...options.extensions ?? [], ...resolveVueProjectExtensions(options, packageName)]);
799
+ }
800
+ function resolveTypeScriptModuleName(options) {
801
+ const resolved = ts.resolveModuleName(options.specifier, options.containingFile, options.compilerOptions, ts.sys).resolvedModule;
802
+ if (resolved?.resolvedFileName) return normalizeAbsolutePath(resolved.resolvedFileName);
803
+ return resolveRelativeModuleCandidate(options) ?? resolvePathMappedModuleCandidate(options);
804
+ }
805
+ function mergeParsedProjectConfigs(parsedConfigs, extensions) {
806
+ const firstConfig = parsedConfigs[0];
807
+ if (!firstConfig) throw new Error("Unable to parse checker project config: no parser ran.");
808
+ return {
809
+ extensions: normalizeExtensions([...extensions, ...parsedConfigs.flatMap((parsedConfig) => parsedConfig.extensions)]),
810
+ fileNames: uniqueSortedStrings(parsedConfigs.flatMap((parsedConfig) => parsedConfig.fileNames)),
811
+ options: firstConfig.options
812
+ };
813
+ }
814
+ function parseCheckerProjectConfigForContext(options) {
815
+ const checkerPresets = resolveContextCheckerPresets(options.context);
816
+ const cacheKey = createParsedProjectConfigCacheKey({
817
+ checkerPresets,
818
+ configPath: options.configPath,
819
+ extensions: options.context.extensions,
820
+ projectRootDir: options.projectRootDir
821
+ });
822
+ const cached = parsedProjectConfigCache.get(cacheKey);
823
+ if (cached) return cloneParsedCheckerProjectConfig(cached);
824
+ const parsedConfig = mergeParsedProjectConfigs(checkerPresets.map((preset) => {
825
+ const adapter = getCheckerAdapter(preset);
826
+ if (!adapter) throw new Error(`Checker preset "${preset}" is not supported.`);
827
+ return adapter.parseProjectConfig({
828
+ configPath: options.configPath,
829
+ extensions: options.context.extensions,
830
+ projectRootDir: options.projectRootDir
831
+ });
832
+ }), options.context.extensions);
833
+ parsedProjectConfigCache.set(cacheKey, cloneParsedCheckerProjectConfig(parsedConfig));
834
+ return cloneParsedCheckerProjectConfig(parsedConfig);
835
+ }
836
+ function resolveModuleNameWithCheckers(options) {
837
+ const checkerPresets = options.context.checkerPresets.length > 0 ? options.context.checkerPresets : ["tsc"];
838
+ for (const preset of checkerPresets) {
839
+ const adapter = getCheckerAdapter(preset);
840
+ if (!adapter) continue;
841
+ const resolved = adapter.resolveModuleName({
842
+ compilerOptions: options.compilerOptions,
843
+ containingFile: options.containingFile,
844
+ extensions: options.context.extensions,
845
+ specifier: options.specifier
846
+ });
847
+ if (resolved) return resolved;
848
+ }
849
+ return null;
850
+ }
851
+ function resolveCheckerProjectExtensions(options) {
852
+ const adapter = getCheckerAdapter(options.preset);
853
+ if (!adapter) throw new Error(`Checker preset "${options.preset}" is not supported.`);
854
+ return adapter.extensions({
855
+ configPath: options.configPath,
856
+ projectRootDir: options.projectRootDir
857
+ });
858
+ }
859
+ function createTscCommandTarget(options) {
860
+ const relativeConfigPath = toRelativePath(options.projectRootDir, options.configPath);
861
+ return {
862
+ args: [
863
+ "-b",
864
+ relativeConfigPath,
865
+ "--pretty",
866
+ "false",
867
+ ...options.watch ? ["--watch", "--preserveWatchOutput"] : []
868
+ ],
869
+ command: options.commandOverride ?? "tsc",
870
+ label: `tsc -b ${relativeConfigPath}${options.watch ? " --watch" : ""}`
871
+ };
872
+ }
873
+ function createTsgoCommandTarget(options) {
874
+ const relativeConfigPath = toRelativePath(options.projectRootDir, options.configPath);
875
+ return {
876
+ args: [
877
+ "-b",
878
+ relativeConfigPath,
879
+ "--pretty",
880
+ "false",
881
+ ...options.watch ? ["--watch", "--preserveWatchOutput"] : []
882
+ ],
883
+ command: "tsgo",
884
+ label: `tsgo -b ${relativeConfigPath}${options.watch ? " --watch" : ""}`
885
+ };
886
+ }
887
+ function createVueTscCommandTarget(options) {
888
+ const relativeConfigPath = toRelativePath(options.projectRootDir, options.configPath);
889
+ return {
890
+ args: [
891
+ "-b",
892
+ relativeConfigPath,
893
+ "--pretty",
894
+ "false",
895
+ ...options.watch ? ["--watch", "--preserveWatchOutput"] : []
896
+ ],
897
+ command: "vue-tsc",
898
+ label: `${options.checker.name}: vue-tsc -b ${relativeConfigPath}${options.watch ? " --watch" : ""}`
899
+ };
900
+ }
901
+ function createVueTsgoCommandTarget(options) {
902
+ const relativeConfigPath = toRelativePath(options.projectRootDir, options.configPath);
903
+ /**
904
+ * vue-tsgo exposes a --build flag, but in current releases that mode
905
+ * generates a transient virtual TS workspace and asks tsgo's LSP for
906
+ * diagnostics. It does not preserve TypeScript project-reference boundaries
907
+ * or provide incremental build semantics, so Limina only uses vue-tsgo as a
908
+ * second-class typecheck execution checker while still using its tsconfig
909
+ * entry for Limina's own graph and proof coverage. Prefer vue-tsc for
910
+ * first-class Vue build checks.
911
+ */
912
+ return {
913
+ args: ["--project", relativeConfigPath],
914
+ command: "vue-tsgo",
915
+ label: `${options.checker.name}: vue-tsgo --project ${relativeConfigPath}`
916
+ };
917
+ }
918
+ function createSvelteCheckCommandTarget(options) {
919
+ const relativeConfigPath = toRelativePath(options.projectRootDir, options.configPath);
920
+ return {
921
+ args: ["--tsconfig", relativeConfigPath],
922
+ command: "svelte-check",
923
+ label: `${options.checker.name}: svelte-check --tsconfig ${relativeConfigPath}`
924
+ };
925
+ }
926
+ const builtinCheckerAdapters = {
927
+ "svelte-check": {
928
+ createCommandTarget: createSvelteCheckCommandTarget,
929
+ extensions: (options) => resolveExtensionsForChecker(options, getSvelteCheckerExtensions()),
930
+ execution: "typecheck",
931
+ packageNames: ["svelte-check"],
932
+ parseProjectConfig: (options) => parseProjectConfigWithExtensions(options, getSvelteCheckerExtensions()),
933
+ preset: "svelte-check",
934
+ resolveModuleName: resolveTypeScriptModuleName,
935
+ sourceGraph: false
936
+ },
937
+ tsc: {
938
+ createCommandTarget: createTscCommandTarget,
939
+ extensions: (options) => resolveExtensionsForChecker(options, getTypeScriptCheckerExtensions()),
940
+ execution: "build",
941
+ packageNames: ["typescript"],
942
+ parseProjectConfig: (options) => parseProjectConfigWithExtensions(options, getTypeScriptCheckerExtensions()),
943
+ preset: "tsc",
944
+ resolveModuleName: resolveTypeScriptModuleName,
945
+ sourceGraph: true
946
+ },
947
+ tsgo: {
948
+ createCommandTarget: createTsgoCommandTarget,
949
+ extensions: (options) => resolveExtensionsForChecker(options, getTypeScriptCheckerExtensions()),
950
+ execution: "build",
951
+ packageNames: ["@typescript/native-preview"],
952
+ parseProjectConfig: (options) => parseProjectConfigWithExtensions(options, getTypeScriptCheckerExtensions()),
953
+ preset: "tsgo",
954
+ resolveModuleName: resolveTypeScriptModuleName,
955
+ sourceGraph: true
956
+ },
957
+ "vue-tsc": {
958
+ createCommandTarget: createVueTscCommandTarget,
959
+ extensions: (options) => resolveVueProjectExtensionsForChecker(options, "vue-tsc"),
960
+ execution: "build",
961
+ packageNames: ["vue-tsc"],
962
+ parseProjectConfig: (options) => parseVueProjectConfig(options, "vue-tsc"),
963
+ preset: "vue-tsc",
964
+ resolveModuleName: resolveTypeScriptModuleName,
965
+ sourceGraph: true
966
+ },
967
+ "vue-tsgo": {
968
+ createCommandTarget: createVueTsgoCommandTarget,
969
+ extensions: (options) => resolveVueProjectExtensionsForChecker(options, "vue-tsgo"),
970
+ execution: "typecheck",
971
+ packageNames: ["vue-tsgo", "@typescript/native-preview"],
972
+ parseProjectConfig: (options) => parseVueProjectConfig(options, "vue-tsgo"),
973
+ preset: "vue-tsgo",
974
+ resolveModuleName: resolveTypeScriptModuleName,
975
+ sourceGraph: true
976
+ }
977
+ };
978
+ function isBuiltinCheckerPreset(value) {
979
+ return Object.hasOwn(builtinCheckerAdapters, value);
980
+ }
981
+ function getCheckerAdapter(preset) {
982
+ return isBuiltinCheckerPreset(preset) ? builtinCheckerAdapters[preset] : null;
983
+ }
984
+ function isVueCheckerPreset(preset) {
985
+ return preset === "vue-tsc" || preset === "vue-tsgo";
986
+ }
987
+ function resolveCheckerPackageFromRoot(options) {
988
+ const requireFromRoot = createRequire(posix.join(options.projectRootDir, "package.json"));
989
+ try {
990
+ return requireFromRoot.resolve(`${options.packageName}/package.json`);
991
+ } catch (error) {
992
+ if (error && typeof error === "object" && "code" in error && error.code === "ERR_PACKAGE_PATH_NOT_EXPORTED") return options.packageName;
993
+ if (error && typeof error === "object" && "code" in error && error.code === "MODULE_NOT_FOUND") return;
994
+ throw error;
995
+ }
996
+ }
997
+ function collectMissingCheckerPeerDependencies(options) {
998
+ const resolvePackage = options.resolvePackage ?? resolveCheckerPackageFromRoot;
999
+ const missingCheckersByPackage = /* @__PURE__ */ new Map();
1000
+ for (const checker of options.checkers) {
1001
+ const packageNames = getCheckerAdapter(checker.preset)?.packageNames ?? [];
1002
+ for (const packageName of packageNames) {
1003
+ if (resolvePackage({
1004
+ packageName,
1005
+ projectRootDir: options.projectRootDir
1006
+ })) continue;
1007
+ const checkerNames = missingCheckersByPackage.get(packageName) ?? /* @__PURE__ */ new Set();
1008
+ checkerNames.add(checker.name);
1009
+ missingCheckersByPackage.set(packageName, checkerNames);
1010
+ }
1011
+ }
1012
+ return [...missingCheckersByPackage.entries()].map(([packageName, checkerNames]) => ({
1013
+ checkerNames: [...checkerNames].sort((left, right) => left.localeCompare(right)),
1014
+ packageName
1015
+ })).sort((left, right) => left.packageName.localeCompare(right.packageName));
1016
+ }
1017
+ function formatMissingCheckerPeerDependencies(missingDependencies) {
1018
+ const packageNames = missingDependencies.map((dependency) => dependency.packageName);
1019
+ return [
1020
+ "Missing checker peer dependencies:",
1021
+ ...missingDependencies.map((dependency) => {
1022
+ const checkerList = dependency.checkerNames.map((checkerName) => `"${checkerName}"`).join(", ");
1023
+ const reason = dependency.reason ? `; ${dependency.reason}` : "";
1024
+ return ` - ${dependency.packageName} (used by checker ${checkerList}${reason})`;
1025
+ }),
1026
+ `Fix: pnpm add -D ${packageNames.join(" ")}`
1027
+ ].join("\n");
1028
+ }
1029
+ function getCheckerExtensions(checker, options = {}) {
1030
+ const adapter = getCheckerAdapter(checker.preset);
1031
+ if (adapter) {
1032
+ if (isVueCheckerPreset(checker.preset)) return normalizeExtensions([...getTypeScriptCheckerExtensions(), ".vue"]);
1033
+ return adapter.extensions({
1034
+ configPath: normalizeAbsolutePath(posix.resolve(options.projectRootDir ?? "", "tsconfig.json")),
1035
+ projectRootDir: options.projectRootDir ?? ""
1036
+ });
1037
+ }
1038
+ throw new Error(`Checker preset "${checker.preset}" is not supported.`);
1039
+ }
1040
+ function getResolvedCheckers(config) {
1041
+ const checkers = config.config?.checkers;
1042
+ if (!checkers || checkers.mode === "auto") return [];
1043
+ const checkerMap = checkers;
1044
+ return Object.entries(checkerMap).map(([name, checker]) => ({
1045
+ exclude: (checker.exclude ?? []).map((value) => value.trim()),
1046
+ extensions: getCheckerExtensions(checker, { projectRootDir: config.rootDir }),
1047
+ include: checker.include.map((value) => value.trim()),
1048
+ name,
1049
+ preset: checker.preset
1050
+ })).sort((left, right) => left.name.localeCompare(right.name));
1051
+ }
1052
+ function normalizeExtensions(extensions) {
1053
+ return uniqueValues(extensions).sort((left, right) => {
1054
+ const lengthDelta = right.length - left.length;
1055
+ return lengthDelta === 0 ? left.localeCompare(right) : lengthDelta;
1056
+ });
1057
+ }
1058
+
1059
+ //#endregion
1060
+ //#region src/utils/values.ts
1061
+ function isPlainRecord(value) {
1062
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
1063
+ }
1064
+ function isNonEmptyString(value) {
1065
+ return typeof value === "string" && value.trim().length > 0;
1066
+ }
1067
+ function formatUnknownValue(value) {
1068
+ if (value === void 0) return "undefined";
1069
+ try {
1070
+ return JSON.stringify(value) ?? String(value);
1071
+ } catch {
1072
+ return String(value);
1073
+ }
1074
+ }
1075
+
1076
+ //#endregion
1077
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.js
1078
+ /** A special constant with type `never` */
1079
+ const NEVER = Object.freeze({ status: "aborted" });
1080
+ function $constructor(name, initializer, params) {
1081
+ function init(inst, def) {
1082
+ if (!inst._zod) Object.defineProperty(inst, "_zod", {
1083
+ value: {
1084
+ def,
1085
+ constr: _,
1086
+ traits: /* @__PURE__ */ new Set()
1087
+ },
1088
+ enumerable: false
1089
+ });
1090
+ if (inst._zod.traits.has(name)) return;
1091
+ inst._zod.traits.add(name);
1092
+ initializer(inst, def);
1093
+ const proto = _.prototype;
1094
+ const keys = Object.keys(proto);
1095
+ for (let i = 0; i < keys.length; i++) {
1096
+ const k = keys[i];
1097
+ if (!(k in inst)) inst[k] = proto[k].bind(inst);
1098
+ }
1099
+ }
1100
+ const Parent = params?.Parent ?? Object;
1101
+ class Definition extends Parent {}
1102
+ Object.defineProperty(Definition, "name", { value: name });
1103
+ function _(def) {
1104
+ var _a;
1105
+ const inst = params?.Parent ? new Definition() : this;
1106
+ init(inst, def);
1107
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
1108
+ for (const fn of inst._zod.deferred) fn();
1109
+ return inst;
1110
+ }
1111
+ Object.defineProperty(_, "init", { value: init });
1112
+ Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
1113
+ if (params?.Parent && inst instanceof params.Parent) return true;
1114
+ return inst?._zod?.traits?.has(name);
1115
+ } });
1116
+ Object.defineProperty(_, "name", { value: name });
1117
+ return _;
1118
+ }
1119
+ var $ZodAsyncError = class extends Error {
1120
+ constructor() {
1121
+ super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
1122
+ }
1123
+ };
1124
+ var $ZodEncodeError = class extends Error {
1125
+ constructor(name) {
1126
+ super(`Encountered unidirectional transform during encode: ${name}`);
1127
+ this.name = "ZodEncodeError";
1128
+ }
1129
+ };
1130
+ const globalConfig = {};
1131
+ function config(newConfig) {
1132
+ if (newConfig) Object.assign(globalConfig, newConfig);
1133
+ return globalConfig;
1134
+ }
1135
+
1136
+ //#endregion
1137
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.js
1138
+ function getEnumValues(entries) {
1139
+ const numericValues = Object.values(entries).filter((v) => typeof v === "number");
1140
+ return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
1141
+ }
1142
+ function jsonStringifyReplacer(_, value) {
1143
+ if (typeof value === "bigint") return value.toString();
1144
+ return value;
1145
+ }
1146
+ function cached(getter) {
1147
+ return { get value() {
1148
+ {
1149
+ const value = getter();
1150
+ Object.defineProperty(this, "value", { value });
1151
+ return value;
1152
+ }
1153
+ throw new Error("cached value already set");
1154
+ } };
1155
+ }
1156
+ function nullish(input) {
1157
+ return input === null || input === void 0;
1158
+ }
1159
+ function cleanRegex(source) {
1160
+ const start = source.startsWith("^") ? 1 : 0;
1161
+ const end = source.endsWith("$") ? source.length - 1 : source.length;
1162
+ return source.slice(start, end);
1163
+ }
1164
+ const EVALUATING = Symbol("evaluating");
1165
+ function defineLazy(object, key, getter) {
1166
+ let value = void 0;
1167
+ Object.defineProperty(object, key, {
1168
+ get() {
1169
+ if (value === EVALUATING) return;
1170
+ if (value === void 0) {
1171
+ value = EVALUATING;
1172
+ value = getter();
1173
+ }
1174
+ return value;
1175
+ },
1176
+ set(v) {
1177
+ Object.defineProperty(object, key, { value: v });
1178
+ },
1179
+ configurable: true
1180
+ });
1181
+ }
1182
+ function assignProp(target, prop, value) {
1183
+ Object.defineProperty(target, prop, {
1184
+ value,
1185
+ writable: true,
1186
+ enumerable: true,
1187
+ configurable: true
1188
+ });
1189
+ }
1190
+ function mergeDefs(...defs) {
1191
+ const mergedDescriptors = {};
1192
+ for (const def of defs) {
1193
+ const descriptors = Object.getOwnPropertyDescriptors(def);
1194
+ Object.assign(mergedDescriptors, descriptors);
1195
+ }
1196
+ return Object.defineProperties({}, mergedDescriptors);
1197
+ }
1198
+ function esc(str) {
1199
+ return JSON.stringify(str);
1200
+ }
1201
+ const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
1202
+ function isObject(data) {
1203
+ return typeof data === "object" && data !== null && !Array.isArray(data);
1204
+ }
1205
+ const allowsEval = cached(() => {
1206
+ if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
1207
+ try {
1208
+ new Function("");
1209
+ return true;
1210
+ } catch (_) {
1211
+ return false;
1212
+ }
1213
+ });
1214
+ function isPlainObject(o) {
1215
+ if (isObject(o) === false) return false;
1216
+ const ctor = o.constructor;
1217
+ if (ctor === void 0) return true;
1218
+ if (typeof ctor !== "function") return true;
1219
+ const prot = ctor.prototype;
1220
+ if (isObject(prot) === false) return false;
1221
+ if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
1222
+ return true;
1223
+ }
1224
+ function shallowClone(o) {
1225
+ if (isPlainObject(o)) return { ...o };
1226
+ if (Array.isArray(o)) return [...o];
1227
+ return o;
1228
+ }
1229
+ const propertyKeyTypes = new Set([
1230
+ "string",
1231
+ "number",
1232
+ "symbol"
1233
+ ]);
1234
+ function escapeRegex(str) {
1235
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1236
+ }
1237
+ function clone(inst, def, params) {
1238
+ const cl = new inst._zod.constr(def ?? inst._zod.def);
1239
+ if (!def || params?.parent) cl._zod.parent = inst;
1240
+ return cl;
1241
+ }
1242
+ function normalizeParams(_params) {
1243
+ const params = _params;
1244
+ if (!params) return {};
1245
+ if (typeof params === "string") return { error: () => params };
1246
+ if (params?.message !== void 0) {
1247
+ if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
1248
+ params.error = params.message;
1249
+ }
1250
+ delete params.message;
1251
+ if (typeof params.error === "string") return {
1252
+ ...params,
1253
+ error: () => params.error
1254
+ };
1255
+ return params;
1256
+ }
1257
+ function optionalKeys(shape) {
1258
+ return Object.keys(shape).filter((k) => {
1259
+ return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
1260
+ });
1261
+ }
1262
+ const NUMBER_FORMAT_RANGES = {
1263
+ safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
1264
+ int32: [-2147483648, 2147483647],
1265
+ uint32: [0, 4294967295],
1266
+ float32: [-34028234663852886e22, 34028234663852886e22],
1267
+ float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
1268
+ };
1269
+ function pick(schema, mask) {
1270
+ const currDef = schema._zod.def;
1271
+ const checks = currDef.checks;
1272
+ if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
1273
+ return clone(schema, mergeDefs(schema._zod.def, {
1274
+ get shape() {
1275
+ const newShape = {};
1276
+ for (const key in mask) {
1277
+ if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
1278
+ if (!mask[key]) continue;
1279
+ newShape[key] = currDef.shape[key];
1280
+ }
1281
+ assignProp(this, "shape", newShape);
1282
+ return newShape;
1283
+ },
1284
+ checks: []
1285
+ }));
1286
+ }
1287
+ function omit(schema, mask) {
1288
+ const currDef = schema._zod.def;
1289
+ const checks = currDef.checks;
1290
+ if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
1291
+ return clone(schema, mergeDefs(schema._zod.def, {
1292
+ get shape() {
1293
+ const newShape = { ...schema._zod.def.shape };
1294
+ for (const key in mask) {
1295
+ if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
1296
+ if (!mask[key]) continue;
1297
+ delete newShape[key];
1298
+ }
1299
+ assignProp(this, "shape", newShape);
1300
+ return newShape;
1301
+ },
1302
+ checks: []
1303
+ }));
1304
+ }
1305
+ function extend(schema, shape) {
1306
+ if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
1307
+ const checks = schema._zod.def.checks;
1308
+ if (checks && checks.length > 0) {
1309
+ const existingShape = schema._zod.def.shape;
1310
+ for (const key in shape) if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
1311
+ }
1312
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
1313
+ const _shape = {
1314
+ ...schema._zod.def.shape,
1315
+ ...shape
1316
+ };
1317
+ assignProp(this, "shape", _shape);
1318
+ return _shape;
1319
+ } }));
1320
+ }
1321
+ function safeExtend(schema, shape) {
1322
+ if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
1323
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
1324
+ const _shape = {
1325
+ ...schema._zod.def.shape,
1326
+ ...shape
1327
+ };
1328
+ assignProp(this, "shape", _shape);
1329
+ return _shape;
1330
+ } }));
1331
+ }
1332
+ function merge(a, b) {
1333
+ return clone(a, mergeDefs(a._zod.def, {
1334
+ get shape() {
1335
+ const _shape = {
1336
+ ...a._zod.def.shape,
1337
+ ...b._zod.def.shape
1338
+ };
1339
+ assignProp(this, "shape", _shape);
1340
+ return _shape;
1341
+ },
1342
+ get catchall() {
1343
+ return b._zod.def.catchall;
1344
+ },
1345
+ checks: []
1346
+ }));
1347
+ }
1348
+ function partial(Class, schema, mask) {
1349
+ const checks = schema._zod.def.checks;
1350
+ if (checks && checks.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
1351
+ return clone(schema, mergeDefs(schema._zod.def, {
1352
+ get shape() {
1353
+ const oldShape = schema._zod.def.shape;
1354
+ const shape = { ...oldShape };
1355
+ if (mask) for (const key in mask) {
1356
+ if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
1357
+ if (!mask[key]) continue;
1358
+ shape[key] = Class ? new Class({
1359
+ type: "optional",
1360
+ innerType: oldShape[key]
1361
+ }) : oldShape[key];
1362
+ }
1363
+ else for (const key in oldShape) shape[key] = Class ? new Class({
1364
+ type: "optional",
1365
+ innerType: oldShape[key]
1366
+ }) : oldShape[key];
1367
+ assignProp(this, "shape", shape);
1368
+ return shape;
1369
+ },
1370
+ checks: []
1371
+ }));
1372
+ }
1373
+ function required(Class, schema, mask) {
1374
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
1375
+ const oldShape = schema._zod.def.shape;
1376
+ const shape = { ...oldShape };
1377
+ if (mask) for (const key in mask) {
1378
+ if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
1379
+ if (!mask[key]) continue;
1380
+ shape[key] = new Class({
1381
+ type: "nonoptional",
1382
+ innerType: oldShape[key]
1383
+ });
1384
+ }
1385
+ else for (const key in oldShape) shape[key] = new Class({
1386
+ type: "nonoptional",
1387
+ innerType: oldShape[key]
1388
+ });
1389
+ assignProp(this, "shape", shape);
1390
+ return shape;
1391
+ } }));
1392
+ }
1393
+ function aborted(x, startIndex = 0) {
1394
+ if (x.aborted === true) return true;
1395
+ for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
1396
+ return false;
1397
+ }
1398
+ function prefixIssues(path, issues) {
1399
+ return issues.map((iss) => {
1400
+ var _a;
1401
+ (_a = iss).path ?? (_a.path = []);
1402
+ iss.path.unshift(path);
1403
+ return iss;
1404
+ });
1405
+ }
1406
+ function unwrapMessage(message) {
1407
+ return typeof message === "string" ? message : message?.message;
1408
+ }
1409
+ function finalizeIssue(iss, ctx, config) {
1410
+ const full = {
1411
+ ...iss,
1412
+ path: iss.path ?? []
1413
+ };
1414
+ if (!iss.message) full.message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
1415
+ delete full.inst;
1416
+ delete full.continue;
1417
+ if (!ctx?.reportInput) delete full.input;
1418
+ return full;
1419
+ }
1420
+ function getLengthableOrigin(input) {
1421
+ if (Array.isArray(input)) return "array";
1422
+ if (typeof input === "string") return "string";
1423
+ return "unknown";
1424
+ }
1425
+ function issue(...args) {
1426
+ const [iss, input, inst] = args;
1427
+ if (typeof iss === "string") return {
1428
+ message: iss,
1429
+ code: "custom",
1430
+ input,
1431
+ inst
1432
+ };
1433
+ return { ...iss };
1434
+ }
1435
+
1436
+ //#endregion
1437
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.js
1438
+ const initializer$1 = (inst, def) => {
1439
+ inst.name = "$ZodError";
1440
+ Object.defineProperty(inst, "_zod", {
1441
+ value: inst._zod,
1442
+ enumerable: false
1443
+ });
1444
+ Object.defineProperty(inst, "issues", {
1445
+ value: def,
1446
+ enumerable: false
1447
+ });
1448
+ inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
1449
+ Object.defineProperty(inst, "toString", {
1450
+ value: () => inst.message,
1451
+ enumerable: false
1452
+ });
1453
+ };
1454
+ const $ZodError = $constructor("$ZodError", initializer$1);
1455
+ const $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
1456
+ function flattenError(error, mapper = (issue) => issue.message) {
1457
+ const fieldErrors = {};
1458
+ const formErrors = [];
1459
+ for (const sub of error.issues) if (sub.path.length > 0) {
1460
+ fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
1461
+ fieldErrors[sub.path[0]].push(mapper(sub));
1462
+ } else formErrors.push(mapper(sub));
1463
+ return {
1464
+ formErrors,
1465
+ fieldErrors
1466
+ };
1467
+ }
1468
+ function formatError(error, mapper = (issue) => issue.message) {
1469
+ const fieldErrors = { _errors: [] };
1470
+ const processError = (error) => {
1471
+ for (const issue of error.issues) if (issue.code === "invalid_union" && issue.errors.length) issue.errors.map((issues) => processError({ issues }));
1472
+ else if (issue.code === "invalid_key") processError({ issues: issue.issues });
1473
+ else if (issue.code === "invalid_element") processError({ issues: issue.issues });
1474
+ else if (issue.path.length === 0) fieldErrors._errors.push(mapper(issue));
1475
+ else {
1476
+ let curr = fieldErrors;
1477
+ let i = 0;
1478
+ while (i < issue.path.length) {
1479
+ const el = issue.path[i];
1480
+ if (!(i === issue.path.length - 1)) curr[el] = curr[el] || { _errors: [] };
1481
+ else {
1482
+ curr[el] = curr[el] || { _errors: [] };
1483
+ curr[el]._errors.push(mapper(issue));
1484
+ }
1485
+ curr = curr[el];
1486
+ i++;
1487
+ }
1488
+ }
1489
+ };
1490
+ processError(error);
1491
+ return fieldErrors;
1492
+ }
1493
+
1494
+ //#endregion
1495
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/parse.js
1496
+ const _parse = (_Err) => (schema, value, _ctx, _params) => {
1497
+ const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
1498
+ const result = schema._zod.run({
1499
+ value,
1500
+ issues: []
1501
+ }, ctx);
1502
+ if (result instanceof Promise) throw new $ZodAsyncError();
1503
+ if (result.issues.length) {
1504
+ const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
1505
+ captureStackTrace(e, _params?.callee);
1506
+ throw e;
1507
+ }
1508
+ return result.value;
1509
+ };
1510
+ const parse$1 = /* @__PURE__ */ _parse($ZodRealError);
1511
+ const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
1512
+ const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
1513
+ let result = schema._zod.run({
1514
+ value,
1515
+ issues: []
1516
+ }, ctx);
1517
+ if (result instanceof Promise) result = await result;
1518
+ if (result.issues.length) {
1519
+ const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
1520
+ captureStackTrace(e, params?.callee);
1521
+ throw e;
1522
+ }
1523
+ return result.value;
1524
+ };
1525
+ const parseAsync$1 = /* @__PURE__ */ _parseAsync($ZodRealError);
1526
+ const _safeParse = (_Err) => (schema, value, _ctx) => {
1527
+ const ctx = _ctx ? {
1528
+ ..._ctx,
1529
+ async: false
1530
+ } : { async: false };
1531
+ const result = schema._zod.run({
1532
+ value,
1533
+ issues: []
1534
+ }, ctx);
1535
+ if (result instanceof Promise) throw new $ZodAsyncError();
1536
+ return result.issues.length ? {
1537
+ success: false,
1538
+ error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
1539
+ } : {
1540
+ success: true,
1541
+ data: result.value
1542
+ };
1543
+ };
1544
+ const safeParse$1 = /* @__PURE__ */ _safeParse($ZodRealError);
1545
+ const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
1546
+ const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
1547
+ let result = schema._zod.run({
1548
+ value,
1549
+ issues: []
1550
+ }, ctx);
1551
+ if (result instanceof Promise) result = await result;
1552
+ return result.issues.length ? {
1553
+ success: false,
1554
+ error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
1555
+ } : {
1556
+ success: true,
1557
+ data: result.value
1558
+ };
1559
+ };
1560
+ const safeParseAsync$1 = /* @__PURE__ */ _safeParseAsync($ZodRealError);
1561
+ const _encode = (_Err) => (schema, value, _ctx) => {
1562
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
1563
+ return _parse(_Err)(schema, value, ctx);
1564
+ };
1565
+ const encode$1 = /* @__PURE__ */ _encode($ZodRealError);
1566
+ const _decode = (_Err) => (schema, value, _ctx) => {
1567
+ return _parse(_Err)(schema, value, _ctx);
1568
+ };
1569
+ const decode$1 = /* @__PURE__ */ _decode($ZodRealError);
1570
+ const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
1571
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
1572
+ return _parseAsync(_Err)(schema, value, ctx);
1573
+ };
1574
+ const encodeAsync$1 = /* @__PURE__ */ _encodeAsync($ZodRealError);
1575
+ const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
1576
+ return _parseAsync(_Err)(schema, value, _ctx);
1577
+ };
1578
+ const decodeAsync$1 = /* @__PURE__ */ _decodeAsync($ZodRealError);
1579
+ const _safeEncode = (_Err) => (schema, value, _ctx) => {
1580
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
1581
+ return _safeParse(_Err)(schema, value, ctx);
1582
+ };
1583
+ const safeEncode$1 = /* @__PURE__ */ _safeEncode($ZodRealError);
1584
+ const _safeDecode = (_Err) => (schema, value, _ctx) => {
1585
+ return _safeParse(_Err)(schema, value, _ctx);
1586
+ };
1587
+ const safeDecode$1 = /* @__PURE__ */ _safeDecode($ZodRealError);
1588
+ const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
1589
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
1590
+ return _safeParseAsync(_Err)(schema, value, ctx);
1591
+ };
1592
+ const safeEncodeAsync$1 = /* @__PURE__ */ _safeEncodeAsync($ZodRealError);
1593
+ const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
1594
+ return _safeParseAsync(_Err)(schema, value, _ctx);
1595
+ };
1596
+ const safeDecodeAsync$1 = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
1597
+
1598
+ //#endregion
1599
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/checks.js
1600
+ const $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
1601
+ var _a;
1602
+ inst._zod ?? (inst._zod = {});
1603
+ inst._zod.def = def;
1604
+ (_a = inst._zod).onattach ?? (_a.onattach = []);
1605
+ });
1606
+ const $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
1607
+ var _a;
1608
+ $ZodCheck.init(inst, def);
1609
+ (_a = inst._zod.def).when ?? (_a.when = (payload) => {
1610
+ const val = payload.value;
1611
+ return !nullish(val) && val.length !== void 0;
1612
+ });
1613
+ inst._zod.onattach.push((inst) => {
1614
+ const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
1615
+ if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
1616
+ });
1617
+ inst._zod.check = (payload) => {
1618
+ const input = payload.value;
1619
+ if (input.length <= def.maximum) return;
1620
+ const origin = getLengthableOrigin(input);
1621
+ payload.issues.push({
1622
+ origin,
1623
+ code: "too_big",
1624
+ maximum: def.maximum,
1625
+ inclusive: true,
1626
+ input,
1627
+ inst,
1628
+ continue: !def.abort
1629
+ });
1630
+ };
1631
+ });
1632
+ const $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
1633
+ var _a;
1634
+ $ZodCheck.init(inst, def);
1635
+ (_a = inst._zod.def).when ?? (_a.when = (payload) => {
1636
+ const val = payload.value;
1637
+ return !nullish(val) && val.length !== void 0;
1638
+ });
1639
+ inst._zod.onattach.push((inst) => {
1640
+ const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
1641
+ if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
1642
+ });
1643
+ inst._zod.check = (payload) => {
1644
+ const input = payload.value;
1645
+ if (input.length >= def.minimum) return;
1646
+ const origin = getLengthableOrigin(input);
1647
+ payload.issues.push({
1648
+ origin,
1649
+ code: "too_small",
1650
+ minimum: def.minimum,
1651
+ inclusive: true,
1652
+ input,
1653
+ inst,
1654
+ continue: !def.abort
1655
+ });
1656
+ };
1657
+ });
1658
+ const $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
1659
+ var _a;
1660
+ $ZodCheck.init(inst, def);
1661
+ (_a = inst._zod.def).when ?? (_a.when = (payload) => {
1662
+ const val = payload.value;
1663
+ return !nullish(val) && val.length !== void 0;
1664
+ });
1665
+ inst._zod.onattach.push((inst) => {
1666
+ const bag = inst._zod.bag;
1667
+ bag.minimum = def.length;
1668
+ bag.maximum = def.length;
1669
+ bag.length = def.length;
1670
+ });
1671
+ inst._zod.check = (payload) => {
1672
+ const input = payload.value;
1673
+ const length = input.length;
1674
+ if (length === def.length) return;
1675
+ const origin = getLengthableOrigin(input);
1676
+ const tooBig = length > def.length;
1677
+ payload.issues.push({
1678
+ origin,
1679
+ ...tooBig ? {
1680
+ code: "too_big",
1681
+ maximum: def.length
1682
+ } : {
1683
+ code: "too_small",
1684
+ minimum: def.length
1685
+ },
1686
+ inclusive: true,
1687
+ exact: true,
1688
+ input: payload.value,
1689
+ inst,
1690
+ continue: !def.abort
1691
+ });
1692
+ };
1693
+ });
1694
+ const $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (inst, def) => {
1695
+ $ZodCheck.init(inst, def);
1696
+ inst._zod.check = (payload) => {
1697
+ payload.value = def.tx(payload.value);
1698
+ };
1699
+ });
1700
+
1701
+ //#endregion
1702
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/doc.js
1703
+ var Doc = class {
1704
+ constructor(args = []) {
1705
+ this.content = [];
1706
+ this.indent = 0;
1707
+ if (this) this.args = args;
1708
+ }
1709
+ indented(fn) {
1710
+ this.indent += 1;
1711
+ fn(this);
1712
+ this.indent -= 1;
1713
+ }
1714
+ write(arg) {
1715
+ if (typeof arg === "function") {
1716
+ arg(this, { execution: "sync" });
1717
+ arg(this, { execution: "async" });
1718
+ return;
1719
+ }
1720
+ const lines = arg.split("\n").filter((x) => x);
1721
+ const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
1722
+ const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
1723
+ for (const line of dedented) this.content.push(line);
1724
+ }
1725
+ compile() {
1726
+ const F = Function;
1727
+ const args = this?.args;
1728
+ const lines = [...(this?.content ?? [``]).map((x) => ` ${x}`)];
1729
+ return new F(...args, lines.join("\n"));
1730
+ }
1731
+ };
1732
+
1733
+ //#endregion
1734
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/versions.js
1735
+ const version = {
1736
+ major: 4,
1737
+ minor: 3,
1738
+ patch: 6
1739
+ };
1740
+
1741
+ //#endregion
1742
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/schemas.js
1743
+ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
1744
+ var _a;
1745
+ inst ?? (inst = {});
1746
+ inst._zod.def = def;
1747
+ inst._zod.bag = inst._zod.bag || {};
1748
+ inst._zod.version = version;
1749
+ const checks = [...inst._zod.def.checks ?? []];
1750
+ if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
1751
+ for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
1752
+ if (checks.length === 0) {
1753
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
1754
+ inst._zod.deferred?.push(() => {
1755
+ inst._zod.run = inst._zod.parse;
1756
+ });
1757
+ } else {
1758
+ const runChecks = (payload, checks, ctx) => {
1759
+ let isAborted = aborted(payload);
1760
+ let asyncResult;
1761
+ for (const ch of checks) {
1762
+ if (ch._zod.def.when) {
1763
+ if (!ch._zod.def.when(payload)) continue;
1764
+ } else if (isAborted) continue;
1765
+ const currLen = payload.issues.length;
1766
+ const _ = ch._zod.check(payload);
1767
+ if (_ instanceof Promise && ctx?.async === false) throw new $ZodAsyncError();
1768
+ if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
1769
+ await _;
1770
+ if (payload.issues.length === currLen) return;
1771
+ if (!isAborted) isAborted = aborted(payload, currLen);
1772
+ });
1773
+ else {
1774
+ if (payload.issues.length === currLen) continue;
1775
+ if (!isAborted) isAborted = aborted(payload, currLen);
1776
+ }
1777
+ }
1778
+ if (asyncResult) return asyncResult.then(() => {
1779
+ return payload;
1780
+ });
1781
+ return payload;
1782
+ };
1783
+ const handleCanaryResult = (canary, payload, ctx) => {
1784
+ if (aborted(canary)) {
1785
+ canary.aborted = true;
1786
+ return canary;
1787
+ }
1788
+ const checkResult = runChecks(payload, checks, ctx);
1789
+ if (checkResult instanceof Promise) {
1790
+ if (ctx.async === false) throw new $ZodAsyncError();
1791
+ return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
1792
+ }
1793
+ return inst._zod.parse(checkResult, ctx);
1794
+ };
1795
+ inst._zod.run = (payload, ctx) => {
1796
+ if (ctx.skipChecks) return inst._zod.parse(payload, ctx);
1797
+ if (ctx.direction === "backward") {
1798
+ const canary = inst._zod.parse({
1799
+ value: payload.value,
1800
+ issues: []
1801
+ }, {
1802
+ ...ctx,
1803
+ skipChecks: true
1804
+ });
1805
+ if (canary instanceof Promise) return canary.then((canary) => {
1806
+ return handleCanaryResult(canary, payload, ctx);
1807
+ });
1808
+ return handleCanaryResult(canary, payload, ctx);
1809
+ }
1810
+ const result = inst._zod.parse(payload, ctx);
1811
+ if (result instanceof Promise) {
1812
+ if (ctx.async === false) throw new $ZodAsyncError();
1813
+ return result.then((result) => runChecks(result, checks, ctx));
1814
+ }
1815
+ return runChecks(result, checks, ctx);
1816
+ };
1817
+ }
1818
+ defineLazy(inst, "~standard", () => ({
1819
+ validate: (value) => {
1820
+ try {
1821
+ const r = safeParse$1(inst, value);
1822
+ return r.success ? { value: r.data } : { issues: r.error?.issues };
1823
+ } catch (_) {
1824
+ return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
1825
+ }
1826
+ },
1827
+ vendor: "zod",
1828
+ version: 1
1829
+ }));
1830
+ });
1831
+ const $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
1832
+ $ZodType.init(inst, def);
1833
+ inst._zod.parse = (payload) => payload;
1834
+ });
1835
+ const $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
1836
+ $ZodType.init(inst, def);
1837
+ inst._zod.parse = (payload, _ctx) => {
1838
+ payload.issues.push({
1839
+ expected: "never",
1840
+ code: "invalid_type",
1841
+ input: payload.value,
1842
+ inst
1843
+ });
1844
+ return payload;
1845
+ };
1846
+ });
1847
+ function handleArrayResult(result, final, index) {
1848
+ if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
1849
+ final.value[index] = result.value;
1850
+ }
1851
+ const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
1852
+ $ZodType.init(inst, def);
1853
+ inst._zod.parse = (payload, ctx) => {
1854
+ const input = payload.value;
1855
+ if (!Array.isArray(input)) {
1856
+ payload.issues.push({
1857
+ expected: "array",
1858
+ code: "invalid_type",
1859
+ input,
1860
+ inst
1861
+ });
1862
+ return payload;
1863
+ }
1864
+ payload.value = Array(input.length);
1865
+ const proms = [];
1866
+ for (let i = 0; i < input.length; i++) {
1867
+ const item = input[i];
1868
+ const result = def.element._zod.run({
1869
+ value: item,
1870
+ issues: []
1871
+ }, ctx);
1872
+ if (result instanceof Promise) proms.push(result.then((result) => handleArrayResult(result, payload, i)));
1873
+ else handleArrayResult(result, payload, i);
1874
+ }
1875
+ if (proms.length) return Promise.all(proms).then(() => payload);
1876
+ return payload;
1877
+ };
1878
+ });
1879
+ function handlePropertyResult(result, final, key, input, isOptionalOut) {
1880
+ if (result.issues.length) {
1881
+ if (isOptionalOut && !(key in input)) return;
1882
+ final.issues.push(...prefixIssues(key, result.issues));
1883
+ }
1884
+ if (result.value === void 0) {
1885
+ if (key in input) final.value[key] = void 0;
1886
+ } else final.value[key] = result.value;
1887
+ }
1888
+ function normalizeDef(def) {
1889
+ const keys = Object.keys(def.shape);
1890
+ for (const k of keys) if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
1891
+ const okeys = optionalKeys(def.shape);
1892
+ return {
1893
+ ...def,
1894
+ keys,
1895
+ keySet: new Set(keys),
1896
+ numKeys: keys.length,
1897
+ optionalKeys: new Set(okeys)
1898
+ };
1899
+ }
1900
+ function handleCatchall(proms, input, payload, ctx, def, inst) {
1901
+ const unrecognized = [];
1902
+ const keySet = def.keySet;
1903
+ const _catchall = def.catchall._zod;
1904
+ const t = _catchall.def.type;
1905
+ const isOptionalOut = _catchall.optout === "optional";
1906
+ for (const key in input) {
1907
+ if (keySet.has(key)) continue;
1908
+ if (t === "never") {
1909
+ unrecognized.push(key);
1910
+ continue;
1911
+ }
1912
+ const r = _catchall.run({
1913
+ value: input[key],
1914
+ issues: []
1915
+ }, ctx);
1916
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
1917
+ else handlePropertyResult(r, payload, key, input, isOptionalOut);
1918
+ }
1919
+ if (unrecognized.length) payload.issues.push({
1920
+ code: "unrecognized_keys",
1921
+ keys: unrecognized,
1922
+ input,
1923
+ inst
1924
+ });
1925
+ if (!proms.length) return payload;
1926
+ return Promise.all(proms).then(() => {
1927
+ return payload;
1928
+ });
1929
+ }
1930
+ const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
1931
+ $ZodType.init(inst, def);
1932
+ if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) {
1933
+ const sh = def.shape;
1934
+ Object.defineProperty(def, "shape", { get: () => {
1935
+ const newSh = { ...sh };
1936
+ Object.defineProperty(def, "shape", { value: newSh });
1937
+ return newSh;
1938
+ } });
1939
+ }
1940
+ const _normalized = cached(() => normalizeDef(def));
1941
+ defineLazy(inst._zod, "propValues", () => {
1942
+ const shape = def.shape;
1943
+ const propValues = {};
1944
+ for (const key in shape) {
1945
+ const field = shape[key]._zod;
1946
+ if (field.values) {
1947
+ propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
1948
+ for (const v of field.values) propValues[key].add(v);
1949
+ }
1950
+ }
1951
+ return propValues;
1952
+ });
1953
+ const isObject$2 = isObject;
1954
+ const catchall = def.catchall;
1955
+ let value;
1956
+ inst._zod.parse = (payload, ctx) => {
1957
+ value ?? (value = _normalized.value);
1958
+ const input = payload.value;
1959
+ if (!isObject$2(input)) {
1960
+ payload.issues.push({
1961
+ expected: "object",
1962
+ code: "invalid_type",
1963
+ input,
1964
+ inst
1965
+ });
1966
+ return payload;
1967
+ }
1968
+ payload.value = {};
1969
+ const proms = [];
1970
+ const shape = value.shape;
1971
+ for (const key of value.keys) {
1972
+ const el = shape[key];
1973
+ const isOptionalOut = el._zod.optout === "optional";
1974
+ const r = el._zod.run({
1975
+ value: input[key],
1976
+ issues: []
1977
+ }, ctx);
1978
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
1979
+ else handlePropertyResult(r, payload, key, input, isOptionalOut);
1980
+ }
1981
+ if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
1982
+ return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
1983
+ };
1984
+ });
1985
+ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
1986
+ $ZodObject.init(inst, def);
1987
+ const superParse = inst._zod.parse;
1988
+ const _normalized = cached(() => normalizeDef(def));
1989
+ const generateFastpass = (shape) => {
1990
+ const doc = new Doc([
1991
+ "shape",
1992
+ "payload",
1993
+ "ctx"
1994
+ ]);
1995
+ const normalized = _normalized.value;
1996
+ const parseStr = (key) => {
1997
+ const k = esc(key);
1998
+ return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
1999
+ };
2000
+ doc.write(`const input = payload.value;`);
2001
+ const ids = Object.create(null);
2002
+ let counter = 0;
2003
+ for (const key of normalized.keys) ids[key] = `key_${counter++}`;
2004
+ doc.write(`const newResult = {};`);
2005
+ for (const key of normalized.keys) {
2006
+ const id = ids[key];
2007
+ const k = esc(key);
2008
+ const isOptionalOut = shape[key]?._zod?.optout === "optional";
2009
+ doc.write(`const ${id} = ${parseStr(key)};`);
2010
+ if (isOptionalOut) doc.write(`
2011
+ if (${id}.issues.length) {
2012
+ if (${k} in input) {
2013
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
2014
+ ...iss,
2015
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
2016
+ })));
2017
+ }
2018
+ }
2019
+
2020
+ if (${id}.value === undefined) {
2021
+ if (${k} in input) {
2022
+ newResult[${k}] = undefined;
2023
+ }
2024
+ } else {
2025
+ newResult[${k}] = ${id}.value;
2026
+ }
2027
+
2028
+ `);
2029
+ else doc.write(`
2030
+ if (${id}.issues.length) {
2031
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
2032
+ ...iss,
2033
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
2034
+ })));
2035
+ }
2036
+
2037
+ if (${id}.value === undefined) {
2038
+ if (${k} in input) {
2039
+ newResult[${k}] = undefined;
2040
+ }
2041
+ } else {
2042
+ newResult[${k}] = ${id}.value;
2043
+ }
2044
+
2045
+ `);
2046
+ }
2047
+ doc.write(`payload.value = newResult;`);
2048
+ doc.write(`return payload;`);
2049
+ const fn = doc.compile();
2050
+ return (payload, ctx) => fn(shape, payload, ctx);
2051
+ };
2052
+ let fastpass;
2053
+ const isObject$1 = isObject;
2054
+ const jit = !globalConfig.jitless;
2055
+ const allowsEval$1 = allowsEval;
2056
+ const fastEnabled = jit && allowsEval$1.value;
2057
+ const catchall = def.catchall;
2058
+ let value;
2059
+ inst._zod.parse = (payload, ctx) => {
2060
+ value ?? (value = _normalized.value);
2061
+ const input = payload.value;
2062
+ if (!isObject$1(input)) {
2063
+ payload.issues.push({
2064
+ expected: "object",
2065
+ code: "invalid_type",
2066
+ input,
2067
+ inst
2068
+ });
2069
+ return payload;
2070
+ }
2071
+ if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
2072
+ if (!fastpass) fastpass = generateFastpass(def.shape);
2073
+ payload = fastpass(payload, ctx);
2074
+ if (!catchall) return payload;
2075
+ return handleCatchall([], input, payload, ctx, value, inst);
2076
+ }
2077
+ return superParse(payload, ctx);
2078
+ };
2079
+ });
2080
+ function handleUnionResults(results, final, inst, ctx) {
2081
+ for (const result of results) if (result.issues.length === 0) {
2082
+ final.value = result.value;
2083
+ return final;
2084
+ }
2085
+ const nonaborted = results.filter((r) => !aborted(r));
2086
+ if (nonaborted.length === 1) {
2087
+ final.value = nonaborted[0].value;
2088
+ return nonaborted[0];
2089
+ }
2090
+ final.issues.push({
2091
+ code: "invalid_union",
2092
+ input: final.value,
2093
+ inst,
2094
+ errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
2095
+ });
2096
+ return final;
2097
+ }
2098
+ const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
2099
+ $ZodType.init(inst, def);
2100
+ defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
2101
+ defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
2102
+ defineLazy(inst._zod, "values", () => {
2103
+ if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
2104
+ });
2105
+ defineLazy(inst._zod, "pattern", () => {
2106
+ if (def.options.every((o) => o._zod.pattern)) {
2107
+ const patterns = def.options.map((o) => o._zod.pattern);
2108
+ return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
2109
+ }
2110
+ });
2111
+ const single = def.options.length === 1;
2112
+ const first = def.options[0]._zod.run;
2113
+ inst._zod.parse = (payload, ctx) => {
2114
+ if (single) return first(payload, ctx);
2115
+ let async = false;
2116
+ const results = [];
2117
+ for (const option of def.options) {
2118
+ const result = option._zod.run({
2119
+ value: payload.value,
2120
+ issues: []
2121
+ }, ctx);
2122
+ if (result instanceof Promise) {
2123
+ results.push(result);
2124
+ async = true;
2125
+ } else {
2126
+ if (result.issues.length === 0) return result;
2127
+ results.push(result);
2128
+ }
2129
+ }
2130
+ if (!async) return handleUnionResults(results, payload, inst, ctx);
2131
+ return Promise.all(results).then((results) => {
2132
+ return handleUnionResults(results, payload, inst, ctx);
2133
+ });
2134
+ };
2135
+ });
2136
+ const $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
2137
+ $ZodType.init(inst, def);
2138
+ inst._zod.parse = (payload, ctx) => {
2139
+ const input = payload.value;
2140
+ const left = def.left._zod.run({
2141
+ value: input,
2142
+ issues: []
2143
+ }, ctx);
2144
+ const right = def.right._zod.run({
2145
+ value: input,
2146
+ issues: []
2147
+ }, ctx);
2148
+ if (left instanceof Promise || right instanceof Promise) return Promise.all([left, right]).then(([left, right]) => {
2149
+ return handleIntersectionResults(payload, left, right);
2150
+ });
2151
+ return handleIntersectionResults(payload, left, right);
2152
+ };
2153
+ });
2154
+ function mergeValues(a, b) {
2155
+ if (a === b) return {
2156
+ valid: true,
2157
+ data: a
2158
+ };
2159
+ if (a instanceof Date && b instanceof Date && +a === +b) return {
2160
+ valid: true,
2161
+ data: a
2162
+ };
2163
+ if (isPlainObject(a) && isPlainObject(b)) {
2164
+ const bKeys = Object.keys(b);
2165
+ const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
2166
+ const newObj = {
2167
+ ...a,
2168
+ ...b
2169
+ };
2170
+ for (const key of sharedKeys) {
2171
+ const sharedValue = mergeValues(a[key], b[key]);
2172
+ if (!sharedValue.valid) return {
2173
+ valid: false,
2174
+ mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
2175
+ };
2176
+ newObj[key] = sharedValue.data;
2177
+ }
2178
+ return {
2179
+ valid: true,
2180
+ data: newObj
2181
+ };
2182
+ }
2183
+ if (Array.isArray(a) && Array.isArray(b)) {
2184
+ if (a.length !== b.length) return {
2185
+ valid: false,
2186
+ mergeErrorPath: []
2187
+ };
2188
+ const newArray = [];
2189
+ for (let index = 0; index < a.length; index++) {
2190
+ const itemA = a[index];
2191
+ const itemB = b[index];
2192
+ const sharedValue = mergeValues(itemA, itemB);
2193
+ if (!sharedValue.valid) return {
2194
+ valid: false,
2195
+ mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
2196
+ };
2197
+ newArray.push(sharedValue.data);
2198
+ }
2199
+ return {
2200
+ valid: true,
2201
+ data: newArray
2202
+ };
2203
+ }
2204
+ return {
2205
+ valid: false,
2206
+ mergeErrorPath: []
2207
+ };
2208
+ }
2209
+ function handleIntersectionResults(result, left, right) {
2210
+ const unrecKeys = /* @__PURE__ */ new Map();
2211
+ let unrecIssue;
2212
+ for (const iss of left.issues) if (iss.code === "unrecognized_keys") {
2213
+ unrecIssue ?? (unrecIssue = iss);
2214
+ for (const k of iss.keys) {
2215
+ if (!unrecKeys.has(k)) unrecKeys.set(k, {});
2216
+ unrecKeys.get(k).l = true;
2217
+ }
2218
+ } else result.issues.push(iss);
2219
+ for (const iss of right.issues) if (iss.code === "unrecognized_keys") for (const k of iss.keys) {
2220
+ if (!unrecKeys.has(k)) unrecKeys.set(k, {});
2221
+ unrecKeys.get(k).r = true;
2222
+ }
2223
+ else result.issues.push(iss);
2224
+ const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
2225
+ if (bothKeys.length && unrecIssue) result.issues.push({
2226
+ ...unrecIssue,
2227
+ keys: bothKeys
2228
+ });
2229
+ if (aborted(result)) return result;
2230
+ const merged = mergeValues(left.value, right.value);
2231
+ if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
2232
+ result.value = merged.data;
2233
+ return result;
2234
+ }
2235
+ const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
2236
+ $ZodType.init(inst, def);
2237
+ const values = getEnumValues(def.entries);
2238
+ const valuesSet = new Set(values);
2239
+ inst._zod.values = valuesSet;
2240
+ inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
2241
+ inst._zod.parse = (payload, _ctx) => {
2242
+ const input = payload.value;
2243
+ if (valuesSet.has(input)) return payload;
2244
+ payload.issues.push({
2245
+ code: "invalid_value",
2246
+ values,
2247
+ input,
2248
+ inst
2249
+ });
2250
+ return payload;
2251
+ };
2252
+ });
2253
+ const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
2254
+ $ZodType.init(inst, def);
2255
+ inst._zod.parse = (payload, ctx) => {
2256
+ if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
2257
+ const _out = def.transform(payload.value, payload);
2258
+ if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
2259
+ payload.value = output;
2260
+ return payload;
2261
+ });
2262
+ if (_out instanceof Promise) throw new $ZodAsyncError();
2263
+ payload.value = _out;
2264
+ return payload;
2265
+ };
2266
+ });
2267
+ function handleOptionalResult(result, input) {
2268
+ if (result.issues.length && input === void 0) return {
2269
+ issues: [],
2270
+ value: void 0
2271
+ };
2272
+ return result;
2273
+ }
2274
+ const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
2275
+ $ZodType.init(inst, def);
2276
+ inst._zod.optin = "optional";
2277
+ inst._zod.optout = "optional";
2278
+ defineLazy(inst._zod, "values", () => {
2279
+ return def.innerType._zod.values ? new Set([...def.innerType._zod.values, void 0]) : void 0;
2280
+ });
2281
+ defineLazy(inst._zod, "pattern", () => {
2282
+ const pattern = def.innerType._zod.pattern;
2283
+ return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
2284
+ });
2285
+ inst._zod.parse = (payload, ctx) => {
2286
+ if (def.innerType._zod.optin === "optional") {
2287
+ const result = def.innerType._zod.run(payload, ctx);
2288
+ if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, payload.value));
2289
+ return handleOptionalResult(result, payload.value);
2290
+ }
2291
+ if (payload.value === void 0) return payload;
2292
+ return def.innerType._zod.run(payload, ctx);
2293
+ };
2294
+ });
2295
+ const $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
2296
+ $ZodOptional.init(inst, def);
2297
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2298
+ defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
2299
+ inst._zod.parse = (payload, ctx) => {
2300
+ return def.innerType._zod.run(payload, ctx);
2301
+ };
2302
+ });
2303
+ const $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
2304
+ $ZodType.init(inst, def);
2305
+ defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
2306
+ defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2307
+ defineLazy(inst._zod, "pattern", () => {
2308
+ const pattern = def.innerType._zod.pattern;
2309
+ return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
2310
+ });
2311
+ defineLazy(inst._zod, "values", () => {
2312
+ return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : void 0;
2313
+ });
2314
+ inst._zod.parse = (payload, ctx) => {
2315
+ if (payload.value === null) return payload;
2316
+ return def.innerType._zod.run(payload, ctx);
2317
+ };
2318
+ });
2319
+ const $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
2320
+ $ZodType.init(inst, def);
2321
+ inst._zod.optin = "optional";
2322
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2323
+ inst._zod.parse = (payload, ctx) => {
2324
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2325
+ if (payload.value === void 0) {
2326
+ payload.value = def.defaultValue;
2327
+ /**
2328
+ * $ZodDefault returns the default value immediately in forward direction.
2329
+ * It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
2330
+ return payload;
2331
+ }
2332
+ const result = def.innerType._zod.run(payload, ctx);
2333
+ if (result instanceof Promise) return result.then((result) => handleDefaultResult(result, def));
2334
+ return handleDefaultResult(result, def);
2335
+ };
2336
+ });
2337
+ function handleDefaultResult(payload, def) {
2338
+ if (payload.value === void 0) payload.value = def.defaultValue;
2339
+ return payload;
2340
+ }
2341
+ const $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
2342
+ $ZodType.init(inst, def);
2343
+ inst._zod.optin = "optional";
2344
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2345
+ inst._zod.parse = (payload, ctx) => {
2346
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2347
+ if (payload.value === void 0) payload.value = def.defaultValue;
2348
+ return def.innerType._zod.run(payload, ctx);
2349
+ };
2350
+ });
2351
+ const $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
2352
+ $ZodType.init(inst, def);
2353
+ defineLazy(inst._zod, "values", () => {
2354
+ const v = def.innerType._zod.values;
2355
+ return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
2356
+ });
2357
+ inst._zod.parse = (payload, ctx) => {
2358
+ const result = def.innerType._zod.run(payload, ctx);
2359
+ if (result instanceof Promise) return result.then((result) => handleNonOptionalResult(result, inst));
2360
+ return handleNonOptionalResult(result, inst);
2361
+ };
2362
+ });
2363
+ function handleNonOptionalResult(payload, inst) {
2364
+ if (!payload.issues.length && payload.value === void 0) payload.issues.push({
2365
+ code: "invalid_type",
2366
+ expected: "nonoptional",
2367
+ input: payload.value,
2368
+ inst
2369
+ });
2370
+ return payload;
2371
+ }
2372
+ const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
2373
+ $ZodType.init(inst, def);
2374
+ defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
2375
+ defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2376
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2377
+ inst._zod.parse = (payload, ctx) => {
2378
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2379
+ const result = def.innerType._zod.run(payload, ctx);
2380
+ if (result instanceof Promise) return result.then((result) => {
2381
+ payload.value = result.value;
2382
+ if (result.issues.length) {
2383
+ payload.value = def.catchValue({
2384
+ ...payload,
2385
+ error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2386
+ input: payload.value
2387
+ });
2388
+ payload.issues = [];
2389
+ }
2390
+ return payload;
2391
+ });
2392
+ payload.value = result.value;
2393
+ if (result.issues.length) {
2394
+ payload.value = def.catchValue({
2395
+ ...payload,
2396
+ error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2397
+ input: payload.value
2398
+ });
2399
+ payload.issues = [];
2400
+ }
2401
+ return payload;
2402
+ };
2403
+ });
2404
+ const $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
2405
+ $ZodType.init(inst, def);
2406
+ defineLazy(inst._zod, "values", () => def.in._zod.values);
2407
+ defineLazy(inst._zod, "optin", () => def.in._zod.optin);
2408
+ defineLazy(inst._zod, "optout", () => def.out._zod.optout);
2409
+ defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
2410
+ inst._zod.parse = (payload, ctx) => {
2411
+ if (ctx.direction === "backward") {
2412
+ const right = def.out._zod.run(payload, ctx);
2413
+ if (right instanceof Promise) return right.then((right) => handlePipeResult(right, def.in, ctx));
2414
+ return handlePipeResult(right, def.in, ctx);
2415
+ }
2416
+ const left = def.in._zod.run(payload, ctx);
2417
+ if (left instanceof Promise) return left.then((left) => handlePipeResult(left, def.out, ctx));
2418
+ return handlePipeResult(left, def.out, ctx);
2419
+ };
2420
+ });
2421
+ function handlePipeResult(left, next, ctx) {
2422
+ if (left.issues.length) {
2423
+ left.aborted = true;
2424
+ return left;
2425
+ }
2426
+ return next._zod.run({
2427
+ value: left.value,
2428
+ issues: left.issues
2429
+ }, ctx);
2430
+ }
2431
+ const $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
2432
+ $ZodType.init(inst, def);
2433
+ defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
2434
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2435
+ defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
2436
+ defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
2437
+ inst._zod.parse = (payload, ctx) => {
2438
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2439
+ const result = def.innerType._zod.run(payload, ctx);
2440
+ if (result instanceof Promise) return result.then(handleReadonlyResult);
2441
+ return handleReadonlyResult(result);
2442
+ };
2443
+ });
2444
+ function handleReadonlyResult(payload) {
2445
+ payload.value = Object.freeze(payload.value);
2446
+ return payload;
2447
+ }
2448
+ const $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
2449
+ $ZodCheck.init(inst, def);
2450
+ $ZodType.init(inst, def);
2451
+ inst._zod.parse = (payload, _) => {
2452
+ return payload;
2453
+ };
2454
+ inst._zod.check = (payload) => {
2455
+ const input = payload.value;
2456
+ const r = def.fn(input);
2457
+ if (r instanceof Promise) return r.then((r) => handleRefineResult(r, payload, input, inst));
2458
+ handleRefineResult(r, payload, input, inst);
2459
+ };
2460
+ });
2461
+ function handleRefineResult(result, payload, input, inst) {
2462
+ if (!result) {
2463
+ const _iss = {
2464
+ code: "custom",
2465
+ input,
2466
+ inst,
2467
+ path: [...inst._zod.def.path ?? []],
2468
+ continue: !inst._zod.def.abort
2469
+ };
2470
+ if (inst._zod.def.params) _iss.params = inst._zod.def.params;
2471
+ payload.issues.push(issue(_iss));
2472
+ }
2473
+ }
2474
+
2475
+ //#endregion
2476
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/registries.js
2477
+ var _a;
2478
+ var $ZodRegistry = class {
2479
+ constructor() {
2480
+ this._map = /* @__PURE__ */ new WeakMap();
2481
+ this._idmap = /* @__PURE__ */ new Map();
2482
+ }
2483
+ add(schema, ..._meta) {
2484
+ const meta = _meta[0];
2485
+ this._map.set(schema, meta);
2486
+ if (meta && typeof meta === "object" && "id" in meta) this._idmap.set(meta.id, schema);
2487
+ return this;
2488
+ }
2489
+ clear() {
2490
+ this._map = /* @__PURE__ */ new WeakMap();
2491
+ this._idmap = /* @__PURE__ */ new Map();
2492
+ return this;
2493
+ }
2494
+ remove(schema) {
2495
+ const meta = this._map.get(schema);
2496
+ if (meta && typeof meta === "object" && "id" in meta) this._idmap.delete(meta.id);
2497
+ this._map.delete(schema);
2498
+ return this;
2499
+ }
2500
+ get(schema) {
2501
+ const p = schema._zod.parent;
2502
+ if (p) {
2503
+ const pm = { ...this.get(p) ?? {} };
2504
+ delete pm.id;
2505
+ const f = {
2506
+ ...pm,
2507
+ ...this._map.get(schema)
2508
+ };
2509
+ return Object.keys(f).length ? f : void 0;
2510
+ }
2511
+ return this._map.get(schema);
2512
+ }
2513
+ has(schema) {
2514
+ return this._map.has(schema);
2515
+ }
2516
+ };
2517
+ function registry() {
2518
+ return new $ZodRegistry();
2519
+ }
2520
+ (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
2521
+ const globalRegistry = globalThis.__zod_globalRegistry;
2522
+
2523
+ //#endregion
2524
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/api.js
2525
+ /* @__NO_SIDE_EFFECTS__ */
2526
+ function _unknown(Class) {
2527
+ return new Class({ type: "unknown" });
2528
+ }
2529
+ /* @__NO_SIDE_EFFECTS__ */
2530
+ function _never(Class, params) {
2531
+ return new Class({
2532
+ type: "never",
2533
+ ...normalizeParams(params)
2534
+ });
2535
+ }
2536
+ /* @__NO_SIDE_EFFECTS__ */
2537
+ function _maxLength(maximum, params) {
2538
+ return new $ZodCheckMaxLength({
2539
+ check: "max_length",
2540
+ ...normalizeParams(params),
2541
+ maximum
2542
+ });
2543
+ }
2544
+ /* @__NO_SIDE_EFFECTS__ */
2545
+ function _minLength(minimum, params) {
2546
+ return new $ZodCheckMinLength({
2547
+ check: "min_length",
2548
+ ...normalizeParams(params),
2549
+ minimum
2550
+ });
2551
+ }
2552
+ /* @__NO_SIDE_EFFECTS__ */
2553
+ function _length(length, params) {
2554
+ return new $ZodCheckLengthEquals({
2555
+ check: "length_equals",
2556
+ ...normalizeParams(params),
2557
+ length
2558
+ });
2559
+ }
2560
+ /* @__NO_SIDE_EFFECTS__ */
2561
+ function _overwrite(tx) {
2562
+ return new $ZodCheckOverwrite({
2563
+ check: "overwrite",
2564
+ tx
2565
+ });
2566
+ }
2567
+ /* @__NO_SIDE_EFFECTS__ */
2568
+ function _array(Class, element, params) {
2569
+ return new Class({
2570
+ type: "array",
2571
+ element,
2572
+ ...normalizeParams(params)
2573
+ });
2574
+ }
2575
+ /* @__NO_SIDE_EFFECTS__ */
2576
+ function _refine(Class, fn, _params) {
2577
+ return new Class({
2578
+ type: "custom",
2579
+ check: "custom",
2580
+ fn,
2581
+ ...normalizeParams(_params)
2582
+ });
2583
+ }
2584
+ /* @__NO_SIDE_EFFECTS__ */
2585
+ function _superRefine(fn) {
2586
+ const ch = /* @__PURE__ */ _check((payload) => {
2587
+ payload.addIssue = (issue$2) => {
2588
+ if (typeof issue$2 === "string") payload.issues.push(issue(issue$2, payload.value, ch._zod.def));
2589
+ else {
2590
+ const _issue = issue$2;
2591
+ if (_issue.fatal) _issue.continue = false;
2592
+ _issue.code ?? (_issue.code = "custom");
2593
+ _issue.input ?? (_issue.input = payload.value);
2594
+ _issue.inst ?? (_issue.inst = ch);
2595
+ _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
2596
+ payload.issues.push(issue(_issue));
2597
+ }
2598
+ };
2599
+ return fn(payload.value, payload);
2600
+ });
2601
+ return ch;
2602
+ }
2603
+ /* @__NO_SIDE_EFFECTS__ */
2604
+ function _check(fn, params) {
2605
+ const ch = new $ZodCheck({
2606
+ check: "custom",
2607
+ ...normalizeParams(params)
2608
+ });
2609
+ ch._zod.check = fn;
2610
+ return ch;
2611
+ }
2612
+ /* @__NO_SIDE_EFFECTS__ */
2613
+ function describe$1(description) {
2614
+ const ch = new $ZodCheck({ check: "describe" });
2615
+ ch._zod.onattach = [(inst) => {
2616
+ const existing = globalRegistry.get(inst) ?? {};
2617
+ globalRegistry.add(inst, {
2618
+ ...existing,
2619
+ description
2620
+ });
2621
+ }];
2622
+ ch._zod.check = () => {};
2623
+ return ch;
2624
+ }
2625
+ /* @__NO_SIDE_EFFECTS__ */
2626
+ function meta$1(metadata) {
2627
+ const ch = new $ZodCheck({ check: "meta" });
2628
+ ch._zod.onattach = [(inst) => {
2629
+ const existing = globalRegistry.get(inst) ?? {};
2630
+ globalRegistry.add(inst, {
2631
+ ...existing,
2632
+ ...metadata
2633
+ });
2634
+ }];
2635
+ ch._zod.check = () => {};
2636
+ return ch;
2637
+ }
2638
+
2639
+ //#endregion
2640
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/to-json-schema.js
2641
+ function initializeContext(params) {
2642
+ let target = params?.target ?? "draft-2020-12";
2643
+ if (target === "draft-4") target = "draft-04";
2644
+ if (target === "draft-7") target = "draft-07";
2645
+ return {
2646
+ processors: params.processors ?? {},
2647
+ metadataRegistry: params?.metadata ?? globalRegistry,
2648
+ target,
2649
+ unrepresentable: params?.unrepresentable ?? "throw",
2650
+ override: params?.override ?? (() => {}),
2651
+ io: params?.io ?? "output",
2652
+ counter: 0,
2653
+ seen: /* @__PURE__ */ new Map(),
2654
+ cycles: params?.cycles ?? "ref",
2655
+ reused: params?.reused ?? "inline",
2656
+ external: params?.external ?? void 0
2657
+ };
2658
+ }
2659
+ function process$1(schema, ctx, _params = {
2660
+ path: [],
2661
+ schemaPath: []
2662
+ }) {
2663
+ var _a;
2664
+ const def = schema._zod.def;
2665
+ const seen = ctx.seen.get(schema);
2666
+ if (seen) {
2667
+ seen.count++;
2668
+ if (_params.schemaPath.includes(schema)) seen.cycle = _params.path;
2669
+ return seen.schema;
2670
+ }
2671
+ const result = {
2672
+ schema: {},
2673
+ count: 1,
2674
+ cycle: void 0,
2675
+ path: _params.path
2676
+ };
2677
+ ctx.seen.set(schema, result);
2678
+ const overrideSchema = schema._zod.toJSONSchema?.();
2679
+ if (overrideSchema) result.schema = overrideSchema;
2680
+ else {
2681
+ const params = {
2682
+ ..._params,
2683
+ schemaPath: [..._params.schemaPath, schema],
2684
+ path: _params.path
2685
+ };
2686
+ if (schema._zod.processJSONSchema) schema._zod.processJSONSchema(ctx, result.schema, params);
2687
+ else {
2688
+ const _json = result.schema;
2689
+ const processor = ctx.processors[def.type];
2690
+ if (!processor) throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
2691
+ processor(schema, ctx, _json, params);
2692
+ }
2693
+ const parent = schema._zod.parent;
2694
+ if (parent) {
2695
+ if (!result.ref) result.ref = parent;
2696
+ process$1(parent, ctx, params);
2697
+ ctx.seen.get(parent).isParent = true;
2698
+ }
2699
+ }
2700
+ const meta = ctx.metadataRegistry.get(schema);
2701
+ if (meta) Object.assign(result.schema, meta);
2702
+ if (ctx.io === "input" && isTransforming(schema)) {
2703
+ delete result.schema.examples;
2704
+ delete result.schema.default;
2705
+ }
2706
+ if (ctx.io === "input" && result.schema._prefault) (_a = result.schema).default ?? (_a.default = result.schema._prefault);
2707
+ delete result.schema._prefault;
2708
+ return ctx.seen.get(schema).schema;
2709
+ }
2710
+ function extractDefs(ctx, schema) {
2711
+ const root = ctx.seen.get(schema);
2712
+ if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
2713
+ const idToSchema = /* @__PURE__ */ new Map();
2714
+ for (const entry of ctx.seen.entries()) {
2715
+ const id = ctx.metadataRegistry.get(entry[0])?.id;
2716
+ if (id) {
2717
+ const existing = idToSchema.get(id);
2718
+ if (existing && existing !== entry[0]) throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
2719
+ idToSchema.set(id, entry[0]);
2720
+ }
2721
+ }
2722
+ const makeURI = (entry) => {
2723
+ const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
2724
+ if (ctx.external) {
2725
+ const externalId = ctx.external.registry.get(entry[0])?.id;
2726
+ const uriGenerator = ctx.external.uri ?? ((id) => id);
2727
+ if (externalId) return { ref: uriGenerator(externalId) };
2728
+ const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
2729
+ entry[1].defId = id;
2730
+ return {
2731
+ defId: id,
2732
+ ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
2733
+ };
2734
+ }
2735
+ if (entry[1] === root) return { ref: "#" };
2736
+ const defUriPrefix = `#/${defsSegment}/`;
2737
+ const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
2738
+ return {
2739
+ defId,
2740
+ ref: defUriPrefix + defId
2741
+ };
2742
+ };
2743
+ const extractToDef = (entry) => {
2744
+ if (entry[1].schema.$ref) return;
2745
+ const seen = entry[1];
2746
+ const { ref, defId } = makeURI(entry);
2747
+ seen.def = { ...seen.schema };
2748
+ if (defId) seen.defId = defId;
2749
+ const schema = seen.schema;
2750
+ for (const key in schema) delete schema[key];
2751
+ schema.$ref = ref;
2752
+ };
2753
+ if (ctx.cycles === "throw") for (const entry of ctx.seen.entries()) {
2754
+ const seen = entry[1];
2755
+ if (seen.cycle) throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
2756
+
2757
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
2758
+ }
2759
+ for (const entry of ctx.seen.entries()) {
2760
+ const seen = entry[1];
2761
+ if (schema === entry[0]) {
2762
+ extractToDef(entry);
2763
+ continue;
2764
+ }
2765
+ if (ctx.external) {
2766
+ const ext = ctx.external.registry.get(entry[0])?.id;
2767
+ if (schema !== entry[0] && ext) {
2768
+ extractToDef(entry);
2769
+ continue;
2770
+ }
2771
+ }
2772
+ if (ctx.metadataRegistry.get(entry[0])?.id) {
2773
+ extractToDef(entry);
2774
+ continue;
2775
+ }
2776
+ if (seen.cycle) {
2777
+ extractToDef(entry);
2778
+ continue;
2779
+ }
2780
+ if (seen.count > 1) {
2781
+ if (ctx.reused === "ref") {
2782
+ extractToDef(entry);
2783
+ continue;
2784
+ }
2785
+ }
2786
+ }
2787
+ }
2788
+ function finalize(ctx, schema) {
2789
+ const root = ctx.seen.get(schema);
2790
+ if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
2791
+ const flattenRef = (zodSchema) => {
2792
+ const seen = ctx.seen.get(zodSchema);
2793
+ if (seen.ref === null) return;
2794
+ const schema = seen.def ?? seen.schema;
2795
+ const _cached = { ...schema };
2796
+ const ref = seen.ref;
2797
+ seen.ref = null;
2798
+ if (ref) {
2799
+ flattenRef(ref);
2800
+ const refSeen = ctx.seen.get(ref);
2801
+ const refSchema = refSeen.schema;
2802
+ if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
2803
+ schema.allOf = schema.allOf ?? [];
2804
+ schema.allOf.push(refSchema);
2805
+ } else Object.assign(schema, refSchema);
2806
+ Object.assign(schema, _cached);
2807
+ if (zodSchema._zod.parent === ref) for (const key in schema) {
2808
+ if (key === "$ref" || key === "allOf") continue;
2809
+ if (!(key in _cached)) delete schema[key];
2810
+ }
2811
+ if (refSchema.$ref && refSeen.def) for (const key in schema) {
2812
+ if (key === "$ref" || key === "allOf") continue;
2813
+ if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) delete schema[key];
2814
+ }
2815
+ }
2816
+ const parent = zodSchema._zod.parent;
2817
+ if (parent && parent !== ref) {
2818
+ flattenRef(parent);
2819
+ const parentSeen = ctx.seen.get(parent);
2820
+ if (parentSeen?.schema.$ref) {
2821
+ schema.$ref = parentSeen.schema.$ref;
2822
+ if (parentSeen.def) for (const key in schema) {
2823
+ if (key === "$ref" || key === "allOf") continue;
2824
+ if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) delete schema[key];
2825
+ }
2826
+ }
2827
+ }
2828
+ ctx.override({
2829
+ zodSchema,
2830
+ jsonSchema: schema,
2831
+ path: seen.path ?? []
2832
+ });
2833
+ };
2834
+ for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
2835
+ const result = {};
2836
+ if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
2837
+ else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
2838
+ else if (ctx.target === "draft-04") result.$schema = "http://json-schema.org/draft-04/schema#";
2839
+ else if (ctx.target === "openapi-3.0") {}
2840
+ if (ctx.external?.uri) {
2841
+ const id = ctx.external.registry.get(schema)?.id;
2842
+ if (!id) throw new Error("Schema is missing an `id` property");
2843
+ result.$id = ctx.external.uri(id);
2844
+ }
2845
+ Object.assign(result, root.def ?? root.schema);
2846
+ const defs = ctx.external?.defs ?? {};
2847
+ for (const entry of ctx.seen.entries()) {
2848
+ const seen = entry[1];
2849
+ if (seen.def && seen.defId) defs[seen.defId] = seen.def;
2850
+ }
2851
+ if (ctx.external) {} else if (Object.keys(defs).length > 0) if (ctx.target === "draft-2020-12") result.$defs = defs;
2852
+ else result.definitions = defs;
2853
+ try {
2854
+ const finalized = JSON.parse(JSON.stringify(result));
2855
+ Object.defineProperty(finalized, "~standard", {
2856
+ value: {
2857
+ ...schema["~standard"],
2858
+ jsonSchema: {
2859
+ input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
2860
+ output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
2861
+ }
2862
+ },
2863
+ enumerable: false,
2864
+ writable: false
2865
+ });
2866
+ return finalized;
2867
+ } catch (_err) {
2868
+ throw new Error("Error converting schema to JSON.");
2869
+ }
2870
+ }
2871
+ function isTransforming(_schema, _ctx) {
2872
+ const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
2873
+ if (ctx.seen.has(_schema)) return false;
2874
+ ctx.seen.add(_schema);
2875
+ const def = _schema._zod.def;
2876
+ if (def.type === "transform") return true;
2877
+ if (def.type === "array") return isTransforming(def.element, ctx);
2878
+ if (def.type === "set") return isTransforming(def.valueType, ctx);
2879
+ if (def.type === "lazy") return isTransforming(def.getter(), ctx);
2880
+ if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") return isTransforming(def.innerType, ctx);
2881
+ if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
2882
+ if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
2883
+ if (def.type === "pipe") return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
2884
+ if (def.type === "object") {
2885
+ for (const key in def.shape) if (isTransforming(def.shape[key], ctx)) return true;
2886
+ return false;
2887
+ }
2888
+ if (def.type === "union") {
2889
+ for (const option of def.options) if (isTransforming(option, ctx)) return true;
2890
+ return false;
2891
+ }
2892
+ if (def.type === "tuple") {
2893
+ for (const item of def.items) if (isTransforming(item, ctx)) return true;
2894
+ if (def.rest && isTransforming(def.rest, ctx)) return true;
2895
+ return false;
2896
+ }
2897
+ return false;
2898
+ }
2899
+ /**
2900
+ * Creates a toJSONSchema method for a schema instance.
2901
+ * This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
2902
+ */
2903
+ const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
2904
+ const ctx = initializeContext({
2905
+ ...params,
2906
+ processors
2907
+ });
2908
+ process$1(schema, ctx);
2909
+ extractDefs(ctx, schema);
2910
+ return finalize(ctx, schema);
2911
+ };
2912
+ const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
2913
+ const { libraryOptions, target } = params ?? {};
2914
+ const ctx = initializeContext({
2915
+ ...libraryOptions ?? {},
2916
+ target,
2917
+ io,
2918
+ processors
2919
+ });
2920
+ process$1(schema, ctx);
2921
+ extractDefs(ctx, schema);
2922
+ return finalize(ctx, schema);
2923
+ };
2924
+
2925
+ //#endregion
2926
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema-processors.js
2927
+ const neverProcessor = (_schema, _ctx, json, _params) => {
2928
+ json.not = {};
2929
+ };
2930
+ const unknownProcessor = (_schema, _ctx, _json, _params) => {};
2931
+ const enumProcessor = (schema, _ctx, json, _params) => {
2932
+ const def = schema._zod.def;
2933
+ const values = getEnumValues(def.entries);
2934
+ if (values.every((v) => typeof v === "number")) json.type = "number";
2935
+ if (values.every((v) => typeof v === "string")) json.type = "string";
2936
+ json.enum = values;
2937
+ };
2938
+ const customProcessor = (_schema, ctx, _json, _params) => {
2939
+ if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
2940
+ };
2941
+ const transformProcessor = (_schema, ctx, _json, _params) => {
2942
+ if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
2943
+ };
2944
+ const arrayProcessor = (schema, ctx, _json, params) => {
2945
+ const json = _json;
2946
+ const def = schema._zod.def;
2947
+ const { minimum, maximum } = schema._zod.bag;
2948
+ if (typeof minimum === "number") json.minItems = minimum;
2949
+ if (typeof maximum === "number") json.maxItems = maximum;
2950
+ json.type = "array";
2951
+ json.items = process$1(def.element, ctx, {
2952
+ ...params,
2953
+ path: [...params.path, "items"]
2954
+ });
2955
+ };
2956
+ const objectProcessor = (schema, ctx, _json, params) => {
2957
+ const json = _json;
2958
+ const def = schema._zod.def;
2959
+ json.type = "object";
2960
+ json.properties = {};
2961
+ const shape = def.shape;
2962
+ for (const key in shape) json.properties[key] = process$1(shape[key], ctx, {
2963
+ ...params,
2964
+ path: [
2965
+ ...params.path,
2966
+ "properties",
2967
+ key
2968
+ ]
2969
+ });
2970
+ const allKeys = new Set(Object.keys(shape));
2971
+ const requiredKeys = new Set([...allKeys].filter((key) => {
2972
+ const v = def.shape[key]._zod;
2973
+ if (ctx.io === "input") return v.optin === void 0;
2974
+ else return v.optout === void 0;
2975
+ }));
2976
+ if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
2977
+ if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
2978
+ else if (!def.catchall) {
2979
+ if (ctx.io === "output") json.additionalProperties = false;
2980
+ } else if (def.catchall) json.additionalProperties = process$1(def.catchall, ctx, {
2981
+ ...params,
2982
+ path: [...params.path, "additionalProperties"]
2983
+ });
2984
+ };
2985
+ const unionProcessor = (schema, ctx, json, params) => {
2986
+ const def = schema._zod.def;
2987
+ const isExclusive = def.inclusive === false;
2988
+ const options = def.options.map((x, i) => process$1(x, ctx, {
2989
+ ...params,
2990
+ path: [
2991
+ ...params.path,
2992
+ isExclusive ? "oneOf" : "anyOf",
2993
+ i
2994
+ ]
2995
+ }));
2996
+ if (isExclusive) json.oneOf = options;
2997
+ else json.anyOf = options;
2998
+ };
2999
+ const intersectionProcessor = (schema, ctx, json, params) => {
3000
+ const def = schema._zod.def;
3001
+ const a = process$1(def.left, ctx, {
3002
+ ...params,
3003
+ path: [
3004
+ ...params.path,
3005
+ "allOf",
3006
+ 0
3007
+ ]
3008
+ });
3009
+ const b = process$1(def.right, ctx, {
3010
+ ...params,
3011
+ path: [
3012
+ ...params.path,
3013
+ "allOf",
3014
+ 1
3015
+ ]
3016
+ });
3017
+ const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
3018
+ json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
3019
+ };
3020
+ const nullableProcessor = (schema, ctx, json, params) => {
3021
+ const def = schema._zod.def;
3022
+ const inner = process$1(def.innerType, ctx, params);
3023
+ const seen = ctx.seen.get(schema);
3024
+ if (ctx.target === "openapi-3.0") {
3025
+ seen.ref = def.innerType;
3026
+ json.nullable = true;
3027
+ } else json.anyOf = [inner, { type: "null" }];
3028
+ };
3029
+ const nonoptionalProcessor = (schema, ctx, _json, params) => {
3030
+ const def = schema._zod.def;
3031
+ process$1(def.innerType, ctx, params);
3032
+ const seen = ctx.seen.get(schema);
3033
+ seen.ref = def.innerType;
3034
+ };
3035
+ const defaultProcessor = (schema, ctx, json, params) => {
3036
+ const def = schema._zod.def;
3037
+ process$1(def.innerType, ctx, params);
3038
+ const seen = ctx.seen.get(schema);
3039
+ seen.ref = def.innerType;
3040
+ json.default = JSON.parse(JSON.stringify(def.defaultValue));
3041
+ };
3042
+ const prefaultProcessor = (schema, ctx, json, params) => {
3043
+ const def = schema._zod.def;
3044
+ process$1(def.innerType, ctx, params);
3045
+ const seen = ctx.seen.get(schema);
3046
+ seen.ref = def.innerType;
3047
+ if (ctx.io === "input") json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
3048
+ };
3049
+ const catchProcessor = (schema, ctx, json, params) => {
3050
+ const def = schema._zod.def;
3051
+ process$1(def.innerType, ctx, params);
3052
+ const seen = ctx.seen.get(schema);
3053
+ seen.ref = def.innerType;
3054
+ let catchValue;
3055
+ try {
3056
+ catchValue = def.catchValue(void 0);
3057
+ } catch {
3058
+ throw new Error("Dynamic catch values are not supported in JSON Schema");
3059
+ }
3060
+ json.default = catchValue;
3061
+ };
3062
+ const pipeProcessor = (schema, ctx, _json, params) => {
3063
+ const def = schema._zod.def;
3064
+ const innerType = ctx.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
3065
+ process$1(innerType, ctx, params);
3066
+ const seen = ctx.seen.get(schema);
3067
+ seen.ref = innerType;
3068
+ };
3069
+ const readonlyProcessor = (schema, ctx, json, params) => {
3070
+ const def = schema._zod.def;
3071
+ process$1(def.innerType, ctx, params);
3072
+ const seen = ctx.seen.get(schema);
3073
+ seen.ref = def.innerType;
3074
+ json.readOnly = true;
3075
+ };
3076
+ const optionalProcessor = (schema, ctx, _json, params) => {
3077
+ const def = schema._zod.def;
3078
+ process$1(def.innerType, ctx, params);
3079
+ const seen = ctx.seen.get(schema);
3080
+ seen.ref = def.innerType;
3081
+ };
3082
+
3083
+ //#endregion
3084
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/errors.js
3085
+ const initializer = (inst, issues) => {
3086
+ $ZodError.init(inst, issues);
3087
+ inst.name = "ZodError";
3088
+ Object.defineProperties(inst, {
3089
+ format: { value: (mapper) => formatError(inst, mapper) },
3090
+ flatten: { value: (mapper) => flattenError(inst, mapper) },
3091
+ addIssue: { value: (issue) => {
3092
+ inst.issues.push(issue);
3093
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3094
+ } },
3095
+ addIssues: { value: (issues) => {
3096
+ inst.issues.push(...issues);
3097
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3098
+ } },
3099
+ isEmpty: { get() {
3100
+ return inst.issues.length === 0;
3101
+ } }
3102
+ });
3103
+ };
3104
+ const ZodError = $constructor("ZodError", initializer);
3105
+ const ZodRealError = $constructor("ZodError", initializer, { Parent: Error });
3106
+
3107
+ //#endregion
3108
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/parse.js
3109
+ const parse = /* @__PURE__ */ _parse(ZodRealError);
3110
+ const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
3111
+ const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
3112
+ const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
3113
+ const encode = /* @__PURE__ */ _encode(ZodRealError);
3114
+ const decode = /* @__PURE__ */ _decode(ZodRealError);
3115
+ const encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
3116
+ const decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
3117
+ const safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
3118
+ const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
3119
+ const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
3120
+ const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
3121
+
3122
+ //#endregion
3123
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/schemas.js
3124
+ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
3125
+ $ZodType.init(inst, def);
3126
+ Object.assign(inst["~standard"], { jsonSchema: {
3127
+ input: createStandardJSONSchemaMethod(inst, "input"),
3128
+ output: createStandardJSONSchemaMethod(inst, "output")
3129
+ } });
3130
+ inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
3131
+ inst.def = def;
3132
+ inst.type = def.type;
3133
+ Object.defineProperty(inst, "_def", { value: def });
3134
+ inst.check = (...checks) => {
3135
+ return inst.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...checks.map((ch) => typeof ch === "function" ? { _zod: {
3136
+ check: ch,
3137
+ def: { check: "custom" },
3138
+ onattach: []
3139
+ } } : ch)] }), { parent: true });
3140
+ };
3141
+ inst.with = inst.check;
3142
+ inst.clone = (def, params) => clone(inst, def, params);
3143
+ inst.brand = () => inst;
3144
+ inst.register = ((reg, meta) => {
3145
+ reg.add(inst, meta);
3146
+ return inst;
3147
+ });
3148
+ inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
3149
+ inst.safeParse = (data, params) => safeParse(inst, data, params);
3150
+ inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
3151
+ inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
3152
+ inst.spa = inst.safeParseAsync;
3153
+ inst.encode = (data, params) => encode(inst, data, params);
3154
+ inst.decode = (data, params) => decode(inst, data, params);
3155
+ inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
3156
+ inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
3157
+ inst.safeEncode = (data, params) => safeEncode(inst, data, params);
3158
+ inst.safeDecode = (data, params) => safeDecode(inst, data, params);
3159
+ inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
3160
+ inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
3161
+ inst.refine = (check, params) => inst.check(refine(check, params));
3162
+ inst.superRefine = (refinement) => inst.check(superRefine(refinement));
3163
+ inst.overwrite = (fn) => inst.check(_overwrite(fn));
3164
+ inst.optional = () => optional(inst);
3165
+ inst.exactOptional = () => exactOptional(inst);
3166
+ inst.nullable = () => nullable(inst);
3167
+ inst.nullish = () => optional(nullable(inst));
3168
+ inst.nonoptional = (params) => nonoptional(inst, params);
3169
+ inst.array = () => array(inst);
3170
+ inst.or = (arg) => union([inst, arg]);
3171
+ inst.and = (arg) => intersection(inst, arg);
3172
+ inst.transform = (tx) => pipe(inst, transform(tx));
3173
+ inst.default = (def) => _default(inst, def);
3174
+ inst.prefault = (def) => prefault(inst, def);
3175
+ inst.catch = (params) => _catch(inst, params);
3176
+ inst.pipe = (target) => pipe(inst, target);
3177
+ inst.readonly = () => readonly(inst);
3178
+ inst.describe = (description) => {
3179
+ const cl = inst.clone();
3180
+ globalRegistry.add(cl, { description });
3181
+ return cl;
3182
+ };
3183
+ Object.defineProperty(inst, "description", {
3184
+ get() {
3185
+ return globalRegistry.get(inst)?.description;
3186
+ },
3187
+ configurable: true
3188
+ });
3189
+ inst.meta = (...args) => {
3190
+ if (args.length === 0) return globalRegistry.get(inst);
3191
+ const cl = inst.clone();
3192
+ globalRegistry.add(cl, args[0]);
3193
+ return cl;
3194
+ };
3195
+ inst.isOptional = () => inst.safeParse(void 0).success;
3196
+ inst.isNullable = () => inst.safeParse(null).success;
3197
+ inst.apply = (fn) => fn(inst);
3198
+ return inst;
3199
+ });
3200
+ const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
3201
+ $ZodUnknown.init(inst, def);
3202
+ ZodType.init(inst, def);
3203
+ inst._zod.processJSONSchema = (ctx, json, params) => unknownProcessor(inst, ctx, json, params);
3204
+ });
3205
+ function unknown() {
3206
+ return _unknown(ZodUnknown);
3207
+ }
3208
+ const ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
3209
+ $ZodNever.init(inst, def);
3210
+ ZodType.init(inst, def);
3211
+ inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json, params);
3212
+ });
3213
+ function never(params) {
3214
+ return _never(ZodNever, params);
3215
+ }
3216
+ const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
3217
+ $ZodArray.init(inst, def);
3218
+ ZodType.init(inst, def);
3219
+ inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
3220
+ inst.element = def.element;
3221
+ inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
3222
+ inst.nonempty = (params) => inst.check(_minLength(1, params));
3223
+ inst.max = (maxLength, params) => inst.check(_maxLength(maxLength, params));
3224
+ inst.length = (len, params) => inst.check(_length(len, params));
3225
+ inst.unwrap = () => inst.element;
3226
+ });
3227
+ function array(element, params) {
3228
+ return _array(ZodArray, element, params);
3229
+ }
3230
+ const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
3231
+ $ZodObjectJIT.init(inst, def);
3232
+ ZodType.init(inst, def);
3233
+ inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
3234
+ defineLazy(inst, "shape", () => {
3235
+ return def.shape;
3236
+ });
3237
+ inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
3238
+ inst.catchall = (catchall) => inst.clone({
3239
+ ...inst._zod.def,
3240
+ catchall
3241
+ });
3242
+ inst.passthrough = () => inst.clone({
3243
+ ...inst._zod.def,
3244
+ catchall: unknown()
3245
+ });
3246
+ inst.loose = () => inst.clone({
3247
+ ...inst._zod.def,
3248
+ catchall: unknown()
3249
+ });
3250
+ inst.strict = () => inst.clone({
3251
+ ...inst._zod.def,
3252
+ catchall: never()
3253
+ });
3254
+ inst.strip = () => inst.clone({
3255
+ ...inst._zod.def,
3256
+ catchall: void 0
3257
+ });
3258
+ inst.extend = (incoming) => {
3259
+ return extend(inst, incoming);
3260
+ };
3261
+ inst.safeExtend = (incoming) => {
3262
+ return safeExtend(inst, incoming);
3263
+ };
3264
+ inst.merge = (other) => merge(inst, other);
3265
+ inst.pick = (mask) => pick(inst, mask);
3266
+ inst.omit = (mask) => omit(inst, mask);
3267
+ inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
3268
+ inst.required = (...args) => required(ZodNonOptional, inst, args[0]);
3269
+ });
3270
+ function looseObject(shape, params) {
3271
+ return new ZodObject({
3272
+ type: "object",
3273
+ shape,
3274
+ catchall: unknown(),
3275
+ ...normalizeParams(params)
3276
+ });
3277
+ }
3278
+ const ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
3279
+ $ZodUnion.init(inst, def);
3280
+ ZodType.init(inst, def);
3281
+ inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
3282
+ inst.options = def.options;
3283
+ });
3284
+ function union(options, params) {
3285
+ return new ZodUnion({
3286
+ type: "union",
3287
+ options,
3288
+ ...normalizeParams(params)
3289
+ });
3290
+ }
3291
+ const ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
3292
+ $ZodIntersection.init(inst, def);
3293
+ ZodType.init(inst, def);
3294
+ inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
3295
+ });
3296
+ function intersection(left, right) {
3297
+ return new ZodIntersection({
3298
+ type: "intersection",
3299
+ left,
3300
+ right
3301
+ });
3302
+ }
3303
+ const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
3304
+ $ZodEnum.init(inst, def);
3305
+ ZodType.init(inst, def);
3306
+ inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
3307
+ inst.enum = def.entries;
3308
+ inst.options = Object.values(def.entries);
3309
+ const keys = new Set(Object.keys(def.entries));
3310
+ inst.extract = (values, params) => {
3311
+ const newEntries = {};
3312
+ for (const value of values) if (keys.has(value)) newEntries[value] = def.entries[value];
3313
+ else throw new Error(`Key ${value} not found in enum`);
3314
+ return new ZodEnum({
3315
+ ...def,
3316
+ checks: [],
3317
+ ...normalizeParams(params),
3318
+ entries: newEntries
3319
+ });
3320
+ };
3321
+ inst.exclude = (values, params) => {
3322
+ const newEntries = { ...def.entries };
3323
+ for (const value of values) if (keys.has(value)) delete newEntries[value];
3324
+ else throw new Error(`Key ${value} not found in enum`);
3325
+ return new ZodEnum({
3326
+ ...def,
3327
+ checks: [],
3328
+ ...normalizeParams(params),
3329
+ entries: newEntries
3330
+ });
3331
+ };
3332
+ });
3333
+ function _enum(values, params) {
3334
+ return new ZodEnum({
3335
+ type: "enum",
3336
+ entries: Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values,
3337
+ ...normalizeParams(params)
3338
+ });
3339
+ }
3340
+ const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
3341
+ $ZodTransform.init(inst, def);
3342
+ ZodType.init(inst, def);
3343
+ inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
3344
+ inst._zod.parse = (payload, _ctx) => {
3345
+ if (_ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
3346
+ payload.addIssue = (issue$1) => {
3347
+ if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, def));
3348
+ else {
3349
+ const _issue = issue$1;
3350
+ if (_issue.fatal) _issue.continue = false;
3351
+ _issue.code ?? (_issue.code = "custom");
3352
+ _issue.input ?? (_issue.input = payload.value);
3353
+ _issue.inst ?? (_issue.inst = inst);
3354
+ payload.issues.push(issue(_issue));
3355
+ }
3356
+ };
3357
+ const output = def.transform(payload.value, payload);
3358
+ if (output instanceof Promise) return output.then((output) => {
3359
+ payload.value = output;
3360
+ return payload;
3361
+ });
3362
+ payload.value = output;
3363
+ return payload;
3364
+ };
3365
+ });
3366
+ function transform(fn) {
3367
+ return new ZodTransform({
3368
+ type: "transform",
3369
+ transform: fn
3370
+ });
3371
+ }
3372
+ const ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
3373
+ $ZodOptional.init(inst, def);
3374
+ ZodType.init(inst, def);
3375
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
3376
+ inst.unwrap = () => inst._zod.def.innerType;
3377
+ });
3378
+ function optional(innerType) {
3379
+ return new ZodOptional({
3380
+ type: "optional",
3381
+ innerType
3382
+ });
3383
+ }
3384
+ const ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
3385
+ $ZodExactOptional.init(inst, def);
3386
+ ZodType.init(inst, def);
3387
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
3388
+ inst.unwrap = () => inst._zod.def.innerType;
3389
+ });
3390
+ function exactOptional(innerType) {
3391
+ return new ZodExactOptional({
3392
+ type: "optional",
3393
+ innerType
3394
+ });
3395
+ }
3396
+ const ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
3397
+ $ZodNullable.init(inst, def);
3398
+ ZodType.init(inst, def);
3399
+ inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
3400
+ inst.unwrap = () => inst._zod.def.innerType;
3401
+ });
3402
+ function nullable(innerType) {
3403
+ return new ZodNullable({
3404
+ type: "nullable",
3405
+ innerType
3406
+ });
3407
+ }
3408
+ const ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
3409
+ $ZodDefault.init(inst, def);
3410
+ ZodType.init(inst, def);
3411
+ inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
3412
+ inst.unwrap = () => inst._zod.def.innerType;
3413
+ inst.removeDefault = inst.unwrap;
3414
+ });
3415
+ function _default(innerType, defaultValue) {
3416
+ return new ZodDefault({
3417
+ type: "default",
3418
+ innerType,
3419
+ get defaultValue() {
3420
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
3421
+ }
3422
+ });
3423
+ }
3424
+ const ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
3425
+ $ZodPrefault.init(inst, def);
3426
+ ZodType.init(inst, def);
3427
+ inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
3428
+ inst.unwrap = () => inst._zod.def.innerType;
3429
+ });
3430
+ function prefault(innerType, defaultValue) {
3431
+ return new ZodPrefault({
3432
+ type: "prefault",
3433
+ innerType,
3434
+ get defaultValue() {
3435
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
3436
+ }
3437
+ });
3438
+ }
3439
+ const ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
3440
+ $ZodNonOptional.init(inst, def);
3441
+ ZodType.init(inst, def);
3442
+ inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
3443
+ inst.unwrap = () => inst._zod.def.innerType;
3444
+ });
3445
+ function nonoptional(innerType, params) {
3446
+ return new ZodNonOptional({
3447
+ type: "nonoptional",
3448
+ innerType,
3449
+ ...normalizeParams(params)
3450
+ });
3451
+ }
3452
+ const ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
3453
+ $ZodCatch.init(inst, def);
3454
+ ZodType.init(inst, def);
3455
+ inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
3456
+ inst.unwrap = () => inst._zod.def.innerType;
3457
+ inst.removeCatch = inst.unwrap;
3458
+ });
3459
+ function _catch(innerType, catchValue) {
3460
+ return new ZodCatch({
3461
+ type: "catch",
3462
+ innerType,
3463
+ catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
3464
+ });
3465
+ }
3466
+ const ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
3467
+ $ZodPipe.init(inst, def);
3468
+ ZodType.init(inst, def);
3469
+ inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
3470
+ inst.in = def.in;
3471
+ inst.out = def.out;
3472
+ });
3473
+ function pipe(in_, out) {
3474
+ return new ZodPipe({
3475
+ type: "pipe",
3476
+ in: in_,
3477
+ out
3478
+ });
3479
+ }
3480
+ const ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
3481
+ $ZodReadonly.init(inst, def);
3482
+ ZodType.init(inst, def);
3483
+ inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
3484
+ inst.unwrap = () => inst._zod.def.innerType;
3485
+ });
3486
+ function readonly(innerType) {
3487
+ return new ZodReadonly({
3488
+ type: "readonly",
3489
+ innerType
3490
+ });
3491
+ }
3492
+ const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
3493
+ $ZodCustom.init(inst, def);
3494
+ ZodType.init(inst, def);
3495
+ inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
3496
+ });
3497
+ function refine(fn, _params = {}) {
3498
+ return _refine(ZodCustom, fn, _params);
3499
+ }
3500
+ function superRefine(fn) {
3501
+ return _superRefine(fn);
3502
+ }
3503
+ const describe = describe$1;
3504
+ const meta = meta$1;
3505
+
3506
+ //#endregion
3507
+ //#region src/config/schema.ts
3508
+ const checkerExtensionsConfigReason = "checker extensions are fixed by built-in presets and cannot be configured.";
3509
+ const checkerRoutesConfigReason = "checker routes are not supported; configure checker.include with source tsconfig selectors.";
3510
+ const unsupportedCheckerPresetReason = "configured checkers require a built-in checker adapter.";
3511
+ const checkerEntryConfigReason = "checker.entry has been removed; configure checker.include with source tsconfig selectors.";
3512
+ const checkerConfigReason = "config.checkers must be an object auto config or an object keyed by checker name.";
3513
+ const checkerAutoStringConfigReason = "checkers: \"auto\" has been removed; omit config.checkers or use { mode: \"auto\" }.";
3514
+ const autoCheckerMixedConfigReason = "auto checker config must not be mixed with named checker entries.";
3515
+ const autoCheckerModeConfigReason = "auto checker config requires mode: \"auto\".";
3516
+ const importAnalysisConfigReason = "config.imports must be an object when configured.";
3517
+ const vueImportParserConfigReason = "config.imports.vue must be \"heuristic\" or \"compiler-sfc\".";
3518
+ const checkerConfigShapeSchema = looseObject({}).superRefine((checker, ctx) => {
3519
+ const preset = checker.preset;
3520
+ const include = checker.include;
3521
+ const exclude = checker.exclude;
3522
+ if (Object.hasOwn(checker, "entry")) ctx.addIssue({
3523
+ code: "custom",
3524
+ message: checkerEntryConfigReason,
3525
+ path: ["entry"]
3526
+ });
3527
+ if (Object.hasOwn(checker, "extensions")) ctx.addIssue({
3528
+ code: "custom",
3529
+ message: checkerExtensionsConfigReason,
3530
+ path: ["extensions"]
3531
+ });
3532
+ if (Object.hasOwn(checker, "routes")) ctx.addIssue({
3533
+ code: "custom",
3534
+ message: checkerRoutesConfigReason,
3535
+ path: ["routes"]
3536
+ });
3537
+ if (typeof preset !== "string" || preset.trim().length === 0) ctx.addIssue({
3538
+ code: "custom",
3539
+ message: "checker preset must be a non-empty string.",
3540
+ path: ["preset"]
3541
+ });
3542
+ else if (!getCheckerAdapter(preset)) ctx.addIssue({
3543
+ code: "custom",
3544
+ message: unsupportedCheckerPresetReason,
3545
+ path: ["preset"]
3546
+ });
3547
+ if (!Array.isArray(include) || include.length === 0) ctx.addIssue({
3548
+ code: "custom",
3549
+ message: "checker include must be a non-empty string array.",
3550
+ path: ["include"]
3551
+ });
3552
+ else for (const [index, value] of include.entries()) if (typeof value !== "string" || value.trim().length === 0) ctx.addIssue({
3553
+ code: "custom",
3554
+ message: "checker include entries must be non-empty string paths.",
3555
+ path: ["include", index]
3556
+ });
3557
+ if (exclude === void 0) return;
3558
+ if (!Array.isArray(exclude)) {
3559
+ ctx.addIssue({
3560
+ code: "custom",
3561
+ message: "checker exclude must be a string array when configured.",
3562
+ path: ["exclude"]
3563
+ });
3564
+ return;
3565
+ }
3566
+ for (const [index, value] of exclude.entries()) if (typeof value !== "string" || value.trim().length === 0) ctx.addIssue({
3567
+ code: "custom",
3568
+ message: "checker exclude entries must be non-empty string paths.",
3569
+ path: ["exclude", index]
3570
+ });
3571
+ });
3572
+ function isPlainConfigRecord(value) {
3573
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
3574
+ }
3575
+ const sharedLiminaConfigShapeSchema = looseObject({}).superRefine((sharedConfig, ctx) => {
3576
+ const checkers = sharedConfig.checkers;
3577
+ const imports = sharedConfig.imports;
3578
+ const source = sharedConfig.source;
3579
+ if (checkers !== void 0) if (checkers === "auto") ctx.addIssue({
3580
+ code: "custom",
3581
+ message: checkerAutoStringConfigReason,
3582
+ path: ["checkers"]
3583
+ });
3584
+ else if (!isPlainConfigRecord(checkers)) ctx.addIssue({
3585
+ code: "custom",
3586
+ message: checkerConfigReason,
3587
+ path: ["checkers"]
3588
+ });
3589
+ else if (Object.hasOwn(checkers, "mode")) {
3590
+ if (checkers.mode !== "auto") ctx.addIssue({
3591
+ code: "custom",
3592
+ message: autoCheckerModeConfigReason,
3593
+ path: ["checkers", "mode"]
3594
+ });
3595
+ const exclude = checkers.exclude;
3596
+ if (exclude !== void 0 && !Array.isArray(exclude)) ctx.addIssue({
3597
+ code: "custom",
3598
+ message: "auto checker exclude must be a string array when configured.",
3599
+ path: ["checkers", "exclude"]
3600
+ });
3601
+ else if (Array.isArray(exclude)) {
3602
+ for (const [index, value] of exclude.entries()) if (typeof value !== "string" || value.trim().length === 0) ctx.addIssue({
3603
+ code: "custom",
3604
+ message: "auto checker exclude entries must be non-empty string paths.",
3605
+ path: [
3606
+ "checkers",
3607
+ "exclude",
3608
+ index
3609
+ ]
3610
+ });
3611
+ }
3612
+ for (const key of Object.keys(checkers)) {
3613
+ if (key === "mode" || key === "exclude") continue;
3614
+ ctx.addIssue({
3615
+ code: "custom",
3616
+ message: autoCheckerMixedConfigReason,
3617
+ path: ["checkers", key]
3618
+ });
3619
+ }
3620
+ } else for (const [checkerName, checker] of Object.entries(checkers)) {
3621
+ const result = checkerConfigShapeSchema.safeParse(checker);
3622
+ if (result.success) continue;
3623
+ for (const issue of result.error.issues) ctx.addIssue({
3624
+ ...issue,
3625
+ path: [
3626
+ "checkers",
3627
+ checkerName,
3628
+ ...issue.path
3629
+ ]
3630
+ });
3631
+ }
3632
+ if (imports !== void 0) {
3633
+ if (!isPlainConfigRecord(imports)) ctx.addIssue({
3634
+ code: "custom",
3635
+ message: importAnalysisConfigReason,
3636
+ path: ["imports"]
3637
+ });
3638
+ else if (imports.vue !== void 0 && imports.vue !== "heuristic" && imports.vue !== "compiler-sfc") ctx.addIssue({
3639
+ code: "custom",
3640
+ message: vueImportParserConfigReason,
3641
+ path: ["imports", "vue"]
3642
+ });
3643
+ }
3644
+ if (source === void 0) return;
3645
+ if (!isPlainConfigRecord(source)) {
3646
+ ctx.addIssue({
3647
+ code: "custom",
3648
+ message: "source boundary config must be an object.",
3649
+ path: ["source"]
3650
+ });
3651
+ return;
3652
+ }
3653
+ for (const key of Object.keys(source)) {
3654
+ if (key === "include" || key === "exclude") continue;
3655
+ ctx.addIssue({
3656
+ code: "custom",
3657
+ message: "unknown source boundary config field.",
3658
+ path: ["source", key]
3659
+ });
3660
+ }
3661
+ });
3662
+ const releaseContentHashShapeSchema = looseObject({}).superRefine((contentHash, ctx) => {
3663
+ const baselineTag = contentHash.baselineTag;
3664
+ if (baselineTag !== void 0 && typeof baselineTag !== "function" && (typeof baselineTag !== "string" || baselineTag.trim().length === 0)) ctx.addIssue({
3665
+ code: "custom",
3666
+ message: "baselineTag must be a non-empty string or function.",
3667
+ path: ["baselineTag"]
3668
+ });
3669
+ const builtinIgnore = contentHash.builtinIgnore;
3670
+ if (builtinIgnore !== void 0 && typeof builtinIgnore !== "boolean") ctx.addIssue({
3671
+ code: "custom",
3672
+ message: "builtinIgnore must be a boolean.",
3673
+ path: ["builtinIgnore"]
3674
+ });
3675
+ const ignore = contentHash.ignore;
3676
+ if (ignore === void 0 || typeof ignore === "function") return;
3677
+ if (!Array.isArray(ignore)) {
3678
+ ctx.addIssue({
3679
+ code: "custom",
3680
+ message: "ignore must be an array of non-empty strings or function.",
3681
+ path: ["ignore"]
3682
+ });
3683
+ return;
3684
+ }
3685
+ for (const [index, pattern] of ignore.entries()) {
3686
+ if (typeof pattern === "string" && pattern.trim().length > 0) continue;
3687
+ ctx.addIssue({
3688
+ code: "custom",
3689
+ message: "ignore patterns must be non-empty strings.",
3690
+ path: ["ignore", index]
3691
+ });
3692
+ }
3693
+ });
3694
+ const releaseConfigShapeSchema = looseObject({ contentHash: releaseContentHashShapeSchema.optional() });
3695
+ const executionConcurrencyFields = [
3696
+ "tasks",
3697
+ "checkerBuild",
3698
+ "checkerTypecheck",
3699
+ "packageEntries",
3700
+ "releaseEntries"
3701
+ ];
3702
+ function isValidExecutionConcurrencyValue(value) {
3703
+ return value === "auto" || typeof value === "number" && Number.isInteger(value) && value > 0;
3704
+ }
3705
+ const executionConfigShapeSchema = looseObject({}).superRefine((execution, ctx) => {
3706
+ for (const key of Object.keys(execution)) {
3707
+ if (key === "failFast" || executionConcurrencyFields.includes(key)) continue;
3708
+ ctx.addIssue({
3709
+ code: "custom",
3710
+ message: "unknown execution config field.",
3711
+ path: [key]
3712
+ });
3713
+ }
3714
+ for (const key of executionConcurrencyFields) {
3715
+ const value = execution[key];
3716
+ if (value === void 0 || isValidExecutionConcurrencyValue(value)) continue;
3717
+ ctx.addIssue({
3718
+ code: "custom",
3719
+ message: "execution concurrency must be a positive integer or \"auto\".",
3720
+ path: [key]
3721
+ });
3722
+ }
3723
+ if (execution.failFast !== void 0 && typeof execution.failFast !== "boolean") ctx.addIssue({
3724
+ code: "custom",
3725
+ message: "execution failFast must be a boolean.",
3726
+ path: ["failFast"]
3727
+ });
3728
+ });
3729
+ function validateStringArrayField(options) {
3730
+ if (options.value === void 0) {
3731
+ if (options.required) options.ctx.addIssue({
3732
+ code: "custom",
3733
+ message: `${options.valueName} must be a non-empty string array.`,
3734
+ path: options.path
3735
+ });
3736
+ return false;
3737
+ }
3738
+ if (!Array.isArray(options.value) || options.value.length === 0) {
3739
+ options.ctx.addIssue({
3740
+ code: "custom",
3741
+ message: `${options.valueName} must be a non-empty string array.`,
3742
+ path: options.path
3743
+ });
3744
+ return false;
3745
+ }
3746
+ for (const [index, item] of options.value.entries()) {
3747
+ if (typeof item === "string" && item.trim().length > 0) continue;
3748
+ options.ctx.addIssue({
3749
+ code: "custom",
3750
+ message: `${options.valueName} entries must be non-empty strings.`,
3751
+ path: [...options.path, index]
3752
+ });
3753
+ }
3754
+ return true;
3755
+ }
3756
+ function validateSourceImportAuthorityConfig(value, ctx) {
3757
+ if (value === void 0) return;
3758
+ if (!isPlainConfigRecord(value)) {
3759
+ ctx.addIssue({
3760
+ code: "custom",
3761
+ message: "importAuthority must be an object.",
3762
+ path: ["source", "importAuthority"]
3763
+ });
3764
+ return;
3765
+ }
3766
+ const allow = value.allow;
3767
+ if (allow === void 0) return;
3768
+ if (!Array.isArray(allow)) {
3769
+ ctx.addIssue({
3770
+ code: "custom",
3771
+ message: "importAuthority.allow must be an array.",
3772
+ path: [
3773
+ "source",
3774
+ "importAuthority",
3775
+ "allow"
3776
+ ]
3777
+ });
3778
+ return;
3779
+ }
3780
+ for (const [index, entry] of allow.entries()) {
3781
+ const path = [
3782
+ "source",
3783
+ "importAuthority",
3784
+ "allow",
3785
+ index
3786
+ ];
3787
+ if (!isPlainConfigRecord(entry)) {
3788
+ ctx.addIssue({
3789
+ code: "custom",
3790
+ message: "importAuthority allow entries must be objects with files, packages or specifiers, and reason fields.",
3791
+ path
3792
+ });
3793
+ continue;
3794
+ }
3795
+ validateStringArrayField({
3796
+ ctx,
3797
+ path: [...path, "files"],
3798
+ required: true,
3799
+ value: entry.files,
3800
+ valueName: "files"
3801
+ });
3802
+ const hasPackages = validateStringArrayField({
3803
+ ctx,
3804
+ path: [...path, "packages"],
3805
+ value: entry.packages,
3806
+ valueName: "packages"
3807
+ });
3808
+ const hasSpecifiers = validateStringArrayField({
3809
+ ctx,
3810
+ path: [...path, "specifiers"],
3811
+ value: entry.specifiers,
3812
+ valueName: "specifiers"
3813
+ });
3814
+ if (!hasPackages && !hasSpecifiers) ctx.addIssue({
3815
+ code: "custom",
3816
+ message: "importAuthority allow entries must declare packages or specifiers.",
3817
+ path
3818
+ });
3819
+ if (entry.owner !== void 0) {
3820
+ if (typeof entry.owner !== "string" || entry.owner.trim().length === 0) ctx.addIssue({
3821
+ code: "custom",
3822
+ message: "owner must be a non-empty string when configured.",
3823
+ path: [...path, "owner"]
3824
+ });
3825
+ }
3826
+ if (typeof entry.reason !== "string" || entry.reason.trim().length === 0) ctx.addIssue({
3827
+ code: "custom",
3828
+ message: "reason must be a non-empty string.",
3829
+ path: [...path, "reason"]
3830
+ });
3831
+ }
3832
+ }
3833
+ const liminaConfigShapeSchema = looseObject({
3834
+ config: sharedLiminaConfigShapeSchema.optional(),
3835
+ execution: executionConfigShapeSchema.optional(),
3836
+ release: releaseConfigShapeSchema.optional()
3837
+ }).superRefine((config, ctx) => {
3838
+ if (Object.hasOwn(config, "paths")) ctx.addIssue({
3839
+ code: "custom",
3840
+ message: "paths config has been removed; use graph/proof/source checks instead.",
3841
+ path: ["paths"]
3842
+ });
3843
+ const source = config.source;
3844
+ if (source === void 0) return;
3845
+ if (!isPlainConfigRecord(source)) {
3846
+ ctx.addIssue({
3847
+ code: "custom",
3848
+ message: "source config must be an object.",
3849
+ path: ["source"]
3850
+ });
3851
+ return;
3852
+ }
3853
+ for (const key of Object.keys(source)) {
3854
+ if (key === "knip" || key === "importAuthority") continue;
3855
+ ctx.addIssue({
3856
+ code: "custom",
3857
+ message: "unknown source config field.",
3858
+ path: ["source", key]
3859
+ });
3860
+ }
3861
+ validateSourceImportAuthorityConfig(source.importAuthority, ctx);
3862
+ });
3863
+ function formatZodPath(pathSegments) {
3864
+ return pathSegments.map((segment) => typeof segment === "number" ? `[${segment}]` : `.${String(segment)}`).join("").replace(/^\./u, "");
3865
+ }
3866
+ function getValueAtPath(value, pathSegments) {
3867
+ let current = value;
3868
+ for (const segment of pathSegments) {
3869
+ if (current === void 0 || current === null) return;
3870
+ current = current[segment];
3871
+ }
3872
+ return current;
3873
+ }
3874
+ function formatLiminaConfigShapeIssue(value, issue) {
3875
+ const pathSegments = issue.path;
3876
+ const field = formatZodPath(pathSegments);
3877
+ if (pathSegments.length === 0) return "limina config must export or return an object.";
3878
+ if (field === "config") return [
3879
+ "Invalid Limina config:",
3880
+ " field: config",
3881
+ ` value: ${formatUnknownValue(getValueAtPath(value, pathSegments))}`,
3882
+ " reason: config must be an object."
3883
+ ].join("\n");
3884
+ if (field === "paths") return [
3885
+ "Invalid Limina paths config:",
3886
+ " field: paths",
3887
+ ` value: ${formatUnknownValue(getValueAtPath(value, pathSegments))}`,
3888
+ ` reason: ${issue.message}`
3889
+ ].join("\n");
3890
+ if (field === "execution") return [
3891
+ "Invalid Limina execution config:",
3892
+ " field: execution",
3893
+ ` value: ${formatUnknownValue(getValueAtPath(value, pathSegments))}`,
3894
+ " reason: execution must be an object."
3895
+ ].join("\n");
3896
+ if (field === "execution.failFast") return [
3897
+ "Invalid Limina execution config:",
3898
+ " field: execution.failFast",
3899
+ ` value: ${formatUnknownValue(getValueAtPath(value, pathSegments))}`,
3900
+ " reason: execution failFast must be a boolean."
3901
+ ].join("\n");
3902
+ if (field.startsWith("execution.")) return [
3903
+ "Invalid Limina execution config:",
3904
+ ` field: ${field}`,
3905
+ ` value: ${formatUnknownValue(getValueAtPath(value, pathSegments))}`,
3906
+ ` reason: ${issue.message}`
3907
+ ].join("\n");
3908
+ if (field === "config.checkers") return [
3909
+ "Invalid Limina checker config:",
3910
+ " field: config.checkers",
3911
+ ` value: ${formatUnknownValue(getValueAtPath(value, pathSegments))}`,
3912
+ ` reason: ${issue.message}`
3913
+ ].join("\n");
3914
+ if (field === "config.checkers.mode") return [
3915
+ "Invalid Limina checker config:",
3916
+ " field: config.checkers.mode",
3917
+ ` value: ${formatUnknownValue(getValueAtPath(value, pathSegments))}`,
3918
+ ` reason: ${issue.message}`
3919
+ ].join("\n");
3920
+ if (field.startsWith("config.checkers.exclude")) return [
3921
+ "Invalid Limina checker config:",
3922
+ ` field: ${field}`,
3923
+ ` value: ${formatUnknownValue(getValueAtPath(value, pathSegments))}`,
3924
+ ` reason: ${issue.message}`
3925
+ ].join("\n");
3926
+ if (field === "config.imports" || field.startsWith("config.imports.")) return [
3927
+ "Invalid Limina import analysis config:",
3928
+ ` field: ${field}`,
3929
+ ` value: ${formatUnknownValue(getValueAtPath(value, pathSegments))}`,
3930
+ ` reason: ${issue.message}`
3931
+ ].join("\n");
3932
+ if (field === "config.source" || field.startsWith("config.source.")) return [
3933
+ "Invalid Limina source boundary config:",
3934
+ ` field: ${field}`,
3935
+ ` value: ${formatUnknownValue(getValueAtPath(value, pathSegments))}`,
3936
+ ` reason: ${issue.message}`
3937
+ ].join("\n");
3938
+ if (field === "source" || field.startsWith("source.")) return [
3939
+ "Invalid Limina source config:",
3940
+ ` field: ${field}`,
3941
+ ` value: ${formatUnknownValue(getValueAtPath(value, pathSegments))}`,
3942
+ ` reason: ${issue.message}`
3943
+ ].join("\n");
3944
+ if (pathSegments[0] === "config" && pathSegments[1] === "checkers") {
3945
+ const checkerName = pathSegments[2];
3946
+ const checkerField = `config.checkers.${String(checkerName)}`;
3947
+ if (pathSegments.length === 3) return [
3948
+ "Invalid Limina checker config:",
3949
+ ` field: ${checkerField}`,
3950
+ ` value: ${formatUnknownValue(getValueAtPath(value, pathSegments))}`,
3951
+ ` reason: ${issue.message === autoCheckerMixedConfigReason ? issue.message : "checker entries must be objects."}`
3952
+ ].join("\n");
3953
+ if (pathSegments[3] === "preset") {
3954
+ if (issue.message === unsupportedCheckerPresetReason) return [
3955
+ "Unsupported Limina checker preset:",
3956
+ ` field: ${checkerField}.preset`,
3957
+ ` value: ${formatUnknownValue(getValueAtPath(value, pathSegments))}`,
3958
+ ` reason: ${issue.message}`
3959
+ ].join("\n");
3960
+ return [
3961
+ "Invalid Limina checker config:",
3962
+ ` field: ${checkerField}.preset`,
3963
+ ` value: ${formatUnknownValue(getValueAtPath(value, pathSegments))}`,
3964
+ " reason: checker preset must be a non-empty string."
3965
+ ].join("\n");
3966
+ }
3967
+ if (pathSegments[3] === "entry") return [
3968
+ "Invalid Limina checker entry config:",
3969
+ ` field: ${checkerField}.entry`,
3970
+ ` value: ${formatUnknownValue(getValueAtPath(value, pathSegments))}`,
3971
+ ` reason: ${issue.message}`
3972
+ ].join("\n");
3973
+ if (pathSegments[3] === "extensions") return [
3974
+ "Invalid Limina checker config:",
3975
+ ` field: ${checkerField}.extensions`,
3976
+ ` value: ${formatUnknownValue(getValueAtPath(value, pathSegments))}`,
3977
+ ` reason: ${issue.message}`
3978
+ ].join("\n");
3979
+ if (pathSegments[3] === "routes") return [
3980
+ "Invalid Limina checker config:",
3981
+ ` field: ${checkerField}.routes`,
3982
+ ` value: ${formatUnknownValue(getValueAtPath(value, pathSegments))}`,
3983
+ ` reason: ${issue.message}`
3984
+ ].join("\n");
3985
+ }
3986
+ if (field === "release") return [
3987
+ "Invalid Limina release config:",
3988
+ " field: release",
3989
+ ` value: ${formatUnknownValue(getValueAtPath(value, pathSegments))}`,
3990
+ " reason: release must be an object."
3991
+ ].join("\n");
3992
+ if (field === "release.contentHash") return [
3993
+ "Invalid Limina release config:",
3994
+ " field: release.contentHash",
3995
+ ` value: ${formatUnknownValue(getValueAtPath(value, pathSegments))}`,
3996
+ " reason: release.contentHash must be an object."
3997
+ ].join("\n");
3998
+ if (field === "release.contentHash.baselineTag") return [
3999
+ "Invalid Limina release config:",
4000
+ " field: release.contentHash.baselineTag",
4001
+ ` value: ${formatUnknownValue(getValueAtPath(value, pathSegments))}`,
4002
+ " reason: baselineTag must be a non-empty string or function."
4003
+ ].join("\n");
4004
+ if (field === "release.contentHash.builtinIgnore") return [
4005
+ "Invalid Limina release config:",
4006
+ " field: release.contentHash.builtinIgnore",
4007
+ ` value: ${formatUnknownValue(getValueAtPath(value, pathSegments))}`,
4008
+ " reason: builtinIgnore must be a boolean."
4009
+ ].join("\n");
4010
+ if (field === "release.contentHash.ignore") return [
4011
+ "Invalid Limina release config:",
4012
+ " field: release.contentHash.ignore",
4013
+ ` value: ${formatUnknownValue(getValueAtPath(value, pathSegments))}`,
4014
+ " reason: ignore must be an array of non-empty strings or function."
4015
+ ].join("\n");
4016
+ if (pathSegments[0] === "release" && pathSegments[1] === "contentHash" && pathSegments[2] === "ignore") return [
4017
+ "Invalid Limina release config:",
4018
+ ` field: ${field}`,
4019
+ ` value: ${formatUnknownValue(getValueAtPath(value, pathSegments))}`,
4020
+ " reason: ignore patterns must be non-empty strings."
4021
+ ].join("\n");
4022
+ return [
4023
+ "Invalid Limina config:",
4024
+ ` field: ${field}`,
4025
+ ` value: ${formatUnknownValue(getValueAtPath(value, pathSegments))}`,
4026
+ ` reason: ${issue.message}`
4027
+ ].join("\n");
4028
+ }
4029
+ function collectLiminaConfigShapeProblems(value) {
4030
+ const result = liminaConfigShapeSchema.safeParse(value);
4031
+ if (result.success) return [];
4032
+ return result.error.issues.map((issue) => formatLiminaConfigShapeIssue(value, issue));
4033
+ }
4034
+ function validateLiminaConfig(config) {
4035
+ const problems = collectLiminaConfigShapeProblems(config);
4036
+ if (problems.length > 0) throw new Error(problems.join("\n\n"));
4037
+ }
4038
+
4039
+ //#endregion
4040
+ //#region src/config/runner.ts
4041
+ function isAutoCheckerConfigMode(checkers) {
4042
+ return Boolean(checkers && checkers.mode === "auto");
4043
+ }
4044
+ function defineConfig(config) {
4045
+ return config;
4046
+ }
4047
+ function getActiveCheckers(config) {
4048
+ validateLiminaConfig(config);
4049
+ return getResolvedCheckers(config);
4050
+ }
4051
+ function normalizeConfig(value) {
4052
+ const config = value;
4053
+ validateLiminaConfig(config);
4054
+ return config;
4055
+ }
4056
+ function createConfigEnv(options) {
4057
+ return {
4058
+ command: options.command ?? "check",
4059
+ mode: options.mode ?? process.env.NODE_ENV ?? "default"
4060
+ };
4061
+ }
4062
+ function findPnpmWorkspaceRoot(startDir) {
4063
+ let currentDir = posix.resolve(startDir);
4064
+ while (true) {
4065
+ if (existsSync(posix.join(currentDir, "pnpm-workspace.yaml"))) return currentDir;
4066
+ const parentDir = posix.dirname(currentDir);
4067
+ if (parentDir === currentDir) return null;
4068
+ currentDir = parentDir;
4069
+ }
4070
+ }
4071
+ function findLiminaConfigPath(startDir, rootDir) {
4072
+ let currentDir = posix.resolve(startDir);
4073
+ const workspaceRootDir = posix.resolve(rootDir);
4074
+ while (isPathInsideDirectory(currentDir, workspaceRootDir)) {
4075
+ const candidatePath = posix.join(currentDir, "limina.config.mjs");
4076
+ if (existsSync(candidatePath)) return candidatePath;
4077
+ if (currentDir === workspaceRootDir) return null;
4078
+ const parentDir = posix.dirname(currentDir);
4079
+ if (parentDir === currentDir) return null;
4080
+ currentDir = parentDir;
4081
+ }
4082
+ return null;
4083
+ }
4084
+ function inferWorkspaceRoot(startDir) {
4085
+ const rootDir = findPnpmWorkspaceRoot(startDir);
4086
+ if (!rootDir) throw new Error([`Unable to infer Limina workspace root from ${startDir}:`, "no pnpm-workspace.yaml was found in this directory or its parents."].join(" "));
4087
+ return rootDir;
4088
+ }
4089
+ function validateConfigPathInsideWorkspace(configPath, rootDir) {
4090
+ if (isPathInsideDirectory(configPath, rootDir)) return;
4091
+ throw new Error([`Unable to load Limina config at ${configPath}:`, `config file must be inside the governed pnpm workspace at ${rootDir}.`].join(" "));
4092
+ }
4093
+ async function resolveConfigExport(configExport, configEnv) {
4094
+ return normalizeConfig(typeof configExport === "function" ? await configExport(configEnv) : await configExport);
4095
+ }
4096
+ function hasSourceImportAuthorityPackageRules(config) {
4097
+ return Boolean(config.source?.importAuthority?.allow?.some((rule) => rule.packages?.some((packageName) => packageName.trim().length > 0)));
4098
+ }
4099
+ function validateRootPackageImportAuthorityConfig(config, rootDir) {
4100
+ if (!hasSourceImportAuthorityPackageRules(config)) return;
4101
+ if (existsSync(posix.join(rootDir, "package.json"))) return;
4102
+ throw new Error([
4103
+ "Invalid Limina source config:",
4104
+ " field: source.importAuthority.allow[].packages",
4105
+ ` value: ${JSON.stringify(config.source?.importAuthority?.allow)}`,
4106
+ " reason: package allow rules enable workspace root package.json as a dependency authority manifest, but no package.json exists at the workspace root."
4107
+ ].join("\n"));
4108
+ }
4109
+ async function loadConfig(options = {}) {
4110
+ const cwd = options.cwd ? posix.resolve(options.cwd) : process.cwd();
4111
+ const rootDir = inferWorkspaceRoot(cwd);
4112
+ const configPath = options.configPath ? posix.resolve(cwd, options.configPath) : findLiminaConfigPath(cwd, rootDir);
4113
+ if (configPath) validateConfigPathInsideWorkspace(configPath, rootDir);
4114
+ if (!configPath || !existsSync(configPath)) throw new Error(options.configPath ? `Unable to find limina config at ${configPath}` : `Unable to find limina config. Searched for limina.config.mjs from ${cwd} up to the pnpm workspace root at ${rootDir}.`);
4115
+ const config = await resolveConfigExport((await import(`${pathToFileURL(configPath).href}?t=${Date.now()}`)).default, createConfigEnv(options));
4116
+ validateRootPackageImportAuthorityConfig(config, rootDir);
4117
+ return {
4118
+ ...config,
4119
+ configPath,
4120
+ rootDir
4121
+ };
4122
+ }
4123
+
4124
+ //#endregion
4125
+ export { isRelativeSpecifier as A, isPathInsideDirectory as C, toRelativePath as D, toPosixPath as E, uniqueSortedStrings as F, uniqueTrimmedNonEmptySortedStrings as I, uniqueValues as L, isVirtualModuleSpecifier as M, posix as N, isBarePackageSpecifier as O, uniqueBy as P, resolveRelativeModuleCandidate as S, normalizeSlashes as T, resolveModuleNameWithCheckers as _, formatUnknownValue as a, resolveExistingFilePath as b, clearCheckerProjectConfigCache as c, getBuildCheckerSupportedExtensions as d, getCheckerAdapter as f, resolveCheckerProjectExtensions as g, parseCheckerProjectConfigForContext as h, loadConfig as i, isUrlOrDataOrFileSpecifier as j, isPackageImportSpecifier as k, collectMissingCheckerPeerDependencies as l, normalizeExtensions as m, getActiveCheckers as n, isNonEmptyString as o, getCheckerExtensions as p, isAutoCheckerConfigMode as r, isPlainRecord as s, defineConfig as t, formatMissingCheckerPeerDependencies as u, candidatePathsForBasePath as v, normalizeAbsolutePath as w, resolvePathMappedModuleCandidate as x, resolveBaseUrlModuleCandidate as y };