@payrails/web-sdk 5.7.5 → 5.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +4 -4
- package/package.json +1 -1
- package/payrails.d.ts +9 -44
- package/payrails.js +4 -4
package/payrails.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
!function(e){"use strict";function t(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 i(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 n(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}e.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"}(e.ElementType||(e.ElementType={})),"function"==typeof SuppressedError&&SuppressedError;var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function s(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var r={};!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:c}=i[e]||{},d=null!=(n=null!=s?s:l)?n:"An unknown error occurred",u=null!=r?r:c;super(d),this.name=e,this.docUrl=u,this.cause=a,this.message=d,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}(r);var a={};!function(e){var t=Object.defineProperty,i=Object.getOwnPropertySymbols,n=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 o in t||(t={}))n.call(t,o)&&r(e,o,t[o]);if(i)for(var o of i(t))s.call(t,o)&&r(e,o,t[o]);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 c=(e=>(e.ERROR="payrails:error",e.INFO="payrails:info",e.DEBUG="payrails:debug",e.WARN="payrails:warn",e))(c||{}),d="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==o?o:"undefined"!=typeof self?self:{};function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var E,_,h,I={},p={},f={},v={},m={};Object.defineProperty(m,"__esModule",{value:!0}),m.subscribers=m.childWindows=m.prefix=void 0,m.prefix="/*framebus*/",m.childWindows=[],m.subscribers={};var N,T={},O={};Object.defineProperty(O,"__esModule",{value:!0}),O.hasOpener=void 0,O.hasOpener=function(e){return e.top===e&&null!=e.opener&&e.opener!==e&&!0!==e.opener.closed};var y={};Object.defineProperty(y,"__esModule",{value:!0}),y.isntString=void 0,y.isntString=function(e){return"string"!=typeof e};var A,L,R={},g={},S={};Object.defineProperty(S,"__esModule",{value:!0}),S.sendMessage=void 0,S.sendMessage=function(e,t,i){try{e.postMessage(t,i)}catch(e){}};var D,C={},P={};function b(){if(D)return P;D=1,Object.defineProperty(P,"__esModule",{value:!0}),P.Framebus=void 0;var e=G(),t="undefined"!=typeof window&&window.Promise,i=function(){function i(e){void 0===e&&(e={}),this.origin=e.origin||"*",this.channel=e.channel||"",this.verifyDomain=e.verifyDomain,this.targetFrames=e.targetFrames||[],this.limitBroadcastToFramesArray=Boolean(e.targetFrames),this.isDestroyed=!1,this.listeners=[],this.hasAdditionalChecksForOnListeners=Boolean(this.verifyDomain||this.limitBroadcastToFramesArray)}return i.setPromise=function(e){i.Promise=e},i.target=function(e){return new i(e)},i.prototype.addTargetFrame=function(e){this.limitBroadcastToFramesArray&&this.targetFrames.push(e)},i.prototype.include=function(t){return null!=t&&null!=t.Window&&t.constructor===t.Window&&(e.childWindows.push(t),!0)},i.prototype.target=function(e){return i.target(e)},i.prototype.emit=function(t,i,n){if(this.isDestroyed)return!1;var o=this.origin;if(t=this.namespaceEvent(t),(0,e.isntString)(t))return!1;if((0,e.isntString)(o))return!1;"function"==typeof i&&(n=i,i=void 0);var s=(0,e.packagePayload)(t,o,i,n);return!!s&&(this.limitBroadcastToFramesArray?this.targetFramesAsWindows().forEach((function(t){(0,e.sendMessage)(t,s,o)})):(0,e.broadcast)(s,{origin:o,frame:window.top||window.self}),!0)},i.prototype.emitAsPromise=function(e,t){var n=this;return new i.Promise((function(i,o){n.emit(e,t,(function(e){i(e)}))||o(new Error('Listener not added for "'.concat(e,'"')))}))},i.prototype.on=function(t,i){if(this.isDestroyed)return!1;var n=this,o=this.origin,s=i;return t=this.namespaceEvent(t),!(0,e.subscriptionArgsInvalid)(t,s,o)&&(this.hasAdditionalChecksForOnListeners&&(s=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];n.passesVerifyDomainCheck(this&&this.origin)&&n.hasMatchingTargetFrame(this&&this.source)&&i.apply(void 0,e)}),this.listeners.push({eventName:t,handler:s,originalHandler:i}),e.subscribers[o]=e.subscribers[o]||{},e.subscribers[o][t]=e.subscribers[o][t]||[],e.subscribers[o][t].push(s),!0)},i.prototype.off=function(t,i){var n=i;if(this.isDestroyed)return!1;if(this.verifyDomain)for(var o=0;o<this.listeners.length;o++){var s=this.listeners[o];s.originalHandler===i&&(n=s.handler)}t=this.namespaceEvent(t);var r=this.origin;if((0,e.subscriptionArgsInvalid)(t,n,r))return!1;var a=e.subscribers[r]&&e.subscribers[r][t];if(!a)return!1;for(o=0;o<a.length;o++)if(a[o]===n)return a.splice(o,1),!0;return!1},i.prototype.teardown=function(){if(!this.isDestroyed){this.isDestroyed=!0;for(var e=0;e<this.listeners.length;e++){var t=this.listeners[e];this.off(t.eventName,t.handler)}this.listeners.length=0}},i.prototype.passesVerifyDomainCheck=function(e){return!this.verifyDomain||this.checkOrigin(e)},i.prototype.targetFramesAsWindows=function(){return this.limitBroadcastToFramesArray?this.targetFrames.map((function(e){return e instanceof HTMLIFrameElement?e.contentWindow:e})).filter((function(e){return e})):[]},i.prototype.hasMatchingTargetFrame=function(e){if(!this.limitBroadcastToFramesArray)return!0;var t=this.targetFramesAsWindows().find((function(t){return t===e}));return Boolean(t)},i.prototype.checkOrigin=function(e){var t,i=document.createElement("a");return i.href=location.href,t="https:"===i.protocol?i.host.replace(/:443$/,""):"http:"===i.protocol?i.host.replace(/:80$/,""):i.host,i.protocol+"//"+t===e||!this.verifyDomain||this.verifyDomain(e)},i.prototype.namespaceEvent=function(e){return this.channel?"".concat(this.channel,":").concat(e):e},i.Promise=t,i}();return P.Framebus=i,P}var M,w,U=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)}))},k={},Y={};Object.defineProperty(Y,"__esModule",{value:!0});var x,V,F={};function G(){return V||(V=1,e=I,t=d&&d.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),i=d&&d.__exportStar||function(e,i){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(i,n)||t(i,e,n)},Object.defineProperty(e,"__esModule",{value:!0}),i(function(){if(E)return p;E=1,Object.defineProperty(p,"__esModule",{value:!0}),p.detach=p.attach=void 0;var e=G(),t=!1;return p.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},p.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},p}(),e),i(function(){if(_)return f;_=1,Object.defineProperty(f,"__esModule",{value:!0}),f.broadcastToChildWindows=void 0;var e=G();return f.broadcastToChildWindows=function(t,i,n){for(var o=e.childWindows.length-1;o>=0;o--){var s=e.childWindows[o];s.closed?e.childWindows.splice(o,1):n!==s&&(0,e.broadcast)(t,{origin:i,frame:s.top})}},f}(),e),i(function(){if(h)return v;h=1,Object.defineProperty(v,"__esModule",{value:!0}),v.broadcast=void 0;var e=G();return v.broadcast=function t(i,n){var o,s=0,r=n.origin,a=n.frame;try{for(a.postMessage(i,r),(0,e.hasOpener)(a)&&a.opener.top!==window.top&&t(i,{origin:r,frame:a.opener.top});o=a.frames[s];)t(i,{origin:r,frame:o}),s++}catch(e){}},v}(),e),i(m,e),i(function(){if(N)return T;N=1,Object.defineProperty(T,"__esModule",{value:!0}),T.dispatch=void 0;var e=G();return T.dispatch=function(t,i,n,o,s){if(e.subscribers[t]&&e.subscribers[t][i]){var r=[];n&&r.push(n),o&&r.push(o);for(var a=0;a<e.subscribers[t][i].length;a++)e.subscribers[t][i][a].apply(s,r)}},T}(),e),i(O,e),i(y,e),i(function(){if(A)return R;A=1,Object.defineProperty(R,"__esModule",{value:!0}),R.onMessage=void 0;var e=G();return R.onMessage=function(t){if(!(0,e.isntString)(t.data)){var i=(0,e.unpackPayload)(t);if(i){var n=i.eventData,o=i.reply;(0,e.dispatch)("*",i.event,n,o,t),(0,e.dispatch)(t.origin,i.event,n,o,t),(0,e.broadcastToChildWindows)(t.data,i.origin,t.source)}}},R}(),e),i(function(){if(L)return g;L=1,Object.defineProperty(g,"__esModule",{value:!0}),g.packagePayload=void 0;var e=G();return g.packagePayload=function(t,i,n,o){var s,r={event:t,origin:i};"function"==typeof o&&(r.reply=(0,e.subscribeReplier)(o,i)),r.eventData=n;try{s=e.prefix+JSON.stringify(r)}catch(e){throw new Error("Could not stringify event: ".concat(e.message))}return s},g}(),e),i(S,e),i(function(){if(M)return C;M=1;var e=d&&d.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(C,"__esModule",{value:!0}),C.subscribeReplier=void 0;var t=b(),i=e(U);return C.subscribeReplier=function(e,n){var o=(0,i.default)();return t.Framebus.target({origin:n}).on(o,(function i(s,r){e(s,r),t.Framebus.target({origin:n}).off(o,i)})),o},C}(),e),i(function(){if(w)return k;w=1,Object.defineProperty(k,"__esModule",{value:!0}),k.subscriptionArgsInvalid=void 0;var e=G();return k.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},k}(),e),i(Y,e),i(function(){if(x)return F;x=1,Object.defineProperty(F,"__esModule",{value:!0}),F.unpackPayload=void 0;var e=G();return F.unpackPayload=function(t){var i;if(t.data.slice(0,e.prefix.length)!==e.prefix)return!1;try{i=JSON.parse(t.data.slice(e.prefix.length))}catch(e){return!1}if(i.reply){var n=t.origin,o=t.source,s=i.reply;i.reply=function(t){if(o){var i=(0,e.packagePayload)(s,n,t);i&&o.postMessage(i,n)}}}return i},F}(),e)),I;var e,t,i}var B=G(),j=b();(0,B.attach)();const X=u(j.Framebus);class W{constructor(e){this.origin=null,this.listeners=[],this.bus=new X(e)}static getInstance(){return W.instance||(W.instance=new W),W.instance}on(e,t){return this.bus.on(e,t)}off(e,t){return this.bus.off(e,t)}emit(e,t,i=void 0){return this.bus.emit(e,t,i)}target(e){return this.bus.target(e)}}class ${constructor(){this.bus=W.getInstance()}log(e,t){this.bus.emit(c.ERROR,{level:e,event:t})}}var z=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===H}(e)}(e)},H="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function K(e,t){return!1!==t.clone&&t.isMergeableObject(e)?ee((i=e,Array.isArray(i)?[]:{}),e,t):e;var i}function q(e,t,i){return e.concat(t).map((function(e){return K(e,i)}))}function J(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return Object.propertyIsEnumerable.call(e,t)})):[]}(e))}function Z(e,t){try{return t in e}catch(e){return!1}}function Q(e,t,i){var n={};return i.isMergeableObject(e)&&J(e).forEach((function(t){n[t]=K(e[t],i)})),J(t).forEach((function(o){(function(e,t){return Z(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,o)||(Z(e,o)&&i.isMergeableObject(t[o])?n[o]=function(e,t){if(!t.customMerge)return ee;var i=t.customMerge(e);return"function"==typeof i?i:ee}(o,i)(e[o],t[o],i):n[o]=K(t[o],i))})),n}function ee(e,t,i){(i=i||{}).arrayMerge=i.arrayMerge||q,i.isMergeableObject=i.isMergeableObject||z,i.cloneUnlessOtherwiseSpecified=K;var n=Array.isArray(t);return n===Array.isArray(e)?n?i.arrayMerge(e,t,i):Q(e,t,i):K(t,i)}ee.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,i){return ee(e,i,t)}),{})};const te=u(ee);class ie{constructor(){this.state={}}static getInstance(){return ie.instance||(ie.instance=new ie),ie.instance}getState(e){return this.state[e]}setState(e){this.state=te(this.state,e)}}const ne=ie.getInstance(),oe=()=>window&&window.navigator,se=()=>window&&window.screen,re=()=>({resolution:`${se().width}x${se().height}`,user_agent:oe().userAgent,language:oe().language});class ae{constructor(e){this.adapter=[new $],this.enabled=e.enabled||!0,this.initGlobalState(e),e.logLevel=e.logLevel||"error","debug"===e.logLevel&&this.addAdapter(new l)}static init(e){ae.instance=new ae(e)}static getLogger(){return ae.instance}initGlobalState(e){ne.setState({payrails:e.payrails,sdk:e.sdk})}static setState(e){ne.setState(e)}log(e,t,i){this.enabled&&this.adapter.forEach((n=>{n.log(e,{mssg:t,error:null==i?void 0:i.error,withMetada:a(a({},this.constructMetadata()),null==i?void 0:i.withMetada),extra:null==i?void 0:i.extra})}))}constructMetadata(){return{device:re(),payrails:ne.getState("payrails"),sdk:ne.getState("sdk")}}addAdapter(e){this.adapter.push(e)}static log(e,t){this.getLogger().log("info",e,t)}static debug(e,t){this.getLogger().log("debug",e,t)}static info(e,t){this.getLogger().log("info",e,t)}static warn(e,t){this.getLogger().log("warning",e,t)}static error(e,t){this.getLogger().log("error",e,t)}static exception(e,t){this.error(e,t)}}e.PayrailsLogger=ae,e.getDeviceInfo=re}(a);for(var l,c=[],d=0;d<256;++d)c.push((d+256).toString(16).slice(1));var u=new Uint8Array(16);function E(){if(!l&&!(l="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return l(u)}var _,h={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function I(e,t,i){if(h.randomUUID&&!t&&!e)return h.randomUUID();var n=(e=e||{}).random||(e.rng||E)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){i=i||0;for(var o=0;o<16;++o)t[i+o]=n[o];return t}return function(e,t=0){return(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]]).toLowerCase()}(n)}!function(e){e.GET="GET",e.POST="POST"}(_||(_={}));const p=({url:e,method:i=_.GET,token:n,body:o})=>t(void 0,void 0,void 0,(function*(){const t={method:i,headers:Object.assign(Object.assign(Object.assign({},O()),T(n)),y())};i===_.POST&&(t.body=JSON.stringify(o||{}));const s=yield fetch(e,t),r=yield s.json();if([401,403].includes(s.status))throw new f(e,i);if(429===s.status)throw new m(e,i);if(!s.ok)throw new v(e,i);return{ok:s.ok,req:Object.assign({url:e},t),res:r}}));class f extends r.PayrailsError{constructor(e,t){super(r.ERROR_CODES.PAYRAILS_API_UNAUTHORIZED,{description:`[${t}] ${e} unauthorized`})}}class v extends r.PayrailsError{constructor(e,t){super(r.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{description:`[${t}] ${e} unsuccessful`})}}class m extends r.PayrailsError{constructor(e,t){super(r.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} too many requests`})}}class N extends r.PayrailsError{constructor(e,t){super(r.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} max poll attempts exceeded.`})}}const T=e=>({authorization:`Bearer ${e}`}),O=()=>({"x-idempotency-key":I()}),y=()=>{const e={version:"5.7.5",type:"web-sdk"};return{"x-client-version":e.version,"x-client-type":e.type}},A=(i,n)=>t(void 0,void 0,void 0,(function*(){var t,o;if(null==i?void 0:i.onPaymentButtonClicked)try{const o=yield i.onPaymentButtonClicked(n);if(!o){const n=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_ONPAY_CALLBACK_FAILED,{description:"Callback passed to onPaymentButtonClicked resolved to false"});return a.PayrailsLogger.error(n.message,{error:n}),null===(t=null==i?void 0:i.onAuthorizeFailed)||void 0===t||t.call(i,{code:e.AuthorizationFailureReasons.VALIDATION_FAILED,message:n.message}),o}}catch(t){const n=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_ONPAY_CALLBACK_FAILED,{description:"Callback passed to onPaymentButtonClicked threw an error",cause:t});return a.PayrailsLogger.error(n.message,{error:n}),null===(o=i.onAuthorizeFailed)||void 0===o||o.call(i,{code:e.AuthorizationFailureReasons.VALIDATION_FAILED,message:n.message}),!1}return!0})),L={success:"https://payrails.io/success",error:"https://payrails.io/error",cancel:"https://payrails.io/cancel"};class R{constructor(e,t,i=L,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(e){return t(this,void 0,void 0,(function*(){try{const t=(yield this.authorize(e)).res.links.execution;return yield this.pollForAuthorizationResult(t)}catch(e){const t=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR,{cause:e});throw a.PayrailsLogger.error(t.message,{error:t}),e}}))}confirm(e,i={}){return t(this,void 0,void 0,(function*(){try{const t=yield p({url:e,method:_.POST,token:this.sdkConfig.token,body:{data:i}}),n=yield this.pollForAuthorizationResult(t.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(t.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 r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR,{cause:e});throw a.PayrailsLogger.error(t.message,{error:t}),e}}))}getExecution(e,i,n=0){return t(this,void 0,void 0,(function*(){if(n>this.MAX_POLL_ATTEMPTS)throw new N(e,_.GET);0===n&&i&&(yield this.wait(this.POLL_INITIAL_DELAY));try{const t=yield p({url:e,token:this.sdkConfig.token});return i&&!t.res.status.find((({time:e})=>new Date(e)>new Date(i)))?(yield this.wait(this.POLL_INTERVAL),this.getExecution(e,i,n+1)):t}catch(t){if(t instanceof v)return yield this.wait(this.POLL_INTERVAL),this.getExecution(e,i,n+this.POLL_ERROR_COUNT_MULTIPLIER);if(t instanceof m)return yield this.wait(this.POLL_INTERVAL*n),this.getExecution(e,i,n+1);throw t}}))}createApplePaySession(e){return t(this,void 0,void 0,(function*(){return p({url:e.requestUrl,method:_.POST,token:this.sdkConfig.token,body:{integrationType:"api",paymentMethodCode:"applePay",amount:this.sdkConfig.amount,meta:{sessionURL:e.sessionUrl,clientContext:{host:e.clientDomain||window.location.host}}}})}))}authorize(e){return t(this,void 0,void 0,(function*(){if(!this.execution.authorizeLink||!this.sdkConfig.amount){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND,{description:"SDK was not initialized with workflow execution"});throw a.PayrailsLogger.error(e.message,{error:e}),e}const{success:t,error:i,cancel:n}=this.returnLinks;return p({url:this.execution.authorizeLink,method:_.POST,token:this.sdkConfig.token,body:{amount:this.sdkConfig.amount,paymentComposition:e,returnInfo:{success:t,cancel:n,error:i}}})}))}wait(e){return t(this,void 0,void 0,(function*(){return new Promise((t=>setTimeout(t,e)))}))}pollForAuthorizationResult(e,i=0){return t(this,void 0,void 0,(function*(){const t=(yield this.getExecution(e)).res,n=t.status,o=["authorizePending","authorizeSuccessful","authorizeFailed"],s=n.find((({code:e})=>"authorizeRequested"===e));if(!s&&i<10)return yield new Promise((e=>setTimeout(e,this.POLL_INTERVAL))),this.pollForAuthorizationResult(e,i+1);if(!s){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED);throw a.PayrailsLogger.error(e.message,{error:e}),e}const l=n.find((({code:e,time:t})=>"confirmRequested"===e&&new Date(t)>new Date(s.time))),c=l?l.time:s.time;let d=n.find((({code:e,time:t})=>o.includes(e)&&new Date(t)>new Date(c)));if(!d){const{res:t}=yield this.getExecution(e,c);return d=t.status.find((({code:e,time:t})=>o.includes(e)&&new Date(t)>new Date(c))),{finalState:d,response:t}}return{finalState:d,response:t}}))}}class g{constructor(e,t,i,n,o=S.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===S.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 i=n=>t(this,void 0,void 0,(function*(){var t,o,s,l;if(n.data&&'{"type":"3DS-challenge-completed"}'===n.data){if(window.removeEventListener("message",i),(yield this.paymentExecutor.getExecution(this.execution.url)).res.status.find((({code:e})=>"authorizeSuccessful"===e)))null===(l=null===(s=this.options.events)||void 0===s?void 0:s.onAuthorizeSuccess)||void 0===l||l.call(s);else{const i=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_3DS_ERROR);a.PayrailsLogger.error(i.message,{error:i}),null===(o=null===(t=this.options.events)||void 0===t?void 0:t.onAuthorizeFailed)||void 0===o||o.call(t,{code:e.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:"Authorization failed after 3DS challenge."})}this.unmount()}}));window.addEventListener("message",i)}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 S,D,C,P;!function(e){e[e.THREE_DS=0]="THREE_DS",e[e.GENERIC_REDIRECT=1]="GENERIC_REDIRECT"}(S||(S={}));class b{constructor(e,t,i){this.options=e,this.execution=t,this.paymentExecutor=i}handle3ds(e){var t,i,n;try{null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onThreeDSecureChallenge)||void 0===i||i.call(t)}catch(e){}const o=null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.links["3ds"];o&&new g(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"}(D||(D={})),function(e){e.ENABLED="enabled",e.CREATED="created",e.DELETED="deleted",e.DISABLED="disabled",e.INVALID="invalid",e.TRANSIENT="transient"}(C||(C={}));class M{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(D.CARD)}get savedPaypalAccounts(){return this.getStoredInstrumentForPaymentMethod(D.PAYPAL)}get savedGooglePayAccounts(){return this.getStoredInstrumentForPaymentMethod(D.GOOGLE_PAY)}get savedApplePayAccounts(){return this.getStoredInstrumentForPaymentMethod(D.APPLE_PAY)}get paypalConfig(){const e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===D.PAYPAL));if(!e){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING);throw a.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:this.availablePaymentMethods}}),e}return e.config||{}}get googlePayConfig(){const e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===D.GOOGLE_PAY));if(!e){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING);throw a.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===D.APPLE_PAY));if(!e){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING);throw a.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 w{constructor(e,{id:t="",className:i=""}={}){this.subElements=[];const n=document.createElement(e);t&&(this.id=t,n.setAttribute("id",t)),i&&(Array.isArray(i)?n.setAttribute("class",function(...e){return e.filter(Boolean).join(" ")}(...i)):n.setAttribute("class",i)),this.element=n}get parentElement(){return this.element.parentElement}get selector(){if(!this.id)throw new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);return`#${this.id}`}mount(e){const t=document.querySelector(e);if(!t)throw new r.PayrailsError(r.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 r.PayrailsError(r.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 U extends w{get bin(){var e;return this.selectedInstrument?this.selectedInstrument.data.bin?this.selectedInstrument.data.bin:"":(null===(e=this.cardForm)||void 0===e?void 0:e.bin)||""}constructor(e,t,i,n){var o;super("button",{id:"payrails-card-payment-button"}),this.sdkConfig=e,this.execution=t,this.options=i,this.returnInfo=n,this.selectedInstrument=null,this.element.innerText=(null===(o=null==i?void 0:i.translations)||void 0===o?void 0:o.label)||"Pay",this.element.addEventListener("click",this.onPay.bind(this)),this.element.addEventListener("mouseenter",(()=>{var e;this.element.classList.contains("disabled")||(this.element.classList.add("hover"),this.setStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{}))})),this.element.addEventListener("mouseleave",(()=>{var e;this.element.classList.contains("disabled")||(this.element.classList.remove("hover"),this.removeStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{}))})),this.paymentExecutor=new R(this.sdkConfig,this.execution,this.returnInfo)}setDisabled(e){var t,i,n,o,s;this.element.classList.contains("disabled")!==e&&(null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onStateChanged)||void 0===i||i.call(t,e?"disabled":"enabled")),this.element.disabled=e,e?(this.element.classList.add("disabled"),(null===(n=this.options.styles)||void 0===n?void 0:n.disabled)&&this.setStyles(this.options.styles.disabled)):(this.element.classList.remove("disabled"),this.removeStyles((null===(o=this.options.styles)||void 0===o?void 0:o.disabled)||{}),(null===(s=this.options.styles)||void 0===s?void 0:s.base)&&this.setStyles(this.options.styles.base))}setSavedCreditCard(e){console.warn("setSavedCreditCard is deprecated, please use setSavedInstrument"),this.setSavedInstrument(e)}setSavedInstrument(e){this.selectedInstrument=e,this.setDisabled(!1)}setStyles(e){var t;const i=Object.assign(Object.assign({},null===(t=this.options.styles)||void 0===t?void 0:t.base),e);Object.keys(i).forEach((e=>{this.element.style[e]=i[e]}))}removeStyles(e){var t;const i=Object.keys((null===(t=this.options.styles)||void 0===t?void 0:t.base)||{});Object.keys(e).forEach((e=>{var t,n;i.includes(e)?this.element.style[e]=null===(n=null===(t=this.options.styles)||void 0===t?void 0:t.base)||void 0===n?void 0:n[e]:this.element.style[e]=""}))}setLabel(e){this.element.innerText=e}setCardForm(e){this.cardForm=e}triggerLoading(e){var t,i,n,o;const s=this.element.offsetWidth;this.element.style.minWidth=`${s}px`,e?(this.element.innerHTML='<div class="dot-flashing"></div>',this.element.classList.add("loading"),(null===(t=this.options.styles)||void 0===t?void 0:t.loading)&&this.setStyles(this.options.styles.loading)):(this.element.innerText=(null===(n=null===(i=this.options)||void 0===i?void 0:i.translations)||void 0===n?void 0:n.label)||"Pay",this.element.classList.remove("loading"),this.removeStyles((null===(o=this.options.styles)||void 0===o?void 0:o.loading)||{}))}onAuthorizationFailed(e){var t,i;this.setDisabled(!1),this.triggerLoading(!1),(null===(t=this.options.events)||void 0===t?void 0:t.onAuthorizeFailed)&&(null===(i=this.options.events)||void 0===i||i.onAuthorizeFailed(e))}onPay(){var i,n,o,s,l,c,d,u;return t(this,void 0,void 0,(function*(){if(this.setDisabled(!0),this.triggerLoading(!0),!(yield A(this.options.events,{bin:this.bin||""})))return this.setDisabled(!1),void this.triggerLoading(!1);try{let e=[{paymentMethodCode:D.CARD,integrationType:"api",amount:this.sdkConfig.amount,storeInstrument:!1}];if(null===(i=this.selectedInstrument)||void 0===i?void 0:i.id)e[0].paymentInstrumentId=null===(n=this.selectedInstrument)||void 0===n?void 0:n.id,e[0].paymentMethodCode=null===(o=this.selectedInstrument)||void 0===o?void 0:o.paymentMethod;else{if(!this.cardForm){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_CARD_FORM_MISSING);throw a.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(t){let i=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_API_AUTHENTICATION_ERROR,{cause:t});t instanceof f||[401,403].includes(null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.code)?(null===(c=null===(l=this.options.events)||void 0===l?void 0:l.onPaymentSessionExpired)||void 0===c||c.call(l),i.message="API token is not valid or expired.",a.PayrailsLogger.error(i.message,{error:i}),this.onAuthorizationFailed({code:e.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:i.message})):t.toString().includes("Invalid token")?(null===(u=null===(d=this.options.events)||void 0===d?void 0:d.onPaymentSessionExpired)||void 0===u||u.call(d),i.message="Vault token is not valid or expired.",a.PayrailsLogger.error(i.message,{error:i})):i=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_API_UNKNOWN_ERROR,{cause:t}),this.onAuthorizationFailed({code:e.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:i.message})}}))}constructTokenizedPayment(e){return t(this,void 0,void 0,(function*(){const{storeInstrument:t,enrollInstrumentToNetworkOffers:i,cardData:n}=yield this.cardForm.collectValues();return e[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}},e[0].storeInstrument=t,e[0].enrollInstrumentToNetworkOffers=i,e}))}constructEncryptedPayment(e){return t(this,void 0,void 0,(function*(){const{cardData:t,storeInstrument:i,enrollInstrumentToNetworkOffers:n}=yield this.cardForm.collectValues();return e[0].paymentInstrumentData=Object.assign({},t),e[0].storeInstrument=i,e[0].enrollInstrumentToNetworkOffers=n,e}))}handleAuthorizationResult(t){var i,n,o;let s;switch(null===(i=null==t?void 0:t.finalState)||void 0===i?void 0:i.code){case"authorizeSuccessful":this.triggerLoading(!1),(null===(n=this.options.events)||void 0===n?void 0:n.onAuthorizeSuccess)&&this.options.events.onAuthorizeSuccess();break;case"authorizePending":"3ds"===(null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.actionRequired)&&new b({events:Object.assign(Object.assign({},this.options.events),{onAuthorizeFailed:e=>{this.onAuthorizationFailed(e)}})},this.execution,this.paymentExecutor).handle3ds(t);break;default:s=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_ERROR),a.PayrailsLogger.error(s.message,{error:s,extra:{result:t}}),this.onAuthorizationFailed({code:e.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:s.message})}}}e.AuthorizationFailureReasons=void 0,(P=e.AuthorizationFailureReasons||(e.AuthorizationFailureReasons={})).VALIDATION_FAILED="VALIDATION_FAILED",P.AUTHORIZATION_ERROR="AUTHORIZATION_ERROR",P.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",P.UNKNOWN_ERROR="UNKNOWN_ERROR";var k={};!function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==o?o:"undefined"!=typeof self?self:{};function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n,s,r,a={},l={},c={},d={},u={};Object.defineProperty(u,"__esModule",{value:!0}),u.subscribers=u.childWindows=u.prefix=void 0,u.prefix="/*framebus*/",u.childWindows=[],u.subscribers={};var E,_={},h={};Object.defineProperty(h,"__esModule",{value:!0}),h.hasOpener=void 0,h.hasOpener=function(e){return e.top===e&&null!=e.opener&&e.opener!==e&&!0!==e.opener.closed};var I={};Object.defineProperty(I,"__esModule",{value:!0}),I.isntString=void 0,I.isntString=function(e){return"string"!=typeof e};var p,f,v={},m={},N={};Object.defineProperty(N,"__esModule",{value:!0}),N.sendMessage=void 0,N.sendMessage=function(e,t,i){try{e.postMessage(t,i)}catch(e){}};var T,O={},y={};function A(){if(T)return y;T=1,Object.defineProperty(y,"__esModule",{value:!0}),y.Framebus=void 0;var e=M(),t="undefined"!=typeof window&&window.Promise,i=function(){function i(e){void 0===e&&(e={}),this.origin=e.origin||"*",this.channel=e.channel||"",this.verifyDomain=e.verifyDomain,this.targetFrames=e.targetFrames||[],this.limitBroadcastToFramesArray=Boolean(e.targetFrames),this.isDestroyed=!1,this.listeners=[],this.hasAdditionalChecksForOnListeners=Boolean(this.verifyDomain||this.limitBroadcastToFramesArray)}return i.setPromise=function(e){i.Promise=e},i.target=function(e){return new i(e)},i.prototype.addTargetFrame=function(e){this.limitBroadcastToFramesArray&&this.targetFrames.push(e)},i.prototype.include=function(t){return null!=t&&null!=t.Window&&t.constructor===t.Window&&(e.childWindows.push(t),!0)},i.prototype.target=function(e){return i.target(e)},i.prototype.emit=function(t,i,n){if(this.isDestroyed)return!1;var o=this.origin;if(t=this.namespaceEvent(t),(0,e.isntString)(t))return!1;if((0,e.isntString)(o))return!1;"function"==typeof i&&(n=i,i=void 0);var s=(0,e.packagePayload)(t,o,i,n);return!!s&&(this.limitBroadcastToFramesArray?this.targetFramesAsWindows().forEach((function(t){(0,e.sendMessage)(t,s,o)})):(0,e.broadcast)(s,{origin:o,frame:window.top||window.self}),!0)},i.prototype.emitAsPromise=function(e,t){var n=this;return new i.Promise((function(i,o){n.emit(e,t,(function(e){i(e)}))||o(new Error('Listener not added for "'.concat(e,'"')))}))},i.prototype.on=function(t,i){if(this.isDestroyed)return!1;var n=this,o=this.origin,s=i;return t=this.namespaceEvent(t),!(0,e.subscriptionArgsInvalid)(t,s,o)&&(this.hasAdditionalChecksForOnListeners&&(s=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];n.passesVerifyDomainCheck(this&&this.origin)&&n.hasMatchingTargetFrame(this&&this.source)&&i.apply(void 0,e)}),this.listeners.push({eventName:t,handler:s,originalHandler:i}),e.subscribers[o]=e.subscribers[o]||{},e.subscribers[o][t]=e.subscribers[o][t]||[],e.subscribers[o][t].push(s),!0)},i.prototype.off=function(t,i){var n=i;if(this.isDestroyed)return!1;if(this.verifyDomain)for(var o=0;o<this.listeners.length;o++){var s=this.listeners[o];s.originalHandler===i&&(n=s.handler)}t=this.namespaceEvent(t);var r=this.origin;if((0,e.subscriptionArgsInvalid)(t,n,r))return!1;var a=e.subscribers[r]&&e.subscribers[r][t];if(!a)return!1;for(o=0;o<a.length;o++)if(a[o]===n)return a.splice(o,1),!0;return!1},i.prototype.teardown=function(){if(!this.isDestroyed){this.isDestroyed=!0;for(var e=0;e<this.listeners.length;e++){var t=this.listeners[e];this.off(t.eventName,t.handler)}this.listeners.length=0}},i.prototype.passesVerifyDomainCheck=function(e){return!this.verifyDomain||this.checkOrigin(e)},i.prototype.targetFramesAsWindows=function(){return this.limitBroadcastToFramesArray?this.targetFrames.map((function(e){return e instanceof HTMLIFrameElement?e.contentWindow:e})).filter((function(e){return e})):[]},i.prototype.hasMatchingTargetFrame=function(e){if(!this.limitBroadcastToFramesArray)return!0;var t=this.targetFramesAsWindows().find((function(t){return t===e}));return Boolean(t)},i.prototype.checkOrigin=function(e){var t,i=document.createElement("a");return i.href=location.href,t="https:"===i.protocol?i.host.replace(/:443$/,""):"http:"===i.protocol?i.host.replace(/:80$/,""):i.host,i.protocol+"//"+t===e||!this.verifyDomain||this.verifyDomain(e)},i.prototype.namespaceEvent=function(e){return this.channel?"".concat(this.channel,":").concat(e):e},i.Promise=t,i}();return y.Framebus=i,y}var L,R,g=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},S={},D={};Object.defineProperty(D,"__esModule",{value:!0});var C,P,b={};function M(){return P||(P=1,e=a,i=t&&t.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=t&&t.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)},Object.defineProperty(e,"__esModule",{value:!0}),o(function(){if(n)return l;n=1,Object.defineProperty(l,"__esModule",{value:!0}),l.detach=l.attach=void 0;var e=M(),t=!1;return l.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},l.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},l}(),e),o(function(){if(s)return c;s=1,Object.defineProperty(c,"__esModule",{value:!0}),c.broadcastToChildWindows=void 0;var e=M();return c.broadcastToChildWindows=function(t,i,n){for(var o=e.childWindows.length-1;o>=0;o--){var s=e.childWindows[o];s.closed?e.childWindows.splice(o,1):n!==s&&(0,e.broadcast)(t,{origin:i,frame:s.top})}},c}(),e),o(function(){if(r)return d;r=1,Object.defineProperty(d,"__esModule",{value:!0}),d.broadcast=void 0;var e=M();return d.broadcast=function t(i,n){var o,s=0,r=n.origin,a=n.frame;try{for(a.postMessage(i,r),(0,e.hasOpener)(a)&&a.opener.top!==window.top&&t(i,{origin:r,frame:a.opener.top});o=a.frames[s];)t(i,{origin:r,frame:o}),s++}catch(e){}},d}(),e),o(u,e),o(function(){if(E)return _;E=1,Object.defineProperty(_,"__esModule",{value:!0}),_.dispatch=void 0;var e=M();return _.dispatch=function(t,i,n,o,s){if(e.subscribers[t]&&e.subscribers[t][i]){var r=[];n&&r.push(n),o&&r.push(o);for(var a=0;a<e.subscribers[t][i].length;a++)e.subscribers[t][i][a].apply(s,r)}},_}(),e),o(h,e),o(I,e),o(function(){if(p)return v;p=1,Object.defineProperty(v,"__esModule",{value:!0}),v.onMessage=void 0;var e=M();return v.onMessage=function(t){if(!(0,e.isntString)(t.data)){var i=(0,e.unpackPayload)(t);if(i){var n=i.eventData,o=i.reply;(0,e.dispatch)("*",i.event,n,o,t),(0,e.dispatch)(t.origin,i.event,n,o,t),(0,e.broadcastToChildWindows)(t.data,i.origin,t.source)}}},v}(),e),o(function(){if(f)return m;f=1,Object.defineProperty(m,"__esModule",{value:!0}),m.packagePayload=void 0;var e=M();return m.packagePayload=function(t,i,n,o){var s,r={event:t,origin:i};"function"==typeof o&&(r.reply=(0,e.subscribeReplier)(o,i)),r.eventData=n;try{s=e.prefix+JSON.stringify(r)}catch(e){throw new Error("Could not stringify event: ".concat(e.message))}return s},m}(),e),o(N,e),o(function(){if(L)return O;L=1;var e=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(O,"__esModule",{value:!0}),O.subscribeReplier=void 0;var i=A(),n=e(g);return O.subscribeReplier=function(e,t){var o=(0,n.default)();return i.Framebus.target({origin:t}).on(o,(function n(s,r){e(s,r),i.Framebus.target({origin:t}).off(o,n)})),o},O}(),e),o(function(){if(R)return S;R=1,Object.defineProperty(S,"__esModule",{value:!0}),S.subscriptionArgsInvalid=void 0;var e=M();return S.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},S}(),e),o(D,e),o(function(){if(C)return b;C=1,Object.defineProperty(b,"__esModule",{value:!0}),b.unpackPayload=void 0;var e=M();return b.unpackPayload=function(t){var i;if(t.data.slice(0,e.prefix.length)!==e.prefix)return!1;try{i=JSON.parse(t.data.slice(e.prefix.length))}catch(e){return!1}if(i.reply){var n=t.origin,o=t.source,s=i.reply;i.reply=function(t){if(o){var i=(0,e.packagePayload)(s,n,t);i&&o.postMessage(i,n)}}}return i},b}(),e)),a;var e,i,o}var w=M(),U=A();(0,w.attach)();const k=i(U.Framebus);class Y{constructor(e){this.origin=null,this.listeners=[],this.bus=new k(e)}static getInstance(){return Y.instance||(Y.instance=new Y),Y.instance}on(e,t){return this.bus.on(e,t)}off(e,t){return this.bus.off(e,t)}emit(e,t,i=void 0){return this.bus.emit(e,t,i)}target(e){return this.bus.target(e)}}e.IframeEventBus=Y,e.getEventBus=()=>Y.getInstance()}(k);const Y={INITIALIZE_CLIENT:"%s1 - Initializing skyflow client.",CLIENT_INITIALIZED:"%s1 - Initialized skyflow client successfully.",CREATE_COLLECT_CONTAINER:"%s1 - Creating Collect container.",COLLECT_CONTAINER_CREATED:"%s1 - Created Collect container successfully.",VALIDATE_RECORDS:"%s1 - Validating insert records.",VALIDATE_DETOKENIZE_INPUT:"%s1 - Validating detokenize input.",VALIDATE_GET_INPUT:"%s1 - Validating get input.",VALIDATE_DELETE_INPUT:"%s1 - Validating delete input.",VALIDATE_COLLECT_RECORDS:"%s1 - Validating collect element input.",CREATED_ELEMENT:"%s1 - Created %s2 element.",ELEMENT_MOUNTED:"%s1 - %s2 Element mounted.",COLLECT_SUBMIT_SUCCESS:"%s1 - Data has been collected successfully.",INSERT_DATA_SUCCESS:"%s1 - Data has been inserted successfully.",DELETE_SUCCESS:"%s1 - Data has been deleted successfully.",BEARER_TOKEN_LISTENER:"%s1 - Get bearer token listener added.",CAPTURED_BEARER_TOKEN_EVENT:"%s1 - Captured bearer token event.",BEARER_TOKEN_RESOLVED:"%s1 - GetBearerToken promise resolved successfully.",REUSE_BEARER_TOKEN:"%s1 - Reusing the bearer token.",PUREJS_CONTROLLER_INITIALIZED:"%s1 - SkyflowController initialized.",PUREJS_LISTENER_READY:"%s1 - Purejs listener ready.",EMIT_PURE_JS_CONTROLLER:"%s1 - Emitted Skyflow controller event.",INSERT_TRIGGERED:"%s1 - Insert method triggered.",DETOKENIZE_TRIGGERED:"%s1 - Detokenize method triggered.",GET_TRIGGERED:"%s1 - Get method triggered.",GET_BY_ID_TRIGGERED:"%s1 - Get method triggered.",DELETE_TRIGGERED:"%s1 - Delete method triggered.",EMIT_PURE_JS_REQUEST:"%s1 - Emitted %s2 request.",CAPTURE_PURE_JS_REQUEST:"%s1 - Captured %s2 event.",LISTEN_PURE_JS_REQUEST:"%s1 - Listening to %s2 event.",CAPTURE_PUREJS_FRAME:"%s1 - Captured SkyflowController frame ready event.",FETCH_RECORDS_RESOLVED:"%s1 - Detokenize request is resolved.",INSERT_RECORDS_RESOLVED:"%s1 - Insert request is resolved.",GET_RESOLVED:"%s1 - Get request is resolved.",GET_BY_SKYFLOWID_RESOLVED:"%s1 - GetById request is resolved.",DELETE_RESOLVED:"%s1 - Delete request is resolved",EMIT_EVENT:"%s1 - %s2 event emitted",CAPTURE_EVENT:"%s1 - Captured event %s2",LISTEN_COLLECT_FRAME_READY:"%s1 - Listening to collect FRAME_READY event",EMIT_COLLECT_ELEMENT_FRAME_READY:"%s1 - Emitting collect element %s2 FRAME_READY event",ENTERED_COLLECT_FRAME_READY_CB:"%s1 - In IFrameForm constructor, Entered FRAME_READY callback",EXECUTE_COLLECT_ELEMENT_FRAME_READY_CB:"%s1 - In IFrameForm, executing collect element, %s2 FRAME_READY callback",CLIENT_METADATA_NOT_SET:"%s1 - Client metadata not set",EXECUTE_COLLECT_ELEMENT_INIT:"%s1 - calling Collect element init",INSIDE__COLLECT_ELEMENT_INIT:"%s1 - Inside Collect element init for %s2",CREATING_COLLECT_ELEMENT_FORM:"%s1 - Start, creating iframe form for %s2",COLLECT_FRAME_READY_CB:"%s1 - In FrameElements, executing collect element FRAME_READY cb for %s2, sending metadata",INSIDE_FRAME_ELEMENTS_CONSTRUCOTR:"%s1 - Inside FrameElements constructor",SETUP_IN_START:"%s1 - Inside FrameElements start(), calling setup",SETUP_IN_CONSTRUCTOR:"%s1 - Inside FrameElements constructor, calling setup",COLLECT_ELEMET_START:"%s1 - %s2, Collect Element start",COLLECT_CONTROLLER_START:"%s1 - %s2, Collect Controller start",EMIT_COLLECT_FRAME_CONTROLLER_EVENT:"%s1 - Emit collect FrameController FRAME_READY event",EXECUTE_COLLECT_CONTROLLER_READY_CB:"%s1 - Executing collect FrameController FRAME_READY callback, set client metadata",IFRAMEFORM_CONSTRUCTOR_FRAME_READY_LISTNER:"%s1 - In IFrameForm constructor, Adding listner for FRAME_READY event",IFRAMEFORM_CONSTRUCTOR_TOKENIZATION_LISTNER:"%s1 - In IFrameForm constructor, Adding listner for TOKENIZATION_REQUEST event",CURRENT_ENV:"%s1 - Client Env is %s2",CURRENT_LOG_LEVEL:"%s1 - Client LogLevel is %s2",VALIDATE_GET_BY_ID_INPUT:"%s1 - Validating getByID input."},x={CLIENT_CONNECTION:"Interface: collect container - client connection not established. client info has not reached iframes",INVALID_BEARER_TOKEN:"Interface: init - Invalid token is generated from getBearerToken callback",BEARER_TOKEN_REJECTED:"Interface: init - GetBearerToken promise got rejected.",VAULTID_IS_REQUIRED:"Interface: init - Invalid client credentials. vaultID is required.",EMPTY_VAULTID_IN_INIT:"Interface: init - Invalid client credentials. vaultID cannot be empty.",VAULTURL_IS_REQUIRED:"Interface: init - Invalid client credentials. vaultURL is required.",EMPTY_VAULTURL_IN_INIT:"Interface: init - Invalid client credentials. vaultURL cannot be empty.",INVALID_VAULTURL_IN_INIT:"Interface: init - Invalid client credentials. Expecting https://XYZ for vaultURL",GET_BEARER_TOKEN_IS_REQUIRED:"Interface: init - Invalid client credentials. getBearerToken is required.",EMPTY_CONTAINER_TYPE:"Interface: client {containerType} container - Invalid container type. Container object cannot be empty.",INVALID_CONTAINER_TYPE:"Interface: client {containerType} container - Invalid container type. Invalid container object.",INVALID_COLLECT_VALUE:"Invalid value",INVALID_COLLECT_VALUE_WITH_LABEL:"Invalid %s1",REQUIRED_COLLECT_VALUE:"%s1 is required",DEFAULT_REQUIRED_COLLECT_VALUE:"Field is required",RECORDS_KEY_NOT_FOUND:"Interface: client insert - records object is required.",INVALID_RECORDS_IN_INSERT:"Interface: client insert - Invalid records. records object should be an array.",EMPTY_RECORDS_IN_INSERT:"Interface: client insert - records array cannot be empty.",MISSING_TABLE_IN_INSERT:'Interface: client insert - "table" key is required in records array at index %s1',EMPTY_TABLE_IN_INSERT:"Interface: client insert - table cannot be empty in records array at index %s1",INVALID_TABLE_IN_INSERT:"Interface: client insert - table of type string is required at index %s1 in records array.",EMPTY_FIELDS_IN_INSERT:"Interface: client insert - fields cannot be empty in records array at index %s1",MISSING_FIELDS_IN_INSERT:'Interface: client insert - "fields" key is required in records array at index %s1',INVALID_FIELDS_IN_INSERT:"Interface: client insert - fields of type object is required at index %s1 in records array.",INVALID_TOKENS_IN_INSERT:"Interface: client insert - Invalid tokens in options. tokens of type boolean is required.",RECORDS_KEY_NOT_FOUND_DELETE:"Interface: client delete - records object is required.",INVALID_RECORDS_IN_DELETE:"Interface: client delete - Invalid records. records object should be an array.",EMPTY_RECORDS_IN_DELETE:"Interface: client delete - records array cannot be empty.",MISSING_TABLE_IN_DELETE:'Interface: client delete - "table" key is required in records array at index %s1',EMPTY_TABLE_IN_DELETE:"Interface: client delete - table cannot be empty in records array at index %s1",INVALID_TABLE_IN_DELETE:"Interface: client delete - table of type string is required at index %s1 in records array.",MISSING_ID_IN_DELETE:'Interface: client delete - "id" key is required in records array at index %s1',EMPTY_ID_IN_DELETE:"Interface: client delete - id cannot be empty in records array at index %s1",INVALID_ID_IN_DELETE:"Interface: client delete - id of type string is required at index %s1 in records array.",DELETE_RECORDS_REJECTED:"Interface: client delete - delete request is rejected.",INVALID_TOKENS_IN_COLLECT:"Interface: collect container - Invalid tokens. tokens of type boolean is required.",RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS:'Interface: collect container - "records" key not found in additionalFields',INVALID_RECORDS_IN_ADDITIONAL_FIELDS:"Interface: collect container - records should be an array inside additionalFields",EMPTY_RECORDS_IN_ADDITIONAL_FIELDS:"Interface: collect container - records object cannot be empty in additionalFields",MISSING_TABLE_IN_ADDITIONAL_FIELDS:'Interface: collect container - "table" key not found in additionalFields records at index %s1',INVALID_TABLE_IN_ADDITIONAL_FIELDS:"Interface: collect container - Provide valid table name in additionalFields records at index %s1",INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:"Interface: collect container - Provide valid skyflow id in additionalFields records at index %s1",MISSING_FIELDS_IN_ADDITIONAL_FIELDS:'Interface: collect container - "fields" key not found in additionalFields records at index %s1',INVALID_FIELDS_IN_ADDITIONAL_FIELDS:"Interface: collect container - Provide valid fields in additionalFields records at index %s1",RECORDS_KEY_NOT_FOUND_DETOKENIZE:"Interface: client detokenize - records object is required.",EMPTY_RECORDS_DETOKENIZE:"Interface: client detokenize - records array cannot be empty.",INVALID_RECORDS_IN_DETOKENIZE:"Interface: client detokenize - Invalid records. records object should be an array.",MISSING_TOKEN_IN_DETOKENIZE:'Interface: client detokenize - "token" key is required in records array at index %s1 ',INVALID_TOKEN_IN_DETOKENIZE:"Interface: client detokenize - Invalid token. token of type string is required at index %s1 in records array.",RECORDS_KEY_NOT_FOUND_GET:"Interface: client get - records object is required.",INVALID_RECORDS_IN_GET:"Interface: client get - Invalid records. records object should be an array.",EMPTY_RECORDS_GET:"Interface: client get - records array cannot be empty.",MISSING_IDS_IN_GET:'Interface: client get - "ids" key is required in records array at index %s1',INVALID_IDS_IN_GET:"Interface: client get - Invalid ids. ids object should be an array.",INVALID_COLUMN_VALUES_IN_GET:"Interface: client get - Invalid column values. column values object should be an array.",EMPTY_IDS_IN_GET:"Interface: client get - ids array cannot be empty at index %s1",INVALID_SKYFLOWID_TYPE_IN_GET:"Interface: client get - Invalid skyflowId in ids array at index %s1",MISSING_TABLE_IN_GET:'Interface: client get - "table" key is required in records array at index %s1',INVALID_TABLE_IN_GET:"Interface: client get - table of type string is required at index %s1 in records array.",MISSING_REDACTION_IN_GET:'Interface: client get - "redaction" key is required in records array at index %s1',INVALID_REDACTION_TYPE_IN_GET:"Interface: client get - Invalid redaction type in records array at index %s1",INVALID_TOKENS_IN_GET:"Interface: client get - Invalid tokens in options. tokens of type boolean is required.",TOKENS_GET_COLUMN_NOT_SUPPORTED:"Interface: client get - column_name or column_values cannot be used with tokens in options.",REDACTION_WITH_TOKENS_NOT_SUPPORTED:"Interface: client get - redaction cannot be used when tokens are true in options.",INVALID_REDACTION_TYPE_IN_DETOKENIZE:"Interface: client get - Invalid redaction type in records array at index %s1",EMPTY_TABLE_IN_ADDITIONAL_FIELDS:"Interface: collect container - table cannot be empty in additionalFields at index %s1",EMPTY_FIELDS_IN_ADDITIONAL_FIELDS:"Interface: collect container - fields cannot be empty in additionalFields at index %s1",EMPTY_TOKEN_IN_DETOKENIZE:"Interface: client detokenize - token cannot be empty in records array at index %s1",EMPTY_SKYFLOWID_IN_GET:"Interface: client get - id cannot be empty in records array at index %s1",EMPTY_TABLE_IN_GET:"Interface: client get - table cannot be empty in records array at index %s1",EMPTY_REDACTION_TYPE_IN_GET:"Interface: client get - redaction cannot be empty in records array at index %s1",FETCH_RECORDS_REJECTED:"Interface: client detokenize - detokenize request is rejected.",INSERT_RECORDS_REJECTED:"Interface: client insert - insert request is rejected.",GET_REJECTED:"Interface: client get - get request is rejected.",MISSING_TABLE_IN_COLLECT:'Interface: collect element - "table" key is required.',EMPTY_TABLE_IN_COLLECT:"Interface: collect element - table cannot be empty.",EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:"Interface: collect element - id cannot be empty.",INVALID_TABLE_IN_COLLECT:"Interface: collect element - Invalid table. table of type string is required",INVALID_SKYFLOWID_IN_COLLECT:"Interface: collect element - Invalid id. id of type string is required",MISSING_COLUMN_IN_COLLECT:'Interface: collect element - "column" key is required.',EMPTY_COLUMN_IN_COLLECT:"Interface: collect element - column cannot be empty.",INVALID_COLUMN_IN_COLLECT:"Interface: collect element - Invalid column. column of type string is required",UNIQUE_ELEMENT_NAME:"The element name has to unique: %s1",ELEMENTS_NOT_MOUNTED:"Interface: collect container - Elements should be mounted before invoking collect",DUPLICATE_ELEMENT:"Interface: collect container - Duplicate column %s1 found in %s2.",DUPLICATE_ELEMENT_ADDITIONAL_FIELDS:"Interface: collect container - Duplicate column %s1 found in %s2 in additional fields",MISSING_ELEMENT_TYPE:'Interface:container element with type {TYPE} - Invalid element type. "type" key is required.',EMPTY_ELEMENT_TYPE:"Interface:container element with type {TYPE} - Invalid element type. type cannot be empty.",INVALID_ELEMENT_TYPE:"Interface:container element with type {TYPE} - invalid element type. type not found",INVALID_ELEMENT_SELECTOR:"Interface: container element with type {TYPE} - Div cannot be found.",CANNOT_CHANGE_ELEMENT:"Element can't be changed.",INVALID_IFRAME:"Error occured while creating an iframe",INVALID_FIELD:"Invalid Field.",FRAME_NOT_FOUND:"Interface: collect element - %s1 frame not found:",COMPLETE_AND_VALID_INPUTS:"Interface: collect container - Provide complete and valid inputs for %s1",REQUIRED_PARAMS_NOT_PROVIDED:"Interface: collect element - Required params are not provided.",INVALID_EVENT_TYPE:"Interface: collect element - Provide a valid event type.",INVALID_EVENT_LISTENER:'Interface: "on" on CollectElement - Provide valid event listener.',MISSING_HANDLER_IN_EVENT_LISTENER:'Interface: "on" on CollectElement - Second argument is missing. handler cannot be empty.',INVALID_HANDLER_IN_EVENT_LISTENER:'Interface: "on" on CollectElement - Invalid handler. handler should be of type function.',UNKNOWN_ERROR:"Unknown Error.",NETWORK_ERROR:"A network error occurred. This could be a CORS issue or a dropped internet connection. It is not possible for us to know. Please reach out to skyflow if you see this error",CONNECTION_ERROR:"Error while initializing the connection.",ERROR_OCCURED:"Error occurred.",INVALID_VALIDATIONS_TYPE:"Interface: collect element - Invalid validations type.",MISSING_VALIDATION_RULE_TYPE:"Interface: collect element - Type is missing in validationRule at index %s1 in validations array",INVALID_VALIDATION_RULE_TYPE:"Interface: collect element - Invalid ValidationRuleType at index %s1 in validations array",MISSING_VALIDATION_RULE_PARAMS:"Interface: collect element - params are missing in validationRule at index %s1 in validations array",INVALID_VALIDATION_RULE_PARAMS:"Interface: collect element - Invalid ValidationRule params at index %s1 in validations array",MISSING_REGEX_IN_REGEX_MATCH_RULE:"Interface: collect element - Missing regex in ValidationRule params at index %s1 in validations array",INVALID_REGEX_IN_REGEX_MATCH_RULE:"Interface: collect element - Invalid regex in ValidationRule params at index %s1 in validations array",MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE:"Interface: collect element - Either min or max is required in ValidationRule params at index %s1 in validations array",MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE:"Interface: collect element - Missing element in ValidationRule params at index %s1 in validations array",INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE:"Interface: collect element - Invalid collect element in ValidationRule params at index %s1 in validations array",ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE:"Interface: collect element - collect element is not mounted in ValidationRule params at index %s1 in validations array",EMPTY_ELEMENT_IN_MOUNT:"Interface: mount element with type %s1 - Mount cannot be empty.",VALIDATION_FAILED:"Validation failed",INVALID_UPSERT_OPTION_TYPE:"Invalid upsert option, should be an array",EMPTY_UPSERT_OPTIONS_ARRAY:"upsert option cannot be an empty array, atleast one object of table and column is required.",INVALID_UPSERT_OPTION_OBJECT_TYPE:"Invalid upsert object at index %s1, an object of table and column is required.",MISSING_TABLE_IN_UPSERT_OPTION:'"table" key is required in upsert options object at index %s1',MISSING_COLUMN_IN_UPSERT_OPTION:'"column" key is required in upsert option at index %s1',INVALID_TABLE_IN_UPSERT_OPTION:"Invalid table in upsert object at index %s1, table of type non empty string is required",INVALID_COLUMN_IN_UPSERT_OPTION:"Invalid column in upsert object at index %s1, column of type non empty string is required",INVALID_RECORD_COLUMN_VALUE:"Invalid Record Column value.",MISSING_RECORD_COLUMN_VALUE:"Column Values is required when Column Name is specified.",MISSING_RECORD_COLUMN_NAME:"Column Name is required when Column Values are specified.",INVALID_RECORD_COLUMN_VALUE_TYPE:"Invalid Type of Records Column Values.",INVALID_COLUMN_VALUES_TYPE:"Invalid column values type, should be an Array.",EMPTY_RECORD_COLUMN_VALUES:"Record column values cannot be empty.",EMPTY_COLUMN_VALUE:"Column Value is empty.",MISSING_IDS_OR_COLUMN_VALUES_IN_GET:'Interface: client get - "ids" key or "columnValues" key is missing.',SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED:"ids and columnName can not be specified together.",GET_BY_SKYFLOWID_RESOLVED:"%s1 - GetById request is resolved.",RECORDS_KEY_NOT_FOUND_GETBYID:"Interface: client getById - records object is required.",INVALID_RECORDS_IN_GETBYID:"Interface: client getById - Invalid records. records object should be an array.",EMPTY_RECORDS_GETBYID:"Interface: client getById - records array cannot be empty.",MISSING_IDS_IN_GETBYID:'Interface: client getById - "ids" key is required in records array at index %s1',INVALID_IDS_IN_GETBYID:"Interface: client getById - Invalid ids. ids object should be an array.",EMPTY_IDS_IN_GETBYID:"Interface: client getById - ids array cannot be empty at index %s1",INVALID_SKYFLOWID_TYPE_IN_GETBYID:"Interface: client getById - Invalid skyflowId in ids array at index %s1",MISSING_TABLE_IN_GETBYID:'Interface: client getById - "table" key is required in records array at index %s1',INVALID_TABLE_IN_GETBYID:"Interface: client getById - table of type string is required at index %s1 in records array.",MISSING_REDACTION_IN_GETBYID:'Interface: client getById - "redaction" key is required in records array at index %s1',INVALID_REDACTION_TYPE_IN_GETBYID:"Interface: client getById - Invalid redaction type in records array at index %s1",EMPTY_SKYFLOWID_IN_GETBYID:"Interface: client getById - id cannot be empty in records array at index %s1",EMPTY_TABLE_IN_GETBYID:"Interface: client getById - table cannot be empty in records array at index %s1",EMPTY_REDACTION_TYPE_IN_GETBYID:"Interface: client getById - redaction cannot be empty in records array at index %s1",GET_BY_SKYFLOWID_REJECTED:"Interface: client getById - getById request is rejected.",MISSING_COMPOSABLE_LAYOUT_KEY:"Interface: client container - layout is required in composable container options.",EMPTY_COMPOSABLE_LAYOUT_ARRAY:"Interface: client container - layout array cannot be empty in composable container options.",INVALID_COMPOSABLE_LAYOUT_TYPE:"Interface: client container - invalid layout value, layout should be of type array of numbers in composable container options.",NEGATIVE_VALUES_COMPOSABLE_LAYOUT:"Interface: client container - layout array should only have postive numbers in composable container options.",MISMATCH_ELEMENT_COUNT_LAYOUT_SUM:"Interface: composable container mount - created elements count should be equal to sum of layout values.",MISSING_COMPOSABLE_CONTAINER_OPTIONS:"Interface: client composable container - options object is required for composable container.",INVALID_COMPOSABLE_CONTAINER_OPTIONS:"Interface: client composable container - invalid options value, should be an object type.",COMPOSABLE_CONTAINER_NOT_MOUNTED:"Interface: composable collect - container should be mounted before invoking collect.",INVALID_BOOLEAN_OPTIONS:"Interface: container create - Invaild %s1 in options, %s1 of type boolean is required.",INVALID_INPUT_OPTIONS_FORMAT:"Interface: container create - Invalid type, format must be of non-empty string type.",INVALID_INPUT_OPTIONS_TRANSLATION:"Interface: container create - Invalid type, translation must be of non-empty object type.",EMPTY_COLLECT_CUSTOM_FORMAT:"Interface: container create - %s1 cannot be empty object."},V={INVALID_EXPIRATION_DATE_FORMAT:"EXPIRATION_DATE format must be in one of %s1, the format is set to default MM/YY",INVALID_EXPIRATION_YEAR_FORMAT:"EXPIRATION_YEAR format must be in one of %s1, the format is set to default YY",UNABLE_TO_SET_VALUE_IN_PROD_ENV:"%s1 setValue() cannot invoked while in PROD env. It is Not Recommeded",UNABLE_TO_CLEAR_VALUE_IN_PROD_ENV:"%s1 clearValue() cannot invoked while in PROD env. It is Not Recommeded",COLLECT_ALT_TEXT_DEPERECATED:"altText is DEPERECATED, passing altText will not have any effect",GET_BY_ID_DEPRECATED:"getById is deprecated, use new get method",INPUT_FORMATTING_NOT_SUPPROTED:"format or translation are not supported on %s1 element type.",INVALID_INPUT_TRANSLATION:"invalid or unsupported translation provided for %s1 element type."},F="collect_controller",G="element",B="INSERT",j="GET_BY_SKYFLOWID",X="GET",W="DELETE",$={CHANGE:"CHANGE",READY:"READY",FOCUS:"FOCUS",BLUR:"BLUR",ESCAPE:"ESCAPE",CLICK:"CLICK",ERROR:"ERROR",SUCCESS:"SUCCESS",SUBMIT:"SUBMIT",CREATED:"CREATED",MOUNTED:"MOUNTED",HEIGHT:"HEIGHT"},z="FRAME_READY",H="TOKENIZATION_REQUEST",K="INPUT_EVENT",q="DESTROY FRAME",J="SET_VALUE",Z="PUREJS_REQUEST",Q="PUREJS_FRAME_READY",ee="GET_BEARER_TOKEN",te="COLLECT_ELEMENT_SET_ERROR",ie="COMPOSABLE_UPDATE_OPTIONS",ne="COMPOSABLE_CONTAINER_MOUNTED",oe="COLLECT_CONTAINER_MOUNTED";var se,re;!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"}(se||(se={})),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"}(re||(re={}));const ae={[re.AMEX]:["XXXX XXXXXX XXXXX",{X:"[0-9]"}],[re.VISA]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[re.MASTERCARD]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[re.DISCOVER]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[re.DINERS_CLUB]:["XXXX XXXXXX XXXXXX",{X:"[0-9]"}],[re.JCB]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[re.MAESTRO]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[re.UNIONPAY]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[re.HIPERCARD]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[re.DEFAULT]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[re.UNKNOWN]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}]},le={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},[se.CARDHOLDER_NAME]:{name:"cardHolderName",attributes:{type:"text",autocomplete:"cc-name"},sensitive:!0,regex:/^([a-zA-Z\\ \\,\\.\\-\\']{2,})$/},[se.CARD_NUMBER]:{name:"CARD_NUMBER",attributes:{type:"text",autocomplete:"cc-number",inputmode:"numeric"},sensitive:!0,mask:ae[re.DEFAULT],regex:/$|^[\s]*?([0-9]{2,6}[ -]?){3,5}[\s]*/},[se.EXPIRATION_DATE]:{name:"EXPIRATION_DATE",attributes:{type:"text",autocomplete:"cc-exp",inputmode:"numeric"},sensitive:!0},[se.EXPIRATION_MONTH]:{name:"EXPIRATION_MONTH",attributes:{maxLength:2,type:"text",inputmode:"numeric",autocomplete:"cc-exp-month"},sensitive:!0,mask:["XX",{X:"[0-9]"}]},[se.EXPIRATION_YEAR]:{name:"EXPIRATION_YEAR",attributes:{type:"text",inputmode:"numeric",autocomplete:"cc-exp-year"},sensitive:!0},[se.CVV]:{name:"CVV",attributes:{type:"text",inputmode:"numeric",maxLength:4},sensitive:!0,regex:/^$|^[0-9]{3,4}$/},[se.INPUT_FIELD]:{name:"INPUT_FIELD",sensitive:!0,attributes:{type:"text"}},[se.PIN]:{name:"PIN",attributes:{type:"text",inputmode:"numeric",maxLength:12,minLength:4},sensitive:!0,regex:/^$|^[0-9]{4,12}$/}},ce="XXXX-XXXX-XXXX-XXXX",de={height:"100%",width:"100%",margin:0,padding:0,border:0,position:"absolute",top:0,left:0,"user-select":"none"},ue={position:"absolute",top:0,width:0,height:0,visibility:"hidden",left:"-99999999px","user-select":"none"},Ee={width:"100%",height:"100%",border:"0",padding:"0",margin:"0",outline:"none"},_e={WEBPACKAUTOFILL:"-webkit-autofill",BASE:"base",FOCUS:"focus",COMPLETE:"complete",EMPTY:"empty",INVALID:"invalid",GLOBAL:"global",REQUIRED_ASTERISK:"requiredAsterisk"};_e.BASE,_e.REQUIRED_ASTERISK;const he={[re.VISA]:{regex:/^4\d*/,maxCardLength:19,cardLengthRange:[13,16]},[re.MASTERCARD]:{regex:/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720)\d*/,maxCardLength:16,cardLengthRange:[16]},[re.AMEX]:{regex:/^3[47]\d*/,maxCardLength:15,cardLengthRange:[15]},[re.DINERS_CLUB]:{regex:/^(36|38|30[0-5])\d*/,maxCardLength:16,cardLengthRange:[14,15,16,17,18,19]},[re.DISCOVER]:{regex:/^(6011|65|64[4-9]|622)\d*/,maxCardLength:16,cardLengthRange:[16,17,18,19]},[re.JCB]:{regex:/^35\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[re.HIPERCARD]:{regex:/^606282\d*/,maxCardLength:19,cardLengthRange:[14,15,16,17,18,19]},[re.UNIONPAY]:{regex:/^62\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[re.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]}};re.DEFAULT,re.AMEX,re.DINERS_CLUB,re.DISCOVER,re.HIPERCARD,re.JCB,re.MAESTRO,re.MASTERCARD,re.UNIONPAY,re.VISA;const Ie="MM/YY",pe=[Ie,"YYYY/MM","YY/MM","MM/YYYY"],fe=["YY","YYYY"];var ve;!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"}(ve||(ve={})),se.CARD_NUMBER,se.EXPIRATION_DATE,se.EXPIRATION_MONTH,se.EXPIRATION_YEAR,se.CVV,se.EXPIRATION_DATE,se.CARD_NUMBER,se.CARDHOLDER_NAME,se.INPUT_FIELD,x.INVALID_COLLECT_VALUE,se.PIN,se.EXPIRATION_MONTH,se.EXPIRATION_YEAR,se.CVV,se.EXPIRATION_DATE,se.CARD_NUMBER,se.CARDHOLDER_NAME,se.INPUT_FIELD,x.DEFAULT_REQUIRED_COLLECT_VALUE,se.PIN,se.EXPIRATION_MONTH,se.EXPIRATION_YEAR;const me=[se.CARDHOLDER_NAME,se.EXPIRATION_MONTH,se.PIN,se.CVV],Ne={X:"[0-9]"};class Te{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(Te.prototype,{constructor:e})}}
|
|
1
|
+
!function(e){"use strict";function t(e,t,i,n){return new(i||(i=Promise))((function(s,o){function r(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}l((n=n.apply(e,t||[])).next())}))}function i(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 n(e,t,i,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(e,i):s?s.value=i:t.set(e,i),i}e.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"}(e.ElementType||(e.ElementType={})),"function"==typeof SuppressedError&&SuppressedError;var s="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 r={};!function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t=(e=>(e.PAYRAILS_CLIENT_CONFIG_MALFORMED="payrails:client:init.config_malformed",e.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT="payrails:client:collectContainer.unmountable",e.PAYRAILS_CLIENT_UI_ELEMENT_MISSING="payrails:client:mount.ui_element_missing",e.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING="payrails:client:mount.parent_element_missing",e.PAYRAILS_CLIENT_SUBELEMENTS_RENDER_ERROR="payrails:client:mount.subelements_render_error",e.PAYRAILS_CLIENT_CARD_FORM_MISSING="payrails:client:pay.card_form_missing",e.PAYRAILS_CLIENT_GPAY_LOADING_ERROR="payrails:client:mount.gpay_loading_error",e.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING="payrails:client:init.gpay_config_missing",e.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR="payrails:client:mount.applepay_loading_error",e.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING="payrails:client:init.applepay_config_missing",e.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR="payrails:client:init.paypal_loading_error",e.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING="payrails:client:init.paypal_config_missing",e.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION="payrails:client:init.paypal_order_creation",e.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT="payrails:client:mount.paypal_button_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR="payrails:client:payment_executor.pay_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_3DS_ERROR="payrails:client:payment_executor.3ds_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR="payrails:client:payment_executor.confirm_error",e.PAYRAILS_API_UNAUTHORIZED="payrails:api:unauthorized",e.PAYRAILS_API_TOO_MANY_REQUESTS="payrails:api:too_many_requests",e.PAYRAILS_API_UNSUCCESSFUL="payrails:api:unsuccessful",e.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED="payrails:api:authorization_not_requested",e.PAYRAILS_API_AUTHENTICATION_ERROR="payrails:api:request_authentication_error",e.PAYRAILS_API_AUTHORIZATION_ERROR="payrails:api:request_authorization_error",e.PAYRAILS_CLIENT_API_URL_NOT_FOUND="payrails:client:api_url_not_found",e.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND="payrails:client:workflow_execution_not_found",e.PAYRAILS_CARD_FORM_CREATION_FAILED="payrails:card_form:iframe_creation_failed",e.PAYRAILS_CARD_FORM_IFRAME_URL_MISSING="payrails:card_form:iframe_url_missing",e.PAYRAILS_CLIENT_UNKNOWN_ERROR="payrails:client:unknown",e.PAYRAILS_API_UNKNOWN_ERROR="payrails:api:unknown",e.PAYRAILS_CLIENT_ONPAY_CALLBACK_FAILED="payrails:client:card.onpay_callback_failed",e.PAYRAILS_CARD_FORM_ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE="payrails.card_form.element_not_mounted_in_element_match_rule",e.PAYRAILS_CARD_FORM_REQUIRED_PARAMS_NOT_PROVIDED="payrails.card_form.required_params_not_provided",e.PAYRAILS_CARD_FORM_CLIENT_CONNECTION="payrails.card_form.client_connection",e.PAYRAILS_CARD_FORM_IFRAME_NOT_FOUND="payrails.card_form.iframe_not_found",e.PAYRAILS_CARD_FORM_IFRAME_LOADING_ERROR="payrails.card_form.iframe_loading_error",e.PAYRAILS_CARD_FORM_CSP_ERROR="payrails.card_form.iframe_csp_error",e.PAYRAILS_CARD_FORM_COMPLETE_AND_VALID_INPUTS="payrails.card_form.complete_and_valid_inputs",e.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED="payrails.card_form.collect_element_not_mounted",e.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK="payrails:client:generic_redirect.missing.redirect_link",e))(t||{});const i={"payrails:client:init.config_malformed":{description:"The provided configuration string is invalid. Please ensure it matches the required format and structure as defined in the documentation",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:unknown":{description:"Unknown Client",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:unauthorized":{description:"Unauthorized access to the Payrails API",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:too_many_requests":{description:"Too many requests to the Payrails API",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:unsuccessful":{description:"Unsuccessful request to the Payrails API",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collectContainer.unmountable":{description:"Collect container cannot be mounted",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.ui_element_missing":{description:"Colect container element does not exist",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:pay.card_form_missing":{description:"Trying to collect values from non-existent card form",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.gpay_loading_error":{description:"Google pay can not be initialized",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.paypal_loading_error":{description:"Paypal can not be initialized",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.paypal_order_creation":{description:"Paypal order creation failed",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.paypal_button_error":{description:"PaypalButtonError occurred",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.parent_element_missing":{description:"Parent element not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.subelements_render_error":{description:"Subelements could not be rendered. Please set id for the element first.",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:api_url_not_found":{description:"API URL not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:workflow_execution_not_found":{description:"Workflow execution not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.paypal_config_missing":{description:"Paypal config not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:authorization_not_requested":{description:"Authorization was not requested",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.gpay_config_missing":{description:"Google pay config not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.applepay_loading_error":{description:"Apple pay can not be initialized",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.applepay_config_missing":{description:"Apple pay config not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:card_form:iframe_creation_failed":{description:"Error occured while creating an iframe",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:card_form:iframe_url_missing":{description:"Iframe URL is missing",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:card.onpay_callback_failed":{description:"Callback passed to onPaymentButtonClicked threw an error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:request_authentication_error":{description:"Authentication error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:unknown":{description:"Unknown API error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:payment_executor.pay_error":{description:"Error occured while executing a payment",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:payment_executor.confirm_error":{description:"Error occured while confirming a payment",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:request_authorization_error":{description:"Authorization error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:payment_executor.3ds_error":{description:"Authorization failed after 3DS challenge.",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.element_not_mounted_in_element_match_rule":{description:"Interface: collect element - collect element is not mounted in ValidationRule params at index %s1 in validations array",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.required_params_not_provided":{description:"Interface: collect element - Required params are not provided.",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.client_connection":{description:"Interface: collect container - client connection not established. client info has not reached iframes",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.iframe_not_found":{description:"Interface: collect element - frame not found:",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.complete_and_valid_inputs":{description:"Interface: collect container - Provide complete and valid inputs",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.collect_element_not_mounted":{description:"Interface: composable collect - collect element is not mounted",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.iframe_loading_error":{description:"Interface: collect element - Error occured while loading iframe",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.iframe_csp_error":{description:"Interface: collect element - Content Security Policy error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:generic_redirect.missing.redirect_link":{description:"[Generic Redirect] Missing redirect link in response"}};var n=(e=>(e.ERROR="payrails:error",e.INFO="payrails:info",e.DEBUG="payrails:debug",e.WARN="payrails:warn",e))(n||{});class s extends Error{constructor(e,t){var n;const{description:o,docUrl:r,cause:a}=null!=t?t:{},{description:l,docUrl:d}=i[e]||{},c=null!=(n=null!=o?o:l)?n:"An unknown error occurred",u=null!=r?r:d;super(c),this.name=e,this.docUrl=u,this.cause=a,this.message=c,Error.captureStackTrace&&Error.captureStackTrace(this,s)}toJSON(){return{name:this.name,message:this.message,docUrl:this.docUrl,stack:this.stack,cause:this.cause}}}e.ERROR_CODES=t,e.PAYRAILS_OBSERVABILITY_EVENTS=n,e.PayrailsError=s}(r);var a={};!function(e){var t=Object.defineProperty,i=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,r=(e,i,n)=>i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n,a=(e,t)=>{for(var s in t||(t={}))n.call(t,s)&&r(e,s,t[s]);if(i)for(var s of i(t))o.call(t,s)&&r(e,s,t[s]);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!==s?s:"undefined"!=typeof self?self:{};function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var E,_,h,I={},p={},f={},v={},m={};Object.defineProperty(m,"__esModule",{value:!0}),m.subscribers=m.childWindows=m.prefix=void 0,m.prefix="/*framebus*/",m.childWindows=[],m.subscribers={};var N,T={},y={};Object.defineProperty(y,"__esModule",{value:!0}),y.hasOpener=void 0,y.hasOpener=function(e){return e.top===e&&null!=e.opener&&e.opener!==e&&!0!==e.opener.closed};var O={};Object.defineProperty(O,"__esModule",{value:!0}),O.isntString=void 0,O.isntString=function(e){return"string"!=typeof e};var A,L,g={},R={},S={};Object.defineProperty(S,"__esModule",{value:!0}),S.sendMessage=void 0,S.sendMessage=function(e,t,i){try{e.postMessage(t,i)}catch(e){}};var C,D={},b={};function P(){if(C)return b;C=1,Object.defineProperty(b,"__esModule",{value:!0}),b.Framebus=void 0;var e=B(),t="undefined"!=typeof window&&window.Promise,i=function(){function i(e){void 0===e&&(e={}),this.origin=e.origin||"*",this.channel=e.channel||"",this.verifyDomain=e.verifyDomain,this.targetFrames=e.targetFrames||[],this.limitBroadcastToFramesArray=Boolean(e.targetFrames),this.isDestroyed=!1,this.listeners=[],this.hasAdditionalChecksForOnListeners=Boolean(this.verifyDomain||this.limitBroadcastToFramesArray)}return i.setPromise=function(e){i.Promise=e},i.target=function(e){return new i(e)},i.prototype.addTargetFrame=function(e){this.limitBroadcastToFramesArray&&this.targetFrames.push(e)},i.prototype.include=function(t){return null!=t&&null!=t.Window&&t.constructor===t.Window&&(e.childWindows.push(t),!0)},i.prototype.target=function(e){return i.target(e)},i.prototype.emit=function(t,i,n){if(this.isDestroyed)return!1;var s=this.origin;if(t=this.namespaceEvent(t),(0,e.isntString)(t))return!1;if((0,e.isntString)(s))return!1;"function"==typeof i&&(n=i,i=void 0);var o=(0,e.packagePayload)(t,s,i,n);return!!o&&(this.limitBroadcastToFramesArray?this.targetFramesAsWindows().forEach((function(t){(0,e.sendMessage)(t,o,s)})):(0,e.broadcast)(o,{origin:s,frame:window.top||window.self}),!0)},i.prototype.emitAsPromise=function(e,t){var n=this;return new i.Promise((function(i,s){n.emit(e,t,(function(e){i(e)}))||s(new Error('Listener not added for "'.concat(e,'"')))}))},i.prototype.on=function(t,i){if(this.isDestroyed)return!1;var n=this,s=this.origin,o=i;return t=this.namespaceEvent(t),!(0,e.subscriptionArgsInvalid)(t,o,s)&&(this.hasAdditionalChecksForOnListeners&&(o=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];n.passesVerifyDomainCheck(this&&this.origin)&&n.hasMatchingTargetFrame(this&&this.source)&&i.apply(void 0,e)}),this.listeners.push({eventName:t,handler:o,originalHandler:i}),e.subscribers[s]=e.subscribers[s]||{},e.subscribers[s][t]=e.subscribers[s][t]||[],e.subscribers[s][t].push(o),!0)},i.prototype.off=function(t,i){var n=i;if(this.isDestroyed)return!1;if(this.verifyDomain)for(var s=0;s<this.listeners.length;s++){var o=this.listeners[s];o.originalHandler===i&&(n=o.handler)}t=this.namespaceEvent(t);var r=this.origin;if((0,e.subscriptionArgsInvalid)(t,n,r))return!1;var a=e.subscribers[r]&&e.subscribers[r][t];if(!a)return!1;for(s=0;s<a.length;s++)if(a[s]===n)return a.splice(s,1),!0;return!1},i.prototype.teardown=function(){if(!this.isDestroyed){this.isDestroyed=!0;for(var e=0;e<this.listeners.length;e++){var t=this.listeners[e];this.off(t.eventName,t.handler)}this.listeners.length=0}},i.prototype.passesVerifyDomainCheck=function(e){return!this.verifyDomain||this.checkOrigin(e)},i.prototype.targetFramesAsWindows=function(){return this.limitBroadcastToFramesArray?this.targetFrames.map((function(e){return e instanceof HTMLIFrameElement?e.contentWindow:e})).filter((function(e){return e})):[]},i.prototype.hasMatchingTargetFrame=function(e){if(!this.limitBroadcastToFramesArray)return!0;var t=this.targetFramesAsWindows().find((function(t){return t===e}));return Boolean(t)},i.prototype.checkOrigin=function(e){var t,i=document.createElement("a");return i.href=location.href,t="https:"===i.protocol?i.host.replace(/:443$/,""):"http:"===i.protocol?i.host.replace(/:80$/,""):i.host,i.protocol+"//"+t===e||!this.verifyDomain||this.verifyDomain(e)},i.prototype.namespaceEvent=function(e){return this.channel?"".concat(this.channel,":").concat(e):e},i.Promise=t,i}();return b.Framebus=i,b}var M,w,U=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)}))},k={},x={};Object.defineProperty(x,"__esModule",{value:!0});var Y,F,V={};function B(){return F||(F=1,e=I,t=c&&c.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,s)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),i=c&&c.__exportStar||function(e,i){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(i,n)||t(i,e,n)},Object.defineProperty(e,"__esModule",{value:!0}),i(function(){if(E)return p;E=1,Object.defineProperty(p,"__esModule",{value:!0}),p.detach=p.attach=void 0;var e=B(),t=!1;return p.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},p.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},p}(),e),i(function(){if(_)return f;_=1,Object.defineProperty(f,"__esModule",{value:!0}),f.broadcastToChildWindows=void 0;var e=B();return f.broadcastToChildWindows=function(t,i,n){for(var s=e.childWindows.length-1;s>=0;s--){var o=e.childWindows[s];o.closed?e.childWindows.splice(s,1):n!==o&&(0,e.broadcast)(t,{origin:i,frame:o.top})}},f}(),e),i(function(){if(h)return v;h=1,Object.defineProperty(v,"__esModule",{value:!0}),v.broadcast=void 0;var e=B();return v.broadcast=function t(i,n){var s,o=0,r=n.origin,a=n.frame;try{for(a.postMessage(i,r),(0,e.hasOpener)(a)&&a.opener.top!==window.top&&t(i,{origin:r,frame:a.opener.top});s=a.frames[o];)t(i,{origin:r,frame:s}),o++}catch(e){}},v}(),e),i(m,e),i(function(){if(N)return T;N=1,Object.defineProperty(T,"__esModule",{value:!0}),T.dispatch=void 0;var e=B();return T.dispatch=function(t,i,n,s,o){if(e.subscribers[t]&&e.subscribers[t][i]){var r=[];n&&r.push(n),s&&r.push(s);for(var a=0;a<e.subscribers[t][i].length;a++)e.subscribers[t][i][a].apply(o,r)}},T}(),e),i(y,e),i(O,e),i(function(){if(A)return g;A=1,Object.defineProperty(g,"__esModule",{value:!0}),g.onMessage=void 0;var e=B();return g.onMessage=function(t){if(!(0,e.isntString)(t.data)){var i=(0,e.unpackPayload)(t);if(i){var n=i.eventData,s=i.reply;(0,e.dispatch)("*",i.event,n,s,t),(0,e.dispatch)(t.origin,i.event,n,s,t),(0,e.broadcastToChildWindows)(t.data,i.origin,t.source)}}},g}(),e),i(function(){if(L)return R;L=1,Object.defineProperty(R,"__esModule",{value:!0}),R.packagePayload=void 0;var e=B();return R.packagePayload=function(t,i,n,s){var o,r={event:t,origin:i};"function"==typeof s&&(r.reply=(0,e.subscribeReplier)(s,i)),r.eventData=n;try{o=e.prefix+JSON.stringify(r)}catch(e){throw new Error("Could not stringify event: ".concat(e.message))}return o},R}(),e),i(S,e),i(function(){if(M)return D;M=1;var e=c&&c.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(D,"__esModule",{value:!0}),D.subscribeReplier=void 0;var t=P(),i=e(U);return D.subscribeReplier=function(e,n){var s=(0,i.default)();return t.Framebus.target({origin:n}).on(s,(function i(o,r){e(o,r),t.Framebus.target({origin:n}).off(s,i)})),s},D}(),e),i(function(){if(w)return k;w=1,Object.defineProperty(k,"__esModule",{value:!0}),k.subscriptionArgsInvalid=void 0;var e=B();return k.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},k}(),e),i(x,e),i(function(){if(Y)return V;Y=1,Object.defineProperty(V,"__esModule",{value:!0}),V.unpackPayload=void 0;var e=B();return V.unpackPayload=function(t){var i;if(t.data.slice(0,e.prefix.length)!==e.prefix)return!1;try{i=JSON.parse(t.data.slice(e.prefix.length))}catch(e){return!1}if(i.reply){var n=t.origin,s=t.source,o=i.reply;i.reply=function(t){if(s){var i=(0,e.packagePayload)(o,n,t);i&&s.postMessage(i,n)}}}return i},V}(),e)),I;var e,t,i}var G=B(),j=P();(0,G.attach)();const X=u(j.Framebus);class W{constructor(e){this.origin=null,this.listeners=[],this.bus=new X(e)}static getInstance(){return W.instance||(W.instance=new W),W.instance}on(e,t){return this.bus.on(e,t)}off(e,t){return this.bus.off(e,t)}emit(e,t,i=void 0){return this.bus.emit(e,t,i)}target(e){return this.bus.target(e)}}class z{constructor(){this.bus=W.getInstance()}log(e,t){this.bus.emit(d.ERROR,{level:e,event:t})}}var H=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===K}(e)}(e)},K="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function $(e,t){return!1!==t.clone&&t.isMergeableObject(e)?ee((i=e,Array.isArray(i)?[]:{}),e,t):e;var i}function q(e,t,i){return e.concat(t).map((function(e){return $(e,i)}))}function J(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return Object.propertyIsEnumerable.call(e,t)})):[]}(e))}function Z(e,t){try{return t in e}catch(e){return!1}}function Q(e,t,i){var n={};return i.isMergeableObject(e)&&J(e).forEach((function(t){n[t]=$(e[t],i)})),J(t).forEach((function(s){(function(e,t){return Z(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,s)||(Z(e,s)&&i.isMergeableObject(t[s])?n[s]=function(e,t){if(!t.customMerge)return ee;var i=t.customMerge(e);return"function"==typeof i?i:ee}(s,i)(e[s],t[s],i):n[s]=$(t[s],i))})),n}function ee(e,t,i){(i=i||{}).arrayMerge=i.arrayMerge||q,i.isMergeableObject=i.isMergeableObject||H,i.cloneUnlessOtherwiseSpecified=$;var n=Array.isArray(t);return n===Array.isArray(e)?n?i.arrayMerge(e,t,i):Q(e,t,i):$(t,i)}ee.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,i){return ee(e,i,t)}),{})};const te=u(ee);class ie{constructor(){this.state={}}static getInstance(){return ie.instance||(ie.instance=new ie),ie.instance}getState(e){return this.state[e]}setState(e){this.state=te(this.state,e)}}const ne=ie.getInstance(),se=()=>window&&window.navigator,oe=()=>window&&window.screen,re=()=>({resolution:`${oe().width}x${oe().height}`,user_agent:se().userAgent,language:se().language});class ae{constructor(e){this.adapter=[new z],this.enabled=e.enabled||!0,this.initGlobalState(e),e.logLevel=e.logLevel||"error","debug"===e.logLevel&&this.addAdapter(new l)}static init(e){ae.instance=new ae(e)}static getLogger(){return ae.instance}initGlobalState(e){ne.setState({payrails:e.payrails,sdk:e.sdk})}static setState(e){ne.setState(e)}log(e,t,i){this.enabled&&this.adapter.forEach((n=>{n.log(e,{mssg:t,error:null==i?void 0:i.error,withMetada:a(a({},this.constructMetadata()),null==i?void 0:i.withMetada),extra:null==i?void 0:i.extra})}))}constructMetadata(){return{device:re(),payrails:ne.getState("payrails"),sdk:ne.getState("sdk")}}addAdapter(e){this.adapter.push(e)}static log(e,t){this.getLogger().log("info",e,t)}static debug(e,t){this.getLogger().log("debug",e,t)}static info(e,t){this.getLogger().log("info",e,t)}static warn(e,t){this.getLogger().log("warning",e,t)}static error(e,t){this.getLogger().log("error",e,t)}static exception(e,t){this.error(e,t)}}e.PayrailsLogger=ae,e.getDeviceInfo=re}(a);for(var l,d=[],c=0;c<256;++c)d.push((c+256).toString(16).slice(1));var u=new Uint8Array(16);function E(){if(!l&&!(l="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return l(u)}var _,h={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function I(e,t,i){if(h.randomUUID&&!t&&!e)return h.randomUUID();var n=(e=e||{}).random||(e.rng||E)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){i=i||0;for(var s=0;s<16;++s)t[i+s]=n[s];return t}return function(e,t=0){return(d[e[t+0]]+d[e[t+1]]+d[e[t+2]]+d[e[t+3]]+"-"+d[e[t+4]]+d[e[t+5]]+"-"+d[e[t+6]]+d[e[t+7]]+"-"+d[e[t+8]]+d[e[t+9]]+"-"+d[e[t+10]]+d[e[t+11]]+d[e[t+12]]+d[e[t+13]]+d[e[t+14]]+d[e[t+15]]).toLowerCase()}(n)}!function(e){e.GET="GET",e.POST="POST"}(_||(_={}));const p=({url:e,method:i=_.GET,token:n,body:s})=>t(void 0,void 0,void 0,(function*(){const t={method:i,headers:Object.assign(Object.assign(Object.assign({},y()),T(n)),O())};i===_.POST&&(t.body=JSON.stringify(s||{}));const o=yield fetch(e,t),r=yield o.json();if([401,403].includes(o.status))throw new f(e,i);if(429===o.status)throw new m(e,i);if(!o.ok)throw new v(e,i);return{ok:o.ok,req:Object.assign({url:e},t),res:r}}));class f extends r.PayrailsError{constructor(e,t){super(r.ERROR_CODES.PAYRAILS_API_UNAUTHORIZED,{description:`[${t}] ${e} unauthorized`})}}class v extends r.PayrailsError{constructor(e,t){super(r.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{description:`[${t}] ${e} unsuccessful`})}}class m extends r.PayrailsError{constructor(e,t){super(r.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} too many requests`})}}class N extends r.PayrailsError{constructor(e,t){super(r.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} max poll attempts exceeded.`})}}const T=e=>({authorization:`Bearer ${e}`}),y=()=>({"x-idempotency-key":I()}),O=()=>{const e={version:"5.8.1",type:"web-sdk"};return{"x-client-version":e.version,"x-client-type":e.type}},A=(i,n)=>t(void 0,void 0,void 0,(function*(){var t,s;if(null==i?void 0:i.onPaymentButtonClicked)try{const s=yield i.onPaymentButtonClicked(n);if(!s){const n=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_ONPAY_CALLBACK_FAILED,{description:"Callback passed to onPaymentButtonClicked resolved to false"});return a.PayrailsLogger.error(n.message,{error:n}),null===(t=null==i?void 0:i.onAuthorizeFailed)||void 0===t||t.call(i,{code:e.AuthorizationFailureReasons.VALIDATION_FAILED,message:n.message}),s}}catch(t){const n=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_ONPAY_CALLBACK_FAILED,{description:"Callback passed to onPaymentButtonClicked threw an error",cause:t});return a.PayrailsLogger.error(n.message,{error:n}),null===(s=i.onAuthorizeFailed)||void 0===s||s.call(i,{code:e.AuthorizationFailureReasons.VALIDATION_FAILED,message:n.message}),!1}return!0})),L={success:"https://payrails.io/success",error:"https://payrails.io/error",cancel:"https://payrails.io/cancel"};class g{constructor(e,t,i=L,n=680,s=60,o=2e3,r=5){this.sdkConfig=e,this.execution=t,this.returnLinks=i,this.POLL_INTERVAL=n,this.MAX_POLL_ATTEMPTS=s,this.POLL_INITIAL_DELAY=o,this.POLL_ERROR_COUNT_MULTIPLIER=r}pay(e){return t(this,void 0,void 0,(function*(){try{const t=(yield this.authorize(e)).res.links.execution;return yield this.pollForAuthorizationResult(t)}catch(e){const t=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR,{cause:e});throw a.PayrailsLogger.error(t.message,{error:t}),e}}))}confirm(e,i={}){return t(this,void 0,void 0,(function*(){try{const t=yield p({url:e,method:_.POST,token:this.sdkConfig.token,body:{data:i}}),n=yield this.pollForAuthorizationResult(t.res.links.execution);if(n.finalState)return n;const s=n.response.status.slice().sort(((e,t)=>new Date(t.time).getTime()-new Date(e.time).getTime()))[0].time,{res:o}=yield this.getExecution(t.res.links.execution,s);return{finalState:o.status.find((({code:e,time:t})=>["authorizeSuccessful","authorizeFailed"].includes(e)&&new Date(t)>new Date(s))),response:o}}catch(e){const t=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR,{cause:e});throw a.PayrailsLogger.error(t.message,{error:t}),e}}))}getExecution(e,i,n=0){return t(this,void 0,void 0,(function*(){if(n>this.MAX_POLL_ATTEMPTS)throw new N(e,_.GET);0===n&&i&&(yield this.wait(this.POLL_INITIAL_DELAY));try{const t=yield p({url:e,token:this.sdkConfig.token});return i&&!t.res.status.find((({time:e})=>new Date(e)>new Date(i)))?(yield this.wait(this.POLL_INTERVAL),this.getExecution(e,i,n+1)):t}catch(t){if(t instanceof v)return yield this.wait(this.POLL_INTERVAL),this.getExecution(e,i,n+this.POLL_ERROR_COUNT_MULTIPLIER);if(t instanceof m)return yield this.wait(this.POLL_INTERVAL*n),this.getExecution(e,i,n+1);throw t}}))}createApplePaySession(e){return t(this,void 0,void 0,(function*(){return p({url:e.requestUrl,method:_.POST,token:this.sdkConfig.token,body:{integrationType:"api",paymentMethodCode:"applePay",amount:this.sdkConfig.amount,meta:{sessionURL:e.sessionUrl,clientContext:{host:e.clientDomain||window.location.host}}}})}))}authorize(e){return t(this,void 0,void 0,(function*(){if(!this.execution.authorizeLink||!this.sdkConfig.amount){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND,{description:"SDK was not initialized with workflow execution"});throw a.PayrailsLogger.error(e.message,{error:e}),e}const{success:t,error:i,cancel:n}=this.returnLinks;return p({url:this.execution.authorizeLink,method:_.POST,token:this.sdkConfig.token,body:{amount:this.sdkConfig.amount,paymentComposition:e,returnInfo:{success:t,cancel:n,error:i}}})}))}wait(e){return t(this,void 0,void 0,(function*(){return new Promise((t=>setTimeout(t,e)))}))}pollForAuthorizationResult(e,i=0){return t(this,void 0,void 0,(function*(){const t=(yield this.getExecution(e)).res,n=t.status,s=["authorizePending","authorizeSuccessful","authorizeFailed"],o=n.find((({code:e})=>"authorizeRequested"===e));if(!o&&i<10)return yield new Promise((e=>setTimeout(e,this.POLL_INTERVAL))),this.pollForAuthorizationResult(e,i+1);if(!o){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED);throw a.PayrailsLogger.error(e.message,{error:e}),e}const l=n.find((({code:e,time:t})=>"confirmRequested"===e&&new Date(t)>new Date(o.time))),d=l?l.time:o.time;let c=n.find((({code:e,time:t})=>s.includes(e)&&new Date(t)>new Date(d)));if(!c){const{res:t}=yield this.getExecution(e,d);return c=t.status.find((({code:e,time:t})=>s.includes(e)&&new Date(t)>new Date(d))),{finalState:c,response:t}}return{finalState:c,response:t}}))}}class R{constructor(e,t,i,n,s=S.THREE_DS){this.link=e,this.execution=t,this.paymentExecutor=i,this.options=n,this.type=s,this.THREE_DS_SIZES=[[250,400],[390,400],[500,600],[600,400]],this.internalPopupBackground=null,this.SCREEN_WIDTH=window.innerWidth,this.SCREEN_HEIGHT=window.innerHeight}get iframeSize(){return this.type===S.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 i=n=>t(this,void 0,void 0,(function*(){var t,s,o,l;if(n.data&&'{"type":"3DS-challenge-completed"}'===n.data){if(window.removeEventListener("message",i),(yield this.paymentExecutor.getExecution(this.execution.url)).res.status.find((({code:e})=>"authorizeSuccessful"===e)))null===(l=null===(o=this.options.events)||void 0===o?void 0:o.onAuthorizeSuccess)||void 0===l||l.call(o);else{const i=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_3DS_ERROR);a.PayrailsLogger.error(i.message,{error:i}),null===(s=null===(t=this.options.events)||void 0===t?void 0:t.onAuthorizeFailed)||void 0===s||s.call(t,{code:e.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:"Authorization failed after 3DS challenge."})}this.unmount()}}));window.addEventListener("message",i)}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 S,C,D,b;!function(e){e[e.THREE_DS=0]="THREE_DS",e[e.GENERIC_REDIRECT=1]="GENERIC_REDIRECT"}(S||(S={}));class P{constructor(e,t,i){this.options=e,this.execution=t,this.paymentExecutor=i}handle3ds(e){var t,i,n;try{null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onThreeDSecureChallenge)||void 0===i||i.call(t)}catch(e){}const s=null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.links["3ds"];s&&new R(s,this.execution,this.paymentExecutor,this.options).mount()}}!function(e){e.CARD="card",e.GOOGLE_PAY="googlePay",e.PAYPAL="payPal",e.APPLE_PAY="applePay",e.GENERIC_REDIRECT="genericRedirect"}(C||(C={})),function(e){e.ENABLED="enabled",e.CREATED="created",e.DELETED="deleted",e.DISABLED="disabled",e.INVALID="invalid",e.TRANSIENT="transient"}(D||(D={}));class M{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(C.CARD)}get savedPaypalAccounts(){return this.getStoredInstrumentForPaymentMethod(C.PAYPAL)}get savedGooglePayAccounts(){return this.getStoredInstrumentForPaymentMethod(C.GOOGLE_PAY)}get savedApplePayAccounts(){return this.getStoredInstrumentForPaymentMethod(C.APPLE_PAY)}get paypalConfig(){const e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===C.PAYPAL));if(!e){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING);throw a.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:this.availablePaymentMethods}}),e}return e.config||{}}get googlePayConfig(){const e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===C.GOOGLE_PAY));if(!e){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING);throw a.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===C.APPLE_PAY));if(!e){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING);throw a.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 w{constructor(e,{id:t="",className:i=""}={}){this.subElements=[];const n=document.createElement(e);t&&(this.id=t,n.setAttribute("id",t)),i&&(Array.isArray(i)?n.setAttribute("class",function(...e){return e.filter(Boolean).join(" ")}(...i)):n.setAttribute("class",i)),this.element=n}get parentElement(){return this.element.parentElement}get selector(){if(!this.id)throw new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);return`#${this.id}`}mount(e){const t=document.querySelector(e);if(!t)throw new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING,{description:`Element with selector "${e}" not found in in the DOM`});this.clean(),t.appendChild(this.element),this.subElements.forEach((e=>{if(!this.id)throw new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_SUBELEMENTS_RENDER_ERROR);e.mount(this.selector)}))}clean(){var e;null===(e=document.getElementById(this.element.id))||void 0===e||e.remove()}unmount(){var e;this.subElements.forEach((e=>e.unmount())),null===(e=this.parentElement)||void 0===e||e.removeChild(this.element)}}class U extends w{get bin(){var e;return this.selectedInstrument?this.selectedInstrument.data.bin?this.selectedInstrument.data.bin:"":(null===(e=this.cardForm)||void 0===e?void 0:e.bin)||""}constructor(e,t,i,n){var s;super("button",{id:"payrails-card-payment-button"}),this.sdkConfig=e,this.execution=t,this.options=i,this.returnInfo=n,this.selectedInstrument=null,this.element.innerText=(null===(s=null==i?void 0:i.translations)||void 0===s?void 0:s.label)||"Pay",this.element.addEventListener("click",this.onPay.bind(this)),this.element.addEventListener("mouseenter",(()=>{var e;this.element.classList.contains("disabled")||(this.element.classList.add("hover"),this.setStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{}))})),this.element.addEventListener("mouseleave",(()=>{var e;this.element.classList.contains("disabled")||(this.element.classList.remove("hover"),this.removeStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{}))})),this.paymentExecutor=new g(this.sdkConfig,this.execution,this.returnInfo)}setDisabled(e){var t,i,n,s,o;this.element.classList.contains("disabled")!==e&&(null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onStateChanged)||void 0===i||i.call(t,e?"disabled":"enabled")),this.element.disabled=e,e?(this.element.classList.add("disabled"),(null===(n=this.options.styles)||void 0===n?void 0:n.disabled)&&this.setStyles(this.options.styles.disabled)):(this.element.classList.remove("disabled"),this.removeStyles((null===(s=this.options.styles)||void 0===s?void 0:s.disabled)||{}),(null===(o=this.options.styles)||void 0===o?void 0:o.base)&&this.setStyles(this.options.styles.base))}setSavedCreditCard(e){console.warn("setSavedCreditCard is deprecated, please use setSavedInstrument"),this.setSavedInstrument(e)}setSavedInstrument(e){this.selectedInstrument=e,this.setDisabled(!1)}setStyles(e){var t;const i=Object.assign(Object.assign({},null===(t=this.options.styles)||void 0===t?void 0:t.base),e);Object.keys(i).forEach((e=>{this.element.style[e]=i[e]}))}removeStyles(e){var t;const i=Object.keys((null===(t=this.options.styles)||void 0===t?void 0:t.base)||{});Object.keys(e).forEach((e=>{var t,n;i.includes(e)?this.element.style[e]=null===(n=null===(t=this.options.styles)||void 0===t?void 0:t.base)||void 0===n?void 0:n[e]:this.element.style[e]=""}))}setLabel(e){this.element.innerText=e}setCardForm(e){this.cardForm=e}triggerLoading(e){var t,i,n,s;const o=this.element.offsetWidth;this.element.style.minWidth=`${o}px`,e?(this.element.innerHTML='<div class="dot-flashing"></div>',this.element.classList.add("loading"),(null===(t=this.options.styles)||void 0===t?void 0:t.loading)&&this.setStyles(this.options.styles.loading)):(this.element.innerText=(null===(n=null===(i=this.options)||void 0===i?void 0:i.translations)||void 0===n?void 0:n.label)||"Pay",this.element.classList.remove("loading"),this.removeStyles((null===(s=this.options.styles)||void 0===s?void 0:s.loading)||{}))}onAuthorizationFailed(e){var t,i;this.setDisabled(!1),this.triggerLoading(!1),(null===(t=this.options.events)||void 0===t?void 0:t.onAuthorizeFailed)&&(null===(i=this.options.events)||void 0===i||i.onAuthorizeFailed(e))}onPay(){var i,n,s,o,l,d,c,u;return t(this,void 0,void 0,(function*(){if(this.setDisabled(!0),this.triggerLoading(!0),!(yield A(this.options.events,{bin:this.bin||""})))return this.setDisabled(!1),void this.triggerLoading(!1);try{let e=[{paymentMethodCode:C.CARD,integrationType:"api",amount:this.sdkConfig.amount,storeInstrument:!1}];if(null===(i=this.selectedInstrument)||void 0===i?void 0:i.id)e[0].paymentInstrumentId=null===(n=this.selectedInstrument)||void 0===n?void 0:n.id,e[0].paymentMethodCode=null===(s=this.selectedInstrument)||void 0===s?void 0:s.paymentMethod;else{if(!this.cardForm){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_CARD_FORM_MISSING);throw a.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(t){let i=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_API_AUTHENTICATION_ERROR,{cause:t});t instanceof f||[401,403].includes(null===(o=null==t?void 0:t.error)||void 0===o?void 0:o.code)?(null===(d=null===(l=this.options.events)||void 0===l?void 0:l.onPaymentSessionExpired)||void 0===d||d.call(l),i.message="API token is not valid or expired.",a.PayrailsLogger.error(i.message,{error:i}),this.onAuthorizationFailed({code:e.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:i.message})):t.toString().includes("Invalid token")?(null===(u=null===(c=this.options.events)||void 0===c?void 0:c.onPaymentSessionExpired)||void 0===u||u.call(c),i.message="Vault token is not valid or expired.",a.PayrailsLogger.error(i.message,{error:i})):i=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_API_UNKNOWN_ERROR,{cause:t}),this.onAuthorizationFailed({code:e.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:i.message})}}))}constructTokenizedPayment(e){return t(this,void 0,void 0,(function*(){const{storeInstrument:t,enrollInstrumentToNetworkOffers:i,cardData:n}=yield this.cardForm.collectValues();return e[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}},e[0].storeInstrument=t,e[0].enrollInstrumentToNetworkOffers=i,e}))}constructEncryptedPayment(e){return t(this,void 0,void 0,(function*(){const{cardData:t,storeInstrument:i,enrollInstrumentToNetworkOffers:n}=yield this.cardForm.collectValues();return e[0].paymentInstrumentData=Object.assign({},t),e[0].storeInstrument=i,e[0].enrollInstrumentToNetworkOffers=n,e}))}handleAuthorizationResult(t){var i,n,s;let o;switch(null===(i=null==t?void 0:t.finalState)||void 0===i?void 0:i.code){case"authorizeSuccessful":this.triggerLoading(!1),(null===(n=this.options.events)||void 0===n?void 0:n.onAuthorizeSuccess)&&this.options.events.onAuthorizeSuccess();break;case"authorizePending":"3ds"===(null===(s=null==t?void 0:t.response)||void 0===s?void 0:s.actionRequired)&&new P({events:Object.assign(Object.assign({},this.options.events),{onAuthorizeFailed:e=>{this.onAuthorizationFailed(e)}})},this.execution,this.paymentExecutor).handle3ds(t);break;default:o=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_ERROR),a.PayrailsLogger.error(o.message,{error:o,extra:{result:t}}),this.onAuthorizationFailed({code:e.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:o.message})}}}e.AuthorizationFailureReasons=void 0,(b=e.AuthorizationFailureReasons||(e.AuthorizationFailureReasons={})).VALIDATION_FAILED="VALIDATION_FAILED",b.AUTHORIZATION_ERROR="AUTHORIZATION_ERROR",b.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",b.UNKNOWN_ERROR="UNKNOWN_ERROR";var k={};!function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==s?s:"undefined"!=typeof self?self:{};function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n,o,r,a={},l={},d={},c={},u={};Object.defineProperty(u,"__esModule",{value:!0}),u.subscribers=u.childWindows=u.prefix=void 0,u.prefix="/*framebus*/",u.childWindows=[],u.subscribers={};var E,_={},h={};Object.defineProperty(h,"__esModule",{value:!0}),h.hasOpener=void 0,h.hasOpener=function(e){return e.top===e&&null!=e.opener&&e.opener!==e&&!0!==e.opener.closed};var I={};Object.defineProperty(I,"__esModule",{value:!0}),I.isntString=void 0,I.isntString=function(e){return"string"!=typeof e};var p,f,v={},m={},N={};Object.defineProperty(N,"__esModule",{value:!0}),N.sendMessage=void 0,N.sendMessage=function(e,t,i){try{e.postMessage(t,i)}catch(e){}};var T,y={},O={};function A(){if(T)return O;T=1,Object.defineProperty(O,"__esModule",{value:!0}),O.Framebus=void 0;var e=M(),t="undefined"!=typeof window&&window.Promise,i=function(){function i(e){void 0===e&&(e={}),this.origin=e.origin||"*",this.channel=e.channel||"",this.verifyDomain=e.verifyDomain,this.targetFrames=e.targetFrames||[],this.limitBroadcastToFramesArray=Boolean(e.targetFrames),this.isDestroyed=!1,this.listeners=[],this.hasAdditionalChecksForOnListeners=Boolean(this.verifyDomain||this.limitBroadcastToFramesArray)}return i.setPromise=function(e){i.Promise=e},i.target=function(e){return new i(e)},i.prototype.addTargetFrame=function(e){this.limitBroadcastToFramesArray&&this.targetFrames.push(e)},i.prototype.include=function(t){return null!=t&&null!=t.Window&&t.constructor===t.Window&&(e.childWindows.push(t),!0)},i.prototype.target=function(e){return i.target(e)},i.prototype.emit=function(t,i,n){if(this.isDestroyed)return!1;var s=this.origin;if(t=this.namespaceEvent(t),(0,e.isntString)(t))return!1;if((0,e.isntString)(s))return!1;"function"==typeof i&&(n=i,i=void 0);var o=(0,e.packagePayload)(t,s,i,n);return!!o&&(this.limitBroadcastToFramesArray?this.targetFramesAsWindows().forEach((function(t){(0,e.sendMessage)(t,o,s)})):(0,e.broadcast)(o,{origin:s,frame:window.top||window.self}),!0)},i.prototype.emitAsPromise=function(e,t){var n=this;return new i.Promise((function(i,s){n.emit(e,t,(function(e){i(e)}))||s(new Error('Listener not added for "'.concat(e,'"')))}))},i.prototype.on=function(t,i){if(this.isDestroyed)return!1;var n=this,s=this.origin,o=i;return t=this.namespaceEvent(t),!(0,e.subscriptionArgsInvalid)(t,o,s)&&(this.hasAdditionalChecksForOnListeners&&(o=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];n.passesVerifyDomainCheck(this&&this.origin)&&n.hasMatchingTargetFrame(this&&this.source)&&i.apply(void 0,e)}),this.listeners.push({eventName:t,handler:o,originalHandler:i}),e.subscribers[s]=e.subscribers[s]||{},e.subscribers[s][t]=e.subscribers[s][t]||[],e.subscribers[s][t].push(o),!0)},i.prototype.off=function(t,i){var n=i;if(this.isDestroyed)return!1;if(this.verifyDomain)for(var s=0;s<this.listeners.length;s++){var o=this.listeners[s];o.originalHandler===i&&(n=o.handler)}t=this.namespaceEvent(t);var r=this.origin;if((0,e.subscriptionArgsInvalid)(t,n,r))return!1;var a=e.subscribers[r]&&e.subscribers[r][t];if(!a)return!1;for(s=0;s<a.length;s++)if(a[s]===n)return a.splice(s,1),!0;return!1},i.prototype.teardown=function(){if(!this.isDestroyed){this.isDestroyed=!0;for(var e=0;e<this.listeners.length;e++){var t=this.listeners[e];this.off(t.eventName,t.handler)}this.listeners.length=0}},i.prototype.passesVerifyDomainCheck=function(e){return!this.verifyDomain||this.checkOrigin(e)},i.prototype.targetFramesAsWindows=function(){return this.limitBroadcastToFramesArray?this.targetFrames.map((function(e){return e instanceof HTMLIFrameElement?e.contentWindow:e})).filter((function(e){return e})):[]},i.prototype.hasMatchingTargetFrame=function(e){if(!this.limitBroadcastToFramesArray)return!0;var t=this.targetFramesAsWindows().find((function(t){return t===e}));return Boolean(t)},i.prototype.checkOrigin=function(e){var t,i=document.createElement("a");return i.href=location.href,t="https:"===i.protocol?i.host.replace(/:443$/,""):"http:"===i.protocol?i.host.replace(/:80$/,""):i.host,i.protocol+"//"+t===e||!this.verifyDomain||this.verifyDomain(e)},i.prototype.namespaceEvent=function(e){return this.channel?"".concat(this.channel,":").concat(e):e},i.Promise=t,i}();return O.Framebus=i,O}var L,g,R=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},S={},C={};Object.defineProperty(C,"__esModule",{value:!0});var D,b,P={};function M(){return b||(b=1,e=a,i=t&&t.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,s)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),s=t&&t.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)},Object.defineProperty(e,"__esModule",{value:!0}),s(function(){if(n)return l;n=1,Object.defineProperty(l,"__esModule",{value:!0}),l.detach=l.attach=void 0;var e=M(),t=!1;return l.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},l.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},l}(),e),s(function(){if(o)return d;o=1,Object.defineProperty(d,"__esModule",{value:!0}),d.broadcastToChildWindows=void 0;var e=M();return d.broadcastToChildWindows=function(t,i,n){for(var s=e.childWindows.length-1;s>=0;s--){var o=e.childWindows[s];o.closed?e.childWindows.splice(s,1):n!==o&&(0,e.broadcast)(t,{origin:i,frame:o.top})}},d}(),e),s(function(){if(r)return c;r=1,Object.defineProperty(c,"__esModule",{value:!0}),c.broadcast=void 0;var e=M();return c.broadcast=function t(i,n){var s,o=0,r=n.origin,a=n.frame;try{for(a.postMessage(i,r),(0,e.hasOpener)(a)&&a.opener.top!==window.top&&t(i,{origin:r,frame:a.opener.top});s=a.frames[o];)t(i,{origin:r,frame:s}),o++}catch(e){}},c}(),e),s(u,e),s(function(){if(E)return _;E=1,Object.defineProperty(_,"__esModule",{value:!0}),_.dispatch=void 0;var e=M();return _.dispatch=function(t,i,n,s,o){if(e.subscribers[t]&&e.subscribers[t][i]){var r=[];n&&r.push(n),s&&r.push(s);for(var a=0;a<e.subscribers[t][i].length;a++)e.subscribers[t][i][a].apply(o,r)}},_}(),e),s(h,e),s(I,e),s(function(){if(p)return v;p=1,Object.defineProperty(v,"__esModule",{value:!0}),v.onMessage=void 0;var e=M();return v.onMessage=function(t){if(!(0,e.isntString)(t.data)){var i=(0,e.unpackPayload)(t);if(i){var n=i.eventData,s=i.reply;(0,e.dispatch)("*",i.event,n,s,t),(0,e.dispatch)(t.origin,i.event,n,s,t),(0,e.broadcastToChildWindows)(t.data,i.origin,t.source)}}},v}(),e),s(function(){if(f)return m;f=1,Object.defineProperty(m,"__esModule",{value:!0}),m.packagePayload=void 0;var e=M();return m.packagePayload=function(t,i,n,s){var o,r={event:t,origin:i};"function"==typeof s&&(r.reply=(0,e.subscribeReplier)(s,i)),r.eventData=n;try{o=e.prefix+JSON.stringify(r)}catch(e){throw new Error("Could not stringify event: ".concat(e.message))}return o},m}(),e),s(N,e),s(function(){if(L)return y;L=1;var e=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(y,"__esModule",{value:!0}),y.subscribeReplier=void 0;var i=A(),n=e(R);return y.subscribeReplier=function(e,t){var s=(0,n.default)();return i.Framebus.target({origin:t}).on(s,(function n(o,r){e(o,r),i.Framebus.target({origin:t}).off(s,n)})),s},y}(),e),s(function(){if(g)return S;g=1,Object.defineProperty(S,"__esModule",{value:!0}),S.subscriptionArgsInvalid=void 0;var e=M();return S.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},S}(),e),s(C,e),s(function(){if(D)return P;D=1,Object.defineProperty(P,"__esModule",{value:!0}),P.unpackPayload=void 0;var e=M();return P.unpackPayload=function(t){var i;if(t.data.slice(0,e.prefix.length)!==e.prefix)return!1;try{i=JSON.parse(t.data.slice(e.prefix.length))}catch(e){return!1}if(i.reply){var n=t.origin,s=t.source,o=i.reply;i.reply=function(t){if(s){var i=(0,e.packagePayload)(o,n,t);i&&s.postMessage(i,n)}}}return i},P}(),e)),a;var e,i,s}var w=M(),U=A();(0,w.attach)();const k=i(U.Framebus);class x{constructor(e){this.origin=null,this.listeners=[],this.bus=new k(e)}static getInstance(){return x.instance||(x.instance=new x),x.instance}on(e,t){return this.bus.on(e,t)}off(e,t){return this.bus.off(e,t)}emit(e,t,i=void 0){return this.bus.emit(e,t,i)}target(e){return this.bus.target(e)}}e.IframeEventBus=x,e.getEventBus=()=>x.getInstance()}(k);const x={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."},Y={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."},F={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."},V="collect_controller",B="element",G={CHANGE:"CHANGE",READY:"READY",FOCUS:"FOCUS",BLUR:"BLUR",ESCAPE:"ESCAPE",CLICK:"CLICK",ERROR:"ERROR",SUCCESS:"SUCCESS",SUBMIT:"SUBMIT",CREATED:"CREATED",MOUNTED:"MOUNTED",HEIGHT:"HEIGHT"},j="FRAME_READY",X="TOKENIZATION_REQUEST",W="INPUT_EVENT",z="DESTROY FRAME",H="SET_VALUE",K="GET_BEARER_TOKEN",$="COLLECT_ELEMENT_SET_ERROR",q="COMPOSABLE_UPDATE_OPTIONS",J="COMPOSABLE_CONTAINER_MOUNTED",Z="COLLECT_CONTAINER_MOUNTED";var Q,ee;!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"}(Q||(Q={})),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"}(ee||(ee={}));const te={[ee.AMEX]:["XXXX XXXXXX XXXXX",{X:"[0-9]"}],[ee.VISA]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[ee.MASTERCARD]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[ee.DISCOVER]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[ee.DINERS_CLUB]:["XXXX XXXXXX XXXXXX",{X:"[0-9]"}],[ee.JCB]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[ee.MAESTRO]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[ee.UNIONPAY]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[ee.HIPERCARD]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[ee.DEFAULT]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[ee.UNKNOWN]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}]},ie={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},[Q.CARDHOLDER_NAME]:{name:"cardHolderName",attributes:{type:"text",autocomplete:"cc-name"},sensitive:!0,regex:/^([a-zA-Z\\ \\,\\.\\-\\']{2,})$/},[Q.CARD_NUMBER]:{name:"CARD_NUMBER",attributes:{type:"text",autocomplete:"cc-number",inputmode:"numeric"},sensitive:!0,mask:te[ee.DEFAULT],regex:/$|^[\s]*?([0-9]{2,6}[ -]?){3,5}[\s]*/},[Q.EXPIRATION_DATE]:{name:"EXPIRATION_DATE",attributes:{type:"text",autocomplete:"cc-exp",inputmode:"numeric"},sensitive:!0},[Q.EXPIRATION_MONTH]:{name:"EXPIRATION_MONTH",attributes:{maxLength:2,type:"text",inputmode:"numeric",autocomplete:"cc-exp-month"},sensitive:!0,mask:["XX",{X:"[0-9]"}]},[Q.EXPIRATION_YEAR]:{name:"EXPIRATION_YEAR",attributes:{type:"text",inputmode:"numeric",autocomplete:"cc-exp-year"},sensitive:!0},[Q.CVV]:{name:"CVV",attributes:{type:"text",inputmode:"numeric",maxLength:4},sensitive:!0,regex:/^$|^[0-9]{3,4}$/},[Q.INPUT_FIELD]:{name:"INPUT_FIELD",sensitive:!0,attributes:{type:"text"}},[Q.PIN]:{name:"PIN",attributes:{type:"text",inputmode:"numeric",maxLength:12,minLength:4},sensitive:!0,regex:/^$|^[0-9]{4,12}$/}},ne="XXXX-XXXX-XXXX-XXXX",se={height:"100%",width:"100%",margin:0,padding:0,border:0,position:"absolute",top:0,left:0,"user-select":"none"},oe={position:"absolute",top:0,width:0,height:0,visibility:"hidden",left:"-99999999px","user-select":"none"},re={width:"100%",height:"100%",border:"0",padding:"0",margin:"0",outline:"none"},ae={WEBPACKAUTOFILL:"-webkit-autofill",BASE:"base",FOCUS:"focus",COMPLETE:"complete",EMPTY:"empty",INVALID:"invalid",GLOBAL:"global",REQUIRED_ASTERISK:"requiredAsterisk"};ae.BASE,ae.REQUIRED_ASTERISK;const le={[ee.VISA]:{regex:/^4\d*/,maxCardLength:19,cardLengthRange:[13,16]},[ee.MASTERCARD]:{regex:/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720)\d*/,maxCardLength:16,cardLengthRange:[16]},[ee.AMEX]:{regex:/^3[47]\d*/,maxCardLength:15,cardLengthRange:[15]},[ee.DINERS_CLUB]:{regex:/^(36|38|30[0-5])\d*/,maxCardLength:16,cardLengthRange:[14,15,16,17,18,19]},[ee.DISCOVER]:{regex:/^(6011|65|64[4-9]|622)\d*/,maxCardLength:16,cardLengthRange:[16,17,18,19]},[ee.JCB]:{regex:/^35\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[ee.HIPERCARD]:{regex:/^606282\d*/,maxCardLength:19,cardLengthRange:[14,15,16,17,18,19]},[ee.UNIONPAY]:{regex:/^62\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[ee.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]}};ee.DEFAULT,ee.AMEX,ee.DINERS_CLUB,ee.DISCOVER,ee.HIPERCARD,ee.JCB,ee.MAESTRO,ee.MASTERCARD,ee.UNIONPAY,ee.VISA;const de="MM/YY",ce=[de,"YYYY/MM","YY/MM","MM/YYYY"],ue=["YY","YYYY"];var Ee;!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"}(Ee||(Ee={})),Q.CARD_NUMBER,Q.EXPIRATION_DATE,Q.EXPIRATION_MONTH,Q.EXPIRATION_YEAR,Q.CVV,Q.EXPIRATION_DATE,Q.CARD_NUMBER,Q.CARDHOLDER_NAME,Q.INPUT_FIELD,Y.INVALID_COLLECT_VALUE,Q.PIN,Q.EXPIRATION_MONTH,Q.EXPIRATION_YEAR,Q.CVV,Q.EXPIRATION_DATE,Q.CARD_NUMBER,Q.CARDHOLDER_NAME,Q.INPUT_FIELD,Y.DEFAULT_REQUIRED_COLLECT_VALUE,Q.PIN,Q.EXPIRATION_MONTH,Q.EXPIRATION_YEAR;const _e=[Q.CARDHOLDER_NAME,Q.EXPIRATION_MONTH,Q.PIN,Q.CVV],he={X:"[0-9]"};class Ie{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(Ie.prototype,{constructor:e})}}
|
|
2
2
|
/* @copyright
|
|
3
3
|
Copyright (c) 2022 Skyflow, Inc.
|
|
4
|
-
*/const Oe={IFRAME_SECURE_SITE:"https://js.skyflow.com/v1/elements/index.html",IFRAME_SECURE_ORGIN:"https://js.skyflow.com"},ye="https://assets.payrails.io/d3ad1fa/card/index.html",Ae="https://assets.payrails.io",Le={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no",style:"width: 100%;",allow:"clipboard-read; clipboard-write"},Re=(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 ge=(e={})=>{const t=document.createElement("iframe"),i=Object.assign(Object.assign({},Le),e);return Object.assign(t.style,de),Re(t,i),t.getAttribute("id")||(t.id=t.name),t};const Se=()=>Oe.IFRAME_SECURE_SITE,De=(e,t)=>{Object.keys(t).forEach((i=>{Object.prototype.hasOwnProperty.call(t,i)&&(e.style[i]=t[i])}))};function Ce(e){return JSON.parse(JSON.stringify(e))}var Pe,be,Me,we,Ue,ke,Ye;!function(e){e.DEFAULT="DEFAULT",e.PLAIN_TEXT="PLAIN_TEXT",e.MASKED="MASKED",e.REDACTED="REDACTED"}(Pe||(Pe={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.PATCH="PATCH",e.DELETE="DELETE"}(be||(be={})),function(e){e.CHANGE="CHANGE",e.READY="READY",e.FOCUS="FOCUS",e.BLUR="BLUR",e.SUBMIT="SUBMIT"}(Me||(Me={})),function(e){e.WARN="WARN",e.INFO="INFO",e.DEBUG="DEBUG",e.ERROR="ERROR"}(we||(we={})),function(e){e.DEV="DEV",e.PROD="PROD"}(Ue||(Ue={})),function(e){e.LOG="LOG",e.WARN="WARN",e.ERROR="ERROR"}(ke||(ke={})),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"}(Ye||(Ye={}));const xe={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}},Ve={PROD:{doesReturnValue:!1},DEV:{doesReturnValue:!0}},Fe="[Skyflow]",Ge=(e,t,i)=>{if(i&&xe[i]){const{showDebugLogs:n,showInfoLogs:o,showWarnLogs:s,showErrorLogs:r}=xe[i];t===ke.LOG&&n?console.log(`${we.DEBUG}: ${Fe} ${e}`):t===ke.LOG&&o?console.log(`${we.INFO}: ${Fe} ${e}`):t===ke.WARN&&s?console.warn(`${we.WARN}: ${Fe} ${e}`):t===ke.ERROR&&r&&console.error(`${we.ERROR}: ${Fe} ${e}`)}},Be=(...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]})):""},je=(e="")=>{const t=e.split(":");if("group"===t[1])return"composable container";let i=atob(t[2]);return-1!==i.indexOf(":")&&(i=i.substring(0,i.indexOf(":"))),i};class Xe extends Error{constructor(e,t,i=!1){const n={code:e.code,description:t&&(null==t?void 0:t.length)>0?Be(e.description,...t):e.description};super(n.description),i?this.error=n:this.errors=[n]}}const We={INVALID_FIELD:{code:400,description:x.INVALID_FIELD},VAULTID_IS_REQUIRED:{code:400,description:x.VAULTID_IS_REQUIRED},EMPTY_VAULTID_IN_INIT:{code:400,description:x.EMPTY_VAULTID_IN_INIT},VAULTURL_IS_REQUIRED:{code:400,description:x.VAULTURL_IS_REQUIRED},EMPTY_VAULTURL_IN_INIT:{code:400,description:x.EMPTY_VAULTURL_IN_INIT},INVALID_VAULTURL_IN_INIT:{code:400,description:x.INVALID_VAULTURL_IN_INIT},GET_BEARER_TOKEN_IS_REQUIRED:{code:400,description:x.GET_BEARER_TOKEN_IS_REQUIRED},EMPTY_CONTAINER_TYPE:{code:400,description:x.EMPTY_CONTAINER_TYPE},INVALID_CONTAINER_TYPE:{code:400,description:x.INVALID_CONTAINER_TYPE},UNIQUE_ELEMENT_NAME:{code:400,description:x.UNIQUE_ELEMENT_NAME},ELEMENTS_NOT_MOUNTED:{code:400,description:x.ELEMENTS_NOT_MOUNTED},MISSING_TABLE_IN_COLLECT:{code:400,description:x.MISSING_TABLE_IN_COLLECT},EMPTY_TABLE_IN_COLLECT:{code:400,description:x.EMPTY_TABLE_IN_COLLECT},EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:{code:400,description:x.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS},INVALID_TABLE_IN_COLLECT:{code:400,description:x.INVALID_TABLE_IN_COLLECT},INVALID_SKYFLOWID_IN_COLLECT:{code:400,description:x.INVALID_SKYFLOWID_IN_COLLECT},MISSING_COLUMN_IN_COLLECT:{code:400,description:x.MISSING_COLUMN_IN_COLLECT},EMPTY_COLUMN_IN_COLLECT:{code:400,description:x.EMPTY_TABLE_IN_COLLECT},INVALID_COLUMN_IN_COLLECT:{code:400,description:x.INVALID_COLUMN_IN_COLLECT},CLIENT_CONNECTION:{code:400,description:x.CLIENT_CONNECTION},RECORDS_KEY_NOT_FOUND:{code:404,description:x.RECORDS_KEY_NOT_FOUND},EMPTY_RECORDS_IN_INSERT:{code:400,description:x.EMPTY_RECORDS_IN_INSERT},INVALID_RECORDS_IN_INSERT:{code:404,description:x.INVALID_RECORDS_IN_INSERT},INVALID_TABLE_IN_INSERT:{code:400,description:x.INVALID_TABLE_IN_INSERT},EMPTY_TABLE_IN_INSERT:{code:400,description:x.EMPTY_TABLE_IN_INSERT},MISSING_TABLE_IN_INSERT:{code:400,description:x.MISSING_TABLE_IN_INSERT},EMPTY_FIELDS_IN_INSERT:{code:400,description:x.EMPTY_FIELDS_IN_INSERT},MISSING_FIELDS_IN_INSERT:{code:404,description:x.MISSING_FIELDS_IN_INSERT},INVALID_FIELDS_IN_INSERT:{code:404,description:x.INVALID_FIELDS_IN_INSERT},INVALID_TOKENS_IN_INSERT:{code:404,description:x.INVALID_TOKENS_IN_INSERT},RECORDS_KEY_NOT_FOUND_DETOKENIZE:{code:404,description:x.RECORDS_KEY_NOT_FOUND_DETOKENIZE},EMPTY_RECORDS_DETOKENIZE:{code:400,description:x.EMPTY_RECORDS_DETOKENIZE},INVALID_RECORDS_IN_DETOKENIZE:{code:404,description:x.INVALID_RECORDS_IN_DETOKENIZE},MISSING_TOKEN_IN_DETOKENIZE:{code:400,description:x.MISSING_TOKEN_IN_DETOKENIZE},INVALID_TOKEN_IN_DETOKENIZE:{code:400,description:x.INVALID_TOKEN_IN_DETOKENIZE},RECORDS_KEY_NOT_FOUND_GET:{code:400,description:x.RECORDS_KEY_NOT_FOUND_GET},INVALID_RECORDS_IN_GET:{code:400,description:x.INVALID_RECORDS_IN_GET},EMPTY_RECORDS_GET:{code:400,description:x.EMPTY_RECORDS_GET},MISSING_IDS_IN_GET:{code:400,description:x.MISSING_IDS_IN_GET},INVALID_IDS_IN_GET:{code:400,description:x.INVALID_IDS_IN_GET},INVALID_COLUMN_VALUES_IN_GET:{code:400,description:x.INVALID_COLUMN_VALUES_IN_GET},EMPTY_IDS_IN_GET:{code:400,description:x.EMPTY_IDS_IN_GET},INVALID_SKYFLOWID_TYPE_IN_GET:{code:400,description:x.INVALID_SKYFLOWID_TYPE_IN_GET},MISSING_TABLE_IN_GET:{code:400,description:x.MISSING_TABLE_IN_GET},INVALID_TABLE_IN_GET:{code:400,description:x.INVALID_TABLE_IN_GET},MISSING_REDACTION_IN_GET:{code:400,description:x.MISSING_REDACTION_IN_GET},INVALID_REDACTION_TYPE_IN_GET:{code:400,description:x.INVALID_REDACTION_TYPE_IN_GET},INVALID_TOKENS_IN_GET:{code:400,description:x.INVALID_TOKENS_IN_GET},TOKENS_GET_COLUMN_NOT_SUPPORTED:{code:400,description:x.TOKENS_GET_COLUMN_NOT_SUPPORTED},REDACTION_WITH_TOKENS_NOT_SUPPORTED:{code:400,description:x.REDACTION_WITH_TOKENS_NOT_SUPPORTED},INVALID_REDACTION_TYPE_IN_DETOKENIZE:{code:400,description:x.INVALID_REDACTION_TYPE_IN_DETOKENIZE},INVALID_TOKENS_IN_COLLECT:{code:404,description:x.INVALID_TOKENS_IN_COLLECT},RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS:{code:404,description:x.RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS},INVALID_RECORDS_IN_ADDITIONAL_FIELDS:{code:404,description:x.INVALID_RECORDS_IN_ADDITIONAL_FIELDS},EMPTY_RECORDS_IN_ADDITIONAL_FIELDS:{code:400,description:x.EMPTY_RECORDS_IN_ADDITIONAL_FIELDS},MISSING_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:x.MISSING_TABLE_IN_ADDITIONAL_FIELDS},INVALID_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:x.INVALID_TABLE_IN_ADDITIONAL_FIELDS},INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:{code:400,description:x.INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS},MISSING_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:x.MISSING_FIELDS_IN_ADDITIONAL_FIELDS},INVALID_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:x.INVALID_FIELDS_IN_ADDITIONAL_FIELDS},RECORDS_KEY_NOT_FOUND_DELETE:{code:400,description:x.RECORDS_KEY_NOT_FOUND_DELETE},EMPTY_RECORDS_IN_DELETE:{code:400,description:x.EMPTY_RECORDS_IN_DELETE},INVALID_RECORDS_IN_DELETE:{code:404,description:x.INVALID_RECORDS_IN_DELETE},INVALID_TABLE_IN_DELETE:{code:400,description:x.INVALID_TABLE_IN_DELETE},EMPTY_TABLE_IN_DELETE:{code:400,description:x.EMPTY_TABLE_IN_DELETE},MISSING_TABLE_IN_DELETE:{code:400,description:x.MISSING_TABLE_IN_DELETE},EMPTY_ID_IN_DELETE:{code:400,description:x.EMPTY_ID_IN_DELETE},MISSING_ID_IN_DELETE:{code:404,description:x.MISSING_ID_IN_DELETE},INVALID_ID_IN_DELETE:{code:404,description:x.INVALID_ID_IN_DELETE},EMPTY_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:x.EMPTY_TABLE_IN_ADDITIONAL_FIELDS},EMPTY_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:x.EMPTY_FIELDS_IN_ADDITIONAL_FIELDS},EMPTY_TOKEN_IN_DETOKENIZE:{code:400,description:x.EMPTY_TOKEN_IN_DETOKENIZE},EMPTY_SKYFLOWID_IN_GET:{code:400,description:x.EMPTY_SKYFLOWID_IN_GET},EMPTY_TABLE_IN_GET:{code:400,description:x.EMPTY_TABLE_IN_GET},EMPTY_REDACTION_TYPE_IN_GET:{code:400,description:x.EMPTY_REDACTION_TYPE_IN_GET},DUPLICATE_ELEMENT:{code:400,description:x.DUPLICATE_ELEMENT},DUPLICATE_ELEMENT_ADDITIONAL_FIELDS:{code:400,description:x.DUPLICATE_ELEMENT_ADDITIONAL_FIELDS},MISSING_ELEMENT_TYPE:{code:400,description:x.MISSING_ELEMENT_TYPE},EMPTY_ELEMENT_TYPE:{code:400,description:x.EMPTY_ELEMENT_TYPE},INVALID_ELEMENT_TYPE:{code:400,description:x.INVALID_ELEMENT_TYPE},INVALID_ELEMENT_SELECTOR:{code:400,description:x.INVALID_ELEMENT_SELECTOR},FRAME_NOT_FOUND:{code:400,description:x.FRAME_NOT_FOUND},REQUIRED_PARAMS_NOT_PROVIDED:{code:400,description:x.REQUIRED_PARAMS_NOT_PROVIDED},INVALID_RECORD_COLUMN_VALUE:{code:400,description:x.INVALID_RECORD_COLUMN_VALUE},MISSING_RECORD_COLUMN_VALUE:{code:400,description:x.MISSING_RECORD_COLUMN_VALUE},MISSING_RECORD_COLUMN_NAME:{code:400,description:x.MISSING_RECORD_COLUMN_NAME},INVALID_EVENT_TYPE:{code:400,description:x.INVALID_EVENT_TYPE},INVALID_EVENT_LISTENER:{code:400,description:x.INVALID_EVENT_LISTENER},MISSING_HANDLER_IN_EVENT_LISTENER:{code:400,description:x.MISSING_HANDLER_IN_EVENT_LISTENER},INVALID_HANDLER_IN_EVENT_LISTENER:{code:400,description:x.INVALID_HANDLER_IN_EVENT_LISTENER},UNKNOWN_ERROR:{code:400,description:x.UNKNOWN_ERROR},CONNECTION_ERROR:{code:400,description:x.CONNECTION_ERROR},NETWORK_ERROR:{code:500,description:x.NETWORK_ERROR},COMPLETE_AND_VALID_INPUTS:{code:400,description:x.COMPLETE_AND_VALID_INPUTS},INVALID_VALIDATIONS_TYPE:{code:400,description:x.INVALID_VALIDATIONS_TYPE},MISSING_VALIDATION_RULE_TYPE:{code:400,description:x.MISSING_VALIDATION_RULE_TYPE},INVALID_VALIDATION_RULE_TYPE:{code:400,description:x.INVALID_VALIDATION_RULE_TYPE},MISSING_VALIDATION_RULE_PARAMS:{code:400,description:x.MISSING_VALIDATION_RULE_PARAMS},INVALID_VALIDATION_RULE_PARAMS:{code:400,description:x.INVALID_VALIDATION_RULE_PARAMS},MISSING_REGEX_IN_REGEX_MATCH_RULE:{code:400,description:x.MISSING_REGEX_IN_REGEX_MATCH_RULE},INVALID_REGEX_IN_REGEX_MATCH_RULE:{code:400,description:x.INVALID_REGEX_IN_REGEX_MATCH_RULE},MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE:{code:400,description:x.MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE},MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE:{code:400,description:x.MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE},INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE:{code:400,description:x.INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE},ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE:{code:400,description:x.ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE},EMPTY_ELEMENT_IN_MOUNT:{code:400,description:x.EMPTY_ELEMENT_IN_MOUNT},INVALID_TABLE_IN_UPSERT_OPTION:{code:400,description:x.INVALID_TABLE_IN_UPSERT_OPTION},INVALID_COLUMN_IN_UPSERT_OPTION:{code:400,description:x.INVALID_COLUMN_IN_UPSERT_OPTION},INVALID_UPSERT_OPTION_TYPE:{code:400,description:x.INVALID_UPSERT_OPTION_TYPE},EMPTY_UPSERT_OPTIONS_ARRAY:{code:400,description:x.EMPTY_UPSERT_OPTIONS_ARRAY},INVALID_UPSERT_OPTION_OBJECT_TYPE:{code:400,description:x.INVALID_UPSERT_OPTION_OBJECT_TYPE},MISSING_TABLE_IN_UPSERT_OPTION:{code:400,description:x.MISSING_TABLE_IN_UPSERT_OPTION},MISSING_COLUMN_IN_UPSERT_OPTION:{code:400,description:x.MISSING_COLUMN_IN_UPSERT_OPTION},INVALID_RECORD_COLUMN_VALUE_TYPE:{code:400,description:x.INVALID_RECORD_COLUMN_VALUE_TYPE},INVALID_COLUMN_VALUES_TYPE:{code:400,description:x.INVALID_COLUMN_VALUES_TYPE},EMPTY_RECORD_COLUMN_VALUES:{code:400,description:x.EMPTY_RECORD_COLUMN_VALUES},EMPTY_COLUMN_VALUE:{code:400,description:x.EMPTY_COLUMN_VALUE},MISSING_IDS_OR_COLUMN_VALUES_IN_GET:{code:400,description:x.MISSING_IDS_OR_COLUMN_VALUES_IN_GET},SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED:{code:400,description:x.SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED},RECORDS_KEY_NOT_FOUND_GETBYID:{code:400,description:x.RECORDS_KEY_NOT_FOUND_GETBYID},INVALID_RECORDS_IN_GETBYID:{code:400,description:x.INVALID_RECORDS_IN_GETBYID},EMPTY_RECORDS_GETBYID:{code:400,description:x.EMPTY_RECORDS_GETBYID},MISSING_IDS_IN_GETBYID:{code:400,description:x.MISSING_IDS_IN_GETBYID},INVALID_IDS_IN_GETBYID:{code:400,description:x.INVALID_IDS_IN_GETBYID},EMPTY_IDS_IN_GETBYID:{code:400,description:x.EMPTY_IDS_IN_GETBYID},INVALID_SKYFLOWID_TYPE_IN_GETBYID:{code:400,description:x.INVALID_SKYFLOWID_TYPE_IN_GETBYID},MISSING_TABLE_IN_GETBYID:{code:400,description:x.MISSING_TABLE_IN_GETBYID},INVALID_TABLE_IN_GETBYID:{code:400,description:x.INVALID_TABLE_IN_GETBYID},MISSING_REDACTION_IN_GETBYID:{code:400,description:x.MISSING_REDACTION_IN_GETBYID},INVALID_REDACTION_TYPE_IN_GETBYID:{code:400,description:x.INVALID_REDACTION_TYPE_IN_GETBYID},EMPTY_SKYFLOWID_IN_GETBYID:{code:400,description:x.EMPTY_SKYFLOWID_IN_GETBYID},EMPTY_TABLE_IN_GETBYID:{code:400,description:x.EMPTY_TABLE_IN_GETBYID},EMPTY_REDACTION_TYPE_IN_GETBYID:{code:400,description:x.EMPTY_REDACTION_TYPE_IN_GETBYID},MISSING_COMPOSABLE_LAYOUT_KEY:{code:400,description:x.MISSING_COMPOSABLE_LAYOUT_KEY},EMPTY_COMPOSABLE_LAYOUT_ARRAY:{code:400,description:x.EMPTY_COMPOSABLE_LAYOUT_ARRAY},INVALID_COMPOSABLE_LAYOUT_TYPE:{code:400,description:x.INVALID_COMPOSABLE_LAYOUT_TYPE},NEGATIVE_VALUES_COMPOSABLE_LAYOUT:{code:400,description:x.NEGATIVE_VALUES_COMPOSABLE_LAYOUT},MISMATCH_ELEMENT_COUNT_LAYOUT_SUM:{code:400,description:x.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM},MISSING_COMPOSABLE_CONTAINER_OPTIONS:{code:400,description:x.MISSING_COMPOSABLE_CONTAINER_OPTIONS},INVALID_COMPOSABLE_CONTAINER_OPTIONS:{code:400,description:x.INVALID_COMPOSABLE_CONTAINER_OPTIONS},COMPOSABLE_CONTAINER_NOT_MOUNTED:{code:400,description:x.COMPOSABLE_CONTAINER_NOT_MOUNTED},INVALID_BOOLEAN_OPTIONS:{code:400,description:x.INVALID_BOOLEAN_OPTIONS},EMPTY_COLLECT_CUSTOM_FORMAT:{code:400,description:x.EMPTY_COLLECT_CUSTOM_FORMAT},INVALID_INPUT_OPTIONS_FORMAT:{code:400,description:x.INVALID_INPUT_OPTIONS_FORMAT},INVALID_INPUT_OPTIONS_TRANSLATION:{code:400,description:x.INVALID_INPUT_OPTIONS_TRANSLATION}},$e=(e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new Xe(We.RECORDS_KEY_NOT_FOUND,[],!0);const{records:i}=e;if(!i||!Array.isArray(i))throw new Xe(We.INVALID_RECORDS_IN_INSERT,[],!0);if(0===i.length)throw new Xe(We.EMPTY_RECORDS_IN_INSERT,[],!0);if(i.forEach(((e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"table"))throw new Xe(We.MISSING_TABLE_IN_INSERT,[`${t}`],!0);if(!e.table)throw new Xe(We.EMPTY_TABLE_IN_INSERT,[`${t}`],!0);if(!("string"==typeof e.table||e.table instanceof String))throw new Xe(We.INVALID_TABLE_IN_INSERT,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"fields"))throw new Xe(We.MISSING_FIELDS_IN_INSERT,[`${t}`],!0);if(!e.fields)throw new Xe(We.EMPTY_FIELDS_IN_INSERT,[`${t}`],!0);if("object"!=typeof e.fields||Array.isArray(e.fields))throw new Xe(We.INVALID_FIELDS_IN_INSERT,[`${t}`],!0)})),t&&t.tokens&&"boolean"!=typeof t.tokens)throw new Xe(We.INVALID_TOKENS_IN_INSERT,[],!0)},ze=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new Xe(We.RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS,[],!0);const{records:t}=e;if(!t||!Array.isArray(t))throw new Xe(We.INVALID_RECORDS_IN_ADDITIONAL_FIELDS,[],!0);if(0===t.length)throw new Xe(We.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 Xe(We.MISSING_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!e.table)throw new Xe(We.EMPTY_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(void 0!==(null===(i=e.fields)||void 0===i?void 0:i.skyflowID)){if(!(null===(n=e.fields)||void 0===n?void 0:n.skyflowID))throw new Xe(We.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 Xe(We.INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[`${t}`],!0)}if(!("string"==typeof e.table||e.table instanceof String))throw new Xe(We.INVALID_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"fields"))throw new Xe(We.MISSING_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!e.fields)throw new Xe(We.EMPTY_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if("object"!=typeof e.fields||Array.isArray(e.fields))throw new Xe(We.INVALID_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0)}))},He=(e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new Xe(We.RECORDS_KEY_NOT_FOUND_GET);const{records:i}=e;if(!i||!Array.isArray(i))throw new Xe(We.INVALID_RECORDS_IN_GET,[]);if(0===i.length)throw new Xe(We.EMPTY_RECORDS_GET);if(t&&Object.prototype.hasOwnProperty.call(t,"tokens")&&"boolean"!=typeof(null==t?void 0:t.tokens))throw new Xe(We.INVALID_TOKENS_IN_GET);i.forEach(((e,i)=>{var n,o,s;if(0===Object.keys(e).length)throw new Xe(We.EMPTY_RECORDS_GET);if(0===(null===(n=e.ids)||void 0===n?void 0:n.length))throw new Xe(We.EMPTY_IDS_IN_GET,[`${i}`]);if(!(null==e.ids||e.ids&&Array.isArray(e.ids)))throw new Xe(We.INVALID_IDS_IN_GET,[`${i}`]);if(null===(o=e.ids)||void 0===o||o.forEach((e=>{if(!e)throw new Xe(We.EMPTY_SKYFLOWID_IN_GET,[`${i}`]);if(!("string"==typeof e||e instanceof String))throw new Xe(We.INVALID_SKYFLOWID_TYPE_IN_GET,[`${i}`])})),!Object.prototype.hasOwnProperty.call(e,"table"))throw new Xe(We.MISSING_TABLE_IN_GET,[`${i}`]);if(!e.table)throw new Xe(We.EMPTY_TABLE_IN_GET,[`${i}`]);if(!("string"==typeof e.table||e.table instanceof String))throw new Xe(We.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 Xe(We.MISSING_REDACTION_IN_GET,[`${i}`]);if(!e.redaction)throw new Xe(We.EMPTY_REDACTION_TYPE_IN_GET,[`${i}`]);if(!Object.values(Pe).includes(e.redaction))throw new Xe(We.INVALID_REDACTION_TYPE_IN_GET,[`${i}`])}if(!0===Object.prototype.hasOwnProperty.call(e,"ids")&&!0===Object.prototype.hasOwnProperty.call(e,"columnName"))throw new Xe(We.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 Xe(We.MISSING_RECORD_COLUMN_VALUE,[`${i}`])}else if(!1===Object.prototype.hasOwnProperty.call(e,"ids")&&!1===Object.prototype.hasOwnProperty.call(e,"columnValues"))throw new Xe(We.MISSING_IDS_OR_COLUMN_VALUES_IN_GET,[`${i}`]);if(0===(null===(s=e.columnValues)||void 0===s?void 0:s.length))throw new Xe(We.EMPTY_RECORD_COLUMN_VALUES,[`${i}`]);if(!(null==e.columnValues||e.columnValues&&Array.isArray(e.columnValues)))throw new Xe(We.INVALID_COLUMN_VALUES_IN_GET,[`${i}`]);if(void 0!==e.columnName&&void 0===e.columnValues)throw new Xe(We.MISSING_RECORD_COLUMN_VALUE,[`${i}`]);if(void 0===e.columnName&&void 0!==e.columnValues)throw new Xe(We.MISSING_RECORD_COLUMN_NAME,[`${i}`]);const r=e.columnName;if(null!=r&&"string"!=typeof r)throw new Xe(We.INVALID_RECORD_COLUMN_VALUE,[`${i}`]);const a=e.columnValues;if(null!=a){if(0===a.length||null===a)throw new Xe(We.EMPTY_RECORD_COLUMN_VALUES,[`${i}`]);a.forEach((e=>{if(""===e||null===e)throw new Xe(We.EMPTY_COLUMN_VALUE,[`${i}`]);if("string"!=typeof e)throw new Xe(We.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 Xe(We.TOKENS_GET_COLUMN_NOT_SUPPORTED);if(e.redaction)throw new Xe(We.REDACTION_WITH_TOKENS_NOT_SUPPORTED)}}))},Ke=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new Xe(We.RECORDS_KEY_NOT_FOUND_GETBYID);const{records:t}=e;if(!t||!Array.isArray(t))throw new Xe(We.INVALID_RECORDS_IN_GETBYID,[]);if(0===t.length)throw new Xe(We.EMPTY_RECORDS_GETBYID);t.forEach(((e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"ids"))throw new Xe(We.MISSING_IDS_IN_GETBYID,[`${t}`]);if(!e.ids||!Array.isArray(e.ids))throw new Xe(We.INVALID_IDS_IN_GETBYID,[`${t}`]);if(0===e.ids.length)throw new Xe(We.EMPTY_IDS_IN_GETBYID,[`${t}`]);if(e.ids.forEach((e=>{if(!e)throw new Xe(We.EMPTY_SKYFLOWID_IN_GETBYID,[`${t}`]);if(!("string"==typeof e||e instanceof String))throw new Xe(We.INVALID_SKYFLOWID_TYPE_IN_GETBYID,[`${t}`])})),!Object.prototype.hasOwnProperty.call(e,"table"))throw new Xe(We.MISSING_TABLE_IN_GETBYID,[`${t}`]);if(!e.table)throw new Xe(We.EMPTY_TABLE_IN_GETBYID,[`${t}`]);if(!("string"==typeof e.table||e.table instanceof String))throw new Xe(We.INVALID_TABLE_IN_GETBYID,[`${t}`]);if(!Object.prototype.hasOwnProperty.call(e,"redaction"))throw new Xe(We.MISSING_REDACTION_IN_GETBYID,[`${t}`]);if(!e.redaction)throw new Xe(We.EMPTY_REDACTION_TYPE_IN_GETBYID,[`${t}`]);if(!Object.values(Pe).includes(e.redaction))throw new Xe(We.INVALID_REDACTION_TYPE_IN_GETBYID,[`${t}`])}))},qe=(e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new Xe(We.RECORDS_KEY_NOT_FOUND_DELETE,[],!0);const{records:i}=e;if(!i||!Array.isArray(i))throw new Xe(We.INVALID_RECORDS_IN_DELETE,[],!0);if(0===i.length)throw new Xe(We.EMPTY_RECORDS_IN_DELETE,[],!0);i.forEach(((e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"table"))throw new Xe(We.MISSING_TABLE_IN_DELETE,[`${t}`],!0);if(!e.table)throw new Xe(We.EMPTY_TABLE_IN_DELETE,[`${t}`],!0);if(!("string"==typeof e.table||e.table instanceof String))throw new Xe(We.INVALID_TABLE_IN_DELETE,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"id"))throw new Xe(We.MISSING_ID_IN_DELETE,[`${t}`],!0);if(!e.id)throw new Xe(We.EMPTY_ID_IN_DELETE,[`${t}`],!0);if(!("string"==typeof e.id||e.id instanceof String))throw new Xe(We.INVALID_ID_IN_DELETE,[`${t}`],!0)}))},Je=e=>{let t=!0;try{new RegExp(e)}catch(e){t=!1}return t},Ze=e=>{if(!Object.prototype.hasOwnProperty.call(e,"getBearerToken"))throw new Xe(We.GET_BEARER_TOKEN_IS_REQUIRED,[],!0)},Qe=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new Xe(We.MISSING_ELEMENT_TYPE,[],!0);if(!e.type)throw new Xe(We.EMPTY_ELEMENT_TYPE,[],!0);if(Object.prototype.hasOwnProperty.call(e,"altText")&&Ge(V.COLLECT_ALT_TEXT_DEPERECATED,ke.WARN,t),Object.prototype.hasOwnProperty.call(e,"skyflowID")&&"string"!=typeof e.skyflowID)throw new Xe(We.INVALID_SKYFLOWID_IN_COLLECT,[],!0)},et=e=>{if(!e||!Array.isArray(e))throw new Xe(We.INVALID_UPSERT_OPTION_TYPE,[],!0);if(!e.length)throw new Xe(We.EMPTY_UPSERT_OPTIONS_ARRAY,[],!0);e.forEach(((e,t)=>{if(!e||"object"!=typeof e)throw new Xe(We.INVALID_UPSERT_OPTION_OBJECT_TYPE,[t],!0);if(!Object.prototype.hasOwnProperty.call(e,"table"))throw new Xe(We.MISSING_TABLE_IN_UPSERT_OPTION,[t],!0);if(!e.table||"string"!=typeof e.table||!e.table.length)throw new Xe(We.INVALID_TABLE_IN_UPSERT_OPTION,[t],!0);if(!Object.prototype.hasOwnProperty.call(e,"column"))throw new Xe(We.MISSING_COLUMN_IN_UPSERT_OPTION,[t],!0);if(!e.column||"string"!=typeof e.column||!e.column.length)throw new Xe(We.INVALID_COLUMN_IN_UPSERT_OPTION,[t],!0)}))},tt=e=>"boolean"==typeof e;function it(e){const t=e.split(":");return t.length>2?(t.pop(),t.pop(),t.join(":")):""}const nt=(e,t,i)=>{if("string"!=typeof e)return e;if(t===se.CARD_NUMBER){if(e=e&&e.replace(/\s/g,""),!i){const t=((e="")=>{const t=e.replace(/[\s-]/g,"");let i=re.DEFAULT;return Object.entries(he).forEach((([e,n])=>{n.regex.test(t)&&(i=e)})),i})(e),i=t!==re.DEFAULT&&t===re.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 ot(e){var t,i,n,o,s;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}`;Oe.IFRAME_SECURE_ORGIN=s,Oe.IFRAME_SECURE_SITE=null===(o=null==e?void 0:e.options)||void 0===o?void 0:o.customElementsURL}if(null===(s=e.options)||void 0===s?void 0:s.deserializedData.usePayrailsFrames){if(!Oe.IFRAME_SECURE_ORGIN||!Oe.IFRAME_SECURE_SITE){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CARD_FORM_IFRAME_NOT_FOUND);throw a.PayrailsLogger.error(e.message,{error:e,extra:{IFRAME_SECURE_ORGIN:Oe.IFRAME_SECURE_ORGIN,IFRAME_SECURE_SITE:Oe.IFRAME_SECURE_SITE}}),e}Oe.IFRAME_SECURE_ORGIN=Ae,Oe.IFRAME_SECURE_SITE=ye}}class st{constructor(e,t,i,n){this.setAttributess=e=>{Re(this.iframe,{src:e})},this.mount=e=>{var t;this.unmount();try{if("string"==typeof e){if(this.container=document.querySelector(e)||void 0,!this.container)throw new Xe(We.INVALID_ELEMENT_SELECTOR,[],!0)}else{if(!(e instanceof HTMLElement))throw new Xe(We.INVALID_ELEMENT_SELECTOR,[],!0);this.container=e}}catch(e){console.error(e)}Re(this.iframe,{src:Se()}),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=ge({name:this.name})}}class rt{}var at,lt,ct,dt,ut,Et,_t,ht,It,pt,ft,vt,mt,Nt,Tt,Ot,yt,At,Lt,Rt;const gt="Element";class St extends rt{constructor(e,t,o,s,r=!1,a,l,c,d){var u;super(),this.type=$i.COLLECT,at.set(this,void 0),lt.set(this,!1),ct.set(this,void 0),dt.set(this,void 0),ut.set(this,{isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:void 0,isRequired:!1}),Et.set(this,void 0),_t.set(this,new Te),ht.set(this,void 0),It.set(this,k.getEventBus()),pt.set(this,void 0),ft.set(this,[]),vt.set(this,!1),mt.set(this,void 0),Nt.set(this,void 0),Tt.set(this,!1),this.getID=()=>i(this,at,"f"),this.mount=e=>{var t;if(!e)throw new Xe(We.EMPTY_ELEMENT_IN_MOUNT,["CollectElement"],!0);const o=(e,t)=>{if(e.name===i(this,pt,"f").name){t(i(this,Et,"f")),i(this,Rt,"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}(i(this,ct,"f")[0],["name"]);i(this,dt,"f").length>1?i(this,dt,"f").forEach(((e,t)=>{i(this,ht,"f")&&i(this,ht,"f")._emit(`${$.READY}:${e.elementName}`,Object.assign(Object.assign({},i(this,ct,"f")[t]),{elementType:e.elementType}))})):i(this,_t,"f")._emit($.READY,Object.assign({},e)),i(this,It,"f").off(z+this.containerId,o),Ge(`${Be(Y.ELEMENT_MOUNTED,gt,je(i(this,pt,"f").name))} `,ke.LOG,i(this,mt,"f").logLevel),i(this,ft,"f").forEach((e=>e())),n(this,ft,[],"f")}};if(i(this,dt,"f").length>1)i(this,pt,"f").mount(e),i(this,It,"f").on(z+this.containerId,o);else{if(i(this,Tt,"f"))return i(this,pt,"f").mount(e),void i(this,It,"f").on(z+this.containerId,o);null===(t=i(this,ht,"f"))||void 0===t||t.on(oe,(t=>{(null==t?void 0:t.containerId)===this.containerId&&(i(this,pt,"f").mount(e),i(this,It,"f").on(z+this.containerId,o))}))}},this.unmount=()=>{i(this,pt,"f").unmount()},this.update=e=>{let t=Ce(e);const o=()=>{i(this,lt,"f")&&(t={rows:[{elements:[Object.assign({},t)]}]}),n(this,Et,Ct(i(this,Et,"f"),t),"f"),n(this,dt,Pt(i(this,Et,"f")),"f"),i(this,lt,"f")?i(this,It,"f").emit(J,{name:i(this,pt,"f").name,options:i(this,dt,"f")[0],isSingleElementAPI:!0}):(i(this,dt,"f").forEach((e=>{i(this,It,"f").emit(J,{name:e.elementName,options:e,isSingleElementAPI:!0})})),i(this,It,"f").emit(J,{name:i(this,pt,"f").name,options:i(this,Et,"f"),isSingleElementAPI:!1})),i(this,Rt,"f").call(this)};i(this,vt,"f")?o():i(this,ft,"f").push(o)},Ot.set(this,(e=>{i(this,lt,"f")||i(this,_t,"f").on(J,(()=>{e(i(this,dt,"f"))}),!0)})),this.updateElement=e=>{i(this,It,"f").emit(J,{name:e.elementName,options:e,isSingleElementAPI:!0})},yt.set(this,(()=>{i(this,ct,"f").forEach(((e,t)=>{if(0===t){i(this,ut,"f").isEmpty=e.isEmpty,i(this,ut,"f").isComplete=e.isComplete,i(this,ut,"f").isValid=e.isValid,i(this,ut,"f").isFocused=e.isFocused,i(this,ut,"f").isRequired=e.isRequired,i(this,ut,"f").value={};const n=i(this,dt,"f")[t].elementName,o=e.value&&nt(e.value,e.elementType,i(this,Nt,"f"));i(this,lt,"f")?i(this,ut,"f").value=o:i(this,ut,"f").value[n]=o}else i(this,ut,"f").isEmpty=i(this,ut,"f").isEmpty||e.isEmpty,i(this,ut,"f").isComplete=i(this,ut,"f").isComplete&&e.isComplete,i(this,ut,"f").isValid=i(this,ut,"f").isValid&&e.isValid,i(this,ut,"f").isFocused=i(this,ut,"f").isFocused||e.isFocused,i(this,ut,"f").isRequired=i(this,ut,"f").isRequired||e.isRequired,i(this,ut,"f").value||(i(this,ut,"f").value={}),i(this,dt,"f")[t].sensitive||(i(this,ut,"f").value[i(this,dt,"f")[t].elementName]=e.value||"")}))})),this.getState=()=>({isEmpty:i(this,ut,"f").isEmpty,isComplete:i(this,ut,"f").isComplete,isValid:i(this,ut,"f").isValid,isFocused:i(this,ut,"f").isFocused,value:i(this,ut,"f").value,required:i(this,ut,"f").isRequired}),this.getOptions=()=>{let e=Ce(i(this,Et,"f"));return i(this,lt,"f")?e=e.rows[0].elements[0]:e.rows.forEach((e=>{e.elements.forEach((e=>{delete e.elementName}))})),delete e.elementName,e},At.set(this,(e=>{i(this,_t,"f").on(q,(()=>{const t=i(this,dt,"f").map((e=>e.elementName));i(this,lt,"f")||t.push(i(this,pt,"f").name),e(t)}),!0)})),Lt.set(this,(()=>{i(this,It,"f").on(K,(e=>{if(i(this,lt,"f")&&e.event===$.READY&&e.name===i(this,pt,"f").name)i(this,_t,"f")._emit($.READY);else{const t=i(this,dt,"f").length>1;i(this,dt,"f").forEach(((n,o)=>{var s;if(e.name===n.elementName){let r="";switch(e.event){case $.FOCUS:r=$.FOCUS;break;case $.BLUR:r=$.BLUR;break;case $.CHANGE:r=$.CHANGE;break;case $.READY:r=$.READY;break;case $.SUBMIT:return void(null===(s=i(this,ht,"f"))||void 0===s||s._emit($.SUBMIT));default:throw new Xe(We.INVALID_EVENT_TYPE,[],!0)}i(this,ct,"f")[o].isEmpty=e.value.isEmpty,i(this,ct,"f")[o].isValid=e.value.isValid,i(this,ct,"f")[o].isComplete=e.value.isComplete,i(this,ct,"f")[o].isFocused=e.value.isFocused,i(this,ct,"f")[o].isRequired=e.value.isRequired,Object.prototype.hasOwnProperty.call(e.value,"value")?i(this,ct,"f")[o].value=e.value.value:i(this,ct,"f")[o].value=void 0,r=t?`${r}:${e.name}`:r,i(this,It,"f").emit($.HEIGHT+i(this,pt,"f").name,{},(e=>{i(this,pt,"f").setIframeHeight(e.height)})),i(this,yt,"f").call(this);const a=Object.assign(Object.assign({},i(this,ct,"f")[o]),{elementType:n.elementType});t&&i(this,ht,"f")?i(this,ht,"f")._emit(r,a):i(this,_t,"f")._emit(r,a)}}))}}))})),Rt.set(this,(()=>{const{rows:e}=i(this,Et,"f");e.forEach((e=>{e.elements.forEach((e=>{e.elementType!==le.radio.name&&e.elementType!==le.checkbox.name&&(e.value=void 0)}))})),n(this,dt,Pt(i(this,Et,"f")),"f")})),this.containerId=s.containerId,n(this,at,e,"f"),n(this,mt,c,"f"),n(this,Et,Ct(t),"f"),n(this,dt,Pt(t),"f"),n(this,lt,r,"f"),d&&n(this,ht,d,"f"),n(this,Nt,Ve[i(this,mt,"f").env].doesReturnValue,"f"),this.elementType=i(this,lt,"f")?i(this,dt,"f")[0].elementType:"group",n(this,ct,[],"f"),i(this,dt,"f").forEach((e=>{i(this,ct,"f").push({isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:i(this,Nt,"f")?"":void 0,elementType:e.elementType,name:e.elementName,isRequired:!1})})),n(this,pt,new st(i(this,Et,"f").elementName,o,this.containerId,i(this,mt,"f").logLevel),"f"),i(this,Lt,"f").call(this),i(this,At,"f").call(this,a),i(this,Ot,"f").call(this,l),Ge(Be(Y.CREATED_ELEMENT,gt,je(i(this,pt,"f").name)),ke.LOG,i(this,mt,"f").logLevel),n(this,Tt,s.isMounted,"f"),null===(u=i(this,ht,"f"))||void 0===u||u.on(oe,(e=>{(null==e?void 0:e.containerId)===this.containerId&&n(this,Tt,!0,"f")})),i(this,It,"f").on($.MOUNTED,(e=>{s.type===$i.COMPOSABLE?i(this,dt,"f").forEach((t=>{e.name===t.elementName&&(t.isMounted=!0,n(this,vt,!0,"f"))})):e.name===i(this,dt,"f")[0].elementName&&(i(this,dt,"f")[0].isMounted=!0,n(this,vt,!0,"f")),i(this,It,"f").emit($.HEIGHT+i(this,pt,"f").name,{},(e=>{i(this,pt,"f").setIframeHeight(e.height)}))}))}on(e,t){if(!Object.values($).includes(e))throw new Xe(We.INVALID_EVENT_LISTENER,[],!0);if(!t)throw new Xe(We.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof t)throw new Xe(We.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);i(this,_t,"f").on(e,(e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,t(e)}))}iframeName(){return i(this,pt,"f").name}isMounted(){return i(this,vt,"f")}isValidElement(){for(let e=0;e<i(this,dt,"f").length;e+=1){if(!Object.prototype.hasOwnProperty.call(i(this,dt,"f")[e],"table"))throw new Xe(We.MISSING_TABLE_IN_COLLECT,[],!0);if(!i(this,dt,"f")[e].table)throw new Xe(We.EMPTY_TABLE_IN_COLLECT,[],!0);if(!("string"==typeof i(this,dt,"f")[e].table||i(this,dt,"f")[e].table instanceof String))throw new Xe(We.INVALID_TABLE_IN_COLLECT,[],!0);if(!Object.prototype.hasOwnProperty.call(i(this,dt,"f")[e],"column"))throw new Xe(We.MISSING_COLUMN_IN_COLLECT,[],!0);if(!i(this,dt,"f")[e].column)throw new Xe(We.EMPTY_COLUMN_IN_COLLECT,[],!0);if(!("string"==typeof i(this,dt,"f")[e].column||i(this,dt,"f")[e].column instanceof String))throw new Xe(We.INVALID_COLUMN_IN_COLLECT,[],!0);if(void 0!==i(this,dt,"f")[e].skyflowID&&!i(this,dt,"f")[e].skyflowID)throw new Xe(We.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[],!0)}return!0}setError(e){i(this,It,"f").emit(te,{name:it(i(this,pt,"f").name),isTriggerError:!0,clientErrorText:e})}resetError(){i(this,It,"f").emit(te,{name:it(i(this,pt,"f").name),isTriggerError:!1})}setValue(e){i(this,mt,"f").env!==Ue.PROD?i(this,lt,"f")&&i(this,It,"f").emit(J,{name:i(this,pt,"f").name,options:Object.assign(Object.assign({},i(this,dt,"f")[0]),{value:e}),isSingleElementAPI:!0}):Ge(Be(V.UNABLE_TO_SET_VALUE_IN_PROD_ENV,i(this,dt,"f")[0].elementType),ke.WARN,i(this,mt,"f").logLevel)}clearValue(){i(this,mt,"f").env!==Ue.PROD?i(this,lt,"f")&&i(this,It,"f").emit(J,{name:i(this,pt,"f").name,options:Object.assign(Object.assign({},i(this,dt,"f")[0]),{value:""}),isSingleElementAPI:!0}):Ge(Be(V.UNABLE_TO_CLEAR_VALUE_IN_PROD_ENV,i(this,dt,"f")[0].elementType),ke.WARN,i(this,mt,"f").logLevel)}}function Dt(e,t,i={}){if("group"!==e&&!Object.prototype.hasOwnProperty.call(le,e))throw new Xe(We.INVALID_ELEMENT_TYPE,[],!0);if(Object.prototype.hasOwnProperty.call(t,"validations")){if(!Array.isArray(t.validations))throw new Xe(We.INVALID_VALIDATIONS_TYPE,[],!0);t.validations.forEach(((e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new Xe(We.MISSING_VALIDATION_RULE_TYPE,[`${t}`],!0);if(!Object.values(Ye).includes(e.type))throw new Xe(We.INVALID_VALIDATION_RULE_TYPE,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"params"))throw new Xe(We.MISSING_VALIDATION_RULE_PARAMS,[`${t}`],!0);if("object"!=typeof e.params||Array.isArray(e.params)||null===e.params)throw new Xe(We.INVALID_VALIDATION_RULE_PARAMS,[`${t}`],!0);if(e.type===Ye.REGEX_MATCH_RULE){if(!Object.prototype.hasOwnProperty.call(e.params,"regex"))throw new Xe(We.MISSING_REGEX_IN_REGEX_MATCH_RULE,[`${t}`],!0)}else if(e.type===Ye.LENGTH_MATCH_RULE&&!Object.prototype.hasOwnProperty.call(e.params,"min")&&!Object.prototype.hasOwnProperty.call(e.params,"max"))throw new Xe(We.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}=le[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===le.radio.name||e===le.checkbox.name)&&!i.value)throw new Error("Elements radio and checkbox requires value attribute");if(!(e!==le.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 Ct(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(x.CANNOT_CHANGE_ELEMENT);Dt(a.elementType,a,l),s.elements[t]=Object.assign(Object.assign(Object.assign({},a),l),{elementName:a.elementName});const c=l.classes||{},d=l.styles||{};d.base=Object.assign(Object.assign({},Ee),d.base),l.classes=c,l.styles=d;const u=(null===(n=null==l?void 0:l.labelStyles)||void 0===n?void 0:n.classes)||{},E=(null===(o=null==l?void 0:l.labelStyles)||void 0===o?void 0:o.styles)||{};i&&function(e,t){Object.values(_e).forEach((i=>{if(e[i]||t[i])switch(i){case _e.BASE:t[i]=Object.assign({},t[i]);break;case _e.FOCUS:t[_e.BASE]=Object.assign(Object.assign({},t[_e.BASE]),{":focus":Object.assign({},t[_e.BASE]&&t[_e.BASE][":focus"])});break;case _e.WEBPACKAUTOFILL:t[_e.BASE]=Object.assign(Object.assign({},t[_e.BASE]),{":-webkit-autofill":Object.assign({},t[_e.BASE]&&t[_e.BASE][":-webkit-autofill"])});break;default:t[i]=Object.assign(Object.assign({},t[_e.BASE]),t[i])}})),Object.keys(t).forEach((e=>{const i=t[e][":-webkit-autofill"];"object"==typeof i&&Object.keys(i).forEach((e=>{i[e]&&!i[e].includes("!important")&&(i[e]=`${i[e]} !important`)}))}))}(u,E),l.labelStyles={labelClasses:u},l.labelStyles.styles=E}))})),t}at=new WeakMap,lt=new WeakMap,ct=new WeakMap,dt=new WeakMap,ut=new WeakMap,Et=new WeakMap,_t=new WeakMap,ht=new WeakMap,It=new WeakMap,pt=new WeakMap,ft=new WeakMap,vt=new WeakMap,mt=new WeakMap,Nt=new WeakMap,Tt=new WeakMap,Ot=new WeakMap,yt=new WeakMap,At=new WeakMap,Lt=new WeakMap,Rt=new WeakMap;const Pt=e=>{const{rows:t}=e,i=[];return t.forEach((e=>{e.elements.forEach((e=>{i.push(e)}))})),i},bt=e=>{const t=e.validations;return t&&Array.isArray(t)&&t.length>0&&t.forEach(((e,t)=>{if(e&&e.type===Ye.ELEMENT_VALUE_MATCH_RULE){if(e.params&&!Object.prototype.hasOwnProperty.call(e.params,"element"))throw new Xe(We.MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE,[`${t}`],!0);if(e.params&&(null==e.params.element||!(e.params.element instanceof St)))throw new Xe(We.INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE,[`${t}`],!0);e.params&&e.params.element&&e.params.element instanceof St&&(e.params.element=e.params.element.iframeName())}else if(e&&e.type===Ye.REGEX_MATCH_RULE){if(e.params&&e.params.regex&&!Je(e.params.regex))throw new Xe(We.INVALID_REGEX_IN_REGEX_MATCH_RULE,[`${t}`],!0);e.params&&e.params.regex&&Je(e.params.regex)&&(e.params.regex=e.params.regex.toString())}})),t},Mt=(e,t,i)=>{let n=Object.assign({required:!1},t);if((Object.prototype.hasOwnProperty.call(n,"format")||Object.prototype.hasOwnProperty.call(n,"translation"))&&(me.includes(e)?(Ge(Be(V.INPUT_FORMATTING_NOT_SUPPROTED,e),ke.WARN,i),null==n||delete n.format,null==n||delete n.translation):e===le.INPUT_FIELD.name&&((e=>{if(e){if(Object.prototype.hasOwnProperty.call(e,"format")&&"string"!=typeof e.format)throw new Xe(We.INVALID_INPUT_OPTIONS_FORMAT,[],!0);if(Object.prototype.hasOwnProperty.call(e,"translation")&&("object"!=typeof e.translation||"[object Object]"!==Object.prototype.toString.call(e.translation)))throw new Xe(We.INVALID_INPUT_OPTIONS_TRANSLATION,[],!0)}})(t),n=Object.assign(Object.assign({},n),{mask:[n.format,n.translation?n.translation:Ne]}),null==n||delete n.format,null==n||delete n.translation)),e===le.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)===ce&&(e="-"),n=Object.assign(Object.assign({},n),{cardSeperator:e}),null==n||delete n.format,null==n||delete n.translation}else if(e===le.EXPIRATION_DATE.name){let e=!1;n.format&&(e=!!(o=n.format.toUpperCase())&&pe.includes(o),e||Ge(Be(V.INVALID_EXPIRATION_DATE_FORMAT,pe.toString()),ke.WARN,i)),n=Object.assign(Object.assign({},n),{format:e?n.format.toUpperCase():Ie}),null==n||delete n.translation}else if(e===le.EXPIRATION_YEAR.name){let e=!1;n.format&&(e=(e=>!!e&&fe.includes(e))(n.format.toUpperCase()),e||Ge(Be(V.INVALID_EXPIRATION_YEAR_FORMAT,fe.toString()),ke.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")&&!tt(n.enableCardIcon))throw new Xe(We.INVALID_BOOLEAN_OPTIONS,["enableCardIcon"],!0);if(Object.prototype.hasOwnProperty.call(n,"enableCopy")&&!tt(n.enableCopy))throw new Xe(We.INVALID_BOOLEAN_OPTIONS,["enableCopy"],!0);if(Object.prototype.hasOwnProperty.call(n,"required")&&!tt(n.required))throw new Xe(We.INVALID_BOOLEAN_OPTIONS,["required"],!0);return n};function wt(){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 Ut{}var kt,Yt,xt,Vt,Ft,Gt,Bt,jt,Xt,Wt,$t,zt;const Ht="CollectContainer";class Kt extends Ut{constructor(e,t,o,s){super(),kt.set(this,void 0),Yt.set(this,{}),xt.set(this,void 0),Vt.set(this,void 0),Ft.set(this,void 0),this.type=$i.COLLECT,Gt.set(this,void 0),Bt.set(this,!1),this.create=(e,t={required:!1})=>{Qe(e,i(this,Vt,"f").logLevel);const n=bt(e),o=Mt(e.type,t,i(this,Vt,"f").logLevel),s={rows:[{elements:[Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column,accept:t.allowedFileType},e),o),{validations:n})]}]};return i(this,jt,"f").call(this,s,!0)},jt.set(this,((e,t=!1)=>{const n=[],o=Ce(e);if(o.rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;Dt(i,t),t.sensitive=t.sensitive||le[i].sensitive,t.replacePattern=t.replacePattern||le[i].replacePattern,t.mask=t.mask||le[i].mask,t.isMounted=!1,t.elementType!==le.radio.name&&t.elementType!==le.checkbox.name||(t.elementName=`${t.elementName}:${btoa(t.value)}`),t.elementName=`${G}:${t.elementType}:${btoa(wt())}`,t.label=e.label,t.skyflowID=e.skyflowID,n.push(t)}))})),o.elementName=t?n[0].elementName:`${G}:group:${btoa(o.name)}`,t&&!i(this,Yt,"f")[n[0].elementName]&&i(this,zt,"f").call(this,n[0].name))throw new Xe(We.UNIQUE_ELEMENT_NAME,[`${n[0].name}`],!0);let s=i(this,Yt,"f")[o.elementName];if(s)t?s.update(n[0]):s.update(o);else{const e=wt();s=new St(e,o,i(this,xt,"f"),{containerId:i(this,kt,"f"),isMounted:i(this,Bt,"f"),type:this.type},t,i(this,Wt,"f"),i(this,$t,"f"),i(this,Vt,"f"),i(this,Gt,"f")),i(this,Yt,"f")[o.elementName]=s,i(this,Ft,"f")[e]=s}return t||n.forEach((e=>{const t=e.elementName;i(this,Yt,"f")[t]?i(this,Yt,"f")[t].update(e):i(this,Yt,"f")[t]=this.create(e.elementType,s)})),s})),Xt.set(this,(e=>{Object.keys(i(this,Yt,"f")).forEach((t=>{t===e&&delete i(this,Yt,"f")[t]}))})),Wt.set(this,(e=>{e.forEach((e=>{i(this,Xt,"f").call(this,e)}))})),$t.set(this,(e=>{e.forEach((e=>{i(this,Yt,"f")[e.elementName]&&i(this,Yt,"f")[e.elementName].update(e)}))})),zt.set(this,(e=>{const t=Object.keys(i(this,Yt,"f"));for(let i=0;i<t.length;i+=1)if(atob(t[i].split(":")[2])===e)return!0;return!1})),this.collect=(e={tokens:!0})=>new Promise(((t,n)=>{try{if(Ze(i(this,xt,"f").clientJSON.config),Object.values(i(this,Yt,"f")).forEach((e=>{if(!e.isMounted())throw new Xe(We.ELEMENTS_NOT_MOUNTED,[],!0);e.isValidElement()})),Object.prototype.hasOwnProperty.call(e,"tokens")&&!tt(e.tokens))throw new Xe(We.INVALID_TOKENS_IN_COLLECT,[],!0);(null==e?void 0:e.additionalFields)&&ze(e.additionalFields),(null==e?void 0:e.upsert)&&et(null==e?void 0:e.upsert),this.bus.emit(H+i(this,kt,"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)?(Ge(`${JSON.stringify(null==e?void 0:e.error)}`,ke.ERROR,i(this,Vt,"f").logLevel),n(null==e?void 0:e.error)):(Ge(Be(Y.COLLECT_SUBMIT_SUCCESS,Ht),ke.LOG,i(this,Vt,"f").logLevel),t(e))})),Ge(Be(Y.EMIT_EVENT,Ht,H),ke.LOG,i(this,Vt,"f").logLevel)}catch(e){Ge(`${e.message}`,ke.ERROR,i(this,Vt,"f").logLevel),n(e)}})),this.bus=k.getEventBus(),n(this,kt,wt(),"f"),n(this,xt,t,"f"),n(this,Ft,o,"f"),n(this,Vt,s,"f"),n(this,Gt,new Te,"f");const r=ge({name:`${F}:${i(this,kt,"f")}:${i(this,Vt,"f").logLevel}`});Re(r,{src:Se()}),De(r,Object.assign({},ue)),Ge(Be(Y.CREATE_COLLECT_CONTAINER,Ht),ke.LOG,i(this,Vt,"f").logLevel);const a=(e,o)=>{e.name===F+i(this,kt,"f")&&(o(Object.assign(Object.assign({},t),{clientJSON:Object.assign(Object.assign({},t.clientJSON),{config:Object.assign({},t.clientJSON.config)}),context:s})),n(this,Bt,!0,"f"),i(this,Gt,"f")._emit(oe,{containerId:i(this,kt,"f")}),this.bus.target({origin:Oe.IFRAME_SECURE_ORGIN}).off(z+i(this,kt,"f"),a))};this.bus.target({origin:Oe.IFRAME_SECURE_ORGIN}).on(z+i(this,kt,"f"),a),document.body.append(r)}}kt=new WeakMap,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;var qt,Jt,Zt,Qt,ei,ti,ii,ni,oi,si,ri,ai,li,ci,di,ui,Ei,_i,hi,Ii,pi,fi,vi,mi=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},Ni=function(e){return e},Ti=s((function(e){return e&&e.length?mi(e,Ni):0}));class Oi{constructor(e,t){qt.set(this,void 0),Jt.set(this,void 0),this.type=$i.COMPOSABLE,Zt.set(this,!1),Qt.set(this,!1),this.update=e=>{n(this,Qt,!0,"f"),i(this,Zt,"f")?(i(this,Jt,"f")._emit(ie,{elementName:i(this,qt,"f"),elementOptions:e}),n(this,Qt,!1,"f")):i(this,Qt,"f")&&i(this,Jt,"f").on(`${Me.READY}:${i(this,qt,"f")}`,(()=>{i(this,Jt,"f")._emit(ie,{elementName:i(this,qt,"f"),elementOptions:e}),n(this,Zt,!0,"f"),n(this,Qt,!1,"f")}))},n(this,qt,e,"f"),n(this,Jt,t,"f"),i(this,Jt,"f").on(`${Me.READY}:${i(this,qt,"f")}`,(()=>{n(this,Zt,!0,"f")}))}on(e,t){if(!Object.values($).includes(e))throw new Xe(We.INVALID_EVENT_LISTENER,[],!0);if(!t)throw new Xe(We.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof t)throw new Xe(We.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);i(this,Jt,"f").on(`${e}:${i(this,qt,"f")}`,(e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,t(e)}))}}qt=new WeakMap,Jt=new WeakMap,Zt=new WeakMap,Qt=new WeakMap;const yi="CollectContainer";class Ai extends Ut{constructor(e,t,o,s){super(),ei.set(this,void 0),ti.set(this,{}),ii.set(this,void 0),ni.set(this,{rows:[]}),oi.set(this,[]),si.set(this,void 0),ri.set(this,void 0),ai.set(this,void 0),li.set(this,!1),ci.set(this,void 0),di.set(this,void 0),this.type=$i.COMPOSABLE,ui.set(this,!1),Ei.set(this,{}),this.create=(e,t={required:!1})=>{Qe(e,i(this,si,"f").logLevel);const n=bt(e),o=Mt(e.type,t,i(this,si,"f").logLevel),s=`${G}:${e.type}:${btoa(wt())}`;return i(this,oi,"f").push(Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column},e),o),{validations:n,elementName:s})),new Oi(s,i(this,ai,"f"))},_i.set(this,((e,t=!1)=>{const o=[];if(n(this,Ei,Ce(e),"f"),i(this,Ei,"f").rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;Dt(i,t),t.sensitive=t.sensitive||le[i].sensitive,t.replacePattern=t.replacePattern||le[i].replacePattern,t.mask=t.mask||le[i].mask,t.isMounted=!1,t.label=e.label,t.skyflowID=e.skyflowID,o.push(t)}))})),i(this,Ei,"f").elementName=t?o[0].elementName:`${G}:group:${btoa(i(this,Ei,"f").name)}`,t&&!i(this,ti,"f")[o[0].elementName]&&i(this,fi,"f").call(this,o[0].name))throw new Xe(We.UNIQUE_ELEMENT_NAME,[`${o[0].name}`],!0);let s=i(this,ti,"f")[i(this,Ei,"f").elementName];if(s)t?s.update(o[0]):s.update(i(this,Ei,"f"));else{const e=wt();s=new St(e,i(this,Ei,"f"),i(this,ii,"f"),{containerId:i(this,ei,"f"),isMounted:i(this,ui,"f"),type:this.type},!0,i(this,Ii,"f"),i(this,pi,"f"),i(this,si,"f"),i(this,ai,"f")),i(this,ti,"f")[i(this,Ei,"f").elementName]=s,i(this,ri,"f")[e]=s}return s})),hi.set(this,(e=>{Object.keys(i(this,ti,"f")).forEach((t=>{t===e&&delete i(this,ti,"f")[t]}))})),Ii.set(this,(e=>{e.forEach((e=>{i(this,hi,"f").call(this,e)}))})),pi.set(this,(e=>{e.forEach((e=>{i(this,ti,"f")[e.elementName]&&i(this,ti,"f")[e.elementName].update(e)}))})),fi.set(this,(e=>{const t=Object.keys(i(this,ti,"f"));for(let i=0;i<t.length;i+=1)if(atob(t[i].split(":")[2])===e)return!0;return!1})),this.on=(e,t)=>{if(!Object.values($).includes(e))throw new Xe(We.INVALID_EVENT_LISTENER,[],!0);if(!t)throw new Xe(We.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof t)throw new Xe(We.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);i(this,ai,"f").on($.SUBMIT,(()=>{t()}))},this.mount=e=>{if(!e)throw new Xe(We.EMPTY_ELEMENT_IN_MOUNT,["CollectElement"],!0);const{layout:t}=i(this,ci,"f");if(Ti(t)!==i(this,oi,"f").length)throw new Xe(We.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM,[],!0);let o=0;if(t.forEach(((e,t)=>{i(this,ni,"f").rows=[...i(this,ni,"f").rows,{elements:[]}];for(let n=0;n<e;n++)i(this,ni,"f").rows[t].elements.push(i(this,oi,"f")[o]),o++})),i(this,ci,"f").styles&&(i(this,ni,"f").styles=Object.assign({},i(this,ci,"f").styles)),i(this,ci,"f").errorTextStyles&&(i(this,ni,"f").errorTextStyles=Object.assign({},i(this,ci,"f").errorTextStyles)),i(this,ui,"f"))return n(this,di,i(this,_i,"f").call(this,i(this,ni,"f"),!1),"f"),i(this,di,"f").mount(e),void n(this,li,!0,"f");i(this,ai,"f").on(ne+i(this,ei,"f"),(()=>{n(this,di,i(this,_i,"f").call(this,i(this,ni,"f"),!1),"f"),i(this,di,"f").mount(e),n(this,li,!0,"f")}))},this.unmount=()=>{i(this,di,"f").unmount()},this.collect=(e={tokens:!0})=>new Promise(((t,n)=>{try{if(Ze(i(this,ii,"f").clientJSON.config),!i(this,li,"f")){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);throw a.PayrailsLogger.error(e.message,{error:e}),e}if(Pt(i(this,Ei,"f")).forEach((e=>{if(!(null==e?void 0:e.isMounted))throw new Xe(We.ELEMENTS_NOT_MOUNTED,[],!0)})),Object.values(i(this,ti,"f")).forEach((e=>{e.isValidElement()})),e&&e.tokens&&"boolean"!=typeof e.tokens)throw new Xe(We.INVALID_TOKENS_IN_COLLECT,[],!0);(null==e?void 0:e.additionalFields)&&ze(e.additionalFields),(null==e?void 0:e.upsert)&&et(null==e?void 0:e.upsert),this.bus.emit(H+i(this,ei,"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)?(Ge(`${JSON.stringify(null==e?void 0:e.error)}`,ke.ERROR,i(this,si,"f").logLevel),n(null==e?void 0:e.error)):(Ge(Be(Y.COLLECT_SUBMIT_SUCCESS,yi),ke.LOG,i(this,si,"f").logLevel),t(e))})),Ge(Be(Y.EMIT_EVENT,yi,H),ke.LOG,i(this,si,"f").logLevel)}catch(e){Ge(`${e.message}`,ke.ERROR,i(this,si,"f").logLevel),n(e)}})),vi.set(this,(()=>{i(this,ai,"f").on(ie,(e=>{let t;const n=i(this,oi,"f").map(((i,n)=>i.elementName===e.elementName?(t=n,Object.assign({elementName:i.elementName},e.elementOptions)):i));i(this,di,"f")&&i(this,di,"f").updateElement(Object.assign({},n[t]))}))})),this.bus=k.getEventBus(),n(this,ei,wt(),"f"),n(this,ii,t,"f"),n(this,ri,o,"f"),n(this,si,s,"f"),n(this,ci,e,"f"),n(this,ai,new Te,"f");const l=ge({name:`${F}:${i(this,ei,"f")}:${i(this,si,"f").logLevel}`});Re(l,{src:Se()}),De(l,Object.assign({},ue)),Ge(Be(Y.CREATE_COLLECT_CONTAINER,yi),ke.LOG,i(this,si,"f").logLevel);const c=(e,o)=>{e.name===F+i(this,ei,"f")&&(o(Object.assign(Object.assign({},t),{clientJSON:Object.assign(Object.assign({},t.clientJSON),{config:Object.assign({},t.clientJSON.config)}),context:s})),n(this,ui,!0,"f"),i(this,ai,"f")._emit(ne+i(this,ei,"f"),{containerId:i(this,ei,"f")}),this.bus.target({origin:Oe.IFRAME_SECURE_ORGIN}).off(z+i(this,ei,"f"),c))};this.bus.target({origin:Oe.IFRAME_SECURE_ORGIN}).on(z+i(this,ei,"f"),c),document.body.append(l),i(this,vi,"f").call(this)}}var Li,Ri,gi,Si;ei=new WeakMap,ti=new WeakMap,ii=new WeakMap,ni=new WeakMap,oi=new WeakMap,si=new WeakMap,ri=new WeakMap,ai=new WeakMap,li=new WeakMap,ci=new WeakMap,di=new WeakMap,ui=new WeakMap,Ei=new WeakMap,_i=new WeakMap,hi=new WeakMap,Ii=new WeakMap,pi=new WeakMap,fi=new WeakMap,vi=new WeakMap;const Di="SkyflowContainer";class Ci{constructor(e,t){var o,s;Li.set(this,void 0),Ri.set(this,void 0),gi.set(this,!1),Si.set(this,void 0),this.bus=k.getEventBus(),n(this,Ri,e,"f"),n(this,Li,(null===(s=null===(o=i(this,Ri,"f").toJSON())||void 0===o?void 0:o.metaData)||void 0===s?void 0:s.uuid)||"","f"),n(this,Si,t,"f");const r=ge({name:`skyflow_controller:${i(this,Li,"f")}`});Re(r,{src:Se()}),De(r,Object.assign({},ue)),document.body.append(r),this.bus.target({origin:Oe.IFRAME_SECURE_ORGIN}).on(Q+i(this,Li,"f"),((e,o)=>{Ge(Be(Y.CAPTURE_PUREJS_FRAME,Di),ke.LOG,i(this,Si,"f").logLevel),o({client:i(this,Ri,"f"),context:t}),n(this,gi,!0,"f")})),Ge(Be(Y.PUREJS_CONTROLLER_INITIALIZED,Di),ke.LOG,i(this,Si,"f").logLevel)}insert(e,t){return i(this,gi,"f")?new Promise(((n,o)=>{Ze(i(this,Ri,"f").config);try{Ge(Be(Y.VALIDATE_RECORDS,Di),ke.LOG,i(this,Si,"f").logLevel),(null==(t=t?Object.assign(Object.assign({},t),{tokens:void 0===(null==t?void 0:t.tokens)||t.tokens}):{tokens:!0})?void 0:t.upsert)&&et(t.upsert),$e(e,t),this.bus.emit(Z+i(this,Li,"f"),{type:B,records:e,options:t},(e=>{e.error?(Ge(`${JSON.stringify(e.error)}`,ke.ERROR,i(this,Si,"f").logLevel),o(e.error)):n(e)})),Ge(Be(Y.EMIT_PURE_JS_REQUEST,Di,B),ke.LOG,i(this,Si,"f").logLevel)}catch(e){Ge(e.message,ke.ERROR,i(this,Si,"f").logLevel),o(e)}})):new Promise(((n,o)=>{try{Ze(i(this,Ri,"f").config),Ge(Be(Y.VALIDATE_RECORDS,Di),ke.LOG,i(this,Si,"f").logLevel),(null==(t=t?Object.assign(Object.assign({},t),{tokens:void 0===(null==t?void 0:t.tokens)||t.tokens}):{tokens:!0})?void 0:t.upsert)&&et(t.upsert),$e(e,t),this.bus.target({origin:Oe.IFRAME_SECURE_ORGIN}).on(Q+i(this,Li,"f"),(()=>{this.bus.emit(Z+i(this,Li,"f"),{type:B,records:e,options:t},(e=>{e.error?(Ge(`${JSON.stringify(e.error)}`,ke.ERROR,i(this,Si,"f").logLevel),o(e.error)):n(e)}))})),Ge(Be(Y.EMIT_PURE_JS_REQUEST,Di,B),ke.LOG,i(this,Si,"f").logLevel)}catch(e){Ge(e.message,ke.ERROR,i(this,Si,"f").logLevel),o(e)}}))}getById(e){return i(this,gi,"f")?new Promise(((t,n)=>{Ze(i(this,Ri,"f").config);try{Ge(Be(Y.VALIDATE_GET_BY_ID_INPUT,Di),ke.LOG,i(this,Si,"f").logLevel),Ke(e),Ge(Be(Y.EMIT_PURE_JS_REQUEST,Di,j),ke.LOG,i(this,Si,"f").logLevel)}catch(e){Ge(e.message,ke.ERROR,i(this,Si,"f").logLevel),n(e)}})):new Promise(((t,n)=>{try{Ze(i(this,Ri,"f").config),Ge(Be(Y.VALIDATE_GET_BY_ID_INPUT,Di),ke.LOG,i(this,Si,"f").logLevel),Ke(e),Ge(Be(Y.EMIT_PURE_JS_REQUEST,Di,j),ke.LOG,i(this,Si,"f").logLevel)}catch(e){Ge(e.message,ke.ERROR,i(this,Si,"f").logLevel),n(e)}}))}get(e,t){return i(this,gi,"f")?new Promise(((n,o)=>{Ze(i(this,Ri,"f").config);try{Ge(Be(Y.VALIDATE_GET_INPUT,Di),ke.LOG,i(this,Si,"f").logLevel),He(e,t),Ge(Be(Y.EMIT_PURE_JS_REQUEST,Di,X),ke.LOG,i(this,Si,"f").logLevel)}catch(e){Ge(e.message,ke.ERROR,i(this,Si,"f").logLevel),o(e)}})):new Promise(((n,o)=>{try{Ze(i(this,Ri,"f").config),Ge(Be(Y.VALIDATE_GET_INPUT,Di),ke.LOG,i(this,Si,"f").logLevel),He(e,t),Ge(Be(Y.EMIT_PURE_JS_REQUEST,Di,X),ke.LOG,i(this,Si,"f").logLevel)}catch(e){Ge(e.message,ke.ERROR,i(this,Si,"f").logLevel),o(e)}}))}delete(e,t){return i(this,gi,"f")?new Promise(((n,o)=>{Ze(i(this,Ri,"f").config);try{Ge(Be(Y.VALIDATE_DELETE_INPUT,Di),ke.LOG,i(this,Si,"f").logLevel),qe(e),this.bus.emit(Z+i(this,Li,"f"),{type:W,records:e,options:t},(e=>{e.error?(Ge(`${JSON.stringify(e.error)}`,ke.ERROR,i(this,Si,"f").logLevel),o(e.error)):n(e)})),Ge(Be(Y.EMIT_PURE_JS_REQUEST,Di,W),ke.LOG,i(this,Si,"f").logLevel)}catch(e){Ge(e.message,ke.ERROR,i(this,Si,"f").logLevel),o(e)}})):new Promise(((n,o)=>{try{Ze(i(this,Ri,"f").config),Ge(Be(Y.VALIDATE_RECORDS,Di),ke.LOG,i(this,Si,"f").logLevel),qe(e),this.bus.target({origin:Oe.IFRAME_SECURE_ORGIN}).on(Q+i(this,Li,"f"),(()=>{this.bus.emit(Z+i(this,Li,"f"),{type:W,records:e,options:t},(e=>{e.error?(Ge(`${JSON.stringify(e.error)}`,ke.ERROR,i(this,Si,"f").logLevel),o(e.error)):n(e)}))})),Ge(Be(Y.EMIT_PURE_JS_REQUEST,Di,W),ke.LOG,i(this,Si,"f").logLevel)}catch(e){Ge(e.message,ke.ERROR,i(this,Si,"f").logLevel),o(e)}}))}}function Pi(e){this.message=e}Li=new WeakMap,Ri=new WeakMap,gi=new WeakMap,Si=new WeakMap,Pi.prototype=new Error,Pi.prototype.name="InvalidCharacterError";var bi="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new Pi("'atob' failed: The string to be decoded is not correctly encoded.");for(var i,n,o=0,s=0,r="";n=t.charAt(s++);~n&&(i=o%4?64*i+n:n,o++%4)?r+=String.fromCharCode(255&i>>(-2*o&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return r};function Mi(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(bi(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 bi(t)}}function wi(e){this.message=e}wi.prototype=new Error,wi.prototype.name="InvalidTokenError";const Ui=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 wi("Invalid token specified");var i=!0===(t=t||{}).header?0:1;try{return JSON.parse(Mi(e.split(".")[i]))}catch(e){throw new wi("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 ki,Yi,xi,Vi,Fi,Gi,Bi,ji,Xi,Wi,$i,zi={name:"skyflow-js",preferGlobal:!0,analyze:!1,version:"1.30.1",author:"Skyflow",description:"Skyflow JavaScript SDK"};class Hi{constructor(e,t){ki.set(this,void 0),this.request=e=>new Promise(((t,n)=>{var o,s,r,a;const l=new XMLHttpRequest;if(l){if(l.open(e.requestMethod,e.url),e.headers){const t=function(e,t,i){var n,o,s,r,a;const l={sdkName:e.name,sdkVersion:e.version},c=function(e,t){return""!==e?`${e}`:`${t.sdkName}@${t.sdkVersion}`}(t.sdkVersion,l),d=function(e){var t,i,n,o,s,r,a,l,c,d,u,E;let _=null,h=null;return/Windows/.test(e)?(_="Windows",h=null!==(i=null===(t=/Windows NT (\d+\.\d+)/.exec(e))||void 0===t?void 0:t[1])&&void 0!==i?i:null):/Android/.test(e)?(_="Android",h=null!==(o=null===(n=/Android (\d+\.\d+)/.exec(e))||void 0===n?void 0:n[1])&&void 0!==o?o:null):/iOS/.test(e)||/iPhone/.test(e)?(_="iOS",h=null!==(a=null===(r=null===(s=/OS (\d+[._]\d+[._]?\d*)/.exec(e))||void 0===s?void 0:s[1])||void 0===r?void 0:r.replace(/_/g,"."))&&void 0!==a?a:null):/Mac OS X/.test(e)?(_="Mac OS X",h=null!==(d=null===(c=null===(l=/Mac OS X (\d+([._]\d+)*)/.exec(e))||void 0===l?void 0:l[1])||void 0===c?void 0:c.replace(/_/g,"."))&&void 0!==d?d:null):/Linux/.test(e)&&(_="Linux",h=null!==(E=null===(u=/Linux( \w+)*?\/([\w.]+)/.exec(e))||void 0===u?void 0:u[2])&&void 0!==E?E:null),{os:_,version:h}}(i.userAgent),u=function(e){let t="",i="";if(-1!==e.indexOf("MSIE")||-1!==e.indexOf("Trident/")){t="Internet Explorer";const n=e.match(/(MSIE|rv:)\s?([\d.]+)/);n&&(i=n[2])}else if(-1!==e.indexOf("Edge")){t="Microsoft Edge";const n=e.match(/Edge\/([\d.]+)/);n&&(i=n[1])}else if(-1!==e.indexOf("Chrome")){t="Google Chrome";const n=e.match(/Chrome\/([\d.]+)/);n&&(i=n[1])}else if(-1!==e.indexOf("Firefox")){t="Mozilla Firefox";const n=e.match(/Firefox\/([\d.]+)/);n&&(i=n[1])}else if(-1!==e.indexOf("Safari")){t="Apple Safari";const n=e.match(/Version\/([\d.]+)/);n&&(i=n[1])}return{browserName:t,browserVersion:i}}(i.userAgent);var E;return{sdk_name_version:c,sdk_client_device_model:(E=i.userAgent,/(ipad|tablet)/gi.test(E)?"tablet":/Mobile|iP(hone|od)|Android|BlackBerry|IEMobile/.test(E)?"mobile":"desktop"),sdk_os_version:null!==(n=i.platform)&&void 0!==n?n:`${null!==(o=d.os)&&void 0!==o?o:""} ${null!==(s=d.version)&&void 0!==s?s:""}`,sdk_runtime_details:`${null!==(r=u.browserName)&&void 0!==r?r:""} ${null!==(a=u.browserVersion)&&void 0!==a?a:""}`}}(zi,i(this,ki,"f"),navigator);e.headers["sky-metadata"]=JSON.stringify(t);const{headers:n}=e;Object.keys(e.headers).forEach((e=>{"content-type"===e&&n[e]&&n[e].includes(ve.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(ve.FORMURLENCODED))||(null===(a=null===(r=e.headers)||void 0===r?void 0:r["content-type"])||void 0===a?void 0:a.includes(ve.FORMDATA))?l.send(e.body):l.send(JSON.stringify(Object.assign({},e.body))),l.onload=()=>{var e,i,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"],c=r["x-request-id"];if(l.status<200||l.status>=400)if(a&&a.includes("application/json")){let t=JSON.parse(l.response);(null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.message)&&(t=c?`${null===(i=null==t?void 0:t.error)||void 0===i?void 0:i.message} - requestId: ${c}`:null===(o=null==t?void 0:t.error)||void 0===o?void 0:o.message),n(new Xe({code:l.status,description:t},[],!0))}else a&&a.includes("text/plain")?n(new Xe({code:l.status,description:c?`${l.response} - requestId: ${c}`:l.response},[],!0)):n(new Xe({code:l.status,description:c?`${x.ERROR_OCCURED} - requestId: ${c}`:x.ERROR_OCCURED},[],!0));a&&a.includes("application/json")&&t(JSON.parse(l.response)),t(l.response)},l.onerror=()=>{n(new Xe(We.NETWORK_ERROR,[],!0))}}else n(new Xe(We.CONNECTION_ERROR,[],!0))})),this.config=e,n(this,ki,t,"f")}toJSON(){return{config:this.config,metaData:i(this,ki,"f")}}static fromJSON(e){return new Hi(e.config,e.metaData)}}ki=new WeakMap,function(e){e.COLLECT="COLLECT",e.COMPOSABLE="COMPOSABLE"}($i||($i={}));const Ki="Skyflow";class qi{constructor(e){var t,o;Yi.set(this,void 0),xi.set(this,wt()),Vi.set(this,{uuid:i(this,xi,"f"),clientDomain:window.location.origin}),Fi.set(this,void 0),Gi.set(this,""),Bi.set(this,void 0),ji.set(this,void 0),Xi.set(this,void 0),Wi.set(this,void 0),this.bus=k.getEventBus();const s=localStorage.getItem("sdk_version")||"";i(this,Vi,"f").sdkVersion=s,n(this,Yi,new Hi(Object.assign({},e),i(this,Vi,"f")),"f"),n(this,ji,(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||we.ERROR,"f"),n(this,Xi,(null===(o=null==e?void 0:e.options)||void 0===o?void 0:o.env)||Ue.PROD,"f"),n(this,Wi,{},"f"),n(this,Fi,new Ci(i(this,Yi,"f"),{logLevel:i(this,ji,"f"),env:i(this,Xi,"f")}),"f"),this.bus.target({origin:Oe.IFRAME_SECURE_ORGIN}).on(ee+i(this,xi,"f"),((e,t)=>{Ge(Be(Y.CAPTURED_BEARER_TOKEN_EVENT,Ki),ke.LOG,i(this,ji,"f")),!i(this,Yi,"f").config.getBearerToken||i(this,Gi,"f")&&Ui(i(this,Gi,"f"))?(Ge(Be(Y.REUSE_BEARER_TOKEN,Ki),ke.LOG,i(this,ji,"f")),t({authToken:i(this,Gi,"f")})):i(this,Yi,"f").config.getBearerToken().then((e=>{Ui(e)?(Ge(Be(Y.BEARER_TOKEN_RESOLVED,Ki),ke.LOG,i(this,ji,"f")),n(this,Gi,e,"f"),t({authToken:i(this,Gi,"f")})):(Ge(x.INVALID_BEARER_TOKEN,ke.ERROR,i(this,ji,"f")),t({error:x.INVALID_BEARER_TOKEN}))})).catch((e=>{Ge(x.BEARER_TOKEN_REJECTED,ke.ERROR,i(this,ji,"f")),t({error:e})}))})),Ge(Be(Y.BEARER_TOKEN_LISTENER,Ki),ke.LOG,i(this,ji,"f")),Ge(Be(Y.CURRENT_ENV,Ki,i(this,Xi,"f")),ke.LOG,i(this,ji,"f")),Ge(Be(Y.CURRENT_LOG_LEVEL,Ki,i(this,ji,"f")),ke.LOG,i(this,ji,"f"))}static init(e){var t;const i=(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||we.ERROR;ot(e),Ge(Be(Y.INITIALIZE_CLIENT,Ki),ke.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 qi(n);return Ge(Be(Y.CLIENT_INITIALIZED,Ki),ke.LOG,i),s}container(e,t){switch(e){case $i.COLLECT:{const n=new Kt(t,Object.assign(Object.assign({},i(this,Vi,"f")),{clientJSON:i(this,Yi,"f").toJSON(),containerType:e}),i(this,Wi,"f"),{logLevel:i(this,ji,"f"),env:i(this,Xi,"f")});return Ge(Be(Y.COLLECT_CONTAINER_CREATED,Ki),ke.LOG,i(this,ji,"f")),n}case $i.COMPOSABLE:{(e=>{if(!e)throw new Xe(We.MISSING_COMPOSABLE_CONTAINER_OPTIONS,[],!0);if("object"!=typeof e)throw new Xe(We.INVALID_COMPOSABLE_CONTAINER_OPTIONS,[],!0);if(!Object.prototype.hasOwnProperty.call(e,"layout"))throw new Xe(We.MISSING_COMPOSABLE_LAYOUT_KEY,[],!0);if(!e.layout)throw new Xe(We.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(!Array.isArray(e.layout))throw new Xe(We.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(0===e.layout.length)throw new Xe(We.EMPTY_COMPOSABLE_LAYOUT_ARRAY,[],!0);e.layout.forEach((e=>{if("number"!=typeof e)throw new Xe(We.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(e<0)throw new Xe(We.NEGATIVE_VALUES_COMPOSABLE_LAYOUT,[],!0)}))})(t);const n=new Ai(t,Object.assign(Object.assign({},i(this,Vi,"f")),{clientJSON:i(this,Yi,"f").toJSON(),containerType:e}),i(this,Wi,"f"),{logLevel:i(this,ji,"f"),env:i(this,Xi,"f")});return Ge(Be(Y.COLLECT_CONTAINER_CREATED,Ki),ke.LOG,i(this,ji,"f")),n}default:if(!e)throw new Xe(We.EMPTY_CONTAINER_TYPE,[],!0);throw new Xe(We.INVALID_CONTAINER_TYPE,[],!0)}}insert(e,t){return Ge(Be(Y.INSERT_TRIGGERED,Ki),ke.LOG,i(this,ji,"f")),i(this,Fi,"f").insert(e,t)}getById(e){return Ge(V.GET_BY_ID_DEPRECATED,ke.WARN,i(this,ji,"f")),Ge(Be(Y.GET_BY_ID_TRIGGERED,Ki),ke.LOG,i(this,ji,"f")),i(this,Fi,"f").getById(e)}get(e,t){return Ge(Be(Y.GET_TRIGGERED,Ki),ke.LOG,i(this,ji,"f")),i(this,Fi,"f").get(e,t)}delete(e,t){return Ge(Be(Y.DELETE_TRIGGERED,Ki),ke.LOG,i(this,ji,"f")),i(this,Fi,"f").delete(e,t)}static get ContainerType(){return $i}static get ElementType(){return se}static get RedactionType(){return Pe}static get RequestMethod(){return be}static get LogLevel(){return we}static get EventName(){return Me}static get Env(){return Ue}static get ValidationRuleType(){return Ye}}function Ji(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,n,o=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:{}}),s=o.queryParams,r=o.dataAttributes;return{url:"".concat(t,"?").concat((i=s,n="",Object.keys(i).forEach((function(e){0!==n.length&&(n+="&"),n+=e+"="+i[e]})),n)),dataAttributes:r}}function Zi(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 Qi(e,t){if(void 0===t&&(t=en()),nn(e,t),"undefined"==typeof window)return t.resolve(null);var i=Ji(e),n=i.url,o=i.dataAttributes,s=o["data-namespace"]||"paypal",r=tn(s);
|
|
4
|
+
*/const pe={IFRAME_SECURE_SITE:"https://js.skyflow.com/v1/elements/index.html",IFRAME_SECURE_ORGIN:"https://js.skyflow.com"},fe="https://assets.payrails.io/df36830/card/index.html",ve="https://assets.payrails.io",me={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no",style:"width: 100%;",allow:"clipboard-read; clipboard-write"},Ne=(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 Te=(e={})=>{const t=document.createElement("iframe"),i=Object.assign(Object.assign({},me),e);return Object.assign(t.style,se),Ne(t,i),t.getAttribute("id")||(t.id=t.name),t};const ye=()=>pe.IFRAME_SECURE_SITE,Oe=(e,t)=>{Object.keys(t).forEach((i=>{Object.prototype.hasOwnProperty.call(t,i)&&(e.style[i]=t[i])}))};function Ae(e){return JSON.parse(JSON.stringify(e))}var Le,ge,Re,Se,Ce,De,be;!function(e){e.DEFAULT="DEFAULT",e.PLAIN_TEXT="PLAIN_TEXT",e.MASKED="MASKED",e.REDACTED="REDACTED"}(Le||(Le={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.PATCH="PATCH",e.DELETE="DELETE"}(ge||(ge={})),function(e){e.CHANGE="CHANGE",e.READY="READY",e.FOCUS="FOCUS",e.BLUR="BLUR",e.SUBMIT="SUBMIT"}(Re||(Re={})),function(e){e.WARN="WARN",e.INFO="INFO",e.DEBUG="DEBUG",e.ERROR="ERROR"}(Se||(Se={})),function(e){e.DEV="DEV",e.PROD="PROD"}(Ce||(Ce={})),function(e){e.LOG="LOG",e.WARN="WARN",e.ERROR="ERROR"}(De||(De={})),function(e){e.REGEX_MATCH_RULE="REGEX_MATCH_RULE",e.LENGTH_MATCH_RULE="LENGTH_MATCH_RULE",e.ELEMENT_VALUE_MATCH_RULE="ELEMENT_VALUE_MATCH_RULE"}(be||(be={}));const Pe={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}},Me={PROD:{doesReturnValue:!1},DEV:{doesReturnValue:!0}},we="[Skyflow]",Ue=(e,t,i)=>{if(i&&Pe[i]){const{showDebugLogs:n,showInfoLogs:s,showWarnLogs:o,showErrorLogs:r}=Pe[i];t===De.LOG&&n?console.log(`${Se.DEBUG}: ${we} ${e}`):t===De.LOG&&s?console.log(`${Se.INFO}: ${we} ${e}`):t===De.WARN&&o?console.warn(`${Se.WARN}: ${we} ${e}`):t===De.ERROR&&r&&console.error(`${Se.ERROR}: ${we} ${e}`)}},ke=(...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]})):""},xe=(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 Ye extends Error{constructor(e,t,i=!1){const n={code:e.code,description:t&&(null==t?void 0:t.length)>0?ke(e.description,...t):e.description};super(n.description),i?this.error=n:this.errors=[n]}}const Fe={INVALID_FIELD:{code:400,description:Y.INVALID_FIELD},VAULTID_IS_REQUIRED:{code:400,description:Y.VAULTID_IS_REQUIRED},EMPTY_VAULTID_IN_INIT:{code:400,description:Y.EMPTY_VAULTID_IN_INIT},VAULTURL_IS_REQUIRED:{code:400,description:Y.VAULTURL_IS_REQUIRED},EMPTY_VAULTURL_IN_INIT:{code:400,description:Y.EMPTY_VAULTURL_IN_INIT},INVALID_VAULTURL_IN_INIT:{code:400,description:Y.INVALID_VAULTURL_IN_INIT},GET_BEARER_TOKEN_IS_REQUIRED:{code:400,description:Y.GET_BEARER_TOKEN_IS_REQUIRED},EMPTY_CONTAINER_TYPE:{code:400,description:Y.EMPTY_CONTAINER_TYPE},INVALID_CONTAINER_TYPE:{code:400,description:Y.INVALID_CONTAINER_TYPE},UNIQUE_ELEMENT_NAME:{code:400,description:Y.UNIQUE_ELEMENT_NAME},ELEMENTS_NOT_MOUNTED:{code:400,description:Y.ELEMENTS_NOT_MOUNTED},MISSING_TABLE_IN_COLLECT:{code:400,description:Y.MISSING_TABLE_IN_COLLECT},EMPTY_TABLE_IN_COLLECT:{code:400,description:Y.EMPTY_TABLE_IN_COLLECT},EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:{code:400,description:Y.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS},INVALID_TABLE_IN_COLLECT:{code:400,description:Y.INVALID_TABLE_IN_COLLECT},INVALID_SKYFLOWID_IN_COLLECT:{code:400,description:Y.INVALID_SKYFLOWID_IN_COLLECT},MISSING_COLUMN_IN_COLLECT:{code:400,description:Y.MISSING_COLUMN_IN_COLLECT},EMPTY_COLUMN_IN_COLLECT:{code:400,description:Y.EMPTY_TABLE_IN_COLLECT},INVALID_COLUMN_IN_COLLECT:{code:400,description:Y.INVALID_COLUMN_IN_COLLECT},CLIENT_CONNECTION:{code:400,description:Y.CLIENT_CONNECTION},RECORDS_KEY_NOT_FOUND:{code:404,description:Y.RECORDS_KEY_NOT_FOUND},EMPTY_RECORDS_IN_INSERT:{code:400,description:Y.EMPTY_RECORDS_IN_INSERT},INVALID_RECORDS_IN_INSERT:{code:404,description:Y.INVALID_RECORDS_IN_INSERT},INVALID_TABLE_IN_INSERT:{code:400,description:Y.INVALID_TABLE_IN_INSERT},EMPTY_TABLE_IN_INSERT:{code:400,description:Y.EMPTY_TABLE_IN_INSERT},MISSING_TABLE_IN_INSERT:{code:400,description:Y.MISSING_TABLE_IN_INSERT},EMPTY_FIELDS_IN_INSERT:{code:400,description:Y.EMPTY_FIELDS_IN_INSERT},MISSING_FIELDS_IN_INSERT:{code:404,description:Y.MISSING_FIELDS_IN_INSERT},INVALID_FIELDS_IN_INSERT:{code:404,description:Y.INVALID_FIELDS_IN_INSERT},INVALID_TOKENS_IN_INSERT:{code:404,description:Y.INVALID_TOKENS_IN_INSERT},RECORDS_KEY_NOT_FOUND_DETOKENIZE:{code:404,description:Y.RECORDS_KEY_NOT_FOUND_DETOKENIZE},EMPTY_RECORDS_DETOKENIZE:{code:400,description:Y.EMPTY_RECORDS_DETOKENIZE},INVALID_RECORDS_IN_DETOKENIZE:{code:404,description:Y.INVALID_RECORDS_IN_DETOKENIZE},MISSING_TOKEN_IN_DETOKENIZE:{code:400,description:Y.MISSING_TOKEN_IN_DETOKENIZE},INVALID_TOKEN_IN_DETOKENIZE:{code:400,description:Y.INVALID_TOKEN_IN_DETOKENIZE},RECORDS_KEY_NOT_FOUND_GET:{code:400,description:Y.RECORDS_KEY_NOT_FOUND_GET},INVALID_RECORDS_IN_GET:{code:400,description:Y.INVALID_RECORDS_IN_GET},EMPTY_RECORDS_GET:{code:400,description:Y.EMPTY_RECORDS_GET},MISSING_IDS_IN_GET:{code:400,description:Y.MISSING_IDS_IN_GET},INVALID_IDS_IN_GET:{code:400,description:Y.INVALID_IDS_IN_GET},INVALID_COLUMN_VALUES_IN_GET:{code:400,description:Y.INVALID_COLUMN_VALUES_IN_GET},EMPTY_IDS_IN_GET:{code:400,description:Y.EMPTY_IDS_IN_GET},INVALID_SKYFLOWID_TYPE_IN_GET:{code:400,description:Y.INVALID_SKYFLOWID_TYPE_IN_GET},MISSING_TABLE_IN_GET:{code:400,description:Y.MISSING_TABLE_IN_GET},INVALID_TABLE_IN_GET:{code:400,description:Y.INVALID_TABLE_IN_GET},MISSING_REDACTION_IN_GET:{code:400,description:Y.MISSING_REDACTION_IN_GET},INVALID_REDACTION_TYPE_IN_GET:{code:400,description:Y.INVALID_REDACTION_TYPE_IN_GET},INVALID_TOKENS_IN_GET:{code:400,description:Y.INVALID_TOKENS_IN_GET},TOKENS_GET_COLUMN_NOT_SUPPORTED:{code:400,description:Y.TOKENS_GET_COLUMN_NOT_SUPPORTED},REDACTION_WITH_TOKENS_NOT_SUPPORTED:{code:400,description:Y.REDACTION_WITH_TOKENS_NOT_SUPPORTED},INVALID_REDACTION_TYPE_IN_DETOKENIZE:{code:400,description:Y.INVALID_REDACTION_TYPE_IN_DETOKENIZE},INVALID_TOKENS_IN_COLLECT:{code:404,description:Y.INVALID_TOKENS_IN_COLLECT},RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS:{code:404,description:Y.RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS},INVALID_RECORDS_IN_ADDITIONAL_FIELDS:{code:404,description:Y.INVALID_RECORDS_IN_ADDITIONAL_FIELDS},EMPTY_RECORDS_IN_ADDITIONAL_FIELDS:{code:400,description:Y.EMPTY_RECORDS_IN_ADDITIONAL_FIELDS},MISSING_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:Y.MISSING_TABLE_IN_ADDITIONAL_FIELDS},INVALID_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:Y.INVALID_TABLE_IN_ADDITIONAL_FIELDS},INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:{code:400,description:Y.INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS},MISSING_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:Y.MISSING_FIELDS_IN_ADDITIONAL_FIELDS},INVALID_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:Y.INVALID_FIELDS_IN_ADDITIONAL_FIELDS},RECORDS_KEY_NOT_FOUND_DELETE:{code:400,description:Y.RECORDS_KEY_NOT_FOUND_DELETE},EMPTY_RECORDS_IN_DELETE:{code:400,description:Y.EMPTY_RECORDS_IN_DELETE},INVALID_RECORDS_IN_DELETE:{code:404,description:Y.INVALID_RECORDS_IN_DELETE},INVALID_TABLE_IN_DELETE:{code:400,description:Y.INVALID_TABLE_IN_DELETE},EMPTY_TABLE_IN_DELETE:{code:400,description:Y.EMPTY_TABLE_IN_DELETE},MISSING_TABLE_IN_DELETE:{code:400,description:Y.MISSING_TABLE_IN_DELETE},EMPTY_ID_IN_DELETE:{code:400,description:Y.EMPTY_ID_IN_DELETE},MISSING_ID_IN_DELETE:{code:404,description:Y.MISSING_ID_IN_DELETE},INVALID_ID_IN_DELETE:{code:404,description:Y.INVALID_ID_IN_DELETE},EMPTY_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:Y.EMPTY_TABLE_IN_ADDITIONAL_FIELDS},EMPTY_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:Y.EMPTY_FIELDS_IN_ADDITIONAL_FIELDS},EMPTY_TOKEN_IN_DETOKENIZE:{code:400,description:Y.EMPTY_TOKEN_IN_DETOKENIZE},EMPTY_SKYFLOWID_IN_GET:{code:400,description:Y.EMPTY_SKYFLOWID_IN_GET},EMPTY_TABLE_IN_GET:{code:400,description:Y.EMPTY_TABLE_IN_GET},EMPTY_REDACTION_TYPE_IN_GET:{code:400,description:Y.EMPTY_REDACTION_TYPE_IN_GET},DUPLICATE_ELEMENT:{code:400,description:Y.DUPLICATE_ELEMENT},DUPLICATE_ELEMENT_ADDITIONAL_FIELDS:{code:400,description:Y.DUPLICATE_ELEMENT_ADDITIONAL_FIELDS},MISSING_ELEMENT_TYPE:{code:400,description:Y.MISSING_ELEMENT_TYPE},EMPTY_ELEMENT_TYPE:{code:400,description:Y.EMPTY_ELEMENT_TYPE},INVALID_ELEMENT_TYPE:{code:400,description:Y.INVALID_ELEMENT_TYPE},INVALID_ELEMENT_SELECTOR:{code:400,description:Y.INVALID_ELEMENT_SELECTOR},FRAME_NOT_FOUND:{code:400,description:Y.FRAME_NOT_FOUND},REQUIRED_PARAMS_NOT_PROVIDED:{code:400,description:Y.REQUIRED_PARAMS_NOT_PROVIDED},INVALID_RECORD_COLUMN_VALUE:{code:400,description:Y.INVALID_RECORD_COLUMN_VALUE},MISSING_RECORD_COLUMN_VALUE:{code:400,description:Y.MISSING_RECORD_COLUMN_VALUE},MISSING_RECORD_COLUMN_NAME:{code:400,description:Y.MISSING_RECORD_COLUMN_NAME},INVALID_EVENT_TYPE:{code:400,description:Y.INVALID_EVENT_TYPE},INVALID_EVENT_LISTENER:{code:400,description:Y.INVALID_EVENT_LISTENER},MISSING_HANDLER_IN_EVENT_LISTENER:{code:400,description:Y.MISSING_HANDLER_IN_EVENT_LISTENER},INVALID_HANDLER_IN_EVENT_LISTENER:{code:400,description:Y.INVALID_HANDLER_IN_EVENT_LISTENER},UNKNOWN_ERROR:{code:400,description:Y.UNKNOWN_ERROR},CONNECTION_ERROR:{code:400,description:Y.CONNECTION_ERROR},NETWORK_ERROR:{code:500,description:Y.NETWORK_ERROR},COMPLETE_AND_VALID_INPUTS:{code:400,description:Y.COMPLETE_AND_VALID_INPUTS},INVALID_VALIDATIONS_TYPE:{code:400,description:Y.INVALID_VALIDATIONS_TYPE},MISSING_VALIDATION_RULE_TYPE:{code:400,description:Y.MISSING_VALIDATION_RULE_TYPE},INVALID_VALIDATION_RULE_TYPE:{code:400,description:Y.INVALID_VALIDATION_RULE_TYPE},MISSING_VALIDATION_RULE_PARAMS:{code:400,description:Y.MISSING_VALIDATION_RULE_PARAMS},INVALID_VALIDATION_RULE_PARAMS:{code:400,description:Y.INVALID_VALIDATION_RULE_PARAMS},MISSING_REGEX_IN_REGEX_MATCH_RULE:{code:400,description:Y.MISSING_REGEX_IN_REGEX_MATCH_RULE},INVALID_REGEX_IN_REGEX_MATCH_RULE:{code:400,description:Y.INVALID_REGEX_IN_REGEX_MATCH_RULE},MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE:{code:400,description:Y.MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE},MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE:{code:400,description:Y.MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE},INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE:{code:400,description:Y.INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE},ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE:{code:400,description:Y.ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE},EMPTY_ELEMENT_IN_MOUNT:{code:400,description:Y.EMPTY_ELEMENT_IN_MOUNT},INVALID_TABLE_IN_UPSERT_OPTION:{code:400,description:Y.INVALID_TABLE_IN_UPSERT_OPTION},INVALID_COLUMN_IN_UPSERT_OPTION:{code:400,description:Y.INVALID_COLUMN_IN_UPSERT_OPTION},INVALID_UPSERT_OPTION_TYPE:{code:400,description:Y.INVALID_UPSERT_OPTION_TYPE},EMPTY_UPSERT_OPTIONS_ARRAY:{code:400,description:Y.EMPTY_UPSERT_OPTIONS_ARRAY},INVALID_UPSERT_OPTION_OBJECT_TYPE:{code:400,description:Y.INVALID_UPSERT_OPTION_OBJECT_TYPE},MISSING_TABLE_IN_UPSERT_OPTION:{code:400,description:Y.MISSING_TABLE_IN_UPSERT_OPTION},MISSING_COLUMN_IN_UPSERT_OPTION:{code:400,description:Y.MISSING_COLUMN_IN_UPSERT_OPTION},INVALID_RECORD_COLUMN_VALUE_TYPE:{code:400,description:Y.INVALID_RECORD_COLUMN_VALUE_TYPE},INVALID_COLUMN_VALUES_TYPE:{code:400,description:Y.INVALID_COLUMN_VALUES_TYPE},EMPTY_RECORD_COLUMN_VALUES:{code:400,description:Y.EMPTY_RECORD_COLUMN_VALUES},EMPTY_COLUMN_VALUE:{code:400,description:Y.EMPTY_COLUMN_VALUE},MISSING_IDS_OR_COLUMN_VALUES_IN_GET:{code:400,description:Y.MISSING_IDS_OR_COLUMN_VALUES_IN_GET},SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED:{code:400,description:Y.SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED},RECORDS_KEY_NOT_FOUND_GETBYID:{code:400,description:Y.RECORDS_KEY_NOT_FOUND_GETBYID},INVALID_RECORDS_IN_GETBYID:{code:400,description:Y.INVALID_RECORDS_IN_GETBYID},EMPTY_RECORDS_GETBYID:{code:400,description:Y.EMPTY_RECORDS_GETBYID},MISSING_IDS_IN_GETBYID:{code:400,description:Y.MISSING_IDS_IN_GETBYID},INVALID_IDS_IN_GETBYID:{code:400,description:Y.INVALID_IDS_IN_GETBYID},EMPTY_IDS_IN_GETBYID:{code:400,description:Y.EMPTY_IDS_IN_GETBYID},INVALID_SKYFLOWID_TYPE_IN_GETBYID:{code:400,description:Y.INVALID_SKYFLOWID_TYPE_IN_GETBYID},MISSING_TABLE_IN_GETBYID:{code:400,description:Y.MISSING_TABLE_IN_GETBYID},INVALID_TABLE_IN_GETBYID:{code:400,description:Y.INVALID_TABLE_IN_GETBYID},MISSING_REDACTION_IN_GETBYID:{code:400,description:Y.MISSING_REDACTION_IN_GETBYID},INVALID_REDACTION_TYPE_IN_GETBYID:{code:400,description:Y.INVALID_REDACTION_TYPE_IN_GETBYID},EMPTY_SKYFLOWID_IN_GETBYID:{code:400,description:Y.EMPTY_SKYFLOWID_IN_GETBYID},EMPTY_TABLE_IN_GETBYID:{code:400,description:Y.EMPTY_TABLE_IN_GETBYID},EMPTY_REDACTION_TYPE_IN_GETBYID:{code:400,description:Y.EMPTY_REDACTION_TYPE_IN_GETBYID},MISSING_COMPOSABLE_LAYOUT_KEY:{code:400,description:Y.MISSING_COMPOSABLE_LAYOUT_KEY},EMPTY_COMPOSABLE_LAYOUT_ARRAY:{code:400,description:Y.EMPTY_COMPOSABLE_LAYOUT_ARRAY},INVALID_COMPOSABLE_LAYOUT_TYPE:{code:400,description:Y.INVALID_COMPOSABLE_LAYOUT_TYPE},NEGATIVE_VALUES_COMPOSABLE_LAYOUT:{code:400,description:Y.NEGATIVE_VALUES_COMPOSABLE_LAYOUT},MISMATCH_ELEMENT_COUNT_LAYOUT_SUM:{code:400,description:Y.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM},MISSING_COMPOSABLE_CONTAINER_OPTIONS:{code:400,description:Y.MISSING_COMPOSABLE_CONTAINER_OPTIONS},INVALID_COMPOSABLE_CONTAINER_OPTIONS:{code:400,description:Y.INVALID_COMPOSABLE_CONTAINER_OPTIONS},COMPOSABLE_CONTAINER_NOT_MOUNTED:{code:400,description:Y.COMPOSABLE_CONTAINER_NOT_MOUNTED},INVALID_BOOLEAN_OPTIONS:{code:400,description:Y.INVALID_BOOLEAN_OPTIONS},EMPTY_COLLECT_CUSTOM_FORMAT:{code:400,description:Y.EMPTY_COLLECT_CUSTOM_FORMAT},INVALID_INPUT_OPTIONS_FORMAT:{code:400,description:Y.INVALID_INPUT_OPTIONS_FORMAT},INVALID_INPUT_OPTIONS_TRANSLATION:{code:400,description:Y.INVALID_INPUT_OPTIONS_TRANSLATION}},Ve=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new Ye(Fe.RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS,[],!0);const{records:t}=e;if(!t||!Array.isArray(t))throw new Ye(Fe.INVALID_RECORDS_IN_ADDITIONAL_FIELDS,[],!0);if(0===t.length)throw new Ye(Fe.EMPTY_RECORDS_IN_ADDITIONAL_FIELDS,[],!0);t.forEach(((e,t)=>{var i,n,s,o;if(!e||!Object.prototype.hasOwnProperty.call(e,"table"))throw new Ye(Fe.MISSING_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!e.table)throw new Ye(Fe.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 Ye(Fe.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!("string"==typeof(null===(s=e.fields)||void 0===s?void 0:s.skyflowID)||(null===(o=e.fields)||void 0===o?void 0:o.skyflowID)instanceof String))throw new Ye(Fe.INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[`${t}`],!0)}if(!("string"==typeof e.table||e.table instanceof String))throw new Ye(Fe.INVALID_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"fields"))throw new Ye(Fe.MISSING_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!e.fields)throw new Ye(Fe.EMPTY_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if("object"!=typeof e.fields||Array.isArray(e.fields))throw new Ye(Fe.INVALID_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0)}))},Be=e=>{let t=!0;try{new RegExp(e)}catch(e){t=!1}return t},Ge=e=>{if(!Object.prototype.hasOwnProperty.call(e,"getBearerToken"))throw new Ye(Fe.GET_BEARER_TOKEN_IS_REQUIRED,[],!0)},je=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new Ye(Fe.MISSING_ELEMENT_TYPE,[],!0);if(!e.type)throw new Ye(Fe.EMPTY_ELEMENT_TYPE,[],!0);if(Object.prototype.hasOwnProperty.call(e,"altText")&&Ue(F.COLLECT_ALT_TEXT_DEPERECATED,De.WARN,t),Object.prototype.hasOwnProperty.call(e,"skyflowID")&&"string"!=typeof e.skyflowID)throw new Ye(Fe.INVALID_SKYFLOWID_IN_COLLECT,[],!0)},Xe=e=>{if(!e||!Array.isArray(e))throw new Ye(Fe.INVALID_UPSERT_OPTION_TYPE,[],!0);if(!e.length)throw new Ye(Fe.EMPTY_UPSERT_OPTIONS_ARRAY,[],!0);e.forEach(((e,t)=>{if(!e||"object"!=typeof e)throw new Ye(Fe.INVALID_UPSERT_OPTION_OBJECT_TYPE,[t],!0);if(!Object.prototype.hasOwnProperty.call(e,"table"))throw new Ye(Fe.MISSING_TABLE_IN_UPSERT_OPTION,[t],!0);if(!e.table||"string"!=typeof e.table||!e.table.length)throw new Ye(Fe.INVALID_TABLE_IN_UPSERT_OPTION,[t],!0);if(!Object.prototype.hasOwnProperty.call(e,"column"))throw new Ye(Fe.MISSING_COLUMN_IN_UPSERT_OPTION,[t],!0);if(!e.column||"string"!=typeof e.column||!e.column.length)throw new Ye(Fe.INVALID_COLUMN_IN_UPSERT_OPTION,[t],!0)}))},We=e=>"boolean"==typeof e;function ze(e){const t=e.split(":");return t.length>2?(t.pop(),t.pop(),t.join(":")):""}const He=(e,t,i)=>{if("string"!=typeof e)return e;if(t===Q.CARD_NUMBER){if(e=e&&e.replace(/\s/g,""),!i){const t=((e="")=>{const t=e.replace(/[\s-]/g,"");let i=ee.DEFAULT;return Object.entries(le).forEach((([e,n])=>{n.regex.test(t)&&(i=e)})),i})(e),i=t!==ee.DEFAULT&&t===ee.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 Ke(e){var t,i,n,s,o;if((null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.customElementsURL)&&(e=>{if(!e||"https"!==e.substring(0,5).toLowerCase())return!1;try{if(new URL(e))return!0}catch(e){return!1}return!0})(null===(i=null==e?void 0:e.options)||void 0===i?void 0:i.customElementsURL)){const t=null===(n=null==e?void 0:e.options)||void 0===n?void 0:n.customElementsURL,i=new URL(t),o=`${i.protocol}//${i.hostname}`;pe.IFRAME_SECURE_ORGIN=o,pe.IFRAME_SECURE_SITE=null===(s=null==e?void 0:e.options)||void 0===s?void 0:s.customElementsURL}if(null===(o=e.options)||void 0===o?void 0:o.deserializedData.usePayrailsFrames){if(!pe.IFRAME_SECURE_ORGIN||!pe.IFRAME_SECURE_SITE){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CARD_FORM_IFRAME_NOT_FOUND);throw a.PayrailsLogger.error(e.message,{error:e,extra:{IFRAME_SECURE_ORGIN:pe.IFRAME_SECURE_ORGIN,IFRAME_SECURE_SITE:pe.IFRAME_SECURE_SITE}}),e}pe.IFRAME_SECURE_ORGIN=ve,pe.IFRAME_SECURE_SITE=fe}}class $e{constructor(e,t,i,n){this.setAttributess=e=>{Ne(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 Ye(Fe.INVALID_ELEMENT_SELECTOR,[],!0)}else{if(!(e instanceof HTMLElement))throw new Ye(Fe.INVALID_ELEMENT_SELECTOR,[],!0);this.container=e}}catch(e){console.error(e)}Ne(this.iframe,{src:ye()}),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=Te({name:this.name})}}class qe{}var Je,Ze,Qe,et,tt,it,nt,st,ot,rt,at,lt,dt,ct,ut,Et,_t,ht,It,pt;const ft="Element";class vt extends qe{constructor(e,t,s,o,r=!1,a,l,d,c){var u;super(),this.type=Ci.COLLECT,Je.set(this,void 0),Ze.set(this,!1),Qe.set(this,void 0),et.set(this,void 0),tt.set(this,{isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:void 0,isRequired:!1}),it.set(this,void 0),nt.set(this,new Ie),st.set(this,void 0),ot.set(this,k.getEventBus()),rt.set(this,void 0),at.set(this,[]),lt.set(this,!1),dt.set(this,void 0),ct.set(this,void 0),ut.set(this,!1),this.getID=()=>i(this,Je,"f"),this.mount=e=>{var t;if(!e)throw new Ye(Fe.EMPTY_ELEMENT_IN_MOUNT,["CollectElement"],!0);const s=(e,t)=>{if(e.name===i(this,rt,"f").name){t(i(this,it,"f")),i(this,pt,"f").call(this);const e=function(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(i[n[s]]=e[n[s]])}return i}(i(this,Qe,"f")[0],["name"]);i(this,et,"f").length>1?i(this,et,"f").forEach(((e,t)=>{i(this,st,"f")&&i(this,st,"f")._emit(`${G.READY}:${e.elementName}`,Object.assign(Object.assign({},i(this,Qe,"f")[t]),{elementType:e.elementType}))})):i(this,nt,"f")._emit(G.READY,Object.assign({},e)),i(this,ot,"f").off(j+this.containerId,s),Ue(`${ke(x.ELEMENT_MOUNTED,ft,xe(i(this,rt,"f").name))} `,De.LOG,i(this,dt,"f").logLevel),i(this,at,"f").forEach((e=>e())),n(this,at,[],"f")}};if(i(this,et,"f").length>1)i(this,rt,"f").mount(e),i(this,ot,"f").on(j+this.containerId,s);else{if(i(this,ut,"f"))return i(this,rt,"f").mount(e),void i(this,ot,"f").on(j+this.containerId,s);null===(t=i(this,st,"f"))||void 0===t||t.on(Z,(t=>{(null==t?void 0:t.containerId)===this.containerId&&(i(this,rt,"f").mount(e),i(this,ot,"f").on(j+this.containerId,s))}))}},this.unmount=()=>{i(this,rt,"f").unmount()},this.update=e=>{let t=Ae(e);const s=()=>{i(this,Ze,"f")&&(t={rows:[{elements:[Object.assign({},t)]}]}),n(this,it,Nt(i(this,it,"f"),t),"f"),n(this,et,Tt(i(this,it,"f")),"f"),i(this,Ze,"f")?i(this,ot,"f").emit(H,{name:i(this,rt,"f").name,options:i(this,et,"f")[0],isSingleElementAPI:!0}):(i(this,et,"f").forEach((e=>{i(this,ot,"f").emit(H,{name:e.elementName,options:e,isSingleElementAPI:!0})})),i(this,ot,"f").emit(H,{name:i(this,rt,"f").name,options:i(this,it,"f"),isSingleElementAPI:!1})),i(this,pt,"f").call(this)};i(this,lt,"f")?s():i(this,at,"f").push(s)},Et.set(this,(e=>{i(this,Ze,"f")||i(this,nt,"f").on(H,(()=>{e(i(this,et,"f"))}),!0)})),this.updateElement=e=>{i(this,ot,"f").emit(H,{name:e.elementName,options:e,isSingleElementAPI:!0})},_t.set(this,(()=>{i(this,Qe,"f").forEach(((e,t)=>{if(0===t){i(this,tt,"f").isEmpty=e.isEmpty,i(this,tt,"f").isComplete=e.isComplete,i(this,tt,"f").isValid=e.isValid,i(this,tt,"f").isFocused=e.isFocused,i(this,tt,"f").isRequired=e.isRequired,i(this,tt,"f").value={};const n=i(this,et,"f")[t].elementName,s=e.value&&He(e.value,e.elementType,i(this,ct,"f"));i(this,Ze,"f")?i(this,tt,"f").value=s:i(this,tt,"f").value[n]=s}else i(this,tt,"f").isEmpty=i(this,tt,"f").isEmpty||e.isEmpty,i(this,tt,"f").isComplete=i(this,tt,"f").isComplete&&e.isComplete,i(this,tt,"f").isValid=i(this,tt,"f").isValid&&e.isValid,i(this,tt,"f").isFocused=i(this,tt,"f").isFocused||e.isFocused,i(this,tt,"f").isRequired=i(this,tt,"f").isRequired||e.isRequired,i(this,tt,"f").value||(i(this,tt,"f").value={}),i(this,et,"f")[t].sensitive||(i(this,tt,"f").value[i(this,et,"f")[t].elementName]=e.value||"")}))})),this.getState=()=>({isEmpty:i(this,tt,"f").isEmpty,isComplete:i(this,tt,"f").isComplete,isValid:i(this,tt,"f").isValid,isFocused:i(this,tt,"f").isFocused,value:i(this,tt,"f").value,required:i(this,tt,"f").isRequired}),this.getOptions=()=>{let e=Ae(i(this,it,"f"));return i(this,Ze,"f")?e=e.rows[0].elements[0]:e.rows.forEach((e=>{e.elements.forEach((e=>{delete e.elementName}))})),delete e.elementName,e},ht.set(this,(e=>{i(this,nt,"f").on(z,(()=>{const t=i(this,et,"f").map((e=>e.elementName));i(this,Ze,"f")||t.push(i(this,rt,"f").name),e(t)}),!0)})),It.set(this,(()=>{i(this,ot,"f").on(W,(e=>{if(i(this,Ze,"f")&&e.event===G.READY&&e.name===i(this,rt,"f").name)i(this,nt,"f")._emit(G.READY);else{const t=i(this,et,"f").length>1;i(this,et,"f").forEach(((n,s)=>{var o;if(e.name===n.elementName){let r="";switch(e.event){case G.FOCUS:r=G.FOCUS;break;case G.BLUR:r=G.BLUR;break;case G.CHANGE:r=G.CHANGE;break;case G.READY:r=G.READY;break;case G.SUBMIT:return void(null===(o=i(this,st,"f"))||void 0===o||o._emit(G.SUBMIT));default:throw new Ye(Fe.INVALID_EVENT_TYPE,[],!0)}i(this,Qe,"f")[s].isEmpty=e.value.isEmpty,i(this,Qe,"f")[s].isValid=e.value.isValid,i(this,Qe,"f")[s].isComplete=e.value.isComplete,i(this,Qe,"f")[s].isFocused=e.value.isFocused,i(this,Qe,"f")[s].isRequired=e.value.isRequired,Object.prototype.hasOwnProperty.call(e.value,"value")?i(this,Qe,"f")[s].value=e.value.value:i(this,Qe,"f")[s].value=void 0,r=t?`${r}:${e.name}`:r,i(this,ot,"f").emit(G.HEIGHT+i(this,rt,"f").name,{},(e=>{i(this,rt,"f").setIframeHeight(e.height)})),i(this,_t,"f").call(this);const a=Object.assign(Object.assign({},i(this,Qe,"f")[s]),{elementType:n.elementType});t&&i(this,st,"f")?i(this,st,"f")._emit(r,a):i(this,nt,"f")._emit(r,a)}}))}}))})),pt.set(this,(()=>{const{rows:e}=i(this,it,"f");e.forEach((e=>{e.elements.forEach((e=>{e.elementType!==ie.radio.name&&e.elementType!==ie.checkbox.name&&(e.value=void 0)}))})),n(this,et,Tt(i(this,it,"f")),"f")})),this.containerId=o.containerId,n(this,Je,e,"f"),n(this,dt,d,"f"),n(this,it,Nt(t),"f"),n(this,et,Tt(t),"f"),n(this,Ze,r,"f"),c&&n(this,st,c,"f"),n(this,ct,Me[i(this,dt,"f").env].doesReturnValue,"f"),this.elementType=i(this,Ze,"f")?i(this,et,"f")[0].elementType:"group",n(this,Qe,[],"f"),i(this,et,"f").forEach((e=>{i(this,Qe,"f").push({isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:i(this,ct,"f")?"":void 0,elementType:e.elementType,name:e.elementName,isRequired:!1})})),n(this,rt,new $e(i(this,it,"f").elementName,s,this.containerId,i(this,dt,"f").logLevel),"f"),i(this,It,"f").call(this),i(this,ht,"f").call(this,a),i(this,Et,"f").call(this,l),Ue(ke(x.CREATED_ELEMENT,ft,xe(i(this,rt,"f").name)),De.LOG,i(this,dt,"f").logLevel),n(this,ut,o.isMounted,"f"),null===(u=i(this,st,"f"))||void 0===u||u.on(Z,(e=>{(null==e?void 0:e.containerId)===this.containerId&&n(this,ut,!0,"f")})),i(this,ot,"f").on(G.MOUNTED,(e=>{o.type===Ci.COMPOSABLE?i(this,et,"f").forEach((t=>{e.name===t.elementName&&(t.isMounted=!0,n(this,lt,!0,"f"))})):e.name===i(this,et,"f")[0].elementName&&(i(this,et,"f")[0].isMounted=!0,n(this,lt,!0,"f")),i(this,ot,"f").emit(G.HEIGHT+i(this,rt,"f").name,{},(e=>{i(this,rt,"f").setIframeHeight(e.height)}))}))}on(e,t){if(!Object.values(G).includes(e))throw new Ye(Fe.INVALID_EVENT_LISTENER,[],!0);if(!t)throw new Ye(Fe.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof t)throw new Ye(Fe.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);i(this,nt,"f").on(e,(e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,t(e)}))}iframeName(){return i(this,rt,"f").name}isMounted(){return i(this,lt,"f")}isValidElement(){for(let e=0;e<i(this,et,"f").length;e+=1){if(!Object.prototype.hasOwnProperty.call(i(this,et,"f")[e],"table"))throw new Ye(Fe.MISSING_TABLE_IN_COLLECT,[],!0);if(!i(this,et,"f")[e].table)throw new Ye(Fe.EMPTY_TABLE_IN_COLLECT,[],!0);if(!("string"==typeof i(this,et,"f")[e].table||i(this,et,"f")[e].table instanceof String))throw new Ye(Fe.INVALID_TABLE_IN_COLLECT,[],!0);if(!Object.prototype.hasOwnProperty.call(i(this,et,"f")[e],"column"))throw new Ye(Fe.MISSING_COLUMN_IN_COLLECT,[],!0);if(!i(this,et,"f")[e].column)throw new Ye(Fe.EMPTY_COLUMN_IN_COLLECT,[],!0);if(!("string"==typeof i(this,et,"f")[e].column||i(this,et,"f")[e].column instanceof String))throw new Ye(Fe.INVALID_COLUMN_IN_COLLECT,[],!0);if(void 0!==i(this,et,"f")[e].skyflowID&&!i(this,et,"f")[e].skyflowID)throw new Ye(Fe.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[],!0)}return!0}setError(e){i(this,ot,"f").emit($,{name:ze(i(this,rt,"f").name),isTriggerError:!0,clientErrorText:e})}resetError(){i(this,ot,"f").emit($,{name:ze(i(this,rt,"f").name),isTriggerError:!1})}setValue(e){i(this,dt,"f").env!==Ce.PROD?i(this,Ze,"f")&&i(this,ot,"f").emit(H,{name:i(this,rt,"f").name,options:Object.assign(Object.assign({},i(this,et,"f")[0]),{value:e}),isSingleElementAPI:!0}):Ue(ke(F.UNABLE_TO_SET_VALUE_IN_PROD_ENV,i(this,et,"f")[0].elementType),De.WARN,i(this,dt,"f").logLevel)}clearValue(){i(this,dt,"f").env!==Ce.PROD?i(this,Ze,"f")&&i(this,ot,"f").emit(H,{name:i(this,rt,"f").name,options:Object.assign(Object.assign({},i(this,et,"f")[0]),{value:""}),isSingleElementAPI:!0}):Ue(ke(F.UNABLE_TO_CLEAR_VALUE_IN_PROD_ENV,i(this,et,"f")[0].elementType),De.WARN,i(this,dt,"f").logLevel)}}function mt(e,t,i={}){if("group"!==e&&!Object.prototype.hasOwnProperty.call(ie,e))throw new Ye(Fe.INVALID_ELEMENT_TYPE,[],!0);if(Object.prototype.hasOwnProperty.call(t,"validations")){if(!Array.isArray(t.validations))throw new Ye(Fe.INVALID_VALIDATIONS_TYPE,[],!0);t.validations.forEach(((e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new Ye(Fe.MISSING_VALIDATION_RULE_TYPE,[`${t}`],!0);if(!Object.values(be).includes(e.type))throw new Ye(Fe.INVALID_VALIDATION_RULE_TYPE,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"params"))throw new Ye(Fe.MISSING_VALIDATION_RULE_PARAMS,[`${t}`],!0);if("object"!=typeof e.params||Array.isArray(e.params)||null===e.params)throw new Ye(Fe.INVALID_VALIDATION_RULE_PARAMS,[`${t}`],!0);if(e.type===be.REGEX_MATCH_RULE){if(!Object.prototype.hasOwnProperty.call(e.params,"regex"))throw new Ye(Fe.MISSING_REGEX_IN_REGEX_MATCH_RULE,[`${t}`],!0)}else if(e.type===be.LENGTH_MATCH_RULE&&!Object.prototype.hasOwnProperty.call(e.params,"min")&&!Object.prototype.hasOwnProperty.call(e.params,"max"))throw new Ye(Fe.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}=ie[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===ie.radio.name||e===ie.checkbox.name)&&!i.value)throw new Error("Elements radio and checkbox requires value attribute");if(!(e!==ie.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 Nt(e,t={},i=!0){return(t=Object.assign(Object.assign({},e),t)).rows.forEach(((n,s)=>{const o=n,r=e.rows[s];t.rows[s]=Object.assign(Object.assign({},r),o),o.elements.forEach(((e,t)=>{var n,s;const a=r.elements[t],l=e;if(l.elementType&&a.elementType!==l.elementType&&a.elementName&&a.elementName!==l.elementName)throw new Error(Y.CANNOT_CHANGE_ELEMENT);mt(a.elementType,a,l),o.elements[t]=Object.assign(Object.assign(Object.assign({},a),l),{elementName:a.elementName});const d=l.classes||{},c=l.styles||{};c.base=Object.assign(Object.assign({},re),c.base),l.classes=d,l.styles=c;const u=(null===(n=null==l?void 0:l.labelStyles)||void 0===n?void 0:n.classes)||{},E=(null===(s=null==l?void 0:l.labelStyles)||void 0===s?void 0:s.styles)||{};i&&function(e,t){Object.values(ae).forEach((i=>{if(e[i]||t[i])switch(i){case ae.BASE:t[i]=Object.assign({},t[i]);break;case ae.FOCUS:t[ae.BASE]=Object.assign(Object.assign({},t[ae.BASE]),{":focus":Object.assign({},t[ae.BASE]&&t[ae.BASE][":focus"])});break;case ae.WEBPACKAUTOFILL:t[ae.BASE]=Object.assign(Object.assign({},t[ae.BASE]),{":-webkit-autofill":Object.assign({},t[ae.BASE]&&t[ae.BASE][":-webkit-autofill"])});break;default:t[i]=Object.assign(Object.assign({},t[ae.BASE]),t[i])}})),Object.keys(t).forEach((e=>{const i=t[e][":-webkit-autofill"];"object"==typeof i&&Object.keys(i).forEach((e=>{i[e]&&!i[e].includes("!important")&&(i[e]=`${i[e]} !important`)}))}))}(u,E),l.labelStyles={labelClasses:u},l.labelStyles.styles=E}))})),t}Je=new WeakMap,Ze=new WeakMap,Qe=new WeakMap,et=new WeakMap,tt=new WeakMap,it=new WeakMap,nt=new WeakMap,st=new WeakMap,ot=new WeakMap,rt=new WeakMap,at=new WeakMap,lt=new WeakMap,dt=new WeakMap,ct=new WeakMap,ut=new WeakMap,Et=new WeakMap,_t=new WeakMap,ht=new WeakMap,It=new WeakMap,pt=new WeakMap;const Tt=e=>{const{rows:t}=e,i=[];return t.forEach((e=>{e.elements.forEach((e=>{i.push(e)}))})),i},yt=e=>{const t=e.validations;return t&&Array.isArray(t)&&t.length>0&&t.forEach(((e,t)=>{if(e&&e.type===be.ELEMENT_VALUE_MATCH_RULE){if(e.params&&!Object.prototype.hasOwnProperty.call(e.params,"element"))throw new Ye(Fe.MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE,[`${t}`],!0);if(e.params&&(null==e.params.element||!(e.params.element instanceof vt)))throw new Ye(Fe.INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE,[`${t}`],!0);e.params&&e.params.element&&e.params.element instanceof vt&&(e.params.element=e.params.element.iframeName())}else if(e&&e.type===be.REGEX_MATCH_RULE){if(e.params&&e.params.regex&&!Be(e.params.regex))throw new Ye(Fe.INVALID_REGEX_IN_REGEX_MATCH_RULE,[`${t}`],!0);e.params&&e.params.regex&&Be(e.params.regex)&&(e.params.regex=e.params.regex.toString())}})),t},Ot=(e,t,i)=>{let n=Object.assign({required:!1},t);if((Object.prototype.hasOwnProperty.call(n,"format")||Object.prototype.hasOwnProperty.call(n,"translation"))&&(_e.includes(e)?(Ue(ke(F.INPUT_FORMATTING_NOT_SUPPROTED,e),De.WARN,i),null==n||delete n.format,null==n||delete n.translation):e===ie.INPUT_FIELD.name&&((e=>{if(e){if(Object.prototype.hasOwnProperty.call(e,"format")&&"string"!=typeof e.format)throw new Ye(Fe.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 Ye(Fe.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===ie.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)===ne&&(e="-"),n=Object.assign(Object.assign({},n),{cardSeperator:e}),null==n||delete n.format,null==n||delete n.translation}else if(e===ie.EXPIRATION_DATE.name){let e=!1;n.format&&(e=!!(s=n.format.toUpperCase())&&ce.includes(s),e||Ue(ke(F.INVALID_EXPIRATION_DATE_FORMAT,ce.toString()),De.WARN,i)),n=Object.assign(Object.assign({},n),{format:e?n.format.toUpperCase():de}),null==n||delete n.translation}else if(e===ie.EXPIRATION_YEAR.name){let e=!1;n.format&&(e=(e=>!!e&&ue.includes(e))(n.format.toUpperCase()),e||Ue(ke(F.INVALID_EXPIRATION_YEAR_FORMAT,ue.toString()),De.WARN,i)),n=Object.assign(Object.assign({},n),{format:e?n.format.toUpperCase():"YY"}),null==n||delete n.translation}var s;if(Object.prototype.hasOwnProperty.call(n,"enableCardIcon")&&!We(n.enableCardIcon))throw new Ye(Fe.INVALID_BOOLEAN_OPTIONS,["enableCardIcon"],!0);if(Object.prototype.hasOwnProperty.call(n,"enableCopy")&&!We(n.enableCopy))throw new Ye(Fe.INVALID_BOOLEAN_OPTIONS,["enableCopy"],!0);if(Object.prototype.hasOwnProperty.call(n,"required")&&!We(n.required))throw new Ye(Fe.INVALID_BOOLEAN_OPTIONS,["required"],!0);return n};function At(){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 Lt{}var gt,Rt,St,Ct,Dt,bt,Pt,Mt,wt,Ut,kt,xt;const Yt="CollectContainer";class Ft extends Lt{constructor(e,t,s,o){super(),gt.set(this,void 0),Rt.set(this,{}),St.set(this,void 0),Ct.set(this,void 0),Dt.set(this,void 0),this.type=Ci.COLLECT,bt.set(this,void 0),Pt.set(this,!1),this.create=(e,t={required:!1})=>{je(e,i(this,Ct,"f").logLevel);const n=yt(e),s=Ot(e.type,t,i(this,Ct,"f").logLevel),o={rows:[{elements:[Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column,accept:t.allowedFileType},e),s),{validations:n})]}]};return i(this,Mt,"f").call(this,o,!0)},Mt.set(this,((e,t=!1)=>{const n=[],s=Ae(e);if(s.rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;mt(i,t),t.sensitive=t.sensitive||ie[i].sensitive,t.replacePattern=t.replacePattern||ie[i].replacePattern,t.mask=t.mask||ie[i].mask,t.isMounted=!1,t.elementType!==ie.radio.name&&t.elementType!==ie.checkbox.name||(t.elementName=`${t.elementName}:${btoa(t.value)}`),t.elementName=`${B}:${t.elementType}:${btoa(At())}`,t.label=e.label,t.skyflowID=e.skyflowID,n.push(t)}))})),s.elementName=t?n[0].elementName:`${B}:group:${btoa(s.name)}`,t&&!i(this,Rt,"f")[n[0].elementName]&&i(this,xt,"f").call(this,n[0].name))throw new Ye(Fe.UNIQUE_ELEMENT_NAME,[`${n[0].name}`],!0);let o=i(this,Rt,"f")[s.elementName];if(o)t?o.update(n[0]):o.update(s);else{const e=At();o=new vt(e,s,i(this,St,"f"),{containerId:i(this,gt,"f"),isMounted:i(this,Pt,"f"),type:this.type},t,i(this,Ut,"f"),i(this,kt,"f"),i(this,Ct,"f"),i(this,bt,"f")),i(this,Rt,"f")[s.elementName]=o,i(this,Dt,"f")[e]=o}return t||n.forEach((e=>{const t=e.elementName;i(this,Rt,"f")[t]?i(this,Rt,"f")[t].update(e):i(this,Rt,"f")[t]=this.create(e.elementType,o)})),o})),wt.set(this,(e=>{Object.keys(i(this,Rt,"f")).forEach((t=>{t===e&&delete i(this,Rt,"f")[t]}))})),Ut.set(this,(e=>{e.forEach((e=>{i(this,wt,"f").call(this,e)}))})),kt.set(this,(e=>{e.forEach((e=>{i(this,Rt,"f")[e.elementName]&&i(this,Rt,"f")[e.elementName].update(e)}))})),xt.set(this,(e=>{const t=Object.keys(i(this,Rt,"f"));for(let i=0;i<t.length;i+=1)if(atob(t[i].split(":")[2])===e)return!0;return!1})),this.collect=(e={tokens:!0})=>new Promise(((t,n)=>{try{if(Ge(i(this,St,"f").clientJSON.config),Object.values(i(this,Rt,"f")).forEach((e=>{if(!e.isMounted())throw new Ye(Fe.ELEMENTS_NOT_MOUNTED,[],!0);e.isValidElement()})),Object.prototype.hasOwnProperty.call(e,"tokens")&&!We(e.tokens))throw new Ye(Fe.INVALID_TOKENS_IN_COLLECT,[],!0);(null==e?void 0:e.additionalFields)&&Ve(e.additionalFields),(null==e?void 0:e.upsert)&&Xe(null==e?void 0:e.upsert),this.bus.emit(X+i(this,gt,"f"),Object.assign(Object.assign({},e),{tokens:void 0===(null==e?void 0:e.tokens)||e.tokens}),(e=>{!e||(null==e?void 0:e.error)?(Ue(`${JSON.stringify(null==e?void 0:e.error)}`,De.ERROR,i(this,Ct,"f").logLevel),n(null==e?void 0:e.error)):(Ue(ke(x.COLLECT_SUBMIT_SUCCESS,Yt),De.LOG,i(this,Ct,"f").logLevel),t(e))})),Ue(ke(x.EMIT_EVENT,Yt,X),De.LOG,i(this,Ct,"f").logLevel)}catch(e){Ue(`${e.message}`,De.ERROR,i(this,Ct,"f").logLevel),n(e)}})),this.unmount=()=>{this.iframe.remove()},this.bus=k.getEventBus(),n(this,gt,At(),"f"),n(this,St,t,"f"),n(this,Dt,s,"f"),n(this,Ct,o,"f"),n(this,bt,new Ie,"f"),this.iframe=Te({name:`${V}:${i(this,gt,"f")}:${i(this,Ct,"f").logLevel}`}),Ne(this.iframe,{src:ye()}),Oe(this.iframe,Object.assign({},oe)),Ue(ke(x.CREATE_COLLECT_CONTAINER,Yt),De.LOG,i(this,Ct,"f").logLevel);const r=(e,s)=>{e.name===V+i(this,gt,"f")&&(s(Object.assign(Object.assign({},t),{clientJSON:Object.assign(Object.assign({},t.clientJSON),{config:Object.assign({},t.clientJSON.config)}),context:o})),n(this,Pt,!0,"f"),i(this,bt,"f")._emit(Z,{containerId:i(this,gt,"f")}),this.bus.target({origin:pe.IFRAME_SECURE_ORGIN}).off(j+i(this,gt,"f"),r))};this.bus.target({origin:pe.IFRAME_SECURE_ORGIN}).on(j+i(this,gt,"f"),r),document.body.append(this.iframe)}}gt=new WeakMap,Rt=new WeakMap,St=new WeakMap,Ct=new WeakMap,Dt=new WeakMap,bt=new WeakMap,Pt=new WeakMap,Mt=new WeakMap,wt=new WeakMap,Ut=new WeakMap,kt=new WeakMap,xt=new WeakMap;var Vt,Bt,Gt,jt,Xt,Wt,zt,Ht,Kt,$t,qt,Jt,Zt,Qt,ei,ti,ii,ni,si,oi,ri,ai,li,di=function(e,t){for(var i,n=-1,s=e.length;++n<s;){var o=t(e[n]);void 0!==o&&(i=void 0===i?o:i+o)}return i},ci=function(e){return e},ui=o((function(e){return e&&e.length?di(e,ci):0}));class Ei{constructor(e,t){Vt.set(this,void 0),Bt.set(this,void 0),this.type=Ci.COMPOSABLE,Gt.set(this,!1),jt.set(this,!1),this.update=e=>{n(this,jt,!0,"f"),i(this,Gt,"f")?(i(this,Bt,"f")._emit(q,{elementName:i(this,Vt,"f"),elementOptions:e}),n(this,jt,!1,"f")):i(this,jt,"f")&&i(this,Bt,"f").on(`${Re.READY}:${i(this,Vt,"f")}`,(()=>{i(this,Bt,"f")._emit(q,{elementName:i(this,Vt,"f"),elementOptions:e}),n(this,Gt,!0,"f"),n(this,jt,!1,"f")}))},n(this,Vt,e,"f"),n(this,Bt,t,"f"),i(this,Bt,"f").on(`${Re.READY}:${i(this,Vt,"f")}`,(()=>{n(this,Gt,!0,"f")}))}on(e,t){if(!Object.values(G).includes(e))throw new Ye(Fe.INVALID_EVENT_LISTENER,[],!0);if(!t)throw new Ye(Fe.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof t)throw new Ye(Fe.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);i(this,Bt,"f").on(`${e}:${i(this,Vt,"f")}`,(e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,t(e)}))}}Vt=new WeakMap,Bt=new WeakMap,Gt=new WeakMap,jt=new WeakMap;const _i="CollectContainer";class hi extends Lt{constructor(e,t,s,o){super(),Xt.set(this,void 0),Wt.set(this,{}),zt.set(this,void 0),Ht.set(this,{rows:[]}),Kt.set(this,[]),$t.set(this,void 0),qt.set(this,void 0),Jt.set(this,void 0),Zt.set(this,!1),Qt.set(this,void 0),ei.set(this,void 0),this.type=Ci.COMPOSABLE,ti.set(this,!1),ii.set(this,{}),this.create=(e,t={required:!1})=>{je(e,i(this,$t,"f").logLevel);const n=yt(e),s=Ot(e.type,t,i(this,$t,"f").logLevel),o=`${B}:${e.type}:${btoa(At())}`;return i(this,Kt,"f").push(Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column},e),s),{validations:n,elementName:o})),new Ei(o,i(this,Jt,"f"))},ni.set(this,((e,t=!1)=>{const s=[];if(n(this,ii,Ae(e),"f"),i(this,ii,"f").rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;mt(i,t),t.sensitive=t.sensitive||ie[i].sensitive,t.replacePattern=t.replacePattern||ie[i].replacePattern,t.mask=t.mask||ie[i].mask,t.isMounted=!1,t.label=e.label,t.skyflowID=e.skyflowID,s.push(t)}))})),i(this,ii,"f").elementName=t?s[0].elementName:`${B}:group:${btoa(i(this,ii,"f").name)}`,t&&!i(this,Wt,"f")[s[0].elementName]&&i(this,ai,"f").call(this,s[0].name))throw new Ye(Fe.UNIQUE_ELEMENT_NAME,[`${s[0].name}`],!0);let o=i(this,Wt,"f")[i(this,ii,"f").elementName];if(o)t?o.update(s[0]):o.update(i(this,ii,"f"));else{const e=At();o=new vt(e,i(this,ii,"f"),i(this,zt,"f"),{containerId:i(this,Xt,"f"),isMounted:i(this,ti,"f"),type:this.type},!0,i(this,oi,"f"),i(this,ri,"f"),i(this,$t,"f"),i(this,Jt,"f")),i(this,Wt,"f")[i(this,ii,"f").elementName]=o,i(this,qt,"f")[e]=o}return o})),si.set(this,(e=>{Object.keys(i(this,Wt,"f")).forEach((t=>{t===e&&delete i(this,Wt,"f")[t]}))})),oi.set(this,(e=>{e.forEach((e=>{i(this,si,"f").call(this,e)}))})),ri.set(this,(e=>{e.forEach((e=>{i(this,Wt,"f")[e.elementName]&&i(this,Wt,"f")[e.elementName].update(e)}))})),ai.set(this,(e=>{const t=Object.keys(i(this,Wt,"f"));for(let i=0;i<t.length;i+=1)if(atob(t[i].split(":")[2])===e)return!0;return!1})),this.on=(e,t)=>{if(!Object.values(G).includes(e))throw new Ye(Fe.INVALID_EVENT_LISTENER,[],!0);if(!t)throw new Ye(Fe.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof t)throw new Ye(Fe.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);i(this,Jt,"f").on(G.SUBMIT,(()=>{t()}))},this.mount=e=>{if(!e)throw new Ye(Fe.EMPTY_ELEMENT_IN_MOUNT,["CollectElement"],!0);const{layout:t}=i(this,Qt,"f");if(ui(t)!==i(this,Kt,"f").length)throw new Ye(Fe.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM,[],!0);let s=0;if(t.forEach(((e,t)=>{i(this,Ht,"f").rows=[...i(this,Ht,"f").rows,{elements:[]}];for(let n=0;n<e;n++)i(this,Ht,"f").rows[t].elements.push(i(this,Kt,"f")[s]),s++})),i(this,Qt,"f").styles&&(i(this,Ht,"f").styles=Object.assign({},i(this,Qt,"f").styles)),i(this,Qt,"f").errorTextStyles&&(i(this,Ht,"f").errorTextStyles=Object.assign({},i(this,Qt,"f").errorTextStyles)),i(this,ti,"f"))return n(this,ei,i(this,ni,"f").call(this,i(this,Ht,"f"),!1),"f"),i(this,ei,"f").mount(e),void n(this,Zt,!0,"f");i(this,Jt,"f").on(J+i(this,Xt,"f"),(()=>{n(this,ei,i(this,ni,"f").call(this,i(this,Ht,"f"),!1),"f"),i(this,ei,"f").mount(e),n(this,Zt,!0,"f")}))},this.unmount=()=>{i(this,ei,"f").unmount(),this.iframe.remove()},this.collect=(e={tokens:!0})=>new Promise(((t,n)=>{try{if(Ge(i(this,zt,"f").clientJSON.config),!i(this,Zt,"f")){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);throw a.PayrailsLogger.error(e.message,{error:e}),e}if(Tt(i(this,ii,"f")).forEach((e=>{if(!(null==e?void 0:e.isMounted))throw new Ye(Fe.ELEMENTS_NOT_MOUNTED,[],!0)})),Object.values(i(this,Wt,"f")).forEach((e=>{e.isValidElement()})),e&&e.tokens&&"boolean"!=typeof e.tokens)throw new Ye(Fe.INVALID_TOKENS_IN_COLLECT,[],!0);(null==e?void 0:e.additionalFields)&&Ve(e.additionalFields),(null==e?void 0:e.upsert)&&Xe(null==e?void 0:e.upsert),this.bus.emit(X+i(this,Xt,"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)?(Ue(`${JSON.stringify(null==e?void 0:e.error)}`,De.ERROR,i(this,$t,"f").logLevel),n(null==e?void 0:e.error)):(Ue(ke(x.COLLECT_SUBMIT_SUCCESS,_i),De.LOG,i(this,$t,"f").logLevel),t(e))})),Ue(ke(x.EMIT_EVENT,_i,X),De.LOG,i(this,$t,"f").logLevel)}catch(e){Ue(`${e.message}`,De.ERROR,i(this,$t,"f").logLevel),n(e)}})),li.set(this,(()=>{i(this,Jt,"f").on(q,(e=>{let t;const n=i(this,Kt,"f").map(((i,n)=>i.elementName===e.elementName?(t=n,Object.assign({elementName:i.elementName},e.elementOptions)):i));i(this,ei,"f")&&i(this,ei,"f").updateElement(Object.assign({},n[t]))}))})),this.bus=k.getEventBus(),n(this,Xt,At(),"f"),n(this,zt,t,"f"),n(this,qt,s,"f"),n(this,$t,o,"f"),n(this,Qt,e,"f"),n(this,Jt,new Ie,"f"),this.iframe=Te({name:`${V}:${i(this,Xt,"f")}:${i(this,$t,"f").logLevel}`}),Ne(this.iframe,{src:ye()}),Oe(this.iframe,Object.assign({},oe)),Ue(ke(x.CREATE_COLLECT_CONTAINER,_i),De.LOG,i(this,$t,"f").logLevel);const l=(e,s)=>{e.name===V+i(this,Xt,"f")&&(s(Object.assign(Object.assign({},t),{clientJSON:Object.assign(Object.assign({},t.clientJSON),{config:Object.assign({},t.clientJSON.config)}),context:o})),n(this,ti,!0,"f"),i(this,Jt,"f")._emit(J+i(this,Xt,"f"),{containerId:i(this,Xt,"f")}),this.bus.target({origin:pe.IFRAME_SECURE_ORGIN}).off(j+i(this,Xt,"f"),l))};this.bus.target({origin:pe.IFRAME_SECURE_ORGIN}).on(j+i(this,Xt,"f"),l),document.body.append(this.iframe),i(this,li,"f").call(this)}}function Ii(e){this.message=e}Xt=new WeakMap,Wt=new WeakMap,zt=new WeakMap,Ht=new WeakMap,Kt=new WeakMap,$t=new WeakMap,qt=new WeakMap,Jt=new WeakMap,Zt=new WeakMap,Qt=new WeakMap,ei=new WeakMap,ti=new WeakMap,ii=new WeakMap,ni=new WeakMap,si=new WeakMap,oi=new WeakMap,ri=new WeakMap,ai=new WeakMap,li=new WeakMap,Ii.prototype=new Error,Ii.prototype.name="InvalidCharacterError";var pi="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new Ii("'atob' failed: The string to be decoded is not correctly encoded.");for(var i,n,s=0,o=0,r="";n=t.charAt(o++);~n&&(i=s%4?64*i+n:n,s++%4)?r+=String.fromCharCode(255&i>>(-2*s&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return r};function fi(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(pi(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 pi(t)}}function vi(e){this.message=e}vi.prototype=new Error,vi.prototype.name="InvalidTokenError";const mi=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 vi("Invalid token specified");var i=!0===(t=t||{}).header?0:1;try{return JSON.parse(fi(e.split(".")[i]))}catch(e){throw new vi("Invalid token specified: "+e.message)}}(e),s=(new Date).getTime()/1e3,o=n.exp;return o&&s>o&&(i=!0),!i}catch(e){return!1}var t};var Ni,Ti,yi,Oi,Ai,Li,gi,Ri,Si,Ci,Di={name:"skyflow-js",preferGlobal:!0,analyze:!1,version:"1.30.1",author:"Skyflow",description:"Skyflow JavaScript SDK"};class bi{constructor(e,t){Ni.set(this,void 0),this.request=e=>new Promise(((t,n)=>{var s,o,r,a;const l=new XMLHttpRequest;if(l){if(l.open(e.requestMethod,e.url),e.headers){const t=function(e,t,i){var n,s,o,r,a;const l={sdkName:e.name,sdkVersion:e.version},d=function(e,t){return""!==e?`${e}`:`${t.sdkName}@${t.sdkVersion}`}(t.sdkVersion,l),c=function(e){var t,i,n,s,o,r,a,l,d,c,u,E;let _=null,h=null;return/Windows/.test(e)?(_="Windows",h=null!==(i=null===(t=/Windows NT (\d+\.\d+)/.exec(e))||void 0===t?void 0:t[1])&&void 0!==i?i:null):/Android/.test(e)?(_="Android",h=null!==(s=null===(n=/Android (\d+\.\d+)/.exec(e))||void 0===n?void 0:n[1])&&void 0!==s?s:null):/iOS/.test(e)||/iPhone/.test(e)?(_="iOS",h=null!==(a=null===(r=null===(o=/OS (\d+[._]\d+[._]?\d*)/.exec(e))||void 0===o?void 0:o[1])||void 0===r?void 0:r.replace(/_/g,"."))&&void 0!==a?a:null):/Mac OS X/.test(e)?(_="Mac OS X",h=null!==(c=null===(d=null===(l=/Mac OS X (\d+([._]\d+)*)/.exec(e))||void 0===l?void 0:l[1])||void 0===d?void 0:d.replace(/_/g,"."))&&void 0!==c?c:null):/Linux/.test(e)&&(_="Linux",h=null!==(E=null===(u=/Linux( \w+)*?\/([\w.]+)/.exec(e))||void 0===u?void 0:u[2])&&void 0!==E?E:null),{os:_,version:h}}(i.userAgent),u=function(e){let t="",i="";if(-1!==e.indexOf("MSIE")||-1!==e.indexOf("Trident/")){t="Internet Explorer";const n=e.match(/(MSIE|rv:)\s?([\d.]+)/);n&&(i=n[2])}else if(-1!==e.indexOf("Edge")){t="Microsoft Edge";const n=e.match(/Edge\/([\d.]+)/);n&&(i=n[1])}else if(-1!==e.indexOf("Chrome")){t="Google Chrome";const n=e.match(/Chrome\/([\d.]+)/);n&&(i=n[1])}else if(-1!==e.indexOf("Firefox")){t="Mozilla Firefox";const n=e.match(/Firefox\/([\d.]+)/);n&&(i=n[1])}else if(-1!==e.indexOf("Safari")){t="Apple Safari";const n=e.match(/Version\/([\d.]+)/);n&&(i=n[1])}return{browserName:t,browserVersion:i}}(i.userAgent);var E;return{sdk_name_version:d,sdk_client_device_model:(E=i.userAgent,/(ipad|tablet)/gi.test(E)?"tablet":/Mobile|iP(hone|od)|Android|BlackBerry|IEMobile/.test(E)?"mobile":"desktop"),sdk_os_version:null!==(n=i.platform)&&void 0!==n?n:`${null!==(s=c.os)&&void 0!==s?s:""} ${null!==(o=c.version)&&void 0!==o?o:""}`,sdk_runtime_details:`${null!==(r=u.browserName)&&void 0!==r?r:""} ${null!==(a=u.browserVersion)&&void 0!==a?a:""}`}}(Di,i(this,Ni,"f"),navigator);e.headers["sky-metadata"]=JSON.stringify(t);const{headers:n}=e;Object.keys(e.headers).forEach((e=>{"content-type"===e&&n[e]&&n[e].includes(Ee.FORMDATA)||l.setRequestHeader(e,n[e])}))}(null===(o=null===(s=e.headers)||void 0===s?void 0:s["content-type"])||void 0===o?void 0:o.includes(Ee.FORMURLENCODED))||(null===(a=null===(r=e.headers)||void 0===r?void 0:r["content-type"])||void 0===a?void 0:a.includes(Ee.FORMDATA))?l.send(e.body):l.send(JSON.stringify(Object.assign({},e.body))),l.onload=()=>{var e,i,s;const o=l.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};o.forEach((e=>{const t=e.split(": "),i=t.shift()||"",n=t.join(": ");r[i]=n}));const a=r["content-type"],d=r["x-request-id"];if(l.status<200||l.status>=400)if(a&&a.includes("application/json")){let t=JSON.parse(l.response);(null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.message)&&(t=d?`${null===(i=null==t?void 0:t.error)||void 0===i?void 0:i.message} - requestId: ${d}`:null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.message),n(new Ye({code:l.status,description:t},[],!0))}else a&&a.includes("text/plain")?n(new Ye({code:l.status,description:d?`${l.response} - requestId: ${d}`:l.response},[],!0)):n(new Ye({code:l.status,description:d?`${Y.ERROR_OCCURED} - requestId: ${d}`:Y.ERROR_OCCURED},[],!0));a&&a.includes("application/json")&&t(JSON.parse(l.response)),t(l.response)},l.onerror=()=>{n(new Ye(Fe.NETWORK_ERROR,[],!0))}}else n(new Ye(Fe.CONNECTION_ERROR,[],!0))})),this.config=e,n(this,Ni,t,"f")}toJSON(){return{config:this.config,metaData:i(this,Ni,"f")}}static fromJSON(e){return new bi(e.config,e.metaData)}}Ni=new WeakMap,function(e){e.COLLECT="COLLECT",e.COMPOSABLE="COMPOSABLE"}(Ci||(Ci={}));const Pi="Skyflow";class Mi{constructor(e){var t,s;Ti.set(this,void 0),yi.set(this,At()),Oi.set(this,{uuid:i(this,yi,"f"),clientDomain:window.location.origin}),Ai.set(this,""),Li.set(this,void 0),gi.set(this,void 0),Ri.set(this,void 0),Si.set(this,void 0),this.bus=k.getEventBus();const o=localStorage.getItem("sdk_version")||"";i(this,Oi,"f").sdkVersion=o,n(this,Ti,new bi(Object.assign({},e),i(this,Oi,"f")),"f"),n(this,gi,(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||Se.ERROR,"f"),n(this,Ri,(null===(s=null==e?void 0:e.options)||void 0===s?void 0:s.env)||Ce.PROD,"f"),n(this,Si,{},"f"),this.bus.target({origin:pe.IFRAME_SECURE_ORGIN}).on(K+i(this,yi,"f"),((e,t)=>{Ue(ke(x.CAPTURED_BEARER_TOKEN_EVENT,Pi),De.LOG,i(this,gi,"f")),!i(this,Ti,"f").config.getBearerToken||i(this,Ai,"f")&&mi(i(this,Ai,"f"))?(Ue(ke(x.REUSE_BEARER_TOKEN,Pi),De.LOG,i(this,gi,"f")),t({authToken:i(this,Ai,"f")})):i(this,Ti,"f").config.getBearerToken().then((e=>{mi(e)?(Ue(ke(x.BEARER_TOKEN_RESOLVED,Pi),De.LOG,i(this,gi,"f")),n(this,Ai,e,"f"),t({authToken:i(this,Ai,"f")})):(Ue(Y.INVALID_BEARER_TOKEN,De.ERROR,i(this,gi,"f")),t({error:Y.INVALID_BEARER_TOKEN}))})).catch((e=>{Ue(Y.BEARER_TOKEN_REJECTED,De.ERROR,i(this,gi,"f")),t({error:e})}))})),Ue(ke(x.BEARER_TOKEN_LISTENER,Pi),De.LOG,i(this,gi,"f")),Ue(ke(x.CURRENT_ENV,Pi,i(this,Ri,"f")),De.LOG,i(this,gi,"f")),Ue(ke(x.CURRENT_LOG_LEVEL,Pi,i(this,gi,"f")),De.LOG,i(this,gi,"f"))}static init(e){var t;const i=(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||Se.ERROR;Ke(e),Ue(ke(x.INITIALIZE_CLIENT,Pi),De.LOG,i);const n=e;var s;n.vaultURL="string"!=typeof(s=e.vaultURL)?s:"/"===(null==s?void 0:s.trim().slice(-1))?s.slice(0,-1):s.trim();const o=new Mi(n);return Ue(ke(x.CLIENT_INITIALIZED,Pi),De.LOG,i),o}container(e,t){switch(e){case Ci.COLLECT:{const n=new Ft(t,Object.assign(Object.assign({},i(this,Oi,"f")),{clientJSON:i(this,Ti,"f").toJSON(),containerType:e}),i(this,Si,"f"),{logLevel:i(this,gi,"f"),env:i(this,Ri,"f")});return Ue(ke(x.COLLECT_CONTAINER_CREATED,Pi),De.LOG,i(this,gi,"f")),n}case Ci.COMPOSABLE:{(e=>{if(!e)throw new Ye(Fe.MISSING_COMPOSABLE_CONTAINER_OPTIONS,[],!0);if("object"!=typeof e)throw new Ye(Fe.INVALID_COMPOSABLE_CONTAINER_OPTIONS,[],!0);if(!Object.prototype.hasOwnProperty.call(e,"layout"))throw new Ye(Fe.MISSING_COMPOSABLE_LAYOUT_KEY,[],!0);if(!e.layout)throw new Ye(Fe.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(!Array.isArray(e.layout))throw new Ye(Fe.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(0===e.layout.length)throw new Ye(Fe.EMPTY_COMPOSABLE_LAYOUT_ARRAY,[],!0);e.layout.forEach((e=>{if("number"!=typeof e)throw new Ye(Fe.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(e<0)throw new Ye(Fe.NEGATIVE_VALUES_COMPOSABLE_LAYOUT,[],!0)}))})(t);const n=new hi(t,Object.assign(Object.assign({},i(this,Oi,"f")),{clientJSON:i(this,Ti,"f").toJSON(),containerType:e}),i(this,Si,"f"),{logLevel:i(this,gi,"f"),env:i(this,Ri,"f")});return Ue(ke(x.COLLECT_CONTAINER_CREATED,Pi),De.LOG,i(this,gi,"f")),n}default:if(!e)throw new Ye(Fe.EMPTY_CONTAINER_TYPE,[],!0);throw new Ye(Fe.INVALID_CONTAINER_TYPE,[],!0)}}static get ContainerType(){return Ci}static get ElementType(){return Q}static get RedactionType(){return Le}static get RequestMethod(){return ge}static get LogLevel(){return Se}static get EventName(){return Re}static get Env(){return Ce}static get ValidationRuleType(){return be}}function wi(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseURL&&(t=e.sdkBaseURL,delete e.sdkBaseURL),function(e){var t=e["merchant-id"],i=e["data-merchant-id"],n="",s="";Array.isArray(t)?t.length>1?(n="*",s=t.toString()):n=t.toString():"string"==typeof t&&t.length>0?n=t:"string"==typeof i&&i.length>0&&(n="*",s=i),e["merchant-id"]=n,e["data-merchant-id"]=s}(e);var i,n,s=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:{}}),o=s.queryParams,r=s.dataAttributes;return{url:"".concat(t,"?").concat((i=o,n="",Object.keys(i).forEach((function(e){0!==n.length&&(n+="&"),n+=e+"="+i[e]})),n)),dataAttributes:r}}function Ui(e,t){void 0===t&&(t={});var i=document.createElement("script");return i.src=e,Object.keys(t).forEach((function(e){i.setAttribute(e,t[e]),"data-csp-nonce"===e&&i.setAttribute("nonce",t["data-csp-nonce"])})),i}function ki(e,t){if(void 0===t&&(t=xi()),Fi(e,t),"undefined"==typeof window)return t.resolve(null);var i=wi(e),n=i.url,s=i.dataAttributes,o=s["data-namespace"]||"paypal",r=Yi(o);
|
|
5
5
|
/*!
|
|
6
6
|
* paypal-js v5.1.4 (2022-11-29T23:08:21.847Z)
|
|
7
7
|
* Copyright 2020-present, PayPal, Inc. All rights reserved.
|
|
@@ -18,8 +18,8 @@ Copyright (c) 2022 Skyflow, Inc.
|
|
|
18
18
|
* See the License for the specific language governing permissions and
|
|
19
19
|
* limitations under the License.
|
|
20
20
|
*/
|
|
21
|
-
return function(e,t){var i=document.querySelector('script[src="'.concat(e,'"]'));if(null===i)return null;var n=Zi(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=en()),nn(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=Zi(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=tn(s);if(e)return e;throw new Error("The window.".concat(s," global variable is not available."))}))}function en(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function tn(e){return window[e]}function nn(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}Yi=new WeakMap,xi=new WeakMap,Vi=new WeakMap,Fi=new WeakMap,Gi=new WeakMap,Bi=new WeakMap,ji=new WeakMap,Xi=new WeakMap,Wi=new WeakMap;class on{static load(e,t){if(e===sn.PayPal){if(!t)throw new Error("PayPal config is required");return on.loadPayPalScript(t)}return on.loadScript(e)}static reset(){on.scriptMap.clear()}static preloadCardForm(){const e="https://assets.payrails.io/d3ad1fa/card";[["https://js.skyflow.com/v1/elements/index.js","payrails-iframe-js-v1"],["https://js.skyflow.com/v1/elements/index.html","payrails-iframe-html-v1"],[`${e}/index.js`,"payrails-iframe-js-v2"],[`${e}/index.html`,"payrails-iframe-html-v2"]].forEach((([e,t])=>{if(!document.getElementById(t)){const i=document.createElement("link");i.id=t,i.rel="preload",i.as="script",i.href=e,document.head.appendChild(i)}}))}static loadScript(e){const t=`payrails-script-${JSON.stringify(e)}`;if(on.scriptMap.has(t))return on.scriptMap.get(t);const i=document.createElement("script");i.src=e,i.id=t;const n=new Promise(((t,n)=>{i.onload=()=>{t()},i.onerror=t=>{n(on.logLoadError(e,new Error(t.toString())))}}));return on.scriptMap.set(t,n),document.body.appendChild(i),n}static loadPayPalScript({clientId:e,currency:i,vault:n,intent:o}){return t(this,void 0,void 0,(function*(){try{const t=yield Qi({"client-id":e,components:"buttons,funding-eligibility",intent:o,currency:i,vault:n,"data-namespace":"payrailsPaypal"});if(t)return t}catch(e){throw on.logLoadError(sn.PayPal,e)}throw on.logLoadError(sn.PayPal)}))}constructor(){}static logLoadError(e,t){const i=new Map([[sn.ApplePay,r.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR],[sn.GooglePay,r.ERROR_CODES.PAYRAILS_CLIENT_GPAY_LOADING_ERROR],[sn.PayPal,r.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR]]),n=new r.PayrailsError(i.get(e)||r.ERROR_CODES.PAYRAILS_CLIENT_UNKNOWN_ERROR,{cause:t,description:null==t?void 0:t.message});return a.PayrailsLogger.error(n.message,{error:n}),n}}var sn;on.scriptMap=new Map,function(e){e.ApplePay="https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js",e.GooglePay="https://pay.google.com/gp/p/js/pay.js",e.PayPal="paypal-sdk"}(sn||(sn={}));class rn extends w{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 c=(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",d=`${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="${d}"><input type="checkbox" id="${d}" name="${d}" class="payrails-store-instrument-checkbox">${c}</label>`}applyStyles(){var e,t;Object.keys((null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.storeInstrumentCheckbox)||{}).forEach((e=>{var t,i,n;this.element.style[e]=null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===i?void 0:i.storeInstrumentCheckbox)||void 0===n?void 0:n[e]}))}addListeners(){this.element.addEventListener("change",(e=>{var t,i,n,o;(null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onSaveInstrumentCheckboxChanged)&&(null===(o=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===o||o.onSaveInstrumentCheckboxChanged({checked:this.isChecked})),e.stopPropagation(),e.stopImmediatePropagation()})),this.element.addEventListener("click",(e=>{e.stopPropagation(),e.stopImmediatePropagation()}))}}class an extends w{constructor(e,i){var n,o;super(e,i),this.options=i,this.storeInstrumentCheckbox=null,(null===(n=this.options)||void 0===n?void 0:n.showStoreInstrumentCheckbox)&&(this.storeInstrumentCheckbox=new rn(Object.assign(Object.assign({},i),{id:`${null===(o=this.options)||void 0===o?void 0:o.id}-store-instrument-checkbox`,events:{onSaveInstrumentCheckboxChanged:e=>t(this,void 0,void 0,(function*(){var t,n;null===(n=null===(t=null==i?void 0:i.events)||void 0===t?void 0:t.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(t,e)}))}})),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 ln extends an{static isApplePayAvailable(){return t(this,void 0,void 0,(function*(){try{return yield on.load(sn.ApplePay),ApplePaySession.canMakePayments()}catch(e){return!1}}))}constructor(e,t,i){super("div",Object.assign(Object.assign({},i),{id:"payrails-apple-pay-button"})),this.sdkConfig=e,this.execution=t,this.options=i,this.appleButton=null,this.paymentExecutor=new R(e,t),ln.isApplePayAvailable().then((e=>{var t,i,n;e&&(null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onApplePayAvailable)||void 0===n||n.call(i))}))}mount(e){super.mount(e),(()=>{t(this,void 0,void 0,(function*(){try{(yield ln.isApplePayAvailable())&&(yield this.mountApplePayButton())}catch(e){}}))})()}unmount(){var e,t;null===(t=null===(e=this.appleButton)||void 0===e?void 0:e.parentElement)||void 0===t||t.removeChild(this.appleButton),super.unmount()}mountApplePayButton(){var e,i,n;return t(this,void 0,void 0,(function*(){try{const o=(null===(e=this.options.styles)||void 0===e?void 0:e.type)||"buy",s=(null===(i=this.options.styles)||void 0===i?void 0:i.style)||"black";this.element.innerHTML=`<apple-pay-button buttonstyle="${s}" type="${o}" locale="en-GB"></apple-pay-button>`,null===(n=this.storeInstrumentCheckbox)||void 0===n||n.mount(this.selector);const r=this.element.querySelector("apple-pay-button");null==r||r.setAttribute("style","width: 100%;"),null==r||r.addEventListener("click",(()=>t(this,void 0,void 0,(function*(){(yield A(this.options.events))&&this.createApplePaySession()}))))}catch(e){}}))}createApplePaySession(){const e=this.execution.applePayConfig,{countryCode:i,supportedNetworks:n,merchantCapabilities:o}=e,{amount:s}=this.sdkConfig;try{const e={countryCode:i,currencyCode:s.currency,merchantCapabilities:o,supportedNetworks:n,total:{label:"",type:"final",amount:s.value}},r=new ApplePaySession(3,e);return r.onvalidatemerchant=e=>t(this,void 0,void 0,(function*(){const{res:t}=yield this.paymentExecutor.createApplePaySession({requestUrl:this.execution.createSessionLink,sessionUrl:e.validationURL,clientDomain:this.options.clientDomain}),i=t.data.data;r.completeMerchantValidation(i)})),r.oncancel=()=>{var e,t,i;(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onAuthorizeFailed)&&(null===(i=this.options)||void 0===i||i.events.onAuthorizeFailed())},r.onpaymentauthorized=e=>t(this,void 0,void 0,(function*(){var t,i,n,o,s,a,l,c,d,u,E,_;try{const u=yield this.onApplePayAuthorized(e.payment.token);"authorizeSuccessful"===(null===(t=null==u?void 0:u.finalState)||void 0===t?void 0:t.code)?(null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeSuccess)&&this.options.events.onAuthorizeSuccess():(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===(d=null===(c=this.options)||void 0===c?void 0:c.events)||void 0===d||d.onAuthorizeSuccess(u))}catch(e){r.completePayment(ApplePaySession.STATUS_FAILURE),(null===(E=null===(u=this.options)||void 0===u?void 0:u.events)||void 0===E?void 0:E.onAuthorizeFailed)&&(null===(_=this.options)||void 0===_||_.events.onAuthorizeFailed(e))}})),r.begin(),r}catch(e){return null}}onApplePayAuthorized(e){return t(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},e),{paymentNetwork:e.paymentMethod.network,paymentInstrumentName:e.paymentMethod.displayName}),i=[{paymentMethodCode:D.APPLE_PAY,integrationType:"api",paymentInstrumentData:{paymentToken:JSON.stringify(t)},amount:this.sdkConfig.amount,storeInstrument:this.shouldStoreInstrument}];return yield this.paymentExecutor.pay(i)}))}}const{CARD_NUMBER:cn,CVV:dn,CARDHOLDER_NAME:un,EXPIRATION_MONTH:En,EXPIRATION_YEAR:_n}=e.ElementType,hn={base:{border:"none",padding:"10px 16px",color:"#1d1d1d",backgroundColor:"#fff"},invalid:{backgroundColor:"#f9e1e1",borderColor:"#f25226",border:"1px solid"}},In=[{type:un,placeholder:"Card holder",styles:Object.assign(Object.assign({},hn),{base:Object.assign(Object.assign({},hn.base),{border:"1px solid #eae8ee",padding:"10px 16px",borderTopLeftRadius:"4px",borderTopRightRadius:"4px"})})},{type:cn,placeholder:"1234 1234 1234 1234",styles:Object.assign(Object.assign({},hn),{base:Object.assign(Object.assign({},hn.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:En,placeholder:"MM",styles:Object.assign(Object.assign({},hn),{base:Object.assign(Object.assign({},hn.base),{borderBottom:"1px solid #eae8ee",borderLeft:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomLeftRadius:"4px"})})},{type:_n,placeholder:"YY",format:"YY",styles:Object.assign(Object.assign({},hn),{base:Object.assign(Object.assign({},hn.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee"})})},{type:dn,placeholder:"CVC",styles:Object.assign(Object.assign({},hn),{base:Object.assign(Object.assign({},hn.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomRightRadius:"4px"})})}];class pn extends an{get bin(){return this.collectContainer.bin}constructor(t,i){var n,o,s,r,a;super("div",Object.assign(Object.assign({},i),{translations:Object.assign(Object.assign({},null==i?void 0:i.translations),{labels:Object.assign(Object.assign({},null===(n=null==i?void 0:i.translations)||void 0===n?void 0:n.labels),{saveInstrument:null===(s=null===(o=null==i?void 0:i.translations)||void 0===o?void 0:o.labels)||void 0===s?void 0:s.saveCreditCard})}),styles:Object.assign({storeInstrumentCheckbox:null===(r=null==i?void 0:i.styles)||void 0===r?void 0:r.storeCardCheckbox},null==i?void 0:i.styles),id:"payrails-card-form"})),this.collectContainer=t,this.options=i,this.formFields=[],(null===(a=null==i?void 0:i.styles)||void 0===a?void 0:a.storeCardCheckbox)&&console.warn("The `storeCardCheckbox` option for styles is deprecated. Please use `storeInstrumentCheckbox` instead."),In.forEach((({type:t,styles:n,format:o,placeholder:s})=>{var r,a,l,c,d,u,E;if(!(null===(r=this.options)||void 0===r?void 0:r.showCardHolderName)&&t===e.ElementType.CARDHOLDER_NAME)return;const _=new fn(this.collectContainer,{type:t,label:null===(l=null===(a=null==i?void 0:i.translations)||void 0===a?void 0:a.labels)||void 0===l?void 0:l[t],placeholder:(null===(d=null===(c=null==i?void 0:i.translations)||void 0===c?void 0:c.placeholders)||void 0===d?void 0:d[t])||s,labelStyles:this.prepareLabelStyles(t),inputStyles:this.prepareInputStyles(n,t),format:o,events:{onFocus:null===(E=null===(u=this.options)||void 0===u?void 0:u.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 r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw a.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,c,d;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===(d=null===(c=null===(l=this.options)||void 0===l?void 0:l.styles)||void 0===c?void 0:c.labels)||void 0===d?void 0:d[e]),t}),{})}prepareInputStyles(t,i){var n;let o=JSON.parse(JSON.stringify(t));return(null===(n=this.options)||void 0===n?void 0:n.showCardHolderName)&&i===e.ElementType.CARD_NUMBER&&(this.element.setAttribute("class","with-card-holder"),o=Object.assign(Object.assign({},t),{base:Object.assign(Object.assign({},hn.base),{border:"1px solid #eae8ee",borderTop:"none",padding:"10px 16px",textIndent:"0"})})),["base","complete","empty","focus","invalid","cardIcon","copyIcon"].forEach((e=>{var t,n,s,r,a,l,c,d;o[e]=Object.assign(Object.assign(Object.assign({},o[e]),null===(r=null===(s=null===(n=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===n?void 0:n.inputFields)||void 0===s?void 0:s.all)||void 0===r?void 0:r[e]),null===(d=null===(c=null===(l=null===(a=this.options)||void 0===a?void 0:a.styles)||void 0===l?void 0:l.inputFields)||void 0===c?void 0:c[i])||void 0===d?void 0:d[e])})),o}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 t(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 vn extends w{constructor(e,t,i,n,o){super("div",{id:e,className:"payrails-dropin-item"}),this.events=n,this.styles=o,this.isActive=!1,this.mountContainerClass="payrails-dropin-item-container",this.applyBaseStyles();const s=`payrails-dropin-item-${e}`,r=document.createElement("label");r.setAttribute("for",s);const a=document.createElement("input");if(a.setAttribute("type","radio"),a.setAttribute("name","payment-option"),a.setAttribute("id",s),a.setAttribute("value",s),this.input=a,r.appendChild(a),this.label=r,i){const e=document.createElement("img");e.src=null!=i?i:"",e.className="payrails-store-instrument-icon",r.appendChild(e)}const l=document.createElement("span");r.appendChild(l),l.innerText=t,this.element.addEventListener("click",(()=>{var e,t;null===(t=(e=this.label).onchange)||void 0===t||t.call(e,new Event("change"))})),this.element.appendChild(r);const c=document.createElement("div");c.setAttribute("class",this.mountContainerClass),this.element.appendChild(c)}get identifier(){return`payrails-dropin-item-${this.id}`}deactivate(){var e,t;this.isActive&&(this.isActive=!1,this.input.checked=!1,this.applyBaseStyles(),null===(e=this.component)||void 0===e||e.unmount(),(null===(t=this.events)||void 0===t?void 0:t.onDeactivate)&&this.events.onDeactivate())}applyBaseStyles(){var e,t;this.element.classList.remove("active"),Object.keys((null===(e=this.styles)||void 0===e?void 0:e.active)||{}).forEach((e=>{this.element.style.removeProperty(e)})),Object.assign(this.element.style,null===(t=this.styles)||void 0===t?void 0:t.base)}applyActiveStyles(){var e,t;this.element.classList.add("active"),Object.assign(this.element.style,null===(e=this.styles)||void 0===e?void 0:e.base,null===(t=this.styles)||void 0===t?void 0:t.active)}activate(){var e,t;this.isActive||(null===(e=this.component)||void 0===e||e.mount(`${this.selector} .${this.mountContainerClass}`),this.applyActiveStyles(),this.input.checked=!0,this.isActive=!0,(null===(t=this.events)||void 0===t?void 0:t.onActivate)&&this.events.onActivate())}mount(e){var t,i;super.mount(e),null===(i=null===(t=this.events)||void 0===t?void 0:t.onAvailable)||void 0===i||i.call(t)}}var mn;!function(e){e.AMEX="amex",e.DINERS="diners",e.DISCOVER="discover",e.HIPERCARD="hipercard",e.JCB="jcb",e.MAESTRO="maestro",e.MASTERCARD="mastercard",e.UNIONPAY="unionpay",e.VISA="visa"}(mn||(mn={}));const Nn="https://assets.payrails.io/img/";class Tn extends vn{constructor(e,t,i,n){const o=e.displayName&&""!==e.displayName?e.displayName:"Unavailable";super(`payrails-payment-instrument-${e.id}`,o,Tn.getInstrumentIcon(e),{onActivate:()=>{i(e),this.component.setDisabled(!1)}},n),this.component=t}static getInstrumentIcon(e){var t;if(e.paymentMethod!==D.CARD)return"";switch(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.network){case mn.AMEX:return Nn+"amex.svg";case mn.DINERS:return Nn+"diners-club.svg";case mn.DISCOVER:return Nn+"discover.svg";case mn.HIPERCARD:return Nn+"hipercard.svg";case mn.JCB:return Nn+"jcb.svg";case mn.MAESTRO:return Nn+"maestro.svg";case mn.MASTERCARD:return Nn+"mastercard.svg";case mn.UNIONPAY:return Nn+"unionpay.svg";case mn.VISA:return Nn+"visa.svg"}return Nn+"default.svg"}}class On extends w{constructor(e,t){super("div",{id:"payrails-card-list"}),this.workflowExecution=e,this.listItems=[],this.workflowExecution.savedCreditCards.forEach((e=>{const i=new yn((()=>{(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 yn extends w{constructor(e,t){super("div",{className:"payrails-card-list-item",id:`payrails-card-list-item-${t.id}`});const{id:i}=t,n=t.displayName&&""!==t.displayName?t.displayName:"Unavailable",o=document.createElement("label");o.setAttribute("for",i),o.addEventListener("click",e);const s=document.createElement("input");s.setAttribute("type","radio"),s.setAttribute("name","payment-option"),s.setAttribute("id",i),s.setAttribute("value",i),o.appendChild(s);const r=document.createElement("span");r.className="payment-option-text",o.appendChild(r);const a=document.createElement("img");a.src=Tn.getInstrumentIcon(t),a.className="payment-option-icon",r.appendChild(a),r.appendChild(document.createTextNode(n)),this.element.appendChild(o)}}class An extends w{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 Ln extends w{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 Rn extends vn{constructor(){super(...arguments),this.buttonShown=!1}activate(){if(!this.buttonShown)return super.activate(),void(this.buttonShown=!0);this.applyActiveStyles(),this.isActive=!0,this.element.querySelector(this.component.selector).style.display="block"}deactivate(){this.isActive&&(this.isActive=!1,this.applyBaseStyles(),this.element.querySelector(this.component.selector).style.display="none")}mountAfterAvailable(){var e,t;super.mount(`#${this.loadElementId}`),null===(t=null===(e=this.events)||void 0===e?void 0:e.onAvailable)||void 0===t||t.call(e)}mount(e){const t=document.querySelector(e);if(!t){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);throw a.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 gn extends Rn{constructor(e,t,i){var n,o;super("apple-pay-dropin",(null===(o=null===(n=i.translations)||void 0===n?void 0:n.labels)||void 0===o?void 0:o.label)||"Apple Pay",void 0,void 0,i.styles),this.loadElementId="apple-pay-dropin-load-element",this.component=new ln(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},i.events),{onApplePayAvailable:()=>{this.mountAfterAvailable()}})}))}}class Sn extends vn{constructor(e,t,i,n){super("payrails-credit-card-wrapper","Card",void 0,n,i),this.cardForm=e,this.paymentButton=t,this.cardFormShown=!1,this.component=new Dn(e,t)}activate(){var e,t;this.applyActiveStyles(),this.cardFormShown||(this.cardFormShown=!0,null===(e=this.component)||void 0===e||e.mount(this.selector)),this.isActive||(this.paymentButton.selectedInstrument=null,this.paymentButton.mount(this.selector),this.paymentButton.setDisabled(!this.cardForm.isValid),this.paymentButton.mount("#payrails-card-form"),this.input.checked=!0,this.cardForm.show(),this.isActive=!0,(null===(t=this.events)||void 0===t?void 0:t.onActivate)&&this.events.onActivate())}deactivate(){var e;this.isActive&&(this.applyBaseStyles(),this.paymentButton.unmount(),this.cardForm.hide(),this.isActive=!1,(null===(e=this.events)||void 0===e?void 0:e.onDeactivate)&&this.events.onDeactivate())}}class Dn extends w{constructor(e,t){super("div",{id:"payrails-form-container"}),this.subElements.push(e,t)}}class Cn extends w{constructor(e){var t,i,n,o;super("button",{id:e.id,className:"payrails-generic-button",styles:null!==(i=null===(t=e.styles)||void 0===t?void 0:t.base)&&void 0!==i?i:{}}),this.options=e,this.isDisabled=!1,this.element.innerText=null==e?void 0:e.translations.label,e.styles&&this.setStyles(null!==(o=null===(n=e.styles)||void 0===n?void 0:n.base)&&void 0!==o?o:{}),this.element.addEventListener("click",this.onClick.bind(this)),this.element.addEventListener("mouseenter",(()=>{var e;this.isDisabled||this.setStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{})})),this.element.addEventListener("mouseleave",(()=>{var e;this.isDisabled||this.removeStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{})}))}getElement(){return this.element}onClick(){var e,i;return t(this,void 0,void 0,(function*(){if((null===(i=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===i?void 0:i.onClick)&&!this.isDisabled){try{this.triggerLoading(!0),yield this.options.events.onClick()}catch(e){throw this.triggerLoading(!1),e}this.triggerLoading(!1)}}))}setStyles(e){var t;const i=Object.assign(Object.assign({},null===(t=this.options.styles)||void 0===t?void 0:t.base),e);Object.keys(i).forEach((e=>{this.element.style[e]=i[e]}))}removeStyles(e){var t;const i=Object.keys((null===(t=this.options.styles)||void 0===t?void 0:t.base)||{});Object.keys(e).forEach((e=>{var t,n;i.includes(e)?this.element.style[e]=null===(n=null===(t=this.options.styles)||void 0===t?void 0:t.base)||void 0===n?void 0:n[e]:this.element.style[e]=""}))}triggerLoading(e){var t,i,n;this.isDisabled=e,e?(this.element.innerHTML='\n <div class="dot-flashing-container">\n <div class="dot-flashing"></div>\n <span class="dot-flashing-text" aria-hidden="true">Loading</span>\n </div>\n ',(null===(t=this.options.styles)||void 0===t?void 0:t.loading)&&this.setStyles(this.options.styles.loading)):(this.element.innerText=null===(i=this.options)||void 0===i?void 0:i.translations.label,this.removeStyles((null===(n=this.options.styles)||void 0===n?void 0:n.loading)||{}))}}const Pn={label:"Generic redirect"};class bn extends w{constructor(e,t,i,n){super("div",{id:"payrails-generic-redirect"}),this.sdkConfig=e,this.options=i,this.returnInfo=n;const o=this.buildRedirectButton();this.element.appendChild(o.getElement()),this.paymentExecutor=new R(e,t,this.returnInfo)}buildRedirectButton(){var e,t,i;return new Cn({id:"payrails-generic-redirect-button",translations:{label:null!==(t=null===(e=this.options.translations)||void 0===e?void 0:e.label)&&void 0!==t?t:Pn.label},events:{onClick:this.onClick.bind(this)},styles:null!==(i=this.options.styles)&&void 0!==i?i:{}})}onClick(){var e,i,n;return t(this,void 0,void 0,(function*(){if(yield A(null!==(e=this.options.events)&&void 0!==e?e:{}))try{const e=(yield this.paymentExecutor.pay([{paymentMethodCode:D.GENERIC_REDIRECT,integrationType:"api",amount:this.sdkConfig.amount}])).response.links.redirect;if(!e)throw new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK);return new Promise(((t,i)=>{window.location.href=e,setTimeout((()=>i(new Error("Timed out doing a redirect to the auth response link"))),3e3)}))}catch(e){null===(n=null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeFailed)||void 0===n||n.call(i)}}))}mount(e){var t;null===(t=document.querySelector(e))||void 0===t||t.appendChild(this.element)}}const Mn={translations:{label:"Mercado Pago",button:{label:"Pay with Mercado Pago"}}};class wn extends vn{constructor(e,t,i,n){var o,s,r,a;super("payrails-generic-redirect-dropin",(null===(o=null==i?void 0:i.translations)||void 0===o?void 0:o.label)||Mn.translations.label,void 0,null==i?void 0:i.events,null===(s=null==i?void 0:i.styles)||void 0===s?void 0:s.element),this.sdkConfig=e,this.execution=t,this.returnInfo=n,this.component=new bn(this.sdkConfig,this.execution,{styles:null===(r=null==i?void 0:i.styles)||void 0===r?void 0:r.mercadoPago,translations:(null===(a=null==i?void 0:i.translations)||void 0===a?void 0:a.button)||Mn.translations.button,events:null==i?void 0:i.events},this.returnInfo)}}const Un={apiVersion:2,apiVersionMinor:0};class kn extends an{static getSDKClient(i=e.PayrailsEnvironment.TEST,n){return t(this,void 0,void 0,(function*(){return yield on.load(sn.GooglePay),kn.googleSDKClient||(kn.googleSDKClient=new google.payments.api.PaymentsClient({environment:i,merchantInfo:n})),kn.googleSDKClient}))}static isGooglePayAvailable(i,n=e.PayrailsEnvironment.TEST,o){return t(this,void 0,void 0,(function*(){try{const e=yield kn.getSDKClient(n,o),t=Object.assign(Object.assign({},Un),{allowedPaymentMethods:i}),{result:s}=yield e.isReadyToPay(t);return s}catch(e){return!1}}))}constructor(e,t,i){super("div",Object.assign(Object.assign({},i),{id:"payrails-google-pay-button"})),this.sdkConfig=e,this.execution=t,this.options=i,this.googleButton=null,this.paymentExecutor=new R(e,t),kn.isGooglePayAvailable(this.execution.googlePayConfig,this.options.environment,this.options.merchantInfo).then((e=>{var t,i,n;e&&(null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onGooglePayAvailable)||void 0===n||n.call(i))}))}sdkLoaded(e){var i,n,o,s,r,a,l,c;return t(this,void 0,void 0,(function*(){const d=(null===(n=null===(i=this.options)||void 0===i?void 0:i.styles)||void 0===n?void 0:n.buttonColor)||"black",u=(null===(s=null===(o=this.options)||void 0===o?void 0:o.styles)||void 0===s?void 0:s.buttonType)||"long",E=(null===(a=null===(r=this.options)||void 0===r?void 0:r.styles)||void 0===a?void 0:a.buttonSizeMode)||"fill",_=(null===(c=null===(l=this.options)||void 0===l?void 0:l.styles)||void 0===c?void 0:c.buttonLocale)||void 0;return this.googleButton=e.createButton({buttonColor:d,buttonType:u,buttonSizeMode:E,buttonLocale:_,onClick:()=>t(this,void 0,void 0,(function*(){(yield A(this.options.events))&&(yield this.authorize(e))})),allowedPaymentMethods:this.execution.googlePayConfig}),this.element.appendChild(this.googleButton),this.googleButton}))}onLoadPaymentData(e){var i,n,o,s,r,a,l,c;return t(this,void 0,void 0,(function*(){const t=[{paymentMethodCode:D.GOOGLE_PAY,integrationType:"api",paymentInstrumentData:{paymentToken:JSON.stringify(e)},amount:this.sdkConfig.amount,storeInstrument:this.shouldStoreInstrument}],d=yield this.paymentExecutor.pay(t);"authorizePending"===(null===(i=null==d?void 0:d.finalState)||void 0===i?void 0:i.code)?new b(this.options,this.execution,this.paymentExecutor).handle3ds(d):"authorizeSuccessful"===(null===(n=null==d?void 0:d.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===(c=null===(l=null===(a=this.options)||void 0===a?void 0:a.events)||void 0===l?void 0:l.onAuthorizeFailed)||void 0===c||c.call(l,d)}))}authorize(e){var i,n,o,s,r,a,l,c;return t(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},Un),{allowedPaymentMethods:this.execution.googlePayConfig,transactionInfo:{totalPriceStatus:"FINAL",totalPrice:null===(i=this.sdkConfig.amount)||void 0===i?void 0:i.value,currencyCode:null===(n=this.sdkConfig.amount)||void 0===n?void 0:n.currency,countryCode:null===(a=null===(r=null===(s=null===(o=this.execution.meta)||void 0===o?void 0:o.order)||void 0===s?void 0:s.billingAddress)||void 0===r?void 0:r.country)||void 0===a?void 0:a.code},merchantInfo:{merchantId:(null===(l=this.options.merchantInfo)||void 0===l?void 0:l.merchantId)||"",merchantName:(null===(c=this.options.merchantInfo)||void 0===c?void 0:c.merchantName)||""}});e.loadPaymentData(t).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(e){super.mount(e),(()=>{t(this,void 0,void 0,(function*(){var e;try{if(yield kn.isGooglePayAvailable(this.execution.googlePayConfig,this.options.environment,this.options.merchantInfo)){const t=yield kn.getSDKClient(this.options.environment,this.options.merchantInfo),i=yield this.sdkLoaded(t);this.element.appendChild(i),null===(e=this.storeInstrumentCheckbox)||void 0===e||e.mount(this.selector)}}catch(e){}}))})()}unmount(){var e,t,i;null===(t=null===(e=this.googleButton)||void 0===e?void 0:e.parentElement)||void 0===t||t.removeChild(this.googleButton),null===(i=this.storeInstrumentCheckbox)||void 0===i||i.unmount(),super.unmount()}}kn.googleSDKClient=null;class Yn extends Rn{constructor(e,t,i){var n,o;super("google-pay-dropin",(null===(o=null===(n=i.translations)||void 0===n?void 0:n.labels)||void 0===o?void 0:o.label)||"Google Pay",void 0,i.events,i.styles),this.loadElementId="google-pay-dropin-load-element",this.component=new kn(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},i.events),{onGooglePayAvailable:()=>{this.mountAfterAvailable()}})}))}}class xn extends an{constructor(e,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:e=>t(this,void 0,void 0,(function*(){var t,i,n,o;null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(i,e),null===(o=this.button)||void 0===o||o.close();const s=yield this.loadPaypal();s&&(this.button=s,yield this.button.render(`#${this.buttonWrapperId}`))}))})})),this.sdkConfig=e,this.execution=i,this.options=n,this.buttonWrapperId="payrails-paypal-button-wrapper",this.checkboxWrapperId="payrails-paypal-checkbox-wrapper",this.createOneTimeOrder=()=>t(this,void 0,void 0,(function*(){var e,t,i,n,o,s,r;const a=[{paymentMethodCode:D.PAYPAL,integrationType:"api",amount:this.sdkConfig.amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!1}],l=yield this.paymentExecutor.pay(a),c=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(!c)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 Vn("No order id returned");return this.confirmLink=null===(r=l.response.links.confirm)||void 0===r?void 0:r.href,c})),this.loadPaypal().catch((()=>{})),this.element.innerHTML=`<div id="${this.buttonWrapperId}"></div><div id="${this.checkboxWrapperId}"></div>`,this.paymentExecutor=new R(e,i),this.fraudNetGuid=null==n?void 0:n.fraudNetGuid}loadPaypal(){return t(this,void 0,void 0,(function*(){const e=yield on.load(sn.PayPal,this.paypalScriptConfig);return yield this.createPaypalButton(e)}))}get paypalScriptConfig(){const e=this.shouldStoreInstrument?"tokenize":"Instant"===this.execution.paypalConfig.captureMode?"capture":"authorize";return{clientId:this.execution.paypalConfig.clientId,intent:e,currency:this.sdkConfig.amount.currency,vault:this.shouldStoreInstrument}}createPaypalButton(e){var i,n,o;return t(this,void 0,void 0,(function*(){if(!e.Buttons)throw new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR);const t=e.Buttons(this.createPayPalButtonConfig());return null===(o=null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n?void 0:n.onPaypalAvailable)||void 0===o||o.call(n),t}))}createPayPalButtonConfig(){return this.shouldStoreInstrument?this.createBillingAgreementConfig():this.createOneTimeOrderConfig()}createBillingAgreementConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{onApprove:this.approvePayment.bind(this),createBillingAgreement:()=>t(this,void 0,void 0,(function*(){var e,t,i,n;const o=[{paymentMethodCode:D.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 e,i,n,o,s,r,a,l,c,d;return{fundingSource:"paypal",style:{color:(null===(i=null===(e=this.options)||void 0===e?void 0:e.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===(d=null===(c=this.options)||void 0===c?void 0:c.styles)||void 0===d?void 0:d.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:(e,i)=>t(this,void 0,void 0,(function*(){var e;return(yield A(null===(e=this.options)||void 0===e?void 0:e.events))?i.resolve():i.reject()}))}}approvePayment(e){var i,n,o,s,r,a,l,c,d,u;return t(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 Vn("No confirm link");const t={};this.shouldStoreInstrument&&e.billingToken&&(t.tokenId=e.billingToken),this.fraudNetGuid&&(t.riskSessionCorrelationId=this.fraudNetGuid);const E=yield this.paymentExecutor.confirm(this.confirmLink,t);"authorizeSuccessful"===(null===(s=E.finalState)||void 0===s?void 0:s.code)?null===(l=null===(a=null===(r=this.options)||void 0===r?void 0:r.events)||void 0===a?void 0:a.onAuthorizeSuccess)||void 0===l||l.call(a):null===(u=null===(d=null===(c=this.options)||void 0===c?void 0:c.events)||void 0===d?void 0:d.onAuthorizeFailed)||void 0===u||u.call(d)}))}mount(e){super.mount(e),(()=>{t(this,void 0,void 0,(function*(){var e;const t=yield this.loadPaypal();t&&(this.button=t);try{null===(e=this.storeInstrumentCheckbox)||void 0===e||e.mount(`#${this.checkboxWrapperId}`),yield null==t?void 0:t.render(`#${this.buttonWrapperId}`)}catch(e){const t=new Fn(e.message,e);throw a.PayrailsLogger.error(t.message,{error:t}),t}}))})()}unmount(){var e;null===(e=this.button)||void 0===e||e.close(),super.unmount()}}class Vn extends r.PayrailsError{constructor(e,t){super(r.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION,{description:`PaypalOrderError: ${e}`,cause:t})}}class Fn extends r.PayrailsError{constructor(e,t){super(r.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT,{description:`PaypalButtonError: ${e}`,cause:t})}}class Gn extends Rn{constructor(e,t,i){var n,o;super("payrails-paypal-button-dropin",(null===(o=null===(n=null==i?void 0:i.translations)||void 0===n?void 0:n.labels)||void 0===o?void 0:o.label)||"PayPal",void 0,void 0,null==i?void 0:i.styles),this.loadElementId="paypal-dropin-load-element",this.component=new xn(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},null==i?void 0:i.events),{onPaypalAvailable:()=>{this.mountAfterAvailable()}})}))}}class Bn extends w{constructor(e,t,i,n,o){var s,r;super("fieldset",{id:"payrails-dropin-component"}),this.collectContainer=e,this.clientConfig=t,this.dropinConfig=i,this.execution=n,this.sdkConfig=o,this.applyStyles(),void 0!==(null===(r=null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s.cards)||void 0===r?void 0:r.showExistingCards)&&console.warn("The `showExistingCards` option is deprecated and will be removed in a future version. Please use `showStoredInstruments` instead.");const a=new Map;this.execution.storedPaymentInstruments.forEach((e=>{if(this.isStoredInstrumentEnabled(e.paymentMethod)){this.cardPaymentButton=this.createCardPaymentButton();const t=this.createStoredInstrumentElement(e);a.set(t.identifier,t)}}));const l={[D.CARD]:this.createCreditCardButton.bind(this),[D.PAYPAL]:this.createPayPalButton.bind(this),[D.GOOGLE_PAY]:this.createGooglePayButton.bind(this),[D.APPLE_PAY]:this.createApplePayButton.bind(this),[D.GENERIC_REDIRECT]:this.createMercadoPagoButton.bind(this)};this.execution.availablePaymentMethods.forEach((({paymentMethodCode:e})=>{if(e&&l[e]){l[e];const t=l[e]();a.set(t.identifier,t)}})),this.element.addEventListener("change",(e=>{var t,i;const n=(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.value)||"";a.forEach((e=>{e.deactivate()})),null===(i=a.get(n))||void 0===i||i.activate()})),1===this.totalPaymentOptions&&this.element.classList.add("payrails-dropin-component--single"),this.subElements.push(...Array.from(a.values()))}createStoredInstrumentElement(e){var t;return this.cardPaymentButton=this.createCardPaymentButton(),new Tn(e,this.cardPaymentButton,(e=>{this.cardPaymentButton&&(this.cardPaymentButton.selectedInstrument=e)}),null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.element)}createMercadoPagoButton(){var e,t,i,n,o;return this.mercadoPago=new wn(this.sdkConfig,this.execution,{styles:{element:null===(t=null===(e=this.dropinConfig)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.element,mercadoPago:null===(n=null===(i=this.dropinConfig)||void 0===i?void 0:i.styles)||void 0===n?void 0:n.mercadoPago},translations:null===(o=this.dropinConfig.translations)||void 0===o?void 0:o.mercadoPago,events:this.getElementEvents()},this.clientConfig.returnInfo),this.mercadoPago}get totalPaymentOptions(){return this.execution.availablePaymentMethods.length+this.execution.storedPaymentInstruments.length}createCreditCardButton(){var e;return this.creditCard=new Sn(this.createCardForm(),this.createCardPaymentButton(),null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.element,this.getElementEvents()),this.creditCard}createGooglePayButton(){var t,i,n;return this.googlePay=new Yn(this.sdkConfig,this.execution,Object.assign({environment:this.clientConfig.environment||e.PayrailsEnvironment.TEST,events:this.getElementEvents(),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 Gn(this.sdkConfig,this.execution,Object.assign(Object.assign({},null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.payPal),{styles:Object.assign(Object.assign({},null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.paypalButton),null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.element),events:this.getElementEvents()})),this.paypal}createCardForm(){var e,t,i,n;if(!this.cardForm){const o=null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.cards,s=Boolean(null==o?void 0:o.showStoreInstrumentCheckbox),r=Boolean(null==o?void 0:o.showCardHolderName),a=Boolean(null==o?void 0:o.alwaysStoreInstrument);this.cardForm=new pn(this.collectContainer,{showStoreInstrumentCheckbox:s,showCardHolderName:r,alwaysStoreInstrument:a,translations:null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.cardForm,styles:Object.assign(Object.assign({},null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.cardForm),null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.element),events:Object.assign(Object.assign({},this.getElementEvents()),{onFocus:()=>{var e;null===(e=this.creditCard)||void 0===e||e.activate()},onChange:({isValid:e})=>{var t;null===(t=this.cardPaymentButton)||void 0===t||t.setDisabled(!e)},onSaveInstrumentCheckboxChanged:e=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onSaveInstrumentCheckboxChanged)||void 0===i||i.call(t,e)}})})}return this.cardPaymentButton&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardForm}createApplePayButton(){var e,t,i;return this.applePay=new gn(this.sdkConfig,this.execution,Object.assign(Object.assign({events:Object.assign(Object.assign({},this.getElementEvents()),{onAuthorizeSuccess:e=>{var t;e&&("authorizeSuccessful"===(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code)?this.onAuthorizeSuccess():this.onAuthorizeFailed())}})},null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.applePay),{styles:Object.assign(Object.assign({},null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.applePayButton),null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.element)})),this.applePay}createCardPaymentButton(){var e,t;return this.cardPaymentButton||(this.cardPaymentButton=new U(this.sdkConfig,this.execution,{styles:null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.cardPaymentButton,translations:null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.cardPaymentButton,events:this.getElementEvents()},this.clientConfig.returnInfo)),this.cardForm&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardPaymentButton}onAuthorizeSuccess(){var e,t,i,n;this.subElements.forEach((e=>e.unmount())),new Ln({translations:{label:null===(i=null===(t=null===(e=this.dropinConfig)||void 0===e?void 0:e.translations)||void 0===t?void 0:t.paymentResult)||void 0===i?void 0:i.success}}).mount(this.selector),(null===(n=this.dropinConfig.events)||void 0===n?void 0:n.onAuthorizeSuccess)&&this.dropinConfig.events.onAuthorizeSuccess()}getElementEvents(){return Object.assign(Object.assign({},this.dropinConfig.events),{onAuthorizeSuccess:this.onAuthorizeSuccess.bind(this),onAuthorizeFailed:this.onAuthorizeFailed.bind(this),onAvailable:()=>{var e;(1===this.totalPaymentOptions||(null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.preselectFirstPaymentOption))&&this.subElements[0].activate()}})}onAuthorizeFailed(e){var t,i,n,o;new An(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 D.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 D.PAYPAL:case D.GOOGLE_PAY:case D.APPLE_PAY:return!1!==(null===(r=null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s[e])||void 0===r?void 0:r.showStoredInstruments);default:return!1}}applyStyles(){var e;(null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.container)&&Object.assign(this.element.style,this.dropinConfig.styles.container)}}const jn={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 Xn{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(t){const i={required:!!t.required,enableCardIcon:!1!==t.enableCardIcon},n=this.__container.create(Object.assign(Object.assign({table:this.cardTableName,labelStyles:{},errorTextStyles:{},column:this.elementToFieldMap.get(t.type)},t),{type:t.type===e.ElementType.CARDHOLDER_NAME?"INPUT_FIELD":t.type}),t.format?Object.assign(Object.assign({},i),{format:t.format}):i);return this.attachCustomEventHandler(n)}mount(e){if("COLLECT"===this.containerType){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw a.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 r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING);throw a.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 t(this,void 0,void 0,(function*(){try{return this.sdkConfig.usePayrailsFrames?yield this.collectPayrailsData():yield this.collectSkyflowData()}catch(e){const t=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CARD_FORM_ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE,{description:"Error collecting data from the iframe!"});throw a.PayrailsLogger.error(t.message,{error:t}),t}}))}collectSkyflowData(){return t(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 t(this,void 0,void 0,(function*(){const e=yield this.__container.collect();return Object.assign(Object.assign({},e),{vaultProviderConfigId:this.sdkConfig.vaultConfiguration.providerConfigId})}))}tokenize(e){return t(this,void 0,void 0,(function*(){const t=yield this.collect(),i=this.sdkConfig.vaultConfiguration.links.saveInstrument.href,n=this.sdkConfig.token;if(!i){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND,{description:"Save instrument URL not available!"});throw a.PayrailsLogger.error(e.message,{error:e}),e}const o=yield(({url:e,token:t,body:i})=>p({url:e,token:t,method:_.POST,body:i}))({url:i,token:n,body:this.constructSaveInstrumentBody(t,e)});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(t){return new Proxy(t,{get:(t,i)=>"on"!==i?t[i]:((n,o)=>{t[i].call(t,n,(t=>{"CHANGE"===n?(t.elementType===e.ElementType.CARD_NUMBER&&(t.network=function(e){for(const[t,i]of Object.entries(jn))if(i.test(e))return t;return""}(t.value),t.bin=this.formatBin(t.value),this.bin=this.formatBin(t.value)),o(t)):o(t)}))}).bind(t)})}formatBin(e){return e.replace(/-|X/g,"")}get elementToFieldMap(){return new Map([[e.ElementType.CARD_NUMBER,"card_number"],[e.ElementType.CARDHOLDER_NAME,"cardholder_name"],[e.ElementType.CVV,"security_code"],[e.ElementType.EXPIRATION_MONTH,"expiry_month"],[e.ElementType.EXPIRATION_YEAR,"expiry_year"]])}}class Wn{constructor(e,t,i){this.pageId=e,this.execution=t,this.environment=i,this.guid=I().replace(/-/g,""),this.fnclsVal="fnparams-dede7cc5-15fd-4c75-a9f4-36c430ee3a99",this.configId=I(),this.scriptId=I()}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 $n=()=>{const e=document.getElementById("sdk-observer");return e||(()=>{const e=document.createElement("iframe");return e.id="sdk-observer",e.src="https://assets.payrails.io/d3ad1fa/observability/index.html",e.width="1px",e.height="1px",document.body.appendChild(e),e})()};
|
|
21
|
+
return function(e,t){var i=document.querySelector('script[src="'.concat(e,'"]'));if(null===i)return null;var n=Ui(e,t),s=i.cloneNode();if(delete s.dataset.uidAuto,Object.keys(s.dataset).length!==Object.keys(n.dataset).length)return null;var o=!0;return Object.keys(s.dataset).forEach((function(e){s.dataset[e]!==n.dataset[e]&&(o=!1)})),o?i:null}(n,s)&&r?t.resolve(r):function(e,t){void 0===t&&(t=xi()),Fi(e,t);var i=e.url,n=e.attributes;if("string"!=typeof i||0===i.length)throw new Error("Invalid url.");if(void 0!==n&&"object"!=typeof n)throw new Error("Expected attributes to be an object.");return new t((function(e,t){if("undefined"==typeof window)return e();!function(e){var t=e.url,i=e.attributes,n=e.onSuccess,s=e.onError,o=Ui(t,i);o.onerror=s,o.onload=n,document.head.insertBefore(o,document.head.firstElementChild)}({url:i,attributes:n,onSuccess:function(){return e()},onError:function(){var e=new Error('The script "'.concat(i,'" failed to load.'));return window.fetch?fetch(i).then((function(i){return 200===i.status&&t(e),i.text()})).then((function(e){var i=function(e){var t=e.split("/* Original Error:")[1];return t?t.replace(/\n/g,"").replace("*/","").trim():e}(e);t(new Error(i))})).catch((function(e){t(e)})):t(e)}})}))}({url:n,attributes:s},t).then((function(){var e=Yi(o);if(e)return e;throw new Error("The window.".concat(o," global variable is not available."))}))}function xi(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function Yi(e){return window[e]}function Fi(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}Ti=new WeakMap,yi=new WeakMap,Oi=new WeakMap,Ai=new WeakMap,Li=new WeakMap,gi=new WeakMap,Ri=new WeakMap,Si=new WeakMap;class Vi{static load(e,t){if(e===Bi.PayPal){if(!t)throw new Error("PayPal config is required");return Vi.loadPayPalScript(t)}return Vi.loadScript(e)}static reset(){Vi.scriptMap.clear()}static preloadCardForm(){const e="https://assets.payrails.io/df36830/card";[["https://js.skyflow.com/v1/elements/index.js","payrails-iframe-js-v1"],["https://js.skyflow.com/v1/elements/index.html","payrails-iframe-html-v1"],[`${e}/index.js`,"payrails-iframe-js-v2"],[`${e}/index.html`,"payrails-iframe-html-v2"]].forEach((([e,t])=>{if(!document.getElementById(t)){const i=document.createElement("link");i.id=t,i.rel="preload",i.as="script",i.href=e,document.head.appendChild(i)}}))}static loadScript(e){const t=`payrails-script-${JSON.stringify(e)}`;if(Vi.scriptMap.has(t))return Vi.scriptMap.get(t);const i=document.createElement("script");i.src=e,i.id=t;const n=new Promise(((t,n)=>{i.onload=()=>{t()},i.onerror=t=>{n(Vi.logLoadError(e,new Error(t.toString())))}}));return Vi.scriptMap.set(t,n),document.body.appendChild(i),n}static loadPayPalScript({clientId:e,currency:i,vault:n,intent:s}){return t(this,void 0,void 0,(function*(){try{const t=yield ki({"client-id":e,components:"buttons,funding-eligibility",intent:s,currency:i,vault:n,"data-namespace":"payrailsPaypal"});if(t)return t}catch(e){throw Vi.logLoadError(Bi.PayPal,e)}throw Vi.logLoadError(Bi.PayPal)}))}constructor(){}static logLoadError(e,t){const i=new Map([[Bi.ApplePay,r.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR],[Bi.GooglePay,r.ERROR_CODES.PAYRAILS_CLIENT_GPAY_LOADING_ERROR],[Bi.PayPal,r.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR]]),n=new r.PayrailsError(i.get(e)||r.ERROR_CODES.PAYRAILS_CLIENT_UNKNOWN_ERROR,{cause:t,description:null==t?void 0:t.message});return a.PayrailsLogger.error(n.message,{error:n}),n}}var Bi;Vi.scriptMap=new Map,function(e){e.ApplePay="https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js",e.GooglePay="https://pay.google.com/gp/p/js/pay.js",e.PayPal="paypal-sdk"}(Bi||(Bi={}));class Gi extends w{constructor(e){super("span",{id:e.id,className:"payrails-store-instrument"}),this.options=e,this.createHTML(),this.applyStyles(),this.addListeners()}get isChecked(){var e;return!!(null===(e=this.element.querySelector("input"))||void 0===e?void 0:e.checked)}createHTML(){var e,t,i,n,s,o,r,a,l;const d=(null===(i=null===(t=null===(e=this.options)||void 0===e?void 0:e.translations)||void 0===t?void 0:t.labels)||void 0===i?void 0:i.saveInstrument)||(null===(o=null===(s=null===(n=this.options)||void 0===n?void 0:n.translations)||void 0===s?void 0:s.labels)||void 0===o?void 0:o.storeInstrument)||"Save instrument for future payments",c=`${this.id}-checkbox`;(null===(l=null===(a=null===(r=this.options)||void 0===r?void 0:r.translations)||void 0===a?void 0:a.labels)||void 0===l?void 0:l.saveInstrument)&&console.warn("The saveInstrument label is deprecated, please use storeInstrument instead"),this.element.innerHTML=`<label for="${c}"><input type="checkbox" id="${c}" name="${c}" class="payrails-store-instrument-checkbox">${d}</label>`}applyStyles(){var e,t;Object.keys((null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.storeInstrumentCheckbox)||{}).forEach((e=>{var t,i,n;this.element.style[e]=null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===i?void 0:i.storeInstrumentCheckbox)||void 0===n?void 0:n[e]}))}addListeners(){this.element.addEventListener("change",(e=>{var t,i,n,s;(null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onSaveInstrumentCheckboxChanged)&&(null===(s=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===s||s.onSaveInstrumentCheckboxChanged({checked:this.isChecked})),e.stopPropagation(),e.stopImmediatePropagation()})),this.element.addEventListener("click",(e=>{e.stopPropagation(),e.stopImmediatePropagation()}))}}class ji extends w{constructor(e,i){var n,s;super(e,i),this.options=i,this.storeInstrumentCheckbox=null,(null===(n=this.options)||void 0===n?void 0:n.showStoreInstrumentCheckbox)&&(this.storeInstrumentCheckbox=new Gi(Object.assign(Object.assign({},i),{id:`${null===(s=this.options)||void 0===s?void 0:s.id}-store-instrument-checkbox`,events:{onSaveInstrumentCheckboxChanged:e=>t(this,void 0,void 0,(function*(){var t,n;null===(n=null===(t=null==i?void 0:i.events)||void 0===t?void 0:t.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(t,e)}))}})),this.subElements.push(this.storeInstrumentCheckbox))}get shouldStoreInstrument(){var e,t;return(null===(e=this.storeInstrumentCheckbox)||void 0===e?void 0:e.isChecked)||(null===(t=this.options)||void 0===t?void 0:t.alwaysStoreInstrument)||!1}}class Xi extends ji{static isApplePayAvailable(){return t(this,void 0,void 0,(function*(){try{return yield Vi.load(Bi.ApplePay),ApplePaySession.canMakePayments()}catch(e){return!1}}))}constructor(e,t,i){super("div",Object.assign(Object.assign({},i),{id:"payrails-apple-pay-button"})),this.sdkConfig=e,this.execution=t,this.options=i,this.appleButton=null,this.paymentExecutor=new g(e,t),Xi.isApplePayAvailable().then((e=>{var t,i,n;e&&(null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onApplePayAvailable)||void 0===n||n.call(i))}))}mount(e){super.mount(e),(()=>{t(this,void 0,void 0,(function*(){try{(yield Xi.isApplePayAvailable())&&(yield this.mountApplePayButton())}catch(e){}}))})()}unmount(){var e,t;null===(t=null===(e=this.appleButton)||void 0===e?void 0:e.parentElement)||void 0===t||t.removeChild(this.appleButton),super.unmount()}mountApplePayButton(){var e,i,n;return t(this,void 0,void 0,(function*(){try{const s=(null===(e=this.options.styles)||void 0===e?void 0:e.type)||"buy",o=(null===(i=this.options.styles)||void 0===i?void 0:i.style)||"black";this.element.innerHTML=`<apple-pay-button buttonstyle="${o}" type="${s}" locale="en-GB"></apple-pay-button>`,null===(n=this.storeInstrumentCheckbox)||void 0===n||n.mount(this.selector);const r=this.element.querySelector("apple-pay-button");null==r||r.setAttribute("style","width: 100%;"),null==r||r.addEventListener("click",(()=>t(this,void 0,void 0,(function*(){(yield A(this.options.events))&&this.createApplePaySession()}))))}catch(e){}}))}createApplePaySession(){const e=this.execution.applePayConfig,{countryCode:i,supportedNetworks:n,merchantCapabilities:s}=e,{amount:o}=this.sdkConfig;try{const e={countryCode:i,currencyCode:o.currency,merchantCapabilities:s,supportedNetworks:n,total:{label:"",type:"final",amount:o.value}},r=new ApplePaySession(3,e);return r.onvalidatemerchant=e=>t(this,void 0,void 0,(function*(){const{res:t}=yield this.paymentExecutor.createApplePaySession({requestUrl:this.execution.createSessionLink,sessionUrl:e.validationURL,clientDomain:this.options.clientDomain}),i=t.data.data;r.completeMerchantValidation(i)})),r.oncancel=()=>{var e,t,i;(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onAuthorizeFailed)&&(null===(i=this.options)||void 0===i||i.events.onAuthorizeFailed())},r.onpaymentauthorized=e=>t(this,void 0,void 0,(function*(){var t,i,n,s,o,a,l,d,c,u,E,_;try{const u=yield this.onApplePayAuthorized(e.payment.token);"authorizeSuccessful"===(null===(t=null==u?void 0:u.finalState)||void 0===t?void 0:t.code)?(null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeSuccess)&&this.options.events.onAuthorizeSuccess():(r.completePayment(ApplePaySession.STATUS_FAILURE),(null===(s=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===s?void 0:s.onAuthorizeFailed)&&(null===(o=this.options)||void 0===o||o.events.onAuthorizeFailed())),r.completePayment(ApplePaySession.STATUS_SUCCESS),(null===(l=null===(a=this.options)||void 0===a?void 0:a.events)||void 0===l?void 0:l.onAuthorizeSuccess)&&(null===(c=null===(d=this.options)||void 0===d?void 0:d.events)||void 0===c||c.onAuthorizeSuccess(u))}catch(e){r.completePayment(ApplePaySession.STATUS_FAILURE),(null===(E=null===(u=this.options)||void 0===u?void 0:u.events)||void 0===E?void 0:E.onAuthorizeFailed)&&(null===(_=this.options)||void 0===_||_.events.onAuthorizeFailed(e))}})),r.begin(),r}catch(e){return null}}onApplePayAuthorized(e){return t(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},e),{paymentNetwork:e.paymentMethod.network,paymentInstrumentName:e.paymentMethod.displayName}),i=[{paymentMethodCode:C.APPLE_PAY,integrationType:"api",paymentInstrumentData:{paymentToken:JSON.stringify(t)},amount:this.sdkConfig.amount,storeInstrument:this.shouldStoreInstrument}];return yield this.paymentExecutor.pay(i)}))}}const{CARD_NUMBER:Wi,CVV:zi,CARDHOLDER_NAME:Hi,EXPIRATION_MONTH:Ki,EXPIRATION_YEAR:$i}=e.ElementType,qi={base:{border:"none",padding:"10px 16px",color:"#1d1d1d",backgroundColor:"#fff"},invalid:{backgroundColor:"#f9e1e1",borderColor:"#f25226",border:"1px solid"}},Ji=[{type:Hi,placeholder:"Card holder",styles:Object.assign(Object.assign({},qi),{base:Object.assign(Object.assign({},qi.base),{border:"1px solid #eae8ee",padding:"10px 16px",borderTopLeftRadius:"4px",borderTopRightRadius:"4px"})})},{type:Wi,placeholder:"1234 1234 1234 1234",styles:Object.assign(Object.assign({},qi),{base:Object.assign(Object.assign({},qi.base),{border:"1px solid #eae8ee",padding:"10px 16px",borderTopLeftRadius:"4px",borderTopRightRadius:"4px",textIndent:"0"}),cardIcon:{position:"absolute",right:"8px",height:"24px",bottom:"calc(50% - 12px)"}})},{type:Ki,placeholder:"MM",styles:Object.assign(Object.assign({},qi),{base:Object.assign(Object.assign({},qi.base),{borderBottom:"1px solid #eae8ee",borderLeft:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomLeftRadius:"4px"})})},{type:$i,placeholder:"YY",format:"YY",styles:Object.assign(Object.assign({},qi),{base:Object.assign(Object.assign({},qi.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee"})})},{type:zi,placeholder:"CVC",styles:Object.assign(Object.assign({},qi),{base:Object.assign(Object.assign({},qi.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomRightRadius:"4px"})})}];class Zi extends ji{get bin(){return this.collectContainer.bin}constructor(t,i){var n,s,o,r,a;super("div",Object.assign(Object.assign({},i),{translations:Object.assign(Object.assign({},null==i?void 0:i.translations),{labels:Object.assign(Object.assign({},null===(n=null==i?void 0:i.translations)||void 0===n?void 0:n.labels),{saveInstrument:null===(o=null===(s=null==i?void 0:i.translations)||void 0===s?void 0:s.labels)||void 0===o?void 0:o.saveCreditCard})}),styles:Object.assign({storeInstrumentCheckbox:null===(r=null==i?void 0:i.styles)||void 0===r?void 0:r.storeCardCheckbox},null==i?void 0:i.styles),id:"payrails-card-form"})),this.collectContainer=t,this.options=i,this.formFields=[],(null===(a=null==i?void 0:i.styles)||void 0===a?void 0:a.storeCardCheckbox)&&console.warn("The `storeCardCheckbox` option for styles is deprecated. Please use `storeInstrumentCheckbox` instead."),Ji.forEach((({type:t,styles:n,format:s,placeholder:o})=>{var r,a,l,d,c,u,E;if(!(null===(r=this.options)||void 0===r?void 0:r.showCardHolderName)&&t===e.ElementType.CARDHOLDER_NAME)return;const _=new Qi(this.collectContainer,{type:t,label:null===(l=null===(a=null==i?void 0:i.translations)||void 0===a?void 0:a.labels)||void 0===l?void 0:l[t],placeholder:(null===(c=null===(d=null==i?void 0:i.translations)||void 0===d?void 0:d.placeholders)||void 0===c?void 0:c[t])||o,labelStyles:this.prepareLabelStyles(t),inputStyles:this.prepareInputStyles(n,t),format:s,events:{onFocus:null===(E=null===(u=this.options)||void 0===u?void 0:u.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 r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw a.PayrailsLogger.error(e.message,{error:e}),e}Object.assign(i.style,null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.wrapper),this.element.style.display="flex"}hide(){this.element.style.display="none"}triggerOnReady(){var e,t,i;this.formFields.reduce(((e,t)=>e&&t.isReady),!0)&&(null===(i=null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onReady)||void 0===i||i.call(t))}prepareLabelStyles(e){return["base"].reduce(((t,i)=>{var n,s,o,r,a,l,d,c;return t[i]=Object.assign(Object.assign(Object.assign({},null===(s=null===(n=this.options)||void 0===n?void 0:n.styles)||void 0===s?void 0:s.base),null===(a=null===(r=null===(o=this.options)||void 0===o?void 0:o.styles)||void 0===r?void 0:r.labels)||void 0===a?void 0:a.all),null===(c=null===(d=null===(l=this.options)||void 0===l?void 0:l.styles)||void 0===d?void 0:d.labels)||void 0===c?void 0:c[e]),t}),{})}prepareInputStyles(t,i){var n;let s=JSON.parse(JSON.stringify(t));return(null===(n=this.options)||void 0===n?void 0:n.showCardHolderName)&&i===e.ElementType.CARD_NUMBER&&(this.element.setAttribute("class","with-card-holder"),s=Object.assign(Object.assign({},t),{base:Object.assign(Object.assign({},qi.base),{border:"1px solid #eae8ee",borderTop:"none",padding:"10px 16px",textIndent:"0"})})),["base","complete","empty","focus","invalid","cardIcon","copyIcon"].forEach((e=>{var t,n,o,r,a,l,d,c;s[e]=Object.assign(Object.assign(Object.assign({},s[e]),null===(r=null===(o=null===(n=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===n?void 0:n.inputFields)||void 0===o?void 0:o.all)||void 0===r?void 0:r[e]),null===(c=null===(d=null===(l=null===(a=this.options)||void 0===a?void 0:a.styles)||void 0===l?void 0:l.inputFields)||void 0===d?void 0:d[i])||void 0===c?void 0:c[e])})),s}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 t(this,void 0,void 0,(function*(){return{cardData:yield this.collectContainer.collect(),storeInstrument:this.shouldStoreInstrument,enrollInstrumentToNetworkOffers:Boolean(this.enforceEnrollInstrumentToNetworkOffersForMasterCard())}}))}enforceEnrollInstrumentToNetworkOffersForMasterCard(){var e;return"mastercard"!==this.cardNetwork&&(null===(e=this.options)||void 0===e?void 0:e.enrollInstrumentToNetworkOffers)}}class Qi{constructor(e,t){this.isValid=!1,this.isReady=!1,this.cardNetwork="";const{events:i}=t,n=e.createCollectElement(t);(null==i?void 0:i.onFocus)&&n.on("FOCUS",i.onFocus),n.on("READY",(()=>{var e,i;this.isReady=!0,null===(i=null===(e=t.events)||void 0===e?void 0:e.onReady)||void 0===i||i.call(e)})),n.on("CHANGE",(e=>{const{isEmpty:t,isValid:n,network:s}=e;this.isValid=!t&&n,this.cardNetwork=null!=s?s:"",(null==i?void 0:i.onChange)&&i.onChange(this)}))}}class en extends w{constructor(e,t,i,n,s){super("div",{id:e,className:"payrails-dropin-item"}),this.events=n,this.styles=s,this.isActive=!1,this.mountContainerClass="payrails-dropin-item-container",this.applyBaseStyles();const o=`payrails-dropin-item-${e}`,r=document.createElement("label");r.setAttribute("for",o);const a=document.createElement("input");if(a.setAttribute("type","radio"),a.setAttribute("name","payment-option"),a.setAttribute("id",o),a.setAttribute("value",o),this.input=a,r.appendChild(a),this.label=r,i){const e=document.createElement("img");e.src=null!=i?i:"",e.className="payrails-store-instrument-icon",r.appendChild(e)}const l=document.createElement("span");r.appendChild(l),l.innerText=t,this.element.addEventListener("click",(()=>{var e,t;null===(t=(e=this.label).onchange)||void 0===t||t.call(e,new Event("change"))})),this.element.appendChild(r);const d=document.createElement("div");d.setAttribute("class",this.mountContainerClass),this.element.appendChild(d)}get identifier(){return`payrails-dropin-item-${this.id}`}deactivate(){var e,t;this.isActive&&(this.isActive=!1,this.input.checked=!1,this.applyBaseStyles(),null===(e=this.component)||void 0===e||e.unmount(),(null===(t=this.events)||void 0===t?void 0:t.onDeactivate)&&this.events.onDeactivate())}applyBaseStyles(){var e,t;this.element.classList.remove("active"),Object.keys((null===(e=this.styles)||void 0===e?void 0:e.active)||{}).forEach((e=>{this.element.style.removeProperty(e)})),Object.assign(this.element.style,null===(t=this.styles)||void 0===t?void 0:t.base)}applyActiveStyles(){var e,t;this.element.classList.add("active"),Object.assign(this.element.style,null===(e=this.styles)||void 0===e?void 0:e.base,null===(t=this.styles)||void 0===t?void 0:t.active)}activate(){var e,t;this.isActive||(null===(e=this.component)||void 0===e||e.mount(`${this.selector} .${this.mountContainerClass}`),this.applyActiveStyles(),this.input.checked=!0,this.isActive=!0,(null===(t=this.events)||void 0===t?void 0:t.onActivate)&&this.events.onActivate())}mount(e){var t,i;super.mount(e),null===(i=null===(t=this.events)||void 0===t?void 0:t.onAvailable)||void 0===i||i.call(t)}}var tn;!function(e){e.AMEX="amex",e.DINERS="diners",e.DISCOVER="discover",e.HIPERCARD="hipercard",e.JCB="jcb",e.MAESTRO="maestro",e.MASTERCARD="mastercard",e.UNIONPAY="unionpay",e.VISA="visa"}(tn||(tn={}));const nn="https://assets.payrails.io/img/";class sn extends en{constructor(e,t,i,n){const s=e.displayName&&""!==e.displayName?e.displayName:"Unavailable";super(`payrails-payment-instrument-${e.id}`,s,sn.getInstrumentIcon(e),{onActivate:()=>{i(e),this.component.setDisabled(!1)}},n),this.component=t}static getInstrumentIcon(e){var t;if(e.paymentMethod!==C.CARD)return"";switch(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.network){case tn.AMEX:return nn+"amex.svg";case tn.DINERS:return nn+"diners-club.svg";case tn.DISCOVER:return nn+"discover.svg";case tn.HIPERCARD:return nn+"hipercard.svg";case tn.JCB:return nn+"jcb.svg";case tn.MAESTRO:return nn+"maestro.svg";case tn.MASTERCARD:return nn+"mastercard.svg";case tn.UNIONPAY:return nn+"unionpay.svg";case tn.VISA:return nn+"visa.svg"}return nn+"default.svg"}}class on extends w{constructor(e,t){super("div",{id:"payrails-card-list"}),this.workflowExecution=e,this.listItems=[],this.workflowExecution.savedCreditCards.forEach((e=>{const i=new rn((()=>{(null==t?void 0:t.onCardChange)&&t.onCardChange(e)}),e);this.listItems.push(i),this.subElements.push(i)}))}reset(){this.element.querySelectorAll("input").forEach((e=>e.checked=!1))}}class rn extends w{constructor(e,t){super("div",{className:"payrails-card-list-item",id:`payrails-card-list-item-${t.id}`});const{id:i}=t,n=t.displayName&&""!==t.displayName?t.displayName:"Unavailable",s=document.createElement("label");s.setAttribute("for",i),s.addEventListener("click",e);const o=document.createElement("input");o.setAttribute("type","radio"),o.setAttribute("name","payment-option"),o.setAttribute("id",i),o.setAttribute("value",i),s.appendChild(o);const r=document.createElement("span");r.className="payment-option-text",s.appendChild(r);const a=document.createElement("img");a.src=sn.getInstrumentIcon(t),a.className="payment-option-icon",r.appendChild(a),r.appendChild(document.createTextNode(n)),this.element.appendChild(s)}}class an extends w{constructor(e){var t;super("div",{id:"authorization-failed-message"});const i=(null===(t=null==e?void 0:e.translations)||void 0===t?void 0:t.label)||"Authorization failed, please try again.";this.element.innerText=i,this.setStyles((null==e?void 0:e.styles)||{}),this.element.innerHTML=`\n <div>\n <svg class="checkmark-cross" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">\n <circle class="checkmark-cross_circle" cx="26" cy="26" r="25" fill="none"/>\n <path class="checkmark-cross_check" fill="none" d="M14.1 14.1l23.8 23.8 m0,-23.8 l-23.8,23.8"/>\n </svg>\n </div>\n <div>${i}</div>`,this.element.addEventListener("click",(e=>{e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),this.unmount()}))}setStyles(e){Object.keys(e).forEach((t=>{this.element.style[t]=e[t]}))}}class ln extends w{constructor(e){var t;super("div",{id:"payrails-authorization-success-msg"}),this.setStyles((null==e?void 0:e.styles)||{}),this.element.innerHTML=`\n <div class="checkmark-wrapper">\n <svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">\n <circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none"/>\n <path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8"/>\n </svg>\n </div>\n <div id="payrails-authorization-success">${(null===(t=null==e?void 0:e.translations)||void 0===t?void 0:t.label)||"Payment successful"}</div`}setStyles(e){Object.keys(e).forEach((t=>{this.element.style[t]=e[t]}))}}class dn extends en{constructor(){super(...arguments),this.buttonShown=!1}activate(){if(!this.buttonShown)return super.activate(),void(this.buttonShown=!0);this.applyActiveStyles(),this.isActive=!0,this.element.querySelector(this.component.selector).style.display="block"}deactivate(){this.isActive&&(this.isActive=!1,this.applyBaseStyles(),this.element.querySelector(this.component.selector).style.display="none")}mountAfterAvailable(){var e,t;super.mount(`#${this.loadElementId}`),null===(t=null===(e=this.events)||void 0===e?void 0:e.onAvailable)||void 0===t||t.call(e)}mount(e){const t=document.querySelector(e);if(!t){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);throw a.PayrailsLogger.error(e.message,{error:e}),e}const i=document.createElement("div");i.setAttribute("id",this.loadElementId),i.setAttribute("style","width: 100%;"),t.appendChild(i)}unmount(){var e;super.unmount(),null===(e=document.querySelector(`#${this.loadElementId}`))||void 0===e||e.remove()}}class cn extends dn{constructor(e,t,i){var n,s;super("apple-pay-dropin",(null===(s=null===(n=i.translations)||void 0===n?void 0:n.labels)||void 0===s?void 0:s.label)||"Apple Pay",void 0,void 0,i.styles),this.loadElementId="apple-pay-dropin-load-element",this.component=new Xi(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},i.events),{onApplePayAvailable:()=>{this.mountAfterAvailable()}})}))}}class un extends en{constructor(e,t,i,n){super("payrails-credit-card-wrapper","Card",void 0,n,i),this.cardForm=e,this.paymentButton=t,this.cardFormShown=!1,this.component=new En(e,t)}activate(){var e,t;this.applyActiveStyles(),this.cardFormShown||(this.cardFormShown=!0,null===(e=this.component)||void 0===e||e.mount(this.selector)),this.isActive||(this.paymentButton.selectedInstrument=null,this.paymentButton.mount(this.selector),this.paymentButton.setDisabled(!this.cardForm.isValid),this.paymentButton.mount("#payrails-card-form"),this.input.checked=!0,this.cardForm.show(),this.isActive=!0,(null===(t=this.events)||void 0===t?void 0:t.onActivate)&&this.events.onActivate())}deactivate(){var e;this.isActive&&(this.applyBaseStyles(),this.paymentButton.unmount(),this.cardForm.hide(),this.isActive=!1,(null===(e=this.events)||void 0===e?void 0:e.onDeactivate)&&this.events.onDeactivate())}}class En extends w{constructor(e,t){super("div",{id:"payrails-form-container"}),this.subElements.push(e,t)}}class _n extends w{constructor(e){var t,i,n,s;super("button",{id:e.id,className:"payrails-generic-button",styles:null!==(i=null===(t=e.styles)||void 0===t?void 0:t.base)&&void 0!==i?i:{}}),this.options=e,this.isDisabled=!1,this.element.innerText=null==e?void 0:e.translations.label,e.styles&&this.setStyles(null!==(s=null===(n=e.styles)||void 0===n?void 0:n.base)&&void 0!==s?s:{}),this.element.addEventListener("click",this.onClick.bind(this)),this.element.addEventListener("mouseenter",(()=>{var e;this.isDisabled||this.setStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{})})),this.element.addEventListener("mouseleave",(()=>{var e;this.isDisabled||this.removeStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{})}))}getElement(){return this.element}onClick(){var e,i;return t(this,void 0,void 0,(function*(){if((null===(i=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===i?void 0:i.onClick)&&!this.isDisabled){try{this.triggerLoading(!0),yield this.options.events.onClick()}catch(e){throw this.triggerLoading(!1),e}this.triggerLoading(!1)}}))}setStyles(e){var t;const i=Object.assign(Object.assign({},null===(t=this.options.styles)||void 0===t?void 0:t.base),e);Object.keys(i).forEach((e=>{this.element.style[e]=i[e]}))}removeStyles(e){var t;const i=Object.keys((null===(t=this.options.styles)||void 0===t?void 0:t.base)||{});Object.keys(e).forEach((e=>{var t,n;i.includes(e)?this.element.style[e]=null===(n=null===(t=this.options.styles)||void 0===t?void 0:t.base)||void 0===n?void 0:n[e]:this.element.style[e]=""}))}triggerLoading(e){var t,i,n;this.isDisabled=e,e?(this.element.innerHTML='\n <div class="dot-flashing-container">\n <div class="dot-flashing"></div>\n <span class="dot-flashing-text" aria-hidden="true">Loading</span>\n </div>\n ',(null===(t=this.options.styles)||void 0===t?void 0:t.loading)&&this.setStyles(this.options.styles.loading)):(this.element.innerText=null===(i=this.options)||void 0===i?void 0:i.translations.label,this.removeStyles((null===(n=this.options.styles)||void 0===n?void 0:n.loading)||{}))}}const hn={label:"Generic redirect"};class In extends w{constructor(e,t,i,n){super("div",{id:"payrails-generic-redirect"}),this.sdkConfig=e,this.options=i,this.returnInfo=n;const s=this.buildRedirectButton();this.element.appendChild(s.getElement()),this.paymentExecutor=new g(e,t,this.returnInfo)}buildRedirectButton(){var e,t,i;return new _n({id:"payrails-generic-redirect-button",translations:{label:null!==(t=null===(e=this.options.translations)||void 0===e?void 0:e.label)&&void 0!==t?t:hn.label},events:{onClick:this.onClick.bind(this)},styles:null!==(i=this.options.styles)&&void 0!==i?i:{}})}onClick(){var e,i,n;return t(this,void 0,void 0,(function*(){if(yield A(null!==(e=this.options.events)&&void 0!==e?e:{}))try{const e=(yield this.paymentExecutor.pay([{paymentMethodCode:C.GENERIC_REDIRECT,integrationType:"api",amount:this.sdkConfig.amount}])).response.links.redirect;if(!e)throw new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK);return new Promise(((t,i)=>{window.location.href=e,setTimeout((()=>i(new Error("Timed out doing a redirect to the auth response link"))),3e3)}))}catch(e){null===(n=null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeFailed)||void 0===n||n.call(i)}}))}}const pn={translations:{label:"Mercado Pago",button:{label:"Pay with Mercado Pago"}}};class fn extends en{constructor(e,t,i,n){var s,o,r,a;super("payrails-generic-redirect-dropin",(null===(s=null==i?void 0:i.translations)||void 0===s?void 0:s.label)||pn.translations.label,void 0,null==i?void 0:i.events,null===(o=null==i?void 0:i.styles)||void 0===o?void 0:o.element),this.sdkConfig=e,this.execution=t,this.returnInfo=n,this.component=new In(this.sdkConfig,this.execution,{styles:null===(r=null==i?void 0:i.styles)||void 0===r?void 0:r.mercadoPago,translations:(null===(a=null==i?void 0:i.translations)||void 0===a?void 0:a.button)||pn.translations.button,events:null==i?void 0:i.events},this.returnInfo)}}const vn={apiVersion:2,apiVersionMinor:0};class mn extends ji{static getSDKClient(i=e.PayrailsEnvironment.TEST,n){return t(this,void 0,void 0,(function*(){return yield Vi.load(Bi.GooglePay),mn.googleSDKClient||(mn.googleSDKClient=new google.payments.api.PaymentsClient({environment:i,merchantInfo:n})),mn.googleSDKClient}))}static isGooglePayAvailable(i,n=e.PayrailsEnvironment.TEST,s){return t(this,void 0,void 0,(function*(){try{const e=yield mn.getSDKClient(n,s),t=Object.assign(Object.assign({},vn),{allowedPaymentMethods:i}),{result:o}=yield e.isReadyToPay(t);return o}catch(e){return!1}}))}constructor(e,t,i){super("div",Object.assign(Object.assign({},i),{id:"payrails-google-pay-button"})),this.sdkConfig=e,this.execution=t,this.options=i,this.googleButton=null,this.paymentExecutor=new g(e,t),mn.isGooglePayAvailable(this.execution.googlePayConfig,this.options.environment,this.options.merchantInfo).then((e=>{var t,i,n;e&&(null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onGooglePayAvailable)||void 0===n||n.call(i))}))}sdkLoaded(e){var i,n,s,o,r,a,l,d;return t(this,void 0,void 0,(function*(){const c=(null===(n=null===(i=this.options)||void 0===i?void 0:i.styles)||void 0===n?void 0:n.buttonColor)||"black",u=(null===(o=null===(s=this.options)||void 0===s?void 0:s.styles)||void 0===o?void 0:o.buttonType)||"long",E=(null===(a=null===(r=this.options)||void 0===r?void 0:r.styles)||void 0===a?void 0:a.buttonSizeMode)||"fill",_=(null===(d=null===(l=this.options)||void 0===l?void 0:l.styles)||void 0===d?void 0:d.buttonLocale)||void 0;return this.googleButton=e.createButton({buttonColor:c,buttonType:u,buttonSizeMode:E,buttonLocale:_,onClick:()=>t(this,void 0,void 0,(function*(){(yield A(this.options.events))&&(yield this.authorize(e))})),allowedPaymentMethods:this.execution.googlePayConfig}),this.element.appendChild(this.googleButton),this.googleButton}))}onLoadPaymentData(e){var i,n,s,o,r,a,l,d;return t(this,void 0,void 0,(function*(){const t=[{paymentMethodCode:C.GOOGLE_PAY,integrationType:"api",paymentInstrumentData:{paymentToken:JSON.stringify(e)},amount:this.sdkConfig.amount,storeInstrument:this.shouldStoreInstrument}],c=yield this.paymentExecutor.pay(t);"authorizePending"===(null===(i=null==c?void 0:c.finalState)||void 0===i?void 0:i.code)?new P(this.options,this.execution,this.paymentExecutor).handle3ds(c):"authorizeSuccessful"===(null===(n=null==c?void 0:c.finalState)||void 0===n?void 0:n.code)?null===(r=null===(o=null===(s=this.options)||void 0===s?void 0:s.events)||void 0===o?void 0:o.onAuthorizeSuccess)||void 0===r||r.call(o):null===(d=null===(l=null===(a=this.options)||void 0===a?void 0:a.events)||void 0===l?void 0:l.onAuthorizeFailed)||void 0===d||d.call(l,c)}))}authorize(e){var i,n,s,o,r,a,l,d;return t(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},vn),{allowedPaymentMethods:this.execution.googlePayConfig,transactionInfo:{totalPriceStatus:"FINAL",totalPrice:null===(i=this.sdkConfig.amount)||void 0===i?void 0:i.value,currencyCode:null===(n=this.sdkConfig.amount)||void 0===n?void 0:n.currency,countryCode:null===(a=null===(r=null===(o=null===(s=this.execution.meta)||void 0===s?void 0:s.order)||void 0===o?void 0:o.billingAddress)||void 0===r?void 0:r.country)||void 0===a?void 0:a.code},merchantInfo:{merchantId:(null===(l=this.options.merchantInfo)||void 0===l?void 0:l.merchantId)||"",merchantName:(null===(d=this.options.merchantInfo)||void 0===d?void 0:d.merchantName)||""}});e.loadPaymentData(t).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(e){super.mount(e),(()=>{t(this,void 0,void 0,(function*(){var e;try{if(yield mn.isGooglePayAvailable(this.execution.googlePayConfig,this.options.environment,this.options.merchantInfo)){const t=yield mn.getSDKClient(this.options.environment,this.options.merchantInfo),i=yield this.sdkLoaded(t);this.element.appendChild(i),null===(e=this.storeInstrumentCheckbox)||void 0===e||e.mount(this.selector)}}catch(e){}}))})()}unmount(){var e,t,i;null===(t=null===(e=this.googleButton)||void 0===e?void 0:e.parentElement)||void 0===t||t.removeChild(this.googleButton),null===(i=this.storeInstrumentCheckbox)||void 0===i||i.unmount(),super.unmount()}}mn.googleSDKClient=null;class Nn extends dn{constructor(e,t,i){var n,s;super("google-pay-dropin",(null===(s=null===(n=i.translations)||void 0===n?void 0:n.labels)||void 0===s?void 0:s.label)||"Google Pay",void 0,i.events,i.styles),this.loadElementId="google-pay-dropin-load-element",this.component=new mn(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},i.events),{onGooglePayAvailable:()=>{this.mountAfterAvailable()}})}))}}class Tn extends ji{constructor(e,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:e=>t(this,void 0,void 0,(function*(){var t,i,n,s;null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(i,e),null===(s=this.button)||void 0===s||s.close();const o=yield this.loadPaypal();o&&(this.button=o,yield this.button.render(`#${this.buttonWrapperId}`))}))})})),this.sdkConfig=e,this.execution=i,this.options=n,this.buttonWrapperId="payrails-paypal-button-wrapper",this.checkboxWrapperId="payrails-paypal-checkbox-wrapper",this.createOneTimeOrder=()=>t(this,void 0,void 0,(function*(){var e,t,i,n,s,o,r;const a=[{paymentMethodCode:C.PAYPAL,integrationType:"api",amount:this.sdkConfig.amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!1}],l=yield this.paymentExecutor.pay(a),d=null===(i=null===(t=null===(e=l.response.links.confirm)||void 0===e?void 0:e.action)||void 0===t?void 0:t.parameters)||void 0===i?void 0:i.orderId;if(!d)throw null===(o=null===(s=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===s?void 0:s.onAuthorizeFailed)||void 0===o||o.call(s),new yn("No order id returned");return this.confirmLink=null===(r=l.response.links.confirm)||void 0===r?void 0:r.href,d})),this.loadPaypal().catch((()=>{})),this.element.innerHTML=`<div id="${this.buttonWrapperId}"></div><div id="${this.checkboxWrapperId}"></div>`,this.paymentExecutor=new g(e,i),this.fraudNetGuid=null==n?void 0:n.fraudNetGuid}loadPaypal(){return t(this,void 0,void 0,(function*(){const e=yield Vi.load(Bi.PayPal,this.paypalScriptConfig);return yield this.createPaypalButton(e)}))}get paypalScriptConfig(){const e=this.shouldStoreInstrument?"tokenize":"Instant"===this.execution.paypalConfig.captureMode?"capture":"authorize";return{clientId:this.execution.paypalConfig.clientId,intent:e,currency:this.sdkConfig.amount.currency,vault:this.shouldStoreInstrument}}createPaypalButton(e){var i,n,s;return t(this,void 0,void 0,(function*(){if(!e.Buttons)throw new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR);const t=e.Buttons(this.createPayPalButtonConfig());return null===(s=null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n?void 0:n.onPaypalAvailable)||void 0===s||s.call(n),t}))}createPayPalButtonConfig(){return this.shouldStoreInstrument?this.createBillingAgreementConfig():this.createOneTimeOrderConfig()}createBillingAgreementConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{onApprove:this.approvePayment.bind(this),createBillingAgreement:()=>t(this,void 0,void 0,(function*(){var e,t,i,n;const s=[{paymentMethodCode:C.PAYPAL,integrationType:"api",amount:this.sdkConfig.amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!0}],o=yield this.paymentExecutor.pay(s);return this.confirmLink=null===(e=o.response.links.confirm)||void 0===e?void 0:e.href,(null===(n=null===(i=null===(t=o.response.links.confirm)||void 0===t?void 0:t.action)||void 0===i?void 0:i.parameters)||void 0===n?void 0:n.tokenId)||""}))})}createOneTimeOrderConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{createOrder:this.createOneTimeOrder.bind(this),onApprove:this.approvePayment.bind(this)})}createBaseConfig(){var e,i,n,s,o,r,a,l,d,c;return{fundingSource:"paypal",style:{color:(null===(i=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===i?void 0:i.color)||"gold",height:(null===(s=null===(n=this.options)||void 0===n?void 0:n.styles)||void 0===s?void 0:s.height)||40,label:(null===(r=null===(o=this.options)||void 0===o?void 0:o.styles)||void 0===r?void 0:r.label)||"paypal",shape:(null===(l=null===(a=this.options)||void 0===a?void 0:a.styles)||void 0===l?void 0:l.shape)||"rect",tagline:(null===(c=null===(d=this.options)||void 0===d?void 0:d.styles)||void 0===c?void 0:c.tagline)||!1},onError:e=>{var t,i;(null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onAuthorizeFailed)&&this.options.events.onAuthorizeFailed(e)},onClick:(e,i)=>t(this,void 0,void 0,(function*(){var e;return(yield A(null===(e=this.options)||void 0===e?void 0:e.events))?i.resolve():i.reject()}))}}approvePayment(e){var i,n,s,o,r,a,l,d,c,u;return t(this,void 0,void 0,(function*(){if(!this.confirmLink)throw null===(s=null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n?void 0:n.onAuthorizeFailed)||void 0===s||s.call(n),new yn("No confirm link");const t={};this.shouldStoreInstrument&&e.billingToken&&(t.tokenId=e.billingToken),this.fraudNetGuid&&(t.riskSessionCorrelationId=this.fraudNetGuid);const E=yield this.paymentExecutor.confirm(this.confirmLink,t);"authorizeSuccessful"===(null===(o=E.finalState)||void 0===o?void 0:o.code)?null===(l=null===(a=null===(r=this.options)||void 0===r?void 0:r.events)||void 0===a?void 0:a.onAuthorizeSuccess)||void 0===l||l.call(a):null===(u=null===(c=null===(d=this.options)||void 0===d?void 0:d.events)||void 0===c?void 0:c.onAuthorizeFailed)||void 0===u||u.call(c)}))}mount(e){super.mount(e),(()=>{t(this,void 0,void 0,(function*(){var e;const t=yield this.loadPaypal();t&&(this.button=t);try{null===(e=this.storeInstrumentCheckbox)||void 0===e||e.mount(`#${this.checkboxWrapperId}`),yield null==t?void 0:t.render(`#${this.buttonWrapperId}`)}catch(e){const t=new On(e.message,e);throw a.PayrailsLogger.error(t.message,{error:t}),t}}))})()}unmount(){var e;null===(e=this.button)||void 0===e||e.close(),super.unmount()}}class yn extends r.PayrailsError{constructor(e,t){super(r.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION,{description:`PaypalOrderError: ${e}`,cause:t})}}class On extends r.PayrailsError{constructor(e,t){super(r.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT,{description:`PaypalButtonError: ${e}`,cause:t})}}class An extends dn{constructor(e,t,i){var n,s;super("payrails-paypal-button-dropin",(null===(s=null===(n=null==i?void 0:i.translations)||void 0===n?void 0:n.labels)||void 0===s?void 0:s.label)||"PayPal",void 0,void 0,null==i?void 0:i.styles),this.loadElementId="paypal-dropin-load-element",this.component=new Tn(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},null==i?void 0:i.events),{onPaypalAvailable:()=>{this.mountAfterAvailable()}})}))}}class Ln extends w{constructor(e,t,i,n,s){var o,r;super("fieldset",{id:"payrails-dropin-component"}),this.collectContainer=e,this.clientConfig=t,this.dropinConfig=i,this.execution=n,this.sdkConfig=s,this.applyStyles(),void 0!==(null===(r=null===(o=this.dropinConfig.paymentMethodsConfiguration)||void 0===o?void 0:o.cards)||void 0===r?void 0:r.showExistingCards)&&console.warn("The `showExistingCards` option is deprecated and will be removed in a future version. Please use `showStoredInstruments` instead.");const a=new Map;this.execution.storedPaymentInstruments.forEach((e=>{if(this.isStoredInstrumentEnabled(e.paymentMethod)){this.cardPaymentButton=this.createCardPaymentButton();const t=this.createStoredInstrumentElement(e);a.set(t.identifier,t)}}));const l={[C.CARD]:this.createCreditCardButton.bind(this),[C.PAYPAL]:this.createPayPalButton.bind(this),[C.GOOGLE_PAY]:this.createGooglePayButton.bind(this),[C.APPLE_PAY]:this.createApplePayButton.bind(this),[C.GENERIC_REDIRECT]:this.createMercadoPagoButton.bind(this)};this.execution.availablePaymentMethods.forEach((({paymentMethodCode:e})=>{if(e&&l[e]){l[e];const t=l[e]();a.set(t.identifier,t)}})),this.element.addEventListener("change",(e=>{var t,i;const n=(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.value)||"";a.forEach((e=>{e.deactivate()})),null===(i=a.get(n))||void 0===i||i.activate()})),1===this.totalPaymentOptions&&this.element.classList.add("payrails-dropin-component--single"),this.subElements.push(...Array.from(a.values()))}createStoredInstrumentElement(e){var t;return this.cardPaymentButton=this.createCardPaymentButton(),new sn(e,this.cardPaymentButton,(e=>{this.cardPaymentButton&&(this.cardPaymentButton.selectedInstrument=e)}),null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.element)}createMercadoPagoButton(){var e,t,i,n,s;return this.mercadoPago=new fn(this.sdkConfig,this.execution,{styles:{element:null===(t=null===(e=this.dropinConfig)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.element,mercadoPago:null===(n=null===(i=this.dropinConfig)||void 0===i?void 0:i.styles)||void 0===n?void 0:n.mercadoPago},translations:null===(s=this.dropinConfig.translations)||void 0===s?void 0:s.mercadoPago,events:this.getElementEvents()},this.clientConfig.returnInfo),this.mercadoPago}get totalPaymentOptions(){return this.execution.availablePaymentMethods.length+this.execution.storedPaymentInstruments.length}createCreditCardButton(){var e;return this.creditCard=new un(this.createCardForm(),this.createCardPaymentButton(),null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.element,this.getElementEvents()),this.creditCard}createGooglePayButton(){var t,i,n;return this.googlePay=new Nn(this.sdkConfig,this.execution,Object.assign({environment:this.clientConfig.environment||e.PayrailsEnvironment.TEST,events:this.getElementEvents(),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 An(this.sdkConfig,this.execution,Object.assign(Object.assign({},null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.payPal),{styles:Object.assign(Object.assign({},null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.paypalButton),null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.element),events:this.getElementEvents()})),this.paypal}createCardForm(){var e,t,i,n;if(!this.cardForm){const s=null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.cards,o=Boolean(null==s?void 0:s.showStoreInstrumentCheckbox),r=Boolean(null==s?void 0:s.showCardHolderName),a=Boolean(null==s?void 0:s.alwaysStoreInstrument);this.cardForm=new Zi(this.collectContainer,{showStoreInstrumentCheckbox:o,showCardHolderName:r,alwaysStoreInstrument:a,translations:null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.cardForm,styles:Object.assign(Object.assign({},null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.cardForm),null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.element),events:Object.assign(Object.assign({},this.getElementEvents()),{onFocus:()=>{var e;null===(e=this.creditCard)||void 0===e||e.activate()},onChange:({isValid:e})=>{var t;null===(t=this.cardPaymentButton)||void 0===t||t.setDisabled(!e)},onSaveInstrumentCheckboxChanged:e=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onSaveInstrumentCheckboxChanged)||void 0===i||i.call(t,e)}})})}return this.cardPaymentButton&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardForm}createApplePayButton(){var e,t,i;return this.applePay=new cn(this.sdkConfig,this.execution,Object.assign(Object.assign({events:Object.assign(Object.assign({},this.getElementEvents()),{onAuthorizeSuccess:e=>{var t;e&&("authorizeSuccessful"===(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code)?this.onAuthorizeSuccess():this.onAuthorizeFailed())}})},null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.applePay),{styles:Object.assign(Object.assign({},null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.applePayButton),null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.element)})),this.applePay}createCardPaymentButton(){var e,t;return this.cardPaymentButton||(this.cardPaymentButton=new U(this.sdkConfig,this.execution,{styles:null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.cardPaymentButton,translations:null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.cardPaymentButton,events:this.getElementEvents()},this.clientConfig.returnInfo)),this.cardForm&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardPaymentButton}onAuthorizeSuccess(){var e,t,i,n,s,o;this.subElements.forEach((e=>e.unmount())),new ln({translations:{label:null===(i=null===(t=null===(e=this.dropinConfig)||void 0===e?void 0:e.translations)||void 0===t?void 0:t.paymentResult)||void 0===i?void 0:i.success},styles:null===(s=null===(n=this.dropinConfig)||void 0===n?void 0:n.styles)||void 0===s?void 0:s.authSuccess}).mount(this.selector),(null===(o=this.dropinConfig.events)||void 0===o?void 0:o.onAuthorizeSuccess)&&this.dropinConfig.events.onAuthorizeSuccess()}getElementEvents(){return Object.assign(Object.assign({},this.dropinConfig.events),{onAuthorizeSuccess:this.onAuthorizeSuccess.bind(this),onAuthorizeFailed:this.onAuthorizeFailed.bind(this),onAvailable:()=>{var e;(1===this.totalPaymentOptions||(null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.preselectFirstPaymentOption))&&this.subElements[0].activate()}})}onAuthorizeFailed(e){var t,i,n,s,o;new an({translations:{label:null===(i=null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.paymentResult)||void 0===i?void 0:i.fail},styles:null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.authFailed}).mount(this.selector),null===(o=null===(s=this.dropinConfig.events)||void 0===s?void 0:s.onAuthorizeFailed)||void 0===o||o.call(s,e)}isStoredInstrumentEnabled(e){var t,i,n,s,o,r;switch(e){case C.CARD:return!1!==(null===(i=null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.cards)||void 0===i?void 0:i.showStoredInstruments)||!1!==(null===(s=null===(n=this.dropinConfig.paymentMethodsConfiguration)||void 0===n?void 0:n.cards)||void 0===s?void 0:s.showExistingCards);case C.PAYPAL:case C.GOOGLE_PAY:case C.APPLE_PAY:return!1!==(null===(r=null===(o=this.dropinConfig.paymentMethodsConfiguration)||void 0===o?void 0:o[e])||void 0===r?void 0:r.showStoredInstruments);default:return!1}}applyStyles(){var e;(null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.container)&&Object.assign(this.element.style,this.dropinConfig.styles.container)}}const gn={visa:/^4\d*/,mastercard:/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720)\d*/,amex:/^3[47]\d*/,diners:/^(36|38|30[0-5])\d*/,discover:/^(6011|65|64[4-9]|622)\d*/,jcb:/^35\d*/,hipercard:/^606282\d*/,unionpay:/^62\d*/,maestro:/^(5018|5020|5038|5043|5[6-9]|6020|6304|6703|6759|676[1-3])\d*/};class Rn{constructor(e,t,i){this.sdkConfig=i,this.bin="",this.id="payrails-container-wrapper",this.containerType="COMPOSABLE",this.cardTableName=t.cardTableName||"cards",this.containerType=t.containerType||"COMPOSABLE",this.__container=e.container(this.containerType,t)}static init(e,t,i){return this.instance&&this.instance.__container.unmount(),this.instance=new Rn(e,t,i),this.instance}createCollectElement(t){const i={required:!!t.required,enableCardIcon:!1!==t.enableCardIcon},n=this.__container.create(Object.assign(Object.assign({table:this.cardTableName,labelStyles:{},errorTextStyles:{},column:this.elementToFieldMap.get(t.type)},t),{type:t.type===e.ElementType.CARDHOLDER_NAME?"INPUT_FIELD":t.type}),t.format?Object.assign(Object.assign({},i),{format:t.format}):i);return this.attachCustomEventHandler(n)}mount(e){if("COLLECT"===this.containerType){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw a.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 r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING);throw a.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 t(this,void 0,void 0,(function*(){try{return this.sdkConfig.usePayrailsFrames?yield this.collectPayrailsData():yield this.collectSkyflowData()}catch(e){const t=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CARD_FORM_ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE,{description:"Error collecting data from the iframe!"});throw a.PayrailsLogger.error(t.message,{error:t}),t}}))}collectSkyflowData(){return t(this,void 0,void 0,(function*(){const e=(yield this.__container.collect()).records,{skyflow_id:t,card_number:i,cardholder_name:n,expiry_month:s,expiry_year:o,security_code:r}=e[0].fields;return{instrumentId:t,card_number:i,cardholder_name:n,expiry_month:s,expiry_year:o,security_code:r}}))}collectPayrailsData(){return t(this,void 0,void 0,(function*(){const e=yield this.__container.collect();return Object.assign(Object.assign({},e),{vaultProviderConfigId:this.sdkConfig.vaultConfiguration.providerConfigId})}))}tokenize(e){return t(this,void 0,void 0,(function*(){const t=yield this.collect(),i=this.sdkConfig.vaultConfiguration.links.saveInstrument.href,n=this.sdkConfig.token;if(!i){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND,{description:"Save instrument URL not available!"});throw a.PayrailsLogger.error(e.message,{error:e}),e}const s=yield(({url:e,token:t,body:i})=>p({url:e,token:t,method:_.POST,body:i}))({url:i,token:n,body:this.constructSaveInstrumentBody(t,e)});return s.res}))}constructSaveInstrumentBody(e,t){var i,n;const s={holderReference:this.sdkConfig.holderReference,paymentMethod:"card",storeInstrument:null!==(i=null==t?void 0:t.storeInstrument)&&void 0!==i&&i,futureUsage:null!==(n=null==t?void 0:t.futureUsage)&&void 0!==n?n:"CardOnFile"};return this.sdkConfig.usePayrailsFrames?s.data={encryptedData:e.encryptedData,vaultProviderConfigId:e.vaultProviderConfigId}:s.token={providerId:this.sdkConfig.vaultConfiguration.providerId,providerConfigId:this.sdkConfig.vaultConfiguration.providerConfigId,reference:e.instrumentId,type:"card",meta:{skyflow_id:e.instrumentId,card_number:e.card_number,cardholder_name:e.cardholder_name,expiry_month:e.expiry_month,expiry_year:e.expiry_year,security_code:e.security_code}},s}attachCustomEventHandler(t){return new Proxy(t,{get:(t,i)=>"on"!==i?t[i]:((n,s)=>{t[i].call(t,n,(t=>{"CHANGE"===n?(t.elementType===e.ElementType.CARD_NUMBER&&(t.network=function(e){for(const[t,i]of Object.entries(gn))if(i.test(e))return t;return""}(t.value),t.bin=this.formatBin(t.value),this.bin=this.formatBin(t.value)),s(t)):s(t)}))}).bind(t)})}formatBin(e){return e.replace(/-|X/g,"")}get elementToFieldMap(){return new Map([[e.ElementType.CARD_NUMBER,"card_number"],[e.ElementType.CARDHOLDER_NAME,"cardholder_name"],[e.ElementType.CVV,"security_code"],[e.ElementType.EXPIRATION_MONTH,"expiry_month"],[e.ElementType.EXPIRATION_YEAR,"expiry_year"]])}}class Sn{constructor(e,t,i){this.pageId=e,this.execution=t,this.environment=i,this.guid=I().replace(/-/g,""),this.fnclsVal="fnparams-dede7cc5-15fd-4c75-a9f4-36c430ee3a99",this.configId=I(),this.scriptId=I()}mount(){this.loadFraudnet(this.pageId)}unmount(){var e,t;null===(e=document.getElementById(this.configId))||void 0===e||e.remove(),null===(t=document.getElementById(this.scriptId))||void 0===t||t.remove()}loadFraudnet(e){this.unmount();const t=this.createFraudnetConfig(e);document.body.appendChild(t);const i=document.createElement("script");i.setAttribute("id",this.scriptId),i.src="https://c.paypal.com/da/r/fb.js",document.body.appendChild(i)}get payPalConfig(){return this.execution.paypalConfig}createFraudnetConfig(e){const t=document.createElement("script");return t.setAttribute("type","application/json"),t.setAttribute("fncls",this.fnclsVal),t.setAttribute("id",this.configId),t.innerText=JSON.stringify({f:this.guid,s:`${this.payPalConfig.merchantId}_${e}`,sandbox:"TEST"===this.environment}),t}}const Cn=()=>{const e=document.getElementById("sdk-observer");return e||(()=>{const e=document.createElement("iframe");return e.id="sdk-observer",e.src="https://assets.payrails.io/df36830/observability/index.html",e.width="1px",e.height="1px",document.body.appendChild(e),e})()};
|
|
22
22
|
/* @copyright
|
|
23
23
|
Copyright (c) 2023 Payrails (https://www.payrails.com/)
|
|
24
24
|
*/
|
|
25
|
-
class
|
|
25
|
+
class Dn{static init(e,t){var i,n,s,o,l,d,c,u;try{Cn(),a.PayrailsLogger.init({enabled:(null===(i=null==t?void 0:t.telemetry)||void 0===i?void 0:i.enabled)||!0,logLevel:(null===(n=null==t?void 0:t.telemetry)||void 0===n?void 0:n.logLevel)||"error",environment:(null==t?void 0:t.environment)||"TEST",sdk:{name:"web-sdk",version:"5.8.1"}});const r=JSON.parse(atob(e.data)),E=Boolean(r.vaultConfiguration.encryptionPublicKey);a.PayrailsLogger.setState({payrails:{execution_id:null===(s=r.execution)||void 0===s?void 0:s.id,holder_reference:r.holderReference,vault_provider:r.vaultConfiguration.vaultType,merchant_reference:null===(o=r.execution)||void 0===o?void 0:o.merchantReference,frames_type:E?"payrails":"skyflow",workflow:{code:(null===(d=null===(l=r.execution)||void 0===l?void 0:l.workflow)||void 0===d?void 0:d.code)||"",version:(null===(u=null===(c=r.execution)||void 0===c?void 0:c.workflow)||void 0===u?void 0:u.version)||0}}});const{vaultConfiguration:{vaultId:_,vaultUrl:h,token:I},execution:p}=r,f=Mi.init({vaultID:_,vaultURL:h,getBearerToken:()=>Promise.resolve(I),options:{initResponse:e,deserializedData:Object.assign(Object.assign({},r),{usePayrailsFrames:E})}});let v;return p&&(v=new M(p),v.isPaymentMethodAvailable(C.CARD)&&Vi.preloadCardForm()),new Dn(Object.assign(Object.assign({},r),{usePayrailsFrames:E}),f,v,t)}catch(e){const t=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED,{cause:e});throw a.PayrailsLogger.error(t.message,{error:t}),t}}update(e){this.sdkConfiguration.amount=e}collectContainer(e){if("COMPOSABLE"===e.containerType&&!e.layout){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw a.PayrailsLogger.error(e.message,{error:e}),e}return this.__container=Rn.init(this.vaultClient,Object.assign(Object.assign({},e),{cardTableName:this.sdkConfiguration.vaultConfiguration.cardTableName}),this.sdkConfiguration),this.__container}googlePayButton(e){var t;return this.logIntegrationMode("elements"),new mn(this.sdkConfiguration,this.safeExecution,Object.assign({environment:null===(t=this.options)||void 0===t?void 0:t.environment},e))}isGooglePayAvailable(e){var t;return mn.isGooglePayAvailable(this.safeExecution.googlePayConfig,null===(t=this.options)||void 0===t?void 0:t.environment,e)}applePayButton(e){if(this.logIntegrationMode("elements"),!this.execution){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND);throw a.PayrailsLogger.error(e.message,{error:e}),e}return new Xi(this.sdkConfiguration,this.execution,e)}isApplePayAvailable(){return Xi.isApplePayAvailable()}cardList(e){return this.logIntegrationMode("elements"),this.__cardList||(this.__cardList=new on(this.safeExecution,{onCardChange:t=>{this.__cardPaymentButton&&(this.__cardPaymentButton.selectedInstrument=t,this.__cardPaymentButton.setDisabled(!1)),null==e||e.onCardChange(t)}})),this.__cardList}cardForm(e){var t,i;if(this.logIntegrationMode("elements"),!this.__cardForm){const n=this.getContainerLayout(null==e?void 0:e.showCardHolderName);this.__container=this.collectContainer(Object.assign(Object.assign({layout:n,errorTextStyles:{base:{display:"none"}}},null===(t=null==e?void 0:e.styles)||void 0===t?void 0:t.errorTextStyles),{styles:{base:null===(i=null==e?void 0:e.styles)||void 0===i?void 0:i.base}})),this.__cardForm=new Zi(this.__container,Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},null==e?void 0:e.events),{onChange:t=>{var i;this.__cardPaymentButton&&(this.__cardPaymentButton.selectedInstrument=null,this.__cardForm&&this.__cardPaymentButton.setDisabled(!this.__cardForm.isValid)),(null===(i=null==e?void 0:e.events)||void 0===i?void 0:i.onChange)&&e.events.onChange(t)},onFocus:()=>{var t;this.__cardList&&this.__cardList.reset(),this.__cardPaymentButton&&(this.__cardPaymentButton.selectedInstrument=null,this.__cardForm&&this.__cardPaymentButton.setDisabled(!this.__cardForm.isValid)),(null===(t=null==e?void 0:e.events)||void 0===t?void 0:t.onFocus)&&e.events.onFocus()}})}))}return this.__cardPaymentButton&&this.__cardPaymentButton.setCardForm(this.__cardForm),this.__cardForm}dropin(e){var t,i;this.logIntegrationMode("dropin");const n=this.getContainerLayout(null===(i=null===(t=e.paymentMethodsConfiguration)||void 0===t?void 0:t.cards)||void 0===i?void 0:i.showCardHolderName);return this.__container=this.collectContainer({layout:n,errorTextStyles:{base:{display:"none"}}}),this.__dropin=new Ln(this.__container,this.options||{},e,this.safeExecution,this.sdkConfiguration),this.__dropin}getSavedCreditCards(){return this.logIntegrationMode("elements"),this.safeExecution.savedCreditCards}getSavedGooglePayAccounts(){return this.logIntegrationMode("elements"),this.safeExecution.savedGooglePayAccounts}getSavedApplePayAccounts(){return this.logIntegrationMode("elements"),this.safeExecution.savedApplePayAccounts}getStoredInstruments(){return this.logIntegrationMode("elements"),this.safeExecution.storedPaymentInstruments}getAvailablePaymentMethods(){return this.logIntegrationMode("elements"),this.safeExecution.availablePaymentMethods.map((({paymentMethodCode:e})=>e)).filter((e=>!!e))}paymentButton(e){var t;return this.logIntegrationMode("elements"),this.__cardPaymentButton||(this.__cardPaymentButton=new U(this.sdkConfiguration,this.safeExecution,e,(null===(t=this.options)||void 0===t?void 0:t.returnInfo)||{})),this.__cardPaymentButton.setDisabled(!0),this.__cardForm&&this.__cardPaymentButton.setCardForm(this.__cardForm),this.__cardPaymentButton}paypalButton(e){var t;return this.logIntegrationMode("elements"),this.__paypalButton=new Tn(this.sdkConfiguration,this.safeExecution,Object.assign(Object.assign({},e),{fraudNetGuid:(null==e?void 0:e.fraudNetGuid)||(null===(t=this.__fraudNet)||void 0===t?void 0:t.guid)})),this.__paypalButton}genericRedirectButton(e){return this.logIntegrationMode("elements"),this.__genericRedirectButton=new In(this.sdkConfiguration,this.safeExecution,Object.assign({},e)),this.__genericRedirectButton}getSavedPaypalAccounts(){return this.logIntegrationMode("elements"),this.safeExecution.savedPaypalAccounts||[]}fraudNet(t){var i;return this.__fraudNet||(this.__fraudNet=new Sn(t,this.safeExecution,(null===(i=this.options)||void 0===i?void 0:i.environment)||e.PayrailsEnvironment.TEST)),this.__paypalButton&&(this.__paypalButton.fraudNetGuid=this.__fraudNet.guid),this.__fraudNet}get safeExecution(){if(!this.execution){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND);throw a.PayrailsLogger.error(e.message,{error:e}),e}return this.execution}logIntegrationMode(e){a.PayrailsLogger.setState({sdk:{integration_mode:e}})}constructor(e,t,i,n){var s;this.sdkConfiguration=e,this.vaultClient=t,this.execution=i,this.options=n,(null===(s=null==n?void 0:n.events)||void 0===s?void 0:s.onClientInitialized)&&n.events.onClientInitialized(this.execution)}getContainerLayout(e){return e?[1,1,3]:[1,3]}}var bn;Dn.preloadCardForm=Vi.preloadCardForm,e.PayrailsEnvironment=void 0,(bn=e.PayrailsEnvironment||(e.PayrailsEnvironment={})).TEST="TEST",bn.PRODUCTION="PRODUCTION",e.Payrails=Dn,window.Payrails=Dn}({});
|