@payrails/web-sdk 2.8.0 → 3.0.0-RC.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 +2 -1
- package/payrails.d.ts +32 -80
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
!function(){"use strict";function e(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{l(n.next(e))}catch(e){s(e)}}function a(e){try{l(n.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}l((n=n.apply(e,t||[])).next())}))}function t(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)}function i(e,t,i,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,i):o?o.value=i:t.set(e,i),i}let n;exports.ElementType=void 0,function(e){e.CARD_NUMBER="CARD_NUMBER",e.CARDHOLDER_NAME="CARDHOLDER_NAME",e.CVV="CVV",e.EXPIRATION_MONTH="EXPIRATION_MONTH",e.EXPIRATION_YEAR="EXPIRATION_YEAR"}(exports.ElementType||(exports.ElementType={})),"function"==typeof SuppressedError&&SuppressedError;const o=new Uint8Array(16);function s(){if(!n&&(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!n))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(o)}const r=[];for(let e=0;e<256;++e)r.push((e+256).toString(16).slice(1));var a,l={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function d(e,t,i){if(l.randomUUID&&!t&&!e)return l.randomUUID();const n=(e=e||{}).random||(e.rng||s)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){i=i||0;for(let e=0;e<16;++e)t[i+e]=n[e];return t}return function(e,t=0){return(r[e[t+0]]+r[e[t+1]]+r[e[t+2]]+r[e[t+3]]+"-"+r[e[t+4]]+r[e[t+5]]+"-"+r[e[t+6]]+r[e[t+7]]+"-"+r[e[t+8]]+r[e[t+9]]+"-"+r[e[t+10]]+r[e[t+11]]+r[e[t+12]]+r[e[t+13]]+r[e[t+14]]+r[e[t+15]]).toLowerCase()}(n)}!function(e){e.GET="GET",e.POST="POST"}(a||(a={}));const c=({url:t,method:i=a.GET,token:n,body:o})=>e(void 0,void 0,void 0,(function*(){const e={method:i,headers:Object.assign(Object.assign(Object.assign({},u()),I(n)),h())};i===a.POST&&(e.body=JSON.stringify(o||{}));const s=yield fetch(t,e),r=yield s.json();if([401,403].includes(s.status))throw new E(t,i);if(!s.ok)throw new _(t,i,r);return{ok:s.ok,req:Object.assign({url:t},e),res:r}}));class E extends Error{constructor(e,t){super(`[${t}] ${e} unauthorized`)}}class _ extends Error{constructor(e,t,i){super(`[${t}] ${e} unsuccessful`),this.res=i}}const I=e=>({authorization:`Bearer ${e}`}),u=()=>({"x-idempotency-key":d()}),h=()=>({"x-client-version":"2.8.0","x-client-type":"web-sdk"});class p{constructor(e,t,i){this.sdkConfig=e,this.execution=t,this.returnLinks=i}pay(t){return e(this,void 0,void 0,(function*(){const e=(yield this.authorize(t)).res.links.execution;return yield this.pollForAuthorizationResult(e)}))}authorize(t){return e(this,void 0,void 0,(function*(){if(!this.execution.authorizeLink||!this.sdkConfig.amount)throw new Error("SDK was not initialized with workflow execution");const{success:e="https://payrails.io/success",error:i="https://payrails.io/error",cancel:n="https://payrails.io/cancel"}=this.returnLinks||{};return c({url:this.execution.authorizeLink,method:a.POST,token:this.sdkConfig.token,body:{amount:this.sdkConfig.amount,paymentComposition:t,returnInfo:{success:e,cancel:n,error:i}}})}))}confirm(t,i={}){return e(this,void 0,void 0,(function*(){const e=yield c({url:t,method:a.POST,token:this.sdkConfig.token,body:{data:i}}),n=yield this.pollForAuthorizationResult(e.res.links.execution);if(n.finalState)return n;const o=n.response.status.slice().sort(((e,t)=>new Date(t.time).getTime()-new Date(e.time).getTime()))[0].time,{res:s}=yield this.getExecution(e.res.links.execution,void 0,o);return{finalState:s.status.find((({code:e,time:t})=>["authorizeSuccessful","authorizeFailed"].includes(e)&&new Date(t)>new Date(o))),response:s}}))}pollForAuthorizationResult(t,i=0){return e(this,void 0,void 0,(function*(){const e=(yield this.getExecution(t)).res,n=e.status,o=["authorizePending","authorizeSuccessful","authorizeFailed"],s=n.find((({code:e})=>"authorizeRequested"===e));if(!s&&i<10)return yield new Promise((e=>setTimeout(e,300))),this.pollForAuthorizationResult(t,i+1);if(!s)throw new Error("Authorization was not requested");const r=n.find((({code:e,time:t})=>"confirmRequested"===e&&new Date(t)>new Date(s.time))),a=r?r.time:s.time;let l=n.find((({code:e,time:t})=>o.includes(e)&&new Date(t)>new Date(a)));if(!l){const{res:e}=yield this.getExecution(t,void 0,a);return l=e.status.find((({code:e,time:t})=>o.includes(e)&&new Date(t)>new Date(a))),{finalState:l,response:e}}return{finalState:l,response:e}}))}getExecution(t,i,n){return e(this,void 0,void 0,(function*(){const e=new URLSearchParams;i&&i.length>0&&e.append("waitWhile[status]",`[${i.map((e=>`"${e}"`)).join(",")}]`),n&&e.append("waitWhile[lastStatusTime]",n);const o=`${t}${e.toString()?"?":""}${e.toString()}`;return c({url:o,token:this.sdkConfig.token})}))}createApplePaySession(t){return e(this,void 0,void 0,(function*(){return c({url:t.requestUrl,method:a.POST,token:this.sdkConfig.token,body:{integrationType:"api",paymentMethodCode:"applePay",amount:this.sdkConfig.amount,meta:{sessionURL:t.sessionUrl,clientDomain:t.clientDomain||window.location.host}}})}))}}var f,N,T;!function(e){e.CARD="card",e.GOOGLE_PAY="googlePay",e.PAYPAL="payPal",e.APPLE_PAY="applePay"}(f||(f={})),function(e){e.ENABLED="enabled",e.CREATED="created"}(N||(N={}));class v{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(f.CARD)}get savedPaypalAccounts(){return this.getStoredInstrumentForPaymentMethod(f.PAYPAL)}get savedGooglePayAccounts(){return this.getStoredInstrumentForPaymentMethod(f.GOOGLE_PAY)}get savedApplePayAccounts(){return this.getStoredInstrumentForPaymentMethod(f.APPLE_PAY)}get paypalConfig(){const e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===f.PAYPAL));if(!e)throw new Error("trying to initialize paypal without config");return e.config||{}}get googlePayConfig(){const e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===f.GOOGLE_PAY));if(!e)throw new Error("trying to initialize google pay without config");return e?[e.config]:[]}isPaymentMethodAvailable(e){return this.availablePaymentMethods.some((({paymentMethodCode:t})=>t===e))}get applePayConfig(){const e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===f.APPLE_PAY));if(!e)throw new Error("apple pay config not found");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(){return this.response.links.startPaymentSession.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 O{constructor(e,{id:t="",className:i=""}={}){this.subElements=[];const n=document.createElement(e);t&&(this.id=t,n.setAttribute("id",t)),i&&n.setAttribute("class",i),this.element=n}get parentElement(){return this.element.parentElement}get selector(){if(!this.id)throw new Error("Element id is not set");return`#${this.id}`}mount(e){const t=document.querySelector(e);if(!t)throw new Error(`Element with selector "${e}" not found in in the DOM`);t.appendChild(this.element),this.subElements.forEach((e=>{if(!this.id)throw new Error("Sub elements can not be rendered, please set id for the element");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 L extends O{get bin(){var e;return this.selectedInstrument?this.selectedInstrument.data.bin?this.selectedInstrument.data.bin:"":(null===(e=this.cardForm)||void 0===e?void 0:e.bin)||""}constructor(e,t,i,n){var o;super("button",{id:"payrails-card-payment-button"}),this.sdkConfig=e,this.execution=t,this.options=i,this.returnLinks=n,this.selectedInstrument=null,this.element.innerText=(null===(o=null==i?void 0:i.translations)||void 0===o?void 0:o.label)||"Pay",this.element.addEventListener("click",this.onPay.bind(this)),this.element.addEventListener("mouseenter",(()=>{var e;this.element.classList.contains("disabled")||(this.element.classList.add("hover"),this.setStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{}))})),this.element.addEventListener("mouseleave",(()=>{var e;this.element.classList.contains("disabled")||(this.element.classList.remove("hover"),this.removeStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{}))})),this.paymentExecutor=new p(this.sdkConfig,this.execution,this.returnLinks)}setDisabled(e){var t,i,n,o,s;this.element.classList.contains("disabled")!==e&&(null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onStateChanged)||void 0===i||i.call(t,e?"disabled":"enabled")),this.element.disabled=e,e?(this.element.classList.add("disabled"),(null===(n=this.options.styles)||void 0===n?void 0:n.disabled)&&this.setStyles(this.options.styles.disabled)):(this.element.classList.remove("disabled"),this.removeStyles((null===(o=this.options.styles)||void 0===o?void 0:o.disabled)||{}),(null===(s=this.options.styles)||void 0===s?void 0:s.base)&&this.setStyles(this.options.styles.base))}setSavedCreditCard(e){console.warn("setSavedCreditCard is deprecated, please use setSavedInstrument"),this.setSavedInstrument(e)}setSavedInstrument(e){this.selectedInstrument=e,this.setDisabled(!1)}setStyles(e){var t;const i=Object.assign(Object.assign({},null===(t=this.options.styles)||void 0===t?void 0:t.base),e);Object.keys(i).forEach((e=>{this.element.style[e]=i[e]}))}removeStyles(e){var t;const i=Object.keys((null===(t=this.options.styles)||void 0===t?void 0:t.base)||{});Object.keys(e).forEach((e=>{var t,n;i.includes(e)?this.element.style[e]=null===(n=null===(t=this.options.styles)||void 0===t?void 0:t.base)||void 0===n?void 0:n[e]:this.element.style[e]=""}))}setLabel(e){this.element.innerText=e}setCardForm(e){this.cardForm=e}triggerLoading(e){var t,i,n,o;const s=this.element.offsetWidth;this.element.style.minWidth=`${s}px`,e?(this.element.innerHTML='<div class="dot-flashing"></div>',this.element.classList.add("loading"),(null===(t=this.options.styles)||void 0===t?void 0:t.loading)&&this.setStyles(this.options.styles.loading)):(this.element.innerText=(null===(n=null===(i=this.options)||void 0===i?void 0:i.translations)||void 0===n?void 0:n.label)||"Pay",this.element.classList.remove("loading"),this.removeStyles((null===(o=this.options.styles)||void 0===o?void 0:o.loading)||{}))}onAuthorizationFailed(e){var t,i;this.setDisabled(!1),this.triggerLoading(!1),(null===(t=this.options.events)||void 0===t?void 0:t.onAuthorizeFailed)&&(null===(i=this.options.events)||void 0===i||i.onAuthorizeFailed(e))}onPay(){var t,i,n,o,s,r,a,l,d,c;return e(this,void 0,void 0,(function*(){if(this.setDisabled(!0),this.triggerLoading(!0),null===(t=this.options.events)||void 0===t?void 0:t.onPaymentButtonClicked)try{if(!1===(yield null===(i=this.options.events)||void 0===i?void 0:i.onPaymentButtonClicked({bin:this.bin||""})))return void this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:"Callback passed to onPaymentButtonClicked resolved to false"})}catch(e){return void this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:"Callback passed to onPaymentButtonClicked threw an error"})}try{const e=[{paymentMethodCode:f.CARD,integrationType:"api",amount:this.sdkConfig.amount,storeInstrument:!1}];if(null===(n=this.selectedInstrument)||void 0===n?void 0:n.id)e[0].paymentInstrumentId=null===(o=this.selectedInstrument)||void 0===o?void 0:o.id,e[0].paymentMethodCode=null===(s=this.selectedInstrument)||void 0===s?void 0:s.paymentMethod;else{const{tokenizedCardData:t,storeInstrument:i,enrollInstrumentToNetworkOffers:n}=yield this.collectCardFormValues();e[0].paymentInstrumentData={vaultToken:null==t?void 0:t.instrumentId,card:{numberToken:null==t?void 0:t.card_number,securityCodeToken:null==t?void 0:t.security_code}},e[0].storeInstrument=i,e[0].enrollInstrumentToNetworkOffers=n}const t=yield this.paymentExecutor.pay(e);this.handleAuthorizationResult(t)}catch(e){e instanceof E||[401,403].includes(null===(r=null==e?void 0:e.error)||void 0===r?void 0:r.code)?(null===(l=null===(a=this.options.events)||void 0===a?void 0:a.onPaymentSessionExpired)||void 0===l||l.call(a),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:"API token is not valid or expired."})):e.toString().includes("Invalid token")?(null===(c=null===(d=this.options.events)||void 0===d?void 0:d.onPaymentSessionExpired)||void 0===c||c.call(d),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:"Vault token is not valid or expired."})):this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.UNKNOWN_ERROR,message:e.toString(),rawError:e})}}))}handleAuthorizationResult(e){var t,i,n;switch(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code){case"authorizeSuccessful":this.triggerLoading(!1),(null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeSuccess)&&this.options.events.onAuthorizeSuccess();break;case"authorizePending":"3ds"===(null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.actionRequired)&&this.handle3ds(e);break;default:this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:"Authorization failed."})}}handle3ds(t){var i,n,o,s;try{null===(n=null===(i=this.options.events)||void 0===i?void 0:i.onThreeDSecureChallenge)||void 0===n||n.call(i)}catch(e){}const r=null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.links["3ds"];if(r){const t=[[250,400],[390,400],[500,600],[600,400]],i=screen.width,n=t.reduce(((e,t)=>i>t[0]?t:e),[250,400]),o=document.createElement("iframe");o.setAttribute("id","payrails-3ds-frame"),o.setAttribute("src",r),o.setAttribute("width",n[0].toString()),o.setAttribute("height",n[1].toString());const a=document.createElement("div");a.setAttribute("id","payrails-3ds-challenge"),a.appendChild(o);const l=document.createElement("div");l.addEventListener("click",(()=>e(this,void 0,void 0,(function*(){l.remove()})))),l.setAttribute("id","payrails-3ds-popup-background"),l.appendChild(a);const d=t=>e(this,void 0,void 0,(function*(){var e,i,n;if(t.data&&'{"type":"3DS-challenge-completed"}'===t.data){window.removeEventListener("message",d),l.remove();if(!(yield this.paymentExecutor.getExecution(this.execution.url)).res.status.find((({code:e})=>"authorizeSuccessful"===e))&&(null===(e=this.options.events)||void 0===e?void 0:e.onAuthorizeFailed))return void this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:"Authorization failed after 3DS challenge."});if(null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeSuccess)return void(null===(n=this.options.events)||void 0===n||n.onAuthorizeSuccess())}}));null===(s=document.querySelector("body"))||void 0===s||s.appendChild(l),window.addEventListener("message",d),a.style.width=`${n[0]+4}px`,a.style.height=`${n[1]+4}px`}}collectCardFormValues(){return e(this,void 0,void 0,(function*(){if(!this.cardForm)throw new Error("Trying to collect values from non-existent card form");return yield this.cardForm.collectValues()}))}}exports.AuthorizationFailureReasons=void 0,(T=exports.AuthorizationFailureReasons||(exports.AuthorizationFailureReasons={})).VALIDATION_FAILED="VALIDATION_FAILED",T.AUTHORIZATION_ERROR="AUTHORIZATION_ERROR",T.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",T.UNKNOWN_ERROR="UNKNOWN_ERROR";var m="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function A(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var R={},y={},D={};Object.defineProperty(D,"__esModule",{value:!0}),D.isntString=void 0,D.isntString=function(e){return"string"!=typeof e};var S={},g={};Object.defineProperty(g,"__esModule",{value:!0}),g.subscribers=g.childWindows=g.prefix=void 0,g.prefix="/*framebus*/",g.childWindows=[],g.subscribers={};var C={},b={},w={},M={};Object.defineProperty(M,"__esModule",{value:!0}),M.subscriptionArgsInvalid=void 0;var P=D;M.subscriptionArgsInvalid=function(e,t,i){return!!P.isntString(e)||("function"!=typeof t||P.isntString(i))};var U={},V={};Object.defineProperty(V,"__esModule",{value:!0}),V.hasOpener=void 0,V.hasOpener=function(e){return e.top===e&&(null!=e.opener&&(e.opener!==e&&!0!==e.opener.closed))},Object.defineProperty(U,"__esModule",{value:!0}),U.broadcast=void 0;var k,Y=V;function x(){if(k)return w;k=1,Object.defineProperty(w,"__esModule",{value:!0}),w.Framebus=void 0;var e=D,t=M,i=U,n=j(),o=g,s=function(){function s(e){void 0===e&&(e="*"),this.origin=e}return s.target=function(e){return void 0===e&&(e="*"),new s(e)},s.prototype.include=function(e){return null!=e&&(null!=e.Window&&(e.constructor===e.Window&&(o.childWindows.push(e),!0)))},s.prototype.target=function(e){return s.target(e)},s.prototype.emit=function(t,o,s){var r=this.origin;if(e.isntString(t))return!1;if(e.isntString(r))return!1;"function"==typeof o&&(s=o,o=void 0);var a=n.packagePayload(t,r,o,s);return!!a&&(i.broadcast(window.top||window.self,a,r),!0)},s.prototype.on=function(e,i){var n=this.origin;return!t.subscriptionArgsInvalid(e,i,n)&&(o.subscribers[n]=o.subscribers[n]||{},o.subscribers[n][e]=o.subscribers[n][e]||[],o.subscribers[n][e].push(i),!0)},s.prototype.off=function(e,i){var n=this.origin;if(t.subscriptionArgsInvalid(e,i,n))return!1;var s=o.subscribers[n]&&o.subscribers[n][e];if(!s)return!1;for(var r=0;r<s.length;r++)if(s[r]===i)return s.splice(r,1),!0;return!1},s}();return w.Framebus=s,w}U.broadcast=function e(t,i,n){var o,s=0;try{for(t.postMessage(i,n),Y.hasOpener(t)&&e(t.opener.top,i,n);o=t.frames[s];)e(o,i,n),s++}catch(e){}};var B,F,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)}))};function j(){if(F)return C;F=1,Object.defineProperty(C,"__esModule",{value:!0}),C.packagePayload=void 0;var e=function(){if(B)return b;B=1;var e=m&&m.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(b,"__esModule",{value:!0}),b.subscribeReplier=void 0;var t=x(),i=e(G);return b.subscribeReplier=function(e,n){var o=i.default();return t.Framebus.target(n).on(o,(function i(s,r){e(s,r),t.Framebus.target(n).off(o,i)})),o},b}(),t=g;return C.packagePayload=function(i,n,o,s){var r,a={event:i,origin:n};"function"==typeof s&&(a.reply=e.subscribeReplier(s,n)),a.eventData=o;try{r=t.prefix+JSON.stringify(a)}catch(e){throw new Error("Could not stringify event: "+e.message)}return r},C}Object.defineProperty(S,"__esModule",{value:!0}),S.unpackPayload=void 0;var X=g,$=j();S.unpackPayload=function(e){var t;if(e.data.slice(0,X.prefix.length)!==X.prefix)return!1;try{t=JSON.parse(e.data.slice(X.prefix.length))}catch(e){return!1}if(t.reply){var i=e.origin,n=e.source,o=t.reply;t.reply=function(e){if(n){var t=$.packagePayload(o,i,e);t&&n.postMessage(t,i)}}}return t};var W={};Object.defineProperty(W,"__esModule",{value:!0}),W.dispatch=void 0;var K=g;W.dispatch=function(e,t,i,n,o){if(K.subscribers[e]&&K.subscribers[e][t]){var s=[];i&&s.push(i),n&&s.push(n);for(var r=0;r<K.subscribers[e][t].length;r++)K.subscribers[e][t][r].apply(o,s)}};var z={};Object.defineProperty(z,"__esModule",{value:!0}),z.broadcastToChildWindows=void 0;var H=U,q=g;z.broadcastToChildWindows=function(e,t,i){for(var n=q.childWindows.length-1;n>=0;n--){var o=q.childWindows[n];o.closed?q.childWindows.splice(n,1):i!==o&&H.broadcast(o.top,e,t)}},Object.defineProperty(y,"__esModule",{value:!0}),y.onmessage=void 0;var J=D,Z=S,Q=W,ee=z;y.onmessage=function(e){if(!J.isntString(e.data)){var t=Z.unpackPayload(e);if(t){var i=t.eventData,n=t.reply;Q.dispatch("*",t.event,i,n,e),Q.dispatch(e.origin,t.event,i,n,e),ee.broadcastToChildWindows(e.data,t.origin,e.source)}}},Object.defineProperty(R,"__esModule",{value:!0}),R.detach=R.attach=void 0;var te=y,ie=!1;R.attach=function(){ie||"undefined"==typeof window||(ie=!0,window.addEventListener("message",te.onmessage,!1))},R.detach=function(){ie=!1,window.removeEventListener("message",te.onmessage,!1)};var ne=R,oe=new(x().Framebus);ne.attach();var se=A(oe);const re={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.",CREATE_REVEAL_CONTAINER:"%s1 - Creating Reveal container.",REVEAL_CONTAINER_CREATED:"%s1 - Created Reveal 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.",VALIDATE_REVEAL_RECORDS:"%s1 - Validating reveal element input.",CREATED_ELEMENT:"%s1 - Created %s2 element.",ELEMENT_MOUNTED:"%s1 - %s2 Element mounted.",ELEMENT_REVEALED:"%s1 - %s2 Element revealed.",COLLECT_SUBMIT_SUCCESS:"%s1 - Data has been collected successfully.",REVEAL_SUBMIT_SUCCESS:"%s1 - Data has been revealed successfully.",INSERT_DATA_SUCCESS:"%s1 - Data has been inserted successfully.",DETOKENIZE_SUCCESS:"%s1 - Data has been revealed successfully.",GET_SUCCESS:"%s1 - Data has been revealed 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",REVEAL_ELEMENT_START:"%s1 - %s2, Reveal Element 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."},ae={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_REDACTION_TYPE_IN_DETOKENIZE:"Interface: client get - Invalid redaction type in records array at index %s1",EMPTY_RECORDS_REVEAL:"Interface: reveal container - cannot invoke reveal method before creating reveal elements",MISSING_TOKEN_KEY_REVEAL:"Interface: RevealElement - token key is required ",INVALID_TOKEN_ID_REVEAL:"Interface: RevealElement - token is invalid. token of type string is required",INVALID_LABEL_REVEAL:"Interface: RevealElement - label is invalid.",INVALID_ALT_TEXT_REVEAL:"Interface: RevealElement - Invalid altText.",INVALID_FORMAT_REVEAL:"Interface: RevealElement - Invalid format type.",EMPTY_FORMAT_REVEAL:"Interface: RevealElement - Empty format value provided.",INVALID_FORMAT_VALUE_REVEAL:"Interface: RevealElement - Invalid format value provided.",INVALID_REDACTION_TYPE_REVEAL:"Interface: RevealElement - Invalid Redaction type.",ELEMENTS_NOT_MOUNTED_REVEAL:"Interface: reveal container - Cannot invoke reveal before mounting the elements",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",EMPTY_TOKEN_ID_REVEAL:"Interface: RevealElement - token cannot be empty",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.",FAILED_REVEAL:"Interface: reveal conatiner - Failed to reveal data",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.',MISSING_SKYFLOWID_IN_COLLECT:'Interface: collect element - "skyflowID" key is required in file type element',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",REVEAL_ELEMENT_ERROR_STATE:"unable to reveal, since one or more element(s) have setError",INVALID_FILE_TYPE:"Interface: collect element - Invalid File Type",INVALID_FILE_SIZE:"Interface: collect element - Invalid File Size",NO_FILE_SELECTED:"Interface: collect element - No File Selected",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."},le={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."},de="collect_controller",ce="reveal_controller",Ee="element",_e="INSERT",Ie="DETOKENIZE",ue="GET_BY_SKYFLOWID",he="GET",pe="DELETE",fe={CHANGE:"CHANGE",READY:"READY",FOCUS:"FOCUS",BLUR:"BLUR",ESCAPE:"ESCAPE",CLICK:"CLICK",ERROR:"ERROR",SUCCESS:"SUCCESS",SUBMIT:"SUBMIT",CREATED:"CREATED",MOUNTED:"MOUNTED"},Ne="FRAME_READY",Te="TOKENIZATION_REQUEST",ve="INPUT_EVENT",Oe="DESTROY FRAME",Le="SET_VALUE",me="REVEAL_REQUEST",Ae="REVEAL_FRAME_READY",Re="PUREJS_REQUEST",ye="PUREJS_FRAME_READY",De="GET_BEARER_TOKEN",Se="COLLECT_ELEMENT_SET_ERROR",ge="REVEAL_ELEMENT_SET_ERROR",Ce="REVEAL_ELEMENT_UPDATE_OPTIONS",be="FILE_UPLOAD",we="COMPOSABLE_UPDATE_OPTIONS",Me="TOKEN",Pe="ALT_TEXT",Ue="ELEMENT_MOUNTED",Ve="ALL_ELEMENTS_MOUNTED",ke="COMPOSABLE_CONTAINER_MOUNTED",Ye="COLLECT_CONTAINER_MOUNTED",xe="REVEAL_CONTAINER_MOUNTED";var Be,Fe;!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",e.FILE_INPUT="FILE_INPUT"}(Be||(Be={})),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"}(Fe||(Fe={}));const Ge={[Fe.AMEX]:["XXXX XXXXXX XXXXX",{X:"[0-9]"}],[Fe.VISA]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[Fe.MASTERCARD]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[Fe.DISCOVER]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Fe.DINERS_CLUB]:["XXXX XXXXXX XXXXXX",{X:"[0-9]"}],[Fe.JCB]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Fe.MAESTRO]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Fe.UNIONPAY]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Fe.HIPERCARD]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Fe.DEFAULT]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Fe.UNKNOWN]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}]},je={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},[Be.CARDHOLDER_NAME]:{name:"cardHolderName",attributes:{type:"text",autocomplete:"cc-name"},sensitive:!0,regex:/^([a-zA-Z\\ \\,\\.\\-\\']{2,})$/},[Be.CARD_NUMBER]:{name:"CARD_NUMBER",attributes:{type:"text",autocomplete:"cc-number",inputmode:"numeric"},sensitive:!0,mask:Ge[Fe.DEFAULT],regex:/$|^[\s]*?([0-9]{2,6}[ -]?){3,5}[\s]*/},[Be.EXPIRATION_DATE]:{name:"EXPIRATION_DATE",attributes:{type:"text",autocomplete:"cc-exp",inputmode:"numeric"},sensitive:!0},[Be.EXPIRATION_MONTH]:{name:"EXPIRATION_MONTH",attributes:{maxLength:2,type:"text",inputmode:"numeric",autocomplete:"cc-exp-month"},sensitive:!0,mask:["XX",{X:"[0-9]"}]},[Be.EXPIRATION_YEAR]:{name:"EXPIRATION_YEAR",attributes:{maxLength:4,type:"text",inputmode:"numeric",autocomplete:"cc-exp-year"},sensitive:!0},[Be.CVV]:{name:"CVV",attributes:{type:"text",inputmode:"numeric",maxLength:4},sensitive:!0,regex:/^$|^[0-9]{3,4}$/},[Be.INPUT_FIELD]:{name:"INPUT_FIELD",sensitive:!0,attributes:{type:"text"}},[Be.PIN]:{name:"PIN",attributes:{type:"text",inputmode:"numeric",maxLength:12,minLength:4},sensitive:!0,regex:/^$|^[0-9]{4,12}$/},[Be.FILE_INPUT]:{name:"FILE_INPUT",sensitive:!0,attributes:{type:"file"}}},Xe="XXXX-XXXX-XXXX-XXXX",$e={height:"100%",width:"100%",margin:0,padding:0,border:0,position:"absolute",top:0,left:0,"user-select":"none"},We={position:"absolute",top:0,width:0,height:0,visibility:"hidden",left:"-99999999px","user-select":"none"},Ke={width:"100%",height:"100%",border:"0",padding:"0",margin:"0",outline:"none"},ze={WEBPACKAUTOFILL:"-webkit-autofill",BASE:"base",FOCUS:"focus",COMPLETE:"complete",EMPTY:"empty",INVALID:"invalid",GLOBAL:"global",REQUIRED_ASTERISK:"requiredAsterisk"};ze.BASE,ze.BASE,ze.BASE,ze.REQUIRED_ASTERISK;const He={[Fe.VISA]:{regex:/^4\d*/,maxCardLength:19,cardLengthRange:[13,16]},[Fe.MASTERCARD]:{regex:/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720)\d*/,maxCardLength:16,cardLengthRange:[16]},[Fe.AMEX]:{regex:/^3[47]\d*/,maxCardLength:15,cardLengthRange:[15]},[Fe.DINERS_CLUB]:{regex:/^(36|38|30[0-5])\d*/,maxCardLength:16,cardLengthRange:[14,15,16,17,18,19]},[Fe.DISCOVER]:{regex:/^(6011|65|64[4-9]|622)\d*/,maxCardLength:16,cardLengthRange:[16,17,18,19]},[Fe.JCB]:{regex:/^35\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[Fe.HIPERCARD]:{regex:/^606282\d*/,maxCardLength:19,cardLengthRange:[14,15,16,17,18,19]},[Fe.UNIONPAY]:{regex:/^62\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[Fe.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]}};Fe.DEFAULT,Fe.AMEX,Fe.DINERS_CLUB,Fe.DISCOVER,Fe.HIPERCARD,Fe.JCB,Fe.MAESTRO,Fe.MASTERCARD,Fe.UNIONPAY,Fe.VISA;const qe="MM/YY",Je=[qe,"YYYY/MM","YY/MM","MM/YYYY"],Ze=["YY","YYYY"];var Qe;!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"}(Qe||(Qe={})),Be.CARD_NUMBER,Be.EXPIRATION_DATE,Be.EXPIRATION_MONTH,Be.EXPIRATION_YEAR,Be.CVV,Be.EXPIRATION_DATE,Be.CARD_NUMBER,Be.CARDHOLDER_NAME,Be.INPUT_FIELD,ae.INVALID_COLLECT_VALUE,Be.PIN,Be.EXPIRATION_MONTH,Be.EXPIRATION_YEAR,Be.FILE_INPUT,ae.INVALID_COLLECT_VALUE,Be.CVV,Be.EXPIRATION_DATE,Be.CARD_NUMBER,Be.CARDHOLDER_NAME,Be.INPUT_FIELD,ae.DEFAULT_REQUIRED_COLLECT_VALUE,Be.PIN,Be.EXPIRATION_MONTH,Be.EXPIRATION_YEAR,Be.FILE_INPUT,ae.DEFAULT_REQUIRED_COLLECT_VALUE;const et=[Be.CARDHOLDER_NAME,Be.EXPIRATION_MONTH,Be.FILE_INPUT,Be.PIN,Be.CVV],tt={X:"[0-9]"};class it{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(it.prototype,{constructor:e})}}
|
|
1
|
+
!function(){"use strict";function e(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{l(n.next(e))}catch(e){s(e)}}function a(e){try{l(n.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}l((n=n.apply(e,t||[])).next())}))}function t(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)}function i(e,t,i,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,i):o?o.value=i:t.set(e,i),i}let n;exports.ElementType=void 0,function(e){e.CARD_NUMBER="CARD_NUMBER",e.CARDHOLDER_NAME="CARDHOLDER_NAME",e.CVV="CVV",e.EXPIRATION_MONTH="EXPIRATION_MONTH",e.EXPIRATION_YEAR="EXPIRATION_YEAR"}(exports.ElementType||(exports.ElementType={})),"function"==typeof SuppressedError&&SuppressedError;const o=new Uint8Array(16);function s(){if(!n&&(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!n))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(o)}const r=[];for(let e=0;e<256;++e)r.push((e+256).toString(16).slice(1));var a,l={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function d(e,t,i){if(l.randomUUID&&!t&&!e)return l.randomUUID();const n=(e=e||{}).random||(e.rng||s)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){i=i||0;for(let e=0;e<16;++e)t[i+e]=n[e];return t}return function(e,t=0){return r[e[t+0]]+r[e[t+1]]+r[e[t+2]]+r[e[t+3]]+"-"+r[e[t+4]]+r[e[t+5]]+"-"+r[e[t+6]]+r[e[t+7]]+"-"+r[e[t+8]]+r[e[t+9]]+"-"+r[e[t+10]]+r[e[t+11]]+r[e[t+12]]+r[e[t+13]]+r[e[t+14]]+r[e[t+15]]}(n)}!function(e){e.GET="GET",e.POST="POST"}(a||(a={}));const c=({url:t,method:i=a.GET,token:n,body:o})=>e(void 0,void 0,void 0,(function*(){const e={method:i,headers:Object.assign(Object.assign(Object.assign({},I()),_(n)),h())};i===a.POST&&(e.body=JSON.stringify(o||{}));const s=yield fetch(t,e),r=yield s.json();if([401,403].includes(s.status))throw new E(t,i);if(!s.ok)throw new u(t,i,r);return{ok:s.ok,req:Object.assign({url:t},e),res:r}}));class E extends Error{constructor(e,t){super(`[${t}] ${e} unauthorized`)}}class u extends Error{constructor(e,t,i){super(`[${t}] ${e} unsuccessful`),this.res=i}}const _=e=>({authorization:`Bearer ${e}`}),I=()=>({"x-idempotency-key":d()}),h=()=>({"x-client-version":"3.0.0-RC.1","x-client-type":"web-sdk"});class p{constructor(e,t,i){this.sdkConfig=e,this.execution=t,this.returnLinks=i}pay(t){return e(this,void 0,void 0,(function*(){const e=(yield this.authorize(t)).res.links.execution;return yield this.pollForAuthorizationResult(e)}))}authorize(t){return e(this,void 0,void 0,(function*(){if(!this.execution.authorizeLink||!this.sdkConfig.amount)throw new Error("SDK was not initialized with workflow execution");const{success:e="https://payrails.io/success",error:i="https://payrails.io/error",cancel:n="https://payrails.io/cancel"}=this.returnLinks||{};return c({url:this.execution.authorizeLink,method:a.POST,token:this.sdkConfig.token,body:{amount:this.sdkConfig.amount,paymentComposition:t,returnInfo:{success:e,cancel:n,error:i}}})}))}confirm(t,i={}){return e(this,void 0,void 0,(function*(){const e=yield c({url:t,method:a.POST,token:this.sdkConfig.token,body:{data:i}}),n=yield this.pollForAuthorizationResult(e.res.links.execution);if(n.finalState)return n;const o=n.response.status.slice().sort(((e,t)=>new Date(t.time).getTime()-new Date(e.time).getTime()))[0].time,{res:s}=yield this.getExecution(e.res.links.execution,void 0,o);return{finalState:s.status.find((({code:e,time:t})=>["authorizeSuccessful","authorizeFailed"].includes(e)&&new Date(t)>new Date(o))),response:s}}))}pollForAuthorizationResult(t,i=0){return e(this,void 0,void 0,(function*(){const e=(yield this.getExecution(t)).res,n=e.status,o=["authorizePending","authorizeSuccessful","authorizeFailed"],s=n.find((({code:e})=>"authorizeRequested"===e));if(!s&&i<10)return yield new Promise((e=>setTimeout(e,300))),this.pollForAuthorizationResult(t,i+1);if(!s)throw new Error("Authorization was not requested");const r=n.find((({code:e,time:t})=>"confirmRequested"===e&&new Date(t)>new Date(s.time))),a=r?r.time:s.time;let l=n.find((({code:e,time:t})=>o.includes(e)&&new Date(t)>new Date(a)));if(!l){const{res:e}=yield this.getExecution(t,void 0,a);return l=e.status.find((({code:e,time:t})=>o.includes(e)&&new Date(t)>new Date(a))),{finalState:l,response:e}}return{finalState:l,response:e}}))}getExecution(t,i,n){return e(this,void 0,void 0,(function*(){const e=new URLSearchParams;i&&i.length>0&&e.append("waitWhile[status]",`[${i.map((e=>`"${e}"`)).join(",")}]`),n&&e.append("waitWhile[lastStatusTime]",n);const o=`${t}${e.toString()?"?":""}${e.toString()}`;return c({url:o,token:this.sdkConfig.token})}))}createApplePaySession(t){return e(this,void 0,void 0,(function*(){return c({url:t.requestUrl,method:a.POST,token:this.sdkConfig.token,body:{integrationType:"api",paymentMethodCode:"applePay",amount:this.sdkConfig.amount,meta:{sessionURL:t.sessionUrl,clientDomain:t.clientDomain||window.location.host}}})}))}}var N,f,T;!function(e){e.CARD="card",e.GOOGLE_PAY="googlePay",e.PAYPAL="payPal",e.APPLE_PAY="applePay"}(N||(N={})),function(e){e.ENABLED="enabled",e.CREATED="created"}(f||(f={}));class v{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(N.CARD)}get savedPaypalAccounts(){return this.getStoredInstrumentForPaymentMethod(N.PAYPAL)}get savedGooglePayAccounts(){return this.getStoredInstrumentForPaymentMethod(N.GOOGLE_PAY)}get savedApplePayAccounts(){return this.getStoredInstrumentForPaymentMethod(N.APPLE_PAY)}get paypalConfig(){const e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===N.PAYPAL));if(!e)throw new Error("trying to initialize paypal without config");return e.config||{}}get googlePayConfig(){const e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===N.GOOGLE_PAY));if(!e)throw new Error("trying to initialize google pay without config");return e?[e.config]:[]}isPaymentMethodAvailable(e){return this.availablePaymentMethods.some((({paymentMethodCode:t})=>t===e))}get applePayConfig(){const e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===N.APPLE_PAY));if(!e)throw new Error("apple pay config not found");return e.config.parameters}get url(){return this.response.links.self}get response(){return this.executionResponse}get meta(){return this.executionResponse.meta}get availablePaymentMethods(){var e;return(null===(e=this.lookup)||void 0===e?void 0:e.body.data.paymentCompositionOptions)||[]}get authorizeLink(){var e;return null===(e=this.lookup)||void 0===e?void 0:e.body.links.authorize.href}get createSessionLink(){var e;return null===(e=this.response.links.startPaymentSession)||void 0===e?void 0:e.href}get storedPaymentInstruments(){return this.availablePaymentMethods.flatMap((e=>e.paymentInstruments||[]))}getStoredInstrumentForPaymentMethod(e){var t;return(null===(t=this.availablePaymentMethods.find((({paymentMethodCode:t})=>t===e)))||void 0===t?void 0:t.paymentInstruments)||[]}}class m{constructor(e,{id:t="",className:i=""}={}){this.subElements=[];const n=document.createElement(e);t&&(this.id=t,n.setAttribute("id",t)),i&&n.setAttribute("class",i),this.element=n}get parentElement(){return this.element.parentElement}get selector(){if(!this.id)throw new Error("Element id is not set");return`#${this.id}`}mount(e){const t=document.querySelector(e);if(!t)throw new Error(`Element with selector "${e}" not found in in the DOM`);t.appendChild(this.element),this.subElements.forEach((e=>{if(!this.id)throw new Error("Sub elements can not be rendered, please set id for the element");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 O extends m{get bin(){var e;return this.selectedInstrument?this.selectedInstrument.data.bin?this.selectedInstrument.data.bin:"":(null===(e=this.cardForm)||void 0===e?void 0:e.bin)||""}constructor(e,t,i,n){var o;super("button",{id:"payrails-card-payment-button"}),this.sdkConfig=e,this.execution=t,this.options=i,this.returnLinks=n,this.selectedInstrument=null,this.element.innerText=(null===(o=null==i?void 0:i.translations)||void 0===o?void 0:o.label)||"Pay",this.element.addEventListener("click",this.onPay.bind(this)),this.element.addEventListener("mouseenter",(()=>{var e;this.element.classList.contains("disabled")||(this.element.classList.add("hover"),this.setStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{}))})),this.element.addEventListener("mouseleave",(()=>{var e;this.element.classList.contains("disabled")||(this.element.classList.remove("hover"),this.removeStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{}))})),this.paymentExecutor=new p(this.sdkConfig,this.execution,this.returnLinks)}setDisabled(e){var t,i,n,o,s;this.element.classList.contains("disabled")!==e&&(null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onStateChanged)||void 0===i||i.call(t,e?"disabled":"enabled")),this.element.disabled=e,e?(this.element.classList.add("disabled"),(null===(n=this.options.styles)||void 0===n?void 0:n.disabled)&&this.setStyles(this.options.styles.disabled)):(this.element.classList.remove("disabled"),this.removeStyles((null===(o=this.options.styles)||void 0===o?void 0:o.disabled)||{}),(null===(s=this.options.styles)||void 0===s?void 0:s.base)&&this.setStyles(this.options.styles.base))}setSavedCreditCard(e){console.warn("setSavedCreditCard is deprecated, please use setSavedInstrument"),this.setSavedInstrument(e)}setSavedInstrument(e){this.selectedInstrument=e,this.setDisabled(!1)}setStyles(e){var t;const i=Object.assign(Object.assign({},null===(t=this.options.styles)||void 0===t?void 0:t.base),e);Object.keys(i).forEach((e=>{this.element.style[e]=i[e]}))}removeStyles(e){var t;const i=Object.keys((null===(t=this.options.styles)||void 0===t?void 0:t.base)||{});Object.keys(e).forEach((e=>{var t,n;i.includes(e)?this.element.style[e]=null===(n=null===(t=this.options.styles)||void 0===t?void 0:t.base)||void 0===n?void 0:n[e]:this.element.style[e]=""}))}setLabel(e){this.element.innerText=e}setCardForm(e){this.cardForm=e}triggerLoading(e){var t,i,n,o;const s=this.element.offsetWidth;this.element.style.minWidth=`${s}px`,e?(this.element.innerHTML='<div class="dot-flashing"></div>',this.element.classList.add("loading"),(null===(t=this.options.styles)||void 0===t?void 0:t.loading)&&this.setStyles(this.options.styles.loading)):(this.element.innerText=(null===(n=null===(i=this.options)||void 0===i?void 0:i.translations)||void 0===n?void 0:n.label)||"Pay",this.element.classList.remove("loading"),this.removeStyles((null===(o=this.options.styles)||void 0===o?void 0:o.loading)||{}))}onAuthorizationFailed(e){var t,i;this.setDisabled(!1),this.triggerLoading(!1),(null===(t=this.options.events)||void 0===t?void 0:t.onAuthorizeFailed)&&(null===(i=this.options.events)||void 0===i||i.onAuthorizeFailed(e))}onPay(){var t,i,n,o,s,r,a,l,d,c,u,_;return e(this,void 0,void 0,(function*(){if(this.setDisabled(!0),this.triggerLoading(!0),null===(t=this.options.events)||void 0===t?void 0:t.onPaymentButtonClicked)try{if(!1===(yield null===(i=this.options.events)||void 0===i?void 0:i.onPaymentButtonClicked({bin:this.bin||""})))return void this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:"Callback passed to onPaymentButtonClicked resolved to false"})}catch(e){return void this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:"Callback passed to onPaymentButtonClicked threw an error"})}try{let e=[{paymentMethodCode:N.CARD,integrationType:"api",amount:this.sdkConfig.amount,storeInstrument:!1}];if(null===(n=this.selectedInstrument)||void 0===n?void 0:n.id)e[0].paymentInstrumentId=null===(o=this.selectedInstrument)||void 0===o?void 0:o.id,e[0].paymentMethodCode=null===(s=this.selectedInstrument)||void 0===s?void 0:s.paymentMethod;else{if(!this.cardForm)throw new Error("Trying to collect values from non-existent card form");e="Payrails"===(null===(a=null===(r=this.sdkConfig)||void 0===r?void 0:r.vaultConfiguration)||void 0===a?void 0:a.vaultType)?yield this.constructEncryptedPayment(e):yield this.constructTokenizedPayment(e);const t=yield this.paymentExecutor.pay(e);this.handleAuthorizationResult(t)}}catch(e){e instanceof E||[401,403].includes(null===(l=null==e?void 0:e.error)||void 0===l?void 0:l.code)?(null===(c=null===(d=this.options.events)||void 0===d?void 0:d.onPaymentSessionExpired)||void 0===c||c.call(d),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:"API token is not valid or expired."})):e.toString().includes("Invalid token")?(null===(_=null===(u=this.options.events)||void 0===u?void 0:u.onPaymentSessionExpired)||void 0===_||_.call(u),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:"Vault token is not valid or expired."})):this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.UNKNOWN_ERROR,message:e.toString(),rawError:e})}}))}constructTokenizedPayment(t){return e(this,void 0,void 0,(function*(){const{storeInstrument:e,enrollInstrumentToNetworkOffers:i,cardData:n}=yield this.cardForm.collectValues();return t[0].paymentInstrumentData={vaultToken:null==n?void 0:n.instrumentId,card:{numberToken:null==n?void 0:n.card_number,securityCodeToken:null==n?void 0:n.security_code}},t[0].storeInstrument=e,t[0].enrollInstrumentToNetworkOffers=i,t}))}constructEncryptedPayment(t){return e(this,void 0,void 0,(function*(){const{cardData:e,storeInstrument:i,enrollInstrumentToNetworkOffers:n}=yield this.cardForm.collectValues();return t[0].paymentInstrumentData=Object.assign({},e),t[0].storeInstrument=i,t[0].enrollInstrumentToNetworkOffers=n,t}))}handleAuthorizationResult(e){var t,i,n;switch(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code){case"authorizeSuccessful":this.triggerLoading(!1),(null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeSuccess)&&this.options.events.onAuthorizeSuccess();break;case"authorizePending":"3ds"===(null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.actionRequired)&&this.handle3ds(e);break;default:this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:"Authorization failed."})}}handle3ds(t){var i,n,o,s;try{null===(n=null===(i=this.options.events)||void 0===i?void 0:i.onThreeDSecureChallenge)||void 0===n||n.call(i)}catch(e){}const r=null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.links["3ds"];if(r){const t=[[250,400],[390,400],[500,600],[600,400]],i=screen.width,n=t.reduce(((e,t)=>i>t[0]?t:e),[250,400]),o=document.createElement("iframe");o.setAttribute("id","payrails-3ds-frame"),o.setAttribute("src",r),o.setAttribute("width",n[0].toString()),o.setAttribute("height",n[1].toString());const a=document.createElement("div");a.setAttribute("id","payrails-3ds-challenge"),a.appendChild(o);const l=document.createElement("div");l.addEventListener("click",(()=>e(this,void 0,void 0,(function*(){l.remove()})))),l.setAttribute("id","payrails-3ds-popup-background"),l.appendChild(a);const d=t=>e(this,void 0,void 0,(function*(){var e,i,n;if(t.data&&'{"type":"3DS-challenge-completed"}'===t.data){window.removeEventListener("message",d),l.remove();if(!(yield this.paymentExecutor.getExecution(this.execution.url)).res.status.find((({code:e})=>"authorizeSuccessful"===e))&&(null===(e=this.options.events)||void 0===e?void 0:e.onAuthorizeFailed))return void this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:"Authorization failed after 3DS challenge."});if(null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeSuccess)return void(null===(n=this.options.events)||void 0===n||n.onAuthorizeSuccess())}}));null===(s=document.querySelector("body"))||void 0===s||s.appendChild(l),window.addEventListener("message",d),a.style.width=`${n[0]+4}px`,a.style.height=`${n[1]+4}px`}}}exports.AuthorizationFailureReasons=void 0,(T=exports.AuthorizationFailureReasons||(exports.AuthorizationFailureReasons={})).VALIDATION_FAILED="VALIDATION_FAILED",T.AUTHORIZATION_ERROR="AUTHORIZATION_ERROR",T.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",T.UNKNOWN_ERROR="UNKNOWN_ERROR";var A="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function L(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var y={},R={},D={};Object.defineProperty(D,"__esModule",{value:!0}),D.isntString=void 0,D.isntString=function(e){return"string"!=typeof e};var S={},C={};Object.defineProperty(C,"__esModule",{value:!0}),C.subscribers=C.childWindows=C.prefix=void 0,C.prefix="/*framebus*/",C.childWindows=[],C.subscribers={};var g={},b={},w={},P={};Object.defineProperty(P,"__esModule",{value:!0}),P.subscriptionArgsInvalid=void 0;var M=D;P.subscriptionArgsInvalid=function(e,t,i){return!!M.isntString(e)||("function"!=typeof t||M.isntString(i))};var U={},k={};Object.defineProperty(k,"__esModule",{value:!0}),k.hasOpener=void 0,k.hasOpener=function(e){return e.top===e&&(null!=e.opener&&(e.opener!==e&&!0!==e.opener.closed))},Object.defineProperty(U,"__esModule",{value:!0}),U.broadcast=void 0;var V,x=k;function Y(){if(V)return w;V=1,Object.defineProperty(w,"__esModule",{value:!0}),w.Framebus=void 0;var e=D,t=P,i=U,n=j(),o=C,s=function(){function s(e){void 0===e&&(e="*"),this.origin=e}return s.target=function(e){return void 0===e&&(e="*"),new s(e)},s.prototype.include=function(e){return null!=e&&(null!=e.Window&&(e.constructor===e.Window&&(o.childWindows.push(e),!0)))},s.prototype.target=function(e){return s.target(e)},s.prototype.emit=function(t,o,s){var r=this.origin;if(e.isntString(t))return!1;if(e.isntString(r))return!1;"function"==typeof o&&(s=o,o=void 0);var a=n.packagePayload(t,r,o,s);return!!a&&(i.broadcast(window.top||window.self,a,r),!0)},s.prototype.on=function(e,i){var n=this.origin;return!t.subscriptionArgsInvalid(e,i,n)&&(o.subscribers[n]=o.subscribers[n]||{},o.subscribers[n][e]=o.subscribers[n][e]||[],o.subscribers[n][e].push(i),!0)},s.prototype.off=function(e,i){var n=this.origin;if(t.subscriptionArgsInvalid(e,i,n))return!1;var s=o.subscribers[n]&&o.subscribers[n][e];if(!s)return!1;for(var r=0;r<s.length;r++)if(s[r]===i)return s.splice(r,1),!0;return!1},s}();return w.Framebus=s,w}U.broadcast=function e(t,i,n){var o,s=0;try{for(t.postMessage(i,n),x.hasOpener(t)&&e(t.opener.top,i,n);o=t.frames[s];)e(o,i,n),s++}catch(e){}};var B,G,F=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))};function j(){if(G)return g;G=1,Object.defineProperty(g,"__esModule",{value:!0}),g.packagePayload=void 0;var e=function(){if(B)return b;B=1;var e=A&&A.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(b,"__esModule",{value:!0}),b.subscribeReplier=void 0;var t=Y(),i=e(F);return b.subscribeReplier=function(e,n){var o=i.default();return t.Framebus.target(n).on(o,(function i(s,r){e(s,r),t.Framebus.target(n).off(o,i)})),o},b}(),t=C;return g.packagePayload=function(i,n,o,s){var r,a={event:i,origin:n};"function"==typeof s&&(a.reply=e.subscribeReplier(s,n)),a.eventData=o;try{r=t.prefix+JSON.stringify(a)}catch(e){throw new Error("Could not stringify event: "+e.message)}return r},g}Object.defineProperty(S,"__esModule",{value:!0}),S.unpackPayload=void 0;var X=C,$=j();S.unpackPayload=function(e){var t;if(e.data.slice(0,X.prefix.length)!==X.prefix)return!1;try{t=JSON.parse(e.data.slice(X.prefix.length))}catch(e){return!1}if(t.reply){var i=e.origin,n=e.source,o=t.reply;t.reply=function(e){if(n){var t=$.packagePayload(o,i,e);t&&n.postMessage(t,i)}}}return t};var W={};Object.defineProperty(W,"__esModule",{value:!0}),W.dispatch=void 0;var K=C;W.dispatch=function(e,t,i,n,o){if(K.subscribers[e]&&K.subscribers[e][t]){var s=[];i&&s.push(i),n&&s.push(n);for(var r=0;r<K.subscribers[e][t].length;r++)K.subscribers[e][t][r].apply(o,s)}};var H={};Object.defineProperty(H,"__esModule",{value:!0}),H.broadcastToChildWindows=void 0;var z=U,q=C;H.broadcastToChildWindows=function(e,t,i){for(var n=q.childWindows.length-1;n>=0;n--){var o=q.childWindows[n];o.closed?q.childWindows.splice(n,1):i!==o&&z.broadcast(o.top,e,t)}},Object.defineProperty(R,"__esModule",{value:!0}),R.onmessage=void 0;var J=D,Z=S,Q=W,ee=H;R.onmessage=function(e){if(!J.isntString(e.data)){var t=Z.unpackPayload(e);if(t){var i=t.eventData,n=t.reply;Q.dispatch("*",t.event,i,n,e),Q.dispatch(e.origin,t.event,i,n,e),ee.broadcastToChildWindows(e.data,t.origin,e.source)}}},Object.defineProperty(y,"__esModule",{value:!0}),y.detach=y.attach=void 0;var te=R,ie=!1;y.attach=function(){ie||"undefined"==typeof window||(ie=!0,window.addEventListener("message",te.onmessage,!1))},y.detach=function(){ie=!1,window.removeEventListener("message",te.onmessage,!1)};var ne=y,oe=new(Y().Framebus);ne.attach();var se=L(oe);const re={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."},ae={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."},le={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."},de="collect_controller",ce="element",Ee="INSERT",ue="GET_BY_SKYFLOWID",_e="GET",Ie="DELETE",he={CHANGE:"CHANGE",READY:"READY",FOCUS:"FOCUS",BLUR:"BLUR",ESCAPE:"ESCAPE",CLICK:"CLICK",ERROR:"ERROR",SUCCESS:"SUCCESS",SUBMIT:"SUBMIT",CREATED:"CREATED",MOUNTED:"MOUNTED",HEIGHT:"HEIGHT"},pe="FRAME_READY",Ne="TOKENIZATION_REQUEST",fe="INPUT_EVENT",Te="DESTROY FRAME",ve="SET_VALUE",me="PUREJS_REQUEST",Oe="PUREJS_FRAME_READY",Ae="GET_BEARER_TOKEN",Le="COLLECT_ELEMENT_SET_ERROR",ye="COMPOSABLE_UPDATE_OPTIONS",Re="COMPOSABLE_CONTAINER_MOUNTED",De="COLLECT_CONTAINER_MOUNTED";var Se,Ce;!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"}(Ce||(Ce={}));const ge={[Ce.AMEX]:["XXXX XXXXXX XXXXX",{X:"[0-9]"}],[Ce.VISA]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[Ce.MASTERCARD]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[Ce.DISCOVER]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Ce.DINERS_CLUB]:["XXXX XXXXXX XXXXXX",{X:"[0-9]"}],[Ce.JCB]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Ce.MAESTRO]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Ce.UNIONPAY]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Ce.HIPERCARD]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Ce.DEFAULT]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Ce.UNKNOWN]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}]},be={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:ge[Ce.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}$/}},we="XXXX-XXXX-XXXX-XXXX",Pe={height:"100%",width:"100%",margin:0,padding:0,border:0,position:"absolute",top:0,left:0,"user-select":"none"},Me={position:"absolute",top:0,width:0,height:0,visibility:"hidden",left:"-99999999px","user-select":"none"},Ue={width:"100%",height:"100%",border:"0",padding:"0",margin:"0",outline:"none"},ke={WEBPACKAUTOFILL:"-webkit-autofill",BASE:"base",FOCUS:"focus",COMPLETE:"complete",EMPTY:"empty",INVALID:"invalid",GLOBAL:"global",REQUIRED_ASTERISK:"requiredAsterisk"};ke.BASE,ke.REQUIRED_ASTERISK;const Ve={[Ce.VISA]:{regex:/^4\d*/,maxCardLength:19,cardLengthRange:[13,16]},[Ce.MASTERCARD]:{regex:/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720)\d*/,maxCardLength:16,cardLengthRange:[16]},[Ce.AMEX]:{regex:/^3[47]\d*/,maxCardLength:15,cardLengthRange:[15]},[Ce.DINERS_CLUB]:{regex:/^(36|38|30[0-5])\d*/,maxCardLength:16,cardLengthRange:[14,15,16,17,18,19]},[Ce.DISCOVER]:{regex:/^(6011|65|64[4-9]|622)\d*/,maxCardLength:16,cardLengthRange:[16,17,18,19]},[Ce.JCB]:{regex:/^35\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[Ce.HIPERCARD]:{regex:/^606282\d*/,maxCardLength:19,cardLengthRange:[14,15,16,17,18,19]},[Ce.UNIONPAY]:{regex:/^62\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[Ce.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]}};Ce.DEFAULT,Ce.AMEX,Ce.DINERS_CLUB,Ce.DISCOVER,Ce.HIPERCARD,Ce.JCB,Ce.MAESTRO,Ce.MASTERCARD,Ce.UNIONPAY,Ce.VISA;const xe="MM/YY",Ye=[xe,"YYYY/MM","YY/MM","MM/YYYY"],Be=["YY","YYYY"];var Ge;!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"}(Ge||(Ge={})),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,ae.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,ae.DEFAULT_REQUIRED_COLLECT_VALUE,Se.PIN,Se.EXPIRATION_MONTH,Se.EXPIRATION_YEAR;const Fe=[Se.CARDHOLDER_NAME,Se.EXPIRATION_MONTH,Se.PIN,Se.CVV],je={X:"[0-9]"};class Xe{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(Xe.prototype,{constructor:e})}}
|
|
2
2
|
/* @copyright
|
|
3
3
|
Copyright (c) 2022 Skyflow, Inc.
|
|
4
|
-
*/const nt={IFRAME_SECURE_SITE:"https://js.skyflow.com/v1/elements/index.html",IFRAME_SECURE_ORGIN:"https://js.skyflow.com"},ot={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no",style:"width: 100%; height: 100%",allow:"clipboard-read; clipboard-write"},st=(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 rt=(e={})=>{const t=document.createElement("iframe"),i=Object.assign(Object.assign({},ot),e);return Object.assign(t.style,$e),st(t,i),t.getAttribute("id")||(t.id=t.name),t};const at=()=>nt.IFRAME_SECURE_SITE,lt=(e,t)=>{Object.keys(t).forEach((i=>{Object.prototype.hasOwnProperty.call(t,i)&&(e.style[i]=t[i])}))};function dt(e){return JSON.parse(JSON.stringify(e))}class ct{constructor(){this.listeners=[],this.isDestroyed=!1}on(e,t){se.on(e,t),this.listeners.push({eventName:e,callback:t})}off(e,t){se.off(e,t);const i=this.listeners.findIndex((t=>t.eventName===e));-1!==i&&this.listeners.splice(i,1)}emit(e,t,i=void 0){se.emit(e,t,i)}hasListener(e){return-1!==this.listeners.findIndex((t=>t.eventName===e))}teardown(){this.listeners.forEach((e=>{se.off(e.eventName,e.handler)})),this.listeners=[]}}var Et,_t,It,ut,ht,pt,ft;!function(e){e.DEFAULT="DEFAULT",e.PLAIN_TEXT="PLAIN_TEXT",e.MASKED="MASKED",e.REDACTED="REDACTED"}(Et||(Et={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.PATCH="PATCH",e.DELETE="DELETE"}(_t||(_t={})),function(e){e.CHANGE="CHANGE",e.READY="READY",e.FOCUS="FOCUS",e.BLUR="BLUR",e.SUBMIT="SUBMIT"}(It||(It={})),function(e){e.WARN="WARN",e.INFO="INFO",e.DEBUG="DEBUG",e.ERROR="ERROR"}(ut||(ut={})),function(e){e.DEV="DEV",e.PROD="PROD"}(ht||(ht={})),function(e){e.LOG="LOG",e.WARN="WARN",e.ERROR="ERROR"}(pt||(pt={})),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"}(ft||(ft={}));const Nt={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}},Tt={PROD:{doesReturnValue:!1},DEV:{doesReturnValue:!0}},vt="[Skyflow]",Ot=(e,t,i)=>{if(i&&Nt[i]){const{showDebugLogs:n,showInfoLogs:o,showWarnLogs:s,showErrorLogs:r}=Nt[i];t===pt.LOG&&n?console.log(`${ut.DEBUG}: ${vt} ${e}`):t===pt.LOG&&o?console.log(`${ut.INFO}: ${vt} ${e}`):t===pt.WARN&&s?console.warn(`${ut.WARN}: ${vt} ${e}`):t===pt.ERROR&&r&&console.error(`${ut.ERROR}: ${vt} ${e}`)}},Lt=(...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]})):""},mt=(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 At extends Error{constructor(e,t,i=!1){const n={code:e.code,description:t&&(null==t?void 0:t.length)>0?Lt(e.description,...t):e.description};super(n.description),i?this.error=n:this.errors=[n]}}const Rt={INVALID_FIELD:{code:400,description:ae.INVALID_FIELD},VAULTID_IS_REQUIRED:{code:400,description:ae.VAULTID_IS_REQUIRED},EMPTY_VAULTID_IN_INIT:{code:400,description:ae.EMPTY_VAULTID_IN_INIT},VAULTURL_IS_REQUIRED:{code:400,description:ae.VAULTURL_IS_REQUIRED},EMPTY_VAULTURL_IN_INIT:{code:400,description:ae.EMPTY_VAULTURL_IN_INIT},INVALID_VAULTURL_IN_INIT:{code:400,description:ae.INVALID_VAULTURL_IN_INIT},GET_BEARER_TOKEN_IS_REQUIRED:{code:400,description:ae.GET_BEARER_TOKEN_IS_REQUIRED},EMPTY_CONTAINER_TYPE:{code:400,description:ae.EMPTY_CONTAINER_TYPE},INVALID_CONTAINER_TYPE:{code:400,description:ae.INVALID_CONTAINER_TYPE},UNIQUE_ELEMENT_NAME:{code:400,description:ae.UNIQUE_ELEMENT_NAME},ELEMENTS_NOT_MOUNTED:{code:400,description:ae.ELEMENTS_NOT_MOUNTED},MISSING_TABLE_IN_COLLECT:{code:400,description:ae.MISSING_TABLE_IN_COLLECT},EMPTY_TABLE_IN_COLLECT:{code:400,description:ae.EMPTY_TABLE_IN_COLLECT},EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:{code:400,description:ae.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS},INVALID_TABLE_IN_COLLECT:{code:400,description:ae.INVALID_TABLE_IN_COLLECT},INVALID_SKYFLOWID_IN_COLLECT:{code:400,description:ae.INVALID_SKYFLOWID_IN_COLLECT},MISSING_COLUMN_IN_COLLECT:{code:400,description:ae.MISSING_COLUMN_IN_COLLECT},MISSING_SKYFLOWID_IN_COLLECT:{code:400,description:ae.MISSING_SKYFLOWID_IN_COLLECT},EMPTY_COLUMN_IN_COLLECT:{code:400,description:ae.EMPTY_TABLE_IN_COLLECT},INVALID_COLUMN_IN_COLLECT:{code:400,description:ae.INVALID_COLUMN_IN_COLLECT},CLIENT_CONNECTION:{code:400,description:ae.CLIENT_CONNECTION},RECORDS_KEY_NOT_FOUND:{code:404,description:ae.RECORDS_KEY_NOT_FOUND},EMPTY_RECORDS_IN_INSERT:{code:400,description:ae.EMPTY_RECORDS_IN_INSERT},INVALID_RECORDS_IN_INSERT:{code:404,description:ae.INVALID_RECORDS_IN_INSERT},INVALID_TABLE_IN_INSERT:{code:400,description:ae.INVALID_TABLE_IN_INSERT},EMPTY_TABLE_IN_INSERT:{code:400,description:ae.EMPTY_TABLE_IN_INSERT},MISSING_TABLE_IN_INSERT:{code:400,description:ae.MISSING_TABLE_IN_INSERT},EMPTY_FIELDS_IN_INSERT:{code:400,description:ae.EMPTY_FIELDS_IN_INSERT},MISSING_FIELDS_IN_INSERT:{code:404,description:ae.MISSING_FIELDS_IN_INSERT},INVALID_FIELDS_IN_INSERT:{code:404,description:ae.INVALID_FIELDS_IN_INSERT},INVALID_TOKENS_IN_INSERT:{code:404,description:ae.INVALID_TOKENS_IN_INSERT},RECORDS_KEY_NOT_FOUND_DETOKENIZE:{code:404,description:ae.RECORDS_KEY_NOT_FOUND_DETOKENIZE},EMPTY_RECORDS_DETOKENIZE:{code:400,description:ae.EMPTY_RECORDS_DETOKENIZE},INVALID_RECORDS_IN_DETOKENIZE:{code:404,description:ae.INVALID_RECORDS_IN_DETOKENIZE},MISSING_TOKEN_IN_DETOKENIZE:{code:400,description:ae.MISSING_TOKEN_IN_DETOKENIZE},INVALID_TOKEN_IN_DETOKENIZE:{code:400,description:ae.INVALID_TOKEN_IN_DETOKENIZE},RECORDS_KEY_NOT_FOUND_GET:{code:400,description:ae.RECORDS_KEY_NOT_FOUND_GET},INVALID_RECORDS_IN_GET:{code:400,description:ae.INVALID_RECORDS_IN_GET},EMPTY_RECORDS_GET:{code:400,description:ae.EMPTY_RECORDS_GET},MISSING_IDS_IN_GET:{code:400,description:ae.MISSING_IDS_IN_GET},INVALID_IDS_IN_GET:{code:400,description:ae.INVALID_IDS_IN_GET},INVALID_COLUMN_VALUES_IN_GET:{code:400,description:ae.INVALID_COLUMN_VALUES_IN_GET},EMPTY_IDS_IN_GET:{code:400,description:ae.EMPTY_IDS_IN_GET},INVALID_SKYFLOWID_TYPE_IN_GET:{code:400,description:ae.INVALID_SKYFLOWID_TYPE_IN_GET},MISSING_TABLE_IN_GET:{code:400,description:ae.MISSING_TABLE_IN_GET},INVALID_TABLE_IN_GET:{code:400,description:ae.INVALID_TABLE_IN_GET},MISSING_REDACTION_IN_GET:{code:400,description:ae.MISSING_REDACTION_IN_GET},INVALID_REDACTION_TYPE_IN_GET:{code:400,description:ae.INVALID_REDACTION_TYPE_IN_GET},INVALID_REDACTION_TYPE_IN_DETOKENIZE:{code:400,description:ae.INVALID_REDACTION_TYPE_IN_DETOKENIZE},INVALID_TOKENS_IN_COLLECT:{code:404,description:ae.INVALID_TOKENS_IN_COLLECT},RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS:{code:404,description:ae.RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS},INVALID_RECORDS_IN_ADDITIONAL_FIELDS:{code:404,description:ae.INVALID_RECORDS_IN_ADDITIONAL_FIELDS},EMPTY_RECORDS_IN_ADDITIONAL_FIELDS:{code:400,description:ae.EMPTY_RECORDS_IN_ADDITIONAL_FIELDS},MISSING_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:ae.MISSING_TABLE_IN_ADDITIONAL_FIELDS},INVALID_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:ae.INVALID_TABLE_IN_ADDITIONAL_FIELDS},INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:{code:400,description:ae.INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS},MISSING_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:ae.MISSING_FIELDS_IN_ADDITIONAL_FIELDS},INVALID_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:ae.INVALID_FIELDS_IN_ADDITIONAL_FIELDS},RECORDS_KEY_NOT_FOUND_DELETE:{code:400,description:ae.RECORDS_KEY_NOT_FOUND_DELETE},EMPTY_RECORDS_IN_DELETE:{code:400,description:ae.EMPTY_RECORDS_IN_DELETE},INVALID_RECORDS_IN_DELETE:{code:404,description:ae.INVALID_RECORDS_IN_DELETE},INVALID_TABLE_IN_DELETE:{code:400,description:ae.INVALID_TABLE_IN_DELETE},EMPTY_TABLE_IN_DELETE:{code:400,description:ae.EMPTY_TABLE_IN_DELETE},MISSING_TABLE_IN_DELETE:{code:400,description:ae.MISSING_TABLE_IN_DELETE},EMPTY_ID_IN_DELETE:{code:400,description:ae.EMPTY_ID_IN_DELETE},MISSING_ID_IN_DELETE:{code:404,description:ae.MISSING_ID_IN_DELETE},INVALID_ID_IN_DELETE:{code:404,description:ae.INVALID_ID_IN_DELETE},EMPTY_RECORDS_REVEAL:{code:400,description:ae.EMPTY_RECORDS_REVEAL},MISSING_TOKEN_KEY_REVEAL:{code:400,description:ae.MISSING_TOKEN_KEY_REVEAL},INVALID_TOKEN_ID_REVEAL:{code:400,description:ae.INVALID_TOKEN_ID_REVEAL},INVALID_LABEL_REVEAL:{code:400,description:ae.INVALID_LABEL_REVEAL},INVALID_ALT_TEXT_REVEAL:{code:400,description:ae.INVALID_ALT_TEXT_REVEAL},INVALID_FORMAT_REVEAL:{code:400,description:ae.INVALID_FORMAT_REVEAL},EMPTY_FORMAT_REVEAL:{code:400,description:ae.EMPTY_FORMAT_REVEAL},INVALID_FORMAT_VALUE_REVEAL:{code:400,description:ae.INVALID_FORMAT_VALUE_REVEAL},INVALID_REDACTION_TYPE_REVEAL:{code:400,description:ae.INVALID_REDACTION_TYPE_REVEAL},EMPTY_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:ae.EMPTY_TABLE_IN_ADDITIONAL_FIELDS},EMPTY_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:ae.EMPTY_FIELDS_IN_ADDITIONAL_FIELDS},EMPTY_TOKEN_IN_DETOKENIZE:{code:400,description:ae.EMPTY_TOKEN_IN_DETOKENIZE},EMPTY_SKYFLOWID_IN_GET:{code:400,description:ae.EMPTY_SKYFLOWID_IN_GET},EMPTY_TABLE_IN_GET:{code:400,description:ae.EMPTY_TABLE_IN_GET},EMPTY_REDACTION_TYPE_IN_GET:{code:400,description:ae.EMPTY_REDACTION_TYPE_IN_GET},EMPTY_TOKEN_ID_REVEAL:{code:400,description:ae.EMPTY_TOKEN_ID_REVEAL},DUPLICATE_ELEMENT:{code:400,description:ae.DUPLICATE_ELEMENT},DUPLICATE_ELEMENT_ADDITIONAL_FIELDS:{code:400,description:ae.DUPLICATE_ELEMENT_ADDITIONAL_FIELDS},MISSING_ELEMENT_TYPE:{code:400,description:ae.MISSING_ELEMENT_TYPE},EMPTY_ELEMENT_TYPE:{code:400,description:ae.EMPTY_ELEMENT_TYPE},INVALID_ELEMENT_TYPE:{code:400,description:ae.INVALID_ELEMENT_TYPE},INVALID_ELEMENT_SELECTOR:{code:400,description:ae.INVALID_ELEMENT_SELECTOR},FRAME_NOT_FOUND:{code:400,description:ae.FRAME_NOT_FOUND},REQUIRED_PARAMS_NOT_PROVIDED:{code:400,description:ae.REQUIRED_PARAMS_NOT_PROVIDED},INVALID_RECORD_COLUMN_VALUE:{code:400,description:ae.INVALID_RECORD_COLUMN_VALUE},MISSING_RECORD_COLUMN_VALUE:{code:400,description:ae.MISSING_RECORD_COLUMN_VALUE},MISSING_RECORD_COLUMN_NAME:{code:400,description:ae.MISSING_RECORD_COLUMN_NAME},INVALID_EVENT_TYPE:{code:400,description:ae.INVALID_EVENT_TYPE},INVALID_EVENT_LISTENER:{code:400,description:ae.INVALID_EVENT_LISTENER},MISSING_HANDLER_IN_EVENT_LISTENER:{code:400,description:ae.MISSING_HANDLER_IN_EVENT_LISTENER},INVALID_HANDLER_IN_EVENT_LISTENER:{code:400,description:ae.INVALID_HANDLER_IN_EVENT_LISTENER},UNKNOWN_ERROR:{code:400,description:ae.UNKNOWN_ERROR},CONNECTION_ERROR:{code:400,description:ae.CONNECTION_ERROR},NETWORK_ERROR:{code:500,description:ae.NETWORK_ERROR},COMPLETE_AND_VALID_INPUTS:{code:400,description:ae.COMPLETE_AND_VALID_INPUTS},INVALID_VALIDATIONS_TYPE:{code:400,description:ae.INVALID_VALIDATIONS_TYPE},MISSING_VALIDATION_RULE_TYPE:{code:400,description:ae.MISSING_VALIDATION_RULE_TYPE},INVALID_VALIDATION_RULE_TYPE:{code:400,description:ae.INVALID_VALIDATION_RULE_TYPE},MISSING_VALIDATION_RULE_PARAMS:{code:400,description:ae.MISSING_VALIDATION_RULE_PARAMS},INVALID_VALIDATION_RULE_PARAMS:{code:400,description:ae.INVALID_VALIDATION_RULE_PARAMS},MISSING_REGEX_IN_REGEX_MATCH_RULE:{code:400,description:ae.MISSING_REGEX_IN_REGEX_MATCH_RULE},INVALID_REGEX_IN_REGEX_MATCH_RULE:{code:400,description:ae.INVALID_REGEX_IN_REGEX_MATCH_RULE},MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE:{code:400,description:ae.MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE},MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE:{code:400,description:ae.MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE},INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE:{code:400,description:ae.INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE},ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE:{code:400,description:ae.ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE},EMPTY_ELEMENT_IN_MOUNT:{code:400,description:ae.EMPTY_ELEMENT_IN_MOUNT},REVEAL_ELEMENT_ERROR_STATE:{code:400,description:ae.REVEAL_ELEMENT_ERROR_STATE},INVALID_FILE_TYPE:{code:400,description:ae.INVALID_FILE_TYPE},INVALID_FILE_SIZE:{code:400,description:ae.INVALID_FILE_SIZE},NO_FILE_SELECTED:{code:400,description:ae.NO_FILE_SELECTED},INVALID_TABLE_IN_UPSERT_OPTION:{code:400,description:ae.INVALID_TABLE_IN_UPSERT_OPTION},INVALID_COLUMN_IN_UPSERT_OPTION:{code:400,description:ae.INVALID_COLUMN_IN_UPSERT_OPTION},INVALID_UPSERT_OPTION_TYPE:{code:400,description:ae.INVALID_UPSERT_OPTION_TYPE},EMPTY_UPSERT_OPTIONS_ARRAY:{code:400,description:ae.EMPTY_UPSERT_OPTIONS_ARRAY},INVALID_UPSERT_OPTION_OBJECT_TYPE:{code:400,description:ae.INVALID_UPSERT_OPTION_OBJECT_TYPE},MISSING_TABLE_IN_UPSERT_OPTION:{code:400,description:ae.MISSING_TABLE_IN_UPSERT_OPTION},MISSING_COLUMN_IN_UPSERT_OPTION:{code:400,description:ae.MISSING_COLUMN_IN_UPSERT_OPTION},INVALID_RECORD_COLUMN_VALUE_TYPE:{code:400,description:ae.INVALID_RECORD_COLUMN_VALUE_TYPE},INVALID_COLUMN_VALUES_TYPE:{code:400,description:ae.INVALID_COLUMN_VALUES_TYPE},EMPTY_RECORD_COLUMN_VALUES:{code:400,description:ae.EMPTY_RECORD_COLUMN_VALUES},EMPTY_COLUMN_VALUE:{code:400,description:ae.EMPTY_COLUMN_VALUE},MISSING_IDS_OR_COLUMN_VALUES_IN_GET:{code:400,description:ae.MISSING_IDS_OR_COLUMN_VALUES_IN_GET},SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED:{code:400,description:ae.SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED},RECORDS_KEY_NOT_FOUND_GETBYID:{code:400,description:ae.RECORDS_KEY_NOT_FOUND_GETBYID},INVALID_RECORDS_IN_GETBYID:{code:400,description:ae.INVALID_RECORDS_IN_GETBYID},EMPTY_RECORDS_GETBYID:{code:400,description:ae.EMPTY_RECORDS_GETBYID},MISSING_IDS_IN_GETBYID:{code:400,description:ae.MISSING_IDS_IN_GETBYID},INVALID_IDS_IN_GETBYID:{code:400,description:ae.INVALID_IDS_IN_GETBYID},EMPTY_IDS_IN_GETBYID:{code:400,description:ae.EMPTY_IDS_IN_GETBYID},INVALID_SKYFLOWID_TYPE_IN_GETBYID:{code:400,description:ae.INVALID_SKYFLOWID_TYPE_IN_GETBYID},MISSING_TABLE_IN_GETBYID:{code:400,description:ae.MISSING_TABLE_IN_GETBYID},INVALID_TABLE_IN_GETBYID:{code:400,description:ae.INVALID_TABLE_IN_GETBYID},MISSING_REDACTION_IN_GETBYID:{code:400,description:ae.MISSING_REDACTION_IN_GETBYID},INVALID_REDACTION_TYPE_IN_GETBYID:{code:400,description:ae.INVALID_REDACTION_TYPE_IN_GETBYID},EMPTY_SKYFLOWID_IN_GETBYID:{code:400,description:ae.EMPTY_SKYFLOWID_IN_GETBYID},EMPTY_TABLE_IN_GETBYID:{code:400,description:ae.EMPTY_TABLE_IN_GETBYID},EMPTY_REDACTION_TYPE_IN_GETBYID:{code:400,description:ae.EMPTY_REDACTION_TYPE_IN_GETBYID},MISSING_COMPOSABLE_LAYOUT_KEY:{code:400,description:ae.MISSING_COMPOSABLE_LAYOUT_KEY},EMPTY_COMPOSABLE_LAYOUT_ARRAY:{code:400,description:ae.EMPTY_COMPOSABLE_LAYOUT_ARRAY},INVALID_COMPOSABLE_LAYOUT_TYPE:{code:400,description:ae.INVALID_COMPOSABLE_LAYOUT_TYPE},NEGATIVE_VALUES_COMPOSABLE_LAYOUT:{code:400,description:ae.NEGATIVE_VALUES_COMPOSABLE_LAYOUT},MISMATCH_ELEMENT_COUNT_LAYOUT_SUM:{code:400,description:ae.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM},MISSING_COMPOSABLE_CONTAINER_OPTIONS:{code:400,description:ae.MISSING_COMPOSABLE_CONTAINER_OPTIONS},INVALID_COMPOSABLE_CONTAINER_OPTIONS:{code:400,description:ae.INVALID_COMPOSABLE_CONTAINER_OPTIONS},COMPOSABLE_CONTAINER_NOT_MOUNTED:{code:400,description:ae.COMPOSABLE_CONTAINER_NOT_MOUNTED},INVALID_BOOLEAN_OPTIONS:{code:400,description:ae.INVALID_BOOLEAN_OPTIONS},EMPTY_COLLECT_CUSTOM_FORMAT:{code:400,description:ae.EMPTY_COLLECT_CUSTOM_FORMAT},INVALID_INPUT_OPTIONS_FORMAT:{code:400,description:ae.INVALID_INPUT_OPTIONS_FORMAT},INVALID_INPUT_OPTIONS_TRANSLATION:{code:400,description:ae.INVALID_INPUT_OPTIONS_TRANSLATION}},yt=(e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new At(Rt.RECORDS_KEY_NOT_FOUND,[],!0);const{records:i}=e;if(!i||!Array.isArray(i))throw new At(Rt.INVALID_RECORDS_IN_INSERT,[],!0);if(0===i.length)throw new At(Rt.EMPTY_RECORDS_IN_INSERT,[],!0);if(i.forEach(((e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"table"))throw new At(Rt.MISSING_TABLE_IN_INSERT,[`${t}`],!0);if(!e.table)throw new At(Rt.EMPTY_TABLE_IN_INSERT,[`${t}`],!0);if(!("string"==typeof e.table||e.table instanceof String))throw new At(Rt.INVALID_TABLE_IN_INSERT,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"fields"))throw new At(Rt.MISSING_FIELDS_IN_INSERT,[`${t}`],!0);if(!e.fields)throw new At(Rt.EMPTY_FIELDS_IN_INSERT,[`${t}`],!0);if("object"!=typeof e.fields||Array.isArray(e.fields))throw new At(Rt.INVALID_FIELDS_IN_INSERT,[`${t}`],!0)})),t&&t.tokens&&"boolean"!=typeof t.tokens)throw new At(Rt.INVALID_TOKENS_IN_INSERT,[],!0)},Dt=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new At(Rt.RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS,[],!0);const{records:t}=e;if(!t||!Array.isArray(t))throw new At(Rt.INVALID_RECORDS_IN_ADDITIONAL_FIELDS,[],!0);if(0===t.length)throw new At(Rt.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 At(Rt.MISSING_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!e.table)throw new At(Rt.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 At(Rt.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 At(Rt.INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[`${t}`],!0)}if(!("string"==typeof e.table||e.table instanceof String))throw new At(Rt.INVALID_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"fields"))throw new At(Rt.MISSING_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!e.fields)throw new At(Rt.EMPTY_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if("object"!=typeof e.fields||Array.isArray(e.fields))throw new At(Rt.INVALID_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0)}))},St=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new At(Rt.RECORDS_KEY_NOT_FOUND_DETOKENIZE);const{records:t}=e;if(!t||!Array.isArray(t))throw new At(Rt.INVALID_RECORDS_IN_DETOKENIZE);if(0===t.length)throw new At(Rt.EMPTY_RECORDS_DETOKENIZE);t.forEach(((e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"token"))throw new At(Rt.MISSING_TOKEN_IN_DETOKENIZE,[`${t}`]);if(!e.token)throw new At(Rt.EMPTY_TOKEN_IN_DETOKENIZE,[`${t}`]);if(!("string"==typeof e.token||e.token instanceof String))throw new At(Rt.INVALID_TOKEN_IN_DETOKENIZE,[`${t}`]);const i=e.redaction;if(i&&!Object.values(Et).includes(i))throw new At(Rt.INVALID_REDACTION_TYPE_IN_DETOKENIZE,[`${t}`])}))},gt=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new At(Rt.RECORDS_KEY_NOT_FOUND_GET);const{records:t}=e;if(!t||!Array.isArray(t))throw new At(Rt.INVALID_RECORDS_IN_GET,[]);if(0===t.length)throw new At(Rt.EMPTY_RECORDS_GET);t.forEach(((e,t)=>{var i,n,o;if(0===Object.keys(e).length)throw new At(Rt.EMPTY_RECORDS_GET);if(0===(null===(i=e.ids)||void 0===i?void 0:i.length))throw new At(Rt.EMPTY_IDS_IN_GET,[`${t}`]);if(!(null==e.ids||e.ids&&Array.isArray(e.ids)))throw new At(Rt.INVALID_IDS_IN_GET,[`${t}`]);if(null===(n=e.ids)||void 0===n||n.forEach((e=>{if(!e)throw new At(Rt.EMPTY_SKYFLOWID_IN_GET,[`${t}`]);if(!("string"==typeof e||e instanceof String))throw new At(Rt.INVALID_SKYFLOWID_TYPE_IN_GET,[`${t}`])})),!Object.prototype.hasOwnProperty.call(e,"table"))throw new At(Rt.MISSING_TABLE_IN_GET,[`${t}`]);if(!e.table)throw new At(Rt.EMPTY_TABLE_IN_GET,[`${t}`]);if(!("string"==typeof e.table||e.table instanceof String))throw new At(Rt.INVALID_TABLE_IN_GET,[`${t}`]);if(!Object.prototype.hasOwnProperty.call(e,"redaction"))throw new At(Rt.MISSING_REDACTION_IN_GET,[`${t}`]);if(!e.redaction)throw new At(Rt.EMPTY_REDACTION_TYPE_IN_GET,[`${t}`]);if(!Object.values(Et).includes(e.redaction))throw new At(Rt.INVALID_REDACTION_TYPE_IN_GET,[`${t}`]);if(!0===Object.prototype.hasOwnProperty.call(e,"ids")&&!0===Object.prototype.hasOwnProperty.call(e,"columnName"))throw new At(Rt.SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED,[`${t}`]);if(Object.prototype.hasOwnProperty.call(e,"columnName")){if(!Object.prototype.hasOwnProperty.call(e,"columnName")||!Object.prototype.hasOwnProperty.call(e,"columnValues"))throw new At(Rt.MISSING_RECORD_COLUMN_VALUE,[`${t}`])}else if(!1===Object.prototype.hasOwnProperty.call(e,"ids")&&!1===Object.prototype.hasOwnProperty.call(e,"columnValues"))throw new At(Rt.MISSING_IDS_OR_COLUMN_VALUES_IN_GET,[`${t}`]);if(0===(null===(o=e.columnValues)||void 0===o?void 0:o.length))throw new At(Rt.EMPTY_RECORD_COLUMN_VALUES,[`${t}`]);if(!(null==e.columnValues||e.columnValues&&Array.isArray(e.columnValues)))throw new At(Rt.INVALID_COLUMN_VALUES_IN_GET,[`${t}`]);if(void 0!==e.columnName&&void 0===e.columnValues)throw new At(Rt.MISSING_RECORD_COLUMN_VALUE,[`${t}`]);if(void 0===e.columnName&&void 0!==e.columnValues)throw new At(Rt.MISSING_RECORD_COLUMN_NAME,[`${t}`]);const s=e.columnName;if(null!=s&&"string"!=typeof s)throw new At(Rt.INVALID_RECORD_COLUMN_VALUE,[`${t}`]);const r=e.columnValues;if(null!=r){if(0===r.length||null===r)throw new At(Rt.EMPTY_RECORD_COLUMN_VALUES,[`${t}`]);r.forEach((e=>{if(""===e||null===e)throw new At(Rt.EMPTY_COLUMN_VALUE,[`${t}`]);if("string"!=typeof e)throw new At(Rt.INVALID_RECORD_COLUMN_VALUE_TYPE,[`${t}`])}))}}))},Ct=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new At(Rt.RECORDS_KEY_NOT_FOUND_GETBYID);const{records:t}=e;if(!t||!Array.isArray(t))throw new At(Rt.INVALID_RECORDS_IN_GETBYID,[]);if(0===t.length)throw new At(Rt.EMPTY_RECORDS_GETBYID);t.forEach(((e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"ids"))throw new At(Rt.MISSING_IDS_IN_GETBYID,[`${t}`]);if(!e.ids||!Array.isArray(e.ids))throw new At(Rt.INVALID_IDS_IN_GETBYID,[`${t}`]);if(0===e.ids.length)throw new At(Rt.EMPTY_IDS_IN_GETBYID,[`${t}`]);if(e.ids.forEach((e=>{if(!e)throw new At(Rt.EMPTY_SKYFLOWID_IN_GETBYID,[`${t}`]);if(!("string"==typeof e||e instanceof String))throw new At(Rt.INVALID_SKYFLOWID_TYPE_IN_GETBYID,[`${t}`])})),!Object.prototype.hasOwnProperty.call(e,"table"))throw new At(Rt.MISSING_TABLE_IN_GETBYID,[`${t}`]);if(!e.table)throw new At(Rt.EMPTY_TABLE_IN_GETBYID,[`${t}`]);if(!("string"==typeof e.table||e.table instanceof String))throw new At(Rt.INVALID_TABLE_IN_GETBYID,[`${t}`]);if(!Object.prototype.hasOwnProperty.call(e,"redaction"))throw new At(Rt.MISSING_REDACTION_IN_GETBYID,[`${t}`]);if(!e.redaction)throw new At(Rt.EMPTY_REDACTION_TYPE_IN_GETBYID,[`${t}`]);if(!Object.values(Et).includes(e.redaction))throw new At(Rt.INVALID_REDACTION_TYPE_IN_GETBYID,[`${t}`])}))},bt=(e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new At(Rt.RECORDS_KEY_NOT_FOUND_DELETE,[],!0);const{records:i}=e;if(!i||!Array.isArray(i))throw new At(Rt.INVALID_RECORDS_IN_DELETE,[],!0);if(0===i.length)throw new At(Rt.EMPTY_RECORDS_IN_DELETE,[],!0);i.forEach(((e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"table"))throw new At(Rt.MISSING_TABLE_IN_DELETE,[`${t}`],!0);if(!e.table)throw new At(Rt.EMPTY_TABLE_IN_DELETE,[`${t}`],!0);if(!("string"==typeof e.table||e.table instanceof String))throw new At(Rt.INVALID_TABLE_IN_DELETE,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"id"))throw new At(Rt.MISSING_ID_IN_DELETE,[`${t}`],!0);if(!e.id)throw new At(Rt.EMPTY_ID_IN_DELETE,[`${t}`],!0);if(!("string"==typeof e.id||e.id instanceof String))throw new At(Rt.INVALID_ID_IN_DELETE,[`${t}`],!0)}))},wt=e=>{if(0===e.length)throw new At(Rt.EMPTY_RECORDS_REVEAL);e.forEach((e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"token"))throw new At(Rt.MISSING_TOKEN_KEY_REVEAL);if(!e.token)throw new At(Rt.EMPTY_TOKEN_ID_REVEAL);if(!("string"==typeof e.token||e.token instanceof String))throw new At(Rt.INVALID_TOKEN_ID_REVEAL);const t=e.redaction;if(t&&!Object.values(Et).includes(t))throw new At(Rt.INVALID_REDACTION_TYPE_REVEAL);if(Object.prototype.hasOwnProperty.call(e,"label")&&"string"!=typeof e.label)throw new At(Rt.INVALID_LABEL_REVEAL);if(Object.prototype.hasOwnProperty.call(e,"altText")&&"string"!=typeof e.altText)throw new At(Rt.INVALID_ALT_TEXT_REVEAL);if(Object.prototype.hasOwnProperty.call(e,"format")&&"string"!=typeof e.format)throw new At(Rt.INVALID_FORMAT_REVEAL);if(Object.prototype.hasOwnProperty.call(e,"format")&&""===e.format)throw new At(Rt.EMPTY_FORMAT_REVEAL)}))},Mt=e=>{if(!e||"https"!==e.substring(0,5).toLowerCase())return!1;try{if(new URL(e))return!0}catch(e){return!1}return!0},Pt=e=>{let t=!0;try{new RegExp(e)}catch(e){t=!1}return t},Ut=e=>{if(!Object.prototype.hasOwnProperty.call(e,"vaultID"))throw new At(Rt.VAULTID_IS_REQUIRED,[],!0);if(!e.vaultID)throw new At(Rt.EMPTY_VAULTID_IN_INIT,[],!0);if(!Object.prototype.hasOwnProperty.call(e,"vaultURL"))throw new At(Rt.VAULTURL_IS_REQUIRED,[],!0);if(!e.vaultURL)throw new At(Rt.EMPTY_VAULTURL_IN_INIT,[],!0);if(e.vaultURL&&!Mt(e.vaultURL))throw new At(Rt.INVALID_VAULTURL_IN_INIT,[],!0);if(!Object.prototype.hasOwnProperty.call(e,"getBearerToken"))throw new At(Rt.GET_BEARER_TOKEN_IS_REQUIRED,[],!0)},Vt=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new At(Rt.MISSING_ELEMENT_TYPE,[],!0);if(!e.type)throw new At(Rt.EMPTY_ELEMENT_TYPE,[],!0);if(Object.prototype.hasOwnProperty.call(e,"altText")&&Ot(le.COLLECT_ALT_TEXT_DEPERECATED,pt.WARN,t),Object.prototype.hasOwnProperty.call(e,"skyflowID")&&"string"!=typeof e.skyflowID)throw new At(Rt.INVALID_SKYFLOWID_IN_COLLECT,[],!0);if(e.type===Be.FILE_INPUT&&!Object.keys(e).includes("skyflowID"))throw new At(Rt.MISSING_SKYFLOWID_IN_COLLECT,[],!0)},kt=e=>{if(!e||!Array.isArray(e))throw new At(Rt.INVALID_UPSERT_OPTION_TYPE,[],!0);if(!e.length)throw new At(Rt.EMPTY_UPSERT_OPTIONS_ARRAY,[],!0);e.forEach(((e,t)=>{if(!e||"object"!=typeof e)throw new At(Rt.INVALID_UPSERT_OPTION_OBJECT_TYPE,[t],!0);if(!Object.prototype.hasOwnProperty.call(e,"table"))throw new At(Rt.MISSING_TABLE_IN_UPSERT_OPTION,[t],!0);if(!e.table||"string"!=typeof e.table||!e.table.length)throw new At(Rt.INVALID_TABLE_IN_UPSERT_OPTION,[t],!0);if(!Object.prototype.hasOwnProperty.call(e,"column"))throw new At(Rt.MISSING_COLUMN_IN_UPSERT_OPTION,[t],!0);if(!e.column||"string"!=typeof e.column||!e.column.length)throw new At(Rt.INVALID_COLUMN_IN_UPSERT_OPTION,[t],!0)}))},Yt=e=>"boolean"==typeof e,xt=e=>{if(e){if(Object.prototype.hasOwnProperty.call(e,"format")&&"string"!=typeof e.format)throw new At(Rt.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 At(Rt.INVALID_INPUT_OPTIONS_TRANSLATION,[],!0)}};function Bt(e){const t=e.split(":");return t.length>2?(t.pop(),t.pop(),t.join(":")):""}const Ft=(e,t,i)=>{if("string"!=typeof e)return e;if(t===Be.CARD_NUMBER){if(e=e&&e.replace(/\s/g,""),!i){const t=((e="")=>{const t=e.replace(/[\s-]/g,"");let i=Fe.DEFAULT;return Object.entries(He).forEach((([e,n])=>{n.regex.test(t)&&(i=e)})),i})(e),i=t!==Fe.DEFAULT&&t===Fe.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};class Gt{constructor(e,t,i,n){this.mount=e=>{var t;this.unmount();try{if("string"==typeof e){if(this.container=document.querySelector(e)||void 0,!this.container)throw new At(Rt.INVALID_ELEMENT_SELECTOR,[],!0)}else{if(!(e instanceof HTMLElement))throw new At(Rt.INVALID_ELEMENT_SELECTOR,[],!0);this.container=e}}catch(e){console.error(e)}st(this.iframe,{src:at()}),null===(t=this.container)||void 0===t||t.appendChild(this.iframe)},this.unmount=()=>{this.iframe.remove()},this.name=`${e}:${i}:${n}`,this.metadata=t,this.iframe=rt({name:this.name})}}class jt{}var Xt,$t,Wt,Kt,zt,Ht,qt,Jt,Zt,Qt,ei,ti,ii,ni,oi,si,ri,ai,li,di;const ci="Element";class Ei extends jt{constructor(e,n,o,s,r=!1,a,l,d,c){var E;super(),this.type=eo.COLLECT,Xt.set(this,void 0),$t.set(this,!1),Wt.set(this,void 0),Kt.set(this,void 0),zt.set(this,{isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:void 0,isRequired:!1}),Ht.set(this,void 0),qt.set(this,new it),Jt.set(this,void 0),Zt.set(this,new ct),Qt.set(this,void 0),ei.set(this,[]),ti.set(this,!1),ii.set(this,void 0),ni.set(this,void 0),oi.set(this,!1),this.getID=()=>t(this,Xt,"f"),this.mount=e=>{var n;if(!e)throw new At(Rt.EMPTY_ELEMENT_IN_MOUNT,["CollectElement"],!0);const o=(e,n)=>{if(e.name===t(this,Qt,"f").name){n(t(this,Ht,"f")),t(this,di,"f").call(this);const e=function(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(i[n[o]]=e[n[o]])}return i}(t(this,Wt,"f")[0],["name"]);t(this,Kt,"f").length>1?t(this,Kt,"f").forEach(((e,i)=>{t(this,Jt,"f")&&t(this,Jt,"f")._emit(`${fe.READY}:${e.elementName}`,Object.assign(Object.assign({},t(this,Wt,"f")[i]),{elementType:e.elementType}))})):t(this,qt,"f")._emit(fe.READY,Object.assign({},e)),t(this,Zt,"f").off(Ne+this.containerId,o),Ot(`${Lt(re.ELEMENT_MOUNTED,ci,mt(t(this,Qt,"f").name))} `,pt.LOG,t(this,ii,"f").logLevel),t(this,ei,"f").forEach((e=>e())),i(this,ei,[],"f")}};if(t(this,Kt,"f").length>1)t(this,Qt,"f").mount(e),t(this,Zt,"f").on(Ne+this.containerId,o);else{if(t(this,oi,"f"))return t(this,Qt,"f").mount(e),void t(this,Zt,"f").on(Ne+this.containerId,o);null===(n=t(this,Jt,"f"))||void 0===n||n.on(Ye,(i=>{(null==i?void 0:i.containerId)===this.containerId&&(t(this,Qt,"f").mount(e),t(this,Zt,"f").on(Ne+this.containerId,o))}))}},this.unmount=()=>{t(this,Qt,"f").unmount()},this.update=e=>{let n=dt(e);const o=()=>{t(this,$t,"f")&&(n={rows:[{elements:[Object.assign({},n)]}]}),i(this,Ht,Ii(t(this,Ht,"f"),n),"f"),i(this,Kt,ui(t(this,Ht,"f")),"f"),t(this,$t,"f")?t(this,Zt,"f").emit(Le,{name:t(this,Qt,"f").name,options:t(this,Kt,"f")[0],isSingleElementAPI:!0}):(t(this,Kt,"f").forEach((e=>{t(this,Zt,"f").emit(Le,{name:e.elementName,options:e,isSingleElementAPI:!0})})),t(this,Zt,"f").emit(Le,{name:t(this,Qt,"f").name,options:t(this,Ht,"f"),isSingleElementAPI:!1})),t(this,di,"f").call(this)};t(this,ti,"f")?o():t(this,ei,"f").push(o)},si.set(this,(e=>{t(this,$t,"f")||t(this,qt,"f").on(Le,(()=>{e(t(this,Kt,"f"))}),!0)})),this.updateElement=e=>{t(this,Zt,"f").emit(Le,{name:e.elementName,options:e,isSingleElementAPI:!0})},ri.set(this,(()=>{t(this,Wt,"f").forEach(((e,i)=>{if(0===i){t(this,zt,"f").isEmpty=e.isEmpty,t(this,zt,"f").isComplete=e.isComplete,t(this,zt,"f").isValid=e.isValid,t(this,zt,"f").isFocused=e.isFocused,t(this,zt,"f").isRequired=e.isRequired,t(this,zt,"f").value={};const n=t(this,Kt,"f")[i].elementName,o=e.value&&Ft(e.value,e.elementType,t(this,ni,"f"));t(this,$t,"f")?t(this,zt,"f").value=o:t(this,zt,"f").value[n]=o}else t(this,zt,"f").isEmpty=t(this,zt,"f").isEmpty||e.isEmpty,t(this,zt,"f").isComplete=t(this,zt,"f").isComplete&&e.isComplete,t(this,zt,"f").isValid=t(this,zt,"f").isValid&&e.isValid,t(this,zt,"f").isFocused=t(this,zt,"f").isFocused||e.isFocused,t(this,zt,"f").isRequired=t(this,zt,"f").isRequired||e.isRequired,t(this,zt,"f").value||(t(this,zt,"f").value={}),t(this,Kt,"f")[i].sensitive||(t(this,zt,"f").value[t(this,Kt,"f")[i].elementName]=e.value||"")}))})),this.getState=()=>({isEmpty:t(this,zt,"f").isEmpty,isComplete:t(this,zt,"f").isComplete,isValid:t(this,zt,"f").isValid,isFocused:t(this,zt,"f").isFocused,value:t(this,zt,"f").value,required:t(this,zt,"f").isRequired}),this.getOptions=()=>{let e=dt(t(this,Ht,"f"));return t(this,$t,"f")?e=e.rows[0].elements[0]:e.rows.forEach((e=>{e.elements.forEach((e=>{delete e.elementName}))})),delete e.elementName,e},ai.set(this,(e=>{t(this,qt,"f").on(Oe,(()=>{const i=t(this,Kt,"f").map((e=>e.elementName));t(this,$t,"f")||i.push(t(this,Qt,"f").name),e(i)}),!0)})),li.set(this,(()=>{t(this,Zt,"f").on(ve,(e=>{if(t(this,$t,"f")&&e.event===fe.READY&&e.name===t(this,Qt,"f").name)t(this,qt,"f")._emit(fe.READY);else{const i=t(this,Kt,"f").length>1;t(this,Kt,"f").forEach(((n,o)=>{var s;if(e.name===n.elementName){let r="";switch(e.event){case fe.FOCUS:r=fe.FOCUS;break;case fe.BLUR:r=fe.BLUR;break;case fe.CHANGE:r=fe.CHANGE;break;case fe.READY:r=fe.READY;break;case fe.SUBMIT:return void(null===(s=t(this,Jt,"f"))||void 0===s||s._emit(fe.SUBMIT));default:throw new At(Rt.INVALID_EVENT_TYPE,[],!0)}t(this,Wt,"f")[o].isEmpty=e.value.isEmpty,t(this,Wt,"f")[o].isValid=e.value.isValid,t(this,Wt,"f")[o].isComplete=e.value.isComplete,t(this,Wt,"f")[o].isFocused=e.value.isFocused,t(this,Wt,"f")[o].isRequired=e.value.isRequired,Object.prototype.hasOwnProperty.call(e.value,"value")?t(this,Wt,"f")[o].value=e.value.value:t(this,Wt,"f")[o].value=void 0,r=i?`${r}:${e.name}`:r,t(this,ri,"f").call(this);const a=Object.assign(Object.assign({},t(this,Wt,"f")[o]),{elementType:n.elementType});i&&t(this,Jt,"f")?t(this,Jt,"f")._emit(r,a):t(this,qt,"f")._emit(r,a)}}))}}))})),di.set(this,(()=>{const{rows:e}=t(this,Ht,"f");e.forEach((e=>{e.elements.forEach((e=>{e.elementType!==je.radio.name&&e.elementType!==je.checkbox.name&&(e.value=void 0)}))})),i(this,Kt,ui(t(this,Ht,"f")),"f")})),this.containerId=s.containerId,i(this,Xt,e,"f"),i(this,ii,d,"f"),i(this,Ht,Ii(n),"f"),i(this,Kt,ui(n),"f"),i(this,$t,r,"f"),c&&i(this,Jt,c,"f"),i(this,ni,Tt[t(this,ii,"f").env].doesReturnValue,"f"),this.elementType=t(this,$t,"f")?t(this,Kt,"f")[0].elementType:"group",i(this,Wt,[],"f"),t(this,Kt,"f").forEach((e=>{t(this,Wt,"f").push({isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:t(this,ni,"f")?"":void 0,elementType:e.elementType,name:e.elementName,isRequired:!1})})),i(this,Qt,new Gt(t(this,Ht,"f").elementName,o,this.containerId,t(this,ii,"f").logLevel),"f"),t(this,li,"f").call(this),t(this,ai,"f").call(this,a),t(this,si,"f").call(this,l),Ot(Lt(re.CREATED_ELEMENT,ci,mt(t(this,Qt,"f").name)),pt.LOG,t(this,ii,"f").logLevel),i(this,oi,s.isMounted,"f"),null===(E=t(this,Jt,"f"))||void 0===E||E.on(Ye,(e=>{(null==e?void 0:e.containerId)===this.containerId&&i(this,oi,!0,"f")})),t(this,Zt,"f").on(fe.MOUNTED,(e=>{s.type===eo.COMPOSABLE?t(this,Kt,"f").forEach((t=>{e.name===t.elementName&&(t.isMounted=!0,i(this,ti,!0,"f"))})):e.name===t(this,Kt,"f")[0].elementName&&(t(this,Kt,"f")[0].isMounted=!0,i(this,ti,!0,"f"))}))}on(e,i){if(!Object.values(fe).includes(e))throw new At(Rt.INVALID_EVENT_LISTENER,[],!0);if(!i)throw new At(Rt.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof i)throw new At(Rt.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);t(this,qt,"f").on(e,(e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,i(e)}))}iframeName(){return t(this,Qt,"f").name}isMounted(){return t(this,ti,"f")}isValidElement(){for(let e=0;e<t(this,Kt,"f").length;e+=1){if(!Object.prototype.hasOwnProperty.call(t(this,Kt,"f")[e],"table"))throw new At(Rt.MISSING_TABLE_IN_COLLECT,[],!0);if(!t(this,Kt,"f")[e].table)throw new At(Rt.EMPTY_TABLE_IN_COLLECT,[],!0);if(!("string"==typeof t(this,Kt,"f")[e].table||t(this,Kt,"f")[e].table instanceof String))throw new At(Rt.INVALID_TABLE_IN_COLLECT,[],!0);if(!Object.prototype.hasOwnProperty.call(t(this,Kt,"f")[e],"column"))throw new At(Rt.MISSING_COLUMN_IN_COLLECT,[],!0);if(!t(this,Kt,"f")[e].column)throw new At(Rt.EMPTY_COLUMN_IN_COLLECT,[],!0);if(!("string"==typeof t(this,Kt,"f")[e].column||t(this,Kt,"f")[e].column instanceof String))throw new At(Rt.INVALID_COLUMN_IN_COLLECT,[],!0);if(void 0!==t(this,Kt,"f")[e].skyflowID&&!t(this,Kt,"f")[e].skyflowID)throw new At(Rt.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[],!0)}return!0}setError(e){t(this,Zt,"f").emit(Se,{name:Bt(t(this,Qt,"f").name),isTriggerError:!0,clientErrorText:e})}resetError(){t(this,Zt,"f").emit(Se,{name:Bt(t(this,Qt,"f").name),isTriggerError:!1})}setValue(e){t(this,ii,"f").env!==ht.PROD?t(this,$t,"f")&&t(this,Zt,"f").emit(Le,{name:t(this,Qt,"f").name,options:Object.assign(Object.assign({},t(this,Kt,"f")[0]),{value:e}),isSingleElementAPI:!0}):Ot(Lt(le.UNABLE_TO_SET_VALUE_IN_PROD_ENV,t(this,Kt,"f")[0].elementType),pt.WARN,t(this,ii,"f").logLevel)}clearValue(){t(this,ii,"f").env!==ht.PROD?t(this,$t,"f")&&t(this,Zt,"f").emit(Le,{name:t(this,Qt,"f").name,options:Object.assign(Object.assign({},t(this,Kt,"f")[0]),{value:""}),isSingleElementAPI:!0}):Ot(Lt(le.UNABLE_TO_CLEAR_VALUE_IN_PROD_ENV,t(this,Kt,"f")[0].elementType),pt.WARN,t(this,ii,"f").logLevel)}}function _i(e,t,i={}){if("group"!==e&&!Object.prototype.hasOwnProperty.call(je,e))throw new At(Rt.INVALID_ELEMENT_TYPE,[],!0);if(Object.prototype.hasOwnProperty.call(t,"validations")){if(!Array.isArray(t.validations))throw new At(Rt.INVALID_VALIDATIONS_TYPE,[],!0);t.validations.forEach(((e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new At(Rt.MISSING_VALIDATION_RULE_TYPE,[`${t}`],!0);if(!Object.values(ft).includes(e.type))throw new At(Rt.INVALID_VALIDATION_RULE_TYPE,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"params"))throw new At(Rt.MISSING_VALIDATION_RULE_PARAMS,[`${t}`],!0);if("object"!=typeof e.params||Array.isArray(e.params)||null===e.params)throw new At(Rt.INVALID_VALIDATION_RULE_PARAMS,[`${t}`],!0);if(e.type===ft.REGEX_MATCH_RULE){if(!Object.prototype.hasOwnProperty.call(e.params,"regex"))throw new At(Rt.MISSING_REGEX_IN_REGEX_MATCH_RULE,[`${t}`],!0)}else if(e.type===ft.LENGTH_MATCH_RULE&&!Object.prototype.hasOwnProperty.call(e.params,"min")&&!Object.prototype.hasOwnProperty.call(e.params,"max"))throw new At(Rt.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}=je[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===je.radio.name||e===je.checkbox.name)&&!i.value)throw new Error("Elements radio and checkbox requires value attribute");if(!(e!==je.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 Ii(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(ae.CANNOT_CHANGE_ELEMENT);_i(a.elementType,a,l),s.elements[t]=Object.assign(Object.assign(Object.assign({},a),l),{elementName:a.elementName});const d=l.classes||{},c=l.styles||{};c.base=Object.assign(Object.assign({},Ke),c.base),l.classes=d,l.styles=c;const E=(null===(n=null==l?void 0:l.labelStyles)||void 0===n?void 0:n.classes)||{},_=(null===(o=null==l?void 0:l.labelStyles)||void 0===o?void 0:o.styles)||{};i&&function(e,t){Object.values(ze).forEach((i=>{if(e[i]||t[i])switch(i){case ze.BASE:t[i]=Object.assign({},t[i]);break;case ze.FOCUS:t[ze.BASE]=Object.assign(Object.assign({},t[ze.BASE]),{":focus":Object.assign({},t[ze.BASE]&&t[ze.BASE][":focus"])});break;case ze.WEBPACKAUTOFILL:t[ze.BASE]=Object.assign(Object.assign({},t[ze.BASE]),{":-webkit-autofill":Object.assign({},t[ze.BASE]&&t[ze.BASE][":-webkit-autofill"])});break;default:t[i]=Object.assign(Object.assign({},t[ze.BASE]),t[i])}})),Object.keys(t).forEach((e=>{const i=t[e][":-webkit-autofill"];"object"==typeof i&&Object.keys(i).forEach((e=>{i[e]&&!i[e].includes("!important")&&(i[e]=`${i[e]} !important`)}))}))}(E,_),l.labelStyles={labelClasses:E},l.labelStyles.styles=_}))})),t}Xt=new WeakMap,$t=new WeakMap,Wt=new WeakMap,Kt=new WeakMap,zt=new WeakMap,Ht=new WeakMap,qt=new WeakMap,Jt=new WeakMap,Zt=new WeakMap,Qt=new WeakMap,ei=new WeakMap,ti=new WeakMap,ii=new WeakMap,ni=new WeakMap,oi=new WeakMap,si=new WeakMap,ri=new WeakMap,ai=new WeakMap,li=new WeakMap,di=new WeakMap;const ui=e=>{const{rows:t}=e,i=[];return t.forEach((e=>{e.elements.forEach((e=>{i.push(e)}))})),i},hi=e=>{const t=e.validations;return t&&Array.isArray(t)&&t.length>0&&t.forEach(((e,t)=>{if(e&&e.type===ft.ELEMENT_VALUE_MATCH_RULE){if(e.params&&!Object.prototype.hasOwnProperty.call(e.params,"element"))throw new At(Rt.MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE,[`${t}`],!0);if(e.params&&(null==e.params.element||!(e.params.element instanceof Ei)))throw new At(Rt.INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE,[`${t}`],!0);e.params&&e.params.element&&e.params.element instanceof Ei&&(e.params.element=e.params.element.iframeName())}else if(e&&e.type===ft.REGEX_MATCH_RULE){if(e.params&&e.params.regex&&!Pt(e.params.regex))throw new At(Rt.INVALID_REGEX_IN_REGEX_MATCH_RULE,[`${t}`],!0);e.params&&e.params.regex&&Pt(e.params.regex)&&(e.params.regex=e.params.regex.toString())}})),t},pi=(e,t,i)=>{let n=Object.assign({required:!1},t);if((Object.prototype.hasOwnProperty.call(n,"format")||Object.prototype.hasOwnProperty.call(n,"translation"))&&(et.includes(e)?(Ot(Lt(le.INPUT_FORMATTING_NOT_SUPPROTED,e),pt.WARN,i),null==n||delete n.format,null==n||delete n.translation):e===je.INPUT_FIELD.name&&(xt(t),n=Object.assign(Object.assign({},n),{mask:[n.format,n.translation?n.translation:tt]}),null==n||delete n.format,null==n||delete n.translation)),e===je.CARD_NUMBER.name){Object.prototype.hasOwnProperty.call(n,"enableCardIcon")||(n=Object.assign(Object.assign({},n),{enableCardIcon:!0}));let e=" ";(null==n?void 0:n.format)===Xe&&(e="-"),n=Object.assign(Object.assign({},n),{cardSeperator:e}),null==n||delete n.format,null==n||delete n.translation}else if(e===je.EXPIRATION_DATE.name){let e=!1;n.format&&(e=!!(o=n.format.toUpperCase())&&Je.includes(o),e||Ot(Lt(le.INVALID_EXPIRATION_DATE_FORMAT,Je.toString()),pt.WARN,i)),n=Object.assign(Object.assign({},n),{format:e?n.format.toUpperCase():qe}),null==n||delete n.translation}else if(e===je.EXPIRATION_YEAR.name){let e=!1;n.format&&(e=(e=>!!e&&Ze.includes(e))(n.format.toUpperCase()),e||Ot(Lt(le.INVALID_EXPIRATION_YEAR_FORMAT,Ze.toString()),pt.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")&&!Yt(n.enableCardIcon))throw new At(Rt.INVALID_BOOLEAN_OPTIONS,["enableCardIcon"],!0);if(Object.prototype.hasOwnProperty.call(n,"enableCopy")&&!Yt(n.enableCopy))throw new At(Rt.INVALID_BOOLEAN_OPTIONS,["enableCopy"],!0);if(Object.prototype.hasOwnProperty.call(n,"required")&&!Yt(n.required))throw new At(Rt.INVALID_BOOLEAN_OPTIONS,["required"],!0);return n};function fi(){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 Ni{}var Ti,vi,Oi,Li,mi,Ai,Ri,yi,Di,Si,gi,Ci;const bi="CollectContainer";class wi extends Ni{constructor(e,n,o,s){super(),Ti.set(this,void 0),vi.set(this,{}),Oi.set(this,void 0),Li.set(this,void 0),mi.set(this,void 0),this.type=eo.COLLECT,Ai.set(this,void 0),Ri.set(this,!1),this.create=(e,i={required:!1})=>{Vt(e,t(this,Li,"f").logLevel);const n=hi(e),o=pi(e.type,i,t(this,Li,"f").logLevel),s={rows:[{elements:[Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column},e),o),{validations:n})]}]};return t(this,yi,"f").call(this,s,!0)},yi.set(this,((e,i=!1)=>{const n=[],o=dt(e);if(o.rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;_i(i,t),t.sensitive=t.sensitive||je[i].sensitive,t.replacePattern=t.replacePattern||je[i].replacePattern,t.mask=t.mask||je[i].mask,t.isMounted=!1,t.elementType!==je.radio.name&&t.elementType!==je.checkbox.name||(t.elementName=`${t.elementName}:${btoa(t.value)}`),t.elementName=`${Ee}:${t.elementType}:${btoa(fi())}`,t.label=e.label,t.skyflowID=e.skyflowID,n.push(t)}))})),o.elementName=i?n[0].elementName:`${Ee}:group:${btoa(o.name)}`,i&&!t(this,vi,"f")[n[0].elementName]&&t(this,Ci,"f").call(this,n[0].name))throw new At(Rt.UNIQUE_ELEMENT_NAME,[`${n[0].name}`],!0);let s=t(this,vi,"f")[o.elementName];if(s)i?s.update(n[0]):s.update(o);else{const e=fi();s=new Ei(e,o,t(this,Oi,"f"),{containerId:t(this,Ti,"f"),isMounted:t(this,Ri,"f"),type:this.type},i,t(this,Si,"f"),t(this,gi,"f"),t(this,Li,"f"),t(this,Ai,"f")),t(this,vi,"f")[o.elementName]=s,t(this,mi,"f")[e]=s}return i||n.forEach((e=>{const i=e.elementName;t(this,vi,"f")[i]?t(this,vi,"f")[i].update(e):t(this,vi,"f")[i]=this.create(e.elementType,s)})),s})),Di.set(this,(e=>{Object.keys(t(this,vi,"f")).forEach((i=>{i===e&&delete t(this,vi,"f")[i]}))})),Si.set(this,(e=>{e.forEach((e=>{t(this,Di,"f").call(this,e)}))})),gi.set(this,(e=>{e.forEach((e=>{t(this,vi,"f")[e.elementName]&&t(this,vi,"f")[e.elementName].update(e)}))})),Ci.set(this,(e=>{const i=Object.keys(t(this,vi,"f"));for(let t=0;t<i.length;t+=1)if(atob(i[t].split(":")[2])===e)return!0;return!1})),this.collect=(e={tokens:!0})=>new Promise(((i,n)=>{try{Ut(t(this,Oi,"f").clientJSON.config);if(Object.values(t(this,vi,"f")).forEach((e=>{if(!e.isMounted())throw new At(Rt.ELEMENTS_NOT_MOUNTED,[],!0);e.isValidElement()})),Object.prototype.hasOwnProperty.call(e,"tokens")&&!Yt(e.tokens))throw new At(Rt.INVALID_TOKENS_IN_COLLECT,[],!0);(null==e?void 0:e.additionalFields)&&Dt(e.additionalFields),(null==e?void 0:e.upsert)&&kt(null==e?void 0:e.upsert),se.emit(Te+t(this,Ti,"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)?(Ot(`${JSON.stringify(null==e?void 0:e.error)}`,pt.ERROR,t(this,Li,"f").logLevel),n(null==e?void 0:e.error)):(Ot(Lt(re.COLLECT_SUBMIT_SUCCESS,bi),pt.LOG,t(this,Li,"f").logLevel),i(e))})),Ot(Lt(re.EMIT_EVENT,bi,Te),pt.LOG,t(this,Li,"f").logLevel)}catch(e){Ot(`${e.message}`,pt.ERROR,t(this,Li,"f").logLevel),n(e)}})),this.uploadFiles=e=>new Promise(((i,n)=>{try{Ut(t(this,Oi,"f").clientJSON.config);Object.values(t(this,vi,"f")).forEach((e=>{if(!e.isMounted())throw new At(Rt.ELEMENTS_NOT_MOUNTED,[],!0);e.isValidElement()})),se.emit(be+t(this,Ti,"f"),Object.assign({},e),(e=>{!e||(null==e?void 0:e.error)?(Ot(`${JSON.stringify(null==e?void 0:e.error)}`,pt.ERROR,t(this,Li,"f").logLevel),n(null==e?void 0:e.error)):(Ot(Lt(re.COLLECT_SUBMIT_SUCCESS,bi),pt.LOG,t(this,Li,"f").logLevel),i(e))})),Ot(Lt(re.EMIT_EVENT,bi,be),pt.LOG,t(this,Li,"f").logLevel)}catch(e){Ot(`${e.message}`,pt.ERROR,t(this,Li,"f").logLevel),n(e)}})),i(this,Ti,fi(),"f"),i(this,Oi,n,"f"),i(this,mi,o,"f"),i(this,Li,s,"f"),i(this,Ai,new it,"f");const r=rt({name:`${de}:${t(this,Ti,"f")}:${t(this,Li,"f").logLevel}`});st(r,{src:at()}),lt(r,Object.assign({},We)),Ot(Lt(re.CREATE_COLLECT_CONTAINER,bi),pt.LOG,t(this,Li,"f").logLevel);const a=(e,o)=>{e.name===de+t(this,Ti,"f")&&(o(Object.assign(Object.assign({},n),{clientJSON:Object.assign(Object.assign({},n.clientJSON),{config:Object.assign({},n.clientJSON.config)}),context:s})),i(this,Ri,!0,"f"),t(this,Ai,"f")._emit(Ye,{containerId:t(this,Ti,"f")}),se.target(nt.IFRAME_SECURE_ORGIN).off(Ne+t(this,Ti,"f"),a))};se.target(nt.IFRAME_SECURE_ORGIN).on(Ne+t(this,Ti,"f"),a),document.body.append(r)}}Ti=new WeakMap,vi=new WeakMap,Oi=new WeakMap,Li=new WeakMap,mi=new WeakMap,Ai=new WeakMap,Ri=new WeakMap,yi=new WeakMap,Di=new WeakMap,Si=new WeakMap,gi=new WeakMap,Ci=new WeakMap;var 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},Pi=function(e){return e};var Ui,Vi,ki,Yi,xi,Bi,Fi,Gi,ji,Xi,$i,Wi,Ki,zi,Hi,qi,Ji,Zi,Qi,en,tn,nn,on,sn=A((function(e){return e&&e.length?Mi(e,Pi):0}));class rn{constructor(e,n){Ui.set(this,void 0),Vi.set(this,void 0),this.type=eo.COMPOSABLE,ki.set(this,!1),Yi.set(this,!1),this.update=e=>{i(this,Yi,!0,"f"),t(this,ki,"f")?(t(this,Vi,"f")._emit(we,{elementName:t(this,Ui,"f"),elementOptions:e}),i(this,Yi,!1,"f")):t(this,Yi,"f")&&t(this,Vi,"f").on(`${It.READY}:${t(this,Ui,"f")}`,(()=>{t(this,Vi,"f")._emit(we,{elementName:t(this,Ui,"f"),elementOptions:e}),i(this,ki,!0,"f"),i(this,Yi,!1,"f")}))},i(this,Ui,e,"f"),i(this,Vi,n,"f"),t(this,Vi,"f").on(`${It.READY}:${t(this,Ui,"f")}`,(()=>{i(this,ki,!0,"f")}))}on(e,i){if(!Object.values(fe).includes(e))throw new At(Rt.INVALID_EVENT_LISTENER,[],!0);if(!i)throw new At(Rt.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof i)throw new At(Rt.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);t(this,Vi,"f").on(`${e}:${t(this,Ui,"f")}`,(e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,i(e)}))}}Ui=new WeakMap,Vi=new WeakMap,ki=new WeakMap,Yi=new WeakMap;const an="CollectContainer";class ln extends Ni{constructor(e,n,o,s){super(),xi.set(this,void 0),Bi.set(this,{}),Fi.set(this,void 0),Gi.set(this,{rows:[]}),ji.set(this,[]),Xi.set(this,void 0),$i.set(this,void 0),Wi.set(this,void 0),Ki.set(this,!1),zi.set(this,void 0),Hi.set(this,void 0),this.type=eo.COMPOSABLE,qi.set(this,!1),Ji.set(this,{}),this.create=(e,i={required:!1})=>{Vt(e,t(this,Xi,"f").logLevel);const n=hi(e),o=pi(e.type,i,t(this,Xi,"f").logLevel),s=`${Ee}:${e.type}:${btoa(fi())}`;return t(this,ji,"f").push(Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column},e),o),{validations:n,elementName:s})),new rn(s,t(this,Wi,"f"))},Zi.set(this,((e,n=!1)=>{const o=[];if(i(this,Ji,dt(e),"f"),t(this,Ji,"f").rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;_i(i,t),t.sensitive=t.sensitive||je[i].sensitive,t.replacePattern=t.replacePattern||je[i].replacePattern,t.mask=t.mask||je[i].mask,t.isMounted=!1,t.label=e.label,t.skyflowID=e.skyflowID,o.push(t)}))})),t(this,Ji,"f").elementName=n?o[0].elementName:`${Ee}:group:${btoa(t(this,Ji,"f").name)}`,n&&!t(this,Bi,"f")[o[0].elementName]&&t(this,nn,"f").call(this,o[0].name))throw new At(Rt.UNIQUE_ELEMENT_NAME,[`${o[0].name}`],!0);let s=t(this,Bi,"f")[t(this,Ji,"f").elementName];if(s)n?s.update(o[0]):s.update(t(this,Ji,"f"));else{const e=fi();s=new Ei(e,t(this,Ji,"f"),t(this,Fi,"f"),{containerId:t(this,xi,"f"),isMounted:t(this,qi,"f"),type:this.type},!0,t(this,en,"f"),t(this,tn,"f"),t(this,Xi,"f"),t(this,Wi,"f")),t(this,Bi,"f")[t(this,Ji,"f").elementName]=s,t(this,$i,"f")[e]=s}return s})),Qi.set(this,(e=>{Object.keys(t(this,Bi,"f")).forEach((i=>{i===e&&delete t(this,Bi,"f")[i]}))})),en.set(this,(e=>{e.forEach((e=>{t(this,Qi,"f").call(this,e)}))})),tn.set(this,(e=>{e.forEach((e=>{t(this,Bi,"f")[e.elementName]&&t(this,Bi,"f")[e.elementName].update(e)}))})),nn.set(this,(e=>{const i=Object.keys(t(this,Bi,"f"));for(let t=0;t<i.length;t+=1)if(atob(i[t].split(":")[2])===e)return!0;return!1})),this.on=(e,i)=>{if(!Object.values(fe).includes(e))throw new At(Rt.INVALID_EVENT_LISTENER,[],!0);if(!i)throw new At(Rt.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof i)throw new At(Rt.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);t(this,Wi,"f").on(fe.SUBMIT,(()=>{i()}))},this.mount=e=>{if(!e)throw new At(Rt.EMPTY_ELEMENT_IN_MOUNT,["CollectElement"],!0);const{layout:n}=t(this,zi,"f");if(sn(n)!==t(this,ji,"f").length)throw new At(Rt.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM,[],!0);let o=0;if(n.forEach(((e,i)=>{t(this,Gi,"f").rows=[...t(this,Gi,"f").rows,{elements:[]}];for(let n=0;n<e;n++)t(this,Gi,"f").rows[i].elements.push(t(this,ji,"f")[o]),o++})),t(this,zi,"f").styles&&(t(this,Gi,"f").styles=Object.assign({},t(this,zi,"f").styles)),t(this,zi,"f").errorTextStyles&&(t(this,Gi,"f").errorTextStyles=Object.assign({},t(this,zi,"f").errorTextStyles)),t(this,qi,"f"))return i(this,Hi,t(this,Zi,"f").call(this,t(this,Gi,"f"),!1),"f"),t(this,Hi,"f").mount(e),void i(this,Ki,!0,"f");t(this,Wi,"f").on(ke+t(this,xi,"f"),(()=>{i(this,Hi,t(this,Zi,"f").call(this,t(this,Gi,"f"),!1),"f"),t(this,Hi,"f").mount(e),i(this,Ki,!0,"f")}))},this.unmount=()=>{t(this,Hi,"f").unmount()},this.collect=(e={tokens:!0})=>new Promise(((i,n)=>{try{if(Ut(t(this,Fi,"f").clientJSON.config),!t(this,Ki,"f"))throw new At(Rt.COMPOSABLE_CONTAINER_NOT_MOUNTED,[],!0);ui(t(this,Ji,"f")).forEach((e=>{if(!(null==e?void 0:e.isMounted))throw new At(Rt.ELEMENTS_NOT_MOUNTED,[],!0)}));if(Object.values(t(this,Bi,"f")).forEach((e=>{e.isValidElement()})),e&&e.tokens&&"boolean"!=typeof e.tokens)throw new At(Rt.INVALID_TOKENS_IN_COLLECT,[],!0);(null==e?void 0:e.additionalFields)&&Dt(e.additionalFields),(null==e?void 0:e.upsert)&&kt(null==e?void 0:e.upsert),se.emit(Te+t(this,xi,"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)?(Ot(`${JSON.stringify(null==e?void 0:e.error)}`,pt.ERROR,t(this,Xi,"f").logLevel),n(null==e?void 0:e.error)):(Ot(Lt(re.COLLECT_SUBMIT_SUCCESS,an),pt.LOG,t(this,Xi,"f").logLevel),i(e))})),Ot(Lt(re.EMIT_EVENT,an,Te),pt.LOG,t(this,Xi,"f").logLevel)}catch(e){Ot(`${e.message}`,pt.ERROR,t(this,Xi,"f").logLevel),n(e)}})),on.set(this,(()=>{t(this,Wi,"f").on(we,(e=>{let i;const n=t(this,ji,"f").map(((t,n)=>t.elementName===e.elementName?(i=n,Object.assign({elementName:t.elementName},e.elementOptions)):t));t(this,Hi,"f")&&t(this,Hi,"f").updateElement(Object.assign({},n[i]))}))})),i(this,xi,fi(),"f"),i(this,Fi,n,"f"),i(this,$i,o,"f"),i(this,Xi,s,"f"),i(this,zi,e,"f"),i(this,Wi,new it,"f");const r=rt({name:`${de}:${t(this,xi,"f")}:${t(this,Xi,"f").logLevel}`});st(r,{src:at()}),lt(r,Object.assign({},We)),Ot(Lt(re.CREATE_COLLECT_CONTAINER,an),pt.LOG,t(this,Xi,"f").logLevel);const a=(e,o)=>{e.name===de+t(this,xi,"f")&&(o(Object.assign(Object.assign({},n),{clientJSON:Object.assign(Object.assign({},n.clientJSON),{config:Object.assign({},n.clientJSON.config)}),context:s})),i(this,qi,!0,"f"),t(this,Wi,"f")._emit(ke+t(this,xi,"f"),{containerId:t(this,xi,"f")}),se.target(nt.IFRAME_SECURE_ORGIN).off(Ne+t(this,xi,"f"),a))};se.target(nt.IFRAME_SECURE_ORGIN).on(Ne+t(this,xi,"f"),a),document.body.append(r),t(this,on,"f").call(this)}}var dn,cn,En,_n,In,un,hn,pn,fn,Nn;xi=new WeakMap,Bi=new WeakMap,Fi=new WeakMap,Gi=new WeakMap,ji=new WeakMap,Xi=new WeakMap,$i=new WeakMap,Wi=new WeakMap,Ki=new WeakMap,zi=new WeakMap,Hi=new WeakMap,qi=new WeakMap,Ji=new WeakMap,Zi=new WeakMap,Qi=new WeakMap,en=new WeakMap,tn=new WeakMap,nn=new WeakMap,on=new WeakMap;class Tn extends jt{constructor(e,n={},o,s,r,a){super(),dn.set(this,void 0),cn.set(this,void 0),En.set(this,void 0),_n.set(this,void 0),In.set(this,!1),un.set(this,!1),hn.set(this,void 0),pn.set(this,void 0),fn.set(this,!1),Nn.set(this,void 0),i(this,pn,r,"f"),i(this,cn,o,"f"),i(this,En,Object.assign(Object.assign({},e),(e=>{let t={};if(e){if(t=Object.assign({},e),Object.prototype.hasOwnProperty.call(t,"enableCopy")&&!Yt(t.enableCopy))throw new At(Rt.INVALID_BOOLEAN_OPTIONS,["enableCopy"],!0);if(Object.prototype.hasOwnProperty.call(t,"format")||Object.prototype.hasOwnProperty.call(t,"translation")){const e=[];t.format&&e.push(t.format),e.push(null),t.translation?e.push(t.translation):t.format&&e.push(tt),t=Object.assign(Object.assign({},t),3===e.length?{mask:e}:{}),null==t||delete t.format,null==t||delete t.translation}}return t})(n)),"f"),i(this,_n,s.containerId,"f"),i(this,fn,s.isMounted,"f"),i(this,Nn,s.eventEmitter,"f"),i(this,hn,a,"f"),i(this,dn,new Gt(`reveal:${btoa(fi())}`,{metaData:o},t(this,_n,"f"),t(this,hn,"f").logLevel),"f"),t(this,fn,"f")||t(this,Nn,"f").on(xe,(e=>{(null==e?void 0:e.containerId)===t(this,_n,"f")&&i(this,fn,!0,"f")})),Ot(Lt(re.CREATED_ELEMENT,"RevealElement",`${e.token||""} reveal `),pt.LOG,t(this,hn,"f").logLevel)}getID(){return t(this,pn,"f")}mount(e){var n;if(!e)throw new At(Rt.EMPTY_ELEMENT_IN_MOUNT,["RevealElement"],!0);const o=(e,n)=>{e.name===t(this,dn,"f").name&&(n(Object.assign(Object.assign({},t(this,cn,"f")),{record:t(this,En,"f"),context:t(this,hn,"f")})),se.off(Ae,o),se.emit(Ue+t(this,_n,"f"),{id:t(this,En,"f").token,containerId:t(this,_n,"f")}),i(this,In,!0,"f"))};if(t(this,fn,"f"))return t(this,dn,"f").mount(e),void se.target(nt.IFRAME_SECURE_ORGIN).on(Ae,o);null===(n=t(this,Nn,"f"))||void 0===n||n.on(xe,(i=>{(null==i?void 0:i.containerId)===t(this,_n,"f")&&(t(this,dn,"f").mount(e),se.target(nt.IFRAME_SECURE_ORGIN).on(Ae,o))}))}iframeName(){return t(this,dn,"f").name}isMounted(){return t(this,In,"f")}hasToken(){return!!t(this,En,"f").token}isClientSetError(){return t(this,un,"f")}getRecordData(){return t(this,En,"f")}setError(e){se.emit(ge,{name:t(this,dn,"f").name,isTriggerError:!0,clientErrorText:e}),i(this,un,!0,"f")}resetError(){se.emit(ge,{name:t(this,dn,"f").name,isTriggerError:!1}),i(this,un,!1,"f")}setAltText(e){se.emit(Ce,{name:t(this,dn,"f").name,updateType:Pe,updatedValue:e})}clearAltText(){se.emit(Ce,{name:t(this,dn,"f").name,updateType:Pe,updatedValue:null})}setToken(e){i(this,En,Object.assign(Object.assign({},t(this,En,"f")),{token:e}),"f"),se.emit(Ce,{name:t(this,dn,"f").name,updateType:Me,updatedValue:e})}unmount(){t(this,dn,"f").unmount()}}var vn,On,Ln,mn,An,Rn,yn,Dn,Sn,gn,Cn;dn=new WeakMap,cn=new WeakMap,En=new WeakMap,_n=new WeakMap,In=new WeakMap,un=new WeakMap,hn=new WeakMap,pn=new WeakMap,fn=new WeakMap,Nn=new WeakMap;const bn="RevealContainer";class wn extends Ni{constructor(e,n,o){super(),vn.set(this,[]),On.set(this,[]),Ln.set(this,[]),mn.set(this,void 0),An.set(this,void 0),Rn.set(this,void 0),yn.set(this,!1),Dn.set(this,!1),Sn.set(this,void 0),gn.set(this,void 0),Cn.set(this,void 0),this.type=eo.REVEAL,i(this,mn,e,"f"),i(this,gn,n,"f"),i(this,An,fi(),"f"),i(this,Rn,new it,"f"),i(this,Sn,o,"f");const s=rt({name:`${ce}:${t(this,An,"f")}`});st(s,{src:at()}),lt(s,Object.assign({},We)),Ot(Lt(re.CREATE_REVEAL_CONTAINER,bn),pt.LOG,t(this,Sn,"f").logLevel);const r=(n,s)=>{n.name===ce&&(s(Object.assign(Object.assign({},e),{clientJSON:Object.assign(Object.assign({},e.clientJSON),{config:Object.assign({},e.clientJSON.config),context:o})})),i(this,Cn,!0,"f"),t(this,Rn,"f")._emit(xe,{containerId:t(this,An,"f")}),se.target(nt.IFRAME_SECURE_ORGIN).off(Ae+t(this,An,"f"),r))};se.target(nt.IFRAME_SECURE_ORGIN).on(Ae+t(this,An,"f"),r),document.body.append(s),se.target(window.location.origin).on(Ue+t(this,An,"f"),(e=>{t(this,Ln,"f").push(e),i(this,Dn,t(this,Ln,"f").length===t(this,On,"f").length,"f"),t(this,yn,"f")&&t(this,Dn,"f")&&t(this,Rn,"f")._emit(Ve+t(this,An,"f"),{containerId:t(this,An,"f")})}))}create(e,i){const n=fi();xt(i);const o=new Tn(e,i,t(this,mn,"f"),{containerId:t(this,An,"f"),isMounted:t(this,Cn,"f"),eventEmitter:t(this,Rn,"f")},n,t(this,Sn,"f"));return t(this,On,"f").push(o),t(this,gn,"f")[n]=o,o}reveal(){return i(this,yn,!0,"f"),t(this,Dn,"f")?new Promise(((e,n)=>{try{Ut(t(this,mn,"f").clientJSON.config),Ot(Lt(re.VALIDATE_REVEAL_RECORDS,bn),pt.LOG,t(this,Sn,"f").logLevel),t(this,On,"f").forEach((e=>{if(e.isClientSetError())throw new At(Rt.REVEAL_ELEMENT_ERROR_STATE);t(this,vn,"f").push(e.getRecordData())})),wt(t(this,vn,"f")),se.emit(me+t(this,An,"f"),{records:t(this,vn,"f")},(o=>{i(this,Ln,[],"f"),i(this,vn,[],"f"),o.error?(Ot(ae.FAILED_REVEAL,pt.ERROR,t(this,Sn,"f").logLevel),n(o.error)):(Ot(Lt(re.REVEAL_SUBMIT_SUCCESS,bn),pt.LOG,t(this,Sn,"f").logLevel),e(o))})),Ot(Lt(re.EMIT_EVENT,bn,me),pt.LOG,t(this,Sn,"f").logLevel)}catch(e){Ot(`Error: ${e.message}`,pt.ERROR,t(this,Sn,"f").logLevel),n(e)}})):new Promise(((e,n)=>{try{Ut(t(this,mn,"f").clientJSON.config),Ot(Lt(re.VALIDATE_REVEAL_RECORDS,bn),pt.LOG,t(this,Sn,"f").logLevel);const o=setTimeout((()=>{Ot(ae.ELEMENTS_NOT_MOUNTED_REVEAL,pt.ERROR,t(this,Sn,"f").logLevel),n(ae.ELEMENTS_NOT_MOUNTED_REVEAL)}),3e4);t(this,On,"f").forEach((e=>{if(e.isClientSetError())throw clearTimeout(o),new At(Rt.REVEAL_ELEMENT_ERROR_STATE);t(this,vn,"f").push(e.getRecordData())})),wt(t(this,vn,"f")),t(this,Rn,"f").on(Ve+t(this,An,"f"),(()=>{clearTimeout(o),se.emit(me+t(this,An,"f"),{records:t(this,vn,"f")},(o=>{i(this,vn,[],"f"),i(this,Ln,[],"f"),o.error?(Ot(ae.FAILED_REVEAL,pt.ERROR,t(this,Sn,"f").logLevel),n(o.error)):(Ot(Lt(re.REVEAL_SUBMIT_SUCCESS,bn),pt.LOG,t(this,Sn,"f").logLevel),e(o))}))}))}catch(e){Ot(e.message,pt.ERROR,t(this,Sn,"f").logLevel),n(e)}}))}}var Mn,Pn,Un,Vn;vn=new WeakMap,On=new WeakMap,Ln=new WeakMap,mn=new WeakMap,An=new WeakMap,Rn=new WeakMap,yn=new WeakMap,Dn=new WeakMap,Sn=new WeakMap,gn=new WeakMap,Cn=new WeakMap;const kn="SkyflowContainer";class Yn{constructor(e,n){var o,s;Mn.set(this,void 0),Pn.set(this,void 0),Un.set(this,!1),Vn.set(this,void 0),i(this,Pn,e,"f"),i(this,Mn,(null===(s=null===(o=t(this,Pn,"f").toJSON())||void 0===o?void 0:o.metaData)||void 0===s?void 0:s.uuid)||"","f"),i(this,Vn,n,"f");const r=rt({name:`skyflow_controller:${t(this,Mn,"f")}`});st(r,{src:at()}),lt(r,Object.assign({},We)),document.body.append(r),se.target(nt.IFRAME_SECURE_ORGIN).on(ye+t(this,Mn,"f"),((e,o)=>{Ot(Lt(re.CAPTURE_PUREJS_FRAME,kn),pt.LOG,t(this,Vn,"f").logLevel),o({client:t(this,Pn,"f"),context:n}),i(this,Un,!0,"f")})),Ot(Lt(re.PUREJS_CONTROLLER_INITIALIZED,kn),pt.LOG,t(this,Vn,"f").logLevel)}detokenize(e){return t(this,Un,"f")?new Promise(((i,n)=>{try{Ut(t(this,Pn,"f").config),Ot(Lt(re.VALIDATE_DETOKENIZE_INPUT,kn),pt.LOG,t(this,Vn,"f").logLevel),St(e),se.emit(Re+t(this,Mn,"f"),{type:Ie,records:e.records},(e=>{e.error?n(e.error):i(e)})),Ot(Lt(re.EMIT_PURE_JS_REQUEST,kn,Ie),pt.LOG,t(this,Vn,"f").logLevel)}catch(e){Ot(e.message,pt.ERROR,t(this,Vn,"f").logLevel),n(e)}})):new Promise(((i,n)=>{try{Ut(t(this,Pn,"f").config),Ot(Lt(re.VALIDATE_DETOKENIZE_INPUT,kn),pt.LOG,t(this,Vn,"f").logLevel),St(e),se.target(nt.IFRAME_SECURE_ORGIN).on(ye+t(this,Mn,"f"),(()=>{se.emit(Re+t(this,Mn,"f"),{type:Ie,records:e.records},(e=>{e.error?n(e.error):i(e)}))})),Ot(Lt(re.EMIT_PURE_JS_REQUEST,kn,Ie),pt.LOG,t(this,Vn,"f").logLevel)}catch(e){Ot(e.message,pt.ERROR,t(this,Vn,"f").logLevel),n(e)}}))}insert(e,i){return t(this,Un,"f")?new Promise(((n,o)=>{Ut(t(this,Pn,"f").config);try{Ot(Lt(re.VALIDATE_RECORDS,kn),pt.LOG,t(this,Vn,"f").logLevel),(null==(i=i?Object.assign(Object.assign({},i),{tokens:void 0===(null==i?void 0:i.tokens)||i.tokens}):{tokens:!0})?void 0:i.upsert)&&kt(i.upsert),yt(e,i),se.emit(Re+t(this,Mn,"f"),{type:_e,records:e,options:i},(e=>{e.error?(Ot(`${JSON.stringify(e.error)}`,pt.ERROR,t(this,Vn,"f").logLevel),o(e.error)):n(e)})),Ot(Lt(re.EMIT_PURE_JS_REQUEST,kn,_e),pt.LOG,t(this,Vn,"f").logLevel)}catch(e){Ot(e.message,pt.ERROR,t(this,Vn,"f").logLevel),o(e)}})):new Promise(((n,o)=>{try{Ut(t(this,Pn,"f").config),Ot(Lt(re.VALIDATE_RECORDS,kn),pt.LOG,t(this,Vn,"f").logLevel),(null==(i=i?Object.assign(Object.assign({},i),{tokens:void 0===(null==i?void 0:i.tokens)||i.tokens}):{tokens:!0})?void 0:i.upsert)&&kt(i.upsert),yt(e,i),se.target(nt.IFRAME_SECURE_ORGIN).on(ye+t(this,Mn,"f"),(()=>{se.emit(Re+t(this,Mn,"f"),{type:_e,records:e,options:i},(e=>{e.error?(Ot(`${JSON.stringify(e.error)}`,pt.ERROR,t(this,Vn,"f").logLevel),o(e.error)):n(e)}))})),Ot(Lt(re.EMIT_PURE_JS_REQUEST,kn,_e),pt.LOG,t(this,Vn,"f").logLevel)}catch(e){Ot(e.message,pt.ERROR,t(this,Vn,"f").logLevel),o(e)}}))}getById(e){return t(this,Un,"f")?new Promise(((i,n)=>{Ut(t(this,Pn,"f").config);try{Ot(Lt(re.VALIDATE_GET_BY_ID_INPUT,kn),pt.LOG,t(this,Vn,"f").logLevel),Ct(e),se.emit(Re+t(this,Mn,"f"),{type:ue,records:e.records},(e=>{e.error?n(e.error):i(e)})),Ot(Lt(re.EMIT_PURE_JS_REQUEST,kn,ue),pt.LOG,t(this,Vn,"f").logLevel)}catch(e){Ot(e.message,pt.ERROR,t(this,Vn,"f").logLevel),n(e)}})):new Promise(((i,n)=>{try{Ut(t(this,Pn,"f").config),Ot(Lt(re.VALIDATE_GET_BY_ID_INPUT,kn),pt.LOG,t(this,Vn,"f").logLevel),Ct(e),se.target(nt.IFRAME_SECURE_ORGIN).on(ye+t(this,Mn,"f"),(()=>{se.emit(Re+t(this,Mn,"f"),{type:ue,records:e.records},(e=>{e.error?n(e.error):i(e)}))})),Ot(Lt(re.EMIT_PURE_JS_REQUEST,kn,ue),pt.LOG,t(this,Vn,"f").logLevel)}catch(e){Ot(e.message,pt.ERROR,t(this,Vn,"f").logLevel),n(e)}}))}get(e){return t(this,Un,"f")?new Promise(((i,n)=>{Ut(t(this,Pn,"f").config);try{Ot(Lt(re.VALIDATE_GET_INPUT,kn),pt.LOG,t(this,Vn,"f").logLevel),gt(e),se.emit(Re+t(this,Mn,"f"),{type:he,records:e.records},(e=>{e.error?n(e.error):i(e)})),Ot(Lt(re.EMIT_PURE_JS_REQUEST,kn,he),pt.LOG,t(this,Vn,"f").logLevel)}catch(e){Ot(e.message,pt.ERROR,t(this,Vn,"f").logLevel),n(e)}})):new Promise(((i,n)=>{try{Ut(t(this,Pn,"f").config),Ot(Lt(re.VALIDATE_GET_INPUT,kn),pt.LOG,t(this,Vn,"f").logLevel),gt(e),se.target(nt.IFRAME_SECURE_ORGIN).on(ye+t(this,Mn,"f"),(()=>{se.emit(Re+t(this,Mn,"f"),{type:he,records:e.records},(e=>{e.error?n(e.error):i(e)}))})),Ot(Lt(re.EMIT_PURE_JS_REQUEST,kn,he),pt.LOG,t(this,Vn,"f").logLevel)}catch(e){Ot(e.message,pt.ERROR,t(this,Vn,"f").logLevel),n(e)}}))}delete(e,i){return t(this,Un,"f")?new Promise(((n,o)=>{Ut(t(this,Pn,"f").config);try{Ot(Lt(re.VALIDATE_DELETE_INPUT,kn),pt.LOG,t(this,Vn,"f").logLevel),bt(e),se.emit(Re+t(this,Mn,"f"),{type:pe,records:e,options:i},(e=>{e.error?(Ot(`${JSON.stringify(e.error)}`,pt.ERROR,t(this,Vn,"f").logLevel),o(e.error)):n(e)})),Ot(Lt(re.EMIT_PURE_JS_REQUEST,kn,pe),pt.LOG,t(this,Vn,"f").logLevel)}catch(e){Ot(e.message,pt.ERROR,t(this,Vn,"f").logLevel),o(e)}})):new Promise(((n,o)=>{try{Ut(t(this,Pn,"f").config),Ot(Lt(re.VALIDATE_RECORDS,kn),pt.LOG,t(this,Vn,"f").logLevel),bt(e),se.target(nt.IFRAME_SECURE_ORGIN).on(ye+t(this,Mn,"f"),(()=>{se.emit(Re+t(this,Mn,"f"),{type:pe,records:e,options:i},(e=>{e.error?(Ot(`${JSON.stringify(e.error)}`,pt.ERROR,t(this,Vn,"f").logLevel),o(e.error)):n(e)}))})),Ot(Lt(re.EMIT_PURE_JS_REQUEST,kn,pe),pt.LOG,t(this,Vn,"f").logLevel)}catch(e){Ot(e.message,pt.ERROR,t(this,Vn,"f").logLevel),o(e)}}))}}function xn(e){this.message=e}Mn=new WeakMap,Pn=new WeakMap,Un=new WeakMap,Vn=new WeakMap,xn.prototype=new Error,xn.prototype.name="InvalidCharacterError";var Bn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new xn("'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 Fn(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(Bn(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 Bn(t)}}function Gn(e){this.message=e}Gn.prototype=new Error,Gn.prototype.name="InvalidTokenError";const jn=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 Gn("Invalid token specified");var i=!0===(t=t||{}).header?0:1;try{return JSON.parse(Fn(e.split(".")[i]))}catch(e){throw new Gn("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 Xn,$n,Wn,Kn,zn,Hn,qn,Jn,Zn,Qn,eo,to={name:"skyflow-js",preferGlobal:!0,analyze:!1,version:"1.30.1",author:"Skyflow",description:"Skyflow JavaScript SDK"};class io{constructor(e,n){Xn.set(this,void 0),this.request=e=>new Promise(((i,n)=>{var o,s,r,a;const l=new XMLHttpRequest;if(l){if(l.open(e.requestMethod,e.url),e.headers){const i=function(e,t,i){var n,o,s,r,a;const l={sdkName:e.name,sdkVersion:e.version},d=function(e,t){return""!==e?`${e}`:`${t.sdkName}@${t.sdkVersion}`}(t.sdkVersion,l),c=function(e){var t,i,n,o,s,r,a,l,d,c,E,_;let I=null,u=null;return/Windows/.test(e)?(I="Windows",u=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)?(I="Android",u=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)?(I="iOS",u=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)?(I="Mac OS X",u=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)&&(I="Linux",u=null!==(_=null===(E=/Linux( \w+)*?\/([\w.]+)/.exec(e))||void 0===E?void 0:E[2])&&void 0!==_?_:null),{os:I,version:u}}(i.userAgent),E=function(e){let t="",i="";if(-1!==e.indexOf("MSIE")||-1!==e.indexOf("Trident/")){t="Internet Explorer";const n=e.match(/(MSIE|rv:)\s?([\d.]+)/);n&&(i=n[2])}else if(-1!==e.indexOf("Edge")){t="Microsoft Edge";const n=e.match(/Edge\/([\d.]+)/);n&&(i=n[1])}else if(-1!==e.indexOf("Chrome")){t="Google Chrome";const n=e.match(/Chrome\/([\d.]+)/);n&&(i=n[1])}else if(-1!==e.indexOf("Firefox")){t="Mozilla Firefox";const n=e.match(/Firefox\/([\d.]+)/);n&&(i=n[1])}else if(-1!==e.indexOf("Safari")){t="Apple Safari";const n=e.match(/Version\/([\d.]+)/);n&&(i=n[1])}return{browserName:t,browserVersion:i}}(i.userAgent);var _;return{sdk_name_version:d,sdk_client_device_model:(_=i.userAgent,/(ipad|tablet)/gi.test(_)?"tablet":/Mobile|iP(hone|od)|Android|BlackBerry|IEMobile/.test(_)?"mobile":"desktop"),sdk_os_version:null!==(n=i.platform)&&void 0!==n?n:`${null!==(o=c.os)&&void 0!==o?o:""} ${null!==(s=c.version)&&void 0!==s?s:""}`,sdk_runtime_details:`${null!==(r=E.browserName)&&void 0!==r?r:""} ${null!==(a=E.browserVersion)&&void 0!==a?a:""}`}}(to,t(this,Xn,"f"),navigator);e.headers["sky-metadata"]=JSON.stringify(i);const{headers:n}=e;Object.keys(e.headers).forEach((e=>{"content-type"===e&&n[e]&&n[e].includes(Qe.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(Qe.FORMURLENCODED))||(null===(a=null===(r=e.headers)||void 0===r?void 0:r["content-type"])||void 0===a?void 0:a.includes(Qe.FORMDATA))?l.send(e.body):l.send(JSON.stringify(Object.assign({},e.body))),l.onload=()=>{var e,t,o;const s=l.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};s.forEach((e=>{const t=e.split(": "),i=t.shift()||"",n=t.join(": ");r[i]=n}));const a=r["content-type"],d=r["x-request-id"];if(l.status<200||l.status>=400)if(a&&a.includes("application/json")){let i=JSON.parse(l.response);(null===(e=null==i?void 0:i.error)||void 0===e?void 0:e.message)&&(i=d?`${null===(t=null==i?void 0:i.error)||void 0===t?void 0:t.message} - requestId: ${d}`:null===(o=null==i?void 0:i.error)||void 0===o?void 0:o.message),n(new At({code:l.status,description:i},[],!0))}else a&&a.includes("text/plain")?n(new At({code:l.status,description:d?`${l.response} - requestId: ${d}`:l.response},[],!0)):n(new At({code:l.status,description:d?`${ae.ERROR_OCCURED} - requestId: ${d}`:ae.ERROR_OCCURED},[],!0));a&&a.includes("application/json")&&i(JSON.parse(l.response)),i(l.response)},l.onerror=()=>{n(new At(Rt.NETWORK_ERROR,[],!0))}}else n(new At(Rt.CONNECTION_ERROR,[],!0))})),this.config=e,i(this,Xn,n,"f")}toJSON(){return{config:this.config,metaData:t(this,Xn,"f")}}static fromJSON(e){return new io(e.config,e.metaData)}}Xn=new WeakMap,function(e){e.COLLECT="COLLECT",e.REVEAL="REVEAL",e.COMPOSABLE="COMPOSABLE"}(eo||(eo={}));const no="Skyflow";class oo{constructor(e){var n,o;$n.set(this,void 0),Wn.set(this,fi()),Kn.set(this,{uuid:t(this,Wn,"f"),clientDomain:window.location.origin}),zn.set(this,void 0),Hn.set(this,""),qn.set(this,void 0),Jn.set(this,void 0),Zn.set(this,void 0),Qn.set(this,void 0);const s=localStorage.getItem("sdk_version")||"";t(this,Kn,"f").sdkVersion=s,i(this,$n,new io(Object.assign({},e),t(this,Kn,"f")),"f"),i(this,Jn,(null===(n=null==e?void 0:e.options)||void 0===n?void 0:n.logLevel)||ut.ERROR,"f"),i(this,Zn,(null===(o=null==e?void 0:e.options)||void 0===o?void 0:o.env)||ht.PROD,"f"),i(this,Qn,{},"f"),i(this,zn,new Yn(t(this,$n,"f"),{logLevel:t(this,Jn,"f"),env:t(this,Zn,"f")}),"f");se.target(nt.IFRAME_SECURE_ORGIN).on(De+t(this,Wn,"f"),((e,n)=>{Ot(Lt(re.CAPTURED_BEARER_TOKEN_EVENT,no),pt.LOG,t(this,Jn,"f")),!t(this,$n,"f").config.getBearerToken||t(this,Hn,"f")&&jn(t(this,Hn,"f"))?(Ot(Lt(re.REUSE_BEARER_TOKEN,no),pt.LOG,t(this,Jn,"f")),n({authToken:t(this,Hn,"f")})):t(this,$n,"f").config.getBearerToken().then((e=>{jn(e)?(Ot(Lt(re.BEARER_TOKEN_RESOLVED,no),pt.LOG,t(this,Jn,"f")),i(this,Hn,e,"f"),n({authToken:t(this,Hn,"f")})):(Ot(ae.INVALID_BEARER_TOKEN,pt.ERROR,t(this,Jn,"f")),n({error:ae.INVALID_BEARER_TOKEN}))})).catch((e=>{Ot(ae.BEARER_TOKEN_REJECTED,pt.ERROR,t(this,Jn,"f")),n({error:e})}))})),Ot(Lt(re.BEARER_TOKEN_LISTENER,no),pt.LOG,t(this,Jn,"f")),Ot(Lt(re.CURRENT_ENV,no,t(this,Zn,"f")),pt.LOG,t(this,Jn,"f")),Ot(Lt(re.CURRENT_LOG_LEVEL,no,t(this,Jn,"f")),pt.LOG,t(this,Jn,"f"))}static init(e){var t;const i=(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||ut.ERROR;!function(e){var t,i,n,o;if((null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.customElementsURL)&&Mt(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}`;nt.IFRAME_SECURE_ORGIN=s,nt.IFRAME_SECURE_SITE=null===(o=null==e?void 0:e.options)||void 0===o?void 0:o.customElementsURL}}(e),Ot(Lt(re.INITIALIZE_CLIENT,no),pt.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 oo(n);return Ot(Lt(re.CLIENT_INITIALIZED,no),pt.LOG,i),s}container(e,i){switch(e){case eo.COLLECT:{const n=new wi(i,Object.assign(Object.assign({},t(this,Kn,"f")),{clientJSON:t(this,$n,"f").toJSON(),containerType:e}),t(this,Qn,"f"),{logLevel:t(this,Jn,"f"),env:t(this,Zn,"f")});return Ot(Lt(re.COLLECT_CONTAINER_CREATED,no),pt.LOG,t(this,Jn,"f")),n}case eo.REVEAL:{const i=new wn(Object.assign(Object.assign({},t(this,Kn,"f")),{clientJSON:t(this,$n,"f").toJSON(),containerType:e}),t(this,Qn,"f"),{logLevel:t(this,Jn,"f")});return Ot(Lt(re.REVEAL_CONTAINER_CREATED,no),pt.LOG,t(this,Jn,"f")),i}case eo.COMPOSABLE:{(e=>{if(!e)throw new At(Rt.MISSING_COMPOSABLE_CONTAINER_OPTIONS,[],!0);if("object"!=typeof e)throw new At(Rt.INVALID_COMPOSABLE_CONTAINER_OPTIONS,[],!0);if(!Object.prototype.hasOwnProperty.call(e,"layout"))throw new At(Rt.MISSING_COMPOSABLE_LAYOUT_KEY,[],!0);if(!e.layout)throw new At(Rt.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(!Array.isArray(e.layout))throw new At(Rt.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(0===e.layout.length)throw new At(Rt.EMPTY_COMPOSABLE_LAYOUT_ARRAY,[],!0);e.layout.forEach((e=>{if("number"!=typeof e)throw new At(Rt.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(e<0)throw new At(Rt.NEGATIVE_VALUES_COMPOSABLE_LAYOUT,[],!0)}))})(i);const n=new ln(i,Object.assign(Object.assign({},t(this,Kn,"f")),{clientJSON:t(this,$n,"f").toJSON(),containerType:e}),t(this,Qn,"f"),{logLevel:t(this,Jn,"f"),env:t(this,Zn,"f")});return Ot(Lt(re.COLLECT_CONTAINER_CREATED,no),pt.LOG,t(this,Jn,"f")),n}default:if(!e)throw new At(Rt.EMPTY_CONTAINER_TYPE,[],!0);throw new At(Rt.INVALID_CONTAINER_TYPE,[],!0)}}insert(e,i){return Ot(Lt(re.INSERT_TRIGGERED,no),pt.LOG,t(this,Jn,"f")),t(this,zn,"f").insert(e,i)}detokenize(e){return Ot(Lt(re.DETOKENIZE_TRIGGERED,no),pt.LOG,t(this,Jn,"f")),t(this,zn,"f").detokenize(e)}getById(e){return Ot(le.GET_BY_ID_DEPRECATED,pt.WARN,t(this,Jn,"f")),Ot(Lt(re.GET_BY_ID_TRIGGERED,no),pt.LOG,t(this,Jn,"f")),t(this,zn,"f").getById(e)}get(e){return Ot(Lt(re.GET_TRIGGERED,no),pt.LOG,t(this,Jn,"f")),t(this,zn,"f").get(e)}delete(e,i){return Ot(Lt(re.DELETE_TRIGGERED,no),pt.LOG,t(this,Jn,"f")),t(this,zn,"f").delete(e,i)}static get ContainerType(){return eo}static get ElementType(){return Be}static get RedactionType(){return Et}static get RequestMethod(){return _t}static get LogLevel(){return ut}static get EventName(){return It}static get Env(){return ht}static get ValidationRuleType(){return ft}}$n=new WeakMap,Wn=new WeakMap,Kn=new WeakMap,zn=new WeakMap,Hn=new WeakMap,qn=new WeakMap,Jn=new WeakMap,Zn=new WeakMap,Qn=new WeakMap;class so{constructor(e){this.loadFunction=e,this.loadScript()}get loader(){return this.loadingPromise||(this.loadingPromise=this.loadScript()),this.loadingPromise}loadScript(){return e(this,void 0,void 0,(function*(){return this.loadingPromise||(this.loadingPromise=new Promise(((e,t)=>{this.loadFunction().then((t=>{t&&e(t)}),(()=>{t()})).catch((()=>{}))}))),this.loadingPromise}))}}class ro extends O{constructor(e){super("span",{id:e.id,className:"payrails-store-instrument"}),this.options=e,this.createHTML(),this.applyStyles(),this.addListeners()}get isChecked(){var e;return!!(null===(e=this.element.querySelector("input"))||void 0===e?void 0:e.checked)}createHTML(){var e,t,i,n,o,s,r,a,l;const d=(null===(i=null===(t=null===(e=this.options)||void 0===e?void 0:e.translations)||void 0===t?void 0:t.labels)||void 0===i?void 0:i.saveInstrument)||(null===(s=null===(o=null===(n=this.options)||void 0===n?void 0:n.translations)||void 0===o?void 0:o.labels)||void 0===s?void 0:s.storeInstrument)||"Save instrument for future payments",c=`${this.id}-checkbox`;(null===(l=null===(a=null===(r=this.options)||void 0===r?void 0:r.translations)||void 0===a?void 0:a.labels)||void 0===l?void 0:l.saveInstrument)&&console.warn("The saveInstrument label is deprecated, please use storeInstrument instead"),this.element.innerHTML=`<label for="${c}"><input type="checkbox" id="${c}" name="${c}" class="payrails-store-instrument-checkbox">${d}</label>`}applyStyles(){var e,t;Object.keys((null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.storeInstrumentCheckbox)||{}).forEach((e=>{var t,i,n;this.element.style[e]=null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===i?void 0:i.storeInstrumentCheckbox)||void 0===n?void 0:n[e]}))}addListeners(){this.element.addEventListener("change",(e=>{var t,i,n,o;(null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onSaveInstrumentCheckboxChanged)&&(null===(o=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===o||o.onSaveInstrumentCheckboxChanged({checked:this.isChecked})),e.stopPropagation(),e.stopImmediatePropagation()}))}}class ao extends O{constructor(t,i){var n,o;super(t,i),this.options=i,this.storeInstrumentCheckbox=null,(null===(n=this.options)||void 0===n?void 0:n.showStoreInstrumentCheckbox)&&(this.storeInstrumentCheckbox=new ro(Object.assign(Object.assign({},i),{id:`${null===(o=this.options)||void 0===o?void 0:o.id}-store-instrument-checkbox`,events:{onSaveInstrumentCheckboxChanged:t=>e(this,void 0,void 0,(function*(){var e,n;null===(n=null===(e=null==i?void 0:i.events)||void 0===e?void 0:e.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(e,t)}))}})),this.subElements.push(this.storeInstrumentCheckbox))}get shouldStoreInstrument(){var e,t;return(null===(e=this.storeInstrumentCheckbox)||void 0===e?void 0:e.isChecked)||(null===(t=this.options)||void 0===t?void 0:t.alwaysStoreInstrument)||!1}}class lo extends ao{constructor(t,i,n){super("div",Object.assign(Object.assign({},n),{id:"payrails-apple-pay-button"})),this.sdkConfig=t,this.execution=i,this.options=n,this.appleButton=null,this.paymentExecutor=new p(t,i),this.loadScript=new so((()=>e(this,void 0,void 0,(function*(){const t=document.createElement("script");return t.src="https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js",new Promise(((i,n)=>{t.onload=()=>e(this,void 0,void 0,(function*(){var e,t,n;(yield this.isApplePayAvailable())?(null===(n=null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onApplePayAvailable)||void 0===n||n.call(t),i(!0)):i(!1)})),t.onerror=()=>{n()},document.body.appendChild(t)}))}))))}mount(t){super.mount(t),(()=>{e(this,void 0,void 0,(function*(){try{yield this.loadScript.loader,yield this.mountApplePayButton()}catch(e){}}))})()}unmount(){var e,t;null===(t=null===(e=this.appleButton)||void 0===e?void 0:e.parentElement)||void 0===t||t.removeChild(this.appleButton),super.unmount()}isApplePayAvailable(){return e(this,void 0,void 0,(function*(){if(!(null===window||void 0===window?void 0:window.ApplePaySession))return!1;return yield ApplePaySession.canMakePayments()}))}mountApplePayButton(){var t,i,n,o,s;return e(this,void 0,void 0,(function*(){if(null===window||void 0===window?void 0:window.ApplePaySession)try{if(!this.isApplePayAvailable())return;null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onApplePayAvailable)||void 0===i||i.call(t);const e=(null===(n=this.options.styles)||void 0===n?void 0:n.type)||"buy",r=(null===(o=this.options.styles)||void 0===o?void 0:o.style)||"black";this.element.innerHTML=`<apple-pay-button buttonstyle="${r}" type="${e}" locale="en-GB"></apple-pay-button>`,null===(s=this.storeInstrumentCheckbox)||void 0===s||s.mount(this.selector);const a=this.element.querySelector("apple-pay-button");null==a||a.setAttribute("style","width: 100%;"),null==a||a.addEventListener("click",(()=>{this.createApplePaySession()}))}catch(e){}}))}createApplePaySession(){const t=this.execution.applePayConfig,{countryCode:i,supportedNetworks:n,merchantCapabilities:o}=t,{amount:s}=this.sdkConfig;try{const t={countryCode:i,currencyCode:s.currency,merchantCapabilities:o,supportedNetworks:n,total:{label:"",type:"final",amount:s.value}},r=new ApplePaySession(3,t);return r.onvalidatemerchant=t=>e(this,void 0,void 0,(function*(){const{res:e}=yield this.paymentExecutor.createApplePaySession({requestUrl:this.execution.createSessionLink,sessionUrl:t.validationURL,clientDomain:this.options.clientDomain}),i=e.data.data;r.completeMerchantValidation(i)})),r.onpaymentauthorized=t=>e(this,void 0,void 0,(function*(){var e,i,n,o,s,a,l,d,c,E,_,I;try{const E=yield this.onApplePayAuthorized(t.payment.token);if("authorizeSuccessful"===(null===(e=null==E?void 0:E.finalState)||void 0===e?void 0:e.code))(null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeSuccess)&&this.options.events.onAuthorizeSuccess();else r.completePayment(ApplePaySession.STATUS_FAILURE),(null===(o=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===o?void 0:o.onAuthorizeFailed)&&(null===(s=this.options)||void 0===s||s.events.onAuthorizeFailed());r.completePayment(ApplePaySession.STATUS_SUCCESS),(null===(l=null===(a=this.options)||void 0===a?void 0:a.events)||void 0===l?void 0:l.onAuthorizeSuccess)&&(null===(c=null===(d=this.options)||void 0===d?void 0:d.events)||void 0===c||c.onAuthorizeSuccess(E))}catch(e){r.completePayment(ApplePaySession.STATUS_FAILURE),(null===(_=null===(E=this.options)||void 0===E?void 0:E.events)||void 0===_?void 0:_.onAuthorizeFailed)&&(null===(I=this.options)||void 0===I||I.events.onAuthorizeFailed(e))}})),r.begin(),r}catch(e){return null}}onApplePayAuthorized(t){return e(this,void 0,void 0,(function*(){const e={paymentData:t.paymentData,transactionIdentifier:t.transactionIdentifier,paymentNetwork:t.paymentMethod.network,paymentInstrumentName:t.paymentMethod.displayName},i=[{paymentMethodCode:"applePay",integrationType:"api",paymentInstrumentData:{paymentToken:JSON.stringify(e)},amount:this.sdkConfig.amount,storeInstrument:this.shouldStoreInstrument}];return yield this.paymentExecutor.pay(i)}))}}const{CARD_NUMBER:co,CVV:Eo,CARDHOLDER_NAME:_o,EXPIRATION_MONTH:Io,EXPIRATION_YEAR:uo}=exports.ElementType,ho={base:{border:"none",padding:"10px 16px",color:"#1d1d1d",backgroundColor:"#fff"},invalid:{backgroundColor:"#f9e1e1",borderColor:"#f25226",border:"1px solid"}},po=[{type:_o,placeholder:"Card holder",styles:Object.assign(Object.assign({},ho),{base:Object.assign(Object.assign({},ho.base),{border:"1px solid #eae8ee",padding:"10px 16px",borderTopLeftRadius:"4px",borderTopRightRadius:"4px"})})},{type:co,placeholder:"1234 1234 1234 1234",styles:Object.assign(Object.assign({},ho),{base:Object.assign(Object.assign({},ho.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:Io,placeholder:"MM",styles:Object.assign(Object.assign({},ho),{base:Object.assign(Object.assign({},ho.base),{borderBottom:"1px solid #eae8ee",borderLeft:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomLeftRadius:"4px"})})},{type:uo,placeholder:"YY",format:"YY",styles:Object.assign(Object.assign({},ho),{base:Object.assign(Object.assign({},ho.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee"})})},{type:Eo,placeholder:"CVC",styles:Object.assign(Object.assign({},ho),{base:Object.assign(Object.assign({},ho.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomRightRadius:"4px"})})}];class fo extends ao{get bin(){return this.collectContainer.bin}constructor(e,t){var i,n,o,s,r;super("div",Object.assign(Object.assign({},t),{translations:Object.assign(Object.assign({},null==t?void 0:t.translations),{labels:Object.assign(Object.assign({},null===(i=null==t?void 0:t.translations)||void 0===i?void 0:i.labels),{saveInstrument:null===(o=null===(n=null==t?void 0:t.translations)||void 0===n?void 0:n.labels)||void 0===o?void 0:o.saveCreditCard})}),styles:Object.assign({storeInstrumentCheckbox:null===(s=null==t?void 0:t.styles)||void 0===s?void 0:s.storeCardCheckbox},null==t?void 0:t.styles),id:"payrails-card-form"})),this.collectContainer=e,this.options=t,this.formFields=[],(null===(r=null==t?void 0:t.styles)||void 0===r?void 0:r.storeCardCheckbox)&&console.warn("The `storeCardCheckbox` option for styles is deprecated. Please use `storeInstrumentCheckbox` instead."),po.forEach((({type:e,styles:i,format:n,placeholder:o})=>{var s,r,a,l,d,c,E;if(!(null===(s=this.options)||void 0===s?void 0:s.showCardHolderName)&&e===exports.ElementType.CARDHOLDER_NAME)return;const _=new No(this.collectContainer,{type:e,label:null===(a=null===(r=null==t?void 0:t.translations)||void 0===r?void 0:r.labels)||void 0===a?void 0:a[e],placeholder:(null===(d=null===(l=null==t?void 0:t.translations)||void 0===l?void 0:l.placeholders)||void 0===d?void 0:d[e])||o,labelStyles:this.prepareLabelStyles(e),inputStyles:this.prepareInputStyles(i,e),format:n,events:{onFocus:null===(E=null===(c=this.options)||void 0===c?void 0:c.events)||void 0===E?void 0:E.onFocus,onChange:this.onChange.bind(this),onReady:this.triggerOnReady.bind(this)}});this.formFields.push(_)})),this.subElements.push(this.collectContainer),this.storeInstrumentCheckbox&&this.subElements.push(this.storeInstrumentCheckbox)}show(){var e,t;const i=document.getElementById(this.collectContainer.id);if(!i)throw new Error("Container is not mounted.");Object.assign(i.style,null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.wrapper),this.element.style.display="flex"}hide(){this.element.style.display="none"}triggerOnReady(){var e,t,i;this.formFields.reduce(((e,t)=>e&&t.isReady),!0)&&(null===(i=null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onReady)||void 0===i||i.call(t))}prepareLabelStyles(e){return["base"].reduce(((t,i)=>{var n,o,s,r,a,l,d,c;return t[i]=Object.assign(Object.assign(Object.assign({},null===(o=null===(n=this.options)||void 0===n?void 0:n.styles)||void 0===o?void 0:o.base),null===(a=null===(r=null===(s=this.options)||void 0===s?void 0:s.styles)||void 0===r?void 0:r.labels)||void 0===a?void 0:a.all),null===(c=null===(d=null===(l=this.options)||void 0===l?void 0:l.styles)||void 0===d?void 0:d.labels)||void 0===c?void 0:c[e]),t}),{})}prepareInputStyles(e,t){var i;let n=JSON.parse(JSON.stringify(e));return(null===(i=this.options)||void 0===i?void 0:i.showCardHolderName)&&t===exports.ElementType.CARD_NUMBER&&(this.element.setAttribute("class","with-card-holder"),n=Object.assign(Object.assign({},e),{base:Object.assign(Object.assign({},ho.base),{border:"1px solid #eae8ee",borderTop:"none",padding:"10px 16px",textIndent:"0"})})),["base","complete","empty","focus","invalid","cardIcon","copyIcon"].forEach((e=>{var i,o,s,r,a,l,d,c;n[e]=Object.assign(Object.assign(Object.assign({},n[e]),null===(r=null===(s=null===(o=null===(i=this.options)||void 0===i?void 0:i.styles)||void 0===o?void 0:o.inputFields)||void 0===s?void 0:s.all)||void 0===r?void 0:r[e]),null===(c=null===(d=null===(l=null===(a=this.options)||void 0===a?void 0:a.styles)||void 0===l?void 0:l.inputFields)||void 0===d?void 0:d[t])||void 0===c?void 0:c[e])})),n}get isValid(){return this.formFields.reduce(((e,t)=>e&&t.isValid),!0)}get cardNetwork(){var e,t;return null!==(t=null===(e=this.formFields.find((e=>Boolean(e.cardNetwork))))||void 0===e?void 0:e.cardNetwork)&&void 0!==t?t:""}onChange(){var e,t,i,n;(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onChange)&&(null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n||n.onChange({isValid:this.isValid,cardNetwork:this.cardNetwork,bin:this.bin}))}collectValues(){var t;return e(this,void 0,void 0,(function*(){return{tokenizedCardData:yield this.collectContainer.collect(),storeInstrument:this.shouldStoreInstrument,enrollInstrumentToNetworkOffers:Boolean(null===(t=this.options)||void 0===t?void 0:t.enrollInstrumentToNetworkOffers)}}))}}class No{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 To extends O{constructor(e,t){super("div",{id:"payrails-card-list"}),this.workflowExecution=e,this.listItems=[],this.workflowExecution.savedCreditCards.forEach((e=>{const i=new vo((()=>{(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 vo extends O{constructor(e,t){super("div",{className:"payrails-card-list-item",id:`payrails-card-list-item-${t.id}`});const{id:i}=t,n=this.createCardLabel(t),o=document.createElement("label");o.setAttribute("for",i),o.addEventListener("click",e);const s=document.createElement("input");s.setAttribute("type","radio"),s.setAttribute("name","payment-option"),s.setAttribute("id",i),s.setAttribute("value",i),o.appendChild(s);const r=document.createElement("span");r.innerText=n,o.appendChild(r),this.element.appendChild(o)}createCardLabel({data:e={}}){return`****${null==e?void 0:e.suffix}`}}class Oo extends O{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 Lo extends O{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 mo extends O{constructor(e,t,i,n){super("div",{id:e,className:"payrails-dropin-item"}),this.events=i,this.styles=n,this.isActive=!1,this.applyBaseStyles();const o=`payrails-dropin-item-${e}`,s=document.createElement("label");s.setAttribute("for",o);const r=document.createElement("input");r.setAttribute("type","radio"),r.setAttribute("name","payment-option"),r.setAttribute("id",o),r.setAttribute("value",o),this.input=r,s.appendChild(r),this.label=s;const a=document.createElement("span");s.appendChild(a),a.innerText=t,this.element.appendChild(s)}get identifier(){return`payrails-dropin-item-${this.id}`}deactivate(){var e,t;this.isActive&&(this.isActive=!1,this.label.style.marginBottom="0",this.applyBaseStyles(),null===(e=this.component)||void 0===e||e.unmount(),(null===(t=this.events)||void 0===t?void 0:t.onDeactivate)&&this.events.onDeactivate())}applyBaseStyles(){var e,t;Object.keys((null===(e=this.styles)||void 0===e?void 0:e.active)||{}).forEach((e=>{this.element.style.removeProperty(e)})),Object.assign(this.element.style,null===(t=this.styles)||void 0===t?void 0:t.base)}applyActiveStyles(){var e,t;Object.assign(this.element.style,null===(e=this.styles)||void 0===e?void 0:e.base,null===(t=this.styles)||void 0===t?void 0:t.active)}activate(){var e,t;this.isActive||(null===(e=this.component)||void 0===e||e.mount(this.selector),this.label.style.marginBottom="8px",this.applyActiveStyles(),this.isActive=!0,(null===(t=this.events)||void 0===t?void 0:t.onActivate)&&this.events.onActivate())}}class Ao extends mo{constructor(){super(...arguments),this.buttonShown=!1}activate(){if(!this.buttonShown)return super.activate(),void(this.buttonShown=!0);this.label.style.marginBottom="8px",this.applyActiveStyles(),this.isActive=!0,this.element.querySelector(this.component.selector).style.display="block"}deactivate(){this.isActive&&(this.isActive=!1,this.label.style.marginBottom="0",this.applyBaseStyles(),this.element.querySelector(this.component.selector).style.display="none")}mountAfterAvailable(){super.mount(`#${this.loadElementId}`)}mount(e){const t=document.querySelector(e);if(!t)throw new Error(`Element with selector "${e}" not found in in the DOM`);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 Ro extends Ao{constructor(e,t,i){var n,o;super("apple-pay-dropin",(null===(o=null===(n=i.translations)||void 0===n?void 0:n.labels)||void 0===o?void 0:o.label)||"Apple Pay",void 0,i.styles),this.loadElementId="apple-pay-dropin-load-element",this.component=new lo(e,t,Object.assign(Object.assign({},i),{events:{onApplePayAvailable:()=>{this.mountAfterAvailable()}}}))}mount(e){const t=document.querySelector(e);if(!t)throw new Error(`Element with selector "${e}" not found in in the DOM`);const i=document.createElement("div");i.setAttribute("id",this.loadElementId),i.setAttribute("style","width: 100%;"),t.appendChild(i)}}class yo extends mo{constructor(e,t,i){super("payrails-credit-card-wrapper","Card",void 0,i),this.cardForm=e,this.paymentButton=t,this.cardFormShown=!1,this.component=new Do(e,t)}activate(){var e,t;this.label.style.marginBottom="8px",this.applyActiveStyles(),this.cardFormShown||(this.cardFormShown=!0,null===(e=this.component)||void 0===e||e.mount(this.selector)),this.isActive||(this.paymentButton.selectedInstrument=null,this.paymentButton.mount(this.selector),this.paymentButton.setDisabled(!this.cardForm.isValid),this.paymentButton.mount("#payrails-card-form"),this.input.checked=!0,this.cardForm.show(),this.isActive=!0,(null===(t=this.events)||void 0===t?void 0:t.onActivate)&&this.events.onActivate())}deactivate(){var e;this.isActive&&(this.label.style.marginBottom="0",this.applyBaseStyles(),this.paymentButton.unmount(),this.cardForm.hide(),this.isActive=!1,(null===(e=this.events)||void 0===e?void 0:e.onDeactivate)&&this.events.onDeactivate())}}class Do extends O{constructor(e,t){super("div",{id:"payrails-form-container"}),this.subElements.push(e,t)}}const So={apiVersion:2,apiVersionMinor:0};class go extends ao{constructor(t,i,n){super("div",Object.assign(Object.assign({},n),{id:"payrails-google-pay-button"})),this.sdkConfig=t,this.execution=i,this.options=n,this.googleButton=null,this.paymentExecutor=new p(t,i),this.loadScript=new so((()=>e(this,void 0,void 0,(function*(){const e=document.createElement("script");return e.src="https://pay.google.com/gp/p/js/pay.js",new Promise(((t,i)=>{e.onload=()=>{const e=new google.payments.api.PaymentsClient({environment:this.options.environment||"TEST"}),n=Object.assign(Object.assign({},So),{allowedPaymentMethods:this.execution.googlePayConfig});e.isReadyToPay(n).then((n=>{var o,s,r;n?(null===(r=null===(s=null===(o=this.options)||void 0===o?void 0:o.events)||void 0===s?void 0:s.onGooglePayAvailable)||void 0===r||r.call(s),t(e)):i()}),i)},e.onerror=()=>{i()},document.body.appendChild(e)}))}))))}sdkLoaded(t){var i,n,o,s,r,a,l,d;return e(this,void 0,void 0,(function*(){try{const c=(null===(n=null===(i=this.options)||void 0===i?void 0:i.styles)||void 0===n?void 0:n.buttonColor)||"black",E=(null===(s=null===(o=this.options)||void 0===o?void 0:o.styles)||void 0===s?void 0:s.buttonType)||"long",_=(null===(a=null===(r=this.options)||void 0===r?void 0:r.styles)||void 0===a?void 0:a.buttonSizeMode)||"fill",I=(null===(d=null===(l=this.options)||void 0===l?void 0:l.styles)||void 0===d?void 0:d.buttonLocale)||void 0;return this.googleButton=t.createButton({buttonColor:c,buttonType:E,buttonSizeMode:_,buttonLocale:I,onClick:()=>e(this,void 0,void 0,(function*(){var e,t,i;if(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onPaymentButtonClicked){if(!(yield null===(i=this.options)||void 0===i?void 0:i.events.onPaymentButtonClicked()))return}yield this.onPaymentButtonClicked()})),allowedPaymentMethods:this.execution.googlePayConfig}),this.element.appendChild(this.googleButton),this.googleButton}catch(e){throw console.error("Google pay can not be initialized",e),new Error(e.message)}}))}onLoadPaymentData(t){var i,n,o,s;return e(this,void 0,void 0,(function*(){const e=[{paymentMethodCode:"googlePay",integrationType:"api",paymentInstrumentData:{paymentToken:t.paymentMethodData.tokenizationData.token},amount:this.sdkConfig.amount,storeInstrument:this.shouldStoreInstrument}],r=yield this.paymentExecutor.pay(e);(null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n?void 0:n.onAuthorizeSuccess)&&(null===(s=null===(o=this.options)||void 0===o?void 0:o.events)||void 0===s||s.onAuthorizeSuccess(r))}))}onPaymentButtonClicked(){var t,i,n,o,s;return e(this,void 0,void 0,(function*(){const e=Object.assign({},So);e.allowedPaymentMethods=this.execution.googlePayConfig,e.transactionInfo={totalPriceStatus:"FINAL",totalPrice:null===(t=this.sdkConfig.amount)||void 0===t?void 0:t.value,currencyCode:null===(i=this.sdkConfig.amount)||void 0===i?void 0:i.currency,countryCode:null===(s=null===(o=null===(n=this.execution.meta)||void 0===n?void 0:n.customer)||void 0===o?void 0:o.country)||void 0===s?void 0:s.code};(yield this.loadScript.loader).loadPaymentData(e).then((e=>{this.onLoadPaymentData(e)})).catch((e=>{var t,i,n;(null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onAuthorizeFailed)&&(null===(n=this.options)||void 0===n||n.events.onAuthorizeFailed(e))}))}))}mount(t){super.mount(t),(()=>{e(this,void 0,void 0,(function*(){var e;try{const t=yield this.loadScript.loader,i=yield this.sdkLoaded(t);this.element.appendChild(i),null===(e=this.storeInstrumentCheckbox)||void 0===e||e.mount(this.selector)}catch(e){}}))})()}unmount(){var e,t,i;null===(t=null===(e=this.googleButton)||void 0===e?void 0:e.parentElement)||void 0===t||t.removeChild(this.googleButton),null===(i=this.storeInstrumentCheckbox)||void 0===i||i.unmount(),super.unmount()}}class Co extends Ao{constructor(e,t,i){var n,o;super("google-pay-dropin",(null===(o=null===(n=i.translations)||void 0===n?void 0:n.labels)||void 0===o?void 0:o.label)||"Google Pay",void 0,i.styles),this.loadElementId="google-pay-dropin-load-element",this.component=new go(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},i.events),{onGooglePayAvailable:()=>{this.mountAfterAvailable()}})}))}mount(e){const t=document.querySelector(e);if(!t)throw new Error(`Element with selector "${e}" not found in in the DOM`);const i=document.createElement("div");i.setAttribute("id",this.loadElementId),i.setAttribute("style","width: 100%;"),t.appendChild(i)}}
|
|
4
|
+
*/const $e={IFRAME_SECURE_SITE:"https://js.skyflow.com/v1/elements/index.html",IFRAME_SECURE_ORGIN:"https://js.skyflow.com"},We="https://assets.payrails.io/3db1b95/index.html",Ke="https://assets.payrails.io",He={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no",style:"width: 100%;",allow:"clipboard-read; clipboard-write"},ze=(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 qe=(e={})=>{const t=document.createElement("iframe"),i=Object.assign(Object.assign({},He),e);return Object.assign(t.style,Pe),ze(t,i),t.getAttribute("id")||(t.id=t.name),t};const Je=()=>$e.IFRAME_SECURE_SITE,Ze=(e,t)=>{Object.keys(t).forEach((i=>{Object.prototype.hasOwnProperty.call(t,i)&&(e.style[i]=t[i])}))};function Qe(e){return JSON.parse(JSON.stringify(e))}class et{constructor(){this.listeners=[],this.isDestroyed=!1}on(e,t){se.on(e,t),this.listeners.push({eventName:e,callback:t})}off(e,t){se.off(e,t);const i=this.listeners.findIndex((t=>t.eventName===e));-1!==i&&this.listeners.splice(i,1)}emit(e,t,i=void 0){se.emit(e,t,i)}hasListener(e){return-1!==this.listeners.findIndex((t=>t.eventName===e))}teardown(){this.listeners.forEach((e=>{se.off(e.eventName,e.handler)})),this.listeners=[]}}var tt,it,nt,ot,st,rt,at;!function(e){e.DEFAULT="DEFAULT",e.PLAIN_TEXT="PLAIN_TEXT",e.MASKED="MASKED",e.REDACTED="REDACTED"}(tt||(tt={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.PATCH="PATCH",e.DELETE="DELETE"}(it||(it={})),function(e){e.CHANGE="CHANGE",e.READY="READY",e.FOCUS="FOCUS",e.BLUR="BLUR",e.SUBMIT="SUBMIT"}(nt||(nt={})),function(e){e.WARN="WARN",e.INFO="INFO",e.DEBUG="DEBUG",e.ERROR="ERROR"}(ot||(ot={})),function(e){e.DEV="DEV",e.PROD="PROD"}(st||(st={})),function(e){e.LOG="LOG",e.WARN="WARN",e.ERROR="ERROR"}(rt||(rt={})),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"}(at||(at={}));const lt={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}},dt={PROD:{doesReturnValue:!1},DEV:{doesReturnValue:!0}},ct="[Skyflow]",Et=(e,t,i)=>{if(i&<[i]){const{showDebugLogs:n,showInfoLogs:o,showWarnLogs:s,showErrorLogs:r}=lt[i];t===rt.LOG&&n?console.log(`${ot.DEBUG}: ${ct} ${e}`):t===rt.LOG&&o?console.log(`${ot.INFO}: ${ct} ${e}`):t===rt.WARN&&s?console.warn(`${ot.WARN}: ${ct} ${e}`):t===rt.ERROR&&r&&console.error(`${ot.ERROR}: ${ct} ${e}`)}},ut=(...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]})):""},_t=(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 It extends Error{constructor(e,t,i=!1){const n={code:e.code,description:t&&(null==t?void 0:t.length)>0?ut(e.description,...t):e.description};super(n.description),i?this.error=n:this.errors=[n]}}const ht={INVALID_FIELD:{code:400,description:ae.INVALID_FIELD},VAULTID_IS_REQUIRED:{code:400,description:ae.VAULTID_IS_REQUIRED},EMPTY_VAULTID_IN_INIT:{code:400,description:ae.EMPTY_VAULTID_IN_INIT},VAULTURL_IS_REQUIRED:{code:400,description:ae.VAULTURL_IS_REQUIRED},EMPTY_VAULTURL_IN_INIT:{code:400,description:ae.EMPTY_VAULTURL_IN_INIT},INVALID_VAULTURL_IN_INIT:{code:400,description:ae.INVALID_VAULTURL_IN_INIT},GET_BEARER_TOKEN_IS_REQUIRED:{code:400,description:ae.GET_BEARER_TOKEN_IS_REQUIRED},EMPTY_CONTAINER_TYPE:{code:400,description:ae.EMPTY_CONTAINER_TYPE},INVALID_CONTAINER_TYPE:{code:400,description:ae.INVALID_CONTAINER_TYPE},UNIQUE_ELEMENT_NAME:{code:400,description:ae.UNIQUE_ELEMENT_NAME},ELEMENTS_NOT_MOUNTED:{code:400,description:ae.ELEMENTS_NOT_MOUNTED},MISSING_TABLE_IN_COLLECT:{code:400,description:ae.MISSING_TABLE_IN_COLLECT},EMPTY_TABLE_IN_COLLECT:{code:400,description:ae.EMPTY_TABLE_IN_COLLECT},EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:{code:400,description:ae.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS},INVALID_TABLE_IN_COLLECT:{code:400,description:ae.INVALID_TABLE_IN_COLLECT},INVALID_SKYFLOWID_IN_COLLECT:{code:400,description:ae.INVALID_SKYFLOWID_IN_COLLECT},MISSING_COLUMN_IN_COLLECT:{code:400,description:ae.MISSING_COLUMN_IN_COLLECT},EMPTY_COLUMN_IN_COLLECT:{code:400,description:ae.EMPTY_TABLE_IN_COLLECT},INVALID_COLUMN_IN_COLLECT:{code:400,description:ae.INVALID_COLUMN_IN_COLLECT},CLIENT_CONNECTION:{code:400,description:ae.CLIENT_CONNECTION},RECORDS_KEY_NOT_FOUND:{code:404,description:ae.RECORDS_KEY_NOT_FOUND},EMPTY_RECORDS_IN_INSERT:{code:400,description:ae.EMPTY_RECORDS_IN_INSERT},INVALID_RECORDS_IN_INSERT:{code:404,description:ae.INVALID_RECORDS_IN_INSERT},INVALID_TABLE_IN_INSERT:{code:400,description:ae.INVALID_TABLE_IN_INSERT},EMPTY_TABLE_IN_INSERT:{code:400,description:ae.EMPTY_TABLE_IN_INSERT},MISSING_TABLE_IN_INSERT:{code:400,description:ae.MISSING_TABLE_IN_INSERT},EMPTY_FIELDS_IN_INSERT:{code:400,description:ae.EMPTY_FIELDS_IN_INSERT},MISSING_FIELDS_IN_INSERT:{code:404,description:ae.MISSING_FIELDS_IN_INSERT},INVALID_FIELDS_IN_INSERT:{code:404,description:ae.INVALID_FIELDS_IN_INSERT},INVALID_TOKENS_IN_INSERT:{code:404,description:ae.INVALID_TOKENS_IN_INSERT},RECORDS_KEY_NOT_FOUND_DETOKENIZE:{code:404,description:ae.RECORDS_KEY_NOT_FOUND_DETOKENIZE},EMPTY_RECORDS_DETOKENIZE:{code:400,description:ae.EMPTY_RECORDS_DETOKENIZE},INVALID_RECORDS_IN_DETOKENIZE:{code:404,description:ae.INVALID_RECORDS_IN_DETOKENIZE},MISSING_TOKEN_IN_DETOKENIZE:{code:400,description:ae.MISSING_TOKEN_IN_DETOKENIZE},INVALID_TOKEN_IN_DETOKENIZE:{code:400,description:ae.INVALID_TOKEN_IN_DETOKENIZE},RECORDS_KEY_NOT_FOUND_GET:{code:400,description:ae.RECORDS_KEY_NOT_FOUND_GET},INVALID_RECORDS_IN_GET:{code:400,description:ae.INVALID_RECORDS_IN_GET},EMPTY_RECORDS_GET:{code:400,description:ae.EMPTY_RECORDS_GET},MISSING_IDS_IN_GET:{code:400,description:ae.MISSING_IDS_IN_GET},INVALID_IDS_IN_GET:{code:400,description:ae.INVALID_IDS_IN_GET},INVALID_COLUMN_VALUES_IN_GET:{code:400,description:ae.INVALID_COLUMN_VALUES_IN_GET},EMPTY_IDS_IN_GET:{code:400,description:ae.EMPTY_IDS_IN_GET},INVALID_SKYFLOWID_TYPE_IN_GET:{code:400,description:ae.INVALID_SKYFLOWID_TYPE_IN_GET},MISSING_TABLE_IN_GET:{code:400,description:ae.MISSING_TABLE_IN_GET},INVALID_TABLE_IN_GET:{code:400,description:ae.INVALID_TABLE_IN_GET},MISSING_REDACTION_IN_GET:{code:400,description:ae.MISSING_REDACTION_IN_GET},INVALID_REDACTION_TYPE_IN_GET:{code:400,description:ae.INVALID_REDACTION_TYPE_IN_GET},INVALID_TOKENS_IN_GET:{code:400,description:ae.INVALID_TOKENS_IN_GET},TOKENS_GET_COLUMN_NOT_SUPPORTED:{code:400,description:ae.TOKENS_GET_COLUMN_NOT_SUPPORTED},REDACTION_WITH_TOKENS_NOT_SUPPORTED:{code:400,description:ae.REDACTION_WITH_TOKENS_NOT_SUPPORTED},INVALID_REDACTION_TYPE_IN_DETOKENIZE:{code:400,description:ae.INVALID_REDACTION_TYPE_IN_DETOKENIZE},INVALID_TOKENS_IN_COLLECT:{code:404,description:ae.INVALID_TOKENS_IN_COLLECT},RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS:{code:404,description:ae.RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS},INVALID_RECORDS_IN_ADDITIONAL_FIELDS:{code:404,description:ae.INVALID_RECORDS_IN_ADDITIONAL_FIELDS},EMPTY_RECORDS_IN_ADDITIONAL_FIELDS:{code:400,description:ae.EMPTY_RECORDS_IN_ADDITIONAL_FIELDS},MISSING_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:ae.MISSING_TABLE_IN_ADDITIONAL_FIELDS},INVALID_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:ae.INVALID_TABLE_IN_ADDITIONAL_FIELDS},INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:{code:400,description:ae.INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS},MISSING_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:ae.MISSING_FIELDS_IN_ADDITIONAL_FIELDS},INVALID_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:ae.INVALID_FIELDS_IN_ADDITIONAL_FIELDS},RECORDS_KEY_NOT_FOUND_DELETE:{code:400,description:ae.RECORDS_KEY_NOT_FOUND_DELETE},EMPTY_RECORDS_IN_DELETE:{code:400,description:ae.EMPTY_RECORDS_IN_DELETE},INVALID_RECORDS_IN_DELETE:{code:404,description:ae.INVALID_RECORDS_IN_DELETE},INVALID_TABLE_IN_DELETE:{code:400,description:ae.INVALID_TABLE_IN_DELETE},EMPTY_TABLE_IN_DELETE:{code:400,description:ae.EMPTY_TABLE_IN_DELETE},MISSING_TABLE_IN_DELETE:{code:400,description:ae.MISSING_TABLE_IN_DELETE},EMPTY_ID_IN_DELETE:{code:400,description:ae.EMPTY_ID_IN_DELETE},MISSING_ID_IN_DELETE:{code:404,description:ae.MISSING_ID_IN_DELETE},INVALID_ID_IN_DELETE:{code:404,description:ae.INVALID_ID_IN_DELETE},EMPTY_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:ae.EMPTY_TABLE_IN_ADDITIONAL_FIELDS},EMPTY_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:ae.EMPTY_FIELDS_IN_ADDITIONAL_FIELDS},EMPTY_TOKEN_IN_DETOKENIZE:{code:400,description:ae.EMPTY_TOKEN_IN_DETOKENIZE},EMPTY_SKYFLOWID_IN_GET:{code:400,description:ae.EMPTY_SKYFLOWID_IN_GET},EMPTY_TABLE_IN_GET:{code:400,description:ae.EMPTY_TABLE_IN_GET},EMPTY_REDACTION_TYPE_IN_GET:{code:400,description:ae.EMPTY_REDACTION_TYPE_IN_GET},DUPLICATE_ELEMENT:{code:400,description:ae.DUPLICATE_ELEMENT},DUPLICATE_ELEMENT_ADDITIONAL_FIELDS:{code:400,description:ae.DUPLICATE_ELEMENT_ADDITIONAL_FIELDS},MISSING_ELEMENT_TYPE:{code:400,description:ae.MISSING_ELEMENT_TYPE},EMPTY_ELEMENT_TYPE:{code:400,description:ae.EMPTY_ELEMENT_TYPE},INVALID_ELEMENT_TYPE:{code:400,description:ae.INVALID_ELEMENT_TYPE},INVALID_ELEMENT_SELECTOR:{code:400,description:ae.INVALID_ELEMENT_SELECTOR},FRAME_NOT_FOUND:{code:400,description:ae.FRAME_NOT_FOUND},REQUIRED_PARAMS_NOT_PROVIDED:{code:400,description:ae.REQUIRED_PARAMS_NOT_PROVIDED},INVALID_RECORD_COLUMN_VALUE:{code:400,description:ae.INVALID_RECORD_COLUMN_VALUE},MISSING_RECORD_COLUMN_VALUE:{code:400,description:ae.MISSING_RECORD_COLUMN_VALUE},MISSING_RECORD_COLUMN_NAME:{code:400,description:ae.MISSING_RECORD_COLUMN_NAME},INVALID_EVENT_TYPE:{code:400,description:ae.INVALID_EVENT_TYPE},INVALID_EVENT_LISTENER:{code:400,description:ae.INVALID_EVENT_LISTENER},MISSING_HANDLER_IN_EVENT_LISTENER:{code:400,description:ae.MISSING_HANDLER_IN_EVENT_LISTENER},INVALID_HANDLER_IN_EVENT_LISTENER:{code:400,description:ae.INVALID_HANDLER_IN_EVENT_LISTENER},UNKNOWN_ERROR:{code:400,description:ae.UNKNOWN_ERROR},CONNECTION_ERROR:{code:400,description:ae.CONNECTION_ERROR},NETWORK_ERROR:{code:500,description:ae.NETWORK_ERROR},COMPLETE_AND_VALID_INPUTS:{code:400,description:ae.COMPLETE_AND_VALID_INPUTS},INVALID_VALIDATIONS_TYPE:{code:400,description:ae.INVALID_VALIDATIONS_TYPE},MISSING_VALIDATION_RULE_TYPE:{code:400,description:ae.MISSING_VALIDATION_RULE_TYPE},INVALID_VALIDATION_RULE_TYPE:{code:400,description:ae.INVALID_VALIDATION_RULE_TYPE},MISSING_VALIDATION_RULE_PARAMS:{code:400,description:ae.MISSING_VALIDATION_RULE_PARAMS},INVALID_VALIDATION_RULE_PARAMS:{code:400,description:ae.INVALID_VALIDATION_RULE_PARAMS},MISSING_REGEX_IN_REGEX_MATCH_RULE:{code:400,description:ae.MISSING_REGEX_IN_REGEX_MATCH_RULE},INVALID_REGEX_IN_REGEX_MATCH_RULE:{code:400,description:ae.INVALID_REGEX_IN_REGEX_MATCH_RULE},MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE:{code:400,description:ae.MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE},MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE:{code:400,description:ae.MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE},INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE:{code:400,description:ae.INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE},ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE:{code:400,description:ae.ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE},EMPTY_ELEMENT_IN_MOUNT:{code:400,description:ae.EMPTY_ELEMENT_IN_MOUNT},INVALID_TABLE_IN_UPSERT_OPTION:{code:400,description:ae.INVALID_TABLE_IN_UPSERT_OPTION},INVALID_COLUMN_IN_UPSERT_OPTION:{code:400,description:ae.INVALID_COLUMN_IN_UPSERT_OPTION},INVALID_UPSERT_OPTION_TYPE:{code:400,description:ae.INVALID_UPSERT_OPTION_TYPE},EMPTY_UPSERT_OPTIONS_ARRAY:{code:400,description:ae.EMPTY_UPSERT_OPTIONS_ARRAY},INVALID_UPSERT_OPTION_OBJECT_TYPE:{code:400,description:ae.INVALID_UPSERT_OPTION_OBJECT_TYPE},MISSING_TABLE_IN_UPSERT_OPTION:{code:400,description:ae.MISSING_TABLE_IN_UPSERT_OPTION},MISSING_COLUMN_IN_UPSERT_OPTION:{code:400,description:ae.MISSING_COLUMN_IN_UPSERT_OPTION},INVALID_RECORD_COLUMN_VALUE_TYPE:{code:400,description:ae.INVALID_RECORD_COLUMN_VALUE_TYPE},INVALID_COLUMN_VALUES_TYPE:{code:400,description:ae.INVALID_COLUMN_VALUES_TYPE},EMPTY_RECORD_COLUMN_VALUES:{code:400,description:ae.EMPTY_RECORD_COLUMN_VALUES},EMPTY_COLUMN_VALUE:{code:400,description:ae.EMPTY_COLUMN_VALUE},MISSING_IDS_OR_COLUMN_VALUES_IN_GET:{code:400,description:ae.MISSING_IDS_OR_COLUMN_VALUES_IN_GET},SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED:{code:400,description:ae.SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED},RECORDS_KEY_NOT_FOUND_GETBYID:{code:400,description:ae.RECORDS_KEY_NOT_FOUND_GETBYID},INVALID_RECORDS_IN_GETBYID:{code:400,description:ae.INVALID_RECORDS_IN_GETBYID},EMPTY_RECORDS_GETBYID:{code:400,description:ae.EMPTY_RECORDS_GETBYID},MISSING_IDS_IN_GETBYID:{code:400,description:ae.MISSING_IDS_IN_GETBYID},INVALID_IDS_IN_GETBYID:{code:400,description:ae.INVALID_IDS_IN_GETBYID},EMPTY_IDS_IN_GETBYID:{code:400,description:ae.EMPTY_IDS_IN_GETBYID},INVALID_SKYFLOWID_TYPE_IN_GETBYID:{code:400,description:ae.INVALID_SKYFLOWID_TYPE_IN_GETBYID},MISSING_TABLE_IN_GETBYID:{code:400,description:ae.MISSING_TABLE_IN_GETBYID},INVALID_TABLE_IN_GETBYID:{code:400,description:ae.INVALID_TABLE_IN_GETBYID},MISSING_REDACTION_IN_GETBYID:{code:400,description:ae.MISSING_REDACTION_IN_GETBYID},INVALID_REDACTION_TYPE_IN_GETBYID:{code:400,description:ae.INVALID_REDACTION_TYPE_IN_GETBYID},EMPTY_SKYFLOWID_IN_GETBYID:{code:400,description:ae.EMPTY_SKYFLOWID_IN_GETBYID},EMPTY_TABLE_IN_GETBYID:{code:400,description:ae.EMPTY_TABLE_IN_GETBYID},EMPTY_REDACTION_TYPE_IN_GETBYID:{code:400,description:ae.EMPTY_REDACTION_TYPE_IN_GETBYID},MISSING_COMPOSABLE_LAYOUT_KEY:{code:400,description:ae.MISSING_COMPOSABLE_LAYOUT_KEY},EMPTY_COMPOSABLE_LAYOUT_ARRAY:{code:400,description:ae.EMPTY_COMPOSABLE_LAYOUT_ARRAY},INVALID_COMPOSABLE_LAYOUT_TYPE:{code:400,description:ae.INVALID_COMPOSABLE_LAYOUT_TYPE},NEGATIVE_VALUES_COMPOSABLE_LAYOUT:{code:400,description:ae.NEGATIVE_VALUES_COMPOSABLE_LAYOUT},MISMATCH_ELEMENT_COUNT_LAYOUT_SUM:{code:400,description:ae.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM},MISSING_COMPOSABLE_CONTAINER_OPTIONS:{code:400,description:ae.MISSING_COMPOSABLE_CONTAINER_OPTIONS},INVALID_COMPOSABLE_CONTAINER_OPTIONS:{code:400,description:ae.INVALID_COMPOSABLE_CONTAINER_OPTIONS},COMPOSABLE_CONTAINER_NOT_MOUNTED:{code:400,description:ae.COMPOSABLE_CONTAINER_NOT_MOUNTED},INVALID_BOOLEAN_OPTIONS:{code:400,description:ae.INVALID_BOOLEAN_OPTIONS},EMPTY_COLLECT_CUSTOM_FORMAT:{code:400,description:ae.EMPTY_COLLECT_CUSTOM_FORMAT},INVALID_INPUT_OPTIONS_FORMAT:{code:400,description:ae.INVALID_INPUT_OPTIONS_FORMAT},INVALID_INPUT_OPTIONS_TRANSLATION:{code:400,description:ae.INVALID_INPUT_OPTIONS_TRANSLATION}},pt=(e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new It(ht.RECORDS_KEY_NOT_FOUND,[],!0);const{records:i}=e;if(!i||!Array.isArray(i))throw new It(ht.INVALID_RECORDS_IN_INSERT,[],!0);if(0===i.length)throw new It(ht.EMPTY_RECORDS_IN_INSERT,[],!0);if(i.forEach(((e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"table"))throw new It(ht.MISSING_TABLE_IN_INSERT,[`${t}`],!0);if(!e.table)throw new It(ht.EMPTY_TABLE_IN_INSERT,[`${t}`],!0);if(!("string"==typeof e.table||e.table instanceof String))throw new It(ht.INVALID_TABLE_IN_INSERT,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"fields"))throw new It(ht.MISSING_FIELDS_IN_INSERT,[`${t}`],!0);if(!e.fields)throw new It(ht.EMPTY_FIELDS_IN_INSERT,[`${t}`],!0);if("object"!=typeof e.fields||Array.isArray(e.fields))throw new It(ht.INVALID_FIELDS_IN_INSERT,[`${t}`],!0)})),t&&t.tokens&&"boolean"!=typeof t.tokens)throw new It(ht.INVALID_TOKENS_IN_INSERT,[],!0)},Nt=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new It(ht.RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS,[],!0);const{records:t}=e;if(!t||!Array.isArray(t))throw new It(ht.INVALID_RECORDS_IN_ADDITIONAL_FIELDS,[],!0);if(0===t.length)throw new It(ht.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 It(ht.MISSING_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!e.table)throw new It(ht.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 It(ht.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 It(ht.INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[`${t}`],!0)}if(!("string"==typeof e.table||e.table instanceof String))throw new It(ht.INVALID_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"fields"))throw new It(ht.MISSING_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!e.fields)throw new It(ht.EMPTY_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if("object"!=typeof e.fields||Array.isArray(e.fields))throw new It(ht.INVALID_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0)}))},ft=(e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new It(ht.RECORDS_KEY_NOT_FOUND_GET);const{records:i}=e;if(!i||!Array.isArray(i))throw new It(ht.INVALID_RECORDS_IN_GET,[]);if(0===i.length)throw new It(ht.EMPTY_RECORDS_GET);if(t&&Object.prototype.hasOwnProperty.call(t,"tokens")&&"boolean"!=typeof(null==t?void 0:t.tokens))throw new It(ht.INVALID_TOKENS_IN_GET);i.forEach(((e,i)=>{var n,o,s;if(0===Object.keys(e).length)throw new It(ht.EMPTY_RECORDS_GET);if(0===(null===(n=e.ids)||void 0===n?void 0:n.length))throw new It(ht.EMPTY_IDS_IN_GET,[`${i}`]);if(!(null==e.ids||e.ids&&Array.isArray(e.ids)))throw new It(ht.INVALID_IDS_IN_GET,[`${i}`]);if(null===(o=e.ids)||void 0===o||o.forEach((e=>{if(!e)throw new It(ht.EMPTY_SKYFLOWID_IN_GET,[`${i}`]);if(!("string"==typeof e||e instanceof String))throw new It(ht.INVALID_SKYFLOWID_TYPE_IN_GET,[`${i}`])})),!Object.prototype.hasOwnProperty.call(e,"table"))throw new It(ht.MISSING_TABLE_IN_GET,[`${i}`]);if(!e.table)throw new It(ht.EMPTY_TABLE_IN_GET,[`${i}`]);if(!("string"==typeof e.table||e.table instanceof String))throw new It(ht.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 It(ht.MISSING_REDACTION_IN_GET,[`${i}`]);if(!e.redaction)throw new It(ht.EMPTY_REDACTION_TYPE_IN_GET,[`${i}`]);if(!Object.values(tt).includes(e.redaction))throw new It(ht.INVALID_REDACTION_TYPE_IN_GET,[`${i}`])}if(!0===Object.prototype.hasOwnProperty.call(e,"ids")&&!0===Object.prototype.hasOwnProperty.call(e,"columnName"))throw new It(ht.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 It(ht.MISSING_RECORD_COLUMN_VALUE,[`${i}`])}else if(!1===Object.prototype.hasOwnProperty.call(e,"ids")&&!1===Object.prototype.hasOwnProperty.call(e,"columnValues"))throw new It(ht.MISSING_IDS_OR_COLUMN_VALUES_IN_GET,[`${i}`]);if(0===(null===(s=e.columnValues)||void 0===s?void 0:s.length))throw new It(ht.EMPTY_RECORD_COLUMN_VALUES,[`${i}`]);if(!(null==e.columnValues||e.columnValues&&Array.isArray(e.columnValues)))throw new It(ht.INVALID_COLUMN_VALUES_IN_GET,[`${i}`]);if(void 0!==e.columnName&&void 0===e.columnValues)throw new It(ht.MISSING_RECORD_COLUMN_VALUE,[`${i}`]);if(void 0===e.columnName&&void 0!==e.columnValues)throw new It(ht.MISSING_RECORD_COLUMN_NAME,[`${i}`]);const r=e.columnName;if(null!=r&&"string"!=typeof r)throw new It(ht.INVALID_RECORD_COLUMN_VALUE,[`${i}`]);const a=e.columnValues;if(null!=a){if(0===a.length||null===a)throw new It(ht.EMPTY_RECORD_COLUMN_VALUES,[`${i}`]);a.forEach((e=>{if(""===e||null===e)throw new It(ht.EMPTY_COLUMN_VALUE,[`${i}`]);if("string"!=typeof e)throw new It(ht.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 It(ht.TOKENS_GET_COLUMN_NOT_SUPPORTED);if(e.redaction)throw new It(ht.REDACTION_WITH_TOKENS_NOT_SUPPORTED)}}))},Tt=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new It(ht.RECORDS_KEY_NOT_FOUND_GETBYID);const{records:t}=e;if(!t||!Array.isArray(t))throw new It(ht.INVALID_RECORDS_IN_GETBYID,[]);if(0===t.length)throw new It(ht.EMPTY_RECORDS_GETBYID);t.forEach(((e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"ids"))throw new It(ht.MISSING_IDS_IN_GETBYID,[`${t}`]);if(!e.ids||!Array.isArray(e.ids))throw new It(ht.INVALID_IDS_IN_GETBYID,[`${t}`]);if(0===e.ids.length)throw new It(ht.EMPTY_IDS_IN_GETBYID,[`${t}`]);if(e.ids.forEach((e=>{if(!e)throw new It(ht.EMPTY_SKYFLOWID_IN_GETBYID,[`${t}`]);if(!("string"==typeof e||e instanceof String))throw new It(ht.INVALID_SKYFLOWID_TYPE_IN_GETBYID,[`${t}`])})),!Object.prototype.hasOwnProperty.call(e,"table"))throw new It(ht.MISSING_TABLE_IN_GETBYID,[`${t}`]);if(!e.table)throw new It(ht.EMPTY_TABLE_IN_GETBYID,[`${t}`]);if(!("string"==typeof e.table||e.table instanceof String))throw new It(ht.INVALID_TABLE_IN_GETBYID,[`${t}`]);if(!Object.prototype.hasOwnProperty.call(e,"redaction"))throw new It(ht.MISSING_REDACTION_IN_GETBYID,[`${t}`]);if(!e.redaction)throw new It(ht.EMPTY_REDACTION_TYPE_IN_GETBYID,[`${t}`]);if(!Object.values(tt).includes(e.redaction))throw new It(ht.INVALID_REDACTION_TYPE_IN_GETBYID,[`${t}`])}))},vt=(e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new It(ht.RECORDS_KEY_NOT_FOUND_DELETE,[],!0);const{records:i}=e;if(!i||!Array.isArray(i))throw new It(ht.INVALID_RECORDS_IN_DELETE,[],!0);if(0===i.length)throw new It(ht.EMPTY_RECORDS_IN_DELETE,[],!0);i.forEach(((e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"table"))throw new It(ht.MISSING_TABLE_IN_DELETE,[`${t}`],!0);if(!e.table)throw new It(ht.EMPTY_TABLE_IN_DELETE,[`${t}`],!0);if(!("string"==typeof e.table||e.table instanceof String))throw new It(ht.INVALID_TABLE_IN_DELETE,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"id"))throw new It(ht.MISSING_ID_IN_DELETE,[`${t}`],!0);if(!e.id)throw new It(ht.EMPTY_ID_IN_DELETE,[`${t}`],!0);if(!("string"==typeof e.id||e.id instanceof String))throw new It(ht.INVALID_ID_IN_DELETE,[`${t}`],!0)}))},mt=e=>{let t=!0;try{new RegExp(e)}catch(e){t=!1}return t},Ot=e=>{if(!Object.prototype.hasOwnProperty.call(e,"getBearerToken"))throw new It(ht.GET_BEARER_TOKEN_IS_REQUIRED,[],!0)},At=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new It(ht.MISSING_ELEMENT_TYPE,[],!0);if(!e.type)throw new It(ht.EMPTY_ELEMENT_TYPE,[],!0);if(Object.prototype.hasOwnProperty.call(e,"altText")&&Et(le.COLLECT_ALT_TEXT_DEPERECATED,rt.WARN,t),Object.prototype.hasOwnProperty.call(e,"skyflowID")&&"string"!=typeof e.skyflowID)throw new It(ht.INVALID_SKYFLOWID_IN_COLLECT,[],!0)},Lt=e=>{if(!e||!Array.isArray(e))throw new It(ht.INVALID_UPSERT_OPTION_TYPE,[],!0);if(!e.length)throw new It(ht.EMPTY_UPSERT_OPTIONS_ARRAY,[],!0);e.forEach(((e,t)=>{if(!e||"object"!=typeof e)throw new It(ht.INVALID_UPSERT_OPTION_OBJECT_TYPE,[t],!0);if(!Object.prototype.hasOwnProperty.call(e,"table"))throw new It(ht.MISSING_TABLE_IN_UPSERT_OPTION,[t],!0);if(!e.table||"string"!=typeof e.table||!e.table.length)throw new It(ht.INVALID_TABLE_IN_UPSERT_OPTION,[t],!0);if(!Object.prototype.hasOwnProperty.call(e,"column"))throw new It(ht.MISSING_COLUMN_IN_UPSERT_OPTION,[t],!0);if(!e.column||"string"!=typeof e.column||!e.column.length)throw new It(ht.INVALID_COLUMN_IN_UPSERT_OPTION,[t],!0)}))},yt=e=>"boolean"==typeof e;function Rt(e){const t=e.split(":");return t.length>2?(t.pop(),t.pop(),t.join(":")):""}const Dt=(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=Ce.DEFAULT;return Object.entries(Ve).forEach((([e,n])=>{n.regex.test(t)&&(i=e)})),i})(e),i=t!==Ce.DEFAULT&&t===Ce.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 St(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}`;$e.IFRAME_SECURE_ORGIN=s,$e.IFRAME_SECURE_SITE=null===(o=null==e?void 0:e.options)||void 0===o?void 0:o.customElementsURL}"Payrails"===(null===(s=e.options)||void 0===s?void 0:s.deserializedData.vaultConfiguration.vaultType)&&($e.IFRAME_SECURE_ORGIN=Ke,$e.IFRAME_SECURE_SITE=We)}class Ct{constructor(e,t,i,n){this.setAttributess=e=>{ze(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 It(ht.INVALID_ELEMENT_SELECTOR,[],!0)}else{if(!(e instanceof HTMLElement))throw new It(ht.INVALID_ELEMENT_SELECTOR,[],!0);this.container=e}}catch(e){console.error(e)}ze(this.iframe,{src:Je()}),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=qe({name:this.name})}}class gt{}var bt,wt,Pt,Mt,Ut,kt,Vt,xt,Yt,Bt,Gt,Ft,jt,Xt,$t,Wt,Kt,Ht,zt,qt;const Jt="Element";class Zt extends gt{constructor(e,n,o,s,r=!1,a,l,d,c){var E;super(),this.type=Nn.COLLECT,bt.set(this,void 0),wt.set(this,!1),Pt.set(this,void 0),Mt.set(this,void 0),Ut.set(this,{isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:void 0,isRequired:!1}),kt.set(this,void 0),Vt.set(this,new Xe),xt.set(this,void 0),Yt.set(this,new et),Bt.set(this,void 0),Gt.set(this,[]),Ft.set(this,!1),jt.set(this,void 0),Xt.set(this,void 0),$t.set(this,!1),this.getID=()=>t(this,bt,"f"),this.mount=e=>{var n;if(!e)throw new It(ht.EMPTY_ELEMENT_IN_MOUNT,["CollectElement"],!0);const o=(e,n)=>{if(e.name===t(this,Bt,"f").name){n(t(this,kt,"f")),t(this,qt,"f").call(this);const e=function(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(i[n[o]]=e[n[o]])}return i}(t(this,Pt,"f")[0],["name"]);t(this,Mt,"f").length>1?t(this,Mt,"f").forEach(((e,i)=>{t(this,xt,"f")&&t(this,xt,"f")._emit(`${he.READY}:${e.elementName}`,Object.assign(Object.assign({},t(this,Pt,"f")[i]),{elementType:e.elementType}))})):t(this,Vt,"f")._emit(he.READY,Object.assign({},e)),t(this,Yt,"f").off(pe+this.containerId,o),Et(`${ut(re.ELEMENT_MOUNTED,Jt,_t(t(this,Bt,"f").name))} `,rt.LOG,t(this,jt,"f").logLevel),t(this,Gt,"f").forEach((e=>e())),i(this,Gt,[],"f")}};if(t(this,Mt,"f").length>1)t(this,Bt,"f").mount(e),t(this,Yt,"f").on(pe+this.containerId,o);else{if(t(this,$t,"f"))return t(this,Bt,"f").mount(e),void t(this,Yt,"f").on(pe+this.containerId,o);null===(n=t(this,xt,"f"))||void 0===n||n.on(De,(i=>{(null==i?void 0:i.containerId)===this.containerId&&(t(this,Bt,"f").mount(e),t(this,Yt,"f").on(pe+this.containerId,o))}))}},this.unmount=()=>{t(this,Bt,"f").unmount()},this.update=e=>{let n=Qe(e);const o=()=>{t(this,wt,"f")&&(n={rows:[{elements:[Object.assign({},n)]}]}),i(this,kt,ei(t(this,kt,"f"),n),"f"),i(this,Mt,ti(t(this,kt,"f")),"f"),t(this,wt,"f")?t(this,Yt,"f").emit(ve,{name:t(this,Bt,"f").name,options:t(this,Mt,"f")[0],isSingleElementAPI:!0}):(t(this,Mt,"f").forEach((e=>{t(this,Yt,"f").emit(ve,{name:e.elementName,options:e,isSingleElementAPI:!0})})),t(this,Yt,"f").emit(ve,{name:t(this,Bt,"f").name,options:t(this,kt,"f"),isSingleElementAPI:!1})),t(this,qt,"f").call(this)};t(this,Ft,"f")?o():t(this,Gt,"f").push(o)},Wt.set(this,(e=>{t(this,wt,"f")||t(this,Vt,"f").on(ve,(()=>{e(t(this,Mt,"f"))}),!0)})),this.updateElement=e=>{t(this,Yt,"f").emit(ve,{name:e.elementName,options:e,isSingleElementAPI:!0})},Kt.set(this,(()=>{t(this,Pt,"f").forEach(((e,i)=>{if(0===i){t(this,Ut,"f").isEmpty=e.isEmpty,t(this,Ut,"f").isComplete=e.isComplete,t(this,Ut,"f").isValid=e.isValid,t(this,Ut,"f").isFocused=e.isFocused,t(this,Ut,"f").isRequired=e.isRequired,t(this,Ut,"f").value={};const n=t(this,Mt,"f")[i].elementName,o=e.value&&Dt(e.value,e.elementType,t(this,Xt,"f"));t(this,wt,"f")?t(this,Ut,"f").value=o:t(this,Ut,"f").value[n]=o}else t(this,Ut,"f").isEmpty=t(this,Ut,"f").isEmpty||e.isEmpty,t(this,Ut,"f").isComplete=t(this,Ut,"f").isComplete&&e.isComplete,t(this,Ut,"f").isValid=t(this,Ut,"f").isValid&&e.isValid,t(this,Ut,"f").isFocused=t(this,Ut,"f").isFocused||e.isFocused,t(this,Ut,"f").isRequired=t(this,Ut,"f").isRequired||e.isRequired,t(this,Ut,"f").value||(t(this,Ut,"f").value={}),t(this,Mt,"f")[i].sensitive||(t(this,Ut,"f").value[t(this,Mt,"f")[i].elementName]=e.value||"")}))})),this.getState=()=>({isEmpty:t(this,Ut,"f").isEmpty,isComplete:t(this,Ut,"f").isComplete,isValid:t(this,Ut,"f").isValid,isFocused:t(this,Ut,"f").isFocused,value:t(this,Ut,"f").value,required:t(this,Ut,"f").isRequired}),this.getOptions=()=>{let e=Qe(t(this,kt,"f"));return t(this,wt,"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=>{t(this,Vt,"f").on(Te,(()=>{const i=t(this,Mt,"f").map((e=>e.elementName));t(this,wt,"f")||i.push(t(this,Bt,"f").name),e(i)}),!0)})),zt.set(this,(()=>{t(this,Yt,"f").on(fe,(e=>{if(t(this,wt,"f")&&e.event===he.READY&&e.name===t(this,Bt,"f").name)t(this,Vt,"f")._emit(he.READY);else{const i=t(this,Mt,"f").length>1;t(this,Mt,"f").forEach(((n,o)=>{var s;if(e.name===n.elementName){let r="";switch(e.event){case he.FOCUS:r=he.FOCUS;break;case he.BLUR:r=he.BLUR;break;case he.CHANGE:r=he.CHANGE;break;case he.READY:r=he.READY;break;case he.SUBMIT:return void(null===(s=t(this,xt,"f"))||void 0===s||s._emit(he.SUBMIT));default:throw new It(ht.INVALID_EVENT_TYPE,[],!0)}t(this,Pt,"f")[o].isEmpty=e.value.isEmpty,t(this,Pt,"f")[o].isValid=e.value.isValid,t(this,Pt,"f")[o].isComplete=e.value.isComplete,t(this,Pt,"f")[o].isFocused=e.value.isFocused,t(this,Pt,"f")[o].isRequired=e.value.isRequired,Object.prototype.hasOwnProperty.call(e.value,"value")?t(this,Pt,"f")[o].value=e.value.value:t(this,Pt,"f")[o].value=void 0,r=i?`${r}:${e.name}`:r,t(this,Yt,"f").emit(he.HEIGHT+t(this,Bt,"f").name,{},(e=>{t(this,Bt,"f").setIframeHeight(e.height)})),t(this,Kt,"f").call(this);const a=Object.assign(Object.assign({},t(this,Pt,"f")[o]),{elementType:n.elementType});i&&t(this,xt,"f")?t(this,xt,"f")._emit(r,a):t(this,Vt,"f")._emit(r,a)}}))}}))})),qt.set(this,(()=>{const{rows:e}=t(this,kt,"f");e.forEach((e=>{e.elements.forEach((e=>{e.elementType!==be.radio.name&&e.elementType!==be.checkbox.name&&(e.value=void 0)}))})),i(this,Mt,ti(t(this,kt,"f")),"f")})),this.containerId=s.containerId,i(this,bt,e,"f"),i(this,jt,d,"f"),i(this,kt,ei(n),"f"),i(this,Mt,ti(n),"f"),i(this,wt,r,"f"),c&&i(this,xt,c,"f"),i(this,Xt,dt[t(this,jt,"f").env].doesReturnValue,"f"),this.elementType=t(this,wt,"f")?t(this,Mt,"f")[0].elementType:"group",i(this,Pt,[],"f"),t(this,Mt,"f").forEach((e=>{t(this,Pt,"f").push({isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:t(this,Xt,"f")?"":void 0,elementType:e.elementType,name:e.elementName,isRequired:!1})})),i(this,Bt,new Ct(t(this,kt,"f").elementName,o,this.containerId,t(this,jt,"f").logLevel),"f"),t(this,zt,"f").call(this),t(this,Ht,"f").call(this,a),t(this,Wt,"f").call(this,l),Et(ut(re.CREATED_ELEMENT,Jt,_t(t(this,Bt,"f").name)),rt.LOG,t(this,jt,"f").logLevel),i(this,$t,s.isMounted,"f"),null===(E=t(this,xt,"f"))||void 0===E||E.on(De,(e=>{(null==e?void 0:e.containerId)===this.containerId&&i(this,$t,!0,"f")})),t(this,Yt,"f").on(he.MOUNTED,(e=>{s.type===Nn.COMPOSABLE?t(this,Mt,"f").forEach((t=>{e.name===t.elementName&&(t.isMounted=!0,i(this,Ft,!0,"f"))})):e.name===t(this,Mt,"f")[0].elementName&&(t(this,Mt,"f")[0].isMounted=!0,i(this,Ft,!0,"f")),t(this,Yt,"f").emit(he.HEIGHT+t(this,Bt,"f").name,{},(e=>{t(this,Bt,"f").setIframeHeight(e.height)}))}))}on(e,i){if(!Object.values(he).includes(e))throw new It(ht.INVALID_EVENT_LISTENER,[],!0);if(!i)throw new It(ht.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof i)throw new It(ht.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);t(this,Vt,"f").on(e,(e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,i(e)}))}iframeName(){return t(this,Bt,"f").name}isMounted(){return t(this,Ft,"f")}isValidElement(){for(let e=0;e<t(this,Mt,"f").length;e+=1){if(!Object.prototype.hasOwnProperty.call(t(this,Mt,"f")[e],"table"))throw new It(ht.MISSING_TABLE_IN_COLLECT,[],!0);if(!t(this,Mt,"f")[e].table)throw new It(ht.EMPTY_TABLE_IN_COLLECT,[],!0);if(!("string"==typeof t(this,Mt,"f")[e].table||t(this,Mt,"f")[e].table instanceof String))throw new It(ht.INVALID_TABLE_IN_COLLECT,[],!0);if(!Object.prototype.hasOwnProperty.call(t(this,Mt,"f")[e],"column"))throw new It(ht.MISSING_COLUMN_IN_COLLECT,[],!0);if(!t(this,Mt,"f")[e].column)throw new It(ht.EMPTY_COLUMN_IN_COLLECT,[],!0);if(!("string"==typeof t(this,Mt,"f")[e].column||t(this,Mt,"f")[e].column instanceof String))throw new It(ht.INVALID_COLUMN_IN_COLLECT,[],!0);if(void 0!==t(this,Mt,"f")[e].skyflowID&&!t(this,Mt,"f")[e].skyflowID)throw new It(ht.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[],!0)}return!0}setError(e){t(this,Yt,"f").emit(Le,{name:Rt(t(this,Bt,"f").name),isTriggerError:!0,clientErrorText:e})}resetError(){t(this,Yt,"f").emit(Le,{name:Rt(t(this,Bt,"f").name),isTriggerError:!1})}setValue(e){t(this,jt,"f").env!==st.PROD?t(this,wt,"f")&&t(this,Yt,"f").emit(ve,{name:t(this,Bt,"f").name,options:Object.assign(Object.assign({},t(this,Mt,"f")[0]),{value:e}),isSingleElementAPI:!0}):Et(ut(le.UNABLE_TO_SET_VALUE_IN_PROD_ENV,t(this,Mt,"f")[0].elementType),rt.WARN,t(this,jt,"f").logLevel)}clearValue(){t(this,jt,"f").env!==st.PROD?t(this,wt,"f")&&t(this,Yt,"f").emit(ve,{name:t(this,Bt,"f").name,options:Object.assign(Object.assign({},t(this,Mt,"f")[0]),{value:""}),isSingleElementAPI:!0}):Et(ut(le.UNABLE_TO_CLEAR_VALUE_IN_PROD_ENV,t(this,Mt,"f")[0].elementType),rt.WARN,t(this,jt,"f").logLevel)}}function Qt(e,t,i={}){if("group"!==e&&!Object.prototype.hasOwnProperty.call(be,e))throw new It(ht.INVALID_ELEMENT_TYPE,[],!0);if(Object.prototype.hasOwnProperty.call(t,"validations")){if(!Array.isArray(t.validations))throw new It(ht.INVALID_VALIDATIONS_TYPE,[],!0);t.validations.forEach(((e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new It(ht.MISSING_VALIDATION_RULE_TYPE,[`${t}`],!0);if(!Object.values(at).includes(e.type))throw new It(ht.INVALID_VALIDATION_RULE_TYPE,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"params"))throw new It(ht.MISSING_VALIDATION_RULE_PARAMS,[`${t}`],!0);if("object"!=typeof e.params||Array.isArray(e.params)||null===e.params)throw new It(ht.INVALID_VALIDATION_RULE_PARAMS,[`${t}`],!0);if(e.type===at.REGEX_MATCH_RULE){if(!Object.prototype.hasOwnProperty.call(e.params,"regex"))throw new It(ht.MISSING_REGEX_IN_REGEX_MATCH_RULE,[`${t}`],!0)}else if(e.type===at.LENGTH_MATCH_RULE&&!Object.prototype.hasOwnProperty.call(e.params,"min")&&!Object.prototype.hasOwnProperty.call(e.params,"max"))throw new It(ht.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}=be[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===be.radio.name||e===be.checkbox.name)&&!i.value)throw new Error("Elements radio and checkbox requires value attribute");if(!(e!==be.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 ei(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(ae.CANNOT_CHANGE_ELEMENT);Qt(a.elementType,a,l),s.elements[t]=Object.assign(Object.assign(Object.assign({},a),l),{elementName:a.elementName});const d=l.classes||{},c=l.styles||{};c.base=Object.assign(Object.assign({},Ue),c.base),l.classes=d,l.styles=c;const E=(null===(n=null==l?void 0:l.labelStyles)||void 0===n?void 0:n.classes)||{},u=(null===(o=null==l?void 0:l.labelStyles)||void 0===o?void 0:o.styles)||{};i&&function(e,t){Object.values(ke).forEach((i=>{if(e[i]||t[i])switch(i){case ke.BASE:t[i]=Object.assign({},t[i]);break;case ke.FOCUS:t[ke.BASE]=Object.assign(Object.assign({},t[ke.BASE]),{":focus":Object.assign({},t[ke.BASE]&&t[ke.BASE][":focus"])});break;case ke.WEBPACKAUTOFILL:t[ke.BASE]=Object.assign(Object.assign({},t[ke.BASE]),{":-webkit-autofill":Object.assign({},t[ke.BASE]&&t[ke.BASE][":-webkit-autofill"])});break;default:t[i]=Object.assign(Object.assign({},t[ke.BASE]),t[i])}})),Object.keys(t).forEach((e=>{const i=t[e][":-webkit-autofill"];"object"==typeof i&&Object.keys(i).forEach((e=>{i[e]&&!i[e].includes("!important")&&(i[e]=`${i[e]} !important`)}))}))}(E,u),l.labelStyles={labelClasses:E},l.labelStyles.styles=u}))})),t}bt=new WeakMap,wt=new WeakMap,Pt=new WeakMap,Mt=new WeakMap,Ut=new WeakMap,kt=new WeakMap,Vt=new WeakMap,xt=new WeakMap,Yt=new WeakMap,Bt=new WeakMap,Gt=new WeakMap,Ft=new WeakMap,jt=new WeakMap,Xt=new WeakMap,$t=new WeakMap,Wt=new WeakMap,Kt=new WeakMap,Ht=new WeakMap,zt=new WeakMap,qt=new WeakMap;const ti=e=>{const{rows:t}=e,i=[];return t.forEach((e=>{e.elements.forEach((e=>{i.push(e)}))})),i},ii=e=>{const t=e.validations;return t&&Array.isArray(t)&&t.length>0&&t.forEach(((e,t)=>{if(e&&e.type===at.ELEMENT_VALUE_MATCH_RULE){if(e.params&&!Object.prototype.hasOwnProperty.call(e.params,"element"))throw new It(ht.MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE,[`${t}`],!0);if(e.params&&(null==e.params.element||!(e.params.element instanceof Zt)))throw new It(ht.INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE,[`${t}`],!0);e.params&&e.params.element&&e.params.element instanceof Zt&&(e.params.element=e.params.element.iframeName())}else if(e&&e.type===at.REGEX_MATCH_RULE){if(e.params&&e.params.regex&&!mt(e.params.regex))throw new It(ht.INVALID_REGEX_IN_REGEX_MATCH_RULE,[`${t}`],!0);e.params&&e.params.regex&&mt(e.params.regex)&&(e.params.regex=e.params.regex.toString())}})),t},ni=(e,t,i)=>{let n=Object.assign({required:!1},t);if((Object.prototype.hasOwnProperty.call(n,"format")||Object.prototype.hasOwnProperty.call(n,"translation"))&&(Fe.includes(e)?(Et(ut(le.INPUT_FORMATTING_NOT_SUPPROTED,e),rt.WARN,i),null==n||delete n.format,null==n||delete n.translation):e===be.INPUT_FIELD.name&&((e=>{if(e){if(Object.prototype.hasOwnProperty.call(e,"format")&&"string"!=typeof e.format)throw new It(ht.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 It(ht.INVALID_INPUT_OPTIONS_TRANSLATION,[],!0)}})(t),n=Object.assign(Object.assign({},n),{mask:[n.format,n.translation?n.translation:je]}),null==n||delete n.format,null==n||delete n.translation)),e===be.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)===we&&(e="-"),n=Object.assign(Object.assign({},n),{cardSeperator:e}),null==n||delete n.format,null==n||delete n.translation}else if(e===be.EXPIRATION_DATE.name){let e=!1;n.format&&(e=!!(o=n.format.toUpperCase())&&Ye.includes(o),e||Et(ut(le.INVALID_EXPIRATION_DATE_FORMAT,Ye.toString()),rt.WARN,i)),n=Object.assign(Object.assign({},n),{format:e?n.format.toUpperCase():xe}),null==n||delete n.translation}else if(e===be.EXPIRATION_YEAR.name){let e=!1;n.format&&(e=(e=>!!e&&Be.includes(e))(n.format.toUpperCase()),e||Et(ut(le.INVALID_EXPIRATION_YEAR_FORMAT,Be.toString()),rt.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")&&!yt(n.enableCardIcon))throw new It(ht.INVALID_BOOLEAN_OPTIONS,["enableCardIcon"],!0);if(Object.prototype.hasOwnProperty.call(n,"enableCopy")&&!yt(n.enableCopy))throw new It(ht.INVALID_BOOLEAN_OPTIONS,["enableCopy"],!0);if(Object.prototype.hasOwnProperty.call(n,"required")&&!yt(n.required))throw new It(ht.INVALID_BOOLEAN_OPTIONS,["required"],!0);return n};function oi(){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 si{}var ri,ai,li,di,ci,Ei,ui,_i,Ii,hi,pi,Ni;const fi="CollectContainer";class Ti extends si{constructor(e,n,o,s){super(),ri.set(this,void 0),ai.set(this,{}),li.set(this,void 0),di.set(this,void 0),ci.set(this,void 0),this.type=Nn.COLLECT,Ei.set(this,void 0),ui.set(this,!1),this.create=(e,i={required:!1})=>{At(e,t(this,di,"f").logLevel);const n=ii(e),o=ni(e.type,i,t(this,di,"f").logLevel),s={rows:[{elements:[Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column,accept:i.allowedFileType},e),o),{validations:n})]}]};return t(this,_i,"f").call(this,s,!0)},_i.set(this,((e,i=!1)=>{const n=[],o=Qe(e);if(o.rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;Qt(i,t),t.sensitive=t.sensitive||be[i].sensitive,t.replacePattern=t.replacePattern||be[i].replacePattern,t.mask=t.mask||be[i].mask,t.isMounted=!1,t.elementType!==be.radio.name&&t.elementType!==be.checkbox.name||(t.elementName=`${t.elementName}:${btoa(t.value)}`),t.elementName=`${ce}:${t.elementType}:${btoa(oi())}`,t.label=e.label,t.skyflowID=e.skyflowID,n.push(t)}))})),o.elementName=i?n[0].elementName:`${ce}:group:${btoa(o.name)}`,i&&!t(this,ai,"f")[n[0].elementName]&&t(this,Ni,"f").call(this,n[0].name))throw new It(ht.UNIQUE_ELEMENT_NAME,[`${n[0].name}`],!0);let s=t(this,ai,"f")[o.elementName];if(s)i?s.update(n[0]):s.update(o);else{const e=oi();s=new Zt(e,o,t(this,li,"f"),{containerId:t(this,ri,"f"),isMounted:t(this,ui,"f"),type:this.type},i,t(this,hi,"f"),t(this,pi,"f"),t(this,di,"f"),t(this,Ei,"f")),t(this,ai,"f")[o.elementName]=s,t(this,ci,"f")[e]=s}return i||n.forEach((e=>{const i=e.elementName;t(this,ai,"f")[i]?t(this,ai,"f")[i].update(e):t(this,ai,"f")[i]=this.create(e.elementType,s)})),s})),Ii.set(this,(e=>{Object.keys(t(this,ai,"f")).forEach((i=>{i===e&&delete t(this,ai,"f")[i]}))})),hi.set(this,(e=>{e.forEach((e=>{t(this,Ii,"f").call(this,e)}))})),pi.set(this,(e=>{e.forEach((e=>{t(this,ai,"f")[e.elementName]&&t(this,ai,"f")[e.elementName].update(e)}))})),Ni.set(this,(e=>{const i=Object.keys(t(this,ai,"f"));for(let t=0;t<i.length;t+=1)if(atob(i[t].split(":")[2])===e)return!0;return!1})),this.collect=(e={tokens:!0})=>new Promise(((i,n)=>{try{Ot(t(this,li,"f").clientJSON.config);if(Object.values(t(this,ai,"f")).forEach((e=>{if(!e.isMounted())throw new It(ht.ELEMENTS_NOT_MOUNTED,[],!0);e.isValidElement()})),Object.prototype.hasOwnProperty.call(e,"tokens")&&!yt(e.tokens))throw new It(ht.INVALID_TOKENS_IN_COLLECT,[],!0);(null==e?void 0:e.additionalFields)&&Nt(e.additionalFields),(null==e?void 0:e.upsert)&&Lt(null==e?void 0:e.upsert),se.emit(Ne+t(this,ri,"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)?(Et(`${JSON.stringify(null==e?void 0:e.error)}`,rt.ERROR,t(this,di,"f").logLevel),n(null==e?void 0:e.error)):(Et(ut(re.COLLECT_SUBMIT_SUCCESS,fi),rt.LOG,t(this,di,"f").logLevel),i(e))})),Et(ut(re.EMIT_EVENT,fi,Ne),rt.LOG,t(this,di,"f").logLevel)}catch(e){Et(`${e.message}`,rt.ERROR,t(this,di,"f").logLevel),n(e)}})),i(this,ri,oi(),"f"),i(this,li,n,"f"),i(this,ci,o,"f"),i(this,di,s,"f"),i(this,Ei,new Xe,"f");const r=qe({name:`${de}:${t(this,ri,"f")}:${t(this,di,"f").logLevel}`});ze(r,{src:Je()}),Ze(r,Object.assign({},Me)),Et(ut(re.CREATE_COLLECT_CONTAINER,fi),rt.LOG,t(this,di,"f").logLevel);const a=(e,o)=>{e.name===de+t(this,ri,"f")&&(o(Object.assign(Object.assign({},n),{clientJSON:Object.assign(Object.assign({},n.clientJSON),{config:Object.assign({},n.clientJSON.config)}),context:s})),i(this,ui,!0,"f"),t(this,Ei,"f")._emit(De,{containerId:t(this,ri,"f")}),se.target($e.IFRAME_SECURE_ORGIN).off(pe+t(this,ri,"f"),a))};se.target($e.IFRAME_SECURE_ORGIN).on(pe+t(this,ri,"f"),a),document.body.append(r)}}ri=new WeakMap,ai=new WeakMap,li=new WeakMap,di=new WeakMap,ci=new WeakMap,Ei=new WeakMap,ui=new WeakMap,_i=new WeakMap,Ii=new WeakMap,hi=new WeakMap,pi=new WeakMap,Ni=new WeakMap;var vi=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},mi=function(e){return e};var Oi,Ai,Li,yi,Ri,Di,Si,Ci,gi,bi,wi,Pi,Mi,Ui,ki,Vi,xi,Yi,Bi,Gi,Fi,ji,Xi,$i=L((function(e){return e&&e.length?vi(e,mi):0}));class Wi{constructor(e,n){Oi.set(this,void 0),Ai.set(this,void 0),this.type=Nn.COMPOSABLE,Li.set(this,!1),yi.set(this,!1),this.update=e=>{i(this,yi,!0,"f"),t(this,Li,"f")?(t(this,Ai,"f")._emit(ye,{elementName:t(this,Oi,"f"),elementOptions:e}),i(this,yi,!1,"f")):t(this,yi,"f")&&t(this,Ai,"f").on(`${nt.READY}:${t(this,Oi,"f")}`,(()=>{t(this,Ai,"f")._emit(ye,{elementName:t(this,Oi,"f"),elementOptions:e}),i(this,Li,!0,"f"),i(this,yi,!1,"f")}))},i(this,Oi,e,"f"),i(this,Ai,n,"f"),t(this,Ai,"f").on(`${nt.READY}:${t(this,Oi,"f")}`,(()=>{i(this,Li,!0,"f")}))}on(e,i){if(!Object.values(he).includes(e))throw new It(ht.INVALID_EVENT_LISTENER,[],!0);if(!i)throw new It(ht.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof i)throw new It(ht.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);t(this,Ai,"f").on(`${e}:${t(this,Oi,"f")}`,(e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,i(e)}))}}Oi=new WeakMap,Ai=new WeakMap,Li=new WeakMap,yi=new WeakMap;const Ki="CollectContainer";class Hi extends si{constructor(e,n,o,s){super(),Ri.set(this,void 0),Di.set(this,{}),Si.set(this,void 0),Ci.set(this,{rows:[]}),gi.set(this,[]),bi.set(this,void 0),wi.set(this,void 0),Pi.set(this,void 0),Mi.set(this,!1),Ui.set(this,void 0),ki.set(this,void 0),this.type=Nn.COMPOSABLE,Vi.set(this,!1),xi.set(this,{}),this.create=(e,i={required:!1})=>{At(e,t(this,bi,"f").logLevel);const n=ii(e),o=ni(e.type,i,t(this,bi,"f").logLevel),s=`${ce}:${e.type}:${btoa(oi())}`;return t(this,gi,"f").push(Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column},e),o),{validations:n,elementName:s})),new Wi(s,t(this,Pi,"f"))},Yi.set(this,((e,n=!1)=>{const o=[];if(i(this,xi,Qe(e),"f"),t(this,xi,"f").rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;Qt(i,t),t.sensitive=t.sensitive||be[i].sensitive,t.replacePattern=t.replacePattern||be[i].replacePattern,t.mask=t.mask||be[i].mask,t.isMounted=!1,t.label=e.label,t.skyflowID=e.skyflowID,o.push(t)}))})),t(this,xi,"f").elementName=n?o[0].elementName:`${ce}:group:${btoa(t(this,xi,"f").name)}`,n&&!t(this,Di,"f")[o[0].elementName]&&t(this,ji,"f").call(this,o[0].name))throw new It(ht.UNIQUE_ELEMENT_NAME,[`${o[0].name}`],!0);let s=t(this,Di,"f")[t(this,xi,"f").elementName];if(s)n?s.update(o[0]):s.update(t(this,xi,"f"));else{const e=oi();s=new Zt(e,t(this,xi,"f"),t(this,Si,"f"),{containerId:t(this,Ri,"f"),isMounted:t(this,Vi,"f"),type:this.type},!0,t(this,Gi,"f"),t(this,Fi,"f"),t(this,bi,"f"),t(this,Pi,"f")),t(this,Di,"f")[t(this,xi,"f").elementName]=s,t(this,wi,"f")[e]=s}return s})),Bi.set(this,(e=>{Object.keys(t(this,Di,"f")).forEach((i=>{i===e&&delete t(this,Di,"f")[i]}))})),Gi.set(this,(e=>{e.forEach((e=>{t(this,Bi,"f").call(this,e)}))})),Fi.set(this,(e=>{e.forEach((e=>{t(this,Di,"f")[e.elementName]&&t(this,Di,"f")[e.elementName].update(e)}))})),ji.set(this,(e=>{const i=Object.keys(t(this,Di,"f"));for(let t=0;t<i.length;t+=1)if(atob(i[t].split(":")[2])===e)return!0;return!1})),this.on=(e,i)=>{if(!Object.values(he).includes(e))throw new It(ht.INVALID_EVENT_LISTENER,[],!0);if(!i)throw new It(ht.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof i)throw new It(ht.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);t(this,Pi,"f").on(he.SUBMIT,(()=>{i()}))},this.mount=e=>{if(!e)throw new It(ht.EMPTY_ELEMENT_IN_MOUNT,["CollectElement"],!0);const{layout:n}=t(this,Ui,"f");if($i(n)!==t(this,gi,"f").length)throw new It(ht.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM,[],!0);let o=0;if(n.forEach(((e,i)=>{t(this,Ci,"f").rows=[...t(this,Ci,"f").rows,{elements:[]}];for(let n=0;n<e;n++)t(this,Ci,"f").rows[i].elements.push(t(this,gi,"f")[o]),o++})),t(this,Ui,"f").styles&&(t(this,Ci,"f").styles=Object.assign({},t(this,Ui,"f").styles)),t(this,Ui,"f").errorTextStyles&&(t(this,Ci,"f").errorTextStyles=Object.assign({},t(this,Ui,"f").errorTextStyles)),t(this,Vi,"f"))return i(this,ki,t(this,Yi,"f").call(this,t(this,Ci,"f"),!1),"f"),t(this,ki,"f").mount(e),void i(this,Mi,!0,"f");t(this,Pi,"f").on(Re+t(this,Ri,"f"),(()=>{i(this,ki,t(this,Yi,"f").call(this,t(this,Ci,"f"),!1),"f"),t(this,ki,"f").mount(e),i(this,Mi,!0,"f")}))},this.unmount=()=>{t(this,ki,"f").unmount()},this.collect=(e={tokens:!0})=>new Promise(((i,n)=>{try{if(Ot(t(this,Si,"f").clientJSON.config),!t(this,Mi,"f"))throw new It(ht.COMPOSABLE_CONTAINER_NOT_MOUNTED,[],!0);ti(t(this,xi,"f")).forEach((e=>{if(!(null==e?void 0:e.isMounted))throw new It(ht.ELEMENTS_NOT_MOUNTED,[],!0)}));if(Object.values(t(this,Di,"f")).forEach((e=>{e.isValidElement()})),e&&e.tokens&&"boolean"!=typeof e.tokens)throw new It(ht.INVALID_TOKENS_IN_COLLECT,[],!0);(null==e?void 0:e.additionalFields)&&Nt(e.additionalFields),(null==e?void 0:e.upsert)&&Lt(null==e?void 0:e.upsert),se.emit(Ne+t(this,Ri,"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)?(Et(`${JSON.stringify(null==e?void 0:e.error)}`,rt.ERROR,t(this,bi,"f").logLevel),n(null==e?void 0:e.error)):(Et(ut(re.COLLECT_SUBMIT_SUCCESS,Ki),rt.LOG,t(this,bi,"f").logLevel),i(e))})),Et(ut(re.EMIT_EVENT,Ki,Ne),rt.LOG,t(this,bi,"f").logLevel)}catch(e){Et(`${e.message}`,rt.ERROR,t(this,bi,"f").logLevel),n(e)}})),Xi.set(this,(()=>{t(this,Pi,"f").on(ye,(e=>{let i;const n=t(this,gi,"f").map(((t,n)=>t.elementName===e.elementName?(i=n,Object.assign({elementName:t.elementName},e.elementOptions)):t));t(this,ki,"f")&&t(this,ki,"f").updateElement(Object.assign({},n[i]))}))})),i(this,Ri,oi(),"f"),i(this,Si,n,"f"),i(this,wi,o,"f"),i(this,bi,s,"f"),i(this,Ui,e,"f"),i(this,Pi,new Xe,"f");const r=qe({name:`${de}:${t(this,Ri,"f")}:${t(this,bi,"f").logLevel}`});ze(r,{src:Je()}),Ze(r,Object.assign({},Me)),Et(ut(re.CREATE_COLLECT_CONTAINER,Ki),rt.LOG,t(this,bi,"f").logLevel);const a=(e,o)=>{e.name===de+t(this,Ri,"f")&&(o(Object.assign(Object.assign({},n),{clientJSON:Object.assign(Object.assign({},n.clientJSON),{config:Object.assign({},n.clientJSON.config)}),context:s})),i(this,Vi,!0,"f"),t(this,Pi,"f")._emit(Re+t(this,Ri,"f"),{containerId:t(this,Ri,"f")}),se.target($e.IFRAME_SECURE_ORGIN).off(pe+t(this,Ri,"f"),a))};se.target($e.IFRAME_SECURE_ORGIN).on(pe+t(this,Ri,"f"),a),document.body.append(r),t(this,Xi,"f").call(this)}}var zi,qi,Ji,Zi;Ri=new WeakMap,Di=new WeakMap,Si=new WeakMap,Ci=new WeakMap,gi=new WeakMap,bi=new WeakMap,wi=new WeakMap,Pi=new WeakMap,Mi=new WeakMap,Ui=new WeakMap,ki=new WeakMap,Vi=new WeakMap,xi=new WeakMap,Yi=new WeakMap,Bi=new WeakMap,Gi=new WeakMap,Fi=new WeakMap,ji=new WeakMap,Xi=new WeakMap;const Qi="SkyflowContainer";class en{constructor(e,n){var o,s;zi.set(this,void 0),qi.set(this,void 0),Ji.set(this,!1),Zi.set(this,void 0),i(this,qi,e,"f"),i(this,zi,(null===(s=null===(o=t(this,qi,"f").toJSON())||void 0===o?void 0:o.metaData)||void 0===s?void 0:s.uuid)||"","f"),i(this,Zi,n,"f");const r=qe({name:`skyflow_controller:${t(this,zi,"f")}`});ze(r,{src:Je()}),Ze(r,Object.assign({},Me)),document.body.append(r),se.target($e.IFRAME_SECURE_ORGIN).on(Oe+t(this,zi,"f"),((e,o)=>{Et(ut(re.CAPTURE_PUREJS_FRAME,Qi),rt.LOG,t(this,Zi,"f").logLevel),o({client:t(this,qi,"f"),context:n}),i(this,Ji,!0,"f")})),Et(ut(re.PUREJS_CONTROLLER_INITIALIZED,Qi),rt.LOG,t(this,Zi,"f").logLevel)}insert(e,i){return t(this,Ji,"f")?new Promise(((n,o)=>{Ot(t(this,qi,"f").config);try{Et(ut(re.VALIDATE_RECORDS,Qi),rt.LOG,t(this,Zi,"f").logLevel),(null==(i=i?Object.assign(Object.assign({},i),{tokens:void 0===(null==i?void 0:i.tokens)||i.tokens}):{tokens:!0})?void 0:i.upsert)&&Lt(i.upsert),pt(e,i),se.emit(me+t(this,zi,"f"),{type:Ee,records:e,options:i},(e=>{e.error?(Et(`${JSON.stringify(e.error)}`,rt.ERROR,t(this,Zi,"f").logLevel),o(e.error)):n(e)})),Et(ut(re.EMIT_PURE_JS_REQUEST,Qi,Ee),rt.LOG,t(this,Zi,"f").logLevel)}catch(e){Et(e.message,rt.ERROR,t(this,Zi,"f").logLevel),o(e)}})):new Promise(((n,o)=>{try{Ot(t(this,qi,"f").config),Et(ut(re.VALIDATE_RECORDS,Qi),rt.LOG,t(this,Zi,"f").logLevel),(null==(i=i?Object.assign(Object.assign({},i),{tokens:void 0===(null==i?void 0:i.tokens)||i.tokens}):{tokens:!0})?void 0:i.upsert)&&Lt(i.upsert),pt(e,i),se.target($e.IFRAME_SECURE_ORGIN).on(Oe+t(this,zi,"f"),(()=>{se.emit(me+t(this,zi,"f"),{type:Ee,records:e,options:i},(e=>{e.error?(Et(`${JSON.stringify(e.error)}`,rt.ERROR,t(this,Zi,"f").logLevel),o(e.error)):n(e)}))})),Et(ut(re.EMIT_PURE_JS_REQUEST,Qi,Ee),rt.LOG,t(this,Zi,"f").logLevel)}catch(e){Et(e.message,rt.ERROR,t(this,Zi,"f").logLevel),o(e)}}))}getById(e){return t(this,Ji,"f")?new Promise(((i,n)=>{Ot(t(this,qi,"f").config);try{Et(ut(re.VALIDATE_GET_BY_ID_INPUT,Qi),rt.LOG,t(this,Zi,"f").logLevel),Tt(e),Et(ut(re.EMIT_PURE_JS_REQUEST,Qi,ue),rt.LOG,t(this,Zi,"f").logLevel)}catch(e){Et(e.message,rt.ERROR,t(this,Zi,"f").logLevel),n(e)}})):new Promise(((i,n)=>{try{Ot(t(this,qi,"f").config),Et(ut(re.VALIDATE_GET_BY_ID_INPUT,Qi),rt.LOG,t(this,Zi,"f").logLevel),Tt(e),Et(ut(re.EMIT_PURE_JS_REQUEST,Qi,ue),rt.LOG,t(this,Zi,"f").logLevel)}catch(e){Et(e.message,rt.ERROR,t(this,Zi,"f").logLevel),n(e)}}))}get(e,i){return t(this,Ji,"f")?new Promise(((n,o)=>{Ot(t(this,qi,"f").config);try{Et(ut(re.VALIDATE_GET_INPUT,Qi),rt.LOG,t(this,Zi,"f").logLevel),ft(e,i),Et(ut(re.EMIT_PURE_JS_REQUEST,Qi,_e),rt.LOG,t(this,Zi,"f").logLevel)}catch(e){Et(e.message,rt.ERROR,t(this,Zi,"f").logLevel),o(e)}})):new Promise(((n,o)=>{try{Ot(t(this,qi,"f").config),Et(ut(re.VALIDATE_GET_INPUT,Qi),rt.LOG,t(this,Zi,"f").logLevel),ft(e,i),Et(ut(re.EMIT_PURE_JS_REQUEST,Qi,_e),rt.LOG,t(this,Zi,"f").logLevel)}catch(e){Et(e.message,rt.ERROR,t(this,Zi,"f").logLevel),o(e)}}))}delete(e,i){return t(this,Ji,"f")?new Promise(((n,o)=>{Ot(t(this,qi,"f").config);try{Et(ut(re.VALIDATE_DELETE_INPUT,Qi),rt.LOG,t(this,Zi,"f").logLevel),vt(e),se.emit(me+t(this,zi,"f"),{type:Ie,records:e,options:i},(e=>{e.error?(Et(`${JSON.stringify(e.error)}`,rt.ERROR,t(this,Zi,"f").logLevel),o(e.error)):n(e)})),Et(ut(re.EMIT_PURE_JS_REQUEST,Qi,Ie),rt.LOG,t(this,Zi,"f").logLevel)}catch(e){Et(e.message,rt.ERROR,t(this,Zi,"f").logLevel),o(e)}})):new Promise(((n,o)=>{try{Ot(t(this,qi,"f").config),Et(ut(re.VALIDATE_RECORDS,Qi),rt.LOG,t(this,Zi,"f").logLevel),vt(e),se.target($e.IFRAME_SECURE_ORGIN).on(Oe+t(this,zi,"f"),(()=>{se.emit(me+t(this,zi,"f"),{type:Ie,records:e,options:i},(e=>{e.error?(Et(`${JSON.stringify(e.error)}`,rt.ERROR,t(this,Zi,"f").logLevel),o(e.error)):n(e)}))})),Et(ut(re.EMIT_PURE_JS_REQUEST,Qi,Ie),rt.LOG,t(this,Zi,"f").logLevel)}catch(e){Et(e.message,rt.ERROR,t(this,Zi,"f").logLevel),o(e)}}))}}function tn(e){this.message=e}zi=new WeakMap,qi=new WeakMap,Ji=new WeakMap,Zi=new WeakMap,tn.prototype=new Error,tn.prototype.name="InvalidCharacterError";var nn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new tn("'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 on(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(nn(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 nn(t)}}function sn(e){this.message=e}sn.prototype=new Error,sn.prototype.name="InvalidTokenError";const rn=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 sn("Invalid token specified");var i=!0===(t=t||{}).header?0:1;try{return JSON.parse(on(e.split(".")[i]))}catch(e){throw new sn("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 an,ln,dn,cn,En,un,_n,In,hn,pn,Nn,fn={name:"skyflow-js",preferGlobal:!0,analyze:!1,version:"1.30.1",author:"Skyflow",description:"Skyflow JavaScript SDK"};class Tn{constructor(e,n){an.set(this,void 0),this.request=e=>new Promise(((i,n)=>{var o,s,r,a;const l=new XMLHttpRequest;if(l){if(l.open(e.requestMethod,e.url),e.headers){const i=function(e,t,i){var n,o,s,r,a;const l={sdkName:e.name,sdkVersion:e.version},d=function(e,t){return""!==e?`${e}`:`${t.sdkName}@${t.sdkVersion}`}(t.sdkVersion,l),c=function(e){var t,i,n,o,s,r,a,l,d,c,E,u;let _=null,I=null;return/Windows/.test(e)?(_="Windows",I=null!==(i=null===(t=/Windows NT (\d+\.\d+)/.exec(e))||void 0===t?void 0:t[1])&&void 0!==i?i:null):/Android/.test(e)?(_="Android",I=null!==(o=null===(n=/Android (\d+\.\d+)/.exec(e))||void 0===n?void 0:n[1])&&void 0!==o?o:null):/iOS/.test(e)||/iPhone/.test(e)?(_="iOS",I=null!==(a=null===(r=null===(s=/OS (\d+[._]\d+[._]?\d*)/.exec(e))||void 0===s?void 0:s[1])||void 0===r?void 0:r.replace(/_/g,"."))&&void 0!==a?a:null):/Mac OS X/.test(e)?(_="Mac OS X",I=null!==(c=null===(d=null===(l=/Mac OS X (\d+([._]\d+)*)/.exec(e))||void 0===l?void 0:l[1])||void 0===d?void 0:d.replace(/_/g,"."))&&void 0!==c?c:null):/Linux/.test(e)&&(_="Linux",I=null!==(u=null===(E=/Linux( \w+)*?\/([\w.]+)/.exec(e))||void 0===E?void 0:E[2])&&void 0!==u?u:null),{os:_,version:I}}(i.userAgent),E=function(e){let t="",i="";if(-1!==e.indexOf("MSIE")||-1!==e.indexOf("Trident/")){t="Internet Explorer";const n=e.match(/(MSIE|rv:)\s?([\d.]+)/);n&&(i=n[2])}else if(-1!==e.indexOf("Edge")){t="Microsoft Edge";const n=e.match(/Edge\/([\d.]+)/);n&&(i=n[1])}else if(-1!==e.indexOf("Chrome")){t="Google Chrome";const n=e.match(/Chrome\/([\d.]+)/);n&&(i=n[1])}else if(-1!==e.indexOf("Firefox")){t="Mozilla Firefox";const n=e.match(/Firefox\/([\d.]+)/);n&&(i=n[1])}else if(-1!==e.indexOf("Safari")){t="Apple Safari";const n=e.match(/Version\/([\d.]+)/);n&&(i=n[1])}return{browserName:t,browserVersion:i}}(i.userAgent);var u;return{sdk_name_version:d,sdk_client_device_model:(u=i.userAgent,/(ipad|tablet)/gi.test(u)?"tablet":/Mobile|iP(hone|od)|Android|BlackBerry|IEMobile/.test(u)?"mobile":"desktop"),sdk_os_version:null!==(n=i.platform)&&void 0!==n?n:`${null!==(o=c.os)&&void 0!==o?o:""} ${null!==(s=c.version)&&void 0!==s?s:""}`,sdk_runtime_details:`${null!==(r=E.browserName)&&void 0!==r?r:""} ${null!==(a=E.browserVersion)&&void 0!==a?a:""}`}}(fn,t(this,an,"f"),navigator);e.headers["sky-metadata"]=JSON.stringify(i);const{headers:n}=e;Object.keys(e.headers).forEach((e=>{"content-type"===e&&n[e]&&n[e].includes(Ge.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(Ge.FORMURLENCODED))||(null===(a=null===(r=e.headers)||void 0===r?void 0:r["content-type"])||void 0===a?void 0:a.includes(Ge.FORMDATA))?l.send(e.body):l.send(JSON.stringify(Object.assign({},e.body))),l.onload=()=>{var e,t,o;const s=l.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};s.forEach((e=>{const t=e.split(": "),i=t.shift()||"",n=t.join(": ");r[i]=n}));const a=r["content-type"],d=r["x-request-id"];if(l.status<200||l.status>=400)if(a&&a.includes("application/json")){let i=JSON.parse(l.response);(null===(e=null==i?void 0:i.error)||void 0===e?void 0:e.message)&&(i=d?`${null===(t=null==i?void 0:i.error)||void 0===t?void 0:t.message} - requestId: ${d}`:null===(o=null==i?void 0:i.error)||void 0===o?void 0:o.message),n(new It({code:l.status,description:i},[],!0))}else a&&a.includes("text/plain")?n(new It({code:l.status,description:d?`${l.response} - requestId: ${d}`:l.response},[],!0)):n(new It({code:l.status,description:d?`${ae.ERROR_OCCURED} - requestId: ${d}`:ae.ERROR_OCCURED},[],!0));a&&a.includes("application/json")&&i(JSON.parse(l.response)),i(l.response)},l.onerror=()=>{n(new It(ht.NETWORK_ERROR,[],!0))}}else n(new It(ht.CONNECTION_ERROR,[],!0))})),this.config=e,i(this,an,n,"f")}toJSON(){return{config:this.config,metaData:t(this,an,"f")}}static fromJSON(e){return new Tn(e.config,e.metaData)}}an=new WeakMap,function(e){e.COLLECT="COLLECT",e.COMPOSABLE="COMPOSABLE"}(Nn||(Nn={}));const vn="Skyflow";class mn{constructor(e){var n,o;ln.set(this,void 0),dn.set(this,oi()),cn.set(this,{uuid:t(this,dn,"f"),clientDomain:window.location.origin}),En.set(this,void 0),un.set(this,""),_n.set(this,void 0),In.set(this,void 0),hn.set(this,void 0),pn.set(this,void 0);const s=localStorage.getItem("sdk_version")||"";t(this,cn,"f").sdkVersion=s,i(this,ln,new Tn(Object.assign({},e),t(this,cn,"f")),"f"),i(this,In,(null===(n=null==e?void 0:e.options)||void 0===n?void 0:n.logLevel)||ot.ERROR,"f"),i(this,hn,(null===(o=null==e?void 0:e.options)||void 0===o?void 0:o.env)||st.PROD,"f"),i(this,pn,{},"f"),i(this,En,new en(t(this,ln,"f"),{logLevel:t(this,In,"f"),env:t(this,hn,"f")}),"f");se.target($e.IFRAME_SECURE_ORGIN).on(Ae+t(this,dn,"f"),((e,n)=>{Et(ut(re.CAPTURED_BEARER_TOKEN_EVENT,vn),rt.LOG,t(this,In,"f")),!t(this,ln,"f").config.getBearerToken||t(this,un,"f")&&rn(t(this,un,"f"))?(Et(ut(re.REUSE_BEARER_TOKEN,vn),rt.LOG,t(this,In,"f")),n({authToken:t(this,un,"f")})):t(this,ln,"f").config.getBearerToken().then((e=>{rn(e)?(Et(ut(re.BEARER_TOKEN_RESOLVED,vn),rt.LOG,t(this,In,"f")),i(this,un,e,"f"),n({authToken:t(this,un,"f")})):(Et(ae.INVALID_BEARER_TOKEN,rt.ERROR,t(this,In,"f")),n({error:ae.INVALID_BEARER_TOKEN}))})).catch((e=>{Et(ae.BEARER_TOKEN_REJECTED,rt.ERROR,t(this,In,"f")),n({error:e})}))})),Et(ut(re.BEARER_TOKEN_LISTENER,vn),rt.LOG,t(this,In,"f")),Et(ut(re.CURRENT_ENV,vn,t(this,hn,"f")),rt.LOG,t(this,In,"f")),Et(ut(re.CURRENT_LOG_LEVEL,vn,t(this,In,"f")),rt.LOG,t(this,In,"f"))}static init(e){var t;const i=(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||ot.ERROR;St(e),Et(ut(re.INITIALIZE_CLIENT,vn),rt.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 mn(n);return Et(ut(re.CLIENT_INITIALIZED,vn),rt.LOG,i),s}container(e,i){switch(e){case Nn.COLLECT:{const n=new Ti(i,Object.assign(Object.assign({},t(this,cn,"f")),{clientJSON:t(this,ln,"f").toJSON(),containerType:e}),t(this,pn,"f"),{logLevel:t(this,In,"f"),env:t(this,hn,"f")});return Et(ut(re.COLLECT_CONTAINER_CREATED,vn),rt.LOG,t(this,In,"f")),n}case Nn.COMPOSABLE:{(e=>{if(!e)throw new It(ht.MISSING_COMPOSABLE_CONTAINER_OPTIONS,[],!0);if("object"!=typeof e)throw new It(ht.INVALID_COMPOSABLE_CONTAINER_OPTIONS,[],!0);if(!Object.prototype.hasOwnProperty.call(e,"layout"))throw new It(ht.MISSING_COMPOSABLE_LAYOUT_KEY,[],!0);if(!e.layout)throw new It(ht.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(!Array.isArray(e.layout))throw new It(ht.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(0===e.layout.length)throw new It(ht.EMPTY_COMPOSABLE_LAYOUT_ARRAY,[],!0);e.layout.forEach((e=>{if("number"!=typeof e)throw new It(ht.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(e<0)throw new It(ht.NEGATIVE_VALUES_COMPOSABLE_LAYOUT,[],!0)}))})(i);const n=new Hi(i,Object.assign(Object.assign({},t(this,cn,"f")),{clientJSON:t(this,ln,"f").toJSON(),containerType:e}),t(this,pn,"f"),{logLevel:t(this,In,"f"),env:t(this,hn,"f")});return Et(ut(re.COLLECT_CONTAINER_CREATED,vn),rt.LOG,t(this,In,"f")),n}default:if(!e)throw new It(ht.EMPTY_CONTAINER_TYPE,[],!0);throw new It(ht.INVALID_CONTAINER_TYPE,[],!0)}}insert(e,i){return Et(ut(re.INSERT_TRIGGERED,vn),rt.LOG,t(this,In,"f")),t(this,En,"f").insert(e,i)}getById(e){return Et(le.GET_BY_ID_DEPRECATED,rt.WARN,t(this,In,"f")),Et(ut(re.GET_BY_ID_TRIGGERED,vn),rt.LOG,t(this,In,"f")),t(this,En,"f").getById(e)}get(e,i){return Et(ut(re.GET_TRIGGERED,vn),rt.LOG,t(this,In,"f")),t(this,En,"f").get(e,i)}delete(e,i){return Et(ut(re.DELETE_TRIGGERED,vn),rt.LOG,t(this,In,"f")),t(this,En,"f").delete(e,i)}static get ContainerType(){return Nn}static get ElementType(){return Se}static get RedactionType(){return tt}static get RequestMethod(){return it}static get LogLevel(){return ot}static get EventName(){return nt}static get Env(){return st}static get ValidationRuleType(){return at}}ln=new WeakMap,dn=new WeakMap,cn=new WeakMap,En=new WeakMap,un=new WeakMap,_n=new WeakMap,In=new WeakMap,hn=new WeakMap,pn=new WeakMap;class On{constructor(e){this.loadFunction=e,this.loadScript()}get loader(){return this.loadingPromise||(this.loadingPromise=this.loadScript()),this.loadingPromise}loadScript(){return e(this,void 0,void 0,(function*(){return this.loadingPromise||(this.loadingPromise=new Promise(((e,t)=>{this.loadFunction().then((t=>{t&&e(t)}),(()=>{t()})).catch((()=>{}))}))),this.loadingPromise}))}}class An extends m{constructor(e){super("span",{id:e.id,className:"payrails-store-instrument"}),this.options=e,this.createHTML(),this.applyStyles(),this.addListeners()}get isChecked(){var e;return!!(null===(e=this.element.querySelector("input"))||void 0===e?void 0:e.checked)}createHTML(){var e,t,i,n,o,s,r,a,l;const d=(null===(i=null===(t=null===(e=this.options)||void 0===e?void 0:e.translations)||void 0===t?void 0:t.labels)||void 0===i?void 0:i.saveInstrument)||(null===(s=null===(o=null===(n=this.options)||void 0===n?void 0:n.translations)||void 0===o?void 0:o.labels)||void 0===s?void 0:s.storeInstrument)||"Save instrument for future payments",c=`${this.id}-checkbox`;(null===(l=null===(a=null===(r=this.options)||void 0===r?void 0:r.translations)||void 0===a?void 0:a.labels)||void 0===l?void 0:l.saveInstrument)&&console.warn("The saveInstrument label is deprecated, please use storeInstrument instead"),this.element.innerHTML=`<label for="${c}"><input type="checkbox" id="${c}" name="${c}" class="payrails-store-instrument-checkbox">${d}</label>`}applyStyles(){var e,t;Object.keys((null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.storeInstrumentCheckbox)||{}).forEach((e=>{var t,i,n;this.element.style[e]=null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===i?void 0:i.storeInstrumentCheckbox)||void 0===n?void 0:n[e]}))}addListeners(){this.element.addEventListener("change",(e=>{var t,i,n,o;(null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onSaveInstrumentCheckboxChanged)&&(null===(o=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===o||o.onSaveInstrumentCheckboxChanged({checked:this.isChecked})),e.stopPropagation(),e.stopImmediatePropagation()}))}}class Ln extends m{constructor(t,i){var n,o;super(t,i),this.options=i,this.storeInstrumentCheckbox=null,(null===(n=this.options)||void 0===n?void 0:n.showStoreInstrumentCheckbox)&&(this.storeInstrumentCheckbox=new An(Object.assign(Object.assign({},i),{id:`${null===(o=this.options)||void 0===o?void 0:o.id}-store-instrument-checkbox`,events:{onSaveInstrumentCheckboxChanged:t=>e(this,void 0,void 0,(function*(){var e,n;null===(n=null===(e=null==i?void 0:i.events)||void 0===e?void 0:e.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(e,t)}))}})),this.subElements.push(this.storeInstrumentCheckbox))}get shouldStoreInstrument(){var e,t;return(null===(e=this.storeInstrumentCheckbox)||void 0===e?void 0:e.isChecked)||(null===(t=this.options)||void 0===t?void 0:t.alwaysStoreInstrument)||!1}}class yn extends Ln{constructor(t,i,n){super("div",Object.assign(Object.assign({},n),{id:"payrails-apple-pay-button"})),this.sdkConfig=t,this.execution=i,this.options=n,this.appleButton=null,this.paymentExecutor=new p(t,i),this.loadScript=new On((()=>e(this,void 0,void 0,(function*(){const t=document.createElement("script");return t.src="https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js",new Promise(((i,n)=>{t.onload=()=>e(this,void 0,void 0,(function*(){var e,t,n;(yield this.isApplePayAvailable())?(null===(n=null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onApplePayAvailable)||void 0===n||n.call(t),i(!0)):i(!1)})),t.onerror=()=>{n()},document.body.appendChild(t)}))}))))}mount(t){super.mount(t),(()=>{e(this,void 0,void 0,(function*(){try{yield this.loadScript.loader,yield this.mountApplePayButton()}catch(e){}}))})()}unmount(){var e,t;null===(t=null===(e=this.appleButton)||void 0===e?void 0:e.parentElement)||void 0===t||t.removeChild(this.appleButton),super.unmount()}isApplePayAvailable(){return e(this,void 0,void 0,(function*(){if(!(null===window||void 0===window?void 0:window.ApplePaySession))return!1;return yield ApplePaySession.canMakePayments()}))}mountApplePayButton(){var t,i,n,o,s;return e(this,void 0,void 0,(function*(){if(null===window||void 0===window?void 0:window.ApplePaySession)try{if(!this.isApplePayAvailable())return;null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onApplePayAvailable)||void 0===i||i.call(t);const e=(null===(n=this.options.styles)||void 0===n?void 0:n.type)||"buy",r=(null===(o=this.options.styles)||void 0===o?void 0:o.style)||"black";this.element.innerHTML=`<apple-pay-button buttonstyle="${r}" type="${e}" locale="en-GB"></apple-pay-button>`,null===(s=this.storeInstrumentCheckbox)||void 0===s||s.mount(this.selector);const a=this.element.querySelector("apple-pay-button");null==a||a.setAttribute("style","width: 100%;"),null==a||a.addEventListener("click",(()=>{this.createApplePaySession()}))}catch(e){}}))}createApplePaySession(){const t=this.execution.applePayConfig,{countryCode:i,supportedNetworks:n,merchantCapabilities:o}=t,{amount:s}=this.sdkConfig;try{const t={countryCode:i,currencyCode:s.currency,merchantCapabilities:o,supportedNetworks:n,total:{label:"",type:"final",amount:s.value}},r=new ApplePaySession(3,t);return r.onvalidatemerchant=t=>e(this,void 0,void 0,(function*(){const{res:e}=yield this.paymentExecutor.createApplePaySession({requestUrl:this.execution.createSessionLink,sessionUrl:t.validationURL,clientDomain:this.options.clientDomain}),i=e.data.data;r.completeMerchantValidation(i)})),r.onpaymentauthorized=t=>e(this,void 0,void 0,(function*(){var e,i,n,o,s,a,l,d,c,E,u,_;try{const E=yield this.onApplePayAuthorized(t.payment.token);if("authorizeSuccessful"===(null===(e=null==E?void 0:E.finalState)||void 0===e?void 0:e.code))(null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeSuccess)&&this.options.events.onAuthorizeSuccess();else r.completePayment(ApplePaySession.STATUS_FAILURE),(null===(o=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===o?void 0:o.onAuthorizeFailed)&&(null===(s=this.options)||void 0===s||s.events.onAuthorizeFailed());r.completePayment(ApplePaySession.STATUS_SUCCESS),(null===(l=null===(a=this.options)||void 0===a?void 0:a.events)||void 0===l?void 0:l.onAuthorizeSuccess)&&(null===(c=null===(d=this.options)||void 0===d?void 0:d.events)||void 0===c||c.onAuthorizeSuccess(E))}catch(e){r.completePayment(ApplePaySession.STATUS_FAILURE),(null===(u=null===(E=this.options)||void 0===E?void 0:E.events)||void 0===u?void 0:u.onAuthorizeFailed)&&(null===(_=this.options)||void 0===_||_.events.onAuthorizeFailed(e))}})),r.begin(),r}catch(e){return null}}onApplePayAuthorized(t){return e(this,void 0,void 0,(function*(){const e={paymentData:t.paymentData,transactionIdentifier:t.transactionIdentifier,paymentNetwork:t.paymentMethod.network,paymentInstrumentName:t.paymentMethod.displayName},i=[{paymentMethodCode:"applePay",integrationType:"api",paymentInstrumentData:{paymentToken:JSON.stringify(e)},amount:this.sdkConfig.amount,storeInstrument:this.shouldStoreInstrument}];return yield this.paymentExecutor.pay(i)}))}}const{CARD_NUMBER:Rn,CVV:Dn,CARDHOLDER_NAME:Sn,EXPIRATION_MONTH:Cn,EXPIRATION_YEAR:gn}=exports.ElementType,bn={base:{border:"none",padding:"10px 16px",color:"#1d1d1d",backgroundColor:"#fff"},invalid:{backgroundColor:"#f9e1e1",borderColor:"#f25226",border:"1px solid"}},wn=[{type:Sn,placeholder:"Card holder",styles:Object.assign(Object.assign({},bn),{base:Object.assign(Object.assign({},bn.base),{border:"1px solid #eae8ee",padding:"10px 16px",borderTopLeftRadius:"4px",borderTopRightRadius:"4px"})})},{type:Rn,placeholder:"1234 1234 1234 1234",styles:Object.assign(Object.assign({},bn),{base:Object.assign(Object.assign({},bn.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:Cn,placeholder:"MM",styles:Object.assign(Object.assign({},bn),{base:Object.assign(Object.assign({},bn.base),{borderBottom:"1px solid #eae8ee",borderLeft:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomLeftRadius:"4px"})})},{type:gn,placeholder:"YY",format:"YY",styles:Object.assign(Object.assign({},bn),{base:Object.assign(Object.assign({},bn.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee"})})},{type:Dn,placeholder:"CVC",styles:Object.assign(Object.assign({},bn),{base:Object.assign(Object.assign({},bn.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomRightRadius:"4px"})})}];class Pn extends Ln{get bin(){return this.collectContainer.bin}constructor(e,t){var i,n,o,s,r;super("div",Object.assign(Object.assign({},t),{translations:Object.assign(Object.assign({},null==t?void 0:t.translations),{labels:Object.assign(Object.assign({},null===(i=null==t?void 0:t.translations)||void 0===i?void 0:i.labels),{saveInstrument:null===(o=null===(n=null==t?void 0:t.translations)||void 0===n?void 0:n.labels)||void 0===o?void 0:o.saveCreditCard})}),styles:Object.assign({storeInstrumentCheckbox:null===(s=null==t?void 0:t.styles)||void 0===s?void 0:s.storeCardCheckbox},null==t?void 0:t.styles),id:"payrails-card-form"})),this.collectContainer=e,this.options=t,this.formFields=[],(null===(r=null==t?void 0:t.styles)||void 0===r?void 0:r.storeCardCheckbox)&&console.warn("The `storeCardCheckbox` option for styles is deprecated. Please use `storeInstrumentCheckbox` instead."),wn.forEach((({type:e,styles:i,format:n,placeholder:o})=>{var s,r,a,l,d,c,E;if(!(null===(s=this.options)||void 0===s?void 0:s.showCardHolderName)&&e===exports.ElementType.CARDHOLDER_NAME)return;const u=new Mn(this.collectContainer,{type:e,label:null===(a=null===(r=null==t?void 0:t.translations)||void 0===r?void 0:r.labels)||void 0===a?void 0:a[e],placeholder:(null===(d=null===(l=null==t?void 0:t.translations)||void 0===l?void 0:l.placeholders)||void 0===d?void 0:d[e])||o,labelStyles:this.prepareLabelStyles(e),inputStyles:this.prepareInputStyles(i,e),format:n,events:{onFocus:null===(E=null===(c=this.options)||void 0===c?void 0:c.events)||void 0===E?void 0:E.onFocus,onChange:this.onChange.bind(this),onReady:this.triggerOnReady.bind(this)}});this.formFields.push(u)})),this.subElements.push(this.collectContainer),this.storeInstrumentCheckbox&&this.subElements.push(this.storeInstrumentCheckbox)}show(){var e,t;const i=document.getElementById(this.collectContainer.id);if(!i)throw new Error("Container is not mounted.");Object.assign(i.style,null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.wrapper),this.element.style.display="flex"}hide(){this.element.style.display="none"}triggerOnReady(){var e,t,i;this.formFields.reduce(((e,t)=>e&&t.isReady),!0)&&(null===(i=null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onReady)||void 0===i||i.call(t))}prepareLabelStyles(e){return["base"].reduce(((t,i)=>{var n,o,s,r,a,l,d,c;return t[i]=Object.assign(Object.assign(Object.assign({},null===(o=null===(n=this.options)||void 0===n?void 0:n.styles)||void 0===o?void 0:o.base),null===(a=null===(r=null===(s=this.options)||void 0===s?void 0:s.styles)||void 0===r?void 0:r.labels)||void 0===a?void 0:a.all),null===(c=null===(d=null===(l=this.options)||void 0===l?void 0:l.styles)||void 0===d?void 0:d.labels)||void 0===c?void 0:c[e]),t}),{})}prepareInputStyles(e,t){var i;let n=JSON.parse(JSON.stringify(e));return(null===(i=this.options)||void 0===i?void 0:i.showCardHolderName)&&t===exports.ElementType.CARD_NUMBER&&(this.element.setAttribute("class","with-card-holder"),n=Object.assign(Object.assign({},e),{base:Object.assign(Object.assign({},bn.base),{border:"1px solid #eae8ee",borderTop:"none",padding:"10px 16px",textIndent:"0"})})),["base","complete","empty","focus","invalid","cardIcon","copyIcon"].forEach((e=>{var i,o,s,r,a,l,d,c;n[e]=Object.assign(Object.assign(Object.assign({},n[e]),null===(r=null===(s=null===(o=null===(i=this.options)||void 0===i?void 0:i.styles)||void 0===o?void 0:o.inputFields)||void 0===s?void 0:s.all)||void 0===r?void 0:r[e]),null===(c=null===(d=null===(l=null===(a=this.options)||void 0===a?void 0:a.styles)||void 0===l?void 0:l.inputFields)||void 0===d?void 0:d[t])||void 0===c?void 0:c[e])})),n}get isValid(){return this.formFields.reduce(((e,t)=>e&&t.isValid),!0)}get cardNetwork(){var e,t;return null!==(t=null===(e=this.formFields.find((e=>Boolean(e.cardNetwork))))||void 0===e?void 0:e.cardNetwork)&&void 0!==t?t:""}onChange(){var e,t,i,n;(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onChange)&&(null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n||n.onChange({isValid:this.isValid,cardNetwork:this.cardNetwork,bin:this.bin}))}collectValues(){return e(this,void 0,void 0,(function*(){return{cardData:yield this.collectContainer.collect(),storeInstrument:this.shouldStoreInstrument,enrollInstrumentToNetworkOffers:Boolean(this.enforceEnrollInstrumentToNetworkOffersForMasterCard())}}))}enforceEnrollInstrumentToNetworkOffersForMasterCard(){var e;return"mastercard"!==this.cardNetwork&&(null===(e=this.options)||void 0===e?void 0:e.enrollInstrumentToNetworkOffers)}}class Mn{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 Un extends m{constructor(e,t){super("div",{id:"payrails-card-list"}),this.workflowExecution=e,this.listItems=[],this.workflowExecution.savedCreditCards.forEach((e=>{const i=new kn((()=>{(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 kn extends m{constructor(e,t){super("div",{className:"payrails-card-list-item",id:`payrails-card-list-item-${t.id}`});const{id:i}=t,n=this.createCardLabel(t),o=document.createElement("label");o.setAttribute("for",i),o.addEventListener("click",e);const s=document.createElement("input");s.setAttribute("type","radio"),s.setAttribute("name","payment-option"),s.setAttribute("id",i),s.setAttribute("value",i),o.appendChild(s);const r=document.createElement("span");r.innerText=n,o.appendChild(r),this.element.appendChild(o)}createCardLabel({data:e={}}){return`****${null==e?void 0:e.suffix}`}}class Vn extends m{constructor(e="Authorization failed, please try again."){super("div",{id:"authorization-failed-message"}),this.element.innerText=e,this.element.innerHTML=`\n <div>\n <svg class="checkmark-cross" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">\n <circle class="checkmark-cross_circle" cx="26" cy="26" r="25" fill="none"/>\n <path class="checkmark-cross_check" fill="none" d="M14.1 14.1l23.8 23.8 m0,-23.8 l-23.8,23.8"/>\n </svg>\n </div>\n <div>${e}</div>`,this.element.addEventListener("click",(e=>{e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),this.unmount()}))}}class xn extends m{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 Yn extends m{constructor(e,t,i,n){super("div",{id:e,className:"payrails-dropin-item"}),this.events=i,this.styles=n,this.isActive=!1,this.applyBaseStyles();const o=`payrails-dropin-item-${e}`,s=document.createElement("label");s.setAttribute("for",o);const r=document.createElement("input");r.setAttribute("type","radio"),r.setAttribute("name","payment-option"),r.setAttribute("id",o),r.setAttribute("value",o),this.input=r,s.appendChild(r),this.label=s;const a=document.createElement("span");s.appendChild(a),a.innerText=t,this.element.appendChild(s)}get identifier(){return`payrails-dropin-item-${this.id}`}deactivate(){var e,t;this.isActive&&(this.isActive=!1,this.label.style.marginBottom="0",this.applyBaseStyles(),null===(e=this.component)||void 0===e||e.unmount(),(null===(t=this.events)||void 0===t?void 0:t.onDeactivate)&&this.events.onDeactivate())}applyBaseStyles(){var e,t;Object.keys((null===(e=this.styles)||void 0===e?void 0:e.active)||{}).forEach((e=>{this.element.style.removeProperty(e)})),Object.assign(this.element.style,null===(t=this.styles)||void 0===t?void 0:t.base)}applyActiveStyles(){var e,t;Object.assign(this.element.style,null===(e=this.styles)||void 0===e?void 0:e.base,null===(t=this.styles)||void 0===t?void 0:t.active)}activate(){var e,t;this.isActive||(null===(e=this.component)||void 0===e||e.mount(this.selector),this.label.style.marginBottom="8px",this.applyActiveStyles(),this.isActive=!0,(null===(t=this.events)||void 0===t?void 0:t.onActivate)&&this.events.onActivate())}}class Bn extends Yn{constructor(){super(...arguments),this.buttonShown=!1}activate(){if(!this.buttonShown)return super.activate(),void(this.buttonShown=!0);this.label.style.marginBottom="8px",this.applyActiveStyles(),this.isActive=!0,this.element.querySelector(this.component.selector).style.display="block"}deactivate(){this.isActive&&(this.isActive=!1,this.label.style.marginBottom="0",this.applyBaseStyles(),this.element.querySelector(this.component.selector).style.display="none")}mountAfterAvailable(){super.mount(`#${this.loadElementId}`)}mount(e){const t=document.querySelector(e);if(!t)throw new Error(`Element with selector "${e}" not found in in the DOM`);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 Bn{constructor(e,t,i){var n,o;super("apple-pay-dropin",(null===(o=null===(n=i.translations)||void 0===n?void 0:n.labels)||void 0===o?void 0:o.label)||"Apple Pay",void 0,i.styles),this.loadElementId="apple-pay-dropin-load-element",this.component=new yn(e,t,Object.assign(Object.assign({},i),{events:{onApplePayAvailable:()=>{this.mountAfterAvailable()}}}))}mount(e){const t=document.querySelector(e);if(!t)throw new Error(`Element with selector "${e}" not found in in the DOM`);const i=document.createElement("div");i.setAttribute("id",this.loadElementId),i.setAttribute("style","width: 100%;"),t.appendChild(i)}}class Fn extends Yn{constructor(e,t,i){super("payrails-credit-card-wrapper","Card",void 0,i),this.cardForm=e,this.paymentButton=t,this.cardFormShown=!1,this.component=new jn(e,t)}activate(){var e,t;this.label.style.marginBottom="8px",this.applyActiveStyles(),this.cardFormShown||(this.cardFormShown=!0,null===(e=this.component)||void 0===e||e.mount(this.selector)),this.isActive||(this.paymentButton.selectedInstrument=null,this.paymentButton.mount(this.selector),this.paymentButton.setDisabled(!this.cardForm.isValid),this.paymentButton.mount("#payrails-card-form"),this.input.checked=!0,this.cardForm.show(),this.isActive=!0,(null===(t=this.events)||void 0===t?void 0:t.onActivate)&&this.events.onActivate())}deactivate(){var e;this.isActive&&(this.label.style.marginBottom="0",this.applyBaseStyles(),this.paymentButton.unmount(),this.cardForm.hide(),this.isActive=!1,(null===(e=this.events)||void 0===e?void 0:e.onDeactivate)&&this.events.onDeactivate())}}class jn extends m{constructor(e,t){super("div",{id:"payrails-form-container"}),this.subElements.push(e,t)}}const Xn={apiVersion:2,apiVersionMinor:0};class $n extends Ln{constructor(t,i,n){super("div",Object.assign(Object.assign({},n),{id:"payrails-google-pay-button"})),this.sdkConfig=t,this.execution=i,this.options=n,this.googleButton=null,this.paymentExecutor=new p(t,i),this.loadScript=new On((()=>e(this,void 0,void 0,(function*(){const e=document.createElement("script");return e.src="https://pay.google.com/gp/p/js/pay.js",new Promise(((t,i)=>{e.onload=()=>{const e=new google.payments.api.PaymentsClient({environment:this.options.environment||"TEST"}),n=Object.assign(Object.assign({},Xn),{allowedPaymentMethods:this.execution.googlePayConfig});e.isReadyToPay(n).then((n=>{var o,s,r;n?(null===(r=null===(s=null===(o=this.options)||void 0===o?void 0:o.events)||void 0===s?void 0:s.onGooglePayAvailable)||void 0===r||r.call(s),t(e)):i()}),i)},e.onerror=()=>{i()},document.body.appendChild(e)}))}))))}sdkLoaded(t){var i,n,o,s,r,a,l,d;return e(this,void 0,void 0,(function*(){try{const c=(null===(n=null===(i=this.options)||void 0===i?void 0:i.styles)||void 0===n?void 0:n.buttonColor)||"black",E=(null===(s=null===(o=this.options)||void 0===o?void 0:o.styles)||void 0===s?void 0:s.buttonType)||"long",u=(null===(a=null===(r=this.options)||void 0===r?void 0:r.styles)||void 0===a?void 0:a.buttonSizeMode)||"fill",_=(null===(d=null===(l=this.options)||void 0===l?void 0:l.styles)||void 0===d?void 0:d.buttonLocale)||void 0;return this.googleButton=t.createButton({buttonColor:c,buttonType:E,buttonSizeMode:u,buttonLocale:_,onClick:()=>e(this,void 0,void 0,(function*(){var e,t,i;if(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onPaymentButtonClicked){if(!(yield null===(i=this.options)||void 0===i?void 0:i.events.onPaymentButtonClicked()))return}yield this.onPaymentButtonClicked()})),allowedPaymentMethods:this.execution.googlePayConfig}),this.element.appendChild(this.googleButton),this.googleButton}catch(e){throw console.error("Google pay can not be initialized",e),new Error(e.message)}}))}onLoadPaymentData(t){var i,n,o,s;return e(this,void 0,void 0,(function*(){const e=[{paymentMethodCode:"googlePay",integrationType:"api",paymentInstrumentData:{paymentToken:t.paymentMethodData.tokenizationData.token},amount:this.sdkConfig.amount,storeInstrument:this.shouldStoreInstrument}],r=yield this.paymentExecutor.pay(e);(null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n?void 0:n.onAuthorizeSuccess)&&(null===(s=null===(o=this.options)||void 0===o?void 0:o.events)||void 0===s||s.onAuthorizeSuccess(r))}))}onPaymentButtonClicked(){var t,i,n,o,s;return e(this,void 0,void 0,(function*(){const e=Object.assign({},Xn);e.allowedPaymentMethods=this.execution.googlePayConfig,e.transactionInfo={totalPriceStatus:"FINAL",totalPrice:null===(t=this.sdkConfig.amount)||void 0===t?void 0:t.value,currencyCode:null===(i=this.sdkConfig.amount)||void 0===i?void 0:i.currency,countryCode:null===(s=null===(o=null===(n=this.execution.meta)||void 0===n?void 0:n.customer)||void 0===o?void 0:o.country)||void 0===s?void 0:s.code};(yield this.loadScript.loader).loadPaymentData(e).then((e=>{this.onLoadPaymentData(e)})).catch((e=>{var t,i,n;(null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onAuthorizeFailed)&&(null===(n=this.options)||void 0===n||n.events.onAuthorizeFailed(e))}))}))}mount(t){super.mount(t),(()=>{e(this,void 0,void 0,(function*(){var e;try{const t=yield this.loadScript.loader,i=yield this.sdkLoaded(t);this.element.appendChild(i),null===(e=this.storeInstrumentCheckbox)||void 0===e||e.mount(this.selector)}catch(e){}}))})()}unmount(){var e,t,i;null===(t=null===(e=this.googleButton)||void 0===e?void 0:e.parentElement)||void 0===t||t.removeChild(this.googleButton),null===(i=this.storeInstrumentCheckbox)||void 0===i||i.unmount(),super.unmount()}}class Wn extends Bn{constructor(e,t,i){var n,o;super("google-pay-dropin",(null===(o=null===(n=i.translations)||void 0===n?void 0:n.labels)||void 0===o?void 0:o.label)||"Google Pay",void 0,i.styles),this.loadElementId="google-pay-dropin-load-element",this.component=new $n(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},i.events),{onGooglePayAvailable:()=>{this.mountAfterAvailable()}})}))}mount(e){const t=document.querySelector(e);if(!t)throw new Error(`Element with selector "${e}" not found in in the DOM`);const i=document.createElement("div");i.setAttribute("id",this.loadElementId),i.setAttribute("style","width: 100%;"),t.appendChild(i)}}
|
|
5
5
|
/*!
|
|
6
6
|
* paypal-js v5.1.4 (2022-11-29T23:08:21.847Z)
|
|
7
7
|
* Copyright 2020-present, PayPal, Inc. All rights reserved.
|
|
@@ -17,7 +17,7 @@ Copyright (c) 2022 Skyflow, Inc.
|
|
|
17
17
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
18
|
* See the License for the specific language governing permissions and
|
|
19
19
|
* limitations under the License.
|
|
20
|
-
*/function bo(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseURL&&(t=e.sdkBaseURL,delete e.sdkBaseURL),function(e){var t=e["merchant-id"],i=e["data-merchant-id"],n="",o="";Array.isArray(t)?t.length>1?(n="*",o=t.toString()):n=t.toString():"string"==typeof t&&t.length>0?n=t:"string"==typeof i&&i.length>0&&(n="*",o=i);e["merchant-id"]=n,e["data-merchant-id"]=o}(e);var i=Object.keys(e).filter((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})).reduce((function(t,i){var n=e[i].toString();return"data-"===i.substring(0,5)?t.dataAttributes[i]=n:t.queryParams[i]=n,t}),{queryParams:{},dataAttributes:{}}),n=i.queryParams,o=i.dataAttributes;return{url:"".concat(t,"?").concat(wo(n)),dataAttributes:o}}function wo(e){var t="";return Object.keys(e).forEach((function(i){0!==t.length&&(t+="&"),t+=i+"="+e[i]})),t}function Mo(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 Po(e,t){if(void 0===t&&(t=Uo()),ko(e,t),"undefined"==typeof window)return t.resolve(null);var i=bo(e),n=i.url,o=i.dataAttributes,s=o["data-namespace"]||"paypal",r=Vo(s);return function(e,t){var i=document.querySelector('script[src="'.concat(e,'"]'));if(null===i)return null;var n=Mo(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=Uo());ko(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=Mo(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=Vo(s);if(e)return e;throw new Error("The window.".concat(s," global variable is not available."))}))}function Uo(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function Vo(e){return window[e]}function ko(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}class Yo extends ao{constructor(t,i,n){super("div",Object.assign(Object.assign({},n),{id:"payrails-paypal-button",events:Object.assign(Object.assign({},null==n?void 0:n.events),{onSaveInstrumentCheckboxChanged:t=>e(this,void 0,void 0,(function*(){var e,i,n,o;null===(e=this.button)||void 0===e||e.close(),this.paypalLoader=null,this.paypalLoader=new so(this.loadPaypal.bind(this)),this.button=yield this.paypalLoader.loader,this.button.render(`#${this.buttonWrapperId}`),null===(o=null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n?void 0:n.onSaveInstrumentCheckboxChanged)||void 0===o||o.call(n,t)}))})})),this.sdkConfig=t,this.execution=i,this.options=n,this.paypalLoader=null,this.buttonWrapperId="payrails-paypal-button-wrapper",this.checkboxWrapperId="payrails-paypal-checkbox-wrapper",this.createOneTimeOrder=()=>e(this,void 0,void 0,(function*(){var e,t,i,n,o,s,r;const a=[{paymentMethodCode:"payPal",integrationType:"api",amount:this.sdkConfig.amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!1}],l=yield this.paymentExecutor.pay(a),d=null===(i=null===(t=null===(e=l.response.links.confirm)||void 0===e?void 0:e.action)||void 0===t?void 0:t.parameters)||void 0===i?void 0:i.orderId;if(!d)throw null===(s=null===(o=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===o?void 0:o.onAuthorizeFailed)||void 0===s||s.call(o),new xo("No order id returned");return this.confirmLink=null===(r=l.response.links.confirm)||void 0===r?void 0:r.href,d})),this.element.innerHTML=`<div id="${this.buttonWrapperId}"></div><div id="${this.checkboxWrapperId}"></div>`,this.paymentExecutor=new p(t,i),this.paypalLoader=new so(this.loadPaypal.bind(this)),this.fraudNetGuid=null==n?void 0:n.fraudNetGuid}loadPaypal(){return e(this,void 0,void 0,(function*(){const e=this.execution.paypalConfig,t=this.shouldStoreInstrument?"tokenize":"Instant"===this.execution.paypalConfig.captureMode?"capture":"authorize",i=yield Po({"client-id":e.clientId,components:"buttons,funding-eligibility",intent:t,currency:this.sdkConfig.amount.currency,vault:this.shouldStoreInstrument,"data-namespace":"payrailsPaypal"});if(i){return yield this.createPaypalButton(i)}throw new Error("Paypal not available")}))}createPaypalButton(t){var i,n,o;return e(this,void 0,void 0,(function*(){if(!t.Buttons)throw new Error("Paypal button not available");const e=yield t.Buttons(this.createPayPalButtonConfig());return e.isEligible()?(null===(o=null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n?void 0:n.onPaypalAvailable)||void 0===o||o.call(n),e):null}))}createPayPalButtonConfig(){return this.shouldStoreInstrument?this.createBillingAgreementConfig():this.createOneTimeOrderConfig()}createBillingAgreementConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{onApprove:this.approvePayment.bind(this),createBillingAgreement:()=>e(this,void 0,void 0,(function*(){var e,t,i,n;const o=[{paymentMethodCode:"payPal",integrationType:"api",amount:this.sdkConfig.amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!0}],s=yield this.paymentExecutor.pay(o);return this.confirmLink=null===(e=s.response.links.confirm)||void 0===e?void 0:e.href,(null===(n=null===(i=null===(t=s.response.links.confirm)||void 0===t?void 0:t.action)||void 0===i?void 0:i.parameters)||void 0===n?void 0:n.tokenId)||""}))})}createOneTimeOrderConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{createOrder:this.createOneTimeOrder.bind(this),onApprove:this.approvePayment.bind(this)})}createBaseConfig(){var t,i,n,o,s,r,a,l,d,c;return{fundingSource:"paypal",style:{color:(null===(i=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===i?void 0:i.color)||"gold",height:(null===(o=null===(n=this.options)||void 0===n?void 0:n.styles)||void 0===o?void 0:o.height)||40,label:(null===(r=null===(s=this.options)||void 0===s?void 0:s.styles)||void 0===r?void 0:r.label)||"paypal",shape:(null===(l=null===(a=this.options)||void 0===a?void 0:a.styles)||void 0===l?void 0:l.shape)||"rect",tagline:(null===(c=null===(d=this.options)||void 0===d?void 0:d.styles)||void 0===c?void 0:c.tagline)||!1},onError:e=>{var t,i;(null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onAuthorizeFailed)&&this.options.events.onAuthorizeFailed(e)},onClick:(t,i)=>e(this,void 0,void 0,(function*(){var e,t;if(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onPaymentButtonClicked){return(yield this.options.events.onPaymentButtonClicked())?i.resolve():i.reject()}}))}}approvePayment(t){var i,n,o,s,r,a,l,d,c,E;return e(this,void 0,void 0,(function*(){if(!this.confirmLink)throw null===(o=null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n?void 0:n.onAuthorizeFailed)||void 0===o||o.call(n),new xo("No confirm link");const e={};this.shouldStoreInstrument&&t.billingToken&&(e.tokenId=t.billingToken),this.fraudNetGuid&&(e.riskSessionCorrelationId=this.fraudNetGuid);const _=yield this.paymentExecutor.confirm(this.confirmLink,e);"authorizeSuccessful"===(null===(s=_.finalState)||void 0===s?void 0:s.code)?null===(l=null===(a=null===(r=this.options)||void 0===r?void 0:r.events)||void 0===a?void 0:a.onAuthorizeSuccess)||void 0===l||l.call(a):null===(E=null===(c=null===(d=this.options)||void 0===d?void 0:d.events)||void 0===c?void 0:c.onAuthorizeFailed)||void 0===E||E.call(c)}))}mount(t){super.mount(t),(()=>{e(this,void 0,void 0,(function*(){var e;this.paypalLoader||(this.paypalLoader=new so(this.loadPaypal.bind(this)));const t=yield this.paypalLoader.loader;this.button=t;try{null===(e=this.storeInstrumentCheckbox)||void 0===e||e.mount(`#${this.checkboxWrapperId}`),yield null==t?void 0:t.render(`#${this.buttonWrapperId}`)}catch(e){throw new Bo(e.message)}}))})()}unmount(){var e;null===(e=this.button)||void 0===e||e.close(),this.paypalLoader=null,super.unmount()}}class xo extends Error{constructor(e){super(`PaypalOrderError: ${e}`),this.name="PaypalOrderError"}}class Bo extends Error{constructor(e){super(`PaypalButtonError: ${e}`),this.name="PaypalButtonError"}}class Fo extends Ao{constructor(e,t,i){var n,o;super("payrails-paypal-button-dropin",(null===(o=null===(n=null==i?void 0:i.translations)||void 0===n?void 0:n.labels)||void 0===o?void 0:o.label)||"PayPal",void 0,null==i?void 0:i.styles),this.loadElementId="paypal-dropin-load-element",this.component=new Yo(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},null==i?void 0:i.events),{onPaypalAvailable:()=>{this.mountAfterAvailable()}})}))}}class Go extends mo{constructor(e,t,i,n){var o,s,r;const a=e.paymentMethod===f.PAYPAL?`${null===(o=e.data)||void 0===o?void 0:o.email}`:`${null===(s=e.data)||void 0===s?void 0:s.bin}**${null===(r=e.data)||void 0===r?void 0:r.suffix}`;super(`payrails-payment-instrument-${e.id}`,a,{onActivate:()=>{i(e),this.component.setDisabled(!1)}},n),this.component=t}}class jo extends O{constructor(e,t,i,n,o){var s,r;super("fieldset",{id:"payrails-dropin-component"}),this.collectContainer=e,this.dropinConfig=t,this.execution=i,this.sdkConfig=n,this.returnLinks=o;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=>{var t;if(this.isStoredInstrumentEnabled(e.paymentMethod)){this.cardPaymentButton=this.createCardPaymentButton(null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.cardPaymentButton);const i=this.createStoredInstrumentElement(e);a.set(i.identifier,i)}}));const l={[f.CARD]:this.createCreditCardButton.bind(this),[f.PAYPAL]:this.createPayPalButton.bind(this),[f.GOOGLE_PAY]:this.createGooglePayButton.bind(this),[f.APPLE_PAY]:this.createApplePayButton.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()})),this.subElements.push(...Array.from(a.values()))}createStoredInstrumentElement(e){var t,i;return this.cardPaymentButton=this.createCardPaymentButton(null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.cardPaymentButton),new Go(e,this.cardPaymentButton,(e=>{this.cardPaymentButton&&(this.cardPaymentButton.selectedInstrument=e)}),null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.element)}createCreditCardButton(){var e,t;return this.creditCard=new yo(this.createCardForm(),this.createCardPaymentButton(null===(e=this.dropinConfig.translations)||void 0===e?void 0:e.cardPaymentButton),null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.element),this.creditCard}createGooglePayButton(){var e,t,i,n;return this.googlePay=new Co(this.sdkConfig,this.execution,Object.assign({events:{onAuthorizeSuccess:e=>{var t;if(e)if("authorizeSuccessful"===(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code))this.onAuthorizeSuccess();else this.onAuthorizeFailed()},onAuthorizeFailed:this.onAuthorizeFailed.bind(this),onPaymentButtonClicked:null===(e=this.dropinConfig.events)||void 0===e?void 0:e.onPaymentButtonClicked},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 Fo(this.sdkConfig,this.execution,Object.assign(Object.assign({},null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.payPal),{styles:Object.assign(Object.assign({},null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.paypalButton),null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.element),events:{onAuthorizeSuccess:this.onAuthorizeSuccess.bind(this),onAuthorizeFailed:this.onAuthorizeFailed.bind(this),onSaveInstrumentCheckboxChanged:e=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onSaveInstrumentCheckboxChanged)||void 0===i||i.call(t,e)}}})),this.paypal}createCardForm(){var e,t,i,n;if(!this.cardForm){const o=null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.cards,s=Boolean(null==o?void 0:o.showStoreInstrumentCheckbox),r=Boolean(null==o?void 0:o.showCardHolderName),a=Boolean(null==o?void 0:o.alwaysStoreInstrument);this.cardForm=new fo(this.collectContainer,{showStoreInstrumentCheckbox:s,showCardHolderName:r,alwaysStoreInstrument:a,translations:null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.cardForm,styles:Object.assign(Object.assign({},null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.cardForm),null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.element),events:{onFocus:()=>{var e;null===(e=this.creditCard)||void 0===e||e.activate()},onChange:({isValid:e})=>{var t;null===(t=this.cardPaymentButton)||void 0===t||t.setDisabled(!e)},onSaveInstrumentCheckboxChanged:e=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onSaveInstrumentCheckboxChanged)||void 0===i||i.call(t,e)}}})}return this.cardPaymentButton&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardForm}createApplePayButton(){var e,t,i,n;return this.applePay=new Ro(this.sdkConfig,this.execution,Object.assign(Object.assign({events:{onAuthorizeSuccess:e=>{var t;if(e)if("authorizeSuccessful"===(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code))this.onAuthorizeSuccess();else this.onAuthorizeFailed()},onAuthorizeFailed:this.onAuthorizeFailed.bind(this),onPaymentButtonClicked:null===(e=this.dropinConfig.events)||void 0===e?void 0:e.onPaymentButtonClicked}},null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.applePay),{styles:Object.assign(Object.assign({},null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.applePayButton),null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.element)})),this.applePay}createCardPaymentButton(e){return this.cardPaymentButton||(this.cardPaymentButton=new L(this.sdkConfig,this.execution,{translations:e,events:Object.assign(Object.assign({},this.dropinConfig.events),{onAuthorizeSuccess:this.onAuthorizeSuccess.bind(this),onAuthorizeFailed:this.onAuthorizeFailed.bind(this)})},this.returnLinks)),this.cardForm&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardPaymentButton}onAuthorizeSuccess(){var e,t,i,n;this.subElements.forEach((e=>e.unmount())),new Lo({translations:{label:null===(i=null===(t=null===(e=this.dropinConfig)||void 0===e?void 0:e.translations)||void 0===t?void 0:t.paymentResult)||void 0===i?void 0:i.success}}).mount(this.selector),(null===(n=this.dropinConfig.events)||void 0===n?void 0:n.onAuthorizeSuccess)&&this.dropinConfig.events.onAuthorizeSuccess()}onAuthorizeFailed(e){var t,i,n,o;new Oo(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 f.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 f.PAYPAL:case f.GOOGLE_PAY:case f.APPLE_PAY:return!1!==(null===(r=null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s[e])||void 0===r?void 0:r.showStoredInstruments);default:return!1}}}const Xo=()=>{[["https://js.skyflow.com/v1/elements/index.js","payrails-iframe-js-v1"],["https://js.skyflow.com/v1/elements/index.html","payrails-iframe-html-v1"]].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)}}))},$o={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 Wo{constructor(e,t,i){this.sdkConfig=i,this.bin="",this.id="payrails-container-wrapper",this.containerType="COMPOSABLE",this.cardTableName=t.cardTableName||"cards",this.containerType=t.containerType||"COMPOSABLE",this.__container=e.container(this.containerType,t)}createCollectElement(e){const t={required:!!e.required,enableCardIcon:!1!==e.enableCardIcon},i=this.__container.create(Object.assign(Object.assign({table:this.cardTableName,labelStyles:{},errorTextStyles:{},column:this.elementToFieldMap.get(e.type)},e),{type:e.type===exports.ElementType.CARDHOLDER_NAME?"INPUT_FIELD":e.type}),e.format?Object.assign(Object.assign({},t),{format:e.format}):t);return this.attachCustomEventHandler(i)}mount(e){if("COLLECT"===this.containerType)throw new Error("Collect container cannot be mounted");this.element=document.createElement("span"),this.element.setAttribute("id",this.id);const t=document.querySelector(e);if(!t)throw new Error(`Element with selector ${e} does not exist`);t.appendChild(this.element),window.setTimeout((()=>{this.__container.mount(`#${this.id}`)}),50)}unmount(){this.element&&this.element.remove()}collect(){return e(this,void 0,void 0,(function*(){const{records:e}=yield this.__container.collect(),{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}}))}tokenize(t){return e(this,void 0,void 0,(function*(){const e=yield this.collect(),{instrumentId:i,card_number:n,cardholder_name:o,expiry_month:s,expiry_year:r,security_code:l}=e,d=this.sdkConfig.vaultConfiguration.links.saveInstrument.href,E=this.sdkConfig.token,_=this.sdkConfig.holderReference;if(!d)throw new Error("Save instrument URL not available!");const I=yield(({url:e,token:t,instrumentId:i,holderReference:n,providerId:o,providerConfigId:s,meta:r,storeInstrument:l=!1,futureUsage:d="CardOnFile"})=>c({url:e,token:t,method:a.POST,body:{holderReference:n,storeInstrument:l,futureUsage:d,paymentMethod:"card",token:{providerId:o,providerConfigId:s,reference:i,type:"vault",meta:r}}}))({url:d,token:E,instrumentId:i,holderReference:_,providerId:this.sdkConfig.vaultConfiguration.providerId,providerConfigId:this.sdkConfig.vaultConfiguration.providerConfigId,meta:{skyflow_id:i,card_number:n,cardholder_name:o,expiry_month:s,expiry_year:r,security_code:l},storeInstrument:t.storeInstrument||!1,futureUsage:t.futureUsage||"CardOnFile"});return I.res}))}attachCustomEventHandler(e){return new Proxy(e,{get:(e,t)=>{if("on"!==t)return e[t];return((i,n)=>{e[t].call(e,i,(e=>{"CHANGE"===i?(e.elementType===exports.ElementType.CARD_NUMBER&&(e.network=function(e){for(const[t,i]of Object.entries($o))if(i.test(e))return t;return""}(e.value),e.bin=this.formatBin(e.value),this.bin=this.formatBin(e.value)),n(e)):n(e)}))}).bind(e)}})}formatBin(e){return e.replace(/-|X/g,"")}get elementToFieldMap(){return new Map([[exports.ElementType.CARD_NUMBER,"card_number"],[exports.ElementType.CARDHOLDER_NAME,"cardholder_name"],[exports.ElementType.CVV,"security_code"],[exports.ElementType.EXPIRATION_MONTH,"expiry_month"],[exports.ElementType.EXPIRATION_YEAR,"expiry_year"]])}}class Ko{constructor(e,t,i){this.pageId=e,this.sdkConfig=t,this.environment=i,this.guid=d().replace(/-/g,""),this.fnclsVal="fnparams-dede7cc5-15fd-4c75-a9f4-36c430ee3a99",this.configId=d(),this.scriptId=d(),this.execution=new v(t.execution)}mount(){this.loadFraudnet(this.pageId)}unmount(){var e,t;null===(e=document.getElementById(this.configId))||void 0===e||e.remove(),null===(t=document.getElementById(this.scriptId))||void 0===t||t.remove()}loadFraudnet(e){this.unmount();const t=this.createFraudnetConfig(e);document.body.appendChild(t);const i=document.createElement("script");i.setAttribute("id",this.scriptId),i.src="https://c.paypal.com/da/r/fb.js",document.body.appendChild(i)}get payPalConfig(){return this.execution.paypalConfig}createFraudnetConfig(e){const t=document.createElement("script");return t.setAttribute("type","application/json"),t.setAttribute("fncls",this.fnclsVal),t.setAttribute("id",this.configId),t.innerText=JSON.stringify({f:this.guid,s:`${this.payPalConfig.merchantId}_${e}`,sandbox:"TEST"===this.environment}),t}}
|
|
20
|
+
*/function Kn(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseURL&&(t=e.sdkBaseURL,delete e.sdkBaseURL),function(e){var t=e["merchant-id"],i=e["data-merchant-id"],n="",o="";Array.isArray(t)?t.length>1?(n="*",o=t.toString()):n=t.toString():"string"==typeof t&&t.length>0?n=t:"string"==typeof i&&i.length>0&&(n="*",o=i);e["merchant-id"]=n,e["data-merchant-id"]=o}(e);var i=Object.keys(e).filter((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})).reduce((function(t,i){var n=e[i].toString();return"data-"===i.substring(0,5)?t.dataAttributes[i]=n:t.queryParams[i]=n,t}),{queryParams:{},dataAttributes:{}}),n=i.queryParams,o=i.dataAttributes;return{url:"".concat(t,"?").concat(Hn(n)),dataAttributes:o}}function Hn(e){var t="";return Object.keys(e).forEach((function(i){0!==t.length&&(t+="&"),t+=i+"="+e[i]})),t}function zn(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 qn(e,t){if(void 0===t&&(t=Jn()),Qn(e,t),"undefined"==typeof window)return t.resolve(null);var i=Kn(e),n=i.url,o=i.dataAttributes,s=o["data-namespace"]||"paypal",r=Zn(s);return function(e,t){var i=document.querySelector('script[src="'.concat(e,'"]'));if(null===i)return null;var n=zn(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=Jn());Qn(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=zn(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=Zn(s);if(e)return e;throw new Error("The window.".concat(s," global variable is not available."))}))}function Jn(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function Zn(e){return window[e]}function Qn(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}class eo extends Ln{constructor(t,i,n){super("div",Object.assign(Object.assign({},n),{id:"payrails-paypal-button",events:Object.assign(Object.assign({},null==n?void 0:n.events),{onSaveInstrumentCheckboxChanged:t=>e(this,void 0,void 0,(function*(){var e,i,n,o;null===(e=this.button)||void 0===e||e.close(),this.paypalLoader=null,this.paypalLoader=new On(this.loadPaypal.bind(this)),this.button=yield this.paypalLoader.loader,this.button.render(`#${this.buttonWrapperId}`),null===(o=null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n?void 0:n.onSaveInstrumentCheckboxChanged)||void 0===o||o.call(n,t)}))})})),this.sdkConfig=t,this.execution=i,this.options=n,this.paypalLoader=null,this.buttonWrapperId="payrails-paypal-button-wrapper",this.checkboxWrapperId="payrails-paypal-checkbox-wrapper",this.createOneTimeOrder=()=>e(this,void 0,void 0,(function*(){var e,t,i,n,o,s,r;const a=[{paymentMethodCode:"payPal",integrationType:"api",amount:this.sdkConfig.amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!1}],l=yield this.paymentExecutor.pay(a),d=null===(i=null===(t=null===(e=l.response.links.confirm)||void 0===e?void 0:e.action)||void 0===t?void 0:t.parameters)||void 0===i?void 0:i.orderId;if(!d)throw null===(s=null===(o=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===o?void 0:o.onAuthorizeFailed)||void 0===s||s.call(o),new to("No order id returned");return this.confirmLink=null===(r=l.response.links.confirm)||void 0===r?void 0:r.href,d})),this.element.innerHTML=`<div id="${this.buttonWrapperId}"></div><div id="${this.checkboxWrapperId}"></div>`,this.paymentExecutor=new p(t,i),this.paypalLoader=new On(this.loadPaypal.bind(this)),this.fraudNetGuid=null==n?void 0:n.fraudNetGuid}loadPaypal(){return e(this,void 0,void 0,(function*(){const e=this.execution.paypalConfig,t=this.shouldStoreInstrument?"tokenize":"Instant"===this.execution.paypalConfig.captureMode?"capture":"authorize",i=yield qn({"client-id":e.clientId,components:"buttons,funding-eligibility",intent:t,currency:this.sdkConfig.amount.currency,vault:this.shouldStoreInstrument,"data-namespace":"payrailsPaypal"});if(i){return yield this.createPaypalButton(i)}throw new Error("Paypal not available")}))}createPaypalButton(t){var i,n,o;return e(this,void 0,void 0,(function*(){if(!t.Buttons)throw new Error("Paypal button not available");const e=yield t.Buttons(this.createPayPalButtonConfig());return e.isEligible()?(null===(o=null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n?void 0:n.onPaypalAvailable)||void 0===o||o.call(n),e):null}))}createPayPalButtonConfig(){return this.shouldStoreInstrument?this.createBillingAgreementConfig():this.createOneTimeOrderConfig()}createBillingAgreementConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{onApprove:this.approvePayment.bind(this),createBillingAgreement:()=>e(this,void 0,void 0,(function*(){var e,t,i,n;const o=[{paymentMethodCode:"payPal",integrationType:"api",amount:this.sdkConfig.amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!0}],s=yield this.paymentExecutor.pay(o);return this.confirmLink=null===(e=s.response.links.confirm)||void 0===e?void 0:e.href,(null===(n=null===(i=null===(t=s.response.links.confirm)||void 0===t?void 0:t.action)||void 0===i?void 0:i.parameters)||void 0===n?void 0:n.tokenId)||""}))})}createOneTimeOrderConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{createOrder:this.createOneTimeOrder.bind(this),onApprove:this.approvePayment.bind(this)})}createBaseConfig(){var t,i,n,o,s,r,a,l,d,c;return{fundingSource:"paypal",style:{color:(null===(i=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===i?void 0:i.color)||"gold",height:(null===(o=null===(n=this.options)||void 0===n?void 0:n.styles)||void 0===o?void 0:o.height)||40,label:(null===(r=null===(s=this.options)||void 0===s?void 0:s.styles)||void 0===r?void 0:r.label)||"paypal",shape:(null===(l=null===(a=this.options)||void 0===a?void 0:a.styles)||void 0===l?void 0:l.shape)||"rect",tagline:(null===(c=null===(d=this.options)||void 0===d?void 0:d.styles)||void 0===c?void 0:c.tagline)||!1},onError:e=>{var t,i;(null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onAuthorizeFailed)&&this.options.events.onAuthorizeFailed(e)},onClick:(t,i)=>e(this,void 0,void 0,(function*(){var e,t;if(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onPaymentButtonClicked){return(yield this.options.events.onPaymentButtonClicked())?i.resolve():i.reject()}}))}}approvePayment(t){var i,n,o,s,r,a,l,d,c,E;return e(this,void 0,void 0,(function*(){if(!this.confirmLink)throw null===(o=null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n?void 0:n.onAuthorizeFailed)||void 0===o||o.call(n),new to("No confirm link");const e={};this.shouldStoreInstrument&&t.billingToken&&(e.tokenId=t.billingToken),this.fraudNetGuid&&(e.riskSessionCorrelationId=this.fraudNetGuid);const u=yield this.paymentExecutor.confirm(this.confirmLink,e);"authorizeSuccessful"===(null===(s=u.finalState)||void 0===s?void 0:s.code)?null===(l=null===(a=null===(r=this.options)||void 0===r?void 0:r.events)||void 0===a?void 0:a.onAuthorizeSuccess)||void 0===l||l.call(a):null===(E=null===(c=null===(d=this.options)||void 0===d?void 0:d.events)||void 0===c?void 0:c.onAuthorizeFailed)||void 0===E||E.call(c)}))}mount(t){super.mount(t),(()=>{e(this,void 0,void 0,(function*(){var e;this.paypalLoader||(this.paypalLoader=new On(this.loadPaypal.bind(this)));const t=yield this.paypalLoader.loader;this.button=t;try{null===(e=this.storeInstrumentCheckbox)||void 0===e||e.mount(`#${this.checkboxWrapperId}`),yield null==t?void 0:t.render(`#${this.buttonWrapperId}`)}catch(e){throw new io(e.message)}}))})()}unmount(){var e;null===(e=this.button)||void 0===e||e.close(),this.paypalLoader=null,super.unmount()}}class to extends Error{constructor(e){super(`PaypalOrderError: ${e}`),this.name="PaypalOrderError"}}class io extends Error{constructor(e){super(`PaypalButtonError: ${e}`),this.name="PaypalButtonError"}}class no extends Bn{constructor(e,t,i){var n,o;super("payrails-paypal-button-dropin",(null===(o=null===(n=null==i?void 0:i.translations)||void 0===n?void 0:n.labels)||void 0===o?void 0:o.label)||"PayPal",void 0,null==i?void 0:i.styles),this.loadElementId="paypal-dropin-load-element",this.component=new eo(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},null==i?void 0:i.events),{onPaypalAvailable:()=>{this.mountAfterAvailable()}})}))}}class oo extends Yn{constructor(e,t,i,n){var o,s,r;const a=e.paymentMethod===N.PAYPAL?`${null===(o=e.data)||void 0===o?void 0:o.email}`:`${null===(s=e.data)||void 0===s?void 0:s.bin}**${null===(r=e.data)||void 0===r?void 0:r.suffix}`;super(`payrails-payment-instrument-${e.id}`,a,{onActivate:()=>{i(e),this.component.setDisabled(!1)}},n),this.component=t}}class so extends m{constructor(e,t,i,n,o){var s,r;super("fieldset",{id:"payrails-dropin-component"}),this.collectContainer=e,this.dropinConfig=t,this.execution=i,this.sdkConfig=n,this.returnLinks=o;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=>{var t;if(this.isStoredInstrumentEnabled(e.paymentMethod)){this.cardPaymentButton=this.createCardPaymentButton(null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.cardPaymentButton);const i=this.createStoredInstrumentElement(e);a.set(i.identifier,i)}}));const l={[N.CARD]:this.createCreditCardButton.bind(this),[N.PAYPAL]:this.createPayPalButton.bind(this),[N.GOOGLE_PAY]:this.createGooglePayButton.bind(this),[N.APPLE_PAY]:this.createApplePayButton.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()})),this.subElements.push(...Array.from(a.values()))}createStoredInstrumentElement(e){var t,i;return this.cardPaymentButton=this.createCardPaymentButton(null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.cardPaymentButton),new oo(e,this.cardPaymentButton,(e=>{this.cardPaymentButton&&(this.cardPaymentButton.selectedInstrument=e)}),null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.element)}createCreditCardButton(){var e,t;return this.creditCard=new Fn(this.createCardForm(),this.createCardPaymentButton(null===(e=this.dropinConfig.translations)||void 0===e?void 0:e.cardPaymentButton),null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.element),this.creditCard}createGooglePayButton(){var e,t,i,n;return this.googlePay=new Wn(this.sdkConfig,this.execution,Object.assign({events:{onAuthorizeSuccess:e=>{var t;if(e)if("authorizeSuccessful"===(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code))this.onAuthorizeSuccess();else this.onAuthorizeFailed()},onAuthorizeFailed:this.onAuthorizeFailed.bind(this),onPaymentButtonClicked:null===(e=this.dropinConfig.events)||void 0===e?void 0:e.onPaymentButtonClicked},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 no(this.sdkConfig,this.execution,Object.assign(Object.assign({},null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.payPal),{styles:Object.assign(Object.assign({},null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.paypalButton),null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.element),events:{onAuthorizeSuccess:this.onAuthorizeSuccess.bind(this),onAuthorizeFailed:this.onAuthorizeFailed.bind(this),onSaveInstrumentCheckboxChanged:e=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onSaveInstrumentCheckboxChanged)||void 0===i||i.call(t,e)}}})),this.paypal}createCardForm(){var e,t,i,n;if(!this.cardForm){const o=null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.cards,s=Boolean(null==o?void 0:o.showStoreInstrumentCheckbox),r=Boolean(null==o?void 0:o.showCardHolderName),a=Boolean(null==o?void 0:o.alwaysStoreInstrument);this.cardForm=new 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:{onFocus:()=>{var e;null===(e=this.creditCard)||void 0===e||e.activate()},onChange:({isValid:e})=>{var t;null===(t=this.cardPaymentButton)||void 0===t||t.setDisabled(!e)},onSaveInstrumentCheckboxChanged:e=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onSaveInstrumentCheckboxChanged)||void 0===i||i.call(t,e)}}})}return this.cardPaymentButton&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardForm}createApplePayButton(){var e,t,i,n;return this.applePay=new Gn(this.sdkConfig,this.execution,Object.assign(Object.assign({events:{onAuthorizeSuccess:e=>{var t;if(e)if("authorizeSuccessful"===(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code))this.onAuthorizeSuccess();else this.onAuthorizeFailed()},onAuthorizeFailed:this.onAuthorizeFailed.bind(this),onPaymentButtonClicked:null===(e=this.dropinConfig.events)||void 0===e?void 0:e.onPaymentButtonClicked}},null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.applePay),{styles:Object.assign(Object.assign({},null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.applePayButton),null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.element)})),this.applePay}createCardPaymentButton(e){return this.cardPaymentButton||(this.cardPaymentButton=new O(this.sdkConfig,this.execution,{translations:e,events:Object.assign(Object.assign({},this.dropinConfig.events),{onAuthorizeSuccess:this.onAuthorizeSuccess.bind(this),onAuthorizeFailed:this.onAuthorizeFailed.bind(this)})},this.returnLinks)),this.cardForm&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardPaymentButton}onAuthorizeSuccess(){var e,t,i,n;this.subElements.forEach((e=>e.unmount())),new xn({translations:{label:null===(i=null===(t=null===(e=this.dropinConfig)||void 0===e?void 0:e.translations)||void 0===t?void 0:t.paymentResult)||void 0===i?void 0:i.success}}).mount(this.selector),(null===(n=this.dropinConfig.events)||void 0===n?void 0:n.onAuthorizeSuccess)&&this.dropinConfig.events.onAuthorizeSuccess()}onAuthorizeFailed(e){var t,i,n,o;new Vn(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 N.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 N.PAYPAL:case N.GOOGLE_PAY:case N.APPLE_PAY:return!1!==(null===(r=null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s[e])||void 0===r?void 0:r.showStoredInstruments);default:return!1}}}const ro=()=>{[["https://js.skyflow.com/v1/elements/index.js","payrails-iframe-js-v1"],["https://js.skyflow.com/v1/elements/index.html","payrails-iframe-html-v1"]].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)}}))},ao={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 lo{constructor(e,t,i){this.sdkConfig=i,this.bin="",this.id="payrails-container-wrapper",this.containerType="COMPOSABLE",this.cardTableName=t.cardTableName||"cards",this.containerType=t.containerType||"COMPOSABLE",this.__container=e.container(this.containerType,t)}createCollectElement(e){const t={required:!!e.required,enableCardIcon:!1!==e.enableCardIcon},i=this.__container.create(Object.assign(Object.assign({table:this.cardTableName,labelStyles:{},errorTextStyles:{},column:this.elementToFieldMap.get(e.type)},e),{type:e.type===exports.ElementType.CARDHOLDER_NAME?"INPUT_FIELD":e.type}),e.format?Object.assign(Object.assign({},t),{format:e.format}):t);return this.attachCustomEventHandler(i)}mount(e){if("COLLECT"===this.containerType)throw new Error("Collect container cannot be mounted");this.element=document.createElement("span"),this.element.setAttribute("id",this.id);const t=document.querySelector(e);if(!t)throw new Error(`Element with selector ${e} does not exist`);t.appendChild(this.element),window.setTimeout((()=>{this.__container.mount(`#${this.id}`)}),50)}unmount(){this.element&&this.element.remove()}collect(){return e(this,void 0,void 0,(function*(){return"Payrails"===this.sdkConfig.vaultConfiguration.vaultType?yield this.collectPayrailsData():yield this.collectSkyflowData()}))}collectSkyflowData(){return e(this,void 0,void 0,(function*(){const e=(yield this.__container.collect()).records,{skyflow_id:t,card_number:i,cardholder_name:n,expiry_month:o,expiry_year:s,security_code:r}=e[0].fields;return{instrumentId:t,card_number:i,cardholder_name:n,expiry_month:o,expiry_year:s,security_code:r}}))}collectPayrailsData(){return e(this,void 0,void 0,(function*(){const e=yield this.__container.collect();return Object.assign(Object.assign({},e),{vaultProviderConfigId:this.sdkConfig.vaultConfiguration.providerConfigId})}))}tokenize(t){return e(this,void 0,void 0,(function*(){const e=yield this.collect(),{instrumentId:i,card_number:n,cardholder_name:o,expiry_month:s,expiry_year:r,security_code:l}=e,d=this.sdkConfig.vaultConfiguration.links.saveInstrument.href,E=this.sdkConfig.token,u=this.sdkConfig.holderReference;if(!d)throw new Error("Save instrument URL not available!");const _=yield(({url:e,token:t,instrumentId:i,holderReference:n,providerId:o,providerConfigId:s,meta:r,storeInstrument:l=!1,futureUsage:d="CardOnFile"})=>c({url:e,token:t,method:a.POST,body:{holderReference:n,storeInstrument:l,futureUsage:d,paymentMethod:"card",token:{providerId:o,providerConfigId:s,reference:i,type:"vault",meta:r}}}))({url:d,token:E,instrumentId:i,holderReference:u,providerId:this.sdkConfig.vaultConfiguration.providerId,providerConfigId:this.sdkConfig.vaultConfiguration.providerConfigId,meta:{skyflow_id:i,card_number:n,cardholder_name:o,expiry_month:s,expiry_year:r,security_code:l},storeInstrument:t.storeInstrument||!1,futureUsage:t.futureUsage||"CardOnFile"});return _.res}))}attachCustomEventHandler(e){return new Proxy(e,{get:(e,t)=>{if("on"!==t)return e[t];return((i,n)=>{e[t].call(e,i,(e=>{"CHANGE"===i?(e.elementType===exports.ElementType.CARD_NUMBER&&(e.network=function(e){for(const[t,i]of Object.entries(ao))if(i.test(e))return t;return""}(e.value),e.bin=this.formatBin(e.value),this.bin=this.formatBin(e.value)),n(e)):n(e)}))}).bind(e)}})}formatBin(e){return e.replace(/-|X/g,"")}get elementToFieldMap(){return new Map([[exports.ElementType.CARD_NUMBER,"card_number"],[exports.ElementType.CARDHOLDER_NAME,"cardholder_name"],[exports.ElementType.CVV,"security_code"],[exports.ElementType.EXPIRATION_MONTH,"expiry_month"],[exports.ElementType.EXPIRATION_YEAR,"expiry_year"]])}}class co{constructor(e,t,i){this.pageId=e,this.sdkConfig=t,this.environment=i,this.guid=d().replace(/-/g,""),this.fnclsVal="fnparams-dede7cc5-15fd-4c75-a9f4-36c430ee3a99",this.configId=d(),this.scriptId=d(),this.execution=new v(t.execution)}mount(){this.loadFraudnet(this.pageId)}unmount(){var e,t;null===(e=document.getElementById(this.configId))||void 0===e||e.remove(),null===(t=document.getElementById(this.scriptId))||void 0===t||t.remove()}loadFraudnet(e){this.unmount();const t=this.createFraudnetConfig(e);document.body.appendChild(t);const i=document.createElement("script");i.setAttribute("id",this.scriptId),i.src="https://c.paypal.com/da/r/fb.js",document.body.appendChild(i)}get payPalConfig(){return this.execution.paypalConfig}createFraudnetConfig(e){const t=document.createElement("script");return t.setAttribute("type","application/json"),t.setAttribute("fncls",this.fnclsVal),t.setAttribute("id",this.configId),t.innerText=JSON.stringify({f:this.guid,s:`${this.payPalConfig.merchantId}_${e}`,sandbox:"TEST"===this.environment}),t}}
|
|
21
21
|
/* @copyright
|
|
22
22
|
Copyright (c) 2023 Payrails (https://www.payrails.com/)
|
|
23
|
-
*/class
|
|
23
|
+
*/class Eo{static init(e,t){const i=JSON.parse(atob(e.data)),{vaultConfiguration:{vaultId:n,vaultUrl:o,token:s},execution:r}=i,a=mn.init({vaultID:n,vaultURL:o,getBearerToken:()=>Promise.resolve(s),options:{initResponse:e,deserializedData:i}}),l=new v(r);return l.isPaymentMethodAvailable(N.CARD)&&ro(),new Eo(i,a,l,t)}update(e){this.sdkConfiguration.amount=e}collectContainer(e){if("COMPOSABLE"===e.containerType&&!e.layout)throw new Error("Layout configuration is required");return this.__container=new lo(this.vaultClient,Object.assign(Object.assign({},e),{cardTableName:this.sdkConfiguration.vaultConfiguration.cardTableName}),this.sdkConfiguration),this.__container}googlePayButton(e){var t;if(!this.execution)throw new Error("SDK was not initialized with workflow execution");return new $n(this.sdkConfiguration,this.execution,Object.assign({environment:null===(t=this.options)||void 0===t?void 0:t.environment},e))}applePayButton(e){if(!this.execution)throw new Error("SDK was not initialized with workflow execution");return new yn(this.sdkConfiguration,this.execution,e)}cardList(e){return this.__cardList||(this.__cardList=new Un(this.execution,{onCardChange:t=>{this.__cardPaymentButton&&(this.__cardPaymentButton.selectedInstrument=t,this.__cardPaymentButton.setDisabled(!1)),null==e||e.onCardChange(t)}})),this.__cardList}cardForm(e){var t,i;if(!this.__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 Pn(this.__container,Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},null==e?void 0:e.events),{onChange:t=>{var i;this.__cardPaymentButton&&(this.__cardPaymentButton.selectedInstrument=null,this.__cardForm&&this.__cardPaymentButton.setDisabled(!this.__cardForm.isValid)),(null===(i=null==e?void 0:e.events)||void 0===i?void 0:i.onChange)&&e.events.onChange(t)},onFocus:()=>{var t;this.__cardList&&this.__cardList.reset(),this.__cardPaymentButton&&(this.__cardPaymentButton.selectedInstrument=null,this.__cardForm&&this.__cardPaymentButton.setDisabled(!this.__cardForm.isValid)),(null===(t=null==e?void 0:e.events)||void 0===t?void 0:t.onFocus)&&e.events.onFocus()}})}))}return this.__cardPaymentButton&&this.__cardPaymentButton.setCardForm(this.__cardForm),this.__cardForm}dropin(e){var t,i,n;const o=this.getContainerLayout(null===(i=null===(t=e.paymentMethodsConfiguration)||void 0===t?void 0:t.cards)||void 0===i?void 0:i.showCardHolderName);return this.__container=this.collectContainer({layout:o,errorTextStyles:{base:{display:"none"}}}),new so(this.__container,e,this.execution,this.sdkConfiguration,(null===(n=this.options)||void 0===n?void 0:n.returnLinks)||{})}getSavedCreditCards(){return this.execution.savedCreditCards}paymentButton(e){var t;return this.__cardPaymentButton||(this.__cardPaymentButton=new O(this.sdkConfiguration,this.execution,e,(null===(t=this.options)||void 0===t?void 0:t.returnLinks)||{})),this.__cardPaymentButton.setDisabled(!0),this.__cardForm&&this.__cardPaymentButton.setCardForm(this.__cardForm),this.__cardPaymentButton}paypalButton(e){var t;return this.__paypalButton=new eo(this.sdkConfiguration,this.execution,Object.assign(Object.assign({},e),{fraudNetGuid:(null==e?void 0:e.fraudNetGuid)||(null===(t=this.__fraudNet)||void 0===t?void 0:t.guid)})),this.__paypalButton}getSavedPaypalAccounts(){return this.execution.savedPaypalAccounts||[]}fraudNet(e){var t;return this.__fraudNet||(this.__fraudNet=new co(e,this.sdkConfiguration,(null===(t=this.options)||void 0===t?void 0:t.environment)||"TEST")),this.__paypalButton&&(this.__paypalButton.fraudNetGuid=this.__fraudNet.guid),this.__fraudNet}constructor(e,t,i,n){var o;this.sdkConfiguration=e,this.vaultClient=t,this.execution=i,this.options=n,(null===(o=null==n?void 0:n.events)||void 0===o?void 0:o.onClientInitialized)&&n.events.onClientInitialized(this.execution)}getContainerLayout(e){return e?[1,1,3]:[1,3]}}Eo.preloadCardForm=ro,exports.Payrails=Eo}();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payrails/web-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-RC.1",
|
|
4
4
|
"description": "SDK providing tokenization options on the client for merchants",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "payrails.d.ts",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"author": "Petr Prchal <petr@payrails.com>",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
|
+
"@payrails/web-cse": "1.2.2-RC.1",
|
|
12
13
|
"@types/applepayjs": "3.0.4",
|
|
13
14
|
"@types/googlepay": "0.7.1"
|
|
14
15
|
}
|
package/payrails.d.ts
CHANGED
|
@@ -37,8 +37,7 @@ declare enum ElementType$1 {
|
|
|
37
37
|
INPUT_FIELD = "INPUT_FIELD",
|
|
38
38
|
PIN = "PIN",
|
|
39
39
|
EXPIRATION_MONTH = "EXPIRATION_MONTH",
|
|
40
|
-
EXPIRATION_YEAR = "EXPIRATION_YEAR"
|
|
41
|
-
FILE_INPUT = "FILE_INPUT"
|
|
40
|
+
EXPIRATION_YEAR = "EXPIRATION_YEAR"
|
|
42
41
|
}
|
|
43
42
|
|
|
44
43
|
declare enum RedactionType {
|
|
@@ -84,20 +83,9 @@ interface IInsertRecord {
|
|
|
84
83
|
fields: Record<string, any>;
|
|
85
84
|
skyflowID?: string;
|
|
86
85
|
}
|
|
87
|
-
interface IRevealRecord {
|
|
88
|
-
token: string;
|
|
89
|
-
redaction?: RedactionType;
|
|
90
|
-
}
|
|
91
|
-
interface IRevealResponseType {
|
|
92
|
-
records?: Record<string, string>[];
|
|
93
|
-
errors?: Record<string, any>[];
|
|
94
|
-
}
|
|
95
|
-
interface IDetokenizeInput {
|
|
96
|
-
records: IRevealRecord[];
|
|
97
|
-
}
|
|
98
86
|
interface IGetRecord {
|
|
99
87
|
ids?: string[];
|
|
100
|
-
redaction
|
|
88
|
+
redaction?: RedactionType;
|
|
101
89
|
table: string;
|
|
102
90
|
columnName?: string;
|
|
103
91
|
columnValues?: string[];
|
|
@@ -105,6 +93,9 @@ interface IGetRecord {
|
|
|
105
93
|
interface IGetInput {
|
|
106
94
|
records: IGetRecord[];
|
|
107
95
|
}
|
|
96
|
+
interface IGetOptions {
|
|
97
|
+
tokens?: boolean;
|
|
98
|
+
}
|
|
108
99
|
interface ISkyflowIdRecord {
|
|
109
100
|
ids: string[];
|
|
110
101
|
redaction: RedactionType;
|
|
@@ -225,7 +216,6 @@ declare class CollectContainer extends Container {
|
|
|
225
216
|
constructor(options: any, metaData: any, skyflowElements: any, context: any);
|
|
226
217
|
create: (input: CollectElementInput$1, options?: any) => CollectElement;
|
|
227
218
|
collect: (options?: ICollectOptions$1) => Promise<unknown>;
|
|
228
|
-
uploadFiles: (options: any) => Promise<unknown>;
|
|
229
219
|
}
|
|
230
220
|
|
|
231
221
|
declare class ComposableElement {
|
|
@@ -265,49 +255,8 @@ declare class ComposableContainer extends Container {
|
|
|
265
255
|
collect: (options?: ICollectOptions) => Promise<unknown>;
|
|
266
256
|
}
|
|
267
257
|
|
|
268
|
-
declare class RevealElement extends SkyflowElement {
|
|
269
|
-
#private;
|
|
270
|
-
constructor(record: IRevealElementInput, options: IRevealElementOptions | undefined, metaData: any, container: any, elementId: string, context: Context);
|
|
271
|
-
getID(): string;
|
|
272
|
-
mount(domElementSelector: any): void;
|
|
273
|
-
iframeName(): string;
|
|
274
|
-
isMounted(): boolean;
|
|
275
|
-
hasToken(): boolean;
|
|
276
|
-
isClientSetError(): boolean;
|
|
277
|
-
getRecordData(): any;
|
|
278
|
-
setError(clientErrorText: string): void;
|
|
279
|
-
resetError(): void;
|
|
280
|
-
setAltText(altText: string): void;
|
|
281
|
-
clearAltText(): void;
|
|
282
|
-
setToken(token: string): void;
|
|
283
|
-
unmount(): void;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
interface IRevealElementInput {
|
|
287
|
-
token?: string;
|
|
288
|
-
redaction?: RedactionType;
|
|
289
|
-
inputStyles?: object;
|
|
290
|
-
label?: string;
|
|
291
|
-
labelStyles?: object;
|
|
292
|
-
altText?: string;
|
|
293
|
-
errorTextStyles?: object;
|
|
294
|
-
}
|
|
295
|
-
interface IRevealElementOptions {
|
|
296
|
-
enableCopy?: boolean;
|
|
297
|
-
format?: string;
|
|
298
|
-
translation?: Record<string, string>;
|
|
299
|
-
}
|
|
300
|
-
declare class RevealContainer extends Container {
|
|
301
|
-
#private;
|
|
302
|
-
type: string;
|
|
303
|
-
constructor(metaData: any, skyflowElements: any, context: any);
|
|
304
|
-
create(record: IRevealElementInput, options?: IRevealElementOptions): RevealElement;
|
|
305
|
-
reveal(): Promise<unknown>;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
258
|
declare enum ContainerType {
|
|
309
259
|
COLLECT = "COLLECT",
|
|
310
|
-
REVEAL = "REVEAL",
|
|
311
260
|
COMPOSABLE = "COMPOSABLE"
|
|
312
261
|
}
|
|
313
262
|
interface ISkyflow {
|
|
@@ -320,12 +269,11 @@ declare class Skyflow {
|
|
|
320
269
|
#private;
|
|
321
270
|
constructor(config: ISkyflow);
|
|
322
271
|
static init(config: ISkyflow): Skyflow;
|
|
323
|
-
container(type: ContainerType, options?: Record<string, any>):
|
|
324
|
-
insert(records: IInsertRecordInput, options
|
|
325
|
-
detokenize(detokenizeInput: IDetokenizeInput): Promise<IRevealResponseType>;
|
|
272
|
+
container(type: ContainerType, options?: Record<string, any>): CollectContainer | ComposableContainer;
|
|
273
|
+
insert(records: IInsertRecordInput, options?: IInsertOptions): Promise<any>;
|
|
326
274
|
getById(getByIdInput: IGetByIdInput): Promise<unknown>;
|
|
327
|
-
get(getInput: IGetInput): Promise<unknown>;
|
|
328
|
-
delete(records: IDeleteRecordInput, options
|
|
275
|
+
get(getInput: IGetInput, options?: IGetOptions): Promise<unknown>;
|
|
276
|
+
delete(records: IDeleteRecordInput, options?: IDeleteOptions): Promise<unknown>;
|
|
329
277
|
static get ContainerType(): typeof ContainerType;
|
|
330
278
|
static get ElementType(): typeof ElementType$1;
|
|
331
279
|
static get RedactionType(): typeof RedactionType;
|
|
@@ -418,7 +366,7 @@ declare class WorkflowExecution {
|
|
|
418
366
|
};
|
|
419
367
|
get availablePaymentMethods(): StorablePaymentCompositionOption<CardMetadata | PayPalMetadata, ApplePayConfig | PayPalConfig | GooglePayConfig | undefined>[];
|
|
420
368
|
get authorizeLink(): string | undefined;
|
|
421
|
-
get createSessionLink(): string;
|
|
369
|
+
get createSessionLink(): string | undefined;
|
|
422
370
|
get storedPaymentInstruments(): StoredPaymentInstrument<PayPalMetadata & CardMetadata>[];
|
|
423
371
|
private getStoredInstrumentForPaymentMethod;
|
|
424
372
|
}
|
|
@@ -455,7 +403,7 @@ interface WorkflowExecutionResponse {
|
|
|
455
403
|
};
|
|
456
404
|
}>;
|
|
457
405
|
links: {
|
|
458
|
-
startPaymentSession
|
|
406
|
+
startPaymentSession?: {
|
|
459
407
|
href: string;
|
|
460
408
|
method: 'POST';
|
|
461
409
|
};
|
|
@@ -652,17 +600,11 @@ declare class CardForm extends PayrailsElementWithStoreInstrumentCheckbox {
|
|
|
652
600
|
get cardNetwork(): "" | "visa" | "mastercard" | "amex" | "diners" | "discover" | "jcb" | "hipercard" | "unionpay" | "maestro";
|
|
653
601
|
onChange(): void;
|
|
654
602
|
collectValues(): Promise<{
|
|
655
|
-
|
|
656
|
-
instrumentId: string;
|
|
657
|
-
card_number: string | undefined;
|
|
658
|
-
cardholder_name: string | undefined;
|
|
659
|
-
expiry_month: string | undefined;
|
|
660
|
-
expiry_year: string | undefined;
|
|
661
|
-
security_code: string;
|
|
662
|
-
};
|
|
603
|
+
cardData: EncryptedCollectResult | TokenizedCollectResult;
|
|
663
604
|
storeInstrument: boolean;
|
|
664
605
|
enrollInstrumentToNetworkOffers: boolean;
|
|
665
606
|
}>;
|
|
607
|
+
private enforceEnrollInstrumentToNetworkOffersForMasterCard;
|
|
666
608
|
}
|
|
667
609
|
interface LabelStyles {
|
|
668
610
|
base?: Partial<CSSStyleDeclaration>;
|
|
@@ -726,9 +668,10 @@ declare class CardPaymentButton extends PayrailsElement {
|
|
|
726
668
|
triggerLoading(isLoading: boolean): void;
|
|
727
669
|
private onAuthorizationFailed;
|
|
728
670
|
private onPay;
|
|
671
|
+
private constructTokenizedPayment;
|
|
672
|
+
private constructEncryptedPayment;
|
|
729
673
|
private handleAuthorizationResult;
|
|
730
674
|
private handle3ds;
|
|
731
|
-
private collectCardFormValues;
|
|
732
675
|
}
|
|
733
676
|
declare enum AuthorizationFailureReasons {
|
|
734
677
|
VALIDATION_FAILED = "VALIDATION_FAILED",
|
|
@@ -974,6 +917,7 @@ interface SdkConfiguration {
|
|
|
974
917
|
vaultUrl: string;
|
|
975
918
|
providerId: string;
|
|
976
919
|
providerConfigId: string;
|
|
920
|
+
vaultType: 'Skyflow' | 'Payrails' | 'Test';
|
|
977
921
|
links: {
|
|
978
922
|
saveInstrument: {
|
|
979
923
|
href: string;
|
|
@@ -987,6 +931,19 @@ interface PayrailsAmount {
|
|
|
987
931
|
currency: string;
|
|
988
932
|
}
|
|
989
933
|
|
|
934
|
+
type TokenizedCollectResult = {
|
|
935
|
+
skyflow_id?: string;
|
|
936
|
+
card_number?: string;
|
|
937
|
+
cardholder_name?: string;
|
|
938
|
+
expiry_month?: string;
|
|
939
|
+
expiry_year?: string;
|
|
940
|
+
security_code: string;
|
|
941
|
+
instrumentId?: string;
|
|
942
|
+
};
|
|
943
|
+
interface EncryptedCollectResult {
|
|
944
|
+
vaultProviderConfigId: string;
|
|
945
|
+
encryptedInstrumentDetails: string;
|
|
946
|
+
}
|
|
990
947
|
interface CollectElementOptions {
|
|
991
948
|
type: ElementType;
|
|
992
949
|
label?: string;
|
|
@@ -1041,14 +998,9 @@ declare class PayrailsCollectContainer implements Mountable {
|
|
|
1041
998
|
createCollectElement(options: CollectElementOptions): PayrailsSecureField;
|
|
1042
999
|
mount(selector: string): void;
|
|
1043
1000
|
unmount(): void;
|
|
1044
|
-
collect(): Promise<
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
cardholder_name: string | undefined;
|
|
1048
|
-
expiry_month: string | undefined;
|
|
1049
|
-
expiry_year: string | undefined;
|
|
1050
|
-
security_code: string;
|
|
1051
|
-
}>;
|
|
1001
|
+
collect(): Promise<EncryptedCollectResult | TokenizedCollectResult>;
|
|
1002
|
+
private collectSkyflowData;
|
|
1003
|
+
private collectPayrailsData;
|
|
1052
1004
|
tokenize(opts: TokenizeOptions): Promise<SaveInstrumentResponse>;
|
|
1053
1005
|
private attachCustomEventHandler;
|
|
1054
1006
|
private formatBin;
|