@pi-oxide/extension-js 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/worker.js CHANGED
@@ -1,12 +1,3449 @@
1
- import x, { setLogLevel as L, ExtensionSession as ee, registerJsCallBatch as re } from "./extension_js.js";
2
- const I = {
1
+ import Pt, { setLogLevel as Fe, ExtensionSession as Zt, registerJsCallBatch as Dt } from "./extension_js.js";
2
+ var S;
3
+ (function(t) {
4
+ t.assertEqual = (n) => {
5
+ };
6
+ function e(n) {
7
+ }
8
+ t.assertIs = e;
9
+ function r(n) {
10
+ throw new Error();
11
+ }
12
+ t.assertNever = r, t.arrayToEnum = (n) => {
13
+ const i = {};
14
+ for (const o of n)
15
+ i[o] = o;
16
+ return i;
17
+ }, t.getValidEnumValues = (n) => {
18
+ const i = t.objectKeys(n).filter((a) => typeof n[n[a]] != "number"), o = {};
19
+ for (const a of i)
20
+ o[a] = n[a];
21
+ return t.objectValues(o);
22
+ }, t.objectValues = (n) => t.objectKeys(n).map(function(i) {
23
+ return n[i];
24
+ }), t.objectKeys = typeof Object.keys == "function" ? (n) => Object.keys(n) : (n) => {
25
+ const i = [];
26
+ for (const o in n)
27
+ Object.prototype.hasOwnProperty.call(n, o) && i.push(o);
28
+ return i;
29
+ }, t.find = (n, i) => {
30
+ for (const o of n)
31
+ if (i(o))
32
+ return o;
33
+ }, t.isInteger = typeof Number.isInteger == "function" ? (n) => Number.isInteger(n) : (n) => typeof n == "number" && Number.isFinite(n) && Math.floor(n) === n;
34
+ function s(n, i = " | ") {
35
+ return n.map((o) => typeof o == "string" ? `'${o}'` : o).join(i);
36
+ }
37
+ t.joinValues = s, t.jsonStringifyReplacer = (n, i) => typeof i == "bigint" ? i.toString() : i;
38
+ })(S || (S = {}));
39
+ var ht;
40
+ (function(t) {
41
+ t.mergeShapes = (e, r) => ({
42
+ ...e,
43
+ ...r
44
+ // second overwrites first
45
+ });
46
+ })(ht || (ht = {}));
47
+ const m = S.arrayToEnum([
48
+ "string",
49
+ "nan",
50
+ "number",
51
+ "integer",
52
+ "float",
53
+ "boolean",
54
+ "date",
55
+ "bigint",
56
+ "symbol",
57
+ "function",
58
+ "undefined",
59
+ "null",
60
+ "array",
61
+ "object",
62
+ "unknown",
63
+ "promise",
64
+ "void",
65
+ "never",
66
+ "map",
67
+ "set"
68
+ ]), K = (t) => {
69
+ switch (typeof t) {
70
+ case "undefined":
71
+ return m.undefined;
72
+ case "string":
73
+ return m.string;
74
+ case "number":
75
+ return Number.isNaN(t) ? m.nan : m.number;
76
+ case "boolean":
77
+ return m.boolean;
78
+ case "function":
79
+ return m.function;
80
+ case "bigint":
81
+ return m.bigint;
82
+ case "symbol":
83
+ return m.symbol;
84
+ case "object":
85
+ return Array.isArray(t) ? m.array : t === null ? m.null : t.then && typeof t.then == "function" && t.catch && typeof t.catch == "function" ? m.promise : typeof Map < "u" && t instanceof Map ? m.map : typeof Set < "u" && t instanceof Set ? m.set : typeof Date < "u" && t instanceof Date ? m.date : m.object;
86
+ default:
87
+ return m.unknown;
88
+ }
89
+ }, u = S.arrayToEnum([
90
+ "invalid_type",
91
+ "invalid_literal",
92
+ "custom",
93
+ "invalid_union",
94
+ "invalid_union_discriminator",
95
+ "invalid_enum_value",
96
+ "unrecognized_keys",
97
+ "invalid_arguments",
98
+ "invalid_return_type",
99
+ "invalid_date",
100
+ "invalid_string",
101
+ "too_small",
102
+ "too_big",
103
+ "invalid_intersection_types",
104
+ "not_multiple_of",
105
+ "not_finite"
106
+ ]);
107
+ class j extends Error {
108
+ get errors() {
109
+ return this.issues;
110
+ }
111
+ constructor(e) {
112
+ super(), this.issues = [], this.addIssue = (s) => {
113
+ this.issues = [...this.issues, s];
114
+ }, this.addIssues = (s = []) => {
115
+ this.issues = [...this.issues, ...s];
116
+ };
117
+ const r = new.target.prototype;
118
+ Object.setPrototypeOf ? Object.setPrototypeOf(this, r) : this.__proto__ = r, this.name = "ZodError", this.issues = e;
119
+ }
120
+ format(e) {
121
+ const r = e || function(i) {
122
+ return i.message;
123
+ }, s = { _errors: [] }, n = (i) => {
124
+ for (const o of i.issues)
125
+ if (o.code === "invalid_union")
126
+ o.unionErrors.map(n);
127
+ else if (o.code === "invalid_return_type")
128
+ n(o.returnTypeError);
129
+ else if (o.code === "invalid_arguments")
130
+ n(o.argumentsError);
131
+ else if (o.path.length === 0)
132
+ s._errors.push(r(o));
133
+ else {
134
+ let a = s, h = 0;
135
+ for (; h < o.path.length; ) {
136
+ const l = o.path[h];
137
+ h === o.path.length - 1 ? (a[l] = a[l] || { _errors: [] }, a[l]._errors.push(r(o))) : a[l] = a[l] || { _errors: [] }, a = a[l], h++;
138
+ }
139
+ }
140
+ };
141
+ return n(this), s;
142
+ }
143
+ static assert(e) {
144
+ if (!(e instanceof j))
145
+ throw new Error(`Not a ZodError: ${e}`);
146
+ }
147
+ toString() {
148
+ return this.message;
149
+ }
150
+ get message() {
151
+ return JSON.stringify(this.issues, S.jsonStringifyReplacer, 2);
152
+ }
153
+ get isEmpty() {
154
+ return this.issues.length === 0;
155
+ }
156
+ flatten(e = (r) => r.message) {
157
+ const r = {}, s = [];
158
+ for (const n of this.issues)
159
+ if (n.path.length > 0) {
160
+ const i = n.path[0];
161
+ r[i] = r[i] || [], r[i].push(e(n));
162
+ } else
163
+ s.push(e(n));
164
+ return { formErrors: s, fieldErrors: r };
165
+ }
166
+ get formErrors() {
167
+ return this.flatten();
168
+ }
169
+ }
170
+ j.create = (t) => new j(t);
171
+ const ke = (t, e) => {
172
+ let r;
173
+ switch (t.code) {
174
+ case u.invalid_type:
175
+ t.received === m.undefined ? r = "Required" : r = `Expected ${t.expected}, received ${t.received}`;
176
+ break;
177
+ case u.invalid_literal:
178
+ r = `Invalid literal value, expected ${JSON.stringify(t.expected, S.jsonStringifyReplacer)}`;
179
+ break;
180
+ case u.unrecognized_keys:
181
+ r = `Unrecognized key(s) in object: ${S.joinValues(t.keys, ", ")}`;
182
+ break;
183
+ case u.invalid_union:
184
+ r = "Invalid input";
185
+ break;
186
+ case u.invalid_union_discriminator:
187
+ r = `Invalid discriminator value. Expected ${S.joinValues(t.options)}`;
188
+ break;
189
+ case u.invalid_enum_value:
190
+ r = `Invalid enum value. Expected ${S.joinValues(t.options)}, received '${t.received}'`;
191
+ break;
192
+ case u.invalid_arguments:
193
+ r = "Invalid function arguments";
194
+ break;
195
+ case u.invalid_return_type:
196
+ r = "Invalid function return type";
197
+ break;
198
+ case u.invalid_date:
199
+ r = "Invalid date";
200
+ break;
201
+ case u.invalid_string:
202
+ typeof t.validation == "object" ? "includes" in t.validation ? (r = `Invalid input: must include "${t.validation.includes}"`, typeof t.validation.position == "number" && (r = `${r} at one or more positions greater than or equal to ${t.validation.position}`)) : "startsWith" in t.validation ? r = `Invalid input: must start with "${t.validation.startsWith}"` : "endsWith" in t.validation ? r = `Invalid input: must end with "${t.validation.endsWith}"` : S.assertNever(t.validation) : t.validation !== "regex" ? r = `Invalid ${t.validation}` : r = "Invalid";
203
+ break;
204
+ case u.too_small:
205
+ t.type === "array" ? r = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "more than"} ${t.minimum} element(s)` : t.type === "string" ? r = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "over"} ${t.minimum} character(s)` : t.type === "number" ? r = `Number must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${t.minimum}` : t.type === "bigint" ? r = `Number must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${t.minimum}` : t.type === "date" ? r = `Date must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(t.minimum))}` : r = "Invalid input";
206
+ break;
207
+ case u.too_big:
208
+ t.type === "array" ? r = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "less than"} ${t.maximum} element(s)` : t.type === "string" ? r = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "under"} ${t.maximum} character(s)` : t.type === "number" ? r = `Number must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "bigint" ? r = `BigInt must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "date" ? r = `Date must be ${t.exact ? "exactly" : t.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(t.maximum))}` : r = "Invalid input";
209
+ break;
210
+ case u.custom:
211
+ r = "Invalid input";
212
+ break;
213
+ case u.invalid_intersection_types:
214
+ r = "Intersection results could not be merged";
215
+ break;
216
+ case u.not_multiple_of:
217
+ r = `Number must be a multiple of ${t.multipleOf}`;
218
+ break;
219
+ case u.not_finite:
220
+ r = "Number must be finite";
221
+ break;
222
+ default:
223
+ r = e.defaultError, S.assertNever(t);
224
+ }
225
+ return { message: r };
226
+ };
227
+ let Wt = ke;
228
+ function ze() {
229
+ return Wt;
230
+ }
231
+ const Be = (t) => {
232
+ const { data: e, path: r, errorMaps: s, issueData: n } = t, i = [...r, ...n.path || []], o = {
233
+ ...n,
234
+ path: i
235
+ };
236
+ if (n.message !== void 0)
237
+ return {
238
+ ...n,
239
+ path: i,
240
+ message: n.message
241
+ };
242
+ let a = "";
243
+ const h = s.filter((l) => !!l).slice().reverse();
244
+ for (const l of h)
245
+ a = l(o, { data: e, defaultError: a }).message;
246
+ return {
247
+ ...n,
248
+ path: i,
249
+ message: a
250
+ };
251
+ };
252
+ function p(t, e) {
253
+ const r = ze(), s = Be({
254
+ issueData: e,
255
+ data: t.data,
256
+ path: t.path,
257
+ errorMaps: [
258
+ t.common.contextualErrorMap,
259
+ // contextual error map is first priority
260
+ t.schemaErrorMap,
261
+ // then schema-bound map if available
262
+ r,
263
+ // then global override map
264
+ r === ke ? void 0 : ke
265
+ // then global default map
266
+ ].filter((n) => !!n)
267
+ });
268
+ t.common.issues.push(s);
269
+ }
270
+ class $ {
271
+ constructor() {
272
+ this.value = "valid";
273
+ }
274
+ dirty() {
275
+ this.value === "valid" && (this.value = "dirty");
276
+ }
277
+ abort() {
278
+ this.value !== "aborted" && (this.value = "aborted");
279
+ }
280
+ static mergeArray(e, r) {
281
+ const s = [];
282
+ for (const n of r) {
283
+ if (n.status === "aborted")
284
+ return v;
285
+ n.status === "dirty" && e.dirty(), s.push(n.value);
286
+ }
287
+ return { status: e.value, value: s };
288
+ }
289
+ static async mergeObjectAsync(e, r) {
290
+ const s = [];
291
+ for (const n of r) {
292
+ const i = await n.key, o = await n.value;
293
+ s.push({
294
+ key: i,
295
+ value: o
296
+ });
297
+ }
298
+ return $.mergeObjectSync(e, s);
299
+ }
300
+ static mergeObjectSync(e, r) {
301
+ const s = {};
302
+ for (const n of r) {
303
+ const { key: i, value: o } = n;
304
+ if (i.status === "aborted" || o.status === "aborted")
305
+ return v;
306
+ i.status === "dirty" && e.dirty(), o.status === "dirty" && e.dirty(), i.value !== "__proto__" && (typeof o.value < "u" || n.alwaysSet) && (s[i.value] = o.value);
307
+ }
308
+ return { status: e.value, value: s };
309
+ }
310
+ }
311
+ const v = Object.freeze({
312
+ status: "aborted"
313
+ }), be = (t) => ({ status: "dirty", value: t }), L = (t) => ({ status: "valid", value: t }), pt = (t) => t.status === "aborted", mt = (t) => t.status === "dirty", fe = (t) => t.status === "valid", $e = (t) => typeof Promise < "u" && t instanceof Promise;
314
+ var g;
315
+ (function(t) {
316
+ t.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, t.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
317
+ })(g || (g = {}));
318
+ class F {
319
+ constructor(e, r, s, n) {
320
+ this._cachedPath = [], this.parent = e, this.data = r, this._path = s, this._key = n;
321
+ }
322
+ get path() {
323
+ return this._cachedPath.length || (Array.isArray(this._key) ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
324
+ }
325
+ }
326
+ const gt = (t, e) => {
327
+ if (fe(e))
328
+ return { success: !0, data: e.value };
329
+ if (!t.common.issues.length)
330
+ throw new Error("Validation failed but no issues detected.");
331
+ return {
332
+ success: !1,
333
+ get error() {
334
+ if (this._error)
335
+ return this._error;
336
+ const r = new j(t.common.issues);
337
+ return this._error = r, this._error;
338
+ }
339
+ };
340
+ };
341
+ function w(t) {
342
+ if (!t)
343
+ return {};
344
+ const { errorMap: e, invalid_type_error: r, required_error: s, description: n } = t;
345
+ if (e && (r || s))
346
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
347
+ return e ? { errorMap: e, description: n } : { errorMap: (o, a) => {
348
+ const { message: h } = t;
349
+ return o.code === "invalid_enum_value" ? { message: h ?? a.defaultError } : typeof a.data > "u" ? { message: h ?? s ?? a.defaultError } : o.code !== "invalid_type" ? { message: a.defaultError } : { message: h ?? r ?? a.defaultError };
350
+ }, description: n };
351
+ }
352
+ class I {
353
+ get description() {
354
+ return this._def.description;
355
+ }
356
+ _getType(e) {
357
+ return K(e.data);
358
+ }
359
+ _getOrReturnCtx(e, r) {
360
+ return r || {
361
+ common: e.parent.common,
362
+ data: e.data,
363
+ parsedType: K(e.data),
364
+ schemaErrorMap: this._def.errorMap,
365
+ path: e.path,
366
+ parent: e.parent
367
+ };
368
+ }
369
+ _processInputParams(e) {
370
+ return {
371
+ status: new $(),
372
+ ctx: {
373
+ common: e.parent.common,
374
+ data: e.data,
375
+ parsedType: K(e.data),
376
+ schemaErrorMap: this._def.errorMap,
377
+ path: e.path,
378
+ parent: e.parent
379
+ }
380
+ };
381
+ }
382
+ _parseSync(e) {
383
+ const r = this._parse(e);
384
+ if ($e(r))
385
+ throw new Error("Synchronous parse encountered promise.");
386
+ return r;
387
+ }
388
+ _parseAsync(e) {
389
+ const r = this._parse(e);
390
+ return Promise.resolve(r);
391
+ }
392
+ parse(e, r) {
393
+ const s = this.safeParse(e, r);
394
+ if (s.success)
395
+ return s.data;
396
+ throw s.error;
397
+ }
398
+ safeParse(e, r) {
399
+ const s = {
400
+ common: {
401
+ issues: [],
402
+ async: (r == null ? void 0 : r.async) ?? !1,
403
+ contextualErrorMap: r == null ? void 0 : r.errorMap
404
+ },
405
+ path: (r == null ? void 0 : r.path) || [],
406
+ schemaErrorMap: this._def.errorMap,
407
+ parent: null,
408
+ data: e,
409
+ parsedType: K(e)
410
+ }, n = this._parseSync({ data: e, path: s.path, parent: s });
411
+ return gt(s, n);
412
+ }
413
+ "~validate"(e) {
414
+ var s, n;
415
+ const r = {
416
+ common: {
417
+ issues: [],
418
+ async: !!this["~standard"].async
419
+ },
420
+ path: [],
421
+ schemaErrorMap: this._def.errorMap,
422
+ parent: null,
423
+ data: e,
424
+ parsedType: K(e)
425
+ };
426
+ if (!this["~standard"].async)
427
+ try {
428
+ const i = this._parseSync({ data: e, path: [], parent: r });
429
+ return fe(i) ? {
430
+ value: i.value
431
+ } : {
432
+ issues: r.common.issues
433
+ };
434
+ } catch (i) {
435
+ (n = (s = i == null ? void 0 : i.message) == null ? void 0 : s.toLowerCase()) != null && n.includes("encountered") && (this["~standard"].async = !0), r.common = {
436
+ issues: [],
437
+ async: !0
438
+ };
439
+ }
440
+ return this._parseAsync({ data: e, path: [], parent: r }).then((i) => fe(i) ? {
441
+ value: i.value
442
+ } : {
443
+ issues: r.common.issues
444
+ });
445
+ }
446
+ async parseAsync(e, r) {
447
+ const s = await this.safeParseAsync(e, r);
448
+ if (s.success)
449
+ return s.data;
450
+ throw s.error;
451
+ }
452
+ async safeParseAsync(e, r) {
453
+ const s = {
454
+ common: {
455
+ issues: [],
456
+ contextualErrorMap: r == null ? void 0 : r.errorMap,
457
+ async: !0
458
+ },
459
+ path: (r == null ? void 0 : r.path) || [],
460
+ schemaErrorMap: this._def.errorMap,
461
+ parent: null,
462
+ data: e,
463
+ parsedType: K(e)
464
+ }, n = this._parse({ data: e, path: s.path, parent: s }), i = await ($e(n) ? n : Promise.resolve(n));
465
+ return gt(s, i);
466
+ }
467
+ refine(e, r) {
468
+ const s = (n) => typeof r == "string" || typeof r > "u" ? { message: r } : typeof r == "function" ? r(n) : r;
469
+ return this._refinement((n, i) => {
470
+ const o = e(n), a = () => i.addIssue({
471
+ code: u.custom,
472
+ ...s(n)
473
+ });
474
+ return typeof Promise < "u" && o instanceof Promise ? o.then((h) => h ? !0 : (a(), !1)) : o ? !0 : (a(), !1);
475
+ });
476
+ }
477
+ refinement(e, r) {
478
+ return this._refinement((s, n) => e(s) ? !0 : (n.addIssue(typeof r == "function" ? r(s, n) : r), !1));
479
+ }
480
+ _refinement(e) {
481
+ return new G({
482
+ schema: this,
483
+ typeName: k.ZodEffects,
484
+ effect: { type: "refinement", refinement: e }
485
+ });
486
+ }
487
+ superRefine(e) {
488
+ return this._refinement(e);
489
+ }
490
+ constructor(e) {
491
+ this.spa = this.safeParseAsync, this._def = e, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this), this["~standard"] = {
492
+ version: 1,
493
+ vendor: "zod",
494
+ validate: (r) => this["~validate"](r)
495
+ };
496
+ }
497
+ optional() {
498
+ return W.create(this, this._def);
499
+ }
500
+ nullable() {
501
+ return ee.create(this, this._def);
502
+ }
503
+ nullish() {
504
+ return this.nullable().optional();
505
+ }
506
+ array() {
507
+ return D.create(this);
508
+ }
509
+ promise() {
510
+ return pe.create(this, this._def);
511
+ }
512
+ or(e) {
513
+ return Te.create([this, e], this._def);
514
+ }
515
+ and(e) {
516
+ return Ie.create(this, e, this._def);
517
+ }
518
+ transform(e) {
519
+ return new G({
520
+ ...w(this._def),
521
+ schema: this,
522
+ typeName: k.ZodEffects,
523
+ effect: { type: "transform", transform: e }
524
+ });
525
+ }
526
+ default(e) {
527
+ const r = typeof e == "function" ? e : () => e;
528
+ return new Ae({
529
+ ...w(this._def),
530
+ innerType: this,
531
+ defaultValue: r,
532
+ typeName: k.ZodDefault
533
+ });
534
+ }
535
+ brand() {
536
+ return new nt({
537
+ typeName: k.ZodBranded,
538
+ type: this,
539
+ ...w(this._def)
540
+ });
541
+ }
542
+ catch(e) {
543
+ const r = typeof e == "function" ? e : () => e;
544
+ return new Re({
545
+ ...w(this._def),
546
+ innerType: this,
547
+ catchValue: r,
548
+ typeName: k.ZodCatch
549
+ });
550
+ }
551
+ describe(e) {
552
+ const r = this.constructor;
553
+ return new r({
554
+ ...this._def,
555
+ description: e
556
+ });
557
+ }
558
+ pipe(e) {
559
+ return We.create(this, e);
560
+ }
561
+ readonly() {
562
+ return Ce.create(this);
563
+ }
564
+ isOptional() {
565
+ return this.safeParse(void 0).success;
566
+ }
567
+ isNullable() {
568
+ return this.safeParse(null).success;
569
+ }
570
+ }
571
+ const Vt = /^c[^\s-]{8,}$/i, Ut = /^[0-9a-z]+$/, Ft = /^[0-9A-HJKMNP-TV-Z]{26}$/i, zt = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, Bt = /^[a-z0-9_-]{21}$/i, qt = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, Ht = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, Gt = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, Jt = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
572
+ let Ue;
573
+ const Yt = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, Kt = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, Xt = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, Qt = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, er = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, tr = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, xt = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", rr = new RegExp(`^${xt}$`);
574
+ function Tt(t) {
575
+ let e = "[0-5]\\d";
576
+ t.precision ? e = `${e}\\.\\d{${t.precision}}` : t.precision == null && (e = `${e}(\\.\\d+)?`);
577
+ const r = t.precision ? "+" : "?";
578
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`;
579
+ }
580
+ function sr(t) {
581
+ return new RegExp(`^${Tt(t)}$`);
582
+ }
583
+ function nr(t) {
584
+ let e = `${xt}T${Tt(t)}`;
585
+ const r = [];
586
+ return r.push(t.local ? "Z?" : "Z"), t.offset && r.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${r.join("|")})`, new RegExp(`^${e}$`);
587
+ }
588
+ function ir(t, e) {
589
+ return !!((e === "v4" || !e) && Yt.test(t) || (e === "v6" || !e) && Xt.test(t));
590
+ }
591
+ function ar(t, e) {
592
+ if (!qt.test(t))
593
+ return !1;
594
+ try {
595
+ const [r] = t.split(".");
596
+ if (!r)
597
+ return !1;
598
+ const s = r.replace(/-/g, "+").replace(/_/g, "/").padEnd(r.length + (4 - r.length % 4) % 4, "="), n = JSON.parse(atob(s));
599
+ return !(typeof n != "object" || n === null || "typ" in n && (n == null ? void 0 : n.typ) !== "JWT" || !n.alg || e && n.alg !== e);
600
+ } catch {
601
+ return !1;
602
+ }
603
+ }
604
+ function or(t, e) {
605
+ return !!((e === "v4" || !e) && Kt.test(t) || (e === "v6" || !e) && Qt.test(t));
606
+ }
607
+ class U extends I {
608
+ _parse(e) {
609
+ if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== m.string) {
610
+ const i = this._getOrReturnCtx(e);
611
+ return p(i, {
612
+ code: u.invalid_type,
613
+ expected: m.string,
614
+ received: i.parsedType
615
+ }), v;
616
+ }
617
+ const s = new $();
618
+ let n;
619
+ for (const i of this._def.checks)
620
+ if (i.kind === "min")
621
+ e.data.length < i.value && (n = this._getOrReturnCtx(e, n), p(n, {
622
+ code: u.too_small,
623
+ minimum: i.value,
624
+ type: "string",
625
+ inclusive: !0,
626
+ exact: !1,
627
+ message: i.message
628
+ }), s.dirty());
629
+ else if (i.kind === "max")
630
+ e.data.length > i.value && (n = this._getOrReturnCtx(e, n), p(n, {
631
+ code: u.too_big,
632
+ maximum: i.value,
633
+ type: "string",
634
+ inclusive: !0,
635
+ exact: !1,
636
+ message: i.message
637
+ }), s.dirty());
638
+ else if (i.kind === "length") {
639
+ const o = e.data.length > i.value, a = e.data.length < i.value;
640
+ (o || a) && (n = this._getOrReturnCtx(e, n), o ? p(n, {
641
+ code: u.too_big,
642
+ maximum: i.value,
643
+ type: "string",
644
+ inclusive: !0,
645
+ exact: !0,
646
+ message: i.message
647
+ }) : a && p(n, {
648
+ code: u.too_small,
649
+ minimum: i.value,
650
+ type: "string",
651
+ inclusive: !0,
652
+ exact: !0,
653
+ message: i.message
654
+ }), s.dirty());
655
+ } else if (i.kind === "email")
656
+ Gt.test(e.data) || (n = this._getOrReturnCtx(e, n), p(n, {
657
+ validation: "email",
658
+ code: u.invalid_string,
659
+ message: i.message
660
+ }), s.dirty());
661
+ else if (i.kind === "emoji")
662
+ Ue || (Ue = new RegExp(Jt, "u")), Ue.test(e.data) || (n = this._getOrReturnCtx(e, n), p(n, {
663
+ validation: "emoji",
664
+ code: u.invalid_string,
665
+ message: i.message
666
+ }), s.dirty());
667
+ else if (i.kind === "uuid")
668
+ zt.test(e.data) || (n = this._getOrReturnCtx(e, n), p(n, {
669
+ validation: "uuid",
670
+ code: u.invalid_string,
671
+ message: i.message
672
+ }), s.dirty());
673
+ else if (i.kind === "nanoid")
674
+ Bt.test(e.data) || (n = this._getOrReturnCtx(e, n), p(n, {
675
+ validation: "nanoid",
676
+ code: u.invalid_string,
677
+ message: i.message
678
+ }), s.dirty());
679
+ else if (i.kind === "cuid")
680
+ Vt.test(e.data) || (n = this._getOrReturnCtx(e, n), p(n, {
681
+ validation: "cuid",
682
+ code: u.invalid_string,
683
+ message: i.message
684
+ }), s.dirty());
685
+ else if (i.kind === "cuid2")
686
+ Ut.test(e.data) || (n = this._getOrReturnCtx(e, n), p(n, {
687
+ validation: "cuid2",
688
+ code: u.invalid_string,
689
+ message: i.message
690
+ }), s.dirty());
691
+ else if (i.kind === "ulid")
692
+ Ft.test(e.data) || (n = this._getOrReturnCtx(e, n), p(n, {
693
+ validation: "ulid",
694
+ code: u.invalid_string,
695
+ message: i.message
696
+ }), s.dirty());
697
+ else if (i.kind === "url")
698
+ try {
699
+ new URL(e.data);
700
+ } catch {
701
+ n = this._getOrReturnCtx(e, n), p(n, {
702
+ validation: "url",
703
+ code: u.invalid_string,
704
+ message: i.message
705
+ }), s.dirty();
706
+ }
707
+ else i.kind === "regex" ? (i.regex.lastIndex = 0, i.regex.test(e.data) || (n = this._getOrReturnCtx(e, n), p(n, {
708
+ validation: "regex",
709
+ code: u.invalid_string,
710
+ message: i.message
711
+ }), s.dirty())) : i.kind === "trim" ? e.data = e.data.trim() : i.kind === "includes" ? e.data.includes(i.value, i.position) || (n = this._getOrReturnCtx(e, n), p(n, {
712
+ code: u.invalid_string,
713
+ validation: { includes: i.value, position: i.position },
714
+ message: i.message
715
+ }), s.dirty()) : i.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : i.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : i.kind === "startsWith" ? e.data.startsWith(i.value) || (n = this._getOrReturnCtx(e, n), p(n, {
716
+ code: u.invalid_string,
717
+ validation: { startsWith: i.value },
718
+ message: i.message
719
+ }), s.dirty()) : i.kind === "endsWith" ? e.data.endsWith(i.value) || (n = this._getOrReturnCtx(e, n), p(n, {
720
+ code: u.invalid_string,
721
+ validation: { endsWith: i.value },
722
+ message: i.message
723
+ }), s.dirty()) : i.kind === "datetime" ? nr(i).test(e.data) || (n = this._getOrReturnCtx(e, n), p(n, {
724
+ code: u.invalid_string,
725
+ validation: "datetime",
726
+ message: i.message
727
+ }), s.dirty()) : i.kind === "date" ? rr.test(e.data) || (n = this._getOrReturnCtx(e, n), p(n, {
728
+ code: u.invalid_string,
729
+ validation: "date",
730
+ message: i.message
731
+ }), s.dirty()) : i.kind === "time" ? sr(i).test(e.data) || (n = this._getOrReturnCtx(e, n), p(n, {
732
+ code: u.invalid_string,
733
+ validation: "time",
734
+ message: i.message
735
+ }), s.dirty()) : i.kind === "duration" ? Ht.test(e.data) || (n = this._getOrReturnCtx(e, n), p(n, {
736
+ validation: "duration",
737
+ code: u.invalid_string,
738
+ message: i.message
739
+ }), s.dirty()) : i.kind === "ip" ? ir(e.data, i.version) || (n = this._getOrReturnCtx(e, n), p(n, {
740
+ validation: "ip",
741
+ code: u.invalid_string,
742
+ message: i.message
743
+ }), s.dirty()) : i.kind === "jwt" ? ar(e.data, i.alg) || (n = this._getOrReturnCtx(e, n), p(n, {
744
+ validation: "jwt",
745
+ code: u.invalid_string,
746
+ message: i.message
747
+ }), s.dirty()) : i.kind === "cidr" ? or(e.data, i.version) || (n = this._getOrReturnCtx(e, n), p(n, {
748
+ validation: "cidr",
749
+ code: u.invalid_string,
750
+ message: i.message
751
+ }), s.dirty()) : i.kind === "base64" ? er.test(e.data) || (n = this._getOrReturnCtx(e, n), p(n, {
752
+ validation: "base64",
753
+ code: u.invalid_string,
754
+ message: i.message
755
+ }), s.dirty()) : i.kind === "base64url" ? tr.test(e.data) || (n = this._getOrReturnCtx(e, n), p(n, {
756
+ validation: "base64url",
757
+ code: u.invalid_string,
758
+ message: i.message
759
+ }), s.dirty()) : S.assertNever(i);
760
+ return { status: s.value, value: e.data };
761
+ }
762
+ _regex(e, r, s) {
763
+ return this.refinement((n) => e.test(n), {
764
+ validation: r,
765
+ code: u.invalid_string,
766
+ ...g.errToObj(s)
767
+ });
768
+ }
769
+ _addCheck(e) {
770
+ return new U({
771
+ ...this._def,
772
+ checks: [...this._def.checks, e]
773
+ });
774
+ }
775
+ email(e) {
776
+ return this._addCheck({ kind: "email", ...g.errToObj(e) });
777
+ }
778
+ url(e) {
779
+ return this._addCheck({ kind: "url", ...g.errToObj(e) });
780
+ }
781
+ emoji(e) {
782
+ return this._addCheck({ kind: "emoji", ...g.errToObj(e) });
783
+ }
784
+ uuid(e) {
785
+ return this._addCheck({ kind: "uuid", ...g.errToObj(e) });
786
+ }
787
+ nanoid(e) {
788
+ return this._addCheck({ kind: "nanoid", ...g.errToObj(e) });
789
+ }
790
+ cuid(e) {
791
+ return this._addCheck({ kind: "cuid", ...g.errToObj(e) });
792
+ }
793
+ cuid2(e) {
794
+ return this._addCheck({ kind: "cuid2", ...g.errToObj(e) });
795
+ }
796
+ ulid(e) {
797
+ return this._addCheck({ kind: "ulid", ...g.errToObj(e) });
798
+ }
799
+ base64(e) {
800
+ return this._addCheck({ kind: "base64", ...g.errToObj(e) });
801
+ }
802
+ base64url(e) {
803
+ return this._addCheck({
804
+ kind: "base64url",
805
+ ...g.errToObj(e)
806
+ });
807
+ }
808
+ jwt(e) {
809
+ return this._addCheck({ kind: "jwt", ...g.errToObj(e) });
810
+ }
811
+ ip(e) {
812
+ return this._addCheck({ kind: "ip", ...g.errToObj(e) });
813
+ }
814
+ cidr(e) {
815
+ return this._addCheck({ kind: "cidr", ...g.errToObj(e) });
816
+ }
817
+ datetime(e) {
818
+ return typeof e == "string" ? this._addCheck({
819
+ kind: "datetime",
820
+ precision: null,
821
+ offset: !1,
822
+ local: !1,
823
+ message: e
824
+ }) : this._addCheck({
825
+ kind: "datetime",
826
+ precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
827
+ offset: (e == null ? void 0 : e.offset) ?? !1,
828
+ local: (e == null ? void 0 : e.local) ?? !1,
829
+ ...g.errToObj(e == null ? void 0 : e.message)
830
+ });
831
+ }
832
+ date(e) {
833
+ return this._addCheck({ kind: "date", message: e });
834
+ }
835
+ time(e) {
836
+ return typeof e == "string" ? this._addCheck({
837
+ kind: "time",
838
+ precision: null,
839
+ message: e
840
+ }) : this._addCheck({
841
+ kind: "time",
842
+ precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
843
+ ...g.errToObj(e == null ? void 0 : e.message)
844
+ });
845
+ }
846
+ duration(e) {
847
+ return this._addCheck({ kind: "duration", ...g.errToObj(e) });
848
+ }
849
+ regex(e, r) {
850
+ return this._addCheck({
851
+ kind: "regex",
852
+ regex: e,
853
+ ...g.errToObj(r)
854
+ });
855
+ }
856
+ includes(e, r) {
857
+ return this._addCheck({
858
+ kind: "includes",
859
+ value: e,
860
+ position: r == null ? void 0 : r.position,
861
+ ...g.errToObj(r == null ? void 0 : r.message)
862
+ });
863
+ }
864
+ startsWith(e, r) {
865
+ return this._addCheck({
866
+ kind: "startsWith",
867
+ value: e,
868
+ ...g.errToObj(r)
869
+ });
870
+ }
871
+ endsWith(e, r) {
872
+ return this._addCheck({
873
+ kind: "endsWith",
874
+ value: e,
875
+ ...g.errToObj(r)
876
+ });
877
+ }
878
+ min(e, r) {
879
+ return this._addCheck({
880
+ kind: "min",
881
+ value: e,
882
+ ...g.errToObj(r)
883
+ });
884
+ }
885
+ max(e, r) {
886
+ return this._addCheck({
887
+ kind: "max",
888
+ value: e,
889
+ ...g.errToObj(r)
890
+ });
891
+ }
892
+ length(e, r) {
893
+ return this._addCheck({
894
+ kind: "length",
895
+ value: e,
896
+ ...g.errToObj(r)
897
+ });
898
+ }
899
+ /**
900
+ * Equivalent to `.min(1)`
901
+ */
902
+ nonempty(e) {
903
+ return this.min(1, g.errToObj(e));
904
+ }
905
+ trim() {
906
+ return new U({
907
+ ...this._def,
908
+ checks: [...this._def.checks, { kind: "trim" }]
909
+ });
910
+ }
911
+ toLowerCase() {
912
+ return new U({
913
+ ...this._def,
914
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
915
+ });
916
+ }
917
+ toUpperCase() {
918
+ return new U({
919
+ ...this._def,
920
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
921
+ });
922
+ }
923
+ get isDatetime() {
924
+ return !!this._def.checks.find((e) => e.kind === "datetime");
925
+ }
926
+ get isDate() {
927
+ return !!this._def.checks.find((e) => e.kind === "date");
928
+ }
929
+ get isTime() {
930
+ return !!this._def.checks.find((e) => e.kind === "time");
931
+ }
932
+ get isDuration() {
933
+ return !!this._def.checks.find((e) => e.kind === "duration");
934
+ }
935
+ get isEmail() {
936
+ return !!this._def.checks.find((e) => e.kind === "email");
937
+ }
938
+ get isURL() {
939
+ return !!this._def.checks.find((e) => e.kind === "url");
940
+ }
941
+ get isEmoji() {
942
+ return !!this._def.checks.find((e) => e.kind === "emoji");
943
+ }
944
+ get isUUID() {
945
+ return !!this._def.checks.find((e) => e.kind === "uuid");
946
+ }
947
+ get isNANOID() {
948
+ return !!this._def.checks.find((e) => e.kind === "nanoid");
949
+ }
950
+ get isCUID() {
951
+ return !!this._def.checks.find((e) => e.kind === "cuid");
952
+ }
953
+ get isCUID2() {
954
+ return !!this._def.checks.find((e) => e.kind === "cuid2");
955
+ }
956
+ get isULID() {
957
+ return !!this._def.checks.find((e) => e.kind === "ulid");
958
+ }
959
+ get isIP() {
960
+ return !!this._def.checks.find((e) => e.kind === "ip");
961
+ }
962
+ get isCIDR() {
963
+ return !!this._def.checks.find((e) => e.kind === "cidr");
964
+ }
965
+ get isBase64() {
966
+ return !!this._def.checks.find((e) => e.kind === "base64");
967
+ }
968
+ get isBase64url() {
969
+ return !!this._def.checks.find((e) => e.kind === "base64url");
970
+ }
971
+ get minLength() {
972
+ let e = null;
973
+ for (const r of this._def.checks)
974
+ r.kind === "min" && (e === null || r.value > e) && (e = r.value);
975
+ return e;
976
+ }
977
+ get maxLength() {
978
+ let e = null;
979
+ for (const r of this._def.checks)
980
+ r.kind === "max" && (e === null || r.value < e) && (e = r.value);
981
+ return e;
982
+ }
983
+ }
984
+ U.create = (t) => new U({
985
+ checks: [],
986
+ typeName: k.ZodString,
987
+ coerce: (t == null ? void 0 : t.coerce) ?? !1,
988
+ ...w(t)
989
+ });
990
+ function dr(t, e) {
991
+ const r = (t.toString().split(".")[1] || "").length, s = (e.toString().split(".")[1] || "").length, n = r > s ? r : s, i = Number.parseInt(t.toFixed(n).replace(".", "")), o = Number.parseInt(e.toFixed(n).replace(".", ""));
992
+ return i % o / 10 ** n;
993
+ }
994
+ class se extends I {
995
+ constructor() {
996
+ super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
997
+ }
998
+ _parse(e) {
999
+ if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== m.number) {
1000
+ const i = this._getOrReturnCtx(e);
1001
+ return p(i, {
1002
+ code: u.invalid_type,
1003
+ expected: m.number,
1004
+ received: i.parsedType
1005
+ }), v;
1006
+ }
1007
+ let s;
1008
+ const n = new $();
1009
+ for (const i of this._def.checks)
1010
+ i.kind === "int" ? S.isInteger(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
1011
+ code: u.invalid_type,
1012
+ expected: "integer",
1013
+ received: "float",
1014
+ message: i.message
1015
+ }), n.dirty()) : i.kind === "min" ? (i.inclusive ? e.data < i.value : e.data <= i.value) && (s = this._getOrReturnCtx(e, s), p(s, {
1016
+ code: u.too_small,
1017
+ minimum: i.value,
1018
+ type: "number",
1019
+ inclusive: i.inclusive,
1020
+ exact: !1,
1021
+ message: i.message
1022
+ }), n.dirty()) : i.kind === "max" ? (i.inclusive ? e.data > i.value : e.data >= i.value) && (s = this._getOrReturnCtx(e, s), p(s, {
1023
+ code: u.too_big,
1024
+ maximum: i.value,
1025
+ type: "number",
1026
+ inclusive: i.inclusive,
1027
+ exact: !1,
1028
+ message: i.message
1029
+ }), n.dirty()) : i.kind === "multipleOf" ? dr(e.data, i.value) !== 0 && (s = this._getOrReturnCtx(e, s), p(s, {
1030
+ code: u.not_multiple_of,
1031
+ multipleOf: i.value,
1032
+ message: i.message
1033
+ }), n.dirty()) : i.kind === "finite" ? Number.isFinite(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
1034
+ code: u.not_finite,
1035
+ message: i.message
1036
+ }), n.dirty()) : S.assertNever(i);
1037
+ return { status: n.value, value: e.data };
1038
+ }
1039
+ gte(e, r) {
1040
+ return this.setLimit("min", e, !0, g.toString(r));
1041
+ }
1042
+ gt(e, r) {
1043
+ return this.setLimit("min", e, !1, g.toString(r));
1044
+ }
1045
+ lte(e, r) {
1046
+ return this.setLimit("max", e, !0, g.toString(r));
1047
+ }
1048
+ lt(e, r) {
1049
+ return this.setLimit("max", e, !1, g.toString(r));
1050
+ }
1051
+ setLimit(e, r, s, n) {
1052
+ return new se({
1053
+ ...this._def,
1054
+ checks: [
1055
+ ...this._def.checks,
1056
+ {
1057
+ kind: e,
1058
+ value: r,
1059
+ inclusive: s,
1060
+ message: g.toString(n)
1061
+ }
1062
+ ]
1063
+ });
1064
+ }
1065
+ _addCheck(e) {
1066
+ return new se({
1067
+ ...this._def,
1068
+ checks: [...this._def.checks, e]
1069
+ });
1070
+ }
1071
+ int(e) {
1072
+ return this._addCheck({
1073
+ kind: "int",
1074
+ message: g.toString(e)
1075
+ });
1076
+ }
1077
+ positive(e) {
1078
+ return this._addCheck({
1079
+ kind: "min",
1080
+ value: 0,
1081
+ inclusive: !1,
1082
+ message: g.toString(e)
1083
+ });
1084
+ }
1085
+ negative(e) {
1086
+ return this._addCheck({
1087
+ kind: "max",
1088
+ value: 0,
1089
+ inclusive: !1,
1090
+ message: g.toString(e)
1091
+ });
1092
+ }
1093
+ nonpositive(e) {
1094
+ return this._addCheck({
1095
+ kind: "max",
1096
+ value: 0,
1097
+ inclusive: !0,
1098
+ message: g.toString(e)
1099
+ });
1100
+ }
1101
+ nonnegative(e) {
1102
+ return this._addCheck({
1103
+ kind: "min",
1104
+ value: 0,
1105
+ inclusive: !0,
1106
+ message: g.toString(e)
1107
+ });
1108
+ }
1109
+ multipleOf(e, r) {
1110
+ return this._addCheck({
1111
+ kind: "multipleOf",
1112
+ value: e,
1113
+ message: g.toString(r)
1114
+ });
1115
+ }
1116
+ finite(e) {
1117
+ return this._addCheck({
1118
+ kind: "finite",
1119
+ message: g.toString(e)
1120
+ });
1121
+ }
1122
+ safe(e) {
1123
+ return this._addCheck({
1124
+ kind: "min",
1125
+ inclusive: !0,
1126
+ value: Number.MIN_SAFE_INTEGER,
1127
+ message: g.toString(e)
1128
+ })._addCheck({
1129
+ kind: "max",
1130
+ inclusive: !0,
1131
+ value: Number.MAX_SAFE_INTEGER,
1132
+ message: g.toString(e)
1133
+ });
1134
+ }
1135
+ get minValue() {
1136
+ let e = null;
1137
+ for (const r of this._def.checks)
1138
+ r.kind === "min" && (e === null || r.value > e) && (e = r.value);
1139
+ return e;
1140
+ }
1141
+ get maxValue() {
1142
+ let e = null;
1143
+ for (const r of this._def.checks)
1144
+ r.kind === "max" && (e === null || r.value < e) && (e = r.value);
1145
+ return e;
1146
+ }
1147
+ get isInt() {
1148
+ return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && S.isInteger(e.value));
1149
+ }
1150
+ get isFinite() {
1151
+ let e = null, r = null;
1152
+ for (const s of this._def.checks) {
1153
+ if (s.kind === "finite" || s.kind === "int" || s.kind === "multipleOf")
1154
+ return !0;
1155
+ s.kind === "min" ? (r === null || s.value > r) && (r = s.value) : s.kind === "max" && (e === null || s.value < e) && (e = s.value);
1156
+ }
1157
+ return Number.isFinite(r) && Number.isFinite(e);
1158
+ }
1159
+ }
1160
+ se.create = (t) => new se({
1161
+ checks: [],
1162
+ typeName: k.ZodNumber,
1163
+ coerce: (t == null ? void 0 : t.coerce) || !1,
1164
+ ...w(t)
1165
+ });
1166
+ class ne extends I {
1167
+ constructor() {
1168
+ super(...arguments), this.min = this.gte, this.max = this.lte;
1169
+ }
1170
+ _parse(e) {
1171
+ if (this._def.coerce)
1172
+ try {
1173
+ e.data = BigInt(e.data);
1174
+ } catch {
1175
+ return this._getInvalidInput(e);
1176
+ }
1177
+ if (this._getType(e) !== m.bigint)
1178
+ return this._getInvalidInput(e);
1179
+ let s;
1180
+ const n = new $();
1181
+ for (const i of this._def.checks)
1182
+ i.kind === "min" ? (i.inclusive ? e.data < i.value : e.data <= i.value) && (s = this._getOrReturnCtx(e, s), p(s, {
1183
+ code: u.too_small,
1184
+ type: "bigint",
1185
+ minimum: i.value,
1186
+ inclusive: i.inclusive,
1187
+ message: i.message
1188
+ }), n.dirty()) : i.kind === "max" ? (i.inclusive ? e.data > i.value : e.data >= i.value) && (s = this._getOrReturnCtx(e, s), p(s, {
1189
+ code: u.too_big,
1190
+ type: "bigint",
1191
+ maximum: i.value,
1192
+ inclusive: i.inclusive,
1193
+ message: i.message
1194
+ }), n.dirty()) : i.kind === "multipleOf" ? e.data % i.value !== BigInt(0) && (s = this._getOrReturnCtx(e, s), p(s, {
1195
+ code: u.not_multiple_of,
1196
+ multipleOf: i.value,
1197
+ message: i.message
1198
+ }), n.dirty()) : S.assertNever(i);
1199
+ return { status: n.value, value: e.data };
1200
+ }
1201
+ _getInvalidInput(e) {
1202
+ const r = this._getOrReturnCtx(e);
1203
+ return p(r, {
1204
+ code: u.invalid_type,
1205
+ expected: m.bigint,
1206
+ received: r.parsedType
1207
+ }), v;
1208
+ }
1209
+ gte(e, r) {
1210
+ return this.setLimit("min", e, !0, g.toString(r));
1211
+ }
1212
+ gt(e, r) {
1213
+ return this.setLimit("min", e, !1, g.toString(r));
1214
+ }
1215
+ lte(e, r) {
1216
+ return this.setLimit("max", e, !0, g.toString(r));
1217
+ }
1218
+ lt(e, r) {
1219
+ return this.setLimit("max", e, !1, g.toString(r));
1220
+ }
1221
+ setLimit(e, r, s, n) {
1222
+ return new ne({
1223
+ ...this._def,
1224
+ checks: [
1225
+ ...this._def.checks,
1226
+ {
1227
+ kind: e,
1228
+ value: r,
1229
+ inclusive: s,
1230
+ message: g.toString(n)
1231
+ }
1232
+ ]
1233
+ });
1234
+ }
1235
+ _addCheck(e) {
1236
+ return new ne({
1237
+ ...this._def,
1238
+ checks: [...this._def.checks, e]
1239
+ });
1240
+ }
1241
+ positive(e) {
1242
+ return this._addCheck({
1243
+ kind: "min",
1244
+ value: BigInt(0),
1245
+ inclusive: !1,
1246
+ message: g.toString(e)
1247
+ });
1248
+ }
1249
+ negative(e) {
1250
+ return this._addCheck({
1251
+ kind: "max",
1252
+ value: BigInt(0),
1253
+ inclusive: !1,
1254
+ message: g.toString(e)
1255
+ });
1256
+ }
1257
+ nonpositive(e) {
1258
+ return this._addCheck({
1259
+ kind: "max",
1260
+ value: BigInt(0),
1261
+ inclusive: !0,
1262
+ message: g.toString(e)
1263
+ });
1264
+ }
1265
+ nonnegative(e) {
1266
+ return this._addCheck({
1267
+ kind: "min",
1268
+ value: BigInt(0),
1269
+ inclusive: !0,
1270
+ message: g.toString(e)
1271
+ });
1272
+ }
1273
+ multipleOf(e, r) {
1274
+ return this._addCheck({
1275
+ kind: "multipleOf",
1276
+ value: e,
1277
+ message: g.toString(r)
1278
+ });
1279
+ }
1280
+ get minValue() {
1281
+ let e = null;
1282
+ for (const r of this._def.checks)
1283
+ r.kind === "min" && (e === null || r.value > e) && (e = r.value);
1284
+ return e;
1285
+ }
1286
+ get maxValue() {
1287
+ let e = null;
1288
+ for (const r of this._def.checks)
1289
+ r.kind === "max" && (e === null || r.value < e) && (e = r.value);
1290
+ return e;
1291
+ }
1292
+ }
1293
+ ne.create = (t) => new ne({
1294
+ checks: [],
1295
+ typeName: k.ZodBigInt,
1296
+ coerce: (t == null ? void 0 : t.coerce) ?? !1,
1297
+ ...w(t)
1298
+ });
1299
+ class Le extends I {
1300
+ _parse(e) {
1301
+ if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== m.boolean) {
1302
+ const s = this._getOrReturnCtx(e);
1303
+ return p(s, {
1304
+ code: u.invalid_type,
1305
+ expected: m.boolean,
1306
+ received: s.parsedType
1307
+ }), v;
1308
+ }
1309
+ return L(e.data);
1310
+ }
1311
+ }
1312
+ Le.create = (t) => new Le({
1313
+ typeName: k.ZodBoolean,
1314
+ coerce: (t == null ? void 0 : t.coerce) || !1,
1315
+ ...w(t)
1316
+ });
1317
+ class we extends I {
1318
+ _parse(e) {
1319
+ if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== m.date) {
1320
+ const i = this._getOrReturnCtx(e);
1321
+ return p(i, {
1322
+ code: u.invalid_type,
1323
+ expected: m.date,
1324
+ received: i.parsedType
1325
+ }), v;
1326
+ }
1327
+ if (Number.isNaN(e.data.getTime())) {
1328
+ const i = this._getOrReturnCtx(e);
1329
+ return p(i, {
1330
+ code: u.invalid_date
1331
+ }), v;
1332
+ }
1333
+ const s = new $();
1334
+ let n;
1335
+ for (const i of this._def.checks)
1336
+ i.kind === "min" ? e.data.getTime() < i.value && (n = this._getOrReturnCtx(e, n), p(n, {
1337
+ code: u.too_small,
1338
+ message: i.message,
1339
+ inclusive: !0,
1340
+ exact: !1,
1341
+ minimum: i.value,
1342
+ type: "date"
1343
+ }), s.dirty()) : i.kind === "max" ? e.data.getTime() > i.value && (n = this._getOrReturnCtx(e, n), p(n, {
1344
+ code: u.too_big,
1345
+ message: i.message,
1346
+ inclusive: !0,
1347
+ exact: !1,
1348
+ maximum: i.value,
1349
+ type: "date"
1350
+ }), s.dirty()) : S.assertNever(i);
1351
+ return {
1352
+ status: s.value,
1353
+ value: new Date(e.data.getTime())
1354
+ };
1355
+ }
1356
+ _addCheck(e) {
1357
+ return new we({
1358
+ ...this._def,
1359
+ checks: [...this._def.checks, e]
1360
+ });
1361
+ }
1362
+ min(e, r) {
1363
+ return this._addCheck({
1364
+ kind: "min",
1365
+ value: e.getTime(),
1366
+ message: g.toString(r)
1367
+ });
1368
+ }
1369
+ max(e, r) {
1370
+ return this._addCheck({
1371
+ kind: "max",
1372
+ value: e.getTime(),
1373
+ message: g.toString(r)
1374
+ });
1375
+ }
1376
+ get minDate() {
1377
+ let e = null;
1378
+ for (const r of this._def.checks)
1379
+ r.kind === "min" && (e === null || r.value > e) && (e = r.value);
1380
+ return e != null ? new Date(e) : null;
1381
+ }
1382
+ get maxDate() {
1383
+ let e = null;
1384
+ for (const r of this._def.checks)
1385
+ r.kind === "max" && (e === null || r.value < e) && (e = r.value);
1386
+ return e != null ? new Date(e) : null;
1387
+ }
1388
+ }
1389
+ we.create = (t) => new we({
1390
+ checks: [],
1391
+ coerce: (t == null ? void 0 : t.coerce) || !1,
1392
+ typeName: k.ZodDate,
1393
+ ...w(t)
1394
+ });
1395
+ class yt extends I {
1396
+ _parse(e) {
1397
+ if (this._getType(e) !== m.symbol) {
1398
+ const s = this._getOrReturnCtx(e);
1399
+ return p(s, {
1400
+ code: u.invalid_type,
1401
+ expected: m.symbol,
1402
+ received: s.parsedType
1403
+ }), v;
1404
+ }
1405
+ return L(e.data);
1406
+ }
1407
+ }
1408
+ yt.create = (t) => new yt({
1409
+ typeName: k.ZodSymbol,
1410
+ ...w(t)
1411
+ });
1412
+ class je extends I {
1413
+ _parse(e) {
1414
+ if (this._getType(e) !== m.undefined) {
1415
+ const s = this._getOrReturnCtx(e);
1416
+ return p(s, {
1417
+ code: u.invalid_type,
1418
+ expected: m.undefined,
1419
+ received: s.parsedType
1420
+ }), v;
1421
+ }
1422
+ return L(e.data);
1423
+ }
1424
+ }
1425
+ je.create = (t) => new je({
1426
+ typeName: k.ZodUndefined,
1427
+ ...w(t)
1428
+ });
1429
+ class xe extends I {
1430
+ _parse(e) {
1431
+ if (this._getType(e) !== m.null) {
1432
+ const s = this._getOrReturnCtx(e);
1433
+ return p(s, {
1434
+ code: u.invalid_type,
1435
+ expected: m.null,
1436
+ received: s.parsedType
1437
+ }), v;
1438
+ }
1439
+ return L(e.data);
1440
+ }
1441
+ }
1442
+ xe.create = (t) => new xe({
1443
+ typeName: k.ZodNull,
1444
+ ...w(t)
1445
+ });
1446
+ class qe extends I {
1447
+ constructor() {
1448
+ super(...arguments), this._any = !0;
1449
+ }
1450
+ _parse(e) {
1451
+ return L(e.data);
1452
+ }
1453
+ }
1454
+ qe.create = (t) => new qe({
1455
+ typeName: k.ZodAny,
1456
+ ...w(t)
1457
+ });
1458
+ class re extends I {
1459
+ constructor() {
1460
+ super(...arguments), this._unknown = !0;
1461
+ }
1462
+ _parse(e) {
1463
+ return L(e.data);
1464
+ }
1465
+ }
1466
+ re.create = (t) => new re({
1467
+ typeName: k.ZodUnknown,
1468
+ ...w(t)
1469
+ });
1470
+ class X extends I {
1471
+ _parse(e) {
1472
+ const r = this._getOrReturnCtx(e);
1473
+ return p(r, {
1474
+ code: u.invalid_type,
1475
+ expected: m.never,
1476
+ received: r.parsedType
1477
+ }), v;
1478
+ }
1479
+ }
1480
+ X.create = (t) => new X({
1481
+ typeName: k.ZodNever,
1482
+ ...w(t)
1483
+ });
1484
+ class He extends I {
1485
+ _parse(e) {
1486
+ if (this._getType(e) !== m.undefined) {
1487
+ const s = this._getOrReturnCtx(e);
1488
+ return p(s, {
1489
+ code: u.invalid_type,
1490
+ expected: m.void,
1491
+ received: s.parsedType
1492
+ }), v;
1493
+ }
1494
+ return L(e.data);
1495
+ }
1496
+ }
1497
+ He.create = (t) => new He({
1498
+ typeName: k.ZodVoid,
1499
+ ...w(t)
1500
+ });
1501
+ class D extends I {
1502
+ _parse(e) {
1503
+ const { ctx: r, status: s } = this._processInputParams(e), n = this._def;
1504
+ if (r.parsedType !== m.array)
1505
+ return p(r, {
1506
+ code: u.invalid_type,
1507
+ expected: m.array,
1508
+ received: r.parsedType
1509
+ }), v;
1510
+ if (n.exactLength !== null) {
1511
+ const o = r.data.length > n.exactLength.value, a = r.data.length < n.exactLength.value;
1512
+ (o || a) && (p(r, {
1513
+ code: o ? u.too_big : u.too_small,
1514
+ minimum: a ? n.exactLength.value : void 0,
1515
+ maximum: o ? n.exactLength.value : void 0,
1516
+ type: "array",
1517
+ inclusive: !0,
1518
+ exact: !0,
1519
+ message: n.exactLength.message
1520
+ }), s.dirty());
1521
+ }
1522
+ if (n.minLength !== null && r.data.length < n.minLength.value && (p(r, {
1523
+ code: u.too_small,
1524
+ minimum: n.minLength.value,
1525
+ type: "array",
1526
+ inclusive: !0,
1527
+ exact: !1,
1528
+ message: n.minLength.message
1529
+ }), s.dirty()), n.maxLength !== null && r.data.length > n.maxLength.value && (p(r, {
1530
+ code: u.too_big,
1531
+ maximum: n.maxLength.value,
1532
+ type: "array",
1533
+ inclusive: !0,
1534
+ exact: !1,
1535
+ message: n.maxLength.message
1536
+ }), s.dirty()), r.common.async)
1537
+ return Promise.all([...r.data].map((o, a) => n.type._parseAsync(new F(r, o, r.path, a)))).then((o) => $.mergeArray(s, o));
1538
+ const i = [...r.data].map((o, a) => n.type._parseSync(new F(r, o, r.path, a)));
1539
+ return $.mergeArray(s, i);
1540
+ }
1541
+ get element() {
1542
+ return this._def.type;
1543
+ }
1544
+ min(e, r) {
1545
+ return new D({
1546
+ ...this._def,
1547
+ minLength: { value: e, message: g.toString(r) }
1548
+ });
1549
+ }
1550
+ max(e, r) {
1551
+ return new D({
1552
+ ...this._def,
1553
+ maxLength: { value: e, message: g.toString(r) }
1554
+ });
1555
+ }
1556
+ length(e, r) {
1557
+ return new D({
1558
+ ...this._def,
1559
+ exactLength: { value: e, message: g.toString(r) }
1560
+ });
1561
+ }
1562
+ nonempty(e) {
1563
+ return this.min(1, e);
1564
+ }
1565
+ }
1566
+ D.create = (t, e) => new D({
1567
+ type: t,
1568
+ minLength: null,
1569
+ maxLength: null,
1570
+ exactLength: null,
1571
+ typeName: k.ZodArray,
1572
+ ...w(e)
1573
+ });
1574
+ function ce(t) {
1575
+ if (t instanceof R) {
1576
+ const e = {};
1577
+ for (const r in t.shape) {
1578
+ const s = t.shape[r];
1579
+ e[r] = W.create(ce(s));
1580
+ }
1581
+ return new R({
1582
+ ...t._def,
1583
+ shape: () => e
1584
+ });
1585
+ } else return t instanceof D ? new D({
1586
+ ...t._def,
1587
+ type: ce(t.element)
1588
+ }) : t instanceof W ? W.create(ce(t.unwrap())) : t instanceof ee ? ee.create(ce(t.unwrap())) : t instanceof z ? z.create(t.items.map((e) => ce(e))) : t;
1589
+ }
1590
+ class R extends I {
1591
+ constructor() {
1592
+ super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
1593
+ }
1594
+ _getCached() {
1595
+ if (this._cached !== null)
1596
+ return this._cached;
1597
+ const e = this._def.shape(), r = S.objectKeys(e);
1598
+ return this._cached = { shape: e, keys: r }, this._cached;
1599
+ }
1600
+ _parse(e) {
1601
+ if (this._getType(e) !== m.object) {
1602
+ const l = this._getOrReturnCtx(e);
1603
+ return p(l, {
1604
+ code: u.invalid_type,
1605
+ expected: m.object,
1606
+ received: l.parsedType
1607
+ }), v;
1608
+ }
1609
+ const { status: s, ctx: n } = this._processInputParams(e), { shape: i, keys: o } = this._getCached(), a = [];
1610
+ if (!(this._def.catchall instanceof X && this._def.unknownKeys === "strip"))
1611
+ for (const l in n.data)
1612
+ o.includes(l) || a.push(l);
1613
+ const h = [];
1614
+ for (const l of o) {
1615
+ const _ = i[l], E = n.data[l];
1616
+ h.push({
1617
+ key: { status: "valid", value: l },
1618
+ value: _._parse(new F(n, E, n.path, l)),
1619
+ alwaysSet: l in n.data
1620
+ });
1621
+ }
1622
+ if (this._def.catchall instanceof X) {
1623
+ const l = this._def.unknownKeys;
1624
+ if (l === "passthrough")
1625
+ for (const _ of a)
1626
+ h.push({
1627
+ key: { status: "valid", value: _ },
1628
+ value: { status: "valid", value: n.data[_] }
1629
+ });
1630
+ else if (l === "strict")
1631
+ a.length > 0 && (p(n, {
1632
+ code: u.unrecognized_keys,
1633
+ keys: a
1634
+ }), s.dirty());
1635
+ else if (l !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
1636
+ } else {
1637
+ const l = this._def.catchall;
1638
+ for (const _ of a) {
1639
+ const E = n.data[_];
1640
+ h.push({
1641
+ key: { status: "valid", value: _ },
1642
+ value: l._parse(
1643
+ new F(n, E, n.path, _)
1644
+ //, ctx.child(key), value, getParsedType(value)
1645
+ ),
1646
+ alwaysSet: _ in n.data
1647
+ });
1648
+ }
1649
+ }
1650
+ return n.common.async ? Promise.resolve().then(async () => {
1651
+ const l = [];
1652
+ for (const _ of h) {
1653
+ const E = await _.key, te = await _.value;
1654
+ l.push({
1655
+ key: E,
1656
+ value: te,
1657
+ alwaysSet: _.alwaysSet
1658
+ });
1659
+ }
1660
+ return l;
1661
+ }).then((l) => $.mergeObjectSync(s, l)) : $.mergeObjectSync(s, h);
1662
+ }
1663
+ get shape() {
1664
+ return this._def.shape();
1665
+ }
1666
+ strict(e) {
1667
+ return g.errToObj, new R({
1668
+ ...this._def,
1669
+ unknownKeys: "strict",
1670
+ ...e !== void 0 ? {
1671
+ errorMap: (r, s) => {
1672
+ var i, o;
1673
+ const n = ((o = (i = this._def).errorMap) == null ? void 0 : o.call(i, r, s).message) ?? s.defaultError;
1674
+ return r.code === "unrecognized_keys" ? {
1675
+ message: g.errToObj(e).message ?? n
1676
+ } : {
1677
+ message: n
1678
+ };
1679
+ }
1680
+ } : {}
1681
+ });
1682
+ }
1683
+ strip() {
1684
+ return new R({
1685
+ ...this._def,
1686
+ unknownKeys: "strip"
1687
+ });
1688
+ }
1689
+ passthrough() {
1690
+ return new R({
1691
+ ...this._def,
1692
+ unknownKeys: "passthrough"
1693
+ });
1694
+ }
1695
+ // const AugmentFactory =
1696
+ // <Def extends ZodObjectDef>(def: Def) =>
1697
+ // <Augmentation extends ZodRawShape>(
1698
+ // augmentation: Augmentation
1699
+ // ): ZodObject<
1700
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
1701
+ // Def["unknownKeys"],
1702
+ // Def["catchall"]
1703
+ // > => {
1704
+ // return new ZodObject({
1705
+ // ...def,
1706
+ // shape: () => ({
1707
+ // ...def.shape(),
1708
+ // ...augmentation,
1709
+ // }),
1710
+ // }) as any;
1711
+ // };
1712
+ extend(e) {
1713
+ return new R({
1714
+ ...this._def,
1715
+ shape: () => ({
1716
+ ...this._def.shape(),
1717
+ ...e
1718
+ })
1719
+ });
1720
+ }
1721
+ /**
1722
+ * Prior to zod@1.0.12 there was a bug in the
1723
+ * inferred type of merged objects. Please
1724
+ * upgrade if you are experiencing issues.
1725
+ */
1726
+ merge(e) {
1727
+ return new R({
1728
+ unknownKeys: e._def.unknownKeys,
1729
+ catchall: e._def.catchall,
1730
+ shape: () => ({
1731
+ ...this._def.shape(),
1732
+ ...e._def.shape()
1733
+ }),
1734
+ typeName: k.ZodObject
1735
+ });
1736
+ }
1737
+ // merge<
1738
+ // Incoming extends AnyZodObject,
1739
+ // Augmentation extends Incoming["shape"],
1740
+ // NewOutput extends {
1741
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
1742
+ // ? Augmentation[k]["_output"]
1743
+ // : k extends keyof Output
1744
+ // ? Output[k]
1745
+ // : never;
1746
+ // },
1747
+ // NewInput extends {
1748
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
1749
+ // ? Augmentation[k]["_input"]
1750
+ // : k extends keyof Input
1751
+ // ? Input[k]
1752
+ // : never;
1753
+ // }
1754
+ // >(
1755
+ // merging: Incoming
1756
+ // ): ZodObject<
1757
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
1758
+ // Incoming["_def"]["unknownKeys"],
1759
+ // Incoming["_def"]["catchall"],
1760
+ // NewOutput,
1761
+ // NewInput
1762
+ // > {
1763
+ // const merged: any = new ZodObject({
1764
+ // unknownKeys: merging._def.unknownKeys,
1765
+ // catchall: merging._def.catchall,
1766
+ // shape: () =>
1767
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
1768
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
1769
+ // }) as any;
1770
+ // return merged;
1771
+ // }
1772
+ setKey(e, r) {
1773
+ return this.augment({ [e]: r });
1774
+ }
1775
+ // merge<Incoming extends AnyZodObject>(
1776
+ // merging: Incoming
1777
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
1778
+ // ZodObject<
1779
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
1780
+ // Incoming["_def"]["unknownKeys"],
1781
+ // Incoming["_def"]["catchall"]
1782
+ // > {
1783
+ // // const mergedShape = objectUtil.mergeShapes(
1784
+ // // this._def.shape(),
1785
+ // // merging._def.shape()
1786
+ // // );
1787
+ // const merged: any = new ZodObject({
1788
+ // unknownKeys: merging._def.unknownKeys,
1789
+ // catchall: merging._def.catchall,
1790
+ // shape: () =>
1791
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
1792
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
1793
+ // }) as any;
1794
+ // return merged;
1795
+ // }
1796
+ catchall(e) {
1797
+ return new R({
1798
+ ...this._def,
1799
+ catchall: e
1800
+ });
1801
+ }
1802
+ pick(e) {
1803
+ const r = {};
1804
+ for (const s of S.objectKeys(e))
1805
+ e[s] && this.shape[s] && (r[s] = this.shape[s]);
1806
+ return new R({
1807
+ ...this._def,
1808
+ shape: () => r
1809
+ });
1810
+ }
1811
+ omit(e) {
1812
+ const r = {};
1813
+ for (const s of S.objectKeys(this.shape))
1814
+ e[s] || (r[s] = this.shape[s]);
1815
+ return new R({
1816
+ ...this._def,
1817
+ shape: () => r
1818
+ });
1819
+ }
1820
+ /**
1821
+ * @deprecated
1822
+ */
1823
+ deepPartial() {
1824
+ return ce(this);
1825
+ }
1826
+ partial(e) {
1827
+ const r = {};
1828
+ for (const s of S.objectKeys(this.shape)) {
1829
+ const n = this.shape[s];
1830
+ e && !e[s] ? r[s] = n : r[s] = n.optional();
1831
+ }
1832
+ return new R({
1833
+ ...this._def,
1834
+ shape: () => r
1835
+ });
1836
+ }
1837
+ required(e) {
1838
+ const r = {};
1839
+ for (const s of S.objectKeys(this.shape))
1840
+ if (e && !e[s])
1841
+ r[s] = this.shape[s];
1842
+ else {
1843
+ let i = this.shape[s];
1844
+ for (; i instanceof W; )
1845
+ i = i._def.innerType;
1846
+ r[s] = i;
1847
+ }
1848
+ return new R({
1849
+ ...this._def,
1850
+ shape: () => r
1851
+ });
1852
+ }
1853
+ keyof() {
1854
+ return It(S.objectKeys(this.shape));
1855
+ }
1856
+ }
1857
+ R.create = (t, e) => new R({
1858
+ shape: () => t,
1859
+ unknownKeys: "strip",
1860
+ catchall: X.create(),
1861
+ typeName: k.ZodObject,
1862
+ ...w(e)
1863
+ });
1864
+ R.strictCreate = (t, e) => new R({
1865
+ shape: () => t,
1866
+ unknownKeys: "strict",
1867
+ catchall: X.create(),
1868
+ typeName: k.ZodObject,
1869
+ ...w(e)
1870
+ });
1871
+ R.lazycreate = (t, e) => new R({
1872
+ shape: t,
1873
+ unknownKeys: "strip",
1874
+ catchall: X.create(),
1875
+ typeName: k.ZodObject,
1876
+ ...w(e)
1877
+ });
1878
+ class Te extends I {
1879
+ _parse(e) {
1880
+ const { ctx: r } = this._processInputParams(e), s = this._def.options;
1881
+ function n(i) {
1882
+ for (const a of i)
1883
+ if (a.result.status === "valid")
1884
+ return a.result;
1885
+ for (const a of i)
1886
+ if (a.result.status === "dirty")
1887
+ return r.common.issues.push(...a.ctx.common.issues), a.result;
1888
+ const o = i.map((a) => new j(a.ctx.common.issues));
1889
+ return p(r, {
1890
+ code: u.invalid_union,
1891
+ unionErrors: o
1892
+ }), v;
1893
+ }
1894
+ if (r.common.async)
1895
+ return Promise.all(s.map(async (i) => {
1896
+ const o = {
1897
+ ...r,
1898
+ common: {
1899
+ ...r.common,
1900
+ issues: []
1901
+ },
1902
+ parent: null
1903
+ };
1904
+ return {
1905
+ result: await i._parseAsync({
1906
+ data: r.data,
1907
+ path: r.path,
1908
+ parent: o
1909
+ }),
1910
+ ctx: o
1911
+ };
1912
+ })).then(n);
1913
+ {
1914
+ let i;
1915
+ const o = [];
1916
+ for (const h of s) {
1917
+ const l = {
1918
+ ...r,
1919
+ common: {
1920
+ ...r.common,
1921
+ issues: []
1922
+ },
1923
+ parent: null
1924
+ }, _ = h._parseSync({
1925
+ data: r.data,
1926
+ path: r.path,
1927
+ parent: l
1928
+ });
1929
+ if (_.status === "valid")
1930
+ return _;
1931
+ _.status === "dirty" && !i && (i = { result: _, ctx: l }), l.common.issues.length && o.push(l.common.issues);
1932
+ }
1933
+ if (i)
1934
+ return r.common.issues.push(...i.ctx.common.issues), i.result;
1935
+ const a = o.map((h) => new j(h));
1936
+ return p(r, {
1937
+ code: u.invalid_union,
1938
+ unionErrors: a
1939
+ }), v;
1940
+ }
1941
+ }
1942
+ get options() {
1943
+ return this._def.options;
1944
+ }
1945
+ }
1946
+ Te.create = (t, e) => new Te({
1947
+ options: t,
1948
+ typeName: k.ZodUnion,
1949
+ ...w(e)
1950
+ });
1951
+ const H = (t) => t instanceof Pe ? H(t.schema) : t instanceof G ? H(t.innerType()) : t instanceof Ee ? [t.value] : t instanceof Q ? t.options : t instanceof Ye ? S.objectValues(t.enum) : t instanceof Ae ? H(t._def.innerType) : t instanceof je ? [void 0] : t instanceof xe ? [null] : t instanceof W ? [void 0, ...H(t.unwrap())] : t instanceof ee ? [null, ...H(t.unwrap())] : t instanceof nt || t instanceof Ce ? H(t.unwrap()) : t instanceof Re ? H(t._def.innerType) : [];
1952
+ class st extends I {
1953
+ _parse(e) {
1954
+ const { ctx: r } = this._processInputParams(e);
1955
+ if (r.parsedType !== m.object)
1956
+ return p(r, {
1957
+ code: u.invalid_type,
1958
+ expected: m.object,
1959
+ received: r.parsedType
1960
+ }), v;
1961
+ const s = this.discriminator, n = r.data[s], i = this.optionsMap.get(n);
1962
+ return i ? r.common.async ? i._parseAsync({
1963
+ data: r.data,
1964
+ path: r.path,
1965
+ parent: r
1966
+ }) : i._parseSync({
1967
+ data: r.data,
1968
+ path: r.path,
1969
+ parent: r
1970
+ }) : (p(r, {
1971
+ code: u.invalid_union_discriminator,
1972
+ options: Array.from(this.optionsMap.keys()),
1973
+ path: [s]
1974
+ }), v);
1975
+ }
1976
+ get discriminator() {
1977
+ return this._def.discriminator;
1978
+ }
1979
+ get options() {
1980
+ return this._def.options;
1981
+ }
1982
+ get optionsMap() {
1983
+ return this._def.optionsMap;
1984
+ }
1985
+ /**
1986
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
1987
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
1988
+ * have a different value for each object in the union.
1989
+ * @param discriminator the name of the discriminator property
1990
+ * @param types an array of object schemas
1991
+ * @param params
1992
+ */
1993
+ static create(e, r, s) {
1994
+ const n = /* @__PURE__ */ new Map();
1995
+ for (const i of r) {
1996
+ const o = H(i.shape[e]);
1997
+ if (!o.length)
1998
+ throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
1999
+ for (const a of o) {
2000
+ if (n.has(a))
2001
+ throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);
2002
+ n.set(a, i);
2003
+ }
2004
+ }
2005
+ return new st({
2006
+ typeName: k.ZodDiscriminatedUnion,
2007
+ discriminator: e,
2008
+ options: r,
2009
+ optionsMap: n,
2010
+ ...w(s)
2011
+ });
2012
+ }
2013
+ }
2014
+ function Ge(t, e) {
2015
+ const r = K(t), s = K(e);
2016
+ if (t === e)
2017
+ return { valid: !0, data: t };
2018
+ if (r === m.object && s === m.object) {
2019
+ const n = S.objectKeys(e), i = S.objectKeys(t).filter((a) => n.indexOf(a) !== -1), o = { ...t, ...e };
2020
+ for (const a of i) {
2021
+ const h = Ge(t[a], e[a]);
2022
+ if (!h.valid)
2023
+ return { valid: !1 };
2024
+ o[a] = h.data;
2025
+ }
2026
+ return { valid: !0, data: o };
2027
+ } else if (r === m.array && s === m.array) {
2028
+ if (t.length !== e.length)
2029
+ return { valid: !1 };
2030
+ const n = [];
2031
+ for (let i = 0; i < t.length; i++) {
2032
+ const o = t[i], a = e[i], h = Ge(o, a);
2033
+ if (!h.valid)
2034
+ return { valid: !1 };
2035
+ n.push(h.data);
2036
+ }
2037
+ return { valid: !0, data: n };
2038
+ } else return r === m.date && s === m.date && +t == +e ? { valid: !0, data: t } : { valid: !1 };
2039
+ }
2040
+ class Ie extends I {
2041
+ _parse(e) {
2042
+ const { status: r, ctx: s } = this._processInputParams(e), n = (i, o) => {
2043
+ if (pt(i) || pt(o))
2044
+ return v;
2045
+ const a = Ge(i.value, o.value);
2046
+ return a.valid ? ((mt(i) || mt(o)) && r.dirty(), { status: r.value, value: a.data }) : (p(s, {
2047
+ code: u.invalid_intersection_types
2048
+ }), v);
2049
+ };
2050
+ return s.common.async ? Promise.all([
2051
+ this._def.left._parseAsync({
2052
+ data: s.data,
2053
+ path: s.path,
2054
+ parent: s
2055
+ }),
2056
+ this._def.right._parseAsync({
2057
+ data: s.data,
2058
+ path: s.path,
2059
+ parent: s
2060
+ })
2061
+ ]).then(([i, o]) => n(i, o)) : n(this._def.left._parseSync({
2062
+ data: s.data,
2063
+ path: s.path,
2064
+ parent: s
2065
+ }), this._def.right._parseSync({
2066
+ data: s.data,
2067
+ path: s.path,
2068
+ parent: s
2069
+ }));
2070
+ }
2071
+ }
2072
+ Ie.create = (t, e, r) => new Ie({
2073
+ left: t,
2074
+ right: e,
2075
+ typeName: k.ZodIntersection,
2076
+ ...w(r)
2077
+ });
2078
+ class z extends I {
2079
+ _parse(e) {
2080
+ const { status: r, ctx: s } = this._processInputParams(e);
2081
+ if (s.parsedType !== m.array)
2082
+ return p(s, {
2083
+ code: u.invalid_type,
2084
+ expected: m.array,
2085
+ received: s.parsedType
2086
+ }), v;
2087
+ if (s.data.length < this._def.items.length)
2088
+ return p(s, {
2089
+ code: u.too_small,
2090
+ minimum: this._def.items.length,
2091
+ inclusive: !0,
2092
+ exact: !1,
2093
+ type: "array"
2094
+ }), v;
2095
+ !this._def.rest && s.data.length > this._def.items.length && (p(s, {
2096
+ code: u.too_big,
2097
+ maximum: this._def.items.length,
2098
+ inclusive: !0,
2099
+ exact: !1,
2100
+ type: "array"
2101
+ }), r.dirty());
2102
+ const i = [...s.data].map((o, a) => {
2103
+ const h = this._def.items[a] || this._def.rest;
2104
+ return h ? h._parse(new F(s, o, s.path, a)) : null;
2105
+ }).filter((o) => !!o);
2106
+ return s.common.async ? Promise.all(i).then((o) => $.mergeArray(r, o)) : $.mergeArray(r, i);
2107
+ }
2108
+ get items() {
2109
+ return this._def.items;
2110
+ }
2111
+ rest(e) {
2112
+ return new z({
2113
+ ...this._def,
2114
+ rest: e
2115
+ });
2116
+ }
2117
+ }
2118
+ z.create = (t, e) => {
2119
+ if (!Array.isArray(t))
2120
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
2121
+ return new z({
2122
+ items: t,
2123
+ typeName: k.ZodTuple,
2124
+ rest: null,
2125
+ ...w(e)
2126
+ });
2127
+ };
2128
+ class Se extends I {
2129
+ get keySchema() {
2130
+ return this._def.keyType;
2131
+ }
2132
+ get valueSchema() {
2133
+ return this._def.valueType;
2134
+ }
2135
+ _parse(e) {
2136
+ const { status: r, ctx: s } = this._processInputParams(e);
2137
+ if (s.parsedType !== m.object)
2138
+ return p(s, {
2139
+ code: u.invalid_type,
2140
+ expected: m.object,
2141
+ received: s.parsedType
2142
+ }), v;
2143
+ const n = [], i = this._def.keyType, o = this._def.valueType;
2144
+ for (const a in s.data)
2145
+ n.push({
2146
+ key: i._parse(new F(s, a, s.path, a)),
2147
+ value: o._parse(new F(s, s.data[a], s.path, a)),
2148
+ alwaysSet: a in s.data
2149
+ });
2150
+ return s.common.async ? $.mergeObjectAsync(r, n) : $.mergeObjectSync(r, n);
2151
+ }
2152
+ get element() {
2153
+ return this._def.valueType;
2154
+ }
2155
+ static create(e, r, s) {
2156
+ return r instanceof I ? new Se({
2157
+ keyType: e,
2158
+ valueType: r,
2159
+ typeName: k.ZodRecord,
2160
+ ...w(s)
2161
+ }) : new Se({
2162
+ keyType: U.create(),
2163
+ valueType: e,
2164
+ typeName: k.ZodRecord,
2165
+ ...w(r)
2166
+ });
2167
+ }
2168
+ }
2169
+ class Je extends I {
2170
+ get keySchema() {
2171
+ return this._def.keyType;
2172
+ }
2173
+ get valueSchema() {
2174
+ return this._def.valueType;
2175
+ }
2176
+ _parse(e) {
2177
+ const { status: r, ctx: s } = this._processInputParams(e);
2178
+ if (s.parsedType !== m.map)
2179
+ return p(s, {
2180
+ code: u.invalid_type,
2181
+ expected: m.map,
2182
+ received: s.parsedType
2183
+ }), v;
2184
+ const n = this._def.keyType, i = this._def.valueType, o = [...s.data.entries()].map(([a, h], l) => ({
2185
+ key: n._parse(new F(s, a, s.path, [l, "key"])),
2186
+ value: i._parse(new F(s, h, s.path, [l, "value"]))
2187
+ }));
2188
+ if (s.common.async) {
2189
+ const a = /* @__PURE__ */ new Map();
2190
+ return Promise.resolve().then(async () => {
2191
+ for (const h of o) {
2192
+ const l = await h.key, _ = await h.value;
2193
+ if (l.status === "aborted" || _.status === "aborted")
2194
+ return v;
2195
+ (l.status === "dirty" || _.status === "dirty") && r.dirty(), a.set(l.value, _.value);
2196
+ }
2197
+ return { status: r.value, value: a };
2198
+ });
2199
+ } else {
2200
+ const a = /* @__PURE__ */ new Map();
2201
+ for (const h of o) {
2202
+ const l = h.key, _ = h.value;
2203
+ if (l.status === "aborted" || _.status === "aborted")
2204
+ return v;
2205
+ (l.status === "dirty" || _.status === "dirty") && r.dirty(), a.set(l.value, _.value);
2206
+ }
2207
+ return { status: r.value, value: a };
2208
+ }
2209
+ }
2210
+ }
2211
+ Je.create = (t, e, r) => new Je({
2212
+ valueType: e,
2213
+ keyType: t,
2214
+ typeName: k.ZodMap,
2215
+ ...w(r)
2216
+ });
2217
+ class he extends I {
2218
+ _parse(e) {
2219
+ const { status: r, ctx: s } = this._processInputParams(e);
2220
+ if (s.parsedType !== m.set)
2221
+ return p(s, {
2222
+ code: u.invalid_type,
2223
+ expected: m.set,
2224
+ received: s.parsedType
2225
+ }), v;
2226
+ const n = this._def;
2227
+ n.minSize !== null && s.data.size < n.minSize.value && (p(s, {
2228
+ code: u.too_small,
2229
+ minimum: n.minSize.value,
2230
+ type: "set",
2231
+ inclusive: !0,
2232
+ exact: !1,
2233
+ message: n.minSize.message
2234
+ }), r.dirty()), n.maxSize !== null && s.data.size > n.maxSize.value && (p(s, {
2235
+ code: u.too_big,
2236
+ maximum: n.maxSize.value,
2237
+ type: "set",
2238
+ inclusive: !0,
2239
+ exact: !1,
2240
+ message: n.maxSize.message
2241
+ }), r.dirty());
2242
+ const i = this._def.valueType;
2243
+ function o(h) {
2244
+ const l = /* @__PURE__ */ new Set();
2245
+ for (const _ of h) {
2246
+ if (_.status === "aborted")
2247
+ return v;
2248
+ _.status === "dirty" && r.dirty(), l.add(_.value);
2249
+ }
2250
+ return { status: r.value, value: l };
2251
+ }
2252
+ const a = [...s.data.values()].map((h, l) => i._parse(new F(s, h, s.path, l)));
2253
+ return s.common.async ? Promise.all(a).then((h) => o(h)) : o(a);
2254
+ }
2255
+ min(e, r) {
2256
+ return new he({
2257
+ ...this._def,
2258
+ minSize: { value: e, message: g.toString(r) }
2259
+ });
2260
+ }
2261
+ max(e, r) {
2262
+ return new he({
2263
+ ...this._def,
2264
+ maxSize: { value: e, message: g.toString(r) }
2265
+ });
2266
+ }
2267
+ size(e, r) {
2268
+ return this.min(e, r).max(e, r);
2269
+ }
2270
+ nonempty(e) {
2271
+ return this.min(1, e);
2272
+ }
2273
+ }
2274
+ he.create = (t, e) => new he({
2275
+ valueType: t,
2276
+ minSize: null,
2277
+ maxSize: null,
2278
+ typeName: k.ZodSet,
2279
+ ...w(e)
2280
+ });
2281
+ class ve extends I {
2282
+ constructor() {
2283
+ super(...arguments), this.validate = this.implement;
2284
+ }
2285
+ _parse(e) {
2286
+ const { ctx: r } = this._processInputParams(e);
2287
+ if (r.parsedType !== m.function)
2288
+ return p(r, {
2289
+ code: u.invalid_type,
2290
+ expected: m.function,
2291
+ received: r.parsedType
2292
+ }), v;
2293
+ function s(a, h) {
2294
+ return Be({
2295
+ data: a,
2296
+ path: r.path,
2297
+ errorMaps: [r.common.contextualErrorMap, r.schemaErrorMap, ze(), ke].filter((l) => !!l),
2298
+ issueData: {
2299
+ code: u.invalid_arguments,
2300
+ argumentsError: h
2301
+ }
2302
+ });
2303
+ }
2304
+ function n(a, h) {
2305
+ return Be({
2306
+ data: a,
2307
+ path: r.path,
2308
+ errorMaps: [r.common.contextualErrorMap, r.schemaErrorMap, ze(), ke].filter((l) => !!l),
2309
+ issueData: {
2310
+ code: u.invalid_return_type,
2311
+ returnTypeError: h
2312
+ }
2313
+ });
2314
+ }
2315
+ const i = { errorMap: r.common.contextualErrorMap }, o = r.data;
2316
+ if (this._def.returns instanceof pe) {
2317
+ const a = this;
2318
+ return L(async function(...h) {
2319
+ const l = new j([]), _ = await a._def.args.parseAsync(h, i).catch((oe) => {
2320
+ throw l.addIssue(s(h, oe)), l;
2321
+ }), E = await Reflect.apply(o, this, _);
2322
+ return await a._def.returns._def.type.parseAsync(E, i).catch((oe) => {
2323
+ throw l.addIssue(n(E, oe)), l;
2324
+ });
2325
+ });
2326
+ } else {
2327
+ const a = this;
2328
+ return L(function(...h) {
2329
+ const l = a._def.args.safeParse(h, i);
2330
+ if (!l.success)
2331
+ throw new j([s(h, l.error)]);
2332
+ const _ = Reflect.apply(o, this, l.data), E = a._def.returns.safeParse(_, i);
2333
+ if (!E.success)
2334
+ throw new j([n(_, E.error)]);
2335
+ return E.data;
2336
+ });
2337
+ }
2338
+ }
2339
+ parameters() {
2340
+ return this._def.args;
2341
+ }
2342
+ returnType() {
2343
+ return this._def.returns;
2344
+ }
2345
+ args(...e) {
2346
+ return new ve({
2347
+ ...this._def,
2348
+ args: z.create(e).rest(re.create())
2349
+ });
2350
+ }
2351
+ returns(e) {
2352
+ return new ve({
2353
+ ...this._def,
2354
+ returns: e
2355
+ });
2356
+ }
2357
+ implement(e) {
2358
+ return this.parse(e);
2359
+ }
2360
+ strictImplement(e) {
2361
+ return this.parse(e);
2362
+ }
2363
+ static create(e, r, s) {
2364
+ return new ve({
2365
+ args: e || z.create([]).rest(re.create()),
2366
+ returns: r || re.create(),
2367
+ typeName: k.ZodFunction,
2368
+ ...w(s)
2369
+ });
2370
+ }
2371
+ }
2372
+ class Pe extends I {
2373
+ get schema() {
2374
+ return this._def.getter();
2375
+ }
2376
+ _parse(e) {
2377
+ const { ctx: r } = this._processInputParams(e);
2378
+ return this._def.getter()._parse({ data: r.data, path: r.path, parent: r });
2379
+ }
2380
+ }
2381
+ Pe.create = (t, e) => new Pe({
2382
+ getter: t,
2383
+ typeName: k.ZodLazy,
2384
+ ...w(e)
2385
+ });
2386
+ class Ee extends I {
2387
+ _parse(e) {
2388
+ if (e.data !== this._def.value) {
2389
+ const r = this._getOrReturnCtx(e);
2390
+ return p(r, {
2391
+ received: r.data,
2392
+ code: u.invalid_literal,
2393
+ expected: this._def.value
2394
+ }), v;
2395
+ }
2396
+ return { status: "valid", value: e.data };
2397
+ }
2398
+ get value() {
2399
+ return this._def.value;
2400
+ }
2401
+ }
2402
+ Ee.create = (t, e) => new Ee({
2403
+ value: t,
2404
+ typeName: k.ZodLiteral,
2405
+ ...w(e)
2406
+ });
2407
+ function It(t, e) {
2408
+ return new Q({
2409
+ values: t,
2410
+ typeName: k.ZodEnum,
2411
+ ...w(e)
2412
+ });
2413
+ }
2414
+ class Q extends I {
2415
+ _parse(e) {
2416
+ if (typeof e.data != "string") {
2417
+ const r = this._getOrReturnCtx(e), s = this._def.values;
2418
+ return p(r, {
2419
+ expected: S.joinValues(s),
2420
+ received: r.parsedType,
2421
+ code: u.invalid_type
2422
+ }), v;
2423
+ }
2424
+ if (this._cache || (this._cache = new Set(this._def.values)), !this._cache.has(e.data)) {
2425
+ const r = this._getOrReturnCtx(e), s = this._def.values;
2426
+ return p(r, {
2427
+ received: r.data,
2428
+ code: u.invalid_enum_value,
2429
+ options: s
2430
+ }), v;
2431
+ }
2432
+ return L(e.data);
2433
+ }
2434
+ get options() {
2435
+ return this._def.values;
2436
+ }
2437
+ get enum() {
2438
+ const e = {};
2439
+ for (const r of this._def.values)
2440
+ e[r] = r;
2441
+ return e;
2442
+ }
2443
+ get Values() {
2444
+ const e = {};
2445
+ for (const r of this._def.values)
2446
+ e[r] = r;
2447
+ return e;
2448
+ }
2449
+ get Enum() {
2450
+ const e = {};
2451
+ for (const r of this._def.values)
2452
+ e[r] = r;
2453
+ return e;
2454
+ }
2455
+ extract(e, r = this._def) {
2456
+ return Q.create(e, {
2457
+ ...this._def,
2458
+ ...r
2459
+ });
2460
+ }
2461
+ exclude(e, r = this._def) {
2462
+ return Q.create(this.options.filter((s) => !e.includes(s)), {
2463
+ ...this._def,
2464
+ ...r
2465
+ });
2466
+ }
2467
+ }
2468
+ Q.create = It;
2469
+ class Ye extends I {
2470
+ _parse(e) {
2471
+ const r = S.getValidEnumValues(this._def.values), s = this._getOrReturnCtx(e);
2472
+ if (s.parsedType !== m.string && s.parsedType !== m.number) {
2473
+ const n = S.objectValues(r);
2474
+ return p(s, {
2475
+ expected: S.joinValues(n),
2476
+ received: s.parsedType,
2477
+ code: u.invalid_type
2478
+ }), v;
2479
+ }
2480
+ if (this._cache || (this._cache = new Set(S.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
2481
+ const n = S.objectValues(r);
2482
+ return p(s, {
2483
+ received: s.data,
2484
+ code: u.invalid_enum_value,
2485
+ options: n
2486
+ }), v;
2487
+ }
2488
+ return L(e.data);
2489
+ }
2490
+ get enum() {
2491
+ return this._def.values;
2492
+ }
2493
+ }
2494
+ Ye.create = (t, e) => new Ye({
2495
+ values: t,
2496
+ typeName: k.ZodNativeEnum,
2497
+ ...w(e)
2498
+ });
2499
+ class pe extends I {
2500
+ unwrap() {
2501
+ return this._def.type;
2502
+ }
2503
+ _parse(e) {
2504
+ const { ctx: r } = this._processInputParams(e);
2505
+ if (r.parsedType !== m.promise && r.common.async === !1)
2506
+ return p(r, {
2507
+ code: u.invalid_type,
2508
+ expected: m.promise,
2509
+ received: r.parsedType
2510
+ }), v;
2511
+ const s = r.parsedType === m.promise ? r.data : Promise.resolve(r.data);
2512
+ return L(s.then((n) => this._def.type.parseAsync(n, {
2513
+ path: r.path,
2514
+ errorMap: r.common.contextualErrorMap
2515
+ })));
2516
+ }
2517
+ }
2518
+ pe.create = (t, e) => new pe({
2519
+ type: t,
2520
+ typeName: k.ZodPromise,
2521
+ ...w(e)
2522
+ });
2523
+ class G extends I {
2524
+ innerType() {
2525
+ return this._def.schema;
2526
+ }
2527
+ sourceType() {
2528
+ return this._def.schema._def.typeName === k.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
2529
+ }
2530
+ _parse(e) {
2531
+ const { status: r, ctx: s } = this._processInputParams(e), n = this._def.effect || null, i = {
2532
+ addIssue: (o) => {
2533
+ p(s, o), o.fatal ? r.abort() : r.dirty();
2534
+ },
2535
+ get path() {
2536
+ return s.path;
2537
+ }
2538
+ };
2539
+ if (i.addIssue = i.addIssue.bind(i), n.type === "preprocess") {
2540
+ const o = n.transform(s.data, i);
2541
+ if (s.common.async)
2542
+ return Promise.resolve(o).then(async (a) => {
2543
+ if (r.value === "aborted")
2544
+ return v;
2545
+ const h = await this._def.schema._parseAsync({
2546
+ data: a,
2547
+ path: s.path,
2548
+ parent: s
2549
+ });
2550
+ return h.status === "aborted" ? v : h.status === "dirty" || r.value === "dirty" ? be(h.value) : h;
2551
+ });
2552
+ {
2553
+ if (r.value === "aborted")
2554
+ return v;
2555
+ const a = this._def.schema._parseSync({
2556
+ data: o,
2557
+ path: s.path,
2558
+ parent: s
2559
+ });
2560
+ return a.status === "aborted" ? v : a.status === "dirty" || r.value === "dirty" ? be(a.value) : a;
2561
+ }
2562
+ }
2563
+ if (n.type === "refinement") {
2564
+ const o = (a) => {
2565
+ const h = n.refinement(a, i);
2566
+ if (s.common.async)
2567
+ return Promise.resolve(h);
2568
+ if (h instanceof Promise)
2569
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
2570
+ return a;
2571
+ };
2572
+ if (s.common.async === !1) {
2573
+ const a = this._def.schema._parseSync({
2574
+ data: s.data,
2575
+ path: s.path,
2576
+ parent: s
2577
+ });
2578
+ return a.status === "aborted" ? v : (a.status === "dirty" && r.dirty(), o(a.value), { status: r.value, value: a.value });
2579
+ } else
2580
+ return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((a) => a.status === "aborted" ? v : (a.status === "dirty" && r.dirty(), o(a.value).then(() => ({ status: r.value, value: a.value }))));
2581
+ }
2582
+ if (n.type === "transform")
2583
+ if (s.common.async === !1) {
2584
+ const o = this._def.schema._parseSync({
2585
+ data: s.data,
2586
+ path: s.path,
2587
+ parent: s
2588
+ });
2589
+ if (!fe(o))
2590
+ return v;
2591
+ const a = n.transform(o.value, i);
2592
+ if (a instanceof Promise)
2593
+ throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
2594
+ return { status: r.value, value: a };
2595
+ } else
2596
+ return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((o) => fe(o) ? Promise.resolve(n.transform(o.value, i)).then((a) => ({
2597
+ status: r.value,
2598
+ value: a
2599
+ })) : v);
2600
+ S.assertNever(n);
2601
+ }
2602
+ }
2603
+ G.create = (t, e, r) => new G({
2604
+ schema: t,
2605
+ typeName: k.ZodEffects,
2606
+ effect: e,
2607
+ ...w(r)
2608
+ });
2609
+ G.createWithPreprocess = (t, e, r) => new G({
2610
+ schema: e,
2611
+ effect: { type: "preprocess", transform: t },
2612
+ typeName: k.ZodEffects,
2613
+ ...w(r)
2614
+ });
2615
+ class W extends I {
2616
+ _parse(e) {
2617
+ return this._getType(e) === m.undefined ? L(void 0) : this._def.innerType._parse(e);
2618
+ }
2619
+ unwrap() {
2620
+ return this._def.innerType;
2621
+ }
2622
+ }
2623
+ W.create = (t, e) => new W({
2624
+ innerType: t,
2625
+ typeName: k.ZodOptional,
2626
+ ...w(e)
2627
+ });
2628
+ class ee extends I {
2629
+ _parse(e) {
2630
+ return this._getType(e) === m.null ? L(null) : this._def.innerType._parse(e);
2631
+ }
2632
+ unwrap() {
2633
+ return this._def.innerType;
2634
+ }
2635
+ }
2636
+ ee.create = (t, e) => new ee({
2637
+ innerType: t,
2638
+ typeName: k.ZodNullable,
2639
+ ...w(e)
2640
+ });
2641
+ class Ae extends I {
2642
+ _parse(e) {
2643
+ const { ctx: r } = this._processInputParams(e);
2644
+ let s = r.data;
2645
+ return r.parsedType === m.undefined && (s = this._def.defaultValue()), this._def.innerType._parse({
2646
+ data: s,
2647
+ path: r.path,
2648
+ parent: r
2649
+ });
2650
+ }
2651
+ removeDefault() {
2652
+ return this._def.innerType;
2653
+ }
2654
+ }
2655
+ Ae.create = (t, e) => new Ae({
2656
+ innerType: t,
2657
+ typeName: k.ZodDefault,
2658
+ defaultValue: typeof e.default == "function" ? e.default : () => e.default,
2659
+ ...w(e)
2660
+ });
2661
+ class Re extends I {
2662
+ _parse(e) {
2663
+ const { ctx: r } = this._processInputParams(e), s = {
2664
+ ...r,
2665
+ common: {
2666
+ ...r.common,
2667
+ issues: []
2668
+ }
2669
+ }, n = this._def.innerType._parse({
2670
+ data: s.data,
2671
+ path: s.path,
2672
+ parent: {
2673
+ ...s
2674
+ }
2675
+ });
2676
+ return $e(n) ? n.then((i) => ({
2677
+ status: "valid",
2678
+ value: i.status === "valid" ? i.value : this._def.catchValue({
2679
+ get error() {
2680
+ return new j(s.common.issues);
2681
+ },
2682
+ input: s.data
2683
+ })
2684
+ })) : {
2685
+ status: "valid",
2686
+ value: n.status === "valid" ? n.value : this._def.catchValue({
2687
+ get error() {
2688
+ return new j(s.common.issues);
2689
+ },
2690
+ input: s.data
2691
+ })
2692
+ };
2693
+ }
2694
+ removeCatch() {
2695
+ return this._def.innerType;
2696
+ }
2697
+ }
2698
+ Re.create = (t, e) => new Re({
2699
+ innerType: t,
2700
+ typeName: k.ZodCatch,
2701
+ catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
2702
+ ...w(e)
2703
+ });
2704
+ class Ke extends I {
2705
+ _parse(e) {
2706
+ if (this._getType(e) !== m.nan) {
2707
+ const s = this._getOrReturnCtx(e);
2708
+ return p(s, {
2709
+ code: u.invalid_type,
2710
+ expected: m.nan,
2711
+ received: s.parsedType
2712
+ }), v;
2713
+ }
2714
+ return { status: "valid", value: e.data };
2715
+ }
2716
+ }
2717
+ Ke.create = (t) => new Ke({
2718
+ typeName: k.ZodNaN,
2719
+ ...w(t)
2720
+ });
2721
+ class nt extends I {
2722
+ _parse(e) {
2723
+ const { ctx: r } = this._processInputParams(e), s = r.data;
2724
+ return this._def.type._parse({
2725
+ data: s,
2726
+ path: r.path,
2727
+ parent: r
2728
+ });
2729
+ }
2730
+ unwrap() {
2731
+ return this._def.type;
2732
+ }
2733
+ }
2734
+ class We extends I {
2735
+ _parse(e) {
2736
+ const { status: r, ctx: s } = this._processInputParams(e);
2737
+ if (s.common.async)
2738
+ return (async () => {
2739
+ const i = await this._def.in._parseAsync({
2740
+ data: s.data,
2741
+ path: s.path,
2742
+ parent: s
2743
+ });
2744
+ return i.status === "aborted" ? v : i.status === "dirty" ? (r.dirty(), be(i.value)) : this._def.out._parseAsync({
2745
+ data: i.value,
2746
+ path: s.path,
2747
+ parent: s
2748
+ });
2749
+ })();
2750
+ {
2751
+ const n = this._def.in._parseSync({
2752
+ data: s.data,
2753
+ path: s.path,
2754
+ parent: s
2755
+ });
2756
+ return n.status === "aborted" ? v : n.status === "dirty" ? (r.dirty(), {
2757
+ status: "dirty",
2758
+ value: n.value
2759
+ }) : this._def.out._parseSync({
2760
+ data: n.value,
2761
+ path: s.path,
2762
+ parent: s
2763
+ });
2764
+ }
2765
+ }
2766
+ static create(e, r) {
2767
+ return new We({
2768
+ in: e,
2769
+ out: r,
2770
+ typeName: k.ZodPipeline
2771
+ });
2772
+ }
2773
+ }
2774
+ class Ce extends I {
2775
+ _parse(e) {
2776
+ const r = this._def.innerType._parse(e), s = (n) => (fe(n) && (n.value = Object.freeze(n.value)), n);
2777
+ return $e(r) ? r.then((n) => s(n)) : s(r);
2778
+ }
2779
+ unwrap() {
2780
+ return this._def.innerType;
2781
+ }
2782
+ }
2783
+ Ce.create = (t, e) => new Ce({
2784
+ innerType: t,
2785
+ typeName: k.ZodReadonly,
2786
+ ...w(e)
2787
+ });
2788
+ var k;
2789
+ (function(t) {
2790
+ t.ZodString = "ZodString", t.ZodNumber = "ZodNumber", t.ZodNaN = "ZodNaN", t.ZodBigInt = "ZodBigInt", t.ZodBoolean = "ZodBoolean", t.ZodDate = "ZodDate", t.ZodSymbol = "ZodSymbol", t.ZodUndefined = "ZodUndefined", t.ZodNull = "ZodNull", t.ZodAny = "ZodAny", t.ZodUnknown = "ZodUnknown", t.ZodNever = "ZodNever", t.ZodVoid = "ZodVoid", t.ZodArray = "ZodArray", t.ZodObject = "ZodObject", t.ZodUnion = "ZodUnion", t.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", t.ZodIntersection = "ZodIntersection", t.ZodTuple = "ZodTuple", t.ZodRecord = "ZodRecord", t.ZodMap = "ZodMap", t.ZodSet = "ZodSet", t.ZodFunction = "ZodFunction", t.ZodLazy = "ZodLazy", t.ZodLiteral = "ZodLiteral", t.ZodEnum = "ZodEnum", t.ZodEffects = "ZodEffects", t.ZodNativeEnum = "ZodNativeEnum", t.ZodOptional = "ZodOptional", t.ZodNullable = "ZodNullable", t.ZodDefault = "ZodDefault", t.ZodCatch = "ZodCatch", t.ZodPromise = "ZodPromise", t.ZodBranded = "ZodBranded", t.ZodPipeline = "ZodPipeline", t.ZodReadonly = "ZodReadonly";
2791
+ })(k || (k = {}));
2792
+ const d = U.create, f = se.create, B = ne.create, x = Le.create, St = xe.create, b = re.create;
2793
+ X.create;
2794
+ const A = D.create, c = R.create, T = Te.create;
2795
+ Ie.create;
2796
+ const cr = z.create, y = Se.create, lr = Ee.create, Xe = Q.create;
2797
+ pe.create;
2798
+ W.create;
2799
+ ee.create;
2800
+ const J = G.createWithPreprocess, P = () => T([B(), f().finite()]).transform((t) => BigInt(t));
2801
+ c({
2802
+ key: d().describe("Storage key to retrieve")
2803
+ });
2804
+ c({
2805
+ key: d().describe("Storage key to set"),
2806
+ value: d().describe("Value to store")
2807
+ });
2808
+ c({
2809
+ key: d().describe("Storage key to delete")
2810
+ });
2811
+ c({});
2812
+ const ur = c({
2813
+ items: y(d()).describe("Record of key-value string pairs to store")
2814
+ });
2815
+ J((t) => t !== null && typeof t == "object" && !Array.isArray(t) && !("items" in t) ? { items: t } : t, ur);
2816
+ const fr = c({
2817
+ keys: A(d()).describe("Array of storage keys to retrieve"),
2818
+ defaults: y(d()).optional().describe("Default string values for missing keys")
2819
+ });
2820
+ J(
2821
+ (t) => Array.isArray(t) ? { keys: t } : t,
2822
+ fr
2823
+ );
2824
+ c({});
2825
+ const hr = c({
2826
+ keys: A(d()).describe("Array of storage keys to delete")
2827
+ });
2828
+ J(
2829
+ (t) => Array.isArray(t) ? { keys: t } : t,
2830
+ hr
2831
+ );
2832
+ c({});
2833
+ c({});
2834
+ T([
2835
+ cr([T([c({ text: d() }), d()])]),
2836
+ c({ text: d().optional(), value: d().optional() })
2837
+ ]);
2838
+ c({
2839
+ url: d().describe("URL to fetch"),
2840
+ method: d().default("GET").describe("HTTP method (GET, POST, PUT, DELETE, etc.)"),
2841
+ headers: y(d()).default({}).describe("Request headers as key-value pairs"),
2842
+ body: d().nullable().default(null).describe("Request body string"),
2843
+ timeout: P().default(30000n).describe("Timeout in milliseconds"),
2844
+ options: c({}).passthrough().optional().describe("Fetch options")
2845
+ }).passthrough();
2846
+ c({
2847
+ duration: P().describe("Duration to sleep in milliseconds")
2848
+ });
2849
+ const ie = () => d().regex(/^e\d+$/), pr = 'use { refId: "e2" } or { label: "..." } object form, not positional arguments', it = (t, e) => {
2850
+ if (t.__invalidPositional !== void 0) {
2851
+ e.addIssue({
2852
+ code: u.custom,
2853
+ message: pr
2854
+ });
2855
+ return;
2856
+ }
2857
+ !t.refId && !t.label && e.addIssue({
2858
+ code: u.custom,
2859
+ message: "Either refId or label is required"
2860
+ });
2861
+ }, Et = (t, e) => {
2862
+ t.x !== void 0 || t.y !== void 0 || it(t, e);
2863
+ }, M = (t) => J(
2864
+ (e) => typeof e == "string" || typeof e == "number" ? { __invalidPositional: e } : e,
2865
+ c({
2866
+ __invalidPositional: T([d(), f()]).optional().describe("Internal flag for positional argument rejection"),
2867
+ refId: ie().optional().describe("Element reference ID (e.g. e2)"),
2868
+ label: d().optional().describe("Human-readable element label"),
2869
+ ...t
2870
+ }).superRefine(it)
2871
+ ), Oe = { tabId: T([f(), B()]).optional().describe("Target tab ID") }, ae = (t) => J(
2872
+ (e) => typeof e == "string" || typeof e == "number" ? { __invalidPositional: e } : e,
2873
+ c({
2874
+ __invalidPositional: T([d(), f()]).optional().describe("Internal flag for positional argument rejection"),
2875
+ ...Oe,
2876
+ refId: ie().optional().describe("Element reference ID (e.g. e2)"),
2877
+ label: d().optional().describe("Human-readable element label"),
2878
+ ...t
2879
+ }).superRefine(it)
2880
+ );
2881
+ c({});
2882
+ c({});
2883
+ c({
2884
+ url: d().describe("URL to navigate to"),
2885
+ timeout: P().optional().describe("Navigation timeout in milliseconds")
2886
+ });
2887
+ c({});
2888
+ c({});
2889
+ c({});
2890
+ c({
2891
+ duration: P().default(1000n).describe("Duration to wait in milliseconds")
2892
+ });
2893
+ M();
2894
+ M({ value: d().describe("Value to fill into the element") });
2895
+ M({ text: d().describe("Text to type into the element") });
2896
+ M({ text: d().describe("Text to append into the element") });
2897
+ c({
2898
+ key: d().describe("Key to press (e.g. Enter, Escape, ArrowDown)")
2899
+ });
2900
+ M({ value: d().describe("Value to select in the dropdown") });
2901
+ M({
2902
+ checked: x().optional().describe("Desired checked state (true to check, false to uncheck)")
2903
+ });
2904
+ M();
2905
+ c({});
2906
+ c({
2907
+ direction: d().default("down").describe("Scroll direction: up, down, left, or right"),
2908
+ amount: f().default(300).describe("Pixels to scroll")
2909
+ });
2910
+ J(
2911
+ (t) => typeof t == "string" || typeof t == "number" ? { __invalidPositional: t } : t,
2912
+ c({
2913
+ __invalidPositional: T([d(), f()]).optional().describe("Internal flag for positional argument rejection"),
2914
+ refId: ie().optional().describe("Element reference ID (e.g. e2)"),
2915
+ label: d().optional().describe("Human-readable element label"),
2916
+ x: f().optional().describe("X coordinate to scroll to"),
2917
+ y: f().optional().describe("Y coordinate to scroll to")
2918
+ }).superRefine(Et)
2919
+ );
2920
+ M();
2921
+ c({
2922
+ selector: d().describe("CSS selector to find elements")
2923
+ });
2924
+ c({
2925
+ selector: d().describe("CSS selector to wait for"),
2926
+ timeout: P().default(30000n).describe("Timeout in milliseconds")
2927
+ });
2928
+ const mr = c({
2929
+ fields: A(d()).describe("Array of field names to extract")
2930
+ });
2931
+ J(
2932
+ (t) => Array.isArray(t) ? { fields: t } : t,
2933
+ mr
2934
+ );
2935
+ T([
2936
+ f(),
2937
+ A(c({}).passthrough()),
2938
+ c({}).passthrough()
2939
+ ]);
2940
+ c({});
2941
+ c({
2942
+ active: x().optional().describe("Whether the tabs are active"),
2943
+ currentWindow: x().optional().describe("Whether the tabs are in the current window"),
2944
+ url: d().optional().describe("URL pattern to match tabs against")
2945
+ }).passthrough();
2946
+ J(
2947
+ (t) => typeof t == "string" ? { url: t } : t,
2948
+ c({
2949
+ url: d().optional().describe("URL to open in the new tab"),
2950
+ active: x().optional().describe("Whether to focus the new tab")
2951
+ })
2952
+ );
2953
+ T([
2954
+ f(),
2955
+ A(c({ id: f().optional(), tabId: f().optional(), tab_id: f().optional() }).passthrough()),
2956
+ c({ id: f().optional(), tabId: f().optional(), tab_id: f().optional() }).passthrough()
2957
+ ]);
2958
+ ae();
2959
+ ae({ value: d().describe("Value to fill into the element") });
2960
+ J(
2961
+ (t) => typeof t == "string" || typeof t == "number" ? { __invalidPositional: t } : t,
2962
+ c({
2963
+ __invalidPositional: T([d(), f()]).optional().describe("Internal flag for positional argument rejection"),
2964
+ ...Oe,
2965
+ refId: ie().optional().describe("Element reference ID (e.g. e2)"),
2966
+ label: d().optional().describe("Human-readable element label"),
2967
+ x: f().optional().describe("X coordinate to scroll to"),
2968
+ y: f().optional().describe("Y coordinate to scroll to")
2969
+ }).superRefine(Et)
2970
+ );
2971
+ ae({ text: d().describe("Text to type into the element") });
2972
+ c({
2973
+ ...Oe,
2974
+ key: d().describe("Key to press (e.g. Enter, Escape, ArrowDown)")
2975
+ });
2976
+ ae({ value: d().describe("Value to select in the dropdown") });
2977
+ ae({
2978
+ checked: x().optional().describe("Desired checked state (true to check, false to uncheck)")
2979
+ });
2980
+ ae();
2981
+ c({
2982
+ ...Oe
2983
+ });
2984
+ c({
2985
+ ...Oe,
2986
+ direction: d().default("down").describe("Scroll direction: up, down, left, or right"),
2987
+ amount: f().default(300).describe("Pixels to scroll")
2988
+ });
2989
+ ae();
2990
+ c({
2991
+ tabId: T([f(), B()]).optional().describe("Target tab ID"),
2992
+ script: d().optional().describe("Script to evaluate"),
2993
+ code: d().optional().describe("Alternative script code"),
2994
+ js: d().optional().describe("Alternative JS code")
2995
+ }).passthrough();
2996
+ c({
2997
+ tabId: T([f(), B()]).optional().describe("Target tab ID")
2998
+ }).passthrough();
2999
+ c({
3000
+ tabId: T([f(), B()]).optional().describe("Target tab ID")
3001
+ }).passthrough();
3002
+ c({
3003
+ tabId: T([f(), B()]).optional().describe("Target tab ID"),
3004
+ timeout: f().optional().describe("Timeout in milliseconds")
3005
+ }).passthrough();
3006
+ c({
3007
+ tabId: T([f(), B()]).optional().describe("Target tab ID"),
3008
+ url: d().optional().describe("URL to fetch"),
3009
+ options: c({}).passthrough().optional().describe("Fetch options")
3010
+ }).passthrough();
3011
+ c({
3012
+ tabId: T([f(), B()]).optional().describe("Target tab ID"),
3013
+ max_nodes: f().optional().describe("Maximum nodes to include"),
3014
+ options: c({}).passthrough().optional().describe("Snapshot options")
3015
+ }).passthrough();
3016
+ c({
3017
+ tabId: T([f(), B()]).optional().describe("Target tab ID"),
3018
+ max_nodes: f().optional().describe("Maximum nodes to include"),
3019
+ options: c({}).passthrough().optional().describe("Snapshot options")
3020
+ }).passthrough();
3021
+ c({
3022
+ tabId: T([f(), B()]).optional().describe("Target tab ID"),
3023
+ max_nodes: f().optional().describe("Maximum nodes to include"),
3024
+ options: c({}).passthrough().optional().describe("Snapshot options")
3025
+ }).passthrough();
3026
+ M();
3027
+ M();
3028
+ M({
3029
+ value: d().optional().describe("Value to fill into the element")
3030
+ });
3031
+ M({
3032
+ text: d().optional().describe("Text to type into the element")
3033
+ });
3034
+ c({
3035
+ key: d().optional().describe("Key to press (e.g. Enter, Escape, ArrowDown)")
3036
+ });
3037
+ M({
3038
+ value: d().optional().describe("Value to select in the dropdown")
3039
+ });
3040
+ M({
3041
+ checked: x().optional().describe("Desired checked state (true to check, false to uncheck)")
3042
+ });
3043
+ M();
3044
+ c({});
3045
+ c({
3046
+ direction: d().optional().describe("Scroll direction: up, down, left, or right"),
3047
+ amount: f().optional().describe("Pixels to scroll")
3048
+ });
3049
+ M();
3050
+ M({
3051
+ text: d().optional().describe("Text to append into the element")
3052
+ });
3053
+ c({});
3054
+ c({});
3055
+ c({
3056
+ duration: P().default(1000n).describe("Duration to wait in milliseconds")
3057
+ });
3058
+ c({
3059
+ interactive_only: x().default(!1).describe("Only include interactive elements"),
3060
+ max_nodes: P().default(500n).describe("Maximum number of nodes to include in snapshot")
3061
+ });
3062
+ c({
3063
+ interactive_only: x().default(!1).describe("Only include interactive elements"),
3064
+ max_nodes: P().default(500n).describe("Maximum number of nodes to include in snapshot")
3065
+ });
3066
+ c({
3067
+ interactive_only: x().default(!1).describe("Only include interactive elements"),
3068
+ max_nodes: P().default(500n).describe("Maximum number of nodes to include in snapshot")
3069
+ });
3070
+ c({
3071
+ interactive_only: x().default(!1).describe("Only include interactive elements"),
3072
+ max_nodes: P().default(500n).describe("Maximum number of nodes to include in snapshot")
3073
+ });
3074
+ c({
3075
+ snapshot: c({}).passthrough().describe("Raw DOM snapshot data to format"),
3076
+ format: d().optional().describe("Output format (e.g. markdown, html)")
3077
+ });
3078
+ c({
3079
+ max_nodes: f().optional().describe("Maximum nodes to include"),
3080
+ options: c({}).passthrough().optional().describe("Snapshot options")
3081
+ }).passthrough();
3082
+ c({
3083
+ max_nodes: f().optional().describe("Maximum nodes to include"),
3084
+ options: c({}).passthrough().optional().describe("Snapshot options")
3085
+ }).passthrough();
3086
+ c({
3087
+ max_nodes: f().optional().describe("Maximum nodes to include"),
3088
+ options: c({}).passthrough().optional().describe("Snapshot options")
3089
+ }).passthrough();
3090
+ const Y = c({
3091
+ path: d().describe("File or directory path")
3092
+ }), bt = c({
3093
+ from: d().describe("Source path"),
3094
+ to: d().describe("Destination path")
3095
+ }), de = c({
3096
+ path: d().describe("File path to write to"),
3097
+ data: d().describe("Data to write")
3098
+ }), gr = c({
3099
+ path: d().describe("File path to read from"),
3100
+ offset: P().describe("Byte offset to start reading"),
3101
+ len: f().describe("Number of bytes to read")
3102
+ }), yr = c({
3103
+ path: d().describe("File path to update"),
3104
+ offset: P().describe("Byte offset to start writing"),
3105
+ data: d().describe("Data to write")
3106
+ }), br = c({
3107
+ path: d().describe("File path to hash"),
3108
+ algo: d().default("sha256").describe("Hash algorithm (e.g. sha256, md5)")
3109
+ });
3110
+ y(b());
3111
+ y(b());
3112
+ y(b());
3113
+ y(b());
3114
+ T([
3115
+ f(),
3116
+ y(b())
3117
+ ]);
3118
+ T([
3119
+ f(),
3120
+ y(b())
3121
+ ]);
3122
+ y(b());
3123
+ y(b());
3124
+ y(b());
3125
+ T([
3126
+ d(),
3127
+ y(b())
3128
+ ]);
3129
+ y(b());
3130
+ y(
3131
+ b()
3132
+ );
3133
+ y(b());
3134
+ y(b());
3135
+ y(b());
3136
+ T([
3137
+ d(),
3138
+ f(),
3139
+ y(b())
3140
+ ]);
3141
+ y(b());
3142
+ y(b());
3143
+ y(b());
3144
+ T([
3145
+ f(),
3146
+ y(b())
3147
+ ]);
3148
+ y(b());
3149
+ y(b());
3150
+ y(b());
3151
+ y(b());
3152
+ y(b());
3153
+ A(b());
3154
+ T([
3155
+ d(),
3156
+ y(b())
3157
+ ]);
3158
+ y(b());
3159
+ T([
3160
+ d(),
3161
+ y(b())
3162
+ ]);
3163
+ y(b());
3164
+ T([
3165
+ d(),
3166
+ y(b())
3167
+ ]);
3168
+ y(b());
3169
+ T([
3170
+ d(),
3171
+ y(b())
3172
+ ]);
3173
+ y(b());
3174
+ y(b());
3175
+ T([
3176
+ f(),
3177
+ y(b())
3178
+ ]);
3179
+ y(b());
3180
+ y(b());
3181
+ T([
3182
+ f(),
3183
+ y(b())
3184
+ ]);
3185
+ y(
3186
+ b()
3187
+ );
3188
+ T([
3189
+ d(),
3190
+ f(),
3191
+ y(b())
3192
+ ]);
3193
+ y(b());
3194
+ y(b());
3195
+ y(b());
3196
+ y(b());
3197
+ T([
3198
+ f(),
3199
+ y(b())
3200
+ ]);
3201
+ T([
3202
+ f(),
3203
+ y(b())
3204
+ ]);
3205
+ T([
3206
+ f(),
3207
+ y(b())
3208
+ ]);
3209
+ T([
3210
+ f(),
3211
+ y(b())
3212
+ ]);
3213
+ T([
3214
+ f(),
3215
+ y(b())
3216
+ ]);
3217
+ y(b());
3218
+ y(b());
3219
+ y(b());
3220
+ c({
3221
+ action: d().describe("Host action name"),
3222
+ params: c({}).passthrough().optional().describe("Parameters for the host action")
3223
+ }).passthrough();
3224
+ T([
3225
+ d(),
3226
+ f(),
3227
+ x(),
3228
+ St(),
3229
+ A(b()),
3230
+ y(b())
3231
+ ]);
3232
+ const _r = c({
3233
+ ok: lr(!0).describe("Whether the action succeeded"),
3234
+ action: d().describe("Action identifier (e.g. 'page_fill')"),
3235
+ refId: ie().optional().describe("Element reference ID that was acted upon (e.g. e2)"),
3236
+ tag: d().optional().describe("HTML tag name of the element"),
3237
+ role: d().optional().describe("ARIA role of the element"),
3238
+ name: d().optional().describe("Accessible name of the element"),
3239
+ value: d().optional().describe("Final value of the element after the action"),
3240
+ checked: x().optional().describe("Checked state after the action"),
3241
+ disabled: x().optional().describe("Whether the element is disabled"),
3242
+ readOnly: x().optional().describe("Whether the element is read-only"),
3243
+ text: d().optional().describe("Text content of the element"),
3244
+ key: d().optional().describe("Key that was pressed (for press actions)"),
3245
+ direction: d().optional().describe("Scroll direction (for scroll actions)"),
3246
+ amount: f().optional().describe("Scroll amount in pixels (for scroll actions)")
3247
+ });
3248
+ T([
3249
+ _r,
3250
+ St()
3251
+ ]);
3252
+ c({
3253
+ status: f().describe("HTTP response status code"),
3254
+ ok: x().describe("Whether the response status is 2xx"),
3255
+ headers: y(d()).describe("Response headers as key-value pairs"),
3256
+ body: d().describe("Response body as string (text or base64-encoded bytes)"),
3257
+ bodyEncoding: Xe(["text", "base64"]).describe("Encoding of the body field"),
3258
+ byteLength: f().describe("Length of the body in bytes"),
3259
+ contentType: d().describe("Response Content-Type header"),
3260
+ finalUrl: d().describe("Final URL after redirects")
3261
+ });
3262
+ c({
3263
+ data: c({}).passthrough().describe("Structured snapshot data"),
3264
+ text: d().describe("Plain text representation of the snapshot")
3265
+ });
3266
+ c({});
3267
+ c({
3268
+ tabId: f(),
3269
+ url: d(),
3270
+ title: d(),
3271
+ contentScript: Xe(["connected", "missing"]),
3272
+ domApis: Xe(["ok", "blocked"]),
3273
+ mutationsReady: x(),
3274
+ hint: d().optional(),
3275
+ recovery: A(d()).optional()
3276
+ });
3277
+ const vr = c({
3278
+ refId: ie().describe("Element reference ID (e.g. e2)"),
3279
+ role: d().describe("ARIA role of the element"),
3280
+ tag: d().describe("HTML tag name"),
3281
+ name: d().optional().describe("Accessible name of the element"),
3282
+ text: d().optional().describe("Visible text content of the element"),
3283
+ value: d().optional().describe("Element value"),
3284
+ checked: x().optional().describe("Checked state"),
3285
+ disabled: x().optional().describe("Whether the element is disabled"),
3286
+ readOnly: x().optional().describe("Whether the element is read-only"),
3287
+ href: d().optional().describe("Absolute URL for link elements"),
3288
+ src: d().optional().describe("Absolute URL for image elements"),
3289
+ alt: d().optional().describe("Alternative text for image elements"),
3290
+ title: d().optional().describe("Title attribute"),
3291
+ parentRefId: ie().optional().describe("Reference ID of the parent container element"),
3292
+ postId: d().optional().describe("Stable post identifier from data-post-id attribute"),
3293
+ permalink: d().optional().describe("Stable permalink URL from anchor element"),
3294
+ imageUrls: A(d()).optional().describe("Image URLs contained within this element")
3295
+ });
3296
+ c({
3297
+ text: d().describe("Plain text representation of the page"),
3298
+ nodes: A(vr).describe("Array of interactive nodes"),
3299
+ url: d().describe("Current page URL"),
3300
+ title: d().describe("Current page title"),
3301
+ viewport: c({
3302
+ width: f().describe("Viewport width in pixels"),
3303
+ height: f().describe("Viewport height in pixels")
3304
+ }).describe("Viewport dimensions")
3305
+ });
3306
+ const At = c({
3307
+ id: f().optional().describe("Tab ID"),
3308
+ tabId: f().optional().describe("Tab ID (added by runner)"),
3309
+ index: f().optional().describe("Tab index in the window"),
3310
+ windowId: f().optional().describe("Window ID"),
3311
+ url: d().optional().describe("Tab URL"),
3312
+ title: d().optional().describe("Tab title"),
3313
+ status: d().optional().describe("Tab status (loading or complete)"),
3314
+ active: x().optional().describe("Whether the tab is active"),
3315
+ pinned: x().optional().describe("Whether the tab is pinned"),
3316
+ highlighted: x().optional().describe("Whether the tab is highlighted"),
3317
+ incognito: x().optional().describe("Whether the tab is incognito"),
3318
+ favIconUrl: d().optional().describe("Favicon URL"),
3319
+ audible: x().optional().describe("Whether the tab is audible"),
3320
+ groupId: f().optional().describe("Group ID"),
3321
+ openerTabId: f().optional().describe("Opener tab ID"),
3322
+ discarded: x().optional().describe("Whether the tab is discarded"),
3323
+ autoDiscardable: x().optional().describe("Whether the tab is auto-discardable"),
3324
+ width: f().optional().describe("Tab width"),
3325
+ height: f().optional().describe("Tab height"),
3326
+ sessionId: d().optional().describe("Session ID")
3327
+ }).passthrough(), kr = A(At), Rt = c({
3328
+ id: f().optional().describe("Window ID"),
3329
+ focused: x().optional().describe("Whether the window is focused"),
3330
+ top: f().optional().describe("Window top position"),
3331
+ left: f().optional().describe("Window left position"),
3332
+ width: f().optional().describe("Window width"),
3333
+ height: f().optional().describe("Window height"),
3334
+ tabs: kr.optional().describe("Array of tabs in the window"),
3335
+ incognito: x().optional().describe("Whether the window is incognito"),
3336
+ type: d().optional().describe("Window type"),
3337
+ state: d().optional().describe("Window state"),
3338
+ alwaysOnTop: x().optional().describe("Whether the window is always on top"),
3339
+ sessionId: d().optional().describe("Session ID")
3340
+ }).passthrough();
3341
+ A(Rt);
3342
+ const wr = c({
3343
+ name: d().describe("Cookie name"),
3344
+ value: d().describe("Cookie value"),
3345
+ domain: d().optional().describe("Cookie domain"),
3346
+ hostOnly: x().optional().describe("Whether the cookie is host-only"),
3347
+ path: d().optional().describe("Cookie path"),
3348
+ secure: x().optional().describe("Whether the cookie is secure"),
3349
+ httpOnly: x().optional().describe("Whether the cookie is HTTP-only"),
3350
+ sameSite: d().optional().describe("SameSite policy"),
3351
+ session: x().optional().describe("Whether the cookie is a session cookie"),
3352
+ expirationDate: f().optional().describe("Expiration date as Unix timestamp"),
3353
+ storeId: d().optional().describe("Store ID")
3354
+ }).nullable();
3355
+ A(wr.nullable().unwrap());
3356
+ const xr = c({
3357
+ id: d().describe("Bookmark ID"),
3358
+ parentId: d().optional().describe("Parent folder ID"),
3359
+ index: f().optional().describe("Bookmark index"),
3360
+ url: d().optional().describe("Bookmark URL"),
3361
+ title: d().describe("Bookmark title"),
3362
+ dateAdded: f().optional().describe("Date added"),
3363
+ dateGroupModified: f().optional().describe("Date group modified"),
3364
+ children: A(c({ id: d() }).passthrough()).optional().describe("Child bookmarks")
3365
+ }).passthrough();
3366
+ A(xr);
3367
+ const Tr = c({
3368
+ id: d().describe("History item ID"),
3369
+ url: d().optional().describe("URL"),
3370
+ title: d().optional().describe("Title"),
3371
+ lastVisitTime: f().optional().describe("Last visit time"),
3372
+ visitCount: f().optional().describe("Visit count"),
3373
+ typedCount: f().optional().describe("Typed count")
3374
+ }).passthrough();
3375
+ A(Tr);
3376
+ const Ir = c({
3377
+ frameId: f().describe("Frame ID"),
3378
+ result: b().optional().describe("Script result")
3379
+ });
3380
+ A(Ir);
3381
+ d();
3382
+ x();
3383
+ T([d(), f()]);
3384
+ x();
3385
+ const Sr = c({
3386
+ id: f().optional().describe("Group ID"),
3387
+ collapsed: x().optional().describe("Whether the group is collapsed"),
3388
+ color: d().optional().describe("Group color"),
3389
+ title: d().optional().describe("Group title"),
3390
+ windowId: f().optional().describe("Window ID")
3391
+ }).passthrough();
3392
+ A(Sr);
3393
+ const Er = c({
3394
+ lastModified: f().optional().describe("Last modified time"),
3395
+ tab: At.optional().describe("Tab info"),
3396
+ window: Rt.optional().describe("Window info")
3397
+ }).passthrough(), Ar = A(Er), Rr = c({
3398
+ deviceName: d().optional().describe("Device name"),
3399
+ sessions: Ar.optional().describe("Sessions")
3400
+ }).passthrough();
3401
+ A(Rr);
3402
+ const Cr = c({
3403
+ id: f().optional().describe("Download ID"),
3404
+ url: d().optional().describe("Download URL"),
3405
+ filename: d().optional().describe("Filename"),
3406
+ startTime: d().optional().describe("Start time"),
3407
+ endTime: d().optional().describe("End time"),
3408
+ state: d().optional().describe("Download state"),
3409
+ danger: d().optional().describe("Danger type"),
3410
+ paused: x().optional().describe("Whether the download is paused"),
3411
+ error: d().optional().describe("Error message"),
3412
+ bytesReceived: f().optional().describe("Bytes received"),
3413
+ totalBytes: f().optional().describe("Total bytes"),
3414
+ fileSize: f().optional().describe("File size"),
3415
+ mime: d().optional().describe("MIME type"),
3416
+ incognito: x().optional().describe("Whether the download is incognito"),
3417
+ referrer: d().optional().describe("Referrer URL"),
3418
+ byExtensionId: d().optional().describe("Extension ID"),
3419
+ byExtensionName: d().optional().describe("Extension name")
3420
+ }).passthrough();
3421
+ A(Cr);
3422
+ f();
3423
+ c({
3424
+ archName: d().describe("CPU architecture"),
3425
+ modelName: d().describe("CPU model"),
3426
+ numOfProcessors: f().describe("Number of processors"),
3427
+ features: A(d()).describe("CPU features")
3428
+ });
3429
+ c({
3430
+ capacity: f().describe("Total memory capacity"),
3431
+ availableCapacity: f().describe("Available memory capacity")
3432
+ });
3433
+ A(c({
3434
+ id: d().describe("Storage ID"),
3435
+ name: d().describe("Storage name"),
3436
+ type: d().describe("Storage type"),
3437
+ capacity: f().describe("Storage capacity")
3438
+ }));
3439
+ const Ze = {
3
3440
  trace: 0,
4
3441
  debug: 1,
5
3442
  info: 2,
6
3443
  warn: 3,
7
3444
  error: 4,
8
3445
  none: 5
9
- }, te = [
3446
+ }, Or = [
10
3447
  "trace",
11
3448
  "debug",
12
3449
  "info",
@@ -14,388 +3451,448 @@ const I = {
14
3451
  "error",
15
3452
  "none"
16
3453
  ];
17
- function se(r) {
18
- const e = Math.max(0, Math.min(5, Math.round(r)));
19
- return te[e] ?? "error";
20
- }
21
- let P = "trace", C = null;
22
- function ne(r) {
23
- P = r, C && C(I[r]);
24
- }
25
- function oe(r) {
26
- C = r, r(I[P]);
27
- }
28
- function ae(r) {
29
- return I[r] >= I[P];
30
- }
31
- function V(r, e = "info") {
32
- var s;
33
- if (r === null) return "null";
34
- if (r === void 0) return "undefined";
35
- if (typeof r == "string") return r;
36
- if (typeof r == "number" || typeof r == "boolean")
37
- return String(r);
38
- if (typeof r == "bigint") return `${r}n`;
39
- if (r instanceof Error) {
40
- const t = e === "debug" || e === "trace" ? r.stack : (s = r.stack) == null ? void 0 : s.split(`
3454
+ function Nr(t) {
3455
+ const e = Math.max(0, Math.min(5, Math.round(t)));
3456
+ return Or[e] ?? "error";
3457
+ }
3458
+ let at = "trace", Qe = null;
3459
+ function Mr(t) {
3460
+ at = t, Qe && Qe(Ze[t]);
3461
+ }
3462
+ function $r(t) {
3463
+ Qe = t, t(Ze[at]);
3464
+ }
3465
+ function Lr(t) {
3466
+ return Ze[t] >= Ze[at];
3467
+ }
3468
+ function Ct(t, e = "info") {
3469
+ var r;
3470
+ if (t === null) return "null";
3471
+ if (t === void 0) return "undefined";
3472
+ if (typeof t == "string") return t;
3473
+ if (typeof t == "number" || typeof t == "boolean")
3474
+ return String(t);
3475
+ if (typeof t == "bigint") return `${t}n`;
3476
+ if (t instanceof Error) {
3477
+ const s = e === "debug" || e === "trace" ? t.stack : (r = t.stack) == null ? void 0 : r.split(`
41
3478
  `)[0];
42
- return JSON.stringify({ message: r.message, name: r.name, stack: t });
3479
+ return JSON.stringify({ message: t.message, name: t.name, stack: s });
43
3480
  }
44
- if (typeof r == "function") return "[Function]";
45
- if (typeof r == "symbol") return String(r);
46
- if (typeof r == "object")
3481
+ if (typeof t == "function") return "[Function]";
3482
+ if (typeof t == "symbol") return String(t);
3483
+ if (typeof t == "object")
47
3484
  try {
48
- return JSON.stringify(r);
49
- } catch (t) {
50
- return t instanceof TypeError && t.message.includes("circular") ? "[Circular]" : `[Unserializable: ${t instanceof Error ? t.message : String(t)}]`;
3485
+ return JSON.stringify(t);
3486
+ } catch (s) {
3487
+ return s instanceof TypeError && s.message.includes("circular") ? "[Circular]" : `[Unserializable: ${s instanceof Error ? s.message : String(s)}]`;
51
3488
  }
52
- return String(r);
3489
+ return String(t);
53
3490
  }
54
- function ie(r) {
55
- return `[extension-js][${r}]`;
3491
+ function jr(t) {
3492
+ return `[extension-js][${t}]`;
56
3493
  }
57
- function le(r, e) {
58
- if (!r) return "";
59
- const s = [];
3494
+ function Pr(t, e) {
3495
+ if (!t) return "";
3496
+ const r = [];
60
3497
  try {
61
- for (const [t, n] of Object.entries(r))
62
- s.push(`${t}=${V(n, e)}`);
3498
+ for (const [s, n] of Object.entries(t))
3499
+ r.push(`${s}=${Ct(n, e)}`);
63
3500
  } catch {
64
3501
  return " metadata=[unreadable]";
65
3502
  }
66
- return s.length > 0 ? ` ${s.join(" ")}` : "";
3503
+ return r.length > 0 ? ` ${r.join(" ")}` : "";
67
3504
  }
68
- function b(r, e) {
69
- return e.length === 0 ? { event: r } : e.length === 1 && typeof e[0] == "object" && e[0] !== null && !Array.isArray(e[0]) ? { event: r, metadata: e[0] } : {
70
- event: r,
71
- metadata: { _args: e.map((s) => V(s)).join(" ") }
3505
+ function ye(t, e) {
3506
+ return e.length === 0 ? { event: t } : e.length === 1 && typeof e[0] == "object" && e[0] !== null && !Array.isArray(e[0]) ? { event: t, metadata: e[0] } : {
3507
+ event: t,
3508
+ metadata: { _args: e.map((r) => Ct(r)).join(" ") }
72
3509
  };
73
3510
  }
74
- class $ {
3511
+ class ot {
75
3512
  constructor(e = "root") {
76
3513
  this.namespace = e;
77
3514
  }
78
- log(e, s, t) {
3515
+ log(e, r, s) {
79
3516
  try {
80
- if (!ae(e)) return;
81
- const n = ie(this.namespace), a = le(t, e), i = `${n} ${s}${a}`;
3517
+ if (!Lr(e)) return;
3518
+ const n = jr(this.namespace), i = Pr(s, e), o = `${n} ${r}${i}`;
82
3519
  switch (e) {
83
3520
  case "trace":
84
3521
  case "debug":
85
3522
  case "info":
86
- console.log(i);
3523
+ console.log(o);
87
3524
  break;
88
3525
  case "warn":
89
- console.warn(i);
3526
+ console.warn(o);
90
3527
  break;
91
3528
  case "error":
92
- console.error(i);
3529
+ console.error(o);
93
3530
  break;
94
3531
  case "none":
95
3532
  break;
96
3533
  default: {
97
- const o = e;
3534
+ const a = e;
98
3535
  break;
99
3536
  }
100
3537
  }
101
3538
  } catch {
102
3539
  }
103
3540
  }
104
- trace(e, ...s) {
105
- const { event: t, metadata: n } = b(e, s);
106
- this.log("trace", t, n);
3541
+ trace(e, ...r) {
3542
+ const { event: s, metadata: n } = ye(e, r);
3543
+ this.log("trace", s, n);
107
3544
  }
108
- debug(e, ...s) {
109
- const { event: t, metadata: n } = b(e, s);
110
- this.log("debug", t, n);
3545
+ debug(e, ...r) {
3546
+ const { event: s, metadata: n } = ye(e, r);
3547
+ this.log("debug", s, n);
111
3548
  }
112
- info(e, ...s) {
113
- const { event: t, metadata: n } = b(e, s);
114
- this.log("info", t, n);
3549
+ info(e, ...r) {
3550
+ const { event: s, metadata: n } = ye(e, r);
3551
+ this.log("info", s, n);
115
3552
  }
116
- warn(e, ...s) {
117
- const { event: t, metadata: n } = b(e, s);
118
- this.log("warn", t, n);
3553
+ warn(e, ...r) {
3554
+ const { event: s, metadata: n } = ye(e, r);
3555
+ this.log("warn", s, n);
119
3556
  }
120
- error(e, ...s) {
121
- const { event: t, metadata: n } = b(e, s);
122
- this.log("error", t, n);
3557
+ error(e, ...r) {
3558
+ const { event: s, metadata: n } = ye(e, r);
3559
+ this.log("error", s, n);
123
3560
  }
124
3561
  child(e) {
125
- return new $(`${this.namespace}.${e}`);
3562
+ return new ot(`${this.namespace}.${e}`);
126
3563
  }
127
- timer(e, s, t = "info") {
128
- const n = typeof performance < "u" && performance.now, a = n ? performance.now() : Date.now();
129
- return (i) => {
3564
+ timer(e, r, s = "info") {
3565
+ const n = typeof performance < "u" && performance.now, i = n ? performance.now() : Date.now();
3566
+ return (o) => {
130
3567
  try {
131
- const o = n ? performance.now() : Date.now(), g = Math.round(o - a), u = {
132
- ...s,
133
- ...i,
134
- duration_ms: g
3568
+ const a = n ? performance.now() : Date.now(), h = Math.round(a - i), l = {
3569
+ ...r,
3570
+ ...o,
3571
+ duration_ms: h
135
3572
  };
136
- this.log(t, e, u);
3573
+ this.log(s, e, l);
137
3574
  } catch {
138
3575
  }
139
3576
  };
140
3577
  }
141
3578
  }
142
- const l = new $("root"), ce = /* @__PURE__ */ new Set();
143
- function ue(r) {
144
- return ce.has(r);
3579
+ const C = new ot("root"), Zr = /* @__PURE__ */ new Set();
3580
+ function Dr(t) {
3581
+ return Zr.has(t);
145
3582
  }
146
- const J = /* @__PURE__ */ new Map();
147
- function de(r, e) {
148
- J.set(r, e);
3583
+ const Ot = /* @__PURE__ */ new Map();
3584
+ function Wr(t, e) {
3585
+ Ot.set(t, e);
149
3586
  }
150
- function fe(r) {
151
- return J.get(r);
3587
+ function Vr(t) {
3588
+ return Ot.get(t);
152
3589
  }
153
- function ge(r) {
154
- return r.startsWith("tab_") ? "required" : "active";
3590
+ function Ur(t) {
3591
+ return t.startsWith("tab_") ? "required" : "active";
155
3592
  }
156
- function pe(r) {
157
- return r === "content-script" ? "content-script" : r === "main-thread" ? "main-thread" : r === "worker" ? "worker:default" : r.startsWith("worker:") ? r : "main-thread";
3593
+ function Fr(t) {
3594
+ return t === "content-script" ? "content-script" : t === "main-thread" ? "main-thread" : t === "worker" ? "worker:default" : t.startsWith("worker:") ? t : "main-thread";
158
3595
  }
159
- function me(r, e) {
160
- return e !== "main-thread" ? e : ue(r) ? "content-script" : e;
3596
+ function zr(t, e) {
3597
+ return e !== "main-thread" ? e : Dr(t) ? "content-script" : e;
161
3598
  }
162
- function ye(r, e) {
3599
+ function Br(t, e) {
163
3600
  return {
164
- endpoint: pe(me(r, e)),
165
- tabPolicy: ge(r)
3601
+ endpoint: Fr(zr(t, e)),
3602
+ tabPolicy: Ur(t)
166
3603
  };
167
3604
  }
168
- function he(r) {
169
- for (const e of r)
170
- de(e.action, ye(e.action, e.owner));
3605
+ function qr(t) {
3606
+ for (const e of t)
3607
+ Wr(e.action, Br(e.action, e.owner));
171
3608
  }
172
- function k(r) {
173
- return r == null ? {} : r instanceof Map ? Object.fromEntries(
174
- [...r.entries()].map(([e, s]) => [e, k(s)])
175
- ) : Array.isArray(r) ? r.map(k) : r;
3609
+ function me(t) {
3610
+ return t == null ? {} : t instanceof Map ? Object.fromEntries(
3611
+ [...t.entries()].map(([e, r]) => [e, me(r)])
3612
+ ) : Array.isArray(t) ? t.map(me) : t;
176
3613
  }
177
- function Ee(r) {
3614
+ function Hr(t) {
178
3615
  return {
179
- action: r.action,
180
- namespace: r.namespace,
181
- name: r.name,
182
- publicName: r.publicName,
183
- description: r.description,
184
- fields: r.fields,
185
- aliases: (r.aliases ?? []).map((e) => ({
3616
+ action: t.action,
3617
+ namespace: t.namespace,
3618
+ name: t.name,
3619
+ publicName: t.publicName,
3620
+ description: t.description,
3621
+ fields: t.fields,
3622
+ aliases: (t.aliases ?? []).map((e) => ({
186
3623
  namespace: e.namespace,
187
3624
  name: e.name,
188
3625
  fields: e.fields
189
3626
  })),
190
- paramsDoc: r.paramsDoc.map((e) => ({
3627
+ paramsDoc: t.paramsDoc.map((e) => ({
191
3628
  name: e.name,
192
3629
  type: e.type,
193
3630
  required: e.required,
194
3631
  description: e.description
195
3632
  })),
196
3633
  returnsDoc: {
197
- type: r.returnsDoc.type,
198
- description: r.returnsDoc.description
3634
+ type: t.returnsDoc.type,
3635
+ description: t.returnsDoc.description
199
3636
  },
200
- errorCode: r.errorCode,
201
- errorCategory: r.errorCategory ?? null,
202
- permission: r.permission ?? null,
203
- example: r.example ?? null,
204
- prerequisites: r.prerequisites ?? null,
205
- notes: r.notes ?? null,
206
- tags: r.tags ?? null,
207
- relatedApis: r.relatedApis ?? null
3637
+ errorCode: t.errorCode,
3638
+ errorCategory: t.errorCategory ?? null,
3639
+ permission: t.permission ?? null,
3640
+ example: t.example ?? null,
3641
+ prerequisites: t.prerequisites ?? null,
3642
+ notes: t.notes ?? null,
3643
+ tags: t.tags ?? null,
3644
+ relatedApis: t.relatedApis ?? null
208
3645
  };
209
3646
  }
210
- l.child("tool-registry");
211
- let h = null, v = !1;
212
- const E = /* @__PURE__ */ new Map();
213
- function T(r, e) {
3647
+ function N(t, e = 0, r = 2) {
3648
+ if (e > r) return "...";
3649
+ if (t instanceof R) {
3650
+ const s = t.shape, n = Object.keys(s).filter((o) => !o.startsWith("__"));
3651
+ return n.length === 0 ? "{ }" : e >= r - 1 ? "{ ... }" : `{ ${n.map((o) => {
3652
+ const a = s[o], h = a instanceof W, l = N(h ? a.unwrap() : a, e + 1, r);
3653
+ return `${o}${h ? "?" : ""}: ${l}`;
3654
+ }).join(", ")} }`;
3655
+ }
3656
+ if (t instanceof Te)
3657
+ return t.options.map((s) => N(s, e, r)).join(" or ");
3658
+ if (t instanceof U) return "string";
3659
+ if (t instanceof se) return "number";
3660
+ if (t instanceof Le) return "boolean";
3661
+ if (t instanceof ne) return "bigint";
3662
+ if (t instanceof xe) return "null";
3663
+ if (t instanceof D) {
3664
+ const s = N(t.element, e + 1, r);
3665
+ return s === "unknown" || s === "any" ? "array" : `${s}[]`;
3666
+ }
3667
+ if (t instanceof z)
3668
+ return `[${t.items.map((s) => N(s, e + 1, r)).join(", ")}]`;
3669
+ if (t instanceof Se) {
3670
+ const s = N(t._def.valueType, e + 1, r);
3671
+ return s === "unknown" || s === "any" ? "{ [key: string]: unknown }" : `{ [key: string]: ${s} }`;
3672
+ }
3673
+ return t instanceof W ? `${N(t.unwrap(), e, r)}?` : t instanceof Ee ? JSON.stringify(t.value) : t instanceof Q ? t.options.map((s) => `"${s}"`).join(" | ") : t instanceof qe ? "any" : t instanceof re ? "unknown" : t instanceof He ? "void" : t instanceof je ? "undefined" : t instanceof G ? N(t.innerType(), e, r) : t instanceof Ae ? N(t.removeDefault(), e, r) : t instanceof ee ? `${N(t.unwrap(), e, r)} | null` : t instanceof Pe ? "lazy" : t instanceof pe ? `Promise<${N(t.unwrap(), e + 1, r)}>` : t instanceof ve ? "function" : t instanceof we ? "Date" : t instanceof Je ? "Map" : t instanceof he ? "Set" : t instanceof Ie ? `${N(t._def.left, e, r)} & ${N(t._def.right, e, r)}` : t instanceof st ? t.options.map((s) => N(s, e, r)).join(" or ") : t instanceof nt ? N(t.unwrap(), e, r) : t instanceof Ke ? "NaN" : t instanceof Re ? N(t.removeCatch(), e, r) : t instanceof We ? N(t._def.in, e, r) : t instanceof Ce ? `readonly ${N(t.unwrap(), e, r)}` : "unknown";
3674
+ }
3675
+ function Gr(t) {
3676
+ return t === null ? "null" : t === void 0 ? "undefined" : Array.isArray(t) ? "array" : typeof t;
3677
+ }
3678
+ function Jr(t, e, r, s) {
3679
+ const n = r.filter((a) => a.path.length === 0), i = r.filter((a) => a.path.length > 0);
3680
+ if (n.length > 0 && i.length === 0) {
3681
+ const a = n.some((l) => l.code === "custom"), h = n.some(
3682
+ (l) => l.code !== "invalid_type" && l.code !== "invalid_literal" && l.code !== "invalid_union"
3683
+ );
3684
+ if (!a && !h) {
3685
+ const l = N(e), _ = Gr(s);
3686
+ return `Invalid parameters for ${t}: expected ${l}${l === "{ }" ? " or no args" : ""}, received ${_}`;
3687
+ }
3688
+ }
3689
+ const o = r.map((a) => `at '${a.path.length > 0 ? a.path.join(".") : "root"}': ${a.message}`);
3690
+ return `Invalid parameters for ${t}: ${o.join("; ")}`;
3691
+ }
3692
+ C.child("tool-registry");
3693
+ let le = null, et = !1;
3694
+ const ue = /* @__PURE__ */ new Map();
3695
+ function De(t, e) {
214
3696
  try {
215
- return r.postMessage(e), !0;
216
- } catch (s) {
217
- const t = s instanceof Error ? s.message : String(s);
218
- return l.error("port_post_failed", { error: t }), !1;
3697
+ return t.postMessage(e), !0;
3698
+ } catch (r) {
3699
+ const s = r instanceof Error ? r.message : String(r);
3700
+ return C.error("port_post_failed", { error: s }), !1;
219
3701
  }
220
3702
  }
221
- const G = 1e3;
222
- function K(r, e, s) {
223
- e === "main-thread" || e === "content-script" ? T(s, { type: "relayCancel", id: r, owner: e }) : T(s, { type: "registryCallCancel", id: r });
3703
+ const _t = 1e3;
3704
+ function Nt(t, e, r) {
3705
+ e === "main-thread" || e === "content-script" ? De(r, { type: "relayCancel", id: t, owner: e }) : De(r, { type: "registryCallCancel", id: t });
224
3706
  }
225
- function q(r, e) {
226
- for (const [s, t] of E)
227
- clearTimeout(t.timeoutId), K(s, t.owner, t.port), t.settle({
3707
+ function vt(t, e) {
3708
+ for (const [r, s] of ue)
3709
+ clearTimeout(s.timeoutId), Nt(r, s.owner, s.port), s.settle({
228
3710
  ok: !1,
229
- error: { message: e, code: r }
230
- }), E.delete(s);
231
- }
232
- const _ = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map();
233
- let z = Promise.resolve(), f = null;
234
- function _e(r) {
235
- l.trace("sessionQueue_enqueue");
236
- const e = z.then(r);
237
- return z = e.then(
3711
+ error: { message: e, code: t }
3712
+ }), ue.delete(r);
3713
+ }
3714
+ const ge = /* @__PURE__ */ new Map(), V = /* @__PURE__ */ new Map();
3715
+ let kt = Promise.resolve(), Z = null;
3716
+ function Yr(t) {
3717
+ C.trace("sessionQueue_enqueue");
3718
+ const e = kt.then(t);
3719
+ return kt = e.then(
238
3720
  () => {
239
3721
  },
240
3722
  () => {
241
3723
  }
242
3724
  ), e;
243
3725
  }
244
- function Y(r) {
245
- f && (l.error("runCell_worker_failure", {
246
- runId: f.runId,
247
- callId: f.id,
248
- error: r
3726
+ function Mt(t) {
3727
+ Z && (C.error("runCell_worker_failure", {
3728
+ runId: Z.runId,
3729
+ callId: Z.id,
3730
+ error: t
249
3731
  }), self.postMessage({
250
3732
  type: "error",
251
- id: f.id,
252
- error: r,
253
- runId: f.runId
254
- }), f = null);
255
- }
256
- self.addEventListener("error", (r) => {
257
- const e = r.message || (r.error instanceof Error ? r.error.message : "Worker uncaught error");
258
- l.error("worker_uncaught_error", { error: e }), Y(e);
259
- });
260
- self.addEventListener("unhandledrejection", (r) => {
261
- const e = r.reason, s = e instanceof Error ? e.message : String(e ?? "Unhandled rejection");
262
- l.error("worker_unhandled_rejection", { error: s }), Y(s);
263
- });
264
- function c(r, e) {
265
- _.set(r, e);
266
- }
267
- function be() {
268
- const r = new Uint8Array(16);
269
- return crypto.getRandomValues(r), Array.from(r, (e) => e.toString(16).padStart(2, "0")).join("");
270
- }
271
- function we(r) {
272
- return se(r);
273
- }
274
- const O = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Map();
275
- function ke(r, e) {
276
- var s;
277
- if (O.has(r))
278
- throw new Error(`Worker port already registered for owner: ${r}`);
3733
+ id: Z.id,
3734
+ error: t,
3735
+ runId: Z.runId
3736
+ }), Z = null);
3737
+ }
3738
+ self.addEventListener("error", (t) => {
3739
+ const e = t.message || (t.error instanceof Error ? t.error.message : "Worker uncaught error");
3740
+ C.error("worker_uncaught_error", { error: e }), Mt(e);
3741
+ });
3742
+ self.addEventListener("unhandledrejection", (t) => {
3743
+ const e = t.reason, r = e instanceof Error ? e.message : String(e ?? "Unhandled rejection");
3744
+ C.error("worker_unhandled_rejection", { error: r }), Mt(r);
3745
+ });
3746
+ function Kr(t, e) {
3747
+ ge.set(t, e);
3748
+ }
3749
+ function O(t, e, r) {
3750
+ Kr(t, async (s, n) => {
3751
+ const i = e.safeParse(me(s));
3752
+ if (!i.success) {
3753
+ const o = Jr(
3754
+ t,
3755
+ e,
3756
+ i.error.issues,
3757
+ s
3758
+ ), a = new Error(o);
3759
+ throw a.code = "E_INVALID_PARAMS", a;
3760
+ }
3761
+ return await r(i.data, n);
3762
+ });
3763
+ }
3764
+ function Xr() {
3765
+ const t = new Uint8Array(16);
3766
+ return crypto.getRandomValues(t), Array.from(t, (e) => e.toString(16).padStart(2, "0")).join("");
3767
+ }
3768
+ function Qr(t) {
3769
+ return Nr(t);
3770
+ }
3771
+ const tt = /* @__PURE__ */ new Map(), Me = /* @__PURE__ */ new Map();
3772
+ function es(t, e) {
3773
+ var r;
3774
+ if (tt.has(t))
3775
+ throw new Error(`Worker port already registered for owner: ${t}`);
279
3776
  if (typeof e.addEventListener != "function")
280
- throw new Error(`Worker port for owner "${r}" cannot receive responses`);
281
- O.set(r, e), e.addEventListener("message", async (t) => {
282
- var a;
283
- const n = t.data;
3777
+ throw new Error(`Worker port for owner "${t}" cannot receive responses`);
3778
+ tt.set(t, e), e.addEventListener("message", async (s) => {
3779
+ var i;
3780
+ const n = s.data;
284
3781
  if (n !== null && (n.type === "asyncRelayResult" || n.type === "registryCallResult") && typeof n.id == "string") {
285
- N(n.id, n.result);
3782
+ rt(n.id, n.result);
286
3783
  return;
287
3784
  }
288
3785
  if (n !== null && n.type === "registryCallCancel" && typeof n.id == "string") {
289
- (a = A.get(n.id)) == null || a.abort(), A.delete(n.id);
3786
+ (i = Me.get(n.id)) == null || i.abort(), Me.delete(n.id);
290
3787
  return;
291
3788
  }
292
3789
  if (n !== null && n.type === "registryCall" && typeof n.id == "string" && typeof n.action == "string") {
293
- const i = n.id, o = new AbortController();
294
- A.set(i, o);
295
- const g = _.get(n.action);
296
- let u;
297
- if (!g)
298
- u = {
3790
+ const o = n.id, a = new AbortController();
3791
+ Me.set(o, a);
3792
+ const h = ge.get(n.action);
3793
+ let l;
3794
+ if (!h)
3795
+ l = {
299
3796
  ok: !1,
300
3797
  error: { message: `Unknown worker action: ${n.action}`, code: "E_UNKNOWN" }
301
3798
  };
302
3799
  else
303
3800
  try {
304
- const d = await g(n.params, {
3801
+ const _ = await h(n.params, {
305
3802
  action: n.action,
306
3803
  callId: n.callId,
307
3804
  runId: n.runId,
308
- signal: o.signal
3805
+ signal: a.signal
309
3806
  });
310
- u = o.signal.aborted ? { ok: !1, error: { message: "Relay aborted", code: "E_ABORT" } } : { ok: !0, value: d };
311
- } catch (d) {
312
- u = {
3807
+ l = a.signal.aborted ? { ok: !1, error: { message: "Relay aborted", code: "E_ABORT" } } : { ok: !0, value: _ };
3808
+ } catch (_) {
3809
+ l = {
313
3810
  ok: !1,
314
3811
  error: {
315
- message: d instanceof Error ? d.message : String(d),
316
- code: o.signal.aborted ? "E_ABORT" : "E_WORKER_HANDLER"
3812
+ message: _ instanceof Error ? _.message : String(_),
3813
+ code: a.signal.aborted ? "E_ABORT" : "E_WORKER_HANDLER"
317
3814
  }
318
3815
  };
319
3816
  }
320
- A.delete(i), T(e, { type: "registryCallResult", id: i, result: u }) || N(i, {
3817
+ Me.delete(o), De(e, { type: "registryCallResult", id: o, result: l }) || rt(o, {
321
3818
  ok: !1,
322
3819
  error: { message: "Failed to deliver worker handler response", code: "E_PORT" }
323
3820
  });
324
3821
  }
325
- }), (s = e.start) == null || s.call(e);
3822
+ }), (r = e.start) == null || r.call(e);
326
3823
  }
327
- function N(r, e) {
328
- l.trace("resolveAsyncRelayResult", { id: r });
329
- const s = E.get(r);
330
- return s ? (s.settle(e), !0) : (l.warn("asyncRelayResult_no_pending_relay", { id: r }), !1);
3824
+ function rt(t, e) {
3825
+ C.trace("resolveAsyncRelayResult", { id: t });
3826
+ const r = ue.get(t);
3827
+ return r ? (r.settle(e), !0) : (C.warn("asyncRelayResult_no_pending_relay", { id: t }), !1);
331
3828
  }
332
- function Me(r) {
333
- if (r === "main-thread" || r === "content-script")
3829
+ function ts(t) {
3830
+ if (t === "main-thread" || t === "content-script")
334
3831
  return self;
335
- const e = O.get(r);
3832
+ const e = tt.get(t);
336
3833
  return e || null;
337
3834
  }
338
- function Q(r) {
339
- const { owner: e, action: s, tabPolicy: t, resolveTimeoutMs: n } = r, a = r.timeoutMs ?? w;
340
- return (i, o) => {
341
- l.trace("safePostAsCall_invoke", { owner: e, action: s, callId: o == null ? void 0 : o.callId, runId: o == null ? void 0 : o.runId });
342
- const g = (n == null ? void 0 : n(i)) ?? a;
343
- return new Promise((u, d) => {
344
- var j;
345
- if ((j = o == null ? void 0 : o.signal) != null && j.aborted) {
346
- const m = new Error(`Relay aborted for action: ${s}`);
347
- m.code = "E_ABORT", d(m);
3835
+ function $t(t) {
3836
+ const { owner: e, action: r, tabPolicy: s, resolveTimeoutMs: n } = t, i = t.timeoutMs ?? _e;
3837
+ return (o, a) => {
3838
+ C.trace("safePostAsCall_invoke", { owner: e, action: r, callId: a == null ? void 0 : a.callId, runId: a == null ? void 0 : a.runId });
3839
+ const h = (n == null ? void 0 : n(o)) ?? i;
3840
+ return new Promise((l, _) => {
3841
+ var ft;
3842
+ if ((ft = a == null ? void 0 : a.signal) != null && ft.aborted) {
3843
+ const q = new Error(`Relay aborted for action: ${r}`);
3844
+ q.code = "E_ABORT", _(q);
348
3845
  return;
349
3846
  }
350
- const y = Me(e);
351
- if (!y) {
352
- d(new Error(`No port available for action: ${s}`));
3847
+ const E = ts(e);
3848
+ if (!E) {
3849
+ _(new Error(`No port available for action: ${r}`));
353
3850
  return;
354
3851
  }
355
- if (E.size >= G) {
356
- d(new Error(
357
- `Too many pending calls (${G} limit exceeded). Action: ${s}`
3852
+ if (ue.size >= _t) {
3853
+ _(new Error(
3854
+ `Too many pending calls (${_t} limit exceeded). Action: ${r}`
358
3855
  ));
359
3856
  return;
360
3857
  }
361
- const M = be();
362
- let W = !1;
363
- const R = (m) => {
364
- W || (W = !0, clearTimeout(U), o != null && o.signal && o.signal.removeEventListener("abort", S), E.delete(M), m());
365
- }, D = () => {
366
- K(M, e, y);
367
- }, S = () => {
368
- D();
369
- const m = new Error(`Relay aborted for action: ${s}`);
370
- m.code = "E_ABORT", R(() => d(m));
3858
+ const te = Xr();
3859
+ let oe = !1;
3860
+ const Ne = (q) => {
3861
+ oe || (oe = !0, clearTimeout(ct), a != null && a.signal && a.signal.removeEventListener("abort", Ve), ue.delete(te), q());
3862
+ }, dt = () => {
3863
+ Nt(te, e, E);
3864
+ }, Ve = () => {
3865
+ dt();
3866
+ const q = new Error(`Relay aborted for action: ${r}`);
3867
+ q.code = "E_ABORT", Ne(() => _(q));
371
3868
  };
372
- o != null && o.signal && o.signal.addEventListener("abort", S);
373
- const U = setTimeout(() => {
374
- D(), R(() => d(new Error(`Relay timeout for action: ${s}`)));
375
- }, g);
376
- E.set(M, {
377
- settle: (m) => R(() => u(m)),
378
- timeoutId: U,
379
- abort: S,
3869
+ a != null && a.signal && a.signal.addEventListener("abort", Ve);
3870
+ const ct = setTimeout(() => {
3871
+ dt(), Ne(() => _(new Error(`Relay timeout for action: ${r}`)));
3872
+ }, h);
3873
+ ue.set(te, {
3874
+ settle: (q) => Ne(() => l(q)),
3875
+ timeoutId: ct,
3876
+ abort: Ve,
380
3877
  owner: e,
381
- port: y
3878
+ port: E
382
3879
  });
383
- const F = o == null ? void 0 : o.runId, B = o == null ? void 0 : o.callId;
384
- T(y, {
3880
+ const lt = a == null ? void 0 : a.runId, ut = a == null ? void 0 : a.callId;
3881
+ De(E, {
385
3882
  type: e === "main-thread" || e === "content-script" ? "asyncRelay" : "registryCall",
386
- id: M,
3883
+ id: te,
387
3884
  owner: e,
388
- action: s,
389
- params: i,
390
- callId: B,
391
- tabPolicy: t,
392
- command: { action: s, params: i, runId: F, callId: B },
393
- runId: F
394
- }) || R(() => d(new Error(`Failed to post relay for action: ${s}`)));
3885
+ action: r,
3886
+ params: o,
3887
+ callId: ut,
3888
+ tabPolicy: s,
3889
+ command: { action: r, params: o, runId: lt, callId: ut },
3890
+ runId: lt
3891
+ }) || Ne(() => _(new Error(`Failed to post relay for action: ${r}`)));
395
3892
  });
396
3893
  };
397
3894
  }
398
- const Re = "worker", w = 3e4, H = 5e3, Ae = 500, Ie = {
3895
+ const rs = "worker", _e = 3e4, wt = 5e3, ss = 500, ns = {
399
3896
  page_goto: "timeout",
400
3897
  page_wait_for: "timeout",
401
3898
  tab_wait_for_load: "timeout",
@@ -403,154 +3900,154 @@ const Re = "worker", w = 3e4, H = 5e3, Ae = 500, Ie = {
403
3900
  sleep: "duration",
404
3901
  page_wait: "duration",
405
3902
  sidepanel_wait: "duration"
406
- }, X = /* @__PURE__ */ new Set(["page_goto"]);
407
- function Te(r, e) {
408
- if (r === null || typeof r != "object" || Array.isArray(r))
3903
+ }, Lt = /* @__PURE__ */ new Set(["page_goto"]);
3904
+ function is(t, e) {
3905
+ if (t === null || typeof t != "object" || Array.isArray(t))
409
3906
  return null;
410
- const s = r[e];
411
- return typeof s == "bigint" ? Number(s) : typeof s == "number" && Number.isFinite(s) ? s : null;
412
- }
413
- function Se(r, e) {
414
- return X.has(r) ? e * 2 + Ae + H : e + H;
415
- }
416
- function Z(r, e) {
417
- const s = Ie[r];
418
- if (!s) return w;
419
- let t = Te(e, s);
420
- return t === null && X.has(r) && (t = w), t === null ? w : Math.max(
421
- w,
422
- Se(r, t)
3907
+ const r = t[e];
3908
+ return typeof r == "bigint" ? Number(r) : typeof r == "number" && Number.isFinite(r) ? r : null;
3909
+ }
3910
+ function as(t, e) {
3911
+ return Lt.has(t) ? e * 2 + ss + wt : e + wt;
3912
+ }
3913
+ function jt(t, e) {
3914
+ const r = ns[t];
3915
+ if (!r) return _e;
3916
+ let s = is(e, r);
3917
+ return s === null && Lt.has(t) && (s = _e), s === null ? _e : Math.max(
3918
+ _e,
3919
+ as(t, s)
423
3920
  );
424
3921
  }
425
- function Ne(r, e) {
426
- var a, i;
427
- r = k(r);
428
- const s = e == null ? void 0 : e.action;
429
- if (l.trace("extensionDispatch", { action: s, callId: e == null ? void 0 : e.callId, runId: e == null ? void 0 : e.runId }), !s)
3922
+ function us(t, e) {
3923
+ var i, o;
3924
+ t = me(t);
3925
+ const r = e == null ? void 0 : e.action;
3926
+ if (C.trace("extensionDispatch", { action: r, callId: e == null ? void 0 : e.callId, runId: e == null ? void 0 : e.runId }), !r)
430
3927
  return Promise.resolve({
431
3928
  ok: !1,
432
3929
  error: { message: "Missing action in dispatch context", code: "E_MISSING_ACTION" }
433
3930
  });
434
- if (_.has(s)) {
435
- const o = _.get(s), g = (e == null ? void 0 : e.signal) ?? (e != null && e.runId ? (a = p.get(e.runId)) == null ? void 0 : a.signal : void 0);
3931
+ if (ge.has(r)) {
3932
+ const a = ge.get(r), h = (e == null ? void 0 : e.signal) ?? (e != null && e.runId ? (i = V.get(e.runId)) == null ? void 0 : i.signal : void 0);
436
3933
  return (async () => {
437
3934
  try {
438
- return { ok: !0, value: await o(r, { ...e, signal: g }) };
439
- } catch (u) {
440
- const d = u instanceof Error ? u.message : String(u), y = typeof u == "object" && u !== null && "code" in u && typeof u.code == "string" ? u.code : "E_WORKER_HANDLER";
441
- return { ok: !1, error: { message: d, code: y } };
3935
+ return { ok: !0, value: await a(t, { ...e, signal: h }) };
3936
+ } catch (l) {
3937
+ const _ = l instanceof Error ? l.message : String(l), E = typeof l == "object" && l !== null && "code" in l && typeof l.code == "string" ? l.code : "E_WORKER_HANDLER";
3938
+ return { ok: !1, error: { message: _, code: E } };
442
3939
  }
443
3940
  })();
444
3941
  }
445
- const t = fe(s);
446
- return t ? Q({
447
- owner: t.endpoint,
448
- action: s,
449
- resolveTimeoutMs: (o) => Z(s, o),
450
- tabPolicy: t.tabPolicy
451
- })(r, {
3942
+ const s = Vr(r);
3943
+ return s ? $t({
3944
+ owner: s.endpoint,
3945
+ action: r,
3946
+ resolveTimeoutMs: (a) => jt(r, a),
3947
+ tabPolicy: s.tabPolicy
3948
+ })(t, {
452
3949
  ...e,
453
- signal: (e == null ? void 0 : e.signal) ?? (e != null && e.runId ? (i = p.get(e.runId)) == null ? void 0 : i.signal : void 0)
3950
+ signal: (e == null ? void 0 : e.signal) ?? (e != null && e.runId ? (o = V.get(e.runId)) == null ? void 0 : o.signal : void 0)
454
3951
  }) : Promise.resolve({
455
3952
  ok: !1,
456
- error: { message: `No route registered for action: ${s}`, code: "E_NO_ROUTE" }
3953
+ error: { message: `No route registered for action: ${r}`, code: "E_NO_ROUTE" }
457
3954
  });
458
3955
  }
459
- function Le(r) {
460
- if (r.owner === Re) {
461
- const e = _.get(r.action);
3956
+ function os(t) {
3957
+ if (t.owner === rs) {
3958
+ const e = ge.get(t.action);
462
3959
  if (!e)
463
3960
  throw new Error(
464
- `No worker-local handler registered for action: ${r.action}`
3961
+ `No worker-local handler registered for action: ${t.action}`
465
3962
  );
466
- return async (s, t) => {
467
- var a;
468
- s = k(s);
469
- const n = (t == null ? void 0 : t.signal) ?? (t != null && t.runId ? (a = p.get(t.runId)) == null ? void 0 : a.signal : void 0);
3963
+ return async (r, s) => {
3964
+ var i;
3965
+ r = me(r);
3966
+ const n = (s == null ? void 0 : s.signal) ?? (s != null && s.runId ? (i = V.get(s.runId)) == null ? void 0 : i.signal : void 0);
470
3967
  try {
471
- return { ok: !0, value: await e(s, { ...t, action: r.action, signal: n }) };
472
- } catch (i) {
473
- const o = i instanceof Error ? i.message : String(i), g = typeof i == "object" && i !== null && "code" in i && typeof i.code == "string" ? i.code : r.errorCode;
474
- return { ok: !1, error: { message: o, code: g } };
3968
+ return { ok: !0, value: await e(r, { ...s, action: t.action, signal: n }) };
3969
+ } catch (o) {
3970
+ const a = o instanceof Error ? o.message : String(o), h = typeof o == "object" && o !== null && "code" in o && typeof o.code == "string" ? o.code : t.errorCode;
3971
+ return { ok: !1, error: { message: a, code: h } };
475
3972
  }
476
3973
  };
477
3974
  } else {
478
- const e = Q({
479
- owner: r.owner,
480
- action: r.action,
481
- resolveTimeoutMs: (s) => Z(r.action, s)
3975
+ const e = $t({
3976
+ owner: t.owner,
3977
+ action: t.action,
3978
+ resolveTimeoutMs: (r) => jt(t.action, r)
482
3979
  });
483
- return (s, t) => {
3980
+ return (r, s) => {
484
3981
  var n;
485
- return e(k(s), {
486
- ...t,
487
- signal: (t == null ? void 0 : t.signal) ?? (t != null && t.runId ? (n = p.get(t.runId)) == null ? void 0 : n.signal : void 0)
3982
+ return e(me(r), {
3983
+ ...s,
3984
+ signal: (s == null ? void 0 : s.signal) ?? (s != null && s.runId ? (n = V.get(s.runId)) == null ? void 0 : n.signal : void 0)
488
3985
  });
489
3986
  };
490
3987
  }
491
3988
  }
492
- function Ce(r) {
493
- c("exists", (e) => r.fsExists(e)), c("stat", (e) => r.fsStat(e)), c("read", (e) => r.fsRead(e)), c("readText", (e) => r.fsReadText(e)), c("readBase64", (e) => r.fsReadBase64(e)), c("list", (e) => r.fsList(e)), c("mkdir", (e) => r.fsMkdir(e)), c("delete", (e) => r.fsDelete(e)), c("copy", (e) => r.fsCopy(e)), c("move", (e) => r.fsMove(e)), c("write", (e) => r.fsWrite(e)), c("writeText", (e) => r.fsWriteText(e)), c("writeBase64", (e) => r.fsWriteBase64(e)), c("append", (e) => r.fsAppend(e)), c("appendText", (e) => r.fsAppendText(e)), c("appendBase64", (e) => r.fsAppendBase64(e)), c("readRange", (e) => r.fsReadRange(e)), c("update", (e) => r.fsUpdate(e)), c("hash", (e) => r.fsHash(e));
3989
+ function ds(t) {
3990
+ O("exists", Y, (e) => t.fsExists(e)), O("stat", Y, (e) => t.fsStat(e)), O("read", Y, (e) => t.fsRead(e)), O("readText", Y, (e) => t.fsReadText(e)), O("readBase64", Y, (e) => t.fsReadBase64(e)), O("list", Y, (e) => t.fsList(e)), O("mkdir", Y, (e) => t.fsMkdir(e)), O("delete", Y, (e) => t.fsDelete(e)), O("copy", bt, (e) => t.fsCopy(e)), O("move", bt, (e) => t.fsMove(e)), O("write", de, (e) => t.fsWrite(e)), O("writeText", de, (e) => t.fsWriteText(e)), O("writeBase64", de, (e) => t.fsWriteBase64(e)), O("append", de, (e) => t.fsAppend(e)), O("appendText", de, (e) => t.fsAppendText(e)), O("appendBase64", de, (e) => t.fsAppendBase64(e)), O("readRange", gr, (e) => t.fsReadRange(e)), O("update", yr, (e) => t.fsUpdate(e)), O("hash", br, (e) => t.fsHash(e));
494
3991
  }
495
- async function ve(r, e) {
496
- if (v) return;
497
- await x(), h = new ee(), L(0), oe(L), l.trace("initWasm_start"), Ce(h), he(r);
498
- const t = r.map((a) => ({
499
- entry: Ee(a),
500
- callback: Le(a)
3992
+ async function cs(t, e) {
3993
+ if (et) return;
3994
+ await Pt(), le = new Zt(), Fe(0), $r(Fe), C.trace("initWasm_start"), ds(le), qr(t);
3995
+ const s = t.map((i) => ({
3996
+ entry: Hr(i),
3997
+ callback: os(i)
501
3998
  }));
502
3999
  try {
503
- re(t);
504
- } catch (a) {
505
- const i = a instanceof Error ? a.message : String(a);
506
- throw new Error(`Registry registration failed: ${i}`);
4000
+ Dt(s);
4001
+ } catch (i) {
4002
+ const o = i instanceof Error ? i.message : String(i);
4003
+ throw new Error(`Registry registration failed: ${o}`);
507
4004
  }
508
4005
  const { freezeManifest: n } = await import("./extension_js.js");
509
4006
  try {
510
4007
  n();
511
- } catch (a) {
512
- const i = a instanceof Error ? a.message : String(a);
513
- throw new Error(`Manifest freeze failed: ${i}`);
514
- }
515
- if (h.injectRegistryBindings(), e) {
516
- const a = JSON.stringify(e);
517
- await h.runCellAsync(
518
- `(function(){var r=globalThis.chrome&&globalThis.chrome.runtime;if(!r){r={};if(!globalThis.chrome)globalThis.chrome={};globalThis.chrome.runtime=r;}r.id=${a};})();`,
4008
+ } catch (i) {
4009
+ const o = i instanceof Error ? i.message : String(i);
4010
+ throw new Error(`Manifest freeze failed: ${o}`);
4011
+ }
4012
+ if (le.injectRegistryBindings(), e) {
4013
+ const i = JSON.stringify(e);
4014
+ await le.runCellAsync(
4015
+ `(function(){var r=globalThis.chrome&&globalThis.chrome.runtime;if(!r){r={};if(!globalThis.chrome)globalThis.chrome={};globalThis.chrome.runtime=r;}r.id=${i};})();`,
519
4016
  "",
520
4017
  "inject-runtime-id"
521
4018
  );
522
4019
  }
523
- v = !0, l.trace("initWasm_done");
4020
+ et = !0, C.trace("initWasm_done");
524
4021
  }
525
- self.onmessage = async (r) => {
526
- const e = r.data;
527
- if (l.trace("onmessage", { type: e.type, id: "id" in e ? e.id : void 0 }), e.type === "asyncRelayResult") {
528
- l.trace("asyncRelayResult", { id: e.id }), N(e.id, e.result);
4022
+ self.onmessage = async (t) => {
4023
+ const e = t.data;
4024
+ if (C.trace("onmessage", { type: e.type, id: "id" in e ? e.id : void 0 }), e.type === "asyncRelayResult") {
4025
+ C.trace("asyncRelayResult", { id: e.id }), rt(e.id, e.result);
529
4026
  return;
530
4027
  }
531
4028
  if (e.type === "registerWorkerPort") {
532
- const t = r.ports[0];
533
- if (!t) {
534
- l.error("register_worker_port_missing", { owner: e.owner });
4029
+ const s = t.ports[0];
4030
+ if (!s) {
4031
+ C.error("register_worker_port_missing", { owner: e.owner });
535
4032
  return;
536
4033
  }
537
- ke(e.owner, t);
4034
+ es(e.owner, s);
538
4035
  return;
539
4036
  }
540
4037
  if (e.type === "init") {
541
4038
  try {
542
- await ve(e.manifest, e.extensionId), self.postMessage({ type: "ready" });
543
- } catch (t) {
544
- const n = t instanceof Error ? t.message : String(t);
545
- l.error("worker_init_failed", { error: n }), self.postMessage({ type: "error", error: `WASM init failed: ${n}` });
4039
+ await cs(e.manifest, e.extensionId), self.postMessage({ type: "ready" });
4040
+ } catch (s) {
4041
+ const n = s instanceof Error ? s.message : String(s);
4042
+ C.error("worker_init_failed", { error: n }), self.postMessage({ type: "error", error: `WASM init failed: ${n}` });
546
4043
  }
547
4044
  return;
548
4045
  }
549
4046
  if (e.type === "setLogLevel") {
550
- L(e.level), ne(we(e.level)), l.trace("set_log_level", { level: e.level });
4047
+ Fe(e.level), Mr(Qr(e.level)), C.trace("set_log_level", { level: e.level });
551
4048
  return;
552
4049
  }
553
- if (!v || !h) {
4050
+ if (!et || !le) {
554
4051
  self.postMessage({
555
4052
  type: "error",
556
4053
  id: e.id,
@@ -558,61 +4055,68 @@ self.onmessage = async (r) => {
558
4055
  });
559
4056
  return;
560
4057
  }
561
- const s = h;
562
- await _e(async () => {
4058
+ const r = le;
4059
+ await Yr(async () => {
563
4060
  switch (e.type) {
564
4061
  case "runCell": {
565
- const t = e.runId, n = new AbortController();
566
- t && p.set(t, n), f = { id: e.id, runId: t }, l.trace("runCell_start", { runId: t, callId: e.id, codeLen: e.code.length });
4062
+ const s = e.runId, n = new AbortController();
4063
+ s && V.set(s, n), Z = { id: e.id, runId: s }, C.trace("runCell_start", { runId: s, callId: e.id, codeLen: e.code.length });
567
4064
  try {
568
- const a = await s.runCellAsync(
4065
+ const i = await r.runCellAsync(
569
4066
  e.code,
570
4067
  e.stdin || "",
571
- t || ""
4068
+ s || ""
572
4069
  );
573
- l.trace("runCell_done", { runId: t, callId: e.id, status: a.status }), self.postMessage({
4070
+ C.trace("runCell_done", { runId: s, callId: e.id, status: i.status }), self.postMessage({
574
4071
  type: "result",
575
4072
  id: e.id,
576
- data: a,
577
- runId: t
4073
+ data: i,
4074
+ runId: s
578
4075
  });
579
- } catch (a) {
580
- const i = a instanceof Error ? a.message : String(a);
581
- l.error("runCell_error", { runId: t, error: i }), self.postMessage({
4076
+ } catch (i) {
4077
+ const o = i instanceof Error ? i.message : String(i), a = i instanceof Error ? i.name : void 0, h = i instanceof Error ? i.stack : void 0;
4078
+ let l;
4079
+ if (h) {
4080
+ const E = h.match(/:(\d+):\d+\)?$/m);
4081
+ E && (l = parseInt(E[1], 10));
4082
+ }
4083
+ C.error("runCell_error", { runId: s, error: o, name: a, line: l });
4084
+ const _ = i instanceof Error ? { name: a, message: o, stack: h, ...l !== void 0 ? { line: l } : {} } : { message: o };
4085
+ self.postMessage({
582
4086
  type: "error",
583
4087
  id: e.id,
584
- error: i,
585
- runId: t
4088
+ error: _,
4089
+ runId: s
586
4090
  });
587
4091
  } finally {
588
- (f == null ? void 0 : f.id) === e.id && (f = null), t && p.delete(t);
4092
+ (Z == null ? void 0 : Z.id) === e.id && (Z = null), s && V.delete(s);
589
4093
  }
590
4094
  break;
591
4095
  }
592
4096
  case "reset": {
593
- s.setAborted(!0);
594
- for (const t of p.values()) t.abort();
595
- p.clear(), q("E_RESET", "Worker reset");
4097
+ r.setAborted(!0);
4098
+ for (const s of V.values()) s.abort();
4099
+ V.clear(), vt("E_RESET", "Worker reset");
596
4100
  try {
597
- s.reset(), self.postMessage({ type: "result", id: e.id, data: { ok: !0 } });
598
- } catch (t) {
599
- const n = t instanceof Error ? t.message : String(t);
4101
+ r.reset(), self.postMessage({ type: "result", id: e.id, data: { ok: !0 } });
4102
+ } catch (s) {
4103
+ const n = s instanceof Error ? s.message : String(s);
600
4104
  self.postMessage({ type: "error", id: e.id, error: n });
601
4105
  }
602
4106
  break;
603
4107
  }
604
4108
  case "stop": {
605
- s.setAborted(!0);
606
- for (const t of p.values()) t.abort();
607
- p.clear(), q("E_STOPPED", "Worker stopped"), self.postMessage({ type: "result", id: e.id, data: { ok: !0 } });
4109
+ r.setAborted(!0);
4110
+ for (const s of V.values()) s.abort();
4111
+ V.clear(), vt("E_STOPPED", "Worker stopped"), self.postMessage({ type: "result", id: e.id, data: { ok: !0 } });
608
4112
  break;
609
4113
  }
610
4114
  case "setFuelLimit": {
611
4115
  try {
612
- s.set_fuel_limit(e.limit), e.id && self.postMessage({ type: "result", id: e.id, data: { ok: !0 } });
613
- } catch (t) {
4116
+ r.set_fuel_limit(e.limit), e.id && self.postMessage({ type: "result", id: e.id, data: { ok: !0 } });
4117
+ } catch (s) {
614
4118
  if (e.id) {
615
- const n = t instanceof Error ? t.message : String(t);
4119
+ const n = s instanceof Error ? s.message : String(s);
616
4120
  self.postMessage({ type: "error", id: e.id, error: n });
617
4121
  }
618
4122
  }
@@ -620,37 +4124,37 @@ self.onmessage = async (r) => {
620
4124
  }
621
4125
  case "inspectGlobals": {
622
4126
  try {
623
- const t = s.inspect_globals();
624
- self.postMessage({ type: "result", id: e.id, data: t });
625
- } catch (t) {
626
- const n = t instanceof Error ? t.message : String(t);
4127
+ const s = r.inspect_globals();
4128
+ self.postMessage({ type: "result", id: e.id, data: s });
4129
+ } catch (s) {
4130
+ const n = s instanceof Error ? s.message : String(s);
627
4131
  self.postMessage({ type: "error", id: e.id, error: n });
628
4132
  }
629
4133
  break;
630
4134
  }
631
4135
  case "apiDocs": {
632
4136
  try {
633
- const t = s.apiDocs(e.format);
634
- self.postMessage({ type: "result", id: e.id, data: t });
635
- } catch (t) {
636
- const n = t instanceof Error ? t.message : String(t);
4137
+ const s = r.apiDocs(e.format);
4138
+ self.postMessage({ type: "result", id: e.id, data: s });
4139
+ } catch (s) {
4140
+ const n = s instanceof Error ? s.message : String(s);
637
4141
  self.postMessage({ type: "error", id: e.id, error: n });
638
4142
  }
639
4143
  break;
640
4144
  }
641
4145
  case "loadLibrary": {
642
4146
  try {
643
- const t = s.load_library(e.source);
644
- self.postMessage({ type: "result", id: e.id, data: t });
645
- } catch (t) {
646
- const n = t instanceof Error ? t.message : String(t);
4147
+ const s = r.load_library(e.source);
4148
+ self.postMessage({ type: "result", id: e.id, data: s });
4149
+ } catch (s) {
4150
+ const n = s instanceof Error ? s.message : String(s);
647
4151
  self.postMessage({ type: "error", id: e.id, error: n });
648
4152
  }
649
4153
  break;
650
4154
  }
651
4155
  case "fsCall": {
652
- const t = _.get(e.action);
653
- if (!t) {
4156
+ const s = ge.get(e.action);
4157
+ if (!s) {
654
4158
  self.postMessage({
655
4159
  type: "error",
656
4160
  id: e.id,
@@ -659,29 +4163,30 @@ self.onmessage = async (r) => {
659
4163
  break;
660
4164
  }
661
4165
  try {
662
- const n = await t(e.params);
4166
+ const n = await s(e.params);
663
4167
  self.postMessage({ type: "result", id: e.id, data: n });
664
4168
  } catch (n) {
665
- const a = n instanceof Error ? n.message : String(n);
666
- self.postMessage({ type: "error", id: e.id, error: a });
4169
+ const i = n instanceof Error ? n.message : String(n);
4170
+ self.postMessage({ type: "error", id: e.id, error: i });
667
4171
  }
668
4172
  break;
669
4173
  }
670
4174
  default: {
671
- l.error("unhandled_worker_message", { type: e.type });
4175
+ C.error("unhandled_worker_message", { type: e.type });
672
4176
  break;
673
4177
  }
674
4178
  }
675
4179
  });
676
4180
  };
677
4181
  export {
678
- w as DEFAULT_RELAY_TIMEOUT_MS,
679
- Le as createExecutableCallback,
680
- Ne as extensionDispatch,
681
- c as registerWorkerHandler,
682
- ke as registerWorkerPort,
683
- N as resolveAsyncRelayResult,
684
- Z as resolveRelayTimeoutMs,
685
- Q as safePostAsCall,
686
- q as settleAllPendingRelays
4182
+ _e as DEFAULT_RELAY_TIMEOUT_MS,
4183
+ os as createExecutableCallback,
4184
+ us as extensionDispatch,
4185
+ Kr as registerWorkerHandler,
4186
+ O as registerWorkerHandlerValidated,
4187
+ es as registerWorkerPort,
4188
+ rt as resolveAsyncRelayResult,
4189
+ jt as resolveRelayTimeoutMs,
4190
+ $t as safePostAsCall,
4191
+ vt as settleAllPendingRelays
687
4192
  };