@opentabs-dev/opentabs-plugin-temporal-cloud 0.0.89 → 0.0.90

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.
@@ -6,530 +6,6 @@
6
6
  __defProp(target, name, { get: all[name], enumerable: true });
7
7
  };
8
8
 
9
- // node_modules/@opentabs-dev/shared/dist/error.js
10
- var toErrorMessage = (err2) => err2 instanceof Error ? err2.message : String(err2);
11
-
12
- // node_modules/@opentabs-dev/plugin-sdk/dist/errors.js
13
- var ToolError = class _ToolError extends Error {
14
- code;
15
- /** Whether this error is retryable (defaults to false). */
16
- retryable;
17
- /** Suggested delay before retrying, in milliseconds. */
18
- retryAfterMs;
19
- /** Error category for structured error classification. */
20
- category;
21
- constructor(message, code, opts) {
22
- super(message);
23
- this.code = code;
24
- this.name = "ToolError";
25
- this.retryable = opts?.retryable ?? false;
26
- this.retryAfterMs = opts?.retryAfterMs;
27
- this.category = opts?.category;
28
- }
29
- /** Authentication or authorization error (not retryable). Accepts an optional domain-specific code. */
30
- static auth(message, code) {
31
- return new _ToolError(message, code ?? "AUTH_ERROR", { category: "auth", retryable: false });
32
- }
33
- /** Resource not found (not retryable). Accepts an optional domain-specific code. */
34
- static notFound(message, code) {
35
- return new _ToolError(message, code ?? "NOT_FOUND", { category: "not_found", retryable: false });
36
- }
37
- /** Rate limited (retryable). Accepts an optional retry delay in milliseconds and an optional domain-specific code. */
38
- static rateLimited(message, retryAfterMs, code) {
39
- return new _ToolError(message, code ?? "RATE_LIMITED", { category: "rate_limit", retryable: true, retryAfterMs });
40
- }
41
- /** Input validation error (not retryable). Accepts an optional domain-specific code. */
42
- static validation(message, code) {
43
- return new _ToolError(message, code ?? "VALIDATION_ERROR", { category: "validation", retryable: false });
44
- }
45
- /** Operation timed out (retryable). Accepts an optional domain-specific code. */
46
- static timeout(message, code) {
47
- return new _ToolError(message, code ?? "TIMEOUT", { category: "timeout", retryable: true });
48
- }
49
- /** Internal/unexpected error (not retryable). Accepts an optional domain-specific code. */
50
- static internal(message, code) {
51
- return new _ToolError(message, code ?? "INTERNAL_ERROR", { category: "internal", retryable: false });
52
- }
53
- };
54
-
55
- // node_modules/@opentabs-dev/plugin-sdk/dist/fetch.js
56
- var MAX_ERROR_BODY_LENGTH = 512;
57
- var httpStatusToToolError = (response, message) => {
58
- const status = response.status;
59
- if (status === 401 || status === 403) {
60
- return ToolError.auth(message);
61
- }
62
- if (status === 404) {
63
- return ToolError.notFound(message);
64
- }
65
- if (status === 429) {
66
- const retryAfter = response.headers.get("Retry-After");
67
- const retryAfterMs = retryAfter !== null ? parseRetryAfterMs(retryAfter) : void 0;
68
- return ToolError.rateLimited(message, retryAfterMs);
69
- }
70
- if (status === 400 || status === 422) {
71
- return ToolError.validation(message);
72
- }
73
- if (status === 408) {
74
- return ToolError.timeout(message);
75
- }
76
- if (status >= 500) {
77
- const TRANSIENT_5XX = /* @__PURE__ */ new Set([500, 502, 503, 504]);
78
- const retryable = TRANSIENT_5XX.has(status);
79
- const retryAfter = status === 503 ? response.headers.get("Retry-After") : null;
80
- const retryAfterMs = retryAfter !== null ? parseRetryAfterMs(retryAfter) : void 0;
81
- return new ToolError(message, "http_error", { category: "internal", retryable, retryAfterMs });
82
- }
83
- if (status >= 400 && status < 500) {
84
- return new ToolError(message, "http_error", { retryable: false });
85
- }
86
- return new ToolError(message, "http_error", { category: "internal" });
87
- };
88
- var parseRetryAfterMs = (value) => {
89
- const seconds = Number(value);
90
- if (!Number.isNaN(seconds) && seconds >= 0) {
91
- return seconds * 1e3;
92
- }
93
- const date5 = Date.parse(value);
94
- if (!Number.isNaN(date5)) {
95
- const ms = date5 - Date.now();
96
- return ms > 0 ? ms : void 0;
97
- }
98
- return void 0;
99
- };
100
- var buildQueryString = (params) => {
101
- const searchParams = new URLSearchParams();
102
- for (const [key, value] of Object.entries(params)) {
103
- if (value === void 0)
104
- continue;
105
- if (Array.isArray(value)) {
106
- for (const item of value) {
107
- searchParams.append(key, String(item));
108
- }
109
- } else {
110
- searchParams.append(key, String(value));
111
- }
112
- }
113
- return searchParams.toString();
114
- };
115
- var fetchFromPage = async (url2, init) => {
116
- const { timeout = 3e4, signal, ...rest } = init ?? {};
117
- const timeoutSignal = AbortSignal.timeout(timeout);
118
- const combinedSignal = signal ? AbortSignal.any([signal, timeoutSignal]) : timeoutSignal;
119
- let response;
120
- try {
121
- response = await fetch(url2, {
122
- credentials: "include",
123
- ...rest,
124
- signal: combinedSignal
125
- });
126
- } catch (error51) {
127
- if (error51 instanceof DOMException && error51.name === "TimeoutError") {
128
- throw ToolError.timeout(`fetchFromPage: request timed out after ${timeout}ms for ${url2}`);
129
- }
130
- if (combinedSignal.aborted) {
131
- throw new ToolError(`fetchFromPage: request aborted for ${url2}`, "aborted");
132
- }
133
- throw new ToolError(`fetchFromPage: network error for ${url2}: ${toErrorMessage(error51)}`, "network_error", {
134
- category: "internal",
135
- retryable: true
136
- });
137
- }
138
- if (!response.ok) {
139
- const rawText = await response.text().catch(() => response.statusText);
140
- const errorText = rawText.length > MAX_ERROR_BODY_LENGTH ? `${rawText.slice(0, MAX_ERROR_BODY_LENGTH)}\u2026` : rawText;
141
- const msg = `fetchFromPage: HTTP ${response.status} for ${url2}: ${errorText}`;
142
- throw httpStatusToToolError(response, msg);
143
- }
144
- return response;
145
- };
146
- var fetchJSONImpl = async (url2, init, schema) => {
147
- const response = await fetchFromPage(url2, init);
148
- let data;
149
- if (response.status === 204 || response.headers.get("content-length") === "0") {
150
- if (!schema) {
151
- return void 0;
152
- }
153
- throw ToolError.validation(`fetchJSON: expected JSON response from ${url2} but received HTTP ${response.status} with no body to validate`);
154
- } else {
155
- try {
156
- data = await response.json();
157
- } catch {
158
- throw ToolError.validation(`fetchJSON: failed to parse JSON response from ${url2}`);
159
- }
160
- }
161
- if (schema) {
162
- const result = schema.safeParse(data);
163
- if (!result.success) {
164
- throw ToolError.validation(`fetchJSON: response from ${url2} failed schema validation: ${result.error.message}`);
165
- }
166
- return result.data;
167
- }
168
- return data;
169
- };
170
- var fetchJSON = fetchJSONImpl;
171
-
172
- // node_modules/@opentabs-dev/plugin-sdk/dist/timing.js
173
- var waitUntil = (predicate, opts) => {
174
- const interval = opts?.interval ?? 200;
175
- const timeout = opts?.timeout ?? 1e4;
176
- const signal = opts?.signal;
177
- const abortReason = () => signal?.reason instanceof Error ? signal.reason : new Error("waitUntil: aborted");
178
- if (signal?.aborted)
179
- return Promise.reject(abortReason());
180
- return new Promise((resolve, reject) => {
181
- let settled = false;
182
- let poller;
183
- let lastPredicateError;
184
- const isSettled = () => settled;
185
- const cleanup = () => {
186
- settled = true;
187
- clearTimeout(timer);
188
- clearTimeout(poller);
189
- signal?.removeEventListener("abort", onAbort);
190
- };
191
- const onAbort = () => {
192
- if (isSettled())
193
- return;
194
- cleanup();
195
- reject(abortReason());
196
- };
197
- signal?.addEventListener("abort", onAbort, { once: true });
198
- const timer = setTimeout(() => {
199
- if (isSettled())
200
- return;
201
- cleanup();
202
- const errorContext = lastPredicateError instanceof Error ? `: predicate last threw \u2014 ${lastPredicateError.message}` : "";
203
- reject(new Error(`waitUntil: timed out after ${timeout}ms waiting for predicate to return true${errorContext}`));
204
- }, timeout);
205
- const check2 = async () => {
206
- if (isSettled())
207
- return;
208
- try {
209
- const result = await predicate();
210
- if (result) {
211
- cleanup();
212
- resolve();
213
- return;
214
- }
215
- } catch (err2) {
216
- lastPredicateError = err2;
217
- }
218
- if (!isSettled()) {
219
- poller = setTimeout(() => void check2(), interval);
220
- }
221
- };
222
- void check2();
223
- });
224
- };
225
-
226
- // node_modules/@opentabs-dev/plugin-sdk/dist/log.js
227
- var MAX_DATA_LENGTH = 10;
228
- var MAX_STRING_LENGTH = 4096;
229
- var MAX_SERIALIZED_SIZE = 64 * 1024;
230
- var safeSerializeArg = (value) => {
231
- try {
232
- if (value === null || value === void 0)
233
- return value;
234
- const type = typeof value;
235
- if (type === "boolean" || type === "number")
236
- return value;
237
- if (type === "string") {
238
- return value.length > MAX_STRING_LENGTH ? `${value.slice(0, MAX_STRING_LENGTH)}\u2026` : value;
239
- }
240
- if (type === "function")
241
- return `[Function: ${value.name || "anonymous"}]`;
242
- if (type === "symbol")
243
- return `[Symbol: ${value.description ?? ""}]`;
244
- if (type === "bigint")
245
- return `[BigInt: ${value.toString()}]`;
246
- if (typeof value.nodeType === "number" && typeof value.nodeName === "string") {
247
- try {
248
- const node = value;
249
- let classStr = "";
250
- if (typeof node.className === "string") {
251
- classStr = node.className ? `.${node.className.split(" ")[0] ?? ""}` : "";
252
- } else if (node.className !== null && typeof node.className === "object") {
253
- const baseVal = node.className.baseVal;
254
- if (typeof baseVal === "string") {
255
- classStr = baseVal ? `.${baseVal.split(" ")[0] ?? ""}` : "";
256
- }
257
- }
258
- return `[${node.nodeName}${node.id ? `#${node.id}` : ""}${classStr}]`;
259
- } catch {
260
- }
261
- }
262
- if (value instanceof Error) {
263
- return { name: value.name, message: value.message, stack: value.stack };
264
- }
265
- if (value instanceof WeakRef)
266
- return "[WeakRef]";
267
- if (value instanceof WeakMap)
268
- return "[WeakMap]";
269
- if (value instanceof WeakSet)
270
- return "[WeakSet]";
271
- if (value instanceof ArrayBuffer)
272
- return "[ArrayBuffer]";
273
- if (typeof SharedArrayBuffer !== "undefined" && value instanceof SharedArrayBuffer)
274
- return "[SharedArrayBuffer]";
275
- try {
276
- const seen = /* @__PURE__ */ new WeakSet();
277
- const json2 = JSON.stringify(value, (_key, v) => {
278
- if (typeof v === "object" && v !== null) {
279
- if (seen.has(v))
280
- return "[Circular]";
281
- seen.add(v);
282
- }
283
- if (typeof v === "function")
284
- return `[Function: ${v.name || "anonymous"}]`;
285
- if (typeof v === "bigint")
286
- return `[BigInt: ${v.toString()}]`;
287
- if (typeof v === "symbol")
288
- return `[Symbol: ${v.description ?? ""}]`;
289
- if (v instanceof WeakRef)
290
- return "[WeakRef]";
291
- if (v instanceof WeakMap)
292
- return "[WeakMap]";
293
- if (v instanceof WeakSet)
294
- return "[WeakSet]";
295
- if (v instanceof ArrayBuffer)
296
- return "[ArrayBuffer]";
297
- if (typeof SharedArrayBuffer !== "undefined" && v instanceof SharedArrayBuffer)
298
- return "[SharedArrayBuffer]";
299
- return v;
300
- });
301
- if (json2.length > MAX_SERIALIZED_SIZE) {
302
- return `[Object truncated: ${json2.length} chars]`;
303
- }
304
- return JSON.parse(json2);
305
- } catch {
306
- return `[Unserializable: ${typeof value}]`;
307
- }
308
- } catch {
309
- return `[Unserializable: ${typeof value}]`;
310
- }
311
- };
312
- var safeSerialize = (args) => {
313
- const capped = args.length > MAX_DATA_LENGTH ? args.slice(0, MAX_DATA_LENGTH) : args;
314
- return capped.map(safeSerializeArg);
315
- };
316
- var CONSOLE_METHODS = {
317
- debug: "debug",
318
- info: "info",
319
- warning: "warn",
320
- error: "error"
321
- };
322
- var defaultTransport = (entry) => {
323
- const method = CONSOLE_METHODS[entry.level];
324
- console[method](`[sdk.log] ${entry.message}`, ...entry.data);
325
- };
326
- var activeTransport = defaultTransport;
327
- var _setLogTransport = (transport) => {
328
- const previous = activeTransport;
329
- activeTransport = transport;
330
- return () => {
331
- if (activeTransport === transport)
332
- activeTransport = previous;
333
- };
334
- };
335
- var makeLogMethod = (level) => (message, ...args) => {
336
- const entry = {
337
- level,
338
- message,
339
- data: safeSerialize(args),
340
- ts: (/* @__PURE__ */ new Date()).toISOString()
341
- };
342
- activeTransport(entry);
343
- };
344
- var log = Object.freeze({
345
- debug: makeLogMethod("debug"),
346
- info: makeLogMethod("info"),
347
- warn: makeLogMethod("warning"),
348
- error: makeLogMethod("error")
349
- });
350
- var ot = globalThis.__openTabs ?? {};
351
- globalThis.__openTabs = ot;
352
- ot._setLogTransport = _setLogTransport;
353
- ot.log = log;
354
-
355
- // node_modules/@opentabs-dev/plugin-sdk/dist/storage.js
356
- var withIframeFallback = (fn) => {
357
- try {
358
- const iframe = document.createElement("iframe");
359
- iframe.style.display = "none";
360
- document.body.appendChild(iframe);
361
- try {
362
- const iframeStorage = iframe.contentWindow?.localStorage;
363
- return iframeStorage ? fn(iframeStorage) : null;
364
- } finally {
365
- document.body.removeChild(iframe);
366
- }
367
- } catch {
368
- return null;
369
- }
370
- };
371
- var getWindowLocalStorage = () => window.localStorage;
372
- var findLocalStorageEntry = (predicate) => {
373
- const search = (storage2) => {
374
- for (let i = 0; i < storage2.length; i++) {
375
- const key = storage2.key(i);
376
- if (key !== null && predicate(key)) {
377
- const value = storage2.getItem(key);
378
- if (value !== null)
379
- return { key, value };
380
- }
381
- }
382
- return null;
383
- };
384
- let storage;
385
- try {
386
- storage = getWindowLocalStorage();
387
- } catch {
388
- return null;
389
- }
390
- if (storage) {
391
- try {
392
- return search(storage);
393
- } catch {
394
- return null;
395
- }
396
- }
397
- return withIframeFallback((s) => search(s));
398
- };
399
- var getAuthCache = (namespace) => {
400
- try {
401
- const ns = globalThis.__openTabs;
402
- const cache = ns?.tokenCache;
403
- return cache?.[namespace] ?? null;
404
- } catch {
405
- return null;
406
- }
407
- };
408
- var setAuthCache = (namespace, value) => {
409
- try {
410
- const g = globalThis;
411
- if (!g.__openTabs)
412
- g.__openTabs = {};
413
- const ns = g.__openTabs;
414
- if (!ns.tokenCache)
415
- ns.tokenCache = {};
416
- ns.tokenCache[namespace] = value;
417
- } catch {
418
- }
419
- };
420
- var clearAuthCache = (namespace) => {
421
- try {
422
- const ns = globalThis.__openTabs;
423
- const cache = ns?.tokenCache;
424
- if (cache)
425
- cache[namespace] = void 0;
426
- } catch {
427
- }
428
- };
429
-
430
- // node_modules/@opentabs-dev/plugin-sdk/dist/page-state.js
431
- var getCurrentUrl = () => window.location.href;
432
-
433
- // node_modules/@opentabs-dev/plugin-sdk/dist/index.js
434
- var defineTool = (config2) => config2;
435
- var OpenTabsPlugin = class {
436
- /**
437
- * Chrome match patterns for URLs that should NOT match this plugin.
438
- * Tabs matching both urlPatterns and excludePatterns are excluded.
439
- * Useful when a broad urlPattern overlaps with another plugin's domain.
440
- * @see https://developer.chrome.com/docs/extensions/develop/concepts/match-patterns
441
- */
442
- excludePatterns;
443
- /**
444
- * URL to open when no matching tab exists and the user triggers an
445
- * 'open tab' action from the side panel. Should be a concrete URL
446
- * (e.g., 'https://github.com'), not a match pattern.
447
- */
448
- homepage;
449
- /** Typed configuration schema — declares settings that users provide via config.json or the side panel. */
450
- configSchema;
451
- };
452
-
453
- // src/temporal-api.ts
454
- var AUTH0_CLIENT_ID = "nTmmPY5xUpQnSr7gRZh7s33hNamtCeDg";
455
- var AUTH0_AUDIENCE = "https://saas-api.tmprl.cloud";
456
- var getToken = () => {
457
- const entry = findLocalStorageEntry(
458
- (key) => key.startsWith(`@@auth0spajs@@::${AUTH0_CLIENT_ID}::`) && key.includes(AUTH0_AUDIENCE)
459
- );
460
- if (!entry) return null;
461
- try {
462
- const data = JSON.parse(entry.value);
463
- if (!data.body?.access_token) return null;
464
- if (data.expiresAt && data.expiresAt < Math.floor(Date.now() / 1e3)) return null;
465
- return data.body.access_token;
466
- } catch {
467
- return null;
468
- }
469
- };
470
- var getAuth = () => {
471
- const freshToken = getToken();
472
- if (freshToken) {
473
- const cached2 = getAuthCache("temporal-cloud");
474
- if (cached2?.token === freshToken) return cached2;
475
- const auth = { token: freshToken };
476
- setAuthCache("temporal-cloud", auth);
477
- return auth;
478
- }
479
- clearAuthCache("temporal-cloud");
480
- return null;
481
- };
482
- var isAuthenticated = () => getAuth() !== null;
483
- var waitForAuth = async () => {
484
- try {
485
- await waitUntil(() => isAuthenticated(), { interval: 500, timeout: 5e3 });
486
- return true;
487
- } catch {
488
- return false;
489
- }
490
- };
491
- var getDefaultNamespace = () => {
492
- const url2 = getCurrentUrl();
493
- const match = url2.match(/\/namespaces\/([^/]+)/);
494
- if (match?.[1]) return match[1];
495
- const hostMatch = url2.match(/^https?:\/\/([^.]+)\.web\.tmprl\.cloud/);
496
- return hostMatch?.[1] ?? null;
497
- };
498
- var resolveNamespace = (namespace) => {
499
- const ns = namespace || getDefaultNamespace();
500
- if (!ns) {
501
- throw ToolError.validation(
502
- "No namespace specified and none detected from the current page URL. Pass a namespace parameter explicitly."
503
- );
504
- }
505
- return ns;
506
- };
507
- var api = async (namespace, path, query) => {
508
- const auth = getAuth();
509
- if (!auth)
510
- throw ToolError.auth(
511
- "Not authenticated \u2014 token may have expired. Please refresh the Temporal Cloud page to obtain a new token."
512
- );
513
- const baseUrl = `https://${namespace}.web.tmprl.cloud/api/v1`;
514
- const qs = query ? buildQueryString(query) : "";
515
- const url2 = qs ? `${baseUrl}${path}?${qs}` : `${baseUrl}${path}`;
516
- try {
517
- const result = await fetchJSON(url2, {
518
- method: "GET",
519
- headers: { Authorization: `Bearer ${auth.token}` }
520
- });
521
- return result;
522
- } catch (err2) {
523
- if (err2 instanceof ToolError) {
524
- if (err2.category === "auth") {
525
- clearAuthCache("temporal-cloud");
526
- }
527
- throw err2;
528
- }
529
- throw ToolError.internal(`Temporal API error: ${err2 instanceof Error ? err2.message : String(err2)}`);
530
- }
531
- };
532
-
533
9
  // node_modules/zod/v4/classic/external.js
534
10
  var external_exports = {};
535
11
  __export(external_exports, {
@@ -13634,1415 +13110,1939 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
13634
13110
  $ZodJWT.init(inst, def);
13635
13111
  ZodStringFormat.init(inst, def);
13636
13112
  });
13637
- function jwt(params) {
13638
- return _jwt(ZodJWT, params);
13113
+ function jwt(params) {
13114
+ return _jwt(ZodJWT, params);
13115
+ }
13116
+ var ZodCustomStringFormat = /* @__PURE__ */ $constructor("ZodCustomStringFormat", (inst, def) => {
13117
+ $ZodCustomStringFormat.init(inst, def);
13118
+ ZodStringFormat.init(inst, def);
13119
+ });
13120
+ function stringFormat(format, fnOrRegex, _params = {}) {
13121
+ return _stringFormat(ZodCustomStringFormat, format, fnOrRegex, _params);
13122
+ }
13123
+ function hostname2(_params) {
13124
+ return _stringFormat(ZodCustomStringFormat, "hostname", regexes_exports.hostname, _params);
13125
+ }
13126
+ function hex2(_params) {
13127
+ return _stringFormat(ZodCustomStringFormat, "hex", regexes_exports.hex, _params);
13128
+ }
13129
+ function hash(alg, params) {
13130
+ const enc = params?.enc ?? "hex";
13131
+ const format = `${alg}_${enc}`;
13132
+ const regex = regexes_exports[format];
13133
+ if (!regex)
13134
+ throw new Error(`Unrecognized hash format: ${format}`);
13135
+ return _stringFormat(ZodCustomStringFormat, format, regex, params);
13136
+ }
13137
+ var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
13138
+ $ZodNumber.init(inst, def);
13139
+ ZodType.init(inst, def);
13140
+ inst._zod.processJSONSchema = (ctx, json2, params) => numberProcessor(inst, ctx, json2, params);
13141
+ _installLazyMethods(inst, "ZodNumber", {
13142
+ gt(value, params) {
13143
+ return this.check(_gt(value, params));
13144
+ },
13145
+ gte(value, params) {
13146
+ return this.check(_gte(value, params));
13147
+ },
13148
+ min(value, params) {
13149
+ return this.check(_gte(value, params));
13150
+ },
13151
+ lt(value, params) {
13152
+ return this.check(_lt(value, params));
13153
+ },
13154
+ lte(value, params) {
13155
+ return this.check(_lte(value, params));
13156
+ },
13157
+ max(value, params) {
13158
+ return this.check(_lte(value, params));
13159
+ },
13160
+ int(params) {
13161
+ return this.check(int(params));
13162
+ },
13163
+ safe(params) {
13164
+ return this.check(int(params));
13165
+ },
13166
+ positive(params) {
13167
+ return this.check(_gt(0, params));
13168
+ },
13169
+ nonnegative(params) {
13170
+ return this.check(_gte(0, params));
13171
+ },
13172
+ negative(params) {
13173
+ return this.check(_lt(0, params));
13174
+ },
13175
+ nonpositive(params) {
13176
+ return this.check(_lte(0, params));
13177
+ },
13178
+ multipleOf(value, params) {
13179
+ return this.check(_multipleOf(value, params));
13180
+ },
13181
+ step(value, params) {
13182
+ return this.check(_multipleOf(value, params));
13183
+ },
13184
+ finite() {
13185
+ return this;
13186
+ }
13187
+ });
13188
+ const bag = inst._zod.bag;
13189
+ inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
13190
+ inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
13191
+ inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
13192
+ inst.isFinite = true;
13193
+ inst.format = bag.format ?? null;
13194
+ });
13195
+ function number2(params) {
13196
+ return _number(ZodNumber, params);
13197
+ }
13198
+ var ZodNumberFormat = /* @__PURE__ */ $constructor("ZodNumberFormat", (inst, def) => {
13199
+ $ZodNumberFormat.init(inst, def);
13200
+ ZodNumber.init(inst, def);
13201
+ });
13202
+ function int(params) {
13203
+ return _int(ZodNumberFormat, params);
13204
+ }
13205
+ function float32(params) {
13206
+ return _float32(ZodNumberFormat, params);
13207
+ }
13208
+ function float64(params) {
13209
+ return _float64(ZodNumberFormat, params);
13210
+ }
13211
+ function int32(params) {
13212
+ return _int32(ZodNumberFormat, params);
13213
+ }
13214
+ function uint32(params) {
13215
+ return _uint32(ZodNumberFormat, params);
13216
+ }
13217
+ var ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
13218
+ $ZodBoolean.init(inst, def);
13219
+ ZodType.init(inst, def);
13220
+ inst._zod.processJSONSchema = (ctx, json2, params) => booleanProcessor(inst, ctx, json2, params);
13221
+ });
13222
+ function boolean2(params) {
13223
+ return _boolean(ZodBoolean, params);
13224
+ }
13225
+ var ZodBigInt = /* @__PURE__ */ $constructor("ZodBigInt", (inst, def) => {
13226
+ $ZodBigInt.init(inst, def);
13227
+ ZodType.init(inst, def);
13228
+ inst._zod.processJSONSchema = (ctx, json2, params) => bigintProcessor(inst, ctx, json2, params);
13229
+ inst.gte = (value, params) => inst.check(_gte(value, params));
13230
+ inst.min = (value, params) => inst.check(_gte(value, params));
13231
+ inst.gt = (value, params) => inst.check(_gt(value, params));
13232
+ inst.gte = (value, params) => inst.check(_gte(value, params));
13233
+ inst.min = (value, params) => inst.check(_gte(value, params));
13234
+ inst.lt = (value, params) => inst.check(_lt(value, params));
13235
+ inst.lte = (value, params) => inst.check(_lte(value, params));
13236
+ inst.max = (value, params) => inst.check(_lte(value, params));
13237
+ inst.positive = (params) => inst.check(_gt(BigInt(0), params));
13238
+ inst.negative = (params) => inst.check(_lt(BigInt(0), params));
13239
+ inst.nonpositive = (params) => inst.check(_lte(BigInt(0), params));
13240
+ inst.nonnegative = (params) => inst.check(_gte(BigInt(0), params));
13241
+ inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
13242
+ const bag = inst._zod.bag;
13243
+ inst.minValue = bag.minimum ?? null;
13244
+ inst.maxValue = bag.maximum ?? null;
13245
+ inst.format = bag.format ?? null;
13246
+ });
13247
+ function bigint2(params) {
13248
+ return _bigint(ZodBigInt, params);
13249
+ }
13250
+ var ZodBigIntFormat = /* @__PURE__ */ $constructor("ZodBigIntFormat", (inst, def) => {
13251
+ $ZodBigIntFormat.init(inst, def);
13252
+ ZodBigInt.init(inst, def);
13253
+ });
13254
+ function int64(params) {
13255
+ return _int64(ZodBigIntFormat, params);
13256
+ }
13257
+ function uint64(params) {
13258
+ return _uint64(ZodBigIntFormat, params);
13259
+ }
13260
+ var ZodSymbol = /* @__PURE__ */ $constructor("ZodSymbol", (inst, def) => {
13261
+ $ZodSymbol.init(inst, def);
13262
+ ZodType.init(inst, def);
13263
+ inst._zod.processJSONSchema = (ctx, json2, params) => symbolProcessor(inst, ctx, json2, params);
13264
+ });
13265
+ function symbol(params) {
13266
+ return _symbol(ZodSymbol, params);
13267
+ }
13268
+ var ZodUndefined = /* @__PURE__ */ $constructor("ZodUndefined", (inst, def) => {
13269
+ $ZodUndefined.init(inst, def);
13270
+ ZodType.init(inst, def);
13271
+ inst._zod.processJSONSchema = (ctx, json2, params) => undefinedProcessor(inst, ctx, json2, params);
13272
+ });
13273
+ function _undefined3(params) {
13274
+ return _undefined2(ZodUndefined, params);
13275
+ }
13276
+ var ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
13277
+ $ZodNull.init(inst, def);
13278
+ ZodType.init(inst, def);
13279
+ inst._zod.processJSONSchema = (ctx, json2, params) => nullProcessor(inst, ctx, json2, params);
13280
+ });
13281
+ function _null3(params) {
13282
+ return _null2(ZodNull, params);
13283
+ }
13284
+ var ZodAny = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
13285
+ $ZodAny.init(inst, def);
13286
+ ZodType.init(inst, def);
13287
+ inst._zod.processJSONSchema = (ctx, json2, params) => anyProcessor(inst, ctx, json2, params);
13288
+ });
13289
+ function any() {
13290
+ return _any(ZodAny);
13291
+ }
13292
+ var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
13293
+ $ZodUnknown.init(inst, def);
13294
+ ZodType.init(inst, def);
13295
+ inst._zod.processJSONSchema = (ctx, json2, params) => unknownProcessor(inst, ctx, json2, params);
13296
+ });
13297
+ function unknown() {
13298
+ return _unknown(ZodUnknown);
13299
+ }
13300
+ var ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
13301
+ $ZodNever.init(inst, def);
13302
+ ZodType.init(inst, def);
13303
+ inst._zod.processJSONSchema = (ctx, json2, params) => neverProcessor(inst, ctx, json2, params);
13304
+ });
13305
+ function never(params) {
13306
+ return _never(ZodNever, params);
13307
+ }
13308
+ var ZodVoid = /* @__PURE__ */ $constructor("ZodVoid", (inst, def) => {
13309
+ $ZodVoid.init(inst, def);
13310
+ ZodType.init(inst, def);
13311
+ inst._zod.processJSONSchema = (ctx, json2, params) => voidProcessor(inst, ctx, json2, params);
13312
+ });
13313
+ function _void2(params) {
13314
+ return _void(ZodVoid, params);
13639
13315
  }
13640
- var ZodCustomStringFormat = /* @__PURE__ */ $constructor("ZodCustomStringFormat", (inst, def) => {
13641
- $ZodCustomStringFormat.init(inst, def);
13642
- ZodStringFormat.init(inst, def);
13316
+ var ZodDate = /* @__PURE__ */ $constructor("ZodDate", (inst, def) => {
13317
+ $ZodDate.init(inst, def);
13318
+ ZodType.init(inst, def);
13319
+ inst._zod.processJSONSchema = (ctx, json2, params) => dateProcessor(inst, ctx, json2, params);
13320
+ inst.min = (value, params) => inst.check(_gte(value, params));
13321
+ inst.max = (value, params) => inst.check(_lte(value, params));
13322
+ const c = inst._zod.bag;
13323
+ inst.minDate = c.minimum ? new Date(c.minimum) : null;
13324
+ inst.maxDate = c.maximum ? new Date(c.maximum) : null;
13643
13325
  });
13644
- function stringFormat(format, fnOrRegex, _params = {}) {
13645
- return _stringFormat(ZodCustomStringFormat, format, fnOrRegex, _params);
13646
- }
13647
- function hostname2(_params) {
13648
- return _stringFormat(ZodCustomStringFormat, "hostname", regexes_exports.hostname, _params);
13649
- }
13650
- function hex2(_params) {
13651
- return _stringFormat(ZodCustomStringFormat, "hex", regexes_exports.hex, _params);
13652
- }
13653
- function hash(alg, params) {
13654
- const enc = params?.enc ?? "hex";
13655
- const format = `${alg}_${enc}`;
13656
- const regex = regexes_exports[format];
13657
- if (!regex)
13658
- throw new Error(`Unrecognized hash format: ${format}`);
13659
- return _stringFormat(ZodCustomStringFormat, format, regex, params);
13326
+ function date3(params) {
13327
+ return _date(ZodDate, params);
13660
13328
  }
13661
- var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
13662
- $ZodNumber.init(inst, def);
13329
+ var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
13330
+ $ZodArray.init(inst, def);
13663
13331
  ZodType.init(inst, def);
13664
- inst._zod.processJSONSchema = (ctx, json2, params) => numberProcessor(inst, ctx, json2, params);
13665
- _installLazyMethods(inst, "ZodNumber", {
13666
- gt(value, params) {
13667
- return this.check(_gt(value, params));
13332
+ inst._zod.processJSONSchema = (ctx, json2, params) => arrayProcessor(inst, ctx, json2, params);
13333
+ inst.element = def.element;
13334
+ _installLazyMethods(inst, "ZodArray", {
13335
+ min(n, params) {
13336
+ return this.check(_minLength(n, params));
13668
13337
  },
13669
- gte(value, params) {
13670
- return this.check(_gte(value, params));
13338
+ nonempty(params) {
13339
+ return this.check(_minLength(1, params));
13671
13340
  },
13672
- min(value, params) {
13673
- return this.check(_gte(value, params));
13341
+ max(n, params) {
13342
+ return this.check(_maxLength(n, params));
13674
13343
  },
13675
- lt(value, params) {
13676
- return this.check(_lt(value, params));
13344
+ length(n, params) {
13345
+ return this.check(_length(n, params));
13677
13346
  },
13678
- lte(value, params) {
13679
- return this.check(_lte(value, params));
13347
+ unwrap() {
13348
+ return this.element;
13349
+ }
13350
+ });
13351
+ });
13352
+ function array(element, params) {
13353
+ return _array(ZodArray, element, params);
13354
+ }
13355
+ function keyof(schema) {
13356
+ const shape = schema._zod.def.shape;
13357
+ return _enum2(Object.keys(shape));
13358
+ }
13359
+ var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
13360
+ $ZodObjectJIT.init(inst, def);
13361
+ ZodType.init(inst, def);
13362
+ inst._zod.processJSONSchema = (ctx, json2, params) => objectProcessor(inst, ctx, json2, params);
13363
+ util_exports.defineLazy(inst, "shape", () => {
13364
+ return def.shape;
13365
+ });
13366
+ _installLazyMethods(inst, "ZodObject", {
13367
+ keyof() {
13368
+ return _enum2(Object.keys(this._zod.def.shape));
13680
13369
  },
13681
- max(value, params) {
13682
- return this.check(_lte(value, params));
13370
+ catchall(catchall) {
13371
+ return this.clone({ ...this._zod.def, catchall });
13683
13372
  },
13684
- int(params) {
13685
- return this.check(int(params));
13373
+ passthrough() {
13374
+ return this.clone({ ...this._zod.def, catchall: unknown() });
13686
13375
  },
13687
- safe(params) {
13688
- return this.check(int(params));
13376
+ loose() {
13377
+ return this.clone({ ...this._zod.def, catchall: unknown() });
13689
13378
  },
13690
- positive(params) {
13691
- return this.check(_gt(0, params));
13379
+ strict() {
13380
+ return this.clone({ ...this._zod.def, catchall: never() });
13692
13381
  },
13693
- nonnegative(params) {
13694
- return this.check(_gte(0, params));
13382
+ strip() {
13383
+ return this.clone({ ...this._zod.def, catchall: void 0 });
13695
13384
  },
13696
- negative(params) {
13697
- return this.check(_lt(0, params));
13385
+ extend(incoming) {
13386
+ return util_exports.extend(this, incoming);
13698
13387
  },
13699
- nonpositive(params) {
13700
- return this.check(_lte(0, params));
13388
+ safeExtend(incoming) {
13389
+ return util_exports.safeExtend(this, incoming);
13701
13390
  },
13702
- multipleOf(value, params) {
13703
- return this.check(_multipleOf(value, params));
13391
+ merge(other) {
13392
+ return util_exports.merge(this, other);
13704
13393
  },
13705
- step(value, params) {
13706
- return this.check(_multipleOf(value, params));
13394
+ pick(mask) {
13395
+ return util_exports.pick(this, mask);
13707
13396
  },
13708
- finite() {
13709
- return this;
13397
+ omit(mask) {
13398
+ return util_exports.omit(this, mask);
13399
+ },
13400
+ partial(...args) {
13401
+ return util_exports.partial(ZodOptional, this, args[0]);
13402
+ },
13403
+ required(...args) {
13404
+ return util_exports.required(ZodNonOptional, this, args[0]);
13710
13405
  }
13711
13406
  });
13712
- const bag = inst._zod.bag;
13713
- inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
13714
- inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
13715
- inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
13716
- inst.isFinite = true;
13717
- inst.format = bag.format ?? null;
13718
- });
13719
- function number2(params) {
13720
- return _number(ZodNumber, params);
13407
+ });
13408
+ function object(shape, params) {
13409
+ const def = {
13410
+ type: "object",
13411
+ shape: shape ?? {},
13412
+ ...util_exports.normalizeParams(params)
13413
+ };
13414
+ return new ZodObject(def);
13415
+ }
13416
+ function strictObject(shape, params) {
13417
+ return new ZodObject({
13418
+ type: "object",
13419
+ shape,
13420
+ catchall: never(),
13421
+ ...util_exports.normalizeParams(params)
13422
+ });
13423
+ }
13424
+ function looseObject(shape, params) {
13425
+ return new ZodObject({
13426
+ type: "object",
13427
+ shape,
13428
+ catchall: unknown(),
13429
+ ...util_exports.normalizeParams(params)
13430
+ });
13431
+ }
13432
+ var ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
13433
+ $ZodUnion.init(inst, def);
13434
+ ZodType.init(inst, def);
13435
+ inst._zod.processJSONSchema = (ctx, json2, params) => unionProcessor(inst, ctx, json2, params);
13436
+ inst.options = def.options;
13437
+ });
13438
+ function union(options, params) {
13439
+ return new ZodUnion({
13440
+ type: "union",
13441
+ options,
13442
+ ...util_exports.normalizeParams(params)
13443
+ });
13444
+ }
13445
+ var ZodXor = /* @__PURE__ */ $constructor("ZodXor", (inst, def) => {
13446
+ ZodUnion.init(inst, def);
13447
+ $ZodXor.init(inst, def);
13448
+ inst._zod.processJSONSchema = (ctx, json2, params) => unionProcessor(inst, ctx, json2, params);
13449
+ inst.options = def.options;
13450
+ });
13451
+ function xor(options, params) {
13452
+ return new ZodXor({
13453
+ type: "union",
13454
+ options,
13455
+ inclusive: false,
13456
+ ...util_exports.normalizeParams(params)
13457
+ });
13458
+ }
13459
+ var ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("ZodDiscriminatedUnion", (inst, def) => {
13460
+ ZodUnion.init(inst, def);
13461
+ $ZodDiscriminatedUnion.init(inst, def);
13462
+ });
13463
+ function discriminatedUnion(discriminator, options, params) {
13464
+ return new ZodDiscriminatedUnion({
13465
+ type: "union",
13466
+ options,
13467
+ discriminator,
13468
+ ...util_exports.normalizeParams(params)
13469
+ });
13470
+ }
13471
+ var ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
13472
+ $ZodIntersection.init(inst, def);
13473
+ ZodType.init(inst, def);
13474
+ inst._zod.processJSONSchema = (ctx, json2, params) => intersectionProcessor(inst, ctx, json2, params);
13475
+ });
13476
+ function intersection(left, right) {
13477
+ return new ZodIntersection({
13478
+ type: "intersection",
13479
+ left,
13480
+ right
13481
+ });
13482
+ }
13483
+ var ZodTuple = /* @__PURE__ */ $constructor("ZodTuple", (inst, def) => {
13484
+ $ZodTuple.init(inst, def);
13485
+ ZodType.init(inst, def);
13486
+ inst._zod.processJSONSchema = (ctx, json2, params) => tupleProcessor(inst, ctx, json2, params);
13487
+ inst.rest = (rest) => inst.clone({
13488
+ ...inst._zod.def,
13489
+ rest
13490
+ });
13491
+ });
13492
+ function tuple(items, _paramsOrRest, _params) {
13493
+ const hasRest = _paramsOrRest instanceof $ZodType;
13494
+ const params = hasRest ? _params : _paramsOrRest;
13495
+ const rest = hasRest ? _paramsOrRest : null;
13496
+ return new ZodTuple({
13497
+ type: "tuple",
13498
+ items,
13499
+ rest,
13500
+ ...util_exports.normalizeParams(params)
13501
+ });
13502
+ }
13503
+ var ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
13504
+ $ZodRecord.init(inst, def);
13505
+ ZodType.init(inst, def);
13506
+ inst._zod.processJSONSchema = (ctx, json2, params) => recordProcessor(inst, ctx, json2, params);
13507
+ inst.keyType = def.keyType;
13508
+ inst.valueType = def.valueType;
13509
+ });
13510
+ function record(keyType, valueType, params) {
13511
+ if (!valueType || !valueType._zod) {
13512
+ return new ZodRecord({
13513
+ type: "record",
13514
+ keyType: string2(),
13515
+ valueType: keyType,
13516
+ ...util_exports.normalizeParams(valueType)
13517
+ });
13518
+ }
13519
+ return new ZodRecord({
13520
+ type: "record",
13521
+ keyType,
13522
+ valueType,
13523
+ ...util_exports.normalizeParams(params)
13524
+ });
13525
+ }
13526
+ function partialRecord(keyType, valueType, params) {
13527
+ const k = clone(keyType);
13528
+ k._zod.values = void 0;
13529
+ return new ZodRecord({
13530
+ type: "record",
13531
+ keyType: k,
13532
+ valueType,
13533
+ ...util_exports.normalizeParams(params)
13534
+ });
13721
13535
  }
13722
- var ZodNumberFormat = /* @__PURE__ */ $constructor("ZodNumberFormat", (inst, def) => {
13723
- $ZodNumberFormat.init(inst, def);
13724
- ZodNumber.init(inst, def);
13725
- });
13726
- function int(params) {
13727
- return _int(ZodNumberFormat, params);
13536
+ function looseRecord(keyType, valueType, params) {
13537
+ return new ZodRecord({
13538
+ type: "record",
13539
+ keyType,
13540
+ valueType,
13541
+ mode: "loose",
13542
+ ...util_exports.normalizeParams(params)
13543
+ });
13728
13544
  }
13729
- function float32(params) {
13730
- return _float32(ZodNumberFormat, params);
13545
+ var ZodMap = /* @__PURE__ */ $constructor("ZodMap", (inst, def) => {
13546
+ $ZodMap.init(inst, def);
13547
+ ZodType.init(inst, def);
13548
+ inst._zod.processJSONSchema = (ctx, json2, params) => mapProcessor(inst, ctx, json2, params);
13549
+ inst.keyType = def.keyType;
13550
+ inst.valueType = def.valueType;
13551
+ inst.min = (...args) => inst.check(_minSize(...args));
13552
+ inst.nonempty = (params) => inst.check(_minSize(1, params));
13553
+ inst.max = (...args) => inst.check(_maxSize(...args));
13554
+ inst.size = (...args) => inst.check(_size(...args));
13555
+ });
13556
+ function map(keyType, valueType, params) {
13557
+ return new ZodMap({
13558
+ type: "map",
13559
+ keyType,
13560
+ valueType,
13561
+ ...util_exports.normalizeParams(params)
13562
+ });
13731
13563
  }
13732
- function float64(params) {
13733
- return _float64(ZodNumberFormat, params);
13564
+ var ZodSet = /* @__PURE__ */ $constructor("ZodSet", (inst, def) => {
13565
+ $ZodSet.init(inst, def);
13566
+ ZodType.init(inst, def);
13567
+ inst._zod.processJSONSchema = (ctx, json2, params) => setProcessor(inst, ctx, json2, params);
13568
+ inst.min = (...args) => inst.check(_minSize(...args));
13569
+ inst.nonempty = (params) => inst.check(_minSize(1, params));
13570
+ inst.max = (...args) => inst.check(_maxSize(...args));
13571
+ inst.size = (...args) => inst.check(_size(...args));
13572
+ });
13573
+ function set(valueType, params) {
13574
+ return new ZodSet({
13575
+ type: "set",
13576
+ valueType,
13577
+ ...util_exports.normalizeParams(params)
13578
+ });
13734
13579
  }
13735
- function int32(params) {
13736
- return _int32(ZodNumberFormat, params);
13580
+ var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
13581
+ $ZodEnum.init(inst, def);
13582
+ ZodType.init(inst, def);
13583
+ inst._zod.processJSONSchema = (ctx, json2, params) => enumProcessor(inst, ctx, json2, params);
13584
+ inst.enum = def.entries;
13585
+ inst.options = Object.values(def.entries);
13586
+ const keys = new Set(Object.keys(def.entries));
13587
+ inst.extract = (values, params) => {
13588
+ const newEntries = {};
13589
+ for (const value of values) {
13590
+ if (keys.has(value)) {
13591
+ newEntries[value] = def.entries[value];
13592
+ } else
13593
+ throw new Error(`Key ${value} not found in enum`);
13594
+ }
13595
+ return new ZodEnum({
13596
+ ...def,
13597
+ checks: [],
13598
+ ...util_exports.normalizeParams(params),
13599
+ entries: newEntries
13600
+ });
13601
+ };
13602
+ inst.exclude = (values, params) => {
13603
+ const newEntries = { ...def.entries };
13604
+ for (const value of values) {
13605
+ if (keys.has(value)) {
13606
+ delete newEntries[value];
13607
+ } else
13608
+ throw new Error(`Key ${value} not found in enum`);
13609
+ }
13610
+ return new ZodEnum({
13611
+ ...def,
13612
+ checks: [],
13613
+ ...util_exports.normalizeParams(params),
13614
+ entries: newEntries
13615
+ });
13616
+ };
13617
+ });
13618
+ function _enum2(values, params) {
13619
+ const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
13620
+ return new ZodEnum({
13621
+ type: "enum",
13622
+ entries,
13623
+ ...util_exports.normalizeParams(params)
13624
+ });
13737
13625
  }
13738
- function uint32(params) {
13739
- return _uint32(ZodNumberFormat, params);
13626
+ function nativeEnum(entries, params) {
13627
+ return new ZodEnum({
13628
+ type: "enum",
13629
+ entries,
13630
+ ...util_exports.normalizeParams(params)
13631
+ });
13740
13632
  }
13741
- var ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
13742
- $ZodBoolean.init(inst, def);
13633
+ var ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
13634
+ $ZodLiteral.init(inst, def);
13743
13635
  ZodType.init(inst, def);
13744
- inst._zod.processJSONSchema = (ctx, json2, params) => booleanProcessor(inst, ctx, json2, params);
13636
+ inst._zod.processJSONSchema = (ctx, json2, params) => literalProcessor(inst, ctx, json2, params);
13637
+ inst.values = new Set(def.values);
13638
+ Object.defineProperty(inst, "value", {
13639
+ get() {
13640
+ if (def.values.length > 1) {
13641
+ throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
13642
+ }
13643
+ return def.values[0];
13644
+ }
13645
+ });
13745
13646
  });
13746
- function boolean2(params) {
13747
- return _boolean(ZodBoolean, params);
13647
+ function literal(value, params) {
13648
+ return new ZodLiteral({
13649
+ type: "literal",
13650
+ values: Array.isArray(value) ? value : [value],
13651
+ ...util_exports.normalizeParams(params)
13652
+ });
13748
13653
  }
13749
- var ZodBigInt = /* @__PURE__ */ $constructor("ZodBigInt", (inst, def) => {
13750
- $ZodBigInt.init(inst, def);
13654
+ var ZodFile = /* @__PURE__ */ $constructor("ZodFile", (inst, def) => {
13655
+ $ZodFile.init(inst, def);
13751
13656
  ZodType.init(inst, def);
13752
- inst._zod.processJSONSchema = (ctx, json2, params) => bigintProcessor(inst, ctx, json2, params);
13753
- inst.gte = (value, params) => inst.check(_gte(value, params));
13754
- inst.min = (value, params) => inst.check(_gte(value, params));
13755
- inst.gt = (value, params) => inst.check(_gt(value, params));
13756
- inst.gte = (value, params) => inst.check(_gte(value, params));
13757
- inst.min = (value, params) => inst.check(_gte(value, params));
13758
- inst.lt = (value, params) => inst.check(_lt(value, params));
13759
- inst.lte = (value, params) => inst.check(_lte(value, params));
13760
- inst.max = (value, params) => inst.check(_lte(value, params));
13761
- inst.positive = (params) => inst.check(_gt(BigInt(0), params));
13762
- inst.negative = (params) => inst.check(_lt(BigInt(0), params));
13763
- inst.nonpositive = (params) => inst.check(_lte(BigInt(0), params));
13764
- inst.nonnegative = (params) => inst.check(_gte(BigInt(0), params));
13765
- inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
13766
- const bag = inst._zod.bag;
13767
- inst.minValue = bag.minimum ?? null;
13768
- inst.maxValue = bag.maximum ?? null;
13769
- inst.format = bag.format ?? null;
13657
+ inst._zod.processJSONSchema = (ctx, json2, params) => fileProcessor(inst, ctx, json2, params);
13658
+ inst.min = (size, params) => inst.check(_minSize(size, params));
13659
+ inst.max = (size, params) => inst.check(_maxSize(size, params));
13660
+ inst.mime = (types, params) => inst.check(_mime(Array.isArray(types) ? types : [types], params));
13770
13661
  });
13771
- function bigint2(params) {
13772
- return _bigint(ZodBigInt, params);
13662
+ function file(params) {
13663
+ return _file(ZodFile, params);
13773
13664
  }
13774
- var ZodBigIntFormat = /* @__PURE__ */ $constructor("ZodBigIntFormat", (inst, def) => {
13775
- $ZodBigIntFormat.init(inst, def);
13776
- ZodBigInt.init(inst, def);
13665
+ var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
13666
+ $ZodTransform.init(inst, def);
13667
+ ZodType.init(inst, def);
13668
+ inst._zod.processJSONSchema = (ctx, json2, params) => transformProcessor(inst, ctx, json2, params);
13669
+ inst._zod.parse = (payload, _ctx) => {
13670
+ if (_ctx.direction === "backward") {
13671
+ throw new $ZodEncodeError(inst.constructor.name);
13672
+ }
13673
+ payload.addIssue = (issue2) => {
13674
+ if (typeof issue2 === "string") {
13675
+ payload.issues.push(util_exports.issue(issue2, payload.value, def));
13676
+ } else {
13677
+ const _issue = issue2;
13678
+ if (_issue.fatal)
13679
+ _issue.continue = false;
13680
+ _issue.code ?? (_issue.code = "custom");
13681
+ _issue.input ?? (_issue.input = payload.value);
13682
+ _issue.inst ?? (_issue.inst = inst);
13683
+ payload.issues.push(util_exports.issue(_issue));
13684
+ }
13685
+ };
13686
+ const output = def.transform(payload.value, payload);
13687
+ if (output instanceof Promise) {
13688
+ return output.then((output2) => {
13689
+ payload.value = output2;
13690
+ payload.fallback = true;
13691
+ return payload;
13692
+ });
13693
+ }
13694
+ payload.value = output;
13695
+ payload.fallback = true;
13696
+ return payload;
13697
+ };
13777
13698
  });
13778
- function int64(params) {
13779
- return _int64(ZodBigIntFormat, params);
13699
+ function transform(fn) {
13700
+ return new ZodTransform({
13701
+ type: "transform",
13702
+ transform: fn
13703
+ });
13780
13704
  }
13781
- function uint64(params) {
13782
- return _uint64(ZodBigIntFormat, params);
13705
+ var ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
13706
+ $ZodOptional.init(inst, def);
13707
+ ZodType.init(inst, def);
13708
+ inst._zod.processJSONSchema = (ctx, json2, params) => optionalProcessor(inst, ctx, json2, params);
13709
+ inst.unwrap = () => inst._zod.def.innerType;
13710
+ });
13711
+ function optional(innerType) {
13712
+ return new ZodOptional({
13713
+ type: "optional",
13714
+ innerType
13715
+ });
13783
13716
  }
13784
- var ZodSymbol = /* @__PURE__ */ $constructor("ZodSymbol", (inst, def) => {
13785
- $ZodSymbol.init(inst, def);
13717
+ var ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
13718
+ $ZodExactOptional.init(inst, def);
13786
13719
  ZodType.init(inst, def);
13787
- inst._zod.processJSONSchema = (ctx, json2, params) => symbolProcessor(inst, ctx, json2, params);
13720
+ inst._zod.processJSONSchema = (ctx, json2, params) => optionalProcessor(inst, ctx, json2, params);
13721
+ inst.unwrap = () => inst._zod.def.innerType;
13788
13722
  });
13789
- function symbol(params) {
13790
- return _symbol(ZodSymbol, params);
13723
+ function exactOptional(innerType) {
13724
+ return new ZodExactOptional({
13725
+ type: "optional",
13726
+ innerType
13727
+ });
13791
13728
  }
13792
- var ZodUndefined = /* @__PURE__ */ $constructor("ZodUndefined", (inst, def) => {
13793
- $ZodUndefined.init(inst, def);
13729
+ var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
13730
+ $ZodNullable.init(inst, def);
13794
13731
  ZodType.init(inst, def);
13795
- inst._zod.processJSONSchema = (ctx, json2, params) => undefinedProcessor(inst, ctx, json2, params);
13732
+ inst._zod.processJSONSchema = (ctx, json2, params) => nullableProcessor(inst, ctx, json2, params);
13733
+ inst.unwrap = () => inst._zod.def.innerType;
13796
13734
  });
13797
- function _undefined3(params) {
13798
- return _undefined2(ZodUndefined, params);
13735
+ function nullable(innerType) {
13736
+ return new ZodNullable({
13737
+ type: "nullable",
13738
+ innerType
13739
+ });
13740
+ }
13741
+ function nullish2(innerType) {
13742
+ return optional(nullable(innerType));
13799
13743
  }
13800
- var ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
13801
- $ZodNull.init(inst, def);
13744
+ var ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
13745
+ $ZodDefault.init(inst, def);
13802
13746
  ZodType.init(inst, def);
13803
- inst._zod.processJSONSchema = (ctx, json2, params) => nullProcessor(inst, ctx, json2, params);
13747
+ inst._zod.processJSONSchema = (ctx, json2, params) => defaultProcessor(inst, ctx, json2, params);
13748
+ inst.unwrap = () => inst._zod.def.innerType;
13749
+ inst.removeDefault = inst.unwrap;
13804
13750
  });
13805
- function _null3(params) {
13806
- return _null2(ZodNull, params);
13751
+ function _default2(innerType, defaultValue) {
13752
+ return new ZodDefault({
13753
+ type: "default",
13754
+ innerType,
13755
+ get defaultValue() {
13756
+ return typeof defaultValue === "function" ? defaultValue() : util_exports.shallowClone(defaultValue);
13757
+ }
13758
+ });
13807
13759
  }
13808
- var ZodAny = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
13809
- $ZodAny.init(inst, def);
13760
+ var ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
13761
+ $ZodPrefault.init(inst, def);
13810
13762
  ZodType.init(inst, def);
13811
- inst._zod.processJSONSchema = (ctx, json2, params) => anyProcessor(inst, ctx, json2, params);
13763
+ inst._zod.processJSONSchema = (ctx, json2, params) => prefaultProcessor(inst, ctx, json2, params);
13764
+ inst.unwrap = () => inst._zod.def.innerType;
13812
13765
  });
13813
- function any() {
13814
- return _any(ZodAny);
13766
+ function prefault(innerType, defaultValue) {
13767
+ return new ZodPrefault({
13768
+ type: "prefault",
13769
+ innerType,
13770
+ get defaultValue() {
13771
+ return typeof defaultValue === "function" ? defaultValue() : util_exports.shallowClone(defaultValue);
13772
+ }
13773
+ });
13815
13774
  }
13816
- var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
13817
- $ZodUnknown.init(inst, def);
13775
+ var ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
13776
+ $ZodNonOptional.init(inst, def);
13818
13777
  ZodType.init(inst, def);
13819
- inst._zod.processJSONSchema = (ctx, json2, params) => unknownProcessor(inst, ctx, json2, params);
13778
+ inst._zod.processJSONSchema = (ctx, json2, params) => nonoptionalProcessor(inst, ctx, json2, params);
13779
+ inst.unwrap = () => inst._zod.def.innerType;
13820
13780
  });
13821
- function unknown() {
13822
- return _unknown(ZodUnknown);
13781
+ function nonoptional(innerType, params) {
13782
+ return new ZodNonOptional({
13783
+ type: "nonoptional",
13784
+ innerType,
13785
+ ...util_exports.normalizeParams(params)
13786
+ });
13823
13787
  }
13824
- var ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
13825
- $ZodNever.init(inst, def);
13788
+ var ZodSuccess = /* @__PURE__ */ $constructor("ZodSuccess", (inst, def) => {
13789
+ $ZodSuccess.init(inst, def);
13826
13790
  ZodType.init(inst, def);
13827
- inst._zod.processJSONSchema = (ctx, json2, params) => neverProcessor(inst, ctx, json2, params);
13791
+ inst._zod.processJSONSchema = (ctx, json2, params) => successProcessor(inst, ctx, json2, params);
13792
+ inst.unwrap = () => inst._zod.def.innerType;
13828
13793
  });
13829
- function never(params) {
13830
- return _never(ZodNever, params);
13794
+ function success(innerType) {
13795
+ return new ZodSuccess({
13796
+ type: "success",
13797
+ innerType
13798
+ });
13831
13799
  }
13832
- var ZodVoid = /* @__PURE__ */ $constructor("ZodVoid", (inst, def) => {
13833
- $ZodVoid.init(inst, def);
13800
+ var ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
13801
+ $ZodCatch.init(inst, def);
13834
13802
  ZodType.init(inst, def);
13835
- inst._zod.processJSONSchema = (ctx, json2, params) => voidProcessor(inst, ctx, json2, params);
13803
+ inst._zod.processJSONSchema = (ctx, json2, params) => catchProcessor(inst, ctx, json2, params);
13804
+ inst.unwrap = () => inst._zod.def.innerType;
13805
+ inst.removeCatch = inst.unwrap;
13836
13806
  });
13837
- function _void2(params) {
13838
- return _void(ZodVoid, params);
13807
+ function _catch2(innerType, catchValue) {
13808
+ return new ZodCatch({
13809
+ type: "catch",
13810
+ innerType,
13811
+ catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
13812
+ });
13839
13813
  }
13840
- var ZodDate = /* @__PURE__ */ $constructor("ZodDate", (inst, def) => {
13841
- $ZodDate.init(inst, def);
13814
+ var ZodNaN = /* @__PURE__ */ $constructor("ZodNaN", (inst, def) => {
13815
+ $ZodNaN.init(inst, def);
13842
13816
  ZodType.init(inst, def);
13843
- inst._zod.processJSONSchema = (ctx, json2, params) => dateProcessor(inst, ctx, json2, params);
13844
- inst.min = (value, params) => inst.check(_gte(value, params));
13845
- inst.max = (value, params) => inst.check(_lte(value, params));
13846
- const c = inst._zod.bag;
13847
- inst.minDate = c.minimum ? new Date(c.minimum) : null;
13848
- inst.maxDate = c.maximum ? new Date(c.maximum) : null;
13817
+ inst._zod.processJSONSchema = (ctx, json2, params) => nanProcessor(inst, ctx, json2, params);
13849
13818
  });
13850
- function date3(params) {
13851
- return _date(ZodDate, params);
13819
+ function nan(params) {
13820
+ return _nan(ZodNaN, params);
13852
13821
  }
13853
- var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
13854
- $ZodArray.init(inst, def);
13822
+ var ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
13823
+ $ZodPipe.init(inst, def);
13855
13824
  ZodType.init(inst, def);
13856
- inst._zod.processJSONSchema = (ctx, json2, params) => arrayProcessor(inst, ctx, json2, params);
13857
- inst.element = def.element;
13858
- _installLazyMethods(inst, "ZodArray", {
13859
- min(n, params) {
13860
- return this.check(_minLength(n, params));
13861
- },
13862
- nonempty(params) {
13863
- return this.check(_minLength(1, params));
13864
- },
13865
- max(n, params) {
13866
- return this.check(_maxLength(n, params));
13867
- },
13868
- length(n, params) {
13869
- return this.check(_length(n, params));
13870
- },
13871
- unwrap() {
13872
- return this.element;
13873
- }
13874
- });
13825
+ inst._zod.processJSONSchema = (ctx, json2, params) => pipeProcessor(inst, ctx, json2, params);
13826
+ inst.in = def.in;
13827
+ inst.out = def.out;
13875
13828
  });
13876
- function array(element, params) {
13877
- return _array(ZodArray, element, params);
13878
- }
13879
- function keyof(schema) {
13880
- const shape = schema._zod.def.shape;
13881
- return _enum2(Object.keys(shape));
13882
- }
13883
- var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
13884
- $ZodObjectJIT.init(inst, def);
13885
- ZodType.init(inst, def);
13886
- inst._zod.processJSONSchema = (ctx, json2, params) => objectProcessor(inst, ctx, json2, params);
13887
- util_exports.defineLazy(inst, "shape", () => {
13888
- return def.shape;
13889
- });
13890
- _installLazyMethods(inst, "ZodObject", {
13891
- keyof() {
13892
- return _enum2(Object.keys(this._zod.def.shape));
13893
- },
13894
- catchall(catchall) {
13895
- return this.clone({ ...this._zod.def, catchall });
13896
- },
13897
- passthrough() {
13898
- return this.clone({ ...this._zod.def, catchall: unknown() });
13899
- },
13900
- loose() {
13901
- return this.clone({ ...this._zod.def, catchall: unknown() });
13902
- },
13903
- strict() {
13904
- return this.clone({ ...this._zod.def, catchall: never() });
13905
- },
13906
- strip() {
13907
- return this.clone({ ...this._zod.def, catchall: void 0 });
13908
- },
13909
- extend(incoming) {
13910
- return util_exports.extend(this, incoming);
13911
- },
13912
- safeExtend(incoming) {
13913
- return util_exports.safeExtend(this, incoming);
13914
- },
13915
- merge(other) {
13916
- return util_exports.merge(this, other);
13917
- },
13918
- pick(mask) {
13919
- return util_exports.pick(this, mask);
13920
- },
13921
- omit(mask) {
13922
- return util_exports.omit(this, mask);
13923
- },
13924
- partial(...args) {
13925
- return util_exports.partial(ZodOptional, this, args[0]);
13926
- },
13927
- required(...args) {
13928
- return util_exports.required(ZodNonOptional, this, args[0]);
13929
- }
13829
+ function pipe(in_, out) {
13830
+ return new ZodPipe({
13831
+ type: "pipe",
13832
+ in: in_,
13833
+ out
13834
+ // ...util.normalizeParams(params),
13930
13835
  });
13931
- });
13932
- function object(shape, params) {
13933
- const def = {
13934
- type: "object",
13935
- shape: shape ?? {},
13936
- ...util_exports.normalizeParams(params)
13937
- };
13938
- return new ZodObject(def);
13939
13836
  }
13940
- function strictObject(shape, params) {
13941
- return new ZodObject({
13942
- type: "object",
13943
- shape,
13944
- catchall: never(),
13945
- ...util_exports.normalizeParams(params)
13837
+ var ZodCodec = /* @__PURE__ */ $constructor("ZodCodec", (inst, def) => {
13838
+ ZodPipe.init(inst, def);
13839
+ $ZodCodec.init(inst, def);
13840
+ });
13841
+ function codec(in_, out, params) {
13842
+ return new ZodCodec({
13843
+ type: "pipe",
13844
+ in: in_,
13845
+ out,
13846
+ transform: params.decode,
13847
+ reverseTransform: params.encode
13946
13848
  });
13947
13849
  }
13948
- function looseObject(shape, params) {
13949
- return new ZodObject({
13950
- type: "object",
13951
- shape,
13952
- catchall: unknown(),
13953
- ...util_exports.normalizeParams(params)
13850
+ function invertCodec(codec2) {
13851
+ const def = codec2._zod.def;
13852
+ return new ZodCodec({
13853
+ type: "pipe",
13854
+ in: def.out,
13855
+ out: def.in,
13856
+ transform: def.reverseTransform,
13857
+ reverseTransform: def.transform
13954
13858
  });
13955
13859
  }
13956
- var ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
13957
- $ZodUnion.init(inst, def);
13860
+ var ZodPreprocess = /* @__PURE__ */ $constructor("ZodPreprocess", (inst, def) => {
13861
+ ZodPipe.init(inst, def);
13862
+ $ZodPreprocess.init(inst, def);
13863
+ });
13864
+ var ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
13865
+ $ZodReadonly.init(inst, def);
13958
13866
  ZodType.init(inst, def);
13959
- inst._zod.processJSONSchema = (ctx, json2, params) => unionProcessor(inst, ctx, json2, params);
13960
- inst.options = def.options;
13867
+ inst._zod.processJSONSchema = (ctx, json2, params) => readonlyProcessor(inst, ctx, json2, params);
13868
+ inst.unwrap = () => inst._zod.def.innerType;
13961
13869
  });
13962
- function union(options, params) {
13963
- return new ZodUnion({
13964
- type: "union",
13965
- options,
13966
- ...util_exports.normalizeParams(params)
13870
+ function readonly(innerType) {
13871
+ return new ZodReadonly({
13872
+ type: "readonly",
13873
+ innerType
13967
13874
  });
13968
13875
  }
13969
- var ZodXor = /* @__PURE__ */ $constructor("ZodXor", (inst, def) => {
13970
- ZodUnion.init(inst, def);
13971
- $ZodXor.init(inst, def);
13972
- inst._zod.processJSONSchema = (ctx, json2, params) => unionProcessor(inst, ctx, json2, params);
13973
- inst.options = def.options;
13876
+ var ZodTemplateLiteral = /* @__PURE__ */ $constructor("ZodTemplateLiteral", (inst, def) => {
13877
+ $ZodTemplateLiteral.init(inst, def);
13878
+ ZodType.init(inst, def);
13879
+ inst._zod.processJSONSchema = (ctx, json2, params) => templateLiteralProcessor(inst, ctx, json2, params);
13974
13880
  });
13975
- function xor(options, params) {
13976
- return new ZodXor({
13977
- type: "union",
13978
- options,
13979
- inclusive: false,
13881
+ function templateLiteral(parts, params) {
13882
+ return new ZodTemplateLiteral({
13883
+ type: "template_literal",
13884
+ parts,
13980
13885
  ...util_exports.normalizeParams(params)
13981
13886
  });
13982
13887
  }
13983
- var ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("ZodDiscriminatedUnion", (inst, def) => {
13984
- ZodUnion.init(inst, def);
13985
- $ZodDiscriminatedUnion.init(inst, def);
13888
+ var ZodLazy = /* @__PURE__ */ $constructor("ZodLazy", (inst, def) => {
13889
+ $ZodLazy.init(inst, def);
13890
+ ZodType.init(inst, def);
13891
+ inst._zod.processJSONSchema = (ctx, json2, params) => lazyProcessor(inst, ctx, json2, params);
13892
+ inst.unwrap = () => inst._zod.def.getter();
13986
13893
  });
13987
- function discriminatedUnion(discriminator, options, params) {
13988
- return new ZodDiscriminatedUnion({
13989
- type: "union",
13990
- options,
13991
- discriminator,
13992
- ...util_exports.normalizeParams(params)
13894
+ function lazy(getter) {
13895
+ return new ZodLazy({
13896
+ type: "lazy",
13897
+ getter
13993
13898
  });
13994
13899
  }
13995
- var ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
13996
- $ZodIntersection.init(inst, def);
13900
+ var ZodPromise = /* @__PURE__ */ $constructor("ZodPromise", (inst, def) => {
13901
+ $ZodPromise.init(inst, def);
13997
13902
  ZodType.init(inst, def);
13998
- inst._zod.processJSONSchema = (ctx, json2, params) => intersectionProcessor(inst, ctx, json2, params);
13903
+ inst._zod.processJSONSchema = (ctx, json2, params) => promiseProcessor(inst, ctx, json2, params);
13904
+ inst.unwrap = () => inst._zod.def.innerType;
13999
13905
  });
14000
- function intersection(left, right) {
14001
- return new ZodIntersection({
14002
- type: "intersection",
14003
- left,
14004
- right
13906
+ function promise(innerType) {
13907
+ return new ZodPromise({
13908
+ type: "promise",
13909
+ innerType
14005
13910
  });
14006
13911
  }
14007
- var ZodTuple = /* @__PURE__ */ $constructor("ZodTuple", (inst, def) => {
14008
- $ZodTuple.init(inst, def);
13912
+ var ZodFunction = /* @__PURE__ */ $constructor("ZodFunction", (inst, def) => {
13913
+ $ZodFunction.init(inst, def);
14009
13914
  ZodType.init(inst, def);
14010
- inst._zod.processJSONSchema = (ctx, json2, params) => tupleProcessor(inst, ctx, json2, params);
14011
- inst.rest = (rest) => inst.clone({
14012
- ...inst._zod.def,
14013
- rest
14014
- });
13915
+ inst._zod.processJSONSchema = (ctx, json2, params) => functionProcessor(inst, ctx, json2, params);
14015
13916
  });
14016
- function tuple(items, _paramsOrRest, _params) {
14017
- const hasRest = _paramsOrRest instanceof $ZodType;
14018
- const params = hasRest ? _params : _paramsOrRest;
14019
- const rest = hasRest ? _paramsOrRest : null;
14020
- return new ZodTuple({
14021
- type: "tuple",
14022
- items,
14023
- rest,
14024
- ...util_exports.normalizeParams(params)
13917
+ function _function(params) {
13918
+ return new ZodFunction({
13919
+ type: "function",
13920
+ input: Array.isArray(params?.input) ? tuple(params?.input) : params?.input ?? array(unknown()),
13921
+ output: params?.output ?? unknown()
14025
13922
  });
14026
13923
  }
14027
- var ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
14028
- $ZodRecord.init(inst, def);
13924
+ var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
13925
+ $ZodCustom.init(inst, def);
14029
13926
  ZodType.init(inst, def);
14030
- inst._zod.processJSONSchema = (ctx, json2, params) => recordProcessor(inst, ctx, json2, params);
14031
- inst.keyType = def.keyType;
14032
- inst.valueType = def.valueType;
13927
+ inst._zod.processJSONSchema = (ctx, json2, params) => customProcessor(inst, ctx, json2, params);
14033
13928
  });
14034
- function record(keyType, valueType, params) {
14035
- if (!valueType || !valueType._zod) {
14036
- return new ZodRecord({
14037
- type: "record",
14038
- keyType: string2(),
14039
- valueType: keyType,
14040
- ...util_exports.normalizeParams(valueType)
14041
- });
14042
- }
14043
- return new ZodRecord({
14044
- type: "record",
14045
- keyType,
14046
- valueType,
14047
- ...util_exports.normalizeParams(params)
13929
+ function check(fn) {
13930
+ const ch = new $ZodCheck({
13931
+ check: "custom"
13932
+ // ...util.normalizeParams(params),
14048
13933
  });
13934
+ ch._zod.check = fn;
13935
+ return ch;
14049
13936
  }
14050
- function partialRecord(keyType, valueType, params) {
14051
- const k = clone(keyType);
14052
- k._zod.values = void 0;
14053
- return new ZodRecord({
14054
- type: "record",
14055
- keyType: k,
14056
- valueType,
13937
+ function custom(fn, _params) {
13938
+ return _custom(ZodCustom, fn ?? (() => true), _params);
13939
+ }
13940
+ function refine(fn, _params = {}) {
13941
+ return _refine(ZodCustom, fn, _params);
13942
+ }
13943
+ function superRefine(fn, params) {
13944
+ return _superRefine(fn, params);
13945
+ }
13946
+ var describe2 = describe;
13947
+ var meta2 = meta;
13948
+ function _instanceof(cls, params = {}) {
13949
+ const inst = new ZodCustom({
13950
+ type: "custom",
13951
+ check: "custom",
13952
+ fn: (data) => data instanceof cls,
13953
+ abort: true,
14057
13954
  ...util_exports.normalizeParams(params)
14058
13955
  });
13956
+ inst._zod.bag.Class = cls;
13957
+ inst._zod.check = (payload) => {
13958
+ if (!(payload.value instanceof cls)) {
13959
+ payload.issues.push({
13960
+ code: "invalid_type",
13961
+ expected: cls.name,
13962
+ input: payload.value,
13963
+ inst,
13964
+ path: [...inst._zod.def.path ?? []]
13965
+ });
13966
+ }
13967
+ };
13968
+ return inst;
14059
13969
  }
14060
- function looseRecord(keyType, valueType, params) {
14061
- return new ZodRecord({
14062
- type: "record",
14063
- keyType,
14064
- valueType,
14065
- mode: "loose",
14066
- ...util_exports.normalizeParams(params)
13970
+ var stringbool = (...args) => _stringbool({
13971
+ Codec: ZodCodec,
13972
+ Boolean: ZodBoolean,
13973
+ String: ZodString
13974
+ }, ...args);
13975
+ function json(params) {
13976
+ const jsonSchema = lazy(() => {
13977
+ return union([string2(params), number2(), boolean2(), _null3(), array(jsonSchema), record(string2(), jsonSchema)]);
14067
13978
  });
13979
+ return jsonSchema;
14068
13980
  }
14069
- var ZodMap = /* @__PURE__ */ $constructor("ZodMap", (inst, def) => {
14070
- $ZodMap.init(inst, def);
14071
- ZodType.init(inst, def);
14072
- inst._zod.processJSONSchema = (ctx, json2, params) => mapProcessor(inst, ctx, json2, params);
14073
- inst.keyType = def.keyType;
14074
- inst.valueType = def.valueType;
14075
- inst.min = (...args) => inst.check(_minSize(...args));
14076
- inst.nonempty = (params) => inst.check(_minSize(1, params));
14077
- inst.max = (...args) => inst.check(_maxSize(...args));
14078
- inst.size = (...args) => inst.check(_size(...args));
14079
- });
14080
- function map(keyType, valueType, params) {
14081
- return new ZodMap({
14082
- type: "map",
14083
- keyType,
14084
- valueType,
14085
- ...util_exports.normalizeParams(params)
13981
+ function preprocess(fn, schema) {
13982
+ return new ZodPreprocess({
13983
+ type: "pipe",
13984
+ in: transform(fn),
13985
+ out: schema
13986
+ });
13987
+ }
13988
+
13989
+ // node_modules/zod/v4/classic/compat.js
13990
+ var ZodIssueCode = {
13991
+ invalid_type: "invalid_type",
13992
+ too_big: "too_big",
13993
+ too_small: "too_small",
13994
+ invalid_format: "invalid_format",
13995
+ not_multiple_of: "not_multiple_of",
13996
+ unrecognized_keys: "unrecognized_keys",
13997
+ invalid_union: "invalid_union",
13998
+ invalid_key: "invalid_key",
13999
+ invalid_element: "invalid_element",
14000
+ invalid_value: "invalid_value",
14001
+ custom: "custom"
14002
+ };
14003
+ function setErrorMap(map2) {
14004
+ config({
14005
+ customError: map2
14086
14006
  });
14087
14007
  }
14088
- var ZodSet = /* @__PURE__ */ $constructor("ZodSet", (inst, def) => {
14089
- $ZodSet.init(inst, def);
14090
- ZodType.init(inst, def);
14091
- inst._zod.processJSONSchema = (ctx, json2, params) => setProcessor(inst, ctx, json2, params);
14092
- inst.min = (...args) => inst.check(_minSize(...args));
14093
- inst.nonempty = (params) => inst.check(_minSize(1, params));
14094
- inst.max = (...args) => inst.check(_maxSize(...args));
14095
- inst.size = (...args) => inst.check(_size(...args));
14096
- });
14097
- function set(valueType, params) {
14098
- return new ZodSet({
14099
- type: "set",
14100
- valueType,
14101
- ...util_exports.normalizeParams(params)
14102
- });
14008
+ function getErrorMap() {
14009
+ return config().customError;
14010
+ }
14011
+ var ZodFirstPartyTypeKind;
14012
+ /* @__PURE__ */ (function(ZodFirstPartyTypeKind2) {
14013
+ })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
14014
+
14015
+ // node_modules/zod/v4/classic/from-json-schema.js
14016
+ var z = {
14017
+ ...schemas_exports2,
14018
+ ...checks_exports2,
14019
+ iso: iso_exports
14020
+ };
14021
+ var RECOGNIZED_KEYS = /* @__PURE__ */ new Set([
14022
+ // Schema identification
14023
+ "$schema",
14024
+ "$ref",
14025
+ "$defs",
14026
+ "definitions",
14027
+ // Core schema keywords
14028
+ "$id",
14029
+ "id",
14030
+ "$comment",
14031
+ "$anchor",
14032
+ "$vocabulary",
14033
+ "$dynamicRef",
14034
+ "$dynamicAnchor",
14035
+ // Type
14036
+ "type",
14037
+ "enum",
14038
+ "const",
14039
+ // Composition
14040
+ "anyOf",
14041
+ "oneOf",
14042
+ "allOf",
14043
+ "not",
14044
+ // Object
14045
+ "properties",
14046
+ "required",
14047
+ "additionalProperties",
14048
+ "patternProperties",
14049
+ "propertyNames",
14050
+ "minProperties",
14051
+ "maxProperties",
14052
+ // Array
14053
+ "items",
14054
+ "prefixItems",
14055
+ "additionalItems",
14056
+ "minItems",
14057
+ "maxItems",
14058
+ "uniqueItems",
14059
+ "contains",
14060
+ "minContains",
14061
+ "maxContains",
14062
+ // String
14063
+ "minLength",
14064
+ "maxLength",
14065
+ "pattern",
14066
+ "format",
14067
+ // Number
14068
+ "minimum",
14069
+ "maximum",
14070
+ "exclusiveMinimum",
14071
+ "exclusiveMaximum",
14072
+ "multipleOf",
14073
+ // Already handled metadata
14074
+ "description",
14075
+ "default",
14076
+ // Content
14077
+ "contentEncoding",
14078
+ "contentMediaType",
14079
+ "contentSchema",
14080
+ // Unsupported (error-throwing)
14081
+ "unevaluatedItems",
14082
+ "unevaluatedProperties",
14083
+ "if",
14084
+ "then",
14085
+ "else",
14086
+ "dependentSchemas",
14087
+ "dependentRequired",
14088
+ // OpenAPI
14089
+ "nullable",
14090
+ "readOnly"
14091
+ ]);
14092
+ function detectVersion(schema, defaultTarget) {
14093
+ const $schema = schema.$schema;
14094
+ if ($schema === "https://json-schema.org/draft/2020-12/schema") {
14095
+ return "draft-2020-12";
14096
+ }
14097
+ if ($schema === "http://json-schema.org/draft-07/schema#") {
14098
+ return "draft-7";
14099
+ }
14100
+ if ($schema === "http://json-schema.org/draft-04/schema#") {
14101
+ return "draft-4";
14102
+ }
14103
+ return defaultTarget ?? "draft-2020-12";
14104
+ }
14105
+ function resolveRef(ref, ctx) {
14106
+ if (!ref.startsWith("#")) {
14107
+ throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
14108
+ }
14109
+ const path = ref.slice(1).split("/").filter(Boolean);
14110
+ if (path.length === 0) {
14111
+ return ctx.rootSchema;
14112
+ }
14113
+ const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14114
+ if (path[0] === defsKey) {
14115
+ const key = path[1];
14116
+ if (!key || !ctx.defs[key]) {
14117
+ throw new Error(`Reference not found: ${ref}`);
14118
+ }
14119
+ return ctx.defs[key];
14120
+ }
14121
+ throw new Error(`Reference not found: ${ref}`);
14103
14122
  }
14104
- var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
14105
- $ZodEnum.init(inst, def);
14106
- ZodType.init(inst, def);
14107
- inst._zod.processJSONSchema = (ctx, json2, params) => enumProcessor(inst, ctx, json2, params);
14108
- inst.enum = def.entries;
14109
- inst.options = Object.values(def.entries);
14110
- const keys = new Set(Object.keys(def.entries));
14111
- inst.extract = (values, params) => {
14112
- const newEntries = {};
14113
- for (const value of values) {
14114
- if (keys.has(value)) {
14115
- newEntries[value] = def.entries[value];
14116
- } else
14117
- throw new Error(`Key ${value} not found in enum`);
14123
+ function convertBaseSchema(schema, ctx) {
14124
+ if (schema.not !== void 0) {
14125
+ if (typeof schema.not === "object" && Object.keys(schema.not).length === 0) {
14126
+ return z.never();
14118
14127
  }
14119
- return new ZodEnum({
14120
- ...def,
14121
- checks: [],
14122
- ...util_exports.normalizeParams(params),
14123
- entries: newEntries
14124
- });
14125
- };
14126
- inst.exclude = (values, params) => {
14127
- const newEntries = { ...def.entries };
14128
- for (const value of values) {
14129
- if (keys.has(value)) {
14130
- delete newEntries[value];
14131
- } else
14132
- throw new Error(`Key ${value} not found in enum`);
14128
+ throw new Error("not is not supported in Zod (except { not: {} } for never)");
14129
+ }
14130
+ if (schema.unevaluatedItems !== void 0) {
14131
+ throw new Error("unevaluatedItems is not supported");
14132
+ }
14133
+ if (schema.unevaluatedProperties !== void 0) {
14134
+ throw new Error("unevaluatedProperties is not supported");
14135
+ }
14136
+ if (schema.if !== void 0 || schema.then !== void 0 || schema.else !== void 0) {
14137
+ throw new Error("Conditional schemas (if/then/else) are not supported");
14138
+ }
14139
+ if (schema.dependentSchemas !== void 0 || schema.dependentRequired !== void 0) {
14140
+ throw new Error("dependentSchemas and dependentRequired are not supported");
14141
+ }
14142
+ if (schema.$ref) {
14143
+ const refPath = schema.$ref;
14144
+ if (ctx.refs.has(refPath)) {
14145
+ return ctx.refs.get(refPath);
14133
14146
  }
14134
- return new ZodEnum({
14135
- ...def,
14136
- checks: [],
14137
- ...util_exports.normalizeParams(params),
14138
- entries: newEntries
14147
+ if (ctx.processing.has(refPath)) {
14148
+ return z.lazy(() => {
14149
+ if (!ctx.refs.has(refPath)) {
14150
+ throw new Error(`Circular reference not resolved: ${refPath}`);
14151
+ }
14152
+ return ctx.refs.get(refPath);
14153
+ });
14154
+ }
14155
+ ctx.processing.add(refPath);
14156
+ const resolved = resolveRef(refPath, ctx);
14157
+ const zodSchema2 = convertSchema(resolved, ctx);
14158
+ ctx.refs.set(refPath, zodSchema2);
14159
+ ctx.processing.delete(refPath);
14160
+ return zodSchema2;
14161
+ }
14162
+ if (schema.enum !== void 0) {
14163
+ const enumValues = schema.enum;
14164
+ if (ctx.version === "openapi-3.0" && schema.nullable === true && enumValues.length === 1 && enumValues[0] === null) {
14165
+ return z.null();
14166
+ }
14167
+ if (enumValues.length === 0) {
14168
+ return z.never();
14169
+ }
14170
+ if (enumValues.length === 1) {
14171
+ return z.literal(enumValues[0]);
14172
+ }
14173
+ if (enumValues.every((v) => typeof v === "string")) {
14174
+ return z.enum(enumValues);
14175
+ }
14176
+ const literalSchemas = enumValues.map((v) => z.literal(v));
14177
+ if (literalSchemas.length < 2) {
14178
+ return literalSchemas[0];
14179
+ }
14180
+ return z.union([literalSchemas[0], literalSchemas[1], ...literalSchemas.slice(2)]);
14181
+ }
14182
+ if (schema.const !== void 0) {
14183
+ return z.literal(schema.const);
14184
+ }
14185
+ const type = schema.type;
14186
+ if (Array.isArray(type)) {
14187
+ const typeSchemas = type.map((t) => {
14188
+ const typeSchema = { ...schema, type: t };
14189
+ return convertBaseSchema(typeSchema, ctx);
14139
14190
  });
14140
- };
14141
- });
14142
- function _enum2(values, params) {
14143
- const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
14144
- return new ZodEnum({
14145
- type: "enum",
14146
- entries,
14147
- ...util_exports.normalizeParams(params)
14148
- });
14149
- }
14150
- function nativeEnum(entries, params) {
14151
- return new ZodEnum({
14152
- type: "enum",
14153
- entries,
14154
- ...util_exports.normalizeParams(params)
14155
- });
14156
- }
14157
- var ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
14158
- $ZodLiteral.init(inst, def);
14159
- ZodType.init(inst, def);
14160
- inst._zod.processJSONSchema = (ctx, json2, params) => literalProcessor(inst, ctx, json2, params);
14161
- inst.values = new Set(def.values);
14162
- Object.defineProperty(inst, "value", {
14163
- get() {
14164
- if (def.values.length > 1) {
14165
- throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
14191
+ if (typeSchemas.length === 0) {
14192
+ return z.never();
14193
+ }
14194
+ if (typeSchemas.length === 1) {
14195
+ return typeSchemas[0];
14196
+ }
14197
+ return z.union(typeSchemas);
14198
+ }
14199
+ if (!type) {
14200
+ return z.any();
14201
+ }
14202
+ let zodSchema;
14203
+ switch (type) {
14204
+ case "string": {
14205
+ let stringSchema = z.string();
14206
+ if (schema.format) {
14207
+ const format = schema.format;
14208
+ if (format === "email") {
14209
+ stringSchema = stringSchema.check(z.email());
14210
+ } else if (format === "uri" || format === "uri-reference") {
14211
+ stringSchema = stringSchema.check(z.url());
14212
+ } else if (format === "uuid" || format === "guid") {
14213
+ stringSchema = stringSchema.check(z.uuid());
14214
+ } else if (format === "date-time") {
14215
+ stringSchema = stringSchema.check(z.iso.datetime());
14216
+ } else if (format === "date") {
14217
+ stringSchema = stringSchema.check(z.iso.date());
14218
+ } else if (format === "time") {
14219
+ stringSchema = stringSchema.check(z.iso.time());
14220
+ } else if (format === "duration") {
14221
+ stringSchema = stringSchema.check(z.iso.duration());
14222
+ } else if (format === "ipv4") {
14223
+ stringSchema = stringSchema.check(z.ipv4());
14224
+ } else if (format === "ipv6") {
14225
+ stringSchema = stringSchema.check(z.ipv6());
14226
+ } else if (format === "mac") {
14227
+ stringSchema = stringSchema.check(z.mac());
14228
+ } else if (format === "cidr") {
14229
+ stringSchema = stringSchema.check(z.cidrv4());
14230
+ } else if (format === "cidr-v6") {
14231
+ stringSchema = stringSchema.check(z.cidrv6());
14232
+ } else if (format === "base64") {
14233
+ stringSchema = stringSchema.check(z.base64());
14234
+ } else if (format === "base64url") {
14235
+ stringSchema = stringSchema.check(z.base64url());
14236
+ } else if (format === "e164") {
14237
+ stringSchema = stringSchema.check(z.e164());
14238
+ } else if (format === "jwt") {
14239
+ stringSchema = stringSchema.check(z.jwt());
14240
+ } else if (format === "emoji") {
14241
+ stringSchema = stringSchema.check(z.emoji());
14242
+ } else if (format === "nanoid") {
14243
+ stringSchema = stringSchema.check(z.nanoid());
14244
+ } else if (format === "cuid") {
14245
+ stringSchema = stringSchema.check(z.cuid());
14246
+ } else if (format === "cuid2") {
14247
+ stringSchema = stringSchema.check(z.cuid2());
14248
+ } else if (format === "ulid") {
14249
+ stringSchema = stringSchema.check(z.ulid());
14250
+ } else if (format === "xid") {
14251
+ stringSchema = stringSchema.check(z.xid());
14252
+ } else if (format === "ksuid") {
14253
+ stringSchema = stringSchema.check(z.ksuid());
14254
+ }
14255
+ }
14256
+ if (typeof schema.minLength === "number") {
14257
+ stringSchema = stringSchema.min(schema.minLength);
14258
+ }
14259
+ if (typeof schema.maxLength === "number") {
14260
+ stringSchema = stringSchema.max(schema.maxLength);
14261
+ }
14262
+ if (schema.pattern) {
14263
+ stringSchema = stringSchema.regex(new RegExp(schema.pattern));
14264
+ }
14265
+ zodSchema = stringSchema;
14266
+ break;
14267
+ }
14268
+ case "number":
14269
+ case "integer": {
14270
+ let numberSchema = type === "integer" ? z.number().int() : z.number();
14271
+ if (typeof schema.minimum === "number") {
14272
+ numberSchema = numberSchema.min(schema.minimum);
14166
14273
  }
14167
- return def.values[0];
14274
+ if (typeof schema.maximum === "number") {
14275
+ numberSchema = numberSchema.max(schema.maximum);
14276
+ }
14277
+ if (typeof schema.exclusiveMinimum === "number") {
14278
+ numberSchema = numberSchema.gt(schema.exclusiveMinimum);
14279
+ } else if (schema.exclusiveMinimum === true && typeof schema.minimum === "number") {
14280
+ numberSchema = numberSchema.gt(schema.minimum);
14281
+ }
14282
+ if (typeof schema.exclusiveMaximum === "number") {
14283
+ numberSchema = numberSchema.lt(schema.exclusiveMaximum);
14284
+ } else if (schema.exclusiveMaximum === true && typeof schema.maximum === "number") {
14285
+ numberSchema = numberSchema.lt(schema.maximum);
14286
+ }
14287
+ if (typeof schema.multipleOf === "number") {
14288
+ numberSchema = numberSchema.multipleOf(schema.multipleOf);
14289
+ }
14290
+ zodSchema = numberSchema;
14291
+ break;
14168
14292
  }
14169
- });
14170
- });
14171
- function literal(value, params) {
14172
- return new ZodLiteral({
14173
- type: "literal",
14174
- values: Array.isArray(value) ? value : [value],
14175
- ...util_exports.normalizeParams(params)
14176
- });
14177
- }
14178
- var ZodFile = /* @__PURE__ */ $constructor("ZodFile", (inst, def) => {
14179
- $ZodFile.init(inst, def);
14180
- ZodType.init(inst, def);
14181
- inst._zod.processJSONSchema = (ctx, json2, params) => fileProcessor(inst, ctx, json2, params);
14182
- inst.min = (size, params) => inst.check(_minSize(size, params));
14183
- inst.max = (size, params) => inst.check(_maxSize(size, params));
14184
- inst.mime = (types, params) => inst.check(_mime(Array.isArray(types) ? types : [types], params));
14185
- });
14186
- function file(params) {
14187
- return _file(ZodFile, params);
14188
- }
14189
- var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
14190
- $ZodTransform.init(inst, def);
14191
- ZodType.init(inst, def);
14192
- inst._zod.processJSONSchema = (ctx, json2, params) => transformProcessor(inst, ctx, json2, params);
14193
- inst._zod.parse = (payload, _ctx) => {
14194
- if (_ctx.direction === "backward") {
14195
- throw new $ZodEncodeError(inst.constructor.name);
14293
+ case "boolean": {
14294
+ zodSchema = z.boolean();
14295
+ break;
14196
14296
  }
14197
- payload.addIssue = (issue2) => {
14198
- if (typeof issue2 === "string") {
14199
- payload.issues.push(util_exports.issue(issue2, payload.value, def));
14297
+ case "null": {
14298
+ zodSchema = z.null();
14299
+ break;
14300
+ }
14301
+ case "object": {
14302
+ const shape = {};
14303
+ const properties = schema.properties || {};
14304
+ const requiredSet = new Set(schema.required || []);
14305
+ for (const [key, propSchema] of Object.entries(properties)) {
14306
+ const propZodSchema = convertSchema(propSchema, ctx);
14307
+ shape[key] = requiredSet.has(key) ? propZodSchema : propZodSchema.optional();
14308
+ }
14309
+ if (schema.propertyNames) {
14310
+ const keySchema = convertSchema(schema.propertyNames, ctx);
14311
+ const valueSchema = schema.additionalProperties && typeof schema.additionalProperties === "object" ? convertSchema(schema.additionalProperties, ctx) : z.any();
14312
+ if (Object.keys(shape).length === 0) {
14313
+ zodSchema = z.record(keySchema, valueSchema);
14314
+ break;
14315
+ }
14316
+ const objectSchema2 = z.object(shape).passthrough();
14317
+ const recordSchema = z.looseRecord(keySchema, valueSchema);
14318
+ zodSchema = z.intersection(objectSchema2, recordSchema);
14319
+ break;
14320
+ }
14321
+ if (schema.patternProperties) {
14322
+ const patternProps = schema.patternProperties;
14323
+ const patternKeys = Object.keys(patternProps);
14324
+ const looseRecords = [];
14325
+ for (const pattern of patternKeys) {
14326
+ const patternValue = convertSchema(patternProps[pattern], ctx);
14327
+ const keySchema = z.string().regex(new RegExp(pattern));
14328
+ looseRecords.push(z.looseRecord(keySchema, patternValue));
14329
+ }
14330
+ const schemasToIntersect = [];
14331
+ if (Object.keys(shape).length > 0) {
14332
+ schemasToIntersect.push(z.object(shape).passthrough());
14333
+ }
14334
+ schemasToIntersect.push(...looseRecords);
14335
+ if (schemasToIntersect.length === 0) {
14336
+ zodSchema = z.object({}).passthrough();
14337
+ } else if (schemasToIntersect.length === 1) {
14338
+ zodSchema = schemasToIntersect[0];
14339
+ } else {
14340
+ let result = z.intersection(schemasToIntersect[0], schemasToIntersect[1]);
14341
+ for (let i = 2; i < schemasToIntersect.length; i++) {
14342
+ result = z.intersection(result, schemasToIntersect[i]);
14343
+ }
14344
+ zodSchema = result;
14345
+ }
14346
+ break;
14347
+ }
14348
+ const objectSchema = z.object(shape);
14349
+ if (schema.additionalProperties === false) {
14350
+ zodSchema = objectSchema.strict();
14351
+ } else if (typeof schema.additionalProperties === "object") {
14352
+ zodSchema = objectSchema.catchall(convertSchema(schema.additionalProperties, ctx));
14200
14353
  } else {
14201
- const _issue = issue2;
14202
- if (_issue.fatal)
14203
- _issue.continue = false;
14204
- _issue.code ?? (_issue.code = "custom");
14205
- _issue.input ?? (_issue.input = payload.value);
14206
- _issue.inst ?? (_issue.inst = inst);
14207
- payload.issues.push(util_exports.issue(_issue));
14354
+ zodSchema = objectSchema.passthrough();
14208
14355
  }
14209
- };
14210
- const output = def.transform(payload.value, payload);
14211
- if (output instanceof Promise) {
14212
- return output.then((output2) => {
14213
- payload.value = output2;
14214
- payload.fallback = true;
14215
- return payload;
14216
- });
14356
+ break;
14217
14357
  }
14218
- payload.value = output;
14219
- payload.fallback = true;
14220
- return payload;
14221
- };
14222
- });
14223
- function transform(fn) {
14224
- return new ZodTransform({
14225
- type: "transform",
14226
- transform: fn
14227
- });
14228
- }
14229
- var ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
14230
- $ZodOptional.init(inst, def);
14231
- ZodType.init(inst, def);
14232
- inst._zod.processJSONSchema = (ctx, json2, params) => optionalProcessor(inst, ctx, json2, params);
14233
- inst.unwrap = () => inst._zod.def.innerType;
14234
- });
14235
- function optional(innerType) {
14236
- return new ZodOptional({
14237
- type: "optional",
14238
- innerType
14239
- });
14240
- }
14241
- var ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
14242
- $ZodExactOptional.init(inst, def);
14243
- ZodType.init(inst, def);
14244
- inst._zod.processJSONSchema = (ctx, json2, params) => optionalProcessor(inst, ctx, json2, params);
14245
- inst.unwrap = () => inst._zod.def.innerType;
14246
- });
14247
- function exactOptional(innerType) {
14248
- return new ZodExactOptional({
14249
- type: "optional",
14250
- innerType
14251
- });
14252
- }
14253
- var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
14254
- $ZodNullable.init(inst, def);
14255
- ZodType.init(inst, def);
14256
- inst._zod.processJSONSchema = (ctx, json2, params) => nullableProcessor(inst, ctx, json2, params);
14257
- inst.unwrap = () => inst._zod.def.innerType;
14258
- });
14259
- function nullable(innerType) {
14260
- return new ZodNullable({
14261
- type: "nullable",
14262
- innerType
14263
- });
14264
- }
14265
- function nullish2(innerType) {
14266
- return optional(nullable(innerType));
14358
+ case "array": {
14359
+ const prefixItems = schema.prefixItems;
14360
+ const items = schema.items;
14361
+ if (prefixItems && Array.isArray(prefixItems)) {
14362
+ const tupleItems = prefixItems.map((item) => convertSchema(item, ctx));
14363
+ const rest = items && typeof items === "object" && !Array.isArray(items) ? convertSchema(items, ctx) : void 0;
14364
+ if (rest) {
14365
+ zodSchema = z.tuple(tupleItems).rest(rest);
14366
+ } else {
14367
+ zodSchema = z.tuple(tupleItems);
14368
+ }
14369
+ if (typeof schema.minItems === "number") {
14370
+ zodSchema = zodSchema.check(z.minLength(schema.minItems));
14371
+ }
14372
+ if (typeof schema.maxItems === "number") {
14373
+ zodSchema = zodSchema.check(z.maxLength(schema.maxItems));
14374
+ }
14375
+ } else if (Array.isArray(items)) {
14376
+ const tupleItems = items.map((item) => convertSchema(item, ctx));
14377
+ const rest = schema.additionalItems && typeof schema.additionalItems === "object" ? convertSchema(schema.additionalItems, ctx) : void 0;
14378
+ if (rest) {
14379
+ zodSchema = z.tuple(tupleItems).rest(rest);
14380
+ } else {
14381
+ zodSchema = z.tuple(tupleItems);
14382
+ }
14383
+ if (typeof schema.minItems === "number") {
14384
+ zodSchema = zodSchema.check(z.minLength(schema.minItems));
14385
+ }
14386
+ if (typeof schema.maxItems === "number") {
14387
+ zodSchema = zodSchema.check(z.maxLength(schema.maxItems));
14388
+ }
14389
+ } else if (items !== void 0) {
14390
+ const element = convertSchema(items, ctx);
14391
+ let arraySchema = z.array(element);
14392
+ if (typeof schema.minItems === "number") {
14393
+ arraySchema = arraySchema.min(schema.minItems);
14394
+ }
14395
+ if (typeof schema.maxItems === "number") {
14396
+ arraySchema = arraySchema.max(schema.maxItems);
14397
+ }
14398
+ zodSchema = arraySchema;
14399
+ } else {
14400
+ zodSchema = z.array(z.any());
14401
+ }
14402
+ break;
14403
+ }
14404
+ default:
14405
+ throw new Error(`Unsupported type: ${type}`);
14406
+ }
14407
+ return zodSchema;
14267
14408
  }
14268
- var ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
14269
- $ZodDefault.init(inst, def);
14270
- ZodType.init(inst, def);
14271
- inst._zod.processJSONSchema = (ctx, json2, params) => defaultProcessor(inst, ctx, json2, params);
14272
- inst.unwrap = () => inst._zod.def.innerType;
14273
- inst.removeDefault = inst.unwrap;
14274
- });
14275
- function _default2(innerType, defaultValue) {
14276
- return new ZodDefault({
14277
- type: "default",
14278
- innerType,
14279
- get defaultValue() {
14280
- return typeof defaultValue === "function" ? defaultValue() : util_exports.shallowClone(defaultValue);
14409
+ function convertSchema(schema, ctx) {
14410
+ if (typeof schema === "boolean") {
14411
+ return schema ? z.any() : z.never();
14412
+ }
14413
+ let baseSchema = convertBaseSchema(schema, ctx);
14414
+ const hasExplicitType = schema.type || schema.enum !== void 0 || schema.const !== void 0;
14415
+ if (schema.anyOf && Array.isArray(schema.anyOf)) {
14416
+ const options = schema.anyOf.map((s) => convertSchema(s, ctx));
14417
+ const anyOfUnion = z.union(options);
14418
+ baseSchema = hasExplicitType ? z.intersection(baseSchema, anyOfUnion) : anyOfUnion;
14419
+ }
14420
+ if (schema.oneOf && Array.isArray(schema.oneOf)) {
14421
+ const options = schema.oneOf.map((s) => convertSchema(s, ctx));
14422
+ const oneOfUnion = z.xor(options);
14423
+ baseSchema = hasExplicitType ? z.intersection(baseSchema, oneOfUnion) : oneOfUnion;
14424
+ }
14425
+ if (schema.allOf && Array.isArray(schema.allOf)) {
14426
+ if (schema.allOf.length === 0) {
14427
+ baseSchema = hasExplicitType ? baseSchema : z.any();
14428
+ } else {
14429
+ let result = hasExplicitType ? baseSchema : convertSchema(schema.allOf[0], ctx);
14430
+ const startIdx = hasExplicitType ? 0 : 1;
14431
+ for (let i = startIdx; i < schema.allOf.length; i++) {
14432
+ result = z.intersection(result, convertSchema(schema.allOf[i], ctx));
14433
+ }
14434
+ baseSchema = result;
14281
14435
  }
14282
- });
14283
- }
14284
- var ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
14285
- $ZodPrefault.init(inst, def);
14286
- ZodType.init(inst, def);
14287
- inst._zod.processJSONSchema = (ctx, json2, params) => prefaultProcessor(inst, ctx, json2, params);
14288
- inst.unwrap = () => inst._zod.def.innerType;
14289
- });
14290
- function prefault(innerType, defaultValue) {
14291
- return new ZodPrefault({
14292
- type: "prefault",
14293
- innerType,
14294
- get defaultValue() {
14295
- return typeof defaultValue === "function" ? defaultValue() : util_exports.shallowClone(defaultValue);
14436
+ }
14437
+ if (schema.nullable === true && ctx.version === "openapi-3.0") {
14438
+ baseSchema = z.nullable(baseSchema);
14439
+ }
14440
+ if (schema.readOnly === true) {
14441
+ baseSchema = z.readonly(baseSchema);
14442
+ }
14443
+ if (schema.default !== void 0) {
14444
+ baseSchema = baseSchema.default(schema.default);
14445
+ }
14446
+ const extraMeta = {};
14447
+ const coreMetadataKeys = ["$id", "id", "$comment", "$anchor", "$vocabulary", "$dynamicRef", "$dynamicAnchor"];
14448
+ for (const key of coreMetadataKeys) {
14449
+ if (key in schema) {
14450
+ extraMeta[key] = schema[key];
14296
14451
  }
14297
- });
14298
- }
14299
- var ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
14300
- $ZodNonOptional.init(inst, def);
14301
- ZodType.init(inst, def);
14302
- inst._zod.processJSONSchema = (ctx, json2, params) => nonoptionalProcessor(inst, ctx, json2, params);
14303
- inst.unwrap = () => inst._zod.def.innerType;
14304
- });
14305
- function nonoptional(innerType, params) {
14306
- return new ZodNonOptional({
14307
- type: "nonoptional",
14308
- innerType,
14309
- ...util_exports.normalizeParams(params)
14310
- });
14311
- }
14312
- var ZodSuccess = /* @__PURE__ */ $constructor("ZodSuccess", (inst, def) => {
14313
- $ZodSuccess.init(inst, def);
14314
- ZodType.init(inst, def);
14315
- inst._zod.processJSONSchema = (ctx, json2, params) => successProcessor(inst, ctx, json2, params);
14316
- inst.unwrap = () => inst._zod.def.innerType;
14317
- });
14318
- function success(innerType) {
14319
- return new ZodSuccess({
14320
- type: "success",
14321
- innerType
14322
- });
14323
- }
14324
- var ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
14325
- $ZodCatch.init(inst, def);
14326
- ZodType.init(inst, def);
14327
- inst._zod.processJSONSchema = (ctx, json2, params) => catchProcessor(inst, ctx, json2, params);
14328
- inst.unwrap = () => inst._zod.def.innerType;
14329
- inst.removeCatch = inst.unwrap;
14330
- });
14331
- function _catch2(innerType, catchValue) {
14332
- return new ZodCatch({
14333
- type: "catch",
14334
- innerType,
14335
- catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
14336
- });
14337
- }
14338
- var ZodNaN = /* @__PURE__ */ $constructor("ZodNaN", (inst, def) => {
14339
- $ZodNaN.init(inst, def);
14340
- ZodType.init(inst, def);
14341
- inst._zod.processJSONSchema = (ctx, json2, params) => nanProcessor(inst, ctx, json2, params);
14342
- });
14343
- function nan(params) {
14344
- return _nan(ZodNaN, params);
14345
- }
14346
- var ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
14347
- $ZodPipe.init(inst, def);
14348
- ZodType.init(inst, def);
14349
- inst._zod.processJSONSchema = (ctx, json2, params) => pipeProcessor(inst, ctx, json2, params);
14350
- inst.in = def.in;
14351
- inst.out = def.out;
14352
- });
14353
- function pipe(in_, out) {
14354
- return new ZodPipe({
14355
- type: "pipe",
14356
- in: in_,
14357
- out
14358
- // ...util.normalizeParams(params),
14359
- });
14360
- }
14361
- var ZodCodec = /* @__PURE__ */ $constructor("ZodCodec", (inst, def) => {
14362
- ZodPipe.init(inst, def);
14363
- $ZodCodec.init(inst, def);
14364
- });
14365
- function codec(in_, out, params) {
14366
- return new ZodCodec({
14367
- type: "pipe",
14368
- in: in_,
14369
- out,
14370
- transform: params.decode,
14371
- reverseTransform: params.encode
14372
- });
14373
- }
14374
- function invertCodec(codec2) {
14375
- const def = codec2._zod.def;
14376
- return new ZodCodec({
14377
- type: "pipe",
14378
- in: def.out,
14379
- out: def.in,
14380
- transform: def.reverseTransform,
14381
- reverseTransform: def.transform
14382
- });
14383
- }
14384
- var ZodPreprocess = /* @__PURE__ */ $constructor("ZodPreprocess", (inst, def) => {
14385
- ZodPipe.init(inst, def);
14386
- $ZodPreprocess.init(inst, def);
14387
- });
14388
- var ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
14389
- $ZodReadonly.init(inst, def);
14390
- ZodType.init(inst, def);
14391
- inst._zod.processJSONSchema = (ctx, json2, params) => readonlyProcessor(inst, ctx, json2, params);
14392
- inst.unwrap = () => inst._zod.def.innerType;
14393
- });
14394
- function readonly(innerType) {
14395
- return new ZodReadonly({
14396
- type: "readonly",
14397
- innerType
14398
- });
14399
- }
14400
- var ZodTemplateLiteral = /* @__PURE__ */ $constructor("ZodTemplateLiteral", (inst, def) => {
14401
- $ZodTemplateLiteral.init(inst, def);
14402
- ZodType.init(inst, def);
14403
- inst._zod.processJSONSchema = (ctx, json2, params) => templateLiteralProcessor(inst, ctx, json2, params);
14404
- });
14405
- function templateLiteral(parts, params) {
14406
- return new ZodTemplateLiteral({
14407
- type: "template_literal",
14408
- parts,
14409
- ...util_exports.normalizeParams(params)
14410
- });
14411
- }
14412
- var ZodLazy = /* @__PURE__ */ $constructor("ZodLazy", (inst, def) => {
14413
- $ZodLazy.init(inst, def);
14414
- ZodType.init(inst, def);
14415
- inst._zod.processJSONSchema = (ctx, json2, params) => lazyProcessor(inst, ctx, json2, params);
14416
- inst.unwrap = () => inst._zod.def.getter();
14417
- });
14418
- function lazy(getter) {
14419
- return new ZodLazy({
14420
- type: "lazy",
14421
- getter
14422
- });
14423
- }
14424
- var ZodPromise = /* @__PURE__ */ $constructor("ZodPromise", (inst, def) => {
14425
- $ZodPromise.init(inst, def);
14426
- ZodType.init(inst, def);
14427
- inst._zod.processJSONSchema = (ctx, json2, params) => promiseProcessor(inst, ctx, json2, params);
14428
- inst.unwrap = () => inst._zod.def.innerType;
14429
- });
14430
- function promise(innerType) {
14431
- return new ZodPromise({
14432
- type: "promise",
14433
- innerType
14434
- });
14435
- }
14436
- var ZodFunction = /* @__PURE__ */ $constructor("ZodFunction", (inst, def) => {
14437
- $ZodFunction.init(inst, def);
14438
- ZodType.init(inst, def);
14439
- inst._zod.processJSONSchema = (ctx, json2, params) => functionProcessor(inst, ctx, json2, params);
14440
- });
14441
- function _function(params) {
14442
- return new ZodFunction({
14443
- type: "function",
14444
- input: Array.isArray(params?.input) ? tuple(params?.input) : params?.input ?? array(unknown()),
14445
- output: params?.output ?? unknown()
14446
- });
14447
- }
14448
- var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
14449
- $ZodCustom.init(inst, def);
14450
- ZodType.init(inst, def);
14451
- inst._zod.processJSONSchema = (ctx, json2, params) => customProcessor(inst, ctx, json2, params);
14452
- });
14453
- function check(fn) {
14454
- const ch = new $ZodCheck({
14455
- check: "custom"
14456
- // ...util.normalizeParams(params),
14457
- });
14458
- ch._zod.check = fn;
14459
- return ch;
14460
- }
14461
- function custom(fn, _params) {
14462
- return _custom(ZodCustom, fn ?? (() => true), _params);
14463
- }
14464
- function refine(fn, _params = {}) {
14465
- return _refine(ZodCustom, fn, _params);
14466
- }
14467
- function superRefine(fn, params) {
14468
- return _superRefine(fn, params);
14469
- }
14470
- var describe2 = describe;
14471
- var meta2 = meta;
14472
- function _instanceof(cls, params = {}) {
14473
- const inst = new ZodCustom({
14474
- type: "custom",
14475
- check: "custom",
14476
- fn: (data) => data instanceof cls,
14477
- abort: true,
14478
- ...util_exports.normalizeParams(params)
14479
- });
14480
- inst._zod.bag.Class = cls;
14481
- inst._zod.check = (payload) => {
14482
- if (!(payload.value instanceof cls)) {
14483
- payload.issues.push({
14484
- code: "invalid_type",
14485
- expected: cls.name,
14486
- input: payload.value,
14487
- inst,
14488
- path: [...inst._zod.def.path ?? []]
14489
- });
14452
+ }
14453
+ const contentMetadataKeys = ["contentEncoding", "contentMediaType", "contentSchema"];
14454
+ for (const key of contentMetadataKeys) {
14455
+ if (key in schema) {
14456
+ extraMeta[key] = schema[key];
14457
+ }
14458
+ }
14459
+ for (const key of Object.keys(schema)) {
14460
+ if (!RECOGNIZED_KEYS.has(key)) {
14461
+ extraMeta[key] = schema[key];
14490
14462
  }
14463
+ }
14464
+ if (Object.keys(extraMeta).length > 0) {
14465
+ ctx.registry.add(baseSchema, extraMeta);
14466
+ }
14467
+ if (schema.description) {
14468
+ baseSchema = baseSchema.describe(schema.description);
14469
+ }
14470
+ return baseSchema;
14471
+ }
14472
+ function fromJSONSchema(schema, params) {
14473
+ if (typeof schema === "boolean") {
14474
+ return schema ? z.any() : z.never();
14475
+ }
14476
+ let normalized;
14477
+ try {
14478
+ normalized = JSON.parse(JSON.stringify(schema));
14479
+ } catch {
14480
+ throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas");
14481
+ }
14482
+ const version2 = detectVersion(normalized, params?.defaultTarget);
14483
+ const defs = normalized.$defs || normalized.definitions || {};
14484
+ const ctx = {
14485
+ version: version2,
14486
+ defs,
14487
+ refs: /* @__PURE__ */ new Map(),
14488
+ processing: /* @__PURE__ */ new Set(),
14489
+ rootSchema: normalized,
14490
+ registry: params?.registry ?? globalRegistry
14491
14491
  };
14492
- return inst;
14492
+ return convertSchema(normalized, ctx);
14493
14493
  }
14494
- var stringbool = (...args) => _stringbool({
14495
- Codec: ZodCodec,
14496
- Boolean: ZodBoolean,
14497
- String: ZodString
14498
- }, ...args);
14499
- function json(params) {
14500
- const jsonSchema = lazy(() => {
14501
- return union([string2(params), number2(), boolean2(), _null3(), array(jsonSchema), record(string2(), jsonSchema)]);
14502
- });
14503
- return jsonSchema;
14494
+
14495
+ // node_modules/zod/v4/classic/coerce.js
14496
+ var coerce_exports = {};
14497
+ __export(coerce_exports, {
14498
+ bigint: () => bigint3,
14499
+ boolean: () => boolean3,
14500
+ date: () => date4,
14501
+ number: () => number3,
14502
+ string: () => string3
14503
+ });
14504
+ function string3(params) {
14505
+ return _coercedString(ZodString, params);
14504
14506
  }
14505
- function preprocess(fn, schema) {
14506
- return new ZodPreprocess({
14507
- type: "pipe",
14508
- in: transform(fn),
14509
- out: schema
14510
- });
14507
+ function number3(params) {
14508
+ return _coercedNumber(ZodNumber, params);
14511
14509
  }
14512
-
14513
- // node_modules/zod/v4/classic/compat.js
14514
- var ZodIssueCode = {
14515
- invalid_type: "invalid_type",
14516
- too_big: "too_big",
14517
- too_small: "too_small",
14518
- invalid_format: "invalid_format",
14519
- not_multiple_of: "not_multiple_of",
14520
- unrecognized_keys: "unrecognized_keys",
14521
- invalid_union: "invalid_union",
14522
- invalid_key: "invalid_key",
14523
- invalid_element: "invalid_element",
14524
- invalid_value: "invalid_value",
14525
- custom: "custom"
14526
- };
14527
- function setErrorMap(map2) {
14528
- config({
14529
- customError: map2
14530
- });
14510
+ function boolean3(params) {
14511
+ return _coercedBoolean(ZodBoolean, params);
14531
14512
  }
14532
- function getErrorMap() {
14533
- return config().customError;
14513
+ function bigint3(params) {
14514
+ return _coercedBigint(ZodBigInt, params);
14515
+ }
14516
+ function date4(params) {
14517
+ return _coercedDate(ZodDate, params);
14534
14518
  }
14535
- var ZodFirstPartyTypeKind;
14536
- /* @__PURE__ */ (function(ZodFirstPartyTypeKind2) {
14537
- })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
14538
14519
 
14539
- // node_modules/zod/v4/classic/from-json-schema.js
14540
- var z = {
14541
- ...schemas_exports2,
14542
- ...checks_exports2,
14543
- iso: iso_exports
14544
- };
14545
- var RECOGNIZED_KEYS = /* @__PURE__ */ new Set([
14546
- // Schema identification
14547
- "$schema",
14548
- "$ref",
14549
- "$defs",
14550
- "definitions",
14551
- // Core schema keywords
14552
- "$id",
14553
- "id",
14554
- "$comment",
14555
- "$anchor",
14556
- "$vocabulary",
14557
- "$dynamicRef",
14558
- "$dynamicAnchor",
14559
- // Type
14560
- "type",
14561
- "enum",
14562
- "const",
14563
- // Composition
14564
- "anyOf",
14565
- "oneOf",
14566
- "allOf",
14567
- "not",
14568
- // Object
14569
- "properties",
14570
- "required",
14571
- "additionalProperties",
14572
- "patternProperties",
14573
- "propertyNames",
14574
- "minProperties",
14575
- "maxProperties",
14576
- // Array
14577
- "items",
14578
- "prefixItems",
14579
- "additionalItems",
14580
- "minItems",
14581
- "maxItems",
14582
- "uniqueItems",
14583
- "contains",
14584
- "minContains",
14585
- "maxContains",
14586
- // String
14587
- "minLength",
14588
- "maxLength",
14589
- "pattern",
14590
- "format",
14591
- // Number
14592
- "minimum",
14593
- "maximum",
14594
- "exclusiveMinimum",
14595
- "exclusiveMaximum",
14596
- "multipleOf",
14597
- // Already handled metadata
14598
- "description",
14599
- "default",
14600
- // Content
14601
- "contentEncoding",
14602
- "contentMediaType",
14603
- "contentSchema",
14604
- // Unsupported (error-throwing)
14605
- "unevaluatedItems",
14606
- "unevaluatedProperties",
14607
- "if",
14608
- "then",
14609
- "else",
14610
- "dependentSchemas",
14611
- "dependentRequired",
14612
- // OpenAPI
14613
- "nullable",
14614
- "readOnly"
14615
- ]);
14616
- function detectVersion(schema, defaultTarget) {
14617
- const $schema = schema.$schema;
14618
- if ($schema === "https://json-schema.org/draft/2020-12/schema") {
14619
- return "draft-2020-12";
14520
+ // node_modules/zod/v4/classic/external.js
14521
+ config(en_default());
14522
+
14523
+ // node_modules/@opentabs-dev/shared/dist/error.js
14524
+ var toErrorMessage = (err2) => err2 instanceof Error ? err2.message : String(err2);
14525
+
14526
+ // node_modules/@opentabs-dev/plugin-sdk/dist/errors.js
14527
+ var ToolError = class _ToolError extends Error {
14528
+ code;
14529
+ /** Whether this error is retryable (defaults to false). */
14530
+ retryable;
14531
+ /** Suggested delay before retrying, in milliseconds. */
14532
+ retryAfterMs;
14533
+ /** Error category for structured error classification. */
14534
+ category;
14535
+ constructor(message, code, opts) {
14536
+ super(message);
14537
+ this.code = code;
14538
+ this.name = "ToolError";
14539
+ this.retryable = opts?.retryable ?? false;
14540
+ this.retryAfterMs = opts?.retryAfterMs;
14541
+ this.category = opts?.category;
14620
14542
  }
14621
- if ($schema === "http://json-schema.org/draft-07/schema#") {
14622
- return "draft-7";
14543
+ /** Authentication or authorization error (not retryable). Accepts an optional domain-specific code. */
14544
+ static auth(message, code) {
14545
+ return new _ToolError(message, code ?? "AUTH_ERROR", { category: "auth", retryable: false });
14623
14546
  }
14624
- if ($schema === "http://json-schema.org/draft-04/schema#") {
14625
- return "draft-4";
14547
+ /** Resource not found (not retryable). Accepts an optional domain-specific code. */
14548
+ static notFound(message, code) {
14549
+ return new _ToolError(message, code ?? "NOT_FOUND", { category: "not_found", retryable: false });
14626
14550
  }
14627
- return defaultTarget ?? "draft-2020-12";
14628
- }
14629
- function resolveRef(ref, ctx) {
14630
- if (!ref.startsWith("#")) {
14631
- throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
14551
+ /** Rate limited (retryable). Accepts an optional retry delay in milliseconds and an optional domain-specific code. */
14552
+ static rateLimited(message, retryAfterMs, code) {
14553
+ return new _ToolError(message, code ?? "RATE_LIMITED", { category: "rate_limit", retryable: true, retryAfterMs });
14632
14554
  }
14633
- const path = ref.slice(1).split("/").filter(Boolean);
14634
- if (path.length === 0) {
14635
- return ctx.rootSchema;
14555
+ /** Input validation error (not retryable). Accepts an optional domain-specific code. */
14556
+ static validation(message, code) {
14557
+ return new _ToolError(message, code ?? "VALIDATION_ERROR", { category: "validation", retryable: false });
14636
14558
  }
14637
- const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14638
- if (path[0] === defsKey) {
14639
- const key = path[1];
14640
- if (!key || !ctx.defs[key]) {
14641
- throw new Error(`Reference not found: ${ref}`);
14642
- }
14643
- return ctx.defs[key];
14559
+ /** Operation timed out (retryable). Accepts an optional domain-specific code. */
14560
+ static timeout(message, code) {
14561
+ return new _ToolError(message, code ?? "TIMEOUT", { category: "timeout", retryable: true });
14644
14562
  }
14645
- throw new Error(`Reference not found: ${ref}`);
14646
- }
14647
- function convertBaseSchema(schema, ctx) {
14648
- if (schema.not !== void 0) {
14649
- if (typeof schema.not === "object" && Object.keys(schema.not).length === 0) {
14650
- return z.never();
14651
- }
14652
- throw new Error("not is not supported in Zod (except { not: {} } for never)");
14563
+ /** Internal/unexpected error (not retryable). Accepts an optional domain-specific code. */
14564
+ static internal(message, code) {
14565
+ return new _ToolError(message, code ?? "INTERNAL_ERROR", { category: "internal", retryable: false });
14653
14566
  }
14654
- if (schema.unevaluatedItems !== void 0) {
14655
- throw new Error("unevaluatedItems is not supported");
14567
+ };
14568
+
14569
+ // node_modules/@opentabs-dev/plugin-sdk/dist/fetch.js
14570
+ var MAX_ERROR_BODY_LENGTH = 512;
14571
+ var httpStatusToToolError = (response, message) => {
14572
+ const status = response.status;
14573
+ if (status === 401 || status === 403) {
14574
+ return ToolError.auth(message);
14575
+ }
14576
+ if (status === 404) {
14577
+ return ToolError.notFound(message);
14578
+ }
14579
+ if (status === 429) {
14580
+ const retryAfter = response.headers.get("Retry-After");
14581
+ const retryAfterMs = retryAfter !== null ? parseRetryAfterMs(retryAfter) : void 0;
14582
+ return ToolError.rateLimited(message, retryAfterMs);
14583
+ }
14584
+ if (status === 400 || status === 422) {
14585
+ return ToolError.validation(message);
14586
+ }
14587
+ if (status === 408) {
14588
+ return ToolError.timeout(message);
14589
+ }
14590
+ if (status >= 500) {
14591
+ const TRANSIENT_5XX = /* @__PURE__ */ new Set([500, 502, 503, 504]);
14592
+ const retryable = TRANSIENT_5XX.has(status);
14593
+ const retryAfter = status === 503 ? response.headers.get("Retry-After") : null;
14594
+ const retryAfterMs = retryAfter !== null ? parseRetryAfterMs(retryAfter) : void 0;
14595
+ return new ToolError(message, "http_error", { category: "internal", retryable, retryAfterMs });
14656
14596
  }
14657
- if (schema.unevaluatedProperties !== void 0) {
14658
- throw new Error("unevaluatedProperties is not supported");
14597
+ if (status >= 400 && status < 500) {
14598
+ return new ToolError(message, "http_error", { retryable: false });
14659
14599
  }
14660
- if (schema.if !== void 0 || schema.then !== void 0 || schema.else !== void 0) {
14661
- throw new Error("Conditional schemas (if/then/else) are not supported");
14600
+ return new ToolError(message, "http_error", { category: "internal" });
14601
+ };
14602
+ var parseRetryAfterMs = (value) => {
14603
+ const seconds = Number(value);
14604
+ if (!Number.isNaN(seconds) && seconds >= 0) {
14605
+ return seconds * 1e3;
14662
14606
  }
14663
- if (schema.dependentSchemas !== void 0 || schema.dependentRequired !== void 0) {
14664
- throw new Error("dependentSchemas and dependentRequired are not supported");
14607
+ const date5 = Date.parse(value);
14608
+ if (!Number.isNaN(date5)) {
14609
+ const ms = date5 - Date.now();
14610
+ return ms > 0 ? ms : void 0;
14665
14611
  }
14666
- if (schema.$ref) {
14667
- const refPath = schema.$ref;
14668
- if (ctx.refs.has(refPath)) {
14669
- return ctx.refs.get(refPath);
14670
- }
14671
- if (ctx.processing.has(refPath)) {
14672
- return z.lazy(() => {
14673
- if (!ctx.refs.has(refPath)) {
14674
- throw new Error(`Circular reference not resolved: ${refPath}`);
14675
- }
14676
- return ctx.refs.get(refPath);
14677
- });
14612
+ return void 0;
14613
+ };
14614
+ var buildQueryString = (params) => {
14615
+ const searchParams = new URLSearchParams();
14616
+ for (const [key, value] of Object.entries(params)) {
14617
+ if (value === void 0)
14618
+ continue;
14619
+ if (Array.isArray(value)) {
14620
+ for (const item of value) {
14621
+ searchParams.append(key, String(item));
14622
+ }
14623
+ } else {
14624
+ searchParams.append(key, String(value));
14678
14625
  }
14679
- ctx.processing.add(refPath);
14680
- const resolved = resolveRef(refPath, ctx);
14681
- const zodSchema2 = convertSchema(resolved, ctx);
14682
- ctx.refs.set(refPath, zodSchema2);
14683
- ctx.processing.delete(refPath);
14684
- return zodSchema2;
14685
14626
  }
14686
- if (schema.enum !== void 0) {
14687
- const enumValues = schema.enum;
14688
- if (ctx.version === "openapi-3.0" && schema.nullable === true && enumValues.length === 1 && enumValues[0] === null) {
14689
- return z.null();
14690
- }
14691
- if (enumValues.length === 0) {
14692
- return z.never();
14693
- }
14694
- if (enumValues.length === 1) {
14695
- return z.literal(enumValues[0]);
14696
- }
14697
- if (enumValues.every((v) => typeof v === "string")) {
14698
- return z.enum(enumValues);
14627
+ return searchParams.toString();
14628
+ };
14629
+ var fetchFromPage = async (url2, init) => {
14630
+ const { timeout = 3e4, signal, ...rest } = init ?? {};
14631
+ const timeoutSignal = AbortSignal.timeout(timeout);
14632
+ const combinedSignal = signal ? AbortSignal.any([signal, timeoutSignal]) : timeoutSignal;
14633
+ let response;
14634
+ try {
14635
+ response = await fetch(url2, {
14636
+ credentials: "include",
14637
+ ...rest,
14638
+ signal: combinedSignal
14639
+ });
14640
+ } catch (error51) {
14641
+ if (error51 instanceof DOMException && error51.name === "TimeoutError") {
14642
+ throw ToolError.timeout(`fetchFromPage: request timed out after ${timeout}ms for ${url2}`);
14699
14643
  }
14700
- const literalSchemas = enumValues.map((v) => z.literal(v));
14701
- if (literalSchemas.length < 2) {
14702
- return literalSchemas[0];
14644
+ if (combinedSignal.aborted) {
14645
+ throw new ToolError(`fetchFromPage: request aborted for ${url2}`, "aborted");
14703
14646
  }
14704
- return z.union([literalSchemas[0], literalSchemas[1], ...literalSchemas.slice(2)]);
14647
+ throw new ToolError(`fetchFromPage: network error for ${url2}: ${toErrorMessage(error51)}`, "network_error", {
14648
+ category: "internal",
14649
+ retryable: true
14650
+ });
14705
14651
  }
14706
- if (schema.const !== void 0) {
14707
- return z.literal(schema.const);
14652
+ if (!response.ok) {
14653
+ const rawText = await response.text().catch(() => response.statusText);
14654
+ const errorText = rawText.length > MAX_ERROR_BODY_LENGTH ? `${rawText.slice(0, MAX_ERROR_BODY_LENGTH)}\u2026` : rawText;
14655
+ const msg = `fetchFromPage: HTTP ${response.status} for ${url2}: ${errorText}`;
14656
+ throw httpStatusToToolError(response, msg);
14708
14657
  }
14709
- const type = schema.type;
14710
- if (Array.isArray(type)) {
14711
- const typeSchemas = type.map((t) => {
14712
- const typeSchema = { ...schema, type: t };
14713
- return convertBaseSchema(typeSchema, ctx);
14714
- });
14715
- if (typeSchemas.length === 0) {
14716
- return z.never();
14658
+ return response;
14659
+ };
14660
+ var fetchJSONImpl = async (url2, init, schema) => {
14661
+ const response = await fetchFromPage(url2, init);
14662
+ let data;
14663
+ if (response.status === 204 || response.headers.get("content-length") === "0") {
14664
+ if (!schema) {
14665
+ return void 0;
14717
14666
  }
14718
- if (typeSchemas.length === 1) {
14719
- return typeSchemas[0];
14667
+ throw ToolError.validation(`fetchJSON: expected JSON response from ${url2} but received HTTP ${response.status} with no body to validate`);
14668
+ } else {
14669
+ try {
14670
+ data = await response.json();
14671
+ } catch {
14672
+ throw ToolError.validation(`fetchJSON: failed to parse JSON response from ${url2}`);
14720
14673
  }
14721
- return z.union(typeSchemas);
14722
14674
  }
14723
- if (!type) {
14724
- return z.any();
14725
- }
14726
- let zodSchema;
14727
- switch (type) {
14728
- case "string": {
14729
- let stringSchema = z.string();
14730
- if (schema.format) {
14731
- const format = schema.format;
14732
- if (format === "email") {
14733
- stringSchema = stringSchema.check(z.email());
14734
- } else if (format === "uri" || format === "uri-reference") {
14735
- stringSchema = stringSchema.check(z.url());
14736
- } else if (format === "uuid" || format === "guid") {
14737
- stringSchema = stringSchema.check(z.uuid());
14738
- } else if (format === "date-time") {
14739
- stringSchema = stringSchema.check(z.iso.datetime());
14740
- } else if (format === "date") {
14741
- stringSchema = stringSchema.check(z.iso.date());
14742
- } else if (format === "time") {
14743
- stringSchema = stringSchema.check(z.iso.time());
14744
- } else if (format === "duration") {
14745
- stringSchema = stringSchema.check(z.iso.duration());
14746
- } else if (format === "ipv4") {
14747
- stringSchema = stringSchema.check(z.ipv4());
14748
- } else if (format === "ipv6") {
14749
- stringSchema = stringSchema.check(z.ipv6());
14750
- } else if (format === "mac") {
14751
- stringSchema = stringSchema.check(z.mac());
14752
- } else if (format === "cidr") {
14753
- stringSchema = stringSchema.check(z.cidrv4());
14754
- } else if (format === "cidr-v6") {
14755
- stringSchema = stringSchema.check(z.cidrv6());
14756
- } else if (format === "base64") {
14757
- stringSchema = stringSchema.check(z.base64());
14758
- } else if (format === "base64url") {
14759
- stringSchema = stringSchema.check(z.base64url());
14760
- } else if (format === "e164") {
14761
- stringSchema = stringSchema.check(z.e164());
14762
- } else if (format === "jwt") {
14763
- stringSchema = stringSchema.check(z.jwt());
14764
- } else if (format === "emoji") {
14765
- stringSchema = stringSchema.check(z.emoji());
14766
- } else if (format === "nanoid") {
14767
- stringSchema = stringSchema.check(z.nanoid());
14768
- } else if (format === "cuid") {
14769
- stringSchema = stringSchema.check(z.cuid());
14770
- } else if (format === "cuid2") {
14771
- stringSchema = stringSchema.check(z.cuid2());
14772
- } else if (format === "ulid") {
14773
- stringSchema = stringSchema.check(z.ulid());
14774
- } else if (format === "xid") {
14775
- stringSchema = stringSchema.check(z.xid());
14776
- } else if (format === "ksuid") {
14777
- stringSchema = stringSchema.check(z.ksuid());
14778
- }
14779
- }
14780
- if (typeof schema.minLength === "number") {
14781
- stringSchema = stringSchema.min(schema.minLength);
14782
- }
14783
- if (typeof schema.maxLength === "number") {
14784
- stringSchema = stringSchema.max(schema.maxLength);
14785
- }
14786
- if (schema.pattern) {
14787
- stringSchema = stringSchema.regex(new RegExp(schema.pattern));
14788
- }
14789
- zodSchema = stringSchema;
14790
- break;
14675
+ if (schema) {
14676
+ const result = schema.safeParse(data);
14677
+ if (!result.success) {
14678
+ throw ToolError.validation(`fetchJSON: response from ${url2} failed schema validation: ${result.error.message}`);
14791
14679
  }
14792
- case "number":
14793
- case "integer": {
14794
- let numberSchema = type === "integer" ? z.number().int() : z.number();
14795
- if (typeof schema.minimum === "number") {
14796
- numberSchema = numberSchema.min(schema.minimum);
14797
- }
14798
- if (typeof schema.maximum === "number") {
14799
- numberSchema = numberSchema.max(schema.maximum);
14800
- }
14801
- if (typeof schema.exclusiveMinimum === "number") {
14802
- numberSchema = numberSchema.gt(schema.exclusiveMinimum);
14803
- } else if (schema.exclusiveMinimum === true && typeof schema.minimum === "number") {
14804
- numberSchema = numberSchema.gt(schema.minimum);
14805
- }
14806
- if (typeof schema.exclusiveMaximum === "number") {
14807
- numberSchema = numberSchema.lt(schema.exclusiveMaximum);
14808
- } else if (schema.exclusiveMaximum === true && typeof schema.maximum === "number") {
14809
- numberSchema = numberSchema.lt(schema.maximum);
14680
+ return result.data;
14681
+ }
14682
+ return data;
14683
+ };
14684
+ var fetchJSON = fetchJSONImpl;
14685
+
14686
+ // node_modules/@opentabs-dev/plugin-sdk/dist/timing.js
14687
+ var waitUntil = (predicate, opts) => {
14688
+ const interval = opts?.interval ?? 200;
14689
+ const timeout = opts?.timeout ?? 1e4;
14690
+ const signal = opts?.signal;
14691
+ const abortReason = () => signal?.reason instanceof Error ? signal.reason : new Error("waitUntil: aborted");
14692
+ if (signal?.aborted)
14693
+ return Promise.reject(abortReason());
14694
+ return new Promise((resolve, reject) => {
14695
+ let settled = false;
14696
+ let poller;
14697
+ let lastPredicateError;
14698
+ const isSettled = () => settled;
14699
+ const cleanup = () => {
14700
+ settled = true;
14701
+ clearTimeout(timer);
14702
+ clearTimeout(poller);
14703
+ signal?.removeEventListener("abort", onAbort);
14704
+ };
14705
+ const onAbort = () => {
14706
+ if (isSettled())
14707
+ return;
14708
+ cleanup();
14709
+ reject(abortReason());
14710
+ };
14711
+ signal?.addEventListener("abort", onAbort, { once: true });
14712
+ const timer = setTimeout(() => {
14713
+ if (isSettled())
14714
+ return;
14715
+ cleanup();
14716
+ const errorContext = lastPredicateError instanceof Error ? `: predicate last threw \u2014 ${lastPredicateError.message}` : "";
14717
+ reject(new Error(`waitUntil: timed out after ${timeout}ms waiting for predicate to return true${errorContext}`));
14718
+ }, timeout);
14719
+ const check2 = async () => {
14720
+ if (isSettled())
14721
+ return;
14722
+ try {
14723
+ const result = await predicate();
14724
+ if (result) {
14725
+ cleanup();
14726
+ resolve();
14727
+ return;
14728
+ }
14729
+ } catch (err2) {
14730
+ lastPredicateError = err2;
14810
14731
  }
14811
- if (typeof schema.multipleOf === "number") {
14812
- numberSchema = numberSchema.multipleOf(schema.multipleOf);
14732
+ if (!isSettled()) {
14733
+ poller = setTimeout(() => void check2(), interval);
14813
14734
  }
14814
- zodSchema = numberSchema;
14815
- break;
14816
- }
14817
- case "boolean": {
14818
- zodSchema = z.boolean();
14819
- break;
14820
- }
14821
- case "null": {
14822
- zodSchema = z.null();
14823
- break;
14735
+ };
14736
+ void check2();
14737
+ });
14738
+ };
14739
+
14740
+ // node_modules/@opentabs-dev/plugin-sdk/dist/log.js
14741
+ var MAX_DATA_LENGTH = 10;
14742
+ var MAX_STRING_LENGTH = 4096;
14743
+ var MAX_SERIALIZED_SIZE = 64 * 1024;
14744
+ var safeSerializeArg = (value) => {
14745
+ try {
14746
+ if (value === null || value === void 0)
14747
+ return value;
14748
+ const type = typeof value;
14749
+ if (type === "boolean" || type === "number")
14750
+ return value;
14751
+ if (type === "string") {
14752
+ return value.length > MAX_STRING_LENGTH ? `${value.slice(0, MAX_STRING_LENGTH)}\u2026` : value;
14824
14753
  }
14825
- case "object": {
14826
- const shape = {};
14827
- const properties = schema.properties || {};
14828
- const requiredSet = new Set(schema.required || []);
14829
- for (const [key, propSchema] of Object.entries(properties)) {
14830
- const propZodSchema = convertSchema(propSchema, ctx);
14831
- shape[key] = requiredSet.has(key) ? propZodSchema : propZodSchema.optional();
14832
- }
14833
- if (schema.propertyNames) {
14834
- const keySchema = convertSchema(schema.propertyNames, ctx);
14835
- const valueSchema = schema.additionalProperties && typeof schema.additionalProperties === "object" ? convertSchema(schema.additionalProperties, ctx) : z.any();
14836
- if (Object.keys(shape).length === 0) {
14837
- zodSchema = z.record(keySchema, valueSchema);
14838
- break;
14839
- }
14840
- const objectSchema2 = z.object(shape).passthrough();
14841
- const recordSchema = z.looseRecord(keySchema, valueSchema);
14842
- zodSchema = z.intersection(objectSchema2, recordSchema);
14843
- break;
14844
- }
14845
- if (schema.patternProperties) {
14846
- const patternProps = schema.patternProperties;
14847
- const patternKeys = Object.keys(patternProps);
14848
- const looseRecords = [];
14849
- for (const pattern of patternKeys) {
14850
- const patternValue = convertSchema(patternProps[pattern], ctx);
14851
- const keySchema = z.string().regex(new RegExp(pattern));
14852
- looseRecords.push(z.looseRecord(keySchema, patternValue));
14853
- }
14854
- const schemasToIntersect = [];
14855
- if (Object.keys(shape).length > 0) {
14856
- schemasToIntersect.push(z.object(shape).passthrough());
14857
- }
14858
- schemasToIntersect.push(...looseRecords);
14859
- if (schemasToIntersect.length === 0) {
14860
- zodSchema = z.object({}).passthrough();
14861
- } else if (schemasToIntersect.length === 1) {
14862
- zodSchema = schemasToIntersect[0];
14863
- } else {
14864
- let result = z.intersection(schemasToIntersect[0], schemasToIntersect[1]);
14865
- for (let i = 2; i < schemasToIntersect.length; i++) {
14866
- result = z.intersection(result, schemasToIntersect[i]);
14754
+ if (type === "function")
14755
+ return `[Function: ${value.name || "anonymous"}]`;
14756
+ if (type === "symbol")
14757
+ return `[Symbol: ${value.description ?? ""}]`;
14758
+ if (type === "bigint")
14759
+ return `[BigInt: ${value.toString()}]`;
14760
+ if (typeof value.nodeType === "number" && typeof value.nodeName === "string") {
14761
+ try {
14762
+ const node = value;
14763
+ let classStr = "";
14764
+ if (typeof node.className === "string") {
14765
+ classStr = node.className ? `.${node.className.split(" ")[0] ?? ""}` : "";
14766
+ } else if (node.className !== null && typeof node.className === "object") {
14767
+ const baseVal = node.className.baseVal;
14768
+ if (typeof baseVal === "string") {
14769
+ classStr = baseVal ? `.${baseVal.split(" ")[0] ?? ""}` : "";
14867
14770
  }
14868
- zodSchema = result;
14869
14771
  }
14870
- break;
14871
- }
14872
- const objectSchema = z.object(shape);
14873
- if (schema.additionalProperties === false) {
14874
- zodSchema = objectSchema.strict();
14875
- } else if (typeof schema.additionalProperties === "object") {
14876
- zodSchema = objectSchema.catchall(convertSchema(schema.additionalProperties, ctx));
14877
- } else {
14878
- zodSchema = objectSchema.passthrough();
14772
+ return `[${node.nodeName}${node.id ? `#${node.id}` : ""}${classStr}]`;
14773
+ } catch {
14879
14774
  }
14880
- break;
14881
14775
  }
14882
- case "array": {
14883
- const prefixItems = schema.prefixItems;
14884
- const items = schema.items;
14885
- if (prefixItems && Array.isArray(prefixItems)) {
14886
- const tupleItems = prefixItems.map((item) => convertSchema(item, ctx));
14887
- const rest = items && typeof items === "object" && !Array.isArray(items) ? convertSchema(items, ctx) : void 0;
14888
- if (rest) {
14889
- zodSchema = z.tuple(tupleItems).rest(rest);
14890
- } else {
14891
- zodSchema = z.tuple(tupleItems);
14892
- }
14893
- if (typeof schema.minItems === "number") {
14894
- zodSchema = zodSchema.check(z.minLength(schema.minItems));
14895
- }
14896
- if (typeof schema.maxItems === "number") {
14897
- zodSchema = zodSchema.check(z.maxLength(schema.maxItems));
14898
- }
14899
- } else if (Array.isArray(items)) {
14900
- const tupleItems = items.map((item) => convertSchema(item, ctx));
14901
- const rest = schema.additionalItems && typeof schema.additionalItems === "object" ? convertSchema(schema.additionalItems, ctx) : void 0;
14902
- if (rest) {
14903
- zodSchema = z.tuple(tupleItems).rest(rest);
14904
- } else {
14905
- zodSchema = z.tuple(tupleItems);
14906
- }
14907
- if (typeof schema.minItems === "number") {
14908
- zodSchema = zodSchema.check(z.minLength(schema.minItems));
14909
- }
14910
- if (typeof schema.maxItems === "number") {
14911
- zodSchema = zodSchema.check(z.maxLength(schema.maxItems));
14912
- }
14913
- } else if (items !== void 0) {
14914
- const element = convertSchema(items, ctx);
14915
- let arraySchema = z.array(element);
14916
- if (typeof schema.minItems === "number") {
14917
- arraySchema = arraySchema.min(schema.minItems);
14918
- }
14919
- if (typeof schema.maxItems === "number") {
14920
- arraySchema = arraySchema.max(schema.maxItems);
14776
+ if (value instanceof Error) {
14777
+ return { name: value.name, message: value.message, stack: value.stack };
14778
+ }
14779
+ if (value instanceof WeakRef)
14780
+ return "[WeakRef]";
14781
+ if (value instanceof WeakMap)
14782
+ return "[WeakMap]";
14783
+ if (value instanceof WeakSet)
14784
+ return "[WeakSet]";
14785
+ if (value instanceof ArrayBuffer)
14786
+ return "[ArrayBuffer]";
14787
+ if (typeof SharedArrayBuffer !== "undefined" && value instanceof SharedArrayBuffer)
14788
+ return "[SharedArrayBuffer]";
14789
+ try {
14790
+ const seen = /* @__PURE__ */ new WeakSet();
14791
+ const json2 = JSON.stringify(value, (_key, v) => {
14792
+ if (typeof v === "object" && v !== null) {
14793
+ if (seen.has(v))
14794
+ return "[Circular]";
14795
+ seen.add(v);
14921
14796
  }
14922
- zodSchema = arraySchema;
14923
- } else {
14924
- zodSchema = z.array(z.any());
14797
+ if (typeof v === "function")
14798
+ return `[Function: ${v.name || "anonymous"}]`;
14799
+ if (typeof v === "bigint")
14800
+ return `[BigInt: ${v.toString()}]`;
14801
+ if (typeof v === "symbol")
14802
+ return `[Symbol: ${v.description ?? ""}]`;
14803
+ if (v instanceof WeakRef)
14804
+ return "[WeakRef]";
14805
+ if (v instanceof WeakMap)
14806
+ return "[WeakMap]";
14807
+ if (v instanceof WeakSet)
14808
+ return "[WeakSet]";
14809
+ if (v instanceof ArrayBuffer)
14810
+ return "[ArrayBuffer]";
14811
+ if (typeof SharedArrayBuffer !== "undefined" && v instanceof SharedArrayBuffer)
14812
+ return "[SharedArrayBuffer]";
14813
+ return v;
14814
+ });
14815
+ if (json2.length > MAX_SERIALIZED_SIZE) {
14816
+ return `[Object truncated: ${json2.length} chars]`;
14925
14817
  }
14926
- break;
14818
+ return JSON.parse(json2);
14819
+ } catch {
14820
+ return `[Unserializable: ${typeof value}]`;
14821
+ }
14822
+ } catch {
14823
+ return `[Unserializable: ${typeof value}]`;
14824
+ }
14825
+ };
14826
+ var safeSerialize = (args) => {
14827
+ const capped = args.length > MAX_DATA_LENGTH ? args.slice(0, MAX_DATA_LENGTH) : args;
14828
+ return capped.map(safeSerializeArg);
14829
+ };
14830
+ var CONSOLE_METHODS = {
14831
+ debug: "debug",
14832
+ info: "info",
14833
+ warning: "warn",
14834
+ error: "error"
14835
+ };
14836
+ var defaultTransport = (entry) => {
14837
+ const method = CONSOLE_METHODS[entry.level];
14838
+ console[method](`[sdk.log] ${entry.message}`, ...entry.data);
14839
+ };
14840
+ var activeTransport = defaultTransport;
14841
+ var _setLogTransport = (transport) => {
14842
+ const previous = activeTransport;
14843
+ activeTransport = transport;
14844
+ return () => {
14845
+ if (activeTransport === transport)
14846
+ activeTransport = previous;
14847
+ };
14848
+ };
14849
+ var makeLogMethod = (level) => (message, ...args) => {
14850
+ const entry = {
14851
+ level,
14852
+ message,
14853
+ data: safeSerialize(args),
14854
+ ts: (/* @__PURE__ */ new Date()).toISOString()
14855
+ };
14856
+ activeTransport(entry);
14857
+ };
14858
+ var log = Object.freeze({
14859
+ debug: makeLogMethod("debug"),
14860
+ info: makeLogMethod("info"),
14861
+ warn: makeLogMethod("warning"),
14862
+ error: makeLogMethod("error")
14863
+ });
14864
+ var ot = globalThis.__openTabs ?? {};
14865
+ globalThis.__openTabs = ot;
14866
+ ot._setLogTransport = _setLogTransport;
14867
+ ot.log = log;
14868
+
14869
+ // node_modules/@opentabs-dev/plugin-sdk/dist/storage.js
14870
+ var withIframeFallback = (fn) => {
14871
+ try {
14872
+ const iframe = document.createElement("iframe");
14873
+ iframe.style.display = "none";
14874
+ document.body.appendChild(iframe);
14875
+ try {
14876
+ const iframeStorage = iframe.contentWindow?.localStorage;
14877
+ return iframeStorage ? fn(iframeStorage) : null;
14878
+ } finally {
14879
+ document.body.removeChild(iframe);
14927
14880
  }
14928
- default:
14929
- throw new Error(`Unsupported type: ${type}`);
14930
- }
14931
- return zodSchema;
14932
- }
14933
- function convertSchema(schema, ctx) {
14934
- if (typeof schema === "boolean") {
14935
- return schema ? z.any() : z.never();
14936
- }
14937
- let baseSchema = convertBaseSchema(schema, ctx);
14938
- const hasExplicitType = schema.type || schema.enum !== void 0 || schema.const !== void 0;
14939
- if (schema.anyOf && Array.isArray(schema.anyOf)) {
14940
- const options = schema.anyOf.map((s) => convertSchema(s, ctx));
14941
- const anyOfUnion = z.union(options);
14942
- baseSchema = hasExplicitType ? z.intersection(baseSchema, anyOfUnion) : anyOfUnion;
14943
- }
14944
- if (schema.oneOf && Array.isArray(schema.oneOf)) {
14945
- const options = schema.oneOf.map((s) => convertSchema(s, ctx));
14946
- const oneOfUnion = z.xor(options);
14947
- baseSchema = hasExplicitType ? z.intersection(baseSchema, oneOfUnion) : oneOfUnion;
14881
+ } catch {
14882
+ return null;
14948
14883
  }
14949
- if (schema.allOf && Array.isArray(schema.allOf)) {
14950
- if (schema.allOf.length === 0) {
14951
- baseSchema = hasExplicitType ? baseSchema : z.any();
14952
- } else {
14953
- let result = hasExplicitType ? baseSchema : convertSchema(schema.allOf[0], ctx);
14954
- const startIdx = hasExplicitType ? 0 : 1;
14955
- for (let i = startIdx; i < schema.allOf.length; i++) {
14956
- result = z.intersection(result, convertSchema(schema.allOf[i], ctx));
14884
+ };
14885
+ var getWindowLocalStorage = () => window.localStorage;
14886
+ var findLocalStorageEntry = (predicate) => {
14887
+ const search = (storage2) => {
14888
+ for (let i = 0; i < storage2.length; i++) {
14889
+ const key = storage2.key(i);
14890
+ if (key !== null && predicate(key)) {
14891
+ const value = storage2.getItem(key);
14892
+ if (value !== null)
14893
+ return { key, value };
14957
14894
  }
14958
- baseSchema = result;
14959
14895
  }
14896
+ return null;
14897
+ };
14898
+ let storage;
14899
+ try {
14900
+ storage = getWindowLocalStorage();
14901
+ } catch {
14902
+ return null;
14960
14903
  }
14961
- if (schema.nullable === true && ctx.version === "openapi-3.0") {
14962
- baseSchema = z.nullable(baseSchema);
14963
- }
14964
- if (schema.readOnly === true) {
14965
- baseSchema = z.readonly(baseSchema);
14966
- }
14967
- if (schema.default !== void 0) {
14968
- baseSchema = baseSchema.default(schema.default);
14969
- }
14970
- const extraMeta = {};
14971
- const coreMetadataKeys = ["$id", "id", "$comment", "$anchor", "$vocabulary", "$dynamicRef", "$dynamicAnchor"];
14972
- for (const key of coreMetadataKeys) {
14973
- if (key in schema) {
14974
- extraMeta[key] = schema[key];
14904
+ if (storage) {
14905
+ try {
14906
+ return search(storage);
14907
+ } catch {
14908
+ return null;
14975
14909
  }
14976
14910
  }
14977
- const contentMetadataKeys = ["contentEncoding", "contentMediaType", "contentSchema"];
14978
- for (const key of contentMetadataKeys) {
14979
- if (key in schema) {
14980
- extraMeta[key] = schema[key];
14981
- }
14911
+ return withIframeFallback((s) => search(s));
14912
+ };
14913
+ var getAuthCache = (namespace) => {
14914
+ try {
14915
+ const ns = globalThis.__openTabs;
14916
+ const cache = ns?.tokenCache;
14917
+ return cache?.[namespace] ?? null;
14918
+ } catch {
14919
+ return null;
14982
14920
  }
14983
- for (const key of Object.keys(schema)) {
14984
- if (!RECOGNIZED_KEYS.has(key)) {
14985
- extraMeta[key] = schema[key];
14986
- }
14921
+ };
14922
+ var setAuthCache = (namespace, value) => {
14923
+ try {
14924
+ const g = globalThis;
14925
+ if (!g.__openTabs)
14926
+ g.__openTabs = {};
14927
+ const ns = g.__openTabs;
14928
+ if (!ns.tokenCache)
14929
+ ns.tokenCache = {};
14930
+ ns.tokenCache[namespace] = value;
14931
+ } catch {
14987
14932
  }
14988
- if (Object.keys(extraMeta).length > 0) {
14989
- ctx.registry.add(baseSchema, extraMeta);
14933
+ };
14934
+ var clearAuthCache = (namespace) => {
14935
+ try {
14936
+ const ns = globalThis.__openTabs;
14937
+ const cache = ns?.tokenCache;
14938
+ if (cache)
14939
+ cache[namespace] = void 0;
14940
+ } catch {
14990
14941
  }
14991
- if (schema.description) {
14992
- baseSchema = baseSchema.describe(schema.description);
14942
+ };
14943
+
14944
+ // node_modules/@opentabs-dev/plugin-sdk/dist/page-state.js
14945
+ var getCurrentUrl = () => window.location.href;
14946
+
14947
+ // node_modules/@opentabs-dev/plugin-sdk/dist/index.js
14948
+ var defineTool = (config2) => config2;
14949
+ var OpenTabsPlugin = class {
14950
+ /**
14951
+ * Chrome match patterns for URLs that should NOT match this plugin.
14952
+ * Tabs matching both urlPatterns and excludePatterns are excluded.
14953
+ * Useful when a broad urlPattern overlaps with another plugin's domain.
14954
+ * @see https://developer.chrome.com/docs/extensions/develop/concepts/match-patterns
14955
+ */
14956
+ excludePatterns;
14957
+ /**
14958
+ * URL to open when no matching tab exists and the user triggers an
14959
+ * 'open tab' action from the side panel. Should be a concrete URL
14960
+ * (e.g., 'https://github.com'), not a match pattern.
14961
+ */
14962
+ homepage;
14963
+ /** Typed configuration schema — declares settings that users provide via config.json or the side panel. */
14964
+ configSchema;
14965
+ };
14966
+
14967
+ // src/temporal-api.ts
14968
+ var AUTH0_CLIENT_ID = "nTmmPY5xUpQnSr7gRZh7s33hNamtCeDg";
14969
+ var AUTH0_AUDIENCE = "https://saas-api.tmprl.cloud";
14970
+ var getToken = () => {
14971
+ const entry = findLocalStorageEntry(
14972
+ (key) => key.startsWith(`@@auth0spajs@@::${AUTH0_CLIENT_ID}::`) && key.includes(AUTH0_AUDIENCE)
14973
+ );
14974
+ if (!entry) return null;
14975
+ try {
14976
+ const data = JSON.parse(entry.value);
14977
+ if (!data.body?.access_token) return null;
14978
+ if (data.expiresAt && data.expiresAt < Math.floor(Date.now() / 1e3)) return null;
14979
+ return data.body.access_token;
14980
+ } catch {
14981
+ return null;
14993
14982
  }
14994
- return baseSchema;
14995
- }
14996
- function fromJSONSchema(schema, params) {
14997
- if (typeof schema === "boolean") {
14998
- return schema ? z.any() : z.never();
14983
+ };
14984
+ var getAuth = () => {
14985
+ const freshToken = getToken();
14986
+ if (freshToken) {
14987
+ const cached2 = getAuthCache("temporal-cloud");
14988
+ if (cached2?.token === freshToken) return cached2;
14989
+ const auth = { token: freshToken };
14990
+ setAuthCache("temporal-cloud", auth);
14991
+ return auth;
14999
14992
  }
15000
- let normalized;
14993
+ clearAuthCache("temporal-cloud");
14994
+ return null;
14995
+ };
14996
+ var isAuthenticated = () => getAuth() !== null;
14997
+ var waitForAuth = async () => {
15001
14998
  try {
15002
- normalized = JSON.parse(JSON.stringify(schema));
14999
+ await waitUntil(() => isAuthenticated(), { interval: 500, timeout: 5e3 });
15000
+ return true;
15003
15001
  } catch {
15004
- throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas");
15002
+ return false;
15005
15003
  }
15006
- const version2 = detectVersion(normalized, params?.defaultTarget);
15007
- const defs = normalized.$defs || normalized.definitions || {};
15008
- const ctx = {
15009
- version: version2,
15010
- defs,
15011
- refs: /* @__PURE__ */ new Map(),
15012
- processing: /* @__PURE__ */ new Set(),
15013
- rootSchema: normalized,
15014
- registry: params?.registry ?? globalRegistry
15015
- };
15016
- return convertSchema(normalized, ctx);
15017
- }
15018
-
15019
- // node_modules/zod/v4/classic/coerce.js
15020
- var coerce_exports = {};
15021
- __export(coerce_exports, {
15022
- bigint: () => bigint3,
15023
- boolean: () => boolean3,
15024
- date: () => date4,
15025
- number: () => number3,
15026
- string: () => string3
15027
- });
15028
- function string3(params) {
15029
- return _coercedString(ZodString, params);
15030
- }
15031
- function number3(params) {
15032
- return _coercedNumber(ZodNumber, params);
15033
- }
15034
- function boolean3(params) {
15035
- return _coercedBoolean(ZodBoolean, params);
15036
- }
15037
- function bigint3(params) {
15038
- return _coercedBigint(ZodBigInt, params);
15039
- }
15040
- function date4(params) {
15041
- return _coercedDate(ZodDate, params);
15042
- }
15043
-
15044
- // node_modules/zod/v4/classic/external.js
15045
- config(en_default());
15004
+ };
15005
+ var getDefaultNamespace = () => {
15006
+ const url2 = getCurrentUrl();
15007
+ const match = url2.match(/\/namespaces\/([^/]+)/);
15008
+ if (match?.[1]) return match[1];
15009
+ const hostMatch = url2.match(/^https?:\/\/([^.]+)\.web\.tmprl\.cloud/);
15010
+ return hostMatch?.[1] ?? null;
15011
+ };
15012
+ var resolveNamespace = (namespace) => {
15013
+ const ns = namespace || getDefaultNamespace();
15014
+ if (!ns) {
15015
+ throw ToolError.validation(
15016
+ "No namespace specified and none detected from the current page URL. Pass a namespace parameter explicitly."
15017
+ );
15018
+ }
15019
+ return ns;
15020
+ };
15021
+ var api = async (namespace, path, query) => {
15022
+ const auth = getAuth();
15023
+ if (!auth)
15024
+ throw ToolError.auth(
15025
+ "Not authenticated \u2014 token may have expired. Please refresh the Temporal Cloud page to obtain a new token."
15026
+ );
15027
+ const baseUrl = `https://${namespace}.web.tmprl.cloud/api/v1`;
15028
+ const qs = query ? buildQueryString(query) : "";
15029
+ const url2 = qs ? `${baseUrl}${path}?${qs}` : `${baseUrl}${path}`;
15030
+ try {
15031
+ const result = await fetchJSON(url2, {
15032
+ method: "GET",
15033
+ headers: { Authorization: `Bearer ${auth.token}` }
15034
+ });
15035
+ return result;
15036
+ } catch (err2) {
15037
+ if (err2 instanceof ToolError) {
15038
+ if (err2.category === "auth") {
15039
+ clearAuthCache("temporal-cloud");
15040
+ }
15041
+ throw err2;
15042
+ }
15043
+ throw ToolError.internal(`Temporal API error: ${err2 instanceof Error ? err2.message : String(err2)}`);
15044
+ }
15045
+ };
15046
15046
 
15047
15047
  // src/tools/schemas.ts
15048
15048
  var namespaceParam = external_exports.string().optional().describe(
@@ -15523,7 +15523,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15523
15523
  };
15524
15524
  var src_default = new TemporalCloudPlugin();
15525
15525
 
15526
- // dist/_adapter_entry_4d9f177e-6eb9-458d-8c86-3ac5cf725734.ts
15526
+ // dist/_adapter_entry_32adb9a1-5006-4183-8d4c-c5d223d76143.ts
15527
+ external_exports.config({ jitless: true });
15527
15528
  if (!globalThis.__openTabs) {
15528
15529
  globalThis.__openTabs = {};
15529
15530
  } else {
@@ -15741,5 +15742,5 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15741
15742
  };
15742
15743
  delete src_default.onDeactivate;
15743
15744
  }
15744
- })();(function(){var o=(globalThis).__openTabs;if(o&&o.adapters&&o.adapters["temporal-cloud"]){var a=o.adapters["temporal-cloud"];a.__adapterHash="8414949383c4e85df9b94f1ced0b1c4091e6cdf521b07fd11632291322f03cd4";if(a.tools&&Array.isArray(a.tools)){for(var i=0;i<a.tools.length;i++){Object.freeze(a.tools[i]);}Object.freeze(a.tools);}Object.freeze(a);Object.defineProperty(o.adapters,"temporal-cloud",{value:a,writable:false,configurable:false,enumerable:true});Object.defineProperty(o,"adapters",{value:o.adapters,writable:false,configurable:false});}})();
15745
+ })();(function(){var o=(globalThis).__openTabs;if(o&&o.adapters&&o.adapters["temporal-cloud"]){var a=o.adapters["temporal-cloud"];a.__adapterHash="8c13241fd3cd70708a32a3848482c7d459ef16b7b73c59897b3c24275286b4c0";if(a.tools&&Array.isArray(a.tools)){for(var i=0;i<a.tools.length;i++){Object.freeze(a.tools[i]);}Object.freeze(a.tools);}Object.freeze(a);Object.defineProperty(o.adapters,"temporal-cloud",{value:a,writable:false,configurable:false,enumerable:true});Object.defineProperty(o,"adapters",{value:o.adapters,writable:false,configurable:false});}})();
15745
15746
  //# sourceMappingURL=adapter.iife.js.map