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