@opentabs-dev/opentabs-plugin-hack2hire 0.0.109 → 0.0.111

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,465 +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
-
147
- // node_modules/@opentabs-dev/plugin-sdk/dist/timing.js
148
- var waitUntil = (predicate, opts) => {
149
- const interval = opts?.interval ?? 200;
150
- const timeout = opts?.timeout ?? 1e4;
151
- const signal = opts?.signal;
152
- const abortReason = () => signal?.reason instanceof Error ? signal.reason : new Error("waitUntil: aborted");
153
- if (signal?.aborted)
154
- return Promise.reject(abortReason());
155
- return new Promise((resolve, reject) => {
156
- let settled = false;
157
- let poller;
158
- let lastPredicateError;
159
- const isSettled = () => settled;
160
- const cleanup = () => {
161
- settled = true;
162
- clearTimeout(timer);
163
- clearTimeout(poller);
164
- signal?.removeEventListener("abort", onAbort);
165
- };
166
- const onAbort = () => {
167
- if (isSettled())
168
- return;
169
- cleanup();
170
- reject(abortReason());
171
- };
172
- signal?.addEventListener("abort", onAbort, { once: true });
173
- const timer = setTimeout(() => {
174
- if (isSettled())
175
- return;
176
- cleanup();
177
- const errorContext = lastPredicateError instanceof Error ? `: predicate last threw \u2014 ${lastPredicateError.message}` : "";
178
- reject(new Error(`waitUntil: timed out after ${timeout}ms waiting for predicate to return true${errorContext}`));
179
- }, timeout);
180
- const check2 = async () => {
181
- if (isSettled())
182
- return;
183
- try {
184
- const result = await predicate();
185
- if (result) {
186
- cleanup();
187
- resolve();
188
- return;
189
- }
190
- } catch (err2) {
191
- lastPredicateError = err2;
192
- }
193
- if (!isSettled()) {
194
- poller = setTimeout(() => void check2(), interval);
195
- }
196
- };
197
- void check2();
198
- });
199
- };
200
-
201
- // node_modules/@opentabs-dev/plugin-sdk/dist/log.js
202
- var MAX_DATA_LENGTH = 10;
203
- var MAX_STRING_LENGTH = 4096;
204
- var MAX_SERIALIZED_SIZE = 64 * 1024;
205
- var safeSerializeArg = (value) => {
206
- try {
207
- if (value === null || value === void 0)
208
- return value;
209
- const type = typeof value;
210
- if (type === "boolean" || type === "number")
211
- return value;
212
- if (type === "string") {
213
- return value.length > MAX_STRING_LENGTH ? `${value.slice(0, MAX_STRING_LENGTH)}\u2026` : value;
214
- }
215
- if (type === "function")
216
- return `[Function: ${value.name || "anonymous"}]`;
217
- if (type === "symbol")
218
- return `[Symbol: ${value.description ?? ""}]`;
219
- if (type === "bigint")
220
- return `[BigInt: ${value.toString()}]`;
221
- if (typeof value.nodeType === "number" && typeof value.nodeName === "string") {
222
- try {
223
- const node = value;
224
- let classStr = "";
225
- if (typeof node.className === "string") {
226
- classStr = node.className ? `.${node.className.split(" ")[0] ?? ""}` : "";
227
- } else if (node.className !== null && typeof node.className === "object") {
228
- const baseVal = node.className.baseVal;
229
- if (typeof baseVal === "string") {
230
- classStr = baseVal ? `.${baseVal.split(" ")[0] ?? ""}` : "";
231
- }
232
- }
233
- return `[${node.nodeName}${node.id ? `#${node.id}` : ""}${classStr}]`;
234
- } catch {
235
- }
236
- }
237
- if (value instanceof Error) {
238
- return { name: value.name, message: value.message, stack: value.stack };
239
- }
240
- if (value instanceof WeakRef)
241
- return "[WeakRef]";
242
- if (value instanceof WeakMap)
243
- return "[WeakMap]";
244
- if (value instanceof WeakSet)
245
- return "[WeakSet]";
246
- if (value instanceof ArrayBuffer)
247
- return "[ArrayBuffer]";
248
- if (typeof SharedArrayBuffer !== "undefined" && value instanceof SharedArrayBuffer)
249
- return "[SharedArrayBuffer]";
250
- try {
251
- const seen = /* @__PURE__ */ new WeakSet();
252
- const json2 = JSON.stringify(value, (_key, v) => {
253
- if (typeof v === "object" && v !== null) {
254
- if (seen.has(v))
255
- return "[Circular]";
256
- seen.add(v);
257
- }
258
- if (typeof v === "function")
259
- return `[Function: ${v.name || "anonymous"}]`;
260
- if (typeof v === "bigint")
261
- return `[BigInt: ${v.toString()}]`;
262
- if (typeof v === "symbol")
263
- return `[Symbol: ${v.description ?? ""}]`;
264
- if (v instanceof WeakRef)
265
- return "[WeakRef]";
266
- if (v instanceof WeakMap)
267
- return "[WeakMap]";
268
- if (v instanceof WeakSet)
269
- return "[WeakSet]";
270
- if (v instanceof ArrayBuffer)
271
- return "[ArrayBuffer]";
272
- if (typeof SharedArrayBuffer !== "undefined" && v instanceof SharedArrayBuffer)
273
- return "[SharedArrayBuffer]";
274
- return v;
275
- });
276
- if (json2.length > MAX_SERIALIZED_SIZE) {
277
- return `[Object truncated: ${json2.length} chars]`;
278
- }
279
- return JSON.parse(json2);
280
- } catch {
281
- return `[Unserializable: ${typeof value}]`;
282
- }
283
- } catch {
284
- return `[Unserializable: ${typeof value}]`;
285
- }
286
- };
287
- var safeSerialize = (args) => {
288
- const capped = args.length > MAX_DATA_LENGTH ? args.slice(0, MAX_DATA_LENGTH) : args;
289
- return capped.map(safeSerializeArg);
290
- };
291
- var CONSOLE_METHODS = {
292
- debug: "debug",
293
- info: "info",
294
- warning: "warn",
295
- error: "error"
296
- };
297
- var defaultTransport = (entry) => {
298
- const method = CONSOLE_METHODS[entry.level];
299
- console[method](`[sdk.log] ${entry.message}`, ...entry.data);
300
- };
301
- var activeTransport = defaultTransport;
302
- var _setLogTransport = (transport) => {
303
- const previous = activeTransport;
304
- activeTransport = transport;
305
- return () => {
306
- if (activeTransport === transport)
307
- activeTransport = previous;
308
- };
309
- };
310
- var makeLogMethod = (level) => (message, ...args) => {
311
- const entry = {
312
- level,
313
- message,
314
- data: safeSerialize(args),
315
- ts: (/* @__PURE__ */ new Date()).toISOString()
316
- };
317
- activeTransport(entry);
318
- };
319
- var log = Object.freeze({
320
- debug: makeLogMethod("debug"),
321
- info: makeLogMethod("info"),
322
- warn: makeLogMethod("warning"),
323
- error: makeLogMethod("error")
324
- });
325
- var ot = globalThis.__openTabs ?? {};
326
- globalThis.__openTabs = ot;
327
- ot._setLogTransport = _setLogTransport;
328
- ot.log = log;
329
-
330
- // node_modules/@opentabs-dev/plugin-sdk/dist/storage.js
331
- var withIframeFallback = (fn) => {
332
- try {
333
- const iframe = document.createElement("iframe");
334
- iframe.style.display = "none";
335
- document.body.appendChild(iframe);
336
- try {
337
- const iframeStorage = iframe.contentWindow?.localStorage;
338
- return iframeStorage ? fn(iframeStorage) : null;
339
- } finally {
340
- document.body.removeChild(iframe);
341
- }
342
- } catch {
343
- return null;
344
- }
345
- };
346
- var getWindowLocalStorage = () => window.localStorage;
347
- var getLocalStorage = (key) => {
348
- let storage;
349
- try {
350
- storage = getWindowLocalStorage();
351
- } catch {
352
- return null;
353
- }
354
- if (storage) {
355
- try {
356
- return storage.getItem(key);
357
- } catch {
358
- return null;
359
- }
360
- }
361
- return withIframeFallback((s) => s.getItem(key));
362
- };
363
- var getAuthCache = (namespace) => {
364
- try {
365
- const ns = globalThis.__openTabs;
366
- const cache = ns?.tokenCache;
367
- return cache?.[namespace] ?? null;
368
- } catch {
369
- return null;
370
- }
371
- };
372
- var setAuthCache = (namespace, value) => {
373
- try {
374
- const g = globalThis;
375
- if (!g.__openTabs)
376
- g.__openTabs = {};
377
- const ns = g.__openTabs;
378
- if (!ns.tokenCache)
379
- ns.tokenCache = {};
380
- ns.tokenCache[namespace] = value;
381
- } catch {
382
- }
383
- };
384
- var clearAuthCache = (namespace) => {
385
- try {
386
- const ns = globalThis.__openTabs;
387
- const cache = ns?.tokenCache;
388
- if (cache)
389
- cache[namespace] = void 0;
390
- } catch {
391
- }
392
- };
393
-
394
- // node_modules/@opentabs-dev/plugin-sdk/dist/index.js
395
- var defineTool = (config2) => config2;
396
- var OpenTabsPlugin = class {
397
- /**
398
- * Chrome match patterns for URLs that should NOT match this plugin.
399
- * Tabs matching both urlPatterns and excludePatterns are excluded.
400
- * Useful when a broad urlPattern overlaps with another plugin's domain.
401
- * @see https://developer.chrome.com/docs/extensions/develop/concepts/match-patterns
402
- */
403
- excludePatterns;
404
- /**
405
- * URL to open when no matching tab exists and the user triggers an
406
- * 'open tab' action from the side panel. Should be a concrete URL
407
- * (e.g., 'https://github.com'), not a match pattern.
408
- */
409
- homepage;
410
- /** Typed configuration schema — declares settings that users provide via config.json or the side panel. */
411
- configSchema;
412
- };
413
-
414
- // src/hack2hire-api.ts
415
- var API_BASE = "https://api.hack2hire.com/algro/v1";
416
- var readJsonString = (key) => {
417
- const raw = getLocalStorage(key);
418
- if (!raw) return null;
419
- try {
420
- const parsed = JSON.parse(raw);
421
- return typeof parsed === "string" && parsed.length > 0 ? parsed : null;
422
- } catch {
423
- return null;
424
- }
425
- };
426
- var getAuth = () => {
427
- const cached2 = getAuthCache("hack2hire");
428
- if (cached2?.token && cached2?.userId) return cached2;
429
- const token = readJsonString("ALGRO_TOKEN");
430
- const userId = readJsonString("USER_ID");
431
- if (!token || !userId) return null;
432
- const auth = { token, userId };
433
- setAuthCache("hack2hire", auth);
434
- return auth;
435
- };
436
- var isAuthenticated = () => getAuth() !== null;
437
- var waitForAuth = () => waitUntil(() => isAuthenticated(), { interval: 500, timeout: 5e3 }).then(
438
- () => true,
439
- () => false
440
- );
441
- var api = async (endpoint, query) => {
442
- const auth = getAuth();
443
- if (!auth) throw ToolError.auth("Not authenticated \u2014 please log in to Hack2Hire.");
444
- const qs = query ? buildQueryString(query) : "";
445
- const url2 = qs ? `${API_BASE}${endpoint}?${qs}` : `${API_BASE}${endpoint}`;
446
- let response;
447
- try {
448
- response = await fetchFromPage(url2, {
449
- method: "GET",
450
- headers: {
451
- Authorization: `Bearer ${auth.token}`,
452
- "x-user-id": auth.userId,
453
- Accept: "application/json"
454
- },
455
- credentials: "omit"
456
- });
457
- } catch (err2) {
458
- if (err2 instanceof ToolError) {
459
- if (err2.category === "auth") clearAuthCache("hack2hire");
460
- throw err2;
461
- }
462
- throw ToolError.internal(`Network error: ${err2 instanceof Error ? err2.message : String(err2)}`);
463
- }
464
- const envelope = await response.json();
465
- return envelope.data;
466
- };
467
-
468
9
  // node_modules/zod/v4/classic/external.js
469
10
  var external_exports = {};
470
11
  __export(external_exports, {
@@ -13534,1450 +13075,1909 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
13534
13075
  $ZodCIDRv4.init(inst, def);
13535
13076
  ZodStringFormat.init(inst, def);
13536
13077
  });
13537
- function cidrv42(params) {
13538
- return _cidrv4(ZodCIDRv4, params);
13078
+ function cidrv42(params) {
13079
+ return _cidrv4(ZodCIDRv4, params);
13080
+ }
13081
+ var ZodCIDRv6 = /* @__PURE__ */ $constructor("ZodCIDRv6", (inst, def) => {
13082
+ $ZodCIDRv6.init(inst, def);
13083
+ ZodStringFormat.init(inst, def);
13084
+ });
13085
+ function cidrv62(params) {
13086
+ return _cidrv6(ZodCIDRv6, params);
13087
+ }
13088
+ var ZodBase64 = /* @__PURE__ */ $constructor("ZodBase64", (inst, def) => {
13089
+ $ZodBase64.init(inst, def);
13090
+ ZodStringFormat.init(inst, def);
13091
+ });
13092
+ function base642(params) {
13093
+ return _base64(ZodBase64, params);
13094
+ }
13095
+ var ZodBase64URL = /* @__PURE__ */ $constructor("ZodBase64URL", (inst, def) => {
13096
+ $ZodBase64URL.init(inst, def);
13097
+ ZodStringFormat.init(inst, def);
13098
+ });
13099
+ function base64url2(params) {
13100
+ return _base64url(ZodBase64URL, params);
13101
+ }
13102
+ var ZodE164 = /* @__PURE__ */ $constructor("ZodE164", (inst, def) => {
13103
+ $ZodE164.init(inst, def);
13104
+ ZodStringFormat.init(inst, def);
13105
+ });
13106
+ function e1642(params) {
13107
+ return _e164(ZodE164, params);
13108
+ }
13109
+ var ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
13110
+ $ZodJWT.init(inst, def);
13111
+ ZodStringFormat.init(inst, def);
13112
+ });
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);
13539
13275
  }
13540
- var ZodCIDRv6 = /* @__PURE__ */ $constructor("ZodCIDRv6", (inst, def) => {
13541
- $ZodCIDRv6.init(inst, def);
13542
- ZodStringFormat.init(inst, def);
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);
13543
13280
  });
13544
- function cidrv62(params) {
13545
- return _cidrv6(ZodCIDRv6, params);
13281
+ function _null3(params) {
13282
+ return _null2(ZodNull, params);
13546
13283
  }
13547
- var ZodBase64 = /* @__PURE__ */ $constructor("ZodBase64", (inst, def) => {
13548
- $ZodBase64.init(inst, def);
13549
- ZodStringFormat.init(inst, def);
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);
13550
13288
  });
13551
- function base642(params) {
13552
- return _base64(ZodBase64, params);
13289
+ function any() {
13290
+ return _any(ZodAny);
13553
13291
  }
13554
- var ZodBase64URL = /* @__PURE__ */ $constructor("ZodBase64URL", (inst, def) => {
13555
- $ZodBase64URL.init(inst, def);
13556
- ZodStringFormat.init(inst, def);
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);
13557
13296
  });
13558
- function base64url2(params) {
13559
- return _base64url(ZodBase64URL, params);
13297
+ function unknown() {
13298
+ return _unknown(ZodUnknown);
13560
13299
  }
13561
- var ZodE164 = /* @__PURE__ */ $constructor("ZodE164", (inst, def) => {
13562
- $ZodE164.init(inst, def);
13563
- ZodStringFormat.init(inst, def);
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);
13564
13304
  });
13565
- function e1642(params) {
13566
- return _e164(ZodE164, params);
13305
+ function never(params) {
13306
+ return _never(ZodNever, params);
13567
13307
  }
13568
- var ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
13569
- $ZodJWT.init(inst, def);
13570
- ZodStringFormat.init(inst, def);
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);
13571
13312
  });
13572
- function jwt(params) {
13573
- return _jwt(ZodJWT, params);
13313
+ function _void2(params) {
13314
+ return _void(ZodVoid, params);
13574
13315
  }
13575
- var ZodCustomStringFormat = /* @__PURE__ */ $constructor("ZodCustomStringFormat", (inst, def) => {
13576
- $ZodCustomStringFormat.init(inst, def);
13577
- 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;
13578
13325
  });
13579
- function stringFormat(format, fnOrRegex, _params = {}) {
13580
- return _stringFormat(ZodCustomStringFormat, format, fnOrRegex, _params);
13581
- }
13582
- function hostname2(_params) {
13583
- return _stringFormat(ZodCustomStringFormat, "hostname", regexes_exports.hostname, _params);
13584
- }
13585
- function hex2(_params) {
13586
- return _stringFormat(ZodCustomStringFormat, "hex", regexes_exports.hex, _params);
13587
- }
13588
- function hash(alg, params) {
13589
- const enc = params?.enc ?? "hex";
13590
- const format = `${alg}_${enc}`;
13591
- const regex = regexes_exports[format];
13592
- if (!regex)
13593
- throw new Error(`Unrecognized hash format: ${format}`);
13594
- return _stringFormat(ZodCustomStringFormat, format, regex, params);
13326
+ function date3(params) {
13327
+ return _date(ZodDate, params);
13595
13328
  }
13596
- var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
13597
- $ZodNumber.init(inst, def);
13329
+ var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
13330
+ $ZodArray.init(inst, def);
13598
13331
  ZodType.init(inst, def);
13599
- inst._zod.processJSONSchema = (ctx, json2, params) => numberProcessor(inst, ctx, json2, params);
13600
- _installLazyMethods(inst, "ZodNumber", {
13601
- gt(value, params) {
13602
- 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));
13603
13337
  },
13604
- gte(value, params) {
13605
- return this.check(_gte(value, params));
13338
+ nonempty(params) {
13339
+ return this.check(_minLength(1, params));
13606
13340
  },
13607
- min(value, params) {
13608
- return this.check(_gte(value, params));
13341
+ max(n, params) {
13342
+ return this.check(_maxLength(n, params));
13609
13343
  },
13610
- lt(value, params) {
13611
- return this.check(_lt(value, params));
13344
+ length(n, params) {
13345
+ return this.check(_length(n, params));
13612
13346
  },
13613
- lte(value, params) {
13614
- 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));
13615
13369
  },
13616
- max(value, params) {
13617
- return this.check(_lte(value, params));
13370
+ catchall(catchall) {
13371
+ return this.clone({ ...this._zod.def, catchall });
13618
13372
  },
13619
- int(params) {
13620
- return this.check(int(params));
13373
+ passthrough() {
13374
+ return this.clone({ ...this._zod.def, catchall: unknown() });
13621
13375
  },
13622
- safe(params) {
13623
- return this.check(int(params));
13376
+ loose() {
13377
+ return this.clone({ ...this._zod.def, catchall: unknown() });
13624
13378
  },
13625
- positive(params) {
13626
- return this.check(_gt(0, params));
13379
+ strict() {
13380
+ return this.clone({ ...this._zod.def, catchall: never() });
13627
13381
  },
13628
- nonnegative(params) {
13629
- return this.check(_gte(0, params));
13382
+ strip() {
13383
+ return this.clone({ ...this._zod.def, catchall: void 0 });
13630
13384
  },
13631
- negative(params) {
13632
- return this.check(_lt(0, params));
13385
+ extend(incoming) {
13386
+ return util_exports.extend(this, incoming);
13633
13387
  },
13634
- nonpositive(params) {
13635
- return this.check(_lte(0, params));
13388
+ safeExtend(incoming) {
13389
+ return util_exports.safeExtend(this, incoming);
13636
13390
  },
13637
- multipleOf(value, params) {
13638
- return this.check(_multipleOf(value, params));
13391
+ merge(other) {
13392
+ return util_exports.merge(this, other);
13639
13393
  },
13640
- step(value, params) {
13641
- return this.check(_multipleOf(value, params));
13394
+ pick(mask) {
13395
+ return util_exports.pick(this, mask);
13642
13396
  },
13643
- finite() {
13644
- 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]);
13645
13405
  }
13646
13406
  });
13647
- const bag = inst._zod.bag;
13648
- inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
13649
- inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
13650
- inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
13651
- inst.isFinite = true;
13652
- inst.format = bag.format ?? null;
13653
13407
  });
13654
- function number2(params) {
13655
- return _number(ZodNumber, params);
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
+ });
13656
13502
  }
13657
- var ZodNumberFormat = /* @__PURE__ */ $constructor("ZodNumberFormat", (inst, def) => {
13658
- $ZodNumberFormat.init(inst, def);
13659
- ZodNumber.init(inst, def);
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;
13660
13509
  });
13661
- function int(params) {
13662
- return _int(ZodNumberFormat, params);
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
+ });
13663
13525
  }
13664
- function float32(params) {
13665
- return _float32(ZodNumberFormat, params);
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
+ });
13666
13535
  }
13667
- function float64(params) {
13668
- return _float64(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
+ });
13669
13544
  }
13670
- function int32(params) {
13671
- return _int32(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
+ });
13672
13563
  }
13673
- function uint32(params) {
13674
- return _uint32(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
+ });
13675
13579
  }
13676
- var ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
13677
- $ZodBoolean.init(inst, def);
13580
+ var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
13581
+ $ZodEnum.init(inst, def);
13678
13582
  ZodType.init(inst, def);
13679
- inst._zod.processJSONSchema = (ctx, json2, params) => booleanProcessor(inst, ctx, json2, params);
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
+ };
13680
13617
  });
13681
- function boolean2(params) {
13682
- return _boolean(ZodBoolean, params);
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
+ });
13683
13625
  }
13684
- var ZodBigInt = /* @__PURE__ */ $constructor("ZodBigInt", (inst, def) => {
13685
- $ZodBigInt.init(inst, def);
13626
+ function nativeEnum(entries, params) {
13627
+ return new ZodEnum({
13628
+ type: "enum",
13629
+ entries,
13630
+ ...util_exports.normalizeParams(params)
13631
+ });
13632
+ }
13633
+ var ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
13634
+ $ZodLiteral.init(inst, def);
13686
13635
  ZodType.init(inst, def);
13687
- inst._zod.processJSONSchema = (ctx, json2, params) => bigintProcessor(inst, ctx, json2, params);
13688
- inst.gte = (value, params) => inst.check(_gte(value, params));
13689
- inst.min = (value, params) => inst.check(_gte(value, params));
13690
- inst.gt = (value, params) => inst.check(_gt(value, params));
13691
- inst.gte = (value, params) => inst.check(_gte(value, params));
13692
- inst.min = (value, params) => inst.check(_gte(value, params));
13693
- inst.lt = (value, params) => inst.check(_lt(value, params));
13694
- inst.lte = (value, params) => inst.check(_lte(value, params));
13695
- inst.max = (value, params) => inst.check(_lte(value, params));
13696
- inst.positive = (params) => inst.check(_gt(BigInt(0), params));
13697
- inst.negative = (params) => inst.check(_lt(BigInt(0), params));
13698
- inst.nonpositive = (params) => inst.check(_lte(BigInt(0), params));
13699
- inst.nonnegative = (params) => inst.check(_gte(BigInt(0), params));
13700
- inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
13701
- const bag = inst._zod.bag;
13702
- inst.minValue = bag.minimum ?? null;
13703
- inst.maxValue = bag.maximum ?? null;
13704
- inst.format = bag.format ?? null;
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
+ });
13705
13646
  });
13706
- function bigint2(params) {
13707
- return _bigint(ZodBigInt, 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
+ });
13708
13653
  }
13709
- var ZodBigIntFormat = /* @__PURE__ */ $constructor("ZodBigIntFormat", (inst, def) => {
13710
- $ZodBigIntFormat.init(inst, def);
13711
- ZodBigInt.init(inst, def);
13654
+ var ZodFile = /* @__PURE__ */ $constructor("ZodFile", (inst, def) => {
13655
+ $ZodFile.init(inst, def);
13656
+ ZodType.init(inst, def);
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));
13661
+ });
13662
+ function file(params) {
13663
+ return _file(ZodFile, params);
13664
+ }
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
+ };
13712
13698
  });
13713
- function int64(params) {
13714
- return _int64(ZodBigIntFormat, params);
13715
- }
13716
- function uint64(params) {
13717
- return _uint64(ZodBigIntFormat, params);
13699
+ function transform(fn) {
13700
+ return new ZodTransform({
13701
+ type: "transform",
13702
+ transform: fn
13703
+ });
13718
13704
  }
13719
- var ZodSymbol = /* @__PURE__ */ $constructor("ZodSymbol", (inst, def) => {
13720
- $ZodSymbol.init(inst, def);
13705
+ var ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
13706
+ $ZodOptional.init(inst, def);
13721
13707
  ZodType.init(inst, def);
13722
- inst._zod.processJSONSchema = (ctx, json2, params) => symbolProcessor(inst, ctx, json2, params);
13708
+ inst._zod.processJSONSchema = (ctx, json2, params) => optionalProcessor(inst, ctx, json2, params);
13709
+ inst.unwrap = () => inst._zod.def.innerType;
13723
13710
  });
13724
- function symbol(params) {
13725
- return _symbol(ZodSymbol, params);
13711
+ function optional(innerType) {
13712
+ return new ZodOptional({
13713
+ type: "optional",
13714
+ innerType
13715
+ });
13726
13716
  }
13727
- var ZodUndefined = /* @__PURE__ */ $constructor("ZodUndefined", (inst, def) => {
13728
- $ZodUndefined.init(inst, def);
13717
+ var ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
13718
+ $ZodExactOptional.init(inst, def);
13729
13719
  ZodType.init(inst, def);
13730
- inst._zod.processJSONSchema = (ctx, json2, params) => undefinedProcessor(inst, ctx, json2, params);
13720
+ inst._zod.processJSONSchema = (ctx, json2, params) => optionalProcessor(inst, ctx, json2, params);
13721
+ inst.unwrap = () => inst._zod.def.innerType;
13731
13722
  });
13732
- function _undefined3(params) {
13733
- return _undefined2(ZodUndefined, params);
13723
+ function exactOptional(innerType) {
13724
+ return new ZodExactOptional({
13725
+ type: "optional",
13726
+ innerType
13727
+ });
13734
13728
  }
13735
- var ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
13736
- $ZodNull.init(inst, def);
13729
+ var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
13730
+ $ZodNullable.init(inst, def);
13737
13731
  ZodType.init(inst, def);
13738
- inst._zod.processJSONSchema = (ctx, json2, params) => nullProcessor(inst, ctx, json2, params);
13732
+ inst._zod.processJSONSchema = (ctx, json2, params) => nullableProcessor(inst, ctx, json2, params);
13733
+ inst.unwrap = () => inst._zod.def.innerType;
13739
13734
  });
13740
- function _null3(params) {
13741
- return _null2(ZodNull, params);
13735
+ function nullable(innerType) {
13736
+ return new ZodNullable({
13737
+ type: "nullable",
13738
+ innerType
13739
+ });
13742
13740
  }
13743
- var ZodAny = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
13744
- $ZodAny.init(inst, def);
13741
+ function nullish2(innerType) {
13742
+ return optional(nullable(innerType));
13743
+ }
13744
+ var ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
13745
+ $ZodDefault.init(inst, def);
13745
13746
  ZodType.init(inst, def);
13746
- inst._zod.processJSONSchema = (ctx, json2, params) => anyProcessor(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;
13747
13750
  });
13748
- function any() {
13749
- return _any(ZodAny);
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
+ });
13750
13759
  }
13751
- var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
13752
- $ZodUnknown.init(inst, def);
13760
+ var ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
13761
+ $ZodPrefault.init(inst, def);
13753
13762
  ZodType.init(inst, def);
13754
- inst._zod.processJSONSchema = (ctx, json2, params) => unknownProcessor(inst, ctx, json2, params);
13763
+ inst._zod.processJSONSchema = (ctx, json2, params) => prefaultProcessor(inst, ctx, json2, params);
13764
+ inst.unwrap = () => inst._zod.def.innerType;
13755
13765
  });
13756
- function unknown() {
13757
- return _unknown(ZodUnknown);
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
+ });
13758
13774
  }
13759
- var ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
13760
- $ZodNever.init(inst, def);
13775
+ var ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
13776
+ $ZodNonOptional.init(inst, def);
13761
13777
  ZodType.init(inst, def);
13762
- inst._zod.processJSONSchema = (ctx, json2, params) => neverProcessor(inst, ctx, json2, params);
13778
+ inst._zod.processJSONSchema = (ctx, json2, params) => nonoptionalProcessor(inst, ctx, json2, params);
13779
+ inst.unwrap = () => inst._zod.def.innerType;
13763
13780
  });
13764
- function never(params) {
13765
- return _never(ZodNever, params);
13781
+ function nonoptional(innerType, params) {
13782
+ return new ZodNonOptional({
13783
+ type: "nonoptional",
13784
+ innerType,
13785
+ ...util_exports.normalizeParams(params)
13786
+ });
13766
13787
  }
13767
- var ZodVoid = /* @__PURE__ */ $constructor("ZodVoid", (inst, def) => {
13768
- $ZodVoid.init(inst, def);
13788
+ var ZodSuccess = /* @__PURE__ */ $constructor("ZodSuccess", (inst, def) => {
13789
+ $ZodSuccess.init(inst, def);
13769
13790
  ZodType.init(inst, def);
13770
- inst._zod.processJSONSchema = (ctx, json2, params) => voidProcessor(inst, ctx, json2, params);
13791
+ inst._zod.processJSONSchema = (ctx, json2, params) => successProcessor(inst, ctx, json2, params);
13792
+ inst.unwrap = () => inst._zod.def.innerType;
13771
13793
  });
13772
- function _void2(params) {
13773
- return _void(ZodVoid, params);
13794
+ function success(innerType) {
13795
+ return new ZodSuccess({
13796
+ type: "success",
13797
+ innerType
13798
+ });
13774
13799
  }
13775
- var ZodDate = /* @__PURE__ */ $constructor("ZodDate", (inst, def) => {
13776
- $ZodDate.init(inst, def);
13800
+ var ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
13801
+ $ZodCatch.init(inst, def);
13777
13802
  ZodType.init(inst, def);
13778
- inst._zod.processJSONSchema = (ctx, json2, params) => dateProcessor(inst, ctx, json2, params);
13779
- inst.min = (value, params) => inst.check(_gte(value, params));
13780
- inst.max = (value, params) => inst.check(_lte(value, params));
13781
- const c = inst._zod.bag;
13782
- inst.minDate = c.minimum ? new Date(c.minimum) : null;
13783
- inst.maxDate = c.maximum ? new Date(c.maximum) : null;
13803
+ inst._zod.processJSONSchema = (ctx, json2, params) => catchProcessor(inst, ctx, json2, params);
13804
+ inst.unwrap = () => inst._zod.def.innerType;
13805
+ inst.removeCatch = inst.unwrap;
13784
13806
  });
13785
- function date3(params) {
13786
- return _date(ZodDate, params);
13807
+ function _catch2(innerType, catchValue) {
13808
+ return new ZodCatch({
13809
+ type: "catch",
13810
+ innerType,
13811
+ catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
13812
+ });
13787
13813
  }
13788
- var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
13789
- $ZodArray.init(inst, def);
13814
+ var ZodNaN = /* @__PURE__ */ $constructor("ZodNaN", (inst, def) => {
13815
+ $ZodNaN.init(inst, def);
13790
13816
  ZodType.init(inst, def);
13791
- inst._zod.processJSONSchema = (ctx, json2, params) => arrayProcessor(inst, ctx, json2, params);
13792
- inst.element = def.element;
13793
- _installLazyMethods(inst, "ZodArray", {
13794
- min(n, params) {
13795
- return this.check(_minLength(n, params));
13796
- },
13797
- nonempty(params) {
13798
- return this.check(_minLength(1, params));
13799
- },
13800
- max(n, params) {
13801
- return this.check(_maxLength(n, params));
13802
- },
13803
- length(n, params) {
13804
- return this.check(_length(n, params));
13805
- },
13806
- unwrap() {
13807
- return this.element;
13808
- }
13809
- });
13817
+ inst._zod.processJSONSchema = (ctx, json2, params) => nanProcessor(inst, ctx, json2, params);
13810
13818
  });
13811
- function array(element, params) {
13812
- return _array(ZodArray, element, params);
13813
- }
13814
- function keyof(schema) {
13815
- const shape = schema._zod.def.shape;
13816
- return _enum2(Object.keys(shape));
13819
+ function nan(params) {
13820
+ return _nan(ZodNaN, params);
13817
13821
  }
13818
- var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
13819
- $ZodObjectJIT.init(inst, def);
13822
+ var ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
13823
+ $ZodPipe.init(inst, def);
13820
13824
  ZodType.init(inst, def);
13821
- inst._zod.processJSONSchema = (ctx, json2, params) => objectProcessor(inst, ctx, json2, params);
13822
- util_exports.defineLazy(inst, "shape", () => {
13823
- return def.shape;
13824
- });
13825
- _installLazyMethods(inst, "ZodObject", {
13826
- keyof() {
13827
- return _enum2(Object.keys(this._zod.def.shape));
13828
- },
13829
- catchall(catchall) {
13830
- return this.clone({ ...this._zod.def, catchall });
13831
- },
13832
- passthrough() {
13833
- return this.clone({ ...this._zod.def, catchall: unknown() });
13834
- },
13835
- loose() {
13836
- return this.clone({ ...this._zod.def, catchall: unknown() });
13837
- },
13838
- strict() {
13839
- return this.clone({ ...this._zod.def, catchall: never() });
13840
- },
13841
- strip() {
13842
- return this.clone({ ...this._zod.def, catchall: void 0 });
13843
- },
13844
- extend(incoming) {
13845
- return util_exports.extend(this, incoming);
13846
- },
13847
- safeExtend(incoming) {
13848
- return util_exports.safeExtend(this, incoming);
13849
- },
13850
- merge(other) {
13851
- return util_exports.merge(this, other);
13852
- },
13853
- pick(mask) {
13854
- return util_exports.pick(this, mask);
13855
- },
13856
- omit(mask) {
13857
- return util_exports.omit(this, mask);
13858
- },
13859
- partial(...args) {
13860
- return util_exports.partial(ZodOptional, this, args[0]);
13861
- },
13862
- required(...args) {
13863
- return util_exports.required(ZodNonOptional, this, args[0]);
13864
- }
13825
+ inst._zod.processJSONSchema = (ctx, json2, params) => pipeProcessor(inst, ctx, json2, params);
13826
+ inst.in = def.in;
13827
+ inst.out = def.out;
13828
+ });
13829
+ function pipe(in_, out) {
13830
+ return new ZodPipe({
13831
+ type: "pipe",
13832
+ in: in_,
13833
+ out
13834
+ // ...util.normalizeParams(params),
13865
13835
  });
13836
+ }
13837
+ var ZodCodec = /* @__PURE__ */ $constructor("ZodCodec", (inst, def) => {
13838
+ ZodPipe.init(inst, def);
13839
+ $ZodCodec.init(inst, def);
13866
13840
  });
13867
- function object(shape, params) {
13868
- const def = {
13869
- type: "object",
13870
- shape: shape ?? {},
13871
- ...util_exports.normalizeParams(params)
13872
- };
13873
- return new ZodObject(def);
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
13848
+ });
13874
13849
  }
13875
- function strictObject(shape, params) {
13876
- return new ZodObject({
13877
- type: "object",
13878
- shape,
13879
- catchall: never(),
13880
- ...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
13881
13858
  });
13882
13859
  }
13883
- function looseObject(shape, params) {
13884
- return new ZodObject({
13885
- type: "object",
13886
- shape,
13887
- catchall: unknown(),
13888
- ...util_exports.normalizeParams(params)
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);
13866
+ ZodType.init(inst, def);
13867
+ inst._zod.processJSONSchema = (ctx, json2, params) => readonlyProcessor(inst, ctx, json2, params);
13868
+ inst.unwrap = () => inst._zod.def.innerType;
13869
+ });
13870
+ function readonly(innerType) {
13871
+ return new ZodReadonly({
13872
+ type: "readonly",
13873
+ innerType
13889
13874
  });
13890
13875
  }
13891
- var ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
13892
- $ZodUnion.init(inst, def);
13876
+ var ZodTemplateLiteral = /* @__PURE__ */ $constructor("ZodTemplateLiteral", (inst, def) => {
13877
+ $ZodTemplateLiteral.init(inst, def);
13893
13878
  ZodType.init(inst, def);
13894
- inst._zod.processJSONSchema = (ctx, json2, params) => unionProcessor(inst, ctx, json2, params);
13895
- inst.options = def.options;
13879
+ inst._zod.processJSONSchema = (ctx, json2, params) => templateLiteralProcessor(inst, ctx, json2, params);
13896
13880
  });
13897
- function union(options, params) {
13898
- return new ZodUnion({
13899
- type: "union",
13900
- options,
13881
+ function templateLiteral(parts, params) {
13882
+ return new ZodTemplateLiteral({
13883
+ type: "template_literal",
13884
+ parts,
13901
13885
  ...util_exports.normalizeParams(params)
13902
13886
  });
13903
13887
  }
13904
- var ZodXor = /* @__PURE__ */ $constructor("ZodXor", (inst, def) => {
13905
- ZodUnion.init(inst, def);
13906
- $ZodXor.init(inst, def);
13907
- inst._zod.processJSONSchema = (ctx, json2, params) => unionProcessor(inst, ctx, json2, params);
13908
- inst.options = def.options;
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();
13909
13893
  });
13910
- function xor(options, params) {
13911
- return new ZodXor({
13912
- type: "union",
13913
- options,
13914
- inclusive: false,
13915
- ...util_exports.normalizeParams(params)
13894
+ function lazy(getter) {
13895
+ return new ZodLazy({
13896
+ type: "lazy",
13897
+ getter
13916
13898
  });
13917
13899
  }
13918
- var ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("ZodDiscriminatedUnion", (inst, def) => {
13919
- ZodUnion.init(inst, def);
13920
- $ZodDiscriminatedUnion.init(inst, def);
13900
+ var ZodPromise = /* @__PURE__ */ $constructor("ZodPromise", (inst, def) => {
13901
+ $ZodPromise.init(inst, def);
13902
+ ZodType.init(inst, def);
13903
+ inst._zod.processJSONSchema = (ctx, json2, params) => promiseProcessor(inst, ctx, json2, params);
13904
+ inst.unwrap = () => inst._zod.def.innerType;
13921
13905
  });
13922
- function discriminatedUnion(discriminator, options, params) {
13923
- return new ZodDiscriminatedUnion({
13924
- type: "union",
13925
- options,
13926
- discriminator,
13927
- ...util_exports.normalizeParams(params)
13906
+ function promise(innerType) {
13907
+ return new ZodPromise({
13908
+ type: "promise",
13909
+ innerType
13928
13910
  });
13929
13911
  }
13930
- var ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
13931
- $ZodIntersection.init(inst, def);
13912
+ var ZodFunction = /* @__PURE__ */ $constructor("ZodFunction", (inst, def) => {
13913
+ $ZodFunction.init(inst, def);
13932
13914
  ZodType.init(inst, def);
13933
- inst._zod.processJSONSchema = (ctx, json2, params) => intersectionProcessor(inst, ctx, json2, params);
13915
+ inst._zod.processJSONSchema = (ctx, json2, params) => functionProcessor(inst, ctx, json2, params);
13934
13916
  });
13935
- function intersection(left, right) {
13936
- return new ZodIntersection({
13937
- type: "intersection",
13938
- left,
13939
- right
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()
13940
13922
  });
13941
13923
  }
13942
- var ZodTuple = /* @__PURE__ */ $constructor("ZodTuple", (inst, def) => {
13943
- $ZodTuple.init(inst, def);
13924
+ var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
13925
+ $ZodCustom.init(inst, def);
13944
13926
  ZodType.init(inst, def);
13945
- inst._zod.processJSONSchema = (ctx, json2, params) => tupleProcessor(inst, ctx, json2, params);
13946
- inst.rest = (rest) => inst.clone({
13947
- ...inst._zod.def,
13948
- rest
13949
- });
13927
+ inst._zod.processJSONSchema = (ctx, json2, params) => customProcessor(inst, ctx, json2, params);
13950
13928
  });
13951
- function tuple(items, _paramsOrRest, _params) {
13952
- const hasRest = _paramsOrRest instanceof $ZodType;
13953
- const params = hasRest ? _params : _paramsOrRest;
13954
- const rest = hasRest ? _paramsOrRest : null;
13955
- return new ZodTuple({
13956
- type: "tuple",
13957
- items,
13958
- rest,
13929
+ function check(fn) {
13930
+ const ch = new $ZodCheck({
13931
+ check: "custom"
13932
+ // ...util.normalizeParams(params),
13933
+ });
13934
+ ch._zod.check = fn;
13935
+ return ch;
13936
+ }
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,
13959
13954
  ...util_exports.normalizeParams(params)
13960
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;
13961
13969
  }
13962
- var ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
13963
- $ZodRecord.init(inst, def);
13964
- ZodType.init(inst, def);
13965
- inst._zod.processJSONSchema = (ctx, json2, params) => recordProcessor(inst, ctx, json2, params);
13966
- inst.keyType = def.keyType;
13967
- inst.valueType = def.valueType;
13968
- });
13969
- function record(keyType, valueType, params) {
13970
- if (!valueType || !valueType._zod) {
13971
- return new ZodRecord({
13972
- type: "record",
13973
- keyType: string2(),
13974
- valueType: keyType,
13975
- ...util_exports.normalizeParams(valueType)
13976
- });
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)]);
13978
+ });
13979
+ return jsonSchema;
13980
+ }
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
14006
+ });
14007
+ }
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";
13977
14096
  }
13978
- return new ZodRecord({
13979
- type: "record",
13980
- keyType,
13981
- valueType,
13982
- ...util_exports.normalizeParams(params)
13983
- });
13984
- }
13985
- function partialRecord(keyType, valueType, params) {
13986
- const k = clone(keyType);
13987
- k._zod.values = void 0;
13988
- return new ZodRecord({
13989
- type: "record",
13990
- keyType: k,
13991
- valueType,
13992
- ...util_exports.normalizeParams(params)
13993
- });
13994
- }
13995
- function looseRecord(keyType, valueType, params) {
13996
- return new ZodRecord({
13997
- type: "record",
13998
- keyType,
13999
- valueType,
14000
- mode: "loose",
14001
- ...util_exports.normalizeParams(params)
14002
- });
14003
- }
14004
- var ZodMap = /* @__PURE__ */ $constructor("ZodMap", (inst, def) => {
14005
- $ZodMap.init(inst, def);
14006
- ZodType.init(inst, def);
14007
- inst._zod.processJSONSchema = (ctx, json2, params) => mapProcessor(inst, ctx, json2, params);
14008
- inst.keyType = def.keyType;
14009
- inst.valueType = def.valueType;
14010
- inst.min = (...args) => inst.check(_minSize(...args));
14011
- inst.nonempty = (params) => inst.check(_minSize(1, params));
14012
- inst.max = (...args) => inst.check(_maxSize(...args));
14013
- inst.size = (...args) => inst.check(_size(...args));
14014
- });
14015
- function map(keyType, valueType, params) {
14016
- return new ZodMap({
14017
- type: "map",
14018
- keyType,
14019
- valueType,
14020
- ...util_exports.normalizeParams(params)
14021
- });
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";
14022
14104
  }
14023
- var ZodSet = /* @__PURE__ */ $constructor("ZodSet", (inst, def) => {
14024
- $ZodSet.init(inst, def);
14025
- ZodType.init(inst, def);
14026
- inst._zod.processJSONSchema = (ctx, json2, params) => setProcessor(inst, ctx, json2, params);
14027
- inst.min = (...args) => inst.check(_minSize(...args));
14028
- inst.nonempty = (params) => inst.check(_minSize(1, params));
14029
- inst.max = (...args) => inst.check(_maxSize(...args));
14030
- inst.size = (...args) => inst.check(_size(...args));
14031
- });
14032
- function set(valueType, params) {
14033
- return new ZodSet({
14034
- type: "set",
14035
- valueType,
14036
- ...util_exports.normalizeParams(params)
14037
- });
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}`);
14038
14122
  }
14039
- var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
14040
- $ZodEnum.init(inst, def);
14041
- ZodType.init(inst, def);
14042
- inst._zod.processJSONSchema = (ctx, json2, params) => enumProcessor(inst, ctx, json2, params);
14043
- inst.enum = def.entries;
14044
- inst.options = Object.values(def.entries);
14045
- const keys = new Set(Object.keys(def.entries));
14046
- inst.extract = (values, params) => {
14047
- const newEntries = {};
14048
- for (const value of values) {
14049
- if (keys.has(value)) {
14050
- newEntries[value] = def.entries[value];
14051
- } else
14052
- 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();
14053
14127
  }
14054
- return new ZodEnum({
14055
- ...def,
14056
- checks: [],
14057
- ...util_exports.normalizeParams(params),
14058
- entries: newEntries
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);
14146
+ }
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);
14059
14190
  });
14060
- };
14061
- inst.exclude = (values, params) => {
14062
- const newEntries = { ...def.entries };
14063
- for (const value of values) {
14064
- if (keys.has(value)) {
14065
- delete newEntries[value];
14066
- } else
14067
- throw new Error(`Key ${value} not found in enum`);
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;
14068
14267
  }
14069
- return new ZodEnum({
14070
- ...def,
14071
- checks: [],
14072
- ...util_exports.normalizeParams(params),
14073
- entries: newEntries
14074
- });
14075
- };
14076
- });
14077
- function _enum2(values, params) {
14078
- const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
14079
- return new ZodEnum({
14080
- type: "enum",
14081
- entries,
14082
- ...util_exports.normalizeParams(params)
14083
- });
14084
- }
14085
- function nativeEnum(entries, params) {
14086
- return new ZodEnum({
14087
- type: "enum",
14088
- entries,
14089
- ...util_exports.normalizeParams(params)
14090
- });
14091
- }
14092
- var ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
14093
- $ZodLiteral.init(inst, def);
14094
- ZodType.init(inst, def);
14095
- inst._zod.processJSONSchema = (ctx, json2, params) => literalProcessor(inst, ctx, json2, params);
14096
- inst.values = new Set(def.values);
14097
- Object.defineProperty(inst, "value", {
14098
- get() {
14099
- if (def.values.length > 1) {
14100
- throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
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);
14101
14273
  }
14102
- 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;
14103
14292
  }
14104
- });
14105
- });
14106
- function literal(value, params) {
14107
- return new ZodLiteral({
14108
- type: "literal",
14109
- values: Array.isArray(value) ? value : [value],
14110
- ...util_exports.normalizeParams(params)
14111
- });
14112
- }
14113
- var ZodFile = /* @__PURE__ */ $constructor("ZodFile", (inst, def) => {
14114
- $ZodFile.init(inst, def);
14115
- ZodType.init(inst, def);
14116
- inst._zod.processJSONSchema = (ctx, json2, params) => fileProcessor(inst, ctx, json2, params);
14117
- inst.min = (size, params) => inst.check(_minSize(size, params));
14118
- inst.max = (size, params) => inst.check(_maxSize(size, params));
14119
- inst.mime = (types, params) => inst.check(_mime(Array.isArray(types) ? types : [types], params));
14120
- });
14121
- function file(params) {
14122
- return _file(ZodFile, params);
14123
- }
14124
- var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
14125
- $ZodTransform.init(inst, def);
14126
- ZodType.init(inst, def);
14127
- inst._zod.processJSONSchema = (ctx, json2, params) => transformProcessor(inst, ctx, json2, params);
14128
- inst._zod.parse = (payload, _ctx) => {
14129
- if (_ctx.direction === "backward") {
14130
- throw new $ZodEncodeError(inst.constructor.name);
14293
+ case "boolean": {
14294
+ zodSchema = z.boolean();
14295
+ break;
14131
14296
  }
14132
- payload.addIssue = (issue2) => {
14133
- if (typeof issue2 === "string") {
14134
- 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));
14135
14353
  } else {
14136
- const _issue = issue2;
14137
- if (_issue.fatal)
14138
- _issue.continue = false;
14139
- _issue.code ?? (_issue.code = "custom");
14140
- _issue.input ?? (_issue.input = payload.value);
14141
- _issue.inst ?? (_issue.inst = inst);
14142
- payload.issues.push(util_exports.issue(_issue));
14354
+ zodSchema = objectSchema.passthrough();
14355
+ }
14356
+ break;
14357
+ }
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;
14408
+ }
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));
14143
14433
  }
14144
- };
14145
- const output = def.transform(payload.value, payload);
14146
- if (output instanceof Promise) {
14147
- return output.then((output2) => {
14148
- payload.value = output2;
14149
- payload.fallback = true;
14150
- return payload;
14151
- });
14434
+ baseSchema = result;
14152
14435
  }
14153
- payload.value = output;
14154
- payload.fallback = true;
14155
- return payload;
14156
- };
14157
- });
14158
- function transform(fn) {
14159
- return new ZodTransform({
14160
- type: "transform",
14161
- transform: fn
14162
- });
14163
- }
14164
- var ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
14165
- $ZodOptional.init(inst, def);
14166
- ZodType.init(inst, def);
14167
- inst._zod.processJSONSchema = (ctx, json2, params) => optionalProcessor(inst, ctx, json2, params);
14168
- inst.unwrap = () => inst._zod.def.innerType;
14169
- });
14170
- function optional(innerType) {
14171
- return new ZodOptional({
14172
- type: "optional",
14173
- innerType
14174
- });
14175
- }
14176
- var ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
14177
- $ZodExactOptional.init(inst, def);
14178
- ZodType.init(inst, def);
14179
- inst._zod.processJSONSchema = (ctx, json2, params) => optionalProcessor(inst, ctx, json2, params);
14180
- inst.unwrap = () => inst._zod.def.innerType;
14181
- });
14182
- function exactOptional(innerType) {
14183
- return new ZodExactOptional({
14184
- type: "optional",
14185
- innerType
14186
- });
14187
- }
14188
- var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
14189
- $ZodNullable.init(inst, def);
14190
- ZodType.init(inst, def);
14191
- inst._zod.processJSONSchema = (ctx, json2, params) => nullableProcessor(inst, ctx, json2, params);
14192
- inst.unwrap = () => inst._zod.def.innerType;
14193
- });
14194
- function nullable(innerType) {
14195
- return new ZodNullable({
14196
- type: "nullable",
14197
- innerType
14198
- });
14199
- }
14200
- function nullish2(innerType) {
14201
- return optional(nullable(innerType));
14202
- }
14203
- var ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
14204
- $ZodDefault.init(inst, def);
14205
- ZodType.init(inst, def);
14206
- inst._zod.processJSONSchema = (ctx, json2, params) => defaultProcessor(inst, ctx, json2, params);
14207
- inst.unwrap = () => inst._zod.def.innerType;
14208
- inst.removeDefault = inst.unwrap;
14209
- });
14210
- function _default2(innerType, defaultValue) {
14211
- return new ZodDefault({
14212
- type: "default",
14213
- innerType,
14214
- get defaultValue() {
14215
- 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];
14216
14451
  }
14217
- });
14218
- }
14219
- var ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
14220
- $ZodPrefault.init(inst, def);
14221
- ZodType.init(inst, def);
14222
- inst._zod.processJSONSchema = (ctx, json2, params) => prefaultProcessor(inst, ctx, json2, params);
14223
- inst.unwrap = () => inst._zod.def.innerType;
14224
- });
14225
- function prefault(innerType, defaultValue) {
14226
- return new ZodPrefault({
14227
- type: "prefault",
14228
- innerType,
14229
- get defaultValue() {
14230
- return typeof defaultValue === "function" ? defaultValue() : util_exports.shallowClone(defaultValue);
14452
+ }
14453
+ const contentMetadataKeys = ["contentEncoding", "contentMediaType", "contentSchema"];
14454
+ for (const key of contentMetadataKeys) {
14455
+ if (key in schema) {
14456
+ extraMeta[key] = schema[key];
14231
14457
  }
14232
- });
14233
- }
14234
- var ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
14235
- $ZodNonOptional.init(inst, def);
14236
- ZodType.init(inst, def);
14237
- inst._zod.processJSONSchema = (ctx, json2, params) => nonoptionalProcessor(inst, ctx, json2, params);
14238
- inst.unwrap = () => inst._zod.def.innerType;
14239
- });
14240
- function nonoptional(innerType, params) {
14241
- return new ZodNonOptional({
14242
- type: "nonoptional",
14243
- innerType,
14244
- ...util_exports.normalizeParams(params)
14245
- });
14246
- }
14247
- var ZodSuccess = /* @__PURE__ */ $constructor("ZodSuccess", (inst, def) => {
14248
- $ZodSuccess.init(inst, def);
14249
- ZodType.init(inst, def);
14250
- inst._zod.processJSONSchema = (ctx, json2, params) => successProcessor(inst, ctx, json2, params);
14251
- inst.unwrap = () => inst._zod.def.innerType;
14252
- });
14253
- function success(innerType) {
14254
- return new ZodSuccess({
14255
- type: "success",
14256
- innerType
14257
- });
14258
- }
14259
- var ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
14260
- $ZodCatch.init(inst, def);
14261
- ZodType.init(inst, def);
14262
- inst._zod.processJSONSchema = (ctx, json2, params) => catchProcessor(inst, ctx, json2, params);
14263
- inst.unwrap = () => inst._zod.def.innerType;
14264
- inst.removeCatch = inst.unwrap;
14265
- });
14266
- function _catch2(innerType, catchValue) {
14267
- return new ZodCatch({
14268
- type: "catch",
14269
- innerType,
14270
- catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
14271
- });
14272
- }
14273
- var ZodNaN = /* @__PURE__ */ $constructor("ZodNaN", (inst, def) => {
14274
- $ZodNaN.init(inst, def);
14275
- ZodType.init(inst, def);
14276
- inst._zod.processJSONSchema = (ctx, json2, params) => nanProcessor(inst, ctx, json2, params);
14277
- });
14278
- function nan(params) {
14279
- return _nan(ZodNaN, params);
14280
- }
14281
- var ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
14282
- $ZodPipe.init(inst, def);
14283
- ZodType.init(inst, def);
14284
- inst._zod.processJSONSchema = (ctx, json2, params) => pipeProcessor(inst, ctx, json2, params);
14285
- inst.in = def.in;
14286
- inst.out = def.out;
14287
- });
14288
- function pipe(in_, out) {
14289
- return new ZodPipe({
14290
- type: "pipe",
14291
- in: in_,
14292
- out
14293
- // ...util.normalizeParams(params),
14294
- });
14295
- }
14296
- var ZodCodec = /* @__PURE__ */ $constructor("ZodCodec", (inst, def) => {
14297
- ZodPipe.init(inst, def);
14298
- $ZodCodec.init(inst, def);
14299
- });
14300
- function codec(in_, out, params) {
14301
- return new ZodCodec({
14302
- type: "pipe",
14303
- in: in_,
14304
- out,
14305
- transform: params.decode,
14306
- reverseTransform: params.encode
14307
- });
14308
- }
14309
- function invertCodec(codec2) {
14310
- const def = codec2._zod.def;
14311
- return new ZodCodec({
14312
- type: "pipe",
14313
- in: def.out,
14314
- out: def.in,
14315
- transform: def.reverseTransform,
14316
- reverseTransform: def.transform
14317
- });
14318
- }
14319
- var ZodPreprocess = /* @__PURE__ */ $constructor("ZodPreprocess", (inst, def) => {
14320
- ZodPipe.init(inst, def);
14321
- $ZodPreprocess.init(inst, def);
14322
- });
14323
- var ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
14324
- $ZodReadonly.init(inst, def);
14325
- ZodType.init(inst, def);
14326
- inst._zod.processJSONSchema = (ctx, json2, params) => readonlyProcessor(inst, ctx, json2, params);
14327
- inst.unwrap = () => inst._zod.def.innerType;
14328
- });
14329
- function readonly(innerType) {
14330
- return new ZodReadonly({
14331
- type: "readonly",
14332
- innerType
14333
- });
14334
- }
14335
- var ZodTemplateLiteral = /* @__PURE__ */ $constructor("ZodTemplateLiteral", (inst, def) => {
14336
- $ZodTemplateLiteral.init(inst, def);
14337
- ZodType.init(inst, def);
14338
- inst._zod.processJSONSchema = (ctx, json2, params) => templateLiteralProcessor(inst, ctx, json2, params);
14339
- });
14340
- function templateLiteral(parts, params) {
14341
- return new ZodTemplateLiteral({
14342
- type: "template_literal",
14343
- parts,
14344
- ...util_exports.normalizeParams(params)
14345
- });
14346
- }
14347
- var ZodLazy = /* @__PURE__ */ $constructor("ZodLazy", (inst, def) => {
14348
- $ZodLazy.init(inst, def);
14349
- ZodType.init(inst, def);
14350
- inst._zod.processJSONSchema = (ctx, json2, params) => lazyProcessor(inst, ctx, json2, params);
14351
- inst.unwrap = () => inst._zod.def.getter();
14352
- });
14353
- function lazy(getter) {
14354
- return new ZodLazy({
14355
- type: "lazy",
14356
- getter
14357
- });
14358
- }
14359
- var ZodPromise = /* @__PURE__ */ $constructor("ZodPromise", (inst, def) => {
14360
- $ZodPromise.init(inst, def);
14361
- ZodType.init(inst, def);
14362
- inst._zod.processJSONSchema = (ctx, json2, params) => promiseProcessor(inst, ctx, json2, params);
14363
- inst.unwrap = () => inst._zod.def.innerType;
14364
- });
14365
- function promise(innerType) {
14366
- return new ZodPromise({
14367
- type: "promise",
14368
- innerType
14369
- });
14458
+ }
14459
+ for (const key of Object.keys(schema)) {
14460
+ if (!RECOGNIZED_KEYS.has(key)) {
14461
+ extraMeta[key] = schema[key];
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;
14370
14471
  }
14371
- var ZodFunction = /* @__PURE__ */ $constructor("ZodFunction", (inst, def) => {
14372
- $ZodFunction.init(inst, def);
14373
- ZodType.init(inst, def);
14374
- inst._zod.processJSONSchema = (ctx, json2, params) => functionProcessor(inst, ctx, json2, params);
14375
- });
14376
- function _function(params) {
14377
- return new ZodFunction({
14378
- type: "function",
14379
- input: Array.isArray(params?.input) ? tuple(params?.input) : params?.input ?? array(unknown()),
14380
- output: params?.output ?? unknown()
14381
- });
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
+ };
14492
+ return convertSchema(normalized, ctx);
14382
14493
  }
14383
- var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
14384
- $ZodCustom.init(inst, def);
14385
- ZodType.init(inst, def);
14386
- inst._zod.processJSONSchema = (ctx, json2, params) => customProcessor(inst, ctx, json2, params);
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
14387
14503
  });
14388
- function check(fn) {
14389
- const ch = new $ZodCheck({
14390
- check: "custom"
14391
- // ...util.normalizeParams(params),
14392
- });
14393
- ch._zod.check = fn;
14394
- return ch;
14395
- }
14396
- function custom(fn, _params) {
14397
- return _custom(ZodCustom, fn ?? (() => true), _params);
14398
- }
14399
- function refine(fn, _params = {}) {
14400
- return _refine(ZodCustom, fn, _params);
14504
+ function string3(params) {
14505
+ return _coercedString(ZodString, params);
14401
14506
  }
14402
- function superRefine(fn, params) {
14403
- return _superRefine(fn, params);
14507
+ function number3(params) {
14508
+ return _coercedNumber(ZodNumber, params);
14404
14509
  }
14405
- var describe2 = describe;
14406
- var meta2 = meta;
14407
- function _instanceof(cls, params = {}) {
14408
- const inst = new ZodCustom({
14409
- type: "custom",
14410
- check: "custom",
14411
- fn: (data) => data instanceof cls,
14412
- abort: true,
14413
- ...util_exports.normalizeParams(params)
14414
- });
14415
- inst._zod.bag.Class = cls;
14416
- inst._zod.check = (payload) => {
14417
- if (!(payload.value instanceof cls)) {
14418
- payload.issues.push({
14419
- code: "invalid_type",
14420
- expected: cls.name,
14421
- input: payload.value,
14422
- inst,
14423
- path: [...inst._zod.def.path ?? []]
14424
- });
14425
- }
14426
- };
14427
- return inst;
14510
+ function boolean3(params) {
14511
+ return _coercedBoolean(ZodBoolean, params);
14428
14512
  }
14429
- var stringbool = (...args) => _stringbool({
14430
- Codec: ZodCodec,
14431
- Boolean: ZodBoolean,
14432
- String: ZodString
14433
- }, ...args);
14434
- function json(params) {
14435
- const jsonSchema = lazy(() => {
14436
- return union([string2(params), number2(), boolean2(), _null3(), array(jsonSchema), record(string2(), jsonSchema)]);
14437
- });
14438
- return jsonSchema;
14513
+ function bigint3(params) {
14514
+ return _coercedBigint(ZodBigInt, params);
14439
14515
  }
14440
- function preprocess(fn, schema) {
14441
- return new ZodPreprocess({
14442
- type: "pipe",
14443
- in: transform(fn),
14444
- out: schema
14445
- });
14516
+ function date4(params) {
14517
+ return _coercedDate(ZodDate, params);
14446
14518
  }
14447
14519
 
14448
- // node_modules/zod/v4/classic/compat.js
14449
- var ZodIssueCode = {
14450
- invalid_type: "invalid_type",
14451
- too_big: "too_big",
14452
- too_small: "too_small",
14453
- invalid_format: "invalid_format",
14454
- not_multiple_of: "not_multiple_of",
14455
- unrecognized_keys: "unrecognized_keys",
14456
- invalid_union: "invalid_union",
14457
- invalid_key: "invalid_key",
14458
- invalid_element: "invalid_element",
14459
- invalid_value: "invalid_value",
14460
- custom: "custom"
14461
- };
14462
- function setErrorMap(map2) {
14463
- config({
14464
- customError: map2
14465
- });
14466
- }
14467
- function getErrorMap() {
14468
- return config().customError;
14469
- }
14470
- var ZodFirstPartyTypeKind;
14471
- /* @__PURE__ */ (function(ZodFirstPartyTypeKind2) {
14472
- })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
14520
+ // node_modules/zod/v4/classic/external.js
14521
+ config(en_default());
14473
14522
 
14474
- // node_modules/zod/v4/classic/from-json-schema.js
14475
- var z = {
14476
- ...schemas_exports2,
14477
- ...checks_exports2,
14478
- iso: iso_exports
14479
- };
14480
- var RECOGNIZED_KEYS = /* @__PURE__ */ new Set([
14481
- // Schema identification
14482
- "$schema",
14483
- "$ref",
14484
- "$defs",
14485
- "definitions",
14486
- // Core schema keywords
14487
- "$id",
14488
- "id",
14489
- "$comment",
14490
- "$anchor",
14491
- "$vocabulary",
14492
- "$dynamicRef",
14493
- "$dynamicAnchor",
14494
- // Type
14495
- "type",
14496
- "enum",
14497
- "const",
14498
- // Composition
14499
- "anyOf",
14500
- "oneOf",
14501
- "allOf",
14502
- "not",
14503
- // Object
14504
- "properties",
14505
- "required",
14506
- "additionalProperties",
14507
- "patternProperties",
14508
- "propertyNames",
14509
- "minProperties",
14510
- "maxProperties",
14511
- // Array
14512
- "items",
14513
- "prefixItems",
14514
- "additionalItems",
14515
- "minItems",
14516
- "maxItems",
14517
- "uniqueItems",
14518
- "contains",
14519
- "minContains",
14520
- "maxContains",
14521
- // String
14522
- "minLength",
14523
- "maxLength",
14524
- "pattern",
14525
- "format",
14526
- // Number
14527
- "minimum",
14528
- "maximum",
14529
- "exclusiveMinimum",
14530
- "exclusiveMaximum",
14531
- "multipleOf",
14532
- // Already handled metadata
14533
- "description",
14534
- "default",
14535
- // Content
14536
- "contentEncoding",
14537
- "contentMediaType",
14538
- "contentSchema",
14539
- // Unsupported (error-throwing)
14540
- "unevaluatedItems",
14541
- "unevaluatedProperties",
14542
- "if",
14543
- "then",
14544
- "else",
14545
- "dependentSchemas",
14546
- "dependentRequired",
14547
- // OpenAPI
14548
- "nullable",
14549
- "readOnly"
14550
- ]);
14551
- function detectVersion(schema, defaultTarget) {
14552
- const $schema = schema.$schema;
14553
- if ($schema === "https://json-schema.org/draft/2020-12/schema") {
14554
- return "draft-2020-12";
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;
14542
+ }
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 });
14546
+ }
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 });
14550
+ }
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 });
14555
14554
  }
14556
- if ($schema === "http://json-schema.org/draft-07/schema#") {
14557
- return "draft-7";
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 });
14558
14558
  }
14559
- if ($schema === "http://json-schema.org/draft-04/schema#") {
14560
- return "draft-4";
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 });
14561
14562
  }
14562
- return defaultTarget ?? "draft-2020-12";
14563
- }
14564
- function resolveRef(ref, ctx) {
14565
- if (!ref.startsWith("#")) {
14566
- throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
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 });
14567
14566
  }
14568
- const path = ref.slice(1).split("/").filter(Boolean);
14569
- if (path.length === 0) {
14570
- return ctx.rootSchema;
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);
14571
14575
  }
14572
- const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14573
- if (path[0] === defsKey) {
14574
- const key = path[1];
14575
- if (!key || !ctx.defs[key]) {
14576
- throw new Error(`Reference not found: ${ref}`);
14577
- }
14578
- return ctx.defs[key];
14576
+ if (status === 404) {
14577
+ return ToolError.notFound(message);
14579
14578
  }
14580
- throw new Error(`Reference not found: ${ref}`);
14581
- }
14582
- function convertBaseSchema(schema, ctx) {
14583
- if (schema.not !== void 0) {
14584
- if (typeof schema.not === "object" && Object.keys(schema.not).length === 0) {
14585
- return z.never();
14586
- }
14587
- throw new Error("not is not supported in Zod (except { not: {} } for never)");
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);
14588
14583
  }
14589
- if (schema.unevaluatedItems !== void 0) {
14590
- throw new Error("unevaluatedItems is not supported");
14584
+ if (status === 400 || status === 422) {
14585
+ return ToolError.validation(message);
14591
14586
  }
14592
- if (schema.unevaluatedProperties !== void 0) {
14593
- throw new Error("unevaluatedProperties is not supported");
14587
+ if (status === 408) {
14588
+ return ToolError.timeout(message);
14594
14589
  }
14595
- if (schema.if !== void 0 || schema.then !== void 0 || schema.else !== void 0) {
14596
- throw new Error("Conditional schemas (if/then/else) are not supported");
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 });
14597
14596
  }
14598
- if (schema.dependentSchemas !== void 0 || schema.dependentRequired !== void 0) {
14599
- throw new Error("dependentSchemas and dependentRequired are not supported");
14597
+ if (status >= 400 && status < 500) {
14598
+ return new ToolError(message, "http_error", { retryable: false });
14600
14599
  }
14601
- if (schema.$ref) {
14602
- const refPath = schema.$ref;
14603
- if (ctx.refs.has(refPath)) {
14604
- return ctx.refs.get(refPath);
14605
- }
14606
- if (ctx.processing.has(refPath)) {
14607
- return z.lazy(() => {
14608
- if (!ctx.refs.has(refPath)) {
14609
- throw new Error(`Circular reference not resolved: ${refPath}`);
14610
- }
14611
- return ctx.refs.get(refPath);
14612
- });
14613
- }
14614
- ctx.processing.add(refPath);
14615
- const resolved = resolveRef(refPath, ctx);
14616
- const zodSchema2 = convertSchema(resolved, ctx);
14617
- ctx.refs.set(refPath, zodSchema2);
14618
- ctx.processing.delete(refPath);
14619
- return zodSchema2;
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;
14620
14606
  }
14621
- if (schema.enum !== void 0) {
14622
- const enumValues = schema.enum;
14623
- if (ctx.version === "openapi-3.0" && schema.nullable === true && enumValues.length === 1 && enumValues[0] === null) {
14624
- return z.null();
14625
- }
14626
- if (enumValues.length === 0) {
14627
- return z.never();
14628
- }
14629
- if (enumValues.length === 1) {
14630
- return z.literal(enumValues[0]);
14631
- }
14632
- if (enumValues.every((v) => typeof v === "string")) {
14633
- return z.enum(enumValues);
14634
- }
14635
- const literalSchemas = enumValues.map((v) => z.literal(v));
14636
- if (literalSchemas.length < 2) {
14637
- return literalSchemas[0];
14638
- }
14639
- return z.union([literalSchemas[0], literalSchemas[1], ...literalSchemas.slice(2)]);
14607
+ const date5 = Date.parse(value);
14608
+ if (!Number.isNaN(date5)) {
14609
+ const ms = date5 - Date.now();
14610
+ return ms > 0 ? ms : void 0;
14640
14611
  }
14641
- if (schema.const !== void 0) {
14642
- return z.literal(schema.const);
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));
14625
+ }
14643
14626
  }
14644
- const type = schema.type;
14645
- if (Array.isArray(type)) {
14646
- const typeSchemas = type.map((t) => {
14647
- const typeSchema = { ...schema, type: t };
14648
- return convertBaseSchema(typeSchema, ctx);
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
14649
14639
  });
14650
- if (typeSchemas.length === 0) {
14651
- return z.never();
14640
+ } catch (error51) {
14641
+ if (error51 instanceof DOMException && error51.name === "TimeoutError") {
14642
+ throw ToolError.timeout(`fetchFromPage: request timed out after ${timeout}ms for ${url2}`);
14652
14643
  }
14653
- if (typeSchemas.length === 1) {
14654
- return typeSchemas[0];
14644
+ if (combinedSignal.aborted) {
14645
+ throw new ToolError(`fetchFromPage: request aborted for ${url2}`, "aborted");
14655
14646
  }
14656
- return z.union(typeSchemas);
14647
+ throw new ToolError(`fetchFromPage: network error for ${url2}: ${toErrorMessage(error51)}`, "network_error", {
14648
+ category: "internal",
14649
+ retryable: true
14650
+ });
14657
14651
  }
14658
- if (!type) {
14659
- return z.any();
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);
14660
14657
  }
14661
- let zodSchema;
14662
- switch (type) {
14663
- case "string": {
14664
- let stringSchema = z.string();
14665
- if (schema.format) {
14666
- const format = schema.format;
14667
- if (format === "email") {
14668
- stringSchema = stringSchema.check(z.email());
14669
- } else if (format === "uri" || format === "uri-reference") {
14670
- stringSchema = stringSchema.check(z.url());
14671
- } else if (format === "uuid" || format === "guid") {
14672
- stringSchema = stringSchema.check(z.uuid());
14673
- } else if (format === "date-time") {
14674
- stringSchema = stringSchema.check(z.iso.datetime());
14675
- } else if (format === "date") {
14676
- stringSchema = stringSchema.check(z.iso.date());
14677
- } else if (format === "time") {
14678
- stringSchema = stringSchema.check(z.iso.time());
14679
- } else if (format === "duration") {
14680
- stringSchema = stringSchema.check(z.iso.duration());
14681
- } else if (format === "ipv4") {
14682
- stringSchema = stringSchema.check(z.ipv4());
14683
- } else if (format === "ipv6") {
14684
- stringSchema = stringSchema.check(z.ipv6());
14685
- } else if (format === "mac") {
14686
- stringSchema = stringSchema.check(z.mac());
14687
- } else if (format === "cidr") {
14688
- stringSchema = stringSchema.check(z.cidrv4());
14689
- } else if (format === "cidr-v6") {
14690
- stringSchema = stringSchema.check(z.cidrv6());
14691
- } else if (format === "base64") {
14692
- stringSchema = stringSchema.check(z.base64());
14693
- } else if (format === "base64url") {
14694
- stringSchema = stringSchema.check(z.base64url());
14695
- } else if (format === "e164") {
14696
- stringSchema = stringSchema.check(z.e164());
14697
- } else if (format === "jwt") {
14698
- stringSchema = stringSchema.check(z.jwt());
14699
- } else if (format === "emoji") {
14700
- stringSchema = stringSchema.check(z.emoji());
14701
- } else if (format === "nanoid") {
14702
- stringSchema = stringSchema.check(z.nanoid());
14703
- } else if (format === "cuid") {
14704
- stringSchema = stringSchema.check(z.cuid());
14705
- } else if (format === "cuid2") {
14706
- stringSchema = stringSchema.check(z.cuid2());
14707
- } else if (format === "ulid") {
14708
- stringSchema = stringSchema.check(z.ulid());
14709
- } else if (format === "xid") {
14710
- stringSchema = stringSchema.check(z.xid());
14711
- } else if (format === "ksuid") {
14712
- stringSchema = stringSchema.check(z.ksuid());
14658
+ return response;
14659
+ };
14660
+
14661
+ // node_modules/@opentabs-dev/plugin-sdk/dist/timing.js
14662
+ var waitUntil = (predicate, opts) => {
14663
+ const interval = opts?.interval ?? 200;
14664
+ const timeout = opts?.timeout ?? 1e4;
14665
+ const signal = opts?.signal;
14666
+ const abortReason = () => signal?.reason instanceof Error ? signal.reason : new Error("waitUntil: aborted");
14667
+ if (signal?.aborted)
14668
+ return Promise.reject(abortReason());
14669
+ return new Promise((resolve, reject) => {
14670
+ let settled = false;
14671
+ let poller;
14672
+ let lastPredicateError;
14673
+ const isSettled = () => settled;
14674
+ const cleanup = () => {
14675
+ settled = true;
14676
+ clearTimeout(timer);
14677
+ clearTimeout(poller);
14678
+ signal?.removeEventListener("abort", onAbort);
14679
+ };
14680
+ const onAbort = () => {
14681
+ if (isSettled())
14682
+ return;
14683
+ cleanup();
14684
+ reject(abortReason());
14685
+ };
14686
+ signal?.addEventListener("abort", onAbort, { once: true });
14687
+ const timer = setTimeout(() => {
14688
+ if (isSettled())
14689
+ return;
14690
+ cleanup();
14691
+ const errorContext = lastPredicateError instanceof Error ? `: predicate last threw \u2014 ${lastPredicateError.message}` : "";
14692
+ reject(new Error(`waitUntil: timed out after ${timeout}ms waiting for predicate to return true${errorContext}`));
14693
+ }, timeout);
14694
+ const check2 = async () => {
14695
+ if (isSettled())
14696
+ return;
14697
+ try {
14698
+ const result = await predicate();
14699
+ if (result) {
14700
+ cleanup();
14701
+ resolve();
14702
+ return;
14713
14703
  }
14704
+ } catch (err2) {
14705
+ lastPredicateError = err2;
14714
14706
  }
14715
- if (typeof schema.minLength === "number") {
14716
- stringSchema = stringSchema.min(schema.minLength);
14717
- }
14718
- if (typeof schema.maxLength === "number") {
14719
- stringSchema = stringSchema.max(schema.maxLength);
14720
- }
14721
- if (schema.pattern) {
14722
- stringSchema = stringSchema.regex(new RegExp(schema.pattern));
14723
- }
14724
- zodSchema = stringSchema;
14725
- break;
14726
- }
14727
- case "number":
14728
- case "integer": {
14729
- let numberSchema = type === "integer" ? z.number().int() : z.number();
14730
- if (typeof schema.minimum === "number") {
14731
- numberSchema = numberSchema.min(schema.minimum);
14732
- }
14733
- if (typeof schema.maximum === "number") {
14734
- numberSchema = numberSchema.max(schema.maximum);
14735
- }
14736
- if (typeof schema.exclusiveMinimum === "number") {
14737
- numberSchema = numberSchema.gt(schema.exclusiveMinimum);
14738
- } else if (schema.exclusiveMinimum === true && typeof schema.minimum === "number") {
14739
- numberSchema = numberSchema.gt(schema.minimum);
14740
- }
14741
- if (typeof schema.exclusiveMaximum === "number") {
14742
- numberSchema = numberSchema.lt(schema.exclusiveMaximum);
14743
- } else if (schema.exclusiveMaximum === true && typeof schema.maximum === "number") {
14744
- numberSchema = numberSchema.lt(schema.maximum);
14745
- }
14746
- if (typeof schema.multipleOf === "number") {
14747
- numberSchema = numberSchema.multipleOf(schema.multipleOf);
14707
+ if (!isSettled()) {
14708
+ poller = setTimeout(() => void check2(), interval);
14748
14709
  }
14749
- zodSchema = numberSchema;
14750
- break;
14751
- }
14752
- case "boolean": {
14753
- zodSchema = z.boolean();
14754
- break;
14755
- }
14756
- case "null": {
14757
- zodSchema = z.null();
14758
- break;
14710
+ };
14711
+ void check2();
14712
+ });
14713
+ };
14714
+
14715
+ // node_modules/@opentabs-dev/plugin-sdk/dist/log.js
14716
+ var MAX_DATA_LENGTH = 10;
14717
+ var MAX_STRING_LENGTH = 4096;
14718
+ var MAX_SERIALIZED_SIZE = 64 * 1024;
14719
+ var safeSerializeArg = (value) => {
14720
+ try {
14721
+ if (value === null || value === void 0)
14722
+ return value;
14723
+ const type = typeof value;
14724
+ if (type === "boolean" || type === "number")
14725
+ return value;
14726
+ if (type === "string") {
14727
+ return value.length > MAX_STRING_LENGTH ? `${value.slice(0, MAX_STRING_LENGTH)}\u2026` : value;
14759
14728
  }
14760
- case "object": {
14761
- const shape = {};
14762
- const properties = schema.properties || {};
14763
- const requiredSet = new Set(schema.required || []);
14764
- for (const [key, propSchema] of Object.entries(properties)) {
14765
- const propZodSchema = convertSchema(propSchema, ctx);
14766
- shape[key] = requiredSet.has(key) ? propZodSchema : propZodSchema.optional();
14767
- }
14768
- if (schema.propertyNames) {
14769
- const keySchema = convertSchema(schema.propertyNames, ctx);
14770
- const valueSchema = schema.additionalProperties && typeof schema.additionalProperties === "object" ? convertSchema(schema.additionalProperties, ctx) : z.any();
14771
- if (Object.keys(shape).length === 0) {
14772
- zodSchema = z.record(keySchema, valueSchema);
14773
- break;
14774
- }
14775
- const objectSchema2 = z.object(shape).passthrough();
14776
- const recordSchema = z.looseRecord(keySchema, valueSchema);
14777
- zodSchema = z.intersection(objectSchema2, recordSchema);
14778
- break;
14779
- }
14780
- if (schema.patternProperties) {
14781
- const patternProps = schema.patternProperties;
14782
- const patternKeys = Object.keys(patternProps);
14783
- const looseRecords = [];
14784
- for (const pattern of patternKeys) {
14785
- const patternValue = convertSchema(patternProps[pattern], ctx);
14786
- const keySchema = z.string().regex(new RegExp(pattern));
14787
- looseRecords.push(z.looseRecord(keySchema, patternValue));
14788
- }
14789
- const schemasToIntersect = [];
14790
- if (Object.keys(shape).length > 0) {
14791
- schemasToIntersect.push(z.object(shape).passthrough());
14792
- }
14793
- schemasToIntersect.push(...looseRecords);
14794
- if (schemasToIntersect.length === 0) {
14795
- zodSchema = z.object({}).passthrough();
14796
- } else if (schemasToIntersect.length === 1) {
14797
- zodSchema = schemasToIntersect[0];
14798
- } else {
14799
- let result = z.intersection(schemasToIntersect[0], schemasToIntersect[1]);
14800
- for (let i = 2; i < schemasToIntersect.length; i++) {
14801
- result = z.intersection(result, schemasToIntersect[i]);
14729
+ if (type === "function")
14730
+ return `[Function: ${value.name || "anonymous"}]`;
14731
+ if (type === "symbol")
14732
+ return `[Symbol: ${value.description ?? ""}]`;
14733
+ if (type === "bigint")
14734
+ return `[BigInt: ${value.toString()}]`;
14735
+ if (typeof value.nodeType === "number" && typeof value.nodeName === "string") {
14736
+ try {
14737
+ const node = value;
14738
+ let classStr = "";
14739
+ if (typeof node.className === "string") {
14740
+ classStr = node.className ? `.${node.className.split(" ")[0] ?? ""}` : "";
14741
+ } else if (node.className !== null && typeof node.className === "object") {
14742
+ const baseVal = node.className.baseVal;
14743
+ if (typeof baseVal === "string") {
14744
+ classStr = baseVal ? `.${baseVal.split(" ")[0] ?? ""}` : "";
14802
14745
  }
14803
- zodSchema = result;
14804
14746
  }
14805
- break;
14806
- }
14807
- const objectSchema = z.object(shape);
14808
- if (schema.additionalProperties === false) {
14809
- zodSchema = objectSchema.strict();
14810
- } else if (typeof schema.additionalProperties === "object") {
14811
- zodSchema = objectSchema.catchall(convertSchema(schema.additionalProperties, ctx));
14812
- } else {
14813
- zodSchema = objectSchema.passthrough();
14747
+ return `[${node.nodeName}${node.id ? `#${node.id}` : ""}${classStr}]`;
14748
+ } catch {
14814
14749
  }
14815
- break;
14816
14750
  }
14817
- case "array": {
14818
- const prefixItems = schema.prefixItems;
14819
- const items = schema.items;
14820
- if (prefixItems && Array.isArray(prefixItems)) {
14821
- const tupleItems = prefixItems.map((item) => convertSchema(item, ctx));
14822
- const rest = items && typeof items === "object" && !Array.isArray(items) ? convertSchema(items, ctx) : void 0;
14823
- if (rest) {
14824
- zodSchema = z.tuple(tupleItems).rest(rest);
14825
- } else {
14826
- zodSchema = z.tuple(tupleItems);
14827
- }
14828
- if (typeof schema.minItems === "number") {
14829
- zodSchema = zodSchema.check(z.minLength(schema.minItems));
14830
- }
14831
- if (typeof schema.maxItems === "number") {
14832
- zodSchema = zodSchema.check(z.maxLength(schema.maxItems));
14833
- }
14834
- } else if (Array.isArray(items)) {
14835
- const tupleItems = items.map((item) => convertSchema(item, ctx));
14836
- const rest = schema.additionalItems && typeof schema.additionalItems === "object" ? convertSchema(schema.additionalItems, ctx) : void 0;
14837
- if (rest) {
14838
- zodSchema = z.tuple(tupleItems).rest(rest);
14839
- } else {
14840
- zodSchema = z.tuple(tupleItems);
14841
- }
14842
- if (typeof schema.minItems === "number") {
14843
- zodSchema = zodSchema.check(z.minLength(schema.minItems));
14844
- }
14845
- if (typeof schema.maxItems === "number") {
14846
- zodSchema = zodSchema.check(z.maxLength(schema.maxItems));
14847
- }
14848
- } else if (items !== void 0) {
14849
- const element = convertSchema(items, ctx);
14850
- let arraySchema = z.array(element);
14851
- if (typeof schema.minItems === "number") {
14852
- arraySchema = arraySchema.min(schema.minItems);
14853
- }
14854
- if (typeof schema.maxItems === "number") {
14855
- arraySchema = arraySchema.max(schema.maxItems);
14856
- }
14857
- zodSchema = arraySchema;
14858
- } else {
14859
- zodSchema = z.array(z.any());
14860
- }
14861
- break;
14751
+ if (value instanceof Error) {
14752
+ return { name: value.name, message: value.message, stack: value.stack };
14862
14753
  }
14863
- default:
14864
- throw new Error(`Unsupported type: ${type}`);
14865
- }
14866
- return zodSchema;
14867
- }
14868
- function convertSchema(schema, ctx) {
14869
- if (typeof schema === "boolean") {
14870
- return schema ? z.any() : z.never();
14871
- }
14872
- let baseSchema = convertBaseSchema(schema, ctx);
14873
- const hasExplicitType = schema.type || schema.enum !== void 0 || schema.const !== void 0;
14874
- if (schema.anyOf && Array.isArray(schema.anyOf)) {
14875
- const options = schema.anyOf.map((s) => convertSchema(s, ctx));
14876
- const anyOfUnion = z.union(options);
14877
- baseSchema = hasExplicitType ? z.intersection(baseSchema, anyOfUnion) : anyOfUnion;
14878
- }
14879
- if (schema.oneOf && Array.isArray(schema.oneOf)) {
14880
- const options = schema.oneOf.map((s) => convertSchema(s, ctx));
14881
- const oneOfUnion = z.xor(options);
14882
- baseSchema = hasExplicitType ? z.intersection(baseSchema, oneOfUnion) : oneOfUnion;
14883
- }
14884
- if (schema.allOf && Array.isArray(schema.allOf)) {
14885
- if (schema.allOf.length === 0) {
14886
- baseSchema = hasExplicitType ? baseSchema : z.any();
14887
- } else {
14888
- let result = hasExplicitType ? baseSchema : convertSchema(schema.allOf[0], ctx);
14889
- const startIdx = hasExplicitType ? 0 : 1;
14890
- for (let i = startIdx; i < schema.allOf.length; i++) {
14891
- result = z.intersection(result, convertSchema(schema.allOf[i], ctx));
14754
+ if (value instanceof WeakRef)
14755
+ return "[WeakRef]";
14756
+ if (value instanceof WeakMap)
14757
+ return "[WeakMap]";
14758
+ if (value instanceof WeakSet)
14759
+ return "[WeakSet]";
14760
+ if (value instanceof ArrayBuffer)
14761
+ return "[ArrayBuffer]";
14762
+ if (typeof SharedArrayBuffer !== "undefined" && value instanceof SharedArrayBuffer)
14763
+ return "[SharedArrayBuffer]";
14764
+ try {
14765
+ const seen = /* @__PURE__ */ new WeakSet();
14766
+ const json2 = JSON.stringify(value, (_key, v) => {
14767
+ if (typeof v === "object" && v !== null) {
14768
+ if (seen.has(v))
14769
+ return "[Circular]";
14770
+ seen.add(v);
14771
+ }
14772
+ if (typeof v === "function")
14773
+ return `[Function: ${v.name || "anonymous"}]`;
14774
+ if (typeof v === "bigint")
14775
+ return `[BigInt: ${v.toString()}]`;
14776
+ if (typeof v === "symbol")
14777
+ return `[Symbol: ${v.description ?? ""}]`;
14778
+ if (v instanceof WeakRef)
14779
+ return "[WeakRef]";
14780
+ if (v instanceof WeakMap)
14781
+ return "[WeakMap]";
14782
+ if (v instanceof WeakSet)
14783
+ return "[WeakSet]";
14784
+ if (v instanceof ArrayBuffer)
14785
+ return "[ArrayBuffer]";
14786
+ if (typeof SharedArrayBuffer !== "undefined" && v instanceof SharedArrayBuffer)
14787
+ return "[SharedArrayBuffer]";
14788
+ return v;
14789
+ });
14790
+ if (json2.length > MAX_SERIALIZED_SIZE) {
14791
+ return `[Object truncated: ${json2.length} chars]`;
14892
14792
  }
14893
- baseSchema = result;
14793
+ return JSON.parse(json2);
14794
+ } catch {
14795
+ return `[Unserializable: ${typeof value}]`;
14894
14796
  }
14797
+ } catch {
14798
+ return `[Unserializable: ${typeof value}]`;
14895
14799
  }
14896
- if (schema.nullable === true && ctx.version === "openapi-3.0") {
14897
- baseSchema = z.nullable(baseSchema);
14898
- }
14899
- if (schema.readOnly === true) {
14900
- baseSchema = z.readonly(baseSchema);
14901
- }
14902
- if (schema.default !== void 0) {
14903
- baseSchema = baseSchema.default(schema.default);
14904
- }
14905
- const extraMeta = {};
14906
- const coreMetadataKeys = ["$id", "id", "$comment", "$anchor", "$vocabulary", "$dynamicRef", "$dynamicAnchor"];
14907
- for (const key of coreMetadataKeys) {
14908
- if (key in schema) {
14909
- extraMeta[key] = schema[key];
14800
+ };
14801
+ var safeSerialize = (args) => {
14802
+ const capped = args.length > MAX_DATA_LENGTH ? args.slice(0, MAX_DATA_LENGTH) : args;
14803
+ return capped.map(safeSerializeArg);
14804
+ };
14805
+ var CONSOLE_METHODS = {
14806
+ debug: "debug",
14807
+ info: "info",
14808
+ warning: "warn",
14809
+ error: "error"
14810
+ };
14811
+ var defaultTransport = (entry) => {
14812
+ const method = CONSOLE_METHODS[entry.level];
14813
+ console[method](`[sdk.log] ${entry.message}`, ...entry.data);
14814
+ };
14815
+ var activeTransport = defaultTransport;
14816
+ var _setLogTransport = (transport) => {
14817
+ const previous = activeTransport;
14818
+ activeTransport = transport;
14819
+ return () => {
14820
+ if (activeTransport === transport)
14821
+ activeTransport = previous;
14822
+ };
14823
+ };
14824
+ var makeLogMethod = (level) => (message, ...args) => {
14825
+ const entry = {
14826
+ level,
14827
+ message,
14828
+ data: safeSerialize(args),
14829
+ ts: (/* @__PURE__ */ new Date()).toISOString()
14830
+ };
14831
+ activeTransport(entry);
14832
+ };
14833
+ var log = Object.freeze({
14834
+ debug: makeLogMethod("debug"),
14835
+ info: makeLogMethod("info"),
14836
+ warn: makeLogMethod("warning"),
14837
+ error: makeLogMethod("error")
14838
+ });
14839
+ var ot = globalThis.__openTabs ?? {};
14840
+ globalThis.__openTabs = ot;
14841
+ ot._setLogTransport = _setLogTransport;
14842
+ ot.log = log;
14843
+
14844
+ // node_modules/@opentabs-dev/plugin-sdk/dist/storage.js
14845
+ var withIframeFallback = (fn) => {
14846
+ try {
14847
+ const iframe = document.createElement("iframe");
14848
+ iframe.style.display = "none";
14849
+ document.body.appendChild(iframe);
14850
+ try {
14851
+ const iframeStorage = iframe.contentWindow?.localStorage;
14852
+ return iframeStorage ? fn(iframeStorage) : null;
14853
+ } finally {
14854
+ document.body.removeChild(iframe);
14910
14855
  }
14856
+ } catch {
14857
+ return null;
14911
14858
  }
14912
- const contentMetadataKeys = ["contentEncoding", "contentMediaType", "contentSchema"];
14913
- for (const key of contentMetadataKeys) {
14914
- if (key in schema) {
14915
- extraMeta[key] = schema[key];
14916
- }
14859
+ };
14860
+ var getWindowLocalStorage = () => window.localStorage;
14861
+ var getLocalStorage = (key) => {
14862
+ let storage;
14863
+ try {
14864
+ storage = getWindowLocalStorage();
14865
+ } catch {
14866
+ return null;
14917
14867
  }
14918
- for (const key of Object.keys(schema)) {
14919
- if (!RECOGNIZED_KEYS.has(key)) {
14920
- extraMeta[key] = schema[key];
14868
+ if (storage) {
14869
+ try {
14870
+ return storage.getItem(key);
14871
+ } catch {
14872
+ return null;
14921
14873
  }
14922
14874
  }
14923
- if (Object.keys(extraMeta).length > 0) {
14924
- ctx.registry.add(baseSchema, extraMeta);
14925
- }
14926
- if (schema.description) {
14927
- baseSchema = baseSchema.describe(schema.description);
14875
+ return withIframeFallback((s) => s.getItem(key));
14876
+ };
14877
+ var getAuthCache = (namespace) => {
14878
+ try {
14879
+ const ns = globalThis.__openTabs;
14880
+ const cache = ns?.tokenCache;
14881
+ return cache?.[namespace] ?? null;
14882
+ } catch {
14883
+ return null;
14928
14884
  }
14929
- return baseSchema;
14930
- }
14931
- function fromJSONSchema(schema, params) {
14932
- if (typeof schema === "boolean") {
14933
- return schema ? z.any() : z.never();
14885
+ };
14886
+ var setAuthCache = (namespace, value) => {
14887
+ try {
14888
+ const g = globalThis;
14889
+ if (!g.__openTabs)
14890
+ g.__openTabs = {};
14891
+ const ns = g.__openTabs;
14892
+ if (!ns.tokenCache)
14893
+ ns.tokenCache = {};
14894
+ ns.tokenCache[namespace] = value;
14895
+ } catch {
14934
14896
  }
14935
- let normalized;
14897
+ };
14898
+ var clearAuthCache = (namespace) => {
14936
14899
  try {
14937
- normalized = JSON.parse(JSON.stringify(schema));
14900
+ const ns = globalThis.__openTabs;
14901
+ const cache = ns?.tokenCache;
14902
+ if (cache)
14903
+ cache[namespace] = void 0;
14938
14904
  } catch {
14939
- throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas");
14940
14905
  }
14941
- const version2 = detectVersion(normalized, params?.defaultTarget);
14942
- const defs = normalized.$defs || normalized.definitions || {};
14943
- const ctx = {
14944
- version: version2,
14945
- defs,
14946
- refs: /* @__PURE__ */ new Map(),
14947
- processing: /* @__PURE__ */ new Set(),
14948
- rootSchema: normalized,
14949
- registry: params?.registry ?? globalRegistry
14950
- };
14951
- return convertSchema(normalized, ctx);
14952
- }
14906
+ };
14953
14907
 
14954
- // node_modules/zod/v4/classic/coerce.js
14955
- var coerce_exports = {};
14956
- __export(coerce_exports, {
14957
- bigint: () => bigint3,
14958
- boolean: () => boolean3,
14959
- date: () => date4,
14960
- number: () => number3,
14961
- string: () => string3
14962
- });
14963
- function string3(params) {
14964
- return _coercedString(ZodString, params);
14965
- }
14966
- function number3(params) {
14967
- return _coercedNumber(ZodNumber, params);
14968
- }
14969
- function boolean3(params) {
14970
- return _coercedBoolean(ZodBoolean, params);
14971
- }
14972
- function bigint3(params) {
14973
- return _coercedBigint(ZodBigInt, params);
14974
- }
14975
- function date4(params) {
14976
- return _coercedDate(ZodDate, params);
14977
- }
14908
+ // node_modules/@opentabs-dev/plugin-sdk/dist/index.js
14909
+ var defineTool = (config2) => config2;
14910
+ var OpenTabsPlugin = class {
14911
+ /**
14912
+ * Chrome match patterns for URLs that should NOT match this plugin.
14913
+ * Tabs matching both urlPatterns and excludePatterns are excluded.
14914
+ * Useful when a broad urlPattern overlaps with another plugin's domain.
14915
+ * @see https://developer.chrome.com/docs/extensions/develop/concepts/match-patterns
14916
+ */
14917
+ excludePatterns;
14918
+ /**
14919
+ * URL to open when no matching tab exists and the user triggers an
14920
+ * 'open tab' action from the side panel. Should be a concrete URL
14921
+ * (e.g., 'https://github.com'), not a match pattern.
14922
+ */
14923
+ homepage;
14924
+ /** Typed configuration schema — declares settings that users provide via config.json or the side panel. */
14925
+ configSchema;
14926
+ };
14978
14927
 
14979
- // node_modules/zod/v4/classic/external.js
14980
- config(en_default());
14928
+ // src/hack2hire-api.ts
14929
+ var API_BASE = "https://api.hack2hire.com/algro/v1";
14930
+ var readJsonString = (key) => {
14931
+ const raw = getLocalStorage(key);
14932
+ if (!raw) return null;
14933
+ try {
14934
+ const parsed = JSON.parse(raw);
14935
+ return typeof parsed === "string" && parsed.length > 0 ? parsed : null;
14936
+ } catch {
14937
+ return null;
14938
+ }
14939
+ };
14940
+ var getAuth = () => {
14941
+ const cached2 = getAuthCache("hack2hire");
14942
+ if (cached2?.token && cached2?.userId) return cached2;
14943
+ const token = readJsonString("ALGRO_TOKEN");
14944
+ const userId = readJsonString("USER_ID");
14945
+ if (!token || !userId) return null;
14946
+ const auth = { token, userId };
14947
+ setAuthCache("hack2hire", auth);
14948
+ return auth;
14949
+ };
14950
+ var isAuthenticated = () => getAuth() !== null;
14951
+ var waitForAuth = () => waitUntil(() => isAuthenticated(), { interval: 500, timeout: 5e3 }).then(
14952
+ () => true,
14953
+ () => false
14954
+ );
14955
+ var api = async (endpoint, query) => {
14956
+ const auth = getAuth();
14957
+ if (!auth) throw ToolError.auth("Not authenticated \u2014 please log in to Hack2Hire.");
14958
+ const qs = query ? buildQueryString(query) : "";
14959
+ const url2 = qs ? `${API_BASE}${endpoint}?${qs}` : `${API_BASE}${endpoint}`;
14960
+ let response;
14961
+ try {
14962
+ response = await fetchFromPage(url2, {
14963
+ method: "GET",
14964
+ headers: {
14965
+ Authorization: `Bearer ${auth.token}`,
14966
+ "x-user-id": auth.userId,
14967
+ Accept: "application/json"
14968
+ },
14969
+ credentials: "omit"
14970
+ });
14971
+ } catch (err2) {
14972
+ if (err2 instanceof ToolError) {
14973
+ if (err2.category === "auth") clearAuthCache("hack2hire");
14974
+ throw err2;
14975
+ }
14976
+ throw ToolError.internal(`Network error: ${err2 instanceof Error ? err2.message : String(err2)}`);
14977
+ }
14978
+ const envelope = await response.json();
14979
+ return envelope.data;
14980
+ };
14981
14981
 
14982
14982
  // src/tools/get-completed-question-count.ts
14983
14983
  var getCompletedQuestionCount = defineTool({
@@ -15642,7 +15642,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15642
15642
  };
15643
15643
  var src_default = new Hack2HirePlugin();
15644
15644
 
15645
- // dist/_adapter_entry_18289137-327a-4604-bd70-733b1f86a202.ts
15645
+ // dist/_adapter_entry_e151ae7e-aae4-433e-848f-0c258f7a3ea7.ts
15646
+ external_exports.config({ jitless: true });
15646
15647
  if (!globalThis.__openTabs) {
15647
15648
  globalThis.__openTabs = {};
15648
15649
  } else {
@@ -15860,5 +15861,5 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15860
15861
  };
15861
15862
  delete src_default.onDeactivate;
15862
15863
  }
15863
- })();(function(){var o=(globalThis).__openTabs;if(o&&o.adapters&&o.adapters["hack2hire"]){var a=o.adapters["hack2hire"];a.__adapterHash="2840aa78cf5fae8f2d475b0ed8d9d6a03e0fee6b59e9726d75b9f28623222eb3";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,"hack2hire",{value:a,writable:false,configurable:false,enumerable:true});Object.defineProperty(o,"adapters",{value:o.adapters,writable:false,configurable:false});}})();
15864
+ })();(function(){var o=(globalThis).__openTabs;if(o&&o.adapters&&o.adapters["hack2hire"]){var a=o.adapters["hack2hire"];a.__adapterHash="8bbf9de6b715710a4dcc9208636595e4ed34f390f61f05e1966e46eec37f9fae";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,"hack2hire",{value:a,writable:false,configurable:false,enumerable:true});Object.defineProperty(o,"adapters",{value:o.adapters,writable:false,configurable:false});}})();
15864
15865
  //# sourceMappingURL=adapter.iife.js.map