@one-payments/web-components 1.0.8 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -284,7 +284,7 @@ Q.elementStyles = [], Q.shadowRootOptions = { mode: "open" }, Q[ie("elementPrope
284
284
  * Copyright 2017 Google LLC
285
285
  * SPDX-License-Identifier: BSD-3-Clause
286
286
  */
287
- const oe = globalThis, we = oe.trustedTypes, tt = we ? we.createPolicy("lit-html", { createHTML: (t) => t }) : void 0, ft = "$lit$", L = `lit$${Math.random().toFixed(9).slice(2)}$`, mt = "?" + L, Yt = `<${mt}>`, Y = document, le = () => Y.createComment(""), de = (t) => t === null || typeof t != "object" && typeof t != "function", je = Array.isArray, Kt = (t) => je(t) || typeof (t == null ? void 0 : t[Symbol.iterator]) == "function", _e = `[
287
+ const oe = globalThis, we = oe.trustedTypes, tt = we ? we.createPolicy("lit-html", { createHTML: (t) => t }) : void 0, mt = "$lit$", L = `lit$${Math.random().toFixed(9).slice(2)}$`, ft = "?" + L, Yt = `<${ft}>`, Y = document, le = () => Y.createComment(""), de = (t) => t === null || typeof t != "object" && typeof t != "function", je = Array.isArray, Kt = (t) => je(t) || typeof (t == null ? void 0 : t[Symbol.iterator]) == "function", _e = `[
288
288
  \f\r]`, re = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, nt = /-->/g, rt = />/g, q = RegExp(`>|${_e}(?:([^\\s"'>=/]+)(${_e}*=${_e}*(?:[^
289
289
  \f\r"'\`<>=]|("|')|))|$)`, "g"), it = /'/g, ot = /"/g, pt = /^(?:script|style|textarea|title)$/i, Qt = (t) => (e, ...n) => ({ _$litType$: t, strings: e, values: n }), A = Qt(1), G = Symbol.for("lit-noChange"), I = Symbol.for("lit-nothing"), st = /* @__PURE__ */ new WeakMap(), V = Y.createTreeWalker(Y, 129);
290
290
  function gt(t, e) {
@@ -296,10 +296,10 @@ const Zt = (t, e) => {
296
296
  let i, o = e === 2 ? "<svg>" : e === 3 ? "<math>" : "", s = re;
297
297
  for (let l = 0; l < n; l++) {
298
298
  const a = t[l];
299
- let d, c, h = -1, f = 0;
300
- for (; f < a.length && (s.lastIndex = f, c = s.exec(a), c !== null); ) f = s.lastIndex, s === re ? c[1] === "!--" ? s = nt : c[1] !== void 0 ? s = rt : c[2] !== void 0 ? (pt.test(c[2]) && (i = RegExp("</" + c[2], "g")), s = q) : c[3] !== void 0 && (s = q) : s === q ? c[0] === ">" ? (s = i ?? re, h = -1) : c[1] === void 0 ? h = -2 : (h = s.lastIndex - c[2].length, d = c[1], s = c[3] === void 0 ? q : c[3] === '"' ? ot : it) : s === ot || s === it ? s = q : s === nt || s === rt ? s = re : (s = q, i = void 0);
299
+ let d, c, h = -1, m = 0;
300
+ for (; m < a.length && (s.lastIndex = m, c = s.exec(a), c !== null); ) m = s.lastIndex, s === re ? c[1] === "!--" ? s = nt : c[1] !== void 0 ? s = rt : c[2] !== void 0 ? (pt.test(c[2]) && (i = RegExp("</" + c[2], "g")), s = q) : c[3] !== void 0 && (s = q) : s === q ? c[0] === ">" ? (s = i ?? re, h = -1) : c[1] === void 0 ? h = -2 : (h = s.lastIndex - c[2].length, d = c[1], s = c[3] === void 0 ? q : c[3] === '"' ? ot : it) : s === ot || s === it ? s = q : s === nt || s === rt ? s = re : (s = q, i = void 0);
301
301
  const u = s === q && t[l + 1].startsWith("/>") ? " " : "";
302
- o += s === re ? a + Yt : h >= 0 ? (r.push(d), a.slice(0, h) + ft + a.slice(h) + L + u) : a + L + (h === -2 ? l : u);
302
+ o += s === re ? a + Yt : h >= 0 ? (r.push(d), a.slice(0, h) + mt + a.slice(h) + L + u) : a + L + (h === -2 ? l : u);
303
303
  }
304
304
  return [gt(t, o + (t[n] || "<?>") + (e === 2 ? "</svg>" : e === 3 ? "</math>" : "")), r];
305
305
  };
@@ -315,19 +315,19 @@ class ce {
315
315
  }
316
316
  for (; (i = V.nextNode()) !== null && a.length < l; ) {
317
317
  if (i.nodeType === 1) {
318
- if (i.hasAttributes()) for (const h of i.getAttributeNames()) if (h.endsWith(ft)) {
319
- const f = c[s++], u = i.getAttribute(h).split(L), m = /([.?@])?(.*)/.exec(f);
320
- a.push({ type: 1, index: o, name: m[2], strings: u, ctor: m[1] === "." ? Jt : m[1] === "?" ? Wt : m[1] === "@" ? Xt : Se }), i.removeAttribute(h);
318
+ if (i.hasAttributes()) for (const h of i.getAttributeNames()) if (h.endsWith(mt)) {
319
+ const m = c[s++], u = i.getAttribute(h).split(L), f = /([.?@])?(.*)/.exec(m);
320
+ a.push({ type: 1, index: o, name: f[2], strings: u, ctor: f[1] === "." ? Jt : f[1] === "?" ? Wt : f[1] === "@" ? Xt : Se }), i.removeAttribute(h);
321
321
  } else h.startsWith(L) && (a.push({ type: 6, index: o }), i.removeAttribute(h));
322
322
  if (pt.test(i.tagName)) {
323
- const h = i.textContent.split(L), f = h.length - 1;
324
- if (f > 0) {
323
+ const h = i.textContent.split(L), m = h.length - 1;
324
+ if (m > 0) {
325
325
  i.textContent = we ? we.emptyScript : "";
326
- for (let u = 0; u < f; u++) i.append(h[u], le()), V.nextNode(), a.push({ type: 2, index: ++o });
327
- i.append(h[f], le());
326
+ for (let u = 0; u < m; u++) i.append(h[u], le()), V.nextNode(), a.push({ type: 2, index: ++o });
327
+ i.append(h[m], le());
328
328
  }
329
329
  }
330
- } else if (i.nodeType === 8) if (i.data === mt) a.push({ type: 2, index: o });
330
+ } else if (i.nodeType === 8) if (i.data === ft) a.push({ type: 2, index: o });
331
331
  else {
332
332
  let h = -1;
333
333
  for (; (h = i.data.indexOf(L, h + 1)) !== -1; ) a.push({ type: 7, index: o }), h += L.length - 1;
@@ -504,8 +504,8 @@ class en {
504
504
  J(this, e);
505
505
  }
506
506
  }
507
- const $e = oe.litHtmlPolyfillSupport;
508
- $e == null || $e(ce, he), (oe.litHtmlVersions ?? (oe.litHtmlVersions = [])).push("3.3.1");
507
+ const De = oe.litHtmlPolyfillSupport;
508
+ De == null || De(ce, he), (oe.litHtmlVersions ?? (oe.litHtmlVersions = [])).push("3.3.1");
509
509
  const tn = (t, e, n) => {
510
510
  const r = (n == null ? void 0 : n.renderBefore) ?? e;
511
511
  let i = r._$litPart$;
@@ -548,8 +548,8 @@ class se extends Q {
548
548
  }
549
549
  var ut;
550
550
  se._$litElement$ = !0, se.finalized = !0, (ut = j.litElementHydrateSupport) == null || ut.call(j, { LitElement: se });
551
- const De = j.litElementPolyfillSupport;
552
- De == null || De({ LitElement: se });
551
+ const $e = j.litElementPolyfillSupport;
552
+ $e == null || $e({ LitElement: se });
553
553
  (j.litElementVersions ?? (j.litElementVersions = [])).push("4.2.1");
554
554
  /**
555
555
  * @license
@@ -601,10 +601,13 @@ function M(t) {
601
601
  function _(t) {
602
602
  return M({ ...t, state: !0, attribute: !1 });
603
603
  }
604
+ function sn(t) {
605
+ return t instanceof Error && ("response" in t && typeof t.response == "object" && t.response !== null || "data" in t && typeof t.data == "object" && t.data !== null);
606
+ }
604
607
  var K = {
605
608
  CARD: "card",
606
609
  PAYNOW: "paynow"
607
- }, D = {
610
+ }, $ = {
608
611
  IDLE: "idle",
609
612
  INITIALIZING: "initializing",
610
613
  READY: "ready",
@@ -613,10 +616,10 @@ var K = {
613
616
  SUCCEEDED: "succeeded",
614
617
  FAILED: "failed"
615
618
  };
616
- function sn(t) {
619
+ function an(t) {
617
620
  return t === "paid" ? "succeeded" : t;
618
621
  }
619
- var an = class {
622
+ var ln = class {
620
623
  constructor(t, e, n, r, i = {}) {
621
624
  this.isPolling = !1, this.attempts = 0, this.startTime = 0, this.pollTimeoutId = null, this.adapters = t, this.baseUrl = e, this.token = n, this.onStatusUpdate = r, this.config = {
622
625
  interval: i.interval ?? 3e3,
@@ -698,10 +701,13 @@ var an = class {
698
701
  if (this.isPolling) {
699
702
  this.attempts++;
700
703
  try {
701
- const t = await this.adapters.http.get(`${this.baseUrl}/payment-intent/get-payment-data`, {
702
- "x-token": this.token
703
- }), e = {
704
- status: sn(t.result.status),
704
+ const t = await this.adapters.http.get(
705
+ `${this.baseUrl}/payment-intent/get-payment-data`,
706
+ {
707
+ "x-token": this.token
708
+ }
709
+ ), e = {
710
+ status: an(t.result.status),
705
711
  // Map "paid" to "succeeded"
706
712
  paymentIntentId: t.result.paymentIntentId || "",
707
713
  ...t.result.amount !== void 0 && { amount: t.result.amount },
@@ -737,7 +743,7 @@ var an = class {
737
743
  }
738
744
  }
739
745
  };
740
- function ln(t) {
746
+ function dn(t) {
741
747
  switch (t) {
742
748
  case "prod":
743
749
  return "https://public.one.ooo";
@@ -749,26 +755,75 @@ function ln(t) {
749
755
  return "https://public.dev.one.ooo";
750
756
  }
751
757
  }
752
- var dn = class {
758
+ var cn = class {
753
759
  // Flag to ignore qrCode after user scans it
754
760
  constructor(t, e) {
755
- this.state = { status: D.IDLE }, this.subscribers = /* @__PURE__ */ new Set(), this.eventListeners = {}, this.paymentToken = null, this.paymentIntentId = null, this.pollingService = null, this.ignore3DSInPolling = !1, this.ignoreQRInPolling = !1, this.config = t, this.adapters = e;
761
+ this.state = { status: $.IDLE }, this.subscribers = /* @__PURE__ */ new Set(), this.eventListeners = {}, this.paymentToken = null, this.paymentIntentId = null, this.pollingService = null, this.ignore3DSInPolling = !1, this.ignoreQRInPolling = !1, this.config = t, this.adapters = e;
756
762
  }
757
763
  /**
758
764
  * Get the API base URL - uses apiBaseUrl if provided, otherwise derives from environment
759
765
  */
760
766
  getApiBaseUrl() {
761
- return this.config.apiBaseUrl ?? ln(this.config.environment);
767
+ return this.config.apiBaseUrl ?? dn(this.config.environment);
762
768
  }
763
769
  /**
764
- * Get current state (immutable)
770
+ * Get the current payment state
771
+ *
772
+ * Returns an immutable snapshot of the current SDK state. The state follows a discriminated
773
+ * union pattern, where the `status` field determines which additional fields are available.
774
+ *
775
+ * @returns The current state object (readonly)
776
+ *
777
+ * @example
778
+ * ```typescript
779
+ * const state = sdk.getState();
780
+ *
781
+ * if (state.status === 'ready') {
782
+ * console.log('Available methods:', state.availableMethods);
783
+ * console.log('Payment intent:', state.paymentIntent);
784
+ * } else if (state.status === 'failed') {
785
+ * console.error('Error:', state.error);
786
+ * }
787
+ * ```
788
+ *
789
+ * @public
765
790
  */
766
791
  getState() {
767
792
  return this.state;
768
793
  }
769
794
  /**
770
795
  * Subscribe to state changes
771
- * @returns Unsubscribe function
796
+ *
797
+ * Registers a callback function that will be called immediately with the current state,
798
+ * and then again whenever the state changes. This is useful for reactive UI updates.
799
+ *
800
+ * @param subscriber - Callback function to be called with state updates
801
+ * @returns Unsubscribe function - call this to stop receiving updates
802
+ *
803
+ * @example
804
+ * ```typescript
805
+ * const unsubscribe = sdk.subscribe((state) => {
806
+ * switch (state.status) {
807
+ * case 'ready':
808
+ * console.log('Ready to accept payment');
809
+ * break;
810
+ * case 'processing':
811
+ * console.log('Processing payment...');
812
+ * break;
813
+ * case 'succeeded':
814
+ * console.log('Payment succeeded!');
815
+ * break;
816
+ * case 'failed':
817
+ * console.error('Payment failed:', state.error.message);
818
+ * break;
819
+ * }
820
+ * });
821
+ *
822
+ * // Later, when you want to stop listening:
823
+ * unsubscribe();
824
+ * ```
825
+ *
826
+ * @public
772
827
  */
773
828
  subscribe(t) {
774
829
  return this.subscribers.add(t), t(this.state), () => {
@@ -776,7 +831,39 @@ var dn = class {
776
831
  };
777
832
  }
778
833
  /**
779
- * Add event listener with type safety
834
+ * Add an event listener for specific payment events
835
+ *
836
+ * Allows you to listen to specific payment lifecycle events with full type safety.
837
+ * Unlike `subscribe`, which receives all state changes, this method lets you listen
838
+ * to specific events like payment initialization, success, failure, etc.
839
+ *
840
+ * @param eventType - The type of event to listen for
841
+ * @param listener - Callback function to be called when the event occurs
842
+ * @returns Unsubscribe function - call this to remove the listener
843
+ *
844
+ * @example
845
+ * ```typescript
846
+ * // Listen for successful payments
847
+ * const removeListener = sdk.on('payment_succeeded', (event) => {
848
+ * console.log('Payment succeeded!', event.payload.paymentIntent);
849
+ * console.log('Method used:', event.payload.methodId);
850
+ * });
851
+ *
852
+ * // Listen for QR codes
853
+ * sdk.on('qr_code_received', (event) => {
854
+ * displayQRCode(event.payload.qrCode);
855
+ * });
856
+ *
857
+ * // Listen for required actions (3DS)
858
+ * sdk.on('payment_requires_action', (event) => {
859
+ * openAuthenticationWindow(event.payload.actionUrl);
860
+ * });
861
+ *
862
+ * // Later, remove the listener:
863
+ * removeListener();
864
+ * ```
865
+ *
866
+ * @public
780
867
  */
781
868
  on(t, e) {
782
869
  this.eventListeners[t] || (this.eventListeners[t] = []);
@@ -787,10 +874,46 @@ var dn = class {
787
874
  };
788
875
  }
789
876
  /**
790
- * Initialize payment intent
877
+ * Initialize a new payment intent
878
+ *
879
+ * Creates a payment intent on the server and fetches available payment methods.
880
+ * This must be called before attempting to submit a payment. The SDK state will
881
+ * transition from 'idle' → 'initializing' → 'ready' (or 'failed' on error).
882
+ *
883
+ * @param params - Payment initialization parameters
884
+ * @param params.amount - Payment amount in smallest currency unit (e.g., cents for USD)
885
+ * @param params.currency - ISO 4217 currency code (e.g., 'USD', 'SGD', 'EUR')
886
+ * @param params.orderId - Your unique order/transaction identifier
887
+ * @param params.notes - Optional notes or description for the payment
888
+ * @param params.metadata - Optional metadata object with custom key-value pairs
889
+ * @returns Promise that resolves with the created payment intent
890
+ * @throws {Error} If initialization fails (network error, invalid credentials, etc.)
891
+ *
892
+ * @example
893
+ * ```typescript
894
+ * try {
895
+ * const paymentIntent = await sdk.initialize({
896
+ * amount: 5000, // $50.00
897
+ * currency: 'USD',
898
+ * orderId: 'ORDER-123',
899
+ * notes: 'Premium subscription',
900
+ * metadata: {
901
+ * userId: '12345',
902
+ * subscriptionId: 'sub_abc',
903
+ * },
904
+ * });
905
+ *
906
+ * console.log('Payment intent created:', paymentIntent.id);
907
+ * console.log('Amount with fees:', paymentIntent.amount);
908
+ * } catch (error) {
909
+ * console.error('Failed to initialize:', error);
910
+ * }
911
+ * ```
912
+ *
913
+ * @public
791
914
  */
792
915
  async initialize(t) {
793
- this.setState({ status: D.INITIALIZING }), this.emit({
916
+ this.setState({ status: $.INITIALIZING }), this.emit({
794
917
  type: "initialize",
795
918
  payload: t
796
919
  });
@@ -811,27 +934,33 @@ var dn = class {
811
934
  if (!s)
812
935
  throw new Error("No token found in redirectUrl");
813
936
  this.paymentToken = s, this.paymentIntentId = i.result.paymentIntentId;
814
- const l = await this.adapters.http.get(`${this.getApiBaseUrl()}/payment-intent/get-payment-data`, {
815
- "x-token": this.paymentToken
816
- }), a = await this.adapters.http.get(`${this.getApiBaseUrl()}/payment-intent/available-methods`, {
817
- "x-token": this.paymentToken
818
- }), d = {
937
+ const l = await this.adapters.http.get(
938
+ `${this.getApiBaseUrl()}/payment-intent/get-payment-data`,
939
+ {
940
+ "x-token": this.paymentToken
941
+ }
942
+ ), a = await this.adapters.http.get(
943
+ `${this.getApiBaseUrl()}/payment-intent/available-methods`,
944
+ {
945
+ "x-token": this.paymentToken
946
+ }
947
+ ), d = {
819
948
  id: this.paymentIntentId,
820
949
  amount: l.result.customerAmount || t.amount,
821
950
  currency: l.result.currency || t.currency,
822
- status: D.READY,
951
+ status: $.READY,
823
952
  ...t.metadata && { metadata: t.metadata }
824
- }, c = a.result.paymentMethods.map((h, f) => {
953
+ }, c = a.result.paymentMethods.map((h, m) => {
825
954
  let u = null;
826
- const m = h.type.toLowerCase(), g = h.capabilities || [];
827
- return m.includes("card") ? u = "card" : (m.includes("paynow") || m.includes("bank transfer") || g.includes("payments_pay_now")) && (u = "paynow"), u === null ? null : {
955
+ const f = h.type.toLowerCase(), g = h.capabilities || [];
956
+ return f.includes("card") ? u = "card" : (f.includes("paynow") || f.includes("bank transfer") || g.includes("payments_pay_now")) && (u = "paynow"), u === null ? null : {
828
957
  id: u,
829
958
  enabled: !0,
830
- priority: f
959
+ priority: m
831
960
  };
832
961
  }).filter((h) => h !== null);
833
962
  return this.setState({
834
- status: D.READY,
963
+ status: $.READY,
835
964
  paymentIntent: d,
836
965
  availableMethods: c
837
966
  }), this.emit({
@@ -848,7 +977,7 @@ var dn = class {
848
977
  timestamp: this.adapters.timer.now()
849
978
  };
850
979
  throw this.setState({
851
- status: D.FAILED,
980
+ status: $.FAILED,
852
981
  error: n
853
982
  }), this.emit({
854
983
  type: "payment_failed",
@@ -857,7 +986,56 @@ var dn = class {
857
986
  }
858
987
  }
859
988
  /**
860
- * Submit payment with selected method
989
+ * Submit a payment with the selected payment method
990
+ *
991
+ * Processes a payment using the specified payment method and customer details.
992
+ * The SDK must be in 'ready' state before calling this method. After submission,
993
+ * the SDK automatically polls for payment status updates.
994
+ *
995
+ * For card payments, the payment may require 3D Secure authentication, which will
996
+ * trigger a 'payment_requires_action' event with an authentication URL.
997
+ *
998
+ * For PayNow/QR payments, a QR code will be provided via 'qr_code_received' event
999
+ * that the customer needs to scan with their mobile banking app.
1000
+ *
1001
+ * @param methodId - The payment method to use ('card' or 'paynow')
1002
+ * @param paymentData - Payment details object containing customer and payment information
1003
+ * @param paymentData.firstName - Customer's first name
1004
+ * @param paymentData.lastName - Customer's last name
1005
+ * @param paymentData.email - Customer's email address
1006
+ * @param paymentData.cardNumber - Card number (for card payments)
1007
+ * @param paymentData.expiryMonth - Card expiry month (for card payments)
1008
+ * @param paymentData.expiryYear - Card expiry year (for card payments)
1009
+ * @param paymentData.cvv - Card CVV code (for card payments)
1010
+ * @returns Promise that resolves with the payment intent
1011
+ * @throws {Error} If SDK is not in ready state, no payment token available, or submission fails
1012
+ *
1013
+ * @example
1014
+ * ```typescript
1015
+ * // Card payment
1016
+ * try {
1017
+ * await sdk.submitPayment('card', {
1018
+ * firstName: 'John',
1019
+ * lastName: 'Doe',
1020
+ * email: 'john@example.com',
1021
+ * cardNumber: '4242424242424242',
1022
+ * expiryMonth: '12',
1023
+ * expiryYear: '2025',
1024
+ * cvv: '123',
1025
+ * });
1026
+ * } catch (error) {
1027
+ * console.error('Payment failed:', error);
1028
+ * }
1029
+ *
1030
+ * // PayNow payment
1031
+ * await sdk.submitPayment('paynow', {
1032
+ * firstName: 'John',
1033
+ * lastName: 'Doe',
1034
+ * email: 'john@example.com',
1035
+ * });
1036
+ * ```
1037
+ *
1038
+ * @public
861
1039
  */
862
1040
  async submitPayment(t, e) {
863
1041
  var r, i, o, s, l;
@@ -867,7 +1045,7 @@ var dn = class {
867
1045
  if (!this.paymentToken)
868
1046
  throw new Error("Cannot submit payment: No payment token available");
869
1047
  this.ignore3DSInPolling = !1, this.ignoreQRInPolling = !1, this.setState({
870
- status: D.PROCESSING,
1048
+ status: $.PROCESSING,
871
1049
  paymentIntent: n.paymentIntent,
872
1050
  selectedMethod: t,
873
1051
  availableMethods: n.availableMethods
@@ -880,16 +1058,16 @@ var dn = class {
880
1058
  });
881
1059
  try {
882
1060
  const a = {
883
- firstName: e.firstName,
884
- lastName: e.lastName,
885
- email: e.email,
1061
+ firstName: String(e.firstName),
1062
+ lastName: String(e.lastName),
1063
+ email: String(e.email),
886
1064
  paymentMethod: t === "card" ? {
887
1065
  type: "card",
888
1066
  card: {
889
- number: e.cardNumber,
890
- expiryMonth: e.expiryMonth,
891
- expiryYear: e.expiryYear,
892
- cvc: e.cvv
1067
+ number: String(e.cardNumber),
1068
+ expiryMonth: String(e.expiryMonth),
1069
+ expiryYear: String(e.expiryYear),
1070
+ cvc: String(e.cvv)
893
1071
  }
894
1072
  } : { type: "qr" }
895
1073
  };
@@ -903,19 +1081,15 @@ var dn = class {
903
1081
  id: this.paymentIntentId || "",
904
1082
  amount: n.paymentIntent.amount,
905
1083
  currency: n.paymentIntent.currency,
906
- status: D.PROCESSING
1084
+ status: $.PROCESSING
907
1085
  };
908
1086
  } catch (a) {
909
1087
  let d = "Unknown error", c = "PAYMENT_FAILED";
910
1088
  if (a instanceof Error)
911
1089
  try {
912
- const f = a;
913
- if ((r = f.response) != null && r.data) {
914
- const u = f.response.data;
915
- d = u.message || ((i = u.error) == null ? void 0 : i.message) || a.message, c = u.code || ((o = u.error) == null ? void 0 : o.code) || c;
916
- } else if (f.data) {
917
- const u = f.data;
918
- d = u.message || ((s = u.error) == null ? void 0 : s.message) || a.message, c = u.code || ((l = u.error) == null ? void 0 : l.code) || c;
1090
+ if (sn(a)) {
1091
+ const m = (r = a.response) == null ? void 0 : r.data, u = a.data;
1092
+ m ? (d = m.message || ((i = m.error) == null ? void 0 : i.message) || a.message, c = m.code || ((o = m.error) == null ? void 0 : o.code) || c) : u ? (d = u.message || ((s = u.error) == null ? void 0 : s.message) || a.message, c = u.code || ((l = u.error) == null ? void 0 : l.code) || c) : d = a.message;
919
1093
  } else
920
1094
  d = a.message;
921
1095
  } catch {
@@ -927,7 +1101,7 @@ var dn = class {
927
1101
  timestamp: this.adapters.timer.now()
928
1102
  };
929
1103
  throw this.setState({
930
- status: D.FAILED,
1104
+ status: $.FAILED,
931
1105
  error: h,
932
1106
  paymentIntent: n.paymentIntent
933
1107
  }), this.emit({
@@ -940,8 +1114,39 @@ var dn = class {
940
1114
  }
941
1115
  }
942
1116
  /**
943
- * Resume polling after 3DS or QR flow completes
944
- * This is called by the UI layer after user completes 3DS authentication or scans QR code
1117
+ * Resume polling after 3D Secure or QR code flow completes
1118
+ *
1119
+ * This method should be called after the user completes 3D Secure authentication
1120
+ * or scans a QR code. It resumes payment status polling while ignoring subsequent
1121
+ * action URLs or QR codes to prevent showing the same modal/action multiple times.
1122
+ *
1123
+ * The SDK will continue polling until it receives a terminal status (succeeded or failed).
1124
+ *
1125
+ * @example
1126
+ * ```typescript
1127
+ * // After 3DS authentication completes
1128
+ * sdk.on('payment_requires_action', (event) => {
1129
+ * const authWindow = window.open(event.payload.actionUrl);
1130
+ *
1131
+ * // Monitor when auth window closes
1132
+ * const checkClosed = setInterval(() => {
1133
+ * if (authWindow?.closed) {
1134
+ * clearInterval(checkClosed);
1135
+ * sdk.resumePolling(); // Resume polling for final status
1136
+ * }
1137
+ * }, 500);
1138
+ * });
1139
+ *
1140
+ * // After QR code is scanned
1141
+ * sdk.on('qr_code_received', (event) => {
1142
+ * displayQRCode(event.payload.qrCode);
1143
+ * // User scans QR code with their banking app
1144
+ * // Once they confirm payment in their app:
1145
+ * sdk.resumePolling(); // Resume polling for final status
1146
+ * });
1147
+ * ```
1148
+ *
1149
+ * @public
945
1150
  */
946
1151
  resumePolling() {
947
1152
  if (!this.paymentToken) {
@@ -951,7 +1156,29 @@ var dn = class {
951
1156
  this.ignore3DSInPolling = !0, this.ignoreQRInPolling = !0, this.startPolling();
952
1157
  }
953
1158
  /**
954
- * Destroy SDK instance and cleanup
1159
+ * Destroy the SDK instance and clean up all resources
1160
+ *
1161
+ * This method should be called when you're done with the SDK instance to:
1162
+ * - Stop all polling operations
1163
+ * - Remove all event listeners
1164
+ * - Clear all state subscribers
1165
+ * - Free up memory
1166
+ *
1167
+ * After calling destroy(), the SDK instance should not be used again.
1168
+ *
1169
+ * @example
1170
+ * ```typescript
1171
+ * // When component unmounts or page unloads
1172
+ * useEffect(() => {
1173
+ * const sdk = new PaymentSDK(config, adapters);
1174
+ *
1175
+ * return () => {
1176
+ * sdk.destroy(); // Cleanup on unmount
1177
+ * };
1178
+ * }, []);
1179
+ * ```
1180
+ *
1181
+ * @public
955
1182
  */
956
1183
  destroy() {
957
1184
  this.stopPolling(), this.subscribers.clear(), Object.keys(this.eventListeners).forEach((t) => {
@@ -966,7 +1193,7 @@ var dn = class {
966
1193
  console.warn("Cannot start polling: no payment token available");
967
1194
  return;
968
1195
  }
969
- this.stopPolling(), this.pollingService = new an(
1196
+ this.stopPolling(), this.pollingService = new ln(
970
1197
  this.adapters,
971
1198
  this.getApiBaseUrl(),
972
1199
  this.paymentToken,
@@ -1031,11 +1258,11 @@ var dn = class {
1031
1258
  id: t.paymentIntentId,
1032
1259
  amount: t.amount ?? e.paymentIntent.amount,
1033
1260
  currency: t.currency ?? e.paymentIntent.currency,
1034
- status: D.REQUIRES_ACTION,
1261
+ status: $.REQUIRES_ACTION,
1035
1262
  ...t.metadata && { metadata: t.metadata }
1036
1263
  };
1037
1264
  this.setState({
1038
- status: D.REQUIRES_ACTION,
1265
+ status: $.REQUIRES_ACTION,
1039
1266
  paymentIntent: r,
1040
1267
  actionUrl: t.nextActionUrl,
1041
1268
  selectedMethod: e.selectedMethod,
@@ -1059,7 +1286,7 @@ var dn = class {
1059
1286
  };
1060
1287
  if (t.status === "succeeded")
1061
1288
  this.stopPolling(), this.setState({
1062
- status: D.SUCCEEDED,
1289
+ status: $.SUCCEEDED,
1063
1290
  paymentIntent: n,
1064
1291
  selectedMethod: e.selectedMethod
1065
1292
  }), this.emit({
@@ -1077,7 +1304,7 @@ var dn = class {
1077
1304
  timestamp: this.adapters.timer.now()
1078
1305
  };
1079
1306
  this.setState({
1080
- status: D.FAILED,
1307
+ status: $.FAILED,
1081
1308
  error: i,
1082
1309
  paymentIntent: n
1083
1310
  }), this.emit({
@@ -1143,7 +1370,7 @@ H.prototype = {
1143
1370
  return e.tailPrefix ? r + o.toString() + (e.numeralDecimalScale > 0 ? s.toString() : "") + e.prefix : i + o.toString() + (e.numeralDecimalScale > 0 ? s.toString() : "");
1144
1371
  }
1145
1372
  };
1146
- var cn = H, yt = function(t, e, n) {
1373
+ var un = H, yt = function(t, e, n) {
1147
1374
  var r = this;
1148
1375
  r.date = [], r.blocks = [], r.datePattern = t, r.dateMin = e.split("-").reverse().map(function(i) {
1149
1376
  return parseInt(i, 10);
@@ -1183,7 +1410,7 @@ yt.prototype = {
1183
1410
  }), this.getFixedDateString(n);
1184
1411
  },
1185
1412
  getFixedDateString: function(t) {
1186
- var e = this, n = e.datePattern, r = [], i = 0, o = 0, s = 0, l = 0, a = 0, d = 0, c, h, f, u = !1;
1413
+ var e = this, n = e.datePattern, r = [], i = 0, o = 0, s = 0, l = 0, a = 0, d = 0, c, h, m, u = !1;
1187
1414
  t.length === 4 && n[0].toLowerCase() !== "y" && n[1].toLowerCase() !== "y" && (l = n[0] === "d" ? 0 : 2, a = 2 - l, c = parseInt(t.slice(l, l + 2), 10), h = parseInt(t.slice(a, a + 2), 10), r = this.getFixedDate(c, h, 0)), t.length === 8 && (n.forEach(function(g, k) {
1188
1415
  switch (g) {
1189
1416
  case "d":
@@ -1196,8 +1423,8 @@ yt.prototype = {
1196
1423
  s = k;
1197
1424
  break;
1198
1425
  }
1199
- }), d = s * 2, l = i <= s ? i * 2 : i * 2 + 2, a = o <= s ? o * 2 : o * 2 + 2, c = parseInt(t.slice(l, l + 2), 10), h = parseInt(t.slice(a, a + 2), 10), f = parseInt(t.slice(d, d + 4), 10), u = t.slice(d, d + 4).length === 4, r = this.getFixedDate(c, h, f)), t.length === 4 && (n[0] === "y" || n[1] === "y") && (a = n[0] === "m" ? 0 : 2, d = 2 - a, h = parseInt(t.slice(a, a + 2), 10), f = parseInt(t.slice(d, d + 2), 10), u = t.slice(d, d + 2).length === 2, r = [0, h, f]), t.length === 6 && (n[0] === "Y" || n[1] === "Y") && (a = n[0] === "m" ? 0 : 4, d = 2 - 0.5 * a, h = parseInt(t.slice(a, a + 2), 10), f = parseInt(t.slice(d, d + 4), 10), u = t.slice(d, d + 4).length === 4, r = [0, h, f]), r = e.getRangeFixedDate(r), e.date = r;
1200
- var m = r.length === 0 ? t : n.reduce(function(g, k) {
1426
+ }), d = s * 2, l = i <= s ? i * 2 : i * 2 + 2, a = o <= s ? o * 2 : o * 2 + 2, c = parseInt(t.slice(l, l + 2), 10), h = parseInt(t.slice(a, a + 2), 10), m = parseInt(t.slice(d, d + 4), 10), u = t.slice(d, d + 4).length === 4, r = this.getFixedDate(c, h, m)), t.length === 4 && (n[0] === "y" || n[1] === "y") && (a = n[0] === "m" ? 0 : 2, d = 2 - a, h = parseInt(t.slice(a, a + 2), 10), m = parseInt(t.slice(d, d + 2), 10), u = t.slice(d, d + 2).length === 2, r = [0, h, m]), t.length === 6 && (n[0] === "Y" || n[1] === "Y") && (a = n[0] === "m" ? 0 : 4, d = 2 - 0.5 * a, h = parseInt(t.slice(a, a + 2), 10), m = parseInt(t.slice(d, d + 4), 10), u = t.slice(d, d + 4).length === 4, r = [0, h, m]), r = e.getRangeFixedDate(r), e.date = r;
1427
+ var f = r.length === 0 ? t : n.reduce(function(g, k) {
1201
1428
  switch (k) {
1202
1429
  case "d":
1203
1430
  return g + (r[0] === 0 ? "" : e.addLeadingZero(r[0]));
@@ -1209,7 +1436,7 @@ yt.prototype = {
1209
1436
  return g + (u ? e.addLeadingZeroForYear(r[2], !0) : "");
1210
1437
  }
1211
1438
  }, "");
1212
- return m;
1439
+ return f;
1213
1440
  },
1214
1441
  getRangeFixedDate: function(t) {
1215
1442
  var e = this, n = e.datePattern, r = e.dateMin || [], i = e.dateMax || [];
@@ -1230,7 +1457,7 @@ yt.prototype = {
1230
1457
  return e ? (t < 10 ? "000" : t < 100 ? "00" : t < 1e3 ? "0" : "") + t : (t < 10 ? "0" : "") + t;
1231
1458
  }
1232
1459
  };
1233
- var un = yt, bt = function(t, e) {
1460
+ var hn = yt, bt = function(t, e) {
1234
1461
  var n = this;
1235
1462
  n.time = [], n.blocks = [], n.timePattern = t, n.timeFormat = e, n.initBlocks();
1236
1463
  };
@@ -1283,30 +1510,30 @@ bt.prototype = {
1283
1510
  }), this.getFixedTimeString(n);
1284
1511
  },
1285
1512
  getFixedTimeString: function(t) {
1286
- var e = this, n = e.timePattern, r = [], i = 0, o = 0, s = 0, l = 0, a = 0, d = 0, c, h, f;
1287
- return t.length === 6 && (n.forEach(function(u, m) {
1513
+ var e = this, n = e.timePattern, r = [], i = 0, o = 0, s = 0, l = 0, a = 0, d = 0, c, h, m;
1514
+ return t.length === 6 && (n.forEach(function(u, f) {
1288
1515
  switch (u) {
1289
1516
  case "s":
1290
- i = m * 2;
1517
+ i = f * 2;
1291
1518
  break;
1292
1519
  case "m":
1293
- o = m * 2;
1520
+ o = f * 2;
1294
1521
  break;
1295
1522
  case "h":
1296
- s = m * 2;
1523
+ s = f * 2;
1297
1524
  break;
1298
1525
  }
1299
- }), d = s, a = o, l = i, c = parseInt(t.slice(l, l + 2), 10), h = parseInt(t.slice(a, a + 2), 10), f = parseInt(t.slice(d, d + 2), 10), r = this.getFixedTime(f, h, c)), t.length === 4 && e.timePattern.indexOf("s") < 0 && (n.forEach(function(u, m) {
1526
+ }), d = s, a = o, l = i, c = parseInt(t.slice(l, l + 2), 10), h = parseInt(t.slice(a, a + 2), 10), m = parseInt(t.slice(d, d + 2), 10), r = this.getFixedTime(m, h, c)), t.length === 4 && e.timePattern.indexOf("s") < 0 && (n.forEach(function(u, f) {
1300
1527
  switch (u) {
1301
1528
  case "m":
1302
- o = m * 2;
1529
+ o = f * 2;
1303
1530
  break;
1304
1531
  case "h":
1305
- s = m * 2;
1532
+ s = f * 2;
1306
1533
  break;
1307
1534
  }
1308
- }), d = s, a = o, c = 0, h = parseInt(t.slice(a, a + 2), 10), f = parseInt(t.slice(d, d + 2), 10), r = this.getFixedTime(f, h, c)), e.time = r, r.length === 0 ? t : n.reduce(function(u, m) {
1309
- switch (m) {
1535
+ }), d = s, a = o, c = 0, h = parseInt(t.slice(a, a + 2), 10), m = parseInt(t.slice(d, d + 2), 10), r = this.getFixedTime(m, h, c)), e.time = r, r.length === 0 ? t : n.reduce(function(u, f) {
1536
+ switch (f) {
1310
1537
  case "s":
1311
1538
  return u + e.addLeadingZero(r[2]);
1312
1539
  case "m":
@@ -1323,7 +1550,7 @@ bt.prototype = {
1323
1550
  return (t < 10 ? "0" : "") + t;
1324
1551
  }
1325
1552
  };
1326
- var hn = bt, wt = function(t, e) {
1553
+ var mn = bt, wt = function(t, e) {
1327
1554
  var n = this;
1328
1555
  n.delimiter = e || e === "" ? e : " ", n.delimiterRE = e ? new RegExp("\\" + e, "g") : "", n.formatter = t;
1329
1556
  };
@@ -1406,7 +1633,7 @@ var fn = wt, Fe = {
1406
1633
  blocks: e ? this.getStrictBlocks(n.general) : n.general
1407
1634
  };
1408
1635
  }
1409
- }, mn = Fe, pn = {
1636
+ }, pn = Fe, gn = {
1410
1637
  noop: function() {
1411
1638
  },
1412
1639
  strip: function(t, e) {
@@ -1482,8 +1709,8 @@ var fn = wt, Fe = {
1482
1709
  var s = "", l = i.length > 0, a = "";
1483
1710
  return n === 0 ? t : (e.forEach(function(d, c) {
1484
1711
  if (t.length > 0) {
1485
- var h = t.slice(0, d), f = t.slice(d);
1486
- l ? a = i[o ? c - 1 : c] || a : a = r, o ? (c > 0 && (s += a), s += h) : (s += h, h.length === d && c < n - 1 && (s += a)), t = f;
1712
+ var h = t.slice(0, d), m = t.slice(d);
1713
+ l ? a = i[o ? c - 1 : c] || a : a = r, o ? (c > 0 && (s += a), s += h) : (s += h, h.length === d && c < n - 1 && (s += a)), t = m;
1487
1714
  }
1488
1715
  }), s);
1489
1716
  },
@@ -1535,7 +1762,7 @@ var fn = wt, Fe = {
1535
1762
  isAndroidBackspaceKeydown: function(t, e) {
1536
1763
  return !this.isAndroid() || !t || !e ? !1 : e === t.slice(0, -1);
1537
1764
  }
1538
- }, gn = pn, yn = {
1765
+ }, yn = gn, bn = {
1539
1766
  // Maybe change to object-assign
1540
1767
  // for now just keep it as simple
1541
1768
  assign: function(t, e) {
@@ -1543,7 +1770,7 @@ var fn = wt, Fe = {
1543
1770
  }, t.phone = !!e.phone, t.phoneRegionCode = e.phoneRegionCode || "AU", t.phoneFormatter = {}, t.time = !!e.time, t.timePattern = e.timePattern || ["h", "m", "s"], t.timeFormat = e.timeFormat || "24", t.timeFormatter = {}, t.date = !!e.date, t.datePattern = e.datePattern || ["d", "m", "Y"], t.dateMin = e.dateMin || "", t.dateMax = e.dateMax || "", t.dateFormatter = {}, t.numeral = !!e.numeral, t.numeralIntegerScale = e.numeralIntegerScale > 0 ? e.numeralIntegerScale : 0, t.numeralDecimalScale = e.numeralDecimalScale >= 0 ? e.numeralDecimalScale : 2, t.numeralDecimalMark = e.numeralDecimalMark || ".", t.numeralThousandsGroupStyle = e.numeralThousandsGroupStyle || "thousand", t.numeralPositiveOnly = !!e.numeralPositiveOnly, t.stripLeadingZeroes = e.stripLeadingZeroes !== !1, t.signBeforePrefix = !!e.signBeforePrefix, t.tailPrefix = !!e.tailPrefix, t.swapHiddenInput = !!e.swapHiddenInput, t.numericOnly = t.creditCard || t.date || !!e.numericOnly, t.uppercase = !!e.uppercase, t.lowercase = !!e.lowercase, t.prefix = t.creditCard || t.date ? "" : e.prefix || "", t.noImmediatePrefix = !!e.noImmediatePrefix, t.prefixLength = t.prefix.length, t.rawValueTrimPrefix = !!e.rawValueTrimPrefix, t.copyDelimiter = !!e.copyDelimiter, t.initValue = e.initValue !== void 0 && e.initValue !== null ? e.initValue.toString() : "", t.delimiter = e.delimiter || e.delimiter === "" ? e.delimiter : e.date ? "/" : e.time ? ":" : e.numeral ? "," : (e.phone, " "), t.delimiterLength = t.delimiter.length, t.delimiterLazyShow = !!e.delimiterLazyShow, t.delimiters = e.delimiters || [], t.blocks = e.blocks || [], t.blocksLength = t.blocks.length, t.root = typeof Z == "object" && Z ? Z : window, t.document = e.document || t.root.document, t.maxLength = 0, t.backspace = !1, t.result = "", t.onValueChanged = e.onValueChanged || function() {
1544
1771
  }, t;
1545
1772
  }
1546
- }, bn = yn, x = function(t, e) {
1773
+ }, wn = bn, x = function(t, e) {
1547
1774
  var n = this, r = !1;
1548
1775
  if (typeof t == "string" ? (n.element = document.querySelector(t), r = document.querySelectorAll(t).length > 1) : typeof t.length < "u" && t.length > 0 ? (n.element = t[0], r = t.length > 1) : n.element = t, !n.element)
1549
1776
  throw new Error("[cleave.js] Please check the element");
@@ -1714,19 +1941,19 @@ x.prototype = {
1714
1941
  return "[Cleave Object]";
1715
1942
  }
1716
1943
  };
1717
- x.NumeralFormatter = cn;
1718
- x.DateFormatter = un;
1719
- x.TimeFormatter = hn;
1944
+ x.NumeralFormatter = un;
1945
+ x.DateFormatter = hn;
1946
+ x.TimeFormatter = mn;
1720
1947
  x.PhoneFormatter = fn;
1721
- x.CreditCardDetector = mn;
1722
- x.Util = gn;
1723
- x.DefaultProperties = bn;
1948
+ x.CreditCardDetector = pn;
1949
+ x.Util = yn;
1950
+ x.DefaultProperties = wn;
1724
1951
  (typeof Z == "object" && Z ? Z : window).Cleave = x;
1725
- var at = x, fe = {}, wn = function() {
1952
+ var at = x, me = {}, vn = function() {
1726
1953
  return typeof Promise == "function" && Promise.prototype && Promise.prototype.then;
1727
- }, vt = {}, $ = {};
1954
+ }, vt = {}, D = {};
1728
1955
  let Ye;
1729
- const vn = [
1956
+ const xn = [
1730
1957
  0,
1731
1958
  // Not used
1732
1959
  26,
@@ -1770,29 +1997,29 @@ const vn = [
1770
1997
  3532,
1771
1998
  3706
1772
1999
  ];
1773
- $.getSymbolSize = function(e) {
2000
+ D.getSymbolSize = function(e) {
1774
2001
  if (!e) throw new Error('"version" cannot be null or undefined');
1775
2002
  if (e < 1 || e > 40) throw new Error('"version" should be in range from 1 to 40');
1776
2003
  return e * 4 + 17;
1777
2004
  };
1778
- $.getSymbolTotalCodewords = function(e) {
1779
- return vn[e];
2005
+ D.getSymbolTotalCodewords = function(e) {
2006
+ return xn[e];
1780
2007
  };
1781
- $.getBCHDigit = function(t) {
2008
+ D.getBCHDigit = function(t) {
1782
2009
  let e = 0;
1783
2010
  for (; t !== 0; )
1784
2011
  e++, t >>>= 1;
1785
2012
  return e;
1786
2013
  };
1787
- $.setToSJISFunction = function(e) {
2014
+ D.setToSJISFunction = function(e) {
1788
2015
  if (typeof e != "function")
1789
2016
  throw new Error('"toSJISFunc" is not a valid function.');
1790
2017
  Ye = e;
1791
2018
  };
1792
- $.isKanjiModeEnabled = function() {
2019
+ D.isKanjiModeEnabled = function() {
1793
2020
  return typeof Ye < "u";
1794
2021
  };
1795
- $.toSJIS = function(e) {
2022
+ D.toSJIS = function(e) {
1796
2023
  return Ye(e);
1797
2024
  };
1798
2025
  var Ce = {};
@@ -1850,28 +2077,28 @@ xt.prototype = {
1850
2077
  this.buffer.length <= e && this.buffer.push(0), t && (this.buffer[e] |= 128 >>> this.length % 8), this.length++;
1851
2078
  }
1852
2079
  };
1853
- var xn = xt;
1854
- function me(t) {
2080
+ var Sn = xt;
2081
+ function fe(t) {
1855
2082
  if (!t || t < 1)
1856
2083
  throw new Error("BitMatrix size must be defined and greater than 0");
1857
2084
  this.size = t, this.data = new Uint8Array(t * t), this.reservedBit = new Uint8Array(t * t);
1858
2085
  }
1859
- me.prototype.set = function(t, e, n, r) {
2086
+ fe.prototype.set = function(t, e, n, r) {
1860
2087
  const i = t * this.size + e;
1861
2088
  this.data[i] = n, r && (this.reservedBit[i] = !0);
1862
2089
  };
1863
- me.prototype.get = function(t, e) {
2090
+ fe.prototype.get = function(t, e) {
1864
2091
  return this.data[t * this.size + e];
1865
2092
  };
1866
- me.prototype.xor = function(t, e, n) {
2093
+ fe.prototype.xor = function(t, e, n) {
1867
2094
  this.data[t * this.size + e] ^= n;
1868
2095
  };
1869
- me.prototype.isReserved = function(t, e) {
2096
+ fe.prototype.isReserved = function(t, e) {
1870
2097
  return this.reservedBit[t * this.size + e];
1871
2098
  };
1872
- var Sn = me, St = {};
2099
+ var Cn = fe, St = {};
1873
2100
  (function(t) {
1874
- const e = $.getSymbolSize;
2101
+ const e = D.getSymbolSize;
1875
2102
  t.getRowColCoords = function(r) {
1876
2103
  if (r === 1) return [];
1877
2104
  const i = Math.floor(r / 7) + 2, o = e(r), s = o === 145 ? 26 : Math.ceil((o - 13) / (2 * i - 2)) * 2, l = [o - 7];
@@ -1889,9 +2116,9 @@ var Sn = me, St = {};
1889
2116
  };
1890
2117
  })(St);
1891
2118
  var Ct = {};
1892
- const Cn = $.getSymbolSize, lt = 7;
2119
+ const kn = D.getSymbolSize, lt = 7;
1893
2120
  Ct.getPositions = function(e) {
1894
- const n = Cn(e);
2121
+ const n = kn(e);
1895
2122
  return [
1896
2123
  // top-left
1897
2124
  [0, 0],
@@ -1928,9 +2155,9 @@ var kt = {};
1928
2155
  let s = 0, l = 0, a = 0, d = null, c = null;
1929
2156
  for (let h = 0; h < o; h++) {
1930
2157
  l = a = 0, d = c = null;
1931
- for (let f = 0; f < o; f++) {
1932
- let u = i.get(h, f);
1933
- u === d ? l++ : (l >= 5 && (s += e.N1 + (l - 5)), d = u, l = 1), u = i.get(f, h), u === c ? a++ : (a >= 5 && (s += e.N1 + (a - 5)), c = u, a = 1);
2158
+ for (let m = 0; m < o; m++) {
2159
+ let u = i.get(h, m);
2160
+ u === d ? l++ : (l >= 5 && (s += e.N1 + (l - 5)), d = u, l = 1), u = i.get(m, h), u === c ? a++ : (a >= 5 && (s += e.N1 + (a - 5)), c = u, a = 1);
1934
2161
  }
1935
2162
  l >= 5 && (s += e.N1 + (l - 5)), a >= 5 && (s += e.N1 + (a - 5));
1936
2163
  }
@@ -2415,30 +2642,30 @@ Ke.prototype.encode = function(e) {
2415
2642
  }
2416
2643
  return r;
2417
2644
  };
2418
- var kn = Ke, Pt = {}, O = {}, Qe = {};
2645
+ var En = Ke, Pt = {}, O = {}, Qe = {};
2419
2646
  Qe.isValid = function(e) {
2420
2647
  return !isNaN(e) && e >= 1 && e <= 40;
2421
2648
  };
2422
2649
  var R = {};
2423
- const It = "[0-9]+", En = "[A-Z $%*+\\-./:]+";
2650
+ const It = "[0-9]+", An = "[A-Z $%*+\\-./:]+";
2424
2651
  let ue = "(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";
2425
2652
  ue = ue.replace(/u/g, "\\u");
2426
- const An = "(?:(?![A-Z0-9 $%*+\\-./:]|" + ue + `)(?:.|[\r
2653
+ const Pn = "(?:(?![A-Z0-9 $%*+\\-./:]|" + ue + `)(?:.|[\r
2427
2654
  ]))+`;
2428
2655
  R.KANJI = new RegExp(ue, "g");
2429
2656
  R.BYTE_KANJI = new RegExp("[^A-Z0-9 $%*+\\-./:]+", "g");
2430
- R.BYTE = new RegExp(An, "g");
2657
+ R.BYTE = new RegExp(Pn, "g");
2431
2658
  R.NUMERIC = new RegExp(It, "g");
2432
- R.ALPHANUMERIC = new RegExp(En, "g");
2433
- const Pn = new RegExp("^" + ue + "$"), In = new RegExp("^" + It + "$"), _n = new RegExp("^[A-Z0-9 $%*+\\-./:]+$");
2659
+ R.ALPHANUMERIC = new RegExp(An, "g");
2660
+ const In = new RegExp("^" + ue + "$"), _n = new RegExp("^" + It + "$"), Dn = new RegExp("^[A-Z0-9 $%*+\\-./:]+$");
2434
2661
  R.testKanji = function(e) {
2435
- return Pn.test(e);
2662
+ return In.test(e);
2436
2663
  };
2437
2664
  R.testNumeric = function(e) {
2438
- return In.test(e);
2665
+ return _n.test(e);
2439
2666
  };
2440
2667
  R.testAlphanumeric = function(e) {
2441
- return _n.test(e);
2668
+ return Dn.test(e);
2442
2669
  };
2443
2670
  (function(t) {
2444
2671
  const e = Qe, n = R;
@@ -2500,34 +2727,34 @@ R.testAlphanumeric = function(e) {
2500
2727
  };
2501
2728
  })(O);
2502
2729
  (function(t) {
2503
- const e = $, n = ke, r = Ce, i = O, o = Qe, s = 7973, l = e.getBCHDigit(s);
2504
- function a(f, u, m) {
2730
+ const e = D, n = ke, r = Ce, i = O, o = Qe, s = 7973, l = e.getBCHDigit(s);
2731
+ function a(m, u, f) {
2505
2732
  for (let g = 1; g <= 40; g++)
2506
- if (u <= t.getCapacity(g, m, f))
2733
+ if (u <= t.getCapacity(g, f, m))
2507
2734
  return g;
2508
2735
  }
2509
- function d(f, u) {
2510
- return i.getCharCountIndicator(f, u) + 4;
2736
+ function d(m, u) {
2737
+ return i.getCharCountIndicator(m, u) + 4;
2511
2738
  }
2512
- function c(f, u) {
2513
- let m = 0;
2514
- return f.forEach(function(g) {
2739
+ function c(m, u) {
2740
+ let f = 0;
2741
+ return m.forEach(function(g) {
2515
2742
  const k = d(g.mode, u);
2516
- m += k + g.getBitsLength();
2517
- }), m;
2743
+ f += k + g.getBitsLength();
2744
+ }), f;
2518
2745
  }
2519
- function h(f, u) {
2520
- for (let m = 1; m <= 40; m++)
2521
- if (c(f, m) <= t.getCapacity(m, u, i.MIXED))
2522
- return m;
2746
+ function h(m, u) {
2747
+ for (let f = 1; f <= 40; f++)
2748
+ if (c(m, f) <= t.getCapacity(f, u, i.MIXED))
2749
+ return f;
2523
2750
  }
2524
- t.from = function(u, m) {
2525
- return o.isValid(u) ? parseInt(u, 10) : m;
2526
- }, t.getCapacity = function(u, m, g) {
2751
+ t.from = function(u, f) {
2752
+ return o.isValid(u) ? parseInt(u, 10) : f;
2753
+ }, t.getCapacity = function(u, f, g) {
2527
2754
  if (!o.isValid(u))
2528
2755
  throw new Error("Invalid QR Code version");
2529
2756
  typeof g > "u" && (g = i.BYTE);
2530
- const k = e.getSymbolTotalCodewords(u), b = n.getTotalCodewordsCount(u, m), w = (k - b) * 8;
2757
+ const k = e.getSymbolTotalCodewords(u), b = n.getTotalCodewordsCount(u, f), w = (k - b) * 8;
2531
2758
  if (g === i.MIXED) return w;
2532
2759
  const y = w - d(g, u);
2533
2760
  switch (g) {
@@ -2541,9 +2768,9 @@ R.testAlphanumeric = function(e) {
2541
2768
  default:
2542
2769
  return Math.floor(y / 8);
2543
2770
  }
2544
- }, t.getBestVersionForData = function(u, m) {
2771
+ }, t.getBestVersionForData = function(u, f) {
2545
2772
  let g;
2546
- const k = r.from(m, r.M);
2773
+ const k = r.from(f, r.M);
2547
2774
  if (Array.isArray(u)) {
2548
2775
  if (u.length > 1)
2549
2776
  return h(u, k);
@@ -2556,25 +2783,25 @@ R.testAlphanumeric = function(e) {
2556
2783
  }, t.getEncodedBits = function(u) {
2557
2784
  if (!o.isValid(u) || u < 7)
2558
2785
  throw new Error("Invalid QR Code version");
2559
- let m = u << 12;
2560
- for (; e.getBCHDigit(m) - l >= 0; )
2561
- m ^= s << e.getBCHDigit(m) - l;
2562
- return u << 12 | m;
2786
+ let f = u << 12;
2787
+ for (; e.getBCHDigit(f) - l >= 0; )
2788
+ f ^= s << e.getBCHDigit(f) - l;
2789
+ return u << 12 | f;
2563
2790
  };
2564
2791
  })(Pt);
2565
2792
  var _t = {};
2566
- const Le = $, $t = 1335, $n = 21522, dt = Le.getBCHDigit($t);
2793
+ const Le = D, Dt = 1335, $n = 21522, dt = Le.getBCHDigit(Dt);
2567
2794
  _t.getEncodedBits = function(e, n) {
2568
2795
  const r = e.bit << 3 | n;
2569
2796
  let i = r << 10;
2570
2797
  for (; Le.getBCHDigit(i) - dt >= 0; )
2571
- i ^= $t << Le.getBCHDigit(i) - dt;
2798
+ i ^= Dt << Le.getBCHDigit(i) - dt;
2572
2799
  return (r << 10 | i) ^ $n;
2573
2800
  };
2574
- var Dt = {};
2575
- const Dn = O;
2801
+ var $t = {};
2802
+ const Mn = O;
2576
2803
  function W(t) {
2577
- this.mode = Dn.NUMERIC, this.data = t.toString();
2804
+ this.mode = Mn.NUMERIC, this.data = t.toString();
2578
2805
  }
2579
2806
  W.getBitsLength = function(e) {
2580
2807
  return 10 * Math.floor(e / 3) + (e % 3 ? e % 3 * 3 + 1 : 0);
@@ -2592,8 +2819,8 @@ W.prototype.write = function(e) {
2592
2819
  const o = this.data.length - n;
2593
2820
  o > 0 && (r = this.data.substr(n), i = parseInt(r, 10), e.put(i, o * 3 + 1));
2594
2821
  };
2595
- var Mn = W;
2596
- const Tn = O, Me = [
2822
+ var Tn = W;
2823
+ const Nn = O, Me = [
2597
2824
  "0",
2598
2825
  "1",
2599
2826
  "2",
@@ -2641,7 +2868,7 @@ const Tn = O, Me = [
2641
2868
  ":"
2642
2869
  ];
2643
2870
  function X(t) {
2644
- this.mode = Tn.ALPHANUMERIC, this.data = t;
2871
+ this.mode = Nn.ALPHANUMERIC, this.data = t;
2645
2872
  }
2646
2873
  X.getBitsLength = function(e) {
2647
2874
  return 11 * Math.floor(e / 2) + 6 * (e % 2);
@@ -2660,10 +2887,10 @@ X.prototype.write = function(e) {
2660
2887
  }
2661
2888
  this.data.length % 2 && e.put(Me.indexOf(this.data[n]), 6);
2662
2889
  };
2663
- var Nn = X;
2664
- const Rn = O;
2890
+ var Rn = X;
2891
+ const Bn = O;
2665
2892
  function ee(t) {
2666
- this.mode = Rn.BYTE, typeof t == "string" ? this.data = new TextEncoder().encode(t) : this.data = new Uint8Array(t);
2893
+ this.mode = Bn.BYTE, typeof t == "string" ? this.data = new TextEncoder().encode(t) : this.data = new Uint8Array(t);
2667
2894
  }
2668
2895
  ee.getBitsLength = function(e) {
2669
2896
  return e * 8;
@@ -2678,10 +2905,10 @@ ee.prototype.write = function(t) {
2678
2905
  for (let e = 0, n = this.data.length; e < n; e++)
2679
2906
  t.put(this.data[e], 8);
2680
2907
  };
2681
- var Bn = ee;
2682
- const Fn = O, Ln = $;
2908
+ var Fn = ee;
2909
+ const Ln = O, Un = D;
2683
2910
  function te(t) {
2684
- this.mode = Fn.KANJI, this.data = t;
2911
+ this.mode = Ln.KANJI, this.data = t;
2685
2912
  }
2686
2913
  te.getBitsLength = function(e) {
2687
2914
  return e * 13;
@@ -2695,7 +2922,7 @@ te.prototype.getBitsLength = function() {
2695
2922
  te.prototype.write = function(t) {
2696
2923
  let e;
2697
2924
  for (e = 0; e < this.data.length; e++) {
2698
- let n = Ln.toSJIS(this.data[e]);
2925
+ let n = Un.toSJIS(this.data[e]);
2699
2926
  if (n >= 33088 && n <= 40956)
2700
2927
  n -= 33088;
2701
2928
  else if (n >= 57408 && n <= 60351)
@@ -2708,7 +2935,7 @@ Make sure your charset is UTF-8`
2708
2935
  n = (n >>> 8 & 255) * 192 + (n & 255), t.put(n, 13);
2709
2936
  }
2710
2937
  };
2711
- var Un = te, Mt = { exports: {} };
2938
+ var zn = te, Mt = { exports: {} };
2712
2939
  (function(t) {
2713
2940
  var e = {
2714
2941
  single_source_shortest_paths: function(n, r, i) {
@@ -2716,10 +2943,10 @@ var Un = te, Mt = { exports: {} };
2716
2943
  s[r] = 0;
2717
2944
  var l = e.PriorityQueue.make();
2718
2945
  l.push(r, 0);
2719
- for (var a, d, c, h, f, u, m, g, k; !l.empty(); ) {
2720
- a = l.pop(), d = a.value, h = a.cost, f = n[d] || {};
2721
- for (c in f)
2722
- f.hasOwnProperty(c) && (u = f[c], m = h + u, g = s[c], k = typeof s[c] > "u", (k || g > m) && (s[c] = m, l.push(c, m), o[c] = d));
2946
+ for (var a, d, c, h, m, u, f, g, k; !l.empty(); ) {
2947
+ a = l.pop(), d = a.value, h = a.cost, m = n[d] || {};
2948
+ for (c in m)
2949
+ m.hasOwnProperty(c) && (u = m[c], f = h + u, g = s[c], k = typeof s[c] > "u", (k || g > f) && (s[c] = f, l.push(c, f), o[c] = d));
2723
2950
  }
2724
2951
  if (typeof i < "u" && typeof s[i] > "u") {
2725
2952
  var b = ["Could not find a path from ", r, " to ", i, "."].join("");
@@ -2774,9 +3001,9 @@ var Un = te, Mt = { exports: {} };
2774
3001
  };
2775
3002
  t.exports = e;
2776
3003
  })(Mt);
2777
- var zn = Mt.exports;
3004
+ var On = Mt.exports;
2778
3005
  (function(t) {
2779
- const e = O, n = Mn, r = Nn, i = Bn, o = Un, s = R, l = $, a = zn;
3006
+ const e = O, n = Tn, r = Rn, i = Fn, o = zn, s = R, l = D, a = On;
2780
3007
  function d(b) {
2781
3008
  return unescape(encodeURIComponent(b)).length;
2782
3009
  }
@@ -2805,7 +3032,7 @@ var zn = Mt.exports;
2805
3032
  };
2806
3033
  });
2807
3034
  }
2808
- function f(b, w) {
3035
+ function m(b, w) {
2809
3036
  switch (w) {
2810
3037
  case e.NUMERIC:
2811
3038
  return n.getBitsLength(b);
@@ -2823,7 +3050,7 @@ var zn = Mt.exports;
2823
3050
  return p && p.mode === y.mode ? (w[w.length - 1].data += y.data, w) : (w.push(y), w);
2824
3051
  }, []);
2825
3052
  }
2826
- function m(b) {
3053
+ function f(b) {
2827
3054
  const w = [];
2828
3055
  for (let y = 0; y < b.length; y++) {
2829
3056
  const p = b[y];
@@ -2865,7 +3092,7 @@ var zn = Mt.exports;
2865
3092
  T.push(ne), y[ne] = { node: N, lastCount: 0 }, p[ne] = {};
2866
3093
  for (let Pe = 0; Pe < C.length; Pe++) {
2867
3094
  const B = C[Pe];
2868
- y[B] && y[B].node.mode === N.mode ? (p[B][ne] = f(y[B].lastCount + N.length, N.mode) - f(y[B].lastCount, N.mode), y[B].lastCount += N.length) : (y[B] && (y[B].lastCount = N.length), p[B][ne] = f(N.length, N.mode) + 4 + e.getCharCountIndicator(N.mode, w));
3095
+ y[B] && y[B].node.mode === N.mode ? (p[B][ne] = m(y[B].lastCount + N.length, N.mode) - m(y[B].lastCount, N.mode), y[B].lastCount += N.length) : (y[B] && (y[B].lastCount = N.length), p[B][ne] = m(N.length, N.mode) + 4 + e.getCharCountIndicator(N.mode, w));
2869
3096
  }
2870
3097
  }
2871
3098
  C = T;
@@ -2896,7 +3123,7 @@ var zn = Mt.exports;
2896
3123
  return typeof p == "string" ? y.push(k(p, null)) : p.data && y.push(k(p.data, p.mode)), y;
2897
3124
  }, []);
2898
3125
  }, t.fromString = function(w, y) {
2899
- const p = h(w, l.isKanjiModeEnabled()), C = m(p), E = g(C, y), P = a.find_path(E.map, "start", "end"), T = [];
3126
+ const p = h(w, l.isKanjiModeEnabled()), C = f(p), E = g(C, y), P = a.find_path(E.map, "start", "end"), T = [];
2900
3127
  for (let F = 1; F < P.length - 1; F++)
2901
3128
  T.push(E.table[P[F]].node);
2902
3129
  return t.fromArray(u(T));
@@ -2905,10 +3132,10 @@ var zn = Mt.exports;
2905
3132
  h(w, l.isKanjiModeEnabled())
2906
3133
  );
2907
3134
  };
2908
- })(Dt);
2909
- const Ae = $, Te = Ce, On = xn, qn = Sn, Vn = St, Hn = Ct, Ue = kt, ze = ke, jn = kn, xe = Pt, Yn = _t, Kn = O, Ne = Dt;
2910
- function Qn(t, e) {
2911
- const n = t.size, r = Hn.getPositions(e);
3135
+ })($t);
3136
+ const Ae = D, Te = Ce, qn = Sn, Vn = Cn, Hn = St, jn = Ct, Ue = kt, ze = ke, Yn = En, xe = Pt, Kn = _t, Qn = O, Ne = $t;
3137
+ function Zn(t, e) {
3138
+ const n = t.size, r = jn.getPositions(e);
2912
3139
  for (let i = 0; i < r.length; i++) {
2913
3140
  const o = r[i][0], s = r[i][1];
2914
3141
  for (let l = -1; l <= 7; l++)
@@ -2917,15 +3144,15 @@ function Qn(t, e) {
2917
3144
  s + a <= -1 || n <= s + a || (l >= 0 && l <= 6 && (a === 0 || a === 6) || a >= 0 && a <= 6 && (l === 0 || l === 6) || l >= 2 && l <= 4 && a >= 2 && a <= 4 ? t.set(o + l, s + a, !0, !0) : t.set(o + l, s + a, !1, !0));
2918
3145
  }
2919
3146
  }
2920
- function Zn(t) {
3147
+ function Gn(t) {
2921
3148
  const e = t.size;
2922
3149
  for (let n = 8; n < e - 8; n++) {
2923
3150
  const r = n % 2 === 0;
2924
3151
  t.set(n, 6, r, !0), t.set(6, n, r, !0);
2925
3152
  }
2926
3153
  }
2927
- function Gn(t, e) {
2928
- const n = Vn.getPositions(e);
3154
+ function Jn(t, e) {
3155
+ const n = Hn.getPositions(e);
2929
3156
  for (let r = 0; r < n.length; r++) {
2930
3157
  const i = n[r][0], o = n[r][1];
2931
3158
  for (let s = -2; s <= 2; s++)
@@ -2933,20 +3160,20 @@ function Gn(t, e) {
2933
3160
  s === -2 || s === 2 || l === -2 || l === 2 || s === 0 && l === 0 ? t.set(i + s, o + l, !0, !0) : t.set(i + s, o + l, !1, !0);
2934
3161
  }
2935
3162
  }
2936
- function Jn(t, e) {
3163
+ function Wn(t, e) {
2937
3164
  const n = t.size, r = xe.getEncodedBits(e);
2938
3165
  let i, o, s;
2939
3166
  for (let l = 0; l < 18; l++)
2940
3167
  i = Math.floor(l / 3), o = l % 3 + n - 8 - 3, s = (r >> l & 1) === 1, t.set(i, o, s, !0), t.set(o, i, s, !0);
2941
3168
  }
2942
3169
  function Re(t, e, n) {
2943
- const r = t.size, i = Yn.getEncodedBits(e, n);
3170
+ const r = t.size, i = Kn.getEncodedBits(e, n);
2944
3171
  let o, s;
2945
3172
  for (o = 0; o < 15; o++)
2946
3173
  s = (i >> o & 1) === 1, o < 6 ? t.set(o, 8, s, !0) : o < 8 ? t.set(o + 1, 8, s, !0) : t.set(r - 15 + o, 8, s, !0), o < 8 ? t.set(8, r - o - 1, s, !0) : o < 9 ? t.set(8, 15 - o - 1 + 1, s, !0) : t.set(8, 15 - o - 1, s, !0);
2947
3174
  t.set(r - 8, 8, 1, !0);
2948
3175
  }
2949
- function Wn(t, e) {
3176
+ function Xn(t, e) {
2950
3177
  const n = t.size;
2951
3178
  let r = -1, i = n - 1, o = 7, s = 0;
2952
3179
  for (let l = n - 1; l > 0; l -= 2)
@@ -2962,10 +3189,10 @@ function Wn(t, e) {
2962
3189
  }
2963
3190
  }
2964
3191
  }
2965
- function Xn(t, e, n) {
2966
- const r = new On();
3192
+ function er(t, e, n) {
3193
+ const r = new qn();
2967
3194
  n.forEach(function(a) {
2968
- r.put(a.mode.bit, 4), r.put(a.getLength(), Kn.getCharCountIndicator(a.mode, t)), a.write(r);
3195
+ r.put(a.mode.bit, 4), r.put(a.getLength(), Qn.getCharCountIndicator(a.mode, t)), a.write(r);
2969
3196
  });
2970
3197
  const i = Ae.getSymbolTotalCodewords(t), o = ze.getTotalCodewordsCount(t, e), s = (i - o) * 8;
2971
3198
  for (r.getLengthInBits() + 4 <= s && r.put(0, 4); r.getLengthInBits() % 8 !== 0; )
@@ -2973,29 +3200,29 @@ function Xn(t, e, n) {
2973
3200
  const l = (s - r.getLengthInBits()) / 8;
2974
3201
  for (let a = 0; a < l; a++)
2975
3202
  r.put(a % 2 ? 17 : 236, 8);
2976
- return er(r, t, e);
3203
+ return tr(r, t, e);
2977
3204
  }
2978
- function er(t, e, n) {
2979
- const r = Ae.getSymbolTotalCodewords(e), i = ze.getTotalCodewordsCount(e, n), o = r - i, s = ze.getBlocksCount(e, n), l = r % s, a = s - l, d = Math.floor(r / s), c = Math.floor(o / s), h = c + 1, f = d - c, u = new jn(f);
2980
- let m = 0;
3205
+ function tr(t, e, n) {
3206
+ const r = Ae.getSymbolTotalCodewords(e), i = ze.getTotalCodewordsCount(e, n), o = r - i, s = ze.getBlocksCount(e, n), l = r % s, a = s - l, d = Math.floor(r / s), c = Math.floor(o / s), h = c + 1, m = d - c, u = new Yn(m);
3207
+ let f = 0;
2981
3208
  const g = new Array(s), k = new Array(s);
2982
3209
  let b = 0;
2983
3210
  const w = new Uint8Array(t.buffer);
2984
3211
  for (let P = 0; P < s; P++) {
2985
3212
  const T = P < a ? c : h;
2986
- g[P] = w.slice(m, m + T), k[P] = u.encode(g[P]), m += T, b = Math.max(b, T);
3213
+ g[P] = w.slice(f, f + T), k[P] = u.encode(g[P]), f += T, b = Math.max(b, T);
2987
3214
  }
2988
3215
  const y = new Uint8Array(r);
2989
3216
  let p = 0, C, E;
2990
3217
  for (C = 0; C < b; C++)
2991
3218
  for (E = 0; E < s; E++)
2992
3219
  C < g[E].length && (y[p++] = g[E][C]);
2993
- for (C = 0; C < f; C++)
3220
+ for (C = 0; C < m; C++)
2994
3221
  for (E = 0; E < s; E++)
2995
3222
  y[p++] = k[E][C];
2996
3223
  return y;
2997
3224
  }
2998
- function tr(t, e, n, r) {
3225
+ function nr(t, e, n, r) {
2999
3226
  let i;
3000
3227
  if (Array.isArray(t))
3001
3228
  i = Ne.fromArray(t);
@@ -3020,8 +3247,8 @@ The chosen QR Code version cannot contain this amount of data.
3020
3247
  Minimum version required to store current data is: ` + o + `.
3021
3248
  `
3022
3249
  );
3023
- const s = Xn(e, n, i), l = Ae.getSymbolSize(e), a = new qn(l);
3024
- return Qn(a, e), Zn(a), Gn(a, e), Re(a, n, 0), e >= 7 && Jn(a, e), Wn(a, s), isNaN(r) && (r = Ue.getBestMask(
3250
+ const s = er(e, n, i), l = Ae.getSymbolSize(e), a = new Vn(l);
3251
+ return Zn(a, e), Gn(a), Jn(a, e), Re(a, n, 0), e >= 7 && Wn(a, e), Xn(a, s), isNaN(r) && (r = Ue.getBestMask(
3025
3252
  a,
3026
3253
  Re.bind(null, a, n)
3027
3254
  )), Ue.applyMask(r, a), Re(a, n, r), {
@@ -3036,7 +3263,7 @@ vt.create = function(e, n) {
3036
3263
  if (typeof e > "u" || e === "")
3037
3264
  throw new Error("No input text");
3038
3265
  let r = Te.M, i, o;
3039
- return typeof n < "u" && (r = Te.from(n.errorCorrectionLevel, Te.M), i = xe.from(n.version), o = Ue.from(n.maskPattern), n.toSJISFunc && Ae.setToSJISFunction(n.toSJISFunc)), tr(e, i, r, o);
3266
+ return typeof n < "u" && (r = Te.from(n.errorCorrectionLevel, Te.M), i = xe.from(n.version), o = Ue.from(n.maskPattern), n.toSJISFunc && Ae.setToSJISFunction(n.toSJISFunc)), nr(e, i, r, o);
3040
3267
  };
3041
3268
  var Tt = {}, Ze = {};
3042
3269
  (function(t) {
@@ -3079,14 +3306,14 @@ var Tt = {}, Ze = {};
3079
3306
  return Math.floor((r + i.margin * 2) * o);
3080
3307
  }, t.qrToImageData = function(r, i, o) {
3081
3308
  const s = i.modules.size, l = i.modules.data, a = t.getScale(s, o), d = Math.floor((s + o.margin * 2) * a), c = o.margin * a, h = [o.color.light, o.color.dark];
3082
- for (let f = 0; f < d; f++)
3309
+ for (let m = 0; m < d; m++)
3083
3310
  for (let u = 0; u < d; u++) {
3084
- let m = (f * d + u) * 4, g = o.color.light;
3085
- if (f >= c && u >= c && f < d - c && u < d - c) {
3086
- const k = Math.floor((f - c) / a), b = Math.floor((u - c) / a);
3311
+ let f = (m * d + u) * 4, g = o.color.light;
3312
+ if (m >= c && u >= c && m < d - c && u < d - c) {
3313
+ const k = Math.floor((m - c) / a), b = Math.floor((u - c) / a);
3087
3314
  g = h[l[k * s + b] ? 1 : 0];
3088
3315
  }
3089
- r[m++] = g.r, r[m++] = g.g, r[m++] = g.b, r[m] = g.a;
3316
+ r[f++] = g.r, r[f++] = g.g, r[f++] = g.b, r[f] = g.a;
3090
3317
  }
3091
3318
  };
3092
3319
  })(Ze);
@@ -3105,8 +3332,8 @@ var Tt = {}, Ze = {};
3105
3332
  t.render = function(o, s, l) {
3106
3333
  let a = l, d = s;
3107
3334
  typeof a > "u" && (!s || !s.getContext) && (a = s, s = void 0), s || (d = r()), a = e.getOptions(a);
3108
- const c = e.getImageWidth(o.modules.size, a), h = d.getContext("2d"), f = h.createImageData(c, c);
3109
- return e.qrToImageData(f.data, o, a), n(h, d, c), h.putImageData(f, 0, 0), d;
3335
+ const c = e.getImageWidth(o.modules.size, a), h = d.getContext("2d"), m = h.createImageData(c, c);
3336
+ return e.qrToImageData(m.data, o, a), n(h, d, c), h.putImageData(m, 0, 0), d;
3110
3337
  }, t.renderToDataURL = function(o, s, l) {
3111
3338
  let a = l;
3112
3339
  typeof a > "u" && (!s || !s.getContext) && (a = s, s = void 0), a || (a = {});
@@ -3115,7 +3342,7 @@ var Tt = {}, Ze = {};
3115
3342
  };
3116
3343
  })(Tt);
3117
3344
  var Nt = {};
3118
- const nr = Ze;
3345
+ const rr = Ze;
3119
3346
  function ct(t, e) {
3120
3347
  const n = t.a / 255, r = e + '="' + t.hex + '"';
3121
3348
  return n < 1 ? r + " " + e + '-opacity="' + n.toFixed(2).slice(1) + '"' : r;
@@ -3124,7 +3351,7 @@ function Be(t, e, n) {
3124
3351
  let r = t + e;
3125
3352
  return typeof n < "u" && (r += " " + n), r;
3126
3353
  }
3127
- function rr(t, e, n) {
3354
+ function ir(t, e, n) {
3128
3355
  let r = "", i = 0, o = !1, s = 0;
3129
3356
  for (let l = 0; l < t.length; l++) {
3130
3357
  const a = Math.floor(l % e), d = Math.floor(l / e);
@@ -3133,14 +3360,14 @@ function rr(t, e, n) {
3133
3360
  return r;
3134
3361
  }
3135
3362
  Nt.render = function(e, n, r) {
3136
- const i = nr.getOptions(n), o = e.modules.size, s = e.modules.data, l = o + i.margin * 2, a = i.color.light.a ? "<path " + ct(i.color.light, "fill") + ' d="M0 0h' + l + "v" + l + 'H0z"/>' : "", d = "<path " + ct(i.color.dark, "stroke") + ' d="' + rr(s, o, i.margin) + '"/>', c = 'viewBox="0 0 ' + l + " " + l + '"', f = '<svg xmlns="http://www.w3.org/2000/svg" ' + (i.width ? 'width="' + i.width + '" height="' + i.width + '" ' : "") + c + ' shape-rendering="crispEdges">' + a + d + `</svg>
3363
+ const i = rr.getOptions(n), o = e.modules.size, s = e.modules.data, l = o + i.margin * 2, a = i.color.light.a ? "<path " + ct(i.color.light, "fill") + ' d="M0 0h' + l + "v" + l + 'H0z"/>' : "", d = "<path " + ct(i.color.dark, "stroke") + ' d="' + ir(s, o, i.margin) + '"/>', c = 'viewBox="0 0 ' + l + " " + l + '"', m = '<svg xmlns="http://www.w3.org/2000/svg" ' + (i.width ? 'width="' + i.width + '" height="' + i.width + '" ' : "") + c + ' shape-rendering="crispEdges">' + a + d + `</svg>
3137
3364
  `;
3138
- return typeof r == "function" && r(null, f), f;
3365
+ return typeof r == "function" && r(null, m), m;
3139
3366
  };
3140
- const ir = wn, Oe = vt, Rt = Tt, or = Nt;
3367
+ const or = vn, Oe = vt, Rt = Tt, sr = Nt;
3141
3368
  function Ge(t, e, n, r, i) {
3142
3369
  const o = [].slice.call(arguments, 1), s = o.length, l = typeof o[s - 1] == "function";
3143
- if (!l && !ir())
3370
+ if (!l && !or())
3144
3371
  throw new Error("Callback required as last argument");
3145
3372
  if (l) {
3146
3373
  if (s < 2)
@@ -3165,16 +3392,16 @@ function Ge(t, e, n, r, i) {
3165
3392
  i(a);
3166
3393
  }
3167
3394
  }
3168
- fe.create = Oe.create;
3169
- fe.toCanvas = Ge.bind(null, Rt.render);
3170
- fe.toDataURL = Ge.bind(null, Rt.renderToDataURL);
3171
- fe.toString = Ge.bind(null, function(t, e, n) {
3172
- return or.render(t, n);
3395
+ me.create = Oe.create;
3396
+ me.toCanvas = Ge.bind(null, Rt.render);
3397
+ me.toDataURL = Ge.bind(null, Rt.renderToDataURL);
3398
+ me.toString = Ge.bind(null, function(t, e, n) {
3399
+ return sr.render(t, n);
3173
3400
  });
3174
- var sr = Object.defineProperty, ar = Object.getOwnPropertyDescriptor, S = (t, e, n, r) => {
3175
- for (var i = r > 1 ? void 0 : r ? ar(e, n) : e, o = t.length - 1, s; o >= 0; o--)
3401
+ var ar = Object.defineProperty, lr = Object.getOwnPropertyDescriptor, S = (t, e, n, r) => {
3402
+ for (var i = r > 1 ? void 0 : r ? lr(e, n) : e, o = t.length - 1, s; o >= 0; o--)
3176
3403
  (s = t[o]) && (i = (r ? s(e, n, i) : s(i)) || i);
3177
- return r && i && sr(e, n, i), i;
3404
+ return r && i && ar(e, n, i), i;
3178
3405
  };
3179
3406
  let v = class extends se {
3180
3407
  constructor() {
@@ -3183,7 +3410,7 @@ let v = class extends se {
3183
3410
  expiry: "",
3184
3411
  cvv: "",
3185
3412
  cardholderName: ""
3186
- }, this.formErrors = {}, this.paymentData = null, this.feesExpanded = !1, this.isInitializing = !0, this.cardBrand = "unknown", this.paymentLocked = !1, this.show3DSModal = !1, this.showQRModal = !1, this.nextActionUrl = null, this.qrCode = null, this.qrCodeDataUrl = null, this.qrAutoResumeTimer = null, this.qrPollingInProgress = !1, this.sdk = null, this.isInitialized = !1, this.cardNumberCleave = null, this.expiryCleave = null, this.leaveEventsCounter = 0, this.handle3DSPostMessage = (t) => {
3413
+ }, this.formErrors = {}, this.paymentData = null, this.feesExpanded = !1, this.isInitializing = !0, this.cardBrand = "unknown", this.paymentLocked = !1, this.show3DSModal = !1, this.showQRModal = !1, this.nextActionUrl = null, this.qrCode = null, this.qrCodeDataUrl = null, this.qrAutoResumeTimer = null, this.qrPollingInProgress = !1, this.sdk = null, this.isInitialized = !1, this.cardNumberCleave = null, this.expiryCleave = null, this.leaveEventsCounter = 0, this.threeDSTimeoutId = null, this.handle3DSPostMessage = (t) => {
3187
3414
  t.data === "ON_AWX_3DS_START_PAGE_LEAVE" && (this.leaveEventsCounter++, this.leaveEventsCounter > 1 && this.handle3DSComplete());
3188
3415
  };
3189
3416
  }
@@ -3196,7 +3423,7 @@ let v = class extends se {
3196
3423
  }
3197
3424
  disconnectedCallback() {
3198
3425
  var t;
3199
- super.disconnectedCallback(), (t = this.sdk) == null || t.destroy(), this.isInitialized = !1, this.destroyCleave(), window.removeEventListener("message", this.handle3DSPostMessage), this.qrAutoResumeTimer !== null && clearTimeout(this.qrAutoResumeTimer);
3426
+ super.disconnectedCallback(), (t = this.sdk) == null || t.destroy(), this.isInitialized = !1, this.destroyCleave(), window.removeEventListener("message", this.handle3DSPostMessage), this.qrAutoResumeTimer !== null && clearTimeout(this.qrAutoResumeTimer), this.threeDSTimeoutId !== null && clearTimeout(this.threeDSTimeoutId);
3200
3427
  }
3201
3428
  // --- Cleave.js Setup ---
3202
3429
  setupCleave() {
@@ -3249,7 +3476,31 @@ let v = class extends se {
3249
3476
  }
3250
3477
  initializeSDK() {
3251
3478
  var t;
3252
- !this.config || !this.adapters || !this.amount || !this.currency || !this.orderId || this.isInitialized || (this.isInitialized = !0, (t = this.sdk) == null || t.destroy(), this.sdk = new dn(this.config, this.adapters), this.sdk.subscribe((e) => {
3479
+ if (!this.config || !this.adapters || !this.amount || !this.currency || !this.orderId) {
3480
+ console.error(
3481
+ "OnePayment: Missing required props. Ensure config, adapters, amount, currency, and orderId are provided."
3482
+ );
3483
+ return;
3484
+ }
3485
+ if (!this.firstName || typeof this.firstName != "string" || this.firstName.trim() === "") {
3486
+ console.error(
3487
+ "OnePayment: firstName is required and must be a non-empty string. Customer information is required for all payment methods."
3488
+ );
3489
+ return;
3490
+ }
3491
+ if (!this.lastName || typeof this.lastName != "string" || this.lastName.trim() === "") {
3492
+ console.error(
3493
+ "OnePayment: lastName is required and must be a non-empty string. Customer information is required for all payment methods."
3494
+ );
3495
+ return;
3496
+ }
3497
+ if (!this.email || typeof this.email != "string" || this.email.trim() === "") {
3498
+ console.error(
3499
+ "OnePayment: email is required and must be a non-empty string. Customer information is required for all payment methods."
3500
+ );
3501
+ return;
3502
+ }
3503
+ this.isInitialized || (this.isInitialized = !0, (t = this.sdk) == null || t.destroy(), this.sdk = new cn(this.config, this.adapters), this.sdk.subscribe((e) => {
3253
3504
  this.currentState = e, this.dispatchEvent(
3254
3505
  new CustomEvent("state-change", {
3255
3506
  detail: { state: e },
@@ -3276,7 +3527,9 @@ let v = class extends se {
3276
3527
  }), this.sdk.on("initialized", (e) => {
3277
3528
  this.paymentData = e.payload.paymentData, this.isInitializing = !1;
3278
3529
  }), this.sdk.on("payment_requires_action", (e) => {
3279
- this.nextActionUrl = e.payload.actionUrl, this.show3DSModal = !0, this.paymentLocked = !0, this.leaveEventsCounter = 0;
3530
+ this.nextActionUrl = e.payload.actionUrl, this.show3DSModal = !0, this.paymentLocked = !0, this.leaveEventsCounter = 0, this.threeDSTimeoutId = window.setTimeout(() => {
3531
+ this.handle3DSComplete();
3532
+ }, 6e4);
3280
3533
  }), this.sdk.on(
3281
3534
  "qr_code_received",
3282
3535
  async (e) => {
@@ -3285,7 +3538,7 @@ let v = class extends se {
3285
3538
  const n = this.qrCode.startsWith("http://") || this.qrCode.startsWith("https://"), r = this.qrCode.startsWith("data:image");
3286
3539
  if (!n && !r)
3287
3540
  try {
3288
- const i = await fe.toDataURL(this.qrCode, {
3541
+ const i = await me.toDataURL(this.qrCode, {
3289
3542
  width: 300,
3290
3543
  margin: 2,
3291
3544
  color: {
@@ -3316,7 +3569,7 @@ let v = class extends se {
3316
3569
  this.qrAutoResumeTimer !== null && (clearTimeout(this.qrAutoResumeTimer), this.qrAutoResumeTimer = null), this.qrPollingInProgress = !0, this.sdk && this.sdk.resumePolling();
3317
3570
  }
3318
3571
  handle3DSComplete() {
3319
- this.show3DSModal = !1, this.nextActionUrl = null, this.leaveEventsCounter = 0, this.sdk && this.sdk.resumePolling();
3572
+ this.threeDSTimeoutId !== null && (clearTimeout(this.threeDSTimeoutId), this.threeDSTimeoutId = null), this.show3DSModal = !1, this.nextActionUrl = null, this.leaveEventsCounter = 0, this.sdk && this.sdk.resumePolling();
3320
3573
  }
3321
3574
  handleInputChange(t, e) {
3322
3575
  if (this.cardFormData = { ...this.cardFormData, [t]: e }, this.formErrors[t]) {
@@ -3575,7 +3828,7 @@ let v = class extends se {
3575
3828
  @click=${this.handleCardPayment}
3576
3829
  ?disabled=${this.currentState.status === "processing" || this.currentState.status === "requires_action"}
3577
3830
  >
3578
- ${this.currentState.status === "processing" || this.currentState.status === "requires_action" ? "Processing..." : `Pay ${this.currency} ${(this.amount / 100).toFixed(2)}`}
3831
+ ${this.currentState.status === "processing" || this.currentState.status === "requires_action" ? "Processing..." : `Pay ${this.currency} ${this.amount.toFixed(2)}`}
3579
3832
  </button>
3580
3833
  </div>
3581
3834
  </div>
@@ -3622,7 +3875,7 @@ let v = class extends se {
3622
3875
  @click=${this.handlePayNowPayment}
3623
3876
  ?disabled=${this.currentState.status === "processing" || this.currentState.status === "requires_action"}
3624
3877
  >
3625
- ${this.currentState.status === "processing" || this.currentState.status === "requires_action" ? "Processing..." : `Pay ${this.currency} ${(this.amount / 100).toFixed(2)}`}
3878
+ ${this.currentState.status === "processing" || this.currentState.status === "requires_action" ? "Processing..." : `Pay ${this.currency} ${this.amount.toFixed(2)}`}
3626
3879
  </button>
3627
3880
  </div>
3628
3881
  </div>
@@ -3633,6 +3886,14 @@ let v = class extends se {
3633
3886
  return !this.show3DSModal || !this.nextActionUrl ? null : A`
3634
3887
  <div class="modal-overlay">
3635
3888
  <div class="modal-content iframe-modal">
3889
+ <button
3890
+ class="modal-close-button"
3891
+ @click=${() => this.handle3DSComplete()}
3892
+ title="Close 3DS authentication"
3893
+ aria-label="Close 3DS authentication modal"
3894
+ >
3895
+
3896
+ </button>
3636
3897
  <iframe
3637
3898
  class="modal-iframe"
3638
3899
  src="${this.nextActionUrl}"
@@ -4756,6 +5017,35 @@ v.styles = Ft`
4756
5017
  border: none;
4757
5018
  }
4758
5019
 
5020
+ .modal-close-button {
5021
+ position: absolute;
5022
+ top: 12px;
5023
+ right: 12px;
5024
+ width: 36px;
5025
+ height: 36px;
5026
+ border-radius: 50%;
5027
+ background: rgba(0, 0, 0, 0.6);
5028
+ color: white;
5029
+ border: none;
5030
+ font-size: 20px;
5031
+ font-weight: bold;
5032
+ cursor: pointer;
5033
+ z-index: 10001;
5034
+ display: flex;
5035
+ align-items: center;
5036
+ justify-content: center;
5037
+ transition: background 0.2s ease;
5038
+ padding: 0;
5039
+ }
5040
+
5041
+ .modal-close-button:hover {
5042
+ background: rgba(0, 0, 0, 0.8);
5043
+ }
5044
+
5045
+ .modal-close-button:active {
5046
+ transform: scale(0.95);
5047
+ }
5048
+
4759
5049
  .modal-content .qr-code-section {
4760
5050
  padding: 2rem;
4761
5051
  min-height: 500px;