@vscode/web-editors 0.0.2-0

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