@solvapay/react 2.1.1 → 2.2.0-preview-11dbbe603cd1b9a44cc41b5eee3686bc4000f97f
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/CHANGELOG.md +23 -2
- package/dist/{chunk-HQH6KSXJ.js → chunk-EWB43JVC.js} +5 -2
- package/dist/{chunk-QXNNMNCV.js → chunk-M6O7ZWNP.js} +136 -51
- package/dist/{chunk-LL6AYSTC.js → chunk-WISTNSUH.js} +371 -317
- package/dist/{index-CBWGkBqF.d.ts → index-APG9WYgS.d.cts} +33 -5
- package/dist/{index-SylJb9Rh.d.cts → index-ofZwGvIZ.d.ts} +33 -5
- package/dist/index.cjs +1455 -1319
- package/dist/index.d.cts +82 -17
- package/dist/index.d.ts +82 -17
- package/dist/index.js +9 -3
- package/dist/mcp/index.cjs +1561 -1345
- package/dist/mcp/index.d.cts +176 -129
- package/dist/mcp/index.d.ts +176 -129
- package/dist/mcp/index.js +178 -92
- package/dist/mcp/styles.css +39 -14
- package/dist/primitives/index.cjs +822 -786
- package/dist/primitives/index.d.cts +4 -4
- package/dist/primitives/index.d.ts +4 -4
- package/dist/primitives/index.js +2 -2
- package/dist/{shared-D0hmT1qU.d.cts → shared-BQbMyX5V.d.cts} +14 -1
- package/dist/{shared-CUl6mTC1.d.ts → shared-DJdsOLag.d.ts} +14 -1
- package/dist/styles.css +20 -0
- package/package.json +5 -5
|
@@ -891,6 +891,9 @@ var enCopy = {
|
|
|
891
891
|
expiresOn: "Expires {date}",
|
|
892
892
|
validIndefinitely: "Valid indefinitely",
|
|
893
893
|
startedOn: "Started {date}",
|
|
894
|
+
priceFieldLabel: "Price",
|
|
895
|
+
rateFieldLabel: "Rate",
|
|
896
|
+
balanceFieldLabel: "Balance",
|
|
894
897
|
paymentMethod: "{brand} \u2022\u2022\u2022\u2022 {last4}",
|
|
895
898
|
paymentMethodExpires: "expires {month}/{year}",
|
|
896
899
|
noPaymentMethod: "No payment method on file",
|
|
@@ -910,7 +913,9 @@ var enCopy = {
|
|
|
910
913
|
noPlanTitle: "Pick a plan",
|
|
911
914
|
noPlanBody: "Choose a free, pay-as-you-go, or paid plan to start using this MCP server.",
|
|
912
915
|
seePlansButton: "See plans",
|
|
913
|
-
pickPlanButton: "Pick a plan"
|
|
916
|
+
pickPlanButton: "Pick a plan",
|
|
917
|
+
upgradeButton: "Upgrade",
|
|
918
|
+
changePlanButton: "Change plan"
|
|
914
919
|
},
|
|
915
920
|
customerPortal: {
|
|
916
921
|
launchButton: "Manage account",
|
|
@@ -2473,7 +2478,7 @@ function usePlanSelector() {
|
|
|
2473
2478
|
}
|
|
2474
2479
|
|
|
2475
2480
|
// src/primitives/PaymentForm.tsx
|
|
2476
|
-
var
|
|
2481
|
+
var import_react20 = __toESM(require("react"), 1);
|
|
2477
2482
|
var import_react_stripe_js = require("@stripe/react-stripe-js");
|
|
2478
2483
|
|
|
2479
2484
|
// src/utils/stripeLocale.ts
|
|
@@ -2538,7 +2543,30 @@ function toStripeElementLocale(locale) {
|
|
|
2538
2543
|
}
|
|
2539
2544
|
|
|
2540
2545
|
// src/primitives/LegalFooter.tsx
|
|
2546
|
+
var import_react13 = require("react");
|
|
2547
|
+
|
|
2548
|
+
// src/hooks/useExternalLink.tsx
|
|
2541
2549
|
var import_react12 = require("react");
|
|
2550
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
2551
|
+
var ExternalLinkContext = (0, import_react12.createContext)(null);
|
|
2552
|
+
function useExternalLinkClick() {
|
|
2553
|
+
const opener = (0, import_react12.useContext)(ExternalLinkContext);
|
|
2554
|
+
return (0, import_react12.useCallback)(
|
|
2555
|
+
(event) => {
|
|
2556
|
+
if (event.defaultPrevented) return;
|
|
2557
|
+
if (!opener?.canOpen()) return;
|
|
2558
|
+
const href = event.currentTarget.href;
|
|
2559
|
+
if (!href) return;
|
|
2560
|
+
event.preventDefault();
|
|
2561
|
+
void opener.open(href).then((opened) => {
|
|
2562
|
+
if (!opened) {
|
|
2563
|
+
console.warn(`[solvapay] host declined to open ${href}`);
|
|
2564
|
+
}
|
|
2565
|
+
});
|
|
2566
|
+
},
|
|
2567
|
+
[opener]
|
|
2568
|
+
);
|
|
2569
|
+
}
|
|
2542
2570
|
|
|
2543
2571
|
// src/constants/legal.ts
|
|
2544
2572
|
var SOLVAPAY_TERMS_URL = "https://solvapay.com/legal/terms";
|
|
@@ -2546,8 +2574,8 @@ var SOLVAPAY_PRIVACY_URL = "https://solvapay.com/legal/privacy";
|
|
|
2546
2574
|
var SOLVAPAY_WEBSITE_URL = "https://solvapay.com";
|
|
2547
2575
|
|
|
2548
2576
|
// src/primitives/LegalFooter.tsx
|
|
2549
|
-
var
|
|
2550
|
-
var LegalFooter = (0,
|
|
2577
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
2578
|
+
var LegalFooter = (0, import_react13.forwardRef)(
|
|
2551
2579
|
function LegalFooter2({
|
|
2552
2580
|
attribution = "provided",
|
|
2553
2581
|
termsUrl = SOLVAPAY_TERMS_URL,
|
|
@@ -2557,39 +2585,43 @@ var LegalFooter = (0, import_react12.forwardRef)(
|
|
|
2557
2585
|
...rest
|
|
2558
2586
|
}, forwardedRef) {
|
|
2559
2587
|
const copy = useCopy();
|
|
2588
|
+
const handleExternalClick = useExternalLinkClick();
|
|
2560
2589
|
const attributionLabel = attribution === "provided" ? copy.legalFooter.providedBy : attribution === "powered" ? copy.legalFooter.poweredBy : null;
|
|
2561
2590
|
const Comp = asChild ? Slot : "div";
|
|
2562
|
-
return /* @__PURE__ */ (0,
|
|
2563
|
-
/* @__PURE__ */ (0,
|
|
2564
|
-
/* @__PURE__ */ (0,
|
|
2591
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Comp, { ref: forwardedRef, "data-solvapay-legal-footer": "", ...rest, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
2592
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { "data-solvapay-legal-footer-links": "", children: [
|
|
2593
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2565
2594
|
"a",
|
|
2566
2595
|
{
|
|
2567
2596
|
"data-solvapay-legal-footer-link": "",
|
|
2568
2597
|
href: termsUrl,
|
|
2569
2598
|
target: "_blank",
|
|
2570
2599
|
rel: "noopener noreferrer",
|
|
2600
|
+
onClick: handleExternalClick,
|
|
2571
2601
|
children: copy.legalFooter.terms
|
|
2572
2602
|
}
|
|
2573
2603
|
),
|
|
2574
|
-
/* @__PURE__ */ (0,
|
|
2575
|
-
/* @__PURE__ */ (0,
|
|
2604
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { "aria-hidden": "true", children: " \xB7 " }),
|
|
2605
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2576
2606
|
"a",
|
|
2577
2607
|
{
|
|
2578
2608
|
"data-solvapay-legal-footer-link": "",
|
|
2579
2609
|
href: privacyUrl,
|
|
2580
2610
|
target: "_blank",
|
|
2581
2611
|
rel: "noopener noreferrer",
|
|
2612
|
+
onClick: handleExternalClick,
|
|
2582
2613
|
children: copy.legalFooter.privacy
|
|
2583
2614
|
}
|
|
2584
2615
|
)
|
|
2585
2616
|
] }),
|
|
2586
|
-
attributionLabel ? /* @__PURE__ */ (0,
|
|
2617
|
+
attributionLabel ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2587
2618
|
"a",
|
|
2588
2619
|
{
|
|
2589
2620
|
"data-solvapay-legal-footer-attribution": "",
|
|
2590
2621
|
href: SOLVAPAY_WEBSITE_URL,
|
|
2591
2622
|
target: "_blank",
|
|
2592
2623
|
rel: "noopener noreferrer",
|
|
2624
|
+
onClick: handleExternalClick,
|
|
2593
2625
|
children: attributionLabel
|
|
2594
2626
|
}
|
|
2595
2627
|
) : null
|
|
@@ -2612,7 +2644,7 @@ function withPaymentElementDefaults(options) {
|
|
|
2612
2644
|
}
|
|
2613
2645
|
|
|
2614
2646
|
// src/hooks/useCheckout.ts
|
|
2615
|
-
var
|
|
2647
|
+
var import_react14 = require("react");
|
|
2616
2648
|
var import_stripe_js = require("@stripe/stripe-js");
|
|
2617
2649
|
var stripePromiseCache = /* @__PURE__ */ new Map();
|
|
2618
2650
|
function getStripeCacheKey(publishableKey, accountId) {
|
|
@@ -2654,14 +2686,14 @@ function useCheckout(options) {
|
|
|
2654
2686
|
const { planRef, productRef, currency: currencyOverride, customer } = options;
|
|
2655
2687
|
const planSelection = usePlanSelection();
|
|
2656
2688
|
const { createPayment, customerRef, updateCustomerRef, _config } = useSolvaPay();
|
|
2657
|
-
const [loading, setLoading] = (0,
|
|
2658
|
-
const [error, setError] = (0,
|
|
2659
|
-
const [stripePromise, setStripePromise] = (0,
|
|
2660
|
-
const [clientSecret, setClientSecret] = (0,
|
|
2661
|
-
const [processorPaymentId, setProcessorPaymentId] = (0,
|
|
2662
|
-
const [resolvedPlanRef, setResolvedPlanRef] = (0,
|
|
2663
|
-
const isStartingRef = (0,
|
|
2664
|
-
const startCheckout = (0,
|
|
2689
|
+
const [loading, setLoading] = (0, import_react14.useState)(false);
|
|
2690
|
+
const [error, setError] = (0, import_react14.useState)(null);
|
|
2691
|
+
const [stripePromise, setStripePromise] = (0, import_react14.useState)(null);
|
|
2692
|
+
const [clientSecret, setClientSecret] = (0, import_react14.useState)(null);
|
|
2693
|
+
const [processorPaymentId, setProcessorPaymentId] = (0, import_react14.useState)(null);
|
|
2694
|
+
const [resolvedPlanRef, setResolvedPlanRef] = (0, import_react14.useState)(planRef || null);
|
|
2695
|
+
const isStartingRef = (0, import_react14.useRef)(false);
|
|
2696
|
+
const startCheckout = (0, import_react14.useCallback)(async () => {
|
|
2665
2697
|
if (isStartingRef.current || loading) {
|
|
2666
2698
|
return;
|
|
2667
2699
|
}
|
|
@@ -2737,7 +2769,7 @@ function useCheckout(options) {
|
|
|
2737
2769
|
loading,
|
|
2738
2770
|
_config
|
|
2739
2771
|
]);
|
|
2740
|
-
const reset = (0,
|
|
2772
|
+
const reset = (0, import_react14.useCallback)(() => {
|
|
2741
2773
|
isStartingRef.current = false;
|
|
2742
2774
|
setLoading(false);
|
|
2743
2775
|
setError(null);
|
|
@@ -2770,14 +2802,14 @@ function useCustomer() {
|
|
|
2770
2802
|
}
|
|
2771
2803
|
|
|
2772
2804
|
// src/hooks/useActivation.ts
|
|
2773
|
-
var
|
|
2805
|
+
var import_react15 = require("react");
|
|
2774
2806
|
function useActivation() {
|
|
2775
2807
|
const { activatePlan } = useSolvaPay();
|
|
2776
2808
|
const copy = useCopy();
|
|
2777
|
-
const [state, setState] = (0,
|
|
2778
|
-
const [error, setError] = (0,
|
|
2779
|
-
const [result, setResult] = (0,
|
|
2780
|
-
const activate = (0,
|
|
2809
|
+
const [state, setState] = (0, import_react15.useState)("idle");
|
|
2810
|
+
const [error, setError] = (0, import_react15.useState)(null);
|
|
2811
|
+
const [result, setResult] = (0, import_react15.useState)(null);
|
|
2812
|
+
const activate = (0, import_react15.useCallback)(
|
|
2781
2813
|
async (params) => {
|
|
2782
2814
|
setState("activating");
|
|
2783
2815
|
setError(null);
|
|
@@ -2812,7 +2844,7 @@ function useActivation() {
|
|
|
2812
2844
|
},
|
|
2813
2845
|
[activatePlan, copy]
|
|
2814
2846
|
);
|
|
2815
|
-
const reset = (0,
|
|
2847
|
+
const reset = (0, import_react15.useCallback)(() => {
|
|
2816
2848
|
setState("idle");
|
|
2817
2849
|
setError(null);
|
|
2818
2850
|
setResult(null);
|
|
@@ -2821,11 +2853,11 @@ function useActivation() {
|
|
|
2821
2853
|
}
|
|
2822
2854
|
|
|
2823
2855
|
// src/components/PaymentFormContext.tsx
|
|
2824
|
-
var
|
|
2825
|
-
var
|
|
2826
|
-
var PaymentFormContext = (0,
|
|
2856
|
+
var import_react16 = require("react");
|
|
2857
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
2858
|
+
var PaymentFormContext = (0, import_react16.createContext)(null);
|
|
2827
2859
|
function usePaymentForm() {
|
|
2828
|
-
const ctx = (0,
|
|
2860
|
+
const ctx = (0, import_react16.useContext)(PaymentFormContext);
|
|
2829
2861
|
if (!ctx) {
|
|
2830
2862
|
throw new Error(
|
|
2831
2863
|
"PaymentForm subcomponents must be used inside a <PaymentForm>. Wrap the slots with <PaymentForm planRef=... productRef=...>."
|
|
@@ -2833,10 +2865,10 @@ function usePaymentForm() {
|
|
|
2833
2865
|
}
|
|
2834
2866
|
return ctx;
|
|
2835
2867
|
}
|
|
2836
|
-
var PaymentFormProvider = ({ value, children }) => /* @__PURE__ */ (0,
|
|
2868
|
+
var PaymentFormProvider = ({ value, children }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PaymentFormContext.Provider, { value, children });
|
|
2837
2869
|
|
|
2838
2870
|
// src/components/CheckoutSummary.tsx
|
|
2839
|
-
var
|
|
2871
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
2840
2872
|
var CheckoutSummary2 = ({
|
|
2841
2873
|
planRef,
|
|
2842
2874
|
productRef,
|
|
@@ -2848,7 +2880,7 @@ var CheckoutSummary2 = ({
|
|
|
2848
2880
|
}) => {
|
|
2849
2881
|
const rootClass = ["solvapay-checkout-summary", className].filter(Boolean).join(" ");
|
|
2850
2882
|
const hasTax = taxBreakdown != null;
|
|
2851
|
-
return /* @__PURE__ */ (0,
|
|
2883
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
2852
2884
|
CheckoutSummary.Root,
|
|
2853
2885
|
{
|
|
2854
2886
|
planRef,
|
|
@@ -2857,25 +2889,25 @@ var CheckoutSummary2 = ({
|
|
|
2857
2889
|
baseAmountMinor,
|
|
2858
2890
|
className: rootClass,
|
|
2859
2891
|
children: [
|
|
2860
|
-
/* @__PURE__ */ (0,
|
|
2861
|
-
/* @__PURE__ */ (0,
|
|
2862
|
-
/* @__PURE__ */ (0,
|
|
2863
|
-
!hasTax && /* @__PURE__ */ (0,
|
|
2892
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CheckoutSummary.Product, { className: "solvapay-checkout-summary-product" }),
|
|
2893
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "solvapay-checkout-summary-row", children: [
|
|
2894
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CheckoutSummary.Plan, { className: "solvapay-checkout-summary-plan" }),
|
|
2895
|
+
!hasTax && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CheckoutSummary.Price, { className: "solvapay-checkout-summary-price" })
|
|
2864
2896
|
] }),
|
|
2865
|
-
hasTax ? /* @__PURE__ */ (0,
|
|
2866
|
-
/* @__PURE__ */ (0,
|
|
2867
|
-
/* @__PURE__ */ (0,
|
|
2868
|
-
/* @__PURE__ */ (0,
|
|
2897
|
+
hasTax ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
2898
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "solvapay-checkout-summary-row", children: [
|
|
2899
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { children: "Subtotal" }),
|
|
2900
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CheckoutSummary.Subtotal, { className: "solvapay-checkout-summary-subtotal" })
|
|
2869
2901
|
] }),
|
|
2870
|
-
/* @__PURE__ */ (0,
|
|
2871
|
-
/* @__PURE__ */ (0,
|
|
2872
|
-
/* @__PURE__ */ (0,
|
|
2873
|
-
/* @__PURE__ */ (0,
|
|
2902
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "solvapay-checkout-summary-row", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CheckoutSummary.Tax, { className: "solvapay-checkout-summary-tax" }) }),
|
|
2903
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "solvapay-checkout-summary-row", children: [
|
|
2904
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { children: "Total" }),
|
|
2905
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CheckoutSummary.Total, { className: "solvapay-checkout-summary-total" })
|
|
2874
2906
|
] }),
|
|
2875
|
-
/* @__PURE__ */ (0,
|
|
2876
|
-
] }) : /* @__PURE__ */ (0,
|
|
2877
|
-
showTrial && /* @__PURE__ */ (0,
|
|
2878
|
-
showTaxNote && /* @__PURE__ */ (0,
|
|
2907
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CheckoutSummary.TaxTreatmentNote, { className: "solvapay-checkout-summary-tax-treatment-note" })
|
|
2908
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
2909
|
+
showTrial && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CheckoutSummary.Trial, { className: "solvapay-checkout-summary-trial" }),
|
|
2910
|
+
showTaxNote && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CheckoutSummary.TaxNote, { className: "solvapay-checkout-summary-tax-note" })
|
|
2879
2911
|
] })
|
|
2880
2912
|
]
|
|
2881
2913
|
}
|
|
@@ -2883,10 +2915,10 @@ var CheckoutSummary2 = ({
|
|
|
2883
2915
|
};
|
|
2884
2916
|
|
|
2885
2917
|
// src/primitives/MandateText.tsx
|
|
2886
|
-
var
|
|
2918
|
+
var import_react18 = require("react");
|
|
2887
2919
|
|
|
2888
2920
|
// src/hooks/useMerchant.ts
|
|
2889
|
-
var
|
|
2921
|
+
var import_react17 = require("react");
|
|
2890
2922
|
var merchantCache = /* @__PURE__ */ new Map();
|
|
2891
2923
|
var CACHE_DURATION5 = 5 * 60 * 1e3;
|
|
2892
2924
|
function cacheKeyFor2(config) {
|
|
@@ -2900,15 +2932,15 @@ async function fetchMerchant(config) {
|
|
|
2900
2932
|
function useMerchant() {
|
|
2901
2933
|
const { _config } = useSolvaPay();
|
|
2902
2934
|
const key = cacheKeyFor2(_config);
|
|
2903
|
-
const [merchant, setMerchant] = (0,
|
|
2935
|
+
const [merchant, setMerchant] = (0, import_react17.useState)(
|
|
2904
2936
|
() => merchantCache.get(key)?.merchant ?? null
|
|
2905
2937
|
);
|
|
2906
|
-
const [loading, setLoading] = (0,
|
|
2938
|
+
const [loading, setLoading] = (0, import_react17.useState)(() => {
|
|
2907
2939
|
const cached = merchantCache.get(key);
|
|
2908
2940
|
return !cached || !cached.merchant && !cached.promise;
|
|
2909
2941
|
});
|
|
2910
|
-
const [error, setError] = (0,
|
|
2911
|
-
const load = (0,
|
|
2942
|
+
const [error, setError] = (0, import_react17.useState)(null);
|
|
2943
|
+
const load = (0, import_react17.useCallback)(
|
|
2912
2944
|
async (force = false) => {
|
|
2913
2945
|
const cached = merchantCache.get(key);
|
|
2914
2946
|
const now = Date.now();
|
|
@@ -2962,7 +2994,7 @@ function useMerchant() {
|
|
|
2962
2994
|
},
|
|
2963
2995
|
[_config, key]
|
|
2964
2996
|
);
|
|
2965
|
-
(0,
|
|
2997
|
+
(0, import_react17.useEffect)(() => {
|
|
2966
2998
|
load();
|
|
2967
2999
|
}, [load]);
|
|
2968
3000
|
return {
|
|
@@ -2991,8 +3023,8 @@ function deriveVariant(plan, mode) {
|
|
|
2991
3023
|
}
|
|
2992
3024
|
|
|
2993
3025
|
// src/primitives/MandateText.tsx
|
|
2994
|
-
var
|
|
2995
|
-
var MandateText = (0,
|
|
3026
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
3027
|
+
var MandateText = (0, import_react18.forwardRef)(
|
|
2996
3028
|
function MandateText2({
|
|
2997
3029
|
planRef,
|
|
2998
3030
|
productRef,
|
|
@@ -3004,10 +3036,11 @@ var MandateText = (0, import_react17.forwardRef)(
|
|
|
3004
3036
|
children,
|
|
3005
3037
|
...rest
|
|
3006
3038
|
}, forwardedRef) {
|
|
3007
|
-
const solva = (0,
|
|
3039
|
+
const solva = (0, import_react18.useContext)(SolvaPayContext);
|
|
3008
3040
|
if (!solva) throw new MissingProviderError("MandateText");
|
|
3009
3041
|
const locale = useLocale();
|
|
3010
3042
|
const copy = useCopy();
|
|
3043
|
+
const handleExternalClick = useExternalLinkClick();
|
|
3011
3044
|
const planSelection = usePlanSelection();
|
|
3012
3045
|
const resolvedPlanRef = planRef ?? planSelection?.selectedPlanRef ?? void 0;
|
|
3013
3046
|
const resolvedProductRef = productRef ?? planSelection?.productRef;
|
|
@@ -3021,7 +3054,7 @@ var MandateText = (0, import_react17.forwardRef)(
|
|
|
3021
3054
|
locale,
|
|
3022
3055
|
free: copy.interval.free
|
|
3023
3056
|
});
|
|
3024
|
-
const ctx = (0,
|
|
3057
|
+
const ctx = (0, import_react18.useMemo)(
|
|
3025
3058
|
() => ({
|
|
3026
3059
|
merchant: {
|
|
3027
3060
|
legalName: merchant?.legalName ?? merchant?.displayName ?? "",
|
|
@@ -3048,19 +3081,19 @@ var MandateText = (0, import_react17.forwardRef)(
|
|
|
3048
3081
|
const text = typeof template === "function" ? template(ctx) : template;
|
|
3049
3082
|
if (!text) return null;
|
|
3050
3083
|
const Comp = asChild ? Slot : "p";
|
|
3051
|
-
return /* @__PURE__ */ (0,
|
|
3084
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3052
3085
|
Comp,
|
|
3053
3086
|
{
|
|
3054
3087
|
ref: forwardedRef,
|
|
3055
3088
|
"data-solvapay-mandate-text": "",
|
|
3056
3089
|
"data-variant": resolvedVariant,
|
|
3057
3090
|
...rest,
|
|
3058
|
-
children: children ?? linkifyMandateText(text, ctx.merchant, copy)
|
|
3091
|
+
children: children ?? linkifyMandateText(text, ctx.merchant, copy, handleExternalClick)
|
|
3059
3092
|
}
|
|
3060
3093
|
);
|
|
3061
3094
|
}
|
|
3062
3095
|
);
|
|
3063
|
-
function linkifyMandateText(text, merchant, copy) {
|
|
3096
|
+
function linkifyMandateText(text, merchant, copy, onLinkClick) {
|
|
3064
3097
|
const entries = [
|
|
3065
3098
|
{ url: merchant.termsUrl, label: copy.legalFooter.terms },
|
|
3066
3099
|
{ url: merchant.privacyUrl, label: copy.legalFooter.privacy }
|
|
@@ -3070,13 +3103,14 @@ function linkifyMandateText(text, merchant, copy) {
|
|
|
3070
3103
|
return text.split(pattern).map((part, i) => {
|
|
3071
3104
|
const match = entries.find((e) => e.url === part);
|
|
3072
3105
|
if (!match) return part;
|
|
3073
|
-
return /* @__PURE__ */ (0,
|
|
3106
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3074
3107
|
"a",
|
|
3075
3108
|
{
|
|
3076
3109
|
href: match.url,
|
|
3077
3110
|
target: "_blank",
|
|
3078
3111
|
rel: "noopener noreferrer",
|
|
3079
3112
|
"data-solvapay-mandate-link": "",
|
|
3113
|
+
onClick: onLinkClick,
|
|
3080
3114
|
children: match.label || match.url
|
|
3081
3115
|
},
|
|
3082
3116
|
i
|
|
@@ -3088,11 +3122,11 @@ function escapeRegExp(value) {
|
|
|
3088
3122
|
}
|
|
3089
3123
|
|
|
3090
3124
|
// src/components/Spinner.tsx
|
|
3091
|
-
var
|
|
3125
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
3092
3126
|
var SIZE_PX = { sm: 16, md: 20, lg: 24 };
|
|
3093
3127
|
var Spinner = ({ className, size = "md" }) => {
|
|
3094
3128
|
const px = SIZE_PX[size];
|
|
3095
|
-
return /* @__PURE__ */ (0,
|
|
3129
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
3096
3130
|
"svg",
|
|
3097
3131
|
{
|
|
3098
3132
|
"data-solvapay-spinner": "",
|
|
@@ -3103,7 +3137,7 @@ var Spinner = ({ className, size = "md" }) => {
|
|
|
3103
3137
|
fill: "none",
|
|
3104
3138
|
"aria-hidden": "true",
|
|
3105
3139
|
children: [
|
|
3106
|
-
/* @__PURE__ */ (0,
|
|
3140
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
3107
3141
|
"circle",
|
|
3108
3142
|
{
|
|
3109
3143
|
cx: "12",
|
|
@@ -3114,7 +3148,7 @@ var Spinner = ({ className, size = "md" }) => {
|
|
|
3114
3148
|
strokeOpacity: "0.25"
|
|
3115
3149
|
}
|
|
3116
3150
|
),
|
|
3117
|
-
/* @__PURE__ */ (0,
|
|
3151
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
3118
3152
|
"path",
|
|
3119
3153
|
{
|
|
3120
3154
|
fill: "currentColor",
|
|
@@ -3325,7 +3359,7 @@ function resolveCta(input) {
|
|
|
3325
3359
|
}
|
|
3326
3360
|
|
|
3327
3361
|
// src/hooks/useBusinessDetailsAttach.ts
|
|
3328
|
-
var
|
|
3362
|
+
var import_react19 = require("react");
|
|
3329
3363
|
var import_core3 = require("@solvapay/core");
|
|
3330
3364
|
var defaultBusinessDetails = { isBusiness: false };
|
|
3331
3365
|
function useBusinessDetailsAttach(options) {
|
|
@@ -3336,14 +3370,14 @@ function useBusinessDetailsAttach(options) {
|
|
|
3336
3370
|
onTaxChange,
|
|
3337
3371
|
refreshElements
|
|
3338
3372
|
} = options;
|
|
3339
|
-
const [businessDetails, setBusinessDetailsState] = (0,
|
|
3340
|
-
const [taxBreakdown, setTaxBreakdown] = (0,
|
|
3341
|
-
const [businessDetailsAttached, setBusinessDetailsAttached] = (0,
|
|
3342
|
-
const [businessDetailsAttaching, setBusinessDetailsAttaching] = (0,
|
|
3343
|
-
const [businessDetailsError, setBusinessDetailsError] = (0,
|
|
3344
|
-
const [fieldErrors, setFieldErrors] = (0,
|
|
3345
|
-
const attachRequestIdRef = (0,
|
|
3346
|
-
const setBusinessDetails = (0,
|
|
3373
|
+
const [businessDetails, setBusinessDetailsState] = (0, import_react19.useState)(defaultBusinessDetails);
|
|
3374
|
+
const [taxBreakdown, setTaxBreakdown] = (0, import_react19.useState)(null);
|
|
3375
|
+
const [businessDetailsAttached, setBusinessDetailsAttached] = (0, import_react19.useState)(false);
|
|
3376
|
+
const [businessDetailsAttaching, setBusinessDetailsAttaching] = (0, import_react19.useState)(false);
|
|
3377
|
+
const [businessDetailsError, setBusinessDetailsError] = (0, import_react19.useState)(null);
|
|
3378
|
+
const [fieldErrors, setFieldErrors] = (0, import_react19.useState)({});
|
|
3379
|
+
const attachRequestIdRef = (0, import_react19.useRef)(0);
|
|
3380
|
+
const setBusinessDetails = (0, import_react19.useCallback)((patch) => {
|
|
3347
3381
|
setBusinessDetailsState((prev) => {
|
|
3348
3382
|
const next = { ...prev, ...patch };
|
|
3349
3383
|
if (patch.isBusiness === false) {
|
|
@@ -3354,7 +3388,7 @@ function useBusinessDetailsAttach(options) {
|
|
|
3354
3388
|
setBusinessDetailsAttached(false);
|
|
3355
3389
|
setBusinessDetailsError(null);
|
|
3356
3390
|
}, []);
|
|
3357
|
-
const runAttach = (0,
|
|
3391
|
+
const runAttach = (0, import_react19.useCallback)(
|
|
3358
3392
|
async (input) => {
|
|
3359
3393
|
if (!processorPaymentId || !attachBusinessDetails) {
|
|
3360
3394
|
return !attachBusinessDetails;
|
|
@@ -3396,7 +3430,7 @@ function useBusinessDetailsAttach(options) {
|
|
|
3396
3430
|
},
|
|
3397
3431
|
[processorPaymentId, attachBusinessDetails, customerRef, onTaxChange, refreshElements]
|
|
3398
3432
|
);
|
|
3399
|
-
(0,
|
|
3433
|
+
(0, import_react19.useEffect)(() => {
|
|
3400
3434
|
if (!processorPaymentId || !attachBusinessDetails) return;
|
|
3401
3435
|
const validation = (0, import_core3.validateBusinessDetails)(businessDetails);
|
|
3402
3436
|
if (!validation.success) {
|
|
@@ -3425,7 +3459,7 @@ function useBusinessDetailsAttach(options) {
|
|
|
3425
3459
|
}
|
|
3426
3460
|
|
|
3427
3461
|
// src/primitives/PaymentForm.tsx
|
|
3428
|
-
var
|
|
3462
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
3429
3463
|
function toSubmitVariant(variant) {
|
|
3430
3464
|
switch (variant) {
|
|
3431
3465
|
case "freeTier":
|
|
@@ -3438,7 +3472,7 @@ function toSubmitVariant(variant) {
|
|
|
3438
3472
|
return "paid";
|
|
3439
3473
|
}
|
|
3440
3474
|
}
|
|
3441
|
-
var Root3 = (0,
|
|
3475
|
+
var Root3 = (0, import_react20.forwardRef)(
|
|
3442
3476
|
function PaymentFormRoot(props, forwardedRef) {
|
|
3443
3477
|
const {
|
|
3444
3478
|
planRef,
|
|
@@ -3455,7 +3489,7 @@ var Root3 = (0, import_react19.forwardRef)(
|
|
|
3455
3489
|
requireTermsAcceptance = false,
|
|
3456
3490
|
children
|
|
3457
3491
|
} = props;
|
|
3458
|
-
const solva = (0,
|
|
3492
|
+
const solva = (0, import_react20.useContext)(SolvaPayContext);
|
|
3459
3493
|
if (!solva) throw new MissingProviderError("PaymentForm");
|
|
3460
3494
|
const { attachBusinessDetails, customerRef } = solva;
|
|
3461
3495
|
const copy = useCopy();
|
|
@@ -3481,9 +3515,9 @@ var Root3 = (0, import_react19.forwardRef)(
|
|
|
3481
3515
|
productRef: effectiveProductRef,
|
|
3482
3516
|
customer: prefillCustomer
|
|
3483
3517
|
});
|
|
3484
|
-
const hasInitializedRef = (0,
|
|
3518
|
+
const hasInitializedRef = (0, import_react20.useRef)(false);
|
|
3485
3519
|
const hasPlanOrProduct = !!(effectivePlanRef || effectiveProductRef);
|
|
3486
|
-
(0,
|
|
3520
|
+
(0, import_react20.useEffect)(() => {
|
|
3487
3521
|
if (isFreePlan) return;
|
|
3488
3522
|
if (!hasInitializedRef.current && hasPlanOrProduct && !checkoutLoading && !checkoutError && !clientSecret) {
|
|
3489
3523
|
hasInitializedRef.current = true;
|
|
@@ -3497,32 +3531,32 @@ var Root3 = (0, import_react19.forwardRef)(
|
|
|
3497
3531
|
}
|
|
3498
3532
|
}, [hasPlanOrProduct, checkoutLoading, checkoutError, clientSecret, startCheckout, isFreePlan]);
|
|
3499
3533
|
const finalReturnUrl = returnUrl || (typeof window !== "undefined" ? window.location.href : "/");
|
|
3500
|
-
const elementsOptions = (0,
|
|
3534
|
+
const elementsOptions = (0, import_react20.useMemo)(() => {
|
|
3501
3535
|
if (!clientSecret) return void 0;
|
|
3502
3536
|
return { clientSecret, locale: toStripeElementLocale(locale) };
|
|
3503
3537
|
}, [clientSecret, locale]);
|
|
3504
3538
|
const shouldRenderElements = !!(stripePromise && clientSecret);
|
|
3505
3539
|
if (!hasPlanOrProduct) {
|
|
3506
|
-
return /* @__PURE__ */ (0,
|
|
3540
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3507
3541
|
"section",
|
|
3508
3542
|
{
|
|
3509
3543
|
ref: forwardedRef,
|
|
3510
3544
|
className,
|
|
3511
3545
|
"data-solvapay-payment-form": "",
|
|
3512
3546
|
"data-state": "error",
|
|
3513
|
-
children: /* @__PURE__ */ (0,
|
|
3547
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { role: "alert", "data-solvapay-payment-form-error": "", children: copy.errors.configMissingPlanOrProduct })
|
|
3514
3548
|
}
|
|
3515
3549
|
);
|
|
3516
3550
|
}
|
|
3517
3551
|
if (checkoutError) {
|
|
3518
|
-
return /* @__PURE__ */ (0,
|
|
3552
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3519
3553
|
"section",
|
|
3520
3554
|
{
|
|
3521
3555
|
ref: forwardedRef,
|
|
3522
3556
|
className,
|
|
3523
3557
|
"data-solvapay-payment-form": "",
|
|
3524
3558
|
"data-state": "error",
|
|
3525
|
-
children: /* @__PURE__ */ (0,
|
|
3559
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("p", { role: "alert", "data-solvapay-payment-form-error": "", children: [
|
|
3526
3560
|
copy.errors.paymentInitFailed,
|
|
3527
3561
|
" ",
|
|
3528
3562
|
checkoutError.message || copy.errors.unknownError
|
|
@@ -3531,7 +3565,7 @@ var Root3 = (0, import_react19.forwardRef)(
|
|
|
3531
3565
|
);
|
|
3532
3566
|
}
|
|
3533
3567
|
if (isFreePlan && resolvedPlan) {
|
|
3534
|
-
return /* @__PURE__ */ (0,
|
|
3568
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3535
3569
|
"section",
|
|
3536
3570
|
{
|
|
3537
3571
|
ref: forwardedRef,
|
|
@@ -3539,7 +3573,7 @@ var Root3 = (0, import_react19.forwardRef)(
|
|
|
3539
3573
|
"data-solvapay-payment-form": "",
|
|
3540
3574
|
"data-state": "ready",
|
|
3541
3575
|
"data-variant": "free",
|
|
3542
|
-
children: /* @__PURE__ */ (0,
|
|
3576
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3543
3577
|
FreeInner,
|
|
3544
3578
|
{
|
|
3545
3579
|
planRef: effectivePlanRef,
|
|
@@ -3560,7 +3594,7 @@ var Root3 = (0, import_react19.forwardRef)(
|
|
|
3560
3594
|
}
|
|
3561
3595
|
if (shouldRenderElements && elementsOptions && clientSecret) {
|
|
3562
3596
|
const resolvedClientSecret = clientSecret;
|
|
3563
|
-
return /* @__PURE__ */ (0,
|
|
3597
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3564
3598
|
"section",
|
|
3565
3599
|
{
|
|
3566
3600
|
ref: forwardedRef,
|
|
@@ -3568,7 +3602,7 @@ var Root3 = (0, import_react19.forwardRef)(
|
|
|
3568
3602
|
"data-solvapay-payment-form": "",
|
|
3569
3603
|
"data-state": "ready",
|
|
3570
3604
|
"data-variant": "paid",
|
|
3571
|
-
children: /* @__PURE__ */ (0,
|
|
3605
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_stripe_js.Elements, { stripe: stripePromise, options: elementsOptions, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3572
3606
|
PaidInner,
|
|
3573
3607
|
{
|
|
3574
3608
|
planRef: effectivePlanRef,
|
|
@@ -3594,14 +3628,14 @@ var Root3 = (0, import_react19.forwardRef)(
|
|
|
3594
3628
|
}
|
|
3595
3629
|
);
|
|
3596
3630
|
}
|
|
3597
|
-
return /* @__PURE__ */ (0,
|
|
3631
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3598
3632
|
"section",
|
|
3599
3633
|
{
|
|
3600
3634
|
ref: forwardedRef,
|
|
3601
3635
|
className,
|
|
3602
3636
|
"data-solvapay-payment-form": "",
|
|
3603
3637
|
"data-state": "loading",
|
|
3604
|
-
children: /* @__PURE__ */ (0,
|
|
3638
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("output", { "data-solvapay-payment-form-loading": "", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Spinner, { size: "md" }) })
|
|
3605
3639
|
}
|
|
3606
3640
|
);
|
|
3607
3641
|
}
|
|
@@ -3632,7 +3666,7 @@ var PaidInner = ({
|
|
|
3632
3666
|
const customer = useCustomer();
|
|
3633
3667
|
const { processPayment, upsertPurchase } = useSolvaPay();
|
|
3634
3668
|
const { refetch } = usePurchase();
|
|
3635
|
-
const refreshElements = (0,
|
|
3669
|
+
const refreshElements = (0, import_react20.useCallback)(async () => {
|
|
3636
3670
|
if (elements) {
|
|
3637
3671
|
await elements.fetchUpdates();
|
|
3638
3672
|
}
|
|
@@ -3654,16 +3688,16 @@ var PaidInner = ({
|
|
|
3654
3688
|
onTaxChange,
|
|
3655
3689
|
refreshElements
|
|
3656
3690
|
});
|
|
3657
|
-
const [elementKind, setElementKind] = (0,
|
|
3691
|
+
const [elementKind, setElementKind] = (0, import_react20.useState)(
|
|
3658
3692
|
children ? null : "payment-element"
|
|
3659
3693
|
);
|
|
3660
|
-
const [customerName, setCustomerName] = (0,
|
|
3661
|
-
const [paymentInputComplete, setPaymentInputComplete] = (0,
|
|
3662
|
-
const [termsAccepted, setTermsAccepted] = (0,
|
|
3663
|
-
const [isProcessing, setIsProcessing] = (0,
|
|
3664
|
-
const [error, setError] = (0,
|
|
3665
|
-
const returnResumeStarted = (0,
|
|
3666
|
-
(0,
|
|
3694
|
+
const [customerName, setCustomerName] = (0, import_react20.useState)("");
|
|
3695
|
+
const [paymentInputComplete, setPaymentInputComplete] = (0, import_react20.useState)(false);
|
|
3696
|
+
const [termsAccepted, setTermsAccepted] = (0, import_react20.useState)(false);
|
|
3697
|
+
const [isProcessing, setIsProcessing] = (0, import_react20.useState)(false);
|
|
3698
|
+
const [error, setError] = (0, import_react20.useState)(null);
|
|
3699
|
+
const returnResumeStarted = (0, import_react20.useRef)(false);
|
|
3700
|
+
(0, import_react20.useEffect)(() => {
|
|
3667
3701
|
if (!stripe || returnResumeStarted.current || typeof window === "undefined") return;
|
|
3668
3702
|
const returnClientSecret = readPaymentIntentClientSecret(window.location.search);
|
|
3669
3703
|
if (!returnClientSecret) return;
|
|
@@ -3751,7 +3785,7 @@ var PaidInner = ({
|
|
|
3751
3785
|
]);
|
|
3752
3786
|
const isReady = !!(stripe && elements);
|
|
3753
3787
|
const canSubmit = isReady && !!clientSecret && !!elementKind && paymentInputComplete && (!requireTermsAcceptance || termsAccepted) && (!requiresBusinessAttach || businessDetailsAttached) && !businessDetailsAttaching && !isProcessing;
|
|
3754
|
-
const submit = (0,
|
|
3788
|
+
const submit = (0, import_react20.useCallback)(async () => {
|
|
3755
3789
|
if (!stripe || !elements || !clientSecret || !elementKind) {
|
|
3756
3790
|
const msg = !stripe || !elements ? copy.errors.stripeUnavailable : copy.errors.paymentIntentUnavailable;
|
|
3757
3791
|
setError(msg);
|
|
@@ -3855,7 +3889,7 @@ var PaidInner = ({
|
|
|
3855
3889
|
businessDetailsError
|
|
3856
3890
|
]);
|
|
3857
3891
|
const effectiveError = error ?? businessDetailsError;
|
|
3858
|
-
const contextValue = (0,
|
|
3892
|
+
const contextValue = (0, import_react20.useMemo)(
|
|
3859
3893
|
() => ({
|
|
3860
3894
|
planRef,
|
|
3861
3895
|
productRef,
|
|
@@ -3924,7 +3958,7 @@ var PaidInner = ({
|
|
|
3924
3958
|
submit
|
|
3925
3959
|
]
|
|
3926
3960
|
);
|
|
3927
|
-
return /* @__PURE__ */ (0,
|
|
3961
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(PaymentFormProvider, { value: contextValue, children });
|
|
3928
3962
|
};
|
|
3929
3963
|
var FreeInner = ({
|
|
3930
3964
|
planRef,
|
|
@@ -3942,10 +3976,10 @@ var FreeInner = ({
|
|
|
3942
3976
|
const copy = useCopy();
|
|
3943
3977
|
const { refetch } = usePurchase();
|
|
3944
3978
|
const { activate, state, error: activationError, result: activationResult } = useActivation();
|
|
3945
|
-
const [termsAccepted, setTermsAccepted] = (0,
|
|
3946
|
-
const [localError, setLocalError] = (0,
|
|
3947
|
-
const resultFiredRef = (0,
|
|
3948
|
-
(0,
|
|
3979
|
+
const [termsAccepted, setTermsAccepted] = (0, import_react20.useState)(false);
|
|
3980
|
+
const [localError, setLocalError] = (0, import_react20.useState)(void 0);
|
|
3981
|
+
const resultFiredRef = (0, import_react20.useRef)(false);
|
|
3982
|
+
(0, import_react20.useEffect)(() => {
|
|
3949
3983
|
if (state === "activated" && activationResult && !resultFiredRef.current) {
|
|
3950
3984
|
resultFiredRef.current = true;
|
|
3951
3985
|
const res = { kind: "activated", result: activationResult };
|
|
@@ -3957,7 +3991,7 @@ var FreeInner = ({
|
|
|
3957
3991
|
}, [state, activationResult, onResult, refetch]);
|
|
3958
3992
|
const isProcessing = state === "activating";
|
|
3959
3993
|
const canSubmit = !isProcessing && (!requireTermsAcceptance || termsAccepted) && !!productRef;
|
|
3960
|
-
const submit = (0,
|
|
3994
|
+
const submit = (0, import_react20.useCallback)(async () => {
|
|
3961
3995
|
if (!productRef) {
|
|
3962
3996
|
const msg = copy.errors.configMissingPlanOrProduct;
|
|
3963
3997
|
setLocalError(msg);
|
|
@@ -3981,7 +4015,7 @@ var FreeInner = ({
|
|
|
3981
4015
|
}
|
|
3982
4016
|
}, [productRef, plan, onFreePlan, activate, onResult, onError, copy]);
|
|
3983
4017
|
const error = localError ?? activationError;
|
|
3984
|
-
const contextValue = (0,
|
|
4018
|
+
const contextValue = (0, import_react20.useMemo)(
|
|
3985
4019
|
() => ({
|
|
3986
4020
|
planRef,
|
|
3987
4021
|
productRef,
|
|
@@ -4036,11 +4070,11 @@ var FreeInner = ({
|
|
|
4036
4070
|
submit
|
|
4037
4071
|
]
|
|
4038
4072
|
);
|
|
4039
|
-
return /* @__PURE__ */ (0,
|
|
4073
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(PaymentFormProvider, { value: contextValue, children });
|
|
4040
4074
|
};
|
|
4041
4075
|
var Summary = (props) => {
|
|
4042
4076
|
const ctx = usePaymentForm();
|
|
4043
|
-
return /* @__PURE__ */ (0,
|
|
4077
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
4044
4078
|
CheckoutSummary2,
|
|
4045
4079
|
{
|
|
4046
4080
|
...props,
|
|
@@ -4053,7 +4087,7 @@ var Summary = (props) => {
|
|
|
4053
4087
|
};
|
|
4054
4088
|
var MandateTextPrimitive = (props) => {
|
|
4055
4089
|
const ctx = usePaymentForm();
|
|
4056
|
-
return /* @__PURE__ */ (0,
|
|
4090
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
4057
4091
|
MandateText,
|
|
4058
4092
|
{
|
|
4059
4093
|
...props,
|
|
@@ -4062,7 +4096,7 @@ var MandateTextPrimitive = (props) => {
|
|
|
4062
4096
|
}
|
|
4063
4097
|
);
|
|
4064
4098
|
};
|
|
4065
|
-
var CustomerFields = (0,
|
|
4099
|
+
var CustomerFields = (0, import_react20.forwardRef)(
|
|
4066
4100
|
function PaymentFormCustomerFields({ asChild, readOnly: _readOnly = true, children, ...rest }, ref) {
|
|
4067
4101
|
const copy = useCopy();
|
|
4068
4102
|
const customer = useCustomer();
|
|
@@ -4070,14 +4104,14 @@ var CustomerFields = (0, import_react19.forwardRef)(
|
|
|
4070
4104
|
const email = customer.email ?? prefillCustomer?.email;
|
|
4071
4105
|
if (!email) return null;
|
|
4072
4106
|
const Comp = asChild ? Slot : "section";
|
|
4073
|
-
return /* @__PURE__ */ (0,
|
|
4074
|
-
email && /* @__PURE__ */ (0,
|
|
4075
|
-
/* @__PURE__ */ (0,
|
|
4076
|
-
/* @__PURE__ */ (0,
|
|
4107
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Comp, { ref, "data-solvapay-payment-form-customer-fields": "", ...rest, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
4108
|
+
email && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("dl", { "data-solvapay-payment-form-customer-email": "", children: [
|
|
4109
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("dt", { children: copy.customer.emailLabel }),
|
|
4110
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("dd", { children: email })
|
|
4077
4111
|
] }),
|
|
4078
|
-
/* @__PURE__ */ (0,
|
|
4079
|
-
/* @__PURE__ */ (0,
|
|
4080
|
-
/* @__PURE__ */ (0,
|
|
4112
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("dl", { "data-solvapay-payment-form-customer-name": "", children: [
|
|
4113
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("dt", { children: copy.customer.nameLabel }),
|
|
4114
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("dd", { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
4081
4115
|
"input",
|
|
4082
4116
|
{
|
|
4083
4117
|
type: "text",
|
|
@@ -4100,14 +4134,14 @@ var CustomerFields = (0, import_react19.forwardRef)(
|
|
|
4100
4134
|
var PaymentElementSlot = ({ options }) => {
|
|
4101
4135
|
const { setElementKind, setPaymentInputComplete, isReady, stripe, elements } = usePaymentForm();
|
|
4102
4136
|
const locale = useLocale();
|
|
4103
|
-
(0,
|
|
4137
|
+
(0, import_react20.useEffect)(() => {
|
|
4104
4138
|
if (stripe && elements) setElementKind("payment-element");
|
|
4105
4139
|
}, [setElementKind, stripe, elements]);
|
|
4106
4140
|
if (!stripe || !elements) return null;
|
|
4107
4141
|
if (!isReady) {
|
|
4108
|
-
return /* @__PURE__ */ (0,
|
|
4142
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("output", { "data-solvapay-payment-form-loading": "", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Spinner, { size: "sm" }) });
|
|
4109
4143
|
}
|
|
4110
|
-
return /* @__PURE__ */ (0,
|
|
4144
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("section", { "data-solvapay-payment-form-payment-element": "", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
4111
4145
|
import_react_stripe_js.PaymentElement,
|
|
4112
4146
|
{
|
|
4113
4147
|
options: withPaymentElementDefaults(options),
|
|
@@ -4118,25 +4152,25 @@ var PaymentElementSlot = ({ options }) => {
|
|
|
4118
4152
|
};
|
|
4119
4153
|
var CardElementSlot = ({ options }) => {
|
|
4120
4154
|
const { setElementKind, setPaymentInputComplete, isReady, stripe, elements } = usePaymentForm();
|
|
4121
|
-
(0,
|
|
4155
|
+
(0, import_react20.useEffect)(() => {
|
|
4122
4156
|
if (stripe && elements) setElementKind("card-element");
|
|
4123
4157
|
}, [setElementKind, stripe, elements]);
|
|
4124
4158
|
if (!stripe || !elements) return null;
|
|
4125
4159
|
if (!isReady) {
|
|
4126
|
-
return /* @__PURE__ */ (0,
|
|
4160
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("output", { "data-solvapay-payment-form-loading": "", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Spinner, { size: "sm" }) });
|
|
4127
4161
|
}
|
|
4128
|
-
return /* @__PURE__ */ (0,
|
|
4162
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("section", { "data-solvapay-payment-form-card-element": "", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_stripe_js.CardElement, { options, onChange: (e) => setPaymentInputComplete(e.complete) }) });
|
|
4129
4163
|
};
|
|
4130
|
-
var TermsCheckbox = (0,
|
|
4164
|
+
var TermsCheckbox = (0, import_react20.forwardRef)(
|
|
4131
4165
|
function PaymentFormTermsCheckbox({ asChild, label, children, ...rest }, ref) {
|
|
4132
4166
|
const { termsAccepted, setTermsAccepted } = usePaymentForm();
|
|
4133
4167
|
const copy = useCopy();
|
|
4134
4168
|
const id = "solvapay-terms-checkbox";
|
|
4135
4169
|
if (asChild) {
|
|
4136
|
-
return /* @__PURE__ */ (0,
|
|
4170
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Slot, { ref, "data-solvapay-payment-form-terms": "", ...rest, children });
|
|
4137
4171
|
}
|
|
4138
|
-
return /* @__PURE__ */ (0,
|
|
4139
|
-
/* @__PURE__ */ (0,
|
|
4172
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { ref, htmlFor: id, "data-solvapay-payment-form-terms": "", ...rest, children: [
|
|
4173
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
4140
4174
|
"input",
|
|
4141
4175
|
{
|
|
4142
4176
|
id,
|
|
@@ -4145,11 +4179,11 @@ var TermsCheckbox = (0, import_react19.forwardRef)(
|
|
|
4145
4179
|
onChange: (e) => setTermsAccepted(e.target.checked)
|
|
4146
4180
|
}
|
|
4147
4181
|
),
|
|
4148
|
-
/* @__PURE__ */ (0,
|
|
4182
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: label ?? copy.terms.checkboxLabel })
|
|
4149
4183
|
] });
|
|
4150
4184
|
}
|
|
4151
4185
|
);
|
|
4152
|
-
var SubmitButton = (0,
|
|
4186
|
+
var SubmitButton = (0, import_react20.forwardRef)(
|
|
4153
4187
|
function PaymentFormSubmitButton({ asChild, onClick, children, ...rest }, ref) {
|
|
4154
4188
|
const ctx = usePaymentForm();
|
|
4155
4189
|
const copy = useCopy();
|
|
@@ -4178,9 +4212,9 @@ var SubmitButton = (0, import_react19.forwardRef)(
|
|
|
4178
4212
|
copy,
|
|
4179
4213
|
override: typeof children === "string" ? children : ctx.submitButtonText
|
|
4180
4214
|
});
|
|
4181
|
-
const processingContent = /* @__PURE__ */ (0,
|
|
4182
|
-
/* @__PURE__ */ (0,
|
|
4183
|
-
/* @__PURE__ */ (0,
|
|
4215
|
+
const processingContent = /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
4216
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Spinner, { size: "sm" }),
|
|
4217
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: copy.cta.processing })
|
|
4184
4218
|
] });
|
|
4185
4219
|
const buttonProps = {
|
|
4186
4220
|
"data-solvapay-payment-form-submit": "",
|
|
@@ -4198,30 +4232,30 @@ var SubmitButton = (0, import_react19.forwardRef)(
|
|
|
4198
4232
|
...rest
|
|
4199
4233
|
};
|
|
4200
4234
|
if (asChild) {
|
|
4201
|
-
const slotChild = ctx.isProcessing &&
|
|
4235
|
+
const slotChild = ctx.isProcessing && import_react20.default.isValidElement(children) ? import_react20.default.cloneElement(
|
|
4202
4236
|
children,
|
|
4203
4237
|
void 0,
|
|
4204
4238
|
processingContent
|
|
4205
4239
|
) : children;
|
|
4206
|
-
return /* @__PURE__ */ (0,
|
|
4240
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Slot, { ref, ...buttonProps, children: slotChild });
|
|
4207
4241
|
}
|
|
4208
4242
|
const content = ctx.isProcessing ? processingContent : children && typeof children !== "string" ? children : label;
|
|
4209
|
-
return /* @__PURE__ */ (0,
|
|
4243
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { ref, type: "submit", ...buttonProps, children: content });
|
|
4210
4244
|
}
|
|
4211
4245
|
);
|
|
4212
|
-
var Loading2 = (0,
|
|
4246
|
+
var Loading2 = (0, import_react20.forwardRef)(function PaymentFormLoading({ asChild, children, ...rest }, ref) {
|
|
4213
4247
|
const ctx = usePaymentForm();
|
|
4214
4248
|
if (ctx.isReady && ctx.clientSecret) return null;
|
|
4215
4249
|
if (asChild) {
|
|
4216
|
-
return /* @__PURE__ */ (0,
|
|
4250
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Slot, { ref, "data-solvapay-payment-form-loading": "", ...rest, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Spinner, { size: "sm" }) });
|
|
4217
4251
|
}
|
|
4218
|
-
return /* @__PURE__ */ (0,
|
|
4252
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("output", { ref, "data-solvapay-payment-form-loading": "", ...rest, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Spinner, { size: "sm" }) });
|
|
4219
4253
|
});
|
|
4220
|
-
var ErrorSlot2 = (0,
|
|
4254
|
+
var ErrorSlot2 = (0, import_react20.forwardRef)(function PaymentFormError({ asChild, children, ...rest }, ref) {
|
|
4221
4255
|
const ctx = usePaymentForm();
|
|
4222
4256
|
if (!ctx.error) return null;
|
|
4223
4257
|
if (asChild) {
|
|
4224
|
-
return /* @__PURE__ */ (0,
|
|
4258
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
4225
4259
|
Slot,
|
|
4226
4260
|
{
|
|
4227
4261
|
ref,
|
|
@@ -4234,7 +4268,7 @@ var ErrorSlot2 = (0, import_react19.forwardRef)(function PaymentFormError({ asCh
|
|
|
4234
4268
|
}
|
|
4235
4269
|
);
|
|
4236
4270
|
}
|
|
4237
|
-
return /* @__PURE__ */ (0,
|
|
4271
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
4238
4272
|
"p",
|
|
4239
4273
|
{
|
|
4240
4274
|
ref,
|
|
@@ -4297,13 +4331,13 @@ var PaymentForm = {
|
|
|
4297
4331
|
};
|
|
4298
4332
|
|
|
4299
4333
|
// src/primitives/ActivationFlow.tsx
|
|
4300
|
-
var
|
|
4334
|
+
var import_react24 = require("react");
|
|
4301
4335
|
|
|
4302
4336
|
// src/primitives/AmountPicker.tsx
|
|
4303
|
-
var
|
|
4337
|
+
var import_react23 = require("react");
|
|
4304
4338
|
|
|
4305
4339
|
// src/hooks/useTopupAmountSelector.ts
|
|
4306
|
-
var
|
|
4340
|
+
var import_react21 = require("react");
|
|
4307
4341
|
function getQuickAmounts(currency) {
|
|
4308
4342
|
switch (currency.toUpperCase()) {
|
|
4309
4343
|
case "SEK":
|
|
@@ -4335,19 +4369,19 @@ var DEFAULT_MAX = 1e5;
|
|
|
4335
4369
|
function useTopupAmountSelector(options) {
|
|
4336
4370
|
const { currency, minAmount = DEFAULT_MIN, maxAmount = DEFAULT_MAX } = options;
|
|
4337
4371
|
const copy = useCopy();
|
|
4338
|
-
const [selectedAmount, setSelectedAmount] = (0,
|
|
4339
|
-
const [customAmount, setCustomAmountRaw] = (0,
|
|
4340
|
-
const [error, setError] = (0,
|
|
4341
|
-
const quickAmounts = (0,
|
|
4342
|
-
const currencySymbol = (0,
|
|
4343
|
-
const resolvedAmount = (0,
|
|
4372
|
+
const [selectedAmount, setSelectedAmount] = (0, import_react21.useState)(null);
|
|
4373
|
+
const [customAmount, setCustomAmountRaw] = (0, import_react21.useState)("");
|
|
4374
|
+
const [error, setError] = (0, import_react21.useState)(null);
|
|
4375
|
+
const quickAmounts = (0, import_react21.useMemo)(() => getQuickAmounts(currency), [currency]);
|
|
4376
|
+
const currencySymbol = (0, import_react21.useMemo)(() => getCurrencySymbol(currency), [currency]);
|
|
4377
|
+
const resolvedAmount = (0, import_react21.useMemo)(() => {
|
|
4344
4378
|
if (customAmount) {
|
|
4345
4379
|
const parsed = parseFloat(customAmount);
|
|
4346
4380
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : null;
|
|
4347
4381
|
}
|
|
4348
4382
|
return selectedAmount;
|
|
4349
4383
|
}, [selectedAmount, customAmount]);
|
|
4350
|
-
const selectQuickAmount = (0,
|
|
4384
|
+
const selectQuickAmount = (0, import_react21.useCallback)(
|
|
4351
4385
|
(amount) => {
|
|
4352
4386
|
setSelectedAmount(amount);
|
|
4353
4387
|
setCustomAmountRaw("");
|
|
@@ -4355,7 +4389,7 @@ function useTopupAmountSelector(options) {
|
|
|
4355
4389
|
},
|
|
4356
4390
|
[]
|
|
4357
4391
|
);
|
|
4358
|
-
const setCustomAmount = (0,
|
|
4392
|
+
const setCustomAmount = (0, import_react21.useCallback)(
|
|
4359
4393
|
(value) => {
|
|
4360
4394
|
const sanitized = value.replace(/[^0-9.]/g, "");
|
|
4361
4395
|
const dotIndex = sanitized.indexOf(".");
|
|
@@ -4366,7 +4400,7 @@ function useTopupAmountSelector(options) {
|
|
|
4366
4400
|
},
|
|
4367
4401
|
[]
|
|
4368
4402
|
);
|
|
4369
|
-
const validate = (0,
|
|
4403
|
+
const validate = (0, import_react21.useCallback)(() => {
|
|
4370
4404
|
if (resolvedAmount == null) {
|
|
4371
4405
|
setError(copy.topup.selectOrEnterAmount);
|
|
4372
4406
|
return false;
|
|
@@ -4394,7 +4428,7 @@ function useTopupAmountSelector(options) {
|
|
|
4394
4428
|
setError(null);
|
|
4395
4429
|
return true;
|
|
4396
4430
|
}, [resolvedAmount, minAmount, maxAmount, currency, copy]);
|
|
4397
|
-
const reset = (0,
|
|
4431
|
+
const reset = (0, import_react21.useCallback)(() => {
|
|
4398
4432
|
setSelectedAmount(null);
|
|
4399
4433
|
setCustomAmountRaw("");
|
|
4400
4434
|
setError(null);
|
|
@@ -4414,26 +4448,26 @@ function useTopupAmountSelector(options) {
|
|
|
4414
4448
|
}
|
|
4415
4449
|
|
|
4416
4450
|
// src/hooks/useBalance.ts
|
|
4417
|
-
var
|
|
4451
|
+
var import_react22 = require("react");
|
|
4418
4452
|
function useBalance() {
|
|
4419
4453
|
const { balance } = useSolvaPay();
|
|
4420
|
-
(0,
|
|
4454
|
+
(0, import_react22.useEffect)(() => {
|
|
4421
4455
|
balance.refetch();
|
|
4422
4456
|
}, [balance.refetch]);
|
|
4423
4457
|
return balance;
|
|
4424
4458
|
}
|
|
4425
4459
|
|
|
4426
4460
|
// src/primitives/AmountPicker.tsx
|
|
4427
|
-
var
|
|
4428
|
-
var AmountPickerContext = (0,
|
|
4461
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
4462
|
+
var AmountPickerContext = (0, import_react23.createContext)(null);
|
|
4429
4463
|
function usePickerCtx(part) {
|
|
4430
|
-
const ctx = (0,
|
|
4464
|
+
const ctx = (0, import_react23.useContext)(AmountPickerContext);
|
|
4431
4465
|
if (!ctx) {
|
|
4432
4466
|
throw new Error(`AmountPicker.${part} must be rendered inside <AmountPicker.Root>.`);
|
|
4433
4467
|
}
|
|
4434
4468
|
return ctx;
|
|
4435
4469
|
}
|
|
4436
|
-
var Root4 = (0,
|
|
4470
|
+
var Root4 = (0, import_react23.forwardRef)(function AmountPickerRoot({
|
|
4437
4471
|
currency,
|
|
4438
4472
|
minAmount,
|
|
4439
4473
|
maxAmount,
|
|
@@ -4444,14 +4478,14 @@ var Root4 = (0, import_react22.forwardRef)(function AmountPickerRoot({
|
|
|
4444
4478
|
children,
|
|
4445
4479
|
...rest
|
|
4446
4480
|
}, forwardedRef) {
|
|
4447
|
-
const solva = (0,
|
|
4481
|
+
const solva = (0, import_react23.useContext)(SolvaPayContext);
|
|
4448
4482
|
if (!solva) throw new MissingProviderError("AmountPicker");
|
|
4449
4483
|
const internalSelector = useTopupAmountSelector({ currency, minAmount, maxAmount });
|
|
4450
4484
|
const selector = externalSelector ?? internalSelector;
|
|
4451
4485
|
const { creditsPerMinorUnit, displayExchangeRate } = useBalance();
|
|
4452
4486
|
const minorPerMajor = getMinorUnitsPerMajor(currency);
|
|
4453
4487
|
const resolvedAmountMinor = selector.resolvedAmount != null && selector.resolvedAmount > 0 ? Math.round(selector.resolvedAmount * minorPerMajor) : null;
|
|
4454
|
-
(0,
|
|
4488
|
+
(0, import_react23.useEffect)(() => {
|
|
4455
4489
|
if (emit === "minor") {
|
|
4456
4490
|
onChange?.(resolvedAmountMinor);
|
|
4457
4491
|
} else {
|
|
@@ -4461,7 +4495,7 @@ var Root4 = (0, import_react22.forwardRef)(function AmountPickerRoot({
|
|
|
4461
4495
|
const rate = displayExchangeRate ?? 1;
|
|
4462
4496
|
const estimatedCredits = creditsPerMinorUnit != null && creditsPerMinorUnit > 0 && resolvedAmountMinor != null ? Math.floor(resolvedAmountMinor / rate * creditsPerMinorUnit) : null;
|
|
4463
4497
|
const isApproximate = rate !== 1;
|
|
4464
|
-
const ctx = (0,
|
|
4498
|
+
const ctx = (0, import_react23.useMemo)(
|
|
4465
4499
|
() => ({
|
|
4466
4500
|
...selector,
|
|
4467
4501
|
currency,
|
|
@@ -4484,9 +4518,9 @@ var Root4 = (0, import_react22.forwardRef)(function AmountPickerRoot({
|
|
|
4484
4518
|
]
|
|
4485
4519
|
);
|
|
4486
4520
|
const Comp = asChild ? Slot : "div";
|
|
4487
|
-
return /* @__PURE__ */ (0,
|
|
4521
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(AmountPickerContext.Provider, { value: ctx, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Comp, { ref: forwardedRef, "data-solvapay-amount-picker": "", ...rest, children }) });
|
|
4488
4522
|
});
|
|
4489
|
-
var Option = (0,
|
|
4523
|
+
var Option = (0, import_react23.forwardRef)(function AmountPickerOption({ asChild, amount, onClick, children, ...rest }, forwardedRef) {
|
|
4490
4524
|
const ctx = usePickerCtx("Option");
|
|
4491
4525
|
const isActive = ctx.selectedAmount === amount && !ctx.customAmount;
|
|
4492
4526
|
const state = rest.disabled ? "disabled" : isActive ? "selected" : "idle";
|
|
@@ -4508,12 +4542,12 @@ var Option = (0, import_react22.forwardRef)(function AmountPickerOption({ asChil
|
|
|
4508
4542
|
if (asChild) {
|
|
4509
4543
|
return (
|
|
4510
4544
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4511
|
-
/* @__PURE__ */ (0,
|
|
4545
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Slot, { ref: forwardedRef, ...commonProps, children: children ?? defaultLabel })
|
|
4512
4546
|
);
|
|
4513
4547
|
}
|
|
4514
|
-
return /* @__PURE__ */ (0,
|
|
4548
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { ref: forwardedRef, type: "button", ...commonProps, children: children ?? defaultLabel });
|
|
4515
4549
|
});
|
|
4516
|
-
var Custom = (0,
|
|
4550
|
+
var Custom = (0, import_react23.forwardRef)(function AmountPickerCustom({ asChild, onChange, onFocus, ...rest }, forwardedRef) {
|
|
4517
4551
|
const ctx = usePickerCtx("Custom");
|
|
4518
4552
|
const state = ctx.customAmount ? "active" : "dormant";
|
|
4519
4553
|
const commonProps = {
|
|
@@ -4534,15 +4568,15 @@ var Custom = (0, import_react22.forwardRef)(function AmountPickerCustom({ asChil
|
|
|
4534
4568
|
if (asChild) {
|
|
4535
4569
|
return (
|
|
4536
4570
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4537
|
-
/* @__PURE__ */ (0,
|
|
4571
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Slot, { ref: forwardedRef, ...commonProps })
|
|
4538
4572
|
);
|
|
4539
4573
|
}
|
|
4540
|
-
return /* @__PURE__ */ (0,
|
|
4574
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("input", { ref: forwardedRef, ...commonProps });
|
|
4541
4575
|
});
|
|
4542
|
-
var Confirm = (0,
|
|
4576
|
+
var Confirm = (0, import_react23.forwardRef)(function AmountPickerConfirm({ asChild, onClick, onConfirm, disabled, children, ...rest }, forwardedRef) {
|
|
4543
4577
|
const ctx = usePickerCtx("Confirm");
|
|
4544
4578
|
const isDisabled = disabled || !ctx.resolvedAmount;
|
|
4545
|
-
const handleConfirm = (0,
|
|
4579
|
+
const handleConfirm = (0, import_react23.useCallback)(() => {
|
|
4546
4580
|
if (!ctx.validate()) return;
|
|
4547
4581
|
if (ctx.emit === "minor") {
|
|
4548
4582
|
if (ctx.resolvedAmountMinor != null) onConfirm?.(ctx.resolvedAmountMinor);
|
|
@@ -4561,10 +4595,10 @@ var Confirm = (0, import_react22.forwardRef)(function AmountPickerConfirm({ asCh
|
|
|
4561
4595
|
if (asChild) {
|
|
4562
4596
|
return (
|
|
4563
4597
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4564
|
-
/* @__PURE__ */ (0,
|
|
4598
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Slot, { ref: forwardedRef, ...commonProps, children })
|
|
4565
4599
|
);
|
|
4566
4600
|
}
|
|
4567
|
-
return /* @__PURE__ */ (0,
|
|
4601
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { ref: forwardedRef, type: "button", ...commonProps, children });
|
|
4568
4602
|
});
|
|
4569
4603
|
var AmountPickerRoot2 = Root4;
|
|
4570
4604
|
var AmountPickerOption2 = Option;
|
|
@@ -4593,16 +4627,16 @@ function useAmountPickerCopy() {
|
|
|
4593
4627
|
}
|
|
4594
4628
|
|
|
4595
4629
|
// src/primitives/ActivationFlow.tsx
|
|
4596
|
-
var
|
|
4597
|
-
var ActivationFlowContext = (0,
|
|
4630
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
4631
|
+
var ActivationFlowContext = (0, import_react24.createContext)(null);
|
|
4598
4632
|
function useFlowCtx(part) {
|
|
4599
|
-
const ctx = (0,
|
|
4633
|
+
const ctx = (0, import_react24.useContext)(ActivationFlowContext);
|
|
4600
4634
|
if (!ctx) {
|
|
4601
4635
|
throw new Error(`ActivationFlow.${part} must be rendered inside <ActivationFlow.Root>.`);
|
|
4602
4636
|
}
|
|
4603
4637
|
return ctx;
|
|
4604
4638
|
}
|
|
4605
|
-
var Root5 = (0,
|
|
4639
|
+
var Root5 = (0, import_react24.forwardRef)(function ActivationFlowRoot({
|
|
4606
4640
|
productRef,
|
|
4607
4641
|
planRef: planRefProp,
|
|
4608
4642
|
onSuccess,
|
|
@@ -4613,7 +4647,7 @@ var Root5 = (0, import_react23.forwardRef)(function ActivationFlowRoot({
|
|
|
4613
4647
|
children,
|
|
4614
4648
|
...rest
|
|
4615
4649
|
}, forwardedRef) {
|
|
4616
|
-
const solva = (0,
|
|
4650
|
+
const solva = (0, import_react24.useContext)(SolvaPayContext);
|
|
4617
4651
|
if (!solva) throw new MissingProviderError("ActivationFlow");
|
|
4618
4652
|
if (!productRef) throw new MissingProductRefError("ActivationFlow");
|
|
4619
4653
|
const planSelection = usePlanSelection();
|
|
@@ -4630,10 +4664,10 @@ var Root5 = (0, import_react23.forwardRef)(function ActivationFlowRoot({
|
|
|
4630
4664
|
refetch,
|
|
4631
4665
|
loading: balanceLoading
|
|
4632
4666
|
} = useBalance();
|
|
4633
|
-
const [step, setStep] = (0,
|
|
4634
|
-
const calledSuccessRef = (0,
|
|
4635
|
-
const retryTimeoutRef = (0,
|
|
4636
|
-
(0,
|
|
4667
|
+
const [step, setStep] = (0, import_react24.useState)("summary");
|
|
4668
|
+
const calledSuccessRef = (0, import_react24.useRef)(false);
|
|
4669
|
+
const retryTimeoutRef = (0, import_react24.useRef)(null);
|
|
4670
|
+
(0, import_react24.useEffect)(() => {
|
|
4637
4671
|
if (state !== "activated") return;
|
|
4638
4672
|
if (step === "selectAmount" || step === "topupPayment") return;
|
|
4639
4673
|
const isUsagePlan = plan?.type === "usage-based";
|
|
@@ -4653,30 +4687,30 @@ var Root5 = (0, import_react23.forwardRef)(function ActivationFlowRoot({
|
|
|
4653
4687
|
}
|
|
4654
4688
|
}
|
|
4655
4689
|
}, [state, result, onSuccess, credits, plan, balanceLoading, step]);
|
|
4656
|
-
(0,
|
|
4690
|
+
(0, import_react24.useEffect)(() => {
|
|
4657
4691
|
if (state === "topup_required" && (step === "summary" || step === "activating")) {
|
|
4658
4692
|
setStep("selectAmount");
|
|
4659
4693
|
}
|
|
4660
4694
|
}, [state, step]);
|
|
4661
|
-
(0,
|
|
4695
|
+
(0, import_react24.useEffect)(() => {
|
|
4662
4696
|
if ((state === "error" || state === "payment_required") && error) {
|
|
4663
4697
|
setStep("error");
|
|
4664
4698
|
if (state === "error") onError?.(new Error(error));
|
|
4665
4699
|
}
|
|
4666
4700
|
}, [state, error, onError]);
|
|
4667
|
-
const handleActivate = (0,
|
|
4701
|
+
const handleActivate = (0, import_react24.useCallback)(async () => {
|
|
4668
4702
|
if (!resolvedPlanRef) return;
|
|
4669
4703
|
setStep("activating");
|
|
4670
4704
|
await activate({ productRef, planRef: resolvedPlanRef });
|
|
4671
4705
|
await refetch();
|
|
4672
4706
|
}, [activate, productRef, resolvedPlanRef, refetch]);
|
|
4673
|
-
const goToTopupPayment = (0,
|
|
4707
|
+
const goToTopupPayment = (0, import_react24.useCallback)(() => {
|
|
4674
4708
|
if (amountSelector.validate()) setStep("topupPayment");
|
|
4675
4709
|
}, [amountSelector]);
|
|
4676
|
-
const backToSelectAmount = (0,
|
|
4710
|
+
const backToSelectAmount = (0, import_react24.useCallback)(() => {
|
|
4677
4711
|
setStep("selectAmount");
|
|
4678
4712
|
}, []);
|
|
4679
|
-
const retryActivation = (0,
|
|
4713
|
+
const retryActivation = (0, import_react24.useCallback)(async () => {
|
|
4680
4714
|
if (!resolvedPlanRef) return;
|
|
4681
4715
|
setStep("retrying");
|
|
4682
4716
|
const amountMinor2 = Math.round(
|
|
@@ -4699,10 +4733,10 @@ var Root5 = (0, import_react23.forwardRef)(function ActivationFlowRoot({
|
|
|
4699
4733
|
activate,
|
|
4700
4734
|
productRef
|
|
4701
4735
|
]);
|
|
4702
|
-
const handleTopupSuccess = (0,
|
|
4736
|
+
const handleTopupSuccess = (0, import_react24.useCallback)(async () => {
|
|
4703
4737
|
await retryActivation();
|
|
4704
4738
|
}, [retryActivation]);
|
|
4705
|
-
(0,
|
|
4739
|
+
(0, import_react24.useEffect)(() => {
|
|
4706
4740
|
if (step !== "retrying") return;
|
|
4707
4741
|
if (state !== "topup_required") return;
|
|
4708
4742
|
if (!resolvedPlanRef) return;
|
|
@@ -4713,7 +4747,7 @@ var Root5 = (0, import_react23.forwardRef)(function ActivationFlowRoot({
|
|
|
4713
4747
|
if (retryTimeoutRef.current) clearTimeout(retryTimeoutRef.current);
|
|
4714
4748
|
};
|
|
4715
4749
|
}, [step, state, resolvedPlanRef, retryBackoffMs, activate, productRef]);
|
|
4716
|
-
const resetFlow = (0,
|
|
4750
|
+
const resetFlow = (0, import_react24.useCallback)(() => {
|
|
4717
4751
|
reset();
|
|
4718
4752
|
calledSuccessRef.current = false;
|
|
4719
4753
|
setStep("summary");
|
|
@@ -4721,7 +4755,7 @@ var Root5 = (0, import_react23.forwardRef)(function ActivationFlowRoot({
|
|
|
4721
4755
|
const amountMinor = Math.round(
|
|
4722
4756
|
(amountSelector.resolvedAmount || 0) * getMinorUnitsPerMajor(currency)
|
|
4723
4757
|
);
|
|
4724
|
-
const ctx = (0,
|
|
4758
|
+
const ctx = (0, import_react24.useMemo)(
|
|
4725
4759
|
() => ({
|
|
4726
4760
|
step,
|
|
4727
4761
|
plan,
|
|
@@ -4760,18 +4794,18 @@ var Root5 = (0, import_react23.forwardRef)(function ActivationFlowRoot({
|
|
|
4760
4794
|
]
|
|
4761
4795
|
);
|
|
4762
4796
|
const Comp = asChild ? Slot : "div";
|
|
4763
|
-
return /* @__PURE__ */ (0,
|
|
4797
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ActivationFlowContext.Provider, { value: ctx, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Comp, { ref: forwardedRef, "data-solvapay-activation-flow": "", "data-state": step, ...rest, children }) });
|
|
4764
4798
|
});
|
|
4765
4799
|
function matchStep(step, allowed) {
|
|
4766
4800
|
return allowed.includes(step);
|
|
4767
4801
|
}
|
|
4768
|
-
var Summary2 = (0,
|
|
4802
|
+
var Summary2 = (0, import_react24.forwardRef)(function ActivationFlowSummary({ asChild, children, ...rest }, forwardedRef) {
|
|
4769
4803
|
const ctx = useFlowCtx("Summary");
|
|
4770
4804
|
if (!matchStep(ctx.step, ["summary", "activating"])) return null;
|
|
4771
4805
|
const Comp = asChild ? Slot : "div";
|
|
4772
|
-
return /* @__PURE__ */ (0,
|
|
4806
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Comp, { ref: forwardedRef, "data-solvapay-activation-flow-summary": "", ...rest, children });
|
|
4773
4807
|
});
|
|
4774
|
-
var ActivateButton = (0,
|
|
4808
|
+
var ActivateButton = (0, import_react24.forwardRef)(
|
|
4775
4809
|
function ActivationFlowActivateButton({ asChild, onClick, children, ...rest }, forwardedRef) {
|
|
4776
4810
|
const ctx = useFlowCtx("ActivateButton");
|
|
4777
4811
|
const copy = useCopy();
|
|
@@ -4792,18 +4826,18 @@ var ActivateButton = (0, import_react23.forwardRef)(
|
|
|
4792
4826
|
if (asChild) {
|
|
4793
4827
|
return (
|
|
4794
4828
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4795
|
-
/* @__PURE__ */ (0,
|
|
4829
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Slot, { ref: forwardedRef, ...commonProps, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, { children: label }) })
|
|
4796
4830
|
);
|
|
4797
4831
|
}
|
|
4798
|
-
return /* @__PURE__ */ (0,
|
|
4832
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { ref: forwardedRef, type: "button", ...commonProps, children: children ?? label });
|
|
4799
4833
|
}
|
|
4800
4834
|
);
|
|
4801
4835
|
var AmountPickerMount = ({ children }) => {
|
|
4802
4836
|
const ctx = useFlowCtx("AmountPicker");
|
|
4803
4837
|
if (ctx.step !== "selectAmount") return null;
|
|
4804
|
-
return /* @__PURE__ */ (0,
|
|
4838
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { "data-solvapay-activation-flow-amount-picker": "", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(AmountPicker.Root, { currency: ctx.currency, selector: ctx.amountSelector, children }) });
|
|
4805
4839
|
};
|
|
4806
|
-
var ContinueButton = (0,
|
|
4840
|
+
var ContinueButton = (0, import_react24.forwardRef)(
|
|
4807
4841
|
function ActivationFlowContinueButton({ asChild, onClick, children, ...rest }, forwardedRef) {
|
|
4808
4842
|
const ctx = useFlowCtx("ContinueButton");
|
|
4809
4843
|
const copy = useCopy();
|
|
@@ -4822,35 +4856,35 @@ var ContinueButton = (0, import_react23.forwardRef)(
|
|
|
4822
4856
|
if (asChild) {
|
|
4823
4857
|
return (
|
|
4824
4858
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4825
|
-
/* @__PURE__ */ (0,
|
|
4859
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Slot, { ref: forwardedRef, ...commonProps, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, { children: copy.activationFlow.continueToPayment }) })
|
|
4826
4860
|
);
|
|
4827
4861
|
}
|
|
4828
|
-
return /* @__PURE__ */ (0,
|
|
4862
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { ref: forwardedRef, type: "button", ...commonProps, children: children ?? copy.activationFlow.continueToPayment });
|
|
4829
4863
|
}
|
|
4830
4864
|
);
|
|
4831
|
-
var Retrying = (0,
|
|
4865
|
+
var Retrying = (0, import_react24.forwardRef)(function ActivationFlowRetrying({ asChild, children, ...rest }, forwardedRef) {
|
|
4832
4866
|
const ctx = useFlowCtx("Retrying");
|
|
4833
4867
|
if (ctx.step !== "retrying") return null;
|
|
4834
4868
|
const Comp = asChild ? Slot : "div";
|
|
4835
|
-
return /* @__PURE__ */ (0,
|
|
4869
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Comp, { ref: forwardedRef, "data-solvapay-activation-flow-retrying": "", ...rest, children });
|
|
4836
4870
|
});
|
|
4837
|
-
var Activated = (0,
|
|
4871
|
+
var Activated = (0, import_react24.forwardRef)(function ActivationFlowActivated({ asChild, children, ...rest }, forwardedRef) {
|
|
4838
4872
|
const ctx = useFlowCtx("Activated");
|
|
4839
4873
|
if (ctx.step !== "activated") return null;
|
|
4840
4874
|
const Comp = asChild ? Slot : "div";
|
|
4841
|
-
return /* @__PURE__ */ (0,
|
|
4875
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Comp, { ref: forwardedRef, "data-solvapay-activation-flow-activated": "", ...rest, children });
|
|
4842
4876
|
});
|
|
4843
|
-
var Loading3 = (0,
|
|
4877
|
+
var Loading3 = (0, import_react24.forwardRef)(function ActivationFlowLoading({ asChild, children, ...rest }, forwardedRef) {
|
|
4844
4878
|
const ctx = useFlowCtx("Loading");
|
|
4845
4879
|
if (ctx.plan) return null;
|
|
4846
4880
|
const Comp = asChild ? Slot : "div";
|
|
4847
|
-
return /* @__PURE__ */ (0,
|
|
4881
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Comp, { ref: forwardedRef, "data-solvapay-activation-flow-loading": "", ...rest, children });
|
|
4848
4882
|
});
|
|
4849
|
-
var ErrorSlot3 = (0,
|
|
4883
|
+
var ErrorSlot3 = (0, import_react24.forwardRef)(function ActivationFlowError({ asChild, children, ...rest }, forwardedRef) {
|
|
4850
4884
|
const ctx = useFlowCtx("Error");
|
|
4851
4885
|
if (ctx.step !== "error") return null;
|
|
4852
4886
|
const Comp = asChild ? Slot : "div";
|
|
4853
|
-
return /* @__PURE__ */ (0,
|
|
4887
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Comp, { ref: forwardedRef, role: "alert", "data-solvapay-activation-flow-error": "", ...rest, children: children ?? ctx.error });
|
|
4854
4888
|
});
|
|
4855
4889
|
var ActivationFlowRoot2 = Root5;
|
|
4856
4890
|
var ActivationFlowSummary2 = Summary2;
|
|
@@ -4877,11 +4911,11 @@ function useActivationFlow() {
|
|
|
4877
4911
|
}
|
|
4878
4912
|
|
|
4879
4913
|
// src/primitives/BalanceBadge.tsx
|
|
4880
|
-
var
|
|
4914
|
+
var import_react25 = require("react");
|
|
4881
4915
|
var import_core4 = require("@solvapay/core");
|
|
4882
|
-
var
|
|
4883
|
-
var BalanceBadge = (0,
|
|
4884
|
-
const solva = (0,
|
|
4916
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
4917
|
+
var BalanceBadge = (0, import_react25.forwardRef)(function BalanceBadge2({ asChild, numberOnly, lowThreshold = 10, children, ...rest }, forwardedRef) {
|
|
4918
|
+
const solva = (0, import_react25.useContext)(SolvaPayContext);
|
|
4885
4919
|
if (!solva) throw new MissingProviderError("BalanceBadge");
|
|
4886
4920
|
const { credits, displayCurrency, creditsPerMinorUnit, displayExchangeRate, loading } = useBalance();
|
|
4887
4921
|
const copy = useCopy();
|
|
@@ -4898,10 +4932,10 @@ var BalanceBadge = (0, import_react24.forwardRef)(function BalanceBadge2({ asChi
|
|
|
4898
4932
|
if (asChild) {
|
|
4899
4933
|
return (
|
|
4900
4934
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4901
|
-
/* @__PURE__ */ (0,
|
|
4935
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Slot, { ref: forwardedRef, ...commonProps, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, {}) })
|
|
4902
4936
|
);
|
|
4903
4937
|
}
|
|
4904
|
-
return /* @__PURE__ */ (0,
|
|
4938
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { ref: forwardedRef, ...commonProps });
|
|
4905
4939
|
}
|
|
4906
4940
|
if (credits == null) return null;
|
|
4907
4941
|
const formattedCredits = new Intl.NumberFormat(locale).format(credits);
|
|
@@ -4923,7 +4957,7 @@ var BalanceBadge = (0, import_react24.forwardRef)(function BalanceBadge2({ asChi
|
|
|
4923
4957
|
currencyEquivalent = interpolate(copy.balance.currencyEquivalent, { amount: formatted });
|
|
4924
4958
|
}
|
|
4925
4959
|
}
|
|
4926
|
-
const content = children ?? /* @__PURE__ */ (0,
|
|
4960
|
+
const content = children ?? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
4927
4961
|
formattedCredits,
|
|
4928
4962
|
!numberOnly && copy.balance.credits,
|
|
4929
4963
|
!numberOnly && currencyEquivalent
|
|
@@ -4931,24 +4965,24 @@ var BalanceBadge = (0, import_react24.forwardRef)(function BalanceBadge2({ asChi
|
|
|
4931
4965
|
if (asChild) {
|
|
4932
4966
|
return (
|
|
4933
4967
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4934
|
-
/* @__PURE__ */ (0,
|
|
4968
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Slot, { ref: forwardedRef, ...commonProps, children: content })
|
|
4935
4969
|
);
|
|
4936
4970
|
}
|
|
4937
|
-
return /* @__PURE__ */ (0,
|
|
4971
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { ref: forwardedRef, ...commonProps, children: content });
|
|
4938
4972
|
});
|
|
4939
4973
|
|
|
4940
4974
|
// src/primitives/CancelPlanButton.tsx
|
|
4941
4975
|
var import_core5 = require("@solvapay/core");
|
|
4942
|
-
var
|
|
4976
|
+
var import_react27 = require("react");
|
|
4943
4977
|
|
|
4944
4978
|
// src/hooks/usePurchaseActions.ts
|
|
4945
|
-
var
|
|
4979
|
+
var import_react26 = require("react");
|
|
4946
4980
|
function usePurchaseActions() {
|
|
4947
4981
|
const ctx = useSolvaPay();
|
|
4948
|
-
const [isCancelling, setIsCancelling] = (0,
|
|
4949
|
-
const [isReactivating, setIsReactivating] = (0,
|
|
4950
|
-
const [isActivating, setIsActivating] = (0,
|
|
4951
|
-
const cancelRenewal = (0,
|
|
4982
|
+
const [isCancelling, setIsCancelling] = (0, import_react26.useState)(false);
|
|
4983
|
+
const [isReactivating, setIsReactivating] = (0, import_react26.useState)(false);
|
|
4984
|
+
const [isActivating, setIsActivating] = (0, import_react26.useState)(false);
|
|
4985
|
+
const cancelRenewal = (0, import_react26.useCallback)(
|
|
4952
4986
|
async (params) => {
|
|
4953
4987
|
setIsCancelling(true);
|
|
4954
4988
|
try {
|
|
@@ -4959,7 +4993,7 @@ function usePurchaseActions() {
|
|
|
4959
4993
|
},
|
|
4960
4994
|
[ctx.cancelRenewal]
|
|
4961
4995
|
);
|
|
4962
|
-
const reactivateRenewal = (0,
|
|
4996
|
+
const reactivateRenewal = (0, import_react26.useCallback)(
|
|
4963
4997
|
async (params) => {
|
|
4964
4998
|
setIsReactivating(true);
|
|
4965
4999
|
try {
|
|
@@ -4970,7 +5004,7 @@ function usePurchaseActions() {
|
|
|
4970
5004
|
},
|
|
4971
5005
|
[ctx.reactivateRenewal]
|
|
4972
5006
|
);
|
|
4973
|
-
const activatePlan = (0,
|
|
5007
|
+
const activatePlan = (0, import_react26.useCallback)(
|
|
4974
5008
|
async (params) => {
|
|
4975
5009
|
setIsActivating(true);
|
|
4976
5010
|
try {
|
|
@@ -4992,7 +5026,7 @@ function usePurchaseActions() {
|
|
|
4992
5026
|
}
|
|
4993
5027
|
|
|
4994
5028
|
// src/primitives/CancelPlanButton.tsx
|
|
4995
|
-
var
|
|
5029
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
4996
5030
|
function resolveConfirmText(confirm, purchase, defaults) {
|
|
4997
5031
|
if (confirm === false) return null;
|
|
4998
5032
|
if (typeof confirm === "string") return confirm;
|
|
@@ -5000,7 +5034,7 @@ function resolveConfirmText(confirm, purchase, defaults) {
|
|
|
5000
5034
|
if (isUsageBased) return defaults.usageBased;
|
|
5001
5035
|
return defaults.recurring;
|
|
5002
5036
|
}
|
|
5003
|
-
var CancelPlanButton = (0,
|
|
5037
|
+
var CancelPlanButton = (0, import_react27.forwardRef)(
|
|
5004
5038
|
function CancelPlanButton2({
|
|
5005
5039
|
asChild,
|
|
5006
5040
|
purchaseRef,
|
|
@@ -5012,14 +5046,14 @@ var CancelPlanButton = (0, import_react26.forwardRef)(
|
|
|
5012
5046
|
children,
|
|
5013
5047
|
...rest
|
|
5014
5048
|
}, forwardedRef) {
|
|
5015
|
-
const solva = (0,
|
|
5049
|
+
const solva = (0, import_react27.useContext)(SolvaPayContext);
|
|
5016
5050
|
if (!solva) throw new MissingProviderError("CancelPlanButton");
|
|
5017
5051
|
const copy = useCopy();
|
|
5018
5052
|
const { activePurchase } = usePurchase();
|
|
5019
5053
|
const { cancelRenewal, isCancelling } = usePurchaseActions();
|
|
5020
5054
|
const effectivePurchase = purchaseRef ? activePurchase && activePurchase.reference === purchaseRef ? activePurchase : { reference: purchaseRef } : activePurchase;
|
|
5021
5055
|
const effectiveRef = purchaseRef ?? effectivePurchase?.reference;
|
|
5022
|
-
const cancel = (0,
|
|
5056
|
+
const cancel = (0, import_react27.useCallback)(async () => {
|
|
5023
5057
|
if (!effectiveRef) return;
|
|
5024
5058
|
const confirmText = resolveConfirmText(confirm, effectivePurchase, {
|
|
5025
5059
|
recurring: copy.cancelPlan.confirmRecurring,
|
|
@@ -5055,25 +5089,25 @@ var CancelPlanButton = (0, import_react26.forwardRef)(
|
|
|
5055
5089
|
if (asChild) {
|
|
5056
5090
|
return (
|
|
5057
5091
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5058
|
-
/* @__PURE__ */ (0,
|
|
5092
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Slot, { ref: forwardedRef, ...commonProps, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children: label }) })
|
|
5059
5093
|
);
|
|
5060
5094
|
}
|
|
5061
|
-
return /* @__PURE__ */ (0,
|
|
5095
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { ref: forwardedRef, type: "button", ...commonProps, children: children ?? label });
|
|
5062
5096
|
}
|
|
5063
5097
|
);
|
|
5064
5098
|
|
|
5065
5099
|
// src/primitives/CancelledPlanNotice.tsx
|
|
5066
|
-
var
|
|
5100
|
+
var import_react29 = require("react");
|
|
5067
5101
|
|
|
5068
5102
|
// src/hooks/usePurchaseStatus.ts
|
|
5069
|
-
var
|
|
5103
|
+
var import_react28 = require("react");
|
|
5070
5104
|
function usePurchaseStatus() {
|
|
5071
5105
|
const { purchases } = usePurchase();
|
|
5072
5106
|
const locale = useLocale();
|
|
5073
|
-
const isPaidPurchase = (0,
|
|
5107
|
+
const isPaidPurchase = (0, import_react28.useCallback)((p) => {
|
|
5074
5108
|
return (p.amount ?? 0) > 0;
|
|
5075
5109
|
}, []);
|
|
5076
|
-
const purchaseData = (0,
|
|
5110
|
+
const purchaseData = (0, import_react28.useMemo)(() => {
|
|
5077
5111
|
const cancelledPaidPurchases = purchases.filter((p) => {
|
|
5078
5112
|
return p.status === "active" && p.cancelledAt && isPaidPurchase(p) && isPlanPurchase(p);
|
|
5079
5113
|
});
|
|
@@ -5086,7 +5120,7 @@ function usePurchaseStatus() {
|
|
|
5086
5120
|
shouldShowCancelledNotice
|
|
5087
5121
|
};
|
|
5088
5122
|
}, [purchases, isPaidPurchase]);
|
|
5089
|
-
const formatDate = (0,
|
|
5123
|
+
const formatDate = (0, import_react28.useCallback)(
|
|
5090
5124
|
(dateString) => {
|
|
5091
5125
|
if (!dateString) return null;
|
|
5092
5126
|
return new Date(dateString).toLocaleDateString(locale || "en-US", {
|
|
@@ -5097,7 +5131,7 @@ function usePurchaseStatus() {
|
|
|
5097
5131
|
},
|
|
5098
5132
|
[locale]
|
|
5099
5133
|
);
|
|
5100
|
-
const getDaysUntilExpiration = (0,
|
|
5134
|
+
const getDaysUntilExpiration = (0, import_react28.useCallback)((endDate) => {
|
|
5101
5135
|
if (!endDate) return null;
|
|
5102
5136
|
const now = /* @__PURE__ */ new Date();
|
|
5103
5137
|
const expiration = new Date(endDate);
|
|
@@ -5114,10 +5148,10 @@ function usePurchaseStatus() {
|
|
|
5114
5148
|
}
|
|
5115
5149
|
|
|
5116
5150
|
// src/primitives/CancelledPlanNotice.tsx
|
|
5117
|
-
var
|
|
5118
|
-
var CancelledPlanNoticeContext = (0,
|
|
5151
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
5152
|
+
var CancelledPlanNoticeContext = (0, import_react29.createContext)(null);
|
|
5119
5153
|
function useNoticeCtx(part) {
|
|
5120
|
-
const ctx = (0,
|
|
5154
|
+
const ctx = (0, import_react29.useContext)(CancelledPlanNoticeContext);
|
|
5121
5155
|
if (!ctx) {
|
|
5122
5156
|
throw new Error(
|
|
5123
5157
|
`CancelledPlanNotice.${part} must be rendered inside <CancelledPlanNotice.Root>.`
|
|
@@ -5125,8 +5159,8 @@ function useNoticeCtx(part) {
|
|
|
5125
5159
|
}
|
|
5126
5160
|
return ctx;
|
|
5127
5161
|
}
|
|
5128
|
-
var Root6 = (0,
|
|
5129
|
-
const solva = (0,
|
|
5162
|
+
var Root6 = (0, import_react29.forwardRef)(function CancelledPlanNoticeRoot({ onReactivated, onError, asChild, children, ...rest }, forwardedRef) {
|
|
5163
|
+
const solva = (0, import_react29.useContext)(SolvaPayContext);
|
|
5130
5164
|
if (!solva) throw new MissingProviderError("CancelledPlanNotice");
|
|
5131
5165
|
const {
|
|
5132
5166
|
cancelledPurchase,
|
|
@@ -5135,7 +5169,7 @@ var Root6 = (0, import_react28.forwardRef)(function CancelledPlanNoticeRoot({ on
|
|
|
5135
5169
|
getDaysUntilExpiration
|
|
5136
5170
|
} = usePurchaseStatus();
|
|
5137
5171
|
const { reactivateRenewal, isReactivating } = usePurchaseActions();
|
|
5138
|
-
const reactivate = (0,
|
|
5172
|
+
const reactivate = (0, import_react29.useCallback)(async () => {
|
|
5139
5173
|
if (!cancelledPurchase) return;
|
|
5140
5174
|
try {
|
|
5141
5175
|
await reactivateRenewal({ purchaseRef: cancelledPurchase.reference });
|
|
@@ -5144,11 +5178,11 @@ var Root6 = (0, import_react28.forwardRef)(function CancelledPlanNoticeRoot({ on
|
|
|
5144
5178
|
onError?.(err instanceof Error ? err : new Error(String(err)));
|
|
5145
5179
|
}
|
|
5146
5180
|
}, [cancelledPurchase, reactivateRenewal, onReactivated, onError]);
|
|
5147
|
-
const daysRemaining = (0,
|
|
5181
|
+
const daysRemaining = (0, import_react29.useMemo)(
|
|
5148
5182
|
() => cancelledPurchase ? getDaysUntilExpiration(cancelledPurchase.endDate) : null,
|
|
5149
5183
|
[cancelledPurchase, getDaysUntilExpiration]
|
|
5150
5184
|
);
|
|
5151
|
-
const ctx = (0,
|
|
5185
|
+
const ctx = (0, import_react29.useMemo)(() => {
|
|
5152
5186
|
if (!cancelledPurchase) return null;
|
|
5153
5187
|
const state = daysRemaining != null && daysRemaining > 0 ? "active" : "expired";
|
|
5154
5188
|
return {
|
|
@@ -5163,7 +5197,7 @@ var Root6 = (0, import_react28.forwardRef)(function CancelledPlanNoticeRoot({ on
|
|
|
5163
5197
|
}, [cancelledPurchase, daysRemaining, formatDate, reactivate, isReactivating]);
|
|
5164
5198
|
if (!shouldShowCancelledNotice || !ctx) return null;
|
|
5165
5199
|
const Comp = asChild ? Slot : "div";
|
|
5166
|
-
return /* @__PURE__ */ (0,
|
|
5200
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(CancelledPlanNoticeContext.Provider, { value: ctx, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
5167
5201
|
Comp,
|
|
5168
5202
|
{
|
|
5169
5203
|
ref: forwardedRef,
|
|
@@ -5175,61 +5209,61 @@ var Root6 = (0, import_react28.forwardRef)(function CancelledPlanNoticeRoot({ on
|
|
|
5175
5209
|
}
|
|
5176
5210
|
) });
|
|
5177
5211
|
});
|
|
5178
|
-
var Heading2 = (0,
|
|
5212
|
+
var Heading2 = (0, import_react29.forwardRef)(function CancelledPlanNoticeHeading({ asChild, children, ...rest }, forwardedRef) {
|
|
5179
5213
|
useNoticeCtx("Heading");
|
|
5180
5214
|
const copy = useCopy();
|
|
5181
5215
|
const Comp = asChild ? Slot : "p";
|
|
5182
|
-
return /* @__PURE__ */ (0,
|
|
5216
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Comp, { ref: forwardedRef, "data-solvapay-cancelled-notice-heading": "", ...rest, children: children ?? copy.cancelledNotice.heading });
|
|
5183
5217
|
});
|
|
5184
|
-
var Expires = (0,
|
|
5218
|
+
var Expires = (0, import_react29.forwardRef)(function CancelledPlanNoticeExpires({ asChild, children, ...rest }, forwardedRef) {
|
|
5185
5219
|
const ctx = useNoticeCtx("Expires");
|
|
5186
5220
|
const copy = useCopy();
|
|
5187
5221
|
const date = ctx.formatDate(ctx.purchase.endDate);
|
|
5188
5222
|
if (!ctx.purchase.endDate) {
|
|
5189
5223
|
const Comp2 = asChild ? Slot : "p";
|
|
5190
|
-
return /* @__PURE__ */ (0,
|
|
5224
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Comp2, { ref: forwardedRef, "data-solvapay-cancelled-notice-expires": "", ...rest, children: children ?? copy.cancelledNotice.accessEnded });
|
|
5191
5225
|
}
|
|
5192
5226
|
const Comp = asChild ? Slot : "p";
|
|
5193
|
-
return /* @__PURE__ */ (0,
|
|
5227
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Comp, { ref: forwardedRef, "data-solvapay-cancelled-notice-expires": "", ...rest, children: children ?? interpolate(copy.cancelledNotice.expiresLabel, { date: date ?? "" }) });
|
|
5194
5228
|
});
|
|
5195
|
-
var DaysRemaining = (0,
|
|
5229
|
+
var DaysRemaining = (0, import_react29.forwardRef)(
|
|
5196
5230
|
function CancelledPlanNoticeDaysRemaining({ asChild, children, ...rest }, forwardedRef) {
|
|
5197
5231
|
const ctx = useNoticeCtx("DaysRemaining");
|
|
5198
5232
|
const copy = useCopy();
|
|
5199
5233
|
if (ctx.daysRemaining == null || ctx.daysRemaining <= 0) return null;
|
|
5200
5234
|
const template = ctx.daysRemaining === 1 ? copy.cancelledNotice.dayRemaining : copy.cancelledNotice.daysRemaining;
|
|
5201
5235
|
const Comp = asChild ? Slot : "p";
|
|
5202
|
-
return /* @__PURE__ */ (0,
|
|
5236
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Comp, { ref: forwardedRef, "data-solvapay-cancelled-notice-days-remaining": "", ...rest, children: children ?? interpolate(template, { days: ctx.daysRemaining }) });
|
|
5203
5237
|
}
|
|
5204
5238
|
);
|
|
5205
|
-
var AccessUntil = (0,
|
|
5239
|
+
var AccessUntil = (0, import_react29.forwardRef)(
|
|
5206
5240
|
function CancelledPlanNoticeAccessUntil({ asChild, children, ...rest }, forwardedRef) {
|
|
5207
5241
|
const ctx = useNoticeCtx("AccessUntil");
|
|
5208
5242
|
const copy = useCopy();
|
|
5209
5243
|
if (!ctx.purchase.endDate) return null;
|
|
5210
5244
|
const Comp = asChild ? Slot : "p";
|
|
5211
|
-
return /* @__PURE__ */ (0,
|
|
5245
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Comp, { ref: forwardedRef, "data-solvapay-cancelled-notice-access-until": "", ...rest, children: children ?? interpolate(copy.cancelledNotice.accessUntil, {
|
|
5212
5246
|
product: ctx.purchase.productName
|
|
5213
5247
|
}) });
|
|
5214
5248
|
}
|
|
5215
5249
|
);
|
|
5216
|
-
var CancelledOn = (0,
|
|
5250
|
+
var CancelledOn = (0, import_react29.forwardRef)(
|
|
5217
5251
|
function CancelledPlanNoticeCancelledOn({ asChild, children, ...rest }, forwardedRef) {
|
|
5218
5252
|
const ctx = useNoticeCtx("CancelledOn");
|
|
5219
5253
|
const copy = useCopy();
|
|
5220
5254
|
if (!ctx.purchase.cancelledAt) return null;
|
|
5221
5255
|
const date = ctx.formatDate(ctx.purchase.cancelledAt);
|
|
5222
5256
|
const Comp = asChild ? Slot : "p";
|
|
5223
|
-
return /* @__PURE__ */ (0,
|
|
5257
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Comp, { ref: forwardedRef, "data-solvapay-cancelled-notice-cancelled-on": "", ...rest, children: children ?? interpolate(copy.cancelledNotice.cancelledOn, { date: date ?? "" }) });
|
|
5224
5258
|
}
|
|
5225
5259
|
);
|
|
5226
|
-
var Reason = (0,
|
|
5260
|
+
var Reason = (0, import_react29.forwardRef)(function CancelledPlanNoticeReason({ asChild, children, ...rest }, forwardedRef) {
|
|
5227
5261
|
const ctx = useNoticeCtx("Reason");
|
|
5228
5262
|
if (!ctx.hasReason) return null;
|
|
5229
5263
|
const Comp = asChild ? Slot : "span";
|
|
5230
|
-
return /* @__PURE__ */ (0,
|
|
5264
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Comp, { ref: forwardedRef, "data-solvapay-cancelled-notice-reason": "", ...rest, children: children ?? ctx.purchase.cancellationReason });
|
|
5231
5265
|
});
|
|
5232
|
-
var ReactivateButton = (0,
|
|
5266
|
+
var ReactivateButton = (0, import_react29.forwardRef)(
|
|
5233
5267
|
function CancelledPlanNoticeReactivateButton({ asChild, onClick, children, ...rest }, forwardedRef) {
|
|
5234
5268
|
const ctx = useNoticeCtx("ReactivateButton");
|
|
5235
5269
|
const copy = useCopy();
|
|
@@ -5249,10 +5283,10 @@ var ReactivateButton = (0, import_react28.forwardRef)(
|
|
|
5249
5283
|
if (asChild) {
|
|
5250
5284
|
return (
|
|
5251
5285
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5252
|
-
/* @__PURE__ */ (0,
|
|
5286
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Slot, { ref: forwardedRef, ...commonProps, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children: label }) })
|
|
5253
5287
|
);
|
|
5254
5288
|
}
|
|
5255
|
-
return /* @__PURE__ */ (0,
|
|
5289
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { ref: forwardedRef, type: "button", ...commonProps, children: children ?? label });
|
|
5256
5290
|
}
|
|
5257
5291
|
);
|
|
5258
5292
|
var CancelledPlanNoticeRoot2 = Root6;
|
|
@@ -5278,14 +5312,14 @@ function useCancelledPlanNotice() {
|
|
|
5278
5312
|
}
|
|
5279
5313
|
|
|
5280
5314
|
// src/primitives/CreditGate.tsx
|
|
5281
|
-
var
|
|
5315
|
+
var import_react32 = require("react");
|
|
5282
5316
|
|
|
5283
5317
|
// src/primitives/TopupForm.tsx
|
|
5284
|
-
var
|
|
5318
|
+
var import_react31 = __toESM(require("react"), 1);
|
|
5285
5319
|
var import_react_stripe_js2 = require("@stripe/react-stripe-js");
|
|
5286
5320
|
|
|
5287
5321
|
// src/hooks/useTopup.ts
|
|
5288
|
-
var
|
|
5322
|
+
var import_react30 = require("react");
|
|
5289
5323
|
var import_stripe_js2 = require("@stripe/stripe-js");
|
|
5290
5324
|
var stripePromiseCache2 = /* @__PURE__ */ new Map();
|
|
5291
5325
|
function getStripeCacheKey2(publishableKey, accountId) {
|
|
@@ -5294,13 +5328,13 @@ function getStripeCacheKey2(publishableKey, accountId) {
|
|
|
5294
5328
|
function useTopup(options) {
|
|
5295
5329
|
const { amount, currency, autoRecharge } = options;
|
|
5296
5330
|
const { createTopupPayment, customerRef, updateCustomerRef } = useSolvaPay();
|
|
5297
|
-
const [loading, setLoading] = (0,
|
|
5298
|
-
const [error, setError] = (0,
|
|
5299
|
-
const [stripePromise, setStripePromise] = (0,
|
|
5300
|
-
const [clientSecret, setClientSecret] = (0,
|
|
5301
|
-
const [processorPaymentId, setProcessorPaymentId] = (0,
|
|
5302
|
-
const isStartingRef = (0,
|
|
5303
|
-
const startTopup = (0,
|
|
5331
|
+
const [loading, setLoading] = (0, import_react30.useState)(false);
|
|
5332
|
+
const [error, setError] = (0, import_react30.useState)(null);
|
|
5333
|
+
const [stripePromise, setStripePromise] = (0, import_react30.useState)(null);
|
|
5334
|
+
const [clientSecret, setClientSecret] = (0, import_react30.useState)(null);
|
|
5335
|
+
const [processorPaymentId, setProcessorPaymentId] = (0, import_react30.useState)(null);
|
|
5336
|
+
const isStartingRef = (0, import_react30.useRef)(false);
|
|
5337
|
+
const startTopup = (0, import_react30.useCallback)(async () => {
|
|
5304
5338
|
if (isStartingRef.current || loading) {
|
|
5305
5339
|
return;
|
|
5306
5340
|
}
|
|
@@ -5348,7 +5382,7 @@ function useTopup(options) {
|
|
|
5348
5382
|
isStartingRef.current = false;
|
|
5349
5383
|
}
|
|
5350
5384
|
}, [amount, currency, autoRecharge, createTopupPayment, customerRef, updateCustomerRef, loading]);
|
|
5351
|
-
const reset = (0,
|
|
5385
|
+
const reset = (0, import_react30.useCallback)(() => {
|
|
5352
5386
|
isStartingRef.current = false;
|
|
5353
5387
|
setLoading(false);
|
|
5354
5388
|
setError(null);
|
|
@@ -5368,16 +5402,16 @@ function useTopup(options) {
|
|
|
5368
5402
|
}
|
|
5369
5403
|
|
|
5370
5404
|
// src/primitives/TopupForm.tsx
|
|
5371
|
-
var
|
|
5372
|
-
var TopupFormContext = (0,
|
|
5405
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
5406
|
+
var TopupFormContext = (0, import_react31.createContext)(null);
|
|
5373
5407
|
function useTopupCtx(part) {
|
|
5374
|
-
const ctx = (0,
|
|
5408
|
+
const ctx = (0, import_react31.useContext)(TopupFormContext);
|
|
5375
5409
|
if (!ctx) {
|
|
5376
5410
|
throw new Error(`TopupForm.${part} must be rendered inside <TopupForm.Root>.`);
|
|
5377
5411
|
}
|
|
5378
5412
|
return ctx;
|
|
5379
5413
|
}
|
|
5380
|
-
var Root7 = (0,
|
|
5414
|
+
var Root7 = (0, import_react31.forwardRef)(function TopupFormRoot(props, forwardedRef) {
|
|
5381
5415
|
const {
|
|
5382
5416
|
amount,
|
|
5383
5417
|
currency,
|
|
@@ -5393,7 +5427,7 @@ var Root7 = (0, import_react30.forwardRef)(function TopupFormRoot(props, forward
|
|
|
5393
5427
|
children,
|
|
5394
5428
|
...rest
|
|
5395
5429
|
} = props;
|
|
5396
|
-
const solva = (0,
|
|
5430
|
+
const solva = (0, import_react31.useContext)(SolvaPayContext);
|
|
5397
5431
|
if (!solva) throw new MissingProviderError("TopupForm");
|
|
5398
5432
|
const { processTopupPayment, attachBusinessDetails, customerRef } = solva;
|
|
5399
5433
|
const copy = useCopy();
|
|
@@ -5410,9 +5444,9 @@ var Root7 = (0, import_react30.forwardRef)(function TopupFormRoot(props, forward
|
|
|
5410
5444
|
currency,
|
|
5411
5445
|
autoRecharge
|
|
5412
5446
|
});
|
|
5413
|
-
const hasInitializedRef = (0,
|
|
5447
|
+
const hasInitializedRef = (0, import_react31.useRef)(false);
|
|
5414
5448
|
const hasAmount = amount > 0;
|
|
5415
|
-
(0,
|
|
5449
|
+
(0, import_react31.useEffect)(() => {
|
|
5416
5450
|
if (!hasInitializedRef.current && hasAmount && !loading && !topupError && !clientSecret) {
|
|
5417
5451
|
hasInitializedRef.current = true;
|
|
5418
5452
|
startTopup().catch((error) => {
|
|
@@ -5423,7 +5457,7 @@ var Root7 = (0, import_react30.forwardRef)(function TopupFormRoot(props, forward
|
|
|
5423
5457
|
if (hasAmount && clientSecret) hasInitializedRef.current = true;
|
|
5424
5458
|
}, [hasAmount, loading, topupError, clientSecret, startTopup]);
|
|
5425
5459
|
const finalReturnUrl = returnUrl || (typeof window !== "undefined" ? window.location.href : "/");
|
|
5426
|
-
const elementsOptions = (0,
|
|
5460
|
+
const elementsOptions = (0, import_react31.useMemo)(() => {
|
|
5427
5461
|
if (!clientSecret) return void 0;
|
|
5428
5462
|
return { clientSecret, locale: toStripeElementLocale(locale) };
|
|
5429
5463
|
}, [clientSecret, locale]);
|
|
@@ -5446,7 +5480,7 @@ var Root7 = (0, import_react30.forwardRef)(function TopupFormRoot(props, forward
|
|
|
5446
5480
|
attachBusinessDetails,
|
|
5447
5481
|
customerRef
|
|
5448
5482
|
};
|
|
5449
|
-
const shell = /* @__PURE__ */ (0,
|
|
5483
|
+
const shell = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
5450
5484
|
Comp,
|
|
5451
5485
|
{
|
|
5452
5486
|
ref: forwardedRef,
|
|
@@ -5458,9 +5492,9 @@ var Root7 = (0, import_react30.forwardRef)(function TopupFormRoot(props, forward
|
|
|
5458
5492
|
}
|
|
5459
5493
|
);
|
|
5460
5494
|
if (canMountElements) {
|
|
5461
|
-
return /* @__PURE__ */ (0,
|
|
5495
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_react_stripe_js2.Elements, { stripe: stripePromise, options: elementsOptions, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Inner, { ...innerCommon, children: shell }) }, clientSecret);
|
|
5462
5496
|
}
|
|
5463
|
-
return /* @__PURE__ */ (0,
|
|
5497
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(OfflineInner, { ...innerCommon, children: shell });
|
|
5464
5498
|
});
|
|
5465
5499
|
var Inner = ({
|
|
5466
5500
|
amount,
|
|
@@ -5481,11 +5515,11 @@ var Inner = ({
|
|
|
5481
5515
|
const stripe = (0, import_react_stripe_js2.useStripe)();
|
|
5482
5516
|
const elements = (0, import_react_stripe_js2.useElements)();
|
|
5483
5517
|
const copy = useCopy();
|
|
5484
|
-
const [paymentInputComplete, setPaymentInputComplete] = (0,
|
|
5485
|
-
const [isProcessing, setIsProcessing] = (0,
|
|
5486
|
-
const [error, setError] = (0,
|
|
5487
|
-
const returnResumeStarted = (0,
|
|
5488
|
-
(0,
|
|
5518
|
+
const [paymentInputComplete, setPaymentInputComplete] = (0, import_react31.useState)(false);
|
|
5519
|
+
const [isProcessing, setIsProcessing] = (0, import_react31.useState)(false);
|
|
5520
|
+
const [error, setError] = (0, import_react31.useState)(null);
|
|
5521
|
+
const returnResumeStarted = (0, import_react31.useRef)(false);
|
|
5522
|
+
(0, import_react31.useEffect)(() => {
|
|
5489
5523
|
if (!stripe || returnResumeStarted.current || typeof window === "undefined") return;
|
|
5490
5524
|
const returnClientSecret = readPaymentIntentClientSecret(window.location.search);
|
|
5491
5525
|
if (!returnClientSecret) return;
|
|
@@ -5575,7 +5609,7 @@ var Inner = ({
|
|
|
5575
5609
|
});
|
|
5576
5610
|
const isReady = !!(stripe && elements);
|
|
5577
5611
|
const canSubmit = isReady && paymentInputComplete && !isProcessing && !!clientSecret && (!requiresBusinessAttach || businessDetailsAttached) && !businessDetailsAttaching;
|
|
5578
|
-
const submit = (0,
|
|
5612
|
+
const submit = (0, import_react31.useCallback)(async () => {
|
|
5579
5613
|
if (!stripe || !elements || !clientSecret) {
|
|
5580
5614
|
const msg = copy.errors.stripeUnavailable;
|
|
5581
5615
|
setError(msg);
|
|
@@ -5663,7 +5697,7 @@ var Inner = ({
|
|
|
5663
5697
|
businessDetailsError
|
|
5664
5698
|
]);
|
|
5665
5699
|
const effectiveError = error ?? outerError ?? businessDetailsError;
|
|
5666
|
-
const ctx = (0,
|
|
5700
|
+
const ctx = (0, import_react31.useMemo)(
|
|
5667
5701
|
() => ({
|
|
5668
5702
|
amount,
|
|
5669
5703
|
currency,
|
|
@@ -5712,7 +5746,7 @@ var Inner = ({
|
|
|
5712
5746
|
submit
|
|
5713
5747
|
]
|
|
5714
5748
|
);
|
|
5715
|
-
return /* @__PURE__ */ (0,
|
|
5749
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(TopupFormContext.Provider, { value: ctx, children });
|
|
5716
5750
|
};
|
|
5717
5751
|
var OfflineInner = ({
|
|
5718
5752
|
amount,
|
|
@@ -5724,13 +5758,13 @@ var OfflineInner = ({
|
|
|
5724
5758
|
state,
|
|
5725
5759
|
children
|
|
5726
5760
|
}) => {
|
|
5727
|
-
const noopSubmit = (0,
|
|
5761
|
+
const noopSubmit = (0, import_react31.useCallback)(async () => {
|
|
5728
5762
|
}, []);
|
|
5729
|
-
const noopSet = (0,
|
|
5763
|
+
const noopSet = (0, import_react31.useCallback)(() => {
|
|
5730
5764
|
}, []);
|
|
5731
|
-
const noopBusinessSet = (0,
|
|
5765
|
+
const noopBusinessSet = (0, import_react31.useCallback)(() => {
|
|
5732
5766
|
}, []);
|
|
5733
|
-
const ctx = (0,
|
|
5767
|
+
const ctx = (0, import_react31.useMemo)(
|
|
5734
5768
|
() => ({
|
|
5735
5769
|
amount,
|
|
5736
5770
|
currency,
|
|
@@ -5768,16 +5802,16 @@ var OfflineInner = ({
|
|
|
5768
5802
|
noopBusinessSet
|
|
5769
5803
|
]
|
|
5770
5804
|
);
|
|
5771
|
-
return /* @__PURE__ */ (0,
|
|
5805
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(TopupFormContext.Provider, { value: ctx, children });
|
|
5772
5806
|
};
|
|
5773
5807
|
var PaymentElementSlot2 = ({ options }) => {
|
|
5774
5808
|
const { setPaymentInputComplete, isReady, stripe, elements } = useTopupCtx("PaymentElement");
|
|
5775
5809
|
const locale = useLocale();
|
|
5776
5810
|
if (!stripe || !elements) return null;
|
|
5777
5811
|
if (!isReady) {
|
|
5778
|
-
return /* @__PURE__ */ (0,
|
|
5812
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("output", { "data-solvapay-topup-form-loading": "", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Spinner, { size: "sm" }) });
|
|
5779
5813
|
}
|
|
5780
|
-
return /* @__PURE__ */ (0,
|
|
5814
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("section", { "data-solvapay-topup-form-payment-element": "", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
5781
5815
|
import_react_stripe_js2.PaymentElement,
|
|
5782
5816
|
{
|
|
5783
5817
|
options: withPaymentElementDefaults(options),
|
|
@@ -5786,14 +5820,14 @@ var PaymentElementSlot2 = ({ options }) => {
|
|
|
5786
5820
|
locale || "default"
|
|
5787
5821
|
) });
|
|
5788
5822
|
};
|
|
5789
|
-
var SubmitButton2 = (0,
|
|
5823
|
+
var SubmitButton2 = (0, import_react31.forwardRef)(
|
|
5790
5824
|
function TopupFormSubmitButton({ asChild, onClick, children, ...rest }, forwardedRef) {
|
|
5791
5825
|
const ctx = useTopupCtx("SubmitButton");
|
|
5792
5826
|
const copy = useCopy();
|
|
5793
5827
|
const dataState = ctx.isProcessing ? "processing" : !ctx.canSubmit ? "disabled" : "idle";
|
|
5794
|
-
const processingContent = /* @__PURE__ */ (0,
|
|
5795
|
-
/* @__PURE__ */ (0,
|
|
5796
|
-
/* @__PURE__ */ (0,
|
|
5828
|
+
const processingContent = /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
|
|
5829
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Spinner, { size: "sm" }),
|
|
5830
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { children: copy.cta.processing })
|
|
5797
5831
|
] });
|
|
5798
5832
|
const commonProps = {
|
|
5799
5833
|
"data-solvapay-topup-form-submit": "",
|
|
@@ -5808,38 +5842,38 @@ var SubmitButton2 = (0, import_react30.forwardRef)(
|
|
|
5808
5842
|
...rest
|
|
5809
5843
|
};
|
|
5810
5844
|
if (asChild) {
|
|
5811
|
-
const slotChild = ctx.isProcessing &&
|
|
5845
|
+
const slotChild = ctx.isProcessing && import_react31.default.isValidElement(children) ? import_react31.default.cloneElement(
|
|
5812
5846
|
children,
|
|
5813
5847
|
void 0,
|
|
5814
5848
|
processingContent
|
|
5815
5849
|
) : children;
|
|
5816
|
-
return /* @__PURE__ */ (0,
|
|
5850
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Slot, { ref: forwardedRef, ...commonProps, children: slotChild });
|
|
5817
5851
|
}
|
|
5818
5852
|
const content = ctx.isProcessing ? processingContent : children ? children : copy.cta.topUp;
|
|
5819
|
-
return /* @__PURE__ */ (0,
|
|
5853
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { ref: forwardedRef, type: "submit", ...commonProps, children: content });
|
|
5820
5854
|
}
|
|
5821
5855
|
);
|
|
5822
|
-
var Loading4 = (0,
|
|
5856
|
+
var Loading4 = (0, import_react31.forwardRef)(function TopupFormLoading({ asChild, children, ...rest }, forwardedRef) {
|
|
5823
5857
|
const ctx = useTopupCtx("Loading");
|
|
5824
5858
|
if (ctx.state !== "loading") return null;
|
|
5825
5859
|
if (asChild) {
|
|
5826
|
-
return /* @__PURE__ */ (0,
|
|
5860
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
5827
5861
|
Slot,
|
|
5828
5862
|
{
|
|
5829
5863
|
ref: forwardedRef,
|
|
5830
5864
|
"data-solvapay-topup-form-loading": "",
|
|
5831
5865
|
...rest,
|
|
5832
|
-
children: children ?? /* @__PURE__ */ (0,
|
|
5866
|
+
children: children ?? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Spinner, { size: "sm" })
|
|
5833
5867
|
}
|
|
5834
5868
|
);
|
|
5835
5869
|
}
|
|
5836
|
-
return /* @__PURE__ */ (0,
|
|
5870
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("output", { ref: forwardedRef, "data-solvapay-topup-form-loading": "", ...rest, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Spinner, { size: "sm" }) });
|
|
5837
5871
|
});
|
|
5838
|
-
var ErrorSlot4 = (0,
|
|
5872
|
+
var ErrorSlot4 = (0, import_react31.forwardRef)(function TopupFormError({ asChild, children, ...rest }, forwardedRef) {
|
|
5839
5873
|
const ctx = useTopupCtx("Error");
|
|
5840
5874
|
if (!ctx.error) return null;
|
|
5841
5875
|
if (asChild) {
|
|
5842
|
-
return /* @__PURE__ */ (0,
|
|
5876
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
5843
5877
|
Slot,
|
|
5844
5878
|
{
|
|
5845
5879
|
ref: forwardedRef,
|
|
@@ -5852,7 +5886,7 @@ var ErrorSlot4 = (0, import_react30.forwardRef)(function TopupFormError({ asChil
|
|
|
5852
5886
|
}
|
|
5853
5887
|
);
|
|
5854
5888
|
}
|
|
5855
|
-
return /* @__PURE__ */ (0,
|
|
5889
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
5856
5890
|
"p",
|
|
5857
5891
|
{
|
|
5858
5892
|
ref: forwardedRef,
|
|
@@ -5909,30 +5943,30 @@ function useTopupForm() {
|
|
|
5909
5943
|
}
|
|
5910
5944
|
|
|
5911
5945
|
// src/TopupForm.tsx
|
|
5912
|
-
var
|
|
5946
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
5913
5947
|
var TopupForm2 = (props) => {
|
|
5914
5948
|
const { className, buttonClassName, submitButtonText, ...rootProps } = props;
|
|
5915
5949
|
const rootClass = ["solvapay-topup-form", className].filter(Boolean).join(" ");
|
|
5916
5950
|
const buttonClass = ["solvapay-topup-form-submit", buttonClassName].filter(Boolean).join(" ");
|
|
5917
|
-
return /* @__PURE__ */ (0,
|
|
5918
|
-
/* @__PURE__ */ (0,
|
|
5919
|
-
/* @__PURE__ */ (0,
|
|
5920
|
-
/* @__PURE__ */ (0,
|
|
5921
|
-
/* @__PURE__ */ (0,
|
|
5951
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(TopupForm.Root, { ...rootProps, className: rootClass, children: [
|
|
5952
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(TopupForm.PaymentElement, {}),
|
|
5953
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(TopupForm.Error, { className: "solvapay-topup-form-error" }),
|
|
5954
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(TopupForm.Loading, { className: "solvapay-topup-form-loading" }),
|
|
5955
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(TopupForm.SubmitButton, { className: buttonClass, children: submitButtonText })
|
|
5922
5956
|
] });
|
|
5923
5957
|
};
|
|
5924
5958
|
|
|
5925
5959
|
// src/primitives/CreditGate.tsx
|
|
5926
|
-
var
|
|
5927
|
-
var CreditGateContext = (0,
|
|
5960
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
5961
|
+
var CreditGateContext = (0, import_react32.createContext)(null);
|
|
5928
5962
|
function useGateCtx(part) {
|
|
5929
|
-
const ctx = (0,
|
|
5963
|
+
const ctx = (0, import_react32.useContext)(CreditGateContext);
|
|
5930
5964
|
if (!ctx) {
|
|
5931
5965
|
throw new Error(`CreditGate.${part} must be rendered inside <CreditGate.Root>.`);
|
|
5932
5966
|
}
|
|
5933
5967
|
return ctx;
|
|
5934
5968
|
}
|
|
5935
|
-
var Root8 = (0,
|
|
5969
|
+
var Root8 = (0, import_react32.forwardRef)(function CreditGateRoot({
|
|
5936
5970
|
minCredits = 1,
|
|
5937
5971
|
productRef,
|
|
5938
5972
|
topupAmount = 1e3,
|
|
@@ -5941,13 +5975,13 @@ var Root8 = (0, import_react31.forwardRef)(function CreditGateRoot({
|
|
|
5941
5975
|
children,
|
|
5942
5976
|
...rest
|
|
5943
5977
|
}, forwardedRef) {
|
|
5944
|
-
const solva = (0,
|
|
5978
|
+
const solva = (0, import_react32.useContext)(SolvaPayContext);
|
|
5945
5979
|
if (!solva) throw new MissingProviderError("CreditGate");
|
|
5946
5980
|
const { credits, loading } = useBalance();
|
|
5947
5981
|
const { product } = useProduct(productRef);
|
|
5948
5982
|
const hasCredits = credits != null && credits >= minCredits;
|
|
5949
5983
|
const state = loading && credits == null ? "loading" : hasCredits ? "allowed" : "blocked";
|
|
5950
|
-
const ctx = (0,
|
|
5984
|
+
const ctx = (0, import_react32.useMemo)(
|
|
5951
5985
|
() => ({
|
|
5952
5986
|
state,
|
|
5953
5987
|
loading,
|
|
@@ -5960,7 +5994,7 @@ var Root8 = (0, import_react31.forwardRef)(function CreditGateRoot({
|
|
|
5960
5994
|
[state, loading, hasCredits, credits, product?.name, topupAmount, topupCurrency]
|
|
5961
5995
|
);
|
|
5962
5996
|
const Comp = asChild ? Slot : "div";
|
|
5963
|
-
return /* @__PURE__ */ (0,
|
|
5997
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(CreditGateContext.Provider, { value: ctx, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
5964
5998
|
Comp,
|
|
5965
5999
|
{
|
|
5966
6000
|
ref: forwardedRef,
|
|
@@ -5971,14 +6005,14 @@ var Root8 = (0, import_react31.forwardRef)(function CreditGateRoot({
|
|
|
5971
6005
|
}
|
|
5972
6006
|
) });
|
|
5973
6007
|
});
|
|
5974
|
-
var Heading3 = (0,
|
|
6008
|
+
var Heading3 = (0, import_react32.forwardRef)(function CreditGateHeading({ asChild, children, ...rest }, forwardedRef) {
|
|
5975
6009
|
const ctx = useGateCtx("Heading");
|
|
5976
6010
|
const copy = useCopy();
|
|
5977
6011
|
if (ctx.state !== "blocked") return null;
|
|
5978
6012
|
const Comp = asChild ? Slot : "h3";
|
|
5979
|
-
return /* @__PURE__ */ (0,
|
|
6013
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Comp, { ref: forwardedRef, "data-solvapay-credit-gate-heading": "", ...rest, children: children ?? copy.creditGate.lowBalanceHeading });
|
|
5980
6014
|
});
|
|
5981
|
-
var Subheading = (0,
|
|
6015
|
+
var Subheading = (0, import_react32.forwardRef)(function CreditGateSubheading({ asChild, children, ...rest }, forwardedRef) {
|
|
5982
6016
|
const ctx = useGateCtx("Subheading");
|
|
5983
6017
|
const copy = useCopy();
|
|
5984
6018
|
if (ctx.state !== "blocked") return null;
|
|
@@ -5986,12 +6020,12 @@ var Subheading = (0, import_react31.forwardRef)(function CreditGateSubheading({
|
|
|
5986
6020
|
product: ctx.productName ?? "this product"
|
|
5987
6021
|
});
|
|
5988
6022
|
const Comp = asChild ? Slot : "p";
|
|
5989
|
-
return /* @__PURE__ */ (0,
|
|
6023
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Comp, { ref: forwardedRef, "data-solvapay-credit-gate-subheading": "", ...rest, children: children ?? text });
|
|
5990
6024
|
});
|
|
5991
6025
|
var Topup = ({ amount, currency }) => {
|
|
5992
6026
|
const ctx = useGateCtx("Topup");
|
|
5993
6027
|
if (ctx.state !== "blocked") return null;
|
|
5994
|
-
return /* @__PURE__ */ (0,
|
|
6028
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
5995
6029
|
TopupForm2,
|
|
5996
6030
|
{
|
|
5997
6031
|
amount: amount ?? ctx.topupAmount,
|
|
@@ -5999,21 +6033,21 @@ var Topup = ({ amount, currency }) => {
|
|
|
5999
6033
|
}
|
|
6000
6034
|
);
|
|
6001
6035
|
};
|
|
6002
|
-
var Loading5 = (0,
|
|
6036
|
+
var Loading5 = (0, import_react32.forwardRef)(function CreditGateLoading({ asChild, children, ...rest }, forwardedRef) {
|
|
6003
6037
|
const ctx = useGateCtx("Loading");
|
|
6004
6038
|
if (ctx.state !== "loading") return null;
|
|
6005
6039
|
const Comp = asChild ? Slot : "div";
|
|
6006
6040
|
return (
|
|
6007
6041
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6008
|
-
/* @__PURE__ */ (0,
|
|
6042
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Comp, { ref: forwardedRef, "data-solvapay-credit-gate-loading": "", ...rest, children })
|
|
6009
6043
|
);
|
|
6010
6044
|
});
|
|
6011
|
-
var ErrorSlot5 = (0,
|
|
6045
|
+
var ErrorSlot5 = (0, import_react32.forwardRef)(function CreditGateError({ asChild, children, ...rest }, forwardedRef) {
|
|
6012
6046
|
if (!children) return null;
|
|
6013
6047
|
const Comp = asChild ? Slot : "div";
|
|
6014
6048
|
return (
|
|
6015
6049
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6016
|
-
/* @__PURE__ */ (0,
|
|
6050
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Comp, { ref: forwardedRef, "data-solvapay-credit-gate-error": "", role: "alert", ...rest, children })
|
|
6017
6051
|
);
|
|
6018
6052
|
});
|
|
6019
6053
|
var CreditGateRoot2 = Root8;
|
|
@@ -6035,29 +6069,29 @@ function useCreditGate() {
|
|
|
6035
6069
|
}
|
|
6036
6070
|
|
|
6037
6071
|
// src/primitives/PurchaseGate.tsx
|
|
6038
|
-
var
|
|
6039
|
-
var
|
|
6040
|
-
var PurchaseGateContext = (0,
|
|
6072
|
+
var import_react33 = require("react");
|
|
6073
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
6074
|
+
var PurchaseGateContext = (0, import_react33.createContext)(null);
|
|
6041
6075
|
function useGateCtx2(part) {
|
|
6042
|
-
const ctx = (0,
|
|
6076
|
+
const ctx = (0, import_react33.useContext)(PurchaseGateContext);
|
|
6043
6077
|
if (!ctx) {
|
|
6044
6078
|
throw new Error(`PurchaseGate.${part} must be rendered inside <PurchaseGate.Root>.`);
|
|
6045
6079
|
}
|
|
6046
6080
|
return ctx;
|
|
6047
6081
|
}
|
|
6048
|
-
var Root9 = (0,
|
|
6049
|
-
const solva = (0,
|
|
6082
|
+
var Root9 = (0, import_react33.forwardRef)(function PurchaseGateRoot({ requirePlan, requireProduct, asChild, children, ...rest }, forwardedRef) {
|
|
6083
|
+
const solva = (0, import_react33.useContext)(SolvaPayContext);
|
|
6050
6084
|
if (!solva) throw new MissingProviderError("PurchaseGate");
|
|
6051
6085
|
const { purchases, loading, hasProduct, error } = usePurchase();
|
|
6052
6086
|
const productToCheck = requireProduct || requirePlan;
|
|
6053
6087
|
const hasAccess = productToCheck ? hasProduct(productToCheck) : purchases.some((p) => p.status === "active");
|
|
6054
6088
|
const state = loading ? "loading" : hasAccess ? "allowed" : "blocked";
|
|
6055
|
-
const ctx = (0,
|
|
6089
|
+
const ctx = (0, import_react33.useMemo)(
|
|
6056
6090
|
() => ({ state, loading, hasAccess, error }),
|
|
6057
6091
|
[state, loading, hasAccess, error]
|
|
6058
6092
|
);
|
|
6059
6093
|
const Comp = asChild ? Slot : "div";
|
|
6060
|
-
return /* @__PURE__ */ (0,
|
|
6094
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(PurchaseGateContext.Provider, { value: ctx, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
6061
6095
|
Comp,
|
|
6062
6096
|
{
|
|
6063
6097
|
ref: forwardedRef,
|
|
@@ -6068,29 +6102,29 @@ var Root9 = (0, import_react32.forwardRef)(function PurchaseGateRoot({ requirePl
|
|
|
6068
6102
|
}
|
|
6069
6103
|
) });
|
|
6070
6104
|
});
|
|
6071
|
-
var Allowed = (0,
|
|
6105
|
+
var Allowed = (0, import_react33.forwardRef)(function PurchaseGateAllowed({ asChild, children, ...rest }, forwardedRef) {
|
|
6072
6106
|
const ctx = useGateCtx2("Allowed");
|
|
6073
6107
|
if (ctx.state !== "allowed") return null;
|
|
6074
6108
|
const Comp = asChild ? Slot : "div";
|
|
6075
|
-
return /* @__PURE__ */ (0,
|
|
6109
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Comp, { ref: forwardedRef, "data-solvapay-purchase-gate-allowed": "", ...rest, children });
|
|
6076
6110
|
});
|
|
6077
|
-
var Blocked = (0,
|
|
6111
|
+
var Blocked = (0, import_react33.forwardRef)(function PurchaseGateBlocked({ asChild, children, ...rest }, forwardedRef) {
|
|
6078
6112
|
const ctx = useGateCtx2("Blocked");
|
|
6079
6113
|
if (ctx.state !== "blocked") return null;
|
|
6080
6114
|
const Comp = asChild ? Slot : "div";
|
|
6081
|
-
return /* @__PURE__ */ (0,
|
|
6115
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Comp, { ref: forwardedRef, "data-solvapay-purchase-gate-blocked": "", ...rest, children });
|
|
6082
6116
|
});
|
|
6083
|
-
var Loading6 = (0,
|
|
6117
|
+
var Loading6 = (0, import_react33.forwardRef)(function PurchaseGateLoading({ asChild, children, ...rest }, forwardedRef) {
|
|
6084
6118
|
const ctx = useGateCtx2("Loading");
|
|
6085
6119
|
if (ctx.state !== "loading") return null;
|
|
6086
6120
|
const Comp = asChild ? Slot : "div";
|
|
6087
|
-
return /* @__PURE__ */ (0,
|
|
6121
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Comp, { ref: forwardedRef, "data-solvapay-purchase-gate-loading": "", ...rest, children });
|
|
6088
6122
|
});
|
|
6089
|
-
var ErrorSlot6 = (0,
|
|
6123
|
+
var ErrorSlot6 = (0, import_react33.forwardRef)(function PurchaseGateError({ asChild, children, ...rest }, forwardedRef) {
|
|
6090
6124
|
const ctx = useGateCtx2("Error");
|
|
6091
6125
|
if (!ctx.error) return null;
|
|
6092
6126
|
const Comp = asChild ? Slot : "div";
|
|
6093
|
-
return /* @__PURE__ */ (0,
|
|
6127
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Comp, { ref: forwardedRef, "data-solvapay-purchase-gate-error": "", role: "alert", ...rest, children: children ?? ctx.error.message });
|
|
6094
6128
|
});
|
|
6095
6129
|
var PurchaseGateRoot2 = Root9;
|
|
6096
6130
|
var PurchaseGateAllowed2 = Allowed;
|
|
@@ -6109,13 +6143,13 @@ function usePurchaseGate() {
|
|
|
6109
6143
|
}
|
|
6110
6144
|
|
|
6111
6145
|
// src/primitives/AutoRecharge.tsx
|
|
6112
|
-
var
|
|
6146
|
+
var import_react35 = require("react");
|
|
6113
6147
|
var import_react_dom = require("react-dom");
|
|
6114
6148
|
var import_react_stripe_js3 = require("@stripe/react-stripe-js");
|
|
6115
6149
|
var import_stripe_js3 = require("@stripe/stripe-js");
|
|
6116
6150
|
|
|
6117
6151
|
// src/hooks/useAutoRecharge.ts
|
|
6118
|
-
var
|
|
6152
|
+
var import_react34 = require("react");
|
|
6119
6153
|
function mergeAutoRechargeConfig(config, display) {
|
|
6120
6154
|
return display ? { ...config, display } : config;
|
|
6121
6155
|
}
|
|
@@ -6129,18 +6163,18 @@ async function fetchAutoRecharge(config) {
|
|
|
6129
6163
|
function useAutoRecharge() {
|
|
6130
6164
|
const { _config } = useSolvaPay();
|
|
6131
6165
|
const key = autoRechargeCacheKeyFor(_config);
|
|
6132
|
-
const [config, setConfig] = (0,
|
|
6166
|
+
const [config, setConfig] = (0, import_react34.useState)(
|
|
6133
6167
|
() => autoRechargeCache.get(key)?.config ?? null
|
|
6134
6168
|
);
|
|
6135
|
-
const [loading, setLoading] = (0,
|
|
6169
|
+
const [loading, setLoading] = (0, import_react34.useState)(() => {
|
|
6136
6170
|
const cached = autoRechargeCache.get(key);
|
|
6137
6171
|
return !cached || !cached.config && !cached.promise;
|
|
6138
6172
|
});
|
|
6139
|
-
const [saving, setSaving] = (0,
|
|
6140
|
-
const [disabling, setDisabling] = (0,
|
|
6141
|
-
const [error, setError] = (0,
|
|
6142
|
-
const requestSeq = (0,
|
|
6143
|
-
const load = (0,
|
|
6173
|
+
const [saving, setSaving] = (0, import_react34.useState)(false);
|
|
6174
|
+
const [disabling, setDisabling] = (0, import_react34.useState)(false);
|
|
6175
|
+
const [error, setError] = (0, import_react34.useState)(null);
|
|
6176
|
+
const requestSeq = (0, import_react34.useRef)(0);
|
|
6177
|
+
const load = (0, import_react34.useCallback)(
|
|
6144
6178
|
async (force = false) => {
|
|
6145
6179
|
const seq = requestSeq.current;
|
|
6146
6180
|
const cached = autoRechargeCache.get(key);
|
|
@@ -6199,10 +6233,10 @@ function useAutoRecharge() {
|
|
|
6199
6233
|
},
|
|
6200
6234
|
[_config, key]
|
|
6201
6235
|
);
|
|
6202
|
-
(0,
|
|
6236
|
+
(0, import_react34.useEffect)(() => {
|
|
6203
6237
|
void load();
|
|
6204
6238
|
}, [load]);
|
|
6205
|
-
(0,
|
|
6239
|
+
(0, import_react34.useEffect)(() => {
|
|
6206
6240
|
return subscribeAutoRecharge(key, () => {
|
|
6207
6241
|
const cached = autoRechargeCache.get(key);
|
|
6208
6242
|
if (cached) {
|
|
@@ -6212,13 +6246,13 @@ function useAutoRecharge() {
|
|
|
6212
6246
|
void load(true);
|
|
6213
6247
|
});
|
|
6214
6248
|
}, [key, load]);
|
|
6215
|
-
const refresh = (0,
|
|
6249
|
+
const refresh = (0, import_react34.useCallback)(
|
|
6216
6250
|
async (force = true) => {
|
|
6217
6251
|
await load(force);
|
|
6218
6252
|
},
|
|
6219
6253
|
[load]
|
|
6220
6254
|
);
|
|
6221
|
-
const save = (0,
|
|
6255
|
+
const save = (0, import_react34.useCallback)(
|
|
6222
6256
|
async (input) => {
|
|
6223
6257
|
const transport = _config?.transport ?? createHttpTransport(_config);
|
|
6224
6258
|
if (!transport.saveAutoRecharge) {
|
|
@@ -6248,7 +6282,7 @@ function useAutoRecharge() {
|
|
|
6248
6282
|
},
|
|
6249
6283
|
[_config, key]
|
|
6250
6284
|
);
|
|
6251
|
-
const disable = (0,
|
|
6285
|
+
const disable = (0, import_react34.useCallback)(async () => {
|
|
6252
6286
|
const transport = _config?.transport ?? createHttpTransport(_config);
|
|
6253
6287
|
if (!transport.disableAutoRecharge) {
|
|
6254
6288
|
throw new Error("disableAutoRecharge is not available on this transport");
|
|
@@ -6613,10 +6647,10 @@ function flipUnitValue(anchor, targetUnit, currency, creditsPerMinorUnit, displa
|
|
|
6613
6647
|
}
|
|
6614
6648
|
|
|
6615
6649
|
// src/primitives/AutoRecharge.tsx
|
|
6616
|
-
var
|
|
6617
|
-
var AutoRechargeContext = (0,
|
|
6650
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
6651
|
+
var AutoRechargeContext = (0, import_react35.createContext)(null);
|
|
6618
6652
|
function useAutoRechargeCtx(part) {
|
|
6619
|
-
const ctx = (0,
|
|
6653
|
+
const ctx = (0, import_react35.useContext)(AutoRechargeContext);
|
|
6620
6654
|
if (!ctx) {
|
|
6621
6655
|
throw new Error(`AutoRecharge.${part} must be rendered inside <AutoRecharge.Root>.`);
|
|
6622
6656
|
}
|
|
@@ -6635,7 +6669,7 @@ var stripePromiseCache3 = /* @__PURE__ */ new Map();
|
|
|
6635
6669
|
function getStripeCacheKey3(publishableKey, accountId) {
|
|
6636
6670
|
return accountId ? `${publishableKey}:${accountId}` : publishableKey;
|
|
6637
6671
|
}
|
|
6638
|
-
var Root10 = (0,
|
|
6672
|
+
var Root10 = (0, import_react35.forwardRef)(function AutoRechargeRoot({
|
|
6639
6673
|
currency = "USD",
|
|
6640
6674
|
defaultThresholdAmountMajor,
|
|
6641
6675
|
defaultTopupAmountMajor,
|
|
@@ -6652,18 +6686,18 @@ var Root10 = (0, import_react34.forwardRef)(function AutoRechargeRoot({
|
|
|
6652
6686
|
className,
|
|
6653
6687
|
...rest
|
|
6654
6688
|
}, forwardedRef) {
|
|
6655
|
-
const solva = (0,
|
|
6689
|
+
const solva = (0, import_react35.useContext)(SolvaPayContext);
|
|
6656
6690
|
if (!solva) throw new MissingProviderError("AutoRecharge");
|
|
6657
6691
|
const autoRecharge = useAutoRecharge();
|
|
6658
6692
|
const { creditsPerMinorUnit, displayExchangeRate } = useBalance();
|
|
6659
6693
|
const copy = useCopy();
|
|
6660
|
-
const titleId = (0,
|
|
6661
|
-
const triggerRef = (0,
|
|
6694
|
+
const titleId = (0, import_react35.useId)();
|
|
6695
|
+
const triggerRef = (0, import_react35.useRef)(null);
|
|
6662
6696
|
const defaultTopup = defaultTopupAmountMajor ?? defaultThresholdAmountMajor ?? void 0;
|
|
6663
|
-
const [uncontrolledOpen, setUncontrolledOpen] = (0,
|
|
6697
|
+
const [uncontrolledOpen, setUncontrolledOpen] = (0, import_react35.useState)(defaultOpen);
|
|
6664
6698
|
const isControlled = openProp !== void 0;
|
|
6665
6699
|
const open = isControlled ? openProp : uncontrolledOpen;
|
|
6666
|
-
const setOpen = (0,
|
|
6700
|
+
const setOpen = (0, import_react35.useCallback)(
|
|
6667
6701
|
(next) => {
|
|
6668
6702
|
if (!isControlled) {
|
|
6669
6703
|
setUncontrolledOpen(next);
|
|
@@ -6672,23 +6706,23 @@ var Root10 = (0, import_react34.forwardRef)(function AutoRechargeRoot({
|
|
|
6672
6706
|
},
|
|
6673
6707
|
[isControlled, onOpenChange]
|
|
6674
6708
|
);
|
|
6675
|
-
const registerTriggerRef = (0,
|
|
6709
|
+
const registerTriggerRef = (0, import_react35.useCallback)((node) => {
|
|
6676
6710
|
triggerRef.current = node;
|
|
6677
6711
|
}, []);
|
|
6678
|
-
const focusTrigger = (0,
|
|
6712
|
+
const focusTrigger = (0, import_react35.useCallback)(() => {
|
|
6679
6713
|
triggerRef.current?.focus();
|
|
6680
6714
|
}, []);
|
|
6681
|
-
const [form, setForm] = (0,
|
|
6715
|
+
const [form, setForm] = (0, import_react35.useState)(
|
|
6682
6716
|
() => autoRecharge.config ? configToForm(autoRecharge.config, currency) : createDefaultAutoRechargeForm(currency, defaultTopup)
|
|
6683
6717
|
);
|
|
6684
|
-
const [validationError, setValidationError] = (0,
|
|
6685
|
-
const [statusMessage, setStatusMessage] = (0,
|
|
6686
|
-
const [setup, setSetup] = (0,
|
|
6687
|
-
const latestConfigRef = (0,
|
|
6688
|
-
(0,
|
|
6718
|
+
const [validationError, setValidationError] = (0, import_react35.useState)(null);
|
|
6719
|
+
const [statusMessage, setStatusMessage] = (0, import_react35.useState)(null);
|
|
6720
|
+
const [setup, setSetup] = (0, import_react35.useState)(null);
|
|
6721
|
+
const latestConfigRef = (0, import_react35.useRef)(autoRecharge.config);
|
|
6722
|
+
(0, import_react35.useEffect)(() => {
|
|
6689
6723
|
latestConfigRef.current = autoRecharge.config;
|
|
6690
6724
|
}, [autoRecharge.config]);
|
|
6691
|
-
(0,
|
|
6725
|
+
(0, import_react35.useEffect)(() => {
|
|
6692
6726
|
if (autoRecharge.config) {
|
|
6693
6727
|
setForm(configToForm(autoRecharge.config, currency));
|
|
6694
6728
|
}
|
|
@@ -6696,7 +6730,7 @@ var Root10 = (0, import_react34.forwardRef)(function AutoRechargeRoot({
|
|
|
6696
6730
|
const canToggleUnits = creditsPerMinorUnit != null && creditsPerMinorUnit > 0;
|
|
6697
6731
|
const rate = displayExchangeRate ?? 1;
|
|
6698
6732
|
const isApproximate = rate !== 1;
|
|
6699
|
-
const emitValidation = (0,
|
|
6733
|
+
const emitValidation = (0, import_react35.useCallback)(
|
|
6700
6734
|
(next) => {
|
|
6701
6735
|
const result = validateAutoRechargeForm(
|
|
6702
6736
|
next,
|
|
@@ -6713,7 +6747,7 @@ var Root10 = (0, import_react34.forwardRef)(function AutoRechargeRoot({
|
|
|
6713
6747
|
},
|
|
6714
6748
|
[currency, creditsPerMinorUnit, displayExchangeRate, copy.autoRecharge]
|
|
6715
6749
|
);
|
|
6716
|
-
const updateForm = (0,
|
|
6750
|
+
const updateForm = (0, import_react35.useCallback)(
|
|
6717
6751
|
(patch) => {
|
|
6718
6752
|
setForm((prev) => {
|
|
6719
6753
|
const next = { ...prev, ...patch };
|
|
@@ -6723,7 +6757,7 @@ var Root10 = (0, import_react34.forwardRef)(function AutoRechargeRoot({
|
|
|
6723
6757
|
},
|
|
6724
6758
|
[emitValidation]
|
|
6725
6759
|
);
|
|
6726
|
-
const resetForm = (0,
|
|
6760
|
+
const resetForm = (0, import_react35.useCallback)(() => {
|
|
6727
6761
|
if (autoRecharge.config) {
|
|
6728
6762
|
setForm(configToForm(autoRecharge.config, currency));
|
|
6729
6763
|
} else {
|
|
@@ -6731,7 +6765,7 @@ var Root10 = (0, import_react34.forwardRef)(function AutoRechargeRoot({
|
|
|
6731
6765
|
}
|
|
6732
6766
|
setValidationError(null);
|
|
6733
6767
|
}, [autoRecharge.config, currency, defaultTopup]);
|
|
6734
|
-
const flipUnit = (0,
|
|
6768
|
+
const flipUnit = (0, import_react35.useCallback)(
|
|
6735
6769
|
(valueKey, unitKey, baseValueKey, baseUnitKey, currentUnit) => {
|
|
6736
6770
|
const nextUnit = currentUnit === "currency" ? "credits" : "currency";
|
|
6737
6771
|
setForm((prev) => {
|
|
@@ -6754,7 +6788,7 @@ var Root10 = (0, import_react34.forwardRef)(function AutoRechargeRoot({
|
|
|
6754
6788
|
},
|
|
6755
6789
|
[currency, creditsPerMinorUnit, displayExchangeRate, emitValidation]
|
|
6756
6790
|
);
|
|
6757
|
-
const fixedTopupHint = (0,
|
|
6791
|
+
const fixedTopupHint = (0, import_react35.useMemo)(() => {
|
|
6758
6792
|
const parsed = Number(form.topupAmountMajor);
|
|
6759
6793
|
if (!Number.isFinite(parsed) || parsed <= 0) return null;
|
|
6760
6794
|
if (form.topupUnit === "currency") {
|
|
@@ -6778,15 +6812,15 @@ var Root10 = (0, import_react34.forwardRef)(function AutoRechargeRoot({
|
|
|
6778
6812
|
displayExchangeRate,
|
|
6779
6813
|
isApproximate
|
|
6780
6814
|
]);
|
|
6781
|
-
const summaryLine = (0,
|
|
6782
|
-
const savedSummaryLine = (0,
|
|
6815
|
+
const summaryLine = (0, import_react35.useMemo)(() => buildSummaryLine(form, currency), [form, currency]);
|
|
6816
|
+
const savedSummaryLine = (0, import_react35.useMemo)(() => {
|
|
6783
6817
|
if (!autoRecharge.config?.enabled) return null;
|
|
6784
6818
|
return buildSummaryLine(
|
|
6785
6819
|
configToForm(autoRecharge.config, currency),
|
|
6786
6820
|
currency
|
|
6787
6821
|
);
|
|
6788
6822
|
}, [autoRecharge.config, currency]);
|
|
6789
|
-
const save = (0,
|
|
6823
|
+
const save = (0, import_react35.useCallback)(async () => {
|
|
6790
6824
|
const payload = emitValidation(form);
|
|
6791
6825
|
if (!payload) return;
|
|
6792
6826
|
const saveInput = deferCardSetup ? { ...payload, deferSetupIntent: true } : payload;
|
|
@@ -6817,13 +6851,13 @@ var Root10 = (0, import_react34.forwardRef)(function AutoRechargeRoot({
|
|
|
6817
6851
|
onSetupRequired,
|
|
6818
6852
|
setOpen
|
|
6819
6853
|
]);
|
|
6820
|
-
const disable = (0,
|
|
6854
|
+
const disable = (0, import_react35.useCallback)(async () => {
|
|
6821
6855
|
await autoRecharge.disable();
|
|
6822
6856
|
setStatusMessage(copy.autoRecharge.disabledMessage);
|
|
6823
6857
|
setSetup(null);
|
|
6824
6858
|
await onDisabled?.();
|
|
6825
6859
|
}, [autoRecharge, copy.autoRecharge, onDisabled]);
|
|
6826
|
-
const completeSetup = (0,
|
|
6860
|
+
const completeSetup = (0, import_react35.useCallback)(async () => {
|
|
6827
6861
|
const activated = await waitForAutoRechargeActivation({
|
|
6828
6862
|
refresh: autoRecharge.refresh,
|
|
6829
6863
|
getStatus: () => latestConfigRef.current?.status
|
|
@@ -6838,7 +6872,7 @@ var Root10 = (0, import_react34.forwardRef)(function AutoRechargeRoot({
|
|
|
6838
6872
|
}
|
|
6839
6873
|
}, [autoRecharge, copy.autoRecharge, form.enabled, setOpen]);
|
|
6840
6874
|
const dataState = setup ? "setup" : autoRecharge.error ? "error" : autoRecharge.loading ? "loading" : autoRecharge.saving ? "saving" : autoRecharge.disabling ? "disabling" : "idle";
|
|
6841
|
-
const ctx = (0,
|
|
6875
|
+
const ctx = (0, import_react35.useMemo)(
|
|
6842
6876
|
() => ({
|
|
6843
6877
|
form,
|
|
6844
6878
|
updateForm,
|
|
@@ -6909,7 +6943,7 @@ var Root10 = (0, import_react34.forwardRef)(function AutoRechargeRoot({
|
|
|
6909
6943
|
]
|
|
6910
6944
|
);
|
|
6911
6945
|
const Comp = asChild ? Slot : "section";
|
|
6912
|
-
return /* @__PURE__ */ (0,
|
|
6946
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(AutoRechargeContext.Provider, { value: ctx, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
6913
6947
|
Comp,
|
|
6914
6948
|
{
|
|
6915
6949
|
ref: forwardedRef,
|
|
@@ -6922,18 +6956,18 @@ var Root10 = (0, import_react34.forwardRef)(function AutoRechargeRoot({
|
|
|
6922
6956
|
}
|
|
6923
6957
|
) });
|
|
6924
6958
|
});
|
|
6925
|
-
var Loading7 = (0,
|
|
6959
|
+
var Loading7 = (0, import_react35.forwardRef)(
|
|
6926
6960
|
function AutoRechargeLoading({ className, children, ...rest }, forwardedRef) {
|
|
6927
6961
|
const ctx = useAutoRechargeCtx("Loading");
|
|
6928
6962
|
if (!ctx.loading) return null;
|
|
6929
|
-
return /* @__PURE__ */ (0,
|
|
6930
|
-
/* @__PURE__ */ (0,
|
|
6963
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { ref: forwardedRef, className, "data-solvapay-auto-recharge-loading": "", ...rest, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
6964
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Spinner, { size: "sm" }),
|
|
6931
6965
|
" Loading auto-recharge settings\u2026"
|
|
6932
6966
|
] }) });
|
|
6933
6967
|
}
|
|
6934
6968
|
);
|
|
6935
|
-
var Card2 = (0,
|
|
6936
|
-
return /* @__PURE__ */ (0,
|
|
6969
|
+
var Card2 = (0, import_react35.forwardRef)(function AutoRechargeCard({ className, children, ...rest }, forwardedRef) {
|
|
6970
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
6937
6971
|
"section",
|
|
6938
6972
|
{
|
|
6939
6973
|
ref: forwardedRef,
|
|
@@ -6944,10 +6978,10 @@ var Card2 = (0, import_react34.forwardRef)(function AutoRechargeCard({ className
|
|
|
6944
6978
|
}
|
|
6945
6979
|
);
|
|
6946
6980
|
});
|
|
6947
|
-
var CardHeading = (0,
|
|
6981
|
+
var CardHeading = (0, import_react35.forwardRef)(
|
|
6948
6982
|
function AutoRechargeCardHeading({ className, children, ...rest }, forwardedRef) {
|
|
6949
6983
|
const copy = useCopy();
|
|
6950
|
-
return /* @__PURE__ */ (0,
|
|
6984
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
6951
6985
|
"h3",
|
|
6952
6986
|
{
|
|
6953
6987
|
ref: forwardedRef,
|
|
@@ -6959,12 +6993,12 @@ var CardHeading = (0, import_react34.forwardRef)(
|
|
|
6959
6993
|
);
|
|
6960
6994
|
}
|
|
6961
6995
|
);
|
|
6962
|
-
var CardSummary = (0,
|
|
6996
|
+
var CardSummary = (0, import_react35.forwardRef)(
|
|
6963
6997
|
function AutoRechargeCardSummary({ className, children, ...rest }, forwardedRef) {
|
|
6964
6998
|
const ctx = useAutoRechargeCtx("CardSummary");
|
|
6965
6999
|
const copy = useCopy();
|
|
6966
7000
|
const text = ctx.savedSummaryLine ?? copy.autoRecharge.notConfiguredHint;
|
|
6967
|
-
return /* @__PURE__ */ (0,
|
|
7001
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
6968
7002
|
"p",
|
|
6969
7003
|
{
|
|
6970
7004
|
ref: forwardedRef,
|
|
@@ -6976,7 +7010,7 @@ var CardSummary = (0, import_react34.forwardRef)(
|
|
|
6976
7010
|
);
|
|
6977
7011
|
}
|
|
6978
7012
|
);
|
|
6979
|
-
var Trigger = (0,
|
|
7013
|
+
var Trigger = (0, import_react35.forwardRef)(function AutoRechargeTrigger({ asChild, onClick, children, className, ...rest }, forwardedRef) {
|
|
6980
7014
|
const ctx = useAutoRechargeCtx("Trigger");
|
|
6981
7015
|
const copy = useCopy();
|
|
6982
7016
|
const hasExistingConfig = Boolean(ctx.config?.enabled);
|
|
@@ -7004,14 +7038,14 @@ var Trigger = (0, import_react34.forwardRef)(function AutoRechargeTrigger({ asCh
|
|
|
7004
7038
|
...rest
|
|
7005
7039
|
};
|
|
7006
7040
|
if (asChild) {
|
|
7007
|
-
return /* @__PURE__ */ (0,
|
|
7041
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Slot, { ref: setRefs, ...commonProps, children: children ?? label });
|
|
7008
7042
|
}
|
|
7009
|
-
return /* @__PURE__ */ (0,
|
|
7043
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("button", { ref: setRefs, ...commonProps, children: children ?? label });
|
|
7010
7044
|
});
|
|
7011
|
-
var Overlay = (0,
|
|
7045
|
+
var Overlay = (0, import_react35.forwardRef)(
|
|
7012
7046
|
function AutoRechargeOverlay({ onClick, className, ...rest }, forwardedRef) {
|
|
7013
7047
|
const ctx = useAutoRechargeCtx("Overlay");
|
|
7014
|
-
return /* @__PURE__ */ (0,
|
|
7048
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
7015
7049
|
"div",
|
|
7016
7050
|
{
|
|
7017
7051
|
ref: forwardedRef,
|
|
@@ -7028,10 +7062,10 @@ var Overlay = (0, import_react34.forwardRef)(
|
|
|
7028
7062
|
);
|
|
7029
7063
|
}
|
|
7030
7064
|
);
|
|
7031
|
-
var Content = (0,
|
|
7065
|
+
var Content = (0, import_react35.forwardRef)(function AutoRechargeContent({ className, children, ...rest }, forwardedRef) {
|
|
7032
7066
|
const ctx = useAutoRechargeCtx("Content");
|
|
7033
|
-
const panelRef = (0,
|
|
7034
|
-
(0,
|
|
7067
|
+
const panelRef = (0, import_react35.useRef)(null);
|
|
7068
|
+
(0, import_react35.useEffect)(() => {
|
|
7035
7069
|
if (!ctx.open) return;
|
|
7036
7070
|
const handleKeyDown = (event) => {
|
|
7037
7071
|
if (event.key === "Escape") {
|
|
@@ -7051,9 +7085,9 @@ var Content = (0, import_react34.forwardRef)(function AutoRechargeContent({ clas
|
|
|
7051
7085
|
}, [ctx.open, ctx.resetForm, ctx.setOpen, ctx.focusTrigger]);
|
|
7052
7086
|
if (!ctx.open || typeof document === "undefined") return null;
|
|
7053
7087
|
return (0, import_react_dom.createPortal)(
|
|
7054
|
-
/* @__PURE__ */ (0,
|
|
7055
|
-
/* @__PURE__ */ (0,
|
|
7056
|
-
/* @__PURE__ */ (0,
|
|
7088
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { "data-solvapay-auto-recharge-portal": "", children: [
|
|
7089
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Overlay, {}),
|
|
7090
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
7057
7091
|
"div",
|
|
7058
7092
|
{
|
|
7059
7093
|
ref: (node) => {
|
|
@@ -7077,11 +7111,11 @@ var Content = (0, import_react34.forwardRef)(function AutoRechargeContent({ clas
|
|
|
7077
7111
|
document.body
|
|
7078
7112
|
);
|
|
7079
7113
|
});
|
|
7080
|
-
var Title = (0,
|
|
7114
|
+
var Title = (0, import_react35.forwardRef)(
|
|
7081
7115
|
function AutoRechargeTitle({ className, children, ...rest }, forwardedRef) {
|
|
7082
7116
|
const ctx = useAutoRechargeCtx("Title");
|
|
7083
7117
|
const copy = useCopy();
|
|
7084
|
-
return /* @__PURE__ */ (0,
|
|
7118
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
7085
7119
|
"h2",
|
|
7086
7120
|
{
|
|
7087
7121
|
ref: forwardedRef,
|
|
@@ -7094,16 +7128,16 @@ var Title = (0, import_react34.forwardRef)(
|
|
|
7094
7128
|
);
|
|
7095
7129
|
}
|
|
7096
7130
|
);
|
|
7097
|
-
var EnableQuestion = (0,
|
|
7131
|
+
var EnableQuestion = (0, import_react35.forwardRef)(
|
|
7098
7132
|
function AutoRechargeEnableQuestion({ className, children, ...rest }, forwardedRef) {
|
|
7099
7133
|
const copy = useCopy();
|
|
7100
|
-
return /* @__PURE__ */ (0,
|
|
7134
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { ref: forwardedRef, className, "data-solvapay-auto-recharge-question": "", ...rest, children: children ?? copy.autoRecharge.enableQuestion });
|
|
7101
7135
|
}
|
|
7102
7136
|
);
|
|
7103
|
-
var EnableSentence = (0,
|
|
7137
|
+
var EnableSentence = (0, import_react35.forwardRef)(
|
|
7104
7138
|
function AutoRechargeEnableSentence({ className, children, ...rest }, forwardedRef) {
|
|
7105
7139
|
const copy = useCopy();
|
|
7106
|
-
return /* @__PURE__ */ (0,
|
|
7140
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
7107
7141
|
"label",
|
|
7108
7142
|
{
|
|
7109
7143
|
ref: forwardedRef,
|
|
@@ -7115,25 +7149,25 @@ var EnableSentence = (0, import_react34.forwardRef)(
|
|
|
7115
7149
|
);
|
|
7116
7150
|
}
|
|
7117
7151
|
);
|
|
7118
|
-
var EnableRow = (0,
|
|
7152
|
+
var EnableRow = (0, import_react35.forwardRef)(
|
|
7119
7153
|
function AutoRechargeEnableRow({ className, children, ...rest }, forwardedRef) {
|
|
7120
|
-
const enableId = (0,
|
|
7121
|
-
return /* @__PURE__ */ (0,
|
|
7154
|
+
const enableId = (0, import_react35.useId)();
|
|
7155
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
7122
7156
|
"div",
|
|
7123
7157
|
{
|
|
7124
7158
|
ref: forwardedRef,
|
|
7125
7159
|
className,
|
|
7126
7160
|
"data-solvapay-auto-recharge-enable-row": "",
|
|
7127
7161
|
...rest,
|
|
7128
|
-
children: children ?? /* @__PURE__ */ (0,
|
|
7129
|
-
/* @__PURE__ */ (0,
|
|
7130
|
-
/* @__PURE__ */ (0,
|
|
7162
|
+
children: children ?? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
7163
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(EnableSwitch, { appearance: "checkbox", id: enableId }),
|
|
7164
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(EnableSentence, { htmlFor: enableId })
|
|
7131
7165
|
] })
|
|
7132
7166
|
}
|
|
7133
7167
|
);
|
|
7134
7168
|
}
|
|
7135
7169
|
);
|
|
7136
|
-
var CancelButton = (0,
|
|
7170
|
+
var CancelButton = (0, import_react35.forwardRef)(
|
|
7137
7171
|
function AutoRechargeCancelButton({ asChild, onClick, children, className, ...rest }, forwardedRef) {
|
|
7138
7172
|
const ctx = useAutoRechargeCtx("CancelButton");
|
|
7139
7173
|
const copy = useCopy();
|
|
@@ -7150,7 +7184,7 @@ var CancelButton = (0, import_react34.forwardRef)(
|
|
|
7150
7184
|
...rest
|
|
7151
7185
|
};
|
|
7152
7186
|
if (asChild) {
|
|
7153
|
-
return /* @__PURE__ */ (0,
|
|
7187
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
7154
7188
|
Slot,
|
|
7155
7189
|
{
|
|
7156
7190
|
ref: forwardedRef,
|
|
@@ -7159,14 +7193,14 @@ var CancelButton = (0, import_react34.forwardRef)(
|
|
|
7159
7193
|
}
|
|
7160
7194
|
);
|
|
7161
7195
|
}
|
|
7162
|
-
return /* @__PURE__ */ (0,
|
|
7196
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("button", { ref: forwardedRef, ...commonProps, children: children ?? copy.autoRecharge.cancelButton });
|
|
7163
7197
|
}
|
|
7164
7198
|
);
|
|
7165
|
-
var Header = (0,
|
|
7199
|
+
var Header = (0, import_react35.forwardRef)(
|
|
7166
7200
|
function AutoRechargeHeader({ className, ...rest }, forwardedRef) {
|
|
7167
7201
|
const copy = useCopy();
|
|
7168
|
-
const headingId = (0,
|
|
7169
|
-
return /* @__PURE__ */ (0,
|
|
7202
|
+
const headingId = (0, import_react35.useId)();
|
|
7203
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
7170
7204
|
"header",
|
|
7171
7205
|
{
|
|
7172
7206
|
ref: forwardedRef,
|
|
@@ -7174,20 +7208,20 @@ var Header = (0, import_react34.forwardRef)(
|
|
|
7174
7208
|
"data-solvapay-auto-recharge-header": "",
|
|
7175
7209
|
...rest,
|
|
7176
7210
|
children: [
|
|
7177
|
-
/* @__PURE__ */ (0,
|
|
7178
|
-
/* @__PURE__ */ (0,
|
|
7179
|
-
/* @__PURE__ */ (0,
|
|
7211
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("section", { "data-solvapay-auto-recharge-heading-group": "", children: [
|
|
7212
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("h3", { id: headingId, "data-solvapay-auto-recharge-heading": "", children: copy.autoRecharge.heading }),
|
|
7213
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Description, {})
|
|
7180
7214
|
] }),
|
|
7181
|
-
/* @__PURE__ */ (0,
|
|
7215
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(EnableSwitch, { "aria-labelledby": headingId })
|
|
7182
7216
|
]
|
|
7183
7217
|
}
|
|
7184
7218
|
);
|
|
7185
7219
|
}
|
|
7186
7220
|
);
|
|
7187
|
-
var Description = (0,
|
|
7221
|
+
var Description = (0, import_react35.forwardRef)(
|
|
7188
7222
|
function AutoRechargeDescription({ className, children, ...rest }, forwardedRef) {
|
|
7189
7223
|
const copy = useCopy();
|
|
7190
|
-
return /* @__PURE__ */ (0,
|
|
7224
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
7191
7225
|
"p",
|
|
7192
7226
|
{
|
|
7193
7227
|
ref: forwardedRef,
|
|
@@ -7199,7 +7233,7 @@ var Description = (0, import_react34.forwardRef)(
|
|
|
7199
7233
|
);
|
|
7200
7234
|
}
|
|
7201
7235
|
);
|
|
7202
|
-
var EnableSwitch = (0,
|
|
7236
|
+
var EnableSwitch = (0, import_react35.forwardRef)(
|
|
7203
7237
|
function AutoRechargeEnableSwitch({ asChild, appearance = "switch", onChange, className, ...rest }, forwardedRef) {
|
|
7204
7238
|
const ctx = useAutoRechargeCtx("EnableSwitch");
|
|
7205
7239
|
const copy = useCopy();
|
|
@@ -7218,7 +7252,7 @@ var EnableSwitch = (0, import_react34.forwardRef)(
|
|
|
7218
7252
|
...rest
|
|
7219
7253
|
};
|
|
7220
7254
|
if (asChild) {
|
|
7221
|
-
return /* @__PURE__ */ (0,
|
|
7255
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
7222
7256
|
Slot,
|
|
7223
7257
|
{
|
|
7224
7258
|
ref: forwardedRef,
|
|
@@ -7226,15 +7260,15 @@ var EnableSwitch = (0, import_react34.forwardRef)(
|
|
|
7226
7260
|
}
|
|
7227
7261
|
);
|
|
7228
7262
|
}
|
|
7229
|
-
return /* @__PURE__ */ (0,
|
|
7263
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("input", { ref: forwardedRef, ...commonProps });
|
|
7230
7264
|
}
|
|
7231
7265
|
);
|
|
7232
|
-
var Fields = (0,
|
|
7266
|
+
var Fields = (0, import_react35.forwardRef)(
|
|
7233
7267
|
function AutoRechargeFields({ className, children, ...rest }, forwardedRef) {
|
|
7234
7268
|
const ctx = useAutoRechargeCtx("Fields");
|
|
7235
7269
|
const copy = useCopy();
|
|
7236
7270
|
if (!ctx.form.enabled) return null;
|
|
7237
|
-
return /* @__PURE__ */ (0,
|
|
7271
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
7238
7272
|
"fieldset",
|
|
7239
7273
|
{
|
|
7240
7274
|
ref: forwardedRef,
|
|
@@ -7245,64 +7279,64 @@ var Fields = (0, import_react34.forwardRef)(
|
|
|
7245
7279
|
"data-state": "open",
|
|
7246
7280
|
...rest,
|
|
7247
7281
|
children: [
|
|
7248
|
-
/* @__PURE__ */ (0,
|
|
7249
|
-
children ?? /* @__PURE__ */ (0,
|
|
7250
|
-
/* @__PURE__ */ (0,
|
|
7251
|
-
/* @__PURE__ */ (0,
|
|
7252
|
-
/* @__PURE__ */ (0,
|
|
7253
|
-
/* @__PURE__ */ (0,
|
|
7254
|
-
/* @__PURE__ */ (0,
|
|
7282
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("legend", { className: "sr-only", children: copy.autoRecharge.heading }),
|
|
7283
|
+
children ?? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
7284
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Summary4, {}),
|
|
7285
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ThresholdField, {}),
|
|
7286
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(TopupField, {}),
|
|
7287
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(MaxMonthlySpendField, {}),
|
|
7288
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ValidationError, {})
|
|
7255
7289
|
] })
|
|
7256
7290
|
]
|
|
7257
7291
|
}
|
|
7258
7292
|
);
|
|
7259
7293
|
}
|
|
7260
7294
|
);
|
|
7261
|
-
var Setup = (0,
|
|
7295
|
+
var Setup = (0, import_react35.forwardRef)(
|
|
7262
7296
|
function AutoRechargeSetup({ className, children, ...rest }, forwardedRef) {
|
|
7263
7297
|
const ctx = useAutoRechargeCtx("Setup");
|
|
7264
7298
|
if (!ctx.setup?.setupClientSecret) return null;
|
|
7265
|
-
return /* @__PURE__ */ (0,
|
|
7299
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
7266
7300
|
"div",
|
|
7267
7301
|
{
|
|
7268
7302
|
ref: forwardedRef,
|
|
7269
7303
|
className,
|
|
7270
7304
|
"data-solvapay-auto-recharge-setup-panel": "",
|
|
7271
7305
|
...rest,
|
|
7272
|
-
children: children ?? /* @__PURE__ */ (0,
|
|
7306
|
+
children: children ?? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(CardSetup, { setup: ctx.setup, onComplete: ctx.completeSetup })
|
|
7273
7307
|
}
|
|
7274
7308
|
);
|
|
7275
7309
|
}
|
|
7276
7310
|
);
|
|
7277
|
-
var Body = (0,
|
|
7311
|
+
var Body = (0, import_react35.forwardRef)(
|
|
7278
7312
|
function AutoRechargeBody({ className, children, ...rest }, forwardedRef) {
|
|
7279
7313
|
const ctx = useAutoRechargeCtx("Body");
|
|
7280
7314
|
if (ctx.setup?.setupClientSecret) {
|
|
7281
|
-
return /* @__PURE__ */ (0,
|
|
7315
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Setup, { className });
|
|
7282
7316
|
}
|
|
7283
7317
|
if (!ctx.form.enabled) return null;
|
|
7284
|
-
return /* @__PURE__ */ (0,
|
|
7285
|
-
/* @__PURE__ */ (0,
|
|
7286
|
-
/* @__PURE__ */ (0,
|
|
7287
|
-
/* @__PURE__ */ (0,
|
|
7288
|
-
/* @__PURE__ */ (0,
|
|
7289
|
-
/* @__PURE__ */ (0,
|
|
7290
|
-
/* @__PURE__ */ (0,
|
|
7318
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Fields, { ref: forwardedRef, className, ...rest, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
7319
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Summary4, {}),
|
|
7320
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ThresholdField, {}),
|
|
7321
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(TopupField, {}),
|
|
7322
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(MaxMonthlySpendField, {}),
|
|
7323
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ValidationError, {}),
|
|
7324
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Actions, {})
|
|
7291
7325
|
] }) });
|
|
7292
7326
|
}
|
|
7293
7327
|
);
|
|
7294
|
-
var Summary4 = (0,
|
|
7328
|
+
var Summary4 = (0, import_react35.forwardRef)(
|
|
7295
7329
|
function AutoRechargeSummary({ className, children, ...rest }, forwardedRef) {
|
|
7296
7330
|
const ctx = useAutoRechargeCtx("Summary");
|
|
7297
7331
|
const copy = useCopy();
|
|
7298
7332
|
if (!ctx.summaryLine) return null;
|
|
7299
|
-
return /* @__PURE__ */ (0,
|
|
7300
|
-
/* @__PURE__ */ (0,
|
|
7301
|
-
/* @__PURE__ */ (0,
|
|
7333
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { "data-solvapay-auto-recharge-summary": "", children: [
|
|
7334
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { ref: forwardedRef, className, ...rest, children: children ?? ctx.summaryLine }),
|
|
7335
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "text-xs text-muted-foreground", children: copy.autoRecharge.taxDisclosure })
|
|
7302
7336
|
] });
|
|
7303
7337
|
}
|
|
7304
7338
|
);
|
|
7305
|
-
var AmountField = (0,
|
|
7339
|
+
var AmountField = (0, import_react35.forwardRef)(function AutoRechargeAmountField({ field, showLabel = true, asChild, onChange, className, ...rest }, forwardedRef) {
|
|
7306
7340
|
const ctx = useAutoRechargeCtx("AmountField");
|
|
7307
7341
|
const copy = useCopy();
|
|
7308
7342
|
const fieldConfig = {
|
|
@@ -7341,7 +7375,7 @@ var AmountField = (0, import_react34.forwardRef)(function AutoRechargeAmountFiel
|
|
|
7341
7375
|
})
|
|
7342
7376
|
}
|
|
7343
7377
|
}[field];
|
|
7344
|
-
const inputId = (0,
|
|
7378
|
+
const inputId = (0, import_react35.useId)();
|
|
7345
7379
|
const prefix = fieldConfig.mode === "currency" ? getCurrencySymbol2(ctx.currency) : void 0;
|
|
7346
7380
|
const handleChange = (event) => {
|
|
7347
7381
|
const raw = event.target.value;
|
|
@@ -7362,12 +7396,12 @@ var AmountField = (0, import_react34.forwardRef)(function AutoRechargeAmountFiel
|
|
|
7362
7396
|
...rest
|
|
7363
7397
|
};
|
|
7364
7398
|
const slotRef = forwardedRef;
|
|
7365
|
-
return /* @__PURE__ */ (0,
|
|
7366
|
-
showLabel ? /* @__PURE__ */ (0,
|
|
7367
|
-
/* @__PURE__ */ (0,
|
|
7368
|
-
prefix ? /* @__PURE__ */ (0,
|
|
7369
|
-
asChild ? /* @__PURE__ */ (0,
|
|
7370
|
-
ctx.canToggleUnits ? /* @__PURE__ */ (0,
|
|
7399
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("p", { "data-solvapay-auto-recharge-field": "", "data-field": field, children: [
|
|
7400
|
+
showLabel ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("label", { htmlFor: inputId, children: fieldConfig.label }) : null,
|
|
7401
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("span", { "data-solvapay-auto-recharge-amount-row": "", children: [
|
|
7402
|
+
prefix ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { "data-solvapay-auto-recharge-currency-prefix": "", "aria-hidden": "true", children: prefix }) : null,
|
|
7403
|
+
asChild ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Slot, { ref: slotRef, ...inputProps }) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("input", { ref: forwardedRef, ...inputProps }),
|
|
7404
|
+
ctx.canToggleUnits ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
7371
7405
|
UnitToggle,
|
|
7372
7406
|
{
|
|
7373
7407
|
unit: fieldConfig.unit,
|
|
@@ -7384,14 +7418,14 @@ var AmountField = (0, import_react34.forwardRef)(function AutoRechargeAmountFiel
|
|
|
7384
7418
|
] })
|
|
7385
7419
|
] });
|
|
7386
7420
|
});
|
|
7387
|
-
var ThresholdField = (0,
|
|
7421
|
+
var ThresholdField = (0, import_react35.forwardRef)(
|
|
7388
7422
|
function AutoRechargeThresholdField({ className, ...rest }, ref) {
|
|
7389
|
-
return /* @__PURE__ */ (0,
|
|
7423
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("section", { ref, className, ...rest, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(AmountField, { field: "threshold" }) });
|
|
7390
7424
|
}
|
|
7391
7425
|
);
|
|
7392
|
-
var TopupField = (0,
|
|
7426
|
+
var TopupField = (0, import_react35.forwardRef)(
|
|
7393
7427
|
function AutoRechargeTopupField({ className, ...rest }, ref) {
|
|
7394
|
-
return /* @__PURE__ */ (0,
|
|
7428
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
7395
7429
|
"section",
|
|
7396
7430
|
{
|
|
7397
7431
|
ref,
|
|
@@ -7399,27 +7433,27 @@ var TopupField = (0, import_react34.forwardRef)(
|
|
|
7399
7433
|
"data-solvapay-auto-recharge-topup-field": "",
|
|
7400
7434
|
...rest,
|
|
7401
7435
|
children: [
|
|
7402
|
-
/* @__PURE__ */ (0,
|
|
7403
|
-
/* @__PURE__ */ (0,
|
|
7436
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(AmountField, { field: "fixed" }),
|
|
7437
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Hint, {})
|
|
7404
7438
|
]
|
|
7405
7439
|
}
|
|
7406
7440
|
);
|
|
7407
7441
|
}
|
|
7408
7442
|
);
|
|
7409
|
-
var MaxMonthlySpendField = (0,
|
|
7443
|
+
var MaxMonthlySpendField = (0, import_react35.forwardRef)(function AutoRechargeMaxMonthlySpendField({ onChange, className, ...rest }, forwardedRef) {
|
|
7410
7444
|
const ctx = useAutoRechargeCtx("MaxMonthlySpendField");
|
|
7411
7445
|
const copy = useCopy();
|
|
7412
|
-
const inputId = (0,
|
|
7446
|
+
const inputId = (0, import_react35.useId)();
|
|
7413
7447
|
const prefix = getCurrencySymbol2(ctx.currency);
|
|
7414
7448
|
const handleChange = (event) => {
|
|
7415
7449
|
const raw = event.target.value.replace(/[^0-9.]/g, "");
|
|
7416
7450
|
ctx.updateForm({ maxMonthlySpendMajor: raw });
|
|
7417
7451
|
};
|
|
7418
|
-
return /* @__PURE__ */ (0,
|
|
7419
|
-
/* @__PURE__ */ (0,
|
|
7420
|
-
/* @__PURE__ */ (0,
|
|
7421
|
-
/* @__PURE__ */ (0,
|
|
7422
|
-
/* @__PURE__ */ (0,
|
|
7452
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("section", { "data-solvapay-auto-recharge-field": "", "data-field": "max-monthly-spend", children: [
|
|
7453
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("label", { htmlFor: inputId, children: copy.autoRecharge.maxMonthlySpendLabel }),
|
|
7454
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("span", { "data-solvapay-auto-recharge-amount-row": "", children: [
|
|
7455
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { "data-solvapay-auto-recharge-currency-prefix": "", "aria-hidden": "true", children: prefix }),
|
|
7456
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
7423
7457
|
"input",
|
|
7424
7458
|
{
|
|
7425
7459
|
ref: forwardedRef,
|
|
@@ -7437,16 +7471,16 @@ var MaxMonthlySpendField = (0, import_react34.forwardRef)(function AutoRechargeM
|
|
|
7437
7471
|
}
|
|
7438
7472
|
)
|
|
7439
7473
|
] }),
|
|
7440
|
-
/* @__PURE__ */ (0,
|
|
7474
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { "data-solvapay-auto-recharge-max-spend-helper": "", children: copy.autoRecharge.maxMonthlySpendHelper })
|
|
7441
7475
|
] });
|
|
7442
7476
|
});
|
|
7443
|
-
var MonthlySpend = (0,
|
|
7477
|
+
var MonthlySpend = (0, import_react35.forwardRef)(
|
|
7444
7478
|
function AutoRechargeMonthlySpend({ className, children, ...rest }, forwardedRef) {
|
|
7445
7479
|
const ctx = useAutoRechargeCtx("MonthlySpend");
|
|
7446
7480
|
const copy = useCopy();
|
|
7447
7481
|
if (!ctx.config?.maxMonthlySpendMinor) return null;
|
|
7448
7482
|
const spent = effectiveMonthlySpend(ctx.config);
|
|
7449
|
-
return /* @__PURE__ */ (0,
|
|
7483
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
7450
7484
|
"p",
|
|
7451
7485
|
{
|
|
7452
7486
|
ref: forwardedRef,
|
|
@@ -7461,10 +7495,10 @@ var MonthlySpend = (0, import_react34.forwardRef)(
|
|
|
7461
7495
|
);
|
|
7462
7496
|
}
|
|
7463
7497
|
);
|
|
7464
|
-
var UnitToggle = (0,
|
|
7498
|
+
var UnitToggle = (0, import_react35.forwardRef)(function AutoRechargeUnitToggle({ unit, fieldLabel, onToggle, className, ...rest }, forwardedRef) {
|
|
7465
7499
|
const ctx = useAutoRechargeCtx("UnitToggle");
|
|
7466
7500
|
const targetUnitLabel = unit === "currency" ? "credits" : "currency";
|
|
7467
|
-
return /* @__PURE__ */ (0,
|
|
7501
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
7468
7502
|
"button",
|
|
7469
7503
|
{
|
|
7470
7504
|
ref: forwardedRef,
|
|
@@ -7478,7 +7512,7 @@ var UnitToggle = (0, import_react34.forwardRef)(function AutoRechargeUnitToggle(
|
|
|
7478
7512
|
}
|
|
7479
7513
|
);
|
|
7480
7514
|
});
|
|
7481
|
-
var Hint = (0,
|
|
7515
|
+
var Hint = (0, import_react35.forwardRef)(
|
|
7482
7516
|
function AutoRechargeHint({ className, ...rest }, forwardedRef) {
|
|
7483
7517
|
const ctx = useAutoRechargeCtx("Hint");
|
|
7484
7518
|
const copy = useCopy();
|
|
@@ -7492,13 +7526,13 @@ var Hint = (0, import_react34.forwardRef)(
|
|
|
7492
7526
|
ctx.isApproximate ? copy.autoRecharge.currencyPerRechargeApprox : copy.autoRecharge.currencyPerRecharge,
|
|
7493
7527
|
{ amount: hint }
|
|
7494
7528
|
);
|
|
7495
|
-
return /* @__PURE__ */ (0,
|
|
7529
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { ref: forwardedRef, className, "data-solvapay-auto-recharge-hint": "", ...rest, children: text });
|
|
7496
7530
|
}
|
|
7497
7531
|
);
|
|
7498
|
-
var ValidationError = (0,
|
|
7532
|
+
var ValidationError = (0, import_react35.forwardRef)(function AutoRechargeValidationError({ className, ...rest }, forwardedRef) {
|
|
7499
7533
|
const ctx = useAutoRechargeCtx("ValidationError");
|
|
7500
7534
|
if (!ctx.validationError) return null;
|
|
7501
|
-
return /* @__PURE__ */ (0,
|
|
7535
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
7502
7536
|
"p",
|
|
7503
7537
|
{
|
|
7504
7538
|
ref: forwardedRef,
|
|
@@ -7511,24 +7545,24 @@ var ValidationError = (0, import_react34.forwardRef)(function AutoRechargeValida
|
|
|
7511
7545
|
}
|
|
7512
7546
|
);
|
|
7513
7547
|
});
|
|
7514
|
-
var Actions = (0,
|
|
7548
|
+
var Actions = (0, import_react35.forwardRef)(
|
|
7515
7549
|
function AutoRechargeActions({ className, children, ...rest }, forwardedRef) {
|
|
7516
|
-
return /* @__PURE__ */ (0,
|
|
7550
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
7517
7551
|
"menu",
|
|
7518
7552
|
{
|
|
7519
7553
|
ref: forwardedRef,
|
|
7520
7554
|
className,
|
|
7521
7555
|
"data-solvapay-auto-recharge-actions": "",
|
|
7522
7556
|
...rest,
|
|
7523
|
-
children: children ?? /* @__PURE__ */ (0,
|
|
7524
|
-
/* @__PURE__ */ (0,
|
|
7525
|
-
/* @__PURE__ */ (0,
|
|
7557
|
+
children: children ?? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
7558
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(CancelButton, {}) }),
|
|
7559
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SaveButton, {}) })
|
|
7526
7560
|
] })
|
|
7527
7561
|
}
|
|
7528
7562
|
);
|
|
7529
7563
|
}
|
|
7530
7564
|
);
|
|
7531
|
-
var SaveButton = (0,
|
|
7565
|
+
var SaveButton = (0, import_react35.forwardRef)(function AutoRechargeSaveButton({ asChild, onClick, children, className, ...rest }, forwardedRef) {
|
|
7532
7566
|
const ctx = useAutoRechargeCtx("SaveButton");
|
|
7533
7567
|
const copy = useCopy();
|
|
7534
7568
|
const dataState = ctx.saving ? "processing" : ctx.validationError ? "disabled" : "idle";
|
|
@@ -7545,13 +7579,13 @@ var SaveButton = (0, import_react34.forwardRef)(function AutoRechargeSaveButton(
|
|
|
7545
7579
|
className,
|
|
7546
7580
|
...rest
|
|
7547
7581
|
};
|
|
7548
|
-
const content = ctx.saving ? /* @__PURE__ */ (0,
|
|
7549
|
-
/* @__PURE__ */ (0,
|
|
7582
|
+
const content = ctx.saving ? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
7583
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Spinner, { size: "sm" }),
|
|
7550
7584
|
" ",
|
|
7551
7585
|
copy.cta.processing
|
|
7552
7586
|
] }) : children ?? copy.autoRecharge.saveButton;
|
|
7553
7587
|
if (asChild) {
|
|
7554
|
-
return /* @__PURE__ */ (0,
|
|
7588
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
7555
7589
|
Slot,
|
|
7556
7590
|
{
|
|
7557
7591
|
ref: forwardedRef,
|
|
@@ -7560,9 +7594,9 @@ var SaveButton = (0, import_react34.forwardRef)(function AutoRechargeSaveButton(
|
|
|
7560
7594
|
}
|
|
7561
7595
|
);
|
|
7562
7596
|
}
|
|
7563
|
-
return /* @__PURE__ */ (0,
|
|
7597
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("button", { ref: forwardedRef, ...commonProps, children: content });
|
|
7564
7598
|
});
|
|
7565
|
-
var DisableButton = (0,
|
|
7599
|
+
var DisableButton = (0, import_react35.forwardRef)(
|
|
7566
7600
|
function AutoRechargeDisableButton({ asChild, onClick, children, className, ...rest }, forwardedRef) {
|
|
7567
7601
|
const ctx = useAutoRechargeCtx("DisableButton");
|
|
7568
7602
|
const copy = useCopy();
|
|
@@ -7580,7 +7614,7 @@ var DisableButton = (0, import_react34.forwardRef)(
|
|
|
7580
7614
|
...rest
|
|
7581
7615
|
};
|
|
7582
7616
|
if (asChild) {
|
|
7583
|
-
return /* @__PURE__ */ (0,
|
|
7617
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
7584
7618
|
Slot,
|
|
7585
7619
|
{
|
|
7586
7620
|
ref: forwardedRef,
|
|
@@ -7589,14 +7623,14 @@ var DisableButton = (0, import_react34.forwardRef)(
|
|
|
7589
7623
|
}
|
|
7590
7624
|
);
|
|
7591
7625
|
}
|
|
7592
|
-
return /* @__PURE__ */ (0,
|
|
7626
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("button", { ref: forwardedRef, ...commonProps, children: children ?? copy.autoRecharge.disableButton });
|
|
7593
7627
|
}
|
|
7594
7628
|
);
|
|
7595
|
-
var ErrorSlot7 = (0,
|
|
7629
|
+
var ErrorSlot7 = (0, import_react35.forwardRef)(
|
|
7596
7630
|
function AutoRechargeError({ className, children, ...rest }, forwardedRef) {
|
|
7597
7631
|
const ctx = useAutoRechargeCtx("Error");
|
|
7598
7632
|
if (!ctx.error) return null;
|
|
7599
|
-
return /* @__PURE__ */ (0,
|
|
7633
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
7600
7634
|
"p",
|
|
7601
7635
|
{
|
|
7602
7636
|
ref: forwardedRef,
|
|
@@ -7610,11 +7644,11 @@ var ErrorSlot7 = (0, import_react34.forwardRef)(
|
|
|
7610
7644
|
);
|
|
7611
7645
|
}
|
|
7612
7646
|
);
|
|
7613
|
-
var StatusMessage = (0,
|
|
7647
|
+
var StatusMessage = (0, import_react35.forwardRef)(
|
|
7614
7648
|
function AutoRechargeStatusMessage({ className, children, ...rest }, forwardedRef) {
|
|
7615
7649
|
const ctx = useAutoRechargeCtx("StatusMessage");
|
|
7616
7650
|
if (!ctx.statusMessage) return null;
|
|
7617
|
-
return /* @__PURE__ */ (0,
|
|
7651
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
7618
7652
|
"p",
|
|
7619
7653
|
{
|
|
7620
7654
|
ref: forwardedRef,
|
|
@@ -7627,7 +7661,7 @@ var StatusMessage = (0, import_react34.forwardRef)(
|
|
|
7627
7661
|
);
|
|
7628
7662
|
}
|
|
7629
7663
|
);
|
|
7630
|
-
var Status = (0,
|
|
7664
|
+
var Status = (0, import_react35.forwardRef)(
|
|
7631
7665
|
function AutoRechargeStatus({ className, ...rest }, forwardedRef) {
|
|
7632
7666
|
const ctx = useAutoRechargeCtx("Status");
|
|
7633
7667
|
const copy = useCopy();
|
|
@@ -7636,7 +7670,7 @@ var Status = (0, import_react34.forwardRef)(
|
|
|
7636
7670
|
const failedLabel = status === "failed" ? copy.autoRecharge.statusFailed : null;
|
|
7637
7671
|
const capLabel = monthlyCapReached ? copy.autoRecharge.statusMonthlyCapReached : null;
|
|
7638
7672
|
if (!failedLabel && !capLabel) return null;
|
|
7639
|
-
return /* @__PURE__ */ (0,
|
|
7673
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
7640
7674
|
"div",
|
|
7641
7675
|
{
|
|
7642
7676
|
ref: forwardedRef,
|
|
@@ -7644,8 +7678,8 @@ var Status = (0, import_react34.forwardRef)(
|
|
|
7644
7678
|
"data-solvapay-auto-recharge-status-group": "",
|
|
7645
7679
|
...rest,
|
|
7646
7680
|
children: [
|
|
7647
|
-
failedLabel ? /* @__PURE__ */ (0,
|
|
7648
|
-
capLabel ? /* @__PURE__ */ (0,
|
|
7681
|
+
failedLabel ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { "data-solvapay-auto-recharge-status": "", "data-status": "failed", children: failedLabel }) : null,
|
|
7682
|
+
capLabel ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { "data-solvapay-auto-recharge-status": "", "data-status": "monthly-cap-reached", children: capLabel }) : null
|
|
7649
7683
|
]
|
|
7650
7684
|
}
|
|
7651
7685
|
);
|
|
@@ -7655,9 +7689,9 @@ function CardSetupInner({ onComplete }) {
|
|
|
7655
7689
|
const copy = useCopy();
|
|
7656
7690
|
const stripe = (0, import_react_stripe_js3.useStripe)();
|
|
7657
7691
|
const elements = (0, import_react_stripe_js3.useElements)();
|
|
7658
|
-
const [processing, setProcessing] = (0,
|
|
7659
|
-
const [error, setError] = (0,
|
|
7660
|
-
(0,
|
|
7692
|
+
const [processing, setProcessing] = (0, import_react35.useState)(false);
|
|
7693
|
+
const [error, setError] = (0, import_react35.useState)(null);
|
|
7694
|
+
(0, import_react35.useEffect)(() => {
|
|
7661
7695
|
if (!stripe) return;
|
|
7662
7696
|
const clientSecret = readSetupIntentClientSecret(window.location.search);
|
|
7663
7697
|
if (!clientSecret) return;
|
|
@@ -7712,12 +7746,12 @@ function CardSetupInner({ onComplete }) {
|
|
|
7712
7746
|
await onComplete();
|
|
7713
7747
|
setProcessing(false);
|
|
7714
7748
|
};
|
|
7715
|
-
return /* @__PURE__ */ (0,
|
|
7716
|
-
/* @__PURE__ */ (0,
|
|
7717
|
-
/* @__PURE__ */ (0,
|
|
7718
|
-
/* @__PURE__ */ (0,
|
|
7719
|
-
error ? /* @__PURE__ */ (0,
|
|
7720
|
-
/* @__PURE__ */ (0,
|
|
7749
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("form", { onSubmit: handleSubmit, "data-solvapay-auto-recharge-setup": "", children: [
|
|
7750
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("h4", { children: copy.autoRecharge.setupHeading }),
|
|
7751
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { children: copy.autoRecharge.setupDescription }),
|
|
7752
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react_stripe_js3.PaymentElement, { options: withPaymentElementDefaults() }),
|
|
7753
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { role: "alert", "aria-live": "polite", "data-solvapay-auto-recharge-setup-error": "", children: error }) : null,
|
|
7754
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
7721
7755
|
"button",
|
|
7722
7756
|
{
|
|
7723
7757
|
type: "submit",
|
|
@@ -7729,7 +7763,7 @@ function CardSetupInner({ onComplete }) {
|
|
|
7729
7763
|
] });
|
|
7730
7764
|
}
|
|
7731
7765
|
function CardSetup({ setup, onComplete }) {
|
|
7732
|
-
const stripePromise = (0,
|
|
7766
|
+
const stripePromise = (0, import_react35.useMemo)(() => {
|
|
7733
7767
|
if (!setup.publishableKey || !setup.setupClientSecret) return null;
|
|
7734
7768
|
const options = {
|
|
7735
7769
|
...setup.stripeAccountId ? { stripeAccount: setup.stripeAccountId } : {},
|
|
@@ -7743,17 +7777,17 @@ function CardSetup({ setup, onComplete }) {
|
|
|
7743
7777
|
return promise;
|
|
7744
7778
|
}, [setup.publishableKey, setup.setupClientSecret, setup.stripeAccountId]);
|
|
7745
7779
|
if (!stripePromise || !setup.setupClientSecret) {
|
|
7746
|
-
return /* @__PURE__ */ (0,
|
|
7747
|
-
/* @__PURE__ */ (0,
|
|
7780
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("p", { "data-solvapay-auto-recharge-setup-loading": "", children: [
|
|
7781
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Spinner, { size: "sm" }),
|
|
7748
7782
|
" Loading card form\u2026"
|
|
7749
7783
|
] });
|
|
7750
7784
|
}
|
|
7751
|
-
return /* @__PURE__ */ (0,
|
|
7785
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
7752
7786
|
import_react_stripe_js3.Elements,
|
|
7753
7787
|
{
|
|
7754
7788
|
stripe: stripePromise,
|
|
7755
7789
|
options: { clientSecret: setup.setupClientSecret },
|
|
7756
|
-
children: /* @__PURE__ */ (0,
|
|
7790
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(CardSetupInner, { onComplete })
|
|
7757
7791
|
},
|
|
7758
7792
|
setup.setupClientSecret
|
|
7759
7793
|
);
|
|
@@ -7835,15 +7869,15 @@ function useAutoRechargeForm() {
|
|
|
7835
7869
|
}
|
|
7836
7870
|
|
|
7837
7871
|
// src/primitives/ProductBadge.tsx
|
|
7838
|
-
var
|
|
7839
|
-
var
|
|
7840
|
-
var ProductBadgeImpl = (0,
|
|
7841
|
-
const solva = (0,
|
|
7872
|
+
var import_react36 = require("react");
|
|
7873
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
7874
|
+
var ProductBadgeImpl = (0, import_react36.forwardRef)(function ProductBadge({ asChild, children, ...rest }, forwardedRef) {
|
|
7875
|
+
const solva = (0, import_react36.useContext)(SolvaPayContext);
|
|
7842
7876
|
if (!solva) throw new MissingProviderError("ProductBadge");
|
|
7843
7877
|
const { purchases, loading, hasPaidPurchase, activePurchase } = usePurchase();
|
|
7844
7878
|
const copy = useCopy();
|
|
7845
|
-
const [hasLoadedOnce, setHasLoadedOnce] = (0,
|
|
7846
|
-
(0,
|
|
7879
|
+
const [hasLoadedOnce, setHasLoadedOnce] = (0, import_react36.useState)(false);
|
|
7880
|
+
(0, import_react36.useEffect)(() => {
|
|
7847
7881
|
if (!loading) setHasLoadedOnce(true);
|
|
7848
7882
|
}, [loading]);
|
|
7849
7883
|
const planToDisplay = activePurchase?.productName ?? null;
|
|
@@ -7863,32 +7897,32 @@ var ProductBadgeImpl = (0, import_react35.forwardRef)(function ProductBadge({ as
|
|
|
7863
7897
|
if (asChild) {
|
|
7864
7898
|
return (
|
|
7865
7899
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7866
|
-
/* @__PURE__ */ (0,
|
|
7900
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Slot, { ref: forwardedRef, ...commonProps, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: planToDisplay }) })
|
|
7867
7901
|
);
|
|
7868
7902
|
}
|
|
7869
7903
|
void purchases;
|
|
7870
7904
|
return (
|
|
7871
7905
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7872
|
-
/* @__PURE__ */ (0,
|
|
7906
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { ref: forwardedRef, ...commonProps, children: children ?? planToDisplay })
|
|
7873
7907
|
);
|
|
7874
7908
|
});
|
|
7875
7909
|
var ProductBadge2 = ProductBadgeImpl;
|
|
7876
7910
|
var PlanBadge = ProductBadgeImpl;
|
|
7877
7911
|
|
|
7878
7912
|
// src/primitives/PaywallNotice.tsx
|
|
7879
|
-
var
|
|
7913
|
+
var import_react41 = require("react");
|
|
7880
7914
|
|
|
7881
7915
|
// src/primitives/checkout/index.tsx
|
|
7882
|
-
var
|
|
7916
|
+
var import_react39 = require("react");
|
|
7883
7917
|
|
|
7884
7918
|
// src/hooks/useCheckoutFlow.ts
|
|
7885
|
-
var
|
|
7919
|
+
var import_react38 = require("react");
|
|
7886
7920
|
|
|
7887
7921
|
// src/hooks/useTransport.ts
|
|
7888
|
-
var
|
|
7922
|
+
var import_react37 = require("react");
|
|
7889
7923
|
function useTransport() {
|
|
7890
7924
|
const { _config } = useSolvaPay();
|
|
7891
|
-
return (0,
|
|
7925
|
+
return (0, import_react37.useMemo)(() => _config?.transport ?? createHttpTransport(_config), [_config]);
|
|
7892
7926
|
}
|
|
7893
7927
|
|
|
7894
7928
|
// src/primitives/checkout/shared.ts
|
|
@@ -7968,10 +8002,10 @@ function resolveInitialCheckoutStep(initialStep) {
|
|
|
7968
8002
|
}
|
|
7969
8003
|
function useCheckoutFlow(opts) {
|
|
7970
8004
|
const { productRef, initialStep = "plan", initialAmountMinor = null } = opts;
|
|
7971
|
-
const onPlanSelectRef = (0,
|
|
7972
|
-
const onAmountSelectRef = (0,
|
|
7973
|
-
const onPurchaseSuccessRef = (0,
|
|
7974
|
-
const onErrorRef = (0,
|
|
8005
|
+
const onPlanSelectRef = (0, import_react38.useRef)(opts.onPlanSelect);
|
|
8006
|
+
const onAmountSelectRef = (0, import_react38.useRef)(opts.onAmountSelect);
|
|
8007
|
+
const onPurchaseSuccessRef = (0, import_react38.useRef)(opts.onPurchaseSuccess);
|
|
8008
|
+
const onErrorRef = (0, import_react38.useRef)(opts.onError);
|
|
7975
8009
|
onPlanSelectRef.current = opts.onPlanSelect;
|
|
7976
8010
|
onAmountSelectRef.current = opts.onAmountSelect;
|
|
7977
8011
|
onPurchaseSuccessRef.current = opts.onPurchaseSuccess;
|
|
@@ -7984,8 +8018,8 @@ function useCheckoutFlow(opts) {
|
|
|
7984
8018
|
const { creditsPerMinorUnit, displayExchangeRate, adjustBalance } = balance;
|
|
7985
8019
|
const { refetchPurchase } = useSolvaPay();
|
|
7986
8020
|
const { merchant } = useMerchant();
|
|
7987
|
-
const [topupCurrencyOverride, setTopupCurrencyOverride] = (0,
|
|
7988
|
-
const topupCurrencies = (0,
|
|
8021
|
+
const [topupCurrencyOverride, setTopupCurrencyOverride] = (0, import_react38.useState)(null);
|
|
8022
|
+
const topupCurrencies = (0, import_react38.useMemo)(() => {
|
|
7989
8023
|
const fromMerchant = (merchant?.supportedTopupCurrencies ?? []).map((code) => code.toUpperCase()).filter(Boolean);
|
|
7990
8024
|
const fallback = opts.topupCurrency?.toUpperCase() ?? merchant?.defaultCurrency?.toUpperCase() ?? null;
|
|
7991
8025
|
const list = fromMerchant.length > 0 ? fromMerchant : fallback ? [fallback] : [];
|
|
@@ -7995,22 +8029,22 @@ function useCheckoutFlow(opts) {
|
|
|
7995
8029
|
const planPickerCurrency = planCtx.preferredCurrency?.toUpperCase() ?? null;
|
|
7996
8030
|
const topupCurrency = (topupCurrencyOverride && topupCurrencies.includes(topupCurrencyOverride) ? topupCurrencyOverride : null) ?? (planPickerCurrency && topupCurrencies.includes(planPickerCurrency) ? planPickerCurrency : null) ?? resolvedDefaultTopupCurrency;
|
|
7997
8031
|
const topupCurrencyReady = topupCurrency != null;
|
|
7998
|
-
const setTopupCurrency = (0,
|
|
8032
|
+
const setTopupCurrency = (0, import_react38.useCallback)((code) => {
|
|
7999
8033
|
const normalized = code.toUpperCase();
|
|
8000
8034
|
setTopupCurrencyOverride(normalized);
|
|
8001
8035
|
}, []);
|
|
8002
|
-
const [step, setStep] = (0,
|
|
8003
|
-
const [status, setStatus] = (0,
|
|
8004
|
-
const [selectedAmountMinor, setSelectedAmountMinor] = (0,
|
|
8005
|
-
const [successMeta, setSuccessMeta] = (0,
|
|
8006
|
-
const [error, setError] = (0,
|
|
8007
|
-
const selectedAmountMinorRef = (0,
|
|
8036
|
+
const [step, setStep] = (0, import_react38.useState)(() => resolveInitialCheckoutStep(initialStep));
|
|
8037
|
+
const [status, setStatus] = (0, import_react38.useState)("idle");
|
|
8038
|
+
const [selectedAmountMinor, setSelectedAmountMinor] = (0, import_react38.useState)(initialAmountMinor);
|
|
8039
|
+
const [successMeta, setSuccessMeta] = (0, import_react38.useState)(null);
|
|
8040
|
+
const [error, setError] = (0, import_react38.useState)(null);
|
|
8041
|
+
const selectedAmountMinorRef = (0, import_react38.useRef)(initialAmountMinor);
|
|
8008
8042
|
const selectedPlan = planCtx.selectedPlan;
|
|
8009
8043
|
const selectedPlanRef = planCtx.selectedPlanRef;
|
|
8010
8044
|
const selectedPlanShape = toBootstrapPlanLike(selectedPlan);
|
|
8011
8045
|
const branch = selectedPlanShape ? isPayg(selectedPlanShape) ? "payg" : "recurring" : null;
|
|
8012
8046
|
const canGoBack = step === "amount" || step === "payment";
|
|
8013
|
-
const selectPlan = (0,
|
|
8047
|
+
const selectPlan = (0, import_react38.useCallback)(
|
|
8014
8048
|
(ref) => {
|
|
8015
8049
|
planCtx.select(ref);
|
|
8016
8050
|
const plan = planCtx.plans.find((p) => p.reference === ref) ?? null;
|
|
@@ -8020,7 +8054,7 @@ function useCheckoutFlow(opts) {
|
|
|
8020
8054
|
},
|
|
8021
8055
|
[planCtx]
|
|
8022
8056
|
);
|
|
8023
|
-
const selectAmount = (0,
|
|
8057
|
+
const selectAmount = (0, import_react38.useCallback)(
|
|
8024
8058
|
(amountMinor) => {
|
|
8025
8059
|
selectedAmountMinorRef.current = amountMinor;
|
|
8026
8060
|
setSelectedAmountMinor(amountMinor);
|
|
@@ -8029,7 +8063,7 @@ function useCheckoutFlow(opts) {
|
|
|
8029
8063
|
},
|
|
8030
8064
|
[topupCurrency]
|
|
8031
8065
|
);
|
|
8032
|
-
const runActivate = (0,
|
|
8066
|
+
const runActivate = (0, import_react38.useCallback)(async () => {
|
|
8033
8067
|
if (!selectedPlanShape || !selectedPlanRef) return false;
|
|
8034
8068
|
setError(null);
|
|
8035
8069
|
setStatus("activating");
|
|
@@ -8061,7 +8095,7 @@ function useCheckoutFlow(opts) {
|
|
|
8061
8095
|
return false;
|
|
8062
8096
|
}
|
|
8063
8097
|
}, [balance, locale, productRef, selectedPlanRef, selectedPlanShape, transport]);
|
|
8064
|
-
const advanceFromPlan = (0,
|
|
8098
|
+
const advanceFromPlan = (0, import_react38.useCallback)(async () => {
|
|
8065
8099
|
if (!selectedPlanShape || !selectedPlanRef) return;
|
|
8066
8100
|
if (branch === "payg") {
|
|
8067
8101
|
if (planCtx.currentPlanRef === selectedPlanRef) {
|
|
@@ -8099,7 +8133,7 @@ function useCheckoutFlow(opts) {
|
|
|
8099
8133
|
setError(null);
|
|
8100
8134
|
setStep("payment");
|
|
8101
8135
|
}, [balance, branch, locale, planCtx.currentPlanRef, runActivate, selectedPlanRef, selectedPlanShape]);
|
|
8102
|
-
const recordPaygSuccess = (0,
|
|
8136
|
+
const recordPaygSuccess = (0, import_react38.useCallback)(
|
|
8103
8137
|
(creditsAddedFromBackend) => {
|
|
8104
8138
|
if (!selectedPlanShape || selectedAmountMinor == null) return;
|
|
8105
8139
|
const currency = topupCurrency ?? "USD";
|
|
@@ -8143,7 +8177,7 @@ function useCheckoutFlow(opts) {
|
|
|
8143
8177
|
transport
|
|
8144
8178
|
]
|
|
8145
8179
|
);
|
|
8146
|
-
const recordRecurringSuccess = (0,
|
|
8180
|
+
const recordRecurringSuccess = (0, import_react38.useCallback)(() => {
|
|
8147
8181
|
if (!selectedPlanShape) return;
|
|
8148
8182
|
const pricingOption = selectedPlan ? resolvePlanPricingOption(selectedPlan, planSelection?.selectedCurrency) : {
|
|
8149
8183
|
currency: selectedPlanShape.currency ?? "USD",
|
|
@@ -8163,7 +8197,7 @@ function useCheckoutFlow(opts) {
|
|
|
8163
8197
|
setStep("success");
|
|
8164
8198
|
onPurchaseSuccessRef.current?.(meta);
|
|
8165
8199
|
}, [selectedPlanShape, selectedPlan, planSelection?.selectedCurrency]);
|
|
8166
|
-
const advance = (0,
|
|
8200
|
+
const advance = (0, import_react38.useCallback)(async () => {
|
|
8167
8201
|
if (step === "plan") {
|
|
8168
8202
|
await advanceFromPlan();
|
|
8169
8203
|
return;
|
|
@@ -8190,7 +8224,7 @@ function useCheckoutFlow(opts) {
|
|
|
8190
8224
|
selectedAmountMinor,
|
|
8191
8225
|
step
|
|
8192
8226
|
]);
|
|
8193
|
-
const back = (0,
|
|
8227
|
+
const back = (0, import_react38.useCallback)(() => {
|
|
8194
8228
|
setError(null);
|
|
8195
8229
|
if (step === "amount") {
|
|
8196
8230
|
setStep("plan");
|
|
@@ -8201,7 +8235,7 @@ function useCheckoutFlow(opts) {
|
|
|
8201
8235
|
return;
|
|
8202
8236
|
}
|
|
8203
8237
|
}, [branch, step]);
|
|
8204
|
-
const reset = (0,
|
|
8238
|
+
const reset = (0, import_react38.useCallback)(() => {
|
|
8205
8239
|
setStep("plan");
|
|
8206
8240
|
selectedAmountMinorRef.current = null;
|
|
8207
8241
|
setSelectedAmountMinor(null);
|
|
@@ -8210,13 +8244,13 @@ function useCheckoutFlow(opts) {
|
|
|
8210
8244
|
setStatus("idle");
|
|
8211
8245
|
setTopupCurrencyOverride(null);
|
|
8212
8246
|
}, []);
|
|
8213
|
-
const retry = (0,
|
|
8247
|
+
const retry = (0, import_react38.useCallback)(async () => {
|
|
8214
8248
|
if (status !== "error") return;
|
|
8215
8249
|
if (step === "plan" && branch === "payg") {
|
|
8216
8250
|
await runActivate();
|
|
8217
8251
|
}
|
|
8218
8252
|
}, [branch, runActivate, status, step]);
|
|
8219
|
-
const notifyPaymentSuccess = (0,
|
|
8253
|
+
const notifyPaymentSuccess = (0, import_react38.useCallback)(
|
|
8220
8254
|
(_intent, extras) => {
|
|
8221
8255
|
if (branch === "payg") {
|
|
8222
8256
|
recordPaygSuccess(extras?.creditsAdded);
|
|
@@ -8226,7 +8260,7 @@ function useCheckoutFlow(opts) {
|
|
|
8226
8260
|
},
|
|
8227
8261
|
[branch, recordPaygSuccess, recordRecurringSuccess]
|
|
8228
8262
|
);
|
|
8229
|
-
return (0,
|
|
8263
|
+
return (0, import_react38.useMemo)(
|
|
8230
8264
|
() => ({
|
|
8231
8265
|
step,
|
|
8232
8266
|
status,
|
|
@@ -8275,10 +8309,10 @@ function useCheckoutFlow(opts) {
|
|
|
8275
8309
|
}
|
|
8276
8310
|
|
|
8277
8311
|
// src/primitives/checkout/index.tsx
|
|
8278
|
-
var
|
|
8279
|
-
var CheckoutContext = (0,
|
|
8312
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
8313
|
+
var CheckoutContext = (0, import_react39.createContext)(null);
|
|
8280
8314
|
function useCheckoutContext(part) {
|
|
8281
|
-
const ctx = (0,
|
|
8315
|
+
const ctx = (0, import_react39.useContext)(CheckoutContext);
|
|
8282
8316
|
if (!ctx) {
|
|
8283
8317
|
throw new Error(`CheckoutSteps.${part} must be rendered inside <CheckoutSteps.Root>.`);
|
|
8284
8318
|
}
|
|
@@ -8287,7 +8321,7 @@ function useCheckoutContext(part) {
|
|
|
8287
8321
|
function useCheckoutSteps() {
|
|
8288
8322
|
return useCheckoutContext("useCheckoutSteps");
|
|
8289
8323
|
}
|
|
8290
|
-
var Root11 = (0,
|
|
8324
|
+
var Root11 = (0, import_react39.forwardRef)(function CheckoutStepsRoot(props, forwardedRef) {
|
|
8291
8325
|
const {
|
|
8292
8326
|
productRef,
|
|
8293
8327
|
returnUrl: _returnUrl,
|
|
@@ -8309,9 +8343,9 @@ var Root11 = (0, import_react38.forwardRef)(function CheckoutStepsRoot(props, fo
|
|
|
8309
8343
|
children
|
|
8310
8344
|
} = props;
|
|
8311
8345
|
if (externalFlow) {
|
|
8312
|
-
return /* @__PURE__ */ (0,
|
|
8346
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { ref: forwardedRef, "data-solvapay-checkout": "", className, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CheckoutContext.Provider, { value: externalFlow, children }) });
|
|
8313
8347
|
}
|
|
8314
|
-
return /* @__PURE__ */ (0,
|
|
8348
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
8315
8349
|
RootWithPlanSelector,
|
|
8316
8350
|
{
|
|
8317
8351
|
productRef,
|
|
@@ -8354,11 +8388,11 @@ function RootWithPlanSelector({
|
|
|
8354
8388
|
children
|
|
8355
8389
|
}) {
|
|
8356
8390
|
const { plans } = usePlans({ productRef });
|
|
8357
|
-
const resolvedFilter = (0,
|
|
8391
|
+
const resolvedFilter = (0, import_react39.useMemo)(
|
|
8358
8392
|
() => filter ?? buildDefaultCheckoutPlanFilter(plans),
|
|
8359
8393
|
[filter, plans]
|
|
8360
8394
|
);
|
|
8361
|
-
return /* @__PURE__ */ (0,
|
|
8395
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
8362
8396
|
PlanSelector.Root,
|
|
8363
8397
|
{
|
|
8364
8398
|
productRef,
|
|
@@ -8368,7 +8402,7 @@ function RootWithPlanSelector({
|
|
|
8368
8402
|
currentPlanRef,
|
|
8369
8403
|
autoSelectFirstPaid,
|
|
8370
8404
|
initialPlanRef,
|
|
8371
|
-
children: /* @__PURE__ */ (0,
|
|
8405
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
8372
8406
|
FlowProvider,
|
|
8373
8407
|
{
|
|
8374
8408
|
productRef,
|
|
@@ -8410,22 +8444,22 @@ function FlowProvider({
|
|
|
8410
8444
|
onPurchaseSuccess,
|
|
8411
8445
|
onError
|
|
8412
8446
|
});
|
|
8413
|
-
return /* @__PURE__ */ (0,
|
|
8447
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { ref: forwardedRef, "data-solvapay-checkout": "", "data-step": flow.step, className, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CheckoutContext.Provider, { value: flow, children }) });
|
|
8414
8448
|
}
|
|
8415
8449
|
function IfStep({ step, children }) {
|
|
8416
8450
|
const flow = useCheckoutContext("IfStep");
|
|
8417
8451
|
const matches = Array.isArray(step) ? step.includes(flow.step) : flow.step === step;
|
|
8418
8452
|
if (!matches) return null;
|
|
8419
|
-
return /* @__PURE__ */ (0,
|
|
8453
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children });
|
|
8420
8454
|
}
|
|
8421
|
-
var StepHeading = (0,
|
|
8455
|
+
var StepHeading = (0, import_react39.forwardRef)(function CheckoutStepsStepHeading({ asChild, children, className, ...rest }, forwardedRef) {
|
|
8422
8456
|
const flow = useCheckoutContext("StepHeading");
|
|
8423
8457
|
const copy = useCopy();
|
|
8424
8458
|
const paywallCtx = usePaywallNoticeOptional();
|
|
8425
8459
|
if (flow.step === "success") return null;
|
|
8426
8460
|
const defaultText = resolveStepHeading(flow.step, copy, paywallCtx?.content ?? null);
|
|
8427
8461
|
const Comp = asChild ? Slot : "h3";
|
|
8428
|
-
return /* @__PURE__ */ (0,
|
|
8462
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
8429
8463
|
Comp,
|
|
8430
8464
|
{
|
|
8431
8465
|
ref: forwardedRef,
|
|
@@ -8437,7 +8471,7 @@ var StepHeading = (0, import_react38.forwardRef)(function CheckoutStepsStepHeadi
|
|
|
8437
8471
|
}
|
|
8438
8472
|
);
|
|
8439
8473
|
});
|
|
8440
|
-
var StepMessage = (0,
|
|
8474
|
+
var StepMessage = (0, import_react39.forwardRef)(
|
|
8441
8475
|
function CheckoutStepsStepMessage({ asChild, children, className, ...rest }, forwardedRef) {
|
|
8442
8476
|
const flow = useCheckoutContext("StepMessage");
|
|
8443
8477
|
const copy = useCopy();
|
|
@@ -8446,7 +8480,7 @@ var StepMessage = (0, import_react38.forwardRef)(
|
|
|
8446
8480
|
const defaultText = resolveStepMessage(flow, copy, paywallCtx?.content ?? null);
|
|
8447
8481
|
if (!defaultText && children == null) return null;
|
|
8448
8482
|
const Comp = asChild ? Slot : "p";
|
|
8449
|
-
return /* @__PURE__ */ (0,
|
|
8483
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
8450
8484
|
Comp,
|
|
8451
8485
|
{
|
|
8452
8486
|
ref: forwardedRef,
|
|
@@ -8494,21 +8528,21 @@ function resolveStepMessage(flow, copy, content) {
|
|
|
8494
8528
|
return "";
|
|
8495
8529
|
}
|
|
8496
8530
|
function PlanGrid({ className, children }) {
|
|
8497
|
-
return /* @__PURE__ */ (0,
|
|
8498
|
-
/* @__PURE__ */ (0,
|
|
8499
|
-
/* @__PURE__ */ (0,
|
|
8500
|
-
/* @__PURE__ */ (0,
|
|
8501
|
-
/* @__PURE__ */ (0,
|
|
8531
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PlanSelector.Grid, { className: className ?? "solvapay-checkout-plan-grid", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(PlanSelector.Card, { className: "solvapay-checkout-plan-card", children: [
|
|
8532
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PlanSelector.CardBadge, { className: "solvapay-checkout-plan-card-badge" }),
|
|
8533
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PlanSelector.CardName, { className: "solvapay-checkout-plan-card-name" }),
|
|
8534
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PlanSelector.CardPrice, { className: "solvapay-checkout-plan-card-price" }),
|
|
8535
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PlanSelector.CardInterval, { className: "solvapay-checkout-plan-card-interval" })
|
|
8502
8536
|
] }) });
|
|
8503
8537
|
}
|
|
8504
|
-
var PlanContinueButton = (0,
|
|
8538
|
+
var PlanContinueButton = (0, import_react39.forwardRef)(
|
|
8505
8539
|
function PlanContinueButton2({ className, children, onClick, disabled, ...rest }, ref) {
|
|
8506
8540
|
const flow = useCheckoutContext("PlanContinueButton");
|
|
8507
8541
|
const locale = useLocale();
|
|
8508
8542
|
const selectedPlanShape = flow.selectedPlan;
|
|
8509
8543
|
const isDisabled = disabled || !flow.selectedPlanRef || flow.status === "activating";
|
|
8510
8544
|
const label = children ?? formatContinueLabel(selectedPlanShape, locale);
|
|
8511
|
-
return /* @__PURE__ */ (0,
|
|
8545
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
8512
8546
|
"button",
|
|
8513
8547
|
{
|
|
8514
8548
|
ref,
|
|
@@ -8531,7 +8565,7 @@ var PlanContinueButton = (0, import_react38.forwardRef)(
|
|
|
8531
8565
|
function AmountPicker2({ className, children }) {
|
|
8532
8566
|
const flow = useCheckoutContext("AmountPicker");
|
|
8533
8567
|
if (!flow.topupCurrencyReady || flow.topupCurrency == null) {
|
|
8534
|
-
return /* @__PURE__ */ (0,
|
|
8568
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: className ?? "solvapay-amount-picker", "data-state": "loading", "aria-busy": "true", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "solvapay-amount-picker-pills", children: [0, 1, 2, 3].map((i) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
8535
8569
|
"span",
|
|
8536
8570
|
{
|
|
8537
8571
|
className: "solvapay-amount-picker-pill",
|
|
@@ -8541,7 +8575,7 @@ function AmountPicker2({ className, children }) {
|
|
|
8541
8575
|
i
|
|
8542
8576
|
)) }) });
|
|
8543
8577
|
}
|
|
8544
|
-
return /* @__PURE__ */ (0,
|
|
8578
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
8545
8579
|
AmountPicker.Root,
|
|
8546
8580
|
{
|
|
8547
8581
|
currency: flow.topupCurrency,
|
|
@@ -8552,16 +8586,16 @@ function AmountPicker2({ className, children }) {
|
|
|
8552
8586
|
flow.selectAmount(value);
|
|
8553
8587
|
}
|
|
8554
8588
|
},
|
|
8555
|
-
children: children ?? /* @__PURE__ */ (0,
|
|
8589
|
+
children: children ?? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DefaultAmountTree, {})
|
|
8556
8590
|
}
|
|
8557
8591
|
);
|
|
8558
8592
|
}
|
|
8559
8593
|
function DefaultAmountTree() {
|
|
8560
8594
|
const ctx = useAmountPicker();
|
|
8561
8595
|
const { selectAmountLabel, customAmountLabel, creditEstimate } = useAmountPickerCopy();
|
|
8562
|
-
return /* @__PURE__ */ (0,
|
|
8563
|
-
/* @__PURE__ */ (0,
|
|
8564
|
-
/* @__PURE__ */ (0,
|
|
8596
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
|
|
8597
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "solvapay-amount-picker-label", children: selectAmountLabel }),
|
|
8598
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "solvapay-amount-picker-pills", children: ctx.quickAmounts.map((amount) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
8565
8599
|
AmountPicker.Option,
|
|
8566
8600
|
{
|
|
8567
8601
|
amount,
|
|
@@ -8569,11 +8603,11 @@ function DefaultAmountTree() {
|
|
|
8569
8603
|
},
|
|
8570
8604
|
amount
|
|
8571
8605
|
)) }),
|
|
8572
|
-
/* @__PURE__ */ (0,
|
|
8573
|
-
/* @__PURE__ */ (0,
|
|
8574
|
-
/* @__PURE__ */ (0,
|
|
8575
|
-
/* @__PURE__ */ (0,
|
|
8576
|
-
/* @__PURE__ */ (0,
|
|
8606
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "solvapay-amount-picker-custom-wrapper", children: [
|
|
8607
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "solvapay-amount-picker-custom-label", children: customAmountLabel }),
|
|
8608
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "solvapay-amount-picker-custom-row", children: [
|
|
8609
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "solvapay-amount-picker-currency-symbol", children: ctx.currencySymbol }),
|
|
8610
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
8577
8611
|
AmountPicker.Custom,
|
|
8578
8612
|
{
|
|
8579
8613
|
className: "solvapay-amount-picker-custom-input",
|
|
@@ -8582,7 +8616,7 @@ function DefaultAmountTree() {
|
|
|
8582
8616
|
)
|
|
8583
8617
|
] })
|
|
8584
8618
|
] }),
|
|
8585
|
-
/* @__PURE__ */ (0,
|
|
8619
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
8586
8620
|
"p",
|
|
8587
8621
|
{
|
|
8588
8622
|
className: "solvapay-amount-picker-credit-estimate",
|
|
@@ -8592,7 +8626,7 @@ function DefaultAmountTree() {
|
|
|
8592
8626
|
)
|
|
8593
8627
|
] });
|
|
8594
8628
|
}
|
|
8595
|
-
var AmountContinueButton = (0,
|
|
8629
|
+
var AmountContinueButton = (0, import_react39.forwardRef)(
|
|
8596
8630
|
function AmountContinueButton2({ className, children, onClick, disabled, ...rest }, ref) {
|
|
8597
8631
|
const flow = useCheckoutContext("AmountContinueButton");
|
|
8598
8632
|
const locale = useLocale();
|
|
@@ -8601,7 +8635,7 @@ var AmountContinueButton = (0, import_react38.forwardRef)(
|
|
|
8601
8635
|
const ready = flow.topupCurrencyReady && currency != null;
|
|
8602
8636
|
const isDisabled = disabled || !ready || amountMinor == null;
|
|
8603
8637
|
const label = children ?? (ready && currency != null && amountMinor != null ? `Continue \u2014 ${formatPrice(amountMinor, currency, { locale })}` : "Continue");
|
|
8604
|
-
return /* @__PURE__ */ (0,
|
|
8638
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
8605
8639
|
"button",
|
|
8606
8640
|
{
|
|
8607
8641
|
ref,
|
|
@@ -8624,10 +8658,10 @@ var AmountContinueButton = (0, import_react38.forwardRef)(
|
|
|
8624
8658
|
function Payment({ className }) {
|
|
8625
8659
|
const flow = useCheckoutContext("Payment");
|
|
8626
8660
|
if (flow.branch === "payg") {
|
|
8627
|
-
return /* @__PURE__ */ (0,
|
|
8661
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PaygPayment, { className });
|
|
8628
8662
|
}
|
|
8629
8663
|
if (flow.branch === "recurring") {
|
|
8630
|
-
return /* @__PURE__ */ (0,
|
|
8664
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(RecurringPayment, { className });
|
|
8631
8665
|
}
|
|
8632
8666
|
return null;
|
|
8633
8667
|
}
|
|
@@ -8641,12 +8675,12 @@ function PaygPayment({ className }) {
|
|
|
8641
8675
|
const currency = flow.topupCurrency;
|
|
8642
8676
|
if (!selectedPlanShape || amountMinor == null || currency == null) return null;
|
|
8643
8677
|
const creditsAdded = creditsPerMinorUnit != null && creditsPerMinorUnit > 0 ? Math.floor(amountMinor / (displayExchangeRate ?? 1) * creditsPerMinorUnit) : null;
|
|
8644
|
-
return /* @__PURE__ */ (0,
|
|
8645
|
-
/* @__PURE__ */ (0,
|
|
8646
|
-
/* @__PURE__ */ (0,
|
|
8647
|
-
creditsAdded != null ? /* @__PURE__ */ (0,
|
|
8678
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: className ?? "solvapay-checkout-payment", "data-branch": "payg", children: [
|
|
8679
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "solvapay-checkout-order-summary", "data-variant": "payg", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "solvapay-checkout-order-summary-row", children: [
|
|
8680
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { children: creditsAdded != null ? `${creditsAdded.toLocaleString(locale)} credits` : formatPrice(amountMinor, currency, { locale }) }),
|
|
8681
|
+
creditsAdded != null ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { children: formatPrice(amountMinor, currency, { locale }) }) : null
|
|
8648
8682
|
] }) }),
|
|
8649
|
-
/* @__PURE__ */ (0,
|
|
8683
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
8650
8684
|
TopupForm.Root,
|
|
8651
8685
|
{
|
|
8652
8686
|
amount: amountMinor,
|
|
@@ -8655,14 +8689,14 @@ function PaygPayment({ className }) {
|
|
|
8655
8689
|
className: "solvapay-checkout-topup-form",
|
|
8656
8690
|
onSuccess: (intent, extras) => flow.notifyPaymentSuccess(intent, extras),
|
|
8657
8691
|
children: [
|
|
8658
|
-
/* @__PURE__ */ (0,
|
|
8659
|
-
/* @__PURE__ */ (0,
|
|
8660
|
-
/* @__PURE__ */ (0,
|
|
8661
|
-
/* @__PURE__ */ (0,
|
|
8662
|
-
/* @__PURE__ */ (0,
|
|
8663
|
-
/* @__PURE__ */ (0,
|
|
8664
|
-
/* @__PURE__ */ (0,
|
|
8665
|
-
/* @__PURE__ */ (0,
|
|
8692
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(TopupForm.Loading, {}),
|
|
8693
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(TopupForm.BusinessDetails.Root, { className: "solvapay-checkout-business-details", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(TopupForm.BusinessDetails.Fields, {}) }),
|
|
8694
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(TopupForm.Summary.Root, { className: "solvapay-checkout-tax-summary", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(TopupForm.Summary.Rows, {}) }),
|
|
8695
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(TopupForm.PaymentElement, {}),
|
|
8696
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(TopupForm.Error, { className: "solvapay-checkout-error" }),
|
|
8697
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(MandateText, { mode: "topup", amountMinor, currency }),
|
|
8698
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "solvapay-secure-note", children: "Secure payment processed by Stripe" }),
|
|
8699
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(TopupForm.SubmitButton, { className: "solvapay-checkout-pay-button", children: [
|
|
8666
8700
|
"Pay ",
|
|
8667
8701
|
formatPrice(amountMinor, currency, { locale })
|
|
8668
8702
|
] })
|
|
@@ -8685,12 +8719,12 @@ function RecurringPayment({ className }) {
|
|
|
8685
8719
|
const isRecurring = !!cycle;
|
|
8686
8720
|
const formattedAmount = formatPrice(amountMinor, currency, { locale });
|
|
8687
8721
|
const priceLine = isRecurring ? `${formattedAmount}/${shortCycle(cycle)}` : formattedAmount;
|
|
8688
|
-
return /* @__PURE__ */ (0,
|
|
8689
|
-
/* @__PURE__ */ (0,
|
|
8690
|
-
/* @__PURE__ */ (0,
|
|
8691
|
-
/* @__PURE__ */ (0,
|
|
8722
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: className ?? "solvapay-checkout-payment", "data-branch": "recurring", children: [
|
|
8723
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "solvapay-checkout-order-summary", "data-variant": "recurring", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "solvapay-checkout-order-summary-row", children: [
|
|
8724
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { children: planName }),
|
|
8725
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { children: priceLine })
|
|
8692
8726
|
] }) }),
|
|
8693
|
-
/* @__PURE__ */ (0,
|
|
8727
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
8694
8728
|
PaymentForm.Root,
|
|
8695
8729
|
{
|
|
8696
8730
|
planRef: flow.selectedPlanRef,
|
|
@@ -8699,31 +8733,31 @@ function RecurringPayment({ className }) {
|
|
|
8699
8733
|
requireTermsAcceptance: false,
|
|
8700
8734
|
onSuccess: (intent) => flow.notifyPaymentSuccess(intent),
|
|
8701
8735
|
children: [
|
|
8702
|
-
/* @__PURE__ */ (0,
|
|
8703
|
-
/* @__PURE__ */ (0,
|
|
8704
|
-
/* @__PURE__ */ (0,
|
|
8705
|
-
/* @__PURE__ */ (0,
|
|
8706
|
-
/* @__PURE__ */ (0,
|
|
8707
|
-
/* @__PURE__ */ (0,
|
|
8708
|
-
/* @__PURE__ */ (0,
|
|
8709
|
-
/* @__PURE__ */ (0,
|
|
8736
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PaymentForm.Loading, {}),
|
|
8737
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PaymentForm.BusinessDetails.Root, { className: "solvapay-checkout-business-details", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PaymentForm.BusinessDetails.Fields, {}) }),
|
|
8738
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PaymentForm.TaxSummary.Root, { className: "solvapay-checkout-tax-summary", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PaymentForm.TaxSummary.Rows, {}) }),
|
|
8739
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PaymentForm.PaymentElement, {}),
|
|
8740
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PaymentForm.Error, { className: "solvapay-checkout-error" }),
|
|
8741
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PaymentForm.MandateText, {}),
|
|
8742
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "solvapay-secure-note", children: "Secure payment processed by Stripe" }),
|
|
8743
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PaymentForm.SubmitButton, { className: "solvapay-checkout-pay-button", children: isRecurring ? `Subscribe \u2014 ${priceLine}` : `Pay ${formattedAmount}` })
|
|
8710
8744
|
]
|
|
8711
8745
|
}
|
|
8712
8746
|
)
|
|
8713
8747
|
] });
|
|
8714
8748
|
}
|
|
8715
|
-
var CheckoutEnvContext = (0,
|
|
8749
|
+
var CheckoutEnvContext = (0, import_react39.createContext)(null);
|
|
8716
8750
|
function useReturnUrl() {
|
|
8717
|
-
return (0,
|
|
8751
|
+
return (0, import_react39.useContext)(CheckoutEnvContext)?.returnUrl ?? "";
|
|
8718
8752
|
}
|
|
8719
8753
|
function useProductRef() {
|
|
8720
|
-
return (0,
|
|
8754
|
+
return (0, import_react39.useContext)(CheckoutEnvContext)?.productRef ?? "";
|
|
8721
8755
|
}
|
|
8722
|
-
var BackLink = (0,
|
|
8756
|
+
var BackLink = (0, import_react39.forwardRef)(function CheckoutStepsBackLink({ label, glyph = "\u2190", className, onClick, ...rest }, ref) {
|
|
8723
8757
|
const flow = useCheckoutContext("BackLink");
|
|
8724
8758
|
if (!flow.canGoBack) return null;
|
|
8725
8759
|
const resolvedLabel = label ?? (flow.step === "payment" && flow.branch === "payg" ? "Change amount" : flow.step === "payment" && flow.branch === "recurring" ? "Change plan" : "Back");
|
|
8726
|
-
return /* @__PURE__ */ (0,
|
|
8760
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
8727
8761
|
"button",
|
|
8728
8762
|
{
|
|
8729
8763
|
ref,
|
|
@@ -8737,8 +8771,8 @@ var BackLink = (0, import_react38.forwardRef)(function CheckoutStepsBackLink({ l
|
|
|
8737
8771
|
},
|
|
8738
8772
|
...rest,
|
|
8739
8773
|
children: [
|
|
8740
|
-
/* @__PURE__ */ (0,
|
|
8741
|
-
/* @__PURE__ */ (0,
|
|
8774
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "solvapay-checkout-back-link-glyph", "aria-hidden": "true", children: glyph }),
|
|
8775
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "solvapay-checkout-back-link-label", children: resolvedLabel })
|
|
8742
8776
|
]
|
|
8743
8777
|
}
|
|
8744
8778
|
);
|
|
@@ -8748,80 +8782,80 @@ function Success({ className, children }) {
|
|
|
8748
8782
|
const locale = useLocale();
|
|
8749
8783
|
if (flow.step !== "success" || !flow.successMeta) return null;
|
|
8750
8784
|
if (children) {
|
|
8751
|
-
return /* @__PURE__ */ (0,
|
|
8785
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: className ?? "solvapay-checkout-success", children });
|
|
8752
8786
|
}
|
|
8753
8787
|
const meta = flow.successMeta;
|
|
8754
8788
|
if (meta.branch === "payg") {
|
|
8755
8789
|
const chargedAmount = meta.amountMinor;
|
|
8756
8790
|
const chargedCurrency = meta.currency;
|
|
8757
8791
|
const charged = chargedAmount != null && chargedCurrency != null;
|
|
8758
|
-
return /* @__PURE__ */ (0,
|
|
8759
|
-
/* @__PURE__ */ (0,
|
|
8760
|
-
/* @__PURE__ */ (0,
|
|
8761
|
-
/* @__PURE__ */ (0,
|
|
8762
|
-
/* @__PURE__ */ (0,
|
|
8763
|
-
charged ? /* @__PURE__ */ (0,
|
|
8764
|
-
/* @__PURE__ */ (0,
|
|
8765
|
-
/* @__PURE__ */ (0,
|
|
8766
|
-
/* @__PURE__ */ (0,
|
|
8792
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: className ?? "solvapay-checkout-success", "data-branch": "payg", children: [
|
|
8793
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "solvapay-checkout-success-check", "aria-hidden": "true", children: "\u2713" }),
|
|
8794
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("h2", { className: "solvapay-checkout-success-heading", children: charged ? "Credits added" : "Plan activated" }),
|
|
8795
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "solvapay-checkout-success-subheading", children: "Pay as you go plan is active." }),
|
|
8796
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("dl", { className: "solvapay-checkout-receipt", "data-variant": "payg", children: [
|
|
8797
|
+
charged ? /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
|
|
8798
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "solvapay-checkout-receipt-row", children: [
|
|
8799
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("dt", { children: "Amount" }),
|
|
8800
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("dd", { children: formatPrice(chargedAmount, chargedCurrency, { locale }) })
|
|
8767
8801
|
] }),
|
|
8768
|
-
/* @__PURE__ */ (0,
|
|
8769
|
-
/* @__PURE__ */ (0,
|
|
8770
|
-
/* @__PURE__ */ (0,
|
|
8802
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "solvapay-checkout-receipt-row", children: [
|
|
8803
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("dt", { children: "Credits" }),
|
|
8804
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("dd", { children: [
|
|
8771
8805
|
"+",
|
|
8772
8806
|
(meta.creditsAdded ?? 0).toLocaleString(locale)
|
|
8773
8807
|
] })
|
|
8774
8808
|
] })
|
|
8775
8809
|
] }) : null,
|
|
8776
|
-
/* @__PURE__ */ (0,
|
|
8777
|
-
/* @__PURE__ */ (0,
|
|
8778
|
-
/* @__PURE__ */ (0,
|
|
8810
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "solvapay-checkout-receipt-row", children: [
|
|
8811
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("dt", { children: "Plan" }),
|
|
8812
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("dd", { children: meta.plan.name ?? "Pay as you go" })
|
|
8779
8813
|
] }),
|
|
8780
|
-
meta.rateLabel ? /* @__PURE__ */ (0,
|
|
8781
|
-
/* @__PURE__ */ (0,
|
|
8782
|
-
/* @__PURE__ */ (0,
|
|
8814
|
+
meta.rateLabel ? /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "solvapay-checkout-receipt-row", children: [
|
|
8815
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("dt", { children: "Rate" }),
|
|
8816
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("dd", { children: meta.rateLabel })
|
|
8783
8817
|
] }) : null
|
|
8784
8818
|
] })
|
|
8785
8819
|
] });
|
|
8786
8820
|
}
|
|
8787
|
-
return /* @__PURE__ */ (0,
|
|
8788
|
-
/* @__PURE__ */ (0,
|
|
8789
|
-
/* @__PURE__ */ (0,
|
|
8821
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: className ?? "solvapay-checkout-success", "data-branch": "recurring", children: [
|
|
8822
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "solvapay-checkout-success-check", "aria-hidden": "true", children: "\u2713" }),
|
|
8823
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("h2", { className: "solvapay-checkout-success-heading", children: [
|
|
8790
8824
|
meta.plan.name ?? "Plan",
|
|
8791
8825
|
" active"
|
|
8792
8826
|
] }),
|
|
8793
|
-
/* @__PURE__ */ (0,
|
|
8794
|
-
/* @__PURE__ */ (0,
|
|
8795
|
-
/* @__PURE__ */ (0,
|
|
8796
|
-
/* @__PURE__ */ (0,
|
|
8797
|
-
/* @__PURE__ */ (0,
|
|
8827
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "solvapay-checkout-success-subheading", children: "Subscription is live and credits are ready." }),
|
|
8828
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("dl", { className: "solvapay-checkout-receipt", "data-variant": "recurring", children: [
|
|
8829
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "solvapay-checkout-receipt-row", children: [
|
|
8830
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("dt", { children: "Plan" }),
|
|
8831
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("dd", { children: meta.plan.name ?? "Plan" })
|
|
8798
8832
|
] }),
|
|
8799
|
-
meta.includedUnits != null ? /* @__PURE__ */ (0,
|
|
8800
|
-
/* @__PURE__ */ (0,
|
|
8801
|
-
/* @__PURE__ */ (0,
|
|
8833
|
+
meta.includedUnits != null ? /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "solvapay-checkout-receipt-row", children: [
|
|
8834
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("dt", { children: "Included" }),
|
|
8835
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("dd", { children: [
|
|
8802
8836
|
meta.includedUnits.toLocaleString(locale),
|
|
8803
8837
|
" ",
|
|
8804
8838
|
meta.meterName ?? "units"
|
|
8805
8839
|
] })
|
|
8806
8840
|
] }) : null,
|
|
8807
|
-
/* @__PURE__ */ (0,
|
|
8808
|
-
/* @__PURE__ */ (0,
|
|
8809
|
-
/* @__PURE__ */ (0,
|
|
8841
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "solvapay-checkout-receipt-row", children: [
|
|
8842
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("dt", { children: "Charged today" }),
|
|
8843
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("dd", { children: formatPrice(meta.chargedTodayMinor, meta.currency, { locale }) })
|
|
8810
8844
|
] }),
|
|
8811
|
-
meta.nextRenewalLabel ? /* @__PURE__ */ (0,
|
|
8812
|
-
/* @__PURE__ */ (0,
|
|
8813
|
-
/* @__PURE__ */ (0,
|
|
8845
|
+
meta.nextRenewalLabel ? /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "solvapay-checkout-receipt-row", children: [
|
|
8846
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("dt", { children: "Next renewal" }),
|
|
8847
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("dd", { children: meta.nextRenewalLabel })
|
|
8814
8848
|
] }) : null
|
|
8815
8849
|
] })
|
|
8816
8850
|
] });
|
|
8817
8851
|
}
|
|
8818
|
-
var RootWithEnv = (0,
|
|
8852
|
+
var RootWithEnv = (0, import_react39.forwardRef)(
|
|
8819
8853
|
function CheckoutStepsRootWithEnv(props, forwardedRef) {
|
|
8820
|
-
const env = (0,
|
|
8854
|
+
const env = (0, import_react39.useMemo)(
|
|
8821
8855
|
() => ({ returnUrl: props.returnUrl, productRef: props.productRef }),
|
|
8822
8856
|
[props.returnUrl, props.productRef]
|
|
8823
8857
|
);
|
|
8824
|
-
return /* @__PURE__ */ (0,
|
|
8858
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CheckoutEnvContext.Provider, { value: env, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Root11, { ...props, ref: forwardedRef }) });
|
|
8825
8859
|
}
|
|
8826
8860
|
);
|
|
8827
8861
|
var CheckoutSteps = {
|
|
@@ -8850,7 +8884,7 @@ var CheckoutStepsBackLink2 = BackLink;
|
|
|
8850
8884
|
var CheckoutStepsSuccess = Success;
|
|
8851
8885
|
|
|
8852
8886
|
// src/hooks/usePaywallResolver.ts
|
|
8853
|
-
var
|
|
8887
|
+
var import_react40 = require("react");
|
|
8854
8888
|
function balanceCoversNextUnit(balance, credits) {
|
|
8855
8889
|
if (!balance) return false;
|
|
8856
8890
|
if (typeof balance.remainingUnits === "number" && balance.remainingUnits > 0) {
|
|
@@ -8864,7 +8898,7 @@ function balanceCoversNextUnit(balance, credits) {
|
|
|
8864
8898
|
function usePaywallResolver(content) {
|
|
8865
8899
|
const { activePurchase, hasPaidPurchase, refetch: refetchPurchase } = usePurchase();
|
|
8866
8900
|
const { credits, refetch: refetchBalance } = useBalance();
|
|
8867
|
-
const resolved = (0,
|
|
8901
|
+
const resolved = (0, import_react40.useMemo)(() => {
|
|
8868
8902
|
if (!content) return false;
|
|
8869
8903
|
const productMatches = !content.product || activePurchase?.productRef === content.product || activePurchase?.productName === content.product;
|
|
8870
8904
|
if (content.kind === "payment_required") {
|
|
@@ -8874,7 +8908,7 @@ function usePaywallResolver(content) {
|
|
|
8874
8908
|
if (balanceCoversNextUnit(content.balance, credits)) return true;
|
|
8875
8909
|
return Boolean(productMatches && activePurchase?.status === "active");
|
|
8876
8910
|
}, [content, hasPaidPurchase, activePurchase, credits]);
|
|
8877
|
-
const refetch = (0,
|
|
8911
|
+
const refetch = (0, import_react40.useCallback)(async () => {
|
|
8878
8912
|
await Promise.all([
|
|
8879
8913
|
refetchPurchase().catch(() => void 0),
|
|
8880
8914
|
refetchBalance().catch(() => void 0)
|
|
@@ -8884,32 +8918,32 @@ function usePaywallResolver(content) {
|
|
|
8884
8918
|
}
|
|
8885
8919
|
|
|
8886
8920
|
// src/primitives/PaywallNotice.tsx
|
|
8887
|
-
var
|
|
8888
|
-
var PaywallNoticeContext = (0,
|
|
8921
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
8922
|
+
var PaywallNoticeContext = (0, import_react41.createContext)(null);
|
|
8889
8923
|
function usePaywallNoticeCtx(part) {
|
|
8890
|
-
const ctx = (0,
|
|
8924
|
+
const ctx = (0, import_react41.useContext)(PaywallNoticeContext);
|
|
8891
8925
|
if (!ctx) {
|
|
8892
8926
|
throw new Error(`PaywallNotice.${part} must be rendered inside <PaywallNotice.Root>.`);
|
|
8893
8927
|
}
|
|
8894
8928
|
return ctx;
|
|
8895
8929
|
}
|
|
8896
|
-
var Root12 = (0,
|
|
8930
|
+
var Root12 = (0, import_react41.forwardRef)(function PaywallNoticeRoot({ content, onResolved, classNames, asChild, children, ...rest }, forwardedRef) {
|
|
8897
8931
|
const { resolved, refetch } = usePaywallResolver(content);
|
|
8898
|
-
const classNamesResolved = (0,
|
|
8899
|
-
const onResolvedRef = (0,
|
|
8900
|
-
(0,
|
|
8932
|
+
const classNamesResolved = (0, import_react41.useMemo)(() => classNames ?? {}, [classNames]);
|
|
8933
|
+
const onResolvedRef = (0, import_react41.useRef)(onResolved);
|
|
8934
|
+
(0, import_react41.useEffect)(() => {
|
|
8901
8935
|
onResolvedRef.current = onResolved;
|
|
8902
8936
|
}, [onResolved]);
|
|
8903
|
-
const hasResolvedRef = (0,
|
|
8904
|
-
const signalResolved = (0,
|
|
8937
|
+
const hasResolvedRef = (0, import_react41.useRef)(false);
|
|
8938
|
+
const signalResolved = (0, import_react41.useCallback)(() => {
|
|
8905
8939
|
if (hasResolvedRef.current) return;
|
|
8906
8940
|
hasResolvedRef.current = true;
|
|
8907
8941
|
onResolvedRef.current?.();
|
|
8908
8942
|
}, []);
|
|
8909
|
-
(0,
|
|
8943
|
+
(0, import_react41.useEffect)(() => {
|
|
8910
8944
|
if (resolved) signalResolved();
|
|
8911
8945
|
}, [resolved, signalResolved]);
|
|
8912
|
-
const ctx = (0,
|
|
8946
|
+
const ctx = (0, import_react41.useMemo)(
|
|
8913
8947
|
() => ({
|
|
8914
8948
|
content,
|
|
8915
8949
|
resolved,
|
|
@@ -8920,7 +8954,7 @@ var Root12 = (0, import_react40.forwardRef)(function PaywallNoticeRoot({ content
|
|
|
8920
8954
|
[content, resolved, refetch, signalResolved, classNamesResolved]
|
|
8921
8955
|
);
|
|
8922
8956
|
const Comp = asChild ? Slot : "div";
|
|
8923
|
-
return /* @__PURE__ */ (0,
|
|
8957
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(PaywallNoticeContext.Provider, { value: ctx, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
8924
8958
|
Comp,
|
|
8925
8959
|
{
|
|
8926
8960
|
ref: forwardedRef,
|
|
@@ -8933,12 +8967,12 @@ var Root12 = (0, import_react40.forwardRef)(function PaywallNoticeRoot({ content
|
|
|
8933
8967
|
}
|
|
8934
8968
|
) });
|
|
8935
8969
|
});
|
|
8936
|
-
var Heading4 = (0,
|
|
8970
|
+
var Heading4 = (0, import_react41.forwardRef)(function PaywallNoticeHeading({ asChild, children, className, ...rest }, forwardedRef) {
|
|
8937
8971
|
const ctx = usePaywallNoticeCtx("Heading");
|
|
8938
8972
|
const copy = useCopy();
|
|
8939
8973
|
const defaultText = ctx.resolved ? copy.paywall.resolvedHeading : ctx.content.kind === "payment_required" ? copy.paywall.paymentRequiredHeading : isTopupGate(ctx.content) ? copy.paywall.topupRequiredHeading : copy.paywall.activationRequiredHeading;
|
|
8940
8974
|
const Comp = asChild ? Slot : "h2";
|
|
8941
|
-
return /* @__PURE__ */ (0,
|
|
8975
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
8942
8976
|
Comp,
|
|
8943
8977
|
{
|
|
8944
8978
|
ref: forwardedRef,
|
|
@@ -8949,12 +8983,12 @@ var Heading4 = (0, import_react40.forwardRef)(function PaywallNoticeHeading({ as
|
|
|
8949
8983
|
}
|
|
8950
8984
|
);
|
|
8951
8985
|
});
|
|
8952
|
-
var Message = (0,
|
|
8986
|
+
var Message = (0, import_react41.forwardRef)(function PaywallNoticeMessage({ asChild, children, className, ...rest }, forwardedRef) {
|
|
8953
8987
|
const ctx = usePaywallNoticeCtx("Message");
|
|
8954
8988
|
const copy = useCopy();
|
|
8955
8989
|
const Comp = asChild ? Slot : "p";
|
|
8956
8990
|
const defaultText = resolvePaywallMessage(ctx.content, copy.paywall);
|
|
8957
|
-
return /* @__PURE__ */ (0,
|
|
8991
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
8958
8992
|
Comp,
|
|
8959
8993
|
{
|
|
8960
8994
|
ref: forwardedRef,
|
|
@@ -9003,14 +9037,14 @@ function resolvePaywallMessage(content, paywallCopy) {
|
|
|
9003
9037
|
}
|
|
9004
9038
|
return content.message ?? "";
|
|
9005
9039
|
}
|
|
9006
|
-
var ProductContext = (0,
|
|
9040
|
+
var ProductContext = (0, import_react41.forwardRef)(function PaywallNoticeProductContext({ asChild, children, className, ...rest }, forwardedRef) {
|
|
9007
9041
|
const ctx = usePaywallNoticeCtx("ProductContext");
|
|
9008
9042
|
const copy = useCopy();
|
|
9009
9043
|
const product = ctx.content.kind === "activation_required" ? ctx.content.productDetails : void 0;
|
|
9010
9044
|
if (!product?.name) return null;
|
|
9011
9045
|
const label = interpolate(copy.paywall.productContext, { product: product.name });
|
|
9012
9046
|
const Comp = asChild ? Slot : "div";
|
|
9013
|
-
return /* @__PURE__ */ (0,
|
|
9047
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
9014
9048
|
Comp,
|
|
9015
9049
|
{
|
|
9016
9050
|
ref: forwardedRef,
|
|
@@ -9021,7 +9055,7 @@ var ProductContext = (0, import_react40.forwardRef)(function PaywallNoticeProduc
|
|
|
9021
9055
|
}
|
|
9022
9056
|
);
|
|
9023
9057
|
});
|
|
9024
|
-
var Balance = (0,
|
|
9058
|
+
var Balance = (0, import_react41.forwardRef)(function PaywallNoticeBalance({ asChild, children, className, ...rest }, forwardedRef) {
|
|
9025
9059
|
const ctx = usePaywallNoticeCtx("Balance");
|
|
9026
9060
|
const copy = useCopy();
|
|
9027
9061
|
const balance = ctx.content.balance;
|
|
@@ -9031,7 +9065,7 @@ var Balance = (0, import_react40.forwardRef)(function PaywallNoticeBalance({ asC
|
|
|
9031
9065
|
required: String(balance.creditsPerUnit ?? 1)
|
|
9032
9066
|
});
|
|
9033
9067
|
const Comp = asChild ? Slot : "div";
|
|
9034
|
-
return /* @__PURE__ */ (0,
|
|
9068
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
9035
9069
|
Comp,
|
|
9036
9070
|
{
|
|
9037
9071
|
ref: forwardedRef,
|
|
@@ -9047,27 +9081,28 @@ function Plans({ className, children }) {
|
|
|
9047
9081
|
if (ctx.content.kind !== "activation_required") return null;
|
|
9048
9082
|
if (!ctx.content.product) return null;
|
|
9049
9083
|
const defaultClass = className ?? ctx.classNames.plans ?? "solvapay-paywall-plans";
|
|
9050
|
-
return /* @__PURE__ */ (0,
|
|
9051
|
-
/* @__PURE__ */ (0,
|
|
9052
|
-
/* @__PURE__ */ (0,
|
|
9053
|
-
/* @__PURE__ */ (0,
|
|
9054
|
-
/* @__PURE__ */ (0,
|
|
9055
|
-
/* @__PURE__ */ (0,
|
|
9084
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { "data-solvapay-paywall-plans": "", className: defaultClass, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(PlanSelector.Root, { productRef: ctx.content.product, filter: hidesFreePlan, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_jsx_runtime27.Fragment, { children: [
|
|
9085
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(PlanSelector.Grid, { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(PlanSelector.Card, { children: [
|
|
9086
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(PlanSelector.CardBadge, {}),
|
|
9087
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(PlanSelector.CardName, {}),
|
|
9088
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(PlanSelector.CardPrice, {}),
|
|
9089
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(PlanSelector.CardInterval, {})
|
|
9056
9090
|
] }) }),
|
|
9057
|
-
/* @__PURE__ */ (0,
|
|
9058
|
-
/* @__PURE__ */ (0,
|
|
9091
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(PlanSelector.Loading, {}),
|
|
9092
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(PlanSelector.Error, {})
|
|
9059
9093
|
] }) }) });
|
|
9060
9094
|
}
|
|
9061
9095
|
function hidesFreePlan(plan) {
|
|
9062
9096
|
return plan.requiresPayment !== false;
|
|
9063
9097
|
}
|
|
9064
|
-
var HostedCheckoutLink = (0,
|
|
9098
|
+
var HostedCheckoutLink = (0, import_react41.forwardRef)(function PaywallNoticeHostedCheckoutLink({ asChild, children, className, onClick, ...rest }, forwardedRef) {
|
|
9065
9099
|
const ctx = usePaywallNoticeCtx("HostedCheckoutLink");
|
|
9066
9100
|
const copy = useCopy();
|
|
9101
|
+
const handleExternalClick = useExternalLinkClick();
|
|
9067
9102
|
const href = ctx.content.checkoutUrl;
|
|
9068
9103
|
if (!href) return null;
|
|
9069
9104
|
const Comp = asChild ? Slot : "a";
|
|
9070
|
-
return /* @__PURE__ */ (0,
|
|
9105
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
9071
9106
|
Comp,
|
|
9072
9107
|
{
|
|
9073
9108
|
ref: forwardedRef,
|
|
@@ -9076,6 +9111,7 @@ var HostedCheckoutLink = (0, import_react40.forwardRef)(function PaywallNoticeHo
|
|
|
9076
9111
|
rel: "noopener noreferrer",
|
|
9077
9112
|
"data-solvapay-paywall-hosted-link": "",
|
|
9078
9113
|
className: className ?? ctx.classNames.hostedLink,
|
|
9114
|
+
onClick: composeEventHandlers(onClick, handleExternalClick),
|
|
9079
9115
|
...rest,
|
|
9080
9116
|
children: children ?? copy.paywall.hostedCheckoutButton
|
|
9081
9117
|
}
|
|
@@ -9085,12 +9121,12 @@ function EmbeddedCheckout({ returnUrl, topupCurrency, className }) {
|
|
|
9085
9121
|
const ctx = usePaywallNoticeCtx("EmbeddedCheckout");
|
|
9086
9122
|
const productRef = ctx.content.product;
|
|
9087
9123
|
const { plans } = usePlans({ productRef: productRef ?? void 0 });
|
|
9088
|
-
const filter = (0,
|
|
9124
|
+
const filter = (0, import_react41.useMemo)(() => buildDefaultCheckoutPlanFilter(plans), [plans]);
|
|
9089
9125
|
if (!productRef) return null;
|
|
9090
9126
|
const resolvedClassName = className ?? ctx.classNames.embeddedCheckout ?? "solvapay-paywall-embedded-checkout";
|
|
9091
9127
|
const headingClassName = ctx.classNames.heading ?? "solvapay-paywall-step-heading";
|
|
9092
9128
|
const messageClassName = ctx.classNames.message ?? "solvapay-paywall-step-message";
|
|
9093
|
-
return /* @__PURE__ */ (0,
|
|
9129
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
9094
9130
|
CheckoutSteps.Root,
|
|
9095
9131
|
{
|
|
9096
9132
|
productRef,
|
|
@@ -9103,33 +9139,33 @@ function EmbeddedCheckout({ returnUrl, topupCurrency, className }) {
|
|
|
9103
9139
|
},
|
|
9104
9140
|
className: resolvedClassName,
|
|
9105
9141
|
children: [
|
|
9106
|
-
/* @__PURE__ */ (0,
|
|
9107
|
-
/* @__PURE__ */ (0,
|
|
9108
|
-
/* @__PURE__ */ (0,
|
|
9109
|
-
/* @__PURE__ */ (0,
|
|
9110
|
-
/* @__PURE__ */ (0,
|
|
9111
|
-
/* @__PURE__ */ (0,
|
|
9112
|
-
/* @__PURE__ */ (0,
|
|
9142
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CheckoutSteps.StepHeading, { className: headingClassName }),
|
|
9143
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CheckoutSteps.StepMessage, { className: messageClassName }),
|
|
9144
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(CheckoutSteps.IfStep, { step: "plan", children: [
|
|
9145
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CheckoutSteps.PlanGrid, {}),
|
|
9146
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(PlanSelector.Loading, {}),
|
|
9147
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(PlanSelector.Error, {}),
|
|
9148
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CheckoutSteps.PlanContinueButton, {})
|
|
9113
9149
|
] }),
|
|
9114
|
-
/* @__PURE__ */ (0,
|
|
9115
|
-
/* @__PURE__ */ (0,
|
|
9116
|
-
/* @__PURE__ */ (0,
|
|
9117
|
-
/* @__PURE__ */ (0,
|
|
9150
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(CheckoutSteps.IfStep, { step: "amount", children: [
|
|
9151
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CheckoutSteps.BackLink, {}),
|
|
9152
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CheckoutSteps.AmountPicker, {}),
|
|
9153
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CheckoutSteps.AmountContinueButton, {})
|
|
9118
9154
|
] }),
|
|
9119
|
-
/* @__PURE__ */ (0,
|
|
9120
|
-
/* @__PURE__ */ (0,
|
|
9121
|
-
/* @__PURE__ */ (0,
|
|
9155
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(CheckoutSteps.IfStep, { step: "payment", children: [
|
|
9156
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CheckoutSteps.BackLink, {}),
|
|
9157
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CheckoutSteps.Payment, {})
|
|
9122
9158
|
] }),
|
|
9123
|
-
/* @__PURE__ */ (0,
|
|
9159
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CheckoutSteps.IfStep, { step: "success", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CheckoutSteps.Success, {}) })
|
|
9124
9160
|
]
|
|
9125
9161
|
}
|
|
9126
9162
|
);
|
|
9127
9163
|
}
|
|
9128
|
-
var Retry = (0,
|
|
9164
|
+
var Retry = (0, import_react41.forwardRef)(function PaywallNoticeRetry({ asChild, children, className, onClick, ...rest }, forwardedRef) {
|
|
9129
9165
|
const ctx = usePaywallNoticeCtx("Retry");
|
|
9130
9166
|
const copy = useCopy();
|
|
9131
9167
|
const Comp = asChild ? Slot : "button";
|
|
9132
|
-
return /* @__PURE__ */ (0,
|
|
9168
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
9133
9169
|
Comp,
|
|
9134
9170
|
{
|
|
9135
9171
|
ref: forwardedRef,
|
|
@@ -9162,18 +9198,18 @@ function usePaywallNotice() {
|
|
|
9162
9198
|
return usePaywallNoticeCtx("usePaywallNotice");
|
|
9163
9199
|
}
|
|
9164
9200
|
function usePaywallNoticeOptional() {
|
|
9165
|
-
return (0,
|
|
9201
|
+
return (0, import_react41.useContext)(PaywallNoticeContext);
|
|
9166
9202
|
}
|
|
9167
9203
|
|
|
9168
9204
|
// src/primitives/UsageMeter.tsx
|
|
9169
|
-
var
|
|
9205
|
+
var import_react44 = require("react");
|
|
9170
9206
|
|
|
9171
9207
|
// src/hooks/useUsage.ts
|
|
9172
9208
|
var import_core8 = require("@solvapay/core");
|
|
9173
|
-
var
|
|
9209
|
+
var import_react43 = require("react");
|
|
9174
9210
|
|
|
9175
9211
|
// src/hooks/useLimits.ts
|
|
9176
|
-
var
|
|
9212
|
+
var import_react42 = require("react");
|
|
9177
9213
|
var CACHE_TTL_MS = 1e4;
|
|
9178
9214
|
var OPTIMISTIC_GRACE_MS = 8e3;
|
|
9179
9215
|
var limitsCache = /* @__PURE__ */ new Map();
|
|
@@ -9190,13 +9226,13 @@ function useLimits(options) {
|
|
|
9190
9226
|
const { customerRef } = useCustomer();
|
|
9191
9227
|
const { purchase } = useSolvaPay();
|
|
9192
9228
|
const currentKey = !productRef || !enabled ? null : cacheKey(customerRef, productRef, meterName2);
|
|
9193
|
-
const [data, setData] = (0,
|
|
9229
|
+
const [data, setData] = (0, import_react42.useState)(() => {
|
|
9194
9230
|
if (!currentKey) return null;
|
|
9195
9231
|
const cached = limitsCache.get(currentKey);
|
|
9196
9232
|
if (!cached || Date.now() - cached.timestamp >= CACHE_TTL_MS) return null;
|
|
9197
9233
|
return cached.data;
|
|
9198
9234
|
});
|
|
9199
|
-
const [loading, setLoading] = (0,
|
|
9235
|
+
const [loading, setLoading] = (0, import_react42.useState)(() => {
|
|
9200
9236
|
if (!currentKey) return false;
|
|
9201
9237
|
const cached = limitsCache.get(currentKey);
|
|
9202
9238
|
if (!cached) return true;
|
|
@@ -9204,24 +9240,24 @@ function useLimits(options) {
|
|
|
9204
9240
|
if (Date.now() - cached.timestamp >= CACHE_TTL_MS) return true;
|
|
9205
9241
|
return false;
|
|
9206
9242
|
});
|
|
9207
|
-
const [error, setError] = (0,
|
|
9208
|
-
const [trackedKey, setTrackedKey] = (0,
|
|
9243
|
+
const [error, setError] = (0, import_react42.useState)(null);
|
|
9244
|
+
const [trackedKey, setTrackedKey] = (0, import_react42.useState)(currentKey);
|
|
9209
9245
|
if (trackedKey !== currentKey) {
|
|
9210
9246
|
setTrackedKey(currentKey);
|
|
9211
9247
|
setData(null);
|
|
9212
9248
|
}
|
|
9213
9249
|
const unlimited = data === null ? null : isUnlimited(data.remaining);
|
|
9214
|
-
const optimisticTimerRef = (0,
|
|
9215
|
-
const unlimitedRef = (0,
|
|
9216
|
-
(0,
|
|
9250
|
+
const optimisticTimerRef = (0, import_react42.useRef)(null);
|
|
9251
|
+
const unlimitedRef = (0, import_react42.useRef)(false);
|
|
9252
|
+
(0, import_react42.useEffect)(() => {
|
|
9217
9253
|
unlimitedRef.current = unlimited === true;
|
|
9218
9254
|
}, [unlimited]);
|
|
9219
|
-
(0,
|
|
9255
|
+
(0, import_react42.useEffect)(() => {
|
|
9220
9256
|
return () => {
|
|
9221
9257
|
if (optimisticTimerRef.current) clearTimeout(optimisticTimerRef.current);
|
|
9222
9258
|
};
|
|
9223
9259
|
}, []);
|
|
9224
|
-
const attachToFetch = (0,
|
|
9260
|
+
const attachToFetch = (0, import_react42.useCallback)(
|
|
9225
9261
|
async (promise) => {
|
|
9226
9262
|
setLoading(true);
|
|
9227
9263
|
try {
|
|
@@ -9238,7 +9274,7 @@ function useLimits(options) {
|
|
|
9238
9274
|
},
|
|
9239
9275
|
[]
|
|
9240
9276
|
);
|
|
9241
|
-
const fetchLimits = (0,
|
|
9277
|
+
const fetchLimits = (0, import_react42.useCallback)(
|
|
9242
9278
|
async (force) => {
|
|
9243
9279
|
if (!productRef || !enabled || !transport.getLimits) {
|
|
9244
9280
|
setLoading(false);
|
|
@@ -9268,19 +9304,19 @@ function useLimits(options) {
|
|
|
9268
9304
|
},
|
|
9269
9305
|
[transport, customerRef, productRef, meterName2, enabled, attachToFetch]
|
|
9270
9306
|
);
|
|
9271
|
-
(0,
|
|
9307
|
+
(0, import_react42.useEffect)(() => {
|
|
9272
9308
|
fetchLimits(false);
|
|
9273
9309
|
}, [fetchLimits]);
|
|
9274
|
-
const prevPurchasesRef = (0,
|
|
9275
|
-
(0,
|
|
9310
|
+
const prevPurchasesRef = (0, import_react42.useRef)(null);
|
|
9311
|
+
(0, import_react42.useEffect)(() => {
|
|
9276
9312
|
if (prevPurchasesRef.current !== null && prevPurchasesRef.current !== purchase.purchases) {
|
|
9277
9313
|
fetchLimits(true).catch(() => {
|
|
9278
9314
|
});
|
|
9279
9315
|
}
|
|
9280
9316
|
prevPurchasesRef.current = purchase.purchases;
|
|
9281
9317
|
}, [purchase.purchases, fetchLimits]);
|
|
9282
|
-
const refetch = (0,
|
|
9283
|
-
const adjustRemaining = (0,
|
|
9318
|
+
const refetch = (0, import_react42.useCallback)(() => fetchLimits(true), [fetchLimits]);
|
|
9319
|
+
const adjustRemaining = (0, import_react42.useCallback)(
|
|
9284
9320
|
(delta) => {
|
|
9285
9321
|
if (!productRef || !enabled) return;
|
|
9286
9322
|
if (unlimitedRef.current) return;
|
|
@@ -9357,9 +9393,9 @@ function deriveUsage(purchase, limits) {
|
|
|
9357
9393
|
function useUsage() {
|
|
9358
9394
|
const { activePurchase, refetch: refetchPurchase, loading: purchaseLoading } = usePurchase();
|
|
9359
9395
|
const transport = useTransport();
|
|
9360
|
-
const [override, setOverride] = (0,
|
|
9361
|
-
const [error, setError] = (0,
|
|
9362
|
-
const [transportLoading, setTransportLoading] = (0,
|
|
9396
|
+
const [override, setOverride] = (0, import_react43.useState)(null);
|
|
9397
|
+
const [error, setError] = (0, import_react43.useState)(null);
|
|
9398
|
+
const [transportLoading, setTransportLoading] = (0, import_react43.useState)(false);
|
|
9363
9399
|
const usageCounted = (0, import_core8.countsUsage)(activePurchase?.planSnapshot) || activePurchase?.planSnapshot?.isMetered === true;
|
|
9364
9400
|
const {
|
|
9365
9401
|
remaining: limitRemaining,
|
|
@@ -9369,16 +9405,16 @@ function useUsage() {
|
|
|
9369
9405
|
productRef: activePurchase?.productRef,
|
|
9370
9406
|
enabled: usageCounted
|
|
9371
9407
|
});
|
|
9372
|
-
const derived = (0,
|
|
9408
|
+
const derived = (0, import_react43.useMemo)(
|
|
9373
9409
|
() => deriveUsage(activePurchase ?? null, { remaining: limitRemaining, unlimited, meterName: meterName2 }),
|
|
9374
9410
|
[activePurchase, limitRemaining, unlimited, meterName2]
|
|
9375
9411
|
);
|
|
9376
9412
|
const activePurchaseRef = activePurchase?.reference ?? null;
|
|
9377
|
-
(0,
|
|
9413
|
+
(0, import_react43.useEffect)(() => {
|
|
9378
9414
|
setOverride(null);
|
|
9379
9415
|
}, [activePurchaseRef]);
|
|
9380
9416
|
const usage = override ?? derived;
|
|
9381
|
-
const refetch = (0,
|
|
9417
|
+
const refetch = (0, import_react43.useCallback)(async () => {
|
|
9382
9418
|
setError(null);
|
|
9383
9419
|
if (typeof transport.getUsage === "function") {
|
|
9384
9420
|
setTransportLoading(true);
|
|
@@ -9416,16 +9452,16 @@ function useUsage() {
|
|
|
9416
9452
|
}
|
|
9417
9453
|
|
|
9418
9454
|
// src/primitives/UsageMeter.tsx
|
|
9419
|
-
var
|
|
9420
|
-
var UsageMeterContext = (0,
|
|
9455
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
9456
|
+
var UsageMeterContext = (0, import_react44.createContext)(null);
|
|
9421
9457
|
function useUsageMeterCtx(part) {
|
|
9422
|
-
const ctx = (0,
|
|
9458
|
+
const ctx = (0, import_react44.useContext)(UsageMeterContext);
|
|
9423
9459
|
if (!ctx) {
|
|
9424
9460
|
throw new Error(`UsageMeter.${part} must be rendered inside <UsageMeter.Root>.`);
|
|
9425
9461
|
}
|
|
9426
9462
|
return ctx;
|
|
9427
9463
|
}
|
|
9428
|
-
var Root13 = (0,
|
|
9464
|
+
var Root13 = (0, import_react44.forwardRef)(function UsageMeterRoot({
|
|
9429
9465
|
warningAt = 75,
|
|
9430
9466
|
criticalAt = 90,
|
|
9431
9467
|
classNames,
|
|
@@ -9440,7 +9476,7 @@ var Root13 = (0, import_react43.forwardRef)(function UsageMeterRoot({
|
|
|
9440
9476
|
const loading = hookResult.loading && !usage;
|
|
9441
9477
|
const percentUsed = usage?.percentUsed ?? null;
|
|
9442
9478
|
const state = loading ? "loading" : percentUsed === null ? "safe" : percentUsed >= criticalAt ? "critical" : percentUsed >= warningAt ? "warning" : "safe";
|
|
9443
|
-
const ctx = (0,
|
|
9479
|
+
const ctx = (0, import_react44.useMemo)(
|
|
9444
9480
|
() => ({
|
|
9445
9481
|
usage,
|
|
9446
9482
|
loading,
|
|
@@ -9468,7 +9504,7 @@ var Root13 = (0, import_react43.forwardRef)(function UsageMeterRoot({
|
|
|
9468
9504
|
);
|
|
9469
9505
|
const rootClass = [classNames?.root ?? "solvapay-usage-meter", className].filter(Boolean).join(" ");
|
|
9470
9506
|
const Comp = asChild ? Slot : "section";
|
|
9471
|
-
return /* @__PURE__ */ (0,
|
|
9507
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(UsageMeterContext.Provider, { value: ctx, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
9472
9508
|
Comp,
|
|
9473
9509
|
{
|
|
9474
9510
|
ref: forwardedRef,
|
|
@@ -9480,10 +9516,10 @@ var Root13 = (0, import_react43.forwardRef)(function UsageMeterRoot({
|
|
|
9480
9516
|
}
|
|
9481
9517
|
) });
|
|
9482
9518
|
});
|
|
9483
|
-
var Bar = (0,
|
|
9519
|
+
var Bar = (0, import_react44.forwardRef)(function UsageMeterBar({ className, style, ...rest }, forwardedRef) {
|
|
9484
9520
|
const ctx = useUsageMeterCtx("Bar");
|
|
9485
9521
|
const width = ctx.percentUsed === null ? 0 : Math.max(0, Math.min(100, ctx.percentUsed));
|
|
9486
|
-
return /* @__PURE__ */ (0,
|
|
9522
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
9487
9523
|
"div",
|
|
9488
9524
|
{
|
|
9489
9525
|
ref: forwardedRef,
|
|
@@ -9504,12 +9540,12 @@ var Bar = (0, import_react43.forwardRef)(function UsageMeterBar({ className, sty
|
|
|
9504
9540
|
}
|
|
9505
9541
|
);
|
|
9506
9542
|
});
|
|
9507
|
-
var Label = (0,
|
|
9543
|
+
var Label = (0, import_react44.forwardRef)(function UsageMeterLabel({ className, children, ...rest }, forwardedRef) {
|
|
9508
9544
|
const ctx = useUsageMeterCtx("Label");
|
|
9509
9545
|
const copy = useCopy();
|
|
9510
9546
|
if (!ctx.usage) return null;
|
|
9511
9547
|
if (ctx.isUnlimited) {
|
|
9512
|
-
return /* @__PURE__ */ (0,
|
|
9548
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
9513
9549
|
"span",
|
|
9514
9550
|
{
|
|
9515
9551
|
ref: forwardedRef,
|
|
@@ -9529,7 +9565,7 @@ var Label = (0, import_react43.forwardRef)(function UsageMeterLabel({ className,
|
|
|
9529
9565
|
remaining: String(ctx.usage.remaining ?? 0),
|
|
9530
9566
|
unit
|
|
9531
9567
|
});
|
|
9532
|
-
return /* @__PURE__ */ (0,
|
|
9568
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
9533
9569
|
"span",
|
|
9534
9570
|
{
|
|
9535
9571
|
ref: forwardedRef,
|
|
@@ -9540,11 +9576,11 @@ var Label = (0, import_react43.forwardRef)(function UsageMeterLabel({ className,
|
|
|
9540
9576
|
}
|
|
9541
9577
|
);
|
|
9542
9578
|
});
|
|
9543
|
-
var Percentage = (0,
|
|
9579
|
+
var Percentage = (0, import_react44.forwardRef)(function UsageMeterPercentage({ className, children, ...rest }, forwardedRef) {
|
|
9544
9580
|
const ctx = useUsageMeterCtx("Percentage");
|
|
9545
9581
|
const copy = useCopy();
|
|
9546
9582
|
if (ctx.percentUsed === null) return null;
|
|
9547
|
-
return /* @__PURE__ */ (0,
|
|
9583
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
9548
9584
|
"span",
|
|
9549
9585
|
{
|
|
9550
9586
|
ref: forwardedRef,
|
|
@@ -9561,14 +9597,14 @@ function formatResetsIn(copy, periodEnd, nowMs = typeof performance !== "undefin
|
|
|
9561
9597
|
const daysLeft = Math.max(0, Math.ceil((end - nowMs) / (24 * 60 * 60 * 1e3)));
|
|
9562
9598
|
return daysLeft > 0 ? interpolate(copy.usage.resetsInLabel, { days: String(daysLeft) }) : interpolate(copy.usage.resetsOnLabel, { date: new Date(periodEnd).toLocaleDateString() });
|
|
9563
9599
|
}
|
|
9564
|
-
var ResetsIn = (0,
|
|
9600
|
+
var ResetsIn = (0, import_react44.forwardRef)(function UsageMeterResetsIn({ className, children, ...rest }, forwardedRef) {
|
|
9565
9601
|
const ctx = useUsageMeterCtx("ResetsIn");
|
|
9566
9602
|
const copy = useCopy();
|
|
9567
9603
|
const periodEnd = ctx.usage?.periodEnd;
|
|
9568
9604
|
if (!periodEnd) return null;
|
|
9569
9605
|
const label = formatResetsIn(copy, periodEnd);
|
|
9570
9606
|
if (!label) return null;
|
|
9571
|
-
return /* @__PURE__ */ (0,
|
|
9607
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
9572
9608
|
"span",
|
|
9573
9609
|
{
|
|
9574
9610
|
ref: forwardedRef,
|
|
@@ -9579,11 +9615,11 @@ var ResetsIn = (0, import_react43.forwardRef)(function UsageMeterResetsIn({ clas
|
|
|
9579
9615
|
}
|
|
9580
9616
|
);
|
|
9581
9617
|
});
|
|
9582
|
-
var Loading8 = (0,
|
|
9618
|
+
var Loading8 = (0, import_react44.forwardRef)(function UsageMeterLoading({ className, children, ...rest }, forwardedRef) {
|
|
9583
9619
|
const ctx = useUsageMeterCtx("Loading");
|
|
9584
9620
|
const copy = useCopy();
|
|
9585
9621
|
if (ctx.state !== "loading") return null;
|
|
9586
|
-
return /* @__PURE__ */ (0,
|
|
9622
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
9587
9623
|
"div",
|
|
9588
9624
|
{
|
|
9589
9625
|
ref: forwardedRef,
|
|
@@ -9595,11 +9631,11 @@ var Loading8 = (0, import_react43.forwardRef)(function UsageMeterLoading({ class
|
|
|
9595
9631
|
}
|
|
9596
9632
|
);
|
|
9597
9633
|
});
|
|
9598
|
-
var Empty = (0,
|
|
9634
|
+
var Empty = (0, import_react44.forwardRef)(function UsageMeterEmpty({ className, children, ...rest }, forwardedRef) {
|
|
9599
9635
|
const ctx = useUsageMeterCtx("Empty");
|
|
9600
9636
|
const copy = useCopy();
|
|
9601
9637
|
if (ctx.loading || ctx.usage !== null) return null;
|
|
9602
|
-
return /* @__PURE__ */ (0,
|
|
9638
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
9603
9639
|
"div",
|
|
9604
9640
|
{
|
|
9605
9641
|
ref: forwardedRef,
|