!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Hexea=t():e.Hexea=t()}(self,()=>(()=>{"use strict";var e={d:(t,i)=>{for(var n in i)e.o(i,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:i[n]})}};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),e.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var t={};e.d(t,{default:()=>L});const i="validation_error";const n=class{constructor(e,t=null,n=null,a=null){this.type=i,this.message=e,this.modelState=a,this.errors=n,this.responseCode=t}},a="configuration_error";const o=class{constructor(e){this.type=a,this.message=e}},s="internal_server_error";const r=class{constructor(e,t=null,i=null,n=null){this.type=s,this.message=e,this.responseCode=t,this.errors=i,this.detailed_error_message=n}};const l=class{constructor(e,t="*"){var i,n,a;this.startSession=this.startSession.bind(this),this.invoke=this.invoke.bind(this),this.message=this.message.bind(this),this.ready=this.ready.bind(this),this.frameCallback=this.frameCallback.bind(this),this.frameCallbackError=this.frameCallbackError.bind(this),this.frameReady=this.frameReady.bind(this),this.isAlive=this.isAlive.bind(this),this.sendMessage=this.sendMessage.bind(this),this.processMessage=this.processMessage.bind(this),this.rpcID=0,this.target=e,this.host=t,this.promises={},this.readyQueue=[],this.readyStatus=!1,this.methods={},i=window,n="message",a=this.message,i.addEventListener?i.addEventListener(n,a,!1):i.attachEvent(`on${n}`,a)}startSession(){return this.sendMessage("frameReady"),this.frameReady()}unbind(){var e,t,i;e=window,t="message",i=this.message,e.removeEventListener?e.removeEventListener(t,i,!1):e.detachEvent(`on${t}`,i)}invoke(e,...t){return this.ready(()=>this.sendMessage(e,t))}message(e){let t=!1;try{t=e.source===this.target&&("*"===this.host||e.origin===this.host)}catch(e){}t&&this.processMessage(e.data)}ready(e){return this.readyStatus?e():new Promise(t=>{this.readyQueue.push(()=>{t(e())})})}frameCallback(e,t){this.promises[e]&&this.promises[e].resolve(t),delete this.promises[e]}frameCallbackError(e,t){this.promises[e]&&this.promises[e].reject(t),delete this.promises[e]}frameReady(){return this.readyStatus=!0,this.readyQueue.forEach(e=>{e()}),!1}isAlive(){return!0}sendMessage(e,t=[]){const i=++this.rpcID;return new Promise((n,a)=>{this.promises[i]={resolve:n,reject:a};const o=JSON.stringify({method:e,args:t,id:i});if(null==(null!=this.target?this.target.postMessage:null)){const e=new Error("Unable to communicate. Please contact support if the problem persists.");if(null==this.methods.rpcError)throw e;return void this.methods.rpcError(e)}this.target.postMessage(o,this.host)})}processMessage(e){let t,l;try{l=JSON.parse(e)}catch(e){return}if(-1!==["frameReady","frameCallback","frameCallbackError","isAlive"].indexOf(l.method)){t=null;const e=this[l.method];null!=e&&(t=e.apply(this,l.args))}else t="function"==typeof this.methods[l.method]?this.methods[l.method](...l.args):void 0;"frameCallback"!==l.method&&"frameCallbackError"!==l.method&&(Promise.resolve(t)===t?t.then(e=>this.invoke("frameCallback",l.id,e)).catch(e=>{return this.invoke("frameCallbackError",l.id,(t=e).type===i?new n(t.message):t.type===a?new o(t.message):t.type===s?new r(t.message):t);var t}):this.invoke("frameCallback",l.id,t))}},c="client_error";const h=class{constructor(e,t,i,n={}){this.paymentMethod=e,this.type=t,this.element=i,this.options=n,this.rpc=null,this.isDestroyed=!1,this.onChange=this.onChange.bind(this),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this),this.callbacks={},this.initialize()}initialize(){this.createElement(),this.createRPC(),this.findLabel()}blur(){this.rpc&&this.rpc.invoke("blur")}clear(){this.rpc&&this.rpc.invoke("clear")}focus(){this.rpc&&this.rpc.invoke("focus")}destroy(){if(!this.isDestroyed){this.isDestroyed=!0;try{this.paymentMethod&&"function"==typeof this.paymentMethod.unregisterFrame&&this.paymentMethod.unregisterFrame(this)}catch(e){this.paymentMethod&&"function"==typeof this.paymentMethod.logTrace&&this.paymentMethod.logTrace("[Field] Failed to unregister field frame",{fieldType:this.type,error:e})}this.rpc&&this.rpc.unbind&&this.rpc.unbind(),this.component&&this.component.parentNode?this.component.parentNode.removeChild(this.component):this.frame&&this.frame.parentNode&&this.frame.parentNode.removeChild(this.frame),this.component=null,this.frame=null,this.rpc=null,this.callbacks={}}}on(e,t){if("function"!=typeof t)throw new Error("callback must be a function");this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t)}emit(e,...t){(this.callbacks[e]||[]).forEach(e=>{e(...t)})}onChange(e){this.emit("change",e)}onFocus(){this.emit("focus")}onBlur(){this.emit("blur")}createElement(){const e=document.createElement("div");e.style.cssText="border: none !important;\nmargin: 0px !important;\npadding: 0px !important;\ndisplay: block !important;\nbackground: transparent !important;\nposition: relative !important;\nopacity: 1 !important;\n";const t=document.createElement("iframe");t.setAttribute("frameBorder","0"),t.setAttribute("allowtransparency","true"),t.setAttribute("scrolling","no"),t.name=this.getFrameID(),t.title="Secure payment method input frame",t.style.cssText="border: none !important;\nmargin: 0px !important;\npadding: 0px !important;\nwidth: 1px !important;\nmin-width: 100% !important;\noverflow: hidden !important;\ndisplay: block !important;\nheight: 20px;\nvisibility: hidden\n",t.addEventListener("load",()=>{t.style.visibility="visible"}),e.appendChild(t),t.src=this.getFieldHtmlUrl(),this.element.appendChild(e),this.component=e,this.frame=t}getFieldHtmlUrl(){const{pcct:e,hexeaOrigin:t,hexeaInstanceId:i}=this.paymentMethod.client,{origin:n}=window.location,a=`?origin=${encodeURIComponent(n)}&uid=${i}&pcct=${e}&ts=${Date.now()}`;switch(this.type){case"cardNumber":return`${t}/hexea/cardnumber${a}`;case"cardExpiration":return`${t}/hexea/cardexpiration${a}`;case"cardSwipe":return`${t}/hexea/cardswipe${a}`;case"cardVerificationValue":return`${t}/hexea/cardverificationvalue${a}`;default:throw new Error(`${this.type} is not a valid field type. Try cardNumber, cardExpiration, or cardSwipe, or cvv instead`)}}createRPC(){const{frame:e,paymentMethod:t,options:i}=this,n=new l(e.contentWindow,this.paymentMethod.client.hexeaOrigin);n.methods.change=this.onChange,n.methods.focus=this.onFocus,n.methods.blur=this.onBlur,this.rpc=n,n.invoke("setOptions",i).then(({height:i})=>{t.registerFrame(this),e.style.height=`${i}px`,e.style.minHeight=`${i}px !important`,this.emit("ready")})}findLabel(){const e=e=>{e.addEventListener("click",e=>{e.preventDefault(),this.focus()})};const{id:t}=this.element;if(t){const i=document.querySelector(`label[for="${t}"]`);i&&e(i)}!function t(i){i&&("LABEL"===i.tagName?e(i):t(i.parentNode))}(this.element.parentNode)}getFrameID(){return this.options.frameID}createPublicApi(){return{on:this.on.bind(this),blur:this.blur.bind(this),clear:this.clear.bind(this),focus:this.focus.bind(this)}}};class d{static configCache=new Map;static getConfigValue(e,t=null){return 0===d.configCache.size&&d.initializeCache(),d.configCache.has(e)?d.configCache.get(e):t}static setConfig(e){e&&"object"==typeof e&&0!==Object.keys(e).length&&(d.configCache.clear(),Object.entries(e).forEach(([e,t])=>{d.configCache.set(e,t)}))}static initializeCache(){let e={};if(d.isRunningLocally()){const t=process.env.ENV_CONFIG;"string"==typeof t?e=JSON.parse(t||"{}"):"object"==typeof t&&null!==t&&(e=t)}Object.entries(e).forEach(([e,t])=>{d.configCache.set(e,t)})}static isRunningLocally(){return!1}}const p=d,m=["amex","discover","masterCard","visa"];class y{static sdkReadyPromise=null;static ensureApplePaySDKLoaded(e){y.sdkReadyPromise||(y.sdkReadyPromise=new Promise((t,i)=>{if(document.querySelector(`script[src="proxy.php?url=${e}"]`))y.pollForSDKReady(t,i);else{const n=document.createElement("script");n.async=!0,n.src=e,n.crossOrigin="anonymous",n.onload=()=>{y.pollForSDKReady(t,i)},n.onerror=e=>{i(e)},document.body.appendChild(n)}}))}static pollForSDKReady(e,t){let i=0;const n=()=>{window.ApplePaySession&&window.ApplePaySession.applePayCapabilities?e():(i+=100,i>=5e3?t(new Error("Apple Pay SDK unable to load within 5000ms")):setTimeout(n,100))};n()}constructor(e){this.walletButton=e,this.paymentMethod=e.paymentMethod,this.options=e.options,this.style=this.options.wallets.applePay.style,this.futurePaymentOptions=this.options.wallets.applePay.futurePaymentOptions,this.supportedNetworks=m.filter(t=>e.supportedNetworks.filter(e=>e.toLowerCase()===t.toLowerCase()).length>0),this.applePaySDKUrl=p.getConfigValue("APPLEPAY_SDKURL"),this.tokenNotificationURL=p.getConfigValue("TOKENURLNOTIFICATION"),this.applePaySettings={merchantIdApplePay:this.paymentMethod.merchantInfo.applePayPSPEnabled?this.paymentMethod.client.pcct:p.getConfigValue("APPLEPAY_MERCHANTID"),currencyCode:"USD",countryCode:"US",merchantCapabilities:["supports3DS"]},this.options.debitCardOnly&&this.applePaySettings.merchantCapabilities.push("supportsDebit"),this.applePayStyle=`\n /*\n Apple Pay Style\n */\n apple-pay-button {\n --apple-pay-button-width: ${this.style.width};\n --apple-pay-button-height: ${this.style.height};\n --apple-pay-button-border-radius: ${this.style.borderRadius};\n --apple-pay-button-padding: 0px 0px;\n --apple-pay-button-box-sizing: border-box;\n }\n `,y.ensureApplePaySDKLoaded(this.applePaySDKUrl)}logTrace(e,t={}){this.walletButton.logTrace(e,{pcct:this.paymentMethod.client.pcct,...t})}logException(e,t={}){this.walletButton.logException(e,{pcct:this.paymentMethod.client.pcct,...t})}startApplePaySession(e){const t=new ApplePaySession(10,e);this.handleApplePayEvents(t),t.begin()}handleApplePayEvents(e){const t={startDate:"",endDate:"",frequency:"",type:""},i={nameOnCard:"",paymentData:"",paymentMethod:"",transactionIdentifier:"",appleRecurrenceData:t},n={addressLine1:"",isSaved:this.options.isSaved,postalCode:"",countryCode:"USA",applePay:i,idType:this.options.idType,id:this.options.id,debitCardOnly:this.options.debitCardOnly};e.onvalidatemerchant=t=>{const i={appleUrl:t.validationURL,body:{merchantIdentifier:this.applePaySettings.merchantIdApplePay,domainName:this.options.merchantDomain??window.location.hostname,displayName:this.walletButton.customerName}};this.logTrace("Create apple pay session",{applePaySession:i,message:"Apple pay session"}),this.paymentMethod.client.controllerRPC.invoke("getApplePaySession",this.paymentMethod.client.pcct,i).then(t=>{e.completeMerchantValidation(JSON.parse(t))}).catch(e=>{this.logException(e,{applePaySession:i,message:"Error occured in apple pay session endpoint"})})},e.onpaymentauthorized=a=>{if(i.paymentData=a.payment.token.paymentData,i.paymentMethod=a.payment.token.paymentMethod,i.transactionIdentifier=a.payment.token.transactionIdentifier,i.nameOnCard=`${a.payment.billingContact.givenName} ${a.payment.billingContact.familyName}`,n.addressLine1=a.payment.billingContact.addressLines[0],n.postalCode=a.payment.billingContact.postalCode,n.deferredUse=this.options.deferredUse,n.isSaved=this.options.deferredUse?this.options.deferredUse:this.options.isSaved,n.email=this.options.email??a.payment.shippingContact.emailAddress,this.options.deferredUse){t.startDate=this.futurePaymentOptions.recurringPaymentStartDate,t.endDate=this.futurePaymentOptions.recurringPaymentEndDate,t.frequency=this.futurePaymentOptions.frequency,t.type="onetime"===this.futurePaymentOptions.type?"oneTime":this.futurePaymentOptions.type;Object.values(t).some(e=>null!=e&&""!==e)||(i.appleRecurrenceData=null)}else i.appleRecurrenceData=null;this.logTrace("Apple pay tokenize"),this.paymentMethod.client.controllerRPC.invoke("tokenizeCardData",this.paymentMethod.client.pcct,n).then(t=>{t&&t.error?(e.completePayment(ApplePaySession.STATUS_FAILURE),this.walletButton.onPaymentMethod({error:t.error})):(this.walletButton.onPaymentMethod({paymentData:{paymentMethodToken:t.paymentMethodToken,isTest:t.isTest,paymentMethodType:t.paymentMethodType,nameOnCard:t.nameOnCard,bin:t.bin,last4:t.last4,expireMonth:t.expireMonth,expireYear:t.expireYear,addressLine1:t.addressLine1,postalCode:t.postalCode,brand:t.brand,countryCode:t.countryCode,isSaved:t.isSaved,deferredUse:t.deferredUse,quickCheckout:t.quickCheckout,isSwiped:t.isSwiped,isApplePay:"ApplePay"===t.digitalWallet,amount:this.options.amount,digitalWallet:t.digitalWallet,phone:a.payment.shippingContact?.phoneNumber||null,email:a.payment.shippingContact?.email||null,address:{addressLine1:a.payment.billingContact.addressLines[0],addressLine2:a.payment.billingContact.addressLines[1]??null,postalCode:a.payment.billingContact.postalCode,country:a.payment.billingContact.countryCode,city:a.payment.billingContact.locality,state:a.payment.billingContact.administrativeArea}},success:!0}),e.completePayment(ApplePaySession.STATUS_SUCCESS),this.logTrace("Apple pay tokenize success"))}).catch(t=>{e.completePayment(ApplePaySession.STATUS_FAILURE),this.walletButton.onPaymentMethod({error:t}),this.logException(t,{message:"Apple pay tokenize failed"})})},e.oncancel=e=>{const t={event:e,message:"Error occured in apple pay session endpoint"};this.logTrace("Apple pay session canceled ",t)}}static getIntervalValues(e){const t={daily:["day",1],weekly:["day",7],everyotherweek:["day",14],monthly:["month",1],quarterly:["month",3],annually:["year",1]},i=e?.toLowerCase();if(t[i])return t[i];throw new Error(`Invalid frequency: "${e}"`)}static validateDates(e,t){const i=new Date(e),n=t?new Date(t):null;if(Number.isNaN(i.getTime()))throw new Error("Start date is invalid");if(in)throw new Error("Start date is greater than end date")}return!0}static getPaymentType(e){const t=e?.toLowerCase();return"recurring"===t?"recurring":"onetime"===t?"deferred":null}buildDeferredPaymentModel(e){return{deferredPaymentRequest:{paymentDescription:this.futurePaymentOptions.paymentDescription,deferredBilling:{label:"Deferred",amount:this.options.amount,paymentTiming:e,deferredPaymentDate:this.futurePaymentOptions.recurringPaymentStartDate},billingAgreement:"",managementURL:this.futurePaymentOptions.managementURL,tokenNotificationURL:this.tokenNotificationURL}}}buildRecurringPaymentModel(e){let t,i;try{[t,i]=y.getIntervalValues(this.futurePaymentOptions.frequency),y.validateDates(this.futurePaymentOptions.recurringPaymentStartDate,this.futurePaymentOptions.recurringPaymentEndDate)}catch(e){throw this.logException(e,{message:"Invalid Apple Pay recurring setup"}),e}return{recurringPaymentRequest:{paymentDescription:this.futurePaymentOptions.paymentDescription,regularBilling:{label:"Recurring",amount:this.options.amount,paymentTiming:e,recurringPaymentStartDate:this.futurePaymentOptions.recurringPaymentStartDate,recurringPaymentEndDate:this.futurePaymentOptions.recurringPaymentEndDate,recurringPaymentIntervalUnit:t,recurringPaymentIntervalCount:i},billingAgreement:"",managementURL:this.futurePaymentOptions.managementURL,tokenNotificationURL:this.tokenNotificationURL}}}buildApplePayModel(){const e={currencyCode:this.applePaySettings.currencyCode,countryCode:this.applePaySettings.countryCode,merchantCapabilities:this.applePaySettings.merchantCapabilities,supportedNetworks:this.supportedNetworks,requiredBillingContactFields:["name","postalAddress"],total:{label:this.walletButton.customerName,amount:this.options.amount,type:"final"},requiredShippingContactFields:["email"]};if(!0===this.options.deferredUse){const t=y.getPaymentType(this.futurePaymentOptions.type);"deferred"===t?Object.assign(e,this.buildDeferredPaymentModel(t)):"recurring"===t?Object.assign(e,this.buildRecurringPaymentModel(t)):this.logTrace("Invalid Apple Pay type for deferred use!")}return e}async checkApplePayAvailability(){try{if(await y.sdkReadyPromise,!window.ApplePaySession)return!1;if(!window.ApplePaySession.applePayCapabilities)return!!window.ApplePaySession.canMakePayments&&window.ApplePaySession.canMakePayments();try{const e=await window.ApplePaySession.applePayCapabilities(this.applePaySettings.merchantIdApplePay);return"paymentCredentialsAvailable"===e.paymentCredentialStatus||"paymentCredentialsUnavailable"===e.paymentCredentialStatus}catch(e){return this.logException(e,{message:"Apple Pay applePayCapabilities failed"}),!1}}catch(e){return this.logException(e,{message:"Apple Pay checkApplePayAvailability failed"}),!1}}render(e){this.checkApplePayAvailability().then(t=>{if(!t)return;e.querySelectorAll("apple-pay-button").forEach(e=>{e.parentNode&&e.parentNode.removeChild(e)});const i=this.buildApplePayModel();if(!i)return;const n=(this.paymentMethod.merchantInfo.acceptDonations??!1)&&"NP"===this.paymentMethod.merchantInfo.customerType,a="donate"===this.style.buttonType?.toLowerCase()&&n?this.style.buttonType??"plain":"plain",o=document.createElement("apple-pay-button");o.setAttribute("buttonstyle",this.style.color),o.setAttribute("type",a),o.setAttribute("locale","en-US");const s="apple-pay-button-style",r=document.getElementById(s);r&&r.parentNode&&r.parentNode.removeChild(r);const l=document.createElement("style");l.id=s,l.innerHTML=this.applePayStyle;const c=document.querySelector("script");c&&c.parentNode?c.parentNode.insertBefore(l,c):document.head.appendChild(l),o.addEventListener("click",()=>{this.startApplePaySession(i)}),e.appendChild(o),this.logTrace("Apple pay initialized",{options:this.options})})}}const u={apiVersion:2,apiVersionMinor:0},g=["AMEX","DISCOVER","MASTERCARD","VISA"],f=["PAN_ONLY","CRYPTOGRAM_3DS"];class w{static sdkReadyPromise=null;constructor(e){this.isInitializing=!1,this.walletButton=e,this.paymentMethod=e.paymentMethod,this.controllerRPC=this.paymentMethod.client.controllerRPC,this.supportedNetworks=e.supportedNetworks,this.style=e.options.wallets.googlePay.style,this.options=e.options,this.googlePayEnvironment=p.getConfigValue("GOOGLEPAY_ENVIRONMENT");const t=p.getConfigValue("GOOGLEPAY_SDKURL");w.sdkReadyPromise||(w.sdkReadyPromise=new Promise((e,i)=>{if(document.querySelector(`script[src="proxy.php?url=${t}"]`))e();else{const n=document.createElement("script");n.async=!0,n.onload=()=>e(),n.onerror=i,n.src=t,document.body.appendChild(n)}})),w.sdkReadyPromise.then(()=>{this.configureGooglePayClient()}).catch(e=>{this.logException(e,{message:"Google Pay SDK failed to load"})})}logTrace(e,t={}){this.walletButton.logTrace(e,{pcct:this.paymentMethod.client.pcct,...t})}logException(e,t={}){this.walletButton.logException(e,{pcct:this.paymentMethod.client.pcct,...t})}async configureGooglePayClient(){if(this.isInitializing)return;this.isInitializing=!0;await this.waitForGooglePaySDK()&&(this.paymentsClient=new google.payments.api.PaymentsClient({environment:this.googlePayEnvironment,paymentDataCallbacks:{onPaymentAuthorized:e=>this.onPaymentAuthorized(e)}}),this.isInitializing=!1)}waitForGooglePaySDK(e=2e3,t=20){const i=Date.now(),n=a=>{if(!(window.google&&window.google.payments&&window.google.payments.api))return Date.now()-i>=e?(this.logException(new Error("[GooglePay] SDK initialization timeout"),{message:"[GooglePay] SDK timeout"}),void a(!1)):void setTimeout(()=>n(a),t);a(!0)};return new Promise(n)}onPaymentAuthorized(e){return new Promise(t=>{this.logTrace("Google Pay tokenize");const i={addressLine1:e.paymentMethodData.info.billingAddress.address1,isSaved:this.options.isSaved,deferredUse:this.options.deferredUse,postalCode:e.paymentMethodData.info.billingAddress.postalCode,countryCode:"USA",googlePay:{nameOnCard:e.paymentMethodData.info.billingAddress.name,billingAddress:{addressLine1:e.paymentMethodData.info.billingAddress.address1,addressLine2:e.paymentMethodData.info.billingAddress.address2,addressLine3:e.paymentMethodData.info.billingAddress.address3,city:e.paymentMethodData.info.billingAddress.locality,state:e.paymentMethodData.info.billingAddress.administrativeArea,postalCode:e.paymentMethodData.info.billingAddress.postalCode},paymentData:JSON.parse(e.paymentMethodData.tokenizationData.token),cardBrand:e.paymentMethodData.info.cardNetwork,last4:e.paymentMethodData.info.cardDetails},idType:this.options.idType,id:this.options.id,debitCardOnly:this.options.debitCardOnly,email:this.options.email??e.email};this.controllerRPC.invoke("tokenizeCardData",this.paymentMethod.client.pcct,i).then(i=>{i&&i.error?(t({transactionState:"ERROR"}),this.walletButton.onPaymentMethod({error:i.error})):(this.walletButton.onPaymentMethod({paymentData:{paymentMethodToken:i.paymentMethodToken,isTest:i.isTest,paymentMethodType:i.paymentMethodType,nameOnCard:i.nameOnCard,bin:i.bin,last4:i.last4,expireMonth:i.expireMonth,expireYear:i.expireYear,brand:i.brand,isSaved:i.isSaved,deferredUse:i.deferredUse,quickCheckout:i.quickCheckout,isSwiped:i.isSwiped,isApplePay:"ApplePay"===i.digitalWallet,amount:this.options.amount,digitalWallet:i.digitalWallet,phone:e.paymentMethodData.info.billingAddress.phoneNumber,email:e.email,address:{addressLine1:e.paymentMethodData.info.billingAddress.address1,addressLine2:e.paymentMethodData.info.billingAddress.address2,postalCode:e.paymentMethodData.info.billingAddress.postalCode,country:e.paymentMethodData.info.billingAddress.countryCode,city:e.paymentMethodData.info.billingAddress.locality,state:e.paymentMethodData.info.billingAddress.administrativeArea}},success:!0}),t({transactionState:"SUCCESS"}),this.logTrace("Google Pay tokenize success"))}).catch(e=>{t({transactionState:"ERROR"}),this.walletButton.onPaymentMethod({error:e}),this.logException(e,{message:"Google Pay tokenize failed"})})})}waitForPaymentsClient(e=5e3,t=100){const i=Date.now(),n=(a,o)=>{this.paymentsClient?a():Date.now()-i>=e?o(new Error("[GooglePay] PaymentsClient initialization timeout")):setTimeout(()=>n(a,o),t)};return new Promise(n)}async render(e){if(!this.paymentsClient)try{await this.waitForPaymentsClient()}catch(e){return void this.logException(e,{message:"Timeout waiting for Google Pay SDK"})}e.querySelectorAll(".google-pay-button-container").forEach(e=>{e.parentNode&&e.parentNode.removeChild(e)});const t={type:"PAYMENT_GATEWAY",parameters:{gateway:"vanco",gatewayMerchantId:this.paymentMethod.client.pcct}},i=!0===this.options.debitCardOnly,n={type:"CARD",parameters:{allowedAuthMethods:f,allowedCardNetworks:g.filter(e=>this.supportedNetworks.filter(t=>t.toLowerCase()===e.toLowerCase()).length>0),allowCreditCards:!i,allowPrepaidCards:!0,billingAddressRequired:!0,billingAddressParameters:{format:"FULL",phoneNumberRequired:!0}},tokenizationSpecification:t},a={...u,allowedPaymentMethods:[{...n}]};this.paymentsClient.isReadyToPay(a).then(t=>{if(t.result){const t={...u,merchantInfo:{merchantId:w.getFirstNonEmpty(this.options.wallets.googlePay?.merchantId,this.paymentMethod.merchantInfo.googleMerchantID),merchantName:this.walletButton.customerName},callbackIntents:["PAYMENT_AUTHORIZATION"],transactionInfo:{countryCode:"US",currencyCode:"USD",totalPriceStatus:"FINAL",totalPrice:this.options.amount.toString()},emailRequired:!0,allowedPaymentMethods:[n]};this.paymentsClient.prefetchPaymentData(t);const i=document.createElement("div");i.className="google-pay-button-container",this.style.width&&(i.style.width=this.style.width),this.style.height&&(i.style.height=this.style.height);let a="default";if(this.style.color)switch(this.style.color.toLowerCase()){case"black":a="black";break;case"white":case"white-outline":a="white";break;default:a="default"}const o=this.paymentsClient.createButton({buttonType:this.style.buttonType??"short",buttonColor:a,buttonRadius:parseInt(this.style.borderRadius,10),buttonSizeMode:"fill",onClick:()=>{try{this.paymentsClient.loadPaymentData(t).then(()=>{}).catch(e=>{this.logException(e,{message:"Google Pay loadPaymentData"})})}catch(e){this.logException(e,{message:"Google Pay onClick"})}},allowedPaymentMethods:[n]});i.appendChild(o),e.appendChild(i)}}).catch(e=>{this.logException(e,{message:"Google Pay isReadyToPay"})})}static getFirstNonEmpty(...e){return e.find(e=>null!=e&&""!==e)}}class b{constructor(e,t,i){this.paymentMethod=e,this.element=t,this.options=i,this.isDestroyed=!1,this.supportedNetworks=[],this.appleButtonEnabled=!1,this.samsungButtonEnabled=!1,this.googleButtonEnabled=!1,this.onPaymentMethod=this.onPaymentMethod.bind(this),this.callbacks={},this.customerName="",this.renderTimeout=null,this.applePayButton=null,this.googlePayButton=null,e.merchantInfo&&this.updateMerchantInfo(e.merchantInfo)}on(e,t){if("function"!=typeof t)throw new Error("callback must be a function");this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t)}emit(e,...t){(this.callbacks[e]||[]).forEach(e=>{e(...t)})}onPaymentMethod(e){e&&e.error?this.emit("paymentmethod",b.normalizeError(e.error)):this.emit("paymentmethod",e)}static normalizeError(e){return e&&e.type?{error:e}:{error:{type:"unknown_error",message:e?.message??"An error has occurred. Please try again.",errors:[]}}}logTrace(e,t={}){const i={pcct:this.paymentMethod.client.pcct,href:window.location.href};this.paymentMethod.client.logTrace(e,{...i,...t})}logException(e,t={}){this.paymentMethod.client.logException(e,{pcct:this.paymentMethod.client.pcct,...t})}updateMerchantInfo(e){if(this.isDestroyed)return;this.logTrace("MerchantInfo for digital wallet",{merchantInfo:e});let t=[];if(e.amexAllowed&&(t=[...t,"amex"]),e.discoverAllowed&&(t=[...t,"discover"]),e.mastercardAllowed&&(t=[...t,"mastercard"]),e.visaAllowed&&(t=[...t,"visa"]),this.options.cardBrandsAllowed.length>0){const e=this.options.cardBrandsAllowed.map(e=>e.toLowerCase());t=t.filter(t=>e.includes(t.toLowerCase()))}this.supportedNetworks=t,e.applePayAllowed&&(this.appleButtonEnabled=e.applePayAllowed),e.samsungPayAllowed&&(this.samsungButtonEnabled=e.samsungPayAllowed),e.googlePayAllowed&&(this.googleButtonEnabled=e.googlePayAllowed),e.customerName&&(this.customerName=e.customerName),this.createElement()}createElement(){this.isDestroyed||(this.renderTimeout&&clearTimeout(this.renderTimeout),this.renderTimeout=setTimeout(()=>{this.createElementInternal()},500))}createElementInternal(){this.isDestroyed||(this.appleButtonEnabled&&(this.createApplePayButton(),this.logTrace("Element created for apple pay")),this.googleButtonEnabled&&(this.createGooglePayButton(),this.logTrace("Element created for google pay")),this.walletContainer())}clearApplePayButton(){if(!this.element)return;this.element.querySelectorAll("apple-pay-button").forEach(e=>{e.parentNode&&e.parentNode.removeChild(e)});const e=document.getElementById("apple-pay-button-style");e&&e.parentNode&&e.parentNode.removeChild(e)}clearGooglePayButton(){this.element&&this.element.querySelectorAll(".google-pay-button-container").forEach(e=>{e.parentNode&&e.parentNode.removeChild(e)})}createApplePayButton(){const e=new y(this);this.applePayButton=e,e.render(this.element)}createGooglePayButton(){const e=this.paymentMethod.merchantInfo.googleMerchantID,t=this.options.wallets?.googlePay?.merchantId;if(!e&&!t){const e="merchantId is required for Google Pay transactions.";throw this.logTrace(e,this.options),new Error(e)}const i=new w(this);this.googlePayButton=i,i.render(this.element)}walletContainer(){if(0===(this.appleButtonEnabled?1:0)+(this.googleButtonEnabled?1:0)+(this.samsungButtonEnabled?1:0))return;const{layoutDirection:e,gap:t}=this.options.containerStyle,i=this.options.wallets?.applePay?.style?.width||this.options.wallets?.googlePay?.style?.width||this.options.wallets?.samsungPay?.style?.width;let n="";n="column"===e?["display: flex","flex-direction: column","width: 100%","align-items: "+(i?"center":"stretch"),`gap: ${t}`].join("; "):i?["display: flex","flex-direction: row","width: 100%","align-items: center",`gap: ${t}`].join("; "):["display: grid","width: 100%","grid-auto-flow: column","grid-auto-columns: 1fr","align-items: center",`gap: ${t}`].join("; "),this.element.setAttribute("style",n)}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.renderTimeout&&(clearTimeout(this.renderTimeout),this.renderTimeout=null),this.element&&(this.clearApplePayButton(),this.clearGooglePayButton(),this.element.removeAttribute("style")),this.applePayButton=null,this.googlePayButton=null,this.callbacks={})}createPublicApi(){return{on:this.on.bind(this)}}}const P=b;class C{static transposeOptions(e,t){const i=JSON.parse(JSON.stringify(e));return i.version||i.amount?C.normalizeNewStructure(i,t):C.normalizeOldStructure(i,t)}static normalizeNewStructure(e,t){const i={...e};return i.version=e.version??"1.0",i.isSaved=e.isSaved??!1,i.deferredUse=e.deferredUse??!1,i.id=e.id??null,i.idType=e.idType??null,i.email=e.email?.trim()||null,i.cardBrandsAllowed=e.cardBrandsAllowed??[],i.debitCardOnly=e.debitCardOnly??!1,i.containerStyle={gap:i.containerStyle?.gap||"10px",layoutDirection:i.containerStyle?.layoutDirection||"row"},i.wallets=i.wallets||{},i.wallets.applePay=C.normalizeWalletConfig(t,e.wallets?.applePay,{futurePaymentOptions:e.wallets?.applePay?.futurePaymentOptions||{}}),i.wallets.googlePay=C.normalizeWalletConfig(t,e.wallets?.googlePay,{merchantId:e.wallets?.googlePay?.merchantId}),i.wallets.samsungPay=C.normalizeWalletConfig(t,e.wallets?.samsungPay),i}static normalizeOldStructure(e,t){const i=C.normalizeStyle(t,e.style);return{version:"1.0",amount:e.total?.amount,merchantDomain:null,containerStyle:{layoutDirection:"row",gap:"10px"},isSaved:e.isSaved??!1,deferredUse:e.deferredUse??!1,id:e.id??null,idType:e.idType??null,email:e.email??null,cardBrandsAllowed:[],debitCardOnly:!1,wallets:{applePay:{style:i,futurePaymentOptions:e.deferredUse?{type:e.type,paymentDescription:e.paymentDescription,recurringPaymentStartDate:e.recurringPaymentStartDate,recurringPaymentEndDate:e.recurringPaymentEndDate,frequency:e.frequency,managementURL:e.managementURL}:{}},googlePay:{merchantId:e.merchantId,style:i},samsungPay:{style:i}}}}static normalizeWalletConfig(e,t,i={}){return{...t||{},style:C.normalizeStyle(e,t?.style||{}),...i}}static normalizeStyle(e,t={}){return{color:t.color||"black",height:`${Math.max(parseInt(t.height,10)||0,40)}px`,...t.width&&C.calculateWidth(t.width),borderRadius:C.calculateRadius(t.borderRadius,e),buttonType:t.buttonType}}static calculateWidth(e){if("string"==typeof e&&e.trim().endsWith("%"))return{width:e};const t=parseInt(e,10)||0;return{width:`${Math.max(t,100)}px`}}static calculateRadius(e,t){if("string"==typeof e&&e.trim().endsWith("em")){return parseFloat(e)*(parseFloat(window.getComputedStyle(t).fontSize)||16)+"px"}return"string"==typeof e&&e.trim().endsWith("px")?e:`${parseInt(e,10)||0}px`}}const E=C;let v=0;const S="card",A="echeck",D=[S,A,"wallet"],M=e=>{e&&"function"==typeof e.destroy&&e.destroy()};const k=class{constructor(e,t){if(-1===D.indexOf(t))throw new Error(`Payment method type "${t}" is not supported. Supported types: ${D.join(", ")}`);v+=1,this.name=`pm${v}`,this.client=e,this.type=t,this.fields=[],this.walletButton=void 0,this.submitting=!1,this.merchantInfo=null,this.isDestroyed=!1}field(e,t,i={}){const n=this.client.createFrameId(),a=new h(this,e,t,{...i,frameID:n,controllerFrameID:this.client.controllerFrameID});return this.fields.push(a),a.createPublicApi()}button(e,t,i={}){if("string"!=typeof e)throw new Error("Invalid button type.");M(this.walletButton);const n=E.transposeOptions(i,t),a=new P(this,t,{...n});return this.walletButton=a,a.createPublicApi()}buttons(e,t={}){M(this.walletButton);const i=E.transposeOptions(t,e),n=new P(this,e,{...i});return this.walletButton=n,n.createPublicApi()}updateMerchantInfo(e){this.merchantInfo=e,this.walletButton&&this.walletButton.updateMerchantInfo(e)}async tokenize(e={},t,i){if(this.submitting)return Promise.reject();this.submitting=!0;try{let n=null;return this.type===S?n=await this.client.controllerRPC.invoke("submit",this.name,e,t,i):this.type===A&&(n=await this.client.controllerRPC.invoke("submitEcheck",e,t,i)),n}catch(e){throw e}finally{this.submitting=!1}}registerFrame(e){this.client.registerPaymentMethodFrame(this.name,{name:e.getFrameID(),type:e.type})}unregisterFrame(e){this.client.unregisterPaymentMethodFrame(this.name,{name:e.getFrameID(),type:e.type})}destroy(){this.isDestroyed||(this.isDestroyed=!0,Array.isArray(this.fields)&&this.fields.forEach(e=>{try{M(e)}catch(t){this.logTrace("[PaymentMethod] Failed to destroy field",{fieldType:e&&e.type,error:t})}}),M(this.walletButton),this.fields=[],this.walletButton=void 0)}createPublicApi(){return{name:this.name,type:this.type,field:this.field.bind(this),button:this.button.bind(this),buttons:this.buttons.bind(this)}}isValidIdType(e){return"idsId"===e||"partnerPayerRef"===e}isValidString(e){return"string"==typeof e&&""!==e.trim()}logTrace(e,t={}){this.client.logTrace(e,{pcct:this.client.pcct,...t})}logException(e,t={}){this.client.logException(e,{pcct:this.client.pcct,...t})}};const T=class{constructor(e){this.rpc=e}async logTrace(e,t={}){try{this.rpc&&await this.rpc.invoke("logTrace",e,t)}catch(e){}}async logException(e,t={}){try{if(this.rpc){let i;i=e instanceof Error?{message:e.message,stack:e.stack}:e,await this.rpc.invoke("logException",i,t)}}catch(e){}}async logEvent(e,t={}){try{this.rpc&&await this.rpc.invoke("logEvent",e,t)}catch(e){}}};const I=class{constructor(e,t,i={}){this.logger=e,this.fieldName=t,this.setConfig(i),this.isInitializing=!1}async start(e,t){if(!this.isInitializing){if(!this.config){const i=new Error("[TransactionMonitor] Configuration missing. Call setConfig() first.");return void this.logException(i,{sessionKey:e,pcct:t})}if(e&&"unknown"!==e&&t&&"unknown"!==t)try{this.isInitializing=!0,await this.loadSDK(e,t)}catch(i){this.logException(i,{sessionKey:e,pcct:t,message:"[TransactionMonitor] Error starting session"})}else this.logException(new Error("[TransactionMonitor] Invalid session key or pcct provided"),{fieldName:this.fieldName,sessionKey:e,pcct:t})}}async loadSDK(e,t){if(!this.config.apiSubdomain){const i=new Error("[TransactionMonitor] API subdomain is not configured.");return this.logException(i,{fieldName:this.fieldName,sessionKey:e,pcct:t}),Promise.resolve(!1)}return document.querySelector(`script[src*="${this.config.apiSubdomain}/assets/loader.min.js"]`)?(await this.waitAndCreateContext(e,t),Promise.resolve(!0)):new Promise(i=>{const n=document.createElement("script");n.type="text/javascript",n.async=!0,n.src=`https://${this.config.apiSubdomain}/assets/loader.min.js`,n.onload=async()=>{await this.waitAndCreateContext(e,t),i(!0)},n.onerror=()=>{const a=new Error("[TransactionMonitor] Error loading SDK.");this.logException(a,{sessionKey:e,pcct:t}),n.parentNode&&n.parentNode.removeChild(n),i(!1)};const a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(n,a)})}async waitAndCreateContext(e,t){try{if(!await this.waitForSDK())return;this.createContext(e,t)}catch(i){this.logException(i,{sessionKey:e,pcct:t,message:"[TransactionMonitor] Error creating context"})}}waitForSDK(e=3e3,t=50){const i=Date.now(),n=a=>{const o=window[this.config.sdkGlobalName];if(o&&"function"==typeof o.createContext)a(!0);else{if(Date.now()-i>=e){const e=new Error("[TransactionMonitor] SDK initialization timeout");return this.logException(e,{message:"[TransactionMonitor] SDK timeout"}),void a(!1)}setTimeout(()=>n(a),t)}};return new Promise(n)}createContext(e,t){const i={clientId:this.config.clientId,sessionKey:e,flow:this.config.flow,environment:this.config.environment,parentElement:this.config.parentElement,partnerId:t,apiSubdomain:this.config.apiSubdomain,pixelSubdomain:this.config.pixelSubdomain,onDeviceResponse:i=>this.handleDeviceResponse(i,t,e)},n=window[this.config.sdkGlobalName].createContext(i);this.logTrace("[TransactionMonitor] Context created successfully:",{config:n.config,sessionKey:e,pcct:t})}handleDeviceResponse(e,t,i){if(this.logTrace("[TransactionMonitor] Device response received:",{data:e,pcct:t,sessionKey:i}),this.config.onDeviceResponseCallback)try{this.config.onDeviceResponseCallback(e,t,i)}catch(e){this.logException(e,{sessionKey:i,pcct:t,message:"[TransactionMonitor] Error in onDeviceResponse callback"})}}setConfig(e={}){this.config={clientId:e.clientId,environment:e.environment,apiSubdomain:e.apiSubdomain,pixelSubdomain:e.pixelSubdomain,flow:e.flow||this.fieldName,parentElement:e.parentElement||document.body,sdkGlobalName:e.sdkGlobalName||"_Sardine"},"function"==typeof e.onDeviceResponse&&(this.config.onDeviceResponseCallback=e.onDeviceResponse)}logTrace(e,t={}){this.logger&&this.logger.logTrace&&this.logger.logTrace(e,t)}logException(e,t={}){this.logger&&this.logger.logException&&this.logger.logException(e,t)}};const x=new class{generate(){return function(){const e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=15&e[6]|64,e[8]=63&e[8]|128;const t=Array.from(e,e=>e.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}()}key(){const e=new Uint8Array(12);return crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,"0")).join("")}};let N="";class R{constructor(e){if("string"!=typeof e||!e.trim())throw new Error("PCCT is required");this.pcct=e.trim(),this.paymentMethods={},this.controllerFrame=null,this.controllerFrameID=null,this.controllerRPC=null,this.logger=null,this.merchantInfo=null,this.frameCount=0,this.envHelper=p,this.siteKeyValue=null,this.hexeaOrigin=this.envHelper.getConfigValue("HEXEA_JS","https://js.connexpoint.com"),this.hexeaInstanceId=x.generate(),this.isDestroyed=!1,this.createControllerFrame()}deconstructor(){this.destroy()}destroy(){if(!this.isDestroyed){this.isDestroyed=!0;try{this.controllerRPC&&this.controllerRPC.unbind&&this.controllerRPC.unbind(),Object.keys(this.paymentMethods).forEach(e=>{const t=this.paymentMethods[e];t&&"function"==typeof t.destroy&&t.destroy()}),this.controllerFrame&&this.controllerFrame.parentNode&&this.controllerFrame.parentNode.removeChild(this.controllerFrame),this.controllerFrame=null,this.controllerRPC=null,this.logger=null,this.paymentMethods={},this.merchantInfo=null}catch(e){}}}paymentMethod(e){const t=new k(this,e);return this.paymentMethods[t.name]=t,this.fetchAndPassOnMerchantInfo(t),t.createPublicApi()}async validateIFrame(){let e=!1;const t=document.querySelectorAll('iframe[name^="hexeaSecureFrame"]');for(let i=0;i{if(this.merchantInfo)return void a();Date.now()-i>=e?o(new Error("Failed to get merchant info within the allowed time.")):setTimeout(()=>n(a,o),t)};return new Promise(n)}async tokenize(e,t){if(!this.merchantInfo)try{await this.waitForMerchantInfo()}catch(e){throw this.logException(e,{message:"Error waiting for merchant info",pcct:this.pcct}),e}const i=this.paymentMethods[e.name];if(N="","captchaEnabled"in this.merchantInfo&&0!==this.merchantInfo.captchaEnabled&&"card"===i.type){const e=await this.getAdminDomainInfo();if(!0===e.isAdminPage)N=e.token;else{await this.loadGrecaptchaDocument(this.merchantInfo.captchaEnabled),setTimeout(()=>{const e=document.getElementById("hexeaCardUIBody");if(e){const t=e.querySelectorAll("div"),i=t[t.length-3];i&&(i.style.zIndex="999999",i.style.transform="scale(0.88)",i.style.transformorigin="top",i.style.top="0px")}},1e3);const e=6e4,t=Date.now();for(;""===N&&Date.now()-tsetTimeout(e,100));""===N&&this.logTrace("Captcha token not received within timeout period.")}}if(!i)throw new o("The payment method provided to Tokenize was not created by this instance of Hexea()");const n=t?{...t}:{};return n.referrerUrl=document.location.href,this.logTrace(`[Hexea] tokenize pm method called for pcct:${this.pcct}`,{pcct:this.pcct,captcha_Token:N,billing:n}),i.tokenize(n,this.pcct,N)}applyStyle(e,t){null!=e&&Object.keys(t).forEach(i=>e.style[i]=t[i])}async loadGrecaptchaDocument(e=1){this.siteKeyValue=this.envHelper.getConfigValue("SITEKEYVALUE");const t=document.createElement("script");t.innerHTML=`var onloadCallback = function() {widgetId = grecaptcha.render('html_element', { 'sitekey': '${this.siteKeyValue}' ,'callback':'myCallBackFunction','size':'normal' });};`,document.head.appendChild(t),document.addEventListener("submit",function(){grecaptcha.reset(undefined)});const i=document.createElement("div");i.id="divCaptchaContainer",this.applyStyle(i,{margin:"15px 0","z-index":"inherit"});const n=document.createElement("div");n.id="divCaptcha",n.innerHTML="
",i.appendChild(n);const a=document.getElementById("g-recaptcha");if(this.applyStyle(n,{display:"flex",justifyContent:"center","z-index":9999}),2===e&&null!==a){const e=document.getElementById("iFrameResizer0");this.applyStyle(e,{height:"500px!important"}),a.parentNode.insertBefore(i,a)}else this.applyStyle(i,{margin:"0 0"}),this.applyStyle(n,{position:"fixed",left:0,top:0,width:"100%",height:"100%","align-items":"center","align-content":"stretch",background:"rgba(0,0,0,0.5)"}),document.body.appendChild(i);const o=document.createElement("script");return o.setAttribute("src","https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit"),o.setAttribute("async","true"),o.setAttribute("defer","true"),document.body.appendChild(o),window.myCallBackFunction=async function(e){const t=e,n=document.createTextNode('Please check "I\'m not a robot"');if(""!==t)return N=t,i.parentElement.removeChild(i),!0;newCaptchaDiv.appendChild(n)},!1}async getAdminDomainInfo(){const e=R.getDeviceType();return this.controllerRPC.invoke("checkIfIsAdminDomain",this.pcct,e)}static getDeviceType(){const e=window.navigator.standalone,t=window.navigator.userAgent.toLowerCase();return/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(window.navigator.userAgent)&&!e||t.includes("wv")?"mobileDevice":window.location.href}fetchAndPassOnMerchantInfo(e){const t="card"===e.type;this.merchantInfo?(e.updateMerchantInfo(this.merchantInfo),this.monitoringKey&&t?this.startTransactionMonitor(this.monitoringKey,this.pcct):t&&this.logTrace("[Hexea] monitoring was not started or is disabled",{pcct:this.pcct})):this.controllerRPC.invoke("getConfig",[this.pcct]).then(({merchantInfo:i,monitoringKey:n,serverConfig:a})=>{this.merchantInfo=i,this.monitoringKey=n,this.envHelper.setConfig(a),e.updateMerchantInfo(this.merchantInfo),n&&t?this.startTransactionMonitor(n,this.pcct):t&&this.logTrace("[Hexea] monitoring was not started or is disabled",{pcct:this.pcct})}).catch(e=>{throw e&&e.type?e.type===c?new Error("PCCT is not recognized"):new Error("Failed to get merchant info"):e})}startTransactionMonitor(e,t){try{const i=window.location.pathname,n=i.length>15?i.slice(0,15):i,a={clientId:p.getConfigValue("MONITORINGCLIENTID"),environment:p.getConfigValue("MONITORINGENVIRONMENT"),apiSubdomain:p.getConfigValue("APISUBDOMAIN"),pixelSubdomain:p.getConfigValue("PIXELSUBDOMAIN")};new I(this.logger,`Main:${n}`,a).start(e,t)}catch(e){this.logException(e,{message:"[Hexea] Error starting TransactionMonitor",pcct:this.pcct})}}createFrameId(){return this.frameCount+=1,`hexeaSecureFrame${this.frameCount}`}createControllerFrame(){this.controllerFrameID=this.createFrameId();const e=document.createElement("iframe");e.title="Secure payment method input frame",e.style.visibility="hidden",e.style.width="0px",e.style.height="0px";const{origin:t}=window.location,i="mobileDevice"===R.getDeviceType();let n=`?origin=${encodeURIComponent(t)}&uid=${this.hexeaInstanceId}&pcct=${this.pcct}&ts=${Date.now()}`;i&&(n+="&m=1");const a=`${this.hexeaOrigin}/hexea/controller${n}`;e.src=a,e.name=this.controllerFrameID,document.body.appendChild(e),this.controllerFrame=e,this.controllerRPC=new l(e.contentWindow,this.hexeaOrigin),this.logger=new T(this.controllerRPC),this.logTrace("[Hexea] controller iFrame created",{controllerUrl:a,href:window.location.href})}registerPaymentMethodFrame(...e){return this.controllerRPC.invoke("registerPaymentMethodFrame",...e)}unregisterPaymentMethodFrame(...e){if(this.controllerRPC)return this.controllerRPC.invoke("unregisterPaymentMethodFrame",...e)}logTrace(e,t={}){this.logger&&this.logger.logTrace&&this.logger.logTrace(e,t)}logException(e,t={}){this.logger&&this.logger.logException&&this.logger.logException(e,t)}createPublicApi(){return{paymentMethod:this.paymentMethod.bind(this),tokenize:this.tokenize.bind(this)}}}const O=R;function B(...e){return new O(...e).createPublicApi()}let F;"undefined"!=typeof window?F=window:void 0!==e.g&&(F=e.g),F&&F.document&&!F.Hexea&&(F.Hexea=B);const L=B;return t=t.default})());