@cartridge/controller 0.11.2-alpha.3 → 0.11.2

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,7 +1,7 @@
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-CjC60jKm.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-CjC60jKm.js";
4
- class Me extends Rt {
1
+ import { WalletAccount as Rt, constants as K, num as rt, shortString as De } from "starknet";
2
+ import { R as Q, t as Ut, i as Tt, K as nt, B as zt, N as x, p as Lt, v as Dt, A as Ot } from "./provider-s-80NdXp.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-s-80NdXp.js";
4
+ class Oe extends Rt {
5
5
  keychain;
6
6
  modal;
7
7
  options;
@@ -89,10 +89,10 @@ var G;
89
89
  (function(t) {
90
90
  t.ConnectionDestroyed = "ConnectionDestroyed", t.ConnectionTimeout = "ConnectionTimeout", t.NoIframeSrc = "NoIframeSrc";
91
91
  })(G || (G = {}));
92
- var _e;
92
+ var be;
93
93
  (function(t) {
94
94
  t.DataCloneError = "DataCloneError";
95
- })(_e || (_e = {}));
95
+ })(be || (be = {}));
96
96
  var U;
97
97
  (function(t) {
98
98
  t.Message = "message";
@@ -123,7 +123,7 @@ const Mt = (t, e) => {
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
124
  const i = o && o !== Ft[n] ? `:${o}` : "";
125
125
  return `${n}//${s}${i}`;
126
- }, Qe = ({ name: t, message: e, stack: r }) => ({
126
+ }, Me = ({ name: t, message: e, stack: r }) => ({
127
127
  name: t,
128
128
  message: e,
129
129
  stack: r
@@ -142,7 +142,7 @@ const Mt = (t, e) => {
142
142
  }
143
143
  const h = d.data, { methodName: f, args: u, id: w } = h;
144
144
  r(`${n}: Received ${f}() call`);
145
- const _ = (m) => (I) => {
145
+ const b = (y) => (m) => {
146
146
  if (r(`${n}: Sending ${f}() reply`), l) {
147
147
  r(`${n}: Unable to send ${f}() reply due to destroyed connection`);
148
148
  return;
@@ -150,19 +150,19 @@ const Mt = (t, e) => {
150
150
  const k = {
151
151
  penpal: B.Reply,
152
152
  id: w,
153
- resolution: m,
154
- returnValue: I
153
+ resolution: y,
154
+ returnValue: m
155
155
  };
156
- m === z.Rejected && I instanceof Error && (k.returnValue = Qe(I), k.returnValueIsError = !0);
156
+ y === z.Rejected && m instanceof Error && (k.returnValue = Me(m), k.returnValueIsError = !0);
157
157
  try {
158
158
  o.postMessage(k, i);
159
159
  } catch (p) {
160
- if (p.name === _e.DataCloneError) {
160
+ if (p.name === be.DataCloneError) {
161
161
  const v = {
162
162
  penpal: B.Reply,
163
163
  id: w,
164
164
  resolution: z.Rejected,
165
- returnValue: Qe(p),
165
+ returnValue: Me(p),
166
166
  returnValueIsError: !0
167
167
  };
168
168
  o.postMessage(v, i);
@@ -170,7 +170,7 @@ const Mt = (t, e) => {
170
170
  throw p;
171
171
  }
172
172
  };
173
- new Promise((m) => m(e[f].call(e, d.origin).apply(e, u))).then(_(z.Fulfilled), _(z.Rejected));
173
+ new Promise((y) => y(e[f].call(e, d.origin).apply(e, u))).then(b(z.Fulfilled), b(z.Rejected));
174
174
  };
175
175
  return s.addEventListener(U.Message, c), () => {
176
176
  l = !0, s.removeEventListener(U.Message, c);
@@ -200,17 +200,17 @@ const qt = () => ++Kt, st = ".", ot = (t) => t ? t.split(st) : [], Gt = (t) => t
200
200
  s(`${o}: Connecting call sender`);
201
201
  const h = (u) => (...w) => {
202
202
  s(`${o}: Sending ${u}() call`);
203
- let _;
203
+ let b;
204
204
  try {
205
- a.closed && (_ = !0);
205
+ a.closed && (b = !0);
206
206
  } catch {
207
- _ = !0;
207
+ b = !0;
208
208
  }
209
- if (_ && n(), d) {
210
- const m = new Error(`Unable to send ${u}() call due to destroyed connection`);
211
- throw m.code = G.ConnectionDestroyed, m;
209
+ if (b && n(), d) {
210
+ const y = new Error(`Unable to send ${u}() call due to destroyed connection`);
211
+ throw y.code = G.ConnectionDestroyed, y;
212
212
  }
213
- return new Promise((m, I) => {
213
+ return new Promise((y, m) => {
214
214
  const k = qt(), p = (C) => {
215
215
  if (C.source !== a || C.data.penpal !== B.Reply || C.data.id !== k)
216
216
  return;
@@ -221,7 +221,7 @@ const qt = () => ++Kt, st = ".", ot = (t) => t ? t.split(st) : [], Gt = (t) => t
221
221
  const de = C.data;
222
222
  s(`${o}: Received ${u}() reply`), i.removeEventListener(U.Message, p);
223
223
  let he = de.returnValue;
224
- de.returnValueIsError && (he = Ht(he)), (de.resolution === z.Fulfilled ? m : I)(he);
224
+ de.returnValueIsError && (he = Ht(he)), (de.resolution === z.Fulfilled ? y : m)(he);
225
225
  };
226
226
  i.addEventListener(U.Message, p);
227
227
  const v = {
@@ -298,8 +298,8 @@ const qt = () => ++Kt, st = ".", ot = (t) => t ? t.split(st) : [], Gt = (t) => t
298
298
  n || (ir(e), n = Yt(e.src));
299
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
- promise: new Promise((_, m) => {
302
- const I = or(s, c), k = (p) => {
301
+ promise: new Promise((b, y) => {
302
+ const m = or(s, c), k = (p) => {
303
303
  if (!(p.source !== e.contentWindow || !p.data)) {
304
304
  if (p.data.penpal === B.Syn) {
305
305
  f(p);
@@ -307,13 +307,13 @@ const qt = () => ++Kt, st = ".", ot = (t) => t ? t.split(st) : [], Gt = (t) => t
307
307
  }
308
308
  if (p.data.penpal === B.Ack) {
309
309
  const v = u(p);
310
- v && (I(), _(v));
310
+ v && (m(), b(v));
311
311
  return;
312
312
  }
313
313
  }
314
314
  };
315
315
  window.addEventListener(U.Message, k), i("Parent: Awaiting handshake"), sr(e, a), l((p) => {
316
- window.removeEventListener(U.Message, k), p && m(p);
316
+ window.removeEventListener(U.Message, k), p && y(p);
317
317
  });
318
318
  }),
319
319
  destroy() {
@@ -415,7 +415,7 @@ class cr {
415
415
  }
416
416
  }
417
417
  const lr = "6.13.7";
418
- function Fe(t, e, r) {
418
+ function Qe(t, e, r) {
419
419
  for (let n in e) {
420
420
  let s = e[n];
421
421
  Object.defineProperty(t, n, { enumerable: !0, value: s, writable: !1 });
@@ -480,7 +480,7 @@ function dr(t, e, r) {
480
480
  default:
481
481
  s = new Error(t);
482
482
  }
483
- return Fe(s, { code: e }), r && Object.assign(s, r), s.shortMessage == null && Fe(s, { shortMessage: n }), s;
483
+ return Qe(s, { code: e }), r && Object.assign(s, r), s.shortMessage == null && Qe(s, { shortMessage: n }), s;
484
484
  }
485
485
  function hr(t, e, r, n) {
486
486
  if (!t)
@@ -512,16 +512,16 @@ function fr(t, e, r) {
512
512
  }
513
513
  Y(!1, "invalid BytesLike value", e || "value", t);
514
514
  }
515
- function $e(t, e) {
515
+ function xe(t, e) {
516
516
  return fr(t, e);
517
517
  }
518
- const We = "0123456789abcdef";
518
+ const Fe = "0123456789abcdef";
519
519
  function ur(t) {
520
- const e = $e(t);
520
+ const e = xe(t);
521
521
  let r = "0x";
522
522
  for (let n = 0; n < e.length; n++) {
523
523
  const s = e[n];
524
- r += We[(s & 240) >> 4] + We[s & 15];
524
+ r += Fe[(s & 240) >> 4] + Fe[s & 15];
525
525
  }
526
526
  return r;
527
527
  }
@@ -529,7 +529,7 @@ function ur(t) {
529
529
  function wr(t) {
530
530
  return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
531
531
  }
532
- function je(t) {
532
+ function We(t) {
533
533
  if (!Number.isSafeInteger(t) || t < 0)
534
534
  throw new Error("positive integer expected, got " + t);
535
535
  }
@@ -539,7 +539,7 @@ function re(t, ...e) {
539
539
  if (e.length > 0 && !e.includes(t.length))
540
540
  throw new Error("Uint8Array expected of length " + e + ", got length=" + t.length);
541
541
  }
542
- function Ye(t, e = !0) {
542
+ function je(t, e = !0) {
543
543
  if (t.destroyed)
544
544
  throw new Error("Hash instance has been destroyed");
545
545
  if (e && t.finished)
@@ -558,16 +558,16 @@ function at(...t) {
558
558
  for (let e = 0; e < t.length; e++)
559
559
  t[e].fill(0);
560
560
  }
561
- const yr = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
562
- function mr(t) {
561
+ const mr = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
562
+ function yr(t) {
563
563
  return t << 24 & 4278190080 | t << 8 & 16711680 | t >>> 8 & 65280 | t >>> 24 & 255;
564
564
  }
565
565
  function br(t) {
566
566
  for (let e = 0; e < t.length; e++)
567
- t[e] = mr(t[e]);
567
+ t[e] = yr(t[e]);
568
568
  return t;
569
569
  }
570
- const He = yr ? (t) => t : br;
570
+ const Ye = mr ? (t) => t : br;
571
571
  function _r(t) {
572
572
  if (typeof t != "string")
573
573
  throw new Error("string expected");
@@ -582,9 +582,9 @@ function Ar(t) {
582
582
  const e = (n) => t().update(ct(n)).digest(), r = t();
583
583
  return e.outputLen = r.outputLen, e.blockLen = r.blockLen, e.create = () => t(), e;
584
584
  }
585
- const Z = /* @__PURE__ */ BigInt(2 ** 32 - 1), Ve = /* @__PURE__ */ BigInt(32);
585
+ const Z = /* @__PURE__ */ BigInt(2 ** 32 - 1), He = /* @__PURE__ */ BigInt(32);
586
586
  function Er(t, e = !1) {
587
- return e ? { h: Number(t & Z), l: Number(t >> Ve & Z) } : { h: Number(t >> Ve & Z) | 0, l: Number(t & Z) | 0 };
587
+ return e ? { h: Number(t & Z), l: Number(t >> He & Z) } : { h: Number(t >> He & Z) | 0, l: Number(t & Z) | 0 };
588
588
  }
589
589
  function vr(t, e = !1) {
590
590
  const r = t.length;
@@ -595,7 +595,7 @@ function vr(t, e = !1) {
595
595
  }
596
596
  return [n, s];
597
597
  }
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 = [];
598
+ const xr = (t, e, r) => t << r | e >>> 32 - r, $r = (t, e, r) => e << r | t >>> 32 - r, Ir = (t, e, r) => e << r - 32 | t >>> 64 - r, Sr = (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 = [];
599
599
  for (let t = 0, e = j, r = 1, n = 0; t < 24; t++) {
600
600
  [r, n] = [n, (2 * r + 3 * n) % 5], lt.push(2 * (5 * n + r)), dt.push((t + 1) * (t + 2) / 2 % 64);
601
601
  let s = Cr;
@@ -603,20 +603,20 @@ for (let t = 0, e = j, r = 1, n = 0; t < 24; t++) {
603
603
  e = (e << j ^ (e >> Br) * Rr) % Nr, e & Pr && (s ^= j << (j << /* @__PURE__ */ BigInt(o)) - j);
604
604
  ht.push(s);
605
605
  }
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);
606
+ const ft = vr(ht, !0), Ur = ft[0], Tr = ft[1], Ve = (t, e, r) => r > 32 ? Ir(t, e, r) : xr(t, e, r), Ke = (t, e, r) => r > 32 ? Sr(t, e, r) : $r(t, e, r);
607
607
  function zr(t, e = 24) {
608
608
  const r = new Uint32Array(10);
609
609
  for (let n = 24 - e; n < 24; n++) {
610
610
  for (let i = 0; i < 10; i++)
611
611
  r[i] = t[i] ^ t[i + 10] ^ t[i + 20] ^ t[i + 30] ^ t[i + 40];
612
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];
613
+ const a = (i + 8) % 10, l = (i + 2) % 10, c = r[l], d = r[l + 1], h = Ve(c, d, 1) ^ r[a], f = Ke(c, d, 1) ^ r[a + 1];
614
614
  for (let u = 0; u < 50; u += 10)
615
615
  t[i + u] ^= h, t[i + u + 1] ^= f;
616
616
  }
617
617
  let s = t[2], o = t[3];
618
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];
619
+ const a = dt[i], l = Ve(s, o, a), c = Ke(s, o, a), d = lt[i];
620
620
  s = t[d], o = t[d + 1], t[d] = l, t[d + 1] = c;
621
621
  }
622
622
  for (let i = 0; i < 50; i += 10) {
@@ -629,10 +629,10 @@ function zr(t, e = 24) {
629
629
  }
630
630
  at(r);
631
631
  }
632
- class Se extends kr {
632
+ class $e extends kr {
633
633
  // NOTE: we accept arguments in bytes instead of bits here.
634
634
  constructor(e, r, n, s = !1, o = 24) {
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))
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, We(n), !(0 < e && e < 200))
636
636
  throw new Error("only keccak-f1600 function is supported");
637
637
  this.state = new Uint8Array(200), this.state32 = pr(this.state);
638
638
  }
@@ -640,10 +640,10 @@ class Se extends kr {
640
640
  return this._cloneInto();
641
641
  }
642
642
  keccak() {
643
- He(this.state32), zr(this.state32, this.rounds), He(this.state32), this.posOut = 0, this.pos = 0;
643
+ Ye(this.state32), zr(this.state32, this.rounds), Ye(this.state32), this.posOut = 0, this.pos = 0;
644
644
  }
645
645
  update(e) {
646
- Ye(this), e = ct(e), re(e);
646
+ je(this), e = ct(e), re(e);
647
647
  const { blockLen: r, state: n } = this, s = e.length;
648
648
  for (let o = 0; o < s; ) {
649
649
  const i = Math.min(r - this.pos, s - o);
@@ -661,7 +661,7 @@ class Se extends kr {
661
661
  e[n] ^= r, (r & 128) !== 0 && n === s - 1 && this.keccak(), e[s - 1] ^= 128, this.keccak();
662
662
  }
663
663
  writeInto(e) {
664
- Ye(this, !1), re(e), this.finish();
664
+ je(this, !1), re(e), this.finish();
665
665
  const r = this.state, { blockLen: n } = this;
666
666
  for (let s = 0, o = e.length; s < o; ) {
667
667
  this.posOut >= n && this.keccak();
@@ -676,7 +676,7 @@ class Se extends kr {
676
676
  return this.writeInto(e);
677
677
  }
678
678
  xof(e) {
679
- return je(e), this.xofInto(new Uint8Array(e));
679
+ return We(e), this.xofInto(new Uint8Array(e));
680
680
  }
681
681
  digestInto(e) {
682
682
  if (gr(e, this), this.finished)
@@ -691,17 +691,17 @@ class Se extends kr {
691
691
  }
692
692
  _cloneInto(e) {
693
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;
694
+ return e || (e = new $e(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;
695
695
  }
696
696
  }
697
- const Lr = (t, e, r) => Ar(() => new Se(e, t, r)), Dr = Lr(1, 136, 256 / 8);
697
+ const Lr = (t, e, r) => Ar(() => new $e(e, t, r)), Dr = Lr(1, 136, 256 / 8);
698
698
  let ut = !1;
699
699
  const wt = function(t) {
700
700
  return Dr(t);
701
701
  };
702
702
  let gt = wt;
703
703
  function X(t) {
704
- const e = $e(t, "data");
704
+ const e = xe(t, "data");
705
705
  return ur(gt(e));
706
706
  }
707
707
  X._ = wt;
@@ -715,12 +715,12 @@ X.register = function(t) {
715
715
  };
716
716
  Object.freeze(X);
717
717
  const Or = BigInt(0), Mr = BigInt(36);
718
- function Ge(t) {
718
+ function qe(t) {
719
719
  t = t.toLowerCase();
720
720
  const e = t.substring(2).split(""), r = new Uint8Array(40);
721
721
  for (let s = 0; s < 40; s++)
722
722
  r[s] = e[s].charCodeAt(0);
723
- const n = $e(X(r));
723
+ const n = xe(X(r));
724
724
  for (let s = 0; s < 40; s += 2)
725
725
  n[s >> 1] >> 4 >= 8 && (e[s] = e[s].toUpperCase()), (n[s >> 1] & 15) >= 8 && (e[s + 1] = e[s + 1].toUpperCase());
726
726
  return "0x" + e.join("");
@@ -730,12 +730,12 @@ for (let t = 0; t < 10; t++)
730
730
  Ie[String(t)] = String(t);
731
731
  for (let t = 0; t < 26; t++)
732
732
  Ie[String.fromCharCode(65 + t)] = String(10 + t);
733
- const Xe = 15;
733
+ const Ge = 15;
734
734
  function Qr(t) {
735
735
  t = t.toUpperCase(), t = t.substring(4) + t.substring(0, 2) + "00";
736
736
  let e = t.split("").map((n) => Ie[n]).join("");
737
- for (; e.length >= Xe; ) {
738
- let n = e.substring(0, Xe);
737
+ for (; e.length >= Ge; ) {
738
+ let n = e.substring(0, Ge);
739
739
  e = parseInt(n, 10) % 97 + e.substring(n.length);
740
740
  }
741
741
  let r = String(98 - parseInt(e, 10) % 97);
@@ -761,7 +761,7 @@ function Wr(t) {
761
761
  function N(t) {
762
762
  if (Y(typeof t == "string", "invalid address", "address", t), t.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
763
763
  t.startsWith("0x") || (t = "0x" + t);
764
- const e = Ge(t);
764
+ const e = qe(t);
765
765
  return Y(!t.match(/([A-F].*[a-f])|([a-f].*[A-F])/) || e === t, "bad address checksum", "address", t), e;
766
766
  }
767
767
  if (t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
@@ -769,7 +769,7 @@ function N(t) {
769
769
  let e = Wr(t.substring(4)).toString(16);
770
770
  for (; e.length < 40; )
771
771
  e = "0" + e;
772
- return Ge("0x" + e);
772
+ return qe("0x" + e);
773
773
  }
774
774
  Y(!1, "invalid address", "address", t);
775
775
  }
@@ -964,10 +964,10 @@ const Vr = {
964
964
  [K.StarknetChainId.SN_MAIN]: "starknet",
965
965
  [K.StarknetChainId.SN_SEPOLIA]: "starknet"
966
966
  }, fe = (t) => {
967
- const e = nt.toHex(t), r = Vr[e];
967
+ const e = rt.toHex(t), r = Vr[e];
968
968
  return r || console.warn(`Unknown chain ID: ${e}`), r;
969
969
  };
970
- class Ce {
970
+ class Se {
971
971
  platform;
972
972
  account = void 0;
973
973
  store = Hr();
@@ -1226,27 +1226,27 @@ class Ce {
1226
1226
  }
1227
1227
  }
1228
1228
  }
1229
- class Kr extends Ce {
1229
+ class Kr extends Se {
1230
1230
  type = "base";
1231
1231
  rdns = "com.coinbase.wallet";
1232
1232
  displayName = "Base Wallet";
1233
1233
  }
1234
- class qr extends Ce {
1234
+ class qr extends Se {
1235
1235
  type = "metamask";
1236
1236
  rdns = "io.metamask";
1237
1237
  displayName = "MetaMask";
1238
1238
  }
1239
1239
  /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
1240
- function Pe(t) {
1240
+ function Ce(t) {
1241
1241
  return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
1242
1242
  }
1243
1243
  function pt(t, ...e) {
1244
- if (!Pe(t))
1244
+ if (!Ce(t))
1245
1245
  throw new Error("Uint8Array expected");
1246
1246
  if (e.length > 0 && !e.includes(t.length))
1247
1247
  throw new Error("Uint8Array expected of length " + e + ", got length=" + t.length);
1248
1248
  }
1249
- function yt(t, e) {
1249
+ function mt(t, e) {
1250
1250
  return Array.isArray(e) ? e.length === 0 ? !0 : t ? e.every((r) => typeof r == "string") : e.every((r) => Number.isSafeInteger(r)) : !1;
1251
1251
  }
1252
1252
  function Gr(t) {
@@ -1268,20 +1268,20 @@ function ne(t) {
1268
1268
  throw new Error("array expected");
1269
1269
  }
1270
1270
  function se(t, e) {
1271
- if (!yt(!0, e))
1271
+ if (!mt(!0, e))
1272
1272
  throw new Error(`${t}: array of strings expected`);
1273
1273
  }
1274
- function mt(t, e) {
1275
- if (!yt(!1, e))
1274
+ function yt(t, e) {
1275
+ if (!mt(!1, e))
1276
1276
  throw new Error(`${t}: array of numbers expected`);
1277
1277
  }
1278
1278
  // @__NO_SIDE_EFFECTS__
1279
- function Be(...t) {
1279
+ function Pe(...t) {
1280
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);
1281
1281
  return { encode: n, decode: s };
1282
1282
  }
1283
1283
  // @__NO_SIDE_EFFECTS__
1284
- function Ne(t) {
1284
+ function Be(t) {
1285
1285
  const e = typeof t == "string" ? t.split("") : t, r = e.length;
1286
1286
  se("alphabet", e);
1287
1287
  const n = new Map(e.map((s, o) => [s, o]));
@@ -1301,7 +1301,7 @@ function Ne(t) {
1301
1301
  };
1302
1302
  }
1303
1303
  // @__NO_SIDE_EFFECTS__
1304
- function Re(t = "") {
1304
+ function Ne(t = "") {
1305
1305
  return W("join", t), {
1306
1306
  encode: (e) => (se("join.decode", e), e.join(t)),
1307
1307
  decode: (e) => (W("join.decode", e), e.split(t))
@@ -1331,7 +1331,7 @@ function Xr(t, e = "=") {
1331
1331
  function Jr(t) {
1332
1332
  return Gr(t), { encode: (e) => e, decode: (e) => t(e) };
1333
1333
  }
1334
- function Je(t, e, r) {
1334
+ function Xe(t, e, r) {
1335
1335
  if (e < 2)
1336
1336
  throw new Error(`convertRadix: invalid from=${e}, base cannot be less than 2`);
1337
1337
  if (r < 2)
@@ -1372,7 +1372,7 @@ const bt = (t, e) => e === 0 ? t : bt(e, t % e), oe = /* @__NO_SIDE_EFFECTS__ */
1372
1372
  t.push(2 ** e);
1373
1373
  return t;
1374
1374
  })();
1375
- function Ze(t, e, r, n) {
1375
+ function Je(t, e, r, n) {
1376
1376
  if (ne(t), e <= 0 || e > 32)
1377
1377
  throw new Error(`convertRadix2: wrong from=${e}`);
1378
1378
  if (r <= 0 || r > 32)
@@ -1405,11 +1405,11 @@ function Zr(t) {
1405
1405
  const e = 2 ** 8;
1406
1406
  return {
1407
1407
  encode: (r) => {
1408
- if (!Pe(r))
1408
+ if (!Ce(r))
1409
1409
  throw new Error("radix.encode input should be Uint8Array");
1410
- return Je(Array.from(r), e, t);
1410
+ return Xe(Array.from(r), e, t);
1411
1411
  },
1412
- decode: (r) => (mt("radix.decode", r), Uint8Array.from(Je(r, t, e)))
1412
+ decode: (r) => (yt("radix.decode", r), Uint8Array.from(Xe(r, t, e)))
1413
1413
  };
1414
1414
  }
1415
1415
  // @__NO_SIDE_EFFECTS__
@@ -1420,11 +1420,11 @@ function _t(t, e = !1) {
1420
1420
  throw new Error("radix2: carry overflow");
1421
1421
  return {
1422
1422
  encode: (r) => {
1423
- if (!Pe(r))
1423
+ if (!Ce(r))
1424
1424
  throw new Error("radix2.encode input should be Uint8Array");
1425
- return Ze(Array.from(r), 8, t, !e);
1425
+ return Je(Array.from(r), 8, t, !e);
1426
1426
  },
1427
- decode: (r) => (mt("radix2.decode", r), Uint8Array.from(Ze(r, t, 8, e)))
1427
+ decode: (r) => (yt("radix2.decode", r), Uint8Array.from(Je(r, t, 8, e)))
1428
1428
  };
1429
1429
  }
1430
1430
  const en = typeof Uint8Array.from([]).toBase64 == "function" && typeof Uint8Array.fromBase64 == "function", tn = en ? {
@@ -1434,7 +1434,7 @@ const en = typeof Uint8Array.from([]).toBase64 == "function" && typeof Uint8Arra
1434
1434
  decode(t) {
1435
1435
  return W("base64", t), Uint8Array.fromBase64(t, { lastChunkHandling: "strict" });
1436
1436
  }
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 = {
1437
+ } : /* @__PURE__ */ Pe(/* @__PURE__ */ _t(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 = {
1438
1438
  encode: (t) => new TextDecoder().decode(t),
1439
1439
  decode: (t) => new TextEncoder().encode(t)
1440
1440
  }, sn = typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", on = {
@@ -1444,12 +1444,12 @@ const en = typeof Uint8Array.from([]).toBase64 == "function" && typeof Uint8Arra
1444
1444
  decode(t) {
1445
1445
  return W("hex", t), Uint8Array.fromHex(t);
1446
1446
  }
1447
- }, we = sn ? on : /* @__PURE__ */ Be(/* @__PURE__ */ _t(4), /* @__PURE__ */ Ne("0123456789abcdef"), /* @__PURE__ */ Re(""), /* @__PURE__ */ Jr((t) => {
1447
+ }, we = sn ? on : /* @__PURE__ */ Pe(/* @__PURE__ */ _t(4), /* @__PURE__ */ Be("0123456789abcdef"), /* @__PURE__ */ Ne(""), /* @__PURE__ */ Jr((t) => {
1448
1448
  if (typeof t != "string" || t.length % 2 !== 0)
1449
1449
  throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);
1450
1450
  return t.toLowerCase();
1451
1451
  }));
1452
- function Ae(t, e) {
1452
+ function ke(t, e) {
1453
1453
  if (t.length !== e.length)
1454
1454
  return !1;
1455
1455
  for (let r = 0; r < t.length; r++)
@@ -1487,17 +1487,17 @@ const At = (t) => {
1487
1487
  return r;
1488
1488
  }
1489
1489
  };
1490
- }, A = {
1490
+ }, E = {
1491
1491
  BITS: 32,
1492
1492
  FULL_MASK: -1 >>> 0,
1493
1493
  // 1<<32 will overflow
1494
1494
  len: (t) => Math.ceil(t / 32),
1495
- create: (t) => new Uint32Array(A.len(t)),
1495
+ create: (t) => new Uint32Array(E.len(t)),
1496
1496
  clean: (t) => t.fill(0),
1497
1497
  debug: (t) => Array.from(t).map((e) => (e >>> 0).toString(2).padStart(32, "0")),
1498
1498
  checkLen: (t, e) => {
1499
- if (A.len(e) !== t.length)
1500
- throw new Error(`wrong length=${t.length}. Expected: ${A.len(e)}`);
1499
+ if (E.len(e) !== t.length)
1500
+ throw new Error(`wrong length=${t.length}. Expected: ${E.len(e)}`);
1501
1501
  },
1502
1502
  chunkLen: (t, e, r) => {
1503
1503
  if (e < 0)
@@ -1511,8 +1511,8 @@ const At = (t) => {
1511
1511
  mask: 1 << 32 - (t + e) % 32 - 1
1512
1512
  }),
1513
1513
  indices: (t, e, r = !1) => {
1514
- A.checkLen(t, e);
1515
- const { FULL_MASK: n, BITS: s } = A, o = s - e % s, i = o ? n >>> o << o : n, a = [];
1514
+ E.checkLen(t, e);
1515
+ const { FULL_MASK: n, BITS: s } = E, o = s - e % s, i = o ? n >>> o << o : n, a = [];
1516
1516
  for (let l = 0; l < t.length; l++) {
1517
1517
  let c = t[l];
1518
1518
  if (r && (c = ~c), l === t.length - 1 && (c &= i), c !== 0)
@@ -1530,19 +1530,19 @@ const At = (t) => {
1530
1530
  r === void 0 || n !== r.pos + r.length ? e.push(r = { pos: n, length: 1 }) : r.length += 1;
1531
1531
  return e;
1532
1532
  },
1533
- rangeDebug: (t, e, r = !1) => `[${A.range(A.indices(t, e, r)).map((n) => `(${n.pos}/${n.length})`).join(", ")}]`,
1533
+ rangeDebug: (t, e, r = !1) => `[${E.range(E.indices(t, e, r)).map((n) => `(${n.pos}/${n.length})`).join(", ")}]`,
1534
1534
  setRange: (t, e, r, n, s = !0) => {
1535
- A.chunkLen(e, r, n);
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;
1535
+ E.chunkLen(e, r, n);
1536
+ const { FULL_MASK: o, BITS: i } = E, a = r % i ? Math.floor(r / i) : void 0, l = r + n, c = l % i ? Math.floor(l / i) : void 0;
1537
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))
1538
+ return E.set(t, a, o >>> i - n << i - n - r, s);
1539
+ if (a !== void 0 && !E.set(t, a, o >>> r % i, s))
1540
1540
  return !1;
1541
1541
  const d = a !== void 0 ? a + 1 : r / i, h = c !== void 0 ? c : l / i;
1542
1542
  for (let f = d; f < h; f++)
1543
- if (!A.set(t, f, o, s))
1543
+ if (!E.set(t, f, o, s))
1544
1544
  return !1;
1545
- return !(c !== void 0 && a !== c && !A.set(t, c, o << i - l % i, s));
1545
+ return !(c !== void 0 && a !== c && !E.set(t, c, o << i - l % i, s));
1546
1546
  }
1547
1547
  }, D = {
1548
1548
  /**
@@ -1583,7 +1583,7 @@ const At = (t) => {
1583
1583
  return o;
1584
1584
  }
1585
1585
  };
1586
- class Ue {
1586
+ class Re {
1587
1587
  constructor(e, r = {}, n = [], s = void 0, o = 0) {
1588
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);
1589
1589
  }
@@ -1591,10 +1591,10 @@ class Ue {
1591
1591
  _enablePointers() {
1592
1592
  if (this.parent)
1593
1593
  return this.parent._enablePointers();
1594
- this.bs || (this.bs = A.create(this.data.length), A.setRange(this.bs, this.data.length, 0, this.pos, this.opts.allowMultipleReads));
1594
+ this.bs || (this.bs = E.create(this.data.length), E.setRange(this.bs, this.data.length, 0, this.pos, this.opts.allowMultipleReads));
1595
1595
  }
1596
1596
  markBytesBS(e, r) {
1597
- return this.parent ? this.parent.markBytesBS(this.parentOffset + e, r) : !r || !this.bs ? !0 : A.setRange(this.bs, this.data.length, e, r, !1);
1597
+ return this.parent ? this.parent.markBytesBS(this.parentOffset + e, r) : !r || !this.bs ? !0 : E.setRange(this.bs, this.data.length, e, r, !1);
1598
1598
  }
1599
1599
  markBytes(e) {
1600
1600
  const r = this.pos;
@@ -1626,9 +1626,9 @@ class Ue {
1626
1626
  if (this.bitPos)
1627
1627
  throw this.err(`${this.bitPos} bits left after unpack: ${we.encode(this.data.slice(this.pos))}`);
1628
1628
  if (this.bs && !this.parent) {
1629
- const e = A.indices(this.bs, this.data.length, !0);
1629
+ const e = E.indices(this.bs, this.data.length, !0);
1630
1630
  if (e.length) {
1631
- const r = A.range(e).map(({ pos: n, length: s }) => `(${n}/${s})[${we.encode(this.data.subarray(n, n + s))}]`).join(", ");
1631
+ const r = E.range(e).map(({ pos: n, length: s }) => `(${n}/${s})[${we.encode(this.data.subarray(n, n + s))}]`).join(", ");
1632
1632
  throw this.err(`unread byte ranges: ${r} (total=${this.data.length})`);
1633
1633
  } else
1634
1634
  return;
@@ -1644,7 +1644,7 @@ class Ue {
1644
1644
  offsetReader(e) {
1645
1645
  if (e > this.data.length)
1646
1646
  throw this.err("offsetReader: Unexpected end of buffer");
1647
- return new Ue(this.absBytes(e), this.opts, this.stack, this, e);
1647
+ return new Re(this.absBytes(e), this.opts, this.stack, this, e);
1648
1648
  }
1649
1649
  bytes(e, r = !1) {
1650
1650
  if (this.bitPos)
@@ -1695,7 +1695,7 @@ class Ue {
1695
1695
  for (let n = r; (n = this.data.indexOf(e[0], n)) !== -1; n++) {
1696
1696
  if (n === -1 || this.data.length - n < e.length)
1697
1697
  return;
1698
- if (Ae(e, this.data.subarray(n, n + e.length)))
1698
+ if (ke(e, this.data.subarray(n, n + e.length)))
1699
1699
  return n;
1700
1700
  }
1701
1701
  }
@@ -1767,7 +1767,7 @@ class an {
1767
1767
  }
1768
1768
  }
1769
1769
  }
1770
- const Ee = (t) => Uint8Array.from(t).reverse();
1770
+ const Ae = (t) => Uint8Array.from(t).reverse();
1771
1771
  function cn(t, e, r) {
1772
1772
  if (r) {
1773
1773
  const n = 2n ** (e - 1n);
@@ -1787,7 +1787,7 @@ function Et(t) {
1787
1787
  return t.encodeStream(r, e), r.finish();
1788
1788
  },
1789
1789
  decode: (e, r = {}) => {
1790
- const n = new Ue(e, r), s = t.decodeStream(n);
1790
+ const n = new Re(e, r), s = t.decodeStream(n);
1791
1791
  return n.finish(), s;
1792
1792
  }
1793
1793
  };
@@ -1818,7 +1818,7 @@ function vt(t, e) {
1818
1818
  }
1819
1819
  });
1820
1820
  }
1821
- const x = (t) => {
1821
+ const $ = (t) => {
1822
1822
  const e = Et(t);
1823
1823
  return t.validate ? vt(e, t.validate) : e;
1824
1824
  }, ce = (t) => O(t) && typeof t.decode == "function" && typeof t.encode == "function";
@@ -1953,7 +1953,7 @@ const wn = (t) => {
1953
1953
  if (typeof n != "boolean")
1954
1954
  throw new Error(`bigint/sized: expected boolean, got ${typeof n}`);
1955
1955
  const s = BigInt(t), o = 2n ** (8n * s - 1n);
1956
- return x({
1956
+ return $({
1957
1957
  size: n ? t : void 0,
1958
1958
  encodeStream: (i, a) => {
1959
1959
  r && a < 0 && (a = a | o);
@@ -1970,7 +1970,7 @@ const wn = (t) => {
1970
1970
  i.bytes(e ? c.reverse() : c);
1971
1971
  },
1972
1972
  decodeStream: (i) => {
1973
- const a = i.bytes(n ? t : Math.min(t, i.leftBytes)), l = e ? a : Ee(a);
1973
+ const a = i.bytes(n ? t : Math.min(t, i.leftBytes)), l = e ? a : Ae(a);
1974
1974
  let c = 0n;
1975
1975
  for (let d = 0; d < l.length; d++)
1976
1976
  c |= BigInt(l[d]) << 8n * BigInt(d);
@@ -1982,7 +1982,7 @@ const wn = (t) => {
1982
1982
  return cn(i, 8n * s, !!r), i;
1983
1983
  }
1984
1984
  });
1985
- }, b = /* @__PURE__ */ gn(8, !0), pn = (t, e) => x({
1985
+ }, A = /* @__PURE__ */ gn(8, !0), pn = (t, e) => $({
1986
1986
  size: t,
1987
1987
  encodeStream: (r, n) => r.writeView(t, (s) => e.write(s, n)),
1988
1988
  decodeStream: (r) => r.readView(t, e.read),
@@ -2011,10 +2011,10 @@ const wn = (t) => {
2011
2011
  }, ie = /* @__PURE__ */ xt(4, !1, {
2012
2012
  read: (t, e) => t.getUint32(e, !0),
2013
2013
  write: (t, e) => t.setUint32(0, e, !0)
2014
- }), $ = /* @__PURE__ */ xt(1, !1, {
2014
+ }), I = /* @__PURE__ */ xt(1, !1, {
2015
2015
  read: (t, e) => t.getUint8(e),
2016
2016
  write: (t, e) => t.setUint8(0, e)
2017
- }), ve = /* @__PURE__ */ x({
2017
+ }), Ee = /* @__PURE__ */ $({
2018
2018
  size: 1,
2019
2019
  encodeStream: (t, e) => t.byte(e ? 1 : 0),
2020
2020
  decodeStream: (t) => {
@@ -2032,10 +2032,10 @@ const wn = (t) => {
2032
2032
  if (typeof e != "boolean")
2033
2033
  throw new Error(`bytes/le: expected boolean, got ${typeof e}`);
2034
2034
  const r = At(t), n = R(t);
2035
- return x({
2035
+ return $({
2036
2036
  size: typeof t == "number" ? t : void 0,
2037
2037
  encodeStream: (s, o) => {
2038
- n || r.encodeStream(s, o.length), s.bytes(e ? Ee(o) : o), n && s.bytes(t);
2038
+ n || r.encodeStream(s, o.length), s.bytes(e ? Ae(o) : o), n && s.bytes(t);
2039
2039
  },
2040
2040
  decodeStream: (s) => {
2041
2041
  let o;
@@ -2046,7 +2046,7 @@ const wn = (t) => {
2046
2046
  o = s.bytes(i - s.pos), s.bytes(t.length);
2047
2047
  } else
2048
2048
  o = s.bytes(t === null ? s.leftBytes : r.decodeStream(s));
2049
- return e ? Ee(o) : o;
2049
+ return e ? Ae(o) : o;
2050
2050
  },
2051
2051
  validate: (s) => {
2052
2052
  if (!R(s))
@@ -2054,17 +2054,17 @@ const wn = (t) => {
2054
2054
  return s;
2055
2055
  }
2056
2056
  });
2057
- }, yn = (t, e = !1) => vt(mn(le(t, e), nn), (r) => {
2057
+ }, mn = (t, e = !1) => vt(yn(le(t, e), nn), (r) => {
2058
2058
  if (typeof r != "string")
2059
2059
  throw new Error(`expected string, got ${typeof r}`);
2060
2060
  return r;
2061
2061
  });
2062
- function mn(t, e) {
2062
+ function yn(t, e) {
2063
2063
  if (!S(t))
2064
2064
  throw new Error(`apply: invalid inner value ${t}`);
2065
2065
  if (!ce(e))
2066
2066
  throw new Error(`apply: invalid base value ${t}`);
2067
- return x({
2067
+ return $({
2068
2068
  size: t.size,
2069
2069
  encodeStream: (r, n) => {
2070
2070
  let s;
@@ -2088,7 +2088,7 @@ function mn(t, e) {
2088
2088
  function q(t, e, r) {
2089
2089
  if (!S(t) || !S(e))
2090
2090
  throw new Error(`optional: invalid flag or inner value flag=${t} inner=${e}`);
2091
- return x({
2091
+ return $({
2092
2092
  size: r !== void 0 && t.size && e.size ? t.size + e.size : void 0,
2093
2093
  encodeStream: (n, s) => {
2094
2094
  t.encodeStream(n, !!s), s ? e.encodeStream(n, s) : r !== void 0 && e.encodeStream(n, r);
@@ -2101,7 +2101,7 @@ function q(t, e, r) {
2101
2101
  });
2102
2102
  }
2103
2103
  function bn(t) {
2104
- return x({
2104
+ return $({
2105
2105
  encodeStream: (e, r) => {
2106
2106
  if (r !== t)
2107
2107
  throw new Error(`constant: invalid value ${r} (exp: ${t})`);
@@ -2126,7 +2126,7 @@ function g(t) {
2126
2126
  for (const e in t)
2127
2127
  if (!S(t[e]))
2128
2128
  throw new Error(`struct: field ${e} is not CoderType`);
2129
- return x({
2129
+ return $({
2130
2130
  size: _n(Object.values(t)),
2131
2131
  encodeStream: (e, r) => {
2132
2132
  e.pushObj(r, (n) => {
@@ -2152,7 +2152,7 @@ function te(t, e) {
2152
2152
  if (!S(e))
2153
2153
  throw new Error(`array: invalid inner value ${e}`);
2154
2154
  const r = At(typeof t == "string" ? `../${t}` : t);
2155
- return x({
2155
+ return $({
2156
2156
  size: typeof t == "number" && e.size ? t * e.size : void 0,
2157
2157
  encodeStream: (n, s) => {
2158
2158
  const o = n;
@@ -2165,7 +2165,7 @@ function te(t, e) {
2165
2165
  if (t.length > o.pos - c)
2166
2166
  return;
2167
2167
  const d = o.finish(!1).subarray(c, o.pos);
2168
- if (Ae(d.subarray(0, t.length), t))
2168
+ if (ke(d.subarray(0, t.length), t))
2169
2169
  throw o.err(`array: inner element encoding same as separator. elm=${l} data=${d}`);
2170
2170
  }
2171
2171
  });
@@ -2179,7 +2179,7 @@ function te(t, e) {
2179
2179
  ;
2180
2180
  else if (R(t))
2181
2181
  for (let i = 0; ; i++) {
2182
- if (Ae(n.bytes(t.length, !0), t)) {
2182
+ if (ke(n.bytes(t.length, !0), t)) {
2183
2183
  n.bytes(t.length);
2184
2184
  break;
2185
2185
  }
@@ -2200,7 +2200,7 @@ function te(t, e) {
2200
2200
  }
2201
2201
  });
2202
2202
  }
2203
- function Te(t, e) {
2203
+ function Ue(t, e) {
2204
2204
  if (!S(t))
2205
2205
  throw new Error(`map: invalid inner value ${t}`);
2206
2206
  if (!O(e))
@@ -2208,7 +2208,7 @@ function Te(t, e) {
2208
2208
  const r = /* @__PURE__ */ new Map();
2209
2209
  for (const n in e)
2210
2210
  r.set(e[n], n);
2211
- return x({
2211
+ return $({
2212
2212
  size: t.size,
2213
2213
  encodeStream: (n, s) => t.encodeStream(n, e[s]),
2214
2214
  decodeStream: (n) => {
@@ -2234,7 +2234,7 @@ function kn(t, e) {
2234
2234
  for (const r in e)
2235
2235
  if (!S(e[r]))
2236
2236
  throw new Error(`tag: variant ${r} is not CoderType`);
2237
- return x({
2237
+ return $({
2238
2238
  size: t.size,
2239
2239
  encodeStream: (r, n) => {
2240
2240
  const { TAG: s, data: o } = n, i = e[s];
@@ -2266,7 +2266,7 @@ function $t(t, e, r) {
2266
2266
  if (r !== void 0 && typeof r != "function")
2267
2267
  throw new Error(`padRight: wrong padFn=${typeof r}`);
2268
2268
  const n = r || An;
2269
- return x({
2269
+ return $({
2270
2270
  size: e.size ? e.size + ge(t, e.size) : void 0,
2271
2271
  encodeStream: (s, o) => {
2272
2272
  const i = s, a = i.pos;
@@ -2281,7 +2281,7 @@ function $t(t, e, r) {
2281
2281
  }
2282
2282
  });
2283
2283
  }
2284
- const En = 9, pe = H.decimal(En), V = x({
2284
+ const En = 9, pe = H.decimal(En), V = $({
2285
2285
  encodeStream: (t, e) => {
2286
2286
  if (!e)
2287
2287
  return t.byte(0);
@@ -2297,32 +2297,32 @@ const En = 9, pe = H.decimal(En), V = x({
2297
2297
  }
2298
2298
  return e;
2299
2299
  }
2300
- }), ee = yn($t(8, ie, void 0)), vn = () => {
2300
+ }), ee = mn($t(8, ie, void 0)), vn = () => {
2301
2301
  const t = le(32);
2302
- return x({
2302
+ return $({
2303
2303
  size: t.size,
2304
- encodeStream: (e, r) => t.encodeStream(e, ke.decode(r)),
2305
- decodeStream: (e) => ke.encode(t.decodeStream(e))
2304
+ encodeStream: (e, r) => t.encodeStream(e, _e.decode(r)),
2305
+ decodeStream: (e) => _e.encode(t.decodeStream(e))
2306
2306
  });
2307
- }, y = vn(), xn = g({
2308
- requiredSignatures: $,
2309
- readSigned: $,
2310
- readUnsigned: $,
2311
- keys: te(V, y),
2312
- blockhash: y,
2313
- instructions: te(V, g({ programIdx: $, keys: te(V, $), data: le(V) }))
2307
+ }, _ = vn(), xn = g({
2308
+ requiredSignatures: I,
2309
+ readSigned: I,
2310
+ readUnsigned: I,
2311
+ keys: te(V, _),
2312
+ blockhash: _,
2313
+ instructions: te(V, g({ programIdx: I, keys: te(V, I), data: le(V) }))
2314
2314
  });
2315
2315
  function $n(t) {
2316
- if (ke.decode(t).length !== 32)
2316
+ if (_e.decode(t).length !== 32)
2317
2317
  throw new Error("Invalid Solana address");
2318
2318
  }
2319
- const Sn = (t, e, r, n, s) => ({
2319
+ const In = (t, e, r, n, s) => ({
2320
2320
  sign: t < e,
2321
2321
  write: t < e - r || t >= e && t < s - n
2322
- }), et = g({
2322
+ }), Ze = g({
2323
2323
  signatures: te(V, le(64)),
2324
2324
  msg: xn
2325
- }), xe = x({
2325
+ }), ve = $({
2326
2326
  encodeStream: (t, e) => {
2327
2327
  const { msg: r, signatures: n } = e, s = {}, o = (h, f, u) => {
2328
2328
  let w = s[h] || (s[h] = { sign: !1, write: !1 });
@@ -2344,7 +2344,7 @@ const Sn = (t, e, r, n, s) => ({
2344
2344
  let l = 0, c = 0, d = 0;
2345
2345
  for (let h of a)
2346
2346
  s[h].sign && l++, !s[h].write && (s[h].sign ? c++ : d++);
2347
- et.encodeStream(t, {
2347
+ Ze.encodeStream(t, {
2348
2348
  signatures: a.filter((h) => s[h].sign).map((h) => n[h] || new Uint8Array(64)),
2349
2349
  msg: {
2350
2350
  requiredSignatures: l,
@@ -2362,7 +2362,7 @@ const Sn = (t, e, r, n, s) => ({
2362
2362
  });
2363
2363
  },
2364
2364
  decodeStream: (t) => {
2365
- const { signatures: e, msg: r } = et.decodeStream(t);
2365
+ const { signatures: e, msg: r } = Ze.decodeStream(t);
2366
2366
  if (e.length !== r.requiredSignatures)
2367
2367
  throw new Error("SOL.tx: wrong signatures length");
2368
2368
  if (r.keys.length < e.length)
@@ -2374,7 +2374,7 @@ const Sn = (t, e, r, n, s) => ({
2374
2374
  for (let o = 0; o < r.keys.length; o++)
2375
2375
  s.push({
2376
2376
  address: r.keys[o],
2377
- ...Sn(o, r.requiredSignatures, r.readSigned, r.readUnsigned, r.keys.length)
2377
+ ...In(o, r.requiredSignatures, r.readSigned, r.readUnsigned, r.keys.length)
2378
2378
  });
2379
2379
  if (!s.length)
2380
2380
  throw new Error("SOL.tx: empty accounts array");
@@ -2391,12 +2391,12 @@ const Sn = (t, e, r, n, s) => ({
2391
2391
  signatures: n
2392
2392
  };
2393
2393
  }
2394
- }), tt = {};
2395
- function ze(t, e, r) {
2396
- if (tt[t])
2394
+ }), et = {};
2395
+ function Te(t, e, r) {
2396
+ if (et[t])
2397
2397
  throw new Error("SOL: program for this address already defined");
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) => {
2398
+ const n = Ue(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
+ et[t] = (a, l) => {
2400
2400
  if (a.program !== t)
2401
2401
  throw new Error("SOL.parseInstruction: Wrong instruction program address");
2402
2402
  const { TAG: c, data: d } = o.decode(a.data), h = { type: c, info: d }, f = Object.keys(r[c].keys);
@@ -2425,9 +2425,9 @@ function ze(t, e, r) {
2425
2425
  });
2426
2426
  return i;
2427
2427
  }
2428
- const ye = "SysvarRecentB1ockHashes11111111111111111111", L = "SysvarRent111111111111111111111111111111111", St = "11111111111111111111111111111111", It = ze(St, ie, {
2428
+ const me = "SysvarRecentB1ockHashes11111111111111111111", L = "SysvarRent111111111111111111111111111111111", It = "11111111111111111111111111111111", St = Te(It, ie, {
2429
2429
  createAccount: {
2430
- coder: g({ lamports: b, space: b, owner: y }),
2430
+ coder: g({ lamports: A, space: A, owner: _ }),
2431
2431
  keys: {
2432
2432
  source: { sign: !0, write: !0 },
2433
2433
  newAccount: { sign: !0, write: !0 }
@@ -2435,22 +2435,22 @@ const ye = "SysvarRecentB1ockHashes11111111111111111111", L = "SysvarRent1111111
2435
2435
  hint: (t) => `Create new account=${t.newAccount} with balance of ${pe.encode(t.lamports)} and owner program ${t.owner}, using funding account ${t.source}`
2436
2436
  },
2437
2437
  assign: {
2438
- coder: g({ owner: y }),
2438
+ coder: g({ owner: _ }),
2439
2439
  keys: { account: { sign: !0, write: !0 } },
2440
2440
  hint: (t) => `Assign account=${t.account} to owner program=${t.owner}`
2441
2441
  },
2442
2442
  transfer: {
2443
- coder: g({ lamports: b }),
2443
+ coder: g({ lamports: A }),
2444
2444
  keys: { source: { sign: !0, write: !0 }, destination: { sign: !1, write: !0 } },
2445
2445
  hint: (t) => `Transfer ${pe.encode(t.lamports)} SOL from ${t.source} to ${t.destination}`
2446
2446
  },
2447
2447
  createAccountWithSeed: {
2448
2448
  coder: g({
2449
- base: y,
2449
+ base: _,
2450
2450
  seed: ee,
2451
- lamports: b,
2452
- space: b,
2453
- owner: y
2451
+ lamports: A,
2452
+ space: A,
2453
+ owner: _
2454
2454
  }),
2455
2455
  keys: {
2456
2456
  source: { sign: !0, write: !0 },
@@ -2462,32 +2462,32 @@ const ye = "SysvarRecentB1ockHashes11111111111111111111", L = "SysvarRent1111111
2462
2462
  coder: g({}),
2463
2463
  keys: {
2464
2464
  nonceAccount: { sign: !1, write: !0 },
2465
- _recent_bh: { address: ye, sign: !1, write: !1 },
2465
+ _recent_bh: { address: me, sign: !1, write: !1 },
2466
2466
  nonceAuthority: { sign: !0, write: !1 }
2467
2467
  },
2468
2468
  hint: (t) => `Consume nonce in nonce account=${t.nonceAccount} (owner: ${t.nonceAuthority})`
2469
2469
  },
2470
2470
  withdrawFromNonce: {
2471
- coder: g({ lamports: b }),
2471
+ coder: g({ lamports: A }),
2472
2472
  keys: {
2473
2473
  nonceAccount: { sign: !1, write: !0 },
2474
2474
  destination: { sign: !1, write: !0 },
2475
- _recent_bh: { address: ye, sign: !1, write: !1 },
2475
+ _recent_bh: { address: me, sign: !1, write: !1 },
2476
2476
  _rent: { address: L, sign: !1, write: !1 },
2477
2477
  nonceAuthority: { sign: !0, write: !1 }
2478
2478
  },
2479
2479
  hint: (t) => `Withdraw ${pe.encode(t.lamports)} SOL from nonce account=${t.nonceAccount} (owner: ${t.nonceAuthority}) to ${t.destination}`
2480
2480
  },
2481
2481
  initializeNonce: {
2482
- coder: g({ nonceAuthority: y }),
2482
+ coder: g({ nonceAuthority: _ }),
2483
2483
  keys: {
2484
2484
  nonceAccount: { sign: !1, write: !0 },
2485
- _recent_bh: { address: ye, sign: !1, write: !1 },
2485
+ _recent_bh: { address: me, sign: !1, write: !1 },
2486
2486
  _rent: { address: L, sign: !1, write: !1 }
2487
2487
  }
2488
2488
  },
2489
2489
  authorizeNonce: {
2490
- coder: g({ newAuthorized: y }),
2490
+ coder: g({ newAuthorized: _ }),
2491
2491
  keys: {
2492
2492
  nonceAccount: { sign: !1, write: !0 },
2493
2493
  nonceAuthority: { sign: !0, write: !1 }
@@ -2495,17 +2495,17 @@ const ye = "SysvarRecentB1ockHashes11111111111111111111", L = "SysvarRent1111111
2495
2495
  hint: (t) => `Change owner of nonce account=${t.nonceAccount} from ${t.nonceAuthority} to ${t.newAuthorized}`
2496
2496
  },
2497
2497
  allocate: {
2498
- coder: g({ space: b }),
2498
+ coder: g({ space: A }),
2499
2499
  keys: {
2500
2500
  account: { sign: !0, write: !0 }
2501
2501
  }
2502
2502
  },
2503
2503
  allocateWithSeed: {
2504
2504
  coder: g({
2505
- base: y,
2505
+ base: _,
2506
2506
  seed: ee,
2507
- space: b,
2508
- owner: y
2507
+ space: A,
2508
+ owner: _
2509
2509
  }),
2510
2510
  keys: {
2511
2511
  account: { sign: !1, write: !0 },
@@ -2514,9 +2514,9 @@ const ye = "SysvarRecentB1ockHashes11111111111111111111", L = "SysvarRent1111111
2514
2514
  },
2515
2515
  assignWithSeed: {
2516
2516
  coder: g({
2517
- base: y,
2517
+ base: _,
2518
2518
  seed: ee,
2519
- owner: y
2519
+ owner: _
2520
2520
  }),
2521
2521
  keys: {
2522
2522
  account: { sign: !1, write: !0 },
@@ -2525,9 +2525,9 @@ const ye = "SysvarRecentB1ockHashes11111111111111111111", L = "SysvarRent1111111
2525
2525
  },
2526
2526
  transferWithSeed: {
2527
2527
  coder: g({
2528
- lamports: b,
2528
+ lamports: A,
2529
2529
  sourceSeed: ee,
2530
- sourceOwner: y
2530
+ sourceOwner: _
2531
2531
  }),
2532
2532
  keys: {
2533
2533
  source: { sign: !1, write: !0 },
@@ -2537,20 +2537,20 @@ const ye = "SysvarRecentB1ockHashes11111111111111111111", L = "SysvarRent1111111
2537
2537
  }
2538
2538
  }), Ct = (t) => {
2539
2539
  };
2540
- Ct(It.transfer);
2541
- Ct(It.advanceNonce);
2542
- const In = Te($, {
2540
+ Ct(St.transfer);
2541
+ Ct(St.advanceNonce);
2542
+ const Sn = Ue(I, {
2543
2543
  MintTokens: 0,
2544
2544
  FreezeAccount: 1,
2545
2545
  AccountOwner: 2,
2546
2546
  CloseAccount: 3
2547
2547
  }), T = (t, e) => e[t]?.symbol || t, Pt = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
2548
- ze(Pt, $, {
2548
+ Te(Pt, I, {
2549
2549
  initializeMint: {
2550
2550
  coder: g({
2551
- decimals: $,
2552
- mintAuthority: y,
2553
- freezeAuthority: q(ve, y, "11111111111111111111111111111111")
2551
+ decimals: I,
2552
+ mintAuthority: _,
2553
+ freezeAuthority: q(Ee, _, "11111111111111111111111111111111")
2554
2554
  }),
2555
2555
  keys: {
2556
2556
  mint: { sign: !1, write: !0 },
@@ -2569,7 +2569,7 @@ ze(Pt, $, {
2569
2569
  },
2570
2570
  // TODO: multisig support?
2571
2571
  initializeMultisig: {
2572
- coder: g({ m: $ }),
2572
+ coder: g({ m: I }),
2573
2573
  keys: {
2574
2574
  account: { sign: !1, write: !0 },
2575
2575
  _rent: { address: L, sign: !1, write: !1 }
@@ -2577,7 +2577,7 @@ ze(Pt, $, {
2577
2577
  hint: (t, e) => `Initialize multi-sig token account=${t.account} with signatures=${t.m}`
2578
2578
  },
2579
2579
  transfer: {
2580
- coder: g({ amount: b }),
2580
+ coder: g({ amount: A }),
2581
2581
  keys: {
2582
2582
  source: { sign: !1, write: !0 },
2583
2583
  destination: { sign: !1, write: !0 },
@@ -2586,7 +2586,7 @@ ze(Pt, $, {
2586
2586
  hint: (t, e) => `Transfer ${t.amount} from token account=${t.source} of owner=${t.owner} to ${t.destination}`
2587
2587
  },
2588
2588
  approve: {
2589
- coder: g({ amount: b }),
2589
+ coder: g({ amount: A }),
2590
2590
  keys: {
2591
2591
  account: { sign: !1, write: !0 },
2592
2592
  delegate: { sign: !1, write: !1 },
@@ -2604,8 +2604,8 @@ ze(Pt, $, {
2604
2604
  },
2605
2605
  setAuthority: {
2606
2606
  coder: g({
2607
- authorityType: In,
2608
- newAuthority: q(ve, y, "11111111111111111111111111111111")
2607
+ authorityType: Sn,
2608
+ newAuthority: q(Ee, _, "11111111111111111111111111111111")
2609
2609
  }),
2610
2610
  keys: {
2611
2611
  account: { sign: !1, write: !0 },
@@ -2614,7 +2614,7 @@ ze(Pt, $, {
2614
2614
  hint: (t, e) => `Sets a new authority=${t.newAuthority} of a mint or account=${t.account}. Current authority=${t.currentAuthority}. Authority Type: ${t.authorityType}`
2615
2615
  },
2616
2616
  mintTo: {
2617
- coder: g({ amount: b }),
2617
+ coder: g({ amount: A }),
2618
2618
  keys: {
2619
2619
  mint: { sign: !1, write: !0 },
2620
2620
  dest: { sign: !1, write: !0 },
@@ -2622,7 +2622,7 @@ ze(Pt, $, {
2622
2622
  }
2623
2623
  },
2624
2624
  burn: {
2625
- coder: g({ amount: b }),
2625
+ coder: g({ amount: A }),
2626
2626
  keys: {
2627
2627
  account: { sign: !1, write: !0 },
2628
2628
  mint: { sign: !1, write: !0 },
@@ -2658,7 +2658,7 @@ ze(Pt, $, {
2658
2658
  hint: (t, e) => `Thaw a frozne token account=${t.account} of mint=${t.mint} using freeze_authority=${t.authority}`
2659
2659
  },
2660
2660
  transferChecked: {
2661
- coder: g({ amount: b, decimals: $ }),
2661
+ coder: g({ amount: A, decimals: I }),
2662
2662
  keys: {
2663
2663
  source: { sign: !1, write: !0 },
2664
2664
  mint: { sign: !1, write: !1 },
@@ -2668,7 +2668,7 @@ ze(Pt, $, {
2668
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}`
2669
2669
  },
2670
2670
  approveChecked: {
2671
- coder: g({ amount: b, decimals: $ }),
2671
+ coder: g({ amount: A, decimals: I }),
2672
2672
  keys: {
2673
2673
  source: { sign: !1, write: !0 },
2674
2674
  mint: { sign: !1, write: !1 },
@@ -2678,7 +2678,7 @@ ze(Pt, $, {
2678
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)}`
2679
2679
  },
2680
2680
  mintToChecked: {
2681
- coder: g({ amount: b, decimals: $ }),
2681
+ coder: g({ amount: A, decimals: I }),
2682
2682
  keys: {
2683
2683
  mint: { sign: !1, write: !0 },
2684
2684
  dest: { sign: !1, write: !0 },
@@ -2687,7 +2687,7 @@ ze(Pt, $, {
2687
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}`
2688
2688
  },
2689
2689
  burnChecked: {
2690
- coder: g({ amount: b, decimals: $ }),
2690
+ coder: g({ amount: A, decimals: I }),
2691
2691
  keys: {
2692
2692
  mint: { sign: !1, write: !0 },
2693
2693
  account: { sign: !1, write: !0 },
@@ -2696,7 +2696,7 @@ ze(Pt, $, {
2696
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}`
2697
2697
  },
2698
2698
  initializeAccount2: {
2699
- coder: g({ owner: y }),
2699
+ coder: g({ owner: _ }),
2700
2700
  keys: {
2701
2701
  account: { sign: !1, write: !0 },
2702
2702
  mint: { sign: !1, write: !1 },
@@ -2713,12 +2713,12 @@ ze(Pt, $, {
2713
2713
  g({
2714
2714
  version: ie,
2715
2715
  state: ie,
2716
- authority: y,
2717
- nonce: y,
2718
- lamportPerSignature: b
2716
+ authority: _,
2717
+ nonce: _,
2718
+ lamportPerSignature: A
2719
2719
  });
2720
2720
  const Cn = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
2721
- ze(Cn, bn(0), {
2721
+ Te(Cn, bn(0), {
2722
2722
  create: {
2723
2723
  coder: g({}),
2724
2724
  keys: {
@@ -2726,32 +2726,32 @@ ze(Cn, bn(0), {
2726
2726
  account: { sign: !1, write: !0 },
2727
2727
  wallet: { sign: !1, write: !1 },
2728
2728
  mint: { sign: !1, write: !1 },
2729
- _sys: { address: St, sign: !1, write: !1 },
2729
+ _sys: { address: It, sign: !1, write: !1 },
2730
2730
  _token: { address: Pt, sign: !1, write: !1 },
2731
2731
  _rent: { address: L, sign: !1, write: !1 }
2732
2732
  },
2733
2733
  hint: (t, e) => `Initialize associated token account=${t.account} with owner=${t.wallet} for token=${T(t.mint, e)}, payed by ${t.source}`
2734
2734
  }
2735
2735
  });
2736
- const me = $t(4, ve, () => 0);
2736
+ const ye = $t(4, Ee, () => 0);
2737
2737
  g({
2738
- mint: y,
2739
- owner: y,
2740
- amount: b,
2741
- delegate: q(me, y, "11111111111111111111111111111111"),
2742
- state: Te($, {
2738
+ mint: _,
2739
+ owner: _,
2740
+ amount: A,
2741
+ delegate: q(ye, _, "11111111111111111111111111111111"),
2742
+ state: Ue(I, {
2743
2743
  uninitialized: 0,
2744
2744
  initialized: 1,
2745
2745
  frozen: 2
2746
2746
  }),
2747
- isNative: q(me, b, 0n),
2748
- delegateAmount: b,
2749
- closeAuthority: q(me, y, "11111111111111111111111111111111")
2747
+ isNative: q(ye, A, 0n),
2748
+ delegateAmount: A,
2749
+ closeAuthority: q(ye, _, "11111111111111111111111111111111")
2750
2750
  });
2751
- function rt(t, e, r) {
2751
+ function tt(t, e, r) {
2752
2752
  if (!e.length)
2753
2753
  throw new Error("SOLPublic: empty instructions array");
2754
- return tn.encode(xe.encode({
2754
+ return tn.encode(ve.encode({
2755
2755
  msg: { feePayer: t, blockhash: r, instructions: e },
2756
2756
  signatures: {}
2757
2757
  }));
@@ -2778,22 +2778,22 @@ function Pn(t) {
2778
2778
  const u = c.length;
2779
2779
  for (; f !== u && c[f] === 0; )
2780
2780
  f++, d++;
2781
- const w = (u - f) * o + 1 >>> 0, _ = new Uint8Array(w);
2781
+ const w = (u - f) * o + 1 >>> 0, b = new Uint8Array(w);
2782
2782
  for (; f !== u; ) {
2783
2783
  let k = c[f], p = 0;
2784
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;
2785
+ k += 256 * b[v] >>> 0, b[v] = k % r >>> 0, k = k / r >>> 0;
2786
2786
  if (k !== 0)
2787
2787
  throw new Error("Non-zero carry");
2788
2788
  h = p, f++;
2789
2789
  }
2790
- let m = w - h;
2791
- for (; m !== w && _[m] === 0; )
2792
- m++;
2793
- let I = n.repeat(d);
2794
- for (; m < w; ++m)
2795
- I += t.charAt(_[m]);
2796
- return I;
2790
+ let y = w - h;
2791
+ for (; y !== w && b[y] === 0; )
2792
+ y++;
2793
+ let m = n.repeat(d);
2794
+ for (; y < w; ++y)
2795
+ m += t.charAt(b[y]);
2796
+ return m;
2797
2797
  }
2798
2798
  function a(c) {
2799
2799
  if (typeof c != "string")
@@ -2818,14 +2818,14 @@ function Pn(t) {
2818
2818
  throw new Error("Non-zero carry");
2819
2819
  f = v, d++;
2820
2820
  }
2821
- let _ = u - f;
2822
- for (; _ !== u && w[_] === 0; )
2823
- _++;
2824
- const m = new Uint8Array(h + (u - _));
2825
- let I = h;
2826
- for (; _ !== u; )
2827
- m[I++] = w[_++];
2828
- return m;
2821
+ let b = u - f;
2822
+ for (; b !== u && w[b] === 0; )
2823
+ b++;
2824
+ const y = new Uint8Array(h + (u - b));
2825
+ let m = h;
2826
+ for (; b !== u; )
2827
+ y[m++] = w[b++];
2828
+ return y;
2829
2829
  }
2830
2830
  function l(c) {
2831
2831
  const d = a(c);
@@ -2841,7 +2841,7 @@ function Pn(t) {
2841
2841
  }
2842
2842
  var Bn = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
2843
2843
  Pn(Bn);
2844
- class Le {
2844
+ class ze {
2845
2845
  _transaction;
2846
2846
  signatures = [];
2847
2847
  feePayer;
@@ -2854,15 +2854,15 @@ class Le {
2854
2854
  return this._instructions.push(...e), this;
2855
2855
  }
2856
2856
  static from(e) {
2857
- const r = e instanceof Uint8Array ? e : new Uint8Array(e), n = xe.decode(r), s = new Le();
2857
+ const r = e instanceof Uint8Array ? e : new Uint8Array(e), n = ve.decode(r), s = new ze();
2858
2858
  return s._transaction = n, s;
2859
2859
  }
2860
2860
  serialize(e) {
2861
2861
  if (this._transaction)
2862
- return Buffer.from(xe.encode(this._transaction));
2862
+ return Buffer.from(ve.encode(this._transaction));
2863
2863
  if (!this.feePayer || !this.recentBlockhash)
2864
2864
  throw new Error("Transaction requires feePayer and recentBlockhash");
2865
- const r = rt(
2865
+ const r = tt(
2866
2866
  this.feePayer.toString(),
2867
2867
  this._instructions,
2868
2868
  this.recentBlockhash
@@ -2872,7 +2872,7 @@ class Le {
2872
2872
  serializeMessage() {
2873
2873
  if (!this.feePayer || !this.recentBlockhash)
2874
2874
  throw new Error("Transaction requires feePayer and recentBlockhash");
2875
- const e = rt(
2875
+ const e = tt(
2876
2876
  this.feePayer.toString(),
2877
2877
  this._instructions,
2878
2878
  this.recentBlockhash
@@ -2948,7 +2948,7 @@ class Nn {
2948
2948
  if (!this.isAvailable() || !this.account)
2949
2949
  throw new Error("Phantom is not connected");
2950
2950
  try {
2951
- const r = Le.from(e), s = await this.getProvider().signAndSendTransaction(r);
2951
+ const r = ze.from(e), s = await this.getProvider().signAndSendTransaction(r);
2952
2952
  return {
2953
2953
  success: !0,
2954
2954
  wallet: this.type,
@@ -2990,7 +2990,7 @@ class Nn {
2990
2990
  };
2991
2991
  }
2992
2992
  }
2993
- class Rn extends Ce {
2993
+ class Rn extends Se {
2994
2994
  type = "rabby";
2995
2995
  rdns = "io.rabby";
2996
2996
  displayName = "Rabby";
@@ -3312,21 +3312,31 @@ class zn extends cr {
3312
3312
  rpcUrl: c,
3313
3313
  ref: d,
3314
3314
  refGroup: h,
3315
- ...f
3315
+ needsSessionCreation: f,
3316
+ username: u,
3317
+ onSessionCreated: w,
3318
+ encryptedBlob: b,
3319
+ ...y
3316
3320
  }) {
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(
3321
+ const m = new URL(e ?? nt), k = new Tn();
3322
+ n && m.searchParams.set("v", encodeURIComponent(n)), s && m.searchParams.set("ps", encodeURIComponent(s)), o && m.searchParams.set("ns", encodeURIComponent(o)), i?.erc20 && m.searchParams.set(
3319
3323
  "erc20",
3320
3324
  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(
3325
+ ), c && m.searchParams.set("rpc_url", encodeURIComponent(c)), d && m.searchParams.set("ref", encodeURIComponent(d)), h && m.searchParams.set("ref_group", encodeURIComponent(h)), f && m.searchParams.set("needs_session_creation", "true"), u && m.searchParams.set("username", encodeURIComponent(u)), (!a || l) && r ? m.searchParams.set(
3322
3326
  "policies",
3323
3327
  encodeURIComponent(JSON.stringify(r))
3324
- ) : a && u.searchParams.set("preset", a), super({
3325
- ...f,
3328
+ ) : a && m.searchParams.set("preset", a), b && (m.hash = `kc=${encodeURIComponent(b)}`), super({
3329
+ ...y,
3326
3330
  id: "controller-keychain",
3327
- url: u,
3328
- methods: w.getIFrameMethods()
3329
- }), this.walletBridge = w, typeof window < "u" && (window.external_wallets = this.walletBridge);
3331
+ url: m,
3332
+ methods: {
3333
+ ...k.getIFrameMethods(),
3334
+ // Expose callback for keychain to notify parent that session was created and storage access granted
3335
+ onSessionCreated: (p) => () => {
3336
+ w && w();
3337
+ }
3338
+ }
3339
+ }), this.walletBridge = k, typeof window < "u" && (window.external_wallets = this.walletBridge);
3330
3340
  }
3331
3341
  getWalletBridge() {
3332
3342
  return this.walletBridge;
@@ -3371,6 +3381,7 @@ class Qn extends zt {
3371
3381
  selectedChain;
3372
3382
  chains;
3373
3383
  referral;
3384
+ encryptedBlob;
3374
3385
  isReady() {
3375
3386
  return !!this.keychain;
3376
3387
  }
@@ -3385,22 +3396,25 @@ class Qn extends zt {
3385
3396
  if (this.referral = {
3386
3397
  ref: o?.get("ref") ?? void 0,
3387
3398
  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") {
3399
+ }, this.options = { ...e, chains: n, defaultChainId: s }, typeof window < "u" && typeof localStorage < "u") {
3396
3400
  const i = o?.get("controller_standalone");
3397
3401
  i === "1" && sessionStorage.setItem("controller_standalone", "1");
3398
3402
  const a = o?.get("lastUsedConnector");
3399
- if (a && localStorage.setItem("lastUsedConnector", a), o && window.history?.replaceState) {
3403
+ if (a && localStorage.setItem("lastUsedConnector", a), window.location.hash) {
3404
+ const c = new URLSearchParams(window.location.hash.slice(1)).get("kc");
3405
+ c && (this.encryptedBlob = c);
3406
+ }
3407
+ if (o && window.history?.replaceState) {
3400
3408
  let l = !1;
3401
- if (i && (o.delete("controller_standalone"), l = !0), a && (o.delete("lastUsedConnector"), l = !0), o.has("controller_redirect") && (o.delete("controller_redirect"), l = !0), l) {
3402
- const c = window.location.pathname + (o.toString() ? "?" + o.toString() : "") + window.location.hash;
3403
- window.history.replaceState({}, "", c);
3409
+ i && (o.delete("controller_standalone"), l = !0), a && (o.delete("lastUsedConnector"), l = !0);
3410
+ let c = window.location.hash;
3411
+ if (c) {
3412
+ const d = new URLSearchParams(c.slice(1));
3413
+ d.has("kc") && (d.delete("kc"), c = d.toString() ? `#${d.toString()}` : "", l = !0);
3414
+ }
3415
+ if (l) {
3416
+ const d = window.location.pathname + (o.toString() ? "?" + o.toString() : "") + c;
3417
+ window.history.replaceState({}, "", d);
3404
3418
  }
3405
3419
  }
3406
3420
  }
@@ -3410,7 +3424,7 @@ class Qn extends zt {
3410
3424
  }
3411
3425
  async logout() {
3412
3426
  if (!this.keychain) {
3413
- console.error(new E().message);
3427
+ console.error(new x().message);
3414
3428
  return;
3415
3429
  }
3416
3430
  try {
@@ -3428,12 +3442,12 @@ class Qn extends zt {
3428
3442
  if (this.iframes) {
3429
3443
  try {
3430
3444
  if (this.iframes.keychain || (this.iframes.keychain = this.createKeychainIframe()), await this.waitForKeychain(), !this.keychain) {
3431
- console.error(new E().message);
3445
+ console.error(new x().message);
3432
3446
  return;
3433
3447
  }
3434
3448
  const e = await this.keychain.probe(this.rpcUrl());
3435
3449
  let r = e?.rpcUrl || this.rpcUrl();
3436
- this.account = new Me(
3450
+ this.account = new Oe(
3437
3451
  this,
3438
3452
  r,
3439
3453
  e.address,
@@ -3453,15 +3467,15 @@ class Qn extends zt {
3453
3467
  if (this.account)
3454
3468
  return this.account;
3455
3469
  if (this.iframes.keychain || (this.iframes.keychain = this.createKeychainIframe(), await this.waitForKeychain()), !this.keychain || !this.iframes.keychain) {
3456
- console.error(new E().message);
3470
+ console.error(new x().message);
3457
3471
  return;
3458
3472
  }
3459
- typeof document < "u" && document.hasStorageAccess && (await document.hasStorageAccess() || await document.requestStorageAccess()), this.iframes.keychain.open();
3473
+ this.iframes.keychain.open();
3460
3474
  try {
3461
3475
  let e = await this.keychain.connect(this.options.signupOptions);
3462
3476
  if (e.code !== Q.SUCCESS)
3463
3477
  throw new Error(e.message);
3464
- return e = e, this.account = new Me(
3478
+ return e = e, this.account = new Oe(
3465
3479
  this,
3466
3480
  this.rpcUrl(),
3467
3481
  e.address,
@@ -3480,7 +3494,7 @@ class Qn extends zt {
3480
3494
  if (!this.iframes)
3481
3495
  return !1;
3482
3496
  if (!this.keychain || !this.iframes.keychain)
3483
- return console.error(new E().message), !1;
3497
+ return console.error(new x().message), !1;
3484
3498
  const r = this.selectedChain;
3485
3499
  try {
3486
3500
  this.selectedChain = e, await this.keychain.switchChain(this.rpcUrl());
@@ -3494,16 +3508,16 @@ class Qn extends zt {
3494
3508
  }
3495
3509
  async disconnect() {
3496
3510
  if (!this.keychain) {
3497
- console.error(new E().message);
3511
+ console.error(new x().message);
3498
3512
  return;
3499
3513
  }
3500
- return typeof document < "u" && document.hasStorageAccess && (await document.hasStorageAccess() || await document.requestStorageAccess()), this.account = void 0, this.keychain.disconnect();
3514
+ return this.account = void 0, this.keychain.disconnect();
3501
3515
  }
3502
3516
  async openProfile(e = "inventory") {
3503
3517
  if (!this.iframes)
3504
3518
  return;
3505
3519
  if (!this.keychain || !this.iframes.keychain) {
3506
- console.error(new E().message);
3520
+ console.error(new x().message);
3507
3521
  return;
3508
3522
  }
3509
3523
  if (!this.account) {
@@ -3519,7 +3533,7 @@ class Qn extends zt {
3519
3533
  if (!this.iframes)
3520
3534
  return;
3521
3535
  if (!this.keychain || !this.iframes.keychain) {
3522
- console.error(new E().message);
3536
+ console.error(new x().message);
3523
3537
  return;
3524
3538
  }
3525
3539
  if (!this.account) {
@@ -3534,7 +3548,7 @@ class Qn extends zt {
3534
3548
  async openProfileAt(e) {
3535
3549
  if (this.iframes) {
3536
3550
  if (!this.keychain || !this.iframes.keychain) {
3537
- console.error(new E().message);
3551
+ console.error(new x().message);
3538
3552
  return;
3539
3553
  }
3540
3554
  if (!this.account) {
@@ -3547,30 +3561,30 @@ class Qn extends zt {
3547
3561
  openSettings() {
3548
3562
  if (this.iframes) {
3549
3563
  if (!this.keychain || !this.iframes.keychain) {
3550
- console.error(new E().message);
3564
+ console.error(new x().message);
3551
3565
  return;
3552
3566
  }
3553
3567
  this.iframes.keychain.open(), this.keychain.openSettings();
3554
3568
  }
3555
3569
  }
3556
3570
  revoke(e, r) {
3557
- return this.keychain ? this.keychain.revoke(e) : (console.error(new E().message), null);
3571
+ return this.keychain ? this.keychain.revoke(e) : (console.error(new x().message), null);
3558
3572
  }
3559
3573
  rpcUrl() {
3560
3574
  const e = this.chains.get(this.selectedChain);
3561
3575
  if (!e) {
3562
3576
  const r = Array.from(this.chains.keys()).map(
3563
- (n) => Oe.decodeShortString(n)
3577
+ (n) => De.decodeShortString(n)
3564
3578
  );
3565
3579
  throw new Error(
3566
- `Chain not found: ${Oe.decodeShortString(this.selectedChain)}. Available chains: ${r.join(", ")}`
3580
+ `Chain not found: ${De.decodeShortString(this.selectedChain)}. Available chains: ${r.join(", ")}`
3567
3581
  );
3568
3582
  }
3569
3583
  return e.rpcUrl;
3570
3584
  }
3571
3585
  username() {
3572
3586
  if (!this.keychain) {
3573
- console.error(new E().message);
3587
+ console.error(new x().message);
3574
3588
  return;
3575
3589
  }
3576
3590
  return this.keychain.username();
@@ -3578,7 +3592,7 @@ class Qn extends zt {
3578
3592
  openPurchaseCredits() {
3579
3593
  if (this.iframes) {
3580
3594
  if (!this.keychain || !this.iframes.keychain) {
3581
- console.error(new E().message);
3595
+ console.error(new x().message);
3582
3596
  return;
3583
3597
  }
3584
3598
  this.keychain.navigate("/purchase/credits").then(() => {
@@ -3589,7 +3603,7 @@ class Qn extends zt {
3589
3603
  async openStarterPack(e, r) {
3590
3604
  if (this.iframes) {
3591
3605
  if (!this.keychain || !this.iframes.keychain) {
3592
- console.error(new E().message);
3606
+ console.error(new x().message);
3593
3607
  return;
3594
3608
  }
3595
3609
  await this.keychain.openStarterPack(e, r), this.iframes.keychain?.open();
@@ -3599,7 +3613,7 @@ class Qn extends zt {
3599
3613
  if (!this.iframes)
3600
3614
  return;
3601
3615
  if (!this.keychain || !this.iframes.keychain) {
3602
- console.error(new E().message);
3616
+ console.error(new x().message);
3603
3617
  return;
3604
3618
  }
3605
3619
  let n = this.selectedChain;
@@ -3611,7 +3625,7 @@ class Qn extends zt {
3611
3625
  };
3612
3626
  }
3613
3627
  async delegateAccount() {
3614
- return this.keychain ? await this.keychain.delegateAccount() : (console.error(new E().message), null);
3628
+ return this.keychain ? await this.keychain.delegateAccount() : (console.error(new x().message), null);
3615
3629
  }
3616
3630
  /**
3617
3631
  * Opens the keychain in standalone mode (first-party context) for authentication.
@@ -3623,7 +3637,7 @@ class Qn extends zt {
3623
3637
  console.error("open can only be called in browser context");
3624
3638
  return;
3625
3639
  }
3626
- const r = new URL(this.options.url || be), n = e.redirectUrl || window.location.href, s = Ln(n);
3640
+ const r = new URL(this.options.url || nt), n = e.redirectUrl || window.location.href, s = Ln(n);
3627
3641
  if (!s.isValid) {
3628
3642
  console.error(
3629
3643
  `Invalid redirect URL: ${s.error}`,
@@ -3636,20 +3650,6 @@ class Qn extends zt {
3636
3650
  this.options.tokens.erc20.toString()
3637
3651
  ), this.rpcUrl() && r.searchParams.set("rpc_url", this.rpcUrl()), window.location.href = r.toString();
3638
3652
  }
3639
- /**
3640
- * Checks if the keychain iframe has first-party storage access.
3641
- * Returns true if the user has previously authenticated via standalone mode.
3642
- * @returns Promise<boolean> indicating if storage access is available
3643
- */
3644
- async hasFirstPartyAccess() {
3645
- if (!this.keychain)
3646
- return console.error(new E().message), !1;
3647
- try {
3648
- return await this.keychain.hasStorageAccess();
3649
- } catch (e) {
3650
- return console.error("Error checking storage access:", e), !1;
3651
- }
3652
- }
3653
3653
  initializeChains(e) {
3654
3654
  for (const r of e)
3655
3655
  try {
@@ -3667,22 +3667,28 @@ class Qn extends zt {
3667
3667
  );
3668
3668
  }
3669
3669
  createKeychainIframe() {
3670
- return new zn({
3670
+ const e = typeof window < "u" && typeof sessionStorage < "u" && sessionStorage.getItem("controller_standalone") === "1", n = (typeof window < "u" ? new URLSearchParams(window.location.search) : void 0)?.get("username") ?? void 0, s = this.encryptedBlob;
3671
+ e && sessionStorage.removeItem("controller_standalone"), s && (this.encryptedBlob = void 0);
3672
+ const o = new zn({
3671
3673
  ...this.options,
3672
3674
  rpcUrl: this.rpcUrl(),
3673
3675
  onClose: this.keychain?.reset,
3674
- onConnect: (e) => {
3675
- this.keychain = e, typeof window < "u" && typeof sessionStorage < "u" && sessionStorage.getItem("controller_standalone") === "1" && (sessionStorage.removeItem("controller_standalone"), this.keychain.requestStorageAccess && this.keychain.requestStorageAccess().catch((n) => {
3676
- console.warn(
3677
- "Failed to request storage access after redirect:",
3678
- n
3679
- );
3680
- }));
3676
+ onConnect: (i) => {
3677
+ this.keychain = i;
3681
3678
  },
3682
3679
  version: Dt,
3683
3680
  ref: this.referral.ref,
3684
- refGroup: this.referral.refGroup
3681
+ refGroup: this.referral.refGroup,
3682
+ needsSessionCreation: e,
3683
+ encryptedBlob: s ?? void 0,
3684
+ username: n,
3685
+ onSessionCreated: async () => {
3686
+ await this.probe();
3687
+ }
3685
3688
  });
3689
+ return e && setTimeout(() => {
3690
+ o.open();
3691
+ }, 100), o;
3686
3692
  }
3687
3693
  waitForKeychain({
3688
3694
  timeout: e = 5e4,
@@ -3723,7 +3729,7 @@ async function Fn(t) {
3723
3729
  );
3724
3730
  }
3725
3731
  async function Wn(t) {
3726
- t = t.map(nt.toHex);
3732
+ t = t.map(rt.toHex);
3727
3733
  const e = t.filter((r) => !F.has(r));
3728
3734
  return e.length > 0 && (await Bt({
3729
3735
  addresses: e
@@ -4321,7 +4327,7 @@ var Dn = [
4321
4327
  icon: "icon.svg"
4322
4328
  }
4323
4329
  }, ae = "https://static.cartridge.gg/presets";
4324
- async function De() {
4330
+ async function Le() {
4325
4331
  try {
4326
4332
  const t = await fetch(`${ae}/index.json`);
4327
4333
  if (!t.ok)
@@ -4332,11 +4338,11 @@ async function De() {
4332
4338
  }
4333
4339
  }
4334
4340
  async function jn() {
4335
- return (await De()).configs;
4341
+ return (await Le()).configs;
4336
4342
  }
4337
4343
  async function Yn(t) {
4338
4344
  try {
4339
- const n = `${(await De()).baseUrl || ae}/${t}`, s = await fetch(`${n}/config.json`);
4345
+ const n = `${(await Le()).baseUrl || ae}/${t}`, s = await fetch(`${n}/config.json`);
4340
4346
  if (!s.ok)
4341
4347
  throw new Error(
4342
4348
  `Failed to load config ${t}: ${s.statusText}`
@@ -4367,7 +4373,7 @@ async function Yn(t) {
4367
4373
  }
4368
4374
  }
4369
4375
  async function Hn() {
4370
- const t = await De(), e = t.configs, r = t.baseUrl || ae, n = {};
4376
+ const t = await Le(), e = t.configs, r = t.baseUrl || ae, n = {};
4371
4377
  return await Promise.all(
4372
4378
  e.map(async (s) => {
4373
4379
  try {
@@ -4393,11 +4399,11 @@ export {
4393
4399
  Zn as EMBEDDED_WALLETS,
4394
4400
  es as EXTERNAL_WALLETS,
4395
4401
  ts as EXTRA_EXTERNAL_WALLETS,
4396
- Ce as EthereumWalletBase,
4402
+ Se as EthereumWalletBase,
4397
4403
  rs as FeeSource,
4398
4404
  ns as IMPLEMENTED_AUTH_OPTIONS,
4399
4405
  qr as MetaMaskWallet,
4400
- E as NotReadyToConnect,
4406
+ x as NotReadyToConnect,
4401
4407
  Nn as PhantomWallet,
4402
4408
  Rn as RabbyWallet,
4403
4409
  Q as ResponseCodes,
@@ -4407,7 +4413,7 @@ export {
4407
4413
  Kn as defaultTheme,
4408
4414
  Vn as erc20Metadata,
4409
4415
  jn as getAvailableConfigs,
4410
- De as getConfigsIndex,
4416
+ Le as getConfigsIndex,
4411
4417
  ss as humanizeString,
4412
4418
  Tt as isMobile,
4413
4419
  Hn as loadAllConfigs,