stripe-pwa-elements 4.0.4 → 4.1.0

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.
Files changed (66) hide show
  1. package/dist/cjs/{factory-Cm6zUD7R.js → factory-yd5HDEZn.js} +2 -1
  2. package/dist/cjs/{i18n-lBbOeQt4.js → i18n-CWEsGqxV.js} +2 -2
  3. package/dist/cjs/ion-icon_2.cjs.entry.js +1 -1
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/cjs/stripe-address-element.cjs.entry.js +2 -2
  6. package/dist/cjs/stripe-card-element.cjs.entry.js +3 -3
  7. package/dist/cjs/stripe-currency-selector.cjs.entry.js +2 -2
  8. package/dist/cjs/stripe-elements.cjs.js +1 -1
  9. package/dist/cjs/stripe-express-checkout-element.cjs.entry.js +2 -2
  10. package/dist/cjs/stripe-link-authentication-element.cjs.entry.js +2 -2
  11. package/dist/cjs/stripe-payment-element.cjs.entry.js +19 -8
  12. package/dist/cjs/stripe-payment-element.helpers-D1JnhTa-.js +182 -0
  13. package/dist/cjs/stripe-payment-sheet.cjs.entry.js +73 -58
  14. package/dist/collection/components/stripe-card-element/stripe-card-element.js +2 -2
  15. package/dist/collection/components/stripe-payment-element/stripe-payment-element.helpers.js +9 -32
  16. package/dist/collection/components/stripe-payment-element/stripe-payment-element.js +88 -6
  17. package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.checkout.js +60 -48
  18. package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.js +5 -2
  19. package/dist/collection/services/stripe-service.js +1 -0
  20. package/dist/collection/utils/checkout-confirm.js +84 -0
  21. package/dist/collection/utils/i18n.js +2 -2
  22. package/dist/components/factory.js +1 -1
  23. package/dist/components/i18n.js +1 -1
  24. package/dist/components/stripe-card-element2.js +1 -1
  25. package/dist/components/stripe-payment-element.helpers.js +1 -1
  26. package/dist/components/stripe-payment-element.js +1 -1
  27. package/dist/components/stripe-payment-sheet.js +1 -1
  28. package/dist/esm/{factory-BaGv8K_i.js → factory-B_WxdnxM.js} +2 -1
  29. package/dist/esm/{i18n-CL5n3bOb.js → i18n-HWdALSvT.js} +2 -2
  30. package/dist/esm/ion-icon_2.entry.js +1 -1
  31. package/dist/esm/loader.js +1 -1
  32. package/dist/esm/stripe-address-element.entry.js +2 -2
  33. package/dist/esm/stripe-card-element.entry.js +3 -3
  34. package/dist/esm/stripe-currency-selector.entry.js +2 -2
  35. package/dist/esm/stripe-elements.js +1 -1
  36. package/dist/esm/stripe-express-checkout-element.entry.js +2 -2
  37. package/dist/esm/stripe-link-authentication-element.entry.js +2 -2
  38. package/dist/esm/stripe-payment-element.entry.js +19 -8
  39. package/dist/esm/stripe-payment-element.helpers-PuWxhMNR.js +176 -0
  40. package/dist/esm/stripe-payment-sheet.entry.js +73 -58
  41. package/dist/stripe-elements/{p-f5552c81.entry.js → p-2e2bf0fe.entry.js} +1 -1
  42. package/dist/stripe-elements/{p-3fc4583a.entry.js → p-32a2d5a4.entry.js} +1 -1
  43. package/dist/stripe-elements/{p-b62c9dae.entry.js → p-84d45b48.entry.js} +1 -1
  44. package/dist/stripe-elements/{p-CL5n3bOb.js → p-HWdALSvT.js} +1 -1
  45. package/dist/stripe-elements/{p-5d3d93ec.entry.js → p-a266da6f.entry.js} +1 -1
  46. package/dist/stripe-elements/{p-7e826964.entry.js → p-b4faa9db.entry.js} +1 -1
  47. package/dist/stripe-elements/p-c4a0e310.entry.js +1 -0
  48. package/dist/stripe-elements/{p-2e41699e.entry.js → p-e660d76a.entry.js} +1 -1
  49. package/dist/stripe-elements/p-eeebfbbf.entry.js +1 -0
  50. package/dist/stripe-elements/p-n0XJSLU3.js +1 -0
  51. package/dist/stripe-elements/p-wrjrFokg.js +1 -0
  52. package/dist/stripe-elements/stripe-elements.esm.js +1 -1
  53. package/dist/types/components/stripe-card-element/stripe-card-element.d.ts +5 -0
  54. package/dist/types/components/stripe-payment-element/stripe-payment-element.d.ts +38 -0
  55. package/dist/types/components/stripe-payment-element/stripe-payment-element.helpers.d.ts +8 -2
  56. package/dist/types/components/stripe-payment-sheet/stripe-payment-sheet.checkout.d.ts +19 -11
  57. package/dist/types/components.d.ts +36 -4
  58. package/dist/types/services/interfaces.d.ts +3 -1
  59. package/dist/types/utils/checkout-confirm.d.ts +35 -0
  60. package/package.json +1 -1
  61. package/dist/cjs/stripe-payment-element.helpers-lafmSRmb.js +0 -121
  62. package/dist/esm/stripe-payment-element.helpers-CklK5RlF.js +0 -116
  63. package/dist/stripe-elements/p-7a8f783c.entry.js +0 -1
  64. package/dist/stripe-elements/p-BoZLkOAy.js +0 -1
  65. package/dist/stripe-elements/p-DlMEZwSe.js +0 -1
  66. package/dist/stripe-elements/p-b69f6103.entry.js +0 -1
@@ -6,7 +6,7 @@ import { serviceFactory } from "../../services/factory";
6
6
  import { confirmPaymentOrSetup } from "../stripe-payment-element/stripe-payment-element.helpers";
7
7
  import { initialSheetState, transition } from "./payment-sheet-state";
8
8
  import { collectedBillingDetails, isRecoverableConfirmError, isSheetValidationError, planBillingDetailsCollection, toAppearance, toPaymentElementOptions, unsupportedOptionKeys, } from "./stripe-payment-sheet.helpers";
9
- import { checkoutIgnoredOptionKeys, confirmCheckoutSessionSheet, toCheckoutElementsOptions, toCheckoutPaymentElementOptions } from "./stripe-payment-sheet.checkout";
9
+ import { checkoutIgnoredOptionKeys, confirmCheckoutSessionSheet, toCheckoutDefaultValues, toCheckoutElementsOptions, toCheckoutPaymentElementOptions, } from "./stripe-payment-sheet.checkout";
10
10
  const nonEmpty = (value) => (value == null || value === '' ? undefined : value);
11
11
  /**
12
12
  * A payment sheet: the Payment Element in a modal, with the same events and results as the native PaymentSheet
@@ -326,6 +326,7 @@ export class StripePaymentSheet {
326
326
  stripeAccount: this.stripeAccount,
327
327
  applicationName: this.applicationName,
328
328
  elementsOptions: toCheckoutElementsOptions(this.options),
329
+ defaultValues: toCheckoutDefaultValues(this.options),
329
330
  });
330
331
  if (generation !== this.sheet.generation) {
331
332
  return;
@@ -347,6 +348,8 @@ export class StripePaymentSheet {
347
348
  }
348
349
  confirmCheckoutSession(generation) {
349
350
  var _a, _b;
351
+ // returnUrl defaults to the current page; confirmCheckoutSessionSheet retries without it when the
352
+ // session was created with `return_url` (which rejects the argument before processing)
350
353
  const returnUrl = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.returnURL) !== null && _b !== void 0 ? _b : window.location.href;
351
354
  return this.runConfirm(generation, async () => {
352
355
  var _a, _b;
@@ -396,7 +399,7 @@ export class StripePaymentSheet {
396
399
  var _a, _b, _c;
397
400
  const { phase } = this.sheet;
398
401
  const confirming = phase === 'confirming';
399
- return (h(Host, { key: 'e6b2c3cb168039eb428eaaee1dce598f534c18e7' }, h("stripe-modal", { key: 'ef1515b07cca402c4db8818e2e94ca80e4d954c2', open: this.visible, showCloseButton: !confirming, onClose: this.handleModalClose }, h("div", { key: '9252fa1653b206d211756c94325c73a8ec482a37', class: "stripe-payment-sheet-wrap" }, h("form", { key: '904a54f2439e0356c2cbf9227326efe446aa08ce', id: "stripe-payment-sheet", onSubmit: this.handleSubmit }, h("div", { key: '103d81e3c56cfba1c421e1bf140a49e2b392c6b5', class: "stripe-heading" }, i18n.t(this.sheetTitle)), h("div", { key: 'cda58a48db7b04af1981407b7100def815404e35', class: "payment-info visible" }, h("div", { key: 'cbe248666aa4807c25d492df1ab1de017bc78e2c', class: "stripe-payment-sheet-email" }, ((_a = this.collection) === null || _a === void 0 ? void 0 : _a.emailElement) != null && h("div", { key: 'b0210c6cce85d1affaa83e3fa30785158c9bab98', id: "link-authentication-element" })), h("div", { key: '2420956298e5b36c63f3fbea6b4e32429b7ace27', class: "stripe-payment-sheet-shipping-address" }, ((_b = this.collection) === null || _b === void 0 ? void 0 : _b.shippingAddressElement) != null && h("div", { key: 'ae41335a42c59598e1addbfdea0a13342c026456', id: "address-element" })), h("div", { key: '3196844c9396c40548a3c632733565027df3cea7', class: "stripe-payment-sheet-billing-address" }, ((_c = this.collection) === null || _c === void 0 ? void 0 : _c.billingAddressElement) != null && h("div", { key: '269a99368975db70722fc181a1c099859f23d3d6', id: "address-element" })), h("div", { key: '2a63173a607501ff08ac072956cdbe462a4400c1', id: "payment-element" })), h("div", { key: '7a72a86097aca2af6491c56b52258286ef820283', class: "stripe-element-errors", role: "alert" }, this.errorMessage), h("div", { key: '10f05d5ecfa53cde350f00acffd86e232e370fe7', class: "stripe-submit" }, h("button", { key: 'a7ad3e538b94403bd8c71b31bd405c1b0c59543c', type: "submit", disabled: phase !== 'presented' }, confirming ? i18n.t('Loading') : i18n.t(this.buttonLabel))))))));
402
+ return (h(Host, { key: '52591afbd5af5ceb2530a37248e3bb1f410f880c' }, h("stripe-modal", { key: '607c26d28f381b5017f9714fca398c2f5eb9c066', open: this.visible, showCloseButton: !confirming, onClose: this.handleModalClose }, h("div", { key: '44cfb1929b178257878d5a42d8441b2f7f823436', class: "stripe-payment-sheet-wrap" }, h("form", { key: '20be8d4cb150883936241639c299a86d081c1903', id: "stripe-payment-sheet", onSubmit: this.handleSubmit }, h("div", { key: '14e5c98793de6d2ebb1a1cc755e501b427915d9f', class: "stripe-heading" }, i18n.t(this.sheetTitle)), h("div", { key: '235ac34c0c2260793756960caa75ef9f62e401fd', class: "payment-info visible" }, h("div", { key: '10ed4c9be02a08429b8bfd028f40be409613250b', class: "stripe-payment-sheet-email" }, ((_a = this.collection) === null || _a === void 0 ? void 0 : _a.emailElement) != null && h("div", { key: '5a21882fc11b839287bd499f9441b7a37b2f7e4d', id: "link-authentication-element" })), h("div", { key: 'd88e637fcecc62bba18fc25cdf674a03624ceb8a', class: "stripe-payment-sheet-shipping-address" }, ((_b = this.collection) === null || _b === void 0 ? void 0 : _b.shippingAddressElement) != null && h("div", { key: '934f6b59ce787c6452191f1df14b1848f847db4a', id: "address-element" })), h("div", { key: '1fe9f0371e0669c6b5485b19672ee02169312674', class: "stripe-payment-sheet-billing-address" }, ((_c = this.collection) === null || _c === void 0 ? void 0 : _c.billingAddressElement) != null && h("div", { key: 'fb548084588b34ffcd8534cc2b0a402e1af60d76', id: "address-element" })), h("div", { key: '8dec277132c63cc11c49962f136b67685e810ccb', id: "payment-element" })), h("div", { key: 'e0f20ba527fb9b941cc8d70d7631a03dcfc2c370', class: "stripe-element-errors", role: "alert" }, this.errorMessage), h("div", { key: 'db7357b49c141ff9272f1b4690f933ea54d9bfb3', class: "stripe-submit" }, h("button", { key: '9112ed21047df0b2fdfa5f8d6b7872f878062dc1', type: "submit", disabled: phase !== 'presented' }, confirming ? i18n.t('Loading') : i18n.t(this.buttonLabel))))))));
400
403
  }
401
404
  static get is() { return "stripe-payment-sheet"; }
402
405
  static get originalStyleUrls() {
@@ -136,6 +136,7 @@ class StripeServiceClass {
136
136
  const checkout = stripe.initCheckoutElementsSdk({
137
137
  clientSecret: checkoutSessionClientSecret,
138
138
  elementsOptions: options === null || options === void 0 ? void 0 : options.elementsOptions,
139
+ defaultValues: options === null || options === void 0 ? void 0 : options.defaultValues,
139
140
  });
140
141
  this.store.state.checkout = checkout;
141
142
  this.store.state.elements = undefined;
@@ -0,0 +1,84 @@
1
+ import { StripeAPIError } from "./error";
2
+ /**
3
+ * Whether a confirm failure means the session was created with `return_url`, which rejects `returnUrl`.
4
+ * Stripe raises this before any payment processing, so retrying without `returnUrl` is safe.
5
+ * `actions.confirm()` reports it both as a thrown `IntegrationError` and as an error result depending on the SDK version.
6
+ * @param error - Error thrown by `actions.confirm()` or the error of its result
7
+ */
8
+ export const isCheckoutReturnUrlConflict = (error) => {
9
+ const message = error instanceof Error ? error.message : error === null || error === void 0 ? void 0 : error.message;
10
+ return typeof message === 'string' && message.includes('cannot provide `returnUrl`');
11
+ };
12
+ /**
13
+ * Throw when the session can no longer be paid. Stripe documents an `expired` session as "No further processing will occur",
14
+ * and a `complete` one is already paid or being paid, so confirming again cannot succeed.
15
+ * @param status - `session.status` from `getSession()`; undefined when it cannot be read
16
+ * @param message - Message of the confirm error, if any
17
+ * @throws StripeAPIError of type `invalid_request_error` (unrecoverable), with the code `checkout_session_expired` or `checkout_session_complete`
18
+ */
19
+ export const assertCheckoutSessionOpen = (status, message) => {
20
+ if (status == null || status.type === 'open') {
21
+ return;
22
+ }
23
+ throw new StripeAPIError({
24
+ type: 'invalid_request_error',
25
+ code: `checkout_session_${status.type}`,
26
+ message: message !== null && message !== void 0 ? message : `The Checkout Session is ${status.type} and can no longer be paid.`,
27
+ });
28
+ };
29
+ /**
30
+ * Confirm a Checkout Session through the checkout actions.
31
+ *
32
+ * Stripe requires exactly one of `returnUrl` (confirm argument) or the session's `return_url`, and the client
33
+ * cannot tell which one a session has (`getSession()` does not expose it). So the first attempt passes
34
+ * `returnUrl`, and when Stripe rejects it because the session already has `return_url`, the confirmation is
35
+ * retried without `returnUrl` (Stripe then redirects to the session's `return_url` automatically).
36
+ *
37
+ * Errors are thrown as `StripeAPIError`:
38
+ * - session `expired` or `complete` (before confirming or after a failed confirm): `invalid_request_error`
39
+ * - `paymentFailed` on an open session (a decline): `card_error`
40
+ * - any other confirm error on an open session, or a failure to load the actions: `api_error`
41
+ * @param checkout - The Checkout instance from `initCheckoutElementsSdk`
42
+ * @param returnUrl - Where Stripe redirects after a redirect-based payment method, when the session has no `return_url`
43
+ * @param email - Customer email; needed when the session was created without `customer_email` or `customer`
44
+ * @returns The confirmation result
45
+ * @throws StripeAPIError when the actions cannot be loaded, the session can no longer be paid, or the confirmation fails
46
+ */
47
+ export const confirmCheckoutActions = async (checkout, returnUrl, email) => {
48
+ const loadActionsResult = await checkout.loadActions();
49
+ if (loadActionsResult.type === 'error') {
50
+ throw new StripeAPIError({
51
+ type: 'api_error',
52
+ code: 'checkout_session_error',
53
+ message: loadActionsResult.error.message,
54
+ });
55
+ }
56
+ const { actions } = loadActionsResult;
57
+ const sessionStatus = () => { var _a, _b; return (_b = (_a = actions.getSession) === null || _a === void 0 ? void 0 : _a.call(actions)) === null || _b === void 0 ? void 0 : _b.status; };
58
+ assertCheckoutSessionOpen(sessionStatus());
59
+ const confirmWith = (withReturnUrl) => actions.confirm(Object.assign(Object.assign({ redirect: 'if_required' }, (withReturnUrl && returnUrl !== '' ? { returnUrl } : {})), (email != null && email !== '' ? { email } : {})));
60
+ // First attempt with returnUrl; a session created with `return_url` rejects it before processing.
61
+ // The rejection can arrive either as a thrown error or as an error result, so both are retried without it.
62
+ let result;
63
+ try {
64
+ result = await confirmWith(true);
65
+ if (result.type === 'error' && isCheckoutReturnUrlConflict(result.error)) {
66
+ result = await confirmWith(false);
67
+ }
68
+ }
69
+ catch (e) {
70
+ if (!isCheckoutReturnUrlConflict(e)) {
71
+ throw e;
72
+ }
73
+ result = await confirmWith(false);
74
+ }
75
+ if (result.type === 'error') {
76
+ const { code, message } = result.error;
77
+ assertCheckoutSessionOpen(sessionStatus(), message);
78
+ if (code === 'paymentFailed') {
79
+ throw new StripeAPIError({ type: 'card_error', code, message });
80
+ }
81
+ throw new StripeAPIError({ type: 'api_error', code: 'checkout_session_error', message });
82
+ }
83
+ return result;
84
+ };
@@ -3,6 +3,8 @@ import I18nextBrowserLanguageDetector from "i18next-browser-languagedetector";
3
3
  i18next.use(I18nextBrowserLanguageDetector).init({
4
4
  fallbackLng: 'en',
5
5
  debug: false,
6
+ // i18next prints a one-time Locize promo to the console unless this is false
7
+ showSupportNotice: false,
6
8
  resources: {
7
9
  'en': {
8
10
  translation: {},
@@ -19,7 +21,6 @@ i18next.use(I18nextBrowserLanguageDetector).init({
19
21
  'Card Number': 'カード番号',
20
22
  'MM / YY': '月 / 年',
21
23
  'CVC': 'セキュリティコード(CVC)',
22
- 'Country or region': '地域',
23
24
  'Postal Code': '郵便番号',
24
25
  'Close': '閉じる',
25
26
  'Loading': '読み込み中',
@@ -43,7 +44,6 @@ i18next.use(I18nextBrowserLanguageDetector).init({
43
44
  'Card Number': 'Número do Cartão',
44
45
  'MM / YY': 'MM / AA',
45
46
  'CVC': 'Número de Segurança(CVC)',
46
- 'Country or region': 'País ou região',
47
47
  'Postal Code': 'Cep',
48
48
  'Close': 'Fechar',
49
49
  'Please complete your billing address.': 'Preencha seu endereço de cobrança.',
@@ -1 +1 @@
1
- import*as t from"@stencil/core/internal/client";import{l as e}from"./index2.js";import{i}from"./i18n.js";const r=(()=>{let t;return(...e)=>{t&&clearTimeout(t),t=setTimeout((()=>{t=0,(t=>{for(let e of t.keys()){const i=t.get(e).filter((t=>{const e=t.deref();return e&&(!("isConnected"in(i=e))||i.isConnected);var i}));t.set(e,i)}})(...e)}),2e3)}})(),s=t.forceUpdate,n=t.getRenderingRef,o=(t,e)=>{const i=t.indexOf(e);i>=0&&(t[i]=t[t.length-1],t.length--)},l=(t,e)=>{const i=((t,e=(t,e)=>t!==e)=>{const i=()=>{return("function"==typeof(e=t)?e():e)??{};var e},r=i();let s=new Map(Object.entries(r));const n="undefined"!=typeof Proxy,l=n?null:{},c={dispose:[],get:[],set:[],reset:[]},a=new Map,h=()=>{s=new Map(Object.entries(i())),n||m(),c.reset.forEach((t=>t()))},u=t=>(c.get.forEach((e=>e(t))),s.get(t)),d=(t,i)=>{const r=s.get(t);e(i,r,t)&&(s.set(t,i),n||g(t),c.set.forEach((e=>e(t,i,r))))},v=n?new Proxy(r,{get:(t,e)=>u(e),ownKeys:()=>Array.from(s.keys()),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),has:(t,e)=>s.has(e),set:(t,e,i)=>(d(e,i),!0)}):(m(),l),p=(t,e)=>(c[t].push(e),()=>{o(c[t],e)});function g(t){!n&&l&&(Object.prototype.hasOwnProperty.call(l,t)||Object.defineProperty(l,t,{configurable:!0,enumerable:!0,get:()=>u(t),set(e){d(t,e)}}))}function m(){if(n||!l)return;const t=new Set(s.keys());for(const e of Object.keys(l))t.has(e)||delete l[e];for(const e of t)g(e)}return{state:v,get:u,set:d,on:p,onChange:(t,e)=>{const r=(i,r)=>{i===t&&e(r)},s=()=>{const r=i();e(r[t])},n=p("set",r),o=p("reset",s);return a.set(e,{setHandler:r,resetHandler:s,propName:t}),()=>{n(),o(),a.delete(e)}},use:(...t)=>{const e=t.reduce(((t,e)=>(e.set&&t.push(p("set",e.set)),e.get&&t.push(p("get",e.get)),e.reset&&t.push(p("reset",e.reset)),e.dispose&&t.push(p("dispose",e.dispose)),t)),[]);return()=>e.forEach((t=>t()))},dispose:()=>{c.dispose.forEach((t=>t())),h()},reset:h,forceUpdate:t=>{const e=s.get(t);c.set.forEach((i=>i(t,e,e)))},removeListener:(t,e)=>{const i=a.get(e);i&&i.propName===t&&(o(c.set,i.setHandler),o(c.reset,i.resetHandler),a.delete(e))}}})(t,e);return i.use((()=>{if("function"!=typeof n||"function"!=typeof s)return{};const t=s,e=n,i=new Map;return{dispose:()=>i.clear(),get:t=>{const r=e();r&&((t,e,i)=>{let r=t.get(e);r||(r=[],t.set(e,r)),r.some((t=>t.deref()===i))||r.push(new WeakRef(i))})(i,t,r)},set:e=>{const s=i.get(e);if(s){const r=s.filter((e=>{const i=e.deref();return!!i&&t(i)}));i.set(e,r)}r(i)},reset:()=>{i.forEach((e=>{e.forEach((e=>{const i=e.deref();i&&t(i)}))})),r(i)}}})()),i};class c{constructor(){this.store=l({loadStripeStatus:"",applicationName:"stripe-pwa-elements",isCheckoutSession:!1}),this.initGeneration=0,this.changeListeners=new Map}get state(){return this.store.state}onChange(t,e){const i=this.store.onChange(t,e);return this.changeListeners.has(t)||this.changeListeners.set(t,[]),this.changeListeners.get(t).push(i),i}async initialize(t,i){const r=null!=(null==i?void 0:i.elementsOptions)?JSON.stringify(i.elementsOptions):void 0,s=null!=this.store.state.stripe&&!this.store.state.isCheckoutSession&&this.store.state.publishableKey===t&&this.store.state.stripeAccount===(null==i?void 0:i.stripeAccount)&&this.intentClientSecret===(null==i?void 0:i.clientSecret)&&this.elementsOptionsKey===r;if(this.store.state.publishableKey=t,this.store.state.isCheckoutSession=!1,this.intentClientSecret=null==i?void 0:i.clientSecret,this.elementsOptionsKey=r,null!=(null==i?void 0:i.stripeAccount)&&""!==(null==i?void 0:i.stripeAccount)&&(this.store.state.stripeAccount=i.stripeAccount),null!=(null==i?void 0:i.applicationName)&&""!==(null==i?void 0:i.applicationName)&&(this.store.state.applicationName=i.applicationName),s)return;const n=++this.initGeneration;this.store.state.loadStripeStatus="loading";try{const r=await e(t,{stripeAccount:null==i?void 0:i.stripeAccount});if(n!==this.initGeneration)return;r.registerAppInfo({name:this.store.state.applicationName}),this.store.state.stripe=r,this.store.state.elements=null!=(null==i?void 0:i.clientSecret)&&""!==i.clientSecret?r.elements({clientSecret:i.clientSecret}):null!=(null==i?void 0:i.elementsOptions)?r.elements(i.elementsOptions):r.elements(),this.store.state.checkout=void 0,this.store.state.loadStripeStatus="success"}catch(t){console.error("Failed to load Stripe.js:",t),this.store.state.loadStripeStatus="failure"}}async initializeWithCheckoutSession(t,i,r){const s=++this.initGeneration;this.store.state.publishableKey=t,this.store.state.isCheckoutSession=!0,null!=(null==r?void 0:r.stripeAccount)&&""!==(null==r?void 0:r.stripeAccount)&&(this.store.state.stripeAccount=r.stripeAccount),null!=(null==r?void 0:r.applicationName)&&""!==(null==r?void 0:r.applicationName)&&(this.store.state.applicationName=r.applicationName),this.store.state.loadStripeStatus="loading";try{const n=await e(t,{stripeAccount:null==r?void 0:r.stripeAccount});if(s!==this.initGeneration)return;n.registerAppInfo({name:this.store.state.applicationName}),this.store.state.stripe=n;const o=n.initCheckoutElementsSdk({clientSecret:i,elementsOptions:null==r?void 0:r.elementsOptions});this.store.state.checkout=o,this.store.state.elements=void 0,this.store.state.loadStripeStatus="success"}catch(t){console.error("Failed to initialize Stripe Checkout:",t),this.store.state.loadStripeStatus="failure"}}getStripe(){return this.store.state.stripe}getElements(){return this.store.state.elements}getCheckout(){return this.store.state.checkout}reset(){this.store.reset()}dispose(){this.changeListeners.forEach((t=>{t.forEach((t=>t()))})),this.changeListeners.clear(),this.store.dispose()}}function a(t,e,i=5e3){return new Promise(((r,s)=>{const n=t.querySelector(e);if(null!=n)return r(n);const o=setTimeout((()=>{l.disconnect(),s(new Error(`Element "${e}" not found within ${i}ms`))}),i),l=new MutationObserver((()=>{const i=t.querySelector(e);null!=i&&(clearTimeout(o),l.disconnect(),r(i))}));l.observe(t,{childList:!0,subtree:!0})}))}new c;class h{constructor(t){this.stripeService=t,this.store=l({errorMessage:"",errorSource:void 0})}getState(){return this.store.state}async initialize(t){const e=this.stripeService.getElements();if(null==e)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");null!=this.cardElements&&this.unmount();const r=e.create("cardNumber",{placeholder:i.t("Card Number")}),s=await a(t,"#card-number");r.mount(s),r.on("change",this.handleCardError("cardNumber"));const n=e.create("cardExpiry"),o=await a(t,"#card-expiry");n.mount(o),n.on("change",this.handleCardError("cardExpiry"));const l=e.create("cardCvc"),c=await a(t,"#card-cvc");return l.mount(c),l.on("change",this.handleCardError("cardCvc")),this.cardElements={cardNumber:r,cardExpiry:n,cardCVC:l},this.cardElements}getElements(){return this.cardElements}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage",""),this.store.set("errorSource",void 0)}unmount(){var t,e,i;null!=this.cardElements&&(null===(t=this.cardElements.cardNumber)||void 0===t||t.unmount(),null===(e=this.cardElements.cardExpiry)||void 0===e||e.unmount(),null===(i=this.cardElements.cardCVC)||void 0===i||i.unmount(),this.cardElements=void 0)}handleCardError(t){return({error:e})=>{if(e)return this.store.set("errorMessage",e.message),void this.store.set("errorSource",t);this.store.state.errorSource===t&&(this.store.set("errorMessage",""),this.store.set("errorSource",void 0))}}}class u{constructor(t){this.stripeService=t,this.store=l({errorMessage:""})}getState(){return this.store.state}async initialize(t,e){const i=this.stripeService.state.isCheckoutSession;if(null!=this.paymentElement&&this.unmount(),i){const t=this.stripeService.getCheckout();if(null==t)throw new Error("StripeService not initialized with Checkout Session. Call StripeService.initializeWithCheckoutSession() first.");this.paymentElement=t.createPaymentElement(e)}else{const t=this.stripeService.getElements();if(null==t)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");this.paymentElement=t.create("payment",e||{})}const r=await a(t,"#payment-element");return this.paymentElement.mount(r),this.paymentElement}getElement(){return this.paymentElement}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage","")}unmount(){null!=this.paymentElement&&(this.paymentElement.unmount(),this.paymentElement=void 0)}}class d{constructor(t){this.stripeService=t,this.store=l({errorMessage:"",isComplete:!1})}getState(){return this.store.state}async initialize(t,e){const i=this.stripeService.getElements();if(null==i)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");null!=this.addressElement&&this.unmount(),this.addressElement=i.create("address",e||{mode:"billing"});const r=await a(t,"#address-element");return this.addressElement.mount(r),this.addressElement.on("change",(t=>{this.store.set("errorMessage",""),this.store.set("isComplete",t.complete)})),this.addressElement}getElement(){return this.addressElement}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage","")}unmount(){null!=this.addressElement&&(this.addressElement.unmount(),this.addressElement=void 0)}}class v{constructor(t){this.stripeService=t,this.store=l({errorMessage:"",email:void 0,complete:void 0})}getState(){return this.store.state}onChange(t,e){return this.store.onChange(t,e)}async initialize(t,e){const i=this.stripeService.getElements();if(null==i)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");null!=this.linkAuthenticationElement&&this.unmount(),this.store.set("email",void 0),this.store.set("complete",void 0);const r=i.create("linkAuthentication",e),s=await a(t,"#link-authentication-element");return r.mount(s),r.on("change",(t=>{var e;this.store.set("email",null===(e=t.value)||void 0===e?void 0:e.email),this.store.set("complete",t.complete)})),this.linkAuthenticationElement=r,this.linkAuthenticationElement}getElement(){return this.linkAuthenticationElement}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage","")}unmount(){null!=this.linkAuthenticationElement&&(this.linkAuthenticationElement.unmount(),this.linkAuthenticationElement=void 0)}}class p{constructor(t){this.stripeService=t,this.store=l({errorMessage:"",selectedCurrency:void 0})}getState(){return this.store.state}async initialize(t,e){const i=this.stripeService.getElements();if(null==i)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");null!=this.currencySelectorElement&&this.unmount();const r=await a(t,"#currency-selector");return this.currencySelectorElement=i.create("currencySelector",e||{}),this.currencySelectorElement.mount(r),this.currencySelectorElement.on("change",(t=>{var e;this.store.set("errorMessage",""),(null===(e=null==t?void 0:t.value)||void 0===e?void 0:e.currency)&&this.store.set("selectedCurrency",t.value.currency)})),this.currencySelectorElement}getElement(){return this.currencySelectorElement}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage","")}unmount(){null!=this.currencySelectorElement&&(this.currencySelectorElement.unmount(),this.currencySelectorElement=void 0)}}var g=function(t,e){var i={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(i[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(i[r[s]]=t[r[s]])}return i};class m{constructor(t){this.stripeService=t,this.store=l({errorMessage:"",isReady:!1})}getState(){return this.store.state}async initialize(t,e,i){const r=this.stripeService.getElements();if(null==r)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");null!=this.expressCheckoutElement&&this.unmount();const s=g(e,["mode","amount","currency"]),n=Object.assign({},s);if(n.buttonHeight&&"string"==typeof n.buttonHeight){const t=parseInt(n.buttonHeight.replace("px",""),10);isNaN(t)||(n.buttonHeight=t)}const o=r.create("expressCheckout",n),l=await a(t,"#express-checkout-element");return null!=(null==i?void 0:i.onConfirm)&&o.on("confirm",i.onConfirm),null!=(null==i?void 0:i.onClick)&&o.on("click",i.onClick),null!=(null==i?void 0:i.onCancel)&&o.on("cancel",i.onCancel),null!=(null==i?void 0:i.onShippingAddressChange)&&o.on("shippingaddresschange",i.onShippingAddressChange),null!=(null==i?void 0:i.onShippingRateChange)&&o.on("shippingratechange",i.onShippingRateChange),o.on("ready",(()=>{this.store.set("isReady",!0)})),o.mount(l),this.expressCheckoutElement=o,this.expressCheckoutElement}getElement(){return this.expressCheckoutElement}update(t){var e;if(null==this.expressCheckoutElement)return void console.warn("Express Checkout Element not initialized. Cannot update options.");const{mode:i,amount:r,currency:s}=t,n=g(t,["mode","amount","currency"]),o={};void 0!==i&&(o.mode=i),void 0!==r&&(o.amount=r),void 0!==s&&(o.currency=s),Object.keys(o).length>0&&(null===(e=this.stripeService.getElements())||void 0===e||e.update(o));const l=Object.assign({},n);if(l.buttonHeight&&"string"==typeof l.buttonHeight){const t=parseInt(l.buttonHeight.replace("px",""),10);isNaN(t)||(l.buttonHeight=t)}0!==Object.keys(l).length&&this.expressCheckoutElement.update(l)}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage","")}unmount(){null!=this.expressCheckoutElement&&(this.expressCheckoutElement.unmount(),this.expressCheckoutElement=void 0,this.store.set("isReady",!1))}}const f=new class{createStripeService(){return new c}createCardElementManager(t){return new h(t)}createPaymentElementManager(t){return new u(t)}createAddressElementManager(t){return new d(t)}createLinkAuthenticationElementManager(t){return new v(t)}createCurrencySelectorElementManager(t){return new p(t)}createExpressCheckoutElementManager(t){return new m(t)}};export{a as f,f as s}
1
+ import*as t from"@stencil/core/internal/client";import{l as e}from"./index2.js";import{i}from"./i18n.js";const r=(()=>{let t;return(...e)=>{t&&clearTimeout(t),t=setTimeout((()=>{t=0,(t=>{for(let e of t.keys()){const i=t.get(e).filter((t=>{const e=t.deref();return e&&(!("isConnected"in(i=e))||i.isConnected);var i}));t.set(e,i)}})(...e)}),2e3)}})(),s=t.forceUpdate,n=t.getRenderingRef,o=(t,e)=>{const i=t.indexOf(e);i>=0&&(t[i]=t[t.length-1],t.length--)},l=(t,e)=>{const i=((t,e=(t,e)=>t!==e)=>{const i=()=>{return("function"==typeof(e=t)?e():e)??{};var e},r=i();let s=new Map(Object.entries(r));const n="undefined"!=typeof Proxy,l=n?null:{},a={dispose:[],get:[],set:[],reset:[]},c=new Map,h=()=>{s=new Map(Object.entries(i())),n||m(),a.reset.forEach((t=>t()))},u=t=>(a.get.forEach((e=>e(t))),s.get(t)),d=(t,i)=>{const r=s.get(t);e(i,r,t)&&(s.set(t,i),n||g(t),a.set.forEach((e=>e(t,i,r))))},v=n?new Proxy(r,{get:(t,e)=>u(e),ownKeys:()=>Array.from(s.keys()),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),has:(t,e)=>s.has(e),set:(t,e,i)=>(d(e,i),!0)}):(m(),l),p=(t,e)=>(a[t].push(e),()=>{o(a[t],e)});function g(t){!n&&l&&(Object.prototype.hasOwnProperty.call(l,t)||Object.defineProperty(l,t,{configurable:!0,enumerable:!0,get:()=>u(t),set(e){d(t,e)}}))}function m(){if(n||!l)return;const t=new Set(s.keys());for(const e of Object.keys(l))t.has(e)||delete l[e];for(const e of t)g(e)}return{state:v,get:u,set:d,on:p,onChange:(t,e)=>{const r=(i,r)=>{i===t&&e(r)},s=()=>{const r=i();e(r[t])},n=p("set",r),o=p("reset",s);return c.set(e,{setHandler:r,resetHandler:s,propName:t}),()=>{n(),o(),c.delete(e)}},use:(...t)=>{const e=t.reduce(((t,e)=>(e.set&&t.push(p("set",e.set)),e.get&&t.push(p("get",e.get)),e.reset&&t.push(p("reset",e.reset)),e.dispose&&t.push(p("dispose",e.dispose)),t)),[]);return()=>e.forEach((t=>t()))},dispose:()=>{a.dispose.forEach((t=>t())),h()},reset:h,forceUpdate:t=>{const e=s.get(t);a.set.forEach((i=>i(t,e,e)))},removeListener:(t,e)=>{const i=c.get(e);i&&i.propName===t&&(o(a.set,i.setHandler),o(a.reset,i.resetHandler),c.delete(e))}}})(t,e);return i.use((()=>{if("function"!=typeof n||"function"!=typeof s)return{};const t=s,e=n,i=new Map;return{dispose:()=>i.clear(),get:t=>{const r=e();r&&((t,e,i)=>{let r=t.get(e);r||(r=[],t.set(e,r)),r.some((t=>t.deref()===i))||r.push(new WeakRef(i))})(i,t,r)},set:e=>{const s=i.get(e);if(s){const r=s.filter((e=>{const i=e.deref();return!!i&&t(i)}));i.set(e,r)}r(i)},reset:()=>{i.forEach((e=>{e.forEach((e=>{const i=e.deref();i&&t(i)}))})),r(i)}}})()),i};class a{constructor(){this.store=l({loadStripeStatus:"",applicationName:"stripe-pwa-elements",isCheckoutSession:!1}),this.initGeneration=0,this.changeListeners=new Map}get state(){return this.store.state}onChange(t,e){const i=this.store.onChange(t,e);return this.changeListeners.has(t)||this.changeListeners.set(t,[]),this.changeListeners.get(t).push(i),i}async initialize(t,i){const r=null!=(null==i?void 0:i.elementsOptions)?JSON.stringify(i.elementsOptions):void 0,s=null!=this.store.state.stripe&&!this.store.state.isCheckoutSession&&this.store.state.publishableKey===t&&this.store.state.stripeAccount===(null==i?void 0:i.stripeAccount)&&this.intentClientSecret===(null==i?void 0:i.clientSecret)&&this.elementsOptionsKey===r;if(this.store.state.publishableKey=t,this.store.state.isCheckoutSession=!1,this.intentClientSecret=null==i?void 0:i.clientSecret,this.elementsOptionsKey=r,null!=(null==i?void 0:i.stripeAccount)&&""!==(null==i?void 0:i.stripeAccount)&&(this.store.state.stripeAccount=i.stripeAccount),null!=(null==i?void 0:i.applicationName)&&""!==(null==i?void 0:i.applicationName)&&(this.store.state.applicationName=i.applicationName),s)return;const n=++this.initGeneration;this.store.state.loadStripeStatus="loading";try{const r=await e(t,{stripeAccount:null==i?void 0:i.stripeAccount});if(n!==this.initGeneration)return;r.registerAppInfo({name:this.store.state.applicationName}),this.store.state.stripe=r,this.store.state.elements=null!=(null==i?void 0:i.clientSecret)&&""!==i.clientSecret?r.elements({clientSecret:i.clientSecret}):null!=(null==i?void 0:i.elementsOptions)?r.elements(i.elementsOptions):r.elements(),this.store.state.checkout=void 0,this.store.state.loadStripeStatus="success"}catch(t){console.error("Failed to load Stripe.js:",t),this.store.state.loadStripeStatus="failure"}}async initializeWithCheckoutSession(t,i,r){const s=++this.initGeneration;this.store.state.publishableKey=t,this.store.state.isCheckoutSession=!0,null!=(null==r?void 0:r.stripeAccount)&&""!==(null==r?void 0:r.stripeAccount)&&(this.store.state.stripeAccount=r.stripeAccount),null!=(null==r?void 0:r.applicationName)&&""!==(null==r?void 0:r.applicationName)&&(this.store.state.applicationName=r.applicationName),this.store.state.loadStripeStatus="loading";try{const n=await e(t,{stripeAccount:null==r?void 0:r.stripeAccount});if(s!==this.initGeneration)return;n.registerAppInfo({name:this.store.state.applicationName}),this.store.state.stripe=n;const o=n.initCheckoutElementsSdk({clientSecret:i,elementsOptions:null==r?void 0:r.elementsOptions,defaultValues:null==r?void 0:r.defaultValues});this.store.state.checkout=o,this.store.state.elements=void 0,this.store.state.loadStripeStatus="success"}catch(t){console.error("Failed to initialize Stripe Checkout:",t),this.store.state.loadStripeStatus="failure"}}getStripe(){return this.store.state.stripe}getElements(){return this.store.state.elements}getCheckout(){return this.store.state.checkout}reset(){this.store.reset()}dispose(){this.changeListeners.forEach((t=>{t.forEach((t=>t()))})),this.changeListeners.clear(),this.store.dispose()}}function c(t,e,i=5e3){return new Promise(((r,s)=>{const n=t.querySelector(e);if(null!=n)return r(n);const o=setTimeout((()=>{l.disconnect(),s(new Error(`Element "${e}" not found within ${i}ms`))}),i),l=new MutationObserver((()=>{const i=t.querySelector(e);null!=i&&(clearTimeout(o),l.disconnect(),r(i))}));l.observe(t,{childList:!0,subtree:!0})}))}new a;class h{constructor(t){this.stripeService=t,this.store=l({errorMessage:"",errorSource:void 0})}getState(){return this.store.state}async initialize(t){const e=this.stripeService.getElements();if(null==e)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");null!=this.cardElements&&this.unmount();const r=e.create("cardNumber",{placeholder:i.t("Card Number")}),s=await c(t,"#card-number");r.mount(s),r.on("change",this.handleCardError("cardNumber"));const n=e.create("cardExpiry"),o=await c(t,"#card-expiry");n.mount(o),n.on("change",this.handleCardError("cardExpiry"));const l=e.create("cardCvc"),a=await c(t,"#card-cvc");return l.mount(a),l.on("change",this.handleCardError("cardCvc")),this.cardElements={cardNumber:r,cardExpiry:n,cardCVC:l},this.cardElements}getElements(){return this.cardElements}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage",""),this.store.set("errorSource",void 0)}unmount(){var t,e,i;null!=this.cardElements&&(null===(t=this.cardElements.cardNumber)||void 0===t||t.unmount(),null===(e=this.cardElements.cardExpiry)||void 0===e||e.unmount(),null===(i=this.cardElements.cardCVC)||void 0===i||i.unmount(),this.cardElements=void 0)}handleCardError(t){return({error:e})=>{if(e)return this.store.set("errorMessage",e.message),void this.store.set("errorSource",t);this.store.state.errorSource===t&&(this.store.set("errorMessage",""),this.store.set("errorSource",void 0))}}}class u{constructor(t){this.stripeService=t,this.store=l({errorMessage:""})}getState(){return this.store.state}async initialize(t,e){const i=this.stripeService.state.isCheckoutSession;if(null!=this.paymentElement&&this.unmount(),i){const t=this.stripeService.getCheckout();if(null==t)throw new Error("StripeService not initialized with Checkout Session. Call StripeService.initializeWithCheckoutSession() first.");this.paymentElement=t.createPaymentElement(e)}else{const t=this.stripeService.getElements();if(null==t)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");this.paymentElement=t.create("payment",e||{})}const r=await c(t,"#payment-element");return this.paymentElement.mount(r),this.paymentElement}getElement(){return this.paymentElement}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage","")}unmount(){null!=this.paymentElement&&(this.paymentElement.unmount(),this.paymentElement=void 0)}}class d{constructor(t){this.stripeService=t,this.store=l({errorMessage:"",isComplete:!1})}getState(){return this.store.state}async initialize(t,e){const i=this.stripeService.getElements();if(null==i)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");null!=this.addressElement&&this.unmount(),this.addressElement=i.create("address",e||{mode:"billing"});const r=await c(t,"#address-element");return this.addressElement.mount(r),this.addressElement.on("change",(t=>{this.store.set("errorMessage",""),this.store.set("isComplete",t.complete)})),this.addressElement}getElement(){return this.addressElement}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage","")}unmount(){null!=this.addressElement&&(this.addressElement.unmount(),this.addressElement=void 0)}}class v{constructor(t){this.stripeService=t,this.store=l({errorMessage:"",email:void 0,complete:void 0})}getState(){return this.store.state}onChange(t,e){return this.store.onChange(t,e)}async initialize(t,e){const i=this.stripeService.getElements();if(null==i)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");null!=this.linkAuthenticationElement&&this.unmount(),this.store.set("email",void 0),this.store.set("complete",void 0);const r=i.create("linkAuthentication",e),s=await c(t,"#link-authentication-element");return r.mount(s),r.on("change",(t=>{var e;this.store.set("email",null===(e=t.value)||void 0===e?void 0:e.email),this.store.set("complete",t.complete)})),this.linkAuthenticationElement=r,this.linkAuthenticationElement}getElement(){return this.linkAuthenticationElement}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage","")}unmount(){null!=this.linkAuthenticationElement&&(this.linkAuthenticationElement.unmount(),this.linkAuthenticationElement=void 0)}}class p{constructor(t){this.stripeService=t,this.store=l({errorMessage:"",selectedCurrency:void 0})}getState(){return this.store.state}async initialize(t,e){const i=this.stripeService.getElements();if(null==i)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");null!=this.currencySelectorElement&&this.unmount();const r=await c(t,"#currency-selector");return this.currencySelectorElement=i.create("currencySelector",e||{}),this.currencySelectorElement.mount(r),this.currencySelectorElement.on("change",(t=>{var e;this.store.set("errorMessage",""),(null===(e=null==t?void 0:t.value)||void 0===e?void 0:e.currency)&&this.store.set("selectedCurrency",t.value.currency)})),this.currencySelectorElement}getElement(){return this.currencySelectorElement}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage","")}unmount(){null!=this.currencySelectorElement&&(this.currencySelectorElement.unmount(),this.currencySelectorElement=void 0)}}var g=function(t,e){var i={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(i[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(i[r[s]]=t[r[s]])}return i};class m{constructor(t){this.stripeService=t,this.store=l({errorMessage:"",isReady:!1})}getState(){return this.store.state}async initialize(t,e,i){const r=this.stripeService.getElements();if(null==r)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");null!=this.expressCheckoutElement&&this.unmount();const s=g(e,["mode","amount","currency"]),n=Object.assign({},s);if(n.buttonHeight&&"string"==typeof n.buttonHeight){const t=parseInt(n.buttonHeight.replace("px",""),10);isNaN(t)||(n.buttonHeight=t)}const o=r.create("expressCheckout",n),l=await c(t,"#express-checkout-element");return null!=(null==i?void 0:i.onConfirm)&&o.on("confirm",i.onConfirm),null!=(null==i?void 0:i.onClick)&&o.on("click",i.onClick),null!=(null==i?void 0:i.onCancel)&&o.on("cancel",i.onCancel),null!=(null==i?void 0:i.onShippingAddressChange)&&o.on("shippingaddresschange",i.onShippingAddressChange),null!=(null==i?void 0:i.onShippingRateChange)&&o.on("shippingratechange",i.onShippingRateChange),o.on("ready",(()=>{this.store.set("isReady",!0)})),o.mount(l),this.expressCheckoutElement=o,this.expressCheckoutElement}getElement(){return this.expressCheckoutElement}update(t){var e;if(null==this.expressCheckoutElement)return void console.warn("Express Checkout Element not initialized. Cannot update options.");const{mode:i,amount:r,currency:s}=t,n=g(t,["mode","amount","currency"]),o={};void 0!==i&&(o.mode=i),void 0!==r&&(o.amount=r),void 0!==s&&(o.currency=s),Object.keys(o).length>0&&(null===(e=this.stripeService.getElements())||void 0===e||e.update(o));const l=Object.assign({},n);if(l.buttonHeight&&"string"==typeof l.buttonHeight){const t=parseInt(l.buttonHeight.replace("px",""),10);isNaN(t)||(l.buttonHeight=t)}0!==Object.keys(l).length&&this.expressCheckoutElement.update(l)}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage","")}unmount(){null!=this.expressCheckoutElement&&(this.expressCheckoutElement.unmount(),this.expressCheckoutElement=void 0,this.store.set("isReady",!1))}}const f=new class{createStripeService(){return new a}createCardElementManager(t){return new h(t)}createPaymentElementManager(t){return new u(t)}createAddressElementManager(t){return new d(t)}createLinkAuthenticationElementManager(t){return new v(t)}createCurrencySelectorElementManager(t){return new p(t)}createExpressCheckoutElementManager(t){return new m(t)}};export{c as f,f as s}
@@ -1 +1 @@
1
- const t=t=>Object.keys(l).filter((e=>l[e](t))),e=t=>!!a(t,/iPad/i)||!(!a(t,/Macintosh/i)||!s(t)),i=t=>a(t,/android|sink/i),s=t=>h(t,"(any-pointer:coarse)"),n=t=>o(t)||r(t),o=t=>!!(t.cordova||t.phonegap||t.PhoneGap),r=t=>{const e=t.Capacitor;return!(!e||!e.isNative)},a=(t,e)=>e.test(t.navigator.userAgent),h=(t,e)=>t.matchMedia(e).matches,l={ipad:e,iphone:t=>a(t,/iPhone/i),ios:t=>a(t,/iPhone|iPod/i)||e(t),android:i,phablet:t=>{const e=t.innerWidth,i=t.innerHeight,s=Math.min(e,i),n=Math.max(e,i);return s>390&&s<520&&n>620&&n<800},tablet:t=>{const s=t.innerWidth,n=t.innerHeight,o=Math.min(s,n),r=Math.max(s,n);return e(t)||(t=>i(t)&&!a(t,/mobile/i))(t)||o>460&&o<820&&r>780&&r<1400},cordova:o,capacitor:r,electron:t=>a(t,/electron/i),pwa:t=>!(!t.matchMedia("(display-mode: standalone)").matches&&!t.navigator.standalone),mobile:s,mobileweb:t=>s(t)&&!n(t),desktop:t=>!s(t),hybrid:n},c=()=>{const e=((e=window)=>{if(void 0===e)return[];e.Ionic=e.Ionic||{};let i=e.Ionic.platforms;return null==i&&(i=e.Ionic.platforms=t(e),i.forEach((t=>e.document.documentElement.classList.add(`plt-${t}`)))),i})(undefined);return e.includes("ios")?"ios":e.includes("android")?"android":void 0},u=t=>"string"==typeof t,d=()=>{let t,e;const i=new Promise(((i,s)=>{t=i,e=s}));return i.resolve=t,i.reject=e,i},f=t=>null==t?"":""+t,p=/###/g,g=t=>t&&t.indexOf("###")>-1?t.replace(p,"."):t,y=t=>!t||u(t),m=(t,e,i)=>{const s=u(e)?e.split("."):e;let n=0;for(;n<s.length-1;){if(y(t))return{};const e=g(s[n]);!t[e]&&i&&(t[e]=new i),t=Object.prototype.hasOwnProperty.call(t,e)?t[e]:{},++n}return y(t)?{}:{obj:t,k:g(s[n])}},v=(t,e,i)=>{const{obj:s,k:n}=m(t,e,Object);if(void 0!==s||1===e.length)return void(s[n]=i);let o=e[e.length-1],r=e.slice(0,e.length-1),a=m(t,r,Object);for(;void 0===a.obj&&r.length;)o=`${r[r.length-1]}.${o}`,r=r.slice(0,r.length-1),a=m(t,r,Object),a?.obj&&void 0!==a.obj[`${a.k}.${o}`]&&(a.obj=void 0);a.obj[`${a.k}.${o}`]=i},w=(t,e)=>{const{obj:i,k:s}=m(t,e);if(i&&Object.prototype.hasOwnProperty.call(i,s))return i[s]},b=(t,e,i)=>{for(const s in e)"__proto__"!==s&&"constructor"!==s&&(s in t?u(t[s])||t[s]instanceof String||u(e[s])||e[s]instanceof String?i&&(t[s]=e[s]):b(t[s],e[s],i):t[s]=e[s]);return t},$=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var x={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const k=t=>u(t)?t.replace(/[&<>"'\/]/g,(t=>x[t])):t,S=[" ",",","?","!",";"],j=new class{constructor(t){this.capacity=t,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(t){const e=this.regExpMap.get(t);if(void 0!==e)return e;const i=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,i),this.regExpQueue.push(t),i}}(20),O=(t,e,i=".")=>{if(!t)return;if(t[e]){if(!Object.prototype.hasOwnProperty.call(t,e))return;return t[e]}const s=e.split(i);let n=t;for(let t=0;t<s.length;){if(!n||"object"!=typeof n)return;let e,o="";for(let r=t;r<s.length;++r)if(r!==t&&(o+=i),o+=s[r],e=n[o],void 0!==e){if(["string","number","boolean"].indexOf(typeof e)>-1&&r<s.length-1)continue;t+=r-t+1;break}n=e}return n},P=t=>t?.replace(/_/g,"-"),L={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){console?.[t]?.apply?.(console,e)}};class N{constructor(t,e={}){this.init(t,e)}init(t,e={}){this.prefix=e.prefix||"i18next:",this.logger=t||L,this.options=e,this.debug=e.debug}log(...t){return this.forward(t,"log","",!0)}warn(...t){return this.forward(t,"warn","",!0)}error(...t){return this.forward(t,"error","")}deprecate(...t){return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}forward(t,e,i,s){return s&&!this.debug?null:(u(t[0])&&(t[0]=`${i}${this.prefix} ${t[0]}`),this.logger[e](t))}create(t){return new N(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return(t=t||this.options).prefix=t.prefix||this.prefix,new N(this.logger,t)}}var C=new N;class A{constructor(){this.observers={}}on(t,e){return t.split(" ").forEach((t=>{this.observers[t]||(this.observers[t]=new Map);const i=this.observers[t].get(e)||0;this.observers[t].set(e,i+1)})),this}off(t,e){this.observers[t]&&(e?this.observers[t].delete(e):delete this.observers[t])}emit(t,...e){this.observers[t]&&Array.from(this.observers[t].entries()).forEach((([t,i])=>{for(let s=0;s<i;s++)t(...e)})),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach((([i,s])=>{for(let n=0;n<s;n++)i.apply(i,[t,...e])}))}}class R extends A{constructor(t,e={ns:["translation"],defaultNS:"translation"}){super(),this.data=t||{},this.options=e,void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}removeNamespaces(t){const e=this.options.ns.indexOf(t);e>-1&&this.options.ns.splice(e,1)}getResource(t,e,i,s={}){const n=void 0!==s.keySeparator?s.keySeparator:this.options.keySeparator,o=void 0!==s.ignoreJSONStructure?s.ignoreJSONStructure:this.options.ignoreJSONStructure;let r;t.indexOf(".")>-1?r=t.split("."):(r=[t,e],i&&(Array.isArray(i)?r.push(...i):u(i)&&n?r.push(...i.split(n)):r.push(i)));const a=w(this.data,r);return!a&&!e&&!i&&t.indexOf(".")>-1&&(t=r[0],e=r[1],i=r.slice(2).join(".")),!a&&o&&u(i)?O(this.data?.[t]?.[e],i,n):a}addResource(t,e,i,s,n={silent:!1}){const o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator;let r=[t,e];i&&(r=r.concat(o?i.split(o):i)),t.indexOf(".")>-1&&(r=t.split("."),s=e,e=r[1]),this.addNamespaces(e),v(this.data,r,s),n.silent||this.emit("added",t,e,i,s)}addResources(t,e,i,s={silent:!1}){for(const s in i)(u(i[s])||Array.isArray(i[s]))&&this.addResource(t,e,s,i[s],{silent:!0});s.silent||this.emit("added",t,e,i)}addResourceBundle(t,e,i,s,n,o={silent:!1,skipCopy:!1}){let r=[t,e];t.indexOf(".")>-1&&(r=t.split("."),s=i,i=e,e=r[1]),this.addNamespaces(e);let a=w(this.data,r)||{};o.skipCopy||(i=JSON.parse(JSON.stringify(i))),s?b(a,i,n):a={...a,...i},v(this.data,r,a),o.silent||this.emit("added",t,e,i)}removeResourceBundle(t,e){this.hasResourceBundle(t,e)&&delete this.data[t][e],this.removeNamespaces(e),this.emit("removed",t,e)}hasResourceBundle(t,e){return void 0!==this.getResource(t,e)}getResourceBundle(t,e){return e||(e=this.options.defaultNS),this.getResource(t,e)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const e=this.getDataByLanguage(t);return!!(e&&Object.keys(e)||[]).find((t=>e[t]&&Object.keys(e[t]).length>0))}toJSON(){return this.data}}var I={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,i,s,n){return t.forEach((t=>{e=this.processors[t]?.process(e,i,s,n)??e})),e}};const E=Symbol("i18next/PATH_KEY");function T(t,e){const{[E]:i}=t(function(){const t=[],e=Object.create(null);let i;return e.get=(s,n)=>(i?.revoke?.(),n===E?t:(t.push(n),i=Proxy.revocable(s,e),i.proxy)),Proxy.revocable(Object.create(null),e).proxy}()),s=e?.keySeparator??".",n=e?.nsSeparator??":";if(i.length>1&&n){const t=e?.ns,o=Array.isArray(t)?t:null;if(o&&o.length>1&&o.slice(1).includes(i[0]))return`${i[0]}${n}${i.slice(1).join(s)}`}return i.join(s)}const M={},z=t=>!u(t)&&"boolean"!=typeof t&&"number"!=typeof t;class F extends A{constructor(t,e={}){var i,s;super(),i=t,s=this,["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"].forEach((t=>{i[t]&&(s[t]=i[t])})),this.options=e,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=C.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t,e={interpolation:{}}){const i={...e};if(null==t)return!1;const s=this.resolve(t,i);if(void 0===s?.res)return!1;const n=z(s.res);return!1!==i.returnObjects||!n}extractFromKey(t,e){let i=void 0!==e.nsSeparator?e.nsSeparator:this.options.nsSeparator;void 0===i&&(i=":");const s=void 0!==e.keySeparator?e.keySeparator:this.options.keySeparator;let n=e.ns||this.options.defaultNS||[];const o=i&&t.indexOf(i)>-1,r=!(this.options.userDefinedKeySeparator||e.keySeparator||this.options.userDefinedNsSeparator||e.nsSeparator||((t,e,i)=>{e=e||"",i=i||"";const s=S.filter((t=>e.indexOf(t)<0&&i.indexOf(t)<0));if(0===s.length)return!0;const n=j.getRegExp(`(${s.map((t=>"?"===t?"\\?":t)).join("|")})`);let o=!n.test(t);if(!o){const e=t.indexOf(i);e>0&&!n.test(t.substring(0,e))&&(o=!0)}return o})(t,i,s));if(o&&!r){const e=t.match(this.interpolator.nestingRegexp);if(e&&e.length>0)return{key:t,namespaces:u(n)?[n]:n};const o=t.split(i);(i!==s||i===s&&this.options.ns.indexOf(o[0])>-1)&&(n=o.shift()),t=o.join(s)}return{key:t,namespaces:u(n)?[n]:n}}translate(t,e,i){let s="object"==typeof e?{...e}:e;if("object"!=typeof s&&this.options.overloadTranslationOptionHandler&&(s=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof s&&(s={...s}),s||(s={}),null==t)return"";"function"==typeof t&&(t=T(t,{...this.options,...s})),Array.isArray(t)||(t=[String(t)]),t=t.map((t=>"function"==typeof t?T(t,{...this.options,...s}):String(t)));const n=void 0!==s.returnDetails?s.returnDetails:this.options.returnDetails,o=void 0!==s.keySeparator?s.keySeparator:this.options.keySeparator,{key:r,namespaces:a}=this.extractFromKey(t[t.length-1],s),h=a[a.length-1];let l=void 0!==s.nsSeparator?s.nsSeparator:this.options.nsSeparator;void 0===l&&(l=":");const c=s.lng||this.language,d=s.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if("cimode"===c?.toLowerCase())return d?n?{res:`${h}${l}${r}`,usedKey:r,exactUsedKey:r,usedLng:c,usedNS:h,usedParams:this.getUsedParamsDetails(s)}:`${h}${l}${r}`:n?{res:r,usedKey:r,exactUsedKey:r,usedLng:c,usedNS:h,usedParams:this.getUsedParamsDetails(s)}:r;const f=this.resolve(t,s);let p=f?.res;const g=f?.usedKey||r,y=f?.exactUsedKey||r,m=void 0!==s.joinArrays?s.joinArrays:this.options.joinArrays,v=!this.i18nFormat||this.i18nFormat.handleAsObject,w=void 0!==s.count&&!u(s.count),b=F.hasDefaultValue(s),$=w?this.pluralResolver.getSuffix(c,s.count,s):"",x=s.ordinal&&w?this.pluralResolver.getSuffix(c,s.count,{ordinal:!1}):"",k=w&&!s.ordinal&&0===s.count,S=k&&s[`defaultValue${this.options.pluralSeparator}zero`]||s[`defaultValue${$}`]||s[`defaultValue${x}`]||s.defaultValue;let j=p;v&&!p&&b&&(j=S);const O=z(j),P=Object.prototype.toString.apply(j);if(!(v&&j&&O&&["[object Number]","[object Function]","[object RegExp]"].indexOf(P)<0)||u(m)&&Array.isArray(j))if(v&&u(m)&&Array.isArray(p))p=p.join(m),p&&(p=this.extendTranslation(p,t,s,i));else{let e=!1,n=!1;!this.isValidLookup(p)&&b&&(e=!0,p=S),this.isValidLookup(p)||(n=!0,p=r);const a=(s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&n?void 0:p,u=b&&S!==p&&this.options.updateMissing;if(n||e||u){if(this.logger.log(u?"updateKey":"missingKey",c,h,r,u?S:p),o){const t=this.resolve(r,{...s,keySeparator:!1});t&&t.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let t=[];const e=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if("fallback"===this.options.saveMissingTo&&e&&e[0])for(let i=0;i<e.length;i++)t.push(e[i]);else"all"===this.options.saveMissingTo?t=this.languageUtils.toResolveHierarchy(s.lng||this.language):t.push(s.lng||this.language);const i=(t,e,i)=>{const n=b&&i!==p?i:a;this.options.missingKeyHandler?this.options.missingKeyHandler(t,h,e,n,u,s):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(t,h,e,n,u,s),this.emit("missingKey",t,h,e,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&w?t.forEach((t=>{const e=this.pluralResolver.getSuffixes(t,s);k&&s[`defaultValue${this.options.pluralSeparator}zero`]&&e.indexOf(`${this.options.pluralSeparator}zero`)<0&&e.push(`${this.options.pluralSeparator}zero`),e.forEach((e=>{i([t],r+e,s[`defaultValue${e}`]||S)}))})):i(t,r,S))}p=this.extendTranslation(p,t,s,f,i),n&&p===r&&this.options.appendNamespaceToMissingKey&&(p=`${h}${l}${r}`),(n||e)&&this.options.parseMissingKeyHandler&&(p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${h}${l}${r}`:r,e?p:void 0,s))}else{if(!s.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const t=this.options.returnedObjectHandler?this.options.returnedObjectHandler(g,j,{...s,ns:a}):`key '${r} (${this.language})' returned an object instead of string.`;return n?(f.res=t,f.usedParams=this.getUsedParamsDetails(s),f):t}if(o){const t=Array.isArray(j),e=t?[]:{},i=t?y:g;for(const t in j)if(Object.prototype.hasOwnProperty.call(j,t)){const n=`${i}${o}${t}`;e[t]=this.translate(n,b&&!p?{...s,defaultValue:z(S)?S[t]:void 0,joinArrays:!1,ns:a}:{...s,joinArrays:!1,ns:a}),e[t]===n&&(e[t]=j[t])}p=e}}return n?(f.res=p,f.usedParams=this.getUsedParamsDetails(s),f):p}extendTranslation(t,e,i,s,n){if(this.i18nFormat?.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...i},i.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!i.skipInterpolation){i.interpolation&&this.interpolator.init({...i,interpolation:{...this.options.interpolation,...i.interpolation}});const o=u(t)&&(void 0!==i?.interpolation?.skipOnVariables?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let r;if(o){const e=t.match(this.interpolator.nestingRegexp);r=e&&e.length}let a=i.replace&&!u(i.replace)?i.replace:i;if(this.options.interpolation.defaultVariables&&(a={...this.options.interpolation.defaultVariables,...a}),t=this.interpolator.interpolate(t,a,i.lng||this.language||s.usedLng,i),o){const e=t.match(this.interpolator.nestingRegexp);r<(e&&e.length)&&(i.nest=!1)}!i.lng&&s&&s.res&&(i.lng=this.language||s.usedLng),!1!==i.nest&&(t=this.interpolator.nest(t,((...t)=>n?.[0]!==t[0]||i.context?this.translate(...t,e):(this.logger.warn(`It seems you are nesting recursively key: ${t[0]} in key: ${e[0]}`),null)),i)),i.interpolation&&this.interpolator.reset()}const o=i.postProcess||this.options.postProcess,r=u(o)?[o]:o;return null!=t&&r?.length&&!1!==i.applyPostProcessor&&(t=I.handle(r,t,e,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...s,usedParams:this.getUsedParamsDetails(i)},...i}:i,this)),t}resolve(t,e={}){let i,s,n,o,r;return u(t)&&(t=[t]),Array.isArray(t)&&(t=t.map((t=>"function"==typeof t?T(t,{...this.options,...e}):t))),t.forEach((t=>{if(this.isValidLookup(i))return;const a=this.extractFromKey(t,e),h=a.key;s=h;let l=a.namespaces;this.options.fallbackNS&&(l=l.concat(this.options.fallbackNS));const c=void 0!==e.count&&!u(e.count),d=c&&!e.ordinal&&0===e.count,f=void 0!==e.context&&(u(e.context)||"number"==typeof e.context)&&""!==e.context,p=e.lngs?e.lngs:this.languageUtils.toResolveHierarchy(e.lng||this.language,e.fallbackLng);l.forEach((t=>{this.isValidLookup(i)||(r=t,M[`${p[0]}-${t}`]||!this.utils?.hasLoadedNamespace||this.utils?.hasLoadedNamespace(r)||(M[`${p[0]}-${t}`]=!0,this.logger.warn(`key "${s}" for languages "${p.join(", ")}" won't get resolved as namespace "${r}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),p.forEach((s=>{if(this.isValidLookup(i))return;o=s;const r=[h];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(r,h,s,t,e);else{let t;c&&(t=this.pluralResolver.getSuffix(s,e.count,e));const i=`${this.options.pluralSeparator}zero`,n=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(c&&(e.ordinal&&0===t.indexOf(n)&&r.push(h+t.replace(n,this.options.pluralSeparator)),r.push(h+t),d&&r.push(h+i)),f){const s=`${h}${this.options.contextSeparator||"_"}${e.context}`;r.push(s),c&&(e.ordinal&&0===t.indexOf(n)&&r.push(s+t.replace(n,this.options.pluralSeparator)),r.push(s+t),d&&r.push(s+i))}}let a;for(;a=r.pop();)this.isValidLookup(i)||(n=a,i=this.getResource(s,t,a,e))})))}))})),{res:i,usedKey:s,exactUsedKey:n,usedLng:o,usedNS:r}}isValidLookup(t){return!(void 0===t||!this.options.returnNull&&null===t||!this.options.returnEmptyString&&""===t)}getResource(t,e,i,s={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(t,e,i,s):this.resourceStore.getResource(t,e,i,s)}getUsedParamsDetails(t={}){const e=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],i=t.replace&&!u(t.replace);let s=i?t.replace:t;if(i&&void 0!==t.count&&(s.count=t.count),this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),!i){s={...s};for(const t of e)delete s[t]}return s}static hasDefaultValue(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)&&"defaultValue"===e.substring(0,12)&&void 0!==t[e])return!0;return!1}}class V{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=C.create("languageUtils")}getScriptPartFromCode(t){if(!(t=P(t))||t.indexOf("-")<0)return null;const e=t.split("-");return 2===e.length?null:(e.pop(),"x"===e[e.length-1].toLowerCase()?null:this.formatLanguageCode(e.join("-")))}getLanguagePartFromCode(t){if(!(t=P(t))||t.indexOf("-")<0)return t;const e=t.split("-");return this.formatLanguageCode(e[0])}formatLanguageCode(t){if(u(t)&&t.indexOf("-")>-1){let e;try{e=Intl.getCanonicalLocales(t)[0]}catch(t){}return e&&this.options.lowerCaseLng&&(e=e.toLowerCase()),e||(this.options.lowerCaseLng?t.toLowerCase():t)}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let e;return t.forEach((t=>{if(e)return;const i=this.formatLanguageCode(t);this.options.supportedLngs&&!this.isSupportedCode(i)||(e=i)})),!e&&this.options.supportedLngs&&t.forEach((t=>{if(e)return;const i=this.getScriptPartFromCode(t);if(this.isSupportedCode(i))return e=i;const s=this.getLanguagePartFromCode(t);if(this.isSupportedCode(s))return e=s;e=this.options.supportedLngs.find((t=>t===s?t:t.indexOf("-")<0&&s.indexOf("-")<0?void 0:t.indexOf("-")>0&&s.indexOf("-")<0&&t.substring(0,t.indexOf("-"))===s||0===t.indexOf(s)&&s.length>1?t:void 0))})),e||(e=this.getFallbackCodes(this.options.fallbackLng)[0]),e}getFallbackCodes(t,e){if(!t)return[];if("function"==typeof t&&(t=t(e)),u(t)&&(t=[t]),Array.isArray(t))return t;if(!e)return t.default||[];let i=t[e];return i||(i=t[this.getScriptPartFromCode(e)]),i||(i=t[this.formatLanguageCode(e)]),i||(i=t[this.getLanguagePartFromCode(e)]),i||(i=t.default),i||[]}toResolveHierarchy(t,e){const i=this.getFallbackCodes((!1===e?[]:e)||this.options.fallbackLng||[],t),s=[],n=t=>{t&&(this.isSupportedCode(t)?s.push(t):this.logger.warn(`rejecting language code not found in supportedLngs: ${t}`))};return u(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?("languageOnly"!==this.options.load&&n(this.formatLanguageCode(t)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&n(this.getScriptPartFromCode(t)),"currentOnly"!==this.options.load&&n(this.getLanguagePartFromCode(t))):u(t)&&n(this.formatLanguageCode(t)),i.forEach((t=>{s.indexOf(t)<0&&n(this.formatLanguageCode(t))})),s}}const D={zero:0,one:1,two:2,few:3,many:4,other:5},B={select:t=>1===t?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class K{constructor(t,e={}){this.languageUtils=t,this.options=e,this.logger=C.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(t,e={}){const i=P("dev"===t?"en":t),s=e.ordinal?"ordinal":"cardinal",n=JSON.stringify({cleanedCode:i,type:s});if(n in this.pluralRulesCache)return this.pluralRulesCache[n];let o;try{o=new Intl.PluralRules(i,{type:s})}catch(i){if("undefined"==typeof Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),B;if(!t.match(/-|_/))return B;const s=this.languageUtils.getLanguagePartFromCode(t);o=this.getRule(s,e)}return this.pluralRulesCache[n]=o,o}needsPlural(t,e={}){let i=this.getRule(t,e);return i||(i=this.getRule("dev",e)),i?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(t,e,i={}){return this.getSuffixes(t,i).map((t=>`${e}${t}`))}getSuffixes(t,e={}){let i=this.getRule(t,e);return i||(i=this.getRule("dev",e)),i?i.resolvedOptions().pluralCategories.sort(((t,e)=>D[t]-D[e])).map((t=>`${this.options.prepend}${e.ordinal?`ordinal${this.options.prepend}`:""}${t}`)):[]}getSuffix(t,e,i={}){const s=this.getRule(t,i);return s?`${this.options.prepend}${i.ordinal?`ordinal${this.options.prepend}`:""}${s.select(e)}`:(this.logger.warn(`no plural rule found for: ${t}`),this.getSuffix("dev",e,i))}}const _=(t,e,i,s=".",n=!0)=>{let o=((t,e,i)=>{const s=w(t,i);return void 0!==s?s:w(e,i)})(t,e,i);return!o&&n&&u(i)&&(o=O(t,i,s),void 0===o&&(o=O(e,i,s))),o},U=t=>t.replace(/\$/g,"$$$$");class H{constructor(t={}){this.logger=C.create("interpolator"),this.options=t,this.format=t?.interpolation?.format||(t=>t),this.init(t)}init(t={}){t.interpolation||(t.interpolation={escapeValue:!0});const{escape:e,escapeValue:i,useRawValueToEscape:s,prefix:n,prefixEscaped:o,suffix:r,suffixEscaped:a,formatSeparator:h,unescapeSuffix:l,unescapePrefix:c,nestingPrefix:u,nestingPrefixEscaped:d,nestingSuffix:f,nestingSuffixEscaped:p,nestingOptionsSeparator:g,maxReplaces:y,alwaysFormat:m}=t.interpolation;this.escape=void 0!==e?e:k,this.escapeValue=void 0===i||i,this.useRawValueToEscape=void 0!==s&&s,this.prefix=n?$(n):o||"{{",this.suffix=r?$(r):a||"}}",this.formatSeparator=h||",",this.unescapePrefix=l?"":c||"-",this.unescapeSuffix=this.unescapePrefix?"":l||"",this.nestingPrefix=u?$(u):d||$("$t("),this.nestingSuffix=f?$(f):p||$(")"),this.nestingOptionsSeparator=g||",",this.maxReplaces=y||1e3,this.alwaysFormat=void 0!==m&&m,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(t,e)=>t?.source===e?(t.lastIndex=0,t):new RegExp(e,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(t,e,i,s){let n,o,r;const a=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},h=t=>{if(t.indexOf(this.formatSeparator)<0){const n=_(e,a,t,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(n,void 0,i,{...s,...e,interpolationkey:t}):n}const n=t.split(this.formatSeparator),o=n.shift().trim(),r=n.join(this.formatSeparator).trim();return this.format(_(e,a,o,this.options.keySeparator,this.options.ignoreJSONStructure),r,i,{...s,...e,interpolationkey:o})};this.resetRegExp();const l=s?.missingInterpolationHandler||this.options.missingInterpolationHandler,c=void 0!==s?.interpolation?.skipOnVariables?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:t=>U(t)},{regex:this.regexp,safeValue:t=>U(this.escapeValue?this.escape(t):t)}].forEach((e=>{for(r=0;n=e.regex.exec(t);){const i=n[1].trim();if(o=h(i),void 0===o)if("function"==typeof l){const e=l(t,n,s);o=u(e)?e:""}else if(s&&Object.prototype.hasOwnProperty.call(s,i))o="";else{if(c){o=n[0];continue}this.logger.warn(`missed to pass in variable ${i} for interpolating ${t}`),o=""}else u(o)||this.useRawValueToEscape||(o=f(o));const a=e.safeValue(o);if(t=t.replace(n[0],a),c?(e.regex.lastIndex+=o.length,e.regex.lastIndex-=n[0].length):e.regex.lastIndex=0,r++,r>=this.maxReplaces)break}})),t}nest(t,e,i={}){let s,n,o;const r=(t,e)=>{const i=this.nestingOptionsSeparator;if(t.indexOf(i)<0)return t;const s=t.split(new RegExp(`${$(i)}[ ]*{`));let n=`{${s[1]}`;t=s[0],n=this.interpolate(n,o);const r=n.match(/'/g),a=n.match(/"/g);((r?.length??0)%2==0&&!a||(a?.length??0)%2!=0)&&(n=n.replace(/'/g,'"'));try{o=JSON.parse(n),e&&(o={...e,...o})}catch(e){return this.logger.warn(`failed parsing options string in nesting for key ${t}`,e),`${t}${i}${n}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,t};for(;s=this.nestingRegexp.exec(t);){let a=[];o={...i},o=o.replace&&!u(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;const h=/{.*}/.test(s[1])?s[1].lastIndexOf("}")+1:s[1].indexOf(this.formatSeparator);if(-1!==h&&(a=s[1].slice(h).split(this.formatSeparator).map((t=>t.trim())).filter(Boolean),s[1]=s[1].slice(0,h)),n=e(r.call(this,s[1].trim(),o),o),n&&s[0]===t&&!u(n))return n;u(n)||(n=f(n)),n||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),n=""),a.length&&(n=a.reduce(((t,e)=>this.format(t,e,i.lng,{...i,interpolationkey:s[1].trim()})),n.trim())),t=t.replace(s[0],n),this.regexp.lastIndex=0}return t}}const Y=t=>{const e={};return(i,s,n)=>{let o=n;n&&n.interpolationkey&&n.formatParams&&n.formatParams[n.interpolationkey]&&n[n.interpolationkey]&&(o={...o,[n.interpolationkey]:void 0});const r=s+JSON.stringify(o);let a=e[r];return a||(a=t(P(s),n),e[r]=a),a(i)}},J=t=>(e,i,s)=>t(P(i),s)(e);class q{constructor(t={}){this.logger=C.create("formatter"),this.options=t,this.init(t)}init(t,e={interpolation:{}}){this.formatSeparator=e.interpolation.formatSeparator||",";const i=e.cacheInBuiltFormats?Y:J;this.formats={number:i(((t,e)=>{const i=new Intl.NumberFormat(t,{...e});return t=>i.format(t)})),currency:i(((t,e)=>{const i=new Intl.NumberFormat(t,{...e,style:"currency"});return t=>i.format(t)})),datetime:i(((t,e)=>{const i=new Intl.DateTimeFormat(t,{...e});return t=>i.format(t)})),relativetime:i(((t,e)=>{const i=new Intl.RelativeTimeFormat(t,{...e});return t=>i.format(t,e.range||"day")})),list:i(((t,e)=>{const i=new Intl.ListFormat(t,{...e});return t=>i.format(t)}))}}add(t,e){this.formats[t.toLowerCase().trim()]=e}addCached(t,e){this.formats[t.toLowerCase().trim()]=Y(e)}format(t,e,i,s={}){const n=e.split(this.formatSeparator);if(n.length>1&&n[0].indexOf("(")>1&&n[0].indexOf(")")<0&&n.find((t=>t.indexOf(")")>-1))){const t=n.findIndex((t=>t.indexOf(")")>-1));n[0]=[n[0],...n.splice(1,t)].join(this.formatSeparator)}return n.reduce(((t,e)=>{const{formatName:n,formatOptions:o}=(t=>{let e=t.toLowerCase().trim();const i={};if(t.indexOf("(")>-1){const s=t.split("(");e=s[0].toLowerCase().trim();const n=s[1].substring(0,s[1].length-1);"currency"===e&&n.indexOf(":")<0?i.currency||(i.currency=n.trim()):"relativetime"===e&&n.indexOf(":")<0?i.range||(i.range=n.trim()):n.split(";").forEach((t=>{if(t){const[e,...s]=t.split(":"),n=s.join(":").trim().replace(/^'+|'+$/g,""),o=e.trim();i[o]||(i[o]=n),"false"===n&&(i[o]=!1),"true"===n&&(i[o]=!0),isNaN(n)||(i[o]=parseInt(n,10))}}))}return{formatName:e,formatOptions:i}})(e);if(this.formats[n]){let e=t;try{const r=s?.formatParams?.[s.interpolationkey]||{};e=this.formats[n](t,r.locale||r.lng||s.locale||s.lng||i,{...o,...s,...r})}catch(t){this.logger.warn(t)}return e}return this.logger.warn(`there was no format function for ${n}`),t}),t)}}class W extends A{constructor(t,e,i,s={}){super(),this.backend=t,this.store=e,this.services=i,this.languageUtils=i.languageUtils,this.options=s,this.logger=C.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=s.maxParallelReads||10,this.readingCalls=0,this.maxRetries=s.maxRetries>=0?s.maxRetries:5,this.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(i,s.backend,s)}queueLoad(t,e,i,s){const n={},o={},r={},a={};return t.forEach((t=>{let s=!0;e.forEach((e=>{const r=`${t}|${e}`;!i.reload&&this.store.hasResourceBundle(t,e)?this.state[r]=2:this.state[r]<0||(1===this.state[r]?void 0===o[r]&&(o[r]=!0):(this.state[r]=1,s=!1,void 0===o[r]&&(o[r]=!0),void 0===n[r]&&(n[r]=!0),void 0===a[e]&&(a[e]=!0)))})),s||(r[t]=!0)})),(Object.keys(n).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(n),pending:Object.keys(o),toLoadLanguages:Object.keys(r),toLoadNamespaces:Object.keys(a)}}loaded(t,e,i){const s=t.split("|"),n=s[0],o=s[1];e&&this.emit("failedLoading",n,o,e),!e&&i&&this.store.addResourceBundle(n,o,i,void 0,void 0,{skipCopy:!0}),this.state[t]=e?-1:2,e&&i&&(this.state[t]=0);const r={};this.queue.forEach((i=>{((t,e,i)=>{const{obj:s,k:n}=m(t,e,Object);s[n]=s[n]||[],s[n].push(i)})(i.loaded,[n],o),((t,e)=>{void 0!==t.pending[e]&&(delete t.pending[e],t.pendingCount--)})(i,t),e&&i.errors.push(e),0!==i.pendingCount||i.done||(Object.keys(i.loaded).forEach((t=>{r[t]||(r[t]={});const e=i.loaded[t];e.length&&e.forEach((e=>{void 0===r[t][e]&&(r[t][e]=!0)}))})),i.done=!0,i.errors.length?i.callback(i.errors):i.callback())})),this.emit("loaded",r),this.queue=this.queue.filter((t=>!t.done))}read(t,e,i,s=0,n=this.retryTimeout,o){if(!t.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:t,ns:e,fcName:i,tried:s,wait:n,callback:o});this.readingCalls++;const r=(r,a)=>{if(this.readingCalls--,this.waitingReads.length>0){const t=this.waitingReads.shift();this.read(t.lng,t.ns,t.fcName,t.tried,t.wait,t.callback)}r&&a&&s<this.maxRetries?setTimeout((()=>{this.read.call(this,t,e,i,s+1,2*n,o)}),n):o(r,a)},a=this.backend[i].bind(this.backend);if(2!==a.length)return a(t,e,r);try{const i=a(t,e);i&&"function"==typeof i.then?i.then((t=>r(null,t))).catch(r):r(null,i)}catch(t){r(t)}}prepareLoading(t,e,i={},s){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();u(t)&&(t=this.languageUtils.toResolveHierarchy(t)),u(e)&&(e=[e]);const n=this.queueLoad(t,e,i,s);if(!n.toLoad.length)return n.pending.length||s(),null;n.toLoad.forEach((t=>{this.loadOne(t)}))}load(t,e,i){this.prepareLoading(t,e,{},i)}reload(t,e,i){this.prepareLoading(t,e,{reload:!0},i)}loadOne(t,e=""){const i=t.split("|"),s=i[0],n=i[1];this.read(s,n,"read",void 0,void 0,((i,o)=>{i&&this.logger.warn(`${e}loading namespace ${n} for language ${s} failed`,i),!i&&o&&this.logger.log(`${e}loaded namespace ${n} for language ${s}`,o),this.loaded(t,i,o)}))}saveMissing(t,e,i,s,n,o={},r=()=>{}){if(!this.services?.utils?.hasLoadedNamespace||this.services?.utils?.hasLoadedNamespace(e)){if(null!=i&&""!==i){if(this.backend?.create){const a={...o,isUpdate:n},h=this.backend.create.bind(this.backend);if(h.length<6)try{let n;n=5===h.length?h(t,e,i,s,a):h(t,e,i,s),n&&"function"==typeof n.then?n.then((t=>r(null,t))).catch(r):r(null,n)}catch(t){r(t)}else h(t,e,i,s,r,a)}t&&t[0]&&this.store.addResource(t[0],e,i,s)}}else this.logger.warn(`did not save key "${i}" as the namespace "${e}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")}}const G=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if("object"==typeof t[1]&&(e=t[1]),u(t[1])&&(e.defaultValue=t[1]),u(t[2])&&(e.tDescription=t[2]),"object"==typeof t[2]||"object"==typeof t[3]){const i=t[3]||t[2];Object.keys(i).forEach((t=>{e[t]=i[t]}))}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),Q=t=>(u(t.ns)&&(t.ns=[t.ns]),u(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),u(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs?.indexOf?.("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),"boolean"==typeof t.initImmediate&&(t.initAsync=t.initImmediate),t),Z=()=>{},X="__i18next_supportNoticeShown";class tt extends A{constructor(t={},e){var i;if(super(),this.options=Q(t),this.services={},this.logger=C,this.modules={external:[]},i=this,Object.getOwnPropertyNames(Object.getPrototypeOf(i)).forEach((t=>{"function"==typeof i[t]&&(i[t]=i[t].bind(i))})),e&&!this.isInitialized&&!t.isClone){if(!this.options.initAsync)return this.init(t,e),this;setTimeout((()=>{this.init(t,e)}),0)}}init(t={},e){this.isInitializing=!0,"function"==typeof t&&(e=t,t={}),null==t.defaultNS&&t.ns&&(u(t.ns)?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));const i=G();var s;this.options={...i,...this.options,...Q(t)},this.options.interpolation={...i.interpolation,...this.options.interpolation},void 0!==t.keySeparator&&(this.options.userDefinedKeySeparator=t.keySeparator),void 0!==t.nsSeparator&&(this.options.userDefinedNsSeparator=t.nsSeparator),"function"!=typeof this.options.overloadTranslationOptionHandler&&(this.options.overloadTranslationOptionHandler=i.overloadTranslationOptionHandler),!1===this.options.showSupportNotice||(s=this,s?.modules?.backend?.name?.indexOf("Locize")>0||s?.modules?.backend?.constructor?.name?.indexOf("Locize")>0||s?.options?.backend?.backends&&s.options.backend.backends.some((t=>t?.name?.indexOf("Locize")>0||t?.constructor?.name?.indexOf("Locize")>0))||s?.options?.backend?.projectId||s?.options?.backend?.backendOptions&&s.options.backend.backendOptions.some((t=>t?.projectId)))||"undefined"!=typeof globalThis&&globalThis[X]||"undefined"!=typeof process&&process.env&&process.env.I18NEXT_NO_SUPPORT_NOTICE||"undefined"!=typeof process&&process.env||("undefined"!=typeof console&&void 0!==console.info&&console.info("🌐 i18next is made possible by our own product, Locize — consider powering your project with managed localization (AI, CDN, integrations): https://locize.com 💙"),"undefined"!=typeof globalThis&&(globalThis[X]=!0));const n=t=>t?"function"==typeof t?new t:t:null;if(!this.options.isClone){let t;C.init(this.modules.logger?n(this.modules.logger):null,this.options),t=this.modules.formatter?this.modules.formatter:q;const e=new V(this.options);this.store=new R(this.options.resources,this.options);const s=this.services;s.logger=C,s.resourceStore=this.store,s.languageUtils=e,s.pluralResolver=new K(e,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==i.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),!t||this.options.interpolation.format&&this.options.interpolation.format!==i.interpolation.format||(s.formatter=n(t),s.formatter.init&&s.formatter.init(s,this.options),this.options.interpolation.format=s.formatter.format.bind(s.formatter)),s.interpolator=new H(this.options),s.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},s.backendConnector=new W(n(this.modules.backend),s.resourceStore,s,this.options),s.backendConnector.on("*",((t,...e)=>{this.emit(t,...e)})),this.modules.languageDetector&&(s.languageDetector=n(this.modules.languageDetector),s.languageDetector.init&&s.languageDetector.init(s,this.options.detection,this.options)),this.modules.i18nFormat&&(s.i18nFormat=n(this.modules.i18nFormat),s.i18nFormat.init&&s.i18nFormat.init(this)),this.translator=new F(this.services,this.options),this.translator.on("*",((t,...e)=>{this.emit(t,...e)})),this.modules.external.forEach((t=>{t.init&&t.init(this)}))}if(this.format=this.options.interpolation.format,e||(e=Z),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const t=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);t.length>0&&"dev"!==t[0]&&(this.options.lng=t[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach((t=>{this[t]=(...e)=>this.store[t](...e)})),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach((t=>{this[t]=(...e)=>(this.store[t](...e),this)}));const o=d(),r=()=>{const t=(t,i)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),o.resolve(i),e(t,i)};if(this.languages&&!this.isInitialized)return t(null,this.t.bind(this));this.changeLanguage(this.options.lng,t)};return this.options.resources||!this.options.initAsync?r():setTimeout(r,0),o}loadResources(t,e=Z){let i=e;const s=u(t)?t:this.language;if("function"==typeof t&&(i=t),!this.options.resources||this.options.partialBundledLanguages){if("cimode"===s?.toLowerCase()&&(!this.options.preload||0===this.options.preload.length))return i();const t=[],e=e=>{e&&"cimode"!==e&&this.services.languageUtils.toResolveHierarchy(e).forEach((e=>{"cimode"!==e&&t.indexOf(e)<0&&t.push(e)}))};s?e(s):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((t=>e(t))),this.options.preload?.forEach?.((t=>e(t))),this.services.backendConnector.load(t,this.options.ns,(t=>{t||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),i(t)}))}else i(null)}reloadResources(t,e,i){const s=d();return"function"==typeof t&&(i=t,t=void 0),"function"==typeof e&&(i=e,e=void 0),t||(t=this.languages),e||(e=this.options.ns),i||(i=Z),this.services.backendConnector.reload(t,e,(t=>{s.resolve(),i(t)})),s}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===t.type&&(this.modules.backend=t),("logger"===t.type||t.log&&t.warn&&t.error)&&(this.modules.logger=t),"languageDetector"===t.type&&(this.modules.languageDetector=t),"i18nFormat"===t.type&&(this.modules.i18nFormat=t),"postProcessor"===t.type&&I.addPostProcessor(t),"formatter"===t.type&&(this.modules.formatter=t),"3rdParty"===t.type&&this.modules.external.push(t),this}setResolvedLanguage(t){if(t&&this.languages&&!(["cimode","dev"].indexOf(t)>-1)){for(let t=0;t<this.languages.length;t++){const e=this.languages[t];if(!(["cimode","dev"].indexOf(e)>-1)&&this.store.hasLanguageSomeTranslations(e)){this.resolvedLanguage=e;break}}!this.resolvedLanguage&&this.languages.indexOf(t)<0&&this.store.hasLanguageSomeTranslations(t)&&(this.resolvedLanguage=t,this.languages.unshift(t))}}changeLanguage(t,e){this.isLanguageChangingTo=t;const i=d();this.emit("languageChanging",t);const s=t=>{this.language=t,this.languages=this.services.languageUtils.toResolveHierarchy(t),this.resolvedLanguage=void 0,this.setResolvedLanguage(t)},n=(n,o)=>{o?this.isLanguageChangingTo===t&&(s(o),this.translator.changeLanguage(o),this.isLanguageChangingTo=void 0,this.emit("languageChanged",o),this.logger.log("languageChanged",o)):this.isLanguageChangingTo=void 0,i.resolve(((...t)=>this.t(...t))),e&&e(n,((...t)=>this.t(...t)))},o=e=>{t||e||!this.services.languageDetector||(e=[]);const i=u(e)?e:e&&e[0],o=this.store.hasLanguageSomeTranslations(i)?i:this.services.languageUtils.getBestMatchFromCodes(u(e)?[e]:e);o&&(this.language||s(o),this.translator.language||this.translator.changeLanguage(o),this.services.languageDetector?.cacheUserLanguage?.(o)),this.loadResources(o,(t=>{n(t,o)}))};return t||!this.services.languageDetector||this.services.languageDetector.async?!t&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(t):o(this.services.languageDetector.detect()),i}getFixedT(t,e,i){const s=(t,e,...n)=>{let o;o="object"!=typeof e?this.options.overloadTranslationOptionHandler([t,e].concat(n)):{...e},o.lng=o.lng||s.lng,o.lngs=o.lngs||s.lngs,o.ns=o.ns||s.ns,""!==o.keyPrefix&&(o.keyPrefix=o.keyPrefix||i||s.keyPrefix);const r={...this.options,...o};"function"==typeof o.keyPrefix&&(o.keyPrefix=T(o.keyPrefix,r));const a=this.options.keySeparator||".";let h;return o.keyPrefix&&Array.isArray(t)?h=t.map((t=>("function"==typeof t&&(t=T(t,r)),`${o.keyPrefix}${a}${t}`))):("function"==typeof t&&(t=T(t,r)),h=o.keyPrefix?`${o.keyPrefix}${a}${t}`:t),this.t(h,o)};return u(t)?s.lng=t:s.lngs=t,s.ns=e,s.keyPrefix=i,s}t(...t){return this.translator?.translate(...t)}exists(...t){return this.translator?.exists(...t)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t,e={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const i=e.lng||this.resolvedLanguage||this.languages[0],s=!!this.options&&this.options.fallbackLng,n=this.languages[this.languages.length-1];if("cimode"===i.toLowerCase())return!0;const o=(t,e)=>{const i=this.services.backendConnector.state[`${t}|${e}`];return-1===i||0===i||2===i};if(e.precheck){const t=e.precheck(this,o);if(void 0!==t)return t}return!(!this.hasResourceBundle(i,t)&&this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages)&&(!o(i,t)||s&&!o(n,t)))}loadNamespaces(t,e){const i=d();return this.options.ns?(u(t)&&(t=[t]),t.forEach((t=>{this.options.ns.indexOf(t)<0&&this.options.ns.push(t)})),this.loadResources((t=>{i.resolve(),e&&e(t)})),i):(e&&e(),Promise.resolve())}loadLanguages(t,e){const i=d();u(t)&&(t=[t]);const s=this.options.preload||[],n=t.filter((t=>s.indexOf(t)<0&&this.services.languageUtils.isSupportedCode(t)));return n.length?(this.options.preload=s.concat(n),this.loadResources((t=>{i.resolve(),e&&e(t)})),i):(e&&e(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!t)return"rtl";try{const e=new Intl.Locale(t);if(e&&e.getTextInfo){const t=e.getTextInfo();if(t&&t.direction)return t.direction}}catch(t){}const e=this.services?.languageUtils||new V(G());return t.toLowerCase().indexOf("-latn")>1?"ltr":["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(e.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(t={},e){const i=new tt(t,e);return i.createInstance=tt.createInstance,i}cloneInstance(t={},e=Z){const i=t.forkResourceStore;i&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},n=new tt(s);if(void 0===t.debug&&void 0===t.prefix||(n.logger=n.logger.clone(t)),["store","services","language"].forEach((t=>{n[t]=this[t]})),n.services={...this.services},n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},i){const t=Object.keys(this.store.data).reduce(((t,e)=>(t[e]={...this.store.data[e]},t[e]=Object.keys(t[e]).reduce(((i,s)=>(i[s]={...t[e][s]},i)),t[e]),t)),{});n.store=new R(t,s),n.services.resourceStore=n.store}if(t.interpolation){const e={...G().interpolation,...this.options.interpolation,...t.interpolation},i={...s,interpolation:e};n.services.interpolator=new H(i)}return n.translator=new F(n.services,s),n.translator.on("*",((t,...e)=>{n.emit(t,...e)})),n.init(s,e),n.translator.options=s,n.translator.backendConnector.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},n}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const et=tt.createInstance(),{slice:it,forEach:st}=[],nt=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,ot={create(t,e,i,s){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{path:"/",sameSite:"strict"};i&&(n.expires=new Date,n.expires.setTime(n.expires.getTime()+60*i*1e3)),s&&(n.domain=s),document.cookie=function(t,e){const i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{path:"/"};let s=`${t}=${encodeURIComponent(e)}`;if(i.maxAge>0){const t=i.maxAge-0;if(Number.isNaN(t))throw new Error("maxAge should be a Number");s+=`; Max-Age=${Math.floor(t)}`}if(i.domain){if(!nt.test(i.domain))throw new TypeError("option domain is invalid");s+=`; Domain=${i.domain}`}if(i.path){if(!nt.test(i.path))throw new TypeError("option path is invalid");s+=`; Path=${i.path}`}if(i.expires){if("function"!=typeof i.expires.toUTCString)throw new TypeError("option expires is invalid");s+=`; Expires=${i.expires.toUTCString()}`}if(i.httpOnly&&(s+="; HttpOnly"),i.secure&&(s+="; Secure"),i.sameSite)switch("string"==typeof i.sameSite?i.sameSite.toLowerCase():i.sameSite){case!0:s+="; SameSite=Strict";break;case"lax":s+="; SameSite=Lax";break;case"strict":s+="; SameSite=Strict";break;case"none":s+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return i.partitioned&&(s+="; Partitioned"),s}(t,e,n)},read(t){const e=`${t}=`,i=document.cookie.split(";");for(let t=0;t<i.length;t++){let s=i[t];for(;" "===s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(e))return s.substring(e.length,s.length)}return null},remove(t,e){this.create(t,"",-1,e)}};var rt={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&"undefined"!=typeof document)return ot.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:i,cookieMinutes:s,cookieDomain:n,cookieOptions:o}=e;i&&"undefined"!=typeof document&&ot.create(i,t,s,n,o)}},at={name:"querystring",lookup(t){let e,{lookupQuerystring:i}=t;if("undefined"!=typeof window){let{search:t}=window.location;!window.location.search&&window.location.hash?.indexOf("?")>-1&&(t=window.location.hash.substring(window.location.hash.indexOf("?")));const s=t.substring(1).split("&");for(let t=0;t<s.length;t++){const n=s[t].indexOf("=");n>0&&s[t].substring(0,n)===i&&(e=s[t].substring(n+1))}}return e}},ht={name:"hash",lookup(t){let e,{lookupHash:i,lookupFromHashIndex:s}=t;if("undefined"!=typeof window){const{hash:t}=window.location;if(t&&t.length>2){const n=t.substring(1);if(i){const t=n.split("&");for(let s=0;s<t.length;s++){const n=t[s].indexOf("=");n>0&&t[s].substring(0,n)===i&&(e=t[s].substring(n+1))}}if(e)return e;if(!e&&s>-1){const e=t.match(/\/([a-zA-Z-]*)/g);if(!Array.isArray(e))return;const i="number"==typeof s?s:0;return e[i]?.replace("/","")}}}return e}};let lt=null;const ct=()=>{if(null!==lt)return lt;try{if(lt="undefined"!=typeof window&&null!==window.localStorage,!lt)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch(t){lt=!1}return lt};var ut={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&ct())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:i}=e;i&&ct()&&window.localStorage.setItem(i,t)}};let dt=null;const ft=()=>{if(null!==dt)return dt;try{if(dt="undefined"!=typeof window&&null!==window.sessionStorage,!dt)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch(t){dt=!1}return dt};var pt={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&ft())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:i}=e;i&&ft()&&window.sessionStorage.setItem(i,t)}},gt={name:"navigator",lookup(t){const e=[];if("undefined"!=typeof navigator){const{languages:t,userLanguage:i,language:s}=navigator;if(t)for(let i=0;i<t.length;i++)e.push(t[i]);i&&e.push(i),s&&e.push(s)}return e.length>0?e:void 0}},yt={name:"htmlTag",lookup(t){let e,{htmlTag:i}=t;const s=i||("undefined"!=typeof document?document.documentElement:null);return s&&"function"==typeof s.getAttribute&&(e=s.getAttribute("lang")),e}},mt={name:"path",lookup(t){let{lookupFromPathIndex:e}=t;if("undefined"==typeof window)return;const i=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(!Array.isArray(i))return;const s="number"==typeof e?e:0;return i[s]?.replace("/","")}},vt={name:"subdomain",lookup(t){let{lookupFromSubdomainIndex:e}=t;const i="number"==typeof e?e+1:1,s="undefined"!=typeof window&&window.location?.hostname?.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(s)return s[i]}};let wt=!1;try{wt=!0}catch(t){}const bt=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];wt||bt.splice(1,1);class $t{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.type="languageDetector",this.detectors={},this.init(t,e)}init(){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.services=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{languageUtils:{}},this.options=function(t){return st.call(it.call(arguments,1),(e=>{if(e)for(const i in e)void 0===t[i]&&(t[i]=e[i])})),t}(t,this.options||{},{order:bt,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t}),"string"==typeof this.options.convertDetectedLanguage&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=t=>t.replace("-","_")),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=e,this.addDetector(rt),this.addDetector(at),this.addDetector(ut),this.addDetector(pt),this.addDetector(gt),this.addDetector(yt),this.addDetector(mt),this.addDetector(vt),this.addDetector(ht)}addDetector(t){return this.detectors[t.name]=t,this}detect(){let t=[];return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.options.order).forEach((e=>{if(this.detectors[e]){let i=this.detectors[e].lookup(this.options);i&&"string"==typeof i&&(i=[i]),i&&(t=t.concat(i))}})),t=t.filter((t=>{return null!=t&&!("string"==typeof(e=t)&&[/<\s*script.*?>/i,/<\s*\/\s*script\s*>/i,/<\s*img.*?on\w+\s*=/i,/<\s*\w+\s*on\w+\s*=.*?>/i,/javascript\s*:/i,/vbscript\s*:/i,/expression\s*\(/i,/eval\s*\(/i,/alert\s*\(/i,/document\.cookie/i,/document\.write\s*\(/i,/window\.location/i,/innerHTML/i].some((t=>t.test(e))));var e})).map((t=>this.options.convertDetectedLanguage(t))),this.services&&this.services.languageUtils&&this.services.languageUtils.getBestMatchFromCodes?t:t.length>0?t[0]:null}cacheUserLanguage(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.options.caches;e&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(t)>-1||e.forEach((e=>{this.detectors[e]&&this.detectors[e].cacheUserLanguage(t,this.options)})))}}$t.type="languageDetector",et.use($t).init({fallbackLng:"en",debug:!1,resources:{en:{translation:{}},ja:{translation:{Pay:"支払う","Failed to load Stripe":"ライブラリの読み込みに失敗しました。","Add your payment information":"支払情報を追加","Add card":"カードを追加","Add a card":"カードを追加",Add:"追加","Card information":"カード情報","Card Number":"カード番号","MM / YY":"月 / 年",CVC:"セキュリティコード(CVC)","Country or region":"地域","Postal Code":"郵便番号",Close:"閉じる",Loading:"読み込み中","Payment information":"支払情報","Billing address":"請求先住所",Save:"保存","Please complete your billing address.":"請求先住所を入力してください。","Please enter your email address.":"メールアドレスを入力してください。","Please enter a valid email address.":"有効なメールアドレスを入力してください。"}},"pt-BR":{translation:{Pay:"Pagar","Failed to load Stripe":"Falha ao ler Stripe","Add your payment information":"Informações do seu Pagamento","Add card":"Adicionar Cartão","Add a card":"Adicionar um Cartão",Add:"Adicionar","Card information":"Informações do Cartão","Card Number":"Número do Cartão","MM / YY":"MM / AA",CVC:"Número de Segurança(CVC)","Country or region":"País ou região","Postal Code":"Cep",Close:"Fechar","Please complete your billing address.":"Preencha seu endereço de cobrança.","Please enter your email address.":"Informe seu endereço de e-mail.","Please enter a valid email address.":"Informe um endereço de e-mail válido."}}}});const xt=et;export{c,xt as i}
1
+ const t=t=>Object.keys(l).filter((e=>l[e](t))),e=t=>!!a(t,/iPad/i)||!(!a(t,/Macintosh/i)||!s(t)),i=t=>a(t,/android|sink/i),s=t=>h(t,"(any-pointer:coarse)"),n=t=>o(t)||r(t),o=t=>!!(t.cordova||t.phonegap||t.PhoneGap),r=t=>{const e=t.Capacitor;return!(!e||!e.isNative)},a=(t,e)=>e.test(t.navigator.userAgent),h=(t,e)=>t.matchMedia(e).matches,l={ipad:e,iphone:t=>a(t,/iPhone/i),ios:t=>a(t,/iPhone|iPod/i)||e(t),android:i,phablet:t=>{const e=t.innerWidth,i=t.innerHeight,s=Math.min(e,i),n=Math.max(e,i);return s>390&&s<520&&n>620&&n<800},tablet:t=>{const s=t.innerWidth,n=t.innerHeight,o=Math.min(s,n),r=Math.max(s,n);return e(t)||(t=>i(t)&&!a(t,/mobile/i))(t)||o>460&&o<820&&r>780&&r<1400},cordova:o,capacitor:r,electron:t=>a(t,/electron/i),pwa:t=>!(!t.matchMedia("(display-mode: standalone)").matches&&!t.navigator.standalone),mobile:s,mobileweb:t=>s(t)&&!n(t),desktop:t=>!s(t),hybrid:n},c=()=>{const e=((e=window)=>{if(void 0===e)return[];e.Ionic=e.Ionic||{};let i=e.Ionic.platforms;return null==i&&(i=e.Ionic.platforms=t(e),i.forEach((t=>e.document.documentElement.classList.add(`plt-${t}`)))),i})(undefined);return e.includes("ios")?"ios":e.includes("android")?"android":void 0},u=t=>"string"==typeof t,d=()=>{let t,e;const i=new Promise(((i,s)=>{t=i,e=s}));return i.resolve=t,i.reject=e,i},f=t=>null==t?"":""+t,p=/###/g,g=t=>t&&t.indexOf("###")>-1?t.replace(p,"."):t,y=t=>!t||u(t),m=(t,e,i)=>{const s=u(e)?e.split("."):e;let n=0;for(;n<s.length-1;){if(y(t))return{};const e=g(s[n]);!t[e]&&i&&(t[e]=new i),t=Object.prototype.hasOwnProperty.call(t,e)?t[e]:{},++n}return y(t)?{}:{obj:t,k:g(s[n])}},v=(t,e,i)=>{const{obj:s,k:n}=m(t,e,Object);if(void 0!==s||1===e.length)return void(s[n]=i);let o=e[e.length-1],r=e.slice(0,e.length-1),a=m(t,r,Object);for(;void 0===a.obj&&r.length;)o=`${r[r.length-1]}.${o}`,r=r.slice(0,r.length-1),a=m(t,r,Object),a?.obj&&void 0!==a.obj[`${a.k}.${o}`]&&(a.obj=void 0);a.obj[`${a.k}.${o}`]=i},w=(t,e)=>{const{obj:i,k:s}=m(t,e);if(i&&Object.prototype.hasOwnProperty.call(i,s))return i[s]},b=(t,e,i)=>{for(const s in e)"__proto__"!==s&&"constructor"!==s&&(s in t?u(t[s])||t[s]instanceof String||u(e[s])||e[s]instanceof String?i&&(t[s]=e[s]):b(t[s],e[s],i):t[s]=e[s]);return t},$=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var x={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const k=t=>u(t)?t.replace(/[&<>"'\/]/g,(t=>x[t])):t,S=[" ",",","?","!",";"],j=new class{constructor(t){this.capacity=t,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(t){const e=this.regExpMap.get(t);if(void 0!==e)return e;const i=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,i),this.regExpQueue.push(t),i}}(20),O=(t,e,i=".")=>{if(!t)return;if(t[e]){if(!Object.prototype.hasOwnProperty.call(t,e))return;return t[e]}const s=e.split(i);let n=t;for(let t=0;t<s.length;){if(!n||"object"!=typeof n)return;let e,o="";for(let r=t;r<s.length;++r)if(r!==t&&(o+=i),o+=s[r],e=n[o],void 0!==e){if(["string","number","boolean"].indexOf(typeof e)>-1&&r<s.length-1)continue;t+=r-t+1;break}n=e}return n},P=t=>t?.replace(/_/g,"-"),L={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){console?.[t]?.apply?.(console,e)}};class N{constructor(t,e={}){this.init(t,e)}init(t,e={}){this.prefix=e.prefix||"i18next:",this.logger=t||L,this.options=e,this.debug=e.debug}log(...t){return this.forward(t,"log","",!0)}warn(...t){return this.forward(t,"warn","",!0)}error(...t){return this.forward(t,"error","")}deprecate(...t){return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}forward(t,e,i,s){return s&&!this.debug?null:(u(t[0])&&(t[0]=`${i}${this.prefix} ${t[0]}`),this.logger[e](t))}create(t){return new N(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return(t=t||this.options).prefix=t.prefix||this.prefix,new N(this.logger,t)}}var C=new N;class A{constructor(){this.observers={}}on(t,e){return t.split(" ").forEach((t=>{this.observers[t]||(this.observers[t]=new Map);const i=this.observers[t].get(e)||0;this.observers[t].set(e,i+1)})),this}off(t,e){this.observers[t]&&(e?this.observers[t].delete(e):delete this.observers[t])}emit(t,...e){this.observers[t]&&Array.from(this.observers[t].entries()).forEach((([t,i])=>{for(let s=0;s<i;s++)t(...e)})),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach((([i,s])=>{for(let n=0;n<s;n++)i.apply(i,[t,...e])}))}}class R extends A{constructor(t,e={ns:["translation"],defaultNS:"translation"}){super(),this.data=t||{},this.options=e,void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}removeNamespaces(t){const e=this.options.ns.indexOf(t);e>-1&&this.options.ns.splice(e,1)}getResource(t,e,i,s={}){const n=void 0!==s.keySeparator?s.keySeparator:this.options.keySeparator,o=void 0!==s.ignoreJSONStructure?s.ignoreJSONStructure:this.options.ignoreJSONStructure;let r;t.indexOf(".")>-1?r=t.split("."):(r=[t,e],i&&(Array.isArray(i)?r.push(...i):u(i)&&n?r.push(...i.split(n)):r.push(i)));const a=w(this.data,r);return!a&&!e&&!i&&t.indexOf(".")>-1&&(t=r[0],e=r[1],i=r.slice(2).join(".")),!a&&o&&u(i)?O(this.data?.[t]?.[e],i,n):a}addResource(t,e,i,s,n={silent:!1}){const o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator;let r=[t,e];i&&(r=r.concat(o?i.split(o):i)),t.indexOf(".")>-1&&(r=t.split("."),s=e,e=r[1]),this.addNamespaces(e),v(this.data,r,s),n.silent||this.emit("added",t,e,i,s)}addResources(t,e,i,s={silent:!1}){for(const s in i)(u(i[s])||Array.isArray(i[s]))&&this.addResource(t,e,s,i[s],{silent:!0});s.silent||this.emit("added",t,e,i)}addResourceBundle(t,e,i,s,n,o={silent:!1,skipCopy:!1}){let r=[t,e];t.indexOf(".")>-1&&(r=t.split("."),s=i,i=e,e=r[1]),this.addNamespaces(e);let a=w(this.data,r)||{};o.skipCopy||(i=JSON.parse(JSON.stringify(i))),s?b(a,i,n):a={...a,...i},v(this.data,r,a),o.silent||this.emit("added",t,e,i)}removeResourceBundle(t,e){this.hasResourceBundle(t,e)&&delete this.data[t][e],this.removeNamespaces(e),this.emit("removed",t,e)}hasResourceBundle(t,e){return void 0!==this.getResource(t,e)}getResourceBundle(t,e){return e||(e=this.options.defaultNS),this.getResource(t,e)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const e=this.getDataByLanguage(t);return!!(e&&Object.keys(e)||[]).find((t=>e[t]&&Object.keys(e[t]).length>0))}toJSON(){return this.data}}var I={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,i,s,n){return t.forEach((t=>{e=this.processors[t]?.process(e,i,s,n)??e})),e}};const E=Symbol("i18next/PATH_KEY");function T(t,e){const{[E]:i}=t(function(){const t=[],e=Object.create(null);let i;return e.get=(s,n)=>(i?.revoke?.(),n===E?t:(t.push(n),i=Proxy.revocable(s,e),i.proxy)),Proxy.revocable(Object.create(null),e).proxy}()),s=e?.keySeparator??".",n=e?.nsSeparator??":";if(i.length>1&&n){const t=e?.ns,o=Array.isArray(t)?t:null;if(o&&o.length>1&&o.slice(1).includes(i[0]))return`${i[0]}${n}${i.slice(1).join(s)}`}return i.join(s)}const M={},z=t=>!u(t)&&"boolean"!=typeof t&&"number"!=typeof t;class F extends A{constructor(t,e={}){var i,s;super(),i=t,s=this,["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"].forEach((t=>{i[t]&&(s[t]=i[t])})),this.options=e,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=C.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t,e={interpolation:{}}){const i={...e};if(null==t)return!1;const s=this.resolve(t,i);if(void 0===s?.res)return!1;const n=z(s.res);return!1!==i.returnObjects||!n}extractFromKey(t,e){let i=void 0!==e.nsSeparator?e.nsSeparator:this.options.nsSeparator;void 0===i&&(i=":");const s=void 0!==e.keySeparator?e.keySeparator:this.options.keySeparator;let n=e.ns||this.options.defaultNS||[];const o=i&&t.indexOf(i)>-1,r=!(this.options.userDefinedKeySeparator||e.keySeparator||this.options.userDefinedNsSeparator||e.nsSeparator||((t,e,i)=>{e=e||"",i=i||"";const s=S.filter((t=>e.indexOf(t)<0&&i.indexOf(t)<0));if(0===s.length)return!0;const n=j.getRegExp(`(${s.map((t=>"?"===t?"\\?":t)).join("|")})`);let o=!n.test(t);if(!o){const e=t.indexOf(i);e>0&&!n.test(t.substring(0,e))&&(o=!0)}return o})(t,i,s));if(o&&!r){const e=t.match(this.interpolator.nestingRegexp);if(e&&e.length>0)return{key:t,namespaces:u(n)?[n]:n};const o=t.split(i);(i!==s||i===s&&this.options.ns.indexOf(o[0])>-1)&&(n=o.shift()),t=o.join(s)}return{key:t,namespaces:u(n)?[n]:n}}translate(t,e,i){let s="object"==typeof e?{...e}:e;if("object"!=typeof s&&this.options.overloadTranslationOptionHandler&&(s=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof s&&(s={...s}),s||(s={}),null==t)return"";"function"==typeof t&&(t=T(t,{...this.options,...s})),Array.isArray(t)||(t=[String(t)]),t=t.map((t=>"function"==typeof t?T(t,{...this.options,...s}):String(t)));const n=void 0!==s.returnDetails?s.returnDetails:this.options.returnDetails,o=void 0!==s.keySeparator?s.keySeparator:this.options.keySeparator,{key:r,namespaces:a}=this.extractFromKey(t[t.length-1],s),h=a[a.length-1];let l=void 0!==s.nsSeparator?s.nsSeparator:this.options.nsSeparator;void 0===l&&(l=":");const c=s.lng||this.language,d=s.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if("cimode"===c?.toLowerCase())return d?n?{res:`${h}${l}${r}`,usedKey:r,exactUsedKey:r,usedLng:c,usedNS:h,usedParams:this.getUsedParamsDetails(s)}:`${h}${l}${r}`:n?{res:r,usedKey:r,exactUsedKey:r,usedLng:c,usedNS:h,usedParams:this.getUsedParamsDetails(s)}:r;const f=this.resolve(t,s);let p=f?.res;const g=f?.usedKey||r,y=f?.exactUsedKey||r,m=void 0!==s.joinArrays?s.joinArrays:this.options.joinArrays,v=!this.i18nFormat||this.i18nFormat.handleAsObject,w=void 0!==s.count&&!u(s.count),b=F.hasDefaultValue(s),$=w?this.pluralResolver.getSuffix(c,s.count,s):"",x=s.ordinal&&w?this.pluralResolver.getSuffix(c,s.count,{ordinal:!1}):"",k=w&&!s.ordinal&&0===s.count,S=k&&s[`defaultValue${this.options.pluralSeparator}zero`]||s[`defaultValue${$}`]||s[`defaultValue${x}`]||s.defaultValue;let j=p;v&&!p&&b&&(j=S);const O=z(j),P=Object.prototype.toString.apply(j);if(!(v&&j&&O&&["[object Number]","[object Function]","[object RegExp]"].indexOf(P)<0)||u(m)&&Array.isArray(j))if(v&&u(m)&&Array.isArray(p))p=p.join(m),p&&(p=this.extendTranslation(p,t,s,i));else{let e=!1,n=!1;!this.isValidLookup(p)&&b&&(e=!0,p=S),this.isValidLookup(p)||(n=!0,p=r);const a=(s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&n?void 0:p,u=b&&S!==p&&this.options.updateMissing;if(n||e||u){if(this.logger.log(u?"updateKey":"missingKey",c,h,r,u?S:p),o){const t=this.resolve(r,{...s,keySeparator:!1});t&&t.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let t=[];const e=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if("fallback"===this.options.saveMissingTo&&e&&e[0])for(let i=0;i<e.length;i++)t.push(e[i]);else"all"===this.options.saveMissingTo?t=this.languageUtils.toResolveHierarchy(s.lng||this.language):t.push(s.lng||this.language);const i=(t,e,i)=>{const n=b&&i!==p?i:a;this.options.missingKeyHandler?this.options.missingKeyHandler(t,h,e,n,u,s):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(t,h,e,n,u,s),this.emit("missingKey",t,h,e,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&w?t.forEach((t=>{const e=this.pluralResolver.getSuffixes(t,s);k&&s[`defaultValue${this.options.pluralSeparator}zero`]&&e.indexOf(`${this.options.pluralSeparator}zero`)<0&&e.push(`${this.options.pluralSeparator}zero`),e.forEach((e=>{i([t],r+e,s[`defaultValue${e}`]||S)}))})):i(t,r,S))}p=this.extendTranslation(p,t,s,f,i),n&&p===r&&this.options.appendNamespaceToMissingKey&&(p=`${h}${l}${r}`),(n||e)&&this.options.parseMissingKeyHandler&&(p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${h}${l}${r}`:r,e?p:void 0,s))}else{if(!s.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const t=this.options.returnedObjectHandler?this.options.returnedObjectHandler(g,j,{...s,ns:a}):`key '${r} (${this.language})' returned an object instead of string.`;return n?(f.res=t,f.usedParams=this.getUsedParamsDetails(s),f):t}if(o){const t=Array.isArray(j),e=t?[]:{},i=t?y:g;for(const t in j)if(Object.prototype.hasOwnProperty.call(j,t)){const n=`${i}${o}${t}`;e[t]=this.translate(n,b&&!p?{...s,defaultValue:z(S)?S[t]:void 0,joinArrays:!1,ns:a}:{...s,joinArrays:!1,ns:a}),e[t]===n&&(e[t]=j[t])}p=e}}return n?(f.res=p,f.usedParams=this.getUsedParamsDetails(s),f):p}extendTranslation(t,e,i,s,n){if(this.i18nFormat?.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...i},i.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!i.skipInterpolation){i.interpolation&&this.interpolator.init({...i,interpolation:{...this.options.interpolation,...i.interpolation}});const o=u(t)&&(void 0!==i?.interpolation?.skipOnVariables?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let r;if(o){const e=t.match(this.interpolator.nestingRegexp);r=e&&e.length}let a=i.replace&&!u(i.replace)?i.replace:i;if(this.options.interpolation.defaultVariables&&(a={...this.options.interpolation.defaultVariables,...a}),t=this.interpolator.interpolate(t,a,i.lng||this.language||s.usedLng,i),o){const e=t.match(this.interpolator.nestingRegexp);r<(e&&e.length)&&(i.nest=!1)}!i.lng&&s&&s.res&&(i.lng=this.language||s.usedLng),!1!==i.nest&&(t=this.interpolator.nest(t,((...t)=>n?.[0]!==t[0]||i.context?this.translate(...t,e):(this.logger.warn(`It seems you are nesting recursively key: ${t[0]} in key: ${e[0]}`),null)),i)),i.interpolation&&this.interpolator.reset()}const o=i.postProcess||this.options.postProcess,r=u(o)?[o]:o;return null!=t&&r?.length&&!1!==i.applyPostProcessor&&(t=I.handle(r,t,e,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...s,usedParams:this.getUsedParamsDetails(i)},...i}:i,this)),t}resolve(t,e={}){let i,s,n,o,r;return u(t)&&(t=[t]),Array.isArray(t)&&(t=t.map((t=>"function"==typeof t?T(t,{...this.options,...e}):t))),t.forEach((t=>{if(this.isValidLookup(i))return;const a=this.extractFromKey(t,e),h=a.key;s=h;let l=a.namespaces;this.options.fallbackNS&&(l=l.concat(this.options.fallbackNS));const c=void 0!==e.count&&!u(e.count),d=c&&!e.ordinal&&0===e.count,f=void 0!==e.context&&(u(e.context)||"number"==typeof e.context)&&""!==e.context,p=e.lngs?e.lngs:this.languageUtils.toResolveHierarchy(e.lng||this.language,e.fallbackLng);l.forEach((t=>{this.isValidLookup(i)||(r=t,M[`${p[0]}-${t}`]||!this.utils?.hasLoadedNamespace||this.utils?.hasLoadedNamespace(r)||(M[`${p[0]}-${t}`]=!0,this.logger.warn(`key "${s}" for languages "${p.join(", ")}" won't get resolved as namespace "${r}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),p.forEach((s=>{if(this.isValidLookup(i))return;o=s;const r=[h];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(r,h,s,t,e);else{let t;c&&(t=this.pluralResolver.getSuffix(s,e.count,e));const i=`${this.options.pluralSeparator}zero`,n=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(c&&(e.ordinal&&0===t.indexOf(n)&&r.push(h+t.replace(n,this.options.pluralSeparator)),r.push(h+t),d&&r.push(h+i)),f){const s=`${h}${this.options.contextSeparator||"_"}${e.context}`;r.push(s),c&&(e.ordinal&&0===t.indexOf(n)&&r.push(s+t.replace(n,this.options.pluralSeparator)),r.push(s+t),d&&r.push(s+i))}}let a;for(;a=r.pop();)this.isValidLookup(i)||(n=a,i=this.getResource(s,t,a,e))})))}))})),{res:i,usedKey:s,exactUsedKey:n,usedLng:o,usedNS:r}}isValidLookup(t){return!(void 0===t||!this.options.returnNull&&null===t||!this.options.returnEmptyString&&""===t)}getResource(t,e,i,s={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(t,e,i,s):this.resourceStore.getResource(t,e,i,s)}getUsedParamsDetails(t={}){const e=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],i=t.replace&&!u(t.replace);let s=i?t.replace:t;if(i&&void 0!==t.count&&(s.count=t.count),this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),!i){s={...s};for(const t of e)delete s[t]}return s}static hasDefaultValue(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)&&"defaultValue"===e.substring(0,12)&&void 0!==t[e])return!0;return!1}}class V{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=C.create("languageUtils")}getScriptPartFromCode(t){if(!(t=P(t))||t.indexOf("-")<0)return null;const e=t.split("-");return 2===e.length?null:(e.pop(),"x"===e[e.length-1].toLowerCase()?null:this.formatLanguageCode(e.join("-")))}getLanguagePartFromCode(t){if(!(t=P(t))||t.indexOf("-")<0)return t;const e=t.split("-");return this.formatLanguageCode(e[0])}formatLanguageCode(t){if(u(t)&&t.indexOf("-")>-1){let e;try{e=Intl.getCanonicalLocales(t)[0]}catch(t){}return e&&this.options.lowerCaseLng&&(e=e.toLowerCase()),e||(this.options.lowerCaseLng?t.toLowerCase():t)}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let e;return t.forEach((t=>{if(e)return;const i=this.formatLanguageCode(t);this.options.supportedLngs&&!this.isSupportedCode(i)||(e=i)})),!e&&this.options.supportedLngs&&t.forEach((t=>{if(e)return;const i=this.getScriptPartFromCode(t);if(this.isSupportedCode(i))return e=i;const s=this.getLanguagePartFromCode(t);if(this.isSupportedCode(s))return e=s;e=this.options.supportedLngs.find((t=>t===s?t:t.indexOf("-")<0&&s.indexOf("-")<0?void 0:t.indexOf("-")>0&&s.indexOf("-")<0&&t.substring(0,t.indexOf("-"))===s||0===t.indexOf(s)&&s.length>1?t:void 0))})),e||(e=this.getFallbackCodes(this.options.fallbackLng)[0]),e}getFallbackCodes(t,e){if(!t)return[];if("function"==typeof t&&(t=t(e)),u(t)&&(t=[t]),Array.isArray(t))return t;if(!e)return t.default||[];let i=t[e];return i||(i=t[this.getScriptPartFromCode(e)]),i||(i=t[this.formatLanguageCode(e)]),i||(i=t[this.getLanguagePartFromCode(e)]),i||(i=t.default),i||[]}toResolveHierarchy(t,e){const i=this.getFallbackCodes((!1===e?[]:e)||this.options.fallbackLng||[],t),s=[],n=t=>{t&&(this.isSupportedCode(t)?s.push(t):this.logger.warn(`rejecting language code not found in supportedLngs: ${t}`))};return u(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?("languageOnly"!==this.options.load&&n(this.formatLanguageCode(t)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&n(this.getScriptPartFromCode(t)),"currentOnly"!==this.options.load&&n(this.getLanguagePartFromCode(t))):u(t)&&n(this.formatLanguageCode(t)),i.forEach((t=>{s.indexOf(t)<0&&n(this.formatLanguageCode(t))})),s}}const D={zero:0,one:1,two:2,few:3,many:4,other:5},B={select:t=>1===t?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class K{constructor(t,e={}){this.languageUtils=t,this.options=e,this.logger=C.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(t,e={}){const i=P("dev"===t?"en":t),s=e.ordinal?"ordinal":"cardinal",n=JSON.stringify({cleanedCode:i,type:s});if(n in this.pluralRulesCache)return this.pluralRulesCache[n];let o;try{o=new Intl.PluralRules(i,{type:s})}catch(i){if("undefined"==typeof Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),B;if(!t.match(/-|_/))return B;const s=this.languageUtils.getLanguagePartFromCode(t);o=this.getRule(s,e)}return this.pluralRulesCache[n]=o,o}needsPlural(t,e={}){let i=this.getRule(t,e);return i||(i=this.getRule("dev",e)),i?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(t,e,i={}){return this.getSuffixes(t,i).map((t=>`${e}${t}`))}getSuffixes(t,e={}){let i=this.getRule(t,e);return i||(i=this.getRule("dev",e)),i?i.resolvedOptions().pluralCategories.sort(((t,e)=>D[t]-D[e])).map((t=>`${this.options.prepend}${e.ordinal?`ordinal${this.options.prepend}`:""}${t}`)):[]}getSuffix(t,e,i={}){const s=this.getRule(t,i);return s?`${this.options.prepend}${i.ordinal?`ordinal${this.options.prepend}`:""}${s.select(e)}`:(this.logger.warn(`no plural rule found for: ${t}`),this.getSuffix("dev",e,i))}}const _=(t,e,i,s=".",n=!0)=>{let o=((t,e,i)=>{const s=w(t,i);return void 0!==s?s:w(e,i)})(t,e,i);return!o&&n&&u(i)&&(o=O(t,i,s),void 0===o&&(o=O(e,i,s))),o},U=t=>t.replace(/\$/g,"$$$$");class H{constructor(t={}){this.logger=C.create("interpolator"),this.options=t,this.format=t?.interpolation?.format||(t=>t),this.init(t)}init(t={}){t.interpolation||(t.interpolation={escapeValue:!0});const{escape:e,escapeValue:i,useRawValueToEscape:s,prefix:n,prefixEscaped:o,suffix:r,suffixEscaped:a,formatSeparator:h,unescapeSuffix:l,unescapePrefix:c,nestingPrefix:u,nestingPrefixEscaped:d,nestingSuffix:f,nestingSuffixEscaped:p,nestingOptionsSeparator:g,maxReplaces:y,alwaysFormat:m}=t.interpolation;this.escape=void 0!==e?e:k,this.escapeValue=void 0===i||i,this.useRawValueToEscape=void 0!==s&&s,this.prefix=n?$(n):o||"{{",this.suffix=r?$(r):a||"}}",this.formatSeparator=h||",",this.unescapePrefix=l?"":c||"-",this.unescapeSuffix=this.unescapePrefix?"":l||"",this.nestingPrefix=u?$(u):d||$("$t("),this.nestingSuffix=f?$(f):p||$(")"),this.nestingOptionsSeparator=g||",",this.maxReplaces=y||1e3,this.alwaysFormat=void 0!==m&&m,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(t,e)=>t?.source===e?(t.lastIndex=0,t):new RegExp(e,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(t,e,i,s){let n,o,r;const a=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},h=t=>{if(t.indexOf(this.formatSeparator)<0){const n=_(e,a,t,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(n,void 0,i,{...s,...e,interpolationkey:t}):n}const n=t.split(this.formatSeparator),o=n.shift().trim(),r=n.join(this.formatSeparator).trim();return this.format(_(e,a,o,this.options.keySeparator,this.options.ignoreJSONStructure),r,i,{...s,...e,interpolationkey:o})};this.resetRegExp();const l=s?.missingInterpolationHandler||this.options.missingInterpolationHandler,c=void 0!==s?.interpolation?.skipOnVariables?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:t=>U(t)},{regex:this.regexp,safeValue:t=>U(this.escapeValue?this.escape(t):t)}].forEach((e=>{for(r=0;n=e.regex.exec(t);){const i=n[1].trim();if(o=h(i),void 0===o)if("function"==typeof l){const e=l(t,n,s);o=u(e)?e:""}else if(s&&Object.prototype.hasOwnProperty.call(s,i))o="";else{if(c){o=n[0];continue}this.logger.warn(`missed to pass in variable ${i} for interpolating ${t}`),o=""}else u(o)||this.useRawValueToEscape||(o=f(o));const a=e.safeValue(o);if(t=t.replace(n[0],a),c?(e.regex.lastIndex+=o.length,e.regex.lastIndex-=n[0].length):e.regex.lastIndex=0,r++,r>=this.maxReplaces)break}})),t}nest(t,e,i={}){let s,n,o;const r=(t,e)=>{const i=this.nestingOptionsSeparator;if(t.indexOf(i)<0)return t;const s=t.split(new RegExp(`${$(i)}[ ]*{`));let n=`{${s[1]}`;t=s[0],n=this.interpolate(n,o);const r=n.match(/'/g),a=n.match(/"/g);((r?.length??0)%2==0&&!a||(a?.length??0)%2!=0)&&(n=n.replace(/'/g,'"'));try{o=JSON.parse(n),e&&(o={...e,...o})}catch(e){return this.logger.warn(`failed parsing options string in nesting for key ${t}`,e),`${t}${i}${n}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,t};for(;s=this.nestingRegexp.exec(t);){let a=[];o={...i},o=o.replace&&!u(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;const h=/{.*}/.test(s[1])?s[1].lastIndexOf("}")+1:s[1].indexOf(this.formatSeparator);if(-1!==h&&(a=s[1].slice(h).split(this.formatSeparator).map((t=>t.trim())).filter(Boolean),s[1]=s[1].slice(0,h)),n=e(r.call(this,s[1].trim(),o),o),n&&s[0]===t&&!u(n))return n;u(n)||(n=f(n)),n||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),n=""),a.length&&(n=a.reduce(((t,e)=>this.format(t,e,i.lng,{...i,interpolationkey:s[1].trim()})),n.trim())),t=t.replace(s[0],n),this.regexp.lastIndex=0}return t}}const Y=t=>{const e={};return(i,s,n)=>{let o=n;n&&n.interpolationkey&&n.formatParams&&n.formatParams[n.interpolationkey]&&n[n.interpolationkey]&&(o={...o,[n.interpolationkey]:void 0});const r=s+JSON.stringify(o);let a=e[r];return a||(a=t(P(s),n),e[r]=a),a(i)}},J=t=>(e,i,s)=>t(P(i),s)(e);class q{constructor(t={}){this.logger=C.create("formatter"),this.options=t,this.init(t)}init(t,e={interpolation:{}}){this.formatSeparator=e.interpolation.formatSeparator||",";const i=e.cacheInBuiltFormats?Y:J;this.formats={number:i(((t,e)=>{const i=new Intl.NumberFormat(t,{...e});return t=>i.format(t)})),currency:i(((t,e)=>{const i=new Intl.NumberFormat(t,{...e,style:"currency"});return t=>i.format(t)})),datetime:i(((t,e)=>{const i=new Intl.DateTimeFormat(t,{...e});return t=>i.format(t)})),relativetime:i(((t,e)=>{const i=new Intl.RelativeTimeFormat(t,{...e});return t=>i.format(t,e.range||"day")})),list:i(((t,e)=>{const i=new Intl.ListFormat(t,{...e});return t=>i.format(t)}))}}add(t,e){this.formats[t.toLowerCase().trim()]=e}addCached(t,e){this.formats[t.toLowerCase().trim()]=Y(e)}format(t,e,i,s={}){const n=e.split(this.formatSeparator);if(n.length>1&&n[0].indexOf("(")>1&&n[0].indexOf(")")<0&&n.find((t=>t.indexOf(")")>-1))){const t=n.findIndex((t=>t.indexOf(")")>-1));n[0]=[n[0],...n.splice(1,t)].join(this.formatSeparator)}return n.reduce(((t,e)=>{const{formatName:n,formatOptions:o}=(t=>{let e=t.toLowerCase().trim();const i={};if(t.indexOf("(")>-1){const s=t.split("(");e=s[0].toLowerCase().trim();const n=s[1].substring(0,s[1].length-1);"currency"===e&&n.indexOf(":")<0?i.currency||(i.currency=n.trim()):"relativetime"===e&&n.indexOf(":")<0?i.range||(i.range=n.trim()):n.split(";").forEach((t=>{if(t){const[e,...s]=t.split(":"),n=s.join(":").trim().replace(/^'+|'+$/g,""),o=e.trim();i[o]||(i[o]=n),"false"===n&&(i[o]=!1),"true"===n&&(i[o]=!0),isNaN(n)||(i[o]=parseInt(n,10))}}))}return{formatName:e,formatOptions:i}})(e);if(this.formats[n]){let e=t;try{const r=s?.formatParams?.[s.interpolationkey]||{};e=this.formats[n](t,r.locale||r.lng||s.locale||s.lng||i,{...o,...s,...r})}catch(t){this.logger.warn(t)}return e}return this.logger.warn(`there was no format function for ${n}`),t}),t)}}class W extends A{constructor(t,e,i,s={}){super(),this.backend=t,this.store=e,this.services=i,this.languageUtils=i.languageUtils,this.options=s,this.logger=C.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=s.maxParallelReads||10,this.readingCalls=0,this.maxRetries=s.maxRetries>=0?s.maxRetries:5,this.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(i,s.backend,s)}queueLoad(t,e,i,s){const n={},o={},r={},a={};return t.forEach((t=>{let s=!0;e.forEach((e=>{const r=`${t}|${e}`;!i.reload&&this.store.hasResourceBundle(t,e)?this.state[r]=2:this.state[r]<0||(1===this.state[r]?void 0===o[r]&&(o[r]=!0):(this.state[r]=1,s=!1,void 0===o[r]&&(o[r]=!0),void 0===n[r]&&(n[r]=!0),void 0===a[e]&&(a[e]=!0)))})),s||(r[t]=!0)})),(Object.keys(n).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(n),pending:Object.keys(o),toLoadLanguages:Object.keys(r),toLoadNamespaces:Object.keys(a)}}loaded(t,e,i){const s=t.split("|"),n=s[0],o=s[1];e&&this.emit("failedLoading",n,o,e),!e&&i&&this.store.addResourceBundle(n,o,i,void 0,void 0,{skipCopy:!0}),this.state[t]=e?-1:2,e&&i&&(this.state[t]=0);const r={};this.queue.forEach((i=>{((t,e,i)=>{const{obj:s,k:n}=m(t,e,Object);s[n]=s[n]||[],s[n].push(i)})(i.loaded,[n],o),((t,e)=>{void 0!==t.pending[e]&&(delete t.pending[e],t.pendingCount--)})(i,t),e&&i.errors.push(e),0!==i.pendingCount||i.done||(Object.keys(i.loaded).forEach((t=>{r[t]||(r[t]={});const e=i.loaded[t];e.length&&e.forEach((e=>{void 0===r[t][e]&&(r[t][e]=!0)}))})),i.done=!0,i.errors.length?i.callback(i.errors):i.callback())})),this.emit("loaded",r),this.queue=this.queue.filter((t=>!t.done))}read(t,e,i,s=0,n=this.retryTimeout,o){if(!t.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:t,ns:e,fcName:i,tried:s,wait:n,callback:o});this.readingCalls++;const r=(r,a)=>{if(this.readingCalls--,this.waitingReads.length>0){const t=this.waitingReads.shift();this.read(t.lng,t.ns,t.fcName,t.tried,t.wait,t.callback)}r&&a&&s<this.maxRetries?setTimeout((()=>{this.read.call(this,t,e,i,s+1,2*n,o)}),n):o(r,a)},a=this.backend[i].bind(this.backend);if(2!==a.length)return a(t,e,r);try{const i=a(t,e);i&&"function"==typeof i.then?i.then((t=>r(null,t))).catch(r):r(null,i)}catch(t){r(t)}}prepareLoading(t,e,i={},s){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();u(t)&&(t=this.languageUtils.toResolveHierarchy(t)),u(e)&&(e=[e]);const n=this.queueLoad(t,e,i,s);if(!n.toLoad.length)return n.pending.length||s(),null;n.toLoad.forEach((t=>{this.loadOne(t)}))}load(t,e,i){this.prepareLoading(t,e,{},i)}reload(t,e,i){this.prepareLoading(t,e,{reload:!0},i)}loadOne(t,e=""){const i=t.split("|"),s=i[0],n=i[1];this.read(s,n,"read",void 0,void 0,((i,o)=>{i&&this.logger.warn(`${e}loading namespace ${n} for language ${s} failed`,i),!i&&o&&this.logger.log(`${e}loaded namespace ${n} for language ${s}`,o),this.loaded(t,i,o)}))}saveMissing(t,e,i,s,n,o={},r=()=>{}){if(!this.services?.utils?.hasLoadedNamespace||this.services?.utils?.hasLoadedNamespace(e)){if(null!=i&&""!==i){if(this.backend?.create){const a={...o,isUpdate:n},h=this.backend.create.bind(this.backend);if(h.length<6)try{let n;n=5===h.length?h(t,e,i,s,a):h(t,e,i,s),n&&"function"==typeof n.then?n.then((t=>r(null,t))).catch(r):r(null,n)}catch(t){r(t)}else h(t,e,i,s,r,a)}t&&t[0]&&this.store.addResource(t[0],e,i,s)}}else this.logger.warn(`did not save key "${i}" as the namespace "${e}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")}}const G=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if("object"==typeof t[1]&&(e=t[1]),u(t[1])&&(e.defaultValue=t[1]),u(t[2])&&(e.tDescription=t[2]),"object"==typeof t[2]||"object"==typeof t[3]){const i=t[3]||t[2];Object.keys(i).forEach((t=>{e[t]=i[t]}))}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),Q=t=>(u(t.ns)&&(t.ns=[t.ns]),u(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),u(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs?.indexOf?.("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),"boolean"==typeof t.initImmediate&&(t.initAsync=t.initImmediate),t),Z=()=>{},X="__i18next_supportNoticeShown";class tt extends A{constructor(t={},e){var i;if(super(),this.options=Q(t),this.services={},this.logger=C,this.modules={external:[]},i=this,Object.getOwnPropertyNames(Object.getPrototypeOf(i)).forEach((t=>{"function"==typeof i[t]&&(i[t]=i[t].bind(i))})),e&&!this.isInitialized&&!t.isClone){if(!this.options.initAsync)return this.init(t,e),this;setTimeout((()=>{this.init(t,e)}),0)}}init(t={},e){this.isInitializing=!0,"function"==typeof t&&(e=t,t={}),null==t.defaultNS&&t.ns&&(u(t.ns)?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));const i=G();var s;this.options={...i,...this.options,...Q(t)},this.options.interpolation={...i.interpolation,...this.options.interpolation},void 0!==t.keySeparator&&(this.options.userDefinedKeySeparator=t.keySeparator),void 0!==t.nsSeparator&&(this.options.userDefinedNsSeparator=t.nsSeparator),"function"!=typeof this.options.overloadTranslationOptionHandler&&(this.options.overloadTranslationOptionHandler=i.overloadTranslationOptionHandler),!1===this.options.showSupportNotice||(s=this,s?.modules?.backend?.name?.indexOf("Locize")>0||s?.modules?.backend?.constructor?.name?.indexOf("Locize")>0||s?.options?.backend?.backends&&s.options.backend.backends.some((t=>t?.name?.indexOf("Locize")>0||t?.constructor?.name?.indexOf("Locize")>0))||s?.options?.backend?.projectId||s?.options?.backend?.backendOptions&&s.options.backend.backendOptions.some((t=>t?.projectId)))||"undefined"!=typeof globalThis&&globalThis[X]||"undefined"!=typeof process&&process.env&&process.env.I18NEXT_NO_SUPPORT_NOTICE||"undefined"!=typeof process&&process.env||("undefined"!=typeof console&&void 0!==console.info&&console.info("🌐 i18next is made possible by our own product, Locize — consider powering your project with managed localization (AI, CDN, integrations): https://locize.com 💙"),"undefined"!=typeof globalThis&&(globalThis[X]=!0));const n=t=>t?"function"==typeof t?new t:t:null;if(!this.options.isClone){let t;C.init(this.modules.logger?n(this.modules.logger):null,this.options),t=this.modules.formatter?this.modules.formatter:q;const e=new V(this.options);this.store=new R(this.options.resources,this.options);const s=this.services;s.logger=C,s.resourceStore=this.store,s.languageUtils=e,s.pluralResolver=new K(e,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==i.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),!t||this.options.interpolation.format&&this.options.interpolation.format!==i.interpolation.format||(s.formatter=n(t),s.formatter.init&&s.formatter.init(s,this.options),this.options.interpolation.format=s.formatter.format.bind(s.formatter)),s.interpolator=new H(this.options),s.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},s.backendConnector=new W(n(this.modules.backend),s.resourceStore,s,this.options),s.backendConnector.on("*",((t,...e)=>{this.emit(t,...e)})),this.modules.languageDetector&&(s.languageDetector=n(this.modules.languageDetector),s.languageDetector.init&&s.languageDetector.init(s,this.options.detection,this.options)),this.modules.i18nFormat&&(s.i18nFormat=n(this.modules.i18nFormat),s.i18nFormat.init&&s.i18nFormat.init(this)),this.translator=new F(this.services,this.options),this.translator.on("*",((t,...e)=>{this.emit(t,...e)})),this.modules.external.forEach((t=>{t.init&&t.init(this)}))}if(this.format=this.options.interpolation.format,e||(e=Z),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const t=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);t.length>0&&"dev"!==t[0]&&(this.options.lng=t[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach((t=>{this[t]=(...e)=>this.store[t](...e)})),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach((t=>{this[t]=(...e)=>(this.store[t](...e),this)}));const o=d(),r=()=>{const t=(t,i)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),o.resolve(i),e(t,i)};if(this.languages&&!this.isInitialized)return t(null,this.t.bind(this));this.changeLanguage(this.options.lng,t)};return this.options.resources||!this.options.initAsync?r():setTimeout(r,0),o}loadResources(t,e=Z){let i=e;const s=u(t)?t:this.language;if("function"==typeof t&&(i=t),!this.options.resources||this.options.partialBundledLanguages){if("cimode"===s?.toLowerCase()&&(!this.options.preload||0===this.options.preload.length))return i();const t=[],e=e=>{e&&"cimode"!==e&&this.services.languageUtils.toResolveHierarchy(e).forEach((e=>{"cimode"!==e&&t.indexOf(e)<0&&t.push(e)}))};s?e(s):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((t=>e(t))),this.options.preload?.forEach?.((t=>e(t))),this.services.backendConnector.load(t,this.options.ns,(t=>{t||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),i(t)}))}else i(null)}reloadResources(t,e,i){const s=d();return"function"==typeof t&&(i=t,t=void 0),"function"==typeof e&&(i=e,e=void 0),t||(t=this.languages),e||(e=this.options.ns),i||(i=Z),this.services.backendConnector.reload(t,e,(t=>{s.resolve(),i(t)})),s}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===t.type&&(this.modules.backend=t),("logger"===t.type||t.log&&t.warn&&t.error)&&(this.modules.logger=t),"languageDetector"===t.type&&(this.modules.languageDetector=t),"i18nFormat"===t.type&&(this.modules.i18nFormat=t),"postProcessor"===t.type&&I.addPostProcessor(t),"formatter"===t.type&&(this.modules.formatter=t),"3rdParty"===t.type&&this.modules.external.push(t),this}setResolvedLanguage(t){if(t&&this.languages&&!(["cimode","dev"].indexOf(t)>-1)){for(let t=0;t<this.languages.length;t++){const e=this.languages[t];if(!(["cimode","dev"].indexOf(e)>-1)&&this.store.hasLanguageSomeTranslations(e)){this.resolvedLanguage=e;break}}!this.resolvedLanguage&&this.languages.indexOf(t)<0&&this.store.hasLanguageSomeTranslations(t)&&(this.resolvedLanguage=t,this.languages.unshift(t))}}changeLanguage(t,e){this.isLanguageChangingTo=t;const i=d();this.emit("languageChanging",t);const s=t=>{this.language=t,this.languages=this.services.languageUtils.toResolveHierarchy(t),this.resolvedLanguage=void 0,this.setResolvedLanguage(t)},n=(n,o)=>{o?this.isLanguageChangingTo===t&&(s(o),this.translator.changeLanguage(o),this.isLanguageChangingTo=void 0,this.emit("languageChanged",o),this.logger.log("languageChanged",o)):this.isLanguageChangingTo=void 0,i.resolve(((...t)=>this.t(...t))),e&&e(n,((...t)=>this.t(...t)))},o=e=>{t||e||!this.services.languageDetector||(e=[]);const i=u(e)?e:e&&e[0],o=this.store.hasLanguageSomeTranslations(i)?i:this.services.languageUtils.getBestMatchFromCodes(u(e)?[e]:e);o&&(this.language||s(o),this.translator.language||this.translator.changeLanguage(o),this.services.languageDetector?.cacheUserLanguage?.(o)),this.loadResources(o,(t=>{n(t,o)}))};return t||!this.services.languageDetector||this.services.languageDetector.async?!t&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(t):o(this.services.languageDetector.detect()),i}getFixedT(t,e,i){const s=(t,e,...n)=>{let o;o="object"!=typeof e?this.options.overloadTranslationOptionHandler([t,e].concat(n)):{...e},o.lng=o.lng||s.lng,o.lngs=o.lngs||s.lngs,o.ns=o.ns||s.ns,""!==o.keyPrefix&&(o.keyPrefix=o.keyPrefix||i||s.keyPrefix);const r={...this.options,...o};"function"==typeof o.keyPrefix&&(o.keyPrefix=T(o.keyPrefix,r));const a=this.options.keySeparator||".";let h;return o.keyPrefix&&Array.isArray(t)?h=t.map((t=>("function"==typeof t&&(t=T(t,r)),`${o.keyPrefix}${a}${t}`))):("function"==typeof t&&(t=T(t,r)),h=o.keyPrefix?`${o.keyPrefix}${a}${t}`:t),this.t(h,o)};return u(t)?s.lng=t:s.lngs=t,s.ns=e,s.keyPrefix=i,s}t(...t){return this.translator?.translate(...t)}exists(...t){return this.translator?.exists(...t)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t,e={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const i=e.lng||this.resolvedLanguage||this.languages[0],s=!!this.options&&this.options.fallbackLng,n=this.languages[this.languages.length-1];if("cimode"===i.toLowerCase())return!0;const o=(t,e)=>{const i=this.services.backendConnector.state[`${t}|${e}`];return-1===i||0===i||2===i};if(e.precheck){const t=e.precheck(this,o);if(void 0!==t)return t}return!(!this.hasResourceBundle(i,t)&&this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages)&&(!o(i,t)||s&&!o(n,t)))}loadNamespaces(t,e){const i=d();return this.options.ns?(u(t)&&(t=[t]),t.forEach((t=>{this.options.ns.indexOf(t)<0&&this.options.ns.push(t)})),this.loadResources((t=>{i.resolve(),e&&e(t)})),i):(e&&e(),Promise.resolve())}loadLanguages(t,e){const i=d();u(t)&&(t=[t]);const s=this.options.preload||[],n=t.filter((t=>s.indexOf(t)<0&&this.services.languageUtils.isSupportedCode(t)));return n.length?(this.options.preload=s.concat(n),this.loadResources((t=>{i.resolve(),e&&e(t)})),i):(e&&e(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!t)return"rtl";try{const e=new Intl.Locale(t);if(e&&e.getTextInfo){const t=e.getTextInfo();if(t&&t.direction)return t.direction}}catch(t){}const e=this.services?.languageUtils||new V(G());return t.toLowerCase().indexOf("-latn")>1?"ltr":["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(e.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(t={},e){const i=new tt(t,e);return i.createInstance=tt.createInstance,i}cloneInstance(t={},e=Z){const i=t.forkResourceStore;i&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},n=new tt(s);if(void 0===t.debug&&void 0===t.prefix||(n.logger=n.logger.clone(t)),["store","services","language"].forEach((t=>{n[t]=this[t]})),n.services={...this.services},n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},i){const t=Object.keys(this.store.data).reduce(((t,e)=>(t[e]={...this.store.data[e]},t[e]=Object.keys(t[e]).reduce(((i,s)=>(i[s]={...t[e][s]},i)),t[e]),t)),{});n.store=new R(t,s),n.services.resourceStore=n.store}if(t.interpolation){const e={...G().interpolation,...this.options.interpolation,...t.interpolation},i={...s,interpolation:e};n.services.interpolator=new H(i)}return n.translator=new F(n.services,s),n.translator.on("*",((t,...e)=>{n.emit(t,...e)})),n.init(s,e),n.translator.options=s,n.translator.backendConnector.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},n}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const et=tt.createInstance(),{slice:it,forEach:st}=[],nt=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,ot={create(t,e,i,s){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{path:"/",sameSite:"strict"};i&&(n.expires=new Date,n.expires.setTime(n.expires.getTime()+60*i*1e3)),s&&(n.domain=s),document.cookie=function(t,e){const i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{path:"/"};let s=`${t}=${encodeURIComponent(e)}`;if(i.maxAge>0){const t=i.maxAge-0;if(Number.isNaN(t))throw new Error("maxAge should be a Number");s+=`; Max-Age=${Math.floor(t)}`}if(i.domain){if(!nt.test(i.domain))throw new TypeError("option domain is invalid");s+=`; Domain=${i.domain}`}if(i.path){if(!nt.test(i.path))throw new TypeError("option path is invalid");s+=`; Path=${i.path}`}if(i.expires){if("function"!=typeof i.expires.toUTCString)throw new TypeError("option expires is invalid");s+=`; Expires=${i.expires.toUTCString()}`}if(i.httpOnly&&(s+="; HttpOnly"),i.secure&&(s+="; Secure"),i.sameSite)switch("string"==typeof i.sameSite?i.sameSite.toLowerCase():i.sameSite){case!0:s+="; SameSite=Strict";break;case"lax":s+="; SameSite=Lax";break;case"strict":s+="; SameSite=Strict";break;case"none":s+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return i.partitioned&&(s+="; Partitioned"),s}(t,e,n)},read(t){const e=`${t}=`,i=document.cookie.split(";");for(let t=0;t<i.length;t++){let s=i[t];for(;" "===s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(e))return s.substring(e.length,s.length)}return null},remove(t,e){this.create(t,"",-1,e)}};var rt={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&"undefined"!=typeof document)return ot.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:i,cookieMinutes:s,cookieDomain:n,cookieOptions:o}=e;i&&"undefined"!=typeof document&&ot.create(i,t,s,n,o)}},at={name:"querystring",lookup(t){let e,{lookupQuerystring:i}=t;if("undefined"!=typeof window){let{search:t}=window.location;!window.location.search&&window.location.hash?.indexOf("?")>-1&&(t=window.location.hash.substring(window.location.hash.indexOf("?")));const s=t.substring(1).split("&");for(let t=0;t<s.length;t++){const n=s[t].indexOf("=");n>0&&s[t].substring(0,n)===i&&(e=s[t].substring(n+1))}}return e}},ht={name:"hash",lookup(t){let e,{lookupHash:i,lookupFromHashIndex:s}=t;if("undefined"!=typeof window){const{hash:t}=window.location;if(t&&t.length>2){const n=t.substring(1);if(i){const t=n.split("&");for(let s=0;s<t.length;s++){const n=t[s].indexOf("=");n>0&&t[s].substring(0,n)===i&&(e=t[s].substring(n+1))}}if(e)return e;if(!e&&s>-1){const e=t.match(/\/([a-zA-Z-]*)/g);if(!Array.isArray(e))return;const i="number"==typeof s?s:0;return e[i]?.replace("/","")}}}return e}};let lt=null;const ct=()=>{if(null!==lt)return lt;try{if(lt="undefined"!=typeof window&&null!==window.localStorage,!lt)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch(t){lt=!1}return lt};var ut={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&ct())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:i}=e;i&&ct()&&window.localStorage.setItem(i,t)}};let dt=null;const ft=()=>{if(null!==dt)return dt;try{if(dt="undefined"!=typeof window&&null!==window.sessionStorage,!dt)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch(t){dt=!1}return dt};var pt={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&ft())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:i}=e;i&&ft()&&window.sessionStorage.setItem(i,t)}},gt={name:"navigator",lookup(t){const e=[];if("undefined"!=typeof navigator){const{languages:t,userLanguage:i,language:s}=navigator;if(t)for(let i=0;i<t.length;i++)e.push(t[i]);i&&e.push(i),s&&e.push(s)}return e.length>0?e:void 0}},yt={name:"htmlTag",lookup(t){let e,{htmlTag:i}=t;const s=i||("undefined"!=typeof document?document.documentElement:null);return s&&"function"==typeof s.getAttribute&&(e=s.getAttribute("lang")),e}},mt={name:"path",lookup(t){let{lookupFromPathIndex:e}=t;if("undefined"==typeof window)return;const i=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(!Array.isArray(i))return;const s="number"==typeof e?e:0;return i[s]?.replace("/","")}},vt={name:"subdomain",lookup(t){let{lookupFromSubdomainIndex:e}=t;const i="number"==typeof e?e+1:1,s="undefined"!=typeof window&&window.location?.hostname?.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(s)return s[i]}};let wt=!1;try{wt=!0}catch(t){}const bt=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];wt||bt.splice(1,1);class $t{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.type="languageDetector",this.detectors={},this.init(t,e)}init(){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.services=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{languageUtils:{}},this.options=function(t){return st.call(it.call(arguments,1),(e=>{if(e)for(const i in e)void 0===t[i]&&(t[i]=e[i])})),t}(t,this.options||{},{order:bt,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t}),"string"==typeof this.options.convertDetectedLanguage&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=t=>t.replace("-","_")),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=e,this.addDetector(rt),this.addDetector(at),this.addDetector(ut),this.addDetector(pt),this.addDetector(gt),this.addDetector(yt),this.addDetector(mt),this.addDetector(vt),this.addDetector(ht)}addDetector(t){return this.detectors[t.name]=t,this}detect(){let t=[];return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.options.order).forEach((e=>{if(this.detectors[e]){let i=this.detectors[e].lookup(this.options);i&&"string"==typeof i&&(i=[i]),i&&(t=t.concat(i))}})),t=t.filter((t=>{return null!=t&&!("string"==typeof(e=t)&&[/<\s*script.*?>/i,/<\s*\/\s*script\s*>/i,/<\s*img.*?on\w+\s*=/i,/<\s*\w+\s*on\w+\s*=.*?>/i,/javascript\s*:/i,/vbscript\s*:/i,/expression\s*\(/i,/eval\s*\(/i,/alert\s*\(/i,/document\.cookie/i,/document\.write\s*\(/i,/window\.location/i,/innerHTML/i].some((t=>t.test(e))));var e})).map((t=>this.options.convertDetectedLanguage(t))),this.services&&this.services.languageUtils&&this.services.languageUtils.getBestMatchFromCodes?t:t.length>0?t[0]:null}cacheUserLanguage(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.options.caches;e&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(t)>-1||e.forEach((e=>{this.detectors[e]&&this.detectors[e].cacheUserLanguage(t,this.options)})))}}$t.type="languageDetector",et.use($t).init({fallbackLng:"en",debug:!1,showSupportNotice:!1,resources:{en:{translation:{}},ja:{translation:{Pay:"支払う","Failed to load Stripe":"ライブラリの読み込みに失敗しました。","Add your payment information":"支払情報を追加","Add card":"カードを追加","Add a card":"カードを追加",Add:"追加","Card information":"カード情報","Card Number":"カード番号","MM / YY":"月 / 年",CVC:"セキュリティコード(CVC)","Postal Code":"郵便番号",Close:"閉じる",Loading:"読み込み中","Payment information":"支払情報","Billing address":"請求先住所",Save:"保存","Please complete your billing address.":"請求先住所を入力してください。","Please enter your email address.":"メールアドレスを入力してください。","Please enter a valid email address.":"有効なメールアドレスを入力してください。"}},"pt-BR":{translation:{Pay:"Pagar","Failed to load Stripe":"Falha ao ler Stripe","Add your payment information":"Informações do seu Pagamento","Add card":"Adicionar Cartão","Add a card":"Adicionar um Cartão",Add:"Adicionar","Card information":"Informações do Cartão","Card Number":"Número do Cartão","MM / YY":"MM / AA",CVC:"Número de Segurança(CVC)","Postal Code":"Cep",Close:"Fechar","Please complete your billing address.":"Preencha seu endereço de cobrança.","Please enter your email address.":"Informe seu endereço de e-mail.","Please enter a valid email address.":"Informe um endereço de e-mail válido."}}}});const xt=et;export{c,xt as i}
@@ -1 +1 @@
1
- import{transformTag as t,proxyCustomElement as e,HTMLElement as i,createEvent as s,h as n}from"@stencil/core/internal/client";import{c as r,i as o}from"./i18n.js";import{s as l}from"./factory.js";import{S as a}from"./error.js";import{d as p}from"./stripe-payment-request-button2.js";const u=t=>{if(null!=t&&""!==t)return{stripeAccount:t}},c=e(class extends i{async initStripe(t,e){if(await this.stripeService.initialize(t,{stripeAccount:null==e?void 0:e.stripeAccount,applicationName:this.applicationName}),"success"===this.stripeService.state.loadStripeStatus)await this.initElement(),this.stripeLoadedEventHandler();else{const t=this.stripeService.onChange("loadStripeStatus",(async e=>{"success"===e&&(await this.initElement(),this.stripeLoadedEventHandler(),t())}))}}async updateProgress(t){return this.progress=t,this}async setErrorMessage(t){return this.cardElementManager.setError(t),this}updatePublishableKey(t){null!=t&&""!==t&&this.initStripe(t,u(this.stripeAccount))}updateStripeAccountId(t){const e=this.stripeService.state.publishableKey||this.publishableKey;null!=e&&""!==e&&this.initStripe(e,{stripeAccount:t})}updateIntentClientSecret(){"success"===this.progress&&(this.progress="")}async setPaymentRequestOption(t){return this.paymentRequestOption=t,this.createPaymentRequestButton(),this}stripeLoadedEventHandler(){const t={stripe:this.stripeService.getStripe()};null!=this.stripeDidLoaded&&this.stripeDidLoaded(t),this.stripeLoaded.emit(t)}async formSubmitEventHandler(){const t=this.cardElementManager.getElements(),e=this.stripeService.getStripe();null!=t?this.formSubmit.emit({cardCVCElement:t.cardCVC,cardExpiryElement:t.cardExpiry,cardNumberElement:t.cardNumber,stripe:e}):console.error("Card elements not initialized")}async defaultFormSubmitResultHandler(t){this.defaultFormSubmitResult.emit(t)}componentWillRender(){const{publishableKey:t}=this.stripeService.state;null!=t&&""!==t&&(["success","loading"].includes(this.stripeService.state.loadStripeStatus)||this.initStripe(t,u(this.stripeService.state.stripeAccount)))}async defaultFormSubmitAction(t,{stripe:e,cardNumberElement:i,intentClientSecret:s}){t.preventDefault();try{const t=await((t,e,i,s)=>"payment"===this.intentType?t.confirmCardPayment(i,{payment_method:{card:s}}):t.confirmCardSetup(i,{payment_method:{card:s}}))(e,0,s,i);if(null!=t.error)throw new a(t.error);this.defaultFormSubmitResultHandler(t)}catch(t){throw console.error(t),this.defaultFormSubmitResultHandler(t),t}}constructor(t){super(),!1!==t&&this.__registerHost(),this.stripeLoaded=s(this,"stripeLoaded",7),this.formSubmit=s(this,"formSubmit",7),this.defaultFormSubmitResult=s(this,"defaultFormSubmitResult",7),this.paymentRequestButtonCreated=!1,this.intentType="payment",this.zip=!0,this.sheetTitle="Add your payment information",this.buttonLabel="Pay",this.progress="",this.zipCode="",this.applicationName="stripe-pwa-elements",this.showLabel=!1,this.shouldUseDefaultFormSubmitAction=!0,this.stripeService=l.createStripeService(),this.cardElementManager=l.createCardElementManager(this.stripeService)}componentWillLoad(){null!=this.publishableKey&&""!==this.publishableKey&&this.initStripe(this.publishableKey,u(this.stripeAccount))}async initElement(){await this.cardElementManager.initialize(this.el);const t=this.el.querySelector("#stripe-card-element");null!=t?t.addEventListener("submit",(async t=>{const e=this.cardElementManager.getElements(),i=this.stripeService.getStripe(),{intentClientSecret:s}=this;if(null==e||null==i)return void console.error("Stripe not properly initialized");const n={cardCVCElement:e.cardCVC,cardExpiryElement:e.cardExpiry,cardNumberElement:e.cardNumber,stripe:i,intentClientSecret:s,zipCode:this.zipCode};this.progress="loading";try{null!=this.handleSubmit?await this.handleSubmit(t,n):!0===this.shouldUseDefaultFormSubmitAction&&null!=s&&""!==s?await this.defaultFormSubmitAction(t,n):t.preventDefault(),await this.formSubmitEventHandler(),null==this.handleSubmit&&!0!==this.shouldUseDefaultFormSubmitAction||(this.progress="success")}catch(t){this.cardElementManager.setError(t.message),this.progress="failure"}})):console.error("Form element #stripe-card-element not found")}componentDidLoad(){this.el.classList.add(r())}componentDidRender(){this.showPaymentRequestButton&&this.paymentRequestOption&&!this.paymentRequestButtonCreated&&this.createPaymentRequestButton()}disconnectedCallback(){this.cardElementManager.unmount()}createPaymentRequestButton(){const{showPaymentRequestButton:t,paymentRequestOption:e}=this;if(this.paymentRequestButtonCreated)return null;if(!t||null==e)return null;if(null==document)return null;const i=this.el.querySelector("#stripe-payment-request-button");if(null==i)return console.error("Target element #stripe-payment-request-button not found"),null;if(null!=i.querySelector("stripe-payment-request-button"))return this.paymentRequestButtonCreated=!0,null;const s=document.createElement("stripe-payment-request-button");i.appendChild(s),customElements.whenDefined("stripe-payment-request-button").then((()=>(((t,e)=>{const{paymentRequestPaymentMethodHandler:i,paymentRequestShippingOptionChangeHandler:s,paymentRequestShippingAddressChangeHandler:n}=e;t.setPaymentRequestOption(e),null!=i&&t.setPaymentMethodEventHandler(i),null!=s&&t.setPaymentRequestShippingOptionEventHandler(s),null!=n&&t.setPaymentRequestShippingAddressEventHandler(n)})(s,e),s.initStripe(this.publishableKey)))),this.paymentRequestButtonCreated=!0}render(){const{loadStripeStatus:t}=this.stripeService.state,{errorMessage:e}=this.cardElementManager.getState();if("failure"===t)return n("p",null,o.t("Failed to load Stripe"));const i="loading"===this.progress||"success"===this.progress;return n("div",{class:"stripe-payment-sheet-wrap"},n("form",{id:"stripe-card-element"},n("div",{class:"stripe-heading"},o.t(this.sheetTitle)),n("div",{id:"stripe-payment-request-button"}),n("div",null,n("div",{class:"stripe-section-title"},o.t("Card information"))),n("div",{class:"payment-info card visible"},n("fieldset",{class:"stripe-input-box"},n("div",null,n("label",null,this.showLabel?n("lenged",null,o.t("Card Number")):null,n("div",{id:"card-number"}))),n("div",{class:"stripe-input-column",style:{display:"flex"}},n("label",{style:{width:"50%"}},this.showLabel?n("lenged",null,o.t("MM / YY")):null,n("div",{id:"card-expiry"})),n("label",{style:{width:"50%"}},this.showLabel?n("lenged",null,o.t("CVC")):null,n("div",{id:"card-cvc"}))))),n("div",{id:"card-errors",class:"stripe-element-errors"},e),this.zip?n("div",{style:{marginTop:"1.5rem"}},n("div",{class:"stripe-section-title"},o.t("Country or region"))):null,this.zip?n("div",{class:"payment-info card visible"},n("fieldset",{class:"stripe-input-box"},n("div",null,n("label",null,this.showLabel?n("lenged",null,o.t("Postal Code")):null,n("input",{id:"zip",name:"zip",type:"text",inputmode:"numeric",class:"StripeElement",style:{width:"100%"},placeholder:o.t("Postal Code"),value:this.zipCode,onInput:t=>{this.zipCode=t.target.value}}))))):null,n("div",{style:{marginTop:"32px"}},n("button",{type:"submit",disabled:i},o.t("loading"===this.progress?"Loading":this.buttonLabel)))))}get el(){return this}static get watchers(){return{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}],intentClientSecret:[{updateIntentClientSecret:0}]}}static get style(){return':root{--color-label:#565656;--color-placeholder:#acacac;--color-heading-text:#333;--color-text-error:#ef4444;--color-input-border:#e4e4e6;--color-input-border-shadow:rgba(228, 228, 230, 0.6);--color-button-text:rgba(255, 255, 255, 0.95);--color-button-text-disabled:rgba(255, 255, 255, 0.4);--color-primary:#0074d4}.stripe-payment-sheet-wrap{box-sizing:border-box}.stripe-payment-sheet-wrap *:where(:not(iframe,canvas,img,svg,video):not(svg *)){all:unset;display:revert;background:none;border:none;font-family:"Roboto", sans-serif;box-sizing:border-box}.stripe-payment-sheet-wrap button{cursor:pointer}.stripe-payment-sheet-wrap{display:block;width:100%;background:#fff;padding:32px 16px}.stripe-payment-sheet-wrap .StripeElement{padding:8px 16px;min-height:64px;display:flex;justify-content:center;align-items:center}.stripe-payment-sheet-wrap .StripeElement>.__PrivateStripeElement{width:100%}.stripe-payment-sheet-wrap .stripe-input-box{background-color:#fff;border-radius:6px;border:1px solid var(--color-input-border);overflow:hidden;filter:drop-shadow(0 0 2px var(--color-input-border-shadow))}.stripe-payment-sheet-wrap .stripe-input-box>*{border-bottom:1px solid var(--color-input-border)}.stripe-payment-sheet-wrap .stripe-input-box>*:last-child{border-bottom:none}.stripe-payment-sheet-wrap .stripe-input-column>*{border-right:1px solid var(--color-input-border)}.stripe-payment-sheet-wrap .stripe-input-column>*:last-child{border-right:none}.stripe-payment-sheet-wrap .stripe-heading{font-size:24px;font-weight:bold;color:var(--color-heading-text);margin-bottom:24px}.stripe-payment-sheet-wrap .stripe-section-title{font-size:14px;font-weight:bold;color:var(--color-label);margin-bottom:8px}.stripe-payment-sheet-wrap .payment-info label{color:var(--color-label)}.stripe-payment-sheet-wrap .stripe-element-errors{margin-top:8px;font-size:14px;color:var(--color-text-error)}.stripe-payment-sheet-wrap button{display:block;color:var(--color-button-text);background-color:var(--color-primary);width:100%;text-align:center;padding:16px 16px;font-size:18px;border-radius:6px;min-height:42px}.stripe-payment-sheet-wrap button:disabled{color:var(--color-button-text-disabled)}'}},[0,"stripe-card-element",{intentType:[1,"intent-type"],zip:[4],sheetTitle:[1,"sheet-title"],buttonLabel:[1,"button-label"],publishableKey:[1,"publishable-key"],stripeAccount:[1,"stripe-account"],applicationName:[1,"application-name"],showLabel:[4,"show-label"],intentClientSecret:[1,"intent-client-secret"],shouldUseDefaultFormSubmitAction:[4,"should-use-default-form-submit-action"],showPaymentRequestButton:[4,"show-payment-request-button"],handleSubmit:[1040],stripeDidLoaded:[1040],progress:[32],zipCode:[32],paymentRequestOption:[32],initStripe:[64],updateProgress:[64],setErrorMessage:[64],setPaymentRequestOption:[64]},void 0,{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}],intentClientSecret:[{updateIntentClientSecret:0}]}]);function d(){"undefined"!=typeof customElements&&["stripe-card-element","stripe-payment-request-button"].forEach((e=>{switch(e){case"stripe-card-element":customElements.get(t(e))||customElements.define(t(e),c);break;case"stripe-payment-request-button":customElements.get(t(e))||p()}}))}d();export{c as S,d}
1
+ import{transformTag as t,proxyCustomElement as e,HTMLElement as i,createEvent as s,h as n}from"@stencil/core/internal/client";import{c as r,i as o}from"./i18n.js";import{s as l}from"./factory.js";import{S as a}from"./error.js";import{d as p}from"./stripe-payment-request-button2.js";const u=t=>{if(null!=t&&""!==t)return{stripeAccount:t}},c=e(class extends i{async initStripe(t,e){if(await this.stripeService.initialize(t,{stripeAccount:null==e?void 0:e.stripeAccount,applicationName:this.applicationName}),"success"===this.stripeService.state.loadStripeStatus)await this.initElement(),this.stripeLoadedEventHandler();else{const t=this.stripeService.onChange("loadStripeStatus",(async e=>{"success"===e&&(await this.initElement(),this.stripeLoadedEventHandler(),t())}))}}async updateProgress(t){return this.progress=t,this}async setErrorMessage(t){return this.cardElementManager.setError(t),this}updatePublishableKey(t){null!=t&&""!==t&&this.initStripe(t,u(this.stripeAccount))}updateStripeAccountId(t){const e=this.stripeService.state.publishableKey||this.publishableKey;null!=e&&""!==e&&this.initStripe(e,{stripeAccount:t})}updateIntentClientSecret(){"success"===this.progress&&(this.progress="")}async setPaymentRequestOption(t){return this.paymentRequestOption=t,this.createPaymentRequestButton(),this}stripeLoadedEventHandler(){const t={stripe:this.stripeService.getStripe()};null!=this.stripeDidLoaded&&this.stripeDidLoaded(t),this.stripeLoaded.emit(t)}async formSubmitEventHandler(){const t=this.cardElementManager.getElements(),e=this.stripeService.getStripe();null!=t?this.formSubmit.emit({cardCVCElement:t.cardCVC,cardExpiryElement:t.cardExpiry,cardNumberElement:t.cardNumber,stripe:e}):console.error("Card elements not initialized")}async defaultFormSubmitResultHandler(t){this.defaultFormSubmitResult.emit(t)}componentWillRender(){const{publishableKey:t}=this.stripeService.state;null!=t&&""!==t&&(["success","loading"].includes(this.stripeService.state.loadStripeStatus)||this.initStripe(t,u(this.stripeService.state.stripeAccount)))}async defaultFormSubmitAction(t,{stripe:e,cardNumberElement:i,intentClientSecret:s}){t.preventDefault();try{const t=await((t,e,i,s)=>"payment"===this.intentType?t.confirmCardPayment(i,{payment_method:{card:s}}):t.confirmCardSetup(i,{payment_method:{card:s}}))(e,0,s,i);if(null!=t.error)throw new a(t.error);this.defaultFormSubmitResultHandler(t)}catch(t){throw console.error(t),this.defaultFormSubmitResultHandler(t),t}}constructor(t){super(),!1!==t&&this.__registerHost(),this.stripeLoaded=s(this,"stripeLoaded",7),this.formSubmit=s(this,"formSubmit",7),this.defaultFormSubmitResult=s(this,"defaultFormSubmitResult",7),this.paymentRequestButtonCreated=!1,this.intentType="payment",this.zip=!0,this.sheetTitle="Add your payment information",this.buttonLabel="Pay",this.progress="",this.zipCode="",this.applicationName="stripe-pwa-elements",this.showLabel=!1,this.shouldUseDefaultFormSubmitAction=!0,this.stripeService=l.createStripeService(),this.cardElementManager=l.createCardElementManager(this.stripeService)}componentWillLoad(){null!=this.publishableKey&&""!==this.publishableKey&&this.initStripe(this.publishableKey,u(this.stripeAccount))}async initElement(){await this.cardElementManager.initialize(this.el);const t=this.el.querySelector("#stripe-card-element");null!=t?t.addEventListener("submit",(async t=>{const e=this.cardElementManager.getElements(),i=this.stripeService.getStripe(),{intentClientSecret:s}=this;if(null==e||null==i)return void console.error("Stripe not properly initialized");const n={cardCVCElement:e.cardCVC,cardExpiryElement:e.cardExpiry,cardNumberElement:e.cardNumber,stripe:i,intentClientSecret:s,zipCode:this.zipCode};this.progress="loading";try{null!=this.handleSubmit?await this.handleSubmit(t,n):!0===this.shouldUseDefaultFormSubmitAction&&null!=s&&""!==s?await this.defaultFormSubmitAction(t,n):t.preventDefault(),await this.formSubmitEventHandler(),null==this.handleSubmit&&!0!==this.shouldUseDefaultFormSubmitAction||(this.progress="success")}catch(t){this.cardElementManager.setError(t.message),this.progress="failure"}})):console.error("Form element #stripe-card-element not found")}componentDidLoad(){this.el.classList.add(r())}componentDidRender(){this.showPaymentRequestButton&&this.paymentRequestOption&&!this.paymentRequestButtonCreated&&this.createPaymentRequestButton()}disconnectedCallback(){this.cardElementManager.unmount()}createPaymentRequestButton(){const{showPaymentRequestButton:t,paymentRequestOption:e}=this;if(this.paymentRequestButtonCreated)return null;if(!t||null==e)return null;if(null==document)return null;const i=this.el.querySelector("#stripe-payment-request-button");if(null==i)return console.error("Target element #stripe-payment-request-button not found"),null;if(null!=i.querySelector("stripe-payment-request-button"))return this.paymentRequestButtonCreated=!0,null;const s=document.createElement("stripe-payment-request-button");i.appendChild(s),customElements.whenDefined("stripe-payment-request-button").then((()=>(((t,e)=>{const{paymentRequestPaymentMethodHandler:i,paymentRequestShippingOptionChangeHandler:s,paymentRequestShippingAddressChangeHandler:n}=e;t.setPaymentRequestOption(e),null!=i&&t.setPaymentMethodEventHandler(i),null!=s&&t.setPaymentRequestShippingOptionEventHandler(s),null!=n&&t.setPaymentRequestShippingAddressEventHandler(n)})(s,e),s.initStripe(this.publishableKey)))),this.paymentRequestButtonCreated=!0}render(){const{loadStripeStatus:t}=this.stripeService.state,{errorMessage:e}=this.cardElementManager.getState();if("failure"===t)return n("p",null,o.t("Failed to load Stripe"));const i="loading"===this.progress||"success"===this.progress;return n("div",{class:"stripe-payment-sheet-wrap"},n("form",{id:"stripe-card-element"},n("div",{class:"stripe-heading"},o.t(this.sheetTitle)),n("div",{id:"stripe-payment-request-button"}),n("div",null,n("div",{class:"stripe-section-title"},o.t("Card information"))),n("div",{class:"payment-info card visible"},n("fieldset",{class:"stripe-input-box"},n("div",null,n("label",null,this.showLabel?n("lenged",null,o.t("Card Number")):null,n("div",{id:"card-number"}))),n("div",{class:"stripe-input-column",style:{display:"flex"}},n("label",{style:{width:"50%"}},this.showLabel?n("lenged",null,o.t("MM / YY")):null,n("div",{id:"card-expiry"})),n("label",{style:{width:"50%"}},this.showLabel?n("lenged",null,o.t("CVC")):null,n("div",{id:"card-cvc"}))))),n("div",{id:"card-errors",class:"stripe-element-errors"},e),this.zip?n("div",{style:{marginTop:"1.5rem"}},n("div",{class:"stripe-section-title"},o.t("Postal Code"))):null,this.zip?n("div",{class:"payment-info card visible"},n("fieldset",{class:"stripe-input-box"},n("div",null,n("label",null,this.showLabel?n("lenged",null,o.t("Postal Code")):null,n("input",{id:"zip",name:"zip",type:"text",inputmode:"numeric",class:"StripeElement",style:{width:"100%"},placeholder:o.t("Postal Code"),value:this.zipCode,onInput:t=>{this.zipCode=t.target.value}}))))):null,n("div",{style:{marginTop:"32px"}},n("button",{type:"submit",disabled:i},o.t("loading"===this.progress?"Loading":this.buttonLabel)))))}get el(){return this}static get watchers(){return{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}],intentClientSecret:[{updateIntentClientSecret:0}]}}static get style(){return':root{--color-label:#565656;--color-placeholder:#acacac;--color-heading-text:#333;--color-text-error:#ef4444;--color-input-border:#e4e4e6;--color-input-border-shadow:rgba(228, 228, 230, 0.6);--color-button-text:rgba(255, 255, 255, 0.95);--color-button-text-disabled:rgba(255, 255, 255, 0.4);--color-primary:#0074d4}.stripe-payment-sheet-wrap{box-sizing:border-box}.stripe-payment-sheet-wrap *:where(:not(iframe,canvas,img,svg,video):not(svg *)){all:unset;display:revert;background:none;border:none;font-family:"Roboto", sans-serif;box-sizing:border-box}.stripe-payment-sheet-wrap button{cursor:pointer}.stripe-payment-sheet-wrap{display:block;width:100%;background:#fff;padding:32px 16px}.stripe-payment-sheet-wrap .StripeElement{padding:8px 16px;min-height:64px;display:flex;justify-content:center;align-items:center}.stripe-payment-sheet-wrap .StripeElement>.__PrivateStripeElement{width:100%}.stripe-payment-sheet-wrap .stripe-input-box{background-color:#fff;border-radius:6px;border:1px solid var(--color-input-border);overflow:hidden;filter:drop-shadow(0 0 2px var(--color-input-border-shadow))}.stripe-payment-sheet-wrap .stripe-input-box>*{border-bottom:1px solid var(--color-input-border)}.stripe-payment-sheet-wrap .stripe-input-box>*:last-child{border-bottom:none}.stripe-payment-sheet-wrap .stripe-input-column>*{border-right:1px solid var(--color-input-border)}.stripe-payment-sheet-wrap .stripe-input-column>*:last-child{border-right:none}.stripe-payment-sheet-wrap .stripe-heading{font-size:24px;font-weight:bold;color:var(--color-heading-text);margin-bottom:24px}.stripe-payment-sheet-wrap .stripe-section-title{font-size:14px;font-weight:bold;color:var(--color-label);margin-bottom:8px}.stripe-payment-sheet-wrap .payment-info label{color:var(--color-label)}.stripe-payment-sheet-wrap .stripe-element-errors{margin-top:8px;font-size:14px;color:var(--color-text-error)}.stripe-payment-sheet-wrap button{display:block;color:var(--color-button-text);background-color:var(--color-primary);width:100%;text-align:center;padding:16px 16px;font-size:18px;border-radius:6px;min-height:42px}.stripe-payment-sheet-wrap button:disabled{color:var(--color-button-text-disabled)}'}},[0,"stripe-card-element",{intentType:[1,"intent-type"],zip:[4],sheetTitle:[1,"sheet-title"],buttonLabel:[1,"button-label"],publishableKey:[1,"publishable-key"],stripeAccount:[1,"stripe-account"],applicationName:[1,"application-name"],showLabel:[4,"show-label"],intentClientSecret:[1,"intent-client-secret"],shouldUseDefaultFormSubmitAction:[4,"should-use-default-form-submit-action"],showPaymentRequestButton:[4,"show-payment-request-button"],handleSubmit:[1040],stripeDidLoaded:[1040],progress:[32],zipCode:[32],paymentRequestOption:[32],initStripe:[64],updateProgress:[64],setErrorMessage:[64],setPaymentRequestOption:[64]},void 0,{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}],intentClientSecret:[{updateIntentClientSecret:0}]}]);function d(){"undefined"!=typeof customElements&&["stripe-card-element","stripe-payment-request-button"].forEach((e=>{switch(e){case"stripe-card-element":customElements.get(t(e))||customElements.define(t(e),c);break;case"stripe-payment-request-button":customElements.get(t(e))||p()}}))}d();export{c as S,d}