@payrails/web-sdk 5.8.2 → 5.8.3

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/index.js CHANGED
@@ -1,7 +1,7 @@
1
- !function(){"use strict";function e(e,t,i,n){return new(i||(i=Promise))((function(s,o){function r(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}l((n=n.apply(e,t||[])).next())}))}function t(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)}function i(e,t,i,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(e,i):s?s.value=i:t.set(e,i),i}exports.ElementType=void 0,function(e){e.CARD_NUMBER="CARD_NUMBER",e.CARDHOLDER_NAME="CARDHOLDER_NAME",e.CVV="CVV",e.EXPIRATION_MONTH="EXPIRATION_MONTH",e.EXPIRATION_YEAR="EXPIRATION_YEAR"}(exports.ElementType||(exports.ElementType={})),"function"==typeof SuppressedError&&SuppressedError;var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function s(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var o={};!function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t=(e=>(e.PAYRAILS_CLIENT_CONFIG_MALFORMED="payrails:client:init.config_malformed",e.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT="payrails:client:collectContainer.unmountable",e.PAYRAILS_CLIENT_UI_ELEMENT_MISSING="payrails:client:mount.ui_element_missing",e.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING="payrails:client:mount.parent_element_missing",e.PAYRAILS_CLIENT_SUBELEMENTS_RENDER_ERROR="payrails:client:mount.subelements_render_error",e.PAYRAILS_CLIENT_CARD_FORM_MISSING="payrails:client:pay.card_form_missing",e.PAYRAILS_CLIENT_GPAY_LOADING_ERROR="payrails:client:mount.gpay_loading_error",e.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING="payrails:client:init.gpay_config_missing",e.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR="payrails:client:mount.applepay_loading_error",e.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING="payrails:client:init.applepay_config_missing",e.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR="payrails:client:init.paypal_loading_error",e.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING="payrails:client:init.paypal_config_missing",e.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION="payrails:client:init.paypal_order_creation",e.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT="payrails:client:mount.paypal_button_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR="payrails:client:payment_executor.pay_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_3DS_ERROR="payrails:client:payment_executor.3ds_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR="payrails:client:payment_executor.confirm_error",e.PAYRAILS_API_UNAUTHORIZED="payrails:api:unauthorized",e.PAYRAILS_API_TOO_MANY_REQUESTS="payrails:api:too_many_requests",e.PAYRAILS_API_UNSUCCESSFUL="payrails:api:unsuccessful",e.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED="payrails:api:authorization_not_requested",e.PAYRAILS_API_AUTHENTICATION_ERROR="payrails:api:request_authentication_error",e.PAYRAILS_API_AUTHORIZATION_ERROR="payrails:api:request_authorization_error",e.PAYRAILS_CLIENT_API_URL_NOT_FOUND="payrails:client:api_url_not_found",e.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND="payrails:client:workflow_execution_not_found",e.PAYRAILS_CARD_FORM_CREATION_FAILED="payrails:card_form:iframe_creation_failed",e.PAYRAILS_CARD_FORM_IFRAME_URL_MISSING="payrails:card_form:iframe_url_missing",e.PAYRAILS_CLIENT_UNKNOWN_ERROR="payrails:client:unknown",e.PAYRAILS_API_UNKNOWN_ERROR="payrails:api:unknown",e.PAYRAILS_CLIENT_ONPAY_CALLBACK_FAILED="payrails:client:card.onpay_callback_failed",e.PAYRAILS_CARD_FORM_ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE="payrails.card_form.element_not_mounted_in_element_match_rule",e.PAYRAILS_CARD_FORM_REQUIRED_PARAMS_NOT_PROVIDED="payrails.card_form.required_params_not_provided",e.PAYRAILS_CARD_FORM_CLIENT_CONNECTION="payrails.card_form.client_connection",e.PAYRAILS_CARD_FORM_IFRAME_NOT_FOUND="payrails.card_form.iframe_not_found",e.PAYRAILS_CARD_FORM_IFRAME_LOADING_ERROR="payrails.card_form.iframe_loading_error",e.PAYRAILS_CARD_FORM_CSP_ERROR="payrails.card_form.iframe_csp_error",e.PAYRAILS_CARD_FORM_COMPLETE_AND_VALID_INPUTS="payrails.card_form.complete_and_valid_inputs",e.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED="payrails.card_form.collect_element_not_mounted",e.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK="payrails:client:generic_redirect.missing.redirect_link",e))(t||{});const i={"payrails:client:init.config_malformed":{description:"The provided configuration string is invalid. Please ensure it matches the required format and structure as defined in the documentation",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:unknown":{description:"Unknown Client",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:unauthorized":{description:"Unauthorized access to the Payrails API",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:too_many_requests":{description:"Too many requests to the Payrails API",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:unsuccessful":{description:"Unsuccessful request to the Payrails API",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collectContainer.unmountable":{description:"Collect container cannot be mounted",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.ui_element_missing":{description:"Colect container element does not exist",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:pay.card_form_missing":{description:"Trying to collect values from non-existent card form",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.gpay_loading_error":{description:"Google pay can not be initialized",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.paypal_loading_error":{description:"Paypal can not be initialized",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.paypal_order_creation":{description:"Paypal order creation failed",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.paypal_button_error":{description:"PaypalButtonError occurred",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.parent_element_missing":{description:"Parent element not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.subelements_render_error":{description:"Subelements could not be rendered. Please set id for the element first.",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:api_url_not_found":{description:"API URL not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:workflow_execution_not_found":{description:"Workflow execution not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.paypal_config_missing":{description:"Paypal config not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:authorization_not_requested":{description:"Authorization was not requested",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.gpay_config_missing":{description:"Google pay config not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.applepay_loading_error":{description:"Apple pay can not be initialized",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.applepay_config_missing":{description:"Apple pay config not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:card_form:iframe_creation_failed":{description:"Error occured while creating an iframe",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:card_form:iframe_url_missing":{description:"Iframe URL is missing",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:card.onpay_callback_failed":{description:"Callback passed to onPaymentButtonClicked threw an error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:request_authentication_error":{description:"Authentication error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:unknown":{description:"Unknown API error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:payment_executor.pay_error":{description:"Error occured while executing a payment",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:payment_executor.confirm_error":{description:"Error occured while confirming a payment",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:request_authorization_error":{description:"Authorization error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:payment_executor.3ds_error":{description:"Authorization failed after 3DS challenge.",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.element_not_mounted_in_element_match_rule":{description:"Interface: collect element - collect element is not mounted in ValidationRule params at index %s1 in validations array",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.required_params_not_provided":{description:"Interface: collect element - Required params are not provided.",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.client_connection":{description:"Interface: collect container - client connection not established. client info has not reached iframes",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.iframe_not_found":{description:"Interface: collect element - frame not found:",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.complete_and_valid_inputs":{description:"Interface: collect container - Provide complete and valid inputs",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.collect_element_not_mounted":{description:"Interface: composable collect - collect element is not mounted",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.iframe_loading_error":{description:"Interface: collect element - Error occured while loading iframe",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.iframe_csp_error":{description:"Interface: collect element - Content Security Policy error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:generic_redirect.missing.redirect_link":{description:"[Generic Redirect] Missing redirect link in response"}};var n=(e=>(e.ERROR="payrails:error",e.INFO="payrails:info",e.DEBUG="payrails:debug",e.WARN="payrails:warn",e))(n||{});class s extends Error{constructor(e,t){var n;const{description:o,docUrl:r,cause:a}=null!=t?t:{},{description:l,docUrl:d}=i[e]||{},c=null!=(n=null!=o?o:l)?n:"An unknown error occurred",u=null!=r?r:d;super(c),this.name=e,this.docUrl=u,this.cause=a,this.message=c,Error.captureStackTrace&&Error.captureStackTrace(this,s)}toJSON(){return{name:this.name,message:this.message,docUrl:this.docUrl,stack:this.stack,cause:this.cause}}}e.ERROR_CODES=t,e.PAYRAILS_OBSERVABILITY_EVENTS=n,e.PayrailsError=s}(o);var r={};!function(e){var t=Object.defineProperty,i=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,r=(e,i,n)=>i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n,a=(e,t)=>{for(var n in t||(t={}))s.call(t,n)&&r(e,n,t[n]);if(i)for(var n of i(t))o.call(t,n)&&r(e,n,t[n]);return e};Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});class l{log(e,t){console.log(JSON.stringify({level:e,mssg:t.mssg,error:t.error,withMetada:t.withMetada,extra:t.extra}))}}var d=(e=>(e.ERROR="payrails:error",e.INFO="payrails:info",e.DEBUG="payrails:debug",e.WARN="payrails:warn",e))(d||{}),c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n?n:"undefined"!=typeof self?self:{};function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var E,_={},h={};var I,p={};var f,v={};var m={};Object.defineProperty(m,"__esModule",{value:!0}),m.subscribers=m.childWindows=m.prefix=void 0,m.prefix="/*framebus*/",m.childWindows=[],m.subscribers={};var N,T={};var y={};Object.defineProperty(y,"__esModule",{value:!0}),y.hasOpener=void 0,y.hasOpener=function(e){return e.top===e&&(null!=e.opener&&(e.opener!==e&&!0!==e.opener.closed))};var O={};Object.defineProperty(O,"__esModule",{value:!0}),O.isntString=void 0,O.isntString=function(e){return"string"!=typeof e};var A,L={};var g,R={};var S={};Object.defineProperty(S,"__esModule",{value:!0}),S.sendMessage=void 0,S.sendMessage=function(e,t,i){try{e.postMessage(t,i)}catch(e){}};var C,D={},b={};function P(){if(C)return b;C=1,Object.defineProperty(b,"__esModule",{value:!0}),b.Framebus=void 0;var e=B(),t="undefined"!=typeof window&&window.Promise,i=function(){function i(e){void 0===e&&(e={}),this.origin=e.origin||"*",this.channel=e.channel||"",this.verifyDomain=e.verifyDomain,this.targetFrames=e.targetFrames||[],this.limitBroadcastToFramesArray=Boolean(e.targetFrames),this.isDestroyed=!1,this.listeners=[],this.hasAdditionalChecksForOnListeners=Boolean(this.verifyDomain||this.limitBroadcastToFramesArray)}return i.setPromise=function(e){i.Promise=e},i.target=function(e){return new i(e)},i.prototype.addTargetFrame=function(e){this.limitBroadcastToFramesArray&&this.targetFrames.push(e)},i.prototype.include=function(t){return null!=t&&(null!=t.Window&&(t.constructor===t.Window&&(e.childWindows.push(t),!0)))},i.prototype.target=function(e){return i.target(e)},i.prototype.emit=function(t,i,n){if(this.isDestroyed)return!1;var s=this.origin;if(t=this.namespaceEvent(t),(0,e.isntString)(t))return!1;if((0,e.isntString)(s))return!1;"function"==typeof i&&(n=i,i=void 0);var o=(0,e.packagePayload)(t,s,i,n);return!!o&&(this.limitBroadcastToFramesArray?this.targetFramesAsWindows().forEach((function(t){(0,e.sendMessage)(t,o,s)})):(0,e.broadcast)(o,{origin:s,frame:window.top||window.self}),!0)},i.prototype.emitAsPromise=function(e,t){var n=this;return new i.Promise((function(i,s){n.emit(e,t,(function(e){i(e)}))||s(new Error('Listener not added for "'.concat(e,'"')))}))},i.prototype.on=function(t,i){if(this.isDestroyed)return!1;var n=this,s=this.origin,o=i;return t=this.namespaceEvent(t),!(0,e.subscriptionArgsInvalid)(t,o,s)&&(this.hasAdditionalChecksForOnListeners&&(o=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];n.passesVerifyDomainCheck(this&&this.origin)&&n.hasMatchingTargetFrame(this&&this.source)&&i.apply(void 0,e)}),this.listeners.push({eventName:t,handler:o,originalHandler:i}),e.subscribers[s]=e.subscribers[s]||{},e.subscribers[s][t]=e.subscribers[s][t]||[],e.subscribers[s][t].push(o),!0)},i.prototype.off=function(t,i){var n=i;if(this.isDestroyed)return!1;if(this.verifyDomain)for(var s=0;s<this.listeners.length;s++){var o=this.listeners[s];o.originalHandler===i&&(n=o.handler)}t=this.namespaceEvent(t);var r=this.origin;if((0,e.subscriptionArgsInvalid)(t,n,r))return!1;var a=e.subscribers[r]&&e.subscribers[r][t];if(!a)return!1;for(s=0;s<a.length;s++)if(a[s]===n)return a.splice(s,1),!0;return!1},i.prototype.teardown=function(){if(!this.isDestroyed){this.isDestroyed=!0;for(var e=0;e<this.listeners.length;e++){var t=this.listeners[e];this.off(t.eventName,t.handler)}this.listeners.length=0}},i.prototype.passesVerifyDomainCheck=function(e){return!this.verifyDomain||this.checkOrigin(e)},i.prototype.targetFramesAsWindows=function(){return this.limitBroadcastToFramesArray?this.targetFrames.map((function(e){return e instanceof HTMLIFrameElement?e.contentWindow:e})).filter((function(e){return e})):[]},i.prototype.hasMatchingTargetFrame=function(e){if(!this.limitBroadcastToFramesArray)return!0;var t=this.targetFramesAsWindows().find((function(t){return t===e}));return Boolean(t)},i.prototype.checkOrigin=function(e){var t,i=document.createElement("a");return i.href=location.href,t="https:"===i.protocol?i.host.replace(/:443$/,""):"http:"===i.protocol?i.host.replace(/:80$/,""):i.host,i.protocol+"//"+t===e||(!this.verifyDomain||this.verifyDomain(e))},i.prototype.namespaceEvent=function(e){return this.channel?"".concat(this.channel,":").concat(e):e},i.Promise=t,i}();return b.Framebus=i,b}var M,w=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))};var U,k={};var x={};Object.defineProperty(x,"__esModule",{value:!0});var Y,F,V={};function B(){return F||(F=1,e=_,t=c&&c.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,s)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),i=c&&c.__exportStar||function(e,i){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(i,n)||t(i,e,n)},Object.defineProperty(e,"__esModule",{value:!0}),i(function(){if(E)return h;E=1,Object.defineProperty(h,"__esModule",{value:!0}),h.detach=h.attach=void 0;var e=B(),t=!1;return h.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},h.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},h}(),e),i(function(){if(I)return p;I=1,Object.defineProperty(p,"__esModule",{value:!0}),p.broadcastToChildWindows=void 0;var e=B();return p.broadcastToChildWindows=function(t,i,n){for(var s=e.childWindows.length-1;s>=0;s--){var o=e.childWindows[s];o.closed?e.childWindows.splice(s,1):n!==o&&(0,e.broadcast)(t,{origin:i,frame:o.top})}},p}(),e),i(function(){if(f)return v;f=1,Object.defineProperty(v,"__esModule",{value:!0}),v.broadcast=void 0;var e=B();return v.broadcast=function t(i,n){var s,o=0,r=n.origin,a=n.frame;try{for(a.postMessage(i,r),(0,e.hasOpener)(a)&&a.opener.top!==window.top&&t(i,{origin:r,frame:a.opener.top});s=a.frames[o];)t(i,{origin:r,frame:s}),o++}catch(e){}},v}(),e),i(m,e),i(function(){if(N)return T;N=1,Object.defineProperty(T,"__esModule",{value:!0}),T.dispatch=void 0;var e=B();return T.dispatch=function(t,i,n,s,o){if(e.subscribers[t]&&e.subscribers[t][i]){var r=[];n&&r.push(n),s&&r.push(s);for(var a=0;a<e.subscribers[t][i].length;a++)e.subscribers[t][i][a].apply(o,r)}},T}(),e),i(y,e),i(O,e),i(function(){if(A)return L;A=1,Object.defineProperty(L,"__esModule",{value:!0}),L.onMessage=void 0;var e=B();return L.onMessage=function(t){if(!(0,e.isntString)(t.data)){var i=(0,e.unpackPayload)(t);if(i){var n=i.eventData,s=i.reply;(0,e.dispatch)("*",i.event,n,s,t),(0,e.dispatch)(t.origin,i.event,n,s,t),(0,e.broadcastToChildWindows)(t.data,i.origin,t.source)}}},L}(),e),i(function(){if(g)return R;g=1,Object.defineProperty(R,"__esModule",{value:!0}),R.packagePayload=void 0;var e=B();return R.packagePayload=function(t,i,n,s){var o,r={event:t,origin:i};"function"==typeof s&&(r.reply=(0,e.subscribeReplier)(s,i)),r.eventData=n;try{o=e.prefix+JSON.stringify(r)}catch(e){throw new Error("Could not stringify event: ".concat(e.message))}return o},R}(),e),i(S,e),i(function(){if(M)return D;M=1;var e=c&&c.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(D,"__esModule",{value:!0}),D.subscribeReplier=void 0;var t=P(),i=e(w);return D.subscribeReplier=function(e,n){var s=(0,i.default)();return t.Framebus.target({origin:n}).on(s,(function i(o,r){e(o,r),t.Framebus.target({origin:n}).off(s,i)})),s},D}(),e),i(function(){if(U)return k;U=1,Object.defineProperty(k,"__esModule",{value:!0}),k.subscriptionArgsInvalid=void 0;var e=B();return k.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},k}(),e),i(x,e),i(function(){if(Y)return V;Y=1,Object.defineProperty(V,"__esModule",{value:!0}),V.unpackPayload=void 0;var e=B();return V.unpackPayload=function(t){var i;if(t.data.slice(0,e.prefix.length)!==e.prefix)return!1;try{i=JSON.parse(t.data.slice(e.prefix.length))}catch(e){return!1}if(i.reply){var n=t.origin,s=t.source,o=i.reply;i.reply=function(t){if(s){var i=(0,e.packagePayload)(o,n,t);i&&s.postMessage(i,n)}}}return i},V}(),e)),_;var e,t,i}var G=B(),j=P();(0,G.attach)();const X=u(j.Framebus);class W{constructor(e){this.origin=null,this.listeners=[],this.bus=new X(e)}static getInstance(){return W.instance||(W.instance=new W),W.instance}on(e,t){return this.bus.on(e,t)}off(e,t){return this.bus.off(e,t)}emit(e,t,i=void 0){return this.bus.emit(e,t,i)}target(e){return this.bus.target(e)}}class z{constructor(){this.bus=W.getInstance()}log(e,t){this.bus.emit(d.ERROR,{level:e,event:t})}}var H=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===K}(e)}(e)};var K="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function $(e,t){return!1!==t.clone&&t.isMergeableObject(e)?ee((i=e,Array.isArray(i)?[]:{}),e,t):e;var i}function q(e,t,i){return e.concat(t).map((function(e){return $(e,i)}))}function J(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return Object.propertyIsEnumerable.call(e,t)})):[]}(e))}function Z(e,t){try{return t in e}catch(e){return!1}}function Q(e,t,i){var n={};return i.isMergeableObject(e)&&J(e).forEach((function(t){n[t]=$(e[t],i)})),J(t).forEach((function(s){(function(e,t){return Z(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,s)||(Z(e,s)&&i.isMergeableObject(t[s])?n[s]=function(e,t){if(!t.customMerge)return ee;var i=t.customMerge(e);return"function"==typeof i?i:ee}(s,i)(e[s],t[s],i):n[s]=$(t[s],i))})),n}function ee(e,t,i){(i=i||{}).arrayMerge=i.arrayMerge||q,i.isMergeableObject=i.isMergeableObject||H,i.cloneUnlessOtherwiseSpecified=$;var n=Array.isArray(t);return n===Array.isArray(e)?n?i.arrayMerge(e,t,i):Q(e,t,i):$(t,i)}ee.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,i){return ee(e,i,t)}),{})};const te=u(ee);class ie{constructor(){this.state={}}static getInstance(){return ie.instance||(ie.instance=new ie),ie.instance}getState(e){return this.state[e]}setState(e){this.state=te(this.state,e)}}const ne=ie.getInstance(),se=()=>window&&window.navigator,oe=()=>window&&window.screen,re=()=>({resolution:`${oe().width}x${oe().height}`,user_agent:se().userAgent,language:se().language});class ae{constructor(e){this.adapter=[new z],this.enabled=e.enabled||!0,this.initGlobalState(e),e.logLevel=e.logLevel||"error","debug"===e.logLevel&&this.addAdapter(new l)}static init(e){ae.instance=new ae(e)}static getLogger(){return ae.instance}initGlobalState(e){ne.setState({payrails:e.payrails,sdk:e.sdk})}static setState(e){ne.setState(e)}log(e,t,i){this.enabled&&this.adapter.forEach((n=>{n.log(e,{mssg:t,error:null==i?void 0:i.error,withMetada:a(a({},this.constructMetadata()),null==i?void 0:i.withMetada),extra:null==i?void 0:i.extra})}))}constructMetadata(){return{device:re(),payrails:ne.getState("payrails"),sdk:ne.getState("sdk")}}addAdapter(e){this.adapter.push(e)}static log(e,t){this.getLogger().log("info",e,t)}static debug(e,t){this.getLogger().log("debug",e,t)}static info(e,t){this.getLogger().log("info",e,t)}static warn(e,t){this.getLogger().log("warning",e,t)}static error(e,t){this.getLogger().log("error",e,t)}static exception(e,t){this.error(e,t)}}e.PayrailsLogger=ae,e.getDeviceInfo=re}(r);for(var a,l=[],d=0;d<256;++d)l.push((d+256).toString(16).slice(1));var c=new Uint8Array(16);function u(){if(!a&&!(a="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return a(c)}var E={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function _(e,t,i){if(E.randomUUID&&!t&&!e)return E.randomUUID();var n=(e=e||{}).random||(e.rng||u)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){i=i||0;for(var s=0;s<16;++s)t[i+s]=n[s];return t}return function(e,t=0){return(l[e[t+0]]+l[e[t+1]]+l[e[t+2]]+l[e[t+3]]+"-"+l[e[t+4]]+l[e[t+5]]+"-"+l[e[t+6]]+l[e[t+7]]+"-"+l[e[t+8]]+l[e[t+9]]+"-"+l[e[t+10]]+l[e[t+11]]+l[e[t+12]]+l[e[t+13]]+l[e[t+14]]+l[e[t+15]]).toLowerCase()}(n)}var h;!function(e){e.GET="GET",e.POST="POST"}(h||(h={}));const I=({url:t,method:i=h.GET,token:n,body:s})=>e(void 0,void 0,void 0,(function*(){const e={method:i,headers:Object.assign(Object.assign(Object.assign({},T()),N(n)),y())};i===h.POST&&(e.body=JSON.stringify(s||{}));const o=yield fetch(t,e),r=yield o.json();if([401,403].includes(o.status))throw new p(t,i);if(429===o.status)throw new v(t,i);if(!o.ok)throw new f(t,i);return{ok:o.ok,req:Object.assign({url:t},e),res:r}}));class p extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_UNAUTHORIZED,{description:`[${t}] ${e} unauthorized`})}}class f extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{description:`[${t}] ${e} unsuccessful`})}}class v extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} too many requests`})}}class m extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} max poll attempts exceeded.`})}}const N=e=>({authorization:`Bearer ${e}`}),T=()=>({"x-idempotency-key":_()}),y=()=>{const e={version:"5.8.2",type:"web-sdk"};return{"x-client-version":e.version,"x-client-type":e.type}},O=(t,i)=>e(void 0,void 0,void 0,(function*(){var e,n;if(null==t?void 0:t.onPaymentButtonClicked)try{const n=yield t.onPaymentButtonClicked(i);if(!n){const i=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_ONPAY_CALLBACK_FAILED,{description:"Callback passed to onPaymentButtonClicked resolved to false"});return r.PayrailsLogger.error(i.message,{error:i}),null===(e=null==t?void 0:t.onAuthorizeFailed)||void 0===e||e.call(t,{code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:i.message}),n}}catch(e){const i=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_ONPAY_CALLBACK_FAILED,{description:"Callback passed to onPaymentButtonClicked threw an error",cause:e});return r.PayrailsLogger.error(i.message,{error:i}),null===(n=t.onAuthorizeFailed)||void 0===n||n.call(t,{code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:i.message}),!1}return!0})),A={success:"https://payrails.io/success",error:"https://payrails.io/error",cancel:"https://payrails.io/cancel"};class L{constructor(e,t,i=A,n=680,s=60,o=2e3,r=5){this.sdkConfig=e,this.execution=t,this.returnLinks=i,this.POLL_INTERVAL=n,this.MAX_POLL_ATTEMPTS=s,this.POLL_INITIAL_DELAY=o,this.POLL_ERROR_COUNT_MULTIPLIER=r}pay(t){return e(this,void 0,void 0,(function*(){try{const e=(yield this.authorize(t)).res.links.execution;return yield this.pollForAuthorizationResult(e)}catch(e){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR,{cause:e});throw r.PayrailsLogger.error(t.message,{error:t}),e}}))}confirm(t,i={}){return e(this,void 0,void 0,(function*(){try{const e=yield I({url:t,method:h.POST,token:this.sdkConfig.token,body:{data:i}}),n=yield this.pollForAuthorizationResult(e.res.links.execution);if(n.finalState)return n;const s=n.response.status.slice().sort(((e,t)=>new Date(t.time).getTime()-new Date(e.time).getTime()))[0].time,{res:o}=yield this.getExecution(e.res.links.execution,s);return{finalState:o.status.find((({code:e,time:t})=>["authorizeSuccessful","authorizeFailed"].includes(e)&&new Date(t)>new Date(s))),response:o}}catch(e){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR,{cause:e});throw r.PayrailsLogger.error(t.message,{error:t}),e}}))}getExecution(t,i,n=0){return e(this,void 0,void 0,(function*(){if(n>this.MAX_POLL_ATTEMPTS)throw new m(t,h.GET);0===n&&i&&(yield this.wait(this.POLL_INITIAL_DELAY));try{const e=yield I({url:t,token:this.sdkConfig.token});if(i){if(!e.res.status.find((({time:e})=>new Date(e)>new Date(i))))return yield this.wait(this.POLL_INTERVAL),this.getExecution(t,i,n+1)}return e}catch(e){if(e instanceof f)return yield this.wait(this.POLL_INTERVAL),this.getExecution(t,i,n+this.POLL_ERROR_COUNT_MULTIPLIER);if(e instanceof v)return yield this.wait(this.POLL_INTERVAL*n),this.getExecution(t,i,n+1);throw e}}))}createApplePaySession(t){return e(this,void 0,void 0,(function*(){return I({url:t.requestUrl,method:h.POST,token:this.sdkConfig.token,body:{integrationType:"api",paymentMethodCode:"applePay",amount:this.sdkConfig.amount,meta:{sessionURL:t.sessionUrl,clientContext:{host:t.clientDomain||window.location.host}}}})}))}authorize(t){return e(this,void 0,void 0,(function*(){if(!this.execution.authorizeLink||!this.sdkConfig.amount){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND,{description:"SDK was not initialized with workflow execution"});throw r.PayrailsLogger.error(e.message,{error:e}),e}const{success:e,error:i,cancel:n}=this.returnLinks;return I({url:this.execution.authorizeLink,method:h.POST,token:this.sdkConfig.token,body:{amount:this.sdkConfig.amount,paymentComposition:t,returnInfo:{success:e,cancel:n,error:i}}})}))}wait(t){return e(this,void 0,void 0,(function*(){return new Promise((e=>setTimeout(e,t)))}))}pollForAuthorizationResult(t,i=0){return e(this,void 0,void 0,(function*(){const e=(yield this.getExecution(t)).res,n=e.status,s=["authorizePending","authorizeSuccessful","authorizeFailed"],a=n.find((({code:e})=>"authorizeRequested"===e));if(!a&&i<10)return yield new Promise((e=>setTimeout(e,this.POLL_INTERVAL))),this.pollForAuthorizationResult(t,i+1);if(!a){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED);throw r.PayrailsLogger.error(e.message,{error:e}),e}const l=n.find((({code:e,time:t})=>"confirmRequested"===e&&new Date(t)>new Date(a.time))),d=l?l.time:a.time;let c=n.find((({code:e,time:t})=>s.includes(e)&&new Date(t)>new Date(d)));if(!c){const{res:e}=yield this.getExecution(t,d);return c=e.status.find((({code:e,time:t})=>s.includes(e)&&new Date(t)>new Date(d))),{finalState:c,response:e}}return{finalState:c,response:e}}))}}class g{constructor(e,t,i,n,s=R.THREE_DS){this.link=e,this.execution=t,this.paymentExecutor=i,this.options=n,this.type=s,this.THREE_DS_SIZES=[[250,400],[390,400],[500,600],[600,400]],this.internalPopupBackground=null,this.SCREEN_WIDTH=window.innerWidth,this.SCREEN_HEIGHT=window.innerHeight}get iframeSize(){return this.type===R.THREE_DS?this.THREE_DS_SIZES.reduce(((e,t)=>this.SCREEN_WIDTH>t[0]?t:e),[250,400]):[this.SCREEN_WIDTH-50,this.SCREEN_HEIGHT-50]}get popupBackground(){if(this.internalPopupBackground)return this.internalPopupBackground;{const e=document.createElement("div");e.addEventListener("click",(()=>{e.remove()})),e.setAttribute("id","payrails-popup-background"),e.appendChild(this.popup),this.internalPopupBackground=e}return this.internalPopupBackground}get popup(){const e=document.createElement("div");return e.setAttribute("id","payrails-popup"),e.setAttribute("width",this.iframeSize[0].toString()),e.setAttribute("height",this.iframeSize[1].toString()),e.appendChild(this.iframe),e.style.width=`${this.iframeSize[0]+4}px`,e.style.height=`${this.iframeSize[1]+4}px`,e}get iframe(){const e=document.createElement("iframe");return e.setAttribute("id","payrails-frame"),e.setAttribute("src",this.link),e.setAttribute("width",this.iframeSize[0].toString()),e.setAttribute("height",this.iframeSize[1].toString()),e}handleMessages(){const t=i=>e(this,void 0,void 0,(function*(){var e,n,s,a;if(i.data&&'{"type":"3DS-challenge-completed"}'===i.data){window.removeEventListener("message",t);if((yield this.paymentExecutor.getExecution(this.execution.url)).res.status.find((({code:e})=>"authorizeSuccessful"===e)))null===(a=null===(s=this.options.events)||void 0===s?void 0:s.onAuthorizeSuccess)||void 0===a||a.call(s);else{const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_3DS_ERROR);r.PayrailsLogger.error(t.message,{error:t}),null===(n=null===(e=this.options.events)||void 0===e?void 0:e.onAuthorizeFailed)||void 0===n||n.call(e,{code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:"Authorization failed after 3DS challenge."})}this.unmount()}}));window.addEventListener("message",t)}mount(){var e;this.popup.remove(),null===(e=document.querySelector("body"))||void 0===e||e.appendChild(this.popupBackground),this.handleMessages()}unmount(){this.popupBackground.remove(),this.internalPopupBackground=null}}var R,S,C,D;!function(e){e[e.THREE_DS=0]="THREE_DS",e[e.GENERIC_REDIRECT=1]="GENERIC_REDIRECT"}(R||(R={}));class b{constructor(e,t,i){this.options=e,this.execution=t,this.paymentExecutor=i}handle3ds(e){var t,i,n;try{null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onThreeDSecureChallenge)||void 0===i||i.call(t)}catch(e){}const s=null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.links["3ds"];if(s){new g(s,this.execution,this.paymentExecutor,this.options).mount()}}}!function(e){e.CARD="card",e.GOOGLE_PAY="googlePay",e.PAYPAL="payPal",e.APPLE_PAY="applePay",e.GENERIC_REDIRECT="genericRedirect"}(S||(S={})),function(e){e.ENABLED="enabled",e.CREATED="created",e.DELETED="deleted",e.DISABLED="disabled",e.INVALID="invalid",e.TRANSIENT="transient"}(C||(C={}));class P{constructor(e){this.executionResponse=e}get lookup(){return this.executionResponse.initialResults.find((({body:{name:e}})=>"lookup"===e))}get holderReference(){return this.executionResponse.holderReference}get savedCreditCards(){return this.getStoredInstrumentForPaymentMethod(S.CARD)}get savedPaypalAccounts(){return this.getStoredInstrumentForPaymentMethod(S.PAYPAL)}get savedGooglePayAccounts(){return this.getStoredInstrumentForPaymentMethod(S.GOOGLE_PAY)}get savedApplePayAccounts(){return this.getStoredInstrumentForPaymentMethod(S.APPLE_PAY)}get paypalConfig(){const e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===S.PAYPAL));if(!e){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING);throw r.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:this.availablePaymentMethods}}),e}return e.config||{}}get googlePayConfig(){const e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===S.GOOGLE_PAY));if(!e){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING);throw r.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:this.availablePaymentMethods}}),e}return e?[e.config]:[]}isPaymentMethodAvailable(e){return this.availablePaymentMethods.some((({paymentMethodCode:t})=>t===e))}get applePayConfig(){const e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===S.APPLE_PAY));if(!e){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING);throw r.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:this.availablePaymentMethods}}),e}return e.config.parameters}get url(){return this.response.links.self}get response(){return this.executionResponse}get meta(){return this.executionResponse.meta}get availablePaymentMethods(){var e;return(null===(e=this.lookup)||void 0===e?void 0:e.body.data.paymentCompositionOptions)||[]}get authorizeLink(){var e;return null===(e=this.lookup)||void 0===e?void 0:e.body.links.authorize.href}get createSessionLink(){var e;return null===(e=this.response.links.startPaymentSession)||void 0===e?void 0:e.href}get storedPaymentInstruments(){return this.availablePaymentMethods.flatMap((e=>e.paymentInstruments||[]))}getStoredInstrumentForPaymentMethod(e){var t;return(null===(t=this.availablePaymentMethods.find((({paymentMethodCode:t})=>t===e)))||void 0===t?void 0:t.paymentInstruments)||[]}}class M{constructor(e,{id:t="",className:i=""}={}){this.subElements=[];const n=document.createElement(e);t&&(this.id=t,n.setAttribute("id",t)),i&&(Array.isArray(i)?n.setAttribute("class",function(...e){return e.filter(Boolean).join(" ")}(...i)):n.setAttribute("class",i)),this.element=n}get parentElement(){return this.element.parentElement}get selector(){if(!this.id)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);return`#${this.id}`}mount(e){const t=document.querySelector(e);if(!t)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING,{description:`Element with selector "${e}" not found in in the DOM`});this.clean(),t.appendChild(this.element),this.subElements.forEach((e=>{if(!this.id)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_SUBELEMENTS_RENDER_ERROR);e.mount(this.selector)}))}clean(){var e;null===(e=document.getElementById(this.element.id))||void 0===e||e.remove()}unmount(){var e;this.subElements.forEach((e=>e.unmount())),null===(e=this.parentElement)||void 0===e||e.removeChild(this.element)}}class w extends M{get bin(){var e;return this.selectedInstrument?this.selectedInstrument.data.bin?this.selectedInstrument.data.bin:"":(null===(e=this.cardForm)||void 0===e?void 0:e.bin)||""}constructor(e,t,i,n){var s;super("button",{id:"payrails-card-payment-button"}),this.sdkConfig=e,this.execution=t,this.options=i,this.returnInfo=n,this.selectedInstrument=null,this.element.innerText=(null===(s=null==i?void 0:i.translations)||void 0===s?void 0:s.label)||"Pay",this.element.addEventListener("click",this.onPay.bind(this)),this.element.addEventListener("mouseenter",(()=>{var e;this.element.classList.contains("disabled")||(this.element.classList.add("hover"),this.setStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{}))})),this.element.addEventListener("mouseleave",(()=>{var e;this.element.classList.contains("disabled")||(this.element.classList.remove("hover"),this.removeStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{}))})),this.paymentExecutor=new L(this.sdkConfig,this.execution,this.returnInfo)}setDisabled(e){var t,i,n,s,o;this.element.classList.contains("disabled")!==e&&(null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onStateChanged)||void 0===i||i.call(t,e?"disabled":"enabled")),this.element.disabled=e,e?(this.element.classList.add("disabled"),(null===(n=this.options.styles)||void 0===n?void 0:n.disabled)&&this.setStyles(this.options.styles.disabled)):(this.element.classList.remove("disabled"),this.removeStyles((null===(s=this.options.styles)||void 0===s?void 0:s.disabled)||{}),(null===(o=this.options.styles)||void 0===o?void 0:o.base)&&this.setStyles(this.options.styles.base))}setSavedCreditCard(e){console.warn("setSavedCreditCard is deprecated, please use setSavedInstrument"),this.setSavedInstrument(e)}setSavedInstrument(e){this.selectedInstrument=e,this.setDisabled(!1)}setStyles(e){var t;const i=Object.assign(Object.assign({},null===(t=this.options.styles)||void 0===t?void 0:t.base),e);Object.keys(i).forEach((e=>{this.element.style[e]=i[e]}))}removeStyles(e){var t;const i=Object.keys((null===(t=this.options.styles)||void 0===t?void 0:t.base)||{});Object.keys(e).forEach((e=>{var t,n;i.includes(e)?this.element.style[e]=null===(n=null===(t=this.options.styles)||void 0===t?void 0:t.base)||void 0===n?void 0:n[e]:this.element.style[e]=""}))}setLabel(e){this.element.innerText=e}setCardForm(e){this.cardForm=e}triggerLoading(e){var t,i,n,s;const o=this.element.offsetWidth;this.element.style.minWidth=`${o}px`,e?(this.element.innerHTML='<div class="dot-flashing"></div>',this.element.classList.add("loading"),(null===(t=this.options.styles)||void 0===t?void 0:t.loading)&&this.setStyles(this.options.styles.loading)):(this.element.innerText=(null===(n=null===(i=this.options)||void 0===i?void 0:i.translations)||void 0===n?void 0:n.label)||"Pay",this.element.classList.remove("loading"),this.removeStyles((null===(s=this.options.styles)||void 0===s?void 0:s.loading)||{}))}onAuthorizationFailed(e){var t,i;this.setDisabled(!1),this.triggerLoading(!1),(null===(t=this.options.events)||void 0===t?void 0:t.onAuthorizeFailed)&&(null===(i=this.options.events)||void 0===i||i.onAuthorizeFailed(e))}onPay(){var t,i,n,s,a,l,d,c;return e(this,void 0,void 0,(function*(){this.setDisabled(!0),this.triggerLoading(!0);if(!(yield O(this.options.events,{bin:this.bin||""})))return this.setDisabled(!1),void this.triggerLoading(!1);try{let e=[{paymentMethodCode:S.CARD,integrationType:"api",amount:this.sdkConfig.amount,storeInstrument:!1}];if(null===(t=this.selectedInstrument)||void 0===t?void 0:t.id)e[0].paymentInstrumentId=null===(i=this.selectedInstrument)||void 0===i?void 0:i.id,e[0].paymentMethodCode=null===(n=this.selectedInstrument)||void 0===n?void 0:n.paymentMethod;else{if(!this.cardForm){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CARD_FORM_MISSING);throw r.PayrailsLogger.error(e.message,{error:e}),e}e=this.sdkConfig.usePayrailsFrames?yield this.constructEncryptedPayment(e):yield this.constructTokenizedPayment(e)}const s=yield this.paymentExecutor.pay(e);this.handleAuthorizationResult(s)}catch(e){let t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_API_AUTHENTICATION_ERROR,{cause:e});e instanceof p||[401,403].includes(null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.code)?(null===(l=null===(a=this.options.events)||void 0===a?void 0:a.onPaymentSessionExpired)||void 0===l||l.call(a),t.message="API token is not valid or expired.",r.PayrailsLogger.error(t.message,{error:t}),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:t.message})):e.toString().includes("Invalid token")?(null===(c=null===(d=this.options.events)||void 0===d?void 0:d.onPaymentSessionExpired)||void 0===c||c.call(d),t.message="Vault token is not valid or expired.",r.PayrailsLogger.error(t.message,{error:t})):t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_API_UNKNOWN_ERROR,{cause:e}),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:t.message})}}))}constructTokenizedPayment(t){return e(this,void 0,void 0,(function*(){const{storeInstrument:e,enrollInstrumentToNetworkOffers:i,cardData:n}=yield this.cardForm.collectValues();return t[0].paymentInstrumentData={vaultToken:null==n?void 0:n.instrumentId,card:{numberToken:null==n?void 0:n.card_number,securityCodeToken:null==n?void 0:n.security_code}},t[0].storeInstrument=e,t[0].enrollInstrumentToNetworkOffers=i,t}))}constructEncryptedPayment(t){return e(this,void 0,void 0,(function*(){const{cardData:e,storeInstrument:i,enrollInstrumentToNetworkOffers:n}=yield this.cardForm.collectValues();return t[0].paymentInstrumentData=Object.assign({},e),t[0].storeInstrument=i,t[0].enrollInstrumentToNetworkOffers=n,t}))}handleAuthorizationResult(e){var t,i,n;let s;switch(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code){case"authorizeSuccessful":this.triggerLoading(!1),(null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeSuccess)&&this.options.events.onAuthorizeSuccess();break;case"authorizePending":if("3ds"===(null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.actionRequired)){new b({events:Object.assign(Object.assign({},this.options.events),{onAuthorizeFailed:e=>{this.onAuthorizationFailed(e)}})},this.execution,this.paymentExecutor).handle3ds(e)}break;default:s=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_ERROR),r.PayrailsLogger.error(s.message,{error:s,extra:{result:e}}),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:s.message})}}}exports.AuthorizationFailureReasons=void 0,(D=exports.AuthorizationFailureReasons||(exports.AuthorizationFailureReasons={})).VALIDATION_FAILED="VALIDATION_FAILED",D.AUTHORIZATION_ERROR="AUTHORIZATION_ERROR",D.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",D.UNKNOWN_ERROR="UNKNOWN_ERROR";var U={};!function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n?n:"undefined"!=typeof self?self:{};function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var s,o={},r={};var a,l={};var d,c={};var u={};Object.defineProperty(u,"__esModule",{value:!0}),u.subscribers=u.childWindows=u.prefix=void 0,u.prefix="/*framebus*/",u.childWindows=[],u.subscribers={};var E,_={};var h={};Object.defineProperty(h,"__esModule",{value:!0}),h.hasOpener=void 0,h.hasOpener=function(e){return e.top===e&&(null!=e.opener&&(e.opener!==e&&!0!==e.opener.closed))};var I={};Object.defineProperty(I,"__esModule",{value:!0}),I.isntString=void 0,I.isntString=function(e){return"string"!=typeof e};var p,f={};var v,m={};var N={};Object.defineProperty(N,"__esModule",{value:!0}),N.sendMessage=void 0,N.sendMessage=function(e,t,i){try{e.postMessage(t,i)}catch(e){}};var T,y={},O={};function A(){if(T)return O;T=1,Object.defineProperty(O,"__esModule",{value:!0}),O.Framebus=void 0;var e=M(),t="undefined"!=typeof window&&window.Promise,i=function(){function i(e){void 0===e&&(e={}),this.origin=e.origin||"*",this.channel=e.channel||"",this.verifyDomain=e.verifyDomain,this.targetFrames=e.targetFrames||[],this.limitBroadcastToFramesArray=Boolean(e.targetFrames),this.isDestroyed=!1,this.listeners=[],this.hasAdditionalChecksForOnListeners=Boolean(this.verifyDomain||this.limitBroadcastToFramesArray)}return i.setPromise=function(e){i.Promise=e},i.target=function(e){return new i(e)},i.prototype.addTargetFrame=function(e){this.limitBroadcastToFramesArray&&this.targetFrames.push(e)},i.prototype.include=function(t){return null!=t&&(null!=t.Window&&(t.constructor===t.Window&&(e.childWindows.push(t),!0)))},i.prototype.target=function(e){return i.target(e)},i.prototype.emit=function(t,i,n){if(this.isDestroyed)return!1;var s=this.origin;if(t=this.namespaceEvent(t),(0,e.isntString)(t))return!1;if((0,e.isntString)(s))return!1;"function"==typeof i&&(n=i,i=void 0);var o=(0,e.packagePayload)(t,s,i,n);return!!o&&(this.limitBroadcastToFramesArray?this.targetFramesAsWindows().forEach((function(t){(0,e.sendMessage)(t,o,s)})):(0,e.broadcast)(o,{origin:s,frame:window.top||window.self}),!0)},i.prototype.emitAsPromise=function(e,t){var n=this;return new i.Promise((function(i,s){n.emit(e,t,(function(e){i(e)}))||s(new Error('Listener not added for "'.concat(e,'"')))}))},i.prototype.on=function(t,i){if(this.isDestroyed)return!1;var n=this,s=this.origin,o=i;return t=this.namespaceEvent(t),!(0,e.subscriptionArgsInvalid)(t,o,s)&&(this.hasAdditionalChecksForOnListeners&&(o=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];n.passesVerifyDomainCheck(this&&this.origin)&&n.hasMatchingTargetFrame(this&&this.source)&&i.apply(void 0,e)}),this.listeners.push({eventName:t,handler:o,originalHandler:i}),e.subscribers[s]=e.subscribers[s]||{},e.subscribers[s][t]=e.subscribers[s][t]||[],e.subscribers[s][t].push(o),!0)},i.prototype.off=function(t,i){var n=i;if(this.isDestroyed)return!1;if(this.verifyDomain)for(var s=0;s<this.listeners.length;s++){var o=this.listeners[s];o.originalHandler===i&&(n=o.handler)}t=this.namespaceEvent(t);var r=this.origin;if((0,e.subscriptionArgsInvalid)(t,n,r))return!1;var a=e.subscribers[r]&&e.subscribers[r][t];if(!a)return!1;for(s=0;s<a.length;s++)if(a[s]===n)return a.splice(s,1),!0;return!1},i.prototype.teardown=function(){if(!this.isDestroyed){this.isDestroyed=!0;for(var e=0;e<this.listeners.length;e++){var t=this.listeners[e];this.off(t.eventName,t.handler)}this.listeners.length=0}},i.prototype.passesVerifyDomainCheck=function(e){return!this.verifyDomain||this.checkOrigin(e)},i.prototype.targetFramesAsWindows=function(){return this.limitBroadcastToFramesArray?this.targetFrames.map((function(e){return e instanceof HTMLIFrameElement?e.contentWindow:e})).filter((function(e){return e})):[]},i.prototype.hasMatchingTargetFrame=function(e){if(!this.limitBroadcastToFramesArray)return!0;var t=this.targetFramesAsWindows().find((function(t){return t===e}));return Boolean(t)},i.prototype.checkOrigin=function(e){var t,i=document.createElement("a");return i.href=location.href,t="https:"===i.protocol?i.host.replace(/:443$/,""):"http:"===i.protocol?i.host.replace(/:80$/,""):i.host,i.protocol+"//"+t===e||(!this.verifyDomain||this.verifyDomain(e))},i.prototype.namespaceEvent=function(e){return this.channel?"".concat(this.channel,":").concat(e):e},i.Promise=t,i}();return O.Framebus=i,O}var L,g=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))};var R,S={};var C={};Object.defineProperty(C,"__esModule",{value:!0});var D,b,P={};function M(){return b||(b=1,e=o,i=t&&t.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,s)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),n=t&&t.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)},Object.defineProperty(e,"__esModule",{value:!0}),n(function(){if(s)return r;s=1,Object.defineProperty(r,"__esModule",{value:!0}),r.detach=r.attach=void 0;var e=M(),t=!1;return r.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},r.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},r}(),e),n(function(){if(a)return l;a=1,Object.defineProperty(l,"__esModule",{value:!0}),l.broadcastToChildWindows=void 0;var e=M();return l.broadcastToChildWindows=function(t,i,n){for(var s=e.childWindows.length-1;s>=0;s--){var o=e.childWindows[s];o.closed?e.childWindows.splice(s,1):n!==o&&(0,e.broadcast)(t,{origin:i,frame:o.top})}},l}(),e),n(function(){if(d)return c;d=1,Object.defineProperty(c,"__esModule",{value:!0}),c.broadcast=void 0;var e=M();return c.broadcast=function t(i,n){var s,o=0,r=n.origin,a=n.frame;try{for(a.postMessage(i,r),(0,e.hasOpener)(a)&&a.opener.top!==window.top&&t(i,{origin:r,frame:a.opener.top});s=a.frames[o];)t(i,{origin:r,frame:s}),o++}catch(e){}},c}(),e),n(u,e),n(function(){if(E)return _;E=1,Object.defineProperty(_,"__esModule",{value:!0}),_.dispatch=void 0;var e=M();return _.dispatch=function(t,i,n,s,o){if(e.subscribers[t]&&e.subscribers[t][i]){var r=[];n&&r.push(n),s&&r.push(s);for(var a=0;a<e.subscribers[t][i].length;a++)e.subscribers[t][i][a].apply(o,r)}},_}(),e),n(h,e),n(I,e),n(function(){if(p)return f;p=1,Object.defineProperty(f,"__esModule",{value:!0}),f.onMessage=void 0;var e=M();return f.onMessage=function(t){if(!(0,e.isntString)(t.data)){var i=(0,e.unpackPayload)(t);if(i){var n=i.eventData,s=i.reply;(0,e.dispatch)("*",i.event,n,s,t),(0,e.dispatch)(t.origin,i.event,n,s,t),(0,e.broadcastToChildWindows)(t.data,i.origin,t.source)}}},f}(),e),n(function(){if(v)return m;v=1,Object.defineProperty(m,"__esModule",{value:!0}),m.packagePayload=void 0;var e=M();return m.packagePayload=function(t,i,n,s){var o,r={event:t,origin:i};"function"==typeof s&&(r.reply=(0,e.subscribeReplier)(s,i)),r.eventData=n;try{o=e.prefix+JSON.stringify(r)}catch(e){throw new Error("Could not stringify event: ".concat(e.message))}return o},m}(),e),n(N,e),n(function(){if(L)return y;L=1;var e=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(y,"__esModule",{value:!0}),y.subscribeReplier=void 0;var i=A(),n=e(g);return y.subscribeReplier=function(e,t){var s=(0,n.default)();return i.Framebus.target({origin:t}).on(s,(function n(o,r){e(o,r),i.Framebus.target({origin:t}).off(s,n)})),s},y}(),e),n(function(){if(R)return S;R=1,Object.defineProperty(S,"__esModule",{value:!0}),S.subscriptionArgsInvalid=void 0;var e=M();return S.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},S}(),e),n(C,e),n(function(){if(D)return P;D=1,Object.defineProperty(P,"__esModule",{value:!0}),P.unpackPayload=void 0;var e=M();return P.unpackPayload=function(t){var i;if(t.data.slice(0,e.prefix.length)!==e.prefix)return!1;try{i=JSON.parse(t.data.slice(e.prefix.length))}catch(e){return!1}if(i.reply){var n=t.origin,s=t.source,o=i.reply;i.reply=function(t){if(s){var i=(0,e.packagePayload)(o,n,t);i&&s.postMessage(i,n)}}}return i},P}(),e)),o;var e,i,n}var w=M(),U=A();(0,w.attach)();const k=i(U.Framebus);class x{constructor(e){this.origin=null,this.listeners=[],this.bus=new k(e)}static getInstance(){return x.instance||(x.instance=new x),x.instance}on(e,t){return this.bus.on(e,t)}off(e,t){return this.bus.off(e,t)}emit(e,t,i=void 0){return this.bus.emit(e,t,i)}target(e){return this.bus.target(e)}}e.IframeEventBus=x,e.getEventBus=()=>x.getInstance()}(U);const k={INITIALIZE_CLIENT:"%s1 - Initializing skyflow client.",CLIENT_INITIALIZED:"%s1 - Initialized skyflow client successfully.",CREATE_COLLECT_CONTAINER:"%s1 - Creating Collect container.",COLLECT_CONTAINER_CREATED:"%s1 - Created Collect container successfully.",VALIDATE_RECORDS:"%s1 - Validating insert records.",VALIDATE_DETOKENIZE_INPUT:"%s1 - Validating detokenize input.",VALIDATE_GET_INPUT:"%s1 - Validating get input.",VALIDATE_DELETE_INPUT:"%s1 - Validating delete input.",VALIDATE_COLLECT_RECORDS:"%s1 - Validating collect element input.",CREATED_ELEMENT:"%s1 - Created %s2 element.",ELEMENT_MOUNTED:"%s1 - %s2 Element mounted.",COLLECT_SUBMIT_SUCCESS:"%s1 - Data has been collected successfully.",INSERT_DATA_SUCCESS:"%s1 - Data has been inserted successfully.",DELETE_SUCCESS:"%s1 - Data has been deleted successfully.",BEARER_TOKEN_LISTENER:"%s1 - Get bearer token listener added.",CAPTURED_BEARER_TOKEN_EVENT:"%s1 - Captured bearer token event.",BEARER_TOKEN_RESOLVED:"%s1 - GetBearerToken promise resolved successfully.",REUSE_BEARER_TOKEN:"%s1 - Reusing the bearer token.",PUREJS_CONTROLLER_INITIALIZED:"%s1 - SkyflowController initialized.",PUREJS_LISTENER_READY:"%s1 - Purejs listener ready.",EMIT_PURE_JS_CONTROLLER:"%s1 - Emitted Skyflow controller event.",INSERT_TRIGGERED:"%s1 - Insert method triggered.",DETOKENIZE_TRIGGERED:"%s1 - Detokenize method triggered.",GET_TRIGGERED:"%s1 - Get method triggered.",GET_BY_ID_TRIGGERED:"%s1 - Get method triggered.",DELETE_TRIGGERED:"%s1 - Delete method triggered.",EMIT_PURE_JS_REQUEST:"%s1 - Emitted %s2 request.",CAPTURE_PURE_JS_REQUEST:"%s1 - Captured %s2 event.",LISTEN_PURE_JS_REQUEST:"%s1 - Listening to %s2 event.",CAPTURE_PUREJS_FRAME:"%s1 - Captured SkyflowController frame ready event.",FETCH_RECORDS_RESOLVED:"%s1 - Detokenize request is resolved.",INSERT_RECORDS_RESOLVED:"%s1 - Insert request is resolved.",GET_RESOLVED:"%s1 - Get request is resolved.",GET_BY_SKYFLOWID_RESOLVED:"%s1 - GetById request is resolved.",DELETE_RESOLVED:"%s1 - Delete request is resolved",EMIT_EVENT:"%s1 - %s2 event emitted",CAPTURE_EVENT:"%s1 - Captured event %s2",LISTEN_COLLECT_FRAME_READY:"%s1 - Listening to collect FRAME_READY event",EMIT_COLLECT_ELEMENT_FRAME_READY:"%s1 - Emitting collect element %s2 FRAME_READY event",ENTERED_COLLECT_FRAME_READY_CB:"%s1 - In IFrameForm constructor, Entered FRAME_READY callback",EXECUTE_COLLECT_ELEMENT_FRAME_READY_CB:"%s1 - In IFrameForm, executing collect element, %s2 FRAME_READY callback",CLIENT_METADATA_NOT_SET:"%s1 - Client metadata not set",EXECUTE_COLLECT_ELEMENT_INIT:"%s1 - calling Collect element init",INSIDE__COLLECT_ELEMENT_INIT:"%s1 - Inside Collect element init for %s2",CREATING_COLLECT_ELEMENT_FORM:"%s1 - Start, creating iframe form for %s2",COLLECT_FRAME_READY_CB:"%s1 - In FrameElements, executing collect element FRAME_READY cb for %s2, sending metadata",INSIDE_FRAME_ELEMENTS_CONSTRUCOTR:"%s1 - Inside FrameElements constructor",SETUP_IN_START:"%s1 - Inside FrameElements start(), calling setup",SETUP_IN_CONSTRUCTOR:"%s1 - Inside FrameElements constructor, calling setup",COLLECT_ELEMET_START:"%s1 - %s2, Collect Element start",COLLECT_CONTROLLER_START:"%s1 - %s2, Collect Controller start",EMIT_COLLECT_FRAME_CONTROLLER_EVENT:"%s1 - Emit collect FrameController FRAME_READY event",EXECUTE_COLLECT_CONTROLLER_READY_CB:"%s1 - Executing collect FrameController FRAME_READY callback, set client metadata",IFRAMEFORM_CONSTRUCTOR_FRAME_READY_LISTNER:"%s1 - In IFrameForm constructor, Adding listner for FRAME_READY event",IFRAMEFORM_CONSTRUCTOR_TOKENIZATION_LISTNER:"%s1 - In IFrameForm constructor, Adding listner for TOKENIZATION_REQUEST event",CURRENT_ENV:"%s1 - Client Env is %s2",CURRENT_LOG_LEVEL:"%s1 - Client LogLevel is %s2",VALIDATE_GET_BY_ID_INPUT:"%s1 - Validating getByID input."},x={CLIENT_CONNECTION:"Interface: collect container - client connection not established. client info has not reached iframes",INVALID_BEARER_TOKEN:"Interface: init - Invalid token is generated from getBearerToken callback",BEARER_TOKEN_REJECTED:"Interface: init - GetBearerToken promise got rejected.",VAULTID_IS_REQUIRED:"Interface: init - Invalid client credentials. vaultID is required.",EMPTY_VAULTID_IN_INIT:"Interface: init - Invalid client credentials. vaultID cannot be empty.",VAULTURL_IS_REQUIRED:"Interface: init - Invalid client credentials. vaultURL is required.",EMPTY_VAULTURL_IN_INIT:"Interface: init - Invalid client credentials. vaultURL cannot be empty.",INVALID_VAULTURL_IN_INIT:"Interface: init - Invalid client credentials. Expecting https://XYZ for vaultURL",GET_BEARER_TOKEN_IS_REQUIRED:"Interface: init - Invalid client credentials. getBearerToken is required.",EMPTY_CONTAINER_TYPE:"Interface: client {containerType} container - Invalid container type. Container object cannot be empty.",INVALID_CONTAINER_TYPE:"Interface: client {containerType} container - Invalid container type. Invalid container object.",INVALID_COLLECT_VALUE:"Invalid value",INVALID_COLLECT_VALUE_WITH_LABEL:"Invalid %s1",REQUIRED_COLLECT_VALUE:"%s1 is required",DEFAULT_REQUIRED_COLLECT_VALUE:"Field is required",RECORDS_KEY_NOT_FOUND:"Interface: client insert - records object is required.",INVALID_RECORDS_IN_INSERT:"Interface: client insert - Invalid records. records object should be an array.",EMPTY_RECORDS_IN_INSERT:"Interface: client insert - records array cannot be empty.",MISSING_TABLE_IN_INSERT:'Interface: client insert - "table" key is required in records array at index %s1',EMPTY_TABLE_IN_INSERT:"Interface: client insert - table cannot be empty in records array at index %s1",INVALID_TABLE_IN_INSERT:"Interface: client insert - table of type string is required at index %s1 in records array.",EMPTY_FIELDS_IN_INSERT:"Interface: client insert - fields cannot be empty in records array at index %s1",MISSING_FIELDS_IN_INSERT:'Interface: client insert - "fields" key is required in records array at index %s1',INVALID_FIELDS_IN_INSERT:"Interface: client insert - fields of type object is required at index %s1 in records array.",INVALID_TOKENS_IN_INSERT:"Interface: client insert - Invalid tokens in options. tokens of type boolean is required.",RECORDS_KEY_NOT_FOUND_DELETE:"Interface: client delete - records object is required.",INVALID_RECORDS_IN_DELETE:"Interface: client delete - Invalid records. records object should be an array.",EMPTY_RECORDS_IN_DELETE:"Interface: client delete - records array cannot be empty.",MISSING_TABLE_IN_DELETE:'Interface: client delete - "table" key is required in records array at index %s1',EMPTY_TABLE_IN_DELETE:"Interface: client delete - table cannot be empty in records array at index %s1",INVALID_TABLE_IN_DELETE:"Interface: client delete - table of type string is required at index %s1 in records array.",MISSING_ID_IN_DELETE:'Interface: client delete - "id" key is required in records array at index %s1',EMPTY_ID_IN_DELETE:"Interface: client delete - id cannot be empty in records array at index %s1",INVALID_ID_IN_DELETE:"Interface: client delete - id of type string is required at index %s1 in records array.",DELETE_RECORDS_REJECTED:"Interface: client delete - delete request is rejected.",INVALID_TOKENS_IN_COLLECT:"Interface: collect container - Invalid tokens. tokens of type boolean is required.",RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS:'Interface: collect container - "records" key not found in additionalFields',INVALID_RECORDS_IN_ADDITIONAL_FIELDS:"Interface: collect container - records should be an array inside additionalFields",EMPTY_RECORDS_IN_ADDITIONAL_FIELDS:"Interface: collect container - records object cannot be empty in additionalFields",MISSING_TABLE_IN_ADDITIONAL_FIELDS:'Interface: collect container - "table" key not found in additionalFields records at index %s1',INVALID_TABLE_IN_ADDITIONAL_FIELDS:"Interface: collect container - Provide valid table name in additionalFields records at index %s1",INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:"Interface: collect container - Provide valid skyflow id in additionalFields records at index %s1",MISSING_FIELDS_IN_ADDITIONAL_FIELDS:'Interface: collect container - "fields" key not found in additionalFields records at index %s1',INVALID_FIELDS_IN_ADDITIONAL_FIELDS:"Interface: collect container - Provide valid fields in additionalFields records at index %s1",RECORDS_KEY_NOT_FOUND_DETOKENIZE:"Interface: client detokenize - records object is required.",EMPTY_RECORDS_DETOKENIZE:"Interface: client detokenize - records array cannot be empty.",INVALID_RECORDS_IN_DETOKENIZE:"Interface: client detokenize - Invalid records. records object should be an array.",MISSING_TOKEN_IN_DETOKENIZE:'Interface: client detokenize - "token" key is required in records array at index %s1 ',INVALID_TOKEN_IN_DETOKENIZE:"Interface: client detokenize - Invalid token. token of type string is required at index %s1 in records array.",RECORDS_KEY_NOT_FOUND_GET:"Interface: client get - records object is required.",INVALID_RECORDS_IN_GET:"Interface: client get - Invalid records. records object should be an array.",EMPTY_RECORDS_GET:"Interface: client get - records array cannot be empty.",MISSING_IDS_IN_GET:'Interface: client get - "ids" key is required in records array at index %s1',INVALID_IDS_IN_GET:"Interface: client get - Invalid ids. ids object should be an array.",INVALID_COLUMN_VALUES_IN_GET:"Interface: client get - Invalid column values. column values object should be an array.",EMPTY_IDS_IN_GET:"Interface: client get - ids array cannot be empty at index %s1",INVALID_SKYFLOWID_TYPE_IN_GET:"Interface: client get - Invalid skyflowId in ids array at index %s1",MISSING_TABLE_IN_GET:'Interface: client get - "table" key is required in records array at index %s1',INVALID_TABLE_IN_GET:"Interface: client get - table of type string is required at index %s1 in records array.",MISSING_REDACTION_IN_GET:'Interface: client get - "redaction" key is required in records array at index %s1',INVALID_REDACTION_TYPE_IN_GET:"Interface: client get - Invalid redaction type in records array at index %s1",INVALID_TOKENS_IN_GET:"Interface: client get - Invalid tokens in options. tokens of type boolean is required.",TOKENS_GET_COLUMN_NOT_SUPPORTED:"Interface: client get - column_name or column_values cannot be used with tokens in options.",REDACTION_WITH_TOKENS_NOT_SUPPORTED:"Interface: client get - redaction cannot be used when tokens are true in options.",INVALID_REDACTION_TYPE_IN_DETOKENIZE:"Interface: client get - Invalid redaction type in records array at index %s1",EMPTY_TABLE_IN_ADDITIONAL_FIELDS:"Interface: collect container - table cannot be empty in additionalFields at index %s1",EMPTY_FIELDS_IN_ADDITIONAL_FIELDS:"Interface: collect container - fields cannot be empty in additionalFields at index %s1",EMPTY_TOKEN_IN_DETOKENIZE:"Interface: client detokenize - token cannot be empty in records array at index %s1",EMPTY_SKYFLOWID_IN_GET:"Interface: client get - id cannot be empty in records array at index %s1",EMPTY_TABLE_IN_GET:"Interface: client get - table cannot be empty in records array at index %s1",EMPTY_REDACTION_TYPE_IN_GET:"Interface: client get - redaction cannot be empty in records array at index %s1",FETCH_RECORDS_REJECTED:"Interface: client detokenize - detokenize request is rejected.",INSERT_RECORDS_REJECTED:"Interface: client insert - insert request is rejected.",GET_REJECTED:"Interface: client get - get request is rejected.",MISSING_TABLE_IN_COLLECT:'Interface: collect element - "table" key is required.',EMPTY_TABLE_IN_COLLECT:"Interface: collect element - table cannot be empty.",EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:"Interface: collect element - id cannot be empty.",INVALID_TABLE_IN_COLLECT:"Interface: collect element - Invalid table. table of type string is required",INVALID_SKYFLOWID_IN_COLLECT:"Interface: collect element - Invalid id. id of type string is required",MISSING_COLUMN_IN_COLLECT:'Interface: collect element - "column" key is required.',EMPTY_COLUMN_IN_COLLECT:"Interface: collect element - column cannot be empty.",INVALID_COLUMN_IN_COLLECT:"Interface: collect element - Invalid column. column of type string is required",UNIQUE_ELEMENT_NAME:"The element name has to unique: %s1",ELEMENTS_NOT_MOUNTED:"Interface: collect container - Elements should be mounted before invoking collect",DUPLICATE_ELEMENT:"Interface: collect container - Duplicate column %s1 found in %s2.",DUPLICATE_ELEMENT_ADDITIONAL_FIELDS:"Interface: collect container - Duplicate column %s1 found in %s2 in additional fields",MISSING_ELEMENT_TYPE:'Interface:container element with type {TYPE} - Invalid element type. "type" key is required.',EMPTY_ELEMENT_TYPE:"Interface:container element with type {TYPE} - Invalid element type. type cannot be empty.",INVALID_ELEMENT_TYPE:"Interface:container element with type {TYPE} - invalid element type. type not found",INVALID_ELEMENT_SELECTOR:"Interface: container element with type {TYPE} - Div cannot be found.",CANNOT_CHANGE_ELEMENT:"Element can't be changed.",INVALID_IFRAME:"Error occured while creating an iframe",INVALID_FIELD:"Invalid Field.",FRAME_NOT_FOUND:"Interface: collect element - %s1 frame not found:",COMPLETE_AND_VALID_INPUTS:"Interface: collect container - Provide complete and valid inputs for %s1",REQUIRED_PARAMS_NOT_PROVIDED:"Interface: collect element - Required params are not provided.",INVALID_EVENT_TYPE:"Interface: collect element - Provide a valid event type.",INVALID_EVENT_LISTENER:'Interface: "on" on CollectElement - Provide valid event listener.',MISSING_HANDLER_IN_EVENT_LISTENER:'Interface: "on" on CollectElement - Second argument is missing. handler cannot be empty.',INVALID_HANDLER_IN_EVENT_LISTENER:'Interface: "on" on CollectElement - Invalid handler. handler should be of type function.',UNKNOWN_ERROR:"Unknown Error.",NETWORK_ERROR:"A network error occurred. This could be a CORS issue or a dropped internet connection. It is not possible for us to know. Please reach out to skyflow if you see this error",CONNECTION_ERROR:"Error while initializing the connection.",ERROR_OCCURED:"Error occurred.",INVALID_VALIDATIONS_TYPE:"Interface: collect element - Invalid validations type.",MISSING_VALIDATION_RULE_TYPE:"Interface: collect element - Type is missing in validationRule at index %s1 in validations array",INVALID_VALIDATION_RULE_TYPE:"Interface: collect element - Invalid ValidationRuleType at index %s1 in validations array",MISSING_VALIDATION_RULE_PARAMS:"Interface: collect element - params are missing in validationRule at index %s1 in validations array",INVALID_VALIDATION_RULE_PARAMS:"Interface: collect element - Invalid ValidationRule params at index %s1 in validations array",MISSING_REGEX_IN_REGEX_MATCH_RULE:"Interface: collect element - Missing regex in ValidationRule params at index %s1 in validations array",INVALID_REGEX_IN_REGEX_MATCH_RULE:"Interface: collect element - Invalid regex in ValidationRule params at index %s1 in validations array",MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE:"Interface: collect element - Either min or max is required in ValidationRule params at index %s1 in validations array",MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE:"Interface: collect element - Missing element in ValidationRule params at index %s1 in validations array",INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE:"Interface: collect element - Invalid collect element in ValidationRule params at index %s1 in validations array",ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE:"Interface: collect element - collect element is not mounted in ValidationRule params at index %s1 in validations array",EMPTY_ELEMENT_IN_MOUNT:"Interface: mount element with type %s1 - Mount cannot be empty.",VALIDATION_FAILED:"Validation failed",INVALID_UPSERT_OPTION_TYPE:"Invalid upsert option, should be an array",EMPTY_UPSERT_OPTIONS_ARRAY:"upsert option cannot be an empty array, atleast one object of table and column is required.",INVALID_UPSERT_OPTION_OBJECT_TYPE:"Invalid upsert object at index %s1, an object of table and column is required.",MISSING_TABLE_IN_UPSERT_OPTION:'"table" key is required in upsert options object at index %s1',MISSING_COLUMN_IN_UPSERT_OPTION:'"column" key is required in upsert option at index %s1',INVALID_TABLE_IN_UPSERT_OPTION:"Invalid table in upsert object at index %s1, table of type non empty string is required",INVALID_COLUMN_IN_UPSERT_OPTION:"Invalid column in upsert object at index %s1, column of type non empty string is required",INVALID_RECORD_COLUMN_VALUE:"Invalid Record Column value.",MISSING_RECORD_COLUMN_VALUE:"Column Values is required when Column Name is specified.",MISSING_RECORD_COLUMN_NAME:"Column Name is required when Column Values are specified.",INVALID_RECORD_COLUMN_VALUE_TYPE:"Invalid Type of Records Column Values.",INVALID_COLUMN_VALUES_TYPE:"Invalid column values type, should be an Array.",EMPTY_RECORD_COLUMN_VALUES:"Record column values cannot be empty.",EMPTY_COLUMN_VALUE:"Column Value is empty.",MISSING_IDS_OR_COLUMN_VALUES_IN_GET:'Interface: client get - "ids" key or "columnValues" key is missing.',SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED:"ids and columnName can not be specified together.",GET_BY_SKYFLOWID_RESOLVED:"%s1 - GetById request is resolved.",RECORDS_KEY_NOT_FOUND_GETBYID:"Interface: client getById - records object is required.",INVALID_RECORDS_IN_GETBYID:"Interface: client getById - Invalid records. records object should be an array.",EMPTY_RECORDS_GETBYID:"Interface: client getById - records array cannot be empty.",MISSING_IDS_IN_GETBYID:'Interface: client getById - "ids" key is required in records array at index %s1',INVALID_IDS_IN_GETBYID:"Interface: client getById - Invalid ids. ids object should be an array.",EMPTY_IDS_IN_GETBYID:"Interface: client getById - ids array cannot be empty at index %s1",INVALID_SKYFLOWID_TYPE_IN_GETBYID:"Interface: client getById - Invalid skyflowId in ids array at index %s1",MISSING_TABLE_IN_GETBYID:'Interface: client getById - "table" key is required in records array at index %s1',INVALID_TABLE_IN_GETBYID:"Interface: client getById - table of type string is required at index %s1 in records array.",MISSING_REDACTION_IN_GETBYID:'Interface: client getById - "redaction" key is required in records array at index %s1',INVALID_REDACTION_TYPE_IN_GETBYID:"Interface: client getById - Invalid redaction type in records array at index %s1",EMPTY_SKYFLOWID_IN_GETBYID:"Interface: client getById - id cannot be empty in records array at index %s1",EMPTY_TABLE_IN_GETBYID:"Interface: client getById - table cannot be empty in records array at index %s1",EMPTY_REDACTION_TYPE_IN_GETBYID:"Interface: client getById - redaction cannot be empty in records array at index %s1",GET_BY_SKYFLOWID_REJECTED:"Interface: client getById - getById request is rejected.",MISSING_COMPOSABLE_LAYOUT_KEY:"Interface: client container - layout is required in composable container options.",EMPTY_COMPOSABLE_LAYOUT_ARRAY:"Interface: client container - layout array cannot be empty in composable container options.",INVALID_COMPOSABLE_LAYOUT_TYPE:"Interface: client container - invalid layout value, layout should be of type array of numbers in composable container options.",NEGATIVE_VALUES_COMPOSABLE_LAYOUT:"Interface: client container - layout array should only have postive numbers in composable container options.",MISMATCH_ELEMENT_COUNT_LAYOUT_SUM:"Interface: composable container mount - created elements count should be equal to sum of layout values.",MISSING_COMPOSABLE_CONTAINER_OPTIONS:"Interface: client composable container - options object is required for composable container.",INVALID_COMPOSABLE_CONTAINER_OPTIONS:"Interface: client composable container - invalid options value, should be an object type.",COMPOSABLE_CONTAINER_NOT_MOUNTED:"Interface: composable collect - container should be mounted before invoking collect.",INVALID_BOOLEAN_OPTIONS:"Interface: container create - Invaild %s1 in options, %s1 of type boolean is required.",INVALID_INPUT_OPTIONS_FORMAT:"Interface: container create - Invalid type, format must be of non-empty string type.",INVALID_INPUT_OPTIONS_TRANSLATION:"Interface: container create - Invalid type, translation must be of non-empty object type.",EMPTY_COLLECT_CUSTOM_FORMAT:"Interface: container create - %s1 cannot be empty object."},Y={INVALID_EXPIRATION_DATE_FORMAT:"EXPIRATION_DATE format must be in one of %s1, the format is set to default MM/YY",INVALID_EXPIRATION_YEAR_FORMAT:"EXPIRATION_YEAR format must be in one of %s1, the format is set to default YY",UNABLE_TO_SET_VALUE_IN_PROD_ENV:"%s1 setValue() cannot invoked while in PROD env. It is Not Recommeded",UNABLE_TO_CLEAR_VALUE_IN_PROD_ENV:"%s1 clearValue() cannot invoked while in PROD env. It is Not Recommeded",COLLECT_ALT_TEXT_DEPERECATED:"altText is DEPERECATED, passing altText will not have any effect",GET_BY_ID_DEPRECATED:"getById is deprecated, use new get method",INPUT_FORMATTING_NOT_SUPPROTED:"format or translation are not supported on %s1 element type.",INVALID_INPUT_TRANSLATION:"invalid or unsupported translation provided for %s1 element type."},F="collect_controller",V="element",B={CHANGE:"CHANGE",READY:"READY",FOCUS:"FOCUS",BLUR:"BLUR",ESCAPE:"ESCAPE",CLICK:"CLICK",ERROR:"ERROR",SUCCESS:"SUCCESS",SUBMIT:"SUBMIT",CREATED:"CREATED",MOUNTED:"MOUNTED",HEIGHT:"HEIGHT"},G="FRAME_READY",j="TOKENIZATION_REQUEST",X="INPUT_EVENT",W="DESTROY FRAME",z="SET_VALUE",H="GET_BEARER_TOKEN",K="COLLECT_ELEMENT_SET_ERROR",$="COMPOSABLE_UPDATE_OPTIONS",q="COMPOSABLE_CONTAINER_MOUNTED",J="COLLECT_CONTAINER_MOUNTED";var Z,Q;!function(e){e.CVV="CVV",e.EXPIRATION_DATE="EXPIRATION_DATE",e.CARD_NUMBER="CARD_NUMBER",e.CARDHOLDER_NAME="CARDHOLDER_NAME",e.INPUT_FIELD="INPUT_FIELD",e.PIN="PIN",e.EXPIRATION_MONTH="EXPIRATION_MONTH",e.EXPIRATION_YEAR="EXPIRATION_YEAR"}(Z||(Z={})),function(e){e.VISA="VISA",e.MASTERCARD="MASTERCARD",e.AMEX="AMEX",e.DINERS_CLUB="DINERS_CLUB",e.DISCOVER="DISCOVER",e.JCB="JCB",e.MAESTRO="MAESTRO",e.UNIONPAY="UNIONPAY",e.HIPERCARD="HIPERCARD",e.DEFAULT="DEFAULT",e.UNKNOWN="UNKNOWN"}(Q||(Q={}));const ee={[Q.AMEX]:["XXXX XXXXXX XXXXX",{X:"[0-9]"}],[Q.VISA]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[Q.MASTERCARD]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[Q.DISCOVER]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Q.DINERS_CLUB]:["XXXX XXXXXX XXXXXX",{X:"[0-9]"}],[Q.JCB]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Q.MAESTRO]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Q.UNIONPAY]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Q.HIPERCARD]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Q.DEFAULT]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Q.UNKNOWN]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}]},te={textarea:{name:"textarea",attributes:{type:"textarea"},sensitive:!1},checkbox:{name:"checkbox",attributes:{type:"checkbox"},sensitive:!1},radio:{name:"radio",attributes:{type:"radio"},sensitive:!1},dropdown:{name:"dropdown",attributes:{type:"select"},sensitive:!1},[Z.CARDHOLDER_NAME]:{name:"cardHolderName",attributes:{type:"text",autocomplete:"cc-name"},sensitive:!0,regex:/^([a-zA-Z\\ \\,\\.\\-\\']{2,})$/},[Z.CARD_NUMBER]:{name:"CARD_NUMBER",attributes:{type:"text",autocomplete:"cc-number",inputmode:"numeric"},sensitive:!0,mask:ee[Q.DEFAULT],regex:/$|^[\s]*?([0-9]{2,6}[ -]?){3,5}[\s]*/},[Z.EXPIRATION_DATE]:{name:"EXPIRATION_DATE",attributes:{type:"text",autocomplete:"cc-exp",inputmode:"numeric"},sensitive:!0},[Z.EXPIRATION_MONTH]:{name:"EXPIRATION_MONTH",attributes:{maxLength:2,type:"text",inputmode:"numeric",autocomplete:"cc-exp-month"},sensitive:!0,mask:["XX",{X:"[0-9]"}]},[Z.EXPIRATION_YEAR]:{name:"EXPIRATION_YEAR",attributes:{type:"text",inputmode:"numeric",autocomplete:"cc-exp-year"},sensitive:!0},[Z.CVV]:{name:"CVV",attributes:{type:"text",inputmode:"numeric",maxLength:4},sensitive:!0,regex:/^$|^[0-9]{3,4}$/},[Z.INPUT_FIELD]:{name:"INPUT_FIELD",sensitive:!0,attributes:{type:"text"}},[Z.PIN]:{name:"PIN",attributes:{type:"text",inputmode:"numeric",maxLength:12,minLength:4},sensitive:!0,regex:/^$|^[0-9]{4,12}$/}},ie="XXXX-XXXX-XXXX-XXXX",ne={height:"100%",width:"100%",margin:0,padding:0,border:0,position:"absolute",top:0,left:0,"user-select":"none"},se={position:"absolute",top:0,width:0,height:0,visibility:"hidden",left:"-99999999px","user-select":"none"},oe={width:"100%",height:"100%",border:"0",padding:"0",margin:"0",outline:"none"},re={WEBPACKAUTOFILL:"-webkit-autofill",BASE:"base",FOCUS:"focus",COMPLETE:"complete",EMPTY:"empty",INVALID:"invalid",GLOBAL:"global",REQUIRED_ASTERISK:"requiredAsterisk"};re.BASE,re.REQUIRED_ASTERISK;const ae={[Q.VISA]:{regex:/^4\d*/,maxCardLength:19,cardLengthRange:[13,16]},[Q.MASTERCARD]:{regex:/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720)\d*/,maxCardLength:16,cardLengthRange:[16]},[Q.AMEX]:{regex:/^3[47]\d*/,maxCardLength:15,cardLengthRange:[15]},[Q.DINERS_CLUB]:{regex:/^(36|38|30[0-5])\d*/,maxCardLength:16,cardLengthRange:[14,15,16,17,18,19]},[Q.DISCOVER]:{regex:/^(6011|65|64[4-9]|622)\d*/,maxCardLength:16,cardLengthRange:[16,17,18,19]},[Q.JCB]:{regex:/^35\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[Q.HIPERCARD]:{regex:/^606282\d*/,maxCardLength:19,cardLengthRange:[14,15,16,17,18,19]},[Q.UNIONPAY]:{regex:/^62\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[Q.MAESTRO]:{regex:/^(5018|5020|5038|5043|5[6-9]|6020|6304|6703|6759|676[1-3])\d*/,maxCardLength:19,cardLengthRange:[12,13,14,15,16,17,18,19]}};Q.DEFAULT,Q.AMEX,Q.DINERS_CLUB,Q.DISCOVER,Q.HIPERCARD,Q.JCB,Q.MAESTRO,Q.MASTERCARD,Q.UNIONPAY,Q.VISA;const le="MM/YY",de=[le,"YYYY/MM","YY/MM","MM/YYYY"],ce=["YY","YYYY"];var ue;!function(e){e.APPLICATIONORJSON="application/json",e.TEXTORPLAIN="text/plain",e.TEXTORXML="text/xml",e.FORMURLENCODED="application/x-www-form-urlencoded",e.FORMDATA="multipart/form-data"}(ue||(ue={})),Z.CARD_NUMBER,Z.EXPIRATION_DATE,Z.EXPIRATION_MONTH,Z.EXPIRATION_YEAR,Z.CVV,Z.EXPIRATION_DATE,Z.CARD_NUMBER,Z.CARDHOLDER_NAME,Z.INPUT_FIELD,x.INVALID_COLLECT_VALUE,Z.PIN,Z.EXPIRATION_MONTH,Z.EXPIRATION_YEAR,Z.CVV,Z.EXPIRATION_DATE,Z.CARD_NUMBER,Z.CARDHOLDER_NAME,Z.INPUT_FIELD,x.DEFAULT_REQUIRED_COLLECT_VALUE,Z.PIN,Z.EXPIRATION_MONTH,Z.EXPIRATION_YEAR;const Ee=[Z.CARDHOLDER_NAME,Z.EXPIRATION_MONTH,Z.PIN,Z.CVV],_e={X:"[0-9]"};class he{constructor(){this.events={}}on(e,t,i=!1){this.events[e]?this.events[e].push({priority:i,callback:t}):this.events[e]=[{priority:i,callback:t}]}off(e,t){const i=this.events[e];if(!i)return;const n=i.findIndex((e=>e.callback===t));i.splice(n,1)}_emit(e,...t){const i=this.events[e];i&&i.forEach((e=>{e.callback(...t)}))}hasListener(e){const t=this.events[e];return!!t&&t.length>0}resetEvents(){const e={};Object.keys(this.events).forEach((t=>{const i=this.events[t];if(i&&i.length>0){const n=[];i.forEach((e=>{e.priority&&n.push(e)})),e[t]=n}})),this.events=e}static createChild(e){e.prototype=Object.create(he.prototype,{constructor:e})}}
1
+ !function(){"use strict";function e(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{l(n.next(e))}catch(e){s(e)}}function a(e){try{l(n.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}l((n=n.apply(e,t||[])).next())}))}function t(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)}function i(e,t,i,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,i):o?o.value=i:t.set(e,i),i}exports.ElementType=void 0,function(e){e.CARD_NUMBER="CARD_NUMBER",e.CARDHOLDER_NAME="CARDHOLDER_NAME",e.CVV="CVV",e.EXPIRATION_MONTH="EXPIRATION_MONTH",e.EXPIRATION_YEAR="EXPIRATION_YEAR"}(exports.ElementType||(exports.ElementType={})),"function"==typeof SuppressedError&&SuppressedError;var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function o(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var s={};!function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t=(e=>(e.PAYRAILS_CLIENT_CONFIG_MALFORMED="payrails:client:init.config_malformed",e.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT="payrails:client:collectContainer.unmountable",e.PAYRAILS_CLIENT_UI_ELEMENT_MISSING="payrails:client:mount.ui_element_missing",e.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING="payrails:client:mount.parent_element_missing",e.PAYRAILS_CLIENT_SUBELEMENTS_RENDER_ERROR="payrails:client:mount.subelements_render_error",e.PAYRAILS_CLIENT_CARD_FORM_MISSING="payrails:client:pay.card_form_missing",e.PAYRAILS_CLIENT_GPAY_LOADING_ERROR="payrails:client:mount.gpay_loading_error",e.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING="payrails:client:init.gpay_config_missing",e.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR="payrails:client:mount.applepay_loading_error",e.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING="payrails:client:init.applepay_config_missing",e.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR="payrails:client:init.paypal_loading_error",e.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING="payrails:client:init.paypal_config_missing",e.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION="payrails:client:init.paypal_order_creation",e.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT="payrails:client:mount.paypal_button_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR="payrails:client:payment_executor.pay_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_3DS_ERROR="payrails:client:payment_executor.3ds_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR="payrails:client:payment_executor.confirm_error",e.PAYRAILS_API_UNAUTHORIZED="payrails:api:unauthorized",e.PAYRAILS_API_TOO_MANY_REQUESTS="payrails:api:too_many_requests",e.PAYRAILS_API_UNSUCCESSFUL="payrails:api:unsuccessful",e.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED="payrails:api:authorization_not_requested",e.PAYRAILS_API_AUTHENTICATION_ERROR="payrails:api:request_authentication_error",e.PAYRAILS_API_AUTHORIZATION_ERROR="payrails:api:request_authorization_error",e.PAYRAILS_CLIENT_API_URL_NOT_FOUND="payrails:client:api_url_not_found",e.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND="payrails:client:workflow_execution_not_found",e.PAYRAILS_CARD_FORM_CREATION_FAILED="payrails:card_form:iframe_creation_failed",e.PAYRAILS_CARD_FORM_IFRAME_URL_MISSING="payrails:card_form:iframe_url_missing",e.PAYRAILS_CLIENT_UNKNOWN_ERROR="payrails:client:unknown",e.PAYRAILS_API_UNKNOWN_ERROR="payrails:api:unknown",e.PAYRAILS_CLIENT_ONPAY_CALLBACK_FAILED="payrails:client:card.onpay_callback_failed",e.PAYRAILS_CARD_FORM_ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE="payrails.card_form.element_not_mounted_in_element_match_rule",e.PAYRAILS_CARD_FORM_REQUIRED_PARAMS_NOT_PROVIDED="payrails.card_form.required_params_not_provided",e.PAYRAILS_CARD_FORM_CLIENT_CONNECTION="payrails.card_form.client_connection",e.PAYRAILS_CARD_FORM_IFRAME_NOT_FOUND="payrails.card_form.iframe_not_found",e.PAYRAILS_CARD_FORM_IFRAME_LOADING_ERROR="payrails.card_form.iframe_loading_error",e.PAYRAILS_CARD_FORM_CSP_ERROR="payrails.card_form.iframe_csp_error",e.PAYRAILS_CARD_FORM_COMPLETE_AND_VALID_INPUTS="payrails.card_form.complete_and_valid_inputs",e.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED="payrails.card_form.collect_element_not_mounted",e.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK="payrails:client:generic_redirect.missing.redirect_link",e))(t||{});const i={"payrails:client:init.config_malformed":{description:"The provided configuration string is invalid. Please ensure it matches the required format and structure as defined in the documentation",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:unknown":{description:"Unknown Client",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:unauthorized":{description:"Unauthorized access to the Payrails API",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:too_many_requests":{description:"Too many requests to the Payrails API",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:unsuccessful":{description:"Unsuccessful request to the Payrails API",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collectContainer.unmountable":{description:"Collect container cannot be mounted",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.ui_element_missing":{description:"Colect container element does not exist",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:pay.card_form_missing":{description:"Trying to collect values from non-existent card form",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.gpay_loading_error":{description:"Google pay can not be initialized",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.paypal_loading_error":{description:"Paypal can not be initialized",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.paypal_order_creation":{description:"Paypal order creation failed",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.paypal_button_error":{description:"PaypalButtonError occurred",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.parent_element_missing":{description:"Parent element not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.subelements_render_error":{description:"Subelements could not be rendered. Please set id for the element first.",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:api_url_not_found":{description:"API URL not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:workflow_execution_not_found":{description:"Workflow execution not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.paypal_config_missing":{description:"Paypal config not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:authorization_not_requested":{description:"Authorization was not requested",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.gpay_config_missing":{description:"Google pay config not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.applepay_loading_error":{description:"Apple pay can not be initialized",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.applepay_config_missing":{description:"Apple pay config not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:card_form:iframe_creation_failed":{description:"Error occured while creating an iframe",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:card_form:iframe_url_missing":{description:"Iframe URL is missing",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:card.onpay_callback_failed":{description:"Callback passed to onPaymentButtonClicked threw an error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:request_authentication_error":{description:"Authentication error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:unknown":{description:"Unknown API error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:payment_executor.pay_error":{description:"Error occured while executing a payment",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:payment_executor.confirm_error":{description:"Error occured while confirming a payment",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:request_authorization_error":{description:"Authorization error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:payment_executor.3ds_error":{description:"Authorization failed after 3DS challenge.",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.element_not_mounted_in_element_match_rule":{description:"Interface: collect element - collect element is not mounted in ValidationRule params at index %s1 in validations array",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.required_params_not_provided":{description:"Interface: collect element - Required params are not provided.",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.client_connection":{description:"Interface: collect container - client connection not established. client info has not reached iframes",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.iframe_not_found":{description:"Interface: collect element - frame not found:",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.complete_and_valid_inputs":{description:"Interface: collect container - Provide complete and valid inputs",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.collect_element_not_mounted":{description:"Interface: composable collect - collect element is not mounted",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.iframe_loading_error":{description:"Interface: collect element - Error occured while loading iframe",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.iframe_csp_error":{description:"Interface: collect element - Content Security Policy error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:generic_redirect.missing.redirect_link":{description:"[Generic Redirect] Missing redirect link in response"}};var n=(e=>(e.ERROR="payrails:error",e.INFO="payrails:info",e.DEBUG="payrails:debug",e.WARN="payrails:warn",e))(n||{});class o extends Error{constructor(e,t){var n;const{description:s,docUrl:r,cause:a}=null!=t?t:{},{description:l,docUrl:d}=i[e]||{},c=null!=(n=null!=s?s:l)?n:"An unknown error occurred",u=null!=r?r:d;super(c),this.name=e,this.docUrl=u,this.cause=a,this.message=c,Error.captureStackTrace&&Error.captureStackTrace(this,o)}toJSON(){return{name:this.name,message:this.message,docUrl:this.docUrl,stack:this.stack,cause:this.cause}}}e.ERROR_CODES=t,e.PAYRAILS_OBSERVABILITY_EVENTS=n,e.PayrailsError=o}(s);var r={};!function(e){var t=Object.defineProperty,i=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,r=(e,i,n)=>i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n,a=(e,t)=>{for(var n in t||(t={}))o.call(t,n)&&r(e,n,t[n]);if(i)for(var n of i(t))s.call(t,n)&&r(e,n,t[n]);return e};Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});class l{log(e,t){console.log(JSON.stringify({level:e,mssg:t.mssg,error:t.error,withMetada:t.withMetada,extra:t.extra}))}}var d=(e=>(e.ERROR="payrails:error",e.INFO="payrails:info",e.DEBUG="payrails:debug",e.WARN="payrails:warn",e))(d||{}),c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n?n:"undefined"!=typeof self?self:{};function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var E,_={},h={};var I,p={};var f,v={};var m={};Object.defineProperty(m,"__esModule",{value:!0}),m.subscribers=m.childWindows=m.prefix=void 0,m.prefix="/*framebus*/",m.childWindows=[],m.subscribers={};var N,T={};var y={};Object.defineProperty(y,"__esModule",{value:!0}),y.hasOpener=void 0,y.hasOpener=function(e){return e.top===e&&(null!=e.opener&&(e.opener!==e&&!0!==e.opener.closed))};var O={};Object.defineProperty(O,"__esModule",{value:!0}),O.isntString=void 0,O.isntString=function(e){return"string"!=typeof e};var A,L={};var R,g={};var S={};Object.defineProperty(S,"__esModule",{value:!0}),S.sendMessage=void 0,S.sendMessage=function(e,t,i){try{e.postMessage(t,i)}catch(e){}};var C,D={},P={};function b(){if(C)return P;C=1,Object.defineProperty(P,"__esModule",{value:!0}),P.Framebus=void 0;var e=B(),t="undefined"!=typeof window&&window.Promise,i=function(){function i(e){void 0===e&&(e={}),this.origin=e.origin||"*",this.channel=e.channel||"",this.verifyDomain=e.verifyDomain,this.targetFrames=e.targetFrames||[],this.limitBroadcastToFramesArray=Boolean(e.targetFrames),this.isDestroyed=!1,this.listeners=[],this.hasAdditionalChecksForOnListeners=Boolean(this.verifyDomain||this.limitBroadcastToFramesArray)}return i.setPromise=function(e){i.Promise=e},i.target=function(e){return new i(e)},i.prototype.addTargetFrame=function(e){this.limitBroadcastToFramesArray&&this.targetFrames.push(e)},i.prototype.include=function(t){return null!=t&&(null!=t.Window&&(t.constructor===t.Window&&(e.childWindows.push(t),!0)))},i.prototype.target=function(e){return i.target(e)},i.prototype.emit=function(t,i,n){if(this.isDestroyed)return!1;var o=this.origin;if(t=this.namespaceEvent(t),(0,e.isntString)(t))return!1;if((0,e.isntString)(o))return!1;"function"==typeof i&&(n=i,i=void 0);var s=(0,e.packagePayload)(t,o,i,n);return!!s&&(this.limitBroadcastToFramesArray?this.targetFramesAsWindows().forEach((function(t){(0,e.sendMessage)(t,s,o)})):(0,e.broadcast)(s,{origin:o,frame:window.top||window.self}),!0)},i.prototype.emitAsPromise=function(e,t){var n=this;return new i.Promise((function(i,o){n.emit(e,t,(function(e){i(e)}))||o(new Error('Listener not added for "'.concat(e,'"')))}))},i.prototype.on=function(t,i){if(this.isDestroyed)return!1;var n=this,o=this.origin,s=i;return t=this.namespaceEvent(t),!(0,e.subscriptionArgsInvalid)(t,s,o)&&(this.hasAdditionalChecksForOnListeners&&(s=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];n.passesVerifyDomainCheck(this&&this.origin)&&n.hasMatchingTargetFrame(this&&this.source)&&i.apply(void 0,e)}),this.listeners.push({eventName:t,handler:s,originalHandler:i}),e.subscribers[o]=e.subscribers[o]||{},e.subscribers[o][t]=e.subscribers[o][t]||[],e.subscribers[o][t].push(s),!0)},i.prototype.off=function(t,i){var n=i;if(this.isDestroyed)return!1;if(this.verifyDomain)for(var o=0;o<this.listeners.length;o++){var s=this.listeners[o];s.originalHandler===i&&(n=s.handler)}t=this.namespaceEvent(t);var r=this.origin;if((0,e.subscriptionArgsInvalid)(t,n,r))return!1;var a=e.subscribers[r]&&e.subscribers[r][t];if(!a)return!1;for(o=0;o<a.length;o++)if(a[o]===n)return a.splice(o,1),!0;return!1},i.prototype.teardown=function(){if(!this.isDestroyed){this.isDestroyed=!0;for(var e=0;e<this.listeners.length;e++){var t=this.listeners[e];this.off(t.eventName,t.handler)}this.listeners.length=0}},i.prototype.passesVerifyDomainCheck=function(e){return!this.verifyDomain||this.checkOrigin(e)},i.prototype.targetFramesAsWindows=function(){return this.limitBroadcastToFramesArray?this.targetFrames.map((function(e){return e instanceof HTMLIFrameElement?e.contentWindow:e})).filter((function(e){return e})):[]},i.prototype.hasMatchingTargetFrame=function(e){if(!this.limitBroadcastToFramesArray)return!0;var t=this.targetFramesAsWindows().find((function(t){return t===e}));return Boolean(t)},i.prototype.checkOrigin=function(e){var t,i=document.createElement("a");return i.href=location.href,t="https:"===i.protocol?i.host.replace(/:443$/,""):"http:"===i.protocol?i.host.replace(/:80$/,""):i.host,i.protocol+"//"+t===e||(!this.verifyDomain||this.verifyDomain(e))},i.prototype.namespaceEvent=function(e){return this.channel?"".concat(this.channel,":").concat(e):e},i.Promise=t,i}();return P.Framebus=i,P}var M,w=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))};var U,k={};var x={};Object.defineProperty(x,"__esModule",{value:!0});var Y,F,V={};function B(){return F||(F=1,e=_,t=c&&c.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),i=c&&c.__exportStar||function(e,i){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(i,n)||t(i,e,n)},Object.defineProperty(e,"__esModule",{value:!0}),i(function(){if(E)return h;E=1,Object.defineProperty(h,"__esModule",{value:!0}),h.detach=h.attach=void 0;var e=B(),t=!1;return h.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},h.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},h}(),e),i(function(){if(I)return p;I=1,Object.defineProperty(p,"__esModule",{value:!0}),p.broadcastToChildWindows=void 0;var e=B();return p.broadcastToChildWindows=function(t,i,n){for(var o=e.childWindows.length-1;o>=0;o--){var s=e.childWindows[o];s.closed?e.childWindows.splice(o,1):n!==s&&(0,e.broadcast)(t,{origin:i,frame:s.top})}},p}(),e),i(function(){if(f)return v;f=1,Object.defineProperty(v,"__esModule",{value:!0}),v.broadcast=void 0;var e=B();return v.broadcast=function t(i,n){var o,s=0,r=n.origin,a=n.frame;try{for(a.postMessage(i,r),(0,e.hasOpener)(a)&&a.opener.top!==window.top&&t(i,{origin:r,frame:a.opener.top});o=a.frames[s];)t(i,{origin:r,frame:o}),s++}catch(e){}},v}(),e),i(m,e),i(function(){if(N)return T;N=1,Object.defineProperty(T,"__esModule",{value:!0}),T.dispatch=void 0;var e=B();return T.dispatch=function(t,i,n,o,s){if(e.subscribers[t]&&e.subscribers[t][i]){var r=[];n&&r.push(n),o&&r.push(o);for(var a=0;a<e.subscribers[t][i].length;a++)e.subscribers[t][i][a].apply(s,r)}},T}(),e),i(y,e),i(O,e),i(function(){if(A)return L;A=1,Object.defineProperty(L,"__esModule",{value:!0}),L.onMessage=void 0;var e=B();return L.onMessage=function(t){if(!(0,e.isntString)(t.data)){var i=(0,e.unpackPayload)(t);if(i){var n=i.eventData,o=i.reply;(0,e.dispatch)("*",i.event,n,o,t),(0,e.dispatch)(t.origin,i.event,n,o,t),(0,e.broadcastToChildWindows)(t.data,i.origin,t.source)}}},L}(),e),i(function(){if(R)return g;R=1,Object.defineProperty(g,"__esModule",{value:!0}),g.packagePayload=void 0;var e=B();return g.packagePayload=function(t,i,n,o){var s,r={event:t,origin:i};"function"==typeof o&&(r.reply=(0,e.subscribeReplier)(o,i)),r.eventData=n;try{s=e.prefix+JSON.stringify(r)}catch(e){throw new Error("Could not stringify event: ".concat(e.message))}return s},g}(),e),i(S,e),i(function(){if(M)return D;M=1;var e=c&&c.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(D,"__esModule",{value:!0}),D.subscribeReplier=void 0;var t=b(),i=e(w);return D.subscribeReplier=function(e,n){var o=(0,i.default)();return t.Framebus.target({origin:n}).on(o,(function i(s,r){e(s,r),t.Framebus.target({origin:n}).off(o,i)})),o},D}(),e),i(function(){if(U)return k;U=1,Object.defineProperty(k,"__esModule",{value:!0}),k.subscriptionArgsInvalid=void 0;var e=B();return k.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},k}(),e),i(x,e),i(function(){if(Y)return V;Y=1,Object.defineProperty(V,"__esModule",{value:!0}),V.unpackPayload=void 0;var e=B();return V.unpackPayload=function(t){var i;if(t.data.slice(0,e.prefix.length)!==e.prefix)return!1;try{i=JSON.parse(t.data.slice(e.prefix.length))}catch(e){return!1}if(i.reply){var n=t.origin,o=t.source,s=i.reply;i.reply=function(t){if(o){var i=(0,e.packagePayload)(s,n,t);i&&o.postMessage(i,n)}}}return i},V}(),e)),_;var e,t,i}var G=B(),j=b();(0,G.attach)();const X=u(j.Framebus);class H{constructor(e){this.origin=null,this.listeners=[],this.bus=new X(e)}static getInstance(){return H.instance||(H.instance=new H),H.instance}on(e,t){return this.bus.on(e,t)}off(e,t){return this.bus.off(e,t)}emit(e,t,i=void 0){return this.bus.emit(e,t,i)}target(e){return this.bus.target(e)}}class W{constructor(){this.bus=H.getInstance()}log(e,t){this.bus.emit(d.ERROR,{level:e,event:t})}}var z=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===K}(e)}(e)};var K="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function $(e,t){return!1!==t.clone&&t.isMergeableObject(e)?ee((i=e,Array.isArray(i)?[]:{}),e,t):e;var i}function q(e,t,i){return e.concat(t).map((function(e){return $(e,i)}))}function J(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return Object.propertyIsEnumerable.call(e,t)})):[]}(e))}function Z(e,t){try{return t in e}catch(e){return!1}}function Q(e,t,i){var n={};return i.isMergeableObject(e)&&J(e).forEach((function(t){n[t]=$(e[t],i)})),J(t).forEach((function(o){(function(e,t){return Z(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,o)||(Z(e,o)&&i.isMergeableObject(t[o])?n[o]=function(e,t){if(!t.customMerge)return ee;var i=t.customMerge(e);return"function"==typeof i?i:ee}(o,i)(e[o],t[o],i):n[o]=$(t[o],i))})),n}function ee(e,t,i){(i=i||{}).arrayMerge=i.arrayMerge||q,i.isMergeableObject=i.isMergeableObject||z,i.cloneUnlessOtherwiseSpecified=$;var n=Array.isArray(t);return n===Array.isArray(e)?n?i.arrayMerge(e,t,i):Q(e,t,i):$(t,i)}ee.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,i){return ee(e,i,t)}),{})};const te=u(ee);class ie{constructor(){this.state={}}static getInstance(){return ie.instance||(ie.instance=new ie),ie.instance}getState(e){return this.state[e]}setState(e){this.state=te(this.state,e)}}const ne=ie.getInstance(),oe=()=>window&&window.navigator,se=()=>window&&window.screen,re=()=>({resolution:`${se().width}x${se().height}`,user_agent:oe().userAgent,language:oe().language});class ae{constructor(e){this.adapter=[new W],this.enabled=e.enabled||!0,this.initGlobalState(e),e.logLevel=e.logLevel||"error","debug"===e.logLevel&&this.addAdapter(new l)}static init(e){ae.instance=new ae(e)}static getLogger(){return ae.instance}initGlobalState(e){ne.setState({payrails:e.payrails,sdk:e.sdk})}static setState(e){ne.setState(e)}log(e,t,i){this.enabled&&this.adapter.forEach((n=>{n.log(e,{mssg:t,error:null==i?void 0:i.error,withMetada:a(a({},this.constructMetadata()),null==i?void 0:i.withMetada),extra:null==i?void 0:i.extra})}))}constructMetadata(){return{device:re(),payrails:ne.getState("payrails"),sdk:ne.getState("sdk")}}addAdapter(e){this.adapter.push(e)}static log(e,t){this.getLogger().log("info",e,t)}static debug(e,t){this.getLogger().log("debug",e,t)}static info(e,t){this.getLogger().log("info",e,t)}static warn(e,t){this.getLogger().log("warning",e,t)}static error(e,t){this.getLogger().log("error",e,t)}static exception(e,t){this.error(e,t)}}e.PayrailsLogger=ae,e.getDeviceInfo=re}(r);for(var a,l=[],d=0;d<256;++d)l.push((d+256).toString(16).slice(1));var c=new Uint8Array(16);function u(){if(!a&&!(a="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return a(c)}var E={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function _(e,t,i){if(E.randomUUID&&!t&&!e)return E.randomUUID();var n=(e=e||{}).random||(e.rng||u)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){i=i||0;for(var o=0;o<16;++o)t[i+o]=n[o];return t}return function(e,t=0){return(l[e[t+0]]+l[e[t+1]]+l[e[t+2]]+l[e[t+3]]+"-"+l[e[t+4]]+l[e[t+5]]+"-"+l[e[t+6]]+l[e[t+7]]+"-"+l[e[t+8]]+l[e[t+9]]+"-"+l[e[t+10]]+l[e[t+11]]+l[e[t+12]]+l[e[t+13]]+l[e[t+14]]+l[e[t+15]]).toLowerCase()}(n)}var h;!function(e){e.GET="GET",e.POST="POST"}(h||(h={}));const I=({url:t,method:i=h.GET,token:n,body:o})=>e(void 0,void 0,void 0,(function*(){const e={method:i,headers:Object.assign(Object.assign(Object.assign({},T()),N(n)),y())};i===h.POST&&(e.body=JSON.stringify(o||{}));const s=yield fetch(t,e),r=yield s.json();if([401,403].includes(s.status))throw new p(t,i);if(429===s.status)throw new v(t,i);if(!s.ok)throw new f(t,i);return{ok:s.ok,req:Object.assign({url:t},e),res:r}}));class p extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_UNAUTHORIZED,{description:`[${t}] ${e} unauthorized`})}}class f extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{description:`[${t}] ${e} unsuccessful`})}}class v extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} too many requests`})}}class m extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} max poll attempts exceeded.`})}}const N=e=>({authorization:`Bearer ${e}`}),T=()=>({"x-idempotency-key":_()}),y=()=>{const e={version:"5.8.3",type:"web-sdk"};return{"x-client-version":e.version,"x-client-type":e.type}},O=(t,i)=>e(void 0,void 0,void 0,(function*(){var e,n;if(null==t?void 0:t.onPaymentButtonClicked)try{const n=yield t.onPaymentButtonClicked(i);if(!n){const i=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_ONPAY_CALLBACK_FAILED,{description:"Callback passed to onPaymentButtonClicked resolved to false"});return r.PayrailsLogger.error(i.message,{error:i}),null===(e=null==t?void 0:t.onAuthorizeFailed)||void 0===e||e.call(t,{code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:i.message}),n}}catch(e){const i=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_ONPAY_CALLBACK_FAILED,{description:"Callback passed to onPaymentButtonClicked threw an error",cause:e});return r.PayrailsLogger.error(i.message,{error:i}),null===(n=t.onAuthorizeFailed)||void 0===n||n.call(t,{code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:i.message}),!1}return!0})),A={success:"https://payrails.io/success",error:"https://payrails.io/error",cancel:"https://payrails.io/cancel"};class L{constructor(e,t,i=A,n=680,o=60,s=2e3,r=5){this.sdkConfig=e,this.execution=t,this.returnLinks=i,this.POLL_INTERVAL=n,this.MAX_POLL_ATTEMPTS=o,this.POLL_INITIAL_DELAY=s,this.POLL_ERROR_COUNT_MULTIPLIER=r}pay(t){return e(this,void 0,void 0,(function*(){try{const e=(yield this.authorize(t)).res.links.execution;return yield this.pollForAuthorizationResult(e)}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR,{cause:e});throw r.PayrailsLogger.error(t.message,{error:t}),e}}))}confirm(t,i={}){return e(this,void 0,void 0,(function*(){try{const e=yield I({url:t,method:h.POST,token:this.sdkConfig.token,body:{data:i}}),n=yield this.pollForAuthorizationResult(e.res.links.execution);if(n.finalState)return n;const o=n.response.status.slice().sort(((e,t)=>new Date(t.time).getTime()-new Date(e.time).getTime()))[0].time,{res:s}=yield this.getExecution(e.res.links.execution,o);return{finalState:s.status.find((({code:e,time:t})=>["authorizeSuccessful","authorizeFailed"].includes(e)&&new Date(t)>new Date(o))),response:s}}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR,{cause:e});throw r.PayrailsLogger.error(t.message,{error:t}),e}}))}getExecution(t,i,n=0){return e(this,void 0,void 0,(function*(){if(n>this.MAX_POLL_ATTEMPTS)throw new m(t,h.GET);0===n&&i&&(yield this.wait(this.POLL_INITIAL_DELAY));try{const e=yield I({url:t,token:this.sdkConfig.token});if(i){if(!e.res.status.find((({time:e})=>new Date(e)>new Date(i))))return yield this.wait(this.POLL_INTERVAL),this.getExecution(t,i,n+1)}return e}catch(e){if(e instanceof f)return yield this.wait(this.POLL_INTERVAL),this.getExecution(t,i,n+this.POLL_ERROR_COUNT_MULTIPLIER);if(e instanceof v)return yield this.wait(this.POLL_INTERVAL*n),this.getExecution(t,i,n+1);throw e}}))}createApplePaySession(t){return e(this,void 0,void 0,(function*(){return I({url:t.requestUrl,method:h.POST,token:this.sdkConfig.token,body:{integrationType:"api",paymentMethodCode:"applePay",amount:this.sdkConfig.amount,meta:{sessionURL:t.sessionUrl,clientContext:{host:t.clientDomain||window.location.host}}}})}))}authorize(t){return e(this,void 0,void 0,(function*(){if(!this.execution.authorizeLink||!this.sdkConfig.amount){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND,{description:"SDK was not initialized with workflow execution"});throw r.PayrailsLogger.error(e.message,{error:e}),e}const{success:e,error:i,cancel:n}=this.returnLinks;return I({url:this.execution.authorizeLink,method:h.POST,token:this.sdkConfig.token,body:{amount:this.sdkConfig.amount,paymentComposition:t,returnInfo:{success:e,cancel:n,error:i}}})}))}wait(t){return e(this,void 0,void 0,(function*(){return new Promise((e=>setTimeout(e,t)))}))}pollForAuthorizationResult(t,i=0){return e(this,void 0,void 0,(function*(){const e=(yield this.getExecution(t)).res,n=e.status,o=["authorizePending","authorizeSuccessful","authorizeFailed"],a=n.find((({code:e})=>"authorizeRequested"===e));if(!a&&i<10)return yield new Promise((e=>setTimeout(e,this.POLL_INTERVAL))),this.pollForAuthorizationResult(t,i+1);if(!a){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED);throw r.PayrailsLogger.error(e.message,{error:e}),e}const l=n.find((({code:e,time:t})=>"confirmRequested"===e&&new Date(t)>new Date(a.time))),d=l?l.time:a.time;let c=n.find((({code:e,time:t})=>o.includes(e)&&new Date(t)>new Date(d)));if(!c){const{res:e}=yield this.getExecution(t,d);return c=e.status.find((({code:e,time:t})=>o.includes(e)&&new Date(t)>new Date(d))),{finalState:c,response:e}}return{finalState:c,response:e}}))}}class R{constructor(e,t,i,n,o=g.THREE_DS){this.link=e,this.execution=t,this.paymentExecutor=i,this.options=n,this.type=o,this.THREE_DS_SIZES=[[250,400],[390,400],[500,600],[600,400]],this.internalPopupBackground=null,this.SCREEN_WIDTH=window.innerWidth,this.SCREEN_HEIGHT=window.innerHeight}get iframeSize(){return this.type===g.THREE_DS?this.THREE_DS_SIZES.reduce(((e,t)=>this.SCREEN_WIDTH>t[0]?t:e),[250,400]):[this.SCREEN_WIDTH-50,this.SCREEN_HEIGHT-50]}get popupBackground(){if(this.internalPopupBackground)return this.internalPopupBackground;{const e=document.createElement("div");e.addEventListener("click",(()=>{e.remove()})),e.setAttribute("id","payrails-popup-background"),e.appendChild(this.popup),this.internalPopupBackground=e}return this.internalPopupBackground}get popup(){const e=document.createElement("div");return e.setAttribute("id","payrails-popup"),e.setAttribute("width",this.iframeSize[0].toString()),e.setAttribute("height",this.iframeSize[1].toString()),e.appendChild(this.iframe),e.style.width=`${this.iframeSize[0]+4}px`,e.style.height=`${this.iframeSize[1]+4}px`,e}get iframe(){const e=document.createElement("iframe");return e.setAttribute("id","payrails-frame"),e.setAttribute("src",this.link),e.setAttribute("width",this.iframeSize[0].toString()),e.setAttribute("height",this.iframeSize[1].toString()),e}handleMessages(){const t=i=>e(this,void 0,void 0,(function*(){var e,n,o,a;if(i.data&&'{"type":"3DS-challenge-completed"}'===i.data){window.removeEventListener("message",t);if((yield this.paymentExecutor.getExecution(this.execution.url)).res.status.find((({code:e})=>"authorizeSuccessful"===e)))null===(a=null===(o=this.options.events)||void 0===o?void 0:o.onAuthorizeSuccess)||void 0===a||a.call(o);else{const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_3DS_ERROR);r.PayrailsLogger.error(t.message,{error:t}),null===(n=null===(e=this.options.events)||void 0===e?void 0:e.onAuthorizeFailed)||void 0===n||n.call(e,{code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:"Authorization failed after 3DS challenge."})}this.unmount()}}));window.addEventListener("message",t)}mount(){var e;this.popup.remove(),null===(e=document.querySelector("body"))||void 0===e||e.appendChild(this.popupBackground),this.handleMessages()}unmount(){this.popupBackground.remove(),this.internalPopupBackground=null}}var g,S,C,D,P,b;!function(e){e[e.THREE_DS=0]="THREE_DS",e[e.GENERIC_REDIRECT=1]="GENERIC_REDIRECT"}(g||(g={}));class M{constructor(e,t,i){this.options=e,this.execution=t,this.paymentExecutor=i}handle3ds(e){var t,i,n;try{null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onThreeDSecureChallenge)||void 0===i||i.call(t)}catch(e){}const o=null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.links["3ds"];if(o){new R(o,this.execution,this.paymentExecutor,this.options).mount()}}}exports.PAYMENT_METHOD_CODES=void 0,(S=exports.PAYMENT_METHOD_CODES||(exports.PAYMENT_METHOD_CODES={})).CARD="card",S.GOOGLE_PAY="googlePay",S.PAYPAL="payPal",S.APPLE_PAY="applePay",S.GENERIC_REDIRECT="genericRedirect",function(e){e.ENABLED="enabled",e.CREATED="created",e.DELETED="deleted",e.DISABLED="disabled",e.INVALID="invalid",e.TRANSIENT="transient"}(C||(C={}));class w{constructor(e){this.executionResponse=e}get lookup(){return this.executionResponse.initialResults.find((({body:{name:e}})=>"lookup"===e))}get holderReference(){return this.executionResponse.holderReference}get savedCreditCards(){return this.getStoredInstrumentForPaymentMethod(exports.PAYMENT_METHOD_CODES.CARD)}get savedPaypalAccounts(){return this.getStoredInstrumentForPaymentMethod(exports.PAYMENT_METHOD_CODES.PAYPAL)}get savedGooglePayAccounts(){return this.getStoredInstrumentForPaymentMethod(exports.PAYMENT_METHOD_CODES.GOOGLE_PAY)}get savedApplePayAccounts(){return this.getStoredInstrumentForPaymentMethod(exports.PAYMENT_METHOD_CODES.APPLE_PAY)}get paypalConfig(){const e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===exports.PAYMENT_METHOD_CODES.PAYPAL));if(!e){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING);throw r.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:this.availablePaymentMethods}}),e}return e.config||{}}get googlePayConfig(){const e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===exports.PAYMENT_METHOD_CODES.GOOGLE_PAY));if(!e){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING);throw r.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:this.availablePaymentMethods}}),e}return e?[e.config]:[]}isPaymentMethodAvailable(e){return this.availablePaymentMethods.some((({paymentMethodCode:t})=>t===e))}get applePayConfig(){const e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===exports.PAYMENT_METHOD_CODES.APPLE_PAY));if(!e){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING);throw r.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:this.availablePaymentMethods}}),e}return e.config.parameters}get url(){return this.response.links.self}get response(){return this.executionResponse}get meta(){return this.executionResponse.meta}get availablePaymentMethods(){var e;return(null===(e=this.lookup)||void 0===e?void 0:e.body.data.paymentCompositionOptions)||[]}get authorizeLink(){var e;return null===(e=this.lookup)||void 0===e?void 0:e.body.links.authorize.href}get createSessionLink(){var e;return null===(e=this.response.links.startPaymentSession)||void 0===e?void 0:e.href}get storedPaymentInstruments(){return this.availablePaymentMethods.flatMap((e=>e.paymentInstruments||[]))}getStoredInstrumentForPaymentMethod(e){var t;return(null===(t=this.availablePaymentMethods.find((({paymentMethodCode:t})=>t===e)))||void 0===t?void 0:t.paymentInstruments)||[]}}!function(e){e.REDIRECT="redirect",e.DIRECT="direct"}(D||(D={})),exports.INTEGRATION_TYPE=void 0,(P=exports.INTEGRATION_TYPE||(exports.INTEGRATION_TYPE={})).API="api",P.HPP="hpp";class U{constructor(e,{id:t="",className:i=""}={}){this.subElements=[];const n=document.createElement(e);t&&(this.id=t,n.setAttribute("id",t)),i&&(Array.isArray(i)?n.setAttribute("class",function(...e){return e.filter(Boolean).join(" ")}(...i)):n.setAttribute("class",i)),this.element=n}get parentElement(){return this.element.parentElement}get selector(){if(!this.id)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);return`#${this.id}`}mount(e){const t=document.querySelector(e);if(!t)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING,{description:`Element with selector "${e}" not found in in the DOM`});this.clean(),t.appendChild(this.element),this.subElements.forEach((e=>{if(!this.id)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_SUBELEMENTS_RENDER_ERROR);e.mount(this.selector)}))}clean(){var e;null===(e=document.getElementById(this.element.id))||void 0===e||e.remove()}unmount(){var e;this.subElements.forEach((e=>e.unmount())),null===(e=this.parentElement)||void 0===e||e.removeChild(this.element)}}class k extends U{get bin(){var e;return this.selectedInstrument?this.selectedInstrument.data.bin?this.selectedInstrument.data.bin:"":(null===(e=this.cardForm)||void 0===e?void 0:e.bin)||""}constructor(e,t,i,n){var o;super("button",{id:"payrails-card-payment-button"}),this.sdkConfig=e,this.execution=t,this.options=i,this.returnInfo=n,this.selectedInstrument=null,this.element.innerText=(null===(o=null==i?void 0:i.translations)||void 0===o?void 0:o.label)||"Pay",this.element.addEventListener("click",this.onPay.bind(this)),this.element.addEventListener("mouseenter",(()=>{var e;this.element.classList.contains("disabled")||(this.element.classList.add("hover"),this.setStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{}))})),this.element.addEventListener("mouseleave",(()=>{var e;this.element.classList.contains("disabled")||(this.element.classList.remove("hover"),this.removeStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{}))})),this.paymentExecutor=new L(this.sdkConfig,this.execution,this.returnInfo)}setDisabled(e){var t,i,n,o,s;this.element.classList.contains("disabled")!==e&&(null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onStateChanged)||void 0===i||i.call(t,e?"disabled":"enabled")),this.element.disabled=e,e?(this.element.classList.add("disabled"),(null===(n=this.options.styles)||void 0===n?void 0:n.disabled)&&this.setStyles(this.options.styles.disabled)):(this.element.classList.remove("disabled"),this.removeStyles((null===(o=this.options.styles)||void 0===o?void 0:o.disabled)||{}),(null===(s=this.options.styles)||void 0===s?void 0:s.base)&&this.setStyles(this.options.styles.base))}setSavedCreditCard(e){console.warn("setSavedCreditCard is deprecated, please use setSavedInstrument"),this.setSavedInstrument(e)}setSavedInstrument(e){this.selectedInstrument=e,this.setDisabled(!1)}setStyles(e){var t;const i=Object.assign(Object.assign({},null===(t=this.options.styles)||void 0===t?void 0:t.base),e);Object.keys(i).forEach((e=>{this.element.style[e]=i[e]}))}removeStyles(e){var t;const i=Object.keys((null===(t=this.options.styles)||void 0===t?void 0:t.base)||{});Object.keys(e).forEach((e=>{var t,n;i.includes(e)?this.element.style[e]=null===(n=null===(t=this.options.styles)||void 0===t?void 0:t.base)||void 0===n?void 0:n[e]:this.element.style[e]=""}))}setLabel(e){this.element.innerText=e}setCardForm(e){this.cardForm=e}triggerLoading(e){var t,i,n,o;const s=this.element.offsetWidth;this.element.style.minWidth=`${s}px`,e?(this.element.innerHTML='<div class="dot-flashing"></div>',this.element.classList.add("loading"),(null===(t=this.options.styles)||void 0===t?void 0:t.loading)&&this.setStyles(this.options.styles.loading)):(this.element.innerText=(null===(n=null===(i=this.options)||void 0===i?void 0:i.translations)||void 0===n?void 0:n.label)||"Pay",this.element.classList.remove("loading"),this.removeStyles((null===(o=this.options.styles)||void 0===o?void 0:o.loading)||{}))}onAuthorizationFailed(e){var t,i;this.setDisabled(!1),this.triggerLoading(!1),(null===(t=this.options.events)||void 0===t?void 0:t.onAuthorizeFailed)&&(null===(i=this.options.events)||void 0===i||i.onAuthorizeFailed(e))}onPay(){var t,i,n,o,a,l,d,c;return e(this,void 0,void 0,(function*(){this.setDisabled(!0),this.triggerLoading(!0);if(!(yield O(this.options.events,{bin:this.bin||""})))return this.setDisabled(!1),void this.triggerLoading(!1);try{let e=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.CARD,integrationType:"api",amount:this.sdkConfig.amount,storeInstrument:!1}];if(null===(t=this.selectedInstrument)||void 0===t?void 0:t.id)e[0].paymentInstrumentId=null===(i=this.selectedInstrument)||void 0===i?void 0:i.id,e[0].paymentMethodCode=null===(n=this.selectedInstrument)||void 0===n?void 0:n.paymentMethod;else{if(!this.cardForm){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CARD_FORM_MISSING);throw r.PayrailsLogger.error(e.message,{error:e}),e}e=this.sdkConfig.usePayrailsFrames?yield this.constructEncryptedPayment(e):yield this.constructTokenizedPayment(e)}const o=yield this.paymentExecutor.pay(e);this.handleAuthorizationResult(o)}catch(e){let t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_AUTHENTICATION_ERROR,{cause:e});e instanceof p||[401,403].includes(null===(o=null==e?void 0:e.error)||void 0===o?void 0:o.code)?(null===(l=null===(a=this.options.events)||void 0===a?void 0:a.onPaymentSessionExpired)||void 0===l||l.call(a),t.message="API token is not valid or expired.",r.PayrailsLogger.error(t.message,{error:t}),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:t.message})):e.toString().includes("Invalid token")?(null===(c=null===(d=this.options.events)||void 0===d?void 0:d.onPaymentSessionExpired)||void 0===c||c.call(d),t.message="Vault token is not valid or expired.",r.PayrailsLogger.error(t.message,{error:t})):t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_UNKNOWN_ERROR,{cause:e}),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:t.message})}}))}constructTokenizedPayment(t){return e(this,void 0,void 0,(function*(){const{storeInstrument:e,enrollInstrumentToNetworkOffers:i,cardData:n}=yield this.cardForm.collectValues();return t[0].paymentInstrumentData={vaultToken:null==n?void 0:n.instrumentId,card:{numberToken:null==n?void 0:n.card_number,securityCodeToken:null==n?void 0:n.security_code}},t[0].storeInstrument=e,t[0].enrollInstrumentToNetworkOffers=i,t}))}constructEncryptedPayment(t){return e(this,void 0,void 0,(function*(){const{cardData:e,storeInstrument:i,enrollInstrumentToNetworkOffers:n}=yield this.cardForm.collectValues();return t[0].paymentInstrumentData=Object.assign({},e),t[0].storeInstrument=i,t[0].enrollInstrumentToNetworkOffers=n,t}))}handleAuthorizationResult(e){var t,i,n;let o;switch(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code){case"authorizeSuccessful":this.triggerLoading(!1),(null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeSuccess)&&this.options.events.onAuthorizeSuccess();break;case"authorizePending":if("3ds"===(null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.actionRequired)){new M({events:Object.assign(Object.assign({},this.options.events),{onAuthorizeFailed:e=>{this.onAuthorizationFailed(e)}})},this.execution,this.paymentExecutor).handle3ds(e)}break;default:o=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_ERROR),r.PayrailsLogger.error(o.message,{error:o,extra:{result:e}}),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:o.message})}}}exports.AuthorizationFailureReasons=void 0,(b=exports.AuthorizationFailureReasons||(exports.AuthorizationFailureReasons={})).VALIDATION_FAILED="VALIDATION_FAILED",b.AUTHORIZATION_ERROR="AUTHORIZATION_ERROR",b.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",b.UNKNOWN_ERROR="UNKNOWN_ERROR";var x={};!function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n?n:"undefined"!=typeof self?self:{};function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var o,s={},r={};var a,l={};var d,c={};var u={};Object.defineProperty(u,"__esModule",{value:!0}),u.subscribers=u.childWindows=u.prefix=void 0,u.prefix="/*framebus*/",u.childWindows=[],u.subscribers={};var E,_={};var h={};Object.defineProperty(h,"__esModule",{value:!0}),h.hasOpener=void 0,h.hasOpener=function(e){return e.top===e&&(null!=e.opener&&(e.opener!==e&&!0!==e.opener.closed))};var I={};Object.defineProperty(I,"__esModule",{value:!0}),I.isntString=void 0,I.isntString=function(e){return"string"!=typeof e};var p,f={};var v,m={};var N={};Object.defineProperty(N,"__esModule",{value:!0}),N.sendMessage=void 0,N.sendMessage=function(e,t,i){try{e.postMessage(t,i)}catch(e){}};var T,y={},O={};function A(){if(T)return O;T=1,Object.defineProperty(O,"__esModule",{value:!0}),O.Framebus=void 0;var e=M(),t="undefined"!=typeof window&&window.Promise,i=function(){function i(e){void 0===e&&(e={}),this.origin=e.origin||"*",this.channel=e.channel||"",this.verifyDomain=e.verifyDomain,this.targetFrames=e.targetFrames||[],this.limitBroadcastToFramesArray=Boolean(e.targetFrames),this.isDestroyed=!1,this.listeners=[],this.hasAdditionalChecksForOnListeners=Boolean(this.verifyDomain||this.limitBroadcastToFramesArray)}return i.setPromise=function(e){i.Promise=e},i.target=function(e){return new i(e)},i.prototype.addTargetFrame=function(e){this.limitBroadcastToFramesArray&&this.targetFrames.push(e)},i.prototype.include=function(t){return null!=t&&(null!=t.Window&&(t.constructor===t.Window&&(e.childWindows.push(t),!0)))},i.prototype.target=function(e){return i.target(e)},i.prototype.emit=function(t,i,n){if(this.isDestroyed)return!1;var o=this.origin;if(t=this.namespaceEvent(t),(0,e.isntString)(t))return!1;if((0,e.isntString)(o))return!1;"function"==typeof i&&(n=i,i=void 0);var s=(0,e.packagePayload)(t,o,i,n);return!!s&&(this.limitBroadcastToFramesArray?this.targetFramesAsWindows().forEach((function(t){(0,e.sendMessage)(t,s,o)})):(0,e.broadcast)(s,{origin:o,frame:window.top||window.self}),!0)},i.prototype.emitAsPromise=function(e,t){var n=this;return new i.Promise((function(i,o){n.emit(e,t,(function(e){i(e)}))||o(new Error('Listener not added for "'.concat(e,'"')))}))},i.prototype.on=function(t,i){if(this.isDestroyed)return!1;var n=this,o=this.origin,s=i;return t=this.namespaceEvent(t),!(0,e.subscriptionArgsInvalid)(t,s,o)&&(this.hasAdditionalChecksForOnListeners&&(s=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];n.passesVerifyDomainCheck(this&&this.origin)&&n.hasMatchingTargetFrame(this&&this.source)&&i.apply(void 0,e)}),this.listeners.push({eventName:t,handler:s,originalHandler:i}),e.subscribers[o]=e.subscribers[o]||{},e.subscribers[o][t]=e.subscribers[o][t]||[],e.subscribers[o][t].push(s),!0)},i.prototype.off=function(t,i){var n=i;if(this.isDestroyed)return!1;if(this.verifyDomain)for(var o=0;o<this.listeners.length;o++){var s=this.listeners[o];s.originalHandler===i&&(n=s.handler)}t=this.namespaceEvent(t);var r=this.origin;if((0,e.subscriptionArgsInvalid)(t,n,r))return!1;var a=e.subscribers[r]&&e.subscribers[r][t];if(!a)return!1;for(o=0;o<a.length;o++)if(a[o]===n)return a.splice(o,1),!0;return!1},i.prototype.teardown=function(){if(!this.isDestroyed){this.isDestroyed=!0;for(var e=0;e<this.listeners.length;e++){var t=this.listeners[e];this.off(t.eventName,t.handler)}this.listeners.length=0}},i.prototype.passesVerifyDomainCheck=function(e){return!this.verifyDomain||this.checkOrigin(e)},i.prototype.targetFramesAsWindows=function(){return this.limitBroadcastToFramesArray?this.targetFrames.map((function(e){return e instanceof HTMLIFrameElement?e.contentWindow:e})).filter((function(e){return e})):[]},i.prototype.hasMatchingTargetFrame=function(e){if(!this.limitBroadcastToFramesArray)return!0;var t=this.targetFramesAsWindows().find((function(t){return t===e}));return Boolean(t)},i.prototype.checkOrigin=function(e){var t,i=document.createElement("a");return i.href=location.href,t="https:"===i.protocol?i.host.replace(/:443$/,""):"http:"===i.protocol?i.host.replace(/:80$/,""):i.host,i.protocol+"//"+t===e||(!this.verifyDomain||this.verifyDomain(e))},i.prototype.namespaceEvent=function(e){return this.channel?"".concat(this.channel,":").concat(e):e},i.Promise=t,i}();return O.Framebus=i,O}var L,R=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))};var g,S={};var C={};Object.defineProperty(C,"__esModule",{value:!0});var D,P,b={};function M(){return P||(P=1,e=s,i=t&&t.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),n=t&&t.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)},Object.defineProperty(e,"__esModule",{value:!0}),n(function(){if(o)return r;o=1,Object.defineProperty(r,"__esModule",{value:!0}),r.detach=r.attach=void 0;var e=M(),t=!1;return r.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},r.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},r}(),e),n(function(){if(a)return l;a=1,Object.defineProperty(l,"__esModule",{value:!0}),l.broadcastToChildWindows=void 0;var e=M();return l.broadcastToChildWindows=function(t,i,n){for(var o=e.childWindows.length-1;o>=0;o--){var s=e.childWindows[o];s.closed?e.childWindows.splice(o,1):n!==s&&(0,e.broadcast)(t,{origin:i,frame:s.top})}},l}(),e),n(function(){if(d)return c;d=1,Object.defineProperty(c,"__esModule",{value:!0}),c.broadcast=void 0;var e=M();return c.broadcast=function t(i,n){var o,s=0,r=n.origin,a=n.frame;try{for(a.postMessage(i,r),(0,e.hasOpener)(a)&&a.opener.top!==window.top&&t(i,{origin:r,frame:a.opener.top});o=a.frames[s];)t(i,{origin:r,frame:o}),s++}catch(e){}},c}(),e),n(u,e),n(function(){if(E)return _;E=1,Object.defineProperty(_,"__esModule",{value:!0}),_.dispatch=void 0;var e=M();return _.dispatch=function(t,i,n,o,s){if(e.subscribers[t]&&e.subscribers[t][i]){var r=[];n&&r.push(n),o&&r.push(o);for(var a=0;a<e.subscribers[t][i].length;a++)e.subscribers[t][i][a].apply(s,r)}},_}(),e),n(h,e),n(I,e),n(function(){if(p)return f;p=1,Object.defineProperty(f,"__esModule",{value:!0}),f.onMessage=void 0;var e=M();return f.onMessage=function(t){if(!(0,e.isntString)(t.data)){var i=(0,e.unpackPayload)(t);if(i){var n=i.eventData,o=i.reply;(0,e.dispatch)("*",i.event,n,o,t),(0,e.dispatch)(t.origin,i.event,n,o,t),(0,e.broadcastToChildWindows)(t.data,i.origin,t.source)}}},f}(),e),n(function(){if(v)return m;v=1,Object.defineProperty(m,"__esModule",{value:!0}),m.packagePayload=void 0;var e=M();return m.packagePayload=function(t,i,n,o){var s,r={event:t,origin:i};"function"==typeof o&&(r.reply=(0,e.subscribeReplier)(o,i)),r.eventData=n;try{s=e.prefix+JSON.stringify(r)}catch(e){throw new Error("Could not stringify event: ".concat(e.message))}return s},m}(),e),n(N,e),n(function(){if(L)return y;L=1;var e=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(y,"__esModule",{value:!0}),y.subscribeReplier=void 0;var i=A(),n=e(R);return y.subscribeReplier=function(e,t){var o=(0,n.default)();return i.Framebus.target({origin:t}).on(o,(function n(s,r){e(s,r),i.Framebus.target({origin:t}).off(o,n)})),o},y}(),e),n(function(){if(g)return S;g=1,Object.defineProperty(S,"__esModule",{value:!0}),S.subscriptionArgsInvalid=void 0;var e=M();return S.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},S}(),e),n(C,e),n(function(){if(D)return b;D=1,Object.defineProperty(b,"__esModule",{value:!0}),b.unpackPayload=void 0;var e=M();return b.unpackPayload=function(t){var i;if(t.data.slice(0,e.prefix.length)!==e.prefix)return!1;try{i=JSON.parse(t.data.slice(e.prefix.length))}catch(e){return!1}if(i.reply){var n=t.origin,o=t.source,s=i.reply;i.reply=function(t){if(o){var i=(0,e.packagePayload)(s,n,t);i&&o.postMessage(i,n)}}}return i},b}(),e)),s;var e,i,n}var w=M(),U=A();(0,w.attach)();const k=i(U.Framebus);class x{constructor(e){this.origin=null,this.listeners=[],this.bus=new k(e)}static getInstance(){return x.instance||(x.instance=new x),x.instance}on(e,t){return this.bus.on(e,t)}off(e,t){return this.bus.off(e,t)}emit(e,t,i=void 0){return this.bus.emit(e,t,i)}target(e){return this.bus.target(e)}}e.IframeEventBus=x,e.getEventBus=()=>x.getInstance()}(x);const Y={INITIALIZE_CLIENT:"%s1 - Initializing skyflow client.",CLIENT_INITIALIZED:"%s1 - Initialized skyflow client successfully.",CREATE_COLLECT_CONTAINER:"%s1 - Creating Collect container.",COLLECT_CONTAINER_CREATED:"%s1 - Created Collect container successfully.",VALIDATE_RECORDS:"%s1 - Validating insert records.",VALIDATE_DETOKENIZE_INPUT:"%s1 - Validating detokenize input.",VALIDATE_GET_INPUT:"%s1 - Validating get input.",VALIDATE_DELETE_INPUT:"%s1 - Validating delete input.",VALIDATE_COLLECT_RECORDS:"%s1 - Validating collect element input.",CREATED_ELEMENT:"%s1 - Created %s2 element.",ELEMENT_MOUNTED:"%s1 - %s2 Element mounted.",COLLECT_SUBMIT_SUCCESS:"%s1 - Data has been collected successfully.",INSERT_DATA_SUCCESS:"%s1 - Data has been inserted successfully.",DELETE_SUCCESS:"%s1 - Data has been deleted successfully.",BEARER_TOKEN_LISTENER:"%s1 - Get bearer token listener added.",CAPTURED_BEARER_TOKEN_EVENT:"%s1 - Captured bearer token event.",BEARER_TOKEN_RESOLVED:"%s1 - GetBearerToken promise resolved successfully.",REUSE_BEARER_TOKEN:"%s1 - Reusing the bearer token.",PUREJS_CONTROLLER_INITIALIZED:"%s1 - SkyflowController initialized.",PUREJS_LISTENER_READY:"%s1 - Purejs listener ready.",EMIT_PURE_JS_CONTROLLER:"%s1 - Emitted Skyflow controller event.",INSERT_TRIGGERED:"%s1 - Insert method triggered.",DETOKENIZE_TRIGGERED:"%s1 - Detokenize method triggered.",GET_TRIGGERED:"%s1 - Get method triggered.",GET_BY_ID_TRIGGERED:"%s1 - Get method triggered.",DELETE_TRIGGERED:"%s1 - Delete method triggered.",EMIT_PURE_JS_REQUEST:"%s1 - Emitted %s2 request.",CAPTURE_PURE_JS_REQUEST:"%s1 - Captured %s2 event.",LISTEN_PURE_JS_REQUEST:"%s1 - Listening to %s2 event.",CAPTURE_PUREJS_FRAME:"%s1 - Captured SkyflowController frame ready event.",FETCH_RECORDS_RESOLVED:"%s1 - Detokenize request is resolved.",INSERT_RECORDS_RESOLVED:"%s1 - Insert request is resolved.",GET_RESOLVED:"%s1 - Get request is resolved.",GET_BY_SKYFLOWID_RESOLVED:"%s1 - GetById request is resolved.",DELETE_RESOLVED:"%s1 - Delete request is resolved",EMIT_EVENT:"%s1 - %s2 event emitted",CAPTURE_EVENT:"%s1 - Captured event %s2",LISTEN_COLLECT_FRAME_READY:"%s1 - Listening to collect FRAME_READY event",EMIT_COLLECT_ELEMENT_FRAME_READY:"%s1 - Emitting collect element %s2 FRAME_READY event",ENTERED_COLLECT_FRAME_READY_CB:"%s1 - In IFrameForm constructor, Entered FRAME_READY callback",EXECUTE_COLLECT_ELEMENT_FRAME_READY_CB:"%s1 - In IFrameForm, executing collect element, %s2 FRAME_READY callback",CLIENT_METADATA_NOT_SET:"%s1 - Client metadata not set",EXECUTE_COLLECT_ELEMENT_INIT:"%s1 - calling Collect element init",INSIDE__COLLECT_ELEMENT_INIT:"%s1 - Inside Collect element init for %s2",CREATING_COLLECT_ELEMENT_FORM:"%s1 - Start, creating iframe form for %s2",COLLECT_FRAME_READY_CB:"%s1 - In FrameElements, executing collect element FRAME_READY cb for %s2, sending metadata",INSIDE_FRAME_ELEMENTS_CONSTRUCOTR:"%s1 - Inside FrameElements constructor",SETUP_IN_START:"%s1 - Inside FrameElements start(), calling setup",SETUP_IN_CONSTRUCTOR:"%s1 - Inside FrameElements constructor, calling setup",COLLECT_ELEMET_START:"%s1 - %s2, Collect Element start",COLLECT_CONTROLLER_START:"%s1 - %s2, Collect Controller start",EMIT_COLLECT_FRAME_CONTROLLER_EVENT:"%s1 - Emit collect FrameController FRAME_READY event",EXECUTE_COLLECT_CONTROLLER_READY_CB:"%s1 - Executing collect FrameController FRAME_READY callback, set client metadata",IFRAMEFORM_CONSTRUCTOR_FRAME_READY_LISTNER:"%s1 - In IFrameForm constructor, Adding listner for FRAME_READY event",IFRAMEFORM_CONSTRUCTOR_TOKENIZATION_LISTNER:"%s1 - In IFrameForm constructor, Adding listner for TOKENIZATION_REQUEST event",CURRENT_ENV:"%s1 - Client Env is %s2",CURRENT_LOG_LEVEL:"%s1 - Client LogLevel is %s2",VALIDATE_GET_BY_ID_INPUT:"%s1 - Validating getByID input."},F={CLIENT_CONNECTION:"Interface: collect container - client connection not established. client info has not reached iframes",INVALID_BEARER_TOKEN:"Interface: init - Invalid token is generated from getBearerToken callback",BEARER_TOKEN_REJECTED:"Interface: init - GetBearerToken promise got rejected.",VAULTID_IS_REQUIRED:"Interface: init - Invalid client credentials. vaultID is required.",EMPTY_VAULTID_IN_INIT:"Interface: init - Invalid client credentials. vaultID cannot be empty.",VAULTURL_IS_REQUIRED:"Interface: init - Invalid client credentials. vaultURL is required.",EMPTY_VAULTURL_IN_INIT:"Interface: init - Invalid client credentials. vaultURL cannot be empty.",INVALID_VAULTURL_IN_INIT:"Interface: init - Invalid client credentials. Expecting https://XYZ for vaultURL",GET_BEARER_TOKEN_IS_REQUIRED:"Interface: init - Invalid client credentials. getBearerToken is required.",EMPTY_CONTAINER_TYPE:"Interface: client {containerType} container - Invalid container type. Container object cannot be empty.",INVALID_CONTAINER_TYPE:"Interface: client {containerType} container - Invalid container type. Invalid container object.",INVALID_COLLECT_VALUE:"Invalid value",INVALID_COLLECT_VALUE_WITH_LABEL:"Invalid %s1",REQUIRED_COLLECT_VALUE:"%s1 is required",DEFAULT_REQUIRED_COLLECT_VALUE:"Field is required",RECORDS_KEY_NOT_FOUND:"Interface: client insert - records object is required.",INVALID_RECORDS_IN_INSERT:"Interface: client insert - Invalid records. records object should be an array.",EMPTY_RECORDS_IN_INSERT:"Interface: client insert - records array cannot be empty.",MISSING_TABLE_IN_INSERT:'Interface: client insert - "table" key is required in records array at index %s1',EMPTY_TABLE_IN_INSERT:"Interface: client insert - table cannot be empty in records array at index %s1",INVALID_TABLE_IN_INSERT:"Interface: client insert - table of type string is required at index %s1 in records array.",EMPTY_FIELDS_IN_INSERT:"Interface: client insert - fields cannot be empty in records array at index %s1",MISSING_FIELDS_IN_INSERT:'Interface: client insert - "fields" key is required in records array at index %s1',INVALID_FIELDS_IN_INSERT:"Interface: client insert - fields of type object is required at index %s1 in records array.",INVALID_TOKENS_IN_INSERT:"Interface: client insert - Invalid tokens in options. tokens of type boolean is required.",RECORDS_KEY_NOT_FOUND_DELETE:"Interface: client delete - records object is required.",INVALID_RECORDS_IN_DELETE:"Interface: client delete - Invalid records. records object should be an array.",EMPTY_RECORDS_IN_DELETE:"Interface: client delete - records array cannot be empty.",MISSING_TABLE_IN_DELETE:'Interface: client delete - "table" key is required in records array at index %s1',EMPTY_TABLE_IN_DELETE:"Interface: client delete - table cannot be empty in records array at index %s1",INVALID_TABLE_IN_DELETE:"Interface: client delete - table of type string is required at index %s1 in records array.",MISSING_ID_IN_DELETE:'Interface: client delete - "id" key is required in records array at index %s1',EMPTY_ID_IN_DELETE:"Interface: client delete - id cannot be empty in records array at index %s1",INVALID_ID_IN_DELETE:"Interface: client delete - id of type string is required at index %s1 in records array.",DELETE_RECORDS_REJECTED:"Interface: client delete - delete request is rejected.",INVALID_TOKENS_IN_COLLECT:"Interface: collect container - Invalid tokens. tokens of type boolean is required.",RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS:'Interface: collect container - "records" key not found in additionalFields',INVALID_RECORDS_IN_ADDITIONAL_FIELDS:"Interface: collect container - records should be an array inside additionalFields",EMPTY_RECORDS_IN_ADDITIONAL_FIELDS:"Interface: collect container - records object cannot be empty in additionalFields",MISSING_TABLE_IN_ADDITIONAL_FIELDS:'Interface: collect container - "table" key not found in additionalFields records at index %s1',INVALID_TABLE_IN_ADDITIONAL_FIELDS:"Interface: collect container - Provide valid table name in additionalFields records at index %s1",INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:"Interface: collect container - Provide valid skyflow id in additionalFields records at index %s1",MISSING_FIELDS_IN_ADDITIONAL_FIELDS:'Interface: collect container - "fields" key not found in additionalFields records at index %s1',INVALID_FIELDS_IN_ADDITIONAL_FIELDS:"Interface: collect container - Provide valid fields in additionalFields records at index %s1",RECORDS_KEY_NOT_FOUND_DETOKENIZE:"Interface: client detokenize - records object is required.",EMPTY_RECORDS_DETOKENIZE:"Interface: client detokenize - records array cannot be empty.",INVALID_RECORDS_IN_DETOKENIZE:"Interface: client detokenize - Invalid records. records object should be an array.",MISSING_TOKEN_IN_DETOKENIZE:'Interface: client detokenize - "token" key is required in records array at index %s1 ',INVALID_TOKEN_IN_DETOKENIZE:"Interface: client detokenize - Invalid token. token of type string is required at index %s1 in records array.",RECORDS_KEY_NOT_FOUND_GET:"Interface: client get - records object is required.",INVALID_RECORDS_IN_GET:"Interface: client get - Invalid records. records object should be an array.",EMPTY_RECORDS_GET:"Interface: client get - records array cannot be empty.",MISSING_IDS_IN_GET:'Interface: client get - "ids" key is required in records array at index %s1',INVALID_IDS_IN_GET:"Interface: client get - Invalid ids. ids object should be an array.",INVALID_COLUMN_VALUES_IN_GET:"Interface: client get - Invalid column values. column values object should be an array.",EMPTY_IDS_IN_GET:"Interface: client get - ids array cannot be empty at index %s1",INVALID_SKYFLOWID_TYPE_IN_GET:"Interface: client get - Invalid skyflowId in ids array at index %s1",MISSING_TABLE_IN_GET:'Interface: client get - "table" key is required in records array at index %s1',INVALID_TABLE_IN_GET:"Interface: client get - table of type string is required at index %s1 in records array.",MISSING_REDACTION_IN_GET:'Interface: client get - "redaction" key is required in records array at index %s1',INVALID_REDACTION_TYPE_IN_GET:"Interface: client get - Invalid redaction type in records array at index %s1",INVALID_TOKENS_IN_GET:"Interface: client get - Invalid tokens in options. tokens of type boolean is required.",TOKENS_GET_COLUMN_NOT_SUPPORTED:"Interface: client get - column_name or column_values cannot be used with tokens in options.",REDACTION_WITH_TOKENS_NOT_SUPPORTED:"Interface: client get - redaction cannot be used when tokens are true in options.",INVALID_REDACTION_TYPE_IN_DETOKENIZE:"Interface: client get - Invalid redaction type in records array at index %s1",EMPTY_TABLE_IN_ADDITIONAL_FIELDS:"Interface: collect container - table cannot be empty in additionalFields at index %s1",EMPTY_FIELDS_IN_ADDITIONAL_FIELDS:"Interface: collect container - fields cannot be empty in additionalFields at index %s1",EMPTY_TOKEN_IN_DETOKENIZE:"Interface: client detokenize - token cannot be empty in records array at index %s1",EMPTY_SKYFLOWID_IN_GET:"Interface: client get - id cannot be empty in records array at index %s1",EMPTY_TABLE_IN_GET:"Interface: client get - table cannot be empty in records array at index %s1",EMPTY_REDACTION_TYPE_IN_GET:"Interface: client get - redaction cannot be empty in records array at index %s1",FETCH_RECORDS_REJECTED:"Interface: client detokenize - detokenize request is rejected.",INSERT_RECORDS_REJECTED:"Interface: client insert - insert request is rejected.",GET_REJECTED:"Interface: client get - get request is rejected.",MISSING_TABLE_IN_COLLECT:'Interface: collect element - "table" key is required.',EMPTY_TABLE_IN_COLLECT:"Interface: collect element - table cannot be empty.",EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:"Interface: collect element - id cannot be empty.",INVALID_TABLE_IN_COLLECT:"Interface: collect element - Invalid table. table of type string is required",INVALID_SKYFLOWID_IN_COLLECT:"Interface: collect element - Invalid id. id of type string is required",MISSING_COLUMN_IN_COLLECT:'Interface: collect element - "column" key is required.',EMPTY_COLUMN_IN_COLLECT:"Interface: collect element - column cannot be empty.",INVALID_COLUMN_IN_COLLECT:"Interface: collect element - Invalid column. column of type string is required",UNIQUE_ELEMENT_NAME:"The element name has to unique: %s1",ELEMENTS_NOT_MOUNTED:"Interface: collect container - Elements should be mounted before invoking collect",DUPLICATE_ELEMENT:"Interface: collect container - Duplicate column %s1 found in %s2.",DUPLICATE_ELEMENT_ADDITIONAL_FIELDS:"Interface: collect container - Duplicate column %s1 found in %s2 in additional fields",MISSING_ELEMENT_TYPE:'Interface:container element with type {TYPE} - Invalid element type. "type" key is required.',EMPTY_ELEMENT_TYPE:"Interface:container element with type {TYPE} - Invalid element type. type cannot be empty.",INVALID_ELEMENT_TYPE:"Interface:container element with type {TYPE} - invalid element type. type not found",INVALID_ELEMENT_SELECTOR:"Interface: container element with type {TYPE} - Div cannot be found.",CANNOT_CHANGE_ELEMENT:"Element can't be changed.",INVALID_IFRAME:"Error occured while creating an iframe",INVALID_FIELD:"Invalid Field.",FRAME_NOT_FOUND:"Interface: collect element - %s1 frame not found:",COMPLETE_AND_VALID_INPUTS:"Interface: collect container - Provide complete and valid inputs for %s1",REQUIRED_PARAMS_NOT_PROVIDED:"Interface: collect element - Required params are not provided.",INVALID_EVENT_TYPE:"Interface: collect element - Provide a valid event type.",INVALID_EVENT_LISTENER:'Interface: "on" on CollectElement - Provide valid event listener.',MISSING_HANDLER_IN_EVENT_LISTENER:'Interface: "on" on CollectElement - Second argument is missing. handler cannot be empty.',INVALID_HANDLER_IN_EVENT_LISTENER:'Interface: "on" on CollectElement - Invalid handler. handler should be of type function.',UNKNOWN_ERROR:"Unknown Error.",NETWORK_ERROR:"A network error occurred. This could be a CORS issue or a dropped internet connection. It is not possible for us to know. Please reach out to skyflow if you see this error",CONNECTION_ERROR:"Error while initializing the connection.",ERROR_OCCURED:"Error occurred.",INVALID_VALIDATIONS_TYPE:"Interface: collect element - Invalid validations type.",MISSING_VALIDATION_RULE_TYPE:"Interface: collect element - Type is missing in validationRule at index %s1 in validations array",INVALID_VALIDATION_RULE_TYPE:"Interface: collect element - Invalid ValidationRuleType at index %s1 in validations array",MISSING_VALIDATION_RULE_PARAMS:"Interface: collect element - params are missing in validationRule at index %s1 in validations array",INVALID_VALIDATION_RULE_PARAMS:"Interface: collect element - Invalid ValidationRule params at index %s1 in validations array",MISSING_REGEX_IN_REGEX_MATCH_RULE:"Interface: collect element - Missing regex in ValidationRule params at index %s1 in validations array",INVALID_REGEX_IN_REGEX_MATCH_RULE:"Interface: collect element - Invalid regex in ValidationRule params at index %s1 in validations array",MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE:"Interface: collect element - Either min or max is required in ValidationRule params at index %s1 in validations array",MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE:"Interface: collect element - Missing element in ValidationRule params at index %s1 in validations array",INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE:"Interface: collect element - Invalid collect element in ValidationRule params at index %s1 in validations array",ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE:"Interface: collect element - collect element is not mounted in ValidationRule params at index %s1 in validations array",EMPTY_ELEMENT_IN_MOUNT:"Interface: mount element with type %s1 - Mount cannot be empty.",VALIDATION_FAILED:"Validation failed",INVALID_UPSERT_OPTION_TYPE:"Invalid upsert option, should be an array",EMPTY_UPSERT_OPTIONS_ARRAY:"upsert option cannot be an empty array, atleast one object of table and column is required.",INVALID_UPSERT_OPTION_OBJECT_TYPE:"Invalid upsert object at index %s1, an object of table and column is required.",MISSING_TABLE_IN_UPSERT_OPTION:'"table" key is required in upsert options object at index %s1',MISSING_COLUMN_IN_UPSERT_OPTION:'"column" key is required in upsert option at index %s1',INVALID_TABLE_IN_UPSERT_OPTION:"Invalid table in upsert object at index %s1, table of type non empty string is required",INVALID_COLUMN_IN_UPSERT_OPTION:"Invalid column in upsert object at index %s1, column of type non empty string is required",INVALID_RECORD_COLUMN_VALUE:"Invalid Record Column value.",MISSING_RECORD_COLUMN_VALUE:"Column Values is required when Column Name is specified.",MISSING_RECORD_COLUMN_NAME:"Column Name is required when Column Values are specified.",INVALID_RECORD_COLUMN_VALUE_TYPE:"Invalid Type of Records Column Values.",INVALID_COLUMN_VALUES_TYPE:"Invalid column values type, should be an Array.",EMPTY_RECORD_COLUMN_VALUES:"Record column values cannot be empty.",EMPTY_COLUMN_VALUE:"Column Value is empty.",MISSING_IDS_OR_COLUMN_VALUES_IN_GET:'Interface: client get - "ids" key or "columnValues" key is missing.',SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED:"ids and columnName can not be specified together.",GET_BY_SKYFLOWID_RESOLVED:"%s1 - GetById request is resolved.",RECORDS_KEY_NOT_FOUND_GETBYID:"Interface: client getById - records object is required.",INVALID_RECORDS_IN_GETBYID:"Interface: client getById - Invalid records. records object should be an array.",EMPTY_RECORDS_GETBYID:"Interface: client getById - records array cannot be empty.",MISSING_IDS_IN_GETBYID:'Interface: client getById - "ids" key is required in records array at index %s1',INVALID_IDS_IN_GETBYID:"Interface: client getById - Invalid ids. ids object should be an array.",EMPTY_IDS_IN_GETBYID:"Interface: client getById - ids array cannot be empty at index %s1",INVALID_SKYFLOWID_TYPE_IN_GETBYID:"Interface: client getById - Invalid skyflowId in ids array at index %s1",MISSING_TABLE_IN_GETBYID:'Interface: client getById - "table" key is required in records array at index %s1',INVALID_TABLE_IN_GETBYID:"Interface: client getById - table of type string is required at index %s1 in records array.",MISSING_REDACTION_IN_GETBYID:'Interface: client getById - "redaction" key is required in records array at index %s1',INVALID_REDACTION_TYPE_IN_GETBYID:"Interface: client getById - Invalid redaction type in records array at index %s1",EMPTY_SKYFLOWID_IN_GETBYID:"Interface: client getById - id cannot be empty in records array at index %s1",EMPTY_TABLE_IN_GETBYID:"Interface: client getById - table cannot be empty in records array at index %s1",EMPTY_REDACTION_TYPE_IN_GETBYID:"Interface: client getById - redaction cannot be empty in records array at index %s1",GET_BY_SKYFLOWID_REJECTED:"Interface: client getById - getById request is rejected.",MISSING_COMPOSABLE_LAYOUT_KEY:"Interface: client container - layout is required in composable container options.",EMPTY_COMPOSABLE_LAYOUT_ARRAY:"Interface: client container - layout array cannot be empty in composable container options.",INVALID_COMPOSABLE_LAYOUT_TYPE:"Interface: client container - invalid layout value, layout should be of type array of numbers in composable container options.",NEGATIVE_VALUES_COMPOSABLE_LAYOUT:"Interface: client container - layout array should only have postive numbers in composable container options.",MISMATCH_ELEMENT_COUNT_LAYOUT_SUM:"Interface: composable container mount - created elements count should be equal to sum of layout values.",MISSING_COMPOSABLE_CONTAINER_OPTIONS:"Interface: client composable container - options object is required for composable container.",INVALID_COMPOSABLE_CONTAINER_OPTIONS:"Interface: client composable container - invalid options value, should be an object type.",COMPOSABLE_CONTAINER_NOT_MOUNTED:"Interface: composable collect - container should be mounted before invoking collect.",INVALID_BOOLEAN_OPTIONS:"Interface: container create - Invaild %s1 in options, %s1 of type boolean is required.",INVALID_INPUT_OPTIONS_FORMAT:"Interface: container create - Invalid type, format must be of non-empty string type.",INVALID_INPUT_OPTIONS_TRANSLATION:"Interface: container create - Invalid type, translation must be of non-empty object type.",EMPTY_COLLECT_CUSTOM_FORMAT:"Interface: container create - %s1 cannot be empty object."},V={INVALID_EXPIRATION_DATE_FORMAT:"EXPIRATION_DATE format must be in one of %s1, the format is set to default MM/YY",INVALID_EXPIRATION_YEAR_FORMAT:"EXPIRATION_YEAR format must be in one of %s1, the format is set to default YY",UNABLE_TO_SET_VALUE_IN_PROD_ENV:"%s1 setValue() cannot invoked while in PROD env. It is Not Recommeded",UNABLE_TO_CLEAR_VALUE_IN_PROD_ENV:"%s1 clearValue() cannot invoked while in PROD env. It is Not Recommeded",COLLECT_ALT_TEXT_DEPERECATED:"altText is DEPERECATED, passing altText will not have any effect",GET_BY_ID_DEPRECATED:"getById is deprecated, use new get method",INPUT_FORMATTING_NOT_SUPPROTED:"format or translation are not supported on %s1 element type.",INVALID_INPUT_TRANSLATION:"invalid or unsupported translation provided for %s1 element type."},B="collect_controller",G="element",j={CHANGE:"CHANGE",READY:"READY",FOCUS:"FOCUS",BLUR:"BLUR",ESCAPE:"ESCAPE",CLICK:"CLICK",ERROR:"ERROR",SUCCESS:"SUCCESS",SUBMIT:"SUBMIT",CREATED:"CREATED",MOUNTED:"MOUNTED",HEIGHT:"HEIGHT"},X="FRAME_READY",H="TOKENIZATION_REQUEST",W="INPUT_EVENT",z="DESTROY FRAME",K="SET_VALUE",$="GET_BEARER_TOKEN",q="COLLECT_ELEMENT_SET_ERROR",J="COMPOSABLE_UPDATE_OPTIONS",Z="COMPOSABLE_CONTAINER_MOUNTED",Q="COLLECT_CONTAINER_MOUNTED";var ee,te;!function(e){e.CVV="CVV",e.EXPIRATION_DATE="EXPIRATION_DATE",e.CARD_NUMBER="CARD_NUMBER",e.CARDHOLDER_NAME="CARDHOLDER_NAME",e.INPUT_FIELD="INPUT_FIELD",e.PIN="PIN",e.EXPIRATION_MONTH="EXPIRATION_MONTH",e.EXPIRATION_YEAR="EXPIRATION_YEAR"}(ee||(ee={})),function(e){e.VISA="VISA",e.MASTERCARD="MASTERCARD",e.AMEX="AMEX",e.DINERS_CLUB="DINERS_CLUB",e.DISCOVER="DISCOVER",e.JCB="JCB",e.MAESTRO="MAESTRO",e.UNIONPAY="UNIONPAY",e.HIPERCARD="HIPERCARD",e.DEFAULT="DEFAULT",e.UNKNOWN="UNKNOWN"}(te||(te={}));const ie={[te.AMEX]:["XXXX XXXXXX XXXXX",{X:"[0-9]"}],[te.VISA]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[te.MASTERCARD]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[te.DISCOVER]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[te.DINERS_CLUB]:["XXXX XXXXXX XXXXXX",{X:"[0-9]"}],[te.JCB]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[te.MAESTRO]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[te.UNIONPAY]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[te.HIPERCARD]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[te.DEFAULT]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[te.UNKNOWN]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}]},ne={textarea:{name:"textarea",attributes:{type:"textarea"},sensitive:!1},checkbox:{name:"checkbox",attributes:{type:"checkbox"},sensitive:!1},radio:{name:"radio",attributes:{type:"radio"},sensitive:!1},dropdown:{name:"dropdown",attributes:{type:"select"},sensitive:!1},[ee.CARDHOLDER_NAME]:{name:"cardHolderName",attributes:{type:"text",autocomplete:"cc-name"},sensitive:!0,regex:/^([a-zA-Z\\ \\,\\.\\-\\']{2,})$/},[ee.CARD_NUMBER]:{name:"CARD_NUMBER",attributes:{type:"text",autocomplete:"cc-number",inputmode:"numeric"},sensitive:!0,mask:ie[te.DEFAULT],regex:/$|^[\s]*?([0-9]{2,6}[ -]?){3,5}[\s]*/},[ee.EXPIRATION_DATE]:{name:"EXPIRATION_DATE",attributes:{type:"text",autocomplete:"cc-exp",inputmode:"numeric"},sensitive:!0},[ee.EXPIRATION_MONTH]:{name:"EXPIRATION_MONTH",attributes:{maxLength:2,type:"text",inputmode:"numeric",autocomplete:"cc-exp-month"},sensitive:!0,mask:["XX",{X:"[0-9]"}]},[ee.EXPIRATION_YEAR]:{name:"EXPIRATION_YEAR",attributes:{type:"text",inputmode:"numeric",autocomplete:"cc-exp-year"},sensitive:!0},[ee.CVV]:{name:"CVV",attributes:{type:"text",inputmode:"numeric",maxLength:4},sensitive:!0,regex:/^$|^[0-9]{3,4}$/},[ee.INPUT_FIELD]:{name:"INPUT_FIELD",sensitive:!0,attributes:{type:"text"}},[ee.PIN]:{name:"PIN",attributes:{type:"text",inputmode:"numeric",maxLength:12,minLength:4},sensitive:!0,regex:/^$|^[0-9]{4,12}$/}},oe="XXXX-XXXX-XXXX-XXXX",se={height:"100%",width:"100%",margin:0,padding:0,border:0,position:"absolute",top:0,left:0,"user-select":"none"},re={position:"absolute",top:0,width:0,height:0,visibility:"hidden",left:"-99999999px","user-select":"none"},ae={width:"100%",height:"100%",border:"0",padding:"0",margin:"0",outline:"none"},le={WEBPACKAUTOFILL:"-webkit-autofill",BASE:"base",FOCUS:"focus",COMPLETE:"complete",EMPTY:"empty",INVALID:"invalid",GLOBAL:"global",REQUIRED_ASTERISK:"requiredAsterisk"};le.BASE,le.REQUIRED_ASTERISK;const de={[te.VISA]:{regex:/^4\d*/,maxCardLength:19,cardLengthRange:[13,16]},[te.MASTERCARD]:{regex:/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720)\d*/,maxCardLength:16,cardLengthRange:[16]},[te.AMEX]:{regex:/^3[47]\d*/,maxCardLength:15,cardLengthRange:[15]},[te.DINERS_CLUB]:{regex:/^(36|38|30[0-5])\d*/,maxCardLength:16,cardLengthRange:[14,15,16,17,18,19]},[te.DISCOVER]:{regex:/^(6011|65|64[4-9]|622)\d*/,maxCardLength:16,cardLengthRange:[16,17,18,19]},[te.JCB]:{regex:/^35\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[te.HIPERCARD]:{regex:/^606282\d*/,maxCardLength:19,cardLengthRange:[14,15,16,17,18,19]},[te.UNIONPAY]:{regex:/^62\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[te.MAESTRO]:{regex:/^(5018|5020|5038|5043|5[6-9]|6020|6304|6703|6759|676[1-3])\d*/,maxCardLength:19,cardLengthRange:[12,13,14,15,16,17,18,19]}};te.DEFAULT,te.AMEX,te.DINERS_CLUB,te.DISCOVER,te.HIPERCARD,te.JCB,te.MAESTRO,te.MASTERCARD,te.UNIONPAY,te.VISA;const ce="MM/YY",ue=[ce,"YYYY/MM","YY/MM","MM/YYYY"],Ee=["YY","YYYY"];var _e;!function(e){e.APPLICATIONORJSON="application/json",e.TEXTORPLAIN="text/plain",e.TEXTORXML="text/xml",e.FORMURLENCODED="application/x-www-form-urlencoded",e.FORMDATA="multipart/form-data"}(_e||(_e={})),ee.CARD_NUMBER,ee.EXPIRATION_DATE,ee.EXPIRATION_MONTH,ee.EXPIRATION_YEAR,ee.CVV,ee.EXPIRATION_DATE,ee.CARD_NUMBER,ee.CARDHOLDER_NAME,ee.INPUT_FIELD,F.INVALID_COLLECT_VALUE,ee.PIN,ee.EXPIRATION_MONTH,ee.EXPIRATION_YEAR,ee.CVV,ee.EXPIRATION_DATE,ee.CARD_NUMBER,ee.CARDHOLDER_NAME,ee.INPUT_FIELD,F.DEFAULT_REQUIRED_COLLECT_VALUE,ee.PIN,ee.EXPIRATION_MONTH,ee.EXPIRATION_YEAR;const he=[ee.CARDHOLDER_NAME,ee.EXPIRATION_MONTH,ee.PIN,ee.CVV],Ie={X:"[0-9]"};class pe{constructor(){this.events={}}on(e,t,i=!1){this.events[e]?this.events[e].push({priority:i,callback:t}):this.events[e]=[{priority:i,callback:t}]}off(e,t){const i=this.events[e];if(!i)return;const n=i.findIndex((e=>e.callback===t));i.splice(n,1)}_emit(e,...t){const i=this.events[e];i&&i.forEach((e=>{e.callback(...t)}))}hasListener(e){const t=this.events[e];return!!t&&t.length>0}resetEvents(){const e={};Object.keys(this.events).forEach((t=>{const i=this.events[t];if(i&&i.length>0){const n=[];i.forEach((e=>{e.priority&&n.push(e)})),e[t]=n}})),this.events=e}static createChild(e){e.prototype=Object.create(pe.prototype,{constructor:e})}}
2
2
  /* @copyright
3
3
  Copyright (c) 2022 Skyflow, Inc.
4
- */const Ie={IFRAME_SECURE_SITE:"https://js.skyflow.com/v1/elements/index.html",IFRAME_SECURE_ORGIN:"https://js.skyflow.com"},pe="https://assets.payrails.io/0d7f8b3/card/index.html",fe="https://assets.payrails.io",ve={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no",style:"width: 100%;",allow:"clipboard-read; clipboard-write"},me=(e,t)=>{Object.keys(t).forEach((i=>{if(Object.prototype.hasOwnProperty.call(t,i)){const n=t[i];null==n?e.removeAttribute(i):e.setAttribute(i,n)}}))};var Ne=(e={})=>{const t=document.createElement("iframe"),i=Object.assign(Object.assign({},ve),e);return Object.assign(t.style,ne),me(t,i),t.getAttribute("id")||(t.id=t.name),t};const Te=()=>Ie.IFRAME_SECURE_SITE,ye=(e,t)=>{Object.keys(t).forEach((i=>{Object.prototype.hasOwnProperty.call(t,i)&&(e.style[i]=t[i])}))};function Oe(e){return JSON.parse(JSON.stringify(e))}var Ae,Le,ge,Re,Se,Ce,De;!function(e){e.DEFAULT="DEFAULT",e.PLAIN_TEXT="PLAIN_TEXT",e.MASKED="MASKED",e.REDACTED="REDACTED"}(Ae||(Ae={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.PATCH="PATCH",e.DELETE="DELETE"}(Le||(Le={})),function(e){e.CHANGE="CHANGE",e.READY="READY",e.FOCUS="FOCUS",e.BLUR="BLUR",e.SUBMIT="SUBMIT"}(ge||(ge={})),function(e){e.WARN="WARN",e.INFO="INFO",e.DEBUG="DEBUG",e.ERROR="ERROR"}(Re||(Re={})),function(e){e.DEV="DEV",e.PROD="PROD"}(Se||(Se={})),function(e){e.LOG="LOG",e.WARN="WARN",e.ERROR="ERROR"}(Ce||(Ce={})),function(e){e.REGEX_MATCH_RULE="REGEX_MATCH_RULE",e.LENGTH_MATCH_RULE="LENGTH_MATCH_RULE",e.ELEMENT_VALUE_MATCH_RULE="ELEMENT_VALUE_MATCH_RULE"}(De||(De={}));const be={DEBUG:{showDebugLogs:!0,showInfoLogs:!0,showWarnLogs:!0,showErrorLogs:!0},INFO:{showDebugLogs:!1,showInfoLogs:!0,showWarnLogs:!0,showErrorLogs:!0},WARN:{showDebugLogs:!1,showInfoLogs:!1,showWarnLogs:!0,showErrorLogs:!0},ERROR:{showDebugLogs:!1,showInfoLogs:!1,showWarnLogs:!1,showErrorLogs:!0}},Pe={PROD:{doesReturnValue:!1},DEV:{doesReturnValue:!0}},Me="[Skyflow]",we=(e,t,i)=>{if(i&&be[i]){const{showDebugLogs:n,showInfoLogs:s,showWarnLogs:o,showErrorLogs:r}=be[i];t===Ce.LOG&&n?console.log(`${Re.DEBUG}: ${Me} ${e}`):t===Ce.LOG&&s?console.log(`${Re.INFO}: ${Me} ${e}`):t===Ce.WARN&&o?console.warn(`${Re.WARN}: ${Me} ${e}`):t===Ce.ERROR&&r&&console.error(`${Re.ERROR}: ${Me} ${e}`)}},Ue=(...e)=>{const t=e[0],i=e.filter(((e,t)=>0!==t));return t?t.replace(/%s[0-9]+/g,(e=>{const t=e.replace("%s","")-1;return i[t]})):""},ke=(e="")=>{const t=e.split(":");if("group"===t[1])return"composable container";let i=atob(t[2]);return-1!==i.indexOf(":")&&(i=i.substring(0,i.indexOf(":"))),i};class xe extends Error{constructor(e,t,i=!1){const n={code:e.code,description:t&&(null==t?void 0:t.length)>0?Ue(e.description,...t):e.description};super(n.description),i?this.error=n:this.errors=[n]}}const Ye={INVALID_FIELD:{code:400,description:x.INVALID_FIELD},VAULTID_IS_REQUIRED:{code:400,description:x.VAULTID_IS_REQUIRED},EMPTY_VAULTID_IN_INIT:{code:400,description:x.EMPTY_VAULTID_IN_INIT},VAULTURL_IS_REQUIRED:{code:400,description:x.VAULTURL_IS_REQUIRED},EMPTY_VAULTURL_IN_INIT:{code:400,description:x.EMPTY_VAULTURL_IN_INIT},INVALID_VAULTURL_IN_INIT:{code:400,description:x.INVALID_VAULTURL_IN_INIT},GET_BEARER_TOKEN_IS_REQUIRED:{code:400,description:x.GET_BEARER_TOKEN_IS_REQUIRED},EMPTY_CONTAINER_TYPE:{code:400,description:x.EMPTY_CONTAINER_TYPE},INVALID_CONTAINER_TYPE:{code:400,description:x.INVALID_CONTAINER_TYPE},UNIQUE_ELEMENT_NAME:{code:400,description:x.UNIQUE_ELEMENT_NAME},ELEMENTS_NOT_MOUNTED:{code:400,description:x.ELEMENTS_NOT_MOUNTED},MISSING_TABLE_IN_COLLECT:{code:400,description:x.MISSING_TABLE_IN_COLLECT},EMPTY_TABLE_IN_COLLECT:{code:400,description:x.EMPTY_TABLE_IN_COLLECT},EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:{code:400,description:x.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS},INVALID_TABLE_IN_COLLECT:{code:400,description:x.INVALID_TABLE_IN_COLLECT},INVALID_SKYFLOWID_IN_COLLECT:{code:400,description:x.INVALID_SKYFLOWID_IN_COLLECT},MISSING_COLUMN_IN_COLLECT:{code:400,description:x.MISSING_COLUMN_IN_COLLECT},EMPTY_COLUMN_IN_COLLECT:{code:400,description:x.EMPTY_TABLE_IN_COLLECT},INVALID_COLUMN_IN_COLLECT:{code:400,description:x.INVALID_COLUMN_IN_COLLECT},CLIENT_CONNECTION:{code:400,description:x.CLIENT_CONNECTION},RECORDS_KEY_NOT_FOUND:{code:404,description:x.RECORDS_KEY_NOT_FOUND},EMPTY_RECORDS_IN_INSERT:{code:400,description:x.EMPTY_RECORDS_IN_INSERT},INVALID_RECORDS_IN_INSERT:{code:404,description:x.INVALID_RECORDS_IN_INSERT},INVALID_TABLE_IN_INSERT:{code:400,description:x.INVALID_TABLE_IN_INSERT},EMPTY_TABLE_IN_INSERT:{code:400,description:x.EMPTY_TABLE_IN_INSERT},MISSING_TABLE_IN_INSERT:{code:400,description:x.MISSING_TABLE_IN_INSERT},EMPTY_FIELDS_IN_INSERT:{code:400,description:x.EMPTY_FIELDS_IN_INSERT},MISSING_FIELDS_IN_INSERT:{code:404,description:x.MISSING_FIELDS_IN_INSERT},INVALID_FIELDS_IN_INSERT:{code:404,description:x.INVALID_FIELDS_IN_INSERT},INVALID_TOKENS_IN_INSERT:{code:404,description:x.INVALID_TOKENS_IN_INSERT},RECORDS_KEY_NOT_FOUND_DETOKENIZE:{code:404,description:x.RECORDS_KEY_NOT_FOUND_DETOKENIZE},EMPTY_RECORDS_DETOKENIZE:{code:400,description:x.EMPTY_RECORDS_DETOKENIZE},INVALID_RECORDS_IN_DETOKENIZE:{code:404,description:x.INVALID_RECORDS_IN_DETOKENIZE},MISSING_TOKEN_IN_DETOKENIZE:{code:400,description:x.MISSING_TOKEN_IN_DETOKENIZE},INVALID_TOKEN_IN_DETOKENIZE:{code:400,description:x.INVALID_TOKEN_IN_DETOKENIZE},RECORDS_KEY_NOT_FOUND_GET:{code:400,description:x.RECORDS_KEY_NOT_FOUND_GET},INVALID_RECORDS_IN_GET:{code:400,description:x.INVALID_RECORDS_IN_GET},EMPTY_RECORDS_GET:{code:400,description:x.EMPTY_RECORDS_GET},MISSING_IDS_IN_GET:{code:400,description:x.MISSING_IDS_IN_GET},INVALID_IDS_IN_GET:{code:400,description:x.INVALID_IDS_IN_GET},INVALID_COLUMN_VALUES_IN_GET:{code:400,description:x.INVALID_COLUMN_VALUES_IN_GET},EMPTY_IDS_IN_GET:{code:400,description:x.EMPTY_IDS_IN_GET},INVALID_SKYFLOWID_TYPE_IN_GET:{code:400,description:x.INVALID_SKYFLOWID_TYPE_IN_GET},MISSING_TABLE_IN_GET:{code:400,description:x.MISSING_TABLE_IN_GET},INVALID_TABLE_IN_GET:{code:400,description:x.INVALID_TABLE_IN_GET},MISSING_REDACTION_IN_GET:{code:400,description:x.MISSING_REDACTION_IN_GET},INVALID_REDACTION_TYPE_IN_GET:{code:400,description:x.INVALID_REDACTION_TYPE_IN_GET},INVALID_TOKENS_IN_GET:{code:400,description:x.INVALID_TOKENS_IN_GET},TOKENS_GET_COLUMN_NOT_SUPPORTED:{code:400,description:x.TOKENS_GET_COLUMN_NOT_SUPPORTED},REDACTION_WITH_TOKENS_NOT_SUPPORTED:{code:400,description:x.REDACTION_WITH_TOKENS_NOT_SUPPORTED},INVALID_REDACTION_TYPE_IN_DETOKENIZE:{code:400,description:x.INVALID_REDACTION_TYPE_IN_DETOKENIZE},INVALID_TOKENS_IN_COLLECT:{code:404,description:x.INVALID_TOKENS_IN_COLLECT},RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS:{code:404,description:x.RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS},INVALID_RECORDS_IN_ADDITIONAL_FIELDS:{code:404,description:x.INVALID_RECORDS_IN_ADDITIONAL_FIELDS},EMPTY_RECORDS_IN_ADDITIONAL_FIELDS:{code:400,description:x.EMPTY_RECORDS_IN_ADDITIONAL_FIELDS},MISSING_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:x.MISSING_TABLE_IN_ADDITIONAL_FIELDS},INVALID_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:x.INVALID_TABLE_IN_ADDITIONAL_FIELDS},INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:{code:400,description:x.INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS},MISSING_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:x.MISSING_FIELDS_IN_ADDITIONAL_FIELDS},INVALID_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:x.INVALID_FIELDS_IN_ADDITIONAL_FIELDS},RECORDS_KEY_NOT_FOUND_DELETE:{code:400,description:x.RECORDS_KEY_NOT_FOUND_DELETE},EMPTY_RECORDS_IN_DELETE:{code:400,description:x.EMPTY_RECORDS_IN_DELETE},INVALID_RECORDS_IN_DELETE:{code:404,description:x.INVALID_RECORDS_IN_DELETE},INVALID_TABLE_IN_DELETE:{code:400,description:x.INVALID_TABLE_IN_DELETE},EMPTY_TABLE_IN_DELETE:{code:400,description:x.EMPTY_TABLE_IN_DELETE},MISSING_TABLE_IN_DELETE:{code:400,description:x.MISSING_TABLE_IN_DELETE},EMPTY_ID_IN_DELETE:{code:400,description:x.EMPTY_ID_IN_DELETE},MISSING_ID_IN_DELETE:{code:404,description:x.MISSING_ID_IN_DELETE},INVALID_ID_IN_DELETE:{code:404,description:x.INVALID_ID_IN_DELETE},EMPTY_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:x.EMPTY_TABLE_IN_ADDITIONAL_FIELDS},EMPTY_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:x.EMPTY_FIELDS_IN_ADDITIONAL_FIELDS},EMPTY_TOKEN_IN_DETOKENIZE:{code:400,description:x.EMPTY_TOKEN_IN_DETOKENIZE},EMPTY_SKYFLOWID_IN_GET:{code:400,description:x.EMPTY_SKYFLOWID_IN_GET},EMPTY_TABLE_IN_GET:{code:400,description:x.EMPTY_TABLE_IN_GET},EMPTY_REDACTION_TYPE_IN_GET:{code:400,description:x.EMPTY_REDACTION_TYPE_IN_GET},DUPLICATE_ELEMENT:{code:400,description:x.DUPLICATE_ELEMENT},DUPLICATE_ELEMENT_ADDITIONAL_FIELDS:{code:400,description:x.DUPLICATE_ELEMENT_ADDITIONAL_FIELDS},MISSING_ELEMENT_TYPE:{code:400,description:x.MISSING_ELEMENT_TYPE},EMPTY_ELEMENT_TYPE:{code:400,description:x.EMPTY_ELEMENT_TYPE},INVALID_ELEMENT_TYPE:{code:400,description:x.INVALID_ELEMENT_TYPE},INVALID_ELEMENT_SELECTOR:{code:400,description:x.INVALID_ELEMENT_SELECTOR},FRAME_NOT_FOUND:{code:400,description:x.FRAME_NOT_FOUND},REQUIRED_PARAMS_NOT_PROVIDED:{code:400,description:x.REQUIRED_PARAMS_NOT_PROVIDED},INVALID_RECORD_COLUMN_VALUE:{code:400,description:x.INVALID_RECORD_COLUMN_VALUE},MISSING_RECORD_COLUMN_VALUE:{code:400,description:x.MISSING_RECORD_COLUMN_VALUE},MISSING_RECORD_COLUMN_NAME:{code:400,description:x.MISSING_RECORD_COLUMN_NAME},INVALID_EVENT_TYPE:{code:400,description:x.INVALID_EVENT_TYPE},INVALID_EVENT_LISTENER:{code:400,description:x.INVALID_EVENT_LISTENER},MISSING_HANDLER_IN_EVENT_LISTENER:{code:400,description:x.MISSING_HANDLER_IN_EVENT_LISTENER},INVALID_HANDLER_IN_EVENT_LISTENER:{code:400,description:x.INVALID_HANDLER_IN_EVENT_LISTENER},UNKNOWN_ERROR:{code:400,description:x.UNKNOWN_ERROR},CONNECTION_ERROR:{code:400,description:x.CONNECTION_ERROR},NETWORK_ERROR:{code:500,description:x.NETWORK_ERROR},COMPLETE_AND_VALID_INPUTS:{code:400,description:x.COMPLETE_AND_VALID_INPUTS},INVALID_VALIDATIONS_TYPE:{code:400,description:x.INVALID_VALIDATIONS_TYPE},MISSING_VALIDATION_RULE_TYPE:{code:400,description:x.MISSING_VALIDATION_RULE_TYPE},INVALID_VALIDATION_RULE_TYPE:{code:400,description:x.INVALID_VALIDATION_RULE_TYPE},MISSING_VALIDATION_RULE_PARAMS:{code:400,description:x.MISSING_VALIDATION_RULE_PARAMS},INVALID_VALIDATION_RULE_PARAMS:{code:400,description:x.INVALID_VALIDATION_RULE_PARAMS},MISSING_REGEX_IN_REGEX_MATCH_RULE:{code:400,description:x.MISSING_REGEX_IN_REGEX_MATCH_RULE},INVALID_REGEX_IN_REGEX_MATCH_RULE:{code:400,description:x.INVALID_REGEX_IN_REGEX_MATCH_RULE},MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE:{code:400,description:x.MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE},MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE:{code:400,description:x.MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE},INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE:{code:400,description:x.INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE},ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE:{code:400,description:x.ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE},EMPTY_ELEMENT_IN_MOUNT:{code:400,description:x.EMPTY_ELEMENT_IN_MOUNT},INVALID_TABLE_IN_UPSERT_OPTION:{code:400,description:x.INVALID_TABLE_IN_UPSERT_OPTION},INVALID_COLUMN_IN_UPSERT_OPTION:{code:400,description:x.INVALID_COLUMN_IN_UPSERT_OPTION},INVALID_UPSERT_OPTION_TYPE:{code:400,description:x.INVALID_UPSERT_OPTION_TYPE},EMPTY_UPSERT_OPTIONS_ARRAY:{code:400,description:x.EMPTY_UPSERT_OPTIONS_ARRAY},INVALID_UPSERT_OPTION_OBJECT_TYPE:{code:400,description:x.INVALID_UPSERT_OPTION_OBJECT_TYPE},MISSING_TABLE_IN_UPSERT_OPTION:{code:400,description:x.MISSING_TABLE_IN_UPSERT_OPTION},MISSING_COLUMN_IN_UPSERT_OPTION:{code:400,description:x.MISSING_COLUMN_IN_UPSERT_OPTION},INVALID_RECORD_COLUMN_VALUE_TYPE:{code:400,description:x.INVALID_RECORD_COLUMN_VALUE_TYPE},INVALID_COLUMN_VALUES_TYPE:{code:400,description:x.INVALID_COLUMN_VALUES_TYPE},EMPTY_RECORD_COLUMN_VALUES:{code:400,description:x.EMPTY_RECORD_COLUMN_VALUES},EMPTY_COLUMN_VALUE:{code:400,description:x.EMPTY_COLUMN_VALUE},MISSING_IDS_OR_COLUMN_VALUES_IN_GET:{code:400,description:x.MISSING_IDS_OR_COLUMN_VALUES_IN_GET},SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED:{code:400,description:x.SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED},RECORDS_KEY_NOT_FOUND_GETBYID:{code:400,description:x.RECORDS_KEY_NOT_FOUND_GETBYID},INVALID_RECORDS_IN_GETBYID:{code:400,description:x.INVALID_RECORDS_IN_GETBYID},EMPTY_RECORDS_GETBYID:{code:400,description:x.EMPTY_RECORDS_GETBYID},MISSING_IDS_IN_GETBYID:{code:400,description:x.MISSING_IDS_IN_GETBYID},INVALID_IDS_IN_GETBYID:{code:400,description:x.INVALID_IDS_IN_GETBYID},EMPTY_IDS_IN_GETBYID:{code:400,description:x.EMPTY_IDS_IN_GETBYID},INVALID_SKYFLOWID_TYPE_IN_GETBYID:{code:400,description:x.INVALID_SKYFLOWID_TYPE_IN_GETBYID},MISSING_TABLE_IN_GETBYID:{code:400,description:x.MISSING_TABLE_IN_GETBYID},INVALID_TABLE_IN_GETBYID:{code:400,description:x.INVALID_TABLE_IN_GETBYID},MISSING_REDACTION_IN_GETBYID:{code:400,description:x.MISSING_REDACTION_IN_GETBYID},INVALID_REDACTION_TYPE_IN_GETBYID:{code:400,description:x.INVALID_REDACTION_TYPE_IN_GETBYID},EMPTY_SKYFLOWID_IN_GETBYID:{code:400,description:x.EMPTY_SKYFLOWID_IN_GETBYID},EMPTY_TABLE_IN_GETBYID:{code:400,description:x.EMPTY_TABLE_IN_GETBYID},EMPTY_REDACTION_TYPE_IN_GETBYID:{code:400,description:x.EMPTY_REDACTION_TYPE_IN_GETBYID},MISSING_COMPOSABLE_LAYOUT_KEY:{code:400,description:x.MISSING_COMPOSABLE_LAYOUT_KEY},EMPTY_COMPOSABLE_LAYOUT_ARRAY:{code:400,description:x.EMPTY_COMPOSABLE_LAYOUT_ARRAY},INVALID_COMPOSABLE_LAYOUT_TYPE:{code:400,description:x.INVALID_COMPOSABLE_LAYOUT_TYPE},NEGATIVE_VALUES_COMPOSABLE_LAYOUT:{code:400,description:x.NEGATIVE_VALUES_COMPOSABLE_LAYOUT},MISMATCH_ELEMENT_COUNT_LAYOUT_SUM:{code:400,description:x.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM},MISSING_COMPOSABLE_CONTAINER_OPTIONS:{code:400,description:x.MISSING_COMPOSABLE_CONTAINER_OPTIONS},INVALID_COMPOSABLE_CONTAINER_OPTIONS:{code:400,description:x.INVALID_COMPOSABLE_CONTAINER_OPTIONS},COMPOSABLE_CONTAINER_NOT_MOUNTED:{code:400,description:x.COMPOSABLE_CONTAINER_NOT_MOUNTED},INVALID_BOOLEAN_OPTIONS:{code:400,description:x.INVALID_BOOLEAN_OPTIONS},EMPTY_COLLECT_CUSTOM_FORMAT:{code:400,description:x.EMPTY_COLLECT_CUSTOM_FORMAT},INVALID_INPUT_OPTIONS_FORMAT:{code:400,description:x.INVALID_INPUT_OPTIONS_FORMAT},INVALID_INPUT_OPTIONS_TRANSLATION:{code:400,description:x.INVALID_INPUT_OPTIONS_TRANSLATION}},Fe=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new xe(Ye.RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS,[],!0);const{records:t}=e;if(!t||!Array.isArray(t))throw new xe(Ye.INVALID_RECORDS_IN_ADDITIONAL_FIELDS,[],!0);if(0===t.length)throw new xe(Ye.EMPTY_RECORDS_IN_ADDITIONAL_FIELDS,[],!0);t.forEach(((e,t)=>{var i,n,s,o;if(!e||!Object.prototype.hasOwnProperty.call(e,"table"))throw new xe(Ye.MISSING_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!e.table)throw new xe(Ye.EMPTY_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(void 0!==(null===(i=e.fields)||void 0===i?void 0:i.skyflowID)){if(!(null===(n=e.fields)||void 0===n?void 0:n.skyflowID))throw new xe(Ye.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!("string"==typeof(null===(s=e.fields)||void 0===s?void 0:s.skyflowID)||(null===(o=e.fields)||void 0===o?void 0:o.skyflowID)instanceof String))throw new xe(Ye.INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[`${t}`],!0)}if(!("string"==typeof e.table||e.table instanceof String))throw new xe(Ye.INVALID_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"fields"))throw new xe(Ye.MISSING_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!e.fields)throw new xe(Ye.EMPTY_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if("object"!=typeof e.fields||Array.isArray(e.fields))throw new xe(Ye.INVALID_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0)}))},Ve=e=>{let t=!0;try{new RegExp(e)}catch(e){t=!1}return t},Be=e=>{if(!Object.prototype.hasOwnProperty.call(e,"getBearerToken"))throw new xe(Ye.GET_BEARER_TOKEN_IS_REQUIRED,[],!0)},Ge=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new xe(Ye.MISSING_ELEMENT_TYPE,[],!0);if(!e.type)throw new xe(Ye.EMPTY_ELEMENT_TYPE,[],!0);if(Object.prototype.hasOwnProperty.call(e,"altText")&&we(Y.COLLECT_ALT_TEXT_DEPERECATED,Ce.WARN,t),Object.prototype.hasOwnProperty.call(e,"skyflowID")&&"string"!=typeof e.skyflowID)throw new xe(Ye.INVALID_SKYFLOWID_IN_COLLECT,[],!0)},je=e=>{if(!e||!Array.isArray(e))throw new xe(Ye.INVALID_UPSERT_OPTION_TYPE,[],!0);if(!e.length)throw new xe(Ye.EMPTY_UPSERT_OPTIONS_ARRAY,[],!0);e.forEach(((e,t)=>{if(!e||"object"!=typeof e)throw new xe(Ye.INVALID_UPSERT_OPTION_OBJECT_TYPE,[t],!0);if(!Object.prototype.hasOwnProperty.call(e,"table"))throw new xe(Ye.MISSING_TABLE_IN_UPSERT_OPTION,[t],!0);if(!e.table||"string"!=typeof e.table||!e.table.length)throw new xe(Ye.INVALID_TABLE_IN_UPSERT_OPTION,[t],!0);if(!Object.prototype.hasOwnProperty.call(e,"column"))throw new xe(Ye.MISSING_COLUMN_IN_UPSERT_OPTION,[t],!0);if(!e.column||"string"!=typeof e.column||!e.column.length)throw new xe(Ye.INVALID_COLUMN_IN_UPSERT_OPTION,[t],!0)}))},Xe=e=>"boolean"==typeof e;function We(e){const t=e.split(":");return t.length>2?(t.pop(),t.pop(),t.join(":")):""}const ze=(e,t,i)=>{if("string"!=typeof e)return e;if(t===Z.CARD_NUMBER){if(e=e&&e.replace(/\s/g,""),!i){const t=((e="")=>{const t=e.replace(/[\s-]/g,"");let i=Q.DEFAULT;return Object.entries(ae).forEach((([e,n])=>{n.regex.test(t)&&(i=e)})),i})(e),i=t!==Q.DEFAULT&&t===Q.AMEX?6:8;return e.length>i?e.replace(new RegExp(`.(?=.{0,${(null==e?void 0:e.length)-i-1}}$)`,"g"),"X"):e}return e}return i?e:void 0};function He(e){var t,i,n,s,a;if((null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.customElementsURL)&&(e=>{if(!e||"https"!==e.substring(0,5).toLowerCase())return!1;try{if(new URL(e))return!0}catch(e){return!1}return!0})(null===(i=null==e?void 0:e.options)||void 0===i?void 0:i.customElementsURL)){const t=null===(n=null==e?void 0:e.options)||void 0===n?void 0:n.customElementsURL,i=new URL(t),o=`${i.protocol}//${i.hostname}`;Ie.IFRAME_SECURE_ORGIN=o,Ie.IFRAME_SECURE_SITE=null===(s=null==e?void 0:e.options)||void 0===s?void 0:s.customElementsURL}if(null===(a=e.options)||void 0===a?void 0:a.deserializedData.usePayrailsFrames){if(!Ie.IFRAME_SECURE_ORGIN||!Ie.IFRAME_SECURE_SITE){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CARD_FORM_IFRAME_NOT_FOUND);throw r.PayrailsLogger.error(e.message,{error:e,extra:{IFRAME_SECURE_ORGIN:Ie.IFRAME_SECURE_ORGIN,IFRAME_SECURE_SITE:Ie.IFRAME_SECURE_SITE}}),e}Ie.IFRAME_SECURE_ORGIN=fe,Ie.IFRAME_SECURE_SITE=pe}}class Ke{constructor(e,t,i,n){this.setAttributess=e=>{me(this.iframe,{src:e})},this.mount=e=>{var t;this.unmount();try{if("string"==typeof e){if(this.container=document.querySelector(e)||void 0,!this.container)throw new xe(Ye.INVALID_ELEMENT_SELECTOR,[],!0)}else{if(!(e instanceof HTMLElement))throw new xe(Ye.INVALID_ELEMENT_SELECTOR,[],!0);this.container=e}}catch(e){console.error(e)}me(this.iframe,{src:Te()}),null===(t=this.container)||void 0===t||t.appendChild(this.iframe)},this.setIframeHeight=e=>{this.iframe.getAttribute("height")!==`${e}px`&&this.iframe.setAttribute("height",`${e}px`)},this.unmount=()=>{this.iframe.remove()},this.name=`${e}:${i}:${n}`,this.metadata=t,this.iframe=Ne({name:this.name})}}class $e{}var qe,Je,Ze,Qe,et,tt,it,nt,st,ot,rt,at,lt,dt,ct,ut,Et,_t,ht,It;const pt="Element";class ft extends $e{constructor(e,n,s,o,r=!1,a,l,d,c){var u;super(),this.type=Si.COLLECT,qe.set(this,void 0),Je.set(this,!1),Ze.set(this,void 0),Qe.set(this,void 0),et.set(this,{isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:void 0,isRequired:!1}),tt.set(this,void 0),it.set(this,new he),nt.set(this,void 0),st.set(this,U.getEventBus()),ot.set(this,void 0),rt.set(this,[]),at.set(this,!1),lt.set(this,void 0),dt.set(this,void 0),ct.set(this,!1),this.getID=()=>t(this,qe,"f"),this.mount=e=>{var n;if(!e)throw new xe(Ye.EMPTY_ELEMENT_IN_MOUNT,["CollectElement"],!0);const s=(e,n)=>{if(e.name===t(this,ot,"f").name){n(t(this,tt,"f")),t(this,It,"f").call(this);const e=function(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(i[n[s]]=e[n[s]])}return i}(t(this,Ze,"f")[0],["name"]);t(this,Qe,"f").length>1?t(this,Qe,"f").forEach(((e,i)=>{t(this,nt,"f")&&t(this,nt,"f")._emit(`${B.READY}:${e.elementName}`,Object.assign(Object.assign({},t(this,Ze,"f")[i]),{elementType:e.elementType}))})):t(this,it,"f")._emit(B.READY,Object.assign({},e)),t(this,st,"f").off(G+this.containerId,s),we(`${Ue(k.ELEMENT_MOUNTED,pt,ke(t(this,ot,"f").name))} `,Ce.LOG,t(this,lt,"f").logLevel),t(this,rt,"f").forEach((e=>e())),i(this,rt,[],"f")}};if(t(this,Qe,"f").length>1)t(this,ot,"f").mount(e),t(this,st,"f").on(G+this.containerId,s);else{if(t(this,ct,"f"))return t(this,ot,"f").mount(e),void t(this,st,"f").on(G+this.containerId,s);null===(n=t(this,nt,"f"))||void 0===n||n.on(J,(i=>{(null==i?void 0:i.containerId)===this.containerId&&(t(this,ot,"f").mount(e),t(this,st,"f").on(G+this.containerId,s))}))}},this.unmount=()=>{t(this,ot,"f").unmount()},this.update=e=>{let n=Oe(e);const s=()=>{t(this,Je,"f")&&(n={rows:[{elements:[Object.assign({},n)]}]}),i(this,tt,mt(t(this,tt,"f"),n),"f"),i(this,Qe,Nt(t(this,tt,"f")),"f"),t(this,Je,"f")?t(this,st,"f").emit(z,{name:t(this,ot,"f").name,options:t(this,Qe,"f")[0],isSingleElementAPI:!0}):(t(this,Qe,"f").forEach((e=>{t(this,st,"f").emit(z,{name:e.elementName,options:e,isSingleElementAPI:!0})})),t(this,st,"f").emit(z,{name:t(this,ot,"f").name,options:t(this,tt,"f"),isSingleElementAPI:!1})),t(this,It,"f").call(this)};t(this,at,"f")?s():t(this,rt,"f").push(s)},ut.set(this,(e=>{t(this,Je,"f")||t(this,it,"f").on(z,(()=>{e(t(this,Qe,"f"))}),!0)})),this.updateElement=e=>{t(this,st,"f").emit(z,{name:e.elementName,options:e,isSingleElementAPI:!0})},Et.set(this,(()=>{t(this,Ze,"f").forEach(((e,i)=>{if(0===i){t(this,et,"f").isEmpty=e.isEmpty,t(this,et,"f").isComplete=e.isComplete,t(this,et,"f").isValid=e.isValid,t(this,et,"f").isFocused=e.isFocused,t(this,et,"f").isRequired=e.isRequired,t(this,et,"f").value={};const n=t(this,Qe,"f")[i].elementName,s=e.value&&ze(e.value,e.elementType,t(this,dt,"f"));t(this,Je,"f")?t(this,et,"f").value=s:t(this,et,"f").value[n]=s}else t(this,et,"f").isEmpty=t(this,et,"f").isEmpty||e.isEmpty,t(this,et,"f").isComplete=t(this,et,"f").isComplete&&e.isComplete,t(this,et,"f").isValid=t(this,et,"f").isValid&&e.isValid,t(this,et,"f").isFocused=t(this,et,"f").isFocused||e.isFocused,t(this,et,"f").isRequired=t(this,et,"f").isRequired||e.isRequired,t(this,et,"f").value||(t(this,et,"f").value={}),t(this,Qe,"f")[i].sensitive||(t(this,et,"f").value[t(this,Qe,"f")[i].elementName]=e.value||"")}))})),this.getState=()=>({isEmpty:t(this,et,"f").isEmpty,isComplete:t(this,et,"f").isComplete,isValid:t(this,et,"f").isValid,isFocused:t(this,et,"f").isFocused,value:t(this,et,"f").value,required:t(this,et,"f").isRequired}),this.getOptions=()=>{let e=Oe(t(this,tt,"f"));return t(this,Je,"f")?e=e.rows[0].elements[0]:e.rows.forEach((e=>{e.elements.forEach((e=>{delete e.elementName}))})),delete e.elementName,e},_t.set(this,(e=>{t(this,it,"f").on(W,(()=>{const i=t(this,Qe,"f").map((e=>e.elementName));t(this,Je,"f")||i.push(t(this,ot,"f").name),e(i)}),!0)})),ht.set(this,(()=>{t(this,st,"f").on(X,(e=>{if(t(this,Je,"f")&&e.event===B.READY&&e.name===t(this,ot,"f").name)t(this,it,"f")._emit(B.READY);else{const i=t(this,Qe,"f").length>1;t(this,Qe,"f").forEach(((n,s)=>{var o;if(e.name===n.elementName){let r="";switch(e.event){case B.FOCUS:r=B.FOCUS;break;case B.BLUR:r=B.BLUR;break;case B.CHANGE:r=B.CHANGE;break;case B.READY:r=B.READY;break;case B.SUBMIT:return void(null===(o=t(this,nt,"f"))||void 0===o||o._emit(B.SUBMIT));default:throw new xe(Ye.INVALID_EVENT_TYPE,[],!0)}t(this,Ze,"f")[s].isEmpty=e.value.isEmpty,t(this,Ze,"f")[s].isValid=e.value.isValid,t(this,Ze,"f")[s].isComplete=e.value.isComplete,t(this,Ze,"f")[s].isFocused=e.value.isFocused,t(this,Ze,"f")[s].isRequired=e.value.isRequired,Object.prototype.hasOwnProperty.call(e.value,"value")?t(this,Ze,"f")[s].value=e.value.value:t(this,Ze,"f")[s].value=void 0,r=i?`${r}:${e.name}`:r,t(this,st,"f").emit(B.HEIGHT+t(this,ot,"f").name,{},(e=>{t(this,ot,"f").setIframeHeight(e.height)})),t(this,Et,"f").call(this);const a=Object.assign(Object.assign({},t(this,Ze,"f")[s]),{elementType:n.elementType});i&&t(this,nt,"f")?t(this,nt,"f")._emit(r,a):t(this,it,"f")._emit(r,a)}}))}}))})),It.set(this,(()=>{const{rows:e}=t(this,tt,"f");e.forEach((e=>{e.elements.forEach((e=>{e.elementType!==te.radio.name&&e.elementType!==te.checkbox.name&&(e.value=void 0)}))})),i(this,Qe,Nt(t(this,tt,"f")),"f")})),this.containerId=o.containerId,i(this,qe,e,"f"),i(this,lt,d,"f"),i(this,tt,mt(n),"f"),i(this,Qe,Nt(n),"f"),i(this,Je,r,"f"),c&&i(this,nt,c,"f"),i(this,dt,Pe[t(this,lt,"f").env].doesReturnValue,"f"),this.elementType=t(this,Je,"f")?t(this,Qe,"f")[0].elementType:"group",i(this,Ze,[],"f"),t(this,Qe,"f").forEach((e=>{t(this,Ze,"f").push({isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:t(this,dt,"f")?"":void 0,elementType:e.elementType,name:e.elementName,isRequired:!1})})),i(this,ot,new Ke(t(this,tt,"f").elementName,s,this.containerId,t(this,lt,"f").logLevel),"f"),t(this,ht,"f").call(this),t(this,_t,"f").call(this,a),t(this,ut,"f").call(this,l),we(Ue(k.CREATED_ELEMENT,pt,ke(t(this,ot,"f").name)),Ce.LOG,t(this,lt,"f").logLevel),i(this,ct,o.isMounted,"f"),null===(u=t(this,nt,"f"))||void 0===u||u.on(J,(e=>{(null==e?void 0:e.containerId)===this.containerId&&i(this,ct,!0,"f")}));const E=e=>{e.height&&e.height>0&&t(this,ot,"f").setIframeHeight(e.height)};t(this,st,"f").on(B.MOUNTED,(e=>{o.type===Si.COMPOSABLE?t(this,Qe,"f").forEach((t=>{e.name===t.elementName&&(t.isMounted=!0,i(this,at,!0,"f"))})):e.name===t(this,Qe,"f")[0].elementName&&(t(this,Qe,"f")[0].isMounted=!0,i(this,at,!0,"f")),t(this,st,"f").emit(B.HEIGHT+t(this,ot,"f").name,{},E)}))}on(e,i){if(!Object.values(B).includes(e))throw new xe(Ye.INVALID_EVENT_LISTENER,[],!0);if(!i)throw new xe(Ye.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof i)throw new xe(Ye.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);t(this,it,"f").on(e,(e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,i(e)}))}iframeName(){return t(this,ot,"f").name}isMounted(){return t(this,at,"f")}isValidElement(){for(let e=0;e<t(this,Qe,"f").length;e+=1){if(!Object.prototype.hasOwnProperty.call(t(this,Qe,"f")[e],"table"))throw new xe(Ye.MISSING_TABLE_IN_COLLECT,[],!0);if(!t(this,Qe,"f")[e].table)throw new xe(Ye.EMPTY_TABLE_IN_COLLECT,[],!0);if(!("string"==typeof t(this,Qe,"f")[e].table||t(this,Qe,"f")[e].table instanceof String))throw new xe(Ye.INVALID_TABLE_IN_COLLECT,[],!0);if(!Object.prototype.hasOwnProperty.call(t(this,Qe,"f")[e],"column"))throw new xe(Ye.MISSING_COLUMN_IN_COLLECT,[],!0);if(!t(this,Qe,"f")[e].column)throw new xe(Ye.EMPTY_COLUMN_IN_COLLECT,[],!0);if(!("string"==typeof t(this,Qe,"f")[e].column||t(this,Qe,"f")[e].column instanceof String))throw new xe(Ye.INVALID_COLUMN_IN_COLLECT,[],!0);if(void 0!==t(this,Qe,"f")[e].skyflowID&&!t(this,Qe,"f")[e].skyflowID)throw new xe(Ye.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[],!0)}return!0}setError(e){t(this,st,"f").emit(K,{name:We(t(this,ot,"f").name),isTriggerError:!0,clientErrorText:e})}resetError(){t(this,st,"f").emit(K,{name:We(t(this,ot,"f").name),isTriggerError:!1})}setValue(e){t(this,lt,"f").env!==Se.PROD?t(this,Je,"f")&&t(this,st,"f").emit(z,{name:t(this,ot,"f").name,options:Object.assign(Object.assign({},t(this,Qe,"f")[0]),{value:e}),isSingleElementAPI:!0}):we(Ue(Y.UNABLE_TO_SET_VALUE_IN_PROD_ENV,t(this,Qe,"f")[0].elementType),Ce.WARN,t(this,lt,"f").logLevel)}clearValue(){t(this,lt,"f").env!==Se.PROD?t(this,Je,"f")&&t(this,st,"f").emit(z,{name:t(this,ot,"f").name,options:Object.assign(Object.assign({},t(this,Qe,"f")[0]),{value:""}),isSingleElementAPI:!0}):we(Ue(Y.UNABLE_TO_CLEAR_VALUE_IN_PROD_ENV,t(this,Qe,"f")[0].elementType),Ce.WARN,t(this,lt,"f").logLevel)}}function vt(e,t,i={}){if("group"!==e&&!Object.prototype.hasOwnProperty.call(te,e))throw new xe(Ye.INVALID_ELEMENT_TYPE,[],!0);if(Object.prototype.hasOwnProperty.call(t,"validations")){if(!Array.isArray(t.validations))throw new xe(Ye.INVALID_VALIDATIONS_TYPE,[],!0);t.validations.forEach(((e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new xe(Ye.MISSING_VALIDATION_RULE_TYPE,[`${t}`],!0);if(!Object.values(De).includes(e.type))throw new xe(Ye.INVALID_VALIDATION_RULE_TYPE,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"params"))throw new xe(Ye.MISSING_VALIDATION_RULE_PARAMS,[`${t}`],!0);if("object"!=typeof e.params||Array.isArray(e.params)||null===e.params)throw new xe(Ye.INVALID_VALIDATION_RULE_PARAMS,[`${t}`],!0);if(e.type===De.REGEX_MATCH_RULE){if(!Object.prototype.hasOwnProperty.call(e.params,"regex"))throw new xe(Ye.MISSING_REGEX_IN_REGEX_MATCH_RULE,[`${t}`],!0)}else if(e.type===De.LENGTH_MATCH_RULE&&!Object.prototype.hasOwnProperty.call(e.params,"min")&&!Object.prototype.hasOwnProperty.call(e.params,"max"))throw new xe(Ye.MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE,[`${t}`],!0)}))}if(Object.prototype.hasOwnProperty.call(i,"name")&&i.name!==t.name)throw new Error("Name attribute can't be updated");if((i=Object.assign(Object.assign({},t),i)).mask||i.replacePattern){const{type:t}=te[e].attributes;"text"===t&&"textarea"===t&&"email"===t||(delete i.mask,delete i.replacePattern)}if(void 0===!i.mask&&!Array.isArray(i.mask))throw new Error("mask option has to be array or undefined");if(Array.isArray(i.mask)){const e=i.mask;if("string"!=typeof e[0]||e[1]&&"object"!=typeof e[1])throw new Error("mask array values has to be string")}if(Array.isArray(i.replacePattern)){const e=i.replacePattern;if("string"!=typeof e[0]||e[1]&&"string"!=typeof e[1])throw new Error("replacePatterns array values has to be string")}if((e===te.radio.name||e===te.checkbox.name)&&!i.value)throw new Error("Elements radio and checkbox requires value attribute");if(!(e!==te.dropdown.name||i.options&&Array.isArray(i.options)&&0!==i.options.length))throw new Error("Element dropdown requires options attribute with an array of objects containing value and text attributes")}function mt(e,t={},i=!0){return(t=Object.assign(Object.assign({},e),t)).rows.forEach(((n,s)=>{const o=n,r=e.rows[s];t.rows[s]=Object.assign(Object.assign({},r),o),o.elements.forEach(((e,t)=>{var n,s;const a=r.elements[t],l=e;if(l.elementType&&a.elementType!==l.elementType&&a.elementName&&a.elementName!==l.elementName)throw new Error(x.CANNOT_CHANGE_ELEMENT);vt(a.elementType,a,l),o.elements[t]=Object.assign(Object.assign(Object.assign({},a),l),{elementName:a.elementName});const d=l.classes||{},c=l.styles||{};c.base=Object.assign(Object.assign({},oe),c.base),l.classes=d,l.styles=c;const u=(null===(n=null==l?void 0:l.labelStyles)||void 0===n?void 0:n.classes)||{},E=(null===(s=null==l?void 0:l.labelStyles)||void 0===s?void 0:s.styles)||{};i&&function(e,t){Object.values(re).forEach((i=>{if(e[i]||t[i])switch(i){case re.BASE:t[i]=Object.assign({},t[i]);break;case re.FOCUS:t[re.BASE]=Object.assign(Object.assign({},t[re.BASE]),{":focus":Object.assign({},t[re.BASE]&&t[re.BASE][":focus"])});break;case re.WEBPACKAUTOFILL:t[re.BASE]=Object.assign(Object.assign({},t[re.BASE]),{":-webkit-autofill":Object.assign({},t[re.BASE]&&t[re.BASE][":-webkit-autofill"])});break;default:t[i]=Object.assign(Object.assign({},t[re.BASE]),t[i])}})),Object.keys(t).forEach((e=>{const i=t[e][":-webkit-autofill"];"object"==typeof i&&Object.keys(i).forEach((e=>{i[e]&&!i[e].includes("!important")&&(i[e]=`${i[e]} !important`)}))}))}(u,E),l.labelStyles={labelClasses:u},l.labelStyles.styles=E}))})),t}qe=new WeakMap,Je=new WeakMap,Ze=new WeakMap,Qe=new WeakMap,et=new WeakMap,tt=new WeakMap,it=new WeakMap,nt=new WeakMap,st=new WeakMap,ot=new WeakMap,rt=new WeakMap,at=new WeakMap,lt=new WeakMap,dt=new WeakMap,ct=new WeakMap,ut=new WeakMap,Et=new WeakMap,_t=new WeakMap,ht=new WeakMap,It=new WeakMap;const Nt=e=>{const{rows:t}=e,i=[];return t.forEach((e=>{e.elements.forEach((e=>{i.push(e)}))})),i},Tt=e=>{const t=e.validations;return t&&Array.isArray(t)&&t.length>0&&t.forEach(((e,t)=>{if(e&&e.type===De.ELEMENT_VALUE_MATCH_RULE){if(e.params&&!Object.prototype.hasOwnProperty.call(e.params,"element"))throw new xe(Ye.MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE,[`${t}`],!0);if(e.params&&(null==e.params.element||!(e.params.element instanceof ft)))throw new xe(Ye.INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE,[`${t}`],!0);e.params&&e.params.element&&e.params.element instanceof ft&&(e.params.element=e.params.element.iframeName())}else if(e&&e.type===De.REGEX_MATCH_RULE){if(e.params&&e.params.regex&&!Ve(e.params.regex))throw new xe(Ye.INVALID_REGEX_IN_REGEX_MATCH_RULE,[`${t}`],!0);e.params&&e.params.regex&&Ve(e.params.regex)&&(e.params.regex=e.params.regex.toString())}})),t},yt=(e,t,i)=>{let n=Object.assign({required:!1},t);if((Object.prototype.hasOwnProperty.call(n,"format")||Object.prototype.hasOwnProperty.call(n,"translation"))&&(Ee.includes(e)?(we(Ue(Y.INPUT_FORMATTING_NOT_SUPPROTED,e),Ce.WARN,i),null==n||delete n.format,null==n||delete n.translation):e===te.INPUT_FIELD.name&&((e=>{if(e){if(Object.prototype.hasOwnProperty.call(e,"format")&&"string"!=typeof e.format)throw new xe(Ye.INVALID_INPUT_OPTIONS_FORMAT,[],!0);if(Object.prototype.hasOwnProperty.call(e,"translation")&&("object"!=typeof e.translation||"[object Object]"!==Object.prototype.toString.call(e.translation)))throw new xe(Ye.INVALID_INPUT_OPTIONS_TRANSLATION,[],!0)}})(t),n=Object.assign(Object.assign({},n),{mask:[n.format,n.translation?n.translation:_e]}),null==n||delete n.format,null==n||delete n.translation)),e===te.CARD_NUMBER.name){Object.prototype.hasOwnProperty.call(n,"enableCardIcon")||(n=Object.assign(Object.assign({},n),{enableCardIcon:!0}));let e=" ";(null==n?void 0:n.format)===ie&&(e="-"),n=Object.assign(Object.assign({},n),{cardSeperator:e}),null==n||delete n.format,null==n||delete n.translation}else if(e===te.EXPIRATION_DATE.name){let e=!1;n.format&&(e=!!(s=n.format.toUpperCase())&&de.includes(s),e||we(Ue(Y.INVALID_EXPIRATION_DATE_FORMAT,de.toString()),Ce.WARN,i)),n=Object.assign(Object.assign({},n),{format:e?n.format.toUpperCase():le}),null==n||delete n.translation}else if(e===te.EXPIRATION_YEAR.name){let e=!1;n.format&&(e=(e=>!!e&&ce.includes(e))(n.format.toUpperCase()),e||we(Ue(Y.INVALID_EXPIRATION_YEAR_FORMAT,ce.toString()),Ce.WARN,i)),n=Object.assign(Object.assign({},n),{format:e?n.format.toUpperCase():"YY"}),null==n||delete n.translation}var s;if(Object.prototype.hasOwnProperty.call(n,"enableCardIcon")&&!Xe(n.enableCardIcon))throw new xe(Ye.INVALID_BOOLEAN_OPTIONS,["enableCardIcon"],!0);if(Object.prototype.hasOwnProperty.call(n,"enableCopy")&&!Xe(n.enableCopy))throw new xe(Ye.INVALID_BOOLEAN_OPTIONS,["enableCopy"],!0);if(Object.prototype.hasOwnProperty.call(n,"required")&&!Xe(n.required))throw new xe(Ye.INVALID_BOOLEAN_OPTIONS,["required"],!0);return n};function Ot(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=crypto.getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*16|0;return("x"===e?t:3&t|8).toString(16)}))}class At{}var Lt,gt,Rt,St,Ct,Dt,bt,Pt,Mt,wt,Ut,kt;const xt="CollectContainer";class Yt extends At{constructor(e,n,s,o){super(),Lt.set(this,void 0),gt.set(this,{}),Rt.set(this,void 0),St.set(this,void 0),Ct.set(this,void 0),this.type=Si.COLLECT,Dt.set(this,void 0),bt.set(this,!1),this.create=(e,i={required:!1})=>{Ge(e,t(this,St,"f").logLevel);const n=Tt(e),s=yt(e.type,i,t(this,St,"f").logLevel),o={rows:[{elements:[Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column,accept:i.allowedFileType},e),s),{validations:n})]}]};return t(this,Pt,"f").call(this,o,!0)},Pt.set(this,((e,i=!1)=>{const n=[],s=Oe(e);if(s.rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;vt(i,t),t.sensitive=t.sensitive||te[i].sensitive,t.replacePattern=t.replacePattern||te[i].replacePattern,t.mask=t.mask||te[i].mask,t.isMounted=!1,t.elementType!==te.radio.name&&t.elementType!==te.checkbox.name||(t.elementName=`${t.elementName}:${btoa(t.value)}`),t.elementName=`${V}:${t.elementType}:${btoa(Ot())}`,t.label=e.label,t.skyflowID=e.skyflowID,n.push(t)}))})),s.elementName=i?n[0].elementName:`${V}:group:${btoa(s.name)}`,i&&!t(this,gt,"f")[n[0].elementName]&&t(this,kt,"f").call(this,n[0].name))throw new xe(Ye.UNIQUE_ELEMENT_NAME,[`${n[0].name}`],!0);let o=t(this,gt,"f")[s.elementName];if(o)i?o.update(n[0]):o.update(s);else{const e=Ot();o=new ft(e,s,t(this,Rt,"f"),{containerId:t(this,Lt,"f"),isMounted:t(this,bt,"f"),type:this.type},i,t(this,wt,"f"),t(this,Ut,"f"),t(this,St,"f"),t(this,Dt,"f")),t(this,gt,"f")[s.elementName]=o,t(this,Ct,"f")[e]=o}return i||n.forEach((e=>{const i=e.elementName;t(this,gt,"f")[i]?t(this,gt,"f")[i].update(e):t(this,gt,"f")[i]=this.create(e.elementType,o)})),o})),Mt.set(this,(e=>{Object.keys(t(this,gt,"f")).forEach((i=>{i===e&&delete t(this,gt,"f")[i]}))})),wt.set(this,(e=>{e.forEach((e=>{t(this,Mt,"f").call(this,e)}))})),Ut.set(this,(e=>{e.forEach((e=>{t(this,gt,"f")[e.elementName]&&t(this,gt,"f")[e.elementName].update(e)}))})),kt.set(this,(e=>{const i=Object.keys(t(this,gt,"f"));for(let t=0;t<i.length;t+=1)if(atob(i[t].split(":")[2])===e)return!0;return!1})),this.collect=(e={tokens:!0})=>new Promise(((i,n)=>{try{Be(t(this,Rt,"f").clientJSON.config);if(Object.values(t(this,gt,"f")).forEach((e=>{if(!e.isMounted())throw new xe(Ye.ELEMENTS_NOT_MOUNTED,[],!0);e.isValidElement()})),Object.prototype.hasOwnProperty.call(e,"tokens")&&!Xe(e.tokens))throw new xe(Ye.INVALID_TOKENS_IN_COLLECT,[],!0);(null==e?void 0:e.additionalFields)&&Fe(e.additionalFields),(null==e?void 0:e.upsert)&&je(null==e?void 0:e.upsert),this.bus.emit(j+t(this,Lt,"f"),Object.assign(Object.assign({},e),{tokens:void 0===(null==e?void 0:e.tokens)||e.tokens}),(e=>{!e||(null==e?void 0:e.error)?(we(`${JSON.stringify(null==e?void 0:e.error)}`,Ce.ERROR,t(this,St,"f").logLevel),n(null==e?void 0:e.error)):(we(Ue(k.COLLECT_SUBMIT_SUCCESS,xt),Ce.LOG,t(this,St,"f").logLevel),i(e))})),we(Ue(k.EMIT_EVENT,xt,j),Ce.LOG,t(this,St,"f").logLevel)}catch(e){we(`${e.message}`,Ce.ERROR,t(this,St,"f").logLevel),n(e)}})),this.unmount=()=>{this.iframe.remove()},this.bus=U.getEventBus(),i(this,Lt,Ot(),"f"),i(this,Rt,n,"f"),i(this,Ct,s,"f"),i(this,St,o,"f"),i(this,Dt,new he,"f"),this.iframe=Ne({name:`${F}:${t(this,Lt,"f")}:${t(this,St,"f").logLevel}`}),me(this.iframe,{src:Te()}),ye(this.iframe,Object.assign({},se)),we(Ue(k.CREATE_COLLECT_CONTAINER,xt),Ce.LOG,t(this,St,"f").logLevel);const r=(e,s)=>{e.name===F+t(this,Lt,"f")&&(s(Object.assign(Object.assign({},n),{clientJSON:Object.assign(Object.assign({},n.clientJSON),{config:Object.assign({},n.clientJSON.config)}),context:o})),i(this,bt,!0,"f"),t(this,Dt,"f")._emit(J,{containerId:t(this,Lt,"f")}),this.bus.target({origin:Ie.IFRAME_SECURE_ORGIN}).off(G+t(this,Lt,"f"),r))};this.bus.target({origin:Ie.IFRAME_SECURE_ORGIN}).on(G+t(this,Lt,"f"),r),document.body.append(this.iframe)}}Lt=new WeakMap,gt=new WeakMap,Rt=new WeakMap,St=new WeakMap,Ct=new WeakMap,Dt=new WeakMap,bt=new WeakMap,Pt=new WeakMap,Mt=new WeakMap,wt=new WeakMap,Ut=new WeakMap,kt=new WeakMap;var Ft=function(e,t){for(var i,n=-1,s=e.length;++n<s;){var o=t(e[n]);void 0!==o&&(i=void 0===i?o:i+o)}return i},Vt=function(e){return e};var Bt,Gt,jt,Xt,Wt,zt,Ht,Kt,$t,qt,Jt,Zt,Qt,ei,ti,ii,ni,si,oi,ri,ai,li,di,ci=s((function(e){return e&&e.length?Ft(e,Vt):0}));class ui{constructor(e,n){Bt.set(this,void 0),Gt.set(this,void 0),this.type=Si.COMPOSABLE,jt.set(this,!1),Xt.set(this,!1),this.update=e=>{i(this,Xt,!0,"f"),t(this,jt,"f")?(t(this,Gt,"f")._emit($,{elementName:t(this,Bt,"f"),elementOptions:e}),i(this,Xt,!1,"f")):t(this,Xt,"f")&&t(this,Gt,"f").on(`${ge.READY}:${t(this,Bt,"f")}`,(()=>{t(this,Gt,"f")._emit($,{elementName:t(this,Bt,"f"),elementOptions:e}),i(this,jt,!0,"f"),i(this,Xt,!1,"f")}))},i(this,Bt,e,"f"),i(this,Gt,n,"f"),t(this,Gt,"f").on(`${ge.READY}:${t(this,Bt,"f")}`,(()=>{i(this,jt,!0,"f")}))}on(e,i){if(!Object.values(B).includes(e))throw new xe(Ye.INVALID_EVENT_LISTENER,[],!0);if(!i)throw new xe(Ye.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof i)throw new xe(Ye.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);t(this,Gt,"f").on(`${e}:${t(this,Bt,"f")}`,(e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,i(e)}))}}Bt=new WeakMap,Gt=new WeakMap,jt=new WeakMap,Xt=new WeakMap;const Ei="CollectContainer";class _i extends At{constructor(e,n,s,a){super(),Wt.set(this,void 0),zt.set(this,{}),Ht.set(this,void 0),Kt.set(this,{rows:[]}),$t.set(this,[]),qt.set(this,void 0),Jt.set(this,void 0),Zt.set(this,void 0),Qt.set(this,!1),ei.set(this,void 0),ti.set(this,void 0),this.type=Si.COMPOSABLE,ii.set(this,!1),ni.set(this,{}),this.create=(e,i={required:!1})=>{Ge(e,t(this,qt,"f").logLevel);const n=Tt(e),s=yt(e.type,i,t(this,qt,"f").logLevel),o=`${V}:${e.type}:${btoa(Ot())}`;return t(this,$t,"f").push(Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column},e),s),{validations:n,elementName:o})),new ui(o,t(this,Zt,"f"))},si.set(this,((e,n=!1)=>{const s=[];if(i(this,ni,Oe(e),"f"),t(this,ni,"f").rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;vt(i,t),t.sensitive=t.sensitive||te[i].sensitive,t.replacePattern=t.replacePattern||te[i].replacePattern,t.mask=t.mask||te[i].mask,t.isMounted=!1,t.label=e.label,t.skyflowID=e.skyflowID,s.push(t)}))})),t(this,ni,"f").elementName=n?s[0].elementName:`${V}:group:${btoa(t(this,ni,"f").name)}`,n&&!t(this,zt,"f")[s[0].elementName]&&t(this,li,"f").call(this,s[0].name))throw new xe(Ye.UNIQUE_ELEMENT_NAME,[`${s[0].name}`],!0);let o=t(this,zt,"f")[t(this,ni,"f").elementName];if(o)n?o.update(s[0]):o.update(t(this,ni,"f"));else{const e=Ot();o=new ft(e,t(this,ni,"f"),t(this,Ht,"f"),{containerId:t(this,Wt,"f"),isMounted:t(this,ii,"f"),type:this.type},!0,t(this,ri,"f"),t(this,ai,"f"),t(this,qt,"f"),t(this,Zt,"f")),t(this,zt,"f")[t(this,ni,"f").elementName]=o,t(this,Jt,"f")[e]=o}return o})),oi.set(this,(e=>{Object.keys(t(this,zt,"f")).forEach((i=>{i===e&&delete t(this,zt,"f")[i]}))})),ri.set(this,(e=>{e.forEach((e=>{t(this,oi,"f").call(this,e)}))})),ai.set(this,(e=>{e.forEach((e=>{t(this,zt,"f")[e.elementName]&&t(this,zt,"f")[e.elementName].update(e)}))})),li.set(this,(e=>{const i=Object.keys(t(this,zt,"f"));for(let t=0;t<i.length;t+=1)if(atob(i[t].split(":")[2])===e)return!0;return!1})),this.on=(e,i)=>{if(!Object.values(B).includes(e))throw new xe(Ye.INVALID_EVENT_LISTENER,[],!0);if(!i)throw new xe(Ye.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof i)throw new xe(Ye.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);t(this,Zt,"f").on(B.SUBMIT,(()=>{i()}))},this.mount=e=>{if(!e)throw new xe(Ye.EMPTY_ELEMENT_IN_MOUNT,["CollectElement"],!0);const{layout:n}=t(this,ei,"f");if(ci(n)!==t(this,$t,"f").length)throw new xe(Ye.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM,[],!0);let s=0;if(n.forEach(((e,i)=>{t(this,Kt,"f").rows=[...t(this,Kt,"f").rows,{elements:[]}];for(let n=0;n<e;n++)t(this,Kt,"f").rows[i].elements.push(t(this,$t,"f")[s]),s++})),t(this,ei,"f").styles&&(t(this,Kt,"f").styles=Object.assign({},t(this,ei,"f").styles)),t(this,ei,"f").errorTextStyles&&(t(this,Kt,"f").errorTextStyles=Object.assign({},t(this,ei,"f").errorTextStyles)),t(this,ii,"f"))return i(this,ti,t(this,si,"f").call(this,t(this,Kt,"f"),!1),"f"),t(this,ti,"f").mount(e),void i(this,Qt,!0,"f");t(this,Zt,"f").on(q+t(this,Wt,"f"),(()=>{i(this,ti,t(this,si,"f").call(this,t(this,Kt,"f"),!1),"f"),t(this,ti,"f").mount(e),i(this,Qt,!0,"f")}))},this.unmount=()=>{t(this,ti,"f").unmount(),this.iframe.remove()},this.collect=(e={tokens:!0})=>new Promise(((i,n)=>{try{if(Be(t(this,Ht,"f").clientJSON.config),!t(this,Qt,"f")){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);throw r.PayrailsLogger.error(e.message,{error:e}),e}Nt(t(this,ni,"f")).forEach((e=>{if(!(null==e?void 0:e.isMounted))throw new xe(Ye.ELEMENTS_NOT_MOUNTED,[],!0)}));if(Object.values(t(this,zt,"f")).forEach((e=>{e.isValidElement()})),e&&e.tokens&&"boolean"!=typeof e.tokens)throw new xe(Ye.INVALID_TOKENS_IN_COLLECT,[],!0);(null==e?void 0:e.additionalFields)&&Fe(e.additionalFields),(null==e?void 0:e.upsert)&&je(null==e?void 0:e.upsert),this.bus.emit(j+t(this,Wt,"f"),Object.assign(Object.assign({},e),{tokens:void 0===(null==e?void 0:e.tokens)||e.tokens}),(e=>{!e||(null==e?void 0:e.error)?(we(`${JSON.stringify(null==e?void 0:e.error)}`,Ce.ERROR,t(this,qt,"f").logLevel),n(null==e?void 0:e.error)):(we(Ue(k.COLLECT_SUBMIT_SUCCESS,Ei),Ce.LOG,t(this,qt,"f").logLevel),i(e))})),we(Ue(k.EMIT_EVENT,Ei,j),Ce.LOG,t(this,qt,"f").logLevel)}catch(e){we(`${e.message}`,Ce.ERROR,t(this,qt,"f").logLevel),n(e)}})),di.set(this,(()=>{t(this,Zt,"f").on($,(e=>{let i;const n=t(this,$t,"f").map(((t,n)=>t.elementName===e.elementName?(i=n,Object.assign({elementName:t.elementName},e.elementOptions)):t));t(this,ti,"f")&&t(this,ti,"f").updateElement(Object.assign({},n[i]))}))})),this.bus=U.getEventBus(),i(this,Wt,Ot(),"f"),i(this,Ht,n,"f"),i(this,Jt,s,"f"),i(this,qt,a,"f"),i(this,ei,e,"f"),i(this,Zt,new he,"f"),this.iframe=Ne({name:`${F}:${t(this,Wt,"f")}:${t(this,qt,"f").logLevel}`}),me(this.iframe,{src:Te()}),ye(this.iframe,Object.assign({},se)),we(Ue(k.CREATE_COLLECT_CONTAINER,Ei),Ce.LOG,t(this,qt,"f").logLevel);const l=(e,s)=>{e.name===F+t(this,Wt,"f")&&(s(Object.assign(Object.assign({},n),{clientJSON:Object.assign(Object.assign({},n.clientJSON),{config:Object.assign({},n.clientJSON.config)}),context:a})),i(this,ii,!0,"f"),t(this,Zt,"f")._emit(q+t(this,Wt,"f"),{containerId:t(this,Wt,"f")}),this.bus.target({origin:Ie.IFRAME_SECURE_ORGIN}).off(G+t(this,Wt,"f"),l))};this.bus.target({origin:Ie.IFRAME_SECURE_ORGIN}).on(G+t(this,Wt,"f"),l),document.body.append(this.iframe),t(this,di,"f").call(this)}}function hi(e){this.message=e}Wt=new WeakMap,zt=new WeakMap,Ht=new WeakMap,Kt=new WeakMap,$t=new WeakMap,qt=new WeakMap,Jt=new WeakMap,Zt=new WeakMap,Qt=new WeakMap,ei=new WeakMap,ti=new WeakMap,ii=new WeakMap,ni=new WeakMap,si=new WeakMap,oi=new WeakMap,ri=new WeakMap,ai=new WeakMap,li=new WeakMap,di=new WeakMap,hi.prototype=new Error,hi.prototype.name="InvalidCharacterError";var Ii="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new hi("'atob' failed: The string to be decoded is not correctly encoded.");for(var i,n,s=0,o=0,r="";n=t.charAt(o++);~n&&(i=s%4?64*i+n:n,s++%4)?r+=String.fromCharCode(255&i>>(-2*s&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return r};function pi(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(Ii(e).replace(/(.)/g,(function(e,t){var i=t.charCodeAt(0).toString(16).toUpperCase();return i.length<2&&(i="0"+i),"%"+i})))}(t)}catch(e){return Ii(t)}}function fi(e){this.message=e}fi.prototype=new Error,fi.prototype.name="InvalidTokenError";const vi=e=>{try{if(!e)return!1;if(t=e,"[object String]"!==Object.prototype.toString.call(t))return!1;let i=!1;const n=function(e,t){if("string"!=typeof e)throw new fi("Invalid token specified");var i=!0===(t=t||{}).header?0:1;try{return JSON.parse(pi(e.split(".")[i]))}catch(e){throw new fi("Invalid token specified: "+e.message)}}(e),s=(new Date).getTime()/1e3,o=n.exp;return o&&s>o&&(i=!0),!i}catch(e){return!1}var t};var mi,Ni,Ti,yi,Oi,Ai,Li,gi,Ri,Si,Ci={name:"skyflow-js",preferGlobal:!0,analyze:!1,version:"1.30.1",author:"Skyflow",description:"Skyflow JavaScript SDK"};class Di{constructor(e,n){mi.set(this,void 0),this.request=e=>new Promise(((i,n)=>{var s,o,r,a;const l=new XMLHttpRequest;if(l){if(l.open(e.requestMethod,e.url),e.headers){const i=function(e,t,i){var n,s,o,r,a;const l={sdkName:e.name,sdkVersion:e.version},d=function(e,t){return""!==e?`${e}`:`${t.sdkName}@${t.sdkVersion}`}(t.sdkVersion,l),c=function(e){var t,i,n,s,o,r,a,l,d,c,u,E;let _=null,h=null;return/Windows/.test(e)?(_="Windows",h=null!==(i=null===(t=/Windows NT (\d+\.\d+)/.exec(e))||void 0===t?void 0:t[1])&&void 0!==i?i:null):/Android/.test(e)?(_="Android",h=null!==(s=null===(n=/Android (\d+\.\d+)/.exec(e))||void 0===n?void 0:n[1])&&void 0!==s?s:null):/iOS/.test(e)||/iPhone/.test(e)?(_="iOS",h=null!==(a=null===(r=null===(o=/OS (\d+[._]\d+[._]?\d*)/.exec(e))||void 0===o?void 0:o[1])||void 0===r?void 0:r.replace(/_/g,"."))&&void 0!==a?a:null):/Mac OS X/.test(e)?(_="Mac OS X",h=null!==(c=null===(d=null===(l=/Mac OS X (\d+([._]\d+)*)/.exec(e))||void 0===l?void 0:l[1])||void 0===d?void 0:d.replace(/_/g,"."))&&void 0!==c?c:null):/Linux/.test(e)&&(_="Linux",h=null!==(E=null===(u=/Linux( \w+)*?\/([\w.]+)/.exec(e))||void 0===u?void 0:u[2])&&void 0!==E?E:null),{os:_,version:h}}(i.userAgent),u=function(e){let t="",i="";if(-1!==e.indexOf("MSIE")||-1!==e.indexOf("Trident/")){t="Internet Explorer";const n=e.match(/(MSIE|rv:)\s?([\d.]+)/);n&&(i=n[2])}else if(-1!==e.indexOf("Edge")){t="Microsoft Edge";const n=e.match(/Edge\/([\d.]+)/);n&&(i=n[1])}else if(-1!==e.indexOf("Chrome")){t="Google Chrome";const n=e.match(/Chrome\/([\d.]+)/);n&&(i=n[1])}else if(-1!==e.indexOf("Firefox")){t="Mozilla Firefox";const n=e.match(/Firefox\/([\d.]+)/);n&&(i=n[1])}else if(-1!==e.indexOf("Safari")){t="Apple Safari";const n=e.match(/Version\/([\d.]+)/);n&&(i=n[1])}return{browserName:t,browserVersion:i}}(i.userAgent);var E;return{sdk_name_version:d,sdk_client_device_model:(E=i.userAgent,/(ipad|tablet)/gi.test(E)?"tablet":/Mobile|iP(hone|od)|Android|BlackBerry|IEMobile/.test(E)?"mobile":"desktop"),sdk_os_version:null!==(n=i.platform)&&void 0!==n?n:`${null!==(s=c.os)&&void 0!==s?s:""} ${null!==(o=c.version)&&void 0!==o?o:""}`,sdk_runtime_details:`${null!==(r=u.browserName)&&void 0!==r?r:""} ${null!==(a=u.browserVersion)&&void 0!==a?a:""}`}}(Ci,t(this,mi,"f"),navigator);e.headers["sky-metadata"]=JSON.stringify(i);const{headers:n}=e;Object.keys(e.headers).forEach((e=>{"content-type"===e&&n[e]&&n[e].includes(ue.FORMDATA)||l.setRequestHeader(e,n[e])}))}(null===(o=null===(s=e.headers)||void 0===s?void 0:s["content-type"])||void 0===o?void 0:o.includes(ue.FORMURLENCODED))||(null===(a=null===(r=e.headers)||void 0===r?void 0:r["content-type"])||void 0===a?void 0:a.includes(ue.FORMDATA))?l.send(e.body):l.send(JSON.stringify(Object.assign({},e.body))),l.onload=()=>{var e,t,s;const o=l.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};o.forEach((e=>{const t=e.split(": "),i=t.shift()||"",n=t.join(": ");r[i]=n}));const a=r["content-type"],d=r["x-request-id"];if(l.status<200||l.status>=400)if(a&&a.includes("application/json")){let i=JSON.parse(l.response);(null===(e=null==i?void 0:i.error)||void 0===e?void 0:e.message)&&(i=d?`${null===(t=null==i?void 0:i.error)||void 0===t?void 0:t.message} - requestId: ${d}`:null===(s=null==i?void 0:i.error)||void 0===s?void 0:s.message),n(new xe({code:l.status,description:i},[],!0))}else a&&a.includes("text/plain")?n(new xe({code:l.status,description:d?`${l.response} - requestId: ${d}`:l.response},[],!0)):n(new xe({code:l.status,description:d?`${x.ERROR_OCCURED} - requestId: ${d}`:x.ERROR_OCCURED},[],!0));a&&a.includes("application/json")&&i(JSON.parse(l.response)),i(l.response)},l.onerror=()=>{n(new xe(Ye.NETWORK_ERROR,[],!0))}}else n(new xe(Ye.CONNECTION_ERROR,[],!0))})),this.config=e,i(this,mi,n,"f")}toJSON(){return{config:this.config,metaData:t(this,mi,"f")}}static fromJSON(e){return new Di(e.config,e.metaData)}}mi=new WeakMap,function(e){e.COLLECT="COLLECT",e.COMPOSABLE="COMPOSABLE"}(Si||(Si={}));const bi="Skyflow";class Pi{constructor(e){var n,s;Ni.set(this,void 0),Ti.set(this,Ot()),yi.set(this,{uuid:t(this,Ti,"f"),clientDomain:window.location.origin}),Oi.set(this,""),Ai.set(this,void 0),Li.set(this,void 0),gi.set(this,void 0),Ri.set(this,void 0),this.bus=U.getEventBus();const o=localStorage.getItem("sdk_version")||"";t(this,yi,"f").sdkVersion=o,i(this,Ni,new Di(Object.assign({},e),t(this,yi,"f")),"f"),i(this,Li,(null===(n=null==e?void 0:e.options)||void 0===n?void 0:n.logLevel)||Re.ERROR,"f"),i(this,gi,(null===(s=null==e?void 0:e.options)||void 0===s?void 0:s.env)||Se.PROD,"f"),i(this,Ri,{},"f");this.bus.target({origin:Ie.IFRAME_SECURE_ORGIN}).on(H+t(this,Ti,"f"),((e,n)=>{we(Ue(k.CAPTURED_BEARER_TOKEN_EVENT,bi),Ce.LOG,t(this,Li,"f")),!t(this,Ni,"f").config.getBearerToken||t(this,Oi,"f")&&vi(t(this,Oi,"f"))?(we(Ue(k.REUSE_BEARER_TOKEN,bi),Ce.LOG,t(this,Li,"f")),n({authToken:t(this,Oi,"f")})):t(this,Ni,"f").config.getBearerToken().then((e=>{vi(e)?(we(Ue(k.BEARER_TOKEN_RESOLVED,bi),Ce.LOG,t(this,Li,"f")),i(this,Oi,e,"f"),n({authToken:t(this,Oi,"f")})):(we(x.INVALID_BEARER_TOKEN,Ce.ERROR,t(this,Li,"f")),n({error:x.INVALID_BEARER_TOKEN}))})).catch((e=>{we(x.BEARER_TOKEN_REJECTED,Ce.ERROR,t(this,Li,"f")),n({error:e})}))})),we(Ue(k.BEARER_TOKEN_LISTENER,bi),Ce.LOG,t(this,Li,"f")),we(Ue(k.CURRENT_ENV,bi,t(this,gi,"f")),Ce.LOG,t(this,Li,"f")),we(Ue(k.CURRENT_LOG_LEVEL,bi,t(this,Li,"f")),Ce.LOG,t(this,Li,"f"))}static init(e){var t;const i=(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||Re.ERROR;He(e),we(Ue(k.INITIALIZE_CLIENT,bi),Ce.LOG,i);const n=e;var s;n.vaultURL="string"!=typeof(s=e.vaultURL)?s:"/"===(null==s?void 0:s.trim().slice(-1))?s.slice(0,-1):s.trim();const o=new Pi(n);return we(Ue(k.CLIENT_INITIALIZED,bi),Ce.LOG,i),o}container(e,i){switch(e){case Si.COLLECT:{const n=new Yt(i,Object.assign(Object.assign({},t(this,yi,"f")),{clientJSON:t(this,Ni,"f").toJSON(),containerType:e}),t(this,Ri,"f"),{logLevel:t(this,Li,"f"),env:t(this,gi,"f")});return we(Ue(k.COLLECT_CONTAINER_CREATED,bi),Ce.LOG,t(this,Li,"f")),n}case Si.COMPOSABLE:{(e=>{if(!e)throw new xe(Ye.MISSING_COMPOSABLE_CONTAINER_OPTIONS,[],!0);if("object"!=typeof e)throw new xe(Ye.INVALID_COMPOSABLE_CONTAINER_OPTIONS,[],!0);if(!Object.prototype.hasOwnProperty.call(e,"layout"))throw new xe(Ye.MISSING_COMPOSABLE_LAYOUT_KEY,[],!0);if(!e.layout)throw new xe(Ye.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(!Array.isArray(e.layout))throw new xe(Ye.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(0===e.layout.length)throw new xe(Ye.EMPTY_COMPOSABLE_LAYOUT_ARRAY,[],!0);e.layout.forEach((e=>{if("number"!=typeof e)throw new xe(Ye.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(e<0)throw new xe(Ye.NEGATIVE_VALUES_COMPOSABLE_LAYOUT,[],!0)}))})(i);const n=new _i(i,Object.assign(Object.assign({},t(this,yi,"f")),{clientJSON:t(this,Ni,"f").toJSON(),containerType:e}),t(this,Ri,"f"),{logLevel:t(this,Li,"f"),env:t(this,gi,"f")});return we(Ue(k.COLLECT_CONTAINER_CREATED,bi),Ce.LOG,t(this,Li,"f")),n}default:if(!e)throw new xe(Ye.EMPTY_CONTAINER_TYPE,[],!0);throw new xe(Ye.INVALID_CONTAINER_TYPE,[],!0)}}static get ContainerType(){return Si}static get ElementType(){return Z}static get RedactionType(){return Ae}static get RequestMethod(){return Le}static get LogLevel(){return Re}static get EventName(){return ge}static get Env(){return Se}static get ValidationRuleType(){return De}}function Mi(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseURL&&(t=e.sdkBaseURL,delete e.sdkBaseURL),function(e){var t=e["merchant-id"],i=e["data-merchant-id"],n="",s="";Array.isArray(t)?t.length>1?(n="*",s=t.toString()):n=t.toString():"string"==typeof t&&t.length>0?n=t:"string"==typeof i&&i.length>0&&(n="*",s=i);e["merchant-id"]=n,e["data-merchant-id"]=s}(e);var i=Object.keys(e).filter((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})).reduce((function(t,i){var n=e[i].toString();return"data-"===i.substring(0,5)?t.dataAttributes[i]=n:t.queryParams[i]=n,t}),{queryParams:{},dataAttributes:{}}),n=i.queryParams,s=i.dataAttributes;return{url:"".concat(t,"?").concat(wi(n)),dataAttributes:s}}function wi(e){var t="";return Object.keys(e).forEach((function(i){0!==t.length&&(t+="&"),t+=i+"="+e[i]})),t}function Ui(e,t){void 0===t&&(t={});var i=document.createElement("script");return i.src=e,Object.keys(t).forEach((function(e){i.setAttribute(e,t[e]),"data-csp-nonce"===e&&i.setAttribute("nonce",t["data-csp-nonce"])})),i}function ki(e,t){if(void 0===t&&(t=xi()),Fi(e,t),"undefined"==typeof window)return t.resolve(null);var i=Mi(e),n=i.url,s=i.dataAttributes,o=s["data-namespace"]||"paypal",r=Yi(o);
4
+ */const fe={IFRAME_SECURE_SITE:"https://js.skyflow.com/v1/elements/index.html",IFRAME_SECURE_ORGIN:"https://js.skyflow.com"},ve="https://assets.payrails.io/8f2cbee/card/index.html",me="https://assets.payrails.io",Ne={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no",style:"width: 100%;",allow:"clipboard-read; clipboard-write"},Te=(e,t)=>{Object.keys(t).forEach((i=>{if(Object.prototype.hasOwnProperty.call(t,i)){const n=t[i];null==n?e.removeAttribute(i):e.setAttribute(i,n)}}))};var ye=(e={})=>{const t=document.createElement("iframe"),i=Object.assign(Object.assign({},Ne),e);return Object.assign(t.style,se),Te(t,i),t.getAttribute("id")||(t.id=t.name),t};const Oe=()=>fe.IFRAME_SECURE_SITE,Ae=(e,t)=>{Object.keys(t).forEach((i=>{Object.prototype.hasOwnProperty.call(t,i)&&(e.style[i]=t[i])}))};function Le(e){return JSON.parse(JSON.stringify(e))}var Re,ge,Se,Ce,De,Pe,be;!function(e){e.DEFAULT="DEFAULT",e.PLAIN_TEXT="PLAIN_TEXT",e.MASKED="MASKED",e.REDACTED="REDACTED"}(Re||(Re={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.PATCH="PATCH",e.DELETE="DELETE"}(ge||(ge={})),function(e){e.CHANGE="CHANGE",e.READY="READY",e.FOCUS="FOCUS",e.BLUR="BLUR",e.SUBMIT="SUBMIT"}(Se||(Se={})),function(e){e.WARN="WARN",e.INFO="INFO",e.DEBUG="DEBUG",e.ERROR="ERROR"}(Ce||(Ce={})),function(e){e.DEV="DEV",e.PROD="PROD"}(De||(De={})),function(e){e.LOG="LOG",e.WARN="WARN",e.ERROR="ERROR"}(Pe||(Pe={})),function(e){e.REGEX_MATCH_RULE="REGEX_MATCH_RULE",e.LENGTH_MATCH_RULE="LENGTH_MATCH_RULE",e.ELEMENT_VALUE_MATCH_RULE="ELEMENT_VALUE_MATCH_RULE"}(be||(be={}));const Me={DEBUG:{showDebugLogs:!0,showInfoLogs:!0,showWarnLogs:!0,showErrorLogs:!0},INFO:{showDebugLogs:!1,showInfoLogs:!0,showWarnLogs:!0,showErrorLogs:!0},WARN:{showDebugLogs:!1,showInfoLogs:!1,showWarnLogs:!0,showErrorLogs:!0},ERROR:{showDebugLogs:!1,showInfoLogs:!1,showWarnLogs:!1,showErrorLogs:!0}},we={PROD:{doesReturnValue:!1},DEV:{doesReturnValue:!0}},Ue="[Skyflow]",ke=(e,t,i)=>{if(i&&Me[i]){const{showDebugLogs:n,showInfoLogs:o,showWarnLogs:s,showErrorLogs:r}=Me[i];t===Pe.LOG&&n?console.log(`${Ce.DEBUG}: ${Ue} ${e}`):t===Pe.LOG&&o?console.log(`${Ce.INFO}: ${Ue} ${e}`):t===Pe.WARN&&s?console.warn(`${Ce.WARN}: ${Ue} ${e}`):t===Pe.ERROR&&r&&console.error(`${Ce.ERROR}: ${Ue} ${e}`)}},xe=(...e)=>{const t=e[0],i=e.filter(((e,t)=>0!==t));return t?t.replace(/%s[0-9]+/g,(e=>{const t=e.replace("%s","")-1;return i[t]})):""},Ye=(e="")=>{const t=e.split(":");if("group"===t[1])return"composable container";let i=atob(t[2]);return-1!==i.indexOf(":")&&(i=i.substring(0,i.indexOf(":"))),i};class Fe extends Error{constructor(e,t,i=!1){const n={code:e.code,description:t&&(null==t?void 0:t.length)>0?xe(e.description,...t):e.description};super(n.description),i?this.error=n:this.errors=[n]}}const Ve={INVALID_FIELD:{code:400,description:F.INVALID_FIELD},VAULTID_IS_REQUIRED:{code:400,description:F.VAULTID_IS_REQUIRED},EMPTY_VAULTID_IN_INIT:{code:400,description:F.EMPTY_VAULTID_IN_INIT},VAULTURL_IS_REQUIRED:{code:400,description:F.VAULTURL_IS_REQUIRED},EMPTY_VAULTURL_IN_INIT:{code:400,description:F.EMPTY_VAULTURL_IN_INIT},INVALID_VAULTURL_IN_INIT:{code:400,description:F.INVALID_VAULTURL_IN_INIT},GET_BEARER_TOKEN_IS_REQUIRED:{code:400,description:F.GET_BEARER_TOKEN_IS_REQUIRED},EMPTY_CONTAINER_TYPE:{code:400,description:F.EMPTY_CONTAINER_TYPE},INVALID_CONTAINER_TYPE:{code:400,description:F.INVALID_CONTAINER_TYPE},UNIQUE_ELEMENT_NAME:{code:400,description:F.UNIQUE_ELEMENT_NAME},ELEMENTS_NOT_MOUNTED:{code:400,description:F.ELEMENTS_NOT_MOUNTED},MISSING_TABLE_IN_COLLECT:{code:400,description:F.MISSING_TABLE_IN_COLLECT},EMPTY_TABLE_IN_COLLECT:{code:400,description:F.EMPTY_TABLE_IN_COLLECT},EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:{code:400,description:F.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS},INVALID_TABLE_IN_COLLECT:{code:400,description:F.INVALID_TABLE_IN_COLLECT},INVALID_SKYFLOWID_IN_COLLECT:{code:400,description:F.INVALID_SKYFLOWID_IN_COLLECT},MISSING_COLUMN_IN_COLLECT:{code:400,description:F.MISSING_COLUMN_IN_COLLECT},EMPTY_COLUMN_IN_COLLECT:{code:400,description:F.EMPTY_TABLE_IN_COLLECT},INVALID_COLUMN_IN_COLLECT:{code:400,description:F.INVALID_COLUMN_IN_COLLECT},CLIENT_CONNECTION:{code:400,description:F.CLIENT_CONNECTION},RECORDS_KEY_NOT_FOUND:{code:404,description:F.RECORDS_KEY_NOT_FOUND},EMPTY_RECORDS_IN_INSERT:{code:400,description:F.EMPTY_RECORDS_IN_INSERT},INVALID_RECORDS_IN_INSERT:{code:404,description:F.INVALID_RECORDS_IN_INSERT},INVALID_TABLE_IN_INSERT:{code:400,description:F.INVALID_TABLE_IN_INSERT},EMPTY_TABLE_IN_INSERT:{code:400,description:F.EMPTY_TABLE_IN_INSERT},MISSING_TABLE_IN_INSERT:{code:400,description:F.MISSING_TABLE_IN_INSERT},EMPTY_FIELDS_IN_INSERT:{code:400,description:F.EMPTY_FIELDS_IN_INSERT},MISSING_FIELDS_IN_INSERT:{code:404,description:F.MISSING_FIELDS_IN_INSERT},INVALID_FIELDS_IN_INSERT:{code:404,description:F.INVALID_FIELDS_IN_INSERT},INVALID_TOKENS_IN_INSERT:{code:404,description:F.INVALID_TOKENS_IN_INSERT},RECORDS_KEY_NOT_FOUND_DETOKENIZE:{code:404,description:F.RECORDS_KEY_NOT_FOUND_DETOKENIZE},EMPTY_RECORDS_DETOKENIZE:{code:400,description:F.EMPTY_RECORDS_DETOKENIZE},INVALID_RECORDS_IN_DETOKENIZE:{code:404,description:F.INVALID_RECORDS_IN_DETOKENIZE},MISSING_TOKEN_IN_DETOKENIZE:{code:400,description:F.MISSING_TOKEN_IN_DETOKENIZE},INVALID_TOKEN_IN_DETOKENIZE:{code:400,description:F.INVALID_TOKEN_IN_DETOKENIZE},RECORDS_KEY_NOT_FOUND_GET:{code:400,description:F.RECORDS_KEY_NOT_FOUND_GET},INVALID_RECORDS_IN_GET:{code:400,description:F.INVALID_RECORDS_IN_GET},EMPTY_RECORDS_GET:{code:400,description:F.EMPTY_RECORDS_GET},MISSING_IDS_IN_GET:{code:400,description:F.MISSING_IDS_IN_GET},INVALID_IDS_IN_GET:{code:400,description:F.INVALID_IDS_IN_GET},INVALID_COLUMN_VALUES_IN_GET:{code:400,description:F.INVALID_COLUMN_VALUES_IN_GET},EMPTY_IDS_IN_GET:{code:400,description:F.EMPTY_IDS_IN_GET},INVALID_SKYFLOWID_TYPE_IN_GET:{code:400,description:F.INVALID_SKYFLOWID_TYPE_IN_GET},MISSING_TABLE_IN_GET:{code:400,description:F.MISSING_TABLE_IN_GET},INVALID_TABLE_IN_GET:{code:400,description:F.INVALID_TABLE_IN_GET},MISSING_REDACTION_IN_GET:{code:400,description:F.MISSING_REDACTION_IN_GET},INVALID_REDACTION_TYPE_IN_GET:{code:400,description:F.INVALID_REDACTION_TYPE_IN_GET},INVALID_TOKENS_IN_GET:{code:400,description:F.INVALID_TOKENS_IN_GET},TOKENS_GET_COLUMN_NOT_SUPPORTED:{code:400,description:F.TOKENS_GET_COLUMN_NOT_SUPPORTED},REDACTION_WITH_TOKENS_NOT_SUPPORTED:{code:400,description:F.REDACTION_WITH_TOKENS_NOT_SUPPORTED},INVALID_REDACTION_TYPE_IN_DETOKENIZE:{code:400,description:F.INVALID_REDACTION_TYPE_IN_DETOKENIZE},INVALID_TOKENS_IN_COLLECT:{code:404,description:F.INVALID_TOKENS_IN_COLLECT},RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS:{code:404,description:F.RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS},INVALID_RECORDS_IN_ADDITIONAL_FIELDS:{code:404,description:F.INVALID_RECORDS_IN_ADDITIONAL_FIELDS},EMPTY_RECORDS_IN_ADDITIONAL_FIELDS:{code:400,description:F.EMPTY_RECORDS_IN_ADDITIONAL_FIELDS},MISSING_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:F.MISSING_TABLE_IN_ADDITIONAL_FIELDS},INVALID_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:F.INVALID_TABLE_IN_ADDITIONAL_FIELDS},INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:{code:400,description:F.INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS},MISSING_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:F.MISSING_FIELDS_IN_ADDITIONAL_FIELDS},INVALID_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:F.INVALID_FIELDS_IN_ADDITIONAL_FIELDS},RECORDS_KEY_NOT_FOUND_DELETE:{code:400,description:F.RECORDS_KEY_NOT_FOUND_DELETE},EMPTY_RECORDS_IN_DELETE:{code:400,description:F.EMPTY_RECORDS_IN_DELETE},INVALID_RECORDS_IN_DELETE:{code:404,description:F.INVALID_RECORDS_IN_DELETE},INVALID_TABLE_IN_DELETE:{code:400,description:F.INVALID_TABLE_IN_DELETE},EMPTY_TABLE_IN_DELETE:{code:400,description:F.EMPTY_TABLE_IN_DELETE},MISSING_TABLE_IN_DELETE:{code:400,description:F.MISSING_TABLE_IN_DELETE},EMPTY_ID_IN_DELETE:{code:400,description:F.EMPTY_ID_IN_DELETE},MISSING_ID_IN_DELETE:{code:404,description:F.MISSING_ID_IN_DELETE},INVALID_ID_IN_DELETE:{code:404,description:F.INVALID_ID_IN_DELETE},EMPTY_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:F.EMPTY_TABLE_IN_ADDITIONAL_FIELDS},EMPTY_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:F.EMPTY_FIELDS_IN_ADDITIONAL_FIELDS},EMPTY_TOKEN_IN_DETOKENIZE:{code:400,description:F.EMPTY_TOKEN_IN_DETOKENIZE},EMPTY_SKYFLOWID_IN_GET:{code:400,description:F.EMPTY_SKYFLOWID_IN_GET},EMPTY_TABLE_IN_GET:{code:400,description:F.EMPTY_TABLE_IN_GET},EMPTY_REDACTION_TYPE_IN_GET:{code:400,description:F.EMPTY_REDACTION_TYPE_IN_GET},DUPLICATE_ELEMENT:{code:400,description:F.DUPLICATE_ELEMENT},DUPLICATE_ELEMENT_ADDITIONAL_FIELDS:{code:400,description:F.DUPLICATE_ELEMENT_ADDITIONAL_FIELDS},MISSING_ELEMENT_TYPE:{code:400,description:F.MISSING_ELEMENT_TYPE},EMPTY_ELEMENT_TYPE:{code:400,description:F.EMPTY_ELEMENT_TYPE},INVALID_ELEMENT_TYPE:{code:400,description:F.INVALID_ELEMENT_TYPE},INVALID_ELEMENT_SELECTOR:{code:400,description:F.INVALID_ELEMENT_SELECTOR},FRAME_NOT_FOUND:{code:400,description:F.FRAME_NOT_FOUND},REQUIRED_PARAMS_NOT_PROVIDED:{code:400,description:F.REQUIRED_PARAMS_NOT_PROVIDED},INVALID_RECORD_COLUMN_VALUE:{code:400,description:F.INVALID_RECORD_COLUMN_VALUE},MISSING_RECORD_COLUMN_VALUE:{code:400,description:F.MISSING_RECORD_COLUMN_VALUE},MISSING_RECORD_COLUMN_NAME:{code:400,description:F.MISSING_RECORD_COLUMN_NAME},INVALID_EVENT_TYPE:{code:400,description:F.INVALID_EVENT_TYPE},INVALID_EVENT_LISTENER:{code:400,description:F.INVALID_EVENT_LISTENER},MISSING_HANDLER_IN_EVENT_LISTENER:{code:400,description:F.MISSING_HANDLER_IN_EVENT_LISTENER},INVALID_HANDLER_IN_EVENT_LISTENER:{code:400,description:F.INVALID_HANDLER_IN_EVENT_LISTENER},UNKNOWN_ERROR:{code:400,description:F.UNKNOWN_ERROR},CONNECTION_ERROR:{code:400,description:F.CONNECTION_ERROR},NETWORK_ERROR:{code:500,description:F.NETWORK_ERROR},COMPLETE_AND_VALID_INPUTS:{code:400,description:F.COMPLETE_AND_VALID_INPUTS},INVALID_VALIDATIONS_TYPE:{code:400,description:F.INVALID_VALIDATIONS_TYPE},MISSING_VALIDATION_RULE_TYPE:{code:400,description:F.MISSING_VALIDATION_RULE_TYPE},INVALID_VALIDATION_RULE_TYPE:{code:400,description:F.INVALID_VALIDATION_RULE_TYPE},MISSING_VALIDATION_RULE_PARAMS:{code:400,description:F.MISSING_VALIDATION_RULE_PARAMS},INVALID_VALIDATION_RULE_PARAMS:{code:400,description:F.INVALID_VALIDATION_RULE_PARAMS},MISSING_REGEX_IN_REGEX_MATCH_RULE:{code:400,description:F.MISSING_REGEX_IN_REGEX_MATCH_RULE},INVALID_REGEX_IN_REGEX_MATCH_RULE:{code:400,description:F.INVALID_REGEX_IN_REGEX_MATCH_RULE},MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE:{code:400,description:F.MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE},MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE:{code:400,description:F.MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE},INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE:{code:400,description:F.INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE},ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE:{code:400,description:F.ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE},EMPTY_ELEMENT_IN_MOUNT:{code:400,description:F.EMPTY_ELEMENT_IN_MOUNT},INVALID_TABLE_IN_UPSERT_OPTION:{code:400,description:F.INVALID_TABLE_IN_UPSERT_OPTION},INVALID_COLUMN_IN_UPSERT_OPTION:{code:400,description:F.INVALID_COLUMN_IN_UPSERT_OPTION},INVALID_UPSERT_OPTION_TYPE:{code:400,description:F.INVALID_UPSERT_OPTION_TYPE},EMPTY_UPSERT_OPTIONS_ARRAY:{code:400,description:F.EMPTY_UPSERT_OPTIONS_ARRAY},INVALID_UPSERT_OPTION_OBJECT_TYPE:{code:400,description:F.INVALID_UPSERT_OPTION_OBJECT_TYPE},MISSING_TABLE_IN_UPSERT_OPTION:{code:400,description:F.MISSING_TABLE_IN_UPSERT_OPTION},MISSING_COLUMN_IN_UPSERT_OPTION:{code:400,description:F.MISSING_COLUMN_IN_UPSERT_OPTION},INVALID_RECORD_COLUMN_VALUE_TYPE:{code:400,description:F.INVALID_RECORD_COLUMN_VALUE_TYPE},INVALID_COLUMN_VALUES_TYPE:{code:400,description:F.INVALID_COLUMN_VALUES_TYPE},EMPTY_RECORD_COLUMN_VALUES:{code:400,description:F.EMPTY_RECORD_COLUMN_VALUES},EMPTY_COLUMN_VALUE:{code:400,description:F.EMPTY_COLUMN_VALUE},MISSING_IDS_OR_COLUMN_VALUES_IN_GET:{code:400,description:F.MISSING_IDS_OR_COLUMN_VALUES_IN_GET},SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED:{code:400,description:F.SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED},RECORDS_KEY_NOT_FOUND_GETBYID:{code:400,description:F.RECORDS_KEY_NOT_FOUND_GETBYID},INVALID_RECORDS_IN_GETBYID:{code:400,description:F.INVALID_RECORDS_IN_GETBYID},EMPTY_RECORDS_GETBYID:{code:400,description:F.EMPTY_RECORDS_GETBYID},MISSING_IDS_IN_GETBYID:{code:400,description:F.MISSING_IDS_IN_GETBYID},INVALID_IDS_IN_GETBYID:{code:400,description:F.INVALID_IDS_IN_GETBYID},EMPTY_IDS_IN_GETBYID:{code:400,description:F.EMPTY_IDS_IN_GETBYID},INVALID_SKYFLOWID_TYPE_IN_GETBYID:{code:400,description:F.INVALID_SKYFLOWID_TYPE_IN_GETBYID},MISSING_TABLE_IN_GETBYID:{code:400,description:F.MISSING_TABLE_IN_GETBYID},INVALID_TABLE_IN_GETBYID:{code:400,description:F.INVALID_TABLE_IN_GETBYID},MISSING_REDACTION_IN_GETBYID:{code:400,description:F.MISSING_REDACTION_IN_GETBYID},INVALID_REDACTION_TYPE_IN_GETBYID:{code:400,description:F.INVALID_REDACTION_TYPE_IN_GETBYID},EMPTY_SKYFLOWID_IN_GETBYID:{code:400,description:F.EMPTY_SKYFLOWID_IN_GETBYID},EMPTY_TABLE_IN_GETBYID:{code:400,description:F.EMPTY_TABLE_IN_GETBYID},EMPTY_REDACTION_TYPE_IN_GETBYID:{code:400,description:F.EMPTY_REDACTION_TYPE_IN_GETBYID},MISSING_COMPOSABLE_LAYOUT_KEY:{code:400,description:F.MISSING_COMPOSABLE_LAYOUT_KEY},EMPTY_COMPOSABLE_LAYOUT_ARRAY:{code:400,description:F.EMPTY_COMPOSABLE_LAYOUT_ARRAY},INVALID_COMPOSABLE_LAYOUT_TYPE:{code:400,description:F.INVALID_COMPOSABLE_LAYOUT_TYPE},NEGATIVE_VALUES_COMPOSABLE_LAYOUT:{code:400,description:F.NEGATIVE_VALUES_COMPOSABLE_LAYOUT},MISMATCH_ELEMENT_COUNT_LAYOUT_SUM:{code:400,description:F.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM},MISSING_COMPOSABLE_CONTAINER_OPTIONS:{code:400,description:F.MISSING_COMPOSABLE_CONTAINER_OPTIONS},INVALID_COMPOSABLE_CONTAINER_OPTIONS:{code:400,description:F.INVALID_COMPOSABLE_CONTAINER_OPTIONS},COMPOSABLE_CONTAINER_NOT_MOUNTED:{code:400,description:F.COMPOSABLE_CONTAINER_NOT_MOUNTED},INVALID_BOOLEAN_OPTIONS:{code:400,description:F.INVALID_BOOLEAN_OPTIONS},EMPTY_COLLECT_CUSTOM_FORMAT:{code:400,description:F.EMPTY_COLLECT_CUSTOM_FORMAT},INVALID_INPUT_OPTIONS_FORMAT:{code:400,description:F.INVALID_INPUT_OPTIONS_FORMAT},INVALID_INPUT_OPTIONS_TRANSLATION:{code:400,description:F.INVALID_INPUT_OPTIONS_TRANSLATION}},Be=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new Fe(Ve.RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS,[],!0);const{records:t}=e;if(!t||!Array.isArray(t))throw new Fe(Ve.INVALID_RECORDS_IN_ADDITIONAL_FIELDS,[],!0);if(0===t.length)throw new Fe(Ve.EMPTY_RECORDS_IN_ADDITIONAL_FIELDS,[],!0);t.forEach(((e,t)=>{var i,n,o,s;if(!e||!Object.prototype.hasOwnProperty.call(e,"table"))throw new Fe(Ve.MISSING_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!e.table)throw new Fe(Ve.EMPTY_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(void 0!==(null===(i=e.fields)||void 0===i?void 0:i.skyflowID)){if(!(null===(n=e.fields)||void 0===n?void 0:n.skyflowID))throw new Fe(Ve.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!("string"==typeof(null===(o=e.fields)||void 0===o?void 0:o.skyflowID)||(null===(s=e.fields)||void 0===s?void 0:s.skyflowID)instanceof String))throw new Fe(Ve.INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[`${t}`],!0)}if(!("string"==typeof e.table||e.table instanceof String))throw new Fe(Ve.INVALID_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"fields"))throw new Fe(Ve.MISSING_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!e.fields)throw new Fe(Ve.EMPTY_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if("object"!=typeof e.fields||Array.isArray(e.fields))throw new Fe(Ve.INVALID_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0)}))},Ge=e=>{let t=!0;try{new RegExp(e)}catch(e){t=!1}return t},je=e=>{if(!Object.prototype.hasOwnProperty.call(e,"getBearerToken"))throw new Fe(Ve.GET_BEARER_TOKEN_IS_REQUIRED,[],!0)},Xe=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new Fe(Ve.MISSING_ELEMENT_TYPE,[],!0);if(!e.type)throw new Fe(Ve.EMPTY_ELEMENT_TYPE,[],!0);if(Object.prototype.hasOwnProperty.call(e,"altText")&&ke(V.COLLECT_ALT_TEXT_DEPERECATED,Pe.WARN,t),Object.prototype.hasOwnProperty.call(e,"skyflowID")&&"string"!=typeof e.skyflowID)throw new Fe(Ve.INVALID_SKYFLOWID_IN_COLLECT,[],!0)},He=e=>{if(!e||!Array.isArray(e))throw new Fe(Ve.INVALID_UPSERT_OPTION_TYPE,[],!0);if(!e.length)throw new Fe(Ve.EMPTY_UPSERT_OPTIONS_ARRAY,[],!0);e.forEach(((e,t)=>{if(!e||"object"!=typeof e)throw new Fe(Ve.INVALID_UPSERT_OPTION_OBJECT_TYPE,[t],!0);if(!Object.prototype.hasOwnProperty.call(e,"table"))throw new Fe(Ve.MISSING_TABLE_IN_UPSERT_OPTION,[t],!0);if(!e.table||"string"!=typeof e.table||!e.table.length)throw new Fe(Ve.INVALID_TABLE_IN_UPSERT_OPTION,[t],!0);if(!Object.prototype.hasOwnProperty.call(e,"column"))throw new Fe(Ve.MISSING_COLUMN_IN_UPSERT_OPTION,[t],!0);if(!e.column||"string"!=typeof e.column||!e.column.length)throw new Fe(Ve.INVALID_COLUMN_IN_UPSERT_OPTION,[t],!0)}))},We=e=>"boolean"==typeof e;function ze(e){const t=e.split(":");return t.length>2?(t.pop(),t.pop(),t.join(":")):""}const Ke=(e,t,i)=>{if("string"!=typeof e)return e;if(t===ee.CARD_NUMBER){if(e=e&&e.replace(/\s/g,""),!i){const t=((e="")=>{const t=e.replace(/[\s-]/g,"");let i=te.DEFAULT;return Object.entries(de).forEach((([e,n])=>{n.regex.test(t)&&(i=e)})),i})(e),i=t!==te.DEFAULT&&t===te.AMEX?6:8;return e.length>i?e.replace(new RegExp(`.(?=.{0,${(null==e?void 0:e.length)-i-1}}$)`,"g"),"X"):e}return e}return i?e:void 0};function $e(e){var t,i,n,o,a;if((null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.customElementsURL)&&(e=>{if(!e||"https"!==e.substring(0,5).toLowerCase())return!1;try{if(new URL(e))return!0}catch(e){return!1}return!0})(null===(i=null==e?void 0:e.options)||void 0===i?void 0:i.customElementsURL)){const t=null===(n=null==e?void 0:e.options)||void 0===n?void 0:n.customElementsURL,i=new URL(t),s=`${i.protocol}//${i.hostname}`;fe.IFRAME_SECURE_ORGIN=s,fe.IFRAME_SECURE_SITE=null===(o=null==e?void 0:e.options)||void 0===o?void 0:o.customElementsURL}if(null===(a=e.options)||void 0===a?void 0:a.deserializedData.usePayrailsFrames){if(!fe.IFRAME_SECURE_ORGIN||!fe.IFRAME_SECURE_SITE){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CARD_FORM_IFRAME_NOT_FOUND);throw r.PayrailsLogger.error(e.message,{error:e,extra:{IFRAME_SECURE_ORGIN:fe.IFRAME_SECURE_ORGIN,IFRAME_SECURE_SITE:fe.IFRAME_SECURE_SITE}}),e}fe.IFRAME_SECURE_ORGIN=me,fe.IFRAME_SECURE_SITE=ve}}class qe{constructor(e,t,i,n){this.setAttributess=e=>{Te(this.iframe,{src:e})},this.mount=e=>{var t;this.unmount();try{if("string"==typeof e){if(this.container=document.querySelector(e)||void 0,!this.container)throw new Fe(Ve.INVALID_ELEMENT_SELECTOR,[],!0)}else{if(!(e instanceof HTMLElement))throw new Fe(Ve.INVALID_ELEMENT_SELECTOR,[],!0);this.container=e}}catch(e){console.error(e)}Te(this.iframe,{src:Oe()}),null===(t=this.container)||void 0===t||t.appendChild(this.iframe)},this.setIframeHeight=e=>{this.iframe.getAttribute("height")!==`${e}px`&&this.iframe.setAttribute("height",`${e}px`)},this.unmount=()=>{this.iframe.remove()},this.name=`${e}:${i}:${n}`,this.metadata=t,this.iframe=ye({name:this.name})}}class Je{}var Ze,Qe,et,tt,it,nt,ot,st,rt,at,lt,dt,ct,ut,Et,_t,ht,It,pt,ft;const vt="Element";class mt extends Je{constructor(e,n,o,s,r=!1,a,l,d,c){var u;super(),this.type=Di.COLLECT,Ze.set(this,void 0),Qe.set(this,!1),et.set(this,void 0),tt.set(this,void 0),it.set(this,{isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:void 0,isRequired:!1}),nt.set(this,void 0),ot.set(this,new pe),st.set(this,void 0),rt.set(this,x.getEventBus()),at.set(this,void 0),lt.set(this,[]),dt.set(this,!1),ct.set(this,void 0),ut.set(this,void 0),Et.set(this,!1),this.getID=()=>t(this,Ze,"f"),this.mount=e=>{var n;if(!e)throw new Fe(Ve.EMPTY_ELEMENT_IN_MOUNT,["CollectElement"],!0);const o=(e,n)=>{if(e.name===t(this,at,"f").name){n(t(this,nt,"f")),t(this,ft,"f").call(this);const e=function(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(i[n[o]]=e[n[o]])}return i}(t(this,et,"f")[0],["name"]);t(this,tt,"f").length>1?t(this,tt,"f").forEach(((e,i)=>{t(this,st,"f")&&t(this,st,"f")._emit(`${j.READY}:${e.elementName}`,Object.assign(Object.assign({},t(this,et,"f")[i]),{elementType:e.elementType}))})):t(this,ot,"f")._emit(j.READY,Object.assign({},e)),t(this,rt,"f").off(X+this.containerId,o),ke(`${xe(Y.ELEMENT_MOUNTED,vt,Ye(t(this,at,"f").name))} `,Pe.LOG,t(this,ct,"f").logLevel),t(this,lt,"f").forEach((e=>e())),i(this,lt,[],"f")}};if(t(this,tt,"f").length>1)t(this,at,"f").mount(e),t(this,rt,"f").on(X+this.containerId,o);else{if(t(this,Et,"f"))return t(this,at,"f").mount(e),void t(this,rt,"f").on(X+this.containerId,o);null===(n=t(this,st,"f"))||void 0===n||n.on(Q,(i=>{(null==i?void 0:i.containerId)===this.containerId&&(t(this,at,"f").mount(e),t(this,rt,"f").on(X+this.containerId,o))}))}},this.unmount=()=>{t(this,at,"f").unmount()},this.update=e=>{let n=Le(e);const o=()=>{t(this,Qe,"f")&&(n={rows:[{elements:[Object.assign({},n)]}]}),i(this,nt,Tt(t(this,nt,"f"),n),"f"),i(this,tt,yt(t(this,nt,"f")),"f"),t(this,Qe,"f")?t(this,rt,"f").emit(K,{name:t(this,at,"f").name,options:t(this,tt,"f")[0],isSingleElementAPI:!0}):(t(this,tt,"f").forEach((e=>{t(this,rt,"f").emit(K,{name:e.elementName,options:e,isSingleElementAPI:!0})})),t(this,rt,"f").emit(K,{name:t(this,at,"f").name,options:t(this,nt,"f"),isSingleElementAPI:!1})),t(this,ft,"f").call(this)};t(this,dt,"f")?o():t(this,lt,"f").push(o)},_t.set(this,(e=>{t(this,Qe,"f")||t(this,ot,"f").on(K,(()=>{e(t(this,tt,"f"))}),!0)})),this.updateElement=e=>{t(this,rt,"f").emit(K,{name:e.elementName,options:e,isSingleElementAPI:!0})},ht.set(this,(()=>{t(this,et,"f").forEach(((e,i)=>{if(0===i){t(this,it,"f").isEmpty=e.isEmpty,t(this,it,"f").isComplete=e.isComplete,t(this,it,"f").isValid=e.isValid,t(this,it,"f").isFocused=e.isFocused,t(this,it,"f").isRequired=e.isRequired,t(this,it,"f").value={};const n=t(this,tt,"f")[i].elementName,o=e.value&&Ke(e.value,e.elementType,t(this,ut,"f"));t(this,Qe,"f")?t(this,it,"f").value=o:t(this,it,"f").value[n]=o}else t(this,it,"f").isEmpty=t(this,it,"f").isEmpty||e.isEmpty,t(this,it,"f").isComplete=t(this,it,"f").isComplete&&e.isComplete,t(this,it,"f").isValid=t(this,it,"f").isValid&&e.isValid,t(this,it,"f").isFocused=t(this,it,"f").isFocused||e.isFocused,t(this,it,"f").isRequired=t(this,it,"f").isRequired||e.isRequired,t(this,it,"f").value||(t(this,it,"f").value={}),t(this,tt,"f")[i].sensitive||(t(this,it,"f").value[t(this,tt,"f")[i].elementName]=e.value||"")}))})),this.getState=()=>({isEmpty:t(this,it,"f").isEmpty,isComplete:t(this,it,"f").isComplete,isValid:t(this,it,"f").isValid,isFocused:t(this,it,"f").isFocused,value:t(this,it,"f").value,required:t(this,it,"f").isRequired}),this.getOptions=()=>{let e=Le(t(this,nt,"f"));return t(this,Qe,"f")?e=e.rows[0].elements[0]:e.rows.forEach((e=>{e.elements.forEach((e=>{delete e.elementName}))})),delete e.elementName,e},It.set(this,(e=>{t(this,ot,"f").on(z,(()=>{const i=t(this,tt,"f").map((e=>e.elementName));t(this,Qe,"f")||i.push(t(this,at,"f").name),e(i)}),!0)})),pt.set(this,(()=>{t(this,rt,"f").on(W,(e=>{if(t(this,Qe,"f")&&e.event===j.READY&&e.name===t(this,at,"f").name)t(this,ot,"f")._emit(j.READY);else{const i=t(this,tt,"f").length>1;t(this,tt,"f").forEach(((n,o)=>{var s;if(e.name===n.elementName){let r="";switch(e.event){case j.FOCUS:r=j.FOCUS;break;case j.BLUR:r=j.BLUR;break;case j.CHANGE:r=j.CHANGE;break;case j.READY:r=j.READY;break;case j.SUBMIT:return void(null===(s=t(this,st,"f"))||void 0===s||s._emit(j.SUBMIT));default:throw new Fe(Ve.INVALID_EVENT_TYPE,[],!0)}t(this,et,"f")[o].isEmpty=e.value.isEmpty,t(this,et,"f")[o].isValid=e.value.isValid,t(this,et,"f")[o].isComplete=e.value.isComplete,t(this,et,"f")[o].isFocused=e.value.isFocused,t(this,et,"f")[o].isRequired=e.value.isRequired,Object.prototype.hasOwnProperty.call(e.value,"value")?t(this,et,"f")[o].value=e.value.value:t(this,et,"f")[o].value=void 0,r=i?`${r}:${e.name}`:r,t(this,rt,"f").emit(j.HEIGHT+t(this,at,"f").name,{},(e=>{t(this,at,"f").setIframeHeight(e.height)})),t(this,ht,"f").call(this);const a=Object.assign(Object.assign({},t(this,et,"f")[o]),{elementType:n.elementType});i&&t(this,st,"f")?t(this,st,"f")._emit(r,a):t(this,ot,"f")._emit(r,a)}}))}}))})),ft.set(this,(()=>{const{rows:e}=t(this,nt,"f");e.forEach((e=>{e.elements.forEach((e=>{e.elementType!==ne.radio.name&&e.elementType!==ne.checkbox.name&&(e.value=void 0)}))})),i(this,tt,yt(t(this,nt,"f")),"f")})),this.containerId=s.containerId,i(this,Ze,e,"f"),i(this,ct,d,"f"),i(this,nt,Tt(n),"f"),i(this,tt,yt(n),"f"),i(this,Qe,r,"f"),c&&i(this,st,c,"f"),i(this,ut,we[t(this,ct,"f").env].doesReturnValue,"f"),this.elementType=t(this,Qe,"f")?t(this,tt,"f")[0].elementType:"group",i(this,et,[],"f"),t(this,tt,"f").forEach((e=>{t(this,et,"f").push({isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:t(this,ut,"f")?"":void 0,elementType:e.elementType,name:e.elementName,isRequired:!1})})),i(this,at,new qe(t(this,nt,"f").elementName,o,this.containerId,t(this,ct,"f").logLevel),"f"),t(this,pt,"f").call(this),t(this,It,"f").call(this,a),t(this,_t,"f").call(this,l),ke(xe(Y.CREATED_ELEMENT,vt,Ye(t(this,at,"f").name)),Pe.LOG,t(this,ct,"f").logLevel),i(this,Et,s.isMounted,"f"),null===(u=t(this,st,"f"))||void 0===u||u.on(Q,(e=>{(null==e?void 0:e.containerId)===this.containerId&&i(this,Et,!0,"f")}));const E=e=>{e.height&&e.height>0&&t(this,at,"f").setIframeHeight(e.height)};t(this,rt,"f").on(j.MOUNTED,(e=>{s.type===Di.COMPOSABLE?t(this,tt,"f").forEach((t=>{e.name===t.elementName&&(t.isMounted=!0,i(this,dt,!0,"f"))})):e.name===t(this,tt,"f")[0].elementName&&(t(this,tt,"f")[0].isMounted=!0,i(this,dt,!0,"f")),t(this,rt,"f").emit(j.HEIGHT+t(this,at,"f").name,{},E)}))}on(e,i){if(!Object.values(j).includes(e))throw new Fe(Ve.INVALID_EVENT_LISTENER,[],!0);if(!i)throw new Fe(Ve.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof i)throw new Fe(Ve.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);t(this,ot,"f").on(e,(e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,i(e)}))}iframeName(){return t(this,at,"f").name}isMounted(){return t(this,dt,"f")}isValidElement(){for(let e=0;e<t(this,tt,"f").length;e+=1){if(!Object.prototype.hasOwnProperty.call(t(this,tt,"f")[e],"table"))throw new Fe(Ve.MISSING_TABLE_IN_COLLECT,[],!0);if(!t(this,tt,"f")[e].table)throw new Fe(Ve.EMPTY_TABLE_IN_COLLECT,[],!0);if(!("string"==typeof t(this,tt,"f")[e].table||t(this,tt,"f")[e].table instanceof String))throw new Fe(Ve.INVALID_TABLE_IN_COLLECT,[],!0);if(!Object.prototype.hasOwnProperty.call(t(this,tt,"f")[e],"column"))throw new Fe(Ve.MISSING_COLUMN_IN_COLLECT,[],!0);if(!t(this,tt,"f")[e].column)throw new Fe(Ve.EMPTY_COLUMN_IN_COLLECT,[],!0);if(!("string"==typeof t(this,tt,"f")[e].column||t(this,tt,"f")[e].column instanceof String))throw new Fe(Ve.INVALID_COLUMN_IN_COLLECT,[],!0);if(void 0!==t(this,tt,"f")[e].skyflowID&&!t(this,tt,"f")[e].skyflowID)throw new Fe(Ve.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[],!0)}return!0}setError(e){t(this,rt,"f").emit(q,{name:ze(t(this,at,"f").name),isTriggerError:!0,clientErrorText:e})}resetError(){t(this,rt,"f").emit(q,{name:ze(t(this,at,"f").name),isTriggerError:!1})}setValue(e){t(this,ct,"f").env!==De.PROD?t(this,Qe,"f")&&t(this,rt,"f").emit(K,{name:t(this,at,"f").name,options:Object.assign(Object.assign({},t(this,tt,"f")[0]),{value:e}),isSingleElementAPI:!0}):ke(xe(V.UNABLE_TO_SET_VALUE_IN_PROD_ENV,t(this,tt,"f")[0].elementType),Pe.WARN,t(this,ct,"f").logLevel)}clearValue(){t(this,ct,"f").env!==De.PROD?t(this,Qe,"f")&&t(this,rt,"f").emit(K,{name:t(this,at,"f").name,options:Object.assign(Object.assign({},t(this,tt,"f")[0]),{value:""}),isSingleElementAPI:!0}):ke(xe(V.UNABLE_TO_CLEAR_VALUE_IN_PROD_ENV,t(this,tt,"f")[0].elementType),Pe.WARN,t(this,ct,"f").logLevel)}}function Nt(e,t,i={}){if("group"!==e&&!Object.prototype.hasOwnProperty.call(ne,e))throw new Fe(Ve.INVALID_ELEMENT_TYPE,[],!0);if(Object.prototype.hasOwnProperty.call(t,"validations")){if(!Array.isArray(t.validations))throw new Fe(Ve.INVALID_VALIDATIONS_TYPE,[],!0);t.validations.forEach(((e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new Fe(Ve.MISSING_VALIDATION_RULE_TYPE,[`${t}`],!0);if(!Object.values(be).includes(e.type))throw new Fe(Ve.INVALID_VALIDATION_RULE_TYPE,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"params"))throw new Fe(Ve.MISSING_VALIDATION_RULE_PARAMS,[`${t}`],!0);if("object"!=typeof e.params||Array.isArray(e.params)||null===e.params)throw new Fe(Ve.INVALID_VALIDATION_RULE_PARAMS,[`${t}`],!0);if(e.type===be.REGEX_MATCH_RULE){if(!Object.prototype.hasOwnProperty.call(e.params,"regex"))throw new Fe(Ve.MISSING_REGEX_IN_REGEX_MATCH_RULE,[`${t}`],!0)}else if(e.type===be.LENGTH_MATCH_RULE&&!Object.prototype.hasOwnProperty.call(e.params,"min")&&!Object.prototype.hasOwnProperty.call(e.params,"max"))throw new Fe(Ve.MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE,[`${t}`],!0)}))}if(Object.prototype.hasOwnProperty.call(i,"name")&&i.name!==t.name)throw new Error("Name attribute can't be updated");if((i=Object.assign(Object.assign({},t),i)).mask||i.replacePattern){const{type:t}=ne[e].attributes;"text"===t&&"textarea"===t&&"email"===t||(delete i.mask,delete i.replacePattern)}if(void 0===!i.mask&&!Array.isArray(i.mask))throw new Error("mask option has to be array or undefined");if(Array.isArray(i.mask)){const e=i.mask;if("string"!=typeof e[0]||e[1]&&"object"!=typeof e[1])throw new Error("mask array values has to be string")}if(Array.isArray(i.replacePattern)){const e=i.replacePattern;if("string"!=typeof e[0]||e[1]&&"string"!=typeof e[1])throw new Error("replacePatterns array values has to be string")}if((e===ne.radio.name||e===ne.checkbox.name)&&!i.value)throw new Error("Elements radio and checkbox requires value attribute");if(!(e!==ne.dropdown.name||i.options&&Array.isArray(i.options)&&0!==i.options.length))throw new Error("Element dropdown requires options attribute with an array of objects containing value and text attributes")}function Tt(e,t={},i=!0){return(t=Object.assign(Object.assign({},e),t)).rows.forEach(((n,o)=>{const s=n,r=e.rows[o];t.rows[o]=Object.assign(Object.assign({},r),s),s.elements.forEach(((e,t)=>{var n,o;const a=r.elements[t],l=e;if(l.elementType&&a.elementType!==l.elementType&&a.elementName&&a.elementName!==l.elementName)throw new Error(F.CANNOT_CHANGE_ELEMENT);Nt(a.elementType,a,l),s.elements[t]=Object.assign(Object.assign(Object.assign({},a),l),{elementName:a.elementName});const d=l.classes||{},c=l.styles||{};c.base=Object.assign(Object.assign({},ae),c.base),l.classes=d,l.styles=c;const u=(null===(n=null==l?void 0:l.labelStyles)||void 0===n?void 0:n.classes)||{},E=(null===(o=null==l?void 0:l.labelStyles)||void 0===o?void 0:o.styles)||{};i&&function(e,t){Object.values(le).forEach((i=>{if(e[i]||t[i])switch(i){case le.BASE:t[i]=Object.assign({},t[i]);break;case le.FOCUS:t[le.BASE]=Object.assign(Object.assign({},t[le.BASE]),{":focus":Object.assign({},t[le.BASE]&&t[le.BASE][":focus"])});break;case le.WEBPACKAUTOFILL:t[le.BASE]=Object.assign(Object.assign({},t[le.BASE]),{":-webkit-autofill":Object.assign({},t[le.BASE]&&t[le.BASE][":-webkit-autofill"])});break;default:t[i]=Object.assign(Object.assign({},t[le.BASE]),t[i])}})),Object.keys(t).forEach((e=>{const i=t[e][":-webkit-autofill"];"object"==typeof i&&Object.keys(i).forEach((e=>{i[e]&&!i[e].includes("!important")&&(i[e]=`${i[e]} !important`)}))}))}(u,E),l.labelStyles={labelClasses:u},l.labelStyles.styles=E}))})),t}Ze=new WeakMap,Qe=new WeakMap,et=new WeakMap,tt=new WeakMap,it=new WeakMap,nt=new WeakMap,ot=new WeakMap,st=new WeakMap,rt=new WeakMap,at=new WeakMap,lt=new WeakMap,dt=new WeakMap,ct=new WeakMap,ut=new WeakMap,Et=new WeakMap,_t=new WeakMap,ht=new WeakMap,It=new WeakMap,pt=new WeakMap,ft=new WeakMap;const yt=e=>{const{rows:t}=e,i=[];return t.forEach((e=>{e.elements.forEach((e=>{i.push(e)}))})),i},Ot=e=>{const t=e.validations;return t&&Array.isArray(t)&&t.length>0&&t.forEach(((e,t)=>{if(e&&e.type===be.ELEMENT_VALUE_MATCH_RULE){if(e.params&&!Object.prototype.hasOwnProperty.call(e.params,"element"))throw new Fe(Ve.MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE,[`${t}`],!0);if(e.params&&(null==e.params.element||!(e.params.element instanceof mt)))throw new Fe(Ve.INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE,[`${t}`],!0);e.params&&e.params.element&&e.params.element instanceof mt&&(e.params.element=e.params.element.iframeName())}else if(e&&e.type===be.REGEX_MATCH_RULE){if(e.params&&e.params.regex&&!Ge(e.params.regex))throw new Fe(Ve.INVALID_REGEX_IN_REGEX_MATCH_RULE,[`${t}`],!0);e.params&&e.params.regex&&Ge(e.params.regex)&&(e.params.regex=e.params.regex.toString())}})),t},At=(e,t,i)=>{let n=Object.assign({required:!1},t);if((Object.prototype.hasOwnProperty.call(n,"format")||Object.prototype.hasOwnProperty.call(n,"translation"))&&(he.includes(e)?(ke(xe(V.INPUT_FORMATTING_NOT_SUPPROTED,e),Pe.WARN,i),null==n||delete n.format,null==n||delete n.translation):e===ne.INPUT_FIELD.name&&((e=>{if(e){if(Object.prototype.hasOwnProperty.call(e,"format")&&"string"!=typeof e.format)throw new Fe(Ve.INVALID_INPUT_OPTIONS_FORMAT,[],!0);if(Object.prototype.hasOwnProperty.call(e,"translation")&&("object"!=typeof e.translation||"[object Object]"!==Object.prototype.toString.call(e.translation)))throw new Fe(Ve.INVALID_INPUT_OPTIONS_TRANSLATION,[],!0)}})(t),n=Object.assign(Object.assign({},n),{mask:[n.format,n.translation?n.translation:Ie]}),null==n||delete n.format,null==n||delete n.translation)),e===ne.CARD_NUMBER.name){Object.prototype.hasOwnProperty.call(n,"enableCardIcon")||(n=Object.assign(Object.assign({},n),{enableCardIcon:!0}));let e=" ";(null==n?void 0:n.format)===oe&&(e="-"),n=Object.assign(Object.assign({},n),{cardSeperator:e}),null==n||delete n.format,null==n||delete n.translation}else if(e===ne.EXPIRATION_DATE.name){let e=!1;n.format&&(e=!!(o=n.format.toUpperCase())&&ue.includes(o),e||ke(xe(V.INVALID_EXPIRATION_DATE_FORMAT,ue.toString()),Pe.WARN,i)),n=Object.assign(Object.assign({},n),{format:e?n.format.toUpperCase():ce}),null==n||delete n.translation}else if(e===ne.EXPIRATION_YEAR.name){let e=!1;n.format&&(e=(e=>!!e&&Ee.includes(e))(n.format.toUpperCase()),e||ke(xe(V.INVALID_EXPIRATION_YEAR_FORMAT,Ee.toString()),Pe.WARN,i)),n=Object.assign(Object.assign({},n),{format:e?n.format.toUpperCase():"YY"}),null==n||delete n.translation}var o;if(Object.prototype.hasOwnProperty.call(n,"enableCardIcon")&&!We(n.enableCardIcon))throw new Fe(Ve.INVALID_BOOLEAN_OPTIONS,["enableCardIcon"],!0);if(Object.prototype.hasOwnProperty.call(n,"enableCopy")&&!We(n.enableCopy))throw new Fe(Ve.INVALID_BOOLEAN_OPTIONS,["enableCopy"],!0);if(Object.prototype.hasOwnProperty.call(n,"required")&&!We(n.required))throw new Fe(Ve.INVALID_BOOLEAN_OPTIONS,["required"],!0);return n};function Lt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=crypto.getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*16|0;return("x"===e?t:3&t|8).toString(16)}))}class Rt{}var gt,St,Ct,Dt,Pt,bt,Mt,wt,Ut,kt,xt,Yt;const Ft="CollectContainer";class Vt extends Rt{constructor(e,n,o,s){super(),gt.set(this,void 0),St.set(this,{}),Ct.set(this,void 0),Dt.set(this,void 0),Pt.set(this,void 0),this.type=Di.COLLECT,bt.set(this,void 0),Mt.set(this,!1),this.create=(e,i={required:!1})=>{Xe(e,t(this,Dt,"f").logLevel);const n=Ot(e),o=At(e.type,i,t(this,Dt,"f").logLevel),s={rows:[{elements:[Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column,accept:i.allowedFileType},e),o),{validations:n})]}]};return t(this,wt,"f").call(this,s,!0)},wt.set(this,((e,i=!1)=>{const n=[],o=Le(e);if(o.rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;Nt(i,t),t.sensitive=t.sensitive||ne[i].sensitive,t.replacePattern=t.replacePattern||ne[i].replacePattern,t.mask=t.mask||ne[i].mask,t.isMounted=!1,t.elementType!==ne.radio.name&&t.elementType!==ne.checkbox.name||(t.elementName=`${t.elementName}:${btoa(t.value)}`),t.elementName=`${G}:${t.elementType}:${btoa(Lt())}`,t.label=e.label,t.skyflowID=e.skyflowID,n.push(t)}))})),o.elementName=i?n[0].elementName:`${G}:group:${btoa(o.name)}`,i&&!t(this,St,"f")[n[0].elementName]&&t(this,Yt,"f").call(this,n[0].name))throw new Fe(Ve.UNIQUE_ELEMENT_NAME,[`${n[0].name}`],!0);let s=t(this,St,"f")[o.elementName];if(s)i?s.update(n[0]):s.update(o);else{const e=Lt();s=new mt(e,o,t(this,Ct,"f"),{containerId:t(this,gt,"f"),isMounted:t(this,Mt,"f"),type:this.type},i,t(this,kt,"f"),t(this,xt,"f"),t(this,Dt,"f"),t(this,bt,"f")),t(this,St,"f")[o.elementName]=s,t(this,Pt,"f")[e]=s}return i||n.forEach((e=>{const i=e.elementName;t(this,St,"f")[i]?t(this,St,"f")[i].update(e):t(this,St,"f")[i]=this.create(e.elementType,s)})),s})),Ut.set(this,(e=>{Object.keys(t(this,St,"f")).forEach((i=>{i===e&&delete t(this,St,"f")[i]}))})),kt.set(this,(e=>{e.forEach((e=>{t(this,Ut,"f").call(this,e)}))})),xt.set(this,(e=>{e.forEach((e=>{t(this,St,"f")[e.elementName]&&t(this,St,"f")[e.elementName].update(e)}))})),Yt.set(this,(e=>{const i=Object.keys(t(this,St,"f"));for(let t=0;t<i.length;t+=1)if(atob(i[t].split(":")[2])===e)return!0;return!1})),this.collect=(e={tokens:!0})=>new Promise(((i,n)=>{try{je(t(this,Ct,"f").clientJSON.config);if(Object.values(t(this,St,"f")).forEach((e=>{if(!e.isMounted())throw new Fe(Ve.ELEMENTS_NOT_MOUNTED,[],!0);e.isValidElement()})),Object.prototype.hasOwnProperty.call(e,"tokens")&&!We(e.tokens))throw new Fe(Ve.INVALID_TOKENS_IN_COLLECT,[],!0);(null==e?void 0:e.additionalFields)&&Be(e.additionalFields),(null==e?void 0:e.upsert)&&He(null==e?void 0:e.upsert),this.bus.emit(H+t(this,gt,"f"),Object.assign(Object.assign({},e),{tokens:void 0===(null==e?void 0:e.tokens)||e.tokens}),(e=>{!e||(null==e?void 0:e.error)?(ke(`${JSON.stringify(null==e?void 0:e.error)}`,Pe.ERROR,t(this,Dt,"f").logLevel),n(null==e?void 0:e.error)):(ke(xe(Y.COLLECT_SUBMIT_SUCCESS,Ft),Pe.LOG,t(this,Dt,"f").logLevel),i(e))})),ke(xe(Y.EMIT_EVENT,Ft,H),Pe.LOG,t(this,Dt,"f").logLevel)}catch(e){ke(`${e.message}`,Pe.ERROR,t(this,Dt,"f").logLevel),n(e)}})),this.unmount=()=>{this.iframe.remove()},this.bus=x.getEventBus(),i(this,gt,Lt(),"f"),i(this,Ct,n,"f"),i(this,Pt,o,"f"),i(this,Dt,s,"f"),i(this,bt,new pe,"f"),this.iframe=ye({name:`${B}:${t(this,gt,"f")}:${t(this,Dt,"f").logLevel}`}),Te(this.iframe,{src:Oe()}),Ae(this.iframe,Object.assign({},re)),ke(xe(Y.CREATE_COLLECT_CONTAINER,Ft),Pe.LOG,t(this,Dt,"f").logLevel);const r=(e,o)=>{e.name===B+t(this,gt,"f")&&(o(Object.assign(Object.assign({},n),{clientJSON:Object.assign(Object.assign({},n.clientJSON),{config:Object.assign({},n.clientJSON.config)}),context:s})),i(this,Mt,!0,"f"),t(this,bt,"f")._emit(Q,{containerId:t(this,gt,"f")}),this.bus.target({origin:fe.IFRAME_SECURE_ORGIN}).off(X+t(this,gt,"f"),r))};this.bus.target({origin:fe.IFRAME_SECURE_ORGIN}).on(X+t(this,gt,"f"),r),document.body.append(this.iframe)}}gt=new WeakMap,St=new WeakMap,Ct=new WeakMap,Dt=new WeakMap,Pt=new WeakMap,bt=new WeakMap,Mt=new WeakMap,wt=new WeakMap,Ut=new WeakMap,kt=new WeakMap,xt=new WeakMap,Yt=new WeakMap;var Bt=function(e,t){for(var i,n=-1,o=e.length;++n<o;){var s=t(e[n]);void 0!==s&&(i=void 0===i?s:i+s)}return i},Gt=function(e){return e};var jt,Xt,Ht,Wt,zt,Kt,$t,qt,Jt,Zt,Qt,ei,ti,ii,ni,oi,si,ri,ai,li,di,ci,ui,Ei=o((function(e){return e&&e.length?Bt(e,Gt):0}));class _i{constructor(e,n){jt.set(this,void 0),Xt.set(this,void 0),this.type=Di.COMPOSABLE,Ht.set(this,!1),Wt.set(this,!1),this.update=e=>{i(this,Wt,!0,"f"),t(this,Ht,"f")?(t(this,Xt,"f")._emit(J,{elementName:t(this,jt,"f"),elementOptions:e}),i(this,Wt,!1,"f")):t(this,Wt,"f")&&t(this,Xt,"f").on(`${Se.READY}:${t(this,jt,"f")}`,(()=>{t(this,Xt,"f")._emit(J,{elementName:t(this,jt,"f"),elementOptions:e}),i(this,Ht,!0,"f"),i(this,Wt,!1,"f")}))},i(this,jt,e,"f"),i(this,Xt,n,"f"),t(this,Xt,"f").on(`${Se.READY}:${t(this,jt,"f")}`,(()=>{i(this,Ht,!0,"f")}))}on(e,i){if(!Object.values(j).includes(e))throw new Fe(Ve.INVALID_EVENT_LISTENER,[],!0);if(!i)throw new Fe(Ve.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof i)throw new Fe(Ve.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);t(this,Xt,"f").on(`${e}:${t(this,jt,"f")}`,(e=>{void 0===e.value&&(e.value=""),"CARD_NUMBER"===e.elementType&&e.value&&(e.value=e.value.slice(0,6)),delete e.isComplete,delete e.name,i(e)}))}}jt=new WeakMap,Xt=new WeakMap,Ht=new WeakMap,Wt=new WeakMap;const hi="CollectContainer";class Ii extends Rt{constructor(e,n,o,a){super(),zt.set(this,void 0),Kt.set(this,{}),$t.set(this,void 0),qt.set(this,{rows:[]}),Jt.set(this,[]),Zt.set(this,void 0),Qt.set(this,void 0),ei.set(this,void 0),ti.set(this,!1),ii.set(this,void 0),ni.set(this,void 0),this.type=Di.COMPOSABLE,oi.set(this,!1),si.set(this,{}),this.create=(e,i={required:!1})=>{Xe(e,t(this,Zt,"f").logLevel);const n=Ot(e),o=At(e.type,i,t(this,Zt,"f").logLevel),s=`${G}:${e.type}:${btoa(Lt())}`;return t(this,Jt,"f").push(Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column},e),o),{validations:n,elementName:s})),new _i(s,t(this,ei,"f"))},ri.set(this,((e,n=!1)=>{const o=[];if(i(this,si,Le(e),"f"),t(this,si,"f").rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;Nt(i,t),t.sensitive=t.sensitive||ne[i].sensitive,t.replacePattern=t.replacePattern||ne[i].replacePattern,t.mask=t.mask||ne[i].mask,t.isMounted=!1,t.label=e.label,t.skyflowID=e.skyflowID,o.push(t)}))})),t(this,si,"f").elementName=n?o[0].elementName:`${G}:group:${btoa(t(this,si,"f").name)}`,n&&!t(this,Kt,"f")[o[0].elementName]&&t(this,ci,"f").call(this,o[0].name))throw new Fe(Ve.UNIQUE_ELEMENT_NAME,[`${o[0].name}`],!0);let s=t(this,Kt,"f")[t(this,si,"f").elementName];if(s)n?s.update(o[0]):s.update(t(this,si,"f"));else{const e=Lt();s=new mt(e,t(this,si,"f"),t(this,$t,"f"),{containerId:t(this,zt,"f"),isMounted:t(this,oi,"f"),type:this.type},!0,t(this,li,"f"),t(this,di,"f"),t(this,Zt,"f"),t(this,ei,"f")),t(this,Kt,"f")[t(this,si,"f").elementName]=s,t(this,Qt,"f")[e]=s}return s})),ai.set(this,(e=>{Object.keys(t(this,Kt,"f")).forEach((i=>{i===e&&delete t(this,Kt,"f")[i]}))})),li.set(this,(e=>{e.forEach((e=>{t(this,ai,"f").call(this,e)}))})),di.set(this,(e=>{e.forEach((e=>{t(this,Kt,"f")[e.elementName]&&t(this,Kt,"f")[e.elementName].update(e)}))})),ci.set(this,(e=>{const i=Object.keys(t(this,Kt,"f"));for(let t=0;t<i.length;t+=1)if(atob(i[t].split(":")[2])===e)return!0;return!1})),this.on=(e,i)=>{if(!Object.values(j).includes(e))throw new Fe(Ve.INVALID_EVENT_LISTENER,[],!0);if(!i)throw new Fe(Ve.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof i)throw new Fe(Ve.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);t(this,ei,"f").on(j.SUBMIT,(()=>{i()}))},this.mount=e=>{if(!e)throw new Fe(Ve.EMPTY_ELEMENT_IN_MOUNT,["CollectElement"],!0);const{layout:n}=t(this,ii,"f");if(Ei(n)!==t(this,Jt,"f").length)throw new Fe(Ve.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM,[],!0);let o=0;if(n.forEach(((e,i)=>{t(this,qt,"f").rows=[...t(this,qt,"f").rows,{elements:[]}];for(let n=0;n<e;n++)t(this,qt,"f").rows[i].elements.push(t(this,Jt,"f")[o]),o++})),t(this,ii,"f").styles&&(t(this,qt,"f").styles=Object.assign({},t(this,ii,"f").styles)),t(this,ii,"f").errorTextStyles&&(t(this,qt,"f").errorTextStyles=Object.assign({},t(this,ii,"f").errorTextStyles)),t(this,oi,"f"))return i(this,ni,t(this,ri,"f").call(this,t(this,qt,"f"),!1),"f"),t(this,ni,"f").mount(e),void i(this,ti,!0,"f");t(this,ei,"f").on(Z+t(this,zt,"f"),(()=>{i(this,ni,t(this,ri,"f").call(this,t(this,qt,"f"),!1),"f"),t(this,ni,"f").mount(e),i(this,ti,!0,"f")}))},this.unmount=()=>{var e;null===(e=t(this,ni,"f"))||void 0===e||e.unmount(),this.iframe.remove()},this.collect=(e={tokens:!0})=>new Promise(((i,n)=>{try{if(je(t(this,$t,"f").clientJSON.config),!t(this,ti,"f")){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);throw r.PayrailsLogger.error(e.message,{error:e}),e}yt(t(this,si,"f")).forEach((e=>{if(!(null==e?void 0:e.isMounted))throw new Fe(Ve.ELEMENTS_NOT_MOUNTED,[],!0)}));if(Object.values(t(this,Kt,"f")).forEach((e=>{e.isValidElement()})),e&&e.tokens&&"boolean"!=typeof e.tokens)throw new Fe(Ve.INVALID_TOKENS_IN_COLLECT,[],!0);(null==e?void 0:e.additionalFields)&&Be(e.additionalFields),(null==e?void 0:e.upsert)&&He(null==e?void 0:e.upsert),this.bus.emit(H+t(this,zt,"f"),Object.assign(Object.assign({},e),{tokens:void 0===(null==e?void 0:e.tokens)||e.tokens}),(e=>{!e||(null==e?void 0:e.error)?(ke(`${JSON.stringify(null==e?void 0:e.error)}`,Pe.ERROR,t(this,Zt,"f").logLevel),n(null==e?void 0:e.error)):(ke(xe(Y.COLLECT_SUBMIT_SUCCESS,hi),Pe.LOG,t(this,Zt,"f").logLevel),i(e))})),ke(xe(Y.EMIT_EVENT,hi,H),Pe.LOG,t(this,Zt,"f").logLevel)}catch(e){ke(`${e.message}`,Pe.ERROR,t(this,Zt,"f").logLevel),n(e)}})),ui.set(this,(()=>{t(this,ei,"f").on(J,(e=>{let i;const n=t(this,Jt,"f").map(((t,n)=>t.elementName===e.elementName?(i=n,Object.assign({elementName:t.elementName},e.elementOptions)):t));t(this,ni,"f")&&t(this,ni,"f").updateElement(Object.assign({},n[i]))}))})),this.bus=x.getEventBus(),i(this,zt,Lt(),"f"),i(this,$t,n,"f"),i(this,Qt,o,"f"),i(this,Zt,a,"f"),i(this,ii,e,"f"),i(this,ei,new pe,"f"),this.iframe=ye({name:`${B}:${t(this,zt,"f")}:${t(this,Zt,"f").logLevel}`}),Te(this.iframe,{src:Oe()}),Ae(this.iframe,Object.assign({},re)),ke(xe(Y.CREATE_COLLECT_CONTAINER,hi),Pe.LOG,t(this,Zt,"f").logLevel);const l=(e,o)=>{e.name===B+t(this,zt,"f")&&(o(Object.assign(Object.assign({},n),{clientJSON:Object.assign(Object.assign({},n.clientJSON),{config:Object.assign({},n.clientJSON.config)}),context:a})),i(this,oi,!0,"f"),t(this,ei,"f")._emit(Z+t(this,zt,"f"),{containerId:t(this,zt,"f")}),this.bus.target({origin:fe.IFRAME_SECURE_ORGIN}).off(X+t(this,zt,"f"),l))};this.bus.target({origin:fe.IFRAME_SECURE_ORGIN}).on(X+t(this,zt,"f"),l),document.body.append(this.iframe),t(this,ui,"f").call(this)}}function pi(e){this.message=e}zt=new WeakMap,Kt=new WeakMap,$t=new WeakMap,qt=new WeakMap,Jt=new WeakMap,Zt=new WeakMap,Qt=new WeakMap,ei=new WeakMap,ti=new WeakMap,ii=new WeakMap,ni=new WeakMap,oi=new WeakMap,si=new WeakMap,ri=new WeakMap,ai=new WeakMap,li=new WeakMap,di=new WeakMap,ci=new WeakMap,ui=new WeakMap,pi.prototype=new Error,pi.prototype.name="InvalidCharacterError";var fi="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new pi("'atob' failed: The string to be decoded is not correctly encoded.");for(var i,n,o=0,s=0,r="";n=t.charAt(s++);~n&&(i=o%4?64*i+n:n,o++%4)?r+=String.fromCharCode(255&i>>(-2*o&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return r};function vi(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(fi(e).replace(/(.)/g,(function(e,t){var i=t.charCodeAt(0).toString(16).toUpperCase();return i.length<2&&(i="0"+i),"%"+i})))}(t)}catch(e){return fi(t)}}function mi(e){this.message=e}mi.prototype=new Error,mi.prototype.name="InvalidTokenError";const Ni=e=>{try{if(!e)return!1;if(t=e,"[object String]"!==Object.prototype.toString.call(t))return!1;let i=!1;const n=function(e,t){if("string"!=typeof e)throw new mi("Invalid token specified");var i=!0===(t=t||{}).header?0:1;try{return JSON.parse(vi(e.split(".")[i]))}catch(e){throw new mi("Invalid token specified: "+e.message)}}(e),o=(new Date).getTime()/1e3,s=n.exp;return s&&o>s&&(i=!0),!i}catch(e){return!1}var t};var Ti,yi,Oi,Ai,Li,Ri,gi,Si,Ci,Di,Pi={name:"skyflow-js",preferGlobal:!0,analyze:!1,version:"1.30.1",author:"Skyflow",description:"Skyflow JavaScript SDK"};class bi{constructor(e,n){Ti.set(this,void 0),this.request=e=>new Promise(((i,n)=>{var o,s,r,a;const l=new XMLHttpRequest;if(l){if(l.open(e.requestMethod,e.url),e.headers){const i=function(e,t,i){var n,o,s,r,a;const l={sdkName:e.name,sdkVersion:e.version},d=function(e,t){return""!==e?`${e}`:`${t.sdkName}@${t.sdkVersion}`}(t.sdkVersion,l),c=function(e){var t,i,n,o,s,r,a,l,d,c,u,E;let _=null,h=null;return/Windows/.test(e)?(_="Windows",h=null!==(i=null===(t=/Windows NT (\d+\.\d+)/.exec(e))||void 0===t?void 0:t[1])&&void 0!==i?i:null):/Android/.test(e)?(_="Android",h=null!==(o=null===(n=/Android (\d+\.\d+)/.exec(e))||void 0===n?void 0:n[1])&&void 0!==o?o:null):/iOS/.test(e)||/iPhone/.test(e)?(_="iOS",h=null!==(a=null===(r=null===(s=/OS (\d+[._]\d+[._]?\d*)/.exec(e))||void 0===s?void 0:s[1])||void 0===r?void 0:r.replace(/_/g,"."))&&void 0!==a?a:null):/Mac OS X/.test(e)?(_="Mac OS X",h=null!==(c=null===(d=null===(l=/Mac OS X (\d+([._]\d+)*)/.exec(e))||void 0===l?void 0:l[1])||void 0===d?void 0:d.replace(/_/g,"."))&&void 0!==c?c:null):/Linux/.test(e)&&(_="Linux",h=null!==(E=null===(u=/Linux( \w+)*?\/([\w.]+)/.exec(e))||void 0===u?void 0:u[2])&&void 0!==E?E:null),{os:_,version:h}}(i.userAgent),u=function(e){let t="",i="";if(-1!==e.indexOf("MSIE")||-1!==e.indexOf("Trident/")){t="Internet Explorer";const n=e.match(/(MSIE|rv:)\s?([\d.]+)/);n&&(i=n[2])}else if(-1!==e.indexOf("Edge")){t="Microsoft Edge";const n=e.match(/Edge\/([\d.]+)/);n&&(i=n[1])}else if(-1!==e.indexOf("Chrome")){t="Google Chrome";const n=e.match(/Chrome\/([\d.]+)/);n&&(i=n[1])}else if(-1!==e.indexOf("Firefox")){t="Mozilla Firefox";const n=e.match(/Firefox\/([\d.]+)/);n&&(i=n[1])}else if(-1!==e.indexOf("Safari")){t="Apple Safari";const n=e.match(/Version\/([\d.]+)/);n&&(i=n[1])}return{browserName:t,browserVersion:i}}(i.userAgent);var E;return{sdk_name_version:d,sdk_client_device_model:(E=i.userAgent,/(ipad|tablet)/gi.test(E)?"tablet":/Mobile|iP(hone|od)|Android|BlackBerry|IEMobile/.test(E)?"mobile":"desktop"),sdk_os_version:null!==(n=i.platform)&&void 0!==n?n:`${null!==(o=c.os)&&void 0!==o?o:""} ${null!==(s=c.version)&&void 0!==s?s:""}`,sdk_runtime_details:`${null!==(r=u.browserName)&&void 0!==r?r:""} ${null!==(a=u.browserVersion)&&void 0!==a?a:""}`}}(Pi,t(this,Ti,"f"),navigator);e.headers["sky-metadata"]=JSON.stringify(i);const{headers:n}=e;Object.keys(e.headers).forEach((e=>{"content-type"===e&&n[e]&&n[e].includes(_e.FORMDATA)||l.setRequestHeader(e,n[e])}))}(null===(s=null===(o=e.headers)||void 0===o?void 0:o["content-type"])||void 0===s?void 0:s.includes(_e.FORMURLENCODED))||(null===(a=null===(r=e.headers)||void 0===r?void 0:r["content-type"])||void 0===a?void 0:a.includes(_e.FORMDATA))?l.send(e.body):l.send(JSON.stringify(Object.assign({},e.body))),l.onload=()=>{var e,t,o;const s=l.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};s.forEach((e=>{const t=e.split(": "),i=t.shift()||"",n=t.join(": ");r[i]=n}));const a=r["content-type"],d=r["x-request-id"];if(l.status<200||l.status>=400)if(a&&a.includes("application/json")){let i=JSON.parse(l.response);(null===(e=null==i?void 0:i.error)||void 0===e?void 0:e.message)&&(i=d?`${null===(t=null==i?void 0:i.error)||void 0===t?void 0:t.message} - requestId: ${d}`:null===(o=null==i?void 0:i.error)||void 0===o?void 0:o.message),n(new Fe({code:l.status,description:i},[],!0))}else a&&a.includes("text/plain")?n(new Fe({code:l.status,description:d?`${l.response} - requestId: ${d}`:l.response},[],!0)):n(new Fe({code:l.status,description:d?`${F.ERROR_OCCURED} - requestId: ${d}`:F.ERROR_OCCURED},[],!0));a&&a.includes("application/json")&&i(JSON.parse(l.response)),i(l.response)},l.onerror=()=>{n(new Fe(Ve.NETWORK_ERROR,[],!0))}}else n(new Fe(Ve.CONNECTION_ERROR,[],!0))})),this.config=e,i(this,Ti,n,"f")}toJSON(){return{config:this.config,metaData:t(this,Ti,"f")}}static fromJSON(e){return new bi(e.config,e.metaData)}}Ti=new WeakMap,function(e){e.COLLECT="COLLECT",e.COMPOSABLE="COMPOSABLE"}(Di||(Di={}));const Mi="Skyflow";class wi{constructor(e){var n,o;yi.set(this,void 0),Oi.set(this,Lt()),Ai.set(this,{uuid:t(this,Oi,"f"),clientDomain:window.location.origin}),Li.set(this,""),Ri.set(this,void 0),gi.set(this,void 0),Si.set(this,void 0),Ci.set(this,void 0),this.bus=x.getEventBus();const s=localStorage.getItem("sdk_version")||"";t(this,Ai,"f").sdkVersion=s,i(this,yi,new bi(Object.assign({},e),t(this,Ai,"f")),"f"),i(this,gi,(null===(n=null==e?void 0:e.options)||void 0===n?void 0:n.logLevel)||Ce.ERROR,"f"),i(this,Si,(null===(o=null==e?void 0:e.options)||void 0===o?void 0:o.env)||De.PROD,"f"),i(this,Ci,{},"f");this.bus.target({origin:fe.IFRAME_SECURE_ORGIN}).on($+t(this,Oi,"f"),((e,n)=>{ke(xe(Y.CAPTURED_BEARER_TOKEN_EVENT,Mi),Pe.LOG,t(this,gi,"f")),!t(this,yi,"f").config.getBearerToken||t(this,Li,"f")&&Ni(t(this,Li,"f"))?(ke(xe(Y.REUSE_BEARER_TOKEN,Mi),Pe.LOG,t(this,gi,"f")),n({authToken:t(this,Li,"f")})):t(this,yi,"f").config.getBearerToken().then((e=>{Ni(e)?(ke(xe(Y.BEARER_TOKEN_RESOLVED,Mi),Pe.LOG,t(this,gi,"f")),i(this,Li,e,"f"),n({authToken:t(this,Li,"f")})):(ke(F.INVALID_BEARER_TOKEN,Pe.ERROR,t(this,gi,"f")),n({error:F.INVALID_BEARER_TOKEN}))})).catch((e=>{ke(F.BEARER_TOKEN_REJECTED,Pe.ERROR,t(this,gi,"f")),n({error:e})}))})),ke(xe(Y.BEARER_TOKEN_LISTENER,Mi),Pe.LOG,t(this,gi,"f")),ke(xe(Y.CURRENT_ENV,Mi,t(this,Si,"f")),Pe.LOG,t(this,gi,"f")),ke(xe(Y.CURRENT_LOG_LEVEL,Mi,t(this,gi,"f")),Pe.LOG,t(this,gi,"f"))}static init(e){var t;const i=(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||Ce.ERROR;$e(e),ke(xe(Y.INITIALIZE_CLIENT,Mi),Pe.LOG,i);const n=e;var o;n.vaultURL="string"!=typeof(o=e.vaultURL)?o:"/"===(null==o?void 0:o.trim().slice(-1))?o.slice(0,-1):o.trim();const s=new wi(n);return ke(xe(Y.CLIENT_INITIALIZED,Mi),Pe.LOG,i),s}container(e,i){switch(e){case Di.COLLECT:{const n=new Vt(i,Object.assign(Object.assign({},t(this,Ai,"f")),{clientJSON:t(this,yi,"f").toJSON(),containerType:e}),t(this,Ci,"f"),{logLevel:t(this,gi,"f"),env:t(this,Si,"f")});return ke(xe(Y.COLLECT_CONTAINER_CREATED,Mi),Pe.LOG,t(this,gi,"f")),n}case Di.COMPOSABLE:{(e=>{if(!e)throw new Fe(Ve.MISSING_COMPOSABLE_CONTAINER_OPTIONS,[],!0);if("object"!=typeof e)throw new Fe(Ve.INVALID_COMPOSABLE_CONTAINER_OPTIONS,[],!0);if(!Object.prototype.hasOwnProperty.call(e,"layout"))throw new Fe(Ve.MISSING_COMPOSABLE_LAYOUT_KEY,[],!0);if(!e.layout)throw new Fe(Ve.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(!Array.isArray(e.layout))throw new Fe(Ve.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(0===e.layout.length)throw new Fe(Ve.EMPTY_COMPOSABLE_LAYOUT_ARRAY,[],!0);e.layout.forEach((e=>{if("number"!=typeof e)throw new Fe(Ve.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(e<0)throw new Fe(Ve.NEGATIVE_VALUES_COMPOSABLE_LAYOUT,[],!0)}))})(i);const n=new Ii(i,Object.assign(Object.assign({},t(this,Ai,"f")),{clientJSON:t(this,yi,"f").toJSON(),containerType:e}),t(this,Ci,"f"),{logLevel:t(this,gi,"f"),env:t(this,Si,"f")});return ke(xe(Y.COLLECT_CONTAINER_CREATED,Mi),Pe.LOG,t(this,gi,"f")),n}default:if(!e)throw new Fe(Ve.EMPTY_CONTAINER_TYPE,[],!0);throw new Fe(Ve.INVALID_CONTAINER_TYPE,[],!0)}}static get ContainerType(){return Di}static get ElementType(){return ee}static get RedactionType(){return Re}static get RequestMethod(){return ge}static get LogLevel(){return Ce}static get EventName(){return Se}static get Env(){return De}static get ValidationRuleType(){return be}}function Ui(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseURL&&(t=e.sdkBaseURL,delete e.sdkBaseURL),function(e){var t=e["merchant-id"],i=e["data-merchant-id"],n="",o="";Array.isArray(t)?t.length>1?(n="*",o=t.toString()):n=t.toString():"string"==typeof t&&t.length>0?n=t:"string"==typeof i&&i.length>0&&(n="*",o=i);e["merchant-id"]=n,e["data-merchant-id"]=o}(e);var i=Object.keys(e).filter((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})).reduce((function(t,i){var n=e[i].toString();return"data-"===i.substring(0,5)?t.dataAttributes[i]=n:t.queryParams[i]=n,t}),{queryParams:{},dataAttributes:{}}),n=i.queryParams,o=i.dataAttributes;return{url:"".concat(t,"?").concat(ki(n)),dataAttributes:o}}function ki(e){var t="";return Object.keys(e).forEach((function(i){0!==t.length&&(t+="&"),t+=i+"="+e[i]})),t}function xi(e,t){void 0===t&&(t={});var i=document.createElement("script");return i.src=e,Object.keys(t).forEach((function(e){i.setAttribute(e,t[e]),"data-csp-nonce"===e&&i.setAttribute("nonce",t["data-csp-nonce"])})),i}function Yi(e,t){if(void 0===t&&(t=Fi()),Bi(e,t),"undefined"==typeof window)return t.resolve(null);var i=Ui(e),n=i.url,o=i.dataAttributes,s=o["data-namespace"]||"paypal",r=Vi(s);
5
5
  /*!
6
6
  * paypal-js v5.1.4 (2022-11-29T23:08:21.847Z)
7
7
  * Copyright 2020-present, PayPal, Inc. All rights reserved.
@@ -18,8 +18,8 @@ Copyright (c) 2022 Skyflow, Inc.
18
18
  * See the License for the specific language governing permissions and
19
19
  * limitations under the License.
20
20
  */
21
- return function(e,t){var i=document.querySelector('script[src="'.concat(e,'"]'));if(null===i)return null;var n=Ui(e,t),s=i.cloneNode();if(delete s.dataset.uidAuto,Object.keys(s.dataset).length!==Object.keys(n.dataset).length)return null;var o=!0;return Object.keys(s.dataset).forEach((function(e){s.dataset[e]!==n.dataset[e]&&(o=!1)})),o?i:null}(n,s)&&r?t.resolve(r):function(e,t){void 0===t&&(t=xi());Fi(e,t);var i=e.url,n=e.attributes;if("string"!=typeof i||0===i.length)throw new Error("Invalid url.");if(void 0!==n&&"object"!=typeof n)throw new Error("Expected attributes to be an object.");return new t((function(e,t){if("undefined"==typeof window)return e();!function(e){var t=e.url,i=e.attributes,n=e.onSuccess,s=e.onError,o=Ui(t,i);o.onerror=s,o.onload=n,document.head.insertBefore(o,document.head.firstElementChild)}({url:i,attributes:n,onSuccess:function(){return e()},onError:function(){var e=new Error('The script "'.concat(i,'" failed to load.'));return window.fetch?fetch(i).then((function(i){return 200===i.status&&t(e),i.text()})).then((function(e){var i=function(e){var t=e.split("/* Original Error:")[1];return t?t.replace(/\n/g,"").replace("*/","").trim():e}(e);t(new Error(i))})).catch((function(e){t(e)})):t(e)}})}))}({url:n,attributes:s},t).then((function(){var e=Yi(o);if(e)return e;throw new Error("The window.".concat(o," global variable is not available."))}))}function xi(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function Yi(e){return window[e]}function Fi(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}Ni=new WeakMap,Ti=new WeakMap,yi=new WeakMap,Oi=new WeakMap,Ai=new WeakMap,Li=new WeakMap,gi=new WeakMap,Ri=new WeakMap;class Vi{static load(e,t){if(e===Bi.PayPal){if(!t)throw new Error("PayPal config is required");return Vi.loadPayPalScript(t)}return Vi.loadScript(e)}static reset(){Vi.scriptMap.clear()}static preloadCardForm(){const e="https://assets.payrails.io/0d7f8b3/card";[["https://js.skyflow.com/v1/elements/index.js","payrails-iframe-js-v1"],["https://js.skyflow.com/v1/elements/index.html","payrails-iframe-html-v1"],[`${e}/index.js`,"payrails-iframe-js-v2"],[`${e}/index.html`,"payrails-iframe-html-v2"]].forEach((([e,t])=>{if(!document.getElementById(t)){const i=document.createElement("link");i.id=t,i.rel="preload",i.as="script",i.href=e,document.head.appendChild(i)}}))}static loadScript(e){const t=`payrails-script-${JSON.stringify(e)}`;if(Vi.scriptMap.has(t))return Vi.scriptMap.get(t);const i=document.createElement("script");i.src=e,i.id=t;const n=new Promise(((t,n)=>{i.onload=()=>{t()},i.onerror=t=>{n(Vi.logLoadError(e,new Error(t.toString())))}}));return Vi.scriptMap.set(t,n),document.body.appendChild(i),n}static loadPayPalScript({clientId:t,currency:i,vault:n,intent:s}){return e(this,void 0,void 0,(function*(){try{const e=yield ki({"client-id":t,components:"buttons,funding-eligibility",intent:s,currency:i,vault:n,"data-namespace":"payrailsPaypal"});if(e)return e}catch(e){throw Vi.logLoadError(Bi.PayPal,e)}throw Vi.logLoadError(Bi.PayPal)}))}constructor(){}static logLoadError(e,t){const i=new Map([[Bi.ApplePay,o.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR],[Bi.GooglePay,o.ERROR_CODES.PAYRAILS_CLIENT_GPAY_LOADING_ERROR],[Bi.PayPal,o.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR]]),n=new o.PayrailsError(i.get(e)||o.ERROR_CODES.PAYRAILS_CLIENT_UNKNOWN_ERROR,{cause:t,description:null==t?void 0:t.message});return r.PayrailsLogger.error(n.message,{error:n}),n}}var Bi;Vi.scriptMap=new Map,function(e){e.ApplePay="https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js",e.GooglePay="https://pay.google.com/gp/p/js/pay.js",e.PayPal="paypal-sdk"}(Bi||(Bi={}));class Gi extends M{constructor(e){super("span",{id:e.id,className:"payrails-store-instrument"}),this.options=e,this.createHTML(),this.applyStyles(),this.addListeners()}get isChecked(){var e;return!!(null===(e=this.element.querySelector("input"))||void 0===e?void 0:e.checked)}createHTML(){var e,t,i,n,s,o,r,a,l;const d=(null===(i=null===(t=null===(e=this.options)||void 0===e?void 0:e.translations)||void 0===t?void 0:t.labels)||void 0===i?void 0:i.saveInstrument)||(null===(o=null===(s=null===(n=this.options)||void 0===n?void 0:n.translations)||void 0===s?void 0:s.labels)||void 0===o?void 0:o.storeInstrument)||"Save instrument for future payments",c=`${this.id}-checkbox`;(null===(l=null===(a=null===(r=this.options)||void 0===r?void 0:r.translations)||void 0===a?void 0:a.labels)||void 0===l?void 0:l.saveInstrument)&&console.warn("The saveInstrument label is deprecated, please use storeInstrument instead"),this.element.innerHTML=`<label for="${c}"><input type="checkbox" id="${c}" name="${c}" class="payrails-store-instrument-checkbox">${d}</label>`}applyStyles(){var e,t;Object.keys((null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.storeInstrumentCheckbox)||{}).forEach((e=>{var t,i,n;this.element.style[e]=null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===i?void 0:i.storeInstrumentCheckbox)||void 0===n?void 0:n[e]}))}addListeners(){this.element.addEventListener("change",(e=>{var t,i,n,s;(null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onSaveInstrumentCheckboxChanged)&&(null===(s=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===s||s.onSaveInstrumentCheckboxChanged({checked:this.isChecked})),e.stopPropagation(),e.stopImmediatePropagation()})),this.element.addEventListener("click",(e=>{e.stopPropagation(),e.stopImmediatePropagation()}))}}class ji extends M{constructor(t,i){var n,s;super(t,i),this.options=i,this.storeInstrumentCheckbox=null,(null===(n=this.options)||void 0===n?void 0:n.showStoreInstrumentCheckbox)&&(this.storeInstrumentCheckbox=new Gi(Object.assign(Object.assign({},i),{id:`${null===(s=this.options)||void 0===s?void 0:s.id}-store-instrument-checkbox`,events:{onSaveInstrumentCheckboxChanged:t=>e(this,void 0,void 0,(function*(){var e,n;null===(n=null===(e=null==i?void 0:i.events)||void 0===e?void 0:e.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(e,t)}))}})),this.subElements.push(this.storeInstrumentCheckbox))}get shouldStoreInstrument(){var e,t;return(null===(e=this.storeInstrumentCheckbox)||void 0===e?void 0:e.isChecked)||(null===(t=this.options)||void 0===t?void 0:t.alwaysStoreInstrument)||!1}}class Xi extends ji{static isApplePayAvailable(){return e(this,void 0,void 0,(function*(){try{return yield Vi.load(Bi.ApplePay),ApplePaySession.canMakePayments()}catch(e){return!1}}))}constructor(e,t,i){super("div",Object.assign(Object.assign({},i),{id:"payrails-apple-pay-button"})),this.sdkConfig=e,this.execution=t,this.options=i,this.appleButton=null,this.paymentExecutor=new L(e,t),Xi.isApplePayAvailable().then((e=>{var t,i,n;e&&(null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onApplePayAvailable)||void 0===n||n.call(i))}))}mount(t){super.mount(t),(()=>{e(this,void 0,void 0,(function*(){try{(yield Xi.isApplePayAvailable())&&(yield this.mountApplePayButton())}catch(e){}}))})()}unmount(){var e,t;null===(t=null===(e=this.appleButton)||void 0===e?void 0:e.parentElement)||void 0===t||t.removeChild(this.appleButton),super.unmount()}mountApplePayButton(){var t,i,n;return e(this,void 0,void 0,(function*(){try{const s=(null===(t=this.options.styles)||void 0===t?void 0:t.type)||"buy",o=(null===(i=this.options.styles)||void 0===i?void 0:i.style)||"black";this.element.innerHTML=`<apple-pay-button buttonstyle="${o}" type="${s}" locale="en-GB"></apple-pay-button>`,null===(n=this.storeInstrumentCheckbox)||void 0===n||n.mount(this.selector);const r=this.element.querySelector("apple-pay-button");null==r||r.setAttribute("style","width: 100%;"),null==r||r.addEventListener("click",(()=>e(this,void 0,void 0,(function*(){(yield O(this.options.events))&&this.createApplePaySession()}))))}catch(e){}}))}createApplePaySession(){const t=this.execution.applePayConfig,{countryCode:i,supportedNetworks:n,merchantCapabilities:s}=t,{amount:o}=this.sdkConfig;try{const t={countryCode:i,currencyCode:o.currency,merchantCapabilities:s,supportedNetworks:n,total:{label:"",type:"final",amount:o.value}},r=new ApplePaySession(3,t);return r.onvalidatemerchant=t=>e(this,void 0,void 0,(function*(){const{res:e}=yield this.paymentExecutor.createApplePaySession({requestUrl:this.execution.createSessionLink,sessionUrl:t.validationURL,clientDomain:this.options.clientDomain}),i=e.data.data;r.completeMerchantValidation(i)})),r.oncancel=()=>{var e,t,i;(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onAuthorizeFailed)&&(null===(i=this.options)||void 0===i||i.events.onAuthorizeFailed())},r.onpaymentauthorized=t=>e(this,void 0,void 0,(function*(){var e,i,n,s,o,a,l,d,c,u,E,_;try{const u=yield this.onApplePayAuthorized(t.payment.token);if("authorizeSuccessful"===(null===(e=null==u?void 0:u.finalState)||void 0===e?void 0:e.code))(null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeSuccess)&&this.options.events.onAuthorizeSuccess();else r.completePayment(ApplePaySession.STATUS_FAILURE),(null===(s=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===s?void 0:s.onAuthorizeFailed)&&(null===(o=this.options)||void 0===o||o.events.onAuthorizeFailed());r.completePayment(ApplePaySession.STATUS_SUCCESS),(null===(l=null===(a=this.options)||void 0===a?void 0:a.events)||void 0===l?void 0:l.onAuthorizeSuccess)&&(null===(c=null===(d=this.options)||void 0===d?void 0:d.events)||void 0===c||c.onAuthorizeSuccess(u))}catch(e){r.completePayment(ApplePaySession.STATUS_FAILURE),(null===(E=null===(u=this.options)||void 0===u?void 0:u.events)||void 0===E?void 0:E.onAuthorizeFailed)&&(null===(_=this.options)||void 0===_||_.events.onAuthorizeFailed(e))}})),r.begin(),r}catch(e){return null}}onApplePayAuthorized(t){return e(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},t),{paymentNetwork:t.paymentMethod.network,paymentInstrumentName:t.paymentMethod.displayName}),i=[{paymentMethodCode:S.APPLE_PAY,integrationType:"api",paymentInstrumentData:{paymentToken:JSON.stringify(e)},amount:this.sdkConfig.amount,storeInstrument:this.shouldStoreInstrument}];return yield this.paymentExecutor.pay(i)}))}}const{CARD_NUMBER:Wi,CVV:zi,CARDHOLDER_NAME:Hi,EXPIRATION_MONTH:Ki,EXPIRATION_YEAR:$i}=exports.ElementType,qi={base:{border:"none",padding:"10px 16px",color:"#1d1d1d",backgroundColor:"#fff"},invalid:{backgroundColor:"#f9e1e1",borderColor:"#f25226",border:"1px solid"}},Ji=[{type:Hi,placeholder:"Card holder",styles:Object.assign(Object.assign({},qi),{base:Object.assign(Object.assign({},qi.base),{border:"1px solid #eae8ee",padding:"10px 16px",borderTopLeftRadius:"4px",borderTopRightRadius:"4px"})})},{type:Wi,placeholder:"1234 1234 1234 1234",styles:Object.assign(Object.assign({},qi),{base:Object.assign(Object.assign({},qi.base),{border:"1px solid #eae8ee",padding:"10px 16px",borderTopLeftRadius:"4px",borderTopRightRadius:"4px",textIndent:"0"}),cardIcon:{position:"absolute",right:"8px",height:"24px",bottom:"calc(50% - 12px)"}})},{type:Ki,placeholder:"MM",styles:Object.assign(Object.assign({},qi),{base:Object.assign(Object.assign({},qi.base),{borderBottom:"1px solid #eae8ee",borderLeft:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomLeftRadius:"4px"})})},{type:$i,placeholder:"YY",format:"YY",styles:Object.assign(Object.assign({},qi),{base:Object.assign(Object.assign({},qi.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee"})})},{type:zi,placeholder:"CVC",styles:Object.assign(Object.assign({},qi),{base:Object.assign(Object.assign({},qi.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomRightRadius:"4px"})})}];class Zi extends ji{get bin(){return this.collectContainer.bin}constructor(e,t){var i,n,s,o,r;super("div",Object.assign(Object.assign({},t),{translations:Object.assign(Object.assign({},null==t?void 0:t.translations),{labels:Object.assign(Object.assign({},null===(i=null==t?void 0:t.translations)||void 0===i?void 0:i.labels),{saveInstrument:null===(s=null===(n=null==t?void 0:t.translations)||void 0===n?void 0:n.labels)||void 0===s?void 0:s.saveCreditCard})}),styles:Object.assign({storeInstrumentCheckbox:null===(o=null==t?void 0:t.styles)||void 0===o?void 0:o.storeCardCheckbox},null==t?void 0:t.styles),id:"payrails-card-form"})),this.collectContainer=e,this.options=t,this.formFields=[],(null===(r=null==t?void 0:t.styles)||void 0===r?void 0:r.storeCardCheckbox)&&console.warn("The `storeCardCheckbox` option for styles is deprecated. Please use `storeInstrumentCheckbox` instead."),Ji.forEach((({type:e,styles:i,format:n,placeholder:s})=>{var o,r,a,l,d,c,u;if(!(null===(o=this.options)||void 0===o?void 0:o.showCardHolderName)&&e===exports.ElementType.CARDHOLDER_NAME)return;const E=new Qi(this.collectContainer,{type:e,label:null===(a=null===(r=null==t?void 0:t.translations)||void 0===r?void 0:r.labels)||void 0===a?void 0:a[e],placeholder:(null===(d=null===(l=null==t?void 0:t.translations)||void 0===l?void 0:l.placeholders)||void 0===d?void 0:d[e])||s,labelStyles:this.prepareLabelStyles(e),inputStyles:this.prepareInputStyles(i,e),format:n,events:{onFocus:null===(u=null===(c=this.options)||void 0===c?void 0:c.events)||void 0===u?void 0:u.onFocus,onChange:this.onChange.bind(this),onReady:this.triggerOnReady.bind(this)}});this.formFields.push(E)})),this.subElements.push(this.collectContainer),this.storeInstrumentCheckbox&&this.subElements.push(this.storeInstrumentCheckbox)}tokenize(e){return this.collectContainer.tokenize(e)}show(){var e,t;const i=document.getElementById(this.collectContainer.id);if(!i){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw r.PayrailsLogger.error(e.message,{error:e}),e}Object.assign(i.style,null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.wrapper),this.element.style.display="flex"}hide(){this.element.style.display="none"}triggerOnReady(){var e,t,i;this.formFields.reduce(((e,t)=>e&&t.isReady),!0)&&(null===(i=null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onReady)||void 0===i||i.call(t))}prepareLabelStyles(e){return["base"].reduce(((t,i)=>{var n,s,o,r,a,l,d,c;return t[i]=Object.assign(Object.assign(Object.assign({},null===(s=null===(n=this.options)||void 0===n?void 0:n.styles)||void 0===s?void 0:s.base),null===(a=null===(r=null===(o=this.options)||void 0===o?void 0:o.styles)||void 0===r?void 0:r.labels)||void 0===a?void 0:a.all),null===(c=null===(d=null===(l=this.options)||void 0===l?void 0:l.styles)||void 0===d?void 0:d.labels)||void 0===c?void 0:c[e]),t}),{})}prepareInputStyles(e,t){var i;let n=JSON.parse(JSON.stringify(e));return(null===(i=this.options)||void 0===i?void 0:i.showCardHolderName)&&t===exports.ElementType.CARD_NUMBER&&(this.element.setAttribute("class","with-card-holder"),n=Object.assign(Object.assign({},e),{base:Object.assign(Object.assign({},qi.base),{border:"1px solid #eae8ee",borderTop:"none",padding:"10px 16px",textIndent:"0"})})),["base","complete","empty","focus","invalid","cardIcon","copyIcon"].forEach((e=>{var i,s,o,r,a,l,d,c;n[e]=Object.assign(Object.assign(Object.assign({},n[e]),null===(r=null===(o=null===(s=null===(i=this.options)||void 0===i?void 0:i.styles)||void 0===s?void 0:s.inputFields)||void 0===o?void 0:o.all)||void 0===r?void 0:r[e]),null===(c=null===(d=null===(l=null===(a=this.options)||void 0===a?void 0:a.styles)||void 0===l?void 0:l.inputFields)||void 0===d?void 0:d[t])||void 0===c?void 0:c[e])})),n}get isValid(){return this.formFields.reduce(((e,t)=>e&&t.isValid),!0)}get cardNetwork(){var e,t;return null!==(t=null===(e=this.formFields.find((e=>Boolean(e.cardNetwork))))||void 0===e?void 0:e.cardNetwork)&&void 0!==t?t:""}onChange(){var e,t,i,n;(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onChange)&&(null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n||n.onChange({isValid:this.isValid,cardNetwork:this.cardNetwork,bin:this.bin}))}collectValues(){return e(this,void 0,void 0,(function*(){return{cardData:yield this.collectContainer.collect(),storeInstrument:this.shouldStoreInstrument,enrollInstrumentToNetworkOffers:Boolean(this.enforceEnrollInstrumentToNetworkOffersForMasterCard())}}))}enforceEnrollInstrumentToNetworkOffersForMasterCard(){var e;return"mastercard"!==this.cardNetwork&&(null===(e=this.options)||void 0===e?void 0:e.enrollInstrumentToNetworkOffers)}}class Qi{constructor(e,t){this.isValid=!1,this.isReady=!1,this.cardNetwork="";const{events:i}=t,n=e.createCollectElement(t);(null==i?void 0:i.onFocus)&&n.on("FOCUS",i.onFocus),n.on("READY",(()=>{var e,i;this.isReady=!0,null===(i=null===(e=t.events)||void 0===e?void 0:e.onReady)||void 0===i||i.call(e)})),n.on("CHANGE",(e=>{const{isEmpty:t,isValid:n,network:s}=e;this.isValid=!t&&n,this.cardNetwork=null!=s?s:"",(null==i?void 0:i.onChange)&&i.onChange(this)}))}}class en extends M{constructor(e,t,i,n,s){super("div",{id:e,className:"payrails-dropin-item"}),this.events=n,this.styles=s,this.isActive=!1,this.mountContainerClass="payrails-dropin-item-container",this.applyBaseStyles();const o=`payrails-dropin-item-${e}`,r=document.createElement("label");r.setAttribute("for",o);const a=document.createElement("input");if(a.setAttribute("type","radio"),a.setAttribute("name","payment-option"),a.setAttribute("id",o),a.setAttribute("value",o),this.input=a,r.appendChild(a),this.label=r,i){const e=document.createElement("img");e.src=null!=i?i:"",e.className="payrails-store-instrument-icon",r.appendChild(e)}const l=document.createElement("span");r.appendChild(l),l.innerText=t,this.element.addEventListener("click",(()=>{var e,t;null===(t=(e=this.label).onchange)||void 0===t||t.call(e,new Event("change"))})),this.element.appendChild(r);const d=document.createElement("div");d.setAttribute("class",this.mountContainerClass),this.element.appendChild(d)}get identifier(){return`payrails-dropin-item-${this.id}`}deactivate(){var e,t;this.isActive&&(this.isActive=!1,this.input.checked=!1,this.applyBaseStyles(),null===(e=this.component)||void 0===e||e.unmount(),(null===(t=this.events)||void 0===t?void 0:t.onDeactivate)&&this.events.onDeactivate())}applyBaseStyles(){var e,t;this.element.classList.remove("active"),Object.keys((null===(e=this.styles)||void 0===e?void 0:e.active)||{}).forEach((e=>{this.element.style.removeProperty(e)})),Object.assign(this.element.style,null===(t=this.styles)||void 0===t?void 0:t.base)}applyActiveStyles(){var e,t;this.element.classList.add("active"),Object.assign(this.element.style,null===(e=this.styles)||void 0===e?void 0:e.base,null===(t=this.styles)||void 0===t?void 0:t.active)}activate(){var e,t;this.isActive||(null===(e=this.component)||void 0===e||e.mount(`${this.selector} .${this.mountContainerClass}`),this.applyActiveStyles(),this.input.checked=!0,this.isActive=!0,(null===(t=this.events)||void 0===t?void 0:t.onActivate)&&this.events.onActivate())}mount(e){var t,i;super.mount(e),null===(i=null===(t=this.events)||void 0===t?void 0:t.onAvailable)||void 0===i||i.call(t)}}var tn;!function(e){e.AMEX="amex",e.DINERS="diners",e.DISCOVER="discover",e.HIPERCARD="hipercard",e.JCB="jcb",e.MAESTRO="maestro",e.MASTERCARD="mastercard",e.UNIONPAY="unionpay",e.VISA="visa"}(tn||(tn={}));const nn="https://assets.payrails.io/img/";class sn extends en{constructor(e,t,i,n){const s=e.displayName&&""!==e.displayName?e.displayName:"Unavailable";super(`payrails-payment-instrument-${e.id}`,s,sn.getInstrumentIcon(e),{onActivate:()=>{i(e),this.component.setDisabled(!1)}},n),this.component=t}static getInstrumentIcon(e){var t;if(e.paymentMethod!==S.CARD)return"";switch(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.network){case tn.AMEX:return nn+"amex.svg";case tn.DINERS:return nn+"diners-club.svg";case tn.DISCOVER:return nn+"discover.svg";case tn.HIPERCARD:return nn+"hipercard.svg";case tn.JCB:return nn+"jcb.svg";case tn.MAESTRO:return nn+"maestro.svg";case tn.MASTERCARD:return nn+"mastercard.svg";case tn.UNIONPAY:return nn+"unionpay.svg";case tn.VISA:return nn+"visa.svg"}return nn+"default.svg"}}class on extends M{constructor(e,t){super("div",{id:"payrails-card-list"}),this.workflowExecution=e,this.listItems=[],this.workflowExecution.savedCreditCards.forEach((e=>{const i=new rn((()=>{(null==t?void 0:t.onCardChange)&&t.onCardChange(e)}),e);this.listItems.push(i),this.subElements.push(i)}))}reset(){this.element.querySelectorAll("input").forEach((e=>e.checked=!1))}}class rn extends M{constructor(e,t){super("div",{className:"payrails-card-list-item",id:`payrails-card-list-item-${t.id}`});const{id:i}=t,n=t.displayName&&""!==t.displayName?t.displayName:"Unavailable",s=document.createElement("label");s.setAttribute("for",i),s.addEventListener("click",e);const o=document.createElement("input");o.setAttribute("type","radio"),o.setAttribute("name","payment-option"),o.setAttribute("id",i),o.setAttribute("value",i),s.appendChild(o);const r=document.createElement("span");r.className="payment-option-text",s.appendChild(r);const a=document.createElement("img");a.src=sn.getInstrumentIcon(t),a.className="payment-option-icon",r.appendChild(a),r.appendChild(document.createTextNode(n)),this.element.appendChild(s)}}class an extends M{constructor(e){var t;super("div",{id:"authorization-failed-message"});const i=(null===(t=null==e?void 0:e.translations)||void 0===t?void 0:t.label)||"Authorization failed, please try again.";this.element.innerText=i,this.setStyles((null==e?void 0:e.styles)||{}),this.element.innerHTML=`\n <div>\n <svg class="checkmark-cross" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">\n <circle class="checkmark-cross_circle" cx="26" cy="26" r="25" fill="none"/>\n <path class="checkmark-cross_check" fill="none" d="M14.1 14.1l23.8 23.8 m0,-23.8 l-23.8,23.8"/>\n </svg>\n </div>\n <div>${i}</div>`,this.element.addEventListener("click",(e=>{e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),this.unmount()}))}setStyles(e){Object.keys(e).forEach((t=>{this.element.style[t]=e[t]}))}}class ln extends M{constructor(e){var t;super("div",{id:"payrails-authorization-success-msg"}),this.setStyles((null==e?void 0:e.styles)||{}),this.element.innerHTML=`\n <div class="checkmark-wrapper">\n <svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">\n <circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none"/>\n <path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8"/>\n </svg>\n </div>\n <div id="payrails-authorization-success">${(null===(t=null==e?void 0:e.translations)||void 0===t?void 0:t.label)||"Payment successful"}</div`}setStyles(e){Object.keys(e).forEach((t=>{this.element.style[t]=e[t]}))}}class dn extends en{constructor(){super(...arguments),this.buttonShown=!1}activate(){if(!this.buttonShown)return super.activate(),void(this.buttonShown=!0);this.applyActiveStyles(),this.isActive=!0,this.element.querySelector(this.component.selector).style.display="block"}deactivate(){this.isActive&&(this.isActive=!1,this.applyBaseStyles(),this.element.querySelector(this.component.selector).style.display="none")}mountAfterAvailable(){var e,t;super.mount(`#${this.loadElementId}`),null===(t=null===(e=this.events)||void 0===e?void 0:e.onAvailable)||void 0===t||t.call(e)}mount(e){const t=document.querySelector(e);if(!t){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);throw r.PayrailsLogger.error(e.message,{error:e}),e}const i=document.createElement("div");i.setAttribute("id",this.loadElementId),i.setAttribute("style","width: 100%;"),t.appendChild(i)}unmount(){var e;super.unmount(),null===(e=document.querySelector(`#${this.loadElementId}`))||void 0===e||e.remove()}}class cn extends dn{constructor(e,t,i){var n,s;super("apple-pay-dropin",(null===(s=null===(n=i.translations)||void 0===n?void 0:n.labels)||void 0===s?void 0:s.label)||"Apple Pay",void 0,void 0,i.styles),this.loadElementId="apple-pay-dropin-load-element",this.component=new Xi(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},i.events),{onApplePayAvailable:()=>{this.mountAfterAvailable()}})}))}}class un extends en{constructor(e,t,i,n){super("payrails-credit-card-wrapper","Card",void 0,n,i),this.cardForm=e,this.paymentButton=t,this.cardFormShown=!1,this.component=new En(e,t)}activate(){var e,t;this.applyActiveStyles(),this.cardFormShown||(this.cardFormShown=!0,null===(e=this.component)||void 0===e||e.mount(this.selector)),this.isActive||(this.paymentButton.selectedInstrument=null,this.paymentButton.mount(this.selector),this.paymentButton.setDisabled(!this.cardForm.isValid),this.paymentButton.mount("#payrails-card-form"),this.input.checked=!0,this.cardForm.show(),this.isActive=!0,(null===(t=this.events)||void 0===t?void 0:t.onActivate)&&this.events.onActivate())}deactivate(){var e;this.isActive&&(this.applyBaseStyles(),this.paymentButton.unmount(),this.cardForm.hide(),this.isActive=!1,(null===(e=this.events)||void 0===e?void 0:e.onDeactivate)&&this.events.onDeactivate())}}class En extends M{constructor(e,t){super("div",{id:"payrails-form-container"}),this.subElements.push(e,t)}}class _n extends M{constructor(e){var t,i,n,s;super("button",{id:e.id,className:"payrails-generic-button",styles:null!==(i=null===(t=e.styles)||void 0===t?void 0:t.base)&&void 0!==i?i:{}}),this.options=e,this.isDisabled=!1,this.element.innerText=null==e?void 0:e.translations.label,e.styles&&this.setStyles(null!==(s=null===(n=e.styles)||void 0===n?void 0:n.base)&&void 0!==s?s:{}),this.element.addEventListener("click",this.onClick.bind(this)),this.element.addEventListener("mouseenter",(()=>{var e;this.isDisabled||this.setStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{})})),this.element.addEventListener("mouseleave",(()=>{var e;this.isDisabled||this.removeStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{})}))}getElement(){return this.element}onClick(){var t,i;return e(this,void 0,void 0,(function*(){if((null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onClick)&&!this.isDisabled){try{this.triggerLoading(!0),yield this.options.events.onClick()}catch(e){throw this.triggerLoading(!1),e}this.triggerLoading(!1)}}))}setStyles(e){var t;const i=Object.assign(Object.assign({},null===(t=this.options.styles)||void 0===t?void 0:t.base),e);Object.keys(i).forEach((e=>{this.element.style[e]=i[e]}))}removeStyles(e){var t;const i=Object.keys((null===(t=this.options.styles)||void 0===t?void 0:t.base)||{});Object.keys(e).forEach((e=>{var t,n;i.includes(e)?this.element.style[e]=null===(n=null===(t=this.options.styles)||void 0===t?void 0:t.base)||void 0===n?void 0:n[e]:this.element.style[e]=""}))}triggerLoading(e){var t,i,n;this.isDisabled=e,e?(this.element.innerHTML='\n <div class="dot-flashing-container">\n <div class="dot-flashing"></div>\n <span class="dot-flashing-text" aria-hidden="true">Loading</span>\n </div>\n ',(null===(t=this.options.styles)||void 0===t?void 0:t.loading)&&this.setStyles(this.options.styles.loading)):(this.element.innerText=null===(i=this.options)||void 0===i?void 0:i.translations.label,this.removeStyles((null===(n=this.options.styles)||void 0===n?void 0:n.loading)||{}))}}const hn={label:"Generic redirect"};class In extends M{constructor(e,t,i,n){super("div",{id:"payrails-generic-redirect"}),this.sdkConfig=e,this.options=i,this.returnInfo=n;const s=this.buildRedirectButton();this.element.appendChild(s.getElement()),this.paymentExecutor=new L(e,t,this.returnInfo)}buildRedirectButton(){var e,t,i;return new _n({id:"payrails-generic-redirect-button",translations:{label:null!==(t=null===(e=this.options.translations)||void 0===e?void 0:e.label)&&void 0!==t?t:hn.label},events:{onClick:this.onClick.bind(this)},styles:null!==(i=this.options.styles)&&void 0!==i?i:{}})}onClick(){var t,i,n;return e(this,void 0,void 0,(function*(){if(yield O(null!==(t=this.options.events)&&void 0!==t?t:{}))try{const e=(yield this.paymentExecutor.pay([{paymentMethodCode:S.GENERIC_REDIRECT,integrationType:"api",amount:this.sdkConfig.amount}])).response.links.redirect;if(!e)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK);return new Promise(((t,i)=>{window.location.href=e,setTimeout((()=>i(new Error("Timed out doing a redirect to the auth response link"))),3e3)}))}catch(e){null===(n=null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeFailed)||void 0===n||n.call(i)}}))}}const pn={translations:{label:"Mercado Pago",button:{label:"Pay with Mercado Pago"}}};class fn extends en{constructor(e,t,i,n){var s,o,r,a;super("payrails-generic-redirect-dropin",(null===(s=null==i?void 0:i.translations)||void 0===s?void 0:s.label)||pn.translations.label,void 0,null==i?void 0:i.events,null===(o=null==i?void 0:i.styles)||void 0===o?void 0:o.element),this.sdkConfig=e,this.execution=t,this.returnInfo=n,this.component=new In(this.sdkConfig,this.execution,{styles:null===(r=null==i?void 0:i.styles)||void 0===r?void 0:r.mercadoPago,translations:(null===(a=null==i?void 0:i.translations)||void 0===a?void 0:a.button)||pn.translations.button,events:null==i?void 0:i.events},this.returnInfo)}}const vn={apiVersion:2,apiVersionMinor:0};class mn extends ji{static getSDKClient(t=exports.PayrailsEnvironment.TEST,i){return e(this,void 0,void 0,(function*(){return yield Vi.load(Bi.GooglePay),mn.googleSDKClient||(mn.googleSDKClient=new google.payments.api.PaymentsClient({environment:t,merchantInfo:i})),mn.googleSDKClient}))}static isGooglePayAvailable(t,i=exports.PayrailsEnvironment.TEST,n){return e(this,void 0,void 0,(function*(){try{const e=yield mn.getSDKClient(i,n),s=Object.assign(Object.assign({},vn),{allowedPaymentMethods:t}),{result:o}=yield e.isReadyToPay(s);return o}catch(e){return!1}}))}constructor(e,t,i){super("div",Object.assign(Object.assign({},i),{id:"payrails-google-pay-button"})),this.sdkConfig=e,this.execution=t,this.options=i,this.googleButton=null,this.paymentExecutor=new L(e,t),mn.isGooglePayAvailable(this.execution.googlePayConfig,this.options.environment,this.options.merchantInfo).then((e=>{var t,i,n;e&&(null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onGooglePayAvailable)||void 0===n||n.call(i))}))}sdkLoaded(t){var i,n,s,o,r,a,l,d;return e(this,void 0,void 0,(function*(){const c=(null===(n=null===(i=this.options)||void 0===i?void 0:i.styles)||void 0===n?void 0:n.buttonColor)||"black",u=(null===(o=null===(s=this.options)||void 0===s?void 0:s.styles)||void 0===o?void 0:o.buttonType)||"long",E=(null===(a=null===(r=this.options)||void 0===r?void 0:r.styles)||void 0===a?void 0:a.buttonSizeMode)||"fill",_=(null===(d=null===(l=this.options)||void 0===l?void 0:l.styles)||void 0===d?void 0:d.buttonLocale)||void 0;return this.googleButton=t.createButton({buttonColor:c,buttonType:u,buttonSizeMode:E,buttonLocale:_,onClick:()=>e(this,void 0,void 0,(function*(){(yield O(this.options.events))&&(yield this.authorize(t))})),allowedPaymentMethods:this.execution.googlePayConfig}),this.element.appendChild(this.googleButton),this.googleButton}))}onLoadPaymentData(t){var i,n,s,o,r,a,l,d;return e(this,void 0,void 0,(function*(){const e=[{paymentMethodCode:S.GOOGLE_PAY,integrationType:"api",paymentInstrumentData:{paymentToken:JSON.stringify(t)},amount:this.sdkConfig.amount,storeInstrument:this.shouldStoreInstrument}],c=yield this.paymentExecutor.pay(e);if("authorizePending"===(null===(i=null==c?void 0:c.finalState)||void 0===i?void 0:i.code)){new b(this.options,this.execution,this.paymentExecutor).handle3ds(c)}else"authorizeSuccessful"===(null===(n=null==c?void 0:c.finalState)||void 0===n?void 0:n.code)?null===(r=null===(o=null===(s=this.options)||void 0===s?void 0:s.events)||void 0===o?void 0:o.onAuthorizeSuccess)||void 0===r||r.call(o):null===(d=null===(l=null===(a=this.options)||void 0===a?void 0:a.events)||void 0===l?void 0:l.onAuthorizeFailed)||void 0===d||d.call(l,c)}))}authorize(t){var i,n,s,o,r,a,l,d;return e(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},vn),{allowedPaymentMethods:this.execution.googlePayConfig,transactionInfo:{totalPriceStatus:"FINAL",totalPrice:null===(i=this.sdkConfig.amount)||void 0===i?void 0:i.value,currencyCode:null===(n=this.sdkConfig.amount)||void 0===n?void 0:n.currency,countryCode:null===(a=null===(r=null===(o=null===(s=this.execution.meta)||void 0===s?void 0:s.order)||void 0===o?void 0:o.billingAddress)||void 0===r?void 0:r.country)||void 0===a?void 0:a.code},merchantInfo:{merchantId:(null===(l=this.options.merchantInfo)||void 0===l?void 0:l.merchantId)||"",merchantName:(null===(d=this.options.merchantInfo)||void 0===d?void 0:d.merchantName)||""}});t.loadPaymentData(e).then((e=>{this.onLoadPaymentData(e)})).catch((e=>{var t,i,n;(null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onAuthorizeFailed)&&(null===(n=this.options)||void 0===n||n.events.onAuthorizeFailed(e))}))}))}mount(t){super.mount(t),(()=>{e(this,void 0,void 0,(function*(){var e;try{if(yield mn.isGooglePayAvailable(this.execution.googlePayConfig,this.options.environment,this.options.merchantInfo)){const t=yield mn.getSDKClient(this.options.environment,this.options.merchantInfo),i=yield this.sdkLoaded(t);this.element.appendChild(i),null===(e=this.storeInstrumentCheckbox)||void 0===e||e.mount(this.selector)}}catch(e){}}))})()}unmount(){var e,t,i;null===(t=null===(e=this.googleButton)||void 0===e?void 0:e.parentElement)||void 0===t||t.removeChild(this.googleButton),null===(i=this.storeInstrumentCheckbox)||void 0===i||i.unmount(),super.unmount()}}mn.googleSDKClient=null;class Nn extends dn{constructor(e,t,i){var n,s;super("google-pay-dropin",(null===(s=null===(n=i.translations)||void 0===n?void 0:n.labels)||void 0===s?void 0:s.label)||"Google Pay",void 0,i.events,i.styles),this.loadElementId="google-pay-dropin-load-element",this.component=new mn(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},i.events),{onGooglePayAvailable:()=>{this.mountAfterAvailable()}})}))}}class Tn extends ji{constructor(t,i,n){super("div",Object.assign(Object.assign({},n),{id:"payrails-paypal-button",events:Object.assign(Object.assign({},null==n?void 0:n.events),{onSaveInstrumentCheckboxChanged:t=>e(this,void 0,void 0,(function*(){var e,i,n,s;null===(n=null===(i=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===i?void 0:i.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(i,t),null===(s=this.button)||void 0===s||s.close();const o=yield this.loadPaypal();o&&(this.button=o,yield this.button.render(`#${this.buttonWrapperId}`))}))})})),this.sdkConfig=t,this.execution=i,this.options=n,this.buttonWrapperId="payrails-paypal-button-wrapper",this.checkboxWrapperId="payrails-paypal-checkbox-wrapper",this.createOneTimeOrder=()=>e(this,void 0,void 0,(function*(){var e,t,i,n,s,o,r;const a=[{paymentMethodCode:S.PAYPAL,integrationType:"api",amount:this.sdkConfig.amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!1}],l=yield this.paymentExecutor.pay(a),d=null===(i=null===(t=null===(e=l.response.links.confirm)||void 0===e?void 0:e.action)||void 0===t?void 0:t.parameters)||void 0===i?void 0:i.orderId;if(!d)throw null===(o=null===(s=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===s?void 0:s.onAuthorizeFailed)||void 0===o||o.call(s),new yn("No order id returned");return this.confirmLink=null===(r=l.response.links.confirm)||void 0===r?void 0:r.href,d})),this.loadPaypal().catch((()=>{})),this.element.innerHTML=`<div id="${this.buttonWrapperId}"></div><div id="${this.checkboxWrapperId}"></div>`,this.paymentExecutor=new L(t,i),this.fraudNetGuid=null==n?void 0:n.fraudNetGuid}loadPaypal(){return e(this,void 0,void 0,(function*(){const e=yield Vi.load(Bi.PayPal,this.paypalScriptConfig);return yield this.createPaypalButton(e)}))}get paypalScriptConfig(){const e=this.shouldStoreInstrument?"tokenize":"Instant"===this.execution.paypalConfig.captureMode?"capture":"authorize";return{clientId:this.execution.paypalConfig.clientId,intent:e,currency:this.sdkConfig.amount.currency,vault:this.shouldStoreInstrument}}createPaypalButton(t){var i,n,s;return e(this,void 0,void 0,(function*(){if(!t.Buttons)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR);const e=t.Buttons(this.createPayPalButtonConfig());return null===(s=null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n?void 0:n.onPaypalAvailable)||void 0===s||s.call(n),e}))}createPayPalButtonConfig(){return this.shouldStoreInstrument?this.createBillingAgreementConfig():this.createOneTimeOrderConfig()}createBillingAgreementConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{onApprove:this.approvePayment.bind(this),createBillingAgreement:()=>e(this,void 0,void 0,(function*(){var e,t,i,n;const s=[{paymentMethodCode:S.PAYPAL,integrationType:"api",amount:this.sdkConfig.amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!0}],o=yield this.paymentExecutor.pay(s);return this.confirmLink=null===(e=o.response.links.confirm)||void 0===e?void 0:e.href,(null===(n=null===(i=null===(t=o.response.links.confirm)||void 0===t?void 0:t.action)||void 0===i?void 0:i.parameters)||void 0===n?void 0:n.tokenId)||""}))})}createOneTimeOrderConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{createOrder:this.createOneTimeOrder.bind(this),onApprove:this.approvePayment.bind(this)})}createBaseConfig(){var t,i,n,s,o,r,a,l,d,c;return{fundingSource:"paypal",style:{color:(null===(i=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===i?void 0:i.color)||"gold",height:(null===(s=null===(n=this.options)||void 0===n?void 0:n.styles)||void 0===s?void 0:s.height)||40,label:(null===(r=null===(o=this.options)||void 0===o?void 0:o.styles)||void 0===r?void 0:r.label)||"paypal",shape:(null===(l=null===(a=this.options)||void 0===a?void 0:a.styles)||void 0===l?void 0:l.shape)||"rect",tagline:(null===(c=null===(d=this.options)||void 0===d?void 0:d.styles)||void 0===c?void 0:c.tagline)||!1},onError:e=>{var t,i;(null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onAuthorizeFailed)&&this.options.events.onAuthorizeFailed(e)},onClick:(t,i)=>e(this,void 0,void 0,(function*(){var e;return(yield O(null===(e=this.options)||void 0===e?void 0:e.events))?i.resolve():i.reject()}))}}approvePayment(t){var i,n,s,o,r,a,l,d,c,u;return e(this,void 0,void 0,(function*(){if(!this.confirmLink)throw null===(s=null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n?void 0:n.onAuthorizeFailed)||void 0===s||s.call(n),new yn("No confirm link");const e={};this.shouldStoreInstrument&&t.billingToken&&(e.tokenId=t.billingToken),this.fraudNetGuid&&(e.riskSessionCorrelationId=this.fraudNetGuid);const E=yield this.paymentExecutor.confirm(this.confirmLink,e);"authorizeSuccessful"===(null===(o=E.finalState)||void 0===o?void 0:o.code)?null===(l=null===(a=null===(r=this.options)||void 0===r?void 0:r.events)||void 0===a?void 0:a.onAuthorizeSuccess)||void 0===l||l.call(a):null===(u=null===(c=null===(d=this.options)||void 0===d?void 0:d.events)||void 0===c?void 0:c.onAuthorizeFailed)||void 0===u||u.call(c)}))}mount(t){super.mount(t),(()=>{e(this,void 0,void 0,(function*(){var e;const t=yield this.loadPaypal();t&&(this.button=t);try{null===(e=this.storeInstrumentCheckbox)||void 0===e||e.mount(`#${this.checkboxWrapperId}`),yield null==t?void 0:t.render(`#${this.buttonWrapperId}`)}catch(e){const t=new On(e.message,e);throw r.PayrailsLogger.error(t.message,{error:t}),t}}))})()}unmount(){var e;null===(e=this.button)||void 0===e||e.close(),super.unmount()}}class yn extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION,{description:`PaypalOrderError: ${e}`,cause:t})}}class On extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT,{description:`PaypalButtonError: ${e}`,cause:t})}}class An extends dn{constructor(e,t,i){var n,s;super("payrails-paypal-button-dropin",(null===(s=null===(n=null==i?void 0:i.translations)||void 0===n?void 0:n.labels)||void 0===s?void 0:s.label)||"PayPal",void 0,void 0,null==i?void 0:i.styles),this.loadElementId="paypal-dropin-load-element",this.component=new Tn(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},null==i?void 0:i.events),{onPaypalAvailable:()=>{this.mountAfterAvailable()}})}))}}class Ln extends M{constructor(e,t,i,n,s){var o,r;super("fieldset",{id:"payrails-dropin-component"}),this.collectContainer=e,this.clientConfig=t,this.dropinConfig=i,this.execution=n,this.sdkConfig=s,this.applyStyles();void 0!==(null===(r=null===(o=this.dropinConfig.paymentMethodsConfiguration)||void 0===o?void 0:o.cards)||void 0===r?void 0:r.showExistingCards)&&console.warn("The `showExistingCards` option is deprecated and will be removed in a future version. Please use `showStoredInstruments` instead.");const a=new Map;this.execution.storedPaymentInstruments.forEach((e=>{if(this.isStoredInstrumentEnabled(e.paymentMethod)){this.cardPaymentButton=this.createCardPaymentButton();const t=this.createStoredInstrumentElement(e);a.set(t.identifier,t)}}));const l={[S.CARD]:this.createCreditCardButton.bind(this),[S.PAYPAL]:this.createPayPalButton.bind(this),[S.GOOGLE_PAY]:this.createGooglePayButton.bind(this),[S.APPLE_PAY]:this.createApplePayButton.bind(this),[S.GENERIC_REDIRECT]:this.createMercadoPagoButton.bind(this)};this.execution.availablePaymentMethods.forEach((({paymentMethodCode:e})=>{if(e&&l[e]){l[e];const t=l[e]();a.set(t.identifier,t)}})),this.element.addEventListener("change",(e=>{var t,i;const n=(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.value)||"";a.forEach((e=>{e.deactivate()})),null===(i=a.get(n))||void 0===i||i.activate()})),1===this.totalPaymentOptions&&this.element.classList.add("payrails-dropin-component--single"),this.subElements.push(...Array.from(a.values()))}createStoredInstrumentElement(e){var t;return this.cardPaymentButton=this.createCardPaymentButton(),new sn(e,this.cardPaymentButton,(e=>{this.cardPaymentButton&&(this.cardPaymentButton.selectedInstrument=e)}),null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.element)}createMercadoPagoButton(){var e,t,i,n,s;return this.mercadoPago=new fn(this.sdkConfig,this.execution,{styles:{element:null===(t=null===(e=this.dropinConfig)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.element,mercadoPago:null===(n=null===(i=this.dropinConfig)||void 0===i?void 0:i.styles)||void 0===n?void 0:n.mercadoPago},translations:null===(s=this.dropinConfig.translations)||void 0===s?void 0:s.mercadoPago,events:this.getElementEvents()},this.clientConfig.returnInfo),this.mercadoPago}get totalPaymentOptions(){return this.execution.availablePaymentMethods.length+this.execution.storedPaymentInstruments.length}createCreditCardButton(){var e;return this.creditCard=new un(this.createCardForm(),this.createCardPaymentButton(),null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.element,this.getElementEvents()),this.creditCard}createGooglePayButton(){var e,t,i;return this.googlePay=new Nn(this.sdkConfig,this.execution,Object.assign({environment:this.clientConfig.environment||exports.PayrailsEnvironment.TEST,events:this.getElementEvents(),styles:Object.assign(Object.assign({},null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.googlePayButton),null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.element)},null===(i=this.dropinConfig.paymentMethodsConfiguration)||void 0===i?void 0:i.googlePay)),this.googlePay}createPayPalButton(){var e,t,i;return this.paypal=new An(this.sdkConfig,this.execution,Object.assign(Object.assign({},null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.payPal),{styles:Object.assign(Object.assign({},null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.paypalButton),null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.element),events:this.getElementEvents()})),this.paypal}createCardForm(){var e,t,i,n;if(!this.cardForm){const s=null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.cards,o=Boolean(null==s?void 0:s.showStoreInstrumentCheckbox),r=Boolean(null==s?void 0:s.showCardHolderName),a=Boolean(null==s?void 0:s.alwaysStoreInstrument);this.cardForm=new Zi(this.collectContainer,{showStoreInstrumentCheckbox:o,showCardHolderName:r,alwaysStoreInstrument:a,translations:null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.cardForm,styles:Object.assign(Object.assign({},null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.cardForm),null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.element),events:Object.assign(Object.assign({},this.getElementEvents()),{onFocus:()=>{var e;null===(e=this.creditCard)||void 0===e||e.activate()},onChange:({isValid:e})=>{var t;null===(t=this.cardPaymentButton)||void 0===t||t.setDisabled(!e)},onSaveInstrumentCheckboxChanged:e=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onSaveInstrumentCheckboxChanged)||void 0===i||i.call(t,e)}})})}return this.cardPaymentButton&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardForm}createApplePayButton(){var e,t,i;return this.applePay=new cn(this.sdkConfig,this.execution,Object.assign(Object.assign({events:Object.assign(Object.assign({},this.getElementEvents()),{onAuthorizeSuccess:e=>{var t;if(e)if("authorizeSuccessful"===(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code))this.onAuthorizeSuccess();else this.onAuthorizeFailed()}})},null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.applePay),{styles:Object.assign(Object.assign({},null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.applePayButton),null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.element)})),this.applePay}createCardPaymentButton(){var e,t;return this.cardPaymentButton||(this.cardPaymentButton=new w(this.sdkConfig,this.execution,{styles:null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.cardPaymentButton,translations:null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.cardPaymentButton,events:this.getElementEvents()},this.clientConfig.returnInfo)),this.cardForm&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardPaymentButton}onAuthorizeSuccess(){var e,t,i,n,s,o;this.subElements.forEach((e=>e.unmount())),new ln({translations:{label:null===(i=null===(t=null===(e=this.dropinConfig)||void 0===e?void 0:e.translations)||void 0===t?void 0:t.paymentResult)||void 0===i?void 0:i.success},styles:null===(s=null===(n=this.dropinConfig)||void 0===n?void 0:n.styles)||void 0===s?void 0:s.authSuccess}).mount(this.selector),(null===(o=this.dropinConfig.events)||void 0===o?void 0:o.onAuthorizeSuccess)&&this.dropinConfig.events.onAuthorizeSuccess()}getElementEvents(){return Object.assign(Object.assign({},this.dropinConfig.events),{onAuthorizeSuccess:this.onAuthorizeSuccess.bind(this),onAuthorizeFailed:this.onAuthorizeFailed.bind(this),onAvailable:()=>{var e;(1===this.totalPaymentOptions||(null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.preselectFirstPaymentOption))&&this.subElements[0].activate()}})}onAuthorizeFailed(e){var t,i,n,s,o;new an({translations:{label:null===(i=null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.paymentResult)||void 0===i?void 0:i.fail},styles:null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.authFailed}).mount(this.selector),null===(o=null===(s=this.dropinConfig.events)||void 0===s?void 0:s.onAuthorizeFailed)||void 0===o||o.call(s,e)}isStoredInstrumentEnabled(e){var t,i,n,s,o,r;switch(e){case S.CARD:return!1!==(null===(i=null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.cards)||void 0===i?void 0:i.showStoredInstruments)||!1!==(null===(s=null===(n=this.dropinConfig.paymentMethodsConfiguration)||void 0===n?void 0:n.cards)||void 0===s?void 0:s.showExistingCards);case S.PAYPAL:case S.GOOGLE_PAY:case S.APPLE_PAY:return!1!==(null===(r=null===(o=this.dropinConfig.paymentMethodsConfiguration)||void 0===o?void 0:o[e])||void 0===r?void 0:r.showStoredInstruments);default:return!1}}applyStyles(){var e;(null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.container)&&Object.assign(this.element.style,this.dropinConfig.styles.container)}}const gn={visa:/^4\d*/,mastercard:/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720)\d*/,amex:/^3[47]\d*/,diners:/^(36|38|30[0-5])\d*/,discover:/^(6011|65|64[4-9]|622)\d*/,jcb:/^35\d*/,hipercard:/^606282\d*/,unionpay:/^62\d*/,maestro:/^(5018|5020|5038|5043|5[6-9]|6020|6304|6703|6759|676[1-3])\d*/};class Rn{constructor(e,t,i){this.sdkConfig=i,this.bin="",this.id="payrails-container-wrapper",this.containerType="COMPOSABLE",this.cardTableName=t.cardTableName||"cards",this.containerType=t.containerType||"COMPOSABLE",this.__container=e.container(this.containerType,t)}static init(e,t,i){return this.instance&&this.instance.__container.unmount(),this.instance=new Rn(e,t,i),this.instance}createCollectElement(e){const t={required:!!e.required,enableCardIcon:!1!==e.enableCardIcon},i=this.__container.create(Object.assign(Object.assign({table:this.cardTableName,labelStyles:{},errorTextStyles:{},column:this.elementToFieldMap.get(e.type)},e),{type:e.type===exports.ElementType.CARDHOLDER_NAME?"INPUT_FIELD":e.type}),e.format?Object.assign(Object.assign({},t),{format:e.format}):t);return this.attachCustomEventHandler(i)}mount(e){if("COLLECT"===this.containerType){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw r.PayrailsLogger.error(e.message),e}this.element=document.createElement("span"),this.element.setAttribute("id",this.id);const t=document.querySelector(e);if(!t){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING);throw r.PayrailsLogger.error(t.message,{error:t,extra:{elementSelector:e}}),t}t.appendChild(this.element),window.setTimeout((()=>{this.__container.mount(`#${this.id}`)}),50)}unmount(){this.element&&this.element.remove()}collect(){return e(this,void 0,void 0,(function*(){try{return this.sdkConfig.usePayrailsFrames?yield this.collectPayrailsData():yield this.collectSkyflowData()}catch(e){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CARD_FORM_ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE,{description:"Error collecting data from the iframe!"});throw r.PayrailsLogger.error(t.message,{error:t}),t}}))}collectSkyflowData(){return e(this,void 0,void 0,(function*(){const e=(yield this.__container.collect()).records,{skyflow_id:t,card_number:i,cardholder_name:n,expiry_month:s,expiry_year:o,security_code:r}=e[0].fields;return{instrumentId:t,card_number:i,cardholder_name:n,expiry_month:s,expiry_year:o,security_code:r}}))}collectPayrailsData(){return e(this,void 0,void 0,(function*(){const e=yield this.__container.collect();return Object.assign(Object.assign({},e),{vaultProviderConfigId:this.sdkConfig.vaultConfiguration.providerConfigId})}))}tokenize(t){return e(this,void 0,void 0,(function*(){const e=yield this.collect(),i=this.sdkConfig.vaultConfiguration.links.saveInstrument.href,n=this.sdkConfig.token;if(!i){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND,{description:"Save instrument URL not available!"});throw r.PayrailsLogger.error(e.message,{error:e}),e}const s=yield(({url:e,token:t,body:i})=>I({url:e,token:t,method:h.POST,body:i}))({url:i,token:n,body:this.constructSaveInstrumentBody(e,t)});return s.res}))}constructSaveInstrumentBody(e,t){var i,n;const s={holderReference:this.sdkConfig.holderReference,paymentMethod:"card",storeInstrument:null!==(i=null==t?void 0:t.storeInstrument)&&void 0!==i&&i,futureUsage:null!==(n=null==t?void 0:t.futureUsage)&&void 0!==n?n:"CardOnFile"};return this.sdkConfig.usePayrailsFrames?s.data={encryptedData:e.encryptedData,vaultProviderConfigId:e.vaultProviderConfigId}:s.token={providerId:this.sdkConfig.vaultConfiguration.providerId,providerConfigId:this.sdkConfig.vaultConfiguration.providerConfigId,reference:e.instrumentId,type:"card",meta:{skyflow_id:e.instrumentId,card_number:e.card_number,cardholder_name:e.cardholder_name,expiry_month:e.expiry_month,expiry_year:e.expiry_year,security_code:e.security_code}},s}attachCustomEventHandler(e){return new Proxy(e,{get:(e,t)=>{if("on"!==t)return e[t];return((i,n)=>{e[t].call(e,i,(e=>{"CHANGE"===i?(e.elementType===exports.ElementType.CARD_NUMBER&&(e.network=function(e){for(const[t,i]of Object.entries(gn))if(i.test(e))return t;return""}(e.value),e.bin=this.formatBin(e.value),this.bin=this.formatBin(e.value)),n(e)):n(e)}))}).bind(e)}})}formatBin(e){return e.replace(/-|X/g,"")}get elementToFieldMap(){return new Map([[exports.ElementType.CARD_NUMBER,"card_number"],[exports.ElementType.CARDHOLDER_NAME,"cardholder_name"],[exports.ElementType.CVV,"security_code"],[exports.ElementType.EXPIRATION_MONTH,"expiry_month"],[exports.ElementType.EXPIRATION_YEAR,"expiry_year"]])}}class Sn{constructor(e,t,i){this.pageId=e,this.execution=t,this.environment=i,this.guid=_().replace(/-/g,""),this.fnclsVal="fnparams-dede7cc5-15fd-4c75-a9f4-36c430ee3a99",this.configId=_(),this.scriptId=_()}mount(){this.loadFraudnet(this.pageId)}unmount(){var e,t;null===(e=document.getElementById(this.configId))||void 0===e||e.remove(),null===(t=document.getElementById(this.scriptId))||void 0===t||t.remove()}loadFraudnet(e){this.unmount();const t=this.createFraudnetConfig(e);document.body.appendChild(t);const i=document.createElement("script");i.setAttribute("id",this.scriptId),i.src="https://c.paypal.com/da/r/fb.js",document.body.appendChild(i)}get payPalConfig(){return this.execution.paypalConfig}createFraudnetConfig(e){const t=document.createElement("script");return t.setAttribute("type","application/json"),t.setAttribute("fncls",this.fnclsVal),t.setAttribute("id",this.configId),t.innerText=JSON.stringify({f:this.guid,s:`${this.payPalConfig.merchantId}_${e}`,sandbox:"TEST"===this.environment}),t}}const Cn=()=>{const e=document.getElementById("sdk-observer");return e||(()=>{const e=document.createElement("iframe");return e.id="sdk-observer",e.src="https://assets.payrails.io/0d7f8b3/observability/index.html",e.width="1px",e.height="1px",document.body.appendChild(e),e})()};
21
+ return function(e,t){var i=document.querySelector('script[src="'.concat(e,'"]'));if(null===i)return null;var n=xi(e,t),o=i.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(n.dataset).length)return null;var s=!0;return Object.keys(o.dataset).forEach((function(e){o.dataset[e]!==n.dataset[e]&&(s=!1)})),s?i:null}(n,o)&&r?t.resolve(r):function(e,t){void 0===t&&(t=Fi());Bi(e,t);var i=e.url,n=e.attributes;if("string"!=typeof i||0===i.length)throw new Error("Invalid url.");if(void 0!==n&&"object"!=typeof n)throw new Error("Expected attributes to be an object.");return new t((function(e,t){if("undefined"==typeof window)return e();!function(e){var t=e.url,i=e.attributes,n=e.onSuccess,o=e.onError,s=xi(t,i);s.onerror=o,s.onload=n,document.head.insertBefore(s,document.head.firstElementChild)}({url:i,attributes:n,onSuccess:function(){return e()},onError:function(){var e=new Error('The script "'.concat(i,'" failed to load.'));return window.fetch?fetch(i).then((function(i){return 200===i.status&&t(e),i.text()})).then((function(e){var i=function(e){var t=e.split("/* Original Error:")[1];return t?t.replace(/\n/g,"").replace("*/","").trim():e}(e);t(new Error(i))})).catch((function(e){t(e)})):t(e)}})}))}({url:n,attributes:o},t).then((function(){var e=Vi(s);if(e)return e;throw new Error("The window.".concat(s," global variable is not available."))}))}function Fi(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function Vi(e){return window[e]}function Bi(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}yi=new WeakMap,Oi=new WeakMap,Ai=new WeakMap,Li=new WeakMap,Ri=new WeakMap,gi=new WeakMap,Si=new WeakMap,Ci=new WeakMap;class Gi{static load(e,t){if(e===ji.PayPal){if(!t)throw new Error("PayPal config is required");return Gi.loadPayPalScript(t)}return Gi.loadScript(e)}static reset(){Gi.scriptMap.clear()}static preloadCardForm(){const e="https://assets.payrails.io/8f2cbee/card";[["https://js.skyflow.com/v1/elements/index.js","payrails-iframe-js-v1"],["https://js.skyflow.com/v1/elements/index.html","payrails-iframe-html-v1"],[`${e}/index.js`,"payrails-iframe-js-v2"],[`${e}/index.html`,"payrails-iframe-html-v2"]].forEach((([e,t])=>{if(!document.getElementById(t)){const i=document.createElement("link");i.id=t,i.rel="preload",i.as="script",i.href=e,document.head.appendChild(i)}}))}static loadScript(e){const t=`payrails-script-${JSON.stringify(e)}`;if(Gi.scriptMap.has(t))return Gi.scriptMap.get(t);const i=document.createElement("script");i.src=e,i.id=t;const n=new Promise(((t,n)=>{i.onload=()=>{t()},i.onerror=t=>{n(Gi.logLoadError(e,new Error(t.toString())))}}));return Gi.scriptMap.set(t,n),document.body.appendChild(i),n}static loadPayPalScript({clientId:t,currency:i,vault:n,intent:o}){return e(this,void 0,void 0,(function*(){try{const e=yield Yi({"client-id":t,components:"buttons,funding-eligibility",intent:o,currency:i,vault:n,"data-namespace":"payrailsPaypal"});if(e)return e}catch(e){throw Gi.logLoadError(ji.PayPal,e)}throw Gi.logLoadError(ji.PayPal)}))}constructor(){}static logLoadError(e,t){const i=new Map([[ji.ApplePay,s.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR],[ji.GooglePay,s.ERROR_CODES.PAYRAILS_CLIENT_GPAY_LOADING_ERROR],[ji.PayPal,s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR]]),n=new s.PayrailsError(i.get(e)||s.ERROR_CODES.PAYRAILS_CLIENT_UNKNOWN_ERROR,{cause:t,description:null==t?void 0:t.message});return r.PayrailsLogger.error(n.message,{error:n}),n}}var ji;Gi.scriptMap=new Map,function(e){e.ApplePay="https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js",e.GooglePay="https://pay.google.com/gp/p/js/pay.js",e.PayPal="paypal-sdk"}(ji||(ji={}));class Xi extends U{constructor(e){super("span",{id:e.id,className:"payrails-store-instrument"}),this.options=e,this.createHTML(),this.applyStyles(),this.addListeners()}get isChecked(){var e;return!!(null===(e=this.element.querySelector("input"))||void 0===e?void 0:e.checked)}createHTML(){var e,t,i,n,o,s,r,a,l;const d=(null===(i=null===(t=null===(e=this.options)||void 0===e?void 0:e.translations)||void 0===t?void 0:t.labels)||void 0===i?void 0:i.saveInstrument)||(null===(s=null===(o=null===(n=this.options)||void 0===n?void 0:n.translations)||void 0===o?void 0:o.labels)||void 0===s?void 0:s.storeInstrument)||"Save instrument for future payments",c=`${this.id}-checkbox`;(null===(l=null===(a=null===(r=this.options)||void 0===r?void 0:r.translations)||void 0===a?void 0:a.labels)||void 0===l?void 0:l.saveInstrument)&&console.warn("The saveInstrument label is deprecated, please use storeInstrument instead"),this.element.innerHTML=`<label for="${c}"><input type="checkbox" id="${c}" name="${c}" class="payrails-store-instrument-checkbox">${d}</label>`}applyStyles(){var e,t;Object.keys((null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.storeInstrumentCheckbox)||{}).forEach((e=>{var t,i,n;this.element.style[e]=null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===i?void 0:i.storeInstrumentCheckbox)||void 0===n?void 0:n[e]}))}addListeners(){this.element.addEventListener("change",(e=>{var t,i,n,o;(null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onSaveInstrumentCheckboxChanged)&&(null===(o=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===o||o.onSaveInstrumentCheckboxChanged({checked:this.isChecked})),e.stopPropagation(),e.stopImmediatePropagation()})),this.element.addEventListener("click",(e=>{e.stopPropagation(),e.stopImmediatePropagation()}))}}class Hi extends U{constructor(t,i){var n,o;super(t,i),this.options=i,this.storeInstrumentCheckbox=null,(null===(n=this.options)||void 0===n?void 0:n.showStoreInstrumentCheckbox)&&(this.storeInstrumentCheckbox=new Xi(Object.assign(Object.assign({},i),{id:`${null===(o=this.options)||void 0===o?void 0:o.id}-store-instrument-checkbox`,events:{onSaveInstrumentCheckboxChanged:t=>e(this,void 0,void 0,(function*(){var e,n;null===(n=null===(e=null==i?void 0:i.events)||void 0===e?void 0:e.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(e,t)}))}})),this.subElements.push(this.storeInstrumentCheckbox))}get shouldStoreInstrument(){var e,t;return(null===(e=this.storeInstrumentCheckbox)||void 0===e?void 0:e.isChecked)||(null===(t=this.options)||void 0===t?void 0:t.alwaysStoreInstrument)||!1}}class Wi extends Hi{static isApplePayAvailable(){return e(this,void 0,void 0,(function*(){try{return yield Gi.load(ji.ApplePay),ApplePaySession.canMakePayments()}catch(e){return!1}}))}constructor(e,t,i){super("div",Object.assign(Object.assign({},i),{id:"payrails-apple-pay-button"})),this.sdkConfig=e,this.execution=t,this.options=i,this.appleButton=null,this.paymentExecutor=new L(e,t),Wi.isApplePayAvailable().then((e=>{var t,i,n;e&&(null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onApplePayAvailable)||void 0===n||n.call(i))}))}mount(t){super.mount(t),(()=>{e(this,void 0,void 0,(function*(){try{(yield Wi.isApplePayAvailable())&&(yield this.mountApplePayButton())}catch(e){}}))})()}unmount(){var e,t;null===(t=null===(e=this.appleButton)||void 0===e?void 0:e.parentElement)||void 0===t||t.removeChild(this.appleButton),super.unmount()}mountApplePayButton(){var t,i,n;return e(this,void 0,void 0,(function*(){try{const o=(null===(t=this.options.styles)||void 0===t?void 0:t.type)||"buy",s=(null===(i=this.options.styles)||void 0===i?void 0:i.style)||"black";this.element.innerHTML=`<apple-pay-button buttonstyle="${s}" type="${o}" locale="en-GB"></apple-pay-button>`,null===(n=this.storeInstrumentCheckbox)||void 0===n||n.mount(this.selector);const r=this.element.querySelector("apple-pay-button");null==r||r.setAttribute("style","width: 100%;"),null==r||r.addEventListener("click",(()=>e(this,void 0,void 0,(function*(){(yield O(this.options.events))&&this.createApplePaySession()}))))}catch(e){}}))}createApplePaySession(){const t=this.execution.applePayConfig,{countryCode:i,supportedNetworks:n,merchantCapabilities:o}=t,{amount:s}=this.sdkConfig;try{const t={countryCode:i,currencyCode:s.currency,merchantCapabilities:o,supportedNetworks:n,total:{label:"",type:"final",amount:s.value}},r=new ApplePaySession(3,t);return r.onvalidatemerchant=t=>e(this,void 0,void 0,(function*(){const{res:e}=yield this.paymentExecutor.createApplePaySession({requestUrl:this.execution.createSessionLink,sessionUrl:t.validationURL,clientDomain:this.options.clientDomain}),i=e.data.data;r.completeMerchantValidation(i)})),r.oncancel=()=>{var e,t,i;(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onAuthorizeFailed)&&(null===(i=this.options)||void 0===i||i.events.onAuthorizeFailed())},r.onpaymentauthorized=t=>e(this,void 0,void 0,(function*(){var e,i,n,o,s,a,l,d,c,u,E,_;try{const u=yield this.onApplePayAuthorized(t.payment.token);if("authorizeSuccessful"===(null===(e=null==u?void 0:u.finalState)||void 0===e?void 0:e.code))(null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeSuccess)&&this.options.events.onAuthorizeSuccess();else r.completePayment(ApplePaySession.STATUS_FAILURE),(null===(o=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===o?void 0:o.onAuthorizeFailed)&&(null===(s=this.options)||void 0===s||s.events.onAuthorizeFailed());r.completePayment(ApplePaySession.STATUS_SUCCESS),(null===(l=null===(a=this.options)||void 0===a?void 0:a.events)||void 0===l?void 0:l.onAuthorizeSuccess)&&(null===(c=null===(d=this.options)||void 0===d?void 0:d.events)||void 0===c||c.onAuthorizeSuccess(u))}catch(e){r.completePayment(ApplePaySession.STATUS_FAILURE),(null===(E=null===(u=this.options)||void 0===u?void 0:u.events)||void 0===E?void 0:E.onAuthorizeFailed)&&(null===(_=this.options)||void 0===_||_.events.onAuthorizeFailed(e))}})),r.begin(),r}catch(e){return null}}onApplePayAuthorized(t){return e(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},t),{paymentNetwork:t.paymentMethod.network,paymentInstrumentName:t.paymentMethod.displayName}),i=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.APPLE_PAY,integrationType:"api",paymentInstrumentData:{paymentToken:JSON.stringify(e)},amount:this.sdkConfig.amount,storeInstrument:this.shouldStoreInstrument}];return yield this.paymentExecutor.pay(i)}))}}const{CARD_NUMBER:zi,CVV:Ki,CARDHOLDER_NAME:$i,EXPIRATION_MONTH:qi,EXPIRATION_YEAR:Ji}=exports.ElementType,Zi={base:{border:"none",padding:"10px 16px",color:"#1d1d1d",backgroundColor:"#fff"},invalid:{backgroundColor:"#f9e1e1",borderColor:"#f25226",border:"1px solid"}},Qi=[{type:$i,placeholder:"Card holder",styles:Object.assign(Object.assign({},Zi),{base:Object.assign(Object.assign({},Zi.base),{border:"1px solid #eae8ee",padding:"10px 16px",borderTopLeftRadius:"4px",borderTopRightRadius:"4px"})})},{type:zi,placeholder:"1234 1234 1234 1234",styles:Object.assign(Object.assign({},Zi),{base:Object.assign(Object.assign({},Zi.base),{border:"1px solid #eae8ee",padding:"10px 16px",borderTopLeftRadius:"4px",borderTopRightRadius:"4px",textIndent:"0"}),cardIcon:{position:"absolute",right:"8px",height:"24px",bottom:"calc(50% - 12px)"}})},{type:qi,placeholder:"MM",styles:Object.assign(Object.assign({},Zi),{base:Object.assign(Object.assign({},Zi.base),{borderBottom:"1px solid #eae8ee",borderLeft:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomLeftRadius:"4px"})})},{type:Ji,placeholder:"YY",format:"YY",styles:Object.assign(Object.assign({},Zi),{base:Object.assign(Object.assign({},Zi.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee"})})},{type:Ki,placeholder:"CVC",styles:Object.assign(Object.assign({},Zi),{base:Object.assign(Object.assign({},Zi.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomRightRadius:"4px"})})}];class en extends Hi{get bin(){return this.collectContainer.bin}constructor(e,t){var i,n,o,s,r;super("div",Object.assign(Object.assign({},t),{translations:Object.assign(Object.assign({},null==t?void 0:t.translations),{labels:Object.assign(Object.assign({},null===(i=null==t?void 0:t.translations)||void 0===i?void 0:i.labels),{saveInstrument:null===(o=null===(n=null==t?void 0:t.translations)||void 0===n?void 0:n.labels)||void 0===o?void 0:o.saveCreditCard})}),styles:Object.assign({storeInstrumentCheckbox:null===(s=null==t?void 0:t.styles)||void 0===s?void 0:s.storeCardCheckbox},null==t?void 0:t.styles),id:"payrails-card-form"})),this.collectContainer=e,this.options=t,this.formFields=[],(null===(r=null==t?void 0:t.styles)||void 0===r?void 0:r.storeCardCheckbox)&&console.warn("The `storeCardCheckbox` option for styles is deprecated. Please use `storeInstrumentCheckbox` instead."),Qi.forEach((({type:e,styles:i,format:n,placeholder:o})=>{var s,r,a,l,d,c,u;if(!(null===(s=this.options)||void 0===s?void 0:s.showCardHolderName)&&e===exports.ElementType.CARDHOLDER_NAME)return;const E=new tn(this.collectContainer,{type:e,label:null===(a=null===(r=null==t?void 0:t.translations)||void 0===r?void 0:r.labels)||void 0===a?void 0:a[e],placeholder:(null===(d=null===(l=null==t?void 0:t.translations)||void 0===l?void 0:l.placeholders)||void 0===d?void 0:d[e])||o,labelStyles:this.prepareLabelStyles(e),inputStyles:this.prepareInputStyles(i,e),format:n,events:{onFocus:null===(u=null===(c=this.options)||void 0===c?void 0:c.events)||void 0===u?void 0:u.onFocus,onChange:this.onChange.bind(this),onReady:this.triggerOnReady.bind(this)}});this.formFields.push(E)})),this.subElements.push(this.collectContainer),this.storeInstrumentCheckbox&&this.subElements.push(this.storeInstrumentCheckbox)}tokenize(e){return this.collectContainer.tokenize(e)}show(){var e,t;const i=document.getElementById(this.collectContainer.id);if(!i){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw r.PayrailsLogger.error(e.message,{error:e}),e}Object.assign(i.style,null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.wrapper),this.element.style.display="flex"}hide(){this.element.style.display="none"}triggerOnReady(){var e,t,i;this.formFields.reduce(((e,t)=>e&&t.isReady),!0)&&(null===(i=null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onReady)||void 0===i||i.call(t))}prepareLabelStyles(e){return["base"].reduce(((t,i)=>{var n,o,s,r,a,l,d,c;return t[i]=Object.assign(Object.assign(Object.assign({},null===(o=null===(n=this.options)||void 0===n?void 0:n.styles)||void 0===o?void 0:o.base),null===(a=null===(r=null===(s=this.options)||void 0===s?void 0:s.styles)||void 0===r?void 0:r.labels)||void 0===a?void 0:a.all),null===(c=null===(d=null===(l=this.options)||void 0===l?void 0:l.styles)||void 0===d?void 0:d.labels)||void 0===c?void 0:c[e]),t}),{})}prepareInputStyles(e,t){var i;let n=JSON.parse(JSON.stringify(e));return(null===(i=this.options)||void 0===i?void 0:i.showCardHolderName)&&t===exports.ElementType.CARD_NUMBER&&(this.element.setAttribute("class","with-card-holder"),n=Object.assign(Object.assign({},e),{base:Object.assign(Object.assign({},Zi.base),{border:"1px solid #eae8ee",borderTop:"none",padding:"10px 16px",textIndent:"0"})})),["base","complete","empty","focus","invalid","cardIcon","copyIcon"].forEach((e=>{var i,o,s,r,a,l,d,c;n[e]=Object.assign(Object.assign(Object.assign({},n[e]),null===(r=null===(s=null===(o=null===(i=this.options)||void 0===i?void 0:i.styles)||void 0===o?void 0:o.inputFields)||void 0===s?void 0:s.all)||void 0===r?void 0:r[e]),null===(c=null===(d=null===(l=null===(a=this.options)||void 0===a?void 0:a.styles)||void 0===l?void 0:l.inputFields)||void 0===d?void 0:d[t])||void 0===c?void 0:c[e])})),n}get isValid(){return this.formFields.reduce(((e,t)=>e&&t.isValid),!0)}get cardNetwork(){var e,t;return null!==(t=null===(e=this.formFields.find((e=>Boolean(e.cardNetwork))))||void 0===e?void 0:e.cardNetwork)&&void 0!==t?t:""}onChange(){var e,t,i,n;(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onChange)&&(null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n||n.onChange({isValid:this.isValid,cardNetwork:this.cardNetwork,bin:this.bin}))}collectValues(){return e(this,void 0,void 0,(function*(){return{cardData:yield this.collectContainer.collect(),storeInstrument:this.shouldStoreInstrument,enrollInstrumentToNetworkOffers:Boolean(this.enforceEnrollInstrumentToNetworkOffersForMasterCard())}}))}enforceEnrollInstrumentToNetworkOffersForMasterCard(){var e;return"mastercard"!==this.cardNetwork&&(null===(e=this.options)||void 0===e?void 0:e.enrollInstrumentToNetworkOffers)}}class tn{constructor(e,t){this.isValid=!1,this.isReady=!1,this.cardNetwork="";const{events:i}=t,n=e.createCollectElement(t);(null==i?void 0:i.onFocus)&&n.on("FOCUS",i.onFocus),n.on("READY",(()=>{var e,i;this.isReady=!0,null===(i=null===(e=t.events)||void 0===e?void 0:e.onReady)||void 0===i||i.call(e)})),n.on("CHANGE",(e=>{const{isEmpty:t,isValid:n,network:o}=e;this.isValid=!t&&n,this.cardNetwork=null!=o?o:"",(null==i?void 0:i.onChange)&&i.onChange(this)}))}}class nn extends U{constructor(e,t,i,n,o){super("div",{id:e,className:"payrails-dropin-item"}),this.events=n,this.styles=o,this.isActive=!1,this.mountContainerClass="payrails-dropin-item-container",this.applyBaseStyles();const s=`payrails-dropin-item-${e}`,r=document.createElement("label");r.setAttribute("for",s);const a=document.createElement("input");if(a.setAttribute("type","radio"),a.setAttribute("name","payment-option"),a.setAttribute("id",s),a.setAttribute("value",s),this.input=a,r.appendChild(a),this.label=r,i){const e=document.createElement("img");e.src=null!=i?i:"",e.className="payrails-store-instrument-icon",r.appendChild(e)}const l=document.createElement("span");r.appendChild(l),l.innerText=t,this.element.addEventListener("click",(()=>{var e,t;null===(t=(e=this.label).onchange)||void 0===t||t.call(e,new Event("change"))})),this.element.appendChild(r);const d=document.createElement("div");d.setAttribute("class",this.mountContainerClass),this.element.appendChild(d)}get identifier(){return`payrails-dropin-item-${this.id}`}deactivate(){var e,t;this.isActive&&(this.isActive=!1,this.input.checked=!1,this.applyBaseStyles(),null===(e=this.component)||void 0===e||e.unmount(),(null===(t=this.events)||void 0===t?void 0:t.onDeactivate)&&this.events.onDeactivate())}applyBaseStyles(){var e,t;this.element.classList.remove("active"),Object.keys((null===(e=this.styles)||void 0===e?void 0:e.active)||{}).forEach((e=>{this.element.style.removeProperty(e)})),Object.assign(this.element.style,null===(t=this.styles)||void 0===t?void 0:t.base)}applyActiveStyles(){var e,t;this.element.classList.add("active"),Object.assign(this.element.style,null===(e=this.styles)||void 0===e?void 0:e.base,null===(t=this.styles)||void 0===t?void 0:t.active)}activate(){var e,t;this.isActive||(null===(e=this.component)||void 0===e||e.mount(`${this.selector} .${this.mountContainerClass}`),this.applyActiveStyles(),this.input.checked=!0,this.isActive=!0,(null===(t=this.events)||void 0===t?void 0:t.onActivate)&&this.events.onActivate())}mount(e){var t,i;super.mount(e),null===(i=null===(t=this.events)||void 0===t?void 0:t.onAvailable)||void 0===i||i.call(t)}}var on;!function(e){e.AMEX="amex",e.DINERS="diners",e.DISCOVER="discover",e.HIPERCARD="hipercard",e.JCB="jcb",e.MAESTRO="maestro",e.MASTERCARD="mastercard",e.UNIONPAY="unionpay",e.VISA="visa"}(on||(on={}));const sn="https://assets.payrails.io/img/";class rn extends nn{constructor(e,t,i,n){const o=e.displayName&&""!==e.displayName?e.displayName:"Unavailable";super(`payrails-payment-instrument-${e.id}`,o,rn.getInstrumentIcon(e),{onActivate:()=>{i(e),this.component.setDisabled(!1)}},n),this.component=t}static getInstrumentIcon(e){var t;if(e.paymentMethod!==exports.PAYMENT_METHOD_CODES.CARD)return"";switch(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.network){case on.AMEX:return sn+"amex.svg";case on.DINERS:return sn+"diners-club.svg";case on.DISCOVER:return sn+"discover.svg";case on.HIPERCARD:return sn+"hipercard.svg";case on.JCB:return sn+"jcb.svg";case on.MAESTRO:return sn+"maestro.svg";case on.MASTERCARD:return sn+"mastercard.svg";case on.UNIONPAY:return sn+"unionpay.svg";case on.VISA:return sn+"visa.svg"}return sn+"default.svg"}}class an extends U{constructor(e,t){super("div",{id:"payrails-card-list"}),this.workflowExecution=e,this.listItems=[],this.workflowExecution.savedCreditCards.forEach((e=>{const i=new ln((()=>{(null==t?void 0:t.onCardChange)&&t.onCardChange(e)}),e);this.listItems.push(i),this.subElements.push(i)}))}reset(){this.element.querySelectorAll("input").forEach((e=>e.checked=!1))}}class ln extends U{constructor(e,t){super("div",{className:"payrails-card-list-item",id:`payrails-card-list-item-${t.id}`});const{id:i}=t,n=t.displayName&&""!==t.displayName?t.displayName:"Unavailable",o=document.createElement("label");o.setAttribute("for",i),o.addEventListener("click",e);const s=document.createElement("input");s.setAttribute("type","radio"),s.setAttribute("name","payment-option"),s.setAttribute("id",i),s.setAttribute("value",i),o.appendChild(s);const r=document.createElement("span");r.className="payment-option-text",o.appendChild(r);const a=document.createElement("img");a.src=rn.getInstrumentIcon(t),a.className="payment-option-icon",r.appendChild(a),r.appendChild(document.createTextNode(n)),this.element.appendChild(o)}}class dn extends U{constructor(e){var t;super("div",{id:"authorization-failed-message"});const i=(null===(t=null==e?void 0:e.translations)||void 0===t?void 0:t.label)||"Authorization failed, please try again.";this.element.innerText=i,this.setStyles((null==e?void 0:e.styles)||{}),this.element.innerHTML=`\n <div>\n <svg class="checkmark-cross" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">\n <circle class="checkmark-cross_circle" cx="26" cy="26" r="25" fill="none"/>\n <path class="checkmark-cross_check" fill="none" d="M14.1 14.1l23.8 23.8 m0,-23.8 l-23.8,23.8"/>\n </svg>\n </div>\n <div>${i}</div>`,this.element.addEventListener("click",(e=>{e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),this.unmount()}))}setStyles(e){Object.keys(e).forEach((t=>{this.element.style[t]=e[t]}))}}class cn extends U{constructor(e){var t;super("div",{id:"payrails-authorization-success-msg"}),this.setStyles((null==e?void 0:e.styles)||{}),this.element.innerHTML=`\n <div class="checkmark-wrapper">\n <svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">\n <circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none"/>\n <path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8"/>\n </svg>\n </div>\n <div id="payrails-authorization-success">${(null===(t=null==e?void 0:e.translations)||void 0===t?void 0:t.label)||"Payment successful"}</div`}setStyles(e){Object.keys(e).forEach((t=>{this.element.style[t]=e[t]}))}}class un extends nn{constructor(){super(...arguments),this.buttonShown=!1}activate(){if(!this.buttonShown)return super.activate(),void(this.buttonShown=!0);this.applyActiveStyles(),this.isActive=!0,this.element.querySelector(this.component.selector).style.display="block"}deactivate(){this.isActive&&(this.isActive=!1,this.applyBaseStyles(),this.element.querySelector(this.component.selector).style.display="none")}mountAfterAvailable(){var e,t;super.mount(`#${this.loadElementId}`),null===(t=null===(e=this.events)||void 0===e?void 0:e.onAvailable)||void 0===t||t.call(e)}mount(e){const t=document.querySelector(e);if(!t){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);throw r.PayrailsLogger.error(e.message,{error:e}),e}const i=document.createElement("div");i.setAttribute("id",this.loadElementId),i.setAttribute("style","width: 100%;"),t.appendChild(i)}unmount(){var e;super.unmount(),null===(e=document.querySelector(`#${this.loadElementId}`))||void 0===e||e.remove()}}class En extends un{constructor(e,t,i){var n,o;super("apple-pay-dropin",(null===(o=null===(n=i.translations)||void 0===n?void 0:n.labels)||void 0===o?void 0:o.label)||"Apple Pay",void 0,void 0,i.styles),this.loadElementId="apple-pay-dropin-load-element",this.component=new Wi(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},i.events),{onApplePayAvailable:()=>{this.mountAfterAvailable()}})}))}}class _n extends nn{constructor(e,t,i,n){super("payrails-credit-card-wrapper","Card",void 0,n,i),this.cardForm=e,this.paymentButton=t,this.cardFormShown=!1,this.component=new hn(e,t)}activate(){var e,t;this.applyActiveStyles(),this.cardFormShown||(this.cardFormShown=!0,null===(e=this.component)||void 0===e||e.mount(this.selector)),this.isActive||(this.paymentButton.selectedInstrument=null,this.paymentButton.mount(this.selector),this.paymentButton.setDisabled(!this.cardForm.isValid),this.paymentButton.mount("#payrails-card-form"),this.input.checked=!0,this.cardForm.show(),this.isActive=!0,(null===(t=this.events)||void 0===t?void 0:t.onActivate)&&this.events.onActivate())}deactivate(){var e;this.isActive&&(this.applyBaseStyles(),this.paymentButton.unmount(),this.cardForm.hide(),this.isActive=!1,(null===(e=this.events)||void 0===e?void 0:e.onDeactivate)&&this.events.onDeactivate())}}class hn extends U{constructor(e,t){super("div",{id:"payrails-form-container"}),this.subElements.push(e,t)}}class In extends U{constructor(e){var t,i,n,o;super("button",{id:e.id,className:"payrails-generic-button",styles:null!==(i=null===(t=e.styles)||void 0===t?void 0:t.base)&&void 0!==i?i:{}}),this.options=e,this.isDisabled=!1,this.element.innerText=null==e?void 0:e.translations.label,e.styles&&this.setStyles(null!==(o=null===(n=e.styles)||void 0===n?void 0:n.base)&&void 0!==o?o:{}),this.element.addEventListener("click",this.onClick.bind(this)),this.element.addEventListener("mouseenter",(()=>{var e;this.isDisabled||this.setStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{})})),this.element.addEventListener("mouseleave",(()=>{var e;this.isDisabled||this.removeStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{})}))}getElement(){return this.element}onClick(){var t,i;return e(this,void 0,void 0,(function*(){if((null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onClick)&&!this.isDisabled){try{this.triggerLoading(!0),yield this.options.events.onClick()}catch(e){throw this.triggerLoading(!1),e}this.triggerLoading(!1)}}))}setStyles(e){var t;const i=Object.assign(Object.assign({},null===(t=this.options.styles)||void 0===t?void 0:t.base),e);Object.keys(i).forEach((e=>{this.element.style[e]=i[e]}))}removeStyles(e){var t;const i=Object.keys((null===(t=this.options.styles)||void 0===t?void 0:t.base)||{});Object.keys(e).forEach((e=>{var t,n;i.includes(e)?this.element.style[e]=null===(n=null===(t=this.options.styles)||void 0===t?void 0:t.base)||void 0===n?void 0:n[e]:this.element.style[e]=""}))}triggerLoading(e){var t,i,n;this.isDisabled=e,e?(this.element.innerHTML='\n <div class="dot-flashing-container">\n <div class="dot-flashing"></div>\n <span class="dot-flashing-text" aria-hidden="true">Loading</span>\n </div>\n ',(null===(t=this.options.styles)||void 0===t?void 0:t.loading)&&this.setStyles(this.options.styles.loading)):(this.element.innerText=null===(i=this.options)||void 0===i?void 0:i.translations.label,this.removeStyles((null===(n=this.options.styles)||void 0===n?void 0:n.loading)||{}))}}const pn={label:"Generic redirect"};class fn extends U{constructor(e,t,i,n){super("div",{id:`payrails-generic-redirect-${i.paymentMethod.paymentMethodCode}`}),this.sdkConfig=e,this.execution=t,this.options=i,this.returnInfo=n;const o=this.buildRedirectButton();this.element.appendChild(o.getElement()),this.paymentExecutor=new L(e,t,this.returnInfo)}buildRedirectButton(){var e,t,i;return new In({id:"payrails-generic-redirect-button",translations:{label:null!==(t=null===(e=this.options.translations)||void 0===e?void 0:e.label)&&void 0!==t?t:pn.label},events:{onClick:this.onClick.bind(this)},styles:null!==(i=this.options.styles)&&void 0!==i?i:{}})}onClick(){var t,i,n,o;return e(this,void 0,void 0,(function*(){if(yield O(null!==(t=this.options.events)&&void 0!==t?t:{}))try{const e=null===(i=this.execution.availablePaymentMethods.find((({paymentMethodCode:e})=>e===this.options.paymentMethod.paymentMethodCode)))||void 0===i?void 0:i.integrationType;if(!e)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED);const t=(yield this.paymentExecutor.pay([{paymentMethodCode:this.options.paymentMethod.paymentMethodCode,integrationType:e,amount:this.sdkConfig.amount}])).response.links.redirect;if(!t)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK);return new Promise(((e,i)=>{window.location.href=t,setTimeout((()=>i(new Error("Timed out doing a redirect to the auth response link"))),3e3)}))}catch(e){e instanceof s.PayrailsError&&r.PayrailsLogger.error(e.message,{error:e}),null===(o=null===(n=this.options.events)||void 0===n?void 0:n.onAuthorizeFailed)||void 0===o||o.call(n)}}))}}const vn=e=>e===exports.PAYMENT_METHOD_CODES.GENERIC_REDIRECT?{translations:{label:"Mercado Pago",button:{label:"Pay with Mercado Pago"}}}:{translations:{label:e,button:{label:`Pay with ${e}`}}};class mn extends nn{constructor(e,t,i,n){var o,s,r,a;super(`payrails-${i.paymentMethod.paymentMethodCode}-dropin-element`,(null===(o=null==i?void 0:i.translations)||void 0===o?void 0:o.label)||vn(i.paymentMethod.paymentMethodCode).translations.label,void 0,null==i?void 0:i.events,null===(s=null==i?void 0:i.styles)||void 0===s?void 0:s.element),this.sdkConfig=e,this.execution=t,this.returnInfo=n,this.component=new fn(this.sdkConfig,this.execution,{styles:(null===(r=null==i?void 0:i.styles)||void 0===r?void 0:r[i.paymentMethod.paymentMethodCode])||{},translations:(null===(a=null==i?void 0:i.translations)||void 0===a?void 0:a.button)||vn(i.paymentMethod.paymentMethodCode).translations.button,events:null==i?void 0:i.events,paymentMethod:i.paymentMethod},this.returnInfo)}}const Nn={apiVersion:2,apiVersionMinor:0};class Tn extends Hi{static getSDKClient(t=exports.PayrailsEnvironment.TEST,i){return e(this,void 0,void 0,(function*(){return yield Gi.load(ji.GooglePay),Tn.googleSDKClient||(Tn.googleSDKClient=new google.payments.api.PaymentsClient({environment:t,merchantInfo:i})),Tn.googleSDKClient}))}static isGooglePayAvailable(t,i=exports.PayrailsEnvironment.TEST,n){return e(this,void 0,void 0,(function*(){try{const e=yield Tn.getSDKClient(i,n),o=Object.assign(Object.assign({},Nn),{allowedPaymentMethods:t}),{result:s}=yield e.isReadyToPay(o);return s}catch(e){return!1}}))}constructor(e,t,i){super("div",Object.assign(Object.assign({},i),{id:"payrails-google-pay-button"})),this.sdkConfig=e,this.execution=t,this.options=i,this.googleButton=null,this.paymentExecutor=new L(e,t),Tn.isGooglePayAvailable(this.execution.googlePayConfig,this.options.environment,this.options.merchantInfo).then((e=>{var t,i,n;e&&(null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onGooglePayAvailable)||void 0===n||n.call(i))}))}sdkLoaded(t){var i,n,o,s,r,a,l,d;return e(this,void 0,void 0,(function*(){const c=(null===(n=null===(i=this.options)||void 0===i?void 0:i.styles)||void 0===n?void 0:n.buttonColor)||"black",u=(null===(s=null===(o=this.options)||void 0===o?void 0:o.styles)||void 0===s?void 0:s.buttonType)||"long",E=(null===(a=null===(r=this.options)||void 0===r?void 0:r.styles)||void 0===a?void 0:a.buttonSizeMode)||"fill",_=(null===(d=null===(l=this.options)||void 0===l?void 0:l.styles)||void 0===d?void 0:d.buttonLocale)||void 0;return this.googleButton=t.createButton({buttonColor:c,buttonType:u,buttonSizeMode:E,buttonLocale:_,onClick:()=>e(this,void 0,void 0,(function*(){(yield O(this.options.events))&&(yield this.authorize(t))})),allowedPaymentMethods:this.execution.googlePayConfig}),this.element.appendChild(this.googleButton),this.googleButton}))}onLoadPaymentData(t){var i,n,o,s,r,a,l,d;return e(this,void 0,void 0,(function*(){const e=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.GOOGLE_PAY,integrationType:"api",paymentInstrumentData:{paymentToken:JSON.stringify(t)},amount:this.sdkConfig.amount,storeInstrument:this.shouldStoreInstrument}],c=yield this.paymentExecutor.pay(e);if("authorizePending"===(null===(i=null==c?void 0:c.finalState)||void 0===i?void 0:i.code)){new M(this.options,this.execution,this.paymentExecutor).handle3ds(c)}else"authorizeSuccessful"===(null===(n=null==c?void 0:c.finalState)||void 0===n?void 0:n.code)?null===(r=null===(s=null===(o=this.options)||void 0===o?void 0:o.events)||void 0===s?void 0:s.onAuthorizeSuccess)||void 0===r||r.call(s):null===(d=null===(l=null===(a=this.options)||void 0===a?void 0:a.events)||void 0===l?void 0:l.onAuthorizeFailed)||void 0===d||d.call(l,c)}))}authorize(t){var i,n,o,s,r,a,l,d;return e(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},Nn),{allowedPaymentMethods:this.execution.googlePayConfig,transactionInfo:{totalPriceStatus:"FINAL",totalPrice:null===(i=this.sdkConfig.amount)||void 0===i?void 0:i.value,currencyCode:null===(n=this.sdkConfig.amount)||void 0===n?void 0:n.currency,countryCode:null===(a=null===(r=null===(s=null===(o=this.execution.meta)||void 0===o?void 0:o.order)||void 0===s?void 0:s.billingAddress)||void 0===r?void 0:r.country)||void 0===a?void 0:a.code},merchantInfo:{merchantId:(null===(l=this.options.merchantInfo)||void 0===l?void 0:l.merchantId)||"",merchantName:(null===(d=this.options.merchantInfo)||void 0===d?void 0:d.merchantName)||""}});t.loadPaymentData(e).then((e=>{this.onLoadPaymentData(e)})).catch((e=>{var t,i,n;(null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onAuthorizeFailed)&&(null===(n=this.options)||void 0===n||n.events.onAuthorizeFailed(e))}))}))}mount(t){super.mount(t),(()=>{e(this,void 0,void 0,(function*(){var e;try{if(yield Tn.isGooglePayAvailable(this.execution.googlePayConfig,this.options.environment,this.options.merchantInfo)){const t=yield Tn.getSDKClient(this.options.environment,this.options.merchantInfo),i=yield this.sdkLoaded(t);this.element.appendChild(i),null===(e=this.storeInstrumentCheckbox)||void 0===e||e.mount(this.selector)}}catch(e){}}))})()}unmount(){var e,t,i;null===(t=null===(e=this.googleButton)||void 0===e?void 0:e.parentElement)||void 0===t||t.removeChild(this.googleButton),null===(i=this.storeInstrumentCheckbox)||void 0===i||i.unmount(),super.unmount()}}Tn.googleSDKClient=null;class yn extends un{constructor(e,t,i){var n,o;super("google-pay-dropin",(null===(o=null===(n=i.translations)||void 0===n?void 0:n.labels)||void 0===o?void 0:o.label)||"Google Pay",void 0,i.events,i.styles),this.loadElementId="google-pay-dropin-load-element",this.component=new Tn(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},i.events),{onGooglePayAvailable:()=>{this.mountAfterAvailable()}})}))}}class On extends Hi{constructor(t,i,n){super("div",Object.assign(Object.assign({},n),{id:"payrails-paypal-button",events:Object.assign(Object.assign({},null==n?void 0:n.events),{onSaveInstrumentCheckboxChanged:t=>e(this,void 0,void 0,(function*(){var e,i,n,o;null===(n=null===(i=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===i?void 0:i.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(i,t),null===(o=this.button)||void 0===o||o.close();const s=yield this.loadPaypal();s&&(this.button=s,yield this.button.render(`#${this.buttonWrapperId}`))}))})})),this.sdkConfig=t,this.execution=i,this.options=n,this.buttonWrapperId="payrails-paypal-button-wrapper",this.checkboxWrapperId="payrails-paypal-checkbox-wrapper",this.createOneTimeOrder=()=>e(this,void 0,void 0,(function*(){var e,t,i,n,o,s,r;const a=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.PAYPAL,integrationType:"api",amount:this.sdkConfig.amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!1}],l=yield this.paymentExecutor.pay(a),d=null===(i=null===(t=null===(e=l.response.links.confirm)||void 0===e?void 0:e.action)||void 0===t?void 0:t.parameters)||void 0===i?void 0:i.orderId;if(!d)throw null===(s=null===(o=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===o?void 0:o.onAuthorizeFailed)||void 0===s||s.call(o),new An("No order id returned");return this.confirmLink=null===(r=l.response.links.confirm)||void 0===r?void 0:r.href,d})),this.loadPaypal().catch((()=>{})),this.element.innerHTML=`<div id="${this.buttonWrapperId}"></div><div id="${this.checkboxWrapperId}"></div>`,this.paymentExecutor=new L(t,i),this.fraudNetGuid=null==n?void 0:n.fraudNetGuid}loadPaypal(){return e(this,void 0,void 0,(function*(){const e=yield Gi.load(ji.PayPal,this.paypalScriptConfig);return yield this.createPaypalButton(e)}))}get paypalScriptConfig(){const e=this.shouldStoreInstrument?"tokenize":"Instant"===this.execution.paypalConfig.captureMode?"capture":"authorize";return{clientId:this.execution.paypalConfig.clientId,intent:e,currency:this.sdkConfig.amount.currency,vault:this.shouldStoreInstrument}}createPaypalButton(t){var i,n,o;return e(this,void 0,void 0,(function*(){if(!t.Buttons)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR);const e=t.Buttons(this.createPayPalButtonConfig());return null===(o=null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n?void 0:n.onPaypalAvailable)||void 0===o||o.call(n),e}))}createPayPalButtonConfig(){return this.shouldStoreInstrument?this.createBillingAgreementConfig():this.createOneTimeOrderConfig()}createBillingAgreementConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{onApprove:this.approvePayment.bind(this),createBillingAgreement:()=>e(this,void 0,void 0,(function*(){var e,t,i,n;const o=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.PAYPAL,integrationType:"api",amount:this.sdkConfig.amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!0}],s=yield this.paymentExecutor.pay(o);return this.confirmLink=null===(e=s.response.links.confirm)||void 0===e?void 0:e.href,(null===(n=null===(i=null===(t=s.response.links.confirm)||void 0===t?void 0:t.action)||void 0===i?void 0:i.parameters)||void 0===n?void 0:n.tokenId)||""}))})}createOneTimeOrderConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{createOrder:this.createOneTimeOrder.bind(this),onApprove:this.approvePayment.bind(this)})}createBaseConfig(){var t,i,n,o,s,r,a,l,d,c;return{fundingSource:"paypal",style:{color:(null===(i=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===i?void 0:i.color)||"gold",height:(null===(o=null===(n=this.options)||void 0===n?void 0:n.styles)||void 0===o?void 0:o.height)||40,label:(null===(r=null===(s=this.options)||void 0===s?void 0:s.styles)||void 0===r?void 0:r.label)||"paypal",shape:(null===(l=null===(a=this.options)||void 0===a?void 0:a.styles)||void 0===l?void 0:l.shape)||"rect",tagline:(null===(c=null===(d=this.options)||void 0===d?void 0:d.styles)||void 0===c?void 0:c.tagline)||!1},onError:e=>{var t,i;(null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onAuthorizeFailed)&&this.options.events.onAuthorizeFailed(e)},onClick:(t,i)=>e(this,void 0,void 0,(function*(){var e;return(yield O(null===(e=this.options)||void 0===e?void 0:e.events))?i.resolve():i.reject()}))}}approvePayment(t){var i,n,o,s,r,a,l,d,c,u;return e(this,void 0,void 0,(function*(){if(!this.confirmLink)throw null===(o=null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n?void 0:n.onAuthorizeFailed)||void 0===o||o.call(n),new An("No confirm link");const e={};this.shouldStoreInstrument&&t.billingToken&&(e.tokenId=t.billingToken),this.fraudNetGuid&&(e.riskSessionCorrelationId=this.fraudNetGuid);const E=yield this.paymentExecutor.confirm(this.confirmLink,e);"authorizeSuccessful"===(null===(s=E.finalState)||void 0===s?void 0:s.code)?null===(l=null===(a=null===(r=this.options)||void 0===r?void 0:r.events)||void 0===a?void 0:a.onAuthorizeSuccess)||void 0===l||l.call(a):null===(u=null===(c=null===(d=this.options)||void 0===d?void 0:d.events)||void 0===c?void 0:c.onAuthorizeFailed)||void 0===u||u.call(c)}))}mount(t){super.mount(t),(()=>{e(this,void 0,void 0,(function*(){var e;const t=yield this.loadPaypal();t&&(this.button=t);try{null===(e=this.storeInstrumentCheckbox)||void 0===e||e.mount(`#${this.checkboxWrapperId}`),yield null==t?void 0:t.render(`#${this.buttonWrapperId}`)}catch(e){const t=new Ln(e.message,e);throw r.PayrailsLogger.error(t.message,{error:t}),t}}))})()}unmount(){var e;null===(e=this.button)||void 0===e||e.close(),super.unmount()}}class An extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION,{description:`PaypalOrderError: ${e}`,cause:t})}}class Ln extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT,{description:`PaypalButtonError: ${e}`,cause:t})}}class Rn extends un{constructor(e,t,i){var n,o;super("payrails-paypal-button-dropin",(null===(o=null===(n=null==i?void 0:i.translations)||void 0===n?void 0:n.labels)||void 0===o?void 0:o.label)||"PayPal",void 0,void 0,null==i?void 0:i.styles),this.loadElementId="paypal-dropin-load-element",this.component=new On(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},null==i?void 0:i.events),{onPaypalAvailable:()=>{this.mountAfterAvailable()}})}))}}class gn extends U{constructor(e,t,i,n,o){var s,r;super("fieldset",{id:"payrails-dropin-component"}),this.collectContainer=e,this.clientConfig=t,this.dropinConfig=i,this.execution=n,this.sdkConfig=o,this.applyStyles();void 0!==(null===(r=null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s.cards)||void 0===r?void 0:r.showExistingCards)&&console.warn("The `showExistingCards` option is deprecated and will be removed in a future version. Please use `showStoredInstruments` instead.");const a=new Map;this.execution.storedPaymentInstruments.forEach((e=>{if(this.isStoredInstrumentEnabled(e.paymentMethod)){this.cardPaymentButton=this.createCardPaymentButton();const t=this.createStoredInstrumentElement(e);a.set(t.identifier,t)}}));const l={[exports.PAYMENT_METHOD_CODES.CARD]:this.createCreditCardButton.bind(this),[exports.PAYMENT_METHOD_CODES.PAYPAL]:this.createPayPalButton.bind(this),[exports.PAYMENT_METHOD_CODES.GOOGLE_PAY]:this.createGooglePayButton.bind(this),[exports.PAYMENT_METHOD_CODES.APPLE_PAY]:this.createApplePayButton.bind(this)};this.execution.availablePaymentMethods.forEach((e=>{const t=e.paymentMethodCode;if(t&&l[t]){l[t];const e=l[t]();a.set(e.identifier,e)}else if(this.isHppIntegration(e)&&t){const t=this.createHppIntegrationElement(e);a.set(t.identifier,t)}})),this.element.addEventListener("change",(e=>{var t,i;const n=(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.value)||"";a.forEach((e=>{e.deactivate()})),null===(i=a.get(n))||void 0===i||i.activate()})),1===this.totalPaymentOptions&&this.element.classList.add("payrails-dropin-component--single"),this.subElements.push(...Array.from(a.values()))}isHppIntegration(e){var t;return e.paymentMethodCode===exports.PAYMENT_METHOD_CODES.GENERIC_REDIRECT||(null===(t=e.clientConfig)||void 0===t?void 0:t.flow)===D.REDIRECT}createStoredInstrumentElement(e){var t;return this.cardPaymentButton=this.createCardPaymentButton(),new rn(e,this.cardPaymentButton,(e=>{this.cardPaymentButton&&(this.cardPaymentButton.selectedInstrument=e)}),null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.element)}createHppIntegrationElement(e){var t,i,n,o,a,l;const d=e.paymentMethodCode;if(!d){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED,{description:`Payment method code is missing for payment method - ${JSON.stringify(e)}`});throw r.PayrailsLogger.error(t.message,{error:t}),t}return new mn(this.sdkConfig,this.execution,{paymentMethod:e,styles:{element:null===(i=null===(t=this.dropinConfig)||void 0===t?void 0:t.styles)||void 0===i?void 0:i.element,button:null===(a=null===(o=null===(n=this.dropinConfig)||void 0===n?void 0:n.styles)||void 0===o?void 0:o[d])||void 0===a?void 0:a.button},translations:null===(l=this.dropinConfig.translations)||void 0===l?void 0:l[d],events:this.getElementEvents()},this.clientConfig.returnInfo)}get totalPaymentOptions(){return this.execution.availablePaymentMethods.length+this.execution.storedPaymentInstruments.length}createCreditCardButton(){var e;return this.creditCard=new _n(this.createCardForm(),this.createCardPaymentButton(),null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.element,this.getElementEvents()),this.creditCard}createGooglePayButton(){var e,t,i;return this.googlePay=new yn(this.sdkConfig,this.execution,Object.assign({environment:this.clientConfig.environment||exports.PayrailsEnvironment.TEST,events:this.getElementEvents(),styles:Object.assign(Object.assign({},null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.googlePayButton),null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.element)},null===(i=this.dropinConfig.paymentMethodsConfiguration)||void 0===i?void 0:i.googlePay)),this.googlePay}createPayPalButton(){var e,t,i;return this.paypal=new Rn(this.sdkConfig,this.execution,Object.assign(Object.assign({},null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.payPal),{styles:Object.assign(Object.assign({},null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.paypalButton),null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.element),events:this.getElementEvents()})),this.paypal}createCardForm(){var e,t,i,n;if(!this.cardForm){const o=null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.cards,s=Boolean(null==o?void 0:o.showStoreInstrumentCheckbox),r=Boolean(null==o?void 0:o.showCardHolderName),a=Boolean(null==o?void 0:o.alwaysStoreInstrument);this.cardForm=new en(this.collectContainer,{showStoreInstrumentCheckbox:s,showCardHolderName:r,alwaysStoreInstrument:a,translations:null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.cardForm,styles:Object.assign(Object.assign({},null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.cardForm),null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.element),events:Object.assign(Object.assign({},this.getElementEvents()),{onFocus:()=>{var e;null===(e=this.creditCard)||void 0===e||e.activate()},onChange:({isValid:e})=>{var t;null===(t=this.cardPaymentButton)||void 0===t||t.setDisabled(!e)},onSaveInstrumentCheckboxChanged:e=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onSaveInstrumentCheckboxChanged)||void 0===i||i.call(t,e)}})})}return this.cardPaymentButton&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardForm}createApplePayButton(){var e,t,i;return this.applePay=new En(this.sdkConfig,this.execution,Object.assign(Object.assign({events:Object.assign(Object.assign({},this.getElementEvents()),{onAuthorizeSuccess:e=>{var t;if(e)if("authorizeSuccessful"===(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code))this.onAuthorizeSuccess();else this.onAuthorizeFailed()}})},null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.applePay),{styles:Object.assign(Object.assign({},null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.applePayButton),null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.element)})),this.applePay}createCardPaymentButton(){var e,t;return this.cardPaymentButton||(this.cardPaymentButton=new k(this.sdkConfig,this.execution,{styles:null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.cardPaymentButton,translations:null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.cardPaymentButton,events:this.getElementEvents()},this.clientConfig.returnInfo)),this.cardForm&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardPaymentButton}onAuthorizeSuccess(){var e,t,i,n,o,s;this.subElements.forEach((e=>e.unmount())),new cn({translations:{label:null===(i=null===(t=null===(e=this.dropinConfig)||void 0===e?void 0:e.translations)||void 0===t?void 0:t.paymentResult)||void 0===i?void 0:i.success},styles:null===(o=null===(n=this.dropinConfig)||void 0===n?void 0:n.styles)||void 0===o?void 0:o.authSuccess}).mount(this.selector),(null===(s=this.dropinConfig.events)||void 0===s?void 0:s.onAuthorizeSuccess)&&this.dropinConfig.events.onAuthorizeSuccess()}getElementEvents(){return Object.assign(Object.assign({},this.dropinConfig.events),{onAuthorizeSuccess:this.onAuthorizeSuccess.bind(this),onAuthorizeFailed:this.onAuthorizeFailed.bind(this),onAvailable:()=>{var e;(1===this.totalPaymentOptions||(null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.preselectFirstPaymentOption))&&this.subElements[0].activate()}})}onAuthorizeFailed(e){var t,i,n,o,s;new dn({translations:{label:null===(i=null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.paymentResult)||void 0===i?void 0:i.fail},styles:null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.authFailed}).mount(this.selector),null===(s=null===(o=this.dropinConfig.events)||void 0===o?void 0:o.onAuthorizeFailed)||void 0===s||s.call(o,e)}isStoredInstrumentEnabled(e){var t,i,n,o,s,r;switch(e){case exports.PAYMENT_METHOD_CODES.CARD:return!1!==(null===(i=null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.cards)||void 0===i?void 0:i.showStoredInstruments)&&!1!==(null===(o=null===(n=this.dropinConfig.paymentMethodsConfiguration)||void 0===n?void 0:n.cards)||void 0===o?void 0:o.showExistingCards);case exports.PAYMENT_METHOD_CODES.PAYPAL:case exports.PAYMENT_METHOD_CODES.GOOGLE_PAY:case exports.PAYMENT_METHOD_CODES.APPLE_PAY:return!1!==(null===(r=null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s[e])||void 0===r?void 0:r.showStoredInstruments);default:return!1}}applyStyles(){var e;(null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.container)&&Object.assign(this.element.style,this.dropinConfig.styles.container)}}const Sn={visa:/^4\d*/,mastercard:/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720)\d*/,amex:/^3[47]\d*/,diners:/^(36|38|30[0-5])\d*/,discover:/^(6011|65|64[4-9]|622)\d*/,jcb:/^35\d*/,hipercard:/^606282\d*/,unionpay:/^62\d*/,maestro:/^(5018|5020|5038|5043|5[6-9]|6020|6304|6703|6759|676[1-3])\d*/};class Cn{constructor(e,t,i){this.sdkConfig=i,this.bin="",this.id="payrails-container-wrapper",this.containerType="COMPOSABLE",this.cardTableName=t.cardTableName||"cards",this.containerType=t.containerType||"COMPOSABLE",this.__container=e.container(this.containerType,t)}static init(e,t,i){return this.instance&&this.instance.__container.unmount(),this.instance=new Cn(e,t,i),this.instance}createCollectElement(e){const t={required:!!e.required,enableCardIcon:!1!==e.enableCardIcon},i=this.__container.create(Object.assign(Object.assign({table:this.cardTableName,labelStyles:{},errorTextStyles:{},column:this.elementToFieldMap.get(e.type)},e),{type:e.type===exports.ElementType.CARDHOLDER_NAME?"INPUT_FIELD":e.type}),e.format?Object.assign(Object.assign({},t),{format:e.format}):t);return this.attachCustomEventHandler(i)}mount(e){if("COLLECT"===this.containerType){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw r.PayrailsLogger.error(e.message),e}this.element=document.createElement("span"),this.element.setAttribute("id",this.id);const t=document.querySelector(e);if(!t){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING);throw r.PayrailsLogger.error(t.message,{error:t,extra:{elementSelector:e}}),t}t.appendChild(this.element),window.setTimeout((()=>{this.__container.mount(`#${this.id}`)}),50)}unmount(){this.element&&this.element.remove()}collect(){return e(this,void 0,void 0,(function*(){try{return this.sdkConfig.usePayrailsFrames?yield this.collectPayrailsData():yield this.collectSkyflowData()}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CARD_FORM_ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE,{description:"Error collecting data from the iframe!"});throw r.PayrailsLogger.error(t.message,{error:t}),t}}))}collectSkyflowData(){return e(this,void 0,void 0,(function*(){const e=(yield this.__container.collect()).records,{skyflow_id:t,card_number:i,cardholder_name:n,expiry_month:o,expiry_year:s,security_code:r}=e[0].fields;return{instrumentId:t,card_number:i,cardholder_name:n,expiry_month:o,expiry_year:s,security_code:r}}))}collectPayrailsData(){return e(this,void 0,void 0,(function*(){const e=yield this.__container.collect();return Object.assign(Object.assign({},e),{vaultProviderConfigId:this.sdkConfig.vaultConfiguration.providerConfigId})}))}tokenize(t){return e(this,void 0,void 0,(function*(){const e=yield this.collect(),i=this.sdkConfig.vaultConfiguration.links.saveInstrument.href,n=this.sdkConfig.token;if(!i){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND,{description:"Save instrument URL not available!"});throw r.PayrailsLogger.error(e.message,{error:e}),e}const o=yield(({url:e,token:t,body:i})=>I({url:e,token:t,method:h.POST,body:i}))({url:i,token:n,body:this.constructSaveInstrumentBody(e,t)});return o.res}))}constructSaveInstrumentBody(e,t){var i,n;const o={holderReference:this.sdkConfig.holderReference,paymentMethod:"card",storeInstrument:null!==(i=null==t?void 0:t.storeInstrument)&&void 0!==i&&i,futureUsage:null!==(n=null==t?void 0:t.futureUsage)&&void 0!==n?n:"CardOnFile"};return this.sdkConfig.usePayrailsFrames?o.data={encryptedData:e.encryptedData,vaultProviderConfigId:e.vaultProviderConfigId}:o.token={providerId:this.sdkConfig.vaultConfiguration.providerId,providerConfigId:this.sdkConfig.vaultConfiguration.providerConfigId,reference:e.instrumentId,type:"card",meta:{skyflow_id:e.instrumentId,card_number:e.card_number,cardholder_name:e.cardholder_name,expiry_month:e.expiry_month,expiry_year:e.expiry_year,security_code:e.security_code}},o}attachCustomEventHandler(e){return new Proxy(e,{get:(e,t)=>{if("on"!==t)return e[t];return((i,n)=>{e[t].call(e,i,(e=>{"CHANGE"===i?(e.elementType===exports.ElementType.CARD_NUMBER&&(e.network=function(e){for(const[t,i]of Object.entries(Sn))if(i.test(e))return t;return""}(e.value),e.bin=this.formatBin(e.value),this.bin=this.formatBin(e.value)),n(e)):n(e)}))}).bind(e)}})}formatBin(e){return e.replace(/-|X/g,"").slice(0,6)}get elementToFieldMap(){return new Map([[exports.ElementType.CARD_NUMBER,"card_number"],[exports.ElementType.CARDHOLDER_NAME,"cardholder_name"],[exports.ElementType.CVV,"security_code"],[exports.ElementType.EXPIRATION_MONTH,"expiry_month"],[exports.ElementType.EXPIRATION_YEAR,"expiry_year"]])}}class Dn{constructor(e,t,i){this.pageId=e,this.execution=t,this.environment=i,this.guid=_().replace(/-/g,""),this.fnclsVal="fnparams-dede7cc5-15fd-4c75-a9f4-36c430ee3a99",this.configId=_(),this.scriptId=_()}mount(){this.loadFraudnet(this.pageId)}unmount(){var e,t;null===(e=document.getElementById(this.configId))||void 0===e||e.remove(),null===(t=document.getElementById(this.scriptId))||void 0===t||t.remove()}loadFraudnet(e){this.unmount();const t=this.createFraudnetConfig(e);document.body.appendChild(t);const i=document.createElement("script");i.setAttribute("id",this.scriptId),i.src="https://c.paypal.com/da/r/fb.js",document.body.appendChild(i)}get payPalConfig(){return this.execution.paypalConfig}createFraudnetConfig(e){const t=document.createElement("script");return t.setAttribute("type","application/json"),t.setAttribute("fncls",this.fnclsVal),t.setAttribute("id",this.configId),t.innerText=JSON.stringify({f:this.guid,s:`${this.payPalConfig.merchantId}_${e}`,sandbox:"TEST"===this.environment}),t}}const Pn=()=>{const e=document.getElementById("sdk-observer");return e||(()=>{const e=document.createElement("iframe");return e.id="sdk-observer",e.src="https://assets.payrails.io/8f2cbee/observability/index.html",e.width="1px",e.height="1px",document.body.appendChild(e),e})()};
22
22
  /* @copyright
23
23
  Copyright (c) 2023 Payrails (https://www.payrails.com/)
24
24
  */
25
- class Dn{static init(e,t){var i,n,s,a,l,d,c,u;try{Cn(),r.PayrailsLogger.init({enabled:(null===(i=null==t?void 0:t.telemetry)||void 0===i?void 0:i.enabled)||!0,logLevel:(null===(n=null==t?void 0:t.telemetry)||void 0===n?void 0:n.logLevel)||"error",environment:(null==t?void 0:t.environment)||"TEST",sdk:{name:"web-sdk",version:"5.8.2"}});const o=JSON.parse(atob(e.data)),E=Boolean(o.vaultConfiguration.encryptionPublicKey);r.PayrailsLogger.setState({payrails:{execution_id:null===(s=o.execution)||void 0===s?void 0:s.id,holder_reference:o.holderReference,vault_provider:o.vaultConfiguration.vaultType,merchant_reference:null===(a=o.execution)||void 0===a?void 0:a.merchantReference,frames_type:E?"payrails":"skyflow",workflow:{code:(null===(d=null===(l=o.execution)||void 0===l?void 0:l.workflow)||void 0===d?void 0:d.code)||"",version:(null===(u=null===(c=o.execution)||void 0===c?void 0:c.workflow)||void 0===u?void 0:u.version)||0}}});const{vaultConfiguration:{vaultId:_,vaultUrl:h,token:I},execution:p}=o,f=Pi.init({vaultID:_,vaultURL:h,getBearerToken:()=>Promise.resolve(I),options:{initResponse:e,deserializedData:Object.assign(Object.assign({},o),{usePayrailsFrames:E})}});let v;return p&&(v=new P(p),v.isPaymentMethodAvailable(S.CARD)&&Vi.preloadCardForm()),new Dn(Object.assign(Object.assign({},o),{usePayrailsFrames:E}),f,v,t)}catch(e){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED,{cause:e});throw r.PayrailsLogger.error(t.message,{error:t}),t}}update(e){this.sdkConfiguration.amount=e}collectContainer(e){if("COMPOSABLE"===e.containerType&&!e.layout){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw r.PayrailsLogger.error(e.message,{error:e}),e}return this.__container=Rn.init(this.vaultClient,Object.assign(Object.assign({},e),{cardTableName:this.sdkConfiguration.vaultConfiguration.cardTableName}),this.sdkConfiguration),this.__container}googlePayButton(e){var t;return this.logIntegrationMode("elements"),new mn(this.sdkConfiguration,this.safeExecution,Object.assign({environment:null===(t=this.options)||void 0===t?void 0:t.environment},e))}isGooglePayAvailable(e){var t;return mn.isGooglePayAvailable(this.safeExecution.googlePayConfig,null===(t=this.options)||void 0===t?void 0:t.environment,e)}applePayButton(e){if(this.logIntegrationMode("elements"),!this.execution){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND);throw r.PayrailsLogger.error(e.message,{error:e}),e}return new Xi(this.sdkConfiguration,this.execution,e)}isApplePayAvailable(){return Xi.isApplePayAvailable()}cardList(e){return this.logIntegrationMode("elements"),this.__cardList||(this.__cardList=new on(this.safeExecution,{onCardChange:t=>{this.__cardPaymentButton&&(this.__cardPaymentButton.selectedInstrument=t,this.__cardPaymentButton.setDisabled(!1)),null==e||e.onCardChange(t)}})),this.__cardList}cardForm(e){var t,i;if(this.logIntegrationMode("elements"),!this.__cardForm){const n=this.getContainerLayout(null==e?void 0:e.showCardHolderName);this.__container=this.collectContainer(Object.assign(Object.assign({layout:n,errorTextStyles:{base:{display:"none"}}},null===(t=null==e?void 0:e.styles)||void 0===t?void 0:t.errorTextStyles),{styles:{base:null===(i=null==e?void 0:e.styles)||void 0===i?void 0:i.base}})),this.__cardForm=new Zi(this.__container,Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},null==e?void 0:e.events),{onChange:t=>{var i;this.__cardPaymentButton&&(this.__cardPaymentButton.selectedInstrument=null,this.__cardForm&&this.__cardPaymentButton.setDisabled(!this.__cardForm.isValid)),(null===(i=null==e?void 0:e.events)||void 0===i?void 0:i.onChange)&&e.events.onChange(t)},onFocus:()=>{var t;this.__cardList&&this.__cardList.reset(),this.__cardPaymentButton&&(this.__cardPaymentButton.selectedInstrument=null,this.__cardForm&&this.__cardPaymentButton.setDisabled(!this.__cardForm.isValid)),(null===(t=null==e?void 0:e.events)||void 0===t?void 0:t.onFocus)&&e.events.onFocus()}})}))}return this.__cardPaymentButton&&this.__cardPaymentButton.setCardForm(this.__cardForm),this.__cardForm}dropin(e){var t,i;this.logIntegrationMode("dropin");const n=this.getContainerLayout(null===(i=null===(t=e.paymentMethodsConfiguration)||void 0===t?void 0:t.cards)||void 0===i?void 0:i.showCardHolderName);return this.__container=this.collectContainer({layout:n,errorTextStyles:{base:{display:"none"}}}),this.__dropin=new Ln(this.__container,this.options||{},e,this.safeExecution,this.sdkConfiguration),this.__dropin}getSavedCreditCards(){return this.logIntegrationMode("elements"),this.safeExecution.savedCreditCards}getSavedGooglePayAccounts(){return this.logIntegrationMode("elements"),this.safeExecution.savedGooglePayAccounts}getSavedApplePayAccounts(){return this.logIntegrationMode("elements"),this.safeExecution.savedApplePayAccounts}getStoredInstruments(){return this.logIntegrationMode("elements"),this.safeExecution.storedPaymentInstruments}getAvailablePaymentMethods(){return this.logIntegrationMode("elements"),this.safeExecution.availablePaymentMethods.map((({paymentMethodCode:e})=>e)).filter((e=>!!e))}paymentButton(e){var t;return this.logIntegrationMode("elements"),this.__cardPaymentButton||(this.__cardPaymentButton=new w(this.sdkConfiguration,this.safeExecution,e,(null===(t=this.options)||void 0===t?void 0:t.returnInfo)||{})),this.__cardPaymentButton.setDisabled(!0),this.__cardForm&&this.__cardPaymentButton.setCardForm(this.__cardForm),this.__cardPaymentButton}paypalButton(e){var t;return this.logIntegrationMode("elements"),this.__paypalButton=new Tn(this.sdkConfiguration,this.safeExecution,Object.assign(Object.assign({},e),{fraudNetGuid:(null==e?void 0:e.fraudNetGuid)||(null===(t=this.__fraudNet)||void 0===t?void 0:t.guid)})),this.__paypalButton}genericRedirectButton(e){return this.logIntegrationMode("elements"),this.__genericRedirectButton=new In(this.sdkConfiguration,this.safeExecution,Object.assign({},e)),this.__genericRedirectButton}getSavedPaypalAccounts(){return this.logIntegrationMode("elements"),this.safeExecution.savedPaypalAccounts||[]}fraudNet(e){var t;return this.__fraudNet||(this.__fraudNet=new Sn(e,this.safeExecution,(null===(t=this.options)||void 0===t?void 0:t.environment)||exports.PayrailsEnvironment.TEST)),this.__paypalButton&&(this.__paypalButton.fraudNetGuid=this.__fraudNet.guid),this.__fraudNet}get safeExecution(){if(!this.execution){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND);throw r.PayrailsLogger.error(e.message,{error:e}),e}return this.execution}logIntegrationMode(e){r.PayrailsLogger.setState({sdk:{integration_mode:e}})}constructor(e,t,i,n){var s;this.sdkConfiguration=e,this.vaultClient=t,this.execution=i,this.options=n,(null===(s=null==n?void 0:n.events)||void 0===s?void 0:s.onClientInitialized)&&n.events.onClientInitialized(this.execution)}getContainerLayout(e){return e?[1,1,3]:[1,3]}}var bn;Dn.preloadCardForm=Vi.preloadCardForm,exports.PayrailsEnvironment=void 0,(bn=exports.PayrailsEnvironment||(exports.PayrailsEnvironment={})).TEST="TEST",bn.PRODUCTION="PRODUCTION",exports.Payrails=Dn}();
25
+ class bn{static init(e,t){var i,n,o,a,l,d,c,u;try{Pn(),r.PayrailsLogger.init({enabled:(null===(i=null==t?void 0:t.telemetry)||void 0===i?void 0:i.enabled)||!0,logLevel:(null===(n=null==t?void 0:t.telemetry)||void 0===n?void 0:n.logLevel)||"error",environment:(null==t?void 0:t.environment)||"TEST",sdk:{name:"web-sdk",version:"5.8.3"}});const s=JSON.parse(atob(e.data)),E=Boolean(s.vaultConfiguration.encryptionPublicKey);r.PayrailsLogger.setState({payrails:{execution_id:null===(o=s.execution)||void 0===o?void 0:o.id,holder_reference:s.holderReference,vault_provider:s.vaultConfiguration.vaultType,merchant_reference:null===(a=s.execution)||void 0===a?void 0:a.merchantReference,frames_type:E?"payrails":"skyflow",workflow:{code:(null===(d=null===(l=s.execution)||void 0===l?void 0:l.workflow)||void 0===d?void 0:d.code)||"",version:(null===(u=null===(c=s.execution)||void 0===c?void 0:c.workflow)||void 0===u?void 0:u.version)||0}}});const{vaultConfiguration:{vaultId:_,vaultUrl:h,token:I},execution:p}=s,f=wi.init({vaultID:_,vaultURL:h,getBearerToken:()=>Promise.resolve(I),options:{initResponse:e,deserializedData:Object.assign(Object.assign({},s),{usePayrailsFrames:E})}});let v;return p&&(v=new w(p),v.isPaymentMethodAvailable(exports.PAYMENT_METHOD_CODES.CARD)&&Gi.preloadCardForm()),new bn(Object.assign(Object.assign({},s),{usePayrailsFrames:E}),f,v,t)}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED,{cause:e});throw r.PayrailsLogger.error(t.message,{error:t}),t}}update(e){this.sdkConfiguration.amount=e}collectContainer(e){if("COMPOSABLE"===e.containerType&&!e.layout){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw r.PayrailsLogger.error(e.message,{error:e}),e}return this.__container=Cn.init(this.vaultClient,Object.assign(Object.assign({},e),{cardTableName:this.sdkConfiguration.vaultConfiguration.cardTableName}),this.sdkConfiguration),this.__container}googlePayButton(e){var t;return this.logIntegrationMode("elements"),new Tn(this.sdkConfiguration,this.safeExecution,Object.assign({environment:null===(t=this.options)||void 0===t?void 0:t.environment},e))}isGooglePayAvailable(e){var t;return Tn.isGooglePayAvailable(this.safeExecution.googlePayConfig,null===(t=this.options)||void 0===t?void 0:t.environment,e)}applePayButton(e){if(this.logIntegrationMode("elements"),!this.execution){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND);throw r.PayrailsLogger.error(e.message,{error:e}),e}return new Wi(this.sdkConfiguration,this.execution,e)}isApplePayAvailable(){return Wi.isApplePayAvailable()}cardList(e){return this.logIntegrationMode("elements"),this.__cardList||(this.__cardList=new an(this.safeExecution,{onCardChange:t=>{this.__cardPaymentButton&&(this.__cardPaymentButton.selectedInstrument=t,this.__cardPaymentButton.setDisabled(!1)),null==e||e.onCardChange(t)}})),this.__cardList}cardForm(e){var t,i;if(this.logIntegrationMode("elements"),!this.__cardForm){const n=this.getContainerLayout(null==e?void 0:e.showCardHolderName);this.__container=this.collectContainer(Object.assign(Object.assign({layout:n,errorTextStyles:{base:{display:"none"}}},null===(t=null==e?void 0:e.styles)||void 0===t?void 0:t.errorTextStyles),{styles:{base:null===(i=null==e?void 0:e.styles)||void 0===i?void 0:i.base}})),this.__cardForm=new en(this.__container,Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},null==e?void 0:e.events),{onChange:t=>{var i;this.__cardPaymentButton&&(this.__cardPaymentButton.selectedInstrument=null,this.__cardForm&&this.__cardPaymentButton.setDisabled(!this.__cardForm.isValid)),(null===(i=null==e?void 0:e.events)||void 0===i?void 0:i.onChange)&&e.events.onChange(t)},onFocus:()=>{var t;this.__cardList&&this.__cardList.reset(),this.__cardPaymentButton&&(this.__cardPaymentButton.selectedInstrument=null,this.__cardForm&&this.__cardPaymentButton.setDisabled(!this.__cardForm.isValid)),(null===(t=null==e?void 0:e.events)||void 0===t?void 0:t.onFocus)&&e.events.onFocus()}})}))}return this.__cardPaymentButton&&this.__cardPaymentButton.setCardForm(this.__cardForm),this.__cardForm}dropin(e){var t,i;this.logIntegrationMode("dropin");const n=this.getContainerLayout(null===(i=null===(t=e.paymentMethodsConfiguration)||void 0===t?void 0:t.cards)||void 0===i?void 0:i.showCardHolderName);return this.__container=this.collectContainer({layout:n,errorTextStyles:{base:{display:"none"}}}),this.__dropin=new gn(this.__container,this.options||{},e,this.safeExecution,this.sdkConfiguration),this.__dropin}getSavedCreditCards(){return this.logIntegrationMode("elements"),this.safeExecution.savedCreditCards}getSavedGooglePayAccounts(){return this.logIntegrationMode("elements"),this.safeExecution.savedGooglePayAccounts}getSavedApplePayAccounts(){return this.logIntegrationMode("elements"),this.safeExecution.savedApplePayAccounts}getStoredInstruments(){return this.logIntegrationMode("elements"),this.safeExecution.storedPaymentInstruments}getAvailablePaymentMethods(){return this.logIntegrationMode("elements"),this.safeExecution.availablePaymentMethods.map((({paymentMethodCode:e})=>e)).filter((e=>!!e))}paymentButton(e){var t;return this.logIntegrationMode("elements"),this.__cardPaymentButton||(this.__cardPaymentButton=new k(this.sdkConfiguration,this.safeExecution,e,(null===(t=this.options)||void 0===t?void 0:t.returnInfo)||{})),this.__cardPaymentButton.setDisabled(!0),this.__cardForm&&this.__cardPaymentButton.setCardForm(this.__cardForm),this.__cardPaymentButton}paypalButton(e){var t;return this.logIntegrationMode("elements"),this.__paypalButton=new On(this.sdkConfiguration,this.safeExecution,Object.assign(Object.assign({},e),{fraudNetGuid:(null==e?void 0:e.fraudNetGuid)||(null===(t=this.__fraudNet)||void 0===t?void 0:t.guid)})),this.__paypalButton}genericRedirectButton(e){return this.logIntegrationMode("elements"),this.__genericRedirectButton=new fn(this.sdkConfiguration,this.safeExecution,e),this.__genericRedirectButton}getSavedPaypalAccounts(){return this.logIntegrationMode("elements"),this.safeExecution.savedPaypalAccounts||[]}fraudNet(e){var t;return this.__fraudNet||(this.__fraudNet=new Dn(e,this.safeExecution,(null===(t=this.options)||void 0===t?void 0:t.environment)||exports.PayrailsEnvironment.TEST)),this.__paypalButton&&(this.__paypalButton.fraudNetGuid=this.__fraudNet.guid),this.__fraudNet}get safeExecution(){if(!this.execution){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND);throw r.PayrailsLogger.error(e.message,{error:e}),e}return this.execution}logIntegrationMode(e){r.PayrailsLogger.setState({sdk:{integration_mode:e}})}constructor(e,t,i,n){var o;this.sdkConfiguration=e,this.vaultClient=t,this.execution=i,this.options=n,(null===(o=null==n?void 0:n.events)||void 0===o?void 0:o.onClientInitialized)&&n.events.onClientInitialized(this.execution)}getContainerLayout(e){return e?[1,1,3]:[1,3]}}var Mn;bn.preloadCardForm=Gi.preloadCardForm,exports.PayrailsEnvironment=void 0,(Mn=exports.PayrailsEnvironment||(exports.PayrailsEnvironment={})).TEST="TEST",Mn.PRODUCTION="PRODUCTION",exports.Payrails=bn}();