@nice2dev/ui-money 1.0.21 → 1.0.23

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,10 @@
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 = [
1
+ var Qe = Object.defineProperty;
2
+ var We = (t, e, n) => e in t ? Qe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var H = (t, e, n) => We(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import Ve, { useState as F, useRef as et, useEffect as tt, useMemo as q, useCallback as L, forwardRef as ie, useId as be } from "react";
5
+ import { jsxs as h, jsx as c, Fragment as nt } from "react/jsx-runtime";
6
+ import { NiceTutorialButton as rt, resolveTutorial as at } from "@nice2dev/ui-core";
7
+ const he = [
7
8
  // ── Majors ─────────────────────────────────────
8
9
  { code: "USD", numeric: 840, symbol: "$", name: "US Dollar", decimals: 2, symbolFirst: !0 },
9
10
  { code: "EUR", numeric: 978, symbol: "€", name: "Euro", decimals: 2, symbolFirst: !0 },
@@ -225,35 +226,35 @@ const fe = [
225
226
  { code: "ETH", numeric: 0, symbol: "Ξ", name: "Ether", decimals: 8, symbolFirst: !0 },
226
227
  { code: "USDC", numeric: 0, symbol: "USDC", name: "USD Coin", decimals: 6 },
227
228
  { code: "USDT", numeric: 0, symbol: "USDT", name: "Tether", decimals: 6 }
228
- ], Oe = new Map(fe.map((t) => [t.code, t]));
229
+ ], Ke = new Map(he.map((t) => [t.code, t]));
229
230
  function V(t) {
230
- return Oe.get(t.toUpperCase());
231
+ return Ke.get(t.toUpperCase());
231
232
  }
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);
233
+ function Yt(t) {
234
+ Ke.set(t.code.toUpperCase(), t);
235
+ const e = he.findIndex((n) => n.code === t.code);
236
+ e >= 0 ? he[e] = t : he.push(t);
236
237
  }
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() };
238
+ function ee(t, e) {
239
+ const n = V(e), r = (n == null ? void 0 : n.decimals) ?? 2, a = Math.pow(10, r);
240
+ return { amount: (t < 0 ? -1 : 1) * Math.round(Math.abs(t) * a), currency: e.toUpperCase() };
240
241
  }
241
- function Ke(t) {
242
+ function Oe(t) {
242
243
  const e = V(t.currency), n = (e == null ? void 0 : e.decimals) ?? 2;
243
244
  return t.amount / Math.pow(10, n);
244
245
  }
245
- function tt(t, e) {
246
+ function ct(t, e) {
246
247
  return t.currency.toUpperCase() === e.currency.toUpperCase();
247
248
  }
248
- function $e(t, e, n) {
249
- if (!tt(t, e))
249
+ function Me(t, e, n) {
250
+ if (!ct(t, e))
250
251
  throw new Error(`Cannot ${n} different currencies: ${t.currency} vs ${e.currency}`);
251
252
  }
252
253
  function me(t, e) {
253
- return $e(t, e, "add"), { amount: t.amount + e.amount, currency: t.currency };
254
+ return Me(t, e, "add"), { amount: t.amount + e.amount, currency: t.currency };
254
255
  }
255
- function nt(t, e) {
256
- return $e(t, e, "subtract"), { amount: t.amount - e.amount, currency: t.currency };
256
+ function it(t, e) {
257
+ return Me(t, e, "subtract"), { amount: t.amount - e.amount, currency: t.currency };
257
258
  }
258
259
  function De(t, e) {
259
260
  return {
@@ -261,150 +262,150 @@ function De(t, e) {
261
262
  currency: t.currency
262
263
  };
263
264
  }
264
- function At(t, e) {
265
- return $e(t, e, "compare"), t.amount - e.amount;
265
+ function Gt(t, e) {
266
+ return Me(t, e, "compare"), t.amount - e.amount;
266
267
  }
267
- function Ot(t) {
268
+ function Zt(t) {
268
269
  return t.amount === 0;
269
270
  }
270
- function Kt(t) {
271
+ function Jt(t) {
271
272
  return t.amount < 0;
272
273
  }
273
- function Bt(t) {
274
+ function Xt(t) {
274
275
  return { amount: -t.amount, currency: t.currency };
275
276
  }
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);
277
+ function ce(t, e = {}) {
278
+ const n = V(t.currency), r = e.decimals ?? (n == null ? void 0 : n.decimals) ?? 2, a = t.amount / Math.pow(10, r);
278
279
  try {
279
280
  return new Intl.NumberFormat(e.locale, {
280
281
  style: "currency",
281
282
  currency: t.currency,
282
- minimumFractionDigits: c,
283
- maximumFractionDigits: c,
283
+ minimumFractionDigits: r,
284
+ maximumFractionDigits: r,
284
285
  currencyDisplay: e.currencyDisplay ?? "symbol"
285
- }).format(r);
286
+ }).format(a);
286
287
  } catch {
287
- const a = (n == null ? void 0 : n.symbol) ?? t.currency, o = r.toFixed(c);
288
- return n != null && n.symbolFirst ? `${a}${o}` : `${o} ${a}`;
288
+ const i = (n == null ? void 0 : n.symbol) ?? t.currency, o = a.toFixed(r);
289
+ return n != null && n.symbolFirst ? `${i}${o}` : `${o} ${i}`;
289
290
  }
290
291
  }
291
- function rt(t, e) {
292
+ function st(t, e) {
292
293
  if (!t)
293
294
  return null;
294
295
  let n = t.replace(/[^\d.,\-]/g, "").trim();
295
296
  if (!n || n === "-")
296
297
  return 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;
298
+ const r = n.startsWith("-");
299
+ r && (n = n.slice(1));
300
+ const a = n.lastIndexOf("."), i = n.lastIndexOf(","), o = Math.max(a, i);
301
+ let s, l = "";
302
+ o === -1 ? s = n : (s = n.slice(0, o).replace(/[.,]/g, ""), l = n.slice(o + 1).replace(/[.,]/g, ""));
303
+ const d = `${s}.${l || "0"}`, p = parseFloat(d);
304
+ return Number.isFinite(p) ? ee(r ? -p : p, e) : null;
304
305
  }
305
- function Ne(t) {
306
+ function ve(t) {
306
307
  const e = (t || "").replace(/\D/g, "");
307
308
  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
309
  }
309
- function Be(t) {
310
+ function Fe(t) {
310
311
  const e = (t || "").replace(/\D/g, "");
311
312
  if (e.length < 12 || e.length > 19)
312
313
  return !1;
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;
314
+ let n = 0, r = !1;
315
+ for (let a = e.length - 1; a >= 0; a--) {
316
+ let i = e.charCodeAt(a) - 48;
317
+ r && (i *= 2, i > 9 && (i -= 9)), n += i, r = !r;
317
318
  }
318
319
  return n % 10 === 0;
319
320
  }
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();
321
+ function ot(t, e) {
322
+ const n = (t || "").replace(/\D/g, ""), r = e ?? ve(n);
323
+ return r === "amex" ? [n.slice(0, 4), n.slice(4, 10), n.slice(10, 15)].filter(Boolean).join(" ") : r === "diners" ? [n.slice(0, 4), n.slice(4, 10), n.slice(10, 14)].filter(Boolean).join(" ") : (n.match(/.{1,4}/g) ?? []).join(" ").trim();
323
324
  }
324
- function Tt(t, e) {
325
+ function Qt(t, e) {
325
326
  const n = (t || "").replace(/\D/g, "");
326
327
  if (n.length < 4)
327
328
  return n;
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();
329
+ const r = n.slice(-4), a = "*".repeat(n.length - 4) + r, i = e ?? ve(n);
330
+ return i === "amex" ? [a.slice(0, 4), a.slice(4, 10), a.slice(10, 15)].filter(Boolean).join(" ") : i === "diners" ? [a.slice(0, 4), a.slice(4, 10), a.slice(10, 14)].filter(Boolean).join(" ") : (a.match(/.{1,4}/g) ?? []).join(" ").trim();
330
331
  }
331
- function Te(t) {
332
+ function Be(t) {
332
333
  const e = (t || "").replace(/\D/g, "");
333
334
  if (e.length < 3)
334
335
  return null;
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}`;
336
+ const n = e.slice(0, 2), r = e.length >= 4 ? e.slice(-2) : e.slice(2, 4), a = parseInt(n, 10);
337
+ return !Number.isFinite(a) || a < 1 || a > 12 ? null : `${n}/${r}`;
337
338
  }
338
339
  function Le(t, e = /* @__PURE__ */ new Date()) {
339
- const n = Te(t);
340
+ const n = Be(t);
340
341
  if (!n)
341
342
  return !1;
342
- const [c, r] = n.split("/"), a = parseInt(c, 10), o = 2e3 + parseInt(r, 10);
343
- return new Date(o, a, 0, 23, 59, 59, 999).getTime() >= e.getTime();
343
+ const [r, a] = n.split("/"), i = parseInt(r, 10), o = 2e3 + parseInt(a, 10);
344
+ return new Date(o, i, 0, 23, 59, 59, 999).getTime() >= e.getTime();
344
345
  }
345
346
  function ye(t) {
346
347
  return t === "amex" ? 4 : 3;
347
348
  }
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
- a || (n.expiry = "Invalid or expired");
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;
349
+ function Ae(t, e = {}) {
350
+ var d;
351
+ const n = {}, r = ve(t.number), a = Fe(t.number);
352
+ a || (n.number = "Invalid card number");
353
+ const i = Le(t.expiry, e.now);
354
+ i || (n.expiry = "Invalid or expired");
355
+ const s = (t.cvc || "").replace(/\D/g, "").length === ye(r);
356
+ s || (n.cvc = `CVC must be ${ye(r)} digits`);
357
+ const l = !e.requireHolder || (((d = t.holderName) == null ? void 0 : d.trim().length) ?? 0) >= 2;
357
358
  return l || (n.holderName = "Cardholder name required"), {
358
- brand: c,
359
- numberValid: r,
360
- expiryValid: a,
361
- cvcValid: i,
359
+ brand: r,
360
+ numberValid: a,
361
+ expiryValid: i,
362
+ cvcValid: s,
362
363
  holderValid: l,
363
- isValid: r && a && i && l,
364
+ isValid: a && i && s && l,
364
365
  errors: n
365
366
  };
366
367
  }
367
- class Lt {
368
+ class Wt {
368
369
  constructor(e) {
369
- K(this, "id", "static");
370
+ H(this, "id", "static");
370
371
  this.rates = e;
371
372
  }
372
373
  async getRate(e, n) {
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
- if (a)
378
- return a;
379
- const o = this.rates.find((u) => u.base === r && u.quote === c);
374
+ const r = e.toUpperCase(), a = n.toUpperCase();
375
+ if (r === a)
376
+ return { base: r, quote: a, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
377
+ const i = this.rates.find((d) => d.base === r && d.quote === a);
378
+ if (i)
379
+ return i;
380
+ const o = this.rates.find((d) => d.base === a && d.quote === r);
380
381
  if (o)
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;
382
+ return { base: r, quote: a, rate: 1 / o.rate, asOf: o.asOf };
383
+ const s = this.rates.find((d) => d.base === r && d.quote === "USD") ?? this.rates.find((d) => d.base === "USD" && d.quote === r), l = this.rates.find((d) => d.base === "USD" && d.quote === a) ?? this.rates.find((d) => d.base === a && d.quote === "USD");
384
+ if (s && l) {
385
+ const d = s.base === "USD" ? 1 / s.rate : s.rate, p = l.base === "USD" ? l.rate : 1 / l.rate;
385
386
  return {
386
- base: c,
387
- quote: r,
388
- rate: u * m,
387
+ base: r,
388
+ quote: a,
389
+ rate: d * p,
389
390
  asOf: (/* @__PURE__ */ new Date()).toISOString()
390
391
  };
391
392
  }
392
- throw new Error(`No FX rate for ${c}/${r}`);
393
+ throw new Error(`No FX rate for ${r}/${a}`);
393
394
  }
394
395
  }
395
- class ge {
396
+ class we {
396
397
  constructor(e = {}) {
397
- K(this, "cache", /* @__PURE__ */ new Map());
398
- K(this, "fetchImpl");
399
- K(this, "ttl");
398
+ H(this, "cache", /* @__PURE__ */ new Map());
399
+ H(this, "fetchImpl");
400
+ H(this, "ttl");
400
401
  this.fetchImpl = e.fetchImpl ?? fetch, this.ttl = e.cacheTtl ?? 6e4;
401
402
  }
402
403
  cacheKey(e, n) {
403
404
  return `${this.id}:${e.toUpperCase()}/${n.toUpperCase()}`;
404
405
  }
405
406
  getCached(e, n) {
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);
407
+ const r = this.cacheKey(e, n), a = this.cache.get(r);
408
+ return a && a.expires > Date.now() ? a.rate : (a && this.cache.delete(r), null);
408
409
  }
409
410
  setCached(e) {
410
411
  this.cache.set(this.cacheKey(e.base, e.quote), {
@@ -413,141 +414,141 @@ class ge {
413
414
  });
414
415
  }
415
416
  }
416
- class at extends ge {
417
+ class lt extends we {
417
418
  constructor(n = {}) {
418
419
  super(n);
419
- K(this, "id", "frankfurter");
420
+ H(this, "id", "frankfurter");
420
421
  }
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);
422
+ async getRate(n, r) {
423
+ const a = n.toUpperCase(), i = r.toUpperCase();
424
+ if (a === i)
425
+ return { base: a, quote: i, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
426
+ const o = this.getCached(a, i);
426
427
  if (o)
427
428
  return o;
428
- const i = `https://api.frankfurter.app/latest?from=${r}&to=${a}`, l = await this.fetchImpl(i);
429
+ const s = `https://api.frankfurter.app/latest?from=${a}&to=${i}`, l = await this.fetchImpl(s);
429
430
  if (!l.ok)
430
431
  throw new Error(`Frankfurter HTTP ${l.status}`);
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;
432
+ const d = await l.json(), p = d.rates[i];
433
+ if (p == null)
434
+ throw new Error(`Frankfurter: no rate for ${a}/${i}`);
435
+ const g = { base: a, quote: i, rate: p, asOf: d.date };
436
+ return this.setCached(g), g;
436
437
  }
437
438
  }
438
- class it extends ge {
439
- constructor(n, c = {}) {
440
- super(c);
441
- K(this, "id", "openexchangerates");
439
+ class dt extends we {
440
+ constructor(n, r = {}) {
441
+ super(r);
442
+ H(this, "id", "openexchangerates");
442
443
  this.appId = n;
443
444
  }
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);
445
+ async getRate(n, r) {
446
+ const a = n.toUpperCase(), i = r.toUpperCase();
447
+ if (a === i)
448
+ return { base: a, quote: i, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
449
+ const o = this.getCached(a, i);
449
450
  if (o)
450
451
  return o;
451
- const i = `https://openexchangerates.org/api/latest.json?app_id=${this.appId}`, l = await this.fetchImpl(i);
452
+ const s = `https://openexchangerates.org/api/latest.json?app_id=${this.appId}`, l = await this.fetchImpl(s);
452
453
  if (!l.ok)
453
454
  throw new Error(`OpenExchangeRates HTTP ${l.status}`);
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
- quote: a,
460
- rate: b / m,
461
- asOf: new Date(u.timestamp * 1e3).toISOString()
455
+ const d = await l.json(), p = d.rates[a], g = d.rates[i];
456
+ if (p == null || g == null)
457
+ throw new Error(`OpenExchangeRates: missing rate for ${a} or ${i}`);
458
+ const y = {
459
+ base: a,
460
+ quote: i,
461
+ rate: g / p,
462
+ asOf: new Date(d.timestamp * 1e3).toISOString()
462
463
  };
463
- return this.setCached(p), p;
464
+ return this.setCached(y), y;
464
465
  }
465
466
  }
466
- class st extends ge {
467
+ class ut extends we {
467
468
  constructor(n = {}) {
468
469
  super(n);
469
- K(this, "id", "exchangerate.host");
470
+ H(this, "id", "exchangerate.host");
470
471
  }
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);
472
+ async getRate(n, r) {
473
+ var y;
474
+ const a = n.toUpperCase(), i = r.toUpperCase();
475
+ if (a === i)
476
+ return { base: a, quote: i, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
477
+ const o = this.getCached(a, i);
477
478
  if (o)
478
479
  return o;
479
- const i = `https://api.exchangerate.host/convert?from=${r}&to=${a}`, l = await this.fetchImpl(i);
480
+ const s = `https://api.exchangerate.host/convert?from=${a}&to=${i}`, l = await this.fetchImpl(s);
480
481
  if (!l.ok)
481
482
  throw new Error(`exchangerate.host HTTP ${l.status}`);
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;
483
+ const d = await l.json(), p = ((y = d.info) == null ? void 0 : y.rate) ?? d.result, g = { base: a, quote: i, rate: p, asOf: d.date };
484
+ return this.setCached(g), g;
484
485
  }
485
486
  }
486
- class ot extends ge {
487
+ class mt extends we {
487
488
  constructor(n = {}) {
488
489
  super(n);
489
- K(this, "id", "nbp");
490
- K(this, "table");
490
+ H(this, "id", "nbp");
491
+ H(this, "table");
491
492
  this.table = n.table ?? "A";
492
493
  }
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);
494
+ async getRate(n, r) {
495
+ const a = n.toUpperCase(), i = r.toUpperCase();
496
+ if (a === i)
497
+ return { base: a, quote: i, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
498
+ const o = this.getCached(a, i);
498
499
  if (o)
499
500
  return o;
500
- const i = async (b) => {
501
- var y;
502
- if (b === "PLN")
501
+ const s = async (g) => {
502
+ var f;
503
+ if (g === "PLN")
503
504
  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)
505
+ const y = `https://api.nbp.pl/api/exchangerates/rates/${this.table}/${g}/?format=json`, m = await this.fetchImpl(y);
506
+ if (!m.ok)
506
507
  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,
508
+ const b = (f = (await m.json()).rates) == null ? void 0 : f[0];
509
+ return b ? { rate: b.mid ?? b.ask ?? 0, date: b.effectiveDate } : null;
510
+ }, l = await s(a), d = await s(i);
511
+ if (!l || !d || l.rate === 0)
512
+ throw new Error(`NBP: missing rate for ${a} or ${i}`);
513
+ const p = {
514
+ base: a,
515
+ quote: i,
516
+ rate: l.rate / d.rate,
516
517
  asOf: l.date
517
518
  };
518
- return this.setCached(m), m;
519
+ return this.setCached(p), p;
519
520
  }
520
521
  }
521
- class lt extends at {
522
+ class pt extends lt {
522
523
  constructor() {
523
524
  super(...arguments);
524
- K(this, "id", "ecb");
525
+ H(this, "id", "ecb");
525
526
  }
526
527
  }
527
- class ut extends st {
528
+ class yt extends ut {
528
529
  constructor() {
529
530
  super(...arguments);
530
- K(this, "id", "free-forex");
531
+ H(this, "id", "free-forex");
531
532
  }
532
533
  }
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)
534
+ const Vt = (t = {}) => new mt(t), en = (t = {}) => new pt(t), tn = (t) => new dt(t.apiKey, t), nn = (t = {}) => new yt(t);
535
+ async function ht(t, e, n) {
536
+ const r = e.toUpperCase();
537
+ if (t.currency.toUpperCase() === r)
537
538
  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;
539
+ const a = V(t.currency), i = V(r), o = (a == null ? void 0 : a.decimals) ?? 2, s = (i == null ? void 0 : i.decimals) ?? 2, { rate: l } = await n.getRate(t.currency, r), p = t.amount / Math.pow(10, o) * l;
539
540
  return {
540
- currency: c,
541
- amount: Math.round(m * Math.pow(10, i))
541
+ currency: r,
542
+ amount: Math.round(p * Math.pow(10, s))
542
543
  };
543
544
  }
544
- class mt {
545
+ class bt {
545
546
  constructor(e = {}) {
546
- K(this, "id");
547
- K(this, "name");
548
- K(this, "supportedCurrencies");
549
- K(this, "minimums");
550
- K(this, "counter", 0);
547
+ H(this, "id");
548
+ H(this, "name");
549
+ H(this, "supportedCurrencies");
550
+ H(this, "minimums");
551
+ H(this, "counter", 0);
551
552
  this.id = e.id ?? "mock", this.name = e.name ?? "Mock Processor", this.supportedCurrencies = e.supportedCurrencies ?? "*";
552
553
  }
553
554
  newId(e) {
@@ -582,10 +583,10 @@ class mt {
582
583
  };
583
584
  }
584
585
  }
585
- function j(t, e, n, c, r) {
586
- const a = (o) => {
587
- const i = c == null ? void 0 : c[o];
588
- return i || (async () => {
586
+ function X(t, e, n, r, a) {
587
+ const i = (o) => {
588
+ const s = r == null ? void 0 : r[o];
589
+ return s || (async () => {
589
590
  throw new Error(
590
591
  `[ui-money] ${e} adapter is not wired. Pass an \`executor.${String(o)}\` implementation that calls the ${e} SDK.`
591
592
  );
@@ -595,15 +596,15 @@ function j(t, e, n, c, r) {
595
596
  id: t,
596
597
  name: e,
597
598
  supportedCurrencies: n,
598
- minimums: r,
599
- authorize: a("authorize"),
600
- capture: a("capture"),
601
- cancel: a("cancel"),
602
- refund: a("refund")
599
+ minimums: a,
600
+ authorize: i("authorize"),
601
+ capture: i("capture"),
602
+ cancel: i("cancel"),
603
+ refund: i("refund")
603
604
  };
604
605
  }
605
- function pt(t) {
606
- return j("stripe", "Stripe", "*", t, {
606
+ function ft(t) {
607
+ return X("stripe", "Stripe", "*", t, {
607
608
  USD: 50,
608
609
  EUR: 50,
609
610
  GBP: 30,
@@ -617,8 +618,8 @@ function pt(t) {
617
618
  PLN: 200
618
619
  });
619
620
  }
620
- function yt(t) {
621
- return j(
621
+ function _t(t) {
622
+ return X(
622
623
  "paypal",
623
624
  "PayPal",
624
625
  [
@@ -648,707 +649,940 @@ function yt(t) {
648
649
  t
649
650
  );
650
651
  }
651
- function ft(t) {
652
- return j("adyen", "Adyen", "*", t);
652
+ function gt(t) {
653
+ return X("adyen", "Adyen", "*", t);
653
654
  }
654
- function ht(t) {
655
- return j("square", "Square", ["USD", "CAD", "GBP", "AUD", "JPY", "EUR"], t);
655
+ function Nt(t) {
656
+ return X("square", "Square", ["USD", "CAD", "GBP", "AUD", "JPY", "EUR"], t);
656
657
  }
657
- function bt(t) {
658
- return j("mollie", "Mollie", "*", t);
658
+ function vt(t) {
659
+ return X("mollie", "Mollie", "*", t);
659
660
  }
660
- function _t(t) {
661
- return j("braintree", "Braintree", "*", t);
661
+ function wt(t) {
662
+ return X("braintree", "Braintree", "*", t);
662
663
  }
663
- function Nt(t) {
664
- return j("razorpay", "Razorpay", ["INR", "USD", "EUR", "GBP", "AED"], t);
664
+ function kt(t) {
665
+ return X("razorpay", "Razorpay", ["INR", "USD", "EUR", "GBP", "AED"], t);
665
666
  }
666
- function gt(t) {
667
- return j(
667
+ function Dt(t) {
668
+ return X(
668
669
  "payu",
669
670
  "PayU",
670
671
  ["PLN", "EUR", "USD", "CZK", "HUF", "RON", "BGN", "TRY"],
671
672
  t
672
673
  );
673
674
  }
674
- function wt(t) {
675
- return j("przelewy24", "Przelewy24", ["PLN", "EUR"], t);
675
+ function Ct(t) {
676
+ return X("przelewy24", "Przelewy24", ["PLN", "EUR"], t);
676
677
  }
677
- function Dt(t = {}) {
678
- return j("tpay", "Tpay", ["PLN", "EUR", "USD", "GBP"], t);
678
+ function Mt(t = {}) {
679
+ return X("tpay", "Tpay", ["PLN", "EUR", "USD", "GBP"], t);
679
680
  }
680
- function vt(t = {}) {
681
- return j("autopay", "Autopay", ["PLN", "EUR", "USD", "GBP", "CZK"], t);
681
+ function Pt(t = {}) {
682
+ return X("autopay", "Autopay", ["PLN", "EUR", "USD", "GBP", "CZK"], t);
682
683
  }
683
- function Ct(t = {}) {
684
+ function It(t = {}) {
684
685
  const { acquirer: e = "native", ...n } = t;
685
- return j(`blik:${e}`, `BLIK (${e})`, ["PLN"], n);
686
+ return X(`blik:${e}`, `BLIK (${e})`, ["PLN"], n);
686
687
  }
687
- function $t(t) {
688
- return j(
688
+ function St(t) {
689
+ return X(
689
690
  "klarna",
690
691
  "Klarna",
691
692
  ["USD", "EUR", "GBP", "SEK", "NOK", "DKK", "CHF", "AUD", "CAD", "NZD", "PLN"],
692
693
  t
693
694
  );
694
695
  }
695
- function xt(t) {
696
- return j(
696
+ function $t(t) {
697
+ return X(
697
698
  "coinbase-commerce",
698
699
  "Coinbase Commerce",
699
700
  ["BTC", "ETH", "USDC", "USDT", "USD", "EUR"],
700
701
  t
701
702
  );
702
703
  }
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()
704
+ const xt = {
705
+ mock: () => new bt(),
706
+ stripe: () => ft(),
707
+ paypal: () => _t(),
708
+ adyen: () => gt(),
709
+ square: () => Nt(),
710
+ mollie: () => vt(),
711
+ braintree: () => wt(),
712
+ razorpay: () => kt(),
713
+ payu: () => Dt(),
714
+ przelewy24: () => Ct(),
715
+ tpay: () => Mt(),
716
+ autopay: () => Pt(),
717
+ blik: () => It(),
718
+ klarna: () => St(),
719
+ "coinbase-commerce": () => $t()
719
720
  };
720
- function Yt(t, e) {
721
- const n = k(
722
- () => "amount" in t ? t : W(
721
+ function Rt(t) {
722
+ const e = xt[t];
723
+ return e ? e().supportedCurrencies : "*";
724
+ }
725
+ function Ut(t) {
726
+ return `/api/payments/${t}/webhook`;
727
+ }
728
+ const At = [
729
+ {
730
+ id: "stripe",
731
+ name: "Stripe",
732
+ type: "card",
733
+ credentials: [
734
+ {
735
+ key: "apiKey",
736
+ label: "Secret API key",
737
+ secret: !0,
738
+ required: !0,
739
+ help: "sk_live_… / sk_test_…"
740
+ },
741
+ {
742
+ key: "publishableKey",
743
+ label: "Publishable key",
744
+ required: !0,
745
+ help: "pk_live_… / pk_test_…"
746
+ },
747
+ { key: "webhookSecret", label: "Webhook signing secret", secret: !0, help: "whsec_…" }
748
+ ],
749
+ supportedMethods: ["card", "applepay", "googlepay", "link"],
750
+ allowedDomains: ["api.stripe.com"],
751
+ hasTestMode: !0
752
+ },
753
+ {
754
+ id: "paypal",
755
+ name: "PayPal",
756
+ type: "wallet",
757
+ credentials: [
758
+ { key: "clientId", label: "Client ID", required: !0 },
759
+ { key: "clientSecret", label: "Client secret", secret: !0, required: !0 },
760
+ { key: "webhookId", label: "Webhook ID" }
761
+ ],
762
+ supportedMethods: ["paypal", "card", "paylater"],
763
+ allowedDomains: ["api-m.paypal.com", "api-m.sandbox.paypal.com"],
764
+ hasTestMode: !0
765
+ },
766
+ {
767
+ id: "adyen",
768
+ name: "Adyen",
769
+ type: "aggregator",
770
+ credentials: [
771
+ { key: "apiKey", label: "API key", secret: !0, required: !0 },
772
+ { key: "merchantAccount", label: "Merchant account", required: !0 },
773
+ { key: "hmacKey", label: "HMAC key (webhooks)", secret: !0 },
774
+ { key: "clientKey", label: "Client key" }
775
+ ],
776
+ supportedMethods: ["card", "ideal", "bancontact", "applepay", "googlepay"],
777
+ allowedDomains: ["checkout-test.adyen.com", "checkout-live.adyen.com"],
778
+ hasTestMode: !0
779
+ },
780
+ {
781
+ id: "square",
782
+ name: "Square",
783
+ type: "card",
784
+ credentials: [
785
+ { key: "accessToken", label: "Access token", secret: !0, required: !0 },
786
+ { key: "applicationId", label: "Application ID", required: !0 },
787
+ { key: "locationId", label: "Location ID", required: !0 }
788
+ ],
789
+ supportedMethods: ["card", "applepay", "googlepay"],
790
+ allowedDomains: ["connect.squareup.com", "connect.squareupsandbox.com"],
791
+ hasTestMode: !0
792
+ },
793
+ {
794
+ id: "mollie",
795
+ name: "Mollie",
796
+ type: "aggregator",
797
+ credentials: [
798
+ { key: "apiKey", label: "API key", secret: !0, required: !0, help: "live_… / test_…" }
799
+ ],
800
+ supportedMethods: ["card", "ideal", "bancontact", "blik", "applepay"],
801
+ allowedDomains: ["api.mollie.com"],
802
+ hasTestMode: !0
803
+ },
804
+ {
805
+ id: "braintree",
806
+ name: "Braintree",
807
+ type: "card",
808
+ credentials: [
809
+ { key: "merchantId", label: "Merchant ID", required: !0 },
810
+ { key: "publicKey", label: "Public key", required: !0 },
811
+ { key: "privateKey", label: "Private key", secret: !0, required: !0 }
812
+ ],
813
+ supportedMethods: ["card", "paypal", "applepay", "googlepay"],
814
+ allowedDomains: ["api.braintreegateway.com", "api.sandbox.braintreegateway.com"],
815
+ hasTestMode: !0
816
+ },
817
+ {
818
+ id: "razorpay",
819
+ name: "Razorpay",
820
+ type: "aggregator",
821
+ credentials: [
822
+ { key: "keyId", label: "Key ID", required: !0 },
823
+ { key: "keySecret", label: "Key secret", secret: !0, required: !0 },
824
+ { key: "webhookSecret", label: "Webhook secret", secret: !0 }
825
+ ],
826
+ supportedMethods: ["card", "upi", "netbanking", "wallet"],
827
+ allowedDomains: ["api.razorpay.com"],
828
+ hasTestMode: !0
829
+ },
830
+ {
831
+ id: "payu",
832
+ name: "PayU",
833
+ type: "aggregator",
834
+ credentials: [
835
+ { key: "posId", label: "POS ID", required: !0 },
836
+ { key: "clientId", label: "OAuth client ID", required: !0 },
837
+ { key: "clientSecret", label: "OAuth client secret", secret: !0, required: !0 },
838
+ { key: "secondKey", label: "Second key (MD5)", secret: !0 }
839
+ ],
840
+ supportedMethods: ["card", "blik", "transfer", "googlepay"],
841
+ allowedDomains: ["secure.payu.com", "secure.snd.payu.com"],
842
+ hasTestMode: !0
843
+ },
844
+ {
845
+ id: "przelewy24",
846
+ name: "Przelewy24",
847
+ type: "bank",
848
+ credentials: [
849
+ { key: "merchantId", label: "Merchant ID", required: !0 },
850
+ { key: "posId", label: "POS ID", required: !0 },
851
+ { key: "crcKey", label: "CRC key", secret: !0, required: !0 },
852
+ { key: "apiKey", label: "API key", secret: !0, required: !0 }
853
+ ],
854
+ supportedMethods: ["transfer", "blik", "card"],
855
+ allowedDomains: ["secure.przelewy24.pl", "sandbox.przelewy24.pl"],
856
+ hasTestMode: !0
857
+ },
858
+ {
859
+ id: "tpay",
860
+ name: "Tpay",
861
+ type: "aggregator",
862
+ credentials: [
863
+ { key: "merchantId", label: "Merchant ID", required: !0 },
864
+ { key: "apiKey", label: "API key", secret: !0, required: !0 },
865
+ { key: "apiPassword", label: "API password", secret: !0, required: !0 }
866
+ ],
867
+ supportedMethods: ["card", "blik", "transfer", "applepay"],
868
+ allowedDomains: ["api.tpay.com", "secure.tpay.com"],
869
+ hasTestMode: !0
870
+ },
871
+ {
872
+ id: "autopay",
873
+ name: "Autopay",
874
+ type: "aggregator",
875
+ credentials: [
876
+ { key: "serviceId", label: "Service ID", required: !0 },
877
+ { key: "sharedSecret", label: "Shared secret", secret: !0, required: !0 }
878
+ ],
879
+ supportedMethods: ["card", "blik", "transfer"],
880
+ allowedDomains: ["pay.autopay.eu", "testpay.autopay.eu"],
881
+ hasTestMode: !0
882
+ },
883
+ {
884
+ id: "blik",
885
+ name: "BLIK",
886
+ type: "bank",
887
+ credentials: [
888
+ {
889
+ key: "acquirer",
890
+ label: "Acquirer (p24 / tpay / payu / native)",
891
+ required: !0,
892
+ help: "Underlying acquirer routing BLIK."
893
+ }
894
+ ],
895
+ supportedMethods: ["blik"],
896
+ hasTestMode: !0
897
+ },
898
+ {
899
+ id: "klarna",
900
+ name: "Klarna",
901
+ type: "bnpl",
902
+ credentials: [
903
+ { key: "username", label: "API username (UID)", required: !0 },
904
+ { key: "password", label: "API password", secret: !0, required: !0 },
905
+ { key: "region", label: "Region (eu / na / oc)", help: "Selects the Klarna API host." }
906
+ ],
907
+ supportedMethods: ["paylater", "installments", "paynow"],
908
+ allowedDomains: ["api.klarna.com", "api.playground.klarna.com"],
909
+ hasTestMode: !0
910
+ },
911
+ {
912
+ id: "coinbase-commerce",
913
+ name: "Coinbase Commerce",
914
+ type: "crypto",
915
+ credentials: [
916
+ { key: "apiKey", label: "API key", secret: !0, required: !0 },
917
+ { key: "webhookSharedSecret", label: "Webhook shared secret", secret: !0 }
918
+ ],
919
+ supportedMethods: ["crypto"],
920
+ allowedDomains: ["api.commerce.coinbase.com"],
921
+ hasTestMode: !1
922
+ },
923
+ {
924
+ id: "wallet",
925
+ name: "In-app Wallet",
926
+ type: "wallet",
927
+ currencyKey: "mock",
928
+ credentials: [
929
+ {
930
+ key: "ledgerAccount",
931
+ label: "Ledger account",
932
+ required: !0,
933
+ help: "Account the wallet debits/credits."
934
+ }
935
+ ],
936
+ supportedMethods: ["wallet"],
937
+ hasTestMode: !0
938
+ }
939
+ ], Ne = Object.fromEntries(
940
+ At.map((t) => {
941
+ const { currencyKey: e, ...n } = t, r = {
942
+ ...n,
943
+ supportedCurrencies: Rt(e ?? t.id),
944
+ webhookPath: Ut(t.id)
945
+ };
946
+ return [t.id, r];
947
+ })
948
+ ), Et = Object.values(
949
+ Ne
950
+ );
951
+ function rn(t) {
952
+ return Ne[t];
953
+ }
954
+ function an(t, e) {
955
+ const n = q(
956
+ () => "amount" in t ? t : ee(
723
957
  t.major,
724
958
  t.currency
725
959
  ),
726
960
  // eslint-disable-next-line react-hooks/exhaustive-deps
727
961
  []
728
- ), [c, r] = B(n), a = F(
729
- (p) => r((d) => W(p, d.currency)),
962
+ ), [r, a] = F(n), i = L(
963
+ (y) => a((m) => ee(y, m.currency)),
730
964
  []
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)),
965
+ ), o = L((y) => {
966
+ a((m) => ({ ...m, currency: y.toUpperCase() }));
967
+ }, []), s = L((y) => a((m) => me(m, y)), []), l = L(
968
+ (y) => a((m) => it(m, y)),
735
969
  []
736
- ), u = F(
737
- (p) => r((d) => De(d, p)),
970
+ ), d = L(
971
+ (y) => a((m) => De(m, y)),
738
972
  []
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 };
973
+ ), p = q(() => ce(r, { locale: e }), [r, e]), g = q(() => Oe(r), [r]);
974
+ return { money: r, setMoney: a, setMajor: i, setCurrency: o, add: s, subtract: l, scale: d, formatted: p, major: g };
741
975
  }
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(() => {
976
+ function Ce(t, e, n) {
977
+ const [r, a] = F(null), [i, o] = F(null), [s, l] = F(!1), d = et(0);
978
+ return tt(() => {
745
979
  if (!t) {
746
- r(null);
980
+ a(null);
747
981
  return;
748
982
  }
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));
983
+ const p = ++d.current;
984
+ l(!0), o(null), ht(t, e, n).then((g) => {
985
+ d.current === p && a(g);
986
+ }).catch((g) => {
987
+ d.current === p && (o(g instanceof Error ? g : new Error(String(g))), a(null));
754
988
  }).finally(() => {
755
- u.current === m && l(!1);
989
+ d.current === p && l(!1);
756
990
  });
757
- }, [t == null ? void 0 : t.amount, t == null ? void 0 : t.currency, e, n]), { converted: c, loading: i, error: a };
991
+ }, [t == null ? void 0 : t.amount, t == null ? void 0 : t.currency, e, n]), { converted: r, loading: s, error: i };
758
992
  }
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) => {
993
+ function qt(t) {
994
+ const [e, n] = F("idle"), [r, a] = F(null), [i, o] = F(null), s = L(() => {
995
+ n("idle"), a(null), o(null);
996
+ }, []), l = L(
997
+ async (y) => {
764
998
  n("authorizing"), o(null);
765
999
  try {
766
- const d = await t.authorize(p);
767
- return r(d), n(d.status), d;
768
- } catch (d) {
769
- const f = d instanceof Error ? d : new Error(String(d));
770
- throw o(f), n("failed"), f;
1000
+ const m = await t.authorize(y);
1001
+ return a(m), n(m.status), m;
1002
+ } catch (m) {
1003
+ const _ = m instanceof Error ? m : new Error(String(m));
1004
+ throw o(_), n("failed"), _;
771
1005
  }
772
1006
  },
773
1007
  [t]
774
- ), u = F(
775
- async (p, d) => {
776
- const f = p ?? (c == null ? void 0 : c.id);
777
- if (!f)
1008
+ ), d = L(
1009
+ async (y, m) => {
1010
+ const _ = y ?? (r == null ? void 0 : r.id);
1011
+ if (!_)
778
1012
  throw new Error("No authorization id to capture");
779
1013
  n("capturing");
780
1014
  try {
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;
1015
+ const b = await t.capture(_, m);
1016
+ return a(b), n(b.status), b;
1017
+ } catch (b) {
1018
+ const f = b instanceof Error ? b : new Error(String(b));
1019
+ throw o(f), n("failed"), f;
786
1020
  }
787
1021
  },
788
- [t, c == null ? void 0 : c.id]
789
- ), m = F(
790
- async (p) => {
791
- const d = p ?? (c == null ? void 0 : c.id);
792
- if (!d)
1022
+ [t, r == null ? void 0 : r.id]
1023
+ ), p = L(
1024
+ async (y) => {
1025
+ const m = y ?? (r == null ? void 0 : r.id);
1026
+ if (!m)
793
1027
  throw new Error("No payment id to cancel");
794
- const f = await t.cancel(d);
795
- return r(f), n(f.status), f;
1028
+ const _ = await t.cancel(m);
1029
+ return a(_), n(_.status), _;
796
1030
  },
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)
1031
+ [t, r == null ? void 0 : r.id]
1032
+ ), g = L(
1033
+ async (y, m) => {
1034
+ const _ = y ?? (r == null ? void 0 : r.id);
1035
+ if (!_)
802
1036
  throw new Error("No payment id to refund");
803
- const h = await t.refund(f, d);
804
- return r(h), n(h.status), h;
1037
+ const b = await t.refund(_, m);
1038
+ return a(b), n(b.status), b;
805
1039
  },
806
- [t, c == null ? void 0 : c.id]
1040
+ [t, r == null ? void 0 : r.id]
807
1041
  );
808
- return { status: e, response: c, error: a, authorize: l, capture: u, cancel: m, refund: b, reset: i };
1042
+ return { status: e, response: r, error: i, authorize: l, capture: d, cancel: p, refund: g, reset: s };
809
1043
  }
810
- const Fe = de(function({
1044
+ const Ee = ie(function({
811
1045
  value: e,
812
1046
  amount: n,
813
- currency: c,
814
- locale: r,
815
- display: a = "symbol",
1047
+ currency: r,
1048
+ locale: a,
1049
+ display: i = "symbol",
816
1050
  highlightNegative: o = !0,
817
- zeroPlaceholder: i,
1051
+ zeroPlaceholder: s,
818
1052
  convertTo: l,
819
- exchangeProvider: u,
820
- className: m,
821
- style: b,
822
- "aria-label": p
823
- }, d) {
824
- const f = k(() => {
1053
+ exchangeProvider: d,
1054
+ className: p,
1055
+ style: g,
1056
+ "aria-label": y
1057
+ }, m) {
1058
+ const _ = q(() => {
825
1059
  if (e)
826
1060
  return e;
827
- if (n != null && c) {
828
- const g = V(c), v = (g == null ? void 0 : g.decimals) ?? 2;
1061
+ if (n != null && r) {
1062
+ const w = V(r), k = (w == null ? void 0 : w.decimals) ?? 2;
829
1063
  return {
830
- amount: Math.round(n * Math.pow(10, v)),
831
- currency: c.toUpperCase()
1064
+ amount: Math.round(n * Math.pow(10, k)),
1065
+ currency: r.toUpperCase()
832
1066
  };
833
1067
  }
834
1068
  return 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,
1069
+ }, [e, n, r]), b = q(() => _ ? _.amount === 0 && s != null ? s : ce(_, { locale: a, currencyDisplay: i }) : "", [_, a, i, s]), { converted: f } = Ce(
1070
+ l && d ? _ : null,
837
1071
  l ?? "",
838
- u
1072
+ d
839
1073
  );
840
- if (!f)
1074
+ if (!_)
841
1075
  return null;
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: [
1076
+ const N = _.amount < 0, $ = "nice-money" + (o && N ? " nice-money--negative" : "") + (p ? ` ${p}` : "");
1077
+ return /* @__PURE__ */ h("span", { ref: m, className: $, style: g, "aria-label": y, children: [
1078
+ /* @__PURE__ */ c("span", { className: "nice-money__value", children: b }),
1079
+ f && /* @__PURE__ */ h("span", { className: "nice-money__converted", "aria-label": `Converted to ${f.currency}`, children: [
846
1080
  " ≈ ",
847
- te(y, { locale: r })
1081
+ ce(f, { locale: a })
848
1082
  ] })
849
1083
  ] });
850
- }), Zt = fe.map((t) => t.code).sort(), qe = de(
1084
+ }), cn = he.map((t) => t.code).sort(), He = ie(
851
1085
  function({
852
1086
  value: e,
853
1087
  onChange: n,
854
- options: c = fe,
855
- recents: r = [],
856
- searchable: a,
1088
+ options: r = he,
1089
+ recents: a = [],
1090
+ searchable: i,
857
1091
  showCode: o = !0,
858
- showSymbol: i = !0,
1092
+ showSymbol: s = !0,
859
1093
  compact: l = !1,
860
- disabled: u,
861
- readOnly: m,
862
- loading: b,
863
- accessMode: p,
864
- label: d,
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)
1094
+ disabled: d,
1095
+ readOnly: p,
1096
+ loading: g,
1097
+ accessMode: y,
1098
+ label: m,
1099
+ helperText: _,
1100
+ error: b,
1101
+ required: f,
1102
+ size: N = "md",
1103
+ labelPlacement: $ = "top",
1104
+ labelWidth: w,
1105
+ controlWidth: k,
1106
+ className: A,
1107
+ style: T,
1108
+ id: C,
1109
+ name: P,
1110
+ title: v,
1111
+ "data-testid": j,
1112
+ "aria-label": K,
1113
+ placeholder: Z
1114
+ }, Y) {
1115
+ const E = y === "hidden", J = d || y === "disabled" || g, te = p || y === "readOnly", O = be(), ne = C ?? `nice-cs-${O}`, [z, u] = F(""), D = i ?? r.length > 8, U = q(() => {
1116
+ if (!z.trim())
1117
+ return r;
1118
+ const S = z.trim().toLowerCase();
1119
+ return r.filter(
1120
+ (x) => x.code.toLowerCase().includes(S) || x.name.toLowerCase().includes(S) || x.symbol.toLowerCase().includes(S)
887
1121
  );
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));
1122
+ }, [r, z]), I = q(() => {
1123
+ const S = /* @__PURE__ */ new Set();
1124
+ return a.map((x) => V(x)).filter((x) => !!x && !S.has(x.code) && !!S.add(x.code));
1125
+ }, [a]), re = L(
1126
+ (S) => {
1127
+ const x = S.target.value, oe = V(x);
1128
+ oe && (n == null || n(x, oe));
895
1129
  },
896
1130
  [n]
897
- ), ee = (D) => {
1131
+ ), ae = (S) => {
898
1132
  if (l)
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,
1133
+ return `${s ? S.symbol + " " : ""}${S.code}`;
1134
+ const x = [];
1135
+ return s && x.push(S.symbol), o && x.push(S.code), x.push("—", S.name), x.join(" ");
1136
+ }, M = `nice-currency-selector nice-currency-selector--${N} nice-currency-selector--label-${$}` + (l ? " nice-currency-selector--compact" : "") + (b ? " nice-currency-selector--error" : "") + (J ? " nice-currency-selector--disabled" : "") + (A ? ` ${A}` : ""), B = $ === "left" && w != null ? { width: typeof w == "number" ? `${w}px` : w, flex: "none" } : void 0, se = k != null ? {
1137
+ width: typeof k == "number" ? `${k}px` : k,
904
1138
  flex: "none"
905
1139
  } : void 0;
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: [
908
- d,
909
- y && /* @__PURE__ */ s("span", { className: "nice-currency-selector__required", "aria-hidden": !0, children: "*" })
1140
+ return E ? null : /* @__PURE__ */ h("div", { ref: Y, className: M, style: T, title: v, "data-testid": j, children: [
1141
+ m && /* @__PURE__ */ h("label", { htmlFor: ne, className: "nice-currency-selector__label", style: B, children: [
1142
+ m,
1143
+ f && /* @__PURE__ */ c("span", { className: "nice-currency-selector__required", "aria-hidden": !0, children: "*" })
910
1144
  ] }),
911
- /* @__PURE__ */ N("div", { className: "nice-currency-selector__inner", style: re, children: [
912
- M && /* @__PURE__ */ s(
1145
+ /* @__PURE__ */ h("div", { className: "nice-currency-selector__inner", style: se, children: [
1146
+ D && /* @__PURE__ */ c(
913
1147
  "input",
914
1148
  {
915
1149
  type: "search",
916
1150
  className: "nice-currency-selector__search",
917
1151
  placeholder: "Search currency…",
918
- value: H,
919
- onChange: (D) => U(D.target.value),
920
- disabled: X || se,
1152
+ value: z,
1153
+ onChange: (S) => u(S.target.value),
1154
+ disabled: J || te,
921
1155
  "aria-label": "Search currency"
922
1156
  }
923
1157
  ),
924
- /* @__PURE__ */ N(
1158
+ /* @__PURE__ */ h(
925
1159
  "select",
926
1160
  {
927
- id: oe,
928
- name: R,
1161
+ id: ne,
1162
+ name: P,
929
1163
  className: "nice-currency-selector__select",
930
1164
  value: e ?? "",
931
- onChange: le,
932
- disabled: X || se,
933
- required: y,
934
- "aria-invalid": !!h,
935
- "aria-label": E ?? (typeof d == "string" ? d : "Currency"),
1165
+ onChange: re,
1166
+ disabled: J || te,
1167
+ required: f,
1168
+ "aria-invalid": !!b,
1169
+ "aria-label": K ?? (typeof m == "string" ? m : "Currency"),
936
1170
  children: [
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)) })
1171
+ !e && /* @__PURE__ */ c("option", { value: "", children: Z ?? "Select currency…" }),
1172
+ I.length > 0 && /* @__PURE__ */ c("optgroup", { label: "Recent", children: I.map((S) => /* @__PURE__ */ c("option", { value: S.code, children: ae(S) }, `r-${S.code}`)) }),
1173
+ /* @__PURE__ */ c("optgroup", { label: I.length > 0 ? "All" : "", children: U.map((S) => /* @__PURE__ */ c("option", { value: S.code, children: ae(S) }, S.code)) })
940
1174
  ]
941
1175
  }
942
1176
  )
943
1177
  ] }),
944
- (h || f) && /* @__PURE__ */ s(
1178
+ (b || _) && /* @__PURE__ */ c(
945
1179
  "span",
946
1180
  {
947
- className: h ? "nice-currency-selector__error" : "nice-currency-selector__helper",
948
- children: h ?? f
1181
+ className: b ? "nice-currency-selector__error" : "nice-currency-selector__helper",
1182
+ children: b ?? _
949
1183
  }
950
1184
  )
951
1185
  ] });
952
1186
  }
953
- ), He = de(
1187
+ ), je = ie(
954
1188
  function({
955
1189
  value: e,
956
1190
  onChange: n,
957
- currency: c,
958
- onCurrencyChange: r,
959
- currencies: a,
1191
+ currency: r,
1192
+ onCurrencyChange: a,
1193
+ currencies: i,
960
1194
  hideCurrencySelector: o,
961
- min: i,
1195
+ min: s,
962
1196
  max: l,
963
- step: u,
964
- locale: m,
965
- placeholder: b,
966
- label: p,
967
- helperText: d,
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);
1197
+ step: d,
1198
+ locale: p,
1199
+ placeholder: g,
1200
+ label: y,
1201
+ helperText: m,
1202
+ error: _,
1203
+ size: b = "md",
1204
+ disabled: f,
1205
+ readOnly: N,
1206
+ required: $,
1207
+ loading: w,
1208
+ accessMode: k,
1209
+ labelPlacement: A = "top",
1210
+ errorPlacement: T = "bottom",
1211
+ labelWidth: C,
1212
+ controlWidth: P,
1213
+ submitOnEnter: v,
1214
+ onSubmit: j,
1215
+ showFormattedPreview: K = !0,
1216
+ showSteppers: Z = !1,
1217
+ className: Y,
1218
+ style: E,
1219
+ id: J,
1220
+ name: te,
1221
+ title: O,
1222
+ "data-testid": ne,
1223
+ onBlur: z,
1224
+ onFocus: u,
1225
+ liveGrouping: D,
1226
+ multiplierShortcuts: U = !0,
1227
+ onValidationError: I
1228
+ }, re) {
1229
+ const ae = f || k === "disabled" || w, M = N || k === "readOnly", B = k === "hidden", se = be(), S = J ?? `nice-money-${se}`, x = ((e == null ? void 0 : e.currency) ?? r ?? "USD").toUpperCase(), oe = V(x), Q = (oe == null ? void 0 : oe.decimals) ?? 2, Pe = d ?? 1 / Math.pow(10, Q), [ke, fe] = F(
1230
+ () => e ? (e.amount / Math.pow(10, Q)).toFixed(Q) : ""
1231
+ ), [_e, Ie] = F(!1);
998
1232
  Ve.useEffect(() => {
999
- if (be)
1233
+ if (_e)
1000
1234
  return;
1001
1235
  if (e == null) {
1002
- he("");
1236
+ fe("");
1003
1237
  return;
1004
1238
  }
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"));
1239
+ const R = V(e.currency), G = (R == null ? void 0 : R.decimals) ?? 2;
1240
+ fe((e.amount / Math.pow(10, G)).toFixed(G));
1241
+ }, [e, _e]);
1242
+ const Se = L(
1243
+ (R) => {
1244
+ let G = R;
1245
+ if (U) {
1246
+ const de = R.trim().match(/^([+-]?\d+(?:[.,]\d+)?)\s*([kKmMbB])$/);
1247
+ if (de) {
1248
+ const ue = de[2].toLowerCase() === "k" ? 1e3 : de[2].toLowerCase() === "m" ? 1e6 : 1e9, Ue = Number(de[1].replace(",", ".")) * ue;
1249
+ if (!Number.isFinite(Ue)) {
1250
+ I == null || I(new Error("overflow"));
1017
1251
  return;
1018
1252
  }
1019
- L = String(ke);
1253
+ G = String(Ue);
1020
1254
  }
1021
1255
  }
1022
- const Q = rt(L, C);
1023
- if (!Q) {
1256
+ const W = st(G, x);
1257
+ if (!W) {
1024
1258
  n == null || n(null);
1025
1259
  return;
1026
1260
  }
1027
- if (!Number.isSafeInteger(Q.amount)) {
1028
- x == null || x(new Error("overflow: amount exceeds Number.MAX_SAFE_INTEGER"));
1261
+ if (!Number.isSafeInteger(W.amount)) {
1262
+ I == null || I(new Error("overflow: amount exceeds Number.MAX_SAFE_INTEGER"));
1029
1263
  return;
1030
1264
  }
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));
1265
+ const le = W.amount / Math.pow(10, Q);
1266
+ if (s != null && le < s) {
1267
+ I == null || I(new Error(`min: ${s}`)), n == null || n(ee(s, x));
1034
1268
  return;
1035
1269
  }
1036
- if (l != null && ae > l) {
1037
- x == null || x(new Error(`max: ${l}`)), n == null || n(W(l, C));
1270
+ if (l != null && le > l) {
1271
+ I == null || I(new Error(`max: ${l}`)), n == null || n(ee(l, x));
1038
1272
  return;
1039
1273
  }
1040
- n == null || n(Q);
1274
+ n == null || n(W);
1041
1275
  },
1042
- [C, G, i, l, n, T, x]
1043
- ), je = F(
1044
- ($) => {
1045
- const L = $.target.value;
1046
- he(L), Ue(L);
1276
+ [x, Q, s, l, n, U, I]
1277
+ ), ze = L(
1278
+ (R) => {
1279
+ const G = R.target.value;
1280
+ fe(G), Se(G);
1047
1281
  },
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));
1282
+ [Se]
1283
+ ), $e = L(
1284
+ (R) => {
1285
+ const W = (e ? e.amount / Math.pow(10, Q) : 0) + R, le = Math.min(l ?? 1 / 0, Math.max(s ?? -1 / 0, W));
1286
+ n == null || n(ee(le, x));
1053
1287
  },
1054
- [e, G, i, l, C, n]
1055
- ), _e = k(() => {
1056
- var $, L;
1288
+ [e, Q, s, l, x, n]
1289
+ ), ge = q(() => {
1290
+ var R, G;
1057
1291
  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 };
1292
+ const W = new Intl.NumberFormat(p).formatToParts(12345.6), le = ((R = W.find((ue) => ue.type === "group")) == null ? void 0 : R.value) ?? ",", de = ((G = W.find((ue) => ue.type === "decimal")) == null ? void 0 : G.value) ?? ".";
1293
+ return { group: le, decimal: de };
1060
1294
  } catch {
1061
1295
  return { group: ",", decimal: "." };
1062
1296
  }
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"),
1297
+ }, [p]), xe = D ?? !!ge.group, Ye = q(() => {
1298
+ if (!xe || _e === !1)
1299
+ return ke;
1300
+ const R = ge.decimal, G = ge.group, W = ke.replace(
1301
+ new RegExp(`[${G.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")}]`, "g"),
1068
1302
  ""
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,
1303
+ ), [le, de] = W.split(R);
1304
+ if (!le)
1305
+ return W;
1306
+ const ue = le.replace(/\B(?=(\d{3})+(?!\d))/g, G);
1307
+ return de != null ? `${ue}${R}${de}` : ue;
1308
+ }, [ke, _e, xe, ge]), Re = q(() => e ? ce(e, { locale: p }) : "", [e, p]), pe = typeof _ == "string" ? _ : void 0, Ge = `nice-money-input nice-money-input--${b} nice-money-input--label-${A} nice-money-input--error-${T}` + (pe ? " nice-money-input--error" : "") + (ae ? " nice-money-input--disabled" : "") + (w ? " nice-money-input--loading" : "") + (Y ? ` ${Y}` : ""), Ze = (R) => {
1309
+ v && R.key === "Enter" && j && (R.preventDefault(), j());
1310
+ }, Je = A === "left" && C != null ? { width: typeof C == "number" ? `${C}px` : C, flex: "none" } : void 0, Xe = P != null ? {
1311
+ width: typeof P == "number" ? `${P}px` : P,
1078
1312
  flex: "none"
1079
1313
  } : void 0;
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: "*" })
1314
+ return B ? null : /* @__PURE__ */ h("div", { ref: re, className: Ge, style: E, title: O, "data-testid": ne, children: [
1315
+ y && /* @__PURE__ */ h("label", { htmlFor: S, className: "nice-money-input__label", style: Je, children: [
1316
+ y,
1317
+ $ && /* @__PURE__ */ c("span", { className: "nice-money-input__required", "aria-hidden": !0, children: "*" })
1084
1318
  ] }),
1085
- /* @__PURE__ */ N("div", { className: "nice-money-input__row", style: Je, children: [
1086
- !o && /* @__PURE__ */ s(
1087
- qe,
1319
+ /* @__PURE__ */ h("div", { className: "nice-money-input__row", style: Xe, children: [
1320
+ !o && /* @__PURE__ */ c(
1321
+ He,
1088
1322
  {
1089
- value: C,
1323
+ value: x,
1090
1324
  compact: !0,
1091
- options: a ? a.map(V).filter(($) => !!$) : void 0,
1092
- onChange: ($) => r == null ? void 0 : r($),
1093
- disabled: ee || w,
1325
+ options: i ? i.map(V).filter((R) => !!R) : void 0,
1326
+ onChange: (R) => a == null ? void 0 : a(R),
1327
+ disabled: ae || M,
1094
1328
  className: "nice-money-input__currency",
1095
1329
  "aria-label": "Currency"
1096
1330
  }
1097
1331
  ),
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(
1332
+ o && /* @__PURE__ */ c("span", { className: "nice-money-input__symbol", "aria-hidden": !0, children: (oe == null ? void 0 : oe.symbol) ?? x }),
1333
+ Z && /* @__PURE__ */ c(
1100
1334
  "button",
1101
1335
  {
1102
1336
  type: "button",
1103
1337
  className: "nice-money-input__step nice-money-input__step--down",
1104
- onClick: () => Re(-xe),
1105
- disabled: ee || w || i != null && e != null && e.amount / Math.pow(10, G) <= i,
1338
+ onClick: () => $e(-Pe),
1339
+ disabled: ae || M || s != null && e != null && e.amount / Math.pow(10, Q) <= s,
1106
1340
  "aria-label": "Decrease amount",
1107
1341
  tabIndex: -1,
1108
1342
  children: "−"
1109
1343
  }
1110
1344
  ),
1111
- /* @__PURE__ */ s(
1345
+ /* @__PURE__ */ c(
1112
1346
  "input",
1113
1347
  {
1114
- id: D,
1115
- name: se,
1348
+ id: S,
1349
+ name: te,
1116
1350
  type: "text",
1117
1351
  inputMode: "decimal",
1118
1352
  autoComplete: "transaction-amount",
1119
1353
  className: "nice-money-input__amount",
1120
- value: ze,
1121
- onChange: je,
1122
- onKeyDown: Ye,
1123
- onFocus: ($) => {
1124
- Se(!0), U == null || U($);
1354
+ value: Ye,
1355
+ onChange: ze,
1356
+ onKeyDown: Ze,
1357
+ onFocus: (R) => {
1358
+ Ie(!0), u == null || u(R);
1125
1359
  },
1126
- onBlur: ($) => {
1127
- Se(!1), e && he((e.amount / Math.pow(10, G)).toFixed(G)), H == null || H($);
1360
+ onBlur: (R) => {
1361
+ Ie(!1), e && fe((e.amount / Math.pow(10, Q)).toFixed(Q)), z == null || z(R);
1128
1362
  },
1129
- placeholder: b ?? `0${G > 0 ? "." + "0".repeat(G) : ""}`,
1130
- disabled: ee,
1131
- readOnly: w,
1132
- required: S,
1363
+ placeholder: g ?? `0${Q > 0 ? "." + "0".repeat(Q) : ""}`,
1364
+ disabled: ae,
1365
+ readOnly: M,
1366
+ required: $,
1133
1367
  "aria-invalid": !!pe,
1134
- "aria-describedby": pe || d ? `${D}-help` : void 0
1368
+ "aria-describedby": pe || m ? `${S}-help` : void 0
1135
1369
  }
1136
1370
  ),
1137
- J && /* @__PURE__ */ s(
1371
+ Z && /* @__PURE__ */ c(
1138
1372
  "button",
1139
1373
  {
1140
1374
  type: "button",
1141
1375
  className: "nice-money-input__step nice-money-input__step--up",
1142
- onClick: () => Re(xe),
1143
- disabled: ee || w || l != null && e != null && e.amount / Math.pow(10, G) >= l,
1376
+ onClick: () => $e(Pe),
1377
+ disabled: ae || M || l != null && e != null && e.amount / Math.pow(10, Q) >= l,
1144
1378
  "aria-label": "Increase amount",
1145
1379
  tabIndex: -1,
1146
1380
  children: "+"
1147
1381
  }
1148
1382
  ),
1149
- g && /* @__PURE__ */ s("span", { className: "nice-money-input__spinner", "aria-hidden": !0, children: "⟳" })
1383
+ w && /* @__PURE__ */ c("span", { className: "nice-money-input__spinner", "aria-hidden": !0, children: "⟳" })
1150
1384
  ] }),
1151
- E && Pe && /* @__PURE__ */ s("span", { className: "nice-money-input__preview", "aria-live": "polite", children: Pe }),
1152
- (pe || d) && /* @__PURE__ */ s(
1385
+ K && Re && /* @__PURE__ */ c("span", { className: "nice-money-input__preview", "aria-live": "polite", children: Re }),
1386
+ (pe || m) && /* @__PURE__ */ c(
1153
1387
  "span",
1154
1388
  {
1155
- id: `${D}-help`,
1389
+ id: `${S}-help`,
1156
1390
  className: pe ? "nice-money-input__error" : "nice-money-input__helper",
1157
- children: pe ?? d
1391
+ children: pe ?? m
1158
1392
  }
1159
1393
  )
1160
1394
  ] });
1161
1395
  }
1162
- ), Ut = { number: "", expiry: "", cvc: "" }, Rt = de(
1396
+ ), Tt = { number: "", expiry: "", cvc: "" }, Kt = ie(
1163
1397
  function({
1164
- value: e = Ut,
1398
+ value: e = Tt,
1165
1399
  onChange: n,
1166
- showHolderName: c = !0,
1167
- requireHolderName: r,
1168
- showPostalCode: a = !1,
1400
+ showHolderName: r = !0,
1401
+ requireHolderName: a,
1402
+ showPostalCode: i = !1,
1169
1403
  acceptedBrands: o,
1170
- showBrandIcon: i = !0,
1404
+ showBrandIcon: s = !0,
1171
1405
  size: l = "md",
1172
- disabled: u,
1173
- readOnly: m,
1174
- loading: b,
1175
- accessMode: p,
1176
- label: d,
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({
1406
+ disabled: d,
1407
+ readOnly: p,
1408
+ loading: g,
1409
+ accessMode: y,
1410
+ label: m,
1411
+ helperText: _,
1412
+ error: b,
1413
+ required: f,
1414
+ className: N,
1415
+ style: $,
1416
+ id: w,
1417
+ title: k,
1418
+ "data-testid": A
1419
+ }, T) {
1420
+ const C = y === "hidden", P = d || y === "disabled" || g, v = p || y === "readOnly", j = be(), K = w ?? `nice-cc-${j}`, [Z, Y] = F({
1187
1421
  number: !1,
1188
1422
  expiry: !1,
1189
1423
  cvc: !1,
1190
1424
  holder: !1,
1191
1425
  postal: !1
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);
1426
+ }), E = q(() => ve(e.number), [e.number]), J = q(
1427
+ () => Ae(e, { requireHolder: a ?? r }),
1428
+ [e, a, r]
1429
+ ), te = !o || o.includes(E) || E === "unknown", O = L(
1430
+ (M) => {
1431
+ const B = { ...e, ...M }, se = Ae(B, { requireHolder: a ?? r });
1432
+ n == null || n(B, se);
1199
1433
  },
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 });
1434
+ [e, a, r, n]
1435
+ ), ne = L(
1436
+ (M) => {
1437
+ const B = M.target.value.replace(/\D/g, "").slice(0, 19);
1438
+ O({ number: B });
1205
1439
  },
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 });
1440
+ [O]
1441
+ ), z = L(
1442
+ (M) => {
1443
+ const B = M.target.value.replace(/\D/g, "").slice(0, 4);
1444
+ let se = B;
1445
+ B.length >= 3 ? se = `${B.slice(0, 2)}/${B.slice(2)}` : B.length === 2 && (se = `${B}/`), O({ expiry: se });
1212
1446
  },
1213
- [A]
1214
- ), U = F(
1215
- (w) => {
1216
- const I = w.target.value.replace(/\D/g, "").slice(0, ye(P));
1217
- A({ cvc: I });
1447
+ [O]
1448
+ ), u = L(
1449
+ (M) => {
1450
+ const B = M.target.value.replace(/\D/g, "").slice(0, ye(E));
1451
+ O({ cvc: B });
1218
1452
  },
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: [
1222
- d && /* @__PURE__ */ N("div", { className: "nice-credit-card__title", children: [
1223
- d,
1224
- y && /* @__PURE__ */ s("span", { className: "nice-credit-card__required", "aria-hidden": !0, children: "*" })
1453
+ [E, O]
1454
+ ), D = q(() => ot(e.number, E), [e.number, E]), U = Z.number && e.number.length > 0 && (Fe(e.number) ? te ? void 0 : "Card brand not accepted" : J.errors.number), I = Z.expiry && e.expiry.length > 0 && !Le(e.expiry) ? J.errors.expiry : void 0, re = Z.cvc && e.cvc.length > 0 && e.cvc.length !== ye(E) ? J.errors.cvc : void 0, ae = `nice-credit-card nice-credit-card--${l}` + (P ? " nice-credit-card--disabled" : "") + (g ? " nice-credit-card--loading" : "") + (b ? " nice-credit-card--error" : "") + (N ? ` ${N}` : "");
1455
+ return C ? null : /* @__PURE__ */ h("div", { ref: T, className: ae, style: $, title: k, "data-testid": A, children: [
1456
+ m && /* @__PURE__ */ h("div", { className: "nice-credit-card__title", children: [
1457
+ m,
1458
+ f && /* @__PURE__ */ c("span", { className: "nice-credit-card__required", "aria-hidden": !0, children: "*" })
1225
1459
  ] }),
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" }),
1228
- /* @__PURE__ */ N("span", { className: "nice-credit-card__input-wrapper", children: [
1229
- /* @__PURE__ */ s(
1460
+ /* @__PURE__ */ c("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ h("label", { className: "nice-credit-card__field nice-credit-card__field--number", children: [
1461
+ /* @__PURE__ */ c("span", { className: "nice-credit-card__label", children: "Card number" }),
1462
+ /* @__PURE__ */ h("span", { className: "nice-credit-card__input-wrapper", children: [
1463
+ /* @__PURE__ */ c(
1230
1464
  "input",
1231
1465
  {
1232
- id: `${E}-number`,
1466
+ id: `${K}-number`,
1233
1467
  type: "text",
1234
1468
  inputMode: "numeric",
1235
1469
  autoComplete: "cc-number",
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,
1470
+ placeholder: E === "amex" ? "3782 822463 10005" : "1234 1234 1234 1234",
1471
+ value: D,
1472
+ onChange: ne,
1473
+ onBlur: () => Y((M) => ({ ...M, number: !0 })),
1474
+ disabled: P,
1475
+ readOnly: v,
1476
+ "aria-invalid": !!U,
1477
+ "aria-describedby": U ? `${K}-number-err` : void 0,
1244
1478
  className: "nice-credit-card__input",
1245
- maxLength: P === "amex" ? 17 : 23
1479
+ maxLength: E === "amex" ? 17 : 23
1246
1480
  }
1247
1481
  ),
1248
- i && /* @__PURE__ */ s(Mt, { brand: P })
1482
+ s && /* @__PURE__ */ c(Ot, { brand: E })
1249
1483
  ] }),
1250
- T && /* @__PURE__ */ s("span", { id: `${E}-number-err`, className: "nice-credit-card__error", children: T })
1484
+ U && /* @__PURE__ */ c("span", { id: `${K}-number-err`, className: "nice-credit-card__error", children: U })
1251
1485
  ] }) }),
1252
- /* @__PURE__ */ N("div", { className: "nice-credit-card__row nice-credit-card__row--split", children: [
1253
- /* @__PURE__ */ N("label", { className: "nice-credit-card__field", children: [
1254
- /* @__PURE__ */ s("span", { className: "nice-credit-card__label", children: "Expiry" }),
1255
- /* @__PURE__ */ s(
1486
+ /* @__PURE__ */ h("div", { className: "nice-credit-card__row nice-credit-card__row--split", children: [
1487
+ /* @__PURE__ */ h("label", { className: "nice-credit-card__field", children: [
1488
+ /* @__PURE__ */ c("span", { className: "nice-credit-card__label", children: "Expiry" }),
1489
+ /* @__PURE__ */ c(
1256
1490
  "input",
1257
1491
  {
1258
- id: `${E}-expiry`,
1492
+ id: `${K}-expiry`,
1259
1493
  type: "text",
1260
1494
  inputMode: "numeric",
1261
1495
  autoComplete: "cc-exp",
1262
1496
  placeholder: "MM/YY",
1263
1497
  value: e.expiry,
1264
- onChange: H,
1498
+ onChange: z,
1265
1499
  onBlur: () => {
1266
- z((I) => ({ ...I, expiry: !0 }));
1267
- const w = Te(e.expiry);
1268
- w && w !== e.expiry && A({ expiry: w });
1500
+ Y((B) => ({ ...B, expiry: !0 }));
1501
+ const M = Be(e.expiry);
1502
+ M && M !== e.expiry && O({ expiry: M });
1269
1503
  },
1270
- disabled: R,
1271
- readOnly: q,
1272
- "aria-invalid": !!x,
1273
- "aria-describedby": x ? `${E}-expiry-err` : void 0,
1504
+ disabled: P,
1505
+ readOnly: v,
1506
+ "aria-invalid": !!I,
1507
+ "aria-describedby": I ? `${K}-expiry-err` : void 0,
1274
1508
  className: "nice-credit-card__input",
1275
1509
  maxLength: 5
1276
1510
  }
1277
1511
  ),
1278
- x && /* @__PURE__ */ s("span", { id: `${E}-expiry-err`, className: "nice-credit-card__error", children: x })
1512
+ I && /* @__PURE__ */ c("span", { id: `${K}-expiry-err`, className: "nice-credit-card__error", children: I })
1279
1513
  ] }),
1280
- /* @__PURE__ */ N("label", { className: "nice-credit-card__field", children: [
1281
- /* @__PURE__ */ s("span", { className: "nice-credit-card__label", children: P === "amex" ? "CID" : "CVC" }),
1282
- /* @__PURE__ */ s(
1514
+ /* @__PURE__ */ h("label", { className: "nice-credit-card__field", children: [
1515
+ /* @__PURE__ */ c("span", { className: "nice-credit-card__label", children: E === "amex" ? "CID" : "CVC" }),
1516
+ /* @__PURE__ */ c(
1283
1517
  "input",
1284
1518
  {
1285
- id: `${E}-cvc`,
1519
+ id: `${K}-cvc`,
1286
1520
  type: "text",
1287
1521
  inputMode: "numeric",
1288
1522
  autoComplete: "cc-csc",
1289
- placeholder: "•".repeat(ye(P)),
1523
+ placeholder: "•".repeat(ye(E)),
1290
1524
  value: e.cvc,
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,
1525
+ onChange: u,
1526
+ onBlur: () => Y((M) => ({ ...M, cvc: !0 })),
1527
+ disabled: P,
1528
+ readOnly: v,
1529
+ "aria-invalid": !!re,
1530
+ "aria-describedby": re ? `${K}-cvc-err` : void 0,
1297
1531
  className: "nice-credit-card__input",
1298
- maxLength: ye(P)
1532
+ maxLength: ye(E)
1299
1533
  }
1300
1534
  ),
1301
- le && /* @__PURE__ */ s("span", { id: `${E}-cvc-err`, className: "nice-credit-card__error", children: le })
1535
+ re && /* @__PURE__ */ c("span", { id: `${K}-cvc-err`, className: "nice-credit-card__error", children: re })
1302
1536
  ] })
1303
1537
  ] }),
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(
1538
+ r && /* @__PURE__ */ c("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ h("label", { className: "nice-credit-card__field", children: [
1539
+ /* @__PURE__ */ c("span", { className: "nice-credit-card__label", children: "Cardholder name" }),
1540
+ /* @__PURE__ */ c(
1307
1541
  "input",
1308
1542
  {
1309
- id: `${E}-holder`,
1543
+ id: `${K}-holder`,
1310
1544
  type: "text",
1311
1545
  autoComplete: "cc-name",
1312
1546
  placeholder: "Jane Doe",
1313
1547
  value: e.holderName ?? "",
1314
- onChange: (w) => A({ holderName: w.target.value }),
1315
- onBlur: () => z((w) => ({ ...w, holder: !0 })),
1316
- disabled: R,
1317
- readOnly: q,
1548
+ onChange: (M) => O({ holderName: M.target.value }),
1549
+ onBlur: () => Y((M) => ({ ...M, holder: !0 })),
1550
+ disabled: P,
1551
+ readOnly: v,
1318
1552
  className: "nice-credit-card__input",
1319
1553
  maxLength: 120
1320
1554
  }
1321
1555
  )
1322
1556
  ] }) }),
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(
1557
+ i && /* @__PURE__ */ c("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ h("label", { className: "nice-credit-card__field", children: [
1558
+ /* @__PURE__ */ c("span", { className: "nice-credit-card__label", children: "Postal code" }),
1559
+ /* @__PURE__ */ c(
1326
1560
  "input",
1327
1561
  {
1328
- id: `${E}-postal`,
1562
+ id: `${K}-postal`,
1329
1563
  type: "text",
1330
1564
  autoComplete: "postal-code",
1331
1565
  value: e.postalCode ?? "",
1332
- onChange: (w) => A({ postalCode: w.target.value }),
1333
- onBlur: () => z((w) => ({ ...w, postal: !0 })),
1334
- disabled: R,
1335
- readOnly: q,
1566
+ onChange: (M) => O({ postalCode: M.target.value }),
1567
+ onBlur: () => Y((M) => ({ ...M, postal: !0 })),
1568
+ disabled: P,
1569
+ readOnly: v,
1336
1570
  className: "nice-credit-card__input",
1337
1571
  maxLength: 16
1338
1572
  }
1339
1573
  )
1340
1574
  ] }) }),
1341
- (h || f) && /* @__PURE__ */ s(
1575
+ (b || _) && /* @__PURE__ */ c(
1342
1576
  "div",
1343
1577
  {
1344
- className: h ? "nice-credit-card__form-error" : "nice-credit-card__helper",
1345
- role: h ? "alert" : void 0,
1346
- children: h ?? f
1578
+ className: b ? "nice-credit-card__form-error" : "nice-credit-card__helper",
1579
+ role: b ? "alert" : void 0,
1580
+ children: b ?? _
1347
1581
  }
1348
1582
  )
1349
1583
  ] });
1350
1584
  }
1351
- ), Ee = {
1585
+ ), qe = {
1352
1586
  visa: "VISA",
1353
1587
  mastercard: "MasterCard",
1354
1588
  amex: "AMEX",
@@ -1362,406 +1596,666 @@ const Fe = de(function({
1362
1596
  hipercard: "Hipercard",
1363
1597
  unknown: ""
1364
1598
  };
1365
- function Mt({ brand: t }) {
1366
- return t === "unknown" ? null : /* @__PURE__ */ s(
1599
+ function Ot({ brand: t }) {
1600
+ return t === "unknown" ? null : /* @__PURE__ */ c(
1367
1601
  "span",
1368
1602
  {
1369
1603
  className: `nice-credit-card__brand nice-credit-card__brand--${t}`,
1370
- "aria-label": Ee[t],
1371
- children: Ee[t]
1604
+ "aria-label": qe[t],
1605
+ children: qe[t]
1372
1606
  }
1373
1607
  );
1374
1608
  }
1375
- const Jt = de(
1609
+ const sn = ie(
1376
1610
  function({
1377
1611
  processor: e,
1378
1612
  amount: n,
1379
- editableAmount: c,
1380
- customer: r,
1381
- currencies: a,
1613
+ editableAmount: r,
1614
+ customer: a,
1615
+ currencies: i,
1382
1616
  description: o,
1383
- metadata: i,
1617
+ metadata: s,
1384
1618
  autoCapture: l = !0,
1385
- submitLabel: u = "Pay",
1386
- onSuccess: m,
1387
- onError: b,
1388
- consents: p,
1389
- className: d,
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);
1619
+ submitLabel: d = "Pay",
1620
+ onSuccess: p,
1621
+ onError: g,
1622
+ consents: y,
1623
+ className: m,
1624
+ style: _
1625
+ }, b) {
1626
+ const [f, N] = F(n), [$, w] = F(n.currency), [k, A] = F({ number: "", expiry: "", cvc: "" }), [T, C] = F(null), [P, v] = F(!1), [j, K] = F(null), Z = qt(e), Y = q(() => e.supportedCurrencies === "*" ? !0 : e.supportedCurrencies.includes(f.currency.toUpperCase()), [e, f.currency]), E = q(() => {
1627
+ var D;
1628
+ const u = (D = e.minimums) == null ? void 0 : D[f.currency.toUpperCase()];
1629
+ return u == null || f.amount >= u;
1630
+ }, [e, f]), J = q(() => {
1631
+ var D;
1632
+ const u = (D = e.minimums) == null ? void 0 : D[f.currency.toUpperCase()];
1633
+ return u == null ? null : { amount: u, currency: f.currency };
1634
+ }, [e, f.currency]), te = !!(T != null && T.isValid), O = !P && Y && E && te, ne = L(
1635
+ async (u) => {
1636
+ if (u.preventDefault(), !!O) {
1637
+ K(null), v(!0);
1404
1638
  try {
1405
- const M = {
1406
- amount: y,
1407
- card: v,
1408
- customer: r,
1639
+ const D = {
1640
+ amount: f,
1641
+ card: k,
1642
+ customer: a,
1409
1643
  description: o,
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);
1644
+ metadata: s,
1645
+ idempotencyKey: Ft()
1646
+ }, U = await Z.authorize(D);
1647
+ if (l && U.status === "authorized") {
1648
+ const I = await Z.capture(U.id, f);
1649
+ p == null || p(I);
1416
1650
  } else
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);
1651
+ p == null || p(U);
1652
+ } catch (D) {
1653
+ const U = D instanceof Error ? D : new Error(String(D));
1654
+ K(U.message), g == null || g(U);
1421
1655
  } finally {
1422
- q(!1);
1656
+ v(!1);
1423
1657
  }
1424
1658
  }
1425
1659
  },
1426
1660
  [
1427
- A,
1428
- y,
1429
- v,
1430
- r,
1661
+ O,
1662
+ f,
1663
+ k,
1664
+ a,
1431
1665
  o,
1432
- i,
1666
+ s,
1433
1667
  l,
1434
- J,
1435
- m,
1436
- b
1668
+ Z,
1669
+ p,
1670
+ g
1437
1671
  ]
1438
- ), H = V(y.currency);
1439
- return /* @__PURE__ */ N(
1672
+ ), z = V(f.currency);
1673
+ return /* @__PURE__ */ h(
1440
1674
  "form",
1441
1675
  {
1442
- ref: h,
1443
- className: "nice-payment-form" + (d ? ` ${d}` : ""),
1444
- style: f,
1445
- onSubmit: oe,
1446
- "aria-busy": R,
1676
+ ref: b,
1677
+ className: "nice-payment-form" + (m ? ` ${m}` : ""),
1678
+ style: _,
1679
+ onSubmit: ne,
1680
+ "aria-busy": P,
1447
1681
  children: [
1448
- /* @__PURE__ */ s("div", { className: "nice-payment-form__amount", children: c ? /* @__PURE__ */ s(
1449
- He,
1682
+ /* @__PURE__ */ c("div", { className: "nice-payment-form__amount", children: r ? /* @__PURE__ */ c(
1683
+ je,
1450
1684
  {
1451
1685
  label: "Amount",
1452
- value: y,
1453
- currency: S,
1454
- currencies: a,
1455
- onChange: (U) => U && _(U),
1456
- onCurrencyChange: (U) => {
1457
- g(U), _((M) => ({ ...M, currency: U }));
1686
+ value: f,
1687
+ currency: $,
1688
+ currencies: i,
1689
+ onChange: (u) => u && N(u),
1690
+ onCurrencyChange: (u) => {
1691
+ w(u), N((D) => ({ ...D, currency: u }));
1458
1692
  },
1459
- disabled: R,
1693
+ disabled: P,
1460
1694
  required: !0,
1461
1695
  showFormattedPreview: !0
1462
1696
  }
1463
- ) : /* @__PURE__ */ N("div", { className: "nice-payment-form__total", children: [
1464
- /* @__PURE__ */ s("span", { className: "nice-payment-form__total-label", children: "Total" }),
1465
- /* @__PURE__ */ s(Fe, { value: y })
1697
+ ) : /* @__PURE__ */ h("div", { className: "nice-payment-form__total", children: [
1698
+ /* @__PURE__ */ c("span", { className: "nice-payment-form__total-label", children: "Total" }),
1699
+ /* @__PURE__ */ c(Ee, { value: f })
1466
1700
  ] }) }),
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,
1701
+ o && /* @__PURE__ */ c("p", { className: "nice-payment-form__description", children: o }),
1702
+ /* @__PURE__ */ c("div", { className: "nice-payment-form__card", children: /* @__PURE__ */ c(
1703
+ Kt,
1470
1704
  {
1471
- value: v,
1472
- onChange: (U, M) => {
1473
- O(U), Z(M);
1705
+ value: k,
1706
+ onChange: (u, D) => {
1707
+ A(u), C(D);
1474
1708
  },
1475
- disabled: R
1709
+ disabled: P
1476
1710
  }
1477
1711
  ) }),
1478
- !z && /* @__PURE__ */ N("div", { className: "nice-payment-form__warning", role: "alert", children: [
1712
+ !Y && /* @__PURE__ */ h("div", { className: "nice-payment-form__warning", role: "alert", children: [
1479
1713
  e.name,
1480
1714
  " does not accept ",
1481
- (H == null ? void 0 : H.name) ?? y.currency,
1715
+ (z == null ? void 0 : z.name) ?? f.currency,
1482
1716
  "."
1483
1717
  ] }),
1484
- !P && X && /* @__PURE__ */ N("div", { className: "nice-payment-form__warning", role: "alert", children: [
1718
+ !E && J && /* @__PURE__ */ h("div", { className: "nice-payment-form__warning", role: "alert", children: [
1485
1719
  "Minimum charge for ",
1486
1720
  e.name,
1487
1721
  " is ",
1488
- /* @__PURE__ */ s(Fe, { value: X }),
1722
+ /* @__PURE__ */ c(Ee, { value: J }),
1489
1723
  "."
1490
1724
  ] }),
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(
1725
+ y && /* @__PURE__ */ c("div", { className: "nice-payment-form__consents", children: y }),
1726
+ j && /* @__PURE__ */ c("div", { className: "nice-payment-form__error", role: "alert", children: j }),
1727
+ /* @__PURE__ */ c(
1494
1728
  "button",
1495
1729
  {
1496
1730
  type: "submit",
1497
1731
  className: "nice-payment-form__submit",
1498
- disabled: !A,
1499
- "aria-disabled": !A,
1500
- children: R ? "Processing…" : u
1732
+ disabled: !O,
1733
+ "aria-disabled": !O,
1734
+ children: P ? "Processing…" : d
1501
1735
  }
1502
1736
  ),
1503
- /* @__PURE__ */ N("p", { className: "nice-payment-form__processor", children: [
1737
+ /* @__PURE__ */ h("p", { className: "nice-payment-form__processor", children: [
1504
1738
  "Secured by ",
1505
- /* @__PURE__ */ s("strong", { children: e.name })
1739
+ /* @__PURE__ */ c("strong", { children: e.name })
1506
1740
  ] })
1507
1741
  ]
1508
1742
  }
1509
1743
  );
1510
1744
  }
1511
1745
  );
1512
- function Pt() {
1746
+ function Ft() {
1513
1747
  return typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `idem_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`;
1514
1748
  }
1515
- const Xt = de(function({
1749
+ const on = ie(function({
1516
1750
  price: e,
1517
1751
  originalPrice: n,
1518
- period: c,
1519
- prefix: r,
1520
- suffix: a,
1752
+ period: r,
1753
+ prefix: a,
1754
+ suffix: i,
1521
1755
  showDiscountBadge: o = !0,
1522
- size: i = "md",
1756
+ size: s = "md",
1523
1757
  locale: l,
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 }),
1530
- /* @__PURE__ */ N("span", { className: "nice-price-tag__main", children: [
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 })
1758
+ className: d,
1759
+ style: p
1760
+ }, g) {
1761
+ const y = n && n.currency === e.currency && n.amount > e.amount, m = q(() => !y || !n ? null : Math.round((n.amount - e.amount) / n.amount * 100), [y, n, e.amount]), _ = `nice-price-tag nice-price-tag--${s}` + (d ? ` ${d}` : "");
1762
+ return /* @__PURE__ */ h("div", { ref: g, className: _, style: p, children: [
1763
+ a && /* @__PURE__ */ c("span", { className: "nice-price-tag__prefix", children: a }),
1764
+ /* @__PURE__ */ h("span", { className: "nice-price-tag__main", children: [
1765
+ /* @__PURE__ */ c("span", { className: "nice-price-tag__amount", children: ce(e, { locale: l }) }),
1766
+ r && /* @__PURE__ */ c("span", { className: "nice-price-tag__period", children: r })
1533
1767
  ] }),
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: [
1768
+ y && n && /* @__PURE__ */ c("span", { className: "nice-price-tag__original", "aria-label": "Original price", children: /* @__PURE__ */ c("s", { children: ce(n, { locale: l }) }) }),
1769
+ y && o && m != null && m > 0 && /* @__PURE__ */ h("span", { className: "nice-price-tag__discount", "aria-label": `${m} percent off`, children: [
1536
1770
  "−",
1537
- d,
1771
+ m,
1538
1772
  "%"
1539
1773
  ] }),
1540
- a && /* @__PURE__ */ s("span", { className: "nice-price-tag__suffix", children: a })
1774
+ i && /* @__PURE__ */ c("span", { className: "nice-price-tag__suffix", children: i })
1541
1775
  ] });
1542
- }), Qt = de(
1776
+ }), ln = ie(
1543
1777
  function({
1544
1778
  source: e,
1545
1779
  onSourceChange: n,
1546
- targetCurrency: c,
1547
- onTargetCurrencyChange: r,
1548
- provider: a,
1780
+ targetCurrency: r,
1781
+ onTargetCurrencyChange: a,
1782
+ provider: i,
1549
1783
  locale: o,
1550
- showRateLine: i = !0,
1784
+ showRateLine: s = !0,
1551
1785
  className: l,
1552
- style: u
1553
- }, m) {
1554
- const { converted: b, loading: p, error: d } = ve(e, c, a), f = k(
1786
+ style: d
1787
+ }, p) {
1788
+ const { converted: g, loading: y, error: m } = Ce(e, r, i), _ = q(
1555
1789
  () => ({ amount: Math.pow(10, 2), currency: e.currency }),
1556
1790
  [e.currency]
1557
- ), { converted: h } = ve(
1558
- i ? f : null,
1559
- c,
1560
- a
1791
+ ), { converted: b } = Ce(
1792
+ s ? _ : null,
1793
+ r,
1794
+ i
1561
1795
  );
1562
- return /* @__PURE__ */ N(
1796
+ return /* @__PURE__ */ h(
1563
1797
  "div",
1564
1798
  {
1565
- ref: m,
1799
+ ref: p,
1566
1800
  className: "nice-currency-converter" + (l ? ` ${l}` : ""),
1567
- style: u,
1801
+ style: d,
1568
1802
  children: [
1569
- /* @__PURE__ */ s("div", { className: "nice-currency-converter__row", children: /* @__PURE__ */ s(
1570
- He,
1803
+ /* @__PURE__ */ c("div", { className: "nice-currency-converter__row", children: /* @__PURE__ */ c(
1804
+ je,
1571
1805
  {
1572
1806
  label: "From",
1573
1807
  value: e,
1574
- onChange: (y) => y && n(y),
1808
+ onChange: (f) => f && n(f),
1575
1809
  currency: e.currency,
1576
- onCurrencyChange: (y) => n({ ...e, currency: y }),
1810
+ onCurrencyChange: (f) => n({ ...e, currency: f }),
1577
1811
  showFormattedPreview: !1
1578
1812
  }
1579
1813
  ) }),
1580
- /* @__PURE__ */ N("div", { className: "nice-currency-converter__row", children: [
1581
- /* @__PURE__ */ s("label", { className: "nice-currency-converter__label", children: "To" }),
1582
- /* @__PURE__ */ N("div", { className: "nice-currency-converter__output", children: [
1583
- /* @__PURE__ */ s(
1584
- qe,
1814
+ /* @__PURE__ */ h("div", { className: "nice-currency-converter__row", children: [
1815
+ /* @__PURE__ */ c("label", { className: "nice-currency-converter__label", children: "To" }),
1816
+ /* @__PURE__ */ h("div", { className: "nice-currency-converter__output", children: [
1817
+ /* @__PURE__ */ c(
1818
+ He,
1585
1819
  {
1586
- value: c,
1587
- onChange: (y) => r(y),
1820
+ value: r,
1821
+ onChange: (f) => a(f),
1588
1822
  compact: !0
1589
1823
  }
1590
1824
  ),
1591
- /* @__PURE__ */ s("span", { className: "nice-currency-converter__amount", children: p ? "…" : d ? "—" : b ? te(b, { locale: o }) : "" })
1825
+ /* @__PURE__ */ c("span", { className: "nice-currency-converter__amount", children: y ? "…" : m ? "—" : g ? ce(g, { locale: o }) : "" })
1592
1826
  ] })
1593
1827
  ] }),
1594
- i && h && /* @__PURE__ */ N("p", { className: "nice-currency-converter__rate", children: [
1828
+ s && b && /* @__PURE__ */ h("p", { className: "nice-currency-converter__rate", children: [
1595
1829
  "1 ",
1596
1830
  e.currency,
1597
1831
  " = ",
1598
- te(h, { locale: o }),
1832
+ ce(b, { locale: o }),
1599
1833
  " ",
1600
- /* @__PURE__ */ N("span", { className: "nice-currency-converter__inverse", children: [
1834
+ /* @__PURE__ */ h("span", { className: "nice-currency-converter__inverse", children: [
1601
1835
  "· 1 ",
1602
- c,
1836
+ r,
1603
1837
  " =",
1604
1838
  " ",
1605
- te(W(1 / Ke(h), e.currency), { locale: o })
1839
+ ce(ee(1 / Oe(b), e.currency), { locale: o })
1606
1840
  ] })
1607
1841
  ] }),
1608
- d && /* @__PURE__ */ s("p", { className: "nice-currency-converter__error", role: "alert", children: d.message })
1842
+ m && /* @__PURE__ */ c("p", { className: "nice-currency-converter__error", role: "alert", children: m.message })
1609
1843
  ]
1610
1844
  }
1611
1845
  );
1612
1846
  }
1613
1847
  );
1614
- function Ae(t) {
1848
+ function Te(t) {
1615
1849
  return { amount: Math.round(t.amount), currency: t.currency };
1616
1850
  }
1617
- const Vt = de(
1851
+ const dn = ie(
1618
1852
  function({
1619
1853
  lines: e,
1620
1854
  locale: n,
1621
- rounding: c = "line",
1622
- showTotals: r = !0,
1623
- showGrandTotal: a = !0,
1855
+ rounding: r = "line",
1856
+ showTotals: a = !0,
1857
+ showGrandTotal: i = !0,
1624
1858
  hideRateColumn: o = !1,
1625
- labels: i,
1859
+ labels: s,
1626
1860
  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);
1861
+ className: d,
1862
+ style: p,
1863
+ id: g
1864
+ }, y) {
1865
+ const m = {
1866
+ label: (s == null ? void 0 : s.label) ?? "Item",
1867
+ rate: (s == null ? void 0 : s.rate) ?? "VAT",
1868
+ net: (s == null ? void 0 : s.net) ?? "Net",
1869
+ vat: (s == null ? void 0 : s.vat) ?? "Tax",
1870
+ gross: (s == null ? void 0 : s.gross) ?? "Gross",
1871
+ total: (s == null ? void 0 : s.total) ?? "Total"
1872
+ }, _ = q(() => {
1873
+ if (r === "total") {
1874
+ const N = /* @__PURE__ */ new Map();
1875
+ for (const w of e) {
1876
+ let k = N.get(w.vatRate);
1877
+ k || (k = [], N.set(w.vatRate, k)), k.push(w.netAmount);
1644
1878
  }
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 });
1879
+ const $ = [];
1880
+ for (const [w, k] of N) {
1881
+ const A = k.reduce((P, v) => me(P, v), ee(0, k[0].currency)), T = Te(De(A, w)), C = me(A, T);
1882
+ $.push({ rate: w, net: A, vat: T, gross: C });
1649
1883
  }
1650
- return S;
1884
+ return $;
1651
1885
  }
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 };
1886
+ return e.map((N) => {
1887
+ const $ = Te(De(N.netAmount, N.vatRate)), w = me(N.netAmount, $);
1888
+ return { label: N.label, rate: N.vatRate, net: N.netAmount, vat: $, gross: w };
1655
1889
  });
1656
- }, [e, c]), h = k(() => {
1657
- if (f.length === 0)
1890
+ }, [e, r]), b = q(() => {
1891
+ if (_.length === 0)
1658
1892
  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(
1893
+ const N = _[0].net.currency;
1894
+ let $ = ee(0, N), w = ee(0, N), k = ee(0, N);
1895
+ for (const A of _)
1896
+ $ = me($, A.net), w = me(w, A.vat), k = me(k, A.gross);
1897
+ return { net: $, vat: w, gross: k };
1898
+ }, [_]), f = (N) => ce(N, { locale: n });
1899
+ return /* @__PURE__ */ h(
1666
1900
  "table",
1667
1901
  {
1668
- ref: p,
1669
- id: b,
1670
- className: `nice-tax-breakdown nice-tax-breakdown--${l} ${u ?? ""}`,
1671
- style: m,
1902
+ ref: y,
1903
+ id: g,
1904
+ className: `nice-tax-breakdown nice-tax-breakdown--${l} ${d ?? ""}`,
1905
+ style: p,
1672
1906
  role: "table",
1673
- "aria-label": d.total,
1907
+ "aria-label": m.total,
1674
1908
  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 })
1909
+ /* @__PURE__ */ c("thead", { children: /* @__PURE__ */ h("tr", { children: [
1910
+ _.some((N) => N.label !== void 0) && /* @__PURE__ */ c("th", { scope: "col", children: m.label }),
1911
+ !o && /* @__PURE__ */ c("th", { scope: "col", className: "nice-tax-breakdown__rate", children: m.rate }),
1912
+ /* @__PURE__ */ c("th", { scope: "col", className: "nice-tax-breakdown__num", children: m.net }),
1913
+ /* @__PURE__ */ c("th", { scope: "col", className: "nice-tax-breakdown__num", children: m.vat }),
1914
+ /* @__PURE__ */ c("th", { scope: "col", className: "nice-tax-breakdown__num", children: m.gross })
1681
1915
  ] }) }),
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 }),
1916
+ /* @__PURE__ */ c("tbody", { children: _.map((N, $) => /* @__PURE__ */ h("tr", { children: [
1917
+ _.some((w) => w.label !== void 0) && /* @__PURE__ */ c("td", { children: N.label ?? "" }),
1918
+ !o && /* @__PURE__ */ h("td", { className: "nice-tax-breakdown__rate", children: [
1919
+ (N.rate * 100).toLocaleString(n, { maximumFractionDigits: 2 }),
1686
1920
  "%"
1687
1921
  ] }),
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) })
1922
+ /* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: f(N.net) }),
1923
+ /* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: f(N.vat) }),
1924
+ /* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: f(N.gross) })
1925
+ ] }, `${N.rate}-${$}`)) }),
1926
+ a && b && /* @__PURE__ */ c("tfoot", { children: i && /* @__PURE__ */ h("tr", { className: "nice-tax-breakdown__totals", children: [
1927
+ _.some((N) => N.label !== void 0) && /* @__PURE__ */ c("td", { children: m.total }),
1928
+ !o && /* @__PURE__ */ c("td", {}),
1929
+ /* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: f(b.net) }),
1930
+ /* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: f(b.vat) }),
1931
+ /* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: f(b.gross) })
1698
1932
  ] }) })
1699
1933
  ]
1700
1934
  }
1701
1935
  );
1702
1936
  }
1937
+ ), un = ie(
1938
+ function(e, n) {
1939
+ const {
1940
+ methods: r,
1941
+ value: a,
1942
+ onChange: i,
1943
+ layout: o = "list",
1944
+ columns: s = 2,
1945
+ currency: l,
1946
+ label: d,
1947
+ name: p,
1948
+ readOnly: g = !1,
1949
+ className: y,
1950
+ style: m,
1951
+ id: _,
1952
+ accessMode: b,
1953
+ "data-testid": f
1954
+ } = e, N = be(), $ = p ?? `nice-pm-${N}`, w = q(() => {
1955
+ if (!l)
1956
+ return r;
1957
+ const C = l.toUpperCase();
1958
+ return r.filter(
1959
+ (P) => !P.currencies || P.currencies.map((v) => v.toUpperCase()).includes(C)
1960
+ );
1961
+ }, [r, l]);
1962
+ if (b === "hidden")
1963
+ return null;
1964
+ const k = g || b === "disabled" || b === "readOnly", A = `nice-payment-method-selector nice-payment-method-selector--${o}` + (y ? ` ${y}` : ""), T = o === "grid" ? { gridTemplateColumns: `repeat(${s}, minmax(0, 1fr))` } : void 0;
1965
+ return /* @__PURE__ */ h("div", { ref: n, id: _, className: A, style: m, "data-testid": f, children: [
1966
+ d && /* @__PURE__ */ c("div", { className: "nice-payment-method-selector__label", children: d }),
1967
+ /* @__PURE__ */ h(
1968
+ "div",
1969
+ {
1970
+ className: "nice-payment-method-selector__options",
1971
+ style: T,
1972
+ role: "radiogroup",
1973
+ "aria-label": d ?? "Payment method",
1974
+ children: [
1975
+ w.map((C) => {
1976
+ const P = C.id === a, v = k || C.disabled;
1977
+ return /* @__PURE__ */ h(
1978
+ "label",
1979
+ {
1980
+ className: "nice-payment-method-selector__option" + (P ? " nice-payment-method-selector__option--selected" : "") + (v ? " nice-payment-method-selector__option--disabled" : ""),
1981
+ children: [
1982
+ /* @__PURE__ */ c(
1983
+ "input",
1984
+ {
1985
+ type: "radio",
1986
+ className: "nice-payment-method-selector__radio",
1987
+ name: $,
1988
+ value: C.id,
1989
+ checked: P,
1990
+ disabled: v,
1991
+ onChange: () => i == null ? void 0 : i(C.id)
1992
+ }
1993
+ ),
1994
+ C.icon && /* @__PURE__ */ c("span", { className: "nice-payment-method-selector__icon", children: C.icon }),
1995
+ /* @__PURE__ */ h("span", { className: "nice-payment-method-selector__text", children: [
1996
+ /* @__PURE__ */ c("span", { className: "nice-payment-method-selector__name", children: C.label }),
1997
+ C.description && /* @__PURE__ */ c("span", { className: "nice-payment-method-selector__desc", children: C.description })
1998
+ ] })
1999
+ ]
2000
+ },
2001
+ C.id
2002
+ );
2003
+ }),
2004
+ w.length === 0 && /* @__PURE__ */ c("div", { className: "nice-payment-method-selector__empty", children: "No methods available." })
2005
+ ]
2006
+ }
2007
+ )
2008
+ ] });
2009
+ }
2010
+ ), Bt = [
2011
+ {
2012
+ target: ".nice-payment-provider-config",
2013
+ titleKey: "tutorial.paymentProviderConfig.intro.title",
2014
+ title: "Payment provider",
2015
+ contentKey: "tutorial.paymentProviderConfig.intro.content",
2016
+ content: "Pick a provider, fill its credentials (secrets are masked), choose test/live, enable methods and copy the webhook URL.",
2017
+ placement: "auto"
2018
+ }
2019
+ ], mn = ie(
2020
+ function(e, n) {
2021
+ const {
2022
+ value: r,
2023
+ onChange: a,
2024
+ providers: i,
2025
+ onTestConnection: o,
2026
+ showWebhookUrl: s = !0,
2027
+ baseUrl: l,
2028
+ readOnly: d = !1,
2029
+ testLabel: p = "Test connection",
2030
+ tutorial: g,
2031
+ className: y,
2032
+ style: m,
2033
+ id: _,
2034
+ accessMode: b,
2035
+ "data-testid": f
2036
+ } = e, N = be(), [$, w] = F(/* @__PURE__ */ new Set()), [k, A] = F(!1), [T, C] = F(null), P = q(() => i ? i.map((u) => Ne[u]).filter((u) => !!u) : Et, [i]), v = Ne[r.providerId];
2037
+ if (b === "hidden")
2038
+ return null;
2039
+ const j = d || b === "disabled" || b === "readOnly", K = (u) => {
2040
+ C(null), w(/* @__PURE__ */ new Set()), a({ providerId: u, mode: r.mode, credentials: {}, enabledMethods: [] });
2041
+ }, Z = (u, D) => {
2042
+ a({ ...r, credentials: { ...r.credentials, [u]: D } });
2043
+ }, Y = (u) => {
2044
+ const D = new Set(r.enabledMethods ?? []);
2045
+ D.has(u) ? D.delete(u) : D.add(u), a({ ...r, enabledMethods: [...D] });
2046
+ }, E = (u) => {
2047
+ w((D) => {
2048
+ const U = new Set(D);
2049
+ return U.has(u) ? U.delete(u) : U.add(u), U;
2050
+ });
2051
+ }, J = async () => {
2052
+ if (o) {
2053
+ A(!0), C(null);
2054
+ try {
2055
+ C(await o(r));
2056
+ } catch (u) {
2057
+ C({ ok: !1, message: u instanceof Error ? u.message : String(u) });
2058
+ } finally {
2059
+ A(!1);
2060
+ }
2061
+ }
2062
+ }, te = v != null && v.webhookPath ? `${(l ?? "").replace(/\/$/, "")}${v.webhookPath}` : "", O = (v == null ? void 0 : v.supportedCurrencies) === "*" ? "All currencies" : ((v == null ? void 0 : v.supportedCurrencies) ?? []).join(", "), ne = "nice-payment-provider-config" + (y ? ` ${y}` : ""), z = ((v == null ? void 0 : v.credentials) ?? []).filter(
2063
+ (u) => !u.testOnly || r.mode === "test"
2064
+ );
2065
+ return /* @__PURE__ */ h("div", { ref: n, id: _, className: ne, style: m, "data-testid": f, children: [
2066
+ g && /* @__PURE__ */ c("div", { className: "nice-payment-provider-config__tutorial", children: /* @__PURE__ */ c(rt, { steps: at(g, Bt) }) }),
2067
+ /* @__PURE__ */ h("div", { className: "nice-payment-provider-config__row", children: [
2068
+ /* @__PURE__ */ h("label", { className: "nice-payment-provider-config__field", children: [
2069
+ /* @__PURE__ */ c("span", { className: "nice-payment-provider-config__field-label", children: "Provider" }),
2070
+ /* @__PURE__ */ h(
2071
+ "select",
2072
+ {
2073
+ className: "nice-payment-provider-config__select",
2074
+ value: r.providerId,
2075
+ disabled: j,
2076
+ onChange: (u) => K(u.target.value),
2077
+ children: [
2078
+ /* @__PURE__ */ c("option", { value: "", children: "— select provider —" }),
2079
+ P.map((u) => /* @__PURE__ */ c("option", { value: u.id, children: u.name }, u.id))
2080
+ ]
2081
+ }
2082
+ )
2083
+ ] }),
2084
+ (v == null ? void 0 : v.hasTestMode) && /* @__PURE__ */ h("div", { className: "nice-payment-provider-config__mode", role: "group", "aria-label": "Mode", children: [
2085
+ /* @__PURE__ */ c(
2086
+ "button",
2087
+ {
2088
+ type: "button",
2089
+ className: "nice-payment-provider-config__mode-btn" + (r.mode === "test" ? " nice-payment-provider-config__mode-btn--active" : ""),
2090
+ onClick: () => a({ ...r, mode: "test" }),
2091
+ disabled: j,
2092
+ children: "Test"
2093
+ }
2094
+ ),
2095
+ /* @__PURE__ */ c(
2096
+ "button",
2097
+ {
2098
+ type: "button",
2099
+ className: "nice-payment-provider-config__mode-btn" + (r.mode === "live" ? " nice-payment-provider-config__mode-btn--active" : ""),
2100
+ onClick: () => a({ ...r, mode: "live" }),
2101
+ disabled: j,
2102
+ children: "Live"
2103
+ }
2104
+ )
2105
+ ] })
2106
+ ] }),
2107
+ v && /* @__PURE__ */ h(nt, { children: [
2108
+ /* @__PURE__ */ h("div", { className: "nice-payment-provider-config__meta", children: [
2109
+ /* @__PURE__ */ c("span", { className: "nice-payment-provider-config__badge", children: v.type }),
2110
+ /* @__PURE__ */ c("span", { className: "nice-payment-provider-config__currencies", children: O })
2111
+ ] }),
2112
+ /* @__PURE__ */ c("div", { className: "nice-payment-provider-config__credentials", children: z.map((u) => {
2113
+ const D = `${N}-${u.key}`, U = u.secret, I = $.has(u.key);
2114
+ return /* @__PURE__ */ h("div", { className: "nice-payment-provider-config__field", children: [
2115
+ /* @__PURE__ */ h("label", { className: "nice-payment-provider-config__field-label", htmlFor: D, children: [
2116
+ u.label,
2117
+ u.required && /* @__PURE__ */ c("span", { className: "nice-payment-provider-config__required", children: " *" })
2118
+ ] }),
2119
+ /* @__PURE__ */ h("div", { className: "nice-payment-provider-config__input-wrap", children: [
2120
+ /* @__PURE__ */ c(
2121
+ "input",
2122
+ {
2123
+ id: D,
2124
+ type: U && !I ? "password" : "text",
2125
+ className: "nice-payment-provider-config__input",
2126
+ value: r.credentials[u.key] ?? "",
2127
+ readOnly: j,
2128
+ autoComplete: U ? "new-password" : "off",
2129
+ onChange: (re) => Z(u.key, re.target.value)
2130
+ }
2131
+ ),
2132
+ U && /* @__PURE__ */ c(
2133
+ "button",
2134
+ {
2135
+ type: "button",
2136
+ className: "nice-payment-provider-config__reveal",
2137
+ onClick: () => E(u.key),
2138
+ "aria-label": I ? "Hide" : "Reveal",
2139
+ "aria-pressed": I,
2140
+ children: I ? "🙈" : "👁"
2141
+ }
2142
+ )
2143
+ ] }),
2144
+ u.help && /* @__PURE__ */ c("span", { className: "nice-payment-provider-config__help", children: u.help })
2145
+ ] }, u.key);
2146
+ }) }),
2147
+ v.supportedMethods && v.supportedMethods.length > 0 && /* @__PURE__ */ h("div", { className: "nice-payment-provider-config__methods", children: [
2148
+ /* @__PURE__ */ c("span", { className: "nice-payment-provider-config__field-label", children: "Enabled methods" }),
2149
+ /* @__PURE__ */ c("div", { className: "nice-payment-provider-config__method-list", children: v.supportedMethods.map((u) => /* @__PURE__ */ h("label", { className: "nice-payment-provider-config__method", children: [
2150
+ /* @__PURE__ */ c(
2151
+ "input",
2152
+ {
2153
+ type: "checkbox",
2154
+ checked: (r.enabledMethods ?? []).includes(u),
2155
+ disabled: j,
2156
+ onChange: () => Y(u)
2157
+ }
2158
+ ),
2159
+ u
2160
+ ] }, u)) })
2161
+ ] }),
2162
+ s && v.webhookPath && /* @__PURE__ */ h("div", { className: "nice-payment-provider-config__field", children: [
2163
+ /* @__PURE__ */ c("span", { className: "nice-payment-provider-config__field-label", children: "Webhook URL" }),
2164
+ /* @__PURE__ */ c("code", { className: "nice-payment-provider-config__webhook", children: te })
2165
+ ] }),
2166
+ o && /* @__PURE__ */ h("div", { className: "nice-payment-provider-config__test", children: [
2167
+ /* @__PURE__ */ c(
2168
+ "button",
2169
+ {
2170
+ type: "button",
2171
+ className: "nice-payment-provider-config__test-btn",
2172
+ onClick: () => void J(),
2173
+ disabled: j || k,
2174
+ children: k ? "Testing…" : p
2175
+ }
2176
+ ),
2177
+ T && /* @__PURE__ */ h(
2178
+ "span",
2179
+ {
2180
+ className: "nice-payment-provider-config__test-result nice-payment-provider-config__test-result--" + (T.ok ? "ok" : "error"),
2181
+ children: [
2182
+ T.ok ? "✓" : "✕",
2183
+ " ",
2184
+ T.message ?? (T.ok ? "OK" : "Failed")
2185
+ ]
2186
+ }
2187
+ )
2188
+ ] })
2189
+ ] })
2190
+ ] });
2191
+ }
1703
2192
  );
1704
2193
  export {
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,
2194
+ pt as EcbRatesProvider,
2195
+ ut as ExchangeRateHostProvider,
2196
+ lt as FrankfurterProvider,
2197
+ yt as FreeForexApiProvider,
2198
+ bt as MockPaymentProcessor,
2199
+ he as NICE_CURRENCY_CATALOG,
2200
+ cn as NICE_CURRENCY_CODES,
2201
+ xt as NICE_PAYMENT_PROCESSORS,
2202
+ Et as NICE_PAYMENT_PROVIDER_LIST,
2203
+ Ne as NICE_PAYMENT_PROVIDER_PROFILES,
2204
+ mt as NbpRatesProvider,
2205
+ Kt as NiceCreditCardInput,
2206
+ ln as NiceCurrencyConverter,
2207
+ He as NiceCurrencySelector,
2208
+ Ee as NiceMoney,
2209
+ je as NiceMoneyInput,
2210
+ sn as NicePaymentForm,
2211
+ un as NicePaymentMethodSelector,
2212
+ mn as NicePaymentProviderConfig,
2213
+ on as NicePriceTag,
2214
+ dn as NiceTaxBreakdown,
2215
+ dt as OpenExchangeRatesProvider,
2216
+ Wt as StaticExchangeRateProvider,
1724
2217
  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,
2218
+ Gt as compareMoney,
2219
+ ht as convertMoney,
2220
+ en as createEcbRatesProvider,
2221
+ nn as createFreeForexApiProvider,
2222
+ Vt as createNbpRatesProvider,
2223
+ tn as createOpenExchangeRatesProvider,
2224
+ ve as detectCardBrand,
1732
2225
  ye as expectedCvcLength,
1733
2226
  V as findCurrency,
1734
- ct as formatCardNumber,
1735
- te as formatMoney,
1736
- Ke as fromMoney,
2227
+ rn as findPaymentProviderProfile,
2228
+ ot as formatCardNumber,
2229
+ ce as formatMoney,
2230
+ Oe as fromMoney,
1737
2231
  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,
2232
+ Jt as isNegative,
2233
+ Zt as isZero,
2234
+ Fe as luhnCheck,
2235
+ gt as makeAdyenAdapter,
2236
+ Pt as makeAutopayAdapter,
2237
+ It as makeBlikAdapter,
2238
+ wt as makeBraintreeAdapter,
2239
+ $t as makeCoinbaseCommerceAdapter,
2240
+ St as makeKlarnaAdapter,
2241
+ vt as makeMollieAdapter,
2242
+ _t as makePayPalAdapter,
2243
+ Dt as makePayUAdapter,
2244
+ Ct as makePrzelewy24Adapter,
2245
+ kt as makeRazorpayAdapter,
2246
+ Nt as makeSquareAdapter,
2247
+ ft as makeStripeAdapter,
2248
+ Mt as makeTpayAdapter,
2249
+ Qt as maskCardNumber,
1756
2250
  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
2251
+ Xt as negateMoney,
2252
+ Be as normaliseExpiry,
2253
+ st as parseMoney,
2254
+ Yt as registerCurrency,
2255
+ it as subtractMoney,
2256
+ ee as toMoney,
2257
+ Ce as useNiceExchangeRate,
2258
+ an as useNiceMoney,
2259
+ qt as useNicePayment,
2260
+ Ae as validateCreditCard
1767
2261
  };