@pi-oxide/extension-js 0.9.0 → 0.10.1

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,4 +1,186 @@
1
- import Xt, { setLogLevel as Je, ExtensionSession as er, registerJsCallBatch as tr, takeCachedVfsWriteBase64 as rr, clearVfsWriteCache as nr } from "./extension_js.js";
1
+ import Xt, { setLogLevel as Ye, ExtensionSession as er, registerJsCallBatch as tr, takeCachedVfsWriteBase64 as rr, clearVfsWriteCache as nr } from "./extension_js.js";
2
+ const $e = {
3
+ trace: 0,
4
+ debug: 1,
5
+ info: 2,
6
+ warn: 3,
7
+ error: 4,
8
+ none: 5
9
+ }, sr = [
10
+ "trace",
11
+ "debug",
12
+ "info",
13
+ "warn",
14
+ "error",
15
+ "none"
16
+ ];
17
+ function ir(t) {
18
+ const e = Math.max(0, Math.min(5, Math.round(t)));
19
+ return sr[e] ?? "error";
20
+ }
21
+ let dt = "trace", Ke = null;
22
+ function ar(t) {
23
+ dt = t, Ke && Ke($e[t]);
24
+ }
25
+ function or(t) {
26
+ Ke = t, t($e[dt]);
27
+ }
28
+ function cr(t) {
29
+ return $e[t] >= $e[dt];
30
+ }
31
+ function Nt(t, e = "info") {
32
+ var r;
33
+ if (t === null) return "null";
34
+ if (t === void 0) return "undefined";
35
+ if (typeof t == "string") return t;
36
+ if (typeof t == "number" || typeof t == "boolean")
37
+ return String(t);
38
+ if (typeof t == "bigint") return `${t}n`;
39
+ if (t instanceof Error) {
40
+ const n = e === "debug" || e === "trace" ? t.stack : (r = t.stack) == null ? void 0 : r.split(`
41
+ `)[0];
42
+ return JSON.stringify({ message: t.message, name: t.name, stack: n });
43
+ }
44
+ if (typeof t == "function") return "[Function]";
45
+ if (typeof t == "symbol") return String(t);
46
+ if (typeof t == "object")
47
+ try {
48
+ return JSON.stringify(t);
49
+ } catch (n) {
50
+ return n instanceof TypeError && n.message.includes("circular") ? "[Circular]" : `[Unserializable: ${n instanceof Error ? n.message : String(n)}]`;
51
+ }
52
+ return String(t);
53
+ }
54
+ function dr(t) {
55
+ return `[extension-js][${t}]`;
56
+ }
57
+ function lr(t, e) {
58
+ if (!t) return "";
59
+ const r = [];
60
+ try {
61
+ for (const [n, s] of Object.entries(t))
62
+ r.push(`${n}=${Nt(s, e)}`);
63
+ } catch {
64
+ return " metadata=[unreadable]";
65
+ }
66
+ return r.length > 0 ? ` ${r.join(" ")}` : "";
67
+ }
68
+ function be(t, e) {
69
+ 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] } : {
70
+ event: t,
71
+ metadata: { _args: e.map((r) => Nt(r)).join(" ") }
72
+ };
73
+ }
74
+ class lt {
75
+ constructor(e = "root") {
76
+ this.namespace = e;
77
+ }
78
+ log(e, r, n) {
79
+ try {
80
+ if (!cr(e)) return;
81
+ const s = dr(this.namespace), i = lr(n, e), o = `${s} ${r}${i}`;
82
+ switch (e) {
83
+ case "trace":
84
+ case "debug":
85
+ case "info":
86
+ console.log(o);
87
+ break;
88
+ case "warn":
89
+ console.warn(o);
90
+ break;
91
+ case "error":
92
+ console.error(o);
93
+ break;
94
+ case "none":
95
+ break;
96
+ default: {
97
+ const a = e;
98
+ break;
99
+ }
100
+ }
101
+ } catch {
102
+ }
103
+ }
104
+ trace(e, ...r) {
105
+ const { event: n, metadata: s } = be(e, r);
106
+ this.log("trace", n, s);
107
+ }
108
+ debug(e, ...r) {
109
+ const { event: n, metadata: s } = be(e, r);
110
+ this.log("debug", n, s);
111
+ }
112
+ info(e, ...r) {
113
+ const { event: n, metadata: s } = be(e, r);
114
+ this.log("info", n, s);
115
+ }
116
+ warn(e, ...r) {
117
+ const { event: n, metadata: s } = be(e, r);
118
+ this.log("warn", n, s);
119
+ }
120
+ error(e, ...r) {
121
+ const { event: n, metadata: s } = be(e, r);
122
+ this.log("error", n, s);
123
+ }
124
+ child(e) {
125
+ return new lt(`${this.namespace}.${e}`);
126
+ }
127
+ timer(e, r, n = "info") {
128
+ const s = typeof performance < "u" && performance.now, i = s ? performance.now() : Date.now();
129
+ return (o) => {
130
+ try {
131
+ const a = s ? performance.now() : Date.now(), h = Math.round(a - i), d = {
132
+ ...r,
133
+ ...o,
134
+ duration_ms: h
135
+ };
136
+ this.log(n, e, d);
137
+ } catch {
138
+ }
139
+ };
140
+ }
141
+ }
142
+ const C = new lt("root");
143
+ function pe(t) {
144
+ return t == null ? {} : t instanceof Map ? Object.fromEntries(
145
+ [...t.entries()].map(([e, r]) => [
146
+ e,
147
+ pe(r)
148
+ ])
149
+ ) : Array.isArray(t) ? t.map(pe) : t;
150
+ }
151
+ function ur(t) {
152
+ return {
153
+ action: t.action,
154
+ namespace: t.namespace,
155
+ name: t.name,
156
+ publicName: t.publicName,
157
+ description: t.description,
158
+ fields: t.fields,
159
+ aliases: (t.aliases ?? []).map((e) => ({
160
+ namespace: e.namespace,
161
+ name: e.name,
162
+ fields: e.fields
163
+ })),
164
+ paramsDoc: t.paramsDoc.map((e) => ({
165
+ name: e.name,
166
+ type: e.type,
167
+ required: e.required,
168
+ description: e.description
169
+ })),
170
+ returnsDoc: {
171
+ type: t.returnsDoc.type,
172
+ description: t.returnsDoc.description
173
+ },
174
+ errorCode: t.errorCode,
175
+ errorCategory: t.errorCategory ?? null,
176
+ permission: t.permission ?? null,
177
+ example: t.example ?? null,
178
+ prerequisites: t.prerequisites ?? null,
179
+ notes: t.notes ?? null,
180
+ tags: t.tags ?? null,
181
+ relatedApis: t.relatedApis ?? null
182
+ };
183
+ }
2
184
  var I;
3
185
  (function(t) {
4
186
  t.assertEqual = (s) => {
@@ -168,7 +350,7 @@ class j extends Error {
168
350
  }
169
351
  }
170
352
  j.create = (t) => new j(t);
171
- const we = (t, e) => {
353
+ const Te = (t, e) => {
172
354
  let r;
173
355
  switch (t.code) {
174
356
  case u.invalid_type:
@@ -224,11 +406,11 @@ const we = (t, e) => {
224
406
  }
225
407
  return { message: r };
226
408
  };
227
- let sr = we;
228
- function Ye() {
229
- return sr;
409
+ let fr = Te;
410
+ function Qe() {
411
+ return fr;
230
412
  }
231
- const Ke = (t) => {
413
+ const Xe = (t) => {
232
414
  const { data: e, path: r, errorMaps: n, issueData: s } = t, i = [...r, ...s.path || []], o = {
233
415
  ...s,
234
416
  path: i
@@ -250,7 +432,7 @@ const Ke = (t) => {
250
432
  };
251
433
  };
252
434
  function p(t, e) {
253
- const r = Ye(), n = Ke({
435
+ const r = Qe(), n = Xe({
254
436
  issueData: e,
255
437
  data: t.data,
256
438
  path: t.path,
@@ -261,13 +443,13 @@ function p(t, e) {
261
443
  // then schema-bound map if available
262
444
  r,
263
445
  // then global override map
264
- r === we ? void 0 : we
446
+ r === Te ? void 0 : Te
265
447
  // then global default map
266
448
  ].filter((s) => !!s)
267
449
  });
268
450
  t.common.issues.push(n);
269
451
  }
270
- class P {
452
+ class $ {
271
453
  constructor() {
272
454
  this.value = "valid";
273
455
  }
@@ -295,7 +477,7 @@ class P {
295
477
  value: o
296
478
  });
297
479
  }
298
- return P.mergeObjectSync(e, n);
480
+ return $.mergeObjectSync(e, n);
299
481
  }
300
482
  static mergeObjectSync(e, r) {
301
483
  const n = {};
@@ -310,7 +492,7 @@ class P {
310
492
  }
311
493
  const v = Object.freeze({
312
494
  status: "aborted"
313
- }), _e = (t) => ({ status: "dirty", value: t }), L = (t) => ({ status: "valid", value: t }), vt = (t) => t.status === "aborted", kt = (t) => t.status === "dirty", pe = (t) => t.status === "valid", $e = (t) => typeof Promise < "u" && t instanceof Promise;
495
+ }), _e = (t) => ({ status: "dirty", value: t }), L = (t) => ({ status: "valid", value: t }), vt = (t) => t.status === "aborted", kt = (t) => t.status === "dirty", me = (t) => t.status === "valid", Le = (t) => typeof Promise < "u" && t instanceof Promise;
314
496
  var y;
315
497
  (function(t) {
316
498
  t.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, t.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
@@ -324,7 +506,7 @@ class B {
324
506
  }
325
507
  }
326
508
  const wt = (t, e) => {
327
- if (pe(e))
509
+ if (me(e))
328
510
  return { success: !0, data: e.value };
329
511
  if (!t.common.issues.length)
330
512
  throw new Error("Validation failed but no issues detected.");
@@ -368,7 +550,7 @@ class S {
368
550
  }
369
551
  _processInputParams(e) {
370
552
  return {
371
- status: new P(),
553
+ status: new $(),
372
554
  ctx: {
373
555
  common: e.parent.common,
374
556
  data: e.data,
@@ -381,7 +563,7 @@ class S {
381
563
  }
382
564
  _parseSync(e) {
383
565
  const r = this._parse(e);
384
- if ($e(r))
566
+ if (Le(r))
385
567
  throw new Error("Synchronous parse encountered promise.");
386
568
  return r;
387
569
  }
@@ -426,7 +608,7 @@ class S {
426
608
  if (!this["~standard"].async)
427
609
  try {
428
610
  const i = this._parseSync({ data: e, path: [], parent: r });
429
- return pe(i) ? {
611
+ return me(i) ? {
430
612
  value: i.value
431
613
  } : {
432
614
  issues: r.common.issues
@@ -437,7 +619,7 @@ class S {
437
619
  async: !0
438
620
  };
439
621
  }
440
- return this._parseAsync({ data: e, path: [], parent: r }).then((i) => pe(i) ? {
622
+ return this._parseAsync({ data: e, path: [], parent: r }).then((i) => me(i) ? {
441
623
  value: i.value
442
624
  } : {
443
625
  issues: r.common.issues
@@ -461,7 +643,7 @@ class S {
461
643
  parent: null,
462
644
  data: e,
463
645
  parsedType: ee(e)
464
- }, s = this._parse({ data: e, path: n.path, parent: n }), i = await ($e(s) ? s : Promise.resolve(s));
646
+ }, s = this._parse({ data: e, path: n.path, parent: n }), i = await (Le(s) ? s : Promise.resolve(s));
465
647
  return wt(n, i);
466
648
  }
467
649
  refine(e, r) {
@@ -507,13 +689,13 @@ class S {
507
689
  return W.create(this);
508
690
  }
509
691
  promise() {
510
- return ge.create(this, this._def);
692
+ return ye.create(this, this._def);
511
693
  }
512
694
  or(e) {
513
- return Se.create([this, e], this._def);
695
+ return Ie.create([this, e], this._def);
514
696
  }
515
697
  and(e) {
516
- return Ie.create(this, e, this._def);
698
+ return Ee.create(this, e, this._def);
517
699
  }
518
700
  transform(e) {
519
701
  return new J({
@@ -525,7 +707,7 @@ class S {
525
707
  }
526
708
  default(e) {
527
709
  const r = typeof e == "function" ? e : () => e;
528
- return new Ae({
710
+ return new Ce({
529
711
  ...w(this._def),
530
712
  innerType: this,
531
713
  defaultValue: r,
@@ -533,7 +715,7 @@ class S {
533
715
  });
534
716
  }
535
717
  brand() {
536
- return new dt({
718
+ return new ut({
537
719
  typeName: k.ZodBranded,
538
720
  type: this,
539
721
  ...w(this._def)
@@ -541,7 +723,7 @@ class S {
541
723
  }
542
724
  catch(e) {
543
725
  const r = typeof e == "function" ? e : () => e;
544
- return new Ce({
726
+ return new Oe({
545
727
  ...w(this._def),
546
728
  innerType: this,
547
729
  catchValue: r,
@@ -556,10 +738,10 @@ class S {
556
738
  });
557
739
  }
558
740
  pipe(e) {
559
- return ze.create(this, e);
741
+ return qe.create(this, e);
560
742
  }
561
743
  readonly() {
562
- return Oe.create(this);
744
+ return Ne.create(this);
563
745
  }
564
746
  isOptional() {
565
747
  return this.safeParse(void 0).success;
@@ -568,28 +750,28 @@ class S {
568
750
  return this.safeParse(null).success;
569
751
  }
570
752
  }
571
- const ir = /^c[^\s-]{8,}$/i, ar = /^[0-9a-z]+$/, or = /^[0-9A-HJKMNP-TV-Z]{26}$/i, cr = /^[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, dr = /^[a-z0-9_-]{21}$/i, lr = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, ur = /^[-+]?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)?)??$/, fr = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, hr = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
572
- let He;
573
- const pr = /^(?:(?: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])$/, mr = /^(?:(?: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])$/, gr = /^(([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]))$/, yr = /^(([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])$/, br = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, _r = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, Nt = "((\\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])))", vr = new RegExp(`^${Nt}$`);
574
- function Mt(t) {
753
+ const hr = /^c[^\s-]{8,}$/i, pr = /^[0-9a-z]+$/, mr = /^[0-9A-HJKMNP-TV-Z]{26}$/i, gr = /^[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, yr = /^[a-z0-9_-]{21}$/i, br = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, _r = /^[-+]?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)?)??$/, vr = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, kr = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
754
+ let Ge;
755
+ const wr = /^(?:(?: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])$/, Tr = /^(?:(?: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])$/, xr = /^(([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]))$/, Sr = /^(([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])$/, Ir = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Er = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, Mt = "((\\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(`^${Mt}$`);
756
+ function Pt(t) {
575
757
  let e = "[0-5]\\d";
576
758
  t.precision ? e = `${e}\\.\\d{${t.precision}}` : t.precision == null && (e = `${e}(\\.\\d+)?`);
577
759
  const r = t.precision ? "+" : "?";
578
760
  return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`;
579
761
  }
580
- function kr(t) {
581
- return new RegExp(`^${Mt(t)}$`);
762
+ function Ar(t) {
763
+ return new RegExp(`^${Pt(t)}$`);
582
764
  }
583
- function wr(t) {
584
- let e = `${Nt}T${Mt(t)}`;
765
+ function Cr(t) {
766
+ let e = `${Mt}T${Pt(t)}`;
585
767
  const r = [];
586
768
  return r.push(t.local ? "Z?" : "Z"), t.offset && r.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${r.join("|")})`, new RegExp(`^${e}$`);
587
769
  }
588
- function Tr(t, e) {
589
- return !!((e === "v4" || !e) && pr.test(t) || (e === "v6" || !e) && gr.test(t));
770
+ function Or(t, e) {
771
+ return !!((e === "v4" || !e) && wr.test(t) || (e === "v6" || !e) && xr.test(t));
590
772
  }
591
- function xr(t, e) {
592
- if (!lr.test(t))
773
+ function Nr(t, e) {
774
+ if (!br.test(t))
593
775
  return !1;
594
776
  try {
595
777
  const [r] = t.split(".");
@@ -601,8 +783,8 @@ function xr(t, e) {
601
783
  return !1;
602
784
  }
603
785
  }
604
- function Sr(t, e) {
605
- return !!((e === "v4" || !e) && mr.test(t) || (e === "v6" || !e) && yr.test(t));
786
+ function Mr(t, e) {
787
+ return !!((e === "v4" || !e) && Tr.test(t) || (e === "v6" || !e) && Sr.test(t));
606
788
  }
607
789
  class U extends S {
608
790
  _parse(e) {
@@ -614,7 +796,7 @@ class U extends S {
614
796
  received: i.parsedType
615
797
  }), v;
616
798
  }
617
- const n = new P();
799
+ const n = new $();
618
800
  let s;
619
801
  for (const i of this._def.checks)
620
802
  if (i.kind === "min")
@@ -653,43 +835,43 @@ class U extends S {
653
835
  message: i.message
654
836
  }), n.dirty());
655
837
  } else if (i.kind === "email")
656
- fr.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
838
+ vr.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
657
839
  validation: "email",
658
840
  code: u.invalid_string,
659
841
  message: i.message
660
842
  }), n.dirty());
661
843
  else if (i.kind === "emoji")
662
- He || (He = new RegExp(hr, "u")), He.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
844
+ Ge || (Ge = new RegExp(kr, "u")), Ge.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
663
845
  validation: "emoji",
664
846
  code: u.invalid_string,
665
847
  message: i.message
666
848
  }), n.dirty());
667
849
  else if (i.kind === "uuid")
668
- cr.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
850
+ gr.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
669
851
  validation: "uuid",
670
852
  code: u.invalid_string,
671
853
  message: i.message
672
854
  }), n.dirty());
673
855
  else if (i.kind === "nanoid")
674
- dr.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
856
+ yr.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
675
857
  validation: "nanoid",
676
858
  code: u.invalid_string,
677
859
  message: i.message
678
860
  }), n.dirty());
679
861
  else if (i.kind === "cuid")
680
- ir.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
862
+ hr.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
681
863
  validation: "cuid",
682
864
  code: u.invalid_string,
683
865
  message: i.message
684
866
  }), n.dirty());
685
867
  else if (i.kind === "cuid2")
686
- ar.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
868
+ pr.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
687
869
  validation: "cuid2",
688
870
  code: u.invalid_string,
689
871
  message: i.message
690
872
  }), n.dirty());
691
873
  else if (i.kind === "ulid")
692
- or.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
874
+ mr.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
693
875
  validation: "ulid",
694
876
  code: u.invalid_string,
695
877
  message: i.message
@@ -720,39 +902,39 @@ class U extends S {
720
902
  code: u.invalid_string,
721
903
  validation: { endsWith: i.value },
722
904
  message: i.message
723
- }), n.dirty()) : i.kind === "datetime" ? wr(i).test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
905
+ }), n.dirty()) : i.kind === "datetime" ? Cr(i).test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
724
906
  code: u.invalid_string,
725
907
  validation: "datetime",
726
908
  message: i.message
727
- }), n.dirty()) : i.kind === "date" ? vr.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
909
+ }), n.dirty()) : i.kind === "date" ? Rr.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
728
910
  code: u.invalid_string,
729
911
  validation: "date",
730
912
  message: i.message
731
- }), n.dirty()) : i.kind === "time" ? kr(i).test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
913
+ }), n.dirty()) : i.kind === "time" ? Ar(i).test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
732
914
  code: u.invalid_string,
733
915
  validation: "time",
734
916
  message: i.message
735
- }), n.dirty()) : i.kind === "duration" ? ur.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
917
+ }), n.dirty()) : i.kind === "duration" ? _r.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
736
918
  validation: "duration",
737
919
  code: u.invalid_string,
738
920
  message: i.message
739
- }), n.dirty()) : i.kind === "ip" ? Tr(e.data, i.version) || (s = this._getOrReturnCtx(e, s), p(s, {
921
+ }), n.dirty()) : i.kind === "ip" ? Or(e.data, i.version) || (s = this._getOrReturnCtx(e, s), p(s, {
740
922
  validation: "ip",
741
923
  code: u.invalid_string,
742
924
  message: i.message
743
- }), n.dirty()) : i.kind === "jwt" ? xr(e.data, i.alg) || (s = this._getOrReturnCtx(e, s), p(s, {
925
+ }), n.dirty()) : i.kind === "jwt" ? Nr(e.data, i.alg) || (s = this._getOrReturnCtx(e, s), p(s, {
744
926
  validation: "jwt",
745
927
  code: u.invalid_string,
746
928
  message: i.message
747
- }), n.dirty()) : i.kind === "cidr" ? Sr(e.data, i.version) || (s = this._getOrReturnCtx(e, s), p(s, {
929
+ }), n.dirty()) : i.kind === "cidr" ? Mr(e.data, i.version) || (s = this._getOrReturnCtx(e, s), p(s, {
748
930
  validation: "cidr",
749
931
  code: u.invalid_string,
750
932
  message: i.message
751
- }), n.dirty()) : i.kind === "base64" ? br.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
933
+ }), n.dirty()) : i.kind === "base64" ? Ir.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
752
934
  validation: "base64",
753
935
  code: u.invalid_string,
754
936
  message: i.message
755
- }), n.dirty()) : i.kind === "base64url" ? _r.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
937
+ }), n.dirty()) : i.kind === "base64url" ? Er.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
756
938
  validation: "base64url",
757
939
  code: u.invalid_string,
758
940
  message: i.message
@@ -987,7 +1169,7 @@ U.create = (t) => new U({
987
1169
  coerce: (t == null ? void 0 : t.coerce) ?? !1,
988
1170
  ...w(t)
989
1171
  });
990
- function Ir(t, e) {
1172
+ function Pr(t, e) {
991
1173
  const r = (t.toString().split(".")[1] || "").length, n = (e.toString().split(".")[1] || "").length, s = r > n ? r : n, i = Number.parseInt(t.toFixed(s).replace(".", "")), o = Number.parseInt(e.toFixed(s).replace(".", ""));
992
1174
  return i % o / 10 ** s;
993
1175
  }
@@ -1005,7 +1187,7 @@ class ae extends S {
1005
1187
  }), v;
1006
1188
  }
1007
1189
  let n;
1008
- const s = new P();
1190
+ const s = new $();
1009
1191
  for (const i of this._def.checks)
1010
1192
  i.kind === "int" ? I.isInteger(e.data) || (n = this._getOrReturnCtx(e, n), p(n, {
1011
1193
  code: u.invalid_type,
@@ -1026,7 +1208,7 @@ class ae extends S {
1026
1208
  inclusive: i.inclusive,
1027
1209
  exact: !1,
1028
1210
  message: i.message
1029
- }), s.dirty()) : i.kind === "multipleOf" ? Ir(e.data, i.value) !== 0 && (n = this._getOrReturnCtx(e, n), p(n, {
1211
+ }), s.dirty()) : i.kind === "multipleOf" ? Pr(e.data, i.value) !== 0 && (n = this._getOrReturnCtx(e, n), p(n, {
1030
1212
  code: u.not_multiple_of,
1031
1213
  multipleOf: i.value,
1032
1214
  message: i.message
@@ -1177,7 +1359,7 @@ class oe extends S {
1177
1359
  if (this._getType(e) !== g.bigint)
1178
1360
  return this._getInvalidInput(e);
1179
1361
  let n;
1180
- const s = new P();
1362
+ const s = new $();
1181
1363
  for (const i of this._def.checks)
1182
1364
  i.kind === "min" ? (i.inclusive ? e.data < i.value : e.data <= i.value) && (n = this._getOrReturnCtx(e, n), p(n, {
1183
1365
  code: u.too_small,
@@ -1296,7 +1478,7 @@ oe.create = (t) => new oe({
1296
1478
  coerce: (t == null ? void 0 : t.coerce) ?? !1,
1297
1479
  ...w(t)
1298
1480
  });
1299
- class Pe extends S {
1481
+ class je extends S {
1300
1482
  _parse(e) {
1301
1483
  if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== g.boolean) {
1302
1484
  const n = this._getOrReturnCtx(e);
@@ -1309,12 +1491,12 @@ class Pe extends S {
1309
1491
  return L(e.data);
1310
1492
  }
1311
1493
  }
1312
- Pe.create = (t) => new Pe({
1494
+ je.create = (t) => new je({
1313
1495
  typeName: k.ZodBoolean,
1314
1496
  coerce: (t == null ? void 0 : t.coerce) || !1,
1315
1497
  ...w(t)
1316
1498
  });
1317
- class Te extends S {
1499
+ class xe extends S {
1318
1500
  _parse(e) {
1319
1501
  if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== g.date) {
1320
1502
  const i = this._getOrReturnCtx(e);
@@ -1330,7 +1512,7 @@ class Te extends S {
1330
1512
  code: u.invalid_date
1331
1513
  }), v;
1332
1514
  }
1333
- const n = new P();
1515
+ const n = new $();
1334
1516
  let s;
1335
1517
  for (const i of this._def.checks)
1336
1518
  i.kind === "min" ? e.data.getTime() < i.value && (s = this._getOrReturnCtx(e, s), p(s, {
@@ -1354,7 +1536,7 @@ class Te extends S {
1354
1536
  };
1355
1537
  }
1356
1538
  _addCheck(e) {
1357
- return new Te({
1539
+ return new xe({
1358
1540
  ...this._def,
1359
1541
  checks: [...this._def.checks, e]
1360
1542
  });
@@ -1386,7 +1568,7 @@ class Te extends S {
1386
1568
  return e != null ? new Date(e) : null;
1387
1569
  }
1388
1570
  }
1389
- Te.create = (t) => new Te({
1571
+ xe.create = (t) => new xe({
1390
1572
  checks: [],
1391
1573
  coerce: (t == null ? void 0 : t.coerce) || !1,
1392
1574
  typeName: k.ZodDate,
@@ -1409,7 +1591,7 @@ Tt.create = (t) => new Tt({
1409
1591
  typeName: k.ZodSymbol,
1410
1592
  ...w(t)
1411
1593
  });
1412
- class Le extends S {
1594
+ class De extends S {
1413
1595
  _parse(e) {
1414
1596
  if (this._getType(e) !== g.undefined) {
1415
1597
  const n = this._getOrReturnCtx(e);
@@ -1422,11 +1604,11 @@ class Le extends S {
1422
1604
  return L(e.data);
1423
1605
  }
1424
1606
  }
1425
- Le.create = (t) => new Le({
1607
+ De.create = (t) => new De({
1426
1608
  typeName: k.ZodUndefined,
1427
1609
  ...w(t)
1428
1610
  });
1429
- class xe extends S {
1611
+ class Se extends S {
1430
1612
  _parse(e) {
1431
1613
  if (this._getType(e) !== g.null) {
1432
1614
  const n = this._getOrReturnCtx(e);
@@ -1439,11 +1621,11 @@ class xe extends S {
1439
1621
  return L(e.data);
1440
1622
  }
1441
1623
  }
1442
- xe.create = (t) => new xe({
1624
+ Se.create = (t) => new Se({
1443
1625
  typeName: k.ZodNull,
1444
1626
  ...w(t)
1445
1627
  });
1446
- class Qe extends S {
1628
+ class et extends S {
1447
1629
  constructor() {
1448
1630
  super(...arguments), this._any = !0;
1449
1631
  }
@@ -1451,7 +1633,7 @@ class Qe extends S {
1451
1633
  return L(e.data);
1452
1634
  }
1453
1635
  }
1454
- Qe.create = (t) => new Qe({
1636
+ et.create = (t) => new et({
1455
1637
  typeName: k.ZodAny,
1456
1638
  ...w(t)
1457
1639
  });
@@ -1481,7 +1663,7 @@ te.create = (t) => new te({
1481
1663
  typeName: k.ZodNever,
1482
1664
  ...w(t)
1483
1665
  });
1484
- class Xe extends S {
1666
+ class tt extends S {
1485
1667
  _parse(e) {
1486
1668
  if (this._getType(e) !== g.undefined) {
1487
1669
  const n = this._getOrReturnCtx(e);
@@ -1494,7 +1676,7 @@ class Xe extends S {
1494
1676
  return L(e.data);
1495
1677
  }
1496
1678
  }
1497
- Xe.create = (t) => new Xe({
1679
+ tt.create = (t) => new tt({
1498
1680
  typeName: k.ZodVoid,
1499
1681
  ...w(t)
1500
1682
  });
@@ -1534,9 +1716,9 @@ class W extends S {
1534
1716
  exact: !1,
1535
1717
  message: s.maxLength.message
1536
1718
  }), n.dirty()), r.common.async)
1537
- return Promise.all([...r.data].map((o, a) => s.type._parseAsync(new B(r, o, r.path, a)))).then((o) => P.mergeArray(n, o));
1719
+ return Promise.all([...r.data].map((o, a) => s.type._parseAsync(new B(r, o, r.path, a)))).then((o) => $.mergeArray(n, o));
1538
1720
  const i = [...r.data].map((o, a) => s.type._parseSync(new B(r, o, r.path, a)));
1539
- return P.mergeArray(n, i);
1721
+ return $.mergeArray(n, i);
1540
1722
  }
1541
1723
  get element() {
1542
1724
  return this._def.type;
@@ -1650,15 +1832,15 @@ class A extends S {
1650
1832
  return s.common.async ? Promise.resolve().then(async () => {
1651
1833
  const d = [];
1652
1834
  for (const m of h) {
1653
- const R = await m.key, $ = await m.value;
1835
+ const R = await m.key, P = await m.value;
1654
1836
  d.push({
1655
1837
  key: R,
1656
- value: $,
1838
+ value: P,
1657
1839
  alwaysSet: m.alwaysSet
1658
1840
  });
1659
1841
  }
1660
1842
  return d;
1661
- }).then((d) => P.mergeObjectSync(n, d)) : P.mergeObjectSync(n, h);
1843
+ }).then((d) => $.mergeObjectSync(n, d)) : $.mergeObjectSync(n, h);
1662
1844
  }
1663
1845
  get shape() {
1664
1846
  return this._def.shape();
@@ -1875,7 +2057,7 @@ A.lazycreate = (t, e) => new A({
1875
2057
  typeName: k.ZodObject,
1876
2058
  ...w(e)
1877
2059
  });
1878
- class Se extends S {
2060
+ class Ie extends S {
1879
2061
  _parse(e) {
1880
2062
  const { ctx: r } = this._processInputParams(e), n = this._def.options;
1881
2063
  function s(i) {
@@ -1943,13 +2125,13 @@ class Se extends S {
1943
2125
  return this._def.options;
1944
2126
  }
1945
2127
  }
1946
- Se.create = (t, e) => new Se({
2128
+ Ie.create = (t, e) => new Ie({
1947
2129
  options: t,
1948
2130
  typeName: k.ZodUnion,
1949
2131
  ...w(e)
1950
2132
  });
1951
- const G = (t) => t instanceof je ? G(t.schema) : t instanceof J ? G(t.innerType()) : t instanceof Re ? [t.value] : t instanceof re ? t.options : t instanceof rt ? I.objectValues(t.enum) : t instanceof Ae ? G(t._def.innerType) : t instanceof Le ? [void 0] : t instanceof xe ? [null] : t instanceof V ? [void 0, ...G(t.unwrap())] : t instanceof ne ? [null, ...G(t.unwrap())] : t instanceof dt || t instanceof Oe ? G(t.unwrap()) : t instanceof Ce ? G(t._def.innerType) : [];
1952
- class Be extends S {
2133
+ const G = (t) => t instanceof Ze ? G(t.schema) : t instanceof J ? G(t.innerType()) : t instanceof Ae ? [t.value] : t instanceof re ? t.options : t instanceof st ? I.objectValues(t.enum) : t instanceof Ce ? G(t._def.innerType) : t instanceof De ? [void 0] : t instanceof Se ? [null] : t instanceof V ? [void 0, ...G(t.unwrap())] : t instanceof ne ? [null, ...G(t.unwrap())] : t instanceof ut || t instanceof Ne ? G(t.unwrap()) : t instanceof Oe ? G(t._def.innerType) : [];
2134
+ class ze extends S {
1953
2135
  _parse(e) {
1954
2136
  const { ctx: r } = this._processInputParams(e);
1955
2137
  if (r.parsedType !== g.object)
@@ -2002,7 +2184,7 @@ class Be extends S {
2002
2184
  s.set(a, i);
2003
2185
  }
2004
2186
  }
2005
- return new Be({
2187
+ return new ze({
2006
2188
  typeName: k.ZodDiscriminatedUnion,
2007
2189
  discriminator: e,
2008
2190
  options: r,
@@ -2011,14 +2193,14 @@ class Be extends S {
2011
2193
  });
2012
2194
  }
2013
2195
  }
2014
- function et(t, e) {
2196
+ function rt(t, e) {
2015
2197
  const r = ee(t), n = ee(e);
2016
2198
  if (t === e)
2017
2199
  return { valid: !0, data: t };
2018
2200
  if (r === g.object && n === g.object) {
2019
2201
  const s = I.objectKeys(e), i = I.objectKeys(t).filter((a) => s.indexOf(a) !== -1), o = { ...t, ...e };
2020
2202
  for (const a of i) {
2021
- const h = et(t[a], e[a]);
2203
+ const h = rt(t[a], e[a]);
2022
2204
  if (!h.valid)
2023
2205
  return { valid: !1 };
2024
2206
  o[a] = h.data;
@@ -2029,7 +2211,7 @@ function et(t, e) {
2029
2211
  return { valid: !1 };
2030
2212
  const s = [];
2031
2213
  for (let i = 0; i < t.length; i++) {
2032
- const o = t[i], a = e[i], h = et(o, a);
2214
+ const o = t[i], a = e[i], h = rt(o, a);
2033
2215
  if (!h.valid)
2034
2216
  return { valid: !1 };
2035
2217
  s.push(h.data);
@@ -2037,12 +2219,12 @@ function et(t, e) {
2037
2219
  return { valid: !0, data: s };
2038
2220
  } else return r === g.date && n === g.date && +t == +e ? { valid: !0, data: t } : { valid: !1 };
2039
2221
  }
2040
- class Ie extends S {
2222
+ class Ee extends S {
2041
2223
  _parse(e) {
2042
2224
  const { status: r, ctx: n } = this._processInputParams(e), s = (i, o) => {
2043
2225
  if (vt(i) || vt(o))
2044
2226
  return v;
2045
- const a = et(i.value, o.value);
2227
+ const a = rt(i.value, o.value);
2046
2228
  return a.valid ? ((kt(i) || kt(o)) && r.dirty(), { status: r.value, value: a.data }) : (p(n, {
2047
2229
  code: u.invalid_intersection_types
2048
2230
  }), v);
@@ -2069,7 +2251,7 @@ class Ie extends S {
2069
2251
  }));
2070
2252
  }
2071
2253
  }
2072
- Ie.create = (t, e, r) => new Ie({
2254
+ Ee.create = (t, e, r) => new Ee({
2073
2255
  left: t,
2074
2256
  right: e,
2075
2257
  typeName: k.ZodIntersection,
@@ -2103,7 +2285,7 @@ class z extends S {
2103
2285
  const h = this._def.items[a] || this._def.rest;
2104
2286
  return h ? h._parse(new B(n, o, n.path, a)) : null;
2105
2287
  }).filter((o) => !!o);
2106
- return n.common.async ? Promise.all(i).then((o) => P.mergeArray(r, o)) : P.mergeArray(r, i);
2288
+ return n.common.async ? Promise.all(i).then((o) => $.mergeArray(r, o)) : $.mergeArray(r, i);
2107
2289
  }
2108
2290
  get items() {
2109
2291
  return this._def.items;
@@ -2125,7 +2307,7 @@ z.create = (t, e) => {
2125
2307
  ...w(e)
2126
2308
  });
2127
2309
  };
2128
- class Ee extends S {
2310
+ class Re extends S {
2129
2311
  get keySchema() {
2130
2312
  return this._def.keyType;
2131
2313
  }
@@ -2147,18 +2329,18 @@ class Ee extends S {
2147
2329
  value: o._parse(new B(n, n.data[a], n.path, a)),
2148
2330
  alwaysSet: a in n.data
2149
2331
  });
2150
- return n.common.async ? P.mergeObjectAsync(r, s) : P.mergeObjectSync(r, s);
2332
+ return n.common.async ? $.mergeObjectAsync(r, s) : $.mergeObjectSync(r, s);
2151
2333
  }
2152
2334
  get element() {
2153
2335
  return this._def.valueType;
2154
2336
  }
2155
2337
  static create(e, r, n) {
2156
- return r instanceof S ? new Ee({
2338
+ return r instanceof S ? new Re({
2157
2339
  keyType: e,
2158
2340
  valueType: r,
2159
2341
  typeName: k.ZodRecord,
2160
2342
  ...w(n)
2161
- }) : new Ee({
2343
+ }) : new Re({
2162
2344
  keyType: U.create(),
2163
2345
  valueType: e,
2164
2346
  typeName: k.ZodRecord,
@@ -2166,7 +2348,7 @@ class Ee extends S {
2166
2348
  });
2167
2349
  }
2168
2350
  }
2169
- class tt extends S {
2351
+ class nt extends S {
2170
2352
  get keySchema() {
2171
2353
  return this._def.keyType;
2172
2354
  }
@@ -2208,13 +2390,13 @@ class tt extends S {
2208
2390
  }
2209
2391
  }
2210
2392
  }
2211
- tt.create = (t, e, r) => new tt({
2393
+ nt.create = (t, e, r) => new nt({
2212
2394
  valueType: e,
2213
2395
  keyType: t,
2214
2396
  typeName: k.ZodMap,
2215
2397
  ...w(r)
2216
2398
  });
2217
- class me extends S {
2399
+ class ge extends S {
2218
2400
  _parse(e) {
2219
2401
  const { status: r, ctx: n } = this._processInputParams(e);
2220
2402
  if (n.parsedType !== g.set)
@@ -2253,13 +2435,13 @@ class me extends S {
2253
2435
  return n.common.async ? Promise.all(a).then((h) => o(h)) : o(a);
2254
2436
  }
2255
2437
  min(e, r) {
2256
- return new me({
2438
+ return new ge({
2257
2439
  ...this._def,
2258
2440
  minSize: { value: e, message: y.toString(r) }
2259
2441
  });
2260
2442
  }
2261
2443
  max(e, r) {
2262
- return new me({
2444
+ return new ge({
2263
2445
  ...this._def,
2264
2446
  maxSize: { value: e, message: y.toString(r) }
2265
2447
  });
@@ -2271,7 +2453,7 @@ class me extends S {
2271
2453
  return this.min(1, e);
2272
2454
  }
2273
2455
  }
2274
- me.create = (t, e) => new me({
2456
+ ge.create = (t, e) => new ge({
2275
2457
  valueType: t,
2276
2458
  minSize: null,
2277
2459
  maxSize: null,
@@ -2291,10 +2473,10 @@ class ke extends S {
2291
2473
  received: r.parsedType
2292
2474
  }), v;
2293
2475
  function n(a, h) {
2294
- return Ke({
2476
+ return Xe({
2295
2477
  data: a,
2296
2478
  path: r.path,
2297
- errorMaps: [r.common.contextualErrorMap, r.schemaErrorMap, Ye(), we].filter((d) => !!d),
2479
+ errorMaps: [r.common.contextualErrorMap, r.schemaErrorMap, Qe(), Te].filter((d) => !!d),
2298
2480
  issueData: {
2299
2481
  code: u.invalid_arguments,
2300
2482
  argumentsError: h
@@ -2302,10 +2484,10 @@ class ke extends S {
2302
2484
  });
2303
2485
  }
2304
2486
  function s(a, h) {
2305
- return Ke({
2487
+ return Xe({
2306
2488
  data: a,
2307
2489
  path: r.path,
2308
- errorMaps: [r.common.contextualErrorMap, r.schemaErrorMap, Ye(), we].filter((d) => !!d),
2490
+ errorMaps: [r.common.contextualErrorMap, r.schemaErrorMap, Qe(), Te].filter((d) => !!d),
2309
2491
  issueData: {
2310
2492
  code: u.invalid_return_type,
2311
2493
  returnTypeError: h
@@ -2313,7 +2495,7 @@ class ke extends S {
2313
2495
  });
2314
2496
  }
2315
2497
  const i = { errorMap: r.common.contextualErrorMap }, o = r.data;
2316
- if (this._def.returns instanceof ge) {
2498
+ if (this._def.returns instanceof ye) {
2317
2499
  const a = this;
2318
2500
  return L(async function(...h) {
2319
2501
  const d = new j([]), m = await a._def.args.parseAsync(h, i).catch((Q) => {
@@ -2369,7 +2551,7 @@ class ke extends S {
2369
2551
  });
2370
2552
  }
2371
2553
  }
2372
- class je extends S {
2554
+ class Ze extends S {
2373
2555
  get schema() {
2374
2556
  return this._def.getter();
2375
2557
  }
@@ -2378,12 +2560,12 @@ class je extends S {
2378
2560
  return this._def.getter()._parse({ data: r.data, path: r.path, parent: r });
2379
2561
  }
2380
2562
  }
2381
- je.create = (t, e) => new je({
2563
+ Ze.create = (t, e) => new Ze({
2382
2564
  getter: t,
2383
2565
  typeName: k.ZodLazy,
2384
2566
  ...w(e)
2385
2567
  });
2386
- class Re extends S {
2568
+ class Ae extends S {
2387
2569
  _parse(e) {
2388
2570
  if (e.data !== this._def.value) {
2389
2571
  const r = this._getOrReturnCtx(e);
@@ -2399,7 +2581,7 @@ class Re extends S {
2399
2581
  return this._def.value;
2400
2582
  }
2401
2583
  }
2402
- Re.create = (t, e) => new Re({
2584
+ Ae.create = (t, e) => new Ae({
2403
2585
  value: t,
2404
2586
  typeName: k.ZodLiteral,
2405
2587
  ...w(e)
@@ -2466,7 +2648,7 @@ class re extends S {
2466
2648
  }
2467
2649
  }
2468
2650
  re.create = $t;
2469
- class rt extends S {
2651
+ class st extends S {
2470
2652
  _parse(e) {
2471
2653
  const r = I.getValidEnumValues(this._def.values), n = this._getOrReturnCtx(e);
2472
2654
  if (n.parsedType !== g.string && n.parsedType !== g.number) {
@@ -2491,12 +2673,12 @@ class rt extends S {
2491
2673
  return this._def.values;
2492
2674
  }
2493
2675
  }
2494
- rt.create = (t, e) => new rt({
2676
+ st.create = (t, e) => new st({
2495
2677
  values: t,
2496
2678
  typeName: k.ZodNativeEnum,
2497
2679
  ...w(e)
2498
2680
  });
2499
- class ge extends S {
2681
+ class ye extends S {
2500
2682
  unwrap() {
2501
2683
  return this._def.type;
2502
2684
  }
@@ -2515,7 +2697,7 @@ class ge extends S {
2515
2697
  })));
2516
2698
  }
2517
2699
  }
2518
- ge.create = (t, e) => new ge({
2700
+ ye.create = (t, e) => new ye({
2519
2701
  type: t,
2520
2702
  typeName: k.ZodPromise,
2521
2703
  ...w(e)
@@ -2586,14 +2768,14 @@ class J extends S {
2586
2768
  path: n.path,
2587
2769
  parent: n
2588
2770
  });
2589
- if (!pe(o))
2771
+ if (!me(o))
2590
2772
  return v;
2591
2773
  const a = s.transform(o.value, i);
2592
2774
  if (a instanceof Promise)
2593
2775
  throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
2594
2776
  return { status: r.value, value: a };
2595
2777
  } else
2596
- return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((o) => pe(o) ? Promise.resolve(s.transform(o.value, i)).then((a) => ({
2778
+ return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((o) => me(o) ? Promise.resolve(s.transform(o.value, i)).then((a) => ({
2597
2779
  status: r.value,
2598
2780
  value: a
2599
2781
  })) : v);
@@ -2638,7 +2820,7 @@ ne.create = (t, e) => new ne({
2638
2820
  typeName: k.ZodNullable,
2639
2821
  ...w(e)
2640
2822
  });
2641
- class Ae extends S {
2823
+ class Ce extends S {
2642
2824
  _parse(e) {
2643
2825
  const { ctx: r } = this._processInputParams(e);
2644
2826
  let n = r.data;
@@ -2652,13 +2834,13 @@ class Ae extends S {
2652
2834
  return this._def.innerType;
2653
2835
  }
2654
2836
  }
2655
- Ae.create = (t, e) => new Ae({
2837
+ Ce.create = (t, e) => new Ce({
2656
2838
  innerType: t,
2657
2839
  typeName: k.ZodDefault,
2658
2840
  defaultValue: typeof e.default == "function" ? e.default : () => e.default,
2659
2841
  ...w(e)
2660
2842
  });
2661
- class Ce extends S {
2843
+ class Oe extends S {
2662
2844
  _parse(e) {
2663
2845
  const { ctx: r } = this._processInputParams(e), n = {
2664
2846
  ...r,
@@ -2673,7 +2855,7 @@ class Ce extends S {
2673
2855
  ...n
2674
2856
  }
2675
2857
  });
2676
- return $e(s) ? s.then((i) => ({
2858
+ return Le(s) ? s.then((i) => ({
2677
2859
  status: "valid",
2678
2860
  value: i.status === "valid" ? i.value : this._def.catchValue({
2679
2861
  get error() {
@@ -2695,13 +2877,13 @@ class Ce extends S {
2695
2877
  return this._def.innerType;
2696
2878
  }
2697
2879
  }
2698
- Ce.create = (t, e) => new Ce({
2880
+ Oe.create = (t, e) => new Oe({
2699
2881
  innerType: t,
2700
2882
  typeName: k.ZodCatch,
2701
2883
  catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
2702
2884
  ...w(e)
2703
2885
  });
2704
- class nt extends S {
2886
+ class it extends S {
2705
2887
  _parse(e) {
2706
2888
  if (this._getType(e) !== g.nan) {
2707
2889
  const n = this._getOrReturnCtx(e);
@@ -2714,11 +2896,11 @@ class nt extends S {
2714
2896
  return { status: "valid", value: e.data };
2715
2897
  }
2716
2898
  }
2717
- nt.create = (t) => new nt({
2899
+ it.create = (t) => new it({
2718
2900
  typeName: k.ZodNaN,
2719
2901
  ...w(t)
2720
2902
  });
2721
- class dt extends S {
2903
+ class ut extends S {
2722
2904
  _parse(e) {
2723
2905
  const { ctx: r } = this._processInputParams(e), n = r.data;
2724
2906
  return this._def.type._parse({
@@ -2731,7 +2913,7 @@ class dt extends S {
2731
2913
  return this._def.type;
2732
2914
  }
2733
2915
  }
2734
- class ze extends S {
2916
+ class qe extends S {
2735
2917
  _parse(e) {
2736
2918
  const { status: r, ctx: n } = this._processInputParams(e);
2737
2919
  if (n.common.async)
@@ -2764,23 +2946,23 @@ class ze extends S {
2764
2946
  }
2765
2947
  }
2766
2948
  static create(e, r) {
2767
- return new ze({
2949
+ return new qe({
2768
2950
  in: e,
2769
2951
  out: r,
2770
2952
  typeName: k.ZodPipeline
2771
2953
  });
2772
2954
  }
2773
2955
  }
2774
- class Oe extends S {
2956
+ class Ne extends S {
2775
2957
  _parse(e) {
2776
- const r = this._def.innerType._parse(e), n = (s) => (pe(s) && (s.value = Object.freeze(s.value)), s);
2777
- return $e(r) ? r.then((s) => n(s)) : n(r);
2958
+ const r = this._def.innerType._parse(e), n = (s) => (me(s) && (s.value = Object.freeze(s.value)), s);
2959
+ return Le(r) ? r.then((s) => n(s)) : n(r);
2778
2960
  }
2779
2961
  unwrap() {
2780
2962
  return this._def.innerType;
2781
2963
  }
2782
2964
  }
2783
- Oe.create = (t, e) => new Oe({
2965
+ Ne.create = (t, e) => new Ne({
2784
2966
  innerType: t,
2785
2967
  typeName: k.ZodReadonly,
2786
2968
  ...w(e)
@@ -2789,15 +2971,95 @@ var k;
2789
2971
  (function(t) {
2790
2972
  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
2973
  })(k || (k = {}));
2792
- const c = U.create, f = ae.create, q = oe.create, T = Pe.create, Pt = xe.create, _ = ie.create;
2974
+ const c = U.create, f = ae.create, q = oe.create, T = je.create, Lt = Se.create, _ = ie.create;
2793
2975
  te.create;
2794
- const E = W.create, l = A.create, x = Se.create, Er = Be.create;
2795
- Ie.create;
2796
- const Rr = z.create, b = Ee.create, st = Re.create, De = re.create;
2797
- ge.create;
2976
+ const E = W.create, l = A.create, x = Ie.create, $r = ze.create;
2977
+ Ee.create;
2978
+ const Lr = z.create, b = Re.create, we = Ae.create, We = re.create;
2979
+ ye.create;
2798
2980
  V.create;
2799
2981
  ne.create;
2800
- const Y = J.createWithPreprocess, D = () => x([q(), f().finite()]).transform((t) => BigInt(t));
2982
+ const Y = J.createWithPreprocess;
2983
+ function N(t, e = 0, r = 2) {
2984
+ if (e > r) return "...";
2985
+ if (t instanceof A) {
2986
+ const n = t.shape, s = Object.keys(n).filter((o) => !o.startsWith("__"));
2987
+ return s.length === 0 ? "{ }" : e >= r - 1 ? "{ ... }" : `{ ${s.map((o) => {
2988
+ const a = n[o], h = a instanceof V, d = N(h ? a.unwrap() : a, e + 1, r);
2989
+ return `${o}${h ? "?" : ""}: ${d}`;
2990
+ }).join(", ")} }`;
2991
+ }
2992
+ if (t instanceof Ie)
2993
+ return t.options.map((n) => N(n, e, r)).join(" or ");
2994
+ if (t instanceof U) return "string";
2995
+ if (t instanceof ae) return "number";
2996
+ if (t instanceof je) return "boolean";
2997
+ if (t instanceof oe) return "bigint";
2998
+ if (t instanceof Se) return "null";
2999
+ if (t instanceof W) {
3000
+ const n = N(t.element, e + 1, r);
3001
+ return n === "unknown" || n === "any" ? "array" : `${n}[]`;
3002
+ }
3003
+ if (t instanceof z)
3004
+ return `[${t.items.map((n) => N(n, e + 1, r)).join(", ")}]`;
3005
+ if (t instanceof Re) {
3006
+ const n = N(
3007
+ t._def.valueType,
3008
+ e + 1,
3009
+ r
3010
+ );
3011
+ return n === "unknown" || n === "any" ? "{ [key: string]: unknown }" : `{ [key: string]: ${n} }`;
3012
+ }
3013
+ return t instanceof V ? `${N(t.unwrap(), e, r)}?` : t instanceof Ae ? JSON.stringify(t.value) : t instanceof re ? t.options.map((n) => `"${n}"`).join(" | ") : t instanceof et ? "any" : t instanceof ie ? "unknown" : t instanceof tt ? "void" : t instanceof De ? "undefined" : t instanceof J ? N(t.innerType(), e, r) : t instanceof Ce ? N(t.removeDefault(), e, r) : t instanceof ne ? `${N(t.unwrap(), e, r)} | null` : t instanceof Ze ? "lazy" : t instanceof ye ? `Promise<${N(t.unwrap(), e + 1, r)}>` : t instanceof ke ? "function" : t instanceof xe ? "Date" : t instanceof nt ? "Map" : t instanceof ge ? "Set" : t instanceof Ee ? `${N(t._def.left, e, r)} & ${N(t._def.right, e, r)}` : t instanceof ze ? t.options.map((n) => N(n, e, r)).join(" or ") : t instanceof ut ? N(t.unwrap(), e, r) : t instanceof it ? "NaN" : t instanceof Oe ? N(t.removeCatch(), e, r) : t instanceof qe ? N(t._def.in, e, r) : t instanceof Ne ? `readonly ${N(t.unwrap(), e, r)}` : "unknown";
3014
+ }
3015
+ function jr(t) {
3016
+ return t === null ? "null" : t === void 0 ? "undefined" : Array.isArray(t) ? "array" : typeof t;
3017
+ }
3018
+ function Dr(t, e, r, n) {
3019
+ const s = r.filter((a) => a.path.length === 0), i = r.filter((a) => a.path.length > 0);
3020
+ if (s.length > 0 && i.length === 0) {
3021
+ const a = s.some((d) => d.code === "custom"), h = s.some(
3022
+ (d) => d.code !== "invalid_type" && d.code !== "invalid_literal" && d.code !== "invalid_union"
3023
+ );
3024
+ if (!a && !h) {
3025
+ const d = N(e), m = jr(n);
3026
+ return `Invalid parameters for ${t}: expected ${d}${d === "{ }" ? " or no args" : ""}, received ${m}`;
3027
+ }
3028
+ }
3029
+ const o = r.map((a) => `at '${a.path.length > 0 ? a.path.join(".") : "root"}': ${a.message}`);
3030
+ return `Invalid parameters for ${t}: ${o.join("; ")}`;
3031
+ }
3032
+ const Zr = /* @__PURE__ */ new Set();
3033
+ function Wr(t) {
3034
+ return Zr.has(t);
3035
+ }
3036
+ const jt = /* @__PURE__ */ new Map();
3037
+ function Vr(t, e) {
3038
+ jt.set(t, e);
3039
+ }
3040
+ function Fr(t) {
3041
+ return jt.get(t);
3042
+ }
3043
+ function Ur(t) {
3044
+ return t.startsWith("tab_") ? "required" : "active";
3045
+ }
3046
+ function Br(t) {
3047
+ return t === "content-script" ? "content-script" : t === "main-thread" ? "main-thread" : t === "worker" ? "worker:default" : t.startsWith("worker:") ? t : "main-thread";
3048
+ }
3049
+ function zr(t, e) {
3050
+ return e !== "main-thread" ? e : Wr(t) ? "content-script" : e;
3051
+ }
3052
+ function qr(t, e) {
3053
+ return {
3054
+ endpoint: Br(zr(t, e)),
3055
+ tabPolicy: Ur(t)
3056
+ };
3057
+ }
3058
+ function Hr(t) {
3059
+ for (const e of t)
3060
+ Vr(e.action, qr(e.action, e.owner));
3061
+ }
3062
+ const D = () => x([q(), f().finite()]).transform((t) => BigInt(t));
2801
3063
  l({
2802
3064
  key: c().describe("Storage key to retrieve")
2803
3065
  });
@@ -2809,30 +3071,30 @@ l({
2809
3071
  key: c().describe("Storage key to delete")
2810
3072
  });
2811
3073
  l({});
2812
- const Ar = l({
3074
+ const Gr = l({
2813
3075
  items: b(c()).describe("Record of key-value string pairs to store")
2814
3076
  });
2815
- Y((t) => t !== null && typeof t == "object" && !Array.isArray(t) && !("items" in t) ? { items: t } : t, Ar);
2816
- const Cr = l({
3077
+ Y((t) => t !== null && typeof t == "object" && !Array.isArray(t) && !("items" in t) ? { items: t } : t, Gr);
3078
+ const Jr = l({
2817
3079
  keys: E(c()).describe("Array of storage keys to retrieve"),
2818
3080
  defaults: b(c()).optional().describe("Default string values for missing keys")
2819
3081
  });
2820
3082
  Y(
2821
3083
  (t) => Array.isArray(t) ? { keys: t } : t,
2822
- Cr
3084
+ Jr
2823
3085
  );
2824
3086
  l({});
2825
- const Or = l({
3087
+ const Yr = l({
2826
3088
  keys: E(c()).describe("Array of storage keys to delete")
2827
3089
  });
2828
3090
  Y(
2829
3091
  (t) => Array.isArray(t) ? { keys: t } : t,
2830
- Or
3092
+ Yr
2831
3093
  );
2832
3094
  l({});
2833
3095
  l({});
2834
3096
  x([
2835
- Rr([x([l({ text: c() }), c()])]),
3097
+ Lr([x([l({ text: c() }), c()])]),
2836
3098
  l({ text: c().optional(), value: c().optional() })
2837
3099
  ]);
2838
3100
  l({
@@ -2841,17 +3103,19 @@ l({
2841
3103
  headers: b(c()).default({}).describe("Request headers as key-value pairs"),
2842
3104
  body: c().nullable().default(null).describe("Request body string"),
2843
3105
  timeout: D().default(30000n).describe("Timeout in milliseconds"),
2844
- store: T().optional().describe("When true, store binary responses as a handle instead of returning body bytes"),
3106
+ store: T().optional().describe(
3107
+ "When true, store binary responses as a handle instead of returning body bytes"
3108
+ ),
2845
3109
  options: l({}).passthrough().optional().describe("Fetch options")
2846
3110
  }).passthrough();
2847
3111
  l({
2848
3112
  duration: D().describe("Duration to sleep in milliseconds")
2849
3113
  });
2850
- const ce = () => c().regex(/^e\d+$/), Nr = 'use { refId: "e2" } or { label: "..." } object form, not positional arguments', lt = (t, e) => {
3114
+ const ce = () => c().regex(/^e\d+$/), Kr = 'use { refId: "e2" } or { label: "..." } object form, not positional arguments', ft = (t, e) => {
2851
3115
  if (t.__invalidPositional !== void 0) {
2852
3116
  e.addIssue({
2853
3117
  code: u.custom,
2854
- message: Nr
3118
+ message: Kr
2855
3119
  });
2856
3120
  return;
2857
3121
  }
@@ -2859,8 +3123,8 @@ const ce = () => c().regex(/^e\d+$/), Nr = 'use { refId: "e2" } or { label: "...
2859
3123
  code: u.custom,
2860
3124
  message: "Either refId or label is required"
2861
3125
  });
2862
- }, Lt = (t, e) => {
2863
- t.x !== void 0 || t.y !== void 0 || lt(t, e);
3126
+ }, Dt = (t, e) => {
3127
+ t.x !== void 0 || t.y !== void 0 || ft(t, e);
2864
3128
  }, M = (t) => Y(
2865
3129
  (e) => typeof e == "string" || typeof e == "number" ? { __invalidPositional: e } : e,
2866
3130
  l({
@@ -2868,23 +3132,27 @@ const ce = () => c().regex(/^e\d+$/), Nr = 'use { refId: "e2" } or { label: "...
2868
3132
  refId: ce().optional().describe("Element reference ID (e.g. e2)"),
2869
3133
  label: c().optional().describe("Human-readable element label"),
2870
3134
  ...t
2871
- }).superRefine(lt)
2872
- ), Ne = { tabId: x([f(), q()]).optional().describe("Target tab ID") }, K = (t) => Y(
3135
+ }).superRefine(ft)
3136
+ ), Me = {
3137
+ tabId: x([f(), q()]).optional().describe("Target tab ID")
3138
+ }, K = (t) => Y(
2873
3139
  (e) => typeof e == "string" || typeof e == "number" ? { __invalidPositional: e } : e,
2874
3140
  l({
2875
3141
  __invalidPositional: x([c(), f()]).optional().describe("Internal flag for positional argument rejection"),
2876
- ...Ne,
3142
+ ...Me,
2877
3143
  refId: ce().optional().describe("Element reference ID (e.g. e2)"),
2878
3144
  label: c().optional().describe("Human-readable element label"),
2879
3145
  ...t
2880
- }).superRefine(lt)
3146
+ }).superRefine(ft)
2881
3147
  );
2882
3148
  l({});
2883
3149
  l({});
2884
3150
  l({
2885
3151
  url: c().describe("URL to navigate to"),
2886
3152
  timeout: D().optional().describe("Navigation timeout in milliseconds"),
2887
- waitUntil: De(["load", "networkidle"]).optional().describe("When to consider navigation complete: 'load' (tab status complete) or 'networkidle' (no in-flight requests for 500ms)")
3153
+ waitUntil: We(["load", "networkidle"]).optional().describe(
3154
+ "When to consider navigation complete: 'load' (tab status complete) or 'networkidle' (no in-flight requests for 500ms)"
3155
+ )
2888
3156
  });
2889
3157
  l({});
2890
3158
  l({});
@@ -2893,46 +3161,54 @@ l({
2893
3161
  duration: D().default(1000n).describe("Duration to wait in milliseconds")
2894
3162
  });
2895
3163
  M();
2896
- const Mr = (t, e) => {
3164
+ const Qr = (t, e) => {
2897
3165
  [t.url, t.path, t.handle].filter(
2898
3166
  (n) => typeof n == "string" && n.length > 0
2899
3167
  ).length !== 1 && e.addIssue({
2900
3168
  code: u.custom,
2901
3169
  message: "Each file entry requires exactly one of url, path, or handle"
2902
3170
  });
2903
- }, jt = l({
3171
+ }, Zt = l({
2904
3172
  name: c().optional().describe("File name including extension"),
2905
3173
  mimeType: c().optional().describe("MIME type (defaults to application/octet-stream)"),
2906
3174
  url: c().url().optional().describe("HTTP(S) URL to fetch in the target tab"),
2907
3175
  path: c().min(1).optional().describe("Virtual filesystem path (resolved in worker)"),
2908
3176
  handle: c().min(1).optional().describe("Binary handle from page.fetch({ store: true })")
2909
- }).superRefine(Mr), Dt = Er("kind", [
3177
+ }).superRefine(Qr), Wt = $r("kind", [
2910
3178
  l({
2911
- kind: st("bytes"),
3179
+ kind: we("bytes"),
2912
3180
  name: c().min(1),
2913
3181
  data: c().min(1),
2914
3182
  mimeType: c().optional()
2915
3183
  }),
2916
3184
  l({
2917
- kind: st("url"),
3185
+ kind: we("url"),
2918
3186
  url: c().url(),
2919
3187
  name: c().min(1),
2920
3188
  mimeType: c().optional()
2921
3189
  })
2922
3190
  ]);
2923
- M({ value: c().describe("Value to fill into the element") });
2924
- const $r = M({
2925
- files: E(jt).min(1).describe("Files to attach to the input")
3191
+ M({
3192
+ value: c().describe("Value to fill into the element")
3193
+ });
3194
+ const Xr = M({
3195
+ files: E(Zt).min(1).describe("Files to attach to the input")
2926
3196
  });
2927
3197
  M({
2928
- files: E(Dt).min(1).describe("Resolved files for content-script application")
3198
+ files: E(Wt).min(1).describe("Resolved files for content-script application")
3199
+ });
3200
+ M({
3201
+ text: c().describe("Text to type into the element")
3202
+ });
3203
+ M({
3204
+ text: c().describe("Text to append into the element")
2929
3205
  });
2930
- M({ text: c().describe("Text to type into the element") });
2931
- M({ text: c().describe("Text to append into the element") });
2932
3206
  l({
2933
3207
  key: c().describe("Key to press (e.g. Enter, Escape, ArrowDown)")
2934
3208
  });
2935
- M({ value: c().describe("Value to select in the dropdown") });
3209
+ M({
3210
+ value: c().describe("Value to select in the dropdown")
3211
+ });
2936
3212
  M({
2937
3213
  checked: T().optional().describe("Desired checked state (true to check, false to uncheck)")
2938
3214
  });
@@ -2950,7 +3226,7 @@ Y(
2950
3226
  label: c().optional().describe("Human-readable element label"),
2951
3227
  x: f().optional().describe("X coordinate to scroll to"),
2952
3228
  y: f().optional().describe("Y coordinate to scroll to")
2953
- }).superRefine(Lt)
3229
+ }).superRefine(Dt)
2954
3230
  );
2955
3231
  M();
2956
3232
  l({
@@ -2960,12 +3236,12 @@ l({
2960
3236
  selector: c().describe("CSS selector to wait for"),
2961
3237
  timeout: D().default(30000n).describe("Timeout in milliseconds")
2962
3238
  });
2963
- const Pr = l({
3239
+ const en = l({
2964
3240
  fields: E(c()).describe("Array of field names to extract")
2965
3241
  });
2966
3242
  Y(
2967
3243
  (t) => Array.isArray(t) ? { fields: t } : t,
2968
- Pr
3244
+ en
2969
3245
  );
2970
3246
  x([
2971
3247
  f(),
@@ -2987,43 +3263,59 @@ Y(
2987
3263
  );
2988
3264
  x([
2989
3265
  f(),
2990
- E(l({ id: f().optional(), tabId: f().optional(), tab_id: f().optional() }).passthrough()),
2991
- l({ id: f().optional(), tabId: f().optional(), tab_id: f().optional() }).passthrough()
3266
+ E(
3267
+ l({
3268
+ id: f().optional(),
3269
+ tabId: f().optional(),
3270
+ tab_id: f().optional()
3271
+ }).passthrough()
3272
+ ),
3273
+ l({
3274
+ id: f().optional(),
3275
+ tabId: f().optional(),
3276
+ tab_id: f().optional()
3277
+ }).passthrough()
2992
3278
  ]);
2993
3279
  K();
2994
- K({ value: c().describe("Value to fill into the element") });
2995
- const Lr = K({
2996
- files: E(jt).min(1).describe("Files to attach to the input")
3280
+ K({
3281
+ value: c().describe("Value to fill into the element")
3282
+ });
3283
+ const tn = K({
3284
+ files: E(Zt).min(1).describe("Files to attach to the input")
2997
3285
  });
2998
3286
  K({
2999
- files: E(Dt).min(1).describe("Resolved files for content-script application")
3287
+ files: E(Wt).min(1).describe("Resolved files for content-script application")
3000
3288
  });
3001
3289
  Y(
3002
3290
  (t) => typeof t == "string" || typeof t == "number" ? { __invalidPositional: t } : t,
3003
3291
  l({
3004
3292
  __invalidPositional: x([c(), f()]).optional().describe("Internal flag for positional argument rejection"),
3005
- ...Ne,
3293
+ ...Me,
3006
3294
  refId: ce().optional().describe("Element reference ID (e.g. e2)"),
3007
3295
  label: c().optional().describe("Human-readable element label"),
3008
3296
  x: f().optional().describe("X coordinate to scroll to"),
3009
3297
  y: f().optional().describe("Y coordinate to scroll to")
3010
- }).superRefine(Lt)
3298
+ }).superRefine(Dt)
3011
3299
  );
3012
- K({ text: c().describe("Text to type into the element") });
3300
+ K({
3301
+ text: c().describe("Text to type into the element")
3302
+ });
3013
3303
  l({
3014
- ...Ne,
3304
+ ...Me,
3015
3305
  key: c().describe("Key to press (e.g. Enter, Escape, ArrowDown)")
3016
3306
  });
3017
- K({ value: c().describe("Value to select in the dropdown") });
3307
+ K({
3308
+ value: c().describe("Value to select in the dropdown")
3309
+ });
3018
3310
  K({
3019
3311
  checked: T().optional().describe("Desired checked state (true to check, false to uncheck)")
3020
3312
  });
3021
3313
  K();
3022
3314
  l({
3023
- ...Ne
3315
+ ...Me
3024
3316
  });
3025
3317
  l({
3026
- ...Ne,
3318
+ ...Me,
3027
3319
  direction: c().default("down").describe("Scroll direction: up, down, left, or right"),
3028
3320
  amount: f().default(300).describe("Pixels to scroll")
3029
3321
  });
@@ -3128,7 +3420,7 @@ l({
3128
3420
  max_nodes: f().optional().describe("Maximum nodes to include"),
3129
3421
  options: l({}).passthrough().optional().describe("Snapshot options")
3130
3422
  }).passthrough();
3131
- const jr = l({
3423
+ const rn = l({
3132
3424
  role: x([c(), E(c())]).optional().describe("Filter by ARIA role"),
3133
3425
  tag: x([c(), E(c())]).optional().describe("Filter by HTML tag"),
3134
3426
  text: c().optional().describe("Filter by text content (case-insensitive substring)"),
@@ -3137,11 +3429,13 @@ const jr = l({
3137
3429
  href: c().optional().describe("Filter by href pattern (case-insensitive substring)"),
3138
3430
  src: c().optional().describe("Filter by src pattern (case-insensitive substring)"),
3139
3431
  limit: f().positive().optional().describe("Maximum filtered nodes to return")
3140
- }).passthrough(), Dr = l({
3141
- filter: jr.optional().describe("Semantic filter criteria"),
3432
+ }).passthrough(), nn = l({
3433
+ filter: rn.optional().describe(
3434
+ "Semantic filter criteria"
3435
+ ),
3142
3436
  max_nodes: f().optional().describe("Maximum nodes to collect before filtering")
3143
3437
  }).passthrough();
3144
- Dr.extend({
3438
+ nn.extend({
3145
3439
  tabId: f().describe("Tab ID")
3146
3440
  });
3147
3441
  const X = l({
@@ -3152,15 +3446,15 @@ const X = l({
3152
3446
  }), ue = l({
3153
3447
  path: c().describe("File path to write to"),
3154
3448
  data: c().describe("Data to write")
3155
- }), Zr = l({
3449
+ }), sn = l({
3156
3450
  path: c().describe("File path to read from"),
3157
3451
  offset: D().describe("Byte offset to start reading"),
3158
3452
  len: f().describe("Number of bytes to read")
3159
- }), Wr = l({
3453
+ }), an = l({
3160
3454
  path: c().describe("File path to update"),
3161
3455
  offset: D().describe("Byte offset to start writing"),
3162
3456
  data: c().describe("Data to write")
3163
- }), Vr = l({
3457
+ }), on = l({
3164
3458
  path: c().describe("File path to hash"),
3165
3459
  algo: c().default("sha256").describe("Hash algorithm (e.g. sha256, md5)")
3166
3460
  });
@@ -3282,12 +3576,12 @@ x([
3282
3576
  c(),
3283
3577
  f(),
3284
3578
  T(),
3285
- Pt(),
3579
+ Lt(),
3286
3580
  E(_()),
3287
3581
  b(_())
3288
3582
  ]);
3289
- const Fr = l({
3290
- ok: st(!0).describe("Whether the action succeeded"),
3583
+ const cn = l({
3584
+ ok: we(!0).describe("Whether the action succeeded"),
3291
3585
  action: c().describe("Action identifier (e.g. 'page_fill')"),
3292
3586
  refId: ce().optional().describe("Element reference ID that was acted upon (e.g. e2)"),
3293
3587
  tag: c().optional().describe("HTML tag name of the element"),
@@ -3302,18 +3596,24 @@ const Fr = l({
3302
3596
  direction: c().optional().describe("Scroll direction (for scroll actions)"),
3303
3597
  amount: f().optional().describe("Scroll amount in pixels (for scroll actions)"),
3304
3598
  fileCount: f().optional().describe("Number of files attached (for setFiles actions)"),
3305
- fileNames: E(c()).optional().describe("Names of attached files (for setFiles actions)")
3599
+ fileNames: E(c()).optional().describe("Names of attached files (for setFiles actions)"),
3600
+ observationId: c().optional().describe(
3601
+ "Opaque ID of the observation lease authorizing this action (snapshot-scoped)"
3602
+ ),
3603
+ dispatched: we(!0).optional().describe(
3604
+ "True if the action was dispatched to the DOM. Does NOT prove the application accepted it."
3605
+ ),
3606
+ verification: we("required").optional().describe(
3607
+ "Always 'required': a fresh observation is required to verify the effect."
3608
+ )
3306
3609
  });
3307
- x([
3308
- Fr,
3309
- Pt()
3310
- ]);
3610
+ x([cn, Lt()]);
3311
3611
  l({
3312
3612
  status: f().describe("HTTP response status code"),
3313
3613
  ok: T().describe("Whether the response status is 2xx"),
3314
3614
  headers: b(c()).describe("Response headers as key-value pairs"),
3315
3615
  body: c().optional().describe("Response body (omitted when bodyEncoding is handle)"),
3316
- bodyEncoding: De(["text", "base64", "handle"]).describe("Encoding of the body field"),
3616
+ bodyEncoding: We(["text", "base64", "handle"]).describe("Encoding of the body field"),
3317
3617
  handle: c().optional().describe("Binary handle when bodyEncoding is handle"),
3318
3618
  byteLength: f().describe("Length of the body in bytes"),
3319
3619
  contentType: c().describe("Response Content-Type header"),
@@ -3328,13 +3628,13 @@ l({
3328
3628
  tabId: f(),
3329
3629
  url: c(),
3330
3630
  title: c(),
3331
- contentScript: De(["connected", "missing"]),
3332
- domApis: De(["ok", "blocked"]),
3631
+ contentScript: We(["connected", "missing"]),
3632
+ domApis: We(["ok", "blocked"]),
3333
3633
  mutationsReady: T(),
3334
3634
  hint: c().optional(),
3335
3635
  recovery: E(c()).optional()
3336
3636
  });
3337
- const Ur = l({
3637
+ const dn = l({
3338
3638
  refId: ce().describe("Element reference ID (e.g. e2)"),
3339
3639
  role: c().describe("ARIA role of the element"),
3340
3640
  tag: c().describe("HTML tag name"),
@@ -3355,15 +3655,18 @@ const Ur = l({
3355
3655
  });
3356
3656
  l({
3357
3657
  text: c().describe("Plain text representation of the page"),
3358
- nodes: E(Ur).describe("Array of interactive nodes"),
3658
+ nodes: E(dn).describe("Array of interactive nodes"),
3359
3659
  url: c().describe("Current page URL"),
3360
3660
  title: c().describe("Current page title"),
3361
3661
  viewport: l({
3362
3662
  width: f().describe("Viewport width in pixels"),
3363
3663
  height: f().describe("Viewport height in pixels")
3364
- }).describe("Viewport dimensions")
3664
+ }).describe("Viewport dimensions"),
3665
+ observationId: c().optional().describe(
3666
+ "Opaque ID of the observation lease granted by this snapshot. Pass to subsequent actions to prove they act on fresh observations."
3667
+ )
3365
3668
  });
3366
- const Zt = l({
3669
+ const Vt = l({
3367
3670
  id: f().optional().describe("Tab ID"),
3368
3671
  tabId: f().optional().describe("Tab ID (added by runner)"),
3369
3672
  index: f().optional().describe("Tab index in the window"),
@@ -3384,22 +3687,24 @@ const Zt = l({
3384
3687
  width: f().optional().describe("Tab width"),
3385
3688
  height: f().optional().describe("Tab height"),
3386
3689
  sessionId: c().optional().describe("Session ID")
3387
- }).passthrough(), Br = E(Zt), Wt = l({
3690
+ }).passthrough(), ln = E(Vt), Ft = l({
3388
3691
  id: f().optional().describe("Window ID"),
3389
3692
  focused: T().optional().describe("Whether the window is focused"),
3390
3693
  top: f().optional().describe("Window top position"),
3391
3694
  left: f().optional().describe("Window left position"),
3392
3695
  width: f().optional().describe("Window width"),
3393
3696
  height: f().optional().describe("Window height"),
3394
- tabs: Br.optional().describe("Array of tabs in the window"),
3697
+ tabs: ln.optional().describe(
3698
+ "Array of tabs in the window"
3699
+ ),
3395
3700
  incognito: T().optional().describe("Whether the window is incognito"),
3396
3701
  type: c().optional().describe("Window type"),
3397
3702
  state: c().optional().describe("Window state"),
3398
3703
  alwaysOnTop: T().optional().describe("Whether the window is always on top"),
3399
3704
  sessionId: c().optional().describe("Session ID")
3400
3705
  }).passthrough();
3401
- E(Wt);
3402
- const zr = l({
3706
+ E(Ft);
3707
+ const un = l({
3403
3708
  name: c().describe("Cookie name"),
3404
3709
  value: c().describe("Cookie value"),
3405
3710
  domain: c().optional().describe("Cookie domain"),
@@ -3412,8 +3717,10 @@ const zr = l({
3412
3717
  expirationDate: f().optional().describe("Expiration date as Unix timestamp"),
3413
3718
  storeId: c().optional().describe("Store ID")
3414
3719
  }).nullable();
3415
- E(zr.nullable().unwrap());
3416
- const qr = l({
3720
+ E(
3721
+ un.nullable().unwrap()
3722
+ );
3723
+ const fn = l({
3417
3724
  id: c().describe("Bookmark ID"),
3418
3725
  parentId: c().optional().describe("Parent folder ID"),
3419
3726
  index: f().optional().describe("Bookmark index"),
@@ -3423,8 +3730,8 @@ const qr = l({
3423
3730
  dateGroupModified: f().optional().describe("Date group modified"),
3424
3731
  children: E(l({ id: c() }).passthrough()).optional().describe("Child bookmarks")
3425
3732
  }).passthrough();
3426
- E(qr);
3427
- const Hr = l({
3733
+ E(fn);
3734
+ const hn = l({
3428
3735
  id: c().describe("History item ID"),
3429
3736
  url: c().optional().describe("URL"),
3430
3737
  title: c().optional().describe("Title"),
@@ -3432,34 +3739,34 @@ const Hr = l({
3432
3739
  visitCount: f().optional().describe("Visit count"),
3433
3740
  typedCount: f().optional().describe("Typed count")
3434
3741
  }).passthrough();
3435
- E(Hr);
3436
- const Gr = l({
3742
+ E(hn);
3743
+ const pn = l({
3437
3744
  frameId: f().describe("Frame ID"),
3438
3745
  result: _().optional().describe("Script result")
3439
3746
  });
3440
- E(Gr);
3747
+ E(pn);
3441
3748
  c();
3442
3749
  T();
3443
3750
  x([c(), f()]);
3444
3751
  T();
3445
- const Jr = l({
3752
+ const mn = l({
3446
3753
  id: f().optional().describe("Group ID"),
3447
3754
  collapsed: T().optional().describe("Whether the group is collapsed"),
3448
3755
  color: c().optional().describe("Group color"),
3449
3756
  title: c().optional().describe("Group title"),
3450
3757
  windowId: f().optional().describe("Window ID")
3451
3758
  }).passthrough();
3452
- E(Jr);
3453
- const Yr = l({
3759
+ E(mn);
3760
+ const gn = l({
3454
3761
  lastModified: f().optional().describe("Last modified time"),
3455
- tab: Zt.optional().describe("Tab info"),
3456
- window: Wt.optional().describe("Window info")
3457
- }).passthrough(), Kr = E(Yr), Qr = l({
3762
+ tab: Vt.optional().describe("Tab info"),
3763
+ window: Ft.optional().describe("Window info")
3764
+ }).passthrough(), yn = E(gn), bn = l({
3458
3765
  deviceName: c().optional().describe("Device name"),
3459
- sessions: Kr.optional().describe("Sessions")
3766
+ sessions: yn.optional().describe("Sessions")
3460
3767
  }).passthrough();
3461
- E(Qr);
3462
- const Xr = l({
3768
+ E(bn);
3769
+ const _n = l({
3463
3770
  id: f().optional().describe("Download ID"),
3464
3771
  url: c().optional().describe("Download URL"),
3465
3772
  filename: c().optional().describe("Filename"),
@@ -3478,7 +3785,7 @@ const Xr = l({
3478
3785
  byExtensionId: c().optional().describe("Extension ID"),
3479
3786
  byExtensionName: c().optional().describe("Extension name")
3480
3787
  }).passthrough();
3481
- E(Xr);
3788
+ E(_n);
3482
3789
  f();
3483
3790
  l({
3484
3791
  archName: c().describe("CPU architecture"),
@@ -3490,278 +3797,27 @@ l({
3490
3797
  capacity: f().describe("Total memory capacity"),
3491
3798
  availableCapacity: f().describe("Available memory capacity")
3492
3799
  });
3493
- E(l({
3494
- id: c().describe("Storage ID"),
3495
- name: c().describe("Storage name"),
3496
- type: c().describe("Storage type"),
3497
- capacity: f().describe("Storage capacity")
3498
- }));
3499
- const Ze = {
3500
- trace: 0,
3501
- debug: 1,
3502
- info: 2,
3503
- warn: 3,
3504
- error: 4,
3505
- none: 5
3506
- }, en = [
3507
- "trace",
3508
- "debug",
3509
- "info",
3510
- "warn",
3511
- "error",
3512
- "none"
3513
- ];
3514
- function tn(t) {
3515
- const e = Math.max(0, Math.min(5, Math.round(t)));
3516
- return en[e] ?? "error";
3517
- }
3518
- let ut = "trace", it = null;
3519
- function rn(t) {
3520
- ut = t, it && it(Ze[t]);
3521
- }
3522
- function nn(t) {
3523
- it = t, t(Ze[ut]);
3524
- }
3525
- function sn(t) {
3526
- return Ze[t] >= Ze[ut];
3527
- }
3528
- function Vt(t, e = "info") {
3529
- var r;
3530
- if (t === null) return "null";
3531
- if (t === void 0) return "undefined";
3532
- if (typeof t == "string") return t;
3533
- if (typeof t == "number" || typeof t == "boolean")
3534
- return String(t);
3535
- if (typeof t == "bigint") return `${t}n`;
3536
- if (t instanceof Error) {
3537
- const n = e === "debug" || e === "trace" ? t.stack : (r = t.stack) == null ? void 0 : r.split(`
3538
- `)[0];
3539
- return JSON.stringify({ message: t.message, name: t.name, stack: n });
3540
- }
3541
- if (typeof t == "function") return "[Function]";
3542
- if (typeof t == "symbol") return String(t);
3543
- if (typeof t == "object")
3544
- try {
3545
- return JSON.stringify(t);
3546
- } catch (n) {
3547
- return n instanceof TypeError && n.message.includes("circular") ? "[Circular]" : `[Unserializable: ${n instanceof Error ? n.message : String(n)}]`;
3548
- }
3549
- return String(t);
3550
- }
3551
- function an(t) {
3552
- return `[extension-js][${t}]`;
3553
- }
3554
- function on(t, e) {
3555
- if (!t) return "";
3556
- const r = [];
3557
- try {
3558
- for (const [n, s] of Object.entries(t))
3559
- r.push(`${n}=${Vt(s, e)}`);
3560
- } catch {
3561
- return " metadata=[unreadable]";
3562
- }
3563
- return r.length > 0 ? ` ${r.join(" ")}` : "";
3564
- }
3565
- function be(t, e) {
3566
- 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] } : {
3567
- event: t,
3568
- metadata: { _args: e.map((r) => Vt(r)).join(" ") }
3569
- };
3570
- }
3571
- class ft {
3572
- constructor(e = "root") {
3573
- this.namespace = e;
3574
- }
3575
- log(e, r, n) {
3576
- try {
3577
- if (!sn(e)) return;
3578
- const s = an(this.namespace), i = on(n, e), o = `${s} ${r}${i}`;
3579
- switch (e) {
3580
- case "trace":
3581
- case "debug":
3582
- case "info":
3583
- console.log(o);
3584
- break;
3585
- case "warn":
3586
- console.warn(o);
3587
- break;
3588
- case "error":
3589
- console.error(o);
3590
- break;
3591
- case "none":
3592
- break;
3593
- default: {
3594
- const a = e;
3595
- break;
3596
- }
3597
- }
3598
- } catch {
3599
- }
3600
- }
3601
- trace(e, ...r) {
3602
- const { event: n, metadata: s } = be(e, r);
3603
- this.log("trace", n, s);
3604
- }
3605
- debug(e, ...r) {
3606
- const { event: n, metadata: s } = be(e, r);
3607
- this.log("debug", n, s);
3608
- }
3609
- info(e, ...r) {
3610
- const { event: n, metadata: s } = be(e, r);
3611
- this.log("info", n, s);
3612
- }
3613
- warn(e, ...r) {
3614
- const { event: n, metadata: s } = be(e, r);
3615
- this.log("warn", n, s);
3616
- }
3617
- error(e, ...r) {
3618
- const { event: n, metadata: s } = be(e, r);
3619
- this.log("error", n, s);
3620
- }
3621
- child(e) {
3622
- return new ft(`${this.namespace}.${e}`);
3623
- }
3624
- timer(e, r, n = "info") {
3625
- const s = typeof performance < "u" && performance.now, i = s ? performance.now() : Date.now();
3626
- return (o) => {
3627
- try {
3628
- const a = s ? performance.now() : Date.now(), h = Math.round(a - i), d = {
3629
- ...r,
3630
- ...o,
3631
- duration_ms: h
3632
- };
3633
- this.log(n, e, d);
3634
- } catch {
3635
- }
3636
- };
3637
- }
3638
- }
3639
- const C = new ft("root"), cn = /* @__PURE__ */ new Set();
3640
- function dn(t) {
3641
- return cn.has(t);
3642
- }
3643
- const Ft = /* @__PURE__ */ new Map();
3644
- function ln(t, e) {
3645
- Ft.set(t, e);
3646
- }
3647
- function un(t) {
3648
- return Ft.get(t);
3649
- }
3650
- function fn(t) {
3651
- return t.startsWith("tab_") ? "required" : "active";
3652
- }
3653
- function hn(t) {
3654
- return t === "content-script" ? "content-script" : t === "main-thread" ? "main-thread" : t === "worker" ? "worker:default" : t.startsWith("worker:") ? t : "main-thread";
3655
- }
3656
- function pn(t, e) {
3657
- return e !== "main-thread" ? e : dn(t) ? "content-script" : e;
3658
- }
3659
- function mn(t, e) {
3660
- return {
3661
- endpoint: hn(pn(t, e)),
3662
- tabPolicy: fn(t)
3663
- };
3664
- }
3665
- function gn(t) {
3666
- for (const e of t)
3667
- ln(e.action, mn(e.action, e.owner));
3668
- }
3669
- function ye(t) {
3670
- return t == null ? {} : t instanceof Map ? Object.fromEntries(
3671
- [...t.entries()].map(([e, r]) => [e, ye(r)])
3672
- ) : Array.isArray(t) ? t.map(ye) : t;
3673
- }
3674
- function yn(t) {
3675
- return {
3676
- action: t.action,
3677
- namespace: t.namespace,
3678
- name: t.name,
3679
- publicName: t.publicName,
3680
- description: t.description,
3681
- fields: t.fields,
3682
- aliases: (t.aliases ?? []).map((e) => ({
3683
- namespace: e.namespace,
3684
- name: e.name,
3685
- fields: e.fields
3686
- })),
3687
- paramsDoc: t.paramsDoc.map((e) => ({
3688
- name: e.name,
3689
- type: e.type,
3690
- required: e.required,
3691
- description: e.description
3692
- })),
3693
- returnsDoc: {
3694
- type: t.returnsDoc.type,
3695
- description: t.returnsDoc.description
3696
- },
3697
- errorCode: t.errorCode,
3698
- errorCategory: t.errorCategory ?? null,
3699
- permission: t.permission ?? null,
3700
- example: t.example ?? null,
3701
- prerequisites: t.prerequisites ?? null,
3702
- notes: t.notes ?? null,
3703
- tags: t.tags ?? null,
3704
- relatedApis: t.relatedApis ?? null
3705
- };
3706
- }
3707
- function N(t, e = 0, r = 2) {
3708
- if (e > r) return "...";
3709
- if (t instanceof A) {
3710
- const n = t.shape, s = Object.keys(n).filter((o) => !o.startsWith("__"));
3711
- return s.length === 0 ? "{ }" : e >= r - 1 ? "{ ... }" : `{ ${s.map((o) => {
3712
- const a = n[o], h = a instanceof V, d = N(h ? a.unwrap() : a, e + 1, r);
3713
- return `${o}${h ? "?" : ""}: ${d}`;
3714
- }).join(", ")} }`;
3715
- }
3716
- if (t instanceof Se)
3717
- return t.options.map((n) => N(n, e, r)).join(" or ");
3718
- if (t instanceof U) return "string";
3719
- if (t instanceof ae) return "number";
3720
- if (t instanceof Pe) return "boolean";
3721
- if (t instanceof oe) return "bigint";
3722
- if (t instanceof xe) return "null";
3723
- if (t instanceof W) {
3724
- const n = N(t.element, e + 1, r);
3725
- return n === "unknown" || n === "any" ? "array" : `${n}[]`;
3726
- }
3727
- if (t instanceof z)
3728
- return `[${t.items.map((n) => N(n, e + 1, r)).join(", ")}]`;
3729
- if (t instanceof Ee) {
3730
- const n = N(t._def.valueType, e + 1, r);
3731
- return n === "unknown" || n === "any" ? "{ [key: string]: unknown }" : `{ [key: string]: ${n} }`;
3732
- }
3733
- return t instanceof V ? `${N(t.unwrap(), e, r)}?` : t instanceof Re ? JSON.stringify(t.value) : t instanceof re ? t.options.map((n) => `"${n}"`).join(" | ") : t instanceof Qe ? "any" : t instanceof ie ? "unknown" : t instanceof Xe ? "void" : t instanceof Le ? "undefined" : t instanceof J ? N(t.innerType(), e, r) : t instanceof Ae ? N(t.removeDefault(), e, r) : t instanceof ne ? `${N(t.unwrap(), e, r)} | null` : t instanceof je ? "lazy" : t instanceof ge ? `Promise<${N(t.unwrap(), e + 1, r)}>` : t instanceof ke ? "function" : t instanceof Te ? "Date" : t instanceof tt ? "Map" : t instanceof me ? "Set" : t instanceof Ie ? `${N(t._def.left, e, r)} & ${N(t._def.right, e, r)}` : t instanceof Be ? t.options.map((n) => N(n, e, r)).join(" or ") : t instanceof dt ? N(t.unwrap(), e, r) : t instanceof nt ? "NaN" : t instanceof Ce ? N(t.removeCatch(), e, r) : t instanceof ze ? N(t._def.in, e, r) : t instanceof Oe ? `readonly ${N(t.unwrap(), e, r)}` : "unknown";
3734
- }
3735
- function bn(t) {
3736
- return t === null ? "null" : t === void 0 ? "undefined" : Array.isArray(t) ? "array" : typeof t;
3737
- }
3738
- function _n(t, e, r, n) {
3739
- const s = r.filter((a) => a.path.length === 0), i = r.filter((a) => a.path.length > 0);
3740
- if (s.length > 0 && i.length === 0) {
3741
- const a = s.some((d) => d.code === "custom"), h = s.some(
3742
- (d) => d.code !== "invalid_type" && d.code !== "invalid_literal" && d.code !== "invalid_union"
3743
- );
3744
- if (!a && !h) {
3745
- const d = N(e), m = bn(n);
3746
- return `Invalid parameters for ${t}: expected ${d}${d === "{ }" ? " or no args" : ""}, received ${m}`;
3747
- }
3748
- }
3749
- const o = r.map((a) => `at '${a.path.length > 0 ? a.path.join(".") : "root"}': ${a.message}`);
3750
- return `Invalid parameters for ${t}: ${o.join("; ")}`;
3751
- }
3800
+ E(
3801
+ l({
3802
+ id: c().describe("Storage ID"),
3803
+ name: c().describe("Storage name"),
3804
+ type: c().describe("Storage type"),
3805
+ capacity: f().describe("Storage capacity")
3806
+ })
3807
+ );
3752
3808
  C.child("tool-registry");
3753
- const We = /* @__PURE__ */ new Map(), Ve = /* @__PURE__ */ new Map();
3809
+ const Ve = /* @__PURE__ */ new Map(), Fe = /* @__PURE__ */ new Map();
3754
3810
  function ht(t) {
3755
3811
  return t && t.length > 0 ? t : "__default__";
3756
3812
  }
3757
3813
  function Ut(t) {
3758
3814
  const e = ht(t);
3759
- let r = We.get(e);
3760
- return r || (r = /* @__PURE__ */ new Map(), We.set(e, r)), r;
3815
+ let r = Ve.get(e);
3816
+ return r || (r = /* @__PURE__ */ new Map(), Ve.set(e, r)), r;
3761
3817
  }
3762
3818
  function vn(t, e, r) {
3763
- const n = ht(t), s = (Ve.get(n) ?? 0) + 1;
3764
- Ve.set(n, s);
3819
+ const n = ht(t), s = (Fe.get(n) ?? 0) + 1;
3820
+ Fe.set(n, s);
3765
3821
  const i = `blob_${s}`;
3766
3822
  return Ut(t).set(i, {
3767
3823
  bytes: e,
@@ -3775,10 +3831,10 @@ function kn(t, e) {
3775
3831
  }
3776
3832
  function wn(t) {
3777
3833
  const e = ht(t);
3778
- We.delete(e), Ve.delete(e);
3834
+ Ve.delete(e), Fe.delete(e);
3779
3835
  }
3780
3836
  function St() {
3781
- We.clear(), Ve.clear();
3837
+ Ve.clear(), Fe.clear();
3782
3838
  }
3783
3839
  const It = 8 * 1024;
3784
3840
  function Tn(t) {
@@ -3823,7 +3879,7 @@ function Et(t, e) {
3823
3879
  const n = (t.split(/[?#]/)[0] ?? t).split("/").filter(Boolean).pop();
3824
3880
  return n && n.length > 0 ? n : e;
3825
3881
  }
3826
- function Ge(t) {
3882
+ function Je(t) {
3827
3883
  return {
3828
3884
  ok: !1,
3829
3885
  error: {
@@ -3835,9 +3891,11 @@ function Ge(t) {
3835
3891
  }
3836
3892
  async function In(t, e, r, n) {
3837
3893
  var h;
3838
- const i = (t === "tab_set_files" ? Lr : $r).safeParse(e);
3894
+ const i = (t === "tab_set_files" ? tn : Xr).safeParse(e);
3839
3895
  if (!i.success)
3840
- return Ge(((h = i.error.issues[0]) == null ? void 0 : h.message) ?? "Invalid setFiles params");
3896
+ return Je(
3897
+ ((h = i.error.issues[0]) == null ? void 0 : h.message) ?? "Invalid setFiles params"
3898
+ );
3841
3899
  const o = i.data, a = [];
3842
3900
  for (const d of o.files) {
3843
3901
  if (d.url) {
@@ -3860,14 +3918,14 @@ async function In(t, e, r, n) {
3860
3918
  });
3861
3919
  } catch (m) {
3862
3920
  const R = m instanceof Error ? m.message : String(m);
3863
- return Ge(`Failed to read path ${d.path}: ${R}`);
3921
+ return Je(`Failed to read path ${d.path}: ${R}`);
3864
3922
  }
3865
3923
  continue;
3866
3924
  }
3867
3925
  if (d.handle) {
3868
3926
  const m = kn(r, d.handle);
3869
3927
  if (!m)
3870
- return Ge(`Unknown or expired handle: ${d.handle}`);
3928
+ return Je(`Unknown or expired handle: ${d.handle}`);
3871
3929
  a.push({
3872
3930
  kind: "bytes",
3873
3931
  name: d.name ?? d.handle,
@@ -3884,21 +3942,21 @@ async function In(t, e, r, n) {
3884
3942
  }
3885
3943
  };
3886
3944
  }
3887
- const Fe = /* @__PURE__ */ new Map();
3945
+ const Ue = /* @__PURE__ */ new Map();
3888
3946
  function En(t, e) {
3889
- Fe.set(t, e);
3947
+ Ue.set(t, e);
3890
3948
  }
3891
3949
  function Rn(t) {
3892
- const e = Fe.get(t);
3893
- return e !== void 0 && Fe.delete(t), e;
3950
+ const e = Ue.get(t);
3951
+ return e !== void 0 && Ue.delete(t), e;
3894
3952
  }
3895
3953
  function An() {
3896
- Fe.clear();
3954
+ Ue.clear();
3897
3955
  }
3898
3956
  const zt = /* @__PURE__ */ new Set(["page_set_files", "tab_set_files"]), qt = /* @__PURE__ */ new Set(["page_fetch", "tab_fetch"]);
3899
3957
  let se = null, at = !1;
3900
3958
  const he = /* @__PURE__ */ new Map();
3901
- function Ue(t, e) {
3959
+ function Be(t, e) {
3902
3960
  try {
3903
3961
  return t.postMessage(e), !0;
3904
3962
  } catch (r) {
@@ -3908,7 +3966,7 @@ function Ue(t, e) {
3908
3966
  }
3909
3967
  const Rt = 1e3;
3910
3968
  function Ht(t, e, r) {
3911
- e === "main-thread" || e === "content-script" ? Ue(r, { type: "relayCancel", id: t, owner: e }) : Ue(r, { type: "registryCallCancel", id: t });
3969
+ e === "main-thread" || e === "content-script" ? Be(r, { type: "relayCancel", id: t, owner: e }) : Be(r, { type: "registryCallCancel", id: t });
3912
3970
  }
3913
3971
  function At(t, e) {
3914
3972
  for (const [r, n] of he)
@@ -3954,9 +4012,9 @@ function On(t, e) {
3954
4012
  }
3955
4013
  function O(t, e, r) {
3956
4014
  On(t, async (n, s) => {
3957
- const i = e.safeParse(ye(n));
4015
+ const i = e.safeParse(pe(n));
3958
4016
  if (!i.success) {
3959
- const o = _n(
4017
+ const o = Dr(
3960
4018
  t,
3961
4019
  e,
3962
4020
  i.error.issues,
@@ -3972,15 +4030,17 @@ function Nn() {
3972
4030
  return crypto.getRandomValues(t), Array.from(t, (e) => e.toString(16).padStart(2, "0")).join("");
3973
4031
  }
3974
4032
  function Mn(t) {
3975
- return tn(t);
4033
+ return ir(t);
3976
4034
  }
3977
- const ot = /* @__PURE__ */ new Map(), Me = /* @__PURE__ */ new Map();
3978
- function $n(t, e) {
4035
+ const ot = /* @__PURE__ */ new Map(), Pe = /* @__PURE__ */ new Map();
4036
+ function Pn(t, e) {
3979
4037
  var r;
3980
4038
  if (ot.has(t))
3981
4039
  throw new Error(`Worker port already registered for owner: ${t}`);
3982
4040
  if (typeof e.addEventListener != "function")
3983
- throw new Error(`Worker port for owner "${t}" cannot receive responses`);
4041
+ throw new Error(
4042
+ `Worker port for owner "${t}" cannot receive responses`
4043
+ );
3984
4044
  ot.set(t, e), e.addEventListener("message", async (n) => {
3985
4045
  var i;
3986
4046
  const s = n.data;
@@ -3989,18 +4049,21 @@ function $n(t, e) {
3989
4049
  return;
3990
4050
  }
3991
4051
  if (s !== null && s.type === "registryCallCancel" && typeof s.id == "string") {
3992
- (i = Me.get(s.id)) == null || i.abort(), Me.delete(s.id);
4052
+ (i = Pe.get(s.id)) == null || i.abort(), Pe.delete(s.id);
3993
4053
  return;
3994
4054
  }
3995
4055
  if (s !== null && s.type === "registryCall" && typeof s.id == "string" && typeof s.action == "string") {
3996
4056
  const o = s.id, a = new AbortController();
3997
- Me.set(o, a);
4057
+ Pe.set(o, a);
3998
4058
  const h = de.get(s.action);
3999
4059
  let d;
4000
4060
  if (!h)
4001
4061
  d = {
4002
4062
  ok: !1,
4003
- error: { message: `Unknown worker action: ${s.action}`, code: "E_UNKNOWN" }
4063
+ error: {
4064
+ message: `Unknown worker action: ${s.action}`,
4065
+ code: "E_UNKNOWN"
4066
+ }
4004
4067
  };
4005
4068
  else
4006
4069
  try {
@@ -4010,7 +4073,10 @@ function $n(t, e) {
4010
4073
  runId: s.runId,
4011
4074
  signal: a.signal
4012
4075
  });
4013
- d = a.signal.aborted ? { ok: !1, error: { message: "Relay aborted", code: "E_ABORT" } } : { ok: !0, value: m };
4076
+ d = a.signal.aborted ? {
4077
+ ok: !1,
4078
+ error: { message: "Relay aborted", code: "E_ABORT" }
4079
+ } : { ok: !0, value: m };
4014
4080
  } catch (m) {
4015
4081
  d = {
4016
4082
  ok: !1,
@@ -4020,9 +4086,12 @@ function $n(t, e) {
4020
4086
  }
4021
4087
  };
4022
4088
  }
4023
- Me.delete(o), Ue(e, { type: "registryCallResult", id: o, result: d }) || ct(o, {
4089
+ Pe.delete(o), Be(e, { type: "registryCallResult", id: o, result: d }) || ct(o, {
4024
4090
  ok: !1,
4025
- error: { message: "Failed to deliver worker handler response", code: "E_PORT" }
4091
+ error: {
4092
+ message: "Failed to deliver worker handler response",
4093
+ code: "E_PORT"
4094
+ }
4026
4095
  });
4027
4096
  }
4028
4097
  }), (r = e.start) == null || r.call(e);
@@ -4032,7 +4101,7 @@ function ct(t, e) {
4032
4101
  const r = he.get(t);
4033
4102
  return r ? (r.settle(e), !0) : (C.warn("asyncRelayResult_no_pending_relay", { id: t }), !1);
4034
4103
  }
4035
- function Pn(t) {
4104
+ function $n(t) {
4036
4105
  if (t === "main-thread" || t === "content-script")
4037
4106
  return self;
4038
4107
  const e = ot.get(t);
@@ -4041,7 +4110,12 @@ function Pn(t) {
4041
4110
  function Jt(t) {
4042
4111
  const { owner: e, action: r, tabPolicy: n, resolveTimeoutMs: s } = t, i = t.timeoutMs ?? ve;
4043
4112
  return (o, a) => {
4044
- C.trace("safePostAsCall_invoke", { owner: e, action: r, callId: a == null ? void 0 : a.callId, runId: a == null ? void 0 : a.runId });
4113
+ C.trace("safePostAsCall_invoke", {
4114
+ owner: e,
4115
+ action: r,
4116
+ callId: a == null ? void 0 : a.callId,
4117
+ runId: a == null ? void 0 : a.runId
4118
+ });
4045
4119
  const h = (s == null ? void 0 : s(o)) ?? i;
4046
4120
  return new Promise((d, m) => {
4047
4121
  var bt;
@@ -4050,43 +4124,45 @@ function Jt(t) {
4050
4124
  H.code = "E_ABORT", m(H);
4051
4125
  return;
4052
4126
  }
4053
- const R = Pn(e);
4127
+ const R = $n(e);
4054
4128
  if (!R) {
4055
4129
  m(new Error(`No port available for action: ${r}`));
4056
4130
  return;
4057
4131
  }
4058
4132
  if (he.size >= Rt) {
4059
- m(new Error(
4060
- `Too many pending calls (${Rt} limit exceeded). Action: ${r}`
4061
- ));
4133
+ m(
4134
+ new Error(
4135
+ `Too many pending calls (${Rt} limit exceeded). Action: ${r}`
4136
+ )
4137
+ );
4062
4138
  return;
4063
4139
  }
4064
- const $ = Nn();
4140
+ const P = Nn();
4065
4141
  let Q = !1;
4066
4142
  const le = (H) => {
4067
- Q || (Q = !0, clearTimeout(mt), a != null && a.signal && a.signal.removeEventListener("abort", qe), he.delete($), H());
4143
+ Q || (Q = !0, clearTimeout(mt), a != null && a.signal && a.signal.removeEventListener("abort", He), he.delete(P), H());
4068
4144
  }, pt = () => {
4069
- Ht($, e, R);
4070
- }, qe = () => {
4145
+ Ht(P, e, R);
4146
+ }, He = () => {
4071
4147
  pt();
4072
4148
  const H = new Error(`Relay aborted for action: ${r}`);
4073
4149
  H.code = "E_ABORT", le(() => m(H));
4074
4150
  };
4075
- a != null && a.signal && a.signal.addEventListener("abort", qe);
4151
+ a != null && a.signal && a.signal.addEventListener("abort", He);
4076
4152
  const mt = setTimeout(() => {
4077
4153
  pt(), le(() => m(new Error(`Relay timeout for action: ${r}`)));
4078
4154
  }, h);
4079
- he.set($, {
4155
+ he.set(P, {
4080
4156
  settle: (H) => le(() => d(H)),
4081
4157
  timeoutId: mt,
4082
- abort: qe,
4158
+ abort: He,
4083
4159
  owner: e,
4084
4160
  port: R
4085
4161
  });
4086
4162
  const gt = a == null ? void 0 : a.runId, yt = a == null ? void 0 : a.callId;
4087
- Ue(R, {
4163
+ Be(R, {
4088
4164
  type: e === "main-thread" || e === "content-script" ? "asyncRelay" : "registryCall",
4089
- id: $,
4165
+ id: P,
4090
4166
  owner: e,
4091
4167
  action: r,
4092
4168
  params: o,
@@ -4094,7 +4170,9 @@ function Jt(t) {
4094
4170
  tabPolicy: n,
4095
4171
  command: { action: r, params: o, runId: gt, callId: yt },
4096
4172
  runId: gt
4097
- }) || le(() => m(new Error(`Failed to post relay for action: ${r}`)));
4173
+ }) || le(
4174
+ () => m(new Error(`Failed to post relay for action: ${r}`))
4175
+ );
4098
4176
  });
4099
4177
  };
4100
4178
  }
@@ -4156,17 +4234,28 @@ async function Qt(t, e, r) {
4156
4234
  return n.ok ? { ok: !0, params: n.value } : n;
4157
4235
  }
4158
4236
  function qn(t, e) {
4159
- t = ye(t);
4237
+ t = pe(t);
4160
4238
  const r = e == null ? void 0 : e.action;
4161
- if (C.trace("extensionDispatch", { action: r, callId: e == null ? void 0 : e.callId, runId: e == null ? void 0 : e.runId }), !r)
4239
+ if (C.trace("extensionDispatch", {
4240
+ action: r,
4241
+ callId: e == null ? void 0 : e.callId,
4242
+ runId: e == null ? void 0 : e.runId
4243
+ }), !r)
4162
4244
  return Promise.resolve({
4163
4245
  ok: !1,
4164
- error: { message: "Missing action in dispatch context", code: "E_MISSING_ACTION" }
4246
+ error: {
4247
+ message: "Missing action in dispatch context",
4248
+ code: "E_MISSING_ACTION"
4249
+ }
4165
4250
  });
4166
4251
  const n = t;
4167
4252
  return (async () => {
4168
4253
  var h, d;
4169
- const s = await Qt(r, t, e == null ? void 0 : e.runId);
4254
+ const s = await Qt(
4255
+ r,
4256
+ t,
4257
+ e == null ? void 0 : e.runId
4258
+ );
4170
4259
  if (!s.ok)
4171
4260
  return s;
4172
4261
  if (t = s.params, de.has(r)) {
@@ -4174,17 +4263,20 @@ function qn(t, e) {
4174
4263
  return (async () => {
4175
4264
  try {
4176
4265
  return { ok: !0, value: await m(t, { ...e, signal: R }) };
4177
- } catch ($) {
4178
- const Q = $ instanceof Error ? $.message : String($), le = typeof $ == "object" && $ !== null && "code" in $ && typeof $.code == "string" ? $.code : "E_WORKER_HANDLER";
4266
+ } catch (P) {
4267
+ const Q = P instanceof Error ? P.message : String(P), le = typeof P == "object" && P !== null && "code" in P && typeof P.code == "string" ? P.code : "E_WORKER_HANDLER";
4179
4268
  return { ok: !1, error: { message: Q, code: le } };
4180
4269
  }
4181
4270
  })();
4182
4271
  }
4183
- const i = un(r);
4272
+ const i = Fr(r);
4184
4273
  if (!i)
4185
4274
  return Promise.resolve({
4186
4275
  ok: !1,
4187
- error: { message: `No route registered for action: ${r}`, code: "E_NO_ROUTE" }
4276
+ error: {
4277
+ message: `No route registered for action: ${r}`,
4278
+ code: "E_NO_ROUTE"
4279
+ }
4188
4280
  });
4189
4281
  const a = await Jt({
4190
4282
  owner: i.endpoint,
@@ -4214,10 +4306,14 @@ function Fn(t) {
4214
4306
  );
4215
4307
  return async (r, n) => {
4216
4308
  var i;
4217
- r = ye(r);
4309
+ r = pe(r);
4218
4310
  const s = (n == null ? void 0 : n.signal) ?? (n != null && n.runId ? (i = F.get(n.runId)) == null ? void 0 : i.signal : void 0);
4219
4311
  try {
4220
- return { ok: !0, value: await e(r, { ...n, action: t.action, signal: s }) };
4312
+ return { ok: !0, value: await e(r, {
4313
+ ...n,
4314
+ action: t.action,
4315
+ signal: s
4316
+ }) };
4221
4317
  } catch (o) {
4222
4318
  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;
4223
4319
  return { ok: !1, error: { message: a, code: h } };
@@ -4230,40 +4326,121 @@ function Fn(t) {
4230
4326
  resolveTimeoutMs: (r) => Kt(t.action, r)
4231
4327
  });
4232
4328
  return async (r, n) => {
4233
- var a;
4234
- const s = ye(r), i = await Qt(
4329
+ var o;
4330
+ const s = pe(r), i = await Qt(
4235
4331
  t.action,
4236
4332
  s,
4237
4333
  n == null ? void 0 : n.runId
4238
4334
  );
4239
4335
  if (!i.ok)
4240
4336
  return i;
4241
- const o = await e(i.params, {
4242
- ...n,
4243
- signal: (n == null ? void 0 : n.signal) ?? (n != null && n.runId ? (a = F.get(n.runId)) == null ? void 0 : a.signal : void 0)
4244
- });
4245
- return typeof o == "object" && o !== null && "ok" in o && o.ok && qt.has(t.action) ? {
4246
- ok: !0,
4247
- value: Bt(
4248
- s,
4249
- o.value,
4250
- n == null ? void 0 : n.runId
4251
- )
4252
- } : o;
4337
+ try {
4338
+ const a = await e(i.params, {
4339
+ ...n,
4340
+ signal: (n == null ? void 0 : n.signal) ?? (n != null && n.runId ? (o = F.get(n.runId)) == null ? void 0 : o.signal : void 0)
4341
+ });
4342
+ return typeof a == "object" && a !== null && "ok" in a && a.ok && qt.has(t.action) ? {
4343
+ ok: !0,
4344
+ value: Bt(
4345
+ s,
4346
+ a.value,
4347
+ n == null ? void 0 : n.runId
4348
+ )
4349
+ } : a;
4350
+ } catch (a) {
4351
+ const h = a instanceof Error ? a.message : String(a), d = typeof a == "object" && a !== null && "code" in a && typeof a.code == "string" ? a.code : t.errorCode || "E_RELAY";
4352
+ return { ok: !1, error: { message: h, code: d } };
4353
+ }
4253
4354
  };
4254
4355
  }
4255
4356
  }
4256
4357
  function Un(t) {
4257
- O("exists", X, (e) => t.fsExists(e)), O("stat", X, (e) => t.fsStat(e)), O("read", X, (e) => t.fsRead(e)), O("readText", X, (e) => t.fsReadText(e)), O("readBase64", X, (e) => t.fsReadBase64(e)), O("list", X, (e) => t.fsList(e)), O("mkdir", X, (e) => t.fsMkdir(e)), O("delete", X, (e) => t.fsDelete(e)), O("copy", xt, (e) => t.fsCopy(e)), O("move", xt, (e) => t.fsMove(e)), O("write", ue, (e) => t.fsWrite(e)), O("writeText", ue, (e) => t.fsWriteText(e)), O("writeBase64", ue, async (e) => {
4258
- const r = e;
4259
- return En(r.path, r.data), t.fsWriteBase64(r);
4260
- }), O("append", ue, (e) => t.fsAppend(e)), O("appendText", ue, (e) => t.fsAppendText(e)), O("appendBase64", ue, (e) => t.fsAppendBase64(e)), O("readRange", Zr, (e) => t.fsReadRange(e)), O("update", Wr, (e) => t.fsUpdate(e)), O("hash", Vr, (e) => t.fsHash(e));
4358
+ O(
4359
+ "exists",
4360
+ X,
4361
+ (e) => t.fsExists(e)
4362
+ ), O(
4363
+ "stat",
4364
+ X,
4365
+ (e) => t.fsStat(e)
4366
+ ), O(
4367
+ "read",
4368
+ X,
4369
+ (e) => t.fsRead(e)
4370
+ ), O(
4371
+ "readText",
4372
+ X,
4373
+ (e) => t.fsReadText(e)
4374
+ ), O(
4375
+ "readBase64",
4376
+ X,
4377
+ (e) => t.fsReadBase64(e)
4378
+ ), O(
4379
+ "list",
4380
+ X,
4381
+ (e) => t.fsList(e)
4382
+ ), O(
4383
+ "mkdir",
4384
+ X,
4385
+ (e) => t.fsMkdir(e)
4386
+ ), O(
4387
+ "delete",
4388
+ X,
4389
+ (e) => t.fsDelete(e)
4390
+ ), O(
4391
+ "copy",
4392
+ xt,
4393
+ (e) => t.fsCopy(e)
4394
+ ), O(
4395
+ "move",
4396
+ xt,
4397
+ (e) => t.fsMove(e)
4398
+ ), O(
4399
+ "write",
4400
+ ue,
4401
+ (e) => t.fsWrite(e)
4402
+ ), O(
4403
+ "writeText",
4404
+ ue,
4405
+ (e) => t.fsWriteText(e)
4406
+ ), O(
4407
+ "writeBase64",
4408
+ ue,
4409
+ async (e) => {
4410
+ const r = e;
4411
+ return En(r.path, r.data), t.fsWriteBase64(r);
4412
+ }
4413
+ ), O(
4414
+ "append",
4415
+ ue,
4416
+ (e) => t.fsAppend(e)
4417
+ ), O(
4418
+ "appendText",
4419
+ ue,
4420
+ (e) => t.fsAppendText(e)
4421
+ ), O(
4422
+ "appendBase64",
4423
+ ue,
4424
+ (e) => t.fsAppendBase64(e)
4425
+ ), O(
4426
+ "readRange",
4427
+ sn,
4428
+ (e) => t.fsReadRange(e)
4429
+ ), O(
4430
+ "update",
4431
+ an,
4432
+ (e) => t.fsUpdate(e)
4433
+ ), O(
4434
+ "hash",
4435
+ on,
4436
+ (e) => t.fsHash(e)
4437
+ );
4261
4438
  }
4262
4439
  async function Bn(t, e) {
4263
4440
  if (at) return;
4264
- await Xt(), se = new er(), Je(0), nn(Je), C.trace("initWasm_start"), Un(se), gn(t);
4441
+ await Xt(), se = new er(), Ye(0), or(Ye), C.trace("initWasm_start"), Un(se), Hr(t);
4265
4442
  const n = t.map((i) => ({
4266
- entry: yn(i),
4443
+ entry: ur(i),
4267
4444
  callback: Fn(i)
4268
4445
  }));
4269
4446
  try {
@@ -4291,7 +4468,10 @@ async function Bn(t, e) {
4291
4468
  }
4292
4469
  self.onmessage = async (t) => {
4293
4470
  const e = t.data;
4294
- if (C.trace("onmessage", { type: e.type, id: "id" in e ? e.id : void 0 }), e.type === "asyncRelayResult") {
4471
+ if (C.trace("onmessage", {
4472
+ type: e.type,
4473
+ id: "id" in e ? e.id : void 0
4474
+ }), e.type === "asyncRelayResult") {
4295
4475
  C.trace("asyncRelayResult", { id: e.id }), ct(e.id, e.result);
4296
4476
  return;
4297
4477
  }
@@ -4301,7 +4481,7 @@ self.onmessage = async (t) => {
4301
4481
  C.error("register_worker_port_missing", { owner: e.owner });
4302
4482
  return;
4303
4483
  }
4304
- $n(e.owner, n);
4484
+ Pn(e.owner, n);
4305
4485
  return;
4306
4486
  }
4307
4487
  if (e.type === "init") {
@@ -4309,12 +4489,15 @@ self.onmessage = async (t) => {
4309
4489
  await Bn(e.manifest, e.extensionId), self.postMessage({ type: "ready" });
4310
4490
  } catch (n) {
4311
4491
  const s = n instanceof Error ? n.message : String(n);
4312
- C.error("worker_init_failed", { error: s }), self.postMessage({ type: "error", error: `WASM init failed: ${s}` });
4492
+ C.error("worker_init_failed", { error: s }), self.postMessage({
4493
+ type: "error",
4494
+ error: `WASM init failed: ${s}`
4495
+ });
4313
4496
  }
4314
4497
  return;
4315
4498
  }
4316
4499
  if (e.type === "setLogLevel") {
4317
- Je(e.level), rn(Mn(e.level)), C.trace("set_log_level", { level: e.level });
4500
+ Ye(e.level), ar(Mn(e.level)), C.trace("set_log_level", { level: e.level });
4318
4501
  return;
4319
4502
  }
4320
4503
  if (!at || !se) {
@@ -4330,14 +4513,22 @@ self.onmessage = async (t) => {
4330
4513
  switch (e.type) {
4331
4514
  case "runCell": {
4332
4515
  const n = e.runId, s = new AbortController();
4333
- n && F.set(n, s), Z = { id: e.id, runId: n }, C.trace("runCell_start", { runId: n, callId: e.id, codeLen: e.code.length });
4516
+ n && F.set(n, s), Z = { id: e.id, runId: n }, C.trace("runCell_start", {
4517
+ runId: n,
4518
+ callId: e.id,
4519
+ codeLen: e.code.length
4520
+ });
4334
4521
  try {
4335
4522
  const i = await r.runCellAsync(
4336
4523
  e.code,
4337
4524
  e.stdin || "",
4338
4525
  n || ""
4339
4526
  );
4340
- C.trace("runCell_done", { runId: n, callId: e.id, status: i.status }), self.postMessage({
4527
+ C.trace("runCell_done", {
4528
+ runId: n,
4529
+ callId: e.id,
4530
+ status: i.status
4531
+ }), self.postMessage({
4341
4532
  type: "result",
4342
4533
  id: e.id,
4343
4534
  data: i,
@@ -4351,7 +4542,12 @@ self.onmessage = async (t) => {
4351
4542
  R && (d = parseInt(R[1], 10));
4352
4543
  }
4353
4544
  C.error("runCell_error", { runId: n, error: o, name: a, line: d });
4354
- const m = i instanceof Error ? { name: a, message: o, stack: h, ...d !== void 0 ? { line: d } : {} } : { message: o };
4545
+ const m = i instanceof Error ? {
4546
+ name: a,
4547
+ message: o,
4548
+ stack: h,
4549
+ ...d !== void 0 ? { line: d } : {}
4550
+ } : { message: o };
4355
4551
  self.postMessage({
4356
4552
  type: "error",
4357
4553
  id: e.id,
@@ -4365,7 +4561,8 @@ self.onmessage = async (t) => {
4365
4561
  }
4366
4562
  case "reset": {
4367
4563
  r.setAborted(!0);
4368
- for (const n of F.values()) n.abort();
4564
+ for (const n of F.values())
4565
+ n.abort();
4369
4566
  F.clear(), St(), An(), nr(), At("E_RESET", "Worker reset");
4370
4567
  try {
4371
4568
  r.reset(), self.postMessage({ type: "result", id: e.id, data: { ok: !0 } });
@@ -4377,13 +4574,18 @@ self.onmessage = async (t) => {
4377
4574
  }
4378
4575
  case "stop": {
4379
4576
  r.setAborted(!0);
4380
- for (const n of F.values()) n.abort();
4577
+ for (const n of F.values())
4578
+ n.abort();
4381
4579
  F.clear(), St(), At("E_STOPPED", "Worker stopped"), self.postMessage({ type: "result", id: e.id, data: { ok: !0 } });
4382
4580
  break;
4383
4581
  }
4384
4582
  case "setFuelLimit": {
4385
4583
  try {
4386
- r.set_fuel_limit(e.limit), e.id && self.postMessage({ type: "result", id: e.id, data: { ok: !0 } });
4584
+ r.set_fuel_limit(e.limit), e.id && self.postMessage({
4585
+ type: "result",
4586
+ id: e.id,
4587
+ data: { ok: !0 }
4588
+ });
4387
4589
  } catch (n) {
4388
4590
  if (e.id) {
4389
4591
  const s = n instanceof Error ? n.message : String(n);
@@ -4442,7 +4644,9 @@ self.onmessage = async (t) => {
4442
4644
  break;
4443
4645
  }
4444
4646
  default: {
4445
- C.error("unhandled_worker_message", { type: e.type });
4647
+ C.error("unhandled_worker_message", {
4648
+ type: e.type
4649
+ });
4446
4650
  break;
4447
4651
  }
4448
4652
  }
@@ -4454,7 +4658,7 @@ export {
4454
4658
  qn as extensionDispatch,
4455
4659
  On as registerWorkerHandler,
4456
4660
  O as registerWorkerHandlerValidated,
4457
- $n as registerWorkerPort,
4661
+ Pn as registerWorkerPort,
4458
4662
  ct as resolveAsyncRelayResult,
4459
4663
  Kt as resolveRelayTimeoutMs,
4460
4664
  Jt as safePostAsCall,