@nexus-cross/crossx-sdk-core 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  var Ys = Object.defineProperty;
2
2
  var Xs = (r, e, s) => e in r ? Ys(r, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[e] = s;
3
- var P = (r, e, s) => Xs(r, typeof e != "symbol" ? e + "" : e, s);
3
+ var C = (r, e, s) => Xs(r, typeof e != "symbol" ? e + "" : e, s);
4
4
  import { createRemoteJWKSet as Js, jwtVerify as Zs, decodeJwt as Qs } from "jose";
5
5
  var h = /* @__PURE__ */ ((r) => (r.AUTH_NOT_INITIALIZED = "AUTH_NOT_INITIALIZED", r.AUTH_FAILED = "AUTH_FAILED", r.AUTH_TOKEN_INVALID = "AUTH_TOKEN_INVALID", r.AUTH_TOKEN_EXPIRED = "AUTH_TOKEN_EXPIRED", r.AUTH_NOT_AUTHENTICATED = "AUTH_NOT_AUTHENTICATED", r.ALREADY_AUTHENTICATED = "ALREADY_AUTHENTICATED", r.SESSION_EXPIRED = "SESSION_EXPIRED", r.OAUTH_POPUP_BLOCKED = "OAUTH_POPUP_BLOCKED", r.WALLET_NOT_FOUND = "WALLET_NOT_FOUND", r.WALLET_CREATION_FAILED = "WALLET_CREATION_FAILED", r.WALLET_ALREADY_EXISTS = "WALLET_ALREADY_EXISTS", r.ADDRESS_LIMIT_EXCEEDED = "ADDRESS_LIMIT_EXCEEDED", r.SIGN_FAILED = "SIGN_FAILED", r.SIGN_REJECTED = "SIGN_REJECTED", r.TX_FAILED = "TX_FAILED", r.TX_REJECTED = "TX_REJECTED", r.BROADCAST_FAILED = "BROADCAST_FAILED", r.USER_REJECTED = "USER_REJECTED", r.TX_INVALID_PARAMS = "TX_INVALID_PARAMS", r.NETWORK_ERROR = "NETWORK_ERROR", r.NETWORK_NOT_CONFIGURED = "NETWORK_NOT_CONFIGURED", r.INVALID_CHAIN = "INVALID_CHAIN", r.CHAIN_NOT_SUPPORTED = "CHAIN_NOT_SUPPORTED", r.CHAIN_ADAPTER_NOT_FOUND = "CHAIN_ADAPTER_NOT_FOUND", r.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", r.SIGNATURE_FAILED = "SIGNATURE_FAILED", r.TRANSACTION_FAILED = "TRANSACTION_FAILED", r.PREPARE_FAILED = "PREPARE_FAILED", r.PREPARE_EXPIRED = "PREPARE_EXPIRED", r.PREPARE_MISMATCH = "PREPARE_MISMATCH", r.MIGRATION_FAILED = "MIGRATION_FAILED", r.MIGRATION_BACKUP_EXISTS = "MIGRATION_BACKUP_EXISTS", r.MIGRATION_PIN_LOCKED = "MIGRATION_PIN_LOCKED", r.GATEWAY_INTERNAL_ERROR = "GATEWAY_INTERNAL_ERROR", r.GATEWAY_LOCK_CONFLICT = "GATEWAY_LOCK_CONFLICT", r.WALLET_INCONSISTENT_STATE = "WALLET_INCONSISTENT_STATE", r.PROJECT_ID_MISSING = "PROJECT_ID_MISSING", r.ORIGIN_NOT_ALLOWED = "ORIGIN_NOT_ALLOWED", r.APP_IDENTIFIER_MISSING = "APP_IDENTIFIER_MISSING", r.INVALID_APP_TYPE = "INVALID_APP_TYPE", r.PROJECT_NOT_REGISTERED = "PROJECT_NOT_REGISTERED", r.SIGNATURE_SIGNER_MISMATCH = "SIGNATURE_SIGNER_MISMATCH", r.GAS_ESTIMATION_FAILED = "GAS_ESTIMATION_FAILED", r.TYPED_DATA_CHAIN_ID_MISMATCH = "TYPED_DATA_CHAIN_ID_MISMATCH", r.PIN_NOT_SET = "PIN_NOT_SET", r.PIN_WRONG = "PIN_WRONG", r.PIN_INVALID = "PIN_INVALID", r.PIN_REPEATED_PATTERN = "PIN_REPEATED_PATTERN", r.PIN_CANCELLED = "PIN_CANCELLED", r.EXTERNAL_WALLET_REQUESTED = "EXTERNAL_WALLET_REQUESTED", r.PIN_LOCKED = "PIN_LOCKED", r.HMAC_REQUIRED = "HMAC_REQUIRED", r.HMAC_VERIFICATION_FAILED = "HMAC_VERIFICATION_FAILED", r.WITHDRAW_FAILED = "WITHDRAW_FAILED", r.USER_NOT_FOUND = "USER_NOT_FOUND", r.INVALID_CONFIG = "INVALID_CONFIG", r.UNKNOWN_ERROR = "UNKNOWN_ERROR", r))(h || {});
6
6
  class g extends Error {
@@ -185,7 +185,7 @@ class or {
185
185
  }
186
186
  }
187
187
  let fe = null;
188
- function Ot(r) {
188
+ function Pt(r) {
189
189
  fe = r;
190
190
  }
191
191
  const d = {
@@ -251,6 +251,8 @@ const d = {
251
251
  walletSelector_title: "지갑 선택",
252
252
  walletSelector_addButton: "지갑 추가",
253
253
  walletSelector_selected: "선택됨",
254
+ walletSelector_addError_limitExceeded: "계정 한도에 도달했습니다. 최대 {limit}개의 계정을 사용할 수 있습니다.",
255
+ walletSelector_addError_generic: "새 계정을 추가하지 못했습니다. 다시 시도해 주세요.",
254
256
  // ── PIN 설정 동의 화면 (PIN Setup Notice) ────────────────────
255
257
  pinNotice_headerSubtitle: "트랜잭션, PK/니모닉 내보내기 및 계정 삭제 시 필요합니다.",
256
258
  pinNotice_title: "PIN 설정 주의사항",
@@ -332,6 +334,8 @@ const d = {
332
334
  walletSelector_title: "Select Wallet",
333
335
  walletSelector_addButton: "Add Wallet",
334
336
  walletSelector_selected: "Selected",
337
+ walletSelector_addError_limitExceeded: "Account limit reached. Maximum {limit} accounts allowed.",
338
+ walletSelector_addError_generic: "Failed to add a new account. Please try again.",
335
339
  // ── PIN Setup Notice (consent screen) ───────────────────────
336
340
  pinNotice_headerSubtitle: "Required for transactions, PK/mnemonic export & account deletion.",
337
341
  pinNotice_title: "PIN Setup Notice",
@@ -384,7 +388,7 @@ For security, you must continue with the same account.`,
384
388
  function xe(r = "en", e) {
385
389
  return cr[r] ?? as;
386
390
  }
387
- const Pt = "crossx_access_token", Ct = "crossx_refresh_token", Nt = "crossx_user_info", Je = class Je {
391
+ const Ct = "crossx_access_token", Nt = "crossx_refresh_token", Lt = "crossx_user_info", Je = class Je {
388
392
  constructor(e, s, t, n, i, o, a) {
389
393
  this.config = e, this.storage = s, this.crypto = t, this.oauth = n, this.transport = i, this.walletProvider = o, this.tokenStore = a, this._refreshPromise = null, this._migrated = !1;
390
394
  const c = e.projectId;
@@ -467,50 +471,50 @@ const Pt = "crossx_access_token", Ct = "crossx_refresh_token", Nt = "crossx_user
467
471
  var i, o, a, c, l;
468
472
  let t, n = !1;
469
473
  try {
470
- const { authApiUrl: u } = this.config, { accessToken: f, refreshToken: x } = await this.exchangeFirebaseToken(e, u);
471
- let _, p, v;
474
+ const { authApiUrl: u } = this.config, { accessToken: p, refreshToken: x } = await this.exchangeFirebaseToken(e, u);
475
+ let _, f, b;
472
476
  try {
473
- const I = this.crypto.decodeJWT(e);
474
- d.log("[CROSSx] Firebase JWT 필드:", Object.keys(I).join(", ")), p = (i = I.firebase) == null ? void 0 : i.sign_in_provider;
475
- const T = ((o = I.firebase) == null ? void 0 : o.identities) ?? {};
476
- v = I.email ?? ((a = T.email) == null ? void 0 : a[0]), p === "google.com" ? _ = (c = T["google.com"]) == null ? void 0 : c[0] : p === "apple.com" && (_ = (l = T["apple.com"]) == null ? void 0 : l[0]), d.log("[CROSSx] OAuth provider sub 추출 — provider:", p, "hasProviderSub:", !!_, "email:", v ?? "(없음)");
477
+ const k = this.crypto.decodeJWT(e);
478
+ d.log("[CROSSx] Firebase JWT 필드:", Object.keys(k).join(", ")), f = (i = k.firebase) == null ? void 0 : i.sign_in_provider;
479
+ const P = ((o = k.firebase) == null ? void 0 : o.identities) ?? {};
480
+ b = k.email ?? ((a = P.email) == null ? void 0 : a[0]), f === "google.com" ? _ = (c = P["google.com"]) == null ? void 0 : c[0] : f === "apple.com" && (_ = (l = P["apple.com"]) == null ? void 0 : l[0]), d.log("[CROSSx] OAuth provider sub 추출 — provider:", f, "hasProviderSub:", !!_, "email:", b ?? "(없음)");
477
481
  } catch {
478
482
  d.warn("[CROSSx] firebaseToken에서 providerSub 추출 실패");
479
483
  }
480
- if (f) {
481
- const I = this.crypto.decodeJWT(f);
482
- d.log("[CROSSx] access_token 디코딩 — sub:", I.sub, "exp:", I.exp, "필드:", Object.keys(I).join(", "));
483
- const T = await this.crypto.verifyJWT(f);
484
- if (n = T.signatureVerified ?? !1, !T.valid)
484
+ if (p) {
485
+ const k = this.crypto.decodeJWT(p);
486
+ d.log("[CROSSx] access_token 디코딩 — sub:", k.sub, "exp:", k.exp, "필드:", Object.keys(k).join(", "));
487
+ const P = await this.crypto.verifyJWT(p);
488
+ if (n = P.signatureVerified ?? !1, !P.valid)
485
489
  throw d.error("[CROSSx] access_token 검증 실패"), new Error("유효하지 않은 access token");
486
- const B = T.payload, D = B.email ?? v ?? s;
490
+ const R = P.payload, N = R.email ?? b ?? s;
487
491
  d.log(
488
492
  "[CROSSx] email 소스 — CROSSx JWT:",
489
- B.email ?? "(없음)",
493
+ R.email ?? "(없음)",
490
494
  "/ Firebase JWT:",
491
- v ?? "(없음)",
495
+ b ?? "(없음)",
492
496
  "/ OAuth 콜백:",
493
497
  s ?? "(없음)",
494
498
  "→",
495
- D ?? "(없음)"
499
+ N ?? "(없음)"
496
500
  ), t = {
497
- id: B.sub,
498
- email: D,
499
- signInProvider: p,
501
+ id: R.sub,
502
+ email: N,
503
+ signInProvider: f,
500
504
  providerSub: _
501
- }, this.tokenStore.set(f), this.useCookieAuth || (await this.storage.set(this.STORAGE_KEY_ACCESS_TOKEN, f), x && this.config.secureStorageAvailable !== !1 ? await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, x) : x && d.warn("[CROSSx] 안전한 스토리지 미사용 — refresh_token 영속 저장을 건너뜁니다"));
505
+ }, this.tokenStore.set(p), this.useCookieAuth || (await this.storage.set(this.STORAGE_KEY_ACCESS_TOKEN, p), x && this.config.secureStorageAvailable !== !1 ? await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, x) : x && d.warn("[CROSSx] 안전한 스토리지 미사용 — refresh_token 영속 저장을 건너뜁니다"));
502
506
  } else {
503
- const I = this.crypto.decodeJWT(e);
507
+ const k = this.crypto.decodeJWT(e);
504
508
  t = {
505
- id: I.sub,
506
- email: I.email ?? s,
507
- signInProvider: p,
509
+ id: k.sub,
510
+ email: k.email ?? s,
511
+ signInProvider: f,
508
512
  providerSub: _
509
513
  }, d.log("[CROSSx] Cookie 모드 — Firebase 토큰에서 사용자 정보 추출 — id:", t.id);
510
514
  }
511
515
  d.log("[CROSSx] 사용자 정보 — id:", t.id, "email:", t.email ?? "(없음)");
512
- const S = this.useCookieAuth ? { id: t.id, email: t.email, signInProvider: t.signInProvider, providerSub: t.providerSub } : t;
513
- await this.storage.set(this.STORAGE_KEY_USER, S), d.log("[CROSSx] 사용자 정보 저장 완료 (authMode:", this.useCookieAuth ? "cookie" : "token", ")");
516
+ const E = this.useCookieAuth ? { id: t.id, email: t.email, signInProvider: t.signInProvider, providerSub: t.providerSub } : t;
517
+ await this.storage.set(this.STORAGE_KEY_USER, E), d.log("[CROSSx] 사용자 정보 저장 완료 (authMode:", this.useCookieAuth ? "cookie" : "token", ")");
514
518
  } catch (u) {
515
519
  return d.error("[CROSSx] SignIn 에러 (토큰 교환 단계):", u), {
516
520
  success: !1,
@@ -747,13 +751,13 @@ const Pt = "crossx_access_token", Ct = "crossx_refresh_token", Nt = "crossx_user
747
751
  if (!this._migrated) {
748
752
  this._migrated = !0;
749
753
  try {
750
- const e = await this.storage.get(Nt);
754
+ const e = await this.storage.get(Lt);
751
755
  if (!e || await this.storage.get(this.STORAGE_KEY_USER)) return;
752
756
  await this.storage.set(this.STORAGE_KEY_USER, e);
753
- const t = await this.storage.get(Pt);
757
+ const t = await this.storage.get(Ct);
754
758
  t && await this.storage.set(this.STORAGE_KEY_ACCESS_TOKEN, t);
755
- const n = await this.storage.get(Ct);
756
- n && await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, n), await this.storage.remove(Nt), await this.storage.remove(Pt), await this.storage.remove(Ct), d.log("[CROSSx] 스토리지 키 마이그레이션 완료 (projectId 스코프)");
759
+ const n = await this.storage.get(Nt);
760
+ n && await this.storage.set(this.STORAGE_KEY_REFRESH_TOKEN, n), await this.storage.remove(Lt), await this.storage.remove(Ct), await this.storage.remove(Nt), d.log("[CROSSx] 스토리지 키 마이그레이션 완료 (projectId 스코프)");
757
761
  } catch (e) {
758
762
  d.warn("[CROSSx] 스토리지 키 마이그레이션 실패:", e);
759
763
  }
@@ -953,7 +957,7 @@ function ls() {
953
957
  }
954
958
  return Ce.production;
955
959
  }
956
- const fr = 2e3, Lt = 6e4, _r = 1e3, xr = 1e4, gr = "0x77359400", Dt = "0x3B9ACA00", Mt = 130, ds = 6, $t = 18, Bt = 3e4, mr = 5 * 60 * 1e3, wr = 30 * 1e3, Ut = 100;
960
+ const fr = 2e3, Dt = 6e4, _r = 1e3, xr = 1e4, gr = "0x77359400", Mt = "0x3B9ACA00", $t = 130, ds = 6, Bt = 18, Ut = 3e4, mr = 5 * 60 * 1e3, wr = 30 * 1e3, ft = 100;
957
961
  function us(r) {
958
962
  let e = r.length;
959
963
  for (; e > 0 && r.charCodeAt(e - 1) === 48; ) e--;
@@ -964,7 +968,7 @@ function yr(r) {
964
968
  try {
965
969
  const e = BigInt(r);
966
970
  if (e === 0n) return "0";
967
- const s = 10n ** BigInt($t), t = e / s, i = (e % s).toString().padStart($t, "0"), o = us(i).slice(0, ds);
971
+ const s = 10n ** BigInt(Bt), t = e / s, i = (e % s).toString().padStart(Bt, "0"), o = us(i).slice(0, ds);
968
972
  return o ? `${t}.${o}` : `${t}`;
969
973
  } catch {
970
974
  return "?";
@@ -988,10 +992,10 @@ function br(r) {
988
992
  h.SIGNATURE_FAILED,
989
993
  "유효하지 않은 서명: 올바른 hex 문자열이 아닙니다"
990
994
  );
991
- if (e.length !== Mt)
995
+ if (e.length !== $t)
992
996
  throw new g(
993
997
  h.SIGNATURE_FAILED,
994
- `서명 길이가 유효하지 않습니다: ${Mt} hex 문자(65 바이트) 예상, 현재 ${e.length}`
998
+ `서명 길이가 유효하지 않습니다: ${$t} hex 문자(65 바이트) 예상, 현재 ${e.length}`
995
999
  );
996
1000
  }
997
1001
  function Sr(r) {
@@ -1370,40 +1374,40 @@ class Rr {
1370
1374
  "[CROSSx][Migration Phase 4] PIN 입력 완료 — verify-recovery-pin API 호출"
1371
1375
  ), n = void 0;
1372
1376
  try {
1373
- const f = await ((l = (c = this.deps.walletProvider).verifyRecoveryPin) == null ? void 0 : l.call(
1377
+ const p = await ((l = (c = this.deps.walletProvider).verifyRecoveryPin) == null ? void 0 : l.call(
1374
1378
  c,
1375
1379
  u,
1376
1380
  e
1377
1381
  ));
1378
- if (!f) {
1382
+ if (!p) {
1379
1383
  d.log(
1380
1384
  "[CROSSx][Migration Phase 4] verifyRecoveryPin 미지원 — PIN 검증 생략"
1381
1385
  ), a = u;
1382
1386
  break;
1383
1387
  }
1384
- if (f.valid) {
1388
+ if (p.valid) {
1385
1389
  d.log("[CROSSx][Migration Phase 4] PIN 검증 성공"), a = u;
1386
1390
  break;
1387
1391
  }
1388
- const x = f.pinStatus;
1392
+ const x = p.pinStatus;
1389
1393
  if (o = x.maxAttempts, i = o - x.remainingAttempts, x.remainingAttempts === 0 && x.lockExpiresAt) {
1390
- const _ = x.lockExpiresAt * 1e3, p = Math.max(
1394
+ const _ = x.lockExpiresAt * 1e3, f = Math.max(
1391
1395
  1,
1392
1396
  Math.round((_ - Date.now()) / 1e3)
1393
- ), v = p <= 1800 ? "Too many failed attempts. Please try again in 30 minutes." : "Too many failed attempts. Please try again in 24 hours.";
1397
+ ), b = f <= 1800 ? "Too many failed attempts. Please try again in 30 minutes." : "Too many failed attempts. Please try again in 24 hours.";
1394
1398
  d.warn(
1395
- `[CROSSx][Migration Phase 4] verify-recovery-pin 잠금 — ${p}초, 메시지: ${v}`
1399
+ `[CROSSx][Migration Phase 4] verify-recovery-pin 잠금 — ${f}초, 메시지: ${b}`
1396
1400
  ), await this.deps.confirmation.showRecoveryPinLockedPrompt(
1397
- p,
1398
- v
1401
+ f,
1402
+ b
1399
1403
  ), i = 0, n = "Your account lock has been lifted. You may try again.";
1400
1404
  } else
1401
1405
  d.warn(
1402
1406
  `[CROSSx][Migration Phase 4] PIN 불일치 (시도 ${i}/${o})`
1403
1407
  ), n = "Incorrect PIN.";
1404
- } catch (f) {
1405
- if (!(f instanceof g)) throw f;
1406
- if (f.code === h.SESSION_EXPIRED) {
1408
+ } catch (p) {
1409
+ if (!(p instanceof g)) throw p;
1410
+ if (p.code === h.SESSION_EXPIRED) {
1407
1411
  d.warn(
1408
1412
  "[CROSSx][Migration Phase 4] 세션 만료 — 재로그인 후 PIN 입력 재시도"
1409
1413
  );
@@ -1418,10 +1422,10 @@ class Rr {
1418
1422
  ), i--;
1419
1423
  continue;
1420
1424
  }
1421
- throw this.deps.clearAuthState(), f;
1425
+ throw this.deps.clearAuthState(), p;
1422
1426
  }
1423
- if (f.code === h.MIGRATION_PIN_LOCKED) {
1424
- const x = f.details;
1427
+ if (p.code === h.MIGRATION_PIN_LOCKED) {
1428
+ const x = p.details;
1425
1429
  if (o = (x == null ? void 0 : x.maxAttempts) ?? 5, (x == null ? void 0 : x.permanent) === !0)
1426
1430
  return d.warn(
1427
1431
  "[CROSSx][Migration Phase 4] PIN 영구 잠금 (verify-recovery-pin)"
@@ -1429,21 +1433,21 @@ class Rr {
1429
1433
  0,
1430
1434
  "Your account has been permanently locked due to too many failed attempts."
1431
1435
  ), null;
1432
- const _ = ((x == null ? void 0 : x.lockExpiresAt) ?? 0) * 1e3, p = Math.max(
1436
+ const _ = ((x == null ? void 0 : x.lockExpiresAt) ?? 0) * 1e3, f = Math.max(
1433
1437
  1,
1434
1438
  Math.round((_ - Date.now()) / 1e3)
1435
- ), v = p <= 1800 ? "Too many failed attempts. Please try again in 30 minutes." : "Too many failed attempts. Please try again in 24 hours.";
1439
+ ), b = f <= 1800 ? "Too many failed attempts. Please try again in 30 minutes." : "Too many failed attempts. Please try again in 24 hours.";
1436
1440
  d.warn(
1437
- `[CROSSx][Migration Phase 4] verify-recovery-pin 이미 잠금 — ${p}초`
1441
+ `[CROSSx][Migration Phase 4] verify-recovery-pin 이미 잠금 — ${f}초`
1438
1442
  ), await this.deps.confirmation.showRecoveryPinLockedPrompt(
1439
- p,
1440
- v
1443
+ f,
1444
+ b
1441
1445
  ), i = 0, n = "Your account lock has been lifted. You may try again.";
1442
1446
  } else
1443
1447
  throw d.error(
1444
1448
  "[CROSSx][Migration Phase 4] verify-recovery-pin 실패 (복구 불가):",
1445
- f
1446
- ), f;
1449
+ p
1450
+ ), p;
1447
1451
  }
1448
1452
  }
1449
1453
  d.log(
@@ -1465,29 +1469,29 @@ class Rr {
1465
1469
  d.warn(
1466
1470
  "[CROSSx][Migration Phase 5] 세션 만료 — 재로그인 후 마이그레이션 재시도"
1467
1471
  );
1468
- const f = xe(this.deps.getLocale() ?? "en"), x = this.deps.getUserEmail();
1472
+ const p = xe(this.deps.getLocale() ?? "en"), x = this.deps.getUserEmail();
1469
1473
  if (await this.deps.confirmation.showSessionAlert({
1470
- title: f.sessionAlert_title,
1471
- message: f.alert_sessionExpired,
1472
- email: x ? this.deps.maskEmail(x, f.sessionAlert_appleAccount) : void 0
1474
+ title: p.sessionAlert_title,
1475
+ message: p.alert_sessionExpired,
1476
+ email: x ? this.deps.maskEmail(x, p.sessionAlert_appleAccount) : void 0
1473
1477
  }) === "signin-again" && (await this.deps.signInAgain()).success) {
1474
1478
  d.log(
1475
1479
  "[CROSSx][Migration Phase 5] 재로그인 성공 — 마이그레이션 재시도 (검증된 PIN 유지)"
1476
1480
  );
1477
1481
  try {
1478
- const v = await this.deps.executeMigrate(
1482
+ const b = await this.deps.executeMigrate(
1479
1483
  a,
1480
1484
  e
1481
1485
  );
1482
1486
  return d.log(
1483
1487
  "[CROSSx][Migration Phase 5] 마이그레이션 재시도 성공 — address:",
1484
- v.address
1485
- ), v;
1486
- } catch (v) {
1488
+ b.address
1489
+ ), b;
1490
+ } catch (b) {
1487
1491
  throw d.error(
1488
1492
  "[CROSSx][Migration Phase 5] 마이그레이션 재시도 실패:",
1489
- v
1490
- ), v;
1493
+ b
1494
+ ), b;
1491
1495
  }
1492
1496
  }
1493
1497
  throw this.deps.clearAuthState(), u;
@@ -1511,7 +1515,7 @@ class Or {
1511
1515
  ), i && d.log("[CROSSx] gasLimit 비어있음 → eth_estimateGas 호출"), o && d.log(
1512
1516
  "[CROSSx] gasPrice & maxFeePerGas 비어있음 → baseFee 조회로 Dynamic/Legacy 판별"
1513
1517
  );
1514
- const [u, f, x] = await Promise.all([
1518
+ const [u, p, x] = await Promise.all([
1515
1519
  l ? this.deps.jsonRpcCall(
1516
1520
  "eth_getTransactionCount",
1517
1521
  [l, "pending"],
@@ -1520,11 +1524,11 @@ class Or {
1520
1524
  i ? this.deps.estimateGas(e, s) : null,
1521
1525
  o ? this.deps.getBaseFeePerGas(s) : null
1522
1526
  ]);
1523
- if (l && (c.nonce = parseInt(u ?? "0x0", 16), d.log("[CROSSx] nonce 결과:", c.nonce)), i && (c.gasLimit = f, d.log("[CROSSx] estimateGas 결과:", c.gasLimit)), o) {
1527
+ if (l && (c.nonce = parseInt(u ?? "0x0", 16), d.log("[CROSSx] nonce 결과:", c.nonce)), i && (c.gasLimit = p, d.log("[CROSSx] estimateGas 결과:", c.gasLimit)), o) {
1524
1528
  const _ = x;
1525
1529
  if (_) {
1526
- const p = Dt;
1527
- c.maxFeePerGas = `0x${(BigInt(_) + BigInt(p)).toString(16)}`, c.maxPriorityFeePerGas = p, d.log(
1530
+ const f = Mt;
1531
+ c.maxFeePerGas = `0x${(BigInt(_) + BigInt(f)).toString(16)}`, c.maxPriorityFeePerGas = f, d.log(
1528
1532
  "[CROSSx] Dynamic 체인 감지 — baseFee:",
1529
1533
  _,
1530
1534
  "maxFeePerGas:",
@@ -1534,7 +1538,7 @@ class Or {
1534
1538
  } else
1535
1539
  c.gasPrice = gr, d.log("[CROSSx] Legacy 체인 감지 — gasPrice: 2 Gwei");
1536
1540
  }
1537
- return !o && a && (c.maxPriorityFeePerGas = Dt, d.log("[CROSSx] maxPriorityFeePerGas 비어있음 → 1 Gwei 기본값 적용")), c;
1541
+ return !o && a && (c.maxPriorityFeePerGas = Mt, d.log("[CROSSx] maxPriorityFeePerGas 비어있음 → 1 Gwei 기본값 적용")), c;
1538
1542
  }
1539
1543
  }
1540
1544
  class Pr {
@@ -1716,18 +1720,18 @@ function rt(r, e = "Apple account") {
1716
1720
  return t.length <= 1 ? `${t}${"*".repeat(Math.max(t.length, 1))}${n}` : `${t[0]}${"*".repeat(t.length - 1)}${n}`;
1717
1721
  }
1718
1722
  const Ie = class Ie extends hr {
1719
- constructor(e, s, t, n, i, o, a, c, l, u, f) {
1723
+ constructor(e, s, t, n, i, o, a, c, l, u, p) {
1720
1724
  var x, _;
1721
- super(), this.storage = t, this.crypto = n, this.transport = i, this.oauth = o, this.walletProvider = a, this.tokenStore = c, this.initialized = !1, this._initPromise = null, this.authenticated = !1, this.userId = null, this.address = null, this.activeWalletIndex = 0, this.userEmail = null, this.loginType = null, this.providerSub = null, this.tokenSignatureVerified = !1, this._themeMediaCleanup = null, this._isRecoveringSession = !1, this._config = Object.freeze({ ...e }), this.internalConfig = e, this.adapterConfig = s, e.logger && Ot(e.logger), this.confirmation = l, this.pinStore = f ?? new cs(), this.stateManager = new Nr({
1722
- setState: (p) => {
1723
- p.authenticated !== void 0 && (this.authenticated = p.authenticated), p.userId !== void 0 && (this.userId = p.userId), p.address !== void 0 && (this.address = p.address), p.activeWalletIndex !== void 0 && (this.activeWalletIndex = p.activeWalletIndex), p.userEmail !== void 0 && (this.userEmail = p.userEmail), p.providerSub !== void 0 && (this.providerSub = p.providerSub), p.loginType !== void 0 && (this.loginType = p.loginType), p.tokenSignatureVerified !== void 0 && (this.tokenSignatureVerified = p.tokenSignatureVerified);
1725
+ super(), this.storage = t, this.crypto = n, this.transport = i, this.oauth = o, this.walletProvider = a, this.tokenStore = c, this.initialized = !1, this._initPromise = null, this.authenticated = !1, this.userId = null, this.address = null, this.activeWalletIndex = 0, this.userEmail = null, this.loginType = null, this.providerSub = null, this.tokenSignatureVerified = !1, this._themeMediaCleanup = null, this._isRecoveringSession = !1, this._config = Object.freeze({ ...e }), this.internalConfig = e, this.adapterConfig = s, e.logger && Pt(e.logger), this.confirmation = l, this.pinStore = p ?? new cs(), this.stateManager = new Nr({
1726
+ setState: (f) => {
1727
+ f.authenticated !== void 0 && (this.authenticated = f.authenticated), f.userId !== void 0 && (this.userId = f.userId), f.address !== void 0 && (this.address = f.address), f.activeWalletIndex !== void 0 && (this.activeWalletIndex = f.activeWalletIndex), f.userEmail !== void 0 && (this.userEmail = f.userEmail), f.providerSub !== void 0 && (this.providerSub = f.providerSub), f.loginType !== void 0 && (this.loginType = f.loginType), f.tokenSignatureVerified !== void 0 && (this.tokenSignatureVerified = f.tokenSignatureVerified);
1724
1728
  },
1725
1729
  getIsRecoveringSession: () => this._isRecoveringSession,
1726
- emitAddressChanged: ({ address: p, index: v }) => {
1727
- this.emit("addressChanged", { address: p, index: v });
1730
+ emitAddressChanged: ({ address: f, index: b }) => {
1731
+ this.emit("addressChanged", { address: f, index: b });
1728
1732
  },
1729
- emitAuthChanged: ({ isAuthenticated: p, address: v, userId: S }) => {
1730
- this.emit("authChanged", { isAuthenticated: p, address: v, userId: S });
1733
+ emitAuthChanged: ({ isAuthenticated: f, address: b, userId: E }) => {
1734
+ this.emit("authChanged", { isAuthenticated: f, address: b, userId: E });
1731
1735
  },
1732
1736
  shouldPersistWalletPreference: () => this._config.persistWalletPreference !== !1,
1733
1737
  walletPreferenceKey: Ie.WALLET_PREF_KEY,
@@ -1749,26 +1753,26 @@ const Ie = class Ie extends hr {
1749
1753
  walletProvider: this.walletProvider,
1750
1754
  pinOrchestrator: this.pinOrchestrator,
1751
1755
  getUserId: () => this.userId,
1752
- setActiveWallet: (p, v) => this.setActiveWallet(p, v)
1756
+ setActiveWallet: (f, b) => this.setActiveWallet(f, b)
1753
1757
  }), this.migrationOrchestrator = new Rr({
1754
1758
  confirmation: this.confirmation,
1755
1759
  walletProvider: this.walletProvider,
1756
1760
  pinOrchestrator: this.pinOrchestrator,
1757
- executeMigrate: (p, v) => this.migrateWalletUseCase.execute(p, v),
1761
+ executeMigrate: (f, b) => this.migrateWalletUseCase.execute(f, b),
1758
1762
  getLocale: () => this._config.locale,
1759
1763
  getUserEmail: () => this.userEmail,
1760
1764
  maskEmail: rt,
1761
1765
  signInAgain: () => this.signInAgain(),
1762
1766
  clearAuthState: () => this.clearAuthState(),
1763
1767
  getAllowSkip: () => {
1764
- var p;
1765
- return ((p = this._config.migration) == null ? void 0 : p.allowSkip) ?? !0;
1768
+ var f;
1769
+ return ((f = this._config.migration) == null ? void 0 : f.allowSkip) ?? !0;
1766
1770
  }
1767
1771
  }), this.transactionLifecycleService = new Or({
1768
1772
  getActiveAddress: () => this.address,
1769
- estimateGas: (p, v) => this.estimateGas(p, v),
1770
- getBaseFeePerGas: (p) => this.getBaseFeePerGas(p),
1771
- jsonRpcCall: (p, v, S) => this.jsonRpc.call(p, v, S)
1773
+ estimateGas: (f, b) => this.estimateGas(f, b),
1774
+ getBaseFeePerGas: (f) => this.getBaseFeePerGas(f),
1775
+ jsonRpcCall: (f, b, E) => this.jsonRpc.call(f, b, E)
1772
1776
  }), this.signatureVerifier = new Pr(this.crypto), this.addressResolverService = new Lr({
1773
1777
  walletProvider: this.walletProvider,
1774
1778
  pinOrchestrator: this.pinOrchestrator,
@@ -1785,7 +1789,7 @@ const Ie = class Ie extends hr {
1785
1789
  walletLifecycleService: this.walletLifecycleService,
1786
1790
  getUserId: () => this.userId,
1787
1791
  getProviderSub: () => this.providerSub,
1788
- setActiveWallet: (p, v) => this.setActiveWallet(p, v)
1792
+ setActiveWallet: (f, b) => this.setActiveWallet(f, b)
1789
1793
  }), this.sessionOrchestrator = new kr({
1790
1794
  ensureInitialized: () => this.ensureInitialized(),
1791
1795
  getSessionSnapshot: () => ({
@@ -1794,18 +1798,18 @@ const Ie = class Ie extends hr {
1794
1798
  loginType: this.loginType,
1795
1799
  userEmail: this.userEmail
1796
1800
  }),
1797
- setRecoveringSession: (p) => {
1798
- this._isRecoveringSession = p;
1801
+ setRecoveringSession: (f) => {
1802
+ this._isRecoveringSession = f;
1799
1803
  },
1800
- setAuthenticated: (p) => {
1801
- this.authenticated = p;
1804
+ setAuthenticated: (f) => {
1805
+ this.authenticated = f;
1802
1806
  },
1803
1807
  clearTokenStore: () => this.tokenStore.clear(),
1804
- executeSignIn: (p) => this.signInUseCase.execute(p),
1808
+ executeSignIn: (f) => this.signInUseCase.execute(f),
1805
1809
  executeSignOut: () => this.signOutUseCase.execute(),
1806
- showSessionAlert: (p) => this.confirmation.showSessionAlert(p),
1810
+ showSessionAlert: (f) => this.confirmation.showSessionAlert(f),
1807
1811
  clearAuthState: () => this.clearAuthState(),
1808
- applyAuthResult: (p) => this.applyAuthResult(p),
1812
+ applyAuthResult: (f) => this.applyAuthResult(f),
1809
1813
  loadWalletAfterAuth: () => this.walletLifecycleService.loadWalletAfterAuth(),
1810
1814
  getLocale: () => this._config.locale,
1811
1815
  maskEmail: rt
@@ -1846,7 +1850,7 @@ const Ie = class Ie extends hr {
1846
1850
  }
1847
1851
  async _doInitialize(e) {
1848
1852
  var s, t;
1849
- d.log("[CROSSx SDK] v2.0.2 초기화 중..."), this.confirmation.setMessages(xe(this._config.locale));
1853
+ d.log("[CROSSx SDK] v2.1.1 초기화 중..."), this.confirmation.setMessages(xe(this._config.locale));
1850
1854
  try {
1851
1855
  const n = ls();
1852
1856
  this.internalConfig.oauthServiceUrl = n.oauthServiceUrl, this.internalConfig.authApiUrl = n.authApiUrl, this.internalConfig.walletGatewayUrl = n.walletGatewayUrl, this.adapterConfig.gatewayUrl = n.walletGatewayUrl, (t = (s = this.crypto).setJWKSEndpoint) == null || t.call(s, `${n.authApiUrl}/.well-known/jwks.json`);
@@ -1863,7 +1867,7 @@ const Ie = class Ie extends hr {
1863
1867
  throw u;
1864
1868
  d.log("[CROSSx] initialize: 비밀번호 입력 취소 — 지갑 미로드 상태로 계속");
1865
1869
  }
1866
- return this.initialized = !0, d.info("[CROSSx SDK] v2.0.2 초기화 완료"), this.emit("initialized", { restored: !!(c != null && c.success) }), c ?? null;
1870
+ return this.initialized = !0, d.info("[CROSSx SDK] v2.1.1 초기화 완료"), this.emit("initialized", { restored: !!(c != null && c.success) }), c ?? null;
1867
1871
  } catch (n) {
1868
1872
  throw new g(h.AUTH_NOT_INITIALIZED, "SDK 초기화에 실패했습니다", n);
1869
1873
  }
@@ -2585,7 +2589,7 @@ const Ie = class Ie extends hr {
2585
2589
  * @param opts.timeoutMs 최대 대기 시간 (기본 60000ms)
2586
2590
  */
2587
2591
  async waitForTxAndGetReceipt(e, s, t = {}) {
2588
- const n = t.intervalMs ?? _r, i = xr, o = t.timeoutMs ?? Lt, a = Date.now() + o;
2592
+ const n = t.intervalMs ?? _r, i = xr, o = t.timeoutMs ?? Dt, a = Date.now() + o;
2589
2593
  let c = n;
2590
2594
  for (; Date.now() < a; ) {
2591
2595
  const l = await this.getTransactionReceipt(e, s);
@@ -2613,35 +2617,35 @@ const Ie = class Ie extends hr {
2613
2617
  * logger.log(receipt.status); // '0x1' | '0x0'
2614
2618
  */
2615
2619
  async sendTransactionWithWaitForReceipt(e, s, t = {}) {
2616
- var v, S;
2617
- const { intervalMs: n, timeoutMs: i, ...o } = t, { txHash: a } = await this.sendTransaction(e, s, o), c = n ?? ((v = this._config.receiptPolling) == null ? void 0 : v.intervalMs) ?? fr, l = i ?? ((S = this._config.receiptPolling) == null ? void 0 : S.timeoutMs) ?? Lt, u = st(e), f = s.from ?? "";
2620
+ var b, E;
2621
+ const { intervalMs: n, timeoutMs: i, ...o } = t, { txHash: a } = await this.sendTransaction(e, s, o), c = n ?? ((b = this._config.receiptPolling) == null ? void 0 : b.intervalMs) ?? fr, l = i ?? ((E = this._config.receiptPolling) == null ? void 0 : E.timeoutMs) ?? Dt, u = st(e), p = s.from ?? "";
2618
2622
  let x, _;
2619
- const p = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((I) => {
2620
- x = I;
2621
- const T = BigInt(I.gasUsed) * BigInt(I.effectiveGasPrice), B = s.value ? BigInt(s.value) : 0n, D = We(s.value, u.symbol, u.decimals), K = We("0x" + T.toString(16), u.symbol, u.decimals), q = We("0x" + (B + T).toString(16), u.symbol, u.decimals);
2623
+ const f = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((k) => {
2624
+ x = k;
2625
+ const P = BigInt(k.gasUsed) * BigInt(k.effectiveGasPrice), R = s.value ? BigInt(s.value) : 0n, N = We(s.value, u.symbol, u.decimals), W = We("0x" + P.toString(16), u.symbol, u.decimals), q = We("0x" + (R + P).toString(16), u.symbol, u.decimals);
2622
2626
  return {
2623
2627
  chainId: e,
2624
2628
  txHash: a,
2625
- from: I.from,
2626
- to: I.to ?? s.to,
2627
- amount: D,
2628
- fees: K,
2629
+ from: k.from,
2630
+ to: k.to ?? s.to,
2631
+ amount: N,
2632
+ fees: W,
2629
2633
  total: q,
2630
2634
  nativeSymbol: u.symbol,
2631
- status: I.status === "0x1" ? "success" : "reverted"
2635
+ status: k.status === "0x1" ? "success" : "reverted"
2632
2636
  };
2633
- }).catch((I) => (_ = I instanceof Error ? I : new Error(String(I)), {
2637
+ }).catch((k) => (_ = k instanceof Error ? k : new Error(String(k)), {
2634
2638
  chainId: e,
2635
2639
  txHash: a,
2636
- from: f,
2640
+ from: p,
2637
2641
  to: s.to,
2638
2642
  amount: We(s.value, u.symbol, u.decimals),
2639
2643
  nativeSymbol: u.symbol,
2640
2644
  status: "timeout"
2641
2645
  }));
2642
2646
  if (await this.confirmation.showTransactionProgress(
2643
- { chainId: e, txHash: a, from: f, to: s.to },
2644
- p
2647
+ { chainId: e, txHash: a, from: p, to: s.to },
2648
+ f
2645
2649
  ), _) throw _;
2646
2650
  return { chainId: e, txHash: a, receipt: x };
2647
2651
  }
@@ -2948,7 +2952,7 @@ const Ie = class Ie extends hr {
2948
2952
  */
2949
2953
  dispose() {
2950
2954
  var e;
2951
- (e = this._themeMediaCleanup) == null || e.call(this), this._themeMediaCleanup = null, this.clearAuthState(), this.tokenStore.clear(), this.pinStore.clear(), this.initialized = !1, this.removeAllListeners(), Ot(null);
2955
+ (e = this._themeMediaCleanup) == null || e.call(this), this._themeMediaCleanup = null, this.clearAuthState(), this.tokenStore.clear(), this.pinStore.clear(), this.initialized = !1, this.removeAllListeners(), Pt(null);
2952
2956
  }
2953
2957
  /**
2954
2958
  * @internal internal 패키지 전용 — 공개 문서에 기재하지 않음
@@ -2969,7 +2973,7 @@ const Ie = class Ie extends hr {
2969
2973
  }
2970
2974
  };
2971
2975
  Ie.WALLET_PREF_KEY = "wallet_preference", Ie.OFFCHAIN_CHAIN_ID = "0";
2972
- let ft = Ie;
2976
+ let _t = Ie;
2973
2977
  class $r {
2974
2978
  constructor() {
2975
2979
  this.prefix = "crossx_";
@@ -3154,7 +3158,7 @@ class Ht {
3154
3158
  }
3155
3159
  }
3156
3160
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3157
- function wt(r) {
3161
+ function yt(r) {
3158
3162
  return r instanceof Uint8Array || ArrayBuffer.isView(r) && r.constructor.name === "Uint8Array";
3159
3163
  }
3160
3164
  function me(r, e = "") {
@@ -3164,7 +3168,7 @@ function me(r, e = "") {
3164
3168
  }
3165
3169
  }
3166
3170
  function V(r, e, s = "") {
3167
- const t = wt(r), n = r == null ? void 0 : r.length, i = e !== void 0;
3171
+ const t = yt(r), n = r == null ? void 0 : r.length, i = e !== void 0;
3168
3172
  if (!t || i && n !== e) {
3169
3173
  const o = s && `"${s}" `, a = i ? ` of length ${e}` : "", c = t ? `length=${n}` : `type=${typeof r}`;
3170
3174
  throw new Error(o + "expected Uint8Array" + a + ", got " + c);
@@ -3281,17 +3285,17 @@ function zr(r, e, s) {
3281
3285
  }
3282
3286
  class jr {
3283
3287
  constructor(e, s, t, n) {
3284
- P(this, "blockLen");
3285
- P(this, "outputLen");
3286
- P(this, "padOffset");
3287
- P(this, "isLE");
3288
+ C(this, "blockLen");
3289
+ C(this, "outputLen");
3290
+ C(this, "padOffset");
3291
+ C(this, "isLE");
3288
3292
  // For partial updates less than block size
3289
- P(this, "buffer");
3290
- P(this, "view");
3291
- P(this, "finished", !1);
3292
- P(this, "length", 0);
3293
- P(this, "pos", 0);
3294
- P(this, "destroyed", !1);
3293
+ C(this, "buffer");
3294
+ C(this, "view");
3295
+ C(this, "finished", !1);
3296
+ C(this, "length", 0);
3297
+ C(this, "pos", 0);
3298
+ C(this, "destroyed", !1);
3295
3299
  this.blockLen = e, this.outputLen = s, this.padOffset = t, this.isLE = n, this.buffer = new Uint8Array(e), this.view = it(this.buffer);
3296
3300
  }
3297
3301
  update(e) {
@@ -3314,8 +3318,8 @@ class jr {
3314
3318
  const { buffer: s, view: t, blockLen: n, isLE: i } = this;
3315
3319
  let { pos: o } = this;
3316
3320
  s[o++] = 128, De(this.buffer.subarray(o)), this.padOffset > n - o && (this.process(t, 0), o = 0);
3317
- for (let f = o; f < n; f++)
3318
- s[f] = 0;
3321
+ for (let p = o; p < n; p++)
3322
+ s[p] = 0;
3319
3323
  t.setBigUint64(n - 8, BigInt(this.length * 8), i), this.process(t, 0);
3320
3324
  const a = it(e), c = this.outputLen;
3321
3325
  if (c % 4)
@@ -3323,8 +3327,8 @@ class jr {
3323
3327
  const l = c / 4, u = this.get();
3324
3328
  if (l > u.length)
3325
3329
  throw new Error("_sha2: outputLen bigger than state");
3326
- for (let f = 0; f < l; f++)
3327
- a.setUint32(4 * f, u[f], i);
3330
+ for (let p = 0; p < l; p++)
3331
+ a.setUint32(4 * p, u[p], i);
3328
3332
  }
3329
3333
  digest() {
3330
3334
  const { buffer: e, outputLen: s } = this;
@@ -3442,16 +3446,16 @@ class sn extends jr {
3442
3446
  this.A = e | 0, this.B = s | 0, this.C = t | 0, this.D = n | 0, this.E = i | 0, this.F = o | 0, this.G = a | 0, this.H = c | 0;
3443
3447
  }
3444
3448
  process(e, s) {
3445
- for (let f = 0; f < 16; f++, s += 4)
3446
- ye[f] = e.getUint32(s, !1);
3447
- for (let f = 16; f < 64; f++) {
3448
- const x = ye[f - 15], _ = ye[f - 2], p = he(x, 7) ^ he(x, 18) ^ x >>> 3, v = he(_, 17) ^ he(_, 19) ^ _ >>> 10;
3449
- ye[f] = v + ye[f - 7] + p + ye[f - 16] | 0;
3449
+ for (let p = 0; p < 16; p++, s += 4)
3450
+ ye[p] = e.getUint32(s, !1);
3451
+ for (let p = 16; p < 64; p++) {
3452
+ const x = ye[p - 15], _ = ye[p - 2], f = he(x, 7) ^ he(x, 18) ^ x >>> 3, b = he(_, 17) ^ he(_, 19) ^ _ >>> 10;
3453
+ ye[p] = b + ye[p - 7] + f + ye[p - 16] | 0;
3450
3454
  }
3451
3455
  let { A: t, B: n, C: i, D: o, E: a, F: c, G: l, H: u } = this;
3452
- for (let f = 0; f < 64; f++) {
3453
- const x = he(a, 6) ^ he(a, 11) ^ he(a, 25), _ = u + x + Vr(a, c, l) + tn[f] + ye[f] | 0, v = (he(t, 2) ^ he(t, 13) ^ he(t, 22)) + zr(t, n, i) | 0;
3454
- u = l, l = c, c = a, a = o + _ | 0, o = i, i = n, n = t, t = _ + v | 0;
3456
+ for (let p = 0; p < 64; p++) {
3457
+ const x = he(a, 6) ^ he(a, 11) ^ he(a, 25), _ = u + x + Vr(a, c, l) + tn[p] + ye[p] | 0, b = (he(t, 2) ^ he(t, 13) ^ he(t, 22)) + zr(t, n, i) | 0;
3458
+ u = l, l = c, c = a, a = o + _ | 0, o = i, i = n, n = t, t = _ + b | 0;
3455
3459
  }
3456
3460
  t = t + this.A | 0, n = n + this.B | 0, i = i + this.C | 0, o = o + this.D | 0, a = a + this.E | 0, c = c + this.F | 0, l = l + this.G | 0, u = u + this.H | 0, this.set(t, n, i, o, a, c, l, u);
3457
3461
  }
@@ -3467,14 +3471,14 @@ class rn extends sn {
3467
3471
  super(32);
3468
3472
  // We cannot use array here since array allows indexing by variable
3469
3473
  // which means optimizer/compiler cannot use registers.
3470
- P(this, "A", we[0] | 0);
3471
- P(this, "B", we[1] | 0);
3472
- P(this, "C", we[2] | 0);
3473
- P(this, "D", we[3] | 0);
3474
- P(this, "E", we[4] | 0);
3475
- P(this, "F", we[5] | 0);
3476
- P(this, "G", we[6] | 0);
3477
- P(this, "H", we[7] | 0);
3474
+ C(this, "A", we[0] | 0);
3475
+ C(this, "B", we[1] | 0);
3476
+ C(this, "C", we[2] | 0);
3477
+ C(this, "D", we[3] | 0);
3478
+ C(this, "E", we[4] | 0);
3479
+ C(this, "F", we[5] | 0);
3480
+ C(this, "G", we[6] | 0);
3481
+ C(this, "H", we[7] | 0);
3478
3482
  }
3479
3483
  }
3480
3484
  const nn = /* @__PURE__ */ _s(
@@ -3482,7 +3486,7 @@ const nn = /* @__PURE__ */ _s(
3482
3486
  /* @__PURE__ */ Kr(1)
3483
3487
  );
3484
3488
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3485
- const yt = /* @__PURE__ */ BigInt(0), _t = /* @__PURE__ */ BigInt(1);
3489
+ const bt = /* @__PURE__ */ BigInt(0), xt = /* @__PURE__ */ BigInt(1);
3486
3490
  function Ye(r, e = "") {
3487
3491
  if (typeof r != "boolean") {
3488
3492
  const s = e && `"${e}" `;
@@ -3505,7 +3509,7 @@ function Ke(r) {
3505
3509
  function ms(r) {
3506
3510
  if (typeof r != "string")
3507
3511
  throw new Error("hex string expected, got " + typeof r);
3508
- return r === "" ? yt : BigInt("0x" + r);
3512
+ return r === "" ? bt : BigInt("0x" + r);
3509
3513
  }
3510
3514
  function Qe(r) {
3511
3515
  return ms(Fe(r));
@@ -3513,7 +3517,7 @@ function Qe(r) {
3513
3517
  function ws(r) {
3514
3518
  return ms(Fe(on(V(r)).reverse()));
3515
3519
  }
3516
- function bt(r, e) {
3520
+ function St(r, e) {
3517
3521
  me(e), r = gs(r);
3518
3522
  const s = je(r.toString(16).padStart(e * 2, "0"));
3519
3523
  if (s.length !== e)
@@ -3521,12 +3525,12 @@ function bt(r, e) {
3521
3525
  return s;
3522
3526
  }
3523
3527
  function ys(r, e) {
3524
- return bt(r, e).reverse();
3528
+ return St(r, e).reverse();
3525
3529
  }
3526
3530
  function on(r) {
3527
3531
  return Uint8Array.from(r);
3528
3532
  }
3529
- const ze = (r) => typeof r == "bigint" && yt <= r;
3533
+ const ze = (r) => typeof r == "bigint" && bt <= r;
3530
3534
  function an(r, e, s) {
3531
3535
  return ze(r) && ze(e) && ze(s) && e <= r && r < s;
3532
3536
  }
@@ -3536,41 +3540,41 @@ function cn(r, e, s, t) {
3536
3540
  }
3537
3541
  function ln(r) {
3538
3542
  let e;
3539
- for (e = 0; r > yt; r >>= _t, e += 1)
3543
+ for (e = 0; r > bt; r >>= xt, e += 1)
3540
3544
  ;
3541
3545
  return e;
3542
3546
  }
3543
- const St = (r) => (_t << BigInt(r)) - _t;
3547
+ const vt = (r) => (xt << BigInt(r)) - xt;
3544
3548
  function dn(r, e, s) {
3545
3549
  if (me(r, "hashLen"), me(e, "qByteLen"), typeof s != "function")
3546
3550
  throw new Error("hmacFn must be a function");
3547
- const t = (S) => new Uint8Array(S), n = Uint8Array.of(), i = Uint8Array.of(0), o = Uint8Array.of(1), a = 1e3;
3551
+ const t = (E) => new Uint8Array(E), n = Uint8Array.of(), i = Uint8Array.of(0), o = Uint8Array.of(1), a = 1e3;
3548
3552
  let c = t(r), l = t(r), u = 0;
3549
- const f = () => {
3553
+ const p = () => {
3550
3554
  c.fill(1), l.fill(0), u = 0;
3551
- }, x = (...S) => s(l, Se(c, ...S)), _ = (S = n) => {
3552
- l = x(i, S), c = x(), S.length !== 0 && (l = x(o, S), c = x());
3553
- }, p = () => {
3555
+ }, x = (...E) => s(l, Se(c, ...E)), _ = (E = n) => {
3556
+ l = x(i, E), c = x(), E.length !== 0 && (l = x(o, E), c = x());
3557
+ }, f = () => {
3554
3558
  if (u++ >= a)
3555
3559
  throw new Error("drbg: tried max amount of iterations");
3556
- let S = 0;
3557
- const I = [];
3558
- for (; S < e; ) {
3560
+ let E = 0;
3561
+ const k = [];
3562
+ for (; E < e; ) {
3559
3563
  c = x();
3560
- const T = c.slice();
3561
- I.push(T), S += c.length;
3564
+ const P = c.slice();
3565
+ k.push(P), E += c.length;
3562
3566
  }
3563
- return Se(...I);
3567
+ return Se(...k);
3564
3568
  };
3565
- return (S, I) => {
3566
- f(), _(S);
3567
- let T;
3568
- for (; !(T = I(p())); )
3569
+ return (E, k) => {
3570
+ p(), _(E);
3571
+ let P;
3572
+ for (; !(P = k(f())); )
3569
3573
  _();
3570
- return f(), T;
3574
+ return p(), P;
3571
3575
  };
3572
3576
  }
3573
- function vt(r, e = {}, s = {}) {
3577
+ function Et(r, e = {}, s = {}) {
3574
3578
  if (!r || typeof r != "object")
3575
3579
  throw new Error("expected valid options object");
3576
3580
  function t(i, o, a) {
@@ -3620,26 +3624,26 @@ function Kt(r, e) {
3620
3624
  throw new Error("invert: does not exist");
3621
3625
  return de(n, e);
3622
3626
  }
3623
- function Et(r, e, s) {
3627
+ function At(r, e, s) {
3624
3628
  if (!r.eql(r.sqr(e), s))
3625
3629
  throw new Error("Cannot find square root");
3626
3630
  }
3627
3631
  function Is(r, e) {
3628
3632
  const s = (r.ORDER + te) / Ss, t = r.pow(e, s);
3629
- return Et(r, t, e), t;
3633
+ return At(r, t, e), t;
3630
3634
  }
3631
3635
  function pn(r, e) {
3632
3636
  const s = (r.ORDER - vs) / Es, t = r.mul(e, ke), n = r.pow(t, s), i = r.mul(e, n), o = r.mul(r.mul(i, ke), n), a = r.mul(i, r.sub(o, r.ONE));
3633
- return Et(r, a, e), a;
3637
+ return At(r, a, e), a;
3634
3638
  }
3635
3639
  function fn(r) {
3636
3640
  const e = et(r), s = ks(r), t = s(e, e.neg(e.ONE)), n = s(e, t), i = s(e, e.neg(t)), o = (r + un) / As;
3637
3641
  return (a, c) => {
3638
3642
  let l = a.pow(c, o), u = a.mul(l, t);
3639
- const f = a.mul(l, n), x = a.mul(l, i), _ = a.eql(a.sqr(u), c), p = a.eql(a.sqr(f), c);
3640
- l = a.cmov(l, u, _), u = a.cmov(x, f, p);
3641
- const v = a.eql(a.sqr(u), c), S = a.cmov(l, u, v);
3642
- return Et(a, S, c), S;
3643
+ const p = a.mul(l, n), x = a.mul(l, i), _ = a.eql(a.sqr(u), c), f = a.eql(a.sqr(p), c);
3644
+ l = a.cmov(l, u, _), u = a.cmov(x, p, f);
3645
+ const b = a.eql(a.sqr(u), c), E = a.cmov(l, u, b);
3646
+ return At(a, E, c), E;
3643
3647
  };
3644
3648
  }
3645
3649
  function ks(r) {
@@ -3662,16 +3666,16 @@ function ks(r) {
3662
3666
  return l;
3663
3667
  if (Vt(c, l) !== 1)
3664
3668
  throw new Error("Cannot find square root");
3665
- let u = s, f = c.mul(c.ONE, i), x = c.pow(l, e), _ = c.pow(l, o);
3669
+ let u = s, p = c.mul(c.ONE, i), x = c.pow(l, e), _ = c.pow(l, o);
3666
3670
  for (; !c.eql(x, c.ONE); ) {
3667
3671
  if (c.is0(x))
3668
3672
  return c.ZERO;
3669
- let p = 1, v = c.sqr(x);
3670
- for (; !c.eql(v, c.ONE); )
3671
- if (p++, v = c.sqr(v), p === u)
3673
+ let f = 1, b = c.sqr(x);
3674
+ for (; !c.eql(b, c.ONE); )
3675
+ if (f++, b = c.sqr(b), f === u)
3672
3676
  throw new Error("Cannot find square root");
3673
- const S = te << BigInt(u - p - 1), I = c.pow(f, S);
3674
- u = p, f = c.sqr(I), x = c.mul(x, f), _ = c.mul(_, I);
3677
+ const E = te << BigInt(u - f - 1), k = c.pow(p, E);
3678
+ u = f, p = c.sqr(k), x = c.mul(x, p), _ = c.mul(_, k);
3675
3679
  }
3676
3680
  return _;
3677
3681
  };
@@ -3704,7 +3708,7 @@ function gn(r) {
3704
3708
  BYTES: "number",
3705
3709
  BITS: "number"
3706
3710
  }, s = xn.reduce((t, n) => (t[n] = "function", t), e);
3707
- return vt(r, s), r;
3711
+ return Et(r, s), r;
3708
3712
  }
3709
3713
  function mn(r, e, s) {
3710
3714
  if (s < re)
@@ -3735,16 +3739,16 @@ function wn(r, e) {
3735
3739
  }
3736
3740
  class yn {
3737
3741
  constructor(e, s = {}) {
3738
- P(this, "ORDER");
3739
- P(this, "BITS");
3740
- P(this, "BYTES");
3741
- P(this, "isLE");
3742
- P(this, "ZERO", re);
3743
- P(this, "ONE", te);
3744
- P(this, "_lengths");
3745
- P(this, "_sqrt");
3742
+ C(this, "ORDER");
3743
+ C(this, "BITS");
3744
+ C(this, "BYTES");
3745
+ C(this, "isLE");
3746
+ C(this, "ZERO", re);
3747
+ C(this, "ONE", te);
3748
+ C(this, "_lengths");
3749
+ C(this, "_sqrt");
3746
3750
  // cached sqrt
3747
- P(this, "_mod");
3751
+ C(this, "_mod");
3748
3752
  var o;
3749
3753
  if (e <= re)
3750
3754
  throw new Error("invalid field: expected ORDER > 0, got " + e);
@@ -3817,7 +3821,7 @@ class yn {
3817
3821
  return this._sqrt || (this._sqrt = _n(this.ORDER)), this._sqrt(this, e);
3818
3822
  }
3819
3823
  toBytes(e) {
3820
- return this.isLE ? ys(e, this.BYTES) : bt(e, this.BYTES);
3824
+ return this.isLE ? ys(e, this.BYTES) : St(e, this.BYTES);
3821
3825
  }
3822
3826
  fromBytes(e, s = !1) {
3823
3827
  V(e);
@@ -3864,7 +3868,7 @@ function bn(r, e, s = !1) {
3864
3868
  if (t < 16 || t < i || t > 1024)
3865
3869
  throw new Error("expected " + i + "-1024 bytes of input, got " + t);
3866
3870
  const o = s ? ws(r) : Qe(r), a = de(o, e - te) + te;
3867
- return s ? ys(a, n) : bt(a, n);
3871
+ return s ? ys(a, n) : St(a, n);
3868
3872
  }
3869
3873
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3870
3874
  const Me = /* @__PURE__ */ BigInt(0), Te = /* @__PURE__ */ BigInt(1);
@@ -3882,15 +3886,15 @@ function Ps(r, e) {
3882
3886
  }
3883
3887
  function ot(r, e) {
3884
3888
  Ps(r, e);
3885
- const s = Math.ceil(e / r) + 1, t = 2 ** (r - 1), n = 2 ** r, i = St(r), o = BigInt(r);
3889
+ const s = Math.ceil(e / r) + 1, t = 2 ** (r - 1), n = 2 ** r, i = vt(r), o = BigInt(r);
3886
3890
  return { windows: s, windowSize: t, mask: i, maxNumber: n, shiftBy: o };
3887
3891
  }
3888
3892
  function jt(r, e, s) {
3889
3893
  const { windowSize: t, mask: n, maxNumber: i, shiftBy: o } = s;
3890
3894
  let a = Number(r & n), c = r >> o;
3891
3895
  a > t && (a -= i, c += Te);
3892
- const l = e * t, u = l + Math.abs(a) - 1, f = a === 0, x = a < 0, _ = e % 2 !== 0;
3893
- return { nextN: c, offset: u, isZero: f, isNeg: x, isNegF: _, offsetF: l };
3896
+ const l = e * t, u = l + Math.abs(a) - 1, p = a === 0, x = a < 0, _ = e % 2 !== 0;
3897
+ return { nextN: c, offset: u, isZero: p, isNeg: x, isNegF: _, offsetF: l };
3894
3898
  }
3895
3899
  const at = /* @__PURE__ */ new WeakMap(), Cs = /* @__PURE__ */ new WeakMap();
3896
3900
  function ct(r) {
@@ -3903,10 +3907,10 @@ function Yt(r) {
3903
3907
  class Sn {
3904
3908
  // Parametrized with a given Point class (not individual point)
3905
3909
  constructor(e, s) {
3906
- P(this, "BASE");
3907
- P(this, "ZERO");
3908
- P(this, "Fn");
3909
- P(this, "bits");
3910
+ C(this, "BASE");
3911
+ C(this, "ZERO");
3912
+ C(this, "Fn");
3913
+ C(this, "bits");
3910
3914
  this.BASE = e.BASE, this.ZERO = e.ZERO, this.Fn = e.Fn, this.bits = s;
3911
3915
  }
3912
3916
  // non-const time multiplication ladder
@@ -3951,8 +3955,8 @@ class Sn {
3951
3955
  let n = this.ZERO, i = this.BASE;
3952
3956
  const o = ot(e, this.bits);
3953
3957
  for (let a = 0; a < o.windows; a++) {
3954
- const { nextN: c, offset: l, isZero: u, isNeg: f, isNegF: x, offsetF: _ } = jt(t, a, o);
3955
- t = c, u ? i = i.add(Xe(x, s[_])) : n = n.add(Xe(f, s[l]));
3958
+ const { nextN: c, offset: l, isZero: u, isNeg: p, isNegF: x, offsetF: _ } = jt(t, a, o);
3959
+ t = c, u ? i = i.add(Xe(x, s[_])) : n = n.add(Xe(p, s[l]));
3956
3960
  }
3957
3961
  return Yt(t), { p: n, f: i };
3958
3962
  }
@@ -3966,8 +3970,8 @@ class Sn {
3966
3970
  for (let o = 0; o < i.windows && t !== Me; o++) {
3967
3971
  const { nextN: a, offset: c, isZero: l, isNeg: u } = jt(t, o, i);
3968
3972
  if (t = a, !l) {
3969
- const f = s[c];
3970
- n = n.add(u ? f.negate() : f);
3973
+ const p = s[c];
3974
+ n = n.add(u ? p.negate() : p);
3971
3975
  }
3972
3976
  }
3973
3977
  return Yt(t), n;
@@ -4030,12 +4034,12 @@ function An(r, e) {
4030
4034
  }
4031
4035
  class Ns {
4032
4036
  constructor(e, s) {
4033
- P(this, "oHash");
4034
- P(this, "iHash");
4035
- P(this, "blockLen");
4036
- P(this, "outputLen");
4037
- P(this, "finished", !1);
4038
- P(this, "destroyed", !1);
4037
+ C(this, "oHash");
4038
+ C(this, "iHash");
4039
+ C(this, "blockLen");
4040
+ C(this, "outputLen");
4041
+ C(this, "finished", !1);
4042
+ C(this, "destroyed", !1);
4039
4043
  if (hs(e), V(s, void 0, "key"), this.iHash = e.create(), typeof this.iHash.update != "function")
4040
4044
  throw new Error("Expected instance of class which extends utils.Hash");
4041
4045
  this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
@@ -4077,14 +4081,14 @@ const Jt = (r, e) => (r + (r >= 0 ? e : -e) / Ds) / e;
4077
4081
  function In(r, e, s) {
4078
4082
  const [[t, n], [i, o]] = e, a = Jt(o * r, s), c = Jt(-n * r, s);
4079
4083
  let l = r - a * t - c * i, u = -a * n - c * o;
4080
- const f = l < _e, x = u < _e;
4081
- f && (l = -l), x && (u = -u);
4082
- const _ = St(Math.ceil(ln(s) / 2)) + Ne;
4084
+ const p = l < _e, x = u < _e;
4085
+ p && (l = -l), x && (u = -u);
4086
+ const _ = vt(Math.ceil(ln(s) / 2)) + Ne;
4083
4087
  if (l < _e || l >= _ || u < _e || u >= _)
4084
4088
  throw new Error("splitScalar (endomorphism): failed, k=" + r);
4085
- return { k1neg: f, k1: l, k2neg: x, k2: u };
4089
+ return { k1neg: p, k1: l, k2neg: x, k2: u };
4086
4090
  }
4087
- function xt(r) {
4091
+ function gt(r) {
4088
4092
  if (!["compact", "recovered", "der"].includes(r))
4089
4093
  throw new Error('Signature format must be "compact", "recovered", or "der"');
4090
4094
  return r;
@@ -4093,7 +4097,7 @@ function lt(r, e) {
4093
4097
  const s = {};
4094
4098
  for (let t of Object.keys(e))
4095
4099
  s[t] = r[t] === void 0 ? e[t] : r[t];
4096
- return Ye(s.lowS, "lowS"), Ye(s.prehash, "prehash"), s.format !== void 0 && xt(s.format), s;
4100
+ return Ye(s.lowS, "lowS"), Ye(s.prehash, "prehash"), s.format !== void 0 && gt(s.format), s;
4097
4101
  }
4098
4102
  class kn extends Error {
4099
4103
  constructor(e = "") {
@@ -4192,7 +4196,7 @@ function Rn(r, e = {}) {
4192
4196
  const s = En("weierstrass", r, e), { Fp: t, Fn: n } = s;
4193
4197
  let i = s.CURVE;
4194
4198
  const { h: o, n: a } = i;
4195
- vt(e, {}, {
4199
+ Et(e, {}, {
4196
4200
  allowInfinityPoint: "boolean",
4197
4201
  clearCofactor: "function",
4198
4202
  isTorsionFree: "function",
@@ -4208,125 +4212,125 @@ function Rn(r, e = {}) {
4208
4212
  if (!t.isOdd)
4209
4213
  throw new Error("compression is not supported: Field does not have .isOdd()");
4210
4214
  }
4211
- function f($, m, w) {
4212
- const { x: k, y: O } = m.toAffine(), M = t.toBytes(k);
4215
+ function p(B, m, w) {
4216
+ const { x: I, y: O } = m.toAffine(), $ = t.toBytes(I);
4213
4217
  if (Ye(w, "isCompressed"), w) {
4214
4218
  u();
4215
4219
  const y = !t.isOdd(O);
4216
- return Se(Ms(y), M);
4220
+ return Se(Ms(y), $);
4217
4221
  } else
4218
- return Se(Uint8Array.of(4), M, t.toBytes(O));
4222
+ return Se(Uint8Array.of(4), $, t.toBytes(O));
4219
4223
  }
4220
- function x($) {
4221
- V($, void 0, "Point");
4222
- const { publicKey: m, publicKeyUncompressed: w } = l, k = $.length, O = $[0], M = $.subarray(1);
4223
- if (k === m && (O === 2 || O === 3)) {
4224
- const y = t.fromBytes(M);
4224
+ function x(B) {
4225
+ V(B, void 0, "Point");
4226
+ const { publicKey: m, publicKeyUncompressed: w } = l, I = B.length, O = B[0], $ = B.subarray(1);
4227
+ if (I === m && (O === 2 || O === 3)) {
4228
+ const y = t.fromBytes($);
4225
4229
  if (!t.isValid(y))
4226
4230
  throw new Error("bad point: is not on curve, wrong x");
4227
- const b = v(y);
4228
- let E;
4231
+ const S = b(y);
4232
+ let v;
4229
4233
  try {
4230
- E = t.sqrt(b);
4234
+ v = t.sqrt(S);
4231
4235
  } catch (F) {
4232
4236
  const U = F instanceof Error ? ": " + F.message : "";
4233
4237
  throw new Error("bad point: is not on curve, sqrt error" + U);
4234
4238
  }
4235
4239
  u();
4236
- const A = t.isOdd(E);
4237
- return (O & 1) === 1 !== A && (E = t.neg(E)), { x: y, y: E };
4238
- } else if (k === w && O === 4) {
4239
- const y = t.BYTES, b = t.fromBytes(M.subarray(0, y)), E = t.fromBytes(M.subarray(y, y * 2));
4240
- if (!S(b, E))
4240
+ const A = t.isOdd(v);
4241
+ return (O & 1) === 1 !== A && (v = t.neg(v)), { x: y, y: v };
4242
+ } else if (I === w && O === 4) {
4243
+ const y = t.BYTES, S = t.fromBytes($.subarray(0, y)), v = t.fromBytes($.subarray(y, y * 2));
4244
+ if (!E(S, v))
4241
4245
  throw new Error("bad point: is not on curve");
4242
- return { x: b, y: E };
4246
+ return { x: S, y: v };
4243
4247
  } else
4244
- throw new Error(`bad point: got length ${k}, expected compressed=${m} or uncompressed=${w}`);
4248
+ throw new Error(`bad point: got length ${I}, expected compressed=${m} or uncompressed=${w}`);
4245
4249
  }
4246
- const _ = e.toBytes || f, p = e.fromBytes || x;
4247
- function v($) {
4248
- const m = t.sqr($), w = t.mul(m, $);
4249
- return t.add(t.add(w, t.mul($, i.a)), i.b);
4250
+ const _ = e.toBytes || p, f = e.fromBytes || x;
4251
+ function b(B) {
4252
+ const m = t.sqr(B), w = t.mul(m, B);
4253
+ return t.add(t.add(w, t.mul(B, i.a)), i.b);
4250
4254
  }
4251
- function S($, m) {
4252
- const w = t.sqr(m), k = v($);
4253
- return t.eql(w, k);
4255
+ function E(B, m) {
4256
+ const w = t.sqr(m), I = b(B);
4257
+ return t.eql(w, I);
4254
4258
  }
4255
- if (!S(i.Gx, i.Gy))
4259
+ if (!E(i.Gx, i.Gy))
4256
4260
  throw new Error("bad curve params: generator point");
4257
- const I = t.mul(t.pow(i.a, Ve), Tn), T = t.mul(t.sqr(i.b), BigInt(27));
4258
- if (t.is0(t.add(I, T)))
4261
+ const k = t.mul(t.pow(i.a, Ve), Tn), P = t.mul(t.sqr(i.b), BigInt(27));
4262
+ if (t.is0(t.add(k, P)))
4259
4263
  throw new Error("bad curve params: a or b");
4260
- function B($, m, w = !1) {
4264
+ function R(B, m, w = !1) {
4261
4265
  if (!t.isValid(m) || w && t.is0(m))
4262
- throw new Error(`bad point coordinate ${$}`);
4266
+ throw new Error(`bad point coordinate ${B}`);
4263
4267
  return m;
4264
4268
  }
4265
- function D($) {
4266
- if (!($ instanceof X))
4269
+ function N(B) {
4270
+ if (!(B instanceof X))
4267
4271
  throw new Error("Weierstrass Point expected");
4268
4272
  }
4269
- function K($) {
4273
+ function W(B) {
4270
4274
  if (!c || !c.basises)
4271
4275
  throw new Error("no endo");
4272
- return In($, c.basises, n.ORDER);
4276
+ return In(B, c.basises, n.ORDER);
4273
4277
  }
4274
- const q = qt(($, m) => {
4275
- const { X: w, Y: k, Z: O } = $;
4278
+ const q = qt((B, m) => {
4279
+ const { X: w, Y: I, Z: O } = B;
4276
4280
  if (t.eql(O, t.ONE))
4277
- return { x: w, y: k };
4278
- const M = $.is0();
4279
- m == null && (m = M ? t.ONE : t.inv(O));
4280
- const y = t.mul(w, m), b = t.mul(k, m), E = t.mul(O, m);
4281
- if (M)
4281
+ return { x: w, y: I };
4282
+ const $ = B.is0();
4283
+ m == null && (m = $ ? t.ONE : t.inv(O));
4284
+ const y = t.mul(w, m), S = t.mul(I, m), v = t.mul(O, m);
4285
+ if ($)
4282
4286
  return { x: t.ZERO, y: t.ZERO };
4283
- if (!t.eql(E, t.ONE))
4287
+ if (!t.eql(v, t.ONE))
4284
4288
  throw new Error("invZ was invalid");
4285
- return { x: y, y: b };
4286
- }), Z = qt(($) => {
4287
- if ($.is0()) {
4288
- if (e.allowInfinityPoint && !t.is0($.Y))
4289
+ return { x: y, y: S };
4290
+ }), J = qt((B) => {
4291
+ if (B.is0()) {
4292
+ if (e.allowInfinityPoint && !t.is0(B.Y))
4289
4293
  return;
4290
4294
  throw new Error("bad point: ZERO");
4291
4295
  }
4292
- const { x: m, y: w } = $.toAffine();
4296
+ const { x: m, y: w } = B.toAffine();
4293
4297
  if (!t.isValid(m) || !t.isValid(w))
4294
4298
  throw new Error("bad point: x or y not field elements");
4295
- if (!S(m, w))
4299
+ if (!E(m, w))
4296
4300
  throw new Error("bad point: equation left != right");
4297
- if (!$.isTorsionFree())
4301
+ if (!B.isTorsionFree())
4298
4302
  throw new Error("bad point: not in prime-order subgroup");
4299
4303
  return !0;
4300
4304
  });
4301
- function W($, m, w, k, O) {
4302
- return w = new X(t.mul(w.X, $), w.Y, w.Z), m = Xe(k, m), w = Xe(O, w), m.add(w);
4305
+ function G(B, m, w, I, O) {
4306
+ return w = new X(t.mul(w.X, B), w.Y, w.Z), m = Xe(I, m), w = Xe(O, w), m.add(w);
4303
4307
  }
4304
- const N = class N {
4308
+ const D = class D {
4305
4309
  /** Does NOT validate if the point is valid. Use `.assertValidity()`. */
4306
- constructor(m, w, k) {
4307
- P(this, "X");
4308
- P(this, "Y");
4309
- P(this, "Z");
4310
- this.X = B("x", m), this.Y = B("y", w, !0), this.Z = B("z", k), Object.freeze(this);
4310
+ constructor(m, w, I) {
4311
+ C(this, "X");
4312
+ C(this, "Y");
4313
+ C(this, "Z");
4314
+ this.X = R("x", m), this.Y = R("y", w, !0), this.Z = R("z", I), Object.freeze(this);
4311
4315
  }
4312
4316
  static CURVE() {
4313
4317
  return i;
4314
4318
  }
4315
4319
  /** Does NOT validate if the point is valid. Use `.assertValidity()`. */
4316
4320
  static fromAffine(m) {
4317
- const { x: w, y: k } = m || {};
4318
- if (!m || !t.isValid(w) || !t.isValid(k))
4321
+ const { x: w, y: I } = m || {};
4322
+ if (!m || !t.isValid(w) || !t.isValid(I))
4319
4323
  throw new Error("invalid affine point");
4320
- if (m instanceof N)
4324
+ if (m instanceof D)
4321
4325
  throw new Error("projective point not allowed");
4322
- return t.is0(w) && t.is0(k) ? N.ZERO : new N(w, k, t.ONE);
4326
+ return t.is0(w) && t.is0(I) ? D.ZERO : new D(w, I, t.ONE);
4323
4327
  }
4324
4328
  static fromBytes(m) {
4325
- const w = N.fromAffine(p(V(m, void 0, "point")));
4329
+ const w = D.fromAffine(f(V(m, void 0, "point")));
4326
4330
  return w.assertValidity(), w;
4327
4331
  }
4328
4332
  static fromHex(m) {
4329
- return N.fromBytes(je(m));
4333
+ return D.fromBytes(je(m));
4330
4334
  }
4331
4335
  get x() {
4332
4336
  return this.toAffine().x;
@@ -4346,7 +4350,7 @@ function Rn(r, e = {}) {
4346
4350
  // TODO: return `this`
4347
4351
  /** A point on curve is valid if it conforms to equation. */
4348
4352
  assertValidity() {
4349
- Z(this);
4353
+ J(this);
4350
4354
  }
4351
4355
  hasEvenY() {
4352
4356
  const { y: m } = this.toAffine();
@@ -4356,42 +4360,42 @@ function Rn(r, e = {}) {
4356
4360
  }
4357
4361
  /** Compare one point to another. */
4358
4362
  equals(m) {
4359
- D(m);
4360
- const { X: w, Y: k, Z: O } = this, { X: M, Y: y, Z: b } = m, E = t.eql(t.mul(w, b), t.mul(M, O)), A = t.eql(t.mul(k, b), t.mul(y, O));
4361
- return E && A;
4363
+ N(m);
4364
+ const { X: w, Y: I, Z: O } = this, { X: $, Y: y, Z: S } = m, v = t.eql(t.mul(w, S), t.mul($, O)), A = t.eql(t.mul(I, S), t.mul(y, O));
4365
+ return v && A;
4362
4366
  }
4363
4367
  /** Flips point to one corresponding to (x, -y) in Affine coordinates. */
4364
4368
  negate() {
4365
- return new N(this.X, t.neg(this.Y), this.Z);
4369
+ return new D(this.X, t.neg(this.Y), this.Z);
4366
4370
  }
4367
4371
  // Renes-Costello-Batina exception-free doubling formula.
4368
4372
  // There is 30% faster Jacobian formula, but it is not complete.
4369
4373
  // https://eprint.iacr.org/2015/1060, algorithm 3
4370
4374
  // Cost: 8M + 3S + 3*a + 2*b3 + 15add.
4371
4375
  double() {
4372
- const { a: m, b: w } = i, k = t.mul(w, Ve), { X: O, Y: M, Z: y } = this;
4373
- let b = t.ZERO, E = t.ZERO, A = t.ZERO, R = t.mul(O, O), F = t.mul(M, M), U = t.mul(y, y), L = t.mul(O, M);
4374
- return L = t.add(L, L), A = t.mul(O, y), A = t.add(A, A), b = t.mul(m, A), E = t.mul(k, U), E = t.add(b, E), b = t.sub(F, E), E = t.add(F, E), E = t.mul(b, E), b = t.mul(L, b), A = t.mul(k, A), U = t.mul(m, U), L = t.sub(R, U), L = t.mul(m, L), L = t.add(L, A), A = t.add(R, R), R = t.add(A, R), R = t.add(R, U), R = t.mul(R, L), E = t.add(E, R), U = t.mul(M, y), U = t.add(U, U), R = t.mul(U, L), b = t.sub(b, R), A = t.mul(U, F), A = t.add(A, A), A = t.add(A, A), new N(b, E, A);
4376
+ const { a: m, b: w } = i, I = t.mul(w, Ve), { X: O, Y: $, Z: y } = this;
4377
+ let S = t.ZERO, v = t.ZERO, A = t.ZERO, T = t.mul(O, O), F = t.mul($, $), U = t.mul(y, y), M = t.mul(O, $);
4378
+ return M = t.add(M, M), A = t.mul(O, y), A = t.add(A, A), S = t.mul(m, A), v = t.mul(I, U), v = t.add(S, v), S = t.sub(F, v), v = t.add(F, v), v = t.mul(S, v), S = t.mul(M, S), A = t.mul(I, A), U = t.mul(m, U), M = t.sub(T, U), M = t.mul(m, M), M = t.add(M, A), A = t.add(T, T), T = t.add(A, T), T = t.add(T, U), T = t.mul(T, M), v = t.add(v, T), U = t.mul($, y), U = t.add(U, U), T = t.mul(U, M), S = t.sub(S, T), A = t.mul(U, F), A = t.add(A, A), A = t.add(A, A), new D(S, v, A);
4375
4379
  }
4376
4380
  // Renes-Costello-Batina exception-free addition formula.
4377
4381
  // There is 30% faster Jacobian formula, but it is not complete.
4378
4382
  // https://eprint.iacr.org/2015/1060, algorithm 1
4379
4383
  // Cost: 12M + 0S + 3*a + 3*b3 + 23add.
4380
4384
  add(m) {
4381
- D(m);
4382
- const { X: w, Y: k, Z: O } = this, { X: M, Y: y, Z: b } = m;
4383
- let E = t.ZERO, A = t.ZERO, R = t.ZERO;
4385
+ N(m);
4386
+ const { X: w, Y: I, Z: O } = this, { X: $, Y: y, Z: S } = m;
4387
+ let v = t.ZERO, A = t.ZERO, T = t.ZERO;
4384
4388
  const F = i.a, U = t.mul(i.b, Ve);
4385
- let L = t.mul(w, M), G = t.mul(k, y), Y = t.mul(O, b), ie = t.add(w, k), z = t.add(M, y);
4386
- ie = t.mul(ie, z), z = t.add(L, G), ie = t.sub(ie, z), z = t.add(w, O);
4387
- let ee = t.add(M, b);
4388
- return z = t.mul(z, ee), ee = t.add(L, Y), z = t.sub(z, ee), ee = t.add(k, O), E = t.add(y, b), ee = t.mul(ee, E), E = t.add(G, Y), ee = t.sub(ee, E), R = t.mul(F, z), E = t.mul(U, Y), R = t.add(E, R), E = t.sub(G, R), R = t.add(G, R), A = t.mul(E, R), G = t.add(L, L), G = t.add(G, L), Y = t.mul(F, Y), z = t.mul(U, z), G = t.add(G, Y), Y = t.sub(L, Y), Y = t.mul(F, Y), z = t.add(z, Y), L = t.mul(G, z), A = t.add(A, L), L = t.mul(ee, z), E = t.mul(ie, E), E = t.sub(E, L), L = t.mul(ie, G), R = t.mul(ee, R), R = t.add(R, L), new N(E, A, R);
4389
+ let M = t.mul(w, $), K = t.mul(I, y), Y = t.mul(O, S), ie = t.add(w, I), z = t.add($, y);
4390
+ ie = t.mul(ie, z), z = t.add(M, K), ie = t.sub(ie, z), z = t.add(w, O);
4391
+ let ee = t.add($, S);
4392
+ return z = t.mul(z, ee), ee = t.add(M, Y), z = t.sub(z, ee), ee = t.add(I, O), v = t.add(y, S), ee = t.mul(ee, v), v = t.add(K, Y), ee = t.sub(ee, v), T = t.mul(F, z), v = t.mul(U, Y), T = t.add(v, T), v = t.sub(K, T), T = t.add(K, T), A = t.mul(v, T), K = t.add(M, M), K = t.add(K, M), Y = t.mul(F, Y), z = t.mul(U, z), K = t.add(K, Y), Y = t.sub(M, Y), Y = t.mul(F, Y), z = t.add(z, Y), M = t.mul(K, z), A = t.add(A, M), M = t.mul(ee, z), v = t.mul(ie, v), v = t.sub(v, M), M = t.mul(ie, K), T = t.mul(ee, T), T = t.add(T, M), new D(v, A, T);
4389
4393
  }
4390
4394
  subtract(m) {
4391
4395
  return this.add(m.negate());
4392
4396
  }
4393
4397
  is0() {
4394
- return this.equals(N.ZERO);
4398
+ return this.equals(D.ZERO);
4395
4399
  }
4396
4400
  /**
4397
4401
  * Constant time multiplication.
@@ -4406,16 +4410,16 @@ function Rn(r, e = {}) {
4406
4410
  const { endo: w } = e;
4407
4411
  if (!n.isValidNot0(m))
4408
4412
  throw new Error("invalid scalar: out of range");
4409
- let k, O;
4410
- const M = (y) => H.cached(this, y, (b) => zt(N, b));
4413
+ let I, O;
4414
+ const $ = (y) => H.cached(this, y, (S) => zt(D, S));
4411
4415
  if (w) {
4412
- const { k1neg: y, k1: b, k2neg: E, k2: A } = K(m), { p: R, f: F } = M(b), { p: U, f: L } = M(A);
4413
- O = F.add(L), k = W(w.beta, R, U, y, E);
4416
+ const { k1neg: y, k1: S, k2neg: v, k2: A } = W(m), { p: T, f: F } = $(S), { p: U, f: M } = $(A);
4417
+ O = F.add(M), I = G(w.beta, T, U, y, v);
4414
4418
  } else {
4415
- const { p: y, f: b } = M(m);
4416
- k = y, O = b;
4419
+ const { p: y, f: S } = $(m);
4420
+ I = y, O = S;
4417
4421
  }
4418
- return zt(N, [k, O])[0];
4422
+ return zt(D, [I, O])[0];
4419
4423
  }
4420
4424
  /**
4421
4425
  * Non-constant-time multiplication. Uses double-and-add algorithm.
@@ -4423,20 +4427,20 @@ function Rn(r, e = {}) {
4423
4427
  * an exposed secret key e.g. sig verification, which works over *public* keys.
4424
4428
  */
4425
4429
  multiplyUnsafe(m) {
4426
- const { endo: w } = e, k = this;
4430
+ const { endo: w } = e, I = this;
4427
4431
  if (!n.isValid(m))
4428
4432
  throw new Error("invalid scalar: out of range");
4429
- if (m === _e || k.is0())
4430
- return N.ZERO;
4433
+ if (m === _e || I.is0())
4434
+ return D.ZERO;
4431
4435
  if (m === Ne)
4432
- return k;
4436
+ return I;
4433
4437
  if (H.hasCache(this))
4434
4438
  return this.multiply(m);
4435
4439
  if (w) {
4436
- const { k1neg: O, k1: M, k2neg: y, k2: b } = K(m), { p1: E, p2: A } = vn(N, k, M, b);
4437
- return W(w.beta, E, A, O, y);
4440
+ const { k1neg: O, k1: $, k2neg: y, k2: S } = W(m), { p1: v, p2: A } = vn(D, I, $, S);
4441
+ return G(w.beta, v, A, O, y);
4438
4442
  } else
4439
- return H.unsafe(k, m);
4443
+ return H.unsafe(I, m);
4440
4444
  }
4441
4445
  /**
4442
4446
  * Converts Projective point to affine (x, y) coordinates.
@@ -4451,17 +4455,17 @@ function Rn(r, e = {}) {
4451
4455
  */
4452
4456
  isTorsionFree() {
4453
4457
  const { isTorsionFree: m } = e;
4454
- return o === Ne ? !0 : m ? m(N, this) : H.unsafe(this, a).is0();
4458
+ return o === Ne ? !0 : m ? m(D, this) : H.unsafe(this, a).is0();
4455
4459
  }
4456
4460
  clearCofactor() {
4457
4461
  const { clearCofactor: m } = e;
4458
- return o === Ne ? this : m ? m(N, this) : this.multiplyUnsafe(o);
4462
+ return o === Ne ? this : m ? m(D, this) : this.multiplyUnsafe(o);
4459
4463
  }
4460
4464
  isSmallOrder() {
4461
4465
  return this.multiplyUnsafe(o).is0();
4462
4466
  }
4463
4467
  toBytes(m = !0) {
4464
- return Ye(m, "isCompressed"), this.assertValidity(), _(N, this, m);
4468
+ return Ye(m, "isCompressed"), this.assertValidity(), _(D, this, m);
4465
4469
  }
4466
4470
  toHex(m = !0) {
4467
4471
  return Fe(this.toBytes(m));
@@ -4471,12 +4475,12 @@ function Rn(r, e = {}) {
4471
4475
  }
4472
4476
  };
4473
4477
  // base / generator point
4474
- P(N, "BASE", new N(i.Gx, i.Gy, t.ONE)), // zero / infinity / identity point
4475
- P(N, "ZERO", new N(t.ZERO, t.ONE, t.ZERO)), // 0, 1, 0
4478
+ C(D, "BASE", new D(i.Gx, i.Gy, t.ONE)), // zero / infinity / identity point
4479
+ C(D, "ZERO", new D(t.ZERO, t.ONE, t.ZERO)), // 0, 1, 0
4476
4480
  // math field
4477
- P(N, "Fp", t), // scalar field
4478
- P(N, "Fn", n);
4479
- let X = N;
4481
+ C(D, "Fp", t), // scalar field
4482
+ C(D, "Fn", n);
4483
+ let X = D;
4480
4484
  const Q = n.BITS, H = new Sn(X, e.endo ? Math.ceil(Q / 2) : Q);
4481
4485
  return X.BASE.precompute(8), X;
4482
4486
  }
@@ -4496,17 +4500,17 @@ function On(r, e = {}) {
4496
4500
  const { Fn: s } = r, t = e.randomBytes || xs, n = Object.assign($s(r.Fp, s), { seed: Os(s.ORDER) });
4497
4501
  function i(_) {
4498
4502
  try {
4499
- const p = s.fromBytes(_);
4500
- return s.isValidNot0(p);
4503
+ const f = s.fromBytes(_);
4504
+ return s.isValidNot0(f);
4501
4505
  } catch {
4502
4506
  return !1;
4503
4507
  }
4504
4508
  }
4505
- function o(_, p) {
4506
- const { publicKey: v, publicKeyUncompressed: S } = n;
4509
+ function o(_, f) {
4510
+ const { publicKey: b, publicKeyUncompressed: E } = n;
4507
4511
  try {
4508
- const I = _.length;
4509
- return p === !0 && I !== v || p === !1 && I !== S ? !1 : !!r.fromBytes(_);
4512
+ const k = _.length;
4513
+ return f === !0 && k !== b || f === !1 && k !== E ? !1 : !!r.fromBytes(_);
4510
4514
  } catch {
4511
4515
  return !1;
4512
4516
  }
@@ -4514,88 +4518,88 @@ function On(r, e = {}) {
4514
4518
  function a(_ = t(n.seed)) {
4515
4519
  return bn(V(_, n.seed, "seed"), s.ORDER);
4516
4520
  }
4517
- function c(_, p = !0) {
4518
- return r.BASE.multiply(s.fromBytes(_)).toBytes(p);
4521
+ function c(_, f = !0) {
4522
+ return r.BASE.multiply(s.fromBytes(_)).toBytes(f);
4519
4523
  }
4520
4524
  function l(_) {
4521
- const { secretKey: p, publicKey: v, publicKeyUncompressed: S } = n;
4522
- if (!wt(_) || "_lengths" in s && s._lengths || p === v)
4525
+ const { secretKey: f, publicKey: b, publicKeyUncompressed: E } = n;
4526
+ if (!yt(_) || "_lengths" in s && s._lengths || f === b)
4523
4527
  return;
4524
- const I = V(_, void 0, "key").length;
4525
- return I === v || I === S;
4528
+ const k = V(_, void 0, "key").length;
4529
+ return k === b || k === E;
4526
4530
  }
4527
- function u(_, p, v = !0) {
4531
+ function u(_, f, b = !0) {
4528
4532
  if (l(_) === !0)
4529
4533
  throw new Error("first arg must be private key");
4530
- if (l(p) === !1)
4534
+ if (l(f) === !1)
4531
4535
  throw new Error("second arg must be public key");
4532
- const S = s.fromBytes(_);
4533
- return r.fromBytes(p).multiply(S).toBytes(v);
4536
+ const E = s.fromBytes(_);
4537
+ return r.fromBytes(f).multiply(E).toBytes(b);
4534
4538
  }
4535
- const f = {
4539
+ const p = {
4536
4540
  isValidSecretKey: i,
4537
4541
  isValidPublicKey: o,
4538
4542
  randomSecretKey: a
4539
4543
  }, x = An(a, c);
4540
- return Object.freeze({ getPublicKey: c, getSharedSecret: u, keygen: x, Point: r, utils: f, lengths: n });
4544
+ return Object.freeze({ getPublicKey: c, getSharedSecret: u, keygen: x, Point: r, utils: p, lengths: n });
4541
4545
  }
4542
4546
  function Pn(r, e, s = {}) {
4543
- hs(e), vt(s, {}, {
4547
+ hs(e), Et(s, {}, {
4544
4548
  hmac: "function",
4545
4549
  lowS: "boolean",
4546
4550
  randomBytes: "function",
4547
4551
  bits2int: "function",
4548
4552
  bits2int_modN: "function"
4549
4553
  }), s = Object.assign({}, s);
4550
- const t = s.randomBytes || xs, n = s.hmac || ((m, w) => Ls(e, m, w)), { Fp: i, Fn: o } = r, { ORDER: a, BITS: c } = o, { keygen: l, getPublicKey: u, getSharedSecret: f, utils: x, lengths: _ } = On(r, s), p = {
4554
+ const t = s.randomBytes || xs, n = s.hmac || ((m, w) => Ls(e, m, w)), { Fp: i, Fn: o } = r, { ORDER: a, BITS: c } = o, { keygen: l, getPublicKey: u, getSharedSecret: p, utils: x, lengths: _ } = On(r, s), f = {
4551
4555
  prehash: !0,
4552
4556
  lowS: typeof s.lowS == "boolean" ? s.lowS : !0,
4553
4557
  format: "compact",
4554
4558
  extraEntropy: !1
4555
- }, v = a * Ds < i.ORDER;
4556
- function S(m) {
4559
+ }, b = a * Ds < i.ORDER;
4560
+ function E(m) {
4557
4561
  const w = a >> Ne;
4558
4562
  return m > w;
4559
4563
  }
4560
- function I(m, w) {
4564
+ function k(m, w) {
4561
4565
  if (!o.isValidNot0(w))
4562
4566
  throw new Error(`invalid signature ${m}: out of range 1..Point.Fn.ORDER`);
4563
4567
  return w;
4564
4568
  }
4565
- function T() {
4566
- if (v)
4569
+ function P() {
4570
+ if (b)
4567
4571
  throw new Error('"recovered" sig type is not supported for cofactor >2 curves');
4568
4572
  }
4569
- function B(m, w) {
4570
- xt(w);
4571
- const k = _.signature, O = w === "compact" ? k : w === "recovered" ? k + 1 : void 0;
4573
+ function R(m, w) {
4574
+ gt(w);
4575
+ const I = _.signature, O = w === "compact" ? I : w === "recovered" ? I + 1 : void 0;
4572
4576
  return V(m, O);
4573
4577
  }
4574
- class D {
4575
- constructor(w, k, O) {
4576
- P(this, "r");
4577
- P(this, "s");
4578
- P(this, "recovery");
4579
- if (this.r = I("r", w), this.s = I("s", k), O != null) {
4580
- if (T(), ![0, 1, 2, 3].includes(O))
4578
+ class N {
4579
+ constructor(w, I, O) {
4580
+ C(this, "r");
4581
+ C(this, "s");
4582
+ C(this, "recovery");
4583
+ if (this.r = k("r", w), this.s = k("s", I), O != null) {
4584
+ if (P(), ![0, 1, 2, 3].includes(O))
4581
4585
  throw new Error("invalid recovery id");
4582
4586
  this.recovery = O;
4583
4587
  }
4584
4588
  Object.freeze(this);
4585
4589
  }
4586
- static fromBytes(w, k = p.format) {
4587
- B(w, k);
4590
+ static fromBytes(w, I = f.format) {
4591
+ R(w, I);
4588
4592
  let O;
4589
- if (k === "der") {
4590
- const { r: E, s: A } = be.toSig(V(w));
4591
- return new D(E, A);
4593
+ if (I === "der") {
4594
+ const { r: v, s: A } = be.toSig(V(w));
4595
+ return new N(v, A);
4592
4596
  }
4593
- k === "recovered" && (O = w[0], k = "compact", w = w.subarray(1));
4594
- const M = _.signature / 2, y = w.subarray(0, M), b = w.subarray(M, M * 2);
4595
- return new D(o.fromBytes(y), o.fromBytes(b), O);
4597
+ I === "recovered" && (O = w[0], I = "compact", w = w.subarray(1));
4598
+ const $ = _.signature / 2, y = w.subarray(0, $), S = w.subarray($, $ * 2);
4599
+ return new N(o.fromBytes(y), o.fromBytes(S), O);
4596
4600
  }
4597
- static fromHex(w, k) {
4598
- return this.fromBytes(je(w), k);
4601
+ static fromHex(w, I) {
4602
+ return this.fromBytes(je(w), I);
4599
4603
  }
4600
4604
  assertRecovery() {
4601
4605
  const { recovery: w } = this;
@@ -4604,113 +4608,113 @@ function Pn(r, e, s = {}) {
4604
4608
  return w;
4605
4609
  }
4606
4610
  addRecoveryBit(w) {
4607
- return new D(this.r, this.s, w);
4611
+ return new N(this.r, this.s, w);
4608
4612
  }
4609
4613
  recoverPublicKey(w) {
4610
- const { r: k, s: O } = this, M = this.assertRecovery(), y = M === 2 || M === 3 ? k + a : k;
4614
+ const { r: I, s: O } = this, $ = this.assertRecovery(), y = $ === 2 || $ === 3 ? I + a : I;
4611
4615
  if (!i.isValid(y))
4612
4616
  throw new Error("invalid recovery id: sig.r+curve.n != R.x");
4613
- const b = i.toBytes(y), E = r.fromBytes(Se(Ms((M & 1) === 0), b)), A = o.inv(y), R = q(V(w, void 0, "msgHash")), F = o.create(-R * A), U = o.create(O * A), L = r.BASE.multiplyUnsafe(F).add(E.multiplyUnsafe(U));
4614
- if (L.is0())
4617
+ const S = i.toBytes(y), v = r.fromBytes(Se(Ms(($ & 1) === 0), S)), A = o.inv(y), T = q(V(w, void 0, "msgHash")), F = o.create(-T * A), U = o.create(O * A), M = r.BASE.multiplyUnsafe(F).add(v.multiplyUnsafe(U));
4618
+ if (M.is0())
4615
4619
  throw new Error("invalid recovery: point at infinify");
4616
- return L.assertValidity(), L;
4620
+ return M.assertValidity(), M;
4617
4621
  }
4618
4622
  // Signatures should be low-s, to prevent malleability.
4619
4623
  hasHighS() {
4620
- return S(this.s);
4624
+ return E(this.s);
4621
4625
  }
4622
- toBytes(w = p.format) {
4623
- if (xt(w), w === "der")
4626
+ toBytes(w = f.format) {
4627
+ if (gt(w), w === "der")
4624
4628
  return je(be.hexFromSig(this));
4625
- const { r: k, s: O } = this, M = o.toBytes(k), y = o.toBytes(O);
4626
- return w === "recovered" ? (T(), Se(Uint8Array.of(this.assertRecovery()), M, y)) : Se(M, y);
4629
+ const { r: I, s: O } = this, $ = o.toBytes(I), y = o.toBytes(O);
4630
+ return w === "recovered" ? (P(), Se(Uint8Array.of(this.assertRecovery()), $, y)) : Se($, y);
4627
4631
  }
4628
4632
  toHex(w) {
4629
4633
  return Fe(this.toBytes(w));
4630
4634
  }
4631
4635
  }
4632
- const K = s.bits2int || function(w) {
4636
+ const W = s.bits2int || function(w) {
4633
4637
  if (w.length > 8192)
4634
4638
  throw new Error("input is too large");
4635
- const k = Qe(w), O = w.length * 8 - c;
4636
- return O > 0 ? k >> BigInt(O) : k;
4639
+ const I = Qe(w), O = w.length * 8 - c;
4640
+ return O > 0 ? I >> BigInt(O) : I;
4637
4641
  }, q = s.bits2int_modN || function(w) {
4638
- return o.create(K(w));
4639
- }, Z = St(c);
4640
- function W(m) {
4641
- return cn("num < 2^" + c, m, _e, Z), o.toBytes(m);
4642
+ return o.create(W(w));
4643
+ }, J = vt(c);
4644
+ function G(m) {
4645
+ return cn("num < 2^" + c, m, _e, J), o.toBytes(m);
4642
4646
  }
4643
4647
  function X(m, w) {
4644
4648
  return V(m, void 0, "message"), w ? V(e(m), void 0, "prehashed message") : m;
4645
4649
  }
4646
- function Q(m, w, k) {
4647
- const { lowS: O, prehash: M, extraEntropy: y } = lt(k, p);
4648
- m = X(m, M);
4649
- const b = q(m), E = o.fromBytes(w);
4650
- if (!o.isValidNot0(E))
4650
+ function Q(m, w, I) {
4651
+ const { lowS: O, prehash: $, extraEntropy: y } = lt(I, f);
4652
+ m = X(m, $);
4653
+ const S = q(m), v = o.fromBytes(w);
4654
+ if (!o.isValidNot0(v))
4651
4655
  throw new Error("invalid private key");
4652
- const A = [W(E), W(b)];
4656
+ const A = [G(v), G(S)];
4653
4657
  if (y != null && y !== !1) {
4654
- const L = y === !0 ? t(_.secretKey) : y;
4655
- A.push(V(L, void 0, "extraEntropy"));
4658
+ const M = y === !0 ? t(_.secretKey) : y;
4659
+ A.push(V(M, void 0, "extraEntropy"));
4656
4660
  }
4657
- const R = Se(...A), F = b;
4658
- function U(L) {
4659
- const G = K(L);
4660
- if (!o.isValidNot0(G))
4661
+ const T = Se(...A), F = S;
4662
+ function U(M) {
4663
+ const K = W(M);
4664
+ if (!o.isValidNot0(K))
4661
4665
  return;
4662
- const Y = o.inv(G), ie = r.BASE.multiply(G).toAffine(), z = o.create(ie.x);
4666
+ const Y = o.inv(K), ie = r.BASE.multiply(K).toAffine(), z = o.create(ie.x);
4663
4667
  if (z === _e)
4664
4668
  return;
4665
- const ee = o.create(Y * o.create(F + z * E));
4669
+ const ee = o.create(Y * o.create(F + z * v));
4666
4670
  if (ee === _e)
4667
4671
  return;
4668
- let Tt = (ie.x === z ? 0 : 2) | Number(ie.y & Ne), Rt = ee;
4669
- return O && S(ee) && (Rt = o.neg(ee), Tt ^= 1), new D(z, Rt, v ? void 0 : Tt);
4672
+ let Rt = (ie.x === z ? 0 : 2) | Number(ie.y & Ne), Ot = ee;
4673
+ return O && E(ee) && (Ot = o.neg(ee), Rt ^= 1), new N(z, Ot, b ? void 0 : Rt);
4670
4674
  }
4671
- return { seed: R, k2sig: U };
4675
+ return { seed: T, k2sig: U };
4672
4676
  }
4673
- function H(m, w, k = {}) {
4674
- const { seed: O, k2sig: M } = Q(m, w, k);
4675
- return dn(e.outputLen, o.BYTES, n)(O, M).toBytes(k.format);
4677
+ function H(m, w, I = {}) {
4678
+ const { seed: O, k2sig: $ } = Q(m, w, I);
4679
+ return dn(e.outputLen, o.BYTES, n)(O, $).toBytes(I.format);
4676
4680
  }
4677
- function N(m, w, k, O = {}) {
4678
- const { lowS: M, prehash: y, format: b } = lt(O, p);
4679
- if (k = V(k, void 0, "publicKey"), w = X(w, y), !wt(m)) {
4680
- const E = m instanceof D ? ", use sig.toBytes()" : "";
4681
- throw new Error("verify expects Uint8Array signature" + E);
4681
+ function D(m, w, I, O = {}) {
4682
+ const { lowS: $, prehash: y, format: S } = lt(O, f);
4683
+ if (I = V(I, void 0, "publicKey"), w = X(w, y), !yt(m)) {
4684
+ const v = m instanceof N ? ", use sig.toBytes()" : "";
4685
+ throw new Error("verify expects Uint8Array signature" + v);
4682
4686
  }
4683
- B(m, b);
4687
+ R(m, S);
4684
4688
  try {
4685
- const E = D.fromBytes(m, b), A = r.fromBytes(k);
4686
- if (M && E.hasHighS())
4689
+ const v = N.fromBytes(m, S), A = r.fromBytes(I);
4690
+ if ($ && v.hasHighS())
4687
4691
  return !1;
4688
- const { r: R, s: F } = E, U = q(w), L = o.inv(F), G = o.create(U * L), Y = o.create(R * L), ie = r.BASE.multiplyUnsafe(G).add(A.multiplyUnsafe(Y));
4689
- return ie.is0() ? !1 : o.create(ie.x) === R;
4692
+ const { r: T, s: F } = v, U = q(w), M = o.inv(F), K = o.create(U * M), Y = o.create(T * M), ie = r.BASE.multiplyUnsafe(K).add(A.multiplyUnsafe(Y));
4693
+ return ie.is0() ? !1 : o.create(ie.x) === T;
4690
4694
  } catch {
4691
4695
  return !1;
4692
4696
  }
4693
4697
  }
4694
- function $(m, w, k = {}) {
4695
- const { prehash: O } = lt(k, p);
4696
- return w = X(w, O), D.fromBytes(m, "recovered").recoverPublicKey(w).toBytes();
4698
+ function B(m, w, I = {}) {
4699
+ const { prehash: O } = lt(I, f);
4700
+ return w = X(w, O), N.fromBytes(m, "recovered").recoverPublicKey(w).toBytes();
4697
4701
  }
4698
4702
  return Object.freeze({
4699
4703
  keygen: l,
4700
4704
  getPublicKey: u,
4701
- getSharedSecret: f,
4705
+ getSharedSecret: p,
4702
4706
  utils: x,
4703
4707
  lengths: _,
4704
4708
  Point: r,
4705
4709
  sign: H,
4706
- verify: N,
4707
- recoverPublicKey: $,
4708
- Signature: D,
4710
+ verify: D,
4711
+ recoverPublicKey: B,
4712
+ Signature: N,
4709
4713
  hash: e
4710
4714
  });
4711
4715
  }
4712
4716
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
4713
- const At = {
4717
+ const It = {
4714
4718
  p: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),
4715
4719
  n: BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),
4716
4720
  h: BigInt(1),
@@ -4726,13 +4730,13 @@ const At = {
4726
4730
  ]
4727
4731
  }, Zt = /* @__PURE__ */ BigInt(2);
4728
4732
  function Nn(r) {
4729
- const e = At.p, s = BigInt(3), t = BigInt(6), n = BigInt(11), i = BigInt(22), o = BigInt(23), a = BigInt(44), c = BigInt(88), l = r * r * r % e, u = l * l * r % e, f = ae(u, s, e) * u % e, x = ae(f, s, e) * u % e, _ = ae(x, Zt, e) * l % e, p = ae(_, n, e) * _ % e, v = ae(p, i, e) * p % e, S = ae(v, a, e) * v % e, I = ae(S, c, e) * S % e, T = ae(I, a, e) * v % e, B = ae(T, s, e) * u % e, D = ae(B, o, e) * p % e, K = ae(D, t, e) * l % e, q = ae(K, Zt, e);
4730
- if (!gt.eql(gt.sqr(q), r))
4733
+ const e = It.p, s = BigInt(3), t = BigInt(6), n = BigInt(11), i = BigInt(22), o = BigInt(23), a = BigInt(44), c = BigInt(88), l = r * r * r % e, u = l * l * r % e, p = ae(u, s, e) * u % e, x = ae(p, s, e) * u % e, _ = ae(x, Zt, e) * l % e, f = ae(_, n, e) * _ % e, b = ae(f, i, e) * f % e, E = ae(b, a, e) * b % e, k = ae(E, c, e) * E % e, P = ae(k, a, e) * b % e, R = ae(P, s, e) * u % e, N = ae(R, o, e) * f % e, W = ae(N, t, e) * l % e, q = ae(W, Zt, e);
4734
+ if (!mt.eql(mt.sqr(q), r))
4731
4735
  throw new Error("Cannot find square root");
4732
4736
  return q;
4733
4737
  }
4734
- const gt = et(At.p, { sqrt: Nn }), Ln = /* @__PURE__ */ Rn(At, {
4735
- Fp: gt,
4738
+ const mt = et(It.p, { sqrt: Nn }), Ln = /* @__PURE__ */ Rn(It, {
4739
+ Fp: mt,
4736
4740
  endo: Cn
4737
4741
  }), Dn = /* @__PURE__ */ Pn(Ln, nn), Mn = BigInt(0), $e = BigInt(1), $n = BigInt(2), Bn = BigInt(7), Un = BigInt(256), Hn = BigInt(113), Bs = [], Us = [], Hs = [];
4738
4742
  for (let r = 0, e = $e, s = 1, t = 0; r < 24; r++) {
@@ -4749,9 +4753,9 @@ function Gn(r, e = 24) {
4749
4753
  for (let o = 0; o < 10; o++)
4750
4754
  s[o] = r[o] ^ r[o + 10] ^ r[o + 20] ^ r[o + 30] ^ r[o + 40];
4751
4755
  for (let o = 0; o < 10; o += 2) {
4752
- const a = (o + 8) % 10, c = (o + 2) % 10, l = s[c], u = s[c + 1], f = Qt(l, u, 1) ^ s[a], x = es(l, u, 1) ^ s[a + 1];
4756
+ const a = (o + 8) % 10, c = (o + 2) % 10, l = s[c], u = s[c + 1], p = Qt(l, u, 1) ^ s[a], x = es(l, u, 1) ^ s[a + 1];
4753
4757
  for (let _ = 0; _ < 50; _ += 10)
4754
- r[o + _] ^= f, r[o + _ + 1] ^= x;
4758
+ r[o + _] ^= p, r[o + _ + 1] ^= x;
4755
4759
  }
4756
4760
  let n = r[2], i = r[3];
4757
4761
  for (let o = 0; o < 24; o++) {
@@ -4768,20 +4772,20 @@ function Gn(r, e = 24) {
4768
4772
  }
4769
4773
  De(s);
4770
4774
  }
4771
- class It {
4775
+ class kt {
4772
4776
  // NOTE: we accept arguments in bytes instead of bits here.
4773
4777
  constructor(e, s, t, n = !1, i = 24) {
4774
- P(this, "state");
4775
- P(this, "pos", 0);
4776
- P(this, "posOut", 0);
4777
- P(this, "finished", !1);
4778
- P(this, "state32");
4779
- P(this, "destroyed", !1);
4780
- P(this, "blockLen");
4781
- P(this, "suffix");
4782
- P(this, "outputLen");
4783
- P(this, "enableXOF", !1);
4784
- P(this, "rounds");
4778
+ C(this, "state");
4779
+ C(this, "pos", 0);
4780
+ C(this, "posOut", 0);
4781
+ C(this, "finished", !1);
4782
+ C(this, "state32");
4783
+ C(this, "destroyed", !1);
4784
+ C(this, "blockLen");
4785
+ C(this, "suffix");
4786
+ C(this, "outputLen");
4787
+ C(this, "enableXOF", !1);
4788
+ C(this, "rounds");
4785
4789
  if (this.blockLen = e, this.suffix = s, this.outputLen = t, this.enableXOF = n, this.rounds = i, me(t, "outputLen"), !(0 < e && e < 200))
4786
4790
  throw new Error("only keccak-f1600 function is supported");
4787
4791
  this.state = new Uint8Array(200), this.state32 = Hr(this.state);
@@ -4841,10 +4845,10 @@ class It {
4841
4845
  }
4842
4846
  _cloneInto(e) {
4843
4847
  const { blockLen: s, suffix: t, outputLen: n, rounds: i, enableXOF: o } = this;
4844
- return e || (e = new It(s, t, n, o, i)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = i, e.suffix = t, e.outputLen = n, e.enableXOF = o, e.destroyed = this.destroyed, e;
4848
+ return e || (e = new kt(s, t, n, o, i)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = i, e.suffix = t, e.outputLen = n, e.enableXOF = o, e.destroyed = this.destroyed, e;
4845
4849
  }
4846
4850
  }
4847
- const qn = (r, e, s, t = {}) => _s(() => new It(e, r, s), t), ts = /* @__PURE__ */ qn(1, 136, 32), Kn = 60;
4851
+ const qn = (r, e, s, t = {}) => _s(() => new kt(e, r, s), t), ts = /* @__PURE__ */ qn(1, 136, 32), Kn = 60;
4848
4852
  class Vn {
4849
4853
  constructor() {
4850
4854
  this.jwks = null;
@@ -4912,11 +4916,11 @@ ${t.length}`
4912
4916
  const o = ts(i), a = s.startsWith("0x") ? s.slice(2) : s;
4913
4917
  if (a.length !== 130)
4914
4918
  throw new Error(`서명 길이가 유효하지 않습니다: 130 hex 문자 예상, 현재 ${a.length}`);
4915
- const c = zn(a), l = c.slice(0, 32), u = c.slice(32, 64), f = c[64], x = f >= 27 ? f - 27 : f, v = new Dn.Signature(
4919
+ const c = zn(a), l = c.slice(0, 32), u = c.slice(32, 64), p = c[64], x = p >= 27 ? p - 27 : p, b = new Dn.Signature(
4916
4920
  ss(l),
4917
4921
  ss(u)
4918
- ).addRecoveryBit(x).recoverPublicKey(o).toBytes(!1).slice(1), S = ts(v);
4919
- return "0x" + Fe(S.slice(12));
4922
+ ).addRecoveryBit(x).recoverPublicKey(o).toBytes(!1).slice(1), E = ts(b);
4923
+ return "0x" + Fe(E.slice(12));
4920
4924
  }
4921
4925
  }
4922
4926
  function zn(r) {
@@ -5045,14 +5049,14 @@ class Ee {
5045
5049
  }
5046
5050
  openAuth(e) {
5047
5051
  return new Promise((s, t) => {
5048
- const n = Math.max(e.width ?? 500, 500), i = Math.max(e.height ?? 700, 700), o = window.screenX + (window.outerWidth - n) / 2, a = window.screenY + (window.outerHeight - i) / 2, c = Ee.generateRandom16Hex(), l = Ee.generateRandom16Hex(), u = e.authUrl.includes("?") ? "&" : "?", f = `${e.authUrl}${u}state=${c}&nonce=${l}`;
5052
+ const n = Math.max(e.width ?? 500, 500), i = Math.max(e.height ?? 700, 700), o = window.screenX + (window.outerWidth - n) / 2, a = window.screenY + (window.outerHeight - i) / 2, c = Ee.generateRandom16Hex(), l = Ee.generateRandom16Hex(), u = e.authUrl.includes("?") ? "&" : "?", p = `${e.authUrl}${u}state=${c}&nonce=${l}`;
5049
5053
  d.log("[CROSSx] OAuth 팝업 열기 — state, nonce 생성 완료:", {
5050
5054
  stateLength: c.length,
5051
5055
  nonceLength: l.length,
5052
5056
  authUrlBase: e.authUrl
5053
5057
  });
5054
5058
  const x = window.open(
5055
- f,
5059
+ p,
5056
5060
  "CROSSx OAuth",
5057
5061
  `width=${n},height=${i},left=${o},top=${a}`
5058
5062
  );
@@ -5061,60 +5065,60 @@ class Ee {
5061
5065
  return;
5062
5066
  }
5063
5067
  const _ = setTimeout(() => {
5064
- d.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"), D(), t(new Error("Authentication timeout"));
5065
- }, 5 * 60 * 1e3), p = 10, v = 30;
5066
- let S = 0, I = null;
5067
- const T = () => {
5068
- clearInterval(B), d.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " + v + "초간 대기합니다"), I = setTimeout(() => {
5069
- D(), t(new Error(
5068
+ d.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"), N(), t(new Error("Authentication timeout"));
5069
+ }, 5 * 60 * 1e3), f = 10, b = 30;
5070
+ let E = 0, k = null;
5071
+ const P = () => {
5072
+ clearInterval(R), d.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " + b + "초간 대기합니다"), k = setTimeout(() => {
5073
+ N(), t(new Error(
5070
5074
  "OAuth 서버로부터 응답을 받지 못했습니다. 브라우저 보안 정책(COOP)으로 인해 팝업 통신이 차단되었을 수 있습니다. 다시 시도해 주세요."
5071
5075
  ));
5072
- }, v * 1e3);
5073
- }, B = setInterval(() => {
5074
- S++;
5076
+ }, b * 1e3);
5077
+ }, R = setInterval(() => {
5078
+ E++;
5075
5079
  try {
5076
- x.closed && (S <= p ? T() : (D(), t(new Error("로그인이 취소되었습니다"))));
5080
+ x.closed && (E <= f ? P() : (N(), t(new Error("로그인이 취소되었습니다"))));
5077
5081
  } catch {
5078
- T();
5082
+ P();
5079
5083
  }
5080
- }, 1e3), D = () => {
5081
- clearTimeout(_), clearInterval(B), I && clearTimeout(I), window.removeEventListener("message", K);
5082
- }, K = (q) => {
5084
+ }, 1e3), N = () => {
5085
+ clearTimeout(_), clearInterval(R), k && clearTimeout(k), window.removeEventListener("message", W);
5086
+ }, W = (q) => {
5083
5087
  if (q.origin !== e.expectedOrigin) return;
5084
5088
  if (!Jn.has(q.origin)) {
5085
- d.error("[CROSSx] postMessage origin이 허용 목록에 없음:", q.origin), D(), t(new Error("Unauthorized OAuth origin"));
5089
+ d.error("[CROSSx] postMessage origin이 허용 목록에 없음:", q.origin), N(), t(new Error("Unauthorized OAuth origin"));
5086
5090
  return;
5087
5091
  }
5088
- D();
5089
- const Z = typeof q.data.status == "string", W = Z ? q.data.data ?? {} : q.data;
5092
+ N();
5093
+ const J = typeof q.data.status == "string", G = J ? q.data.data ?? {} : q.data;
5090
5094
  d.log("[CROSSx] OAuth postMessage 수신 —", {
5091
- format: Z ? "wrapped" : "flat",
5092
- status: Z ? q.data.status : "(flat)"
5095
+ format: J ? "wrapped" : "flat",
5096
+ status: J ? q.data.status : "(flat)"
5093
5097
  });
5094
- const X = (W == null ? void 0 : W.state) ?? q.data.state;
5098
+ const X = (G == null ? void 0 : G.state) ?? q.data.state;
5095
5099
  if (!X || X !== c) {
5096
5100
  t(new Error("OAuth state mismatch — possible CSRF attack"));
5097
5101
  return;
5098
5102
  }
5099
- if (Z && q.data.status !== "success") {
5100
- d.error("[CROSSx] OAuth 실패:", W == null ? void 0 : W.error), t(new Error((W == null ? void 0 : W.error) || "Authentication failed"));
5103
+ if (J && q.data.status !== "success") {
5104
+ d.error("[CROSSx] OAuth 실패:", G == null ? void 0 : G.error), t(new Error((G == null ? void 0 : G.error) || "Authentication failed"));
5101
5105
  return;
5102
5106
  }
5103
- if (!Z && (W != null && W.error)) {
5104
- d.error("[CROSSx] OAuth 실패:", W.error), t(new Error(W.error || "Authentication failed"));
5107
+ if (!J && (G != null && G.error)) {
5108
+ d.error("[CROSSx] OAuth 실패:", G.error), t(new Error(G.error || "Authentication failed"));
5105
5109
  return;
5106
5110
  }
5107
- const Q = W == null ? void 0 : W.idToken, H = W == null ? void 0 : W.accessToken, N = H ?? Q, $ = (W == null ? void 0 : W.email) || void 0;
5111
+ const Q = G == null ? void 0 : G.idToken, H = G == null ? void 0 : G.accessToken, D = H ?? Q, B = (G == null ? void 0 : G.email) || void 0;
5108
5112
  if (d.log("[CROSSx] OAuth 토큰 수신:", {
5109
5113
  hasAccessToken: !!H,
5110
5114
  hasIdToken: !!Q,
5111
- hasEmail: !!$
5112
- }), !N) {
5115
+ hasEmail: !!B
5116
+ }), !D) {
5113
5117
  d.error("[CROSSx] 토큰을 찾을 수 없음:", q.data), t(new Error("Token not found in response"));
5114
5118
  return;
5115
5119
  }
5116
- const m = { token: N, email: $ }, w = (k) => {
5117
- Ee.verifyIdTokenNonce(k, l).then(() => s(m)).catch((O) => {
5120
+ const m = { token: D, email: B }, w = (I) => {
5121
+ Ee.verifyIdTokenNonce(I, l).then(() => s(m)).catch((O) => {
5118
5122
  d.error("[CROSSx] nonce 검증 실패:", O), t(O instanceof Error ? O : new Error("nonce verification failed"));
5119
5123
  });
5120
5124
  };
@@ -5123,7 +5127,7 @@ class Ee {
5123
5127
  "서버 측 nonce 검증이 필요합니다."
5124
5128
  ), s(m)) : Q ? w(Q) : t(new Error("Token not found in response"));
5125
5129
  };
5126
- window.addEventListener("message", K);
5130
+ window.addEventListener("message", W);
5127
5131
  });
5128
5132
  }
5129
5133
  }
@@ -5300,9 +5304,9 @@ class Ae {
5300
5304
  */
5301
5305
  async ensureValidToken() {
5302
5306
  const e = this.tokenStore.get();
5303
- if (e && !this.tokenStore.isExpiringSoon(Bt))
5307
+ if (e && !this.tokenStore.isExpiringSoon(Ut))
5304
5308
  return e;
5305
- const s = !e || this.tokenStore.isExpiringSoon(Bt);
5309
+ const s = !e || this.tokenStore.isExpiringSoon(Ut);
5306
5310
  if (this._onTokenRefresh) {
5307
5311
  if (await this.deduplicatedRefresh()) {
5308
5312
  const n = this.tokenStore.get();
@@ -5328,7 +5332,7 @@ class Ae {
5328
5332
  }), this._refreshPromise);
5329
5333
  }
5330
5334
  async request(e, s, t, n = !1) {
5331
- var c, l, u, f;
5335
+ var c, l, u, p;
5332
5336
  const i = await this.ensureValidToken(), o = `${this.baseUrl}${s}`, a = {
5333
5337
  Authorization: `Bearer ${i}`,
5334
5338
  "Content-Type": "application/json",
@@ -5343,27 +5347,27 @@ class Ae {
5343
5347
  })).data;
5344
5348
  if (_ && typeof _.code == "number") {
5345
5349
  if (_.code < 0 || _.code >= 400) {
5346
- const p = _.message || _.data || "API 요청에 실패했습니다";
5350
+ const f = _.message || _.data || "API 요청에 실패했습니다";
5347
5351
  d.error("[CROSSx] Wallet Gateway API 에러 (HTTP 200):", {
5348
5352
  code: _.code,
5349
- message: p,
5353
+ message: f,
5350
5354
  url: o,
5351
5355
  method: e
5352
5356
  });
5353
- const v = Ae.mapGatewayError(_.code, _.data);
5354
- if (v === h.AUTH_NOT_AUTHENTICATED && !n && this._onTokenRefresh) {
5357
+ const b = Ae.mapGatewayError(_.code, _.data);
5358
+ if (b === h.AUTH_NOT_AUTHENTICATED && !n && this._onTokenRefresh) {
5355
5359
  if (d.warn("[CROSSx] Gateway -10002 감지 — 토큰 갱신 후 재시도"), await this.deduplicatedRefresh())
5356
5360
  return this.request(e, s, t, !0);
5357
5361
  throw new g(h.SESSION_EXPIRED, "인증 세션이 만료되었습니다. 다시 로그인해 주세요.");
5358
5362
  }
5359
- if (v === h.USER_NOT_FOUND)
5363
+ if (b === h.USER_NOT_FOUND)
5360
5364
  throw d.warn("[CROSSx] Gateway -10033 감지 — 유저 미존재, 강제 로그아웃"), (c = this._onUnauthorized) == null || c.call(this), new g(
5361
5365
  h.USER_NOT_FOUND,
5362
- Ae.getGatewayErrorMessage(_.code, p)
5366
+ Ae.getGatewayErrorMessage(_.code, f)
5363
5367
  );
5364
- const S = v === h.AUTH_NOT_AUTHENTICATED ? h.SESSION_EXPIRED : v, I = S === h.SESSION_EXPIRED ? "인증 세션이 만료되었습니다. 다시 로그인해 주세요." : Ae.getGatewayErrorMessage(_.code, p), T = _.data;
5365
- let B;
5366
- throw v === h.PIN_LOCKED ? B = Ae.extractLockDetails(T) : v === h.ADDRESS_LIMIT_EXCEEDED ? B = { limit: Ut, raw: T } : B = T ?? void 0, new g(S, I, B);
5368
+ const E = b === h.AUTH_NOT_AUTHENTICATED ? h.SESSION_EXPIRED : b, k = E === h.SESSION_EXPIRED ? "인증 세션이 만료되었습니다. 다시 로그인해 주세요." : Ae.getGatewayErrorMessage(_.code, f), P = _.data;
5369
+ let R;
5370
+ throw b === h.PIN_LOCKED ? R = Ae.extractLockDetails(P) : b === h.ADDRESS_LIMIT_EXCEEDED ? R = { limit: ft, raw: P } : R = P ?? void 0, new g(E, k, R);
5367
5371
  }
5368
5372
  return d.log("[CROSSx] Wallet Gateway API 성공:", { code: _.code, url: o, method: e }), _.data ?? _;
5369
5373
  }
@@ -5380,16 +5384,16 @@ class Ae {
5380
5384
  );
5381
5385
  }
5382
5386
  if ((u = x.response) != null && u.data) {
5383
- const p = x.response.data, v = p.message || p.data || "API 요청에 실패했습니다", S = p.code || "UNKNOWN";
5387
+ const f = x.response.data, b = f.message || f.data || "API 요청에 실패했습니다", E = f.code || "UNKNOWN";
5384
5388
  throw d.error("[CROSSx] Wallet Gateway API 에러 (HTTP 에러):", {
5385
- code: S,
5386
- message: v,
5389
+ code: E,
5390
+ message: b,
5387
5391
  url: o,
5388
5392
  method: e,
5389
- status: (f = x.response) == null ? void 0 : f.status
5393
+ status: (p = x.response) == null ? void 0 : p.status
5390
5394
  }), new g(
5391
5395
  h.UNKNOWN_ERROR,
5392
- `Wallet Gateway 오류 (${S}): ${v}`
5396
+ `Wallet Gateway 오류 (${E}): ${b}`
5393
5397
  );
5394
5398
  }
5395
5399
  throw x;
@@ -5751,7 +5755,7 @@ class Ae {
5751
5755
  case -10033:
5752
5756
  return "User not found. You have been signed out.";
5753
5757
  case -10036:
5754
- return `Account limit reached. Maximum ${Ut} accounts allowed.`;
5758
+ return `Account limit reached. Maximum ${ft} accounts allowed.`;
5755
5759
  case -10040:
5756
5760
  return "HMAC signature header is required.";
5757
5761
  case -10041:
@@ -5858,7 +5862,7 @@ class He {
5858
5862
  }
5859
5863
  }
5860
5864
  }
5861
- const rs = "__crossx-confirm-style", J = "__crossx-confirm-overlay", Qn = {
5865
+ const rs = "__crossx-confirm-style", Z = "__crossx-confirm-overlay", Qn = {
5862
5866
  light: {
5863
5867
  bg: "#FFFFFF",
5864
5868
  border: "rgba(18,18,18,0.05)",
@@ -5950,7 +5954,7 @@ function ns(r, e) {
5950
5954
  const ei = `
5951
5955
  @import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600&display=swap');
5952
5956
 
5953
- #${J} {
5957
+ #${Z} {
5954
5958
  position: fixed;
5955
5959
  inset: 0;
5956
5960
  z-index: 2147483647;
@@ -7309,6 +7313,18 @@ button.__crossx-connect-other-block:active {
7309
7313
  line-height: 1.3;
7310
7314
  color: var(--cx-subtitle);
7311
7315
  }
7316
+ .__crossx-wallet-add-error {
7317
+ margin: 8px 0 0;
7318
+ padding: 8px 10px;
7319
+ font-size: 13px;
7320
+ line-height: 1.45;
7321
+ color: var(--cx-error);
7322
+ background: color-mix(in srgb, var(--cx-error) 10%, transparent);
7323
+ border: 1px solid color-mix(in srgb, var(--cx-error) 35%, transparent);
7324
+ border-radius: 8px;
7325
+ word-break: break-word;
7326
+ }
7327
+ .__crossx-wallet-add-error[hidden] { display: none; }
7312
7328
 
7313
7329
  /* ── Safe area fill (mobile only, created by JS in mountOverlay) ── */
7314
7330
  .__crossx-safe-area-fill {
@@ -7316,7 +7332,7 @@ button.__crossx-connect-other-block:active {
7316
7332
  }
7317
7333
  /* ── Mobile bottom sheet ───────────────────────────────────── */
7318
7334
  @media (max-width: 480px) {
7319
- #${J} { align-items: flex-end; }
7335
+ #${Z} { align-items: flex-end; }
7320
7336
  .__crossx-safe-area-fill {
7321
7337
  display: block;
7322
7338
  position: fixed;
@@ -7526,7 +7542,7 @@ button.__crossx-connect-other-block:active {
7526
7542
 
7527
7543
  /* ── Landscape for signing/transaction modals ──────────── */
7528
7544
  @media (orientation: landscape) and (max-height: 500px) {
7529
- #${J} { align-items: center !important; overflow: hidden; }
7545
+ #${Z} { align-items: center !important; overflow: hidden; }
7530
7546
  .__crossx-card--send-tx,
7531
7547
  .__crossx-card--sign-tx,
7532
7548
  .__crossx-card--sign-msg,
@@ -8027,7 +8043,7 @@ function ce() {
8027
8043
  r || (r = document.createElement("style"), r.id = rs, document.head.appendChild(r)), r.textContent = ei;
8028
8044
  }
8029
8045
  function ti() {
8030
- const r = `#${J}`, e = (t) => {
8046
+ const r = `#${Z}`, e = (t) => {
8031
8047
  var n, i;
8032
8048
  (i = (n = t.target) == null ? void 0 : n.closest) != null && i.call(n, r) && t.stopImmediatePropagation();
8033
8049
  }, s = (t) => {
@@ -8092,7 +8108,7 @@ function Ws(r, e = "CROSS", s = 18) {
8092
8108
  try {
8093
8109
  const t = BigInt(r);
8094
8110
  if (t === 0n) return null;
8095
- const n = mt(t, s);
8111
+ const n = wt(t, s);
8096
8112
  return n === "0" ? null : `${n} ${e}`;
8097
8113
  } catch {
8098
8114
  return null;
@@ -8125,7 +8141,7 @@ function Gs(r) {
8125
8141
  const e = parseInt(r.split(":")[1] ?? "", 10);
8126
8142
  return !isNaN(e) && is[e] ? is[e] : r;
8127
8143
  }
8128
- function mt(r, e) {
8144
+ function wt(r, e) {
8129
8145
  if (r === 0n) return "0";
8130
8146
  const s = 10n ** BigInt(e), t = r / s, o = (r % s).toString().padStart(e, "0").slice(0, 6).replace(/0+$/, "");
8131
8147
  return o ? `${t}.${o}` : `${t}`;
@@ -8154,7 +8170,7 @@ function ni(r) {
8154
8170
  const l = a * BigInt(t);
8155
8171
  return {
8156
8172
  isDynamic: !0,
8157
- estTxFee: `${mt(l, o)} ${i}`,
8173
+ estTxFee: `${wt(l, o)} ${i}`,
8158
8174
  maxFeeGwei: dt(t),
8159
8175
  maxPriorityFeeGwei: n ? dt(n) : void 0,
8160
8176
  gasLimitFormatted: c
@@ -8164,7 +8180,7 @@ function ni(r) {
8164
8180
  const l = a * BigInt(s);
8165
8181
  return {
8166
8182
  isDynamic: !1,
8167
- estTxFee: `${mt(l, o)} ${i}`,
8183
+ estTxFee: `${wt(l, o)} ${i}`,
8168
8184
  gasPriceGwei: dt(s),
8169
8185
  gasLimitFormatted: c
8170
8186
  };
@@ -8193,7 +8209,7 @@ const ge = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="
8193
8209
  [Ue.MetaMask]: oi,
8194
8210
  [Ue.Binance]: ai,
8195
8211
  [Ue.CROSSx]: ci
8196
- }, Ks = '<path d="M22.6667 11.8333V10.1667C22.6667 9.2475 21.9192 8.5 21.0001 8.5H10.1667C8.78841 8.5 7.66675 9.62167 7.66675 11V21C7.66675 22.8342 9.16175 23.5 10.1667 23.5H22.6667C23.5859 23.5 24.3334 22.7525 24.3334 21.8333V13.5C24.3334 12.5808 23.5859 11.8333 22.6667 11.8333ZM21.0001 19.3333H19.3334V16H21.0001V19.3333ZM10.1667 11.8333C9.95218 11.8237 9.74959 11.7317 9.60114 11.5765C9.4527 11.4213 9.36986 11.2148 9.36986 11C9.36986 10.7852 9.4527 10.5787 9.60114 10.4235C9.74959 10.2683 9.95218 10.1763 10.1667 10.1667H21.0001V11.8333H10.1667Z"/>', kt = `<svg width="20" height="20" viewBox="0 0 32 32" fill="currentColor" xmlns="http://www.w3.org/2000/svg">${Ks}</svg>`, di = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
8212
+ }, Ks = '<path d="M22.6667 11.8333V10.1667C22.6667 9.2475 21.9192 8.5 21.0001 8.5H10.1667C8.78841 8.5 7.66675 9.62167 7.66675 11V21C7.66675 22.8342 9.16175 23.5 10.1667 23.5H22.6667C23.5859 23.5 24.3334 22.7525 24.3334 21.8333V13.5C24.3334 12.5808 23.5859 11.8333 22.6667 11.8333ZM21.0001 19.3333H19.3334V16H21.0001V19.3333ZM10.1667 11.8333C9.95218 11.8237 9.74959 11.7317 9.60114 11.5765C9.4527 11.4213 9.36986 11.2148 9.36986 11C9.36986 10.7852 9.4527 10.5787 9.60114 10.4235C9.74959 10.2683 9.95218 10.1763 10.1667 10.1667H21.0001V11.8333H10.1667Z"/>', Tt = `<svg width="20" height="20" viewBox="0 0 32 32" fill="currentColor" xmlns="http://www.w3.org/2000/svg">${Ks}</svg>`, di = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
8197
8213
  <path d="M12 0C18.6274 0 24 5.37258 24 12C23.9999 18.6273 18.6274 24 12 24C5.37264 24 9.89594e-05 18.6273 0 12C0 5.37258 5.37258 0 12 0ZM10.875 15.127V17.377H13.125V15.127H10.875ZM10.875 6.62207V13.627H13.125V6.62207H10.875Z" fill="var(--cx-error)"/>
8198
8214
  </svg>`, ui = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
8199
8215
  <circle cx="12" cy="12" r="12" fill="var(--cx-error)"/>
@@ -8235,8 +8251,8 @@ function j(r, e) {
8235
8251
  }
8236
8252
  function hi(r, e) {
8237
8253
  const s = e, t = r.nativeSymbol ?? "ETH", n = r.nativeDecimals ?? 18, i = tt(r.dappName), o = r.to ? `<span class="__crossx-addr-text">${se(r.to)}</span>
8238
- <button class="__crossx-copy-btn" data-copy="${C(r.to)}" title="Copy address">${ge}</button>` : "<span>—</span>", a = qs(r), c = Ws(r.value, t, n), l = c ? j("Value", `<span>${c}</span>`) : "", u = r.data ?? "0x", f = document.createElement("div");
8239
- return f.id = J, f.innerHTML = `
8254
+ <button class="__crossx-copy-btn" data-copy="${L(r.to)}" title="Copy address">${ge}</button>` : "<span>—</span>", a = qs(r), c = Ws(r.value, t, n), l = c ? j("Value", `<span>${c}</span>`) : "", u = r.data ?? "0x", p = document.createElement("div");
8255
+ return p.id = Z, p.innerHTML = `
8240
8256
  <div class="__crossx-card __crossx-card--migration __crossx-card--sign-tx" style="${oe(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
8241
8257
  <div class="__crossx-header">
8242
8258
  <p class="__crossx-title" id="__crossx-ttl">Signature Request</p>
@@ -8247,10 +8263,10 @@ function hi(r, e) {
8247
8263
  <div class="__crossx-body-cols">
8248
8264
  <div class="__crossx-col-left">
8249
8265
  <p class="__crossx-sig-subtitle">
8250
- <span class="__crossx-sig-origin">${C(i)} </span>is requesting a Signature
8266
+ <span class="__crossx-sig-origin">${L(i)} </span>is requesting a Signature
8251
8267
  </p>
8252
8268
  <div class="__crossx-addr-pill">
8253
- ${kt}
8269
+ ${Tt}
8254
8270
  <span class="__crossx-addr-pill-text">${se(r.from)}</span>
8255
8271
  </div>
8256
8272
  <p class="__crossx-warning">After you sign, changes or cancellations are not possible.</p>
@@ -8263,7 +8279,7 @@ function hi(r, e) {
8263
8279
  ${l}
8264
8280
  ${a}
8265
8281
  </div>
8266
- <pre class="__crossx-raw-tx">${C(u)}</pre>
8282
+ <pre class="__crossx-raw-tx">${L(u)}</pre>
8267
8283
  </div>
8268
8284
  </div>
8269
8285
  <div class="__crossx-btn-row">
@@ -8272,12 +8288,12 @@ function hi(r, e) {
8272
8288
  </div>
8273
8289
  </div>
8274
8290
  </div>
8275
- `, f;
8291
+ `, p;
8276
8292
  }
8277
8293
  function pi(r, e) {
8278
8294
  const s = e, t = r.nativeSymbol ?? "ETH", n = r.nativeDecimals ?? 18, i = tt(r.dappName), o = r.to ? `<span class="__crossx-addr-text">${se(r.to)}</span>
8279
- <button class="__crossx-copy-btn" data-copy="${C(r.to)}" title="Copy address">${ge}</button>` : "<span>—</span>", a = qs(r), l = Ws(r.value, t, n) ?? "—", u = document.createElement("div");
8280
- return u.id = J, u.innerHTML = `
8295
+ <button class="__crossx-copy-btn" data-copy="${L(r.to)}" title="Copy address">${ge}</button>` : "<span>—</span>", a = qs(r), l = Ws(r.value, t, n) ?? "—", u = document.createElement("div");
8296
+ return u.id = Z, u.innerHTML = `
8281
8297
  <div class="__crossx-card __crossx-card--migration __crossx-card--send-tx" style="${oe(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
8282
8298
  <div class="__crossx-header">
8283
8299
  <p class="__crossx-title" id="__crossx-ttl">Approve transaction</p>
@@ -8286,7 +8302,7 @@ function pi(r, e) {
8286
8302
  <hr class="__crossx-divider">
8287
8303
  <div class="__crossx-body">
8288
8304
  <p class="__crossx-tx-subtitle">
8289
- <span class="__crossx-sig-origin">${C(i)}</span> wants your permission to approve the following transaction.
8305
+ <span class="__crossx-sig-origin">${L(i)}</span> wants your permission to approve the following transaction.
8290
8306
  </p>
8291
8307
  <div class="__crossx-body-cols">
8292
8308
  <div class="__crossx-rows">
@@ -8313,17 +8329,17 @@ function tt(r) {
8313
8329
  return "This site";
8314
8330
  }
8315
8331
  }
8316
- function C(r) {
8332
+ function L(r) {
8317
8333
  return r.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
8318
8334
  }
8319
8335
  function fi(r) {
8320
8336
  return typeof r == "string" && /^0x[0-9a-fA-F]{40}$/i.test(r);
8321
8337
  }
8322
8338
  function _i(r) {
8323
- if (typeof r == "string") return C(r);
8339
+ if (typeof r == "string") return L(r);
8324
8340
  if (typeof r == "number" || typeof r == "bigint" || typeof r == "boolean") return String(r);
8325
8341
  try {
8326
- return C(JSON.stringify(r));
8342
+ return L(JSON.stringify(r));
8327
8343
  } catch {
8328
8344
  return String(r);
8329
8345
  }
@@ -8332,14 +8348,14 @@ function xi(r, e) {
8332
8348
  const s = j(
8333
8349
  "From",
8334
8350
  `<span class="__crossx-addr-text">${se(r.from)}</span>
8335
- <button class="__crossx-copy-btn" data-copy="${C(r.from)}" title="Copy address">${ge}</button>`
8351
+ <button class="__crossx-copy-btn" data-copy="${L(r.from)}" title="Copy address">${ge}</button>`
8336
8352
  ), t = r.to ? j("To", `<span class="__crossx-addr-text">${se(r.to)}</span>
8337
- <button class="__crossx-copy-btn" data-copy="${C(r.to)}" title="Copy address">${ge}</button>`) : "", n = r.amount ? j("Transfer", `<span>${C(r.amount)}</span>`) : "", i = r.fees ? j("Tx Fee", `<span>${C(r.fees)}</span>`) : "", o = r.txHash ? j("Tx Hash", `<span class="__crossx-addr-text">${se(r.txHash)}</span>
8338
- <button class="__crossx-copy-btn" data-copy="${C(r.txHash)}" title="Copy hash">${ge}</button>`) : "", a = r.total ? `<div class="__crossx-total-pill">
8353
+ <button class="__crossx-copy-btn" data-copy="${L(r.to)}" title="Copy address">${ge}</button>`) : "", n = r.amount ? j("Transfer", `<span>${L(r.amount)}</span>`) : "", i = r.fees ? j("Tx Fee", `<span>${L(r.fees)}</span>`) : "", o = r.txHash ? j("Tx Hash", `<span class="__crossx-addr-text">${se(r.txHash)}</span>
8354
+ <button class="__crossx-copy-btn" data-copy="${L(r.txHash)}" title="Copy hash">${ge}</button>`) : "", a = r.total ? `<div class="__crossx-total-pill">
8339
8355
  <span class="__crossx-total-label">Total<br>(including fees)</span>
8340
- <span class="__crossx-total-amount">${C(r.total)}</span>
8356
+ <span class="__crossx-total-amount">${L(r.total)}</span>
8341
8357
  </div>` : "", c = document.createElement("div");
8342
- return c.id = J, c.innerHTML = `
8358
+ return c.id = Z, c.innerHTML = `
8343
8359
  <div class="__crossx-card __crossx-card--migration" style="${oe(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
8344
8360
  <div class="__crossx-header">
8345
8361
  <p class="__crossx-title" id="__crossx-ttl">Transaction complete</p>
@@ -8362,7 +8378,7 @@ function xi(r, e) {
8362
8378
  }
8363
8379
  function gi(r, e) {
8364
8380
  const s = document.createElement("div");
8365
- return s.id = J, s.innerHTML = `
8381
+ return s.id = Z, s.innerHTML = `
8366
8382
  <div class="__crossx-card __crossx-card--migration" style="${oe(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
8367
8383
  <div class="__crossx-header">
8368
8384
  <p class="__crossx-title" id="__crossx-ttl">Waiting for confirmation</p>
@@ -8380,45 +8396,45 @@ function gi(r, e) {
8380
8396
  function mi(r, e, s) {
8381
8397
  const t = e.status !== "reverted" && e.status !== "timeout", n = e.status === "timeout", i = r.querySelector("#__crossx-ttl"), o = r.querySelector(".__crossx-header");
8382
8398
  if (i) {
8383
- const p = n ? ui : t ? "" : di, v = n ? "Transaction timeout" : t ? "Transaction complete" : "Transaction failed";
8384
- p ? (i.style.display = "flex", i.style.alignItems = "center", i.style.gap = "8px", i.innerHTML = `${p}<span>${v}</span>`) : i.textContent = v;
8399
+ const f = n ? ui : t ? "" : di, b = n ? "Transaction timeout" : t ? "Transaction complete" : "Transaction failed";
8400
+ f ? (i.style.display = "flex", i.style.alignItems = "center", i.style.gap = "8px", i.innerHTML = `${f}<span>${b}</span>`) : i.textContent = b;
8385
8401
  }
8386
8402
  if (o && !r.querySelector("#__crossx-close-btn")) {
8387
- const p = document.createElement("button");
8388
- p.className = "__crossx-close", p.id = "__crossx-close-btn", p.setAttribute("aria-label", "Close"), p.innerHTML = ne, o.appendChild(p);
8403
+ const f = document.createElement("button");
8404
+ f.className = "__crossx-close", f.id = "__crossx-close-btn", f.setAttribute("aria-label", "Close"), f.innerHTML = ne, o.appendChild(f);
8389
8405
  }
8390
8406
  const a = r.querySelector("#__crossx-progress-body");
8391
8407
  if (!a) return;
8392
8408
  const c = e.from ? j("From", `<span class="__crossx-addr-text">${se(e.from)}</span>
8393
- <button class="__crossx-copy-btn" data-copy="${C(e.from)}" title="Copy address">${ge}</button>`) : "", l = e.to ? j("To", `<span class="__crossx-addr-text">${se(e.to)}</span>
8394
- <button class="__crossx-copy-btn" data-copy="${C(e.to)}" title="Copy address">${ge}</button>`) : "", u = e.amount ? j("Transfer", `<span>${C(e.amount)}</span>`) : "", f = e.fees ? j("Tx Fee", `<span>${C(e.fees)}</span>`) : "", x = e.txHash ? j("Tx Hash", `<span class="__crossx-addr-text">${se(e.txHash)}</span>
8395
- <button class="__crossx-copy-btn" data-copy="${C(e.txHash)}" title="Copy hash">${ge}</button>`) : "", _ = e.total ? `<div class="__crossx-total-pill">
8409
+ <button class="__crossx-copy-btn" data-copy="${L(e.from)}" title="Copy address">${ge}</button>`) : "", l = e.to ? j("To", `<span class="__crossx-addr-text">${se(e.to)}</span>
8410
+ <button class="__crossx-copy-btn" data-copy="${L(e.to)}" title="Copy address">${ge}</button>`) : "", u = e.amount ? j("Transfer", `<span>${L(e.amount)}</span>`) : "", p = e.fees ? j("Tx Fee", `<span>${L(e.fees)}</span>`) : "", x = e.txHash ? j("Tx Hash", `<span class="__crossx-addr-text">${se(e.txHash)}</span>
8411
+ <button class="__crossx-copy-btn" data-copy="${L(e.txHash)}" title="Copy hash">${ge}</button>`) : "", _ = e.total ? `<div class="__crossx-total-pill">
8396
8412
  <span class="__crossx-total-label">Total<br>(including fees)</span>
8397
- <span class="__crossx-total-amount">${C(e.total)}</span>
8413
+ <span class="__crossx-total-amount">${L(e.total)}</span>
8398
8414
  </div>` : "";
8399
8415
  a.innerHTML = `
8400
8416
  <div class="__crossx-rows">
8401
8417
  ${c}
8402
8418
  ${l}
8403
8419
  ${u}
8404
- ${f}
8420
+ ${p}
8405
8421
  ${x}
8406
8422
  </div>
8407
8423
  ${_}
8408
8424
  <button class="__crossx-approve-btn" id="__crossx-done-btn">${t ? "All Done" : "Done"}</button>
8409
- `, a.querySelectorAll(".__crossx-copy-btn").forEach((p) => {
8410
- p.addEventListener("click", (v) => {
8411
- var I;
8412
- v.stopPropagation();
8413
- const S = p.dataset.copy;
8414
- S && ((I = navigator.clipboard) == null || I.writeText(S).catch(() => {
8425
+ `, a.querySelectorAll(".__crossx-copy-btn").forEach((f) => {
8426
+ f.addEventListener("click", (b) => {
8427
+ var k;
8428
+ b.stopPropagation();
8429
+ const E = f.dataset.copy;
8430
+ E && ((k = navigator.clipboard) == null || k.writeText(E).catch(() => {
8415
8431
  }));
8416
8432
  });
8417
8433
  });
8418
8434
  }
8419
8435
  function wi(r, e) {
8420
- const s = e, t = tt(r.dappName), n = C(r.message), i = document.createElement("div");
8421
- return i.id = J, i.innerHTML = `
8436
+ const s = e, t = tt(r.dappName), n = L(r.message), i = document.createElement("div");
8437
+ return i.id = Z, i.innerHTML = `
8422
8438
  <div class="__crossx-card __crossx-card--migration __crossx-card--sign-msg" style="${oe(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
8423
8439
  <div class="__crossx-header">
8424
8440
  <p class="__crossx-title" id="__crossx-ttl">Signature Request</p>
@@ -8429,10 +8445,10 @@ function wi(r, e) {
8429
8445
  <div class="__crossx-body-cols">
8430
8446
  <div class="__crossx-col-left">
8431
8447
  <p class="__crossx-sig-subtitle">
8432
- <span class="__crossx-sig-origin">${C(t)} </span>is requesting a Signature
8448
+ <span class="__crossx-sig-origin">${L(t)} </span>is requesting a Signature
8433
8449
  </p>
8434
8450
  <div class="__crossx-addr-pill">
8435
- ${kt}
8451
+ ${Tt}
8436
8452
  <span class="__crossx-addr-pill-text">${se(r.from)}</span>
8437
8453
  </div>
8438
8454
  <p class="__crossx-warning">After you sign, changes or cancellations are not possible.</p>
@@ -8461,19 +8477,19 @@ function yi(r, e) {
8461
8477
  let a = `
8462
8478
  <div class="__crossx-td-row">
8463
8479
  <span class="__crossx-td-label">Primary Type</span>
8464
- <span class="__crossx-td-value">${C(i)}</span>
8480
+ <span class="__crossx-td-value">${L(i)}</span>
8465
8481
  </div>`;
8466
8482
  for (const [l, u] of Object.entries(o)) {
8467
- const f = _i(u), _ = fi(u) ? `<span class="__crossx-addr-text">${se(u)}</span>
8468
- <button class="__crossx-copy-btn" data-copy="${C(String(u))}" title="Copy">${ge}</button>` : `<span>${f}</span>`;
8483
+ const p = _i(u), _ = fi(u) ? `<span class="__crossx-addr-text">${se(u)}</span>
8484
+ <button class="__crossx-copy-btn" data-copy="${L(String(u))}" title="Copy">${ge}</button>` : `<span>${p}</span>`;
8469
8485
  a += `
8470
8486
  <div class="__crossx-td-row">
8471
- <span class="__crossx-td-label">${C(l)}</span>
8487
+ <span class="__crossx-td-label">${L(l)}</span>
8472
8488
  <div class="__crossx-td-value">${_}</div>
8473
8489
  </div>`;
8474
8490
  }
8475
8491
  const c = document.createElement("div");
8476
- return c.id = J, c.innerHTML = `
8492
+ return c.id = Z, c.innerHTML = `
8477
8493
  <div class="__crossx-card __crossx-card--migration __crossx-card--sign-typed" style="${oe(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
8478
8494
  <div class="__crossx-header">
8479
8495
  <p class="__crossx-title" id="__crossx-ttl">Signature Request</p>
@@ -8484,10 +8500,10 @@ function yi(r, e) {
8484
8500
  <div class="__crossx-body-cols">
8485
8501
  <div class="__crossx-col-left">
8486
8502
  <p class="__crossx-sig-subtitle">
8487
- <span class="__crossx-sig-origin">${C(t)} </span>is requesting a Signature
8503
+ <span class="__crossx-sig-origin">${L(t)} </span>is requesting a Signature
8488
8504
  </p>
8489
8505
  <div class="__crossx-addr-pill">
8490
- ${kt}
8506
+ ${Tt}
8491
8507
  <span class="__crossx-addr-pill-text">${se(r.from)}</span>
8492
8508
  </div>
8493
8509
  <p class="__crossx-warning">After you sign, changes or cancellations are not possible.</p>
@@ -8524,11 +8540,11 @@ function zs(r, e, s) {
8524
8540
  function Ii(r, e, s) {
8525
8541
  const t = s == null ? void 0 : s.toLowerCase(), n = r.map((o) => {
8526
8542
  const a = t && o.address.toLowerCase() === t, c = a ? " __crossx-wallet-item--selected" : "", l = a ? `<span class="__crossx-wallet-selected">Selected</span><span class="__crossx-wallet-check">${Si}</span>` : "";
8527
- return `<button class="__crossx-wallet-item${c}" data-wallet-index="${o.index}" data-wallet-address="${C(o.address)}">
8528
- ${zs(o.address, o.index, e.bg)}<span class="__crossx-wallet-info"><span class="__crossx-wallet-idx">${C(Vs(o))}</span><span class="__crossx-wallet-addr">${se(o.address)}</span></span>${l}
8543
+ return `<button class="__crossx-wallet-item${c}" data-wallet-index="${o.index}" data-wallet-address="${L(o.address)}">
8544
+ ${zs(o.address, o.index, e.bg)}<span class="__crossx-wallet-info"><span class="__crossx-wallet-idx">${L(Vs(o))}</span><span class="__crossx-wallet-addr">${se(o.address)}</span></span>${l}
8529
8545
  </button>`;
8530
8546
  }).join(""), i = document.createElement("div");
8531
- return i.id = J, i.innerHTML = `
8547
+ return i.id = Z, i.innerHTML = `
8532
8548
  <div class="__crossx-card __crossx-card--migration __crossx-card--wallet-selector" style="${oe(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
8533
8549
  <div class="__crossx-header">
8534
8550
  <div style="display:flex;flex-direction:column;gap:4px;padding-right:36px;">
@@ -8555,6 +8571,7 @@ function Ii(r, e, s) {
8555
8571
  <span class="__crossx-wallet-add-icon">${bi}</span>
8556
8572
  <span class="__crossx-wallet-add-label">add a wallet</span>
8557
8573
  </button>
8574
+ <p class="__crossx-wallet-add-error" id="__crossx-add-wallet-error" role="alert" aria-live="polite" hidden></p>
8558
8575
  </div>
8559
8576
  </div>
8560
8577
  </div>
@@ -8572,7 +8589,7 @@ const ki = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="h
8572
8589
  </svg>`;
8573
8590
  function Ri(r) {
8574
8591
  const e = sr(r);
8575
- return `<span class="__crossx-connect-other-wallet-desc-part"><span class="__crossx-connect-other-wallet-icon" aria-hidden="true">${li[r] ?? ""}</span><span class="__crossx-connect-other-wallet-name">${C(e)}</span></span>`;
8592
+ return `<span class="__crossx-connect-other-wallet-desc-part"><span class="__crossx-connect-other-wallet-icon" aria-hidden="true">${li[r] ?? ""}</span><span class="__crossx-connect-other-wallet-name">${L(e)}</span></span>`;
8576
8593
  }
8577
8594
  function Oi(r) {
8578
8595
  if (r.length === 0) return "";
@@ -8587,7 +8604,7 @@ function Oi(r) {
8587
8604
  return `${s}${e(0)}, ${e(1)}, ${e(2)}, and ${t} more.`;
8588
8605
  }
8589
8606
  function Pi(r, e = []) {
8590
- const s = r, t = C(String(e[0])), n = e.length > 0 ? `
8607
+ const s = r, t = L(String(e[0])), n = e.length > 0 ? `
8591
8608
  <div class="__crossx-login-or-divider">
8592
8609
  <hr><span>or</span><hr>
8593
8610
  </div>
@@ -8597,7 +8614,7 @@ function Pi(r, e = []) {
8597
8614
  <span class="__crossx-connect-other-desc __crossx-connect-other-summary">${Oi(e)}</span>
8598
8615
  </span>
8599
8616
  </button>` : "", i = document.createElement("div");
8600
- return i.id = J, i.innerHTML = `
8617
+ return i.id = Z, i.innerHTML = `
8601
8618
  <div class="__crossx-card __crossx-card--migration" style="${oe(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
8602
8619
  <div class="__crossx-header">
8603
8620
  <div style="display:flex;flex-direction:column;gap:4px;padding-right:36px;">
@@ -8627,27 +8644,27 @@ function Pi(r, e = []) {
8627
8644
  }
8628
8645
  function Ci(r, e) {
8629
8646
  const s = r, t = document.createElement("div");
8630
- t.id = J;
8631
- const n = C(e.message).replace(/\n/g, "<br>"), i = e.email ? `<div class="__crossx-session-account-card">
8632
- <p class="__crossx-session-account-label">${C(e.accountLabel)}</p>
8633
- <p class="__crossx-session-account-email">${C(e.email)}</p>
8647
+ t.id = Z;
8648
+ const n = L(e.message).replace(/\n/g, "<br>"), i = e.email ? `<div class="__crossx-session-account-card">
8649
+ <p class="__crossx-session-account-label">${L(e.accountLabel)}</p>
8650
+ <p class="__crossx-session-account-email">${L(e.email)}</p>
8634
8651
  </div>` : "";
8635
8652
  return t.innerHTML = `
8636
8653
  <div class="__crossx-card __crossx-card--migration" style="${oe(s)}" role="alertdialog" aria-modal="true" aria-labelledby="__crossx-session-header-title" aria-describedby="__crossx-session-msg">
8637
8654
  <div class="__crossx-header">
8638
- <p class="__crossx-title" id="__crossx-session-header-title">${C(e.title)}</p>
8655
+ <p class="__crossx-title" id="__crossx-session-header-title">${L(e.title)}</p>
8639
8656
  <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ne}</button>
8640
8657
  </div>
8641
8658
  <hr class="__crossx-divider">
8642
8659
  <div class="__crossx-body" style="padding:20px 24px 24px;display:flex;flex-direction:column;gap:16px;">
8643
8660
  <div class="__crossx-session-hero">
8644
- <p class="__crossx-session-hero-title">${C(e.title)}</p>
8661
+ <p class="__crossx-session-hero-title">${L(e.title)}</p>
8645
8662
  <p class="__crossx-session-hero-message" id="__crossx-session-msg">${n}</p>
8646
8663
  </div>
8647
8664
  ${i}
8648
8665
  <div class="__crossx-btn-row">
8649
- <button class="__crossx-cancel-btn" id="__crossx-session-signout">${C(e.signOutLabel)}</button>
8650
- <button class="__crossx-confirm-btn" id="__crossx-session-signin">${C(e.signInAgainLabel)}</button>
8666
+ <button class="__crossx-cancel-btn" id="__crossx-session-signout">${L(e.signOutLabel)}</button>
8667
+ <button class="__crossx-confirm-btn" id="__crossx-session-signin">${L(e.signInAgainLabel)}</button>
8651
8668
  </div>
8652
8669
  </div>
8653
8670
  </div>
@@ -8655,7 +8672,7 @@ function Ci(r, e) {
8655
8672
  }
8656
8673
  function Ni(r, e = !0) {
8657
8674
  const s = r, t = e ? `<button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ne}</button>` : "", n = e ? '<button class="__crossx-skip-btn" id="__crossx-skip-btn">Skip for Now</button>' : "", i = document.createElement("div");
8658
- return i.id = J, i.innerHTML = `
8675
+ return i.id = Z, i.innerHTML = `
8659
8676
  <div class="__crossx-card __crossx-card--migration" style="${oe(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
8660
8677
  <div class="__crossx-header">
8661
8678
  <p class="__crossx-title" id="__crossx-ttl">Wallet Found on Social Account 🎉</p>
@@ -8678,8 +8695,8 @@ function Ni(r, e = !0) {
8678
8695
  `, i;
8679
8696
  }
8680
8697
  function Li(r, e) {
8681
- const s = r, { errorMessage: t, attemptCount: n, maxAttempts: i = 5 } = e ?? {}, o = !!t, a = o ? " --error" : "", c = n != null && n > 0 ? `<p class="__crossx-pin-attempt">${n}/${i}</p>` : "", l = n != null && n >= 3 ? '<p class="__crossx-pin-warning">Your account will be locked after further failures.</p>' : "", u = o ? `<p class="__crossx-pin-error-text">${t}</p>` : "", f = document.createElement("div");
8682
- return f.id = J, f.innerHTML = `
8698
+ const s = r, { errorMessage: t, attemptCount: n, maxAttempts: i = 5 } = e ?? {}, o = !!t, a = o ? " --error" : "", c = n != null && n > 0 ? `<p class="__crossx-pin-attempt">${n}/${i}</p>` : "", l = n != null && n >= 3 ? '<p class="__crossx-pin-warning">Your account will be locked after further failures.</p>' : "", u = o ? `<p class="__crossx-pin-error-text">${t}</p>` : "", p = document.createElement("div");
8699
+ return p.id = Z, p.innerHTML = `
8683
8700
  <div class="__crossx-card __crossx-card--migration" style="${oe(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
8684
8701
  <div class="__crossx-header">
8685
8702
  <p class="__crossx-title" id="__crossx-ttl">Import from Social Backup</p>
@@ -8699,7 +8716,7 @@ function Li(r, e) {
8699
8716
  ${u}
8700
8717
  </div>
8701
8718
  </div>
8702
- `, f;
8719
+ `, p;
8703
8720
  }
8704
8721
  function Di(r) {
8705
8722
  const e = new Date(r), s = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], t = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], n = s[e.getDay()], i = t[e.getMonth()], o = e.getDate(), a = String(e.getHours()).padStart(2, "0"), c = String(e.getMinutes()).padStart(2, "0");
@@ -8707,7 +8724,7 @@ function Di(r) {
8707
8724
  }
8708
8725
  function Mi(r, e, s) {
8709
8726
  const t = r, n = e <= 0, i = n ? null : Date.now() + e * 1e3, o = i ? Di(i) : null, a = document.createElement("div");
8710
- return a.id = J, a.innerHTML = `
8727
+ return a.id = Z, a.innerHTML = `
8711
8728
  <div class="__crossx-card __crossx-card--migration" style="${oe(t)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
8712
8729
  <div class="__crossx-header">
8713
8730
  <p class="__crossx-title" id="__crossx-ttl">Import from Social Backup</p>
@@ -8730,23 +8747,23 @@ function Mi(r, e, s) {
8730
8747
  `, { overlay: a, startCountdown: (l) => {
8731
8748
  if (n || !i) return () => {
8732
8749
  };
8733
- const f = setInterval(() => {
8734
- Date.now() >= i && (clearInterval(f), l());
8750
+ const p = setInterval(() => {
8751
+ Date.now() >= i && (clearInterval(p), l());
8735
8752
  }, 1e3);
8736
- return () => clearInterval(f);
8753
+ return () => clearInterval(p);
8737
8754
  } };
8738
8755
  }
8739
8756
  function $i(r) {
8740
8757
  const s = [r.check1, r.check2].map((t, n) => `
8741
8758
  <div class="__crossx-pw-notice-item" data-check-index="${n}" role="checkbox" aria-checked="false" tabindex="0">
8742
8759
  <div class="__crossx-pw-notice-check" id="__crossx-notice-check-${n}">${Fi}</div>
8743
- <span class="__crossx-pw-notice-item-text">${C(t)}</span>
8760
+ <span class="__crossx-pw-notice-item-text">${L(t)}</span>
8744
8761
  </div>
8745
8762
  `).join("");
8746
8763
  return `
8747
8764
  <div class="__crossx-header">
8748
- <p class="__crossx-title" id="__crossx-ttl" style="padding-right:48px;">${C(r.title)}</p>
8749
- <p class="__crossx-pw-subtitle">${C(r.headerSubtitle)}</p>
8765
+ <p class="__crossx-title" id="__crossx-ttl" style="padding-right:48px;">${L(r.title)}</p>
8766
+ <p class="__crossx-pw-subtitle">${L(r.headerSubtitle)}</p>
8750
8767
  <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ne}</button>
8751
8768
  </div>
8752
8769
  <hr class="__crossx-divider">
@@ -8755,34 +8772,34 @@ function $i(r) {
8755
8772
  <div class="__crossx-pw-notice-header">
8756
8773
  <div class="__crossx-pw-notice-title-row">
8757
8774
  <span class="__crossx-pw-notice-icon">${Wi}</span>
8758
- <p class="__crossx-pw-notice-title">${C(r.noticeTitle)}</p>
8775
+ <p class="__crossx-pw-notice-title">${L(r.noticeTitle)}</p>
8759
8776
  </div>
8760
- <p class="__crossx-pw-notice-desc">${C(r.noticeDesc)}</p>
8777
+ <p class="__crossx-pw-notice-desc">${L(r.noticeDesc)}</p>
8761
8778
  </div>
8762
8779
  <div class="__crossx-pw-notice-checks" id="__crossx-notice-checks">
8763
8780
  ${s}
8764
8781
  </div>
8765
8782
  </div>
8766
8783
  <button class="__crossx-pw-btn --disabled" id="__crossx-pin-notice-next"
8767
- data-next-label="${C(r.nextButton)}"
8768
- data-submit-label="${C(r.submitButton)}">
8769
- ${C(r.nextButton)}
8784
+ data-next-label="${L(r.nextButton)}"
8785
+ data-submit-label="${L(r.submitButton)}">
8786
+ ${L(r.nextButton)}
8770
8787
  </button>
8771
8788
  </div>
8772
8789
  <div class="__crossx-home-indicator"></div>
8773
8790
  `;
8774
8791
  }
8775
8792
  function ut(r) {
8776
- const e = !!r.lockExpiresAt && r.lockExpiresAt > Date.now(), s = r.lockExpiresAt ? ` data-lock-expires="${r.lockExpiresAt}"` : "", t = r.headerSubtitle ? `<p class="__crossx-pin6-header-sub">${C(r.headerSubtitle)}</p>` : "", n = r.subtitle ? `<p class="__crossx-pin6-subtitle">${C(r.subtitle)}</p>` : "", i = r.errorMessage ? `<p class="__crossx-pin6-error" id="__crossx-pin6-error">${C(r.errorMessage)}</p>` : '<p class="__crossx-pin6-error" id="__crossx-pin6-error"></p>', o = e ? `<p class="__crossx-pin6-lock-msg" id="__crossx-pin6-lock-msg">
8793
+ const e = !!r.lockExpiresAt && r.lockExpiresAt > Date.now(), s = r.lockExpiresAt ? ` data-lock-expires="${r.lockExpiresAt}"` : "", t = r.headerSubtitle ? `<p class="__crossx-pin6-header-sub">${L(r.headerSubtitle)}</p>` : "", n = r.subtitle ? `<p class="__crossx-pin6-subtitle">${L(r.subtitle)}</p>` : "", i = r.errorMessage ? `<p class="__crossx-pin6-error" id="__crossx-pin6-error">${L(r.errorMessage)}</p>` : '<p class="__crossx-pin6-error" id="__crossx-pin6-error"></p>', o = e ? `<p class="__crossx-pin6-lock-msg" id="__crossx-pin6-lock-msg">
8777
8794
  ${js}
8778
8795
  <span id="__crossx-pin6-lock-countdown"></span>
8779
- </p>` : "", a = r.warningMessage && r.attemptCount != null && r.attemptCount > 0 ? `<p class="__crossx-pin6-warning" id="__crossx-pin6-warning">${C(r.warningMessage)}</p>` : '<p class="__crossx-pin6-warning" id="__crossx-pin6-warning"></p>', c = r.attemptCount != null && r.attemptCount > 0 ? `<p class="__crossx-pin6-attempt" id="__crossx-pin6-attempt">${r.attemptCount}/${r.maxAttempts ?? "?"}</p>` : '<p class="__crossx-pin6-attempt" id="__crossx-pin6-attempt"></p>', l = e ? " --locked" : "", u = Array.from(
8796
+ </p>` : "", a = r.warningMessage && r.attemptCount != null && r.attemptCount > 0 ? `<p class="__crossx-pin6-warning" id="__crossx-pin6-warning">${L(r.warningMessage)}</p>` : '<p class="__crossx-pin6-warning" id="__crossx-pin6-warning"></p>', c = r.attemptCount != null && r.attemptCount > 0 ? `<p class="__crossx-pin6-attempt" id="__crossx-pin6-attempt">${r.attemptCount}/${r.maxAttempts ?? "?"}</p>` : '<p class="__crossx-pin6-attempt" id="__crossx-pin6-attempt"></p>', l = e ? " --locked" : "", u = Array.from(
8780
8797
  { length: 6 },
8781
- (v, S) => `<input class="__crossx-pin6-box${l}" type="password" maxlength="1" inputmode="numeric" pattern="[0-9]" autocomplete="off" aria-label="PIN digit ${S + 1}"${e ? " disabled" : ""}>`
8782
- ).join(""), f = e ? " --locked" : "", x = Array.from(
8798
+ (b, E) => `<input class="__crossx-pin6-box${l}" type="password" maxlength="1" inputmode="numeric" pattern="[0-9]" autocomplete="off" aria-label="PIN digit ${E + 1}"${e ? " disabled" : ""}>`
8799
+ ).join(""), p = e ? " --locked" : "", x = Array.from(
8783
8800
  { length: 6 },
8784
- (v, S) => `<div class="__crossx-pin6-dot${f}" data-dot-index="${S}" aria-label="PIN digit ${S + 1}"></div>`
8785
- ).join(""), _ = e ? " --disabled" : "", p = `
8801
+ (b, E) => `<div class="__crossx-pin6-dot${p}" data-dot-index="${E}" aria-label="PIN digit ${E + 1}"></div>`
8802
+ ).join(""), _ = e ? " --disabled" : "", f = `
8786
8803
  <div class="__crossx-pin6-numpad" id="__crossx-pin6-numpad">
8787
8804
  <div class="__crossx-pin6-numpad-row">
8788
8805
  <button type="button" class="__crossx-pin6-numpad-key${_}" data-key="1">1</button>
@@ -8807,7 +8824,7 @@ function ut(r) {
8807
8824
  </div>`;
8808
8825
  return `
8809
8826
  <div class="__crossx-header">
8810
- <p class="__crossx-title" id="__crossx-ttl" style="padding-right:48px;">${C(r.title)}</p>
8827
+ <p class="__crossx-title" id="__crossx-ttl" style="padding-right:48px;">${L(r.title)}</p>
8811
8828
  ${t}
8812
8829
  <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ne}</button>
8813
8830
  </div>
@@ -8825,12 +8842,12 @@ function ut(r) {
8825
8842
  ${c}
8826
8843
  ${o}
8827
8844
  </div>
8828
- ${p}
8845
+ ${f}
8829
8846
  `;
8830
8847
  }
8831
8848
  function os(r, e) {
8832
8849
  const s = document.createElement("div");
8833
- return s.id = J, s.innerHTML = `
8850
+ return s.id = Z, s.innerHTML = `
8834
8851
  <div class="__crossx-card __crossx-card--pin6" style="${oe(r)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
8835
8852
  ${e}
8836
8853
  </div>
@@ -8848,178 +8865,178 @@ function Ui(r) {
8848
8865
  return s > 0 ? `${s}h ${String(t).padStart(2, "0")}m` : `${String(t).padStart(2, "0")}:${String(n).padStart(2, "0")}`;
8849
8866
  }
8850
8867
  function ht(r, e, s, t, n, i, o) {
8851
- var O, M;
8868
+ var O, $;
8852
8869
  let a = !!(i && i > Date.now()), c = !1;
8853
- const l = () => Array.from(r.querySelectorAll(".__crossx-pin6-box")), u = () => r.querySelector("#__crossx-pin6-boxes"), f = () => r.querySelector("#__crossx-pin6-error"), x = () => r.querySelector("#__crossx-pin6-lock-msg"), _ = () => r.querySelector("#__crossx-pin6-lock-countdown"), p = () => r.querySelector(".__crossx-pin6-body"), v = () => l().map((y) => y.value).join(""), S = () => Array.from(r.querySelectorAll(".__crossx-pin6-dot")), I = () => {
8854
- var E;
8855
- const y = l(), b = S();
8856
- if (b.length && (b.forEach((A, R) => {
8857
- const F = !!(y[R] && y[R].value);
8870
+ const l = () => Array.from(r.querySelectorAll(".__crossx-pin6-box")), u = () => r.querySelector("#__crossx-pin6-boxes"), p = () => r.querySelector("#__crossx-pin6-error"), x = () => r.querySelector("#__crossx-pin6-lock-msg"), _ = () => r.querySelector("#__crossx-pin6-lock-countdown"), f = () => r.querySelector(".__crossx-pin6-body"), b = () => l().map((y) => y.value).join(""), E = () => Array.from(r.querySelectorAll(".__crossx-pin6-dot")), k = () => {
8871
+ var v;
8872
+ const y = l(), S = E();
8873
+ if (S.length && (S.forEach((A, T) => {
8874
+ const F = !!(y[T] && y[T].value);
8858
8875
  A.classList.toggle("--filled", F), A.classList.toggle("--active", !1);
8859
8876
  }), !a && !c)) {
8860
8877
  const A = y.findIndex((F) => !F.value);
8861
- (E = b[A === -1 ? 5 : A]) == null || E.classList.add("--active");
8878
+ (v = S[A === -1 ? 5 : A]) == null || v.classList.add("--active");
8862
8879
  }
8863
- }, T = () => {
8864
- r.querySelectorAll(".__crossx-pin6-numpad-key[data-key]").forEach((b) => b.classList.toggle("--disabled", a)), S().forEach((b) => b.classList.toggle("--locked", a)), I();
8865
- }, B = (y) => {
8866
- a = y, l().forEach((b) => {
8867
- b.disabled = y, b.classList.toggle("--locked", y);
8880
+ }, P = () => {
8881
+ r.querySelectorAll(".__crossx-pin6-numpad-key[data-key]").forEach((S) => S.classList.toggle("--disabled", a)), E().forEach((S) => S.classList.toggle("--locked", a)), k();
8882
+ }, R = (y) => {
8883
+ a = y, l().forEach((S) => {
8884
+ S.disabled = y, S.classList.toggle("--locked", y);
8868
8885
  });
8869
- }, D = () => r.querySelector("#__crossx-pin6-attempt"), K = () => {
8870
- const y = f();
8886
+ }, N = () => r.querySelector("#__crossx-pin6-attempt"), W = () => {
8887
+ const y = p();
8871
8888
  y && (y.textContent = "");
8872
- }, q = () => o ?? "Your account will be locked after further failures.", Z = () => r.querySelector("#__crossx-pin6-warning"), W = (y) => {
8873
- var E;
8874
- let b = Z();
8875
- if (!b) {
8876
- b = document.createElement("p"), b.className = "__crossx-pin6-warning", b.id = "__crossx-pin6-warning";
8877
- const A = f();
8878
- A ? A.insertAdjacentElement("afterend", b) : (E = p()) == null || E.appendChild(b);
8879
- }
8880
- b.textContent = y;
8889
+ }, q = () => o ?? "Your account will be locked after further failures.", J = () => r.querySelector("#__crossx-pin6-warning"), G = (y) => {
8890
+ var v;
8891
+ let S = J();
8892
+ if (!S) {
8893
+ S = document.createElement("p"), S.className = "__crossx-pin6-warning", S.id = "__crossx-pin6-warning";
8894
+ const A = p();
8895
+ A ? A.insertAdjacentElement("afterend", S) : (v = f()) == null || v.appendChild(S);
8896
+ }
8897
+ S.textContent = y;
8881
8898
  }, X = () => {
8882
- const y = Z();
8899
+ const y = J();
8883
8900
  y && (y.textContent = "");
8884
- }, Q = (y, b) => {
8901
+ }, Q = (y, S) => {
8885
8902
  var A;
8886
- let E = D();
8887
- if (!E) {
8888
- E = document.createElement("p"), E.className = "__crossx-pin6-attempt", E.id = "__crossx-pin6-attempt";
8889
- const R = Z() ?? f();
8890
- R ? R.insertAdjacentElement("afterend", E) : (A = p()) == null || A.appendChild(E);
8903
+ let v = N();
8904
+ if (!v) {
8905
+ v = document.createElement("p"), v.className = "__crossx-pin6-attempt", v.id = "__crossx-pin6-attempt";
8906
+ const T = J() ?? p();
8907
+ T ? T.insertAdjacentElement("afterend", v) : (A = f()) == null || A.appendChild(v);
8891
8908
  }
8892
- E.textContent = `${y}/${b}`;
8909
+ v.textContent = `${y}/${S}`;
8893
8910
  }, H = () => {
8894
- const y = D();
8911
+ const y = N();
8895
8912
  y && (y.textContent = "");
8896
- }, N = (y) => {
8897
- const b = f();
8898
- b && (b.textContent = y);
8899
- const E = u();
8900
- E == null || E.classList.add("--shake"), setTimeout(() => E == null ? void 0 : E.classList.remove("--shake"), 500), l().forEach((A) => {
8913
+ }, D = (y) => {
8914
+ const S = p();
8915
+ S && (S.textContent = y);
8916
+ const v = u();
8917
+ v == null || v.classList.add("--shake"), setTimeout(() => v == null ? void 0 : v.classList.remove("--shake"), 500), l().forEach((A) => {
8901
8918
  A.value = "";
8902
8919
  }), setTimeout(() => {
8903
8920
  var A;
8904
- (A = l()[0]) == null || A.focus(), I();
8921
+ (A = l()[0]) == null || A.focus(), k();
8905
8922
  }, 50);
8906
- }, $ = (y) => {
8923
+ }, B = (y) => {
8907
8924
  var F;
8908
- B(!0), l().forEach((U) => {
8925
+ R(!0), l().forEach((U) => {
8909
8926
  U.value = "";
8910
- }), T();
8911
- const b = f();
8912
- if (b && (b.textContent = "Too many failed attempts. Please wait."), !x()) {
8927
+ }), P();
8928
+ const S = p();
8929
+ if (S && (S.textContent = "Too many failed attempts. Please wait."), !x()) {
8913
8930
  const U = document.createElement("p");
8914
8931
  U.className = "__crossx-pin6-lock-msg", U.id = "__crossx-pin6-lock-msg", U.innerHTML = `${js}<span id="__crossx-pin6-lock-countdown"></span>`;
8915
- const L = f();
8916
- L ? L.insertAdjacentElement("afterend", U) : (F = p()) == null || F.appendChild(U);
8932
+ const M = p();
8933
+ M ? M.insertAdjacentElement("afterend", U) : (F = f()) == null || F.appendChild(U);
8917
8934
  }
8918
- const E = () => {
8919
- var G;
8920
- const U = y - Date.now(), L = _();
8921
- U <= 0 ? (clearInterval(A), B(!1), (G = x()) == null || G.remove(), b && (b.textContent = ""), T(), setTimeout(() => {
8935
+ const v = () => {
8936
+ var K;
8937
+ const U = y - Date.now(), M = _();
8938
+ U <= 0 ? (clearInterval(A), R(!1), (K = x()) == null || K.remove(), S && (S.textContent = ""), P(), setTimeout(() => {
8922
8939
  var Y;
8923
8940
  return (Y = l()[0]) == null ? void 0 : Y.focus();
8924
- }, 50)) : L && (L.textContent = ` ${Ui(U)}`);
8925
- }, A = setInterval(E, 1e3);
8926
- E();
8927
- const R = new MutationObserver(() => {
8928
- document.contains(r) || (clearInterval(A), R.disconnect());
8941
+ }, 50)) : M && (M.textContent = ` ${Ui(U)}`);
8942
+ }, A = setInterval(v, 1e3);
8943
+ v();
8944
+ const T = new MutationObserver(() => {
8945
+ document.contains(r) || (clearInterval(A), T.disconnect());
8929
8946
  });
8930
- R.observe(document.body, { childList: !0, subtree: !1 });
8947
+ T.observe(document.body, { childList: !0, subtree: !1 });
8931
8948
  }, m = async () => {
8932
8949
  if (a || c) return;
8933
- const y = v();
8950
+ const y = b();
8934
8951
  if (y.length === 6) {
8935
- c = !0, l().forEach((b) => {
8936
- b.disabled = !0;
8952
+ c = !0, l().forEach((S) => {
8953
+ S.disabled = !0;
8937
8954
  });
8938
8955
  try {
8939
8956
  if (n) {
8940
- const b = await n(y);
8941
- b.ok ? e(y) : b.lockExpiresAt ? (H(), $(b.lockExpiresAt)) : (N(b.error ?? "Incorrect PIN. Please try again."), b.attemptCount != null && b.maxAttempts != null ? (W(q()), Q(b.attemptCount, b.maxAttempts)) : (X(), H()));
8957
+ const S = await n(y);
8958
+ S.ok ? e(y) : S.lockExpiresAt ? (H(), B(S.lockExpiresAt)) : (D(S.error ?? "Incorrect PIN. Please try again."), S.attemptCount != null && S.maxAttempts != null ? (G(q()), Q(S.attemptCount, S.maxAttempts)) : (X(), H()));
8942
8959
  } else
8943
8960
  e(y);
8944
- } catch (b) {
8945
- t && t(b);
8961
+ } catch (S) {
8962
+ t && t(S);
8946
8963
  } finally {
8947
- c = !1, a || l().forEach((b) => {
8948
- b.disabled = !1;
8949
- }), I();
8964
+ c = !1, a || l().forEach((S) => {
8965
+ S.disabled = !1;
8966
+ }), k();
8950
8967
  }
8951
8968
  }
8952
8969
  };
8953
- i && i > Date.now() ? $(i) : setTimeout(() => {
8970
+ i && i > Date.now() ? B(i) : setTimeout(() => {
8954
8971
  var y;
8955
8972
  return (y = l()[0]) == null ? void 0 : y.focus();
8956
8973
  }, 100);
8957
8974
  const w = () => {
8958
8975
  if (a || c) return;
8959
- const y = l(), b = y.find((E) => !E.value) ?? y[y.length - 1];
8960
- b == null || b.focus();
8976
+ const y = l(), S = y.find((v) => !v.value) ?? y[y.length - 1];
8977
+ S == null || S.focus();
8961
8978
  };
8962
8979
  (O = u()) == null || O.addEventListener("click", (y) => {
8963
8980
  y.target.classList.contains("__crossx-pin6-box") || w();
8964
- }), (M = p()) == null || M.addEventListener("click", (y) => {
8965
- const b = y.target;
8966
- b.classList.contains("__crossx-pin6-box") || b.closest("button") || w();
8967
- }), l().forEach((y, b) => {
8981
+ }), ($ = f()) == null || $.addEventListener("click", (y) => {
8982
+ const S = y.target;
8983
+ S.classList.contains("__crossx-pin6-box") || S.closest("button") || w();
8984
+ }), l().forEach((y, S) => {
8968
8985
  y.addEventListener("input", () => {
8969
8986
  var A;
8970
- const E = y.value.replace(/\D/g, "").slice(-1);
8971
- y.value = E, K(), E && b < 5 && ((A = l()[b + 1]) == null || A.focus()), I(), v().length === 6 && setTimeout(m, 80);
8972
- }), y.addEventListener("keydown", (E) => {
8973
- var A, R;
8974
- if (E.key === "Backspace") {
8975
- if (E.preventDefault(), y.value)
8987
+ const v = y.value.replace(/\D/g, "").slice(-1);
8988
+ y.value = v, W(), v && S < 5 && ((A = l()[S + 1]) == null || A.focus()), k(), b().length === 6 && setTimeout(m, 80);
8989
+ }), y.addEventListener("keydown", (v) => {
8990
+ var A, T;
8991
+ if (v.key === "Backspace") {
8992
+ if (v.preventDefault(), y.value)
8976
8993
  y.value = "";
8977
- else if (b > 0) {
8978
- const F = l()[b - 1];
8994
+ else if (S > 0) {
8995
+ const F = l()[S - 1];
8979
8996
  F.value = "", F.focus();
8980
8997
  }
8981
- I();
8982
- } else E.key === "ArrowLeft" && b > 0 ? (E.preventDefault(), (A = l()[b - 1]) == null || A.focus()) : E.key === "ArrowRight" && b < 5 ? (E.preventDefault(), (R = l()[b + 1]) == null || R.focus()) : E.key === "Escape" && s();
8983
- }), y.addEventListener("paste", (E) => {
8998
+ k();
8999
+ } else v.key === "ArrowLeft" && S > 0 ? (v.preventDefault(), (A = l()[S - 1]) == null || A.focus()) : v.key === "ArrowRight" && S < 5 ? (v.preventDefault(), (T = l()[S + 1]) == null || T.focus()) : v.key === "Escape" && s();
9000
+ }), y.addEventListener("paste", (v) => {
8984
9001
  var F, U;
8985
- E.preventDefault();
8986
- const A = (((F = E.clipboardData) == null ? void 0 : F.getData("text")) ?? "").replace(/\D/g, "").slice(0, 6);
9002
+ v.preventDefault();
9003
+ const A = (((F = v.clipboardData) == null ? void 0 : F.getData("text")) ?? "").replace(/\D/g, "").slice(0, 6);
8987
9004
  if (!A) return;
8988
- const R = l();
8989
- A.split("").forEach((L, G) => {
8990
- R[G] && (R[G].value = L);
8991
- }), (U = R[Math.min(A.length - 1, 5)]) == null || U.focus(), K(), I(), v().length === 6 && setTimeout(m, 80);
9005
+ const T = l();
9006
+ A.split("").forEach((M, K) => {
9007
+ T[K] && (T[K].value = M);
9008
+ }), (U = T[Math.min(A.length - 1, 5)]) == null || U.focus(), W(), k(), b().length === 6 && setTimeout(m, 80);
8992
9009
  }), y.addEventListener("focus", () => y.select());
8993
9010
  });
8994
- const k = r.querySelector("#__crossx-pin6-numpad");
8995
- if (k) {
9011
+ const I = r.querySelector("#__crossx-pin6-numpad");
9012
+ if (I) {
8996
9013
  let y = null;
8997
- const b = () => {
9014
+ const S = () => {
8998
9015
  y && (y.classList.remove("--pressed"), y = null);
8999
9016
  };
9000
- k.addEventListener("pointerdown", (A) => {
9001
- const R = A.target.closest(".__crossx-pin6-numpad-key");
9002
- !R || a || c || (b(), y = R, R.classList.add("--pressed"), R.setPointerCapture(A.pointerId));
9017
+ I.addEventListener("pointerdown", (A) => {
9018
+ const T = A.target.closest(".__crossx-pin6-numpad-key");
9019
+ !T || a || c || (S(), y = T, T.classList.add("--pressed"), T.setPointerCapture(A.pointerId));
9003
9020
  });
9004
- const E = (A) => {
9005
- const R = A.dataset.key;
9006
- if (!R) return;
9007
- if (R === "backspace") {
9008
- const G = [...l()].reverse().find((Y) => Y.value);
9009
- G && (G.value = "", K()), I();
9021
+ const v = (A) => {
9022
+ const T = A.dataset.key;
9023
+ if (!T) return;
9024
+ if (T === "backspace") {
9025
+ const K = [...l()].reverse().find((Y) => Y.value);
9026
+ K && (K.value = "", W()), k();
9010
9027
  return;
9011
9028
  }
9012
- if (!/^\d$/.test(R)) return;
9013
- const U = l().find((L) => !L.value);
9014
- U && (U.value = R, K(), I(), v().length === 6 && setTimeout(m, 80));
9029
+ if (!/^\d$/.test(T)) return;
9030
+ const U = l().find((M) => !M.value);
9031
+ U && (U.value = T, W(), k(), b().length === 6 && setTimeout(m, 80));
9015
9032
  };
9016
- k.addEventListener("pointerup", (A) => {
9033
+ I.addEventListener("pointerup", (A) => {
9017
9034
  if (!y) return;
9018
- const R = y;
9019
- b();
9020
- const F = R.getBoundingClientRect();
9021
- A.clientX >= F.left && A.clientX <= F.right && A.clientY >= F.top && A.clientY <= F.bottom && !a && !c && E(R);
9022
- }), k.addEventListener("pointercancel", b), k.addEventListener("pointerleave", b, !0), I(), i && i > Date.now() && T();
9035
+ const T = y;
9036
+ S();
9037
+ const F = T.getBoundingClientRect();
9038
+ A.clientX >= F.left && A.clientX <= F.right && A.clientY >= F.top && A.clientY <= F.bottom && !a && !c && v(T);
9039
+ }), I.addEventListener("pointercancel", S), I.addEventListener("pointerleave", S, !0), k(), i && i > Date.now() && P();
9023
9040
  }
9024
9041
  }
9025
9042
  const Hi = `<svg width="22" height="17" viewBox="0 0 22 17" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -9047,9 +9064,9 @@ function Gi(r, e, s) {
9047
9064
  }), o.addEventListener("keypress", (c) => {
9048
9065
  /[0-9]/.test(c.key) || c.preventDefault();
9049
9066
  }), o.addEventListener("paste", (c) => {
9050
- var f;
9067
+ var p;
9051
9068
  c.preventDefault();
9052
- const l = (((f = c.clipboardData) == null ? void 0 : f.getData("text")) ?? "").replace(/\D/g, "").slice(0, 4);
9069
+ const l = (((p = c.clipboardData) == null ? void 0 : p.getData("text")) ?? "").replace(/\D/g, "").slice(0, 4);
9053
9070
  if (!l) return;
9054
9071
  l.split("").forEach((x, _) => {
9055
9072
  t[_] && (t[_].value = x);
@@ -9083,53 +9100,81 @@ class qi {
9083
9100
  * 지갑 선택 팝업: "Select Connected Wallet"
9084
9101
  * 지갑 목록을 표시하고, 사용자가 선택하거나 새 지갑을 추가할 수 있습니다.
9085
9102
  * 모달은 지갑을 선택하거나 X를 누를 때까지 유지됩니다.
9103
+ *
9104
+ * 새 계정 추가(`onAddWallet`) 실패 시:
9105
+ * - 모달 내부에 inline 에러 메시지를 노출합니다.
9106
+ * - `ADDRESS_LIMIT_EXCEEDED`(-10036) 인 경우 Add 버튼을 영구 비활성화합니다.
9107
+ * - 사용자가 기존 계정을 선택하면 정상 resolve, 모달을 닫으면 reject로 에러를
9108
+ * 호출자에게 전달합니다(throws). 호출자는 별도 처리(로깅/토스트 등)에 사용할 수 있습니다.
9086
9109
  */
9087
9110
  showWalletSelector(e, s, t) {
9088
- return new Promise((n) => {
9089
- var v;
9111
+ return new Promise((n, i) => {
9112
+ var P;
9090
9113
  ce();
9091
- const i = [...e], o = Ii(i, this.tokens, t), a = Oe();
9092
- le(o);
9093
- let c = !1;
9094
- const l = () => {
9095
- c || (c = !0, o.remove(), a());
9096
- }, u = (S) => {
9097
- l(), n(S);
9098
- }, f = () => {
9099
- l(), n(null);
9114
+ const o = [...e], a = Ii(o, this.tokens, t), c = Oe();
9115
+ le(a);
9116
+ let l = !1;
9117
+ const u = () => {
9118
+ l || (l = !0, a.remove(), c());
9119
+ };
9120
+ let p = null;
9121
+ const x = (R) => {
9122
+ u(), n(R);
9123
+ }, _ = () => {
9124
+ u(), p ? i(p) : n(null);
9100
9125
  };
9101
9126
  (() => {
9102
- o.querySelectorAll(".__crossx-wallet-item").forEach((S) => {
9103
- S.addEventListener("click", () => {
9104
- const I = S.dataset.walletAddress ?? "", T = parseInt(S.dataset.walletIndex ?? "0", 10), B = i.find((D) => D.index === T);
9105
- u({ address: I, index: T, name: B == null ? void 0 : B.name });
9127
+ a.querySelectorAll(".__crossx-wallet-item").forEach((R) => {
9128
+ R.addEventListener("click", () => {
9129
+ const N = R.dataset.walletAddress ?? "", W = parseInt(R.dataset.walletIndex ?? "0", 10), q = o.find((J) => J.index === W);
9130
+ x({ address: N, index: W, name: q == null ? void 0 : q.name });
9106
9131
  });
9107
9132
  });
9108
9133
  })();
9109
- const _ = o.querySelector("#__crossx-add-wallet-btn");
9110
- _ && _.addEventListener("click", async () => {
9111
- _.disabled = !0;
9134
+ const b = a.querySelector("#__crossx-add-wallet-error"), E = a.querySelector("#__crossx-add-wallet-btn");
9135
+ E && E.addEventListener("click", async () => {
9136
+ E.disabled = !0, b && (b.hidden = !0, b.textContent = "");
9112
9137
  try {
9113
- const S = await s();
9114
- i.push(S);
9115
- const I = o.querySelector("#__crossx-wallet-list");
9116
- if (I) {
9117
- const T = document.createElement("button");
9118
- T.className = "__crossx-wallet-item", T.dataset.walletIndex = String(S.index), T.dataset.walletAddress = S.address, T.innerHTML = `${zs(S.address, S.index, this.tokens.bg)}<span class="__crossx-wallet-info"><span class="__crossx-wallet-idx">${C(Vs(S))}</span><span class="__crossx-wallet-addr">${se(S.address)}</span></span>`, T.addEventListener("click", () => u(S)), I.appendChild(T), T.scrollIntoView({ behavior: "smooth", block: "nearest" });
9138
+ const R = await s();
9139
+ o.push(R);
9140
+ const N = a.querySelector("#__crossx-wallet-list");
9141
+ if (N) {
9142
+ const W = document.createElement("button");
9143
+ W.className = "__crossx-wallet-item", W.dataset.walletIndex = String(R.index), W.dataset.walletAddress = R.address, W.innerHTML = `${zs(R.address, R.index, this.tokens.bg)}<span class="__crossx-wallet-info"><span class="__crossx-wallet-idx">${L(Vs(R))}</span><span class="__crossx-wallet-addr">${se(R.address)}</span></span>`, W.addEventListener("click", () => x(R)), N.appendChild(W);
9144
+ try {
9145
+ W.scrollIntoView({ behavior: "smooth", block: "nearest" });
9146
+ } catch {
9147
+ }
9119
9148
  }
9120
- } catch {
9121
- } finally {
9122
- _.disabled = !1;
9149
+ E.disabled = !1;
9150
+ } catch (R) {
9151
+ const N = R instanceof g && R.code === h.ADDRESS_LIMIT_EXCEEDED, W = this.resolveAddWalletErrorMessage(R);
9152
+ b && (b.textContent = W, b.hidden = !1), N ? (E.disabled = !0, E.setAttribute("aria-disabled", "true")) : E.disabled = !1, p = R;
9123
9153
  }
9124
- }), (v = o.querySelector("#__crossx-close-btn")) == null || v.addEventListener("click", f), o.addEventListener("click", (S) => {
9125
- S.target === o && f();
9154
+ }), (P = a.querySelector("#__crossx-close-btn")) == null || P.addEventListener("click", _), a.addEventListener("click", (R) => {
9155
+ R.target === a && _();
9126
9156
  });
9127
- const p = (S) => {
9128
- S.key === "Escape" && (document.removeEventListener("keydown", p), f());
9157
+ const k = (R) => {
9158
+ R.key === "Escape" && (document.removeEventListener("keydown", k), _());
9129
9159
  };
9130
- document.addEventListener("keydown", p);
9160
+ document.addEventListener("keydown", k);
9131
9161
  });
9132
9162
  }
9163
+ /**
9164
+ * `onAddWallet()` 실패 시 모달에 표시할 사용자 안내 문자열을 결정합니다.
9165
+ * - `ADDRESS_LIMIT_EXCEEDED` (-10036): 한도 안내 (`{limit}` 치환)
9166
+ * - 그 외: 일반 재시도 안내
9167
+ *
9168
+ * `setMessages`로 전달된 i18n 문자열이 우선이며, 미설정 시 영문 디폴트를 사용합니다.
9169
+ */
9170
+ resolveAddWalletErrorMessage(e) {
9171
+ const s = this.messages;
9172
+ if (e instanceof g && e.code === h.ADDRESS_LIMIT_EXCEEDED) {
9173
+ const n = e.details, i = typeof (n == null ? void 0 : n.limit) == "number" ? n.limit : ft;
9174
+ return ((s == null ? void 0 : s.walletSelector_addError_limitExceeded) ?? "Account limit reached. Maximum {limit} accounts allowed.").replace("{limit}", String(i));
9175
+ }
9176
+ return (s == null ? void 0 : s.walletSelector_addError_generic) ?? "Failed to add a new account. Please try again.";
9177
+ }
9133
9178
  /**
9134
9179
  * 로그인 프로바이더 선택 팝업: "CROSS Wallet"
9135
9180
  * Apple / Google 버튼을 표시하고 선택된 프로바이더를 반환합니다.
@@ -9141,36 +9186,36 @@ class qi {
9141
9186
  (n) => Object.values(Ue).includes(n) && String(n).trim() !== ""
9142
9187
  )) ?? [];
9143
9188
  return new Promise((n) => {
9144
- var x, _, p, v;
9189
+ var x, _, f, b;
9145
9190
  ce();
9146
9191
  const i = Pi(this.tokens, s), o = Oe();
9147
9192
  le(i);
9148
9193
  const a = () => {
9149
9194
  i.remove(), o();
9150
- }, c = (S) => {
9151
- a(), n({ type: "oauth", provider: S });
9152
- }, l = (S) => {
9153
- a(), n({ type: "external", walletId: S });
9195
+ }, c = (E) => {
9196
+ a(), n({ type: "oauth", provider: E });
9197
+ }, l = (E) => {
9198
+ a(), n({ type: "external", walletId: E });
9154
9199
  }, u = () => {
9155
9200
  a(), n(null);
9156
9201
  };
9157
- (x = i.querySelector("#__crossx-apple-btn")) == null || x.addEventListener("click", () => c("apple")), (_ = i.querySelector("#__crossx-google-btn")) == null || _.addEventListener("click", () => c("google")), (p = i.querySelector("#__crossx-connect-other-wallet-btn")) == null || p.addEventListener("click", (S) => {
9158
- const T = S.currentTarget.dataset.walletId ?? "";
9159
- T && l(T);
9160
- }), (v = i.querySelector("#__crossx-close-btn")) == null || v.addEventListener("click", u), i.addEventListener("click", (S) => {
9161
- S.target === i && u();
9162
- }), i.querySelectorAll(".__crossx-login-terms-link").forEach((S) => {
9163
- S.addEventListener("click", (I) => I.stopPropagation());
9202
+ (x = i.querySelector("#__crossx-apple-btn")) == null || x.addEventListener("click", () => c("apple")), (_ = i.querySelector("#__crossx-google-btn")) == null || _.addEventListener("click", () => c("google")), (f = i.querySelector("#__crossx-connect-other-wallet-btn")) == null || f.addEventListener("click", (E) => {
9203
+ const P = E.currentTarget.dataset.walletId ?? "";
9204
+ P && l(P);
9205
+ }), (b = i.querySelector("#__crossx-close-btn")) == null || b.addEventListener("click", u), i.addEventListener("click", (E) => {
9206
+ E.target === i && u();
9207
+ }), i.querySelectorAll(".__crossx-login-terms-link").forEach((E) => {
9208
+ E.addEventListener("click", (k) => k.stopPropagation());
9164
9209
  });
9165
- const f = (S) => {
9166
- S.key === "Escape" && (document.removeEventListener("keydown", f), u());
9210
+ const p = (E) => {
9211
+ E.key === "Escape" && (document.removeEventListener("keydown", p), u());
9167
9212
  };
9168
- document.addEventListener("keydown", f);
9213
+ document.addEventListener("keydown", p);
9169
9214
  });
9170
9215
  }
9171
9216
  showSessionAlert(e) {
9172
9217
  return new Promise((s) => {
9173
- var u, f, x;
9218
+ var u, p, x;
9174
9219
  ce();
9175
9220
  const t = this.messages, n = Ci(this.tokens, {
9176
9221
  title: e.title,
@@ -9189,7 +9234,7 @@ class qi {
9189
9234
  }, l = () => {
9190
9235
  a(), s("signin-again");
9191
9236
  };
9192
- (u = n.querySelector("#__crossx-session-signout")) == null || u.addEventListener("click", c), (f = n.querySelector("#__crossx-session-signin")) == null || f.addEventListener("click", l), (x = n.querySelector("#__crossx-close-btn")) == null || x.addEventListener("click", c);
9237
+ (u = n.querySelector("#__crossx-session-signout")) == null || u.addEventListener("click", c), (p = n.querySelector("#__crossx-session-signin")) == null || p.addEventListener("click", l), (x = n.querySelector("#__crossx-close-btn")) == null || x.addEventListener("click", c);
9193
9238
  });
9194
9239
  }
9195
9240
  /**
@@ -9214,10 +9259,10 @@ class qi {
9214
9259
  (c = n.querySelector("#__crossx-skip-btn")) == null || c.addEventListener("click", u), (l = n.querySelector("#__crossx-close-btn")) == null || l.addEventListener("click", u), n.addEventListener("click", (x) => {
9215
9260
  x.target === n && u();
9216
9261
  });
9217
- const f = (x) => {
9218
- x.key === "Escape" && (document.removeEventListener("keydown", f), u());
9262
+ const p = (x) => {
9263
+ x.key === "Escape" && (document.removeEventListener("keydown", p), u());
9219
9264
  };
9220
- document.addEventListener("keydown", f);
9265
+ document.addEventListener("keydown", p);
9221
9266
  }
9222
9267
  });
9223
9268
  }
@@ -9253,76 +9298,76 @@ class qi {
9253
9298
  let l = !1;
9254
9299
  const u = () => {
9255
9300
  l || (l = !0, a.remove(), c());
9256
- }, f = (T) => {
9257
- u(), s(T);
9301
+ }, p = (P) => {
9302
+ u(), s(P);
9258
9303
  }, x = () => {
9259
9304
  u(), s(null);
9260
- }, _ = a.querySelector(".__crossx-card"), p = {
9305
+ }, _ = a.querySelector(".__crossx-card"), f = {
9261
9306
  tooShort: (t == null ? void 0 : t.pinValidation_tooShort) ?? "Please enter a 6-digit PIN.",
9262
9307
  numbersOnly: (t == null ? void 0 : t.pinValidation_numbersOnly) ?? "Only numbers (0-9) are allowed.",
9263
9308
  repeatingDigit: (t == null ? void 0 : t.pinValidation_repeatingDigit) ?? "Cannot use the same number 3+ times in a row.",
9264
9309
  sequential: (t == null ? void 0 : t.pinValidation_sequential) ?? "Sequential numbers (e.g., 123456) are not allowed.",
9265
9310
  alternatingPattern: (t == null ? void 0 : t.pinValidation_alternatingPattern) ?? "Repeating patterns (e.g., 121212) are not allowed."
9266
- }, v = (T) => {
9267
- var B;
9311
+ }, b = (P) => {
9312
+ var R;
9268
9313
  _.innerHTML = ut({
9269
9314
  title: o.title,
9270
9315
  headerSubtitle: o.headerSubtitle
9271
- }), (B = _.querySelector("#__crossx-close-btn")) == null || B.addEventListener("click", x), ht(_, (D) => {
9272
- D === T ? f(T) : S(i.mismatchError);
9316
+ }), (R = _.querySelector("#__crossx-close-btn")) == null || R.addEventListener("click", x), ht(_, (N) => {
9317
+ N === P ? p(P) : E(i.mismatchError);
9273
9318
  }, x);
9274
- }, S = (T) => {
9275
- var B;
9319
+ }, E = (P) => {
9320
+ var R;
9276
9321
  _.innerHTML = ut({
9277
9322
  title: i.title,
9278
9323
  headerSubtitle: i.headerSubtitle,
9279
9324
  subtitle: i.subtitle,
9280
- errorMessage: T
9281
- }), (B = _.querySelector("#__crossx-close-btn")) == null || B.addEventListener("click", x), ht(_, (D) => {
9282
- const K = Bi(D, p);
9283
- K ? S(K) : v(D);
9325
+ errorMessage: P
9326
+ }), (R = _.querySelector("#__crossx-close-btn")) == null || R.addEventListener("click", x), ht(_, (N) => {
9327
+ const W = Bi(N, f);
9328
+ W ? E(W) : b(N);
9284
9329
  }, x);
9285
9330
  };
9286
9331
  (() => {
9287
9332
  var Q;
9288
- const T = Array.from(_.querySelectorAll(".__crossx-pw-notice-item")), B = _.querySelector("#__crossx-pin-notice-next"), D = /* @__PURE__ */ new Set();
9289
- B.removeAttribute("disabled");
9290
- const K = B.dataset.nextLabel ?? "Next", q = B.dataset.submitLabel ?? "I Understand", Z = () => {
9291
- const H = D.size === T.length;
9292
- B.classList.toggle("--disabled", !H), B.textContent = H ? q : K;
9293
- }, W = (H, N) => {
9294
- if (D.has(N)) return;
9295
- const $ = H.querySelector(`#__crossx-notice-check-${N}`);
9296
- D.add(N), $.classList.add("--checked"), H.setAttribute("aria-checked", "true"), Z();
9297
- }, X = (H, N) => {
9298
- if (!D.has(N)) return;
9299
- const $ = H.querySelector(`#__crossx-notice-check-${N}`);
9300
- D.delete(N), $.classList.remove("--checked"), H.setAttribute("aria-checked", "false"), Z();
9333
+ const P = Array.from(_.querySelectorAll(".__crossx-pw-notice-item")), R = _.querySelector("#__crossx-pin-notice-next"), N = /* @__PURE__ */ new Set();
9334
+ R.removeAttribute("disabled");
9335
+ const W = R.dataset.nextLabel ?? "Next", q = R.dataset.submitLabel ?? "I Understand", J = () => {
9336
+ const H = N.size === P.length;
9337
+ R.classList.toggle("--disabled", !H), R.textContent = H ? q : W;
9338
+ }, G = (H, D) => {
9339
+ if (N.has(D)) return;
9340
+ const B = H.querySelector(`#__crossx-notice-check-${D}`);
9341
+ N.add(D), B.classList.add("--checked"), H.setAttribute("aria-checked", "true"), J();
9342
+ }, X = (H, D) => {
9343
+ if (!N.has(D)) return;
9344
+ const B = H.querySelector(`#__crossx-notice-check-${D}`);
9345
+ N.delete(D), B.classList.remove("--checked"), H.setAttribute("aria-checked", "false"), J();
9301
9346
  };
9302
- T.forEach((H) => {
9303
- const N = parseInt(H.dataset.checkIndex ?? "0", 10);
9347
+ P.forEach((H) => {
9348
+ const D = parseInt(H.dataset.checkIndex ?? "0", 10);
9304
9349
  H.addEventListener("click", () => {
9305
- D.has(N) ? X(H, N) : W(H, N);
9306
- }), H.addEventListener("keydown", ($) => {
9307
- ($.key === " " || $.key === "Enter") && ($.preventDefault(), D.has(N) ? X(H, N) : W(H, N));
9350
+ N.has(D) ? X(H, D) : G(H, D);
9351
+ }), H.addEventListener("keydown", (B) => {
9352
+ (B.key === " " || B.key === "Enter") && (B.preventDefault(), N.has(D) ? X(H, D) : G(H, D));
9308
9353
  });
9309
- }), B.addEventListener("click", () => {
9310
- if (D.size === T.length) {
9311
- S(e == null ? void 0 : e.errorMessage);
9354
+ }), R.addEventListener("click", () => {
9355
+ if (N.size === P.length) {
9356
+ E(e == null ? void 0 : e.errorMessage);
9312
9357
  return;
9313
9358
  }
9314
- const H = T.find(($) => {
9315
- const m = parseInt($.dataset.checkIndex ?? "0", 10);
9316
- return !D.has(m);
9359
+ const H = P.find((B) => {
9360
+ const m = parseInt(B.dataset.checkIndex ?? "0", 10);
9361
+ return !N.has(m);
9317
9362
  });
9318
9363
  if (!H) return;
9319
- const N = parseInt(H.dataset.checkIndex ?? "0", 10);
9364
+ const D = parseInt(H.dataset.checkIndex ?? "0", 10);
9320
9365
  H.scrollIntoView({ behavior: "smooth", block: "nearest" }), H.classList.add("--highlight"), setTimeout(() => {
9321
- H.classList.remove("--highlight"), W(H, N);
9366
+ H.classList.remove("--highlight"), G(H, D);
9322
9367
  }, 400);
9323
9368
  }), (Q = _.querySelector("#__crossx-close-btn")) == null || Q.addEventListener("click", x);
9324
- })(), a.addEventListener("click", (T) => {
9325
- T.target === a && x();
9369
+ })(), a.addEventListener("click", (P) => {
9370
+ P.target === a && x();
9326
9371
  });
9327
9372
  });
9328
9373
  }
@@ -9333,7 +9378,7 @@ class qi {
9333
9378
  */
9334
9379
  showPinInputPrompt(e) {
9335
9380
  return new Promise((s, t) => {
9336
- var I;
9381
+ var k;
9337
9382
  ce();
9338
9383
  const n = this.messages, i = (e == null ? void 0 : e.verifyMode) === !0, o = i ? (n == null ? void 0 : n.verifyPin_title) ?? "Verify Your PIN" : (n == null ? void 0 : n.pinInput_title) ?? "Enter PIN", a = i ? (n == null ? void 0 : n.verifyPin_subtitle) ?? "Enter your PIN to authorize this transaction." : (n == null ? void 0 : n.pinInput_subtitle) ?? "Enter your 6-digit PIN to continue.", c = (n == null ? void 0 : n.pinLocked_failureWarning) ?? "Your account will be locked after further failures.", l = os(
9339
9384
  this.tokens,
@@ -9348,18 +9393,18 @@ class qi {
9348
9393
  })
9349
9394
  ), u = Oe();
9350
9395
  le(l);
9351
- let f = !1;
9396
+ let p = !1;
9352
9397
  const x = () => {
9353
- f || (f = !0, l.remove(), u());
9354
- }, _ = (T) => {
9355
- x(), s(T);
9356
- }, p = () => {
9398
+ p || (p = !0, l.remove(), u());
9399
+ }, _ = (P) => {
9400
+ x(), s(P);
9401
+ }, f = () => {
9357
9402
  x(), s(null);
9358
- }, v = (T) => {
9359
- x(), t(T);
9360
- }, S = l.querySelector(".__crossx-card");
9361
- (I = S.querySelector("#__crossx-close-btn")) == null || I.addEventListener("click", p), ht(S, _, p, v, e == null ? void 0 : e.onSubmit, e == null ? void 0 : e.lockExpiresAt, c), l.addEventListener("click", (T) => {
9362
- T.target === l && p();
9403
+ }, b = (P) => {
9404
+ x(), t(P);
9405
+ }, E = l.querySelector(".__crossx-card");
9406
+ (k = E.querySelector("#__crossx-close-btn")) == null || k.addEventListener("click", f), ht(E, _, f, b, e == null ? void 0 : e.onSubmit, e == null ? void 0 : e.lockExpiresAt, c), l.addEventListener("click", (P) => {
9407
+ P.target === l && f();
9363
9408
  });
9364
9409
  });
9365
9410
  }
@@ -9425,8 +9470,8 @@ class qi {
9425
9470
  l.addEventListener("click", (u) => {
9426
9471
  var x;
9427
9472
  u.stopPropagation();
9428
- const f = l.dataset.copy;
9429
- f && ((x = navigator.clipboard) == null || x.writeText(f).catch(() => {
9473
+ const p = l.dataset.copy;
9474
+ p && ((x = navigator.clipboard) == null || x.writeText(p).catch(() => {
9430
9475
  }));
9431
9476
  });
9432
9477
  }), t.addEventListener("click", (l) => {
@@ -9452,8 +9497,8 @@ class qi {
9452
9497
  const a = () => {
9453
9498
  o || (o = !0, i(), t());
9454
9499
  }, c = () => {
9455
- var u, f;
9456
- (u = n.querySelector("#__crossx-done-btn")) == null || u.addEventListener("click", a), (f = n.querySelector("#__crossx-close-btn")) == null || f.addEventListener("click", a), n.addEventListener("click", (x) => {
9500
+ var u, p;
9501
+ (u = n.querySelector("#__crossx-done-btn")) == null || u.addEventListener("click", a), (p = n.querySelector("#__crossx-close-btn")) == null || p.addEventListener("click", a), n.addEventListener("click", (x) => {
9457
9502
  x.target === n && a();
9458
9503
  });
9459
9504
  const l = (x) => {
@@ -9468,7 +9513,7 @@ class qi {
9468
9513
  }
9469
9514
  requestConfirmation(e) {
9470
9515
  return new Promise((s) => {
9471
- var l, u, f;
9516
+ var l, u, p;
9472
9517
  ce();
9473
9518
  let t;
9474
9519
  e.type === "sign-message" ? t = wi(e, this.tokens) : e.type === "sign-typed-data" ? t = yi(e, this.tokens) : e.type === "sign" ? t = hi(e, this.tokens) : t = pi(e, this.tokens);
@@ -9481,12 +9526,12 @@ class qi {
9481
9526
  }, a = () => {
9482
9527
  i(), s(!1);
9483
9528
  };
9484
- (l = t.querySelector("#__crossx-confirm-btn")) == null || l.addEventListener("click", o), (u = t.querySelector("#__crossx-cancel-btn")) == null || u.addEventListener("click", a), (f = t.querySelector("#__crossx-close-btn")) == null || f.addEventListener("click", a), t.querySelectorAll(".__crossx-copy-btn").forEach((x) => {
9529
+ (l = t.querySelector("#__crossx-confirm-btn")) == null || l.addEventListener("click", o), (u = t.querySelector("#__crossx-cancel-btn")) == null || u.addEventListener("click", a), (p = t.querySelector("#__crossx-close-btn")) == null || p.addEventListener("click", a), t.querySelectorAll(".__crossx-copy-btn").forEach((x) => {
9485
9530
  x.addEventListener("click", (_) => {
9486
- var v;
9531
+ var b;
9487
9532
  _.stopPropagation();
9488
- const p = x.dataset.copy;
9489
- p && ((v = navigator.clipboard) == null || v.writeText(p).catch(() => {
9533
+ const f = x.dataset.copy;
9534
+ f && ((b = navigator.clipboard) == null || b.writeText(f).catch(() => {
9490
9535
  }));
9491
9536
  });
9492
9537
  }), t.addEventListener("click", (x) => {
@@ -9547,16 +9592,16 @@ function Qi(r, e) {
9547
9592
  "refresh_token이 평문 저장되지 않도록 세션 영속성이 제한됩니다.",
9548
9593
  "IndexedDB를 지원하는 브라우저 사용을 권장합니다."
9549
9594
  ), t.secureStorageAvailable = i;
9550
- const o = i ? new Ht(r.projectId) : new $r(), a = new Vn(), c = new Xn(), l = new Ee(), u = new Ki(), f = new cs();
9595
+ const o = i ? new Ht(r.projectId) : new $r(), a = new Vn(), c = new Xn(), l = new Ee(), u = new Ki(), p = new cs();
9551
9596
  let x;
9552
- r.useMockWallet ? (d.log("[CROSSx] Mock Wallet Provider 사용"), x = new Zn(o, f)) : (d.log("[CROSSx] Remote Wallet Provider 사용"), x = new Ae(
9597
+ r.useMockWallet ? (d.log("[CROSSx] Mock Wallet Provider 사용"), x = new Zn(o, p)) : (d.log("[CROSSx] Remote Wallet Provider 사용"), x = new Ae(
9553
9598
  n,
9554
9599
  o,
9555
9600
  c,
9556
9601
  u,
9557
- f
9602
+ p
9558
9603
  ));
9559
- const _ = new He(n, c), p = new qi(r.theme ?? "light", r.themeTokens), v = e != null && e.wrapConfirmation ? e.wrapConfirmation(p) : p, S = new ft(
9604
+ const _ = new He(n, c), f = new qi(r.theme ?? "light", r.themeTokens), b = e != null && e.wrapConfirmation ? e.wrapConfirmation(f) : f, E = new _t(
9560
9605
  t,
9561
9606
  n,
9562
9607
  o,
@@ -9565,11 +9610,11 @@ function Qi(r, e) {
9565
9610
  l,
9566
9611
  x,
9567
9612
  u,
9568
- v,
9613
+ b,
9569
9614
  _,
9570
- f
9615
+ p
9571
9616
  );
9572
- return typeof window < "u" && (window.__crossxSDK = S), S;
9617
+ return typeof window < "u" && (window.__crossxSDK = E), E;
9573
9618
  }
9574
9619
  function eo(r) {
9575
9620
  const e = Vi(r), s = zi(e), t = JSON.parse(s);
@@ -9632,11 +9677,11 @@ export {
9632
9677
  tr as CONNECT_OTHER_WALLET_DISPLAY_ORDER,
9633
9678
  g as CROSSxError,
9634
9679
  or as CROSSxEthereumProvider,
9635
- ft as CROSSxSDK,
9680
+ _t as CROSSxSDK,
9636
9681
  Zi as ChainId,
9637
9682
  Ue as ConnectOtherWalletItem,
9638
9683
  h as ErrorCode,
9639
- Ut as MNEMONIC_ADDRESS_LIMIT,
9684
+ ft as MNEMONIC_ADDRESS_LIMIT,
9640
9685
  cs as PinMemoryStore,
9641
9686
  Ki as TokenMemoryStore,
9642
9687
  Qi as createCROSSxSDK,