@payrails/web-sdk 4.0.0 → 4.1.0-RC.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(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))(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"}};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",E=null!=r?r:d;super(c),this.name=e,this.docUrl=E,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={};let a;!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 E(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var _={},u={},I={};Object.defineProperty(I,"__esModule",{value:!0}),I.isntString=void 0,I.isntString=function(e){return"string"!=typeof e};var h={},p={};Object.defineProperty(p,"__esModule",{value:!0}),p.subscribers=p.childWindows=p.prefix=void 0,p.prefix="/*framebus*/",p.childWindows=[],p.subscribers={};var f={},N={},T={},m={};Object.defineProperty(m,"__esModule",{value:!0}),m.subscriptionArgsInvalid=void 0;var O=I;m.subscriptionArgsInvalid=function(e,t,i){return!!O.isntString(e)||("function"!=typeof t||O.isntString(i))};var v={},A={};Object.defineProperty(A,"__esModule",{value:!0}),A.hasOpener=void 0,A.hasOpener=function(e){return e.top===e&&(null!=e.opener&&(e.opener!==e&&!0!==e.opener.closed))},Object.defineProperty(v,"__esModule",{value:!0}),v.broadcast=void 0;var y,L=A;function R(){if(y)return T;y=1,Object.defineProperty(T,"__esModule",{value:!0}),T.Framebus=void 0;var e=I,t=m,i=v,n=C(),o=p,s=function(){function s(e){void 0===e&&(e="*"),this.origin=e}return s.target=function(e){return void 0===e&&(e="*"),new s(e)},s.prototype.include=function(e){return null!=e&&(null!=e.Window&&(e.constructor===e.Window&&(o.childWindows.push(e),!0)))},s.prototype.target=function(e){return s.target(e)},s.prototype.emit=function(t,o,s){var r=this.origin;if(e.isntString(t))return!1;if(e.isntString(r))return!1;"function"==typeof o&&(s=o,o=void 0);var a=n.packagePayload(t,r,o,s);return!!a&&(i.broadcast(window.top||window.self,a,r),!0)},s.prototype.on=function(e,i){var n=this.origin;return!t.subscriptionArgsInvalid(e,i,n)&&(o.subscribers[n]=o.subscribers[n]||{},o.subscribers[n][e]=o.subscribers[n][e]||[],o.subscribers[n][e].push(i),!0)},s.prototype.off=function(e,i){var n=this.origin;if(t.subscriptionArgsInvalid(e,i,n))return!1;var s=o.subscribers[n]&&o.subscribers[n][e];if(!s)return!1;for(var r=0;r<s.length;r++)if(s[r]===i)return s.splice(r,1),!0;return!1},s}();return T.Framebus=s,T}v.broadcast=function e(t,i,n){var o,s=0;try{for(t.postMessage(i,n),L.hasOpener(t)&&e(t.opener.top,i,n);o=t.frames[s];)e(o,i,n),s++}catch(e){}};var g,S,D=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)}))};function C(){if(S)return f;S=1,Object.defineProperty(f,"__esModule",{value:!0}),f.packagePayload=void 0;var e=function(){if(g)return N;g=1;var e=c&&c.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(N,"__esModule",{value:!0}),N.subscribeReplier=void 0;var t=R(),i=e(D);return N.subscribeReplier=function(e,n){var o=i.default();return t.Framebus.target(n).on(o,(function i(s,r){e(s,r),t.Framebus.target(n).off(o,i)})),o},N}(),t=p;return f.packagePayload=function(i,n,o,s){var r,a={event:i,origin:n};"function"==typeof s&&(a.reply=e.subscribeReplier(s,n)),a.eventData=o;try{r=t.prefix+JSON.stringify(a)}catch(e){throw new Error("Could not stringify event: "+e.message)}return r},f}Object.defineProperty(h,"__esModule",{value:!0}),h.unpackPayload=void 0;var P=p,b=C();h.unpackPayload=function(e){var t;if(e.data.slice(0,P.prefix.length)!==P.prefix)return!1;try{t=JSON.parse(e.data.slice(P.prefix.length))}catch(e){return!1}if(t.reply){var i=e.origin,n=e.source,o=t.reply;t.reply=function(e){if(n){var t=b.packagePayload(o,i,e);t&&n.postMessage(t,i)}}}return t};var M={};Object.defineProperty(M,"__esModule",{value:!0}),M.dispatch=void 0;var w=p;M.dispatch=function(e,t,i,n,o){if(w.subscribers[e]&&w.subscribers[e][t]){var s=[];i&&s.push(i),n&&s.push(n);for(var r=0;r<w.subscribers[e][t].length;r++)w.subscribers[e][t][r].apply(o,s)}};var U={};Object.defineProperty(U,"__esModule",{value:!0}),U.broadcastToChildWindows=void 0;var k=v,Y=p;U.broadcastToChildWindows=function(e,t,i){for(var n=Y.childWindows.length-1;n>=0;n--){var o=Y.childWindows[n];o.closed?Y.childWindows.splice(n,1):i!==o&&k.broadcast(o.top,e,t)}},Object.defineProperty(u,"__esModule",{value:!0}),u.onmessage=void 0;var x=I,V=h,F=M,G=U;u.onmessage=function(e){if(!x.isntString(e.data)){var t=V.unpackPayload(e);if(t){var i=t.eventData,n=t.reply;F.dispatch("*",t.event,i,n,e),F.dispatch(e.origin,t.event,i,n,e),G.broadcastToChildWindows(e.data,t.origin,e.source)}}},Object.defineProperty(_,"__esModule",{value:!0}),_.detach=_.attach=void 0;var B=u,j=!1;_.attach=function(){j||"undefined"==typeof window||(j=!0,window.addEventListener("message",B.onmessage,!1))},_.detach=function(){j=!1,window.removeEventListener("message",B.onmessage,!1)};var X=_,W=new(R().Framebus);X.attach();const $=E(W);class z{constructor(){this.listeners=[],this.isDestroyed=!1}on(e,t){$.on(e,t),this.listeners.push({eventName:e,callback:t})}off(e,t){$.off(e,t);const i=this.listeners.findIndex((t=>t.eventName===e));-1!==i&&this.listeners.splice(i,1)}emit(e,t,i=void 0){$.emit(e,t,i)}hasListener(e){return-1!==this.listeners.findIndex((t=>t.eventName===e))}teardown(){this.listeners.forEach((e=>{$.off(e.eventName,e.handler)})),this.listeners=[]}}class K{constructor(){this.bus=new z}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===q}(e)}(e)};var q="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function J(e,t){return!1!==t.clone&&t.isMergeableObject(e)?ie((i=e,Array.isArray(i)?[]:{}),e,t):e;var i}function Z(e,t,i){return e.concat(t).map((function(e){return J(e,i)}))}function Q(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 ee(e,t){try{return t in e}catch(e){return!1}}function te(e,t,i){var n={};return i.isMergeableObject(e)&&Q(e).forEach((function(t){n[t]=J(e[t],i)})),Q(t).forEach((function(o){(function(e,t){return ee(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,o)||(ee(e,o)&&i.isMergeableObject(t[o])?n[o]=function(e,t){if(!t.customMerge)return ie;var i=t.customMerge(e);return"function"==typeof i?i:ie}(o,i)(e[o],t[o],i):n[o]=J(t[o],i))})),n}function ie(e,t,i){(i=i||{}).arrayMerge=i.arrayMerge||Z,i.isMergeableObject=i.isMergeableObject||H,i.cloneUnlessOtherwiseSpecified=J;var n=Array.isArray(t);return n===Array.isArray(e)?n?i.arrayMerge(e,t,i):te(e,t,i):J(t,i)}ie.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,i){return ie(e,i,t)}),{})};const ne=E(ie);class oe{constructor(){this.state={}}static getInstance(){return oe.instance||(oe.instance=new oe),oe.instance}getState(e){return this.state[e]}setState(e){this.state=ne(this.state,e)}}const se=oe.getInstance(),re=()=>window&&window.navigator,ae=()=>window&&window.screen,le=()=>({resolution:`${ae().width}x${ae().height}`,user_agent:re().userAgent,language:re().language});class de{constructor(e){this.adapter=[new K],this.enabled=e.enabled||!0,this.initGlobalState(e),e.logLevel=e.logLevel||"error","debug"===e.logLevel&&this.addAdapter(new l)}static init(e){de.instance=new de(e)}static getLogger(){return de.instance}initGlobalState(e){se.setState({payrails:e.payrails,sdk:e.sdk})}static setState(e){se.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:le(),payrails:se.getState("payrails"),sdk:se.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=de,e.getDeviceInfo=le}(r);const l=new Uint8Array(16);function d(){if(!a&&(a="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!a))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return a(l)}const c=[];for(let e=0;e<256;++e)c.push((e+256).toString(16).slice(1));var E={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function _(e,t,i){if(E.randomUUID&&!t&&!e)return E.randomUUID();const n=(e=e||{}).random||(e.rng||d)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){i=i||0;for(let e=0;e<16;++e)t[i+e]=n[e];return t}return function(e,t=0){return c[e[t+0]]+c[e[t+1]]+c[e[t+2]]+c[e[t+3]]+"-"+c[e[t+4]]+c[e[t+5]]+"-"+c[e[t+6]]+c[e[t+7]]+"-"+c[e[t+8]]+c[e[t+9]]+"-"+c[e[t+10]]+c[e[t+11]]+c[e[t+12]]+c[e[t+13]]+c[e[t+14]]+c[e[t+15]]}(n)}var u;!function(e){e.GET="GET",e.POST="POST"}(u||(u={}));const I=({url:t,method:i=u.GET,token:n,body:o})=>e(void 0,void 0,void 0,(function*(){const e={method:i,headers:Object.assign(Object.assign(Object.assign({},m()),T(n)),O())};i===u.POST&&(e.body=JSON.stringify(o||{}));const s=yield fetch(t,e),r=yield s.json();if([401,403].includes(s.status))throw new h(t,i);if(429===s.status)throw new f(t,i);if(!s.ok)throw new p(t,i);return{ok:s.ok,req:Object.assign({url:t},e),res:r}}));class h extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_UNAUTHORIZED,{description:`[${t}] ${e} unauthorized`})}}class p extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{description:`[${t}] ${e} unsuccessful`})}}class f extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} too many requests`})}}class N extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} max poll attempts exceeded.`})}}const T=e=>({authorization:`Bearer ${e}`}),m=()=>({"x-idempotency-key":_()}),O=()=>{const e={version:"4.0.0",type:"web-sdk"};return{"x-client-version":e.version,"x-client-type":e.type}},v={success:"https://payrails.io/success",error:"https://payrails.io/error",cancel:"https://payrails.io/cancel"};class A{constructor(e,t,i=v,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:u.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 N(t,u.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 p)return yield this.wait(this.POLL_INTERVAL),this.getExecution(t,i,n+this.POLL_ERROR_COUNT_MULTIPLIER);if(e instanceof f)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:u.POST,token:this.sdkConfig.token,body:{integrationType:"api",paymentMethodCode:"applePay",amount:this.sdkConfig.amount,meta:{sessionURL:t.sessionUrl,clientDomain: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:u.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 y{constructor(e,t,i){this.options=e,this.execution=t,this.paymentExecutor=i}handle3ds(t){var i,n,o,a;try{null===(n=null===(i=this.options.events)||void 0===i?void 0:i.onThreeDSecureChallenge)||void 0===n||n.call(i)}catch(e){}const l=null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.links["3ds"];if(l){const t=[[250,400],[390,400],[500,600],[600,400]],i=screen.width,n=t.reduce(((e,t)=>i>t[0]?t:e),[250,400]),o=document.createElement("iframe");o.setAttribute("id","payrails-3ds-frame"),o.setAttribute("src",l),o.setAttribute("width",n[0].toString()),o.setAttribute("height",n[1].toString());const d=document.createElement("div");d.setAttribute("id","payrails-3ds-challenge"),d.appendChild(o);const c=document.createElement("div");c.addEventListener("click",(()=>{c.remove()})),c.setAttribute("id","payrails-3ds-popup-background"),c.appendChild(d);const E=t=>e(this,void 0,void 0,(function*(){var e,i,n,o;if(t.data&&'{"type":"3DS-challenge-completed"}'===t.data){window.removeEventListener("message",E),c.remove();if(!(yield this.paymentExecutor.getExecution(this.execution.url)).res.status.find((({code:e})=>"authorizeSuccessful"===e))&&(null===(e=this.options.events)||void 0===e?void 0:e.onAuthorizeFailed)){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_3DS_ERROR);return r.PayrailsLogger.error(e.message,{error:e}),void(null===(i=this.options.events)||void 0===i||i.onAuthorizeFailed({code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:"Authorization failed after 3DS challenge."}))}if(null===(n=this.options.events)||void 0===n?void 0:n.onAuthorizeSuccess)return void(null===(o=this.options.events)||void 0===o||o.onAuthorizeSuccess())}}));null===(a=document.querySelector("body"))||void 0===a||a.appendChild(c),window.addEventListener("message",E),d.style.width=`${n[0]+4}px`,d.style.height=`${n[1]+4}px`}}}var L,R,g;!function(e){e.CARD="card",e.GOOGLE_PAY="googlePay",e.PAYPAL="payPal",e.APPLE_PAY="applePay"}(L||(L={})),function(e){e.ENABLED="enabled",e.CREATED="created",e.DELETED="deleted",e.DISABLED="disabled",e.INVALID="invalid",e.TRANSIENT="transient"}(R||(R={}));class S{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(L.CARD)}get savedPaypalAccounts(){return this.getStoredInstrumentForPaymentMethod(L.PAYPAL)}get savedGooglePayAccounts(){return this.getStoredInstrumentForPaymentMethod(L.GOOGLE_PAY)}get savedApplePayAccounts(){return this.getStoredInstrumentForPaymentMethod(L.APPLE_PAY)}get paypalConfig(){const e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===L.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===L.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===L.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)||[]}}class D{constructor(e,{id:t="",className:i=""}={}){this.subElements=[];const n=document.createElement(e);t&&(this.id=t,n.setAttribute("id",t)),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`});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)}))}unmount(){var e;this.subElements.forEach((e=>e.unmount())),null===(e=this.parentElement)||void 0===e||e.removeChild(this.element)}}class C extends D{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.returnLinks=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 A(this.sdkConfig,this.execution,this.returnLinks)}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,E,_;return e(this,void 0,void 0,(function*(){if(this.setDisabled(!0),this.triggerLoading(!0),null===(t=this.options.events)||void 0===t?void 0:t.onPaymentButtonClicked)try{if(!1===(yield null===(i=this.options.events)||void 0===i?void 0:i.onPaymentButtonClicked({bin:this.bin||""}))){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_ONPAY_CALLBACK_FAILED,{description:"Callback passed to onPaymentButtonClicked resolved to false"});return r.PayrailsLogger.error(e.message,{error:e}),void this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:e.message})}}catch(e){const t=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(t.message,{error:t}),void this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:t.message})}try{let e=[{paymentMethodCode:L.CARD,integrationType:"api",amount:this.sdkConfig.amount,storeInstrument:!1}];if(null===(n=this.selectedInstrument)||void 0===n?void 0:n.id)e[0].paymentInstrumentId=null===(o=this.selectedInstrument)||void 0===o?void 0:o.id,e[0].paymentMethodCode=null===(a=this.selectedInstrument)||void 0===a?void 0:a.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 t=yield this.paymentExecutor.pay(e);this.handleAuthorizationResult(t)}catch(e){let t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_AUTHENTICATION_ERROR,{cause:e});e instanceof h||[401,403].includes(null===(l=null==e?void 0:e.error)||void 0===l?void 0:l.code)?(null===(c=null===(d=this.options.events)||void 0===d?void 0:d.onPaymentSessionExpired)||void 0===c||c.call(d),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===(_=null===(E=this.options.events)||void 0===E?void 0:E.onPaymentSessionExpired)||void 0===_||_.call(E),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 y({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,(g=exports.AuthorizationFailureReasons||(exports.AuthorizationFailureReasons={})).VALIDATION_FAILED="VALIDATION_FAILED",g.AUTHORIZATION_ERROR="AUTHORIZATION_ERROR",g.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",g.UNKNOWN_ERROR="UNKNOWN_ERROR";var P={},b={},M={};Object.defineProperty(M,"__esModule",{value:!0}),M.isntString=void 0,M.isntString=function(e){return"string"!=typeof e};var w={},U={};Object.defineProperty(U,"__esModule",{value:!0}),U.subscribers=U.childWindows=U.prefix=void 0,U.prefix="/*framebus*/",U.childWindows=[],U.subscribers={};var k={},Y={},x={},V={};Object.defineProperty(V,"__esModule",{value:!0}),V.subscriptionArgsInvalid=void 0;var F=M;V.subscriptionArgsInvalid=function(e,t,i){return!!F.isntString(e)||("function"!=typeof t||F.isntString(i))};var G={},B={};Object.defineProperty(B,"__esModule",{value:!0}),B.hasOpener=void 0,B.hasOpener=function(e){return e.top===e&&(null!=e.opener&&(e.opener!==e&&!0!==e.opener.closed))},Object.defineProperty(G,"__esModule",{value:!0}),G.broadcast=void 0;var j,X=B;function W(){if(j)return x;j=1,Object.defineProperty(x,"__esModule",{value:!0}),x.Framebus=void 0;var e=M,t=V,i=G,n=H(),o=U,s=function(){function s(e){void 0===e&&(e="*"),this.origin=e}return s.target=function(e){return void 0===e&&(e="*"),new s(e)},s.prototype.include=function(e){return null!=e&&(null!=e.Window&&(e.constructor===e.Window&&(o.childWindows.push(e),!0)))},s.prototype.target=function(e){return s.target(e)},s.prototype.emit=function(t,o,s){var r=this.origin;if(e.isntString(t))return!1;if(e.isntString(r))return!1;"function"==typeof o&&(s=o,o=void 0);var a=n.packagePayload(t,r,o,s);return!!a&&(i.broadcast(window.top||window.self,a,r),!0)},s.prototype.on=function(e,i){var n=this.origin;return!t.subscriptionArgsInvalid(e,i,n)&&(o.subscribers[n]=o.subscribers[n]||{},o.subscribers[n][e]=o.subscribers[n][e]||[],o.subscribers[n][e].push(i),!0)},s.prototype.off=function(e,i){var n=this.origin;if(t.subscriptionArgsInvalid(e,i,n))return!1;var s=o.subscribers[n]&&o.subscribers[n][e];if(!s)return!1;for(var r=0;r<s.length;r++)if(s[r]===i)return s.splice(r,1),!0;return!1},s}();return x.Framebus=s,x}G.broadcast=function e(t,i,n){var o,s=0;try{for(t.postMessage(i,n),X.hasOpener(t)&&e(t.opener.top,i,n);o=t.frames[s];)e(o,i,n),s++}catch(e){}};var $,z,K=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)}))};function H(){if(z)return k;z=1,Object.defineProperty(k,"__esModule",{value:!0}),k.packagePayload=void 0;var e=function(){if($)return Y;$=1;var e=n&&n.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Y,"__esModule",{value:!0}),Y.subscribeReplier=void 0;var t=W(),i=e(K);return Y.subscribeReplier=function(e,n){var o=i.default();return t.Framebus.target(n).on(o,(function i(s,r){e(s,r),t.Framebus.target(n).off(o,i)})),o},Y}(),t=U;return k.packagePayload=function(i,n,o,s){var r,a={event:i,origin:n};"function"==typeof s&&(a.reply=e.subscribeReplier(s,n)),a.eventData=o;try{r=t.prefix+JSON.stringify(a)}catch(e){throw new Error("Could not stringify event: "+e.message)}return r},k}Object.defineProperty(w,"__esModule",{value:!0}),w.unpackPayload=void 0;var q=U,J=H();w.unpackPayload=function(e){var t;if(e.data.slice(0,q.prefix.length)!==q.prefix)return!1;try{t=JSON.parse(e.data.slice(q.prefix.length))}catch(e){return!1}if(t.reply){var i=e.origin,n=e.source,o=t.reply;t.reply=function(e){if(n){var t=J.packagePayload(o,i,e);t&&n.postMessage(t,i)}}}return t};var Z={};Object.defineProperty(Z,"__esModule",{value:!0}),Z.dispatch=void 0;var Q=U;Z.dispatch=function(e,t,i,n,o){if(Q.subscribers[e]&&Q.subscribers[e][t]){var s=[];i&&s.push(i),n&&s.push(n);for(var r=0;r<Q.subscribers[e][t].length;r++)Q.subscribers[e][t][r].apply(o,s)}};var ee={};Object.defineProperty(ee,"__esModule",{value:!0}),ee.broadcastToChildWindows=void 0;var te=G,ie=U;ee.broadcastToChildWindows=function(e,t,i){for(var n=ie.childWindows.length-1;n>=0;n--){var o=ie.childWindows[n];o.closed?ie.childWindows.splice(n,1):i!==o&&te.broadcast(o.top,e,t)}},Object.defineProperty(b,"__esModule",{value:!0}),b.onmessage=void 0;var ne=M,oe=w,se=Z,re=ee;b.onmessage=function(e){if(!ne.isntString(e.data)){var t=oe.unpackPayload(e);if(t){var i=t.eventData,n=t.reply;se.dispatch("*",t.event,i,n,e),se.dispatch(e.origin,t.event,i,n,e),re.broadcastToChildWindows(e.data,t.origin,e.source)}}},Object.defineProperty(P,"__esModule",{value:!0}),P.detach=P.attach=void 0;var ae=b,le=!1;P.attach=function(){le||"undefined"==typeof window||(le=!0,window.addEventListener("message",ae.onmessage,!1))},P.detach=function(){le=!1,window.removeEventListener("message",ae.onmessage,!1)};var de=P,ce=new(W().Framebus);de.attach();var Ee=o(ce);const _e={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."},ue={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."},Ie={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."},he="collect_controller",pe="element",fe="INSERT",Ne="GET_BY_SKYFLOWID",Te="GET",me="DELETE",Oe={CHANGE:"CHANGE",READY:"READY",FOCUS:"FOCUS",BLUR:"BLUR",ESCAPE:"ESCAPE",CLICK:"CLICK",ERROR:"ERROR",SUCCESS:"SUCCESS",SUBMIT:"SUBMIT",CREATED:"CREATED",MOUNTED:"MOUNTED",HEIGHT:"HEIGHT"},ve="FRAME_READY",Ae="TOKENIZATION_REQUEST",ye="INPUT_EVENT",Le="DESTROY FRAME",Re="SET_VALUE",ge="PUREJS_REQUEST",Se="PUREJS_FRAME_READY",De="GET_BEARER_TOKEN",Ce="COLLECT_ELEMENT_SET_ERROR",Pe="COMPOSABLE_UPDATE_OPTIONS",be="COMPOSABLE_CONTAINER_MOUNTED",Me="COLLECT_CONTAINER_MOUNTED";var we,Ue;!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"}(we||(we={})),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"}(Ue||(Ue={}));const ke={[Ue.AMEX]:["XXXX XXXXXX XXXXX",{X:"[0-9]"}],[Ue.VISA]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[Ue.MASTERCARD]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[Ue.DISCOVER]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Ue.DINERS_CLUB]:["XXXX XXXXXX XXXXXX",{X:"[0-9]"}],[Ue.JCB]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Ue.MAESTRO]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Ue.UNIONPAY]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Ue.HIPERCARD]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Ue.DEFAULT]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Ue.UNKNOWN]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}]},Ye={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},[we.CARDHOLDER_NAME]:{name:"cardHolderName",attributes:{type:"text",autocomplete:"cc-name"},sensitive:!0,regex:/^([a-zA-Z\\ \\,\\.\\-\\']{2,})$/},[we.CARD_NUMBER]:{name:"CARD_NUMBER",attributes:{type:"text",autocomplete:"cc-number",inputmode:"numeric"},sensitive:!0,mask:ke[Ue.DEFAULT],regex:/$|^[\s]*?([0-9]{2,6}[ -]?){3,5}[\s]*/},[we.EXPIRATION_DATE]:{name:"EXPIRATION_DATE",attributes:{type:"text",autocomplete:"cc-exp",inputmode:"numeric"},sensitive:!0},[we.EXPIRATION_MONTH]:{name:"EXPIRATION_MONTH",attributes:{maxLength:2,type:"text",inputmode:"numeric",autocomplete:"cc-exp-month"},sensitive:!0,mask:["XX",{X:"[0-9]"}]},[we.EXPIRATION_YEAR]:{name:"EXPIRATION_YEAR",attributes:{type:"text",inputmode:"numeric",autocomplete:"cc-exp-year"},sensitive:!0},[we.CVV]:{name:"CVV",attributes:{type:"text",inputmode:"numeric",maxLength:4},sensitive:!0,regex:/^$|^[0-9]{3,4}$/},[we.INPUT_FIELD]:{name:"INPUT_FIELD",sensitive:!0,attributes:{type:"text"}},[we.PIN]:{name:"PIN",attributes:{type:"text",inputmode:"numeric",maxLength:12,minLength:4},sensitive:!0,regex:/^$|^[0-9]{4,12}$/}},xe="XXXX-XXXX-XXXX-XXXX",Ve={height:"100%",width:"100%",margin:0,padding:0,border:0,position:"absolute",top:0,left:0,"user-select":"none"},Fe={position:"absolute",top:0,width:0,height:0,visibility:"hidden",left:"-99999999px","user-select":"none"},Ge={width:"100%",height:"100%",border:"0",padding:"0",margin:"0",outline:"none"},Be={WEBPACKAUTOFILL:"-webkit-autofill",BASE:"base",FOCUS:"focus",COMPLETE:"complete",EMPTY:"empty",INVALID:"invalid",GLOBAL:"global",REQUIRED_ASTERISK:"requiredAsterisk"};Be.BASE,Be.REQUIRED_ASTERISK;const je={[Ue.VISA]:{regex:/^4\d*/,maxCardLength:19,cardLengthRange:[13,16]},[Ue.MASTERCARD]:{regex:/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720)\d*/,maxCardLength:16,cardLengthRange:[16]},[Ue.AMEX]:{regex:/^3[47]\d*/,maxCardLength:15,cardLengthRange:[15]},[Ue.DINERS_CLUB]:{regex:/^(36|38|30[0-5])\d*/,maxCardLength:16,cardLengthRange:[14,15,16,17,18,19]},[Ue.DISCOVER]:{regex:/^(6011|65|64[4-9]|622)\d*/,maxCardLength:16,cardLengthRange:[16,17,18,19]},[Ue.JCB]:{regex:/^35\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[Ue.HIPERCARD]:{regex:/^606282\d*/,maxCardLength:19,cardLengthRange:[14,15,16,17,18,19]},[Ue.UNIONPAY]:{regex:/^62\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[Ue.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]}};Ue.DEFAULT,Ue.AMEX,Ue.DINERS_CLUB,Ue.DISCOVER,Ue.HIPERCARD,Ue.JCB,Ue.MAESTRO,Ue.MASTERCARD,Ue.UNIONPAY,Ue.VISA;const Xe="MM/YY",We=[Xe,"YYYY/MM","YY/MM","MM/YYYY"],$e=["YY","YYYY"];var ze;!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"}(ze||(ze={})),we.CARD_NUMBER,we.EXPIRATION_DATE,we.EXPIRATION_MONTH,we.EXPIRATION_YEAR,we.CVV,we.EXPIRATION_DATE,we.CARD_NUMBER,we.CARDHOLDER_NAME,we.INPUT_FIELD,ue.INVALID_COLLECT_VALUE,we.PIN,we.EXPIRATION_MONTH,we.EXPIRATION_YEAR,we.CVV,we.EXPIRATION_DATE,we.CARD_NUMBER,we.CARDHOLDER_NAME,we.INPUT_FIELD,ue.DEFAULT_REQUIRED_COLLECT_VALUE,we.PIN,we.EXPIRATION_MONTH,we.EXPIRATION_YEAR;const Ke=[we.CARDHOLDER_NAME,we.EXPIRATION_MONTH,we.PIN,we.CVV],He={X:"[0-9]"};class qe{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(qe.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",E=null!=r?r:d;super(c),this.name=e,this.docUrl=E,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={};let a;!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 E(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var _={},u={},I={};Object.defineProperty(I,"__esModule",{value:!0}),I.isntString=void 0,I.isntString=function(e){return"string"!=typeof e};var h={},p={};Object.defineProperty(p,"__esModule",{value:!0}),p.subscribers=p.childWindows=p.prefix=void 0,p.prefix="/*framebus*/",p.childWindows=[],p.subscribers={};var f={},N={},T={},m={};Object.defineProperty(m,"__esModule",{value:!0}),m.subscriptionArgsInvalid=void 0;var v=I;m.subscriptionArgsInvalid=function(e,t,i){return!!v.isntString(e)||("function"!=typeof t||v.isntString(i))};var O={},A={};Object.defineProperty(A,"__esModule",{value:!0}),A.hasOpener=void 0,A.hasOpener=function(e){return e.top===e&&(null!=e.opener&&(e.opener!==e&&!0!==e.opener.closed))},Object.defineProperty(O,"__esModule",{value:!0}),O.broadcast=void 0;var y,L=A;function R(){if(y)return T;y=1,Object.defineProperty(T,"__esModule",{value:!0}),T.Framebus=void 0;var e=I,t=m,i=O,n=D(),o=p,s=function(){function s(e){void 0===e&&(e="*"),this.origin=e}return s.target=function(e){return void 0===e&&(e="*"),new s(e)},s.prototype.include=function(e){return null!=e&&(null!=e.Window&&(e.constructor===e.Window&&(o.childWindows.push(e),!0)))},s.prototype.target=function(e){return s.target(e)},s.prototype.emit=function(t,o,s){var r=this.origin;if(e.isntString(t))return!1;if(e.isntString(r))return!1;"function"==typeof o&&(s=o,o=void 0);var a=n.packagePayload(t,r,o,s);return!!a&&(i.broadcast(window.top||window.self,a,r),!0)},s.prototype.on=function(e,i){var n=this.origin;return!t.subscriptionArgsInvalid(e,i,n)&&(o.subscribers[n]=o.subscribers[n]||{},o.subscribers[n][e]=o.subscribers[n][e]||[],o.subscribers[n][e].push(i),!0)},s.prototype.off=function(e,i){var n=this.origin;if(t.subscriptionArgsInvalid(e,i,n))return!1;var s=o.subscribers[n]&&o.subscribers[n][e];if(!s)return!1;for(var r=0;r<s.length;r++)if(s[r]===i)return s.splice(r,1),!0;return!1},s}();return T.Framebus=s,T}O.broadcast=function e(t,i,n){var o,s=0;try{for(t.postMessage(i,n),L.hasOpener(t)&&e(t.opener.top,i,n);o=t.frames[s];)e(o,i,n),s++}catch(e){}};var g,S,C=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)}))};function D(){if(S)return f;S=1,Object.defineProperty(f,"__esModule",{value:!0}),f.packagePayload=void 0;var e=function(){if(g)return N;g=1;var e=c&&c.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(N,"__esModule",{value:!0}),N.subscribeReplier=void 0;var t=R(),i=e(C);return N.subscribeReplier=function(e,n){var o=i.default();return t.Framebus.target(n).on(o,(function i(s,r){e(s,r),t.Framebus.target(n).off(o,i)})),o},N}(),t=p;return f.packagePayload=function(i,n,o,s){var r,a={event:i,origin:n};"function"==typeof s&&(a.reply=e.subscribeReplier(s,n)),a.eventData=o;try{r=t.prefix+JSON.stringify(a)}catch(e){throw new Error("Could not stringify event: "+e.message)}return r},f}Object.defineProperty(h,"__esModule",{value:!0}),h.unpackPayload=void 0;var P=p,b=D();h.unpackPayload=function(e){var t;if(e.data.slice(0,P.prefix.length)!==P.prefix)return!1;try{t=JSON.parse(e.data.slice(P.prefix.length))}catch(e){return!1}if(t.reply){var i=e.origin,n=e.source,o=t.reply;t.reply=function(e){if(n){var t=b.packagePayload(o,i,e);t&&n.postMessage(t,i)}}}return t};var M={};Object.defineProperty(M,"__esModule",{value:!0}),M.dispatch=void 0;var w=p;M.dispatch=function(e,t,i,n,o){if(w.subscribers[e]&&w.subscribers[e][t]){var s=[];i&&s.push(i),n&&s.push(n);for(var r=0;r<w.subscribers[e][t].length;r++)w.subscribers[e][t][r].apply(o,s)}};var U={};Object.defineProperty(U,"__esModule",{value:!0}),U.broadcastToChildWindows=void 0;var k=O,Y=p;U.broadcastToChildWindows=function(e,t,i){for(var n=Y.childWindows.length-1;n>=0;n--){var o=Y.childWindows[n];o.closed?Y.childWindows.splice(n,1):i!==o&&k.broadcast(o.top,e,t)}},Object.defineProperty(u,"__esModule",{value:!0}),u.onmessage=void 0;var x=I,V=h,G=M,B=U;u.onmessage=function(e){if(!x.isntString(e.data)){var t=V.unpackPayload(e);if(t){var i=t.eventData,n=t.reply;G.dispatch("*",t.event,i,n,e),G.dispatch(e.origin,t.event,i,n,e),B.broadcastToChildWindows(e.data,t.origin,e.source)}}},Object.defineProperty(_,"__esModule",{value:!0}),_.detach=_.attach=void 0;var F=u,j=!1;_.attach=function(){j||"undefined"==typeof window||(j=!0,window.addEventListener("message",F.onmessage,!1))},_.detach=function(){j=!1,window.removeEventListener("message",F.onmessage,!1)};var X=_,W=new(R().Framebus);X.attach();const z=E(W);class ${constructor(){this.listeners=[],this.isDestroyed=!1}on(e,t){z.on(e,t),this.listeners.push({eventName:e,callback:t})}off(e,t){z.off(e,t);const i=this.listeners.findIndex((t=>t.eventName===e));-1!==i&&this.listeners.splice(i,1)}emit(e,t,i=void 0){z.emit(e,t,i)}hasListener(e){return-1!==this.listeners.findIndex((t=>t.eventName===e))}teardown(){this.listeners.forEach((e=>{z.off(e.eventName,e.handler)})),this.listeners=[]}}class K{constructor(){this.bus=new $}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===q}(e)}(e)};var q="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function J(e,t){return!1!==t.clone&&t.isMergeableObject(e)?ie((i=e,Array.isArray(i)?[]:{}),e,t):e;var i}function Z(e,t,i){return e.concat(t).map((function(e){return J(e,i)}))}function Q(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 ee(e,t){try{return t in e}catch(e){return!1}}function te(e,t,i){var n={};return i.isMergeableObject(e)&&Q(e).forEach((function(t){n[t]=J(e[t],i)})),Q(t).forEach((function(o){(function(e,t){return ee(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,o)||(ee(e,o)&&i.isMergeableObject(t[o])?n[o]=function(e,t){if(!t.customMerge)return ie;var i=t.customMerge(e);return"function"==typeof i?i:ie}(o,i)(e[o],t[o],i):n[o]=J(t[o],i))})),n}function ie(e,t,i){(i=i||{}).arrayMerge=i.arrayMerge||Z,i.isMergeableObject=i.isMergeableObject||H,i.cloneUnlessOtherwiseSpecified=J;var n=Array.isArray(t);return n===Array.isArray(e)?n?i.arrayMerge(e,t,i):te(e,t,i):J(t,i)}ie.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,i){return ie(e,i,t)}),{})};const ne=E(ie);class oe{constructor(){this.state={}}static getInstance(){return oe.instance||(oe.instance=new oe),oe.instance}getState(e){return this.state[e]}setState(e){this.state=ne(this.state,e)}}const se=oe.getInstance(),re=()=>window&&window.navigator,ae=()=>window&&window.screen,le=()=>({resolution:`${ae().width}x${ae().height}`,user_agent:re().userAgent,language:re().language});class de{constructor(e){this.adapter=[new K],this.enabled=e.enabled||!0,this.initGlobalState(e),e.logLevel=e.logLevel||"error","debug"===e.logLevel&&this.addAdapter(new l)}static init(e){de.instance=new de(e)}static getLogger(){return de.instance}initGlobalState(e){se.setState({payrails:e.payrails,sdk:e.sdk})}static setState(e){se.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:le(),payrails:se.getState("payrails"),sdk:se.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=de,e.getDeviceInfo=le}(r);const l=new Uint8Array(16);function d(){if(!a&&(a="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!a))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return a(l)}const c=[];for(let e=0;e<256;++e)c.push((e+256).toString(16).slice(1));var E={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function _(e,t,i){if(E.randomUUID&&!t&&!e)return E.randomUUID();const n=(e=e||{}).random||(e.rng||d)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){i=i||0;for(let e=0;e<16;++e)t[i+e]=n[e];return t}return function(e,t=0){return c[e[t+0]]+c[e[t+1]]+c[e[t+2]]+c[e[t+3]]+"-"+c[e[t+4]]+c[e[t+5]]+"-"+c[e[t+6]]+c[e[t+7]]+"-"+c[e[t+8]]+c[e[t+9]]+"-"+c[e[t+10]]+c[e[t+11]]+c[e[t+12]]+c[e[t+13]]+c[e[t+14]]+c[e[t+15]]}(n)}var u;!function(e){e.GET="GET",e.POST="POST"}(u||(u={}));const I=({url:t,method:i=u.GET,token:n,body:o})=>e(void 0,void 0,void 0,(function*(){const e={method:i,headers:Object.assign(Object.assign(Object.assign({},m()),T(n)),v())};i===u.POST&&(e.body=JSON.stringify(o||{}));const s=yield fetch(t,e),r=yield s.json();if([401,403].includes(s.status))throw new h(t,i);if(429===s.status)throw new f(t,i);if(!s.ok)throw new p(t,i);return{ok:s.ok,req:Object.assign({url:t},e),res:r}}));class h extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_UNAUTHORIZED,{description:`[${t}] ${e} unauthorized`})}}class p extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{description:`[${t}] ${e} unsuccessful`})}}class f extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} too many requests`})}}class N extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} max poll attempts exceeded.`})}}const T=e=>({authorization:`Bearer ${e}`}),m=()=>({"x-idempotency-key":_()}),v=()=>{const e={version:"4.1.0-RC.3",type:"web-sdk"};return{"x-client-version":e.version,"x-client-type":e.type}},O={success:"https://payrails.io/success",error:"https://payrails.io/error",cancel:"https://payrails.io/cancel"};class A{constructor(e,t,i=O,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:u.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 N(t,u.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 p)return yield this.wait(this.POLL_INTERVAL),this.getExecution(t,i,n+this.POLL_ERROR_COUNT_MULTIPLIER);if(e instanceof f)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:u.POST,token:this.sdkConfig.token,body:{integrationType:"api",paymentMethodCode:"applePay",amount:this.sdkConfig.amount,meta:{sessionURL:t.sessionUrl,clientDomain: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:u.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 y{constructor(e,t,i,n,o=L.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===L.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 L,R,g,S;!function(e){e[e.THREE_DS=0]="THREE_DS",e[e.GENERIC_REDIRECT=1]="GENERIC_REDIRECT"}(L||(L={}));class C{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 y(o,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"}(R||(R={})),function(e){e.ENABLED="enabled",e.CREATED="created",e.DELETED="deleted",e.DISABLED="disabled",e.INVALID="invalid",e.TRANSIENT="transient"}(g||(g={}));class D{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(R.CARD)}get savedPaypalAccounts(){return this.getStoredInstrumentForPaymentMethod(R.PAYPAL)}get savedGooglePayAccounts(){return this.getStoredInstrumentForPaymentMethod(R.GOOGLE_PAY)}get savedApplePayAccounts(){return this.getStoredInstrumentForPaymentMethod(R.APPLE_PAY)}get paypalConfig(){const e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===R.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===R.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===R.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)||[]}}class P{constructor(e,{id:t="",className:i=""}={}){this.subElements=[];const n=document.createElement(e);t&&(this.id=t,n.setAttribute("id",t)),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`});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)}))}unmount(){var e;this.subElements.forEach((e=>e.unmount())),null===(e=this.parentElement)||void 0===e||e.removeChild(this.element)}}class b extends P{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.returnLinks=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 A(this.sdkConfig,this.execution,this.returnLinks)}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,E,_;return e(this,void 0,void 0,(function*(){if(this.setDisabled(!0),this.triggerLoading(!0),null===(t=this.options.events)||void 0===t?void 0:t.onPaymentButtonClicked)try{if(!1===(yield null===(i=this.options.events)||void 0===i?void 0:i.onPaymentButtonClicked({bin:this.bin||""}))){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_ONPAY_CALLBACK_FAILED,{description:"Callback passed to onPaymentButtonClicked resolved to false"});return r.PayrailsLogger.error(e.message,{error:e}),void this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:e.message})}}catch(e){const t=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(t.message,{error:t}),void this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:t.message})}try{let e=[{paymentMethodCode:R.CARD,integrationType:"api",amount:this.sdkConfig.amount,storeInstrument:!1}];if(null===(n=this.selectedInstrument)||void 0===n?void 0:n.id)e[0].paymentInstrumentId=null===(o=this.selectedInstrument)||void 0===o?void 0:o.id,e[0].paymentMethodCode=null===(a=this.selectedInstrument)||void 0===a?void 0:a.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 t=yield this.paymentExecutor.pay(e);this.handleAuthorizationResult(t)}catch(e){let t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_AUTHENTICATION_ERROR,{cause:e});e instanceof h||[401,403].includes(null===(l=null==e?void 0:e.error)||void 0===l?void 0:l.code)?(null===(c=null===(d=this.options.events)||void 0===d?void 0:d.onPaymentSessionExpired)||void 0===c||c.call(d),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===(_=null===(E=this.options.events)||void 0===E?void 0:E.onPaymentSessionExpired)||void 0===_||_.call(E),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 C({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,(S=exports.AuthorizationFailureReasons||(exports.AuthorizationFailureReasons={})).VALIDATION_FAILED="VALIDATION_FAILED",S.AUTHORIZATION_ERROR="AUTHORIZATION_ERROR",S.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",S.UNKNOWN_ERROR="UNKNOWN_ERROR";var M={},w={},U={};Object.defineProperty(U,"__esModule",{value:!0}),U.isntString=void 0,U.isntString=function(e){return"string"!=typeof e};var k={},Y={};Object.defineProperty(Y,"__esModule",{value:!0}),Y.subscribers=Y.childWindows=Y.prefix=void 0,Y.prefix="/*framebus*/",Y.childWindows=[],Y.subscribers={};var x={},V={},G={},B={};Object.defineProperty(B,"__esModule",{value:!0}),B.subscriptionArgsInvalid=void 0;var F=U;B.subscriptionArgsInvalid=function(e,t,i){return!!F.isntString(e)||("function"!=typeof t||F.isntString(i))};var j={},X={};Object.defineProperty(X,"__esModule",{value:!0}),X.hasOpener=void 0,X.hasOpener=function(e){return e.top===e&&(null!=e.opener&&(e.opener!==e&&!0!==e.opener.closed))},Object.defineProperty(j,"__esModule",{value:!0}),j.broadcast=void 0;var W,z=X;function $(){if(W)return G;W=1,Object.defineProperty(G,"__esModule",{value:!0}),G.Framebus=void 0;var e=U,t=B,i=j,n=J(),o=Y,s=function(){function s(e){void 0===e&&(e="*"),this.origin=e}return s.target=function(e){return void 0===e&&(e="*"),new s(e)},s.prototype.include=function(e){return null!=e&&(null!=e.Window&&(e.constructor===e.Window&&(o.childWindows.push(e),!0)))},s.prototype.target=function(e){return s.target(e)},s.prototype.emit=function(t,o,s){var r=this.origin;if(e.isntString(t))return!1;if(e.isntString(r))return!1;"function"==typeof o&&(s=o,o=void 0);var a=n.packagePayload(t,r,o,s);return!!a&&(i.broadcast(window.top||window.self,a,r),!0)},s.prototype.on=function(e,i){var n=this.origin;return!t.subscriptionArgsInvalid(e,i,n)&&(o.subscribers[n]=o.subscribers[n]||{},o.subscribers[n][e]=o.subscribers[n][e]||[],o.subscribers[n][e].push(i),!0)},s.prototype.off=function(e,i){var n=this.origin;if(t.subscriptionArgsInvalid(e,i,n))return!1;var s=o.subscribers[n]&&o.subscribers[n][e];if(!s)return!1;for(var r=0;r<s.length;r++)if(s[r]===i)return s.splice(r,1),!0;return!1},s}();return G.Framebus=s,G}j.broadcast=function e(t,i,n){var o,s=0;try{for(t.postMessage(i,n),z.hasOpener(t)&&e(t.opener.top,i,n);o=t.frames[s];)e(o,i,n),s++}catch(e){}};var K,H,q=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)}))};function J(){if(H)return x;H=1,Object.defineProperty(x,"__esModule",{value:!0}),x.packagePayload=void 0;var e=function(){if(K)return V;K=1;var e=n&&n.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(V,"__esModule",{value:!0}),V.subscribeReplier=void 0;var t=$(),i=e(q);return V.subscribeReplier=function(e,n){var o=i.default();return t.Framebus.target(n).on(o,(function i(s,r){e(s,r),t.Framebus.target(n).off(o,i)})),o},V}(),t=Y;return x.packagePayload=function(i,n,o,s){var r,a={event:i,origin:n};"function"==typeof s&&(a.reply=e.subscribeReplier(s,n)),a.eventData=o;try{r=t.prefix+JSON.stringify(a)}catch(e){throw new Error("Could not stringify event: "+e.message)}return r},x}Object.defineProperty(k,"__esModule",{value:!0}),k.unpackPayload=void 0;var Z=Y,Q=J();k.unpackPayload=function(e){var t;if(e.data.slice(0,Z.prefix.length)!==Z.prefix)return!1;try{t=JSON.parse(e.data.slice(Z.prefix.length))}catch(e){return!1}if(t.reply){var i=e.origin,n=e.source,o=t.reply;t.reply=function(e){if(n){var t=Q.packagePayload(o,i,e);t&&n.postMessage(t,i)}}}return t};var ee={};Object.defineProperty(ee,"__esModule",{value:!0}),ee.dispatch=void 0;var te=Y;ee.dispatch=function(e,t,i,n,o){if(te.subscribers[e]&&te.subscribers[e][t]){var s=[];i&&s.push(i),n&&s.push(n);for(var r=0;r<te.subscribers[e][t].length;r++)te.subscribers[e][t][r].apply(o,s)}};var ie={};Object.defineProperty(ie,"__esModule",{value:!0}),ie.broadcastToChildWindows=void 0;var ne=j,oe=Y;ie.broadcastToChildWindows=function(e,t,i){for(var n=oe.childWindows.length-1;n>=0;n--){var o=oe.childWindows[n];o.closed?oe.childWindows.splice(n,1):i!==o&&ne.broadcast(o.top,e,t)}},Object.defineProperty(w,"__esModule",{value:!0}),w.onmessage=void 0;var se=U,re=k,ae=ee,le=ie;w.onmessage=function(e){if(!se.isntString(e.data)){var t=re.unpackPayload(e);if(t){var i=t.eventData,n=t.reply;ae.dispatch("*",t.event,i,n,e),ae.dispatch(e.origin,t.event,i,n,e),le.broadcastToChildWindows(e.data,t.origin,e.source)}}},Object.defineProperty(M,"__esModule",{value:!0}),M.detach=M.attach=void 0;var de=w,ce=!1;M.attach=function(){ce||"undefined"==typeof window||(ce=!0,window.addEventListener("message",de.onmessage,!1))},M.detach=function(){ce=!1,window.removeEventListener("message",de.onmessage,!1)};var Ee=M,_e=new($().Framebus);Ee.attach();var ue=o(_e);const Ie={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."},he={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."},pe={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."},fe="collect_controller",Ne="element",Te="INSERT",me="GET_BY_SKYFLOWID",ve="GET",Oe="DELETE",Ae={CHANGE:"CHANGE",READY:"READY",FOCUS:"FOCUS",BLUR:"BLUR",ESCAPE:"ESCAPE",CLICK:"CLICK",ERROR:"ERROR",SUCCESS:"SUCCESS",SUBMIT:"SUBMIT",CREATED:"CREATED",MOUNTED:"MOUNTED",HEIGHT:"HEIGHT"},ye="FRAME_READY",Le="TOKENIZATION_REQUEST",Re="INPUT_EVENT",ge="DESTROY FRAME",Se="SET_VALUE",Ce="PUREJS_REQUEST",De="PUREJS_FRAME_READY",Pe="GET_BEARER_TOKEN",be="COLLECT_ELEMENT_SET_ERROR",Me="COMPOSABLE_UPDATE_OPTIONS",we="COMPOSABLE_CONTAINER_MOUNTED",Ue="COLLECT_CONTAINER_MOUNTED";var ke,Ye;!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"}(ke||(ke={})),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"}(Ye||(Ye={}));const xe={[Ye.AMEX]:["XXXX XXXXXX XXXXX",{X:"[0-9]"}],[Ye.VISA]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[Ye.MASTERCARD]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[Ye.DISCOVER]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Ye.DINERS_CLUB]:["XXXX XXXXXX XXXXXX",{X:"[0-9]"}],[Ye.JCB]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Ye.MAESTRO]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Ye.UNIONPAY]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Ye.HIPERCARD]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Ye.DEFAULT]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Ye.UNKNOWN]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}]},Ve={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},[ke.CARDHOLDER_NAME]:{name:"cardHolderName",attributes:{type:"text",autocomplete:"cc-name"},sensitive:!0,regex:/^([a-zA-Z\\ \\,\\.\\-\\']{2,})$/},[ke.CARD_NUMBER]:{name:"CARD_NUMBER",attributes:{type:"text",autocomplete:"cc-number",inputmode:"numeric"},sensitive:!0,mask:xe[Ye.DEFAULT],regex:/$|^[\s]*?([0-9]{2,6}[ -]?){3,5}[\s]*/},[ke.EXPIRATION_DATE]:{name:"EXPIRATION_DATE",attributes:{type:"text",autocomplete:"cc-exp",inputmode:"numeric"},sensitive:!0},[ke.EXPIRATION_MONTH]:{name:"EXPIRATION_MONTH",attributes:{maxLength:2,type:"text",inputmode:"numeric",autocomplete:"cc-exp-month"},sensitive:!0,mask:["XX",{X:"[0-9]"}]},[ke.EXPIRATION_YEAR]:{name:"EXPIRATION_YEAR",attributes:{type:"text",inputmode:"numeric",autocomplete:"cc-exp-year"},sensitive:!0},[ke.CVV]:{name:"CVV",attributes:{type:"text",inputmode:"numeric",maxLength:4},sensitive:!0,regex:/^$|^[0-9]{3,4}$/},[ke.INPUT_FIELD]:{name:"INPUT_FIELD",sensitive:!0,attributes:{type:"text"}},[ke.PIN]:{name:"PIN",attributes:{type:"text",inputmode:"numeric",maxLength:12,minLength:4},sensitive:!0,regex:/^$|^[0-9]{4,12}$/}},Ge="XXXX-XXXX-XXXX-XXXX",Be={height:"100%",width:"100%",margin:0,padding:0,border:0,position:"absolute",top:0,left:0,"user-select":"none"},Fe={position:"absolute",top:0,width:0,height:0,visibility:"hidden",left:"-99999999px","user-select":"none"},je={width:"100%",height:"100%",border:"0",padding:"0",margin:"0",outline:"none"},Xe={WEBPACKAUTOFILL:"-webkit-autofill",BASE:"base",FOCUS:"focus",COMPLETE:"complete",EMPTY:"empty",INVALID:"invalid",GLOBAL:"global",REQUIRED_ASTERISK:"requiredAsterisk"};Xe.BASE,Xe.REQUIRED_ASTERISK;const We={[Ye.VISA]:{regex:/^4\d*/,maxCardLength:19,cardLengthRange:[13,16]},[Ye.MASTERCARD]:{regex:/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720)\d*/,maxCardLength:16,cardLengthRange:[16]},[Ye.AMEX]:{regex:/^3[47]\d*/,maxCardLength:15,cardLengthRange:[15]},[Ye.DINERS_CLUB]:{regex:/^(36|38|30[0-5])\d*/,maxCardLength:16,cardLengthRange:[14,15,16,17,18,19]},[Ye.DISCOVER]:{regex:/^(6011|65|64[4-9]|622)\d*/,maxCardLength:16,cardLengthRange:[16,17,18,19]},[Ye.JCB]:{regex:/^35\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[Ye.HIPERCARD]:{regex:/^606282\d*/,maxCardLength:19,cardLengthRange:[14,15,16,17,18,19]},[Ye.UNIONPAY]:{regex:/^62\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[Ye.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]}};Ye.DEFAULT,Ye.AMEX,Ye.DINERS_CLUB,Ye.DISCOVER,Ye.HIPERCARD,Ye.JCB,Ye.MAESTRO,Ye.MASTERCARD,Ye.UNIONPAY,Ye.VISA;const ze="MM/YY",$e=[ze,"YYYY/MM","YY/MM","MM/YYYY"],Ke=["YY","YYYY"];var He;!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"}(He||(He={})),ke.CARD_NUMBER,ke.EXPIRATION_DATE,ke.EXPIRATION_MONTH,ke.EXPIRATION_YEAR,ke.CVV,ke.EXPIRATION_DATE,ke.CARD_NUMBER,ke.CARDHOLDER_NAME,ke.INPUT_FIELD,he.INVALID_COLLECT_VALUE,ke.PIN,ke.EXPIRATION_MONTH,ke.EXPIRATION_YEAR,ke.CVV,ke.EXPIRATION_DATE,ke.CARD_NUMBER,ke.CARDHOLDER_NAME,ke.INPUT_FIELD,he.DEFAULT_REQUIRED_COLLECT_VALUE,ke.PIN,ke.EXPIRATION_MONTH,ke.EXPIRATION_YEAR;const qe=[ke.CARDHOLDER_NAME,ke.EXPIRATION_MONTH,ke.PIN,ke.CVV],Je={X:"[0-9]"};class Ze{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(Ze.prototype,{constructor:e})}}
2
2
  /* @copyright
3
3
  Copyright (c) 2022 Skyflow, Inc.
4
- */const Je={IFRAME_SECURE_SITE:"https://js.skyflow.com/v1/elements/index.html",IFRAME_SECURE_ORGIN:"https://js.skyflow.com"},Ze="https://assets.payrails.io/40cce42/card/index.html",Qe="https://assets.payrails.io",et={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no",style:"width: 100%;",allow:"clipboard-read; clipboard-write"},tt=(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 it=(e={})=>{const t=document.createElement("iframe"),i=Object.assign(Object.assign({},et),e);return Object.assign(t.style,Ve),tt(t,i),t.getAttribute("id")||(t.id=t.name),t};const nt=()=>Je.IFRAME_SECURE_SITE,ot=(e,t)=>{Object.keys(t).forEach((i=>{Object.prototype.hasOwnProperty.call(t,i)&&(e.style[i]=t[i])}))};function st(e){return JSON.parse(JSON.stringify(e))}class rt{constructor(){this.listeners=[],this.isDestroyed=!1}on(e,t){Ee.on(e,t),this.listeners.push({eventName:e,callback:t})}off(e,t){Ee.off(e,t);const i=this.listeners.findIndex((t=>t.eventName===e));-1!==i&&this.listeners.splice(i,1)}emit(e,t,i=void 0){Ee.emit(e,t,i)}hasListener(e){return-1!==this.listeners.findIndex((t=>t.eventName===e))}teardown(){this.listeners.forEach((e=>{Ee.off(e.eventName,e.handler)})),this.listeners=[]}}var at,lt,dt,ct,Et,_t,ut;!function(e){e.DEFAULT="DEFAULT",e.PLAIN_TEXT="PLAIN_TEXT",e.MASKED="MASKED",e.REDACTED="REDACTED"}(at||(at={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.PATCH="PATCH",e.DELETE="DELETE"}(lt||(lt={})),function(e){e.CHANGE="CHANGE",e.READY="READY",e.FOCUS="FOCUS",e.BLUR="BLUR",e.SUBMIT="SUBMIT"}(dt||(dt={})),function(e){e.WARN="WARN",e.INFO="INFO",e.DEBUG="DEBUG",e.ERROR="ERROR"}(ct||(ct={})),function(e){e.DEV="DEV",e.PROD="PROD"}(Et||(Et={})),function(e){e.LOG="LOG",e.WARN="WARN",e.ERROR="ERROR"}(_t||(_t={})),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"}(ut||(ut={}));const It={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}},ht={PROD:{doesReturnValue:!1},DEV:{doesReturnValue:!0}},pt="[Skyflow]",ft=(e,t,i)=>{if(i&&It[i]){const{showDebugLogs:n,showInfoLogs:o,showWarnLogs:s,showErrorLogs:r}=It[i];t===_t.LOG&&n?console.log(`${ct.DEBUG}: ${pt} ${e}`):t===_t.LOG&&o?console.log(`${ct.INFO}: ${pt} ${e}`):t===_t.WARN&&s?console.warn(`${ct.WARN}: ${pt} ${e}`):t===_t.ERROR&&r&&console.error(`${ct.ERROR}: ${pt} ${e}`)}},Nt=(...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]})):""},Tt=(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 mt extends Error{constructor(e,t,i=!1){const n={code:e.code,description:t&&(null==t?void 0:t.length)>0?Nt(e.description,...t):e.description};super(n.description),i?this.error=n:this.errors=[n]}}const Ot={INVALID_FIELD:{code:400,description:ue.INVALID_FIELD},VAULTID_IS_REQUIRED:{code:400,description:ue.VAULTID_IS_REQUIRED},EMPTY_VAULTID_IN_INIT:{code:400,description:ue.EMPTY_VAULTID_IN_INIT},VAULTURL_IS_REQUIRED:{code:400,description:ue.VAULTURL_IS_REQUIRED},EMPTY_VAULTURL_IN_INIT:{code:400,description:ue.EMPTY_VAULTURL_IN_INIT},INVALID_VAULTURL_IN_INIT:{code:400,description:ue.INVALID_VAULTURL_IN_INIT},GET_BEARER_TOKEN_IS_REQUIRED:{code:400,description:ue.GET_BEARER_TOKEN_IS_REQUIRED},EMPTY_CONTAINER_TYPE:{code:400,description:ue.EMPTY_CONTAINER_TYPE},INVALID_CONTAINER_TYPE:{code:400,description:ue.INVALID_CONTAINER_TYPE},UNIQUE_ELEMENT_NAME:{code:400,description:ue.UNIQUE_ELEMENT_NAME},ELEMENTS_NOT_MOUNTED:{code:400,description:ue.ELEMENTS_NOT_MOUNTED},MISSING_TABLE_IN_COLLECT:{code:400,description:ue.MISSING_TABLE_IN_COLLECT},EMPTY_TABLE_IN_COLLECT:{code:400,description:ue.EMPTY_TABLE_IN_COLLECT},EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:{code:400,description:ue.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS},INVALID_TABLE_IN_COLLECT:{code:400,description:ue.INVALID_TABLE_IN_COLLECT},INVALID_SKYFLOWID_IN_COLLECT:{code:400,description:ue.INVALID_SKYFLOWID_IN_COLLECT},MISSING_COLUMN_IN_COLLECT:{code:400,description:ue.MISSING_COLUMN_IN_COLLECT},EMPTY_COLUMN_IN_COLLECT:{code:400,description:ue.EMPTY_TABLE_IN_COLLECT},INVALID_COLUMN_IN_COLLECT:{code:400,description:ue.INVALID_COLUMN_IN_COLLECT},CLIENT_CONNECTION:{code:400,description:ue.CLIENT_CONNECTION},RECORDS_KEY_NOT_FOUND:{code:404,description:ue.RECORDS_KEY_NOT_FOUND},EMPTY_RECORDS_IN_INSERT:{code:400,description:ue.EMPTY_RECORDS_IN_INSERT},INVALID_RECORDS_IN_INSERT:{code:404,description:ue.INVALID_RECORDS_IN_INSERT},INVALID_TABLE_IN_INSERT:{code:400,description:ue.INVALID_TABLE_IN_INSERT},EMPTY_TABLE_IN_INSERT:{code:400,description:ue.EMPTY_TABLE_IN_INSERT},MISSING_TABLE_IN_INSERT:{code:400,description:ue.MISSING_TABLE_IN_INSERT},EMPTY_FIELDS_IN_INSERT:{code:400,description:ue.EMPTY_FIELDS_IN_INSERT},MISSING_FIELDS_IN_INSERT:{code:404,description:ue.MISSING_FIELDS_IN_INSERT},INVALID_FIELDS_IN_INSERT:{code:404,description:ue.INVALID_FIELDS_IN_INSERT},INVALID_TOKENS_IN_INSERT:{code:404,description:ue.INVALID_TOKENS_IN_INSERT},RECORDS_KEY_NOT_FOUND_DETOKENIZE:{code:404,description:ue.RECORDS_KEY_NOT_FOUND_DETOKENIZE},EMPTY_RECORDS_DETOKENIZE:{code:400,description:ue.EMPTY_RECORDS_DETOKENIZE},INVALID_RECORDS_IN_DETOKENIZE:{code:404,description:ue.INVALID_RECORDS_IN_DETOKENIZE},MISSING_TOKEN_IN_DETOKENIZE:{code:400,description:ue.MISSING_TOKEN_IN_DETOKENIZE},INVALID_TOKEN_IN_DETOKENIZE:{code:400,description:ue.INVALID_TOKEN_IN_DETOKENIZE},RECORDS_KEY_NOT_FOUND_GET:{code:400,description:ue.RECORDS_KEY_NOT_FOUND_GET},INVALID_RECORDS_IN_GET:{code:400,description:ue.INVALID_RECORDS_IN_GET},EMPTY_RECORDS_GET:{code:400,description:ue.EMPTY_RECORDS_GET},MISSING_IDS_IN_GET:{code:400,description:ue.MISSING_IDS_IN_GET},INVALID_IDS_IN_GET:{code:400,description:ue.INVALID_IDS_IN_GET},INVALID_COLUMN_VALUES_IN_GET:{code:400,description:ue.INVALID_COLUMN_VALUES_IN_GET},EMPTY_IDS_IN_GET:{code:400,description:ue.EMPTY_IDS_IN_GET},INVALID_SKYFLOWID_TYPE_IN_GET:{code:400,description:ue.INVALID_SKYFLOWID_TYPE_IN_GET},MISSING_TABLE_IN_GET:{code:400,description:ue.MISSING_TABLE_IN_GET},INVALID_TABLE_IN_GET:{code:400,description:ue.INVALID_TABLE_IN_GET},MISSING_REDACTION_IN_GET:{code:400,description:ue.MISSING_REDACTION_IN_GET},INVALID_REDACTION_TYPE_IN_GET:{code:400,description:ue.INVALID_REDACTION_TYPE_IN_GET},INVALID_TOKENS_IN_GET:{code:400,description:ue.INVALID_TOKENS_IN_GET},TOKENS_GET_COLUMN_NOT_SUPPORTED:{code:400,description:ue.TOKENS_GET_COLUMN_NOT_SUPPORTED},REDACTION_WITH_TOKENS_NOT_SUPPORTED:{code:400,description:ue.REDACTION_WITH_TOKENS_NOT_SUPPORTED},INVALID_REDACTION_TYPE_IN_DETOKENIZE:{code:400,description:ue.INVALID_REDACTION_TYPE_IN_DETOKENIZE},INVALID_TOKENS_IN_COLLECT:{code:404,description:ue.INVALID_TOKENS_IN_COLLECT},RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS:{code:404,description:ue.RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS},INVALID_RECORDS_IN_ADDITIONAL_FIELDS:{code:404,description:ue.INVALID_RECORDS_IN_ADDITIONAL_FIELDS},EMPTY_RECORDS_IN_ADDITIONAL_FIELDS:{code:400,description:ue.EMPTY_RECORDS_IN_ADDITIONAL_FIELDS},MISSING_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:ue.MISSING_TABLE_IN_ADDITIONAL_FIELDS},INVALID_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:ue.INVALID_TABLE_IN_ADDITIONAL_FIELDS},INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:{code:400,description:ue.INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS},MISSING_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:ue.MISSING_FIELDS_IN_ADDITIONAL_FIELDS},INVALID_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:ue.INVALID_FIELDS_IN_ADDITIONAL_FIELDS},RECORDS_KEY_NOT_FOUND_DELETE:{code:400,description:ue.RECORDS_KEY_NOT_FOUND_DELETE},EMPTY_RECORDS_IN_DELETE:{code:400,description:ue.EMPTY_RECORDS_IN_DELETE},INVALID_RECORDS_IN_DELETE:{code:404,description:ue.INVALID_RECORDS_IN_DELETE},INVALID_TABLE_IN_DELETE:{code:400,description:ue.INVALID_TABLE_IN_DELETE},EMPTY_TABLE_IN_DELETE:{code:400,description:ue.EMPTY_TABLE_IN_DELETE},MISSING_TABLE_IN_DELETE:{code:400,description:ue.MISSING_TABLE_IN_DELETE},EMPTY_ID_IN_DELETE:{code:400,description:ue.EMPTY_ID_IN_DELETE},MISSING_ID_IN_DELETE:{code:404,description:ue.MISSING_ID_IN_DELETE},INVALID_ID_IN_DELETE:{code:404,description:ue.INVALID_ID_IN_DELETE},EMPTY_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:ue.EMPTY_TABLE_IN_ADDITIONAL_FIELDS},EMPTY_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:ue.EMPTY_FIELDS_IN_ADDITIONAL_FIELDS},EMPTY_TOKEN_IN_DETOKENIZE:{code:400,description:ue.EMPTY_TOKEN_IN_DETOKENIZE},EMPTY_SKYFLOWID_IN_GET:{code:400,description:ue.EMPTY_SKYFLOWID_IN_GET},EMPTY_TABLE_IN_GET:{code:400,description:ue.EMPTY_TABLE_IN_GET},EMPTY_REDACTION_TYPE_IN_GET:{code:400,description:ue.EMPTY_REDACTION_TYPE_IN_GET},DUPLICATE_ELEMENT:{code:400,description:ue.DUPLICATE_ELEMENT},DUPLICATE_ELEMENT_ADDITIONAL_FIELDS:{code:400,description:ue.DUPLICATE_ELEMENT_ADDITIONAL_FIELDS},MISSING_ELEMENT_TYPE:{code:400,description:ue.MISSING_ELEMENT_TYPE},EMPTY_ELEMENT_TYPE:{code:400,description:ue.EMPTY_ELEMENT_TYPE},INVALID_ELEMENT_TYPE:{code:400,description:ue.INVALID_ELEMENT_TYPE},INVALID_ELEMENT_SELECTOR:{code:400,description:ue.INVALID_ELEMENT_SELECTOR},FRAME_NOT_FOUND:{code:400,description:ue.FRAME_NOT_FOUND},REQUIRED_PARAMS_NOT_PROVIDED:{code:400,description:ue.REQUIRED_PARAMS_NOT_PROVIDED},INVALID_RECORD_COLUMN_VALUE:{code:400,description:ue.INVALID_RECORD_COLUMN_VALUE},MISSING_RECORD_COLUMN_VALUE:{code:400,description:ue.MISSING_RECORD_COLUMN_VALUE},MISSING_RECORD_COLUMN_NAME:{code:400,description:ue.MISSING_RECORD_COLUMN_NAME},INVALID_EVENT_TYPE:{code:400,description:ue.INVALID_EVENT_TYPE},INVALID_EVENT_LISTENER:{code:400,description:ue.INVALID_EVENT_LISTENER},MISSING_HANDLER_IN_EVENT_LISTENER:{code:400,description:ue.MISSING_HANDLER_IN_EVENT_LISTENER},INVALID_HANDLER_IN_EVENT_LISTENER:{code:400,description:ue.INVALID_HANDLER_IN_EVENT_LISTENER},UNKNOWN_ERROR:{code:400,description:ue.UNKNOWN_ERROR},CONNECTION_ERROR:{code:400,description:ue.CONNECTION_ERROR},NETWORK_ERROR:{code:500,description:ue.NETWORK_ERROR},COMPLETE_AND_VALID_INPUTS:{code:400,description:ue.COMPLETE_AND_VALID_INPUTS},INVALID_VALIDATIONS_TYPE:{code:400,description:ue.INVALID_VALIDATIONS_TYPE},MISSING_VALIDATION_RULE_TYPE:{code:400,description:ue.MISSING_VALIDATION_RULE_TYPE},INVALID_VALIDATION_RULE_TYPE:{code:400,description:ue.INVALID_VALIDATION_RULE_TYPE},MISSING_VALIDATION_RULE_PARAMS:{code:400,description:ue.MISSING_VALIDATION_RULE_PARAMS},INVALID_VALIDATION_RULE_PARAMS:{code:400,description:ue.INVALID_VALIDATION_RULE_PARAMS},MISSING_REGEX_IN_REGEX_MATCH_RULE:{code:400,description:ue.MISSING_REGEX_IN_REGEX_MATCH_RULE},INVALID_REGEX_IN_REGEX_MATCH_RULE:{code:400,description:ue.INVALID_REGEX_IN_REGEX_MATCH_RULE},MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE:{code:400,description:ue.MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE},MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE:{code:400,description:ue.MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE},INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE:{code:400,description:ue.INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE},ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE:{code:400,description:ue.ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE},EMPTY_ELEMENT_IN_MOUNT:{code:400,description:ue.EMPTY_ELEMENT_IN_MOUNT},INVALID_TABLE_IN_UPSERT_OPTION:{code:400,description:ue.INVALID_TABLE_IN_UPSERT_OPTION},INVALID_COLUMN_IN_UPSERT_OPTION:{code:400,description:ue.INVALID_COLUMN_IN_UPSERT_OPTION},INVALID_UPSERT_OPTION_TYPE:{code:400,description:ue.INVALID_UPSERT_OPTION_TYPE},EMPTY_UPSERT_OPTIONS_ARRAY:{code:400,description:ue.EMPTY_UPSERT_OPTIONS_ARRAY},INVALID_UPSERT_OPTION_OBJECT_TYPE:{code:400,description:ue.INVALID_UPSERT_OPTION_OBJECT_TYPE},MISSING_TABLE_IN_UPSERT_OPTION:{code:400,description:ue.MISSING_TABLE_IN_UPSERT_OPTION},MISSING_COLUMN_IN_UPSERT_OPTION:{code:400,description:ue.MISSING_COLUMN_IN_UPSERT_OPTION},INVALID_RECORD_COLUMN_VALUE_TYPE:{code:400,description:ue.INVALID_RECORD_COLUMN_VALUE_TYPE},INVALID_COLUMN_VALUES_TYPE:{code:400,description:ue.INVALID_COLUMN_VALUES_TYPE},EMPTY_RECORD_COLUMN_VALUES:{code:400,description:ue.EMPTY_RECORD_COLUMN_VALUES},EMPTY_COLUMN_VALUE:{code:400,description:ue.EMPTY_COLUMN_VALUE},MISSING_IDS_OR_COLUMN_VALUES_IN_GET:{code:400,description:ue.MISSING_IDS_OR_COLUMN_VALUES_IN_GET},SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED:{code:400,description:ue.SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED},RECORDS_KEY_NOT_FOUND_GETBYID:{code:400,description:ue.RECORDS_KEY_NOT_FOUND_GETBYID},INVALID_RECORDS_IN_GETBYID:{code:400,description:ue.INVALID_RECORDS_IN_GETBYID},EMPTY_RECORDS_GETBYID:{code:400,description:ue.EMPTY_RECORDS_GETBYID},MISSING_IDS_IN_GETBYID:{code:400,description:ue.MISSING_IDS_IN_GETBYID},INVALID_IDS_IN_GETBYID:{code:400,description:ue.INVALID_IDS_IN_GETBYID},EMPTY_IDS_IN_GETBYID:{code:400,description:ue.EMPTY_IDS_IN_GETBYID},INVALID_SKYFLOWID_TYPE_IN_GETBYID:{code:400,description:ue.INVALID_SKYFLOWID_TYPE_IN_GETBYID},MISSING_TABLE_IN_GETBYID:{code:400,description:ue.MISSING_TABLE_IN_GETBYID},INVALID_TABLE_IN_GETBYID:{code:400,description:ue.INVALID_TABLE_IN_GETBYID},MISSING_REDACTION_IN_GETBYID:{code:400,description:ue.MISSING_REDACTION_IN_GETBYID},INVALID_REDACTION_TYPE_IN_GETBYID:{code:400,description:ue.INVALID_REDACTION_TYPE_IN_GETBYID},EMPTY_SKYFLOWID_IN_GETBYID:{code:400,description:ue.EMPTY_SKYFLOWID_IN_GETBYID},EMPTY_TABLE_IN_GETBYID:{code:400,description:ue.EMPTY_TABLE_IN_GETBYID},EMPTY_REDACTION_TYPE_IN_GETBYID:{code:400,description:ue.EMPTY_REDACTION_TYPE_IN_GETBYID},MISSING_COMPOSABLE_LAYOUT_KEY:{code:400,description:ue.MISSING_COMPOSABLE_LAYOUT_KEY},EMPTY_COMPOSABLE_LAYOUT_ARRAY:{code:400,description:ue.EMPTY_COMPOSABLE_LAYOUT_ARRAY},INVALID_COMPOSABLE_LAYOUT_TYPE:{code:400,description:ue.INVALID_COMPOSABLE_LAYOUT_TYPE},NEGATIVE_VALUES_COMPOSABLE_LAYOUT:{code:400,description:ue.NEGATIVE_VALUES_COMPOSABLE_LAYOUT},MISMATCH_ELEMENT_COUNT_LAYOUT_SUM:{code:400,description:ue.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM},MISSING_COMPOSABLE_CONTAINER_OPTIONS:{code:400,description:ue.MISSING_COMPOSABLE_CONTAINER_OPTIONS},INVALID_COMPOSABLE_CONTAINER_OPTIONS:{code:400,description:ue.INVALID_COMPOSABLE_CONTAINER_OPTIONS},COMPOSABLE_CONTAINER_NOT_MOUNTED:{code:400,description:ue.COMPOSABLE_CONTAINER_NOT_MOUNTED},INVALID_BOOLEAN_OPTIONS:{code:400,description:ue.INVALID_BOOLEAN_OPTIONS},EMPTY_COLLECT_CUSTOM_FORMAT:{code:400,description:ue.EMPTY_COLLECT_CUSTOM_FORMAT},INVALID_INPUT_OPTIONS_FORMAT:{code:400,description:ue.INVALID_INPUT_OPTIONS_FORMAT},INVALID_INPUT_OPTIONS_TRANSLATION:{code:400,description:ue.INVALID_INPUT_OPTIONS_TRANSLATION}},vt=(e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new mt(Ot.RECORDS_KEY_NOT_FOUND,[],!0);const{records:i}=e;if(!i||!Array.isArray(i))throw new mt(Ot.INVALID_RECORDS_IN_INSERT,[],!0);if(0===i.length)throw new mt(Ot.EMPTY_RECORDS_IN_INSERT,[],!0);if(i.forEach(((e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"table"))throw new mt(Ot.MISSING_TABLE_IN_INSERT,[`${t}`],!0);if(!e.table)throw new mt(Ot.EMPTY_TABLE_IN_INSERT,[`${t}`],!0);if(!("string"==typeof e.table||e.table instanceof String))throw new mt(Ot.INVALID_TABLE_IN_INSERT,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"fields"))throw new mt(Ot.MISSING_FIELDS_IN_INSERT,[`${t}`],!0);if(!e.fields)throw new mt(Ot.EMPTY_FIELDS_IN_INSERT,[`${t}`],!0);if("object"!=typeof e.fields||Array.isArray(e.fields))throw new mt(Ot.INVALID_FIELDS_IN_INSERT,[`${t}`],!0)})),t&&t.tokens&&"boolean"!=typeof t.tokens)throw new mt(Ot.INVALID_TOKENS_IN_INSERT,[],!0)},At=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new mt(Ot.RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS,[],!0);const{records:t}=e;if(!t||!Array.isArray(t))throw new mt(Ot.INVALID_RECORDS_IN_ADDITIONAL_FIELDS,[],!0);if(0===t.length)throw new mt(Ot.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 mt(Ot.MISSING_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!e.table)throw new mt(Ot.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 mt(Ot.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 mt(Ot.INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[`${t}`],!0)}if(!("string"==typeof e.table||e.table instanceof String))throw new mt(Ot.INVALID_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"fields"))throw new mt(Ot.MISSING_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!e.fields)throw new mt(Ot.EMPTY_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if("object"!=typeof e.fields||Array.isArray(e.fields))throw new mt(Ot.INVALID_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0)}))},yt=(e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new mt(Ot.RECORDS_KEY_NOT_FOUND_GET);const{records:i}=e;if(!i||!Array.isArray(i))throw new mt(Ot.INVALID_RECORDS_IN_GET,[]);if(0===i.length)throw new mt(Ot.EMPTY_RECORDS_GET);if(t&&Object.prototype.hasOwnProperty.call(t,"tokens")&&"boolean"!=typeof(null==t?void 0:t.tokens))throw new mt(Ot.INVALID_TOKENS_IN_GET);i.forEach(((e,i)=>{var n,o,s;if(0===Object.keys(e).length)throw new mt(Ot.EMPTY_RECORDS_GET);if(0===(null===(n=e.ids)||void 0===n?void 0:n.length))throw new mt(Ot.EMPTY_IDS_IN_GET,[`${i}`]);if(!(null==e.ids||e.ids&&Array.isArray(e.ids)))throw new mt(Ot.INVALID_IDS_IN_GET,[`${i}`]);if(null===(o=e.ids)||void 0===o||o.forEach((e=>{if(!e)throw new mt(Ot.EMPTY_SKYFLOWID_IN_GET,[`${i}`]);if(!("string"==typeof e||e instanceof String))throw new mt(Ot.INVALID_SKYFLOWID_TYPE_IN_GET,[`${i}`])})),!Object.prototype.hasOwnProperty.call(e,"table"))throw new mt(Ot.MISSING_TABLE_IN_GET,[`${i}`]);if(!e.table)throw new mt(Ot.EMPTY_TABLE_IN_GET,[`${i}`]);if(!("string"==typeof e.table||e.table instanceof String))throw new mt(Ot.INVALID_TABLE_IN_GET,[`${i}`]);if(!t||!Object.prototype.hasOwnProperty.call(t,"tokens")||!0!==(null==t?void 0:t.tokens)){if(!Object.prototype.hasOwnProperty.call(e,"redaction"))throw new mt(Ot.MISSING_REDACTION_IN_GET,[`${i}`]);if(!e.redaction)throw new mt(Ot.EMPTY_REDACTION_TYPE_IN_GET,[`${i}`]);if(!Object.values(at).includes(e.redaction))throw new mt(Ot.INVALID_REDACTION_TYPE_IN_GET,[`${i}`])}if(!0===Object.prototype.hasOwnProperty.call(e,"ids")&&!0===Object.prototype.hasOwnProperty.call(e,"columnName"))throw new mt(Ot.SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED,[`${i}`]);if(Object.prototype.hasOwnProperty.call(e,"columnName")){if(!Object.prototype.hasOwnProperty.call(e,"columnName")||!Object.prototype.hasOwnProperty.call(e,"columnValues"))throw new mt(Ot.MISSING_RECORD_COLUMN_VALUE,[`${i}`])}else if(!1===Object.prototype.hasOwnProperty.call(e,"ids")&&!1===Object.prototype.hasOwnProperty.call(e,"columnValues"))throw new mt(Ot.MISSING_IDS_OR_COLUMN_VALUES_IN_GET,[`${i}`]);if(0===(null===(s=e.columnValues)||void 0===s?void 0:s.length))throw new mt(Ot.EMPTY_RECORD_COLUMN_VALUES,[`${i}`]);if(!(null==e.columnValues||e.columnValues&&Array.isArray(e.columnValues)))throw new mt(Ot.INVALID_COLUMN_VALUES_IN_GET,[`${i}`]);if(void 0!==e.columnName&&void 0===e.columnValues)throw new mt(Ot.MISSING_RECORD_COLUMN_VALUE,[`${i}`]);if(void 0===e.columnName&&void 0!==e.columnValues)throw new mt(Ot.MISSING_RECORD_COLUMN_NAME,[`${i}`]);const r=e.columnName;if(null!=r&&"string"!=typeof r)throw new mt(Ot.INVALID_RECORD_COLUMN_VALUE,[`${i}`]);const a=e.columnValues;if(null!=a){if(0===a.length||null===a)throw new mt(Ot.EMPTY_RECORD_COLUMN_VALUES,[`${i}`]);a.forEach((e=>{if(""===e||null===e)throw new mt(Ot.EMPTY_COLUMN_VALUE,[`${i}`]);if("string"!=typeof e)throw new mt(Ot.INVALID_RECORD_COLUMN_VALUE_TYPE,[`${i}`])}))}if(t&&Object.prototype.hasOwnProperty.call(t,"tokens")&&!0===(null==t?void 0:t.tokens)){if(r||a)throw new mt(Ot.TOKENS_GET_COLUMN_NOT_SUPPORTED);if(e.redaction)throw new mt(Ot.REDACTION_WITH_TOKENS_NOT_SUPPORTED)}}))},Lt=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new mt(Ot.RECORDS_KEY_NOT_FOUND_GETBYID);const{records:t}=e;if(!t||!Array.isArray(t))throw new mt(Ot.INVALID_RECORDS_IN_GETBYID,[]);if(0===t.length)throw new mt(Ot.EMPTY_RECORDS_GETBYID);t.forEach(((e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"ids"))throw new mt(Ot.MISSING_IDS_IN_GETBYID,[`${t}`]);if(!e.ids||!Array.isArray(e.ids))throw new mt(Ot.INVALID_IDS_IN_GETBYID,[`${t}`]);if(0===e.ids.length)throw new mt(Ot.EMPTY_IDS_IN_GETBYID,[`${t}`]);if(e.ids.forEach((e=>{if(!e)throw new mt(Ot.EMPTY_SKYFLOWID_IN_GETBYID,[`${t}`]);if(!("string"==typeof e||e instanceof String))throw new mt(Ot.INVALID_SKYFLOWID_TYPE_IN_GETBYID,[`${t}`])})),!Object.prototype.hasOwnProperty.call(e,"table"))throw new mt(Ot.MISSING_TABLE_IN_GETBYID,[`${t}`]);if(!e.table)throw new mt(Ot.EMPTY_TABLE_IN_GETBYID,[`${t}`]);if(!("string"==typeof e.table||e.table instanceof String))throw new mt(Ot.INVALID_TABLE_IN_GETBYID,[`${t}`]);if(!Object.prototype.hasOwnProperty.call(e,"redaction"))throw new mt(Ot.MISSING_REDACTION_IN_GETBYID,[`${t}`]);if(!e.redaction)throw new mt(Ot.EMPTY_REDACTION_TYPE_IN_GETBYID,[`${t}`]);if(!Object.values(at).includes(e.redaction))throw new mt(Ot.INVALID_REDACTION_TYPE_IN_GETBYID,[`${t}`])}))},Rt=(e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new mt(Ot.RECORDS_KEY_NOT_FOUND_DELETE,[],!0);const{records:i}=e;if(!i||!Array.isArray(i))throw new mt(Ot.INVALID_RECORDS_IN_DELETE,[],!0);if(0===i.length)throw new mt(Ot.EMPTY_RECORDS_IN_DELETE,[],!0);i.forEach(((e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"table"))throw new mt(Ot.MISSING_TABLE_IN_DELETE,[`${t}`],!0);if(!e.table)throw new mt(Ot.EMPTY_TABLE_IN_DELETE,[`${t}`],!0);if(!("string"==typeof e.table||e.table instanceof String))throw new mt(Ot.INVALID_TABLE_IN_DELETE,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"id"))throw new mt(Ot.MISSING_ID_IN_DELETE,[`${t}`],!0);if(!e.id)throw new mt(Ot.EMPTY_ID_IN_DELETE,[`${t}`],!0);if(!("string"==typeof e.id||e.id instanceof String))throw new mt(Ot.INVALID_ID_IN_DELETE,[`${t}`],!0)}))},gt=e=>{let t=!0;try{new RegExp(e)}catch(e){t=!1}return t},St=e=>{if(!Object.prototype.hasOwnProperty.call(e,"getBearerToken"))throw new mt(Ot.GET_BEARER_TOKEN_IS_REQUIRED,[],!0)},Dt=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new mt(Ot.MISSING_ELEMENT_TYPE,[],!0);if(!e.type)throw new mt(Ot.EMPTY_ELEMENT_TYPE,[],!0);if(Object.prototype.hasOwnProperty.call(e,"altText")&&ft(Ie.COLLECT_ALT_TEXT_DEPERECATED,_t.WARN,t),Object.prototype.hasOwnProperty.call(e,"skyflowID")&&"string"!=typeof e.skyflowID)throw new mt(Ot.INVALID_SKYFLOWID_IN_COLLECT,[],!0)},Ct=e=>{if(!e||!Array.isArray(e))throw new mt(Ot.INVALID_UPSERT_OPTION_TYPE,[],!0);if(!e.length)throw new mt(Ot.EMPTY_UPSERT_OPTIONS_ARRAY,[],!0);e.forEach(((e,t)=>{if(!e||"object"!=typeof e)throw new mt(Ot.INVALID_UPSERT_OPTION_OBJECT_TYPE,[t],!0);if(!Object.prototype.hasOwnProperty.call(e,"table"))throw new mt(Ot.MISSING_TABLE_IN_UPSERT_OPTION,[t],!0);if(!e.table||"string"!=typeof e.table||!e.table.length)throw new mt(Ot.INVALID_TABLE_IN_UPSERT_OPTION,[t],!0);if(!Object.prototype.hasOwnProperty.call(e,"column"))throw new mt(Ot.MISSING_COLUMN_IN_UPSERT_OPTION,[t],!0);if(!e.column||"string"!=typeof e.column||!e.column.length)throw new mt(Ot.INVALID_COLUMN_IN_UPSERT_OPTION,[t],!0)}))},Pt=e=>"boolean"==typeof e;function bt(e){const t=e.split(":");return t.length>2?(t.pop(),t.pop(),t.join(":")):""}const Mt=(e,t,i)=>{if("string"!=typeof e)return e;if(t===we.CARD_NUMBER){if(e=e&&e.replace(/\s/g,""),!i){const t=((e="")=>{const t=e.replace(/[\s-]/g,"");let i=Ue.DEFAULT;return Object.entries(je).forEach((([e,n])=>{n.regex.test(t)&&(i=e)})),i})(e),i=t!==Ue.DEFAULT&&t===Ue.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 wt(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}`;Je.IFRAME_SECURE_ORGIN=s,Je.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(!Je.IFRAME_SECURE_ORGIN||!Je.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:Je.IFRAME_SECURE_ORGIN,IFRAME_SECURE_SITE:Je.IFRAME_SECURE_SITE}}),e}Je.IFRAME_SECURE_ORGIN=Qe,Je.IFRAME_SECURE_SITE=Ze}}class Ut{constructor(e,t,i,n){this.setAttributess=e=>{tt(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 mt(Ot.INVALID_ELEMENT_SELECTOR,[],!0)}else{if(!(e instanceof HTMLElement))throw new mt(Ot.INVALID_ELEMENT_SELECTOR,[],!0);this.container=e}}catch(e){console.error(e)}tt(this.iframe,{src:nt()}),null===(t=this.container)||void 0===t||t.appendChild(this.iframe)},this.setIframeHeight=e=>{this.iframe.getAttribute("height")!==e&&this.iframe.setAttribute("height",`${e}px`)},this.unmount=()=>{this.iframe.remove()},this.name=`${e}:${i}:${n}`,this.metadata=t,this.iframe=it({name:this.name})}}class kt{}var Yt,xt,Vt,Ft,Gt,Bt,jt,Xt,Wt,$t,zt,Kt,Ht,qt,Jt,Zt,Qt,ei,ti,ii;const ni="Element";class oi extends kt{constructor(e,n,o,s,r=!1,a,l,d,c){var E;super(),this.type=An.COLLECT,Yt.set(this,void 0),xt.set(this,!1),Vt.set(this,void 0),Ft.set(this,void 0),Gt.set(this,{isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:void 0,isRequired:!1}),Bt.set(this,void 0),jt.set(this,new qe),Xt.set(this,void 0),Wt.set(this,new rt),$t.set(this,void 0),zt.set(this,[]),Kt.set(this,!1),Ht.set(this,void 0),qt.set(this,void 0),Jt.set(this,!1),this.getID=()=>t(this,Yt,"f"),this.mount=e=>{var n;if(!e)throw new mt(Ot.EMPTY_ELEMENT_IN_MOUNT,["CollectElement"],!0);const o=(e,n)=>{if(e.name===t(this,$t,"f").name){n(t(this,Bt,"f")),t(this,ii,"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,Vt,"f")[0],["name"]);t(this,Ft,"f").length>1?t(this,Ft,"f").forEach(((e,i)=>{t(this,Xt,"f")&&t(this,Xt,"f")._emit(`${Oe.READY}:${e.elementName}`,Object.assign(Object.assign({},t(this,Vt,"f")[i]),{elementType:e.elementType}))})):t(this,jt,"f")._emit(Oe.READY,Object.assign({},e)),t(this,Wt,"f").off(ve+this.containerId,o),ft(`${Nt(_e.ELEMENT_MOUNTED,ni,Tt(t(this,$t,"f").name))} `,_t.LOG,t(this,Ht,"f").logLevel),t(this,zt,"f").forEach((e=>e())),i(this,zt,[],"f")}};if(t(this,Ft,"f").length>1)t(this,$t,"f").mount(e),t(this,Wt,"f").on(ve+this.containerId,o);else{if(t(this,Jt,"f"))return t(this,$t,"f").mount(e),void t(this,Wt,"f").on(ve+this.containerId,o);null===(n=t(this,Xt,"f"))||void 0===n||n.on(Me,(i=>{(null==i?void 0:i.containerId)===this.containerId&&(t(this,$t,"f").mount(e),t(this,Wt,"f").on(ve+this.containerId,o))}))}},this.unmount=()=>{t(this,$t,"f").unmount()},this.update=e=>{let n=st(e);const o=()=>{t(this,xt,"f")&&(n={rows:[{elements:[Object.assign({},n)]}]}),i(this,Bt,ri(t(this,Bt,"f"),n),"f"),i(this,Ft,ai(t(this,Bt,"f")),"f"),t(this,xt,"f")?t(this,Wt,"f").emit(Re,{name:t(this,$t,"f").name,options:t(this,Ft,"f")[0],isSingleElementAPI:!0}):(t(this,Ft,"f").forEach((e=>{t(this,Wt,"f").emit(Re,{name:e.elementName,options:e,isSingleElementAPI:!0})})),t(this,Wt,"f").emit(Re,{name:t(this,$t,"f").name,options:t(this,Bt,"f"),isSingleElementAPI:!1})),t(this,ii,"f").call(this)};t(this,Kt,"f")?o():t(this,zt,"f").push(o)},Zt.set(this,(e=>{t(this,xt,"f")||t(this,jt,"f").on(Re,(()=>{e(t(this,Ft,"f"))}),!0)})),this.updateElement=e=>{t(this,Wt,"f").emit(Re,{name:e.elementName,options:e,isSingleElementAPI:!0})},Qt.set(this,(()=>{t(this,Vt,"f").forEach(((e,i)=>{if(0===i){t(this,Gt,"f").isEmpty=e.isEmpty,t(this,Gt,"f").isComplete=e.isComplete,t(this,Gt,"f").isValid=e.isValid,t(this,Gt,"f").isFocused=e.isFocused,t(this,Gt,"f").isRequired=e.isRequired,t(this,Gt,"f").value={};const n=t(this,Ft,"f")[i].elementName,o=e.value&&Mt(e.value,e.elementType,t(this,qt,"f"));t(this,xt,"f")?t(this,Gt,"f").value=o:t(this,Gt,"f").value[n]=o}else t(this,Gt,"f").isEmpty=t(this,Gt,"f").isEmpty||e.isEmpty,t(this,Gt,"f").isComplete=t(this,Gt,"f").isComplete&&e.isComplete,t(this,Gt,"f").isValid=t(this,Gt,"f").isValid&&e.isValid,t(this,Gt,"f").isFocused=t(this,Gt,"f").isFocused||e.isFocused,t(this,Gt,"f").isRequired=t(this,Gt,"f").isRequired||e.isRequired,t(this,Gt,"f").value||(t(this,Gt,"f").value={}),t(this,Ft,"f")[i].sensitive||(t(this,Gt,"f").value[t(this,Ft,"f")[i].elementName]=e.value||"")}))})),this.getState=()=>({isEmpty:t(this,Gt,"f").isEmpty,isComplete:t(this,Gt,"f").isComplete,isValid:t(this,Gt,"f").isValid,isFocused:t(this,Gt,"f").isFocused,value:t(this,Gt,"f").value,required:t(this,Gt,"f").isRequired}),this.getOptions=()=>{let e=st(t(this,Bt,"f"));return t(this,xt,"f")?e=e.rows[0].elements[0]:e.rows.forEach((e=>{e.elements.forEach((e=>{delete e.elementName}))})),delete e.elementName,e},ei.set(this,(e=>{t(this,jt,"f").on(Le,(()=>{const i=t(this,Ft,"f").map((e=>e.elementName));t(this,xt,"f")||i.push(t(this,$t,"f").name),e(i)}),!0)})),ti.set(this,(()=>{t(this,Wt,"f").on(ye,(e=>{if(t(this,xt,"f")&&e.event===Oe.READY&&e.name===t(this,$t,"f").name)t(this,jt,"f")._emit(Oe.READY);else{const i=t(this,Ft,"f").length>1;t(this,Ft,"f").forEach(((n,o)=>{var s;if(e.name===n.elementName){let r="";switch(e.event){case Oe.FOCUS:r=Oe.FOCUS;break;case Oe.BLUR:r=Oe.BLUR;break;case Oe.CHANGE:r=Oe.CHANGE;break;case Oe.READY:r=Oe.READY;break;case Oe.SUBMIT:return void(null===(s=t(this,Xt,"f"))||void 0===s||s._emit(Oe.SUBMIT));default:throw new mt(Ot.INVALID_EVENT_TYPE,[],!0)}t(this,Vt,"f")[o].isEmpty=e.value.isEmpty,t(this,Vt,"f")[o].isValid=e.value.isValid,t(this,Vt,"f")[o].isComplete=e.value.isComplete,t(this,Vt,"f")[o].isFocused=e.value.isFocused,t(this,Vt,"f")[o].isRequired=e.value.isRequired,Object.prototype.hasOwnProperty.call(e.value,"value")?t(this,Vt,"f")[o].value=e.value.value:t(this,Vt,"f")[o].value=void 0,r=i?`${r}:${e.name}`:r,t(this,Wt,"f").emit(Oe.HEIGHT+t(this,$t,"f").name,{},(e=>{t(this,$t,"f").setIframeHeight(e.height)})),t(this,Qt,"f").call(this);const a=Object.assign(Object.assign({},t(this,Vt,"f")[o]),{elementType:n.elementType});i&&t(this,Xt,"f")?t(this,Xt,"f")._emit(r,a):t(this,jt,"f")._emit(r,a)}}))}}))})),ii.set(this,(()=>{const{rows:e}=t(this,Bt,"f");e.forEach((e=>{e.elements.forEach((e=>{e.elementType!==Ye.radio.name&&e.elementType!==Ye.checkbox.name&&(e.value=void 0)}))})),i(this,Ft,ai(t(this,Bt,"f")),"f")})),this.containerId=s.containerId,i(this,Yt,e,"f"),i(this,Ht,d,"f"),i(this,Bt,ri(n),"f"),i(this,Ft,ai(n),"f"),i(this,xt,r,"f"),c&&i(this,Xt,c,"f"),i(this,qt,ht[t(this,Ht,"f").env].doesReturnValue,"f"),this.elementType=t(this,xt,"f")?t(this,Ft,"f")[0].elementType:"group",i(this,Vt,[],"f"),t(this,Ft,"f").forEach((e=>{t(this,Vt,"f").push({isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:t(this,qt,"f")?"":void 0,elementType:e.elementType,name:e.elementName,isRequired:!1})})),i(this,$t,new Ut(t(this,Bt,"f").elementName,o,this.containerId,t(this,Ht,"f").logLevel),"f"),t(this,ti,"f").call(this),t(this,ei,"f").call(this,a),t(this,Zt,"f").call(this,l),ft(Nt(_e.CREATED_ELEMENT,ni,Tt(t(this,$t,"f").name)),_t.LOG,t(this,Ht,"f").logLevel),i(this,Jt,s.isMounted,"f"),null===(E=t(this,Xt,"f"))||void 0===E||E.on(Me,(e=>{(null==e?void 0:e.containerId)===this.containerId&&i(this,Jt,!0,"f")})),t(this,Wt,"f").on(Oe.MOUNTED,(e=>{s.type===An.COMPOSABLE?t(this,Ft,"f").forEach((t=>{e.name===t.elementName&&(t.isMounted=!0,i(this,Kt,!0,"f"))})):e.name===t(this,Ft,"f")[0].elementName&&(t(this,Ft,"f")[0].isMounted=!0,i(this,Kt,!0,"f")),t(this,Wt,"f").emit(Oe.HEIGHT+t(this,$t,"f").name,{},(e=>{t(this,$t,"f").setIframeHeight(e.height)}))}))}on(e,i){if(!Object.values(Oe).includes(e))throw new mt(Ot.INVALID_EVENT_LISTENER,[],!0);if(!i)throw new mt(Ot.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof i)throw new mt(Ot.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);t(this,jt,"f").on(e,(e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,i(e)}))}iframeName(){return t(this,$t,"f").name}isMounted(){return t(this,Kt,"f")}isValidElement(){for(let e=0;e<t(this,Ft,"f").length;e+=1){if(!Object.prototype.hasOwnProperty.call(t(this,Ft,"f")[e],"table"))throw new mt(Ot.MISSING_TABLE_IN_COLLECT,[],!0);if(!t(this,Ft,"f")[e].table)throw new mt(Ot.EMPTY_TABLE_IN_COLLECT,[],!0);if(!("string"==typeof t(this,Ft,"f")[e].table||t(this,Ft,"f")[e].table instanceof String))throw new mt(Ot.INVALID_TABLE_IN_COLLECT,[],!0);if(!Object.prototype.hasOwnProperty.call(t(this,Ft,"f")[e],"column"))throw new mt(Ot.MISSING_COLUMN_IN_COLLECT,[],!0);if(!t(this,Ft,"f")[e].column)throw new mt(Ot.EMPTY_COLUMN_IN_COLLECT,[],!0);if(!("string"==typeof t(this,Ft,"f")[e].column||t(this,Ft,"f")[e].column instanceof String))throw new mt(Ot.INVALID_COLUMN_IN_COLLECT,[],!0);if(void 0!==t(this,Ft,"f")[e].skyflowID&&!t(this,Ft,"f")[e].skyflowID)throw new mt(Ot.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[],!0)}return!0}setError(e){t(this,Wt,"f").emit(Ce,{name:bt(t(this,$t,"f").name),isTriggerError:!0,clientErrorText:e})}resetError(){t(this,Wt,"f").emit(Ce,{name:bt(t(this,$t,"f").name),isTriggerError:!1})}setValue(e){t(this,Ht,"f").env!==Et.PROD?t(this,xt,"f")&&t(this,Wt,"f").emit(Re,{name:t(this,$t,"f").name,options:Object.assign(Object.assign({},t(this,Ft,"f")[0]),{value:e}),isSingleElementAPI:!0}):ft(Nt(Ie.UNABLE_TO_SET_VALUE_IN_PROD_ENV,t(this,Ft,"f")[0].elementType),_t.WARN,t(this,Ht,"f").logLevel)}clearValue(){t(this,Ht,"f").env!==Et.PROD?t(this,xt,"f")&&t(this,Wt,"f").emit(Re,{name:t(this,$t,"f").name,options:Object.assign(Object.assign({},t(this,Ft,"f")[0]),{value:""}),isSingleElementAPI:!0}):ft(Nt(Ie.UNABLE_TO_CLEAR_VALUE_IN_PROD_ENV,t(this,Ft,"f")[0].elementType),_t.WARN,t(this,Ht,"f").logLevel)}}function si(e,t,i={}){if("group"!==e&&!Object.prototype.hasOwnProperty.call(Ye,e))throw new mt(Ot.INVALID_ELEMENT_TYPE,[],!0);if(Object.prototype.hasOwnProperty.call(t,"validations")){if(!Array.isArray(t.validations))throw new mt(Ot.INVALID_VALIDATIONS_TYPE,[],!0);t.validations.forEach(((e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new mt(Ot.MISSING_VALIDATION_RULE_TYPE,[`${t}`],!0);if(!Object.values(ut).includes(e.type))throw new mt(Ot.INVALID_VALIDATION_RULE_TYPE,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"params"))throw new mt(Ot.MISSING_VALIDATION_RULE_PARAMS,[`${t}`],!0);if("object"!=typeof e.params||Array.isArray(e.params)||null===e.params)throw new mt(Ot.INVALID_VALIDATION_RULE_PARAMS,[`${t}`],!0);if(e.type===ut.REGEX_MATCH_RULE){if(!Object.prototype.hasOwnProperty.call(e.params,"regex"))throw new mt(Ot.MISSING_REGEX_IN_REGEX_MATCH_RULE,[`${t}`],!0)}else if(e.type===ut.LENGTH_MATCH_RULE&&!Object.prototype.hasOwnProperty.call(e.params,"min")&&!Object.prototype.hasOwnProperty.call(e.params,"max"))throw new mt(Ot.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}=Ye[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===Ye.radio.name||e===Ye.checkbox.name)&&!i.value)throw new Error("Elements radio and checkbox requires value attribute");if(!(e!==Ye.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 ri(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(ue.CANNOT_CHANGE_ELEMENT);si(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({},Ge),c.base),l.classes=d,l.styles=c;const E=(null===(n=null==l?void 0:l.labelStyles)||void 0===n?void 0:n.classes)||{},_=(null===(o=null==l?void 0:l.labelStyles)||void 0===o?void 0:o.styles)||{};i&&function(e,t){Object.values(Be).forEach((i=>{if(e[i]||t[i])switch(i){case Be.BASE:t[i]=Object.assign({},t[i]);break;case Be.FOCUS:t[Be.BASE]=Object.assign(Object.assign({},t[Be.BASE]),{":focus":Object.assign({},t[Be.BASE]&&t[Be.BASE][":focus"])});break;case Be.WEBPACKAUTOFILL:t[Be.BASE]=Object.assign(Object.assign({},t[Be.BASE]),{":-webkit-autofill":Object.assign({},t[Be.BASE]&&t[Be.BASE][":-webkit-autofill"])});break;default:t[i]=Object.assign(Object.assign({},t[Be.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`)}))}))}(E,_),l.labelStyles={labelClasses:E},l.labelStyles.styles=_}))})),t}Yt=new WeakMap,xt=new WeakMap,Vt=new WeakMap,Ft=new WeakMap,Gt=new WeakMap,Bt=new WeakMap,jt=new WeakMap,Xt=new WeakMap,Wt=new WeakMap,$t=new WeakMap,zt=new WeakMap,Kt=new WeakMap,Ht=new WeakMap,qt=new WeakMap,Jt=new WeakMap,Zt=new WeakMap,Qt=new WeakMap,ei=new WeakMap,ti=new WeakMap,ii=new WeakMap;const ai=e=>{const{rows:t}=e,i=[];return t.forEach((e=>{e.elements.forEach((e=>{i.push(e)}))})),i},li=e=>{const t=e.validations;return t&&Array.isArray(t)&&t.length>0&&t.forEach(((e,t)=>{if(e&&e.type===ut.ELEMENT_VALUE_MATCH_RULE){if(e.params&&!Object.prototype.hasOwnProperty.call(e.params,"element"))throw new mt(Ot.MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE,[`${t}`],!0);if(e.params&&(null==e.params.element||!(e.params.element instanceof oi)))throw new mt(Ot.INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE,[`${t}`],!0);e.params&&e.params.element&&e.params.element instanceof oi&&(e.params.element=e.params.element.iframeName())}else if(e&&e.type===ut.REGEX_MATCH_RULE){if(e.params&&e.params.regex&&!gt(e.params.regex))throw new mt(Ot.INVALID_REGEX_IN_REGEX_MATCH_RULE,[`${t}`],!0);e.params&&e.params.regex&&gt(e.params.regex)&&(e.params.regex=e.params.regex.toString())}})),t},di=(e,t,i)=>{let n=Object.assign({required:!1},t);if((Object.prototype.hasOwnProperty.call(n,"format")||Object.prototype.hasOwnProperty.call(n,"translation"))&&(Ke.includes(e)?(ft(Nt(Ie.INPUT_FORMATTING_NOT_SUPPROTED,e),_t.WARN,i),null==n||delete n.format,null==n||delete n.translation):e===Ye.INPUT_FIELD.name&&((e=>{if(e){if(Object.prototype.hasOwnProperty.call(e,"format")&&"string"!=typeof e.format)throw new mt(Ot.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 mt(Ot.INVALID_INPUT_OPTIONS_TRANSLATION,[],!0)}})(t),n=Object.assign(Object.assign({},n),{mask:[n.format,n.translation?n.translation:He]}),null==n||delete n.format,null==n||delete n.translation)),e===Ye.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)===xe&&(e="-"),n=Object.assign(Object.assign({},n),{cardSeperator:e}),null==n||delete n.format,null==n||delete n.translation}else if(e===Ye.EXPIRATION_DATE.name){let e=!1;n.format&&(e=!!(o=n.format.toUpperCase())&&We.includes(o),e||ft(Nt(Ie.INVALID_EXPIRATION_DATE_FORMAT,We.toString()),_t.WARN,i)),n=Object.assign(Object.assign({},n),{format:e?n.format.toUpperCase():Xe}),null==n||delete n.translation}else if(e===Ye.EXPIRATION_YEAR.name){let e=!1;n.format&&(e=(e=>!!e&&$e.includes(e))(n.format.toUpperCase()),e||ft(Nt(Ie.INVALID_EXPIRATION_YEAR_FORMAT,$e.toString()),_t.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")&&!Pt(n.enableCardIcon))throw new mt(Ot.INVALID_BOOLEAN_OPTIONS,["enableCardIcon"],!0);if(Object.prototype.hasOwnProperty.call(n,"enableCopy")&&!Pt(n.enableCopy))throw new mt(Ot.INVALID_BOOLEAN_OPTIONS,["enableCopy"],!0);if(Object.prototype.hasOwnProperty.call(n,"required")&&!Pt(n.required))throw new mt(Ot.INVALID_BOOLEAN_OPTIONS,["required"],!0);return n};function ci(){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 Ei{}var _i,ui,Ii,hi,pi,fi,Ni,Ti,mi,Oi,vi,Ai;const yi="CollectContainer";class Li extends Ei{constructor(e,n,o,s){super(),_i.set(this,void 0),ui.set(this,{}),Ii.set(this,void 0),hi.set(this,void 0),pi.set(this,void 0),this.type=An.COLLECT,fi.set(this,void 0),Ni.set(this,!1),this.create=(e,i={required:!1})=>{Dt(e,t(this,hi,"f").logLevel);const n=li(e),o=di(e.type,i,t(this,hi,"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,Ti,"f").call(this,s,!0)},Ti.set(this,((e,i=!1)=>{const n=[],o=st(e);if(o.rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;si(i,t),t.sensitive=t.sensitive||Ye[i].sensitive,t.replacePattern=t.replacePattern||Ye[i].replacePattern,t.mask=t.mask||Ye[i].mask,t.isMounted=!1,t.elementType!==Ye.radio.name&&t.elementType!==Ye.checkbox.name||(t.elementName=`${t.elementName}:${btoa(t.value)}`),t.elementName=`${pe}:${t.elementType}:${btoa(ci())}`,t.label=e.label,t.skyflowID=e.skyflowID,n.push(t)}))})),o.elementName=i?n[0].elementName:`${pe}:group:${btoa(o.name)}`,i&&!t(this,ui,"f")[n[0].elementName]&&t(this,Ai,"f").call(this,n[0].name))throw new mt(Ot.UNIQUE_ELEMENT_NAME,[`${n[0].name}`],!0);let s=t(this,ui,"f")[o.elementName];if(s)i?s.update(n[0]):s.update(o);else{const e=ci();s=new oi(e,o,t(this,Ii,"f"),{containerId:t(this,_i,"f"),isMounted:t(this,Ni,"f"),type:this.type},i,t(this,Oi,"f"),t(this,vi,"f"),t(this,hi,"f"),t(this,fi,"f")),t(this,ui,"f")[o.elementName]=s,t(this,pi,"f")[e]=s}return i||n.forEach((e=>{const i=e.elementName;t(this,ui,"f")[i]?t(this,ui,"f")[i].update(e):t(this,ui,"f")[i]=this.create(e.elementType,s)})),s})),mi.set(this,(e=>{Object.keys(t(this,ui,"f")).forEach((i=>{i===e&&delete t(this,ui,"f")[i]}))})),Oi.set(this,(e=>{e.forEach((e=>{t(this,mi,"f").call(this,e)}))})),vi.set(this,(e=>{e.forEach((e=>{t(this,ui,"f")[e.elementName]&&t(this,ui,"f")[e.elementName].update(e)}))})),Ai.set(this,(e=>{const i=Object.keys(t(this,ui,"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{St(t(this,Ii,"f").clientJSON.config);if(Object.values(t(this,ui,"f")).forEach((e=>{if(!e.isMounted())throw new mt(Ot.ELEMENTS_NOT_MOUNTED,[],!0);e.isValidElement()})),Object.prototype.hasOwnProperty.call(e,"tokens")&&!Pt(e.tokens))throw new mt(Ot.INVALID_TOKENS_IN_COLLECT,[],!0);(null==e?void 0:e.additionalFields)&&At(e.additionalFields),(null==e?void 0:e.upsert)&&Ct(null==e?void 0:e.upsert),Ee.emit(Ae+t(this,_i,"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)?(ft(`${JSON.stringify(null==e?void 0:e.error)}`,_t.ERROR,t(this,hi,"f").logLevel),n(null==e?void 0:e.error)):(ft(Nt(_e.COLLECT_SUBMIT_SUCCESS,yi),_t.LOG,t(this,hi,"f").logLevel),i(e))})),ft(Nt(_e.EMIT_EVENT,yi,Ae),_t.LOG,t(this,hi,"f").logLevel)}catch(e){ft(`${e.message}`,_t.ERROR,t(this,hi,"f").logLevel),n(e)}})),i(this,_i,ci(),"f"),i(this,Ii,n,"f"),i(this,pi,o,"f"),i(this,hi,s,"f"),i(this,fi,new qe,"f");const r=it({name:`${he}:${t(this,_i,"f")}:${t(this,hi,"f").logLevel}`});tt(r,{src:nt()}),ot(r,Object.assign({},Fe)),ft(Nt(_e.CREATE_COLLECT_CONTAINER,yi),_t.LOG,t(this,hi,"f").logLevel);const a=(e,o)=>{e.name===he+t(this,_i,"f")&&(o(Object.assign(Object.assign({},n),{clientJSON:Object.assign(Object.assign({},n.clientJSON),{config:Object.assign({},n.clientJSON.config)}),context:s})),i(this,Ni,!0,"f"),t(this,fi,"f")._emit(Me,{containerId:t(this,_i,"f")}),Ee.target(Je.IFRAME_SECURE_ORGIN).off(ve+t(this,_i,"f"),a))};Ee.target(Je.IFRAME_SECURE_ORGIN).on(ve+t(this,_i,"f"),a),document.body.append(r)}}_i=new WeakMap,ui=new WeakMap,Ii=new WeakMap,hi=new WeakMap,pi=new WeakMap,fi=new WeakMap,Ni=new WeakMap,Ti=new WeakMap,mi=new WeakMap,Oi=new WeakMap,vi=new WeakMap,Ai=new WeakMap;var Ri=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},gi=function(e){return e};var Si,Di,Ci,Pi,bi,Mi,wi,Ui,ki,Yi,xi,Vi,Fi,Gi,Bi,ji,Xi,Wi,$i,zi,Ki,Hi,qi,Ji=o((function(e){return e&&e.length?Ri(e,gi):0}));class Zi{constructor(e,n){Si.set(this,void 0),Di.set(this,void 0),this.type=An.COMPOSABLE,Ci.set(this,!1),Pi.set(this,!1),this.update=e=>{i(this,Pi,!0,"f"),t(this,Ci,"f")?(t(this,Di,"f")._emit(Pe,{elementName:t(this,Si,"f"),elementOptions:e}),i(this,Pi,!1,"f")):t(this,Pi,"f")&&t(this,Di,"f").on(`${dt.READY}:${t(this,Si,"f")}`,(()=>{t(this,Di,"f")._emit(Pe,{elementName:t(this,Si,"f"),elementOptions:e}),i(this,Ci,!0,"f"),i(this,Pi,!1,"f")}))},i(this,Si,e,"f"),i(this,Di,n,"f"),t(this,Di,"f").on(`${dt.READY}:${t(this,Si,"f")}`,(()=>{i(this,Ci,!0,"f")}))}on(e,i){if(!Object.values(Oe).includes(e))throw new mt(Ot.INVALID_EVENT_LISTENER,[],!0);if(!i)throw new mt(Ot.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof i)throw new mt(Ot.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);t(this,Di,"f").on(`${e}:${t(this,Si,"f")}`,(e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,i(e)}))}}Si=new WeakMap,Di=new WeakMap,Ci=new WeakMap,Pi=new WeakMap;const Qi="CollectContainer";class en extends Ei{constructor(e,n,o,a){super(),bi.set(this,void 0),Mi.set(this,{}),wi.set(this,void 0),Ui.set(this,{rows:[]}),ki.set(this,[]),Yi.set(this,void 0),xi.set(this,void 0),Vi.set(this,void 0),Fi.set(this,!1),Gi.set(this,void 0),Bi.set(this,void 0),this.type=An.COMPOSABLE,ji.set(this,!1),Xi.set(this,{}),this.create=(e,i={required:!1})=>{Dt(e,t(this,Yi,"f").logLevel);const n=li(e),o=di(e.type,i,t(this,Yi,"f").logLevel),s=`${pe}:${e.type}:${btoa(ci())}`;return t(this,ki,"f").push(Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column},e),o),{validations:n,elementName:s})),new Zi(s,t(this,Vi,"f"))},Wi.set(this,((e,n=!1)=>{const o=[];if(i(this,Xi,st(e),"f"),t(this,Xi,"f").rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;si(i,t),t.sensitive=t.sensitive||Ye[i].sensitive,t.replacePattern=t.replacePattern||Ye[i].replacePattern,t.mask=t.mask||Ye[i].mask,t.isMounted=!1,t.label=e.label,t.skyflowID=e.skyflowID,o.push(t)}))})),t(this,Xi,"f").elementName=n?o[0].elementName:`${pe}:group:${btoa(t(this,Xi,"f").name)}`,n&&!t(this,Mi,"f")[o[0].elementName]&&t(this,Hi,"f").call(this,o[0].name))throw new mt(Ot.UNIQUE_ELEMENT_NAME,[`${o[0].name}`],!0);let s=t(this,Mi,"f")[t(this,Xi,"f").elementName];if(s)n?s.update(o[0]):s.update(t(this,Xi,"f"));else{const e=ci();s=new oi(e,t(this,Xi,"f"),t(this,wi,"f"),{containerId:t(this,bi,"f"),isMounted:t(this,ji,"f"),type:this.type},!0,t(this,zi,"f"),t(this,Ki,"f"),t(this,Yi,"f"),t(this,Vi,"f")),t(this,Mi,"f")[t(this,Xi,"f").elementName]=s,t(this,xi,"f")[e]=s}return s})),$i.set(this,(e=>{Object.keys(t(this,Mi,"f")).forEach((i=>{i===e&&delete t(this,Mi,"f")[i]}))})),zi.set(this,(e=>{e.forEach((e=>{t(this,$i,"f").call(this,e)}))})),Ki.set(this,(e=>{e.forEach((e=>{t(this,Mi,"f")[e.elementName]&&t(this,Mi,"f")[e.elementName].update(e)}))})),Hi.set(this,(e=>{const i=Object.keys(t(this,Mi,"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(Oe).includes(e))throw new mt(Ot.INVALID_EVENT_LISTENER,[],!0);if(!i)throw new mt(Ot.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof i)throw new mt(Ot.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);t(this,Vi,"f").on(Oe.SUBMIT,(()=>{i()}))},this.mount=e=>{if(!e)throw new mt(Ot.EMPTY_ELEMENT_IN_MOUNT,["CollectElement"],!0);const{layout:n}=t(this,Gi,"f");if(Ji(n)!==t(this,ki,"f").length)throw new mt(Ot.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM,[],!0);let o=0;if(n.forEach(((e,i)=>{t(this,Ui,"f").rows=[...t(this,Ui,"f").rows,{elements:[]}];for(let n=0;n<e;n++)t(this,Ui,"f").rows[i].elements.push(t(this,ki,"f")[o]),o++})),t(this,Gi,"f").styles&&(t(this,Ui,"f").styles=Object.assign({},t(this,Gi,"f").styles)),t(this,Gi,"f").errorTextStyles&&(t(this,Ui,"f").errorTextStyles=Object.assign({},t(this,Gi,"f").errorTextStyles)),t(this,ji,"f"))return i(this,Bi,t(this,Wi,"f").call(this,t(this,Ui,"f"),!1),"f"),t(this,Bi,"f").mount(e),void i(this,Fi,!0,"f");t(this,Vi,"f").on(be+t(this,bi,"f"),(()=>{i(this,Bi,t(this,Wi,"f").call(this,t(this,Ui,"f"),!1),"f"),t(this,Bi,"f").mount(e),i(this,Fi,!0,"f")}))},this.unmount=()=>{t(this,Bi,"f").unmount()},this.collect=(e={tokens:!0})=>new Promise(((i,n)=>{try{if(St(t(this,wi,"f").clientJSON.config),!t(this,Fi,"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}ai(t(this,Xi,"f")).forEach((e=>{if(!(null==e?void 0:e.isMounted))throw new mt(Ot.ELEMENTS_NOT_MOUNTED,[],!0)}));if(Object.values(t(this,Mi,"f")).forEach((e=>{e.isValidElement()})),e&&e.tokens&&"boolean"!=typeof e.tokens)throw new mt(Ot.INVALID_TOKENS_IN_COLLECT,[],!0);(null==e?void 0:e.additionalFields)&&At(e.additionalFields),(null==e?void 0:e.upsert)&&Ct(null==e?void 0:e.upsert),Ee.emit(Ae+t(this,bi,"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)?(ft(`${JSON.stringify(null==e?void 0:e.error)}`,_t.ERROR,t(this,Yi,"f").logLevel),n(null==e?void 0:e.error)):(ft(Nt(_e.COLLECT_SUBMIT_SUCCESS,Qi),_t.LOG,t(this,Yi,"f").logLevel),i(e))})),ft(Nt(_e.EMIT_EVENT,Qi,Ae),_t.LOG,t(this,Yi,"f").logLevel)}catch(e){ft(`${e.message}`,_t.ERROR,t(this,Yi,"f").logLevel),n(e)}})),qi.set(this,(()=>{t(this,Vi,"f").on(Pe,(e=>{let i;const n=t(this,ki,"f").map(((t,n)=>t.elementName===e.elementName?(i=n,Object.assign({elementName:t.elementName},e.elementOptions)):t));t(this,Bi,"f")&&t(this,Bi,"f").updateElement(Object.assign({},n[i]))}))})),i(this,bi,ci(),"f"),i(this,wi,n,"f"),i(this,xi,o,"f"),i(this,Yi,a,"f"),i(this,Gi,e,"f"),i(this,Vi,new qe,"f");const l=it({name:`${he}:${t(this,bi,"f")}:${t(this,Yi,"f").logLevel}`});tt(l,{src:nt()}),ot(l,Object.assign({},Fe)),ft(Nt(_e.CREATE_COLLECT_CONTAINER,Qi),_t.LOG,t(this,Yi,"f").logLevel);const d=(e,o)=>{e.name===he+t(this,bi,"f")&&(o(Object.assign(Object.assign({},n),{clientJSON:Object.assign(Object.assign({},n.clientJSON),{config:Object.assign({},n.clientJSON.config)}),context:a})),i(this,ji,!0,"f"),t(this,Vi,"f")._emit(be+t(this,bi,"f"),{containerId:t(this,bi,"f")}),Ee.target(Je.IFRAME_SECURE_ORGIN).off(ve+t(this,bi,"f"),d))};Ee.target(Je.IFRAME_SECURE_ORGIN).on(ve+t(this,bi,"f"),d),document.body.append(l),t(this,qi,"f").call(this)}}var tn,nn,on,sn;bi=new WeakMap,Mi=new WeakMap,wi=new WeakMap,Ui=new WeakMap,ki=new WeakMap,Yi=new WeakMap,xi=new WeakMap,Vi=new WeakMap,Fi=new WeakMap,Gi=new WeakMap,Bi=new WeakMap,ji=new WeakMap,Xi=new WeakMap,Wi=new WeakMap,$i=new WeakMap,zi=new WeakMap,Ki=new WeakMap,Hi=new WeakMap,qi=new WeakMap;const rn="SkyflowContainer";class an{constructor(e,n){var o,s;tn.set(this,void 0),nn.set(this,void 0),on.set(this,!1),sn.set(this,void 0),i(this,nn,e,"f"),i(this,tn,(null===(s=null===(o=t(this,nn,"f").toJSON())||void 0===o?void 0:o.metaData)||void 0===s?void 0:s.uuid)||"","f"),i(this,sn,n,"f");const r=it({name:`skyflow_controller:${t(this,tn,"f")}`});tt(r,{src:nt()}),ot(r,Object.assign({},Fe)),document.body.append(r),Ee.target(Je.IFRAME_SECURE_ORGIN).on(Se+t(this,tn,"f"),((e,o)=>{ft(Nt(_e.CAPTURE_PUREJS_FRAME,rn),_t.LOG,t(this,sn,"f").logLevel),o({client:t(this,nn,"f"),context:n}),i(this,on,!0,"f")})),ft(Nt(_e.PUREJS_CONTROLLER_INITIALIZED,rn),_t.LOG,t(this,sn,"f").logLevel)}insert(e,i){return t(this,on,"f")?new Promise(((n,o)=>{St(t(this,nn,"f").config);try{ft(Nt(_e.VALIDATE_RECORDS,rn),_t.LOG,t(this,sn,"f").logLevel),(null==(i=i?Object.assign(Object.assign({},i),{tokens:void 0===(null==i?void 0:i.tokens)||i.tokens}):{tokens:!0})?void 0:i.upsert)&&Ct(i.upsert),vt(e,i),Ee.emit(ge+t(this,tn,"f"),{type:fe,records:e,options:i},(e=>{e.error?(ft(`${JSON.stringify(e.error)}`,_t.ERROR,t(this,sn,"f").logLevel),o(e.error)):n(e)})),ft(Nt(_e.EMIT_PURE_JS_REQUEST,rn,fe),_t.LOG,t(this,sn,"f").logLevel)}catch(e){ft(e.message,_t.ERROR,t(this,sn,"f").logLevel),o(e)}})):new Promise(((n,o)=>{try{St(t(this,nn,"f").config),ft(Nt(_e.VALIDATE_RECORDS,rn),_t.LOG,t(this,sn,"f").logLevel),(null==(i=i?Object.assign(Object.assign({},i),{tokens:void 0===(null==i?void 0:i.tokens)||i.tokens}):{tokens:!0})?void 0:i.upsert)&&Ct(i.upsert),vt(e,i),Ee.target(Je.IFRAME_SECURE_ORGIN).on(Se+t(this,tn,"f"),(()=>{Ee.emit(ge+t(this,tn,"f"),{type:fe,records:e,options:i},(e=>{e.error?(ft(`${JSON.stringify(e.error)}`,_t.ERROR,t(this,sn,"f").logLevel),o(e.error)):n(e)}))})),ft(Nt(_e.EMIT_PURE_JS_REQUEST,rn,fe),_t.LOG,t(this,sn,"f").logLevel)}catch(e){ft(e.message,_t.ERROR,t(this,sn,"f").logLevel),o(e)}}))}getById(e){return t(this,on,"f")?new Promise(((i,n)=>{St(t(this,nn,"f").config);try{ft(Nt(_e.VALIDATE_GET_BY_ID_INPUT,rn),_t.LOG,t(this,sn,"f").logLevel),Lt(e),ft(Nt(_e.EMIT_PURE_JS_REQUEST,rn,Ne),_t.LOG,t(this,sn,"f").logLevel)}catch(e){ft(e.message,_t.ERROR,t(this,sn,"f").logLevel),n(e)}})):new Promise(((i,n)=>{try{St(t(this,nn,"f").config),ft(Nt(_e.VALIDATE_GET_BY_ID_INPUT,rn),_t.LOG,t(this,sn,"f").logLevel),Lt(e),ft(Nt(_e.EMIT_PURE_JS_REQUEST,rn,Ne),_t.LOG,t(this,sn,"f").logLevel)}catch(e){ft(e.message,_t.ERROR,t(this,sn,"f").logLevel),n(e)}}))}get(e,i){return t(this,on,"f")?new Promise(((n,o)=>{St(t(this,nn,"f").config);try{ft(Nt(_e.VALIDATE_GET_INPUT,rn),_t.LOG,t(this,sn,"f").logLevel),yt(e,i),ft(Nt(_e.EMIT_PURE_JS_REQUEST,rn,Te),_t.LOG,t(this,sn,"f").logLevel)}catch(e){ft(e.message,_t.ERROR,t(this,sn,"f").logLevel),o(e)}})):new Promise(((n,o)=>{try{St(t(this,nn,"f").config),ft(Nt(_e.VALIDATE_GET_INPUT,rn),_t.LOG,t(this,sn,"f").logLevel),yt(e,i),ft(Nt(_e.EMIT_PURE_JS_REQUEST,rn,Te),_t.LOG,t(this,sn,"f").logLevel)}catch(e){ft(e.message,_t.ERROR,t(this,sn,"f").logLevel),o(e)}}))}delete(e,i){return t(this,on,"f")?new Promise(((n,o)=>{St(t(this,nn,"f").config);try{ft(Nt(_e.VALIDATE_DELETE_INPUT,rn),_t.LOG,t(this,sn,"f").logLevel),Rt(e),Ee.emit(ge+t(this,tn,"f"),{type:me,records:e,options:i},(e=>{e.error?(ft(`${JSON.stringify(e.error)}`,_t.ERROR,t(this,sn,"f").logLevel),o(e.error)):n(e)})),ft(Nt(_e.EMIT_PURE_JS_REQUEST,rn,me),_t.LOG,t(this,sn,"f").logLevel)}catch(e){ft(e.message,_t.ERROR,t(this,sn,"f").logLevel),o(e)}})):new Promise(((n,o)=>{try{St(t(this,nn,"f").config),ft(Nt(_e.VALIDATE_RECORDS,rn),_t.LOG,t(this,sn,"f").logLevel),Rt(e),Ee.target(Je.IFRAME_SECURE_ORGIN).on(Se+t(this,tn,"f"),(()=>{Ee.emit(ge+t(this,tn,"f"),{type:me,records:e,options:i},(e=>{e.error?(ft(`${JSON.stringify(e.error)}`,_t.ERROR,t(this,sn,"f").logLevel),o(e.error)):n(e)}))})),ft(Nt(_e.EMIT_PURE_JS_REQUEST,rn,me),_t.LOG,t(this,sn,"f").logLevel)}catch(e){ft(e.message,_t.ERROR,t(this,sn,"f").logLevel),o(e)}}))}}function ln(e){this.message=e}tn=new WeakMap,nn=new WeakMap,on=new WeakMap,sn=new WeakMap,ln.prototype=new Error,ln.prototype.name="InvalidCharacterError";var dn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new ln("'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 cn(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(dn(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 dn(t)}}function En(e){this.message=e}En.prototype=new Error,En.prototype.name="InvalidTokenError";const _n=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 En("Invalid token specified");var i=!0===(t=t||{}).header?0:1;try{return JSON.parse(cn(e.split(".")[i]))}catch(e){throw new En("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 un,In,hn,pn,fn,Nn,Tn,mn,On,vn,An,yn={name:"skyflow-js",preferGlobal:!0,analyze:!1,version:"1.30.1",author:"Skyflow",description:"Skyflow JavaScript SDK"};class Ln{constructor(e,n){un.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,E,_;let u=null,I=null;return/Windows/.test(e)?(u="Windows",I=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)?(u="Android",I=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)?(u="iOS",I=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)?(u="Mac OS X",I=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)&&(u="Linux",I=null!==(_=null===(E=/Linux( \w+)*?\/([\w.]+)/.exec(e))||void 0===E?void 0:E[2])&&void 0!==_?_:null),{os:u,version:I}}(i.userAgent),E=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 _;return{sdk_name_version:d,sdk_client_device_model:(_=i.userAgent,/(ipad|tablet)/gi.test(_)?"tablet":/Mobile|iP(hone|od)|Android|BlackBerry|IEMobile/.test(_)?"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=E.browserName)&&void 0!==r?r:""} ${null!==(a=E.browserVersion)&&void 0!==a?a:""}`}}(yn,t(this,un,"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(ze.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(ze.FORMURLENCODED))||(null===(a=null===(r=e.headers)||void 0===r?void 0:r["content-type"])||void 0===a?void 0:a.includes(ze.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 mt({code:l.status,description:i},[],!0))}else a&&a.includes("text/plain")?n(new mt({code:l.status,description:d?`${l.response} - requestId: ${d}`:l.response},[],!0)):n(new mt({code:l.status,description:d?`${ue.ERROR_OCCURED} - requestId: ${d}`:ue.ERROR_OCCURED},[],!0));a&&a.includes("application/json")&&i(JSON.parse(l.response)),i(l.response)},l.onerror=()=>{n(new mt(Ot.NETWORK_ERROR,[],!0))}}else n(new mt(Ot.CONNECTION_ERROR,[],!0))})),this.config=e,i(this,un,n,"f")}toJSON(){return{config:this.config,metaData:t(this,un,"f")}}static fromJSON(e){return new Ln(e.config,e.metaData)}}un=new WeakMap,function(e){e.COLLECT="COLLECT",e.COMPOSABLE="COMPOSABLE"}(An||(An={}));const Rn="Skyflow";class gn{constructor(e){var n,o;In.set(this,void 0),hn.set(this,ci()),pn.set(this,{uuid:t(this,hn,"f"),clientDomain:window.location.origin}),fn.set(this,void 0),Nn.set(this,""),Tn.set(this,void 0),mn.set(this,void 0),On.set(this,void 0),vn.set(this,void 0);const s=localStorage.getItem("sdk_version")||"";t(this,pn,"f").sdkVersion=s,i(this,In,new Ln(Object.assign({},e),t(this,pn,"f")),"f"),i(this,mn,(null===(n=null==e?void 0:e.options)||void 0===n?void 0:n.logLevel)||ct.ERROR,"f"),i(this,On,(null===(o=null==e?void 0:e.options)||void 0===o?void 0:o.env)||Et.PROD,"f"),i(this,vn,{},"f"),i(this,fn,new an(t(this,In,"f"),{logLevel:t(this,mn,"f"),env:t(this,On,"f")}),"f");Ee.target(Je.IFRAME_SECURE_ORGIN).on(De+t(this,hn,"f"),((e,n)=>{ft(Nt(_e.CAPTURED_BEARER_TOKEN_EVENT,Rn),_t.LOG,t(this,mn,"f")),!t(this,In,"f").config.getBearerToken||t(this,Nn,"f")&&_n(t(this,Nn,"f"))?(ft(Nt(_e.REUSE_BEARER_TOKEN,Rn),_t.LOG,t(this,mn,"f")),n({authToken:t(this,Nn,"f")})):t(this,In,"f").config.getBearerToken().then((e=>{_n(e)?(ft(Nt(_e.BEARER_TOKEN_RESOLVED,Rn),_t.LOG,t(this,mn,"f")),i(this,Nn,e,"f"),n({authToken:t(this,Nn,"f")})):(ft(ue.INVALID_BEARER_TOKEN,_t.ERROR,t(this,mn,"f")),n({error:ue.INVALID_BEARER_TOKEN}))})).catch((e=>{ft(ue.BEARER_TOKEN_REJECTED,_t.ERROR,t(this,mn,"f")),n({error:e})}))})),ft(Nt(_e.BEARER_TOKEN_LISTENER,Rn),_t.LOG,t(this,mn,"f")),ft(Nt(_e.CURRENT_ENV,Rn,t(this,On,"f")),_t.LOG,t(this,mn,"f")),ft(Nt(_e.CURRENT_LOG_LEVEL,Rn,t(this,mn,"f")),_t.LOG,t(this,mn,"f"))}static init(e){var t;const i=(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||ct.ERROR;wt(e),ft(Nt(_e.INITIALIZE_CLIENT,Rn),_t.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 gn(n);return ft(Nt(_e.CLIENT_INITIALIZED,Rn),_t.LOG,i),s}container(e,i){switch(e){case An.COLLECT:{const n=new Li(i,Object.assign(Object.assign({},t(this,pn,"f")),{clientJSON:t(this,In,"f").toJSON(),containerType:e}),t(this,vn,"f"),{logLevel:t(this,mn,"f"),env:t(this,On,"f")});return ft(Nt(_e.COLLECT_CONTAINER_CREATED,Rn),_t.LOG,t(this,mn,"f")),n}case An.COMPOSABLE:{(e=>{if(!e)throw new mt(Ot.MISSING_COMPOSABLE_CONTAINER_OPTIONS,[],!0);if("object"!=typeof e)throw new mt(Ot.INVALID_COMPOSABLE_CONTAINER_OPTIONS,[],!0);if(!Object.prototype.hasOwnProperty.call(e,"layout"))throw new mt(Ot.MISSING_COMPOSABLE_LAYOUT_KEY,[],!0);if(!e.layout)throw new mt(Ot.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(!Array.isArray(e.layout))throw new mt(Ot.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(0===e.layout.length)throw new mt(Ot.EMPTY_COMPOSABLE_LAYOUT_ARRAY,[],!0);e.layout.forEach((e=>{if("number"!=typeof e)throw new mt(Ot.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(e<0)throw new mt(Ot.NEGATIVE_VALUES_COMPOSABLE_LAYOUT,[],!0)}))})(i);const n=new en(i,Object.assign(Object.assign({},t(this,pn,"f")),{clientJSON:t(this,In,"f").toJSON(),containerType:e}),t(this,vn,"f"),{logLevel:t(this,mn,"f"),env:t(this,On,"f")});return ft(Nt(_e.COLLECT_CONTAINER_CREATED,Rn),_t.LOG,t(this,mn,"f")),n}default:if(!e)throw new mt(Ot.EMPTY_CONTAINER_TYPE,[],!0);throw new mt(Ot.INVALID_CONTAINER_TYPE,[],!0)}}insert(e,i){return ft(Nt(_e.INSERT_TRIGGERED,Rn),_t.LOG,t(this,mn,"f")),t(this,fn,"f").insert(e,i)}getById(e){return ft(Ie.GET_BY_ID_DEPRECATED,_t.WARN,t(this,mn,"f")),ft(Nt(_e.GET_BY_ID_TRIGGERED,Rn),_t.LOG,t(this,mn,"f")),t(this,fn,"f").getById(e)}get(e,i){return ft(Nt(_e.GET_TRIGGERED,Rn),_t.LOG,t(this,mn,"f")),t(this,fn,"f").get(e,i)}delete(e,i){return ft(Nt(_e.DELETE_TRIGGERED,Rn),_t.LOG,t(this,mn,"f")),t(this,fn,"f").delete(e,i)}static get ContainerType(){return An}static get ElementType(){return we}static get RedactionType(){return at}static get RequestMethod(){return lt}static get LogLevel(){return ct}static get EventName(){return dt}static get Env(){return Et}static get ValidationRuleType(){return ut}}In=new WeakMap,hn=new WeakMap,pn=new WeakMap,fn=new WeakMap,Nn=new WeakMap,Tn=new WeakMap,mn=new WeakMap,On=new WeakMap,vn=new WeakMap;class Sn{constructor(e){this.loadFunction=e,this.loadScript()}get loader(){return this.loadingPromise||(this.loadingPromise=this.loadScript()),this.loadingPromise}loadScript(){return e(this,void 0,void 0,(function*(){return this.loadingPromise||(this.loadingPromise=new Promise(((e,t)=>{this.loadFunction().then((t=>{t&&e(t)}),(()=>{t()})).catch((()=>{}))}))),this.loadingPromise}))}}class Dn extends D{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()}))}}class Cn extends D{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 Dn(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 Pn extends Cn{constructor(t,i,n){super("div",Object.assign(Object.assign({},n),{id:"payrails-apple-pay-button"})),this.sdkConfig=t,this.execution=i,this.options=n,this.appleButton=null,this.paymentExecutor=new A(t,i),this.loadScript=new Sn((()=>e(this,void 0,void 0,(function*(){const t=document.createElement("script");return t.src="https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js",new Promise(((i,n)=>{t.onload=()=>e(this,void 0,void 0,(function*(){var e,t,n;(yield this.isApplePayAvailable())?(null===(n=null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onApplePayAvailable)||void 0===n||n.call(t),i(!0)):i(!1)})),t.onerror=()=>{n()},document.body.appendChild(t)}))}))))}mount(t){super.mount(t),(()=>{e(this,void 0,void 0,(function*(){try{yield this.loadScript.loader,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()}isApplePayAvailable(){return e(this,void 0,void 0,(function*(){if(!(null===window||void 0===window?void 0:window.ApplePaySession))return!1;return yield ApplePaySession.canMakePayments()}))}mountApplePayButton(){var t,i,n,o,s;return e(this,void 0,void 0,(function*(){if(null===window||void 0===window?void 0:window.ApplePaySession)try{if(!this.isApplePayAvailable())return;null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onApplePayAvailable)||void 0===i||i.call(t);const e=(null===(n=this.options.styles)||void 0===n?void 0:n.type)||"buy",r=(null===(o=this.options.styles)||void 0===o?void 0:o.style)||"black";this.element.innerHTML=`<apple-pay-button buttonstyle="${r}" type="${e}" locale="en-GB"></apple-pay-button>`,null===(s=this.storeInstrumentCheckbox)||void 0===s||s.mount(this.selector);const a=this.element.querySelector("apple-pay-button");null==a||a.setAttribute("style","width: 100%;"),null==a||a.addEventListener("click",(()=>{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.onpaymentauthorized=t=>e(this,void 0,void 0,(function*(){var e,i,n,o,s,a,l,d,c,E,_,u;try{const E=yield this.onApplePayAuthorized(t.payment.token);if("authorizeSuccessful"===(null===(e=null==E?void 0:E.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(E))}catch(e){r.completePayment(ApplePaySession.STATUS_FAILURE),(null===(_=null===(E=this.options)||void 0===E?void 0:E.events)||void 0===_?void 0:_.onAuthorizeFailed)&&(null===(u=this.options)||void 0===u||u.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:"applePay",integrationType:"api",paymentInstrumentData:{paymentToken:JSON.stringify(e)},amount:this.sdkConfig.amount,storeInstrument:this.shouldStoreInstrument}];return yield this.paymentExecutor.pay(i)}))}}const{CARD_NUMBER:bn,CVV:Mn,CARDHOLDER_NAME:wn,EXPIRATION_MONTH:Un,EXPIRATION_YEAR:kn}=exports.ElementType,Yn={base:{border:"none",padding:"10px 16px",color:"#1d1d1d",backgroundColor:"#fff"},invalid:{backgroundColor:"#f9e1e1",borderColor:"#f25226",border:"1px solid"}},xn=[{type:wn,placeholder:"Card holder",styles:Object.assign(Object.assign({},Yn),{base:Object.assign(Object.assign({},Yn.base),{border:"1px solid #eae8ee",padding:"10px 16px",borderTopLeftRadius:"4px",borderTopRightRadius:"4px"})})},{type:bn,placeholder:"1234 1234 1234 1234",styles:Object.assign(Object.assign({},Yn),{base:Object.assign(Object.assign({},Yn.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:Un,placeholder:"MM",styles:Object.assign(Object.assign({},Yn),{base:Object.assign(Object.assign({},Yn.base),{borderBottom:"1px solid #eae8ee",borderLeft:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomLeftRadius:"4px"})})},{type:kn,placeholder:"YY",format:"YY",styles:Object.assign(Object.assign({},Yn),{base:Object.assign(Object.assign({},Yn.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee"})})},{type:Mn,placeholder:"CVC",styles:Object.assign(Object.assign({},Yn),{base:Object.assign(Object.assign({},Yn.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomRightRadius:"4px"})})}];class Vn extends Cn{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."),xn.forEach((({type:e,styles:i,format:n,placeholder:o})=>{var s,r,a,l,d,c,E;if(!(null===(s=this.options)||void 0===s?void 0:s.showCardHolderName)&&e===exports.ElementType.CARDHOLDER_NAME)return;const _=new Fn(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===(E=null===(c=this.options)||void 0===c?void 0:c.events)||void 0===E?void 0:E.onFocus,onChange:this.onChange.bind(this),onReady:this.triggerOnReady.bind(this)}});this.formFields.push(_)})),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({},Yn.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 Fn{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 Gn extends D{constructor(e,t){super("div",{id:"payrails-card-list"}),this.workflowExecution=e,this.listItems=[],this.workflowExecution.savedCreditCards.forEach((e=>{const i=new Bn((()=>{(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 Bn extends D{constructor(e,t){super("div",{className:"payrails-card-list-item",id:`payrails-card-list-item-${t.id}`});const{id:i}=t,n=this.createCardLabel(t),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.innerText=n,o.appendChild(r),this.element.appendChild(o)}createCardLabel({data:e={}}){return`****${null==e?void 0:e.suffix}`}}class jn extends D{constructor(e="Authorization failed, please try again."){super("div",{id:"authorization-failed-message"}),this.element.innerText=e,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>${e}</div>`,this.element.addEventListener("click",(e=>{e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),this.unmount()}))}}class Xn extends D{constructor(e){var t;super("div",{id:"payrails-authorization-success-msg"}),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`}}class Wn extends D{constructor(e,t,i,n){super("div",{id:e,className:"payrails-dropin-item"}),this.events=i,this.styles=n,this.isActive=!1,this.applyBaseStyles();const o=`payrails-dropin-item-${e}`,s=document.createElement("label");s.setAttribute("for",o);const r=document.createElement("input");r.setAttribute("type","radio"),r.setAttribute("name","payment-option"),r.setAttribute("id",o),r.setAttribute("value",o),this.input=r,s.appendChild(r),this.label=s;const a=document.createElement("span");s.appendChild(a),a.innerText=t,this.element.appendChild(s)}get identifier(){return`payrails-dropin-item-${this.id}`}deactivate(){var e,t;this.isActive&&(this.isActive=!1,this.label.style.marginBottom="0",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;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;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.label.style.marginBottom="8px",this.applyActiveStyles(),this.isActive=!0,(null===(t=this.events)||void 0===t?void 0:t.onActivate)&&this.events.onActivate())}}class $n extends Wn{constructor(){super(...arguments),this.buttonShown=!1}activate(){if(!this.buttonShown)return super.activate(),void(this.buttonShown=!0);this.label.style.marginBottom="8px",this.applyActiveStyles(),this.isActive=!0,this.element.querySelector(this.component.selector).style.display="block"}deactivate(){this.isActive&&(this.isActive=!1,this.label.style.marginBottom="0",this.applyBaseStyles(),this.element.querySelector(this.component.selector).style.display="none")}mountAfterAvailable(){super.mount(`#${this.loadElementId}`)}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 zn extends $n{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,i.styles),this.loadElementId="apple-pay-dropin-load-element",this.component=new Pn(e,t,Object.assign(Object.assign({},i),{events:{onApplePayAvailable:()=>{this.mountAfterAvailable()}}}))}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)}}class Kn extends Wn{constructor(e,t,i){super("payrails-credit-card-wrapper","Card",void 0,i),this.cardForm=e,this.paymentButton=t,this.cardFormShown=!1,this.component=new Hn(e,t)}activate(){var e,t;this.label.style.marginBottom="8px",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.label.style.marginBottom="0",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 D{constructor(e,t){super("div",{id:"payrails-form-container"}),this.subElements.push(e,t)}}const qn={apiVersion:2,apiVersionMinor:0};class Jn extends Cn{constructor(t,i,n){super("div",Object.assign(Object.assign({},n),{id:"payrails-google-pay-button"})),this.sdkConfig=t,this.execution=i,this.options=n,this.googleButton=null,this.paymentExecutor=new A(t,i),this.loadScript=new Sn((()=>e(this,void 0,void 0,(function*(){const e=document.createElement("script");return e.src="https://pay.google.com/gp/p/js/pay.js",new Promise(((t,i)=>{e.onload=()=>{const e=new google.payments.api.PaymentsClient({environment:this.options.environment||"TEST",merchantInfo:this.options.merchantInfo}),n=Object.assign(Object.assign({},qn),{allowedPaymentMethods:this.execution.googlePayConfig});e.isReadyToPay(n).then((n=>{var o,s,r;n?(null===(r=null===(s=null===(o=this.options)||void 0===o?void 0:o.events)||void 0===s?void 0:s.onGooglePayAvailable)||void 0===r||r.call(s),t(e)):i()}),i)},e.onerror=()=>{i()},document.body.appendChild(e)}))}))))}sdkLoaded(t){var i,n,o,a,l,d,c,E;return e(this,void 0,void 0,(function*(){try{const s=(null===(n=null===(i=this.options)||void 0===i?void 0:i.styles)||void 0===n?void 0:n.buttonColor)||"black",r=(null===(a=null===(o=this.options)||void 0===o?void 0:o.styles)||void 0===a?void 0:a.buttonType)||"long",_=(null===(d=null===(l=this.options)||void 0===l?void 0:l.styles)||void 0===d?void 0:d.buttonSizeMode)||"fill",u=(null===(E=null===(c=this.options)||void 0===c?void 0:c.styles)||void 0===E?void 0:E.buttonLocale)||void 0;return this.googleButton=t.createButton({buttonColor:s,buttonType:r,buttonSizeMode:_,buttonLocale:u,onClick:()=>e(this,void 0,void 0,(function*(){var e,t,i;if(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onPaymentButtonClicked){if(!(yield null===(i=this.options)||void 0===i?void 0:i.events.onPaymentButtonClicked()))return}yield this.onPaymentButtonClicked()})),allowedPaymentMethods:this.execution.googlePayConfig}),this.element.appendChild(this.googleButton),this.googleButton}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_GPAY_LOADING_ERROR,{cause:e,description:e.message});throw r.PayrailsLogger.error(t.message,{error:t}),t}}))}onLoadPaymentData(t){var i,n,o,s,r,a,l,d;return e(this,void 0,void 0,(function*(){const e=[{paymentMethodCode:"googlePay",integrationType:"api",paymentInstrumentData:Object.assign(Object.assign({},t),{paymentToken:t.paymentMethodData.tokenizationData.token}),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 y(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)}))}onPaymentButtonClicked(){var t,i,n,o,s,r,a,l;return e(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},qn),{allowedPaymentMethods:this.execution.googlePayConfig,transactionInfo:{totalPriceStatus:"FINAL",totalPrice:null===(t=this.sdkConfig.amount)||void 0===t?void 0:t.value,currencyCode:null===(i=this.sdkConfig.amount)||void 0===i?void 0:i.currency,countryCode:null===(r=null===(s=null===(o=null===(n=this.execution.meta)||void 0===n?void 0:n.order)||void 0===o?void 0:o.billingAddress)||void 0===s?void 0:s.country)||void 0===r?void 0:r.code},merchantInfo:{merchantId:(null===(a=this.options.merchantInfo)||void 0===a?void 0:a.merchantId)||"",merchantName:(null===(l=this.options.merchantInfo)||void 0===l?void 0:l.merchantName)||""}});(yield this.loadScript.loader).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{const t=yield this.loadScript.loader,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()}}class Zn extends $n{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.styles),this.loadElementId="google-pay-dropin-load-element",this.component=new Jn(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},i.events),{onGooglePayAvailable:()=>{this.mountAfterAvailable()}})}))}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)}}
4
+ */const Qe={IFRAME_SECURE_SITE:"https://js.skyflow.com/v1/elements/index.html",IFRAME_SECURE_ORGIN:"https://js.skyflow.com"},et="https://assets.payrails.io/b8c402b/card/index.html",tt="https://assets.payrails.io",it={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no",style:"width: 100%;",allow:"clipboard-read; clipboard-write"},nt=(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 ot=(e={})=>{const t=document.createElement("iframe"),i=Object.assign(Object.assign({},it),e);return Object.assign(t.style,Be),nt(t,i),t.getAttribute("id")||(t.id=t.name),t};const st=()=>Qe.IFRAME_SECURE_SITE,rt=(e,t)=>{Object.keys(t).forEach((i=>{Object.prototype.hasOwnProperty.call(t,i)&&(e.style[i]=t[i])}))};function at(e){return JSON.parse(JSON.stringify(e))}class lt{constructor(){this.listeners=[],this.isDestroyed=!1}on(e,t){ue.on(e,t),this.listeners.push({eventName:e,callback:t})}off(e,t){ue.off(e,t);const i=this.listeners.findIndex((t=>t.eventName===e));-1!==i&&this.listeners.splice(i,1)}emit(e,t,i=void 0){ue.emit(e,t,i)}hasListener(e){return-1!==this.listeners.findIndex((t=>t.eventName===e))}teardown(){this.listeners.forEach((e=>{ue.off(e.eventName,e.handler)})),this.listeners=[]}}var dt,ct,Et,_t,ut,It,ht;!function(e){e.DEFAULT="DEFAULT",e.PLAIN_TEXT="PLAIN_TEXT",e.MASKED="MASKED",e.REDACTED="REDACTED"}(dt||(dt={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.PATCH="PATCH",e.DELETE="DELETE"}(ct||(ct={})),function(e){e.CHANGE="CHANGE",e.READY="READY",e.FOCUS="FOCUS",e.BLUR="BLUR",e.SUBMIT="SUBMIT"}(Et||(Et={})),function(e){e.WARN="WARN",e.INFO="INFO",e.DEBUG="DEBUG",e.ERROR="ERROR"}(_t||(_t={})),function(e){e.DEV="DEV",e.PROD="PROD"}(ut||(ut={})),function(e){e.LOG="LOG",e.WARN="WARN",e.ERROR="ERROR"}(It||(It={})),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"}(ht||(ht={}));const pt={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}},ft={PROD:{doesReturnValue:!1},DEV:{doesReturnValue:!0}},Nt="[Skyflow]",Tt=(e,t,i)=>{if(i&&pt[i]){const{showDebugLogs:n,showInfoLogs:o,showWarnLogs:s,showErrorLogs:r}=pt[i];t===It.LOG&&n?console.log(`${_t.DEBUG}: ${Nt} ${e}`):t===It.LOG&&o?console.log(`${_t.INFO}: ${Nt} ${e}`):t===It.WARN&&s?console.warn(`${_t.WARN}: ${Nt} ${e}`):t===It.ERROR&&r&&console.error(`${_t.ERROR}: ${Nt} ${e}`)}},mt=(...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]})):""},vt=(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 Ot extends Error{constructor(e,t,i=!1){const n={code:e.code,description:t&&(null==t?void 0:t.length)>0?mt(e.description,...t):e.description};super(n.description),i?this.error=n:this.errors=[n]}}const At={INVALID_FIELD:{code:400,description:he.INVALID_FIELD},VAULTID_IS_REQUIRED:{code:400,description:he.VAULTID_IS_REQUIRED},EMPTY_VAULTID_IN_INIT:{code:400,description:he.EMPTY_VAULTID_IN_INIT},VAULTURL_IS_REQUIRED:{code:400,description:he.VAULTURL_IS_REQUIRED},EMPTY_VAULTURL_IN_INIT:{code:400,description:he.EMPTY_VAULTURL_IN_INIT},INVALID_VAULTURL_IN_INIT:{code:400,description:he.INVALID_VAULTURL_IN_INIT},GET_BEARER_TOKEN_IS_REQUIRED:{code:400,description:he.GET_BEARER_TOKEN_IS_REQUIRED},EMPTY_CONTAINER_TYPE:{code:400,description:he.EMPTY_CONTAINER_TYPE},INVALID_CONTAINER_TYPE:{code:400,description:he.INVALID_CONTAINER_TYPE},UNIQUE_ELEMENT_NAME:{code:400,description:he.UNIQUE_ELEMENT_NAME},ELEMENTS_NOT_MOUNTED:{code:400,description:he.ELEMENTS_NOT_MOUNTED},MISSING_TABLE_IN_COLLECT:{code:400,description:he.MISSING_TABLE_IN_COLLECT},EMPTY_TABLE_IN_COLLECT:{code:400,description:he.EMPTY_TABLE_IN_COLLECT},EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:{code:400,description:he.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS},INVALID_TABLE_IN_COLLECT:{code:400,description:he.INVALID_TABLE_IN_COLLECT},INVALID_SKYFLOWID_IN_COLLECT:{code:400,description:he.INVALID_SKYFLOWID_IN_COLLECT},MISSING_COLUMN_IN_COLLECT:{code:400,description:he.MISSING_COLUMN_IN_COLLECT},EMPTY_COLUMN_IN_COLLECT:{code:400,description:he.EMPTY_TABLE_IN_COLLECT},INVALID_COLUMN_IN_COLLECT:{code:400,description:he.INVALID_COLUMN_IN_COLLECT},CLIENT_CONNECTION:{code:400,description:he.CLIENT_CONNECTION},RECORDS_KEY_NOT_FOUND:{code:404,description:he.RECORDS_KEY_NOT_FOUND},EMPTY_RECORDS_IN_INSERT:{code:400,description:he.EMPTY_RECORDS_IN_INSERT},INVALID_RECORDS_IN_INSERT:{code:404,description:he.INVALID_RECORDS_IN_INSERT},INVALID_TABLE_IN_INSERT:{code:400,description:he.INVALID_TABLE_IN_INSERT},EMPTY_TABLE_IN_INSERT:{code:400,description:he.EMPTY_TABLE_IN_INSERT},MISSING_TABLE_IN_INSERT:{code:400,description:he.MISSING_TABLE_IN_INSERT},EMPTY_FIELDS_IN_INSERT:{code:400,description:he.EMPTY_FIELDS_IN_INSERT},MISSING_FIELDS_IN_INSERT:{code:404,description:he.MISSING_FIELDS_IN_INSERT},INVALID_FIELDS_IN_INSERT:{code:404,description:he.INVALID_FIELDS_IN_INSERT},INVALID_TOKENS_IN_INSERT:{code:404,description:he.INVALID_TOKENS_IN_INSERT},RECORDS_KEY_NOT_FOUND_DETOKENIZE:{code:404,description:he.RECORDS_KEY_NOT_FOUND_DETOKENIZE},EMPTY_RECORDS_DETOKENIZE:{code:400,description:he.EMPTY_RECORDS_DETOKENIZE},INVALID_RECORDS_IN_DETOKENIZE:{code:404,description:he.INVALID_RECORDS_IN_DETOKENIZE},MISSING_TOKEN_IN_DETOKENIZE:{code:400,description:he.MISSING_TOKEN_IN_DETOKENIZE},INVALID_TOKEN_IN_DETOKENIZE:{code:400,description:he.INVALID_TOKEN_IN_DETOKENIZE},RECORDS_KEY_NOT_FOUND_GET:{code:400,description:he.RECORDS_KEY_NOT_FOUND_GET},INVALID_RECORDS_IN_GET:{code:400,description:he.INVALID_RECORDS_IN_GET},EMPTY_RECORDS_GET:{code:400,description:he.EMPTY_RECORDS_GET},MISSING_IDS_IN_GET:{code:400,description:he.MISSING_IDS_IN_GET},INVALID_IDS_IN_GET:{code:400,description:he.INVALID_IDS_IN_GET},INVALID_COLUMN_VALUES_IN_GET:{code:400,description:he.INVALID_COLUMN_VALUES_IN_GET},EMPTY_IDS_IN_GET:{code:400,description:he.EMPTY_IDS_IN_GET},INVALID_SKYFLOWID_TYPE_IN_GET:{code:400,description:he.INVALID_SKYFLOWID_TYPE_IN_GET},MISSING_TABLE_IN_GET:{code:400,description:he.MISSING_TABLE_IN_GET},INVALID_TABLE_IN_GET:{code:400,description:he.INVALID_TABLE_IN_GET},MISSING_REDACTION_IN_GET:{code:400,description:he.MISSING_REDACTION_IN_GET},INVALID_REDACTION_TYPE_IN_GET:{code:400,description:he.INVALID_REDACTION_TYPE_IN_GET},INVALID_TOKENS_IN_GET:{code:400,description:he.INVALID_TOKENS_IN_GET},TOKENS_GET_COLUMN_NOT_SUPPORTED:{code:400,description:he.TOKENS_GET_COLUMN_NOT_SUPPORTED},REDACTION_WITH_TOKENS_NOT_SUPPORTED:{code:400,description:he.REDACTION_WITH_TOKENS_NOT_SUPPORTED},INVALID_REDACTION_TYPE_IN_DETOKENIZE:{code:400,description:he.INVALID_REDACTION_TYPE_IN_DETOKENIZE},INVALID_TOKENS_IN_COLLECT:{code:404,description:he.INVALID_TOKENS_IN_COLLECT},RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS:{code:404,description:he.RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS},INVALID_RECORDS_IN_ADDITIONAL_FIELDS:{code:404,description:he.INVALID_RECORDS_IN_ADDITIONAL_FIELDS},EMPTY_RECORDS_IN_ADDITIONAL_FIELDS:{code:400,description:he.EMPTY_RECORDS_IN_ADDITIONAL_FIELDS},MISSING_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:he.MISSING_TABLE_IN_ADDITIONAL_FIELDS},INVALID_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:he.INVALID_TABLE_IN_ADDITIONAL_FIELDS},INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:{code:400,description:he.INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS},MISSING_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:he.MISSING_FIELDS_IN_ADDITIONAL_FIELDS},INVALID_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:he.INVALID_FIELDS_IN_ADDITIONAL_FIELDS},RECORDS_KEY_NOT_FOUND_DELETE:{code:400,description:he.RECORDS_KEY_NOT_FOUND_DELETE},EMPTY_RECORDS_IN_DELETE:{code:400,description:he.EMPTY_RECORDS_IN_DELETE},INVALID_RECORDS_IN_DELETE:{code:404,description:he.INVALID_RECORDS_IN_DELETE},INVALID_TABLE_IN_DELETE:{code:400,description:he.INVALID_TABLE_IN_DELETE},EMPTY_TABLE_IN_DELETE:{code:400,description:he.EMPTY_TABLE_IN_DELETE},MISSING_TABLE_IN_DELETE:{code:400,description:he.MISSING_TABLE_IN_DELETE},EMPTY_ID_IN_DELETE:{code:400,description:he.EMPTY_ID_IN_DELETE},MISSING_ID_IN_DELETE:{code:404,description:he.MISSING_ID_IN_DELETE},INVALID_ID_IN_DELETE:{code:404,description:he.INVALID_ID_IN_DELETE},EMPTY_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:he.EMPTY_TABLE_IN_ADDITIONAL_FIELDS},EMPTY_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:he.EMPTY_FIELDS_IN_ADDITIONAL_FIELDS},EMPTY_TOKEN_IN_DETOKENIZE:{code:400,description:he.EMPTY_TOKEN_IN_DETOKENIZE},EMPTY_SKYFLOWID_IN_GET:{code:400,description:he.EMPTY_SKYFLOWID_IN_GET},EMPTY_TABLE_IN_GET:{code:400,description:he.EMPTY_TABLE_IN_GET},EMPTY_REDACTION_TYPE_IN_GET:{code:400,description:he.EMPTY_REDACTION_TYPE_IN_GET},DUPLICATE_ELEMENT:{code:400,description:he.DUPLICATE_ELEMENT},DUPLICATE_ELEMENT_ADDITIONAL_FIELDS:{code:400,description:he.DUPLICATE_ELEMENT_ADDITIONAL_FIELDS},MISSING_ELEMENT_TYPE:{code:400,description:he.MISSING_ELEMENT_TYPE},EMPTY_ELEMENT_TYPE:{code:400,description:he.EMPTY_ELEMENT_TYPE},INVALID_ELEMENT_TYPE:{code:400,description:he.INVALID_ELEMENT_TYPE},INVALID_ELEMENT_SELECTOR:{code:400,description:he.INVALID_ELEMENT_SELECTOR},FRAME_NOT_FOUND:{code:400,description:he.FRAME_NOT_FOUND},REQUIRED_PARAMS_NOT_PROVIDED:{code:400,description:he.REQUIRED_PARAMS_NOT_PROVIDED},INVALID_RECORD_COLUMN_VALUE:{code:400,description:he.INVALID_RECORD_COLUMN_VALUE},MISSING_RECORD_COLUMN_VALUE:{code:400,description:he.MISSING_RECORD_COLUMN_VALUE},MISSING_RECORD_COLUMN_NAME:{code:400,description:he.MISSING_RECORD_COLUMN_NAME},INVALID_EVENT_TYPE:{code:400,description:he.INVALID_EVENT_TYPE},INVALID_EVENT_LISTENER:{code:400,description:he.INVALID_EVENT_LISTENER},MISSING_HANDLER_IN_EVENT_LISTENER:{code:400,description:he.MISSING_HANDLER_IN_EVENT_LISTENER},INVALID_HANDLER_IN_EVENT_LISTENER:{code:400,description:he.INVALID_HANDLER_IN_EVENT_LISTENER},UNKNOWN_ERROR:{code:400,description:he.UNKNOWN_ERROR},CONNECTION_ERROR:{code:400,description:he.CONNECTION_ERROR},NETWORK_ERROR:{code:500,description:he.NETWORK_ERROR},COMPLETE_AND_VALID_INPUTS:{code:400,description:he.COMPLETE_AND_VALID_INPUTS},INVALID_VALIDATIONS_TYPE:{code:400,description:he.INVALID_VALIDATIONS_TYPE},MISSING_VALIDATION_RULE_TYPE:{code:400,description:he.MISSING_VALIDATION_RULE_TYPE},INVALID_VALIDATION_RULE_TYPE:{code:400,description:he.INVALID_VALIDATION_RULE_TYPE},MISSING_VALIDATION_RULE_PARAMS:{code:400,description:he.MISSING_VALIDATION_RULE_PARAMS},INVALID_VALIDATION_RULE_PARAMS:{code:400,description:he.INVALID_VALIDATION_RULE_PARAMS},MISSING_REGEX_IN_REGEX_MATCH_RULE:{code:400,description:he.MISSING_REGEX_IN_REGEX_MATCH_RULE},INVALID_REGEX_IN_REGEX_MATCH_RULE:{code:400,description:he.INVALID_REGEX_IN_REGEX_MATCH_RULE},MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE:{code:400,description:he.MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE},MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE:{code:400,description:he.MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE},INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE:{code:400,description:he.INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE},ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE:{code:400,description:he.ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE},EMPTY_ELEMENT_IN_MOUNT:{code:400,description:he.EMPTY_ELEMENT_IN_MOUNT},INVALID_TABLE_IN_UPSERT_OPTION:{code:400,description:he.INVALID_TABLE_IN_UPSERT_OPTION},INVALID_COLUMN_IN_UPSERT_OPTION:{code:400,description:he.INVALID_COLUMN_IN_UPSERT_OPTION},INVALID_UPSERT_OPTION_TYPE:{code:400,description:he.INVALID_UPSERT_OPTION_TYPE},EMPTY_UPSERT_OPTIONS_ARRAY:{code:400,description:he.EMPTY_UPSERT_OPTIONS_ARRAY},INVALID_UPSERT_OPTION_OBJECT_TYPE:{code:400,description:he.INVALID_UPSERT_OPTION_OBJECT_TYPE},MISSING_TABLE_IN_UPSERT_OPTION:{code:400,description:he.MISSING_TABLE_IN_UPSERT_OPTION},MISSING_COLUMN_IN_UPSERT_OPTION:{code:400,description:he.MISSING_COLUMN_IN_UPSERT_OPTION},INVALID_RECORD_COLUMN_VALUE_TYPE:{code:400,description:he.INVALID_RECORD_COLUMN_VALUE_TYPE},INVALID_COLUMN_VALUES_TYPE:{code:400,description:he.INVALID_COLUMN_VALUES_TYPE},EMPTY_RECORD_COLUMN_VALUES:{code:400,description:he.EMPTY_RECORD_COLUMN_VALUES},EMPTY_COLUMN_VALUE:{code:400,description:he.EMPTY_COLUMN_VALUE},MISSING_IDS_OR_COLUMN_VALUES_IN_GET:{code:400,description:he.MISSING_IDS_OR_COLUMN_VALUES_IN_GET},SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED:{code:400,description:he.SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED},RECORDS_KEY_NOT_FOUND_GETBYID:{code:400,description:he.RECORDS_KEY_NOT_FOUND_GETBYID},INVALID_RECORDS_IN_GETBYID:{code:400,description:he.INVALID_RECORDS_IN_GETBYID},EMPTY_RECORDS_GETBYID:{code:400,description:he.EMPTY_RECORDS_GETBYID},MISSING_IDS_IN_GETBYID:{code:400,description:he.MISSING_IDS_IN_GETBYID},INVALID_IDS_IN_GETBYID:{code:400,description:he.INVALID_IDS_IN_GETBYID},EMPTY_IDS_IN_GETBYID:{code:400,description:he.EMPTY_IDS_IN_GETBYID},INVALID_SKYFLOWID_TYPE_IN_GETBYID:{code:400,description:he.INVALID_SKYFLOWID_TYPE_IN_GETBYID},MISSING_TABLE_IN_GETBYID:{code:400,description:he.MISSING_TABLE_IN_GETBYID},INVALID_TABLE_IN_GETBYID:{code:400,description:he.INVALID_TABLE_IN_GETBYID},MISSING_REDACTION_IN_GETBYID:{code:400,description:he.MISSING_REDACTION_IN_GETBYID},INVALID_REDACTION_TYPE_IN_GETBYID:{code:400,description:he.INVALID_REDACTION_TYPE_IN_GETBYID},EMPTY_SKYFLOWID_IN_GETBYID:{code:400,description:he.EMPTY_SKYFLOWID_IN_GETBYID},EMPTY_TABLE_IN_GETBYID:{code:400,description:he.EMPTY_TABLE_IN_GETBYID},EMPTY_REDACTION_TYPE_IN_GETBYID:{code:400,description:he.EMPTY_REDACTION_TYPE_IN_GETBYID},MISSING_COMPOSABLE_LAYOUT_KEY:{code:400,description:he.MISSING_COMPOSABLE_LAYOUT_KEY},EMPTY_COMPOSABLE_LAYOUT_ARRAY:{code:400,description:he.EMPTY_COMPOSABLE_LAYOUT_ARRAY},INVALID_COMPOSABLE_LAYOUT_TYPE:{code:400,description:he.INVALID_COMPOSABLE_LAYOUT_TYPE},NEGATIVE_VALUES_COMPOSABLE_LAYOUT:{code:400,description:he.NEGATIVE_VALUES_COMPOSABLE_LAYOUT},MISMATCH_ELEMENT_COUNT_LAYOUT_SUM:{code:400,description:he.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM},MISSING_COMPOSABLE_CONTAINER_OPTIONS:{code:400,description:he.MISSING_COMPOSABLE_CONTAINER_OPTIONS},INVALID_COMPOSABLE_CONTAINER_OPTIONS:{code:400,description:he.INVALID_COMPOSABLE_CONTAINER_OPTIONS},COMPOSABLE_CONTAINER_NOT_MOUNTED:{code:400,description:he.COMPOSABLE_CONTAINER_NOT_MOUNTED},INVALID_BOOLEAN_OPTIONS:{code:400,description:he.INVALID_BOOLEAN_OPTIONS},EMPTY_COLLECT_CUSTOM_FORMAT:{code:400,description:he.EMPTY_COLLECT_CUSTOM_FORMAT},INVALID_INPUT_OPTIONS_FORMAT:{code:400,description:he.INVALID_INPUT_OPTIONS_FORMAT},INVALID_INPUT_OPTIONS_TRANSLATION:{code:400,description:he.INVALID_INPUT_OPTIONS_TRANSLATION}},yt=(e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new Ot(At.RECORDS_KEY_NOT_FOUND,[],!0);const{records:i}=e;if(!i||!Array.isArray(i))throw new Ot(At.INVALID_RECORDS_IN_INSERT,[],!0);if(0===i.length)throw new Ot(At.EMPTY_RECORDS_IN_INSERT,[],!0);if(i.forEach(((e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"table"))throw new Ot(At.MISSING_TABLE_IN_INSERT,[`${t}`],!0);if(!e.table)throw new Ot(At.EMPTY_TABLE_IN_INSERT,[`${t}`],!0);if(!("string"==typeof e.table||e.table instanceof String))throw new Ot(At.INVALID_TABLE_IN_INSERT,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"fields"))throw new Ot(At.MISSING_FIELDS_IN_INSERT,[`${t}`],!0);if(!e.fields)throw new Ot(At.EMPTY_FIELDS_IN_INSERT,[`${t}`],!0);if("object"!=typeof e.fields||Array.isArray(e.fields))throw new Ot(At.INVALID_FIELDS_IN_INSERT,[`${t}`],!0)})),t&&t.tokens&&"boolean"!=typeof t.tokens)throw new Ot(At.INVALID_TOKENS_IN_INSERT,[],!0)},Lt=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new Ot(At.RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS,[],!0);const{records:t}=e;if(!t||!Array.isArray(t))throw new Ot(At.INVALID_RECORDS_IN_ADDITIONAL_FIELDS,[],!0);if(0===t.length)throw new Ot(At.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 Ot(At.MISSING_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!e.table)throw new Ot(At.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 Ot(At.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 Ot(At.INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[`${t}`],!0)}if(!("string"==typeof e.table||e.table instanceof String))throw new Ot(At.INVALID_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"fields"))throw new Ot(At.MISSING_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!e.fields)throw new Ot(At.EMPTY_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if("object"!=typeof e.fields||Array.isArray(e.fields))throw new Ot(At.INVALID_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0)}))},Rt=(e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new Ot(At.RECORDS_KEY_NOT_FOUND_GET);const{records:i}=e;if(!i||!Array.isArray(i))throw new Ot(At.INVALID_RECORDS_IN_GET,[]);if(0===i.length)throw new Ot(At.EMPTY_RECORDS_GET);if(t&&Object.prototype.hasOwnProperty.call(t,"tokens")&&"boolean"!=typeof(null==t?void 0:t.tokens))throw new Ot(At.INVALID_TOKENS_IN_GET);i.forEach(((e,i)=>{var n,o,s;if(0===Object.keys(e).length)throw new Ot(At.EMPTY_RECORDS_GET);if(0===(null===(n=e.ids)||void 0===n?void 0:n.length))throw new Ot(At.EMPTY_IDS_IN_GET,[`${i}`]);if(!(null==e.ids||e.ids&&Array.isArray(e.ids)))throw new Ot(At.INVALID_IDS_IN_GET,[`${i}`]);if(null===(o=e.ids)||void 0===o||o.forEach((e=>{if(!e)throw new Ot(At.EMPTY_SKYFLOWID_IN_GET,[`${i}`]);if(!("string"==typeof e||e instanceof String))throw new Ot(At.INVALID_SKYFLOWID_TYPE_IN_GET,[`${i}`])})),!Object.prototype.hasOwnProperty.call(e,"table"))throw new Ot(At.MISSING_TABLE_IN_GET,[`${i}`]);if(!e.table)throw new Ot(At.EMPTY_TABLE_IN_GET,[`${i}`]);if(!("string"==typeof e.table||e.table instanceof String))throw new Ot(At.INVALID_TABLE_IN_GET,[`${i}`]);if(!t||!Object.prototype.hasOwnProperty.call(t,"tokens")||!0!==(null==t?void 0:t.tokens)){if(!Object.prototype.hasOwnProperty.call(e,"redaction"))throw new Ot(At.MISSING_REDACTION_IN_GET,[`${i}`]);if(!e.redaction)throw new Ot(At.EMPTY_REDACTION_TYPE_IN_GET,[`${i}`]);if(!Object.values(dt).includes(e.redaction))throw new Ot(At.INVALID_REDACTION_TYPE_IN_GET,[`${i}`])}if(!0===Object.prototype.hasOwnProperty.call(e,"ids")&&!0===Object.prototype.hasOwnProperty.call(e,"columnName"))throw new Ot(At.SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED,[`${i}`]);if(Object.prototype.hasOwnProperty.call(e,"columnName")){if(!Object.prototype.hasOwnProperty.call(e,"columnName")||!Object.prototype.hasOwnProperty.call(e,"columnValues"))throw new Ot(At.MISSING_RECORD_COLUMN_VALUE,[`${i}`])}else if(!1===Object.prototype.hasOwnProperty.call(e,"ids")&&!1===Object.prototype.hasOwnProperty.call(e,"columnValues"))throw new Ot(At.MISSING_IDS_OR_COLUMN_VALUES_IN_GET,[`${i}`]);if(0===(null===(s=e.columnValues)||void 0===s?void 0:s.length))throw new Ot(At.EMPTY_RECORD_COLUMN_VALUES,[`${i}`]);if(!(null==e.columnValues||e.columnValues&&Array.isArray(e.columnValues)))throw new Ot(At.INVALID_COLUMN_VALUES_IN_GET,[`${i}`]);if(void 0!==e.columnName&&void 0===e.columnValues)throw new Ot(At.MISSING_RECORD_COLUMN_VALUE,[`${i}`]);if(void 0===e.columnName&&void 0!==e.columnValues)throw new Ot(At.MISSING_RECORD_COLUMN_NAME,[`${i}`]);const r=e.columnName;if(null!=r&&"string"!=typeof r)throw new Ot(At.INVALID_RECORD_COLUMN_VALUE,[`${i}`]);const a=e.columnValues;if(null!=a){if(0===a.length||null===a)throw new Ot(At.EMPTY_RECORD_COLUMN_VALUES,[`${i}`]);a.forEach((e=>{if(""===e||null===e)throw new Ot(At.EMPTY_COLUMN_VALUE,[`${i}`]);if("string"!=typeof e)throw new Ot(At.INVALID_RECORD_COLUMN_VALUE_TYPE,[`${i}`])}))}if(t&&Object.prototype.hasOwnProperty.call(t,"tokens")&&!0===(null==t?void 0:t.tokens)){if(r||a)throw new Ot(At.TOKENS_GET_COLUMN_NOT_SUPPORTED);if(e.redaction)throw new Ot(At.REDACTION_WITH_TOKENS_NOT_SUPPORTED)}}))},gt=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new Ot(At.RECORDS_KEY_NOT_FOUND_GETBYID);const{records:t}=e;if(!t||!Array.isArray(t))throw new Ot(At.INVALID_RECORDS_IN_GETBYID,[]);if(0===t.length)throw new Ot(At.EMPTY_RECORDS_GETBYID);t.forEach(((e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"ids"))throw new Ot(At.MISSING_IDS_IN_GETBYID,[`${t}`]);if(!e.ids||!Array.isArray(e.ids))throw new Ot(At.INVALID_IDS_IN_GETBYID,[`${t}`]);if(0===e.ids.length)throw new Ot(At.EMPTY_IDS_IN_GETBYID,[`${t}`]);if(e.ids.forEach((e=>{if(!e)throw new Ot(At.EMPTY_SKYFLOWID_IN_GETBYID,[`${t}`]);if(!("string"==typeof e||e instanceof String))throw new Ot(At.INVALID_SKYFLOWID_TYPE_IN_GETBYID,[`${t}`])})),!Object.prototype.hasOwnProperty.call(e,"table"))throw new Ot(At.MISSING_TABLE_IN_GETBYID,[`${t}`]);if(!e.table)throw new Ot(At.EMPTY_TABLE_IN_GETBYID,[`${t}`]);if(!("string"==typeof e.table||e.table instanceof String))throw new Ot(At.INVALID_TABLE_IN_GETBYID,[`${t}`]);if(!Object.prototype.hasOwnProperty.call(e,"redaction"))throw new Ot(At.MISSING_REDACTION_IN_GETBYID,[`${t}`]);if(!e.redaction)throw new Ot(At.EMPTY_REDACTION_TYPE_IN_GETBYID,[`${t}`]);if(!Object.values(dt).includes(e.redaction))throw new Ot(At.INVALID_REDACTION_TYPE_IN_GETBYID,[`${t}`])}))},St=(e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new Ot(At.RECORDS_KEY_NOT_FOUND_DELETE,[],!0);const{records:i}=e;if(!i||!Array.isArray(i))throw new Ot(At.INVALID_RECORDS_IN_DELETE,[],!0);if(0===i.length)throw new Ot(At.EMPTY_RECORDS_IN_DELETE,[],!0);i.forEach(((e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"table"))throw new Ot(At.MISSING_TABLE_IN_DELETE,[`${t}`],!0);if(!e.table)throw new Ot(At.EMPTY_TABLE_IN_DELETE,[`${t}`],!0);if(!("string"==typeof e.table||e.table instanceof String))throw new Ot(At.INVALID_TABLE_IN_DELETE,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"id"))throw new Ot(At.MISSING_ID_IN_DELETE,[`${t}`],!0);if(!e.id)throw new Ot(At.EMPTY_ID_IN_DELETE,[`${t}`],!0);if(!("string"==typeof e.id||e.id instanceof String))throw new Ot(At.INVALID_ID_IN_DELETE,[`${t}`],!0)}))},Ct=e=>{let t=!0;try{new RegExp(e)}catch(e){t=!1}return t},Dt=e=>{if(!Object.prototype.hasOwnProperty.call(e,"getBearerToken"))throw new Ot(At.GET_BEARER_TOKEN_IS_REQUIRED,[],!0)},Pt=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new Ot(At.MISSING_ELEMENT_TYPE,[],!0);if(!e.type)throw new Ot(At.EMPTY_ELEMENT_TYPE,[],!0);if(Object.prototype.hasOwnProperty.call(e,"altText")&&Tt(pe.COLLECT_ALT_TEXT_DEPERECATED,It.WARN,t),Object.prototype.hasOwnProperty.call(e,"skyflowID")&&"string"!=typeof e.skyflowID)throw new Ot(At.INVALID_SKYFLOWID_IN_COLLECT,[],!0)},bt=e=>{if(!e||!Array.isArray(e))throw new Ot(At.INVALID_UPSERT_OPTION_TYPE,[],!0);if(!e.length)throw new Ot(At.EMPTY_UPSERT_OPTIONS_ARRAY,[],!0);e.forEach(((e,t)=>{if(!e||"object"!=typeof e)throw new Ot(At.INVALID_UPSERT_OPTION_OBJECT_TYPE,[t],!0);if(!Object.prototype.hasOwnProperty.call(e,"table"))throw new Ot(At.MISSING_TABLE_IN_UPSERT_OPTION,[t],!0);if(!e.table||"string"!=typeof e.table||!e.table.length)throw new Ot(At.INVALID_TABLE_IN_UPSERT_OPTION,[t],!0);if(!Object.prototype.hasOwnProperty.call(e,"column"))throw new Ot(At.MISSING_COLUMN_IN_UPSERT_OPTION,[t],!0);if(!e.column||"string"!=typeof e.column||!e.column.length)throw new Ot(At.INVALID_COLUMN_IN_UPSERT_OPTION,[t],!0)}))},Mt=e=>"boolean"==typeof e;function wt(e){const t=e.split(":");return t.length>2?(t.pop(),t.pop(),t.join(":")):""}const Ut=(e,t,i)=>{if("string"!=typeof e)return e;if(t===ke.CARD_NUMBER){if(e=e&&e.replace(/\s/g,""),!i){const t=((e="")=>{const t=e.replace(/[\s-]/g,"");let i=Ye.DEFAULT;return Object.entries(We).forEach((([e,n])=>{n.regex.test(t)&&(i=e)})),i})(e),i=t!==Ye.DEFAULT&&t===Ye.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 kt(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}`;Qe.IFRAME_SECURE_ORGIN=s,Qe.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(!Qe.IFRAME_SECURE_ORGIN||!Qe.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:Qe.IFRAME_SECURE_ORGIN,IFRAME_SECURE_SITE:Qe.IFRAME_SECURE_SITE}}),e}Qe.IFRAME_SECURE_ORGIN=tt,Qe.IFRAME_SECURE_SITE=et}}class Yt{constructor(e,t,i,n){this.setAttributess=e=>{nt(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 Ot(At.INVALID_ELEMENT_SELECTOR,[],!0)}else{if(!(e instanceof HTMLElement))throw new Ot(At.INVALID_ELEMENT_SELECTOR,[],!0);this.container=e}}catch(e){console.error(e)}nt(this.iframe,{src:st()}),null===(t=this.container)||void 0===t||t.appendChild(this.iframe)},this.setIframeHeight=e=>{this.iframe.getAttribute("height")!==e&&this.iframe.setAttribute("height",`${e}px`)},this.unmount=()=>{this.iframe.remove()},this.name=`${e}:${i}:${n}`,this.metadata=t,this.iframe=ot({name:this.name})}}class xt{}var Vt,Gt,Bt,Ft,jt,Xt,Wt,zt,$t,Kt,Ht,qt,Jt,Zt,Qt,ei,ti,ii,ni,oi;const si="Element";class ri extends xt{constructor(e,n,o,s,r=!1,a,l,d,c){var E;super(),this.type=Ln.COLLECT,Vt.set(this,void 0),Gt.set(this,!1),Bt.set(this,void 0),Ft.set(this,void 0),jt.set(this,{isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:void 0,isRequired:!1}),Xt.set(this,void 0),Wt.set(this,new Ze),zt.set(this,void 0),$t.set(this,new lt),Kt.set(this,void 0),Ht.set(this,[]),qt.set(this,!1),Jt.set(this,void 0),Zt.set(this,void 0),Qt.set(this,!1),this.getID=()=>t(this,Vt,"f"),this.mount=e=>{var n;if(!e)throw new Ot(At.EMPTY_ELEMENT_IN_MOUNT,["CollectElement"],!0);const o=(e,n)=>{if(e.name===t(this,Kt,"f").name){n(t(this,Xt,"f")),t(this,oi,"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,Bt,"f")[0],["name"]);t(this,Ft,"f").length>1?t(this,Ft,"f").forEach(((e,i)=>{t(this,zt,"f")&&t(this,zt,"f")._emit(`${Ae.READY}:${e.elementName}`,Object.assign(Object.assign({},t(this,Bt,"f")[i]),{elementType:e.elementType}))})):t(this,Wt,"f")._emit(Ae.READY,Object.assign({},e)),t(this,$t,"f").off(ye+this.containerId,o),Tt(`${mt(Ie.ELEMENT_MOUNTED,si,vt(t(this,Kt,"f").name))} `,It.LOG,t(this,Jt,"f").logLevel),t(this,Ht,"f").forEach((e=>e())),i(this,Ht,[],"f")}};if(t(this,Ft,"f").length>1)t(this,Kt,"f").mount(e),t(this,$t,"f").on(ye+this.containerId,o);else{if(t(this,Qt,"f"))return t(this,Kt,"f").mount(e),void t(this,$t,"f").on(ye+this.containerId,o);null===(n=t(this,zt,"f"))||void 0===n||n.on(Ue,(i=>{(null==i?void 0:i.containerId)===this.containerId&&(t(this,Kt,"f").mount(e),t(this,$t,"f").on(ye+this.containerId,o))}))}},this.unmount=()=>{t(this,Kt,"f").unmount()},this.update=e=>{let n=at(e);const o=()=>{t(this,Gt,"f")&&(n={rows:[{elements:[Object.assign({},n)]}]}),i(this,Xt,li(t(this,Xt,"f"),n),"f"),i(this,Ft,di(t(this,Xt,"f")),"f"),t(this,Gt,"f")?t(this,$t,"f").emit(Se,{name:t(this,Kt,"f").name,options:t(this,Ft,"f")[0],isSingleElementAPI:!0}):(t(this,Ft,"f").forEach((e=>{t(this,$t,"f").emit(Se,{name:e.elementName,options:e,isSingleElementAPI:!0})})),t(this,$t,"f").emit(Se,{name:t(this,Kt,"f").name,options:t(this,Xt,"f"),isSingleElementAPI:!1})),t(this,oi,"f").call(this)};t(this,qt,"f")?o():t(this,Ht,"f").push(o)},ei.set(this,(e=>{t(this,Gt,"f")||t(this,Wt,"f").on(Se,(()=>{e(t(this,Ft,"f"))}),!0)})),this.updateElement=e=>{t(this,$t,"f").emit(Se,{name:e.elementName,options:e,isSingleElementAPI:!0})},ti.set(this,(()=>{t(this,Bt,"f").forEach(((e,i)=>{if(0===i){t(this,jt,"f").isEmpty=e.isEmpty,t(this,jt,"f").isComplete=e.isComplete,t(this,jt,"f").isValid=e.isValid,t(this,jt,"f").isFocused=e.isFocused,t(this,jt,"f").isRequired=e.isRequired,t(this,jt,"f").value={};const n=t(this,Ft,"f")[i].elementName,o=e.value&&Ut(e.value,e.elementType,t(this,Zt,"f"));t(this,Gt,"f")?t(this,jt,"f").value=o:t(this,jt,"f").value[n]=o}else t(this,jt,"f").isEmpty=t(this,jt,"f").isEmpty||e.isEmpty,t(this,jt,"f").isComplete=t(this,jt,"f").isComplete&&e.isComplete,t(this,jt,"f").isValid=t(this,jt,"f").isValid&&e.isValid,t(this,jt,"f").isFocused=t(this,jt,"f").isFocused||e.isFocused,t(this,jt,"f").isRequired=t(this,jt,"f").isRequired||e.isRequired,t(this,jt,"f").value||(t(this,jt,"f").value={}),t(this,Ft,"f")[i].sensitive||(t(this,jt,"f").value[t(this,Ft,"f")[i].elementName]=e.value||"")}))})),this.getState=()=>({isEmpty:t(this,jt,"f").isEmpty,isComplete:t(this,jt,"f").isComplete,isValid:t(this,jt,"f").isValid,isFocused:t(this,jt,"f").isFocused,value:t(this,jt,"f").value,required:t(this,jt,"f").isRequired}),this.getOptions=()=>{let e=at(t(this,Xt,"f"));return t(this,Gt,"f")?e=e.rows[0].elements[0]:e.rows.forEach((e=>{e.elements.forEach((e=>{delete e.elementName}))})),delete e.elementName,e},ii.set(this,(e=>{t(this,Wt,"f").on(ge,(()=>{const i=t(this,Ft,"f").map((e=>e.elementName));t(this,Gt,"f")||i.push(t(this,Kt,"f").name),e(i)}),!0)})),ni.set(this,(()=>{t(this,$t,"f").on(Re,(e=>{if(t(this,Gt,"f")&&e.event===Ae.READY&&e.name===t(this,Kt,"f").name)t(this,Wt,"f")._emit(Ae.READY);else{const i=t(this,Ft,"f").length>1;t(this,Ft,"f").forEach(((n,o)=>{var s;if(e.name===n.elementName){let r="";switch(e.event){case Ae.FOCUS:r=Ae.FOCUS;break;case Ae.BLUR:r=Ae.BLUR;break;case Ae.CHANGE:r=Ae.CHANGE;break;case Ae.READY:r=Ae.READY;break;case Ae.SUBMIT:return void(null===(s=t(this,zt,"f"))||void 0===s||s._emit(Ae.SUBMIT));default:throw new Ot(At.INVALID_EVENT_TYPE,[],!0)}t(this,Bt,"f")[o].isEmpty=e.value.isEmpty,t(this,Bt,"f")[o].isValid=e.value.isValid,t(this,Bt,"f")[o].isComplete=e.value.isComplete,t(this,Bt,"f")[o].isFocused=e.value.isFocused,t(this,Bt,"f")[o].isRequired=e.value.isRequired,Object.prototype.hasOwnProperty.call(e.value,"value")?t(this,Bt,"f")[o].value=e.value.value:t(this,Bt,"f")[o].value=void 0,r=i?`${r}:${e.name}`:r,t(this,$t,"f").emit(Ae.HEIGHT+t(this,Kt,"f").name,{},(e=>{t(this,Kt,"f").setIframeHeight(e.height)})),t(this,ti,"f").call(this);const a=Object.assign(Object.assign({},t(this,Bt,"f")[o]),{elementType:n.elementType});i&&t(this,zt,"f")?t(this,zt,"f")._emit(r,a):t(this,Wt,"f")._emit(r,a)}}))}}))})),oi.set(this,(()=>{const{rows:e}=t(this,Xt,"f");e.forEach((e=>{e.elements.forEach((e=>{e.elementType!==Ve.radio.name&&e.elementType!==Ve.checkbox.name&&(e.value=void 0)}))})),i(this,Ft,di(t(this,Xt,"f")),"f")})),this.containerId=s.containerId,i(this,Vt,e,"f"),i(this,Jt,d,"f"),i(this,Xt,li(n),"f"),i(this,Ft,di(n),"f"),i(this,Gt,r,"f"),c&&i(this,zt,c,"f"),i(this,Zt,ft[t(this,Jt,"f").env].doesReturnValue,"f"),this.elementType=t(this,Gt,"f")?t(this,Ft,"f")[0].elementType:"group",i(this,Bt,[],"f"),t(this,Ft,"f").forEach((e=>{t(this,Bt,"f").push({isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:t(this,Zt,"f")?"":void 0,elementType:e.elementType,name:e.elementName,isRequired:!1})})),i(this,Kt,new Yt(t(this,Xt,"f").elementName,o,this.containerId,t(this,Jt,"f").logLevel),"f"),t(this,ni,"f").call(this),t(this,ii,"f").call(this,a),t(this,ei,"f").call(this,l),Tt(mt(Ie.CREATED_ELEMENT,si,vt(t(this,Kt,"f").name)),It.LOG,t(this,Jt,"f").logLevel),i(this,Qt,s.isMounted,"f"),null===(E=t(this,zt,"f"))||void 0===E||E.on(Ue,(e=>{(null==e?void 0:e.containerId)===this.containerId&&i(this,Qt,!0,"f")})),t(this,$t,"f").on(Ae.MOUNTED,(e=>{s.type===Ln.COMPOSABLE?t(this,Ft,"f").forEach((t=>{e.name===t.elementName&&(t.isMounted=!0,i(this,qt,!0,"f"))})):e.name===t(this,Ft,"f")[0].elementName&&(t(this,Ft,"f")[0].isMounted=!0,i(this,qt,!0,"f")),t(this,$t,"f").emit(Ae.HEIGHT+t(this,Kt,"f").name,{},(e=>{t(this,Kt,"f").setIframeHeight(e.height)}))}))}on(e,i){if(!Object.values(Ae).includes(e))throw new Ot(At.INVALID_EVENT_LISTENER,[],!0);if(!i)throw new Ot(At.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof i)throw new Ot(At.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);t(this,Wt,"f").on(e,(e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,i(e)}))}iframeName(){return t(this,Kt,"f").name}isMounted(){return t(this,qt,"f")}isValidElement(){for(let e=0;e<t(this,Ft,"f").length;e+=1){if(!Object.prototype.hasOwnProperty.call(t(this,Ft,"f")[e],"table"))throw new Ot(At.MISSING_TABLE_IN_COLLECT,[],!0);if(!t(this,Ft,"f")[e].table)throw new Ot(At.EMPTY_TABLE_IN_COLLECT,[],!0);if(!("string"==typeof t(this,Ft,"f")[e].table||t(this,Ft,"f")[e].table instanceof String))throw new Ot(At.INVALID_TABLE_IN_COLLECT,[],!0);if(!Object.prototype.hasOwnProperty.call(t(this,Ft,"f")[e],"column"))throw new Ot(At.MISSING_COLUMN_IN_COLLECT,[],!0);if(!t(this,Ft,"f")[e].column)throw new Ot(At.EMPTY_COLUMN_IN_COLLECT,[],!0);if(!("string"==typeof t(this,Ft,"f")[e].column||t(this,Ft,"f")[e].column instanceof String))throw new Ot(At.INVALID_COLUMN_IN_COLLECT,[],!0);if(void 0!==t(this,Ft,"f")[e].skyflowID&&!t(this,Ft,"f")[e].skyflowID)throw new Ot(At.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[],!0)}return!0}setError(e){t(this,$t,"f").emit(be,{name:wt(t(this,Kt,"f").name),isTriggerError:!0,clientErrorText:e})}resetError(){t(this,$t,"f").emit(be,{name:wt(t(this,Kt,"f").name),isTriggerError:!1})}setValue(e){t(this,Jt,"f").env!==ut.PROD?t(this,Gt,"f")&&t(this,$t,"f").emit(Se,{name:t(this,Kt,"f").name,options:Object.assign(Object.assign({},t(this,Ft,"f")[0]),{value:e}),isSingleElementAPI:!0}):Tt(mt(pe.UNABLE_TO_SET_VALUE_IN_PROD_ENV,t(this,Ft,"f")[0].elementType),It.WARN,t(this,Jt,"f").logLevel)}clearValue(){t(this,Jt,"f").env!==ut.PROD?t(this,Gt,"f")&&t(this,$t,"f").emit(Se,{name:t(this,Kt,"f").name,options:Object.assign(Object.assign({},t(this,Ft,"f")[0]),{value:""}),isSingleElementAPI:!0}):Tt(mt(pe.UNABLE_TO_CLEAR_VALUE_IN_PROD_ENV,t(this,Ft,"f")[0].elementType),It.WARN,t(this,Jt,"f").logLevel)}}function ai(e,t,i={}){if("group"!==e&&!Object.prototype.hasOwnProperty.call(Ve,e))throw new Ot(At.INVALID_ELEMENT_TYPE,[],!0);if(Object.prototype.hasOwnProperty.call(t,"validations")){if(!Array.isArray(t.validations))throw new Ot(At.INVALID_VALIDATIONS_TYPE,[],!0);t.validations.forEach(((e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new Ot(At.MISSING_VALIDATION_RULE_TYPE,[`${t}`],!0);if(!Object.values(ht).includes(e.type))throw new Ot(At.INVALID_VALIDATION_RULE_TYPE,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"params"))throw new Ot(At.MISSING_VALIDATION_RULE_PARAMS,[`${t}`],!0);if("object"!=typeof e.params||Array.isArray(e.params)||null===e.params)throw new Ot(At.INVALID_VALIDATION_RULE_PARAMS,[`${t}`],!0);if(e.type===ht.REGEX_MATCH_RULE){if(!Object.prototype.hasOwnProperty.call(e.params,"regex"))throw new Ot(At.MISSING_REGEX_IN_REGEX_MATCH_RULE,[`${t}`],!0)}else if(e.type===ht.LENGTH_MATCH_RULE&&!Object.prototype.hasOwnProperty.call(e.params,"min")&&!Object.prototype.hasOwnProperty.call(e.params,"max"))throw new Ot(At.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}=Ve[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===Ve.radio.name||e===Ve.checkbox.name)&&!i.value)throw new Error("Elements radio and checkbox requires value attribute");if(!(e!==Ve.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 li(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(he.CANNOT_CHANGE_ELEMENT);ai(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({},je),c.base),l.classes=d,l.styles=c;const E=(null===(n=null==l?void 0:l.labelStyles)||void 0===n?void 0:n.classes)||{},_=(null===(o=null==l?void 0:l.labelStyles)||void 0===o?void 0:o.styles)||{};i&&function(e,t){Object.values(Xe).forEach((i=>{if(e[i]||t[i])switch(i){case Xe.BASE:t[i]=Object.assign({},t[i]);break;case Xe.FOCUS:t[Xe.BASE]=Object.assign(Object.assign({},t[Xe.BASE]),{":focus":Object.assign({},t[Xe.BASE]&&t[Xe.BASE][":focus"])});break;case Xe.WEBPACKAUTOFILL:t[Xe.BASE]=Object.assign(Object.assign({},t[Xe.BASE]),{":-webkit-autofill":Object.assign({},t[Xe.BASE]&&t[Xe.BASE][":-webkit-autofill"])});break;default:t[i]=Object.assign(Object.assign({},t[Xe.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`)}))}))}(E,_),l.labelStyles={labelClasses:E},l.labelStyles.styles=_}))})),t}Vt=new WeakMap,Gt=new WeakMap,Bt=new WeakMap,Ft=new WeakMap,jt=new WeakMap,Xt=new WeakMap,Wt=new WeakMap,zt=new WeakMap,$t=new WeakMap,Kt=new WeakMap,Ht=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;const di=e=>{const{rows:t}=e,i=[];return t.forEach((e=>{e.elements.forEach((e=>{i.push(e)}))})),i},ci=e=>{const t=e.validations;return t&&Array.isArray(t)&&t.length>0&&t.forEach(((e,t)=>{if(e&&e.type===ht.ELEMENT_VALUE_MATCH_RULE){if(e.params&&!Object.prototype.hasOwnProperty.call(e.params,"element"))throw new Ot(At.MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE,[`${t}`],!0);if(e.params&&(null==e.params.element||!(e.params.element instanceof ri)))throw new Ot(At.INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE,[`${t}`],!0);e.params&&e.params.element&&e.params.element instanceof ri&&(e.params.element=e.params.element.iframeName())}else if(e&&e.type===ht.REGEX_MATCH_RULE){if(e.params&&e.params.regex&&!Ct(e.params.regex))throw new Ot(At.INVALID_REGEX_IN_REGEX_MATCH_RULE,[`${t}`],!0);e.params&&e.params.regex&&Ct(e.params.regex)&&(e.params.regex=e.params.regex.toString())}})),t},Ei=(e,t,i)=>{let n=Object.assign({required:!1},t);if((Object.prototype.hasOwnProperty.call(n,"format")||Object.prototype.hasOwnProperty.call(n,"translation"))&&(qe.includes(e)?(Tt(mt(pe.INPUT_FORMATTING_NOT_SUPPROTED,e),It.WARN,i),null==n||delete n.format,null==n||delete n.translation):e===Ve.INPUT_FIELD.name&&((e=>{if(e){if(Object.prototype.hasOwnProperty.call(e,"format")&&"string"!=typeof e.format)throw new Ot(At.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 Ot(At.INVALID_INPUT_OPTIONS_TRANSLATION,[],!0)}})(t),n=Object.assign(Object.assign({},n),{mask:[n.format,n.translation?n.translation:Je]}),null==n||delete n.format,null==n||delete n.translation)),e===Ve.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)===Ge&&(e="-"),n=Object.assign(Object.assign({},n),{cardSeperator:e}),null==n||delete n.format,null==n||delete n.translation}else if(e===Ve.EXPIRATION_DATE.name){let e=!1;n.format&&(e=!!(o=n.format.toUpperCase())&&$e.includes(o),e||Tt(mt(pe.INVALID_EXPIRATION_DATE_FORMAT,$e.toString()),It.WARN,i)),n=Object.assign(Object.assign({},n),{format:e?n.format.toUpperCase():ze}),null==n||delete n.translation}else if(e===Ve.EXPIRATION_YEAR.name){let e=!1;n.format&&(e=(e=>!!e&&Ke.includes(e))(n.format.toUpperCase()),e||Tt(mt(pe.INVALID_EXPIRATION_YEAR_FORMAT,Ke.toString()),It.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")&&!Mt(n.enableCardIcon))throw new Ot(At.INVALID_BOOLEAN_OPTIONS,["enableCardIcon"],!0);if(Object.prototype.hasOwnProperty.call(n,"enableCopy")&&!Mt(n.enableCopy))throw new Ot(At.INVALID_BOOLEAN_OPTIONS,["enableCopy"],!0);if(Object.prototype.hasOwnProperty.call(n,"required")&&!Mt(n.required))throw new Ot(At.INVALID_BOOLEAN_OPTIONS,["required"],!0);return n};function _i(){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 ui{}var Ii,hi,pi,fi,Ni,Ti,mi,vi,Oi,Ai,yi,Li;const Ri="CollectContainer";class gi extends ui{constructor(e,n,o,s){super(),Ii.set(this,void 0),hi.set(this,{}),pi.set(this,void 0),fi.set(this,void 0),Ni.set(this,void 0),this.type=Ln.COLLECT,Ti.set(this,void 0),mi.set(this,!1),this.create=(e,i={required:!1})=>{Pt(e,t(this,fi,"f").logLevel);const n=ci(e),o=Ei(e.type,i,t(this,fi,"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,vi,"f").call(this,s,!0)},vi.set(this,((e,i=!1)=>{const n=[],o=at(e);if(o.rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;ai(i,t),t.sensitive=t.sensitive||Ve[i].sensitive,t.replacePattern=t.replacePattern||Ve[i].replacePattern,t.mask=t.mask||Ve[i].mask,t.isMounted=!1,t.elementType!==Ve.radio.name&&t.elementType!==Ve.checkbox.name||(t.elementName=`${t.elementName}:${btoa(t.value)}`),t.elementName=`${Ne}:${t.elementType}:${btoa(_i())}`,t.label=e.label,t.skyflowID=e.skyflowID,n.push(t)}))})),o.elementName=i?n[0].elementName:`${Ne}:group:${btoa(o.name)}`,i&&!t(this,hi,"f")[n[0].elementName]&&t(this,Li,"f").call(this,n[0].name))throw new Ot(At.UNIQUE_ELEMENT_NAME,[`${n[0].name}`],!0);let s=t(this,hi,"f")[o.elementName];if(s)i?s.update(n[0]):s.update(o);else{const e=_i();s=new ri(e,o,t(this,pi,"f"),{containerId:t(this,Ii,"f"),isMounted:t(this,mi,"f"),type:this.type},i,t(this,Ai,"f"),t(this,yi,"f"),t(this,fi,"f"),t(this,Ti,"f")),t(this,hi,"f")[o.elementName]=s,t(this,Ni,"f")[e]=s}return i||n.forEach((e=>{const i=e.elementName;t(this,hi,"f")[i]?t(this,hi,"f")[i].update(e):t(this,hi,"f")[i]=this.create(e.elementType,s)})),s})),Oi.set(this,(e=>{Object.keys(t(this,hi,"f")).forEach((i=>{i===e&&delete t(this,hi,"f")[i]}))})),Ai.set(this,(e=>{e.forEach((e=>{t(this,Oi,"f").call(this,e)}))})),yi.set(this,(e=>{e.forEach((e=>{t(this,hi,"f")[e.elementName]&&t(this,hi,"f")[e.elementName].update(e)}))})),Li.set(this,(e=>{const i=Object.keys(t(this,hi,"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{Dt(t(this,pi,"f").clientJSON.config);if(Object.values(t(this,hi,"f")).forEach((e=>{if(!e.isMounted())throw new Ot(At.ELEMENTS_NOT_MOUNTED,[],!0);e.isValidElement()})),Object.prototype.hasOwnProperty.call(e,"tokens")&&!Mt(e.tokens))throw new Ot(At.INVALID_TOKENS_IN_COLLECT,[],!0);(null==e?void 0:e.additionalFields)&&Lt(e.additionalFields),(null==e?void 0:e.upsert)&&bt(null==e?void 0:e.upsert),ue.emit(Le+t(this,Ii,"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)?(Tt(`${JSON.stringify(null==e?void 0:e.error)}`,It.ERROR,t(this,fi,"f").logLevel),n(null==e?void 0:e.error)):(Tt(mt(Ie.COLLECT_SUBMIT_SUCCESS,Ri),It.LOG,t(this,fi,"f").logLevel),i(e))})),Tt(mt(Ie.EMIT_EVENT,Ri,Le),It.LOG,t(this,fi,"f").logLevel)}catch(e){Tt(`${e.message}`,It.ERROR,t(this,fi,"f").logLevel),n(e)}})),i(this,Ii,_i(),"f"),i(this,pi,n,"f"),i(this,Ni,o,"f"),i(this,fi,s,"f"),i(this,Ti,new Ze,"f");const r=ot({name:`${fe}:${t(this,Ii,"f")}:${t(this,fi,"f").logLevel}`});nt(r,{src:st()}),rt(r,Object.assign({},Fe)),Tt(mt(Ie.CREATE_COLLECT_CONTAINER,Ri),It.LOG,t(this,fi,"f").logLevel);const a=(e,o)=>{e.name===fe+t(this,Ii,"f")&&(o(Object.assign(Object.assign({},n),{clientJSON:Object.assign(Object.assign({},n.clientJSON),{config:Object.assign({},n.clientJSON.config)}),context:s})),i(this,mi,!0,"f"),t(this,Ti,"f")._emit(Ue,{containerId:t(this,Ii,"f")}),ue.target(Qe.IFRAME_SECURE_ORGIN).off(ye+t(this,Ii,"f"),a))};ue.target(Qe.IFRAME_SECURE_ORGIN).on(ye+t(this,Ii,"f"),a),document.body.append(r)}}Ii=new WeakMap,hi=new WeakMap,pi=new WeakMap,fi=new WeakMap,Ni=new WeakMap,Ti=new WeakMap,mi=new WeakMap,vi=new WeakMap,Oi=new WeakMap,Ai=new WeakMap,yi=new WeakMap,Li=new WeakMap;var Si=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},Ci=function(e){return e};var Di,Pi,bi,Mi,wi,Ui,ki,Yi,xi,Vi,Gi,Bi,Fi,ji,Xi,Wi,zi,$i,Ki,Hi,qi,Ji,Zi,Qi=o((function(e){return e&&e.length?Si(e,Ci):0}));class en{constructor(e,n){Di.set(this,void 0),Pi.set(this,void 0),this.type=Ln.COMPOSABLE,bi.set(this,!1),Mi.set(this,!1),this.update=e=>{i(this,Mi,!0,"f"),t(this,bi,"f")?(t(this,Pi,"f")._emit(Me,{elementName:t(this,Di,"f"),elementOptions:e}),i(this,Mi,!1,"f")):t(this,Mi,"f")&&t(this,Pi,"f").on(`${Et.READY}:${t(this,Di,"f")}`,(()=>{t(this,Pi,"f")._emit(Me,{elementName:t(this,Di,"f"),elementOptions:e}),i(this,bi,!0,"f"),i(this,Mi,!1,"f")}))},i(this,Di,e,"f"),i(this,Pi,n,"f"),t(this,Pi,"f").on(`${Et.READY}:${t(this,Di,"f")}`,(()=>{i(this,bi,!0,"f")}))}on(e,i){if(!Object.values(Ae).includes(e))throw new Ot(At.INVALID_EVENT_LISTENER,[],!0);if(!i)throw new Ot(At.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof i)throw new Ot(At.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);t(this,Pi,"f").on(`${e}:${t(this,Di,"f")}`,(e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,i(e)}))}}Di=new WeakMap,Pi=new WeakMap,bi=new WeakMap,Mi=new WeakMap;const tn="CollectContainer";class nn extends ui{constructor(e,n,o,a){super(),wi.set(this,void 0),Ui.set(this,{}),ki.set(this,void 0),Yi.set(this,{rows:[]}),xi.set(this,[]),Vi.set(this,void 0),Gi.set(this,void 0),Bi.set(this,void 0),Fi.set(this,!1),ji.set(this,void 0),Xi.set(this,void 0),this.type=Ln.COMPOSABLE,Wi.set(this,!1),zi.set(this,{}),this.create=(e,i={required:!1})=>{Pt(e,t(this,Vi,"f").logLevel);const n=ci(e),o=Ei(e.type,i,t(this,Vi,"f").logLevel),s=`${Ne}:${e.type}:${btoa(_i())}`;return t(this,xi,"f").push(Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column},e),o),{validations:n,elementName:s})),new en(s,t(this,Bi,"f"))},$i.set(this,((e,n=!1)=>{const o=[];if(i(this,zi,at(e),"f"),t(this,zi,"f").rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;ai(i,t),t.sensitive=t.sensitive||Ve[i].sensitive,t.replacePattern=t.replacePattern||Ve[i].replacePattern,t.mask=t.mask||Ve[i].mask,t.isMounted=!1,t.label=e.label,t.skyflowID=e.skyflowID,o.push(t)}))})),t(this,zi,"f").elementName=n?o[0].elementName:`${Ne}:group:${btoa(t(this,zi,"f").name)}`,n&&!t(this,Ui,"f")[o[0].elementName]&&t(this,Ji,"f").call(this,o[0].name))throw new Ot(At.UNIQUE_ELEMENT_NAME,[`${o[0].name}`],!0);let s=t(this,Ui,"f")[t(this,zi,"f").elementName];if(s)n?s.update(o[0]):s.update(t(this,zi,"f"));else{const e=_i();s=new ri(e,t(this,zi,"f"),t(this,ki,"f"),{containerId:t(this,wi,"f"),isMounted:t(this,Wi,"f"),type:this.type},!0,t(this,Hi,"f"),t(this,qi,"f"),t(this,Vi,"f"),t(this,Bi,"f")),t(this,Ui,"f")[t(this,zi,"f").elementName]=s,t(this,Gi,"f")[e]=s}return s})),Ki.set(this,(e=>{Object.keys(t(this,Ui,"f")).forEach((i=>{i===e&&delete t(this,Ui,"f")[i]}))})),Hi.set(this,(e=>{e.forEach((e=>{t(this,Ki,"f").call(this,e)}))})),qi.set(this,(e=>{e.forEach((e=>{t(this,Ui,"f")[e.elementName]&&t(this,Ui,"f")[e.elementName].update(e)}))})),Ji.set(this,(e=>{const i=Object.keys(t(this,Ui,"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(Ae).includes(e))throw new Ot(At.INVALID_EVENT_LISTENER,[],!0);if(!i)throw new Ot(At.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof i)throw new Ot(At.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);t(this,Bi,"f").on(Ae.SUBMIT,(()=>{i()}))},this.mount=e=>{if(!e)throw new Ot(At.EMPTY_ELEMENT_IN_MOUNT,["CollectElement"],!0);const{layout:n}=t(this,ji,"f");if(Qi(n)!==t(this,xi,"f").length)throw new Ot(At.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM,[],!0);let o=0;if(n.forEach(((e,i)=>{t(this,Yi,"f").rows=[...t(this,Yi,"f").rows,{elements:[]}];for(let n=0;n<e;n++)t(this,Yi,"f").rows[i].elements.push(t(this,xi,"f")[o]),o++})),t(this,ji,"f").styles&&(t(this,Yi,"f").styles=Object.assign({},t(this,ji,"f").styles)),t(this,ji,"f").errorTextStyles&&(t(this,Yi,"f").errorTextStyles=Object.assign({},t(this,ji,"f").errorTextStyles)),t(this,Wi,"f"))return i(this,Xi,t(this,$i,"f").call(this,t(this,Yi,"f"),!1),"f"),t(this,Xi,"f").mount(e),void i(this,Fi,!0,"f");t(this,Bi,"f").on(we+t(this,wi,"f"),(()=>{i(this,Xi,t(this,$i,"f").call(this,t(this,Yi,"f"),!1),"f"),t(this,Xi,"f").mount(e),i(this,Fi,!0,"f")}))},this.unmount=()=>{t(this,Xi,"f").unmount()},this.collect=(e={tokens:!0})=>new Promise(((i,n)=>{try{if(Dt(t(this,ki,"f").clientJSON.config),!t(this,Fi,"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}di(t(this,zi,"f")).forEach((e=>{if(!(null==e?void 0:e.isMounted))throw new Ot(At.ELEMENTS_NOT_MOUNTED,[],!0)}));if(Object.values(t(this,Ui,"f")).forEach((e=>{e.isValidElement()})),e&&e.tokens&&"boolean"!=typeof e.tokens)throw new Ot(At.INVALID_TOKENS_IN_COLLECT,[],!0);(null==e?void 0:e.additionalFields)&&Lt(e.additionalFields),(null==e?void 0:e.upsert)&&bt(null==e?void 0:e.upsert),ue.emit(Le+t(this,wi,"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)?(Tt(`${JSON.stringify(null==e?void 0:e.error)}`,It.ERROR,t(this,Vi,"f").logLevel),n(null==e?void 0:e.error)):(Tt(mt(Ie.COLLECT_SUBMIT_SUCCESS,tn),It.LOG,t(this,Vi,"f").logLevel),i(e))})),Tt(mt(Ie.EMIT_EVENT,tn,Le),It.LOG,t(this,Vi,"f").logLevel)}catch(e){Tt(`${e.message}`,It.ERROR,t(this,Vi,"f").logLevel),n(e)}})),Zi.set(this,(()=>{t(this,Bi,"f").on(Me,(e=>{let i;const n=t(this,xi,"f").map(((t,n)=>t.elementName===e.elementName?(i=n,Object.assign({elementName:t.elementName},e.elementOptions)):t));t(this,Xi,"f")&&t(this,Xi,"f").updateElement(Object.assign({},n[i]))}))})),i(this,wi,_i(),"f"),i(this,ki,n,"f"),i(this,Gi,o,"f"),i(this,Vi,a,"f"),i(this,ji,e,"f"),i(this,Bi,new Ze,"f");const l=ot({name:`${fe}:${t(this,wi,"f")}:${t(this,Vi,"f").logLevel}`});nt(l,{src:st()}),rt(l,Object.assign({},Fe)),Tt(mt(Ie.CREATE_COLLECT_CONTAINER,tn),It.LOG,t(this,Vi,"f").logLevel);const d=(e,o)=>{e.name===fe+t(this,wi,"f")&&(o(Object.assign(Object.assign({},n),{clientJSON:Object.assign(Object.assign({},n.clientJSON),{config:Object.assign({},n.clientJSON.config)}),context:a})),i(this,Wi,!0,"f"),t(this,Bi,"f")._emit(we+t(this,wi,"f"),{containerId:t(this,wi,"f")}),ue.target(Qe.IFRAME_SECURE_ORGIN).off(ye+t(this,wi,"f"),d))};ue.target(Qe.IFRAME_SECURE_ORGIN).on(ye+t(this,wi,"f"),d),document.body.append(l),t(this,Zi,"f").call(this)}}var on,sn,rn,an;wi=new WeakMap,Ui=new WeakMap,ki=new WeakMap,Yi=new WeakMap,xi=new WeakMap,Vi=new WeakMap,Gi=new WeakMap,Bi=new WeakMap,Fi=new WeakMap,ji=new WeakMap,Xi=new WeakMap,Wi=new WeakMap,zi=new WeakMap,$i=new WeakMap,Ki=new WeakMap,Hi=new WeakMap,qi=new WeakMap,Ji=new WeakMap,Zi=new WeakMap;const ln="SkyflowContainer";class dn{constructor(e,n){var o,s;on.set(this,void 0),sn.set(this,void 0),rn.set(this,!1),an.set(this,void 0),i(this,sn,e,"f"),i(this,on,(null===(s=null===(o=t(this,sn,"f").toJSON())||void 0===o?void 0:o.metaData)||void 0===s?void 0:s.uuid)||"","f"),i(this,an,n,"f");const r=ot({name:`skyflow_controller:${t(this,on,"f")}`});nt(r,{src:st()}),rt(r,Object.assign({},Fe)),document.body.append(r),ue.target(Qe.IFRAME_SECURE_ORGIN).on(De+t(this,on,"f"),((e,o)=>{Tt(mt(Ie.CAPTURE_PUREJS_FRAME,ln),It.LOG,t(this,an,"f").logLevel),o({client:t(this,sn,"f"),context:n}),i(this,rn,!0,"f")})),Tt(mt(Ie.PUREJS_CONTROLLER_INITIALIZED,ln),It.LOG,t(this,an,"f").logLevel)}insert(e,i){return t(this,rn,"f")?new Promise(((n,o)=>{Dt(t(this,sn,"f").config);try{Tt(mt(Ie.VALIDATE_RECORDS,ln),It.LOG,t(this,an,"f").logLevel),(null==(i=i?Object.assign(Object.assign({},i),{tokens:void 0===(null==i?void 0:i.tokens)||i.tokens}):{tokens:!0})?void 0:i.upsert)&&bt(i.upsert),yt(e,i),ue.emit(Ce+t(this,on,"f"),{type:Te,records:e,options:i},(e=>{e.error?(Tt(`${JSON.stringify(e.error)}`,It.ERROR,t(this,an,"f").logLevel),o(e.error)):n(e)})),Tt(mt(Ie.EMIT_PURE_JS_REQUEST,ln,Te),It.LOG,t(this,an,"f").logLevel)}catch(e){Tt(e.message,It.ERROR,t(this,an,"f").logLevel),o(e)}})):new Promise(((n,o)=>{try{Dt(t(this,sn,"f").config),Tt(mt(Ie.VALIDATE_RECORDS,ln),It.LOG,t(this,an,"f").logLevel),(null==(i=i?Object.assign(Object.assign({},i),{tokens:void 0===(null==i?void 0:i.tokens)||i.tokens}):{tokens:!0})?void 0:i.upsert)&&bt(i.upsert),yt(e,i),ue.target(Qe.IFRAME_SECURE_ORGIN).on(De+t(this,on,"f"),(()=>{ue.emit(Ce+t(this,on,"f"),{type:Te,records:e,options:i},(e=>{e.error?(Tt(`${JSON.stringify(e.error)}`,It.ERROR,t(this,an,"f").logLevel),o(e.error)):n(e)}))})),Tt(mt(Ie.EMIT_PURE_JS_REQUEST,ln,Te),It.LOG,t(this,an,"f").logLevel)}catch(e){Tt(e.message,It.ERROR,t(this,an,"f").logLevel),o(e)}}))}getById(e){return t(this,rn,"f")?new Promise(((i,n)=>{Dt(t(this,sn,"f").config);try{Tt(mt(Ie.VALIDATE_GET_BY_ID_INPUT,ln),It.LOG,t(this,an,"f").logLevel),gt(e),Tt(mt(Ie.EMIT_PURE_JS_REQUEST,ln,me),It.LOG,t(this,an,"f").logLevel)}catch(e){Tt(e.message,It.ERROR,t(this,an,"f").logLevel),n(e)}})):new Promise(((i,n)=>{try{Dt(t(this,sn,"f").config),Tt(mt(Ie.VALIDATE_GET_BY_ID_INPUT,ln),It.LOG,t(this,an,"f").logLevel),gt(e),Tt(mt(Ie.EMIT_PURE_JS_REQUEST,ln,me),It.LOG,t(this,an,"f").logLevel)}catch(e){Tt(e.message,It.ERROR,t(this,an,"f").logLevel),n(e)}}))}get(e,i){return t(this,rn,"f")?new Promise(((n,o)=>{Dt(t(this,sn,"f").config);try{Tt(mt(Ie.VALIDATE_GET_INPUT,ln),It.LOG,t(this,an,"f").logLevel),Rt(e,i),Tt(mt(Ie.EMIT_PURE_JS_REQUEST,ln,ve),It.LOG,t(this,an,"f").logLevel)}catch(e){Tt(e.message,It.ERROR,t(this,an,"f").logLevel),o(e)}})):new Promise(((n,o)=>{try{Dt(t(this,sn,"f").config),Tt(mt(Ie.VALIDATE_GET_INPUT,ln),It.LOG,t(this,an,"f").logLevel),Rt(e,i),Tt(mt(Ie.EMIT_PURE_JS_REQUEST,ln,ve),It.LOG,t(this,an,"f").logLevel)}catch(e){Tt(e.message,It.ERROR,t(this,an,"f").logLevel),o(e)}}))}delete(e,i){return t(this,rn,"f")?new Promise(((n,o)=>{Dt(t(this,sn,"f").config);try{Tt(mt(Ie.VALIDATE_DELETE_INPUT,ln),It.LOG,t(this,an,"f").logLevel),St(e),ue.emit(Ce+t(this,on,"f"),{type:Oe,records:e,options:i},(e=>{e.error?(Tt(`${JSON.stringify(e.error)}`,It.ERROR,t(this,an,"f").logLevel),o(e.error)):n(e)})),Tt(mt(Ie.EMIT_PURE_JS_REQUEST,ln,Oe),It.LOG,t(this,an,"f").logLevel)}catch(e){Tt(e.message,It.ERROR,t(this,an,"f").logLevel),o(e)}})):new Promise(((n,o)=>{try{Dt(t(this,sn,"f").config),Tt(mt(Ie.VALIDATE_RECORDS,ln),It.LOG,t(this,an,"f").logLevel),St(e),ue.target(Qe.IFRAME_SECURE_ORGIN).on(De+t(this,on,"f"),(()=>{ue.emit(Ce+t(this,on,"f"),{type:Oe,records:e,options:i},(e=>{e.error?(Tt(`${JSON.stringify(e.error)}`,It.ERROR,t(this,an,"f").logLevel),o(e.error)):n(e)}))})),Tt(mt(Ie.EMIT_PURE_JS_REQUEST,ln,Oe),It.LOG,t(this,an,"f").logLevel)}catch(e){Tt(e.message,It.ERROR,t(this,an,"f").logLevel),o(e)}}))}}function cn(e){this.message=e}on=new WeakMap,sn=new WeakMap,rn=new WeakMap,an=new WeakMap,cn.prototype=new Error,cn.prototype.name="InvalidCharacterError";var En="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new cn("'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 _n(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(En(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 En(t)}}function un(e){this.message=e}un.prototype=new Error,un.prototype.name="InvalidTokenError";const In=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 un("Invalid token specified");var i=!0===(t=t||{}).header?0:1;try{return JSON.parse(_n(e.split(".")[i]))}catch(e){throw new un("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 hn,pn,fn,Nn,Tn,mn,vn,On,An,yn,Ln,Rn={name:"skyflow-js",preferGlobal:!0,analyze:!1,version:"1.30.1",author:"Skyflow",description:"Skyflow JavaScript SDK"};class gn{constructor(e,n){hn.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,E,_;let u=null,I=null;return/Windows/.test(e)?(u="Windows",I=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)?(u="Android",I=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)?(u="iOS",I=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)?(u="Mac OS X",I=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)&&(u="Linux",I=null!==(_=null===(E=/Linux( \w+)*?\/([\w.]+)/.exec(e))||void 0===E?void 0:E[2])&&void 0!==_?_:null),{os:u,version:I}}(i.userAgent),E=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 _;return{sdk_name_version:d,sdk_client_device_model:(_=i.userAgent,/(ipad|tablet)/gi.test(_)?"tablet":/Mobile|iP(hone|od)|Android|BlackBerry|IEMobile/.test(_)?"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=E.browserName)&&void 0!==r?r:""} ${null!==(a=E.browserVersion)&&void 0!==a?a:""}`}}(Rn,t(this,hn,"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(He.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(He.FORMURLENCODED))||(null===(a=null===(r=e.headers)||void 0===r?void 0:r["content-type"])||void 0===a?void 0:a.includes(He.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 Ot({code:l.status,description:i},[],!0))}else a&&a.includes("text/plain")?n(new Ot({code:l.status,description:d?`${l.response} - requestId: ${d}`:l.response},[],!0)):n(new Ot({code:l.status,description:d?`${he.ERROR_OCCURED} - requestId: ${d}`:he.ERROR_OCCURED},[],!0));a&&a.includes("application/json")&&i(JSON.parse(l.response)),i(l.response)},l.onerror=()=>{n(new Ot(At.NETWORK_ERROR,[],!0))}}else n(new Ot(At.CONNECTION_ERROR,[],!0))})),this.config=e,i(this,hn,n,"f")}toJSON(){return{config:this.config,metaData:t(this,hn,"f")}}static fromJSON(e){return new gn(e.config,e.metaData)}}hn=new WeakMap,function(e){e.COLLECT="COLLECT",e.COMPOSABLE="COMPOSABLE"}(Ln||(Ln={}));const Sn="Skyflow";class Cn{constructor(e){var n,o;pn.set(this,void 0),fn.set(this,_i()),Nn.set(this,{uuid:t(this,fn,"f"),clientDomain:window.location.origin}),Tn.set(this,void 0),mn.set(this,""),vn.set(this,void 0),On.set(this,void 0),An.set(this,void 0),yn.set(this,void 0);const s=localStorage.getItem("sdk_version")||"";t(this,Nn,"f").sdkVersion=s,i(this,pn,new gn(Object.assign({},e),t(this,Nn,"f")),"f"),i(this,On,(null===(n=null==e?void 0:e.options)||void 0===n?void 0:n.logLevel)||_t.ERROR,"f"),i(this,An,(null===(o=null==e?void 0:e.options)||void 0===o?void 0:o.env)||ut.PROD,"f"),i(this,yn,{},"f"),i(this,Tn,new dn(t(this,pn,"f"),{logLevel:t(this,On,"f"),env:t(this,An,"f")}),"f");ue.target(Qe.IFRAME_SECURE_ORGIN).on(Pe+t(this,fn,"f"),((e,n)=>{Tt(mt(Ie.CAPTURED_BEARER_TOKEN_EVENT,Sn),It.LOG,t(this,On,"f")),!t(this,pn,"f").config.getBearerToken||t(this,mn,"f")&&In(t(this,mn,"f"))?(Tt(mt(Ie.REUSE_BEARER_TOKEN,Sn),It.LOG,t(this,On,"f")),n({authToken:t(this,mn,"f")})):t(this,pn,"f").config.getBearerToken().then((e=>{In(e)?(Tt(mt(Ie.BEARER_TOKEN_RESOLVED,Sn),It.LOG,t(this,On,"f")),i(this,mn,e,"f"),n({authToken:t(this,mn,"f")})):(Tt(he.INVALID_BEARER_TOKEN,It.ERROR,t(this,On,"f")),n({error:he.INVALID_BEARER_TOKEN}))})).catch((e=>{Tt(he.BEARER_TOKEN_REJECTED,It.ERROR,t(this,On,"f")),n({error:e})}))})),Tt(mt(Ie.BEARER_TOKEN_LISTENER,Sn),It.LOG,t(this,On,"f")),Tt(mt(Ie.CURRENT_ENV,Sn,t(this,An,"f")),It.LOG,t(this,On,"f")),Tt(mt(Ie.CURRENT_LOG_LEVEL,Sn,t(this,On,"f")),It.LOG,t(this,On,"f"))}static init(e){var t;const i=(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||_t.ERROR;kt(e),Tt(mt(Ie.INITIALIZE_CLIENT,Sn),It.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 Cn(n);return Tt(mt(Ie.CLIENT_INITIALIZED,Sn),It.LOG,i),s}container(e,i){switch(e){case Ln.COLLECT:{const n=new gi(i,Object.assign(Object.assign({},t(this,Nn,"f")),{clientJSON:t(this,pn,"f").toJSON(),containerType:e}),t(this,yn,"f"),{logLevel:t(this,On,"f"),env:t(this,An,"f")});return Tt(mt(Ie.COLLECT_CONTAINER_CREATED,Sn),It.LOG,t(this,On,"f")),n}case Ln.COMPOSABLE:{(e=>{if(!e)throw new Ot(At.MISSING_COMPOSABLE_CONTAINER_OPTIONS,[],!0);if("object"!=typeof e)throw new Ot(At.INVALID_COMPOSABLE_CONTAINER_OPTIONS,[],!0);if(!Object.prototype.hasOwnProperty.call(e,"layout"))throw new Ot(At.MISSING_COMPOSABLE_LAYOUT_KEY,[],!0);if(!e.layout)throw new Ot(At.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(!Array.isArray(e.layout))throw new Ot(At.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(0===e.layout.length)throw new Ot(At.EMPTY_COMPOSABLE_LAYOUT_ARRAY,[],!0);e.layout.forEach((e=>{if("number"!=typeof e)throw new Ot(At.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(e<0)throw new Ot(At.NEGATIVE_VALUES_COMPOSABLE_LAYOUT,[],!0)}))})(i);const n=new nn(i,Object.assign(Object.assign({},t(this,Nn,"f")),{clientJSON:t(this,pn,"f").toJSON(),containerType:e}),t(this,yn,"f"),{logLevel:t(this,On,"f"),env:t(this,An,"f")});return Tt(mt(Ie.COLLECT_CONTAINER_CREATED,Sn),It.LOG,t(this,On,"f")),n}default:if(!e)throw new Ot(At.EMPTY_CONTAINER_TYPE,[],!0);throw new Ot(At.INVALID_CONTAINER_TYPE,[],!0)}}insert(e,i){return Tt(mt(Ie.INSERT_TRIGGERED,Sn),It.LOG,t(this,On,"f")),t(this,Tn,"f").insert(e,i)}getById(e){return Tt(pe.GET_BY_ID_DEPRECATED,It.WARN,t(this,On,"f")),Tt(mt(Ie.GET_BY_ID_TRIGGERED,Sn),It.LOG,t(this,On,"f")),t(this,Tn,"f").getById(e)}get(e,i){return Tt(mt(Ie.GET_TRIGGERED,Sn),It.LOG,t(this,On,"f")),t(this,Tn,"f").get(e,i)}delete(e,i){return Tt(mt(Ie.DELETE_TRIGGERED,Sn),It.LOG,t(this,On,"f")),t(this,Tn,"f").delete(e,i)}static get ContainerType(){return Ln}static get ElementType(){return ke}static get RedactionType(){return dt}static get RequestMethod(){return ct}static get LogLevel(){return _t}static get EventName(){return Et}static get Env(){return ut}static get ValidationRuleType(){return ht}}pn=new WeakMap,fn=new WeakMap,Nn=new WeakMap,Tn=new WeakMap,mn=new WeakMap,vn=new WeakMap,On=new WeakMap,An=new WeakMap,yn=new WeakMap;class Dn{constructor(e){this.loadFunction=e,this.loadScript()}get loader(){return this.loadingPromise||(this.loadingPromise=this.loadScript()),this.loadingPromise}loadScript(){return e(this,void 0,void 0,(function*(){return this.loadingPromise||(this.loadingPromise=new Promise(((e,t)=>{this.loadFunction().then((t=>{t&&e(t)}),(()=>{t()})).catch((()=>{}))}))),this.loadingPromise}))}}class Pn extends P{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()}))}}class bn extends P{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 Pn(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 Mn extends bn{constructor(t,i,n){super("div",Object.assign(Object.assign({},n),{id:"payrails-apple-pay-button"})),this.sdkConfig=t,this.execution=i,this.options=n,this.appleButton=null,this.paymentExecutor=new A(t,i),this.loadScript=new Dn((()=>e(this,void 0,void 0,(function*(){const t=document.createElement("script");return t.src="https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js",new Promise(((i,n)=>{t.onload=()=>e(this,void 0,void 0,(function*(){var e,t,n;(yield this.isApplePayAvailable())?(null===(n=null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onApplePayAvailable)||void 0===n||n.call(t),i(!0)):i(!1)})),t.onerror=()=>{n()},document.body.appendChild(t)}))}))))}mount(t){super.mount(t),(()=>{e(this,void 0,void 0,(function*(){try{yield this.loadScript.loader,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()}isApplePayAvailable(){return e(this,void 0,void 0,(function*(){if(!(null===window||void 0===window?void 0:window.ApplePaySession))return!1;return yield ApplePaySession.canMakePayments()}))}mountApplePayButton(){var t,i,n,o,s;return e(this,void 0,void 0,(function*(){if(null===window||void 0===window?void 0:window.ApplePaySession)try{if(!this.isApplePayAvailable())return;null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onApplePayAvailable)||void 0===i||i.call(t);const e=(null===(n=this.options.styles)||void 0===n?void 0:n.type)||"buy",r=(null===(o=this.options.styles)||void 0===o?void 0:o.style)||"black";this.element.innerHTML=`<apple-pay-button buttonstyle="${r}" type="${e}" locale="en-GB"></apple-pay-button>`,null===(s=this.storeInstrumentCheckbox)||void 0===s||s.mount(this.selector);const a=this.element.querySelector("apple-pay-button");null==a||a.setAttribute("style","width: 100%;"),null==a||a.addEventListener("click",(()=>{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.onpaymentauthorized=t=>e(this,void 0,void 0,(function*(){var e,i,n,o,s,a,l,d,c,E,_,u;try{const E=yield this.onApplePayAuthorized(t.payment.token);if("authorizeSuccessful"===(null===(e=null==E?void 0:E.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(E))}catch(e){r.completePayment(ApplePaySession.STATUS_FAILURE),(null===(_=null===(E=this.options)||void 0===E?void 0:E.events)||void 0===_?void 0:_.onAuthorizeFailed)&&(null===(u=this.options)||void 0===u||u.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:R.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:wn,CVV:Un,CARDHOLDER_NAME:kn,EXPIRATION_MONTH:Yn,EXPIRATION_YEAR:xn}=exports.ElementType,Vn={base:{border:"none",padding:"10px 16px",color:"#1d1d1d",backgroundColor:"#fff"},invalid:{backgroundColor:"#f9e1e1",borderColor:"#f25226",border:"1px solid"}},Gn=[{type:kn,placeholder:"Card holder",styles:Object.assign(Object.assign({},Vn),{base:Object.assign(Object.assign({},Vn.base),{border:"1px solid #eae8ee",padding:"10px 16px",borderTopLeftRadius:"4px",borderTopRightRadius:"4px"})})},{type:wn,placeholder:"1234 1234 1234 1234",styles:Object.assign(Object.assign({},Vn),{base:Object.assign(Object.assign({},Vn.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:Yn,placeholder:"MM",styles:Object.assign(Object.assign({},Vn),{base:Object.assign(Object.assign({},Vn.base),{borderBottom:"1px solid #eae8ee",borderLeft:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomLeftRadius:"4px"})})},{type:xn,placeholder:"YY",format:"YY",styles:Object.assign(Object.assign({},Vn),{base:Object.assign(Object.assign({},Vn.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee"})})},{type:Un,placeholder:"CVC",styles:Object.assign(Object.assign({},Vn),{base:Object.assign(Object.assign({},Vn.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomRightRadius:"4px"})})}];class Bn extends bn{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."),Gn.forEach((({type:e,styles:i,format:n,placeholder:o})=>{var s,r,a,l,d,c,E;if(!(null===(s=this.options)||void 0===s?void 0:s.showCardHolderName)&&e===exports.ElementType.CARDHOLDER_NAME)return;const _=new Fn(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===(E=null===(c=this.options)||void 0===c?void 0:c.events)||void 0===E?void 0:E.onFocus,onChange:this.onChange.bind(this),onReady:this.triggerOnReady.bind(this)}});this.formFields.push(_)})),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({},Vn.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 Fn{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 jn extends P{constructor(e,t){super("div",{id:"payrails-card-list"}),this.workflowExecution=e,this.listItems=[],this.workflowExecution.savedCreditCards.forEach((e=>{const i=new Xn((()=>{(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 Xn extends P{constructor(e,t){super("div",{className:"payrails-card-list-item",id:`payrails-card-list-item-${t.id}`});const{id:i}=t,n=this.createCardLabel(t),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.innerText=n,o.appendChild(r),this.element.appendChild(o)}createCardLabel({data:e={}}){return`****${null==e?void 0:e.suffix}`}}class Wn extends P{constructor(e="Authorization failed, please try again."){super("div",{id:"authorization-failed-message"}),this.element.innerText=e,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>${e}</div>`,this.element.addEventListener("click",(e=>{e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),this.unmount()}))}}class zn extends P{constructor(e){var t;super("div",{id:"payrails-authorization-success-msg"}),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`}}class $n extends P{constructor(e,t,i,n){super("div",{id:e,className:"payrails-dropin-item"}),this.events=i,this.styles=n,this.isActive=!1,this.applyBaseStyles();const o=`payrails-dropin-item-${e}`,s=document.createElement("label");s.setAttribute("for",o);const r=document.createElement("input");r.setAttribute("type","radio"),r.setAttribute("name","payment-option"),r.setAttribute("id",o),r.setAttribute("value",o),this.input=r,s.appendChild(r),this.label=s;const a=document.createElement("span");s.appendChild(a),a.innerText=t,this.element.appendChild(s)}get identifier(){return`payrails-dropin-item-${this.id}`}deactivate(){var e,t;this.isActive&&(this.isActive=!1,this.label.style.marginBottom="0",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;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;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.label.style.marginBottom="8px",this.applyActiveStyles(),this.isActive=!0,(null===(t=this.events)||void 0===t?void 0:t.onActivate)&&this.events.onActivate())}}class Kn extends $n{constructor(){super(...arguments),this.buttonShown=!1}activate(){if(!this.buttonShown)return super.activate(),void(this.buttonShown=!0);this.label.style.marginBottom="8px",this.applyActiveStyles(),this.isActive=!0,this.element.querySelector(this.component.selector).style.display="block"}deactivate(){this.isActive&&(this.isActive=!1,this.label.style.marginBottom="0",this.applyBaseStyles(),this.element.querySelector(this.component.selector).style.display="none")}mountAfterAvailable(){super.mount(`#${this.loadElementId}`)}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 Hn extends Kn{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,i.styles),this.loadElementId="apple-pay-dropin-load-element",this.component=new Mn(e,t,Object.assign(Object.assign({},i),{events:{onApplePayAvailable:()=>{this.mountAfterAvailable()}}}))}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)}}class qn extends $n{constructor(e,t,i){super("payrails-credit-card-wrapper","Card",void 0,i),this.cardForm=e,this.paymentButton=t,this.cardFormShown=!1,this.component=new Jn(e,t)}activate(){var e,t;this.label.style.marginBottom="8px",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.label.style.marginBottom="0",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 Jn extends P{constructor(e,t){super("div",{id:"payrails-form-container"}),this.subElements.push(e,t)}}const Zn={label:"Generic redirect"};class Qn extends P{constructor(e,t,i,n){super("div",{id:"payrails-generic-redirect-button"}),this.sdkConfig=e,this.execution=t,this.options=i,this.returnLinks=n,this.button=document.createElement("button"),this.element.appendChild(this.configureButton()),this.paymentExecutor=new A(e,t,this.returnLinks)}onClick(){var t,i,n,o,r,a;return e(this,void 0,void 0,(function*(){console.log("Redirecting...");try{yield null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onPaymentButtonClicked)||void 0===i?void 0:i.call(t)}catch(e){null===(o=null===(n=this.options.events)||void 0===n?void 0:n.onAuthorizeFailed)||void 0===o||o.call(n,e)}try{const e=(yield this.paymentExecutor.pay([{paymentMethodCode:R.GENERIC_REDIRECT,integrationType:"api",amount:this.sdkConfig.amount}])).response.links.redirect;if(!e)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK);window.location.href=e}catch(e){null===(a=null===(r=this.options.events)||void 0===r?void 0:r.onAuthorizeFailed)||void 0===a||a.call(r)}}))}configureButton(){var e,t;return this.button.textContent=null!==(t=null===(e=this.options.translations)||void 0===e?void 0:e.label)&&void 0!==t?t:Zn.label,this.options.styles&&Object.assign(this.button.style,this.options.styles),this.button}mount(e){var t;null===(t=document.querySelector(e))||void 0===t||t.appendChild(this.element),this.element.addEventListener("click",this.onClick.bind(this))}}const eo={translations:{label:"Mercadopago",button:{label:"Pay with mercadgopago"}}};class to extends $n{constructor(e,t,i,n){var o,s,r;super("payrails-generic-redirect-dropin",(null===(o=null==i?void 0:i.translations)||void 0===o?void 0:o.label)||eo.translations.label,null==i?void 0:i.events,null==i?void 0:i.styles),this.sdkConfig=e,this.execution=t,this.returnLinks=n,this.component=new Qn(this.sdkConfig,this.execution,{styles:null===(s=null==i?void 0:i.styles)||void 0===s?void 0:s.button,translations:(null===(r=null==i?void 0:i.translations)||void 0===r?void 0:r.button)||eo.translations.button},this.returnLinks)}}const io={apiVersion:2,apiVersionMinor:0};class no extends bn{constructor(t,i,n){super("div",Object.assign(Object.assign({},n),{id:"payrails-google-pay-button"})),this.sdkConfig=t,this.execution=i,this.options=n,this.googleButton=null,this.paymentExecutor=new A(t,i),this.loadScript=new Dn((()=>e(this,void 0,void 0,(function*(){const e=document.createElement("script");return e.src="https://pay.google.com/gp/p/js/pay.js",new Promise(((t,i)=>{e.onload=()=>{const e=new google.payments.api.PaymentsClient({environment:this.options.environment||"TEST",merchantInfo:this.options.merchantInfo}),n=Object.assign(Object.assign({},io),{allowedPaymentMethods:this.execution.googlePayConfig});e.isReadyToPay(n).then((n=>{var o,s,r;n?(null===(r=null===(s=null===(o=this.options)||void 0===o?void 0:o.events)||void 0===s?void 0:s.onGooglePayAvailable)||void 0===r||r.call(s),t(e)):i()}),i)},e.onerror=()=>{i()},document.body.appendChild(e)}))}))))}sdkLoaded(t){var i,n,o,a,l,d,c,E;return e(this,void 0,void 0,(function*(){try{const s=(null===(n=null===(i=this.options)||void 0===i?void 0:i.styles)||void 0===n?void 0:n.buttonColor)||"black",r=(null===(a=null===(o=this.options)||void 0===o?void 0:o.styles)||void 0===a?void 0:a.buttonType)||"long",_=(null===(d=null===(l=this.options)||void 0===l?void 0:l.styles)||void 0===d?void 0:d.buttonSizeMode)||"fill",u=(null===(E=null===(c=this.options)||void 0===c?void 0:c.styles)||void 0===E?void 0:E.buttonLocale)||void 0;return this.googleButton=t.createButton({buttonColor:s,buttonType:r,buttonSizeMode:_,buttonLocale:u,onClick:()=>e(this,void 0,void 0,(function*(){var e,t,i;if(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onPaymentButtonClicked){if(!(yield null===(i=this.options)||void 0===i?void 0:i.events.onPaymentButtonClicked()))return}yield this.onPaymentButtonClicked()})),allowedPaymentMethods:this.execution.googlePayConfig}),this.element.appendChild(this.googleButton),this.googleButton}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_GPAY_LOADING_ERROR,{cause:e,description:e.message});throw r.PayrailsLogger.error(t.message,{error:t}),t}}))}onLoadPaymentData(t){var i,n,o,s,r,a,l,d;return e(this,void 0,void 0,(function*(){const e=[{paymentMethodCode:R.GOOGLE_PAY,integrationType:"api",paymentInstrumentData:Object.assign(Object.assign({},t),{paymentToken:t.paymentMethodData.tokenizationData.token}),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 C(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)}))}onPaymentButtonClicked(){var t,i,n,o,s,r,a,l;return e(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},io),{allowedPaymentMethods:this.execution.googlePayConfig,transactionInfo:{totalPriceStatus:"FINAL",totalPrice:null===(t=this.sdkConfig.amount)||void 0===t?void 0:t.value,currencyCode:null===(i=this.sdkConfig.amount)||void 0===i?void 0:i.currency,countryCode:null===(r=null===(s=null===(o=null===(n=this.execution.meta)||void 0===n?void 0:n.order)||void 0===o?void 0:o.billingAddress)||void 0===s?void 0:s.country)||void 0===r?void 0:r.code},merchantInfo:{merchantId:(null===(a=this.options.merchantInfo)||void 0===a?void 0:a.merchantId)||"",merchantName:(null===(l=this.options.merchantInfo)||void 0===l?void 0:l.merchantName)||""}});(yield this.loadScript.loader).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{const t=yield this.loadScript.loader,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()}}class oo extends Kn{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.styles),this.loadElementId="google-pay-dropin-load-element",this.component=new no(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},i.events),{onGooglePayAvailable:()=>{this.mountAfterAvailable()}})}))}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)}}
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.
@@ -17,8 +17,8 @@ Copyright (c) 2022 Skyflow, Inc.
17
17
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
18
  * See the License for the specific language governing permissions and
19
19
  * limitations under the License.
20
- */function Qn(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(eo(n)),dataAttributes:o}}function eo(e){var t="";return Object.keys(e).forEach((function(i){0!==t.length&&(t+="&"),t+=i+"="+e[i]})),t}function to(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 io(e,t){if(void 0===t&&(t=no()),so(e,t),"undefined"==typeof window)return t.resolve(null);var i=Qn(e),n=i.url,o=i.dataAttributes,s=o["data-namespace"]||"paypal",r=oo(s);return function(e,t){var i=document.querySelector('script[src="'.concat(e,'"]'));if(null===i)return null;var n=to(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=no());so(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=to(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=oo(s);if(e)return e;throw new Error("The window.".concat(s," global variable is not available."))}))}function no(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function oo(e){return window[e]}function so(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.")}class ro extends Cn{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===(e=this.button)||void 0===e||e.close(),this.paypalLoader=null,this.paypalLoader=new Sn(this.loadPaypal.bind(this)),this.button=yield this.paypalLoader.loader,this.button.render(`#${this.buttonWrapperId}`),null===(o=null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n?void 0:n.onSaveInstrumentCheckboxChanged)||void 0===o||o.call(n,t)}))})})),this.sdkConfig=t,this.execution=i,this.options=n,this.paypalLoader=null,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:"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 ao("No order id returned");return this.confirmLink=null===(r=l.response.links.confirm)||void 0===r?void 0:r.href,d})),this.element.innerHTML=`<div id="${this.buttonWrapperId}"></div><div id="${this.checkboxWrapperId}"></div>`,this.paymentExecutor=new A(t,i),this.paypalLoader=new Sn(this.loadPaypal.bind(this)),this.fraudNetGuid=null==n?void 0:n.fraudNetGuid}loadPaypal(){return e(this,void 0,void 0,(function*(){try{const e=this.execution.paypalConfig,t=this.shouldStoreInstrument?"tokenize":"Instant"===this.execution.paypalConfig.captureMode?"capture":"authorize",i=yield io({"client-id":e.clientId,components:"buttons,funding-eligibility",intent:t,currency:this.sdkConfig.amount.currency,vault:this.shouldStoreInstrument,"data-namespace":"payrailsPaypal"});return i&&(yield this.createPaypalButton(i))}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR,{cause:e});throw r.PayrailsLogger.error(t.message,{error:t}),t}}))}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=yield t.Buttons(this.createPayPalButtonConfig());return e.isEligible()?(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):null}))}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:"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,t;if(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onPaymentButtonClicked){return(yield this.options.events.onPaymentButtonClicked())?i.resolve():i.reject()}}))}}approvePayment(t){var i,n,o,s,r,a,l,d,c,E;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 ao("No confirm link");const e={};this.shouldStoreInstrument&&t.billingToken&&(e.tokenId=t.billingToken),this.fraudNetGuid&&(e.riskSessionCorrelationId=this.fraudNetGuid);const _=yield this.paymentExecutor.confirm(this.confirmLink,e);"authorizeSuccessful"===(null===(s=_.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===(E=null===(c=null===(d=this.options)||void 0===d?void 0:d.events)||void 0===c?void 0:c.onAuthorizeFailed)||void 0===E||E.call(c)}))}mount(t){super.mount(t),(()=>{e(this,void 0,void 0,(function*(){var e;this.paypalLoader||(this.paypalLoader=new Sn(this.loadPaypal.bind(this)));const t=yield this.paypalLoader.loader;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 lo(e.message,e);throw r.PayrailsLogger.error(t.message,{error:t}),t}}))})()}unmount(){var e;null===(e=this.button)||void 0===e||e.close(),this.paypalLoader=null,super.unmount()}}class ao extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION,{description:`PaypalOrderError: ${e}`,cause:t})}}class lo extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT,{description:`PaypalButtonError: ${e}`,cause:t})}}class co extends $n{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,null==i?void 0:i.styles),this.loadElementId="paypal-dropin-load-element",this.component=new ro(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},null==i?void 0:i.events),{onPaypalAvailable:()=>{this.mountAfterAvailable()}})}))}}class Eo extends Wn{constructor(e,t,i,n){var o,s,r;const a=e.paymentMethod===L.PAYPAL?`${null===(o=e.data)||void 0===o?void 0:o.email}`:`${null===(s=e.data)||void 0===s?void 0:s.bin}**${null===(r=e.data)||void 0===r?void 0:r.suffix}`;super(`payrails-payment-instrument-${e.id}`,a,{onActivate:()=>{i(e),this.component.setDisabled(!1)}},n),this.component=t}}class _o extends D{constructor(e,t,i,n,o,s){var r,a;super("fieldset",{id:"payrails-dropin-component"}),this.collectContainer=e,this.clientConfig=t,this.dropinConfig=i,this.execution=n,this.sdkConfig=o,this.returnLinks=s;void 0!==(null===(a=null===(r=this.dropinConfig.paymentMethodsConfiguration)||void 0===r?void 0:r.cards)||void 0===a?void 0:a.showExistingCards)&&console.warn("The `showExistingCards` option is deprecated and will be removed in a future version. Please use `showStoredInstruments` instead.");const l=new Map;this.execution.storedPaymentInstruments.forEach((e=>{if(this.isStoredInstrumentEnabled(e.paymentMethod)){this.cardPaymentButton=this.createCardPaymentButton();const t=this.createStoredInstrumentElement(e);l.set(t.identifier,t)}}));const d={[L.CARD]:this.createCreditCardButton.bind(this),[L.PAYPAL]:this.createPayPalButton.bind(this),[L.GOOGLE_PAY]:this.createGooglePayButton.bind(this),[L.APPLE_PAY]:this.createApplePayButton.bind(this)};this.execution.availablePaymentMethods.forEach((({paymentMethodCode:e})=>{if(e&&d[e]){d[e];const t=d[e]();l.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)||"";l.forEach((e=>{e.deactivate()})),null===(i=l.get(n))||void 0===i||i.activate()})),this.subElements.push(...Array.from(l.values()))}createStoredInstrumentElement(e){var t;return this.cardPaymentButton=this.createCardPaymentButton(),new Eo(e,this.cardPaymentButton,(e=>{this.cardPaymentButton&&(this.cardPaymentButton.selectedInstrument=e)}),null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.element)}createCreditCardButton(){var e;return this.creditCard=new Kn(this.createCardForm(),this.createCardPaymentButton(),null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.element),this.creditCard}createGooglePayButton(){var e,t,i,n;return this.googlePay=new Zn(this.sdkConfig,this.execution,Object.assign({environment:this.clientConfig.environment||"TEST",events:{onAuthorizeSuccess:this.onAuthorizeSuccess.bind(this),onAuthorizeFailed:this.onAuthorizeFailed.bind(this),onPaymentButtonClicked:null===(e=this.dropinConfig.events)||void 0===e?void 0:e.onPaymentButtonClicked},styles:Object.assign(Object.assign({},null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.googlePayButton),null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.element)},null===(n=this.dropinConfig.paymentMethodsConfiguration)||void 0===n?void 0:n.googlePay)),this.googlePay}createPayPalButton(){var e,t,i;return this.paypal=new co(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:{onAuthorizeSuccess:this.onAuthorizeSuccess.bind(this),onAuthorizeFailed:this.onAuthorizeFailed.bind(this),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)}}})),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 Vn(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:{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,n;return this.applePay=new zn(this.sdkConfig,this.execution,Object.assign(Object.assign({events:{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()},onAuthorizeFailed:this.onAuthorizeFailed.bind(this),onPaymentButtonClicked:null===(e=this.dropinConfig.events)||void 0===e?void 0:e.onPaymentButtonClicked}},null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.applePay),{styles:Object.assign(Object.assign({},null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.applePayButton),null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.element)})),this.applePay}createCardPaymentButton(){var e,t;return this.cardPaymentButton||(this.cardPaymentButton=new C(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:Object.assign(Object.assign({},this.dropinConfig.events),{onAuthorizeSuccess:this.onAuthorizeSuccess.bind(this),onAuthorizeFailed:this.onAuthorizeFailed.bind(this)})},this.returnLinks)),this.cardForm&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardPaymentButton}onAuthorizeSuccess(){var e,t,i,n;this.subElements.forEach((e=>e.unmount())),new Xn({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}}).mount(this.selector),(null===(n=this.dropinConfig.events)||void 0===n?void 0:n.onAuthorizeSuccess)&&this.dropinConfig.events.onAuthorizeSuccess()}onAuthorizeFailed(e){var t,i,n,o;new jn(null===(i=null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.paymentResult)||void 0===i?void 0:i.fail).mount(this.selector),null===(o=null===(n=this.dropinConfig.events)||void 0===n?void 0:n.onAuthorizeFailed)||void 0===o||o.call(n,e)}isStoredInstrumentEnabled(e){var t,i,n,o,s,r;switch(e){case L.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 L.PAYPAL:case L.GOOGLE_PAY:case L.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}}}const uo=()=>{const e="https://assets.payrails.io/40cce42/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)}}))},Io={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 ho{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)}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:u.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(Io))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 po{constructor(e,t,i){this.pageId=e,this.sdkConfig=t,this.environment=i,this.guid=_().replace(/-/g,""),this.fnclsVal="fnparams-dede7cc5-15fd-4c75-a9f4-36c430ee3a99",this.configId=_(),this.scriptId=_(),this.execution=new S(t.execution)}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 fo=()=>{const e=document.getElementById("sdk-observer");return e||(()=>{const e=document.createElement("iframe");return e.id="sdk-observer",e.src="https://assets.payrails.io/40cce42/observability/index.html",e.width="1px",e.height="1px",document.body.appendChild(e),e})()};
20
+ */function so(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(ro(n)),dataAttributes:o}}function ro(e){var t="";return Object.keys(e).forEach((function(i){0!==t.length&&(t+="&"),t+=i+"="+e[i]})),t}function ao(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 lo(e,t){if(void 0===t&&(t=co()),_o(e,t),"undefined"==typeof window)return t.resolve(null);var i=so(e),n=i.url,o=i.dataAttributes,s=o["data-namespace"]||"paypal",r=Eo(s);return function(e,t){var i=document.querySelector('script[src="'.concat(e,'"]'));if(null===i)return null;var n=ao(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=co());_o(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=ao(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=Eo(s);if(e)return e;throw new Error("The window.".concat(s," global variable is not available."))}))}function co(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function Eo(e){return window[e]}function _o(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.")}class uo extends bn{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===(e=this.button)||void 0===e||e.close(),this.paypalLoader=null,this.paypalLoader=new Dn(this.loadPaypal.bind(this)),this.button=yield this.paypalLoader.loader,this.button.render(`#${this.buttonWrapperId}`),null===(o=null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n?void 0:n.onSaveInstrumentCheckboxChanged)||void 0===o||o.call(n,t)}))})})),this.sdkConfig=t,this.execution=i,this.options=n,this.paypalLoader=null,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:R.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 Io("No order id returned");return this.confirmLink=null===(r=l.response.links.confirm)||void 0===r?void 0:r.href,d})),this.element.innerHTML=`<div id="${this.buttonWrapperId}"></div><div id="${this.checkboxWrapperId}"></div>`,this.paymentExecutor=new A(t,i),this.paypalLoader=new Dn(this.loadPaypal.bind(this)),this.fraudNetGuid=null==n?void 0:n.fraudNetGuid}loadPaypal(){return e(this,void 0,void 0,(function*(){try{const e=this.execution.paypalConfig,t=this.shouldStoreInstrument?"tokenize":"Instant"===this.execution.paypalConfig.captureMode?"capture":"authorize",i=yield lo({"client-id":e.clientId,components:"buttons,funding-eligibility",intent:t,currency:this.sdkConfig.amount.currency,vault:this.shouldStoreInstrument,"data-namespace":"payrailsPaypal"});return i&&(yield this.createPaypalButton(i))}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR,{cause:e});throw r.PayrailsLogger.error(t.message,{error:t}),t}}))}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=yield t.Buttons(this.createPayPalButtonConfig());return e.isEligible()?(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):null}))}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:R.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,t;if(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onPaymentButtonClicked){return(yield this.options.events.onPaymentButtonClicked())?i.resolve():i.reject()}}))}}approvePayment(t){var i,n,o,s,r,a,l,d,c,E;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 Io("No confirm link");const e={};this.shouldStoreInstrument&&t.billingToken&&(e.tokenId=t.billingToken),this.fraudNetGuid&&(e.riskSessionCorrelationId=this.fraudNetGuid);const _=yield this.paymentExecutor.confirm(this.confirmLink,e);"authorizeSuccessful"===(null===(s=_.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===(E=null===(c=null===(d=this.options)||void 0===d?void 0:d.events)||void 0===c?void 0:c.onAuthorizeFailed)||void 0===E||E.call(c)}))}mount(t){super.mount(t),(()=>{e(this,void 0,void 0,(function*(){var e;this.paypalLoader||(this.paypalLoader=new Dn(this.loadPaypal.bind(this)));const t=yield this.paypalLoader.loader;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 ho(e.message,e);throw r.PayrailsLogger.error(t.message,{error:t}),t}}))})()}unmount(){var e;null===(e=this.button)||void 0===e||e.close(),this.paypalLoader=null,super.unmount()}}class Io extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION,{description:`PaypalOrderError: ${e}`,cause:t})}}class ho extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT,{description:`PaypalButtonError: ${e}`,cause:t})}}class po extends Kn{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,null==i?void 0:i.styles),this.loadElementId="paypal-dropin-load-element",this.component=new uo(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},null==i?void 0:i.events),{onPaypalAvailable:()=>{this.mountAfterAvailable()}})}))}}class fo extends $n{constructor(e,t,i,n){var o,s,r;const a=e.paymentMethod===R.PAYPAL?`${null===(o=e.data)||void 0===o?void 0:o.email}`:`${null===(s=e.data)||void 0===s?void 0:s.bin}**${null===(r=e.data)||void 0===r?void 0:r.suffix}`;super(`payrails-payment-instrument-${e.id}`,a,{onActivate:()=>{i(e),this.component.setDisabled(!1)}},n),this.component=t}}class No extends P{constructor(e,t,i,n,o,s){var r,a;super("fieldset",{id:"payrails-dropin-component"}),this.collectContainer=e,this.clientConfig=t,this.dropinConfig=i,this.execution=n,this.sdkConfig=o,this.returnLinks=s;void 0!==(null===(a=null===(r=this.dropinConfig.paymentMethodsConfiguration)||void 0===r?void 0:r.cards)||void 0===a?void 0:a.showExistingCards)&&console.warn("The `showExistingCards` option is deprecated and will be removed in a future version. Please use `showStoredInstruments` instead.");const l=new Map;this.execution.storedPaymentInstruments.forEach((e=>{if(this.isStoredInstrumentEnabled(e.paymentMethod)){this.cardPaymentButton=this.createCardPaymentButton();const t=this.createStoredInstrumentElement(e);l.set(t.identifier,t)}}));const d={[R.CARD]:this.createCreditCardButton.bind(this),[R.PAYPAL]:this.createPayPalButton.bind(this),[R.GOOGLE_PAY]:this.createGooglePayButton.bind(this),[R.APPLE_PAY]:this.createApplePayButton.bind(this),[R.GENERIC_REDIRECT]:this.createGenericRedirectButton.bind(this)};this.execution.availablePaymentMethods.forEach((({paymentMethodCode:e})=>{if(e&&d[e]){d[e];const t=d[e]();l.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)||"";l.forEach((e=>{e.deactivate()})),null===(i=l.get(n))||void 0===i||i.activate()})),this.subElements.push(...Array.from(l.values()))}createStoredInstrumentElement(e){var t;return this.cardPaymentButton=this.createCardPaymentButton(),new fo(e,this.cardPaymentButton,(e=>{this.cardPaymentButton&&(this.cardPaymentButton.selectedInstrument=e)}),null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.element)}createGenericRedirectButton(){var e,t;return this.genericRedirect=new to(this.sdkConfig,this.execution,{styles:null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.genericRedirect,translations:null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.genericRedirect},this.returnLinks),this.genericRedirect}createCreditCardButton(){var e;return this.creditCard=new qn(this.createCardForm(),this.createCardPaymentButton(),null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.element),this.creditCard}createGooglePayButton(){var e,t,i,n;return this.googlePay=new oo(this.sdkConfig,this.execution,Object.assign({environment:this.clientConfig.environment||"TEST",events:{onAuthorizeSuccess:this.onAuthorizeSuccess.bind(this),onAuthorizeFailed:this.onAuthorizeFailed.bind(this),onPaymentButtonClicked:null===(e=this.dropinConfig.events)||void 0===e?void 0:e.onPaymentButtonClicked},styles:Object.assign(Object.assign({},null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.googlePayButton),null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.element)},null===(n=this.dropinConfig.paymentMethodsConfiguration)||void 0===n?void 0:n.googlePay)),this.googlePay}createPayPalButton(){var e,t,i;return this.paypal=new po(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:{onAuthorizeSuccess:this.onAuthorizeSuccess.bind(this),onAuthorizeFailed:this.onAuthorizeFailed.bind(this),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)}}})),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 Bn(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:{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,n;return this.applePay=new Hn(this.sdkConfig,this.execution,Object.assign(Object.assign({events:{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()},onAuthorizeFailed:this.onAuthorizeFailed.bind(this),onPaymentButtonClicked:null===(e=this.dropinConfig.events)||void 0===e?void 0:e.onPaymentButtonClicked}},null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.applePay),{styles:Object.assign(Object.assign({},null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.applePayButton),null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.element)})),this.applePay}createCardPaymentButton(){var e,t;return this.cardPaymentButton||(this.cardPaymentButton=new b(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:Object.assign(Object.assign({},this.dropinConfig.events),{onAuthorizeSuccess:this.onAuthorizeSuccess.bind(this),onAuthorizeFailed:this.onAuthorizeFailed.bind(this)})},this.returnLinks)),this.cardForm&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardPaymentButton}onAuthorizeSuccess(){var e,t,i,n;this.subElements.forEach((e=>e.unmount())),new zn({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}}).mount(this.selector),(null===(n=this.dropinConfig.events)||void 0===n?void 0:n.onAuthorizeSuccess)&&this.dropinConfig.events.onAuthorizeSuccess()}onAuthorizeFailed(e){var t,i,n,o;new Wn(null===(i=null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.paymentResult)||void 0===i?void 0:i.fail).mount(this.selector),null===(o=null===(n=this.dropinConfig.events)||void 0===n?void 0:n.onAuthorizeFailed)||void 0===o||o.call(n,e)}isStoredInstrumentEnabled(e){var t,i,n,o,s,r;switch(e){case R.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 R.PAYPAL:case R.GOOGLE_PAY:case R.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}}}const To=()=>{const e="https://assets.payrails.io/b8c402b/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)}}))},mo={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 vo{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)}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:u.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(mo))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 Oo{constructor(e,t,i){this.pageId=e,this.sdkConfig=t,this.environment=i,this.guid=_().replace(/-/g,""),this.fnclsVal="fnparams-dede7cc5-15fd-4c75-a9f4-36c430ee3a99",this.configId=_(),this.scriptId=_(),this.execution=new D(t.execution)}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 Ao=()=>{const e=document.getElementById("sdk-observer");return e||(()=>{const e=document.createElement("iframe");return e.id="sdk-observer",e.src="https://assets.payrails.io/b8c402b/observability/index.html",e.width="1px",e.height="1px",document.body.appendChild(e),e})()};
21
21
  /* @copyright
22
22
  Copyright (c) 2023 Payrails (https://www.payrails.com/)
23
23
  */
24
- class No{static init(e,t){var i,n;try{fo(),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:"4.0.0"}});const o=JSON.parse(atob(e.data)),s=Boolean(o.vaultConfiguration.encryptionPublicKey);r.PayrailsLogger.setState({payrails:{execution_id:o.execution.id,holder_reference:o.holderReference,vault_provider:o.vaultConfiguration.vaultType,merchant_reference:o.execution.merchantReference,frames_type:s?"payrails":"skyflow",workflow:{code:o.execution.workflow.code,version:o.execution.workflow.version}}});const{vaultConfiguration:{vaultId:a,vaultUrl:l,token:d},execution:c}=o,E=gn.init({vaultID:a,vaultURL:l,getBearerToken:()=>Promise.resolve(d),options:{initResponse:e,deserializedData:Object.assign(Object.assign({},o),{usePayrailsFrames:s})}}),_=new S(c);return _.isPaymentMethodAvailable(L.CARD)&&uo(),new No(Object.assign(Object.assign({},o),{usePayrailsFrames:s}),E,_,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=new ho(this.vaultClient,Object.assign(Object.assign({},e),{cardTableName:this.sdkConfiguration.vaultConfiguration.cardTableName}),this.sdkConfiguration),this.__container}googlePayButton(e){var t;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 Jn(this.sdkConfiguration,this.execution,Object.assign({environment: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 Pn(this.sdkConfiguration,this.execution,e)}cardList(e){return this.logIntegrationMode("elements"),this.__cardList||(this.__cardList=new Gn(this.execution,{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 Vn(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,n;this.logIntegrationMode("dropin");const o=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:o,errorTextStyles:{base:{display:"none"}}}),new _o(this.__container,this.options||{},e,this.execution,this.sdkConfiguration,(null===(n=this.options)||void 0===n?void 0:n.returnLinks)||{})}getSavedCreditCards(){return this.logIntegrationMode("elements"),this.execution.savedCreditCards}getSavedGooglePayAccounts(){return this.logIntegrationMode("elements"),this.execution.savedGooglePayAccounts}getSavedApplePayAccounts(){return this.logIntegrationMode("elements"),this.execution.savedApplePayAccounts}getStoredInstruments(){return this.logIntegrationMode("elements"),this.execution.storedPaymentInstruments}getAvailablePaymentMethods(){return this.logIntegrationMode("elements"),this.execution.availablePaymentMethods.map((({paymentMethodCode:e})=>e)).filter((e=>!!e))}paymentButton(e){var t;return this.logIntegrationMode("elements"),this.__cardPaymentButton||(this.__cardPaymentButton=new C(this.sdkConfiguration,this.execution,e,(null===(t=this.options)||void 0===t?void 0:t.returnLinks)||{})),this.__cardPaymentButton.setDisabled(!0),this.__cardForm&&this.__cardPaymentButton.setCardForm(this.__cardForm),this.__cardPaymentButton}paypalButton(e){var t;return this.logIntegrationMode("elements"),this.__paypalButton=new ro(this.sdkConfiguration,this.execution,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}getSavedPaypalAccounts(){return this.logIntegrationMode("elements"),this.execution.savedPaypalAccounts||[]}fraudNet(e){var t;return this.__fraudNet||(this.__fraudNet=new po(e,this.sdkConfiguration,(null===(t=this.options)||void 0===t?void 0:t.environment)||"TEST")),this.__paypalButton&&(this.__paypalButton.fraudNetGuid=this.__fraudNet.guid),this.__fraudNet}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]}}No.preloadCardForm=uo,exports.Payrails=No}();
24
+ class yo{static init(e,t){var i,n;try{Ao(),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:"4.1.0-RC.3"}});const o=JSON.parse(atob(e.data)),s=Boolean(o.vaultConfiguration.encryptionPublicKey);r.PayrailsLogger.setState({payrails:{execution_id:o.execution.id,holder_reference:o.holderReference,vault_provider:o.vaultConfiguration.vaultType,merchant_reference:o.execution.merchantReference,frames_type:s?"payrails":"skyflow",workflow:{code:o.execution.workflow.code,version:o.execution.workflow.version}}});const{vaultConfiguration:{vaultId:a,vaultUrl:l,token:d},execution:c}=o,E=Cn.init({vaultID:a,vaultURL:l,getBearerToken:()=>Promise.resolve(d),options:{initResponse:e,deserializedData:Object.assign(Object.assign({},o),{usePayrailsFrames:s})}}),_=new D(c);return _.isPaymentMethodAvailable(R.CARD)&&To(),new yo(Object.assign(Object.assign({},o),{usePayrailsFrames:s}),E,_,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=new vo(this.vaultClient,Object.assign(Object.assign({},e),{cardTableName:this.sdkConfiguration.vaultConfiguration.cardTableName}),this.sdkConfiguration),this.__container}googlePayButton(e){var t;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 no(this.sdkConfiguration,this.execution,Object.assign({environment: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 Mn(this.sdkConfiguration,this.execution,e)}cardList(e){return this.logIntegrationMode("elements"),this.__cardList||(this.__cardList=new jn(this.execution,{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 Bn(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,n,o,s;this.logIntegrationMode("dropin");const r=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:r,errorTextStyles:{base:{display:"none"}}}),new No(this.__container,this.options||{},e,this.execution,this.sdkConfiguration,null!==(s=null!==(n=e.returnInfo)&&void 0!==n?n:null===(o=this.options)||void 0===o?void 0:o.returnLinks)&&void 0!==s?s:{})}getSavedCreditCards(){return this.logIntegrationMode("elements"),this.execution.savedCreditCards}getSavedGooglePayAccounts(){return this.logIntegrationMode("elements"),this.execution.savedGooglePayAccounts}getSavedApplePayAccounts(){return this.logIntegrationMode("elements"),this.execution.savedApplePayAccounts}getStoredInstruments(){return this.logIntegrationMode("elements"),this.execution.storedPaymentInstruments}getAvailablePaymentMethods(){return this.logIntegrationMode("elements"),this.execution.availablePaymentMethods.map((({paymentMethodCode:e})=>e)).filter((e=>!!e))}paymentButton(e){var t;return this.logIntegrationMode("elements"),this.__cardPaymentButton||(this.__cardPaymentButton=new b(this.sdkConfiguration,this.execution,e,(null===(t=this.options)||void 0===t?void 0:t.returnLinks)||{})),this.__cardPaymentButton.setDisabled(!0),this.__cardForm&&this.__cardPaymentButton.setCardForm(this.__cardForm),this.__cardPaymentButton}paypalButton(e){var t;return this.logIntegrationMode("elements"),this.__paypalButton=new uo(this.sdkConfiguration,this.execution,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 Qn(this.sdkConfiguration,this.execution,Object.assign({},e)),this.__genericRedirectButton}getSavedPaypalAccounts(){return this.logIntegrationMode("elements"),this.execution.savedPaypalAccounts||[]}fraudNet(e){var t;return this.__fraudNet||(this.__fraudNet=new Oo(e,this.sdkConfiguration,(null===(t=this.options)||void 0===t?void 0:t.environment)||"TEST")),this.__paypalButton&&(this.__paypalButton.fraudNetGuid=this.__fraudNet.guid),this.__fraudNet}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]}}yo.preloadCardForm=To,exports.Payrails=yo}();