@superlogic/spree-pay 0.1.18 → 0.1.20

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/build/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/SpreePay.tsx
2
- import { useLayoutEffect as useLayoutEffect3, useMemo as useMemo8, useRef as useRef7, useState as useState13 } from "react";
2
+ import { useLayoutEffect as useLayoutEffect3, useMemo as useMemo10, useRef as useRef7, useState as useState14 } from "react";
3
3
  import NiceModal7 from "@ebay/nice-modal-react";
4
4
  import { SWRConfig } from "swr";
5
5
 
@@ -558,10 +558,10 @@ var slapiApi = {
558
558
  throw new Error("slapiApi is not configured. Call registerApi(...) first.");
559
559
  }
560
560
  };
561
- var registerApi = (config2) => {
562
- cfg.baseUrl = config2.baseUrl;
563
- cfg.accessToken = config2.accessToken;
564
- cfg.tenantId = config2.tenantId;
561
+ var registerApi = (config) => {
562
+ cfg.baseUrl = config.baseUrl;
563
+ cfg.accessToken = config.accessToken;
564
+ cfg.tenantId = config.tenantId;
565
565
  slapiApi = {
566
566
  get: async (key) => {
567
567
  const url = buildUrl(key);
@@ -2409,12 +2409,12 @@ var CreditCardTab = () => {
2409
2409
  };
2410
2410
 
2411
2411
  // src/components/CryptoTab/Crypto/CryptoWrapper.tsx
2412
+ import { useMemo as useMemo9 } from "react";
2412
2413
  import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
2413
2414
  import NiceModal6 from "@ebay/nice-modal-react";
2414
- import { RainbowKitProvider, connectorsForWallets } from "@rainbow-me/rainbowkit";
2415
+ import { RainbowKitProvider, getDefaultConfig, lightTheme } from "@rainbow-me/rainbowkit";
2415
2416
  import "@rainbow-me/rainbowkit/styles.css";
2416
- import { injectedWallet, walletConnectWallet } from "@rainbow-me/rainbowkit/wallets";
2417
- import { WagmiProvider, createConfig, http as http2 } from "wagmi";
2417
+ import { WagmiProvider } from "wagmi";
2418
2418
  import { base } from "wagmi/chains";
2419
2419
 
2420
2420
  // src/components/CryptoTab/Crypto/Crypto.tsx
@@ -2434,9 +2434,9 @@ function getAction(client, actionFn, name) {
2434
2434
 
2435
2435
  // ../../node_modules/@wagmi/core/dist/esm/actions/readContract.js
2436
2436
  import { readContract as viem_readContract } from "viem/actions";
2437
- function readContract(config2, parameters) {
2437
+ function readContract(config, parameters) {
2438
2438
  const { chainId, ...rest } = parameters;
2439
- const client = config2.getClient({ chainId });
2439
+ const client = config.getClient({ chainId });
2440
2440
  const action = getAction(client, viem_readContract, "readContract");
2441
2441
  return action(rest);
2442
2442
  }
@@ -2444,9 +2444,9 @@ function readContract(config2, parameters) {
2444
2444
  // ../../node_modules/@wagmi/core/dist/esm/actions/waitForTransactionReceipt.js
2445
2445
  import { hexToString } from "viem";
2446
2446
  import { call, getTransaction, waitForTransactionReceipt as viem_waitForTransactionReceipt } from "viem/actions";
2447
- async function waitForTransactionReceipt(config2, parameters) {
2447
+ async function waitForTransactionReceipt(config, parameters) {
2448
2448
  const { chainId, timeout = 0, ...rest } = parameters;
2449
- const client = config2.getClient({ chainId });
2449
+ const client = config.getClient({ chainId });
2450
2450
  const action = getAction(client, viem_waitForTransactionReceipt, "waitForTransactionReceipt");
2451
2451
  const receipt = await action({ ...rest, timeout });
2452
2452
  if (receipt.status === "reverted") {
@@ -2518,7 +2518,7 @@ var MAX_UINT256 = BigInt(2) ** BigInt(256) - BigInt(1);
2518
2518
  var ONE_INCH_AGGREGATION_ROUTER_V6 = "0x111111125421ca6dc452d289314280a0f8842a65";
2519
2519
  var useCryptoPayment = () => {
2520
2520
  const { data: walletClient } = useWalletClient();
2521
- const config2 = useConfig();
2521
+ const config = useConfig();
2522
2522
  const { selectedPaymentMethod } = useSpreePaymentMethod();
2523
2523
  const cryptoPayment = async (params) => {
2524
2524
  if (!walletClient) {
@@ -2534,7 +2534,7 @@ var useCryptoPayment = () => {
2534
2534
  if (!tokenAddress) {
2535
2535
  throw new Error("Token address not found");
2536
2536
  }
2537
- const allowance = await readContract(config2, {
2537
+ const allowance = await readContract(config, {
2538
2538
  address: tokenAddress,
2539
2539
  abi: erc20Abi2,
2540
2540
  functionName: "allowance",
@@ -2547,7 +2547,7 @@ var useCryptoPayment = () => {
2547
2547
  functionName: "approve",
2548
2548
  args: [ONE_INCH_AGGREGATION_ROUTER_V6, MAX_UINT256]
2549
2549
  });
2550
- await waitForTransactionReceipt(config2, {
2550
+ await waitForTransactionReceipt(config, {
2551
2551
  hash: result,
2552
2552
  confirmations: 1
2553
2553
  // You can change the number of block confirmations as per your requirement
@@ -2606,9 +2606,9 @@ var ConnectButton = () => {
2606
2606
  return /* @__PURE__ */ jsx28(
2607
2607
  "button",
2608
2608
  {
2609
- className: "h-[34px] rounded-md border-1 border-black px-3 text-sm font-medium text-red-500",
2609
+ className: "h-[34px] rounded-md border-1 border-black px-3 text-sm font-medium text-black",
2610
2610
  onClick: openChainModal,
2611
- children: "Wrong network"
2611
+ children: "Select a Network"
2612
2612
  }
2613
2613
  );
2614
2614
  }
@@ -2741,20 +2741,90 @@ var Logos = () => {
2741
2741
  import NiceModal5 from "@ebay/nice-modal-react";
2742
2742
 
2743
2743
  // src/modals/CryptoSelectModal.tsx
2744
+ import { useMemo as useMemo8, useState as useState12 } from "react";
2744
2745
  import NiceModal4, { useModal as useModal2 } from "@ebay/nice-modal-react";
2745
2746
 
2746
- // src/hooks/useBaseERC20Token.ts
2747
+ // ../ui/src/components/input.tsx
2748
+ import { jsx as jsx31 } from "react/jsx-runtime";
2749
+ function Input2({ className, type, ...props }) {
2750
+ return /* @__PURE__ */ jsx31(
2751
+ "input",
2752
+ {
2753
+ type,
2754
+ "data-slot": "input",
2755
+ className: cn2(
2756
+ "file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
2757
+ "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
2758
+ "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
2759
+ className
2760
+ ),
2761
+ ...props
2762
+ }
2763
+ );
2764
+ }
2765
+
2766
+ // ../../node_modules/@radix-ui/react-separator/dist/index.mjs
2747
2767
  import * as React13 from "react";
2768
+ import { jsx as jsx32 } from "react/jsx-runtime";
2769
+ var NAME = "Separator";
2770
+ var DEFAULT_ORIENTATION = "horizontal";
2771
+ var ORIENTATIONS = ["horizontal", "vertical"];
2772
+ var Separator = React13.forwardRef((props, forwardedRef) => {
2773
+ const { decorative, orientation: orientationProp = DEFAULT_ORIENTATION, ...domProps } = props;
2774
+ const orientation = isValidOrientation(orientationProp) ? orientationProp : DEFAULT_ORIENTATION;
2775
+ const ariaOrientation = orientation === "vertical" ? orientation : void 0;
2776
+ const semanticProps = decorative ? { role: "none" } : { "aria-orientation": ariaOrientation, role: "separator" };
2777
+ return /* @__PURE__ */ jsx32(
2778
+ Primitive.div,
2779
+ {
2780
+ "data-orientation": orientation,
2781
+ ...semanticProps,
2782
+ ...domProps,
2783
+ ref: forwardedRef
2784
+ }
2785
+ );
2786
+ });
2787
+ Separator.displayName = NAME;
2788
+ function isValidOrientation(orientation) {
2789
+ return ORIENTATIONS.includes(orientation);
2790
+ }
2791
+ var Root6 = Separator;
2792
+
2793
+ // ../ui/src/components/separator.tsx
2794
+ import { jsx as jsx33 } from "react/jsx-runtime";
2795
+ function Separator2({
2796
+ className,
2797
+ orientation = "horizontal",
2798
+ decorative = true,
2799
+ ...props
2800
+ }) {
2801
+ return /* @__PURE__ */ jsx33(
2802
+ Root6,
2803
+ {
2804
+ "data-slot": "separator",
2805
+ decorative,
2806
+ orientation,
2807
+ className: cn2(
2808
+ "bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",
2809
+ className
2810
+ ),
2811
+ ...props
2812
+ }
2813
+ );
2814
+ }
2815
+
2816
+ // src/hooks/useBaseERC20Token.ts
2817
+ import * as React14 from "react";
2748
2818
  import { erc20Abi as erc20Abi3, formatUnits, getAddress } from "viem";
2749
2819
  import { useAccount, usePublicClient } from "wagmi";
2750
2820
  function useBaseERC20Token() {
2751
2821
  const { address } = useAccount();
2752
2822
  const baseClient = usePublicClient({ chainId: BASE_CHAIN_ID });
2753
2823
  const defaultClient = usePublicClient();
2754
- const [rows, setRows] = React13.useState([]);
2755
- const [isLoading, setLoading] = React13.useState(false);
2756
- const [error, setError] = React13.useState(null);
2757
- React13.useEffect(() => {
2824
+ const [rows, setRows] = React14.useState([]);
2825
+ const [isLoading, setLoading] = React14.useState(false);
2826
+ const [error, setError] = React14.useState(null);
2827
+ React14.useEffect(() => {
2758
2828
  let cancelled = false;
2759
2829
  async function run() {
2760
2830
  const client = baseClient ?? defaultClient;
@@ -2827,36 +2897,56 @@ function useBaseNativeToken() {
2827
2897
  };
2828
2898
  }
2829
2899
 
2900
+ // src/hooks/useBaseTokens.ts
2901
+ import useSWR4 from "swr";
2902
+ var useBaseTokens = () => {
2903
+ const { data: resData, isLoading } = useSWR4(`/v1/base-transactions/tokens`);
2904
+ return { tokens: resData?.data ?? [], tokensIsLoading: isLoading };
2905
+ };
2906
+
2830
2907
  // src/modals/CryptoSelectModal.tsx
2831
- import { Fragment as Fragment5, jsx as jsx31, jsxs as jsxs19 } from "react/jsx-runtime";
2908
+ import { Fragment as Fragment5, jsx as jsx34, jsxs as jsxs19 } from "react/jsx-runtime";
2832
2909
  var CryptoSelectModal = NiceModal4.create(() => {
2833
2910
  const modal = useModal2();
2834
2911
  const { isLoading, error, erc20Balances } = useBaseERC20Token();
2835
2912
  const { isLoadingNative, nativeError, nativeBalance } = useBaseNativeToken();
2913
+ const { tokens, tokensIsLoading } = useBaseTokens();
2914
+ const [search, setSearch] = useState12("");
2915
+ const filteredCoins = useMemo8(() => {
2916
+ return tokens.filter(
2917
+ (coin) => coin.name.toLowerCase().includes(search.toLowerCase()) || coin.symbol.toLowerCase().includes(search.toLowerCase())
2918
+ );
2919
+ }, [tokens, search]);
2836
2920
  const { setSelectedPaymentMethod } = useSpreePaymentMethod();
2837
2921
  const handleSelect = (coin) => {
2838
2922
  modal.remove();
2839
2923
  setSelectedPaymentMethod({ type: "CRYPTO" /* CRYPTO */, method: coin });
2840
2924
  };
2925
+ const userCoins = [nativeBalance, ...erc20Balances].filter(Boolean);
2926
+ const userCoinSymbols = userCoins.map((c) => c.symbol);
2841
2927
  return /* @__PURE__ */ jsxs19(Dialog, { open: modal.visible, onOpenChange: modal.remove, children: [
2842
- /* @__PURE__ */ jsx31(DialogDescription, { className: "hidden", children: "Crypto Select Modal" }),
2843
- /* @__PURE__ */ jsxs19(DialogContent, { showCloseButton: false, className: "gap-0 p-0", children: [
2844
- /* @__PURE__ */ jsx31("div", { className: "flex flex-col gap-6 px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ jsxs19("div", { className: "flex items-center justify-between gap-4", children: [
2845
- /* @__PURE__ */ jsx31("button", { className: "rounded-md hover:bg-gray-100", onClick: modal.remove, children: /* @__PURE__ */ jsx31("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "25", fill: "none", children: /* @__PURE__ */ jsx31("path", { stroke: "#000", d: "m15 6.5-6 6 6 6" }) }) }),
2846
- /* @__PURE__ */ jsx31(DialogTitle, { className: "text-primary text-2xl font-semibold", children: "Select a token" }),
2847
- /* @__PURE__ */ jsx31("button", { className: "rounded-md p-1 hover:bg-gray-100", onClick: modal.remove, children: /* @__PURE__ */ jsx31("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "17", fill: "none", children: /* @__PURE__ */ jsx31(
2848
- "path",
2849
- {
2850
- fill: "#000",
2851
- d: "M12.6 3.9c.2.2.2.52 0 .71L8.7 8.5l3.9 3.89a.5.5 0 1 1-.71.7L8 9.22 4.11 13.1a.5.5 0 1 1-.7-.71L7.28 8.5 3.4 4.61a.5.5 0 1 1 .71-.7L8 7.78l3.89-3.89c.2-.2.51-.2.7 0Z"
2852
- }
2853
- ) }) })
2854
- ] }) }),
2855
- /* @__PURE__ */ jsxs19("div", { className: "flex flex-col gap-4 px-5 py-5 md:px-7 md:py-6", children: [
2856
- /* @__PURE__ */ jsx31("h3", { className: "text-primary text-xl font-semibold", children: "Tokens with wallet balance" }),
2857
- (error || nativeError) && /* @__PURE__ */ jsx31("p", { className: "text-center text-sm text-red-500", children: "Something wrong" }),
2928
+ /* @__PURE__ */ jsx34(DialogDescription, { className: "hidden", children: "Crypto Select Modal" }),
2929
+ /* @__PURE__ */ jsxs19(DialogContent, { showCloseButton: false, className: "max-h-[90vh] gap-0 p-0", children: [
2930
+ /* @__PURE__ */ jsxs19("div", { className: "flex flex-col gap-4 px-5 py-5 md:px-7", children: [
2931
+ /* @__PURE__ */ jsxs19("div", { className: "flex items-center justify-between gap-4", children: [
2932
+ /* @__PURE__ */ jsx34("button", { className: "rounded-md hover:bg-gray-100", onClick: modal.remove, children: /* @__PURE__ */ jsx34("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "25", fill: "none", children: /* @__PURE__ */ jsx34("path", { stroke: "#000", d: "m15 6.5-6 6 6 6" }) }) }),
2933
+ /* @__PURE__ */ jsx34(DialogTitle, { className: "text-primary text-2xl font-semibold", children: "Select a token" }),
2934
+ /* @__PURE__ */ jsx34("button", { className: "rounded-md p-1 hover:bg-gray-100", onClick: modal.remove, children: /* @__PURE__ */ jsx34("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "17", fill: "none", children: /* @__PURE__ */ jsx34(
2935
+ "path",
2936
+ {
2937
+ fill: "#000",
2938
+ d: "M12.6 3.9c.2.2.2.52 0 .71L8.7 8.5l3.9 3.89a.5.5 0 1 1-.71.7L8 9.22 4.11 13.1a.5.5 0 1 1-.7-.71L7.28 8.5 3.4 4.61a.5.5 0 1 1 .71-.7L8 7.78l3.89-3.89c.2-.2.51-.2.7 0Z"
2939
+ }
2940
+ ) }) })
2941
+ ] }),
2942
+ /* @__PURE__ */ jsx34(Input2, { onChange: (e) => setSearch(e.target.value), placeholder: "Search by token name", value: search })
2943
+ ] }),
2944
+ /* @__PURE__ */ jsx34(Separator2, { className: "hidden md:block" }),
2945
+ /* @__PURE__ */ jsxs19("div", { className: "flex flex-col gap-4 px-5 py-5 md:px-7", children: [
2946
+ /* @__PURE__ */ jsx34("h3", { className: "text-primary text-xl font-semibold", children: "Tokens with wallet balance" }),
2947
+ (error || nativeError) && /* @__PURE__ */ jsx34("p", { className: "text-center text-sm text-red-500", children: "Something wrong" }),
2858
2948
  /* @__PURE__ */ jsxs19("div", { className: "flex w-full flex-col gap-1", children: [
2859
- isLoadingNative && /* @__PURE__ */ jsx31("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
2949
+ isLoadingNative && /* @__PURE__ */ jsx34("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
2860
2950
  nativeBalance && /* @__PURE__ */ jsxs19(
2861
2951
  "button",
2862
2952
  {
@@ -2864,7 +2954,7 @@ var CryptoSelectModal = NiceModal4.create(() => {
2864
2954
  onClick: () => handleSelect(nativeBalance),
2865
2955
  children: [
2866
2956
  /* @__PURE__ */ jsxs19("div", { className: "flex items-center gap-2", children: [
2867
- nativeBalance.logoURI && /* @__PURE__ */ jsx31(
2957
+ nativeBalance.logoURI && /* @__PURE__ */ jsx34(
2868
2958
  "img",
2869
2959
  {
2870
2960
  className: "h-8 w-8 shrink-0",
@@ -2872,17 +2962,17 @@ var CryptoSelectModal = NiceModal4.create(() => {
2872
2962
  alt: `${nativeBalance.symbol} logo`
2873
2963
  }
2874
2964
  ),
2875
- /* @__PURE__ */ jsx31("p", { className: "text-sm font-medium", children: nativeBalance.symbol })
2965
+ /* @__PURE__ */ jsx34("p", { className: "text-sm font-medium", children: nativeBalance.symbol })
2876
2966
  ] }),
2877
- /* @__PURE__ */ jsx31("p", { className: "text-sm font-medium", children: nativeBalance.formatted })
2967
+ /* @__PURE__ */ jsx34("p", { className: "text-sm font-medium", children: nativeBalance.formatted })
2878
2968
  ]
2879
2969
  },
2880
2970
  nativeBalance.symbol
2881
2971
  ),
2882
2972
  isLoading && /* @__PURE__ */ jsxs19(Fragment5, { children: [
2883
- /* @__PURE__ */ jsx31("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
2884
- /* @__PURE__ */ jsx31("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
2885
- /* @__PURE__ */ jsx31("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" })
2973
+ /* @__PURE__ */ jsx34("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
2974
+ /* @__PURE__ */ jsx34("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
2975
+ /* @__PURE__ */ jsx34("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" })
2886
2976
  ] }),
2887
2977
  erc20Balances.map((coin) => {
2888
2978
  const Icon = getSymbolLogo(coin.symbol);
@@ -2894,14 +2984,35 @@ var CryptoSelectModal = NiceModal4.create(() => {
2894
2984
  children: [
2895
2985
  /* @__PURE__ */ jsxs19("div", { className: "flex items-center gap-2", children: [
2896
2986
  Boolean(Icon) && Icon,
2897
- /* @__PURE__ */ jsx31("p", { className: "text-sm font-medium", children: coin.symbol })
2987
+ /* @__PURE__ */ jsx34("p", { className: "text-sm font-medium", children: coin.symbol })
2898
2988
  ] }),
2899
- /* @__PURE__ */ jsx31("p", { className: "text-sm font-medium", children: coin.formatted })
2989
+ /* @__PURE__ */ jsx34("p", { className: "text-sm font-medium", children: coin.formatted })
2900
2990
  ]
2901
2991
  },
2902
2992
  coin.symbol
2903
2993
  );
2904
2994
  })
2995
+ ] }),
2996
+ /* @__PURE__ */ jsx34("h3", { className: "text-primary text-xl font-semibold", children: "All Tokens" }),
2997
+ /* @__PURE__ */ jsxs19("div", { className: "flex max-h-[40vh] w-full flex-col gap-1 overflow-y-auto", children: [
2998
+ tokensIsLoading && /* @__PURE__ */ jsxs19(Fragment5, { children: [
2999
+ /* @__PURE__ */ jsx34("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
3000
+ /* @__PURE__ */ jsx34("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
3001
+ /* @__PURE__ */ jsx34("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" })
3002
+ ] }),
3003
+ filteredCoins.map((token) => /* @__PURE__ */ jsx34(
3004
+ "button",
3005
+ {
3006
+ disabled: !userCoinSymbols.includes(token.symbol),
3007
+ onClick: () => handleSelect(userCoins.find((c) => c.symbol === token.symbol)),
3008
+ className: "flex min-h-11 w-full items-center justify-between gap-4 rounded-sm px-1.5 text-black hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50",
3009
+ children: /* @__PURE__ */ jsxs19("div", { className: "flex items-center gap-2", children: [
3010
+ token.logoURI ? /* @__PURE__ */ jsx34("img", { className: "h-8 w-8 shrink-0", src: token.logoURI, alt: `${token.name} logo` }) : /* @__PURE__ */ jsx34("div", { className: "h-8 w-8 shrink-0 rounded-full bg-gray-400" }),
3011
+ /* @__PURE__ */ jsx34("p", { className: "text-sm font-medium", children: token.symbol })
3012
+ ] })
3013
+ },
3014
+ token.symbol
3015
+ ))
2905
3016
  ] })
2906
3017
  ] })
2907
3018
  ] })
@@ -2910,44 +3021,44 @@ var CryptoSelectModal = NiceModal4.create(() => {
2910
3021
  CryptoSelectModal.displayName = "CryptoSelectModal";
2911
3022
 
2912
3023
  // src/components/CryptoTab/Crypto/SelectCoinButton.tsx
2913
- import { jsx as jsx32, jsxs as jsxs20 } from "react/jsx-runtime";
3024
+ import { jsx as jsx35, jsxs as jsxs20 } from "react/jsx-runtime";
2914
3025
  var SelectCoinButton = () => {
2915
3026
  const openModal = () => {
2916
3027
  NiceModal5.show(CryptoSelectModal);
2917
3028
  };
2918
3029
  return /* @__PURE__ */ jsxs20("button", { onClick: openModal, type: "button", className: "bg-primary/8 flex h-11 w-full overflow-hidden rounded-md", children: [
2919
- /* @__PURE__ */ jsx32("div", { className: "bg-primary flex h-full w-11 items-center justify-center", children: /* @__PURE__ */ jsx32("div", { className: "flex h-5 w-5 items-center justify-center rounded-full bg-white" }) }),
3030
+ /* @__PURE__ */ jsx35("div", { className: "bg-primary flex h-full w-11 items-center justify-center", children: /* @__PURE__ */ jsx35("div", { className: "flex h-5 w-5 items-center justify-center rounded-full bg-white" }) }),
2920
3031
  /* @__PURE__ */ jsxs20("div", { className: "flex h-full w-full items-center justify-between px-3", children: [
2921
- /* @__PURE__ */ jsx32("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx32("p", { className: "font-medium text-black/50", children: "Select a token" }) }),
2922
- /* @__PURE__ */ jsx32("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "none", children: /* @__PURE__ */ jsx32("path", { stroke: "#000", strokeLinecap: "round", d: "m6 12.43 4-4-4-4" }) })
3032
+ /* @__PURE__ */ jsx35("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx35("p", { className: "font-medium text-black/50", children: "Select a token" }) }),
3033
+ /* @__PURE__ */ jsx35("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "none", children: /* @__PURE__ */ jsx35("path", { stroke: "#000", strokeLinecap: "round", d: "m6 12.43 4-4-4-4" }) })
2923
3034
  ] })
2924
3035
  ] });
2925
3036
  };
2926
3037
 
2927
3038
  // src/components/CryptoTab/Crypto/SelectedCoin.tsx
2928
- import { jsx as jsx33, jsxs as jsxs21 } from "react/jsx-runtime";
3039
+ import { jsx as jsx36, jsxs as jsxs21 } from "react/jsx-runtime";
2929
3040
  var SelectedCoin = (props) => {
2930
3041
  const { coin, balance, logoURI } = props;
2931
3042
  const Icon = getSymbolLogo(coin);
2932
3043
  return /* @__PURE__ */ jsxs21("div", { className: "bg-primary/8 flex h-11 w-full overflow-hidden rounded-md", children: [
2933
- /* @__PURE__ */ jsx33("div", { className: "bg-primary flex h-full w-11 items-center justify-center", children: /* @__PURE__ */ jsx33("div", { className: "flex h-5 w-5 items-center justify-center rounded-full bg-white", children: /* @__PURE__ */ jsx33("div", { className: "bg-primary h-2.5 w-2.5 rounded-full" }) }) }),
3044
+ /* @__PURE__ */ jsx36("div", { className: "bg-primary flex h-full w-11 items-center justify-center", children: /* @__PURE__ */ jsx36("div", { className: "flex h-5 w-5 items-center justify-center rounded-full bg-white", children: /* @__PURE__ */ jsx36("div", { className: "bg-primary h-2.5 w-2.5 rounded-full" }) }) }),
2934
3045
  /* @__PURE__ */ jsxs21("div", { className: "border-primary flex h-full w-full items-center justify-between rounded-r-md border-1 !border-l-0 px-3", children: [
2935
3046
  /* @__PURE__ */ jsxs21("div", { className: "flex items-center gap-1", children: [
2936
3047
  Icon,
2937
- !Icon && logoURI && /* @__PURE__ */ jsx33("img", { className: "mr-1 h-8 w-8 shrink-0", src: logoURI, alt: `${coin} logo` }),
2938
- /* @__PURE__ */ jsx33("p", { className: "font-semibold text-black", children: coin }),
2939
- /* @__PURE__ */ jsx33("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx33("path", { d: "M6 12.4341L10 8.43408L6 4.43408", stroke: "black", strokeLinecap: "round" }) })
3048
+ !Icon && logoURI && /* @__PURE__ */ jsx36("img", { className: "mr-1 h-8 w-8 shrink-0", src: logoURI, alt: `${coin} logo` }),
3049
+ /* @__PURE__ */ jsx36("p", { className: "font-semibold text-black", children: coin }),
3050
+ /* @__PURE__ */ jsx36("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx36("path", { d: "M6 12.4341L10 8.43408L6 4.43408", stroke: "black", strokeLinecap: "round" }) })
2940
3051
  ] }),
2941
3052
  /* @__PURE__ */ jsxs21("p", { className: "text-xs font-medium text-black/50", children: [
2942
3053
  "Wallet balance ",
2943
- /* @__PURE__ */ jsx33("span", { className: "text-black", children: balance })
3054
+ /* @__PURE__ */ jsx36("span", { className: "text-black", children: balance })
2944
3055
  ] })
2945
3056
  ] })
2946
3057
  ] });
2947
3058
  };
2948
3059
 
2949
3060
  // src/components/CryptoTab/Crypto/Crypto.tsx
2950
- import { jsx as jsx34, jsxs as jsxs22 } from "react/jsx-runtime";
3061
+ import { jsx as jsx37, jsxs as jsxs22 } from "react/jsx-runtime";
2951
3062
  var Crypto = () => {
2952
3063
  const { address } = useAccount3();
2953
3064
  const { selectedPaymentMethod } = useSpreePaymentMethod();
@@ -2973,12 +3084,12 @@ var Crypto = () => {
2973
3084
  }, [register, handlePay]);
2974
3085
  return /* @__PURE__ */ jsxs22("div", { className: "flex flex-col items-baseline gap-4", children: [
2975
3086
  /* @__PURE__ */ jsxs22("div", { className: "flex w-full items-center justify-between gap-4", children: [
2976
- /* @__PURE__ */ jsx34("h3", { className: "text-primary text-xl leading-[1.7] font-semibold", children: "Pay with Crypto" }),
2977
- /* @__PURE__ */ jsx34(ConnectButton, {})
3087
+ /* @__PURE__ */ jsx37("h3", { className: "text-primary text-xl leading-[1.7] font-semibold", children: "Pay with Crypto" }),
3088
+ /* @__PURE__ */ jsx37(ConnectButton, {})
2978
3089
  ] }),
2979
- !isWalletConnected && /* @__PURE__ */ jsx34(Logos, {}),
3090
+ !isWalletConnected && /* @__PURE__ */ jsx37(Logos, {}),
2980
3091
  isWalletConnected && /* @__PURE__ */ jsxs22("div", { className: "flex w-full flex-col gap-1", children: [
2981
- selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && selectedPaymentMethod.method && /* @__PURE__ */ jsx34(
3092
+ selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && selectedPaymentMethod.method && /* @__PURE__ */ jsx37(
2982
3093
  SelectedCoin,
2983
3094
  {
2984
3095
  coin: selectedPaymentMethod.method.symbol,
@@ -2986,46 +3097,42 @@ var Crypto = () => {
2986
3097
  logoURI: selectedPaymentMethod.method.logoURI
2987
3098
  }
2988
3099
  ),
2989
- /* @__PURE__ */ jsx34(SelectCoinButton, {})
3100
+ /* @__PURE__ */ jsx37(SelectCoinButton, {})
2990
3101
  ] })
2991
3102
  ] });
2992
3103
  };
2993
3104
 
2994
3105
  // src/components/CryptoTab/Crypto/CryptoWrapper.tsx
2995
- import { jsx as jsx35 } from "react/jsx-runtime";
3106
+ import { jsx as jsx38 } from "react/jsx-runtime";
2996
3107
  var queryClient = new QueryClient();
2997
- var connectors = connectorsForWallets(
2998
- [
2999
- {
3000
- groupName: "Supported",
3001
- wallets: [injectedWallet, walletConnectWallet]
3002
- }
3003
- ],
3004
- { appName: "Spree Pay", projectId: "YOUR_PROJECT_ID" }
3005
- );
3006
- var config = createConfig({
3007
- chains: [base],
3008
- connectors,
3009
- transports: { [base.id]: http2() },
3010
- ssr: true
3011
- });
3012
3108
  var CryptoWrapper = () => {
3013
- return /* @__PURE__ */ jsx35(WagmiProvider, { config, children: /* @__PURE__ */ jsx35(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx35(RainbowKitProvider, { children: /* @__PURE__ */ jsx35(NiceModal6.Provider, { children: /* @__PURE__ */ jsx35(Crypto, {}) }) }) }) });
3109
+ const { spreePayConfig } = useSpreePayConfig();
3110
+ const config = useMemo9(() => {
3111
+ if (!spreePayConfig) return null;
3112
+ return getDefaultConfig({
3113
+ appName: spreePayConfig.rainbowAppName || "AIR Shop",
3114
+ projectId: spreePayConfig.rainbowProjectId || "3fdcd5ff50cb84917cd05e40146975d8",
3115
+ chains: [base],
3116
+ ssr: true
3117
+ });
3118
+ }, [spreePayConfig]);
3119
+ if (!config) return null;
3120
+ return /* @__PURE__ */ jsx38(WagmiProvider, { config, children: /* @__PURE__ */ jsx38(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx38(RainbowKitProvider, { theme: lightTheme({ borderRadius: "large" }), children: /* @__PURE__ */ jsx38(NiceModal6.Provider, { children: /* @__PURE__ */ jsx38(Crypto, {}) }) }) }) });
3014
3121
  };
3015
3122
 
3016
3123
  // src/components/CryptoTab/CryptoTab.tsx
3017
- import { jsx as jsx36, jsxs as jsxs23 } from "react/jsx-runtime";
3124
+ import { jsx as jsx39, jsxs as jsxs23 } from "react/jsx-runtime";
3018
3125
  var CryptoTab = () => {
3019
3126
  return /* @__PURE__ */ jsxs23("div", { children: [
3020
- /* @__PURE__ */ jsx36("div", { className: "border-b-1 border-black/7 px-5 py-5 md:px-7 md:py-5", children: /* @__PURE__ */ jsx36(CryptoWrapper, {}) }),
3021
- /* @__PURE__ */ jsx36("div", { className: "px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ jsx36(PointsSwitch, { disabled: true }) })
3127
+ /* @__PURE__ */ jsx39("div", { className: "border-b-1 border-black/7 px-5 py-5 md:px-7 md:py-5", children: /* @__PURE__ */ jsx39(CryptoWrapper, {}) }),
3128
+ /* @__PURE__ */ jsx39("div", { className: "px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ jsx39(PointsSwitch, { disabled: true }) })
3022
3129
  ] });
3023
3130
  };
3024
3131
 
3025
3132
  // src/components/TabButtons.tsx
3026
- import { jsx as jsx37, jsxs as jsxs24 } from "react/jsx-runtime";
3133
+ import { jsx as jsx40, jsxs as jsxs24 } from "react/jsx-runtime";
3027
3134
  var TabButton = ({ isDisabled = true, isActive, children, onClick }) => {
3028
- return /* @__PURE__ */ jsx37(
3135
+ return /* @__PURE__ */ jsx40(
3029
3136
  "button",
3030
3137
  {
3031
3138
  disabled: isDisabled,
@@ -3056,14 +3163,14 @@ var TabButtons = (props) => {
3056
3163
  onClick: handleChange("CREDIT_CARD" /* CREDIT_CARD */),
3057
3164
  isActive: value === "CREDIT_CARD" /* CREDIT_CARD */,
3058
3165
  children: [
3059
- /* @__PURE__ */ jsx37("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", fill: "none", children: /* @__PURE__ */ jsx37(
3166
+ /* @__PURE__ */ jsx40("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", fill: "none", children: /* @__PURE__ */ jsx40(
3060
3167
  "path",
3061
3168
  {
3062
3169
  fill: "currentColor",
3063
3170
  d: "M22 6v12c0 .55-.2 1.02-.59 1.41-.39.4-.86.59-1.41.59H4c-.55 0-1.02-.2-1.41-.59-.4-.39-.59-.86-.59-1.41V6c0-.55.2-1.02.59-1.41C2.98 4.19 3.45 4 4 4h16c.55 0 1.02.2 1.41.59.4.39.59.86.59 1.41ZM4 8h16V6H4v2Zm0 4v6h16v-6H4Z"
3064
3171
  }
3065
3172
  ) }),
3066
- /* @__PURE__ */ jsx37("p", { className: "text-sm font-medium", children: "Card" })
3173
+ /* @__PURE__ */ jsx40("p", { className: "text-sm font-medium", children: "Card" })
3067
3174
  ]
3068
3175
  }
3069
3176
  ),
@@ -3075,23 +3182,23 @@ var TabButtons = (props) => {
3075
3182
  isActive: value === "CRYPTO" /* CRYPTO */,
3076
3183
  children: [
3077
3184
  /* @__PURE__ */ jsxs24("svg", { className: "my-1", xmlns: "http://www.w3.org/2000/svg", width: "30", height: "16", fill: "none", children: [
3078
- /* @__PURE__ */ jsx37(
3185
+ /* @__PURE__ */ jsx40(
3079
3186
  "path",
3080
3187
  {
3081
3188
  fill: "currentColor",
3082
3189
  d: "M14.5 0C19.2 0 23 3.58 23 8s-3.8 8-8.5 8a8.93 8.93 0 0 1-3.35-.65 8 8 0 0 0 2.24-1.44c.36.06.73.09 1.11.09 3.7 0 6.5-2.8 6.5-6s-2.8-6-6.5-6c-.38 0-.75.03-1.11.09A8 8 0 0 0 11.15.65 8.93 8.93 0 0 1 14.5 0Z"
3083
3190
  }
3084
3191
  ),
3085
- /* @__PURE__ */ jsx37(
3192
+ /* @__PURE__ */ jsx40(
3086
3193
  "path",
3087
3194
  {
3088
3195
  fill: "currentColor",
3089
3196
  d: "M21.15 0c4.7 0 8.5 3.58 8.5 8s-3.8 8-8.5 8a8.93 8.93 0 0 1-3.35-.65 8 8 0 0 0 2.24-1.44c.36.06.73.09 1.1.09 3.71 0 6.5-2.8 6.5-6s-2.79-6-6.5-6c-.37 0-.74.03-1.1.09A8 8 0 0 0 17.8.65 8.93 8.93 0 0 1 21.15 0Z"
3090
3197
  }
3091
3198
  ),
3092
- /* @__PURE__ */ jsx37("circle", { cx: "8", cy: "8", r: "7", stroke: "currentColor", strokeWidth: "2" })
3199
+ /* @__PURE__ */ jsx40("circle", { cx: "8", cy: "8", r: "7", stroke: "currentColor", strokeWidth: "2" })
3093
3200
  ] }),
3094
- /* @__PURE__ */ jsx37("p", { className: "text-sm font-medium", children: "Crypto" })
3201
+ /* @__PURE__ */ jsx40("p", { className: "text-sm font-medium", children: "Crypto" })
3095
3202
  ]
3096
3203
  }
3097
3204
  )
@@ -3099,41 +3206,41 @@ var TabButtons = (props) => {
3099
3206
  };
3100
3207
 
3101
3208
  // src/components/Tabs.tsx
3102
- import { jsx as jsx38, jsxs as jsxs25 } from "react/jsx-runtime";
3209
+ import { jsx as jsx41, jsxs as jsxs25 } from "react/jsx-runtime";
3103
3210
  var Tabs = () => {
3104
3211
  const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
3105
3212
  return /* @__PURE__ */ jsxs25("div", { className: "mb-4 rounded-3xl border border-black/25 bg-white", children: [
3106
3213
  /* @__PURE__ */ jsxs25("div", { className: "flex w-full flex-col gap-4 border-b-1 border-black/7 px-5 py-5 md:px-7 md:py-6", children: [
3107
- /* @__PURE__ */ jsx38("h2", { className: "text-primary text-2xl font-semibold", children: "Choose a Payment Method" }),
3108
- /* @__PURE__ */ jsx38(TabButtons, { value: selectedPaymentMethod.type, onChange: setSelectedPaymentMethod })
3214
+ /* @__PURE__ */ jsx41("h2", { className: "text-primary text-2xl font-semibold", children: "Choose a Payment Method" }),
3215
+ /* @__PURE__ */ jsx41(TabButtons, { value: selectedPaymentMethod.type, onChange: setSelectedPaymentMethod })
3109
3216
  ] }),
3110
- selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */ && /* @__PURE__ */ jsx38(CreditCardTab, {}),
3111
- selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && /* @__PURE__ */ jsx38(CryptoTab, {})
3217
+ selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */ && /* @__PURE__ */ jsx41(CreditCardTab, {}),
3218
+ selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && /* @__PURE__ */ jsx41(CryptoTab, {})
3112
3219
  ] });
3113
3220
  };
3114
3221
 
3115
3222
  // src/SpreePayContent.tsx
3116
- import { jsx as jsx39, jsxs as jsxs26 } from "react/jsx-runtime";
3223
+ import { jsx as jsx42, jsxs as jsxs26 } from "react/jsx-runtime";
3117
3224
  var SpreePayContent = ({ isLoggedIn }) => {
3118
3225
  return /* @__PURE__ */ jsxs26("div", { className: "w-full", children: [
3119
- /* @__PURE__ */ jsx39(Tabs, {}),
3120
- /* @__PURE__ */ jsx39(CheckoutButton, { isLoggedIn }),
3121
- /* @__PURE__ */ jsx39(SpreeLegal, {})
3226
+ /* @__PURE__ */ jsx42(Tabs, {}),
3227
+ /* @__PURE__ */ jsx42(CheckoutButton, { isLoggedIn }),
3228
+ /* @__PURE__ */ jsx42(SpreeLegal, {})
3122
3229
  ] });
3123
3230
  };
3124
3231
 
3125
3232
  // src/hooks/useKeycloakSSO.ts
3126
- import { useCallback as useCallback7, useEffect as useEffect10, useRef as useRef6, useState as useState12 } from "react";
3233
+ import { useCallback as useCallback7, useEffect as useEffect10, useRef as useRef6, useState as useState13 } from "react";
3127
3234
  import Keycloak from "keycloak-js";
3128
3235
  var refreshAheadSeconds = 60;
3129
- function useKeycloakSSO(config2) {
3130
- const { url, realm, clientId, ssoPageURI, enabled } = config2;
3236
+ function useKeycloakSSO(config) {
3237
+ const { url, realm, clientId, ssoPageURI, enabled } = config;
3131
3238
  const initRef = useRef6(false);
3132
3239
  const kcRef = useRef6(null);
3133
3240
  const refreshTimerRef = useRef6(null);
3134
- const [error, setError] = useState12(null);
3135
- const [isChecking, setIsChecking] = useState12(enabled);
3136
- const [accessToken, setAccessToken] = useState12(null);
3241
+ const [error, setError] = useState13(null);
3242
+ const [isChecking, setIsChecking] = useState13(enabled);
3243
+ const [accessToken, setAccessToken] = useState13(null);
3137
3244
  const scheduleRefresh = useCallback7(() => {
3138
3245
  const kc = kcRef.current;
3139
3246
  if (!kc || !kc.tokenParsed || !kc.tokenParsed.exp) {
@@ -3190,10 +3297,10 @@ function useKeycloakSSO(config2) {
3190
3297
  }
3191
3298
 
3192
3299
  // src/SpreePay.tsx
3193
- import { jsx as jsx40, jsxs as jsxs27 } from "react/jsx-runtime";
3300
+ import { jsx as jsx43, jsxs as jsxs27 } from "react/jsx-runtime";
3194
3301
  var SpreePayInner = () => {
3195
3302
  const rootRef = useRef7(null);
3196
- const [portalEl, setPortalEl] = useState13(null);
3303
+ const [portalEl, setPortalEl] = useState14(null);
3197
3304
  useLayoutEffect3(() => {
3198
3305
  if (!rootRef.current) return;
3199
3306
  const el = rootRef.current.querySelector(":scope > .sl-spreepay__portal");
@@ -3209,7 +3316,7 @@ var SpreePayInner = () => {
3209
3316
  ssoPageURI: env?.ssoPageURI,
3210
3317
  enabled: !env?.accessToken
3211
3318
  });
3212
- const slapiFetcher = useMemo8(() => {
3319
+ const slapiFetcher = useMemo10(() => {
3213
3320
  if (accessToken || env.accessToken) {
3214
3321
  return registerApi({
3215
3322
  accessToken: env.accessToken || accessToken,
@@ -3221,12 +3328,12 @@ var SpreePayInner = () => {
3221
3328
  const getContent = () => {
3222
3329
  if (isChecking) {
3223
3330
  return /* @__PURE__ */ jsxs27("div", { className: "flex w-full flex-col", children: [
3224
- /* @__PURE__ */ jsx40("div", { className: "bg-primary/8 mb-4 h-[315px] animate-pulse rounded-3xl" }),
3225
- /* @__PURE__ */ jsx40("div", { className: "bg-primary/8 h-[135px] animate-pulse rounded-3xl" }),
3226
- /* @__PURE__ */ jsx40(SpreeLegal, {})
3331
+ /* @__PURE__ */ jsx43("div", { className: "bg-primary/8 mb-4 h-[315px] animate-pulse rounded-3xl" }),
3332
+ /* @__PURE__ */ jsx43("div", { className: "bg-primary/8 h-[135px] animate-pulse rounded-3xl" }),
3333
+ /* @__PURE__ */ jsx43(SpreeLegal, {})
3227
3334
  ] });
3228
3335
  }
3229
- return /* @__PURE__ */ jsx40(
3336
+ return /* @__PURE__ */ jsx43(
3230
3337
  SWRConfig,
3231
3338
  {
3232
3339
  value: {
@@ -3235,17 +3342,17 @@ var SpreePayInner = () => {
3235
3342
  revalidateOnFocus: false,
3236
3343
  revalidateIfStale: false
3237
3344
  },
3238
- children: /* @__PURE__ */ jsx40(PortalContainerProvider, { container: portalEl, children: /* @__PURE__ */ jsx40(NiceModal7.Provider, { children: /* @__PURE__ */ jsx40(SpreePayContent, { isLoggedIn: Boolean(accessToken || env.accessToken) }) }) })
3345
+ children: /* @__PURE__ */ jsx43(PortalContainerProvider, { container: portalEl, children: /* @__PURE__ */ jsx43(NiceModal7.Provider, { children: /* @__PURE__ */ jsx43(SpreePayContent, { isLoggedIn: Boolean(accessToken || env.accessToken) }) }) })
3239
3346
  }
3240
3347
  );
3241
3348
  };
3242
3349
  return /* @__PURE__ */ jsxs27("div", { ref: rootRef, className: cn("sl-spreepay", appProps.className), children: [
3243
- /* @__PURE__ */ jsx40("div", { className: "sl-spreepay__portal" }),
3350
+ /* @__PURE__ */ jsx43("div", { className: "sl-spreepay__portal" }),
3244
3351
  getContent()
3245
3352
  ] });
3246
3353
  };
3247
3354
  var SpreePay = (props) => {
3248
- return /* @__PURE__ */ jsx40(StaticConfigProvider, { props, children: /* @__PURE__ */ jsx40(SpreePayInner, {}) });
3355
+ return /* @__PURE__ */ jsx43(StaticConfigProvider, { props, children: /* @__PURE__ */ jsx43(SpreePayInner, {}) });
3249
3356
  };
3250
3357
 
3251
3358
  // src/hooks/useCapture3DS.ts