@cartridge/controller 0.9.0 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
- import { WalletAccount as ye, constants as $, shortString as W, num as be } from "starknet";
2
- import { R as v, t as we, K as _e, P as ke, B as Ae, v as Ie, N as b, p as ve, A as Ee } from "./provider-B9Ikz5hr.js";
3
- import { F as nr, h as or, n as sr, a as ar, b as ir } from "./provider-B9Ikz5hr.js";
4
- import { connect as xe } from "starknetkit";
5
- import { InjectedConnector as Ce } from "starknetkit/injected";
6
- import { MetaMaskSDK as Pe } from "@metamask/sdk";
7
- import { Transaction as Re } from "@solana/web3.js";
8
- class H extends ye {
1
+ import { WalletAccount as ge, constants as $, shortString as W, num as ye } from "starknet";
2
+ import { R, t as be, K as we, B as _e, v as ke, N as p, p as Ae, A as Ie } from "./provider-C1UeMjUr.js";
3
+ import { F as tr, h as rr, n as nr, a as sr, b as or } from "./provider-C1UeMjUr.js";
4
+ import { connect as ve } from "starknetkit";
5
+ import { InjectedConnector as Ee } from "starknetkit/injected";
6
+ import { MetaMaskSDK as xe } from "@metamask/sdk";
7
+ import { Transaction as Ce } from "@solana/web3.js";
8
+ class H extends ge {
9
9
  keychain;
10
10
  modal;
11
11
  options;
12
- constructor(e, t, n, o, s, a) {
13
- super({ nodeUrl: t }, e, n), this.keychain = o, this.options = s, this.modal = a;
12
+ constructor(e, t, n, s, o, a) {
13
+ super({ nodeUrl: t }, e, n), this.keychain = s, this.options = o, this.modal = a;
14
14
  }
15
15
  /**
16
16
  * Invoke execute function in account contract
@@ -25,35 +25,35 @@ class H extends ye {
25
25
  * @returns response from addTransaction
26
26
  */
27
27
  async execute(e) {
28
- return e = we(e), new Promise(async (t, n) => {
29
- const o = await this.keychain.execute(
28
+ return e = be(e), new Promise(async (t, n) => {
29
+ const s = await this.keychain.execute(
30
30
  e,
31
31
  void 0,
32
32
  void 0,
33
33
  !1,
34
34
  this.options?.feeSource
35
35
  );
36
- if (o.code === v.SUCCESS) {
37
- t(o);
36
+ if (s.code === R.SUCCESS) {
37
+ t(s);
38
38
  return;
39
39
  }
40
- if (this.options?.propagateSessionErrors && o.code !== v.USER_INTERACTION_REQUIRED) {
41
- n(o.error);
40
+ if (this.options?.propagateSessionErrors && s.code !== R.USER_INTERACTION_REQUIRED) {
41
+ n(s.error);
42
42
  return;
43
43
  }
44
44
  this.modal.open();
45
- const s = await this.keychain.execute(
45
+ const o = await this.keychain.execute(
46
46
  e,
47
47
  void 0,
48
48
  void 0,
49
49
  !0,
50
- o.error
50
+ s.error
51
51
  );
52
- if (s.code === v.SUCCESS) {
53
- t(s), this.modal.close();
52
+ if (o.code === R.SUCCESS) {
53
+ t(o), this.modal.close();
54
54
  return;
55
55
  }
56
- n(s.error);
56
+ n(o.error);
57
57
  });
58
58
  }
59
59
  /**
@@ -66,29 +66,29 @@ class H extends ye {
66
66
  */
67
67
  async signMessage(e) {
68
68
  return new Promise(async (t, n) => {
69
- const o = await this.keychain.signMessage(e, "", !0);
70
- if (!("code" in o)) {
71
- t(o);
69
+ const s = await this.keychain.signMessage(e, "", !0);
70
+ if (!("code" in s)) {
71
+ t(s);
72
72
  return;
73
73
  }
74
74
  this.modal.open();
75
- const s = await this.keychain.signMessage(e, "", !1);
76
- "code" in s ? n(s.error) : t(s), this.modal.close();
75
+ const o = await this.keychain.signMessage(e, "", !1);
76
+ "code" in o ? n(o.error) : t(o), this.modal.close();
77
77
  });
78
78
  }
79
79
  }
80
- var w;
80
+ var b;
81
81
  (function(r) {
82
82
  r.Call = "call", r.Reply = "reply", r.Syn = "syn", r.SynAck = "synAck", r.Ack = "ack";
83
- })(w || (w = {}));
84
- var E;
83
+ })(b || (b = {}));
84
+ var v;
85
85
  (function(r) {
86
86
  r.Fulfilled = "fulfilled", r.Rejected = "rejected";
87
- })(E || (E = {}));
88
- var D;
87
+ })(v || (v = {}));
88
+ var N;
89
89
  (function(r) {
90
90
  r.ConnectionDestroyed = "ConnectionDestroyed", r.ConnectionTimeout = "ConnectionTimeout", r.NoIframeSrc = "NoIframeSrc";
91
- })(D || (D = {}));
91
+ })(N || (N = {}));
92
92
  var z;
93
93
  (function(r) {
94
94
  r.DataCloneError = "DataCloneError";
@@ -97,242 +97,243 @@ var A;
97
97
  (function(r) {
98
98
  r.Message = "message";
99
99
  })(A || (A = {}));
100
- const Se = (r, e) => {
100
+ const Re = (r, e) => {
101
101
  const t = [];
102
102
  let n = !1;
103
103
  return {
104
- destroy(o) {
105
- n || (n = !0, e(`${r}: Destroying connection`), t.forEach((s) => {
106
- s(o);
104
+ destroy(s) {
105
+ n || (n = !0, e(`${r}: Destroying connection`), t.forEach((o) => {
106
+ o(s);
107
107
  }));
108
108
  },
109
- onDestroy(o) {
110
- n ? o() : t.push(o);
109
+ onDestroy(s) {
110
+ n ? s() : t.push(s);
111
111
  }
112
112
  };
113
- }, Ne = (r) => (...e) => {
113
+ }, Se = (r) => (...e) => {
114
114
  r && console.log("[Penpal]", ...e);
115
- }, De = {
115
+ }, Pe = {
116
116
  "http:": "80",
117
117
  "https:": "443"
118
- }, Me = /^(https?:)?\/\/([^/:]+)?(:(\d+))?/, Be = ["file:", "data:"], Ue = (r) => {
119
- if (r && Be.find((i) => r.startsWith(i)))
118
+ }, De = /^(https?:)?\/\/([^/:]+)?(:(\d+))?/, Ne = ["file:", "data:"], Me = (r) => {
119
+ if (r && Ne.find((i) => r.startsWith(i)))
120
120
  return "null";
121
- const e = document.location, t = Me.exec(r);
122
- let n, o, s;
123
- t ? (n = t[1] ? t[1] : e.protocol, o = t[2], s = t[4]) : (n = e.protocol, o = e.hostname, s = e.port);
124
- const a = s && s !== De[n] ? `:${s}` : "";
125
- return `${n}//${o}${a}`;
121
+ const e = document.location, t = De.exec(r);
122
+ let n, s, o;
123
+ t ? (n = t[1] ? t[1] : e.protocol, s = t[2], o = t[4]) : (n = e.protocol, s = e.hostname, o = e.port);
124
+ const a = o && o !== Pe[n] ? `:${o}` : "";
125
+ return `${n}//${s}${a}`;
126
126
  }, K = ({ name: r, message: e, stack: t }) => ({
127
127
  name: r,
128
128
  message: e,
129
129
  stack: t
130
- }), Qe = (r) => {
130
+ }), Be = (r) => {
131
131
  const e = new Error();
132
132
  return Object.keys(r).forEach((t) => e[t] = r[t]), e;
133
133
  }, Te = (r, e, t) => {
134
- const { localName: n, local: o, remote: s, originForSending: a, originForReceiving: i } = r;
134
+ const { localName: n, local: s, remote: o, originForSending: a, originForReceiving: i } = r;
135
135
  let c = !1;
136
- const d = (l) => {
137
- if (l.source !== s || l.data.penpal !== w.Call)
136
+ const l = (d) => {
137
+ if (d.source !== o || d.data.penpal !== b.Call)
138
138
  return;
139
- if (i !== "*" && l.origin !== i) {
140
- t(`${n} received message from origin ${l.origin} which did not match expected origin ${i}`);
139
+ if (i !== "*" && d.origin !== i) {
140
+ t(`${n} received message from origin ${d.origin} which did not match expected origin ${i}`);
141
141
  return;
142
142
  }
143
- const h = l.data, { methodName: p, args: f, id: g } = h;
144
- t(`${n}: Received ${p}() call`);
143
+ const h = d.data, { methodName: g, args: u, id: _ } = h;
144
+ t(`${n}: Received ${g}() call`);
145
145
  const k = (y) => (I) => {
146
- if (t(`${n}: Sending ${p}() reply`), c) {
147
- t(`${n}: Unable to send ${p}() reply due to destroyed connection`);
146
+ if (t(`${n}: Sending ${g}() reply`), c) {
147
+ t(`${n}: Unable to send ${g}() reply due to destroyed connection`);
148
148
  return;
149
149
  }
150
- const _ = {
151
- penpal: w.Reply,
152
- id: g,
150
+ const w = {
151
+ penpal: b.Reply,
152
+ id: _,
153
153
  resolution: y,
154
154
  returnValue: I
155
155
  };
156
- y === E.Rejected && I instanceof Error && (_.returnValue = K(I), _.returnValueIsError = !0);
156
+ y === v.Rejected && I instanceof Error && (w.returnValue = K(I), w.returnValueIsError = !0);
157
157
  try {
158
- s.postMessage(_, a);
159
- } catch (u) {
160
- if (u.name === z.DataCloneError) {
161
- const x = {
162
- penpal: w.Reply,
163
- id: g,
164
- resolution: E.Rejected,
165
- returnValue: K(u),
158
+ o.postMessage(w, a);
159
+ } catch (f) {
160
+ if (f.name === z.DataCloneError) {
161
+ const E = {
162
+ penpal: b.Reply,
163
+ id: _,
164
+ resolution: v.Rejected,
165
+ returnValue: K(f),
166
166
  returnValueIsError: !0
167
167
  };
168
- s.postMessage(x, a);
168
+ o.postMessage(E, a);
169
169
  }
170
- throw u;
170
+ throw f;
171
171
  }
172
172
  };
173
- new Promise((y) => y(e[p].call(e, l.origin).apply(e, f))).then(k(E.Fulfilled), k(E.Rejected));
173
+ new Promise((y) => y(e[g].call(e, d.origin).apply(e, u))).then(k(v.Fulfilled), k(v.Rejected));
174
174
  };
175
- return o.addEventListener(A.Message, d), () => {
176
- c = !0, o.removeEventListener(A.Message, d);
175
+ return s.addEventListener(A.Message, l), () => {
176
+ c = !0, s.removeEventListener(A.Message, l);
177
177
  };
178
178
  };
179
- let $e = 0;
180
- const ze = () => ++$e, re = ".", ne = (r) => r ? r.split(re) : [], Oe = (r) => r.join(re), Le = (r, e) => {
179
+ let Qe = 0;
180
+ const Ue = () => ++Qe, re = ".", ne = (r) => r ? r.split(re) : [], $e = (r) => r.join(re), ze = (r, e) => {
181
181
  const t = ne(e || "");
182
- return t.push(r), Oe(t);
183
- }, Ye = (r, e, t) => {
182
+ return t.push(r), $e(t);
183
+ }, Oe = (r, e, t) => {
184
184
  const n = ne(e);
185
- return n.reduce((o, s, a) => (typeof o[s] > "u" && (o[s] = {}), a === n.length - 1 && (o[s] = t), o[s]), r), r;
186
- }, oe = (r, e) => {
185
+ return n.reduce((s, o, a) => (typeof s[o] > "u" && (s[o] = {}), a === n.length - 1 && (s[o] = t), s[o]), r), r;
186
+ }, se = (r, e) => {
187
187
  const t = {};
188
188
  return Object.keys(r).forEach((n) => {
189
- const o = r[n], s = Le(n, e);
190
- typeof o == "object" && Object.assign(t, oe(o, s)), typeof o == "function" && (t[s] = o);
189
+ const s = r[n], o = ze(n, e);
190
+ typeof s == "object" && Object.assign(t, se(s, o)), typeof s == "function" && (t[o] = s);
191
191
  }), t;
192
- }, Fe = (r) => {
192
+ }, Le = (r) => {
193
193
  const e = {};
194
194
  for (const t in r)
195
- Ye(e, t, r[t]);
195
+ Oe(e, t, r[t]);
196
196
  return e;
197
- }, We = (r, e, t, n, o) => {
198
- const { localName: s, local: a, remote: i, originForSending: c, originForReceiving: d } = e;
199
- let l = !1;
200
- o(`${s}: Connecting call sender`);
201
- const h = (f) => (...g) => {
202
- o(`${s}: Sending ${f}() call`);
197
+ }, Ye = (r, e, t, n, s) => {
198
+ const { localName: o, local: a, remote: i, originForSending: c, originForReceiving: l } = e;
199
+ let d = !1;
200
+ s(`${o}: Connecting call sender`);
201
+ const h = (u) => (..._) => {
202
+ s(`${o}: Sending ${u}() call`);
203
203
  let k;
204
204
  try {
205
205
  i.closed && (k = !0);
206
206
  } catch {
207
207
  k = !0;
208
208
  }
209
- if (k && n(), l) {
210
- const y = new Error(`Unable to send ${f}() call due to destroyed connection`);
211
- throw y.code = D.ConnectionDestroyed, y;
209
+ if (k && n(), d) {
210
+ const y = new Error(`Unable to send ${u}() call due to destroyed connection`);
211
+ throw y.code = N.ConnectionDestroyed, y;
212
212
  }
213
213
  return new Promise((y, I) => {
214
- const _ = ze(), u = (C) => {
215
- if (C.source !== i || C.data.penpal !== w.Reply || C.data.id !== _)
214
+ const w = Ue(), f = (x) => {
215
+ if (x.source !== i || x.data.penpal !== b.Reply || x.data.id !== w)
216
216
  return;
217
- if (d !== "*" && C.origin !== d) {
218
- o(`${s} received message from origin ${C.origin} which did not match expected origin ${d}`);
217
+ if (l !== "*" && x.origin !== l) {
218
+ s(`${o} received message from origin ${x.origin} which did not match expected origin ${l}`);
219
219
  return;
220
220
  }
221
- const Q = C.data;
222
- o(`${s}: Received ${f}() reply`), a.removeEventListener(A.Message, u);
223
- let T = Q.returnValue;
224
- Q.returnValueIsError && (T = Qe(T)), (Q.resolution === E.Fulfilled ? y : I)(T);
221
+ const Q = x.data;
222
+ s(`${o}: Received ${u}() reply`), a.removeEventListener(A.Message, f);
223
+ let U = Q.returnValue;
224
+ Q.returnValueIsError && (U = Be(U)), (Q.resolution === v.Fulfilled ? y : I)(U);
225
225
  };
226
- a.addEventListener(A.Message, u);
227
- const x = {
228
- penpal: w.Call,
229
- id: _,
230
- methodName: f,
231
- args: g
226
+ a.addEventListener(A.Message, f);
227
+ const E = {
228
+ penpal: b.Call,
229
+ id: w,
230
+ methodName: u,
231
+ args: _
232
232
  };
233
- i.postMessage(x, c);
233
+ i.postMessage(E, c);
234
234
  });
235
- }, p = t.reduce((f, g) => (f[g] = h(g), f), {});
236
- return Object.assign(r, Fe(p)), () => {
237
- l = !0;
235
+ }, g = t.reduce((u, _) => (u[_] = h(_), u), {});
236
+ return Object.assign(r, Le(g)), () => {
237
+ d = !0;
238
238
  };
239
- }, He = (r, e, t, n, o) => {
240
- const { destroy: s, onDestroy: a } = n;
239
+ }, Fe = (r, e, t, n, s) => {
240
+ const { destroy: o, onDestroy: a } = n;
241
241
  let i, c;
242
- const d = {};
243
- return (l) => {
244
- if (e !== "*" && l.origin !== e) {
245
- o(`Parent: Handshake - Received ACK message from origin ${l.origin} which did not match expected origin ${e}`);
242
+ const l = {};
243
+ return (d) => {
244
+ if (e !== "*" && d.origin !== e) {
245
+ s(`Parent: Handshake - Received ACK message from origin ${d.origin} which did not match expected origin ${e}`);
246
246
  return;
247
247
  }
248
- o("Parent: Handshake - Received ACK");
248
+ s("Parent: Handshake - Received ACK");
249
249
  const h = {
250
250
  localName: "Parent",
251
251
  local: window,
252
- remote: l.source,
252
+ remote: d.source,
253
253
  originForSending: t,
254
254
  originForReceiving: e
255
255
  };
256
- i && i(), i = Te(h, r, o), a(i), c && c.forEach((f) => {
257
- delete d[f];
258
- }), c = l.data.methodNames;
259
- const p = We(d, h, c, s, o);
260
- return a(p), d;
256
+ i && i(), i = Te(h, r, s), a(i), c && c.forEach((u) => {
257
+ delete l[u];
258
+ }), c = d.data.methodNames;
259
+ const g = Ye(l, h, c, o, s);
260
+ return a(g), l;
261
261
  };
262
- }, Ke = (r, e, t, n) => (o) => {
263
- if (!o.source)
262
+ }, We = (r, e, t, n) => (s) => {
263
+ if (!s.source)
264
264
  return;
265
- if (t !== "*" && o.origin !== t) {
266
- r(`Parent: Handshake - Received SYN message from origin ${o.origin} which did not match expected origin ${t}`);
265
+ if (t !== "*" && s.origin !== t) {
266
+ r(`Parent: Handshake - Received SYN message from origin ${s.origin} which did not match expected origin ${t}`);
267
267
  return;
268
268
  }
269
269
  r("Parent: Handshake - Received SYN, responding with SYN-ACK");
270
- const s = {
271
- penpal: w.SynAck,
270
+ const o = {
271
+ penpal: b.SynAck,
272
272
  methodNames: Object.keys(e)
273
273
  };
274
- o.source.postMessage(s, n);
275
- }, je = 6e4, qe = (r, e) => {
276
- const { destroy: t, onDestroy: n } = e, o = setInterval(() => {
277
- r.isConnected || (clearInterval(o), t());
278
- }, je);
274
+ s.source.postMessage(o, n);
275
+ }, He = 6e4, Ke = (r, e) => {
276
+ const { destroy: t, onDestroy: n } = e, s = setInterval(() => {
277
+ r.isConnected || (clearInterval(s), t());
278
+ }, He);
279
279
  n(() => {
280
- clearInterval(o);
280
+ clearInterval(s);
281
281
  });
282
- }, Xe = (r, e) => {
282
+ }, je = (r, e) => {
283
283
  let t;
284
284
  return r !== void 0 && (t = window.setTimeout(() => {
285
285
  const n = new Error(`Connection timed out after ${r}ms`);
286
- n.code = D.ConnectionTimeout, e(n);
286
+ n.code = N.ConnectionTimeout, e(n);
287
287
  }, r)), () => {
288
288
  clearTimeout(t);
289
289
  };
290
- }, Ge = (r) => {
290
+ }, qe = (r) => {
291
291
  if (!r.src && !r.srcdoc) {
292
292
  const e = new Error("Iframe must have src or srcdoc property defined.");
293
- throw e.code = D.NoIframeSrc, e;
293
+ throw e.code = N.NoIframeSrc, e;
294
294
  }
295
- }, Ve = (r) => {
296
- let { iframe: e, methods: t = {}, childOrigin: n, timeout: o, debug: s = !1 } = r;
297
- const a = Ne(s), i = Se("Parent", a), { onDestroy: c, destroy: d } = i;
298
- n || (Ge(e), n = Ue(e.src));
299
- const l = n === "null" ? "*" : n, h = oe(t), p = Ke(a, h, n, l), f = He(h, n, l, i, a);
295
+ }, Xe = (r) => {
296
+ let { iframe: e, methods: t = {}, childOrigin: n, timeout: s, debug: o = !1 } = r;
297
+ const a = Se(o), i = Re("Parent", a), { onDestroy: c, destroy: l } = i;
298
+ n || (qe(e), n = Me(e.src));
299
+ const d = n === "null" ? "*" : n, h = se(t), g = We(a, h, n, d), u = Fe(h, n, d, i, a);
300
300
  return {
301
301
  promise: new Promise((k, y) => {
302
- const I = Xe(o, d), _ = (u) => {
303
- if (!(u.source !== e.contentWindow || !u.data)) {
304
- if (u.data.penpal === w.Syn) {
305
- p(u);
302
+ const I = je(s, l), w = (f) => {
303
+ if (!(f.source !== e.contentWindow || !f.data)) {
304
+ if (f.data.penpal === b.Syn) {
305
+ g(f);
306
306
  return;
307
307
  }
308
- if (u.data.penpal === w.Ack) {
309
- const x = f(u);
310
- x && (I(), k(x));
308
+ if (f.data.penpal === b.Ack) {
309
+ const E = u(f);
310
+ E && (I(), k(E));
311
311
  return;
312
312
  }
313
313
  }
314
314
  };
315
- window.addEventListener(A.Message, _), a("Parent: Awaiting handshake"), qe(e, i), c((u) => {
316
- window.removeEventListener(A.Message, _), u && y(u);
315
+ window.addEventListener(A.Message, w), a("Parent: Awaiting handshake"), Ke(e, i), c((f) => {
316
+ window.removeEventListener(A.Message, w), f && y(f);
317
317
  });
318
318
  }),
319
319
  destroy() {
320
- d();
320
+ l();
321
321
  }
322
322
  };
323
323
  };
324
- class se {
324
+ class Ge {
325
325
  url;
326
326
  iframe;
327
327
  container;
328
328
  onClose;
329
329
  child;
330
+ closeTimeout;
330
331
  constructor({
331
332
  id: e,
332
333
  url: t,
333
334
  preset: n,
334
- onClose: o,
335
- onConnect: s,
335
+ onClose: s,
336
+ onConnect: o,
336
337
  methods: a = {}
337
338
  }) {
338
339
  if (typeof document > "u" || typeof window > "u")
@@ -341,43 +342,39 @@ class se {
341
342
  const i = document.createElement("iframe");
342
343
  i.src = t.toString(), i.id = e, i.style.border = "none", i.sandbox.add("allow-forms"), i.sandbox.add("allow-popups"), i.sandbox.add("allow-popups-to-escape-sandbox"), i.sandbox.add("allow-scripts"), i.sandbox.add("allow-same-origin"), i.allow = "publickey-credentials-create *; publickey-credentials-get *; clipboard-write", document.hasStorageAccess && i.sandbox.add("allow-storage-access-by-user-activation");
343
344
  const c = document.createElement("div");
344
- 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 = "flex", c.style.alignItems = "center", c.style.justifyContent = "center", c.style.visibility = "hidden", c.style.opacity = "0", c.style.transition = "opacity 0.2s ease", c.style.pointerEvents = "auto", c.appendChild(i), c.addEventListener("click", (h) => {
345
- h.target === c && (e === "controller-keychain" && this.child && this.child.reset?.().catch((p) => console.error("Error resetting context:", p)), this.close());
346
- }), this.iframe = i, this.container = c, Ve({
345
+ 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.appendChild(i), c.addEventListener("click", (h) => {
346
+ h.target === c && (e === "controller-keychain" && this.child && this.child.reset?.().catch((g) => console.error("Error resetting context:", g)), this.close());
347
+ }), this.iframe = i, this.container = c, Xe({
347
348
  iframe: this.iframe,
348
349
  methods: {
349
350
  close: (h) => () => this.close(),
350
- closeAll: (h) => () => {
351
- document.querySelectorAll(
352
- 'iframe[id^="controller-"]'
353
- ).forEach((f) => {
354
- const g = f.parentElement;
355
- g && (g.style.visibility = "hidden", g.style.opacity = "0");
356
- }), document.body && (document.body.style.overflow = "auto");
357
- },
358
351
  reload: (h) => () => window.location.reload(),
359
352
  ...a
360
353
  }
361
354
  }).promise.then((h) => {
362
- this.child = h, s(h);
355
+ this.child = h, o(h);
363
356
  }), this.resize(), window.addEventListener("resize", () => this.resize());
364
- const d = new MutationObserver(() => {
357
+ const l = new MutationObserver(() => {
365
358
  if (typeof document > "u") return;
366
359
  const h = document.getElementById("controller");
367
- document.body && (e === "controller-keychain" && !h || e === "controller-profile") && (document.body.appendChild(c), d.disconnect());
360
+ document.body && e === "controller-keychain" && !h && (document.body.appendChild(c), l.disconnect());
368
361
  });
369
- d.observe(document.documentElement, {
362
+ l.observe(document.documentElement, {
370
363
  childList: !0,
371
364
  subtree: !0
372
365
  });
373
- const l = document.getElementById("controller");
374
- document.body && (e === "controller-keychain" && !l || e === "controller-profile") && document.body.appendChild(c), this.onClose = o;
366
+ const d = document.getElementById("controller");
367
+ document.body && e === "controller-keychain" && !d && document.body.appendChild(c), this.onClose = s;
375
368
  }
376
369
  open() {
377
- !this.container || typeof document > "u" || !document.body || (document.body.style.overflow = "hidden", this.container.style.visibility = "visible", this.container.style.opacity = "1");
370
+ !this.container || typeof document > "u" || !document.body || (this.closeTimeout && (clearTimeout(this.closeTimeout), this.closeTimeout = void 0), document.body.style.overflow = "hidden", this.container.style.display = "flex", requestAnimationFrame(() => {
371
+ this.container && (this.container.style.opacity = "1");
372
+ }));
378
373
  }
379
374
  close() {
380
- !this.container || typeof document > "u" || !document.body || (this.onClose?.(), document.body.style.overflow = "auto", this.container.style.visibility = "hidden", this.container.style.opacity = "0");
375
+ !this.container || typeof document > "u" || !document.body || (this.onClose?.(), document.body.style.overflow = "auto", this.container.style.opacity = "0", this.closeTimeout = setTimeout(() => {
376
+ this.container && (this.container.style.display = "none"), this.closeTimeout = void 0;
377
+ }, 200));
381
378
  }
382
379
  sendBackward() {
383
380
  this.container && (this.container.style.zIndex = "9999");
@@ -394,19 +391,22 @@ class se {
394
391
  this.iframe.style.height = "600px", this.iframe.style.width = "432px", this.iframe.style.borderRadius = "8px";
395
392
  }
396
393
  }
394
+ isOpen() {
395
+ return this.container?.style.display !== "none";
396
+ }
397
397
  }
398
- const Je = "6.13.7";
398
+ const Ve = "6.13.7";
399
399
  function j(r, e, t) {
400
400
  for (let n in e) {
401
- let o = e[n];
402
- Object.defineProperty(r, n, { enumerable: !0, value: o, writable: !1 });
401
+ let s = e[n];
402
+ Object.defineProperty(r, n, { enumerable: !0, value: s, writable: !1 });
403
403
  }
404
404
  }
405
- function P(r) {
405
+ function C(r) {
406
406
  if (r == null)
407
407
  return "null";
408
408
  if (Array.isArray(r))
409
- return "[ " + r.map(P).join(", ") + " ]";
409
+ return "[ " + r.map(C).join(", ") + " ]";
410
410
  if (r instanceof Uint8Array) {
411
411
  const e = "0123456789abcdef";
412
412
  let t = "0x";
@@ -415,7 +415,7 @@ function P(r) {
415
415
  return t;
416
416
  }
417
417
  if (typeof r == "object" && typeof r.toJSON == "function")
418
- return P(r.toJSON());
418
+ return C(r.toJSON());
419
419
  switch (typeof r) {
420
420
  case "boolean":
421
421
  case "symbol":
@@ -428,47 +428,47 @@ function P(r) {
428
428
  return JSON.stringify(r);
429
429
  case "object": {
430
430
  const e = Object.keys(r);
431
- return e.sort(), "{ " + e.map((t) => `${P(t)}: ${P(r[t])}`).join(", ") + " }";
431
+ return e.sort(), "{ " + e.map((t) => `${C(t)}: ${C(r[t])}`).join(", ") + " }";
432
432
  }
433
433
  }
434
434
  return "[ COULD NOT SERIALIZE ]";
435
435
  }
436
- function Ze(r, e, t) {
436
+ function Je(r, e, t) {
437
437
  let n = r;
438
438
  {
439
- const s = [];
439
+ const o = [];
440
440
  if (t) {
441
441
  if ("message" in t || "code" in t || "name" in t)
442
- throw new Error(`value will overwrite populated values: ${P(t)}`);
442
+ throw new Error(`value will overwrite populated values: ${C(t)}`);
443
443
  for (const a in t) {
444
444
  if (a === "shortMessage")
445
445
  continue;
446
446
  const i = t[a];
447
- s.push(a + "=" + P(i));
447
+ o.push(a + "=" + C(i));
448
448
  }
449
449
  }
450
- s.push(`code=${e}`), s.push(`version=${Je}`), s.length && (r += " (" + s.join(", ") + ")");
450
+ o.push(`code=${e}`), o.push(`version=${Ve}`), o.length && (r += " (" + o.join(", ") + ")");
451
451
  }
452
- let o;
452
+ let s;
453
453
  switch (e) {
454
454
  case "INVALID_ARGUMENT":
455
- o = new TypeError(r);
455
+ s = new TypeError(r);
456
456
  break;
457
457
  case "NUMERIC_FAULT":
458
458
  case "BUFFER_OVERRUN":
459
- o = new RangeError(r);
459
+ s = new RangeError(r);
460
460
  break;
461
461
  default:
462
- o = new Error(r);
462
+ s = new Error(r);
463
463
  }
464
- return j(o, { code: e }), t && Object.assign(o, t), o.shortMessage == null && j(o, { shortMessage: n }), o;
464
+ return j(s, { code: e }), t && Object.assign(s, t), s.shortMessage == null && j(s, { shortMessage: n }), s;
465
465
  }
466
- function et(r, e, t, n) {
466
+ function Ze(r, e, t, n) {
467
467
  if (!r)
468
- throw Ze(e, t, n);
468
+ throw Je(e, t, n);
469
469
  }
470
- function N(r, e, t, n) {
471
- et(r, e, "INVALID_ARGUMENT", { argument: t, value: n });
470
+ function D(r, e, t, n) {
471
+ Ze(r, e, "INVALID_ARGUMENT", { argument: t, value: n });
472
472
  }
473
473
  ["NFD", "NFC", "NFKD", "NFKC"].reduce((r, e) => {
474
474
  try {
@@ -481,28 +481,28 @@ function N(r, e, t, n) {
481
481
  }
482
482
  return r;
483
483
  }, []);
484
- function tt(r, e, t) {
484
+ function et(r, e, t) {
485
485
  if (r instanceof Uint8Array)
486
486
  return r;
487
487
  if (typeof r == "string" && r.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)) {
488
488
  const n = new Uint8Array((r.length - 2) / 2);
489
- let o = 2;
490
- for (let s = 0; s < n.length; s++)
491
- n[s] = parseInt(r.substring(o, o + 2), 16), o += 2;
489
+ let s = 2;
490
+ for (let o = 0; o < n.length; o++)
491
+ n[o] = parseInt(r.substring(s, s + 2), 16), s += 2;
492
492
  return n;
493
493
  }
494
- N(!1, "invalid BytesLike value", e || "value", r);
494
+ D(!1, "invalid BytesLike value", e || "value", r);
495
495
  }
496
496
  function O(r, e) {
497
- return tt(r, e);
497
+ return et(r, e);
498
498
  }
499
499
  const q = "0123456789abcdef";
500
- function rt(r) {
500
+ function tt(r) {
501
501
  const e = O(r);
502
502
  let t = "0x";
503
503
  for (let n = 0; n < e.length; n++) {
504
- const o = e[n];
505
- t += q[(o & 240) >> 4] + q[o & 15];
504
+ const s = e[n];
505
+ t += q[(s & 240) >> 4] + q[s & 15];
506
506
  }
507
507
  return t;
508
508
  }
@@ -510,7 +510,7 @@ function X(r) {
510
510
  if (!Number.isSafeInteger(r) || r < 0)
511
511
  throw new Error(`Wrong positive integer: ${r}`);
512
512
  }
513
- function ae(r, ...e) {
513
+ function oe(r, ...e) {
514
514
  if (!(r instanceof Uint8Array))
515
515
  throw new Error("Expected Uint8Array");
516
516
  if (e.length > 0 && !e.includes(r.length))
@@ -522,71 +522,71 @@ function G(r, e = !0) {
522
522
  if (e && r.finished)
523
523
  throw new Error("Hash#digest() has already been called");
524
524
  }
525
- function nt(r, e) {
526
- ae(r);
525
+ function rt(r, e) {
526
+ oe(r);
527
527
  const t = e.outputLen;
528
528
  if (r.length < t)
529
529
  throw new Error(`digestInto() expects output buffer of length at least ${t}`);
530
530
  }
531
531
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
532
- const ot = (r) => r instanceof Uint8Array, st = (r) => new Uint32Array(r.buffer, r.byteOffset, Math.floor(r.byteLength / 4)), at = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
533
- if (!at)
532
+ const nt = (r) => r instanceof Uint8Array, st = (r) => new Uint32Array(r.buffer, r.byteOffset, Math.floor(r.byteLength / 4)), ot = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
533
+ if (!ot)
534
534
  throw new Error("Non little-endian hardware is not supported");
535
- function it(r) {
535
+ function at(r) {
536
536
  if (typeof r != "string")
537
537
  throw new Error(`utf8ToBytes expected string, got ${typeof r}`);
538
538
  return new Uint8Array(new TextEncoder().encode(r));
539
539
  }
540
- function ie(r) {
541
- if (typeof r == "string" && (r = it(r)), !ot(r))
540
+ function ae(r) {
541
+ if (typeof r == "string" && (r = at(r)), !nt(r))
542
542
  throw new Error(`expected Uint8Array, got ${typeof r}`);
543
543
  return r;
544
544
  }
545
- class ct {
545
+ class it {
546
546
  // Safe version that clones internal state
547
547
  clone() {
548
548
  return this._cloneInto();
549
549
  }
550
550
  }
551
- function lt(r) {
552
- const e = (n) => r().update(ie(n)).digest(), t = r();
551
+ function ct(r) {
552
+ const e = (n) => r().update(ae(n)).digest(), t = r();
553
553
  return e.outputLen = t.outputLen, e.blockLen = t.blockLen, e.create = () => r(), e;
554
554
  }
555
555
  const B = /* @__PURE__ */ BigInt(2 ** 32 - 1), V = /* @__PURE__ */ BigInt(32);
556
- function dt(r, e = !1) {
556
+ function lt(r, e = !1) {
557
557
  return e ? { h: Number(r & B), l: Number(r >> V & B) } : { h: Number(r >> V & B) | 0, l: Number(r & B) | 0 };
558
558
  }
559
- function ht(r, e = !1) {
559
+ function dt(r, e = !1) {
560
560
  let t = new Uint32Array(r.length), n = new Uint32Array(r.length);
561
- for (let o = 0; o < r.length; o++) {
562
- const { h: s, l: a } = dt(r[o], e);
563
- [t[o], n[o]] = [s, a];
561
+ for (let s = 0; s < r.length; s++) {
562
+ const { h: o, l: a } = lt(r[s], e);
563
+ [t[s], n[s]] = [o, a];
564
564
  }
565
565
  return [t, n];
566
566
  }
567
- const ft = (r, e, t) => r << t | e >>> 32 - t, ut = (r, e, t) => e << t | r >>> 32 - t, pt = (r, e, t) => e << t - 32 | r >>> 64 - t, mt = (r, e, t) => r << t - 32 | e >>> 64 - t, [ce, le, de] = [[], [], []], gt = /* @__PURE__ */ BigInt(0), S = /* @__PURE__ */ BigInt(1), yt = /* @__PURE__ */ BigInt(2), bt = /* @__PURE__ */ BigInt(7), wt = /* @__PURE__ */ BigInt(256), _t = /* @__PURE__ */ BigInt(113);
568
- for (let r = 0, e = S, t = 1, n = 0; r < 24; r++) {
569
- [t, n] = [n, (2 * t + 3 * n) % 5], ce.push(2 * (5 * n + t)), le.push((r + 1) * (r + 2) / 2 % 64);
570
- let o = gt;
571
- for (let s = 0; s < 7; s++)
572
- e = (e << S ^ (e >> bt) * _t) % wt, e & yt && (o ^= S << (S << /* @__PURE__ */ BigInt(s)) - S);
573
- de.push(o);
567
+ const ht = (r, e, t) => r << t | e >>> 32 - t, ut = (r, e, t) => e << t | r >>> 32 - t, ft = (r, e, t) => e << t - 32 | r >>> 64 - t, pt = (r, e, t) => r << t - 32 | e >>> 64 - t, [ie, ce, le] = [[], [], []], mt = /* @__PURE__ */ BigInt(0), P = /* @__PURE__ */ BigInt(1), gt = /* @__PURE__ */ BigInt(2), yt = /* @__PURE__ */ BigInt(7), bt = /* @__PURE__ */ BigInt(256), wt = /* @__PURE__ */ BigInt(113);
568
+ for (let r = 0, e = P, t = 1, n = 0; r < 24; r++) {
569
+ [t, n] = [n, (2 * t + 3 * n) % 5], ie.push(2 * (5 * n + t)), ce.push((r + 1) * (r + 2) / 2 % 64);
570
+ let s = mt;
571
+ for (let o = 0; o < 7; o++)
572
+ e = (e << P ^ (e >> yt) * wt) % bt, e & gt && (s ^= P << (P << /* @__PURE__ */ BigInt(o)) - P);
573
+ le.push(s);
574
574
  }
575
- const [kt, At] = /* @__PURE__ */ ht(de, !0), J = (r, e, t) => t > 32 ? pt(r, e, t) : ft(r, e, t), Z = (r, e, t) => t > 32 ? mt(r, e, t) : ut(r, e, t);
576
- function It(r, e = 24) {
575
+ const [_t, kt] = /* @__PURE__ */ dt(le, !0), J = (r, e, t) => t > 32 ? ft(r, e, t) : ht(r, e, t), Z = (r, e, t) => t > 32 ? pt(r, e, t) : ut(r, e, t);
576
+ function At(r, e = 24) {
577
577
  const t = new Uint32Array(10);
578
578
  for (let n = 24 - e; n < 24; n++) {
579
579
  for (let a = 0; a < 10; a++)
580
580
  t[a] = r[a] ^ r[a + 10] ^ r[a + 20] ^ r[a + 30] ^ r[a + 40];
581
581
  for (let a = 0; a < 10; a += 2) {
582
- const i = (a + 8) % 10, c = (a + 2) % 10, d = t[c], l = t[c + 1], h = J(d, l, 1) ^ t[i], p = Z(d, l, 1) ^ t[i + 1];
583
- for (let f = 0; f < 50; f += 10)
584
- r[a + f] ^= h, r[a + f + 1] ^= p;
582
+ const i = (a + 8) % 10, c = (a + 2) % 10, l = t[c], d = t[c + 1], h = J(l, d, 1) ^ t[i], g = Z(l, d, 1) ^ t[i + 1];
583
+ for (let u = 0; u < 50; u += 10)
584
+ r[a + u] ^= h, r[a + u + 1] ^= g;
585
585
  }
586
- let o = r[2], s = r[3];
586
+ let s = r[2], o = r[3];
587
587
  for (let a = 0; a < 24; a++) {
588
- const i = le[a], c = J(o, s, i), d = Z(o, s, i), l = ce[a];
589
- o = r[l], s = r[l + 1], r[l] = c, r[l + 1] = d;
588
+ const i = ce[a], c = J(s, o, i), l = Z(s, o, i), d = ie[a];
589
+ s = r[d], o = r[d + 1], r[d] = c, r[d + 1] = l;
590
590
  }
591
591
  for (let a = 0; a < 50; a += 10) {
592
592
  for (let i = 0; i < 10; i++)
@@ -594,29 +594,29 @@ function It(r, e = 24) {
594
594
  for (let i = 0; i < 10; i++)
595
595
  r[a + i] ^= ~t[(i + 2) % 10] & t[(i + 4) % 10];
596
596
  }
597
- r[0] ^= kt[n], r[1] ^= At[n];
597
+ r[0] ^= _t[n], r[1] ^= kt[n];
598
598
  }
599
599
  t.fill(0);
600
600
  }
601
- class L extends ct {
601
+ class L extends it {
602
602
  // NOTE: we accept arguments in bytes instead of bits here.
603
- constructor(e, t, n, o = !1, s = 24) {
604
- if (super(), this.blockLen = e, this.suffix = t, this.outputLen = n, this.enableXOF = o, this.rounds = s, this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, X(n), 0 >= this.blockLen || this.blockLen >= 200)
603
+ constructor(e, t, n, s = !1, o = 24) {
604
+ if (super(), this.blockLen = e, this.suffix = t, this.outputLen = n, this.enableXOF = s, this.rounds = o, this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, X(n), 0 >= this.blockLen || this.blockLen >= 200)
605
605
  throw new Error("Sha3 supports only keccak-f1600 function");
606
606
  this.state = new Uint8Array(200), this.state32 = st(this.state);
607
607
  }
608
608
  keccak() {
609
- It(this.state32, this.rounds), this.posOut = 0, this.pos = 0;
609
+ At(this.state32, this.rounds), this.posOut = 0, this.pos = 0;
610
610
  }
611
611
  update(e) {
612
612
  G(this);
613
613
  const { blockLen: t, state: n } = this;
614
- e = ie(e);
615
- const o = e.length;
616
- for (let s = 0; s < o; ) {
617
- const a = Math.min(t - this.pos, o - s);
614
+ e = ae(e);
615
+ const s = e.length;
616
+ for (let o = 0; o < s; ) {
617
+ const a = Math.min(t - this.pos, s - o);
618
618
  for (let i = 0; i < a; i++)
619
- n[this.pos++] ^= e[s++];
619
+ n[this.pos++] ^= e[o++];
620
620
  this.pos === t && this.keccak();
621
621
  }
622
622
  return this;
@@ -625,16 +625,16 @@ class L extends ct {
625
625
  if (this.finished)
626
626
  return;
627
627
  this.finished = !0;
628
- const { state: e, suffix: t, pos: n, blockLen: o } = this;
629
- e[n] ^= t, (t & 128) !== 0 && n === o - 1 && this.keccak(), e[o - 1] ^= 128, this.keccak();
628
+ const { state: e, suffix: t, pos: n, blockLen: s } = this;
629
+ e[n] ^= t, (t & 128) !== 0 && n === s - 1 && this.keccak(), e[s - 1] ^= 128, this.keccak();
630
630
  }
631
631
  writeInto(e) {
632
- G(this, !1), ae(e), this.finish();
632
+ G(this, !1), oe(e), this.finish();
633
633
  const t = this.state, { blockLen: n } = this;
634
- for (let o = 0, s = e.length; o < s; ) {
634
+ for (let s = 0, o = e.length; s < o; ) {
635
635
  this.posOut >= n && this.keccak();
636
- const a = Math.min(n - this.posOut, s - o);
637
- e.set(t.subarray(this.posOut, this.posOut + a), o), this.posOut += a, o += a;
636
+ const a = Math.min(n - this.posOut, o - s);
637
+ e.set(t.subarray(this.posOut, this.posOut + a), s), this.posOut += a, s += a;
638
638
  }
639
639
  return e;
640
640
  }
@@ -647,7 +647,7 @@ class L extends ct {
647
647
  return X(e), this.xofInto(new Uint8Array(e));
648
648
  }
649
649
  digestInto(e) {
650
- if (nt(e, this), this.finished)
650
+ if (rt(e, this), this.finished)
651
651
  throw new Error("digest() was already called");
652
652
  return this.writeInto(e), this.destroy(), e;
653
653
  }
@@ -658,39 +658,39 @@ class L extends ct {
658
658
  this.destroyed = !0, this.state.fill(0);
659
659
  }
660
660
  _cloneInto(e) {
661
- const { blockLen: t, suffix: n, outputLen: o, rounds: s, enableXOF: a } = this;
662
- return e || (e = new L(t, 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;
661
+ const { blockLen: t, suffix: n, outputLen: s, rounds: o, enableXOF: a } = this;
662
+ return e || (e = new L(t, 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;
663
663
  }
664
664
  }
665
- const vt = (r, e, t) => lt(() => new L(e, r, t)), Et = /* @__PURE__ */ vt(1, 136, 256 / 8);
666
- let he = !1;
667
- const fe = function(r) {
668
- return Et(r);
665
+ const It = (r, e, t) => ct(() => new L(e, r, t)), vt = /* @__PURE__ */ It(1, 136, 256 / 8);
666
+ let de = !1;
667
+ const he = function(r) {
668
+ return vt(r);
669
669
  };
670
- let ue = fe;
670
+ let ue = he;
671
671
  function M(r) {
672
672
  const e = O(r, "data");
673
- return rt(ue(e));
673
+ return tt(ue(e));
674
674
  }
675
- M._ = fe;
675
+ M._ = he;
676
676
  M.lock = function() {
677
- he = !0;
677
+ de = !0;
678
678
  };
679
679
  M.register = function(r) {
680
- if (he)
680
+ if (de)
681
681
  throw new TypeError("keccak256 is locked");
682
682
  ue = r;
683
683
  };
684
684
  Object.freeze(M);
685
- const xt = BigInt(0), Ct = BigInt(36);
685
+ const Et = BigInt(0), xt = BigInt(36);
686
686
  function ee(r) {
687
687
  r = r.toLowerCase();
688
688
  const e = r.substring(2).split(""), t = new Uint8Array(40);
689
- for (let o = 0; o < 40; o++)
690
- t[o] = e[o].charCodeAt(0);
689
+ for (let s = 0; s < 40; s++)
690
+ t[s] = e[s].charCodeAt(0);
691
691
  const n = O(M(t));
692
- for (let o = 0; o < 40; o += 2)
693
- n[o >> 1] >> 4 >= 8 && (e[o] = e[o].toUpperCase()), (n[o >> 1] & 15) >= 8 && (e[o + 1] = e[o + 1].toUpperCase());
692
+ for (let s = 0; s < 40; s += 2)
693
+ n[s >> 1] >> 4 >= 8 && (e[s] = e[s].toUpperCase()), (n[s >> 1] & 15) >= 8 && (e[s + 1] = e[s + 1].toUpperCase());
694
694
  return "0x" + e.join("");
695
695
  }
696
696
  const Y = {};
@@ -699,7 +699,7 @@ for (let r = 0; r < 10; r++)
699
699
  for (let r = 0; r < 26; r++)
700
700
  Y[String.fromCharCode(65 + r)] = String(10 + r);
701
701
  const te = 15;
702
- function Pt(r) {
702
+ function Ct(r) {
703
703
  r = r.toUpperCase(), r = r.substring(4) + r.substring(0, 2) + "00";
704
704
  let e = r.split("").map((n) => Y[n]).join("");
705
705
  for (; e.length >= te; ) {
@@ -721,27 +721,27 @@ const Rt = function() {
721
721
  }();
722
722
  function St(r) {
723
723
  r = r.toLowerCase();
724
- let e = xt;
724
+ let e = Et;
725
725
  for (let t = 0; t < r.length; t++)
726
- e = e * Ct + Rt[r[t]];
726
+ e = e * xt + Rt[r[t]];
727
727
  return e;
728
728
  }
729
729
  function m(r) {
730
- if (N(typeof r == "string", "invalid address", "address", r), r.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
730
+ if (D(typeof r == "string", "invalid address", "address", r), r.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
731
731
  r.startsWith("0x") || (r = "0x" + r);
732
732
  const e = ee(r);
733
- return N(!r.match(/([A-F].*[a-f])|([a-f].*[A-F])/) || e === r, "bad address checksum", "address", r), e;
733
+ return D(!r.match(/([A-F].*[a-f])|([a-f].*[A-F])/) || e === r, "bad address checksum", "address", r), e;
734
734
  }
735
735
  if (r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
736
- N(r.substring(2, 4) === Pt(r), "bad icap checksum", "address", r);
736
+ D(r.substring(2, 4) === Ct(r), "bad icap checksum", "address", r);
737
737
  let e = St(r.substring(4)).toString(16);
738
738
  for (; e.length < 40; )
739
739
  e = "0" + e;
740
740
  return ee("0x" + e);
741
741
  }
742
- N(!1, "invalid address", "address", r);
742
+ D(!1, "invalid address", "address", r);
743
743
  }
744
- class Nt {
744
+ class Pt {
745
745
  type = "argent";
746
746
  platform = "starknet";
747
747
  wallet = void 0;
@@ -767,8 +767,8 @@ class Nt {
767
767
  try {
768
768
  if (!this.isAvailable())
769
769
  throw new Error("Argent is not available");
770
- const { wallet: e, connectorData: t } = await xe({
771
- connectors: [new Ce({ options: { id: "argentX" } })]
770
+ const { wallet: e, connectorData: t } = await ve({
771
+ connectors: [new Ee({ options: { id: "argentX" } })]
772
772
  });
773
773
  if (!e)
774
774
  throw new Error("No wallet found");
@@ -837,11 +837,11 @@ function Dt(r) {
837
837
  const e = (t) => r(t.detail);
838
838
  return window.addEventListener("eip6963:announceProvider", e), window.dispatchEvent(new CustomEvent("eip6963:requestProvider")), () => window.removeEventListener("eip6963:announceProvider", e);
839
839
  }
840
- function pe() {
840
+ function fe() {
841
841
  const r = /* @__PURE__ */ new Set();
842
842
  let e = [];
843
- const t = () => Dt((o) => {
844
- e.some(({ info: s }) => s.uuid === o.info.uuid) || (e = [...e, o], r.forEach((s) => s(e, { added: [o] })));
843
+ const t = () => Dt((s) => {
844
+ e.some(({ info: o }) => o.uuid === s.info.uuid) || (e = [...e, s], r.forEach((o) => o(e, { added: [s] })));
845
845
  });
846
846
  let n = t();
847
847
  return {
@@ -849,13 +849,13 @@ function pe() {
849
849
  return r;
850
850
  },
851
851
  clear() {
852
- r.forEach((o) => o([], { removed: [...e] })), e = [];
852
+ r.forEach((s) => s([], { removed: [...e] })), e = [];
853
853
  },
854
854
  destroy() {
855
855
  this.clear(), r.clear(), n?.();
856
856
  },
857
- findProvider({ rdns: o }) {
858
- return e.find((s) => s.info.rdns === o);
857
+ findProvider({ rdns: s }) {
858
+ return e.find((o) => o.info.rdns === s);
859
859
  },
860
860
  getProviders() {
861
861
  return e;
@@ -863,20 +863,20 @@ function pe() {
863
863
  reset() {
864
864
  this.clear(), n?.(), n = t();
865
865
  },
866
- subscribe(o, { emitImmediately: s } = {}) {
867
- return r.add(o), s && o(e, { added: e }), () => r.delete(o);
866
+ subscribe(s, { emitImmediately: o } = {}) {
867
+ return r.add(s), o && s(e, { added: e }), () => r.delete(s);
868
868
  }
869
869
  };
870
870
  }
871
- class Mt {
871
+ class Nt {
872
872
  type = "metamask";
873
873
  platform = "ethereum";
874
874
  MMSDK;
875
- store = pe();
875
+ store = fe();
876
876
  account = void 0;
877
877
  connectedAccounts = [];
878
878
  constructor() {
879
- this.MMSDK = new Pe({
879
+ this.MMSDK = new xe({
880
880
  dappMetadata: {
881
881
  name: "Cartridge Controller",
882
882
  url: window.location.href
@@ -1041,7 +1041,7 @@ class Mt {
1041
1041
  }
1042
1042
  }
1043
1043
  }
1044
- class Bt {
1044
+ class Mt {
1045
1045
  type = "phantom";
1046
1046
  platform = "solana";
1047
1047
  account = void 0;
@@ -1109,11 +1109,11 @@ class Bt {
1109
1109
  if (!this.isAvailable() || !this.account)
1110
1110
  throw new Error("Phantom is not connected");
1111
1111
  try {
1112
- const t = Re.from(e), o = await this.getProvider().signAndSendTransaction(t);
1112
+ const t = Ce.from(e), s = await this.getProvider().signAndSendTransaction(t);
1113
1113
  return {
1114
1114
  success: !0,
1115
1115
  wallet: this.type,
1116
- result: o
1116
+ result: s
1117
1117
  };
1118
1118
  } catch (t) {
1119
1119
  return console.error("Error sending transaction with Phantom:", t), {
@@ -1144,16 +1144,16 @@ class Bt {
1144
1144
  }
1145
1145
  }
1146
1146
  }
1147
- const Ut = "io.rabby";
1148
- class Qt {
1147
+ const Bt = "io.rabby";
1148
+ class Tt {
1149
1149
  type = "rabby";
1150
1150
  platform = "ethereum";
1151
1151
  account = void 0;
1152
- store = pe();
1152
+ store = fe();
1153
1153
  provider;
1154
1154
  connectedAccounts = [];
1155
1155
  constructor() {
1156
- this.provider = this.store.getProviders().find((e) => e.info.rdns === Ut), this.provider?.provider.request({
1156
+ this.provider = this.store.getProviders().find((e) => e.info.rdns === Bt), this.provider?.provider.request({
1157
1157
  method: "eth_accounts"
1158
1158
  }).then((e) => {
1159
1159
  this.connectedAccounts = e.map(m), e.length > 0 && (this.account = m(e?.[0]));
@@ -1311,19 +1311,19 @@ class Qt {
1311
1311
  }
1312
1312
  }
1313
1313
  }
1314
- class Tt {
1314
+ class Qt {
1315
1315
  walletAdapters;
1316
1316
  constructor() {
1317
1317
  if (this.walletAdapters = /* @__PURE__ */ new Map(), typeof window > "u")
1318
1318
  return;
1319
- const e = new Mt();
1319
+ const e = new Nt();
1320
1320
  e.isAvailable() && this.walletAdapters.set("metamask", e);
1321
- const t = new Bt();
1321
+ const t = new Mt();
1322
1322
  t.isAvailable() && this.walletAdapters.set("phantom", t);
1323
- const n = new Nt();
1323
+ const n = new Pt();
1324
1324
  n.isAvailable() && this.walletAdapters.set("argent", n);
1325
- const o = new Qt();
1326
- o.isAvailable() && this.walletAdapters.set("rabby", o), window.wallet_bridge = this;
1325
+ const s = new Tt();
1326
+ s.isAvailable() && this.walletAdapters.set("rabby", s), window.wallet_bridge = this;
1327
1327
  }
1328
1328
  getIFrameMethods() {
1329
1329
  return {
@@ -1346,18 +1346,18 @@ class Tt {
1346
1346
  throw new Error(`Unsupported wallet type: ${e}`);
1347
1347
  return t;
1348
1348
  }
1349
- handleError(e, t, n, o) {
1350
- const s = t instanceof Error ? t.message : "Unknown error";
1349
+ handleError(e, t, n, s) {
1350
+ const o = t instanceof Error ? t.message : "Unknown error";
1351
1351
  let a = "unknown";
1352
1352
  if (typeof e == "string") {
1353
1353
  const i = this.getConnectedWalletAdapter(e);
1354
- a = o ?? i?.type ?? e;
1354
+ a = s ?? i?.type ?? e;
1355
1355
  } else
1356
1356
  a = e;
1357
1357
  return console.error(`Error ${n} with ${e} wallet:`, t), {
1358
1358
  success: !1,
1359
1359
  wallet: a,
1360
- error: s
1360
+ error: o
1361
1361
  };
1362
1362
  }
1363
1363
  async connectWallet(e) {
@@ -1384,7 +1384,7 @@ class Tt {
1384
1384
  let t;
1385
1385
  if (typeof e == "string") {
1386
1386
  const n = m(e);
1387
- t = this.walletAdapters.values().find((o) => o.getConnectedAccounts().includes(n));
1387
+ t = this.walletAdapters.values().find((s) => s.getConnectedAccounts().includes(n));
1388
1388
  } else
1389
1389
  t = this.walletAdapters.get(e);
1390
1390
  if (!t)
@@ -1401,10 +1401,10 @@ class Tt {
1401
1401
  `Wallet type ${n.type} (identifier: ${e}) does not support signing messages`
1402
1402
  );
1403
1403
  return await n.signMessage(t, e);
1404
- } catch (o) {
1404
+ } catch (s) {
1405
1405
  return this.handleError(
1406
1406
  e,
1407
- o,
1407
+ s,
1408
1408
  "signing message with",
1409
1409
  n?.type
1410
1410
  );
@@ -1418,10 +1418,10 @@ class Tt {
1418
1418
  `Wallet type ${n.type} (identifier: ${e}) does not support signing typed data`
1419
1419
  );
1420
1420
  return await n.signTypedData(t);
1421
- } catch (o) {
1421
+ } catch (s) {
1422
1422
  return this.handleError(
1423
1423
  e,
1424
- o,
1424
+ s,
1425
1425
  "signing typed data with",
1426
1426
  n?.type
1427
1427
  );
@@ -1431,10 +1431,10 @@ class Tt {
1431
1431
  let n;
1432
1432
  try {
1433
1433
  return n = this.getConnectedWalletAdapter(e), await n.sendTransaction(t);
1434
- } catch (o) {
1434
+ } catch (s) {
1435
1435
  return this.handleError(
1436
1436
  e,
1437
- o,
1437
+ s,
1438
1438
  "sending transaction with",
1439
1439
  n?.type
1440
1440
  );
@@ -1444,67 +1444,47 @@ class Tt {
1444
1444
  let n;
1445
1445
  try {
1446
1446
  return n = this.getConnectedWalletAdapter(e), await n.getBalance(t);
1447
- } catch (o) {
1447
+ } catch (s) {
1448
1448
  return this.handleError(
1449
1449
  e,
1450
- o,
1450
+ s,
1451
1451
  "getting balance from",
1452
1452
  n?.type
1453
1453
  );
1454
1454
  }
1455
1455
  }
1456
1456
  }
1457
- class $t extends se {
1457
+ class Ut extends Ge {
1458
1458
  walletBridge;
1459
1459
  constructor({
1460
1460
  url: e,
1461
1461
  policies: t,
1462
1462
  version: n,
1463
- ...o
1463
+ slot: s,
1464
+ namespace: o,
1465
+ tokens: a,
1466
+ ...i
1464
1467
  }) {
1465
- const s = new URL(e ?? _e), a = new Tt();
1466
- t && s.searchParams.set(
1468
+ const c = new URL(e ?? we), l = new Qt();
1469
+ t && c.searchParams.set(
1467
1470
  "policies",
1468
1471
  encodeURIComponent(JSON.stringify(t))
1469
- ), n && s.searchParams.set("v", encodeURIComponent(n)), super({
1470
- ...o,
1472
+ ), n && c.searchParams.set("v", encodeURIComponent(n)), s && c.searchParams.set("ps", encodeURIComponent(s)), o && c.searchParams.set("ns", encodeURIComponent(o)), a?.erc20 && c.searchParams.set(
1473
+ "erc20",
1474
+ encodeURIComponent(a.erc20.toString())
1475
+ ), super({
1476
+ ...i,
1471
1477
  id: "controller-keychain",
1472
- url: s,
1473
- methods: a.getIFrameMethods()
1474
- }), this.walletBridge = a, typeof window < "u" && (window.external_wallets = this.walletBridge);
1478
+ url: c,
1479
+ methods: l.getIFrameMethods()
1480
+ }), this.walletBridge = l, typeof window < "u" && (window.external_wallets = this.walletBridge);
1475
1481
  }
1476
1482
  getWalletBridge() {
1477
1483
  return this.walletBridge;
1478
1484
  }
1479
1485
  }
1480
- class zt extends se {
1481
- constructor({
1482
- profileUrl: e,
1483
- rpcUrl: t,
1484
- version: n,
1485
- username: o,
1486
- slot: s,
1487
- namespace: a,
1488
- tokens: i,
1489
- ...c
1490
- }) {
1491
- const d = (e || ke).replace(/\/$/, "");
1492
- let l = new URL(
1493
- s ? `${d}/account/${o}/slot/${s}` : `${d}/account/${o}`
1494
- );
1495
- s && l.searchParams.set("ps", encodeURIComponent(s)), a && l.searchParams.set("ns", encodeURIComponent(a)), n && l.searchParams.set("v", encodeURIComponent(n)), l.searchParams.set("rpcUrl", encodeURIComponent(t)), i?.erc20 && l.searchParams.set(
1496
- "erc20",
1497
- encodeURIComponent(i.erc20.toString())
1498
- ), super({
1499
- ...c,
1500
- id: "controller-profile",
1501
- url: l
1502
- });
1503
- }
1504
- }
1505
- class jt extends Ae {
1486
+ class Ht extends _e {
1506
1487
  keychain;
1507
- profile;
1508
1488
  options;
1509
1489
  iframes;
1510
1490
  selectedChain;
@@ -1517,27 +1497,29 @@ class jt extends Ae {
1517
1497
  const n = [...[
1518
1498
  { rpcUrl: "https://api.cartridge.gg/x/starknet/sepolia" },
1519
1499
  { rpcUrl: "https://api.cartridge.gg/x/starknet/mainnet" }
1520
- ], ...e.chains || []], o = e.defaultChainId || $.StarknetChainId.SN_MAIN;
1521
- this.selectedChain = o, this.chains = /* @__PURE__ */ new Map(), this.iframes = {
1522
- keychain: new $t({
1500
+ ], ...e.chains || []], s = e.defaultChainId || $.StarknetChainId.SN_MAIN;
1501
+ this.selectedChain = s, this.chains = /* @__PURE__ */ new Map(), this.iframes = {
1502
+ keychain: new Ut({
1523
1503
  ...e,
1524
1504
  onClose: this.keychain?.reset,
1525
- onConnect: (s) => {
1526
- this.keychain = s;
1505
+ onConnect: (o) => {
1506
+ this.keychain = o;
1527
1507
  },
1528
- version: Ie
1508
+ version: ke
1529
1509
  })
1530
- }, this.options = { ...e, chains: n, defaultChainId: o }, this.initializeChains(n), typeof window < "u" && (window.starknet_controller = this);
1510
+ }, this.options = { ...e, chains: n, defaultChainId: s }, this.initializeChains(n), typeof window < "u" && (window.starknet_controller = this);
1531
1511
  }
1532
1512
  async logout() {
1533
1513
  if (!this.keychain) {
1534
- console.error(new b().message);
1514
+ console.error(new p().message);
1535
1515
  return;
1536
1516
  }
1537
1517
  try {
1538
1518
  await this.disconnect(), document.querySelectorAll('iframe[id^="controller-"]').forEach((t) => {
1539
1519
  const n = t.parentElement;
1540
- n && (n.style.visibility = "hidden", n.style.opacity = "0");
1520
+ n && (n.style.opacity = "0", setTimeout(() => {
1521
+ n.style.display = "none";
1522
+ }, 200));
1541
1523
  }), document.body && (document.body.style.overflow = "auto"), window.location.reload();
1542
1524
  } catch (e) {
1543
1525
  throw console.error("Logout failed:", e), e;
@@ -1546,7 +1528,7 @@ class jt extends Ae {
1546
1528
  async probe() {
1547
1529
  try {
1548
1530
  if (await this.waitForKeychain(), !this.keychain) {
1549
- console.error(new b().message);
1531
+ console.error(new p().message);
1550
1532
  return;
1551
1533
  }
1552
1534
  const e = await this.keychain.probe(this.rpcUrl());
@@ -1563,31 +1545,13 @@ class jt extends Ae {
1563
1545
  console.error(e);
1564
1546
  return;
1565
1547
  }
1566
- if (!this.iframes.profile) {
1567
- const e = await this.keychain.username();
1568
- this.iframes.profile = new zt({
1569
- ...this.options,
1570
- onConnect: (t) => {
1571
- this.profile = t;
1572
- },
1573
- methods: {
1574
- openSettings: () => this.openSettings.bind(this),
1575
- openPurchaseCredits: () => this.openPurchaseCredits.bind(this),
1576
- openExecute: () => this.openExecute.bind(this),
1577
- logout: () => this.logout.bind(this)
1578
- },
1579
- rpcUrl: this.rpcUrl(),
1580
- username: e,
1581
- version: this.version
1582
- });
1583
- }
1584
1548
  return this.account;
1585
1549
  }
1586
1550
  async connect() {
1587
1551
  if (this.account)
1588
1552
  return this.account;
1589
1553
  if (!this.keychain || !this.iframes.keychain) {
1590
- console.error(new b().message);
1554
+ console.error(new p().message);
1591
1555
  return;
1592
1556
  }
1593
1557
  typeof document < "u" && document.hasStorageAccess && (await document.hasStorageAccess() || await document.requestStorageAccess()), this.iframes.keychain.open();
@@ -1601,7 +1565,7 @@ class jt extends Ae {
1601
1565
  this.rpcUrl(),
1602
1566
  this.options.signupOptions
1603
1567
  );
1604
- if (e.code !== v.SUCCESS)
1568
+ if (e.code !== R.SUCCESS)
1605
1569
  throw new Error(e.message);
1606
1570
  return e = e, this.account = new H(
1607
1571
  this,
@@ -1619,11 +1583,11 @@ class jt extends Ae {
1619
1583
  }
1620
1584
  async switchStarknetChain(e) {
1621
1585
  if (!this.keychain || !this.iframes.keychain)
1622
- return console.error(new b().message), !1;
1586
+ return console.error(new p().message), !1;
1623
1587
  try {
1624
1588
  if (this.selectedChain = e, (await this.keychain.probe(this.rpcUrl())).rpcUrl === this.rpcUrl())
1625
1589
  return !0;
1626
- await this.keychain.switchChain(this.rpcUrl()), await this.profile?.switchChain(this.rpcUrl());
1590
+ await this.keychain.switchChain(this.rpcUrl());
1627
1591
  } catch (t) {
1628
1592
  return console.error(t), !1;
1629
1593
  }
@@ -1634,53 +1598,55 @@ class jt extends Ae {
1634
1598
  }
1635
1599
  async disconnect() {
1636
1600
  if (!this.keychain) {
1637
- console.error(new b().message);
1601
+ console.error(new p().message);
1638
1602
  return;
1639
1603
  }
1640
1604
  return typeof document < "u" && document.hasStorageAccess && (await document.hasStorageAccess() || await document.requestStorageAccess()), this.account = void 0, this.keychain.disconnect();
1641
1605
  }
1642
1606
  async openProfile(e = "inventory") {
1643
- if (!this.profile || !this.iframes.profile?.url) {
1644
- console.error("Profile is not ready");
1607
+ if (!this.keychain || !this.iframes.keychain) {
1608
+ console.error(new p().message);
1645
1609
  return;
1646
1610
  }
1647
1611
  if (!this.account) {
1648
1612
  console.error("Account is not ready");
1649
1613
  return;
1650
1614
  }
1651
- this.profile.navigate(`${this.iframes.profile.url?.pathname}/${e}`), this.iframes.profile.open();
1615
+ const t = await this.keychain.username();
1616
+ await this.keychain.navigate(`/account/${t}/${e}`), this.iframes.keychain.open();
1652
1617
  }
1653
1618
  async openProfileTo(e) {
1654
- if (!this.profile || !this.iframes.profile?.url) {
1655
- console.error("Profile is not ready");
1619
+ if (!this.keychain || !this.iframes.keychain) {
1620
+ console.error(new p().message);
1656
1621
  return;
1657
1622
  }
1658
1623
  if (!this.account) {
1659
1624
  console.error("Account is not ready");
1660
1625
  return;
1661
1626
  }
1662
- this.profile.navigate(`${this.iframes.profile.url?.pathname}/${e}`), this.iframes.profile.open();
1627
+ const t = await this.keychain.username();
1628
+ await this.keychain.navigate(`/account/${t}/${e}`), this.iframes.keychain.open();
1663
1629
  }
1664
1630
  async openProfileAt(e) {
1665
- if (!this.profile || !this.iframes.profile?.url) {
1666
- console.error("Profile is not ready");
1631
+ if (!this.keychain || !this.iframes.keychain) {
1632
+ console.error(new p().message);
1667
1633
  return;
1668
1634
  }
1669
1635
  if (!this.account) {
1670
1636
  console.error("Account is not ready");
1671
1637
  return;
1672
1638
  }
1673
- this.profile.navigate(e), this.iframes.profile.open();
1639
+ await this.keychain.navigate(e), this.iframes.keychain.open();
1674
1640
  }
1675
- async openSettings() {
1676
- if (!this.keychain || !this.iframes.keychain)
1677
- return console.error(new b().message), null;
1678
- this.iframes.profile?.sendBackward ? this.iframes.profile?.sendBackward() : this.iframes.profile?.close(), this.iframes.keychain.open();
1679
- const e = await this.keychain.openSettings();
1680
- return this.iframes.keychain.close(), this.iframes.profile?.sendForward?.(), !(e && e.code === v.NOT_CONNECTED);
1641
+ openSettings() {
1642
+ if (!this.keychain || !this.iframes.keychain) {
1643
+ console.error(new p().message);
1644
+ return;
1645
+ }
1646
+ this.iframes.keychain.open(), this.keychain.openSettings();
1681
1647
  }
1682
1648
  revoke(e, t) {
1683
- return this.keychain ? this.keychain.revoke(e) : (console.error(new b().message), null);
1649
+ return this.keychain ? this.keychain.revoke(e) : (console.error(new p().message), null);
1684
1650
  }
1685
1651
  rpcUrl() {
1686
1652
  const e = this.chains.get(this.selectedChain);
@@ -1696,62 +1662,52 @@ class jt extends Ae {
1696
1662
  }
1697
1663
  username() {
1698
1664
  if (!this.keychain) {
1699
- console.error(new b().message);
1665
+ console.error(new p().message);
1700
1666
  return;
1701
1667
  }
1702
1668
  return this.keychain.username();
1703
1669
  }
1704
1670
  openPurchaseCredits() {
1705
1671
  if (!this.keychain || !this.iframes.keychain) {
1706
- console.error(new b().message);
1707
- return;
1708
- }
1709
- if (!this.iframes.profile) {
1710
- console.error("Profile is not ready");
1672
+ console.error(new p().message);
1711
1673
  return;
1712
1674
  }
1713
- this.iframes.profile.close(), this.iframes.keychain.open(), this.keychain.openPurchaseCredits();
1675
+ this.iframes.keychain.open(), this.keychain.openPurchaseCredits();
1714
1676
  }
1715
1677
  openStarterPack(e) {
1716
1678
  if (!this.keychain || !this.iframes.keychain) {
1717
- console.error(new b().message);
1679
+ console.error(new p().message);
1718
1680
  return;
1719
1681
  }
1720
- if (!this.iframes.profile) {
1721
- console.error("Profile is not ready");
1722
- return;
1723
- }
1724
- this.iframes.profile.close(), this.iframes.keychain.open(), this.keychain.openStarterPack(e);
1682
+ this.keychain.navigate(`/starter-pack/${e}`).then(() => {
1683
+ this.iframes.keychain.open();
1684
+ });
1725
1685
  }
1726
1686
  async openExecute(e, t) {
1727
1687
  if (!this.keychain || !this.iframes.keychain) {
1728
- console.error(new b().message);
1729
- return;
1730
- }
1731
- if (!this.iframes.profile) {
1732
- console.error("Profile is not ready");
1688
+ console.error(new p().message);
1733
1689
  return;
1734
1690
  }
1735
1691
  let n = this.selectedChain;
1736
- t && this.switchStarknetChain(t), this.iframes.profile?.sendBackward(), this.iframes.keychain.open(), this.iframes.profile?.close();
1737
- const o = await this.keychain.execute(e, void 0, void 0, !0);
1738
- return this.iframes.profile?.open(), this.iframes.keychain.close(), this.iframes.profile?.sendForward(), t && this.switchStarknetChain(n), {
1739
- status: !(o && (o.code === v.NOT_CONNECTED || o.code === v.CANCELED)),
1740
- transactionHash: o?.transaction_hash
1692
+ t && this.switchStarknetChain(t), this.iframes.keychain.open();
1693
+ const s = await this.keychain.execute(e, void 0, void 0, !0);
1694
+ return this.iframes.keychain.close(), t && this.switchStarknetChain(n), {
1695
+ status: !(s && (s.code === R.NOT_CONNECTED || s.code === R.CANCELED)),
1696
+ transactionHash: s?.transaction_hash
1741
1697
  };
1742
1698
  }
1743
1699
  async delegateAccount() {
1744
- return this.keychain ? await this.keychain.delegateAccount() : (console.error(new b().message), null);
1700
+ return this.keychain ? await this.keychain.delegateAccount() : (console.error(new p().message), null);
1745
1701
  }
1746
1702
  initializeChains(e) {
1747
1703
  for (const t of e)
1748
1704
  try {
1749
- const n = new URL(t.rpcUrl), o = ve(n), s = o === $.StarknetChainId.SN_MAIN, a = o === $.StarknetChainId.SN_SEPOLIA, i = n.hostname === "api.cartridge.gg", c = n.hostname === "localhost" || n.hostname === "127.0.0.1";
1750
- if ((s || a) && !(i || c))
1705
+ const n = new URL(t.rpcUrl), s = Ae(n), o = s === $.StarknetChainId.SN_MAIN, a = s === $.StarknetChainId.SN_SEPOLIA, i = n.hostname === "api.cartridge.gg", c = n.hostname === "localhost" || n.hostname === "127.0.0.1";
1706
+ if ((o || a) && !(i || c))
1751
1707
  throw new Error(
1752
- `Only Cartridge RPC providers are allowed for ${s ? "mainnet" : "sepolia"}. Please use: https://api.cartridge.gg/x/starknet/${s ? "mainnet" : "sepolia"}`
1708
+ `Only Cartridge RPC providers are allowed for ${o ? "mainnet" : "sepolia"}. Please use: https://api.cartridge.gg/x/starknet/${o ? "mainnet" : "sepolia"}`
1753
1709
  );
1754
- this.chains.set(o, t);
1710
+ this.chains.set(s, t);
1755
1711
  } catch (n) {
1756
1712
  throw console.error(`Failed to parse chainId for ${t.rpcUrl}:`, n), n;
1757
1713
  }
@@ -1763,10 +1719,10 @@ class jt extends Ae {
1763
1719
  timeout: e = 5e4,
1764
1720
  interval: t = 100
1765
1721
  } = {}) {
1766
- return new Promise((n, o) => {
1767
- const s = Date.now(), a = setInterval(() => {
1768
- if (Date.now() - s > e) {
1769
- clearInterval(a), o(new Error("Timeout waiting for keychain"));
1722
+ return new Promise((n, s) => {
1723
+ const o = Date.now(), a = setInterval(() => {
1724
+ if (Date.now() - o > e) {
1725
+ clearInterval(a), s(new Error("Timeout waiting for keychain"));
1770
1726
  return;
1771
1727
  }
1772
1728
  this.keychain && (clearInterval(a), n());
@@ -1774,11 +1730,11 @@ class jt extends Ae {
1774
1730
  });
1775
1731
  }
1776
1732
  }
1777
- const R = /* @__PURE__ */ new Map();
1778
- async function me(r) {
1733
+ const S = /* @__PURE__ */ new Map();
1734
+ async function pe(r) {
1779
1735
  if (!r.addresses?.length && !r.usernames?.length)
1780
1736
  return { results: [] };
1781
- const e = await fetch(`${Ee}/lookup`, {
1737
+ const e = await fetch(`${Ie}/lookup`, {
1782
1738
  method: "POST",
1783
1739
  headers: {
1784
1740
  "Content-Type": "application/json"
@@ -1789,26 +1745,26 @@ async function me(r) {
1789
1745
  throw new Error(`HTTP error! status: ${e.status}`);
1790
1746
  return e.json();
1791
1747
  }
1792
- async function qt(r) {
1793
- const e = r.filter((t) => !R.has(t));
1794
- return e.length > 0 && (await me({ usernames: e })).results.forEach((n) => {
1795
- R.set(n.username, n.addresses[0]);
1748
+ async function Kt(r) {
1749
+ const e = r.filter((t) => !S.has(t));
1750
+ return e.length > 0 && (await pe({ usernames: e })).results.forEach((n) => {
1751
+ S.set(n.username, n.addresses[0]);
1796
1752
  }), new Map(
1797
- r.map((t) => [t, R.get(t)]).filter((t) => t[1] !== void 0)
1753
+ r.map((t) => [t, S.get(t)]).filter((t) => t[1] !== void 0)
1798
1754
  );
1799
1755
  }
1800
- async function Xt(r) {
1801
- r = r.map(be.toHex);
1802
- const e = r.filter((t) => !R.has(t));
1803
- return e.length > 0 && (await me({
1756
+ async function jt(r) {
1757
+ r = r.map(ye.toHex);
1758
+ const e = r.filter((t) => !S.has(t));
1759
+ return e.length > 0 && (await pe({
1804
1760
  addresses: e
1805
1761
  })).results.forEach((n) => {
1806
- R.set(n.addresses[0], n.username);
1762
+ S.set(n.addresses[0], n.username);
1807
1763
  }), new Map(
1808
- r.map((t) => [t, R.get(t)]).filter((t) => t[1] !== void 0)
1764
+ r.map((t) => [t, S.get(t)]).filter((t) => t[1] !== void 0)
1809
1765
  );
1810
1766
  }
1811
- var Ot = [
1767
+ var $t = [
1812
1768
  {
1813
1769
  name: "Wrapped BTC",
1814
1770
  symbol: "WBTC",
@@ -2372,98 +2328,98 @@ var Ot = [
2372
2328
  total_supply: null,
2373
2329
  logo_url: "https://assets.underware.gg/pistols/fame.svg"
2374
2330
  }
2375
- ], ge = {
2331
+ ], me = {
2376
2332
  theme: {
2377
2333
  name: "Cartridge",
2378
2334
  icon: "icon.svg"
2379
2335
  }
2380
- }, U = "https://static.cartridge.gg/presets";
2336
+ }, T = "https://static.cartridge.gg/presets";
2381
2337
  async function F() {
2382
2338
  try {
2383
- const r = await fetch(`${U}/index.json`);
2339
+ const r = await fetch(`${T}/index.json`);
2384
2340
  if (!r.ok)
2385
2341
  throw new Error(`Failed to load configs index: ${r.statusText}`);
2386
2342
  return await r.json();
2387
2343
  } catch (r) {
2388
- return console.error("Error loading configs index:", r), { configs: [], baseUrl: U };
2344
+ return console.error("Error loading configs index:", r), { configs: [], baseUrl: T };
2389
2345
  }
2390
2346
  }
2391
- async function Gt() {
2347
+ async function qt() {
2392
2348
  return (await F()).configs;
2393
2349
  }
2394
- async function Vt(r) {
2350
+ async function Xt(r) {
2395
2351
  try {
2396
- const n = `${(await F()).baseUrl || U}/${r}`, o = await fetch(`${n}/config.json`);
2397
- if (!o.ok)
2352
+ const n = `${(await F()).baseUrl || T}/${r}`, s = await fetch(`${n}/config.json`);
2353
+ if (!s.ok)
2398
2354
  throw new Error(
2399
- `Failed to load config ${r}: ${o.statusText}`
2355
+ `Failed to load config ${r}: ${s.statusText}`
2400
2356
  );
2401
- const s = await o.json();
2402
- if (s && s.theme) {
2403
- 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}`)));
2357
+ const o = await s.json();
2358
+ if (o && o.theme) {
2359
+ 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}`)));
2404
2360
  const a = (i) => {
2405
2361
  if (i) {
2406
2362
  for (const c in i)
2407
2363
  if (i[c])
2408
- for (const d in i[c])
2409
- i[c][d] && !i[c][d].startsWith("http") && (i[c][d] = `${n}/${i[c][d]}`);
2364
+ for (const l in i[c])
2365
+ i[c][l] && !i[c][l].startsWith("http") && (i[c][l] = `${n}/${i[c][l]}`);
2410
2366
  }
2411
2367
  };
2412
- if (s.theme.optimizedIcon && a(s.theme.optimizedIcon), s.theme.optimizedCover)
2413
- if (typeof s.theme.optimizedCover == "string")
2414
- s.theme.optimizedCover.startsWith("http") || (s.theme.optimizedCover = `${n}/${s.theme.optimizedCover}`);
2415
- else if (s.theme.optimizedCover.light || s.theme.optimizedCover.dark) {
2416
- const i = s.theme.optimizedCover;
2368
+ if (o.theme.optimizedIcon && a(o.theme.optimizedIcon), o.theme.optimizedCover)
2369
+ if (typeof o.theme.optimizedCover == "string")
2370
+ o.theme.optimizedCover.startsWith("http") || (o.theme.optimizedCover = `${n}/${o.theme.optimizedCover}`);
2371
+ else if (o.theme.optimizedCover.light || o.theme.optimizedCover.dark) {
2372
+ const i = o.theme.optimizedCover;
2417
2373
  i.light && a(i.light), i.dark && a(i.dark);
2418
2374
  } else
2419
- a(s.theme.optimizedCover);
2375
+ a(o.theme.optimizedCover);
2420
2376
  }
2421
- return s;
2377
+ return o;
2422
2378
  } catch (e) {
2423
2379
  return console.error(`Error loading config ${r}:`, e), null;
2424
2380
  }
2425
2381
  }
2426
- async function Jt() {
2427
- const r = await F(), e = r.configs, t = r.baseUrl || U, n = {};
2382
+ async function Gt() {
2383
+ const r = await F(), e = r.configs, t = r.baseUrl || T, n = {};
2428
2384
  return await Promise.all(
2429
- e.map(async (o) => {
2385
+ e.map(async (s) => {
2430
2386
  try {
2431
- const s = await fetch(`${t}/${o}/config.json`);
2432
- if (s.ok) {
2433
- const a = await s.json();
2434
- n[o] = a;
2387
+ const o = await fetch(`${t}/${s}/config.json`);
2388
+ if (o.ok) {
2389
+ const a = await o.json();
2390
+ n[s] = a;
2435
2391
  }
2436
- } catch (s) {
2437
- console.error(`Error loading config ${o}:`, s);
2392
+ } catch (o) {
2393
+ console.error(`Error loading config ${s}:`, o);
2438
2394
  }
2439
2395
  })
2440
2396
  ), n;
2441
2397
  }
2442
- ge.theme.icon = "https://static.cartridge.gg/presets/cartridge/icon.svg";
2443
- var Zt = Ot, er = ge.theme;
2398
+ me.theme.icon = "https://static.cartridge.gg/presets/cartridge/icon.svg";
2399
+ var Vt = $t, Jt = me.theme;
2444
2400
  export {
2445
- Nt as ArgentWallet,
2446
- nr as FeeSource,
2447
- Mt as MetaMaskWallet,
2448
- b as NotReadyToConnect,
2449
- Bt as PhantomWallet,
2450
- Qt as RabbyWallet,
2451
- v as ResponseCodes,
2452
- Tt as WalletBridge,
2453
- jt as default,
2454
- er as defaultTheme,
2455
- Zt as erc20Metadata,
2456
- Gt as getAvailableConfigs,
2401
+ Pt as ArgentWallet,
2402
+ tr as FeeSource,
2403
+ Nt as MetaMaskWallet,
2404
+ p as NotReadyToConnect,
2405
+ Mt as PhantomWallet,
2406
+ Tt as RabbyWallet,
2407
+ R as ResponseCodes,
2408
+ Qt as WalletBridge,
2409
+ Ht as default,
2410
+ Jt as defaultTheme,
2411
+ Vt as erc20Metadata,
2412
+ qt as getAvailableConfigs,
2457
2413
  F as getConfigsIndex,
2458
- or as humanizeString,
2459
- Jt as loadAllConfigs,
2460
- Vt as loadConfig,
2461
- Xt as lookupAddresses,
2462
- qt as lookupUsernames,
2463
- sr as normalizeCalls,
2464
- ve as parseChainId,
2465
- we as toArray,
2466
- ar as toSessionPolicies,
2467
- ir as toWasmPolicies
2414
+ rr as humanizeString,
2415
+ Gt as loadAllConfigs,
2416
+ Xt as loadConfig,
2417
+ jt as lookupAddresses,
2418
+ Kt as lookupUsernames,
2419
+ nr as normalizeCalls,
2420
+ Ae as parseChainId,
2421
+ be as toArray,
2422
+ sr as toSessionPolicies,
2423
+ or as toWasmPolicies
2468
2424
  };
2469
2425
  //# sourceMappingURL=index.js.map