@cedros/pay-react 1.0.2 → 1.0.4

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.
@@ -1,8 +1,8 @@
1
- import { jsxs as E, jsx as C } from "react/jsx-runtime";
2
- import { useState as F, useCallback as A, useMemo as W, useEffect as U, useRef as ke } from "react";
3
- import { g as f, u as me, a as fe, f as se } from "./CedrosContext-vX9uqZKp.mjs";
1
+ import { jsxs as E, jsx as S } from "react/jsx-runtime";
2
+ import { useState as F, useCallback as x, useMemo as W, useEffect as B, useRef as Ce } from "react";
3
+ import { g as m, u as fe, a as me, f as se } from "./CedrosContext-vX9uqZKp.mjs";
4
4
  import { useWallet as De } from "@solana/wallet-adapter-react";
5
- import { WalletReadyState as Ce } from "@solana/wallet-adapter-base";
5
+ import { WalletReadyState as ke } from "@solana/wallet-adapter-base";
6
6
  import { WalletIcon as Ge } from "@solana/wallet-adapter-react-ui";
7
7
  import "@solana/wallet-adapter-wallets";
8
8
  function wt(e) {
@@ -14,6 +14,17 @@ function bt(e, t = ", ") {
14
14
  function vt(e, t) {
15
15
  return e <= 0 ? 0 : (e - t) / e * 100;
16
16
  }
17
+ function It(e, t) {
18
+ if (!t || t.length === 0)
19
+ return e;
20
+ let n = e, o = 0;
21
+ for (const a of t)
22
+ if (a.discountType === "percentage") {
23
+ const r = 1 - a.discountValue / 100;
24
+ n = n * r;
25
+ } else a.discountType === "fixed" && (o += a.discountValue);
26
+ return n = n - o, n < 0 && (n = 0), Math.ceil(n * 100) / 100;
27
+ }
17
28
  function Ee(e) {
18
29
  const t = Number(e);
19
30
  if (!Number.isFinite(t) || t <= 0)
@@ -294,24 +305,24 @@ function ne(e) {
294
305
  technicalHint: `Unknown error code: ${e}`
295
306
  };
296
307
  }
297
- const Ae = /* @__PURE__ */ new Map(), le = /* @__PURE__ */ new Map(), ue = /* @__PURE__ */ new Map(), xe = 200, ge = 2e3;
308
+ const xe = /* @__PURE__ */ new Map(), le = /* @__PURE__ */ new Map(), ue = /* @__PURE__ */ new Map(), Ae = 200, ge = 2e3;
298
309
  function Ke(e) {
299
310
  const t = ue.get(e);
300
311
  return t ? Date.now() < t ? !0 : (ue.delete(e), !1) : !1;
301
312
  }
302
- function Qe(e, t = xe) {
313
+ function Qe(e, t = Ae) {
303
314
  const n = Date.now() + t;
304
315
  ue.set(e, n);
305
316
  }
306
317
  function Ze(e, t = ge) {
307
- const n = Ae.get(e);
318
+ const n = xe.get(e);
308
319
  if (!n)
309
320
  return !1;
310
- const o = Date.now() - n;
311
- return o < t ? (f().debug(`[Deduplication] Duplicate request blocked: ${e} (${o}ms ago)`), !0) : !1;
321
+ const a = Date.now() - n;
322
+ return a < t ? (m().debug(`[Deduplication] Duplicate request blocked: ${e} (${a}ms ago)`), !0) : !1;
312
323
  }
313
324
  function Je(e) {
314
- Ae.set(e, Date.now());
325
+ xe.set(e, Date.now());
315
326
  }
316
327
  function et(e) {
317
328
  return le.get(e) || null;
@@ -324,25 +335,25 @@ function tt(e, t) {
324
335
  return t.then(n, n), t;
325
336
  }
326
337
  async function nt(e, t, n = {}) {
327
- const { windowMs: a = ge, throwOnDuplicate: o = !0 } = n, r = et(e);
338
+ const { windowMs: o = ge, throwOnDuplicate: a = !0 } = n, r = et(e);
328
339
  if (r)
329
- return f().debug(`[Deduplication] Reusing in-flight request: ${e}`), r;
330
- if (Ze(e, a)) {
331
- if (o)
340
+ return m().debug(`[Deduplication] Reusing in-flight request: ${e}`), r;
341
+ if (Ze(e, o)) {
342
+ if (a)
332
343
  throw new Error(`Duplicate request blocked: ${e}`);
333
- return f().warn(`[Deduplication] Duplicate request blocked but not throwing: ${e}`), Promise.reject(new Error("Duplicate request"));
344
+ return m().warn(`[Deduplication] Duplicate request blocked but not throwing: ${e}`), Promise.reject(new Error("Duplicate request"));
334
345
  }
335
346
  const l = t();
336
347
  return tt(e, l);
337
348
  }
338
349
  function Le(e, t, n = {}) {
339
- const { cooldownMs: a = xe, deduplicationWindowMs: o = ge } = n;
350
+ const { cooldownMs: o = Ae, deduplicationWindowMs: a = ge } = n;
340
351
  return async () => {
341
352
  if (Ke(e)) {
342
- f().debug(`[Deduplication] Button in cooldown: ${e}`);
353
+ m().debug(`[Deduplication] Button in cooldown: ${e}`);
343
354
  return;
344
355
  }
345
- Qe(e, a);
356
+ Qe(e, o);
346
357
  try {
347
358
  await nt(
348
359
  e,
@@ -350,7 +361,7 @@ function Le(e, t, n = {}) {
350
361
  const r = t();
351
362
  r instanceof Promise && await r;
352
363
  },
353
- { windowMs: o, throwOnDuplicate: !1 }
364
+ { windowMs: a, throwOnDuplicate: !1 }
354
365
  );
355
366
  } catch (r) {
356
367
  if (r instanceof Error && r.message.includes("Duplicate request"))
@@ -426,22 +437,22 @@ function de(e, t, n) {
426
437
  itemCount: n
427
438
  });
428
439
  }
429
- function He(e, t, n, a) {
440
+ function He(e, t, n, o) {
430
441
  z($.PAYMENT_SUCCESS, {
431
442
  timestamp: Date.now(),
432
443
  method: e,
433
444
  transactionId: t,
434
445
  resource: n,
435
- itemCount: a
446
+ itemCount: o
436
447
  });
437
448
  }
438
- function ae(e, t, n, a) {
449
+ function ae(e, t, n, o) {
439
450
  z($.PAYMENT_ERROR, {
440
451
  timestamp: Date.now(),
441
452
  method: e,
442
453
  error: t,
443
454
  resource: n,
444
- itemCount: a
455
+ itemCount: o
445
456
  });
446
457
  }
447
458
  var pe = /* @__PURE__ */ ((e) => (e.INVALID_PAYMENT_PROOF = "invalid_payment_proof", e.INVALID_SIGNATURE = "invalid_signature", e.INVALID_TRANSACTION = "invalid_transaction", e.TRANSACTION_NOT_FOUND = "transaction_not_found", e.TRANSACTION_NOT_CONFIRMED = "transaction_not_confirmed", e.TRANSACTION_FAILED = "transaction_failed", e.TRANSACTION_EXPIRED = "transaction_expired", e.INVALID_RECIPIENT = "invalid_recipient", e.INVALID_SENDER = "invalid_sender", e.UNAUTHORIZED_REFUND_ISSUER = "unauthorized_refund_issuer", e.AMOUNT_BELOW_MINIMUM = "amount_below_minimum", e.AMOUNT_MISMATCH = "amount_mismatch", e.INSUFFICIENT_FUNDS_SOL = "insufficient_funds_sol", e.INSUFFICIENT_FUNDS_TOKEN = "insufficient_funds_token", e.INVALID_TOKEN_MINT = "invalid_token_mint", e.NOT_SPL_TRANSFER = "not_spl_transfer", e.MISSING_TOKEN_ACCOUNT = "missing_token_account", e.INVALID_TOKEN_PROGRAM = "invalid_token_program", e.MISSING_MEMO = "missing_memo", e.INVALID_MEMO = "invalid_memo", e.PAYMENT_ALREADY_USED = "payment_already_used", e.SIGNATURE_REUSED = "signature_reused", e.QUOTE_EXPIRED = "quote_expired", e.MISSING_FIELD = "missing_field", e.INVALID_FIELD = "invalid_field", e.INVALID_AMOUNT = "invalid_amount", e.INVALID_WALLET = "invalid_wallet", e.INVALID_RESOURCE = "invalid_resource", e.INVALID_COUPON = "invalid_coupon", e.INVALID_CART_ITEM = "invalid_cart_item", e.EMPTY_CART = "empty_cart", e.RESOURCE_NOT_FOUND = "resource_not_found", e.CART_NOT_FOUND = "cart_not_found", e.REFUND_NOT_FOUND = "refund_not_found", e.PRODUCT_NOT_FOUND = "product_not_found", e.COUPON_NOT_FOUND = "coupon_not_found", e.SESSION_NOT_FOUND = "session_not_found", e.CART_ALREADY_PAID = "cart_already_paid", e.REFUND_ALREADY_PROCESSED = "refund_already_processed", e.COUPON_EXPIRED = "coupon_expired", e.COUPON_USAGE_LIMIT_REACHED = "coupon_usage_limit_reached", e.COUPON_NOT_APPLICABLE = "coupon_not_applicable", e.COUPON_WRONG_PAYMENT_METHOD = "coupon_wrong_payment_method", e.STRIPE_ERROR = "stripe_error", e.RPC_ERROR = "rpc_error", e.NETWORK_ERROR = "network_error", e.INTERNAL_ERROR = "internal_error", e.DATABASE_ERROR = "database_error", e.CONFIG_ERROR = "config_error", e))(pe || {});
@@ -454,8 +465,8 @@ class M extends Error {
454
465
  details;
455
466
  /** HTTP status code (if from API response) */
456
467
  httpStatus;
457
- constructor(t, n, a = !1, o, r) {
458
- super(n), this.name = "PaymentError", this.code = t, this.retryable = a, this.details = o, this.httpStatus = r, Object.setPrototypeOf(this, M.prototype);
468
+ constructor(t, n, o = !1, a, r) {
469
+ super(n), this.name = "PaymentError", this.code = t, this.retryable = o, this.details = a, this.httpStatus = r, Object.setPrototypeOf(this, M.prototype);
459
470
  }
460
471
  /**
461
472
  * Check if this error is retryable
@@ -530,7 +541,7 @@ class M extends Error {
530
541
  );
531
542
  }
532
543
  }
533
- const It = {
544
+ const Tt = {
534
545
  /** Insufficient funds errors requiring user to add funds */
535
546
  INSUFFICIENT_FUNDS: [
536
547
  "insufficient_funds_sol",
@@ -583,13 +594,13 @@ const It = {
583
594
  /* SESSION_NOT_FOUND */
584
595
  ]
585
596
  };
586
- async function Tt(e) {
597
+ async function Rt(e) {
587
598
  const t = e.status;
588
599
  try {
589
600
  const n = await e.json();
590
601
  if (n.error && typeof n.error.code == "string") {
591
- const a = n;
592
- return M.fromErrorResponse(a, t);
602
+ const o = n;
603
+ return M.fromErrorResponse(o, t);
593
604
  }
594
605
  return new M(
595
606
  pe.INTERNAL_ERROR,
@@ -608,19 +619,19 @@ async function Tt(e) {
608
619
  );
609
620
  }
610
621
  }
611
- function Rt(e) {
622
+ function Nt(e) {
612
623
  return e instanceof M && e.canRetry();
613
624
  }
614
- function Nt(e) {
625
+ function Ct(e) {
615
626
  return e instanceof M ? e.getUserMessage() : e instanceof Error ? e.message : String(e);
616
627
  }
617
628
  function ot() {
618
- const { stripeManager: e } = me(), [t, n] = F({
629
+ const { stripeManager: e } = fe(), [t, n] = F({
619
630
  status: "idle",
620
631
  error: null,
621
632
  transactionId: null
622
- }), a = A(
623
- async (l, p, S, g, _, w) => {
633
+ }), o = x(
634
+ async (l, d, N, g, _, w) => {
624
635
  n({
625
636
  status: "loading",
626
637
  error: null,
@@ -628,8 +639,8 @@ function ot() {
628
639
  });
629
640
  const y = {
630
641
  resource: l,
631
- successUrl: p,
632
- cancelUrl: S,
642
+ successUrl: d,
643
+ cancelUrl: N,
633
644
  metadata: g,
634
645
  customerEmail: _,
635
646
  couponCode: w
@@ -641,8 +652,8 @@ function ot() {
641
652
  }), b;
642
653
  },
643
654
  [e]
644
- ), o = A(
645
- async (l, p, S, g, _, w) => {
655
+ ), a = x(
656
+ async (l, d, N, g, _, w) => {
646
657
  n({
647
658
  status: "loading",
648
659
  error: null,
@@ -650,8 +661,8 @@ function ot() {
650
661
  });
651
662
  const y = Oe(l), b = await e.processCartCheckout({
652
663
  items: y,
653
- successUrl: p,
654
- cancelUrl: S,
664
+ successUrl: d,
665
+ cancelUrl: N,
655
666
  metadata: g,
656
667
  customerEmail: _,
657
668
  couponCode: w
@@ -663,7 +674,7 @@ function ot() {
663
674
  }), b;
664
675
  },
665
676
  [e]
666
- ), r = A(() => {
677
+ ), r = x(() => {
667
678
  n({
668
679
  status: "idle",
669
680
  error: null,
@@ -672,21 +683,21 @@ function ot() {
672
683
  }, []);
673
684
  return {
674
685
  ...t,
675
- processPayment: a,
676
- processCartCheckout: o,
686
+ processPayment: o,
687
+ processCartCheckout: a,
677
688
  reset: r
678
689
  };
679
690
  }
680
691
  function Fe(e, t) {
681
- const n = Ve(t), a = e || (t?.length === 1 ? t[0].resource : "");
692
+ const n = Ve(t), o = e || (t?.length === 1 ? t[0].resource : "");
682
693
  return {
683
694
  isCartMode: n,
684
- effectiveResource: a
695
+ effectiveResource: o
685
696
  };
686
697
  }
687
698
  const rt = (e, t, n) => {
688
- const a = e[t];
689
- return a ? typeof a == "function" ? a() : Promise.resolve(a) : new Promise((o, r) => {
699
+ const o = e[t];
700
+ return o ? typeof o == "function" ? o() : Promise.resolve(o) : new Promise((a, r) => {
690
701
  (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(r.bind(null, /* @__PURE__ */ new Error("Unknown variable dynamic import: " + t + (t.split("/").length !== n ? ". Note that variables only represent file names one level deep." : ""))));
691
702
  });
692
703
  }, ce = /* @__PURE__ */ new Map();
@@ -706,8 +717,8 @@ async function kt() {
706
717
  return te;
707
718
  const e = /* @__PURE__ */ Object.assign({ "./translations/ar.json": () => import("./ar-w27mU-4x.mjs"), "./translations/bn.json": () => import("./bn-Ba_k3Kex.mjs"), "./translations/de.json": () => import("./de-CoZiPFN7.mjs"), "./translations/en.json": () => import("./en-CSsJl3nf.mjs"), "./translations/es.json": () => import("./es-BWGIBp2f.mjs"), "./translations/fil.json": () => import("./fil-Czo27xmj.mjs"), "./translations/fr.json": () => import("./fr-DQ-2ThBv.mjs"), "./translations/he.json": () => import("./he-DpV1WnBQ.mjs"), "./translations/id.json": () => import("./id-BJMqsu19.mjs"), "./translations/in.json": () => import("./in-BxgxKLQH.mjs"), "./translations/it.json": () => import("./it-DZFFPALf.mjs"), "./translations/jp.json": () => import("./jp-ZExTrlHK.mjs"), "./translations/kr.json": () => import("./kr-DHX3i4Ht.mjs"), "./translations/ms.json": () => import("./ms-Cv1fdIi2.mjs"), "./translations/nl.json": () => import("./nl-BmGonsKb.mjs"), "./translations/pa.json": () => import("./pa-BfwcJIar.mjs"), "./translations/pl.json": () => import("./pl-DE5IB9xv.mjs"), "./translations/pt.json": () => import("./pt-CLzkqDzf.mjs"), "./translations/ru.json": () => import("./ru-DM6-oUR0.mjs"), "./translations/ta.json": () => import("./ta-A5HnrGb5.mjs"), "./translations/th.json": () => import("./th-3fbB3Ytp.mjs"), "./translations/tr.json": () => import("./tr-BrgfFFdq.mjs"), "./translations/uk.json": () => import("./uk-0hFun_g_.mjs"), "./translations/ur.json": () => import("./ur-CaOjJXai.mjs"), "./translations/vn.json": () => import("./vn-0nlIZFLP.mjs"), "./translations/zh.json": () => import("./zh-B4Endr1F.mjs") }), t = [];
708
719
  for (const n in e) {
709
- const a = n.match(/\.\/translations\/([a-z]{2,3}(?:-[A-Z]{2})?)\.json$/);
710
- a && t.push(a[1]);
720
+ const o = n.match(/\.\/translations\/([a-z]{2,3}(?:-[A-Z]{2})?)\.json$/);
721
+ o && t.push(o[1]);
711
722
  }
712
723
  return te = t.length > 0 ? t : ["en"], te;
713
724
  }
@@ -722,111 +733,123 @@ async function it(e) {
722
733
  }
723
734
  function ct(e) {
724
735
  return (t, n) => {
725
- const a = t.split(".");
726
- let o = e;
727
- for (const r of a)
728
- if (o && typeof o == "object" && r in o)
729
- o = o[r];
736
+ const o = t.split(".");
737
+ let a = e;
738
+ for (const r of o)
739
+ if (a && typeof a == "object" && r in a)
740
+ a = a[r];
730
741
  else
731
742
  return t;
732
- return typeof o != "string" ? t : n ? Object.entries(n).reduce(
733
- (r, [l, p]) => r.replace(new RegExp(`\\{${l}\\}`, "g"), p),
734
- o
735
- ) : o;
743
+ return typeof a != "string" ? t : n ? Object.entries(n).reduce(
744
+ (r, [l, d]) => r.replace(new RegExp(`\\{${l}\\}`, "g"), d),
745
+ a
746
+ ) : a;
736
747
  };
737
748
  }
738
- function Ct(e, t, n = !0) {
739
- const a = t.errors[e];
740
- if (!a) {
741
- const o = ne(e);
742
- return n && o.action ? `${o.message} ${o.action}` : o.message;
749
+ function St(e, t, n = !0) {
750
+ const o = t.errors[e];
751
+ if (!o) {
752
+ const a = ne(e);
753
+ return n && a.action ? `${a.message} ${a.action}` : a.message;
743
754
  }
744
- return n && a.action ? `${a.message} ${a.action}` : a.message;
755
+ return n && o.action ? `${o.message} ${o.action}` : o.message;
745
756
  }
746
757
  function ye(e) {
747
- const [t, n] = F(null), [a, o] = F(!0), r = W(() => e || st(), [e]);
748
- return U(() => {
749
- let p = !1;
758
+ const [t, n] = F(null), [o, a] = F(!0), r = W(() => e || st(), [e]);
759
+ return B(() => {
760
+ let d = !1;
750
761
  return (async () => {
751
- o(!0);
762
+ a(!0);
752
763
  try {
753
764
  const g = await it(r);
754
- p || (n(g), o(!1));
765
+ d || (n(g), a(!1));
755
766
  } catch (g) {
756
- console.error("[CedrosPay] Failed to load translations:", g), p || o(!1);
767
+ console.error("[CedrosPay] Failed to load translations:", g), d || a(!1);
757
768
  }
758
769
  })(), () => {
759
- p = !0;
770
+ d = !0;
760
771
  };
761
772
  }, [r]), {
762
- t: W(() => t ? ct(t) : (p) => p, [t]),
773
+ t: W(() => t ? ct(t) : (d) => ({
774
+ "ui.purchase": "Purchase",
775
+ "ui.pay_with_card": "Pay with Card",
776
+ "ui.pay_with_crypto": "Pay with USDC",
777
+ "ui.pay_with_usdc": "Pay with USDC",
778
+ "ui.card": "Card",
779
+ "ui.usdc_solana": "USDC (Solana)",
780
+ "ui.crypto": "Crypto",
781
+ "ui.processing": "Processing...",
782
+ "ui.loading": "Loading...",
783
+ "ui.connect_wallet": "Connect Wallet",
784
+ "ui.connecting": "Connecting..."
785
+ })[d] || d, [t]),
763
786
  locale: r,
764
- isLoading: a,
787
+ isLoading: o,
765
788
  translations: t
766
789
  };
767
790
  }
768
- function St(e, t = !0) {
791
+ function Pt(e, t = !0) {
769
792
  const { translations: n } = ye();
770
793
  if (!n) {
771
- const o = ne(e);
772
- return t && o.action ? `${o.message} ${o.action}` : o.message;
794
+ const a = ne(e);
795
+ return t && a.action ? `${a.message} ${a.action}` : a.message;
773
796
  }
774
- const a = n.errors[e];
775
- if (!a) {
776
- const o = ne(e);
777
- return t && o.action ? `${o.message} ${o.action}` : o.message;
797
+ const o = n.errors[e];
798
+ if (!o) {
799
+ const a = ne(e);
800
+ return t && a.action ? `${a.message} ${a.action}` : a.message;
778
801
  }
779
- return t && a.action ? `${a.message} ${a.action}` : a.message;
802
+ return t && o.action ? `${o.message} ${o.action}` : o.message;
780
803
  }
781
804
  function lt({
782
805
  resource: e,
783
806
  items: t,
784
807
  successUrl: n,
785
- cancelUrl: a,
786
- metadata: o,
808
+ cancelUrl: o,
809
+ metadata: a,
787
810
  customerEmail: r,
788
811
  couponCode: l,
789
- label: p,
790
- disabled: S = !1,
812
+ label: d,
813
+ disabled: N = !1,
791
814
  onAttempt: g,
792
815
  onSuccess: _,
793
816
  onError: w,
794
817
  className: y = ""
795
818
  }) {
796
- const { status: b, error: D, transactionId: H, processPayment: m, processCartCheckout: h } = ot(), i = fe(), { isCartMode: v, effectiveResource: c } = Fe(e, t), { t: u, translations: N } = ye(), I = p || u("ui.pay_with_card"), k = i.unstyled ? y : `${i.className} cedros-theme__stripe-button ${y}`.trim(), d = D && typeof D != "string" ? D?.code ?? null : null, O = D ? typeof D == "string" ? D : ((L) => {
797
- if (!L || !N) return "";
798
- const R = N.errors[L];
819
+ const { status: b, error: D, transactionId: H, processPayment: f, processCartCheckout: h } = ot(), i = me(), { isCartMode: v, effectiveResource: c } = Fe(e, t), { t: u, translations: C } = ye(), I = d || u("ui.pay_with_card"), k = i.unstyled ? y : `${i.className} cedros-theme__stripe-button ${y}`.trim(), p = D && typeof D != "string" ? D?.code ?? null : null, O = D ? typeof D == "string" ? D : ((L) => {
820
+ if (!L || !C) return "";
821
+ const R = C.errors[L];
799
822
  return R ? R.action ? `${R.message} ${R.action}` : R.message : "";
800
- })(d) : null, P = A(async () => {
801
- f().debug("[StripeButton] executePayment with couponCode:", l);
823
+ })(p) : null, P = x(async () => {
824
+ m().debug("[StripeButton] executePayment with couponCode:", l);
802
825
  const L = v && t ? K(t) : void 0;
803
826
  if (Me("stripe", c, L), g && g("stripe"), !v && !c) {
804
827
  const Y = "Invalid payment configuration: missing resource or items";
805
- f().error("[StripeButton]", Y), ae("stripe", Y, c, L), w && w(Y);
828
+ m().error("[StripeButton]", Y), ae("stripe", Y, c, L), w && w(Y);
806
829
  return;
807
830
  }
808
831
  let R;
809
- de("stripe", c, L), v && t ? (f().debug("[StripeButton] Processing cart checkout with coupon:", l), R = await h(
832
+ de("stripe", c, L), v && t ? (m().debug("[StripeButton] Processing cart checkout with coupon:", l), R = await h(
810
833
  t,
811
834
  n,
812
- a,
813
835
  o,
836
+ a,
814
837
  r,
815
838
  l
816
- )) : c && (f().debug("[StripeButton] Processing single payment with coupon:", l), R = await m(
839
+ )) : c && (m().debug("[StripeButton] Processing single payment with coupon:", l), R = await f(
817
840
  c,
818
841
  n,
819
- a,
820
842
  o,
843
+ a,
821
844
  r,
822
845
  l
823
846
  )), R && R.success && R.transactionId ? (He("stripe", R.transactionId, c, L), _ && _(R.transactionId)) : R && !R.success && R.error && (ae("stripe", R.error, c, L), w && w(R.error));
824
- }, [l, v, c, t, n, a, o, r, h, m, g, _, w]), B = W(() => v && t ? `stripe-cart-${t.map((L) => L.resource).join("-")}` : `stripe-${c || "unknown"}`, [v, t, c]), Q = W(
825
- () => Le(B, P),
826
- [B, P]
827
- ), Z = b === "loading", oe = S || Z;
847
+ }, [l, v, c, t, n, o, a, r, h, f, g, _, w]), U = W(() => v && t ? `stripe-cart-${t.map((L) => L.resource).join("-")}` : `stripe-${c || "unknown"}`, [v, t, c]), Q = W(
848
+ () => Le(U, P),
849
+ [U, P]
850
+ ), Z = b === "loading", oe = N || Z;
828
851
  return /* @__PURE__ */ E("div", { className: k, style: i.unstyled ? {} : i.style, children: [
829
- /* @__PURE__ */ C(
852
+ /* @__PURE__ */ S(
830
853
  "button",
831
854
  {
832
855
  onClick: Q,
@@ -836,33 +859,33 @@ function lt({
836
859
  children: Z ? u("ui.processing") : I
837
860
  }
838
861
  ),
839
- O && /* @__PURE__ */ C("div", { className: i.unstyled ? "" : "cedros-theme__error", children: O }),
840
- H && /* @__PURE__ */ C("div", { className: i.unstyled ? "" : "cedros-theme__success", children: u("ui.payment_successful") })
862
+ O && /* @__PURE__ */ S("div", { className: i.unstyled ? "" : "cedros-theme__error", children: O }),
863
+ H && /* @__PURE__ */ S("div", { className: i.unstyled ? "" : "cedros-theme__success", children: u("ui.payment_successful") })
841
864
  ] });
842
865
  }
843
866
  function ut() {
844
- const { x402Manager: e, walletManager: t } = me(), { publicKey: n, signTransaction: a } = De(), [o, r] = F({
867
+ const { x402Manager: e, walletManager: t } = fe(), { publicKey: n, signTransaction: o } = De(), [a, r] = F({
845
868
  status: "idle",
846
869
  error: null,
847
870
  transactionId: null
848
- }), [l, p] = F(null), [S, g] = F(null), _ = A(() => {
871
+ }), [l, d] = F(null), [N, g] = F(null), _ = x(() => {
849
872
  if (!n) {
850
- const m = "Wallet not connected";
851
- return r({ status: "error", error: m, transactionId: null }), { valid: !1, error: m };
873
+ const f = "Wallet not connected";
874
+ return r({ status: "error", error: f, transactionId: null }), { valid: !1, error: f };
852
875
  }
853
- if (!a) {
854
- const m = "Wallet does not support signing";
855
- return r({ status: "error", error: m, transactionId: null }), { valid: !1, error: m };
876
+ if (!o) {
877
+ const f = "Wallet does not support signing";
878
+ return r({ status: "error", error: f, transactionId: null }), { valid: !1, error: f };
856
879
  }
857
880
  return { valid: !0 };
858
- }, [n, a]), w = A(
859
- async (m) => {
881
+ }, [n, o]), w = x(
882
+ async (f) => {
860
883
  try {
861
884
  r((i) => ({ ...i, status: "loading" }));
862
- const h = await e.requestQuote({ resource: m });
885
+ const h = await e.requestQuote({ resource: f });
863
886
  if (!e.validateRequirement(h))
864
887
  throw new Error("Invalid requirement received from server");
865
- return p(h), r((i) => ({ ...i, status: "idle" })), h;
888
+ return d(h), r((i) => ({ ...i, status: "idle" })), h;
866
889
  } catch (h) {
867
890
  const i = se(h, "Failed to fetch requirement");
868
891
  throw r({
@@ -873,58 +896,58 @@ function ut() {
873
896
  }
874
897
  },
875
898
  [e]
876
- ), y = A(
877
- async (m, h, i, v, c = "regular") => {
878
- if (!!m.extra?.feePayer) {
899
+ ), y = x(
900
+ async (f, h, i, v, c = "regular") => {
901
+ if (!!f.extra?.feePayer) {
879
902
  console.log("⚡ [useX402Payment] GASLESS FLOW - Backend pays fees"), console.log("🔨 [useX402Payment] Requesting backend to build gasless transaction");
880
- const { transaction: N, blockhash: I } = await e.buildGaslessTransaction({
903
+ const { transaction: C, blockhash: I } = await e.buildGaslessTransaction({
881
904
  resourceId: h,
882
905
  userWallet: n.toString(),
883
- feePayer: m.extra.feePayer,
906
+ feePayer: f.extra.feePayer,
884
907
  couponCode: i
885
908
  });
886
909
  console.log("📦 [useX402Payment] Deserializing transaction from backend");
887
- const k = t.deserializeTransaction(N);
910
+ const k = t.deserializeTransaction(C);
888
911
  console.log("✍️ [useX402Payment] Requesting wallet to partially sign (transfer authority only)");
889
- const d = await t.partiallySignTransaction({
912
+ const p = await t.partiallySignTransaction({
890
913
  transaction: k,
891
- signTransaction: a,
914
+ signTransaction: o,
892
915
  blockhash: I
893
916
  });
894
917
  console.log("📤 [useX402Payment] Submitting partially-signed transaction to backend");
895
- const x = await e.submitGaslessTransaction({
918
+ const A = await e.submitGaslessTransaction({
896
919
  resource: h,
897
- partialTx: d,
920
+ partialTx: p,
898
921
  couponCode: i,
899
922
  metadata: v,
900
923
  resourceType: c,
901
- requirement: m
924
+ requirement: f
902
925
  });
903
- return x.success && x.settlement && g(x.settlement), x;
926
+ return A.success && A.settlement && g(A.settlement), A;
904
927
  } else {
905
- const N = await t.buildTransaction({
906
- requirement: m,
928
+ const C = await t.buildTransaction({
929
+ requirement: f,
907
930
  payerPublicKey: n
908
931
  }), I = await t.signTransaction({
909
- transaction: N,
910
- signTransaction: a
932
+ transaction: C,
933
+ signTransaction: o
911
934
  }), k = t.buildPaymentPayload({
912
- requirement: m,
935
+ requirement: f,
913
936
  signedTx: I,
914
937
  payerPublicKey: n
915
- }), d = await e.submitPayment({
938
+ }), p = await e.submitPayment({
916
939
  resource: h,
917
940
  payload: k,
918
941
  couponCode: i,
919
942
  metadata: v,
920
943
  resourceType: c
921
944
  });
922
- return d.success && d.settlement && g(d.settlement), d;
945
+ return p.success && p.settlement && g(p.settlement), p;
923
946
  }
924
947
  },
925
- [n, a, e, t]
926
- ), b = A(
927
- async (m, h, i) => {
948
+ [n, o, e, t]
949
+ ), b = x(
950
+ async (f, h, i) => {
928
951
  const v = _();
929
952
  if (!v.valid)
930
953
  return { success: !1, error: v.error };
@@ -934,10 +957,10 @@ function ut() {
934
957
  transactionId: null
935
958
  });
936
959
  try {
937
- console.log("🔍 [useX402Payment] Fetching fresh quote for resource:", m);
938
- const c = await e.requestQuote({ resource: m, couponCode: h });
939
- console.log("✅ [useX402Payment] Got quote:", { payTo: c.payTo, amount: c.maxAmountRequired }), p(c), console.log("⚙️ [useX402Payment] Executing payment flow with fresh requirement");
940
- const u = await y(c, m, h, i, "regular");
960
+ console.log("🔍 [useX402Payment] Fetching fresh quote for resource:", f);
961
+ const c = await e.requestQuote({ resource: f, couponCode: h });
962
+ console.log("✅ [useX402Payment] Got quote:", { payTo: c.payTo, amount: c.maxAmountRequired }), d(c), console.log("⚙️ [useX402Payment] Executing payment flow with fresh requirement");
963
+ const u = await y(c, f, h, i, "regular");
941
964
  return u.success ? r({
942
965
  status: "success",
943
966
  error: null,
@@ -957,8 +980,8 @@ function ut() {
957
980
  }
958
981
  },
959
982
  [_, e, y]
960
- ), D = A(
961
- async (m, h, i) => {
983
+ ), D = x(
984
+ async (f, h, i) => {
962
985
  const v = _();
963
986
  if (!v.valid)
964
987
  return { success: !1, error: v.error };
@@ -968,15 +991,15 @@ function ut() {
968
991
  transactionId: null
969
992
  });
970
993
  try {
971
- const c = Oe(m), u = await e.requestCartQuote({
994
+ const c = Oe(f), u = await e.requestCartQuote({
972
995
  items: c,
973
996
  metadata: h,
974
997
  couponCode: i
975
- }), N = u.cartId, I = u.quote;
998
+ }), C = u.cartId, I = u.quote;
976
999
  if (!e.validateRequirement(I))
977
1000
  throw new Error("Invalid cart quote received from server");
978
- p(I);
979
- const k = await y(I, N, i, h, "cart");
1001
+ d(I);
1002
+ const k = await y(I, C, i, h, "cart");
980
1003
  return k.success ? r({
981
1004
  status: "success",
982
1005
  error: null,
@@ -996,17 +1019,17 @@ function ut() {
996
1019
  }
997
1020
  },
998
1021
  [_, e, y]
999
- ), H = A(() => {
1022
+ ), H = x(() => {
1000
1023
  r({
1001
1024
  status: "idle",
1002
1025
  error: null,
1003
1026
  transactionId: null
1004
- }), p(null), g(null);
1027
+ }), d(null), g(null);
1005
1028
  }, []);
1006
1029
  return {
1007
- ...o,
1030
+ ...a,
1008
1031
  requirement: l,
1009
- settlement: S,
1032
+ settlement: N,
1010
1033
  fetchQuote: w,
1011
1034
  processPayment: b,
1012
1035
  processCartPayment: D,
@@ -1017,57 +1040,57 @@ function dt({
1017
1040
  resource: e,
1018
1041
  items: t,
1019
1042
  label: n,
1020
- disabled: a = !1,
1021
- onAttempt: o,
1043
+ disabled: o = !1,
1044
+ onAttempt: a,
1022
1045
  onSuccess: r,
1023
1046
  onError: l,
1024
- className: p = "",
1025
- testPageUrl: S,
1047
+ className: d = "",
1048
+ testPageUrl: N,
1026
1049
  hideMessages: g = !1,
1027
1050
  metadata: _,
1028
1051
  couponCode: w
1029
1052
  }) {
1030
- const { connected: y, connecting: b, connect: D, disconnect: H, select: m, wallets: h, wallet: i, publicKey: v } = De(), { status: c, error: u, transactionId: N, processPayment: I, processCartPayment: k } = ut(), d = fe(), { solanaError: x } = me(), { isCartMode: O, effectiveResource: P } = Fe(e, t), { t: B, translations: Q } = ye(), Z = n || B("ui.pay_with_crypto"), oe = u && typeof u != "string" ? u?.code ?? null : null, L = x && typeof x != "string" ? x?.code ?? null : null, R = (s) => {
1053
+ const { connected: y, connecting: b, connect: D, disconnect: H, select: f, wallets: h, wallet: i, publicKey: v } = De(), { status: c, error: u, transactionId: C, processPayment: I, processCartPayment: k } = ut(), p = me(), { solanaError: A } = fe(), { isCartMode: O, effectiveResource: P } = Fe(e, t), { t: U, translations: Q } = ye(), Z = n || U("ui.pay_with_crypto"), oe = u && typeof u != "string" ? u?.code ?? null : null, L = A && typeof A != "string" ? A?.code ?? null : null, R = (s) => {
1031
1054
  if (!s || !Q) return "";
1032
1055
  const T = Q.errors[s];
1033
1056
  return T ? T.action ? `${T.message} ${T.action}` : T.message : "";
1034
- }, Y = u ? typeof u == "string" ? u : R(oe) : null, he = x ? typeof x == "string" ? x : R(L) : null, _e = ke(I), we = ke(k);
1035
- U(() => {
1057
+ }, Y = u ? typeof u == "string" ? u : R(oe) : null, he = A ? typeof A == "string" ? A : R(L) : null, _e = Ce(I), we = Ce(k);
1058
+ B(() => {
1036
1059
  _e.current = I, we.current = k;
1037
1060
  }, [I, k]);
1038
- const Be = W(
1061
+ const Ue = W(
1039
1062
  () => h.map((s) => `${s.adapter.name}-${s.readyState}`).join(","),
1040
1063
  [h]
1041
1064
  ), J = W(
1042
1065
  () => h.filter(
1043
- ({ readyState: s }) => s === Ce.Installed || s === Ce.Loadable
1066
+ ({ readyState: s }) => s === ke.Installed || s === ke.Loadable
1044
1067
  ),
1045
1068
  // walletStateKey is derived from availableWallets, so we only need availableWallets as dependency
1046
1069
  // eslint-disable-next-line react-hooks/exhaustive-deps
1047
- [Be]
1070
+ [Ue]
1048
1071
  );
1049
- U(() => {
1050
- if (c === "success" && N) {
1072
+ B(() => {
1073
+ if (c === "success" && C) {
1051
1074
  const s = O && t ? K(t) : void 0;
1052
- He("crypto", N, P, s), r && r(N);
1075
+ He("crypto", C, P, s), r && r(C);
1053
1076
  }
1054
- }, [c, N, r, O, t, P]), U(() => {
1077
+ }, [c, C, r, O, t, P]), B(() => {
1055
1078
  if (c === "error" && u) {
1056
1079
  const s = O && t ? K(t) : void 0;
1057
1080
  ae("crypto", u, P, s), l && l(u);
1058
1081
  }
1059
1082
  }, [c, u, l, O, t, P]);
1060
- const be = typeof window < "u" && window.top !== window.self, [ve, G] = F(!1), [Ie, re] = F(!1), [V, q] = F(null), X = x;
1061
- U(() => {
1083
+ const be = typeof window < "u" && window.top !== window.self, [ve, G] = F(!1), [Ie, re] = F(!1), [V, q] = F(null), X = A;
1084
+ B(() => {
1062
1085
  let s = !1;
1063
1086
  return s || (async () => {
1064
1087
  if (Ie && i && !y && !b) {
1065
- f().debug("[CryptoButton] Wallet detected, attempting auto-connect:", i.adapter.name), re(!1), Se(i.adapter.name);
1088
+ m().debug("[CryptoButton] Wallet detected, attempting auto-connect:", i.adapter.name), re(!1), Se(i.adapter.name);
1066
1089
  try {
1067
- await D(), s || f().debug("[CryptoButton] Auto-connect successful");
1090
+ await D(), s || m().debug("[CryptoButton] Auto-connect successful");
1068
1091
  } catch (j) {
1069
1092
  if (!s) {
1070
- f().error("[CryptoButton] Auto-connect failed:", j);
1093
+ m().error("[CryptoButton] Auto-connect failed:", j);
1071
1094
  const ee = j instanceof Error ? j.message : "Failed to connect wallet";
1072
1095
  ie(ee, i.adapter.name), q(null);
1073
1096
  }
@@ -1076,22 +1099,22 @@ function dt({
1076
1099
  })(), () => {
1077
1100
  s = !0;
1078
1101
  };
1079
- }, [i, Ie, y, b, D]), U(() => {
1080
- if (f().debug("[CryptoButton] Payment useEffect triggered", {
1102
+ }, [i, Ie, y, b, D]), B(() => {
1103
+ if (m().debug("[CryptoButton] Payment useEffect triggered", {
1081
1104
  connected: y,
1082
1105
  hasPendingPayment: !!V,
1083
1106
  hasPublicKey: !!v,
1084
1107
  pendingPaymentType: V?.type
1085
1108
  }), y && V && v && i) {
1086
- at(i.adapter.name, v.toString()), f().debug("[CryptoButton] All conditions met! Processing pending payment:", V);
1109
+ at(i.adapter.name, v.toString()), m().debug("[CryptoButton] All conditions met! Processing pending payment:", V);
1087
1110
  const s = V;
1088
1111
  q(null), G(!1);
1089
1112
  const T = s.type === "cart" && s.items ? K(s.items) : void 0;
1090
- de("crypto", s.resource, T), s.type === "cart" && s.items ? (f().debug("[CryptoButton] Auto-processing cart payment"), we.current(s.items, s.metadata, s.couponCode)) : s.type === "single" && s.resource && (f().debug("[CryptoButton] Auto-processing single payment"), _e.current(s.resource, s.couponCode, s.metadata));
1113
+ de("crypto", s.resource, T), s.type === "cart" && s.items ? (m().debug("[CryptoButton] Auto-processing cart payment"), we.current(s.items, s.metadata, s.couponCode)) : s.type === "single" && s.resource && (m().debug("[CryptoButton] Auto-processing single payment"), _e.current(s.resource, s.couponCode, s.metadata));
1091
1114
  }
1092
1115
  }, [y, V, v, i]);
1093
- const Te = A(async () => {
1094
- f().debug("[CryptoButton] executePaymentFlow called", {
1116
+ const Te = x(async () => {
1117
+ m().debug("[CryptoButton] executePaymentFlow called", {
1095
1118
  connected: y,
1096
1119
  wallet: i?.adapter.name,
1097
1120
  couponCode: w,
@@ -1100,28 +1123,28 @@ function dt({
1100
1123
  effectiveResource: P
1101
1124
  });
1102
1125
  const s = O && t ? K(t) : void 0;
1103
- if (Me("crypto", P, s), o && o("crypto"), X) {
1104
- f().error("[CryptoButton] Solana dependencies missing:", X), ae("crypto", X, P, s), l && l(X);
1126
+ if (Me("crypto", P, s), a && a("crypto"), X) {
1127
+ m().error("[CryptoButton] Solana dependencies missing:", X), ae("crypto", X, P, s), l && l(X);
1105
1128
  return;
1106
1129
  }
1107
1130
  if (be) {
1108
- const T = S || window.location.href;
1131
+ const T = N || window.location.href;
1109
1132
  window.open(T, "_blank", "noopener,noreferrer");
1110
1133
  return;
1111
1134
  }
1112
1135
  if (y)
1113
- de("crypto", P, s), O && t ? (f().debug("[CryptoButton] Processing cart payment with coupon:", w), await k(t, _, w)) : P && (f().debug("[CryptoButton] Processing single payment with coupon:", w), await I(P, w, _));
1136
+ de("crypto", P, s), O && t ? (m().debug("[CryptoButton] Processing cart payment with coupon:", w), await k(t, _, w)) : P && (m().debug("[CryptoButton] Processing single payment with coupon:", w), await I(P, w, _));
1114
1137
  else {
1115
1138
  let T = !1;
1116
- if (O && t ? (f().debug("[CryptoButton] Setting pending cart payment with coupon:", w), q({ type: "cart", items: t, metadata: _, couponCode: w }), T = !0) : P && (f().debug("[CryptoButton] Setting pending single payment with coupon:", w), q({ type: "single", resource: P, metadata: _, couponCode: w }), T = !0), !T) {
1117
- f().error("[CryptoButton] No valid payment to process");
1139
+ if (O && t ? (m().debug("[CryptoButton] Setting pending cart payment with coupon:", w), q({ type: "cart", items: t, metadata: _, couponCode: w }), T = !0) : P && (m().debug("[CryptoButton] Setting pending single payment with coupon:", w), q({ type: "single", resource: P, metadata: _, couponCode: w }), T = !0), !T) {
1140
+ m().error("[CryptoButton] No valid payment to process");
1118
1141
  return;
1119
1142
  }
1120
1143
  try {
1121
1144
  if (i)
1122
- f().debug("[CryptoButton] Wallet already selected, connecting:", i.adapter.name), Se(i.adapter.name), await D();
1145
+ m().debug("[CryptoButton] Wallet already selected, connecting:", i.adapter.name), Se(i.adapter.name), await D();
1123
1146
  else {
1124
- if (f().debug(
1147
+ if (m().debug(
1125
1148
  "[CryptoButton] No wallet selected, showing selector. Available wallets:",
1126
1149
  J.map((j) => j.adapter.name)
1127
1150
  ), J.length === 0) {
@@ -1134,43 +1157,43 @@ function dt({
1134
1157
  } catch (j) {
1135
1158
  q(null);
1136
1159
  const ee = j instanceof Error ? j.message : "Failed to connect wallet";
1137
- f().error("[CryptoButton] Connection error:", ee), ie(ee, i?.adapter.name);
1160
+ m().error("[CryptoButton] Connection error:", ee), ie(ee, i?.adapter.name);
1138
1161
  }
1139
1162
  }
1140
- }, [y, i, w, O, t, P, be, S, J, D, _, k, I, X, o, l]), Re = W(() => O && t ? `crypto-cart-${t.map((s) => s.resource).join("-")}` : `crypto-${P || "unknown"}`, [O, t, P]), Ue = W(
1163
+ }, [y, i, w, O, t, P, be, N, J, D, _, k, I, X, a, l]), Re = W(() => O && t ? `crypto-cart-${t.map((s) => s.resource).join("-")}` : `crypto-${P || "unknown"}`, [O, t, P]), Be = W(
1141
1164
  () => Le(Re, Te, {
1142
1165
  cooldownMs: 200,
1143
1166
  deduplicationWindowMs: 0
1144
1167
  // MUST be 0 for crypto - each payment needs fresh transaction
1145
1168
  }),
1146
1169
  [Re, Te]
1147
- ), Ne = c === "loading", We = a || Ne || b || !!X, qe = Ne ? B("ui.processing") : Z, $e = A(async () => {
1170
+ ), Ne = c === "loading", We = o || Ne || b || !!X, qe = Ne ? U("ui.processing") : Z, $e = x(async () => {
1148
1171
  try {
1149
- re(!1), y && await H(), m(null), G(!0);
1172
+ re(!1), y && await H(), f(null), G(!0);
1150
1173
  } catch (s) {
1151
- f().error("Failed to change wallet:", s);
1174
+ m().error("Failed to change wallet:", s);
1152
1175
  }
1153
- }, [y, H, m]), ze = A((s) => {
1154
- f().debug("[CryptoButton] Wallet clicked:", s), G(!1), m(s), re(!0), f().debug("[CryptoButton] Wallet selected, useEffect will auto-connect");
1155
- }, [m]), Ye = A(async () => {
1176
+ }, [y, H, f]), ze = x((s) => {
1177
+ m().debug("[CryptoButton] Wallet clicked:", s), G(!1), f(s), re(!0), m().debug("[CryptoButton] Wallet selected, useEffect will auto-connect");
1178
+ }, [f]), Ye = x(async () => {
1156
1179
  try {
1157
1180
  await H(), q(null), typeof window < "u" && window.localStorage && window.localStorage.removeItem("walletName");
1158
1181
  } catch (s) {
1159
- f().error("Failed to disconnect wallet:", s);
1182
+ m().error("Failed to disconnect wallet:", s);
1160
1183
  }
1161
1184
  }, [H]);
1162
- return /* @__PURE__ */ E("div", { className: d.unstyled ? p : `${d.className} cedros-theme__crypto-button ${p || ""}`, style: d.unstyled ? {} : d.style, children: [
1163
- /* @__PURE__ */ C(
1185
+ return /* @__PURE__ */ E("div", { className: p.unstyled ? d : `${p.className} cedros-theme__crypto-button ${d || ""}`, style: p.unstyled ? {} : p.style, children: [
1186
+ /* @__PURE__ */ S(
1164
1187
  "button",
1165
1188
  {
1166
- onClick: Ue,
1189
+ onClick: Be,
1167
1190
  disabled: We,
1168
- className: d.unstyled ? p : "cedros-theme__button cedros-theme__crypto",
1191
+ className: p.unstyled ? d : "cedros-theme__button cedros-theme__crypto",
1169
1192
  type: "button",
1170
1193
  children: qe
1171
1194
  }
1172
1195
  ),
1173
- ve && !g && /* @__PURE__ */ C(
1196
+ ve && !g && /* @__PURE__ */ S(
1174
1197
  "div",
1175
1198
  {
1176
1199
  className: "cedros-modal-overlay",
@@ -1180,7 +1203,7 @@ function dt({
1180
1203
  left: 0,
1181
1204
  right: 0,
1182
1205
  bottom: 0,
1183
- backgroundColor: d.tokens.modalOverlay,
1206
+ backgroundColor: p.tokens.modalOverlay,
1184
1207
  display: "flex",
1185
1208
  alignItems: "center",
1186
1209
  justifyContent: "center",
@@ -1193,13 +1216,13 @@ function dt({
1193
1216
  {
1194
1217
  className: "cedros-modal-content",
1195
1218
  style: {
1196
- backgroundColor: d.tokens.modalBackground,
1219
+ backgroundColor: p.tokens.modalBackground,
1197
1220
  borderRadius: "12px",
1198
1221
  padding: "2rem",
1199
1222
  maxWidth: "400px",
1200
1223
  width: "100%",
1201
1224
  boxShadow: "0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",
1202
- border: `1px solid ${d.tokens.modalBorder}`
1225
+ border: `1px solid ${p.tokens.modalBorder}`
1203
1226
  },
1204
1227
  onClick: (s) => s.stopPropagation(),
1205
1228
  children: [
@@ -1213,23 +1236,23 @@ function dt({
1213
1236
  marginBottom: "1.5rem"
1214
1237
  },
1215
1238
  children: [
1216
- /* @__PURE__ */ C(
1239
+ /* @__PURE__ */ S(
1217
1240
  "h3",
1218
1241
  {
1219
1242
  style: {
1220
1243
  margin: 0,
1221
1244
  fontSize: "1.25rem",
1222
1245
  fontWeight: 600,
1223
- color: d.tokens.surfaceText
1246
+ color: p.tokens.surfaceText
1224
1247
  },
1225
- children: B("wallet.select_wallet")
1248
+ children: U("wallet.select_wallet")
1226
1249
  }
1227
1250
  ),
1228
- /* @__PURE__ */ C(
1251
+ /* @__PURE__ */ S(
1229
1252
  "button",
1230
1253
  {
1231
1254
  onClick: () => G(!1),
1232
- style: je(d.tokens.surfaceText),
1255
+ style: je(p.tokens.surfaceText),
1233
1256
  "aria-label": "Close modal",
1234
1257
  type: "button",
1235
1258
  children: "×"
@@ -1238,35 +1261,35 @@ function dt({
1238
1261
  ]
1239
1262
  }
1240
1263
  ),
1241
- /* @__PURE__ */ C("div", { style: { display: "flex", flexDirection: "column", gap: "0.75rem" }, children: J.map((s) => /* @__PURE__ */ E(
1264
+ /* @__PURE__ */ S("div", { style: { display: "flex", flexDirection: "column", gap: "0.75rem" }, children: J.map((s) => /* @__PURE__ */ E(
1242
1265
  "button",
1243
1266
  {
1244
1267
  onClick: () => ze(s.adapter.name),
1245
1268
  style: {
1246
1269
  width: "100%",
1247
1270
  padding: "1rem",
1248
- backgroundColor: d.tokens.surfaceBackground,
1249
- border: `1px solid ${d.tokens.surfaceBorder}`,
1271
+ backgroundColor: p.tokens.surfaceBackground,
1272
+ border: `1px solid ${p.tokens.surfaceBorder}`,
1250
1273
  borderRadius: "0.5rem",
1251
1274
  cursor: "pointer",
1252
1275
  fontSize: "1rem",
1253
1276
  textAlign: "left",
1254
- color: d.tokens.surfaceText,
1277
+ color: p.tokens.surfaceText,
1255
1278
  display: "flex",
1256
1279
  alignItems: "center",
1257
1280
  gap: "1rem",
1258
1281
  transition: "all 0.2s ease"
1259
1282
  },
1260
1283
  onMouseEnter: (T) => {
1261
- T.currentTarget.style.backgroundColor = d.tokens.modalBackground, T.currentTarget.style.borderColor = d.tokens.surfaceText, T.currentTarget.style.transform = "translateY(-2px)";
1284
+ T.currentTarget.style.backgroundColor = p.tokens.modalBackground, T.currentTarget.style.borderColor = p.tokens.surfaceText, T.currentTarget.style.transform = "translateY(-2px)";
1262
1285
  },
1263
1286
  onMouseLeave: (T) => {
1264
- T.currentTarget.style.backgroundColor = d.tokens.surfaceBackground, T.currentTarget.style.borderColor = d.tokens.surfaceBorder, T.currentTarget.style.transform = "translateY(0)";
1287
+ T.currentTarget.style.backgroundColor = p.tokens.surfaceBackground, T.currentTarget.style.borderColor = p.tokens.surfaceBorder, T.currentTarget.style.transform = "translateY(0)";
1265
1288
  },
1266
1289
  type: "button",
1267
1290
  children: [
1268
- /* @__PURE__ */ C(Ge, { wallet: s, style: { width: "24px", height: "24px" } }),
1269
- /* @__PURE__ */ C("span", { style: { fontWeight: 500 }, children: s.adapter.name })
1291
+ /* @__PURE__ */ S(Ge, { wallet: s, style: { width: "24px", height: "24px" } }),
1292
+ /* @__PURE__ */ S("span", { style: { fontWeight: 500 }, children: s.adapter.name })
1270
1293
  ]
1271
1294
  },
1272
1295
  s.adapter.name
@@ -1281,10 +1304,10 @@ function dt({
1281
1304
  justifyContent: "space-between",
1282
1305
  marginTop: "0.5rem",
1283
1306
  fontSize: "0.75rem",
1284
- color: d.tokens.surfaceText,
1307
+ color: p.tokens.surfaceText,
1285
1308
  opacity: 0.7
1286
1309
  }, children: [
1287
- /* @__PURE__ */ C(
1310
+ /* @__PURE__ */ S(
1288
1311
  "button",
1289
1312
  {
1290
1313
  onClick: $e,
@@ -1301,7 +1324,7 @@ function dt({
1301
1324
  children: "Change Wallet"
1302
1325
  }
1303
1326
  ),
1304
- /* @__PURE__ */ C(
1327
+ /* @__PURE__ */ S(
1305
1328
  "button",
1306
1329
  {
1307
1330
  onClick: Ye,
@@ -1315,25 +1338,25 @@ function dt({
1315
1338
  fontSize: "inherit"
1316
1339
  },
1317
1340
  type: "button",
1318
- children: B("ui.disconnect")
1341
+ children: U("ui.disconnect")
1319
1342
  }
1320
1343
  )
1321
1344
  ] }),
1322
- !g && he && /* @__PURE__ */ C("div", { className: d.unstyled ? "" : "cedros-theme__error", children: he }),
1323
- !g && Y && /* @__PURE__ */ C("div", { className: d.unstyled ? "" : "cedros-theme__error", children: Y }),
1324
- !g && N && /* @__PURE__ */ C("div", { className: d.unstyled ? "" : "cedros-theme__success", children: B("ui.payment_successful") })
1345
+ !g && he && /* @__PURE__ */ S("div", { className: p.unstyled ? "" : "cedros-theme__error", children: he }),
1346
+ !g && Y && /* @__PURE__ */ S("div", { className: p.unstyled ? "" : "cedros-theme__error", children: Y }),
1347
+ !g && C && /* @__PURE__ */ S("div", { className: p.unstyled ? "" : "cedros-theme__success", children: U("ui.payment_successful") })
1325
1348
  ] });
1326
1349
  }
1327
- const Pt = ({
1350
+ const Dt = ({
1328
1351
  isOpen: e,
1329
1352
  onClose: t,
1330
1353
  resource: n,
1331
- items: a,
1332
- cardLabel: o = "Card",
1354
+ items: o,
1355
+ cardLabel: a = "Card",
1333
1356
  cryptoLabel: r = "USDC (Solana)",
1334
1357
  showCard: l = !0,
1335
- showCrypto: p = !0,
1336
- onPaymentAttempt: S,
1358
+ showCrypto: d = !0,
1359
+ onPaymentAttempt: N,
1337
1360
  onPaymentSuccess: g,
1338
1361
  onPaymentError: _,
1339
1362
  onStripeSuccess: w,
@@ -1341,20 +1364,20 @@ const Pt = ({
1341
1364
  onStripeError: b,
1342
1365
  onCryptoError: D,
1343
1366
  customerEmail: H,
1344
- successUrl: m,
1367
+ successUrl: f,
1345
1368
  cancelUrl: h,
1346
1369
  metadata: i,
1347
1370
  couponCode: v,
1348
1371
  testPageUrl: c,
1349
1372
  hideMessages: u = !1
1350
1373
  }) => {
1351
- const { tokens: N } = fe();
1352
- return U(() => {
1374
+ const { tokens: C } = me();
1375
+ return B(() => {
1353
1376
  const I = (k) => {
1354
1377
  k.key === "Escape" && e && t();
1355
1378
  };
1356
1379
  return window.addEventListener("keydown", I), () => window.removeEventListener("keydown", I);
1357
- }, [e, t]), U(() => {
1380
+ }, [e, t]), B(() => {
1358
1381
  if (e) {
1359
1382
  const I = window.scrollY;
1360
1383
  return document.body.style.position = "fixed", document.body.style.top = `-${I}px`, document.body.style.width = "100%", document.body.style.overflowY = "scroll", () => {
@@ -1362,7 +1385,7 @@ const Pt = ({
1362
1385
  document.body.style.position = "", document.body.style.top = "", document.body.style.width = "", document.body.style.overflowY = "", window.scrollTo(0, k);
1363
1386
  };
1364
1387
  }
1365
- }, [e]), e ? /* @__PURE__ */ C(
1388
+ }, [e]), e ? /* @__PURE__ */ S(
1366
1389
  "div",
1367
1390
  {
1368
1391
  className: "cedros-modal-overlay",
@@ -1372,7 +1395,7 @@ const Pt = ({
1372
1395
  left: 0,
1373
1396
  right: 0,
1374
1397
  bottom: 0,
1375
- backgroundColor: N.modalOverlay,
1398
+ backgroundColor: C.modalOverlay,
1376
1399
  display: "flex",
1377
1400
  alignItems: "center",
1378
1401
  justifyContent: "center",
@@ -1385,13 +1408,13 @@ const Pt = ({
1385
1408
  {
1386
1409
  className: "cedros-modal-content",
1387
1410
  style: {
1388
- backgroundColor: N.modalBackground,
1411
+ backgroundColor: C.modalBackground,
1389
1412
  borderRadius: "12px",
1390
1413
  padding: "2rem",
1391
1414
  maxWidth: "400px",
1392
1415
  width: "100%",
1393
1416
  boxShadow: "0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",
1394
- border: `1px solid ${N.modalBorder}`
1417
+ border: `1px solid ${C.modalBorder}`
1395
1418
  },
1396
1419
  onClick: (I) => I.stopPropagation(),
1397
1420
  children: [
@@ -1405,23 +1428,23 @@ const Pt = ({
1405
1428
  marginBottom: "1.5rem"
1406
1429
  },
1407
1430
  children: [
1408
- /* @__PURE__ */ C(
1431
+ /* @__PURE__ */ S(
1409
1432
  "h3",
1410
1433
  {
1411
1434
  style: {
1412
1435
  margin: 0,
1413
1436
  fontSize: "1.25rem",
1414
1437
  fontWeight: 600,
1415
- color: N.surfaceText
1438
+ color: C.surfaceText
1416
1439
  },
1417
1440
  children: "Choose Payment Method"
1418
1441
  }
1419
1442
  ),
1420
- /* @__PURE__ */ C(
1443
+ /* @__PURE__ */ S(
1421
1444
  "button",
1422
1445
  {
1423
1446
  onClick: t,
1424
- style: je(N.surfaceText),
1447
+ style: je(C.surfaceText),
1425
1448
  "aria-label": "Close modal",
1426
1449
  children: "×"
1427
1450
  }
@@ -1430,29 +1453,29 @@ const Pt = ({
1430
1453
  }
1431
1454
  ),
1432
1455
  /* @__PURE__ */ E("div", { style: { display: "flex", flexDirection: "column", gap: "1rem" }, children: [
1433
- l && /* @__PURE__ */ C(
1456
+ l && /* @__PURE__ */ S(
1434
1457
  lt,
1435
1458
  {
1436
1459
  resource: n,
1437
- items: a,
1438
- label: o,
1439
- onAttempt: S,
1460
+ items: o,
1461
+ label: a,
1462
+ onAttempt: N,
1440
1463
  onSuccess: w || g,
1441
1464
  onError: b || _,
1442
1465
  customerEmail: H,
1443
- successUrl: m,
1466
+ successUrl: f,
1444
1467
  cancelUrl: h,
1445
1468
  metadata: i,
1446
1469
  couponCode: v
1447
1470
  }
1448
1471
  ),
1449
- p && /* @__PURE__ */ C(
1472
+ d && /* @__PURE__ */ S(
1450
1473
  dt,
1451
1474
  {
1452
1475
  resource: n,
1453
- items: a,
1476
+ items: o,
1454
1477
  label: r,
1455
- onAttempt: S,
1478
+ onAttempt: N,
1456
1479
  onSuccess: y || g,
1457
1480
  onError: D || _,
1458
1481
  testPageUrl: c,
@@ -1468,15 +1491,15 @@ const Pt = ({
1468
1491
  }
1469
1492
  ) : null;
1470
1493
  };
1471
- function Dt({
1494
+ function Et({
1472
1495
  product: e,
1473
1496
  paymentMethod: t,
1474
1497
  showOriginalPrice: n = !1,
1475
- className: a = "",
1476
- style: o = {}
1498
+ className: o = "",
1499
+ style: a = {}
1477
1500
  }) {
1478
- const r = t === "stripe", l = r ? e.fiatAmount : e.cryptoAmount, p = r ? e.effectiveFiatAmount : e.effectiveCryptoAmount, S = r ? e.fiatCurrency.toUpperCase() : e.cryptoToken, g = r ? e.hasStripeCoupon : e.hasCryptoCoupon, _ = r ? e.stripeDiscountPercent : e.cryptoDiscountPercent;
1479
- return /* @__PURE__ */ E("div", { className: a, style: o, children: [
1501
+ const r = t === "stripe", l = r ? e.fiatAmount : e.cryptoAmount, d = r ? e.effectiveFiatAmount : e.effectiveCryptoAmount, N = r ? e.fiatCurrency.toUpperCase() : e.cryptoToken, g = r ? e.hasStripeCoupon : e.hasCryptoCoupon, _ = r ? e.stripeDiscountPercent : e.cryptoDiscountPercent;
1502
+ return /* @__PURE__ */ E("div", { className: o, style: a, children: [
1480
1503
  n && g && /* @__PURE__ */ E(
1481
1504
  "span",
1482
1505
  {
@@ -1489,14 +1512,14 @@ function Dt({
1489
1512
  children: [
1490
1513
  l.toFixed(2),
1491
1514
  " ",
1492
- S
1515
+ N
1493
1516
  ]
1494
1517
  }
1495
1518
  ),
1496
1519
  /* @__PURE__ */ E("span", { style: { fontWeight: 600 }, children: [
1497
- p.toFixed(2),
1520
+ d.toFixed(2),
1498
1521
  " ",
1499
- S
1522
+ N
1500
1523
  ] }),
1501
1524
  g && _ > 0 && /* @__PURE__ */ E(
1502
1525
  "span",
@@ -1518,16 +1541,16 @@ function Dt({
1518
1541
  )
1519
1542
  ] });
1520
1543
  }
1521
- function Et({
1544
+ function Ot({
1522
1545
  product: e,
1523
1546
  paymentMethod: t,
1524
1547
  className: n = "",
1525
- style: a = {}
1548
+ style: o = {}
1526
1549
  }) {
1527
- const o = t === "stripe", r = o ? e.hasStripeCoupon : e.hasCryptoCoupon, l = o ? e.stripeDiscountPercent : e.cryptoDiscountPercent, p = o ? e.stripeCouponCode : e.cryptoCouponCode;
1550
+ const a = t === "stripe", r = a ? e.hasStripeCoupon : e.hasCryptoCoupon, l = a ? e.stripeDiscountPercent : e.cryptoDiscountPercent, d = a ? e.stripeCouponCode : e.cryptoCouponCode;
1528
1551
  if (!r || l === 0)
1529
1552
  return null;
1530
- const S = o ? `${l}% off with card!` : `${l}% off with crypto!`;
1553
+ const N = a ? `${l}% off with card!` : `${l}% off with crypto!`;
1531
1554
  return /* @__PURE__ */ E(
1532
1555
  "div",
1533
1556
  {
@@ -1536,16 +1559,16 @@ function Et({
1536
1559
  display: "inline-flex",
1537
1560
  alignItems: "center",
1538
1561
  padding: "0.5rem 0.75rem",
1539
- backgroundColor: o ? "#6366f1" : "#10b981",
1562
+ backgroundColor: a ? "#6366f1" : "#10b981",
1540
1563
  color: "white",
1541
1564
  borderRadius: "0.375rem",
1542
1565
  fontSize: "0.875rem",
1543
1566
  fontWeight: 600,
1544
- ...a
1567
+ ...o
1545
1568
  },
1546
1569
  children: [
1547
- S,
1548
- p && /* @__PURE__ */ E(
1570
+ N,
1571
+ d && /* @__PURE__ */ E(
1549
1572
  "span",
1550
1573
  {
1551
1574
  style: {
@@ -1556,7 +1579,7 @@ function Et({
1556
1579
  },
1557
1580
  children: [
1558
1581
  "(",
1559
- p,
1582
+ d,
1560
1583
  ")"
1561
1584
  ]
1562
1585
  }
@@ -1566,14 +1589,15 @@ function Et({
1566
1589
  );
1567
1590
  }
1568
1591
  export {
1569
- Ct as A,
1592
+ ct as A,
1570
1593
  St as B,
1571
1594
  $ as C,
1572
- It as E,
1573
- Pt as P,
1595
+ Pt as D,
1596
+ Tt as E,
1597
+ Dt as P,
1574
1598
  lt as S,
1575
- Dt as a,
1576
- Et as b,
1599
+ Et as a,
1600
+ Ot as b,
1577
1601
  Fe as c,
1578
1602
  vt as d,
1579
1603
  Me as e,
@@ -1581,21 +1605,21 @@ export {
1581
1605
  de as g,
1582
1606
  He as h,
1583
1607
  ae as i,
1584
- Tt as j,
1585
- Rt as k,
1586
- Nt as l,
1608
+ Rt as j,
1609
+ Nt as k,
1610
+ Ct as l,
1587
1611
  dt as m,
1588
1612
  ut as n,
1589
1613
  ye as o,
1590
1614
  wt as p,
1591
1615
  K as q,
1592
1616
  Le as r,
1593
- Se as s,
1594
- at as t,
1617
+ It as s,
1618
+ Se as t,
1595
1619
  ot as u,
1596
- ie as v,
1597
- st as w,
1598
- it as x,
1599
- kt as y,
1600
- ct as z
1620
+ at as v,
1621
+ ie as w,
1622
+ st as x,
1623
+ it as y,
1624
+ kt as z
1601
1625
  };