@doujins/payments-ui 0.1.8 → 0.1.9

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,5 +1,5 @@
1
- import * as React17 from 'react';
2
- import React17__default, { createContext, useMemo, useState, useEffect, useCallback, useRef, useContext } from 'react';
1
+ import * as React15 from 'react';
2
+ import React15__default, { createContext, useMemo, useState, useEffect, useCallback, useRef, useContext } from 'react';
3
3
  import { useQueryClient, useQuery, useMutation, QueryClient, QueryClientProvider, useInfiniteQuery } from '@tanstack/react-query';
4
4
  import { ConnectionProvider, WalletProvider, useWallet, useConnection } from '@solana/wallet-adapter-react';
5
5
  import { WalletModalProvider } from '@solana/wallet-adapter-react-ui';
@@ -11,7 +11,7 @@ import { SolflareWalletAdapter } from '@solana/wallet-adapter-solflare';
11
11
  import { TrustWalletAdapter } from '@solana/wallet-adapter-trust';
12
12
  import { CoinbaseWalletAdapter } from '@solana/wallet-adapter-coinbase';
13
13
  import * as DialogPrimitive from '@radix-ui/react-dialog';
14
- import { X, ChevronDown, ChevronUp, Check, Loader2, CheckCircle, AlertCircle, Wallet, Ban, TriangleAlert, WalletCards, CreditCard, Trash2, Shield, UserRound, Calendar, KeyRound, XCircle, RotateCcw, RefreshCw } from 'lucide-react';
14
+ import { ChevronDown, ChevronUp, Check, Loader2, CheckCircle, AlertCircle, Wallet, Ban, TriangleAlert, CreditCard, Trash2, Shield, UserRound, Calendar, KeyRound, XIcon, XCircle, RotateCcw, RefreshCw } from 'lucide-react';
15
15
  import clsx2, { clsx } from 'clsx';
16
16
  import { twMerge } from 'tailwind-merge';
17
17
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
@@ -31,30 +31,119 @@ import { getAssociatedTokenAddress, getAccount } from '@solana/spl-token';
31
31
 
32
32
  // src/utils/collect.ts
33
33
  var SCRIPT_SRC = "https://secure.networkmerchants.com/token/Collect.js";
34
+ var baseFieldReset = {
35
+ border: "none",
36
+ "border-bottom": "0",
37
+ "border-top": "0",
38
+ "border-left": "0",
39
+ "border-right": "0",
40
+ "border-width": "0",
41
+ "border-color": "transparent",
42
+ "border-style": "none",
43
+ outline: "none",
44
+ "box-shadow": "none",
45
+ "background-clip": "padding-box",
46
+ "text-decoration": "none"
47
+ };
48
+ var customCss = {
49
+ ...baseFieldReset,
50
+ background: "#0d1325",
51
+ "background-color": "#0d1325",
52
+ color: "#e2e8f0",
53
+ padding: "0",
54
+ margin: "0",
55
+ width: "100%",
56
+ height: "100%",
57
+ "font-size": "15px",
58
+ "letter-spacing": "0.05em",
59
+ "line-height": "1.5"
60
+ };
61
+ var focusCss = {
62
+ ...baseFieldReset,
63
+ color: "#f8fafc",
64
+ "box-shadow": "0 0 0 1px rgba(94,234,212,0.3)"
65
+ };
66
+ var invalidCss = {
67
+ ...baseFieldReset,
68
+ color: "#fecaca",
69
+ "box-shadow": "0 0 0 1px rgba(248,113,113,0.5)"
70
+ };
71
+ var placeholderCss = {
72
+ color: "rgba(226,232,240,0.45)",
73
+ "font-size": "14px",
74
+ "letter-spacing": "0.03em"
75
+ };
76
+ var baseCssString = JSON.stringify(customCss);
77
+ var focusCssString = JSON.stringify(focusCss);
78
+ var invalidCssString = JSON.stringify(invalidCss);
79
+ var placeholderCssString = JSON.stringify(placeholderCss);
80
+ var collectCssConfig = {
81
+ customCss,
82
+ focusCss,
83
+ invalidCss,
84
+ placeholderCss
85
+ };
86
+ var loadPromise = null;
34
87
  var loadCollectJs = (tokenizationKey) => {
35
88
  if (typeof document === "undefined") return;
89
+ if (typeof window !== "undefined" && window.CollectJS) {
90
+ return Promise.resolve();
91
+ }
36
92
  const trimmed = tokenizationKey?.trim();
37
93
  if (!trimmed || trimmed.length < 10) {
38
94
  console.warn("payments-ui: invalid Collect.js key, skipping load");
39
95
  return;
40
96
  }
97
+ if (loadPromise) {
98
+ return loadPromise;
99
+ }
41
100
  const existing = document.querySelector(`script[src="${SCRIPT_SRC}"]`);
42
- if (existing) return;
43
- const script = document.createElement("script");
44
- script.src = SCRIPT_SRC;
45
- script.setAttribute("data-tokenization-key", trimmed);
46
- script.setAttribute("data-field-ccnumber-placeholder", "0000 0000 0000 0000");
47
- script.setAttribute("data-field-ccexp-placeholder", "10 / 25");
48
- script.setAttribute("data-field-cvv-placeholder", "123");
49
- script.setAttribute("data-variant", "inline");
50
- script.async = true;
51
- script.addEventListener("load", () => {
52
- console.log("payments-ui: Collect.js loaded");
53
- });
54
- script.addEventListener("error", (event) => {
55
- console.error("payments-ui: failed to load Collect.js", event);
101
+ if (existing) {
102
+ loadPromise = new Promise((resolve) => {
103
+ existing.addEventListener("load", () => resolve(), { once: true });
104
+ existing.addEventListener("error", () => resolve(), { once: true });
105
+ });
106
+ return loadPromise;
107
+ }
108
+ loadPromise = new Promise((resolve, reject) => {
109
+ const script = document.createElement("script");
110
+ script.src = SCRIPT_SRC;
111
+ script.setAttribute("data-tokenization-key", trimmed);
112
+ script.setAttribute("data-field-ccnumber-placeholder", "0000 0000 0000 0000");
113
+ script.setAttribute("data-field-ccexp-placeholder", "10 / 25");
114
+ script.setAttribute("data-field-cvv-placeholder", "123");
115
+ script.setAttribute("data-variant", "inline");
116
+ script.setAttribute("data-style-sniffer", "false");
117
+ script.setAttribute("data-custom-css", baseCssString);
118
+ script.setAttribute("data-placeholder-css", placeholderCssString);
119
+ script.setAttribute("data-focus-css", focusCssString);
120
+ script.setAttribute("data-invalid-css", invalidCssString);
121
+ script.async = true;
122
+ script.addEventListener("load", () => {
123
+ console.log("payments-ui: Collect.js loaded");
124
+ resolve();
125
+ });
126
+ script.addEventListener("error", (event) => {
127
+ console.error("payments-ui: failed to load Collect.js", event);
128
+ reject(event);
129
+ });
130
+ document.head.appendChild(script);
56
131
  });
57
- document.head.appendChild(script);
132
+ window.__doujinsCollectPromise = loadPromise;
133
+ return loadPromise;
134
+ };
135
+ var waitForCollectJs = async () => {
136
+ if (typeof window === "undefined") return null;
137
+ if (window.CollectJS) return window.CollectJS;
138
+ const promise = loadPromise ?? window.__doujinsCollectPromise;
139
+ if (!promise) return null;
140
+ try {
141
+ await promise;
142
+ return window.CollectJS ?? null;
143
+ } catch (error) {
144
+ console.error("payments-ui: Collect.js failed to initialise", error);
145
+ return null;
146
+ }
58
147
  };
59
148
 
60
149
  // src/lib/client.ts
@@ -262,77 +351,103 @@ var createClient = (config) => {
262
351
  function cn(...inputs) {
263
352
  return twMerge(clsx(inputs));
264
353
  }
265
- var Dialog = DialogPrimitive.Root;
266
- var DialogPortal = DialogPrimitive.Portal;
267
- var DialogOverlay = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
268
- DialogPrimitive.Overlay,
269
- {
270
- ref,
271
- className: cn(
272
- "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
273
- className
274
- ),
275
- ...props
276
- }
277
- ));
278
- DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
279
- var DialogContent = React17.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(DialogPortal, { children: [
280
- /* @__PURE__ */ jsx(DialogOverlay, {}),
281
- /* @__PURE__ */ jsxs(
282
- DialogPrimitive.Content,
354
+ function Dialog({
355
+ ...props
356
+ }) {
357
+ return /* @__PURE__ */ jsx(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
358
+ }
359
+ function DialogPortal({
360
+ ...props
361
+ }) {
362
+ return /* @__PURE__ */ jsx(DialogPrimitive.Portal, { "data-slot": "dialog-portal", ...props });
363
+ }
364
+ function DialogOverlay({
365
+ className,
366
+ ...props
367
+ }) {
368
+ return /* @__PURE__ */ jsx(
369
+ DialogPrimitive.Overlay,
283
370
  {
284
- ref,
371
+ "data-slot": "dialog-overlay",
285
372
  className: cn(
286
- "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
373
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
287
374
  className
288
375
  ),
289
- ...props,
290
- children: [
291
- children,
292
- /* @__PURE__ */ jsxs(DialogPrimitive.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground", children: [
293
- /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }),
294
- /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
295
- ] })
296
- ]
376
+ ...props
297
377
  }
298
- )
299
- ] }));
300
- DialogContent.displayName = DialogPrimitive.Content.displayName;
301
- var DialogHeader = ({
378
+ );
379
+ }
380
+ function DialogContent({
302
381
  className,
382
+ children,
383
+ showCloseButton = true,
303
384
  ...props
304
- }) => /* @__PURE__ */ jsx(
305
- "div",
306
- {
307
- className: cn(
308
- "flex flex-col space-y-1.5 text-center sm:text-left",
309
- className
310
- ),
311
- ...props
312
- }
313
- );
314
- DialogHeader.displayName = "DialogHeader";
315
- var DialogTitle = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
316
- DialogPrimitive.Title,
317
- {
318
- ref,
319
- className: cn(
320
- "text-lg font-semibold leading-none tracking-tight",
321
- className
322
- ),
323
- ...props
324
- }
325
- ));
326
- DialogTitle.displayName = DialogPrimitive.Title.displayName;
327
- var DialogDescription = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
328
- DialogPrimitive.Description,
329
- {
330
- ref,
331
- className: cn("text-sm text-muted-foreground", className),
332
- ...props
333
- }
334
- ));
335
- DialogDescription.displayName = DialogPrimitive.Description.displayName;
385
+ }) {
386
+ return /* @__PURE__ */ jsxs(DialogPortal, { "data-slot": "dialog-portal", children: [
387
+ /* @__PURE__ */ jsx(DialogOverlay, {}),
388
+ /* @__PURE__ */ jsxs(
389
+ DialogPrimitive.Content,
390
+ {
391
+ "data-slot": "dialog-content",
392
+ className: cn(
393
+ "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 outline-none sm:max-w-lg",
394
+ className
395
+ ),
396
+ ...props,
397
+ children: [
398
+ children,
399
+ showCloseButton && /* @__PURE__ */ jsxs(
400
+ DialogPrimitive.Close,
401
+ {
402
+ "data-slot": "dialog-close",
403
+ className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
404
+ children: [
405
+ /* @__PURE__ */ jsx(XIcon, {}),
406
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
407
+ ]
408
+ }
409
+ )
410
+ ]
411
+ }
412
+ )
413
+ ] });
414
+ }
415
+ function DialogHeader({ className, ...props }) {
416
+ return /* @__PURE__ */ jsx(
417
+ "div",
418
+ {
419
+ "data-slot": "dialog-header",
420
+ className: cn("flex flex-col gap-2 text-center sm:text-left", className),
421
+ ...props
422
+ }
423
+ );
424
+ }
425
+ function DialogTitle({
426
+ className,
427
+ ...props
428
+ }) {
429
+ return /* @__PURE__ */ jsx(
430
+ DialogPrimitive.Title,
431
+ {
432
+ "data-slot": "dialog-title",
433
+ className: cn("text-lg leading-none font-semibold", className),
434
+ ...props
435
+ }
436
+ );
437
+ }
438
+ function DialogDescription({
439
+ className,
440
+ ...props
441
+ }) {
442
+ return /* @__PURE__ */ jsx(
443
+ DialogPrimitive.Description,
444
+ {
445
+ "data-slot": "dialog-description",
446
+ className: cn("text-muted-foreground text-sm", className),
447
+ ...props
448
+ }
449
+ );
450
+ }
336
451
  var customCountries = [
337
452
  { code: "TW", name: "Taiwan, Province of China" },
338
453
  { code: "KR", name: "Korea" },
@@ -373,7 +488,7 @@ var buttonVariants = cva(
373
488
  }
374
489
  }
375
490
  );
376
- var Button = React17.forwardRef(
491
+ var Button = React15.forwardRef(
377
492
  ({ className, variant, size, asChild = false, ...props }, ref) => {
378
493
  const Comp = asChild ? Slot : "button";
379
494
  return /* @__PURE__ */ jsx(
@@ -387,7 +502,7 @@ var Button = React17.forwardRef(
387
502
  }
388
503
  );
389
504
  Button.displayName = "Button";
390
- var Input = React17.forwardRef(
505
+ var Input = React15.forwardRef(
391
506
  ({ className, type, ...props }, ref) => {
392
507
  return /* @__PURE__ */ jsx(
393
508
  "input",
@@ -407,7 +522,7 @@ Input.displayName = "Input";
407
522
  var labelVariants = cva(
408
523
  "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
409
524
  );
410
- var Label = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
525
+ var Label = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
411
526
  LabelPrimitive.Root,
412
527
  {
413
528
  ref,
@@ -418,7 +533,7 @@ var Label = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
418
533
  Label.displayName = LabelPrimitive.Root.displayName;
419
534
  var Select = SelectPrimitive.Root;
420
535
  var SelectValue = SelectPrimitive.Value;
421
- var SelectTrigger = React17.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
536
+ var SelectTrigger = React15.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
422
537
  SelectPrimitive.Trigger,
423
538
  {
424
539
  ref,
@@ -434,7 +549,7 @@ var SelectTrigger = React17.forwardRef(({ className, children, ...props }, ref)
434
549
  }
435
550
  ));
436
551
  SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
437
- var SelectScrollUpButton = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
552
+ var SelectScrollUpButton = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
438
553
  SelectPrimitive.ScrollUpButton,
439
554
  {
440
555
  ref,
@@ -447,7 +562,7 @@ var SelectScrollUpButton = React17.forwardRef(({ className, ...props }, ref) =>
447
562
  }
448
563
  ));
449
564
  SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
450
- var SelectScrollDownButton = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
565
+ var SelectScrollDownButton = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
451
566
  SelectPrimitive.ScrollDownButton,
452
567
  {
453
568
  ref,
@@ -460,7 +575,7 @@ var SelectScrollDownButton = React17.forwardRef(({ className, ...props }, ref) =
460
575
  }
461
576
  ));
462
577
  SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
463
- var SelectContent = React17.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsx(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsxs(
578
+ var SelectContent = React15.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsx(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsxs(
464
579
  SelectPrimitive.Content,
465
580
  {
466
581
  ref,
@@ -488,7 +603,7 @@ var SelectContent = React17.forwardRef(({ className, children, position = "poppe
488
603
  }
489
604
  ) }));
490
605
  SelectContent.displayName = SelectPrimitive.Content.displayName;
491
- var SelectLabel = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
606
+ var SelectLabel = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
492
607
  SelectPrimitive.Label,
493
608
  {
494
609
  ref,
@@ -497,7 +612,7 @@ var SelectLabel = React17.forwardRef(({ className, ...props }, ref) => /* @__PUR
497
612
  }
498
613
  ));
499
614
  SelectLabel.displayName = SelectPrimitive.Label.displayName;
500
- var SelectItem = React17.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
615
+ var SelectItem = React15.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
501
616
  SelectPrimitive.Item,
502
617
  {
503
618
  ref,
@@ -513,7 +628,7 @@ var SelectItem = React17.forwardRef(({ className, children, ...props }, ref) =>
513
628
  }
514
629
  ));
515
630
  SelectItem.displayName = SelectPrimitive.Item.displayName;
516
- var SelectSeparator = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
631
+ var SelectSeparator = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
517
632
  SelectPrimitive.Separator,
518
633
  {
519
634
  ref,
@@ -568,6 +683,21 @@ var CardDetailsForm = ({
568
683
  const [email, setEmail] = useState(mergedDefaults.email ?? "");
569
684
  const [localError, setLocalError] = useState(null);
570
685
  const [isTokenizing, setIsTokenizing] = useState(false);
686
+ const [collectReady, setCollectReady] = useState(
687
+ typeof window !== "undefined" && Boolean(window.CollectJS)
688
+ );
689
+ useEffect(() => {
690
+ if (collectReady) return;
691
+ let active = true;
692
+ waitForCollectJs().then((instance) => {
693
+ if (active && instance) {
694
+ setCollectReady(true);
695
+ }
696
+ });
697
+ return () => {
698
+ active = false;
699
+ };
700
+ }, [collectReady]);
571
701
  useEffect(() => {
572
702
  if (!visible) {
573
703
  setLocalError(null);
@@ -610,8 +740,22 @@ var CardDetailsForm = ({
610
740
  mergedDefaults.provider,
611
741
  onBillingChange
612
742
  ]);
743
+ const sanitizeCollectField = (field) => {
744
+ const sanitized = { ...field };
745
+ if ("style_input" in sanitized || "style_placeholder" in sanitized) {
746
+ delete sanitized.style_input;
747
+ delete sanitized.style_placeholder;
748
+ if (typeof window !== "undefined") {
749
+ console.warn(
750
+ "[payments-ui] stripping unsupported Collect.js style fields",
751
+ Object.keys(field).filter((key) => key.startsWith("style_"))
752
+ );
753
+ }
754
+ }
755
+ return sanitized;
756
+ };
613
757
  useEffect(() => {
614
- if (typeof window === "undefined" || !window.CollectJS || !visible) {
758
+ if (!collectReady || typeof window === "undefined" || !window.CollectJS || !visible) {
615
759
  return;
616
760
  }
617
761
  const handlers = window.__doujinsCollectHandlers || (window.__doujinsCollectHandlers = {});
@@ -638,10 +782,14 @@ var CardDetailsForm = ({
638
782
  if (!configured[collectPrefix]) {
639
783
  window.CollectJS.configure({
640
784
  variant: "inline",
785
+ customCss: collectCssConfig.customCss,
786
+ focusCss: collectCssConfig.focusCss,
787
+ invalidCss: collectCssConfig.invalidCss,
788
+ placeholderCss: collectCssConfig.placeholderCss,
641
789
  fields: {
642
- ccnumber: { selector: buildSelector(collectPrefix, "ccnumber") },
643
- ccexp: { selector: buildSelector(collectPrefix, "ccexp") },
644
- cvv: { selector: buildSelector(collectPrefix, "cvv") }
790
+ ccnumber: sanitizeCollectField({ selector: buildSelector(collectPrefix, "ccnumber") }),
791
+ ccexp: sanitizeCollectField({ selector: buildSelector(collectPrefix, "ccexp") }),
792
+ cvv: sanitizeCollectField({ selector: buildSelector(collectPrefix, "cvv") })
645
793
  },
646
794
  callback: (response) => {
647
795
  const fn = window.__doujinsCollectHandlers?.[collectPrefix];
@@ -652,6 +800,7 @@ var CardDetailsForm = ({
652
800
  }
653
801
  }, [
654
802
  collectPrefix,
803
+ collectReady,
655
804
  firstName,
656
805
  lastName,
657
806
  address1,
@@ -683,22 +832,22 @@ var CardDetailsForm = ({
683
832
  window.CollectJS.startPaymentRequest();
684
833
  };
685
834
  const errorMessage = localError ?? externalError;
686
- const collectFieldClass = "flex h-11 w-full items-center rounded-md border bg-white/5 px-3 text-sm text-white";
835
+ const collectFieldClass = "relative flex h-11 w-full items-center overflow-hidden rounded-md border border-border/60 bg-background/40 px-3 text-sm text-foreground";
687
836
  return /* @__PURE__ */ jsxs(
688
837
  "form",
689
838
  {
690
- className: cn("space-y-5", className),
839
+ className: cn("space-y-2", className),
691
840
  onSubmit: handleSubmit,
692
841
  noValidate: true,
693
842
  children: [
694
843
  errorMessage && /* @__PURE__ */ jsx("div", { className: "rounded-md border border-red-500/40 bg-red-500/10 px-4 py-2 text-sm text-red-400", children: errorMessage }),
695
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 md:flex-row", children: [
844
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 md:flex-row", children: [
696
845
  /* @__PURE__ */ jsxs("div", { className: "flex-1 space-y-2", children: [
697
- /* @__PURE__ */ jsx(Label, { htmlFor: "payments-first", children: "First name" }),
846
+ /* @__PURE__ */ jsx(Label, { htmlFor: "firstName", children: "First name" }),
698
847
  /* @__PURE__ */ jsx(
699
848
  Input,
700
849
  {
701
- id: "payments-first",
850
+ id: "firstName",
702
851
  value: firstName,
703
852
  onChange: (e) => setFirstName(e.target.value),
704
853
  required: true
@@ -706,11 +855,11 @@ var CardDetailsForm = ({
706
855
  )
707
856
  ] }),
708
857
  /* @__PURE__ */ jsxs("div", { className: "flex-1 space-y-2", children: [
709
- /* @__PURE__ */ jsx(Label, { htmlFor: "payments-last", children: "Last name" }),
858
+ /* @__PURE__ */ jsx(Label, { htmlFor: "lastName", children: "Last name" }),
710
859
  /* @__PURE__ */ jsx(
711
860
  Input,
712
861
  {
713
- id: "payments-last",
862
+ id: "lastName",
714
863
  value: lastName,
715
864
  onChange: (e) => setLastName(e.target.value),
716
865
  required: true
@@ -719,11 +868,11 @@ var CardDetailsForm = ({
719
868
  ] })
720
869
  ] }),
721
870
  /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
722
- /* @__PURE__ */ jsx(Label, { htmlFor: "payments-email", children: "Email" }),
871
+ /* @__PURE__ */ jsx(Label, { htmlFor: "email", children: "Email" }),
723
872
  /* @__PURE__ */ jsx(
724
873
  Input,
725
874
  {
726
- id: "payments-email",
875
+ id: "email",
727
876
  type: "email",
728
877
  value: email,
729
878
  onChange: (e) => setEmail(e.target.value),
@@ -732,24 +881,24 @@ var CardDetailsForm = ({
732
881
  )
733
882
  ] }),
734
883
  /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
735
- /* @__PURE__ */ jsx(Label, { htmlFor: "payments-address1", children: "Address" }),
884
+ /* @__PURE__ */ jsx(Label, { htmlFor: "address1", children: "Address" }),
736
885
  /* @__PURE__ */ jsx(
737
886
  Input,
738
887
  {
739
- id: "payments-address1",
888
+ id: "address1",
740
889
  value: address1,
741
890
  onChange: (e) => setAddress1(e.target.value),
742
891
  required: true
743
892
  }
744
893
  )
745
894
  ] }),
746
- /* @__PURE__ */ jsxs("div", { className: "grid gap-5 md:grid-cols-2", children: [
895
+ /* @__PURE__ */ jsxs("div", { className: "grid gap-2 md:grid-cols-2", children: [
747
896
  /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
748
- /* @__PURE__ */ jsx(Label, { htmlFor: "payments-city", children: "City" }),
897
+ /* @__PURE__ */ jsx(Label, { htmlFor: "city", children: "City" }),
749
898
  /* @__PURE__ */ jsx(
750
899
  Input,
751
900
  {
752
- id: "payments-city",
901
+ id: "city",
753
902
  value: city,
754
903
  onChange: (e) => setCity(e.target.value),
755
904
  required: true
@@ -757,24 +906,24 @@ var CardDetailsForm = ({
757
906
  )
758
907
  ] }),
759
908
  /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
760
- /* @__PURE__ */ jsx(Label, { htmlFor: "payments-state", children: "State / Region" }),
909
+ /* @__PURE__ */ jsx(Label, { htmlFor: "state", children: "State / Region" }),
761
910
  /* @__PURE__ */ jsx(
762
911
  Input,
763
912
  {
764
- id: "payments-state",
913
+ id: "state",
765
914
  value: stateRegion,
766
915
  onChange: (e) => setStateRegion(e.target.value)
767
916
  }
768
917
  )
769
918
  ] })
770
919
  ] }),
771
- /* @__PURE__ */ jsxs("div", { className: "grid gap-5 md:grid-cols-2", children: [
920
+ /* @__PURE__ */ jsxs("div", { className: "grid gap-2 md:grid-cols-2", children: [
772
921
  /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
773
- /* @__PURE__ */ jsx(Label, { htmlFor: "payments-postal", children: "Postal code" }),
922
+ /* @__PURE__ */ jsx(Label, { htmlFor: "postal", children: "Postal code" }),
774
923
  /* @__PURE__ */ jsx(
775
924
  Input,
776
925
  {
777
- id: "payments-postal",
926
+ id: "postal",
778
927
  value: postalCode,
779
928
  onChange: (e) => setPostalCode(e.target.value),
780
929
  required: true
@@ -793,7 +942,7 @@ var CardDetailsForm = ({
793
942
  /* @__PURE__ */ jsx(Label, { children: "Card number" }),
794
943
  /* @__PURE__ */ jsx("div", { id: buildSelector(collectPrefix, "ccnumber").slice(1), className: collectFieldClass })
795
944
  ] }),
796
- /* @__PURE__ */ jsxs("div", { className: "grid gap-4 md:grid-cols-2", children: [
945
+ /* @__PURE__ */ jsxs("div", { className: "grid gap-2 md:grid-cols-2", children: [
797
946
  /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
798
947
  /* @__PURE__ */ jsx(Label, { children: "Expiry" }),
799
948
  /* @__PURE__ */ jsx("div", { id: buildSelector(collectPrefix, "ccexp").slice(1), className: collectFieldClass })
@@ -891,7 +1040,7 @@ var badgeVariants = cva(
891
1040
  function Badge({ className, variant, ...props }) {
892
1041
  return /* @__PURE__ */ jsx("div", { className: cn(badgeVariants({ variant }), className), ...props });
893
1042
  }
894
- var ScrollArea = React17.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
1043
+ var ScrollArea = React15.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
895
1044
  ScrollAreaPrimitive.Root,
896
1045
  {
897
1046
  ref,
@@ -905,7 +1054,7 @@ var ScrollArea = React17.forwardRef(({ className, children, ...props }, ref) =>
905
1054
  }
906
1055
  ));
907
1056
  ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
908
- var ScrollBar = React17.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ jsx(
1057
+ var ScrollBar = React15.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ jsx(
909
1058
  ScrollAreaPrimitive.ScrollAreaScrollbar,
910
1059
  {
911
1060
  ref,
@@ -928,108 +1077,104 @@ var formatCardLabel = (method) => {
928
1077
  };
929
1078
  var StoredPaymentMethods = ({
930
1079
  selectedMethodId,
931
- onMethodSelect,
932
- showAddButton = true
1080
+ onMethodSelect
933
1081
  }) => {
934
- const [isModalOpen, setIsModalOpen] = useState(false);
935
- const [deletingId, setDeletingId] = useState(null);
936
- const { listQuery, createMutation, deleteMutation } = usePaymentMethods();
1082
+ const { listQuery } = usePaymentMethods();
937
1083
  const payments = useMemo(() => listQuery.data?.data ?? [], [listQuery.data]);
938
- const handleCardTokenize = (token, billing) => {
939
- createMutation.mutate({ token, billing });
940
- };
941
- return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
942
- /* @__PURE__ */ jsx("div", { className: "flex items-start justify-between gap-4", children: showAddButton && /* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", onClick: () => setIsModalOpen(true), children: "Add card" }) }),
943
- listQuery.isLoading ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center py-4 text-sm text-muted-foreground", children: [
944
- /* @__PURE__ */ jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }),
945
- " Loading cards..."
946
- ] }) : payments.length === 0 ? /* @__PURE__ */ jsx("div", { className: "p-4 text-center text-sm text-muted-foreground", children: "No saved payment methods yet." }) : /* @__PURE__ */ jsx(ScrollArea, { className: "max-h-[320px] pr-2", children: /* @__PURE__ */ jsx("div", { className: "space-y-3", children: payments.map((method) => {
947
- const isSelected = selectedMethodId === method.id;
948
- return /* @__PURE__ */ jsxs(
949
- "div",
950
- {
951
- className: cn(
952
- "flex border border-border rounded-md px-4 py-3 flex-row items-center justify-between",
953
- {
954
- "bg-primary/5": isSelected
955
- }
956
- ),
957
- children: [
958
- /* @__PURE__ */ jsx("div", { className: "text-sm font-semibold text-foreground", children: formatCardLabel(method) }),
959
- /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
960
- method.failure_reason && /* @__PURE__ */ jsx(Badge, { variant: "destructive", children: method.failure_reason }),
961
- onMethodSelect && /* @__PURE__ */ jsx(
962
- Button,
963
- {
964
- size: "sm",
965
- variant: "ghost",
966
- onClick: () => onMethodSelect(method),
967
- className: clsx2("px-3", { "bg-muted/90": !isSelected, "bg-background": isSelected }),
968
- children: isSelected ? "Selected" : "Use card"
969
- }
970
- )
971
- ] })
972
- ]
973
- },
974
- method.id
975
- );
976
- }) }) }),
977
- /* @__PURE__ */ jsx(Dialog, { open: isModalOpen, onOpenChange: setIsModalOpen, children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto", children: [
978
- /* @__PURE__ */ jsxs(DialogHeader, { children: [
979
- /* @__PURE__ */ jsx(DialogTitle, { children: "Add a new card" }),
980
- /* @__PURE__ */ jsx(DialogDescription, { children: "Your card details are tokenized securely via our payment provider." })
981
- ] }),
982
- /* @__PURE__ */ jsx(
983
- CardDetailsForm,
984
- {
985
- visible: isModalOpen,
986
- collectPrefix: "payments-ui-card",
987
- submitting: createMutation.isPending,
988
- submitLabel: "Save card",
989
- externalError: createMutation.error?.message ?? null,
990
- onTokenize: handleCardTokenize
991
- }
992
- )
993
- ] }) })
994
- ] });
1084
+ return /* @__PURE__ */ jsx("div", { className: "space-y-4", children: listQuery.isLoading ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center py-4 text-sm text-muted-foreground", children: [
1085
+ /* @__PURE__ */ jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }),
1086
+ " Loading cards..."
1087
+ ] }) : payments.length === 0 ? /* @__PURE__ */ jsx("div", { className: "p-4 text-center text-sm text-muted-foreground", children: "No saved payment methods yet." }) : /* @__PURE__ */ jsx(ScrollArea, { className: "max-h-[320px] pr-2", children: /* @__PURE__ */ jsx("div", { className: "space-y-3", children: payments.map((method) => {
1088
+ const isSelected = selectedMethodId === method.id;
1089
+ return /* @__PURE__ */ jsxs(
1090
+ "div",
1091
+ {
1092
+ className: cn(
1093
+ "flex border border-border rounded-md px-4 py-3 flex-row items-center justify-between",
1094
+ {
1095
+ "bg-muted/20": isSelected
1096
+ }
1097
+ ),
1098
+ children: [
1099
+ /* @__PURE__ */ jsx("div", { className: "text-sm font-semibold text-foreground", children: formatCardLabel(method) }),
1100
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
1101
+ method.failure_reason && /* @__PURE__ */ jsx(Badge, { variant: "destructive", children: method.failure_reason }),
1102
+ onMethodSelect && /* @__PURE__ */ jsx(
1103
+ Button,
1104
+ {
1105
+ size: "sm",
1106
+ variant: "ghost",
1107
+ disabled: isSelected,
1108
+ onClick: () => onMethodSelect(method),
1109
+ className: clsx2("px-3", { "bg-muted/90": !isSelected, "bg-inherit": isSelected }),
1110
+ children: isSelected ? "Selected" : "Use card"
1111
+ }
1112
+ )
1113
+ ] })
1114
+ ]
1115
+ },
1116
+ method.id
1117
+ );
1118
+ }) }) }) });
995
1119
  };
996
- var Tabs = TabsPrimitive.Root;
997
- var TabsList = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
998
- TabsPrimitive.List,
999
- {
1000
- ref,
1001
- className: cn(
1002
- "inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",
1003
- className
1004
- ),
1005
- ...props
1006
- }
1007
- ));
1008
- TabsList.displayName = TabsPrimitive.List.displayName;
1009
- var TabsTrigger = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1010
- TabsPrimitive.Trigger,
1011
- {
1012
- ref,
1013
- className: cn(
1014
- "inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",
1015
- className
1016
- ),
1017
- ...props
1018
- }
1019
- ));
1020
- TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
1021
- var TabsContent = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1022
- TabsPrimitive.Content,
1023
- {
1024
- ref,
1025
- className: cn(
1026
- "mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
1027
- className
1028
- ),
1029
- ...props
1030
- }
1031
- ));
1032
- TabsContent.displayName = TabsPrimitive.Content.displayName;
1120
+ function Tabs({
1121
+ className,
1122
+ ...props
1123
+ }) {
1124
+ return /* @__PURE__ */ jsx(
1125
+ TabsPrimitive.Root,
1126
+ {
1127
+ "data-slot": "tabs",
1128
+ className: cn("flex flex-col gap-2", className),
1129
+ ...props
1130
+ }
1131
+ );
1132
+ }
1133
+ function TabsList({
1134
+ className,
1135
+ ...props
1136
+ }) {
1137
+ return /* @__PURE__ */ jsx(
1138
+ TabsPrimitive.List,
1139
+ {
1140
+ "data-slot": "tabs-list",
1141
+ className: cn(
1142
+ "bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",
1143
+ className
1144
+ ),
1145
+ ...props
1146
+ }
1147
+ );
1148
+ }
1149
+ function TabsTrigger({
1150
+ className,
1151
+ ...props
1152
+ }) {
1153
+ return /* @__PURE__ */ jsx(
1154
+ TabsPrimitive.Trigger,
1155
+ {
1156
+ "data-slot": "tabs-trigger",
1157
+ className: cn(
1158
+ "data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
1159
+ className
1160
+ ),
1161
+ ...props
1162
+ }
1163
+ );
1164
+ }
1165
+ function TabsContent({
1166
+ className,
1167
+ ...props
1168
+ }) {
1169
+ return /* @__PURE__ */ jsx(
1170
+ TabsPrimitive.Content,
1171
+ {
1172
+ "data-slot": "tabs-content",
1173
+ className: cn("flex-1 outline-none", className),
1174
+ ...props
1175
+ }
1176
+ );
1177
+ }
1033
1178
  var usePaymentNotifications = () => {
1034
1179
  const { config } = usePaymentContext();
1035
1180
  const notifyStatus = useCallback(
@@ -1254,7 +1399,7 @@ var useSolanaQrPayment = (options) => {
1254
1399
  refresh
1255
1400
  };
1256
1401
  };
1257
- var Card = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1402
+ var Card = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1258
1403
  "div",
1259
1404
  {
1260
1405
  ref,
@@ -1266,7 +1411,7 @@ var Card = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
1266
1411
  }
1267
1412
  ));
1268
1413
  Card.displayName = "Card";
1269
- var CardHeader = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1414
+ var CardHeader = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1270
1415
  "div",
1271
1416
  {
1272
1417
  ref,
@@ -1275,7 +1420,7 @@ var CardHeader = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE
1275
1420
  }
1276
1421
  ));
1277
1422
  CardHeader.displayName = "CardHeader";
1278
- var CardTitle = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1423
+ var CardTitle = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1279
1424
  "div",
1280
1425
  {
1281
1426
  ref,
@@ -1287,7 +1432,7 @@ var CardTitle = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE_
1287
1432
  }
1288
1433
  ));
1289
1434
  CardTitle.displayName = "CardTitle";
1290
- var CardDescription = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1435
+ var CardDescription = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1291
1436
  "div",
1292
1437
  {
1293
1438
  ref,
@@ -1296,9 +1441,9 @@ var CardDescription = React17.forwardRef(({ className, ...props }, ref) => /* @_
1296
1441
  }
1297
1442
  ));
1298
1443
  CardDescription.displayName = "CardDescription";
1299
- var CardContent = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("p-6 pt-0", className), ...props }));
1444
+ var CardContent = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("p-6 pt-0", className), ...props }));
1300
1445
  CardContent.displayName = "CardContent";
1301
- var CardFooter = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1446
+ var CardFooter = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1302
1447
  "div",
1303
1448
  {
1304
1449
  ref,
@@ -1313,7 +1458,7 @@ var QRCodePayment = ({
1313
1458
  onPaymentError,
1314
1459
  onPaymentSuccess
1315
1460
  }) => {
1316
- const handleQrSuccess = React17__default.useCallback(
1461
+ const handleQrSuccess = React15__default.useCallback(
1317
1462
  (paymentId, txId) => {
1318
1463
  if (!paymentId && !txId) {
1319
1464
  onPaymentError("Missing payment confirmation details");
@@ -1859,7 +2004,6 @@ var PaymentExperience = ({
1859
2004
  /* @__PURE__ */ jsx(
1860
2005
  StoredPaymentMethods,
1861
2006
  {
1862
- showAddButton: false,
1863
2007
  selectedMethodId,
1864
2008
  onMethodSelect: handleMethodSelect
1865
2009
  }
@@ -1891,21 +2035,14 @@ var PaymentExperience = ({
1891
2035
  }
1892
2036
  );
1893
2037
  };
1894
- const renderCardExperience = () => /* @__PURE__ */ jsxs(
1895
- Tabs,
1896
- {
1897
- value: activeTab,
1898
- onValueChange: (value) => setActiveTab(value),
1899
- children: [
1900
- /* @__PURE__ */ jsxs(TabsList, { className: "grid w-full grid-cols-2", children: [
1901
- /* @__PURE__ */ jsx(TabsTrigger, { value: "saved", disabled: !showStored, children: "Use saved card" }),
1902
- /* @__PURE__ */ jsx(TabsTrigger, { value: "new", disabled: !showNewCard, children: "Add new card" })
1903
- ] }),
1904
- /* @__PURE__ */ jsx(TabsContent, { value: "saved", children: renderSavedTab() }),
1905
- /* @__PURE__ */ jsx(TabsContent, { value: "new", children: renderNewTab() })
1906
- ]
1907
- }
1908
- );
2038
+ const renderCardExperience = () => /* @__PURE__ */ jsxs(Tabs, { value: activeTab, onValueChange: setActiveTab, children: [
2039
+ /* @__PURE__ */ jsxs(TabsList, { className: "w-full rounded-md mb-4", children: [
2040
+ /* @__PURE__ */ jsx(TabsTrigger, { className: clsx("cursor-pointer", { "bg-background": activeTab == "saved" }), value: "saved", children: "Use saved card" }),
2041
+ /* @__PURE__ */ jsx(TabsTrigger, { className: clsx("cursor-pointer", { "bg-background": activeTab == "new" }), value: "new", children: "Add new card" })
2042
+ ] }),
2043
+ /* @__PURE__ */ jsx(TabsContent, { value: "saved", children: renderSavedTab() }),
2044
+ /* @__PURE__ */ jsx(TabsContent, { value: "new", children: renderNewTab() })
2045
+ ] });
1909
2046
  return /* @__PURE__ */ jsxs("div", { className: "space-y-6 pt-4", children: [
1910
2047
  mode === "cards" && renderCardExperience(),
1911
2048
  mode === "solana" && enableSolanaPay && /* @__PURE__ */ jsx(
@@ -2114,16 +2251,17 @@ var SubscriptionCheckoutModal = ({
2114
2251
  onSolanaError?.(error);
2115
2252
  };
2116
2253
  return /* @__PURE__ */ jsxs(Fragment, { children: [
2117
- /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: handleClose, children: /* @__PURE__ */ jsx(
2254
+ /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs(
2118
2255
  DialogContent,
2119
2256
  {
2120
- className: "max-w-3xl max-h-[90vh] overflow-y-auto [&::-webkit-scrollbar]:hidden",
2121
- children: /* @__PURE__ */ jsxs("div", { className: "p-6 space-y-6", children: [
2122
- !priceId && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 rounded-lg px-3 py-2 text-sm text-destructive", children: [
2257
+ className: "max-w-3xl max-h-[90vh] overflow-y-auto border-border rounded-md [&::-webkit-scrollbar]:hidden",
2258
+ children: [
2259
+ /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: "Checkout" }) }),
2260
+ /* @__PURE__ */ jsx("div", { className: "space-y-4", children: !priceId ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-center px-3 py-2 text-sm text-destructive", children: [
2123
2261
  /* @__PURE__ */ jsx(AlertCircle, { className: "h-4 w-4" }),
2124
- " Select a subscription plan to continue."
2125
- ] }),
2126
- /* @__PURE__ */ jsx(
2262
+ " ",
2263
+ /* @__PURE__ */ jsx("span", { children: "Select a subscription plan to continue." })
2264
+ ] }) : /* @__PURE__ */ jsx(
2127
2265
  PaymentExperience,
2128
2266
  {
2129
2267
  usdAmount,
@@ -2137,8 +2275,8 @@ var SubscriptionCheckoutModal = ({
2137
2275
  onNewCardPayment: priceId ? handleNewCardPayment : void 0,
2138
2276
  onSavedMethodPayment: priceId ? handleSavedMethodPayment : void 0
2139
2277
  }
2140
- )
2141
- ] })
2278
+ ) })
2279
+ ]
2142
2280
  }
2143
2281
  ) }),
2144
2282
  /* @__PURE__ */ jsx(
@@ -2380,7 +2518,7 @@ var SolanaPaymentSelector = ({
2380
2518
  }) => {
2381
2519
  return /* @__PURE__ */ jsx(Dialog, { open: isOpen, onOpenChange: (value) => value ? void 0 : onClose(), children: /* @__PURE__ */ jsx(DialogContent, { className: "w-full max-w-2xl max-h-[90vh] overflow-y-auto rounded-md border bg-background/95 p-0 shadow-2xl [&::-webkit-scrollbar]:hidden", children: /* @__PURE__ */ jsx(SolanaPaymentView, { ...props, onClose }) }) });
2382
2520
  };
2383
- var Table = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { className: "relative w-full overflow-auto", children: /* @__PURE__ */ jsx(
2521
+ var Table = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { className: "relative w-full overflow-auto", children: /* @__PURE__ */ jsx(
2384
2522
  "table",
2385
2523
  {
2386
2524
  ref,
@@ -2389,9 +2527,9 @@ var Table = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
2389
2527
  }
2390
2528
  ) }));
2391
2529
  Table.displayName = "Table";
2392
- var TableHeader = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("thead", { ref, className: cn("[&_tr]:border-b", className), ...props }));
2530
+ var TableHeader = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("thead", { ref, className: cn("[&_tr]:border-b", className), ...props }));
2393
2531
  TableHeader.displayName = "TableHeader";
2394
- var TableBody = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2532
+ var TableBody = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2395
2533
  "tbody",
2396
2534
  {
2397
2535
  ref,
@@ -2400,7 +2538,7 @@ var TableBody = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE_
2400
2538
  }
2401
2539
  ));
2402
2540
  TableBody.displayName = "TableBody";
2403
- var TableFooter = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2541
+ var TableFooter = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2404
2542
  "tfoot",
2405
2543
  {
2406
2544
  ref,
@@ -2412,7 +2550,7 @@ var TableFooter = React17.forwardRef(({ className, ...props }, ref) => /* @__PUR
2412
2550
  }
2413
2551
  ));
2414
2552
  TableFooter.displayName = "TableFooter";
2415
- var TableRow = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2553
+ var TableRow = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2416
2554
  "tr",
2417
2555
  {
2418
2556
  ref,
@@ -2424,7 +2562,7 @@ var TableRow = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__
2424
2562
  }
2425
2563
  ));
2426
2564
  TableRow.displayName = "TableRow";
2427
- var TableHead = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2565
+ var TableHead = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2428
2566
  "th",
2429
2567
  {
2430
2568
  ref,
@@ -2436,7 +2574,7 @@ var TableHead = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE_
2436
2574
  }
2437
2575
  ));
2438
2576
  TableHead.displayName = "TableHead";
2439
- var TableCell = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2577
+ var TableCell = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2440
2578
  "td",
2441
2579
  {
2442
2580
  ref,
@@ -2445,7 +2583,7 @@ var TableCell = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE_
2445
2583
  }
2446
2584
  ));
2447
2585
  TableCell.displayName = "TableCell";
2448
- var TableCaption = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2586
+ var TableCaption = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2449
2587
  "caption",
2450
2588
  {
2451
2589
  ref,
@@ -2457,7 +2595,7 @@ TableCaption.displayName = "TableCaption";
2457
2595
  var AlertDialog = AlertDialogPrimitive.Root;
2458
2596
  var AlertDialogTrigger = AlertDialogPrimitive.Trigger;
2459
2597
  var AlertDialogPortal = AlertDialogPrimitive.Portal;
2460
- var AlertDialogOverlay = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2598
+ var AlertDialogOverlay = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2461
2599
  AlertDialogPrimitive.Overlay,
2462
2600
  {
2463
2601
  className: cn(
@@ -2469,7 +2607,7 @@ var AlertDialogOverlay = React17.forwardRef(({ className, ...props }, ref) => /*
2469
2607
  }
2470
2608
  ));
2471
2609
  AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
2472
- var AlertDialogContent = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxs(AlertDialogPortal, { children: [
2610
+ var AlertDialogContent = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxs(AlertDialogPortal, { children: [
2473
2611
  /* @__PURE__ */ jsx(AlertDialogOverlay, {}),
2474
2612
  /* @__PURE__ */ jsx(
2475
2613
  AlertDialogPrimitive.Content,
@@ -2512,7 +2650,7 @@ var AlertDialogFooter = ({
2512
2650
  }
2513
2651
  );
2514
2652
  AlertDialogFooter.displayName = "AlertDialogFooter";
2515
- var AlertDialogTitle = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2653
+ var AlertDialogTitle = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2516
2654
  AlertDialogPrimitive.Title,
2517
2655
  {
2518
2656
  ref,
@@ -2521,7 +2659,7 @@ var AlertDialogTitle = React17.forwardRef(({ className, ...props }, ref) => /* @
2521
2659
  }
2522
2660
  ));
2523
2661
  AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
2524
- var AlertDialogDescription = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2662
+ var AlertDialogDescription = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2525
2663
  AlertDialogPrimitive.Description,
2526
2664
  {
2527
2665
  ref,
@@ -2530,7 +2668,7 @@ var AlertDialogDescription = React17.forwardRef(({ className, ...props }, ref) =
2530
2668
  }
2531
2669
  ));
2532
2670
  AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayName;
2533
- var AlertDialogAction = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2671
+ var AlertDialogAction = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2534
2672
  AlertDialogPrimitive.Action,
2535
2673
  {
2536
2674
  ref,
@@ -2539,7 +2677,7 @@ var AlertDialogAction = React17.forwardRef(({ className, ...props }, ref) => /*
2539
2677
  }
2540
2678
  ));
2541
2679
  AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
2542
- var AlertDialogCancel = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2680
+ var AlertDialogCancel = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2543
2681
  AlertDialogPrimitive.Cancel,
2544
2682
  {
2545
2683
  ref,
@@ -2552,7 +2690,7 @@ var AlertDialogCancel = React17.forwardRef(({ className, ...props }, ref) => /*
2552
2690
  }
2553
2691
  ));
2554
2692
  AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
2555
- var Textarea = React17.forwardRef(({ className, ...props }, ref) => {
2693
+ var Textarea = React15.forwardRef(({ className, ...props }, ref) => {
2556
2694
  return /* @__PURE__ */ jsx(
2557
2695
  "textarea",
2558
2696
  {
@@ -2860,21 +2998,17 @@ var defaultTranslations3 = {
2860
2998
  addedOn: "Added on",
2861
2999
  active: "Active",
2862
3000
  inactive: "Inactive",
2863
- replaceCard: "Replace card",
2864
3001
  makeDefault: "Make default",
2865
3002
  defaultMethod: "Default method",
2866
3003
  remove: "Remove",
2867
3004
  addNewCard: "Add a new card",
2868
3005
  addNewCardDescription: "Your card details are tokenized securely via our payment provider.",
2869
3006
  saveCard: "Save card",
2870
- replaceCardTitle: "Replace card",
2871
- replaceCardDescription: "Update this card with new billing details.",
2872
3007
  cardAddedSuccess: "Card added successfully",
2873
3008
  unableToAddCard: "Unable to add card",
2874
3009
  cardRemoved: "Card removed",
2875
- unableToRemoveCard: "Unable to remove card",
2876
3010
  cardUpdated: "Card updated",
2877
- unableToReplaceCard: "Unable to replace card",
3011
+ unableToRemoveCard: "Unable to remove card",
2878
3012
  defaultPaymentMethodUpdated: "Default payment method updated",
2879
3013
  unableToSetDefault: "Unable to set default payment method"
2880
3014
  };
@@ -2898,7 +3032,6 @@ var PaymentMethodsSection = ({
2898
3032
  };
2899
3033
  const [isModalOpen, setIsModalOpen] = useState(false);
2900
3034
  const [deletingId, setDeletingId] = useState(null);
2901
- const [methodBeingReplaced, setMethodBeingReplaced] = useState(null);
2902
3035
  const notify = onNotify ?? notifyDefault3;
2903
3036
  const t = { ...defaultTranslations3, ...customTranslations };
2904
3037
  const queryKey = ["payments-ui", "payment-methods"];
@@ -2939,21 +3072,6 @@ var PaymentMethodsSection = ({
2939
3072
  },
2940
3073
  onSettled: () => setDeletingId(null)
2941
3074
  });
2942
- const replaceMutation = useMutation({
2943
- mutationFn: ({ id, payload }) => paymentMethods.update(id, payload),
2944
- onSuccess: () => {
2945
- notify({ title: t.cardUpdated, status: "success" });
2946
- setMethodBeingReplaced(null);
2947
- void queryClient.invalidateQueries({ queryKey });
2948
- },
2949
- onError: (error) => {
2950
- notify({
2951
- title: t.unableToReplaceCard,
2952
- description: error.message,
2953
- status: "destructive"
2954
- });
2955
- }
2956
- });
2957
3075
  const activateMutation = useMutation({
2958
3076
  mutationFn: (id) => paymentMethods.activate(id),
2959
3077
  onSuccess: () => {
@@ -2991,18 +3109,10 @@ var PaymentMethodsSection = ({
2991
3109
  const handleCardTokenize = (token, billing) => {
2992
3110
  createMutation.mutate(buildPayload(token, billing));
2993
3111
  };
2994
- const handleReplaceTokenize = (token, billing) => {
2995
- if (!methodBeingReplaced) return;
2996
- replaceMutation.mutate({ id: methodBeingReplaced.id, payload: buildPayload(token, billing) });
2997
- };
2998
- return /* @__PURE__ */ jsxs(Card, { children: [
3112
+ return /* @__PURE__ */ jsxs(Card, { className: "bg-bckground border-border rounded-md", children: [
2999
3113
  /* @__PURE__ */ jsxs(CardHeader, { className: "flex flex-col gap-4 md:flex-row md:items-center md:justify-between", children: [
3000
3114
  /* @__PURE__ */ jsxs("div", { children: [
3001
- /* @__PURE__ */ jsxs(CardTitle, { className: "flex items-center gap-2", children: [
3002
- /* @__PURE__ */ jsx(WalletCards, { className: "h-5 w-5 text-emerald-400" }),
3003
- " ",
3004
- t.title
3005
- ] }),
3115
+ /* @__PURE__ */ jsx(CardTitle, { className: "flex items-center gap-2", children: t.title }),
3006
3116
  /* @__PURE__ */ jsx(CardDescription, { children: t.description })
3007
3117
  ] }),
3008
3118
  /* @__PURE__ */ jsxs(Button, { onClick: () => setIsModalOpen(true), children: [
@@ -3020,40 +3130,14 @@ var PaymentMethodsSection = ({
3020
3130
  {
3021
3131
  className: "rounded-lg border bg-white/5 p-4 shadow-sm",
3022
3132
  children: [
3023
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 md:flex-row md:items-center md:justify-between", children: [
3024
- /* @__PURE__ */ jsxs("div", { children: [
3025
- /* @__PURE__ */ jsx("h4", { className: "text-base font-medium text-white", children: formatCardLabel2(method) }),
3026
- /* @__PURE__ */ jsxs("p", { className: "text-sm text-white/60", children: [
3027
- t.addedOn,
3028
- " ",
3029
- method.created_at ? new Date(method.created_at).toLocaleDateString() : "unknown date"
3030
- ] })
3133
+ /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
3134
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-between", children: [
3135
+ /* @__PURE__ */ jsx("div", { className: "text-base font-medium text-white", children: formatCardLabel2(method) }),
3136
+ /* @__PURE__ */ jsx(Badge, { variant: method.is_active ? "default" : "secondary", children: method.is_active ? t.active : t.inactive })
3031
3137
  ] }),
3032
- /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
3033
- /* @__PURE__ */ jsx(
3034
- Badge,
3035
- {
3036
- variant: method.is_active ? "default" : "secondary",
3037
- children: method.is_active ? t.active : t.inactive
3038
- }
3039
- ),
3040
- method.failure_reason && /* @__PURE__ */ jsx(Badge, { variant: "destructive", children: method.failure_reason })
3041
- ] })
3138
+ /* @__PURE__ */ jsx("div", { children: method.failure_reason && /* @__PURE__ */ jsx(Badge, { variant: "destructive", children: method.failure_reason }) })
3042
3139
  ] }),
3043
3140
  /* @__PURE__ */ jsxs("div", { className: "mt-3 flex flex-wrap gap-2", children: [
3044
- /* @__PURE__ */ jsxs(
3045
- Button,
3046
- {
3047
- variant: "ghost",
3048
- className: "text-blue-400",
3049
- disabled: replaceMutation.isPending && methodBeingReplaced?.id === method.id,
3050
- onClick: () => setMethodBeingReplaced(method),
3051
- children: [
3052
- replaceMutation.isPending && methodBeingReplaced?.id === method.id ? /* @__PURE__ */ jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(CreditCard, { className: "mr-2 h-4 w-4" }),
3053
- t.replaceCard
3054
- ]
3055
- }
3056
- ),
3057
3141
  /* @__PURE__ */ jsxs(
3058
3142
  Button,
3059
3143
  {
@@ -3084,55 +3168,34 @@ var PaymentMethodsSection = ({
3084
3168
  },
3085
3169
  method.id
3086
3170
  )) }) }),
3087
- /* @__PURE__ */ jsx(Dialog, { open: isModalOpen, onOpenChange: setIsModalOpen, children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[95vh] overflow-y-auto", children: [
3088
- /* @__PURE__ */ jsxs(DialogHeader, { children: [
3089
- /* @__PURE__ */ jsx(DialogTitle, { children: t.addNewCard }),
3090
- /* @__PURE__ */ jsx(DialogDescription, { children: t.addNewCardDescription })
3091
- ] }),
3092
- /* @__PURE__ */ jsx(
3093
- CardDetailsForm,
3094
- {
3095
- visible: isModalOpen,
3096
- collectPrefix,
3097
- submitting: createMutation.isPending,
3098
- submitLabel: t.saveCard,
3099
- defaultValues: {
3100
- email: userEmail ?? "",
3101
- country: defaultCountry,
3102
- provider
3103
- },
3104
- externalError: createMutation.error?.message ?? null,
3105
- onTokenize: handleCardTokenize,
3106
- className: "rounded-2xl border bg-white/5 p-6"
3107
- }
3108
- )
3109
- ] }) }),
3110
- /* @__PURE__ */ jsx(Dialog, { open: Boolean(methodBeingReplaced), onOpenChange: (open) => !open && setMethodBeingReplaced(null), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[95vh] overflow-y-auto", children: [
3111
- /* @__PURE__ */ jsxs(DialogHeader, { children: [
3112
- /* @__PURE__ */ jsx(DialogTitle, { children: t.replaceCardTitle }),
3113
- /* @__PURE__ */ jsx(DialogDescription, { children: t.replaceCardDescription })
3114
- ] }),
3115
- methodBeingReplaced && /* @__PURE__ */ jsx(
3116
- CardDetailsForm,
3117
- {
3118
- visible: true,
3119
- collectPrefix: `${collectPrefix}-replace-${methodBeingReplaced.id}`,
3120
- submitting: replaceMutation.isPending,
3121
- submitLabel: t.replaceCard,
3122
- defaultValues: {
3123
- email: userEmail ?? "",
3124
- country: defaultCountry,
3125
- provider
3126
- },
3127
- externalError: replaceMutation.error?.message ?? null,
3128
- onTokenize: handleReplaceTokenize,
3129
- className: "rounded-2xl border bg-white/5 p-6"
3130
- }
3131
- )
3132
- ] }) })
3171
+ /* @__PURE__ */ jsx(Dialog, { open: isModalOpen, onOpenChange: setIsModalOpen, children: /* @__PURE__ */ jsxs(
3172
+ DialogContent,
3173
+ {
3174
+ className: "max-w-3xl max-h-[90vh] overflow-y-auto border-border rounded-md [&::-webkit-scrollbar]:hidden",
3175
+ children: [
3176
+ /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: t.addNewCard }) }),
3177
+ /* @__PURE__ */ jsx(
3178
+ CardDetailsForm,
3179
+ {
3180
+ visible: isModalOpen,
3181
+ submitLabel: t.saveCard,
3182
+ collectPrefix,
3183
+ onTokenize: handleCardTokenize,
3184
+ submitting: createMutation.isPending,
3185
+ defaultValues: {
3186
+ provider,
3187
+ email: userEmail ?? "",
3188
+ country: defaultCountry
3189
+ },
3190
+ externalError: createMutation.error?.message ?? null
3191
+ }
3192
+ )
3193
+ ]
3194
+ }
3195
+ ) })
3133
3196
  ] });
3134
3197
  };
3135
- var Checkbox = React17.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
3198
+ var Checkbox = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
3136
3199
  CheckboxPrimitive.Root,
3137
3200
  {
3138
3201
  ref,