@usethrottle/checkout-react 2.1.0 → 2.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.cjs CHANGED
@@ -1,8 +1,13 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
6
11
  var __export = (target, all) => {
7
12
  for (var name in all)
8
13
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -15,8 +20,987 @@ var __copyProps = (to, from, except, desc) => {
15
20
  }
16
21
  return to;
17
22
  };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
18
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
32
 
33
+ // ../../node_modules/.pnpm/@gr4vy+secure-fields@2.11.1/node_modules/@gr4vy/secure-fields/lib/index.js
34
+ var require_lib = __commonJS({
35
+ "../../node_modules/.pnpm/@gr4vy+secure-fields@2.11.1/node_modules/@gr4vy/secure-fields/lib/index.js"(exports2, module2) {
36
+ "use strict";
37
+ !(function(e, t) {
38
+ if ("object" == typeof exports2 && "object" == typeof module2) module2.exports = t();
39
+ else if ("function" == typeof define && define.amd) define([], t);
40
+ else {
41
+ var r = t();
42
+ for (var n in r) ("object" == typeof exports2 ? exports2 : e)[n] = r[n];
43
+ }
44
+ })(exports2, () => (() => {
45
+ "use strict";
46
+ const e = { d: (t2, r2) => {
47
+ for (var n2 in r2) e.o(r2, n2) && !e.o(t2, n2) && Object.defineProperty(t2, n2, { enumerable: true, get: r2[n2] });
48
+ }, o: (e2, t2) => Object.prototype.hasOwnProperty.call(e2, t2), r: (e2) => {
49
+ Object.defineProperty(e2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e2, "__esModule", { value: true });
50
+ } };
51
+ let t = {};
52
+ e.r(t), e.d(t, { Events: () => o, SecureFields: () => te, SecureInput: () => W });
53
+ var r = function(e2) {
54
+ var t2 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "production";
55
+ return "https://".concat(arguments.length > 2 ? arguments[2] : void 0, ".").concat("sandbox" === t2 ? "sandbox." : "").concat(e2, ".gr4vy.app");
56
+ }, n = (e2, t2) => "".concat(e2, "?").concat(new URLSearchParams(t2).toString()), i = "@gr4vy-secure-fields-debug", o = (function(e2) {
57
+ return e2.CARD_VAULT_SUCCESS = "card-vault-success", e2.CARD_VAULT_FAILURE = "card-vault-failure", e2.FORM_CHANGE = "form-change", e2.METHOD_CHANGE = "method-change", e2.READY = "ready", e2.RESIZE = "resize", e2.CLICK_TO_PAY_INITIALIZED = "click-to-pay-initialized", e2.CLICK_TO_PAY_READY = "click-to-pay-ready", e2.CLICK_TO_PAY_SIGN_OUT = "click-to-pay-sign-out", e2.CLICK_TO_PAY_ERROR = "click-to-pay-error", e2.CLICK_TO_PAY_CANCEL = "click-to-pay-cancel", e2.CLICK_TO_PAY_CHECKOUT_WITH_NEW_CARD = "click-to-pay-checkout-with-new-card", e2.CLICK_TO_PAY_UNABLE_TO_LOAD_DPA = "click-to-pay-unable-to-load-dpa", e2.CLICK_TO_PAY_VISIBILITY_CHANGE = "click-to-pay:visibility-change", e2.CLICK_TO_PAY_CARD_FORM_VISIBILITY_CHANGE = "click-to-pay-card-form:visibility-change", e2.CLICK_TO_PAY_SIGN_IN_VISIBILITY_CHANGE = "click-to-pay-sign-in:visibility-change", e2.CLICK_TO_PAY_PROCESSING = "click-to-pay-processing", e2.CLICK_TO_PAY_AUTHENTICATE = "click-to-pay-authenticate", e2.CLICK_TO_PAY_AUTHENTICATE_FAILURE = "click-to-pay-authenticate-failure", e2.THREE_DS_START = "three-ds-start", e2.THREE_DS_FINISH = "three-ds-finish", e2;
58
+ })({}), a = (function(e2) {
59
+ return e2.REQUEST_PORT = "request-port", e2.TRANSFER_PORT = "transfer-port", e2.REQUEST_RECOGNITION_TOKEN = "request-recognition-token", e2.REQUEST_RECOGNITION_TOKEN_FAILED = "request-recognition-token-failed", e2.RECOGNITION_TOKEN = "recognition-token", e2;
60
+ })({}), s = (function(e2) {
61
+ return e2.FOCUSED = "data-secure-fields-focused", e2.INVALID = "data-secure-fields-invalid", e2.AUTOFILLED = "data-secure-fields-autofilled", e2;
62
+ })({}), c = (function(e2) {
63
+ return e2.PAYMENT_METHOD_ID_IN_USE = "You're passing a paymentMethodId to use a stored payment method, which means Secure Fields methods `addCardNumber`, `addExpiryDate` and `addClickToPay` are automatically disabled and won't render the related fields", e2.PAYMENT_METHOD_ID_DEPRECATED = "The 'paymentMethodId' prop is deprecated and will be removed in a future version. Please use the 'paymentMethod' prop instead: { paymentMethod: { id: 'your-id', scheme: 'visa' } }", e2.FIELD_PATTERN_IN_USE = "The `pattern` option can't be used on card fields, so it won't be applied here.", e2.AUTO_ADVANCE_ENABLED = "autoAdvance is enabled. Auto-advancing focus on field completion can degrade checkout UX (see WCAG 3.2.2). Use with caution.", e2.NO_RECOGNITION_TOKEN = "The recognition token couldn't be obtained or the request took too much time. It is possible that a Click to Pay user was therefore not recognised.", e2;
64
+ })({}), l = "secure-fields", d = { number: "addCardNumberField", expiryDate: "addExpiryDateField", securityCode: "addSecurityCodeField" }, h = ["01", "02", "03", "04", "05"];
65
+ function u(e2, t2) {
66
+ (null == t2 || t2 > e2.length) && (t2 = e2.length);
67
+ for (var r2 = 0, n2 = new Array(t2); r2 < t2; r2++) n2[r2] = e2[r2];
68
+ return n2;
69
+ }
70
+ function p(e2, t2) {
71
+ return (function(e3) {
72
+ if (Array.isArray(e3)) return e3;
73
+ })(e2) || (function(e3, t3) {
74
+ var r2 = null == e3 ? null : "undefined" != typeof Symbol && e3[Symbol.iterator] || e3["@@iterator"];
75
+ if (null != r2) {
76
+ var n2, i2, o2 = [], a2 = true, s2 = false;
77
+ try {
78
+ for (r2 = r2.call(e3); !(a2 = (n2 = r2.next()).done) && (o2.push(n2.value), !t3 || o2.length !== t3); a2 = true) ;
79
+ } catch (e4) {
80
+ s2 = true, i2 = e4;
81
+ } finally {
82
+ try {
83
+ a2 || null == r2.return || r2.return();
84
+ } finally {
85
+ if (s2) throw i2;
86
+ }
87
+ }
88
+ return o2;
89
+ }
90
+ })(e2, t2) || (function(e3, t3) {
91
+ if (e3) {
92
+ if ("string" == typeof e3) return u(e3, t3);
93
+ var r2 = Object.prototype.toString.call(e3).slice(8, -1);
94
+ return "Object" === r2 && e3.constructor && (r2 = e3.constructor.name), "Map" === r2 || "Set" === r2 ? Array.from(r2) : "Arguments" === r2 || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r2) ? u(e3, t3) : void 0;
95
+ }
96
+ })(e2, t2) || (function() {
97
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
98
+ })();
99
+ }
100
+ var y = new class {
101
+ subscribe(e2, t2) {
102
+ this.subscribers.push([e2, t2]);
103
+ }
104
+ unsubscribe(e2, t2) {
105
+ this.subscribers = this.subscribers.filter((r2) => {
106
+ var n2 = p(r2, 2), i2 = n2[0], o2 = n2[1];
107
+ return i2 !== e2 || o2.toString() !== t2.toString();
108
+ });
109
+ }
110
+ unsubscribeAll() {
111
+ this.subscribers = [];
112
+ }
113
+ publish(e2, t2) {
114
+ this.subscribers.forEach((r2) => {
115
+ var n2 = p(r2, 2), i2 = n2[0], o2 = n2[1];
116
+ return setTimeout(() => i2 === e2 ? o2(t2) : null, 0);
117
+ });
118
+ }
119
+ constructor() {
120
+ var e2, t2;
121
+ t2 = void 0, (e2 = "subscribers") in this ? Object.defineProperty(this, e2, { value: t2, enumerable: true, configurable: true, writable: true }) : this[e2] = t2, this.subscribers = [];
122
+ }
123
+ }();
124
+ function m(e2, t2) {
125
+ (null == t2 || t2 > e2.length) && (t2 = e2.length);
126
+ for (var r2 = 0, n2 = new Array(t2); r2 < t2; r2++) n2[r2] = e2[r2];
127
+ return n2;
128
+ }
129
+ function f(e2, t2) {
130
+ return (function(e3) {
131
+ if (Array.isArray(e3)) return e3;
132
+ })(e2) || (function(e3, t3) {
133
+ var r2 = null == e3 ? null : "undefined" != typeof Symbol && e3[Symbol.iterator] || e3["@@iterator"];
134
+ if (null != r2) {
135
+ var n2, i2, o2 = [], a2 = true, s2 = false;
136
+ try {
137
+ for (r2 = r2.call(e3); !(a2 = (n2 = r2.next()).done) && (o2.push(n2.value), !t3 || o2.length !== t3); a2 = true) ;
138
+ } catch (e4) {
139
+ s2 = true, i2 = e4;
140
+ } finally {
141
+ try {
142
+ a2 || null == r2.return || r2.return();
143
+ } finally {
144
+ if (s2) throw i2;
145
+ }
146
+ }
147
+ return o2;
148
+ }
149
+ })(e2, t2) || (function(e3, t3) {
150
+ if (e3) {
151
+ if ("string" == typeof e3) return m(e3, t3);
152
+ var r2 = Object.prototype.toString.call(e3).slice(8, -1);
153
+ return "Object" === r2 && e3.constructor && (r2 = e3.constructor.name), "Map" === r2 || "Set" === r2 ? Array.from(r2) : "Arguments" === r2 || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r2) ? m(e3, t3) : void 0;
154
+ }
155
+ })(e2, t2) || (function() {
156
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
157
+ })();
158
+ }
159
+ var v = new class {
160
+ add(e2, t2, r2) {
161
+ window.addEventListener(e2, t2), this.listeners.push([e2, t2, r2]);
162
+ }
163
+ remove(e2, t2, r2) {
164
+ var n2 = this.listeners.findIndex((n3) => {
165
+ var i3 = f(n3, 3), o3 = i3[0], a3 = i3[1], s3 = i3[2];
166
+ return o3 === e2 && a3.toString() === t2.toString() && s3 === r2;
167
+ });
168
+ if (-1 !== n2) {
169
+ var i2 = f(this.listeners.splice(n2, 1), 1), o2 = f(i2[0], 2), a2 = o2[0], s2 = o2[1];
170
+ window.removeEventListener(a2, s2);
171
+ }
172
+ }
173
+ removeAll() {
174
+ this.listeners.forEach((e2) => {
175
+ var t2 = f(e2, 2), r2 = t2[0], n2 = t2[1];
176
+ window.removeEventListener(r2, n2);
177
+ }), this.listeners = [];
178
+ }
179
+ constructor() {
180
+ var e2, t2;
181
+ t2 = [], (e2 = "listeners") in this ? Object.defineProperty(this, e2, { value: t2, enumerable: true, configurable: true, writable: true }) : this[e2] = t2;
182
+ }
183
+ }();
184
+ function b(e2, t2, r2) {
185
+ return t2 in e2 ? Object.defineProperty(e2, t2, { value: r2, enumerable: true, configurable: true, writable: true }) : e2[t2] = r2, e2;
186
+ }
187
+ function _(e2) {
188
+ for (var t2 = 1; t2 < arguments.length; t2++) {
189
+ var r2 = null != arguments[t2] ? arguments[t2] : {}, n2 = Object.keys(r2);
190
+ "function" == typeof Object.getOwnPropertySymbols && (n2 = n2.concat(Object.getOwnPropertySymbols(r2).filter(function(e3) {
191
+ return Object.getOwnPropertyDescriptor(r2, e3).enumerable;
192
+ }))), n2.forEach(function(t3) {
193
+ b(e2, t3, r2[t3]);
194
+ });
195
+ }
196
+ return e2;
197
+ }
198
+ var I = { debug: false, level: "log" }, g = (e2, t2, r2) => {
199
+ var n2 = _({}, I, r2), o2 = n2.debug, a2 = n2.level;
200
+ (o2 || "true" === localStorage.getItem(i)) && console[a2]("Gr4vy - Secure Fields - ".concat(e2), t2 || {});
201
+ }, O = (e2, t2, r2) => {
202
+ var n2, i2;
203
+ g(e2, t2, (n2 = _({}, r2), i2 = null != (i2 = { level: "warn" }) ? i2 : {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(n2, Object.getOwnPropertyDescriptors(i2)) : (function(e3) {
204
+ var t3 = Object.keys(e3);
205
+ if (Object.getOwnPropertySymbols) {
206
+ var r3 = Object.getOwnPropertySymbols(e3);
207
+ t3.push.apply(t3, r3);
208
+ }
209
+ return t3;
210
+ })(Object(i2)).forEach(function(e3) {
211
+ Object.defineProperty(n2, e3, Object.getOwnPropertyDescriptor(i2, e3));
212
+ }), n2));
213
+ };
214
+ function C(e2, t2, r2, n2, i2, o2, a2) {
215
+ try {
216
+ var s2 = e2[o2](a2), c2 = s2.value;
217
+ } catch (e3) {
218
+ return void r2(e3);
219
+ }
220
+ s2.done ? t2(c2) : Promise.resolve(c2).then(n2, i2);
221
+ }
222
+ function E(e2, t2, r2) {
223
+ return t2 in e2 ? Object.defineProperty(e2, t2, { value: r2, enumerable: true, configurable: true, writable: true }) : e2[t2] = r2, e2;
224
+ }
225
+ function T(e2) {
226
+ for (var t2 = 1; t2 < arguments.length; t2++) {
227
+ var r2 = null != arguments[t2] ? arguments[t2] : {}, n2 = Object.keys(r2);
228
+ "function" == typeof Object.getOwnPropertySymbols && (n2 = n2.concat(Object.getOwnPropertySymbols(r2).filter(function(e3) {
229
+ return Object.getOwnPropertyDescriptor(r2, e3).enumerable;
230
+ }))), n2.forEach(function(t3) {
231
+ E(e2, t3, r2[t3]);
232
+ });
233
+ }
234
+ return e2;
235
+ }
236
+ function A(e2, t2) {
237
+ return t2 = null != t2 ? t2 : {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(e2, Object.getOwnPropertyDescriptors(t2)) : (function(e3) {
238
+ var t3 = Object.keys(e3);
239
+ if (Object.getOwnPropertySymbols) {
240
+ var r2 = Object.getOwnPropertySymbols(e3);
241
+ t3.push.apply(t3, r2);
242
+ }
243
+ return t3;
244
+ })(Object(t2)).forEach(function(r2) {
245
+ Object.defineProperty(e2, r2, Object.getOwnPropertyDescriptor(t2, r2));
246
+ }), e2;
247
+ }
248
+ class S {
249
+ init(e2, t2) {
250
+ var r2;
251
+ this.challengeWindowSize = h.includes(null == t2 ? void 0 : t2.challengeWindowSize) ? t2.challengeWindowSize : "05", this.element = "string" == typeof e2 ? document.querySelector(e2) : e2;
252
+ var i2 = "gr4vy-threeds-flow-controller";
253
+ null === (r2 = document.body.querySelector("iframe#".concat(i2))) || void 0 === r2 || r2.remove();
254
+ var o2 = document.createElement("iframe");
255
+ o2.id = i2, o2.title = "ThreeDSecure", o2.style.display = "block", o2.style.border = "0px", o2.style.padding = "0px", o2.style.margin = "0px", o2.style.width = "100%", o2.style.height = "100%", o2.src = n(this.secureFields.frameUrl + "/threeds.html", { sessionId: this.secureFields.config.sessionId, parentOrigin: this.secureFields.parentOrigin, gr4vyId: this.secureFields.config.gr4vyId, environment: this.secureFields.config.environment }), this.element.appendChild(o2), this.controller = o2;
256
+ var a2 = { type: "three-ds-init", channel: l, data: { challengeWindowSize: this.challengeWindowSize } };
257
+ return o2.addEventListener("load", () => {
258
+ var e3;
259
+ null === (e3 = o2.contentWindow) || void 0 === e3 || e3.postMessage(a2, this.secureFields.frameUrl), this.resolveReady();
260
+ }, { once: true }), this.destroy(), v.add("message", this.boundListener, "three-ds"), this;
261
+ }
262
+ destroy() {
263
+ v.remove("message", this.boundListener, "three-ds");
264
+ }
265
+ listener(e2) {
266
+ return (t2 = function* () {
267
+ if (e2.origin === this.secureFields.frameUrl) {
268
+ var t3 = e2.data, r2 = t3.type, n2 = t3.data;
269
+ switch (r2) {
270
+ case o.THREE_DS_START:
271
+ y.publish(o.THREE_DS_START, A(T({}, n2), { element: this.element })), g("3DS start", e2.data.data);
272
+ break;
273
+ case o.THREE_DS_FINISH:
274
+ y.publish(o.THREE_DS_FINISH, A(T({}, n2), { element: this.element })), g("3DS finish", e2.data.data);
275
+ }
276
+ }
277
+ }, function() {
278
+ var e3 = this, r2 = arguments;
279
+ return new Promise(function(n2, i2) {
280
+ var o2 = t2.apply(e3, r2);
281
+ function a2(e4) {
282
+ C(o2, n2, i2, a2, s2, "next", e4);
283
+ }
284
+ function s2(e4) {
285
+ C(o2, n2, i2, a2, s2, "throw", e4);
286
+ }
287
+ a2(void 0);
288
+ });
289
+ }).call(this);
290
+ var t2;
291
+ }
292
+ constructor(e2) {
293
+ E(this, "secureFields", void 0), E(this, "controller", void 0), E(this, "ready", void 0), E(this, "challengeWindowSize", void 0), E(this, "element", void 0), E(this, "resolveReady", void 0), E(this, "boundListener", void 0), this.secureFields = e2, this.boundListener = this.listener.bind(this), this.ready = new Promise((e3) => {
294
+ this.resolveReady = e3;
295
+ });
296
+ }
297
+ }
298
+ function P(e2, t2, r2, n2, i2, o2, a2) {
299
+ try {
300
+ var s2 = e2[o2](a2), c2 = s2.value;
301
+ } catch (e3) {
302
+ return void r2(e3);
303
+ }
304
+ s2.done ? t2(c2) : Promise.resolve(c2).then(n2, i2);
305
+ }
306
+ class w extends Error {
307
+ constructor(e2) {
308
+ super(e2), this.name = "UnableToLoadDpaError";
309
+ }
310
+ }
311
+ var k = (e2, t2) => e2 && (e2.style.display = t2 ? "block" : "none"), N = (e2) => {
312
+ var t2, r2;
313
+ if (null === (t2 = document) || void 0 === t2 ? void 0 : t2.cookie) return null === (r2 = "; ".concat(document.cookie).match(";\\s*".concat(e2, "=([^;]+)"))) || void 0 === r2 ? void 0 : r2[1];
314
+ };
315
+ function D(e2, t2, r2, n2, i2, o2, a2) {
316
+ try {
317
+ var s2 = e2[o2](a2), c2 = s2.value;
318
+ } catch (e3) {
319
+ return void r2(e3);
320
+ }
321
+ s2.done ? t2(c2) : Promise.resolve(c2).then(n2, i2);
322
+ }
323
+ function L(e2) {
324
+ return function() {
325
+ var t2 = this, r2 = arguments;
326
+ return new Promise(function(n2, i2) {
327
+ var o2 = e2.apply(t2, r2);
328
+ function a2(e3) {
329
+ D(o2, n2, i2, a2, s2, "next", e3);
330
+ }
331
+ function s2(e3) {
332
+ D(o2, n2, i2, a2, s2, "throw", e3);
333
+ }
334
+ a2(void 0);
335
+ });
336
+ };
337
+ }
338
+ function R(e2, t2, r2) {
339
+ return t2 in e2 ? Object.defineProperty(e2, t2, { value: r2, enumerable: true, configurable: true, writable: true }) : e2[t2] = r2, e2;
340
+ }
341
+ function U() {
342
+ return U = Object.assign || function(e2) {
343
+ for (var t2 = 1; t2 < arguments.length; t2++) {
344
+ var r2 = arguments[t2];
345
+ for (var n2 in r2) Object.prototype.hasOwnProperty.call(r2, n2) && (e2[n2] = r2[n2]);
346
+ }
347
+ return e2;
348
+ }, U.apply(this, arguments);
349
+ }
350
+ function j(e2) {
351
+ for (var t2 = 1; t2 < arguments.length; t2++) {
352
+ var r2 = null != arguments[t2] ? arguments[t2] : {}, n2 = Object.keys(r2);
353
+ "function" == typeof Object.getOwnPropertySymbols && (n2 = n2.concat(Object.getOwnPropertySymbols(r2).filter(function(e3) {
354
+ return Object.getOwnPropertyDescriptor(r2, e3).enumerable;
355
+ }))), n2.forEach(function(t3) {
356
+ R(e2, t3, r2[t3]);
357
+ });
358
+ }
359
+ return e2;
360
+ }
361
+ class M {
362
+ _addIframe(e2, t2, r2, i2) {
363
+ var o2 = document.createElement("iframe");
364
+ return o2.id = e2, o2.title = t2, o2.setAttribute("width", "100%"), o2.setAttribute("frameborder", "0"), o2.setAttribute("style", "height:0px"), o2.src = n(r2, i2), o2;
365
+ }
366
+ _attachListeners() {
367
+ var e2 = new MessageChannel(), t2 = true, r2 = (r3) => {
368
+ var n2 = r3.origin, i2 = r3.data, s2 = i2.type, d2 = i2.data;
369
+ switch (n2) {
370
+ case this.origin:
371
+ switch (s2) {
372
+ case o.RESIZE:
373
+ this.controller.style.height = "".concat(d2.height > 0 ? d2.height + 48 : 0, "px");
374
+ break;
375
+ case o.METHOD_CHANGE:
376
+ var h2 = d2.method || "card";
377
+ (this.secureFields.method !== h2 || t2) && (t2 = false, this.secureFields.updateMethod(h2, { data: d2 }), k(this.cardForm, "card" === h2), y.publish(o.CLICK_TO_PAY_CARD_FORM_VISIBILITY_CHANGE, "card" === h2));
378
+ break;
379
+ case o.CLICK_TO_PAY_INITIALIZED:
380
+ y.publish(o.CLICK_TO_PAY_INITIALIZED, this.clickToPay), g("Click to Pay initialized", this.clickToPay), k(this.signIn, false), y.publish(o.CLICK_TO_PAY_SIGN_IN_VISIBILITY_CHANGE, false), k(this.clickToPay.element, true), y.publish(o.CLICK_TO_PAY_VISIBILITY_CHANGE, true);
381
+ break;
382
+ case o.CLICK_TO_PAY_READY:
383
+ this._buyerExists = d2.buyerExists, y.publish(o.CLICK_TO_PAY_READY, d2), g("Click to Pay ready"), k(this.signIn, !d2.buyerExists), y.publish(o.CLICK_TO_PAY_SIGN_IN_VISIBILITY_CHANGE, !d2.buyerExists), k(this.clickToPay.element, true), y.publish(o.CLICK_TO_PAY_VISIBILITY_CHANGE, true);
384
+ break;
385
+ case o.CLICK_TO_PAY_SIGN_OUT:
386
+ this.clickToPay.signOut();
387
+ break;
388
+ case o.CLICK_TO_PAY_ERROR:
389
+ y.publish(o.CLICK_TO_PAY_ERROR, d2), g("Click to Pay error:", d2), k(this.signIn, !["UNKNOWN", "INVALID_CARD", "CODE_INVALID"].includes(d2.error)), y.publish(o.CLICK_TO_PAY_SIGN_IN_VISIBILITY_CHANGE, !["UNKNOWN", "INVALID_CARD", "CODE_INVALID"].includes(d2.error)), k(this.clickToPay.element, "UNKNOWN" !== d2.error), y.publish(o.CLICK_TO_PAY_VISIBILITY_CHANGE, "UNKNOWN" !== d2.error);
390
+ break;
391
+ case o.CLICK_TO_PAY_CANCEL:
392
+ y.publish(o.CLICK_TO_PAY_CANCEL, d2), g("Click to Pay cancelled"), this._buyerExists || (k(this.signIn, true), y.publish(o.CLICK_TO_PAY_SIGN_IN_VISIBILITY_CHANGE, true));
393
+ break;
394
+ case o.CLICK_TO_PAY_CHECKOUT_WITH_NEW_CARD:
395
+ y.publish(o.CLICK_TO_PAY_CHECKOUT_WITH_NEW_CARD, d2), k(this.signIn, false), y.publish(o.CLICK_TO_PAY_SIGN_IN_VISIBILITY_CHANGE, false), g("Click to Pay checkout with new card initiated");
396
+ break;
397
+ case o.CLICK_TO_PAY_PROCESSING:
398
+ k(this.cardForm, !d2), y.publish(o.CLICK_TO_PAY_CARD_FORM_VISIBILITY_CHANGE, d2), g("Click to Pay processing", d2);
399
+ break;
400
+ case o.CLICK_TO_PAY_AUTHENTICATE:
401
+ !(function(e3, t3) {
402
+ for (var r4 = arguments.length, n3 = new Array(r4 > 2 ? r4 - 2 : 0), i3 = 2; i3 < r4; i3++) n3[i3 - 2] = arguments[i3];
403
+ document.cookie = "".concat(e3, "=").concat(t3, "; path=/; ").concat(n3.join("; "));
404
+ })("recognitionToken", d2.recognitionToken, "Secure", "SameSite=Strict", "MaxAge=15552000");
405
+ break;
406
+ case o.CLICK_TO_PAY_AUTHENTICATE_FAILURE:
407
+ y.publish(o.CLICK_TO_PAY_AUTHENTICATE_FAILURE, d2), g("Click to Pay authenticate failure:", d2);
408
+ break;
409
+ case a.REQUEST_RECOGNITION_TOKEN:
410
+ this.controller.contentWindow.postMessage({ channel: l, type: a.RECOGNITION_TOKEN, data: { recognitionToken: N("recognitionToken") } }, this.origin);
411
+ break;
412
+ case a.REQUEST_RECOGNITION_TOKEN_FAILED:
413
+ O(c.NO_RECOGNITION_TOKEN);
414
+ break;
415
+ case a.REQUEST_PORT:
416
+ this.controller.contentWindow.postMessage({ channel: l, type: a.TRANSFER_PORT }, this.origin, [e2.port1]);
417
+ }
418
+ break;
419
+ case this.secureFields.frameUrl:
420
+ s2 === a.REQUEST_PORT && this.encrypt.contentWindow.postMessage({ channel: l, type: a.TRANSFER_PORT }, this.secureFields.frameUrl, [e2.port2]);
421
+ }
422
+ };
423
+ v.remove("message", r2, "click-to-pay"), v.add("message", r2, "click-to-pay");
424
+ }
425
+ _fetchDPA(e2, t2) {
426
+ return L(function* (e3, t3) {
427
+ var n2 = t3.gr4vyId, i2 = t3.environment, a2 = t3.sessionId;
428
+ try {
429
+ var s2 = e3 || (function(e4) {
430
+ return r(e4, arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "production", "api");
431
+ })(n2, i2);
432
+ return yield (function(e4) {
433
+ return (t4 = function* (e5) {
434
+ var t5 = e5.apiBaseUrl, r2 = e5.checkoutSessionId;
435
+ try {
436
+ var n3 = "".concat(t5, "/digital-wallets/click-to-pay/session"), i3 = yield fetch(n3, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ checkout_session_id: r2 }) });
437
+ if (i3.ok) {
438
+ var o2 = yield i3.json();
439
+ return { srcDpaId: o2.digital_payment_application_id, dpaName: o2.digital_payment_application_name };
440
+ }
441
+ throw new w("Unable to load DPA");
442
+ } catch (e6) {
443
+ throw new w("Unable to load DPA");
444
+ }
445
+ }, function() {
446
+ var e5 = this, r2 = arguments;
447
+ return new Promise(function(n3, i3) {
448
+ var o2 = t4.apply(e5, r2);
449
+ function a3(e6) {
450
+ P(o2, n3, i3, a3, s3, "next", e6);
451
+ }
452
+ function s3(e6) {
453
+ P(o2, n3, i3, a3, s3, "throw", e6);
454
+ }
455
+ a3(void 0);
456
+ });
457
+ }).apply(this, arguments);
458
+ var t4;
459
+ })({ apiBaseUrl: s2, checkoutSessionId: a2 });
460
+ } catch (e4) {
461
+ return g(e4.message), y.publish(o.CLICK_TO_PAY_UNABLE_TO_LOAD_DPA), k(this.cardForm, true), y.publish(o.CLICK_TO_PAY_CARD_FORM_VISIBILITY_CHANGE, true), k(this.clickToPay.element, false), void y.publish(o.CLICK_TO_PAY_VISIBILITY_CHANGE, false);
462
+ }
463
+ }).apply(this, arguments);
464
+ }
465
+ _initConsentCheckbox(e2) {
466
+ var t2 = e2.checked ? "click-to-pay" : "card";
467
+ this.secureFields.updateMethod(t2, { data: { method: t2 } }), e2.addEventListener("change", (e3) => {
468
+ var t3 = e3.target;
469
+ this.consent = t3.checked;
470
+ }), v.add("message", (t3) => {
471
+ switch (t3.data.type) {
472
+ case o.CLICK_TO_PAY_ERROR:
473
+ "UNKNOWN" === t3.data.data.error && (this.consent = false, e2.checked = false);
474
+ break;
475
+ case o.METHOD_CHANGE:
476
+ var r2 = this._buyerExists && "card" === t3.data.data.method;
477
+ this.consent = r2, e2.checked = r2;
478
+ }
479
+ }, "click-to-pay-consent-checkbox");
480
+ }
481
+ _setNewCardRememberMe(e2) {
482
+ this.controller.contentWindow.postMessage({ type: "remember-me-new-card-changed", channel: l, data: { value: e2 } }, this.origin);
483
+ }
484
+ _initNewCardRememberMeCheckbox(e2) {
485
+ e2.addEventListener("change", (e3) => {
486
+ var t2 = e3.target;
487
+ this._setNewCardRememberMe(t2.checked);
488
+ }), v.add("message", (t2) => {
489
+ switch (t2.data.type) {
490
+ case o.CLICK_TO_PAY_INITIALIZED:
491
+ this._setNewCardRememberMe(e2.checked);
492
+ break;
493
+ case o.CLICK_TO_PAY_ERROR:
494
+ "UNKNOWN" === t2.data.data.error && (this._setNewCardRememberMe(false), e2.checked = false);
495
+ }
496
+ }, "click-to-pay-new-card-remember-me-checkbox");
497
+ }
498
+ _initLearnMore(e2) {
499
+ e2.style.visibility = "hidden", v.add("message", (t2) => {
500
+ t2.data.type === o.CLICK_TO_PAY_INITIALIZED && (e2.style.visibility = "visible", e2.addEventListener("click", () => {
501
+ this.controller.contentWindow.postMessage({ type: "show-learn-more", channel: l }, this.origin);
502
+ }));
503
+ }, "click-to-pay-learn-more");
504
+ }
505
+ init(e2, t2) {
506
+ return L(function* () {
507
+ this.cardForm = "string" == typeof (null == t2 ? void 0 : t2.cardForm) ? document.querySelector(null == t2 ? void 0 : t2.cardForm) : null == t2 ? void 0 : t2.cardForm, this.signIn = "string" == typeof (null == t2 ? void 0 : t2.signIn) ? document.querySelector(null == t2 ? void 0 : t2.signIn) : null == t2 ? void 0 : t2.signIn, k(this.signIn, false);
508
+ var r2 = this.secureFields, n2 = r2.apiUrl, i2 = r2.config, a2 = i2.gr4vyId, s2 = i2.environment, c2 = i2.sessionId, l2 = r2.environmentPath;
509
+ if (this.clickToPay = { element: null, options: t2, signIn: (e3) => {
510
+ var t3 = e3.email, r3 = e3.mobileNumber;
511
+ return L(function* () {
512
+ var e4 = this.clickToPay, n3 = e4.element, i3 = e4.options;
513
+ delete i3.email, delete i3.mobileNumber, n3.innerHTML = "", k(this.signIn, false), y.publish(o.CLICK_TO_PAY_SIGN_IN_VISIBILITY_CHANGE, false), k(this.cardForm, false), y.publish(o.CLICK_TO_PAY_CARD_FORM_VISIBILITY_CHANGE, false), this.secureFields.update("clickToPay", yield this.init(n3, j({}, i3, t3 ? { email: t3 } : {}, r3 ? { mobileNumber: r3 } : {})));
514
+ }).call(this);
515
+ }, signOut: () => (this._buyerExists = false, y.publish(o.CLICK_TO_PAY_SIGN_OUT), g("Click to pay signed out"), k(this.signIn, true), y.publish(o.CLICK_TO_PAY_SIGN_IN_VISIBILITY_CHANGE, true), document.cookie = "".concat("recognitionToken", "=; path=/; expires=Thu, 01 Jan 1970 00:00:00 UTC;"), this.clickToPay.signIn({ email: null, mobileNumber: null })), updateCheckoutOptions: (e3) => {
516
+ this.checkoutOptions = j({}, this.checkoutOptions, e3);
517
+ } }, !(null == t2 ? void 0 : t2.srcDpaId) || !(null == t2 ? void 0 : t2.dpaName)) {
518
+ var d2 = yield this._fetchDPA(n2, { gr4vyId: a2, environment: s2, sessionId: c2 });
519
+ if (!(null == d2 ? void 0 : d2.srcDpaId) && !(null == d2 ? void 0 : d2.dpaName)) return;
520
+ t2.srcDpaId = d2.srcDpaId, t2.dpaName = d2.dpaName;
521
+ }
522
+ this.url = window.CLICK_TO_PAY_FRAME_URL || "https://click-to-pay.".concat(l2).concat(a2, ".gr4vy.app"), this.origin = new URL(this.url).origin;
523
+ var h2 = window.location.origin, u2 = ((function(e3) {
524
+ if (null == e3) throw new TypeError("Cannot destructure " + e3);
525
+ })(t2), j({ gr4vyId: a2, environment: s2, sessionId: c2 }, U({}, t2)));
526
+ if (this.controller = this._addIframe("click-to-pay-controller", "Click To Pay", "".concat(this.url, "/click-to-pay.html"), { parentOrigin: h2, environment: s2, config: encodeURIComponent(JSON.stringify(u2)) }), this.encrypt = this._addIframe("click-to-pay-encrypt", "Click To Pay Encrypt", "".concat(this.secureFields.frameUrl, "/click-to-pay-encrypt.html"), { parentOrigin: h2, environment: s2, config: encodeURIComponent(JSON.stringify(u2)) }), this._attachListeners(), null == t2 ? void 0 : t2.consentCheckbox) {
527
+ var p2 = "string" == typeof (null == t2 ? void 0 : t2.consentCheckbox) ? document.querySelector(null == t2 ? void 0 : t2.consentCheckbox) : null == t2 ? void 0 : t2.consentCheckbox;
528
+ p2 && this._initConsentCheckbox(p2);
529
+ }
530
+ if (null == t2 ? void 0 : t2.rememberMeCheckbox) {
531
+ var m2 = "string" == typeof (null == t2 ? void 0 : t2.rememberMeCheckbox) ? document.querySelector(t2.rememberMeCheckbox) : null == t2 ? void 0 : t2.rememberMeCheckbox;
532
+ m2 && this._initNewCardRememberMeCheckbox(m2);
533
+ }
534
+ if (null == t2 ? void 0 : t2.learnMoreLink) {
535
+ var f2 = "string" == typeof (null == t2 ? void 0 : t2.learnMoreLink) ? document.querySelector(null == t2 ? void 0 : t2.learnMoreLink) : null == t2 ? void 0 : t2.learnMoreLink;
536
+ f2 && this._initLearnMore(f2);
537
+ }
538
+ return (e2 = "string" == typeof e2 ? document.querySelector(e2) : e2).appendChild(this.controller), e2.appendChild(this.encrypt), this.clickToPay.element = e2, this.clickToPay;
539
+ }).call(this);
540
+ }
541
+ constructor(e2) {
542
+ R(this, "secureFields", void 0), R(this, "_buyerExists", void 0), R(this, "consent", void 0), R(this, "controller", void 0), R(this, "encrypt", void 0), R(this, "origin", void 0), R(this, "url", void 0), R(this, "cardForm", void 0), R(this, "signIn", void 0), R(this, "checkoutOptions", void 0), R(this, "clickToPay", void 0), this.secureFields = e2, this._buyerExists = false, this.consent = false, this.checkoutOptions = {};
543
+ }
544
+ }
545
+ var F = (e2) => (e2 != e2.toLowerCase() && (e2 = e2.replace(/[A-Z]/g, (e3) => "-" + e3.toLowerCase())), e2);
546
+ function x(e2, t2) {
547
+ (null == t2 || t2 > e2.length) && (t2 = e2.length);
548
+ for (var r2 = 0, n2 = new Array(t2); r2 < t2; r2++) n2[r2] = e2[r2];
549
+ return n2;
550
+ }
551
+ var Y = function() {
552
+ var e2 = function(t2) {
553
+ var r2 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "";
554
+ return Object.entries(t2).reduce((n2, i2) => {
555
+ var o2, a2, s2 = (a2 = 2, (function(e3) {
556
+ if (Array.isArray(e3)) return e3;
557
+ })(o2 = i2) || (function(e3, t3) {
558
+ var r3 = null == e3 ? null : "undefined" != typeof Symbol && e3[Symbol.iterator] || e3["@@iterator"];
559
+ if (null != r3) {
560
+ var n3, i3, o3 = [], a3 = true, s3 = false;
561
+ try {
562
+ for (r3 = r3.call(e3); !(a3 = (n3 = r3.next()).done) && (o3.push(n3.value), !t3 || o3.length !== t3); a3 = true) ;
563
+ } catch (e4) {
564
+ s3 = true, i3 = e4;
565
+ } finally {
566
+ try {
567
+ a3 || null == r3.return || r3.return();
568
+ } finally {
569
+ if (s3) throw i3;
570
+ }
571
+ }
572
+ return o3;
573
+ }
574
+ })(o2, a2) || (function(e3, t3) {
575
+ if (e3) {
576
+ if ("string" == typeof e3) return x(e3, t3);
577
+ var r3 = Object.prototype.toString.call(e3).slice(8, -1);
578
+ return "Object" === r3 && e3.constructor && (r3 = e3.constructor.name), "Map" === r3 || "Set" === r3 ? Array.from(r3) : "Arguments" === r3 || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r3) ? x(e3, t3) : void 0;
579
+ }
580
+ })(o2, a2) || (function() {
581
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
582
+ })()), c2 = s2[0], l2 = s2[1];
583
+ return ((e3) => "[object Object]" === Object.prototype.toString.call(e3))(l2) ? n2.push(...e2(t2[c2], "".concat((r2 + c2).match(/[a-zA-Z0-9]+/g).join("-"), "-"))) : (c2 = F(c2).replace(/^-/, ""), n2.push(["--".concat(r2).concat(c2), l2])), n2;
584
+ }, []);
585
+ };
586
+ return e2(arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {});
587
+ };
588
+ function K(e2, t2, r2, n2, i2, o2, a2) {
589
+ try {
590
+ var s2 = e2[o2](a2), c2 = s2.value;
591
+ } catch (e3) {
592
+ return void r2(e3);
593
+ }
594
+ s2.done ? t2(c2) : Promise.resolve(c2).then(n2, i2);
595
+ }
596
+ function H(e2, t2, r2) {
597
+ return t2 in e2 ? Object.defineProperty(e2, t2, { value: r2, enumerable: true, configurable: true, writable: true }) : e2[t2] = r2, e2;
598
+ }
599
+ function G(e2) {
600
+ for (var t2 = 1; t2 < arguments.length; t2++) {
601
+ var r2 = null != arguments[t2] ? arguments[t2] : {}, n2 = Object.keys(r2);
602
+ "function" == typeof Object.getOwnPropertySymbols && (n2 = n2.concat(Object.getOwnPropertySymbols(r2).filter(function(e3) {
603
+ return Object.getOwnPropertyDescriptor(r2, e3).enumerable;
604
+ }))), n2.forEach(function(t3) {
605
+ H(e2, t3, r2[t3]);
606
+ });
607
+ }
608
+ return e2;
609
+ }
610
+ function V(e2, t2) {
611
+ return t2 = null != t2 ? t2 : {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(e2, Object.getOwnPropertyDescriptors(t2)) : (function(e3) {
612
+ var t3 = Object.keys(e3);
613
+ if (Object.getOwnPropertySymbols) {
614
+ var r2 = Object.getOwnPropertySymbols(e3);
615
+ t3.push.apply(t3, r2);
616
+ }
617
+ return t3;
618
+ })(Object(t2)).forEach(function(r2) {
619
+ Object.defineProperty(e2, r2, Object.getOwnPropertyDescriptor(t2, r2));
620
+ }), e2;
621
+ }
622
+ class W {
623
+ _postMessage(e2) {
624
+ return (t2 = function* () {
625
+ yield this.ready, this.frame.contentWindow.postMessage(G({ channel: l }, e2), this.frameUrl);
626
+ }, function() {
627
+ var e3 = this, r2 = arguments;
628
+ return new Promise(function(n2, i2) {
629
+ var o2 = t2.apply(e3, r2);
630
+ function a2(e4) {
631
+ K(o2, n2, i2, a2, s2, "next", e4);
632
+ }
633
+ function s2(e4) {
634
+ K(o2, n2, i2, a2, s2, "throw", e4);
635
+ }
636
+ a2(void 0);
637
+ });
638
+ }).call(this);
639
+ var t2;
640
+ }
641
+ update(e2) {
642
+ if (this.frameUrl) {
643
+ this.options = G({}, this.options, e2);
644
+ var t2 = Y(G({}, this.options.styles, e2.styles)), r2 = V(G({}, this.options, e2), { styles: t2 });
645
+ this._postMessage({ type: "update", data: V(G({}, r2), { styles: t2 }) }), g("Updated field", this.options);
646
+ }
647
+ }
648
+ setPlaceholder(e2) {
649
+ this.update({ placeholder: e2 });
650
+ }
651
+ setStyles(e2) {
652
+ this.update({ styles: e2 });
653
+ }
654
+ clear() {
655
+ if (this.frameUrl) {
656
+ var e2 = this.type;
657
+ this._postMessage({ type: "reset", data: { type: e2 } }), g("Cleared field", { type: e2 });
658
+ }
659
+ }
660
+ focus() {
661
+ if (this.frameUrl) {
662
+ var e2 = this.type;
663
+ this._postMessage({ type: "focus", data: { type: e2 } }), g("Focus field", { type: e2 });
664
+ }
665
+ }
666
+ redactValue() {
667
+ if (this.frameUrl) {
668
+ var e2 = this.type;
669
+ this._postMessage({ type: "redact-value", data: { type: e2 } }), g("Redact field", { type: e2 });
670
+ }
671
+ }
672
+ unredactValue() {
673
+ if (this.frameUrl) {
674
+ var e2 = this.type;
675
+ this._postMessage({ type: "unredact-value", data: { type: e2 } }), g("Unredact field", { type: e2 });
676
+ }
677
+ }
678
+ setEnterKeyHint(e2) {
679
+ if (this.frameUrl) {
680
+ var t2 = this.type;
681
+ this._postMessage({ type: "set-enter-key-hint", data: { type: t2, value: e2 } }), g("Updated enter key hint", { type: t2, value: e2 });
682
+ }
683
+ }
684
+ constructor(e2) {
685
+ if (H(this, "frameUrl", void 0), H(this, "parentOrigin", void 0), H(this, "frame", void 0), H(this, "type", void 0), H(this, "options", void 0), H(this, "addEventListener", void 0), H(this, "removeEventListener", void 0), H(this, "ready", void 0), H(this, "_resolveReady", void 0), H(this, "complete", void 0), e2) {
686
+ this.ready = new Promise((e3) => {
687
+ this._resolveReady = e3;
688
+ });
689
+ var t2 = e2.frameUrl, r2 = e2.parentOrigin, i2 = e2.font, o2 = e2.sessionId, a2 = e2.gr4vyId, s2 = e2.environment, c2 = e2.options, l2 = c2.type, d2 = c2.autoFocus, h2 = (function(e3, t3) {
690
+ if (null == e3) return {};
691
+ var r3, n2, i3, o3 = {};
692
+ if ("undefined" != typeof Reflect && Reflect.ownKeys) {
693
+ for (r3 = Reflect.ownKeys(Object(e3)), i3 = 0; i3 < r3.length; i3++) n2 = r3[i3], t3.indexOf(n2) >= 0 || Object.prototype.propertyIsEnumerable.call(e3, n2) && (o3[n2] = e3[n2]);
694
+ return o3;
695
+ }
696
+ if (o3 = (function(e4, t4) {
697
+ if (null == e4) return {};
698
+ var r4, n3, i4 = {}, o4 = Object.getOwnPropertyNames(e4);
699
+ for (n3 = 0; n3 < o4.length; n3++) r4 = o4[n3], t4.indexOf(r4) >= 0 || Object.prototype.propertyIsEnumerable.call(e4, r4) && (i4[r4] = e4[r4]);
700
+ return i4;
701
+ })(e3, t3), Object.getOwnPropertySymbols) for (r3 = Object.getOwnPropertySymbols(e3), i3 = 0; i3 < r3.length; i3++) n2 = r3[i3], t3.indexOf(n2) >= 0 || Object.prototype.propertyIsEnumerable.call(e3, n2) && (o3[n2] = e3[n2]);
702
+ return o3;
703
+ })(c2, ["type", "autoFocus"]), u2 = e2.paymentMethodScheme;
704
+ this.frameUrl = t2, this.parentOrigin = r2, this.type = l2, this.options = h2;
705
+ var p2 = Y(h2.styles), y2 = { parentOrigin: r2, type: l2, sessionId: o2, gr4vyId: a2, environment: s2 };
706
+ this.frame = document.createElement("iframe"), this.frame.id = l2, this.frame.src = n("".concat(t2, "/input.html"), y2), this.frame.title = "Secure Input", this.frame.style.display = "block", this.frame.style.height = "100%", this.frame.style.border = "none", this.frame.style.width = "100%", i2 && (this.frame.src += "&font=".concat(i2)), u2 && (this.frame.src += "&paymentMethodScheme=".concat(u2)), this.frame.onload = () => {
707
+ this._postMessage({ type: "update", data: V(G({}, this.options), { styles: p2, type: l2 }) }), g("Added field", this.options), d2 && this.focus();
708
+ };
709
+ }
710
+ }
711
+ }
712
+ var B = ["number", "expiryDate", "securityCode", "postalCode"], q = ["accesskey", "autocapitalize", "autocomplete", "autofocus", "aria-.", "class", "contenteditable", "data-.", "dir", "draggable", "enterkeyhint", "hidden", "id", "inert", "inputmode", "is", "itemid", "itemprop", "itemref", "itemscope", "itemtype", "lang", "nonce", "onabort", "onautocomplete", "onautocompleteerror", "onblur", "oncancel", "oncanplay", "oncanplaythrough", "onchange", "onclick", "onclose", "oncontextmenu", "oncuechange", "ondblclick", "ondrag", "ondragend", "ondragenter", "ondragleave", "ondragover", "ondragstart", "ondrop", "ondurationchange", "onemptied", "onended", "onerror", "onfocus", "oninput", "oninvalid", "onkeydown", "onkeypress", "onkeyup", "onload", "onloadeddata", "onloadedmetadata", "onloadstart", "onmousedown", "onmouseenter", "onmouseleave", "onmousemove", "onmouseout", "onmouseover", "onmouseup", "onmousewheel", "onpause", "onplay", "onplaying", "onprogress", "onratechange", "onreset", "onresize", "onscroll", "onseeked", "onseeking", "onselect", "onshow", "onsort", "onstalled", "onsubmit", "onsuspend", "ontimeupdate", "ontoggle", "onvolumechange", "onwaiting", "popover", "role", "slot", "spellcheck", "style", "tabindex", "title", "translate"];
713
+ function z(e2, t2, r2) {
714
+ return t2 in e2 ? Object.defineProperty(e2, t2, { value: r2, enumerable: true, configurable: true, writable: true }) : e2[t2] = r2, e2;
715
+ }
716
+ var Z = ["visa", "mastercard", "amex"];
717
+ function Q(e2, t2, r2, n2, i2, o2, a2) {
718
+ try {
719
+ var s2 = e2[o2](a2), c2 = s2.value;
720
+ } catch (e3) {
721
+ return void r2(e3);
722
+ }
723
+ s2.done ? t2(c2) : Promise.resolve(c2).then(n2, i2);
724
+ }
725
+ function J(e2, t2, r2) {
726
+ return t2 in e2 ? Object.defineProperty(e2, t2, { value: r2, enumerable: true, configurable: true, writable: true }) : e2[t2] = r2, e2;
727
+ }
728
+ function $(e2) {
729
+ for (var t2 = 1; t2 < arguments.length; t2++) {
730
+ var r2 = null != arguments[t2] ? arguments[t2] : {}, n2 = Object.keys(r2);
731
+ "function" == typeof Object.getOwnPropertySymbols && (n2 = n2.concat(Object.getOwnPropertySymbols(r2).filter(function(e3) {
732
+ return Object.getOwnPropertyDescriptor(r2, e3).enumerable;
733
+ }))), n2.forEach(function(t3) {
734
+ J(e2, t3, r2[t3]);
735
+ });
736
+ }
737
+ return e2;
738
+ }
739
+ function X(e2, t2) {
740
+ return t2 = null != t2 ? t2 : {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(e2, Object.getOwnPropertyDescriptors(t2)) : (function(e3) {
741
+ var t3 = Object.keys(e3);
742
+ if (Object.getOwnPropertySymbols) {
743
+ var r2 = Object.getOwnPropertySymbols(e3);
744
+ t3.push.apply(t3, r2);
745
+ }
746
+ return t3;
747
+ })(Object(t2)).forEach(function(r2) {
748
+ Object.defineProperty(e2, r2, Object.getOwnPropertyDescriptor(t2, r2));
749
+ }), e2;
750
+ }
751
+ function ee(e2, t2) {
752
+ if (null == e2) return {};
753
+ var r2, n2, i2, o2 = {};
754
+ if ("undefined" != typeof Reflect && Reflect.ownKeys) {
755
+ for (r2 = Reflect.ownKeys(Object(e2)), i2 = 0; i2 < r2.length; i2++) n2 = r2[i2], t2.indexOf(n2) >= 0 || Object.prototype.propertyIsEnumerable.call(e2, n2) && (o2[n2] = e2[n2]);
756
+ return o2;
757
+ }
758
+ if (o2 = (function(e3, t3) {
759
+ if (null == e3) return {};
760
+ var r3, n3, i3 = {}, o3 = Object.getOwnPropertyNames(e3);
761
+ for (n3 = 0; n3 < o3.length; n3++) r3 = o3[n3], t3.indexOf(r3) >= 0 || Object.prototype.propertyIsEnumerable.call(e3, r3) && (i3[r3] = e3[r3]);
762
+ return i3;
763
+ })(e2, t2), Object.getOwnPropertySymbols) for (r2 = Object.getOwnPropertySymbols(e2), i2 = 0; i2 < r2.length; i2++) n2 = r2[i2], t2.indexOf(n2) >= 0 || Object.prototype.propertyIsEnumerable.call(e2, n2) && (o2[n2] = e2[n2]);
764
+ return o2;
765
+ }
766
+ class te {
767
+ static get Events() {
768
+ return o;
769
+ }
770
+ static get version() {
771
+ return "#ffb6feb2e0f001ac7ebf45b5c1b5802e589b3a28";
772
+ }
773
+ update(e2, t2) {
774
+ this[e2] = t2;
775
+ }
776
+ updateMethod(e2, t2) {
777
+ var r2 = t2.data;
778
+ this.update("method", e2), y.publish(o.METHOD_CHANGE, r2), g("Method changed", { method: e2 }), this.controller.contentWindow.postMessage({ type: "method-change", channel: l }, this.frameUrl);
779
+ }
780
+ setAutoAdvance(e2) {
781
+ e2.enabled && (O(c.AUTO_ADVANCE_ENABLED), this.autoAdvance = ((e3) => {
782
+ var t2 = e3.enabled, r2 = e3.secureFields, n2 = ((e4) => {
783
+ if (!(null == e4 ? void 0 : e4.length)) return B;
784
+ var t3 = e4.filter((t4, r4) => B.includes(t4) && e4.indexOf(t4) === r4), r3 = B.filter((e5) => !t3.includes(e5));
785
+ return [...t3, ...r3];
786
+ })(e3.fieldOrder), i2 = (e4) => e4 ? "number" === e4 ? r2.cardNumber : "expiryDate" === e4 ? r2.expiryDate : "securityCode" === e4 ? r2.securityCode : r2.otherFields[e4] : null, o2 = (e4) => {
787
+ var t3 = e4.type, r3 = e4.nextIndex, a2 = null != r3 ? r3 : n2.indexOf(t3);
788
+ if (!(a2 < 0 || a2 >= n2.length - 1)) {
789
+ var s2 = i2(n2[a2 + 1]);
790
+ !(null == s2 ? void 0 : s2.complete) && (null == s2 ? void 0 : s2.frame) ? s2.focus() : o2({ nextIndex: a2 + 1 });
791
+ }
792
+ };
793
+ return { get enabled() {
794
+ return t2;
795
+ }, get fieldOrder() {
796
+ return n2;
797
+ }, updateEnterKeyHint: (e4) => {
798
+ var r3;
799
+ if (null == e4 ? void 0 : e4.frame) {
800
+ var o3 = n2.indexOf(e4.type), a2 = n2[o3 + 1], s2 = a2 && (null === (r3 = i2(a2)) || void 0 === r3 ? void 0 : r3.frame);
801
+ e4.setEnterKeyHint(t2 && s2 ? "next" : "done");
802
+ }
803
+ }, trigger: o2 };
804
+ })(X($({}, e2), { secureFields: this })));
805
+ }
806
+ _addField(e2, t2, r2) {
807
+ if (!(e2 = "string" == typeof e2 ? document.querySelector(e2) : e2) || !t2.frame) return t2.addEventListener = () => {
808
+ }, t2.removeEventListener = () => {
809
+ }, t2;
810
+ var n2 = e2.closest("[data-secure-fields-input-group]"), i2 = null != n2 ? n2 : document.createElement("div"), o2 = (e3) => {
811
+ var r3;
812
+ if (e3.origin === this.frameUrl && (null === (r3 = e3.data.data) || void 0 === r3 ? void 0 : r3.id) === t2.type) switch (e3.data.type) {
813
+ case "blur":
814
+ y.publish("".concat(t2.type, ":blur"), e3.data.data), i2.removeAttribute(s.FOCUSED), g("Field blurred", e3.data.data);
815
+ break;
816
+ case "focus":
817
+ y.publish("".concat(t2.type, ":focus"), e3.data.data), i2.setAttribute(s.FOCUSED, ""), g("Field focused", e3.data.data);
818
+ break;
819
+ case "input":
820
+ var n3, o3 = e3.data.data, a2 = o3.complete, c2 = o3.fromBlur, l2 = o3.isDeleteInputType, d2 = ee(o3, ["complete", "fromBlur", "isDeleteInputType"]);
821
+ if (y.publish("".concat(t2.type, ":input"), d2), t2.complete = a2, e3.data.data.valid ? i2.removeAttribute(s.INVALID) : i2.setAttribute(s.INVALID, ""), e3.data.data.autofilled ? i2.setAttribute(s.AUTOFILLED, "") : i2.removeAttribute(s.AUTOFILLED), (null === (n3 = this.autoAdvance) || void 0 === n3 ? void 0 : n3.enabled) && a2 && !d2.autofilled && false === c2 && !l2 && this.autoAdvance.trigger({ type: t2.type }), this.schemeIcons && "number" === t2.type) {
822
+ var h2, u2, p2;
823
+ d2.bin || (this.cardDetailsSchemes = { scheme: void 0, additionalSchemes: [] });
824
+ var m2 = null !== (h2 = null === (u2 = this.cardDetailsSchemes) || void 0 === u2 ? void 0 : u2.scheme) && void 0 !== h2 ? h2 : d2.schema, f2 = null === (p2 = this.cardDetailsSchemes) || void 0 === p2 ? void 0 : p2.additionalSchemes;
825
+ !m2 && d2.empty && this.schemeIcons.config.placeholders ? this.schemeIcons.showPlaceholders() : m2 ? this.schemeIcons.showSchemes({ scheme: m2, additionalSchemes: f2 }) : this.schemeIcons.hideSchemes();
826
+ }
827
+ g("Field input changed", d2);
828
+ break;
829
+ case "redacted":
830
+ y.publish("".concat(t2.type, ":redacted"), e3.data.data), g("Field redacted", e3.data.data);
831
+ break;
832
+ case "unredacted":
833
+ y.publish("".concat(t2.type, ":unredacted"), e3.data.data), g("Field unredacted", e3.data.data);
834
+ break;
835
+ case "card-details-changed":
836
+ var v2;
837
+ y.publish("".concat(t2.type, ":card-details-changed"), e3.data.data), this.schemeIcons && (this.cardDetailsSchemes = { scheme: e3.data.data.scheme, additionalSchemes: null !== (v2 = e3.data.data.additionalSchemes) && void 0 !== v2 ? v2 : [] }, this.schemeIcons.showSchemes(this.cardDetailsSchemes)), g("Card details changed", e3.data.data);
838
+ }
839
+ };
840
+ return v.remove("message", o2, t2.type), v.add("message", o2, t2.type), t2.addEventListener = this.addEventListener, t2.removeEventListener = this.removeEventListener, this.controllerReady.then(() => {
841
+ var o3, a2, s2, c2;
842
+ o3 = e2, a2 = i2, Array.from(o3.attributes).forEach((e3) => {
843
+ var t3 = e3.name, r3 = e3.value;
844
+ q.some((e4) => new RegExp(e4).test(t3)) && a2.setAttribute(t3, r3);
845
+ }), (i2 = a2).classList.add("secure-fields__input", "secure-fields__input--".concat(F(t2.type))), n2 ? (null === (s2 = e2.parentNode) || void 0 === s2 || s2.replaceChild(t2.frame, e2), n2.style.display = "inline-flex", n2.style.alignItems = "center", t2.frame.style.minWidth = "0") : (null === (c2 = e2.parentNode) || void 0 === c2 || c2.replaceChild(i2, e2), i2.appendChild(t2.frame)), "number" === t2.type && (null == r2 ? void 0 : r2.showSchemeIcons) && (i2.style.display = "inline-flex", i2.style.alignItems = "center", this.schemeIcons = ((e3) => {
846
+ var t3 = e3.baseUrl, r3 = ((e4) => {
847
+ var t4 = { scheme: false, additionalSchemes: false, placeholders: false };
848
+ return "boolean" == typeof e4 ? e4 ? { scheme: true, additionalSchemes: true, placeholders: false } : t4 : (function(e5) {
849
+ for (var t5 = 1; t5 < arguments.length; t5++) {
850
+ var r4 = null != arguments[t5] ? arguments[t5] : {}, n4 = Object.keys(r4);
851
+ "function" == typeof Object.getOwnPropertySymbols && (n4 = n4.concat(Object.getOwnPropertySymbols(r4).filter(function(e6) {
852
+ return Object.getOwnPropertyDescriptor(r4, e6).enumerable;
853
+ }))), n4.forEach(function(t6) {
854
+ z(e5, t6, r4[t6]);
855
+ });
856
+ }
857
+ return e5;
858
+ })({}, t4, e4);
859
+ })(e3.showSchemeIcons), n3 = /* @__PURE__ */ new Set(), i3 = document.createElement("div");
860
+ i3.classList.add("secure-fields__scheme-icons"), i3.style.display = "flex", i3.style.gap = "4px", i3.style.marginRight = "4px";
861
+ var o4 = Array.from({ length: 3 }, () => {
862
+ var e4 = document.createElement("img");
863
+ return e4.setAttribute("alt", ""), e4.setAttribute("aria-hidden", "true"), e4.style.display = "none", e4.onerror = () => {
864
+ var t4 = e4.getAttribute("src");
865
+ t4 && n3.add(t4), e4.style.display = "none";
866
+ }, e4.onload = () => {
867
+ e4.style.display = "block";
868
+ }, i3.appendChild(e4), e4;
869
+ }), a3 = (e4) => {
870
+ var i4 = e4.scheme, a4 = void 0 === i4 ? "" : i4, s3 = e4.additionalSchemes, c3 = void 0 === s3 ? [] : s3, l2 = e4.placeholders, d2 = void 0 !== l2 && l2, h2 = [...r3.scheme && a4 ? [a4] : [], ...r3.additionalSchemes && c3.length ? c3 : [], ...d2 ? Z : []].slice(0, 3);
871
+ o4.forEach((e5, r4) => {
872
+ var i5 = h2[r4];
873
+ if (i5) {
874
+ var o5 = "".concat(t3, "/").concat(i5, ".svg");
875
+ e5.getAttribute("src") !== o5 ? (e5.setAttribute("src", o5), e5.width = 48) : n3.has(o5) || (e5.style.display = "block");
876
+ } else e5.style.display = "none";
877
+ });
878
+ };
879
+ return { config: r3, container: i3, slots: o4, showSchemes: a3, showPlaceholders: () => a3({ placeholders: true }), hideSchemes: () => o4.forEach((e4) => e4.style.display = "none") };
880
+ })({ baseUrl: "".concat(this.cdnBaseUrl, "/assets/icons/card-schemes"), showSchemeIcons: r2.showSchemeIcons }), t2.frame.after(this.schemeIcons.container), this.schemeIcons.config.placeholders && this.schemeIcons.showPlaceholders()), t2._resolveReady(), t2.frame.addEventListener("load", () => {
881
+ var e3;
882
+ return null === (e3 = this.autoAdvance) || void 0 === e3 ? void 0 : e3.updateEnterKeyHint(t2);
883
+ });
884
+ }), t2;
885
+ }
886
+ addCardNumberField(e2, t2) {
887
+ return this.paymentMethodId && O(c.PAYMENT_METHOD_ID_IN_USE, { method: "addCardNumberField" }), this.cardNumber || (this.cardNumber = new W(X($({ frameUrl: this.frameUrl, parentOrigin: this.parentOrigin, font: this.font, sessionId: this.config.sessionId, gr4vyId: this.config.gr4vyId, environment: this.config.environment }, this.paymentMethodId ? { paymentMethodId: this.paymentMethodId } : {}), { options: X($({ label: "Card number" }, t2), { type: "number" }) }))), this._addField(e2, this.cardNumber, t2);
888
+ }
889
+ addSecurityCodeField(e2, t2) {
890
+ var r2, n2;
891
+ return this.securityCode || (this.securityCode = new W({ frameUrl: this.frameUrl, parentOrigin: this.parentOrigin, font: this.font, options: X($({ label: "Security code" }, this.paymentMethodId && !(null === (r2 = this.config.paymentMethod) || void 0 === r2 ? void 0 : r2.scheme) ? { lengths: [3, 4] } : {}, t2), { type: "securityCode" }), paymentMethodScheme: null === (n2 = this.config.paymentMethod) || void 0 === n2 ? void 0 : n2.scheme })), this._addField(e2, this.securityCode);
892
+ }
893
+ addExpiryDateField(e2, t2) {
894
+ return this.paymentMethodId && O(c.PAYMENT_METHOD_ID_IN_USE, { method: "addExpiryDateField" }), this.expiryDate || (this.expiryDate = new W({ frameUrl: this.frameUrl, parentOrigin: this.parentOrigin, font: this.font, options: X($({ label: "Expiry date" }, t2), { type: "expiryDate" }) })), this._addField(e2, this.expiryDate);
895
+ }
896
+ addField(e2, t2) {
897
+ if (["number", "expiryDate", "securityCode"].includes(t2.type)) {
898
+ t2.pattern && O(c.FIELD_PATTERN_IN_USE, $({ method: "addField" }, t2)), t2.pattern, t2.type;
899
+ var r2 = ee(t2, ["pattern", "type"]);
900
+ return this[d[t2.type]](e2, r2);
901
+ }
902
+ return this.otherFields[t2.type] || (this.otherFields = X($({}, this.otherFields), { [t2.type]: new W({ frameUrl: this.frameUrl, parentOrigin: this.parentOrigin, font: this.font, options: t2 }) })), this._addField(e2, this.otherFields[t2.type]);
903
+ }
904
+ addThreeDSecure(e2, t2) {
905
+ this.threeDS || (this.threeDS = new S(this), this.threeDS.init(e2, t2), this.setThreeDSecureEnabled(true), this.postThreeDSInit());
906
+ }
907
+ removeThreeDSecure() {
908
+ var e2, t2;
909
+ null === (e2 = this.threeDS) || void 0 === e2 || e2.destroy(), null === (t2 = this.threeDS) || void 0 === t2 || t2.controller.remove(), this.threeDS = void 0, this.setThreeDSecureEnabled(false);
910
+ }
911
+ setThreeDSecureEnabled(e2) {
912
+ this.threeDSEnabled = e2;
913
+ }
914
+ postThreeDSInit() {
915
+ this.controllerReady.then(() => {
916
+ var e2;
917
+ null === (e2 = this.controller.contentWindow) || void 0 === e2 || e2.postMessage({ type: "three-ds-init", channel: l }, this.frameUrl);
918
+ });
919
+ }
920
+ addClickToPay(e2, t2) {
921
+ return (r2 = function* () {
922
+ if (!this.paymentMethodId) return this.clickToPayInstance = yield new M(this), this.clickToPay = yield this.clickToPayInstance.init(e2, t2), this.clickToPay;
923
+ O(c.PAYMENT_METHOD_ID_IN_USE, { method: "addClickToPay" });
924
+ }, function() {
925
+ var e3 = this, t3 = arguments;
926
+ return new Promise(function(n2, i2) {
927
+ var o2 = r2.apply(e3, t3);
928
+ function a2(e4) {
929
+ Q(o2, n2, i2, a2, s2, "next", e4);
930
+ }
931
+ function s2(e4) {
932
+ Q(o2, n2, i2, a2, s2, "throw", e4);
933
+ }
934
+ a2(void 0);
935
+ });
936
+ }).call(this);
937
+ var r2;
938
+ }
939
+ addEventListener(e2, t2) {
940
+ var r2 = this.type, n2 = "".concat(this.constructor === W ? "".concat(r2, ":") : "").concat(e2);
941
+ y.subscribe(n2, t2);
942
+ }
943
+ removeEventListener(e2, t2) {
944
+ var r2 = this.type, n2 = "".concat(this.constructor === W ? "".concat(r2, ":") : "").concat(e2);
945
+ y.unsubscribe(n2, t2);
946
+ }
947
+ submit() {
948
+ var e2, t2, r2 = (e3) => {
949
+ var t3, n3 = [this.frameUrl, null === (t3 = this.clickToPayInstance) || void 0 === t3 ? void 0 : t3.origin].includes(e3.origin), i3 = e3.data.channel === l, a2 = ["success", "error", o.CLICK_TO_PAY_CANCEL, o.CLICK_TO_PAY_ERROR, o.CLICK_TO_PAY_AUTHENTICATE_FAILURE].includes(e3.data.type);
950
+ if (n3 && i3 && a2) {
951
+ switch (e3.data.type) {
952
+ case "success":
953
+ var s2;
954
+ y.publish(o.CARD_VAULT_SUCCESS, e3.data.data), (null === (s2 = e3.data.data) || void 0 === s2 ? void 0 : s2.warn) && (O(e3.data.data.warn), delete e3.data.data.warn), g("Payment method tokenized successfully", e3.data.data);
955
+ break;
956
+ case "error":
957
+ y.publish(o.CARD_VAULT_FAILURE, e3.data), g("Failed to update checkout session", e3.data.data);
958
+ }
959
+ window.removeEventListener("message", r2);
960
+ }
961
+ };
962
+ if (window.addEventListener("message", r2), "click-to-pay" === this.method || "card" === this.method && (null === (e2 = this.clickToPayInstance) || void 0 === e2 ? void 0 : e2.controller) && true === (null === (t2 = this.clickToPayInstance) || void 0 === t2 ? void 0 : t2.consent)) {
963
+ var n2;
964
+ this.clickToPayInstance.controller.contentWindow.postMessage({ type: "submit", channel: l, data: { checkoutOptions: null === (n2 = this.clickToPayInstance) || void 0 === n2 ? void 0 : n2.checkoutOptions } }, this.clickToPayInstance.url);
965
+ } else {
966
+ var i2 = () => this.controller.contentWindow.postMessage({ type: "submit", channel: l, data: { method: this.paymentMethodId ? "id" : "card", threeDSEnabled: !!this.threeDS && this.threeDSEnabled } }, this.frameUrl);
967
+ this.threeDS && this.threeDSEnabled ? this.threeDS.ready.then(i2) : i2();
968
+ }
969
+ }
970
+ setDebug(e2) {
971
+ localStorage.setItem(i, String(e2));
972
+ }
973
+ addFont(e2) {
974
+ this.font = e2.replace(/\s/g, "+");
975
+ }
976
+ constructor(e2) {
977
+ var t2, i2;
978
+ J(this, "config", void 0), J(this, "controller", void 0), J(this, "frameUrl", void 0), J(this, "apiUrl", void 0), J(this, "cdnBaseUrl", void 0), J(this, "parentOrigin", void 0), J(this, "font", void 0), J(this, "cardNumber", void 0), J(this, "securityCode", void 0), J(this, "expiryDate", void 0), J(this, "otherFields", {}), J(this, "method", "card"), J(this, "clickToPayInstance", void 0), J(this, "clickToPay", void 0), J(this, "threeDS", void 0), J(this, "threeDSEnabled", true), J(this, "environmentPath", void 0), J(this, "paymentMethodId", void 0), J(this, "autoAdvance", null), J(this, "schemeIcons", null), J(this, "cardDetailsSchemes", null), J(this, "controllerReady", void 0), J(this, "_resolveControllerReady", void 0), y.unsubscribeAll(), this.config = $({ environment: "production" }, e2), this.controllerReady = new Promise((e3) => {
979
+ var t3 = Date.now();
980
+ this._resolveControllerReady = () => e3(Date.now() - t3);
981
+ }), this.config.paymentMethodId && !this.config.paymentMethod && O(c.PAYMENT_METHOD_ID_DEPRECATED), this.environmentPath = "sandbox" === this.config.environment ? "sandbox." : "", this.frameUrl = window.SECURE_FIELDS_FRAME_URL || "https://secure-fields.".concat(this.environmentPath).concat(this.config.gr4vyId, ".gr4vy.app"), this.parentOrigin = window.location.origin, this.paymentMethodId = (null === (t2 = this.config.paymentMethod) || void 0 === t2 ? void 0 : t2.id) || this.config.paymentMethodId, this.cdnBaseUrl = (function(e3) {
982
+ return r(e3, arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "production", "cdn");
983
+ })(this.config.gr4vyId, this.config.environment);
984
+ var a2 = $({ parentOrigin: this.parentOrigin, sessionId: this.config.sessionId, gr4vyId: this.config.gr4vyId, environment: this.config.environment }, this.paymentMethodId ? { paymentMethodId: this.paymentMethodId } : {});
985
+ null === (i2 = document.body.querySelector("iframe#controller[src*=secure-fields]")) || void 0 === i2 || i2.remove(), this.controller = document.createElement("iframe"), this.controller.id = "controller", this.controller.src = n("".concat(this.frameUrl, "/controller.html"), a2), this.controller.title = "Secure Controller", this.controller.style.position = "absolute", this.controller.style.left = "-9999999px", document.body.appendChild(this.controller), this.paymentMethodId && (this.cardNumber = new W(), this.expiryDate = new W()), g("Initialized", X($({}, this.config), { version: te.version, frameUrl: this.frameUrl, parentOrigin: this.parentOrigin }));
986
+ var s2 = (e3) => {
987
+ if (e3.origin === this.frameUrl) switch (e3.data.type) {
988
+ case "ready":
989
+ var t3 = $({ version: te.version }, this.config);
990
+ y.publish(o.READY, t3), this._resolveControllerReady(), g("Ready", t3);
991
+ break;
992
+ case "form-change":
993
+ y.publish(o.FORM_CHANGE, e3.data.data), g("Form change", e3.data.data);
994
+ }
995
+ };
996
+ v.remove("message", s2, "init"), v.add("message", s2, "init"), this.controllerReady.then((e3) => g("Loaded controller after ".concat(e3, " milliseconds")));
997
+ }
998
+ }
999
+ return t;
1000
+ })());
1001
+ }
1002
+ });
1003
+
20
1004
  // src/index.tsx
21
1005
  var index_exports = {};
22
1006
  __export(index_exports, {
@@ -674,10 +1658,10 @@ function useThrottleCheckout(options) {
674
1658
 
675
1659
  // src/useSecureCard.tsx
676
1660
  var import_react7 = require("react");
677
- var import_secure_fields2 = require("@gr4vy/secure-fields");
1661
+ var import_secure_fields2 = __toESM(require_lib(), 1);
678
1662
 
679
1663
  // src/threeDSecure.ts
680
- var import_secure_fields = require("@gr4vy/secure-fields");
1664
+ var import_secure_fields = __toESM(require_lib(), 1);
681
1665
  function resolveChallenge({ instance, element, challengeWindowSize }) {
682
1666
  return new Promise((resolve) => {
683
1667
  const handleFinish = () => {