@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.
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
- var Oe = Object.defineProperty;
2
- var ke = (r, e, n) => e in r ? Oe(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
3
- var T = (r, e, n) => ke(r, typeof e != "symbol" ? e + "" : e, n);
4
- import Be, { useState as E, useRef as Te, useEffect as qe, useMemo as P, useCallback as R, forwardRef as te, useId as ye } from "react";
5
- import { jsxs as N, jsx as i } from "react/jsx-runtime";
6
- const se = [
1
+ var Xe = Object.defineProperty;
2
+ var Qe = (t, e, n) => e in t ? Xe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var K = (t, e, n) => Qe(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import Ve, { useState as B, useRef as We, useEffect as et, useMemo as k, useCallback as F, forwardRef as de, useId as Ce } from "react";
5
+ import { jsxs as N, jsx as s } from "react/jsx-runtime";
6
+ const fe = [
7
7
  // ── Majors ─────────────────────────────────────
8
8
  { code: "USD", numeric: 840, symbol: "$", name: "US Dollar", decimals: 2, symbolFirst: !0 },
9
9
  { code: "EUR", numeric: 978, symbol: "€", name: "Euro", decimals: 2, symbolFirst: !0 },
@@ -225,186 +225,186 @@ const se = [
225
225
  { code: "ETH", numeric: 0, symbol: "Ξ", name: "Ether", decimals: 8, symbolFirst: !0 },
226
226
  { code: "USDC", numeric: 0, symbol: "USDC", name: "USD Coin", decimals: 6 },
227
227
  { code: "USDT", numeric: 0, symbol: "USDT", name: "Tether", decimals: 6 }
228
- ], ve = new Map(se.map((r) => [r.code, r]));
229
- function L(r) {
230
- return ve.get(r.toUpperCase());
228
+ ], Oe = new Map(fe.map((t) => [t.code, t]));
229
+ function V(t) {
230
+ return Oe.get(t.toUpperCase());
231
231
  }
232
- function fn(r) {
233
- ve.set(r.code.toUpperCase(), r);
234
- const e = se.findIndex((n) => n.code === r.code);
235
- e >= 0 ? se[e] = r : se.push(r);
232
+ function Et(t) {
233
+ Oe.set(t.code.toUpperCase(), t);
234
+ const e = fe.findIndex((n) => n.code === t.code);
235
+ e >= 0 ? fe[e] = t : fe.push(t);
236
236
  }
237
- function re(r, e) {
238
- const n = L(e), t = (n == null ? void 0 : n.decimals) ?? 2, c = Math.pow(10, t);
239
- return { amount: (r < 0 ? -1 : 1) * Math.round(Math.abs(r) * c), currency: e.toUpperCase() };
237
+ function W(t, e) {
238
+ const n = V(e), c = (n == null ? void 0 : n.decimals) ?? 2, r = Math.pow(10, c);
239
+ return { amount: (t < 0 ? -1 : 1) * Math.round(Math.abs(t) * r), currency: e.toUpperCase() };
240
240
  }
241
- function $e(r) {
242
- const e = L(r.currency), n = (e == null ? void 0 : e.decimals) ?? 2;
243
- return r.amount / Math.pow(10, n);
241
+ function Ke(t) {
242
+ const e = V(t.currency), n = (e == null ? void 0 : e.decimals) ?? 2;
243
+ return t.amount / Math.pow(10, n);
244
244
  }
245
- function Le(r, e) {
246
- return r.currency.toUpperCase() === e.currency.toUpperCase();
245
+ function tt(t, e) {
246
+ return t.currency.toUpperCase() === e.currency.toUpperCase();
247
247
  }
248
- function pe(r, e, n) {
249
- if (!Le(r, e))
250
- throw new Error(`Cannot ${n} different currencies: ${r.currency} vs ${e.currency}`);
248
+ function $e(t, e, n) {
249
+ if (!tt(t, e))
250
+ throw new Error(`Cannot ${n} different currencies: ${t.currency} vs ${e.currency}`);
251
251
  }
252
- function He(r, e) {
253
- return pe(r, e, "add"), { amount: r.amount + e.amount, currency: r.currency };
252
+ function me(t, e) {
253
+ return $e(t, e, "add"), { amount: t.amount + e.amount, currency: t.currency };
254
254
  }
255
- function je(r, e) {
256
- return pe(r, e, "subtract"), { amount: r.amount - e.amount, currency: r.currency };
255
+ function nt(t, e) {
256
+ return $e(t, e, "subtract"), { amount: t.amount - e.amount, currency: t.currency };
257
257
  }
258
- function ze(r, e) {
258
+ function De(t, e) {
259
259
  return {
260
- amount: (r.amount * e < 0 ? -1 : 1) * Math.round(Math.abs(r.amount * e)),
261
- currency: r.currency
260
+ amount: (t.amount * e < 0 ? -1 : 1) * Math.round(Math.abs(t.amount * e)),
261
+ currency: t.currency
262
262
  };
263
263
  }
264
- function bn(r, e) {
265
- return pe(r, e, "compare"), r.amount - e.amount;
264
+ function At(t, e) {
265
+ return $e(t, e, "compare"), t.amount - e.amount;
266
266
  }
267
- function _n(r) {
268
- return r.amount === 0;
267
+ function Ot(t) {
268
+ return t.amount === 0;
269
269
  }
270
- function Nn(r) {
271
- return r.amount < 0;
270
+ function Kt(t) {
271
+ return t.amount < 0;
272
272
  }
273
- function gn(r) {
274
- return { amount: -r.amount, currency: r.currency };
273
+ function Bt(t) {
274
+ return { amount: -t.amount, currency: t.currency };
275
275
  }
276
- function ee(r, e = {}) {
277
- const n = L(r.currency), t = e.decimals ?? (n == null ? void 0 : n.decimals) ?? 2, c = r.amount / Math.pow(10, t);
276
+ function te(t, e = {}) {
277
+ const n = V(t.currency), c = e.decimals ?? (n == null ? void 0 : n.decimals) ?? 2, r = t.amount / Math.pow(10, c);
278
278
  try {
279
279
  return new Intl.NumberFormat(e.locale, {
280
280
  style: "currency",
281
- currency: r.currency,
282
- minimumFractionDigits: t,
283
- maximumFractionDigits: t,
281
+ currency: t.currency,
282
+ minimumFractionDigits: c,
283
+ maximumFractionDigits: c,
284
284
  currencyDisplay: e.currencyDisplay ?? "symbol"
285
- }).format(c);
285
+ }).format(r);
286
286
  } catch {
287
- const a = (n == null ? void 0 : n.symbol) ?? r.currency, o = c.toFixed(t);
287
+ const a = (n == null ? void 0 : n.symbol) ?? t.currency, o = r.toFixed(c);
288
288
  return n != null && n.symbolFirst ? `${a}${o}` : `${o} ${a}`;
289
289
  }
290
290
  }
291
- function Ye(r, e) {
292
- if (!r)
291
+ function rt(t, e) {
292
+ if (!t)
293
293
  return null;
294
- let n = r.replace(/[^\d.,\-]/g, "").trim();
294
+ let n = t.replace(/[^\d.,\-]/g, "").trim();
295
295
  if (!n || n === "-")
296
296
  return null;
297
- const t = n.startsWith("-");
298
- t && (n = n.slice(1));
299
- const c = n.lastIndexOf("."), a = n.lastIndexOf(","), o = Math.max(c, a);
300
- let u, l = "";
301
- o === -1 ? u = n : (u = n.slice(0, o).replace(/[.,]/g, ""), l = n.slice(o + 1).replace(/[.,]/g, ""));
302
- const s = `${u}.${l || "0"}`, y = parseFloat(s);
303
- return Number.isFinite(y) ? re(t ? -y : y, e) : null;
297
+ const c = n.startsWith("-");
298
+ c && (n = n.slice(1));
299
+ const r = n.lastIndexOf("."), a = n.lastIndexOf(","), o = Math.max(r, a);
300
+ let i, l = "";
301
+ o === -1 ? i = n : (i = n.slice(0, o).replace(/[.,]/g, ""), l = n.slice(o + 1).replace(/[.,]/g, ""));
302
+ const u = `${i}.${l || "0"}`, m = parseFloat(u);
303
+ return Number.isFinite(m) ? W(c ? -m : m, e) : null;
304
304
  }
305
- function de(r) {
306
- const e = (r || "").replace(/\D/g, "");
305
+ function Ne(t) {
306
+ const e = (t || "").replace(/\D/g, "");
307
307
  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";
308
308
  }
309
- function Se(r) {
310
- const e = (r || "").replace(/\D/g, "");
309
+ function Be(t) {
310
+ const e = (t || "").replace(/\D/g, "");
311
311
  if (e.length < 12 || e.length > 19)
312
312
  return !1;
313
- let n = 0, t = !1;
314
- for (let c = e.length - 1; c >= 0; c--) {
315
- let a = e.charCodeAt(c) - 48;
316
- t && (a *= 2, a > 9 && (a -= 9)), n += a, t = !t;
313
+ let n = 0, c = !1;
314
+ for (let r = e.length - 1; r >= 0; r--) {
315
+ let a = e.charCodeAt(r) - 48;
316
+ c && (a *= 2, a > 9 && (a -= 9)), n += a, c = !c;
317
317
  }
318
318
  return n % 10 === 0;
319
319
  }
320
- function Ge(r, e) {
321
- const n = (r || "").replace(/\D/g, ""), t = e ?? de(n);
322
- 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();
320
+ function ct(t, e) {
321
+ const n = (t || "").replace(/\D/g, ""), c = e ?? Ne(n);
322
+ return c === "amex" ? [n.slice(0, 4), n.slice(4, 10), n.slice(10, 15)].filter(Boolean).join(" ") : c === "diners" ? [n.slice(0, 4), n.slice(4, 10), n.slice(10, 14)].filter(Boolean).join(" ") : (n.match(/.{1,4}/g) ?? []).join(" ").trim();
323
323
  }
324
- function wn(r, e) {
325
- const n = (r || "").replace(/\D/g, "");
324
+ function Tt(t, e) {
325
+ const n = (t || "").replace(/\D/g, "");
326
326
  if (n.length < 4)
327
327
  return n;
328
- const t = n.slice(-4), c = "*".repeat(n.length - 4) + t, a = e ?? de(n);
329
- return a === "amex" ? [c.slice(0, 4), c.slice(4, 10), c.slice(10, 15)].filter(Boolean).join(" ") : a === "diners" ? [c.slice(0, 4), c.slice(4, 10), c.slice(10, 14)].filter(Boolean).join(" ") : (c.match(/.{1,4}/g) ?? []).join(" ").trim();
328
+ const c = n.slice(-4), r = "*".repeat(n.length - 4) + c, a = e ?? Ne(n);
329
+ return a === "amex" ? [r.slice(0, 4), r.slice(4, 10), r.slice(10, 15)].filter(Boolean).join(" ") : a === "diners" ? [r.slice(0, 4), r.slice(4, 10), r.slice(10, 14)].filter(Boolean).join(" ") : (r.match(/.{1,4}/g) ?? []).join(" ").trim();
330
330
  }
331
- function Ue(r) {
332
- const e = (r || "").replace(/\D/g, "");
331
+ function Te(t) {
332
+ const e = (t || "").replace(/\D/g, "");
333
333
  if (e.length < 3)
334
334
  return null;
335
- const n = e.slice(0, 2), t = e.length >= 4 ? e.slice(-2) : e.slice(2, 4), c = parseInt(n, 10);
336
- return !Number.isFinite(c) || c < 1 || c > 12 ? null : `${n}/${t}`;
335
+ const n = e.slice(0, 2), c = e.length >= 4 ? e.slice(-2) : e.slice(2, 4), r = parseInt(n, 10);
336
+ return !Number.isFinite(r) || r < 1 || r > 12 ? null : `${n}/${c}`;
337
337
  }
338
- function xe(r, e = /* @__PURE__ */ new Date()) {
339
- const n = Ue(r);
338
+ function Le(t, e = /* @__PURE__ */ new Date()) {
339
+ const n = Te(t);
340
340
  if (!n)
341
341
  return !1;
342
- const [t, c] = n.split("/"), a = parseInt(t, 10), o = 2e3 + parseInt(c, 10);
342
+ const [c, r] = n.split("/"), a = parseInt(c, 10), o = 2e3 + parseInt(r, 10);
343
343
  return new Date(o, a, 0, 23, 59, 59, 999).getTime() >= e.getTime();
344
344
  }
345
- function ie(r) {
346
- return r === "amex" ? 4 : 3;
345
+ function ye(t) {
346
+ return t === "amex" ? 4 : 3;
347
347
  }
348
- function we(r, e = {}) {
349
- var s;
350
- const n = {}, t = de(r.number), c = Se(r.number);
351
- c || (n.number = "Invalid card number");
352
- const a = xe(r.expiry, e.now);
348
+ function Ie(t, e = {}) {
349
+ var u;
350
+ const n = {}, c = Ne(t.number), r = Be(t.number);
351
+ r || (n.number = "Invalid card number");
352
+ const a = Le(t.expiry, e.now);
353
353
  a || (n.expiry = "Invalid or expired");
354
- const u = (r.cvc || "").replace(/\D/g, "").length === ie(t);
355
- u || (n.cvc = `CVC must be ${ie(t)} digits`);
356
- const l = !e.requireHolder || (((s = r.holderName) == null ? void 0 : s.trim().length) ?? 0) >= 2;
354
+ const i = (t.cvc || "").replace(/\D/g, "").length === ye(c);
355
+ i || (n.cvc = `CVC must be ${ye(c)} digits`);
356
+ const l = !e.requireHolder || (((u = t.holderName) == null ? void 0 : u.trim().length) ?? 0) >= 2;
357
357
  return l || (n.holderName = "Cardholder name required"), {
358
- brand: t,
359
- numberValid: c,
358
+ brand: c,
359
+ numberValid: r,
360
360
  expiryValid: a,
361
- cvcValid: u,
361
+ cvcValid: i,
362
362
  holderValid: l,
363
- isValid: c && a && u && l,
363
+ isValid: r && a && i && l,
364
364
  errors: n
365
365
  };
366
366
  }
367
- class Dn {
367
+ class Lt {
368
368
  constructor(e) {
369
- T(this, "id", "static");
369
+ K(this, "id", "static");
370
370
  this.rates = e;
371
371
  }
372
372
  async getRate(e, n) {
373
- const t = e.toUpperCase(), c = n.toUpperCase();
374
- if (t === c)
375
- return { base: t, quote: c, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
376
- const a = this.rates.find((s) => s.base === t && s.quote === c);
373
+ const c = e.toUpperCase(), r = n.toUpperCase();
374
+ if (c === r)
375
+ return { base: c, quote: r, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
376
+ const a = this.rates.find((u) => u.base === c && u.quote === r);
377
377
  if (a)
378
378
  return a;
379
- const o = this.rates.find((s) => s.base === c && s.quote === t);
379
+ const o = this.rates.find((u) => u.base === r && u.quote === c);
380
380
  if (o)
381
- return { base: t, quote: c, rate: 1 / o.rate, asOf: o.asOf };
382
- const u = this.rates.find((s) => s.base === t && s.quote === "USD") ?? this.rates.find((s) => s.base === "USD" && s.quote === t), l = this.rates.find((s) => s.base === "USD" && s.quote === c) ?? this.rates.find((s) => s.base === c && s.quote === "USD");
383
- if (u && l) {
384
- const s = u.base === "USD" ? 1 / u.rate : u.rate, y = l.base === "USD" ? l.rate : 1 / l.rate;
381
+ return { base: c, quote: r, rate: 1 / o.rate, asOf: o.asOf };
382
+ const i = this.rates.find((u) => u.base === c && u.quote === "USD") ?? this.rates.find((u) => u.base === "USD" && u.quote === c), l = this.rates.find((u) => u.base === "USD" && u.quote === r) ?? this.rates.find((u) => u.base === r && u.quote === "USD");
383
+ if (i && l) {
384
+ const u = i.base === "USD" ? 1 / i.rate : i.rate, m = l.base === "USD" ? l.rate : 1 / l.rate;
385
385
  return {
386
- base: t,
387
- quote: c,
388
- rate: s * y,
386
+ base: c,
387
+ quote: r,
388
+ rate: u * m,
389
389
  asOf: (/* @__PURE__ */ new Date()).toISOString()
390
390
  };
391
391
  }
392
- throw new Error(`No FX rate for ${t}/${c}`);
392
+ throw new Error(`No FX rate for ${c}/${r}`);
393
393
  }
394
394
  }
395
- class he {
395
+ class ge {
396
396
  constructor(e = {}) {
397
- T(this, "cache", /* @__PURE__ */ new Map());
398
- T(this, "fetchImpl");
399
- T(this, "ttl");
397
+ K(this, "cache", /* @__PURE__ */ new Map());
398
+ K(this, "fetchImpl");
399
+ K(this, "ttl");
400
400
  this.fetchImpl = e.fetchImpl ?? fetch, this.ttl = e.cacheTtl ?? 6e4;
401
401
  }
402
402
  cacheKey(e, n) {
403
403
  return `${this.id}:${e.toUpperCase()}/${n.toUpperCase()}`;
404
404
  }
405
405
  getCached(e, n) {
406
- const t = this.cacheKey(e, n), c = this.cache.get(t);
407
- return c && c.expires > Date.now() ? c.rate : (c && this.cache.delete(t), null);
406
+ const c = this.cacheKey(e, n), r = this.cache.get(c);
407
+ return r && r.expires > Date.now() ? r.rate : (r && this.cache.delete(c), null);
408
408
  }
409
409
  setCached(e) {
410
410
  this.cache.set(this.cacheKey(e.base, e.quote), {
@@ -413,93 +413,141 @@ class he {
413
413
  });
414
414
  }
415
415
  }
416
- class Cn extends he {
416
+ class at extends ge {
417
417
  constructor(n = {}) {
418
418
  super(n);
419
- T(this, "id", "frankfurter");
419
+ K(this, "id", "frankfurter");
420
420
  }
421
- async getRate(n, t) {
422
- const c = n.toUpperCase(), a = t.toUpperCase();
423
- if (c === a)
424
- return { base: c, quote: a, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
425
- const o = this.getCached(c, a);
421
+ async getRate(n, c) {
422
+ const r = n.toUpperCase(), a = c.toUpperCase();
423
+ if (r === a)
424
+ return { base: r, quote: a, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
425
+ const o = this.getCached(r, a);
426
426
  if (o)
427
427
  return o;
428
- const u = `https://api.frankfurter.app/latest?from=${c}&to=${a}`, l = await this.fetchImpl(u);
428
+ const i = `https://api.frankfurter.app/latest?from=${r}&to=${a}`, l = await this.fetchImpl(i);
429
429
  if (!l.ok)
430
430
  throw new Error(`Frankfurter HTTP ${l.status}`);
431
- const s = await l.json(), y = s.rates[a];
432
- if (y == null)
433
- throw new Error(`Frankfurter: no rate for ${c}/${a}`);
434
- const h = { base: c, quote: a, rate: y, asOf: s.date };
435
- return this.setCached(h), h;
431
+ const u = await l.json(), m = u.rates[a];
432
+ if (m == null)
433
+ throw new Error(`Frankfurter: no rate for ${r}/${a}`);
434
+ const b = { base: r, quote: a, rate: m, asOf: u.date };
435
+ return this.setCached(b), b;
436
436
  }
437
437
  }
438
- class vn extends he {
439
- constructor(n, t = {}) {
440
- super(t);
441
- T(this, "id", "openexchangerates");
438
+ class it extends ge {
439
+ constructor(n, c = {}) {
440
+ super(c);
441
+ K(this, "id", "openexchangerates");
442
442
  this.appId = n;
443
443
  }
444
- async getRate(n, t) {
445
- const c = n.toUpperCase(), a = t.toUpperCase();
446
- if (c === a)
447
- return { base: c, quote: a, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
448
- const o = this.getCached(c, a);
444
+ async getRate(n, c) {
445
+ const r = n.toUpperCase(), a = c.toUpperCase();
446
+ if (r === a)
447
+ return { base: r, quote: a, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
448
+ const o = this.getCached(r, a);
449
449
  if (o)
450
450
  return o;
451
- const u = `https://openexchangerates.org/api/latest.json?app_id=${this.appId}`, l = await this.fetchImpl(u);
451
+ const i = `https://openexchangerates.org/api/latest.json?app_id=${this.appId}`, l = await this.fetchImpl(i);
452
452
  if (!l.ok)
453
453
  throw new Error(`OpenExchangeRates HTTP ${l.status}`);
454
- const s = await l.json(), y = s.rates[c], h = s.rates[a];
455
- if (y == null || h == null)
456
- throw new Error(`OpenExchangeRates: missing rate for ${c} or ${a}`);
457
- const m = {
458
- base: c,
454
+ const u = await l.json(), m = u.rates[r], b = u.rates[a];
455
+ if (m == null || b == null)
456
+ throw new Error(`OpenExchangeRates: missing rate for ${r} or ${a}`);
457
+ const p = {
458
+ base: r,
459
459
  quote: a,
460
- rate: h / y,
461
- asOf: new Date(s.timestamp * 1e3).toISOString()
460
+ rate: b / m,
461
+ asOf: new Date(u.timestamp * 1e3).toISOString()
462
462
  };
463
- return this.setCached(m), m;
463
+ return this.setCached(p), p;
464
464
  }
465
465
  }
466
- class $n extends he {
466
+ class st extends ge {
467
467
  constructor(n = {}) {
468
468
  super(n);
469
- T(this, "id", "exchangerate.host");
469
+ K(this, "id", "exchangerate.host");
470
470
  }
471
- async getRate(n, t) {
472
- var m;
473
- const c = n.toUpperCase(), a = t.toUpperCase();
474
- if (c === a)
475
- return { base: c, quote: a, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
476
- const o = this.getCached(c, a);
471
+ async getRate(n, c) {
472
+ var p;
473
+ const r = n.toUpperCase(), a = c.toUpperCase();
474
+ if (r === a)
475
+ return { base: r, quote: a, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
476
+ const o = this.getCached(r, a);
477
477
  if (o)
478
478
  return o;
479
- const u = `https://api.exchangerate.host/convert?from=${c}&to=${a}`, l = await this.fetchImpl(u);
479
+ const i = `https://api.exchangerate.host/convert?from=${r}&to=${a}`, l = await this.fetchImpl(i);
480
480
  if (!l.ok)
481
481
  throw new Error(`exchangerate.host HTTP ${l.status}`);
482
- const s = await l.json(), y = ((m = s.info) == null ? void 0 : m.rate) ?? s.result, h = { base: c, quote: a, rate: y, asOf: s.date };
483
- return this.setCached(h), h;
482
+ const u = await l.json(), m = ((p = u.info) == null ? void 0 : p.rate) ?? u.result, b = { base: r, quote: a, rate: m, asOf: u.date };
483
+ return this.setCached(b), b;
484
+ }
485
+ }
486
+ class ot extends ge {
487
+ constructor(n = {}) {
488
+ super(n);
489
+ K(this, "id", "nbp");
490
+ K(this, "table");
491
+ this.table = n.table ?? "A";
492
+ }
493
+ async getRate(n, c) {
494
+ const r = n.toUpperCase(), a = c.toUpperCase();
495
+ if (r === a)
496
+ return { base: r, quote: a, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
497
+ const o = this.getCached(r, a);
498
+ if (o)
499
+ return o;
500
+ const i = async (b) => {
501
+ var y;
502
+ if (b === "PLN")
503
+ return { rate: 1, date: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10) };
504
+ const p = `https://api.nbp.pl/api/exchangerates/rates/${this.table}/${b}/?format=json`, d = await this.fetchImpl(p);
505
+ if (!d.ok)
506
+ return null;
507
+ const h = (y = (await d.json()).rates) == null ? void 0 : y[0];
508
+ return h ? { rate: h.mid ?? h.ask ?? 0, date: h.effectiveDate } : null;
509
+ }, l = await i(r), u = await i(a);
510
+ if (!l || !u || l.rate === 0)
511
+ throw new Error(`NBP: missing rate for ${r} or ${a}`);
512
+ const m = {
513
+ base: r,
514
+ quote: a,
515
+ rate: l.rate / u.rate,
516
+ asOf: l.date
517
+ };
518
+ return this.setCached(m), m;
484
519
  }
485
520
  }
486
- async function Ve(r, e, n) {
487
- const t = e.toUpperCase();
488
- if (r.currency.toUpperCase() === t)
489
- return r;
490
- const c = L(r.currency), a = L(t), o = (c == null ? void 0 : c.decimals) ?? 2, u = (a == null ? void 0 : a.decimals) ?? 2, { rate: l } = await n.getRate(r.currency, t), y = r.amount / Math.pow(10, o) * l;
521
+ class lt extends at {
522
+ constructor() {
523
+ super(...arguments);
524
+ K(this, "id", "ecb");
525
+ }
526
+ }
527
+ class ut extends st {
528
+ constructor() {
529
+ super(...arguments);
530
+ K(this, "id", "free-forex");
531
+ }
532
+ }
533
+ const qt = (t = {}) => new ot(t), Ht = (t = {}) => new lt(t), jt = (t) => new it(t.apiKey, t), zt = (t = {}) => new ut(t);
534
+ async function dt(t, e, n) {
535
+ const c = e.toUpperCase();
536
+ if (t.currency.toUpperCase() === c)
537
+ return t;
538
+ const r = V(t.currency), a = V(c), o = (r == null ? void 0 : r.decimals) ?? 2, i = (a == null ? void 0 : a.decimals) ?? 2, { rate: l } = await n.getRate(t.currency, c), m = t.amount / Math.pow(10, o) * l;
491
539
  return {
492
- currency: t,
493
- amount: Math.round(y * Math.pow(10, u))
540
+ currency: c,
541
+ amount: Math.round(m * Math.pow(10, i))
494
542
  };
495
543
  }
496
- class Ze {
544
+ class mt {
497
545
  constructor(e = {}) {
498
- T(this, "id");
499
- T(this, "name");
500
- T(this, "supportedCurrencies");
501
- T(this, "minimums");
502
- T(this, "counter", 0);
546
+ K(this, "id");
547
+ K(this, "name");
548
+ K(this, "supportedCurrencies");
549
+ K(this, "minimums");
550
+ K(this, "counter", 0);
503
551
  this.id = e.id ?? "mock", this.name = e.name ?? "Mock Processor", this.supportedCurrencies = e.supportedCurrencies ?? "*";
504
552
  }
505
553
  newId(e) {
@@ -534,28 +582,28 @@ class Ze {
534
582
  };
535
583
  }
536
584
  }
537
- function G(r, e, n, t, c) {
585
+ function j(t, e, n, c, r) {
538
586
  const a = (o) => {
539
- const u = t == null ? void 0 : t[o];
540
- return u || (async () => {
587
+ const i = c == null ? void 0 : c[o];
588
+ return i || (async () => {
541
589
  throw new Error(
542
590
  `[ui-money] ${e} adapter is not wired. Pass an \`executor.${String(o)}\` implementation that calls the ${e} SDK.`
543
591
  );
544
592
  });
545
593
  };
546
594
  return {
547
- id: r,
595
+ id: t,
548
596
  name: e,
549
597
  supportedCurrencies: n,
550
- minimums: c,
598
+ minimums: r,
551
599
  authorize: a("authorize"),
552
600
  capture: a("capture"),
553
601
  cancel: a("cancel"),
554
602
  refund: a("refund")
555
603
  };
556
604
  }
557
- function Je(r) {
558
- return G("stripe", "Stripe", "*", r, {
605
+ function pt(t) {
606
+ return j("stripe", "Stripe", "*", t, {
559
607
  USD: 50,
560
608
  EUR: 50,
561
609
  GBP: 30,
@@ -569,8 +617,8 @@ function Je(r) {
569
617
  PLN: 200
570
618
  });
571
619
  }
572
- function Qe(r) {
573
- return G(
620
+ function yt(t) {
621
+ return j(
574
622
  "paypal",
575
623
  "PayPal",
576
624
  [
@@ -597,666 +645,710 @@ function Qe(r) {
597
645
  "PHP",
598
646
  "ILS"
599
647
  ],
600
- r
648
+ t
601
649
  );
602
650
  }
603
- function Xe(r) {
604
- return G("adyen", "Adyen", "*", r);
651
+ function ft(t) {
652
+ return j("adyen", "Adyen", "*", t);
605
653
  }
606
- function We(r) {
607
- return G("square", "Square", ["USD", "CAD", "GBP", "AUD", "JPY", "EUR"], r);
654
+ function ht(t) {
655
+ return j("square", "Square", ["USD", "CAD", "GBP", "AUD", "JPY", "EUR"], t);
608
656
  }
609
- function en(r) {
610
- return G("mollie", "Mollie", "*", r);
657
+ function bt(t) {
658
+ return j("mollie", "Mollie", "*", t);
611
659
  }
612
- function nn(r) {
613
- return G("braintree", "Braintree", "*", r);
660
+ function _t(t) {
661
+ return j("braintree", "Braintree", "*", t);
614
662
  }
615
- function rn(r) {
616
- return G("razorpay", "Razorpay", ["INR", "USD", "EUR", "GBP", "AED"], r);
663
+ function Nt(t) {
664
+ return j("razorpay", "Razorpay", ["INR", "USD", "EUR", "GBP", "AED"], t);
617
665
  }
618
- function tn(r) {
619
- return G(
666
+ function gt(t) {
667
+ return j(
620
668
  "payu",
621
669
  "PayU",
622
670
  ["PLN", "EUR", "USD", "CZK", "HUF", "RON", "BGN", "TRY"],
623
- r
671
+ t
624
672
  );
625
673
  }
626
- function cn(r) {
627
- return G("przelewy24", "Przelewy24", ["PLN", "EUR"], r);
674
+ function wt(t) {
675
+ return j("przelewy24", "Przelewy24", ["PLN", "EUR"], t);
676
+ }
677
+ function Dt(t = {}) {
678
+ return j("tpay", "Tpay", ["PLN", "EUR", "USD", "GBP"], t);
679
+ }
680
+ function vt(t = {}) {
681
+ return j("autopay", "Autopay", ["PLN", "EUR", "USD", "GBP", "CZK"], t);
628
682
  }
629
- function an(r) {
630
- return G(
683
+ function Ct(t = {}) {
684
+ const { acquirer: e = "native", ...n } = t;
685
+ return j(`blik:${e}`, `BLIK (${e})`, ["PLN"], n);
686
+ }
687
+ function $t(t) {
688
+ return j(
631
689
  "klarna",
632
690
  "Klarna",
633
691
  ["USD", "EUR", "GBP", "SEK", "NOK", "DKK", "CHF", "AUD", "CAD", "NZD", "PLN"],
634
- r
692
+ t
635
693
  );
636
694
  }
637
- function sn(r) {
638
- return G(
695
+ function xt(t) {
696
+ return j(
639
697
  "coinbase-commerce",
640
698
  "Coinbase Commerce",
641
699
  ["BTC", "ETH", "USDC", "USDT", "USD", "EUR"],
642
- r
700
+ t
643
701
  );
644
702
  }
645
- const Sn = {
646
- mock: () => new Ze(),
647
- stripe: () => Je(),
648
- paypal: () => Qe(),
649
- adyen: () => Xe(),
650
- square: () => We(),
651
- mollie: () => en(),
652
- braintree: () => nn(),
653
- razorpay: () => rn(),
654
- payu: () => tn(),
655
- przelewy24: () => cn(),
656
- klarna: () => an(),
657
- "coinbase-commerce": () => sn()
703
+ const Gt = {
704
+ mock: () => new mt(),
705
+ stripe: () => pt(),
706
+ paypal: () => yt(),
707
+ adyen: () => ft(),
708
+ square: () => ht(),
709
+ mollie: () => bt(),
710
+ braintree: () => _t(),
711
+ razorpay: () => Nt(),
712
+ payu: () => gt(),
713
+ przelewy24: () => wt(),
714
+ tpay: () => Dt(),
715
+ autopay: () => vt(),
716
+ blik: () => Ct(),
717
+ klarna: () => $t(),
718
+ "coinbase-commerce": () => xt()
658
719
  };
659
- function Un(r, e) {
660
- const n = P(
661
- () => "amount" in r ? r : re(
662
- r.major,
663
- r.currency
720
+ function Yt(t, e) {
721
+ const n = k(
722
+ () => "amount" in t ? t : W(
723
+ t.major,
724
+ t.currency
664
725
  ),
665
726
  // eslint-disable-next-line react-hooks/exhaustive-deps
666
727
  []
667
- ), [t, c] = E(n), a = R(
668
- (m) => c((d) => re(m, d.currency)),
728
+ ), [c, r] = B(n), a = F(
729
+ (p) => r((d) => W(p, d.currency)),
669
730
  []
670
- ), o = R((m) => {
671
- c((d) => ({ ...d, currency: m.toUpperCase() }));
672
- }, []), u = R((m) => c((d) => He(d, m)), []), l = R(
673
- (m) => c((d) => je(d, m)),
731
+ ), o = F((p) => {
732
+ r((d) => ({ ...d, currency: p.toUpperCase() }));
733
+ }, []), i = F((p) => r((d) => me(d, p)), []), l = F(
734
+ (p) => r((d) => nt(d, p)),
674
735
  []
675
- ), s = R(
676
- (m) => c((d) => ze(d, m)),
736
+ ), u = F(
737
+ (p) => r((d) => De(d, p)),
677
738
  []
678
- ), y = P(() => ee(t, { locale: e }), [t, e]), h = P(() => $e(t), [t]);
679
- return { money: t, setMoney: c, setMajor: a, setCurrency: o, add: u, subtract: l, scale: s, formatted: y, major: h };
739
+ ), m = k(() => te(c, { locale: e }), [c, e]), b = k(() => Ke(c), [c]);
740
+ return { money: c, setMoney: r, setMajor: a, setCurrency: o, add: i, subtract: l, scale: u, formatted: m, major: b };
680
741
  }
681
- function me(r, e, n) {
682
- const [t, c] = E(null), [a, o] = E(null), [u, l] = E(!1), s = Te(0);
683
- return qe(() => {
684
- if (!r) {
685
- c(null);
742
+ function ve(t, e, n) {
743
+ const [c, r] = B(null), [a, o] = B(null), [i, l] = B(!1), u = We(0);
744
+ return et(() => {
745
+ if (!t) {
746
+ r(null);
686
747
  return;
687
748
  }
688
- const y = ++s.current;
689
- l(!0), o(null), Ve(r, e, n).then((h) => {
690
- s.current === y && c(h);
691
- }).catch((h) => {
692
- s.current === y && (o(h instanceof Error ? h : new Error(String(h))), c(null));
749
+ const m = ++u.current;
750
+ l(!0), o(null), dt(t, e, n).then((b) => {
751
+ u.current === m && r(b);
752
+ }).catch((b) => {
753
+ u.current === m && (o(b instanceof Error ? b : new Error(String(b))), r(null));
693
754
  }).finally(() => {
694
- s.current === y && l(!1);
755
+ u.current === m && l(!1);
695
756
  });
696
- }, [r == null ? void 0 : r.amount, r == null ? void 0 : r.currency, e, n]), { converted: t, loading: u, error: a };
757
+ }, [t == null ? void 0 : t.amount, t == null ? void 0 : t.currency, e, n]), { converted: c, loading: i, error: a };
697
758
  }
698
- function on(r) {
699
- const [e, n] = E("idle"), [t, c] = E(null), [a, o] = E(null), u = R(() => {
700
- n("idle"), c(null), o(null);
701
- }, []), l = R(
702
- async (m) => {
759
+ function St(t) {
760
+ const [e, n] = B("idle"), [c, r] = B(null), [a, o] = B(null), i = F(() => {
761
+ n("idle"), r(null), o(null);
762
+ }, []), l = F(
763
+ async (p) => {
703
764
  n("authorizing"), o(null);
704
765
  try {
705
- const d = await r.authorize(m);
706
- return c(d), n(d.status), d;
766
+ const d = await t.authorize(p);
767
+ return r(d), n(d.status), d;
707
768
  } catch (d) {
708
- const b = d instanceof Error ? d : new Error(String(d));
709
- throw o(b), n("failed"), b;
769
+ const f = d instanceof Error ? d : new Error(String(d));
770
+ throw o(f), n("failed"), f;
710
771
  }
711
772
  },
712
- [r]
713
- ), s = R(
714
- async (m, d) => {
715
- const b = m ?? (t == null ? void 0 : t.id);
716
- if (!b)
773
+ [t]
774
+ ), u = F(
775
+ async (p, d) => {
776
+ const f = p ?? (c == null ? void 0 : c.id);
777
+ if (!f)
717
778
  throw new Error("No authorization id to capture");
718
779
  n("capturing");
719
780
  try {
720
- const _ = await r.capture(b, d);
721
- return c(_), n(_.status), _;
722
- } catch (_) {
723
- const f = _ instanceof Error ? _ : new Error(String(_));
724
- throw o(f), n("failed"), f;
781
+ const h = await t.capture(f, d);
782
+ return r(h), n(h.status), h;
783
+ } catch (h) {
784
+ const y = h instanceof Error ? h : new Error(String(h));
785
+ throw o(y), n("failed"), y;
725
786
  }
726
787
  },
727
- [r, t == null ? void 0 : t.id]
728
- ), y = R(
729
- async (m) => {
730
- const d = m ?? (t == null ? void 0 : t.id);
788
+ [t, c == null ? void 0 : c.id]
789
+ ), m = F(
790
+ async (p) => {
791
+ const d = p ?? (c == null ? void 0 : c.id);
731
792
  if (!d)
732
793
  throw new Error("No payment id to cancel");
733
- const b = await r.cancel(d);
734
- return c(b), n(b.status), b;
794
+ const f = await t.cancel(d);
795
+ return r(f), n(f.status), f;
735
796
  },
736
- [r, t == null ? void 0 : t.id]
737
- ), h = R(
738
- async (m, d) => {
739
- const b = m ?? (t == null ? void 0 : t.id);
740
- if (!b)
797
+ [t, c == null ? void 0 : c.id]
798
+ ), b = F(
799
+ async (p, d) => {
800
+ const f = p ?? (c == null ? void 0 : c.id);
801
+ if (!f)
741
802
  throw new Error("No payment id to refund");
742
- const _ = await r.refund(b, d);
743
- return c(_), n(_.status), _;
803
+ const h = await t.refund(f, d);
804
+ return r(h), n(h.status), h;
744
805
  },
745
- [r, t == null ? void 0 : t.id]
806
+ [t, c == null ? void 0 : c.id]
746
807
  );
747
- return { status: e, response: t, error: a, authorize: l, capture: s, cancel: y, refund: h, reset: u };
808
+ return { status: e, response: c, error: a, authorize: l, capture: u, cancel: m, refund: b, reset: i };
748
809
  }
749
- const De = te(function({
810
+ const Fe = de(function({
750
811
  value: e,
751
812
  amount: n,
752
- currency: t,
753
- locale: c,
813
+ currency: c,
814
+ locale: r,
754
815
  display: a = "symbol",
755
816
  highlightNegative: o = !0,
756
- zeroPlaceholder: u,
817
+ zeroPlaceholder: i,
757
818
  convertTo: l,
758
- exchangeProvider: s,
759
- className: y,
760
- style: h,
761
- "aria-label": m
819
+ exchangeProvider: u,
820
+ className: m,
821
+ style: b,
822
+ "aria-label": p
762
823
  }, d) {
763
- const b = P(() => {
824
+ const f = k(() => {
764
825
  if (e)
765
826
  return e;
766
- if (n != null && t) {
767
- const I = L(t), F = (I == null ? void 0 : I.decimals) ?? 2;
827
+ if (n != null && c) {
828
+ const g = V(c), v = (g == null ? void 0 : g.decimals) ?? 2;
768
829
  return {
769
- amount: Math.round(n * Math.pow(10, F)),
770
- currency: t.toUpperCase()
830
+ amount: Math.round(n * Math.pow(10, v)),
831
+ currency: c.toUpperCase()
771
832
  };
772
833
  }
773
834
  return null;
774
- }, [e, n, t]), _ = P(() => b ? b.amount === 0 && u != null ? u : ee(b, { locale: c, currencyDisplay: a }) : "", [b, c, a, u]), { converted: f } = me(
775
- l && s ? b : null,
835
+ }, [e, n, c]), h = k(() => f ? f.amount === 0 && i != null ? i : te(f, { locale: r, currencyDisplay: a }) : "", [f, r, a, i]), { converted: y } = ve(
836
+ l && u ? f : null,
776
837
  l ?? "",
777
- s
838
+ u
778
839
  );
779
- if (!b)
840
+ if (!f)
780
841
  return null;
781
- const H = b.amount < 0, j = "nice-money" + (o && H ? " nice-money--negative" : "") + (y ? ` ${y}` : "");
782
- return /* @__PURE__ */ N("span", { ref: d, className: j, style: h, "aria-label": m, children: [
783
- /* @__PURE__ */ i("span", { className: "nice-money__value", children: _ }),
784
- f && /* @__PURE__ */ N("span", { className: "nice-money__converted", "aria-label": `Converted to ${f.currency}`, children: [
842
+ const _ = f.amount < 0, S = "nice-money" + (o && _ ? " nice-money--negative" : "") + (m ? ` ${m}` : "");
843
+ return /* @__PURE__ */ N("span", { ref: d, className: S, style: b, "aria-label": p, children: [
844
+ /* @__PURE__ */ s("span", { className: "nice-money__value", children: h }),
845
+ y && /* @__PURE__ */ N("span", { className: "nice-money__converted", "aria-label": `Converted to ${y.currency}`, children: [
785
846
  " ≈ ",
786
- ee(f, { locale: c })
847
+ te(y, { locale: r })
787
848
  ] })
788
849
  ] });
789
- }), xn = se.map((r) => r.code).sort(), Re = te(
850
+ }), Zt = fe.map((t) => t.code).sort(), qe = de(
790
851
  function({
791
852
  value: e,
792
853
  onChange: n,
793
- options: t = se,
794
- recents: c = [],
854
+ options: c = fe,
855
+ recents: r = [],
795
856
  searchable: a,
796
857
  showCode: o = !0,
797
- showSymbol: u = !0,
858
+ showSymbol: i = !0,
798
859
  compact: l = !1,
799
- disabled: s,
800
- readOnly: y,
801
- loading: h,
802
- accessMode: m,
860
+ disabled: u,
861
+ readOnly: m,
862
+ loading: b,
863
+ accessMode: p,
803
864
  label: d,
804
- helperText: b,
805
- error: _,
806
- required: f,
807
- size: H = "md",
808
- labelPlacement: j = "top",
809
- labelWidth: I,
810
- controlWidth: F,
811
- className: Q,
812
- style: X,
813
- id: A,
814
- name: M,
815
- title: ne,
816
- "data-testid": x,
817
- "aria-label": V,
818
- placeholder: O
819
- }, v) {
820
- if (m === "hidden")
821
- return null;
822
- const q = s || m === "disabled" || h, W = y || m === "readOnly", K = ye(), z = A ?? `nice-cs-${K}`, [Z, Y] = E(""), C = a ?? t.length > 8, D = P(() => {
823
- if (!Z.trim())
824
- return t;
825
- const p = Z.trim().toLowerCase();
826
- return t.filter(
827
- (S) => S.code.toLowerCase().includes(p) || S.name.toLowerCase().includes(p) || S.symbol.toLowerCase().includes(p)
865
+ helperText: f,
866
+ error: h,
867
+ required: y,
868
+ size: _ = "md",
869
+ labelPlacement: S = "top",
870
+ labelWidth: g,
871
+ controlWidth: v,
872
+ className: O,
873
+ style: Y,
874
+ id: Z,
875
+ name: R,
876
+ title: q,
877
+ "data-testid": ne,
878
+ "aria-label": E,
879
+ placeholder: J
880
+ }, z) {
881
+ const P = p === "hidden", X = u || p === "disabled" || b, se = m || p === "readOnly", A = Ce(), oe = Z ?? `nice-cs-${A}`, [H, U] = B(""), M = a ?? c.length > 8, T = k(() => {
882
+ if (!H.trim())
883
+ return c;
884
+ const D = H.trim().toLowerCase();
885
+ return c.filter(
886
+ (C) => C.code.toLowerCase().includes(D) || C.name.toLowerCase().includes(D) || C.symbol.toLowerCase().includes(D)
828
887
  );
829
- }, [t, Z]), $ = P(() => {
830
- const p = /* @__PURE__ */ new Set();
831
- return c.map((S) => L(S)).filter((S) => !!S && !p.has(S.code) && !!p.add(S.code));
832
- }, [c]), B = R(
833
- (p) => {
834
- const S = p.target.value, oe = L(S);
835
- oe && (n == null || n(S, oe));
888
+ }, [c, H]), x = k(() => {
889
+ const D = /* @__PURE__ */ new Set();
890
+ return r.map((C) => V(C)).filter((C) => !!C && !D.has(C.code) && !!D.add(C.code));
891
+ }, [r]), le = F(
892
+ (D) => {
893
+ const C = D.target.value, ce = V(C);
894
+ ce && (n == null || n(C, ce));
836
895
  },
837
896
  [n]
838
- ), ce = (p) => {
897
+ ), ee = (D) => {
839
898
  if (l)
840
- return `${u ? p.symbol + " " : ""}${p.code}`;
841
- const S = [];
842
- return u && S.push(p.symbol), o && S.push(p.code), S.push("—", p.name), S.join(" ");
843
- }, g = `nice-currency-selector nice-currency-selector--${H} nice-currency-selector--label-${j}` + (l ? " nice-currency-selector--compact" : "") + (_ ? " nice-currency-selector--error" : "") + (q ? " nice-currency-selector--disabled" : "") + (Q ? ` ${Q}` : ""), w = j === "left" && I != null ? { width: typeof I == "number" ? `${I}px` : I, flex: "none" } : void 0, k = F != null ? {
844
- width: typeof F == "number" ? `${F}px` : F,
899
+ return `${i ? D.symbol + " " : ""}${D.code}`;
900
+ const C = [];
901
+ return i && C.push(D.symbol), o && C.push(D.code), C.push("—", D.name), C.join(" ");
902
+ }, w = `nice-currency-selector nice-currency-selector--${_} nice-currency-selector--label-${S}` + (l ? " nice-currency-selector--compact" : "") + (h ? " nice-currency-selector--error" : "") + (X ? " nice-currency-selector--disabled" : "") + (O ? ` ${O}` : ""), I = S === "left" && g != null ? { width: typeof g == "number" ? `${g}px` : g, flex: "none" } : void 0, re = v != null ? {
903
+ width: typeof v == "number" ? `${v}px` : v,
845
904
  flex: "none"
846
905
  } : void 0;
847
- return /* @__PURE__ */ N("div", { ref: v, className: g, style: X, title: ne, "data-testid": x, children: [
848
- d && /* @__PURE__ */ N("label", { htmlFor: z, className: "nice-currency-selector__label", style: w, children: [
906
+ return P ? null : /* @__PURE__ */ N("div", { ref: z, className: w, style: Y, title: q, "data-testid": ne, children: [
907
+ d && /* @__PURE__ */ N("label", { htmlFor: oe, className: "nice-currency-selector__label", style: I, children: [
849
908
  d,
850
- f && /* @__PURE__ */ i("span", { className: "nice-currency-selector__required", "aria-hidden": !0, children: "*" })
909
+ y && /* @__PURE__ */ s("span", { className: "nice-currency-selector__required", "aria-hidden": !0, children: "*" })
851
910
  ] }),
852
- /* @__PURE__ */ N("div", { className: "nice-currency-selector__inner", style: k, children: [
853
- C && /* @__PURE__ */ i(
911
+ /* @__PURE__ */ N("div", { className: "nice-currency-selector__inner", style: re, children: [
912
+ M && /* @__PURE__ */ s(
854
913
  "input",
855
914
  {
856
915
  type: "search",
857
916
  className: "nice-currency-selector__search",
858
917
  placeholder: "Search currency…",
859
- value: Z,
860
- onChange: (p) => Y(p.target.value),
861
- disabled: q || W,
918
+ value: H,
919
+ onChange: (D) => U(D.target.value),
920
+ disabled: X || se,
862
921
  "aria-label": "Search currency"
863
922
  }
864
923
  ),
865
924
  /* @__PURE__ */ N(
866
925
  "select",
867
926
  {
868
- id: z,
869
- name: M,
927
+ id: oe,
928
+ name: R,
870
929
  className: "nice-currency-selector__select",
871
930
  value: e ?? "",
872
- onChange: B,
873
- disabled: q || W,
874
- required: f,
875
- "aria-invalid": !!_,
876
- "aria-label": V ?? (typeof d == "string" ? d : "Currency"),
931
+ onChange: le,
932
+ disabled: X || se,
933
+ required: y,
934
+ "aria-invalid": !!h,
935
+ "aria-label": E ?? (typeof d == "string" ? d : "Currency"),
877
936
  children: [
878
- !e && /* @__PURE__ */ i("option", { value: "", children: O ?? "Select currency…" }),
879
- $.length > 0 && /* @__PURE__ */ i("optgroup", { label: "Recent", children: $.map((p) => /* @__PURE__ */ i("option", { value: p.code, children: ce(p) }, `r-${p.code}`)) }),
880
- /* @__PURE__ */ i("optgroup", { label: $.length > 0 ? "All" : "", children: D.map((p) => /* @__PURE__ */ i("option", { value: p.code, children: ce(p) }, p.code)) })
937
+ !e && /* @__PURE__ */ s("option", { value: "", children: J ?? "Select currency…" }),
938
+ x.length > 0 && /* @__PURE__ */ s("optgroup", { label: "Recent", children: x.map((D) => /* @__PURE__ */ s("option", { value: D.code, children: ee(D) }, `r-${D.code}`)) }),
939
+ /* @__PURE__ */ s("optgroup", { label: x.length > 0 ? "All" : "", children: T.map((D) => /* @__PURE__ */ s("option", { value: D.code, children: ee(D) }, D.code)) })
881
940
  ]
882
941
  }
883
942
  )
884
943
  ] }),
885
- (_ || b) && /* @__PURE__ */ i(
944
+ (h || f) && /* @__PURE__ */ s(
886
945
  "span",
887
946
  {
888
- className: _ ? "nice-currency-selector__error" : "nice-currency-selector__helper",
889
- children: _ ?? b
947
+ className: h ? "nice-currency-selector__error" : "nice-currency-selector__helper",
948
+ children: h ?? f
890
949
  }
891
950
  )
892
951
  ] });
893
952
  }
894
- ), Me = te(
953
+ ), He = de(
895
954
  function({
896
955
  value: e,
897
956
  onChange: n,
898
- currency: t,
899
- onCurrencyChange: c,
957
+ currency: c,
958
+ onCurrencyChange: r,
900
959
  currencies: a,
901
960
  hideCurrencySelector: o,
902
- min: u,
961
+ min: i,
903
962
  max: l,
904
- step: s,
905
- locale: y,
906
- placeholder: h,
907
- label: m,
963
+ step: u,
964
+ locale: m,
965
+ placeholder: b,
966
+ label: p,
908
967
  helperText: d,
909
- error: b,
910
- size: _ = "md",
911
- disabled: f,
912
- readOnly: H,
913
- required: j,
914
- loading: I,
915
- accessMode: F,
916
- labelPlacement: Q = "top",
917
- errorPlacement: X = "bottom",
918
- labelWidth: A,
919
- controlWidth: M,
920
- submitOnEnter: ne,
921
- onSubmit: x,
922
- showFormattedPreview: V = !0,
923
- showSteppers: O = !1,
924
- className: v,
925
- style: q,
926
- id: W,
927
- name: K,
928
- title: z,
929
- "data-testid": Z,
930
- onBlur: Y,
931
- onFocus: C
932
- }, D) {
933
- const $ = f || F === "disabled" || I, B = H || F === "readOnly";
934
- if (F === "hidden")
935
- return null;
936
- const ce = ye(), g = W ?? `nice-money-${ce}`, w = ((e == null ? void 0 : e.currency) ?? t ?? "USD").toUpperCase(), k = L(w), p = (k == null ? void 0 : k.decimals) ?? 2, S = s ?? 1 / Math.pow(10, p), [oe, le] = E(
937
- () => e ? (e.amount / Math.pow(10, p)).toFixed(p) : ""
938
- ), [fe, be] = E(!1);
939
- Be.useEffect(() => {
940
- if (fe)
968
+ error: f,
969
+ size: h = "md",
970
+ disabled: y,
971
+ readOnly: _,
972
+ required: S,
973
+ loading: g,
974
+ accessMode: v,
975
+ labelPlacement: O = "top",
976
+ errorPlacement: Y = "bottom",
977
+ labelWidth: Z,
978
+ controlWidth: R,
979
+ submitOnEnter: q,
980
+ onSubmit: ne,
981
+ showFormattedPreview: E = !0,
982
+ showSteppers: J = !1,
983
+ className: z,
984
+ style: P,
985
+ id: X,
986
+ name: se,
987
+ title: A,
988
+ "data-testid": oe,
989
+ onBlur: H,
990
+ onFocus: U,
991
+ liveGrouping: M,
992
+ multiplierShortcuts: T = !0,
993
+ onValidationError: x
994
+ }, le) {
995
+ const ee = y || v === "disabled" || g, w = _ || v === "readOnly", I = v === "hidden", re = Ce(), D = X ?? `nice-money-${re}`, C = ((e == null ? void 0 : e.currency) ?? c ?? "USD").toUpperCase(), ce = V(C), G = (ce == null ? void 0 : ce.decimals) ?? 2, xe = u ?? 1 / Math.pow(10, G), [we, he] = B(
996
+ () => e ? (e.amount / Math.pow(10, G)).toFixed(G) : ""
997
+ ), [be, Se] = B(!1);
998
+ Ve.useEffect(() => {
999
+ if (be)
941
1000
  return;
942
1001
  if (e == null) {
943
- le("");
1002
+ he("");
944
1003
  return;
945
1004
  }
946
- const U = L(e.currency), J = (U == null ? void 0 : U.decimals) ?? 2;
947
- le((e.amount / Math.pow(10, J)).toFixed(J));
948
- }, [e, fe]);
949
- const _e = R(
950
- (U) => {
951
- const J = Ye(U, w);
952
- if (!J) {
1005
+ const $ = V(e.currency), L = ($ == null ? void 0 : $.decimals) ?? 2;
1006
+ he((e.amount / Math.pow(10, L)).toFixed(L));
1007
+ }, [e, be]);
1008
+ const Ue = F(
1009
+ ($) => {
1010
+ let L = $;
1011
+ if (T) {
1012
+ const ie = $.trim().match(/^([+-]?\d+(?:[.,]\d+)?)\s*([kKmMbB])$/);
1013
+ if (ie) {
1014
+ const ue = ie[2].toLowerCase() === "k" ? 1e3 : ie[2].toLowerCase() === "m" ? 1e6 : 1e9, ke = Number(ie[1].replace(",", ".")) * ue;
1015
+ if (!Number.isFinite(ke)) {
1016
+ x == null || x(new Error("overflow"));
1017
+ return;
1018
+ }
1019
+ L = String(ke);
1020
+ }
1021
+ }
1022
+ const Q = rt(L, C);
1023
+ if (!Q) {
953
1024
  n == null || n(null);
954
1025
  return;
955
1026
  }
956
- const ue = J.amount / Math.pow(10, p);
957
- if (u != null && ue < u) {
958
- n == null || n(re(u, w));
1027
+ if (!Number.isSafeInteger(Q.amount)) {
1028
+ x == null || x(new Error("overflow: amount exceeds Number.MAX_SAFE_INTEGER"));
1029
+ return;
1030
+ }
1031
+ const ae = Q.amount / Math.pow(10, G);
1032
+ if (i != null && ae < i) {
1033
+ x == null || x(new Error(`min: ${i}`)), n == null || n(W(i, C));
959
1034
  return;
960
1035
  }
961
- if (l != null && ue > l) {
962
- n == null || n(re(l, w));
1036
+ if (l != null && ae > l) {
1037
+ x == null || x(new Error(`max: ${l}`)), n == null || n(W(l, C));
963
1038
  return;
964
1039
  }
965
- n == null || n(J);
1040
+ n == null || n(Q);
966
1041
  },
967
- [w, p, u, l, n]
968
- ), Ee = R(
969
- (U) => {
970
- const J = U.target.value;
971
- le(J), _e(J);
1042
+ [C, G, i, l, n, T, x]
1043
+ ), je = F(
1044
+ ($) => {
1045
+ const L = $.target.value;
1046
+ he(L), Ue(L);
972
1047
  },
973
- [_e]
974
- ), Ne = R(
975
- (U) => {
976
- const ue = (e ? e.amount / Math.pow(10, p) : 0) + U, Ke = Math.min(l ?? 1 / 0, Math.max(u ?? -1 / 0, ue));
977
- n == null || n(re(Ke, w));
1048
+ [Ue]
1049
+ ), Re = F(
1050
+ ($) => {
1051
+ const Q = (e ? e.amount / Math.pow(10, G) : 0) + $, ae = Math.min(l ?? 1 / 0, Math.max(i ?? -1 / 0, Q));
1052
+ n == null || n(W(ae, C));
978
1053
  },
979
- [e, p, u, l, w, n]
980
- ), ge = P(() => e ? ee(e, { locale: y }) : "", [e, y]), ae = typeof b == "string" ? b : void 0, Ie = `nice-money-input nice-money-input--${_} nice-money-input--label-${Q} nice-money-input--error-${X}` + (ae ? " nice-money-input--error" : "") + ($ ? " nice-money-input--disabled" : "") + (I ? " nice-money-input--loading" : "") + (v ? ` ${v}` : ""), Fe = (U) => {
981
- ne && U.key === "Enter" && x && (U.preventDefault(), x());
982
- }, Pe = Q === "left" && A != null ? { width: typeof A == "number" ? `${A}px` : A, flex: "none" } : void 0, Ae = M != null ? {
983
- width: typeof M == "number" ? `${M}px` : M,
1054
+ [e, G, i, l, C, n]
1055
+ ), _e = k(() => {
1056
+ var $, L;
1057
+ try {
1058
+ const Q = new Intl.NumberFormat(m).formatToParts(12345.6), ae = (($ = Q.find((ue) => ue.type === "group")) == null ? void 0 : $.value) ?? ",", ie = ((L = Q.find((ue) => ue.type === "decimal")) == null ? void 0 : L.value) ?? ".";
1059
+ return { group: ae, decimal: ie };
1060
+ } catch {
1061
+ return { group: ",", decimal: "." };
1062
+ }
1063
+ }, [m]), Me = M ?? !!_e.group, ze = k(() => {
1064
+ if (!Me || be === !1)
1065
+ return we;
1066
+ const $ = _e.decimal, L = _e.group, Q = we.replace(
1067
+ new RegExp(`[${L.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")}]`, "g"),
1068
+ ""
1069
+ ), [ae, ie] = Q.split($);
1070
+ if (!ae)
1071
+ return Q;
1072
+ const ue = ae.replace(/\B(?=(\d{3})+(?!\d))/g, L);
1073
+ return ie != null ? `${ue}${$}${ie}` : ue;
1074
+ }, [we, be, Me, _e]), Pe = k(() => e ? te(e, { locale: m }) : "", [e, m]), pe = typeof f == "string" ? f : void 0, Ge = `nice-money-input nice-money-input--${h} nice-money-input--label-${O} nice-money-input--error-${Y}` + (pe ? " nice-money-input--error" : "") + (ee ? " nice-money-input--disabled" : "") + (g ? " nice-money-input--loading" : "") + (z ? ` ${z}` : ""), Ye = ($) => {
1075
+ q && $.key === "Enter" && ne && ($.preventDefault(), ne());
1076
+ }, Ze = O === "left" && Z != null ? { width: typeof Z == "number" ? `${Z}px` : Z, flex: "none" } : void 0, Je = R != null ? {
1077
+ width: typeof R == "number" ? `${R}px` : R,
984
1078
  flex: "none"
985
1079
  } : void 0;
986
- return /* @__PURE__ */ N("div", { ref: D, className: Ie, style: q, title: z, "data-testid": Z, children: [
987
- m && /* @__PURE__ */ N("label", { htmlFor: g, className: "nice-money-input__label", style: Pe, children: [
988
- m,
989
- j && /* @__PURE__ */ i("span", { className: "nice-money-input__required", "aria-hidden": !0, children: "*" })
1080
+ return I ? null : /* @__PURE__ */ N("div", { ref: le, className: Ge, style: P, title: A, "data-testid": oe, children: [
1081
+ p && /* @__PURE__ */ N("label", { htmlFor: D, className: "nice-money-input__label", style: Ze, children: [
1082
+ p,
1083
+ S && /* @__PURE__ */ s("span", { className: "nice-money-input__required", "aria-hidden": !0, children: "*" })
990
1084
  ] }),
991
- /* @__PURE__ */ N("div", { className: "nice-money-input__row", style: Ae, children: [
992
- !o && /* @__PURE__ */ i(
993
- Re,
1085
+ /* @__PURE__ */ N("div", { className: "nice-money-input__row", style: Je, children: [
1086
+ !o && /* @__PURE__ */ s(
1087
+ qe,
994
1088
  {
995
- value: w,
1089
+ value: C,
996
1090
  compact: !0,
997
- options: a ? a.map(L).filter((U) => !!U) : void 0,
998
- onChange: (U) => c == null ? void 0 : c(U),
999
- disabled: $ || B,
1091
+ options: a ? a.map(V).filter(($) => !!$) : void 0,
1092
+ onChange: ($) => r == null ? void 0 : r($),
1093
+ disabled: ee || w,
1000
1094
  className: "nice-money-input__currency",
1001
1095
  "aria-label": "Currency"
1002
1096
  }
1003
1097
  ),
1004
- o && /* @__PURE__ */ i("span", { className: "nice-money-input__symbol", "aria-hidden": !0, children: (k == null ? void 0 : k.symbol) ?? w }),
1005
- O && /* @__PURE__ */ i(
1098
+ o && /* @__PURE__ */ s("span", { className: "nice-money-input__symbol", "aria-hidden": !0, children: (ce == null ? void 0 : ce.symbol) ?? C }),
1099
+ J && /* @__PURE__ */ s(
1006
1100
  "button",
1007
1101
  {
1008
1102
  type: "button",
1009
1103
  className: "nice-money-input__step nice-money-input__step--down",
1010
- onClick: () => Ne(-S),
1011
- disabled: $ || B || u != null && e != null && e.amount / Math.pow(10, p) <= u,
1104
+ onClick: () => Re(-xe),
1105
+ disabled: ee || w || i != null && e != null && e.amount / Math.pow(10, G) <= i,
1012
1106
  "aria-label": "Decrease amount",
1013
1107
  tabIndex: -1,
1014
1108
  children: "−"
1015
1109
  }
1016
1110
  ),
1017
- /* @__PURE__ */ i(
1111
+ /* @__PURE__ */ s(
1018
1112
  "input",
1019
1113
  {
1020
- id: g,
1021
- name: K,
1114
+ id: D,
1115
+ name: se,
1022
1116
  type: "text",
1023
1117
  inputMode: "decimal",
1024
1118
  autoComplete: "transaction-amount",
1025
1119
  className: "nice-money-input__amount",
1026
- value: oe,
1027
- onChange: Ee,
1028
- onKeyDown: Fe,
1029
- onFocus: (U) => {
1030
- be(!0), C == null || C(U);
1120
+ value: ze,
1121
+ onChange: je,
1122
+ onKeyDown: Ye,
1123
+ onFocus: ($) => {
1124
+ Se(!0), U == null || U($);
1031
1125
  },
1032
- onBlur: (U) => {
1033
- be(!1), e && le((e.amount / Math.pow(10, p)).toFixed(p)), Y == null || Y(U);
1126
+ onBlur: ($) => {
1127
+ Se(!1), e && he((e.amount / Math.pow(10, G)).toFixed(G)), H == null || H($);
1034
1128
  },
1035
- placeholder: h ?? `0${p > 0 ? "." + "0".repeat(p) : ""}`,
1036
- disabled: $,
1037
- readOnly: B,
1038
- required: j,
1039
- "aria-invalid": !!ae,
1040
- "aria-describedby": ae || d ? `${g}-help` : void 0
1129
+ placeholder: b ?? `0${G > 0 ? "." + "0".repeat(G) : ""}`,
1130
+ disabled: ee,
1131
+ readOnly: w,
1132
+ required: S,
1133
+ "aria-invalid": !!pe,
1134
+ "aria-describedby": pe || d ? `${D}-help` : void 0
1041
1135
  }
1042
1136
  ),
1043
- O && /* @__PURE__ */ i(
1137
+ J && /* @__PURE__ */ s(
1044
1138
  "button",
1045
1139
  {
1046
1140
  type: "button",
1047
1141
  className: "nice-money-input__step nice-money-input__step--up",
1048
- onClick: () => Ne(S),
1049
- disabled: $ || B || l != null && e != null && e.amount / Math.pow(10, p) >= l,
1142
+ onClick: () => Re(xe),
1143
+ disabled: ee || w || l != null && e != null && e.amount / Math.pow(10, G) >= l,
1050
1144
  "aria-label": "Increase amount",
1051
1145
  tabIndex: -1,
1052
1146
  children: "+"
1053
1147
  }
1054
1148
  ),
1055
- I && /* @__PURE__ */ i("span", { className: "nice-money-input__spinner", "aria-hidden": !0, children: "⟳" })
1149
+ g && /* @__PURE__ */ s("span", { className: "nice-money-input__spinner", "aria-hidden": !0, children: "⟳" })
1056
1150
  ] }),
1057
- V && ge && /* @__PURE__ */ i("span", { className: "nice-money-input__preview", "aria-live": "polite", children: ge }),
1058
- (ae || d) && /* @__PURE__ */ i(
1151
+ E && Pe && /* @__PURE__ */ s("span", { className: "nice-money-input__preview", "aria-live": "polite", children: Pe }),
1152
+ (pe || d) && /* @__PURE__ */ s(
1059
1153
  "span",
1060
1154
  {
1061
- id: `${g}-help`,
1062
- className: ae ? "nice-money-input__error" : "nice-money-input__helper",
1063
- children: ae ?? d
1155
+ id: `${D}-help`,
1156
+ className: pe ? "nice-money-input__error" : "nice-money-input__helper",
1157
+ children: pe ?? d
1064
1158
  }
1065
1159
  )
1066
1160
  ] });
1067
1161
  }
1068
- ), ln = { number: "", expiry: "", cvc: "" }, un = te(
1162
+ ), Ut = { number: "", expiry: "", cvc: "" }, Rt = de(
1069
1163
  function({
1070
- value: e = ln,
1164
+ value: e = Ut,
1071
1165
  onChange: n,
1072
- showHolderName: t = !0,
1073
- requireHolderName: c,
1166
+ showHolderName: c = !0,
1167
+ requireHolderName: r,
1074
1168
  showPostalCode: a = !1,
1075
1169
  acceptedBrands: o,
1076
- showBrandIcon: u = !0,
1170
+ showBrandIcon: i = !0,
1077
1171
  size: l = "md",
1078
- disabled: s,
1079
- readOnly: y,
1080
- loading: h,
1081
- accessMode: m,
1172
+ disabled: u,
1173
+ readOnly: m,
1174
+ loading: b,
1175
+ accessMode: p,
1082
1176
  label: d,
1083
- helperText: b,
1084
- error: _,
1085
- required: f,
1086
- className: H,
1087
- style: j,
1088
- id: I,
1089
- title: F,
1090
- "data-testid": Q
1091
- }, X) {
1092
- if (m === "hidden")
1093
- return null;
1094
- const A = s || m === "disabled" || h, M = y || m === "readOnly", ne = ye(), x = I ?? `nice-cc-${ne}`, [V, O] = E({
1177
+ helperText: f,
1178
+ error: h,
1179
+ required: y,
1180
+ className: _,
1181
+ style: S,
1182
+ id: g,
1183
+ title: v,
1184
+ "data-testid": O
1185
+ }, Y) {
1186
+ const Z = p === "hidden", R = u || p === "disabled" || b, q = m || p === "readOnly", ne = Ce(), E = g ?? `nice-cc-${ne}`, [J, z] = B({
1095
1187
  number: !1,
1096
1188
  expiry: !1,
1097
1189
  cvc: !1,
1098
1190
  holder: !1,
1099
1191
  postal: !1
1100
- }), v = P(() => de(e.number), [e.number]), q = P(
1101
- () => we(e, { requireHolder: c ?? t }),
1102
- [e, c, t]
1103
- ), W = !o || o.includes(v) || v === "unknown", K = R(
1104
- (g) => {
1105
- const w = { ...e, ...g }, k = we(w, { requireHolder: c ?? t });
1106
- n == null || n(w, k);
1192
+ }), P = k(() => Ne(e.number), [e.number]), X = k(
1193
+ () => Ie(e, { requireHolder: r ?? c }),
1194
+ [e, r, c]
1195
+ ), se = !o || o.includes(P) || P === "unknown", A = F(
1196
+ (w) => {
1197
+ const I = { ...e, ...w }, re = Ie(I, { requireHolder: r ?? c });
1198
+ n == null || n(I, re);
1107
1199
  },
1108
- [e, c, t, n]
1109
- ), z = R(
1110
- (g) => {
1111
- const w = g.target.value.replace(/\D/g, "").slice(0, 19);
1112
- K({ number: w });
1200
+ [e, r, c, n]
1201
+ ), oe = F(
1202
+ (w) => {
1203
+ const I = w.target.value.replace(/\D/g, "").slice(0, 19);
1204
+ A({ number: I });
1113
1205
  },
1114
- [K]
1115
- ), Z = R(
1116
- (g) => {
1117
- const w = g.target.value.replace(/\D/g, "").slice(0, 4);
1118
- let k = w;
1119
- w.length >= 3 ? k = `${w.slice(0, 2)}/${w.slice(2)}` : w.length === 2 && (k = `${w}/`), K({ expiry: k });
1206
+ [A]
1207
+ ), H = F(
1208
+ (w) => {
1209
+ const I = w.target.value.replace(/\D/g, "").slice(0, 4);
1210
+ let re = I;
1211
+ I.length >= 3 ? re = `${I.slice(0, 2)}/${I.slice(2)}` : I.length === 2 && (re = `${I}/`), A({ expiry: re });
1120
1212
  },
1121
- [K]
1122
- ), Y = R(
1123
- (g) => {
1124
- const w = g.target.value.replace(/\D/g, "").slice(0, ie(v));
1125
- K({ cvc: w });
1213
+ [A]
1214
+ ), U = F(
1215
+ (w) => {
1216
+ const I = w.target.value.replace(/\D/g, "").slice(0, ye(P));
1217
+ A({ cvc: I });
1126
1218
  },
1127
- [v, K]
1128
- ), C = P(() => Ge(e.number, v), [e.number, v]), D = V.number && e.number.length > 0 && (Se(e.number) ? W ? void 0 : "Card brand not accepted" : q.errors.number), $ = V.expiry && e.expiry.length > 0 && !xe(e.expiry) ? q.errors.expiry : void 0, B = V.cvc && e.cvc.length > 0 && e.cvc.length !== ie(v) ? q.errors.cvc : void 0, ce = `nice-credit-card nice-credit-card--${l}` + (A ? " nice-credit-card--disabled" : "") + (h ? " nice-credit-card--loading" : "") + (_ ? " nice-credit-card--error" : "") + (H ? ` ${H}` : "");
1129
- return /* @__PURE__ */ N("div", { ref: X, className: ce, style: j, title: F, "data-testid": Q, children: [
1219
+ [P, A]
1220
+ ), M = k(() => ct(e.number, P), [e.number, P]), T = J.number && e.number.length > 0 && (Be(e.number) ? se ? void 0 : "Card brand not accepted" : X.errors.number), x = J.expiry && e.expiry.length > 0 && !Le(e.expiry) ? X.errors.expiry : void 0, le = J.cvc && e.cvc.length > 0 && e.cvc.length !== ye(P) ? X.errors.cvc : void 0, ee = `nice-credit-card nice-credit-card--${l}` + (R ? " nice-credit-card--disabled" : "") + (b ? " nice-credit-card--loading" : "") + (h ? " nice-credit-card--error" : "") + (_ ? ` ${_}` : "");
1221
+ return Z ? null : /* @__PURE__ */ N("div", { ref: Y, className: ee, style: S, title: v, "data-testid": O, children: [
1130
1222
  d && /* @__PURE__ */ N("div", { className: "nice-credit-card__title", children: [
1131
1223
  d,
1132
- f && /* @__PURE__ */ i("span", { className: "nice-credit-card__required", "aria-hidden": !0, children: "*" })
1224
+ y && /* @__PURE__ */ s("span", { className: "nice-credit-card__required", "aria-hidden": !0, children: "*" })
1133
1225
  ] }),
1134
- /* @__PURE__ */ i("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ N("label", { className: "nice-credit-card__field nice-credit-card__field--number", children: [
1135
- /* @__PURE__ */ i("span", { className: "nice-credit-card__label", children: "Card number" }),
1226
+ /* @__PURE__ */ s("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ N("label", { className: "nice-credit-card__field nice-credit-card__field--number", children: [
1227
+ /* @__PURE__ */ s("span", { className: "nice-credit-card__label", children: "Card number" }),
1136
1228
  /* @__PURE__ */ N("span", { className: "nice-credit-card__input-wrapper", children: [
1137
- /* @__PURE__ */ i(
1229
+ /* @__PURE__ */ s(
1138
1230
  "input",
1139
1231
  {
1140
- id: `${x}-number`,
1232
+ id: `${E}-number`,
1141
1233
  type: "text",
1142
1234
  inputMode: "numeric",
1143
1235
  autoComplete: "cc-number",
1144
- placeholder: v === "amex" ? "3782 822463 10005" : "1234 1234 1234 1234",
1145
- value: C,
1146
- onChange: z,
1147
- onBlur: () => O((g) => ({ ...g, number: !0 })),
1148
- disabled: A,
1149
- readOnly: M,
1150
- "aria-invalid": !!D,
1151
- "aria-describedby": D ? `${x}-number-err` : void 0,
1236
+ placeholder: P === "amex" ? "3782 822463 10005" : "1234 1234 1234 1234",
1237
+ value: M,
1238
+ onChange: oe,
1239
+ onBlur: () => z((w) => ({ ...w, number: !0 })),
1240
+ disabled: R,
1241
+ readOnly: q,
1242
+ "aria-invalid": !!T,
1243
+ "aria-describedby": T ? `${E}-number-err` : void 0,
1152
1244
  className: "nice-credit-card__input",
1153
- maxLength: v === "amex" ? 17 : 23
1245
+ maxLength: P === "amex" ? 17 : 23
1154
1246
  }
1155
1247
  ),
1156
- u && /* @__PURE__ */ i(dn, { brand: v })
1248
+ i && /* @__PURE__ */ s(Mt, { brand: P })
1157
1249
  ] }),
1158
- D && /* @__PURE__ */ i("span", { id: `${x}-number-err`, className: "nice-credit-card__error", children: D })
1250
+ T && /* @__PURE__ */ s("span", { id: `${E}-number-err`, className: "nice-credit-card__error", children: T })
1159
1251
  ] }) }),
1160
1252
  /* @__PURE__ */ N("div", { className: "nice-credit-card__row nice-credit-card__row--split", children: [
1161
1253
  /* @__PURE__ */ N("label", { className: "nice-credit-card__field", children: [
1162
- /* @__PURE__ */ i("span", { className: "nice-credit-card__label", children: "Expiry" }),
1163
- /* @__PURE__ */ i(
1254
+ /* @__PURE__ */ s("span", { className: "nice-credit-card__label", children: "Expiry" }),
1255
+ /* @__PURE__ */ s(
1164
1256
  "input",
1165
1257
  {
1166
- id: `${x}-expiry`,
1258
+ id: `${E}-expiry`,
1167
1259
  type: "text",
1168
1260
  inputMode: "numeric",
1169
1261
  autoComplete: "cc-exp",
1170
1262
  placeholder: "MM/YY",
1171
1263
  value: e.expiry,
1172
- onChange: Z,
1264
+ onChange: H,
1173
1265
  onBlur: () => {
1174
- O((w) => ({ ...w, expiry: !0 }));
1175
- const g = Ue(e.expiry);
1176
- g && g !== e.expiry && K({ expiry: g });
1266
+ z((I) => ({ ...I, expiry: !0 }));
1267
+ const w = Te(e.expiry);
1268
+ w && w !== e.expiry && A({ expiry: w });
1177
1269
  },
1178
- disabled: A,
1179
- readOnly: M,
1180
- "aria-invalid": !!$,
1181
- "aria-describedby": $ ? `${x}-expiry-err` : void 0,
1270
+ disabled: R,
1271
+ readOnly: q,
1272
+ "aria-invalid": !!x,
1273
+ "aria-describedby": x ? `${E}-expiry-err` : void 0,
1182
1274
  className: "nice-credit-card__input",
1183
1275
  maxLength: 5
1184
1276
  }
1185
1277
  ),
1186
- $ && /* @__PURE__ */ i("span", { id: `${x}-expiry-err`, className: "nice-credit-card__error", children: $ })
1278
+ x && /* @__PURE__ */ s("span", { id: `${E}-expiry-err`, className: "nice-credit-card__error", children: x })
1187
1279
  ] }),
1188
1280
  /* @__PURE__ */ N("label", { className: "nice-credit-card__field", children: [
1189
- /* @__PURE__ */ i("span", { className: "nice-credit-card__label", children: v === "amex" ? "CID" : "CVC" }),
1190
- /* @__PURE__ */ i(
1281
+ /* @__PURE__ */ s("span", { className: "nice-credit-card__label", children: P === "amex" ? "CID" : "CVC" }),
1282
+ /* @__PURE__ */ s(
1191
1283
  "input",
1192
1284
  {
1193
- id: `${x}-cvc`,
1285
+ id: `${E}-cvc`,
1194
1286
  type: "text",
1195
1287
  inputMode: "numeric",
1196
1288
  autoComplete: "cc-csc",
1197
- placeholder: "•".repeat(ie(v)),
1289
+ placeholder: "•".repeat(ye(P)),
1198
1290
  value: e.cvc,
1199
- onChange: Y,
1200
- onBlur: () => O((g) => ({ ...g, cvc: !0 })),
1201
- disabled: A,
1202
- readOnly: M,
1203
- "aria-invalid": !!B,
1204
- "aria-describedby": B ? `${x}-cvc-err` : void 0,
1291
+ onChange: U,
1292
+ onBlur: () => z((w) => ({ ...w, cvc: !0 })),
1293
+ disabled: R,
1294
+ readOnly: q,
1295
+ "aria-invalid": !!le,
1296
+ "aria-describedby": le ? `${E}-cvc-err` : void 0,
1205
1297
  className: "nice-credit-card__input",
1206
- maxLength: ie(v)
1298
+ maxLength: ye(P)
1207
1299
  }
1208
1300
  ),
1209
- B && /* @__PURE__ */ i("span", { id: `${x}-cvc-err`, className: "nice-credit-card__error", children: B })
1301
+ le && /* @__PURE__ */ s("span", { id: `${E}-cvc-err`, className: "nice-credit-card__error", children: le })
1210
1302
  ] })
1211
1303
  ] }),
1212
- t && /* @__PURE__ */ i("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ N("label", { className: "nice-credit-card__field", children: [
1213
- /* @__PURE__ */ i("span", { className: "nice-credit-card__label", children: "Cardholder name" }),
1214
- /* @__PURE__ */ i(
1304
+ c && /* @__PURE__ */ s("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ N("label", { className: "nice-credit-card__field", children: [
1305
+ /* @__PURE__ */ s("span", { className: "nice-credit-card__label", children: "Cardholder name" }),
1306
+ /* @__PURE__ */ s(
1215
1307
  "input",
1216
1308
  {
1217
- id: `${x}-holder`,
1309
+ id: `${E}-holder`,
1218
1310
  type: "text",
1219
1311
  autoComplete: "cc-name",
1220
1312
  placeholder: "Jane Doe",
1221
1313
  value: e.holderName ?? "",
1222
- onChange: (g) => K({ holderName: g.target.value }),
1223
- onBlur: () => O((g) => ({ ...g, holder: !0 })),
1224
- disabled: A,
1225
- readOnly: M,
1314
+ onChange: (w) => A({ holderName: w.target.value }),
1315
+ onBlur: () => z((w) => ({ ...w, holder: !0 })),
1316
+ disabled: R,
1317
+ readOnly: q,
1226
1318
  className: "nice-credit-card__input",
1227
1319
  maxLength: 120
1228
1320
  }
1229
1321
  )
1230
1322
  ] }) }),
1231
- a && /* @__PURE__ */ i("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ N("label", { className: "nice-credit-card__field", children: [
1232
- /* @__PURE__ */ i("span", { className: "nice-credit-card__label", children: "Postal code" }),
1233
- /* @__PURE__ */ i(
1323
+ a && /* @__PURE__ */ s("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ N("label", { className: "nice-credit-card__field", children: [
1324
+ /* @__PURE__ */ s("span", { className: "nice-credit-card__label", children: "Postal code" }),
1325
+ /* @__PURE__ */ s(
1234
1326
  "input",
1235
1327
  {
1236
- id: `${x}-postal`,
1328
+ id: `${E}-postal`,
1237
1329
  type: "text",
1238
1330
  autoComplete: "postal-code",
1239
1331
  value: e.postalCode ?? "",
1240
- onChange: (g) => K({ postalCode: g.target.value }),
1241
- onBlur: () => O((g) => ({ ...g, postal: !0 })),
1242
- disabled: A,
1243
- readOnly: M,
1332
+ onChange: (w) => A({ postalCode: w.target.value }),
1333
+ onBlur: () => z((w) => ({ ...w, postal: !0 })),
1334
+ disabled: R,
1335
+ readOnly: q,
1244
1336
  className: "nice-credit-card__input",
1245
1337
  maxLength: 16
1246
1338
  }
1247
1339
  )
1248
1340
  ] }) }),
1249
- (_ || b) && /* @__PURE__ */ i(
1341
+ (h || f) && /* @__PURE__ */ s(
1250
1342
  "div",
1251
1343
  {
1252
- className: _ ? "nice-credit-card__form-error" : "nice-credit-card__helper",
1253
- role: _ ? "alert" : void 0,
1254
- children: _ ?? b
1344
+ className: h ? "nice-credit-card__form-error" : "nice-credit-card__helper",
1345
+ role: h ? "alert" : void 0,
1346
+ children: h ?? f
1255
1347
  }
1256
1348
  )
1257
1349
  ] });
1258
1350
  }
1259
- ), Ce = {
1351
+ ), Ee = {
1260
1352
  visa: "VISA",
1261
1353
  mastercard: "MasterCard",
1262
1354
  amex: "AMEX",
@@ -1270,305 +1362,406 @@ const De = te(function({
1270
1362
  hipercard: "Hipercard",
1271
1363
  unknown: ""
1272
1364
  };
1273
- function dn({ brand: r }) {
1274
- return r === "unknown" ? null : /* @__PURE__ */ i(
1365
+ function Mt({ brand: t }) {
1366
+ return t === "unknown" ? null : /* @__PURE__ */ s(
1275
1367
  "span",
1276
1368
  {
1277
- className: `nice-credit-card__brand nice-credit-card__brand--${r}`,
1278
- "aria-label": Ce[r],
1279
- children: Ce[r]
1369
+ className: `nice-credit-card__brand nice-credit-card__brand--${t}`,
1370
+ "aria-label": Ee[t],
1371
+ children: Ee[t]
1280
1372
  }
1281
1373
  );
1282
1374
  }
1283
- const Rn = te(
1375
+ const Jt = de(
1284
1376
  function({
1285
1377
  processor: e,
1286
1378
  amount: n,
1287
- editableAmount: t,
1288
- customer: c,
1379
+ editableAmount: c,
1380
+ customer: r,
1289
1381
  currencies: a,
1290
1382
  description: o,
1291
- metadata: u,
1383
+ metadata: i,
1292
1384
  autoCapture: l = !0,
1293
- submitLabel: s = "Pay",
1294
- onSuccess: y,
1295
- onError: h,
1296
- consents: m,
1385
+ submitLabel: u = "Pay",
1386
+ onSuccess: m,
1387
+ onError: b,
1388
+ consents: p,
1297
1389
  className: d,
1298
- style: b
1299
- }, _) {
1300
- const [f, H] = E(n), [j, I] = E(n.currency), [F, Q] = E({ number: "", expiry: "", cvc: "" }), [X, A] = E(null), [M, ne] = E(!1), [x, V] = E(null), O = on(e), v = P(() => e.supportedCurrencies === "*" ? !0 : e.supportedCurrencies.includes(f.currency.toUpperCase()), [e, f.currency]), q = P(() => {
1301
- var D;
1302
- const C = (D = e.minimums) == null ? void 0 : D[f.currency.toUpperCase()];
1303
- return C == null || f.amount >= C;
1304
- }, [e, f]), W = P(() => {
1305
- var D;
1306
- const C = (D = e.minimums) == null ? void 0 : D[f.currency.toUpperCase()];
1307
- return C == null ? null : { amount: C, currency: f.currency };
1308
- }, [e, f.currency]), K = !!(X != null && X.isValid), z = !M && v && q && K, Z = R(
1309
- async (C) => {
1310
- if (C.preventDefault(), !!z) {
1311
- V(null), ne(!0);
1390
+ style: f
1391
+ }, h) {
1392
+ const [y, _] = B(n), [S, g] = B(n.currency), [v, O] = B({ number: "", expiry: "", cvc: "" }), [Y, Z] = B(null), [R, q] = B(!1), [ne, E] = B(null), J = St(e), z = k(() => e.supportedCurrencies === "*" ? !0 : e.supportedCurrencies.includes(y.currency.toUpperCase()), [e, y.currency]), P = k(() => {
1393
+ var M;
1394
+ const U = (M = e.minimums) == null ? void 0 : M[y.currency.toUpperCase()];
1395
+ return U == null || y.amount >= U;
1396
+ }, [e, y]), X = k(() => {
1397
+ var M;
1398
+ const U = (M = e.minimums) == null ? void 0 : M[y.currency.toUpperCase()];
1399
+ return U == null ? null : { amount: U, currency: y.currency };
1400
+ }, [e, y.currency]), se = !!(Y != null && Y.isValid), A = !R && z && P && se, oe = F(
1401
+ async (U) => {
1402
+ if (U.preventDefault(), !!A) {
1403
+ E(null), q(!0);
1312
1404
  try {
1313
- const D = {
1314
- amount: f,
1315
- card: F,
1316
- customer: c,
1405
+ const M = {
1406
+ amount: y,
1407
+ card: v,
1408
+ customer: r,
1317
1409
  description: o,
1318
- metadata: u,
1319
- idempotencyKey: mn()
1320
- }, $ = await O.authorize(D);
1321
- if (l && $.status === "authorized") {
1322
- const B = await O.capture($.id, f);
1323
- y == null || y(B);
1410
+ metadata: i,
1411
+ idempotencyKey: Pt()
1412
+ }, T = await J.authorize(M);
1413
+ if (l && T.status === "authorized") {
1414
+ const x = await J.capture(T.id, y);
1415
+ m == null || m(x);
1324
1416
  } else
1325
- y == null || y($);
1326
- } catch (D) {
1327
- const $ = D instanceof Error ? D : new Error(String(D));
1328
- V($.message), h == null || h($);
1417
+ m == null || m(T);
1418
+ } catch (M) {
1419
+ const T = M instanceof Error ? M : new Error(String(M));
1420
+ E(T.message), b == null || b(T);
1329
1421
  } finally {
1330
- ne(!1);
1422
+ q(!1);
1331
1423
  }
1332
1424
  }
1333
1425
  },
1334
1426
  [
1335
- z,
1336
- f,
1337
- F,
1338
- c,
1427
+ A,
1428
+ y,
1429
+ v,
1430
+ r,
1339
1431
  o,
1340
- u,
1432
+ i,
1341
1433
  l,
1342
- O,
1343
- y,
1344
- h
1434
+ J,
1435
+ m,
1436
+ b
1345
1437
  ]
1346
- ), Y = L(f.currency);
1438
+ ), H = V(y.currency);
1347
1439
  return /* @__PURE__ */ N(
1348
1440
  "form",
1349
1441
  {
1350
- ref: _,
1442
+ ref: h,
1351
1443
  className: "nice-payment-form" + (d ? ` ${d}` : ""),
1352
- style: b,
1353
- onSubmit: Z,
1354
- "aria-busy": M,
1444
+ style: f,
1445
+ onSubmit: oe,
1446
+ "aria-busy": R,
1355
1447
  children: [
1356
- /* @__PURE__ */ i("div", { className: "nice-payment-form__amount", children: t ? /* @__PURE__ */ i(
1357
- Me,
1448
+ /* @__PURE__ */ s("div", { className: "nice-payment-form__amount", children: c ? /* @__PURE__ */ s(
1449
+ He,
1358
1450
  {
1359
1451
  label: "Amount",
1360
- value: f,
1361
- currency: j,
1452
+ value: y,
1453
+ currency: S,
1362
1454
  currencies: a,
1363
- onChange: (C) => C && H(C),
1364
- onCurrencyChange: (C) => {
1365
- I(C), H((D) => ({ ...D, currency: C }));
1455
+ onChange: (U) => U && _(U),
1456
+ onCurrencyChange: (U) => {
1457
+ g(U), _((M) => ({ ...M, currency: U }));
1366
1458
  },
1367
- disabled: M,
1459
+ disabled: R,
1368
1460
  required: !0,
1369
1461
  showFormattedPreview: !0
1370
1462
  }
1371
1463
  ) : /* @__PURE__ */ N("div", { className: "nice-payment-form__total", children: [
1372
- /* @__PURE__ */ i("span", { className: "nice-payment-form__total-label", children: "Total" }),
1373
- /* @__PURE__ */ i(De, { value: f })
1464
+ /* @__PURE__ */ s("span", { className: "nice-payment-form__total-label", children: "Total" }),
1465
+ /* @__PURE__ */ s(Fe, { value: y })
1374
1466
  ] }) }),
1375
- o && /* @__PURE__ */ i("p", { className: "nice-payment-form__description", children: o }),
1376
- /* @__PURE__ */ i("div", { className: "nice-payment-form__card", children: /* @__PURE__ */ i(
1377
- un,
1467
+ o && /* @__PURE__ */ s("p", { className: "nice-payment-form__description", children: o }),
1468
+ /* @__PURE__ */ s("div", { className: "nice-payment-form__card", children: /* @__PURE__ */ s(
1469
+ Rt,
1378
1470
  {
1379
- value: F,
1380
- onChange: (C, D) => {
1381
- Q(C), A(D);
1471
+ value: v,
1472
+ onChange: (U, M) => {
1473
+ O(U), Z(M);
1382
1474
  },
1383
- disabled: M
1475
+ disabled: R
1384
1476
  }
1385
1477
  ) }),
1386
- !v && /* @__PURE__ */ N("div", { className: "nice-payment-form__warning", role: "alert", children: [
1478
+ !z && /* @__PURE__ */ N("div", { className: "nice-payment-form__warning", role: "alert", children: [
1387
1479
  e.name,
1388
1480
  " does not accept ",
1389
- (Y == null ? void 0 : Y.name) ?? f.currency,
1481
+ (H == null ? void 0 : H.name) ?? y.currency,
1390
1482
  "."
1391
1483
  ] }),
1392
- !q && W && /* @__PURE__ */ N("div", { className: "nice-payment-form__warning", role: "alert", children: [
1484
+ !P && X && /* @__PURE__ */ N("div", { className: "nice-payment-form__warning", role: "alert", children: [
1393
1485
  "Minimum charge for ",
1394
1486
  e.name,
1395
1487
  " is ",
1396
- /* @__PURE__ */ i(De, { value: W }),
1488
+ /* @__PURE__ */ s(Fe, { value: X }),
1397
1489
  "."
1398
1490
  ] }),
1399
- m && /* @__PURE__ */ i("div", { className: "nice-payment-form__consents", children: m }),
1400
- x && /* @__PURE__ */ i("div", { className: "nice-payment-form__error", role: "alert", children: x }),
1401
- /* @__PURE__ */ i(
1491
+ p && /* @__PURE__ */ s("div", { className: "nice-payment-form__consents", children: p }),
1492
+ ne && /* @__PURE__ */ s("div", { className: "nice-payment-form__error", role: "alert", children: ne }),
1493
+ /* @__PURE__ */ s(
1402
1494
  "button",
1403
1495
  {
1404
1496
  type: "submit",
1405
1497
  className: "nice-payment-form__submit",
1406
- disabled: !z,
1407
- "aria-disabled": !z,
1408
- children: M ? "Processing…" : s
1498
+ disabled: !A,
1499
+ "aria-disabled": !A,
1500
+ children: R ? "Processing…" : u
1409
1501
  }
1410
1502
  ),
1411
1503
  /* @__PURE__ */ N("p", { className: "nice-payment-form__processor", children: [
1412
1504
  "Secured by ",
1413
- /* @__PURE__ */ i("strong", { children: e.name })
1505
+ /* @__PURE__ */ s("strong", { children: e.name })
1414
1506
  ] })
1415
1507
  ]
1416
1508
  }
1417
1509
  );
1418
1510
  }
1419
1511
  );
1420
- function mn() {
1512
+ function Pt() {
1421
1513
  return typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `idem_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`;
1422
1514
  }
1423
- const Mn = te(function({
1515
+ const Xt = de(function({
1424
1516
  price: e,
1425
1517
  originalPrice: n,
1426
- period: t,
1427
- prefix: c,
1518
+ period: c,
1519
+ prefix: r,
1428
1520
  suffix: a,
1429
1521
  showDiscountBadge: o = !0,
1430
- size: u = "md",
1522
+ size: i = "md",
1431
1523
  locale: l,
1432
- className: s,
1433
- style: y
1434
- }, h) {
1435
- const m = n && n.currency === e.currency && n.amount > e.amount, d = P(() => !m || !n ? null : Math.round((n.amount - e.amount) / n.amount * 100), [m, n, e.amount]), b = `nice-price-tag nice-price-tag--${u}` + (s ? ` ${s}` : "");
1436
- return /* @__PURE__ */ N("div", { ref: h, className: b, style: y, children: [
1437
- c && /* @__PURE__ */ i("span", { className: "nice-price-tag__prefix", children: c }),
1524
+ className: u,
1525
+ style: m
1526
+ }, b) {
1527
+ const p = n && n.currency === e.currency && n.amount > e.amount, d = k(() => !p || !n ? null : Math.round((n.amount - e.amount) / n.amount * 100), [p, n, e.amount]), f = `nice-price-tag nice-price-tag--${i}` + (u ? ` ${u}` : "");
1528
+ return /* @__PURE__ */ N("div", { ref: b, className: f, style: m, children: [
1529
+ r && /* @__PURE__ */ s("span", { className: "nice-price-tag__prefix", children: r }),
1438
1530
  /* @__PURE__ */ N("span", { className: "nice-price-tag__main", children: [
1439
- /* @__PURE__ */ i("span", { className: "nice-price-tag__amount", children: ee(e, { locale: l }) }),
1440
- t && /* @__PURE__ */ i("span", { className: "nice-price-tag__period", children: t })
1531
+ /* @__PURE__ */ s("span", { className: "nice-price-tag__amount", children: te(e, { locale: l }) }),
1532
+ c && /* @__PURE__ */ s("span", { className: "nice-price-tag__period", children: c })
1441
1533
  ] }),
1442
- m && n && /* @__PURE__ */ i("span", { className: "nice-price-tag__original", "aria-label": "Original price", children: /* @__PURE__ */ i("s", { children: ee(n, { locale: l }) }) }),
1443
- m && o && d != null && d > 0 && /* @__PURE__ */ N("span", { className: "nice-price-tag__discount", "aria-label": `${d} percent off`, children: [
1534
+ p && n && /* @__PURE__ */ s("span", { className: "nice-price-tag__original", "aria-label": "Original price", children: /* @__PURE__ */ s("s", { children: te(n, { locale: l }) }) }),
1535
+ p && o && d != null && d > 0 && /* @__PURE__ */ N("span", { className: "nice-price-tag__discount", "aria-label": `${d} percent off`, children: [
1444
1536
  "−",
1445
1537
  d,
1446
1538
  "%"
1447
1539
  ] }),
1448
- a && /* @__PURE__ */ i("span", { className: "nice-price-tag__suffix", children: a })
1540
+ a && /* @__PURE__ */ s("span", { className: "nice-price-tag__suffix", children: a })
1449
1541
  ] });
1450
- }), En = te(
1542
+ }), Qt = de(
1451
1543
  function({
1452
1544
  source: e,
1453
1545
  onSourceChange: n,
1454
- targetCurrency: t,
1455
- onTargetCurrencyChange: c,
1546
+ targetCurrency: c,
1547
+ onTargetCurrencyChange: r,
1456
1548
  provider: a,
1457
1549
  locale: o,
1458
- showRateLine: u = !0,
1550
+ showRateLine: i = !0,
1459
1551
  className: l,
1460
- style: s
1461
- }, y) {
1462
- const { converted: h, loading: m, error: d } = me(e, t, a), b = P(
1552
+ style: u
1553
+ }, m) {
1554
+ const { converted: b, loading: p, error: d } = ve(e, c, a), f = k(
1463
1555
  () => ({ amount: Math.pow(10, 2), currency: e.currency }),
1464
1556
  [e.currency]
1465
- ), { converted: _ } = me(
1466
- u ? b : null,
1467
- t,
1557
+ ), { converted: h } = ve(
1558
+ i ? f : null,
1559
+ c,
1468
1560
  a
1469
1561
  );
1470
1562
  return /* @__PURE__ */ N(
1471
1563
  "div",
1472
1564
  {
1473
- ref: y,
1565
+ ref: m,
1474
1566
  className: "nice-currency-converter" + (l ? ` ${l}` : ""),
1475
- style: s,
1567
+ style: u,
1476
1568
  children: [
1477
- /* @__PURE__ */ i("div", { className: "nice-currency-converter__row", children: /* @__PURE__ */ i(
1478
- Me,
1569
+ /* @__PURE__ */ s("div", { className: "nice-currency-converter__row", children: /* @__PURE__ */ s(
1570
+ He,
1479
1571
  {
1480
1572
  label: "From",
1481
1573
  value: e,
1482
- onChange: (f) => f && n(f),
1574
+ onChange: (y) => y && n(y),
1483
1575
  currency: e.currency,
1484
- onCurrencyChange: (f) => n({ ...e, currency: f }),
1576
+ onCurrencyChange: (y) => n({ ...e, currency: y }),
1485
1577
  showFormattedPreview: !1
1486
1578
  }
1487
1579
  ) }),
1488
1580
  /* @__PURE__ */ N("div", { className: "nice-currency-converter__row", children: [
1489
- /* @__PURE__ */ i("label", { className: "nice-currency-converter__label", children: "To" }),
1581
+ /* @__PURE__ */ s("label", { className: "nice-currency-converter__label", children: "To" }),
1490
1582
  /* @__PURE__ */ N("div", { className: "nice-currency-converter__output", children: [
1491
- /* @__PURE__ */ i(
1492
- Re,
1583
+ /* @__PURE__ */ s(
1584
+ qe,
1493
1585
  {
1494
- value: t,
1495
- onChange: (f) => c(f),
1586
+ value: c,
1587
+ onChange: (y) => r(y),
1496
1588
  compact: !0
1497
1589
  }
1498
1590
  ),
1499
- /* @__PURE__ */ i("span", { className: "nice-currency-converter__amount", children: m ? "…" : d ? "—" : h ? ee(h, { locale: o }) : "" })
1591
+ /* @__PURE__ */ s("span", { className: "nice-currency-converter__amount", children: p ? "…" : d ? "—" : b ? te(b, { locale: o }) : "" })
1500
1592
  ] })
1501
1593
  ] }),
1502
- u && _ && /* @__PURE__ */ N("p", { className: "nice-currency-converter__rate", children: [
1594
+ i && h && /* @__PURE__ */ N("p", { className: "nice-currency-converter__rate", children: [
1503
1595
  "1 ",
1504
1596
  e.currency,
1505
1597
  " = ",
1506
- ee(_, { locale: o }),
1598
+ te(h, { locale: o }),
1507
1599
  " ",
1508
1600
  /* @__PURE__ */ N("span", { className: "nice-currency-converter__inverse", children: [
1509
1601
  "· 1 ",
1510
- t,
1602
+ c,
1511
1603
  " =",
1512
1604
  " ",
1513
- ee(re(1 / $e(_), e.currency), { locale: o })
1605
+ te(W(1 / Ke(h), e.currency), { locale: o })
1514
1606
  ] })
1515
1607
  ] }),
1516
- d && /* @__PURE__ */ i("p", { className: "nice-currency-converter__error", role: "alert", children: d.message })
1608
+ d && /* @__PURE__ */ s("p", { className: "nice-currency-converter__error", role: "alert", children: d.message })
1609
+ ]
1610
+ }
1611
+ );
1612
+ }
1613
+ );
1614
+ function Ae(t) {
1615
+ return { amount: Math.round(t.amount), currency: t.currency };
1616
+ }
1617
+ const Vt = de(
1618
+ function({
1619
+ lines: e,
1620
+ locale: n,
1621
+ rounding: c = "line",
1622
+ showTotals: r = !0,
1623
+ showGrandTotal: a = !0,
1624
+ hideRateColumn: o = !1,
1625
+ labels: i,
1626
+ density: l = "comfortable",
1627
+ className: u,
1628
+ style: m,
1629
+ id: b
1630
+ }, p) {
1631
+ const d = {
1632
+ label: (i == null ? void 0 : i.label) ?? "Item",
1633
+ rate: (i == null ? void 0 : i.rate) ?? "VAT",
1634
+ net: (i == null ? void 0 : i.net) ?? "Net",
1635
+ vat: (i == null ? void 0 : i.vat) ?? "Tax",
1636
+ gross: (i == null ? void 0 : i.gross) ?? "Gross",
1637
+ total: (i == null ? void 0 : i.total) ?? "Total"
1638
+ }, f = k(() => {
1639
+ if (c === "total") {
1640
+ const _ = /* @__PURE__ */ new Map();
1641
+ for (const g of e) {
1642
+ let v = _.get(g.vatRate);
1643
+ v || (v = [], _.set(g.vatRate, v)), v.push(g.netAmount);
1644
+ }
1645
+ const S = [];
1646
+ for (const [g, v] of _) {
1647
+ const O = v.reduce((R, q) => me(R, q), W(0, v[0].currency)), Y = Ae(De(O, g)), Z = me(O, Y);
1648
+ S.push({ rate: g, net: O, vat: Y, gross: Z });
1649
+ }
1650
+ return S;
1651
+ }
1652
+ return e.map((_) => {
1653
+ const S = Ae(De(_.netAmount, _.vatRate)), g = me(_.netAmount, S);
1654
+ return { label: _.label, rate: _.vatRate, net: _.netAmount, vat: S, gross: g };
1655
+ });
1656
+ }, [e, c]), h = k(() => {
1657
+ if (f.length === 0)
1658
+ return null;
1659
+ const _ = f[0].net.currency;
1660
+ let S = W(0, _), g = W(0, _), v = W(0, _);
1661
+ for (const O of f)
1662
+ S = me(S, O.net), g = me(g, O.vat), v = me(v, O.gross);
1663
+ return { net: S, vat: g, gross: v };
1664
+ }, [f]), y = (_) => te(_, { locale: n });
1665
+ return /* @__PURE__ */ N(
1666
+ "table",
1667
+ {
1668
+ ref: p,
1669
+ id: b,
1670
+ className: `nice-tax-breakdown nice-tax-breakdown--${l} ${u ?? ""}`,
1671
+ style: m,
1672
+ role: "table",
1673
+ "aria-label": d.total,
1674
+ children: [
1675
+ /* @__PURE__ */ s("thead", { children: /* @__PURE__ */ N("tr", { children: [
1676
+ f.some((_) => _.label !== void 0) && /* @__PURE__ */ s("th", { scope: "col", children: d.label }),
1677
+ !o && /* @__PURE__ */ s("th", { scope: "col", className: "nice-tax-breakdown__rate", children: d.rate }),
1678
+ /* @__PURE__ */ s("th", { scope: "col", className: "nice-tax-breakdown__num", children: d.net }),
1679
+ /* @__PURE__ */ s("th", { scope: "col", className: "nice-tax-breakdown__num", children: d.vat }),
1680
+ /* @__PURE__ */ s("th", { scope: "col", className: "nice-tax-breakdown__num", children: d.gross })
1681
+ ] }) }),
1682
+ /* @__PURE__ */ s("tbody", { children: f.map((_, S) => /* @__PURE__ */ N("tr", { children: [
1683
+ f.some((g) => g.label !== void 0) && /* @__PURE__ */ s("td", { children: _.label ?? "" }),
1684
+ !o && /* @__PURE__ */ N("td", { className: "nice-tax-breakdown__rate", children: [
1685
+ (_.rate * 100).toLocaleString(n, { maximumFractionDigits: 2 }),
1686
+ "%"
1687
+ ] }),
1688
+ /* @__PURE__ */ s("td", { className: "nice-tax-breakdown__num", children: y(_.net) }),
1689
+ /* @__PURE__ */ s("td", { className: "nice-tax-breakdown__num", children: y(_.vat) }),
1690
+ /* @__PURE__ */ s("td", { className: "nice-tax-breakdown__num", children: y(_.gross) })
1691
+ ] }, `${_.rate}-${S}`)) }),
1692
+ r && h && /* @__PURE__ */ s("tfoot", { children: a && /* @__PURE__ */ N("tr", { className: "nice-tax-breakdown__totals", children: [
1693
+ f.some((_) => _.label !== void 0) && /* @__PURE__ */ s("td", { children: d.total }),
1694
+ !o && /* @__PURE__ */ s("td", {}),
1695
+ /* @__PURE__ */ s("td", { className: "nice-tax-breakdown__num", children: y(h.net) }),
1696
+ /* @__PURE__ */ s("td", { className: "nice-tax-breakdown__num", children: y(h.vat) }),
1697
+ /* @__PURE__ */ s("td", { className: "nice-tax-breakdown__num", children: y(h.gross) })
1698
+ ] }) })
1517
1699
  ]
1518
1700
  }
1519
1701
  );
1520
1702
  }
1521
1703
  );
1522
1704
  export {
1523
- $n as ExchangeRateHostProvider,
1524
- Cn as FrankfurterProvider,
1525
- Ze as MockPaymentProcessor,
1526
- se as NICE_CURRENCY_CATALOG,
1527
- xn as NICE_CURRENCY_CODES,
1528
- Sn as NICE_PAYMENT_PROCESSORS,
1529
- un as NiceCreditCardInput,
1530
- En as NiceCurrencyConverter,
1531
- Re as NiceCurrencySelector,
1532
- De as NiceMoney,
1533
- Me as NiceMoneyInput,
1534
- Rn as NicePaymentForm,
1535
- Mn as NicePriceTag,
1536
- vn as OpenExchangeRatesProvider,
1537
- Dn as StaticExchangeRateProvider,
1538
- He as addMoney,
1539
- bn as compareMoney,
1540
- Ve as convertMoney,
1541
- de as detectCardBrand,
1542
- ie as expectedCvcLength,
1543
- L as findCurrency,
1544
- Ge as formatCardNumber,
1545
- ee as formatMoney,
1546
- $e as fromMoney,
1547
- xe as isExpiryValid,
1548
- Nn as isNegative,
1549
- _n as isZero,
1550
- Se as luhnCheck,
1551
- Xe as makeAdyenAdapter,
1552
- nn as makeBraintreeAdapter,
1553
- sn as makeCoinbaseCommerceAdapter,
1554
- an as makeKlarnaAdapter,
1555
- en as makeMollieAdapter,
1556
- Qe as makePayPalAdapter,
1557
- tn as makePayUAdapter,
1558
- cn as makePrzelewy24Adapter,
1559
- rn as makeRazorpayAdapter,
1560
- We as makeSquareAdapter,
1561
- Je as makeStripeAdapter,
1562
- wn as maskCardNumber,
1563
- ze as multiplyMoney,
1564
- gn as negateMoney,
1565
- Ue as normaliseExpiry,
1566
- Ye as parseMoney,
1567
- fn as registerCurrency,
1568
- je as subtractMoney,
1569
- re as toMoney,
1570
- me as useNiceExchangeRate,
1571
- Un as useNiceMoney,
1572
- on as useNicePayment,
1573
- we as validateCreditCard
1705
+ lt as EcbRatesProvider,
1706
+ st as ExchangeRateHostProvider,
1707
+ at as FrankfurterProvider,
1708
+ ut as FreeForexApiProvider,
1709
+ mt as MockPaymentProcessor,
1710
+ fe as NICE_CURRENCY_CATALOG,
1711
+ Zt as NICE_CURRENCY_CODES,
1712
+ Gt as NICE_PAYMENT_PROCESSORS,
1713
+ ot as NbpRatesProvider,
1714
+ Rt as NiceCreditCardInput,
1715
+ Qt as NiceCurrencyConverter,
1716
+ qe as NiceCurrencySelector,
1717
+ Fe as NiceMoney,
1718
+ He as NiceMoneyInput,
1719
+ Jt as NicePaymentForm,
1720
+ Xt as NicePriceTag,
1721
+ Vt as NiceTaxBreakdown,
1722
+ it as OpenExchangeRatesProvider,
1723
+ Lt as StaticExchangeRateProvider,
1724
+ me as addMoney,
1725
+ At as compareMoney,
1726
+ dt as convertMoney,
1727
+ Ht as createEcbRatesProvider,
1728
+ zt as createFreeForexApiProvider,
1729
+ qt as createNbpRatesProvider,
1730
+ jt as createOpenExchangeRatesProvider,
1731
+ Ne as detectCardBrand,
1732
+ ye as expectedCvcLength,
1733
+ V as findCurrency,
1734
+ ct as formatCardNumber,
1735
+ te as formatMoney,
1736
+ Ke as fromMoney,
1737
+ Le as isExpiryValid,
1738
+ Kt as isNegative,
1739
+ Ot as isZero,
1740
+ Be as luhnCheck,
1741
+ ft as makeAdyenAdapter,
1742
+ vt as makeAutopayAdapter,
1743
+ Ct as makeBlikAdapter,
1744
+ _t as makeBraintreeAdapter,
1745
+ xt as makeCoinbaseCommerceAdapter,
1746
+ $t as makeKlarnaAdapter,
1747
+ bt as makeMollieAdapter,
1748
+ yt as makePayPalAdapter,
1749
+ gt as makePayUAdapter,
1750
+ wt as makePrzelewy24Adapter,
1751
+ Nt as makeRazorpayAdapter,
1752
+ ht as makeSquareAdapter,
1753
+ pt as makeStripeAdapter,
1754
+ Dt as makeTpayAdapter,
1755
+ Tt as maskCardNumber,
1756
+ De as multiplyMoney,
1757
+ Bt as negateMoney,
1758
+ Te as normaliseExpiry,
1759
+ rt as parseMoney,
1760
+ Et as registerCurrency,
1761
+ nt as subtractMoney,
1762
+ W as toMoney,
1763
+ ve as useNiceExchangeRate,
1764
+ Yt as useNiceMoney,
1765
+ St as useNicePayment,
1766
+ Ie as validateCreditCard
1574
1767
  };