@solvapay/react 2.0.1 → 2.0.2-preview-55843c4d7bb67bbe89bfcdabbbe0e3a679eb2805

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.
@@ -322,7 +322,7 @@ function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForD
322
322
  }
323
323
 
324
324
  // src/primitives/CheckoutSummary.tsx
325
- var import_react9 = require("react");
325
+ var import_react10 = require("react");
326
326
 
327
327
  // src/hooks/usePlan.ts
328
328
  var import_react6 = require("react");
@@ -1505,6 +1505,297 @@ function usePlanSelection() {
1505
1505
  return (0, import_react8.useContext)(PlanSelectionContext);
1506
1506
  }
1507
1507
 
1508
+ // src/components/businessCheckoutParts.tsx
1509
+ var import_react9 = require("react");
1510
+ var import_core = require("@solvapay/core");
1511
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1512
+ function mapBusinessFieldErrors(input) {
1513
+ const result = (0, import_core.validateBusinessDetails)(input);
1514
+ if (result.success) return {};
1515
+ const errors = {};
1516
+ for (const issue of result.error.issues) {
1517
+ const key = issue.path[0];
1518
+ if (typeof key === "string" && isBusinessDetailsKey(key) && !errors[key]) {
1519
+ errors[key] = issue.message;
1520
+ }
1521
+ }
1522
+ return errors;
1523
+ }
1524
+ function isBusinessDetailsKey(key) {
1525
+ return key === "isBusiness" || key === "businessName" || key === "country" || key === "customerCountry" || key === "customerName" || key === "taxId" || key === "taxIdType";
1526
+ }
1527
+ function attr(prefix, suffix) {
1528
+ return `data-solvapay-${prefix}-${suffix}`;
1529
+ }
1530
+ var SUPPORTED_BUSINESS_COUNTRIES_SET = new Set(import_core.SUPPORTED_BUSINESS_COUNTRIES);
1531
+ function isSupportedBusinessCountry(value) {
1532
+ return SUPPORTED_BUSINESS_COUNTRIES_SET.has(value);
1533
+ }
1534
+ function resolveTaxIdLabel(country) {
1535
+ if (country && isSupportedBusinessCountry(country)) {
1536
+ return (0, import_core.getTaxIdFieldLabel)(country);
1537
+ }
1538
+ return "Tax ID";
1539
+ }
1540
+ function resolveTaxIdPlaceholder(country) {
1541
+ if (country && isSupportedBusinessCountry(country)) {
1542
+ return (0, import_core.getTaxIdExample)(country);
1543
+ }
1544
+ return "Enter tax ID";
1545
+ }
1546
+ function resolveTaxIdHelperText(country) {
1547
+ if (country && isSupportedBusinessCountry(country)) {
1548
+ return (0, import_core.getTaxIdHelperText)(country);
1549
+ }
1550
+ return "";
1551
+ }
1552
+ var REVERSE_CHARGE_NOTE = "VAT reverse charge applies \u2014 you are responsible for reporting VAT in your jurisdiction.";
1553
+ var TAX_NOT_COLLECTED_NOTE = "Tax is not collected on this purchase.";
1554
+ function formatVatSummaryLabel(breakdown) {
1555
+ if (breakdown.treatment === "reverse_charge") {
1556
+ return "VAT (reverse charge)";
1557
+ }
1558
+ if (breakdown.taxRate > 0) {
1559
+ const ratePercent = breakdown.taxRate <= 1 ? Math.round(breakdown.taxRate * 100) : breakdown.taxRate;
1560
+ return `VAT (${ratePercent}%)`;
1561
+ }
1562
+ return "VAT";
1563
+ }
1564
+ function shouldShowTaxRow(treatment) {
1565
+ return treatment !== "not_collecting" && treatment !== "not_supported";
1566
+ }
1567
+ function formatSubtotalLabel(treatment) {
1568
+ return shouldShowTaxRow(treatment) ? "Subtotal (excl. VAT)" : "Subtotal";
1569
+ }
1570
+ function createBusinessDetailsParts(useCtx, prefix) {
1571
+ const Root14 = (0, import_react9.forwardRef)(function BusinessDetailsRoot({ asChild, children, ...rest }, forwardedRef) {
1572
+ useCtx("BusinessDetails");
1573
+ const Comp = asChild ? Slot : "section";
1574
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Comp, { ref: forwardedRef, ...{ [attr(prefix, "business-details")]: "" }, ...rest, children });
1575
+ });
1576
+ const Toggle = (0, import_react9.forwardRef)(function BusinessDetailsToggle({ asChild, onChange, ...rest }, forwardedRef) {
1577
+ const ctx = useCtx("BusinessDetails.Toggle");
1578
+ const commonProps = {
1579
+ [attr(prefix, "business-details-toggle")]: "",
1580
+ type: "checkbox",
1581
+ checked: ctx.businessDetails.isBusiness,
1582
+ onChange: composeEventHandlers(onChange, (e) => {
1583
+ ctx.setBusinessDetails({ isBusiness: e.target.checked });
1584
+ }),
1585
+ ...rest
1586
+ };
1587
+ if (asChild) {
1588
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Slot, { ref: forwardedRef, ...commonProps });
1589
+ }
1590
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { ref: forwardedRef, ...commonProps });
1591
+ });
1592
+ const BusinessName = (0, import_react9.forwardRef)(
1593
+ function BusinessDetailsBusinessName({ asChild, onChange, ...rest }, forwardedRef) {
1594
+ const ctx = useCtx("BusinessDetails.BusinessName");
1595
+ if (!ctx.businessDetails.isBusiness) return null;
1596
+ const commonProps = {
1597
+ [attr(prefix, "business-details-name")]: "",
1598
+ type: "text",
1599
+ value: ctx.businessDetails.businessName ?? "",
1600
+ "aria-invalid": ctx.fieldErrors.businessName ? true : void 0,
1601
+ onChange: composeEventHandlers(onChange, (e) => {
1602
+ ctx.setBusinessDetails({ businessName: e.target.value });
1603
+ }),
1604
+ ...rest
1605
+ };
1606
+ if (asChild) {
1607
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Slot, { ref: forwardedRef, ...commonProps });
1608
+ }
1609
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { ref: forwardedRef, ...commonProps });
1610
+ }
1611
+ );
1612
+ const Country = (0, import_react9.forwardRef)(function BusinessDetailsCountry({ asChild, onChange, children, ...rest }, forwardedRef) {
1613
+ const ctx = useCtx("BusinessDetails.Country");
1614
+ if (!ctx.businessDetails.isBusiness) return null;
1615
+ const commonProps = {
1616
+ [attr(prefix, "business-details-country")]: "",
1617
+ value: ctx.businessDetails.country ?? "",
1618
+ "aria-invalid": ctx.fieldErrors.country ? true : void 0,
1619
+ onChange: composeEventHandlers(onChange, (e) => {
1620
+ ctx.setBusinessDetails({ country: e.target.value });
1621
+ }),
1622
+ ...rest
1623
+ };
1624
+ const defaultOptions = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1625
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "", children: "Select country" }),
1626
+ import_core.BUSINESS_COUNTRY_OPTIONS.map(({ value, label }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value, children: label }, value))
1627
+ ] });
1628
+ if (asChild) {
1629
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Slot, { ref: forwardedRef, ...commonProps, children: children ?? defaultOptions });
1630
+ }
1631
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("select", { ref: forwardedRef, ...commonProps, children: children ?? defaultOptions });
1632
+ });
1633
+ const TaxId = (0, import_react9.forwardRef)(function BusinessDetailsTaxId({ asChild, onChange, ...rest }, forwardedRef) {
1634
+ const ctx = useCtx("BusinessDetails.TaxId");
1635
+ if (!ctx.businessDetails.isBusiness) return null;
1636
+ const commonProps = {
1637
+ [attr(prefix, "business-details-tax-id")]: "",
1638
+ type: "text",
1639
+ value: ctx.businessDetails.taxId ?? "",
1640
+ "aria-invalid": ctx.fieldErrors.taxId ? true : void 0,
1641
+ onChange: composeEventHandlers(onChange, (e) => {
1642
+ ctx.setBusinessDetails({ taxId: e.target.value });
1643
+ }),
1644
+ ...rest
1645
+ };
1646
+ if (asChild) {
1647
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Slot, { ref: forwardedRef, ...commonProps });
1648
+ }
1649
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { ref: forwardedRef, ...commonProps });
1650
+ });
1651
+ const Fields2 = (0, import_react9.forwardRef)(function BusinessDetailsFields({ asChild, children, ...rest }, forwardedRef) {
1652
+ const ctx = useCtx("BusinessDetails.Fields");
1653
+ const country = ctx.businessDetails.country ?? "";
1654
+ const taxIdLabel = resolveTaxIdLabel(country);
1655
+ const taxIdPlaceholder = resolveTaxIdPlaceholder(country);
1656
+ const taxIdHelperText = resolveTaxIdHelperText(country);
1657
+ const content = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1658
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "solvapay-checkout-business-toggle", children: [
1659
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Toggle, {}),
1660
+ "I'm purchasing as a business"
1661
+ ] }),
1662
+ ctx.businessDetails.isBusiness ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("fieldset", { className: "solvapay-business-fields", children: [
1663
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "solvapay-business-field", children: [
1664
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "solvapay-business-field-label", children: "Business name" }),
1665
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(BusinessName, { placeholder: "Acme GmbH" })
1666
+ ] }),
1667
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "solvapay-business-field", children: [
1668
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "solvapay-business-field-label", children: "Country" }),
1669
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Country, {})
1670
+ ] }),
1671
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "solvapay-business-field", children: [
1672
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "solvapay-business-field-label", children: taxIdLabel }),
1673
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TaxId, { placeholder: taxIdPlaceholder }),
1674
+ taxIdHelperText ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "solvapay-business-field-hint", children: taxIdHelperText }) : null
1675
+ ] })
1676
+ ] }) : null,
1677
+ children
1678
+ ] });
1679
+ if (asChild) {
1680
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Slot, { ref: forwardedRef, ...rest, children: content });
1681
+ }
1682
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("section", { ref: forwardedRef, ...{ [attr(prefix, "business-details-fields")]: "" }, ...rest, children: content });
1683
+ });
1684
+ return {
1685
+ Root: Root14,
1686
+ Toggle,
1687
+ BusinessName,
1688
+ Country,
1689
+ TaxId,
1690
+ Fields: Fields2
1691
+ };
1692
+ }
1693
+ function useSummaryAmounts(useCtx, part) {
1694
+ const ctx = useCtx(part);
1695
+ const locale = useLocale();
1696
+ const currency = (ctx.taxBreakdown?.currency ?? ctx.currency ?? "usd").toLowerCase();
1697
+ const subtotalMinor = ctx.taxBreakdown?.subtotal ?? ctx.baseAmountMinor;
1698
+ const taxMinor = ctx.taxBreakdown?.taxAmount ?? 0;
1699
+ const totalMinor = ctx.taxBreakdown?.total ?? ctx.baseAmountMinor;
1700
+ return {
1701
+ // `free: ''` — a summary line is an amount, not a price. Without it
1702
+ // formatPrice turns any zero (VAT, and a zero subtotal or total) into
1703
+ // the word "Free". DEV-723.
1704
+ subtotalFormatted: formatPrice(subtotalMinor, currency, { locale, free: "" }),
1705
+ taxFormatted: formatPrice(taxMinor, currency, { locale, free: "" }),
1706
+ totalFormatted: formatPrice(totalMinor, currency, { locale, free: "" }),
1707
+ taxRate: ctx.taxBreakdown?.taxRate ?? 0,
1708
+ treatment: ctx.taxBreakdown?.treatment ?? null,
1709
+ attaching: ctx.businessDetailsAttaching
1710
+ };
1711
+ }
1712
+ function createTaxSummaryParts(useCtx, prefix) {
1713
+ const Root14 = (0, import_react9.forwardRef)(function TaxSummaryRoot({ asChild, children, ...rest }, forwardedRef) {
1714
+ const ctx = useCtx("Summary");
1715
+ if (!ctx.isBusiness) return null;
1716
+ const Comp = asChild ? Slot : "section";
1717
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Comp, { ref: forwardedRef, ...{ [attr(prefix, "summary")]: "" }, ...rest, children });
1718
+ });
1719
+ const Subtotal = (0, import_react9.forwardRef)(function TaxSummarySubtotal({ asChild, children, ...rest }, forwardedRef) {
1720
+ const ctx = useCtx("Summary.Subtotal");
1721
+ const { subtotalFormatted } = useSummaryAmounts(useCtx, "Summary.Subtotal");
1722
+ if (!ctx.isBusiness) return null;
1723
+ const Comp = asChild ? Slot : "span";
1724
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Comp, { ref: forwardedRef, ...{ [attr(prefix, "summary-subtotal")]: "" }, ...rest, children: children ?? subtotalFormatted });
1725
+ });
1726
+ const Tax = (0, import_react9.forwardRef)(function TaxSummaryTax({ asChild, children, ...rest }, forwardedRef) {
1727
+ const ctx = useCtx("Summary.Tax");
1728
+ const { taxFormatted, taxRate, treatment } = useSummaryAmounts(useCtx, "Summary.Tax");
1729
+ if (!ctx.isBusiness) return null;
1730
+ if (!shouldShowTaxRow(treatment)) return null;
1731
+ const Comp = asChild ? Slot : "span";
1732
+ const defaultLabel = formatVatSummaryLabel({
1733
+ treatment: treatment ?? "standard",
1734
+ taxRate
1735
+ });
1736
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Comp, { ref: forwardedRef, ...{ [attr(prefix, "summary-tax")]: "" }, ...rest, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1737
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: defaultLabel }),
1738
+ " ",
1739
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { ...{ [attr(prefix, "summary-tax-amount")]: "" }, children: taxFormatted })
1740
+ ] }) });
1741
+ });
1742
+ const Total = (0, import_react9.forwardRef)(function TaxSummaryTotal({ asChild, children, ...rest }, forwardedRef) {
1743
+ const ctx = useCtx("Summary.Total");
1744
+ const { totalFormatted } = useSummaryAmounts(useCtx, "Summary.Total");
1745
+ if (!ctx.isBusiness) return null;
1746
+ const Comp = asChild ? Slot : "span";
1747
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Comp, { ref: forwardedRef, ...{ [attr(prefix, "summary-total")]: "" }, ...rest, children: children ?? totalFormatted });
1748
+ });
1749
+ const TaxNote = (0, import_react9.forwardRef)(function TaxSummaryTaxNote({ asChild, children, ...rest }, forwardedRef) {
1750
+ const ctx = useCtx("Summary.TaxNote");
1751
+ const { treatment } = useSummaryAmounts(useCtx, "Summary.TaxNote");
1752
+ if (!ctx.isBusiness) return null;
1753
+ if (!treatment || treatment === "standard") return null;
1754
+ const Comp = asChild ? Slot : "p";
1755
+ const defaultNote = treatment === "reverse_charge" ? REVERSE_CHARGE_NOTE : treatment === "not_collecting" || treatment === "not_supported" ? TAX_NOT_COLLECTED_NOTE : null;
1756
+ if (!defaultNote && !children) return null;
1757
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Comp, { ref: forwardedRef, ...{ [attr(prefix, "summary-tax-note")]: "" }, ...rest, children: children ?? defaultNote });
1758
+ });
1759
+ const Rows = (0, import_react9.forwardRef)(function TaxSummaryRows({ asChild, children, ...rest }, forwardedRef) {
1760
+ const ctx = useCtx("Summary.Rows");
1761
+ const { taxRate, treatment, taxFormatted } = useSummaryAmounts(useCtx, "Summary.Rows");
1762
+ if (!ctx.isBusiness) return null;
1763
+ const showTaxRow = shouldShowTaxRow(treatment);
1764
+ const vatLabel = formatVatSummaryLabel({
1765
+ treatment: treatment ?? "standard",
1766
+ taxRate
1767
+ });
1768
+ const content = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("dl", { className: "solvapay-tax-summary-rows", children: [
1769
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "solvapay-tax-summary-row", children: [
1770
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("dt", { children: formatSubtotalLabel(treatment) }),
1771
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("dd", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Subtotal, {}) })
1772
+ ] }),
1773
+ showTaxRow ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "solvapay-tax-summary-row", children: [
1774
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("dt", { children: vatLabel }),
1775
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("dd", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { ...{ [attr(prefix, "summary-tax-amount")]: "" }, children: taxFormatted }) })
1776
+ ] }) : null,
1777
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "solvapay-tax-summary-row solvapay-tax-summary-row--total", children: [
1778
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("dt", { children: "Total" }),
1779
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("dd", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Total, {}) })
1780
+ ] }),
1781
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TaxNote, {}),
1782
+ children
1783
+ ] });
1784
+ if (asChild) {
1785
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Slot, { ref: forwardedRef, ...rest, children: content });
1786
+ }
1787
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("section", { ref: forwardedRef, ...{ [attr(prefix, "summary-rows")]: "" }, ...rest, children: content });
1788
+ });
1789
+ return {
1790
+ Root: Root14,
1791
+ Subtotal,
1792
+ Tax,
1793
+ Total,
1794
+ TaxNote,
1795
+ Rows
1796
+ };
1797
+ }
1798
+
1508
1799
  // src/utils/errors.ts
1509
1800
  var DOCS_BASE_URL = "https://solvapay.com/docs";
1510
1801
  var SolvaPayError = class extends Error {
@@ -1541,10 +1832,10 @@ var MissingProductRefError = class extends SolvaPayError {
1541
1832
  };
1542
1833
 
1543
1834
  // src/primitives/CheckoutSummary.tsx
1544
- var import_jsx_runtime5 = require("react/jsx-runtime");
1545
- var CheckoutSummaryContext = (0, import_react9.createContext)(null);
1835
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1836
+ var CheckoutSummaryContext = (0, import_react10.createContext)(null);
1546
1837
  function useCheckoutSummaryContext(part) {
1547
- const ctx = (0, import_react9.useContext)(CheckoutSummaryContext);
1838
+ const ctx = (0, import_react10.useContext)(CheckoutSummaryContext);
1548
1839
  if (!ctx) {
1549
1840
  throw new Error(
1550
1841
  `CheckoutSummary.${part} must be rendered inside <CheckoutSummary.Root>.`
@@ -1552,8 +1843,8 @@ function useCheckoutSummaryContext(part) {
1552
1843
  }
1553
1844
  return ctx;
1554
1845
  }
1555
- var Root = (0, import_react9.forwardRef)(function CheckoutSummaryRoot({ planRef, productRef, taxBreakdown = null, baseAmountMinor = 0, asChild, children, ...rest }, forwardedRef) {
1556
- const solva = (0, import_react9.useContext)(SolvaPayContext);
1846
+ var Root = (0, import_react10.forwardRef)(function CheckoutSummaryRoot({ planRef, productRef, taxBreakdown = null, baseAmountMinor = 0, asChild, children, ...rest }, forwardedRef) {
1847
+ const solva = (0, import_react10.useContext)(SolvaPayContext);
1557
1848
  if (!solva) throw new MissingProviderError("CheckoutSummary");
1558
1849
  const locale = useLocale();
1559
1850
  const copy = useCopy();
@@ -1566,7 +1857,7 @@ var Root = (0, import_react9.forwardRef)(function CheckoutSummaryRoot({ planRef,
1566
1857
  });
1567
1858
  const { product, loading: productLoading } = useProduct(resolvedProductRef);
1568
1859
  const loading = planLoading || productLoading;
1569
- const priceFormatted = (0, import_react9.useMemo)(() => {
1860
+ const priceFormatted = (0, import_react10.useMemo)(() => {
1570
1861
  const price = plan?.price ?? 0;
1571
1862
  const currency = plan?.currency ?? "usd";
1572
1863
  return formatPrice(price, currency, {
@@ -1576,7 +1867,7 @@ var Root = (0, import_react9.forwardRef)(function CheckoutSummaryRoot({ planRef,
1576
1867
  free: copy.interval.free
1577
1868
  });
1578
1869
  }, [plan, locale, copy.interval.free]);
1579
- const trialBanner = (0, import_react9.useMemo)(() => {
1870
+ const trialBanner = (0, import_react10.useMemo)(() => {
1580
1871
  const trialDays = plan?.trialDays;
1581
1872
  if (!trialDays || trialDays <= 0) return null;
1582
1873
  return interpolate(copy.interval.trial, { trialDays });
@@ -1585,10 +1876,10 @@ var Root = (0, import_react9.forwardRef)(function CheckoutSummaryRoot({ planRef,
1585
1876
  const subtotalMinor = taxBreakdown?.subtotal ?? baseAmountMinor;
1586
1877
  const taxMinor = taxBreakdown?.taxAmount ?? 0;
1587
1878
  const totalMinor = taxBreakdown?.total ?? baseAmountMinor;
1588
- const subtotalFormatted = formatPrice(subtotalMinor, taxCurrency, { locale });
1589
- const taxFormatted = formatPrice(taxMinor, taxCurrency, { locale });
1590
- const totalFormatted = formatPrice(totalMinor, taxCurrency, { locale });
1591
- const ctx = (0, import_react9.useMemo)(
1879
+ const subtotalFormatted = formatPrice(subtotalMinor, taxCurrency, { locale, free: "" });
1880
+ const taxFormatted = formatPrice(taxMinor, taxCurrency, { locale, free: "" });
1881
+ const totalFormatted = formatPrice(totalMinor, taxCurrency, { locale, free: "" });
1882
+ const ctx = (0, import_react10.useMemo)(
1592
1883
  () => ({
1593
1884
  plan,
1594
1885
  product,
@@ -1615,77 +1906,78 @@ var Root = (0, import_react9.forwardRef)(function CheckoutSummaryRoot({ planRef,
1615
1906
  ]
1616
1907
  );
1617
1908
  const Comp = asChild ? Slot : "section";
1618
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Comp, { ref: forwardedRef, "data-solvapay-checkout-summary": "", ...rest, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CheckoutSummaryContext.Provider, { value: ctx, children }) });
1909
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Comp, { ref: forwardedRef, "data-solvapay-checkout-summary": "", ...rest, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CheckoutSummaryContext.Provider, { value: ctx, children }) });
1619
1910
  });
1620
- var ProductSlot = (0, import_react9.forwardRef)(function CheckoutSummaryProduct({ asChild, children, ...rest }, forwardedRef) {
1911
+ var ProductSlot = (0, import_react10.forwardRef)(function CheckoutSummaryProduct({ asChild, children, ...rest }, forwardedRef) {
1621
1912
  const ctx = useCheckoutSummaryContext("Product");
1622
1913
  const name = ctx.product?.name;
1623
1914
  if (!name) return null;
1624
1915
  const Comp = asChild ? Slot : "span";
1625
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Comp, { ref: forwardedRef, "data-solvapay-checkout-summary-product": "", ...rest, children: children ?? name });
1916
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Comp, { ref: forwardedRef, "data-solvapay-checkout-summary-product": "", ...rest, children: children ?? name });
1626
1917
  });
1627
- var PlanSlot = (0, import_react9.forwardRef)(function CheckoutSummaryPlan({ asChild, children, ...rest }, forwardedRef) {
1918
+ var PlanSlot = (0, import_react10.forwardRef)(function CheckoutSummaryPlan({ asChild, children, ...rest }, forwardedRef) {
1628
1919
  const ctx = useCheckoutSummaryContext("Plan");
1629
1920
  const name = ctx.plan?.name;
1630
1921
  if (!name) return null;
1631
1922
  const Comp = asChild ? Slot : "span";
1632
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Comp, { ref: forwardedRef, "data-solvapay-checkout-summary-plan": "", ...rest, children: children ?? name });
1923
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Comp, { ref: forwardedRef, "data-solvapay-checkout-summary-plan": "", ...rest, children: children ?? name });
1633
1924
  });
1634
- var TaxNoteSlot = (0, import_react9.forwardRef)(
1925
+ var TaxNoteSlot = (0, import_react10.forwardRef)(
1635
1926
  function CheckoutSummaryTaxNote({ asChild, children, ...rest }, forwardedRef) {
1636
1927
  const ctx = useCheckoutSummaryContext("TaxNote");
1637
1928
  if (ctx.taxBreakdown) return null;
1638
1929
  const Comp = asChild ? Slot : "p";
1639
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Comp, { ref: forwardedRef, "data-solvapay-checkout-summary-tax-note": "", ...rest, children: children ?? "Taxes calculated at checkout" });
1930
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Comp, { ref: forwardedRef, "data-solvapay-checkout-summary-tax-note": "", ...rest, children: children ?? "Taxes calculated at checkout" });
1640
1931
  }
1641
1932
  );
1642
- var SubtotalSlot = (0, import_react9.forwardRef)(function CheckoutSummarySubtotal({ asChild, children, ...rest }, forwardedRef) {
1933
+ var SubtotalSlot = (0, import_react10.forwardRef)(function CheckoutSummarySubtotal({ asChild, children, ...rest }, forwardedRef) {
1643
1934
  const ctx = useCheckoutSummaryContext("Subtotal");
1644
1935
  if (!ctx.taxBreakdown) return null;
1645
1936
  const Comp = asChild ? Slot : "span";
1646
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Comp, { ref: forwardedRef, "data-solvapay-checkout-summary-subtotal": "", ...rest, children: children ?? ctx.subtotalFormatted });
1937
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Comp, { ref: forwardedRef, "data-solvapay-checkout-summary-subtotal": "", ...rest, children: children ?? ctx.subtotalFormatted });
1647
1938
  });
1648
- var TaxSlot = (0, import_react9.forwardRef)(function CheckoutSummaryTax({ asChild, children, ...rest }, forwardedRef) {
1939
+ var TaxSlot = (0, import_react10.forwardRef)(function CheckoutSummaryTax({ asChild, children, ...rest }, forwardedRef) {
1649
1940
  const ctx = useCheckoutSummaryContext("Tax");
1650
1941
  if (!ctx.taxBreakdown) return null;
1651
- const Comp = asChild ? Slot : "span";
1652
1942
  const { taxRate, treatment } = ctx.taxBreakdown;
1653
- const defaultLabel = treatment === "reverse_charge" ? `VAT reverse charge (${ctx.taxFormatted})` : taxRate != null ? `Tax (${Math.round(taxRate * 100)}%)` : "Tax";
1654
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Comp, { ref: forwardedRef, "data-solvapay-checkout-summary-tax": "", ...rest, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1655
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: defaultLabel }),
1943
+ if (!shouldShowTaxRow(treatment)) return null;
1944
+ const Comp = asChild ? Slot : "span";
1945
+ const defaultLabel = formatVatSummaryLabel({ treatment, taxRate: taxRate ?? 0 });
1946
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Comp, { ref: forwardedRef, "data-solvapay-checkout-summary-tax": "", ...rest, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
1947
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: defaultLabel }),
1656
1948
  " ",
1657
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { "data-solvapay-checkout-summary-tax-amount": "", children: ctx.taxFormatted })
1949
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { "data-solvapay-checkout-summary-tax-amount": "", children: ctx.taxFormatted })
1658
1950
  ] }) });
1659
1951
  });
1660
- var TotalSlot = (0, import_react9.forwardRef)(function CheckoutSummaryTotal({ asChild, children, ...rest }, forwardedRef) {
1952
+ var TotalSlot = (0, import_react10.forwardRef)(function CheckoutSummaryTotal({ asChild, children, ...rest }, forwardedRef) {
1661
1953
  const ctx = useCheckoutSummaryContext("Total");
1662
1954
  if (!ctx.taxBreakdown) return null;
1663
1955
  const Comp = asChild ? Slot : "span";
1664
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Comp, { ref: forwardedRef, "data-solvapay-checkout-summary-total": "", ...rest, children: children ?? ctx.totalFormatted });
1956
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Comp, { ref: forwardedRef, "data-solvapay-checkout-summary-total": "", ...rest, children: children ?? ctx.totalFormatted });
1665
1957
  });
1666
- var TaxTreatmentNoteSlot = (0, import_react9.forwardRef)(
1958
+ var TaxTreatmentNoteSlot = (0, import_react10.forwardRef)(
1667
1959
  function CheckoutSummaryTaxTreatmentNote({ asChild, children, ...rest }, forwardedRef) {
1668
1960
  const ctx = useCheckoutSummaryContext("TaxTreatmentNote");
1669
1961
  const treatment = ctx.taxBreakdown?.treatment;
1670
1962
  if (!treatment || treatment === "standard") return null;
1671
1963
  const Comp = asChild ? Slot : "p";
1672
- const defaultNote = treatment === "reverse_charge" ? "VAT reverse charge applies \u2014 you are responsible for reporting VAT in your jurisdiction." : treatment === "not_collecting" ? "Tax is not collected on this purchase." : null;
1964
+ const defaultNote = treatment === "reverse_charge" ? REVERSE_CHARGE_NOTE : treatment === "not_collecting" || treatment === "not_supported" ? TAX_NOT_COLLECTED_NOTE : null;
1673
1965
  if (!defaultNote && !children) return null;
1674
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Comp, { ref: forwardedRef, "data-solvapay-checkout-summary-tax-treatment-note": "", ...rest, children: children ?? defaultNote });
1966
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Comp, { ref: forwardedRef, "data-solvapay-checkout-summary-tax-treatment-note": "", ...rest, children: children ?? defaultNote });
1675
1967
  }
1676
1968
  );
1677
- var PriceSlot = (0, import_react9.forwardRef)(function CheckoutSummaryPrice({ asChild, children, ...rest }, forwardedRef) {
1969
+ var PriceSlot = (0, import_react10.forwardRef)(function CheckoutSummaryPrice({ asChild, children, ...rest }, forwardedRef) {
1678
1970
  const ctx = useCheckoutSummaryContext("Price");
1679
1971
  if (ctx.taxBreakdown) return null;
1680
1972
  const Comp = asChild ? Slot : "span";
1681
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Comp, { ref: forwardedRef, "data-solvapay-checkout-summary-price": "", ...rest, children: children ?? ctx.priceFormatted });
1973
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Comp, { ref: forwardedRef, "data-solvapay-checkout-summary-price": "", ...rest, children: children ?? ctx.priceFormatted });
1682
1974
  });
1683
- var TrialSlot = (0, import_react9.forwardRef)(
1975
+ var TrialSlot = (0, import_react10.forwardRef)(
1684
1976
  function CheckoutSummaryTrial({ asChild, children, ...rest }, forwardedRef) {
1685
1977
  const ctx = useCheckoutSummaryContext("Trial");
1686
1978
  if (!ctx.trialBanner || ctx.taxBreakdown) return null;
1687
1979
  const Comp = asChild ? Slot : "p";
1688
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Comp, { ref: forwardedRef, "data-solvapay-checkout-summary-trial": "", ...rest, children: children ?? ctx.trialBanner });
1980
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Comp, { ref: forwardedRef, "data-solvapay-checkout-summary-trial": "", ...rest, children: children ?? ctx.trialBanner });
1689
1981
  }
1690
1982
  );
1691
1983
  var CheckoutSummaryRoot2 = Root;
@@ -1715,7 +2007,7 @@ function useCheckoutSummary() {
1715
2007
  }
1716
2008
 
1717
2009
  // src/primitives/PlanSelector.tsx
1718
- var import_react10 = require("react");
2010
+ var import_react11 = require("react");
1719
2011
 
1720
2012
  // src/hooks/usePurchase.ts
1721
2013
  function usePurchase() {
@@ -1732,13 +2024,13 @@ function isPaygPlan(plan) {
1732
2024
  }
1733
2025
 
1734
2026
  // src/utils/planPricing.ts
1735
- var import_core = require("@solvapay/core");
2027
+ var import_core2 = require("@solvapay/core");
1736
2028
  function getPlanPricingOptions(plan) {
1737
2029
  if (plan.pricingOptions && plan.pricingOptions.length > 0) {
1738
2030
  return plan.pricingOptions;
1739
2031
  }
1740
2032
  const defaultCurrency = (plan.currency ?? "USD").toUpperCase();
1741
- const charges = (0, import_core.headlineCharges)(plan);
2033
+ const charges = (0, import_core2.headlineCharges)(plan);
1742
2034
  if (charges.length > 0) {
1743
2035
  return charges.map((charge) => ({
1744
2036
  currency: charge.currency,
@@ -1764,24 +2056,24 @@ function resolvePlanPricingOption(plan, currency) {
1764
2056
  }
1765
2057
 
1766
2058
  // src/primitives/PlanSelector.tsx
1767
- var import_jsx_runtime6 = require("react/jsx-runtime");
1768
- var PlanSelectorContext = (0, import_react10.createContext)(null);
2059
+ var import_jsx_runtime7 = require("react/jsx-runtime");
2060
+ var PlanSelectorContext = (0, import_react11.createContext)(null);
1769
2061
  function usePlanSelectorContext(part) {
1770
- const ctx = (0, import_react10.useContext)(PlanSelectorContext);
2062
+ const ctx = (0, import_react11.useContext)(PlanSelectorContext);
1771
2063
  if (!ctx) {
1772
2064
  throw new Error(`PlanSelector.${part} must be rendered inside <PlanSelector.Root>.`);
1773
2065
  }
1774
2066
  return ctx;
1775
2067
  }
1776
- var CardContext = (0, import_react10.createContext)(null);
2068
+ var CardContext = (0, import_react11.createContext)(null);
1777
2069
  function useCardContext(part) {
1778
- const ctx = (0, import_react10.useContext)(CardContext);
2070
+ const ctx = (0, import_react11.useContext)(CardContext);
1779
2071
  if (!ctx) {
1780
2072
  throw new Error(`PlanSelector.${part} must be rendered inside <PlanSelector.Card>.`);
1781
2073
  }
1782
2074
  return ctx;
1783
2075
  }
1784
- var Root2 = (0, import_react10.forwardRef)(function PlanSelectorRoot(props, forwardedRef) {
2076
+ var Root2 = (0, import_react11.forwardRef)(function PlanSelectorRoot(props, forwardedRef) {
1785
2077
  const {
1786
2078
  productRef,
1787
2079
  fetcher,
@@ -1795,12 +2087,12 @@ var Root2 = (0, import_react10.forwardRef)(function PlanSelectorRoot(props, forw
1795
2087
  children,
1796
2088
  ...rest
1797
2089
  } = props;
1798
- const solva = (0, import_react10.useContext)(SolvaPayContext);
2090
+ const solva = (0, import_react11.useContext)(SolvaPayContext);
1799
2091
  if (!solva) throw new MissingProviderError("PlanSelector");
1800
2092
  if (!productRef) throw new MissingProductRefError("PlanSelector");
1801
2093
  const { _config } = solva;
1802
2094
  const { purchases } = usePurchase();
1803
- const effectiveFetcher = (0, import_react10.useMemo)(
2095
+ const effectiveFetcher = (0, import_react11.useMemo)(
1804
2096
  () => fetcher ?? ((ref) => defaultListPlans(ref, _config)),
1805
2097
  [fetcher, _config]
1806
2098
  );
@@ -1812,24 +2104,24 @@ var Root2 = (0, import_react10.forwardRef)(function PlanSelectorRoot(props, forw
1812
2104
  autoSelectFirstPaid,
1813
2105
  initialPlanRef
1814
2106
  });
1815
- const autoCurrentPlanRef = (0, import_react10.useMemo)(() => {
2107
+ const autoCurrentPlanRef = (0, import_react11.useMemo)(() => {
1816
2108
  const active = purchases.filter((p) => p.status === "active").sort((a, b) => new Date(b.startDate).getTime() - new Date(a.startDate).getTime())[0];
1817
2109
  return active?.planSnapshot?.reference ?? null;
1818
2110
  }, [purchases]);
1819
2111
  const resolvedCurrentPlanRef = currentPlanRef === null ? null : currentPlanRef ?? autoCurrentPlanRef;
1820
- const isCurrent = (0, import_react10.useCallback)(
2112
+ const isCurrent = (0, import_react11.useCallback)(
1821
2113
  (ref) => resolvedCurrentPlanRef === ref,
1822
2114
  [resolvedCurrentPlanRef]
1823
2115
  );
1824
- const isFree = (0, import_react10.useCallback)(
2116
+ const isFree = (0, import_react11.useCallback)(
1825
2117
  (ref) => plans.find((p) => p.reference === ref)?.requiresPayment === false,
1826
2118
  [plans]
1827
2119
  );
1828
- const isPopular = (0, import_react10.useCallback)(
2120
+ const isPopular = (0, import_react11.useCallback)(
1829
2121
  (ref) => popularPlanRef === ref,
1830
2122
  [popularPlanRef]
1831
2123
  );
1832
- const select = (0, import_react10.useCallback)(
2124
+ const select = (0, import_react11.useCallback)(
1833
2125
  (ref) => {
1834
2126
  const plan = plans.find((p) => p.reference === ref);
1835
2127
  if (!plan) return;
@@ -1839,29 +2131,29 @@ var Root2 = (0, import_react10.forwardRef)(function PlanSelectorRoot(props, forw
1839
2131
  },
1840
2132
  [plans, selectPlan, onSelect]
1841
2133
  );
1842
- const clearSelection = (0, import_react10.useCallback)(() => {
2134
+ const clearSelection = (0, import_react11.useCallback)(() => {
1843
2135
  setSelectedPlanIndex(-1);
1844
2136
  }, [setSelectedPlanIndex]);
1845
2137
  const selectedPlanRef = selectedPlan?.reference ?? null;
1846
- const [preferredCurrency, setPreferredCurrencyState] = (0, import_react10.useState)(null);
1847
- const [selectedCurrencies, setSelectedCurrencies] = (0, import_react10.useState)({});
1848
- const getSelectedOption = (0, import_react10.useCallback)(
2138
+ const [preferredCurrency, setPreferredCurrencyState] = (0, import_react11.useState)(null);
2139
+ const [selectedCurrencies, setSelectedCurrencies] = (0, import_react11.useState)({});
2140
+ const getSelectedOption = (0, import_react11.useCallback)(
1849
2141
  (plan) => resolvePlanPricingOption(
1850
2142
  plan,
1851
2143
  selectedCurrencies[plan.reference] ?? preferredCurrency ?? null
1852
2144
  ),
1853
2145
  [selectedCurrencies, preferredCurrency]
1854
2146
  );
1855
- const setPreferredCurrency = (0, import_react10.useCallback)((currency) => {
2147
+ const setPreferredCurrency = (0, import_react11.useCallback)((currency) => {
1856
2148
  setPreferredCurrencyState(currency.toUpperCase());
1857
2149
  setSelectedCurrencies({});
1858
2150
  }, []);
1859
- const setPlanCurrency = (0, import_react10.useCallback)((planRef, currency) => {
2151
+ const setPlanCurrency = (0, import_react11.useCallback)((planRef, currency) => {
1860
2152
  setSelectedCurrencies((current) => ({ ...current, [planRef]: currency }));
1861
2153
  }, []);
1862
2154
  const selectedCurrency = selectedPlan ? getSelectedOption(selectedPlan).currency : null;
1863
- const autoCurrentAppliedKeyRef = (0, import_react10.useRef)(null);
1864
- (0, import_react10.useEffect)(() => {
2155
+ const autoCurrentAppliedKeyRef = (0, import_react11.useRef)(null);
2156
+ (0, import_react11.useEffect)(() => {
1865
2157
  if (autoCurrentAppliedKeyRef.current === productRef) return;
1866
2158
  if (selectedPlanRef) {
1867
2159
  autoCurrentAppliedKeyRef.current = productRef;
@@ -1876,7 +2168,7 @@ var Root2 = (0, import_react10.forwardRef)(function PlanSelectorRoot(props, forw
1876
2168
  autoCurrentAppliedKeyRef.current = productRef;
1877
2169
  select(resolvedCurrentPlanRef);
1878
2170
  }, [productRef, plans, resolvedCurrentPlanRef, selectedPlanRef, select]);
1879
- const ctx = (0, import_react10.useMemo)(
2171
+ const ctx = (0, import_react11.useMemo)(
1880
2172
  () => ({
1881
2173
  plans,
1882
2174
  loading,
@@ -1916,7 +2208,7 @@ var Root2 = (0, import_react10.forwardRef)(function PlanSelectorRoot(props, forw
1916
2208
  getSelectedOption
1917
2209
  ]
1918
2210
  );
1919
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2211
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1920
2212
  PlanSelectionProvider,
1921
2213
  {
1922
2214
  value: {
@@ -1935,19 +2227,19 @@ var Root2 = (0, import_react10.forwardRef)(function PlanSelectorRoot(props, forw
1935
2227
  loading,
1936
2228
  error
1937
2229
  },
1938
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ref: forwardedRef, "data-solvapay-plan-selector": "", ...rest, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PlanSelectorContext.Provider, { value: ctx, children }) })
2230
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { ref: forwardedRef, "data-solvapay-plan-selector": "", ...rest, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(PlanSelectorContext.Provider, { value: ctx, children }) })
1939
2231
  }
1940
2232
  );
1941
2233
  });
1942
- var Heading = (0, import_react10.forwardRef)(function PlanSelectorHeading({ asChild, children, ...rest }, forwardedRef) {
2234
+ var Heading = (0, import_react11.forwardRef)(function PlanSelectorHeading({ asChild, children, ...rest }, forwardedRef) {
1943
2235
  usePlanSelectorContext("Heading");
1944
2236
  const copy = useCopy();
1945
2237
  const Comp = asChild ? Slot : "h3";
1946
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Comp, { ref: forwardedRef, "data-solvapay-plan-selector-heading": "", ...rest, children: children ?? copy.planSelector.heading });
2238
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Comp, { ref: forwardedRef, "data-solvapay-plan-selector-heading": "", ...rest, children: children ?? copy.planSelector.heading });
1947
2239
  });
1948
- var Grid = (0, import_react10.forwardRef)(function PlanSelectorGrid({ children, ...rest }, forwardedRef) {
2240
+ var Grid = (0, import_react11.forwardRef)(function PlanSelectorGrid({ children, ...rest }, forwardedRef) {
1949
2241
  const ctx = usePlanSelectorContext("Grid");
1950
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ref: forwardedRef, "data-solvapay-plan-selector-grid": "", ...rest, children: ctx.plans.map((plan) => {
2242
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { ref: forwardedRef, "data-solvapay-plan-selector-grid": "", ...rest, children: ctx.plans.map((plan) => {
1951
2243
  const isCurrent = ctx.isCurrent(plan.reference);
1952
2244
  const isFree = ctx.isFree(plan.reference);
1953
2245
  const isPopular = ctx.isPopular(plan.reference);
@@ -1969,10 +2261,10 @@ var Grid = (0, import_react10.forwardRef)(function PlanSelectorGrid({ children,
1969
2261
  select: () => ctx.select(plan.reference),
1970
2262
  setCurrency: (currency) => ctx.setPlanCurrency(plan.reference, currency)
1971
2263
  };
1972
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CardContext.Provider, { value: cardCtx, children }, plan.reference);
2264
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CardContext.Provider, { value: cardCtx, children }, plan.reference);
1973
2265
  }) });
1974
2266
  });
1975
- var Card = (0, import_react10.forwardRef)(function PlanSelectorCard({ asChild, onClick, children, ...rest }, forwardedRef) {
2267
+ var Card = (0, import_react11.forwardRef)(function PlanSelectorCard({ asChild, onClick, children, ...rest }, forwardedRef) {
1976
2268
  const card = useCardContext("Card");
1977
2269
  const dataTrial = !!(card.plan.trialDays && card.plan.trialDays > 0);
1978
2270
  const commonProps = {
@@ -1990,10 +2282,10 @@ var Card = (0, import_react10.forwardRef)(function PlanSelectorCard({ asChild, o
1990
2282
  if (asChild) {
1991
2283
  return (
1992
2284
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1993
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Slot, { ref: forwardedRef, ...commonProps, children })
2285
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Slot, { ref: forwardedRef, ...commonProps, children })
1994
2286
  );
1995
2287
  }
1996
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2288
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1997
2289
  "button",
1998
2290
  {
1999
2291
  ref: forwardedRef,
@@ -2004,19 +2296,19 @@ var Card = (0, import_react10.forwardRef)(function PlanSelectorCard({ asChild, o
2004
2296
  }
2005
2297
  );
2006
2298
  });
2007
- var CardName = (0, import_react10.forwardRef)(function PlanSelectorCardName({ asChild, children, ...rest }, forwardedRef) {
2299
+ var CardName = (0, import_react11.forwardRef)(function PlanSelectorCardName({ asChild, children, ...rest }, forwardedRef) {
2008
2300
  const card = useCardContext("CardName");
2009
2301
  const fallback = card.plan.requiresPayment === false ? "Free" : card.plan.type === "usage-based" ? "Pay as you go" : card.plan.type === "recurring" ? "Plan" : null;
2010
2302
  const label = card.plan.name ?? fallback;
2011
2303
  if (!label && children == null) return null;
2012
2304
  const Comp = asChild ? Slot : "span";
2013
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Comp, { ref: forwardedRef, "data-solvapay-plan-selector-card-name": "", ...rest, children: children ?? label });
2305
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Comp, { ref: forwardedRef, "data-solvapay-plan-selector-card-name": "", ...rest, children: children ?? label });
2014
2306
  });
2015
- var CardPrice = (0, import_react10.forwardRef)(function PlanSelectorCardPrice({ asChild, children, ...rest }, forwardedRef) {
2307
+ var CardPrice = (0, import_react11.forwardRef)(function PlanSelectorCardPrice({ asChild, children, ...rest }, forwardedRef) {
2016
2308
  const card = useCardContext("CardPrice");
2017
2309
  const locale = useLocale();
2018
2310
  const copy = useCopy();
2019
- const formatted = (0, import_react10.useMemo)(() => {
2311
+ const formatted = (0, import_react11.useMemo)(() => {
2020
2312
  if (card.isFree) return copy.planSelector.freeBadge;
2021
2313
  if (card.plan.type === "usage-based") {
2022
2314
  return copy.planSelector.usageRateLabel;
@@ -2036,9 +2328,9 @@ var CardPrice = (0, import_react10.forwardRef)(function PlanSelectorCardPrice({
2036
2328
  copy.interval.free
2037
2329
  ]);
2038
2330
  const Comp = asChild ? Slot : "span";
2039
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Comp, { ref: forwardedRef, "data-solvapay-plan-selector-card-price": "", ...rest, children: children ?? formatted });
2331
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Comp, { ref: forwardedRef, "data-solvapay-plan-selector-card-price": "", ...rest, children: children ?? formatted });
2040
2332
  });
2041
- var CardInterval = (0, import_react10.forwardRef)(function PlanSelectorCardInterval({ asChild, children, ...rest }, forwardedRef) {
2333
+ var CardInterval = (0, import_react11.forwardRef)(function PlanSelectorCardInterval({ asChild, children, ...rest }, forwardedRef) {
2042
2334
  const card = useCardContext("CardInterval");
2043
2335
  const copy = useCopy();
2044
2336
  if (card.isFree || card.plan.type === "usage-based") return null;
@@ -2046,7 +2338,7 @@ var CardInterval = (0, import_react10.forwardRef)(function PlanSelectorCardInter
2046
2338
  if (!rawInterval) return null;
2047
2339
  const text = interpolate(copy.planSelector.perIntervalShort, { interval: rawInterval });
2048
2340
  const Comp = asChild ? Slot : "span";
2049
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Comp, { ref: forwardedRef, "data-solvapay-plan-selector-card-interval": "", ...rest, children: children ?? text });
2341
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Comp, { ref: forwardedRef, "data-solvapay-plan-selector-card-interval": "", ...rest, children: children ?? text });
2050
2342
  });
2051
2343
  function normalizeBillingCycle(cycle) {
2052
2344
  if (!cycle) return null;
@@ -2057,9 +2349,9 @@ function normalizeBillingCycle(cycle) {
2057
2349
  if (lc === "daily" || lc === "day") return "day";
2058
2350
  return cycle;
2059
2351
  }
2060
- var CurrencySwitcher = (0, import_react10.forwardRef)(function PlanSelectorCurrencySwitcher({ children, onChange, className, ...rest }, forwardedRef) {
2352
+ var CurrencySwitcher = (0, import_react11.forwardRef)(function PlanSelectorCurrencySwitcher({ children, onChange, className, ...rest }, forwardedRef) {
2061
2353
  const ctx = usePlanSelectorContext("CurrencySwitcher");
2062
- const availableCurrencies = (0, import_react10.useMemo)(() => {
2354
+ const availableCurrencies = (0, import_react11.useMemo)(() => {
2063
2355
  const currencies = /* @__PURE__ */ new Set();
2064
2356
  for (const plan of ctx.plans) {
2065
2357
  const options = getPlanPricingOptions(plan);
@@ -2072,7 +2364,7 @@ var CurrencySwitcher = (0, import_react10.forwardRef)(function PlanSelectorCurre
2072
2364
  }, [ctx.plans]);
2073
2365
  if (availableCurrencies.length < 2) return null;
2074
2366
  const effectiveCurrency = ctx.preferredCurrency ?? (ctx.selectedPlan ? ctx.getSelectedOption(ctx.selectedPlan).currency.toUpperCase() : null) ?? availableCurrencies[0];
2075
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2367
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2076
2368
  "select",
2077
2369
  {
2078
2370
  ref: forwardedRef,
@@ -2084,15 +2376,15 @@ var CurrencySwitcher = (0, import_react10.forwardRef)(function PlanSelectorCurre
2084
2376
  onChange?.(event);
2085
2377
  },
2086
2378
  ...rest,
2087
- children: children ?? availableCurrencies.map((currency) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: currency, children: currency }, currency))
2379
+ children: children ?? availableCurrencies.map((currency) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: currency, children: currency }, currency))
2088
2380
  }
2089
2381
  );
2090
2382
  });
2091
- var CardCurrency = (0, import_react10.forwardRef)(
2383
+ var CardCurrency = (0, import_react11.forwardRef)(
2092
2384
  function PlanSelectorCardCurrency({ children, onChange, ...rest }, forwardedRef) {
2093
2385
  const card = useCardContext("CardCurrency");
2094
2386
  if (card.pricingOptions.length <= 1) return null;
2095
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2387
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2096
2388
  "select",
2097
2389
  {
2098
2390
  ref: forwardedRef,
@@ -2103,12 +2395,12 @@ var CardCurrency = (0, import_react10.forwardRef)(
2103
2395
  onChange?.(event);
2104
2396
  },
2105
2397
  ...rest,
2106
- children: children ?? card.pricingOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: option.currency, children: option.currency }, option.currency))
2398
+ children: children ?? card.pricingOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: option.currency, children: option.currency }, option.currency))
2107
2399
  }
2108
2400
  );
2109
2401
  }
2110
2402
  );
2111
- var CardBadge = (0, import_react10.forwardRef)(function PlanSelectorCardBadge({ asChild, children, ...rest }, forwardedRef) {
2403
+ var CardBadge = (0, import_react11.forwardRef)(function PlanSelectorCardBadge({ asChild, children, ...rest }, forwardedRef) {
2112
2404
  const card = useCardContext("CardBadge");
2113
2405
  const copy = useCopy();
2114
2406
  let variant = null;
@@ -2122,7 +2414,7 @@ var CardBadge = (0, import_react10.forwardRef)(function PlanSelectorCardBadge({
2122
2414
  }
2123
2415
  if (!variant) return null;
2124
2416
  const Comp = asChild ? Slot : "span";
2125
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2417
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2126
2418
  Comp,
2127
2419
  {
2128
2420
  ref: forwardedRef,
@@ -2133,17 +2425,17 @@ var CardBadge = (0, import_react10.forwardRef)(function PlanSelectorCardBadge({
2133
2425
  }
2134
2426
  );
2135
2427
  });
2136
- var Loading = (0, import_react10.forwardRef)(function PlanSelectorLoading({ asChild, children, ...rest }, forwardedRef) {
2428
+ var Loading = (0, import_react11.forwardRef)(function PlanSelectorLoading({ asChild, children, ...rest }, forwardedRef) {
2137
2429
  const ctx = usePlanSelectorContext("Loading");
2138
2430
  if (!ctx.loading || ctx.plans.length > 0) return null;
2139
2431
  const Comp = asChild ? Slot : "div";
2140
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Comp, { ref: forwardedRef, "data-solvapay-plan-selector-loading": "", ...rest, children });
2432
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Comp, { ref: forwardedRef, "data-solvapay-plan-selector-loading": "", ...rest, children });
2141
2433
  });
2142
- var ErrorSlot = (0, import_react10.forwardRef)(function PlanSelectorError({ asChild, children, ...rest }, forwardedRef) {
2434
+ var ErrorSlot = (0, import_react11.forwardRef)(function PlanSelectorError({ asChild, children, ...rest }, forwardedRef) {
2143
2435
  const ctx = usePlanSelectorContext("Error");
2144
2436
  if (!ctx.error) return null;
2145
2437
  const Comp = asChild ? Slot : "div";
2146
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Comp, { ref: forwardedRef, "data-solvapay-plan-selector-error": "", role: "alert", ...rest, children: children ?? ctx.error.message });
2438
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Comp, { ref: forwardedRef, "data-solvapay-plan-selector-error": "", role: "alert", ...rest, children: children ?? ctx.error.message });
2147
2439
  });
2148
2440
  var PlanSelectorRoot2 = Root2;
2149
2441
  var PlanSelectorHeading2 = Heading;
@@ -2241,7 +2533,7 @@ function toStripeElementLocale(locale) {
2241
2533
  }
2242
2534
 
2243
2535
  // src/primitives/LegalFooter.tsx
2244
- var import_react11 = require("react");
2536
+ var import_react12 = require("react");
2245
2537
 
2246
2538
  // src/constants/legal.ts
2247
2539
  var SOLVAPAY_TERMS_URL = "https://solvapay.com/legal/terms";
@@ -2249,8 +2541,8 @@ var SOLVAPAY_PRIVACY_URL = "https://solvapay.com/legal/privacy";
2249
2541
  var SOLVAPAY_WEBSITE_URL = "https://solvapay.com";
2250
2542
 
2251
2543
  // src/primitives/LegalFooter.tsx
2252
- var import_jsx_runtime7 = require("react/jsx-runtime");
2253
- var LegalFooter = (0, import_react11.forwardRef)(
2544
+ var import_jsx_runtime8 = require("react/jsx-runtime");
2545
+ var LegalFooter = (0, import_react12.forwardRef)(
2254
2546
  function LegalFooter2({
2255
2547
  attribution = "provided",
2256
2548
  termsUrl = SOLVAPAY_TERMS_URL,
@@ -2262,9 +2554,9 @@ var LegalFooter = (0, import_react11.forwardRef)(
2262
2554
  const copy = useCopy();
2263
2555
  const attributionLabel = attribution === "provided" ? copy.legalFooter.providedBy : attribution === "powered" ? copy.legalFooter.poweredBy : null;
2264
2556
  const Comp = asChild ? Slot : "div";
2265
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Comp, { ref: forwardedRef, "data-solvapay-legal-footer": "", ...rest, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
2266
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { "data-solvapay-legal-footer-links": "", children: [
2267
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2557
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Comp, { ref: forwardedRef, "data-solvapay-legal-footer": "", ...rest, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
2558
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { "data-solvapay-legal-footer-links": "", children: [
2559
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2268
2560
  "a",
2269
2561
  {
2270
2562
  "data-solvapay-legal-footer-link": "",
@@ -2274,8 +2566,8 @@ var LegalFooter = (0, import_react11.forwardRef)(
2274
2566
  children: copy.legalFooter.terms
2275
2567
  }
2276
2568
  ),
2277
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { "aria-hidden": "true", children: " \xB7 " }),
2278
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2569
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { "aria-hidden": "true", children: " \xB7 " }),
2570
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2279
2571
  "a",
2280
2572
  {
2281
2573
  "data-solvapay-legal-footer-link": "",
@@ -2286,7 +2578,7 @@ var LegalFooter = (0, import_react11.forwardRef)(
2286
2578
  }
2287
2579
  )
2288
2580
  ] }),
2289
- attributionLabel ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2581
+ attributionLabel ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2290
2582
  "a",
2291
2583
  {
2292
2584
  "data-solvapay-legal-footer-attribution": "",
@@ -2315,7 +2607,7 @@ function withPaymentElementDefaults(options) {
2315
2607
  }
2316
2608
 
2317
2609
  // src/hooks/useCheckout.ts
2318
- var import_react12 = require("react");
2610
+ var import_react13 = require("react");
2319
2611
  var import_stripe_js = require("@stripe/stripe-js");
2320
2612
  var stripePromiseCache = /* @__PURE__ */ new Map();
2321
2613
  function getStripeCacheKey(publishableKey, accountId) {
@@ -2357,14 +2649,14 @@ function useCheckout(options) {
2357
2649
  const { planRef, productRef, currency: currencyOverride, customer } = options;
2358
2650
  const planSelection = usePlanSelection();
2359
2651
  const { createPayment, customerRef, updateCustomerRef, _config } = useSolvaPay();
2360
- const [loading, setLoading] = (0, import_react12.useState)(false);
2361
- const [error, setError] = (0, import_react12.useState)(null);
2362
- const [stripePromise, setStripePromise] = (0, import_react12.useState)(null);
2363
- const [clientSecret, setClientSecret] = (0, import_react12.useState)(null);
2364
- const [processorPaymentId, setProcessorPaymentId] = (0, import_react12.useState)(null);
2365
- const [resolvedPlanRef, setResolvedPlanRef] = (0, import_react12.useState)(planRef || null);
2366
- const isStartingRef = (0, import_react12.useRef)(false);
2367
- const startCheckout = (0, import_react12.useCallback)(async () => {
2652
+ const [loading, setLoading] = (0, import_react13.useState)(false);
2653
+ const [error, setError] = (0, import_react13.useState)(null);
2654
+ const [stripePromise, setStripePromise] = (0, import_react13.useState)(null);
2655
+ const [clientSecret, setClientSecret] = (0, import_react13.useState)(null);
2656
+ const [processorPaymentId, setProcessorPaymentId] = (0, import_react13.useState)(null);
2657
+ const [resolvedPlanRef, setResolvedPlanRef] = (0, import_react13.useState)(planRef || null);
2658
+ const isStartingRef = (0, import_react13.useRef)(false);
2659
+ const startCheckout = (0, import_react13.useCallback)(async () => {
2368
2660
  if (isStartingRef.current || loading) {
2369
2661
  return;
2370
2662
  }
@@ -2440,7 +2732,7 @@ function useCheckout(options) {
2440
2732
  loading,
2441
2733
  _config
2442
2734
  ]);
2443
- const reset = (0, import_react12.useCallback)(() => {
2735
+ const reset = (0, import_react13.useCallback)(() => {
2444
2736
  isStartingRef.current = false;
2445
2737
  setLoading(false);
2446
2738
  setError(null);
@@ -2473,14 +2765,14 @@ function useCustomer() {
2473
2765
  }
2474
2766
 
2475
2767
  // src/hooks/useActivation.ts
2476
- var import_react13 = require("react");
2768
+ var import_react14 = require("react");
2477
2769
  function useActivation() {
2478
2770
  const { activatePlan } = useSolvaPay();
2479
2771
  const copy = useCopy();
2480
- const [state, setState] = (0, import_react13.useState)("idle");
2481
- const [error, setError] = (0, import_react13.useState)(null);
2482
- const [result, setResult] = (0, import_react13.useState)(null);
2483
- const activate = (0, import_react13.useCallback)(
2772
+ const [state, setState] = (0, import_react14.useState)("idle");
2773
+ const [error, setError] = (0, import_react14.useState)(null);
2774
+ const [result, setResult] = (0, import_react14.useState)(null);
2775
+ const activate = (0, import_react14.useCallback)(
2484
2776
  async (params) => {
2485
2777
  setState("activating");
2486
2778
  setError(null);
@@ -2515,7 +2807,7 @@ function useActivation() {
2515
2807
  },
2516
2808
  [activatePlan, copy]
2517
2809
  );
2518
- const reset = (0, import_react13.useCallback)(() => {
2810
+ const reset = (0, import_react14.useCallback)(() => {
2519
2811
  setState("idle");
2520
2812
  setError(null);
2521
2813
  setResult(null);
@@ -2524,11 +2816,11 @@ function useActivation() {
2524
2816
  }
2525
2817
 
2526
2818
  // src/components/PaymentFormContext.tsx
2527
- var import_react14 = require("react");
2528
- var import_jsx_runtime8 = require("react/jsx-runtime");
2529
- var PaymentFormContext = (0, import_react14.createContext)(null);
2819
+ var import_react15 = require("react");
2820
+ var import_jsx_runtime9 = require("react/jsx-runtime");
2821
+ var PaymentFormContext = (0, import_react15.createContext)(null);
2530
2822
  function usePaymentForm() {
2531
- const ctx = (0, import_react14.useContext)(PaymentFormContext);
2823
+ const ctx = (0, import_react15.useContext)(PaymentFormContext);
2532
2824
  if (!ctx) {
2533
2825
  throw new Error(
2534
2826
  "PaymentForm subcomponents must be used inside a <PaymentForm>. Wrap the slots with <PaymentForm planRef=... productRef=...>."
@@ -2536,10 +2828,10 @@ function usePaymentForm() {
2536
2828
  }
2537
2829
  return ctx;
2538
2830
  }
2539
- var PaymentFormProvider = ({ value, children }) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PaymentFormContext.Provider, { value, children });
2831
+ var PaymentFormProvider = ({ value, children }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PaymentFormContext.Provider, { value, children });
2540
2832
 
2541
2833
  // src/components/CheckoutSummary.tsx
2542
- var import_jsx_runtime9 = require("react/jsx-runtime");
2834
+ var import_jsx_runtime10 = require("react/jsx-runtime");
2543
2835
  var CheckoutSummary2 = ({
2544
2836
  planRef,
2545
2837
  productRef,
@@ -2551,7 +2843,7 @@ var CheckoutSummary2 = ({
2551
2843
  }) => {
2552
2844
  const rootClass = ["solvapay-checkout-summary", className].filter(Boolean).join(" ");
2553
2845
  const hasTax = taxBreakdown != null;
2554
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2846
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
2555
2847
  CheckoutSummary.Root,
2556
2848
  {
2557
2849
  planRef,
@@ -2560,25 +2852,25 @@ var CheckoutSummary2 = ({
2560
2852
  baseAmountMinor,
2561
2853
  className: rootClass,
2562
2854
  children: [
2563
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CheckoutSummary.Product, { className: "solvapay-checkout-summary-product" }),
2564
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "solvapay-checkout-summary-row", children: [
2565
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CheckoutSummary.Plan, { className: "solvapay-checkout-summary-plan" }),
2566
- !hasTax && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CheckoutSummary.Price, { className: "solvapay-checkout-summary-price" })
2855
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CheckoutSummary.Product, { className: "solvapay-checkout-summary-product" }),
2856
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "solvapay-checkout-summary-row", children: [
2857
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CheckoutSummary.Plan, { className: "solvapay-checkout-summary-plan" }),
2858
+ !hasTax && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CheckoutSummary.Price, { className: "solvapay-checkout-summary-price" })
2567
2859
  ] }),
2568
- hasTax ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
2569
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "solvapay-checkout-summary-row", children: [
2570
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: "Subtotal" }),
2571
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CheckoutSummary.Subtotal, { className: "solvapay-checkout-summary-subtotal" })
2860
+ hasTax ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
2861
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "solvapay-checkout-summary-row", children: [
2862
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children: "Subtotal" }),
2863
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CheckoutSummary.Subtotal, { className: "solvapay-checkout-summary-subtotal" })
2572
2864
  ] }),
2573
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "solvapay-checkout-summary-row", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CheckoutSummary.Tax, { className: "solvapay-checkout-summary-tax" }) }),
2574
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "solvapay-checkout-summary-row", children: [
2575
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: "Total" }),
2576
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CheckoutSummary.Total, { className: "solvapay-checkout-summary-total" })
2865
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "solvapay-checkout-summary-row", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CheckoutSummary.Tax, { className: "solvapay-checkout-summary-tax" }) }),
2866
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "solvapay-checkout-summary-row", children: [
2867
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children: "Total" }),
2868
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CheckoutSummary.Total, { className: "solvapay-checkout-summary-total" })
2577
2869
  ] }),
2578
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CheckoutSummary.TaxTreatmentNote, { className: "solvapay-checkout-summary-tax-treatment-note" })
2579
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
2580
- showTrial && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CheckoutSummary.Trial, { className: "solvapay-checkout-summary-trial" }),
2581
- showTaxNote && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CheckoutSummary.TaxNote, { className: "solvapay-checkout-summary-tax-note" })
2870
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CheckoutSummary.TaxTreatmentNote, { className: "solvapay-checkout-summary-tax-treatment-note" })
2871
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
2872
+ showTrial && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CheckoutSummary.Trial, { className: "solvapay-checkout-summary-trial" }),
2873
+ showTaxNote && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CheckoutSummary.TaxNote, { className: "solvapay-checkout-summary-tax-note" })
2582
2874
  ] })
2583
2875
  ]
2584
2876
  }
@@ -2586,10 +2878,10 @@ var CheckoutSummary2 = ({
2586
2878
  };
2587
2879
 
2588
2880
  // src/primitives/MandateText.tsx
2589
- var import_react16 = require("react");
2881
+ var import_react17 = require("react");
2590
2882
 
2591
2883
  // src/hooks/useMerchant.ts
2592
- var import_react15 = require("react");
2884
+ var import_react16 = require("react");
2593
2885
  var merchantCache = /* @__PURE__ */ new Map();
2594
2886
  var CACHE_DURATION5 = 5 * 60 * 1e3;
2595
2887
  function cacheKeyFor2(config) {
@@ -2603,15 +2895,15 @@ async function fetchMerchant(config) {
2603
2895
  function useMerchant() {
2604
2896
  const { _config } = useSolvaPay();
2605
2897
  const key = cacheKeyFor2(_config);
2606
- const [merchant, setMerchant] = (0, import_react15.useState)(
2898
+ const [merchant, setMerchant] = (0, import_react16.useState)(
2607
2899
  () => merchantCache.get(key)?.merchant ?? null
2608
2900
  );
2609
- const [loading, setLoading] = (0, import_react15.useState)(() => {
2901
+ const [loading, setLoading] = (0, import_react16.useState)(() => {
2610
2902
  const cached = merchantCache.get(key);
2611
2903
  return !cached || !cached.merchant && !cached.promise;
2612
2904
  });
2613
- const [error, setError] = (0, import_react15.useState)(null);
2614
- const load = (0, import_react15.useCallback)(
2905
+ const [error, setError] = (0, import_react16.useState)(null);
2906
+ const load = (0, import_react16.useCallback)(
2615
2907
  async (force = false) => {
2616
2908
  const cached = merchantCache.get(key);
2617
2909
  const now = Date.now();
@@ -2665,7 +2957,7 @@ function useMerchant() {
2665
2957
  },
2666
2958
  [_config, key]
2667
2959
  );
2668
- (0, import_react15.useEffect)(() => {
2960
+ (0, import_react16.useEffect)(() => {
2669
2961
  load();
2670
2962
  }, [load]);
2671
2963
  return {
@@ -2694,8 +2986,8 @@ function deriveVariant(plan, mode) {
2694
2986
  }
2695
2987
 
2696
2988
  // src/primitives/MandateText.tsx
2697
- var import_jsx_runtime10 = require("react/jsx-runtime");
2698
- var MandateText = (0, import_react16.forwardRef)(
2989
+ var import_jsx_runtime11 = require("react/jsx-runtime");
2990
+ var MandateText = (0, import_react17.forwardRef)(
2699
2991
  function MandateText2({
2700
2992
  planRef,
2701
2993
  productRef,
@@ -2707,7 +2999,7 @@ var MandateText = (0, import_react16.forwardRef)(
2707
2999
  children,
2708
3000
  ...rest
2709
3001
  }, forwardedRef) {
2710
- const solva = (0, import_react16.useContext)(SolvaPayContext);
3002
+ const solva = (0, import_react17.useContext)(SolvaPayContext);
2711
3003
  if (!solva) throw new MissingProviderError("MandateText");
2712
3004
  const locale = useLocale();
2713
3005
  const copy = useCopy();
@@ -2724,7 +3016,7 @@ var MandateText = (0, import_react16.forwardRef)(
2724
3016
  locale,
2725
3017
  free: copy.interval.free
2726
3018
  });
2727
- const ctx = (0, import_react16.useMemo)(
3019
+ const ctx = (0, import_react17.useMemo)(
2728
3020
  () => ({
2729
3021
  merchant: {
2730
3022
  legalName: merchant?.legalName ?? merchant?.displayName ?? "",
@@ -2751,7 +3043,7 @@ var MandateText = (0, import_react16.forwardRef)(
2751
3043
  const text = typeof template === "function" ? template(ctx) : template;
2752
3044
  if (!text) return null;
2753
3045
  const Comp = asChild ? Slot : "p";
2754
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
3046
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2755
3047
  Comp,
2756
3048
  {
2757
3049
  ref: forwardedRef,
@@ -2773,7 +3065,7 @@ function linkifyMandateText(text, merchant, copy) {
2773
3065
  return text.split(pattern).map((part, i) => {
2774
3066
  const match = entries.find((e) => e.url === part);
2775
3067
  if (!match) return part;
2776
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
3068
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2777
3069
  "a",
2778
3070
  {
2779
3071
  href: match.url,
@@ -2791,11 +3083,11 @@ function escapeRegExp(value) {
2791
3083
  }
2792
3084
 
2793
3085
  // src/components/Spinner.tsx
2794
- var import_jsx_runtime11 = require("react/jsx-runtime");
3086
+ var import_jsx_runtime12 = require("react/jsx-runtime");
2795
3087
  var SIZE_PX = { sm: 16, md: 20, lg: 24 };
2796
3088
  var Spinner = ({ className, size = "md" }) => {
2797
3089
  const px = SIZE_PX[size];
2798
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
3090
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
2799
3091
  "svg",
2800
3092
  {
2801
3093
  "data-solvapay-spinner": "",
@@ -2806,7 +3098,7 @@ var Spinner = ({ className, size = "md" }) => {
2806
3098
  fill: "none",
2807
3099
  "aria-hidden": "true",
2808
3100
  children: [
2809
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3101
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2810
3102
  "circle",
2811
3103
  {
2812
3104
  cx: "12",
@@ -2817,7 +3109,7 @@ var Spinner = ({ className, size = "md" }) => {
2817
3109
  strokeOpacity: "0.25"
2818
3110
  }
2819
3111
  ),
2820
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3112
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2821
3113
  "path",
2822
3114
  {
2823
3115
  fill: "currentColor",
@@ -3030,295 +3322,6 @@ function resolveCta(input) {
3030
3322
  // src/hooks/useBusinessDetailsAttach.ts
3031
3323
  var import_react18 = require("react");
3032
3324
  var import_core3 = require("@solvapay/core");
3033
-
3034
- // src/components/businessCheckoutParts.tsx
3035
- var import_react17 = require("react");
3036
- var import_core2 = require("@solvapay/core");
3037
- var import_jsx_runtime12 = require("react/jsx-runtime");
3038
- function mapBusinessFieldErrors(input) {
3039
- const result = (0, import_core2.validateBusinessDetails)(input);
3040
- if (result.success) return {};
3041
- const errors = {};
3042
- for (const issue of result.error.issues) {
3043
- const key = issue.path[0];
3044
- if (typeof key === "string" && isBusinessDetailsKey(key) && !errors[key]) {
3045
- errors[key] = issue.message;
3046
- }
3047
- }
3048
- return errors;
3049
- }
3050
- function isBusinessDetailsKey(key) {
3051
- return key === "isBusiness" || key === "businessName" || key === "country" || key === "customerCountry" || key === "customerName" || key === "taxId" || key === "taxIdType";
3052
- }
3053
- function attr(prefix, suffix) {
3054
- return `data-solvapay-${prefix}-${suffix}`;
3055
- }
3056
- var SUPPORTED_BUSINESS_COUNTRIES_SET = new Set(import_core2.SUPPORTED_BUSINESS_COUNTRIES);
3057
- function isSupportedBusinessCountry(value) {
3058
- return SUPPORTED_BUSINESS_COUNTRIES_SET.has(value);
3059
- }
3060
- function resolveTaxIdLabel(country) {
3061
- if (country && isSupportedBusinessCountry(country)) {
3062
- return (0, import_core2.getTaxIdFieldLabel)(country);
3063
- }
3064
- return "Tax ID";
3065
- }
3066
- function resolveTaxIdPlaceholder(country) {
3067
- if (country && isSupportedBusinessCountry(country)) {
3068
- return (0, import_core2.getTaxIdExample)(country);
3069
- }
3070
- return "Enter tax ID";
3071
- }
3072
- function resolveTaxIdHelperText(country) {
3073
- if (country && isSupportedBusinessCountry(country)) {
3074
- return (0, import_core2.getTaxIdHelperText)(country);
3075
- }
3076
- return "";
3077
- }
3078
- function formatVatSummaryLabel(breakdown) {
3079
- if (breakdown.treatment === "reverse_charge") {
3080
- return "VAT (reverse charge)";
3081
- }
3082
- if (breakdown.taxRate > 0) {
3083
- const ratePercent = breakdown.taxRate <= 1 ? Math.round(breakdown.taxRate * 100) : breakdown.taxRate;
3084
- return breakdown.inclusive ? `VAT (${ratePercent}%, incl.)` : `VAT (${ratePercent}%)`;
3085
- }
3086
- return "VAT";
3087
- }
3088
- function shouldShowTaxRow(treatment, taxRate) {
3089
- if (treatment === "not_collecting") return false;
3090
- if (treatment === "reverse_charge") return true;
3091
- return taxRate > 0;
3092
- }
3093
- function createBusinessDetailsParts(useCtx, prefix) {
3094
- const Root14 = (0, import_react17.forwardRef)(function BusinessDetailsRoot({ asChild, children, ...rest }, forwardedRef) {
3095
- useCtx("BusinessDetails");
3096
- const Comp = asChild ? Slot : "section";
3097
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Comp, { ref: forwardedRef, ...{ [attr(prefix, "business-details")]: "" }, ...rest, children });
3098
- });
3099
- const Toggle = (0, import_react17.forwardRef)(function BusinessDetailsToggle({ asChild, onChange, ...rest }, forwardedRef) {
3100
- const ctx = useCtx("BusinessDetails.Toggle");
3101
- const commonProps = {
3102
- [attr(prefix, "business-details-toggle")]: "",
3103
- type: "checkbox",
3104
- checked: ctx.businessDetails.isBusiness,
3105
- onChange: composeEventHandlers(onChange, (e) => {
3106
- ctx.setBusinessDetails({ isBusiness: e.target.checked });
3107
- }),
3108
- ...rest
3109
- };
3110
- if (asChild) {
3111
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Slot, { ref: forwardedRef, ...commonProps });
3112
- }
3113
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("input", { ref: forwardedRef, ...commonProps });
3114
- });
3115
- const BusinessName = (0, import_react17.forwardRef)(
3116
- function BusinessDetailsBusinessName({ asChild, onChange, ...rest }, forwardedRef) {
3117
- const ctx = useCtx("BusinessDetails.BusinessName");
3118
- if (!ctx.businessDetails.isBusiness) return null;
3119
- const commonProps = {
3120
- [attr(prefix, "business-details-name")]: "",
3121
- type: "text",
3122
- value: ctx.businessDetails.businessName ?? "",
3123
- "aria-invalid": ctx.fieldErrors.businessName ? true : void 0,
3124
- onChange: composeEventHandlers(onChange, (e) => {
3125
- ctx.setBusinessDetails({ businessName: e.target.value });
3126
- }),
3127
- ...rest
3128
- };
3129
- if (asChild) {
3130
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Slot, { ref: forwardedRef, ...commonProps });
3131
- }
3132
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("input", { ref: forwardedRef, ...commonProps });
3133
- }
3134
- );
3135
- const Country = (0, import_react17.forwardRef)(function BusinessDetailsCountry({ asChild, onChange, children, ...rest }, forwardedRef) {
3136
- const ctx = useCtx("BusinessDetails.Country");
3137
- if (!ctx.businessDetails.isBusiness) return null;
3138
- const commonProps = {
3139
- [attr(prefix, "business-details-country")]: "",
3140
- value: ctx.businessDetails.country ?? "",
3141
- "aria-invalid": ctx.fieldErrors.country ? true : void 0,
3142
- onChange: composeEventHandlers(onChange, (e) => {
3143
- ctx.setBusinessDetails({ country: e.target.value });
3144
- }),
3145
- ...rest
3146
- };
3147
- const defaultOptions = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
3148
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("option", { value: "", children: "Select country" }),
3149
- import_core2.BUSINESS_COUNTRY_OPTIONS.map(({ value, label }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("option", { value, children: label }, value))
3150
- ] });
3151
- if (asChild) {
3152
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Slot, { ref: forwardedRef, ...commonProps, children: children ?? defaultOptions });
3153
- }
3154
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("select", { ref: forwardedRef, ...commonProps, children: children ?? defaultOptions });
3155
- });
3156
- const TaxId = (0, import_react17.forwardRef)(function BusinessDetailsTaxId({ asChild, onChange, ...rest }, forwardedRef) {
3157
- const ctx = useCtx("BusinessDetails.TaxId");
3158
- if (!ctx.businessDetails.isBusiness) return null;
3159
- const commonProps = {
3160
- [attr(prefix, "business-details-tax-id")]: "",
3161
- type: "text",
3162
- value: ctx.businessDetails.taxId ?? "",
3163
- "aria-invalid": ctx.fieldErrors.taxId ? true : void 0,
3164
- onChange: composeEventHandlers(onChange, (e) => {
3165
- ctx.setBusinessDetails({ taxId: e.target.value });
3166
- }),
3167
- ...rest
3168
- };
3169
- if (asChild) {
3170
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Slot, { ref: forwardedRef, ...commonProps });
3171
- }
3172
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("input", { ref: forwardedRef, ...commonProps });
3173
- });
3174
- const Fields2 = (0, import_react17.forwardRef)(function BusinessDetailsFields({ asChild, children, ...rest }, forwardedRef) {
3175
- const ctx = useCtx("BusinessDetails.Fields");
3176
- const country = ctx.businessDetails.country ?? "";
3177
- const taxIdLabel = resolveTaxIdLabel(country);
3178
- const taxIdPlaceholder = resolveTaxIdPlaceholder(country);
3179
- const taxIdHelperText = resolveTaxIdHelperText(country);
3180
- const content = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
3181
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "solvapay-checkout-business-toggle", children: [
3182
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Toggle, {}),
3183
- "I'm purchasing as a business"
3184
- ] }),
3185
- ctx.businessDetails.isBusiness ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("fieldset", { className: "solvapay-business-fields", children: [
3186
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "solvapay-business-field", children: [
3187
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "solvapay-business-field-label", children: "Business name" }),
3188
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(BusinessName, { placeholder: "Acme GmbH" })
3189
- ] }),
3190
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "solvapay-business-field", children: [
3191
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "solvapay-business-field-label", children: "Country" }),
3192
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Country, {})
3193
- ] }),
3194
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "solvapay-business-field", children: [
3195
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "solvapay-business-field-label", children: taxIdLabel }),
3196
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TaxId, { placeholder: taxIdPlaceholder }),
3197
- taxIdHelperText ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "solvapay-business-field-hint", children: taxIdHelperText }) : null
3198
- ] })
3199
- ] }) : null,
3200
- children
3201
- ] });
3202
- if (asChild) {
3203
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Slot, { ref: forwardedRef, ...rest, children: content });
3204
- }
3205
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("section", { ref: forwardedRef, ...{ [attr(prefix, "business-details-fields")]: "" }, ...rest, children: content });
3206
- });
3207
- return {
3208
- Root: Root14,
3209
- Toggle,
3210
- BusinessName,
3211
- Country,
3212
- TaxId,
3213
- Fields: Fields2
3214
- };
3215
- }
3216
- function useSummaryAmounts(useCtx, part) {
3217
- const ctx = useCtx(part);
3218
- const locale = useLocale();
3219
- const currency = (ctx.taxBreakdown?.currency ?? ctx.currency ?? "usd").toLowerCase();
3220
- const subtotalMinor = ctx.taxBreakdown?.subtotal ?? ctx.baseAmountMinor;
3221
- const taxMinor = ctx.taxBreakdown?.taxAmount ?? 0;
3222
- const totalMinor = ctx.taxBreakdown?.total ?? ctx.baseAmountMinor;
3223
- return {
3224
- subtotalFormatted: formatPrice(subtotalMinor, currency, { locale }),
3225
- taxFormatted: formatPrice(taxMinor, currency, { locale }),
3226
- totalFormatted: formatPrice(totalMinor, currency, { locale }),
3227
- taxRate: ctx.taxBreakdown?.taxRate ?? 0,
3228
- treatment: ctx.taxBreakdown?.treatment ?? null,
3229
- inclusive: ctx.taxBreakdown?.inclusive ?? false,
3230
- attaching: ctx.businessDetailsAttaching
3231
- };
3232
- }
3233
- function createTaxSummaryParts(useCtx, prefix) {
3234
- const Root14 = (0, import_react17.forwardRef)(function TaxSummaryRoot({ asChild, children, ...rest }, forwardedRef) {
3235
- const ctx = useCtx("Summary");
3236
- if (!ctx.isBusiness) return null;
3237
- const Comp = asChild ? Slot : "section";
3238
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Comp, { ref: forwardedRef, ...{ [attr(prefix, "summary")]: "" }, ...rest, children });
3239
- });
3240
- const Subtotal = (0, import_react17.forwardRef)(function TaxSummarySubtotal({ asChild, children, ...rest }, forwardedRef) {
3241
- const ctx = useCtx("Summary.Subtotal");
3242
- const { subtotalFormatted } = useSummaryAmounts(useCtx, "Summary.Subtotal");
3243
- if (!ctx.isBusiness) return null;
3244
- const Comp = asChild ? Slot : "span";
3245
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Comp, { ref: forwardedRef, ...{ [attr(prefix, "summary-subtotal")]: "" }, ...rest, children: children ?? subtotalFormatted });
3246
- });
3247
- const Tax = (0, import_react17.forwardRef)(function TaxSummaryTax({ asChild, children, ...rest }, forwardedRef) {
3248
- const ctx = useCtx("Summary.Tax");
3249
- const { taxFormatted, taxRate, treatment, inclusive } = useSummaryAmounts(useCtx, "Summary.Tax");
3250
- if (!ctx.isBusiness) return null;
3251
- const Comp = asChild ? Slot : "span";
3252
- const defaultLabel = formatVatSummaryLabel({
3253
- treatment: treatment ?? "standard",
3254
- taxRate,
3255
- inclusive
3256
- });
3257
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Comp, { ref: forwardedRef, ...{ [attr(prefix, "summary-tax")]: "" }, ...rest, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
3258
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: defaultLabel }),
3259
- " ",
3260
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { ...{ [attr(prefix, "summary-tax-amount")]: "" }, children: taxFormatted })
3261
- ] }) });
3262
- });
3263
- const Total = (0, import_react17.forwardRef)(function TaxSummaryTotal({ asChild, children, ...rest }, forwardedRef) {
3264
- const ctx = useCtx("Summary.Total");
3265
- const { totalFormatted } = useSummaryAmounts(useCtx, "Summary.Total");
3266
- if (!ctx.isBusiness) return null;
3267
- const Comp = asChild ? Slot : "span";
3268
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Comp, { ref: forwardedRef, ...{ [attr(prefix, "summary-total")]: "" }, ...rest, children: children ?? totalFormatted });
3269
- });
3270
- const TaxNote = (0, import_react17.forwardRef)(function TaxSummaryTaxNote({ asChild, children, ...rest }, forwardedRef) {
3271
- const ctx = useCtx("Summary.TaxNote");
3272
- const { treatment } = useSummaryAmounts(useCtx, "Summary.TaxNote");
3273
- if (!ctx.isBusiness) return null;
3274
- if (!treatment || treatment === "standard") return null;
3275
- const Comp = asChild ? Slot : "p";
3276
- const defaultNote = treatment === "reverse_charge" ? "VAT reverse charge applies \u2014 you are responsible for reporting VAT in your jurisdiction." : treatment === "not_collecting" ? "Tax is not collected on this purchase." : null;
3277
- if (!defaultNote && !children) return null;
3278
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Comp, { ref: forwardedRef, ...{ [attr(prefix, "summary-tax-note")]: "" }, ...rest, children: children ?? defaultNote });
3279
- });
3280
- const Rows = (0, import_react17.forwardRef)(function TaxSummaryRows({ asChild, children, ...rest }, forwardedRef) {
3281
- const ctx = useCtx("Summary.Rows");
3282
- const { taxRate, treatment, inclusive, taxFormatted } = useSummaryAmounts(useCtx, "Summary.Rows");
3283
- if (!ctx.isBusiness) return null;
3284
- const showTaxRow = shouldShowTaxRow(treatment, taxRate);
3285
- const vatLabel = formatVatSummaryLabel({
3286
- treatment: treatment ?? "standard",
3287
- taxRate,
3288
- inclusive
3289
- });
3290
- const content = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("dl", { className: "solvapay-tax-summary-rows", children: [
3291
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { className: "solvapay-tax-summary-row", children: [
3292
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dt", { children: "Subtotal" }),
3293
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dd", { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Subtotal, {}) })
3294
- ] }),
3295
- showTaxRow ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { className: "solvapay-tax-summary-row", children: [
3296
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dt", { children: vatLabel }),
3297
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dd", { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { ...{ [attr(prefix, "summary-tax-amount")]: "" }, children: taxFormatted }) })
3298
- ] }) : null,
3299
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { className: "solvapay-tax-summary-row solvapay-tax-summary-row--total", children: [
3300
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dt", { children: "Total" }),
3301
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dd", { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Total, {}) })
3302
- ] }),
3303
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TaxNote, {}),
3304
- children
3305
- ] });
3306
- if (asChild) {
3307
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Slot, { ref: forwardedRef, ...rest, children: content });
3308
- }
3309
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("section", { ref: forwardedRef, ...{ [attr(prefix, "summary-rows")]: "" }, ...rest, children: content });
3310
- });
3311
- return {
3312
- Root: Root14,
3313
- Subtotal,
3314
- Tax,
3315
- Total,
3316
- TaxNote,
3317
- Rows
3318
- };
3319
- }
3320
-
3321
- // src/hooks/useBusinessDetailsAttach.ts
3322
3325
  var defaultBusinessDetails = { isBusiness: false };
3323
3326
  function useBusinessDetailsAttach(options) {
3324
3327
  const {
@@ -7928,15 +7931,14 @@ function planBillingInterval(plan) {
7928
7931
  return (0, import_core7.billingCycle)(plan)?.interval ?? null;
7929
7932
  }
7930
7933
  function formatPaygRate(plan, locale, balance) {
7934
+ const rate = (0, import_core7.usageRate)(plan);
7935
+ if (!rate || !(rate.amountMinor > 0)) return null;
7936
+ const prefix = rate.tiered ? "from " : "";
7931
7937
  const credits = (0, import_core7.creditsPerUnitFromBalance)(plan, balance);
7932
7938
  if (credits != null) {
7933
- return `${credits.toLocaleString(locale)} ${credits === 1 ? "credit" : "credits"} / call`;
7934
- }
7935
- const charge = (0, import_core7.perUnitCharge)(plan);
7936
- if (charge && charge.amountMinor > 0) {
7937
- return `${formatPrice(charge.amountMinor, charge.currency.toUpperCase(), { locale })} / call`;
7939
+ return `${prefix}${credits.toLocaleString(locale)} ${credits === 1 ? "credit" : "credits"} / call`;
7938
7940
  }
7939
- return null;
7941
+ return `${prefix}${formatPrice(rate.amountMinor, rate.currency.toUpperCase(), { locale })} / call`;
7940
7942
  }
7941
7943
  function inferIncludedUnits(plan) {
7942
7944
  const cap = (0, import_core7.includedUnits)(plan);