@easypaypt/checkout-sdk
Version:
SDK for easypay's Checkout
3 lines (2 loc) • 23.5 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).easypayCheckout={})}(this,(function(t){"use strict";var e=function(){return e=Object.assign||function(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var i in e=arguments[o])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},e.apply(this,arguments)},o=window.CustomEvent;function n(t,e){var o="on"+e.type.toLowerCase();return"function"==typeof t[o]&&t[o](e),t.dispatchEvent(e)}function i(t){for(;t;){if("dialog"===t.localName)return t;t=t.parentElement?t.parentElement:t.parentNode?t.parentNode.host:null}return null}function r(t){for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;t&&t.blur&&t!==document.body&&t.blur()}function a(t,e){for(var o=0;o<t.length;++o)if(t[o]===e)return!0;return!1}function s(t){return!(!t||!t.hasAttribute("method"))&&"dialog"===t.getAttribute("method").toLowerCase()}function l(t){var e=["button","input","keygen","select","textarea"].map((function(t){return t+":not([disabled])"}));e.push('[tabindex]:not([disabled]):not([tabindex=""])');var o=t.querySelector(e.join(", "));if(!o&&"attachShadow"in Element.prototype)for(var n=t.querySelectorAll("*"),i=0;i<n.length&&!(n[i].tagName&&n[i].shadowRoot&&(o=l(n[i].shadowRoot)));i++);return o}function d(t){return t.isConnected||document.body.contains(t)}function c(t){if(t.submitter)return t.submitter;var e=t.target;if(!(e instanceof HTMLFormElement))return null;var o=p.formSubmitter;if(!o){var n=t.target;o=("getRootNode"in n&&n.getRootNode()||document).activeElement}return o&&o.form===e?o:null}function u(t){if(!t.defaultPrevented){var e=t.target,o=p.imagemapUseValue,n=c(t);null===o&&n&&(o=n.value);var r=i(e);if(r)"dialog"===(n&&n.getAttribute("formmethod")||e.getAttribute("method"))&&(t.preventDefault(),null!=o?r.close(o):r.close())}}function h(t){if(this.dialog_=t,this.replacedStyleTop_=!1,this.openAsModal_=!1,t.hasAttribute("role")||t.setAttribute("role","dialog"),t.show=this.show.bind(this),t.showModal=this.showModal.bind(this),t.close=this.close.bind(this),t.addEventListener("submit",u,!1),"returnValue"in t||(t.returnValue=""),"MutationObserver"in window){new MutationObserver(this.maybeHideModal.bind(this)).observe(t,{attributes:!0,attributeFilter:["open"]})}else{var e,o=!1,n=function(){o?this.downgradeModal():this.maybeHideModal(),o=!1}.bind(this),i=function(i){if(i.target===t){var r="DOMNodeRemoved";o|=i.type.substr(0,r.length)===r,window.clearTimeout(e),e=window.setTimeout(n,0)}};["DOMAttrModified","DOMNodeRemoved","DOMNodeRemovedFromDocument"].forEach((function(e){t.addEventListener(e,i)}))}Object.defineProperty(t,"open",{set:this.setOpen.bind(this),get:t.hasAttribute.bind(t,"open")}),this.backdrop_=document.createElement("div"),this.backdrop_.className="backdrop",this.backdrop_.addEventListener("mouseup",this.backdropMouseEvent_.bind(this)),this.backdrop_.addEventListener("mousedown",this.backdropMouseEvent_.bind(this)),this.backdrop_.addEventListener("click",this.backdropMouseEvent_.bind(this))}o&&"object"!=typeof o||((o=function(t,e){e=e||{};var o=document.createEvent("CustomEvent");return o.initCustomEvent(t,!!e.bubbles,!!e.cancelable,e.detail||null),o}).prototype=window.Event.prototype),h.prototype={get dialog(){return this.dialog_},maybeHideModal:function(){this.dialog_.hasAttribute("open")&&d(this.dialog_)||this.downgradeModal()},downgradeModal:function(){this.openAsModal_&&(this.openAsModal_=!1,this.dialog_.style.zIndex="",this.replacedStyleTop_&&(this.dialog_.style.top="",this.replacedStyleTop_=!1),this.backdrop_.parentNode&&this.backdrop_.parentNode.removeChild(this.backdrop_),p.dm.removeDialog(this))},setOpen:function(t){t?this.dialog_.hasAttribute("open")||this.dialog_.setAttribute("open",""):(this.dialog_.removeAttribute("open"),this.maybeHideModal())},backdropMouseEvent_:function(t){if(this.dialog_.hasAttribute("tabindex"))this.dialog_.focus();else{var e=document.createElement("div");this.dialog_.insertBefore(e,this.dialog_.firstChild),e.tabIndex=-1,e.focus(),this.dialog_.removeChild(e)}var o=document.createEvent("MouseEvents");o.initMouseEvent(t.type,t.bubbles,t.cancelable,window,t.detail,t.screenX,t.screenY,t.clientX,t.clientY,t.ctrlKey,t.altKey,t.shiftKey,t.metaKey,t.button,t.relatedTarget),this.dialog_.dispatchEvent(o),t.stopPropagation()},focus_:function(){var t=this.dialog_.querySelector("[autofocus]:not([disabled])");!t&&this.dialog_.tabIndex>=0&&(t=this.dialog_),t||(t=l(this.dialog_)),r(document.activeElement),t&&t.focus()},updateZIndex:function(t,e){if(t<e)throw new Error("dialogZ should never be < backdropZ");this.dialog_.style.zIndex=t,this.backdrop_.style.zIndex=e},show:function(){this.dialog_.open||(this.setOpen(!0),this.focus_())},showModal:function(){if(this.dialog_.hasAttribute("open"))throw new Error("Failed to execute 'showModal' on dialog: The element is already open, and therefore cannot be opened modally.");if(!d(this.dialog_))throw new Error("Failed to execute 'showModal' on dialog: The element is not in a Document.");if(!p.dm.pushDialog(this))throw new Error("Failed to execute 'showModal' on dialog: There are too many open modal dialogs.");(function(t){for(;t&&t!==document.body;){var e=window.getComputedStyle(t),o=function(t,o){return!(void 0===e[t]||e[t]===o)};if(e.opacity<1||o("zIndex","auto")||o("transform","none")||o("mixBlendMode","normal")||o("filter","none")||o("perspective","none")||"isolate"===e.isolation||"fixed"===e.position||"touch"===e.webkitOverflowScrolling)return!0;t=t.parentElement}return!1})(this.dialog_.parentElement)&&console.warn("A dialog is being shown inside a stacking context. This may cause it to be unusable. For more information, see this link: https://github.com/GoogleChrome/dialog-polyfill/#stacking-context"),this.setOpen(!0),this.openAsModal_=!0,p.needsCentering(this.dialog_)?(p.reposition(this.dialog_),this.replacedStyleTop_=!0):this.replacedStyleTop_=!1,this.dialog_.parentNode.insertBefore(this.backdrop_,this.dialog_.nextSibling),this.focus_()},close:function(t){if(!this.dialog_.hasAttribute("open"))throw new Error("Failed to execute 'close' on dialog: The element does not have an 'open' attribute, and therefore cannot be closed.");this.setOpen(!1),void 0!==t&&(this.dialog_.returnValue=t);var e=new o("close",{bubbles:!1,cancelable:!1});n(this.dialog_,e)}};var p={reposition:function(t){var e=document.body.scrollTop||document.documentElement.scrollTop,o=e+(window.innerHeight-t.offsetHeight)/2;t.style.top=Math.max(e,o)+"px"},isInlinePositionSetByStylesheet:function(t){for(var e=0;e<document.styleSheets.length;++e){var o=document.styleSheets[e],n=null;try{n=o.cssRules}catch(t){}if(n)for(var i=0;i<n.length;++i){var r=n[i],s=null;try{s=document.querySelectorAll(r.selectorText)}catch(t){}if(s&&a(s,t)){var l=r.style.getPropertyValue("top"),d=r.style.getPropertyValue("bottom");if(l&&"auto"!==l||d&&"auto"!==d)return!0}}}return!1},needsCentering:function(t){return"absolute"===window.getComputedStyle(t).position&&(!("auto"!==t.style.top&&""!==t.style.top||"auto"!==t.style.bottom&&""!==t.style.bottom)&&!p.isInlinePositionSetByStylesheet(t))},forceRegisterDialog:function(t){if((window.HTMLDialogElement||t.showModal)&&console.warn("This browser already supports <dialog>, the polyfill may not work correctly",t),"dialog"!==t.localName)throw new Error("Failed to register dialog: The element is not a dialog.");new h(t)},registerDialog:function(t){t.showModal||p.forceRegisterDialog(t)},DialogManager:function(){this.pendingDialogStack=[];var t=this.checkDOM_.bind(this);this.overlay=document.createElement("div"),this.overlay.className="_dialog_overlay",this.overlay.addEventListener("click",function(e){this.forwardTab_=void 0,e.stopPropagation(),t([])}.bind(this)),this.handleKey_=this.handleKey_.bind(this),this.handleFocus_=this.handleFocus_.bind(this),this.zIndexLow_=1e5,this.zIndexHigh_=100150,this.forwardTab_=void 0,"MutationObserver"in window&&(this.mo_=new MutationObserver((function(e){var o=[];e.forEach((function(t){for(var e,n=0;e=t.removedNodes[n];++n)e instanceof Element&&("dialog"===e.localName&&o.push(e),o=o.concat(e.querySelectorAll("dialog")))})),o.length&&t(o)})))}};if(p.DialogManager.prototype.blockDocument=function(){document.documentElement.addEventListener("focus",this.handleFocus_,!0),document.addEventListener("keydown",this.handleKey_),this.mo_&&this.mo_.observe(document,{childList:!0,subtree:!0})},p.DialogManager.prototype.unblockDocument=function(){document.documentElement.removeEventListener("focus",this.handleFocus_,!0),document.removeEventListener("keydown",this.handleKey_),this.mo_&&this.mo_.disconnect()},p.DialogManager.prototype.updateStacking=function(){for(var t,e=this.zIndexHigh_,o=0;t=this.pendingDialogStack[o];++o)t.updateZIndex(--e,--e),0===o&&(this.overlay.style.zIndex=--e);var n=this.pendingDialogStack[0];n?(n.dialog.parentNode||document.body).appendChild(this.overlay):this.overlay.parentNode&&this.overlay.parentNode.removeChild(this.overlay)},p.DialogManager.prototype.containedByTopDialog_=function(t){for(;t=i(t);){for(var e,o=0;e=this.pendingDialogStack[o];++o)if(e.dialog===t)return 0===o;t=t.parentElement}return!1},p.DialogManager.prototype.handleFocus_=function(t){var e=t.composedPath?t.composedPath()[0]:t.target;if(!this.containedByTopDialog_(e)&&document.activeElement!==document.documentElement&&(t.preventDefault(),t.stopPropagation(),r(e),void 0!==this.forwardTab_)){var o=this.pendingDialogStack[0];return o.dialog.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING&&(this.forwardTab_?o.focus_():e!==document.documentElement&&document.documentElement.focus()),!1}},p.DialogManager.prototype.handleKey_=function(t){if(this.forwardTab_=void 0,27===t.keyCode){t.preventDefault(),t.stopPropagation();var e=new o("cancel",{bubbles:!1,cancelable:!0}),i=this.pendingDialogStack[0];i&&n(i.dialog,e)&&i.dialog.close()}else 9===t.keyCode&&(this.forwardTab_=!t.shiftKey)},p.DialogManager.prototype.checkDOM_=function(t){this.pendingDialogStack.slice().forEach((function(e){-1!==t.indexOf(e.dialog)?e.downgradeModal():e.maybeHideModal()}))},p.DialogManager.prototype.pushDialog=function(t){var e=(this.zIndexHigh_-this.zIndexLow_)/2-1;return!(this.pendingDialogStack.length>=e)&&(1===this.pendingDialogStack.unshift(t)&&this.blockDocument(),this.updateStacking(),!0)},p.DialogManager.prototype.removeDialog=function(t){var e=this.pendingDialogStack.indexOf(t);-1!==e&&(this.pendingDialogStack.splice(e,1),0===this.pendingDialogStack.length&&this.unblockDocument(),this.updateStacking())},p.dm=new p.DialogManager,p.formSubmitter=null,p.imagemapUseValue=null,void 0===window.HTMLDialogElement){var g=document.createElement("form");if(g.setAttribute("method","dialog"),"dialog"!==g.method){var m=Object.getOwnPropertyDescriptor(HTMLFormElement.prototype,"method");if(m){var f=m.get;m.get=function(){return s(this)?"dialog":f.call(this)};var b=m.set;m.set=function(t){return"string"==typeof t&&"dialog"===t.toLowerCase()?this.setAttribute("method",t):b.call(this,t)},Object.defineProperty(HTMLFormElement.prototype,"method",m)}}document.addEventListener("click",(function(t){if(p.formSubmitter=null,p.imagemapUseValue=null,!t.defaultPrevented){var e=t.target;if("composedPath"in t)e=t.composedPath().shift()||e;if(e&&s(e.form)){if(!("submit"===e.type&&["button","input"].indexOf(e.localName)>-1)){if("input"!==e.localName||"image"!==e.type)return;p.imagemapUseValue=t.offsetX+","+t.offsetY}i(e)&&(p.formSubmitter=e)}}}),!1),document.addEventListener("submit",(function(t){var e=t.target;if(!i(e)){var o=c(t);"dialog"===(o&&o.getAttribute("formmethod")||e.getAttribute("method"))&&t.preventDefault()}}));var y=HTMLFormElement.prototype.submit;HTMLFormElement.prototype.submit=function(){if(!s(this))return y.call(this);var t=i(this);t&&t.close()}}var v={id:"easypay-checkout",onSuccess:function(){},onError:function(){},onPaymentError:function(){},testing:!1,iframeUrl:"",display:"inline",showLoading:!1,hideDetails:!1,hideDetailsButton:!1,hideCartButton:!1,hideSubscriptionSummary:!1,language:"",logoUrl:"",backgroundColor:"white",accentColor:"",errorColor:"",inputBackgroundColor:"",inputBorderColor:"",inputBorderRadius:void 0,inputFloatingLabel:!0,buttonBackgroundColor:"",buttonTextColor:"",buttonBorderRadius:void 0,buttonBoxShadow:!0,linkColor:"",stepperTextColor:"",fontFamily:"",baseFontSize:void 0},k=function(){function t(o,n){var i,r;if(this.manifest=o,this.givenOptions=n,this.dialog=null,this.style=null,this.hostElement=null,this.originUrl=t.PROD_URL,this.messageHandler=null,this.clickHandler=null,this.successfulPaymentInteraction=!1,this.options=e(e({},v),n),this.validateParameters(o,this.options)){this.mapOptionsToManifest(o,this.options),o.config.sdkVersion="2.9.1",this.options.testing&&(this.originUrl=t.TEST_URL),this.options.iframeUrl&&(this.originUrl=this.options.iframeUrl),this.messageHandler=this.handleMessage.bind(this),window.addEventListener("message",this.messageHandler);var a=document.createElement("iframe");a.setAttribute("src","".concat(this.originUrl,"?manifest=").concat(this.encodeManifest(o))),a.setAttribute("width","400"),a.setAttribute("height","700"),a.setAttribute("frameborder","0"),a.setAttribute("allow","payment"),a.style.maxWidth="100%",this.options.backgroundColor&&(a.style.backgroundColor=this.options.backgroundColor),this.hostElement=document.getElementById(this.options.id),"popup"===this.options.display?(null!==this.hostElement&&(this.createPopupDOMTree(a),this.clickHandler=this.handleClick.bind(this)),this.hostElement.addEventListener("click",this.clickHandler)):(this.addCss(),null===(i=this.hostElement)||void 0===i||i.appendChild(a)),this.options.showLoading&&(null===(r=a.parentElement)||void 0===r||r.classList.add("epcsdk-loading"),a.addEventListener("load",(function(){var t;null===(t=a.parentElement)||void 0===t||t.classList.remove("epcsdk-loading")})))}}return t.prototype.mapOptionsToManifest=function(t,e){var o=e.hideDetails,n=e.hideDetailsButton,i=e.hideCartButton,r=e.hideSubscriptionSummary,a=e.language,s=e.logoUrl,l=e.display,d=e.backgroundColor,c=e.accentColor,u=e.errorColor,h=e.inputBackgroundColor,p=e.inputBorderColor,g=e.inputBorderRadius,m=e.inputFloatingLabel,f=e.buttonBackgroundColor,b=e.buttonTextColor,y=e.buttonBorderRadius,v=e.buttonBoxShadow,k=e.linkColor,w=e.stepperTextColor,T=e.fontFamily,C=e.baseFontSize;t.config||(t.config={}),o&&(t.config.hideDetails=o),n&&(t.config.hideDetailsButton=n),i&&(t.config.hideCartButton=i),r&&(t.config.hideSubscriptionSummary=r),a&&(t.config.language=a),s&&(t.config.logoUrl=s),"popup"===l&&(t.config.allowClose=!0),"inline"===l&&(t.config.allowClose=!1),d&&(t.config.backgroundColor=d),c&&(t.config.accentColor=c),u&&(t.config.errorColor=u),h&&(t.config.inputBackgroundColor=h),p&&(t.config.inputBorderColor=p),void 0!==g&&(t.config.inputBorderRadius=g),void 0!==m&&(t.config.inputFloatingLabel=m),f&&(t.config.buttonBackgroundColor=f),b&&(t.config.buttonTextColor=b),void 0!==y&&(t.config.buttonBorderRadius=y),void 0!==v&&(t.config.buttonBoxShadow=v),k&&(t.config.linkColor=k),w&&(t.config.stepperTextColor=w),T&&(t.config.fontFamily=T),C&&(t.config.baseFontSize=C)},t.prototype.validateParameters=function(e,o){return e&&"string"==typeof e.id&&""!==e.id&&"string"==typeof e.session&&""!==e.session?"string"!=typeof o.id||""===o.id?(console.error("".concat(t.LOGTAG," The HTML element id must be a non-empty string.")),!1):document.getElementById(o.id)?"function"!=typeof o.onSuccess?(console.error("".concat(t.LOGTAG," The onSuccess callback must be a function.")),!1):"function"!=typeof o.onError?(console.error("".concat(t.LOGTAG," The onError callback must be a function.")),!1):"function"!=typeof o.onPaymentError?(console.error("".concat(t.LOGTAG," The onPaymentError callback must be a function.")),!1):o.onClose&&"function"!=typeof o.onClose?(console.error("".concat(t.LOGTAG," The onClose callback must be a function.")),!1):"boolean"!=typeof o.testing?(console.error("".concat(t.LOGTAG," The testing option must be true or false.")),!1):"string"!=typeof o.iframeUrl?(console.error("".concat(t.LOGTAG," The iframeUrl option must be a string.")),!1):"string"==typeof o.display&&["inline","popup"].includes(o.display)?"boolean"!=typeof o.showLoading?(console.error("".concat(t.LOGTAG," The showLoading option must be true or false.")),!1):"boolean"!=typeof o.hideDetails?(console.error("".concat(t.LOGTAG," The hideDetails option must be true or false.")),!1):"boolean"!=typeof o.hideDetailsButton?(console.error("".concat(t.LOGTAG," The hideDetailsButton option must be true or false.")),!1):"boolean"!=typeof o.hideCartButton?(console.error("".concat(t.LOGTAG," The hideCartButton option must be true or false.")),!1):"boolean"!=typeof o.hideSubscriptionSummary?(console.error("".concat(t.LOGTAG," The hideSubscriptionSummary option must be true or false.")),!1):"string"!=typeof o.language?(console.error("".concat(t.LOGTAG," The language option must be a string.")),!1):"string"!=typeof o.logoUrl?(console.error("".concat(t.LOGTAG," The logoUrl option must be a string.")),!1):"string"!=typeof o.backgroundColor?(console.error("".concat(t.LOGTAG," The backgroundColor option must be a string.")),!1):"string"!=typeof o.accentColor?(console.error("".concat(t.LOGTAG," The accentColor option must be a string.")),!1):"string"!=typeof o.errorColor?(console.error("".concat(t.LOGTAG," The errorColor option must be a string.")),!1):"string"!=typeof o.inputBackgroundColor?(console.error("".concat(t.LOGTAG," The inputBackgroundColor option must be a string.")),!1):"string"!=typeof o.inputBorderColor?(console.error("".concat(t.LOGTAG," The inputBorderColor option must be a string.")),!1):"number"!=typeof o.inputBorderRadius&&void 0!==o.inputBorderRadius?(console.error("".concat(t.LOGTAG," The inputBorderRadius option must be a number.")),!1):"boolean"!=typeof o.inputFloatingLabel||"boolean"!=typeof o.inputFloatingLabel?(console.error("".concat(t.LOGTAG," The inputFloatingLabel option must be a boolean.")),!1):"string"!=typeof o.buttonBackgroundColor?(console.error("".concat(t.LOGTAG," The buttonBackgroundColor option must be a string.")),!1):"string"!=typeof o.buttonTextColor?(console.error("".concat(t.LOGTAG," The buttonTextColor option must be a string.")),!1):"number"!=typeof o.buttonBorderRadius&&void 0!==o.buttonBorderRadius?(console.error("".concat(t.LOGTAG," The buttonBorderRadius option must be a number.")),!1):"boolean"!=typeof o.buttonBoxShadow?(console.error("".concat(t.LOGTAG," The buttonBoxShadow option must be a boolean.")),!1):"string"!=typeof o.linkColor?(console.error("".concat(t.LOGTAG," The linkColor option must be a string.")),!1):"string"!=typeof o.stepperTextColor?(console.error("".concat(t.LOGTAG," The stepperTextColor option must be a string.")),!1):"string"!=typeof o.fontFamily?(console.error("".concat(t.LOGTAG," The fontFamily option must be a string.")),!1):"number"==typeof o.baseFontSize||void 0===o.baseFontSize||(console.error("".concat(t.LOGTAG," The baseFontSize option must be a number.")),!1):(console.error("".concat(t.LOGTAG," The display option must be 'inline' or 'popup'.")),!1):(console.error("".concat(t.LOGTAG," Could not find element ").concat(o.id,".")),!1):(console.error("".concat(t.LOGTAG," Please provide a valid Checkout Manifest when calling startCheckout.")),!1)},t.prototype.encodeManifest=function(t){return"undefined"!=typeof Buffer?Buffer.from(JSON.stringify(t),"binary").toString("base64"):window.btoa(JSON.stringify(t))},t.prototype.handleMessage=function(t){if((t.origin.endsWith("/")?t.origin:t.origin.concat("/"))===(this.originUrl.endsWith("/")?this.originUrl:this.originUrl.concat("/"))&&"ep-checkout"===t.data.type)switch("close"===t.data.status&&(this.dialog&&this.dialog.close(),this.options.onClose&&this.options.onClose(),this.successfulPaymentInteraction&&this.messageHandler&&window.removeEventListener("message",this.messageHandler)),t.data.status){case"success":this.successfulPaymentInteraction=!0,this.options.onSuccess(t.data.checkout);break;case"error":this.options.onError(t.data.error);break;case"payment-error":var e={code:t.data.error.code,paymentMethod:t.data.paymentMethod};t.data.checkout&&(e.checkout=t.data.checkout),this.options.onPaymentError(e)}},t.prototype.handleClick=function(){this.dialog.showModal()},t.prototype.addCss=function(t){void 0===t&&(t=!1);var e=document.createElement("style");e.setAttribute("type","text/css"),t&&e.appendChild(document.createTextNode("dialog {\n position: absolute;\n left: 0; right: 0;\n width: -moz-fit-content;\n width: -webkit-fit-content;\n width: fit-content;\n height: -moz-fit-content;\n height: -webkit-fit-content;\n height: fit-content;\n margin: auto;\n border: solid;\n padding: 1em;\n background: white;\n color: black;\n display: block;\n}\n\ndialog:not([open]) {\n display: none;\n}\n\ndialog + .backdrop {\n position: fixed;\n top: 0; right: 0; bottom: 0; left: 0;\n background: rgba(0,0,0,0.1);\n}\n\n._dialog_overlay {\n position: fixed;\n top: 0; right: 0; bottom: 0; left: 0;\n}\n\ndialog.fixed {\n position: fixed;\n top: 50%;\n transform: translate(0, -50%);\n}")),e.appendChild(document.createTextNode("dialog.epcsdk-modal {\n border: 0.5px solid #dadada;\n border-radius: 10px;\n padding: 0;\n width: 400px;\n max-width: 90%;\n height: 700px;\n background-color: white;\n transition: 200ms linear;\n}\n\ndialog.epcsdk-modal::backdrop {\n background-color: rgba(0, 0, 0, 0.5);\n transition: 200ms ease-in-out;\n}\n\ndialog.epcsdk-modal + .backdrop {\n /* polyfill */\n background-color: rgba(0, 0, 0, 0.5);\n transition: 200ms ease-in-out;\n}\n\ndialog.epcsdk-modal iframe {\n height: 100%;\n}\n\n.epcsdk-loading {\n position: relative;\n}\n\n.epcsdk-loading::before {\n position: absolute;\n top: 5px;\n left: 50%;\n display: block;\n content: '';\n width: 48px;\n height: 48px;\n border: 5px solid #dadada;\n border-bottom-color: transparent;\n border-radius: 50%;\n box-sizing: border-box;\n animation: epcsdk-rotation 1s linear infinite;\n}\n\n@keyframes epcsdk-rotation {\n 0% {\n transform: translateX(-50%) rotate(0deg);\n }\n 100% {\n transform: translateX(-50%) rotate(360deg);\n }\n}\n")),document.head.appendChild(e),this.style=e},t.prototype.createPopupDOMTree=function(t){var e=document.createElement("dialog"),o=document.createElement("div"),n="function"!=typeof e.showModal;n&&p.registerDialog(e),this.addCss(n),this.options.backgroundColor&&e.setAttribute("style","background-color:".concat(this.options.backgroundColor)),e.setAttribute("class","epcsdk-modal"),o.appendChild(t),e.appendChild(o),document.body.appendChild(e),this.dialog=e},t.prototype.unmount=function(){var t,e,o,n;this.messageHandler&&window.removeEventListener("message",this.messageHandler),this.clickHandler&&(null===(t=this.hostElement)||void 0===t||t.removeEventListener("click",this.clickHandler)),null===(e=this.dialog)||void 0===e||e.remove(),null===(o=this.style)||void 0===o||o.remove(),Array.from((null===(n=document.getElementById(this.options.id))||void 0===n?void 0:n.children)||[]).map((function(t){t.remove()}))},t.PROD_URL="https://pay.easypay.pt",t.TEST_URL="https://pay.sandbox.easypay.pt",t.LOGTAG="[easypay Checkout SDK]",t}();t.CheckoutInstance=k,t.startCheckout=function(t,e){return void 0===e&&(e={}),new k(t,e)},Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=index.js.map