@cartridge/controller 0.10.7 → 0.11.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/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
- import { WalletAccount as Nt, constants as V, num as rt, shortString as De } from "starknet";
2
- import { R as Q, t as Rt, i as Tt, K as Ut, B as zt, N as v, p as Lt, v as Dt, A as Ot } from "./provider-CN6AecRF.js";
3
- import { a as Gn, d as Xn, E as Jn, f as Zn, e as es, F as ts, I as rs, S as ns, h as ss, n as os, b as is, c as as } from "./provider-CN6AecRF.js";
4
- class Oe extends Nt {
1
+ import { WalletAccount as Rt, constants as K, num as nt, shortString as Oe } from "starknet";
2
+ import { R as Q, t as Ut, i as Tt, K as be, B as zt, N as E, p as Lt, v as Dt, A as Ot } from "./provider-GfOahKeA.js";
3
+ import { a as Xn, d as Jn, E as Zn, f as es, e as ts, F as rs, I as ns, h as ss, n as os, b as is, c as as } from "./provider-GfOahKeA.js";
4
+ class Me extends Rt {
5
5
  keychain;
6
6
  modal;
7
7
  options;
8
- constructor(e, r, n, s, o, a) {
8
+ constructor(e, r, n, s, o, i) {
9
9
  super({
10
10
  provider: { nodeUrl: r },
11
11
  walletProvider: e,
12
12
  address: n
13
- }), this.keychain = s, this.options = o, this.modal = a;
13
+ }), this.keychain = s, this.options = o, this.modal = i;
14
14
  }
15
15
  /**
16
16
  * Invoke execute function in account contract
@@ -25,7 +25,7 @@ class Oe extends Nt {
25
25
  * @returns response from addTransaction
26
26
  */
27
27
  async execute(e) {
28
- return e = Rt(e), new Promise(async (r, n) => {
28
+ return e = Ut(e), new Promise(async (r, n) => {
29
29
  const s = await this.keychain.execute(
30
30
  e,
31
31
  void 0,
@@ -89,14 +89,14 @@ var G;
89
89
  (function(t) {
90
90
  t.ConnectionDestroyed = "ConnectionDestroyed", t.ConnectionTimeout = "ConnectionTimeout", t.NoIframeSrc = "NoIframeSrc";
91
91
  })(G || (G = {}));
92
- var be;
92
+ var _e;
93
93
  (function(t) {
94
94
  t.DataCloneError = "DataCloneError";
95
- })(be || (be = {}));
96
- var T;
95
+ })(_e || (_e = {}));
96
+ var U;
97
97
  (function(t) {
98
98
  t.Message = "message";
99
- })(T || (T = {}));
99
+ })(U || (U = {}));
100
100
  const Mt = (t, e) => {
101
101
  const r = [];
102
102
  let n = !1;
@@ -116,28 +116,28 @@ const Mt = (t, e) => {
116
116
  "http:": "80",
117
117
  "https:": "443"
118
118
  }, Wt = /^(https?:)?\/\/([^/:]+)?(:(\d+))?/, jt = ["file:", "data:"], Yt = (t) => {
119
- if (t && jt.find((i) => t.startsWith(i)))
119
+ if (t && jt.find((a) => t.startsWith(a)))
120
120
  return "null";
121
121
  const e = document.location, r = Wt.exec(t);
122
122
  let n, s, o;
123
123
  r ? (n = r[1] ? r[1] : e.protocol, s = r[2], o = r[4]) : (n = e.protocol, s = e.hostname, o = e.port);
124
- const a = o && o !== Ft[n] ? `:${o}` : "";
125
- return `${n}//${s}${a}`;
126
- }, Me = ({ name: t, message: e, stack: r }) => ({
124
+ const i = o && o !== Ft[n] ? `:${o}` : "";
125
+ return `${n}//${s}${i}`;
126
+ }, Qe = ({ name: t, message: e, stack: r }) => ({
127
127
  name: t,
128
128
  message: e,
129
129
  stack: r
130
130
  }), Ht = (t) => {
131
131
  const e = new Error();
132
132
  return Object.keys(t).forEach((r) => e[r] = t[r]), e;
133
- }, Kt = (t, e, r) => {
134
- const { localName: n, local: s, remote: o, originForSending: a, originForReceiving: i } = t;
133
+ }, Vt = (t, e, r) => {
134
+ const { localName: n, local: s, remote: o, originForSending: i, originForReceiving: a } = t;
135
135
  let l = !1;
136
136
  const c = (d) => {
137
137
  if (d.source !== o || d.data.penpal !== B.Call)
138
138
  return;
139
- if (i !== "*" && d.origin !== i) {
140
- r(`${n} received message from origin ${d.origin} which did not match expected origin ${i}`);
139
+ if (a !== "*" && d.origin !== a) {
140
+ r(`${n} received message from origin ${d.origin} which did not match expected origin ${a}`);
141
141
  return;
142
142
  }
143
143
  const h = d.data, { methodName: f, args: u, id: w } = h;
@@ -153,41 +153,41 @@ const Mt = (t, e) => {
153
153
  resolution: m,
154
154
  returnValue: I
155
155
  };
156
- m === z.Rejected && I instanceof Error && (k.returnValue = Me(I), k.returnValueIsError = !0);
156
+ m === z.Rejected && I instanceof Error && (k.returnValue = Qe(I), k.returnValueIsError = !0);
157
157
  try {
158
- o.postMessage(k, a);
158
+ o.postMessage(k, i);
159
159
  } catch (p) {
160
- if (p.name === be.DataCloneError) {
161
- const E = {
160
+ if (p.name === _e.DataCloneError) {
161
+ const v = {
162
162
  penpal: B.Reply,
163
163
  id: w,
164
164
  resolution: z.Rejected,
165
- returnValue: Me(p),
165
+ returnValue: Qe(p),
166
166
  returnValueIsError: !0
167
167
  };
168
- o.postMessage(E, a);
168
+ o.postMessage(v, i);
169
169
  }
170
170
  throw p;
171
171
  }
172
172
  };
173
173
  new Promise((m) => m(e[f].call(e, d.origin).apply(e, u))).then(_(z.Fulfilled), _(z.Rejected));
174
174
  };
175
- return s.addEventListener(T.Message, c), () => {
176
- l = !0, s.removeEventListener(T.Message, c);
175
+ return s.addEventListener(U.Message, c), () => {
176
+ l = !0, s.removeEventListener(U.Message, c);
177
177
  };
178
178
  };
179
- let Vt = 0;
180
- const qt = () => ++Vt, nt = ".", st = (t) => t ? t.split(nt) : [], Gt = (t) => t.join(nt), Xt = (t, e) => {
181
- const r = st(e || "");
179
+ let Kt = 0;
180
+ const qt = () => ++Kt, st = ".", ot = (t) => t ? t.split(st) : [], Gt = (t) => t.join(st), Xt = (t, e) => {
181
+ const r = ot(e || "");
182
182
  return r.push(t), Gt(r);
183
183
  }, Jt = (t, e, r) => {
184
- const n = st(e);
185
- return n.reduce((s, o, a) => (typeof s[o] > "u" && (s[o] = {}), a === n.length - 1 && (s[o] = r), s[o]), t), t;
186
- }, ot = (t, e) => {
184
+ const n = ot(e);
185
+ return n.reduce((s, o, i) => (typeof s[o] > "u" && (s[o] = {}), i === n.length - 1 && (s[o] = r), s[o]), t), t;
186
+ }, it = (t, e) => {
187
187
  const r = {};
188
188
  return Object.keys(t).forEach((n) => {
189
189
  const s = t[n], o = Xt(n, e);
190
- typeof s == "object" && Object.assign(r, ot(s, o)), typeof s == "function" && (r[o] = s);
190
+ typeof s == "object" && Object.assign(r, it(s, o)), typeof s == "function" && (r[o] = s);
191
191
  }), r;
192
192
  }, Zt = (t) => {
193
193
  const e = {};
@@ -195,14 +195,14 @@ const qt = () => ++Vt, nt = ".", st = (t) => t ? t.split(nt) : [], Gt = (t) => t
195
195
  Jt(e, r, t[r]);
196
196
  return e;
197
197
  }, er = (t, e, r, n, s) => {
198
- const { localName: o, local: a, remote: i, originForSending: l, originForReceiving: c } = e;
198
+ const { localName: o, local: i, remote: a, originForSending: l, originForReceiving: c } = e;
199
199
  let d = !1;
200
200
  s(`${o}: Connecting call sender`);
201
201
  const h = (u) => (...w) => {
202
202
  s(`${o}: Sending ${u}() call`);
203
203
  let _;
204
204
  try {
205
- i.closed && (_ = !0);
205
+ a.closed && (_ = !0);
206
206
  } catch {
207
207
  _ = !0;
208
208
  }
@@ -212,33 +212,33 @@ const qt = () => ++Vt, nt = ".", st = (t) => t ? t.split(nt) : [], Gt = (t) => t
212
212
  }
213
213
  return new Promise((m, I) => {
214
214
  const k = qt(), p = (C) => {
215
- if (C.source !== i || C.data.penpal !== B.Reply || C.data.id !== k)
215
+ if (C.source !== a || C.data.penpal !== B.Reply || C.data.id !== k)
216
216
  return;
217
217
  if (c !== "*" && C.origin !== c) {
218
218
  s(`${o} received message from origin ${C.origin} which did not match expected origin ${c}`);
219
219
  return;
220
220
  }
221
221
  const de = C.data;
222
- s(`${o}: Received ${u}() reply`), a.removeEventListener(T.Message, p);
222
+ s(`${o}: Received ${u}() reply`), i.removeEventListener(U.Message, p);
223
223
  let he = de.returnValue;
224
224
  de.returnValueIsError && (he = Ht(he)), (de.resolution === z.Fulfilled ? m : I)(he);
225
225
  };
226
- a.addEventListener(T.Message, p);
227
- const E = {
226
+ i.addEventListener(U.Message, p);
227
+ const v = {
228
228
  penpal: B.Call,
229
229
  id: k,
230
230
  methodName: u,
231
231
  args: w
232
232
  };
233
- i.postMessage(E, l);
233
+ a.postMessage(v, l);
234
234
  });
235
235
  }, f = r.reduce((u, w) => (u[w] = h(w), u), {});
236
236
  return Object.assign(t, Zt(f)), () => {
237
237
  d = !0;
238
238
  };
239
239
  }, tr = (t, e, r, n, s) => {
240
- const { destroy: o, onDestroy: a } = n;
241
- let i, l;
240
+ const { destroy: o, onDestroy: i } = n;
241
+ let a, l;
242
242
  const c = {};
243
243
  return (d) => {
244
244
  if (e !== "*" && d.origin !== e) {
@@ -253,11 +253,11 @@ const qt = () => ++Vt, nt = ".", st = (t) => t ? t.split(nt) : [], Gt = (t) => t
253
253
  originForSending: r,
254
254
  originForReceiving: e
255
255
  };
256
- i && i(), i = Kt(h, t, s), a(i), l && l.forEach((u) => {
256
+ a && a(), a = Vt(h, t, s), i(a), l && l.forEach((u) => {
257
257
  delete c[u];
258
258
  }), l = d.data.methodNames;
259
259
  const f = er(c, h, l, o, s);
260
- return a(f), c;
260
+ return i(f), c;
261
261
  };
262
262
  }, rr = (t, e, r, n) => (s) => {
263
263
  if (!s.source)
@@ -294,9 +294,9 @@ const qt = () => ++Vt, nt = ".", st = (t) => t ? t.split(nt) : [], Gt = (t) => t
294
294
  }
295
295
  }, ar = (t) => {
296
296
  let { iframe: e, methods: r = {}, childOrigin: n, timeout: s, debug: o = !1 } = t;
297
- const a = Qt(o), i = Mt("Parent", a), { onDestroy: l, destroy: c } = i;
297
+ const i = Qt(o), a = Mt("Parent", i), { onDestroy: l, destroy: c } = a;
298
298
  n || (ir(e), n = Yt(e.src));
299
- const d = n === "null" ? "*" : n, h = ot(r), f = rr(a, h, n, d), u = tr(h, n, d, i, a);
299
+ const d = n === "null" ? "*" : n, h = it(r), f = rr(i, h, n, d), u = tr(h, n, d, a, i);
300
300
  return {
301
301
  promise: new Promise((_, m) => {
302
302
  const I = or(s, c), k = (p) => {
@@ -306,14 +306,14 @@ const qt = () => ++Vt, nt = ".", st = (t) => t ? t.split(nt) : [], Gt = (t) => t
306
306
  return;
307
307
  }
308
308
  if (p.data.penpal === B.Ack) {
309
- const E = u(p);
310
- E && (I(), _(E));
309
+ const v = u(p);
310
+ v && (I(), _(v));
311
311
  return;
312
312
  }
313
313
  }
314
314
  };
315
- window.addEventListener(T.Message, k), a("Parent: Awaiting handshake"), sr(e, i), l((p) => {
316
- window.removeEventListener(T.Message, k), p && m(p);
315
+ window.addEventListener(U.Message, k), i("Parent: Awaiting handshake"), sr(e, a), l((p) => {
316
+ window.removeEventListener(U.Message, k), p && m(p);
317
317
  });
318
318
  }),
319
319
  destroy() {
@@ -331,40 +331,59 @@ class cr {
331
331
  constructor({
332
332
  id: e,
333
333
  url: r,
334
- preset: n,
335
- onClose: s,
336
- onConnect: o,
337
- methods: a = {}
334
+ onClose: n,
335
+ onConnect: s,
336
+ methods: o = {}
338
337
  }) {
339
338
  if (typeof document > "u" || typeof window > "u")
340
339
  return;
341
- n && r.searchParams.set("preset", n), this.url = r;
342
- const i = document.createElement("iframe");
343
- i.src = r.toString(), i.id = e, i.style.border = "none", i.sandbox.add("allow-forms"), i.sandbox.add("allow-popups"), i.sandbox.add("allow-popups-to-escape-sandbox"), i.sandbox.add("allow-scripts"), i.sandbox.add("allow-same-origin"), i.allow = "publickey-credentials-create *; publickey-credentials-get *; clipboard-write", document.hasStorageAccess && i.sandbox.add("allow-storage-access-by-user-activation");
344
- const l = document.createElement("div");
345
- l.id = "controller", l.style.position = "fixed", l.style.height = "100%", l.style.width = "100%", l.style.top = "0", l.style.left = "0", l.style.zIndex = "10000", l.style.backgroundColor = "rgba(0,0,0,0.6)", l.style.display = "none", l.style.alignItems = "center", l.style.justifyContent = "center", l.style.transition = "opacity 0.2s ease", l.style.opacity = "0", l.style.pointerEvents = "auto", l.appendChild(i), l.addEventListener("click", (h) => {
346
- h.target === l && (e === "controller-keychain" && this.child && this.child.reset?.().catch((f) => console.error("Error resetting context:", f)), this.close());
347
- }), this.iframe = i, this.container = l, ar({
340
+ this.url = r;
341
+ const i = document.head, a = document.createElement("meta");
342
+ a.name = "viewport", a.id = "controller-viewport", a.content = "width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, interactive-widget=resizes-content", i.appendChild(a);
343
+ const l = document.createElement("iframe");
344
+ l.src = r.toString(), l.id = e, l.style.border = "none", l.sandbox.add("allow-forms"), l.sandbox.add("allow-popups"), l.sandbox.add("allow-popups-to-escape-sandbox"), l.sandbox.add("allow-scripts"), l.sandbox.add("allow-same-origin"), l.allow = "publickey-credentials-create *; publickey-credentials-get *; clipboard-write", l.style.scrollbarWidth = "none", l.style.setProperty("-ms-overflow-style", "none"), l.style.setProperty("-webkit-scrollbar", "none"), document.hasStorageAccess && l.sandbox.add("allow-storage-access-by-user-activation");
345
+ const c = document.createElement("div");
346
+ c.id = "controller", c.style.position = "fixed", c.style.height = "100%", c.style.width = "100%", c.style.top = "0", c.style.left = "0", c.style.zIndex = "10000", c.style.backgroundColor = "rgba(0,0,0,0.6)", c.style.display = "none", c.style.alignItems = "center", c.style.justifyContent = "center", c.style.transition = "opacity 0.2s ease", c.style.opacity = "0", c.style.pointerEvents = "auto", c.style.overscrollBehaviorY = "contain", c.style.scrollbarWidth = "none", c.style.setProperty("-ms-overflow-style", "none"), c.style.setProperty("-webkit-scrollbar", "none"), c.appendChild(l), c.addEventListener(
347
+ "touchstart",
348
+ (f) => {
349
+ f.touches.length > 1 && f.preventDefault();
350
+ },
351
+ { passive: !1 }
352
+ ), c.addEventListener(
353
+ "touchmove",
354
+ (f) => {
355
+ f.touches.length > 1 && f.preventDefault();
356
+ },
357
+ { passive: !1 }
358
+ ), c.addEventListener(
359
+ "touchend",
360
+ (f) => {
361
+ f.touches.length > 1 && f.preventDefault();
362
+ },
363
+ { passive: !1 }
364
+ ), c.addEventListener("click", (f) => {
365
+ f.target === c && (e === "controller-keychain" && this.child && this.child.reset?.().catch((u) => console.error("Error resetting context:", u)), this.close());
366
+ }), this.iframe = l, this.container = c, ar({
348
367
  iframe: this.iframe,
349
368
  methods: {
350
- close: (h) => () => this.close(),
351
- reload: (h) => () => window.location.reload(),
352
- ...a
369
+ close: (f) => () => this.close(),
370
+ reload: (f) => () => window.location.reload(),
371
+ ...o
353
372
  }
354
- }).promise.then((h) => {
355
- this.child = h, o(h);
373
+ }).promise.then((f) => {
374
+ this.child = f, s(f);
356
375
  }), this.resize(), window.addEventListener("resize", () => this.resize());
357
- const c = new MutationObserver(() => {
376
+ const d = new MutationObserver(() => {
358
377
  if (typeof document > "u") return;
359
- const h = document.getElementById("controller");
360
- document.body && e === "controller-keychain" && !h && (document.body.appendChild(l), c.disconnect());
378
+ const f = document.getElementById("controller");
379
+ document.body && e === "controller-keychain" && !f && (document.body.appendChild(c), d.disconnect());
361
380
  });
362
- c.observe(document.documentElement, {
381
+ d.observe(document.documentElement, {
363
382
  childList: !0,
364
383
  subtree: !0
365
384
  });
366
- const d = document.getElementById("controller");
367
- document.body && e === "controller-keychain" && !d && document.body.appendChild(l), this.onClose = s;
385
+ const h = document.getElementById("controller");
386
+ document.body && e === "controller-keychain" && !h && document.body.appendChild(c), this.onClose = n;
368
387
  }
369
388
  open() {
370
389
  !this.container || typeof document > "u" || !document.body || (this.closeTimeout && (clearTimeout(this.closeTimeout), this.closeTimeout = void 0), document.body.style.overflow = "hidden", this.container.style.display = "flex", requestAnimationFrame(() => {
@@ -396,7 +415,7 @@ class cr {
396
415
  }
397
416
  }
398
417
  const lr = "6.13.7";
399
- function Qe(t, e, r) {
418
+ function Fe(t, e, r) {
400
419
  for (let n in e) {
401
420
  let s = e[n];
402
421
  Object.defineProperty(t, n, { enumerable: !0, value: s, writable: !1 });
@@ -440,11 +459,11 @@ function dr(t, e, r) {
440
459
  if (r) {
441
460
  if ("message" in r || "code" in r || "name" in r)
442
461
  throw new Error(`value will overwrite populated values: ${M(r)}`);
443
- for (const a in r) {
444
- if (a === "shortMessage")
462
+ for (const i in r) {
463
+ if (i === "shortMessage")
445
464
  continue;
446
- const i = r[a];
447
- o.push(a + "=" + M(i));
465
+ const a = r[i];
466
+ o.push(i + "=" + M(a));
448
467
  }
449
468
  }
450
469
  o.push(`code=${e}`), o.push(`version=${lr}`), o.length && (t += " (" + o.join(", ") + ")");
@@ -461,7 +480,7 @@ function dr(t, e, r) {
461
480
  default:
462
481
  s = new Error(t);
463
482
  }
464
- return Qe(s, { code: e }), r && Object.assign(s, r), s.shortMessage == null && Qe(s, { shortMessage: n }), s;
483
+ return Fe(s, { code: e }), r && Object.assign(s, r), s.shortMessage == null && Fe(s, { shortMessage: n }), s;
465
484
  }
466
485
  function hr(t, e, r, n) {
467
486
  if (!t)
@@ -493,40 +512,40 @@ function fr(t, e, r) {
493
512
  }
494
513
  Y(!1, "invalid BytesLike value", e || "value", t);
495
514
  }
496
- function xe(t, e) {
515
+ function $e(t, e) {
497
516
  return fr(t, e);
498
517
  }
499
- const Fe = "0123456789abcdef";
518
+ const We = "0123456789abcdef";
500
519
  function ur(t) {
501
- const e = xe(t);
520
+ const e = $e(t);
502
521
  let r = "0x";
503
522
  for (let n = 0; n < e.length; n++) {
504
523
  const s = e[n];
505
- r += Fe[(s & 240) >> 4] + Fe[s & 15];
524
+ r += We[(s & 240) >> 4] + We[s & 15];
506
525
  }
507
526
  return r;
508
527
  }
509
528
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
510
- function gr(t) {
529
+ function wr(t) {
511
530
  return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
512
531
  }
513
- function We(t) {
532
+ function je(t) {
514
533
  if (!Number.isSafeInteger(t) || t < 0)
515
534
  throw new Error("positive integer expected, got " + t);
516
535
  }
517
536
  function re(t, ...e) {
518
- if (!gr(t))
537
+ if (!wr(t))
519
538
  throw new Error("Uint8Array expected");
520
539
  if (e.length > 0 && !e.includes(t.length))
521
540
  throw new Error("Uint8Array expected of length " + e + ", got length=" + t.length);
522
541
  }
523
- function je(t, e = !0) {
542
+ function Ye(t, e = !0) {
524
543
  if (t.destroyed)
525
544
  throw new Error("Hash instance has been destroyed");
526
545
  if (e && t.finished)
527
546
  throw new Error("Hash#digest() has already been called");
528
547
  }
529
- function wr(t, e) {
548
+ function gr(t, e) {
530
549
  re(t);
531
550
  const r = e.outputLen;
532
551
  if (t.length < r)
@@ -535,7 +554,7 @@ function wr(t, e) {
535
554
  function pr(t) {
536
555
  return new Uint32Array(t.buffer, t.byteOffset, Math.floor(t.byteLength / 4));
537
556
  }
538
- function it(...t) {
557
+ function at(...t) {
539
558
  for (let e = 0; e < t.length; e++)
540
559
  t[e].fill(0);
541
560
  }
@@ -548,72 +567,72 @@ function br(t) {
548
567
  t[e] = mr(t[e]);
549
568
  return t;
550
569
  }
551
- const Ye = yr ? (t) => t : br;
570
+ const He = yr ? (t) => t : br;
552
571
  function _r(t) {
553
572
  if (typeof t != "string")
554
573
  throw new Error("string expected");
555
574
  return new Uint8Array(new TextEncoder().encode(t));
556
575
  }
557
- function at(t) {
576
+ function ct(t) {
558
577
  return typeof t == "string" && (t = _r(t)), re(t), t;
559
578
  }
560
579
  class kr {
561
580
  }
562
581
  function Ar(t) {
563
- const e = (n) => t().update(at(n)).digest(), r = t();
582
+ const e = (n) => t().update(ct(n)).digest(), r = t();
564
583
  return e.outputLen = r.outputLen, e.blockLen = r.blockLen, e.create = () => t(), e;
565
584
  }
566
- const Z = /* @__PURE__ */ BigInt(2 ** 32 - 1), He = /* @__PURE__ */ BigInt(32);
585
+ const Z = /* @__PURE__ */ BigInt(2 ** 32 - 1), Ve = /* @__PURE__ */ BigInt(32);
567
586
  function Er(t, e = !1) {
568
- return e ? { h: Number(t & Z), l: Number(t >> He & Z) } : { h: Number(t >> He & Z) | 0, l: Number(t & Z) | 0 };
587
+ return e ? { h: Number(t & Z), l: Number(t >> Ve & Z) } : { h: Number(t >> Ve & Z) | 0, l: Number(t & Z) | 0 };
569
588
  }
570
589
  function vr(t, e = !1) {
571
590
  const r = t.length;
572
591
  let n = new Uint32Array(r), s = new Uint32Array(r);
573
592
  for (let o = 0; o < r; o++) {
574
- const { h: a, l: i } = Er(t[o], e);
575
- [n[o], s[o]] = [a, i];
593
+ const { h: i, l: a } = Er(t[o], e);
594
+ [n[o], s[o]] = [i, a];
576
595
  }
577
596
  return [n, s];
578
597
  }
579
- const xr = (t, e, r) => t << r | e >>> 32 - r, $r = (t, e, r) => e << r | t >>> 32 - r, Sr = (t, e, r) => e << r - 32 | t >>> 64 - r, Ir = (t, e, r) => t << r - 32 | e >>> 64 - r, Cr = BigInt(0), j = BigInt(1), Pr = BigInt(2), Br = BigInt(7), Nr = BigInt(256), Rr = BigInt(113), ct = [], lt = [], dt = [];
598
+ const xr = (t, e, r) => t << r | e >>> 32 - r, $r = (t, e, r) => e << r | t >>> 32 - r, Sr = (t, e, r) => e << r - 32 | t >>> 64 - r, Ir = (t, e, r) => t << r - 32 | e >>> 64 - r, Cr = BigInt(0), j = BigInt(1), Pr = BigInt(2), Br = BigInt(7), Nr = BigInt(256), Rr = BigInt(113), lt = [], dt = [], ht = [];
580
599
  for (let t = 0, e = j, r = 1, n = 0; t < 24; t++) {
581
- [r, n] = [n, (2 * r + 3 * n) % 5], ct.push(2 * (5 * n + r)), lt.push((t + 1) * (t + 2) / 2 % 64);
600
+ [r, n] = [n, (2 * r + 3 * n) % 5], lt.push(2 * (5 * n + r)), dt.push((t + 1) * (t + 2) / 2 % 64);
582
601
  let s = Cr;
583
602
  for (let o = 0; o < 7; o++)
584
603
  e = (e << j ^ (e >> Br) * Rr) % Nr, e & Pr && (s ^= j << (j << /* @__PURE__ */ BigInt(o)) - j);
585
- dt.push(s);
604
+ ht.push(s);
586
605
  }
587
- const ht = vr(dt, !0), Tr = ht[0], Ur = ht[1], Ke = (t, e, r) => r > 32 ? Sr(t, e, r) : xr(t, e, r), Ve = (t, e, r) => r > 32 ? Ir(t, e, r) : $r(t, e, r);
606
+ const ft = vr(ht, !0), Ur = ft[0], Tr = ft[1], Ke = (t, e, r) => r > 32 ? Sr(t, e, r) : xr(t, e, r), qe = (t, e, r) => r > 32 ? Ir(t, e, r) : $r(t, e, r);
588
607
  function zr(t, e = 24) {
589
608
  const r = new Uint32Array(10);
590
609
  for (let n = 24 - e; n < 24; n++) {
591
- for (let a = 0; a < 10; a++)
592
- r[a] = t[a] ^ t[a + 10] ^ t[a + 20] ^ t[a + 30] ^ t[a + 40];
593
- for (let a = 0; a < 10; a += 2) {
594
- const i = (a + 8) % 10, l = (a + 2) % 10, c = r[l], d = r[l + 1], h = Ke(c, d, 1) ^ r[i], f = Ve(c, d, 1) ^ r[i + 1];
610
+ for (let i = 0; i < 10; i++)
611
+ r[i] = t[i] ^ t[i + 10] ^ t[i + 20] ^ t[i + 30] ^ t[i + 40];
612
+ for (let i = 0; i < 10; i += 2) {
613
+ const a = (i + 8) % 10, l = (i + 2) % 10, c = r[l], d = r[l + 1], h = Ke(c, d, 1) ^ r[a], f = qe(c, d, 1) ^ r[a + 1];
595
614
  for (let u = 0; u < 50; u += 10)
596
- t[a + u] ^= h, t[a + u + 1] ^= f;
615
+ t[i + u] ^= h, t[i + u + 1] ^= f;
597
616
  }
598
617
  let s = t[2], o = t[3];
599
- for (let a = 0; a < 24; a++) {
600
- const i = lt[a], l = Ke(s, o, i), c = Ve(s, o, i), d = ct[a];
618
+ for (let i = 0; i < 24; i++) {
619
+ const a = dt[i], l = Ke(s, o, a), c = qe(s, o, a), d = lt[i];
601
620
  s = t[d], o = t[d + 1], t[d] = l, t[d + 1] = c;
602
621
  }
603
- for (let a = 0; a < 50; a += 10) {
604
- for (let i = 0; i < 10; i++)
605
- r[i] = t[a + i];
606
- for (let i = 0; i < 10; i++)
607
- t[a + i] ^= ~r[(i + 2) % 10] & r[(i + 4) % 10];
622
+ for (let i = 0; i < 50; i += 10) {
623
+ for (let a = 0; a < 10; a++)
624
+ r[a] = t[i + a];
625
+ for (let a = 0; a < 10; a++)
626
+ t[i + a] ^= ~r[(a + 2) % 10] & r[(a + 4) % 10];
608
627
  }
609
- t[0] ^= Tr[n], t[1] ^= Ur[n];
628
+ t[0] ^= Ur[n], t[1] ^= Tr[n];
610
629
  }
611
- it(r);
630
+ at(r);
612
631
  }
613
- class $e extends kr {
632
+ class Se extends kr {
614
633
  // NOTE: we accept arguments in bytes instead of bits here.
615
634
  constructor(e, r, n, s = !1, o = 24) {
616
- if (super(), this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, this.enableXOF = !1, this.blockLen = e, this.suffix = r, this.outputLen = n, this.enableXOF = s, this.rounds = o, We(n), !(0 < e && e < 200))
635
+ if (super(), this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, this.enableXOF = !1, this.blockLen = e, this.suffix = r, this.outputLen = n, this.enableXOF = s, this.rounds = o, je(n), !(0 < e && e < 200))
617
636
  throw new Error("only keccak-f1600 function is supported");
618
637
  this.state = new Uint8Array(200), this.state32 = pr(this.state);
619
638
  }
@@ -621,14 +640,14 @@ class $e extends kr {
621
640
  return this._cloneInto();
622
641
  }
623
642
  keccak() {
624
- Ye(this.state32), zr(this.state32, this.rounds), Ye(this.state32), this.posOut = 0, this.pos = 0;
643
+ He(this.state32), zr(this.state32, this.rounds), He(this.state32), this.posOut = 0, this.pos = 0;
625
644
  }
626
645
  update(e) {
627
- je(this), e = at(e), re(e);
646
+ Ye(this), e = ct(e), re(e);
628
647
  const { blockLen: r, state: n } = this, s = e.length;
629
648
  for (let o = 0; o < s; ) {
630
- const a = Math.min(r - this.pos, s - o);
631
- for (let i = 0; i < a; i++)
649
+ const i = Math.min(r - this.pos, s - o);
650
+ for (let a = 0; a < i; a++)
632
651
  n[this.pos++] ^= e[o++];
633
652
  this.pos === r && this.keccak();
634
653
  }
@@ -642,12 +661,12 @@ class $e extends kr {
642
661
  e[n] ^= r, (r & 128) !== 0 && n === s - 1 && this.keccak(), e[s - 1] ^= 128, this.keccak();
643
662
  }
644
663
  writeInto(e) {
645
- je(this, !1), re(e), this.finish();
664
+ Ye(this, !1), re(e), this.finish();
646
665
  const r = this.state, { blockLen: n } = this;
647
666
  for (let s = 0, o = e.length; s < o; ) {
648
667
  this.posOut >= n && this.keccak();
649
- const a = Math.min(n - this.posOut, o - s);
650
- e.set(r.subarray(this.posOut, this.posOut + a), s), this.posOut += a, s += a;
668
+ const i = Math.min(n - this.posOut, o - s);
669
+ e.set(r.subarray(this.posOut, this.posOut + i), s), this.posOut += i, s += i;
651
670
  }
652
671
  return e;
653
672
  }
@@ -657,10 +676,10 @@ class $e extends kr {
657
676
  return this.writeInto(e);
658
677
  }
659
678
  xof(e) {
660
- return We(e), this.xofInto(new Uint8Array(e));
679
+ return je(e), this.xofInto(new Uint8Array(e));
661
680
  }
662
681
  digestInto(e) {
663
- if (wr(e, this), this.finished)
682
+ if (gr(e, this), this.finished)
664
683
  throw new Error("digest() was already called");
665
684
  return this.writeInto(e), this.destroy(), e;
666
685
  }
@@ -668,55 +687,55 @@ class $e extends kr {
668
687
  return this.digestInto(new Uint8Array(this.outputLen));
669
688
  }
670
689
  destroy() {
671
- this.destroyed = !0, it(this.state);
690
+ this.destroyed = !0, at(this.state);
672
691
  }
673
692
  _cloneInto(e) {
674
- const { blockLen: r, suffix: n, outputLen: s, rounds: o, enableXOF: a } = this;
675
- return e || (e = new $e(r, n, s, a, o)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = o, e.suffix = n, e.outputLen = s, e.enableXOF = a, e.destroyed = this.destroyed, e;
693
+ const { blockLen: r, suffix: n, outputLen: s, rounds: o, enableXOF: i } = this;
694
+ return e || (e = new Se(r, n, s, i, o)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = o, e.suffix = n, e.outputLen = s, e.enableXOF = i, e.destroyed = this.destroyed, e;
676
695
  }
677
696
  }
678
- const Lr = (t, e, r) => Ar(() => new $e(e, t, r)), Dr = Lr(1, 136, 256 / 8);
679
- let ft = !1;
680
- const ut = function(t) {
697
+ const Lr = (t, e, r) => Ar(() => new Se(e, t, r)), Dr = Lr(1, 136, 256 / 8);
698
+ let ut = !1;
699
+ const wt = function(t) {
681
700
  return Dr(t);
682
701
  };
683
- let gt = ut;
702
+ let gt = wt;
684
703
  function X(t) {
685
- const e = xe(t, "data");
704
+ const e = $e(t, "data");
686
705
  return ur(gt(e));
687
706
  }
688
- X._ = ut;
707
+ X._ = wt;
689
708
  X.lock = function() {
690
- ft = !0;
709
+ ut = !0;
691
710
  };
692
711
  X.register = function(t) {
693
- if (ft)
712
+ if (ut)
694
713
  throw new TypeError("keccak256 is locked");
695
714
  gt = t;
696
715
  };
697
716
  Object.freeze(X);
698
717
  const Or = BigInt(0), Mr = BigInt(36);
699
- function qe(t) {
718
+ function Ge(t) {
700
719
  t = t.toLowerCase();
701
720
  const e = t.substring(2).split(""), r = new Uint8Array(40);
702
721
  for (let s = 0; s < 40; s++)
703
722
  r[s] = e[s].charCodeAt(0);
704
- const n = xe(X(r));
723
+ const n = $e(X(r));
705
724
  for (let s = 0; s < 40; s += 2)
706
725
  n[s >> 1] >> 4 >= 8 && (e[s] = e[s].toUpperCase()), (n[s >> 1] & 15) >= 8 && (e[s + 1] = e[s + 1].toUpperCase());
707
726
  return "0x" + e.join("");
708
727
  }
709
- const Se = {};
728
+ const Ie = {};
710
729
  for (let t = 0; t < 10; t++)
711
- Se[String(t)] = String(t);
730
+ Ie[String(t)] = String(t);
712
731
  for (let t = 0; t < 26; t++)
713
- Se[String.fromCharCode(65 + t)] = String(10 + t);
714
- const Ge = 15;
732
+ Ie[String.fromCharCode(65 + t)] = String(10 + t);
733
+ const Xe = 15;
715
734
  function Qr(t) {
716
735
  t = t.toUpperCase(), t = t.substring(4) + t.substring(0, 2) + "00";
717
- let e = t.split("").map((n) => Se[n]).join("");
718
- for (; e.length >= Ge; ) {
719
- let n = e.substring(0, Ge);
736
+ let e = t.split("").map((n) => Ie[n]).join("");
737
+ for (; e.length >= Xe; ) {
738
+ let n = e.substring(0, Xe);
720
739
  e = parseInt(n, 10) % 97 + e.substring(n.length);
721
740
  }
722
741
  let r = String(98 - parseInt(e, 10) % 97);
@@ -742,7 +761,7 @@ function Wr(t) {
742
761
  function N(t) {
743
762
  if (Y(typeof t == "string", "invalid address", "address", t), t.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
744
763
  t.startsWith("0x") || (t = "0x" + t);
745
- const e = qe(t);
764
+ const e = Ge(t);
746
765
  return Y(!t.match(/([A-F].*[a-f])|([a-f].*[A-F])/) || e === t, "bad address checksum", "address", t), e;
747
766
  }
748
767
  if (t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
@@ -750,7 +769,7 @@ function N(t) {
750
769
  let e = Wr(t.substring(4)).toString(16);
751
770
  for (; e.length < 40; )
752
771
  e = "0" + e;
753
- return qe("0x" + e);
772
+ return Ge("0x" + e);
754
773
  }
755
774
  Y(!1, "invalid address", "address", t);
756
775
  }
@@ -925,7 +944,7 @@ function Hr() {
925
944
  }
926
945
  };
927
946
  }
928
- const Kr = {
947
+ const Vr = {
929
948
  "0x1": "ethereum",
930
949
  // ethereum mainnet
931
950
  "0xaa36a7": "ethereum",
@@ -942,13 +961,13 @@ const Kr = {
942
961
  // op mainnet
943
962
  "0xaa37dc": "optimism",
944
963
  // op sepolia
945
- [V.StarknetChainId.SN_MAIN]: "starknet",
946
- [V.StarknetChainId.SN_SEPOLIA]: "starknet"
964
+ [K.StarknetChainId.SN_MAIN]: "starknet",
965
+ [K.StarknetChainId.SN_SEPOLIA]: "starknet"
947
966
  }, fe = (t) => {
948
- const e = rt.toHex(t), r = Kr[e];
967
+ const e = nt.toHex(t), r = Vr[e];
949
968
  return r || console.warn(`Unknown chain ID: ${e}`), r;
950
969
  };
951
- class Ie {
970
+ class Ce {
952
971
  platform;
953
972
  account = void 0;
954
973
  store = Hr();
@@ -1182,17 +1201,17 @@ class Ie {
1182
1201
  throw new Error(`${this.displayName} is not connected`);
1183
1202
  const s = Date.now(), o = 1e3;
1184
1203
  for (; Date.now() - s < r; ) {
1185
- const a = await n.request({
1204
+ const i = await n.request({
1186
1205
  method: "eth_getTransactionReceipt",
1187
1206
  params: [e]
1188
1207
  });
1189
- if (a)
1208
+ if (i)
1190
1209
  return {
1191
1210
  success: !0,
1192
1211
  wallet: this.type,
1193
- result: a
1212
+ result: i
1194
1213
  };
1195
- await new Promise((i) => setTimeout(i, o));
1214
+ await new Promise((a) => setTimeout(a, o));
1196
1215
  }
1197
1216
  throw new Error("Transaction confirmation timed out");
1198
1217
  } catch (n) {
@@ -1207,27 +1226,27 @@ class Ie {
1207
1226
  }
1208
1227
  }
1209
1228
  }
1210
- class Vr extends Ie {
1229
+ class Kr extends Ce {
1211
1230
  type = "base";
1212
1231
  rdns = "com.coinbase.wallet";
1213
1232
  displayName = "Base Wallet";
1214
1233
  }
1215
- class qr extends Ie {
1234
+ class qr extends Ce {
1216
1235
  type = "metamask";
1217
1236
  rdns = "io.metamask";
1218
1237
  displayName = "MetaMask";
1219
1238
  }
1220
1239
  /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
1221
- function Ce(t) {
1240
+ function Pe(t) {
1222
1241
  return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
1223
1242
  }
1224
- function wt(t, ...e) {
1225
- if (!Ce(t))
1243
+ function pt(t, ...e) {
1244
+ if (!Pe(t))
1226
1245
  throw new Error("Uint8Array expected");
1227
1246
  if (e.length > 0 && !e.includes(t.length))
1228
1247
  throw new Error("Uint8Array expected of length " + e + ", got length=" + t.length);
1229
1248
  }
1230
- function pt(t, e) {
1249
+ function yt(t, e) {
1231
1250
  return Array.isArray(e) ? e.length === 0 ? !0 : t ? e.every((r) => typeof r == "string") : e.every((r) => Number.isSafeInteger(r)) : !1;
1232
1251
  }
1233
1252
  function Gr(t) {
@@ -1249,20 +1268,20 @@ function ne(t) {
1249
1268
  throw new Error("array expected");
1250
1269
  }
1251
1270
  function se(t, e) {
1252
- if (!pt(!0, e))
1271
+ if (!yt(!0, e))
1253
1272
  throw new Error(`${t}: array of strings expected`);
1254
1273
  }
1255
- function yt(t, e) {
1256
- if (!pt(!1, e))
1274
+ function mt(t, e) {
1275
+ if (!yt(!1, e))
1257
1276
  throw new Error(`${t}: array of numbers expected`);
1258
1277
  }
1259
1278
  // @__NO_SIDE_EFFECTS__
1260
- function Pe(...t) {
1261
- const e = (o) => o, r = (o, a) => (i) => o(a(i)), n = t.map((o) => o.encode).reduceRight(r, e), s = t.map((o) => o.decode).reduce(r, e);
1279
+ function Be(...t) {
1280
+ const e = (o) => o, r = (o, i) => (a) => o(i(a)), n = t.map((o) => o.encode).reduceRight(r, e), s = t.map((o) => o.decode).reduce(r, e);
1262
1281
  return { encode: n, decode: s };
1263
1282
  }
1264
1283
  // @__NO_SIDE_EFFECTS__
1265
- function Be(t) {
1284
+ function Ne(t) {
1266
1285
  const e = typeof t == "string" ? t.split("") : t, r = e.length;
1267
1286
  se("alphabet", e);
1268
1287
  const n = new Map(e.map((s, o) => [s, o]));
@@ -1274,15 +1293,15 @@ function Be(t) {
1274
1293
  })),
1275
1294
  decode: (s) => (ne(s), s.map((o) => {
1276
1295
  W("alphabet.decode", o);
1277
- const a = n.get(o);
1278
- if (a === void 0)
1296
+ const i = n.get(o);
1297
+ if (i === void 0)
1279
1298
  throw new Error(`Unknown letter: "${o}". Allowed: ${t}`);
1280
- return a;
1299
+ return i;
1281
1300
  }))
1282
1301
  };
1283
1302
  }
1284
1303
  // @__NO_SIDE_EFFECTS__
1285
- function Ne(t = "") {
1304
+ function Re(t = "") {
1286
1305
  return W("join", t), {
1287
1306
  encode: (e) => (se("join.decode", e), e.join(t)),
1288
1307
  decode: (e) => (W("join.decode", e), e.split(t))
@@ -1312,7 +1331,7 @@ function Xr(t, e = "=") {
1312
1331
  function Jr(t) {
1313
1332
  return Gr(t), { encode: (e) => e, decode: (e) => t(e) };
1314
1333
  }
1315
- function Xe(t, e, r) {
1334
+ function Je(t, e, r) {
1316
1335
  if (e < 2)
1317
1336
  throw new Error(`convertRadix: invalid from=${e}, base cannot be less than 2`);
1318
1337
  if (r < 2)
@@ -1320,40 +1339,40 @@ function Xe(t, e, r) {
1320
1339
  if (ne(t), !t.length)
1321
1340
  return [];
1322
1341
  let n = 0;
1323
- const s = [], o = Array.from(t, (i) => {
1324
- if (J(i), i < 0 || i >= e)
1325
- throw new Error(`invalid integer: ${i}`);
1326
- return i;
1327
- }), a = o.length;
1342
+ const s = [], o = Array.from(t, (a) => {
1343
+ if (J(a), a < 0 || a >= e)
1344
+ throw new Error(`invalid integer: ${a}`);
1345
+ return a;
1346
+ }), i = o.length;
1328
1347
  for (; ; ) {
1329
- let i = 0, l = !0;
1330
- for (let c = n; c < a; c++) {
1331
- const d = o[c], h = e * i, f = h + d;
1332
- if (!Number.isSafeInteger(f) || h / e !== i || f - d !== h)
1348
+ let a = 0, l = !0;
1349
+ for (let c = n; c < i; c++) {
1350
+ const d = o[c], h = e * a, f = h + d;
1351
+ if (!Number.isSafeInteger(f) || h / e !== a || f - d !== h)
1333
1352
  throw new Error("convertRadix: carry overflow");
1334
1353
  const u = f / r;
1335
- i = f % r;
1354
+ a = f % r;
1336
1355
  const w = Math.floor(u);
1337
- if (o[c] = w, !Number.isSafeInteger(w) || w * r + i !== f)
1356
+ if (o[c] = w, !Number.isSafeInteger(w) || w * r + a !== f)
1338
1357
  throw new Error("convertRadix: carry overflow");
1339
1358
  if (l)
1340
1359
  w ? l = !1 : n = c;
1341
1360
  else continue;
1342
1361
  }
1343
- if (s.push(i), l)
1362
+ if (s.push(a), l)
1344
1363
  break;
1345
1364
  }
1346
- for (let i = 0; i < t.length - 1 && t[i] === 0; i++)
1365
+ for (let a = 0; a < t.length - 1 && t[a] === 0; a++)
1347
1366
  s.push(0);
1348
1367
  return s.reverse();
1349
1368
  }
1350
- const mt = (t, e) => e === 0 ? t : mt(e, t % e), oe = /* @__NO_SIDE_EFFECTS__ */ (t, e) => t + (e - mt(t, e)), ue = /* @__PURE__ */ (() => {
1369
+ const bt = (t, e) => e === 0 ? t : bt(e, t % e), oe = /* @__NO_SIDE_EFFECTS__ */ (t, e) => t + (e - bt(t, e)), ue = /* @__PURE__ */ (() => {
1351
1370
  let t = [];
1352
1371
  for (let e = 0; e < 40; e++)
1353
1372
  t.push(2 ** e);
1354
1373
  return t;
1355
1374
  })();
1356
- function Je(t, e, r, n) {
1375
+ function Ze(t, e, r, n) {
1357
1376
  if (ne(t), e <= 0 || e > 32)
1358
1377
  throw new Error(`convertRadix2: wrong from=${e}`);
1359
1378
  if (r <= 0 || r > 32)
@@ -1361,20 +1380,20 @@ function Je(t, e, r, n) {
1361
1380
  if (/* @__PURE__ */ oe(e, r) > 32)
1362
1381
  throw new Error(`convertRadix2: carry overflow from=${e} to=${r} carryBits=${/* @__PURE__ */ oe(e, r)}`);
1363
1382
  let s = 0, o = 0;
1364
- const a = ue[e], i = ue[r] - 1, l = [];
1383
+ const i = ue[e], a = ue[r] - 1, l = [];
1365
1384
  for (const c of t) {
1366
- if (J(c), c >= a)
1385
+ if (J(c), c >= i)
1367
1386
  throw new Error(`convertRadix2: invalid data word=${c} from=${e}`);
1368
1387
  if (s = s << e | c, o + e > 32)
1369
1388
  throw new Error(`convertRadix2: carry overflow pos=${o} from=${e}`);
1370
1389
  for (o += e; o >= r; o -= r)
1371
- l.push((s >> o - r & i) >>> 0);
1390
+ l.push((s >> o - r & a) >>> 0);
1372
1391
  const d = ue[o];
1373
1392
  if (d === void 0)
1374
1393
  throw new Error("invalid carry");
1375
1394
  s &= d - 1;
1376
1395
  }
1377
- if (s = s << r - o & i, !n && o >= e)
1396
+ if (s = s << r - o & a, !n && o >= e)
1378
1397
  throw new Error("Excess padding");
1379
1398
  if (!n && s > 0)
1380
1399
  throw new Error(`Non-zero padding: ${s}`);
@@ -1386,51 +1405,51 @@ function Zr(t) {
1386
1405
  const e = 2 ** 8;
1387
1406
  return {
1388
1407
  encode: (r) => {
1389
- if (!Ce(r))
1408
+ if (!Pe(r))
1390
1409
  throw new Error("radix.encode input should be Uint8Array");
1391
- return Xe(Array.from(r), e, t);
1410
+ return Je(Array.from(r), e, t);
1392
1411
  },
1393
- decode: (r) => (yt("radix.decode", r), Uint8Array.from(Xe(r, t, e)))
1412
+ decode: (r) => (mt("radix.decode", r), Uint8Array.from(Je(r, t, e)))
1394
1413
  };
1395
1414
  }
1396
1415
  // @__NO_SIDE_EFFECTS__
1397
- function bt(t, e = !1) {
1416
+ function _t(t, e = !1) {
1398
1417
  if (J(t), t <= 0 || t > 32)
1399
1418
  throw new Error("radix2: bits should be in (0..32]");
1400
1419
  if (/* @__PURE__ */ oe(8, t) > 32 || /* @__PURE__ */ oe(t, 8) > 32)
1401
1420
  throw new Error("radix2: carry overflow");
1402
1421
  return {
1403
1422
  encode: (r) => {
1404
- if (!Ce(r))
1423
+ if (!Pe(r))
1405
1424
  throw new Error("radix2.encode input should be Uint8Array");
1406
- return Je(Array.from(r), 8, t, !e);
1425
+ return Ze(Array.from(r), 8, t, !e);
1407
1426
  },
1408
- decode: (r) => (yt("radix2.decode", r), Uint8Array.from(Je(r, t, 8, e)))
1427
+ decode: (r) => (mt("radix2.decode", r), Uint8Array.from(Ze(r, t, 8, e)))
1409
1428
  };
1410
1429
  }
1411
1430
  const en = typeof Uint8Array.from([]).toBase64 == "function" && typeof Uint8Array.fromBase64 == "function", tn = en ? {
1412
1431
  encode(t) {
1413
- return wt(t), t.toBase64();
1432
+ return pt(t), t.toBase64();
1414
1433
  },
1415
1434
  decode(t) {
1416
1435
  return W("base64", t), Uint8Array.fromBase64(t, { lastChunkHandling: "strict" });
1417
1436
  }
1418
- } : /* @__PURE__ */ Pe(/* @__PURE__ */ bt(6), /* @__PURE__ */ Be("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), /* @__PURE__ */ Xr(6), /* @__PURE__ */ Ne("")), rn = /* @__NO_SIDE_EFFECTS__ */ (t) => /* @__PURE__ */ Pe(/* @__PURE__ */ Zr(58), /* @__PURE__ */ Be(t), /* @__PURE__ */ Ne("")), _e = /* @__PURE__ */ rn("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"), nn = {
1437
+ } : /* @__PURE__ */ Be(/* @__PURE__ */ _t(6), /* @__PURE__ */ Ne("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), /* @__PURE__ */ Xr(6), /* @__PURE__ */ Re("")), rn = /* @__NO_SIDE_EFFECTS__ */ (t) => /* @__PURE__ */ Be(/* @__PURE__ */ Zr(58), /* @__PURE__ */ Ne(t), /* @__PURE__ */ Re("")), ke = /* @__PURE__ */ rn("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"), nn = {
1419
1438
  encode: (t) => new TextDecoder().decode(t),
1420
1439
  decode: (t) => new TextEncoder().encode(t)
1421
1440
  }, sn = typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", on = {
1422
1441
  encode(t) {
1423
- return wt(t), t.toHex();
1442
+ return pt(t), t.toHex();
1424
1443
  },
1425
1444
  decode(t) {
1426
1445
  return W("hex", t), Uint8Array.fromHex(t);
1427
1446
  }
1428
- }, ge = sn ? on : /* @__PURE__ */ Pe(/* @__PURE__ */ bt(4), /* @__PURE__ */ Be("0123456789abcdef"), /* @__PURE__ */ Ne(""), /* @__PURE__ */ Jr((t) => {
1447
+ }, we = sn ? on : /* @__PURE__ */ Be(/* @__PURE__ */ _t(4), /* @__PURE__ */ Ne("0123456789abcdef"), /* @__PURE__ */ Re(""), /* @__PURE__ */ Jr((t) => {
1429
1448
  if (typeof t != "string" || t.length % 2 !== 0)
1430
1449
  throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);
1431
1450
  return t.toLowerCase();
1432
1451
  }));
1433
- function ke(t, e) {
1452
+ function Ae(t, e) {
1434
1453
  if (t.length !== e.length)
1435
1454
  return !1;
1436
1455
  for (let r = 0; r < t.length; r++)
@@ -1441,14 +1460,14 @@ function ke(t, e) {
1441
1460
  function R(t) {
1442
1461
  return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
1443
1462
  }
1444
- const _t = (t) => new DataView(t.buffer, t.byteOffset, t.byteLength);
1463
+ const kt = (t) => new DataView(t.buffer, t.byteOffset, t.byteLength);
1445
1464
  function O(t) {
1446
1465
  return Object.prototype.toString.call(t) === "[object Object]";
1447
1466
  }
1448
1467
  function P(t) {
1449
1468
  return Number.isSafeInteger(t);
1450
1469
  }
1451
- const kt = (t) => {
1470
+ const At = (t) => {
1452
1471
  if (t !== null && typeof t != "string" && !S(t) && !R(t) && !P(t))
1453
1472
  throw new Error(`lengthCoder: expected null | number | Uint8Array | CoderType, got ${t} (${typeof t})`);
1454
1473
  return {
@@ -1493,16 +1512,16 @@ const kt = (t) => {
1493
1512
  }),
1494
1513
  indices: (t, e, r = !1) => {
1495
1514
  A.checkLen(t, e);
1496
- const { FULL_MASK: n, BITS: s } = A, o = s - e % s, a = o ? n >>> o << o : n, i = [];
1515
+ const { FULL_MASK: n, BITS: s } = A, o = s - e % s, i = o ? n >>> o << o : n, a = [];
1497
1516
  for (let l = 0; l < t.length; l++) {
1498
1517
  let c = t[l];
1499
- if (r && (c = ~c), l === t.length - 1 && (c &= a), c !== 0)
1518
+ if (r && (c = ~c), l === t.length - 1 && (c &= i), c !== 0)
1500
1519
  for (let d = 0; d < s; d++) {
1501
1520
  const h = 1 << s - d - 1;
1502
- c & h && i.push(l * s + d);
1521
+ c & h && a.push(l * s + d);
1503
1522
  }
1504
1523
  }
1505
- return i;
1524
+ return a;
1506
1525
  },
1507
1526
  range: (t) => {
1508
1527
  const e = [];
@@ -1514,16 +1533,16 @@ const kt = (t) => {
1514
1533
  rangeDebug: (t, e, r = !1) => `[${A.range(A.indices(t, e, r)).map((n) => `(${n.pos}/${n.length})`).join(", ")}]`,
1515
1534
  setRange: (t, e, r, n, s = !0) => {
1516
1535
  A.chunkLen(e, r, n);
1517
- const { FULL_MASK: o, BITS: a } = A, i = r % a ? Math.floor(r / a) : void 0, l = r + n, c = l % a ? Math.floor(l / a) : void 0;
1518
- if (i !== void 0 && i === c)
1519
- return A.set(t, i, o >>> a - n << a - n - r, s);
1520
- if (i !== void 0 && !A.set(t, i, o >>> r % a, s))
1536
+ const { FULL_MASK: o, BITS: i } = A, a = r % i ? Math.floor(r / i) : void 0, l = r + n, c = l % i ? Math.floor(l / i) : void 0;
1537
+ if (a !== void 0 && a === c)
1538
+ return A.set(t, a, o >>> i - n << i - n - r, s);
1539
+ if (a !== void 0 && !A.set(t, a, o >>> r % i, s))
1521
1540
  return !1;
1522
- const d = i !== void 0 ? i + 1 : r / a, h = c !== void 0 ? c : l / a;
1541
+ const d = a !== void 0 ? a + 1 : r / i, h = c !== void 0 ? c : l / i;
1523
1542
  for (let f = d; f < h; f++)
1524
1543
  if (!A.set(t, f, o, s))
1525
1544
  return !1;
1526
- return !(c !== void 0 && i !== c && !A.set(t, c, o << a - l % a, s));
1545
+ return !(c !== void 0 && a !== c && !A.set(t, c, o << i - l % i, s));
1527
1546
  }
1528
1547
  }, D = {
1529
1548
  /**
@@ -1551,7 +1570,7 @@ const kt = (t) => {
1551
1570
  return r instanceof Error && r.stack && (n.stack = r.stack), n;
1552
1571
  },
1553
1572
  resolve: (t, e) => {
1554
- const r = e.split("/"), n = t.map((a) => a.obj);
1573
+ const r = e.split("/"), n = t.map((i) => i.obj);
1555
1574
  let s = 0;
1556
1575
  for (; s < r.length && r[s] === ".."; s++)
1557
1576
  n.pop();
@@ -1564,9 +1583,9 @@ const kt = (t) => {
1564
1583
  return o;
1565
1584
  }
1566
1585
  };
1567
- class Re {
1586
+ class Ue {
1568
1587
  constructor(e, r = {}, n = [], s = void 0, o = 0) {
1569
- this.pos = 0, this.bitBuf = 0, this.bitPos = 0, this.data = e, this.opts = r, this.stack = n, this.parent = s, this.parentOffset = o, this.view = _t(e);
1588
+ this.pos = 0, this.bitBuf = 0, this.bitPos = 0, this.data = e, this.opts = r, this.stack = n, this.parent = s, this.parentOffset = o, this.view = kt(e);
1570
1589
  }
1571
1590
  /** Internal method for pointers. */
1572
1591
  _enablePointers() {
@@ -1605,17 +1624,17 @@ class Re {
1605
1624
  finish() {
1606
1625
  if (!this.opts.allowUnreadBytes) {
1607
1626
  if (this.bitPos)
1608
- throw this.err(`${this.bitPos} bits left after unpack: ${ge.encode(this.data.slice(this.pos))}`);
1627
+ throw this.err(`${this.bitPos} bits left after unpack: ${we.encode(this.data.slice(this.pos))}`);
1609
1628
  if (this.bs && !this.parent) {
1610
1629
  const e = A.indices(this.bs, this.data.length, !0);
1611
1630
  if (e.length) {
1612
- const r = A.range(e).map(({ pos: n, length: s }) => `(${n}/${s})[${ge.encode(this.data.subarray(n, n + s))}]`).join(", ");
1631
+ const r = A.range(e).map(({ pos: n, length: s }) => `(${n}/${s})[${we.encode(this.data.subarray(n, n + s))}]`).join(", ");
1613
1632
  throw this.err(`unread byte ranges: ${r} (total=${this.data.length})`);
1614
1633
  } else
1615
1634
  return;
1616
1635
  }
1617
1636
  if (!this.isEnd())
1618
- throw this.err(`${this.leftBytes} bytes ${this.bitPos} bits left after unpack: ${ge.encode(this.data.slice(this.pos))}`);
1637
+ throw this.err(`${this.leftBytes} bytes ${this.bitPos} bits left after unpack: ${we.encode(this.data.slice(this.pos))}`);
1619
1638
  }
1620
1639
  }
1621
1640
  // User methods
@@ -1625,7 +1644,7 @@ class Re {
1625
1644
  offsetReader(e) {
1626
1645
  if (e > this.data.length)
1627
1646
  throw this.err("offsetReader: Unexpected end of buffer");
1628
- return new Re(this.absBytes(e), this.opts, this.stack, this, e);
1647
+ return new Ue(this.absBytes(e), this.opts, this.stack, this, e);
1629
1648
  }
1630
1649
  bytes(e, r = !1) {
1631
1650
  if (this.bitPos)
@@ -1676,14 +1695,14 @@ class Re {
1676
1695
  for (let n = r; (n = this.data.indexOf(e[0], n)) !== -1; n++) {
1677
1696
  if (n === -1 || this.data.length - n < e.length)
1678
1697
  return;
1679
- if (ke(e, this.data.subarray(n, n + e.length)))
1698
+ if (Ae(e, this.data.subarray(n, n + e.length)))
1680
1699
  return n;
1681
1700
  }
1682
1701
  }
1683
1702
  }
1684
1703
  class an {
1685
1704
  constructor(e = []) {
1686
- this.pos = 0, this.buffers = [], this.ptrs = [], this.bitBuf = 0, this.bitPos = 0, this.viewBuf = new Uint8Array(8), this.finished = !1, this.stack = e, this.view = _t(this.viewBuf);
1705
+ this.pos = 0, this.buffers = [], this.ptrs = [], this.bitBuf = 0, this.bitPos = 0, this.viewBuf = new Uint8Array(8), this.finished = !1, this.stack = e, this.view = kt(this.viewBuf);
1687
1706
  }
1688
1707
  pushObj(e, r) {
1689
1708
  return D.pushObj(this.stack, e, r);
@@ -1720,14 +1739,14 @@ class an {
1720
1739
  throw this.err("buffer: finished");
1721
1740
  if (this.bitPos)
1722
1741
  throw this.err("buffer: ends with non-empty bit buffer");
1723
- const r = this.buffers.concat(this.ptrs.map((o) => o.buffer)), n = r.map((o) => o.length).reduce((o, a) => o + a, 0), s = new Uint8Array(n);
1724
- for (let o = 0, a = 0; o < r.length; o++) {
1725
- const i = r[o];
1726
- s.set(i, a), a += i.length;
1742
+ const r = this.buffers.concat(this.ptrs.map((o) => o.buffer)), n = r.map((o) => o.length).reduce((o, i) => o + i, 0), s = new Uint8Array(n);
1743
+ for (let o = 0, i = 0; o < r.length; o++) {
1744
+ const a = r[o];
1745
+ s.set(a, i), i += a.length;
1727
1746
  }
1728
- for (let o = this.pos, a = 0; a < this.ptrs.length; a++) {
1729
- const i = this.ptrs[a];
1730
- s.set(i.ptr.encode(o), i.pos), o += i.buffer.length;
1747
+ for (let o = this.pos, i = 0; i < this.ptrs.length; i++) {
1748
+ const a = this.ptrs[i];
1749
+ s.set(a.ptr.encode(o), a.pos), o += a.buffer.length;
1731
1750
  }
1732
1751
  if (e) {
1733
1752
  this.buffers = [];
@@ -1748,7 +1767,7 @@ class an {
1748
1767
  }
1749
1768
  }
1750
1769
  }
1751
- const Ae = (t) => Uint8Array.from(t).reverse();
1770
+ const Ee = (t) => Uint8Array.from(t).reverse();
1752
1771
  function cn(t, e, r) {
1753
1772
  if (r) {
1754
1773
  const n = 2n ** (e - 1n);
@@ -1757,7 +1776,7 @@ function cn(t, e, r) {
1757
1776
  } else if (0n > t || t >= 2n ** e)
1758
1777
  throw new Error(`value out of unsigned bounds. Expected 0 <= ${t} < ${2n ** e}`);
1759
1778
  }
1760
- function At(t) {
1779
+ function Et(t) {
1761
1780
  return {
1762
1781
  // NOTE: we cannot export validate here, since it is likely mistake.
1763
1782
  encodeStream: t.encodeStream,
@@ -1768,17 +1787,17 @@ function At(t) {
1768
1787
  return t.encodeStream(r, e), r.finish();
1769
1788
  },
1770
1789
  decode: (e, r = {}) => {
1771
- const n = new Re(e, r), s = t.decodeStream(n);
1790
+ const n = new Ue(e, r), s = t.decodeStream(n);
1772
1791
  return n.finish(), s;
1773
1792
  }
1774
1793
  };
1775
1794
  }
1776
- function Et(t, e) {
1795
+ function vt(t, e) {
1777
1796
  if (!S(t))
1778
1797
  throw new Error(`validate: invalid inner value ${t}`);
1779
1798
  if (typeof e != "function")
1780
1799
  throw new Error("validate: fn should be function");
1781
- return At({
1800
+ return Et({
1782
1801
  size: t.size,
1783
1802
  encodeStream: (r, n) => {
1784
1803
  let s;
@@ -1800,8 +1819,8 @@ function Et(t, e) {
1800
1819
  });
1801
1820
  }
1802
1821
  const x = (t) => {
1803
- const e = At(t);
1804
- return t.validate ? Et(e, t.validate) : e;
1822
+ const e = Et(t);
1823
+ return t.validate ? vt(e, t.validate) : e;
1805
1824
  }, ce = (t) => O(t) && typeof t.decode == "function" && typeof t.encode == "function";
1806
1825
  function S(t) {
1807
1826
  return O(t) && ce(t) && typeof t.encodeStream == "function" && typeof t.decodeStream == "function" && (t.size === void 0 || P(t.size));
@@ -1871,11 +1890,11 @@ function fn(t, e = !1) {
1871
1890
  throw new Error(`expected bigint, got ${typeof n}`);
1872
1891
  let s = (n < 0n ? -n : n).toString(10), o = s.length - t;
1873
1892
  o < 0 && (s = s.padStart(s.length - o, "0"), o = 0);
1874
- let a = s.length - 1;
1875
- for (; a >= o && s[a] === "0"; a--)
1893
+ let i = s.length - 1;
1894
+ for (; i >= o && s[i] === "0"; i--)
1876
1895
  ;
1877
- let i = s.slice(0, o), l = s.slice(o, a + 1);
1878
- return i || (i = "0"), n < 0n && (i = "-" + i), l ? `${i}.${l}` : i;
1896
+ let a = s.slice(0, o), l = s.slice(o, i + 1);
1897
+ return a || (a = "0"), n < 0n && (a = "-" + a), l ? `${a}.${l}` : a;
1879
1898
  },
1880
1899
  decode: (n) => {
1881
1900
  if (typeof n != "string")
@@ -1887,10 +1906,10 @@ function fn(t, e = !1) {
1887
1906
  throw new Error(`wrong string value=${n}`);
1888
1907
  let o = n.indexOf(".");
1889
1908
  o = o === -1 ? n.length : o;
1890
- const a = n.slice(0, o), i = n.slice(o + 1).replace(/0+$/, ""), l = BigInt(a) * r;
1891
- if (!e && i.length > t)
1909
+ const i = n.slice(0, o), a = n.slice(o + 1).replace(/0+$/, ""), l = BigInt(i) * r;
1910
+ if (!e && a.length > t)
1892
1911
  throw new Error(`fractional part cannot be represented with this precision (num=${n}, prec=${t})`);
1893
- const c = Math.min(i.length, t), d = BigInt(i.slice(0, c)) * 10n ** BigInt(t - c), h = l + d;
1912
+ const c = Math.min(a.length, t), d = BigInt(a.slice(0, c)) * 10n ** BigInt(t - c), h = l + d;
1894
1913
  return s ? -h : h;
1895
1914
  }
1896
1915
  };
@@ -1920,11 +1939,11 @@ function un(t) {
1920
1939
  }
1921
1940
  };
1922
1941
  }
1923
- const gn = (t) => {
1942
+ const wn = (t) => {
1924
1943
  if (!ce(t))
1925
1944
  throw new Error("BaseCoder expected");
1926
1945
  return { encode: t.decode, decode: t.encode };
1927
- }, H = { dict: ln, numberBigint: dn, tsEnum: hn, decimal: fn, match: un, reverse: gn }, wn = (t, e = !1, r = !1, n = !0) => {
1946
+ }, H = { dict: ln, numberBigint: dn, tsEnum: hn, decimal: fn, match: un, reverse: wn }, gn = (t, e = !1, r = !1, n = !0) => {
1928
1947
  if (!P(t))
1929
1948
  throw new Error(`bigint/size: wrong value ${t}`);
1930
1949
  if (typeof e != "boolean")
@@ -1936,11 +1955,11 @@ const gn = (t) => {
1936
1955
  const s = BigInt(t), o = 2n ** (8n * s - 1n);
1937
1956
  return x({
1938
1957
  size: n ? t : void 0,
1939
- encodeStream: (a, i) => {
1940
- r && i < 0 && (i = i | o);
1958
+ encodeStream: (i, a) => {
1959
+ r && a < 0 && (a = a | o);
1941
1960
  const l = [];
1942
1961
  for (let d = 0; d < t; d++)
1943
- l.push(Number(i & 255n)), i >>= 8n;
1962
+ l.push(Number(a & 255n)), a >>= 8n;
1944
1963
  let c = new Uint8Array(l).reverse();
1945
1964
  if (!n) {
1946
1965
  let d = 0;
@@ -1948,22 +1967,22 @@ const gn = (t) => {
1948
1967
  ;
1949
1968
  c = c.subarray(d);
1950
1969
  }
1951
- a.bytes(e ? c.reverse() : c);
1970
+ i.bytes(e ? c.reverse() : c);
1952
1971
  },
1953
- decodeStream: (a) => {
1954
- const i = a.bytes(n ? t : Math.min(t, a.leftBytes)), l = e ? i : Ae(i);
1972
+ decodeStream: (i) => {
1973
+ const a = i.bytes(n ? t : Math.min(t, i.leftBytes)), l = e ? a : Ee(a);
1955
1974
  let c = 0n;
1956
1975
  for (let d = 0; d < l.length; d++)
1957
1976
  c |= BigInt(l[d]) << 8n * BigInt(d);
1958
1977
  return r && c & o && (c = (c ^ o) - o), c;
1959
1978
  },
1960
- validate: (a) => {
1961
- if (typeof a != "bigint")
1962
- throw new Error(`bigint: invalid value: ${a}`);
1963
- return cn(a, 8n * s, !!r), a;
1979
+ validate: (i) => {
1980
+ if (typeof i != "bigint")
1981
+ throw new Error(`bigint: invalid value: ${i}`);
1982
+ return cn(i, 8n * s, !!r), i;
1964
1983
  }
1965
1984
  });
1966
- }, b = /* @__PURE__ */ wn(8, !0), pn = (t, e) => x({
1985
+ }, b = /* @__PURE__ */ gn(8, !0), pn = (t, e) => x({
1967
1986
  size: t,
1968
1987
  encodeStream: (r, n) => r.writeView(t, (s) => e.write(s, n)),
1969
1988
  decodeStream: (r) => r.readView(t, e.read),
@@ -1972,30 +1991,30 @@ const gn = (t) => {
1972
1991
  throw new Error(`viewCoder: expected number, got ${typeof r}`);
1973
1992
  return e.validate && e.validate(r), r;
1974
1993
  }
1975
- }), vt = (t, e, r) => {
1994
+ }), xt = (t, e, r) => {
1976
1995
  const n = t * 8, s = 2 ** (n - 1), o = (l) => {
1977
1996
  if (!P(l))
1978
1997
  throw new Error(`sintView: value is not safe integer: ${l}`);
1979
1998
  if (l < -s || l >= s)
1980
1999
  throw new Error(`sintView: value out of bounds. Expected ${-s} <= ${l} < ${s}`);
1981
- }, a = 2 ** n, i = (l) => {
2000
+ }, i = 2 ** n, a = (l) => {
1982
2001
  if (!P(l))
1983
2002
  throw new Error(`uintView: value is not safe integer: ${l}`);
1984
- if (0 > l || l >= a)
1985
- throw new Error(`uintView: value out of bounds. Expected 0 <= ${l} < ${a}`);
2003
+ if (0 > l || l >= i)
2004
+ throw new Error(`uintView: value out of bounds. Expected 0 <= ${l} < ${i}`);
1986
2005
  };
1987
2006
  return pn(t, {
1988
2007
  write: r.write,
1989
2008
  read: r.read,
1990
- validate: e ? o : i
2009
+ validate: e ? o : a
1991
2010
  });
1992
- }, ie = /* @__PURE__ */ vt(4, !1, {
2011
+ }, ie = /* @__PURE__ */ xt(4, !1, {
1993
2012
  read: (t, e) => t.getUint32(e, !0),
1994
2013
  write: (t, e) => t.setUint32(0, e, !0)
1995
- }), $ = /* @__PURE__ */ vt(1, !1, {
2014
+ }), $ = /* @__PURE__ */ xt(1, !1, {
1996
2015
  read: (t, e) => t.getUint8(e),
1997
2016
  write: (t, e) => t.setUint8(0, e)
1998
- }), Ee = /* @__PURE__ */ x({
2017
+ }), ve = /* @__PURE__ */ x({
1999
2018
  size: 1,
2000
2019
  encodeStream: (t, e) => t.byte(e ? 1 : 0),
2001
2020
  decodeStream: (t) => {
@@ -2012,22 +2031,22 @@ const gn = (t) => {
2012
2031
  }), le = (t, e = !1) => {
2013
2032
  if (typeof e != "boolean")
2014
2033
  throw new Error(`bytes/le: expected boolean, got ${typeof e}`);
2015
- const r = kt(t), n = R(t);
2034
+ const r = At(t), n = R(t);
2016
2035
  return x({
2017
2036
  size: typeof t == "number" ? t : void 0,
2018
2037
  encodeStream: (s, o) => {
2019
- n || r.encodeStream(s, o.length), s.bytes(e ? Ae(o) : o), n && s.bytes(t);
2038
+ n || r.encodeStream(s, o.length), s.bytes(e ? Ee(o) : o), n && s.bytes(t);
2020
2039
  },
2021
2040
  decodeStream: (s) => {
2022
2041
  let o;
2023
2042
  if (n) {
2024
- const a = s.find(t);
2025
- if (!a)
2043
+ const i = s.find(t);
2044
+ if (!i)
2026
2045
  throw s.err("bytes: cannot find terminator");
2027
- o = s.bytes(a - s.pos), s.bytes(t.length);
2046
+ o = s.bytes(i - s.pos), s.bytes(t.length);
2028
2047
  } else
2029
2048
  o = s.bytes(t === null ? s.leftBytes : r.decodeStream(s));
2030
- return e ? Ae(o) : o;
2049
+ return e ? Ee(o) : o;
2031
2050
  },
2032
2051
  validate: (s) => {
2033
2052
  if (!R(s))
@@ -2035,7 +2054,7 @@ const gn = (t) => {
2035
2054
  return s;
2036
2055
  }
2037
2056
  });
2038
- }, yn = (t, e = !1) => Et(mn(le(t, e), nn), (r) => {
2057
+ }, yn = (t, e = !1) => vt(mn(le(t, e), nn), (r) => {
2039
2058
  if (typeof r != "string")
2040
2059
  throw new Error(`expected string, got ${typeof r}`);
2041
2060
  return r;
@@ -2132,21 +2151,21 @@ function g(t) {
2132
2151
  function te(t, e) {
2133
2152
  if (!S(e))
2134
2153
  throw new Error(`array: invalid inner value ${e}`);
2135
- const r = kt(typeof t == "string" ? `../${t}` : t);
2154
+ const r = At(typeof t == "string" ? `../${t}` : t);
2136
2155
  return x({
2137
2156
  size: typeof t == "number" && e.size ? t * e.size : void 0,
2138
2157
  encodeStream: (n, s) => {
2139
2158
  const o = n;
2140
- o.pushObj(s, (a) => {
2159
+ o.pushObj(s, (i) => {
2141
2160
  R(t) || r.encodeStream(n, s.length);
2142
- for (let i = 0; i < s.length; i++)
2143
- a(`${i}`, () => {
2144
- const l = s[i], c = n.pos;
2161
+ for (let a = 0; a < s.length; a++)
2162
+ i(`${a}`, () => {
2163
+ const l = s[a], c = n.pos;
2145
2164
  if (e.encodeStream(n, l), R(t)) {
2146
2165
  if (t.length > o.pos - c)
2147
2166
  return;
2148
2167
  const d = o.finish(!1).subarray(c, o.pos);
2149
- if (ke(d.subarray(0, t.length), t))
2168
+ if (Ae(d.subarray(0, t.length), t))
2150
2169
  throw o.err(`array: inner element encoding same as separator. elm=${l} data=${d}`);
2151
2170
  }
2152
2171
  });
@@ -2156,21 +2175,21 @@ function te(t, e) {
2156
2175
  const s = [];
2157
2176
  return n.pushObj(s, (o) => {
2158
2177
  if (t === null)
2159
- for (let a = 0; !n.isEnd() && (o(`${a}`, () => s.push(e.decodeStream(n))), !(e.size && n.leftBytes < e.size)); a++)
2178
+ for (let i = 0; !n.isEnd() && (o(`${i}`, () => s.push(e.decodeStream(n))), !(e.size && n.leftBytes < e.size)); i++)
2160
2179
  ;
2161
2180
  else if (R(t))
2162
- for (let a = 0; ; a++) {
2163
- if (ke(n.bytes(t.length, !0), t)) {
2181
+ for (let i = 0; ; i++) {
2182
+ if (Ae(n.bytes(t.length, !0), t)) {
2164
2183
  n.bytes(t.length);
2165
2184
  break;
2166
2185
  }
2167
- o(`${a}`, () => s.push(e.decodeStream(n)));
2186
+ o(`${i}`, () => s.push(e.decodeStream(n)));
2168
2187
  }
2169
2188
  else {
2170
- let a;
2171
- o("arrayLen", () => a = r.decodeStream(n));
2172
- for (let i = 0; i < a; i++)
2173
- o(`${i}`, () => s.push(e.decodeStream(n)));
2189
+ let i;
2190
+ o("arrayLen", () => i = r.decodeStream(n));
2191
+ for (let a = 0; a < i; a++)
2192
+ o(`${a}`, () => s.push(e.decodeStream(n)));
2174
2193
  }
2175
2194
  }), s;
2176
2195
  },
@@ -2218,8 +2237,8 @@ function kn(t, e) {
2218
2237
  return x({
2219
2238
  size: t.size,
2220
2239
  encodeStream: (r, n) => {
2221
- const { TAG: s, data: o } = n, a = e[s];
2222
- t.encodeStream(r, s), a.encodeStream(r, o);
2240
+ const { TAG: s, data: o } = n, i = e[s];
2241
+ t.encodeStream(r, s), i.encodeStream(r, o);
2223
2242
  },
2224
2243
  decodeStream: (r) => {
2225
2244
  const n = t.decodeStream(r), s = e[n];
@@ -2236,10 +2255,10 @@ function kn(t, e) {
2236
2255
  });
2237
2256
  }
2238
2257
  const An = (t) => 0;
2239
- function we(t, e) {
2258
+ function ge(t, e) {
2240
2259
  return e % t === 0 ? 0 : t - e % t;
2241
2260
  }
2242
- function xt(t, e, r) {
2261
+ function $t(t, e, r) {
2243
2262
  if (!S(e))
2244
2263
  throw new Error(`padRight: invalid inner value ${e}`);
2245
2264
  if (!P(t) || t <= 0)
@@ -2248,21 +2267,21 @@ function xt(t, e, r) {
2248
2267
  throw new Error(`padRight: wrong padFn=${typeof r}`);
2249
2268
  const n = r || An;
2250
2269
  return x({
2251
- size: e.size ? e.size + we(t, e.size) : void 0,
2270
+ size: e.size ? e.size + ge(t, e.size) : void 0,
2252
2271
  encodeStream: (s, o) => {
2253
- const a = s, i = a.pos;
2272
+ const i = s, a = i.pos;
2254
2273
  e.encodeStream(s, o);
2255
- const l = we(t, a.pos - i);
2274
+ const l = ge(t, i.pos - a);
2256
2275
  for (let c = 0; c < l; c++)
2257
2276
  s.byte(n(c));
2258
2277
  },
2259
2278
  decodeStream: (s) => {
2260
- const o = s.pos, a = e.decodeStream(s);
2261
- return s.bytes(we(t, s.pos - o)), a;
2279
+ const o = s.pos, i = e.decodeStream(s);
2280
+ return s.bytes(ge(t, s.pos - o)), i;
2262
2281
  }
2263
2282
  });
2264
2283
  }
2265
- const En = 9, pe = H.decimal(En), K = x({
2284
+ const En = 9, pe = H.decimal(En), V = x({
2266
2285
  encodeStream: (t, e) => {
2267
2286
  if (!e)
2268
2287
  return t.byte(0);
@@ -2278,32 +2297,32 @@ const En = 9, pe = H.decimal(En), K = x({
2278
2297
  }
2279
2298
  return e;
2280
2299
  }
2281
- }), ee = yn(xt(8, ie, void 0)), vn = () => {
2300
+ }), ee = yn($t(8, ie, void 0)), vn = () => {
2282
2301
  const t = le(32);
2283
2302
  return x({
2284
2303
  size: t.size,
2285
- encodeStream: (e, r) => t.encodeStream(e, _e.decode(r)),
2286
- decodeStream: (e) => _e.encode(t.decodeStream(e))
2304
+ encodeStream: (e, r) => t.encodeStream(e, ke.decode(r)),
2305
+ decodeStream: (e) => ke.encode(t.decodeStream(e))
2287
2306
  });
2288
2307
  }, y = vn(), xn = g({
2289
2308
  requiredSignatures: $,
2290
2309
  readSigned: $,
2291
2310
  readUnsigned: $,
2292
- keys: te(K, y),
2311
+ keys: te(V, y),
2293
2312
  blockhash: y,
2294
- instructions: te(K, g({ programIdx: $, keys: te(K, $), data: le(K) }))
2313
+ instructions: te(V, g({ programIdx: $, keys: te(V, $), data: le(V) }))
2295
2314
  });
2296
2315
  function $n(t) {
2297
- if (_e.decode(t).length !== 32)
2316
+ if (ke.decode(t).length !== 32)
2298
2317
  throw new Error("Invalid Solana address");
2299
2318
  }
2300
2319
  const Sn = (t, e, r, n, s) => ({
2301
2320
  sign: t < e,
2302
2321
  write: t < e - r || t >= e && t < s - n
2303
- }), Ze = g({
2304
- signatures: te(K, le(64)),
2322
+ }), et = g({
2323
+ signatures: te(V, le(64)),
2305
2324
  msg: xn
2306
- }), ve = x({
2325
+ }), xe = x({
2307
2326
  encodeStream: (t, e) => {
2308
2327
  const { msg: r, signatures: n } = e, s = {}, o = (h, f, u) => {
2309
2328
  let w = s[h] || (s[h] = { sign: !1, write: !1 });
@@ -2315,27 +2334,27 @@ const Sn = (t, e, r, n, s) => ({
2315
2334
  o(f.address, f.sign, f.write);
2316
2335
  for (let h of r.instructions)
2317
2336
  o(h.program, !1, !1);
2318
- const a = Object.keys(s), i = [
2337
+ const i = Object.keys(s), a = [
2319
2338
  r.feePayer,
2320
- ...a.filter((h) => s[h].sign && s[h].write && h !== r.feePayer),
2321
- ...a.filter((h) => s[h].sign && !s[h].write),
2322
- ...a.filter((h) => !s[h].sign && s[h].write),
2323
- ...a.filter((h) => !s[h].sign && !s[h].write)
2339
+ ...i.filter((h) => s[h].sign && s[h].write && h !== r.feePayer),
2340
+ ...i.filter((h) => s[h].sign && !s[h].write),
2341
+ ...i.filter((h) => !s[h].sign && s[h].write),
2342
+ ...i.filter((h) => !s[h].sign && !s[h].write)
2324
2343
  ];
2325
2344
  let l = 0, c = 0, d = 0;
2326
- for (let h of i)
2345
+ for (let h of a)
2327
2346
  s[h].sign && l++, !s[h].write && (s[h].sign ? c++ : d++);
2328
- Ze.encodeStream(t, {
2329
- signatures: i.filter((h) => s[h].sign).map((h) => n[h] || new Uint8Array(64)),
2347
+ et.encodeStream(t, {
2348
+ signatures: a.filter((h) => s[h].sign).map((h) => n[h] || new Uint8Array(64)),
2330
2349
  msg: {
2331
2350
  requiredSignatures: l,
2332
2351
  readSigned: c,
2333
2352
  readUnsigned: d,
2334
- keys: i,
2353
+ keys: a,
2335
2354
  // indexOf potentially can be slow, but for most tx there will be ~3-5 keys, so doesn't matter much
2336
2355
  instructions: r.instructions.map((h) => ({
2337
- programIdx: i.indexOf(h.program),
2338
- keys: h.keys.map((f) => i.indexOf(f.address)),
2356
+ programIdx: a.indexOf(h.program),
2357
+ keys: h.keys.map((f) => a.indexOf(f.address)),
2339
2358
  data: h.data
2340
2359
  })),
2341
2360
  blockhash: r.blockhash
@@ -2343,7 +2362,7 @@ const Sn = (t, e, r, n, s) => ({
2343
2362
  });
2344
2363
  },
2345
2364
  decodeStream: (t) => {
2346
- const { signatures: e, msg: r } = Ze.decodeStream(t);
2365
+ const { signatures: e, msg: r } = et.decodeStream(t);
2347
2366
  if (e.length !== r.requiredSignatures)
2348
2367
  throw new Error("SOL.tx: wrong signatures length");
2349
2368
  if (r.keys.length < e.length)
@@ -2365,48 +2384,48 @@ const Sn = (t, e, r, n, s) => ({
2365
2384
  blockhash: r.blockhash,
2366
2385
  instructions: r.instructions.map((o) => ({
2367
2386
  program: s[o.programIdx].address,
2368
- keys: o.keys.map((a) => s[a]),
2387
+ keys: o.keys.map((i) => s[i]),
2369
2388
  data: o.data
2370
2389
  }))
2371
2390
  },
2372
2391
  signatures: n
2373
2392
  };
2374
2393
  }
2375
- }), et = {};
2376
- function Ue(t, e, r) {
2377
- if (et[t])
2394
+ }), tt = {};
2395
+ function ze(t, e, r) {
2396
+ if (tt[t])
2378
2397
  throw new Error("SOL: program for this address already defined");
2379
- const n = Te(e, Object.keys(r).reduce((i, l, c) => ({ ...i, [l]: c }), {})), s = Object.keys(r).reduce((i, l) => ({ ...i, [l]: r[l].coder }), {}), o = kn(n, s);
2380
- et[t] = (i, l) => {
2381
- if (i.program !== t)
2398
+ const n = Te(e, Object.keys(r).reduce((a, l, c) => ({ ...a, [l]: c }), {})), s = Object.keys(r).reduce((a, l) => ({ ...a, [l]: r[l].coder }), {}), o = kn(n, s);
2399
+ tt[t] = (a, l) => {
2400
+ if (a.program !== t)
2382
2401
  throw new Error("SOL.parseInstruction: Wrong instruction program address");
2383
- const { TAG: c, data: d } = o.decode(i.data), h = { type: c, info: d }, f = Object.keys(r[c].keys);
2384
- if (f.length !== i.keys.length)
2402
+ const { TAG: c, data: d } = o.decode(a.data), h = { type: c, info: d }, f = Object.keys(r[c].keys);
2403
+ if (f.length !== a.keys.length)
2385
2404
  throw new Error("SOL.parseInstruction: Keys length mismatch");
2386
2405
  for (let u = 0; u < f.length; u++) {
2387
2406
  const w = f[u];
2388
2407
  if (r[c].keys[w].address) {
2389
- if (r[c].keys[w].address !== i.keys[u].address)
2390
- throw new Error(`SOL.parseInstruction(${t}/${c}): Invalid constant address for key exp=${r[c].keys[w].address} got=${i.keys[u].address}`);
2408
+ if (r[c].keys[w].address !== a.keys[u].address)
2409
+ throw new Error(`SOL.parseInstruction(${t}/${c}): Invalid constant address for key exp=${r[c].keys[w].address} got=${a.keys[u].address}`);
2391
2410
  continue;
2392
2411
  }
2393
- h.info[f[u]] = i.keys[u].address;
2412
+ h.info[f[u]] = a.keys[u].address;
2394
2413
  }
2395
2414
  return r[c].hint && (h.hint = r[c].hint(d, l)), h;
2396
2415
  };
2397
- const a = {};
2398
- for (const i in r)
2399
- a[i] = (l) => ({
2416
+ const i = {};
2417
+ for (const a in r)
2418
+ i[a] = (l) => ({
2400
2419
  program: t,
2401
- data: o.encode({ TAG: i, data: l }),
2402
- keys: Object.keys(r[i].keys).map((c) => {
2403
- let { sign: d, write: h, address: f } = r[i].keys[c];
2420
+ data: o.encode({ TAG: a, data: l }),
2421
+ keys: Object.keys(r[a].keys).map((c) => {
2422
+ let { sign: d, write: h, address: f } = r[a].keys[c];
2404
2423
  return f || (f = l[c]), $n(f), { address: f, sign: d, write: h };
2405
2424
  })
2406
2425
  });
2407
- return a;
2426
+ return i;
2408
2427
  }
2409
- const ye = "SysvarRecentB1ockHashes11111111111111111111", L = "SysvarRent111111111111111111111111111111111", $t = "11111111111111111111111111111111", St = Ue($t, ie, {
2428
+ const ye = "SysvarRecentB1ockHashes11111111111111111111", L = "SysvarRent111111111111111111111111111111111", St = "11111111111111111111111111111111", It = ze(St, ie, {
2410
2429
  createAccount: {
2411
2430
  coder: g({ lamports: b, space: b, owner: y }),
2412
2431
  keys: {
@@ -2516,22 +2535,22 @@ const ye = "SysvarRecentB1ockHashes11111111111111111111", L = "SysvarRent1111111
2516
2535
  destination: { sign: !1, write: !0 }
2517
2536
  }
2518
2537
  }
2519
- }), It = (t) => {
2538
+ }), Ct = (t) => {
2520
2539
  };
2521
- It(St.transfer);
2522
- It(St.advanceNonce);
2540
+ Ct(It.transfer);
2541
+ Ct(It.advanceNonce);
2523
2542
  const In = Te($, {
2524
2543
  MintTokens: 0,
2525
2544
  FreezeAccount: 1,
2526
2545
  AccountOwner: 2,
2527
2546
  CloseAccount: 3
2528
- }), U = (t, e) => e[t]?.symbol || t, Ct = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
2529
- Ue(Ct, $, {
2547
+ }), T = (t, e) => e[t]?.symbol || t, Pt = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
2548
+ ze(Pt, $, {
2530
2549
  initializeMint: {
2531
2550
  coder: g({
2532
2551
  decimals: $,
2533
2552
  mintAuthority: y,
2534
- freezeAuthority: q(Ee, y, "11111111111111111111111111111111")
2553
+ freezeAuthority: q(ve, y, "11111111111111111111111111111111")
2535
2554
  }),
2536
2555
  keys: {
2537
2556
  mint: { sign: !1, write: !0 },
@@ -2546,7 +2565,7 @@ Ue(Ct, $, {
2546
2565
  owner: { sign: !1, write: !1 },
2547
2566
  _rent: { address: L, sign: !1, write: !1 }
2548
2567
  },
2549
- hint: (t, e) => `Initialize token account=${t.account} with owner=${t.owner} token=${U(t.mint, e)}`
2568
+ hint: (t, e) => `Initialize token account=${t.account} with owner=${t.owner} token=${T(t.mint, e)}`
2550
2569
  },
2551
2570
  // TODO: multisig support?
2552
2571
  initializeMultisig: {
@@ -2586,7 +2605,7 @@ Ue(Ct, $, {
2586
2605
  setAuthority: {
2587
2606
  coder: g({
2588
2607
  authorityType: In,
2589
- newAuthority: q(Ee, y, "11111111111111111111111111111111")
2608
+ newAuthority: q(ve, y, "11111111111111111111111111111111")
2590
2609
  }),
2591
2610
  keys: {
2592
2611
  account: { sign: !1, write: !0 },
@@ -2646,7 +2665,7 @@ Ue(Ct, $, {
2646
2665
  destination: { sign: !1, write: !0 },
2647
2666
  owner: { sign: !0, write: !1 }
2648
2667
  },
2649
- hint: (t, e) => `Transfer ${H.decimal(t.decimals).encode(t.amount)} ${U(t.mint, e)} from token account=${t.source} of owner=${t.owner} to ${t.destination}`
2668
+ hint: (t, e) => `Transfer ${H.decimal(t.decimals).encode(t.amount)} ${T(t.mint, e)} from token account=${t.source} of owner=${t.owner} to ${t.destination}`
2650
2669
  },
2651
2670
  approveChecked: {
2652
2671
  coder: g({ amount: b, decimals: $ }),
@@ -2656,7 +2675,7 @@ Ue(Ct, $, {
2656
2675
  delegate: { sign: !1, write: !1 },
2657
2676
  owner: { sign: !0, write: !1 }
2658
2677
  },
2659
- hint: (t, e) => `Approve delgate=${t.delegate} authority on behalf account=${t.source} owner=${t.owner} over ${H.decimal(t.decimals).encode(t.amount)} ${U(t.mint, e)}`
2678
+ hint: (t, e) => `Approve delgate=${t.delegate} authority on behalf account=${t.source} owner=${t.owner} over ${H.decimal(t.decimals).encode(t.amount)} ${T(t.mint, e)}`
2660
2679
  },
2661
2680
  mintToChecked: {
2662
2681
  coder: g({ amount: b, decimals: $ }),
@@ -2665,7 +2684,7 @@ Ue(Ct, $, {
2665
2684
  dest: { sign: !1, write: !0 },
2666
2685
  authority: { sign: !0, write: !1 }
2667
2686
  },
2668
- hint: (t, e) => `Mint new tokens (${H.decimal(t.decimals).encode(t.amount)} ${U(t.mint, e)}) to account=${t.dest} using authority=${t.authority}`
2687
+ hint: (t, e) => `Mint new tokens (${H.decimal(t.decimals).encode(t.amount)} ${T(t.mint, e)}) to account=${t.dest} using authority=${t.authority}`
2669
2688
  },
2670
2689
  burnChecked: {
2671
2690
  coder: g({ amount: b, decimals: $ }),
@@ -2674,7 +2693,7 @@ Ue(Ct, $, {
2674
2693
  account: { sign: !1, write: !0 },
2675
2694
  owner: { sign: !0, write: !1 }
2676
2695
  },
2677
- hint: (t, e) => `Burn tokens (${H.decimal(t.decimals).encode(t.amount)} ${U(t.mint, e)}) on account=${t.account} of owner=${t.owner}`
2696
+ hint: (t, e) => `Burn tokens (${H.decimal(t.decimals).encode(t.amount)} ${T(t.mint, e)}) on account=${t.account} of owner=${t.owner}`
2678
2697
  },
2679
2698
  initializeAccount2: {
2680
2699
  coder: g({ owner: y }),
@@ -2683,7 +2702,7 @@ Ue(Ct, $, {
2683
2702
  mint: { sign: !1, write: !1 },
2684
2703
  _rent: { address: L, sign: !1, write: !1 }
2685
2704
  },
2686
- hint: (t, e) => `Initialize token account=${t.account} with owner=${t.owner} token=${U(t.mint, e)}`
2705
+ hint: (t, e) => `Initialize token account=${t.account} with owner=${t.owner} token=${T(t.mint, e)}`
2687
2706
  },
2688
2707
  syncNative: {
2689
2708
  coder: g({}),
@@ -2699,7 +2718,7 @@ g({
2699
2718
  lamportPerSignature: b
2700
2719
  });
2701
2720
  const Cn = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
2702
- Ue(Cn, bn(0), {
2721
+ ze(Cn, bn(0), {
2703
2722
  create: {
2704
2723
  coder: g({}),
2705
2724
  keys: {
@@ -2707,14 +2726,14 @@ Ue(Cn, bn(0), {
2707
2726
  account: { sign: !1, write: !0 },
2708
2727
  wallet: { sign: !1, write: !1 },
2709
2728
  mint: { sign: !1, write: !1 },
2710
- _sys: { address: $t, sign: !1, write: !1 },
2711
- _token: { address: Ct, sign: !1, write: !1 },
2729
+ _sys: { address: St, sign: !1, write: !1 },
2730
+ _token: { address: Pt, sign: !1, write: !1 },
2712
2731
  _rent: { address: L, sign: !1, write: !1 }
2713
2732
  },
2714
- hint: (t, e) => `Initialize associated token account=${t.account} with owner=${t.wallet} for token=${U(t.mint, e)}, payed by ${t.source}`
2733
+ hint: (t, e) => `Initialize associated token account=${t.account} with owner=${t.wallet} for token=${T(t.mint, e)}, payed by ${t.source}`
2715
2734
  }
2716
2735
  });
2717
- const me = xt(4, Ee, () => 0);
2736
+ const me = $t(4, ve, () => 0);
2718
2737
  g({
2719
2738
  mint: y,
2720
2739
  owner: y,
@@ -2729,10 +2748,10 @@ g({
2729
2748
  delegateAmount: b,
2730
2749
  closeAuthority: q(me, y, "11111111111111111111111111111111")
2731
2750
  });
2732
- function tt(t, e, r) {
2751
+ function rt(t, e, r) {
2733
2752
  if (!e.length)
2734
2753
  throw new Error("SOLPublic: empty instructions array");
2735
- return tn.encode(ve.encode({
2754
+ return tn.encode(xe.encode({
2736
2755
  msg: { feePayer: t, blockhash: r, instructions: e },
2737
2756
  signatures: {}
2738
2757
  }));
@@ -2750,7 +2769,7 @@ function Pn(t) {
2750
2769
  e[h] = c;
2751
2770
  }
2752
2771
  const r = t.length, n = t.charAt(0), s = Math.log(r) / Math.log(256), o = Math.log(256) / Math.log(r);
2753
- function a(c) {
2772
+ function i(c) {
2754
2773
  if (c instanceof Uint8Array || (ArrayBuffer.isView(c) ? c = new Uint8Array(c.buffer, c.byteOffset, c.byteLength) : Array.isArray(c) && (c = Uint8Array.from(c))), !(c instanceof Uint8Array))
2755
2774
  throw new TypeError("Expected Uint8Array");
2756
2775
  if (c.length === 0)
@@ -2762,8 +2781,8 @@ function Pn(t) {
2762
2781
  const w = (u - f) * o + 1 >>> 0, _ = new Uint8Array(w);
2763
2782
  for (; f !== u; ) {
2764
2783
  let k = c[f], p = 0;
2765
- for (let E = w - 1; (k !== 0 || p < h) && E !== -1; E--, p++)
2766
- k += 256 * _[E] >>> 0, _[E] = k % r >>> 0, k = k / r >>> 0;
2784
+ for (let v = w - 1; (k !== 0 || p < h) && v !== -1; v--, p++)
2785
+ k += 256 * _[v] >>> 0, _[v] = k % r >>> 0, k = k / r >>> 0;
2767
2786
  if (k !== 0)
2768
2787
  throw new Error("Non-zero carry");
2769
2788
  h = p, f++;
@@ -2776,7 +2795,7 @@ function Pn(t) {
2776
2795
  I += t.charAt(_[m]);
2777
2796
  return I;
2778
2797
  }
2779
- function i(c) {
2798
+ function a(c) {
2780
2799
  if (typeof c != "string")
2781
2800
  throw new TypeError("Expected String");
2782
2801
  if (c.length === 0)
@@ -2792,12 +2811,12 @@ function Pn(t) {
2792
2811
  let p = e[k];
2793
2812
  if (p === 255)
2794
2813
  return;
2795
- let E = 0;
2796
- for (let C = u - 1; (p !== 0 || E < f) && C !== -1; C--, E++)
2814
+ let v = 0;
2815
+ for (let C = u - 1; (p !== 0 || v < f) && C !== -1; C--, v++)
2797
2816
  p += r * w[C] >>> 0, w[C] = p % 256 >>> 0, p = p / 256 >>> 0;
2798
2817
  if (p !== 0)
2799
2818
  throw new Error("Non-zero carry");
2800
- f = E, d++;
2819
+ f = v, d++;
2801
2820
  }
2802
2821
  let _ = u - f;
2803
2822
  for (; _ !== u && w[_] === 0; )
@@ -2809,20 +2828,20 @@ function Pn(t) {
2809
2828
  return m;
2810
2829
  }
2811
2830
  function l(c) {
2812
- const d = i(c);
2831
+ const d = a(c);
2813
2832
  if (d)
2814
2833
  return d;
2815
2834
  throw new Error("Non-base" + r + " character");
2816
2835
  }
2817
2836
  return {
2818
- encode: a,
2819
- decodeUnsafe: i,
2837
+ encode: i,
2838
+ decodeUnsafe: a,
2820
2839
  decode: l
2821
2840
  };
2822
2841
  }
2823
2842
  var Bn = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
2824
2843
  Pn(Bn);
2825
- class ze {
2844
+ class Le {
2826
2845
  _transaction;
2827
2846
  signatures = [];
2828
2847
  feePayer;
@@ -2835,15 +2854,15 @@ class ze {
2835
2854
  return this._instructions.push(...e), this;
2836
2855
  }
2837
2856
  static from(e) {
2838
- const r = e instanceof Uint8Array ? e : new Uint8Array(e), n = ve.decode(r), s = new ze();
2857
+ const r = e instanceof Uint8Array ? e : new Uint8Array(e), n = xe.decode(r), s = new Le();
2839
2858
  return s._transaction = n, s;
2840
2859
  }
2841
2860
  serialize(e) {
2842
2861
  if (this._transaction)
2843
- return Buffer.from(ve.encode(this._transaction));
2862
+ return Buffer.from(xe.encode(this._transaction));
2844
2863
  if (!this.feePayer || !this.recentBlockhash)
2845
2864
  throw new Error("Transaction requires feePayer and recentBlockhash");
2846
- const r = tt(
2865
+ const r = rt(
2847
2866
  this.feePayer.toString(),
2848
2867
  this._instructions,
2849
2868
  this.recentBlockhash
@@ -2853,7 +2872,7 @@ class ze {
2853
2872
  serializeMessage() {
2854
2873
  if (!this.feePayer || !this.recentBlockhash)
2855
2874
  throw new Error("Transaction requires feePayer and recentBlockhash");
2856
- const e = tt(
2875
+ const e = rt(
2857
2876
  this.feePayer.toString(),
2858
2877
  this._instructions,
2859
2878
  this.recentBlockhash
@@ -2929,7 +2948,7 @@ class Nn {
2929
2948
  if (!this.isAvailable() || !this.account)
2930
2949
  throw new Error("Phantom is not connected");
2931
2950
  try {
2932
- const r = ze.from(e), s = await this.getProvider().signAndSendTransaction(r);
2951
+ const r = Le.from(e), s = await this.getProvider().signAndSendTransaction(r);
2933
2952
  return {
2934
2953
  success: !0,
2935
2954
  wallet: this.type,
@@ -2971,12 +2990,12 @@ class Nn {
2971
2990
  };
2972
2991
  }
2973
2992
  }
2974
- class Rn extends Ie {
2993
+ class Rn extends Ce {
2975
2994
  type = "rabby";
2976
2995
  rdns = "io.rabby";
2977
2996
  displayName = "Rabby";
2978
2997
  }
2979
- class Tn {
2998
+ class Un {
2980
2999
  type = "braavos";
2981
3000
  platform = "starknet";
2982
3001
  wallet = void 0;
@@ -3110,7 +3129,7 @@ class Tn {
3110
3129
  this.removeAccountChangeListener(), this.wallet = void 0, this.account = void 0, this.connectedAccounts = [];
3111
3130
  }
3112
3131
  }
3113
- class Un {
3132
+ class Tn {
3114
3133
  walletAdapters;
3115
3134
  constructor() {
3116
3135
  if (this.walletAdapters = /* @__PURE__ */ new Map(), typeof window > "u")
@@ -3121,12 +3140,12 @@ class Un {
3121
3140
  this.walletAdapters.set("phantom", r);
3122
3141
  const n = new jr();
3123
3142
  this.walletAdapters.set("argent", n);
3124
- const s = new Tn();
3143
+ const s = new Un();
3125
3144
  this.walletAdapters.set("braavos", s);
3126
3145
  const o = new Rn();
3127
3146
  this.walletAdapters.set("rabby", o);
3128
- const a = new Vr();
3129
- this.walletAdapters.set("base", a), window.wallet_bridge = this;
3147
+ const i = new Kr();
3148
+ this.walletAdapters.set("base", i), window.wallet_bridge = this;
3130
3149
  }
3131
3150
  getIFrameMethods() {
3132
3151
  return {
@@ -3153,15 +3172,15 @@ class Un {
3153
3172
  }
3154
3173
  handleError(e, r, n, s) {
3155
3174
  const o = r instanceof Error ? r.message : "Unknown error";
3156
- let a = "unknown";
3175
+ let i = "unknown";
3157
3176
  if (typeof e == "string") {
3158
- const i = this.getConnectedWalletAdapter(e);
3159
- a = s ?? i?.type ?? e;
3177
+ const a = this.getConnectedWalletAdapter(e);
3178
+ i = s ?? a?.type ?? e;
3160
3179
  } else
3161
- a = e;
3180
+ i = e;
3162
3181
  return console.error(`Error ${n} with ${e} wallet:`, r), {
3163
3182
  success: !1,
3164
- wallet: a,
3183
+ wallet: i,
3165
3184
  error: o
3166
3185
  };
3167
3186
  }
@@ -3287,33 +3306,71 @@ class zn extends cr {
3287
3306
  version: n,
3288
3307
  slot: s,
3289
3308
  namespace: o,
3290
- tokens: a,
3291
- ...i
3309
+ tokens: i,
3310
+ preset: a,
3311
+ shouldOverridePresetPolicies: l,
3312
+ rpcUrl: c,
3313
+ ref: d,
3314
+ refGroup: h,
3315
+ ...f
3292
3316
  }) {
3293
- const l = new URL(e ?? Ut), c = new Un();
3294
- r && l.searchParams.set(
3317
+ const u = new URL(e ?? be), w = new Tn();
3318
+ n && u.searchParams.set("v", encodeURIComponent(n)), s && u.searchParams.set("ps", encodeURIComponent(s)), o && u.searchParams.set("ns", encodeURIComponent(o)), i?.erc20 && u.searchParams.set(
3319
+ "erc20",
3320
+ encodeURIComponent(i.erc20.toString())
3321
+ ), c && u.searchParams.set("rpc_url", encodeURIComponent(c)), d && u.searchParams.set("ref", encodeURIComponent(d)), h && u.searchParams.set("ref_group", encodeURIComponent(h)), (!a || l) && r ? u.searchParams.set(
3295
3322
  "policies",
3296
3323
  encodeURIComponent(JSON.stringify(r))
3297
- ), n && l.searchParams.set("v", encodeURIComponent(n)), s && l.searchParams.set("ps", encodeURIComponent(s)), o && l.searchParams.set("ns", encodeURIComponent(o)), a?.erc20 && l.searchParams.set(
3298
- "erc20",
3299
- encodeURIComponent(a.erc20.toString())
3300
- ), super({
3301
- ...i,
3324
+ ) : a && u.searchParams.set("preset", a), super({
3325
+ ...f,
3302
3326
  id: "controller-keychain",
3303
- url: l,
3304
- methods: c.getIFrameMethods()
3305
- }), this.walletBridge = c, typeof window < "u" && (window.external_wallets = this.walletBridge);
3327
+ url: u,
3328
+ methods: w.getIFrameMethods()
3329
+ }), this.walletBridge = w, typeof window < "u" && (window.external_wallets = this.walletBridge);
3306
3330
  }
3307
3331
  getWalletBridge() {
3308
3332
  return this.walletBridge;
3309
3333
  }
3310
3334
  }
3311
- class Mn extends zt {
3335
+ function Ln(t) {
3336
+ if (!t || t.trim() === "")
3337
+ return { isValid: !1, error: "Redirect URL is empty" };
3338
+ let e;
3339
+ try {
3340
+ e = new URL(t);
3341
+ } catch {
3342
+ return {
3343
+ isValid: !1,
3344
+ error: "Invalid URL format"
3345
+ };
3346
+ }
3347
+ if (!["http:", "https:"].includes(e.protocol))
3348
+ return {
3349
+ isValid: !1,
3350
+ error: `Protocol "${e.protocol}" is not allowed. Only http: and https: are supported.`
3351
+ };
3352
+ if (!e.hostname || e.hostname === "")
3353
+ return {
3354
+ isValid: !1,
3355
+ error: "URL must have a valid hostname"
3356
+ };
3357
+ if (typeof window < "u") {
3358
+ const n = window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1", s = e.hostname === "localhost" || e.hostname === "127.0.0.1";
3359
+ if (!n && s)
3360
+ return {
3361
+ isValid: !1,
3362
+ error: "Cannot redirect to localhost from production"
3363
+ };
3364
+ }
3365
+ return { isValid: !0 };
3366
+ }
3367
+ class Qn extends zt {
3312
3368
  keychain;
3313
3369
  options;
3314
3370
  iframes;
3315
3371
  selectedChain;
3316
3372
  chains;
3373
+ referral;
3317
3374
  isReady() {
3318
3375
  return !!this.keychain;
3319
3376
  }
@@ -3322,14 +3379,36 @@ class Mn extends zt {
3322
3379
  const n = [...[
3323
3380
  { rpcUrl: "https://api.cartridge.gg/x/starknet/sepolia/rpc/v0_9" },
3324
3381
  { rpcUrl: "https://api.cartridge.gg/x/starknet/mainnet/rpc/v0_9" }
3325
- ], ...e.chains || []], s = e.defaultChainId || V.StarknetChainId.SN_MAIN;
3326
- this.selectedChain = s, this.chains = /* @__PURE__ */ new Map(), this.options = { ...e, chains: n, defaultChainId: s }, this.iframes = {
3382
+ ], ...e.chains || []], s = e.defaultChainId || K.StarknetChainId.SN_MAIN;
3383
+ this.selectedChain = s, this.chains = /* @__PURE__ */ new Map();
3384
+ const o = typeof window < "u" ? new URLSearchParams(window.location.search) : null;
3385
+ if (this.referral = {
3386
+ ref: o?.get("ref") ?? void 0,
3387
+ refGroup: o?.get("ref_group") ?? void 0
3388
+ }, this.options = { ...e, chains: n, defaultChainId: s }, typeof window < "u" && o?.has("controller_redirect")) {
3389
+ const a = new URL(e.url || be), l = new URL(window.location.href);
3390
+ l.searchParams.delete("controller_redirect");
3391
+ const c = l.toString();
3392
+ a.searchParams.set("redirect_url", c), e.preset && a.searchParams.set("preset", e.preset), window.location.href = a.toString();
3393
+ return;
3394
+ }
3395
+ if (typeof window < "u" && typeof localStorage < "u") {
3396
+ const i = o?.get("lastUsedConnector");
3397
+ if (i && localStorage.setItem("lastUsedConnector", i), o && window.history?.replaceState) {
3398
+ let a = !1;
3399
+ if (i && (o.delete("lastUsedConnector"), a = !0), o.has("controller_redirect") && (o.delete("controller_redirect"), a = !0), a) {
3400
+ const l = window.location.pathname + (o.toString() ? "?" + o.toString() : "") + window.location.hash;
3401
+ window.history.replaceState({}, "", l);
3402
+ }
3403
+ }
3404
+ }
3405
+ this.initializeChains(n), this.iframes = {
3327
3406
  keychain: e.lazyload ? void 0 : this.createKeychainIframe()
3328
- }, this.initializeChains(n), typeof window < "u" && (window.starknet_controller = this);
3407
+ }, typeof window < "u" && (window.starknet_controller = this);
3329
3408
  }
3330
3409
  async logout() {
3331
3410
  if (!this.keychain) {
3332
- console.error(new v().message);
3411
+ console.error(new E().message);
3333
3412
  return;
3334
3413
  }
3335
3414
  try {
@@ -3344,64 +3423,62 @@ class Mn extends zt {
3344
3423
  }
3345
3424
  }
3346
3425
  async probe() {
3347
- try {
3348
- if (this.iframes.keychain || (this.iframes.keychain = this.createKeychainIframe()), await this.waitForKeychain(), !this.keychain) {
3349
- console.error(new v().message);
3426
+ if (this.iframes) {
3427
+ try {
3428
+ if (this.iframes.keychain || (this.iframes.keychain = this.createKeychainIframe()), await this.waitForKeychain(), !this.keychain) {
3429
+ console.error(new E().message);
3430
+ return;
3431
+ }
3432
+ const e = await this.keychain.probe(this.rpcUrl());
3433
+ let r = e?.rpcUrl || this.rpcUrl();
3434
+ this.account = new Me(
3435
+ this,
3436
+ r,
3437
+ e.address,
3438
+ this.keychain,
3439
+ this.options,
3440
+ this.iframes.keychain
3441
+ );
3442
+ } catch (e) {
3443
+ console.error(e);
3350
3444
  return;
3351
3445
  }
3352
- const e = await this.keychain.probe(this.rpcUrl());
3353
- let r = e?.rpcUrl || this.rpcUrl();
3354
- this.account = new Oe(
3355
- this,
3356
- r,
3357
- e.address,
3358
- this.keychain,
3359
- this.options,
3360
- this.iframes.keychain
3361
- );
3362
- } catch (e) {
3363
- console.error(e);
3364
- return;
3446
+ return this.account;
3365
3447
  }
3366
- return this.account;
3367
3448
  }
3368
3449
  async connect() {
3369
- if (this.account)
3370
- return this.account;
3371
- if (this.iframes.keychain || (this.iframes.keychain = this.createKeychainIframe(), await this.waitForKeychain()), !this.keychain || !this.iframes.keychain) {
3372
- console.error(new v().message);
3373
- return;
3374
- }
3375
- typeof document < "u" && document.hasStorageAccess && (await document.hasStorageAccess() || await document.requestStorageAccess()), this.iframes.keychain.open();
3376
- try {
3377
- let e = await this.keychain.connect(
3378
- // Policy precedence logic:
3379
- // 1. If shouldOverridePresetPolicies is true and policies are provided, use policies
3380
- // 2. Otherwise, if preset is defined, use empty object (let preset take precedence)
3381
- // 3. Otherwise, use provided policies or empty object
3382
- this.options.shouldOverridePresetPolicies && this.options.policies ? this.options.policies : this.options.preset ? {} : this.options.policies || {},
3383
- this.rpcUrl(),
3384
- this.options.signupOptions
3385
- );
3386
- if (e.code !== Q.SUCCESS)
3387
- throw new Error(e.message);
3388
- return e = e, this.account = new Oe(
3389
- this,
3390
- this.rpcUrl(),
3391
- e.address,
3392
- this.keychain,
3393
- this.options,
3394
- this.iframes.keychain
3395
- ), this.account;
3396
- } catch (e) {
3397
- console.log(e);
3398
- } finally {
3399
- this.iframes.keychain.close();
3450
+ if (this.iframes) {
3451
+ if (this.account)
3452
+ return this.account;
3453
+ if (this.iframes.keychain || (this.iframes.keychain = this.createKeychainIframe(), await this.waitForKeychain()), !this.keychain || !this.iframes.keychain) {
3454
+ console.error(new E().message);
3455
+ return;
3456
+ }
3457
+ typeof document < "u" && document.hasStorageAccess && (await document.hasStorageAccess() || await document.requestStorageAccess()), this.iframes.keychain.open();
3458
+ try {
3459
+ let e = await this.keychain.connect(this.options.signupOptions);
3460
+ if (e.code !== Q.SUCCESS)
3461
+ throw new Error(e.message);
3462
+ return e = e, this.account = new Me(
3463
+ this,
3464
+ this.rpcUrl(),
3465
+ e.address,
3466
+ this.keychain,
3467
+ this.options,
3468
+ this.iframes.keychain
3469
+ ), this.account;
3470
+ } catch (e) {
3471
+ console.log(e);
3472
+ } finally {
3473
+ this.iframes.keychain.close();
3474
+ }
3400
3475
  }
3401
3476
  }
3402
3477
  async switchStarknetChain(e) {
3478
+ if (!this.iframes)
3479
+ return !1;
3403
3480
  if (!this.keychain || !this.iframes.keychain)
3404
- return console.error(new v().message), !1;
3481
+ return console.error(new E().message), !1;
3405
3482
  const r = this.selectedChain;
3406
3483
  try {
3407
3484
  this.selectedChain = e, await this.keychain.switchChain(this.rpcUrl());
@@ -3415,14 +3492,16 @@ class Mn extends zt {
3415
3492
  }
3416
3493
  async disconnect() {
3417
3494
  if (!this.keychain) {
3418
- console.error(new v().message);
3495
+ console.error(new E().message);
3419
3496
  return;
3420
3497
  }
3421
3498
  return typeof document < "u" && document.hasStorageAccess && (await document.hasStorageAccess() || await document.requestStorageAccess()), this.account = void 0, this.keychain.disconnect();
3422
3499
  }
3423
3500
  async openProfile(e = "inventory") {
3501
+ if (!this.iframes)
3502
+ return;
3424
3503
  if (!this.keychain || !this.iframes.keychain) {
3425
- console.error(new v().message);
3504
+ console.error(new E().message);
3426
3505
  return;
3427
3506
  }
3428
3507
  if (!this.account) {
@@ -3435,8 +3514,10 @@ class Mn extends zt {
3435
3514
  ), this.iframes.keychain.open();
3436
3515
  }
3437
3516
  async openProfileTo(e) {
3517
+ if (!this.iframes)
3518
+ return;
3438
3519
  if (!this.keychain || !this.iframes.keychain) {
3439
- console.error(new v().message);
3520
+ console.error(new E().message);
3440
3521
  return;
3441
3522
  }
3442
3523
  if (!this.account) {
@@ -3449,64 +3530,74 @@ class Mn extends zt {
3449
3530
  ), this.iframes.keychain.open();
3450
3531
  }
3451
3532
  async openProfileAt(e) {
3452
- if (!this.keychain || !this.iframes.keychain) {
3453
- console.error(new v().message);
3454
- return;
3455
- }
3456
- if (!this.account) {
3457
- console.error("Account is not ready");
3458
- return;
3533
+ if (this.iframes) {
3534
+ if (!this.keychain || !this.iframes.keychain) {
3535
+ console.error(new E().message);
3536
+ return;
3537
+ }
3538
+ if (!this.account) {
3539
+ console.error("Account is not ready");
3540
+ return;
3541
+ }
3542
+ await this.keychain.navigate(e), this.iframes.keychain.open();
3459
3543
  }
3460
- await this.keychain.navigate(e), this.iframes.keychain.open();
3461
3544
  }
3462
3545
  openSettings() {
3463
- if (!this.keychain || !this.iframes.keychain) {
3464
- console.error(new v().message);
3465
- return;
3546
+ if (this.iframes) {
3547
+ if (!this.keychain || !this.iframes.keychain) {
3548
+ console.error(new E().message);
3549
+ return;
3550
+ }
3551
+ this.iframes.keychain.open(), this.keychain.openSettings();
3466
3552
  }
3467
- this.iframes.keychain.open(), this.keychain.openSettings();
3468
3553
  }
3469
3554
  revoke(e, r) {
3470
- return this.keychain ? this.keychain.revoke(e) : (console.error(new v().message), null);
3555
+ return this.keychain ? this.keychain.revoke(e) : (console.error(new E().message), null);
3471
3556
  }
3472
3557
  rpcUrl() {
3473
3558
  const e = this.chains.get(this.selectedChain);
3474
3559
  if (!e) {
3475
3560
  const r = Array.from(this.chains.keys()).map(
3476
- (n) => De.decodeShortString(n)
3561
+ (n) => Oe.decodeShortString(n)
3477
3562
  );
3478
3563
  throw new Error(
3479
- `Chain not found: ${De.decodeShortString(this.selectedChain)}. Available chains: ${r.join(", ")}`
3564
+ `Chain not found: ${Oe.decodeShortString(this.selectedChain)}. Available chains: ${r.join(", ")}`
3480
3565
  );
3481
3566
  }
3482
3567
  return e.rpcUrl;
3483
3568
  }
3484
3569
  username() {
3485
3570
  if (!this.keychain) {
3486
- console.error(new v().message);
3571
+ console.error(new E().message);
3487
3572
  return;
3488
3573
  }
3489
3574
  return this.keychain.username();
3490
3575
  }
3491
3576
  openPurchaseCredits() {
3492
- if (!this.keychain || !this.iframes.keychain) {
3493
- console.error(new v().message);
3494
- return;
3577
+ if (this.iframes) {
3578
+ if (!this.keychain || !this.iframes.keychain) {
3579
+ console.error(new E().message);
3580
+ return;
3581
+ }
3582
+ this.keychain.navigate("/purchase/credits").then(() => {
3583
+ this.iframes.keychain?.open();
3584
+ });
3495
3585
  }
3496
- this.keychain.navigate("/purchase/credits").then(() => {
3497
- this.iframes.keychain?.open();
3498
- });
3499
3586
  }
3500
3587
  async openStarterPack(e) {
3501
- if (!this.keychain || !this.iframes.keychain) {
3502
- console.error(new v().message);
3503
- return;
3588
+ if (this.iframes) {
3589
+ if (!this.keychain || !this.iframes.keychain) {
3590
+ console.error(new E().message);
3591
+ return;
3592
+ }
3593
+ await this.keychain.openStarterPack(e), this.iframes.keychain?.open();
3504
3594
  }
3505
- await this.keychain.openStarterPack(e), this.iframes.keychain?.open();
3506
3595
  }
3507
3596
  async openExecute(e, r) {
3597
+ if (!this.iframes)
3598
+ return;
3508
3599
  if (!this.keychain || !this.iframes.keychain) {
3509
- console.error(new v().message);
3600
+ console.error(new E().message);
3510
3601
  return;
3511
3602
  }
3512
3603
  let n = this.selectedChain;
@@ -3518,13 +3609,50 @@ class Mn extends zt {
3518
3609
  };
3519
3610
  }
3520
3611
  async delegateAccount() {
3521
- return this.keychain ? await this.keychain.delegateAccount() : (console.error(new v().message), null);
3612
+ return this.keychain ? await this.keychain.delegateAccount() : (console.error(new E().message), null);
3613
+ }
3614
+ /**
3615
+ * Opens the keychain in standalone mode (first-party context) for authentication.
3616
+ * This establishes first-party storage, enabling seamless iframe access across all games.
3617
+ * @param options - Configuration for redirect after authentication
3618
+ */
3619
+ open(e = {}) {
3620
+ if (typeof window > "u") {
3621
+ console.error("open can only be called in browser context");
3622
+ return;
3623
+ }
3624
+ const r = new URL(this.options.url || be), n = e.redirectUrl || window.location.href, s = Ln(n);
3625
+ if (!s.isValid) {
3626
+ console.error(
3627
+ `Invalid redirect URL: ${s.error}`,
3628
+ `URL: ${n}`
3629
+ );
3630
+ return;
3631
+ }
3632
+ r.searchParams.set("redirect_url", n), this.options.preset && r.searchParams.set("preset", this.options.preset), this.options.slot && r.searchParams.set("ps", this.options.slot), this.options.namespace && r.searchParams.set("ns", this.options.namespace), this.options.tokens?.erc20 && r.searchParams.set(
3633
+ "erc20",
3634
+ this.options.tokens.erc20.toString()
3635
+ ), this.rpcUrl() && r.searchParams.set("rpc_url", this.rpcUrl()), window.location.href = r.toString();
3636
+ }
3637
+ /**
3638
+ * Checks if the keychain iframe has first-party storage access.
3639
+ * Returns true if the user has previously authenticated via standalone mode.
3640
+ * @returns Promise<boolean> indicating if storage access is available
3641
+ */
3642
+ async hasFirstPartyAccess() {
3643
+ if (!this.keychain)
3644
+ return console.error(new E().message), !1;
3645
+ try {
3646
+ return await this.keychain.hasStorageAccess();
3647
+ } catch (e) {
3648
+ return console.error("Error checking storage access:", e), !1;
3649
+ }
3522
3650
  }
3523
3651
  initializeChains(e) {
3524
3652
  for (const r of e)
3525
3653
  try {
3526
- const n = new URL(r.rpcUrl), s = Lt(n), o = s === V.StarknetChainId.SN_MAIN, a = s === V.StarknetChainId.SN_SEPOLIA, i = n.hostname === "api.cartridge.gg", l = n.hostname === "localhost" || n.hostname === "127.0.0.1";
3527
- if ((o || a) && !(i || l))
3654
+ const n = new URL(r.rpcUrl), s = Lt(n), o = s === K.StarknetChainId.SN_MAIN, i = s === K.StarknetChainId.SN_SEPOLIA, a = n.hostname === "api.cartridge.gg", l = n.hostname === "localhost" || n.hostname === "127.0.0.1";
3655
+ if ((o || i) && !(a || l))
3528
3656
  throw new Error(
3529
3657
  `Only Cartridge RPC providers are allowed for ${o ? "mainnet" : "sepolia"}. Please use: https://api.cartridge.gg/x/starknet/${o ? "mainnet" : "sepolia"}/rpc/v0_9`
3530
3658
  );
@@ -3539,11 +3667,14 @@ class Mn extends zt {
3539
3667
  createKeychainIframe() {
3540
3668
  return new zn({
3541
3669
  ...this.options,
3670
+ rpcUrl: this.rpcUrl(),
3542
3671
  onClose: this.keychain?.reset,
3543
3672
  onConnect: (e) => {
3544
3673
  this.keychain = e;
3545
3674
  },
3546
- version: Dt
3675
+ version: Dt,
3676
+ ref: this.referral.ref,
3677
+ refGroup: this.referral.refGroup
3547
3678
  });
3548
3679
  }
3549
3680
  waitForKeychain({
@@ -3551,18 +3682,18 @@ class Mn extends zt {
3551
3682
  interval: r = 100
3552
3683
  } = {}) {
3553
3684
  return new Promise((n, s) => {
3554
- const o = Date.now(), a = setInterval(() => {
3685
+ const o = Date.now(), i = setInterval(() => {
3555
3686
  if (Date.now() - o > e) {
3556
- clearInterval(a), s(new Error("Timeout waiting for keychain"));
3687
+ clearInterval(i), s(new Error("Timeout waiting for keychain"));
3557
3688
  return;
3558
3689
  }
3559
- this.keychain && (clearInterval(a), n());
3690
+ this.keychain && (clearInterval(i), n());
3560
3691
  }, r);
3561
3692
  });
3562
3693
  }
3563
3694
  }
3564
3695
  const F = /* @__PURE__ */ new Map();
3565
- async function Pt(t) {
3696
+ async function Bt(t) {
3566
3697
  if (!t.addresses?.length && !t.usernames?.length)
3567
3698
  return { results: [] };
3568
3699
  const e = await fetch(`${Ot}/lookup`, {
@@ -3576,18 +3707,18 @@ async function Pt(t) {
3576
3707
  throw new Error(`HTTP error! status: ${e.status}`);
3577
3708
  return e.json();
3578
3709
  }
3579
- async function Qn(t) {
3710
+ async function Fn(t) {
3580
3711
  const e = t.filter((r) => !F.has(r));
3581
- return e.length > 0 && (await Pt({ usernames: e })).results.forEach((n) => {
3712
+ return e.length > 0 && (await Bt({ usernames: e })).results.forEach((n) => {
3582
3713
  F.set(n.username, n.addresses[0]);
3583
3714
  }), new Map(
3584
3715
  t.map((r) => [r, F.get(r)]).filter((r) => r[1] !== void 0)
3585
3716
  );
3586
3717
  }
3587
- async function Fn(t) {
3588
- t = t.map(rt.toHex);
3718
+ async function Wn(t) {
3719
+ t = t.map(nt.toHex);
3589
3720
  const e = t.filter((r) => !F.has(r));
3590
- return e.length > 0 && (await Pt({
3721
+ return e.length > 0 && (await Bt({
3591
3722
  addresses: e
3592
3723
  })).results.forEach((n) => {
3593
3724
  F.set(n.addresses[0], n.username);
@@ -3595,7 +3726,7 @@ async function Fn(t) {
3595
3726
  t.map((r) => [r, F.get(r)]).filter((r) => r[1] !== void 0)
3596
3727
  );
3597
3728
  }
3598
- var Ln = [
3729
+ var Dn = [
3599
3730
  {
3600
3731
  name: "Wrapped BTC",
3601
3732
  symbol: "WBTC",
@@ -4166,15 +4297,24 @@ var Ln = [
4166
4297
  l2_token_address: "0x42dd777885ad2c116be96d4d634abc90a26a790ffb5871e037dd5ae7d2ec86b",
4167
4298
  sort_order: 1,
4168
4299
  total_supply: null,
4169
- logo_url: "https://lootsurvivor.io/images/survivor_token.png"
4300
+ logo_url: "https://imagedelivery.net/0xPAQaDtnQhBs8IzYRIlNg/399cb277-f675-4efe-97fb-fac94a236a00/logo"
4301
+ },
4302
+ {
4303
+ name: "Dungeon Ticket",
4304
+ symbol: "TICKET",
4305
+ decimals: 18,
4306
+ l2_token_address: "0x035f581b050a39958b7188ab5c75daaa1f9d3571a0c032203038c898663f31f8",
4307
+ sort_order: 1,
4308
+ total_supply: null,
4309
+ logo_url: " https://imagedelivery.net/0xPAQaDtnQhBs8IzYRIlNg/f96b51e2-e978-42e2-c67a-e84159015000/logo"
4170
4310
  }
4171
- ], Bt = {
4311
+ ], Nt = {
4172
4312
  theme: {
4173
4313
  name: "Cartridge",
4174
4314
  icon: "icon.svg"
4175
4315
  }
4176
4316
  }, ae = "https://static.cartridge.gg/presets";
4177
- async function Le() {
4317
+ async function De() {
4178
4318
  try {
4179
4319
  const t = await fetch(`${ae}/index.json`);
4180
4320
  if (!t.ok)
@@ -4184,12 +4324,12 @@ async function Le() {
4184
4324
  return console.error("Error loading configs index:", t), { configs: [], baseUrl: ae };
4185
4325
  }
4186
4326
  }
4187
- async function Wn() {
4188
- return (await Le()).configs;
4327
+ async function jn() {
4328
+ return (await De()).configs;
4189
4329
  }
4190
- async function jn(t) {
4330
+ async function Yn(t) {
4191
4331
  try {
4192
- const n = `${(await Le()).baseUrl || ae}/${t}`, s = await fetch(`${n}/config.json`);
4332
+ const n = `${(await De()).baseUrl || ae}/${t}`, s = await fetch(`${n}/config.json`);
4193
4333
  if (!s.ok)
4194
4334
  throw new Error(
4195
4335
  `Failed to load config ${t}: ${s.statusText}`
@@ -4197,37 +4337,37 @@ async function jn(t) {
4197
4337
  const o = await s.json();
4198
4338
  if (o && o.theme) {
4199
4339
  o.theme.icon && !o.theme.icon.startsWith("http") && (o.theme.icon = `${n}/${o.theme.icon}`), o.theme.cover && (typeof o.theme.cover == "string" ? o.theme.cover.startsWith("http") || (o.theme.cover = `${n}/${o.theme.cover}`) : (o.theme.cover.light && !o.theme.cover.light.startsWith("http") && (o.theme.cover.light = `${n}/${o.theme.cover.light}`), o.theme.cover.dark && !o.theme.cover.dark.startsWith("http") && (o.theme.cover.dark = `${n}/${o.theme.cover.dark}`)));
4200
- const a = (i) => {
4201
- if (i) {
4202
- for (const l in i)
4203
- if (i[l])
4204
- for (const c in i[l])
4205
- i[l][c] && !i[l][c].startsWith("http") && (i[l][c] = `${n}/${i[l][c]}`);
4340
+ const i = (a) => {
4341
+ if (a) {
4342
+ for (const l in a)
4343
+ if (a[l])
4344
+ for (const c in a[l])
4345
+ a[l][c] && !a[l][c].startsWith("http") && (a[l][c] = `${n}/${a[l][c]}`);
4206
4346
  }
4207
4347
  };
4208
- if (o.theme.optimizedIcon && a(o.theme.optimizedIcon), o.theme.optimizedCover)
4348
+ if (o.theme.optimizedIcon && i(o.theme.optimizedIcon), o.theme.optimizedCover)
4209
4349
  if (typeof o.theme.optimizedCover == "string")
4210
4350
  o.theme.optimizedCover.startsWith("http") || (o.theme.optimizedCover = `${n}/${o.theme.optimizedCover}`);
4211
4351
  else if (o.theme.optimizedCover.light || o.theme.optimizedCover.dark) {
4212
- const i = o.theme.optimizedCover;
4213
- i.light && a(i.light), i.dark && a(i.dark);
4352
+ const a = o.theme.optimizedCover;
4353
+ a.light && i(a.light), a.dark && i(a.dark);
4214
4354
  } else
4215
- a(o.theme.optimizedCover);
4355
+ i(o.theme.optimizedCover);
4216
4356
  }
4217
4357
  return o;
4218
4358
  } catch (e) {
4219
4359
  return console.error(`Error loading config ${t}:`, e), null;
4220
4360
  }
4221
4361
  }
4222
- async function Yn() {
4223
- const t = await Le(), e = t.configs, r = t.baseUrl || ae, n = {};
4362
+ async function Hn() {
4363
+ const t = await De(), e = t.configs, r = t.baseUrl || ae, n = {};
4224
4364
  return await Promise.all(
4225
4365
  e.map(async (s) => {
4226
4366
  try {
4227
4367
  const o = await fetch(`${r}/${s}/config.json`);
4228
4368
  if (o.ok) {
4229
- const a = await o.json();
4230
- n[s] = a;
4369
+ const i = await o.json();
4370
+ n[s] = i;
4231
4371
  }
4232
4372
  } catch (o) {
4233
4373
  console.error(`Error loading config ${s}:`, o);
@@ -4235,42 +4375,41 @@ async function Yn() {
4235
4375
  })
4236
4376
  ), n;
4237
4377
  }
4238
- Bt.theme.icon = "https://static.cartridge.gg/presets/cartridge/icon.svg";
4239
- var Hn = Ln, Kn = Bt.theme;
4378
+ Nt.theme.icon = "https://static.cartridge.gg/presets/cartridge/icon.svg";
4379
+ var Vn = Dn, Kn = Nt.theme;
4240
4380
  export {
4241
- Gn as ALL_AUTH_OPTIONS,
4242
- Xn as AUTH_EXTERNAL_WALLETS,
4381
+ Xn as ALL_AUTH_OPTIONS,
4382
+ Jn as AUTH_EXTERNAL_WALLETS,
4243
4383
  jr as ArgentWallet,
4244
- Vr as BaseWallet,
4245
- Tn as BraavosWallet,
4246
- Jn as EMBEDDED_WALLETS,
4247
- Zn as EXTERNAL_WALLETS,
4248
- es as EXTRA_EXTERNAL_WALLETS,
4249
- Ie as EthereumWalletBase,
4250
- ts as FeeSource,
4251
- rs as IMPLEMENTED_AUTH_OPTIONS,
4384
+ Kr as BaseWallet,
4385
+ Un as BraavosWallet,
4386
+ Zn as EMBEDDED_WALLETS,
4387
+ es as EXTERNAL_WALLETS,
4388
+ ts as EXTRA_EXTERNAL_WALLETS,
4389
+ Ce as EthereumWalletBase,
4390
+ rs as FeeSource,
4391
+ ns as IMPLEMENTED_AUTH_OPTIONS,
4252
4392
  qr as MetaMaskWallet,
4253
- v as NotReadyToConnect,
4393
+ E as NotReadyToConnect,
4254
4394
  Nn as PhantomWallet,
4255
4395
  Rn as RabbyWallet,
4256
4396
  Q as ResponseCodes,
4257
- ns as StarterPackItemType,
4258
- Un as WalletBridge,
4397
+ Tn as WalletBridge,
4259
4398
  fe as chainIdToPlatform,
4260
- Mn as default,
4399
+ Qn as default,
4261
4400
  Kn as defaultTheme,
4262
- Hn as erc20Metadata,
4263
- Wn as getAvailableConfigs,
4264
- Le as getConfigsIndex,
4401
+ Vn as erc20Metadata,
4402
+ jn as getAvailableConfigs,
4403
+ De as getConfigsIndex,
4265
4404
  ss as humanizeString,
4266
4405
  Tt as isMobile,
4267
- Yn as loadAllConfigs,
4268
- jn as loadConfig,
4269
- Fn as lookupAddresses,
4270
- Qn as lookupUsernames,
4406
+ Hn as loadAllConfigs,
4407
+ Yn as loadConfig,
4408
+ Wn as lookupAddresses,
4409
+ Fn as lookupUsernames,
4271
4410
  os as normalizeCalls,
4272
4411
  Lt as parseChainId,
4273
- Rt as toArray,
4412
+ Ut as toArray,
4274
4413
  is as toSessionPolicies,
4275
4414
  as as toWasmPolicies
4276
4415
  };