@nice2dev/ui-money 1.0.11 → 1.0.14

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.
@@ -31,6 +31,21 @@ export interface NiceMoneyInputProps extends Omit<NiceFormFieldProps, 'displayMo
31
31
  /** Bubble up blur / focus for form-library integrations. */
32
32
  onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;
33
33
  onFocus?: (e: React.FocusEvent<HTMLInputElement>) => void;
34
+ /**
35
+ * Live thousands grouping while typing (default: `true` when the active locale
36
+ * uses a group separator). Disable for crypto inputs where you want pure digits.
37
+ */
38
+ liveGrouping?: boolean;
39
+ /**
40
+ * Enable `k` / `m` / `b` shortcut multipliers (e.g. typing `12k` produces `12000`).
41
+ * Default: `true`.
42
+ */
43
+ multiplierShortcuts?: boolean;
44
+ /**
45
+ * Called when validation fails (overflow `Number.MAX_SAFE_INTEGER`, NaN,
46
+ * out-of-range etc.). Passed an `Error`.
47
+ */
48
+ onValidationError?: (err: Error) => void;
34
49
  }
35
50
  /**
36
51
  * {@link NiceMoneyInput} — amount + currency input with locale-aware formatting,
@@ -0,0 +1,46 @@
1
+ import { NiceBaseProps } from '@nice2dev/ui-core';
2
+ import { Money } from '../types';
3
+
4
+ export interface NiceTaxBreakdownLine {
5
+ /** Optional human label (e.g. "Standard rate", "Reduced rate"). */
6
+ label?: string;
7
+ /** Net amount in minor units. */
8
+ netAmount: Money;
9
+ /** VAT/tax rate as a fraction (0.23 = 23%). */
10
+ vatRate: number;
11
+ }
12
+ export interface NiceTaxBreakdownProps extends NiceBaseProps {
13
+ /** Tax lines (one row per VAT rate, optionally grouped). */
14
+ lines: NiceTaxBreakdownLine[];
15
+ /** Locale used for formatting amounts. Default: browser locale. */
16
+ locale?: string;
17
+ /**
18
+ * Rounding semantics:
19
+ * - `'line'` (PL): VAT computed and rounded per line, then summed (Polish JPK requirement).
20
+ * - `'total'` (DE): net summed first, then VAT computed once.
21
+ * Default: `'line'`.
22
+ */
23
+ rounding?: 'line' | 'total';
24
+ /** Show a totals row at the bottom (default `true`). */
25
+ showTotals?: boolean;
26
+ /** Show a grand-total VAT row that aggregates all lines (default `true`). */
27
+ showGrandTotal?: boolean;
28
+ /** Hide the rate column. Useful when every line shares one rate. */
29
+ hideRateColumn?: boolean;
30
+ /** Custom column titles. */
31
+ labels?: Partial<{
32
+ label: string;
33
+ rate: string;
34
+ net: string;
35
+ vat: string;
36
+ gross: string;
37
+ total: string;
38
+ }>;
39
+ /** Compact density (smaller padding / font). */
40
+ density?: 'comfortable' | 'compact';
41
+ }
42
+ /**
43
+ * {@link NiceTaxBreakdown} — VAT/tax breakdown table grouping net / tax / gross
44
+ * by rate. Supports both per-line and per-total rounding semantics.
45
+ */
46
+ export declare const NiceTaxBreakdown: import('react').ForwardRefExoticComponent<NiceTaxBreakdownProps & import('react').RefAttributes<HTMLTableElement>>;
@@ -76,6 +76,45 @@ export declare class ExchangeRateHostProvider extends CachingHttpProvider {
76
76
  constructor(opts?: HttpProviderOpts);
77
77
  getRate(base: string, quote: string): Promise<ExchangeRate>;
78
78
  }
79
+ /**
80
+ * NBP (Narodowy Bank Polski) — official Polish central-bank rates. Free, no API key.
81
+ * Supports tables A (mid rates, ~32 currencies), B (less common ~118 currencies),
82
+ * and C (bid/ask rates).
83
+ *
84
+ * https://api.nbp.pl/
85
+ */
86
+ export declare class NbpRatesProvider extends CachingHttpProvider {
87
+ readonly id = "nbp";
88
+ private readonly table;
89
+ constructor(opts?: HttpProviderOpts & {
90
+ table?: 'A' | 'B' | 'C';
91
+ });
92
+ getRate(base: string, quote: string): Promise<ExchangeRate>;
93
+ }
94
+ /**
95
+ * European Central Bank (ECB) — official EUR-base rates published business days at ~16:00 CET.
96
+ * Implemented on top of the Frankfurter API which proxies ECB data.
97
+ */
98
+ export declare class EcbRatesProvider extends FrankfurterProvider {
99
+ readonly id: "frankfurter";
100
+ }
101
+ /**
102
+ * Generic free-forex fallback (uses exchangerate.host). No API key.
103
+ * Aliased helper kept for clarity in factory callers.
104
+ */
105
+ export declare class FreeForexApiProvider extends ExchangeRateHostProvider {
106
+ readonly id: "exchangerate.host";
107
+ }
108
+ /** Factory helpers — ergonomic for OmniVerk-style callers. */
109
+ export declare const createNbpRatesProvider: (opts?: HttpProviderOpts & {
110
+ table?: "A" | "B" | "C";
111
+ cache?: string;
112
+ }) => NbpRatesProvider;
113
+ export declare const createEcbRatesProvider: (opts?: HttpProviderOpts) => EcbRatesProvider;
114
+ export declare const createOpenExchangeRatesProvider: (config: {
115
+ apiKey: string;
116
+ } & HttpProviderOpts) => OpenExchangeRatesProvider;
117
+ export declare const createFreeForexApiProvider: (opts?: HttpProviderOpts) => FreeForexApiProvider;
79
118
  /** Convert a money amount using a provider (single round-trip). */
80
119
  export declare function convertMoney(source: Money, targetCurrency: string, provider: ExchangeRateProvider): Promise<Money>;
81
120
  export {};
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var Xe=Object.defineProperty;var We=(r,e,n)=>e in r?Xe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n;var F=(r,e,n)=>We(r,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),c=require("react/jsx-runtime"),ne=[{code:"USD",numeric:840,symbol:"$",name:"US Dollar",decimals:2,symbolFirst:!0},{code:"EUR",numeric:978,symbol:"€",name:"Euro",decimals:2,symbolFirst:!0},{code:"GBP",numeric:826,symbol:"£",name:"Pound Sterling",decimals:2,symbolFirst:!0},{code:"JPY",numeric:392,symbol:"¥",name:"Japanese Yen",decimals:0,symbolFirst:!0},{code:"CHF",numeric:756,symbol:"Fr",name:"Swiss Franc",decimals:2},{code:"CAD",numeric:124,symbol:"CA$",name:"Canadian Dollar",decimals:2,symbolFirst:!0},{code:"AUD",numeric:36,symbol:"A$",name:"Australian Dollar",decimals:2,symbolFirst:!0},{code:"NZD",numeric:554,symbol:"NZ$",name:"New Zealand Dollar",decimals:2,symbolFirst:!0},{code:"CNY",numeric:156,symbol:"¥",name:"Chinese Yuan Renminbi",decimals:2,symbolFirst:!0},{code:"HKD",numeric:344,symbol:"HK$",name:"Hong Kong Dollar",decimals:2,symbolFirst:!0},{code:"SGD",numeric:702,symbol:"S$",name:"Singapore Dollar",decimals:2,symbolFirst:!0},{code:"PLN",numeric:985,symbol:"zł",name:"Polish Złoty",decimals:2},{code:"CZK",numeric:203,symbol:"Kč",name:"Czech Koruna",decimals:2},{code:"HUF",numeric:348,symbol:"Ft",name:"Hungarian Forint",decimals:2},{code:"RON",numeric:946,symbol:"lei",name:"Romanian Leu",decimals:2},{code:"BGN",numeric:975,symbol:"лв",name:"Bulgarian Lev",decimals:2},{code:"HRK",numeric:191,symbol:"kn",name:"Croatian Kuna",decimals:2},{code:"DKK",numeric:208,symbol:"kr",name:"Danish Krone",decimals:2},{code:"SEK",numeric:752,symbol:"kr",name:"Swedish Krona",decimals:2},{code:"NOK",numeric:578,symbol:"kr",name:"Norwegian Krone",decimals:2},{code:"ISK",numeric:352,symbol:"kr",name:"Icelandic Króna",decimals:0},{code:"RUB",numeric:643,symbol:"₽",name:"Russian Ruble",decimals:2},{code:"UAH",numeric:980,symbol:"₴",name:"Ukrainian Hryvnia",decimals:2},{code:"TRY",numeric:949,symbol:"₺",name:"Turkish Lira",decimals:2,symbolFirst:!0},{code:"MXN",numeric:484,symbol:"Mex$",name:"Mexican Peso",decimals:2,symbolFirst:!0},{code:"BRL",numeric:986,symbol:"R$",name:"Brazilian Real",decimals:2,symbolFirst:!0},{code:"ARS",numeric:32,symbol:"AR$",name:"Argentine Peso",decimals:2,symbolFirst:!0},{code:"CLP",numeric:152,symbol:"CL$",name:"Chilean Peso",decimals:0,symbolFirst:!0},{code:"COP",numeric:170,symbol:"CO$",name:"Colombian Peso",decimals:2,symbolFirst:!0},{code:"PEN",numeric:604,symbol:"S/",name:"Peruvian Sol",decimals:2,symbolFirst:!0},{code:"UYU",numeric:858,symbol:"$U",name:"Uruguayan Peso",decimals:2,symbolFirst:!0},{code:"INR",numeric:356,symbol:"₹",name:"Indian Rupee",decimals:2,symbolFirst:!0},{code:"IDR",numeric:360,symbol:"Rp",name:"Indonesian Rupiah",decimals:2,symbolFirst:!0},{code:"KRW",numeric:410,symbol:"₩",name:"South Korean Won",decimals:0,symbolFirst:!0},{code:"MYR",numeric:458,symbol:"RM",name:"Malaysian Ringgit",decimals:2,symbolFirst:!0},{code:"PHP",numeric:608,symbol:"₱",name:"Philippine Peso",decimals:2,symbolFirst:!0},{code:"THB",numeric:764,symbol:"฿",name:"Thai Baht",decimals:2,symbolFirst:!0},{code:"VND",numeric:704,symbol:"₫",name:"Vietnamese Đồng",decimals:0},{code:"TWD",numeric:901,symbol:"NT$",name:"New Taiwan Dollar",decimals:2,symbolFirst:!0},{code:"PKR",numeric:586,symbol:"₨",name:"Pakistani Rupee",decimals:2},{code:"BDT",numeric:50,symbol:"৳",name:"Bangladeshi Taka",decimals:2},{code:"LKR",numeric:144,symbol:"Rs",name:"Sri Lankan Rupee",decimals:2},{code:"AED",numeric:784,symbol:"د.إ",name:"UAE Dirham",decimals:2},{code:"SAR",numeric:682,symbol:"ر.س",name:"Saudi Riyal",decimals:2},{code:"QAR",numeric:634,symbol:"ر.ق",name:"Qatari Riyal",decimals:2},{code:"KWD",numeric:414,symbol:"د.ك",name:"Kuwaiti Dinar",decimals:3},{code:"BHD",numeric:48,symbol:".د.ب",name:"Bahraini Dinar",decimals:3},{code:"OMR",numeric:512,symbol:"ر.ع",name:"Omani Rial",decimals:3},{code:"JOD",numeric:400,symbol:"د.أ",name:"Jordanian Dinar",decimals:3},{code:"ILS",numeric:376,symbol:"₪",name:"Israeli New Shekel",decimals:2,symbolFirst:!0},{code:"EGP",numeric:818,symbol:"E£",name:"Egyptian Pound",decimals:2,symbolFirst:!0},{code:"ZAR",numeric:710,symbol:"R",name:"South African Rand",decimals:2,symbolFirst:!0},{code:"NGN",numeric:566,symbol:"₦",name:"Nigerian Naira",decimals:2,symbolFirst:!0},{code:"KES",numeric:404,symbol:"KSh",name:"Kenyan Shilling",decimals:2},{code:"GHS",numeric:936,symbol:"₵",name:"Ghanaian Cedi",decimals:2},{code:"MAD",numeric:504,symbol:"د.م.",name:"Moroccan Dirham",decimals:2},{code:"TND",numeric:788,symbol:"د.ت",name:"Tunisian Dinar",decimals:3},{code:"BTC",numeric:0,symbol:"₿",name:"Bitcoin",decimals:8,symbolFirst:!0},{code:"ETH",numeric:0,symbol:"Ξ",name:"Ether",decimals:8,symbolFirst:!0},{code:"USDC",numeric:0,symbol:"USDC",name:"USD Coin",decimals:6},{code:"USDT",numeric:0,symbol:"USDT",name:"Tether",decimals:6}],je=new Map(ne.map(r=>[r.code,r]));function O(r){return je.get(r.toUpperCase())}function en(r){je.set(r.code.toUpperCase(),r);const e=ne.findIndex(n=>n.code===r.code);e>=0?ne[e]=r:ne.push(r)}function W(r,e){const n=O(e),t=(n==null?void 0:n.decimals)??2,a=Math.pow(10,t);return{amount:(r<0?-1:1)*Math.round(Math.abs(r)*a),currency:e.toUpperCase()}}function de(r){const e=O(r.currency),n=(e==null?void 0:e.decimals)??2;return r.amount/Math.pow(10,n)}function nn(r,e){return r.currency.toUpperCase()===e.currency.toUpperCase()}function me(r,e,n){if(!nn(r,e))throw new Error(`Cannot ${n} different currencies: ${r.currency} vs ${e.currency}`)}function Se(r,e){return me(r,e,"add"),{amount:r.amount+e.amount,currency:r.currency}}function Me(r,e){return me(r,e,"subtract"),{amount:r.amount-e.amount,currency:r.currency}}function ve(r,e){return{amount:(r.amount*e<0?-1:1)*Math.round(Math.abs(r.amount*e)),currency:r.currency}}function rn(r,e){return me(r,e,"compare"),r.amount-e.amount}function tn(r){return r.amount===0}function an(r){return r.amount<0}function cn(r){return{amount:-r.amount,currency:r.currency}}function V(r,e={}){const n=O(r.currency),t=e.decimals??(n==null?void 0:n.decimals)??2,a=r.amount/Math.pow(10,t);try{return new Intl.NumberFormat(e.locale,{style:"currency",currency:r.currency,minimumFractionDigits:t,maximumFractionDigits:t,currencyDisplay:e.currencyDisplay??"symbol"}).format(a)}catch{const s=(n==null?void 0:n.symbol)??r.currency,l=a.toFixed(t);return n!=null&&n.symbolFirst?`${s}${l}`:`${l} ${s}`}}function Re(r,e){if(!r)return null;let n=r.replace(/[^\d.,\-]/g,"").trim();if(!n||n==="-")return null;const t=n.startsWith("-");t&&(n=n.slice(1));const a=n.lastIndexOf("."),s=n.lastIndexOf(","),l=Math.max(a,s);let d,u="";l===-1?d=n:(d=n.slice(0,l).replace(/[.,]/g,""),u=n.slice(l+1).replace(/[.,]/g,""));const o=`${d}.${u||"0"}`,p=parseFloat(o);return Number.isFinite(p)?W(t?-p:p,e):null}function ae(r){const e=(r||"").replace(/\D/g,"");return e?/^4/.test(e)?"visa":/^(5[1-5]|2(2[2-9]|[3-6]\d|7[01]|720))/.test(e)?"mastercard":/^3[47]/.test(e)?"amex":/^(6011|65|64[4-9]|622(12[6-9]|1[3-9]\d|[2-8]\d\d|9[01]\d|92[0-5]))/.test(e)?"discover":/^3(0[0-5]|[68])/.test(e)?"diners":/^35(2[89]|[3-8])/.test(e)?"jcb":/^62/.test(e)?"unionpay":/^(50|5[6-9]|6[0-9])/.test(e)?"maestro":/^(2200|2201|2202|2203|2204)/.test(e)?"mir":/^(4011|4312|4389|4514|4576|5041|5066|5067|509|6277|6362|6363|650|6516|6550)/.test(e)?"elo":/^(606282|3841)/.test(e)?"hipercard":"unknown":"unknown"}function ye(r){const e=(r||"").replace(/\D/g,"");if(e.length<12||e.length>19)return!1;let n=0,t=!1;for(let a=e.length-1;a>=0;a--){let s=e.charCodeAt(a)-48;t&&(s*=2,s>9&&(s-=9)),n+=s,t=!t}return n%10===0}function $e(r,e){const n=(r||"").replace(/\D/g,""),t=e??ae(n);return t==="amex"?[n.slice(0,4),n.slice(4,10),n.slice(10,15)].filter(Boolean).join(" "):t==="diners"?[n.slice(0,4),n.slice(4,10),n.slice(10,14)].filter(Boolean).join(" "):(n.match(/.{1,4}/g)??[]).join(" ").trim()}function sn(r,e){const n=(r||"").replace(/\D/g,"");if(n.length<4)return n;const t=n.slice(-4),a="*".repeat(n.length-4)+t,s=e??ae(n);return s==="amex"?[a.slice(0,4),a.slice(4,10),a.slice(10,15)].filter(Boolean).join(" "):s==="diners"?[a.slice(0,4),a.slice(4,10),a.slice(10,14)].filter(Boolean).join(" "):(a.match(/.{1,4}/g)??[]).join(" ").trim()}function pe(r){const e=(r||"").replace(/\D/g,"");if(e.length<3)return null;const n=e.slice(0,2),t=e.length>=4?e.slice(-2):e.slice(2,4),a=parseInt(n,10);return!Number.isFinite(a)||a<1||a>12?null:`${n}/${t}`}function fe(r,e=new Date){const n=pe(r);if(!n)return!1;const[t,a]=n.split("/"),s=parseInt(t,10),l=2e3+parseInt(a,10);return new Date(l,s,0,23,59,59,999).getTime()>=e.getTime()}function ee(r){return r==="amex"?4:3}function le(r,e={}){var o;const n={},t=ae(r.number),a=ye(r.number);a||(n.number="Invalid card number");const s=fe(r.expiry,e.now);s||(n.expiry="Invalid or expired");const d=(r.cvc||"").replace(/\D/g,"").length===ee(t);d||(n.cvc=`CVC must be ${ee(t)} digits`);const u=!e.requireHolder||(((o=r.holderName)==null?void 0:o.trim().length)??0)>=2;return u||(n.holderName="Cardholder name required"),{brand:t,numberValid:a,expiryValid:s,cvcValid:d,holderValid:u,isValid:a&&s&&d&&u,errors:n}}class on{constructor(e){F(this,"id","static");this.rates=e}async getRate(e,n){const t=e.toUpperCase(),a=n.toUpperCase();if(t===a)return{base:t,quote:a,rate:1,asOf:new Date().toISOString()};const s=this.rates.find(o=>o.base===t&&o.quote===a);if(s)return s;const l=this.rates.find(o=>o.base===a&&o.quote===t);if(l)return{base:t,quote:a,rate:1/l.rate,asOf:l.asOf};const d=this.rates.find(o=>o.base===t&&o.quote==="USD")??this.rates.find(o=>o.base==="USD"&&o.quote===t),u=this.rates.find(o=>o.base==="USD"&&o.quote===a)??this.rates.find(o=>o.base===a&&o.quote==="USD");if(d&&u){const o=d.base==="USD"?1/d.rate:d.rate,p=u.base==="USD"?u.rate:1/u.rate;return{base:t,quote:a,rate:o*p,asOf:new Date().toISOString()}}throw new Error(`No FX rate for ${t}/${a}`)}}class he{constructor(e={}){F(this,"cache",new Map);F(this,"fetchImpl");F(this,"ttl");this.fetchImpl=e.fetchImpl??fetch,this.ttl=e.cacheTtl??6e4}cacheKey(e,n){return`${this.id}:${e.toUpperCase()}/${n.toUpperCase()}`}getCached(e,n){const t=this.cacheKey(e,n),a=this.cache.get(t);return a&&a.expires>Date.now()?a.rate:(a&&this.cache.delete(t),null)}setCached(e){this.cache.set(this.cacheKey(e.base,e.quote),{expires:Date.now()+this.ttl,rate:e})}}class ln extends he{constructor(n={}){super(n);F(this,"id","frankfurter")}async getRate(n,t){const a=n.toUpperCase(),s=t.toUpperCase();if(a===s)return{base:a,quote:s,rate:1,asOf:new Date().toISOString()};const l=this.getCached(a,s);if(l)return l;const d=`https://api.frankfurter.app/latest?from=${a}&to=${s}`,u=await this.fetchImpl(d);if(!u.ok)throw new Error(`Frankfurter HTTP ${u.status}`);const o=await u.json(),p=o.rates[s];if(p==null)throw new Error(`Frankfurter: no rate for ${a}/${s}`);const h={base:a,quote:s,rate:p,asOf:o.date};return this.setCached(h),h}}class un extends he{constructor(n,t={}){super(t);F(this,"id","openexchangerates");this.appId=n}async getRate(n,t){const a=n.toUpperCase(),s=t.toUpperCase();if(a===s)return{base:a,quote:s,rate:1,asOf:new Date().toISOString()};const l=this.getCached(a,s);if(l)return l;const d=`https://openexchangerates.org/api/latest.json?app_id=${this.appId}`,u=await this.fetchImpl(d);if(!u.ok)throw new Error(`OpenExchangeRates HTTP ${u.status}`);const o=await u.json(),p=o.rates[a],h=o.rates[s];if(p==null||h==null)throw new Error(`OpenExchangeRates: missing rate for ${a} or ${s}`);const y={base:a,quote:s,rate:h/p,asOf:new Date(o.timestamp*1e3).toISOString()};return this.setCached(y),y}}class dn extends he{constructor(n={}){super(n);F(this,"id","exchangerate.host")}async getRate(n,t){var y;const a=n.toUpperCase(),s=t.toUpperCase();if(a===s)return{base:a,quote:s,rate:1,asOf:new Date().toISOString()};const l=this.getCached(a,s);if(l)return l;const d=`https://api.exchangerate.host/convert?from=${a}&to=${s}`,u=await this.fetchImpl(d);if(!u.ok)throw new Error(`exchangerate.host HTTP ${u.status}`);const o=await u.json(),p=((y=o.info)==null?void 0:y.rate)??o.result,h={base:a,quote:s,rate:p,asOf:o.date};return this.setCached(h),h}}async function Ue(r,e,n){const t=e.toUpperCase();if(r.currency.toUpperCase()===t)return r;const a=O(r.currency),s=O(t),l=(a==null?void 0:a.decimals)??2,d=(s==null?void 0:s.decimals)??2,{rate:u}=await n.getRate(r.currency,t),p=r.amount/Math.pow(10,l)*u;return{currency:t,amount:Math.round(p*Math.pow(10,d))}}class Ee{constructor(e={}){F(this,"id");F(this,"name");F(this,"supportedCurrencies");F(this,"minimums");F(this,"counter",0);this.id=e.id??"mock",this.name=e.name??"Mock Processor",this.supportedCurrencies=e.supportedCurrencies??"*"}newId(e){return this.counter+=1,`${e}_${Date.now().toString(36)}_${this.counter}`}async authorize(e){return{id:this.newId("auth"),status:"authorized",processor:this.id,amount:e.amount,raw:{mock:!0,request:e}}}async capture(e,n){return{id:e.replace("auth_","cap_"),status:"captured",processor:this.id,amount:n}}async cancel(e){return{id:e,status:"cancelled",processor:this.id}}async refund(e,n){return{id:e.replace(/^[a-z]+_/,"ref_"),status:"refunded",processor:this.id,amount:n}}}function H(r,e,n,t,a){const s=l=>{const d=t==null?void 0:t[l];return d||(async()=>{throw new Error(`[ui-money] ${e} adapter is not wired. Pass an \`executor.${String(l)}\` implementation that calls the ${e} SDK.`)})};return{id:r,name:e,supportedCurrencies:n,minimums:a,authorize:s("authorize"),capture:s("capture"),cancel:s("cancel"),refund:s("refund")}}function ke(r){return H("stripe","Stripe","*",r,{USD:50,EUR:50,GBP:30,JPY:50,AUD:50,CAD:50,CHF:50,DKK:250,NOK:300,SEK:300,PLN:200})}function Pe(r){return H("paypal","PayPal",["USD","EUR","GBP","AUD","CAD","JPY","CHF","NZD","SEK","NOK","DKK","PLN","CZK","HUF","BRL","MXN","HKD","SGD","TWD","THB","PHP","ILS"],r)}function Ie(r){return H("adyen","Adyen","*",r)}function Ae(r){return H("square","Square",["USD","CAD","GBP","AUD","JPY","EUR"],r)}function Fe(r){return H("mollie","Mollie","*",r)}function Oe(r){return H("braintree","Braintree","*",r)}function Ke(r){return H("razorpay","Razorpay",["INR","USD","EUR","GBP","AED"],r)}function Te(r){return H("payu","PayU",["PLN","EUR","USD","CZK","HUF","RON","BGN","TRY"],r)}function Be(r){return H("przelewy24","Przelewy24",["PLN","EUR"],r)}function qe(r){return H("klarna","Klarna",["USD","EUR","GBP","SEK","NOK","DKK","CHF","AUD","CAD","NZD","PLN"],r)}function Le(r){return H("coinbase-commerce","Coinbase Commerce",["BTC","ETH","USDC","USDT","USD","EUR"],r)}const mn={mock:()=>new Ee,stripe:()=>ke(),paypal:()=>Pe(),adyen:()=>Ie(),square:()=>Ae(),mollie:()=>Fe(),braintree:()=>Oe(),razorpay:()=>Ke(),payu:()=>Te(),przelewy24:()=>Be(),klarna:()=>qe(),"coinbase-commerce":()=>Le()};function yn(r,e){const n=i.useMemo(()=>"amount"in r?r:W(r.major,r.currency),[]),[t,a]=i.useState(n),s=i.useCallback(y=>a(m=>W(y,m.currency)),[]),l=i.useCallback(y=>{a(m=>({...m,currency:y.toUpperCase()}))},[]),d=i.useCallback(y=>a(m=>Se(m,y)),[]),u=i.useCallback(y=>a(m=>Me(m,y)),[]),o=i.useCallback(y=>a(m=>ve(m,y)),[]),p=i.useMemo(()=>V(t,{locale:e}),[t,e]),h=i.useMemo(()=>de(t),[t]);return{money:t,setMoney:a,setMajor:s,setCurrency:l,add:d,subtract:u,scale:o,formatted:p,major:h}}function oe(r,e,n){const[t,a]=i.useState(null),[s,l]=i.useState(null),[d,u]=i.useState(!1),o=i.useRef(0);return i.useEffect(()=>{if(!r){a(null);return}const p=++o.current;u(!0),l(null),Ue(r,e,n).then(h=>{o.current===p&&a(h)}).catch(h=>{o.current===p&&(l(h instanceof Error?h:new Error(String(h))),a(null))}).finally(()=>{o.current===p&&u(!1)})},[r==null?void 0:r.amount,r==null?void 0:r.currency,e,n]),{converted:t,loading:d,error:s}}function He(r){const[e,n]=i.useState("idle"),[t,a]=i.useState(null),[s,l]=i.useState(null),d=i.useCallback(()=>{n("idle"),a(null),l(null)},[]),u=i.useCallback(async y=>{n("authorizing"),l(null);try{const m=await r.authorize(y);return a(m),n(m.status),m}catch(m){const _=m instanceof Error?m:new Error(String(m));throw l(_),n("failed"),_}},[r]),o=i.useCallback(async(y,m)=>{const _=y??(t==null?void 0:t.id);if(!_)throw new Error("No authorization id to capture");n("capturing");try{const x=await r.capture(_,m);return a(x),n(x.status),x}catch(x){const b=x instanceof Error?x:new Error(String(x));throw l(b),n("failed"),b}},[r,t==null?void 0:t.id]),p=i.useCallback(async y=>{const m=y??(t==null?void 0:t.id);if(!m)throw new Error("No payment id to cancel");const _=await r.cancel(m);return a(_),n(_.status),_},[r,t==null?void 0:t.id]),h=i.useCallback(async(y,m)=>{const _=y??(t==null?void 0:t.id);if(!_)throw new Error("No payment id to refund");const x=await r.refund(_,m);return a(x),n(x.status),x},[r,t==null?void 0:t.id]);return{status:e,response:t,error:s,authorize:u,capture:o,cancel:p,refund:h,reset:d}}const ue=i.forwardRef(function({value:e,amount:n,currency:t,locale:a,display:s="symbol",highlightNegative:l=!0,zeroPlaceholder:d,convertTo:u,exchangeProvider:o,className:p,style:h,"aria-label":y},m){const _=i.useMemo(()=>{if(e)return e;if(n!=null&&t){const $=O(t),U=($==null?void 0:$.decimals)??2;return{amount:Math.round(n*Math.pow(10,U)),currency:t.toUpperCase()}}return null},[e,n,t]),x=i.useMemo(()=>_?_.amount===0&&d!=null?d:V(_,{locale:a,currencyDisplay:s}):"",[_,a,s,d]),{converted:b}=oe(u&&o?_:null,u??"",o);if(!_)return null;const T=_.amount<0,B="nice-money"+(l&&T?" nice-money--negative":"")+(p?` ${p}`:"");return c.jsxs("span",{ref:m,className:B,style:h,"aria-label":y,children:[c.jsx("span",{className:"nice-money__value",children:x}),b&&c.jsxs("span",{className:"nice-money__converted","aria-label":`Converted to ${b.currency}`,children:[" ≈ ",V(b,{locale:a})]})]})}),pn=ne.map(r=>r.code).sort(),be=i.forwardRef(function({value:e,onChange:n,options:t=ne,recents:a=[],searchable:s,showCode:l=!0,showSymbol:d=!0,compact:u=!1,disabled:o,readOnly:p,loading:h,accessMode:y,label:m,helperText:_,error:x,required:b,size:T="md",labelPlacement:B="top",labelWidth:$,controlWidth:U,className:Z,style:J,id:E,name:R,title:X,"data-testid":v,"aria-label":z,placeholder:P},D){if(y==="hidden")return null;const K=o||y==="disabled"||h,Q=p||y==="readOnly",k=i.useId(),q=E??`nice-cs-${k}`,[Y,L]=i.useState(""),w=s??t.length>8,g=i.useMemo(()=>{if(!Y.trim())return t;const f=Y.trim().toLowerCase();return t.filter(S=>S.code.toLowerCase().includes(f)||S.name.toLowerCase().includes(f)||S.symbol.toLowerCase().includes(f))},[t,Y]),j=i.useMemo(()=>{const f=new Set;return a.map(S=>O(S)).filter(S=>!!S&&!f.has(S.code)&&!!f.add(S.code))},[a]),A=i.useCallback(f=>{const S=f.target.value,ce=O(S);ce&&(n==null||n(S,ce))},[n]),re=f=>{if(u)return`${d?f.symbol+" ":""}${f.code}`;const S=[];return d&&S.push(f.symbol),l&&S.push(f.code),S.push("—",f.name),S.join(" ")},N=`nice-currency-selector nice-currency-selector--${T} nice-currency-selector--label-${B}`+(u?" nice-currency-selector--compact":"")+(x?" nice-currency-selector--error":"")+(K?" nice-currency-selector--disabled":"")+(Z?` ${Z}`:""),C=B==="left"&&$!=null?{width:typeof $=="number"?`${$}px`:$,flex:"none"}:void 0,I=U!=null?{width:typeof U=="number"?`${U}px`:U,flex:"none"}:void 0;return c.jsxs("div",{ref:D,className:N,style:J,title:X,"data-testid":v,children:[m&&c.jsxs("label",{htmlFor:q,className:"nice-currency-selector__label",style:C,children:[m,b&&c.jsx("span",{className:"nice-currency-selector__required","aria-hidden":!0,children:"*"})]}),c.jsxs("div",{className:"nice-currency-selector__inner",style:I,children:[w&&c.jsx("input",{type:"search",className:"nice-currency-selector__search",placeholder:"Search currency…",value:Y,onChange:f=>L(f.target.value),disabled:K||Q,"aria-label":"Search currency"}),c.jsxs("select",{id:q,name:R,className:"nice-currency-selector__select",value:e??"",onChange:A,disabled:K||Q,required:b,"aria-invalid":!!x,"aria-label":z??(typeof m=="string"?m:"Currency"),children:[!e&&c.jsx("option",{value:"",children:P??"Select currency…"}),j.length>0&&c.jsx("optgroup",{label:"Recent",children:j.map(f=>c.jsx("option",{value:f.code,children:re(f)},`r-${f.code}`))}),c.jsx("optgroup",{label:j.length>0?"All":"",children:g.map(f=>c.jsx("option",{value:f.code,children:re(f)},f.code))})]})]}),(x||_)&&c.jsx("span",{className:x?"nice-currency-selector__error":"nice-currency-selector__helper",children:x??_})]})}),_e=i.forwardRef(function({value:e,onChange:n,currency:t,onCurrencyChange:a,currencies:s,hideCurrencySelector:l,min:d,max:u,step:o,locale:p,placeholder:h,label:y,helperText:m,error:_,size:x="md",disabled:b,readOnly:T,required:B,loading:$,accessMode:U,labelPlacement:Z="top",errorPlacement:J="bottom",labelWidth:E,controlWidth:R,submitOnEnter:X,onSubmit:v,showFormattedPreview:z=!0,showSteppers:P=!1,className:D,style:K,id:Q,name:k,title:q,"data-testid":Y,onBlur:L,onFocus:w},g){const j=b||U==="disabled"||$,A=T||U==="readOnly";if(U==="hidden")return null;const re=i.useId(),N=Q??`nice-money-${re}`,C=((e==null?void 0:e.currency)??t??"USD").toUpperCase(),I=O(C),f=(I==null?void 0:I.decimals)??2,S=o??1/Math.pow(10,f),[ce,se]=i.useState(()=>e?(e.amount/Math.pow(10,f)).toFixed(f):""),[xe,Ne]=i.useState(!1);i.useEffect(()=>{if(xe)return;if(e==null){se("");return}const M=O(e.currency),G=(M==null?void 0:M.decimals)??2;se((e.amount/Math.pow(10,G)).toFixed(G))},[e,xe]);const Ce=i.useCallback(M=>{const G=Re(M,C);if(!G){n==null||n(null);return}const ie=G.amount/Math.pow(10,f);if(d!=null&&ie<d){n==null||n(W(d,C));return}if(u!=null&&ie>u){n==null||n(W(u,C));return}n==null||n(G)},[C,f,d,u,n]),Ye=i.useCallback(M=>{const G=M.target.value;se(G),Ce(G)},[Ce]),ge=i.useCallback(M=>{const ie=(e?e.amount/Math.pow(10,f):0)+M,Qe=Math.min(u??1/0,Math.max(d??-1/0,ie));n==null||n(W(Qe,C))},[e,f,d,u,C,n]),we=i.useMemo(()=>e?V(e,{locale:p}):"",[e,p]),te=typeof _=="string"?_:void 0,Ge=`nice-money-input nice-money-input--${x} nice-money-input--label-${Z} nice-money-input--error-${J}`+(te?" nice-money-input--error":"")+(j?" nice-money-input--disabled":"")+($?" nice-money-input--loading":"")+(D?` ${D}`:""),Ve=M=>{X&&M.key==="Enter"&&v&&(M.preventDefault(),v())},Ze=Z==="left"&&E!=null?{width:typeof E=="number"?`${E}px`:E,flex:"none"}:void 0,Je=R!=null?{width:typeof R=="number"?`${R}px`:R,flex:"none"}:void 0;return c.jsxs("div",{ref:g,className:Ge,style:K,title:q,"data-testid":Y,children:[y&&c.jsxs("label",{htmlFor:N,className:"nice-money-input__label",style:Ze,children:[y,B&&c.jsx("span",{className:"nice-money-input__required","aria-hidden":!0,children:"*"})]}),c.jsxs("div",{className:"nice-money-input__row",style:Je,children:[!l&&c.jsx(be,{value:C,compact:!0,options:s?s.map(O).filter(M=>!!M):void 0,onChange:M=>a==null?void 0:a(M),disabled:j||A,className:"nice-money-input__currency","aria-label":"Currency"}),l&&c.jsx("span",{className:"nice-money-input__symbol","aria-hidden":!0,children:(I==null?void 0:I.symbol)??C}),P&&c.jsx("button",{type:"button",className:"nice-money-input__step nice-money-input__step--down",onClick:()=>ge(-S),disabled:j||A||d!=null&&e!=null&&e.amount/Math.pow(10,f)<=d,"aria-label":"Decrease amount",tabIndex:-1,children:"−"}),c.jsx("input",{id:N,name:k,type:"text",inputMode:"decimal",autoComplete:"transaction-amount",className:"nice-money-input__amount",value:ce,onChange:Ye,onKeyDown:Ve,onFocus:M=>{Ne(!0),w==null||w(M)},onBlur:M=>{Ne(!1),e&&se((e.amount/Math.pow(10,f)).toFixed(f)),L==null||L(M)},placeholder:h??`0${f>0?"."+"0".repeat(f):""}`,disabled:j,readOnly:A,required:B,"aria-invalid":!!te,"aria-describedby":te||m?`${N}-help`:void 0}),P&&c.jsx("button",{type:"button",className:"nice-money-input__step nice-money-input__step--up",onClick:()=>ge(S),disabled:j||A||u!=null&&e!=null&&e.amount/Math.pow(10,f)>=u,"aria-label":"Increase amount",tabIndex:-1,children:"+"}),$&&c.jsx("span",{className:"nice-money-input__spinner","aria-hidden":!0,children:"⟳"})]}),z&&we&&c.jsx("span",{className:"nice-money-input__preview","aria-live":"polite",children:we}),(te||m)&&c.jsx("span",{id:`${N}-help`,className:te?"nice-money-input__error":"nice-money-input__helper",children:te??m})]})}),fn={number:"",expiry:"",cvc:""},ze=i.forwardRef(function({value:e=fn,onChange:n,showHolderName:t=!0,requireHolderName:a,showPostalCode:s=!1,acceptedBrands:l,showBrandIcon:d=!0,size:u="md",disabled:o,readOnly:p,loading:h,accessMode:y,label:m,helperText:_,error:x,required:b,className:T,style:B,id:$,title:U,"data-testid":Z},J){if(y==="hidden")return null;const E=o||y==="disabled"||h,R=p||y==="readOnly",X=i.useId(),v=$??`nice-cc-${X}`,[z,P]=i.useState({number:!1,expiry:!1,cvc:!1,holder:!1,postal:!1}),D=i.useMemo(()=>ae(e.number),[e.number]),K=i.useMemo(()=>le(e,{requireHolder:a??t}),[e,a,t]),Q=!l||l.includes(D)||D==="unknown",k=i.useCallback(N=>{const C={...e,...N},I=le(C,{requireHolder:a??t});n==null||n(C,I)},[e,a,t,n]),q=i.useCallback(N=>{const C=N.target.value.replace(/\D/g,"").slice(0,19);k({number:C})},[k]),Y=i.useCallback(N=>{const C=N.target.value.replace(/\D/g,"").slice(0,4);let I=C;C.length>=3?I=`${C.slice(0,2)}/${C.slice(2)}`:C.length===2&&(I=`${C}/`),k({expiry:I})},[k]),L=i.useCallback(N=>{const C=N.target.value.replace(/\D/g,"").slice(0,ee(D));k({cvc:C})},[D,k]),w=i.useMemo(()=>$e(e.number,D),[e.number,D]),g=z.number&&e.number.length>0&&(ye(e.number)?Q?void 0:"Card brand not accepted":K.errors.number),j=z.expiry&&e.expiry.length>0&&!fe(e.expiry)?K.errors.expiry:void 0,A=z.cvc&&e.cvc.length>0&&e.cvc.length!==ee(D)?K.errors.cvc:void 0,re=`nice-credit-card nice-credit-card--${u}`+(E?" nice-credit-card--disabled":"")+(h?" nice-credit-card--loading":"")+(x?" nice-credit-card--error":"")+(T?` ${T}`:"");return c.jsxs("div",{ref:J,className:re,style:B,title:U,"data-testid":Z,children:[m&&c.jsxs("div",{className:"nice-credit-card__title",children:[m,b&&c.jsx("span",{className:"nice-credit-card__required","aria-hidden":!0,children:"*"})]}),c.jsx("div",{className:"nice-credit-card__row",children:c.jsxs("label",{className:"nice-credit-card__field nice-credit-card__field--number",children:[c.jsx("span",{className:"nice-credit-card__label",children:"Card number"}),c.jsxs("span",{className:"nice-credit-card__input-wrapper",children:[c.jsx("input",{id:`${v}-number`,type:"text",inputMode:"numeric",autoComplete:"cc-number",placeholder:D==="amex"?"3782 822463 10005":"1234 1234 1234 1234",value:w,onChange:q,onBlur:()=>P(N=>({...N,number:!0})),disabled:E,readOnly:R,"aria-invalid":!!g,"aria-describedby":g?`${v}-number-err`:void 0,className:"nice-credit-card__input",maxLength:D==="amex"?17:23}),d&&c.jsx(hn,{brand:D})]}),g&&c.jsx("span",{id:`${v}-number-err`,className:"nice-credit-card__error",children:g})]})}),c.jsxs("div",{className:"nice-credit-card__row nice-credit-card__row--split",children:[c.jsxs("label",{className:"nice-credit-card__field",children:[c.jsx("span",{className:"nice-credit-card__label",children:"Expiry"}),c.jsx("input",{id:`${v}-expiry`,type:"text",inputMode:"numeric",autoComplete:"cc-exp",placeholder:"MM/YY",value:e.expiry,onChange:Y,onBlur:()=>{P(C=>({...C,expiry:!0}));const N=pe(e.expiry);N&&N!==e.expiry&&k({expiry:N})},disabled:E,readOnly:R,"aria-invalid":!!j,"aria-describedby":j?`${v}-expiry-err`:void 0,className:"nice-credit-card__input",maxLength:5}),j&&c.jsx("span",{id:`${v}-expiry-err`,className:"nice-credit-card__error",children:j})]}),c.jsxs("label",{className:"nice-credit-card__field",children:[c.jsx("span",{className:"nice-credit-card__label",children:D==="amex"?"CID":"CVC"}),c.jsx("input",{id:`${v}-cvc`,type:"text",inputMode:"numeric",autoComplete:"cc-csc",placeholder:"•".repeat(ee(D)),value:e.cvc,onChange:L,onBlur:()=>P(N=>({...N,cvc:!0})),disabled:E,readOnly:R,"aria-invalid":!!A,"aria-describedby":A?`${v}-cvc-err`:void 0,className:"nice-credit-card__input",maxLength:ee(D)}),A&&c.jsx("span",{id:`${v}-cvc-err`,className:"nice-credit-card__error",children:A})]})]}),t&&c.jsx("div",{className:"nice-credit-card__row",children:c.jsxs("label",{className:"nice-credit-card__field",children:[c.jsx("span",{className:"nice-credit-card__label",children:"Cardholder name"}),c.jsx("input",{id:`${v}-holder`,type:"text",autoComplete:"cc-name",placeholder:"Jane Doe",value:e.holderName??"",onChange:N=>k({holderName:N.target.value}),onBlur:()=>P(N=>({...N,holder:!0})),disabled:E,readOnly:R,className:"nice-credit-card__input",maxLength:120})]})}),s&&c.jsx("div",{className:"nice-credit-card__row",children:c.jsxs("label",{className:"nice-credit-card__field",children:[c.jsx("span",{className:"nice-credit-card__label",children:"Postal code"}),c.jsx("input",{id:`${v}-postal`,type:"text",autoComplete:"postal-code",value:e.postalCode??"",onChange:N=>k({postalCode:N.target.value}),onBlur:()=>P(N=>({...N,postal:!0})),disabled:E,readOnly:R,className:"nice-credit-card__input",maxLength:16})]})}),(x||_)&&c.jsx("div",{className:x?"nice-credit-card__form-error":"nice-credit-card__helper",role:x?"alert":void 0,children:x??_})]})}),De={visa:"VISA",mastercard:"MasterCard",amex:"AMEX",discover:"Discover",diners:"Diners",jcb:"JCB",unionpay:"UnionPay",maestro:"Maestro",mir:"MIR",elo:"Elo",hipercard:"Hipercard",unknown:""};function hn({brand:r}){return r==="unknown"?null:c.jsx("span",{className:`nice-credit-card__brand nice-credit-card__brand--${r}`,"aria-label":De[r],children:De[r]})}const bn=i.forwardRef(function({processor:e,amount:n,editableAmount:t,customer:a,currencies:s,description:l,metadata:d,autoCapture:u=!0,submitLabel:o="Pay",onSuccess:p,onError:h,consents:y,className:m,style:_},x){const[b,T]=i.useState(n),[B,$]=i.useState(n.currency),[U,Z]=i.useState({number:"",expiry:"",cvc:""}),[J,E]=i.useState(null),[R,X]=i.useState(!1),[v,z]=i.useState(null),P=He(e),D=i.useMemo(()=>e.supportedCurrencies==="*"?!0:e.supportedCurrencies.includes(b.currency.toUpperCase()),[e,b.currency]),K=i.useMemo(()=>{var g;const w=(g=e.minimums)==null?void 0:g[b.currency.toUpperCase()];return w==null||b.amount>=w},[e,b]),Q=i.useMemo(()=>{var g;const w=(g=e.minimums)==null?void 0:g[b.currency.toUpperCase()];return w==null?null:{amount:w,currency:b.currency}},[e,b.currency]),k=!!(J!=null&&J.isValid),q=!R&&D&&K&&k,Y=i.useCallback(async w=>{if(w.preventDefault(),!!q){z(null),X(!0);try{const g={amount:b,card:U,customer:a,description:l,metadata:d,idempotencyKey:_n()},j=await P.authorize(g);if(u&&j.status==="authorized"){const A=await P.capture(j.id,b);p==null||p(A)}else p==null||p(j)}catch(g){const j=g instanceof Error?g:new Error(String(g));z(j.message),h==null||h(j)}finally{X(!1)}}},[q,b,U,a,l,d,u,P,p,h]),L=O(b.currency);return c.jsxs("form",{ref:x,className:"nice-payment-form"+(m?` ${m}`:""),style:_,onSubmit:Y,"aria-busy":R,children:[c.jsx("div",{className:"nice-payment-form__amount",children:t?c.jsx(_e,{label:"Amount",value:b,currency:B,currencies:s,onChange:w=>w&&T(w),onCurrencyChange:w=>{$(w),T(g=>({...g,currency:w}))},disabled:R,required:!0,showFormattedPreview:!0}):c.jsxs("div",{className:"nice-payment-form__total",children:[c.jsx("span",{className:"nice-payment-form__total-label",children:"Total"}),c.jsx(ue,{value:b})]})}),l&&c.jsx("p",{className:"nice-payment-form__description",children:l}),c.jsx("div",{className:"nice-payment-form__card",children:c.jsx(ze,{value:U,onChange:(w,g)=>{Z(w),E(g)},disabled:R})}),!D&&c.jsxs("div",{className:"nice-payment-form__warning",role:"alert",children:[e.name," does not accept ",(L==null?void 0:L.name)??b.currency,"."]}),!K&&Q&&c.jsxs("div",{className:"nice-payment-form__warning",role:"alert",children:["Minimum charge for ",e.name," is ",c.jsx(ue,{value:Q}),"."]}),y&&c.jsx("div",{className:"nice-payment-form__consents",children:y}),v&&c.jsx("div",{className:"nice-payment-form__error",role:"alert",children:v}),c.jsx("button",{type:"submit",className:"nice-payment-form__submit",disabled:!q,"aria-disabled":!q,children:R?"Processing…":o}),c.jsxs("p",{className:"nice-payment-form__processor",children:["Secured by ",c.jsx("strong",{children:e.name})]})]})});function _n(){return typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`idem_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`}const xn=i.forwardRef(function({price:e,originalPrice:n,period:t,prefix:a,suffix:s,showDiscountBadge:l=!0,size:d="md",locale:u,className:o,style:p},h){const y=n&&n.currency===e.currency&&n.amount>e.amount,m=i.useMemo(()=>!y||!n?null:Math.round((n.amount-e.amount)/n.amount*100),[y,n,e.amount]),_=`nice-price-tag nice-price-tag--${d}`+(o?` ${o}`:"");return c.jsxs("div",{ref:h,className:_,style:p,children:[a&&c.jsx("span",{className:"nice-price-tag__prefix",children:a}),c.jsxs("span",{className:"nice-price-tag__main",children:[c.jsx("span",{className:"nice-price-tag__amount",children:V(e,{locale:u})}),t&&c.jsx("span",{className:"nice-price-tag__period",children:t})]}),y&&n&&c.jsx("span",{className:"nice-price-tag__original","aria-label":"Original price",children:c.jsx("s",{children:V(n,{locale:u})})}),y&&l&&m!=null&&m>0&&c.jsxs("span",{className:"nice-price-tag__discount","aria-label":`${m} percent off`,children:["−",m,"%"]}),s&&c.jsx("span",{className:"nice-price-tag__suffix",children:s})]})}),Nn=i.forwardRef(function({source:e,onSourceChange:n,targetCurrency:t,onTargetCurrencyChange:a,provider:s,locale:l,showRateLine:d=!0,className:u,style:o},p){const{converted:h,loading:y,error:m}=oe(e,t,s),_=i.useMemo(()=>({amount:Math.pow(10,2),currency:e.currency}),[e.currency]),{converted:x}=oe(d?_:null,t,s);return c.jsxs("div",{ref:p,className:"nice-currency-converter"+(u?` ${u}`:""),style:o,children:[c.jsx("div",{className:"nice-currency-converter__row",children:c.jsx(_e,{label:"From",value:e,onChange:b=>b&&n(b),currency:e.currency,onCurrencyChange:b=>n({...e,currency:b}),showFormattedPreview:!1})}),c.jsxs("div",{className:"nice-currency-converter__row",children:[c.jsx("label",{className:"nice-currency-converter__label",children:"To"}),c.jsxs("div",{className:"nice-currency-converter__output",children:[c.jsx(be,{value:t,onChange:b=>a(b),compact:!0}),c.jsx("span",{className:"nice-currency-converter__amount",children:y?"…":m?"—":h?V(h,{locale:l}):""})]})]}),d&&x&&c.jsxs("p",{className:"nice-currency-converter__rate",children:["1 ",e.currency," = ",V(x,{locale:l})," ",c.jsxs("span",{className:"nice-currency-converter__inverse",children:["· 1 ",t," ="," ",V(W(1/de(x),e.currency),{locale:l})]})]}),m&&c.jsx("p",{className:"nice-currency-converter__error",role:"alert",children:m.message})]})});exports.ExchangeRateHostProvider=dn;exports.FrankfurterProvider=ln;exports.MockPaymentProcessor=Ee;exports.NICE_CURRENCY_CATALOG=ne;exports.NICE_CURRENCY_CODES=pn;exports.NICE_PAYMENT_PROCESSORS=mn;exports.NiceCreditCardInput=ze;exports.NiceCurrencyConverter=Nn;exports.NiceCurrencySelector=be;exports.NiceMoney=ue;exports.NiceMoneyInput=_e;exports.NicePaymentForm=bn;exports.NicePriceTag=xn;exports.OpenExchangeRatesProvider=un;exports.StaticExchangeRateProvider=on;exports.addMoney=Se;exports.compareMoney=rn;exports.convertMoney=Ue;exports.detectCardBrand=ae;exports.expectedCvcLength=ee;exports.findCurrency=O;exports.formatCardNumber=$e;exports.formatMoney=V;exports.fromMoney=de;exports.isExpiryValid=fe;exports.isNegative=an;exports.isZero=tn;exports.luhnCheck=ye;exports.makeAdyenAdapter=Ie;exports.makeBraintreeAdapter=Oe;exports.makeCoinbaseCommerceAdapter=Le;exports.makeKlarnaAdapter=qe;exports.makeMollieAdapter=Fe;exports.makePayPalAdapter=Pe;exports.makePayUAdapter=Te;exports.makePrzelewy24Adapter=Be;exports.makeRazorpayAdapter=Ke;exports.makeSquareAdapter=Ae;exports.makeStripeAdapter=ke;exports.maskCardNumber=sn;exports.multiplyMoney=ve;exports.negateMoney=cn;exports.normaliseExpiry=pe;exports.parseMoney=Re;exports.registerCurrency=en;exports.subtractMoney=Me;exports.toMoney=W;exports.useNiceExchangeRate=oe;exports.useNiceMoney=yn;exports.useNicePayment=He;exports.validateCreditCard=le;
1
+ "use strict";var xt=Object.defineProperty;var _t=(t,e,n)=>e in t?xt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var I=(t,e,n)=>_t(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react"),c=require("react/jsx-runtime"),ue=[{code:"USD",numeric:840,symbol:"$",name:"US Dollar",decimals:2,symbolFirst:!0},{code:"EUR",numeric:978,symbol:"€",name:"Euro",decimals:2,symbolFirst:!0},{code:"GBP",numeric:826,symbol:"£",name:"Pound Sterling",decimals:2,symbolFirst:!0},{code:"JPY",numeric:392,symbol:"¥",name:"Japanese Yen",decimals:0,symbolFirst:!0},{code:"CHF",numeric:756,symbol:"Fr",name:"Swiss Franc",decimals:2},{code:"CAD",numeric:124,symbol:"CA$",name:"Canadian Dollar",decimals:2,symbolFirst:!0},{code:"AUD",numeric:36,symbol:"A$",name:"Australian Dollar",decimals:2,symbolFirst:!0},{code:"NZD",numeric:554,symbol:"NZ$",name:"New Zealand Dollar",decimals:2,symbolFirst:!0},{code:"CNY",numeric:156,symbol:"¥",name:"Chinese Yuan Renminbi",decimals:2,symbolFirst:!0},{code:"HKD",numeric:344,symbol:"HK$",name:"Hong Kong Dollar",decimals:2,symbolFirst:!0},{code:"SGD",numeric:702,symbol:"S$",name:"Singapore Dollar",decimals:2,symbolFirst:!0},{code:"PLN",numeric:985,symbol:"zł",name:"Polish Złoty",decimals:2},{code:"CZK",numeric:203,symbol:"Kč",name:"Czech Koruna",decimals:2},{code:"HUF",numeric:348,symbol:"Ft",name:"Hungarian Forint",decimals:2},{code:"RON",numeric:946,symbol:"lei",name:"Romanian Leu",decimals:2},{code:"BGN",numeric:975,symbol:"лв",name:"Bulgarian Lev",decimals:2},{code:"HRK",numeric:191,symbol:"kn",name:"Croatian Kuna",decimals:2},{code:"DKK",numeric:208,symbol:"kr",name:"Danish Krone",decimals:2},{code:"SEK",numeric:752,symbol:"kr",name:"Swedish Krona",decimals:2},{code:"NOK",numeric:578,symbol:"kr",name:"Norwegian Krone",decimals:2},{code:"ISK",numeric:352,symbol:"kr",name:"Icelandic Króna",decimals:0},{code:"RUB",numeric:643,symbol:"₽",name:"Russian Ruble",decimals:2},{code:"UAH",numeric:980,symbol:"₴",name:"Ukrainian Hryvnia",decimals:2},{code:"TRY",numeric:949,symbol:"₺",name:"Turkish Lira",decimals:2,symbolFirst:!0},{code:"MXN",numeric:484,symbol:"Mex$",name:"Mexican Peso",decimals:2,symbolFirst:!0},{code:"BRL",numeric:986,symbol:"R$",name:"Brazilian Real",decimals:2,symbolFirst:!0},{code:"ARS",numeric:32,symbol:"AR$",name:"Argentine Peso",decimals:2,symbolFirst:!0},{code:"CLP",numeric:152,symbol:"CL$",name:"Chilean Peso",decimals:0,symbolFirst:!0},{code:"COP",numeric:170,symbol:"CO$",name:"Colombian Peso",decimals:2,symbolFirst:!0},{code:"PEN",numeric:604,symbol:"S/",name:"Peruvian Sol",decimals:2,symbolFirst:!0},{code:"UYU",numeric:858,symbol:"$U",name:"Uruguayan Peso",decimals:2,symbolFirst:!0},{code:"INR",numeric:356,symbol:"₹",name:"Indian Rupee",decimals:2,symbolFirst:!0},{code:"IDR",numeric:360,symbol:"Rp",name:"Indonesian Rupiah",decimals:2,symbolFirst:!0},{code:"KRW",numeric:410,symbol:"₩",name:"South Korean Won",decimals:0,symbolFirst:!0},{code:"MYR",numeric:458,symbol:"RM",name:"Malaysian Ringgit",decimals:2,symbolFirst:!0},{code:"PHP",numeric:608,symbol:"₱",name:"Philippine Peso",decimals:2,symbolFirst:!0},{code:"THB",numeric:764,symbol:"฿",name:"Thai Baht",decimals:2,symbolFirst:!0},{code:"VND",numeric:704,symbol:"₫",name:"Vietnamese Đồng",decimals:0},{code:"TWD",numeric:901,symbol:"NT$",name:"New Taiwan Dollar",decimals:2,symbolFirst:!0},{code:"PKR",numeric:586,symbol:"₨",name:"Pakistani Rupee",decimals:2},{code:"BDT",numeric:50,symbol:"৳",name:"Bangladeshi Taka",decimals:2},{code:"LKR",numeric:144,symbol:"Rs",name:"Sri Lankan Rupee",decimals:2},{code:"AED",numeric:784,symbol:"د.إ",name:"UAE Dirham",decimals:2},{code:"SAR",numeric:682,symbol:"ر.س",name:"Saudi Riyal",decimals:2},{code:"QAR",numeric:634,symbol:"ر.ق",name:"Qatari Riyal",decimals:2},{code:"KWD",numeric:414,symbol:"د.ك",name:"Kuwaiti Dinar",decimals:3},{code:"BHD",numeric:48,symbol:".د.ب",name:"Bahraini Dinar",decimals:3},{code:"OMR",numeric:512,symbol:"ر.ع",name:"Omani Rial",decimals:3},{code:"JOD",numeric:400,symbol:"د.أ",name:"Jordanian Dinar",decimals:3},{code:"ILS",numeric:376,symbol:"₪",name:"Israeli New Shekel",decimals:2,symbolFirst:!0},{code:"EGP",numeric:818,symbol:"E£",name:"Egyptian Pound",decimals:2,symbolFirst:!0},{code:"ZAR",numeric:710,symbol:"R",name:"South African Rand",decimals:2,symbolFirst:!0},{code:"NGN",numeric:566,symbol:"₦",name:"Nigerian Naira",decimals:2,symbolFirst:!0},{code:"KES",numeric:404,symbol:"KSh",name:"Kenyan Shilling",decimals:2},{code:"GHS",numeric:936,symbol:"₵",name:"Ghanaian Cedi",decimals:2},{code:"MAD",numeric:504,symbol:"د.م.",name:"Moroccan Dirham",decimals:2},{code:"TND",numeric:788,symbol:"د.ت",name:"Tunisian Dinar",decimals:3},{code:"BTC",numeric:0,symbol:"₿",name:"Bitcoin",decimals:8,symbolFirst:!0},{code:"ETH",numeric:0,symbol:"Ξ",name:"Ether",decimals:8,symbolFirst:!0},{code:"USDC",numeric:0,symbol:"USDC",name:"USD Coin",decimals:6},{code:"USDT",numeric:0,symbol:"USDT",name:"Tether",decimals:6}],Oe=new Map(ue.map(t=>[t.code,t]));function H(t){return Oe.get(t.toUpperCase())}function Nt(t){Oe.set(t.code.toUpperCase(),t);const e=ue.findIndex(n=>n.code===t.code);e>=0?ue[e]=t:ue.push(t)}function X(t,e){const n=H(e),a=(n==null?void 0:n.decimals)??2,r=Math.pow(10,a);return{amount:(t<0?-1:1)*Math.round(Math.abs(t)*r),currency:e.toUpperCase()}}function we(t){const e=H(t.currency),n=(e==null?void 0:e.decimals)??2;return t.amount/Math.pow(10,n)}function gt(t,e){return t.currency.toUpperCase()===e.currency.toUpperCase()}function Ce(t,e,n){if(!gt(t,e))throw new Error(`Cannot ${n} different currencies: ${t.currency} vs ${e.currency}`)}function oe(t,e){return Ce(t,e,"add"),{amount:t.amount+e.amount,currency:t.currency}}function Ke(t,e){return Ce(t,e,"subtract"),{amount:t.amount-e.amount,currency:t.currency}}function he(t,e){return{amount:(t.amount*e<0?-1:1)*Math.round(Math.abs(t.amount*e)),currency:t.currency}}function wt(t,e){return Ce(t,e,"compare"),t.amount-e.amount}function Ct(t){return t.amount===0}function jt(t){return t.amount<0}function vt(t){return{amount:-t.amount,currency:t.currency}}function Q(t,e={}){const n=H(t.currency),a=e.decimals??(n==null?void 0:n.decimals)??2,r=t.amount/Math.pow(10,a);try{return new Intl.NumberFormat(e.locale,{style:"currency",currency:t.currency,minimumFractionDigits:a,maximumFractionDigits:a,currencyDisplay:e.currencyDisplay??"symbol"}).format(r)}catch{const s=(n==null?void 0:n.symbol)??t.currency,l=r.toFixed(a);return n!=null&&n.symbolFirst?`${s}${l}`:`${l} ${s}`}}function Te(t,e){if(!t)return null;let n=t.replace(/[^\d.,\-]/g,"").trim();if(!n||n==="-")return null;const a=n.startsWith("-");a&&(n=n.slice(1));const r=n.lastIndexOf("."),s=n.lastIndexOf(","),l=Math.max(r,s);let i,u="";l===-1?i=n:(i=n.slice(0,l).replace(/[.,]/g,""),u=n.slice(l+1).replace(/[.,]/g,""));const d=`${i}.${u||"0"}`,p=parseFloat(d);return Number.isFinite(p)?X(a?-p:p,e):null}function me(t){const e=(t||"").replace(/\D/g,"");return e?/^4/.test(e)?"visa":/^(5[1-5]|2(2[2-9]|[3-6]\d|7[01]|720))/.test(e)?"mastercard":/^3[47]/.test(e)?"amex":/^(6011|65|64[4-9]|622(12[6-9]|1[3-9]\d|[2-8]\d\d|9[01]\d|92[0-5]))/.test(e)?"discover":/^3(0[0-5]|[68])/.test(e)?"diners":/^35(2[89]|[3-8])/.test(e)?"jcb":/^62/.test(e)?"unionpay":/^(50|5[6-9]|6[0-9])/.test(e)?"maestro":/^(2200|2201|2202|2203|2204)/.test(e)?"mir":/^(4011|4312|4389|4514|4576|5041|5066|5067|509|6277|6362|6363|650|6516|6550)/.test(e)?"elo":/^(606282|3841)/.test(e)?"hipercard":"unknown":"unknown"}function je(t){const e=(t||"").replace(/\D/g,"");if(e.length<12||e.length>19)return!1;let n=0,a=!1;for(let r=e.length-1;r>=0;r--){let s=e.charCodeAt(r)-48;a&&(s*=2,s>9&&(s-=9)),n+=s,a=!a}return n%10===0}function Be(t,e){const n=(t||"").replace(/\D/g,""),a=e??me(n);return a==="amex"?[n.slice(0,4),n.slice(4,10),n.slice(10,15)].filter(Boolean).join(" "):a==="diners"?[n.slice(0,4),n.slice(4,10),n.slice(10,14)].filter(Boolean).join(" "):(n.match(/.{1,4}/g)??[]).join(" ").trim()}function Dt(t,e){const n=(t||"").replace(/\D/g,"");if(n.length<4)return n;const a=n.slice(-4),r="*".repeat(n.length-4)+a,s=e??me(n);return s==="amex"?[r.slice(0,4),r.slice(4,10),r.slice(10,15)].filter(Boolean).join(" "):s==="diners"?[r.slice(0,4),r.slice(4,10),r.slice(10,14)].filter(Boolean).join(" "):(r.match(/.{1,4}/g)??[]).join(" ").trim()}function ve(t){const e=(t||"").replace(/\D/g,"");if(e.length<3)return null;const n=e.slice(0,2),a=e.length>=4?e.slice(-2):e.slice(2,4),r=parseInt(n,10);return!Number.isFinite(r)||r<1||r>12?null:`${n}/${a}`}function De(t,e=new Date){const n=ve(t);if(!n)return!1;const[a,r]=n.split("/"),s=parseInt(a,10),l=2e3+parseInt(r,10);return new Date(l,s,0,23,59,59,999).getTime()>=e.getTime()}function le(t){return t==="amex"?4:3}function Ne(t,e={}){var d;const n={},a=me(t.number),r=je(t.number);r||(n.number="Invalid card number");const s=De(t.expiry,e.now);s||(n.expiry="Invalid or expired");const i=(t.cvc||"").replace(/\D/g,"").length===le(a);i||(n.cvc=`CVC must be ${le(a)} digits`);const u=!e.requireHolder||(((d=t.holderName)==null?void 0:d.trim().length)??0)>=2;return u||(n.holderName="Cardholder name required"),{brand:a,numberValid:r,expiryValid:s,cvcValid:i,holderValid:u,isValid:r&&s&&i&&u,errors:n}}class St{constructor(e){I(this,"id","static");this.rates=e}async getRate(e,n){const a=e.toUpperCase(),r=n.toUpperCase();if(a===r)return{base:a,quote:r,rate:1,asOf:new Date().toISOString()};const s=this.rates.find(d=>d.base===a&&d.quote===r);if(s)return s;const l=this.rates.find(d=>d.base===r&&d.quote===a);if(l)return{base:a,quote:r,rate:1/l.rate,asOf:l.asOf};const i=this.rates.find(d=>d.base===a&&d.quote==="USD")??this.rates.find(d=>d.base==="USD"&&d.quote===a),u=this.rates.find(d=>d.base==="USD"&&d.quote===r)??this.rates.find(d=>d.base===r&&d.quote==="USD");if(i&&u){const d=i.base==="USD"?1/i.rate:i.rate,p=u.base==="USD"?u.rate:1/u.rate;return{base:a,quote:r,rate:d*p,asOf:new Date().toISOString()}}throw new Error(`No FX rate for ${a}/${r}`)}}class xe{constructor(e={}){I(this,"cache",new Map);I(this,"fetchImpl");I(this,"ttl");this.fetchImpl=e.fetchImpl??fetch,this.ttl=e.cacheTtl??6e4}cacheKey(e,n){return`${this.id}:${e.toUpperCase()}/${n.toUpperCase()}`}getCached(e,n){const a=this.cacheKey(e,n),r=this.cache.get(a);return r&&r.expires>Date.now()?r.rate:(r&&this.cache.delete(a),null)}setCached(e){this.cache.set(this.cacheKey(e.base,e.quote),{expires:Date.now()+this.ttl,rate:e})}}class qe extends xe{constructor(n={}){super(n);I(this,"id","frankfurter")}async getRate(n,a){const r=n.toUpperCase(),s=a.toUpperCase();if(r===s)return{base:r,quote:s,rate:1,asOf:new Date().toISOString()};const l=this.getCached(r,s);if(l)return l;const i=`https://api.frankfurter.app/latest?from=${r}&to=${s}`,u=await this.fetchImpl(i);if(!u.ok)throw new Error(`Frankfurter HTTP ${u.status}`);const d=await u.json(),p=d.rates[s];if(p==null)throw new Error(`Frankfurter: no rate for ${r}/${s}`);const x={base:r,quote:s,rate:p,asOf:d.date};return this.setCached(x),x}}class Le extends xe{constructor(n,a={}){super(a);I(this,"id","openexchangerates");this.appId=n}async getRate(n,a){const r=n.toUpperCase(),s=a.toUpperCase();if(r===s)return{base:r,quote:s,rate:1,asOf:new Date().toISOString()};const l=this.getCached(r,s);if(l)return l;const i=`https://openexchangerates.org/api/latest.json?app_id=${this.appId}`,u=await this.fetchImpl(i);if(!u.ok)throw new Error(`OpenExchangeRates HTTP ${u.status}`);const d=await u.json(),p=d.rates[r],x=d.rates[s];if(p==null||x==null)throw new Error(`OpenExchangeRates: missing rate for ${r} or ${s}`);const y={base:r,quote:s,rate:x/p,asOf:new Date(d.timestamp*1e3).toISOString()};return this.setCached(y),y}}class He extends xe{constructor(n={}){super(n);I(this,"id","exchangerate.host")}async getRate(n,a){var y;const r=n.toUpperCase(),s=a.toUpperCase();if(r===s)return{base:r,quote:s,rate:1,asOf:new Date().toISOString()};const l=this.getCached(r,s);if(l)return l;const i=`https://api.exchangerate.host/convert?from=${r}&to=${s}`,u=await this.fetchImpl(i);if(!u.ok)throw new Error(`exchangerate.host HTTP ${u.status}`);const d=await u.json(),p=((y=d.info)==null?void 0:y.rate)??d.result,x={base:r,quote:s,rate:p,asOf:d.date};return this.setCached(x),x}}class ze extends xe{constructor(n={}){super(n);I(this,"id","nbp");I(this,"table");this.table=n.table??"A"}async getRate(n,a){const r=n.toUpperCase(),s=a.toUpperCase();if(r===s)return{base:r,quote:s,rate:1,asOf:new Date().toISOString()};const l=this.getCached(r,s);if(l)return l;const i=async x=>{var f;if(x==="PLN")return{rate:1,date:new Date().toISOString().slice(0,10)};const y=`https://api.nbp.pl/api/exchangerates/rates/${this.table}/${x}/?format=json`,m=await this.fetchImpl(y);if(!m.ok)return null;const b=(f=(await m.json()).rates)==null?void 0:f[0];return b?{rate:b.mid??b.ask??0,date:b.effectiveDate}:null},u=await i(r),d=await i(s);if(!u||!d||u.rate===0)throw new Error(`NBP: missing rate for ${r} or ${s}`);const p={base:r,quote:s,rate:u.rate/d.rate,asOf:u.date};return this.setCached(p),p}}class Ye extends qe{constructor(){super(...arguments);I(this,"id","ecb")}}class Ge extends He{constructor(){super(...arguments);I(this,"id","free-forex")}}const Mt=(t={})=>new ze(t),Rt=(t={})=>new Ye(t),kt=t=>new Le(t.apiKey,t),$t=(t={})=>new Ge(t);async function Ze(t,e,n){const a=e.toUpperCase();if(t.currency.toUpperCase()===a)return t;const r=H(t.currency),s=H(a),l=(r==null?void 0:r.decimals)??2,i=(s==null?void 0:s.decimals)??2,{rate:u}=await n.getRate(t.currency,a),p=t.amount/Math.pow(10,l)*u;return{currency:a,amount:Math.round(p*Math.pow(10,i))}}class Je{constructor(e={}){I(this,"id");I(this,"name");I(this,"supportedCurrencies");I(this,"minimums");I(this,"counter",0);this.id=e.id??"mock",this.name=e.name??"Mock Processor",this.supportedCurrencies=e.supportedCurrencies??"*"}newId(e){return this.counter+=1,`${e}_${Date.now().toString(36)}_${this.counter}`}async authorize(e){return{id:this.newId("auth"),status:"authorized",processor:this.id,amount:e.amount,raw:{mock:!0,request:e}}}async capture(e,n){return{id:e.replace("auth_","cap_"),status:"captured",processor:this.id,amount:n}}async cancel(e){return{id:e,status:"cancelled",processor:this.id}}async refund(e,n){return{id:e.replace(/^[a-z]+_/,"ref_"),status:"refunded",processor:this.id,amount:n}}}function B(t,e,n,a,r){const s=l=>{const i=a==null?void 0:a[l];return i||(async()=>{throw new Error(`[ui-money] ${e} adapter is not wired. Pass an \`executor.${String(l)}\` implementation that calls the ${e} SDK.`)})};return{id:t,name:e,supportedCurrencies:n,minimums:r,authorize:s("authorize"),capture:s("capture"),cancel:s("cancel"),refund:s("refund")}}function Xe(t){return B("stripe","Stripe","*",t,{USD:50,EUR:50,GBP:30,JPY:50,AUD:50,CAD:50,CHF:50,DKK:250,NOK:300,SEK:300,PLN:200})}function Qe(t){return B("paypal","PayPal",["USD","EUR","GBP","AUD","CAD","JPY","CHF","NZD","SEK","NOK","DKK","PLN","CZK","HUF","BRL","MXN","HKD","SGD","TWD","THB","PHP","ILS"],t)}function Ve(t){return B("adyen","Adyen","*",t)}function We(t){return B("square","Square",["USD","CAD","GBP","AUD","JPY","EUR"],t)}function et(t){return B("mollie","Mollie","*",t)}function tt(t){return B("braintree","Braintree","*",t)}function nt(t){return B("razorpay","Razorpay",["INR","USD","EUR","GBP","AED"],t)}function rt(t){return B("payu","PayU",["PLN","EUR","USD","CZK","HUF","RON","BGN","TRY"],t)}function at(t){return B("przelewy24","Przelewy24",["PLN","EUR"],t)}function ct(t={}){return B("tpay","Tpay",["PLN","EUR","USD","GBP"],t)}function st(t={}){return B("autopay","Autopay",["PLN","EUR","USD","GBP","CZK"],t)}function it(t={}){const{acquirer:e="native",...n}=t;return B(`blik:${e}`,`BLIK (${e})`,["PLN"],n)}function ot(t){return B("klarna","Klarna",["USD","EUR","GBP","SEK","NOK","DKK","CHF","AUD","CAD","NZD","PLN"],t)}function lt(t){return B("coinbase-commerce","Coinbase Commerce",["BTC","ETH","USDC","USDT","USD","EUR"],t)}const Pt={mock:()=>new Je,stripe:()=>Xe(),paypal:()=>Qe(),adyen:()=>Ve(),square:()=>We(),mollie:()=>et(),braintree:()=>tt(),razorpay:()=>nt(),payu:()=>rt(),przelewy24:()=>at(),tpay:()=>ct(),autopay:()=>st(),blik:()=>it(),klarna:()=>ot(),"coinbase-commerce":()=>lt()};function Ut(t,e){const n=o.useMemo(()=>"amount"in t?t:X(t.major,t.currency),[]),[a,r]=o.useState(n),s=o.useCallback(y=>r(m=>X(y,m.currency)),[]),l=o.useCallback(y=>{r(m=>({...m,currency:y.toUpperCase()}))},[]),i=o.useCallback(y=>r(m=>oe(m,y)),[]),u=o.useCallback(y=>r(m=>Ke(m,y)),[]),d=o.useCallback(y=>r(m=>he(m,y)),[]),p=o.useMemo(()=>Q(a,{locale:e}),[a,e]),x=o.useMemo(()=>we(a),[a]);return{money:a,setMoney:r,setMajor:s,setCurrency:l,add:i,subtract:u,scale:d,formatted:p,major:x}}function be(t,e,n){const[a,r]=o.useState(null),[s,l]=o.useState(null),[i,u]=o.useState(!1),d=o.useRef(0);return o.useEffect(()=>{if(!t){r(null);return}const p=++d.current;u(!0),l(null),Ze(t,e,n).then(x=>{d.current===p&&r(x)}).catch(x=>{d.current===p&&(l(x instanceof Error?x:new Error(String(x))),r(null))}).finally(()=>{d.current===p&&u(!1)})},[t==null?void 0:t.amount,t==null?void 0:t.currency,e,n]),{converted:a,loading:i,error:s}}function ut(t){const[e,n]=o.useState("idle"),[a,r]=o.useState(null),[s,l]=o.useState(null),i=o.useCallback(()=>{n("idle"),r(null),l(null)},[]),u=o.useCallback(async y=>{n("authorizing"),l(null);try{const m=await t.authorize(y);return r(m),n(m.status),m}catch(m){const h=m instanceof Error?m:new Error(String(m));throw l(h),n("failed"),h}},[t]),d=o.useCallback(async(y,m)=>{const h=y??(a==null?void 0:a.id);if(!h)throw new Error("No authorization id to capture");n("capturing");try{const b=await t.capture(h,m);return r(b),n(b.status),b}catch(b){const f=b instanceof Error?b:new Error(String(b));throw l(f),n("failed"),f}},[t,a==null?void 0:a.id]),p=o.useCallback(async y=>{const m=y??(a==null?void 0:a.id);if(!m)throw new Error("No payment id to cancel");const h=await t.cancel(m);return r(h),n(h.status),h},[t,a==null?void 0:a.id]),x=o.useCallback(async(y,m)=>{const h=y??(a==null?void 0:a.id);if(!h)throw new Error("No payment id to refund");const b=await t.refund(h,m);return r(b),n(b.status),b},[t,a==null?void 0:a.id]);return{status:e,response:a,error:s,authorize:u,capture:d,cancel:p,refund:x,reset:i}}const ge=o.forwardRef(function({value:e,amount:n,currency:a,locale:r,display:s="symbol",highlightNegative:l=!0,zeroPlaceholder:i,convertTo:u,exchangeProvider:d,className:p,style:x,"aria-label":y},m){const h=o.useMemo(()=>{if(e)return e;if(n!=null&&a){const N=H(a),C=(N==null?void 0:N.decimals)??2;return{amount:Math.round(n*Math.pow(10,C)),currency:a.toUpperCase()}}return null},[e,n,a]),b=o.useMemo(()=>h?h.amount===0&&i!=null?i:Q(h,{locale:r,currencyDisplay:s}):"",[h,r,s,i]),{converted:f}=be(u&&d?h:null,u??"",d);if(!h)return null;const _=h.amount<0,S="nice-money"+(l&&_?" nice-money--negative":"")+(p?` ${p}`:"");return c.jsxs("span",{ref:m,className:S,style:x,"aria-label":y,children:[c.jsx("span",{className:"nice-money__value",children:b}),f&&c.jsxs("span",{className:"nice-money__converted","aria-label":`Converted to ${f.currency}`,children:[" ≈ ",Q(f,{locale:r})]})]})}),At=ue.map(t=>t.code).sort(),Se=o.forwardRef(function({value:e,onChange:n,options:a=ue,recents:r=[],searchable:s,showCode:l=!0,showSymbol:i=!0,compact:u=!1,disabled:d,readOnly:p,loading:x,accessMode:y,label:m,helperText:h,error:b,required:f,size:_="md",labelPlacement:S="top",labelWidth:N,controlWidth:C,className:E,style:z,id:Y,name:R,title:K,"data-testid":W,"aria-label":U,placeholder:G},q){const $=y==="hidden",Z=d||y==="disabled"||x,ae=p||y==="readOnly",A=o.useId(),ce=Y??`nice-cs-${A}`,[T,M]=o.useState(""),k=s??a.length>8,F=o.useMemo(()=>{if(!T.trim())return a;const w=T.trim().toLowerCase();return a.filter(j=>j.code.toLowerCase().includes(w)||j.name.toLowerCase().includes(w)||j.symbol.toLowerCase().includes(w))},[a,T]),D=o.useMemo(()=>{const w=new Set;return r.map(j=>H(j)).filter(j=>!!j&&!w.has(j.code)&&!!w.add(j.code))},[r]),se=o.useCallback(w=>{const j=w.target.value,te=H(j);te&&(n==null||n(j,te))},[n]),V=w=>{if(u)return`${i?w.symbol+" ":""}${w.code}`;const j=[];return i&&j.push(w.symbol),l&&j.push(w.code),j.push("—",w.name),j.join(" ")},g=`nice-currency-selector nice-currency-selector--${_} nice-currency-selector--label-${S}`+(u?" nice-currency-selector--compact":"")+(b?" nice-currency-selector--error":"")+(Z?" nice-currency-selector--disabled":"")+(E?` ${E}`:""),P=S==="left"&&N!=null?{width:typeof N=="number"?`${N}px`:N,flex:"none"}:void 0,ee=C!=null?{width:typeof C=="number"?`${C}px`:C,flex:"none"}:void 0;return $?null:c.jsxs("div",{ref:q,className:g,style:z,title:K,"data-testid":W,children:[m&&c.jsxs("label",{htmlFor:ce,className:"nice-currency-selector__label",style:P,children:[m,f&&c.jsx("span",{className:"nice-currency-selector__required","aria-hidden":!0,children:"*"})]}),c.jsxs("div",{className:"nice-currency-selector__inner",style:ee,children:[k&&c.jsx("input",{type:"search",className:"nice-currency-selector__search",placeholder:"Search currency…",value:T,onChange:w=>M(w.target.value),disabled:Z||ae,"aria-label":"Search currency"}),c.jsxs("select",{id:ce,name:R,className:"nice-currency-selector__select",value:e??"",onChange:se,disabled:Z||ae,required:f,"aria-invalid":!!b,"aria-label":U??(typeof m=="string"?m:"Currency"),children:[!e&&c.jsx("option",{value:"",children:G??"Select currency…"}),D.length>0&&c.jsx("optgroup",{label:"Recent",children:D.map(w=>c.jsx("option",{value:w.code,children:V(w)},`r-${w.code}`))}),c.jsx("optgroup",{label:D.length>0?"All":"",children:F.map(w=>c.jsx("option",{value:w.code,children:V(w)},w.code))})]})]}),(b||h)&&c.jsx("span",{className:b?"nice-currency-selector__error":"nice-currency-selector__helper",children:b??h})]})}),Me=o.forwardRef(function({value:e,onChange:n,currency:a,onCurrencyChange:r,currencies:s,hideCurrencySelector:l,min:i,max:u,step:d,locale:p,placeholder:x,label:y,helperText:m,error:h,size:b="md",disabled:f,readOnly:_,required:S,loading:N,accessMode:C,labelPlacement:E="top",errorPlacement:z="bottom",labelWidth:Y,controlWidth:R,submitOnEnter:K,onSubmit:W,showFormattedPreview:U=!0,showSteppers:G=!1,className:q,style:$,id:Z,name:ae,title:A,"data-testid":ce,onBlur:T,onFocus:M,liveGrouping:k,multiplierShortcuts:F=!0,onValidationError:D},se){const V=f||C==="disabled"||N,g=_||C==="readOnly",P=C==="hidden",ee=o.useId(),w=Z??`nice-money-${ee}`,j=((e==null?void 0:e.currency)??a??"USD").toUpperCase(),te=H(j),L=(te==null?void 0:te.decimals)??2,Re=d??1/Math.pow(10,L),[_e,pe]=o.useState(()=>e?(e.amount/Math.pow(10,L)).toFixed(L):""),[ye,ke]=o.useState(!1);o.useEffect(()=>{if(ye)return;if(e==null){pe("");return}const v=H(e.currency),O=(v==null?void 0:v.decimals)??2;pe((e.amount/Math.pow(10,O)).toFixed(O))},[e,ye]);const $e=o.useCallback(v=>{let O=v;if(F){const re=v.trim().match(/^([+-]?\d+(?:[.,]\d+)?)\s*([kKmMbB])$/);if(re){const ie=re[2].toLowerCase()==="k"?1e3:re[2].toLowerCase()==="m"?1e6:1e9,Ee=Number(re[1].replace(",","."))*ie;if(!Number.isFinite(Ee)){D==null||D(new Error("overflow"));return}O=String(Ee)}}const J=Te(O,j);if(!J){n==null||n(null);return}if(!Number.isSafeInteger(J.amount)){D==null||D(new Error("overflow: amount exceeds Number.MAX_SAFE_INTEGER"));return}const ne=J.amount/Math.pow(10,L);if(i!=null&&ne<i){D==null||D(new Error(`min: ${i}`)),n==null||n(X(i,j));return}if(u!=null&&ne>u){D==null||D(new Error(`max: ${u}`)),n==null||n(X(u,j));return}n==null||n(J)},[j,L,i,u,n,F,D]),mt=o.useCallback(v=>{const O=v.target.value;pe(O),$e(O)},[$e]),Pe=o.useCallback(v=>{const J=(e?e.amount/Math.pow(10,L):0)+v,ne=Math.min(u??1/0,Math.max(i??-1/0,J));n==null||n(X(ne,j))},[e,L,i,u,j,n]),fe=o.useMemo(()=>{var v,O;try{const J=new Intl.NumberFormat(p).formatToParts(12345.6),ne=((v=J.find(ie=>ie.type==="group"))==null?void 0:v.value)??",",re=((O=J.find(ie=>ie.type==="decimal"))==null?void 0:O.value)??".";return{group:ne,decimal:re}}catch{return{group:",",decimal:"."}}},[p]),Ue=k??!!fe.group,pt=o.useMemo(()=>{if(!Ue||ye===!1)return _e;const v=fe.decimal,O=fe.group,J=_e.replace(new RegExp(`[${O.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}]`,"g"),""),[ne,re]=J.split(v);if(!ne)return J;const ie=ne.replace(/\B(?=(\d{3})+(?!\d))/g,O);return re!=null?`${ie}${v}${re}`:ie},[_e,ye,Ue,fe]),Ae=o.useMemo(()=>e?Q(e,{locale:p}):"",[e,p]),de=typeof h=="string"?h:void 0,yt=`nice-money-input nice-money-input--${b} nice-money-input--label-${E} nice-money-input--error-${z}`+(de?" nice-money-input--error":"")+(V?" nice-money-input--disabled":"")+(N?" nice-money-input--loading":"")+(q?` ${q}`:""),ft=v=>{K&&v.key==="Enter"&&W&&(v.preventDefault(),W())},ht=E==="left"&&Y!=null?{width:typeof Y=="number"?`${Y}px`:Y,flex:"none"}:void 0,bt=R!=null?{width:typeof R=="number"?`${R}px`:R,flex:"none"}:void 0;return P?null:c.jsxs("div",{ref:se,className:yt,style:$,title:A,"data-testid":ce,children:[y&&c.jsxs("label",{htmlFor:w,className:"nice-money-input__label",style:ht,children:[y,S&&c.jsx("span",{className:"nice-money-input__required","aria-hidden":!0,children:"*"})]}),c.jsxs("div",{className:"nice-money-input__row",style:bt,children:[!l&&c.jsx(Se,{value:j,compact:!0,options:s?s.map(H).filter(v=>!!v):void 0,onChange:v=>r==null?void 0:r(v),disabled:V||g,className:"nice-money-input__currency","aria-label":"Currency"}),l&&c.jsx("span",{className:"nice-money-input__symbol","aria-hidden":!0,children:(te==null?void 0:te.symbol)??j}),G&&c.jsx("button",{type:"button",className:"nice-money-input__step nice-money-input__step--down",onClick:()=>Pe(-Re),disabled:V||g||i!=null&&e!=null&&e.amount/Math.pow(10,L)<=i,"aria-label":"Decrease amount",tabIndex:-1,children:"−"}),c.jsx("input",{id:w,name:ae,type:"text",inputMode:"decimal",autoComplete:"transaction-amount",className:"nice-money-input__amount",value:pt,onChange:mt,onKeyDown:ft,onFocus:v=>{ke(!0),M==null||M(v)},onBlur:v=>{ke(!1),e&&pe((e.amount/Math.pow(10,L)).toFixed(L)),T==null||T(v)},placeholder:x??`0${L>0?"."+"0".repeat(L):""}`,disabled:V,readOnly:g,required:S,"aria-invalid":!!de,"aria-describedby":de||m?`${w}-help`:void 0}),G&&c.jsx("button",{type:"button",className:"nice-money-input__step nice-money-input__step--up",onClick:()=>Pe(Re),disabled:V||g||u!=null&&e!=null&&e.amount/Math.pow(10,L)>=u,"aria-label":"Increase amount",tabIndex:-1,children:"+"}),N&&c.jsx("span",{className:"nice-money-input__spinner","aria-hidden":!0,children:"⟳"})]}),U&&Ae&&c.jsx("span",{className:"nice-money-input__preview","aria-live":"polite",children:Ae}),(de||m)&&c.jsx("span",{id:`${w}-help`,className:de?"nice-money-input__error":"nice-money-input__helper",children:de??m})]})}),Et={number:"",expiry:"",cvc:""},dt=o.forwardRef(function({value:e=Et,onChange:n,showHolderName:a=!0,requireHolderName:r,showPostalCode:s=!1,acceptedBrands:l,showBrandIcon:i=!0,size:u="md",disabled:d,readOnly:p,loading:x,accessMode:y,label:m,helperText:h,error:b,required:f,className:_,style:S,id:N,title:C,"data-testid":E},z){const Y=y==="hidden",R=d||y==="disabled"||x,K=p||y==="readOnly",W=o.useId(),U=N??`nice-cc-${W}`,[G,q]=o.useState({number:!1,expiry:!1,cvc:!1,holder:!1,postal:!1}),$=o.useMemo(()=>me(e.number),[e.number]),Z=o.useMemo(()=>Ne(e,{requireHolder:r??a}),[e,r,a]),ae=!l||l.includes($)||$==="unknown",A=o.useCallback(g=>{const P={...e,...g},ee=Ne(P,{requireHolder:r??a});n==null||n(P,ee)},[e,r,a,n]),ce=o.useCallback(g=>{const P=g.target.value.replace(/\D/g,"").slice(0,19);A({number:P})},[A]),T=o.useCallback(g=>{const P=g.target.value.replace(/\D/g,"").slice(0,4);let ee=P;P.length>=3?ee=`${P.slice(0,2)}/${P.slice(2)}`:P.length===2&&(ee=`${P}/`),A({expiry:ee})},[A]),M=o.useCallback(g=>{const P=g.target.value.replace(/\D/g,"").slice(0,le($));A({cvc:P})},[$,A]),k=o.useMemo(()=>Be(e.number,$),[e.number,$]),F=G.number&&e.number.length>0&&(je(e.number)?ae?void 0:"Card brand not accepted":Z.errors.number),D=G.expiry&&e.expiry.length>0&&!De(e.expiry)?Z.errors.expiry:void 0,se=G.cvc&&e.cvc.length>0&&e.cvc.length!==le($)?Z.errors.cvc:void 0,V=`nice-credit-card nice-credit-card--${u}`+(R?" nice-credit-card--disabled":"")+(x?" nice-credit-card--loading":"")+(b?" nice-credit-card--error":"")+(_?` ${_}`:"");return Y?null:c.jsxs("div",{ref:z,className:V,style:S,title:C,"data-testid":E,children:[m&&c.jsxs("div",{className:"nice-credit-card__title",children:[m,f&&c.jsx("span",{className:"nice-credit-card__required","aria-hidden":!0,children:"*"})]}),c.jsx("div",{className:"nice-credit-card__row",children:c.jsxs("label",{className:"nice-credit-card__field nice-credit-card__field--number",children:[c.jsx("span",{className:"nice-credit-card__label",children:"Card number"}),c.jsxs("span",{className:"nice-credit-card__input-wrapper",children:[c.jsx("input",{id:`${U}-number`,type:"text",inputMode:"numeric",autoComplete:"cc-number",placeholder:$==="amex"?"3782 822463 10005":"1234 1234 1234 1234",value:k,onChange:ce,onBlur:()=>q(g=>({...g,number:!0})),disabled:R,readOnly:K,"aria-invalid":!!F,"aria-describedby":F?`${U}-number-err`:void 0,className:"nice-credit-card__input",maxLength:$==="amex"?17:23}),i&&c.jsx(It,{brand:$})]}),F&&c.jsx("span",{id:`${U}-number-err`,className:"nice-credit-card__error",children:F})]})}),c.jsxs("div",{className:"nice-credit-card__row nice-credit-card__row--split",children:[c.jsxs("label",{className:"nice-credit-card__field",children:[c.jsx("span",{className:"nice-credit-card__label",children:"Expiry"}),c.jsx("input",{id:`${U}-expiry`,type:"text",inputMode:"numeric",autoComplete:"cc-exp",placeholder:"MM/YY",value:e.expiry,onChange:T,onBlur:()=>{q(P=>({...P,expiry:!0}));const g=ve(e.expiry);g&&g!==e.expiry&&A({expiry:g})},disabled:R,readOnly:K,"aria-invalid":!!D,"aria-describedby":D?`${U}-expiry-err`:void 0,className:"nice-credit-card__input",maxLength:5}),D&&c.jsx("span",{id:`${U}-expiry-err`,className:"nice-credit-card__error",children:D})]}),c.jsxs("label",{className:"nice-credit-card__field",children:[c.jsx("span",{className:"nice-credit-card__label",children:$==="amex"?"CID":"CVC"}),c.jsx("input",{id:`${U}-cvc`,type:"text",inputMode:"numeric",autoComplete:"cc-csc",placeholder:"•".repeat(le($)),value:e.cvc,onChange:M,onBlur:()=>q(g=>({...g,cvc:!0})),disabled:R,readOnly:K,"aria-invalid":!!se,"aria-describedby":se?`${U}-cvc-err`:void 0,className:"nice-credit-card__input",maxLength:le($)}),se&&c.jsx("span",{id:`${U}-cvc-err`,className:"nice-credit-card__error",children:se})]})]}),a&&c.jsx("div",{className:"nice-credit-card__row",children:c.jsxs("label",{className:"nice-credit-card__field",children:[c.jsx("span",{className:"nice-credit-card__label",children:"Cardholder name"}),c.jsx("input",{id:`${U}-holder`,type:"text",autoComplete:"cc-name",placeholder:"Jane Doe",value:e.holderName??"",onChange:g=>A({holderName:g.target.value}),onBlur:()=>q(g=>({...g,holder:!0})),disabled:R,readOnly:K,className:"nice-credit-card__input",maxLength:120})]})}),s&&c.jsx("div",{className:"nice-credit-card__row",children:c.jsxs("label",{className:"nice-credit-card__field",children:[c.jsx("span",{className:"nice-credit-card__label",children:"Postal code"}),c.jsx("input",{id:`${U}-postal`,type:"text",autoComplete:"postal-code",value:e.postalCode??"",onChange:g=>A({postalCode:g.target.value}),onBlur:()=>q(g=>({...g,postal:!0})),disabled:R,readOnly:K,className:"nice-credit-card__input",maxLength:16})]})}),(b||h)&&c.jsx("div",{className:b?"nice-credit-card__form-error":"nice-credit-card__helper",role:b?"alert":void 0,children:b??h})]})}),Ie={visa:"VISA",mastercard:"MasterCard",amex:"AMEX",discover:"Discover",diners:"Diners",jcb:"JCB",unionpay:"UnionPay",maestro:"Maestro",mir:"MIR",elo:"Elo",hipercard:"Hipercard",unknown:""};function It({brand:t}){return t==="unknown"?null:c.jsx("span",{className:`nice-credit-card__brand nice-credit-card__brand--${t}`,"aria-label":Ie[t],children:Ie[t]})}const Ft=o.forwardRef(function({processor:e,amount:n,editableAmount:a,customer:r,currencies:s,description:l,metadata:i,autoCapture:u=!0,submitLabel:d="Pay",onSuccess:p,onError:x,consents:y,className:m,style:h},b){const[f,_]=o.useState(n),[S,N]=o.useState(n.currency),[C,E]=o.useState({number:"",expiry:"",cvc:""}),[z,Y]=o.useState(null),[R,K]=o.useState(!1),[W,U]=o.useState(null),G=ut(e),q=o.useMemo(()=>e.supportedCurrencies==="*"?!0:e.supportedCurrencies.includes(f.currency.toUpperCase()),[e,f.currency]),$=o.useMemo(()=>{var k;const M=(k=e.minimums)==null?void 0:k[f.currency.toUpperCase()];return M==null||f.amount>=M},[e,f]),Z=o.useMemo(()=>{var k;const M=(k=e.minimums)==null?void 0:k[f.currency.toUpperCase()];return M==null?null:{amount:M,currency:f.currency}},[e,f.currency]),ae=!!(z!=null&&z.isValid),A=!R&&q&&$&&ae,ce=o.useCallback(async M=>{if(M.preventDefault(),!!A){U(null),K(!0);try{const k={amount:f,card:C,customer:r,description:l,metadata:i,idempotencyKey:Ot()},F=await G.authorize(k);if(u&&F.status==="authorized"){const D=await G.capture(F.id,f);p==null||p(D)}else p==null||p(F)}catch(k){const F=k instanceof Error?k:new Error(String(k));U(F.message),x==null||x(F)}finally{K(!1)}}},[A,f,C,r,l,i,u,G,p,x]),T=H(f.currency);return c.jsxs("form",{ref:b,className:"nice-payment-form"+(m?` ${m}`:""),style:h,onSubmit:ce,"aria-busy":R,children:[c.jsx("div",{className:"nice-payment-form__amount",children:a?c.jsx(Me,{label:"Amount",value:f,currency:S,currencies:s,onChange:M=>M&&_(M),onCurrencyChange:M=>{N(M),_(k=>({...k,currency:M}))},disabled:R,required:!0,showFormattedPreview:!0}):c.jsxs("div",{className:"nice-payment-form__total",children:[c.jsx("span",{className:"nice-payment-form__total-label",children:"Total"}),c.jsx(ge,{value:f})]})}),l&&c.jsx("p",{className:"nice-payment-form__description",children:l}),c.jsx("div",{className:"nice-payment-form__card",children:c.jsx(dt,{value:C,onChange:(M,k)=>{E(M),Y(k)},disabled:R})}),!q&&c.jsxs("div",{className:"nice-payment-form__warning",role:"alert",children:[e.name," does not accept ",(T==null?void 0:T.name)??f.currency,"."]}),!$&&Z&&c.jsxs("div",{className:"nice-payment-form__warning",role:"alert",children:["Minimum charge for ",e.name," is ",c.jsx(ge,{value:Z}),"."]}),y&&c.jsx("div",{className:"nice-payment-form__consents",children:y}),W&&c.jsx("div",{className:"nice-payment-form__error",role:"alert",children:W}),c.jsx("button",{type:"submit",className:"nice-payment-form__submit",disabled:!A,"aria-disabled":!A,children:R?"Processing…":d}),c.jsxs("p",{className:"nice-payment-form__processor",children:["Secured by ",c.jsx("strong",{children:e.name})]})]})});function Ot(){return typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`idem_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`}const Kt=o.forwardRef(function({price:e,originalPrice:n,period:a,prefix:r,suffix:s,showDiscountBadge:l=!0,size:i="md",locale:u,className:d,style:p},x){const y=n&&n.currency===e.currency&&n.amount>e.amount,m=o.useMemo(()=>!y||!n?null:Math.round((n.amount-e.amount)/n.amount*100),[y,n,e.amount]),h=`nice-price-tag nice-price-tag--${i}`+(d?` ${d}`:"");return c.jsxs("div",{ref:x,className:h,style:p,children:[r&&c.jsx("span",{className:"nice-price-tag__prefix",children:r}),c.jsxs("span",{className:"nice-price-tag__main",children:[c.jsx("span",{className:"nice-price-tag__amount",children:Q(e,{locale:u})}),a&&c.jsx("span",{className:"nice-price-tag__period",children:a})]}),y&&n&&c.jsx("span",{className:"nice-price-tag__original","aria-label":"Original price",children:c.jsx("s",{children:Q(n,{locale:u})})}),y&&l&&m!=null&&m>0&&c.jsxs("span",{className:"nice-price-tag__discount","aria-label":`${m} percent off`,children:["−",m,"%"]}),s&&c.jsx("span",{className:"nice-price-tag__suffix",children:s})]})}),Tt=o.forwardRef(function({source:e,onSourceChange:n,targetCurrency:a,onTargetCurrencyChange:r,provider:s,locale:l,showRateLine:i=!0,className:u,style:d},p){const{converted:x,loading:y,error:m}=be(e,a,s),h=o.useMemo(()=>({amount:Math.pow(10,2),currency:e.currency}),[e.currency]),{converted:b}=be(i?h:null,a,s);return c.jsxs("div",{ref:p,className:"nice-currency-converter"+(u?` ${u}`:""),style:d,children:[c.jsx("div",{className:"nice-currency-converter__row",children:c.jsx(Me,{label:"From",value:e,onChange:f=>f&&n(f),currency:e.currency,onCurrencyChange:f=>n({...e,currency:f}),showFormattedPreview:!1})}),c.jsxs("div",{className:"nice-currency-converter__row",children:[c.jsx("label",{className:"nice-currency-converter__label",children:"To"}),c.jsxs("div",{className:"nice-currency-converter__output",children:[c.jsx(Se,{value:a,onChange:f=>r(f),compact:!0}),c.jsx("span",{className:"nice-currency-converter__amount",children:y?"…":m?"—":x?Q(x,{locale:l}):""})]})]}),i&&b&&c.jsxs("p",{className:"nice-currency-converter__rate",children:["1 ",e.currency," = ",Q(b,{locale:l})," ",c.jsxs("span",{className:"nice-currency-converter__inverse",children:["· 1 ",a," ="," ",Q(X(1/we(b),e.currency),{locale:l})]})]}),m&&c.jsx("p",{className:"nice-currency-converter__error",role:"alert",children:m.message})]})});function Fe(t){return{amount:Math.round(t.amount),currency:t.currency}}const Bt=o.forwardRef(function({lines:e,locale:n,rounding:a="line",showTotals:r=!0,showGrandTotal:s=!0,hideRateColumn:l=!1,labels:i,density:u="comfortable",className:d,style:p,id:x},y){const m={label:(i==null?void 0:i.label)??"Item",rate:(i==null?void 0:i.rate)??"VAT",net:(i==null?void 0:i.net)??"Net",vat:(i==null?void 0:i.vat)??"Tax",gross:(i==null?void 0:i.gross)??"Gross",total:(i==null?void 0:i.total)??"Total"},h=o.useMemo(()=>{if(a==="total"){const _=new Map;for(const N of e){let C=_.get(N.vatRate);C||(C=[],_.set(N.vatRate,C)),C.push(N.netAmount)}const S=[];for(const[N,C]of _){const E=C.reduce((R,K)=>oe(R,K),X(0,C[0].currency)),z=Fe(he(E,N)),Y=oe(E,z);S.push({rate:N,net:E,vat:z,gross:Y})}return S}return e.map(_=>{const S=Fe(he(_.netAmount,_.vatRate)),N=oe(_.netAmount,S);return{label:_.label,rate:_.vatRate,net:_.netAmount,vat:S,gross:N}})},[e,a]),b=o.useMemo(()=>{if(h.length===0)return null;const _=h[0].net.currency;let S=X(0,_),N=X(0,_),C=X(0,_);for(const E of h)S=oe(S,E.net),N=oe(N,E.vat),C=oe(C,E.gross);return{net:S,vat:N,gross:C}},[h]),f=_=>Q(_,{locale:n});return c.jsxs("table",{ref:y,id:x,className:`nice-tax-breakdown nice-tax-breakdown--${u} ${d??""}`,style:p,role:"table","aria-label":m.total,children:[c.jsx("thead",{children:c.jsxs("tr",{children:[h.some(_=>_.label!==void 0)&&c.jsx("th",{scope:"col",children:m.label}),!l&&c.jsx("th",{scope:"col",className:"nice-tax-breakdown__rate",children:m.rate}),c.jsx("th",{scope:"col",className:"nice-tax-breakdown__num",children:m.net}),c.jsx("th",{scope:"col",className:"nice-tax-breakdown__num",children:m.vat}),c.jsx("th",{scope:"col",className:"nice-tax-breakdown__num",children:m.gross})]})}),c.jsx("tbody",{children:h.map((_,S)=>c.jsxs("tr",{children:[h.some(N=>N.label!==void 0)&&c.jsx("td",{children:_.label??""}),!l&&c.jsxs("td",{className:"nice-tax-breakdown__rate",children:[(_.rate*100).toLocaleString(n,{maximumFractionDigits:2}),"%"]}),c.jsx("td",{className:"nice-tax-breakdown__num",children:f(_.net)}),c.jsx("td",{className:"nice-tax-breakdown__num",children:f(_.vat)}),c.jsx("td",{className:"nice-tax-breakdown__num",children:f(_.gross)})]},`${_.rate}-${S}`))}),r&&b&&c.jsx("tfoot",{children:s&&c.jsxs("tr",{className:"nice-tax-breakdown__totals",children:[h.some(_=>_.label!==void 0)&&c.jsx("td",{children:m.total}),!l&&c.jsx("td",{}),c.jsx("td",{className:"nice-tax-breakdown__num",children:f(b.net)}),c.jsx("td",{className:"nice-tax-breakdown__num",children:f(b.vat)}),c.jsx("td",{className:"nice-tax-breakdown__num",children:f(b.gross)})]})})]})});exports.EcbRatesProvider=Ye;exports.ExchangeRateHostProvider=He;exports.FrankfurterProvider=qe;exports.FreeForexApiProvider=Ge;exports.MockPaymentProcessor=Je;exports.NICE_CURRENCY_CATALOG=ue;exports.NICE_CURRENCY_CODES=At;exports.NICE_PAYMENT_PROCESSORS=Pt;exports.NbpRatesProvider=ze;exports.NiceCreditCardInput=dt;exports.NiceCurrencyConverter=Tt;exports.NiceCurrencySelector=Se;exports.NiceMoney=ge;exports.NiceMoneyInput=Me;exports.NicePaymentForm=Ft;exports.NicePriceTag=Kt;exports.NiceTaxBreakdown=Bt;exports.OpenExchangeRatesProvider=Le;exports.StaticExchangeRateProvider=St;exports.addMoney=oe;exports.compareMoney=wt;exports.convertMoney=Ze;exports.createEcbRatesProvider=Rt;exports.createFreeForexApiProvider=$t;exports.createNbpRatesProvider=Mt;exports.createOpenExchangeRatesProvider=kt;exports.detectCardBrand=me;exports.expectedCvcLength=le;exports.findCurrency=H;exports.formatCardNumber=Be;exports.formatMoney=Q;exports.fromMoney=we;exports.isExpiryValid=De;exports.isNegative=jt;exports.isZero=Ct;exports.luhnCheck=je;exports.makeAdyenAdapter=Ve;exports.makeAutopayAdapter=st;exports.makeBlikAdapter=it;exports.makeBraintreeAdapter=tt;exports.makeCoinbaseCommerceAdapter=lt;exports.makeKlarnaAdapter=ot;exports.makeMollieAdapter=et;exports.makePayPalAdapter=Qe;exports.makePayUAdapter=rt;exports.makePrzelewy24Adapter=at;exports.makeRazorpayAdapter=nt;exports.makeSquareAdapter=We;exports.makeStripeAdapter=Xe;exports.makeTpayAdapter=ct;exports.maskCardNumber=Dt;exports.multiplyMoney=he;exports.negateMoney=vt;exports.normaliseExpiry=ve;exports.parseMoney=Te;exports.registerCurrency=Nt;exports.subtractMoney=Ke;exports.toMoney=X;exports.useNiceExchangeRate=be;exports.useNiceMoney=Ut;exports.useNicePayment=ut;exports.validateCreditCard=Ne;
package/dist/index.d.ts CHANGED
@@ -3,9 +3,9 @@ export type { Money, CurrencyDef, CardBrand, CreditCardData, CreditCardValidatio
3
3
  export { NICE_CURRENCY_CATALOG, findCurrency, registerCurrency } from './catalog';
4
4
  export { toMoney, fromMoney, addMoney, subtractMoney, multiplyMoney, compareMoney, isZero, isNegative, negateMoney, formatMoney, parseMoney, } from './money';
5
5
  export { detectCardBrand, luhnCheck, formatCardNumber, maskCardNumber, normaliseExpiry, isExpiryValid, expectedCvcLength, validateCreditCard, } from './creditCard';
6
- export { StaticExchangeRateProvider, FrankfurterProvider, OpenExchangeRatesProvider, ExchangeRateHostProvider, convertMoney, } from './exchange';
6
+ export { StaticExchangeRateProvider, FrankfurterProvider, OpenExchangeRatesProvider, ExchangeRateHostProvider, NbpRatesProvider, EcbRatesProvider, FreeForexApiProvider, createNbpRatesProvider, createEcbRatesProvider, createOpenExchangeRatesProvider, createFreeForexApiProvider, convertMoney, } from './exchange';
7
7
  export type { ExchangeRateProvider } from './exchange';
8
- export { MockPaymentProcessor, makeStripeAdapter, makePayPalAdapter, makeAdyenAdapter, makeSquareAdapter, makeMollieAdapter, makeBraintreeAdapter, makeRazorpayAdapter, makePayUAdapter, makePrzelewy24Adapter, makeKlarnaAdapter, makeCoinbaseCommerceAdapter, NICE_PAYMENT_PROCESSORS, } from './processors';
8
+ export { MockPaymentProcessor, makeStripeAdapter, makePayPalAdapter, makeAdyenAdapter, makeSquareAdapter, makeMollieAdapter, makeBraintreeAdapter, makeRazorpayAdapter, makePayUAdapter, makePrzelewy24Adapter, makeTpayAdapter, makeAutopayAdapter, makeBlikAdapter, makeKlarnaAdapter, makeCoinbaseCommerceAdapter, NICE_PAYMENT_PROCESSORS, } from './processors';
9
9
  export type { PaymentProcessor, ProcessorExecutor } from './processors';
10
10
  export { useNiceMoney, useNiceExchangeRate, useNicePayment } from './hooks';
11
11
  export { NiceMoney, NICE_CURRENCY_CODES } from './components/NiceMoney';
@@ -22,3 +22,5 @@ export { NicePriceTag } from './components/NicePriceTag';
22
22
  export type { NicePriceTagProps } from './components/NicePriceTag';
23
23
  export { NiceCurrencyConverter } from './components/NiceCurrencyConverter';
24
24
  export type { NiceCurrencyConverterProps } from './components/NiceCurrencyConverter';
25
+ export { NiceTaxBreakdown } from './components/NiceTaxBreakdown';
26
+ export type { NiceTaxBreakdownProps, NiceTaxBreakdownLine } from './components/NiceTaxBreakdown';