@cartridge/controller 0.13.4 → 0.13.5

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,466 @@
1
- import { WalletAccount as Ht, constants as ve, num as lt, shortString as He } from "starknet";
2
- import { R, t as jt, i as Yt, K as dt, B as Wt, N as A, p as Vt, v as qt, A as Zt, s as ht } from "./provider-DSqqvDee.js";
3
- import { a as Mo, d as zo, E as Oo, f as Do, e as Fo, F as Qo, I as Ho, h as jo, n as Yo, b as Wo, c as Vo } from "./provider-DSqqvDee.js";
4
- class je extends Ht {
1
+ import { WalletAccount as Er, constants as Ue, num as Tt, shortString as ut } from "starknet";
2
+ import { R as z, t as _r, i as Ar, K as Rt, B as Sr, N as I, H as he, p as Ir, v as $r, A as Lr, s as Ut } from "./provider-NKp7_oNj.js";
3
+ import { b as Ro, f as Uo, E as Mo, j as zo, g as Oo, F as Do, a as Fo, c as Qo, I as jo, h as Ho, n as Wo, d as Yo, e as Vo } from "./provider-NKp7_oNj.js";
4
+ const Pr = "standard:connect", Nr = "standard:disconnect", Br = "standard:events", Tr = "0.1.1";
5
+ function Rr() {
6
+ return Tr;
7
+ }
8
+ class oe extends Error {
9
+ constructor(e, r = {}) {
10
+ const n = (() => {
11
+ if (r.cause instanceof oe) {
12
+ if (r.cause.details)
13
+ return r.cause.details;
14
+ if (r.cause.shortMessage)
15
+ return r.cause.shortMessage;
16
+ }
17
+ return r.cause?.message ? r.cause.message : r.details;
18
+ })(), s = r.cause instanceof oe && r.cause.docsPath || r.docsPath, a = `https://oxlib.sh${s ?? ""}`, i = [
19
+ e || "An error occurred.",
20
+ ...r.metaMessages ? ["", ...r.metaMessages] : [],
21
+ ...n || s ? [
22
+ "",
23
+ n ? `Details: ${n}` : void 0,
24
+ s ? `See: ${a}` : void 0
25
+ ] : []
26
+ ].filter((l) => typeof l == "string").join(`
27
+ `);
28
+ super(i, r.cause ? { cause: r.cause } : void 0), Object.defineProperty(this, "details", {
29
+ enumerable: !0,
30
+ configurable: !0,
31
+ writable: !0,
32
+ value: void 0
33
+ }), Object.defineProperty(this, "docs", {
34
+ enumerable: !0,
35
+ configurable: !0,
36
+ writable: !0,
37
+ value: void 0
38
+ }), Object.defineProperty(this, "docsPath", {
39
+ enumerable: !0,
40
+ configurable: !0,
41
+ writable: !0,
42
+ value: void 0
43
+ }), Object.defineProperty(this, "shortMessage", {
44
+ enumerable: !0,
45
+ configurable: !0,
46
+ writable: !0,
47
+ value: void 0
48
+ }), Object.defineProperty(this, "cause", {
49
+ enumerable: !0,
50
+ configurable: !0,
51
+ writable: !0,
52
+ value: void 0
53
+ }), Object.defineProperty(this, "name", {
54
+ enumerable: !0,
55
+ configurable: !0,
56
+ writable: !0,
57
+ value: "BaseError"
58
+ }), Object.defineProperty(this, "version", {
59
+ enumerable: !0,
60
+ configurable: !0,
61
+ writable: !0,
62
+ value: `ox@${Rr()}`
63
+ }), this.cause = r.cause, this.details = n, this.docs = a, this.docsPath = s, this.shortMessage = e;
64
+ }
65
+ walk(e) {
66
+ return Mt(this, e);
67
+ }
68
+ }
69
+ function Mt(t, e) {
70
+ return e?.(t) ? t : t && typeof t == "object" && "cause" in t && t.cause ? Mt(t.cause, e) : e ? null : t;
71
+ }
72
+ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
73
+ function Ur(t) {
74
+ return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
75
+ }
76
+ function pt(t) {
77
+ if (!Number.isSafeInteger(t) || t < 0)
78
+ throw new Error("positive integer expected, got " + t);
79
+ }
80
+ function ge(t, ...e) {
81
+ if (!Ur(t))
82
+ throw new Error("Uint8Array expected");
83
+ if (e.length > 0 && !e.includes(t.length))
84
+ throw new Error("Uint8Array expected of length " + e + ", got length=" + t.length);
85
+ }
86
+ function gt(t, e = !0) {
87
+ if (t.destroyed)
88
+ throw new Error("Hash instance has been destroyed");
89
+ if (e && t.finished)
90
+ throw new Error("Hash#digest() has already been called");
91
+ }
92
+ function Mr(t, e) {
93
+ ge(t);
94
+ const r = e.outputLen;
95
+ if (t.length < r)
96
+ throw new Error("digestInto() expects output buffer of length at least " + r);
97
+ }
98
+ function zr(t) {
99
+ return new Uint32Array(t.buffer, t.byteOffset, Math.floor(t.byteLength / 4));
100
+ }
101
+ function zt(...t) {
102
+ for (let e = 0; e < t.length; e++)
103
+ t[e].fill(0);
104
+ }
105
+ const Or = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
106
+ function Dr(t) {
107
+ return t << 24 & 4278190080 | t << 8 & 16711680 | t >>> 8 & 65280 | t >>> 24 & 255;
108
+ }
109
+ function Fr(t) {
110
+ for (let e = 0; e < t.length; e++)
111
+ t[e] = Dr(t[e]);
112
+ return t;
113
+ }
114
+ const mt = Or ? (t) => t : Fr;
115
+ function Qr(t) {
116
+ if (typeof t != "string")
117
+ throw new Error("string expected");
118
+ return new Uint8Array(new TextEncoder().encode(t));
119
+ }
120
+ function Ot(t) {
121
+ return typeof t == "string" && (t = Qr(t)), ge(t), t;
122
+ }
123
+ class jr {
124
+ }
125
+ function Hr(t) {
126
+ const e = (n) => t().update(Ot(n)).digest(), r = t();
127
+ return e.outputLen = r.outputLen, e.blockLen = r.blockLen, e.create = () => t(), e;
128
+ }
129
+ const fe = /* @__PURE__ */ BigInt(2 ** 32 - 1), wt = /* @__PURE__ */ BigInt(32);
130
+ function Wr(t, e = !1) {
131
+ return e ? { h: Number(t & fe), l: Number(t >> wt & fe) } : { h: Number(t >> wt & fe) | 0, l: Number(t & fe) | 0 };
132
+ }
133
+ function Yr(t, e = !1) {
134
+ const r = t.length;
135
+ let n = new Uint32Array(r), s = new Uint32Array(r);
136
+ for (let o = 0; o < r; o++) {
137
+ const { h: a, l: i } = Wr(t[o], e);
138
+ [n[o], s[o]] = [a, i];
139
+ }
140
+ return [n, s];
141
+ }
142
+ const Vr = (t, e, r) => t << r | e >>> 32 - r, qr = (t, e, r) => e << r | t >>> 32 - r, Kr = (t, e, r) => e << r - 32 | t >>> 64 - r, Zr = (t, e, r) => t << r - 32 | e >>> 64 - r, Gr = BigInt(0), ee = BigInt(1), Xr = BigInt(2), Jr = BigInt(7), en = BigInt(256), tn = BigInt(113), Dt = [], Ft = [], Qt = [];
143
+ for (let t = 0, e = ee, r = 1, n = 0; t < 24; t++) {
144
+ [r, n] = [n, (2 * r + 3 * n) % 5], Dt.push(2 * (5 * n + r)), Ft.push((t + 1) * (t + 2) / 2 % 64);
145
+ let s = Gr;
146
+ for (let o = 0; o < 7; o++)
147
+ e = (e << ee ^ (e >> Jr) * tn) % en, e & Xr && (s ^= ee << (ee << /* @__PURE__ */ BigInt(o)) - ee);
148
+ Qt.push(s);
149
+ }
150
+ const jt = Yr(Qt, !0), rn = jt[0], nn = jt[1], yt = (t, e, r) => r > 32 ? Kr(t, e, r) : Vr(t, e, r), bt = (t, e, r) => r > 32 ? Zr(t, e, r) : qr(t, e, r);
151
+ function sn(t, e = 24) {
152
+ const r = new Uint32Array(10);
153
+ for (let n = 24 - e; n < 24; n++) {
154
+ for (let a = 0; a < 10; a++)
155
+ r[a] = t[a] ^ t[a + 10] ^ t[a + 20] ^ t[a + 30] ^ t[a + 40];
156
+ for (let a = 0; a < 10; a += 2) {
157
+ const i = (a + 8) % 10, l = (a + 2) % 10, c = r[l], d = r[l + 1], h = yt(c, d, 1) ^ r[i], f = bt(c, d, 1) ^ r[i + 1];
158
+ for (let u = 0; u < 50; u += 10)
159
+ t[a + u] ^= h, t[a + u + 1] ^= f;
160
+ }
161
+ let s = t[2], o = t[3];
162
+ for (let a = 0; a < 24; a++) {
163
+ const i = Ft[a], l = yt(s, o, i), c = bt(s, o, i), d = Dt[a];
164
+ s = t[d], o = t[d + 1], t[d] = l, t[d + 1] = c;
165
+ }
166
+ for (let a = 0; a < 50; a += 10) {
167
+ for (let i = 0; i < 10; i++)
168
+ r[i] = t[a + i];
169
+ for (let i = 0; i < 10; i++)
170
+ t[a + i] ^= ~r[(i + 2) % 10] & r[(i + 4) % 10];
171
+ }
172
+ t[0] ^= rn[n], t[1] ^= nn[n];
173
+ }
174
+ zt(r);
175
+ }
176
+ class Ge extends jr {
177
+ // NOTE: we accept arguments in bytes instead of bits here.
178
+ constructor(e, r, n, s = !1, o = 24) {
179
+ 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, pt(n), !(0 < e && e < 200))
180
+ throw new Error("only keccak-f1600 function is supported");
181
+ this.state = new Uint8Array(200), this.state32 = zr(this.state);
182
+ }
183
+ clone() {
184
+ return this._cloneInto();
185
+ }
186
+ keccak() {
187
+ mt(this.state32), sn(this.state32, this.rounds), mt(this.state32), this.posOut = 0, this.pos = 0;
188
+ }
189
+ update(e) {
190
+ gt(this), e = Ot(e), ge(e);
191
+ const { blockLen: r, state: n } = this, s = e.length;
192
+ for (let o = 0; o < s; ) {
193
+ const a = Math.min(r - this.pos, s - o);
194
+ for (let i = 0; i < a; i++)
195
+ n[this.pos++] ^= e[o++];
196
+ this.pos === r && this.keccak();
197
+ }
198
+ return this;
199
+ }
200
+ finish() {
201
+ if (this.finished)
202
+ return;
203
+ this.finished = !0;
204
+ const { state: e, suffix: r, pos: n, blockLen: s } = this;
205
+ e[n] ^= r, (r & 128) !== 0 && n === s - 1 && this.keccak(), e[s - 1] ^= 128, this.keccak();
206
+ }
207
+ writeInto(e) {
208
+ gt(this, !1), ge(e), this.finish();
209
+ const r = this.state, { blockLen: n } = this;
210
+ for (let s = 0, o = e.length; s < o; ) {
211
+ this.posOut >= n && this.keccak();
212
+ const a = Math.min(n - this.posOut, o - s);
213
+ e.set(r.subarray(this.posOut, this.posOut + a), s), this.posOut += a, s += a;
214
+ }
215
+ return e;
216
+ }
217
+ xofInto(e) {
218
+ if (!this.enableXOF)
219
+ throw new Error("XOF is not possible for this instance");
220
+ return this.writeInto(e);
221
+ }
222
+ xof(e) {
223
+ return pt(e), this.xofInto(new Uint8Array(e));
224
+ }
225
+ digestInto(e) {
226
+ if (Mr(e, this), this.finished)
227
+ throw new Error("digest() was already called");
228
+ return this.writeInto(e), this.destroy(), e;
229
+ }
230
+ digest() {
231
+ return this.digestInto(new Uint8Array(this.outputLen));
232
+ }
233
+ destroy() {
234
+ this.destroyed = !0, zt(this.state);
235
+ }
236
+ _cloneInto(e) {
237
+ const { blockLen: r, suffix: n, outputLen: s, rounds: o, enableXOF: a } = this;
238
+ return e || (e = new Ge(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;
239
+ }
240
+ }
241
+ const on = (t, e, r) => Hr(() => new Ge(e, t, r)), an = on(1, 136, 256 / 8), cn = "#__bigint";
242
+ function ln(t, e, r) {
243
+ return JSON.stringify(t, (n, s) => typeof s == "bigint" ? s.toString() + cn : s, r);
244
+ }
245
+ function dn(t, e = {}) {
246
+ const { strict: r = !1 } = e;
247
+ if (!t)
248
+ throw new Ct(t);
249
+ if (typeof t != "string")
250
+ throw new Ct(t);
251
+ if (r && !/^0x[0-9a-fA-F]*$/.test(t))
252
+ throw new xt(t);
253
+ if (!t.startsWith("0x"))
254
+ throw new xt(t);
255
+ }
256
+ function Ht(t, e = {}) {
257
+ const { strict: r = !1 } = e;
258
+ try {
259
+ return dn(t, { strict: r }), !0;
260
+ } catch {
261
+ return !1;
262
+ }
263
+ }
264
+ class Ct extends oe {
265
+ constructor(e) {
266
+ super(`Value \`${typeof e == "object" ? ln(e) : e}\` of type \`${typeof e}\` is an invalid hex type.`, {
267
+ metaMessages: ['Hex types must be represented as `"0x${string}"`.']
268
+ }), Object.defineProperty(this, "name", {
269
+ enumerable: !0,
270
+ configurable: !0,
271
+ writable: !0,
272
+ value: "Hex.InvalidHexTypeError"
273
+ });
274
+ }
275
+ }
276
+ class xt extends oe {
277
+ constructor(e) {
278
+ super(`Value \`${e}\` is an invalid hex value.`, {
279
+ metaMessages: [
280
+ 'Hex values must start with `"0x"` and contain only hexadecimal characters (0-9, a-f, A-F).'
281
+ ]
282
+ }), Object.defineProperty(this, "name", {
283
+ enumerable: !0,
284
+ configurable: !0,
285
+ writable: !0,
286
+ value: "Hex.InvalidHexValueError"
287
+ });
288
+ }
289
+ }
290
+ const hn = "starknet:";
291
+ class fn extends Error {
292
+ constructor(e) {
293
+ super(e), this.name = "StarknetChainError";
294
+ }
295
+ }
296
+ const un = [
297
+ "starknet:0x534e5f4d41494e",
298
+ // mainnet
299
+ "starknet:0x534e5f5345504f4c4941"
300
+ // sepolia
301
+ ];
302
+ function Wt(t) {
303
+ const e = t.split(":");
304
+ return e.length !== 2 || e[0] !== "starknet" ? !1 : Ht(e[1]);
305
+ }
306
+ function Yt(t) {
307
+ if (!Ht(t))
308
+ throw new fn(`Invalid Starknet chain id: ${t}`);
309
+ return `${hn}${t}`;
310
+ }
311
+ const pn = "starknet:walletApi";
312
+ var Xe = (t, e, r) => {
313
+ if (!e.has(t))
314
+ throw TypeError("Cannot " + r);
315
+ }, E = (t, e, r) => (Xe(t, e, "read from private field"), r ? r.call(t) : e.get(t)), B = (t, e, r) => {
316
+ if (e.has(t))
317
+ throw TypeError("Cannot add the same private member more than once");
318
+ e instanceof WeakSet ? e.add(t) : e.set(t, r);
319
+ }, me = (t, e, r, n) => (Xe(t, e, "write to private field"), e.set(t, r), r), $ = (t, e, r) => (Xe(t, e, "access private method"), r), O, S, Me, ze, Oe, Y, X, De, Vt, ae, ke, Fe, qt, Qe, Kt, we, Je, je, Zt, et, Gt;
320
+ class gn {
321
+ constructor(e) {
322
+ this.injected = e, B(this, Y), B(this, De), B(this, ae), B(this, Fe), B(this, Qe), B(this, we), B(this, je), B(this, et), B(this, O, {}), B(this, S, null), B(this, Me, async ({ silent: r }) => {
323
+ if (!E(this, S)) {
324
+ const n = await this.injected.request({
325
+ type: "wallet_requestAccounts",
326
+ params: {
327
+ silent_mode: r
328
+ }
329
+ });
330
+ if (n.length === 0)
331
+ return { accounts: [] };
332
+ await $(this, we, Je).call(this, n);
333
+ }
334
+ return { accounts: this.accounts };
335
+ }), B(this, ze, async () => {
336
+ $(this, ae, ke).call(this);
337
+ }), B(this, Oe, (r, n) => (E(this, O)[r] || (E(this, O)[r] = []), E(this, O)[r].push(n), () => $(this, De, Vt).call(this, r, n))), this.injected.on("accountsChanged", $(this, Fe, qt).bind(this)), this.injected.on("networkChanged", $(this, Qe, Kt).bind(this));
338
+ }
339
+ get version() {
340
+ return "1.0.0";
341
+ }
342
+ get name() {
343
+ return this.injected.name;
344
+ }
345
+ get icon() {
346
+ return typeof this.injected.icon == "string" ? this.injected.icon : this.injected.icon.light;
347
+ }
348
+ get features() {
349
+ return {
350
+ [Pr]: {
351
+ version: "1.0.0",
352
+ connect: E(this, Me).bind(this)
353
+ },
354
+ [Nr]: {
355
+ version: "1.0.0",
356
+ disconnect: E(this, ze).bind(this)
357
+ },
358
+ [Br]: {
359
+ version: "1.0.0",
360
+ on: E(this, Oe).bind(this)
361
+ },
362
+ [pn]: {
363
+ version: "1.0.0",
364
+ request: $(this, je, Zt).bind(this),
365
+ walletVersion: this.injected.version
366
+ }
367
+ };
368
+ }
369
+ get chains() {
370
+ return un.slice();
371
+ }
372
+ get accounts() {
373
+ return E(this, S) ? [
374
+ {
375
+ address: E(this, S).address,
376
+ publicKey: new Uint8Array(),
377
+ chains: [E(this, S).chain],
378
+ features: []
379
+ }
380
+ ] : [];
381
+ }
382
+ }
383
+ O = /* @__PURE__ */ new WeakMap();
384
+ S = /* @__PURE__ */ new WeakMap();
385
+ Me = /* @__PURE__ */ new WeakMap();
386
+ ze = /* @__PURE__ */ new WeakMap();
387
+ Oe = /* @__PURE__ */ new WeakMap();
388
+ Y = /* @__PURE__ */ new WeakSet();
389
+ X = function(t, ...e) {
390
+ if (E(this, O)[t])
391
+ for (const r of E(this, O)[t])
392
+ r.apply(null, e);
393
+ };
394
+ De = /* @__PURE__ */ new WeakSet();
395
+ Vt = function(t, e) {
396
+ E(this, O)[t] = E(this, O)[t]?.filter(
397
+ (r) => e !== r
398
+ );
399
+ };
400
+ ae = /* @__PURE__ */ new WeakSet();
401
+ ke = function() {
402
+ E(this, S) && (me(this, S, null), $(this, Y, X).call(this, "change", { accounts: this.accounts }));
403
+ };
404
+ Fe = /* @__PURE__ */ new WeakSet();
405
+ qt = async function(t) {
406
+ if (!t || t.length === 0) {
407
+ $(this, ae, ke).call(this);
408
+ return;
409
+ }
410
+ E(this, S) && await $(this, we, Je).call(this, t);
411
+ };
412
+ Qe = /* @__PURE__ */ new WeakSet();
413
+ Kt = function(t, e) {
414
+ if (!t) {
415
+ $(this, ae, ke).call(this);
416
+ return;
417
+ }
418
+ if (!E(this, S))
419
+ return;
420
+ const r = Yt(t);
421
+ if (!Wt(r))
422
+ throw new Error(`Invalid Starknet chain: ${r}`);
423
+ if (e?.length > 0) {
424
+ const [n] = e;
425
+ me(this, S, { address: n, chain: r }), $(this, Y, X).call(this, "change", { accounts: this.accounts });
426
+ } else
427
+ me(this, S, { address: E(this, S)?.address, chain: r }), $(this, Y, X).call(this, "change", { accounts: this.accounts });
428
+ };
429
+ we = /* @__PURE__ */ new WeakSet();
430
+ Je = async function(t) {
431
+ if (t.length === 0)
432
+ return;
433
+ const [e] = t;
434
+ if (E(this, S)?.chain)
435
+ E(this, S).address = e, $(this, Y, X).call(this, "change", { accounts: this.accounts });
436
+ else {
437
+ const r = await $(this, et, Gt).call(this);
438
+ me(this, S, { address: e, chain: r }), $(this, Y, X).call(this, "change", { accounts: this.accounts });
439
+ }
440
+ };
441
+ je = /* @__PURE__ */ new WeakSet();
442
+ Zt = function(...t) {
443
+ return this.injected.request(...t);
444
+ };
445
+ et = /* @__PURE__ */ new WeakSet();
446
+ Gt = async function() {
447
+ const t = await this.injected.request({
448
+ type: "wallet_requestChainId"
449
+ }), e = Yt(t);
450
+ if (!Wt(e))
451
+ throw new Error(`Invalid Starknet chain: ${e}`);
452
+ return e;
453
+ };
454
+ class Ie extends Er {
5
455
  keychain;
6
456
  modal;
7
457
  options;
8
- constructor(e, r, n, o, s, a) {
458
+ constructor(e, r, n, s, o, a) {
9
459
  super({
10
460
  provider: { nodeUrl: r },
11
461
  walletProvider: e,
12
462
  address: n
13
- }), this.keychain = o, this.options = s, this.modal = a;
463
+ }), this.keychain = s, this.options = o, this.modal = a;
14
464
  }
15
465
  /**
16
466
  * Invoke execute function in account contract
@@ -25,32 +475,32 @@ class je extends Ht {
25
475
  * @returns response from addTransaction
26
476
  */
27
477
  async execute(e) {
28
- return e = jt(e), new Promise(async (r, n) => {
29
- const o = await this.keychain.execute(
478
+ return e = _r(e), new Promise(async (r, n) => {
479
+ const s = await this.keychain.execute(
30
480
  e,
31
481
  void 0,
32
482
  void 0,
33
483
  !1,
34
484
  this.options?.feeSource
35
485
  );
36
- if (o.code === R.SUCCESS) {
37
- r(o);
486
+ if (s.code === z.SUCCESS) {
487
+ r(s);
38
488
  return;
39
489
  }
40
- if (this.options?.propagateSessionErrors && o.code !== R.USER_INTERACTION_REQUIRED) {
41
- n(o.error);
490
+ if (this.options?.propagateSessionErrors && s.code !== z.USER_INTERACTION_REQUIRED) {
491
+ n(s.error);
42
492
  return;
43
493
  }
44
- const s = this.options?.errorDisplayMode || "modal", a = o.error, i = o.code === R.USER_INTERACTION_REQUIRED;
45
- if (s === "silent" && !i) {
494
+ const o = this.options?.errorDisplayMode || "modal", a = s.error, i = s.code === z.USER_INTERACTION_REQUIRED;
495
+ if (o === "silent" && !i) {
46
496
  console.warn(
47
497
  "[Cartridge Controller] Transaction failed silently:",
48
498
  a
49
499
  ), n(a);
50
500
  return;
51
501
  }
52
- if (s === "notification" && !i) {
53
- const { toast: c } = await Promise.resolve().then(() => ko);
502
+ if (o === "notification" && !i) {
503
+ const { toast: c } = await Promise.resolve().then(() => Co);
54
504
  let d = !1, h;
55
505
  h = c({
56
506
  variant: "error",
@@ -58,7 +508,7 @@ class je extends Ht {
58
508
  duration: 1e4,
59
509
  onClick: () => {
60
510
  d = !0, h && h(), this.modal.open(), this.keychain.execute(e, void 0, void 0, !0, a).then((f) => {
61
- f.code === R.SUCCESS ? (r(f), this.modal.close()) : n(f.error);
511
+ f.code === z.SUCCESS ? (r(f), this.modal.close()) : n(f.error);
62
512
  });
63
513
  }
64
514
  }), setTimeout(() => {
@@ -74,7 +524,7 @@ class je extends Ht {
74
524
  !0,
75
525
  a
76
526
  );
77
- if (l.code === R.SUCCESS) {
527
+ if (l.code === z.SUCCESS) {
78
528
  r(l), this.modal.close();
79
529
  return;
80
530
  }
@@ -91,140 +541,140 @@ class je extends Ht {
91
541
  */
92
542
  async signMessage(e) {
93
543
  return new Promise(async (r, n) => {
94
- const o = await this.keychain.signMessage(e, "", !0);
95
- if (!("code" in o)) {
96
- r(o);
544
+ const s = await this.keychain.signMessage(e, "", !0);
545
+ if (!("code" in s)) {
546
+ r(s);
97
547
  return;
98
548
  }
99
549
  this.modal.open();
100
- const s = await this.keychain.signMessage(e, "", !1);
101
- "code" in s ? n(s.error) : r(s), this.modal.close();
550
+ const o = await this.keychain.signMessage(e, "", !1);
551
+ "code" in o ? n(o.error) : r(o), this.modal.close();
102
552
  });
103
553
  }
104
554
  }
105
- var P;
555
+ var U;
106
556
  (function(t) {
107
557
  t.Call = "call", t.Reply = "reply", t.Syn = "syn", t.SynAck = "synAck", t.Ack = "ack";
108
- })(P || (P = {}));
109
- var O;
558
+ })(U || (U = {}));
559
+ var H;
110
560
  (function(t) {
111
561
  t.Fulfilled = "fulfilled", t.Rejected = "rejected";
112
- })(O || (O = {}));
113
- var X;
562
+ })(H || (H = {}));
563
+ var ie;
114
564
  (function(t) {
115
565
  t.ConnectionDestroyed = "ConnectionDestroyed", t.ConnectionTimeout = "ConnectionTimeout", t.NoIframeSrc = "NoIframeSrc";
116
- })(X || (X = {}));
117
- var ke;
566
+ })(ie || (ie = {}));
567
+ var He;
118
568
  (function(t) {
119
569
  t.DataCloneError = "DataCloneError";
120
- })(ke || (ke = {}));
121
- var M;
570
+ })(He || (He = {}));
571
+ var Q;
122
572
  (function(t) {
123
573
  t.Message = "message";
124
- })(M || (M = {}));
125
- const Kt = (t, e) => {
574
+ })(Q || (Q = {}));
575
+ const mn = (t, e) => {
126
576
  const r = [];
127
577
  let n = !1;
128
578
  return {
129
- destroy(o) {
130
- n || (n = !0, e(`${t}: Destroying connection`), r.forEach((s) => {
131
- s(o);
579
+ destroy(s) {
580
+ n || (n = !0, e(`${t}: Destroying connection`), r.forEach((o) => {
581
+ o(s);
132
582
  }));
133
583
  },
134
- onDestroy(o) {
135
- n ? o() : r.push(o);
584
+ onDestroy(s) {
585
+ n ? s() : r.push(s);
136
586
  }
137
587
  };
138
- }, Gt = (t) => (...e) => {
588
+ }, wn = (t) => (...e) => {
139
589
  t && console.log("[Penpal]", ...e);
140
- }, Xt = {
590
+ }, yn = {
141
591
  "http:": "80",
142
592
  "https:": "443"
143
- }, Jt = /^(https?:)?\/\/([^/:]+)?(:(\d+))?/, er = ["file:", "data:"], tr = (t) => {
144
- if (t && er.find((i) => t.startsWith(i)))
593
+ }, bn = /^(https?:)?\/\/([^/:]+)?(:(\d+))?/, Cn = ["file:", "data:"], xn = (t) => {
594
+ if (t && Cn.find((i) => t.startsWith(i)))
145
595
  return "null";
146
- const e = document.location, r = Jt.exec(t);
147
- let n, o, s;
148
- r ? (n = r[1] ? r[1] : e.protocol, o = r[2], s = r[4]) : (n = e.protocol, o = e.hostname, s = e.port);
149
- const a = s && s !== Xt[n] ? `:${s}` : "";
150
- return `${n}//${o}${a}`;
151
- }, Ye = ({ name: t, message: e, stack: r }) => ({
596
+ const e = document.location, r = bn.exec(t);
597
+ let n, s, o;
598
+ r ? (n = r[1] ? r[1] : e.protocol, s = r[2], o = r[4]) : (n = e.protocol, s = e.hostname, o = e.port);
599
+ const a = o && o !== yn[n] ? `:${o}` : "";
600
+ return `${n}//${s}${a}`;
601
+ }, vt = ({ name: t, message: e, stack: r }) => ({
152
602
  name: t,
153
603
  message: e,
154
604
  stack: r
155
- }), rr = (t) => {
605
+ }), vn = (t) => {
156
606
  const e = new Error();
157
607
  return Object.keys(t).forEach((r) => e[r] = t[r]), e;
158
- }, nr = (t, e, r) => {
159
- const { localName: n, local: o, remote: s, originForSending: a, originForReceiving: i } = t;
608
+ }, kn = (t, e, r) => {
609
+ const { localName: n, local: s, remote: o, originForSending: a, originForReceiving: i } = t;
160
610
  let l = !1;
161
611
  const c = (d) => {
162
- if (d.source !== s || d.data.penpal !== P.Call)
612
+ if (d.source !== o || d.data.penpal !== U.Call)
163
613
  return;
164
614
  if (i !== "*" && d.origin !== i) {
165
615
  r(`${n} received message from origin ${d.origin} which did not match expected origin ${i}`);
166
616
  return;
167
617
  }
168
- const h = d.data, { methodName: f, args: u, id: p } = h;
618
+ const h = d.data, { methodName: f, args: u, id: g } = h;
169
619
  r(`${n}: Received ${f}() call`);
170
- const C = (y) => (S) => {
620
+ const C = (y) => (P) => {
171
621
  if (r(`${n}: Sending ${f}() reply`), l) {
172
622
  r(`${n}: Unable to send ${f}() reply due to destroyed connection`);
173
623
  return;
174
624
  }
175
625
  const x = {
176
- penpal: P.Reply,
177
- id: p,
626
+ penpal: U.Reply,
627
+ id: g,
178
628
  resolution: y,
179
- returnValue: S
629
+ returnValue: P
180
630
  };
181
- y === O.Rejected && S instanceof Error && (x.returnValue = Ye(S), x.returnValueIsError = !0);
631
+ y === H.Rejected && P instanceof Error && (x.returnValue = vt(P), x.returnValueIsError = !0);
182
632
  try {
183
- s.postMessage(x, a);
633
+ o.postMessage(x, a);
184
634
  } catch (m) {
185
- if (m.name === ke.DataCloneError) {
186
- const E = {
187
- penpal: P.Reply,
188
- id: p,
189
- resolution: O.Rejected,
190
- returnValue: Ye(m),
635
+ if (m.name === He.DataCloneError) {
636
+ const _ = {
637
+ penpal: U.Reply,
638
+ id: g,
639
+ resolution: H.Rejected,
640
+ returnValue: vt(m),
191
641
  returnValueIsError: !0
192
642
  };
193
- s.postMessage(E, a);
643
+ o.postMessage(_, a);
194
644
  }
195
645
  throw m;
196
646
  }
197
647
  };
198
- new Promise((y) => y(e[f].call(e, d.origin).apply(e, u))).then(C(O.Fulfilled), C(O.Rejected));
648
+ new Promise((y) => y(e[f].call(e, d.origin).apply(e, u))).then(C(H.Fulfilled), C(H.Rejected));
199
649
  };
200
- return o.addEventListener(M.Message, c), () => {
201
- l = !0, o.removeEventListener(M.Message, c);
650
+ return s.addEventListener(Q.Message, c), () => {
651
+ l = !0, s.removeEventListener(Q.Message, c);
202
652
  };
203
653
  };
204
- let or = 0;
205
- const sr = () => ++or, ft = ".", ut = (t) => t ? t.split(ft) : [], ar = (t) => t.join(ft), ir = (t, e) => {
206
- const r = ut(e || "");
207
- return r.push(t), ar(r);
208
- }, cr = (t, e, r) => {
209
- const n = ut(e);
210
- return n.reduce((o, s, a) => (typeof o[s] > "u" && (o[s] = {}), a === n.length - 1 && (o[s] = r), o[s]), t), t;
211
- }, pt = (t, e) => {
654
+ let En = 0;
655
+ const _n = () => ++En, Xt = ".", Jt = (t) => t ? t.split(Xt) : [], An = (t) => t.join(Xt), Sn = (t, e) => {
656
+ const r = Jt(e || "");
657
+ return r.push(t), An(r);
658
+ }, In = (t, e, r) => {
659
+ const n = Jt(e);
660
+ return n.reduce((s, o, a) => (typeof s[o] > "u" && (s[o] = {}), a === n.length - 1 && (s[o] = r), s[o]), t), t;
661
+ }, er = (t, e) => {
212
662
  const r = {};
213
663
  return Object.keys(t).forEach((n) => {
214
- const o = t[n], s = ir(n, e);
215
- typeof o == "object" && Object.assign(r, pt(o, s)), typeof o == "function" && (r[s] = o);
664
+ const s = t[n], o = Sn(n, e);
665
+ typeof s == "object" && Object.assign(r, er(s, o)), typeof s == "function" && (r[o] = s);
216
666
  }), r;
217
- }, lr = (t) => {
667
+ }, $n = (t) => {
218
668
  const e = {};
219
669
  for (const r in t)
220
- cr(e, r, t[r]);
670
+ In(e, r, t[r]);
221
671
  return e;
222
- }, dr = (t, e, r, n, o) => {
223
- const { localName: s, local: a, remote: i, originForSending: l, originForReceiving: c } = e;
672
+ }, Ln = (t, e, r, n, s) => {
673
+ const { localName: o, local: a, remote: i, originForSending: l, originForReceiving: c } = e;
224
674
  let d = !1;
225
- o(`${s}: Connecting call sender`);
226
- const h = (u) => (...p) => {
227
- o(`${s}: Sending ${u}() call`);
675
+ s(`${o}: Connecting call sender`);
676
+ const h = (u) => (...g) => {
677
+ s(`${o}: Sending ${u}() call`);
228
678
  let C;
229
679
  try {
230
680
  i.closed && (C = !0);
@@ -233,44 +683,44 @@ const sr = () => ++or, ft = ".", ut = (t) => t ? t.split(ft) : [], ar = (t) => t
233
683
  }
234
684
  if (C && n(), d) {
235
685
  const y = new Error(`Unable to send ${u}() call due to destroyed connection`);
236
- throw y.code = X.ConnectionDestroyed, y;
686
+ throw y.code = ie.ConnectionDestroyed, y;
237
687
  }
238
- return new Promise((y, S) => {
239
- const x = sr(), m = (w) => {
240
- if (w.source !== i || w.data.penpal !== P.Reply || w.data.id !== x)
688
+ return new Promise((y, P) => {
689
+ const x = _n(), m = (w) => {
690
+ if (w.source !== i || w.data.penpal !== U.Reply || w.data.id !== x)
241
691
  return;
242
692
  if (c !== "*" && w.origin !== c) {
243
- o(`${s} received message from origin ${w.origin} which did not match expected origin ${c}`);
693
+ s(`${o} received message from origin ${w.origin} which did not match expected origin ${c}`);
244
694
  return;
245
695
  }
246
- const H = w.data;
247
- o(`${s}: Received ${u}() reply`), a.removeEventListener(M.Message, m);
248
- let T = H.returnValue;
249
- H.returnValueIsError && (T = rr(T)), (H.resolution === O.Fulfilled ? y : S)(T);
696
+ const K = w.data;
697
+ s(`${o}: Received ${u}() reply`), a.removeEventListener(Q.Message, m);
698
+ let D = K.returnValue;
699
+ K.returnValueIsError && (D = vn(D)), (K.resolution === H.Fulfilled ? y : P)(D);
250
700
  };
251
- a.addEventListener(M.Message, m);
252
- const E = {
253
- penpal: P.Call,
701
+ a.addEventListener(Q.Message, m);
702
+ const _ = {
703
+ penpal: U.Call,
254
704
  id: x,
255
705
  methodName: u,
256
- args: p
706
+ args: g
257
707
  };
258
- i.postMessage(E, l);
708
+ i.postMessage(_, l);
259
709
  });
260
- }, f = r.reduce((u, p) => (u[p] = h(p), u), {});
261
- return Object.assign(t, lr(f)), () => {
710
+ }, f = r.reduce((u, g) => (u[g] = h(g), u), {});
711
+ return Object.assign(t, $n(f)), () => {
262
712
  d = !0;
263
713
  };
264
- }, hr = (t, e, r, n, o) => {
265
- const { destroy: s, onDestroy: a } = n;
714
+ }, Pn = (t, e, r, n, s) => {
715
+ const { destroy: o, onDestroy: a } = n;
266
716
  let i, l;
267
717
  const c = {};
268
718
  return (d) => {
269
719
  if (e !== "*" && d.origin !== e) {
270
- o(`Parent: Handshake - Received ACK message from origin ${d.origin} which did not match expected origin ${e}`);
720
+ s(`Parent: Handshake - Received ACK message from origin ${d.origin} which did not match expected origin ${e}`);
271
721
  return;
272
722
  }
273
- o("Parent: Handshake - Received ACK");
723
+ s("Parent: Handshake - Received ACK");
274
724
  const h = {
275
725
  localName: "Parent",
276
726
  local: window,
@@ -278,75 +728,96 @@ const sr = () => ++or, ft = ".", ut = (t) => t ? t.split(ft) : [], ar = (t) => t
278
728
  originForSending: r,
279
729
  originForReceiving: e
280
730
  };
281
- i && i(), i = nr(h, t, o), a(i), l && l.forEach((u) => {
731
+ i && i(), i = kn(h, t, s), a(i), l && l.forEach((u) => {
282
732
  delete c[u];
283
733
  }), l = d.data.methodNames;
284
- const f = dr(c, h, l, s, o);
734
+ const f = Ln(c, h, l, o, s);
285
735
  return a(f), c;
286
736
  };
287
- }, fr = (t, e, r, n) => (o) => {
288
- if (!o.source)
737
+ }, Nn = (t, e, r, n) => (s) => {
738
+ if (!s.source)
289
739
  return;
290
- if (r !== "*" && o.origin !== r) {
291
- t(`Parent: Handshake - Received SYN message from origin ${o.origin} which did not match expected origin ${r}`);
740
+ if (r !== "*" && s.origin !== r) {
741
+ t(`Parent: Handshake - Received SYN message from origin ${s.origin} which did not match expected origin ${r}`);
292
742
  return;
293
743
  }
294
744
  t("Parent: Handshake - Received SYN, responding with SYN-ACK");
295
- const s = {
296
- penpal: P.SynAck,
745
+ const o = {
746
+ penpal: U.SynAck,
297
747
  methodNames: Object.keys(e)
298
748
  };
299
- o.source.postMessage(s, n);
300
- }, ur = 6e4, pr = (t, e) => {
301
- const { destroy: r, onDestroy: n } = e, o = setInterval(() => {
302
- t.isConnected || (clearInterval(o), r());
303
- }, ur);
749
+ s.source.postMessage(o, n);
750
+ }, Bn = 6e4, Tn = (t, e) => {
751
+ const { destroy: r, onDestroy: n } = e, s = setInterval(() => {
752
+ t.isConnected || (clearInterval(s), r());
753
+ }, Bn);
304
754
  n(() => {
305
- clearInterval(o);
755
+ clearInterval(s);
306
756
  });
307
- }, gr = (t, e) => {
757
+ }, Rn = (t, e) => {
308
758
  let r;
309
759
  return t !== void 0 && (r = window.setTimeout(() => {
310
760
  const n = new Error(`Connection timed out after ${t}ms`);
311
- n.code = X.ConnectionTimeout, e(n);
761
+ n.code = ie.ConnectionTimeout, e(n);
312
762
  }, t)), () => {
313
763
  clearTimeout(r);
314
764
  };
315
- }, mr = (t) => {
765
+ }, Un = (t) => {
316
766
  if (!t.src && !t.srcdoc) {
317
767
  const e = new Error("Iframe must have src or srcdoc property defined.");
318
- throw e.code = X.NoIframeSrc, e;
768
+ throw e.code = ie.NoIframeSrc, e;
319
769
  }
320
- }, wr = (t) => {
321
- let { iframe: e, methods: r = {}, childOrigin: n, timeout: o, debug: s = !1 } = t;
322
- const a = Gt(s), i = Kt("Parent", a), { onDestroy: l, destroy: c } = i;
323
- n || (mr(e), n = tr(e.src));
324
- const d = n === "null" ? "*" : n, h = pt(r), f = fr(a, h, n, d), u = hr(h, n, d, i, a);
770
+ }, Mn = (t) => {
771
+ let { iframe: e, methods: r = {}, childOrigin: n, timeout: s, debug: o = !1 } = t;
772
+ const a = wn(o), i = mn("Parent", a), { onDestroy: l, destroy: c } = i;
773
+ n || (Un(e), n = xn(e.src));
774
+ const d = n === "null" ? "*" : n, h = er(r), f = Nn(a, h, n, d), u = Pn(h, n, d, i, a);
325
775
  return {
326
776
  promise: new Promise((C, y) => {
327
- const S = gr(o, c), x = (m) => {
777
+ const P = Rn(s, c), x = (m) => {
328
778
  if (!(m.source !== e.contentWindow || !m.data)) {
329
- if (m.data.penpal === P.Syn) {
779
+ if (m.data.penpal === U.Syn) {
330
780
  f(m);
331
781
  return;
332
782
  }
333
- if (m.data.penpal === P.Ack) {
334
- const E = u(m);
335
- E && (S(), C(E));
783
+ if (m.data.penpal === U.Ack) {
784
+ const _ = u(m);
785
+ _ && (P(), C(_));
336
786
  return;
337
787
  }
338
788
  }
339
789
  };
340
- window.addEventListener(M.Message, x), a("Parent: Awaiting handshake"), pr(e, i), l((m) => {
341
- window.removeEventListener(M.Message, x), m && y(m);
790
+ window.addEventListener(Q.Message, x), a("Parent: Awaiting handshake"), Tn(e, i), l((m) => {
791
+ window.removeEventListener(Q.Message, x), m && y(m);
342
792
  });
343
793
  }),
344
794
  destroy() {
345
795
  c();
346
796
  }
347
797
  };
348
- };
349
- class yr {
798
+ }, zn = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
799
+ function tr(t) {
800
+ const e = t.toLowerCase();
801
+ return zn.has(e) || e.endsWith(".localhost");
802
+ }
803
+ function On(t) {
804
+ if (t.username || t.password)
805
+ throw new Error("Invalid keychain iframe URL: credentials are not allowed");
806
+ if (t.protocol !== "https:" && !(t.protocol === "http:" && tr(t.hostname)))
807
+ throw new Error(
808
+ "Invalid keychain iframe URL: only https:// or local http:// URLs are allowed"
809
+ );
810
+ }
811
+ function Dn(t) {
812
+ const e = [
813
+ "publickey-credentials-create *",
814
+ "publickey-credentials-get *",
815
+ "clipboard-write",
816
+ "payment *"
817
+ ];
818
+ return tr(t.hostname) && e.push("local-network-access *"), e.join("; ");
819
+ }
820
+ class Fn {
350
821
  url;
351
822
  iframe;
352
823
  container;
@@ -356,16 +827,16 @@ class yr {
356
827
  id: e,
357
828
  url: r,
358
829
  onClose: n,
359
- onConnect: o,
360
- methods: s = {}
830
+ onConnect: s,
831
+ methods: o = {}
361
832
  }) {
362
833
  if (typeof document > "u" || typeof window > "u")
363
834
  return;
364
- this.url = r;
835
+ this.url = r, On(r);
365
836
  const a = document.head, i = document.createElement("meta");
366
837
  i.name = "viewport", i.id = "controller-viewport", i.content = "width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, interactive-widget=resizes-content", a.appendChild(i);
367
838
  const l = document.createElement("iframe");
368
- 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; local-network-access *; payment *", 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");
839
+ 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 = Dn(r), l.referrerPolicy = "no-referrer", 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");
369
840
  const c = document.createElement("div");
370
841
  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(
371
842
  "touchstart",
@@ -385,14 +856,21 @@ class yr {
385
856
  f.touches.length > 1 && f.preventDefault();
386
857
  },
387
858
  { passive: !1 }
388
- ), this.iframe = l, this.container = c, wr({
859
+ ), this.iframe = l, this.container = c, Mn({
389
860
  iframe: this.iframe,
861
+ childOrigin: r.origin,
390
862
  methods: {
863
+ open: (f) => () => this.open(),
391
864
  close: (f) => () => this.close(),
392
865
  reload: (f) => () => window.location.reload(),
393
- ...s
866
+ ...o
394
867
  }
395
- }).promise.then(o), this.resize(), window.addEventListener("resize", () => this.resize());
868
+ }).promise.then(s).catch((f) => {
869
+ console.error("Failed to establish secure keychain iframe connection", {
870
+ error: f,
871
+ childOrigin: r.origin
872
+ });
873
+ }), this.resize(), window.addEventListener("resize", () => this.resize());
396
874
  const d = new MutationObserver(() => {
397
875
  if (typeof document > "u") return;
398
876
  const f = document.getElementById("controller");
@@ -434,18 +912,18 @@ class yr {
434
912
  return this.container?.style.display !== "none";
435
913
  }
436
914
  }
437
- const br = "6.13.7";
438
- function We(t, e, r) {
915
+ const Qn = "6.13.7";
916
+ function kt(t, e, r) {
439
917
  for (let n in e) {
440
- let o = e[n];
441
- Object.defineProperty(t, n, { enumerable: !0, value: o, writable: !1 });
918
+ let s = e[n];
919
+ Object.defineProperty(t, n, { enumerable: !0, value: s, writable: !1 });
442
920
  }
443
921
  }
444
- function j(t) {
922
+ function Z(t) {
445
923
  if (t == null)
446
924
  return "null";
447
925
  if (Array.isArray(t))
448
- return "[ " + t.map(j).join(", ") + " ]";
926
+ return "[ " + t.map(Z).join(", ") + " ]";
449
927
  if (t instanceof Uint8Array) {
450
928
  const e = "0123456789abcdef";
451
929
  let r = "0x";
@@ -454,7 +932,7 @@ function j(t) {
454
932
  return r;
455
933
  }
456
934
  if (typeof t == "object" && typeof t.toJSON == "function")
457
- return j(t.toJSON());
935
+ return Z(t.toJSON());
458
936
  switch (typeof t) {
459
937
  case "boolean":
460
938
  case "symbol":
@@ -467,47 +945,47 @@ function j(t) {
467
945
  return JSON.stringify(t);
468
946
  case "object": {
469
947
  const e = Object.keys(t);
470
- return e.sort(), "{ " + e.map((r) => `${j(r)}: ${j(t[r])}`).join(", ") + " }";
948
+ return e.sort(), "{ " + e.map((r) => `${Z(r)}: ${Z(t[r])}`).join(", ") + " }";
471
949
  }
472
950
  }
473
951
  return "[ COULD NOT SERIALIZE ]";
474
952
  }
475
- function Cr(t, e, r) {
953
+ function jn(t, e, r) {
476
954
  let n = t;
477
955
  {
478
- const s = [];
956
+ const o = [];
479
957
  if (r) {
480
958
  if ("message" in r || "code" in r || "name" in r)
481
- throw new Error(`value will overwrite populated values: ${j(r)}`);
959
+ throw new Error(`value will overwrite populated values: ${Z(r)}`);
482
960
  for (const a in r) {
483
961
  if (a === "shortMessage")
484
962
  continue;
485
963
  const i = r[a];
486
- s.push(a + "=" + j(i));
964
+ o.push(a + "=" + Z(i));
487
965
  }
488
966
  }
489
- s.push(`code=${e}`), s.push(`version=${br}`), s.length && (t += " (" + s.join(", ") + ")");
967
+ o.push(`code=${e}`), o.push(`version=${Qn}`), o.length && (t += " (" + o.join(", ") + ")");
490
968
  }
491
- let o;
969
+ let s;
492
970
  switch (e) {
493
971
  case "INVALID_ARGUMENT":
494
- o = new TypeError(t);
972
+ s = new TypeError(t);
495
973
  break;
496
974
  case "NUMERIC_FAULT":
497
975
  case "BUFFER_OVERRUN":
498
- o = new RangeError(t);
976
+ s = new RangeError(t);
499
977
  break;
500
978
  default:
501
- o = new Error(t);
979
+ s = new Error(t);
502
980
  }
503
- return We(o, { code: e }), r && Object.assign(o, r), o.shortMessage == null && We(o, { shortMessage: n }), o;
981
+ return kt(s, { code: e }), r && Object.assign(s, r), s.shortMessage == null && kt(s, { shortMessage: n }), s;
504
982
  }
505
- function xr(t, e, r, n) {
983
+ function Hn(t, e, r, n) {
506
984
  if (!t)
507
- throw Cr(e, r, n);
985
+ throw jn(e, r, n);
508
986
  }
509
- function q(t, e, r, n) {
510
- xr(t, e, "INVALID_ARGUMENT", { argument: r, value: n });
987
+ function te(t, e, r, n) {
988
+ Hn(t, e, "INVALID_ARGUMENT", { argument: r, value: n });
511
989
  }
512
990
  ["NFD", "NFC", "NFKD", "NFKC"].reduce((t, e) => {
513
991
  try {
@@ -520,242 +998,72 @@ function q(t, e, r, n) {
520
998
  }
521
999
  return t;
522
1000
  }, []);
523
- function vr(t, e, r) {
1001
+ function Wn(t, e, r) {
524
1002
  if (t instanceof Uint8Array)
525
1003
  return t;
526
1004
  if (typeof t == "string" && t.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)) {
527
1005
  const n = new Uint8Array((t.length - 2) / 2);
528
- let o = 2;
529
- for (let s = 0; s < n.length; s++)
530
- n[s] = parseInt(t.substring(o, o + 2), 16), o += 2;
1006
+ let s = 2;
1007
+ for (let o = 0; o < n.length; o++)
1008
+ n[o] = parseInt(t.substring(s, s + 2), 16), s += 2;
531
1009
  return n;
532
1010
  }
533
- q(!1, "invalid BytesLike value", e || "value", t);
1011
+ te(!1, "invalid BytesLike value", e || "value", t);
534
1012
  }
535
- function Le(t, e) {
536
- return vr(t, e);
1013
+ function tt(t, e) {
1014
+ return Wn(t, e);
537
1015
  }
538
- const Ve = "0123456789abcdef";
539
- function kr(t) {
540
- const e = Le(t);
1016
+ const Et = "0123456789abcdef";
1017
+ function Yn(t) {
1018
+ const e = tt(t);
541
1019
  let r = "0x";
542
1020
  for (let n = 0; n < e.length; n++) {
543
- const o = e[n];
544
- r += Ve[(o & 240) >> 4] + Ve[o & 15];
1021
+ const s = e[n];
1022
+ r += Et[(s & 240) >> 4] + Et[s & 15];
545
1023
  }
546
1024
  return r;
547
1025
  }
548
- /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
549
- function Er(t) {
550
- return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
551
- }
552
- function qe(t) {
553
- if (!Number.isSafeInteger(t) || t < 0)
554
- throw new Error("positive integer expected, got " + t);
555
- }
556
- function se(t, ...e) {
557
- if (!Er(t))
558
- throw new Error("Uint8Array expected");
559
- if (e.length > 0 && !e.includes(t.length))
560
- throw new Error("Uint8Array expected of length " + e + ", got length=" + t.length);
561
- }
562
- function Ze(t, e = !0) {
563
- if (t.destroyed)
564
- throw new Error("Hash instance has been destroyed");
565
- if (e && t.finished)
566
- throw new Error("Hash#digest() has already been called");
567
- }
568
- function _r(t, e) {
569
- se(t);
570
- const r = e.outputLen;
571
- if (t.length < r)
572
- throw new Error("digestInto() expects output buffer of length at least " + r);
573
- }
574
- function Ar(t) {
575
- return new Uint32Array(t.buffer, t.byteOffset, Math.floor(t.byteLength / 4));
576
- }
577
- function gt(...t) {
578
- for (let e = 0; e < t.length; e++)
579
- t[e].fill(0);
580
- }
581
- const Ir = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
582
- function Sr(t) {
583
- return t << 24 & 4278190080 | t << 8 & 16711680 | t >>> 8 & 65280 | t >>> 24 & 255;
584
- }
585
- function $r(t) {
586
- for (let e = 0; e < t.length; e++)
587
- t[e] = Sr(t[e]);
588
- return t;
589
- }
590
- const Ke = Ir ? (t) => t : $r;
591
- function Lr(t) {
592
- if (typeof t != "string")
593
- throw new Error("string expected");
594
- return new Uint8Array(new TextEncoder().encode(t));
595
- }
596
- function mt(t) {
597
- return typeof t == "string" && (t = Lr(t)), se(t), t;
598
- }
599
- class Nr {
600
- }
601
- function Pr(t) {
602
- const e = (n) => t().update(mt(n)).digest(), r = t();
603
- return e.outputLen = r.outputLen, e.blockLen = r.blockLen, e.create = () => t(), e;
604
- }
605
- const re = /* @__PURE__ */ BigInt(2 ** 32 - 1), Ge = /* @__PURE__ */ BigInt(32);
606
- function Br(t, e = !1) {
607
- return e ? { h: Number(t & re), l: Number(t >> Ge & re) } : { h: Number(t >> Ge & re) | 0, l: Number(t & re) | 0 };
608
- }
609
- function Tr(t, e = !1) {
610
- const r = t.length;
611
- let n = new Uint32Array(r), o = new Uint32Array(r);
612
- for (let s = 0; s < r; s++) {
613
- const { h: a, l: i } = Br(t[s], e);
614
- [n[s], o[s]] = [a, i];
615
- }
616
- return [n, o];
617
- }
618
- const Rr = (t, e, r) => t << r | e >>> 32 - r, Ur = (t, e, r) => e << r | t >>> 32 - r, Mr = (t, e, r) => e << r - 32 | t >>> 64 - r, zr = (t, e, r) => t << r - 32 | e >>> 64 - r, Or = BigInt(0), V = BigInt(1), Dr = BigInt(2), Fr = BigInt(7), Qr = BigInt(256), Hr = BigInt(113), wt = [], yt = [], bt = [];
619
- for (let t = 0, e = V, r = 1, n = 0; t < 24; t++) {
620
- [r, n] = [n, (2 * r + 3 * n) % 5], wt.push(2 * (5 * n + r)), yt.push((t + 1) * (t + 2) / 2 % 64);
621
- let o = Or;
622
- for (let s = 0; s < 7; s++)
623
- e = (e << V ^ (e >> Fr) * Hr) % Qr, e & Dr && (o ^= V << (V << /* @__PURE__ */ BigInt(s)) - V);
624
- bt.push(o);
625
- }
626
- const Ct = Tr(bt, !0), jr = Ct[0], Yr = Ct[1], Xe = (t, e, r) => r > 32 ? Mr(t, e, r) : Rr(t, e, r), Je = (t, e, r) => r > 32 ? zr(t, e, r) : Ur(t, e, r);
627
- function Wr(t, e = 24) {
628
- const r = new Uint32Array(10);
629
- for (let n = 24 - e; n < 24; n++) {
630
- for (let a = 0; a < 10; a++)
631
- r[a] = t[a] ^ t[a + 10] ^ t[a + 20] ^ t[a + 30] ^ t[a + 40];
632
- for (let a = 0; a < 10; a += 2) {
633
- const i = (a + 8) % 10, l = (a + 2) % 10, c = r[l], d = r[l + 1], h = Xe(c, d, 1) ^ r[i], f = Je(c, d, 1) ^ r[i + 1];
634
- for (let u = 0; u < 50; u += 10)
635
- t[a + u] ^= h, t[a + u + 1] ^= f;
636
- }
637
- let o = t[2], s = t[3];
638
- for (let a = 0; a < 24; a++) {
639
- const i = yt[a], l = Xe(o, s, i), c = Je(o, s, i), d = wt[a];
640
- o = t[d], s = t[d + 1], t[d] = l, t[d + 1] = c;
641
- }
642
- for (let a = 0; a < 50; a += 10) {
643
- for (let i = 0; i < 10; i++)
644
- r[i] = t[a + i];
645
- for (let i = 0; i < 10; i++)
646
- t[a + i] ^= ~r[(i + 2) % 10] & r[(i + 4) % 10];
647
- }
648
- t[0] ^= jr[n], t[1] ^= Yr[n];
649
- }
650
- gt(r);
651
- }
652
- class Ne extends Nr {
653
- // NOTE: we accept arguments in bytes instead of bits here.
654
- constructor(e, r, n, o = !1, s = 24) {
655
- 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 = o, this.rounds = s, qe(n), !(0 < e && e < 200))
656
- throw new Error("only keccak-f1600 function is supported");
657
- this.state = new Uint8Array(200), this.state32 = Ar(this.state);
658
- }
659
- clone() {
660
- return this._cloneInto();
661
- }
662
- keccak() {
663
- Ke(this.state32), Wr(this.state32, this.rounds), Ke(this.state32), this.posOut = 0, this.pos = 0;
664
- }
665
- update(e) {
666
- Ze(this), e = mt(e), se(e);
667
- const { blockLen: r, state: n } = this, o = e.length;
668
- for (let s = 0; s < o; ) {
669
- const a = Math.min(r - this.pos, o - s);
670
- for (let i = 0; i < a; i++)
671
- n[this.pos++] ^= e[s++];
672
- this.pos === r && this.keccak();
673
- }
674
- return this;
675
- }
676
- finish() {
677
- if (this.finished)
678
- return;
679
- this.finished = !0;
680
- const { state: e, suffix: r, pos: n, blockLen: o } = this;
681
- e[n] ^= r, (r & 128) !== 0 && n === o - 1 && this.keccak(), e[o - 1] ^= 128, this.keccak();
682
- }
683
- writeInto(e) {
684
- Ze(this, !1), se(e), this.finish();
685
- const r = this.state, { blockLen: n } = this;
686
- for (let o = 0, s = e.length; o < s; ) {
687
- this.posOut >= n && this.keccak();
688
- const a = Math.min(n - this.posOut, s - o);
689
- e.set(r.subarray(this.posOut, this.posOut + a), o), this.posOut += a, o += a;
690
- }
691
- return e;
692
- }
693
- xofInto(e) {
694
- if (!this.enableXOF)
695
- throw new Error("XOF is not possible for this instance");
696
- return this.writeInto(e);
697
- }
698
- xof(e) {
699
- return qe(e), this.xofInto(new Uint8Array(e));
700
- }
701
- digestInto(e) {
702
- if (_r(e, this), this.finished)
703
- throw new Error("digest() was already called");
704
- return this.writeInto(e), this.destroy(), e;
705
- }
706
- digest() {
707
- return this.digestInto(new Uint8Array(this.outputLen));
708
- }
709
- destroy() {
710
- this.destroyed = !0, gt(this.state);
711
- }
712
- _cloneInto(e) {
713
- const { blockLen: r, suffix: n, outputLen: o, rounds: s, enableXOF: a } = this;
714
- return e || (e = new Ne(r, n, o, a, s)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = s, e.suffix = n, e.outputLen = o, e.enableXOF = a, e.destroyed = this.destroyed, e;
715
- }
716
- }
717
- const Vr = (t, e, r) => Pr(() => new Ne(e, t, r)), qr = Vr(1, 136, 256 / 8);
718
- let xt = !1;
719
- const vt = function(t) {
720
- return qr(t);
1026
+ let rr = !1;
1027
+ const nr = function(t) {
1028
+ return an(t);
721
1029
  };
722
- let kt = vt;
723
- function J(t) {
724
- const e = Le(t, "data");
725
- return kr(kt(e));
726
- }
727
- J._ = vt;
728
- J.lock = function() {
729
- xt = !0;
1030
+ let sr = nr;
1031
+ function ce(t) {
1032
+ const e = tt(t, "data");
1033
+ return Yn(sr(e));
1034
+ }
1035
+ ce._ = nr;
1036
+ ce.lock = function() {
1037
+ rr = !0;
730
1038
  };
731
- J.register = function(t) {
732
- if (xt)
1039
+ ce.register = function(t) {
1040
+ if (rr)
733
1041
  throw new TypeError("keccak256 is locked");
734
- kt = t;
1042
+ sr = t;
735
1043
  };
736
- Object.freeze(J);
737
- const Zr = BigInt(0), Kr = BigInt(36);
738
- function et(t) {
1044
+ Object.freeze(ce);
1045
+ const Vn = BigInt(0), qn = BigInt(36);
1046
+ function _t(t) {
739
1047
  t = t.toLowerCase();
740
1048
  const e = t.substring(2).split(""), r = new Uint8Array(40);
741
- for (let o = 0; o < 40; o++)
742
- r[o] = e[o].charCodeAt(0);
743
- const n = Le(J(r));
744
- for (let o = 0; o < 40; o += 2)
745
- n[o >> 1] >> 4 >= 8 && (e[o] = e[o].toUpperCase()), (n[o >> 1] & 15) >= 8 && (e[o + 1] = e[o + 1].toUpperCase());
1049
+ for (let s = 0; s < 40; s++)
1050
+ r[s] = e[s].charCodeAt(0);
1051
+ const n = tt(ce(r));
1052
+ for (let s = 0; s < 40; s += 2)
1053
+ n[s >> 1] >> 4 >= 8 && (e[s] = e[s].toUpperCase()), (n[s >> 1] & 15) >= 8 && (e[s + 1] = e[s + 1].toUpperCase());
746
1054
  return "0x" + e.join("");
747
1055
  }
748
- const Pe = {};
1056
+ const rt = {};
749
1057
  for (let t = 0; t < 10; t++)
750
- Pe[String(t)] = String(t);
1058
+ rt[String(t)] = String(t);
751
1059
  for (let t = 0; t < 26; t++)
752
- Pe[String.fromCharCode(65 + t)] = String(10 + t);
753
- const tt = 15;
754
- function Gr(t) {
1060
+ rt[String.fromCharCode(65 + t)] = String(10 + t);
1061
+ const At = 15;
1062
+ function Kn(t) {
755
1063
  t = t.toUpperCase(), t = t.substring(4) + t.substring(0, 2) + "00";
756
- let e = t.split("").map((n) => Pe[n]).join("");
757
- for (; e.length >= tt; ) {
758
- let n = e.substring(0, tt);
1064
+ let e = t.split("").map((n) => rt[n]).join("");
1065
+ for (; e.length >= At; ) {
1066
+ let n = e.substring(0, At);
759
1067
  e = parseInt(n, 10) % 97 + e.substring(n.length);
760
1068
  }
761
1069
  let r = String(98 - parseInt(e, 10) % 97);
@@ -763,7 +1071,7 @@ function Gr(t) {
763
1071
  r = "0" + r;
764
1072
  return r;
765
1073
  }
766
- const Xr = function() {
1074
+ const Zn = function() {
767
1075
  const t = {};
768
1076
  for (let e = 0; e < 36; e++) {
769
1077
  const r = "0123456789abcdefghijklmnopqrstuvwxyz"[e];
@@ -771,29 +1079,29 @@ const Xr = function() {
771
1079
  }
772
1080
  return t;
773
1081
  }();
774
- function Jr(t) {
1082
+ function Gn(t) {
775
1083
  t = t.toLowerCase();
776
- let e = Zr;
1084
+ let e = Vn;
777
1085
  for (let r = 0; r < t.length; r++)
778
- e = e * Kr + Xr[t[r]];
1086
+ e = e * qn + Zn[t[r]];
779
1087
  return e;
780
1088
  }
781
- function B(t) {
782
- if (q(typeof t == "string", "invalid address", "address", t), t.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
1089
+ function M(t) {
1090
+ if (te(typeof t == "string", "invalid address", "address", t), t.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
783
1091
  t.startsWith("0x") || (t = "0x" + t);
784
- const e = et(t);
785
- return q(!t.match(/([A-F].*[a-f])|([a-f].*[A-F])/) || e === t, "bad address checksum", "address", t), e;
1092
+ const e = _t(t);
1093
+ return te(!t.match(/([A-F].*[a-f])|([a-f].*[A-F])/) || e === t, "bad address checksum", "address", t), e;
786
1094
  }
787
1095
  if (t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
788
- q(t.substring(2, 4) === Gr(t), "bad icap checksum", "address", t);
789
- let e = Jr(t.substring(4)).toString(16);
1096
+ te(t.substring(2, 4) === Kn(t), "bad icap checksum", "address", t);
1097
+ let e = Gn(t.substring(4)).toString(16);
790
1098
  for (; e.length < 40; )
791
1099
  e = "0" + e;
792
- return et("0x" + e);
1100
+ return _t("0x" + e);
793
1101
  }
794
- q(!1, "invalid address", "address", t);
1102
+ te(!1, "invalid address", "address", t);
795
1103
  }
796
- class en {
1104
+ class Xn {
797
1105
  type = "argent";
798
1106
  platform = "starknet";
799
1107
  wallet = void 0;
@@ -927,17 +1235,17 @@ class en {
927
1235
  this.removeAccountChangeListener(), this.wallet = void 0, this.account = void 0, this.connectedAccounts = [];
928
1236
  }
929
1237
  }
930
- function tn(t) {
1238
+ function Jn(t) {
931
1239
  if (typeof window > "u")
932
1240
  return;
933
1241
  const e = (r) => t(r.detail);
934
1242
  return window.addEventListener("eip6963:announceProvider", e), window.dispatchEvent(new CustomEvent("eip6963:requestProvider")), () => window.removeEventListener("eip6963:announceProvider", e);
935
1243
  }
936
- function rn() {
1244
+ function es() {
937
1245
  const t = /* @__PURE__ */ new Set();
938
1246
  let e = [];
939
- const r = () => tn((o) => {
940
- e.some(({ info: s }) => s.uuid === o.info.uuid) || (e = [...e, o], t.forEach((s) => s(e, { added: [o] })));
1247
+ const r = () => Jn((s) => {
1248
+ e.some(({ info: o }) => o.uuid === s.info.uuid) || (e = [...e, s], t.forEach((o) => o(e, { added: [s] })));
941
1249
  });
942
1250
  let n = r();
943
1251
  return {
@@ -945,13 +1253,13 @@ function rn() {
945
1253
  return t;
946
1254
  },
947
1255
  clear() {
948
- t.forEach((o) => o([], { removed: [...e] })), e = [];
1256
+ t.forEach((s) => s([], { removed: [...e] })), e = [];
949
1257
  },
950
1258
  destroy() {
951
1259
  this.clear(), t.clear(), n?.();
952
1260
  },
953
- findProvider({ rdns: o }) {
954
- return e.find((s) => s.info.rdns === o);
1261
+ findProvider({ rdns: s }) {
1262
+ return e.find((o) => o.info.rdns === s);
955
1263
  },
956
1264
  getProviders() {
957
1265
  return e;
@@ -959,12 +1267,12 @@ function rn() {
959
1267
  reset() {
960
1268
  this.clear(), n?.(), n = r();
961
1269
  },
962
- subscribe(o, { emitImmediately: s } = {}) {
963
- return t.add(o), s && o(e, { added: e }), () => t.delete(o);
1270
+ subscribe(s, { emitImmediately: o } = {}) {
1271
+ return t.add(s), o && s(e, { added: e }), () => t.delete(s);
964
1272
  }
965
1273
  };
966
1274
  }
967
- const nn = {
1275
+ const ts = {
968
1276
  "0x1": "ethereum",
969
1277
  // ethereum mainnet
970
1278
  "0xaa36a7": "ethereum",
@@ -981,16 +1289,16 @@ const nn = {
981
1289
  // op mainnet
982
1290
  "0xaa37dc": "optimism",
983
1291
  // op sepolia
984
- [ve.StarknetChainId.SN_MAIN]: "starknet",
985
- [ve.StarknetChainId.SN_SEPOLIA]: "starknet"
986
- }, ge = (t) => {
987
- const e = lt.toHex(t), r = nn[e];
1292
+ [Ue.StarknetChainId.SN_MAIN]: "starknet",
1293
+ [Ue.StarknetChainId.SN_SEPOLIA]: "starknet"
1294
+ }, $e = (t) => {
1295
+ const e = Tt.toHex(t), r = ts[e];
988
1296
  return r || console.warn(`Unknown chain ID: ${e}`), r;
989
1297
  };
990
- class he {
1298
+ class Ee {
991
1299
  platform;
992
1300
  account = void 0;
993
- store = rn();
1301
+ store = es();
994
1302
  provider;
995
1303
  connectedAccounts = [];
996
1304
  constructor() {
@@ -1012,19 +1320,19 @@ class he {
1012
1320
  e && (e.provider.request({
1013
1321
  method: "eth_accounts"
1014
1322
  }).then((r) => {
1015
- this.connectedAccounts = r.map(B), r.length > 0 && (this.account = B(r[0]));
1323
+ this.connectedAccounts = r.map(M), r.length > 0 && (this.account = M(r[0]));
1016
1324
  }).catch(console.error), e.provider.request({
1017
1325
  method: "eth_chainId"
1018
1326
  }).then((r) => {
1019
- this.platform = ge(r);
1327
+ this.platform = $e(r);
1020
1328
  }).catch(console.error), e.provider?.on("chainChanged", (r) => {
1021
- this.platform = ge(r);
1329
+ this.platform = $e(r);
1022
1330
  }), e.provider?.on("accountsChanged", (r) => {
1023
- r && (this.connectedAccounts = r.map((n) => B(n)), this.account = r.length > 0 ? B(r[0]) : void 0);
1331
+ r && (this.connectedAccounts = r.map((n) => M(n)), this.account = r.length > 0 ? M(r[0]) : void 0);
1024
1332
  }));
1025
1333
  }
1026
1334
  isAvailable() {
1027
- if (Yt())
1335
+ if (Ar())
1028
1336
  return !1;
1029
1337
  const e = this.getProvider();
1030
1338
  return !e && this.rdns === "io.metamask" && typeof window < "u" ? !!window.ethereum?.isMetaMask : (e && !this.initialized && this.initializeIfAvailable(), typeof window < "u" && !!e);
@@ -1045,7 +1353,7 @@ class he {
1045
1353
  return this.connectedAccounts;
1046
1354
  }
1047
1355
  async connect(e) {
1048
- if (e && this.connectedAccounts.includes(B(e)) && (this.account = B(e)), this.account)
1356
+ if (e && this.connectedAccounts.includes(M(e)) && (this.account = M(e)), this.account)
1049
1357
  return { success: !0, wallet: this.type, account: this.account };
1050
1358
  try {
1051
1359
  if (!this.isAvailable())
@@ -1054,11 +1362,11 @@ class he {
1054
1362
  const n = this.getProvider();
1055
1363
  if (n ? r = n.provider : this.rdns === "io.metamask" && window.ethereum?.isMetaMask && (r = window.ethereum), !r)
1056
1364
  throw new Error(`${this.displayName} provider not found`);
1057
- const o = await r.request({
1365
+ const s = await r.request({
1058
1366
  method: "eth_requestAccounts"
1059
1367
  });
1060
- if (o && o.length > 0)
1061
- return this.account = B(o[0]), this.connectedAccounts = o.map(B), !n && this.rdns === "io.metamask" && (this.provider = {
1368
+ if (s && s.length > 0)
1369
+ return this.account = M(s[0]), this.connectedAccounts = s.map(M), !n && this.rdns === "io.metamask" && (this.provider = {
1062
1370
  info: {
1063
1371
  uuid: "metamask-fallback",
1064
1372
  name: "MetaMask",
@@ -1106,11 +1414,11 @@ class he {
1106
1414
  const n = this.getEthereumProvider();
1107
1415
  if (!n)
1108
1416
  throw new Error(`${this.displayName} provider not found`);
1109
- const o = await n.request({
1417
+ const s = await n.request({
1110
1418
  method: "personal_sign",
1111
1419
  params: [e, r || this.account]
1112
1420
  });
1113
- return { success: !0, wallet: this.type, result: o };
1421
+ return { success: !0, wallet: this.type, result: s };
1114
1422
  } catch (n) {
1115
1423
  return console.error(`Error signing message with ${this.displayName}:`, n), {
1116
1424
  success: !1,
@@ -1176,7 +1484,7 @@ class he {
1176
1484
  return await r.request({
1177
1485
  method: "wallet_switchEthereumChain",
1178
1486
  params: [{ chainId: e }]
1179
- }), this.platform = ge(e), !0;
1487
+ }), this.platform = $e(e), !0;
1180
1488
  } catch (n) {
1181
1489
  throw n.code === 4902 && console.warn(`Chain not added to ${this.displayName}`), n;
1182
1490
  }
@@ -1219,8 +1527,8 @@ class he {
1219
1527
  const n = this.getEthereumProvider();
1220
1528
  if (!n)
1221
1529
  throw new Error(`${this.displayName} is not connected`);
1222
- const o = Date.now(), s = 1e3;
1223
- for (; Date.now() - o < r; ) {
1530
+ const s = Date.now(), o = 1e3;
1531
+ for (; Date.now() - s < r; ) {
1224
1532
  const a = await n.request({
1225
1533
  method: "eth_getTransactionReceipt",
1226
1534
  params: [e]
@@ -1231,7 +1539,7 @@ class he {
1231
1539
  wallet: this.type,
1232
1540
  result: a
1233
1541
  };
1234
- await new Promise((i) => setTimeout(i, s));
1542
+ await new Promise((i) => setTimeout(i, o));
1235
1543
  }
1236
1544
  throw new Error("Transaction confirmation timed out");
1237
1545
  } catch (n) {
@@ -1246,97 +1554,97 @@ class he {
1246
1554
  }
1247
1555
  }
1248
1556
  }
1249
- class on extends he {
1557
+ class rs extends Ee {
1250
1558
  type = "base";
1251
1559
  rdns = "com.coinbase.wallet";
1252
1560
  displayName = "Base Wallet";
1253
1561
  }
1254
- class sn extends he {
1562
+ class ns extends Ee {
1255
1563
  type = "metamask";
1256
1564
  rdns = "io.metamask";
1257
1565
  displayName = "MetaMask";
1258
1566
  }
1259
1567
  /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
1260
- function Be(t) {
1568
+ function nt(t) {
1261
1569
  return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
1262
1570
  }
1263
- function Et(t, ...e) {
1264
- if (!Be(t))
1571
+ function or(t, ...e) {
1572
+ if (!nt(t))
1265
1573
  throw new Error("Uint8Array expected");
1266
1574
  if (e.length > 0 && !e.includes(t.length))
1267
1575
  throw new Error("Uint8Array expected of length " + e + ", got length=" + t.length);
1268
1576
  }
1269
- function _t(t, e) {
1577
+ function ar(t, e) {
1270
1578
  return Array.isArray(e) ? e.length === 0 ? !0 : t ? e.every((r) => typeof r == "string") : e.every((r) => Number.isSafeInteger(r)) : !1;
1271
1579
  }
1272
- function an(t) {
1580
+ function ss(t) {
1273
1581
  if (typeof t != "function")
1274
1582
  throw new Error("function expected");
1275
1583
  return !0;
1276
1584
  }
1277
- function W(t, e) {
1585
+ function J(t, e) {
1278
1586
  if (typeof e != "string")
1279
1587
  throw new Error(`${t}: string expected`);
1280
1588
  return !0;
1281
1589
  }
1282
- function ee(t) {
1590
+ function le(t) {
1283
1591
  if (!Number.isSafeInteger(t))
1284
1592
  throw new Error(`invalid integer: ${t}`);
1285
1593
  }
1286
- function ae(t) {
1594
+ function ye(t) {
1287
1595
  if (!Array.isArray(t))
1288
1596
  throw new Error("array expected");
1289
1597
  }
1290
- function ie(t, e) {
1291
- if (!_t(!0, e))
1598
+ function be(t, e) {
1599
+ if (!ar(!0, e))
1292
1600
  throw new Error(`${t}: array of strings expected`);
1293
1601
  }
1294
- function At(t, e) {
1295
- if (!_t(!1, e))
1602
+ function ir(t, e) {
1603
+ if (!ar(!1, e))
1296
1604
  throw new Error(`${t}: array of numbers expected`);
1297
1605
  }
1298
1606
  // @__NO_SIDE_EFFECTS__
1299
- function Te(...t) {
1300
- const e = (s) => s, r = (s, a) => (i) => s(a(i)), n = t.map((s) => s.encode).reduceRight(r, e), o = t.map((s) => s.decode).reduce(r, e);
1301
- return { encode: n, decode: o };
1607
+ function st(...t) {
1608
+ 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);
1609
+ return { encode: n, decode: s };
1302
1610
  }
1303
1611
  // @__NO_SIDE_EFFECTS__
1304
- function Re(t) {
1612
+ function ot(t) {
1305
1613
  const e = typeof t == "string" ? t.split("") : t, r = e.length;
1306
- ie("alphabet", e);
1307
- const n = new Map(e.map((o, s) => [o, s]));
1614
+ be("alphabet", e);
1615
+ const n = new Map(e.map((s, o) => [s, o]));
1308
1616
  return {
1309
- encode: (o) => (ae(o), o.map((s) => {
1310
- if (!Number.isSafeInteger(s) || s < 0 || s >= r)
1311
- throw new Error(`alphabet.encode: digit index outside alphabet "${s}". Allowed: ${t}`);
1312
- return e[s];
1617
+ encode: (s) => (ye(s), s.map((o) => {
1618
+ if (!Number.isSafeInteger(o) || o < 0 || o >= r)
1619
+ throw new Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${t}`);
1620
+ return e[o];
1313
1621
  })),
1314
- decode: (o) => (ae(o), o.map((s) => {
1315
- W("alphabet.decode", s);
1316
- const a = n.get(s);
1622
+ decode: (s) => (ye(s), s.map((o) => {
1623
+ J("alphabet.decode", o);
1624
+ const a = n.get(o);
1317
1625
  if (a === void 0)
1318
- throw new Error(`Unknown letter: "${s}". Allowed: ${t}`);
1626
+ throw new Error(`Unknown letter: "${o}". Allowed: ${t}`);
1319
1627
  return a;
1320
1628
  }))
1321
1629
  };
1322
1630
  }
1323
1631
  // @__NO_SIDE_EFFECTS__
1324
- function Ue(t = "") {
1325
- return W("join", t), {
1326
- encode: (e) => (ie("join.decode", e), e.join(t)),
1327
- decode: (e) => (W("join.decode", e), e.split(t))
1632
+ function at(t = "") {
1633
+ return J("join", t), {
1634
+ encode: (e) => (be("join.decode", e), e.join(t)),
1635
+ decode: (e) => (J("join.decode", e), e.split(t))
1328
1636
  };
1329
1637
  }
1330
1638
  // @__NO_SIDE_EFFECTS__
1331
- function cn(t, e = "=") {
1332
- return ee(t), W("padding", e), {
1639
+ function os(t, e = "=") {
1640
+ return le(t), J("padding", e), {
1333
1641
  encode(r) {
1334
- for (ie("padding.encode", r); r.length * t % 8; )
1642
+ for (be("padding.encode", r); r.length * t % 8; )
1335
1643
  r.push(e);
1336
1644
  return r;
1337
1645
  },
1338
1646
  decode(r) {
1339
- ie("padding.decode", r);
1647
+ be("padding.decode", r);
1340
1648
  let n = r.length;
1341
1649
  if (n * t % 8)
1342
1650
  throw new Error("padding: invalid, string should have whole number of bytes");
@@ -1348,128 +1656,128 @@ function cn(t, e = "=") {
1348
1656
  };
1349
1657
  }
1350
1658
  // @__NO_SIDE_EFFECTS__
1351
- function ln(t) {
1352
- return an(t), { encode: (e) => e, decode: (e) => t(e) };
1659
+ function as(t) {
1660
+ return ss(t), { encode: (e) => e, decode: (e) => t(e) };
1353
1661
  }
1354
- function rt(t, e, r) {
1662
+ function St(t, e, r) {
1355
1663
  if (e < 2)
1356
1664
  throw new Error(`convertRadix: invalid from=${e}, base cannot be less than 2`);
1357
1665
  if (r < 2)
1358
1666
  throw new Error(`convertRadix: invalid to=${r}, base cannot be less than 2`);
1359
- if (ae(t), !t.length)
1667
+ if (ye(t), !t.length)
1360
1668
  return [];
1361
1669
  let n = 0;
1362
- const o = [], s = Array.from(t, (i) => {
1363
- if (ee(i), i < 0 || i >= e)
1670
+ const s = [], o = Array.from(t, (i) => {
1671
+ if (le(i), i < 0 || i >= e)
1364
1672
  throw new Error(`invalid integer: ${i}`);
1365
1673
  return i;
1366
- }), a = s.length;
1674
+ }), a = o.length;
1367
1675
  for (; ; ) {
1368
1676
  let i = 0, l = !0;
1369
1677
  for (let c = n; c < a; c++) {
1370
- const d = s[c], h = e * i, f = h + d;
1678
+ const d = o[c], h = e * i, f = h + d;
1371
1679
  if (!Number.isSafeInteger(f) || h / e !== i || f - d !== h)
1372
1680
  throw new Error("convertRadix: carry overflow");
1373
1681
  const u = f / r;
1374
1682
  i = f % r;
1375
- const p = Math.floor(u);
1376
- if (s[c] = p, !Number.isSafeInteger(p) || p * r + i !== f)
1683
+ const g = Math.floor(u);
1684
+ if (o[c] = g, !Number.isSafeInteger(g) || g * r + i !== f)
1377
1685
  throw new Error("convertRadix: carry overflow");
1378
1686
  if (l)
1379
- p ? l = !1 : n = c;
1687
+ g ? l = !1 : n = c;
1380
1688
  else continue;
1381
1689
  }
1382
- if (o.push(i), l)
1690
+ if (s.push(i), l)
1383
1691
  break;
1384
1692
  }
1385
1693
  for (let i = 0; i < t.length - 1 && t[i] === 0; i++)
1386
- o.push(0);
1387
- return o.reverse();
1694
+ s.push(0);
1695
+ return s.reverse();
1388
1696
  }
1389
- const It = (t, e) => e === 0 ? t : It(e, t % e), ce = /* @__NO_SIDE_EFFECTS__ */ (t, e) => t + (e - It(t, e)), me = /* @__PURE__ */ (() => {
1697
+ const cr = (t, e) => e === 0 ? t : cr(e, t % e), Ce = /* @__NO_SIDE_EFFECTS__ */ (t, e) => t + (e - cr(t, e)), Le = /* @__PURE__ */ (() => {
1390
1698
  let t = [];
1391
1699
  for (let e = 0; e < 40; e++)
1392
1700
  t.push(2 ** e);
1393
1701
  return t;
1394
1702
  })();
1395
- function nt(t, e, r, n) {
1396
- if (ae(t), e <= 0 || e > 32)
1703
+ function It(t, e, r, n) {
1704
+ if (ye(t), e <= 0 || e > 32)
1397
1705
  throw new Error(`convertRadix2: wrong from=${e}`);
1398
1706
  if (r <= 0 || r > 32)
1399
1707
  throw new Error(`convertRadix2: wrong to=${r}`);
1400
- if (/* @__PURE__ */ ce(e, r) > 32)
1401
- throw new Error(`convertRadix2: carry overflow from=${e} to=${r} carryBits=${/* @__PURE__ */ ce(e, r)}`);
1402
- let o = 0, s = 0;
1403
- const a = me[e], i = me[r] - 1, l = [];
1708
+ if (/* @__PURE__ */ Ce(e, r) > 32)
1709
+ throw new Error(`convertRadix2: carry overflow from=${e} to=${r} carryBits=${/* @__PURE__ */ Ce(e, r)}`);
1710
+ let s = 0, o = 0;
1711
+ const a = Le[e], i = Le[r] - 1, l = [];
1404
1712
  for (const c of t) {
1405
- if (ee(c), c >= a)
1713
+ if (le(c), c >= a)
1406
1714
  throw new Error(`convertRadix2: invalid data word=${c} from=${e}`);
1407
- if (o = o << e | c, s + e > 32)
1408
- throw new Error(`convertRadix2: carry overflow pos=${s} from=${e}`);
1409
- for (s += e; s >= r; s -= r)
1410
- l.push((o >> s - r & i) >>> 0);
1411
- const d = me[s];
1715
+ if (s = s << e | c, o + e > 32)
1716
+ throw new Error(`convertRadix2: carry overflow pos=${o} from=${e}`);
1717
+ for (o += e; o >= r; o -= r)
1718
+ l.push((s >> o - r & i) >>> 0);
1719
+ const d = Le[o];
1412
1720
  if (d === void 0)
1413
1721
  throw new Error("invalid carry");
1414
- o &= d - 1;
1722
+ s &= d - 1;
1415
1723
  }
1416
- if (o = o << r - s & i, !n && s >= e)
1724
+ if (s = s << r - o & i, !n && o >= e)
1417
1725
  throw new Error("Excess padding");
1418
- if (!n && o > 0)
1419
- throw new Error(`Non-zero padding: ${o}`);
1420
- return n && s > 0 && l.push(o >>> 0), l;
1726
+ if (!n && s > 0)
1727
+ throw new Error(`Non-zero padding: ${s}`);
1728
+ return n && o > 0 && l.push(s >>> 0), l;
1421
1729
  }
1422
1730
  // @__NO_SIDE_EFFECTS__
1423
- function dn(t) {
1424
- ee(t);
1731
+ function is(t) {
1732
+ le(t);
1425
1733
  const e = 2 ** 8;
1426
1734
  return {
1427
1735
  encode: (r) => {
1428
- if (!Be(r))
1736
+ if (!nt(r))
1429
1737
  throw new Error("radix.encode input should be Uint8Array");
1430
- return rt(Array.from(r), e, t);
1738
+ return St(Array.from(r), e, t);
1431
1739
  },
1432
- decode: (r) => (At("radix.decode", r), Uint8Array.from(rt(r, t, e)))
1740
+ decode: (r) => (ir("radix.decode", r), Uint8Array.from(St(r, t, e)))
1433
1741
  };
1434
1742
  }
1435
1743
  // @__NO_SIDE_EFFECTS__
1436
- function St(t, e = !1) {
1437
- if (ee(t), t <= 0 || t > 32)
1744
+ function lr(t, e = !1) {
1745
+ if (le(t), t <= 0 || t > 32)
1438
1746
  throw new Error("radix2: bits should be in (0..32]");
1439
- if (/* @__PURE__ */ ce(8, t) > 32 || /* @__PURE__ */ ce(t, 8) > 32)
1747
+ if (/* @__PURE__ */ Ce(8, t) > 32 || /* @__PURE__ */ Ce(t, 8) > 32)
1440
1748
  throw new Error("radix2: carry overflow");
1441
1749
  return {
1442
1750
  encode: (r) => {
1443
- if (!Be(r))
1751
+ if (!nt(r))
1444
1752
  throw new Error("radix2.encode input should be Uint8Array");
1445
- return nt(Array.from(r), 8, t, !e);
1753
+ return It(Array.from(r), 8, t, !e);
1446
1754
  },
1447
- decode: (r) => (At("radix2.decode", r), Uint8Array.from(nt(r, t, 8, e)))
1755
+ decode: (r) => (ir("radix2.decode", r), Uint8Array.from(It(r, t, 8, e)))
1448
1756
  };
1449
1757
  }
1450
- const hn = typeof Uint8Array.from([]).toBase64 == "function" && typeof Uint8Array.fromBase64 == "function", fn = hn ? {
1758
+ const cs = typeof Uint8Array.from([]).toBase64 == "function" && typeof Uint8Array.fromBase64 == "function", ls = cs ? {
1451
1759
  encode(t) {
1452
- return Et(t), t.toBase64();
1760
+ return or(t), t.toBase64();
1453
1761
  },
1454
1762
  decode(t) {
1455
- return W("base64", t), Uint8Array.fromBase64(t, { lastChunkHandling: "strict" });
1763
+ return J("base64", t), Uint8Array.fromBase64(t, { lastChunkHandling: "strict" });
1456
1764
  }
1457
- } : /* @__PURE__ */ Te(/* @__PURE__ */ St(6), /* @__PURE__ */ Re("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), /* @__PURE__ */ cn(6), /* @__PURE__ */ Ue("")), un = /* @__NO_SIDE_EFFECTS__ */ (t) => /* @__PURE__ */ Te(/* @__PURE__ */ dn(58), /* @__PURE__ */ Re(t), /* @__PURE__ */ Ue("")), Ee = /* @__PURE__ */ un("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"), pn = {
1765
+ } : /* @__PURE__ */ st(/* @__PURE__ */ lr(6), /* @__PURE__ */ ot("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), /* @__PURE__ */ os(6), /* @__PURE__ */ at("")), ds = /* @__NO_SIDE_EFFECTS__ */ (t) => /* @__PURE__ */ st(/* @__PURE__ */ is(58), /* @__PURE__ */ ot(t), /* @__PURE__ */ at("")), We = /* @__PURE__ */ ds("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"), hs = {
1458
1766
  encode: (t) => new TextDecoder().decode(t),
1459
1767
  decode: (t) => new TextEncoder().encode(t)
1460
- }, gn = typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", mn = {
1768
+ }, fs = typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", us = {
1461
1769
  encode(t) {
1462
- return Et(t), t.toHex();
1770
+ return or(t), t.toHex();
1463
1771
  },
1464
1772
  decode(t) {
1465
- return W("hex", t), Uint8Array.fromHex(t);
1773
+ return J("hex", t), Uint8Array.fromHex(t);
1466
1774
  }
1467
- }, we = gn ? mn : /* @__PURE__ */ Te(/* @__PURE__ */ St(4), /* @__PURE__ */ Re("0123456789abcdef"), /* @__PURE__ */ Ue(""), /* @__PURE__ */ ln((t) => {
1775
+ }, Pe = fs ? us : /* @__PURE__ */ st(/* @__PURE__ */ lr(4), /* @__PURE__ */ ot("0123456789abcdef"), /* @__PURE__ */ at(""), /* @__PURE__ */ as((t) => {
1468
1776
  if (typeof t != "string" || t.length % 2 !== 0)
1469
1777
  throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);
1470
1778
  return t.toLowerCase();
1471
1779
  }));
1472
- function _e(t, e) {
1780
+ function Ye(t, e) {
1473
1781
  if (t.length !== e.length)
1474
1782
  return !1;
1475
1783
  for (let r = 0; r < t.length; r++)
@@ -1477,47 +1785,47 @@ function _e(t, e) {
1477
1785
  return !1;
1478
1786
  return !0;
1479
1787
  }
1480
- function U(t) {
1788
+ function F(t) {
1481
1789
  return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
1482
1790
  }
1483
- const $t = (t) => new DataView(t.buffer, t.byteOffset, t.byteLength);
1484
- function Q(t) {
1791
+ const dr = (t) => new DataView(t.buffer, t.byteOffset, t.byteLength);
1792
+ function q(t) {
1485
1793
  return Object.prototype.toString.call(t) === "[object Object]";
1486
1794
  }
1487
- function N(t) {
1795
+ function R(t) {
1488
1796
  return Number.isSafeInteger(t);
1489
1797
  }
1490
- const Lt = (t) => {
1491
- if (t !== null && typeof t != "string" && !L(t) && !U(t) && !N(t))
1798
+ const hr = (t) => {
1799
+ if (t !== null && typeof t != "string" && !T(t) && !F(t) && !R(t))
1492
1800
  throw new Error(`lengthCoder: expected null | number | Uint8Array | CoderType, got ${t} (${typeof t})`);
1493
1801
  return {
1494
1802
  encodeStream(e, r) {
1495
1803
  if (t === null)
1496
1804
  return;
1497
- if (L(t))
1805
+ if (T(t))
1498
1806
  return t.encodeStream(e, r);
1499
1807
  let n;
1500
- if (typeof t == "number" ? n = t : typeof t == "string" && (n = F.resolve(e.stack, t)), typeof n == "bigint" && (n = Number(n)), n === void 0 || n !== r)
1808
+ if (typeof t == "number" ? n = t : typeof t == "string" && (n = V.resolve(e.stack, t)), typeof n == "bigint" && (n = Number(n)), n === void 0 || n !== r)
1501
1809
  throw e.err(`Wrong length: ${n} len=${t} exp=${r} (${typeof r})`);
1502
1810
  },
1503
1811
  decodeStream(e) {
1504
1812
  let r;
1505
- if (L(t) ? r = Number(t.decodeStream(e)) : typeof t == "number" ? r = t : typeof t == "string" && (r = F.resolve(e.stack, t)), typeof r == "bigint" && (r = Number(r)), typeof r != "number")
1813
+ if (T(t) ? r = Number(t.decodeStream(e)) : typeof t == "number" ? r = t : typeof t == "string" && (r = V.resolve(e.stack, t)), typeof r == "bigint" && (r = Number(r)), typeof r != "number")
1506
1814
  throw e.err(`Wrong length: ${r}`);
1507
1815
  return r;
1508
1816
  }
1509
1817
  };
1510
- }, _ = {
1818
+ }, A = {
1511
1819
  BITS: 32,
1512
1820
  FULL_MASK: -1 >>> 0,
1513
1821
  // 1<<32 will overflow
1514
1822
  len: (t) => Math.ceil(t / 32),
1515
- create: (t) => new Uint32Array(_.len(t)),
1823
+ create: (t) => new Uint32Array(A.len(t)),
1516
1824
  clean: (t) => t.fill(0),
1517
1825
  debug: (t) => Array.from(t).map((e) => (e >>> 0).toString(2).padStart(32, "0")),
1518
1826
  checkLen: (t, e) => {
1519
- if (_.len(e) !== t.length)
1520
- throw new Error(`wrong length=${t.length}. Expected: ${_.len(e)}`);
1827
+ if (A.len(e) !== t.length)
1828
+ throw new Error(`wrong length=${t.length}. Expected: ${A.len(e)}`);
1521
1829
  },
1522
1830
  chunkLen: (t, e, r) => {
1523
1831
  if (e < 0)
@@ -1531,14 +1839,14 @@ const Lt = (t) => {
1531
1839
  mask: 1 << 32 - (t + e) % 32 - 1
1532
1840
  }),
1533
1841
  indices: (t, e, r = !1) => {
1534
- _.checkLen(t, e);
1535
- const { FULL_MASK: n, BITS: o } = _, s = o - e % o, a = s ? n >>> s << s : n, i = [];
1842
+ A.checkLen(t, e);
1843
+ const { FULL_MASK: n, BITS: s } = A, o = s - e % s, a = o ? n >>> o << o : n, i = [];
1536
1844
  for (let l = 0; l < t.length; l++) {
1537
1845
  let c = t[l];
1538
1846
  if (r && (c = ~c), l === t.length - 1 && (c &= a), c !== 0)
1539
- for (let d = 0; d < o; d++) {
1540
- const h = 1 << o - d - 1;
1541
- c & h && i.push(l * o + d);
1847
+ for (let d = 0; d < s; d++) {
1848
+ const h = 1 << s - d - 1;
1849
+ c & h && i.push(l * s + d);
1542
1850
  }
1543
1851
  }
1544
1852
  return i;
@@ -1550,21 +1858,21 @@ const Lt = (t) => {
1550
1858
  r === void 0 || n !== r.pos + r.length ? e.push(r = { pos: n, length: 1 }) : r.length += 1;
1551
1859
  return e;
1552
1860
  },
1553
- rangeDebug: (t, e, r = !1) => `[${_.range(_.indices(t, e, r)).map((n) => `(${n.pos}/${n.length})`).join(", ")}]`,
1554
- setRange: (t, e, r, n, o = !0) => {
1555
- _.chunkLen(e, r, n);
1556
- const { FULL_MASK: s, BITS: a } = _, i = r % a ? Math.floor(r / a) : void 0, l = r + n, c = l % a ? Math.floor(l / a) : void 0;
1861
+ rangeDebug: (t, e, r = !1) => `[${A.range(A.indices(t, e, r)).map((n) => `(${n.pos}/${n.length})`).join(", ")}]`,
1862
+ setRange: (t, e, r, n, s = !0) => {
1863
+ A.chunkLen(e, r, n);
1864
+ 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;
1557
1865
  if (i !== void 0 && i === c)
1558
- return _.set(t, i, s >>> a - n << a - n - r, o);
1559
- if (i !== void 0 && !_.set(t, i, s >>> r % a, o))
1866
+ return A.set(t, i, o >>> a - n << a - n - r, s);
1867
+ if (i !== void 0 && !A.set(t, i, o >>> r % a, s))
1560
1868
  return !1;
1561
1869
  const d = i !== void 0 ? i + 1 : r / a, h = c !== void 0 ? c : l / a;
1562
1870
  for (let f = d; f < h; f++)
1563
- if (!_.set(t, f, s, o))
1871
+ if (!A.set(t, f, o, s))
1564
1872
  return !1;
1565
- return !(c !== void 0 && i !== c && !_.set(t, c, s << a - l % a, o));
1873
+ return !(c !== void 0 && i !== c && !A.set(t, c, o << a - l % a, s));
1566
1874
  }
1567
- }, F = {
1875
+ }, V = {
1568
1876
  /**
1569
1877
  * Internal method for handling stack of paths (debug, errors, dynamic fields via path)
1570
1878
  * This is looks ugly (callback), but allows us to force stack cleaning by construction (.pop always after function).
@@ -1575,8 +1883,8 @@ const Lt = (t) => {
1575
1883
  */
1576
1884
  pushObj: (t, e, r) => {
1577
1885
  const n = { obj: e };
1578
- t.push(n), r((o, s) => {
1579
- n.field = o, s(), n.field = void 0;
1886
+ t.push(n), r((s, o) => {
1887
+ n.field = s, o(), n.field = void 0;
1580
1888
  }), t.pop();
1581
1889
  },
1582
1890
  path: (t) => {
@@ -1586,35 +1894,35 @@ const Lt = (t) => {
1586
1894
  return e.join("/");
1587
1895
  },
1588
1896
  err: (t, e, r) => {
1589
- const n = new Error(`${t}(${F.path(e)}): ${typeof r == "string" ? r : r.message}`);
1897
+ const n = new Error(`${t}(${V.path(e)}): ${typeof r == "string" ? r : r.message}`);
1590
1898
  return r instanceof Error && r.stack && (n.stack = r.stack), n;
1591
1899
  },
1592
1900
  resolve: (t, e) => {
1593
1901
  const r = e.split("/"), n = t.map((a) => a.obj);
1594
- let o = 0;
1595
- for (; o < r.length && r[o] === ".."; o++)
1902
+ let s = 0;
1903
+ for (; s < r.length && r[s] === ".."; s++)
1596
1904
  n.pop();
1597
- let s = n.pop();
1598
- for (; o < r.length; o++) {
1599
- if (!s || s[r[o]] === void 0)
1905
+ let o = n.pop();
1906
+ for (; s < r.length; s++) {
1907
+ if (!o || o[r[s]] === void 0)
1600
1908
  return;
1601
- s = s[r[o]];
1909
+ o = o[r[s]];
1602
1910
  }
1603
- return s;
1911
+ return o;
1604
1912
  }
1605
1913
  };
1606
- class Me {
1607
- constructor(e, r = {}, n = [], o = void 0, s = 0) {
1608
- this.pos = 0, this.bitBuf = 0, this.bitPos = 0, this.data = e, this.opts = r, this.stack = n, this.parent = o, this.parentOffset = s, this.view = $t(e);
1914
+ class it {
1915
+ constructor(e, r = {}, n = [], s = void 0, o = 0) {
1916
+ 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 = dr(e);
1609
1917
  }
1610
1918
  /** Internal method for pointers. */
1611
1919
  _enablePointers() {
1612
1920
  if (this.parent)
1613
1921
  return this.parent._enablePointers();
1614
- this.bs || (this.bs = _.create(this.data.length), _.setRange(this.bs, this.data.length, 0, this.pos, this.opts.allowMultipleReads));
1922
+ this.bs || (this.bs = A.create(this.data.length), A.setRange(this.bs, this.data.length, 0, this.pos, this.opts.allowMultipleReads));
1615
1923
  }
1616
1924
  markBytesBS(e, r) {
1617
- return this.parent ? this.parent.markBytesBS(this.parentOffset + e, r) : !r || !this.bs ? !0 : _.setRange(this.bs, this.data.length, e, r, !1);
1925
+ return this.parent ? this.parent.markBytesBS(this.parentOffset + e, r) : !r || !this.bs ? !0 : A.setRange(this.bs, this.data.length, e, r, !1);
1618
1926
  }
1619
1927
  markBytes(e) {
1620
1928
  const r = this.pos;
@@ -1625,7 +1933,7 @@ class Me {
1625
1933
  return n;
1626
1934
  }
1627
1935
  pushObj(e, r) {
1628
- return F.pushObj(this.stack, e, r);
1936
+ return V.pushObj(this.stack, e, r);
1629
1937
  }
1630
1938
  readView(e, r) {
1631
1939
  if (!Number.isFinite(e))
@@ -1644,27 +1952,27 @@ class Me {
1644
1952
  finish() {
1645
1953
  if (!this.opts.allowUnreadBytes) {
1646
1954
  if (this.bitPos)
1647
- throw this.err(`${this.bitPos} bits left after unpack: ${we.encode(this.data.slice(this.pos))}`);
1955
+ throw this.err(`${this.bitPos} bits left after unpack: ${Pe.encode(this.data.slice(this.pos))}`);
1648
1956
  if (this.bs && !this.parent) {
1649
- const e = _.indices(this.bs, this.data.length, !0);
1957
+ const e = A.indices(this.bs, this.data.length, !0);
1650
1958
  if (e.length) {
1651
- const r = _.range(e).map(({ pos: n, length: o }) => `(${n}/${o})[${we.encode(this.data.subarray(n, n + o))}]`).join(", ");
1959
+ const r = A.range(e).map(({ pos: n, length: s }) => `(${n}/${s})[${Pe.encode(this.data.subarray(n, n + s))}]`).join(", ");
1652
1960
  throw this.err(`unread byte ranges: ${r} (total=${this.data.length})`);
1653
1961
  } else
1654
1962
  return;
1655
1963
  }
1656
1964
  if (!this.isEnd())
1657
- throw this.err(`${this.leftBytes} bytes ${this.bitPos} bits left after unpack: ${we.encode(this.data.slice(this.pos))}`);
1965
+ throw this.err(`${this.leftBytes} bytes ${this.bitPos} bits left after unpack: ${Pe.encode(this.data.slice(this.pos))}`);
1658
1966
  }
1659
1967
  }
1660
1968
  // User methods
1661
1969
  err(e) {
1662
- return F.err("Reader", this.stack, e);
1970
+ return V.err("Reader", this.stack, e);
1663
1971
  }
1664
1972
  offsetReader(e) {
1665
1973
  if (e > this.data.length)
1666
1974
  throw this.err("offsetReader: Unexpected end of buffer");
1667
- return new Me(this.absBytes(e), this.opts, this.stack, this, e);
1975
+ return new it(this.absBytes(e), this.opts, this.stack, this, e);
1668
1976
  }
1669
1977
  bytes(e, r = !1) {
1670
1978
  if (this.bitPos)
@@ -1706,7 +2014,7 @@ class Me {
1706
2014
  return r >>> 0;
1707
2015
  }
1708
2016
  find(e, r = this.pos) {
1709
- if (!U(e))
2017
+ if (!F(e))
1710
2018
  throw this.err(`find: needle is not bytes! ${e}`);
1711
2019
  if (this.bitPos)
1712
2020
  throw this.err("findByte: bitPos not empty");
@@ -1715,22 +2023,22 @@ class Me {
1715
2023
  for (let n = r; (n = this.data.indexOf(e[0], n)) !== -1; n++) {
1716
2024
  if (n === -1 || this.data.length - n < e.length)
1717
2025
  return;
1718
- if (_e(e, this.data.subarray(n, n + e.length)))
2026
+ if (Ye(e, this.data.subarray(n, n + e.length)))
1719
2027
  return n;
1720
2028
  }
1721
2029
  }
1722
2030
  }
1723
- class wn {
2031
+ class ps {
1724
2032
  constructor(e = []) {
1725
- 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);
2033
+ 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 = dr(this.viewBuf);
1726
2034
  }
1727
2035
  pushObj(e, r) {
1728
- return F.pushObj(this.stack, e, r);
2036
+ return V.pushObj(this.stack, e, r);
1729
2037
  }
1730
2038
  writeView(e, r) {
1731
2039
  if (this.finished)
1732
2040
  throw this.err("buffer: finished");
1733
- if (!N(e) || e > 8)
2041
+ if (!R(e) || e > 8)
1734
2042
  throw new Error(`wrong writeView length=${e}`);
1735
2043
  r(this.view), this.bytes(this.viewBuf.slice(0, e)), this.viewBuf.fill(0);
1736
2044
  }
@@ -1738,7 +2046,7 @@ class wn {
1738
2046
  err(e) {
1739
2047
  if (this.finished)
1740
2048
  throw this.err("buffer: finished");
1741
- return F.err("Reader", this.stack, e);
2049
+ return V.err("Reader", this.stack, e);
1742
2050
  }
1743
2051
  bytes(e) {
1744
2052
  if (this.finished)
@@ -1759,22 +2067,22 @@ class wn {
1759
2067
  throw this.err("buffer: finished");
1760
2068
  if (this.bitPos)
1761
2069
  throw this.err("buffer: ends with non-empty bit buffer");
1762
- const r = this.buffers.concat(this.ptrs.map((s) => s.buffer)), n = r.map((s) => s.length).reduce((s, a) => s + a, 0), o = new Uint8Array(n);
1763
- for (let s = 0, a = 0; s < r.length; s++) {
1764
- const i = r[s];
1765
- o.set(i, a), a += i.length;
2070
+ 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);
2071
+ for (let o = 0, a = 0; o < r.length; o++) {
2072
+ const i = r[o];
2073
+ s.set(i, a), a += i.length;
1766
2074
  }
1767
- for (let s = this.pos, a = 0; a < this.ptrs.length; a++) {
2075
+ for (let o = this.pos, a = 0; a < this.ptrs.length; a++) {
1768
2076
  const i = this.ptrs[a];
1769
- o.set(i.ptr.encode(s), i.pos), s += i.buffer.length;
2077
+ s.set(i.ptr.encode(o), i.pos), o += i.buffer.length;
1770
2078
  }
1771
2079
  if (e) {
1772
2080
  this.buffers = [];
1773
- for (const s of this.ptrs)
1774
- s.buffer.fill(0);
2081
+ for (const o of this.ptrs)
2082
+ o.buffer.fill(0);
1775
2083
  this.ptrs = [], this.finished = !0, this.bitBuf = 0;
1776
2084
  }
1777
- return o;
2085
+ return s;
1778
2086
  }
1779
2087
  bits(e, r) {
1780
2088
  if (r > 32)
@@ -1787,8 +2095,8 @@ class wn {
1787
2095
  }
1788
2096
  }
1789
2097
  }
1790
- const Ae = (t) => Uint8Array.from(t).reverse();
1791
- function yn(t, e, r) {
2098
+ const Ve = (t) => Uint8Array.from(t).reverse();
2099
+ function gs(t, e, r) {
1792
2100
  if (r) {
1793
2101
  const n = 2n ** (e - 1n);
1794
2102
  if (t < -n || t >= n)
@@ -1796,56 +2104,56 @@ function yn(t, e, r) {
1796
2104
  } else if (0n > t || t >= 2n ** e)
1797
2105
  throw new Error(`value out of unsigned bounds. Expected 0 <= ${t} < ${2n ** e}`);
1798
2106
  }
1799
- function Nt(t) {
2107
+ function fr(t) {
1800
2108
  return {
1801
2109
  // NOTE: we cannot export validate here, since it is likely mistake.
1802
2110
  encodeStream: t.encodeStream,
1803
2111
  decodeStream: t.decodeStream,
1804
2112
  size: t.size,
1805
2113
  encode: (e) => {
1806
- const r = new wn();
2114
+ const r = new ps();
1807
2115
  return t.encodeStream(r, e), r.finish();
1808
2116
  },
1809
2117
  decode: (e, r = {}) => {
1810
- const n = new Me(e, r), o = t.decodeStream(n);
1811
- return n.finish(), o;
2118
+ const n = new it(e, r), s = t.decodeStream(n);
2119
+ return n.finish(), s;
1812
2120
  }
1813
2121
  };
1814
2122
  }
1815
- function Pt(t, e) {
1816
- if (!L(t))
2123
+ function ur(t, e) {
2124
+ if (!T(t))
1817
2125
  throw new Error(`validate: invalid inner value ${t}`);
1818
2126
  if (typeof e != "function")
1819
2127
  throw new Error("validate: fn should be function");
1820
- return Nt({
2128
+ return fr({
1821
2129
  size: t.size,
1822
2130
  encodeStream: (r, n) => {
1823
- let o;
2131
+ let s;
1824
2132
  try {
1825
- o = e(n);
1826
- } catch (s) {
1827
- throw r.err(s);
2133
+ s = e(n);
2134
+ } catch (o) {
2135
+ throw r.err(o);
1828
2136
  }
1829
- t.encodeStream(r, o);
2137
+ t.encodeStream(r, s);
1830
2138
  },
1831
2139
  decodeStream: (r) => {
1832
2140
  const n = t.decodeStream(r);
1833
2141
  try {
1834
2142
  return e(n);
1835
- } catch (o) {
1836
- throw r.err(o);
2143
+ } catch (s) {
2144
+ throw r.err(s);
1837
2145
  }
1838
2146
  }
1839
2147
  });
1840
2148
  }
1841
- const I = (t) => {
1842
- const e = Nt(t);
1843
- return t.validate ? Pt(e, t.validate) : e;
1844
- }, fe = (t) => Q(t) && typeof t.decode == "function" && typeof t.encode == "function";
1845
- function L(t) {
1846
- return Q(t) && fe(t) && typeof t.encodeStream == "function" && typeof t.decodeStream == "function" && (t.size === void 0 || N(t.size));
2149
+ const L = (t) => {
2150
+ const e = fr(t);
2151
+ return t.validate ? ur(e, t.validate) : e;
2152
+ }, _e = (t) => q(t) && typeof t.decode == "function" && typeof t.encode == "function";
2153
+ function T(t) {
2154
+ return q(t) && _e(t) && typeof t.encodeStream == "function" && typeof t.decodeStream == "function" && (t.size === void 0 || R(t.size));
1847
2155
  }
1848
- function bn() {
2156
+ function ms() {
1849
2157
  return {
1850
2158
  encode: (t) => {
1851
2159
  if (!Array.isArray(t))
@@ -1854,21 +2162,21 @@ function bn() {
1854
2162
  for (const r of t) {
1855
2163
  if (!Array.isArray(r) || r.length !== 2)
1856
2164
  throw new Error("array of two elements expected");
1857
- const n = r[0], o = r[1];
2165
+ const n = r[0], s = r[1];
1858
2166
  if (e[n] !== void 0)
1859
2167
  throw new Error(`key(${n}) appears twice in struct`);
1860
- e[n] = o;
2168
+ e[n] = s;
1861
2169
  }
1862
2170
  return e;
1863
2171
  },
1864
2172
  decode: (t) => {
1865
- if (!Q(t))
2173
+ if (!q(t))
1866
2174
  throw new Error(`expected plain object, got ${t}`);
1867
2175
  return Object.entries(t);
1868
2176
  }
1869
2177
  };
1870
2178
  }
1871
- const Cn = {
2179
+ const ws = {
1872
2180
  encode: (t) => {
1873
2181
  if (typeof t != "bigint")
1874
2182
  throw new Error(`expected bigint, got ${typeof t}`);
@@ -1877,17 +2185,17 @@ const Cn = {
1877
2185
  return Number(t);
1878
2186
  },
1879
2187
  decode: (t) => {
1880
- if (!N(t))
2188
+ if (!R(t))
1881
2189
  throw new Error("element is not a safe integer");
1882
2190
  return BigInt(t);
1883
2191
  }
1884
2192
  };
1885
- function xn(t) {
1886
- if (!Q(t))
2193
+ function ys(t) {
2194
+ if (!q(t))
1887
2195
  throw new Error("plain object expected");
1888
2196
  return {
1889
2197
  encode: (e) => {
1890
- if (!N(e) || !(e in t))
2198
+ if (!R(e) || !(e in t))
1891
2199
  throw new Error(`wrong value ${e}`);
1892
2200
  return t[e];
1893
2201
  },
@@ -1898,8 +2206,8 @@ function xn(t) {
1898
2206
  }
1899
2207
  };
1900
2208
  }
1901
- function vn(t, e = !1) {
1902
- if (!N(t))
2209
+ function bs(t, e = !1) {
2210
+ if (!R(t))
1903
2211
  throw new Error(`decimal/precision: wrong value ${t}`);
1904
2212
  if (typeof e != "boolean")
1905
2213
  throw new Error(`decimal/round: expected boolean, got ${typeof e}`);
@@ -1908,12 +2216,12 @@ function vn(t, e = !1) {
1908
2216
  encode: (n) => {
1909
2217
  if (typeof n != "bigint")
1910
2218
  throw new Error(`expected bigint, got ${typeof n}`);
1911
- let o = (n < 0n ? -n : n).toString(10), s = o.length - t;
1912
- s < 0 && (o = o.padStart(o.length - s, "0"), s = 0);
1913
- let a = o.length - 1;
1914
- for (; a >= s && o[a] === "0"; a--)
2219
+ let s = (n < 0n ? -n : n).toString(10), o = s.length - t;
2220
+ o < 0 && (s = s.padStart(s.length - o, "0"), o = 0);
2221
+ let a = s.length - 1;
2222
+ for (; a >= o && s[a] === "0"; a--)
1915
2223
  ;
1916
- let i = o.slice(0, s), l = o.slice(s, a + 1);
2224
+ let i = s.slice(0, o), l = s.slice(o, a + 1);
1917
2225
  return i || (i = "0"), n < 0n && (i = "-" + i), l ? `${i}.${l}` : i;
1918
2226
  },
1919
2227
  decode: (n) => {
@@ -1921,24 +2229,24 @@ function vn(t, e = !1) {
1921
2229
  throw new Error(`expected string, got ${typeof n}`);
1922
2230
  if (n === "-0")
1923
2231
  throw new Error("negative zero is not allowed");
1924
- let o = !1;
1925
- if (n.startsWith("-") && (o = !0, n = n.slice(1)), !/^(0|[1-9]\d*)(\.\d+)?$/.test(n))
2232
+ let s = !1;
2233
+ if (n.startsWith("-") && (s = !0, n = n.slice(1)), !/^(0|[1-9]\d*)(\.\d+)?$/.test(n))
1926
2234
  throw new Error(`wrong string value=${n}`);
1927
- let s = n.indexOf(".");
1928
- s = s === -1 ? n.length : s;
1929
- const a = n.slice(0, s), i = n.slice(s + 1).replace(/0+$/, ""), l = BigInt(a) * r;
2235
+ let o = n.indexOf(".");
2236
+ o = o === -1 ? n.length : o;
2237
+ const a = n.slice(0, o), i = n.slice(o + 1).replace(/0+$/, ""), l = BigInt(a) * r;
1930
2238
  if (!e && i.length > t)
1931
2239
  throw new Error(`fractional part cannot be represented with this precision (num=${n}, prec=${t})`);
1932
2240
  const c = Math.min(i.length, t), d = BigInt(i.slice(0, c)) * 10n ** BigInt(t - c), h = l + d;
1933
- return o ? -h : h;
2241
+ return s ? -h : h;
1934
2242
  }
1935
2243
  };
1936
2244
  }
1937
- function kn(t) {
2245
+ function Cs(t) {
1938
2246
  if (!Array.isArray(t))
1939
2247
  throw new Error(`expected array, got ${typeof t}`);
1940
2248
  for (const e of t)
1941
- if (!fe(e))
2249
+ if (!_e(e))
1942
2250
  throw new Error(`wrong base coder ${e}`);
1943
2251
  return {
1944
2252
  encode: (e) => {
@@ -1959,12 +2267,12 @@ function kn(t) {
1959
2267
  }
1960
2268
  };
1961
2269
  }
1962
- const En = (t) => {
1963
- if (!fe(t))
2270
+ const xs = (t) => {
2271
+ if (!_e(t))
1964
2272
  throw new Error("BaseCoder expected");
1965
2273
  return { encode: t.decode, decode: t.encode };
1966
- }, Z = { dict: bn, numberBigint: Cn, tsEnum: xn, decimal: vn, match: kn, reverse: En }, _n = (t, e = !1, r = !1, n = !0) => {
1967
- if (!N(t))
2274
+ }, re = { dict: ms, numberBigint: ws, tsEnum: ys, decimal: bs, match: Cs, reverse: xs }, vs = (t, e = !1, r = !1, n = !0) => {
2275
+ if (!R(t))
1968
2276
  throw new Error(`bigint/size: wrong value ${t}`);
1969
2277
  if (typeof e != "boolean")
1970
2278
  throw new Error(`bigint/le: expected boolean, got ${typeof e}`);
@@ -1972,11 +2280,11 @@ const En = (t) => {
1972
2280
  throw new Error(`bigint/signed: expected boolean, got ${typeof r}`);
1973
2281
  if (typeof n != "boolean")
1974
2282
  throw new Error(`bigint/sized: expected boolean, got ${typeof n}`);
1975
- const o = BigInt(t), s = 2n ** (8n * o - 1n);
1976
- return I({
2283
+ const s = BigInt(t), o = 2n ** (8n * s - 1n);
2284
+ return L({
1977
2285
  size: n ? t : void 0,
1978
2286
  encodeStream: (a, i) => {
1979
- r && i < 0 && (i = i | s);
2287
+ r && i < 0 && (i = i | o);
1980
2288
  const l = [];
1981
2289
  for (let d = 0; d < t; d++)
1982
2290
  l.push(Number(i & 255n)), i >>= 8n;
@@ -1990,51 +2298,51 @@ const En = (t) => {
1990
2298
  a.bytes(e ? c.reverse() : c);
1991
2299
  },
1992
2300
  decodeStream: (a) => {
1993
- const i = a.bytes(n ? t : Math.min(t, a.leftBytes)), l = e ? i : Ae(i);
2301
+ const i = a.bytes(n ? t : Math.min(t, a.leftBytes)), l = e ? i : Ve(i);
1994
2302
  let c = 0n;
1995
2303
  for (let d = 0; d < l.length; d++)
1996
2304
  c |= BigInt(l[d]) << 8n * BigInt(d);
1997
- return r && c & s && (c = (c ^ s) - s), c;
2305
+ return r && c & o && (c = (c ^ o) - o), c;
1998
2306
  },
1999
2307
  validate: (a) => {
2000
2308
  if (typeof a != "bigint")
2001
2309
  throw new Error(`bigint: invalid value: ${a}`);
2002
- return yn(a, 8n * o, !!r), a;
2310
+ return gs(a, 8n * s, !!r), a;
2003
2311
  }
2004
2312
  });
2005
- }, k = /* @__PURE__ */ _n(8, !0), An = (t, e) => I({
2313
+ }, k = /* @__PURE__ */ vs(8, !0), ks = (t, e) => L({
2006
2314
  size: t,
2007
- encodeStream: (r, n) => r.writeView(t, (o) => e.write(o, n)),
2315
+ encodeStream: (r, n) => r.writeView(t, (s) => e.write(s, n)),
2008
2316
  decodeStream: (r) => r.readView(t, e.read),
2009
2317
  validate: (r) => {
2010
2318
  if (typeof r != "number")
2011
2319
  throw new Error(`viewCoder: expected number, got ${typeof r}`);
2012
2320
  return e.validate && e.validate(r), r;
2013
2321
  }
2014
- }), Bt = (t, e, r) => {
2015
- const n = t * 8, o = 2 ** (n - 1), s = (l) => {
2016
- if (!N(l))
2322
+ }), pr = (t, e, r) => {
2323
+ const n = t * 8, s = 2 ** (n - 1), o = (l) => {
2324
+ if (!R(l))
2017
2325
  throw new Error(`sintView: value is not safe integer: ${l}`);
2018
- if (l < -o || l >= o)
2019
- throw new Error(`sintView: value out of bounds. Expected ${-o} <= ${l} < ${o}`);
2326
+ if (l < -s || l >= s)
2327
+ throw new Error(`sintView: value out of bounds. Expected ${-s} <= ${l} < ${s}`);
2020
2328
  }, a = 2 ** n, i = (l) => {
2021
- if (!N(l))
2329
+ if (!R(l))
2022
2330
  throw new Error(`uintView: value is not safe integer: ${l}`);
2023
2331
  if (0 > l || l >= a)
2024
2332
  throw new Error(`uintView: value out of bounds. Expected 0 <= ${l} < ${a}`);
2025
2333
  };
2026
- return An(t, {
2334
+ return ks(t, {
2027
2335
  write: r.write,
2028
2336
  read: r.read,
2029
- validate: e ? s : i
2337
+ validate: e ? o : i
2030
2338
  });
2031
- }, le = /* @__PURE__ */ Bt(4, !1, {
2339
+ }, xe = /* @__PURE__ */ pr(4, !1, {
2032
2340
  read: (t, e) => t.getUint32(e, !0),
2033
2341
  write: (t, e) => t.setUint32(0, e, !0)
2034
- }), $ = /* @__PURE__ */ Bt(1, !1, {
2342
+ }), N = /* @__PURE__ */ pr(1, !1, {
2035
2343
  read: (t, e) => t.getUint8(e),
2036
2344
  write: (t, e) => t.setUint8(0, e)
2037
- }), Ie = /* @__PURE__ */ I({
2345
+ }), qe = /* @__PURE__ */ L({
2038
2346
  size: 1,
2039
2347
  encodeStream: (t, e) => t.byte(e ? 1 : 0),
2040
2348
  decodeStream: (t) => {
@@ -2048,70 +2356,70 @@ const En = (t) => {
2048
2356
  throw new Error(`bool: invalid value ${t}`);
2049
2357
  return t;
2050
2358
  }
2051
- }), ue = (t, e = !1) => {
2359
+ }), Ae = (t, e = !1) => {
2052
2360
  if (typeof e != "boolean")
2053
2361
  throw new Error(`bytes/le: expected boolean, got ${typeof e}`);
2054
- const r = Lt(t), n = U(t);
2055
- return I({
2362
+ const r = hr(t), n = F(t);
2363
+ return L({
2056
2364
  size: typeof t == "number" ? t : void 0,
2057
- encodeStream: (o, s) => {
2058
- n || r.encodeStream(o, s.length), o.bytes(e ? Ae(s) : s), n && o.bytes(t);
2365
+ encodeStream: (s, o) => {
2366
+ n || r.encodeStream(s, o.length), s.bytes(e ? Ve(o) : o), n && s.bytes(t);
2059
2367
  },
2060
- decodeStream: (o) => {
2061
- let s;
2368
+ decodeStream: (s) => {
2369
+ let o;
2062
2370
  if (n) {
2063
- const a = o.find(t);
2371
+ const a = s.find(t);
2064
2372
  if (!a)
2065
- throw o.err("bytes: cannot find terminator");
2066
- s = o.bytes(a - o.pos), o.bytes(t.length);
2373
+ throw s.err("bytes: cannot find terminator");
2374
+ o = s.bytes(a - s.pos), s.bytes(t.length);
2067
2375
  } else
2068
- s = o.bytes(t === null ? o.leftBytes : r.decodeStream(o));
2069
- return e ? Ae(s) : s;
2376
+ o = s.bytes(t === null ? s.leftBytes : r.decodeStream(s));
2377
+ return e ? Ve(o) : o;
2070
2378
  },
2071
- validate: (o) => {
2072
- if (!U(o))
2073
- throw new Error(`bytes: invalid value ${o}`);
2074
- return o;
2379
+ validate: (s) => {
2380
+ if (!F(s))
2381
+ throw new Error(`bytes: invalid value ${s}`);
2382
+ return s;
2075
2383
  }
2076
2384
  });
2077
- }, In = (t, e = !1) => Pt(Sn(ue(t, e), pn), (r) => {
2385
+ }, Es = (t, e = !1) => ur(_s(Ae(t, e), hs), (r) => {
2078
2386
  if (typeof r != "string")
2079
2387
  throw new Error(`expected string, got ${typeof r}`);
2080
2388
  return r;
2081
2389
  });
2082
- function Sn(t, e) {
2083
- if (!L(t))
2390
+ function _s(t, e) {
2391
+ if (!T(t))
2084
2392
  throw new Error(`apply: invalid inner value ${t}`);
2085
- if (!fe(e))
2393
+ if (!_e(e))
2086
2394
  throw new Error(`apply: invalid base value ${t}`);
2087
- return I({
2395
+ return L({
2088
2396
  size: t.size,
2089
2397
  encodeStream: (r, n) => {
2090
- let o;
2398
+ let s;
2091
2399
  try {
2092
- o = e.decode(n);
2093
- } catch (s) {
2094
- throw r.err("" + s);
2400
+ s = e.decode(n);
2401
+ } catch (o) {
2402
+ throw r.err("" + o);
2095
2403
  }
2096
- return t.encodeStream(r, o);
2404
+ return t.encodeStream(r, s);
2097
2405
  },
2098
2406
  decodeStream: (r) => {
2099
2407
  const n = t.decodeStream(r);
2100
2408
  try {
2101
2409
  return e.encode(n);
2102
- } catch (o) {
2103
- throw r.err("" + o);
2410
+ } catch (s) {
2411
+ throw r.err("" + s);
2104
2412
  }
2105
2413
  }
2106
2414
  });
2107
2415
  }
2108
- function G(t, e, r) {
2109
- if (!L(t) || !L(e))
2416
+ function se(t, e, r) {
2417
+ if (!T(t) || !T(e))
2110
2418
  throw new Error(`optional: invalid flag or inner value flag=${t} inner=${e}`);
2111
- return I({
2419
+ return L({
2112
2420
  size: r !== void 0 && t.size && e.size ? t.size + e.size : void 0,
2113
- encodeStream: (n, o) => {
2114
- t.encodeStream(n, !!o), o ? e.encodeStream(n, o) : r !== void 0 && e.encodeStream(n, r);
2421
+ encodeStream: (n, s) => {
2422
+ t.encodeStream(n, !!s), s ? e.encodeStream(n, s) : r !== void 0 && e.encodeStream(n, r);
2115
2423
  },
2116
2424
  decodeStream: (n) => {
2117
2425
  if (t.decodeStream(n))
@@ -2120,8 +2428,8 @@ function G(t, e, r) {
2120
2428
  }
2121
2429
  });
2122
2430
  }
2123
- function $n(t) {
2124
- return I({
2431
+ function As(t) {
2432
+ return L({
2125
2433
  encodeStream: (e, r) => {
2126
2434
  if (r !== t)
2127
2435
  throw new Error(`constant: invalid value ${r} (exp: ${t})`);
@@ -2129,36 +2437,36 @@ function $n(t) {
2129
2437
  decodeStream: (e) => t
2130
2438
  });
2131
2439
  }
2132
- function Ln(t) {
2440
+ function Ss(t) {
2133
2441
  let e = 0;
2134
2442
  for (const r of t) {
2135
2443
  if (r.size === void 0)
2136
2444
  return;
2137
- if (!N(r.size))
2445
+ if (!R(r.size))
2138
2446
  throw new Error(`sizeof: wrong element size=${e}`);
2139
2447
  e += r.size;
2140
2448
  }
2141
2449
  return e;
2142
2450
  }
2143
- function g(t) {
2144
- if (!Q(t))
2451
+ function p(t) {
2452
+ if (!q(t))
2145
2453
  throw new Error(`struct: expected plain object, got ${t}`);
2146
2454
  for (const e in t)
2147
- if (!L(t[e]))
2455
+ if (!T(t[e]))
2148
2456
  throw new Error(`struct: field ${e} is not CoderType`);
2149
- return I({
2150
- size: Ln(Object.values(t)),
2457
+ return L({
2458
+ size: Ss(Object.values(t)),
2151
2459
  encodeStream: (e, r) => {
2152
2460
  e.pushObj(r, (n) => {
2153
- for (const o in t)
2154
- n(o, () => t[o].encodeStream(e, r[o]));
2461
+ for (const s in t)
2462
+ n(s, () => t[s].encodeStream(e, r[s]));
2155
2463
  });
2156
2464
  },
2157
2465
  decodeStream: (e) => {
2158
2466
  const r = {};
2159
2467
  return e.pushObj(r, (n) => {
2160
- for (const o in t)
2161
- n(o, () => r[o] = t[o].decodeStream(e));
2468
+ for (const s in t)
2469
+ n(s, () => r[s] = t[s].decodeStream(e));
2162
2470
  }), r;
2163
2471
  },
2164
2472
  validate: (e) => {
@@ -2168,50 +2476,50 @@ function g(t) {
2168
2476
  }
2169
2477
  });
2170
2478
  }
2171
- function oe(t, e) {
2172
- if (!L(e))
2479
+ function pe(t, e) {
2480
+ if (!T(e))
2173
2481
  throw new Error(`array: invalid inner value ${e}`);
2174
- const r = Lt(typeof t == "string" ? `../${t}` : t);
2175
- return I({
2482
+ const r = hr(typeof t == "string" ? `../${t}` : t);
2483
+ return L({
2176
2484
  size: typeof t == "number" && e.size ? t * e.size : void 0,
2177
- encodeStream: (n, o) => {
2178
- const s = n;
2179
- s.pushObj(o, (a) => {
2180
- U(t) || r.encodeStream(n, o.length);
2181
- for (let i = 0; i < o.length; i++)
2485
+ encodeStream: (n, s) => {
2486
+ const o = n;
2487
+ o.pushObj(s, (a) => {
2488
+ F(t) || r.encodeStream(n, s.length);
2489
+ for (let i = 0; i < s.length; i++)
2182
2490
  a(`${i}`, () => {
2183
- const l = o[i], c = n.pos;
2184
- if (e.encodeStream(n, l), U(t)) {
2185
- if (t.length > s.pos - c)
2491
+ const l = s[i], c = n.pos;
2492
+ if (e.encodeStream(n, l), F(t)) {
2493
+ if (t.length > o.pos - c)
2186
2494
  return;
2187
- const d = s.finish(!1).subarray(c, s.pos);
2188
- if (_e(d.subarray(0, t.length), t))
2189
- throw s.err(`array: inner element encoding same as separator. elm=${l} data=${d}`);
2495
+ const d = o.finish(!1).subarray(c, o.pos);
2496
+ if (Ye(d.subarray(0, t.length), t))
2497
+ throw o.err(`array: inner element encoding same as separator. elm=${l} data=${d}`);
2190
2498
  }
2191
2499
  });
2192
- }), U(t) && n.bytes(t);
2500
+ }), F(t) && n.bytes(t);
2193
2501
  },
2194
2502
  decodeStream: (n) => {
2195
- const o = [];
2196
- return n.pushObj(o, (s) => {
2503
+ const s = [];
2504
+ return n.pushObj(s, (o) => {
2197
2505
  if (t === null)
2198
- for (let a = 0; !n.isEnd() && (s(`${a}`, () => o.push(e.decodeStream(n))), !(e.size && n.leftBytes < e.size)); a++)
2506
+ for (let a = 0; !n.isEnd() && (o(`${a}`, () => s.push(e.decodeStream(n))), !(e.size && n.leftBytes < e.size)); a++)
2199
2507
  ;
2200
- else if (U(t))
2508
+ else if (F(t))
2201
2509
  for (let a = 0; ; a++) {
2202
- if (_e(n.bytes(t.length, !0), t)) {
2510
+ if (Ye(n.bytes(t.length, !0), t)) {
2203
2511
  n.bytes(t.length);
2204
2512
  break;
2205
2513
  }
2206
- s(`${a}`, () => o.push(e.decodeStream(n)));
2514
+ o(`${a}`, () => s.push(e.decodeStream(n)));
2207
2515
  }
2208
2516
  else {
2209
2517
  let a;
2210
- s("arrayLen", () => a = r.decodeStream(n));
2518
+ o("arrayLen", () => a = r.decodeStream(n));
2211
2519
  for (let i = 0; i < a; i++)
2212
- s(`${i}`, () => o.push(e.decodeStream(n)));
2520
+ o(`${i}`, () => s.push(e.decodeStream(n)));
2213
2521
  }
2214
- }), o;
2522
+ }), s;
2215
2523
  },
2216
2524
  validate: (n) => {
2217
2525
  if (!Array.isArray(n))
@@ -2220,22 +2528,22 @@ function oe(t, e) {
2220
2528
  }
2221
2529
  });
2222
2530
  }
2223
- function ze(t, e) {
2224
- if (!L(t))
2531
+ function ct(t, e) {
2532
+ if (!T(t))
2225
2533
  throw new Error(`map: invalid inner value ${t}`);
2226
- if (!Q(e))
2534
+ if (!q(e))
2227
2535
  throw new Error("map: variants should be plain object");
2228
2536
  const r = /* @__PURE__ */ new Map();
2229
2537
  for (const n in e)
2230
2538
  r.set(e[n], n);
2231
- return I({
2539
+ return L({
2232
2540
  size: t.size,
2233
- encodeStream: (n, o) => t.encodeStream(n, e[o]),
2541
+ encodeStream: (n, s) => t.encodeStream(n, e[s]),
2234
2542
  decodeStream: (n) => {
2235
- const o = t.decodeStream(n), s = r.get(o);
2236
- if (s === void 0)
2237
- throw n.err(`Enum: unknown value: ${o} ${Array.from(r.keys())}`);
2238
- return s;
2543
+ const s = t.decodeStream(n), o = r.get(s);
2544
+ if (o === void 0)
2545
+ throw n.err(`Enum: unknown value: ${s} ${Array.from(r.keys())}`);
2546
+ return o;
2239
2547
  },
2240
2548
  validate: (n) => {
2241
2549
  if (typeof n != "string")
@@ -2246,25 +2554,25 @@ function ze(t, e) {
2246
2554
  }
2247
2555
  });
2248
2556
  }
2249
- function Nn(t, e) {
2250
- if (!L(t))
2557
+ function Is(t, e) {
2558
+ if (!T(t))
2251
2559
  throw new Error(`tag: invalid tag value ${t}`);
2252
- if (!Q(e))
2560
+ if (!q(e))
2253
2561
  throw new Error("tag: variants should be plain object");
2254
2562
  for (const r in e)
2255
- if (!L(e[r]))
2563
+ if (!T(e[r]))
2256
2564
  throw new Error(`tag: variant ${r} is not CoderType`);
2257
- return I({
2565
+ return L({
2258
2566
  size: t.size,
2259
2567
  encodeStream: (r, n) => {
2260
- const { TAG: o, data: s } = n, a = e[o];
2261
- t.encodeStream(r, o), a.encodeStream(r, s);
2568
+ const { TAG: s, data: o } = n, a = e[s];
2569
+ t.encodeStream(r, s), a.encodeStream(r, o);
2262
2570
  },
2263
2571
  decodeStream: (r) => {
2264
- const n = t.decodeStream(r), o = e[n];
2265
- if (!o)
2572
+ const n = t.decodeStream(r), s = e[n];
2573
+ if (!s)
2266
2574
  throw r.err(`Tag: invalid tag ${n}`);
2267
- return { TAG: n, data: o.decodeStream(r) };
2575
+ return { TAG: n, data: s.decodeStream(r) };
2268
2576
  },
2269
2577
  validate: (r) => {
2270
2578
  const { TAG: n } = r;
@@ -2274,34 +2582,34 @@ function Nn(t, e) {
2274
2582
  }
2275
2583
  });
2276
2584
  }
2277
- const Pn = (t) => 0;
2278
- function ye(t, e) {
2585
+ const $s = (t) => 0;
2586
+ function Ne(t, e) {
2279
2587
  return e % t === 0 ? 0 : t - e % t;
2280
2588
  }
2281
- function Tt(t, e, r) {
2282
- if (!L(e))
2589
+ function gr(t, e, r) {
2590
+ if (!T(e))
2283
2591
  throw new Error(`padRight: invalid inner value ${e}`);
2284
- if (!N(t) || t <= 0)
2592
+ if (!R(t) || t <= 0)
2285
2593
  throw new Error(`padLeft: wrong blockSize=${t}`);
2286
2594
  if (r !== void 0 && typeof r != "function")
2287
2595
  throw new Error(`padRight: wrong padFn=${typeof r}`);
2288
- const n = r || Pn;
2289
- return I({
2290
- size: e.size ? e.size + ye(t, e.size) : void 0,
2291
- encodeStream: (o, s) => {
2292
- const a = o, i = a.pos;
2293
- e.encodeStream(o, s);
2294
- const l = ye(t, a.pos - i);
2596
+ const n = r || $s;
2597
+ return L({
2598
+ size: e.size ? e.size + Ne(t, e.size) : void 0,
2599
+ encodeStream: (s, o) => {
2600
+ const a = s, i = a.pos;
2601
+ e.encodeStream(s, o);
2602
+ const l = Ne(t, a.pos - i);
2295
2603
  for (let c = 0; c < l; c++)
2296
- o.byte(n(c));
2604
+ s.byte(n(c));
2297
2605
  },
2298
- decodeStream: (o) => {
2299
- const s = o.pos, a = e.decodeStream(o);
2300
- return o.bytes(ye(t, o.pos - s)), a;
2606
+ decodeStream: (s) => {
2607
+ const o = s.pos, a = e.decodeStream(s);
2608
+ return s.bytes(Ne(t, s.pos - o)), a;
2301
2609
  }
2302
2610
  });
2303
2611
  }
2304
- const Bn = 9, be = Z.decimal(Bn), K = I({
2612
+ const Ls = 9, Be = re.decimal(Ls), ne = L({
2305
2613
  encodeStream: (t, e) => {
2306
2614
  if (!e)
2307
2615
  return t.byte(0);
@@ -2317,55 +2625,55 @@ const Bn = 9, be = Z.decimal(Bn), K = I({
2317
2625
  }
2318
2626
  return e;
2319
2627
  }
2320
- }), ne = In(Tt(8, le, void 0)), Tn = () => {
2321
- const t = ue(32);
2322
- return I({
2628
+ }), ue = Es(gr(8, xe, void 0)), Ps = () => {
2629
+ const t = Ae(32);
2630
+ return L({
2323
2631
  size: t.size,
2324
- encodeStream: (e, r) => t.encodeStream(e, Ee.decode(r)),
2325
- decodeStream: (e) => Ee.encode(t.decodeStream(e))
2632
+ encodeStream: (e, r) => t.encodeStream(e, We.decode(r)),
2633
+ decodeStream: (e) => We.encode(t.decodeStream(e))
2326
2634
  });
2327
- }, b = Tn(), Rn = g({
2328
- requiredSignatures: $,
2329
- readSigned: $,
2330
- readUnsigned: $,
2331
- keys: oe(K, b),
2635
+ }, b = Ps(), Ns = p({
2636
+ requiredSignatures: N,
2637
+ readSigned: N,
2638
+ readUnsigned: N,
2639
+ keys: pe(ne, b),
2332
2640
  blockhash: b,
2333
- instructions: oe(K, g({ programIdx: $, keys: oe(K, $), data: ue(K) }))
2641
+ instructions: pe(ne, p({ programIdx: N, keys: pe(ne, N), data: Ae(ne) }))
2334
2642
  });
2335
- function Un(t) {
2336
- if (Ee.decode(t).length !== 32)
2643
+ function Bs(t) {
2644
+ if (We.decode(t).length !== 32)
2337
2645
  throw new Error("Invalid Solana address");
2338
2646
  }
2339
- const Mn = (t, e, r, n, o) => ({
2647
+ const Ts = (t, e, r, n, s) => ({
2340
2648
  sign: t < e,
2341
- write: t < e - r || t >= e && t < o - n
2342
- }), ot = g({
2343
- signatures: oe(K, ue(64)),
2344
- msg: Rn
2345
- }), Se = I({
2649
+ write: t < e - r || t >= e && t < s - n
2650
+ }), $t = p({
2651
+ signatures: pe(ne, Ae(64)),
2652
+ msg: Ns
2653
+ }), Ke = L({
2346
2654
  encodeStream: (t, e) => {
2347
- const { msg: r, signatures: n } = e, o = {}, s = (h, f, u) => {
2348
- let p = o[h] || (o[h] = { sign: !1, write: !1 });
2349
- p.write || (p.write = u), p.sign || (p.sign = f);
2655
+ const { msg: r, signatures: n } = e, s = {}, o = (h, f, u) => {
2656
+ let g = s[h] || (s[h] = { sign: !1, write: !1 });
2657
+ g.write || (g.write = u), g.sign || (g.sign = f);
2350
2658
  };
2351
- s(r.feePayer, !0, !0);
2659
+ o(r.feePayer, !0, !0);
2352
2660
  for (let h of r.instructions)
2353
2661
  for (let f of h.keys)
2354
- s(f.address, f.sign, f.write);
2662
+ o(f.address, f.sign, f.write);
2355
2663
  for (let h of r.instructions)
2356
- s(h.program, !1, !1);
2357
- const a = Object.keys(o), i = [
2664
+ o(h.program, !1, !1);
2665
+ const a = Object.keys(s), i = [
2358
2666
  r.feePayer,
2359
- ...a.filter((h) => o[h].sign && o[h].write && h !== r.feePayer),
2360
- ...a.filter((h) => o[h].sign && !o[h].write),
2361
- ...a.filter((h) => !o[h].sign && o[h].write),
2362
- ...a.filter((h) => !o[h].sign && !o[h].write)
2667
+ ...a.filter((h) => s[h].sign && s[h].write && h !== r.feePayer),
2668
+ ...a.filter((h) => s[h].sign && !s[h].write),
2669
+ ...a.filter((h) => !s[h].sign && s[h].write),
2670
+ ...a.filter((h) => !s[h].sign && !s[h].write)
2363
2671
  ];
2364
2672
  let l = 0, c = 0, d = 0;
2365
2673
  for (let h of i)
2366
- o[h].sign && l++, !o[h].write && (o[h].sign ? c++ : d++);
2367
- ot.encodeStream(t, {
2368
- signatures: i.filter((h) => o[h].sign).map((h) => n[h] || new Uint8Array(64)),
2674
+ s[h].sign && l++, !s[h].write && (s[h].sign ? c++ : d++);
2675
+ $t.encodeStream(t, {
2676
+ signatures: i.filter((h) => s[h].sign).map((h) => n[h] || new Uint8Array(64)),
2369
2677
  msg: {
2370
2678
  requiredSignatures: l,
2371
2679
  readSigned: c,
@@ -2382,51 +2690,51 @@ const Mn = (t, e, r, n, o) => ({
2382
2690
  });
2383
2691
  },
2384
2692
  decodeStream: (t) => {
2385
- const { signatures: e, msg: r } = ot.decodeStream(t);
2693
+ const { signatures: e, msg: r } = $t.decodeStream(t);
2386
2694
  if (e.length !== r.requiredSignatures)
2387
2695
  throw new Error("SOL.tx: wrong signatures length");
2388
2696
  if (r.keys.length < e.length)
2389
2697
  throw new Error("SOL.tx: invalid keys length");
2390
2698
  const n = {};
2391
- for (let s = 0; s < e.length; s++)
2392
- n[r.keys[s]] = e[s];
2393
- let o = [];
2394
- for (let s = 0; s < r.keys.length; s++)
2395
- o.push({
2396
- address: r.keys[s],
2397
- ...Mn(s, r.requiredSignatures, r.readSigned, r.readUnsigned, r.keys.length)
2699
+ for (let o = 0; o < e.length; o++)
2700
+ n[r.keys[o]] = e[o];
2701
+ let s = [];
2702
+ for (let o = 0; o < r.keys.length; o++)
2703
+ s.push({
2704
+ address: r.keys[o],
2705
+ ...Ts(o, r.requiredSignatures, r.readSigned, r.readUnsigned, r.keys.length)
2398
2706
  });
2399
- if (!o.length)
2707
+ if (!s.length)
2400
2708
  throw new Error("SOL.tx: empty accounts array");
2401
2709
  return {
2402
2710
  msg: {
2403
- feePayer: o[0].address,
2711
+ feePayer: s[0].address,
2404
2712
  blockhash: r.blockhash,
2405
- instructions: r.instructions.map((s) => ({
2406
- program: o[s.programIdx].address,
2407
- keys: s.keys.map((a) => o[a]),
2408
- data: s.data
2713
+ instructions: r.instructions.map((o) => ({
2714
+ program: s[o.programIdx].address,
2715
+ keys: o.keys.map((a) => s[a]),
2716
+ data: o.data
2409
2717
  }))
2410
2718
  },
2411
2719
  signatures: n
2412
2720
  };
2413
2721
  }
2414
- }), st = {};
2415
- function Oe(t, e, r) {
2416
- if (st[t])
2722
+ }), Lt = {};
2723
+ function lt(t, e, r) {
2724
+ if (Lt[t])
2417
2725
  throw new Error("SOL: program for this address already defined");
2418
- const n = ze(e, Object.keys(r).reduce((i, l, c) => ({ ...i, [l]: c }), {})), o = Object.keys(r).reduce((i, l) => ({ ...i, [l]: r[l].coder }), {}), s = Nn(n, o);
2419
- st[t] = (i, l) => {
2726
+ const n = ct(e, Object.keys(r).reduce((i, l, c) => ({ ...i, [l]: c }), {})), s = Object.keys(r).reduce((i, l) => ({ ...i, [l]: r[l].coder }), {}), o = Is(n, s);
2727
+ Lt[t] = (i, l) => {
2420
2728
  if (i.program !== t)
2421
2729
  throw new Error("SOL.parseInstruction: Wrong instruction program address");
2422
- const { TAG: c, data: d } = s.decode(i.data), h = { type: c, info: d }, f = Object.keys(r[c].keys);
2730
+ const { TAG: c, data: d } = o.decode(i.data), h = { type: c, info: d }, f = Object.keys(r[c].keys);
2423
2731
  if (f.length !== i.keys.length)
2424
2732
  throw new Error("SOL.parseInstruction: Keys length mismatch");
2425
2733
  for (let u = 0; u < f.length; u++) {
2426
- const p = f[u];
2427
- if (r[c].keys[p].address) {
2428
- if (r[c].keys[p].address !== i.keys[u].address)
2429
- throw new Error(`SOL.parseInstruction(${t}/${c}): Invalid constant address for key exp=${r[c].keys[p].address} got=${i.keys[u].address}`);
2734
+ const g = f[u];
2735
+ if (r[c].keys[g].address) {
2736
+ if (r[c].keys[g].address !== i.keys[u].address)
2737
+ throw new Error(`SOL.parseInstruction(${t}/${c}): Invalid constant address for key exp=${r[c].keys[g].address} got=${i.keys[u].address}`);
2430
2738
  continue;
2431
2739
  }
2432
2740
  h.info[f[u]] = i.keys[u].address;
@@ -2437,37 +2745,37 @@ function Oe(t, e, r) {
2437
2745
  for (const i in r)
2438
2746
  a[i] = (l) => ({
2439
2747
  program: t,
2440
- data: s.encode({ TAG: i, data: l }),
2748
+ data: o.encode({ TAG: i, data: l }),
2441
2749
  keys: Object.keys(r[i].keys).map((c) => {
2442
2750
  let { sign: d, write: h, address: f } = r[i].keys[c];
2443
- return f || (f = l[c]), Un(f), { address: f, sign: d, write: h };
2751
+ return f || (f = l[c]), Bs(f), { address: f, sign: d, write: h };
2444
2752
  })
2445
2753
  });
2446
2754
  return a;
2447
2755
  }
2448
- const Ce = "SysvarRecentB1ockHashes11111111111111111111", D = "SysvarRent111111111111111111111111111111111", Rt = "11111111111111111111111111111111", Ut = Oe(Rt, le, {
2756
+ const Te = "SysvarRecentB1ockHashes11111111111111111111", W = "SysvarRent111111111111111111111111111111111", mr = "11111111111111111111111111111111", wr = lt(mr, xe, {
2449
2757
  createAccount: {
2450
- coder: g({ lamports: k, space: k, owner: b }),
2758
+ coder: p({ lamports: k, space: k, owner: b }),
2451
2759
  keys: {
2452
2760
  source: { sign: !0, write: !0 },
2453
2761
  newAccount: { sign: !0, write: !0 }
2454
2762
  },
2455
- hint: (t) => `Create new account=${t.newAccount} with balance of ${be.encode(t.lamports)} and owner program ${t.owner}, using funding account ${t.source}`
2763
+ hint: (t) => `Create new account=${t.newAccount} with balance of ${Be.encode(t.lamports)} and owner program ${t.owner}, using funding account ${t.source}`
2456
2764
  },
2457
2765
  assign: {
2458
- coder: g({ owner: b }),
2766
+ coder: p({ owner: b }),
2459
2767
  keys: { account: { sign: !0, write: !0 } },
2460
2768
  hint: (t) => `Assign account=${t.account} to owner program=${t.owner}`
2461
2769
  },
2462
2770
  transfer: {
2463
- coder: g({ lamports: k }),
2771
+ coder: p({ lamports: k }),
2464
2772
  keys: { source: { sign: !0, write: !0 }, destination: { sign: !1, write: !0 } },
2465
- hint: (t) => `Transfer ${be.encode(t.lamports)} SOL from ${t.source} to ${t.destination}`
2773
+ hint: (t) => `Transfer ${Be.encode(t.lamports)} SOL from ${t.source} to ${t.destination}`
2466
2774
  },
2467
2775
  createAccountWithSeed: {
2468
- coder: g({
2776
+ coder: p({
2469
2777
  base: b,
2470
- seed: ne,
2778
+ seed: ue,
2471
2779
  lamports: k,
2472
2780
  space: k,
2473
2781
  owner: b
@@ -2479,35 +2787,35 @@ const Ce = "SysvarRecentB1ockHashes11111111111111111111", D = "SysvarRent1111111
2479
2787
  }
2480
2788
  },
2481
2789
  advanceNonce: {
2482
- coder: g({}),
2790
+ coder: p({}),
2483
2791
  keys: {
2484
2792
  nonceAccount: { sign: !1, write: !0 },
2485
- _recent_bh: { address: Ce, sign: !1, write: !1 },
2793
+ _recent_bh: { address: Te, sign: !1, write: !1 },
2486
2794
  nonceAuthority: { sign: !0, write: !1 }
2487
2795
  },
2488
2796
  hint: (t) => `Consume nonce in nonce account=${t.nonceAccount} (owner: ${t.nonceAuthority})`
2489
2797
  },
2490
2798
  withdrawFromNonce: {
2491
- coder: g({ lamports: k }),
2799
+ coder: p({ lamports: k }),
2492
2800
  keys: {
2493
2801
  nonceAccount: { sign: !1, write: !0 },
2494
2802
  destination: { sign: !1, write: !0 },
2495
- _recent_bh: { address: Ce, sign: !1, write: !1 },
2496
- _rent: { address: D, sign: !1, write: !1 },
2803
+ _recent_bh: { address: Te, sign: !1, write: !1 },
2804
+ _rent: { address: W, sign: !1, write: !1 },
2497
2805
  nonceAuthority: { sign: !0, write: !1 }
2498
2806
  },
2499
- hint: (t) => `Withdraw ${be.encode(t.lamports)} SOL from nonce account=${t.nonceAccount} (owner: ${t.nonceAuthority}) to ${t.destination}`
2807
+ hint: (t) => `Withdraw ${Be.encode(t.lamports)} SOL from nonce account=${t.nonceAccount} (owner: ${t.nonceAuthority}) to ${t.destination}`
2500
2808
  },
2501
2809
  initializeNonce: {
2502
- coder: g({ nonceAuthority: b }),
2810
+ coder: p({ nonceAuthority: b }),
2503
2811
  keys: {
2504
2812
  nonceAccount: { sign: !1, write: !0 },
2505
- _recent_bh: { address: Ce, sign: !1, write: !1 },
2506
- _rent: { address: D, sign: !1, write: !1 }
2813
+ _recent_bh: { address: Te, sign: !1, write: !1 },
2814
+ _rent: { address: W, sign: !1, write: !1 }
2507
2815
  }
2508
2816
  },
2509
2817
  authorizeNonce: {
2510
- coder: g({ newAuthorized: b }),
2818
+ coder: p({ newAuthorized: b }),
2511
2819
  keys: {
2512
2820
  nonceAccount: { sign: !1, write: !0 },
2513
2821
  nonceAuthority: { sign: !0, write: !1 }
@@ -2515,15 +2823,15 @@ const Ce = "SysvarRecentB1ockHashes11111111111111111111", D = "SysvarRent1111111
2515
2823
  hint: (t) => `Change owner of nonce account=${t.nonceAccount} from ${t.nonceAuthority} to ${t.newAuthorized}`
2516
2824
  },
2517
2825
  allocate: {
2518
- coder: g({ space: k }),
2826
+ coder: p({ space: k }),
2519
2827
  keys: {
2520
2828
  account: { sign: !0, write: !0 }
2521
2829
  }
2522
2830
  },
2523
2831
  allocateWithSeed: {
2524
- coder: g({
2832
+ coder: p({
2525
2833
  base: b,
2526
- seed: ne,
2834
+ seed: ue,
2527
2835
  space: k,
2528
2836
  owner: b
2529
2837
  }),
@@ -2533,9 +2841,9 @@ const Ce = "SysvarRecentB1ockHashes11111111111111111111", D = "SysvarRent1111111
2533
2841
  }
2534
2842
  },
2535
2843
  assignWithSeed: {
2536
- coder: g({
2844
+ coder: p({
2537
2845
  base: b,
2538
- seed: ne,
2846
+ seed: ue,
2539
2847
  owner: b
2540
2848
  }),
2541
2849
  keys: {
@@ -2544,9 +2852,9 @@ const Ce = "SysvarRecentB1ockHashes11111111111111111111", D = "SysvarRent1111111
2544
2852
  }
2545
2853
  },
2546
2854
  transferWithSeed: {
2547
- coder: g({
2855
+ coder: p({
2548
2856
  lamports: k,
2549
- sourceSeed: ne,
2857
+ sourceSeed: ue,
2550
2858
  sourceOwner: b
2551
2859
  }),
2552
2860
  keys: {
@@ -2555,49 +2863,49 @@ const Ce = "SysvarRecentB1ockHashes11111111111111111111", D = "SysvarRent1111111
2555
2863
  destination: { sign: !1, write: !0 }
2556
2864
  }
2557
2865
  }
2558
- }), Mt = (t) => {
2866
+ }), yr = (t) => {
2559
2867
  };
2560
- Mt(Ut.transfer);
2561
- Mt(Ut.advanceNonce);
2562
- const zn = ze($, {
2868
+ yr(wr.transfer);
2869
+ yr(wr.advanceNonce);
2870
+ const Rs = ct(N, {
2563
2871
  MintTokens: 0,
2564
2872
  FreezeAccount: 1,
2565
2873
  AccountOwner: 2,
2566
2874
  CloseAccount: 3
2567
- }), z = (t, e) => e[t]?.symbol || t, zt = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
2568
- Oe(zt, $, {
2875
+ }), j = (t, e) => e[t]?.symbol || t, br = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
2876
+ lt(br, N, {
2569
2877
  initializeMint: {
2570
- coder: g({
2571
- decimals: $,
2878
+ coder: p({
2879
+ decimals: N,
2572
2880
  mintAuthority: b,
2573
- freezeAuthority: G(Ie, b, "11111111111111111111111111111111")
2881
+ freezeAuthority: se(qe, b, "11111111111111111111111111111111")
2574
2882
  }),
2575
2883
  keys: {
2576
2884
  mint: { sign: !1, write: !0 },
2577
- _rent: { address: D, sign: !1, write: !1 }
2885
+ _rent: { address: W, sign: !1, write: !1 }
2578
2886
  }
2579
2887
  },
2580
2888
  initializeAccount: {
2581
- coder: g({}),
2889
+ coder: p({}),
2582
2890
  keys: {
2583
2891
  account: { sign: !1, write: !0 },
2584
2892
  mint: { sign: !1, write: !1 },
2585
2893
  owner: { sign: !1, write: !1 },
2586
- _rent: { address: D, sign: !1, write: !1 }
2894
+ _rent: { address: W, sign: !1, write: !1 }
2587
2895
  },
2588
- hint: (t, e) => `Initialize token account=${t.account} with owner=${t.owner} token=${z(t.mint, e)}`
2896
+ hint: (t, e) => `Initialize token account=${t.account} with owner=${t.owner} token=${j(t.mint, e)}`
2589
2897
  },
2590
2898
  // TODO: multisig support?
2591
2899
  initializeMultisig: {
2592
- coder: g({ m: $ }),
2900
+ coder: p({ m: N }),
2593
2901
  keys: {
2594
2902
  account: { sign: !1, write: !0 },
2595
- _rent: { address: D, sign: !1, write: !1 }
2903
+ _rent: { address: W, sign: !1, write: !1 }
2596
2904
  },
2597
2905
  hint: (t, e) => `Initialize multi-sig token account=${t.account} with signatures=${t.m}`
2598
2906
  },
2599
2907
  transfer: {
2600
- coder: g({ amount: k }),
2908
+ coder: p({ amount: k }),
2601
2909
  keys: {
2602
2910
  source: { sign: !1, write: !0 },
2603
2911
  destination: { sign: !1, write: !0 },
@@ -2606,7 +2914,7 @@ Oe(zt, $, {
2606
2914
  hint: (t, e) => `Transfer ${t.amount} from token account=${t.source} of owner=${t.owner} to ${t.destination}`
2607
2915
  },
2608
2916
  approve: {
2609
- coder: g({ amount: k }),
2917
+ coder: p({ amount: k }),
2610
2918
  keys: {
2611
2919
  account: { sign: !1, write: !0 },
2612
2920
  delegate: { sign: !1, write: !1 },
@@ -2615,7 +2923,7 @@ Oe(zt, $, {
2615
2923
  hint: (t, e) => `Approve authority of delegate=${t.delegate} over tokens on account=${t.account} on behalf of owner=${t.owner}`
2616
2924
  },
2617
2925
  revoke: {
2618
- coder: g({}),
2926
+ coder: p({}),
2619
2927
  keys: {
2620
2928
  account: { sign: !1, write: !0 },
2621
2929
  owner: { sign: !0, write: !1 }
@@ -2623,9 +2931,9 @@ Oe(zt, $, {
2623
2931
  hint: (t, e) => `Revoke delegate's authority over tokens on account=${t.account} on behalf of owner=${t.owner}`
2624
2932
  },
2625
2933
  setAuthority: {
2626
- coder: g({
2627
- authorityType: zn,
2628
- newAuthority: G(Ie, b, "11111111111111111111111111111111")
2934
+ coder: p({
2935
+ authorityType: Rs,
2936
+ newAuthority: se(qe, b, "11111111111111111111111111111111")
2629
2937
  }),
2630
2938
  keys: {
2631
2939
  account: { sign: !1, write: !0 },
@@ -2634,7 +2942,7 @@ Oe(zt, $, {
2634
2942
  hint: (t, e) => `Sets a new authority=${t.newAuthority} of a mint or account=${t.account}. Current authority=${t.currentAuthority}. Authority Type: ${t.authorityType}`
2635
2943
  },
2636
2944
  mintTo: {
2637
- coder: g({ amount: k }),
2945
+ coder: p({ amount: k }),
2638
2946
  keys: {
2639
2947
  mint: { sign: !1, write: !0 },
2640
2948
  dest: { sign: !1, write: !0 },
@@ -2642,7 +2950,7 @@ Oe(zt, $, {
2642
2950
  }
2643
2951
  },
2644
2952
  burn: {
2645
- coder: g({ amount: k }),
2953
+ coder: p({ amount: k }),
2646
2954
  keys: {
2647
2955
  account: { sign: !1, write: !0 },
2648
2956
  mint: { sign: !1, write: !0 },
@@ -2651,7 +2959,7 @@ Oe(zt, $, {
2651
2959
  hint: (t, e) => `Burn ${t.amount} tokens from account=${t.account} of owner=${t.owner} mint=${t.mint}`
2652
2960
  },
2653
2961
  closeAccount: {
2654
- coder: g({}),
2962
+ coder: p({}),
2655
2963
  keys: {
2656
2964
  account: { sign: !1, write: !0 },
2657
2965
  dest: { sign: !1, write: !0 },
@@ -2660,7 +2968,7 @@ Oe(zt, $, {
2660
2968
  hint: (t, e) => `Close token account=${t.account} of owner=${t.owner}, transferring all its SOL to destionation account=${t.dest}`
2661
2969
  },
2662
2970
  freezeAccount: {
2663
- coder: g({}),
2971
+ coder: p({}),
2664
2972
  keys: {
2665
2973
  account: { sign: !1, write: !0 },
2666
2974
  mint: { sign: !1, write: !0 },
@@ -2669,7 +2977,7 @@ Oe(zt, $, {
2669
2977
  hint: (t, e) => `Freeze token account=${t.account} of mint=${t.mint} using freeze_authority=${t.authority}`
2670
2978
  },
2671
2979
  thawAccount: {
2672
- coder: g({}),
2980
+ coder: p({}),
2673
2981
  keys: {
2674
2982
  account: { sign: !1, write: !0 },
2675
2983
  mint: { sign: !1, write: !1 },
@@ -2678,105 +2986,105 @@ Oe(zt, $, {
2678
2986
  hint: (t, e) => `Thaw a frozne token account=${t.account} of mint=${t.mint} using freeze_authority=${t.authority}`
2679
2987
  },
2680
2988
  transferChecked: {
2681
- coder: g({ amount: k, decimals: $ }),
2989
+ coder: p({ amount: k, decimals: N }),
2682
2990
  keys: {
2683
2991
  source: { sign: !1, write: !0 },
2684
2992
  mint: { sign: !1, write: !1 },
2685
2993
  destination: { sign: !1, write: !0 },
2686
2994
  owner: { sign: !0, write: !1 }
2687
2995
  },
2688
- hint: (t, e) => `Transfer ${Z.decimal(t.decimals).encode(t.amount)} ${z(t.mint, e)} from token account=${t.source} of owner=${t.owner} to ${t.destination}`
2996
+ hint: (t, e) => `Transfer ${re.decimal(t.decimals).encode(t.amount)} ${j(t.mint, e)} from token account=${t.source} of owner=${t.owner} to ${t.destination}`
2689
2997
  },
2690
2998
  approveChecked: {
2691
- coder: g({ amount: k, decimals: $ }),
2999
+ coder: p({ amount: k, decimals: N }),
2692
3000
  keys: {
2693
3001
  source: { sign: !1, write: !0 },
2694
3002
  mint: { sign: !1, write: !1 },
2695
3003
  delegate: { sign: !1, write: !1 },
2696
3004
  owner: { sign: !0, write: !1 }
2697
3005
  },
2698
- hint: (t, e) => `Approve delgate=${t.delegate} authority on behalf account=${t.source} owner=${t.owner} over ${Z.decimal(t.decimals).encode(t.amount)} ${z(t.mint, e)}`
3006
+ hint: (t, e) => `Approve delgate=${t.delegate} authority on behalf account=${t.source} owner=${t.owner} over ${re.decimal(t.decimals).encode(t.amount)} ${j(t.mint, e)}`
2699
3007
  },
2700
3008
  mintToChecked: {
2701
- coder: g({ amount: k, decimals: $ }),
3009
+ coder: p({ amount: k, decimals: N }),
2702
3010
  keys: {
2703
3011
  mint: { sign: !1, write: !0 },
2704
3012
  dest: { sign: !1, write: !0 },
2705
3013
  authority: { sign: !0, write: !1 }
2706
3014
  },
2707
- hint: (t, e) => `Mint new tokens (${Z.decimal(t.decimals).encode(t.amount)} ${z(t.mint, e)}) to account=${t.dest} using authority=${t.authority}`
3015
+ hint: (t, e) => `Mint new tokens (${re.decimal(t.decimals).encode(t.amount)} ${j(t.mint, e)}) to account=${t.dest} using authority=${t.authority}`
2708
3016
  },
2709
3017
  burnChecked: {
2710
- coder: g({ amount: k, decimals: $ }),
3018
+ coder: p({ amount: k, decimals: N }),
2711
3019
  keys: {
2712
3020
  mint: { sign: !1, write: !0 },
2713
3021
  account: { sign: !1, write: !0 },
2714
3022
  owner: { sign: !0, write: !1 }
2715
3023
  },
2716
- hint: (t, e) => `Burn tokens (${Z.decimal(t.decimals).encode(t.amount)} ${z(t.mint, e)}) on account=${t.account} of owner=${t.owner}`
3024
+ hint: (t, e) => `Burn tokens (${re.decimal(t.decimals).encode(t.amount)} ${j(t.mint, e)}) on account=${t.account} of owner=${t.owner}`
2717
3025
  },
2718
3026
  initializeAccount2: {
2719
- coder: g({ owner: b }),
3027
+ coder: p({ owner: b }),
2720
3028
  keys: {
2721
3029
  account: { sign: !1, write: !0 },
2722
3030
  mint: { sign: !1, write: !1 },
2723
- _rent: { address: D, sign: !1, write: !1 }
3031
+ _rent: { address: W, sign: !1, write: !1 }
2724
3032
  },
2725
- hint: (t, e) => `Initialize token account=${t.account} with owner=${t.owner} token=${z(t.mint, e)}`
3033
+ hint: (t, e) => `Initialize token account=${t.account} with owner=${t.owner} token=${j(t.mint, e)}`
2726
3034
  },
2727
3035
  syncNative: {
2728
- coder: g({}),
3036
+ coder: p({}),
2729
3037
  keys: { nativeAccount: { sign: !1, write: !0 } },
2730
3038
  hint: (t) => `Sync SOL balance for wrapped account ${t.nativeAccount}`
2731
3039
  }
2732
3040
  });
2733
- g({
2734
- version: le,
2735
- state: le,
3041
+ p({
3042
+ version: xe,
3043
+ state: xe,
2736
3044
  authority: b,
2737
3045
  nonce: b,
2738
3046
  lamportPerSignature: k
2739
3047
  });
2740
- const On = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
2741
- Oe(On, $n(0), {
3048
+ const Us = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
3049
+ lt(Us, As(0), {
2742
3050
  create: {
2743
- coder: g({}),
3051
+ coder: p({}),
2744
3052
  keys: {
2745
3053
  source: { sign: !0, write: !0 },
2746
3054
  account: { sign: !1, write: !0 },
2747
3055
  wallet: { sign: !1, write: !1 },
2748
3056
  mint: { sign: !1, write: !1 },
2749
- _sys: { address: Rt, sign: !1, write: !1 },
2750
- _token: { address: zt, sign: !1, write: !1 },
2751
- _rent: { address: D, sign: !1, write: !1 }
3057
+ _sys: { address: mr, sign: !1, write: !1 },
3058
+ _token: { address: br, sign: !1, write: !1 },
3059
+ _rent: { address: W, sign: !1, write: !1 }
2752
3060
  },
2753
- hint: (t, e) => `Initialize associated token account=${t.account} with owner=${t.wallet} for token=${z(t.mint, e)}, payed by ${t.source}`
3061
+ hint: (t, e) => `Initialize associated token account=${t.account} with owner=${t.wallet} for token=${j(t.mint, e)}, payed by ${t.source}`
2754
3062
  }
2755
3063
  });
2756
- const xe = Tt(4, Ie, () => 0);
2757
- g({
3064
+ const Re = gr(4, qe, () => 0);
3065
+ p({
2758
3066
  mint: b,
2759
3067
  owner: b,
2760
3068
  amount: k,
2761
- delegate: G(xe, b, "11111111111111111111111111111111"),
2762
- state: ze($, {
3069
+ delegate: se(Re, b, "11111111111111111111111111111111"),
3070
+ state: ct(N, {
2763
3071
  uninitialized: 0,
2764
3072
  initialized: 1,
2765
3073
  frozen: 2
2766
3074
  }),
2767
- isNative: G(xe, k, 0n),
3075
+ isNative: se(Re, k, 0n),
2768
3076
  delegateAmount: k,
2769
- closeAuthority: G(xe, b, "11111111111111111111111111111111")
3077
+ closeAuthority: se(Re, b, "11111111111111111111111111111111")
2770
3078
  });
2771
- function at(t, e, r) {
3079
+ function Pt(t, e, r) {
2772
3080
  if (!e.length)
2773
3081
  throw new Error("SOLPublic: empty instructions array");
2774
- return fn.encode(Se.encode({
3082
+ return ls.encode(Ke.encode({
2775
3083
  msg: { feePayer: t, blockhash: r, instructions: e },
2776
3084
  signatures: {}
2777
3085
  }));
2778
3086
  }
2779
- function Dn(t) {
3087
+ function Ms(t) {
2780
3088
  if (t.length >= 255)
2781
3089
  throw new TypeError("Alphabet too long");
2782
3090
  const e = new Uint8Array(256);
@@ -2788,7 +3096,7 @@ function Dn(t) {
2788
3096
  throw new TypeError(d + " is ambiguous");
2789
3097
  e[h] = c;
2790
3098
  }
2791
- const r = t.length, n = t.charAt(0), o = Math.log(r) / Math.log(256), s = Math.log(256) / Math.log(r);
3099
+ const r = t.length, n = t.charAt(0), s = Math.log(r) / Math.log(256), o = Math.log(256) / Math.log(r);
2792
3100
  function a(c) {
2793
3101
  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))
2794
3102
  throw new TypeError("Expected Uint8Array");
@@ -2798,22 +3106,22 @@ function Dn(t) {
2798
3106
  const u = c.length;
2799
3107
  for (; f !== u && c[f] === 0; )
2800
3108
  f++, d++;
2801
- const p = (u - f) * s + 1 >>> 0, C = new Uint8Array(p);
3109
+ const g = (u - f) * o + 1 >>> 0, C = new Uint8Array(g);
2802
3110
  for (; f !== u; ) {
2803
3111
  let x = c[f], m = 0;
2804
- for (let E = p - 1; (x !== 0 || m < h) && E !== -1; E--, m++)
2805
- x += 256 * C[E] >>> 0, C[E] = x % r >>> 0, x = x / r >>> 0;
3112
+ for (let _ = g - 1; (x !== 0 || m < h) && _ !== -1; _--, m++)
3113
+ x += 256 * C[_] >>> 0, C[_] = x % r >>> 0, x = x / r >>> 0;
2806
3114
  if (x !== 0)
2807
3115
  throw new Error("Non-zero carry");
2808
3116
  h = m, f++;
2809
3117
  }
2810
- let y = p - h;
2811
- for (; y !== p && C[y] === 0; )
3118
+ let y = g - h;
3119
+ for (; y !== g && C[y] === 0; )
2812
3120
  y++;
2813
- let S = n.repeat(d);
2814
- for (; y < p; ++y)
2815
- S += t.charAt(C[y]);
2816
- return S;
3121
+ let P = n.repeat(d);
3122
+ for (; y < g; ++y)
3123
+ P += t.charAt(C[y]);
3124
+ return P;
2817
3125
  }
2818
3126
  function i(c) {
2819
3127
  if (typeof c != "string")
@@ -2823,7 +3131,7 @@ function Dn(t) {
2823
3131
  let d = 0, h = 0, f = 0;
2824
3132
  for (; c[d] === n; )
2825
3133
  h++, d++;
2826
- const u = (c.length - d) * o + 1 >>> 0, p = new Uint8Array(u);
3134
+ const u = (c.length - d) * s + 1 >>> 0, g = new Uint8Array(u);
2827
3135
  for (; d < c.length; ) {
2828
3136
  const x = c.charCodeAt(d);
2829
3137
  if (x > 255)
@@ -2831,20 +3139,20 @@ function Dn(t) {
2831
3139
  let m = e[x];
2832
3140
  if (m === 255)
2833
3141
  return;
2834
- let E = 0;
2835
- for (let w = u - 1; (m !== 0 || E < f) && w !== -1; w--, E++)
2836
- m += r * p[w] >>> 0, p[w] = m % 256 >>> 0, m = m / 256 >>> 0;
3142
+ let _ = 0;
3143
+ for (let w = u - 1; (m !== 0 || _ < f) && w !== -1; w--, _++)
3144
+ m += r * g[w] >>> 0, g[w] = m % 256 >>> 0, m = m / 256 >>> 0;
2837
3145
  if (m !== 0)
2838
3146
  throw new Error("Non-zero carry");
2839
- f = E, d++;
3147
+ f = _, d++;
2840
3148
  }
2841
3149
  let C = u - f;
2842
- for (; C !== u && p[C] === 0; )
3150
+ for (; C !== u && g[C] === 0; )
2843
3151
  C++;
2844
3152
  const y = new Uint8Array(h + (u - C));
2845
- let S = h;
3153
+ let P = h;
2846
3154
  for (; C !== u; )
2847
- y[S++] = p[C++];
3155
+ y[P++] = g[C++];
2848
3156
  return y;
2849
3157
  }
2850
3158
  function l(c) {
@@ -2859,9 +3167,9 @@ function Dn(t) {
2859
3167
  decode: l
2860
3168
  };
2861
3169
  }
2862
- var Fn = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
2863
- Dn(Fn);
2864
- class De {
3170
+ var zs = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
3171
+ Ms(zs);
3172
+ class dt {
2865
3173
  _transaction;
2866
3174
  signatures = [];
2867
3175
  feePayer;
@@ -2874,15 +3182,15 @@ class De {
2874
3182
  return this._instructions.push(...e), this;
2875
3183
  }
2876
3184
  static from(e) {
2877
- const r = e instanceof Uint8Array ? e : new Uint8Array(e), n = Se.decode(r), o = new De();
2878
- return o._transaction = n, o;
3185
+ const r = e instanceof Uint8Array ? e : new Uint8Array(e), n = Ke.decode(r), s = new dt();
3186
+ return s._transaction = n, s;
2879
3187
  }
2880
3188
  serialize(e) {
2881
3189
  if (this._transaction)
2882
- return Buffer.from(Se.encode(this._transaction));
3190
+ return Buffer.from(Ke.encode(this._transaction));
2883
3191
  if (!this.feePayer || !this.recentBlockhash)
2884
3192
  throw new Error("Transaction requires feePayer and recentBlockhash");
2885
- const r = at(
3193
+ const r = Pt(
2886
3194
  this.feePayer.toString(),
2887
3195
  this._instructions,
2888
3196
  this.recentBlockhash
@@ -2892,7 +3200,7 @@ class De {
2892
3200
  serializeMessage() {
2893
3201
  if (!this.feePayer || !this.recentBlockhash)
2894
3202
  throw new Error("Transaction requires feePayer and recentBlockhash");
2895
- const e = at(
3203
+ const e = Pt(
2896
3204
  this.feePayer.toString(),
2897
3205
  this._instructions,
2898
3206
  this.recentBlockhash
@@ -2900,7 +3208,7 @@ class De {
2900
3208
  return Buffer.from(e, "hex");
2901
3209
  }
2902
3210
  }
2903
- class Qn {
3211
+ class Os {
2904
3212
  type = "phantom";
2905
3213
  platform = "solana";
2906
3214
  account = void 0;
@@ -2968,11 +3276,11 @@ class Qn {
2968
3276
  if (!this.isAvailable() || !this.account)
2969
3277
  throw new Error("Phantom is not connected");
2970
3278
  try {
2971
- const r = De.from(e), o = await this.getProvider().signAndSendTransaction(r);
3279
+ const r = dt.from(e), s = await this.getProvider().signAndSendTransaction(r);
2972
3280
  return {
2973
3281
  success: !0,
2974
3282
  wallet: this.type,
2975
- result: o
3283
+ result: s
2976
3284
  };
2977
3285
  } catch (r) {
2978
3286
  return console.error("Error sending transaction with Phantom:", r), {
@@ -3010,17 +3318,17 @@ class Qn {
3010
3318
  };
3011
3319
  }
3012
3320
  }
3013
- class Hn extends he {
3321
+ class Ds extends Ee {
3014
3322
  type = "phantom-evm";
3015
3323
  rdns = "app.phantom";
3016
3324
  displayName = "Phantom";
3017
3325
  }
3018
- class jn extends he {
3326
+ class Fs extends Ee {
3019
3327
  type = "rabby";
3020
3328
  rdns = "io.rabby";
3021
3329
  displayName = "Rabby";
3022
3330
  }
3023
- class Yn {
3331
+ class Qs {
3024
3332
  type = "braavos";
3025
3333
  platform = "starknet";
3026
3334
  wallet = void 0;
@@ -3154,24 +3462,24 @@ class Yn {
3154
3462
  this.removeAccountChangeListener(), this.wallet = void 0, this.account = void 0, this.connectedAccounts = [];
3155
3463
  }
3156
3464
  }
3157
- class Wn {
3465
+ class js {
3158
3466
  walletAdapters;
3159
3467
  constructor() {
3160
3468
  if (this.walletAdapters = /* @__PURE__ */ new Map(), typeof window > "u")
3161
3469
  return;
3162
- const e = new sn();
3470
+ const e = new ns();
3163
3471
  this.walletAdapters.set("metamask", e);
3164
- const r = new Qn();
3472
+ const r = new Os();
3165
3473
  this.walletAdapters.set("phantom", r);
3166
- const n = new Hn();
3474
+ const n = new Ds();
3167
3475
  this.walletAdapters.set("phantom-evm", n);
3168
- const o = new en();
3169
- this.walletAdapters.set("argent", o);
3170
- const s = new Yn();
3171
- this.walletAdapters.set("braavos", s);
3172
- const a = new jn();
3476
+ const s = new Xn();
3477
+ this.walletAdapters.set("argent", s);
3478
+ const o = new Qs();
3479
+ this.walletAdapters.set("braavos", o);
3480
+ const a = new Fs();
3173
3481
  this.walletAdapters.set("rabby", a);
3174
- const i = new on();
3482
+ const i = new rs();
3175
3483
  this.walletAdapters.set("base", i), window.wallet_bridge = this;
3176
3484
  }
3177
3485
  getIFrameMethods() {
@@ -3183,7 +3491,7 @@ class Wn {
3183
3491
  externalSendTransaction: (e) => (r, n) => this.sendTransaction(r, n),
3184
3492
  externalGetBalance: (e) => (r, n) => this.getBalance(r, n),
3185
3493
  externalSwitchChain: (e) => (r, n) => this.switchChain(r, n),
3186
- externalWaitForTransaction: (e) => (r, n, o) => this.waitForTransaction(r, n, o)
3494
+ externalWaitForTransaction: (e) => (r, n, s) => this.waitForTransaction(r, n, s)
3187
3495
  };
3188
3496
  }
3189
3497
  async detectWallets() {
@@ -3197,18 +3505,18 @@ class Wn {
3197
3505
  throw new Error(`Unsupported wallet type: ${e}`);
3198
3506
  return r;
3199
3507
  }
3200
- handleError(e, r, n, o) {
3201
- const s = r instanceof Error ? r.message : "Unknown error";
3508
+ handleError(e, r, n, s) {
3509
+ const o = r instanceof Error ? r.message : "Unknown error";
3202
3510
  let a = "unknown";
3203
3511
  if (typeof e == "string") {
3204
3512
  const i = this.getConnectedWalletAdapter(e);
3205
- a = o ?? i?.type ?? e;
3513
+ a = s ?? i?.type ?? e;
3206
3514
  } else
3207
3515
  a = e;
3208
3516
  return console.error(`Error ${n} with ${e} wallet:`, r), {
3209
3517
  success: !1,
3210
3518
  wallet: a,
3211
- error: s
3519
+ error: o
3212
3520
  };
3213
3521
  }
3214
3522
  async connectWallet(e) {
@@ -3234,13 +3542,13 @@ class Wn {
3234
3542
  getConnectedWalletAdapter(e) {
3235
3543
  let r, n;
3236
3544
  try {
3237
- n = B(e);
3545
+ n = M(e);
3238
3546
  } catch {
3239
3547
  if (r = this.walletAdapters.get(e), !r)
3240
3548
  throw new Error(`Wallet ${e} is not connected or supported`);
3241
3549
  return r;
3242
3550
  }
3243
- if (r = this.walletAdapters.values().find((o) => o.getConnectedAccounts().includes(n)), !r)
3551
+ if (r = this.walletAdapters.values().find((s) => s.getConnectedAccounts().includes(n)), !r)
3244
3552
  throw new Error(`No wallet found with connected address ${e}`);
3245
3553
  return r;
3246
3554
  }
@@ -3252,10 +3560,10 @@ class Wn {
3252
3560
  `Wallet type ${n.type} (identifier: ${e}) does not support signing messages`
3253
3561
  );
3254
3562
  return await n.signMessage(r, e);
3255
- } catch (o) {
3563
+ } catch (s) {
3256
3564
  return this.handleError(
3257
3565
  e,
3258
- o,
3566
+ s,
3259
3567
  "signing message with",
3260
3568
  n?.type
3261
3569
  );
@@ -3269,10 +3577,10 @@ class Wn {
3269
3577
  `Wallet type ${n.type} (identifier: ${e}) does not support signing typed data`
3270
3578
  );
3271
3579
  return await n.signTypedData(r);
3272
- } catch (o) {
3580
+ } catch (s) {
3273
3581
  return this.handleError(
3274
3582
  e,
3275
- o,
3583
+ s,
3276
3584
  "signing typed data with",
3277
3585
  n?.type
3278
3586
  );
@@ -3282,10 +3590,10 @@ class Wn {
3282
3590
  let n;
3283
3591
  try {
3284
3592
  return n = this.getConnectedWalletAdapter(e), await n.sendTransaction(r);
3285
- } catch (o) {
3593
+ } catch (s) {
3286
3594
  return this.handleError(
3287
3595
  e,
3288
- o,
3596
+ s,
3289
3597
  "sending transaction with",
3290
3598
  n?.type
3291
3599
  );
@@ -3295,10 +3603,10 @@ class Wn {
3295
3603
  let n;
3296
3604
  try {
3297
3605
  return n = this.getConnectedWalletAdapter(e), await n.getBalance(r);
3298
- } catch (o) {
3606
+ } catch (s) {
3299
3607
  return this.handleError(
3300
3608
  e,
3301
- o,
3609
+ s,
3302
3610
  "getting balance from",
3303
3611
  n?.type
3304
3612
  );
@@ -3312,29 +3620,29 @@ class Wn {
3312
3620
  }
3313
3621
  }
3314
3622
  async waitForTransaction(e, r, n) {
3315
- let o;
3623
+ let s;
3316
3624
  try {
3317
- return o = this.getConnectedWalletAdapter(e), await o.waitForTransaction(r, n);
3318
- } catch (s) {
3625
+ return s = this.getConnectedWalletAdapter(e), await s.waitForTransaction(r, n);
3626
+ } catch (o) {
3319
3627
  return this.handleError(
3320
3628
  e,
3321
- s,
3629
+ o,
3322
3630
  "waiting for transaction with",
3323
- o?.type
3631
+ s?.type
3324
3632
  );
3325
3633
  }
3326
3634
  }
3327
3635
  }
3328
- const Vn = 200;
3329
- class qn extends yr {
3636
+ const Hs = 200;
3637
+ class Ws extends Fn {
3330
3638
  walletBridge;
3331
3639
  onStarterpackPlay;
3332
3640
  constructor({
3333
3641
  url: e,
3334
3642
  policies: r,
3335
3643
  version: n,
3336
- slot: o,
3337
- namespace: s,
3644
+ slot: s,
3645
+ namespace: o,
3338
3646
  tokens: a,
3339
3647
  preset: i,
3340
3648
  shouldOverridePresetPolicies: l,
@@ -3343,16 +3651,16 @@ class qn extends yr {
3343
3651
  refGroup: h,
3344
3652
  needsSessionCreation: f,
3345
3653
  username: u,
3346
- onSessionCreated: p,
3654
+ onSessionCreated: g,
3347
3655
  onStarterpackPlay: C,
3348
3656
  encryptedBlob: y,
3349
- propagateSessionErrors: S,
3657
+ propagateSessionErrors: P,
3350
3658
  errorDisplayMode: x,
3351
3659
  ...m
3352
3660
  }) {
3353
- let E;
3354
- const w = new URL(e ?? dt), H = new Wn();
3355
- S && w.searchParams.set("propagate_error", "true"), x && w.searchParams.set("error_display_mode", x), n && w.searchParams.set("v", encodeURIComponent(n)), o && w.searchParams.set("ps", encodeURIComponent(o)), s && w.searchParams.set("ns", encodeURIComponent(s)), a?.erc20 && w.searchParams.set(
3661
+ let _;
3662
+ const w = new URL(e ?? Rt), K = new js();
3663
+ P && w.searchParams.set("propagate_error", "true"), x && w.searchParams.set("error_display_mode", x), n && w.searchParams.set("v", encodeURIComponent(n)), s && w.searchParams.set("ps", encodeURIComponent(s)), o && w.searchParams.set("ns", encodeURIComponent(o)), a?.erc20 && w.searchParams.set(
3356
3664
  "erc20",
3357
3665
  encodeURIComponent(a.erc20.toString())
3358
3666
  ), c && w.searchParams.set("rpc_url", encodeURIComponent(c)), d && w.searchParams.set("ref", encodeURIComponent(d)), h && w.searchParams.set("ref_group", encodeURIComponent(h)), f && w.searchParams.set("needs_session_creation", "true"), u && w.searchParams.set("username", encodeURIComponent(u)), (!i || l) && r ? w.searchParams.set(
@@ -3363,26 +3671,24 @@ class qn extends yr {
3363
3671
  id: "controller-keychain",
3364
3672
  url: w,
3365
3673
  methods: {
3366
- ...H.getIFrameMethods(),
3674
+ ...K.getIFrameMethods(),
3367
3675
  // Expose callback for keychain to notify parent that session was created and storage access granted
3368
- onSessionCreated: (T) => () => {
3369
- p && p();
3370
- },
3371
- onStarterpackPlay: (T) => async () => {
3372
- E && await E();
3676
+ onSessionCreated: (D) => () => g?.(),
3677
+ onStarterpackPlay: (D) => async () => {
3678
+ _ && await _();
3373
3679
  }
3374
3680
  }
3375
- }), this.walletBridge = H, this.onStarterpackPlay = C, E = async () => {
3681
+ }), this.walletBridge = K, this.onStarterpackPlay = C, _ = async () => {
3376
3682
  this.close();
3377
- const T = this.onStarterpackPlay;
3378
- if (this.onStarterpackPlay = void 0, !!T) {
3683
+ const D = this.onStarterpackPlay;
3684
+ if (this.onStarterpackPlay = void 0, !!D) {
3379
3685
  await new Promise(
3380
- (pe) => setTimeout(pe, Vn)
3686
+ (Se) => setTimeout(Se, Hs)
3381
3687
  );
3382
3688
  try {
3383
- T();
3384
- } catch (pe) {
3385
- console.error("Failed to run starterpack play callback:", pe);
3689
+ D();
3690
+ } catch (Se) {
3691
+ console.error("Failed to run starterpack play callback:", Se);
3386
3692
  }
3387
3693
  }
3388
3694
  }, typeof window < "u" && (window.external_wallets = this.walletBridge);
@@ -3394,7 +3700,7 @@ class qn extends yr {
3394
3700
  this.onStarterpackPlay = e;
3395
3701
  }
3396
3702
  }
3397
- function Zn(t) {
3703
+ function Ys(t) {
3398
3704
  if (!t || t.trim() === "")
3399
3705
  return { isValid: !1, error: "Redirect URL is empty" };
3400
3706
  let e;
@@ -3417,8 +3723,8 @@ function Zn(t) {
3417
3723
  error: "URL must have a valid hostname"
3418
3724
  };
3419
3725
  if (typeof window < "u") {
3420
- const n = window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1", o = e.hostname === "localhost" || e.hostname === "127.0.0.1";
3421
- if (!n && o)
3726
+ const n = window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1", s = e.hostname === "localhost" || e.hostname === "127.0.0.1";
3727
+ if (!n && s)
3422
3728
  return {
3423
3729
  isValid: !1,
3424
3730
  error: "Cannot redirect to localhost from production"
@@ -3426,7 +3732,7 @@ function Zn(t) {
3426
3732
  }
3427
3733
  return { isValid: !0 };
3428
3734
  }
3429
- class Io extends Wt {
3735
+ class Eo extends Sr {
3430
3736
  keychain;
3431
3737
  options;
3432
3738
  iframes;
@@ -3442,30 +3748,30 @@ class Io extends Wt {
3442
3748
  const n = [...[
3443
3749
  { rpcUrl: "https://api.cartridge.gg/x/starknet/sepolia/rpc/v0_9" },
3444
3750
  { rpcUrl: "https://api.cartridge.gg/x/starknet/mainnet/rpc/v0_9" }
3445
- ], ...e.chains || []], o = e.defaultChainId || ve.StarknetChainId.SN_MAIN;
3446
- this.selectedChain = o, this.chains = /* @__PURE__ */ new Map();
3447
- const s = typeof window < "u" ? new URLSearchParams(window.location.search) : null;
3751
+ ], ...e.chains || []], s = e.defaultChainId || Ue.StarknetChainId.SN_MAIN;
3752
+ this.selectedChain = s, this.chains = /* @__PURE__ */ new Map();
3753
+ const o = typeof window < "u" ? new URLSearchParams(window.location.search) : null;
3448
3754
  if (this.referral = {
3449
- ref: s?.get("ref") ?? void 0,
3450
- refGroup: s?.get("ref_group") ?? void 0
3451
- }, this.options = { ...e, chains: n, defaultChainId: o }, typeof window < "u" && typeof localStorage < "u") {
3452
- const a = s?.get("controller_standalone");
3755
+ ref: o?.get("ref") ?? void 0,
3756
+ refGroup: o?.get("ref_group") ?? void 0
3757
+ }, this.options = { ...e, chains: n, defaultChainId: s }, typeof window < "u" && typeof localStorage < "u") {
3758
+ const a = o?.get("controller_standalone");
3453
3759
  a === "1" && sessionStorage.setItem("controller_standalone", "1");
3454
- const i = s?.get("lastUsedConnector");
3760
+ const i = o?.get("lastUsedConnector");
3455
3761
  if (i && localStorage.setItem("lastUsedConnector", i), window.location.hash) {
3456
3762
  const c = new URLSearchParams(window.location.hash.slice(1)).get("kc");
3457
3763
  c && (this.encryptedBlob = c);
3458
3764
  }
3459
- if (s && window.history?.replaceState) {
3765
+ if (o && window.history?.replaceState) {
3460
3766
  let l = !1;
3461
- a && (s.delete("controller_standalone"), l = !0), i && (s.delete("lastUsedConnector"), l = !0);
3767
+ a && (o.delete("controller_standalone"), l = !0), i && (o.delete("lastUsedConnector"), l = !0);
3462
3768
  let c = window.location.hash;
3463
3769
  if (c) {
3464
3770
  const d = new URLSearchParams(c.slice(1));
3465
3771
  d.has("kc") && (d.delete("kc"), c = d.toString() ? `#${d.toString()}` : "", l = !0);
3466
3772
  }
3467
3773
  if (l) {
3468
- const d = window.location.pathname + (s.toString() ? "?" + s.toString() : "") + c;
3774
+ const d = window.location.pathname + (o.toString() ? "?" + o.toString() : "") + c;
3469
3775
  window.history.replaceState({}, "", d);
3470
3776
  }
3471
3777
  }
@@ -3476,7 +3782,7 @@ class Io extends Wt {
3476
3782
  }
3477
3783
  async logout() {
3478
3784
  if (!this.keychain) {
3479
- console.error(new A().message);
3785
+ console.error(new I().message);
3480
3786
  return;
3481
3787
  }
3482
3788
  try {
@@ -3494,12 +3800,12 @@ class Io extends Wt {
3494
3800
  if (this.iframes) {
3495
3801
  try {
3496
3802
  if (this.iframes.keychain || (this.iframes.keychain = this.createKeychainIframe()), await this.waitForKeychain(), !this.keychain) {
3497
- console.error(new A().message);
3803
+ console.error(new I().message);
3498
3804
  return;
3499
3805
  }
3500
3806
  const e = await this.keychain.probe(this.rpcUrl());
3501
3807
  let r = e?.rpcUrl || this.rpcUrl();
3502
- this.account = new je(
3808
+ this.account = new Ie(
3503
3809
  this,
3504
3810
  r,
3505
3811
  e.address,
@@ -3515,31 +3821,70 @@ class Io extends Wt {
3515
3821
  }
3516
3822
  }
3517
3823
  async connect(e) {
3824
+ const r = Array.isArray(e) ? void 0 : e, n = r?.username && r?.signer ? {
3825
+ username: r.username,
3826
+ signer: r.signer,
3827
+ password: r.password
3828
+ } : void 0;
3518
3829
  if (this.iframes) {
3519
3830
  if (this.account)
3520
3831
  return this.account;
3521
- if (this.iframes.keychain || (this.iframes.keychain = this.createKeychainIframe(), await this.waitForKeychain()), !this.keychain || !this.iframes.keychain) {
3522
- console.error(new A().message);
3832
+ if (this.iframes.keychain || (this.iframes.keychain = this.createKeychainIframe()), await this.waitForKeychain(), !this.keychain || !this.iframes.keychain) {
3833
+ console.error(new I().message);
3523
3834
  return;
3524
3835
  }
3525
- this.iframes.keychain.open();
3526
3836
  try {
3527
- const r = e ?? this.options.signupOptions;
3528
- let n = await this.keychain.connect(r);
3529
- if (n.code !== R.SUCCESS)
3530
- throw new Error(n.message);
3531
- return n = n, this.account = new je(
3837
+ if (n) {
3838
+ const a = await this.keychain.connect({
3839
+ username: n.username,
3840
+ signer: n.signer,
3841
+ password: n.password
3842
+ });
3843
+ if (a.code !== z.SUCCESS)
3844
+ throw new he(
3845
+ "message" in a && a.message ? a.message : "Headless authentication failed"
3846
+ );
3847
+ if (this.account)
3848
+ return this.account;
3849
+ const i = "address" in a && a.address ? a.address : null;
3850
+ if (!i)
3851
+ throw new he(
3852
+ "Headless authentication failed"
3853
+ );
3854
+ return this.account = new Ie(
3855
+ this,
3856
+ this.rpcUrl(),
3857
+ i,
3858
+ this.keychain,
3859
+ this.options,
3860
+ this.iframes.keychain
3861
+ ), this.emitAccountsChanged([i]), this.account;
3862
+ }
3863
+ this.iframes.keychain.open();
3864
+ const s = Array.isArray(e) ? e : r?.signupOptions ?? this.options.signupOptions;
3865
+ let o = await this.keychain.connect({
3866
+ signupOptions: s
3867
+ });
3868
+ if (o.code !== z.SUCCESS)
3869
+ throw new Error(o.message);
3870
+ return o = o, this.account = new Ie(
3532
3871
  this,
3533
3872
  this.rpcUrl(),
3534
- n.address,
3873
+ o.address,
3535
3874
  this.keychain,
3536
3875
  this.options,
3537
3876
  this.iframes.keychain
3538
3877
  ), this.account;
3539
- } catch (r) {
3540
- console.log(r);
3878
+ } catch (s) {
3879
+ if (n) {
3880
+ if (s instanceof he)
3881
+ throw s;
3882
+ const o = s instanceof Error ? s.message : typeof s == "object" && s && "message" in s ? String(s.message) : "Headless authentication failed";
3883
+ throw new he(o);
3884
+ }
3885
+ console.log(s);
3541
3886
  } finally {
3542
- this.iframes.keychain.close();
3887
+ n || this.iframes.keychain.close();
3543
3888
  }
3544
3889
  }
3545
3890
  }
@@ -3547,7 +3892,7 @@ class Io extends Wt {
3547
3892
  if (!this.iframes)
3548
3893
  return !1;
3549
3894
  if (!this.keychain || !this.iframes.keychain)
3550
- return console.error(new A().message), !1;
3895
+ return console.error(new I().message), !1;
3551
3896
  const r = this.selectedChain;
3552
3897
  try {
3553
3898
  this.selectedChain = e, await this.keychain.switchChain(this.rpcUrl());
@@ -3560,17 +3905,22 @@ class Io extends Wt {
3560
3905
  return Promise.resolve(!0);
3561
3906
  }
3562
3907
  async disconnect() {
3908
+ this.account = void 0, this.emitAccountsChanged([]);
3909
+ try {
3910
+ typeof localStorage < "u" && localStorage.removeItem("lastUsedConnector");
3911
+ } catch {
3912
+ }
3563
3913
  if (!this.keychain) {
3564
- console.error(new A().message);
3914
+ console.error(new I().message);
3565
3915
  return;
3566
3916
  }
3567
- return this.account = void 0, this.keychain.disconnect();
3917
+ return this.keychain.disconnect();
3568
3918
  }
3569
3919
  async openProfile(e = "inventory") {
3570
3920
  if (!this.iframes)
3571
3921
  return;
3572
3922
  if (!this.keychain || !this.iframes.keychain) {
3573
- console.error(new A().message);
3923
+ console.error(new I().message);
3574
3924
  return;
3575
3925
  }
3576
3926
  if (!this.account) {
@@ -3586,7 +3936,7 @@ class Io extends Wt {
3586
3936
  if (!this.iframes)
3587
3937
  return;
3588
3938
  if (!this.keychain || !this.iframes.keychain) {
3589
- console.error(new A().message);
3939
+ console.error(new I().message);
3590
3940
  return;
3591
3941
  }
3592
3942
  if (!this.account) {
@@ -3601,7 +3951,7 @@ class Io extends Wt {
3601
3951
  async openProfileAt(e) {
3602
3952
  if (this.iframes) {
3603
3953
  if (!this.keychain || !this.iframes.keychain) {
3604
- console.error(new A().message);
3954
+ console.error(new I().message);
3605
3955
  return;
3606
3956
  }
3607
3957
  if (!this.account) {
@@ -3614,30 +3964,33 @@ class Io extends Wt {
3614
3964
  openSettings() {
3615
3965
  if (this.iframes) {
3616
3966
  if (!this.keychain || !this.iframes.keychain) {
3617
- console.error(new A().message);
3967
+ console.error(new I().message);
3618
3968
  return;
3619
3969
  }
3620
3970
  this.iframes.keychain.open(), this.keychain.openSettings();
3621
3971
  }
3622
3972
  }
3973
+ async close() {
3974
+ !this.iframes || !this.iframes.keychain || this.iframes.keychain.close();
3975
+ }
3623
3976
  revoke(e, r) {
3624
- return this.keychain ? this.keychain.revoke(e) : (console.error(new A().message), null);
3977
+ return this.keychain ? this.keychain.revoke(e) : (console.error(new I().message), null);
3625
3978
  }
3626
3979
  rpcUrl() {
3627
3980
  const e = this.chains.get(this.selectedChain);
3628
3981
  if (!e) {
3629
3982
  const r = Array.from(this.chains.keys()).map(
3630
- (n) => He.decodeShortString(n)
3983
+ (n) => ut.decodeShortString(n)
3631
3984
  );
3632
3985
  throw new Error(
3633
- `Chain not found: ${He.decodeShortString(this.selectedChain)}. Available chains: ${r.join(", ")}`
3986
+ `Chain not found: ${ut.decodeShortString(this.selectedChain)}. Available chains: ${r.join(", ")}`
3634
3987
  );
3635
3988
  }
3636
3989
  return e.rpcUrl;
3637
3990
  }
3638
3991
  username() {
3639
3992
  if (!this.keychain) {
3640
- console.error(new A().message);
3993
+ console.error(new I().message);
3641
3994
  return;
3642
3995
  }
3643
3996
  return this.keychain.username();
@@ -3645,7 +3998,7 @@ class Io extends Wt {
3645
3998
  openPurchaseCredits() {
3646
3999
  if (this.iframes) {
3647
4000
  if (!this.keychain || !this.iframes.keychain) {
3648
- console.error(new A().message);
4001
+ console.error(new I().message);
3649
4002
  return;
3650
4003
  }
3651
4004
  this.keychain.navigate("/purchase/credits").then(() => {
@@ -3657,31 +4010,68 @@ class Io extends Wt {
3657
4010
  if (!this.iframes)
3658
4011
  return;
3659
4012
  if (!this.keychain || !this.iframes.keychain) {
3660
- console.error(new A().message);
4013
+ console.error(new I().message);
3661
4014
  return;
3662
4015
  }
3663
- const { onPurchaseComplete: n, ...o } = r ?? {};
4016
+ const { onPurchaseComplete: n, ...s } = r ?? {};
3664
4017
  this.iframes.keychain.setOnStarterpackPlay(n);
3665
- const s = Object.keys(o).length > 0 ? o : void 0;
3666
- await this.keychain.openStarterPack(e, s), this.iframes.keychain?.open();
4018
+ const o = Object.keys(s).length > 0 ? s : void 0;
4019
+ await this.keychain.openStarterPack(e, o), this.iframes.keychain?.open();
3667
4020
  }
3668
4021
  async openExecute(e, r) {
3669
4022
  if (!this.iframes)
3670
4023
  return;
3671
4024
  if (!this.keychain || !this.iframes.keychain) {
3672
- console.error(new A().message);
4025
+ console.error(new I().message);
3673
4026
  return;
3674
4027
  }
3675
4028
  let n = this.selectedChain;
3676
4029
  r && this.switchStarknetChain(r), this.iframes.keychain.open();
3677
- const o = await this.keychain.execute(e, void 0, void 0, !0);
4030
+ const s = await this.keychain.execute(e, void 0, void 0, !0);
3678
4031
  return this.iframes.keychain.close(), r && this.switchStarknetChain(n), {
3679
- status: !(o && (o.code === R.NOT_CONNECTED || o.code === R.CANCELED)),
3680
- transactionHash: o?.transaction_hash
4032
+ status: !(s && (s.code === z.NOT_CONNECTED || s.code === z.CANCELED)),
4033
+ transactionHash: s?.transaction_hash
3681
4034
  };
3682
4035
  }
3683
4036
  async delegateAccount() {
3684
- return this.keychain ? await this.keychain.delegateAccount() : (console.error(new A().message), null);
4037
+ return this.keychain ? await this.keychain.delegateAccount() : (console.error(new I().message), null);
4038
+ }
4039
+ /**
4040
+ * Returns a wallet standard interface for the controller.
4041
+ * This allows using the controller with libraries that expect the wallet standard interface.
4042
+ */
4043
+ asWalletStandard() {
4044
+ typeof window < "u" && console.warn(
4045
+ "Casting Controller to WalletWithStarknetFeatures is an experimental feature. Please report any issues at https://github.com/cartridge-gg/controller/issues"
4046
+ );
4047
+ const e = this, r = new gn(e), n = {
4048
+ "standard:disconnect": {
4049
+ version: "1.0.0",
4050
+ disconnect: async () => {
4051
+ await r.features["standard:disconnect"].disconnect(), await e.disconnect();
4052
+ }
4053
+ }
4054
+ };
4055
+ return {
4056
+ get version() {
4057
+ return r.version;
4058
+ },
4059
+ get name() {
4060
+ return r.name;
4061
+ },
4062
+ get icon() {
4063
+ return r.icon;
4064
+ },
4065
+ get chains() {
4066
+ return r.chains;
4067
+ },
4068
+ get accounts() {
4069
+ return r.accounts;
4070
+ },
4071
+ get features() {
4072
+ return { ...r.features, ...n };
4073
+ }
4074
+ };
3685
4075
  }
3686
4076
  /**
3687
4077
  * Opens the keychain in standalone mode (first-party context) for authentication.
@@ -3693,10 +4083,10 @@ class Io extends Wt {
3693
4083
  console.error("open can only be called in browser context");
3694
4084
  return;
3695
4085
  }
3696
- const r = new URL(this.options.url || dt), n = e.redirectUrl || window.location.href, o = Zn(n);
3697
- if (!o.isValid) {
4086
+ const r = new URL(this.options.url || Rt), n = e.redirectUrl || window.location.href, s = Ys(n);
4087
+ if (!s.isValid) {
3698
4088
  console.error(
3699
- `Invalid redirect URL: ${o.error}`,
4089
+ `Invalid redirect URL: ${s.error}`,
3700
4090
  `URL: ${n}`
3701
4091
  );
3702
4092
  return;
@@ -3709,8 +4099,8 @@ class Io extends Wt {
3709
4099
  initializeChains(e) {
3710
4100
  for (const r of e)
3711
4101
  try {
3712
- const n = new URL(r.rpcUrl), o = Vt(n);
3713
- this.chains.set(o, r);
4102
+ const n = new URL(r.rpcUrl), s = Ir(n);
4103
+ this.chains.set(s, r);
3714
4104
  } catch (n) {
3715
4105
  throw console.error(`Failed to parse chainId for ${r.rpcUrl}:`, n), n;
3716
4106
  }
@@ -3719,37 +4109,40 @@ class Io extends Wt {
3719
4109
  );
3720
4110
  }
3721
4111
  createKeychainIframe() {
3722
- 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, o = this.encryptedBlob;
3723
- e && sessionStorage.removeItem("controller_standalone"), o && (this.encryptedBlob = void 0);
3724
- const s = new qn({
4112
+ 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;
4113
+ e && sessionStorage.removeItem("controller_standalone"), s && (this.encryptedBlob = void 0);
4114
+ const o = new Ws({
3725
4115
  ...this.options,
3726
4116
  rpcUrl: this.rpcUrl(),
3727
- onClose: this.keychain?.reset,
4117
+ onClose: () => {
4118
+ this.keychain?.reset?.();
4119
+ },
3728
4120
  onConnect: (a) => {
3729
4121
  this.keychain = a;
3730
4122
  },
3731
- version: qt,
4123
+ version: $r,
3732
4124
  ref: this.referral.ref,
3733
4125
  refGroup: this.referral.refGroup,
3734
4126
  needsSessionCreation: e,
3735
- encryptedBlob: o ?? void 0,
4127
+ encryptedBlob: s ?? void 0,
3736
4128
  username: n,
3737
4129
  onSessionCreated: async () => {
3738
- await this.probe();
4130
+ const a = this.account?.address, i = await this.probe();
4131
+ i?.address && i.address !== a && this.emitAccountsChanged([i.address]);
3739
4132
  }
3740
4133
  });
3741
4134
  return e && setTimeout(() => {
3742
- s.open();
3743
- }, 100), s;
4135
+ o.open();
4136
+ }, 100), o;
3744
4137
  }
3745
4138
  waitForKeychain({
3746
4139
  timeout: e = 5e4,
3747
4140
  interval: r = 100
3748
4141
  } = {}) {
3749
- return new Promise((n, o) => {
3750
- const s = Date.now(), a = setInterval(() => {
3751
- if (Date.now() - s > e) {
3752
- clearInterval(a), o(new Error("Timeout waiting for keychain"));
4142
+ return new Promise((n, s) => {
4143
+ const o = Date.now(), a = setInterval(() => {
4144
+ if (Date.now() - o > e) {
4145
+ clearInterval(a), s(new Error("Timeout waiting for keychain"));
3753
4146
  return;
3754
4147
  }
3755
4148
  this.keychain && (clearInterval(a), n());
@@ -3757,11 +4150,11 @@ class Io extends Wt {
3757
4150
  });
3758
4151
  }
3759
4152
  }
3760
- const Y = /* @__PURE__ */ new Map();
3761
- async function Ot(t) {
4153
+ const G = /* @__PURE__ */ new Map();
4154
+ async function Cr(t) {
3762
4155
  if (!t.addresses?.length && !t.usernames?.length)
3763
4156
  return { results: [] };
3764
- const e = await fetch(`${Zt}/lookup`, {
4157
+ const e = await fetch(`${Lr}/lookup`, {
3765
4158
  method: "POST",
3766
4159
  headers: {
3767
4160
  "Content-Type": "application/json"
@@ -3772,37 +4165,58 @@ async function Ot(t) {
3772
4165
  throw new Error(`HTTP error! status: ${e.status}`);
3773
4166
  return e.json();
3774
4167
  }
3775
- async function So(t) {
3776
- const e = t.filter((r) => !Y.has(r));
3777
- return e.length > 0 && (await Ot({ usernames: e })).results.forEach((n) => {
3778
- Y.set(n.username, n.addresses[0]);
4168
+ async function _o(t) {
4169
+ const e = t.filter((r) => !G.has(r));
4170
+ return e.length > 0 && (await Cr({ usernames: e })).results.forEach((n) => {
4171
+ G.set(n.username, n.addresses[0]);
3779
4172
  }), new Map(
3780
- t.map((r) => [r, Y.get(r)]).filter((r) => r[1] !== void 0)
4173
+ t.map((r) => [r, G.get(r)]).filter((r) => r[1] !== void 0)
3781
4174
  );
3782
4175
  }
3783
- async function $o(t) {
3784
- t = t.map(lt.toHex);
3785
- const e = t.filter((r) => !Y.has(r));
3786
- return e.length > 0 && (await Ot({
4176
+ async function Ao(t) {
4177
+ t = t.map(Tt.toHex);
4178
+ const e = t.filter((r) => !G.has(r));
4179
+ return e.length > 0 && (await Cr({
3787
4180
  addresses: e
3788
4181
  })).results.forEach((n) => {
3789
- Y.set(n.addresses[0], n.username);
4182
+ G.set(n.addresses[0], n.username);
3790
4183
  }), new Map(
3791
- t.map((r) => [r, Y.get(r)]).filter((r) => r[1] !== void 0)
4184
+ t.map((r) => [r, G.get(r)]).filter((r) => r[1] !== void 0)
3792
4185
  );
3793
4186
  }
3794
- const v = "cartridge-toast-container", Kn = 3e3, Gn = "bottom-right", Dt = "cartridge-toast-show";
3795
- function Fe() {
4187
+ function So(t) {
4188
+ return {
4189
+ verified: !1,
4190
+ contracts: t.contracts ? Object.fromEntries(
4191
+ Object.entries(t.contracts).map(([e, r]) => [
4192
+ e,
4193
+ {
4194
+ ...r,
4195
+ methods: r.methods.map((n) => ({
4196
+ ...n,
4197
+ authorized: !0
4198
+ }))
4199
+ }
4200
+ ])
4201
+ ) : void 0,
4202
+ messages: t.messages?.map((e) => ({
4203
+ ...e,
4204
+ authorized: !0
4205
+ }))
4206
+ };
4207
+ }
4208
+ const v = "cartridge-toast-container", Vs = 3e3, qs = "bottom-right", xr = "cartridge-toast-show";
4209
+ function ht() {
3796
4210
  try {
3797
4211
  return typeof window < "u" && window.self !== window.top;
3798
4212
  } catch {
3799
4213
  return !0;
3800
4214
  }
3801
4215
  }
3802
- function Xn() {
4216
+ function Ks() {
3803
4217
  if (typeof document > "u")
3804
4218
  return null;
3805
- if (Fe())
4219
+ if (ht())
3806
4220
  try {
3807
4221
  if (window.parent && window.parent.document)
3808
4222
  return window.parent.document;
@@ -3811,22 +4225,22 @@ function Xn() {
3811
4225
  }
3812
4226
  return document;
3813
4227
  }
3814
- function Jn(t, e) {
4228
+ function Zs(t, e) {
3815
4229
  let r = t.getElementById(v);
3816
4230
  return r || (r = t.createElement("div"), r.id = v, t.body && t.body.appendChild(r)), r.className = e, r;
3817
4231
  }
3818
- function eo(t) {
4232
+ function Gs(t) {
3819
4233
  t.classList.add("closing"), setTimeout(() => {
3820
4234
  t.parentNode && t.parentNode.removeChild(t);
3821
4235
  }, 200);
3822
4236
  }
3823
- function to(t) {
4237
+ function Xs(t) {
3824
4238
  if (t.getElementById("cartridge-toast-styles"))
3825
4239
  return;
3826
4240
  const e = t.createElement("style");
3827
- e.id = "cartridge-toast-styles", e.textContent = ro(), t.head.appendChild(e);
4241
+ e.id = "cartridge-toast-styles", e.textContent = Js(), t.head.appendChild(e);
3828
4242
  }
3829
- function ro() {
4243
+ function Js() {
3830
4244
  return `
3831
4245
  #${v} {
3832
4246
  position: fixed;
@@ -3954,21 +4368,21 @@ function ro() {
3954
4368
  }
3955
4369
  `;
3956
4370
  }
3957
- const te = (t = !1) => {
4371
+ const de = (t = !1) => {
3958
4372
  const e = document.createElement("div");
3959
4373
  e.id = "close-button", e.style.display = "flex", e.style.alignItems = "center", e.style.justifyContent = "center";
3960
4374
  const r = document.createElement("button");
3961
4375
  r.className = t ? "cartridge-close-button translucent" : "cartridge-close-button";
3962
4376
  const n = document.createElementNS("http://www.w3.org/2000/svg", "svg");
3963
4377
  n.setAttribute("width", "20"), n.setAttribute("height", "20"), n.setAttribute("viewBox", "0 0 20 20"), n.setAttribute("fill", "none"), n.style.pointerEvents = "none";
3964
- const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
3965
- o.setAttribute(
4378
+ const s = document.createElementNS("http://www.w3.org/2000/svg", "path");
4379
+ s.setAttribute(
3966
4380
  "d",
3967
4381
  "M15.5465 14.343C15.8881 14.6837 15.8881 15.2364 15.5465 15.5772C15.2049 15.9179 14.6506 15.9178 14.309 15.5772L10.0006 11.2484L5.66162 15.5757C5.32001 15.9164 4.76575 15.9164 4.4241 15.5757C4.08245 15.235 4.08249 14.6822 4.4241 14.3415L8.76455 10.0157L4.4229 5.65573C4.08128 5.31504 4.08128 4.76227 4.4229 4.42155C4.76451 4.08082 5.31877 4.08086 5.66042 4.42155L10.0006 8.78299L14.3396 4.45573C14.6812 4.11504 15.2355 4.11504 15.5771 4.45573C15.9188 4.79642 15.9187 5.34918 15.5771 5.68991L11.2367 10.0157L15.5465 14.343Z"
3968
- ), o.setAttribute("class", "cartridge-close-icon"), n.appendChild(o), r.appendChild(n), r.style.display = "flex", r.style.alignItems = "center", r.style.justifyContent = "center", r.style.border = "none", r.style.background = "transparent", r.style.cursor = "pointer", r.style.borderRadius = "4px", r.style.padding = "10px", r.style.gap = "4px", r.style.transition = "background-color 0.2s ease";
3969
- const s = e.ownerDocument;
3970
- if (!s.getElementById("cartridge-close-button-style")) {
3971
- const a = s.createElement("style");
4382
+ ), s.setAttribute("class", "cartridge-close-icon"), n.appendChild(s), r.appendChild(n), r.style.display = "flex", r.style.alignItems = "center", r.style.justifyContent = "center", r.style.border = "none", r.style.background = "transparent", r.style.cursor = "pointer", r.style.borderRadius = "4px", r.style.padding = "10px", r.style.gap = "4px", r.style.transition = "background-color 0.2s ease";
4383
+ const o = e.ownerDocument;
4384
+ if (!o.getElementById("cartridge-close-button-style")) {
4385
+ const a = o.createElement("style");
3972
4386
  a.id = "cartridge-close-button-style", a.textContent = `
3973
4387
  .cartridge-close-button .cartridge-close-icon {
3974
4388
  fill: rgba(0, 0, 0, 0.48);
@@ -3998,11 +4412,11 @@ const te = (t = !1) => {
3998
4412
  .cartridge-close-button:active {
3999
4413
  transform: scale(0.95);
4000
4414
  }
4001
- `, s.head.appendChild(a);
4415
+ `, o.head.appendChild(a);
4002
4416
  }
4003
4417
  return e.appendChild(r), e;
4004
4418
  };
4005
- function no(t) {
4419
+ function eo(t) {
4006
4420
  if (t.getElementById("cartridge-toast-error-styles"))
4007
4421
  return;
4008
4422
  const e = t.createElement("style");
@@ -4076,27 +4490,27 @@ function no(t) {
4076
4490
  }
4077
4491
  `, t.head.appendChild(e);
4078
4492
  }
4079
- function oo(t) {
4493
+ function to(t) {
4080
4494
  const e = document.createElement("div");
4081
4495
  e.className = "cartridge-toast error";
4082
4496
  const r = document.createElement("div");
4083
4497
  r.className = "label-bar", e.appendChild(r);
4084
4498
  const n = document.createElement("div");
4085
4499
  n.className = "label-container", r.appendChild(n);
4086
- const o = document.createElement("div");
4087
- o.className = "icon-container", o.innerHTML = `
4500
+ const s = document.createElement("div");
4501
+ s.className = "icon-container", s.innerHTML = `
4088
4502
  <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none">
4089
4503
  <path fill-rule="evenodd" clip-rule="evenodd" d="M9.79313 0.326989L17.673 8.20771C18.109 8.6437 18.109 9.35713 17.673 9.79229L9.79229 17.673C9.3563 18.109 8.6437 18.109 8.20771 17.673L0.326989 9.79229C-0.108996 9.35713 -0.108996 8.6437 0.326989 8.20771L8.20856 0.326989C8.64454 -0.108996 9.35715 -0.108996 9.79313 0.326989ZM8.26159 4.84378C8.26159 4.37794 8.63953 4 9.10537 4C9.57121 4 9.94915 4.3797 9.94915 4.84378V9.34394C9.94915 9.80978 9.57121 10.1877 9.13701 10.1877C8.70282 10.1877 8.26159 9.81154 8.26159 9.34394V4.84378ZM9.10537 13.5628C8.49503 13.5628 8.00002 13.0678 8.00002 12.4575C8.00002 11.8472 8.49468 11.3521 9.10537 11.3521C9.71605 11.3521 10.2107 11.8472 10.2107 12.4575C10.2093 13.0671 9.71711 13.5628 9.10537 13.5628Z" fill="#0F1410"/>
4090
4504
  </svg>
4091
- `, n.appendChild(o);
4092
- const s = document.createElement("p");
4093
- s.className = "content", s.textContent = t.message || "Error", n.appendChild(s);
4505
+ `, n.appendChild(s);
4506
+ const o = document.createElement("p");
4507
+ o.className = "content", o.textContent = t.message || "Error", n.appendChild(o);
4094
4508
  const a = document.createElement("div");
4095
4509
  a.className = "close-button-container";
4096
- const i = te(!0);
4510
+ const i = de(!0);
4097
4511
  return a.appendChild(i), e.appendChild(a), e;
4098
4512
  }
4099
- function so(t) {
4513
+ function ro(t) {
4100
4514
  if (t.getElementById("cartridge-toast-transaction-styles"))
4101
4515
  return;
4102
4516
  const e = t.createElement("style");
@@ -4233,28 +4647,28 @@ function so(t) {
4233
4647
  }
4234
4648
  `, t.head.appendChild(e);
4235
4649
  }
4236
- function ao(t) {
4650
+ function no(t) {
4237
4651
  const e = document.createElement("div");
4238
4652
  if (e.className = `cartridge-toast transaction ${t.isExpanded ? "expanded" : "collapsed"}`, t.isExpanded) {
4239
4653
  const r = document.createElement("div");
4240
4654
  r.className = "toast-content";
4241
4655
  const n = document.createElement("div");
4242
4656
  n.className = "label-bar";
4243
- const o = document.createElement("div");
4244
- o.className = "label-container";
4245
4657
  const s = document.createElement("div");
4246
- s.className = "icon-container", t.status === "confirming" ? (s.classList.add("spinning"), s.innerHTML = `
4658
+ s.className = "label-container";
4659
+ const o = document.createElement("div");
4660
+ o.className = "icon-container", t.status === "confirming" ? (o.classList.add("spinning"), o.innerHTML = `
4247
4661
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
4248
4662
  <path d="M11.1111 5.77756C11.1111 5.28673 11.5083 4.88867 12 4.88867C15.9278 4.88867 19.1111 8.07201 19.1111 11.9998C19.1111 13.2942 18.7639 14.5109 18.1583 15.5553C17.9139 15.9803 17.3694 16.1276 16.9194 15.8803C16.5194 15.6359 16.375 15.0914 16.6194 14.6414C17.0722 13.8831 17.3333 12.972 17.3333 11.9748C17.3333 9.03034 14.9444 6.64145 12 6.64145C11.5083 6.64145 11.1111 6.26839 11.1111 5.75256V5.77756Z" fill="white"/>
4249
4663
  <path opacity="0.25" d="M11.975 6.66645C9.03058 6.66645 6.64169 9.03034 6.64169 11.9998C6.64169 14.9442 9.03058 17.3331 11.975 17.3331C13.9472 17.3331 15.6472 16.2914 16.5806 14.7331L16.5834 14.7359C16.3917 15.1498 16.5417 15.647 16.9195 15.8803C17.3695 16.1276 17.9139 15.9803 18.1584 15.5553C18.1639 15.547 18.1695 15.5387 18.1722 15.5303C16.9472 17.6692 14.6417 19.1109 12 19.1109C8.07225 19.1109 4.88892 15.9276 4.88892 11.9998C4.88892 8.07201 8.07225 4.88867 12 4.88867C11.5084 4.88867 11.1111 5.28673 11.1111 5.77756C11.1111 6.26839 11.5084 6.66645 12 6.66645H11.975Z" fill="white" fill-opacity="0.64"/>
4250
4664
  </svg>
4251
- `) : s.innerHTML = `
4665
+ `) : o.innerHTML = `
4252
4666
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
4253
4667
  <path d="M8.36382 18.5465L4 14.1827L5.45427 12.7284L8.36382 15.638L18.5457 5.45508L20 6.91032L8.36382 18.5465Z" fill="#33FF33"/>
4254
4668
  </svg>
4255
4669
  `;
4256
4670
  const a = document.createElement("p");
4257
- if (a.className = "status", a.textContent = t.status === "confirming" ? "Confirming" : "Confirmed", o.appendChild(s), o.appendChild(a), t.label) {
4671
+ if (a.className = "status", a.textContent = t.status === "confirming" ? "Confirming" : "Confirmed", s.appendChild(o), s.appendChild(a), t.label) {
4258
4672
  const c = document.createElement("div");
4259
4673
  c.className = "activity-feed-container";
4260
4674
  const d = document.createElement("div");
@@ -4266,12 +4680,12 @@ function ao(t) {
4266
4680
  const h = document.createElement("div");
4267
4681
  h.className = "activity-label-container";
4268
4682
  const f = document.createElement("span");
4269
- f.className = "activity-label", f.textContent = t.label, h.appendChild(f), c.appendChild(d), c.appendChild(h), o.appendChild(c);
4683
+ f.className = "activity-label", f.textContent = t.label, h.appendChild(f), c.appendChild(d), c.appendChild(h), s.appendChild(c);
4270
4684
  }
4271
- n.appendChild(o), r.appendChild(n);
4685
+ n.appendChild(s), r.appendChild(n);
4272
4686
  const i = document.createElement("div");
4273
4687
  i.className = "close-button-container";
4274
- const l = te();
4688
+ const l = de();
4275
4689
  i.appendChild(l), r.appendChild(i), e.appendChild(r);
4276
4690
  } else {
4277
4691
  const r = document.createElement("div");
@@ -4288,7 +4702,7 @@ function ao(t) {
4288
4702
  }
4289
4703
  return e;
4290
4704
  }
4291
- function io(t) {
4705
+ function so(t) {
4292
4706
  if (t.getElementById("cartridge-toast-network-switch-styles"))
4293
4707
  return;
4294
4708
  const e = t.createElement("style");
@@ -4312,15 +4726,15 @@ function io(t) {
4312
4726
  }
4313
4727
  `, t.head.appendChild(e);
4314
4728
  }
4315
- function co(t) {
4729
+ function oo(t) {
4316
4730
  const e = document.createElement("div");
4317
4731
  e.className = "cartridge-toast network-switch";
4318
4732
  const r = document.createElement(t.networkIcon ? "img" : "div");
4319
- r.className = "icon", r.style.width = "24px", r.style.height = "24px", r.style.aspectRatio = "1/1", t.networkIcon ? (r.src = ht(t.networkIcon), r.alt = t.networkName) : (r.style.backgroundColor = "#161A17", r.innerHTML = t.networkName.charAt(0).toUpperCase(), r.style.color = "#ffffff", r.style.fontWeight = "600", r.style.fontSize = "12px", r.style.lineHeight = "16px", r.style.textAlign = "center", r.style.textTransform = "uppercase", r.style.borderRadius = "4px", r.style.padding = "4px");
4733
+ r.className = "icon", r.style.width = "24px", r.style.height = "24px", r.style.aspectRatio = "1/1", t.networkIcon ? (r.src = Ut(t.networkIcon), r.alt = t.networkName) : (r.style.backgroundColor = "#161A17", r.innerHTML = t.networkName.charAt(0).toUpperCase(), r.style.color = "#ffffff", r.style.fontWeight = "600", r.style.fontSize = "12px", r.style.lineHeight = "16px", r.style.textAlign = "center", r.style.textTransform = "uppercase", r.style.borderRadius = "4px", r.style.padding = "4px");
4320
4734
  const n = document.createElement("p");
4321
4735
  return n.className = "content", n.textContent = `Switched to ${t.networkName}`, e.appendChild(r), e.appendChild(n), e;
4322
4736
  }
4323
- function lo(t) {
4737
+ function ao(t) {
4324
4738
  if (t.getElementById("cartridge-toast-achievement-styles"))
4325
4739
  return;
4326
4740
  const e = t.createElement("style");
@@ -4423,33 +4837,33 @@ function lo(t) {
4423
4837
  }
4424
4838
  `, t.head.appendChild(e);
4425
4839
  }
4426
- function ho(t) {
4840
+ function io(t) {
4427
4841
  const e = document.createElement("div");
4428
4842
  e.className = "cartridge-toast achievement";
4429
4843
  const r = document.createElement("div");
4430
4844
  r.className = "image-content-container";
4431
4845
  const n = document.createElement("div");
4432
4846
  n.className = "image-container";
4433
- const o = fo(t.isDraft);
4434
- o.className = "image", n.appendChild(o);
4435
- const s = document.createElement("div");
4436
- s.className = "content";
4847
+ const s = co(t.isDraft);
4848
+ s.className = "image", n.appendChild(s);
4849
+ const o = document.createElement("div");
4850
+ o.className = "content";
4437
4851
  const a = document.createElement("p");
4438
4852
  a.className = "title", a.textContent = t.title;
4439
4853
  const i = document.createElement("p");
4440
- i.className = "subtitle", i.textContent = t.subtitle || "Earned!", s.appendChild(a), s.appendChild(i), r.appendChild(n), r.appendChild(s);
4854
+ i.className = "subtitle", i.textContent = t.subtitle || "Earned!", o.appendChild(a), o.appendChild(i), r.appendChild(n), r.appendChild(o);
4441
4855
  const l = document.createElement("div");
4442
4856
  l.className = "xp-section-container";
4443
4857
  const c = document.createElement("div");
4444
4858
  c.className = "xp-section";
4445
- const d = uo(!t.isDraft);
4859
+ const d = lo(!t.isDraft);
4446
4860
  d.setAttribute("class", "xp-icon"), c.appendChild(d);
4447
4861
  const h = document.createElement("span");
4448
4862
  h.className = "xp-amount", h.textContent = `${t.xpAmount}`, c.appendChild(h), l.appendChild(c);
4449
- const f = te(!1);
4863
+ const f = de(!1);
4450
4864
  return e.appendChild(r), e.appendChild(l), e.appendChild(f), e;
4451
4865
  }
4452
- const fo = (t = !1) => {
4866
+ const co = (t = !1) => {
4453
4867
  const e = document.createElement("div"), r = document.createElementNS("http://www.w3.org/2000/svg", "svg");
4454
4868
  switch (r.setAttribute("width", "34"), r.setAttribute("height", "34"), r.setAttribute("viewBox", "0 0 30 30"), r.style.width = "100%", r.style.height = "100%", t) {
4455
4869
  case !0:
@@ -4463,7 +4877,7 @@ const fo = (t = !1) => {
4463
4877
  `;
4464
4878
  }
4465
4879
  return e.appendChild(r), e;
4466
- }, uo = (t) => {
4880
+ }, lo = (t) => {
4467
4881
  const e = document.createElementNS(
4468
4882
  "http://www.w3.org/2000/svg",
4469
4883
  "svg"
@@ -4499,7 +4913,7 @@ const fo = (t = !1) => {
4499
4913
  }
4500
4914
  return e;
4501
4915
  };
4502
- function po(t) {
4916
+ function ho(t) {
4503
4917
  if (t.getElementById("cartridge-toast-marketplace-styles"))
4504
4918
  return;
4505
4919
  const e = t.createElement("style");
@@ -4583,17 +4997,17 @@ function po(t) {
4583
4997
  }
4584
4998
  `, t.head.appendChild(e);
4585
4999
  }
4586
- function go(t) {
5000
+ function fo(t) {
4587
5001
  const e = document.createElement("div");
4588
5002
  e.className = "cartridge-toast marketplace";
4589
5003
  const r = document.createElement("div");
4590
5004
  r.className = "image-content-container";
4591
5005
  const n = document.createElement("div");
4592
5006
  n.className = "image-container";
4593
- const o = document.createElement("img");
4594
- o.className = "image", o.src = ht(t.itemImages[0]), o.alt = t.itemNames[0], n.appendChild(o);
4595
- const s = document.createElement("div");
4596
- s.className = "content";
5007
+ const s = document.createElement("img");
5008
+ s.className = "image", s.src = Ut(t.itemImages[0]), s.alt = t.itemNames[0], n.appendChild(s);
5009
+ const o = document.createElement("div");
5010
+ o.className = "content";
4597
5011
  const a = {
4598
5012
  purchased: "Purchased!",
4599
5013
  sold: "Sold!",
@@ -4603,13 +5017,13 @@ function go(t) {
4603
5017
  }, i = document.createElement("p");
4604
5018
  i.className = "title", i.textContent = a[t.action];
4605
5019
  const l = document.createElement("p");
4606
- l.className = "item-name", l.textContent = t.itemNames[0], s.appendChild(i), s.appendChild(l), r.appendChild(n), r.appendChild(s);
5020
+ l.className = "item-name", l.textContent = t.itemNames[0], o.appendChild(i), o.appendChild(l), r.appendChild(n), r.appendChild(o);
4607
5021
  const c = document.createElement("div");
4608
5022
  c.className = "close-button-container";
4609
- const d = te(!1);
5023
+ const d = de(!1);
4610
5024
  return c.appendChild(d), e.appendChild(r), e.appendChild(c), e;
4611
5025
  }
4612
- function mo(t) {
5026
+ function uo(t) {
4613
5027
  if (t.getElementById("cartridge-toast-quest-styles"))
4614
5028
  return;
4615
5029
  const e = t.createElement("style");
@@ -4712,127 +5126,127 @@ function mo(t) {
4712
5126
  }
4713
5127
  `, t.head.appendChild(e);
4714
5128
  }
4715
- function wo(t) {
5129
+ function po(t) {
4716
5130
  const e = document.createElement("div");
4717
5131
  e.className = "cartridge-toast quest";
4718
5132
  const r = document.createElement("div");
4719
5133
  r.className = "image-content-container";
4720
5134
  const n = document.createElement("div");
4721
5135
  n.className = "image-container";
4722
- const o = yo();
4723
- o.className = "image", n.appendChild(o);
4724
- const s = document.createElement("div");
4725
- s.className = "content";
5136
+ const s = go();
5137
+ s.className = "image", n.appendChild(s);
5138
+ const o = document.createElement("div");
5139
+ o.className = "content";
4726
5140
  const a = document.createElement("p");
4727
5141
  a.className = "title", a.textContent = t.title;
4728
5142
  const i = document.createElement("p");
4729
- i.className = "subtitle", i.textContent = t.subtitle || "Earned!", s.appendChild(a), s.appendChild(i), r.appendChild(n), r.appendChild(s);
4730
- const l = te(!1);
5143
+ i.className = "subtitle", i.textContent = t.subtitle || "Earned!", o.appendChild(a), o.appendChild(i), r.appendChild(n), r.appendChild(o);
5144
+ const l = de(!1);
4731
5145
  return e.appendChild(r), e.appendChild(l), e;
4732
5146
  }
4733
- const yo = () => {
5147
+ const go = () => {
4734
5148
  const t = document.createElement("div"), e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
4735
5149
  return e.setAttribute("width", "34"), e.setAttribute("height", "34"), e.setAttribute("viewBox", "0 0 30 30"), e.style.width = "100%", e.style.height = "100%", e.innerHTML = '<path d="M3 6.5V8C3 8.55312 3.44687 9 4 9H4.5H6V6.5C6 5.67188 5.32812 5 4.5 5C3.67188 5 3 5.67188 3 6.5ZM6.5 5C6.8125 5.41875 7 5.9375 7 6.5V16C7 17.1031 7.89687 18 9 18C10.1031 18 11 17.1031 11 16V15.8344C11 14.8219 11.8219 14 12.8344 14H18V8C18 6.34375 16.6562 5 15 5H6.5ZM17.5 19C19.4344 19 21 17.4344 21 15.5C21 15.225 20.775 15 20.5 15H12.8344C12.375 15 12 15.3719 12 15.8344V16C12 17.6562 10.6562 19 9 19H14.5H17.5Z" fill="white"/>', t.appendChild(e), t;
4736
- }, bo = (t) => {
5150
+ }, mo = (t) => {
4737
5151
  const e = t.borderRadius ?? 8, r = !isFinite(t.duration) || t.duration <= 0, n = document.createElement("div");
4738
5152
  n.className = "cartridge-toast-progress-bar", n.style.position = "absolute", n.style.bottom = "0", n.style.left = "0", n.style.right = "0", n.style.height = "4px", n.style.overflow = "hidden", n.style.borderBottomLeftRadius = `${e}px`, n.style.borderBottomRightRadius = `${e}px`, n.style.backgroundColor = "rgba(255, 255, 255, 0.2)";
4739
- const o = document.createElement("div");
4740
- return o.className = "cartridge-toast-progress-bar-fill", o.style.position = "absolute", o.style.bottom = "0", o.style.left = "0", o.style.height = "100%", o.style.backgroundColor = "rgba(255, 255, 255, 0.8)", o.style.borderBottomLeftRadius = `${e}px`, r ? (o.style.width = "100%", o.style.transition = "none") : (o.style.width = "0%", o.style.transition = `width ${t.duration}ms linear`, requestAnimationFrame(() => {
5153
+ const s = document.createElement("div");
5154
+ return s.className = "cartridge-toast-progress-bar-fill", s.style.position = "absolute", s.style.bottom = "0", s.style.left = "0", s.style.height = "100%", s.style.backgroundColor = "rgba(255, 255, 255, 0.8)", s.style.borderBottomLeftRadius = `${e}px`, r ? (s.style.width = "100%", s.style.transition = "none") : (s.style.width = "0%", s.style.transition = `width ${t.duration}ms linear`, requestAnimationFrame(() => {
4741
5155
  requestAnimationFrame(() => {
4742
- o.style.width = "100%";
5156
+ s.style.width = "100%";
4743
5157
  });
4744
5158
  }), t.onComplete && setTimeout(() => {
4745
5159
  t.onComplete?.();
4746
- }, t.duration)), n.appendChild(o), n;
5160
+ }, t.duration)), n.appendChild(s), n;
4747
5161
  };
4748
- function it(t, e, r, n) {
4749
- const o = bo({
5162
+ function Nt(t, e, r, n) {
5163
+ const s = mo({
4750
5164
  duration: e,
4751
5165
  onComplete: r,
4752
5166
  borderRadius: n
4753
5167
  });
4754
- t.appendChild(o);
5168
+ t.appendChild(s);
4755
5169
  }
4756
- function Co(t) {
5170
+ function wo(t) {
4757
5171
  switch (t.variant) {
4758
5172
  case "error":
4759
- return oo(t);
5173
+ return to(t);
4760
5174
  case "transaction":
4761
- return ao(t);
5175
+ return no(t);
4762
5176
  case "network-switch":
4763
- return co(t);
5177
+ return oo(t);
4764
5178
  case "achievement":
4765
- return ho(t);
5179
+ return io(t);
4766
5180
  case "quest":
4767
- return wo(t);
5181
+ return po(t);
4768
5182
  case "marketplace":
4769
- return go(t);
5183
+ return fo(t);
4770
5184
  }
4771
5185
  }
4772
- function xo(t, e) {
5186
+ function yo(t, e) {
4773
5187
  switch (e) {
4774
5188
  case "error":
4775
- no(t);
5189
+ eo(t);
4776
5190
  break;
4777
5191
  case "transaction":
4778
- so(t);
5192
+ ro(t);
4779
5193
  break;
4780
5194
  case "network-switch":
4781
- io(t);
5195
+ so(t);
4782
5196
  break;
4783
5197
  case "achievement":
4784
- lo(t);
5198
+ ao(t);
4785
5199
  break;
4786
5200
  case "quest":
4787
- mo(t);
5201
+ uo(t);
4788
5202
  break;
4789
5203
  case "marketplace":
4790
- po(t);
5204
+ ho(t);
4791
5205
  break;
4792
5206
  }
4793
5207
  }
4794
- function $e(t, e) {
4795
- to(t), xo(t, e.variant);
4796
- const r = e.position || Gn, n = Jn(t, r), o = Co(e), s = () => eo(o);
4797
- n.appendChild(o), e.onClick && (o.style.cursor = "pointer", o.addEventListener("click", (d) => {
5208
+ function Ze(t, e) {
5209
+ Xs(t), yo(t, e.variant);
5210
+ const r = e.position || qs, n = Zs(t, r), s = wo(e), o = () => Gs(s);
5211
+ n.appendChild(s), e.onClick && (s.style.cursor = "pointer", s.addEventListener("click", (d) => {
4798
5212
  !d.target.closest("#close-button") && e.onClick && e.onClick();
4799
5213
  }));
4800
- const a = o.querySelector("#close-button");
5214
+ const a = s.querySelector("#close-button");
4801
5215
  a && a.addEventListener("click", (d) => {
4802
- d.stopPropagation(), s();
5216
+ d.stopPropagation(), o();
4803
5217
  });
4804
5218
  let i = null;
4805
- const l = e.duration ?? Kn, c = !isFinite(l) || l <= 0;
5219
+ const l = e.duration ?? Vs, c = !isFinite(l) || l <= 0;
4806
5220
  if (e.variant !== "network-switch") {
4807
5221
  const d = e.variant === "error" || e.variant === "transaction" ? 8 : 4;
4808
- c ? it(o, 1 / 0, () => {
4809
- }, d) : it(o, l, s, d);
4810
- } else c || (i = setTimeout(s, l));
5222
+ c ? Nt(s, 1 / 0, () => {
5223
+ }, d) : Nt(s, l, o, d);
5224
+ } else c || (i = setTimeout(o, l));
4811
5225
  return () => {
4812
- i && clearTimeout(i), s();
5226
+ i && clearTimeout(i), o();
4813
5227
  };
4814
5228
  }
4815
- let ct = !1;
4816
- function Ft() {
4817
- ct || typeof window > "u" || Fe() || (window.addEventListener("message", (t) => {
4818
- if (t.data?.type === Dt && t.data?.options) {
5229
+ let Bt = !1;
5230
+ function vr() {
5231
+ Bt || typeof window > "u" || ht() || (window.addEventListener("message", (t) => {
5232
+ if (t.data?.type === xr && t.data?.options) {
4819
5233
  const e = document;
4820
- e && $e(e, t.data.options);
5234
+ e && Ze(e, t.data.options);
4821
5235
  }
4822
- }), ct = !0);
5236
+ }), Bt = !0);
4823
5237
  }
4824
- function vo(t) {
5238
+ function bo(t) {
4825
5239
  if (typeof window > "u" || typeof document > "u")
4826
5240
  return console.warn("Toast can only be used in a browser environment"), () => {
4827
5241
  };
4828
- if (Ft(), Fe()) {
4829
- const e = Xn();
5242
+ if (vr(), ht()) {
5243
+ const e = Ks();
4830
5244
  if (e)
4831
- return $e(e, t);
5245
+ return Ze(e, t);
4832
5246
  try {
4833
5247
  window.parent && window.parent.postMessage(
4834
5248
  {
4835
- type: Dt,
5249
+ type: xr,
4836
5250
  options: t
4837
5251
  },
4838
5252
  "*"
@@ -4844,14 +5258,14 @@ function vo(t) {
4844
5258
  return () => {
4845
5259
  };
4846
5260
  } else
4847
- return $e(document, t);
5261
+ return Ze(document, t);
4848
5262
  }
4849
- typeof window < "u" && Ft();
4850
- const ko = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5263
+ typeof window < "u" && vr();
5264
+ const Co = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4851
5265
  __proto__: null,
4852
- toast: vo
5266
+ toast: bo
4853
5267
  }, Symbol.toStringTag, { value: "Module" }));
4854
- var Eo = [
5268
+ var xo = [
4855
5269
  {
4856
5270
  name: "Wrapped BTC",
4857
5271
  symbol: "WBTC",
@@ -5433,35 +5847,35 @@ var Eo = [
5433
5847
  total_supply: null,
5434
5848
  logo_url: " https://imagedelivery.net/0xPAQaDtnQhBs8IzYRIlNg/f96b51e2-e978-42e2-c67a-e84159015000/logo"
5435
5849
  }
5436
- ], Qt = {
5850
+ ], kr = {
5437
5851
  theme: {
5438
5852
  name: "Cartridge",
5439
5853
  icon: "icon.svg"
5440
5854
  }
5441
- }, de = "https://static.cartridge.gg/presets";
5442
- async function Qe() {
5855
+ }, ve = "https://static.cartridge.gg/presets";
5856
+ async function ft() {
5443
5857
  try {
5444
- const t = await fetch(`${de}/index.json`);
5858
+ const t = await fetch(`${ve}/index.json`);
5445
5859
  if (!t.ok)
5446
5860
  throw new Error(`Failed to load configs index: ${t.statusText}`);
5447
5861
  return await t.json();
5448
5862
  } catch (t) {
5449
- return console.error("Error loading configs index:", t), { configs: [], baseUrl: de };
5863
+ return console.error("Error loading configs index:", t), { configs: [], baseUrl: ve };
5450
5864
  }
5451
5865
  }
5452
- async function Lo() {
5453
- return (await Qe()).configs;
5866
+ async function Io() {
5867
+ return (await ft()).configs;
5454
5868
  }
5455
- async function No(t) {
5869
+ async function $o(t) {
5456
5870
  try {
5457
- const n = `${(await Qe()).baseUrl || de}/${t}`, o = await fetch(`${n}/config.json`);
5458
- if (!o.ok)
5871
+ const n = `${(await ft()).baseUrl || ve}/${t}`, s = await fetch(`${n}/config.json`);
5872
+ if (!s.ok)
5459
5873
  throw new Error(
5460
- `Failed to load config ${t}: ${o.statusText}`
5874
+ `Failed to load config ${t}: ${s.statusText}`
5461
5875
  );
5462
- const s = await o.json();
5463
- if (s && s.theme) {
5464
- s.theme.icon && !s.theme.icon.startsWith("http") && (s.theme.icon = `${n}/${s.theme.icon}`), s.theme.cover && (typeof s.theme.cover == "string" ? s.theme.cover.startsWith("http") || (s.theme.cover = `${n}/${s.theme.cover}`) : (s.theme.cover.light && !s.theme.cover.light.startsWith("http") && (s.theme.cover.light = `${n}/${s.theme.cover.light}`), s.theme.cover.dark && !s.theme.cover.dark.startsWith("http") && (s.theme.cover.dark = `${n}/${s.theme.cover.dark}`)));
5876
+ const o = await s.json();
5877
+ if (o && o.theme) {
5878
+ 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}`)));
5465
5879
  const a = (i) => {
5466
5880
  if (i) {
5467
5881
  for (const l in i)
@@ -5470,75 +5884,79 @@ async function No(t) {
5470
5884
  i[l][c] && !i[l][c].startsWith("http") && (i[l][c] = `${n}/${i[l][c]}`);
5471
5885
  }
5472
5886
  };
5473
- if (s.theme.optimizedIcon && a(s.theme.optimizedIcon), s.theme.optimizedCover)
5474
- if (typeof s.theme.optimizedCover == "string")
5475
- s.theme.optimizedCover.startsWith("http") || (s.theme.optimizedCover = `${n}/${s.theme.optimizedCover}`);
5476
- else if (s.theme.optimizedCover.light || s.theme.optimizedCover.dark) {
5477
- const i = s.theme.optimizedCover;
5887
+ if (o.theme.optimizedIcon && a(o.theme.optimizedIcon), o.theme.optimizedCover)
5888
+ if (typeof o.theme.optimizedCover == "string")
5889
+ o.theme.optimizedCover.startsWith("http") || (o.theme.optimizedCover = `${n}/${o.theme.optimizedCover}`);
5890
+ else if (o.theme.optimizedCover.light || o.theme.optimizedCover.dark) {
5891
+ const i = o.theme.optimizedCover;
5478
5892
  i.light && a(i.light), i.dark && a(i.dark);
5479
5893
  } else
5480
- a(s.theme.optimizedCover);
5894
+ a(o.theme.optimizedCover);
5481
5895
  }
5482
- return s;
5896
+ return o;
5483
5897
  } catch (e) {
5484
5898
  return console.error(`Error loading config ${t}:`, e), null;
5485
5899
  }
5486
5900
  }
5487
- async function Po() {
5488
- const t = await Qe(), e = t.configs, r = t.baseUrl || de, n = {};
5901
+ async function Lo() {
5902
+ const t = await ft(), e = t.configs, r = t.baseUrl || ve, n = {};
5489
5903
  return await Promise.all(
5490
- e.map(async (o) => {
5904
+ e.map(async (s) => {
5491
5905
  try {
5492
- const s = await fetch(`${r}/${o}/config.json`);
5493
- if (s.ok) {
5494
- const a = await s.json();
5495
- n[o] = a;
5906
+ const o = await fetch(`${r}/${s}/config.json`);
5907
+ if (o.ok) {
5908
+ const a = await o.json();
5909
+ n[s] = a;
5496
5910
  }
5497
- } catch (s) {
5498
- console.error(`Error loading config ${o}:`, s);
5911
+ } catch (o) {
5912
+ console.error(`Error loading config ${s}:`, o);
5499
5913
  }
5500
5914
  })
5501
5915
  ), n;
5502
5916
  }
5503
- Qt.theme.icon = "https://static.cartridge.gg/presets/cartridge/icon.svg";
5504
- var Bo = Eo, To = Qt.theme;
5917
+ kr.theme.icon = "https://static.cartridge.gg/presets/cartridge/icon.svg";
5918
+ var Po = xo, No = kr.theme;
5505
5919
  export {
5506
- Mo as ALL_AUTH_OPTIONS,
5507
- zo as AUTH_EXTERNAL_WALLETS,
5508
- en as ArgentWallet,
5509
- on as BaseWallet,
5510
- Yn as BraavosWallet,
5511
- Oo as EMBEDDED_WALLETS,
5512
- Do as EXTERNAL_WALLETS,
5513
- Fo as EXTRA_EXTERNAL_WALLETS,
5514
- he as EthereumWalletBase,
5515
- Qo as FeeSource,
5516
- Ho as IMPLEMENTED_AUTH_OPTIONS,
5517
- sn as MetaMaskWallet,
5518
- A as NotReadyToConnect,
5519
- Hn as PhantomEVMWallet,
5520
- Qn as PhantomWallet,
5521
- jn as RabbyWallet,
5522
- R as ResponseCodes,
5523
- Wn as WalletBridge,
5524
- ge as chainIdToPlatform,
5525
- Io as default,
5526
- To as defaultTheme,
5527
- Bo as erc20Metadata,
5528
- Lo as getAvailableConfigs,
5529
- Qe as getConfigsIndex,
5530
- jo as humanizeString,
5531
- Yt as isMobile,
5532
- Po as loadAllConfigs,
5533
- No as loadConfig,
5534
- $o as lookupAddresses,
5535
- So as lookupUsernames,
5536
- Yo as normalizeCalls,
5537
- Vt as parseChainId,
5538
- ht as sanitizeImageSrc,
5539
- jt as toArray,
5540
- Wo as toSessionPolicies,
5920
+ Ro as ALL_AUTH_OPTIONS,
5921
+ Uo as AUTH_EXTERNAL_WALLETS,
5922
+ Xn as ArgentWallet,
5923
+ rs as BaseWallet,
5924
+ Qs as BraavosWallet,
5925
+ Mo as EMBEDDED_WALLETS,
5926
+ zo as EXTERNAL_WALLETS,
5927
+ Oo as EXTRA_EXTERNAL_WALLETS,
5928
+ Ee as EthereumWalletBase,
5929
+ Do as FeeSource,
5930
+ he as HeadlessAuthenticationError,
5931
+ Fo as HeadlessModeNotSupportedError,
5932
+ Qo as IMPLEMENTED_AUTH_OPTIONS,
5933
+ jo as InvalidCredentialsError,
5934
+ ns as MetaMaskWallet,
5935
+ I as NotReadyToConnect,
5936
+ Ds as PhantomEVMWallet,
5937
+ Os as PhantomWallet,
5938
+ Fs as RabbyWallet,
5939
+ z as ResponseCodes,
5940
+ js as WalletBridge,
5941
+ $e as chainIdToPlatform,
5942
+ Eo as default,
5943
+ No as defaultTheme,
5944
+ Po as erc20Metadata,
5945
+ Io as getAvailableConfigs,
5946
+ ft as getConfigsIndex,
5947
+ Ho as humanizeString,
5948
+ Ar as isMobile,
5949
+ Lo as loadAllConfigs,
5950
+ $o as loadConfig,
5951
+ Ao as lookupAddresses,
5952
+ _o as lookupUsernames,
5953
+ Wo as normalizeCalls,
5954
+ Ir as parseChainId,
5955
+ So as parsePolicies,
5956
+ Ut as sanitizeImageSrc,
5957
+ _r as toArray,
5958
+ Yo as toSessionPolicies,
5541
5959
  Vo as toWasmPolicies,
5542
- vo as toast
5960
+ bo as toast
5543
5961
  };
5544
5962
  //# sourceMappingURL=index.js.map