@paydock/client-sdk 1.107.0 → 1.107.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/bundles/index.cjs +1 -1
- package/bundles/index.mjs +1 -1
- package/bundles/widget.umd.js +1 -1
- package/bundles/widget.umd.min.js +1 -1
- package/package.json +1 -1
package/bundles/index.cjs
CHANGED
package/bundles/index.mjs
CHANGED
package/bundles/widget.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("isomorphic-dompurify")):"function"==typeof define&&define.amd?define(["exports","isomorphic-dompurify"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).paydock={})}(this,(function(e){"use strict";function t(e,t,i){return t=d(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,n()?Reflect.construct(t,i||[],d(e).constructor):t.apply(e,i))}function n(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(n=function(){return!!e})()}function i(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,i(r.key),r)}}function s(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function u(e,t,n){return(t=i(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},c.apply(this,arguments)}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}function d(e){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},d(e)}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function p(){return p="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=d(e)););return e}(e,t);if(i){var r=Object.getOwnPropertyDescriptor(i,t);return r.get?r.get.call(arguments.length<3?e:n):r.value}},p.apply(this,arguments)}function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t);else for(;!(u=(i=o.call(n)).done)&&(s.push(i.value),s.length!==t);u=!0);}catch(e){c=!0,r=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw r}}return s}}(e,t)||m(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e){return function(e){if(Array.isArray(e))return y(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||m(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(e,t){if(e){if("string"==typeof e)return y(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(e,t):void 0}}function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}var g,k=function(){return s((function e(){o(this,e)}),null,[{key:"isFacebook",value:function(){return-1!==navigator.userAgent.indexOf("FBSN/iOS")&&-1!==navigator.userAgent.indexOf("AppleWebKit")&&-1!==navigator.userAgent.indexOf("(KHTML, like Gecko)")}},{key:"isInstagram",value:function(){return-1!==navigator.userAgent.indexOf("iOS")&&-1!==navigator.userAgent.indexOf("Instagram")&&-1!==navigator.userAgent.indexOf("(KHTML, like Gecko)")}},{key:"isSupportPopUp",value:function(){return!this.isFacebook()&&!this.isInstagram()}},{key:"getLanguage",value:function(){return window.navigator.language||""}},{key:"getTimezoneOffset",value:function(){return(new Date).getTimezoneOffset()}},{key:"getBrowserName",value:function(){var e=navigator.userAgent;return e.indexOf("Firefox")>-1?"Mozilla Firefox":e.indexOf("Opera")>-1?"Opera":e.indexOf("Trident")>-1?"Microsoft Internet Explorer":e.indexOf("Edge")>-1?"Microsoft Edge":e.indexOf("Chrome")>-1?"Google Chrome or Chromium":e.indexOf("Safari")>-1?"Apple Safari":"unknown"}},{key:"isJavaEnabled",value:function(){return navigator.javaEnabled()}},{key:"getColorDepth",value:function(){return screen.colorDepth}},{key:"getScreenHeight",value:function(){return screen.height}},{key:"getScreenWidth",value:function(){return screen.width}},{key:"getBrowserInfo",value:function(){var e,t=navigator.userAgent,n=t.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];return/trident/i.test(n[1])?{name:"IE",version:(e=/\brv[ :]+(\d+)/g.exec(t)||[])[1]||""}:"Chrome"===n[1]&&null!=(e=t.match(/\bOPR|Edge\/(\d+)/))?{name:"Opera",version:e[1]}:(n=n[2]?[n[1],n[2]]:[navigator.appName,navigator.appVersion,"-?"],null!=(e=t.match(/version\/(\d+)/i))&&n.splice(1,1,e[1]),{name:n[0],version:n[1]})}}])}(),E="/v1/charges/3ds",_=function(){return s((function e(t){o(this,e),this.api=t}),[{key:"preAuth",value:function(e,t){return"function"==typeof t?this.api.getClient("POST",E).send(c(c({},e),{_3ds:c(c({},e._3ds),{browser_details:{name:k.getBrowserName(),java_enabled:k.isJavaEnabled().toString(),language:k.getLanguage(),screen_height:k.getScreenHeight().toString(),screen_width:k.getScreenWidth().toString(),time_zone:k.getTimezoneOffset().toString(),color_depth:k.getColorDepth().toString()}})}),(function(e){t(e)})):this.api.getClientPromise("POST",E).send(c(c({},e),{_3ds:c(c({},e._3ds),{browser_details:{name:k.getBrowserName(),java_enabled:k.isJavaEnabled().toString(),language:k.getLanguage(),screen_height:k.getScreenHeight().toString(),screen_width:k.getScreenWidth().toString(),time_zone:k.getTimezoneOffset().toString(),color_depth:k.getColorDepth().toString()}})}))}}])}(),b="x-access-token",w="x-user-public-key",C=function(){function e(){o(this,e)}return s(e,null,[{key:"validateJWT",value:function(e){if(!e)return null;var t=f(e.split("."),3),n=t[0],i=t[1],r=t[2];if(!n||!i||!r)return null;if(2+n.length+i.length+r.length!==e.length)return null;try{return{head:JSON.parse(atob(n)),body:JSON.parse(atob(i)),signature:r}}catch(e){return null}}},{key:"extractData",value:function(e){try{return JSON.parse(atob(e.meta))}catch(e){return null}}},{key:"extractMeta",value:function(e){try{return JSON.parse(atob(e.meta)).meta}catch(e){return null}}},{key:"getAccessHeaderNameByToken",value:function(t){return e.validateJWT(t)?b:w}}])}(),S="sandbox",T="sandbox-kovena",O="sandbox-demo-kovena",A="production",P="staging",R="staging_1",x="staging_2",I="staging_3",U="staging_4",L="staging_5",N="staging_6",D="staging_7",M="staging_8",H="staging_9",F="staging_10",B="staging_11",j="staging_12",z="staging_13",V="staging_14",q="staging_15",K=[{env:S,url:"https://widget-sandbox."},{env:T,url:"https://widget-sandbox."},{env:"sandbox-demo",url:"https://widget-sandbox-demo."},{env:O,url:"https://widget-sandbox-demo."},{env:A,url:"https://widget."},{env:P,url:"https://widsta."},{env:R,url:"https://widsta-1."},{env:x,url:"https://widsta-2."},{env:I,url:"https://widsta-3."},{env:U,url:"https://widsta-4."},{env:L,url:"https://widsta-5."},{env:N,url:"https://widsta-6."},{env:D,url:"https://widsta-7."},{env:M,url:"https://widsta-8."},{env:H,url:"https://widsta-9."},{env:F,url:"https://widsta-10."},{env:B,url:"https://widsta-11."},{env:j,url:"https://widsta-12."},{env:z,url:"https://widsta-13."},{env:V,url:"https://widsta-14."},{env:q,url:"https://widsta-15."}],Y=[{env:S,url:"https://api-sandbox."},{env:A,url:"https://api."},{env:P,url:"https://apista."},{env:R,url:"https://apista-1."},{env:x,url:"https://apista-2."},{env:I,url:"https://apista-3."},{env:U,url:"https://apista-4."},{env:L,url:"https://apista-5."},{env:N,url:"https://apista-6."},{env:D,url:"https://apista-7."},{env:M,url:"https://apista-8."},{env:H,url:"https://apista-9."},{env:F,url:"https://apista-10."},{env:B,url:"https://apista-11."},{env:j,url:"https://apista-12."},{env:z,url:"https://apista-13."},{env:V,url:"https://apista-14."},{env:q,url:"https://apista-15."}],W=[T,O],G=S,J="paydock.com",Z="kovena.com",X=function(){return s((function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:G;o(this,e),this.configs=t,this.setEnv(n)}),[{key:"setEnv",value:function(e,t){if(!this.isValidMode(this.configs,e))throw new Error("unknown env: "+e);if(this.env=e,t&&!t.match("^([a-zA-Z0-9](?:(?:[a-zA-Z0-9-.]*(?!-)\\.(?![-.]))*[a-zA-Z0-9]+)?)$"))throw new Error("invalid: "+t);t?this.alias=t:-1!==W.indexOf(this.env)?this.alias=Z:this.alias=J}},{key:"getEnv",value:function(){return this.env}},{key:"getConf",value:function(){for(var e in this.configs)if(this.configs.hasOwnProperty(e)&&this.configs[e].env===this.getEnv())return{url:-1!==this.configs[e].url.indexOf("localhost")?this.configs[e].url:this.configs[e].url+this.alias,env:this.configs[e].env};throw new Error("invalid env")}},{key:"isValidMode",value:function(e,t){for(var n in e)if(e.hasOwnProperty(n)&&e[n].env===t)return!0;return!1}}])}(),$=function(){function e(){o(this,e)}return s(e,null,[{key:"version",get:function(){return e._version.trim()||null}}])}();$.type="client",$.headerKeys=Object.freeze({version:"x-sdk-version",type:"x-sdk-type"}),$._version="v1.107.0",function(e){e[e.PUBLIC_KEY=0]="PUBLIC_KEY",e[e.TOKEN=1]="TOKEN"}(g||(g={}));var Q,ee=function(){return s((function e(t,n){o(this,e),this.auth=t,this.authType=n||this.setAuthType(),this.env=new X(Y)}),[{key:"setEnv",value:function(e,t){return this.env.setEnv(e,t),this}},{key:"setAuthType",value:function(){return this.authType=C.validateJWT(this.auth)?g.TOKEN:g.PUBLIC_KEY}},{key:"getClient",value:function(e,t){var n=this,i=new XMLHttpRequest;return i.open(e,this.env.getConf().url+t,!0),i.setRequestHeader("Content-Type","application/json; charset=UTF-8"),this.setAuthHeader(i),$.version&&(i.setRequestHeader($.headerKeys.version,$.version),i.setRequestHeader($.headerKeys.type,$.type)),{config:i,send:function(e,t,r){i.onload=function(){return n.parser({text:i.responseText,status:i.status},t,r)},i.send(JSON.stringify(e))}}}},{key:"getClientPromise",value:function(e,t){var n=this,i=new XMLHttpRequest;return i.open(e,this.env.getConf().url+t,!0),i.setRequestHeader("Content-Type","application/json; charset=UTF-8"),this.setAuthHeader(i),$.version&&(i.setRequestHeader($.headerKeys.version,$.version),i.setRequestHeader($.headerKeys.type,$.type)),{config:i,send:function(e){return new Promise((function(t,n){i.onload=function(){return t({text:i.responseText,status:i.status})},i.send(JSON.stringify(e))})).then((function(e){return n.parserPromise(e)}))}}}},{key:"parser",value:function(e,t,n){var i=e.text,r=e.status;try{var o=JSON.parse(i);if(r>=200&&r<300||302===r)return t(o.resource.data);n(o.error||{message:"unknown error"})}catch(e){}}},{key:"parserPromise",value:function(e){var t=e.text,n=e.status;try{var i=JSON.parse(t);return n>=200&&n<300||302===n?Promise.resolve(i.resource.data):Promise.reject(i.error||{message:"unknown error"})}catch(e){return Promise.reject(e)}}},{key:"setAuthHeader",value:function(e){switch(this.authType){case g.PUBLIC_KEY:e.setRequestHeader("x-user-public-key",this.auth);break;case g.TOKEN:e.setRequestHeader("x-access-token",this.auth)}}}])}(),te=function(e){function n(e){var i;return o(this,n),(i=t(this,n,[e])).publicKey=i.auth,i}return l(n,e),s(n,[{key:"getBrowserDetails",value:function(){return{name:k.getBrowserName(),java_enabled:k.isJavaEnabled().toString(),language:k.getLanguage(),screen_height:k.getScreenHeight().toString(),screen_width:k.getScreenWidth().toString(),time_zone:k.getTimezoneOffset().toString(),color_depth:k.getColorDepth().toString()}}},{key:"charge",value:function(){return new _(this)}}])}(ee),ne=function(){return s((function e(){o(this,e)}),null,[{key:"extendSearchParams",value:function(e,t,n){return e.replace(new RegExp("([?&]"+t+"(?=[=&#]|$)[^#&]*|(?=#|$))"),"&"+t+"="+encodeURIComponent(n)).replace(/^([^?&]+)&/,"$1?")}},{key:"serialize",value:function(e){return Object.keys(e).map((function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])})).join("&")}}])}(),ie=function(){return s((function e(){o(this,e)}),null,[{key:"generate",value:function(){if("undefined"!=typeof window&&void 0!==window.crypto&&void 0!==window.crypto.getRandomValues){var e=new Uint16Array(8);return window.crypto.getRandomValues(e),this.hash(e[0])+this.hash(e[1])+"-"+this.hash(e[2])+"-"+this.hash(e[3])+"-"+this.hash(e[4])+"-"+this.hash(e[5])+this.hash(e[6])+this.hash(e[7])}return this.random()+this.random()+"-"+this.random()+"-"+this.random()+"-"+this.random()+"-"+this.random()+this.random()+this.random()}},{key:"hash",value:function(e){for(var t=e.toString(16);t.length<4;)t="0"+t;return t}},{key:"random",value:function(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}}])}(),re="/wallet/flypay",oe="/images/logo.png",ae=function(){return s((function e(t){o(this,e),this.params={},this.widgetId=ie.generate(),this.linkResource=t,this.env=new X(K),this.setParams({widget_id:this.widgetId})}),[{key:"getNetUrl",value:function(){return this.env.getConf().url+this.linkResource}},{key:"getUrl",value:function(){var e=this.getNetUrl(),t=this.getParams();for(var n in t)t.hasOwnProperty(n)&&(e=ne.extendSearchParams(e,n,t[n]));return e}},{key:"setParams",value:function(e){this.params=c({},this.params,e)}},{key:"concatParams",value:function(e){for(var t in e)e.hasOwnProperty(t)&&e[t].length&&("string"!=typeof this.params[t]&&(this.params[t]=""),this.params[t].length?this.params[t]+=","+e[t]:this.params[t]+=e[t])}},{key:"getParams",value:function(){return this.params}},{key:"setEnv",value:function(e,t){this.env.setEnv(e,t)}},{key:"getEnv",value:function(){return this.env.getEnv()}},{key:"getBaseUrl",value:function(){return this.env.getConf().url}}])}(),se=function(){return s((function e(){o(this,e)}),null,[{key:"insertToInput",value:function(e,t,n){if(void 0!==n[t]){var i=document.querySelector(e);i&&(i.value=n[t])}}},{key:"subscribe",value:function(e,t,n){t.addEventListener?t.addEventListener(e,n):t.attachEvent("on".concat(e),n)}}])}(),ue=function(){return s((function e(t){o(this,e),this.selector=t}),[{key:"isExist",value:function(){return!!this.getElement()}},{key:"getStyles",value:function(e){if(this.isExist()){var t=this.getElement().getAttribute("widget-style");if(!t)return{};var n=t.split(";");return void 0===n||n.length?this.convertConfigs(n,e):{}}}},{key:"on",value:function(e,t){this.isExist()&&se.subscribe(e,this.getElement(),t)}},{key:"getAttr",value:function(e){if(this.isExist()){var t=this.getElement(),n=[];for(var i in e)if(e.hasOwnProperty(i)){var r=e[i].replace(/_/g,"-"),o=t.getAttribute(r);o&&n.push("".concat(e[i],":").concat(o))}return void 0===n||n.length?this.convertConfigs(n,e):{}}}},{key:"getElement",value:function(){return document.querySelector(this.selector)}},{key:"getSelector",value:function(){return this.selector}},{key:"convertConfigs",value:function(e,t){var n={};for(var i in e)if(e.hasOwnProperty(i)){var r=e[i].split(":"),o=r[0].replace(/-/g,"_").trim();-1!==t.indexOf(o)&&(n[o]=r[1].trim())}return n}}])}(),ce=function(){return s((function e(t){o(this,e),this.container=t}),[{key:"load",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.container.isExist()&&!this.isExist()){var n=document.createElement("iframe");n.setAttribute("src",e),t.title&&(n.title=t.title),this.container.getElement().appendChild(n)}}},{key:"loadFromHtml",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.container.isExist()&&!this.isExist()){var n=document.createElement("iframe");n.setAttribute("height","100%"),n.setAttribute("width","100%"),t.title&&(n.title=t.title);this.container.getElement().appendChild(n);var i=this.getElement().contentDocument;i.open(),i.write("<html><head><style>html, body {margin: 0;} iframe {border: 0; width: 100%}</style><title></title></head><body>{{content}}</body></html>".replace("{{content}}",e)),i.close()}}},{key:"remove",value:function(){if(this.container.isExist()&&this.isExist()){var e=this.getElement();this.container.getElement().removeChild(e)}}},{key:"show",value:function(){this.isExist()&&(this.setStyle("visibility","visible"),this.setStyle("display","block"))}},{key:"hide",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.isExist()&&(e?this.setStyle("visibility","hidden"):this.setStyle("display","none"))}},{key:"isExist",value:function(){return!!this.getElement()}},{key:"getElement",value:function(){return this.container.isExist()?this.container.getElement().querySelector("iframe"):null}},{key:"setStyle",value:function(e,t){this.getElement().style[e]=t}}])}(),le={AFTER_LOAD:"afterLoad",SUBMIT:"submit",FINISH:"finish",VALIDATION_ERROR:"validationError",SYSTEM_ERROR:"systemError",CHECKOUT_SUCCESS:"checkoutSuccess",CHECKOUT_READY:"checkoutReady",CHECKOUT_ERROR:"checkoutError",CHECKOUT_COMPLETED:"checkoutCompleted",CHECKOUT_POPUP_OPEN:"checkoutPopupOpen",CHECKOUT_POPUP_CLOSE:"checkoutPopupClose",VALIDATION:"validation",SELECT:"select",UNSELECT:"unselect",NEXT:"next",PREV:"prev",META_CHANGE:"metaChange",RESIZE:"resize",CHARGE_AUTH_SUCCESS:"chargeAuthSuccess",CHARGE_AUTH_REJECT:"chargeAuthReject",CHARGE_AUTH_CANCELLED:"chargeAuthCancelled",ADDITIONAL_DATA_SUCCESS:"additionalDataCollectSuccess",ADDITIONAL_DATA_REJECT:"additionalDataCollectReject",CHARGE_AUTH:"chargeAuth",DISPATCH_SUCCESS:"dispatchSuccess",DISPATCH_ERROR:"dispatchError"},de=function(){return s((function e(t){var n=this;o(this,e),this.listeners=[],t&&se.subscribe("message",t,(function(e){var t;try{t=JSON.parse(e.data)}catch(e){}t&&n.emit(t)}))}),[{key:"emit",value:function(e){for(var t in this.listeners)this.listeners[t].event===e.event&&e.widget_id===this.listeners[t].widget_id&&this.listeners[t].listener.apply(this,[e])}},{key:"on",value:function(e,t,n){for(var i in le)le.hasOwnProperty(i)&&e===le[i]&&this.listeners.push({event:e,listener:n,widget_id:t})}},{key:"clear",value:function(){this.listeners=[]}},{key:"subscribe",value:function(e,t){e.addEventListener?e.addEventListener("message",t):e.attachEvent("onmessage",t)}}])}(),he={visibility:"hidden",border:"0",width:"0",height:"0"};!function(e){e.SUCCESS="success",e.ERROR="error",e.PENDING="pending"}(Q||(Q={}));var pe,fe="chargeAuthSuccess",ve="chargeAuthReject",me="chargeAuthDecoupled",ye="chargeAuthChallenge",ge="chargeAuthInfo",ke="error",Ee=function(){return s((function e(t,n,i){o(this,e),this.container=t,this.api=n,this.eventEmitter=i,this.resultRead=!1,this.iFrameEvent=new de(window)}),[{key:"load",value:function(e,t){var n=e.initialization_url,i=e.secondary_url,r=e.charge_3ds_id;try{this.setupIFrameEvents(r),this.initializeIFrames(n,i,t)}catch(e){this.eventEmitter.emit(ke,this.parseError(e,r))}}},{key:"initializeIFrames",value:function(e,t,n){var i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],r=this.container.getElement();if(r){var o=document.createElement("div");if(o.setAttribute("id","paydock_authorization_iframe"),r.appendChild(o),this.browserAndChallengeContainer=new ue("#paydock_authorization_iframe"),this.iFrameAuthorization=new ce(this.browserAndChallengeContainer),this.iFrameAuthorization.load(e,{title:n}),t){var a=document.createElement("div");a.setAttribute("id","paydock_secondary_iframe"),r.appendChild(a),this.monitoringContainer=new ue("#paydock_secondary_iframe"),this.iFrameSecondaryUrl=new ce(this.monitoringContainer),this.iFrameSecondaryUrl.load(t,{title:n})}else this.iFrameSecondaryUrl=void 0;this.hideIframes(i)}}},{key:"hideIframes",value:function(){var e,t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];for(var n in he)he.hasOwnProperty(n)&&(t&&this.iFrameAuthorization.setStyle(n,he[n]),null===(e=this.iFrameSecondaryUrl)||void 0===e||e.setStyle(n,he[n]))}},{key:"setupIFrameEvents",value:function(e){var t=this;this.iFrameEvent.on(le.CHARGE_AUTH,e,(function(e){"MethodSkipped"===e.status||"MethodFinished"===e.status?(e.info&&t.eventEmitter.emit(ge,{info:e.info}),t.performAuthentication(e)):"AuthTimedOut"!==e.status&&"invalid_event"!==e.status||t.eventEmitter.emit(ve,t.parseHandleResponse({status:e.status},e.charge_3ds_id))})),this.iFrameEvent.on(le.CHARGE_AUTH_SUCCESS,e,(function(e){t.processResult(e.charge_3ds_id)}))}},{key:"parseResultData",value:function(e,t){return{status:e.status,charge_3ds_id:t}}},{key:"parseHandleResponse",value:function(e,t){var n=e.status,i=e.result;return{status:n,charge_3ds_id:t,result:{description:null==i?void 0:i.description}}}},{key:"parseError",value:function(e,t){return{charge_3ds_id:t,error:e}}},{key:"processResult",value:function(e){var t=this;this.resultRead||(this.resultRead=!0,this.api.charge().standalone3dsHandle().then((function(n){var i;t.iFrameAuthorization.remove(),null===(i=t.iFrameSecondaryUrl)||void 0===i||i.remove(),n.status===Q.SUCCESS?t.eventEmitter.emit(fe,t.parseResultData(n,e)):t.eventEmitter.emit(ve,t.parseResultData(n,e))}),(function(n){t.eventEmitter.emit(ke,t.parseError(n,e))})))}},{key:"externalAPI",value:function(e,t){var n=new XMLHttpRequest;return n.open(e,t,!0),new Promise((function(e,t){n.onload=function(){try{var i=JSON.parse(n.responseText);e(i)}catch(e){t(e)}},n.send()}))}},{key:"doPolling",value:function(e,t){var n=this;this.externalAPI("GET",e).then((function(i){if(i.event&&"AuthResultNotReady"!==i.event){if("AuthResultReady"!==i.event)throw new Error("Event not supported");n.processResult(t)}else setTimeout((function(){n.doPolling(e,t)}),2e3)})).catch((function(e){return n.eventEmitter.emit(ke,n.parseError(e,t))}))}},{key:"performAuthentication",value:function(e){var t,n=this,i=e.charge_3ds_id;this.iFrameAuthorization.remove(),null===(t=this.iFrameSecondaryUrl)||void 0===t||t.remove(),this.api.charge().standalone3dsProcess({charge_3ds_id:i}).then((function(e){var t,r;if("success"===e.status)n.eventEmitter.emit(fe,n.parseHandleResponse(e,i));else{if("pending"!==e.status)return n.eventEmitter.emit(ve,n.parseHandleResponse(e,i));(null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.challenge)?(n.eventEmitter.emit(ye,n.parseHandleResponse(e,i)),n.initializeIFrames(e.result.challenge_url,void 0,"Authentication Challenge",!1),e.result.secondary_url&&n.doPolling(e.result.secondary_url,i)):(null===(r=null==e?void 0:e.result)||void 0===r?void 0:r.decoupled_challenge)&&(n.eventEmitter.emit(me,n.parseHandleResponse(e,i)),e.result.secondary_url&&n.doPolling(e.result.secondary_url,i))}}),(function(e){n.eventEmitter.emit(ke,n.parseError(e,i))}))}}])}(),_e=function(){return s((function e(t){o(this,e),this.api=t}),[{key:"walletCapture",value:function(e){return this.api.getClientPromise("POST","/v1/charges/wallet/capture").send(e)}},{key:"walletCallback",value:function(e){return this.api.getClientPromise("POST","/v1/charges/wallet/callback").send(e)}},{key:"standalone3dsProcess",value:function(e){return this.api.getClientPromise("POST","/v1/charges/standalone-3ds/process").send(e)}},{key:"standalone3dsHandle",value:function(){return this.api.getClientPromise("GET","/v1/charges/standalone-3ds/handle").send(void 0)}}])}(),be=function(){return s((function e(t){o(this,e),this.api=t}),[{key:"getConfig",value:function(e){var t="/v1/services/:service_id/config".replace(":service_id",e);return this.api.getClientPromise("GET",t).send(void 0)}}])}();!function(e){e.VISA_SRC="VisaSRC",e.MASTERCARD_SRC="ClickToPay"}(pe||(pe={}));var we,Ce=function(e){function n(){return o(this,n),t(this,n,arguments)}return l(n,e),s(n,[{key:"charge",value:function(){return new _e(this)}},{key:"service",value:function(){return new be(this)}}])}(ee),Se="GPayments",Te=function(){return s((function e(t,n){o(this,e),this.env=G,this.container=t,this.eventEmitter=n}),[{key:"load",value:function(e,t){var n=C.validateJWT(e);if(!n)throw new Error("Invalid charge token");var i=C.extractData(n.body),r=new Ce(e,g.TOKEN);if(r.setEnv(this.env,this.alias),i.service_type===Se)new Ee(this.container,r,this.eventEmitter).load(i,t.title)}},{key:"setEnv",value:function(e,t){this.env=e,this.alias=t}}])}(),Oe=function(){return s((function e(){o(this,e),this.events={}}),[{key:"emit",value:function(e,t){var n=this.events[e];n&&n.forEach((function(e){e.call(null,t)}))}},{key:"subscribe",value:function(e,t){var n=this;return this.events[e]||(this.events[e]=[]),this.events[e].push(t),function(){n.events[e]=n.events[e].filter((function(e){return t!==e}))}}}])}();!function(e){e.HTML="html",e.URL="url",e.STANDALONE_3DS="standalone_3ds"}(we||(we={}));var Ae,Pe,Re=function(){return s((function e(t,n){o(this,e),this.configs=[],this.link=new ae("/3ds/webhook"),this.token=e.extractToken(n),this.link.setParams({ref_id:this.token.charge_3ds_id}),this.container=new ue(t),this.iFrame=new ce(this.container),this.eventEmitter=new Oe,this.standalone3dsService=new Te(this.container,this.eventEmitter),this.event=new de(window)}),[{key:"load",value:function(){this.token.format===we.HTML?this.iFrame.loadFromHtml(this.token.content,{title:"3d secure authentication"}):this.token.format===we.URL?this.iFrame.load(this.token.content,{title:"3d secure authentication"}):this.token.format===we.STANDALONE_3DS?this.standalone3dsService.load(this.token.content,{title:"3d secure authentication"}):console.error("Token contain unsupported payload")}},{key:"setEnv",value:function(e,t){for(var n in this.link.setEnv(e,t),this.standalone3dsService.setEnv(e,t),this.configs)this.configs.hasOwnProperty(n)&&this.configs[n].setEnv(e,t)}},{key:"getEnv",value:function(){return this.link.getEnv()}},{key:"on",value:function(e,t){var n=this;return this.token.format===we.STANDALONE_3DS?"function"==typeof t?this.eventEmitter.subscribe(e,t):new Promise((function(t){return n.eventEmitter.subscribe(e,(function(e){return t(e)}))})):"function"==typeof t?this.event.on(e,this.link.getParams().ref_id,t):new Promise((function(t){return n.event.on(e,n.link.getParams().ref_id,(function(e){return t(e)}))}))}},{key:"hide",value:function(e){this.iFrame.hide(e)}},{key:"show",value:function(){this.iFrame.show()}},{key:"reload",value:function(){this.iFrame.remove(),this.load()}}],[{key:"extractToken",value:function(e){return JSON.parse(window.atob(e))}}])}(),xe={CLICK:"click",POPUP_REDIRECT:"popupRedirect",REDIRECT:"redirect",ERROR:"error",REFERRED:"referred",DECLINED:"declined",CANCELLED:"cancelled",ACCEPTED:"accepted",FINISH:"finish",CLOSE:"close"};!function(e){e.CONTEXTUAL="contextual",e.REDIRECT="redirect"}(Ae||(Ae={})),function(e){e.ZIPMONEY="Zipmoney",e.PAYPAL="PaypalClassic",e.AFTERPAY="Afterpay"}(Pe||(Pe={}));var Ie,Ue,Le="[Paydock:CheckoutButton]",Ne={CARD:"card",BANK_ACCOUNT:"bank_account",CHECKOUT:"checkout"},De={CARD_NAME:"card_name",CARD_NUMBER:"card_number",EXPIRE_MONTH:"expire_month",EXPIRE_YEAR:"expire_year",CARD_CCV:"card_ccv",CARD_PIN:"card_pin",ACCOUNT_NAME:"account_name",ACCOUNT_BSB:"account_bsb",ACCOUNT_NUMBER:"account_number",ACCOUNT_ROUTING:"account_routing",ACCOUNT_HOLDER_TYPE:"account_holder_type",ACCOUNT_BANK_NAME:"account_bank_name",ACCOUNT_TYPE:"account_type",FIRST_NAME:"first_name",LAST_NAME:"last_name",EMAIL:"email",PHONE:"phone",PHONE2:"phone2",ADDRESS_LINE1:"address_line1",ADDRESS_LINE2:"address_line2",ADDRESS_STATE:"address_state",ADDRESS_COUNTRY:"address_country",ADDRESS_CITY:"address_city",ADDRESS_POSTCODE:"address_postcode",ADDRESS_COMPANY:"address_company"},Me={BACKGROUND_COLOR:"background_color",BACKGROUND_ACTIVE_COLOR:"background_active_color",TEXT_COLOR:"text_color",BORDER_COLOR:"border_color",ICON_SIZE:"icon_size",BUTTON_COLOR:"button_color",ERROR_COLOR:"error_color",SUCCESS_COLOR:"success_color",FONT_SIZE:"font_size",FONT_FAMILY:"font_family"},He={TITLE:"title",TITLE_H1:"title_h1",TITLE_H2:"title_h2",TITLE_H3:"title_h3",TITLE_H4:"title_h4",TITLE_H5:"title_h5",TITLE_H6:"title_h6",FINISH:"finish_text",TITLE_DESCRIPTION:"title_description",SUBMIT_BUTTON:"submit_button",SUBMIT_BUTTON_PROCESSING:"submit_button_processing"},Fe={SUBMIT_BUTTON:"submit_button",TABS:"tabs"},Be={AMEX:"amex",AUSBC:"ausbc",DINERS:"diners",DISCOVER:"discover",JAPCB:"japcb",LASER:"laser",MASTERCARD:"mastercard",SOLO:"solo",VISA:"visa",VISA_WHITE:"visa_white"},je=[].concat(["brand_name","cart_border_color","reference","email","hdr_img","logo_img","pay_flow_color","first_name","last_name","address_line","address_line2","address_city","address_state","address_postcode","address_country","phone","hide_shipping_address"],["first_name","last_name","phone","tokenize","email","gender","date_of_birth","charge","statistics","hide_shipping_address"],["amount","currency","email","first_name","last_name","address_line","address_line2","address_city","address_state","address_postcode","address_country","phone"],["customer_storage_number","tokenise_algorithm"]);!function(e){e.STRIPE="Stripe",e.FLYPAY="Flypay",e.FLYPAY_V2="FlypayV2",e.PAYPAL="Paypal",e.MASTERCARD="MasterCard",e.AFTERPAY="Afterpay"}(Ie||(Ie={})),function(e){e.GOOGLE="google",e.APPLE="apple",e.FLYPAY="flypay",e.FLYPAY_V2="flypayV2",e.PAYPAL="paypal",e.AFTERPAY="afterpay"}(Ue||(Ue={}));var ze,Ve=function(){return s((function e(){o(this,e),this.env=new X(Y)}),[{key:"setEnv",value:function(e,t){this.env.setEnv(e,t)}},{key:"getEnv",value:function(){return this.env.getEnv()}},{key:"getUrl",value:function(){return this.env.getConf().url+this.getLink()}},{key:"create",value:function(e,t,n,i){var r=this,o=new XMLHttpRequest;o.onload=function(){r.parser(o.responseText,o.status,n,i)},o.open("POST",this.getUrl(),!0),o.setRequestHeader("Content-Type","application/json; charset=UTF-8"),o.setRequestHeader(C.getAccessHeaderNameByToken(e),e),$.version&&(o.setRequestHeader($.headerKeys.version,$.version),o.setRequestHeader($.headerKeys.type,$.type)),o.send(JSON.stringify(t))}},{key:"get",value:function(e,t,n){var i=this,r=new XMLHttpRequest;r.onload=function(){i.parser(r.responseText,r.status,t,n)},r.open("GET",this.getUrl(),!0),r.setRequestHeader("Content-Type","application/json; charset=UTF-8"),r.setRequestHeader(C.getAccessHeaderNameByToken(e),e),$.version&&(r.setRequestHeader($.headerKeys.version,$.version),r.setRequestHeader($.headerKeys.type,$.type)),r.send()}},{key:"parser",value:function(e,t,n,i){var r={};try{r=JSON.parse(e)}catch(e){}if(t>=200&&t<300||302===t)return n(r.resource.data,t);i(r.error||{message:"unknown error"},t)}}])}(),qe=function(e){function n(e,i,r){var a;return o(this,n),(a=t(this,n)).body={gateway_id:e,meta:{},success_redirect_url:i,error_redirect_url:r,redirect_url:i},a}return l(n,e),s(n,[{key:"getLink",value:function(){return"/v1/payment_sources/external_checkout"}},{key:"setDescriptions",value:function(e){this.body.description=e}},{key:"setMeta",value:function(e){for(var t in e)e.hasOwnProperty(t)&&(-1!==je.indexOf(t)?this.body.meta[t]=e[t]:console.warn("ExternalCheckout::setMeta: unsupported meta key ".concat(t)))}},{key:"getConfigs",value:function(){return this.body}},{key:"send",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(e,t){};this.create(e,this.getConfigs(),(function(e,n){t(e)}),(function(e,t){void 0===e.message?n("".concat(t,": unknown error"),"unknown_error"):n(e.message,e.code)}))}}])}(Ve),Ke=function(e){function n(e){var i;return o(this,n),(i=t(this,n)).token=e,i}return l(n,e),s(n,[{key:"getLink",value:function(){return"/v1/payment_sources/external_checkout/:token".replace(":token",this.token)}},{key:"send",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(e){};this.get(e,(function(e,n){t(e)}),(function(e,t){void 0===e.message?n("".concat(t,": unknown error")):n(e.message)}))}}])}(Ve),Ye='\n <div class="cs-loader">\n <div class="cs-loader-inner">\n <label>\t●</label>\n <label>\t●</label>\n <label>\t●</label>\n <label>\t●</label>\n <label>\t●</label>\n <label>\t●</label>\n </div>\n </div>\n',We="\n <style> \n .cs-loader {\n position: absolute;\n top: 0;\n left: 0;\n height: 100%;\n width: 100%;\n }\n \n .cs-loader-inner {\n transform: translateY(-50%);\n top: 50%;\n position: absolute;\n width: calc(100% - 200px);\n color: #8e8d8c;\n padding: 0 100px;\n text-align: center;\n }\n \n \n .cs-loader-inner label {\n font-size: 20px;\n opacity: 0;\n display:inline-block;\n }\n \n @keyframes lol {\n 0% {\n opacity: 0;\n transform: translateX(-300px);\n }\n 33% {\n opacity: 1;\n transform: translateX(0px);\n }\n 66% {\n opacity: 1;\n transform: translateX(0px);\n }\n 100% {\n opacity: 0;\n transform: translateX(300px);\n }\n }\n \n @-webkit-keyframes lol {\n 0% {\n opacity: 0;\n -webkit-transform: translateX(-300px);\n }\n 33% {\n opacity: 1;\n -webkit-transform: translateX(0px);\n }\n 66% {\n opacity: 1;\n -webkit-transform: translateX(0px);\n }\n 100% {\n opacity: 0;\n -webkit-transform: translateX(300px);\n -moz-transform: translateX(300px);\n }\n }\n \n .cs-loader-inner label:nth-child(6) {\n -webkit-animation: lol 3s infinite ease-in-out;\n -moz-animation: lol 3s infinite ease-in-out;\n animation: lol 3s infinite ease-in-out;\n }\n \n .cs-loader-inner label:nth-child(5) {\n -webkit-animation: lol 3s 100ms infinite ease-in-out;\n -moz-animation: lol 3s 100ms infinite ease-in-out;\n animation: lol 3s 100ms infinite ease-in-out;\n }\n \n .cs-loader-inner label:nth-child(4) {\n -webkit-animation: lol 3s 200ms infinite ease-in-out;\n -moz-animation: lol 3s 200ms infinite ease-in-out;\n animation: lol 3s 200ms infinite ease-in-out;\n }\n \n .cs-loader-inner label:nth-child(3) {\n -webkit-animation: lol 3s 300ms infinite ease-in-out;\n -moz-animation: lol 3s 300ms infinite ease-in-out;\n animation: lol 3s 300ms infinite ease-in-out;\n }\n \n .cs-loader-inner label:nth-child(2) {\n -webkit-animation: lol 3s 400ms infinite ease-in-out;\n -moz-animation: lol 3s 400ms infinite ease-in-out;\n animation: lol 3s 400ms infinite ease-in-out;\n }\n \n .cs-loader-inner label:nth-child(1) {\n -webkit-animation: lol 3s 500ms infinite ease-in-out;\n -moz-animation: lol 3s 500ms infinite ease-in-out;\n animation: lol 3s 500ms infinite ease-in-out;\n }\n </style>\n",Ge="close",Je="focus",Ze=function(){return s((function e(){o(this,e),this.description="Don't see the secure checkout browser? We'll help you re-launch the window to complete your purchase",this.title="Checkout",this.overlay=null,this.style=null,this.showControl=!0,this.showLoader=!0,this.eventEmitter=new Oe}),[{key:"initControl",value:function(){if(!this.isInit()&&this.showControl){if(!k.isSupportPopUp())return this.createLoader();this.createTemplate(),this.createStyles(),this.eventHandler()}}},{key:"initLoader",value:function(){!this.isInit()&&this.showLoader&&(this.createStyles(),this.createLoader())}},{key:"eventHandler",value:function(){var e=this,t=document.querySelector("[data-close]"),n=document.querySelector("[data-continue]");t&&se.subscribe("click",t,(function(){return e.eventEmitter.emit(Ge,{})})),n&&se.subscribe("click",n,(function(){return e.eventEmitter.emit(Je,{})}))}},{key:"clear",value:function(){(this.style||this.overlay)&&(this.style.parentNode.removeChild(this.style),this.overlay.parentNode.removeChild(this.overlay),this.style=null,this.overlay=null)}},{key:"createLoader",value:function(){var e=this,t=document.body||document.getElementsByTagName("body")[0];this.overlay=document.createElement("div"),this.overlay.classList.add("checkout-overlay"),this.overlay.setAttribute("checkout-overlay"," "),this.overlay.innerHTML=We+Ye,t.appendChild(this.overlay),setTimeout((function(){e.isInit()&&e.overlay.classList.add("display")}),5)}},{key:"createTemplate",value:function(){var e=this,t=document.body||document.getElementsByTagName("body")[0],n=String('\n <div class="checkout-container">\n <strong class="checkout-title" data-title>{{title}}</strong>\n <p data-description>{{description}}</p>\n <a href="#" data-continue>Continue</a>\n <a href="#" data-close>Close</a>\n </div>\n');n=(n=n.replace("{{description}}",this.description)).replace("{{title}}",this.title),this.overlay=document.createElement("div"),this.overlay.classList.add("checkout-overlay"),this.overlay.setAttribute("checkout-overlay"," "),this.overlay.innerHTML=n,t.appendChild(this.overlay),setTimeout((function(){e.isInit()&&e.overlay.classList.add("display")}),5)}},{key:"createStyles",value:function(){var e=document.head||document.getElementsByTagName("head")[0],t=String("\n .hide-continue-button [data-continue] {\n display: none;\n }\n\n .checkout-overlay .cs-loader-inner {\n color: #ddd;\n }\n\n .checkout-overlay {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(0,0,0, 0.5);\n text-align: center;\n color: #fff;\n opacity: 0;\n }\n .checkout-overlay.display {\n opacity: 1;\n transition: opacity 0.7s ease-out;\n }\n .checkout-overlay a { color: #00f; }\n .checkout-container {\n position: absolute;\n top: 50%;\n left: 0;\n width: 100%;\n margin-top: -{{width}}px;\n }\n .checkout-title {\n font-size: 24px;\n display: block;\n text-transform: uppercase;\n }\n [data-close] {\n position: fixed;\n right: 32px;\n top: 32px;\n width: 32px;\n height: 32px;\n opacity: 0.3;\n overflow: hidden;\n text-indent: -9999px;\n }\n [data-close]:hover { opacity: 1; }\n [data-close]:before, [data-close]:after {\n position: absolute;\n left: 15px;\n content: ' ';\n height: 33px;\n width: 2px;\n background-color: #00f;\n }\n [data-close]:before { transform: rotate(45deg); }\n [data-close]:after { transform: rotate(-45deg); }\n"),n=document.querySelector(".checkout-container");t=t.replace("{{width}}",n?String(n.offsetHeight/2):"0"),this.style=document.createElement("style"),this.style.type="text/css",this.style.appendChild(document.createTextNode(t)),e.appendChild(this.style)}},{key:"setBackdropDescription",value:function(e){this.description=e}},{key:"setBackdropTitle",value:function(e){this.title=e}},{key:"onTrigger",value:function(e,t){this.eventEmitter.subscribe(e,t)}},{key:"isInit",value:function(){return!(!this.overlay||!this.style)}},{key:"hideContinueControl",value:function(){this.isInit()&&this.overlay.classList.add("hide-continue-button")}},{key:"turnOffControl",value:function(){this.showControl=!1}},{key:"turnOffLoader",value:function(){this.showLoader=!1}}])}(),Xe=function(){return s((function e(){o(this,e),this.widgetEnv=new X(K)}),[{key:"error",value:function(e,t,n){n(!0)}},{key:"setEnv",value:function(e,t){this.widgetEnv.setEnv(e,t)}}])}();function $e(){return function(e){function n(){var e;o(this,n);for(var i=arguments.length,r=new Array(i),a=0;a<i;a++)r[a]=arguments[a];return(e=t(this,n,[].concat(r))).background=new Ze,e.background.onTrigger(Je,(function(){return e.continue()})),e.background.onTrigger(Ge,(function(){return e.stop()})),e}return l(n,e),s(n,[{key:"continue",value:function(){}},{key:"stop",value:function(){}},{key:"error",value:function(e,t,n){n(!0)}},{key:"setSuspendedRedirectUri",value:function(e){this.suspendedRedirectUri=e}},{key:"setBackgroundTitle",value:function(e){this.background.setBackdropTitle(e)}},{key:"setBackgroundDescription",value:function(e){this.background.setBackdropDescription(e)}},{key:"turnOffBackdrop",value:function(){this.background.turnOffControl(),this.background.turnOffLoader()}}])}(arguments.length>0&&void 0!==arguments[0]?arguments[0]:Xe)}!function(e){e.SUCCESS="success",e.DECLINED="declined",e.CLOSE="close",e.REFERRED="referred",e.ERROR="error"}(ze||(ze={}));var Qe="paydock-dispatcher",et=function(){return s((function e(t){o(this,e),this.messageSource=t,this.env=new X(K)}),[{key:"restartDispatcher",value:function(){var e=document.getElementById(Qe);e&&e.parentNode&&e.parentNode.removeChild(e);var t=document.createElement("iframe");t.setAttribute("src",this.env.getConf().url+"/dispatcher"),t.id=Qe,t.style.display="none",document.body.appendChild(t)}},{key:"on",value:function(e,t){var n=this;se.subscribe("message",window,(function(i){var r=null;try{r=JSON.parse(i.data)}catch(e){}r&&r.message_source===n.messageSource&&r.event===e&&t(r)}))}},{key:"setEnv",value:function(e,t){this.env.setEnv(e,t),this.restartDispatcher()}}])}(),tt="close",nt=function(){return s((function e(){o(this,e),this.configs={width:500,height:500,scrollbars:!0,resizable:!0,top:0,left:0},this.eventEmitter=new Oe}),[{key:"isExist",value:function(){return!(!this.getElement()||this.getElement().closed)}},{key:"getElement",value:function(){return this.window}},{key:"init",value:function(){var e=this;if(!k.isSupportPopUp())return this.window=window;var t=this.getConfigs();this.window=window.open("about:blank","_blank","noopener=false,width=".concat(t.width,",height=").concat(t.height,",top=").concat(t.top,",left=").concat(t.left,",scrollbars=").concat(t.scrollbars?"yes":"no",",resizable=").concat(t.resizable?"yes":"no")),this.showLoader();var n=setInterval((function(){e.isExist()||(clearInterval(n),e.eventEmitter.emit(tt,{}))}),200)}},{key:"redirect",value:function(e){this.isExist()&&(this.window.location.href=e)}},{key:"close",value:function(){this.isExist()&&this.getElement().close&&(this.getElement().close(),this.window=null)}},{key:"focus",value:function(){this.isExist()&&this.getElement().focus&&this.getElement().focus()}},{key:"setConfigs",value:function(e){this.configs=c(this.configs,e)}},{key:"getNetConfigs",value:function(){return c({},this.configs)}},{key:"getConfigs",value:function(){var e=this.getNetConfigs();return e.left=window.screenX+(window.screen.width/2-e.width/2),e.top=window.screenY+(window.screen.height/2-e.height/2),e}},{key:"onClose",value:function(e){this.eventEmitter.subscribe(tt,e)}},{key:"initError",value:function(e){this.getElement().document.write("."),(this.getElement().document.body||this.getElement().document.getElementsByTagName("body")[0]).innerHTML="<style>\n .error-wrapper {\n color: #ff0000;\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100%;\n }\n </style>"+'<div class="error-wrapper"><div>{{error}}</div></div>'.replace("{{error}}",e)}},{key:"showLoader",value:function(){this.getElement().document.write(".");var e=this.getElement().document.body||this.getElement().document.getElementsByTagName("body")[0];if(e.innerHTML=We+Ye,this.env===P&&this.env===R&&this.env===x&&this.env===I&&this.env===U&&this.env===L&&this.env===N&&this.env===D&&this.env===M&&this.env===H&&this.env===F&&this.env===B&&this.env===j&&this.env===z&&this.env===V&&this.env===q){var t=0;se.subscribe("click",e,(function(){5===++t&&(e.innerHTML='\n <style>\n html{width: 100%;height: 100%;}\n body{margin: 0px;padding: 0px;background-color: #111;}\n \n .eye{\n width: 20px; height: 8px;\n background-color: #eee;\n border-radius:0px 0px 20px 20px;\n position: relative;\n top: 40px;\n left: 10px;\n box-shadow: 40px 0px 0px 0px #eee; \n }\n \n .head{\n -webkit-backface-visibility: hidden;\n -moz-backface-visibility: hidden;\n backface-visibility: hidden; \n position: relative;\n margin: -250px auto;\n width: 80px; height: 80px;\n background-color: #111;\n border-radius:50px;\n box-shadow: inset -4px 2px 0px 0px #eee;\n -webkit-animation:node 1.5s infinite alternate;\n -webkit-animation-timing-function:ease-out;\n -moz-animation:node 1.5s infinite alternate;\n -moz-animation-timing-function:ease-out;\n animation:node 1.5s infinite alternate;\n animation-timing-function:ease-out;\n }\n .body{ \n position: relative;\n margin: 90px auto;\n width: 140px; height: 120px;\n background-color: #111;\n border-radius: 50px/25px ;\n box-shadow: inset -5px 2px 0px 0px #eee;\n -webkit-animation:node2 1.5s infinite alternate;\n -webkit-animation-timing-function:ease-out; \n -moz-animation:node2 1.5s infinite alternate;\n -moz-animation-timing-function:ease-out; \n animation:node2 1.5s infinite alternate;\n animation-timing-function:ease-out; \n }\n \n @keyframes node {0%{ top:0px; }50%{ top:10px; }100% { top:0px;} }\n @keyframes node2 {0%{ top:-5px; }50%{ top:10px; }100% { top:-5px;}}\n @-moz-keyframes node {0%{ top:0px; }50%{ top:10px; }100% { top:0px;} }\n @-moz-keyframes node2 {0%{ top:-5px; }50%{ top:10px; }100% { top:-5px;}}\n @-webkit-keyframes node {0%{ top:0px; }50%{ top:10px; }100% { top:0px;} }\n @-webkit-keyframes node2 {0%{ top:-5px; }50%{ top:10px; }100% { top:-5px;}}\n \n \n .circ{\n -webkit-backface-visibility: hidden;\n -moz-backface-visibility: hidden;\n backface-visibility: hidden;\n margin: 60px auto;\n width: 180px; height: 180px;\n background-color: #111;\n border-radius: 0px 0px 50px 50px;\n position: relative;\n z-index: -1; \n left: 0%;\n top: 20%;\n overflow: hidden;\n }\n \n .hands{\n -webkit-backface-visibility: hidden;\n -moz-backface-visibility: hidden;\n backface-visibility: hidden;\n margin-top: 140px;\n width: 120px;height: 120px;\n position: absolute;\n background-color: #111;\n border-radius:20px;\n box-shadow:-1px -4px 0px 0px #eee;\n transform:rotate(45deg);\n -webkit-transform:rotate(45deg);\n -mox-transform:rotate(45deg);\n top:75%;left: 16%;\n z-index: 1;\n -webkit-animation:node2 1.5s infinite alternate;\n -webkit-animation-timing-function:ease-out;\n -moz-animation:node2 1.5s infinite alternate;\n -moz-animation-timing-function:ease-out;\n animation:node2 1.5s infinite alternate;\n animation-timing-function:ease-out;\n }\n \n .load{ position: absolute;\n width: 100px; height: 20px;\n margin: -10px auto;\n -webkit-font-smoothing: antialiased;\n -moz-font-smoothing: antialiased;\n font-smoothing: antialiased;\n font-family: \'Julius Sans One\', sans-serif;\n font-size:30px;\n font-weight:400;\n color:#eee;\n left: 10%;\n top: 5%;\n }\n </style>\n\n <div class="circ">\n <div class="load">A little patience ...</div>\n <div class="hands"></div>\n <div class="body"></div>\n <div class="head">\n <div class="eye"></div>\n </div>\n </div>\n')}))}}},{key:"setEnv",value:function(e){this.env=e}}])}(),it=function(e){function n(e){var i;return o(this,n),(i=t(this,n)).publicKey=e,i.checkout=null,i.dispatcher=new et("checkout.paydock"),setTimeout((function(){return i.dispatcher.restartDispatcher()}),200),i.popup=new nt,i}return l(n,e),s(n,[{key:"run",value:function(){this.isRunning()||(this.popup.init(),this.background.initControl())}},{key:"isRunning",value:function(){return this.popup.isExist()}},{key:"next",value:function(e){this.checkout=e,k.isSupportPopUp()||window.localStorage.setItem("paydock_checkout_token",JSON.stringify(this.checkout)),this.popup.redirect(this.checkout.link)}},{key:"continue",value:function(){this.popup.focus()}},{key:"stop",value:function(){this.popup.close()}},{key:"onStop",value:function(e){var t=this;this.popup.onClose((function(){t.background.clear(),t.checkout=null,e()}))}},{key:"onCheckout",value:function(e,t){var n=this;this.dispatcher.on(e,(function(e){if(n.checkout&&n.checkout.reference_id===e.reference_id)n.background.clear(),t(n.checkout);else if(!k.isSupportPopUp()){var i=window.localStorage.getItem("paydock_checkout_token");if(!i)return;var r=JSON.parse(i);r&&r.reference_id===e.reference_id&&(window.localStorage.removeItem("paydock_checkout_token"),n.checkout=r,n.background.clear(),t(n.checkout))}}))}},{key:"setEnv",value:function(e,t){p(d(n.prototype),"setEnv",this).call(this,e,t),this.dispatcher.setEnv(e,t),this.popup.setEnv(e)}}])}($e());function rt(e){return"run"in e}function ot(e){return"setRedirectUrl"in e}!function e(t,n,i){function r(a,s){if(!n[a]){if(!t[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);var c=Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[a]={exports:{}};t[a][0].call(l.exports,(function(e){return r(t[a][1][e]||e)}),l,l.exports,e,t,n,i)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;a<i.length;a++)r(i[a]);return r}({1:[function(e,t,n){function i(){throw Error("setTimeout has not been defined")}function r(){throw Error("clearTimeout has not been defined")}function o(e){if(l===setTimeout)return setTimeout(e,0);if((l===i||!l)&&setTimeout)return l=setTimeout,setTimeout(e,0);try{return l(e,0)}catch(t){try{return l.call(null,e,0)}catch(t){return l.call(this,e,0)}}}function a(){v&&p&&(v=!1,p.length?f=p.concat(f):m=-1,f.length&&s())}function s(){if(!v){var e=o(a);v=!0;for(var t=f.length;t;){for(p=f,f=[];++m<t;)p&&p[m].run();m=-1,t=f.length}p=null,v=!1,function(e){if(d===clearTimeout)return clearTimeout(e);if((d===r||!d)&&clearTimeout)return d=clearTimeout,clearTimeout(e);try{return d(e)}catch(t){try{return d.call(null,e)}catch(t){return d.call(this,e)}}}(e)}}function u(e,t){this.fun=e,this.array=t}function c(){}var l,d,h=t.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:i}catch(e){l=i}try{d="function"==typeof clearTimeout?clearTimeout:r}catch(e){d=r}}();var p,f=[],v=!1,m=-1;h.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];f.push(new u(e,t)),1!==f.length||v||o(s)},u.prototype.run=function(){this.fun.apply(null,this.array)},h.title="browser",h.browser=!0,h.env={},h.argv=[],h.version="",h.versions={},h.on=c,h.addListener=c,h.once=c,h.off=c,h.removeListener=c,h.removeAllListeners=c,h.emit=c,h.prependListener=c,h.prependOnceListener=c,h.listeners=function(e){return[]},h.binding=function(e){throw Error("process.binding is not supported")},h.cwd=function(){return"/"},h.chdir=function(e){throw Error("process.chdir is not supported")},h.umask=function(){return 0}},{}],2:[function(e,t,n){(function(e){!function(e){if("function"==typeof bootstrap)bootstrap("promise",e);else if("object"==r(n)&&"object"==r(t))t.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeQ=e}else{if("undefined"==typeof window&&"undefined"==typeof self)throw Error("This environment was not anticipated by Q. Please file a bug.");var i="undefined"!=typeof window?window:self,o=i.Q;i.Q=e(),i.Q.noConflict=function(){return i.Q=o,this}}}((function(){function t(e){return function(){return x.apply(e,arguments)}}function n(e,t){if(S&&t.stack&&"object"==r(e)&&null!==e&&e.stack){for(var n=[],o=t;o;o=o.source)o.stack&&(!e.__minimumStackCounter__||e.__minimumStackCounter__>o.stackCounter)&&(M(e,"__minimumStackCounter__",{value:o.stackCounter,configurable:!0}),n.unshift(o.stack));n.unshift(e.stack),M(e,"stack",{value:function(e){for(var t=e.split("\n"),n=[],r=0;r<t.length;++r){var o=t[r];a(o)||i(o)||!o||n.push(o)}return n.join("\n")}(n.join("\n"+j+"\n")),configurable:!0})}}function i(e){return-1!==e.indexOf("(module.js:")||-1!==e.indexOf("(node.js:")}function o(e){var t=/at .+ \((.+):(\d+):(?:\d+)\)$/.exec(e);if(t)return[t[1],Number(t[2])];var n=/at ([^ ]+):(\d+):(?:\d+)$/.exec(e);if(n)return[n[1],Number(n[2])];var i=/.*@(.+):(\d+)$/.exec(e);return i?[i[1],Number(i[2])]:void 0}function a(e){var t=o(e);if(!t)return!1;var n=t[0],i=t[1];return n===T&&i>=A&&i<=G}function s(){if(S)try{throw Error()}catch(n){var e=n.stack.split("\n"),t=o(e[0].indexOf("@")>0?e[1]:e[2]);if(!t)return;return T=t[0],t[1]}}function u(e){var t,n;return e instanceof h?e:m(e)?(t=e,n=c(),u.nextTick((function(){try{t.then(n.resolve,n.reject,n.notify)}catch(e){n.reject(e)}})),n.promise):k(e)}function c(){function e(e){t=e,u.longStackSupport&&S&&(o.source=e),U(n,(function(t,n){u.nextTick((function(){e.promiseDispatch.apply(e,n)}))}),void 0),n=void 0,i=void 0}var t,n=[],i=[],r=D(c.prototype),o=D(h.prototype);if(o.promiseDispatch=function(e,r,o){var a=I(arguments);n?(n.push(a),"when"===r&&o[1]&&i.push(o[1])):u.nextTick((function(){t.promiseDispatch.apply(t,a)}))},o.valueOf=function(){if(n)return o;var e=f(t);return v(e)&&(t=e),e},o.inspect=function(){return t?t.inspect():{state:"pending"}},u.longStackSupport&&S)try{throw Error()}catch(e){o.stack=e.stack.substring(e.stack.indexOf("\n")+1),o.stackCounter=z++}return r.promise=o,r.resolve=function(n){t||e(u(n))},r.fulfill=function(n){t||e(k(n))},r.reject=function(n){t||e(g(n))},r.notify=function(e){t||U(i,(function(t,n){u.nextTick((function(){n(e)}))}),void 0)},r}function l(e){if("function"!=typeof e)throw TypeError("resolver must be a function.");var t=c();try{e(t.resolve,t.reject,t.notify)}catch(e){t.reject(e)}return t.promise}function d(e){return l((function(t,n){for(var i=0,r=e.length;i<r;i++)u(e[i]).then(t,n)}))}function h(e,t,n){void 0===t&&(t=function(e){return g(Error("Promise does not support operation: "+e))}),void 0===n&&(n=function(){return{state:"unknown"}});var i=D(h.prototype);if(i.promiseDispatch=function(n,r,o){var a;try{a=e[r]?e[r].apply(i,o):t.call(i,r,o)}catch(e){a=g(e)}n&&n(a)},i.inspect=n,n){var r=n();"rejected"===r.state&&(i.exception=r.reason),i.valueOf=function(){var e=n();return"pending"===e.state||"rejected"===e.state?i:e.value}}return i}function p(e,t,n,i){return u(e).then(t,n,i)}function f(e){if(v(e)){var t=e.inspect();if("fulfilled"===t.state)return t.value}return e}function v(e){return e instanceof h}function m(e){var t;return(t=e)===Object(t)&&"function"==typeof e.then}function y(){q.length=0,K.length=0,W||(W=!0)}function g(t){var n,i,o=h({when:function(n){return n&&function(t){if(W){var n=L(K,t);-1!==n&&("object"==r(e)&&"function"==typeof e.emit&&u.nextTick.runAfter((function(){var i=L(Y,t);-1!==i&&(e.emit("rejectionHandled",q[n],t),Y.splice(i,1))})),K.splice(n,1),q.splice(n,1))}}(this),n?n(t):this}},(function(){return this}),(function(){return{state:"rejected",reason:t}}));return n=o,i=t,W&&("object"==r(e)&&"function"==typeof e.emit&&u.nextTick.runAfter((function(){-1!==L(K,n)&&(e.emit("unhandledRejection",i,n),Y.push(n))})),K.push(n),i&&void 0!==i.stack?q.push(i.stack):q.push("(no stack) "+i)),o}function k(e){return h({when:function(){return e},get:function(t){return e[t]},set:function(t,n){e[t]=n},delete:function(t){delete e[t]},post:function(t,n){return null==t?e.apply(void 0,n):e[t].apply(e,n)},apply:function(t,n){return e.apply(t,n)},keys:function(){return F(e)}},void 0,(function(){return{state:"fulfilled",value:e}}))}function E(e,t,n){return u(e).spread(t,n)}function _(e,t,n){return u(e).dispatch(t,n)}function b(e){return p(e,(function(e){var t=0,n=c();return U(e,(function(i,r,o){var a;v(r)&&"fulfilled"===(a=r.inspect()).state?e[o]=a.value:(++t,p(r,(function(i){e[o]=i,0==--t&&n.resolve(e)}),n.reject,(function(e){n.notify({index:o,value:e})})))}),void 0),0===t&&n.resolve(e),n.promise}))}function w(e){if(0===e.length)return u.resolve();var t=u.defer(),n=0;return U(e,(function(i,r,o){var a=e[o];n++,p(a,(function(e){t.resolve(e)}),(function(e){0==--n&&(e.message="Q can't get fulfillment value from any promise, all promises were rejected. Last error message: "+e.message,t.reject(e))}),(function(e){t.notify({index:o,value:e})}))}),void 0),t.promise}function C(e){return p(e,(function(e){return e=N(e,u),p(b(N(e,(function(e){return p(e,P,P)}))),(function(){return e}))}))}var S=!1;try{throw Error()}catch(e){S=!!e.stack}var T,O,A=s(),P=function(){},R=function(){function t(){for(var e,t;i.next;)e=(i=i.next).task,i.task=void 0,(t=i.domain)&&(i.domain=void 0,t.enter()),n(e,t);for(;c.length;)n(e=c.pop());a=!1}function n(e,n){try{e()}catch(e){if(u)throw n&&n.exit(),setTimeout(t,0),n&&n.enter(),e;setTimeout((function(){throw e}),0)}n&&n.exit()}var i={task:void 0,next:null},o=i,a=!1,s=void 0,u=!1,c=[];if(R=function(t){o=o.next={task:t,domain:u&&e.domain,next:null},a||(a=!0,s())},"object"==r(e)&&"[object process]"===e.toString()&&e.nextTick)u=!0,s=function(){e.nextTick(t)};else if("function"==typeof setImmediate)s="undefined"!=typeof window?setImmediate.bind(window,t):function(){setImmediate(t)};else if("undefined"!=typeof MessageChannel){var l=new MessageChannel;l.port1.onmessage=function(){s=d,l.port1.onmessage=t,t()};var d=function(){l.port2.postMessage(0)};s=function(){setTimeout(t,0),d()}}else s=function(){setTimeout(t,0)};return R.runAfter=function(e){c.push(e),a||(a=!0,s())},R}(),x=Function.call,I=t(Array.prototype.slice),U=t(Array.prototype.reduce||function(e,t){var n=0,i=this.length;if(1===arguments.length)for(;;){if(n in this){t=this[n++];break}if(++n>=i)throw TypeError()}for(;n<i;n++)n in this&&(t=e(t,this[n],n));return t}),L=t(Array.prototype.indexOf||function(e){for(var t=0;t<this.length;t++)if(this[t]===e)return t;return-1}),N=t(Array.prototype.map||function(e,t){var n=this,i=[];return U(n,(function(r,o,a){i.push(e.call(t,o,a,n))}),void 0),i}),D=Object.create||function(e){function t(){}return t.prototype=e,new t},M=Object.defineProperty||function(e,t,n){return e[t]=n.value,e},H=t(Object.prototype.hasOwnProperty),F=Object.keys||function(e){var t=[];for(var n in e)H(e,n)&&t.push(n);return t},B=t(Object.prototype.toString);O="undefined"!=typeof ReturnValue?ReturnValue:function(e){this.value=e};var j="From previous event:";u.resolve=u,u.nextTick=R,u.longStackSupport=!1;var z=1;"object"==r(e)&&e&&e.env&&e.env.Q_DEBUG&&(u.longStackSupport=!0),u.defer=c,c.prototype.makeNodeResolver=function(){var e=this;return function(t,n){t?e.reject(t):arguments.length>2?e.resolve(I(arguments,1)):e.resolve(n)}},u.Promise=l,u.promise=l,l.race=d,l.all=b,l.reject=g,l.resolve=u,u.passByCopy=function(e){return e},h.prototype.passByCopy=function(){return this},u.join=function(e,t){return u(e).join(t)},h.prototype.join=function(e){return u([this,e]).spread((function(e,t){if(e===t)return e;throw Error("Q can't join: not the same: "+e+" "+t)}))},u.race=d,h.prototype.race=function(){return this.then(u.race)},u.makePromise=h,h.prototype.toString=function(){return"[object Promise]"},h.prototype.then=function(e,t,i){var r=this,o=c(),a=!1;return u.nextTick((function(){r.promiseDispatch((function(t){a||(a=!0,o.resolve(function(t){try{return"function"==typeof e?e(t):t}catch(e){return g(e)}}(t)))}),"when",[function(e){a||(a=!0,o.resolve(function(e){if("function"==typeof t){n(e,r);try{return t(e)}catch(e){return g(e)}}return g(e)}(e)))}])})),r.promiseDispatch(void 0,"when",[void 0,function(e){var t,n,r=!1;try{t=e,n="function"==typeof i?i(t):t}catch(e){if(r=!0,!u.onerror)throw e;u.onerror(e)}r||o.notify(n)}]),o.promise},u.tap=function(e,t){return u(e).tap(t)},h.prototype.tap=function(e){return e=u(e),this.then((function(t){return e.fcall(t).thenResolve(t)}))},u.when=p,h.prototype.thenResolve=function(e){return this.then((function(){return e}))},u.thenResolve=function(e,t){return u(e).thenResolve(t)},h.prototype.thenReject=function(e){return this.then((function(){throw e}))},u.thenReject=function(e,t){return u(e).thenReject(t)},u.nearer=f,u.isPromise=v,u.isPromiseAlike=m,u.isPending=function(e){return v(e)&&"pending"===e.inspect().state},h.prototype.isPending=function(){return"pending"===this.inspect().state},u.isFulfilled=function(e){return!v(e)||"fulfilled"===e.inspect().state},h.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},u.isRejected=function(e){return v(e)&&"rejected"===e.inspect().state},h.prototype.isRejected=function(){return"rejected"===this.inspect().state};var V,q=[],K=[],Y=[],W=!0;u.resetUnhandledRejections=y,u.getUnhandledReasons=function(){return q.slice()},u.stopUnhandledRejectionTracking=function(){y(),W=!1},y(),u.reject=g,u.fulfill=k,u.master=function(e){return h({isDef:function(){}},(function(t,n){return _(e,t,n)}),(function(){return u(e).inspect()}))},u.spread=E,h.prototype.spread=function(e,t){return this.all().then((function(t){return e.apply(void 0,t)}),t)},u.async=function(e){return function(){function t(e,t){var o,a;if("undefined"==typeof StopIteration){try{o=n[e](t)}catch(e){return g(e)}return o.done?u(o.value):p(o.value,i,r)}try{o=n[e](t)}catch(e){return"[object StopIteration]"===B(a=e)||a instanceof O?u(e.value):g(e)}return p(o,i,r)}var n=e.apply(this,arguments),i=t.bind(t,"next"),r=t.bind(t,"throw");return i()}},u.spawn=function(e){u.done(u.async(e)())},u.return=function(e){throw new O(e)},u.promised=function(e){return function(){return E([this,b(arguments)],(function(t,n){return e.apply(t,n)}))}},u.dispatch=_,h.prototype.dispatch=function(e,t){var n=this,i=c();return u.nextTick((function(){n.promiseDispatch(i.resolve,e,t)})),i.promise},u.get=function(e,t){return u(e).dispatch("get",[t])},h.prototype.get=function(e){return this.dispatch("get",[e])},u.set=function(e,t,n){return u(e).dispatch("set",[t,n])},h.prototype.set=function(e,t){return this.dispatch("set",[e,t])},u.del=u.delete=function(e,t){return u(e).dispatch("delete",[t])},h.prototype.del=h.prototype.delete=function(e){return this.dispatch("delete",[e])},u.mapply=u.post=function(e,t,n){return u(e).dispatch("post",[t,n])},h.prototype.mapply=h.prototype.post=function(e,t){return this.dispatch("post",[e,t])},u.send=u.mcall=u.invoke=function(e,t){return u(e).dispatch("post",[t,I(arguments,2)])},h.prototype.send=h.prototype.mcall=h.prototype.invoke=function(e){return this.dispatch("post",[e,I(arguments,1)])},u.fapply=function(e,t){return u(e).dispatch("apply",[void 0,t])},h.prototype.fapply=function(e){return this.dispatch("apply",[void 0,e])},u.try=u.fcall=function(e){return u(e).dispatch("apply",[void 0,I(arguments,1)])},h.prototype.fcall=function(){return this.dispatch("apply",[void 0,I(arguments)])},u.fbind=function(e){var t=u(e),n=I(arguments,1);return function(){return t.dispatch("apply",[this,n.concat(I(arguments))])}},h.prototype.fbind=function(){var e=this,t=I(arguments);return function(){return e.dispatch("apply",[this,t.concat(I(arguments))])}},u.keys=function(e){return u(e).dispatch("keys",[])},h.prototype.keys=function(){return this.dispatch("keys",[])},u.all=b,h.prototype.all=function(){return b(this)},u.any=w,h.prototype.any=function(){return w(this)},u.allResolved=(V=C,function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn("allResolved is deprecated, use allSettled instead.",Error("").stack),V.apply(V,arguments)}),h.prototype.allResolved=function(){return C(this)},u.allSettled=function(e){return u(e).allSettled()},h.prototype.allSettled=function(){return this.then((function(e){return b(N(e,(function(e){function t(){return e.inspect()}return(e=u(e)).then(t,t)})))}))},u.fail=u.catch=function(e,t){return u(e).then(void 0,t)},h.prototype.fail=h.prototype.catch=function(e){return this.then(void 0,e)},u.progress=function(e,t){return u(e).then(void 0,void 0,t)},h.prototype.progress=function(e){return this.then(void 0,void 0,e)},u.fin=u.finally=function(e,t){return u(e).finally(t)},h.prototype.fin=h.prototype.finally=function(e){if(!e||"function"!=typeof e.apply)throw Error("Q can't apply finally callback");return e=u(e),this.then((function(t){return e.fcall().then((function(){return t}))}),(function(t){return e.fcall().then((function(){throw t}))}))},u.done=function(e,t,n,i){return u(e).done(t,n,i)},h.prototype.done=function(t,i,o){var a=function(e){u.nextTick((function(){if(n(e,s),!u.onerror)throw e;u.onerror(e)}))},s=t||i||o?this.then(t,i,o):this;"object"==r(e)&&e&&e.domain&&(a=e.domain.bind(a)),s.then(void 0,a)},u.timeout=function(e,t,n){return u(e).timeout(t,n)},h.prototype.timeout=function(e,t){var n=c(),i=setTimeout((function(){t&&"string"!=typeof t||((t=Error(t||"Timed out after "+e+" ms")).code="ETIMEDOUT"),n.reject(t)}),e);return this.then((function(e){clearTimeout(i),n.resolve(e)}),(function(e){clearTimeout(i),n.reject(e)}),n.notify),n.promise},u.delay=function(e,t){return void 0===t&&(t=e,e=void 0),u(e).delay(t)},h.prototype.delay=function(e){return this.then((function(t){var n=c();return setTimeout((function(){n.resolve(t)}),e),n.promise}))},u.nfapply=function(e,t){return u(e).nfapply(t)},h.prototype.nfapply=function(e){var t=c(),n=I(e);return n.push(t.makeNodeResolver()),this.fapply(n).fail(t.reject),t.promise},u.nfcall=function(e){var t=I(arguments,1);return u(e).nfapply(t)},h.prototype.nfcall=function(){var e=I(arguments),t=c();return e.push(t.makeNodeResolver()),this.fapply(e).fail(t.reject),t.promise},u.nfbind=u.denodeify=function(e){if(void 0===e)throw Error("Q can't wrap an undefined function");var t=I(arguments,1);return function(){var n=t.concat(I(arguments)),i=c();return n.push(i.makeNodeResolver()),u(e).fapply(n).fail(i.reject),i.promise}},h.prototype.nfbind=h.prototype.denodeify=function(){var e=I(arguments);return e.unshift(this),u.denodeify.apply(void 0,e)},u.nbind=function(e,t){var n=I(arguments,2);return function(){var i=n.concat(I(arguments)),r=c();return i.push(r.makeNodeResolver()),u((function(){return e.apply(t,arguments)})).fapply(i).fail(r.reject),r.promise}},h.prototype.nbind=function(){var e=I(arguments,0);return e.unshift(this),u.nbind.apply(void 0,e)},u.nmapply=u.npost=function(e,t,n){return u(e).npost(t,n)},h.prototype.nmapply=h.prototype.npost=function(e,t){var n=I(t||[]),i=c();return n.push(i.makeNodeResolver()),this.dispatch("post",[e,n]).fail(i.reject),i.promise},u.nsend=u.nmcall=u.ninvoke=function(e,t){var n=I(arguments,2),i=c();return n.push(i.makeNodeResolver()),u(e).dispatch("post",[t,n]).fail(i.reject),i.promise},h.prototype.nsend=h.prototype.nmcall=h.prototype.ninvoke=function(e){var t=I(arguments,1),n=c();return t.push(n.makeNodeResolver()),this.dispatch("post",[e,t]).fail(n.reject),n.promise},u.nodeify=function(e,t){return u(e).nodeify(t)},h.prototype.nodeify=function(e){if(!e)return this;this.then((function(t){u.nextTick((function(){e(null,t)}))}),(function(t){u.nextTick((function(){e(t)}))}))},u.noConflict=function(){throw Error("Q.noConflict only works when Q is used as a global")};var G=s();return u}))}).call(this,e("_process"))},{_process:1}],3:[function(e,t,n){var i=function(e){switch(r(e)){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,n,o){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==r(e)?Object.keys(e).map((function(r){var o=encodeURIComponent(i(r))+n;return Array.isArray(e[r])?e[r].map((function(e){return o+encodeURIComponent(i(e))})).join(t):o+encodeURIComponent(i(e[r]))})).join(t):o?encodeURIComponent(i(o))+n+encodeURIComponent(i(e)):""}},{}],4:[function(e,t,n){function i(e){return e&&e.__esModule?e:{default:e}}function r(e,t,n){return l.default.information("zip:checkout:init"),d.default.Promise((function(t,n){return e.onCheckout(t,n,{})})).then((function(i){var r=i.redirect_uri||i.redirectUri||i.data&&(i.data.redirect_uri||i.data.redirectUri);if(!r)return l.default.debug("zip:checkout:error","Response does not contain redirectUri property"),n(i),void e.onError({code:"checkout_error",message:"The response does not contain the redirectUri property",detail:i});l.default.debug("zip:checkout:success",i),t({redirectUri:r})})).catch((function(t){l.default.debug("zip:checkout:error",t),n(t),e.onError({code:"checkout_error",message:"Checkout response error",detail:t})}))}Object.defineProperty(n,"__esModule",{value:!0}),n.Checkout=void 0;var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),a=i(e("./modal")),s=i(e("./options")),u=i(e("./utility")),l=i(e("./console")),d=i((e("./events"),e("q"))),h=function(){function e(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e)}return o(e,null,[{key:"init",value:function(e){var t,n;if("function"!=typeof Object.assign&&(Object.assign=function(e){if(null==e)throw TypeError("Cannot convert undefined or null to object");e=Object(e);for(var t=1;t<arguments.length;t++){var n=arguments[t];if(null!=n)for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}),e=c({},s.default,e),!this._validate(e))return l.default.setLevel(e.logLevel),e.redirect?r(e,(function(t){return e.redirectFn(t.redirectUri)})):(t=e,(n=new a.default).onClose=t.onComplete.bind(t),n.build(),void r(t,(function(e){return n.setUri(e.redirectUri)}),(function(e){return n.close(!1)})))}},{key:"attachButton",value:function(e,t){var n=document.querySelectorAll(e);if(!n.length)return config.onError({code:"attach_error",message:"Cannot find button to attach zipMoney checkout"});for(var i=0;i<n.length;i++)u.default.addEventHandler(n[i],"click",(function(){return Zip.Checkout.init(t)}))}},{key:"_validate",value:function(e){return 0>["error","information","debug"].indexOf(e.logLevel.toLowerCase())&&(e.logLevel="error"),0>["standard","express"].indexOf(e.request.toLowerCase())&&(e.request="standard"),e.onComplete=e.onComplete||function(){},e.onError=e.onError||function(){},e.checkoutUri||e.onCheckout!==s.default.onCheckout?"express"===e.request?e.onError({code:"not_implemented",message:"This feature is not yet implemented"}):e.redirect||e.onComplete!==s.default.onComplete||e.redirectUri?void 0:e.onError({code:"validation",message:"if onComplete function is not specified then redirectUri must be specified"}):e.onError({code:"validation",message:"if onCheckout function is not specified then checkoutUri must be specified"})}}]),e}();n.Checkout=h},{"./console":5,"./events":6,"./modal":8,"./options":9,"./utility":10,q:2}],5:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});var i="error";n.default={error:function(){var e;(e=window.console).log.apply(e,arguments)},information:function(){var e;"error"!==i&&(e=window.console).log.apply(e,arguments)},debug:function(){var e;"debug"===i&&(e=window.console).log.apply(e,arguments)},setLevel:function(e){i=e}}},{}],6:[function(e,t,n){(function(t){Object.defineProperty(n,"__esModule",{value:!0}),n.EventListener=void 0;var i,r=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();if(((i=e("./utility"))&&i.__esModule?i:{default:i}).default.isIe){var o=function(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n};o.prototype=t.Event.prototype,t.CustomEvent=o}var a={},s=n.EventListener=function(){function e(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e)}return r(e,null,[{key:"constructor",value:function(){a={}}},{key:"on",value:function(e,t){a[e]=t}},{key:"off",value:function(e){a[e]=null}}]),e}();s.Event=function(e,t){this.eventType=e,this.data=t||{}},s.Event.eventTypes={resize:"resize",transition:"transition",close:"close",complete:"complete",clear:"clear"};var u=window.addEventListener?"addEventListener":"attachEvent",c=window[u];c("attachEvent"==u?"onmessage":"message",(function(e){var n,i;e.data.zipmoney&&(n=e.data.msg,i=new t.CustomEvent("zipmoney",{detail:n}),t.dispatchEvent(i))}),!1),c("zipmoney",(function(e){var t,n=a[e.detail.eventType];n?n(e.detail.data||{}):(t=e,console.log("Unexpected Event",t))}),!1)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./utility":10}],7:[function(e,t,n){(function(t){var n=e("./checkout"),i=e("./events");t.Zip=t.Zip||{},t.Zip.Checkout=n.Checkout,t.zipMoneyEvent=i.EventListener.ZipEvent}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./checkout":4,"./events":6}],8:[function(e,t,n){function i(e){return e&&e.__esModule?e:{default:e}}function r(){return Math.max(document.documentElement.clientHeight,window.innerHeight||0)}function o(){var e=document.body,t=document.documentElement;return Math.max(e.scrollHeight,e.offsetHeight,t.clientHeight,t.scrollHeight,t.offsetHeight)}function a(e){for(var t=document.querySelectorAll("html, body"),n=0;n<t.length;n++)t[n].style.overflowY=e}function s(e){var t=document.body.currentStyle||window.getComputedStyle(document.body),n=document.body.offsetHeight+(parseInt(t.marginTop,10)+parseInt(t.marginBottom,10))-parseInt(t.height,10);document.body.style.height=e-n+"px"}Object.defineProperty(n,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),l=i(e("./utility")),d=e("./events"),h=(i(e("./console")),{iframeWidth:400,iframeMinWidth:320,iframeInitialHeight:704,iframeMinHeight:600,verticalMargin:35}),p=["resize","transition","close","complete","clear"],f="https://d3k1w8lx8mqizo.cloudfront.net/zm/",v=function(){function e(){var t=this;(function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")})(this,e),this._events=[],this._isMobile=l.default.isMobileDevice(),p.forEach((function(e){return d.EventListener.on(d.EventListener.Event.eventTypes[e],t[e].bind(t))}))}return u(e,[{key:"build",value:function(){this._initialHtmlHeight=o(),window.scrollTo(0,0);var e=this._frame=(t=this._frameUri,n=this._isMobile,(i=document.createElement("iframe")).id="zipmoney-iframe",i.frameborder=0,c(i.style,{padding:"0",border:"none",zIndex:"999999",backgroundColor:"#FFF",backgroundImage:"url("+f+"spinner.gif)",backgroundRepeat:"no-repeat",backgroundPosition:"50% 50%"}),c(i.style,n?{overflow:"scroll",width:"100%",height:"100%",position:"absolute",top:"0",bottom:"0",left:"0",right:"0",margin:"0"}:{width:h.iframeWidth+"px",minWidth:h.iframeMinWidth+"px",height:h.iframeInitialHeight+"px",margin:h.verticalMargin+"px auto 0 auto",display:"table-row",backgroundSize:"25%",textAlign:"center",boxShadow:"0px 0px 70px 0px rgb(0, 0, 0)"}),i.src=t||"",i);if(!this._isMobile){var t,n,i,r,u,l=((r=document.createElement("img")).src=f+"icon-close.png",c(r.style,{width:"50px",height:"50px",position:"absolute",top:"20px",right:"20px",cursor:"pointer"}),r);l.onclick=this.close.bind(this),this._overlay=((u=document.createElement("div")).className="zipmoney-overlay",c(u.style,{position:"absolute",left:"0",top:"0",display:"table-cell",textAlign:"center",verticalAlign:"middle",background:"rgba(0, 0, 0, 0.75)",zIndex:"10000",height:"100%",width:"100%"}),u),this._overlay.appendChild(l),this._overlay.appendChild(this._frame),e=this._overlay}document.body.appendChild(e),this._isMobile&&s(this._frame.offsetHeight),a("auto"),this._startMonitoringWindowResize()}},{key:"setUri",value:function(e){this._frameUri=e,this._frame&&(this._frame.src=e)}},{key:"resize",value:function(e){var t=this._isMobile?16:0,n=(e=e>=h.iframeMinHeight?e:h.iframeMinHeight,(e+=t)+2*h.verticalMargin),i=r();this._frame.style.height=e+"px",this._overlay&&(this._overlay.style.height=Math.max(i,this._initialHtmlHeight,n)+"px"),this._isMobile&&s(e)}},{key:"transition",value:function(){window.scroll(0,0)}},{key:"close",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t={state:"cancelled"};this._events.length&&(t=this._events.pop()),this._destroy(),this.onClose&&e&&this.onClose(t)}},{key:"complete",value:function(e){this._events.push(e)}},{key:"clear",value:function(e){this._events=[]}},{key:"_startMonitoringWindowResize",value:function(){var e=this;this._resizeHandler=l.default.debounce((function(){var t,n,i,a;return t=e,n=r(),i=o(),a=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,t._overlay&&(t._overlay.style.height=Math.max(n,i)+"px"),void(t._isMobile||a<h.iframeWidth?t._frame.style.width="100%":t._frame.style.width=h.iframeWidth+"px")}),250),l.default.addEventHandler(window,"resize",this._resizeHandler)}},{key:"_stopMonitoringWindowResize",value:function(){l.default.removeEventHandler(window,"resize",this._resizeHandler)}},{key:"_destroy",value:function(){this._stopMonitoringWindowResize(),this._overlay?document.body.removeChild(this._overlay):document.body.removeChild(this._frame),this._isMobile&&(document.body.style.height="initial"),a("initial"),this._overlay=this._frame=null,p.forEach((function(e){return d.EventListener.off(d.EventListener.Event.eventTypes[e])}))}}]),e}();n.default=v},{"./console":5,"./events":6,"./utility":10}],9:[function(e,t,n){function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var r=i(e("./xr")),o=i(e("./console"));r.default.configure({headers:{"X-Requested-With":"XMLHttpRequest"}}),n.default={request:"standard",redirect:!1,logLevel:"Error",onCheckout:function(e,t,n){r.default.post(this.checkoutUri).then((function(t){return e(t.data)})).catch(t)},onShippingAddressChanged:function(e,t,n){r.default.post(this.shippingUri).then(e).catch(t)},onComplete:function(e){if(o.default.information("zip:completed",e),"cancelled"!==e.state){var t=e.checkoutId?"&checkoutId="+e.checkoutId:"";this.redirectFn(this.redirectUri+"?result="+e.state+t)}},onError:function(e){o.default.error(e)},redirectFn:function(e){window.location.href=e}}},{"./console":5,"./xr":11}],10:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),r=function(){function e(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e)}return i(e,null,[{key:"isIe",value:function(){var e=-1,t=window.navigator.userAgent,n=t.indexOf("MSIE "),i=t.indexOf("Trident/");if(n>0)e=parseInt(t.substring(n+5,t.indexOf(".",n)),10);else if(i>0){var r=t.indexOf("rv:");e=parseInt(t.substring(r+3,t.indexOf(".",r)),10)}return e>-1?e:void 0}},{key:"isMobileDevice",value:function(){var e=navigator.userAgent||navigator.vendor||window.opera;return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4))}},{key:"debounce",value:function(e,t){var n;return function(){var i=this,r=arguments,o=!n;clearTimeout(n),n=setTimeout((function(){n=null,e.apply(i,r)}),t),o&&e.apply(i,r)}}},{key:"addEventHandler",value:function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent&&e.attachEvent("on"+t,n)}},{key:"removeEventHandler",value:function(e,t,n){e.removeEventListener?e.removeEventListener(t,n,!1):e.detachEvent&&e.detachEvent("on"+t,n)}}]),e}();n.default=r},{}],11:[function(e,t,n){function i(e){return e&&e.__esModule?e:{default:e}}function o(e,t){return{status:e.status,response:e.response,data:t,xhr:e}}function a(e){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];for(var r in n)if({}.hasOwnProperty.call(n,r)){var o=n[r];if("object"===(void 0===o?"undefined":u(o)))for(var a in o)({}).hasOwnProperty.call(o,a)&&(e[a]=o[a])}return e}function s(e){var t,n;return n=function(t,n){var i=a({},p,f,e),r=i.xmlHttpRequest();for(var s in i.abort&&e.abort((function(){n(o(r)),r.abort()})),r.open(i.method,i.params?i.url.split("?")[0]+"?"+(0,c.default)(i.params):i.url,!0),r.withCredentials=i.withCredentials,r.addEventListener(h.LOAD,(function(){if(r.status>=200&&r.status<300){var e=null;r.responseText&&(e=!0===i.raw?r.responseText:i.load(r.responseText)),t(o(r,e))}else n(o(r))})),r.addEventListener(h.ABORT,(function(){return n(o(r))})),r.addEventListener(h.ERROR,(function(){return n(o(r))})),r.addEventListener(h.TIMEOUT,(function(){return n(o(r))})),i.headers)({}).hasOwnProperty.call(i.headers,s)&&r.setRequestHeader(s,i.headers[s]);for(var l in i.events)({}).hasOwnProperty.call(i.events,l)&&r.addEventListener(l,i.events[l].bind(null,r),!1);var d="object"!==u(i.data)||i.raw?i.data:i.dump(i.data);void 0!==d?r.send(d):r.send()},((t=e)&&t.promise?t.promise:f.promise||p.promise)(n)}Object.defineProperty(n,"__esModule",{value:!0});var u="function"==typeof Symbol&&"symbol"==r(Symbol.iterator)?function(e){return r(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":r(e)},c=i(e("querystring/encode")),l=i(e("q")),d={GET:"GET",POST:"POST",PUT:"PUT",DELETE:"DELETE",PATCH:"PATCH",OPTIONS:"OPTIONS"},h={READY_STATE_CHANGE:"readystatechange",LOAD_START:"loadstart",PROGRESS:"progress",ABORT:"abort",ERROR:"error",LOAD:"load",TIMEOUT:"timeout",LOAD_END:"loadend"},p={method:d.GET,data:void 0,headers:{Accept:"application/json","Content-Type":"application/json"},dump:JSON.stringify,load:JSON.parse,xmlHttpRequest:function(){return new XMLHttpRequest},promise:function(e){return l.default.Promise(e)},withCredentials:!1},f={};s.assign=a,s.encode=c.default,s.configure=function(e){f=a({},f,e)},s.Methods=d,s.Events=h,s.defaults=p,s.get=function(e,t,n){return s(a({url:e,method:d.GET,params:t},n))},s.put=function(e,t,n){return s(a({url:e,method:d.PUT,data:t},n))},s.post=function(e,t,n){return s(a({url:e,method:d.POST,data:t},n))},s.patch=function(e,t,n){return s(a({url:e,method:d.PATCH,data:t},n))},s.del=function(e,t){return s(a({url:e,method:d.DELETE},t))},s.options=function(e,t){return s(a({url:e,method:d.OPTIONS},t))},n.default=s},{q:2,"querystring/encode":3}]},{},[7]);var at,st=function(e){function n(){var e;return o(this,n),(e=t(this,n)).apiEnv=new X(Y),e}return l(n,e),s(n,[{key:"setEnv",value:function(e,t){p(d(n.prototype),"setEnv",this).call(this,e,t),this.apiEnv.setEnv(e,t)}},{key:"getCheckoutUri",value:function(e){return this.apiEnv.getConf().url+"/v1/echo?"+ne.serialize({json_body:JSON.stringify({redirect_uri:e})})}}])}(Xe),ut=function(e){function n(){var e;return o(this,n),(e=t(this,n)).runs=!1,e.eventEmitter=new Oe,e}return l(n,e),s(n,[{key:"run",value:function(){this.runs=!0,this.background.initLoader()}},{key:"isRunning",value:function(){return this.runs}},{key:"next",value:function(e){var t=this;this.background.clear(),this.checkout=e;var n=this.getCheckoutUri(this.checkout.link);Zip.Checkout.init({checkoutUri:n,onComplete:function(e){return t.eventHandler(e)},onError:function(e){return t.eventHandler(e)}})}},{key:"getSuccessRedirectUri",value:function(){return this.suspendedRedirectUri?this.suspendedRedirectUri:this.widgetEnv.getConf().url+String("/checkout/zipmoney/suspended")}},{key:"getErrorRedirectUri",value:function(){return this.getSuccessRedirectUri()}},{key:"stop",value:function(){p(d(n.prototype),"stop",this).call(this),this.runs=!1;var e=document.querySelector(".zipmoney-overlay");e&&e.remove(),this.eventEmitter.emit(ze.CLOSE)}},{key:"onStop",value:function(e){var t=this;this.eventEmitter.subscribe(ze.CLOSE,(function(){t.background.clear(),e()}))}},{key:"onCheckout",value:function(e,t){var n=this;this.eventEmitter.subscribe(e,(function(){t(n.checkout)}))}},{key:"eventHandler",value:function(e){switch(this.runs=!1,e.state){case"approved":this.eventEmitter.emit(ze.CLOSE),this.eventEmitter.emit(ze.SUCCESS);break;case"declined":this.eventEmitter.emit(ze.CLOSE),this.eventEmitter.emit(ze.DECLINED);break;case"cancelled":this.eventEmitter.emit(ze.CLOSE);break;case"referred":this.eventEmitter.emit(ze.CLOSE),this.eventEmitter.emit(ze.REFERRED);break;default:console.warn("".concat("[CheckoutButton:Zipmoney]"," Unknown gateway status."))}}}])}($e(st)),ct="[Paydock:StorageDispatcher]";!function(e){e.WIDGET_SESSION="widget-session"}(at||(at={}));var lt,dt,ht=function(){return s((function e(t){o(this,e),this.messageSource=t,this.defaultPayload={destination:"widget.paydock"},this.env=new X(K),this.defaultPayload.source=t,this.iframeEvent=new de(window)}),[{key:"create",value:function(e){this.onLoadCallback=e,this.dispatcherFrame&&this.destroy(),this.widgetId=ie.generate(),this.setupIframeEventListeners();var t=document.createElement("iframe");return t.setAttribute("src",this.env.getConf().url+"/storage-dispatcher"+"?widgetId=".concat(this.widgetId)),t.setAttribute("id","pd-storage-dispatcher"),t.style.display="none",document.body.appendChild(t),this.dispatcherFrame=t,console.info("".concat(ct," initialized.")),t}},{key:"destroy",value:function(){this.dispatcherFrame&&this.dispatcherFrame.parentNode&&this.dispatcherFrame.parentNode.removeChild(this.dispatcherFrame),this.iframeEvent.clear(),this.widgetId=void 0,this.dispatcherFrame=void 0}},{key:"push",value:function(e,t){var n;if(this.pushCallbacks=t,this.dispatcherFrame){var i=c(c({},this.defaultPayload),e);null===(n=this.dispatcherFrame.contentWindow)||void 0===n||n.postMessage(i,this.env.getConf().url)}else console.error("".concat(ct," dispatcher is not initialized."))}},{key:"setEnv",value:function(e,t){this.env.setEnv(e,t),this.create(this.onLoadCallback)}},{key:"setupIframeEventListeners",value:function(){var e=this;this.widgetId&&(this.iframeEvent.on(le.AFTER_LOAD,this.widgetId,(function(t){var n;null===(n=e.onLoadCallback)||void 0===n||n.call(e)})),this.iframeEvent.on(le.DISPATCH_SUCCESS,this.widgetId,(function(t){var n,i;null===(i=null===(n=e.pushCallbacks)||void 0===n?void 0:n.onSuccess)||void 0===i||i.call(n)})),this.iframeEvent.on(le.DISPATCH_ERROR,this.widgetId,(function(t){var n,i;null===(i=null===(n=e.pushCallbacks)||void 0===n?void 0:n.onError)||void 0===i||i.call(n)})))}}])}(),pt=function(e){function n(){var e;return o(this,n),(e=t(this,n)).storageDispatcher=new ht("zipmoney.checkout.paydock"),e}return l(n,e),s(n,[{key:"getProxyRedirectUrl",value:function(){return this.widgetEnv.getConf().url+"/checkout/zipmoney/response"}},{key:"next",value:function(e,t){var n=this;this.storageDispatcher.create((function(){var i={merchant_redirect_url:n.getRedirectUrl(),checkout_token:e.token,public_key:t.public_key,gateway_id:t.gateway_id};n.storageDispatcher.push({intent:at.WIDGET_SESSION,data:i},{onSuccess:function(){var t=n.getCheckoutUri(e.link);Zip.Checkout.init({checkoutUri:t,redirect:!0})},onError:function(){console.error("Error initializing Zip Checkout")}})}))}},{key:"getSuccessRedirectUri",value:function(){return this.getProxyRedirectUrl()}},{key:"getErrorRedirectUri",value:function(){return this.getProxyRedirectUrl()}},{key:"setEnv",value:function(e,t){p(d(n.prototype),"setEnv",this).call(this,e,t),this.storageDispatcher.setEnv(e,t)}}])}(function(){return function(e){function n(){return o(this,n),t(this,n,arguments)}return l(n,e),s(n,[{key:"setRedirectUrl",value:function(e){this.merchantRedirectUrl=e}},{key:"getRedirectUrl",value:function(){return this.merchantRedirectUrl}},{key:"error",value:function(e,t,n){n(!1)}}])}(arguments.length>0&&void 0!==arguments[0]?arguments[0]:Xe)}(st)),ft=function(e){function n(){return o(this,n),t(this,n,arguments)}return l(n,e),s(n,[{key:"getSuccessRedirectUri",value:function(){return this.widgetEnv.getConf().url+ne.extendSearchParams("/checkout/success","merchant",encodeURIComponent(window.location.href))}},{key:"getErrorRedirectUri",value:function(){return this.widgetEnv.getConf().url+ne.extendSearchParams("/checkout/error","merchant",encodeURIComponent(window.location.href))}}])}(it),vt=function(e){function n(){return o(this,n),t(this,n,arguments)}return l(n,e),s(n,[{key:"getSuccessRedirectUri",value:function(){return this.widgetEnv.getConf().url+"/checkout/afterpay/merchant/{{merchant}}/success".replace("{{merchant}}",encodeURIComponent(window.btoa(window.location.href)))}},{key:"getErrorRedirectUri",value:function(){return this.widgetEnv.getConf().url+"/checkout/afterpay/merchant/{{merchant}}/error".replace("{{merchant}}",encodeURIComponent(window.btoa(window.location.href)))}},{key:"next",value:function(e,t){this.checkout=e,k.isSupportPopUp()||window.localStorage.setItem("paydock_checkout_token",JSON.stringify(this.checkout)),this.popup.redirect(this.getRedirectUrl(this.checkout,t))}},{key:"error",value:function(e,t,n){return!t||t&&"invalid_amount"!==t?n(!0):(this.popup.initError(e),n(!1))}},{key:"run",value:function(){this.isRunning()||(this.popup.setConfigs({width:420,height:715}),this.popup.init(),this.background.initControl())}},{key:"getRedirectUrl",value:function(e,t){return this.widgetEnv.getConf().url+"/checkout/afterpay/init?"+ne.serialize(c(c({},t),{token:e.reference_id,env:"live"===e.mode?"live":"test"}))}}])}(it),mt={EXTERNAL_CHECKOUT_TOKEN:"external_checkout_token",CHECKOUT_TOKEN:"checkout_token",BANK_ACCOUNT:"bank_account",CARD:"card"},yt=function(e){function n(e,i){var r,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:mt.CARD;switch(o(this,n),(r=t(this,n)).body={gateway_id:e,type:a},a){case mt.CARD:case mt.BANK_ACCOUNT:delete i.gateway_id,delete i.type,delete i.checkout_token,r.body=c(r.body,i);break;case mt.CHECKOUT_TOKEN:case mt.EXTERNAL_CHECKOUT_TOKEN:r.body.checkout_token=i;break;default:throw new Error("Unsupported type of PaymentSourceToken")}return r}return l(n,e),s(n,[{key:"getLink",value:function(){return"/v1/payment_sources/tokens"}},{key:"send",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(e){};this.create(e,this.getConfigs(),(function(e,n){return t(e)}),(function(e,t){void 0===e.message?n("unknown error"):n(e.message)}))}},{key:"getConfigs",value:function(){return this.body}}])}(Ve),gt=function(){return s((function e(t,n,i,r){var a=this;o(this,e),this.background=t,this.runner=n,this.eventEmitter=i,this.params=r,this.runner.onStop((function(){a.eventEmitter.emit(xe.CLOSE)}))}),[{key:"init",value:function(e){var t=this;this.setEnv(e),this.runner.onCheckout(ze.SUCCESS,(function(e){t.eventEmitter.emit(xe.ACCEPTED,{}),t.background.initLoader(),t.runner.stop(),t.checkToken(e.token,(function(){t.createOneTimeToken(e.token)}))})),this.runner.onCheckout(ze.ERROR,(function(){t.eventEmitter.emit(xe.ERROR),console.error("".concat(Le," Error from checkout server.")),t.runner.stop()})),this.runner.onCheckout(ze.REFERRED,(function(){t.eventEmitter.emit(xe.REFERRED),t.runner.stop()})),this.runner.onCheckout(ze.DECLINED,(function(){t.eventEmitter.emit(xe.DECLINED),t.runner.stop()})),this.eventEmitter.subscribe(xe.ERROR,(function(){t.runner.stop()})),this.eventEmitter.subscribe(xe.FINISH,(function(e){t.background.clear()}))}},{key:"setEnv",value:function(e){this.env=e}},{key:"checkToken",value:function(e,t){var n=this,i=new Ke(e);i.setEnv(this.env),i.send(this.params.accessToken,(function(e){n.details=e,t()}),(function(){n.eventEmitter.emit(xe.ERROR,{}),console.error("".concat(Le," Error during creating payment source token."))}))}},{key:"createOneTimeToken",value:function(e){var t=this,n=new yt(this.params.gatewayId,e,mt.CHECKOUT_TOKEN);n.setEnv(this.env),n.send(this.params.accessToken,(function(e){t.eventEmitter.emit(xe.FINISH,{payment_source_token:e,checkout_email:t.details.checkout_email,checkout_holder:t.details.checkout_holder,gateway_type:t.details.gateway_type})}),(function(){t.eventEmitter.emit(xe.ERROR,{}),console.error("".concat(Le," Error during creating payment source token."))}))}}])}(),kt=function(){return s((function e(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"default",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Pe.PAYPAL,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:Ae.CONTEXTUAL;o(this,e),this.accessToken=n,this.gatewayId=i,this.gatewayType=r,this.mode=a,this.window=window,this.meta={},this.env=G,this.eventEmitter=new Oe,this.container=new ue(t),this.initCheckout(this.container),this.chooseRunner(r,a)}),[{key:"chooseRunner",value:function(e,t){var n=this.getRunnerByMode(e,t);this.runner=new n(this.accessToken),rt(this.runner)?(this.background=new Ze,this.checkoutHandler=new gt(this.background,this.runner,this.eventEmitter,{accessToken:this.accessToken,gatewayId:this.gatewayId}),this.checkoutHandler.init(this.env)):(this.background=void 0,this.checkoutHandler=void 0)}},{key:"buildAdditionalParams",value:function(){return{}}},{key:"initCheckout",value:function(e){var t=this;e.on("click",(function(e){if(rt(t.runner)){if(t.runner.isRunning())return;t.runner.run()}else if(ot(t.runner)&&!t.runner.getRedirectUrl())throw Error("".concat(Le," The merchant redirect URL should is required in the '").concat(t.mode,"' mode."));t.eventEmitter.emit(xe.CLICK);var n=new qe(t.gatewayId,t.runner.getSuccessRedirectUri(),t.runner.getErrorRedirectUri());n.setMeta(t.meta),n.setEnv(t.env),n.send(t.accessToken,(function(e){var n=rt(t.runner)?xe.POPUP_REDIRECT:xe.REDIRECT;t.eventEmitter.emit(n),t.runner.next(e,t.buildAdditionalParams())}),(function(e,n){console.error("".concat(Le," ").concat(e)),t.eventEmitter.emit(xe.ERROR,{error:e,code:n}),t.runner.error(e,n,(function(e){e&&t.close()}))}))}))}},{key:"on",value:function(e,t){this.eventEmitter.subscribe(e,t)}},{key:"close",value:function(){this.assertMethodSupport(this.runner,Ae.CONTEXTUAL)&&this.runner.stop()}},{key:"onFinishInsert",value:function(e,t){this.on(xe.FINISH,(function(n){se.insertToInput(e,t,n)}))}},{key:"setMeta",value:function(e){this.meta=c(this.meta,e)}},{key:"setBackdropDescription",value:function(e){this.assertMethodSupport(this.runner,Ae.CONTEXTUAL)&&this.runner.setBackgroundDescription(e)}},{key:"setBackdropTitle",value:function(e){this.assertMethodSupport(this.runner,Ae.CONTEXTUAL)&&this.runner.setBackgroundTitle(e)}},{key:"setSuspendedRedirectUri",value:function(e){this.assertMethodSupport(this.runner,Ae.CONTEXTUAL)&&this.runner.setSuspendedRedirectUri(e)}},{key:"setRedirectUrl",value:function(e){this.assertMethodSupport(this.runner,Ae.REDIRECT)&&this.runner.setRedirectUrl(e)}},{key:"getSuccessRedirectUri",value:function(){return this.runner.getSuccessRedirectUri()}},{key:"turnOffBackdrop",value:function(){this.turnOffControlBackdrop(),this.turnOffLoaderBackdrop()}},{key:"turnOffControlBackdrop",value:function(){this.assertMethodSupport(this.runner,Ae.CONTEXTUAL)&&this.runner.turnOffBackdrop()}},{key:"turnOffLoaderBackdrop",value:function(){var e;null===(e=this.background)||void 0===e||e.turnOffLoader()}},{key:"setEnv",value:function(e,t){var n;this.env=e,this.alias=t,null===(n=this.checkoutHandler)||void 0===n||n.setEnv(e),this.runner.setEnv(e,t)}},{key:"getEnv",value:function(){return this.env}},{key:"getRunnerByMode",value:function(e,t){if(e===Pe.PAYPAL){if(t===Ae.REDIRECT)throw Error("".concat(Le," Gateway '").concat(e,"' do not support '").concat(t,"' mode"));return ft}if(e===Pe.AFTERPAY){if(t===Ae.REDIRECT)throw Error("".concat(Le," Gateway '").concat(e,"' do not support '").concat(t,"' mode"));return vt}if(e===Pe.ZIPMONEY)return t===Ae.CONTEXTUAL?ut:pt;throw Error("".concat(Le," Unsupported gateway."))}},{key:"assertMethodSupport",value:function(e,t){var n="".concat(Le," The method is not supported in the '").concat(t,"' mode.");switch(t){case Ae.CONTEXTUAL:if(rt(e))return!0;console.warn(n);break;case Ae.REDIRECT:if(ot(e))return!0;console.warn(n)}return!1}}])}(),Et=function(e){function n(e,i){var r,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"default",s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Ae.CONTEXTUAL;return o(this,n),(r=t(this,n,[e,i,a,Pe.ZIPMONEY,s])).publicKey=i,r.gatewayId=a,r.mode=s,r}return l(n,e),s(n,[{key:"setSuspendedRedirectUri",value:function(e){p(d(n.prototype),"setSuspendedRedirectUri",this).call(this,e)}},{key:"setRedirectUrl",value:function(e){rt(this.runner)&&(p(d(n.prototype),"chooseRunner",this).call(this,Pe.ZIPMONEY,Ae.REDIRECT),p(d(n.prototype),"setEnv",this).call(this,this.env,this.alias)),p(d(n.prototype),"setRedirectUrl",this).call(this,e)}},{key:"buildAdditionalParams",value:function(){return c(c({},p(d(n.prototype),"buildAdditionalParams",this).call(this)),{public_key:this.publicKey,gateway_id:this.gatewayId})}}])}(kt),_t=function(e){function n(e,i){var r,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"default";return o(this,n),(r=t(this,n,[e,i,a,Pe.AFTERPAY])).accessToken=i,r.gatewayId=a,r.showETP=!1,r}return l(n,e),s(n,[{key:"showEnhancedTrackingProtectionPopup",value:function(e){var t=k.getBrowserInfo(),n=t.name,i=t.version;e&&"Firefox"===n&&+i>=100&&(this.showETP=!0)}},{key:"buildAdditionalParams",value:function(){var e=p(d(n.prototype),"buildAdditionalParams",this).call(this);return this.showETP&&(e.show_etp=!0),e}}])}(kt),bt=function(e){function n(e,i){var r,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"default";return o(this,n),(r=t(this,n,[e,i,a,Pe.PAYPAL])).publicKey=i,r.gatewayId=a,r}return l(n,e),s(n)}(kt),wt=function(){return s((function e(){o(this,e)}),null,[{key:"values",value:function(e){return Object.keys(e).map((function(t){return e[t]}))}}])}(),Ct=function(){return s((function e(t,n){o(this,e),this.configs=[],this.configTokens=[],this.link=new ae("/payment-sources"),this.link.setParams(c({query_token:n},C.validateJWT(t)?{access_token:t}:{public_key:t})),$.version&&this.link.setParams({sdk_version:$.version,sdk_type:$.type})}),[{key:"setStyles",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setStyle(t,e[t])}},{key:"setStyle",value:function(e,t){-1!==wt.values(Me).indexOf(e)?this.link.setParams(u({},e,t)):console.warn("Widget::setStyle[s: unsupported style param ".concat(e))}},{key:"setRefId",value:function(e){this.link.setParams({ref_id:e})}},{key:"setLimit",value:function(e){this.link.setParams({limit:e})}},{key:"setEnv",value:function(e,t){for(var n in this.link.setEnv(e,t),this.configs)this.configs.hasOwnProperty(n)&&this.configs[n].setEnv(e,t)}},{key:"getEnv",value:function(){this.link.getEnv()}},{key:"getIFrameUrl",value:function(){return this.link.getUrl()}},{key:"filterByGatewayIds",value:function(e){this.link.setParams({gateway_ids:e.join(",")})}},{key:"filterByTypes",value:function(e){var t,n=[],i=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=m(e))||t){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}(e);try{for(i.s();!(t=i.n()).done;){var r=t.value;e.hasOwnProperty(r)&&(-1===wt.values(Ne).indexOf(r)?console.warn("PaymentSourceWidget::filterByTypes: unsupported type ".concat(r)):n.push(r))}}catch(e){i.e(e)}finally{i.f()}this.link.setParams({payment_source_types:n.join(",")})}},{key:"setLanguage",value:function(e){this.link.setParams({language:e})}}])}(),St=function(e){function n(e,i,r){var a;return o(this,n),(a=t(this,n,[i,r])).container=new ue(e),a.iFrame=new ce(a.container),a.event=new de(window),a}return l(n,e),s(n,[{key:"load",value:function(){this.iFrame.load(this.getIFrameUrl(),{title:"Payment Sources"})}},{key:"on",value:function(e,t){this.event.on(e,this.link.getParams().widget_id,t)}},{key:"hide",value:function(e){console.info("PayDock SDK"),this.iFrame.hide(e)}},{key:"show",value:function(){this.iFrame.show()}},{key:"reload",value:function(){this.iFrame.remove(),this.load()}},{key:"onSelectInsert",value:function(e,t){this.on(le.SELECT,(function(n){se.insertToInput(e,t,n)}))}}])}(Ct);!function(e){e.IFRAME_LOADED="iframeLoaded",e.CHECKOUT_READY="checkoutReady",e.CHECKOUT_COMPLETED="checkoutCompleted",e.CHECKOUT_ERROR="checkoutError",e.CHECKOUT_POPUP_OPEN="checkoutPopupOpen",e.CHECKOUT_POPUP_CLOSE="checkoutPopupClose"}(lt||(lt={})),function(e){e.CRITICAL_ERROR="CriticalError",e.USER_ERROR="UserError",e.SUCCESS="Success"}(dt||(dt={}));var Tt,Ot={PRIMARY_BUTTON_COLOR:"primary_button_color",SECONDARY_BUTTON_COLOR:"secondary_button_color",PRIMARY_BUTTON_TEXT_COLOR:"primary_button_text_color",SECONDARY_BUTTON_TEXT_COLOR:"secondary_button_text_color",FONT_FAMILY:"font_family",ENABLE_SRC_POPUP:"enable_src_popup"},At=function(){return s((function e(t,n,i,r,a,s,u,l){o(this,e),this.meta=r,this.eventEmitter=a,this.autoResize=s,this.link=new ae("/secure-remote-commerce/mastercard"),this.link.setParams(c({service_id:n,public_key:i},r&&{meta:JSON.stringify(r)})),$.version&&this.link.setParams({sdk_version:$.version,sdk_type:$.type}),u&&this.link.setEnv(u,l),this.iFrameContainer=new ue(t),this.iFrame=new ce(this.iFrameContainer),this.iFrameEvent=new de(window),this.setupIFrameEvents()}),[{key:"setupIFrameEvents",value:function(){var e=this,t=this.link.getParams().widget_id;t&&(this.iFrameEvent.on(lt.CHECKOUT_READY,t,(function(t){var n=t.data;e.eventEmitter.emit(lt.CHECKOUT_READY,n)})),this.iFrameEvent.on(lt.CHECKOUT_COMPLETED,t,(function(t){var n=t.data;e.eventEmitter.emit(lt.CHECKOUT_COMPLETED,n)})),this.iFrameEvent.on(lt.CHECKOUT_POPUP_OPEN,t,(function(t){var n=t.data;e.eventEmitter.emit(lt.CHECKOUT_POPUP_OPEN,n)})),this.iFrameEvent.on(lt.CHECKOUT_POPUP_CLOSE,t,(function(t){var n=t.data;e.eventEmitter.emit(lt.CHECKOUT_POPUP_CLOSE,n)})),this.iFrameEvent.on(lt.CHECKOUT_ERROR,t,(function(t){var n=t.data;e.eventEmitter.emit(lt.CHECKOUT_ERROR,n)})),this.autoResize&&this.useAutoResize(!0))}},{key:"load",value:function(){var e=this;this.iFrame.load(this.link.getUrl(),{title:"Click To Pay checkout"});var t=this.iFrame.getElement();this.iFrame.setStyle("width","100%"),t&&(t.onload=function(){return e.eventEmitter.emit(lt.IFRAME_LOADED,{})})}},{key:"getEnv",value:function(){return this.link.getEnv()}},{key:"hideCheckout",value:function(e){this.iFrame&&this.iFrame.hide()}},{key:"showCheckout",value:function(){this.iFrame&&this.iFrame.show()}},{key:"reload",value:function(){this.iFrame.remove(),this.load()}},{key:"useAutoResize",value:function(e){var t=this;if(!this.autoResize||e){this.autoResize=!0;var n=this.link.getParams();(null==n?void 0:n.widget_id)&&this.iFrameEvent.on("resize",n.widget_id,(function(e){var n,i,r=e.data,o=t.iFrame.getElement();o&&(o.scrolling="no",(null===(n=null==r?void 0:r.data)||void 0===n?void 0:n.height)&&t.iFrame.setStyle("height",(null===(i=null==r?void 0:r.data)||void 0===i?void 0:i.height)+"px"))}))}}}])}(),Pt=function(e){function n(e,i,r,a){var s;return o(this,n),(s=t(this,n,[e,i,r,a])).iframe_selector=e,s.service_id=i,s.public_key_or_access_token=r,s.meta=a,s}return l(n,e),s(n,[{key:"load",value:function(){this.provider||(this.meta.customizations=this.style,this.provider=new At(this.iframe_selector,this.service_id,this.public_key_or_access_token,this.meta,this.eventEmitter,this.autoResize,this.env,this.alias),this.provider.load())}}])}(function(){return s((function e(t,n,i,r){o(this,e),this.iframe_selector=t,this.service_id=n,this.public_key_or_access_token=i,this.meta=r,this.autoResize=!1,this.style={},this.api=new Ce(i,g.PUBLIC_KEY),this.eventEmitter=new Oe}),[{key:"setStyles",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setStyle(t,e[t])}},{key:"setStyle",value:function(e,t){-1!==wt.values(Ot).indexOf(e)?this.style[e]=t:console.warn("Widget::setStyle[s: unsupported style param ".concat(e))}},{key:"load",value:function(){var e=this;this.provider||this.api.service().getConfig(this.service_id).then((function(t){var n=t.type;if(e.meta.customizations=e.style,n===pe.MASTERCARD_SRC)e.provider=new At(e.iframe_selector,e.service_id,e.public_key_or_access_token,e.meta,e.eventEmitter,e.autoResize,e.env,e.alias);e.provider&&e.provider.load()}))}},{key:"setEnv",value:function(e,t){this.provider||(this.env=e,this.alias=t,this.api.setEnv(e,t))}},{key:"getEnv",value:function(){return this.provider?this.provider.getEnv():this.env}},{key:"on",value:function(e,t){var n=this;return"function"==typeof t?this.eventEmitter.subscribe(e,t):new Promise((function(t){return n.eventEmitter.subscribe(e,(function(e){return t(e)}))}))}},{key:"hideCheckout",value:function(e){this.provider&&"function"==typeof this.provider.hideCheckout&&this.provider.hideCheckout(e)}},{key:"showCheckout",value:function(){this.provider&&"function"==typeof this.provider.showCheckout&&this.provider.showCheckout()}},{key:"reload",value:function(){this.provider&&this.provider.reload()}},{key:"useAutoResize",value:function(){this.autoResize=!0,this.provider&&"function"==typeof this.provider.useAutoResize&&this.provider.useAutoResize()}}])}()),Rt={SUBMIT_FORM:"submit_form",CHANGE_TAB:"tab",HIDE_ELEMENTS:"hide_elements",SHOW_ELEMENTS:"show_elements",REFRESH_CHECKOUT:"refresh_checkout",UPDATE_FORM_VALUES:"update_form_values",INIT_CHECKOUT:"init_checkout"},xt=function(){return s((function e(t){o(this,e),this.iFrame=t}),[{key:"push",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.iFrame.isExist()){-1===wt.values(Rt).indexOf(e)&&console.warn("unsupported trigger type");var n={trigger:e,destination:"widget.paydock",data:t};this.iFrame.getElement().contentWindow.postMessage(JSON.stringify(n),"*")}}}])}();!function(e){e.AFTER_LOAD="after_load",e.SYSTEM_ERROR="system_error",e.CVV_SECURE_CODE_REQUESTED="cvv_secure_code_requested",e.CARD_NUMBER_SECURE_CODE_REQUESTED="card_number_secure_code_requested",e.ACCESS_FORBIDDEN="access_forbidden",e.SESSION_EXPIRED="session_expired",e.OPERATION_FORBIDDEN="operation_forbidden"}(Tt||(Tt={}));var It,Ut=function(e){function n(){return o(this,n),t(this,n,arguments)}return l(n,e),s(n,[{key:"on",value:function(e,t,n){for(var i in Tt)Tt.hasOwnProperty(i)&&e===Tt[i]&&this.listeners.push({event:e,listener:n,widget_id:t})}}])}(de),Lt=function(){return s((function e(t,n){o(this,e),this.validationData={},this.configs=[],this.container=new ue(t),this.iFrame=new ce(this.container),this.triggerElement=new xt(this.iFrame),this.event=new Ut(window),this.vaultDisplayToken=n,this.link=new ae("/vault-display"),this.link.setParams({vault_display_token:n})}),[{key:"setEnv",value:function(e,t){this.link.setEnv(e,t)}},{key:"on",value:function(e,t){var n=this;return"function"==typeof t?this.event.on(e,this.link.getParams().widget_id,t):new Promise((function(t){return n.event.on(e,n.link.getParams().widget_id,(function(e){return t(e)}))}))}},{key:"setStyles",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setStyle(t,e[t])}},{key:"setStyle",value:function(e,t){-1!==wt.values(Me).indexOf(e)?this.link.setParams(u({},e,t)):console.warn("Widget::setStyle[s: unsupported style param ".concat(e))}},{key:"load",value:function(){this.iFrame.load(this.link.getUrl(),{title:"Vault Display"})}}])}();!function(e){e.AFTER_LOAD="after_load",e.UNAVAILABLE="unavailable",e.START_LOADING="start_loading",e.END_LOADING="end_loading",e.UPDATE="update",e.PAYMENT_SUCCESSFUL="payment_successful",e.PAYMENT_IN_REVIEW="payment_in_review",e.PAYMENT_ERROR="payment_error"}(It||(It={}));var Nt=function(e){function n(){return o(this,n),t(this,n,arguments)}return l(n,e),s(n,[{key:"on",value:function(e,t,n){for(var i in It)It.hasOwnProperty(i)&&e===It[i]&&this.listeners.push({event:e,listener:n,widget_id:t})}}])}(de),Dt={CLOSE:"close",UPDATED:"updated"},Mt=function(e){function n(e,i){var r;return o(this,n),(r=t(this,n,[e])).widgetId=i,r}return l(n,e),s(n,[{key:"push",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.iFrame.isExist()){-1===wt.values(Dt).indexOf(e)&&console.warn("unsupported trigger type");var n={message_source:"wallet.paydock",reference_id:this.widgetId,trigger:e,destination:"widget.paydock",data:t};this.iFrame.getElement().contentWindow.postMessage(JSON.stringify(n),"*")}}}])}(xt),Ht=function(e){function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return o(this,n),(i=t(this,n)).bgImageUrl=e,i.hideCloseButton=r,i.hideContinueButton=a,i.imageStyle=null,i}return l(n,e),s(n,[{key:"initControl",value:function(){this.imageStyle||this.createImageStyles(),p(d(n.prototype),"initControl",this).call(this)}},{key:"clear",value:function(){this.imageStyle&&this.imageStyle.parentNode.removeChild(this.imageStyle),this.imageStyle=null,p(d(n.prototype),"clear",this).call(this)}},{key:"createTemplate",value:function(){var e=this,t=document.body||document.getElementsByTagName("body")[0],n=String('\n <div class="checkout-container">\n <div class="checkout-bg-logo"></div>\n <a href="#" data-continue>Continue</a>\n <a href="#" data-close>Close</a>\n </div>\n');!0===this.hideCloseButton&&(n=n.replace('<a href="#" data-close>Close</a>',"")),!0===this.hideContinueButton&&(n=n.replace('<a href="#" data-continue>Continue</a>',"")),this.overlay=document.createElement("div"),this.overlay.classList.add("checkout-overlay"),this.overlay.setAttribute("checkout-overlay"," "),this.overlay.innerHTML=n,t.appendChild(this.overlay),setTimeout((function(){e.isInit()&&e.overlay.classList.add("display")}),5)}},{key:"createImageStyles",value:function(){var e=document.head||document.getElementsByTagName("head")[0],t=String("\n .checkout-bg-logo {\n display: block;\n background: url({{url}}) no-repeat;\n width: 100px;\n height: 50px;\n margin: 0 auto;\n border-radius: 10px;\n background-size: contain;\n }\n [data-continue] {\n margin-top: 24px;\n display: block;\n font-family: Helvetica, sans-serif;\n text-decoration: none;\n color: #fff !important;\n border: 1px solid white;\n width: 100px;\n border-radius: 16px;\n padding: 5px;\n }\n [data-continue]:hover {\n background-color: #f2f2f2;\n border: none;\n color: rgba(0, 0, 0, 0.7) !important;\n }\n .checkout-container {\n display: flex;\n flex-direction: column;\n align-items: center;\n }\n\n .checkout-overlay {\n z-index: 2147483647;\n }\n\n .checkout-container [data-close] {\n opacity: 1;\n }\n .checkout-container [data-close]:before,\n .checkout-container [data-close]:after {\n background-color: #fff;\n }\n");document.querySelector(".checkout-container"),t=t.replace("{{url}}",this.bgImageUrl),this.imageStyle=document.createElement("style"),this.imageStyle.type="text/css",this.imageStyle.appendChild(document.createTextNode(t)),e.appendChild(this.imageStyle)}}])}(Ze),Ft={UNAVAILABLE:"unavailable",UPDATE:"update",PAYMENT_METHOD_SELECTED:"payment_method_selected",PAYMENT_SUCCESS:"payment_success",PAYMENT_IN_REVIEW:"payment_in_review",PAYMENT_ERROR:"payment_error",CALLBACK:"callback",AUTH_TOKENS_CHANGED:"auth_tokens_changed",BUTTON_CLICK:"button_click",CHECKOUT_OPEN:"checkout_open",CHECKOUT_CLOSE:"checkout_close"},Bt=function(){return s((function e(t,n){o(this,e),this.publicKey=t,this.meta=n,this.env=G,this.eventEmitter=new Oe,this.initializeChildWallets()}),[{key:"initializeChildWallets",value:function(){this.childWallets=[]}},{key:"getGatewayName",value:function(){throw new Error("Method not implemented")}},{key:"setEnv",value:function(e){return this.env=e,this}},{key:"load",value:function(e){this.childWallets.forEach((function(t){return t.load(e)}))}},{key:"update",value:function(e){}},{key:"enable",value:function(){}},{key:"disable",value:function(){}},{key:"on",value:function(e,t){var n=this;if(-1===wt.values(Ft).indexOf(e))throw new Error("invalid wallet event");return"function"==typeof t?this.eventEmitter.subscribe(e,t):new Promise((function(t){return n.eventEmitter.subscribe(e,(function(e){return t(e)}))}))}}])}(),jt=function(e){function n(e,i){var r;o(this,n),(r=t(this,n,[e,i])).link=new ae(re);var a=i.amount,s=i.currency,u=i.id,l=i.gateway_mode,d=i.reference,h=i.request_shipping;return r.link.setParams(c({token:e,amount:a,currency:s,gateway_mode:l,credentials:d||u},h?{request_shipping:h}:{})),$.version&&r.link.setParams({sdk_version:$.version,sdk_type:$.type}),r.token=e,r.event=new Nt(window),r}return l(n,e),s(n,[{key:"load",value:function(e){this.container=e,this.iFrame=new ce(this.container);var t=this.link.getParams().widget_id;this.triggerElement=new Mt(this.iFrame,t),this.setupIFrameEvents(t),this.background=this.initBackground(),this.iFrame.load(this.link.getUrl())}},{key:"close",value:function(){this.triggerElement.push(Dt.CLOSE),this.background.clear()}},{key:"update",value:function(e){this.triggerElement.push(Dt.UPDATED,e)}},{key:"setEnv",value:function(e){return this.link.setEnv(e),this}},{key:"initBackground",value:function(){var e=this,t=new Ht(this.link.getNetUrl().replace(re,oe));return t.setBackdropTitle(""),t.setBackdropDescription(""),t.onTrigger(Ge,(function(){return e.triggerElement.push(Dt.CLOSE)})),t}},{key:"setupIFrameEvents",value:function(e){var t=this;this.event.on(It.UNAVAILABLE,e,(function(e){return t.eventEmitter.emit(Ft.UNAVAILABLE,null)})),this.event.on(It.START_LOADING,e,(function(e){return t.background.initControl()})),this.event.on(It.END_LOADING,e,(function(e){return t.background.clear()})),this.event.on(It.UPDATE,e,(function(e){t.eventEmitter.emit(Ft.UPDATE,t.parseUpdateData(e))})),this.event.on(It.PAYMENT_SUCCESSFUL,e,(function(e){t.eventEmitter.emit(Ft.PAYMENT_SUCCESS,t.parsePaymentSuccessfulData(e)),t.iFrame.getElement()||t.background.clear()})),this.event.on(It.PAYMENT_IN_REVIEW,e,(function(e){t.eventEmitter.emit(Ft.PAYMENT_IN_REVIEW,t.parsePaymentSuccessfulData(e)),t.iFrame.getElement()||t.background.clear()})),this.event.on(It.PAYMENT_ERROR,e,(function(e){t.eventEmitter.emit(Ft.PAYMENT_ERROR,e),t.iFrame.getElement()||t.background.clear()}))}},{key:"parsePaymentSuccessfulData",value:function(e){var t;return{id:this.meta.id,amount:e.amount,currency:e.currencyCode,status:null===(t=e.charge)||void 0===t?void 0:t.status}}},{key:"parseUpdateData",value:function(e){return c(c(c({wallet_response_code:e.responseCode,wallet_session_id:e.sessionId},e.paymentMethodDetails?{payment_source:{wallet_payment_method_id:e.paymentMethodDetails.paymentMethodId,card_number_last4:e.paymentMethodDetails.lastFourDigitsOfPan,card_scheme:e.paymentMethodDetails.paymentScheme}}:{}),e.loyaltyAccountSummary?{wallet_loyalty_account:{id:e.loyaltyAccountSummary.loyaltyAccountId,barcode:e.loyaltyAccountSummary.loyaltyAccountBarcode}}:{}),e.deliveryAddressDetails?{shipping:{address_line1:e.deliveryAddressDetails.line1,address_line2:e.deliveryAddressDetails.line2,address_postcode:e.deliveryAddressDetails.postalCode,address_city:e.deliveryAddressDetails.city,address_state:e.deliveryAddressDetails.state,address_country:e.deliveryAddressDetails.countryCode,address_company:e.deliveryAddressDetails.companyName,wallet_address_id:e.deliveryAddressDetails.addressId,post_office_box_number:e.deliveryAddressDetails.postOfficeBoxNumber,wallet_address_created_timestamp:e.deliveryAddressDetails.createdTimestamp,wallet_address_updated_timestamp:e.deliveryAddressDetails.updatedTimestamp,wallet_address_name:e.deliveryAddressDetails.name}}:{})}}])}(Bt),zt=function(e){function n(){return o(this,n),t(this,n,arguments)}return l(n,e),s(n,[{key:"load",value:function(e){return window.Promise?(!0===this.meta.standalone?this.renderPaypalStandaloneComponent(e):this.renderPaypalCommonComponent(e),Promise.resolve()):(this.eventEmitter.emit(Ft.UNAVAILABLE,null),Promise.resolve())}},{key:"update",value:function(e){var t=this;if(this.latestShippingChangePromiseResolve&&this.latestShippingChangePromiseReject)return e.success?void this.eventEmitter.emit(Ft.CALLBACK,{data:{request_type:"UPDATE_TRANSACTION",shipping:this.latestShippingData},onSuccess:function(e){return t.latestShippingChangePromiseResolve(!0)},onError:function(){return t.latestShippingChangePromiseReject()}}):this.latestShippingChangePromiseReject()}},{key:"renderPaypalCommonComponent",value:function(e){var t,n=this,i=(null===(t=e.getElement())||void 0===t?void 0:t.id)||"",r=document.createElement("script");r.src="https://www.paypal.com/sdk/js?client-id=".concat(this.publicKey,"¤cy=").concat(this.meta.currency).concat(!0===this.meta.pay_later?"&enable-funding=paylater&disable-funding=card":"&disable-funding=credit,card").concat(this.meta.capture?"":"&intent=authorize"),r.async=!0,r.onload=function(){window.paypal?(n.paypal=window.paypal,n.paypal.Buttons(c({},n.paypalSharedProps())).render("#".concat(i))):n.eventEmitter.emit(Ft.UNAVAILABLE,null)},document.head.appendChild(r)}},{key:"renderPaypalStandaloneComponent",value:function(e){var t,n,i=this,r=(null===(t=e.getElement())||void 0===t?void 0:t.id)||"",o=document.createElement("script");o.src="https://www.paypal.com/sdk/js?client-id=".concat(this.publicKey,"¤cy=").concat(this.meta.currency,"&components=buttons,funding-eligibility,messages&enable-funding=paylater").concat(this.meta.capture?"":"&intent=authorize").concat("live"===(null===(n=this.meta)||void 0===n?void 0:n.gateway_mode)?"":"&buyer-country=AU"),o.async=!0,o.onload=function(){if(window.paypal){i.paypal=window.paypal;var e=!!i.meta.pay_later,t=i.paypal.Buttons(c({fundingSource:e?i.paypal.FUNDING.PAYLATER:i.paypal.FUNDING.PAYPAL},i.paypalSharedProps()));if(t.isEligible()){if(t.render("#".concat(r)),e)i.paypal.Messages(c({amount:i.meta.amount,currency:i.meta.currency,placement:"payment"},i.meta.style&&i.meta.style.messages&&{style:i.meta.style.messages})).render("#".concat(r))}else i.eventEmitter.emit(Ft.UNAVAILABLE,null)}else i.eventEmitter.emit(Ft.UNAVAILABLE,null)},document.head.appendChild(o)}},{key:"paypalSharedProps",value:function(){var e=this;return c(c({},this.meta.style&&{style:this.meta.style}),{onClick:function(t,n){var i;return e.eventEmitter.emit(Ft.BUTTON_CLICK,{attachResult:function(e){i=e&&e instanceof Promise?e.then((function(){return n.resolve()})).catch((function(){return n.reject()})):e}}),i},createOrder:function(){return new Promise((function(t,n){e.eventEmitter.emit(Ft.CALLBACK,{data:c({request_type:"CREATE_TRANSACTION"},e.meta.request_shipping&&{request_shipping:e.meta.request_shipping}),onSuccess:function(e){return t(e.id)},onError:function(e){return n(e)}})}))},onShippingChange:function(t,n){return new Promise((function(n,i){var r=e.parseUpdateData(t);e.latestShippingData=r.shipping,e.latestShippingChangePromiseResolve=n,e.latestShippingChangePromiseReject=i,e.eventEmitter.emit(Ft.UPDATE,r)}))},onApprove:function(t){return e.pendingApprovalPromise=e.pendingApprovalPromise||new Promise((function(n,i){return e.eventEmitter.emit(Ft.PAYMENT_METHOD_SELECTED,{data:{payment_method_id:t.orderID,customer:{payment_source:{external_payer_id:t.payerID}}},onSuccess:function(){e.pendingApprovalPromise=void 0,n(!0)},onError:function(t){e.pendingApprovalPromise=void 0,i(t)}})})),e.pendingApprovalPromise},onCancel:function(){return e.eventEmitter.emit(Ft.CHECKOUT_CLOSE)},onError:function(e){}})}},{key:"parseUpdateData",value:function(e){var t;return c(c({wallet_order_id:e.orderID,wallet_session_id:e.paymentID,payment_source:{wallet_payment_method_id:e.paymentToken}},e.shipping_address&&{shipping:{address_city:e.shipping_address.city,address_state:e.shipping_address.state,address_postcode:e.shipping_address.postal_code,address_country:e.shipping_address.country_code}}),e.selected_shipping_option&&{selected_shipping_option:{id:e.selected_shipping_option.id,label:e.selected_shipping_option.label,amount:e.selected_shipping_option.amount.value,currency:e.selected_shipping_option.amount.currency_code,type:null===(t=e.selected_shipping_option)||void 0===t?void 0:t.type}})}}])}(Bt),Vt={};function qt(e){return qt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},qt(e)}Object.defineProperty(Vt,"__esModule",{value:!0});var Kt,Yt="https://js.stripe.com/v3",Wt=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,Gt="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used",Jt=null,Zt=function(e){return null!==Jt||(Jt=new Promise((function(t,n){if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(Gt),window.Stripe)t(window.Stripe);else try{var i=function(){for(var e=document.querySelectorAll('script[src^="'.concat(Yt,'"]')),t=0;t<e.length;t++){var n=e[t];if(Wt.test(n.src))return n}return null}();i&&e?console.warn(Gt):i||(i=function(e){var t=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",n=document.createElement("script");n.src="".concat(Yt).concat(t);var i=document.head||document.body;if(!i)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return i.appendChild(n),n}(e)),i.addEventListener("load",(function(){window.Stripe?t(window.Stripe):n(new Error("Stripe.js not available"))})),i.addEventListener("error",(function(){n(new Error("Failed to load Stripe.js"))}))}catch(e){return void n(e)}else t(null)}))),Jt},Xt=function(e){var t="invalid load parameters; expected object of shape\n\n {advancedFraudSignals: boolean}\n\nbut received\n\n ".concat(JSON.stringify(e),"\n");if(null===e||"object"!==qt(e))throw new Error(t);if(1===Object.keys(e).length&&"boolean"==typeof e.advancedFraudSignals)return e;throw new Error(t)},$t=!1,Qt=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];$t=!0;var i=Date.now();return Zt(Kt).then((function(e){return function(e,t,n){if(null===e)return null;var i=e.apply(void 0,t);return function(e,t){e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",version:"1.54.2",startTime:t})}(i,n),i}(e,t,i)}))};Qt.setLoadParameters=function(e){if($t&&Kt){var t=Xt(e);if(Object.keys(t).reduce((function(t,n){var i;return t&&e[n]===(null===(i=Kt)||void 0===i?void 0:i[n])}),!0))return}if($t)throw new Error("You cannot change load parameters after calling loadStripe");Kt=Xt(e)},Vt.loadStripe=Qt;var en=Vt,tn="success",nn="fail",rn=function(e){function n(){return o(this,n),t(this,n,arguments)}return l(n,e),s(n,[{key:"initPaymentRequest",value:function(){return this.stripe.paymentRequest({country:this.meta.country.toUpperCase(),currency:this.meta.currency.toLowerCase(),total:{label:this.meta.amount_label,amount:Math.floor(100*this.meta.amount)},requestPayerName:!0===this.meta.request_payer_name,requestPayerEmail:!0===this.meta.request_payer_email,requestPayerPhone:!0===this.meta.request_payer_phone})}},{key:"createWalletButton",value:function(){return this.stripe.elements().create("paymentRequestButton",{paymentRequest:this.paymentRequest})}},{key:"load",value:function(e){var t=this;return en.loadStripe(this.publicKey).then((function(e){t.stripe=e,t.paymentRequest=t.initPaymentRequest()})).then((function(){return t.checkAvailability()})).then((function(n){return t.mount(e,n)})).then((function(){return t.setOnPaymentMethodSelected()}))}},{key:"checkAvailability",value:function(){var e=this;return this.paymentRequest.canMakePayment().then((function(t){if(t){var n=!e.meta.wallets||e.meta.wallets.includes(Ue.GOOGLE),i=!e.meta.wallets||e.meta.wallets.includes(Ue.APPLE);return{google_pay:n&&!t.applePay,apple_pay:i&&t.applePay,flypay:!1}}}))}},{key:"mount",value:function(e,t){if(!t||!t.apple_pay&&!t.google_pay)return this.eventEmitter.emit(Ft.UNAVAILABLE,null);this.createWalletButton().mount(e.getElement())}},{key:"setOnPaymentMethodSelected",value:function(){var e=this;this.paymentRequest.on("paymentmethod",(function(t){var n,i,r=t.paymentMethod,o=r.id,a=r.card,s=r.billing_details,u=s.name,c=s.address,l={payment_method_id:o,customer:{payer_name:t.payerName,payer_email:t.payerEmail,payer_phone:t.payerPhone,payment_source:{wallet_type:e.getWalletType(null===(n=null==a?void 0:a.wallet)||void 0===n?void 0:n.type),card_name:u,type:null===(i=null==a?void 0:a.wallet)||void 0===i?void 0:i.type,card_scheme:null==a?void 0:a.brand,card_number_last4:null==a?void 0:a.last4,expire_month:null==a?void 0:a.exp_month,expire_year:null==a?void 0:a.exp_year,address_line1:c.line1,address_line2:c.line2,address_city:c.city,address_postcode:c.postal_code,address_state:c.state,address_country:c.country}}};e.eventEmitter.emit(Ft.PAYMENT_METHOD_SELECTED,{data:l,onSuccess:function(){return t.complete(tn)},onError:function(e){return t.complete(nn)}})}))}},{key:"getWalletType",value:function(e){return e?"google_pay"===e?Ue.GOOGLE:Ue.APPLE:null}}])}(Bt),on=function(e){function n(e,i,r,a){var s;return o(this,n),(s=t(this,n,[e,i])).gatewayName=r,s.eventEmitter=a,s.latestShippingData={},s.onCancelPayment=function(e){return s.eventEmitter.emit(Ft.CHECKOUT_CLOSE)},s.onValidateMerchant=function(e){s.handleMerchantOnButtonClickEvent().then((function(){s.getMerchantSession().then((function(e){s.paymentSession.completeMerchantValidation(e)})).catch((function(e){console.error("Error fetching merchant session",e),s.paymentSession.abort()}))})).catch((function(e){console.error("Error while processing merchant callback",e),s.paymentSession.abort()}))},s.onPaymentAuthorized=function(e){var t,n=e.payment,i=n.token,r=n.billingContact,o=n.shippingContact;s.latestShippingData.shippingContact=o;var a=null===(t=s.selectedShippingOption)||void 0===t?void 0:t.type,u=[null==o?void 0:o.givenName,null==o?void 0:o.familyName].join(" ").trim();s.eventEmitter.emit(Ft.PAYMENT_METHOD_SELECTED,{data:c({customer:{payment_source:c(c({wallet_type:Ue.APPLE},u&&{card_name:u}),{type:i.paymentMethod.type,card_scheme:i.paymentMethod.network,address_line1:null==r?void 0:r.addressLines[0],address_line2:null==r?void 0:r.addressLines[1],address_country:null==r?void 0:r.countryCode,address_city:null==r?void 0:r.locality,address_postcode:null==r?void 0:r.postalCode,address_state:null==r?void 0:r.administrativeArea,ref_token:i.paymentData?JSON.stringify(i.paymentData):""})}},s.meta.request_shipping&&o&&{shipping:c(c(c({},a&&{method:a}),s.hasShippingOptions()&&{options:s.meta.shipping_options}),{address_line1:o.addressLines[0],address_line2:o.addressLines[1],address_country:o.countryCode,address_city:o.locality,address_postcode:o.postalCode,address_state:o.administrativeArea,contact:{first_name:o.givenName,last_name:o.familyName,email:o.emailAddress,phone:o.phoneNumber}})}),onSuccess:function(){return s.paymentSession.completePayment(ApplePaySession.STATUS_SUCCESS)},onError:function(){return s.paymentSession.completePayment(ApplePaySession.STATUS_FAILURE)}})},s.onShippingContactSelected=function(e){s.latestShippingData.shippingContact=e.shippingContact;var t=s.parseUpdateData(s.latestShippingData);return s.eventEmitter.emit(Ft.UPDATE,t),new Promise((function(e,t){s.latestShippingChangePromiseResolve=e,s.latestShippingChangePromiseReject=t}))},s.onShippingMethodSelected=function(e){var t,n;s.latestShippingData.shippingMethod=e.shippingMethod;var i={newTotal:{label:s.meta.amount_label||(null===(n=null===(t=s.getMetaRawDataInitialization())||void 0===t?void 0:t.total)||void 0===n?void 0:n.label),amount:s.meta.amount.toString(),type:"final"}};s.paymentSession.completeShippingMethodSelection(i)},s.parseUpdateData=function(e){var t,n,i,r,o,a,s,u;return c({shipping:{address_city:null===(t=null==e?void 0:e.shippingContact)||void 0===t?void 0:t.locality,address_state:null===(n=null==e?void 0:e.shippingContact)||void 0===n?void 0:n.administrativeArea,address_postcode:null===(i=null==e?void 0:e.shippingContact)||void 0===i?void 0:i.postalCode,address_country:null===(r=null==e?void 0:e.shippingContact)||void 0===r?void 0:r.countryCode}},(null==e?void 0:e.shippingMethod)&&{selected_shipping_option:{id:null===(o=null==e?void 0:e.shippingMethod)||void 0===o?void 0:o.identifier,label:null===(a=null==e?void 0:e.shippingMethod)||void 0===a?void 0:a.label,detail:null===(s=null==e?void 0:e.shippingMethod)||void 0===s?void 0:s.detail,amount:null===(u=null==e?void 0:e.shippingMethod)||void 0===u?void 0:u.amount}})},s.formatShippingOptions=function(e){return e.map((function(e){return{identifier:e.id,label:e.label,detail:(null==e?void 0:e.detail)||"",amount:e.amount}}))},s.eventEmitter=a,s}return l(n,e),s(n,[{key:"getGatewayName",value:function(){return this.gatewayName}},{key:"getMerchantId",value:function(){var e,t,n;return(null===(n=null===(t=null===(e=this.meta)||void 0===e?void 0:e.credentials)||void 0===t?void 0:t[Ue.APPLE])||void 0===n?void 0:n.merchant)||""}},{key:"getMetaStyles",value:function(){var e,t,n;if((null===(e=this.meta)||void 0===e?void 0:e.style)&&"object"===r(null===(t=this.meta)||void 0===t?void 0:t.style)){var i=JSON.parse(JSON.stringify(null===(n=this.meta)||void 0===n?void 0:n.style));return"google"in i&&(null==i||delete i.google),"apple"in i?null==i?void 0:i.apple:i}return null}},{key:"getMetaRawDataInitialization",value:function(){var e,t,n,i;if((null===(e=this.meta)||void 0===e?void 0:e.raw_data_initialization)&&(null===(t=this.meta)||void 0===t?void 0:t.raw_data_initialization)&&"object"===r(null===(n=this.meta)||void 0===n?void 0:n.raw_data_initialization)){var o=JSON.parse(JSON.stringify(null===(i=this.meta)||void 0===i?void 0:i.raw_data_initialization));return"google"in o&&(null==o||delete o.google),"apple"in o?null==o?void 0:o.apple:o}return null}},{key:"isShippingRequired",value:function(){var e;return null===(e=this.meta)||void 0===e?void 0:e.request_shipping}},{key:"hasShippingOptions",value:function(){var e,t;return(null===(e=this.meta)||void 0===e?void 0:e.request_shipping)&&!!(null===(t=this.meta)||void 0===t?void 0:t.shipping_options)}},{key:"load",value:function(e){var t=this;if(window.Promise)return this.checkAvailability().then((function(n){var i;n?(t.isShippingRequired()&&t.hasShippingOptions()&&(t.selectedShippingOption=null===(i=t.meta)||void 0===i?void 0:i.shipping_options[0],t.latestShippingData.shippingMethod=t.formatShippingOptions([t.selectedShippingOption])[0]),t.mount(e)):t.eventEmitter.emit(Ft.UNAVAILABLE,{wallet:Ue.APPLE})})).catch((function(e){return console.error("Error checking ApplePay availability",e)}));this.eventEmitter.emit(Ft.UNAVAILABLE,{wallet:Ue.APPLE})}},{key:"update",value:function(e){var t,n,i;if(this.latestShippingChangePromiseResolve&&this.latestShippingChangePromiseReject){if(!e.success||!e.body)return this.latestShippingChangePromiseReject();var r=null===(t=null==e?void 0:e.body)||void 0===t?void 0:t.amount,o=null===(n=null==e?void 0:e.body)||void 0===n?void 0:n.shipping_options;r&&(this.meta.amount=r),o&&(this.meta.shipping_options=o,this.selectedShippingOption=o?o[0]:void 0);var a=c({newTotal:{label:null===(i=this.meta)||void 0===i?void 0:i.amount_label,amount:this.meta.amount.toString(),type:"final"}},this.isShippingRequired()&&this.hasShippingOptions()&&{newShippingMethods:this.formatShippingOptions(this.meta.shipping_options)});this.paymentSession.completeShippingContactSelection(a),this.latestShippingChangePromiseResolve({})}}},{key:"checkAvailability",value:function(){var e=this;return new Promise((function(t,n){window.ApplePaySession&&ApplePaySession||t(!1),ApplePaySession.canMakePaymentsWithActiveCard(e.getMerchantId()).then((function(e){return t(e)})).catch((function(e){return t(!1)}))}))}},{key:"mount",value:function(e){var t=this,n=document.createElement("style");n.innerHTML=this.createButtonStyle(),document.head.appendChild(n);var i=document.createElement("div");i.onclick=function(){return t.onApplePayButtonClicked()},i.classList.add("paydock-apple-container","apple-pay-button","apple-pay-button-black"),i.setAttribute("tabindex","0"),i.setAttribute("role","button"),e.getElement().appendChild(i)}},{key:"onApplePayButtonClicked",value:function(){this.paymentSession=new ApplePaySession(3,this.createRequest()),this.paymentSession.onvalidatemerchant=this.onValidateMerchant,this.paymentSession.onpaymentauthorized=this.onPaymentAuthorized,this.paymentSession.oncancel=this.onCancelPayment,this.paymentSession.onshippingcontactselected=this.onShippingContactSelected,this.paymentSession.onshippingmethodselected=this.onShippingMethodSelected,this.paymentSession.begin()}},{key:"createRequest",value:function(){var e,t=this.getMetaRawDataInitialization();return t&&"object"===r(t)&&("object"===r(t.total)?t.total.amount=this.meta.amount.toString():t.total={label:(null===(e=this.meta)||void 0===e?void 0:e.amount_label)||"",amount:this.meta.amount.toString()},this.isShippingRequired()&&this.hasShippingOptions()&&(t.shippingMethods=this.formatShippingOptions(this.meta.shipping_options))),t||c(c(c({countryCode:this.meta.country.toUpperCase(),currencyCode:this.meta.currency.toUpperCase(),merchantCapabilities:["supports3DS","supportsCredit","supportsDebit"],supportedNetworks:["visa","masterCard","amex","discover"]},this.meta.show_billing_address&&{requiredBillingContactFields:["name","postalAddress"]}),this.isShippingRequired()&&c({requiredShippingContactFields:["postalAddress","name","phone","email"]},this.hasShippingOptions()&&{shippingMethods:this.formatShippingOptions(this.meta.shipping_options)})),{total:{label:this.meta.amount_label,amount:this.meta.amount.toString(),type:"final"}})}},{key:"getMerchantSession",value:function(){var e=this;return new Promise((function(t,n){return e.eventEmitter.emit(Ft.CALLBACK,{data:c({request_type:"CREATE_SESSION",wallet_type:Ue.APPLE,session_id:window.location.hostname},e.isShippingRequired()&&{request_shipping:e.meta.request_shipping}),onSuccess:function(e){return t(e)},onError:function(e){return n(e)}})}))}},{key:"handleMerchantOnButtonClickEvent",value:function(){var e=this;return new Promise((function(t,n){var i;e.eventEmitter.emit(Ft.BUTTON_CLICK,{attachResult:function(e){i=e}}),i instanceof Promise?i.then(t).catch(n):!1===i?n():t()}))}},{key:"createButtonStyle",value:function(){var e,t;return"\n .paydock-apple-container {\n width: 100%;\n height: 40px;\n }\n\n @supports (-webkit-appearance: -apple-pay-button) {\n .apple-pay-button {\n display: inline-block;\n -webkit-appearance: -apple-pay-button;\n -apple-pay-button-type: ".concat((null===(e=this.getMetaStyles())||void 0===e?void 0:e.button_type)||"plain","\n }\n .apple-pay-button-black {\n -apple-pay-button-style: black;\n }\n .apple-pay-button-white {\n -apple-pay-button-style: white;\n }\n .apple-pay-button-white-with-line {\n -apple-pay-button-style: white-outline;\n }\n }\n\n @supports not (-webkit-appearance: -apple-pay-button) {\n .apple-pay-button {\n display: inline-block;\n background-size: 100% 60%;\n background-repeat: no-repeat;\n background-position: 50% 50%;\n border-radius: 5px;\n padding: 0px;\n box-sizing: border-box;\n min-width: 200px;\n min-height: 32px;\n max-height: 64px;\n -apple-pay-button-type: ").concat((null===(t=this.getMetaStyles())||void 0===t?void 0:t.button_type)||"plain","\n }\n .apple-pay-button-black {\n background-image: -webkit-named-image(apple-pay-logo-white);\n background-color: black;\n }\n .apple-pay-button-white {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n }\n .apple-pay-button-white-with-line {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n border: .5px solid black;\n }\n }\n ")}}])}(Bt),an=function(e){function n(e,i,r,a){var s;return o(this,n),(s=t(this,n,[e,i])).gatewayName=r,s.eventEmitter=a,s.processingButtonClick=!1,s.parseUpdateData=function(e){var t,n,i,r,o,a,u=null===(n=null===(t=s.meta)||void 0===t?void 0:t.shipping_options)||void 0===n?void 0:n.find((function(t){var n;return t.id===(null===(n=null==e?void 0:e.shippingOptionData)||void 0===n?void 0:n.id)}));return c({shipping:{address_city:null===(i=e.shippingAddress)||void 0===i?void 0:i.locality,address_state:null===(r=e.shippingAddress)||void 0===r?void 0:r.administrativeArea,address_postcode:null===(o=null==e?void 0:e.shippingAddress)||void 0===o?void 0:o.postalCode,address_country:null===(a=null==e?void 0:e.shippingAddress)||void 0===a?void 0:a.countryCode}},u&&{selected_shipping_option:{id:null==u?void 0:u.id,label:null==u?void 0:u.label,detail:null==u?void 0:u.detail,type:null==u?void 0:u.type}})},s.formatShippingOptions=function(e){return e.map((function(e){return{id:e.id,label:e.label,description:(null==e?void 0:e.detail)||""}}))},s.eventEmitter=a,s}return l(n,e),s(n,[{key:"getGatewayName",value:function(){return this.gatewayName}},{key:"getMerchantId",value:function(){var e,t,n;return null===(n=null===(t=null===(e=this.meta)||void 0===e?void 0:e.credentials)||void 0===t?void 0:t[Ue.GOOGLE])||void 0===n?void 0:n.merchant}},{key:"getMetaStyles",value:function(){var e,t,n,i;return"object"===r(null===(e=this.meta)||void 0===e?void 0:e.style)&&"google"in(null===(t=this.meta)||void 0===t?void 0:t.style)?null===(i=null===(n=this.meta)||void 0===n?void 0:n.style)||void 0===i?void 0:i.google:null}},{key:"getMetaRawDataInitialization",value:function(){var e,t,n,i,o;return(null===(e=this.meta)||void 0===e?void 0:e.raw_data_initialization)&&"object"===r(null===(t=this.meta)||void 0===t?void 0:t.raw_data_initialization)&&"google"in(null===(n=this.meta)||void 0===n?void 0:n.raw_data_initialization)?null===(o=null===(i=this.meta)||void 0===i?void 0:i.raw_data_initialization)||void 0===o?void 0:o.google:null}},{key:"isShippingRequired",value:function(){return!!this.meta.request_shipping}},{key:"hasShippingOptions",value:function(){return this.meta.request_shipping&&!!this.meta.shipping_options}},{key:"load",value:function(e){var t=this;if(window.Promise)return new Promise((function(n,i){var r=document.createElement("script");r.type="text/javascript",r.src="https://pay.google.com/gp/p/js/pay.js",r.async=!0,r.onload=function(){var r,o,a,s;if(!window.google)return t.eventEmitter.emit(Ft.UNAVAILABLE,{wallet:Ue.GOOGLE}),void i();t.isShippingRequired()&&t.hasShippingOptions()&&(t.selectedShippingOption=null===(r=t.meta)||void 0===r?void 0:r.shipping_options[0]),t.paymentsClient=new google.payments.api.PaymentsClient(c({merchantInfo:c(c({},(null===(o=t.meta)||void 0===o?void 0:o.merchant_name)?{merchantName:null===(a=t.meta)||void 0===a?void 0:a.merchant_name}:{}),{merchantId:t.getMerchantId()}),paymentDataCallbacks:c({onPaymentAuthorized:function(e){return t.onPaymentAuthorized(e)}},t.isShippingRequired()&&{onPaymentDataChanged:function(e){return t.onPaymentDataChanged(e)}})},"live"===(null===(s=t.meta)||void 0===s?void 0:s.gateway_mode)?{environment:"PRODUCTION"}:{environment:"TEST"})),t.checkAvailability().then((function(r){if(!r)return t.eventEmitter.emit(Ft.UNAVAILABLE,{wallet:Ue.GOOGLE}),void i();t.mount(e),n()}))},document.head.appendChild(r)}));this.eventEmitter.emit(Ft.UNAVAILABLE,{wallet:Ue.GOOGLE})}},{key:"update",value:function(e){var t,n,i,r;if(this.latestShippingChangePromiseResolve&&this.latestShippingChangePromiseReject){if(!e.success)return this.latestShippingChangePromiseReject();var o=(null===(t=null==e?void 0:e.body)||void 0===t?void 0:t.amount)||this.meta.amount,a=null===(n=null==e?void 0:e.body)||void 0===n?void 0:n.shipping_options;o&&(this.meta.amount=o),a&&(this.meta.shipping_options=a,this.selectedShippingOption=a?a[0]:void 0);var s=c({newTransactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:this.meta.amount_label,totalPrice:null===(i=this.meta.amount)||void 0===i?void 0:i.toString(),currencyCode:this.meta.currency.toUpperCase(),countryCode:this.meta.country.toUpperCase()}},this.isShippingRequired()&&this.hasShippingOptions()&&a&&{newShippingOptionParameters:{defaultSelectedOptionId:null===(r=this.selectedShippingOption)||void 0===r?void 0:r.id,shippingOptions:this.formatShippingOptions(this.meta.shipping_options)}});this.latestShippingChangePromiseResolve(s)}}},{key:"checkAvailability",value:function(){return this.paymentsClient.isReadyToPay(this.createRequest()).then((function(e){return!!e.result})).catch((function(e){return console.error("Error checking GooglePay availability",e),!1}))}},{key:"mount",value:function(e){var t,n,i,r=this;e.getElement().appendChild(this.paymentsClient.createButton({onClick:function(){return r.onGooglePayButtonClicked()},buttonType:(null===(t=this.getMetaStyles())||void 0===t?void 0:t.button_type)||"pay",buttonSizeMode:(null===(n=this.getMetaStyles())||void 0===n?void 0:n.button_size_mode)||"fill",buttonColor:(null===(i=this.getMetaStyles())||void 0===i?void 0:i.button_color)||"default"}))}},{key:"onGooglePayButtonClicked",value:function(){var e=this;this.processingButtonClick||(this.processingButtonClick=!0,this.handleMerchantOnButtonClickEvent().then((function(){e.loadPaymentData().finally((function(){e.processingButtonClick=!1}))})).catch((function(t){e.processingButtonClick=!1,console.error("Error while processing merchant callback",t)})))}},{key:"handleMerchantOnButtonClickEvent",value:function(){var e=this;return new Promise((function(t,n){var i;e.eventEmitter.emit(Ft.BUTTON_CLICK,{attachResult:function(e){i=e}}),i instanceof Promise?i.then(t).catch(n):!1===i?n():t()}))}},{key:"loadPaymentData",value:function(){var e=this;return this.paymentsClient.loadPaymentData(this.createPaymentDataRequest()).catch((function(t){throw e.eventEmitter.emit(Ft.CHECKOUT_CLOSE),console.error("Error while loading payment data",t),t}))}},{key:"onPaymentAuthorized",value:function(e){var t,n,i,r,o,a,s,u,l,d,h,p,f,v,m,y=this,g=null===(i=null===(n=null===(t=e.paymentMethodData)||void 0===t?void 0:t.info)||void 0===n?void 0:n.billingAddress)||void 0===i?void 0:i.address1,k=null===(a=null===(o=null===(r=e.paymentMethodData)||void 0===r?void 0:r.info)||void 0===o?void 0:o.billingAddress)||void 0===a?void 0:a.address2,E=null===(s=null==e?void 0:e.shippingAddress)||void 0===s?void 0:s.address1,_=null===(u=null==e?void 0:e.shippingAddress)||void 0===u?void 0:u.address2,b=null===(l=this.selectedShippingOption)||void 0===l?void 0:l.type,w=null===(d=null==e?void 0:e.shippingAddress)||void 0===d?void 0:d.countryCode,C=null===(h=null==e?void 0:e.shippingAddress)||void 0===h?void 0:h.locality,S=null===(p=null==e?void 0:e.shippingAddress)||void 0===p?void 0:p.postalCode,T=null===(f=null==e?void 0:e.shippingAddress)||void 0===f?void 0:f.administrativeArea,O=null===(v=null==e?void 0:e.shippingAddress)||void 0===v?void 0:v.name,A=null==e?void 0:e.email,P=null===(m=null==e?void 0:e.shippingAddress)||void 0===m?void 0:m.phoneNumber;return new Promise((function(t){var n,i,r,o,a,s,u,l,d,h,p,f,v,m;return y.eventEmitter.emit(Ft.PAYMENT_METHOD_SELECTED,{data:c({customer:{payment_source:c(c(c(c({wallet_type:Ue.GOOGLE,type:e.paymentMethodData.type,card_scheme:null===(i=null===(n=e.paymentMethodData)||void 0===n?void 0:n.info)||void 0===i?void 0:i.cardNetwork},g&&{address_line1:g}),k&&{address_line2:k}),k&&{address_line2:k}),{address_country:null===(a=null===(o=null===(r=e.paymentMethodData)||void 0===r?void 0:r.info)||void 0===o?void 0:o.billingAddress)||void 0===a?void 0:a.countryCode,address_city:null===(l=null===(u=null===(s=e.paymentMethodData)||void 0===s?void 0:s.info)||void 0===u?void 0:u.billingAddress)||void 0===l?void 0:l.locality,address_postcode:null===(p=null===(h=null===(d=e.paymentMethodData)||void 0===d?void 0:d.info)||void 0===h?void 0:h.billingAddress)||void 0===p?void 0:p.postalCode,address_state:null===(m=null===(v=null===(f=e.paymentMethodData)||void 0===f?void 0:f.info)||void 0===v?void 0:v.billingAddress)||void 0===m?void 0:m.administrativeArea,ref_token:e.paymentMethodData.tokenizationData.token})}},y.isShippingRequired()&&{shipping:c(c(c(c(c(c(c(c(c({},b&&{method:b}),y.hasShippingOptions()&&{options:y.meta.shipping_options}),E&&{address_line1:E}),_&&{address_line2:_}),w&&{address_country:w}),C&&{address_city:C}),S&&{address_postcode:S}),T&&{address_state:T}),{contact:c(c(c({},O&&{first_name:O}),A&&{email:A}),P&&{phone:P})})}),onSuccess:function(){return t({transactionState:"SUCCESS"})},onError:function(e){return t({transactionState:"ERROR",error:{intent:"PAYMENT_AUTHORIZATION",message:(null==e?void 0:e.message)||"Error processing payment",reason:"PAYMENT_DATA_INVALID"}})}})}))}},{key:"onPaymentDataChanged",value:function(e){var t=this;if(this.isShippingRequired()){var n=this.parseUpdateData(e),i=new Promise((function(e,n){t.latestShippingChangePromiseResolve=e,t.latestShippingChangePromiseReject=n}));return this.eventEmitter.emit(Ft.UPDATE,n),i}}},{key:"createRequest",value:function(){var e="Apple Safari"===k.getBrowserName();return{apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:[this.createCardData()],existingPaymentMethodRequired:!e}}},{key:"createPaymentDataRequest",value:function(){var e,t,n,i;this.isShippingRequired()&&this.hasShippingOptions()&&(this.selectedShippingOption=null===(e=this.meta)||void 0===e?void 0:e.shipping_options[0]);var r=this.getMerchantId();return c({apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:[c(c({},this.createCardData()),{tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"paydock",gatewayMerchantId:r}}})],transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:this.meta.amount_label,totalPrice:this.meta.amount.toString(),currencyCode:this.meta.currency.toUpperCase(),countryCode:this.meta.country.toUpperCase()},merchantInfo:c(c({},(null===(t=this.meta)||void 0===t?void 0:t.merchant_name)?{merchantName:null===(n=this.meta)||void 0===n?void 0:n.merchant_name}:{}),{merchantId:r}),callbackIntents:["PAYMENT_AUTHORIZATION"].concat(v(this.isShippingRequired()?["SHIPPING_ADDRESS"]:[]),v(this.hasShippingOptions()?["SHIPPING_OPTION"]:[]))},this.isShippingRequired()&&c({shippingAddressRequired:!0},this.hasShippingOptions()&&{shippingOptionRequired:!0,shippingOptionParameters:{defaultSelectedOptionId:null===(i=this.selectedShippingOption)||void 0===i?void 0:i.id,shippingOptions:this.formatShippingOptions(this.meta.shipping_options)}}))}},{key:"createCardData",value:function(){return this.getMetaRawDataInitialization()||{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:["AMEX","DISCOVER","INTERAC","JCB","MASTERCARD","VISA"],billingAddressRequired:!!this.meta.show_billing_address}}}}])}(Bt),sn=function(e){function n(){return o(this,n),t(this,n,arguments)}return l(n,e),s(n,[{key:"initializeChildWallets",value:function(){var e,t,n,i,r,o;this.childWallets=[];var a=!!(null===(n=null===(t=null===(e=this.meta)||void 0===e?void 0:e.credentials)||void 0===t?void 0:t.apple)||void 0===n?void 0:n.merchant),s=!!(null===(o=null===(r=null===(i=this.meta)||void 0===i?void 0:i.credentials)||void 0===r?void 0:r.google)||void 0===o?void 0:o.merchant);!a||this.meta.wallets&&!this.meta.wallets.includes(Ue.APPLE)||this.childWallets.push(new on(this.publicKey,this.meta,this.getGatewayName(),this.eventEmitter)),!s||this.meta.wallets&&!this.meta.wallets.includes(Ue.GOOGLE)||this.childWallets.push(new an(this.publicKey,this.meta,this.getGatewayName(),this.eventEmitter))}},{key:"getGatewayName",value:function(){return Ie.MASTERCARD}},{key:"setEnv",value:function(e){return this.childWallets.forEach((function(t){return t.setEnv(e)})),this}},{key:"update",value:function(e){this.childWallets.forEach((function(t){return t.update(e)}))}}])}(Bt),un=function(e){function n(e,i){var r;return o(this,n),(r=t(this,n,[e,i])).token=e,r.storageDispatcher=new ht("afterpay.wallet.paydock"),r}return l(n,e),s(n,[{key:"load",value:function(e){var t=this;this.storageDispatcher.create((function(){return t.mount(e)}))}},{key:"setEnv",value:function(e){return p(d(n.prototype),"setEnv",this).call(this,e),this.storageDispatcher.setEnv(e),this}},{key:"mount",value:function(e){var t,n,i,o,a=this,s={};(null===(t=this.meta)||void 0===t?void 0:t.style)&&"object"===r(null===(n=this.meta)||void 0===n?void 0:n.style)&&(s=JSON.parse(JSON.stringify((null===(i=this.meta)||void 0===i?void 0:i.style.afterpay)||(null===(o=this.meta)||void 0===o?void 0:o.style))));var u=this.getButton(s);u.onclick=function(){return a.onAfterPayButtonClicked()};var c=this.getButtonStyle(s);e.getElement().appendChild(u),e.getElement().appendChild(c)}},{key:"onAfterPayButtonClicked",value:function(){var e,t,n=this,i=document.createElement("script"),r=null===(e=this.meta)||void 0===e?void 0:e.country;i.type="text/javascript",i.src="live"===(null===(t=this.meta)||void 0===t?void 0:t.gateway_mode)?"https://portal.afterpay.com/afterpay.js":"https://portal.sandbox.afterpay.com/afterpay.js",i.async=!0,i.defer=!0,i.onload=function(){window.AfterPay.initialize({countryCode:r}),n.storageDispatcher.push({intent:at.WIDGET_SESSION,data:{token:n.token}},{onSuccess:function(){n.getCheckoutSession().then((function(e){window.AfterPay.redirect({token:e.ref_token})})).catch((function(e){window.AfterPay.close(),n.eventEmitter.emit(Ft.UNAVAILABLE,{err:e})}))},onError:function(){console.error("Error initializing Afterpay wallet"),window.AfterPay.close(),n.eventEmitter.emit(Ft.UNAVAILABLE,{})}})},document.head.appendChild(i)}},{key:"getCheckoutSession",value:function(){var e=this;return new Promise((function(t,n){return e.eventEmitter.emit(Ft.CALLBACK,{data:{request_type:"CREATE_SESSION",wallet_type:Ue.AFTERPAY},onSuccess:function(e){t(e)},onError:function(e){n(e)}})}))}},{key:"getButton",value:function(e){var t=document.createElement("button");return t.classList.add("afterpay-checkout-btn"),t.setAttribute("type","button"),t.innerHTML='\n <div class="afterpay-checkout-btn__wrapper">\n <svg viewBox="0 0 390 94"\n height="'.concat(this.getHeight(e),'"\n xmlns="http://www.w3.org/2000/svg">\n <g fill="currentColor">\n <path\n d="M388.6 21.4l-34.8 71.8h-14.4l13-26.8-20.5-45h14.8l13.2 30.1 14.3-30.1zM41 46.9c0-8.6-6.2-14.6-13.9-14.6s-13.9 6.1-13.9 14.6c0 8.4 6.2 14.6 13.9 14.6 7.6 0 13.9-6.1 13.9-14.6m.1 25.5v-6.6c-3.8 4.6-9.4 7.4-16.1 7.4C11 73.2.4 62 .4 46.9c0-15 11-26.4 24.9-26.4 6.5 0 12 2.9 15.8 7.3v-6.4h12.5v51H41.1zM114.6 61.1c-4.4 0-5.6-1.6-5.6-5.9V32.5h8.1V21.4H109V8.9H96.1v12.4H79.5v-5.1c0-4.3 1.6-5.9 6.1-5.9h2.8V.4h-6.2C71.6.4 66.6 3.9 66.6 14.5v6.8h-7.1v11.1h7.1v39.9h12.9V32.5h16.6v25c0 10.4 4 14.9 14.4 14.9h6.6V61.1h-2.5zM160.7 42.3c-.9-6.6-6.3-10.6-12.6-10.6s-11.5 3.9-12.9 10.6h25.5zm-25.6 7.9c.9 7.5 6.3 11.8 13.2 11.8 5.4 0 9.6-2.6 12-6.6h13.2c-3.1 10.8-12.7 17.7-25.5 17.7-15.4 0-26.2-10.8-26.2-26.2 0-15.4 11.4-26.5 26.5-26.5 15.2 0 26.2 11.2 26.2 26.5 0 1.1-.1 2.2-.3 3.3h-39.1zM256.2 46.9c0-8.3-6.2-14.6-13.9-14.6s-13.9 6.1-13.9 14.6c0 8.4 6.2 14.6 13.9 14.6 7.6 0 13.9-6.4 13.9-14.6m-40.4 46.3V21.4h12.5V28c3.8-4.7 9.4-7.5 16.1-7.5 13.8 0 24.6 11.3 24.6 26.3s-11 26.4-24.9 26.4c-6.4 0-11.7-2.6-15.4-6.8v26.8h-12.9zM314.2 46.9c0-8.6-6.2-14.6-13.9-14.6-7.6 0-13.9 6.1-13.9 14.6 0 8.4 6.2 14.6 13.9 14.6s13.9-6.1 13.9-14.6m.1 25.5v-6.6c-3.8 4.6-9.4 7.4-16.1 7.4-14 0-24.6-11.2-24.6-26.3 0-15 11-26.4 24.9-26.4 6.5 0 12 2.9 15.8 7.3v-6.4h12.5v51h-12.5zM193.2 26.4s3.2-5.9 11-5.9c3.3 0 5.5 1.2 5.5 1.2v13s-4.7-2.9-9.1-2.3c-4.3.6-7.1 4.6-7.1 9.9v30.2h-13v-51H193v4.9h.2z" />\n </g>\n </svg>\n <svg viewBox="0 0 107 96"\n height="').concat(this.getHeight(e),'"\n xmlns="http://www.w3.org/2000/svg">\n <path\n d="M99 19.5L84.2 11l-15-8.6c-10-5.7-22.4 1.5-22.4 13v1.9c0 1.1.6 2 1.5 2.6l7 4c1.9 1.1 4.4-.3 4.4-2.5v-4.6c0-2.3 2.5-3.7 4.4-2.6l13.8 7.9L91.6 30c2 1.1 2 4 0 5.1L77.9 43l-13.8 7.9c-2 1.1-4.4-.3-4.4-2.6V46c0-11.5-12.4-18.7-22.4-13l-15 8.6-14.8 8.5c-10 5.7-10 20.2 0 26l14.8 8.5 15 8.6c10 5.7 22.4-1.5 22.4-13v-1.9c0-1.1-.6-2-1.5-2.6l-7-4c-1.9-1.1-4.4.3-4.4 2.5v4.6c0 2.3-2.5 3.7-4.4 2.6l-13.8-7.9-13.7-7.9c-2-1.1-2-4 0-5.1l13.7-7.9 13.8-7.9c2-1.1 4.4.3 4.4 2.6v2.3c0 11.5 12.4 18.7 22.4 13l15-8.6L99 45.5c10.1-5.8 10.1-20.2 0-26"\n fill="currentColor" />\n </svg>\n </div>\n '),t}},{key:"getButtonStyle",value:function(e){var t=document.createElement("style"),n=this.generateButtonColor(e.button_type);return t.innerText="\n .afterpay-checkout-btn {\n outline: none;\n border: none;\n border-radius: ".concat(this.getHeight(e),";\n padding: 0;\n margin: 0;\n transition: all 300ms;\n cursor: pointer;\n }\n\n .afterpay-checkout-btn:active {\n opacity: 0.7;\n }\n\n .afterpay-checkout-btn__wrapper {\n display: flex;\n align-items: center;\n padding: 10px 20px;\n color: ").concat(n.color,";\n background-color: ").concat(n.background,";\n border-radius: ").concat(this.getHeight(e),";\n }\n "),t}},{key:"generateButtonColor",value:function(e){switch(e){case"black":return{color:"#B2FCE3",background:"#000"};case"mint":return{color:"#000",background:"#B2FCE3"};default:return{color:"#fff",background:"#000"}}}},{key:"getHeight",value:function(e){return e.height?Number.isNaN(Number(e.height))?e.height:"".concat(e.height,"px"):"40px"}}])}(Bt);var cn=class{DEFAULT_WIDTH=450;DEFAULT_HEIGHT=750;DEFAULT_FEATURES={resizable:"no"};auth;callback;error;frame;isCheckoutOpen;onMessage;url;orderId;accessToken;refreshToken;clientId;onCheckoutClosed;rootUrl;targetOrigin;title;windowFeatures;windowObserver;constructor({auth:e,url:t,clientId:n,mode:i,orderId:r,onCheckoutClosed:o,onError:a,onTokensChanged:s,onPaymentSuccess:u,onPaymentError:c,title:l,windowFeatures:d}){this.callback={ERROR({error:e,orderId:t}){a?.({error:e,orderId:t})},PAYMENT_ERROR({error:e,orderId:t}){c?.({error:e,orderId:t})},PAYMENT_SUCCESS({orderId:e}){u?.({orderId:e})},TOKENS_CHANGED({accessToken:e,refreshToken:t}){s?.({accessToken:e,refreshToken:t})}},this.auth=e,this.isCheckoutOpen=!1,this.error=void 0,this.frame=void 0,this.onMessage=e=>{const{data:n,origin:i}=e;i===t&&(!0===n?.isDomReady&&this.postMessage(),n?.isPaymentSuccessful&&this.callback.PAYMENT_SUCCESS({orderId:n.orderId}),!n?.isPaymentSuccessful&&n?.error&&this.callback.PAYMENT_ERROR({orderId:n.orderId,error:n.error}),!n?.paymentFlowState&&n?.error&&this.callback.ERROR({orderId:n.orderId,error:n.error}),n?.accessToken&&n?.refreshToken&&this.callback.TOKENS_CHANGED({accessToken:n.accessToken,refreshToken:n.refreshToken}))};const h=i||"default";this.rootUrl=t,this.targetOrigin=window.location.href.replace(/\/$/,""),this.url=`${t}?orderId=${r}&merchantUrl=${encodeURIComponent(this.targetOrigin)}&mode=${h}`,this.orderId=r,this.clientId=n,this.onCheckoutClosed=o,this.title=l,this.windowFeatures=d,this.windowObserver=void 0}get isWindowObserverOpen(){return!!this.windowObserver}open=()=>{this.isCheckoutOpen?this.frame?.focus():(this.frame=window.open(this.url,this.title,this.getFeatures()),this.isCheckoutOpen=!0,this.startWindowObserver())};close=()=>{this.frame=void 0,this.isCheckoutOpen=!1,this.stopWindowObserver()};listenMessage=()=>{this.onMessage&&window.addEventListener("message",this.onMessage,!1)};postMessage=()=>{this.frame&&this.rootUrl&&this.frame.postMessage({auth:{...this.auth}},this.rootUrl)};getFeatures(){const e=this.windowFeatures?.width||this.DEFAULT_WIDTH,t=this.windowFeatures?.height||this.DEFAULT_HEIGHT,n={...this.DEFAULT_FEATURES,...this.windowFeatures};return function(e,t="="){return Object.keys(e).length?Object.entries(e).reduce(((e,[n,i])=>[...e,`${n}${t}${i}`]),[]).join(","):""}({...this.getCenteredPosition(e,t),...n,width:e,height:t})}getCenteredPosition(e,t){return{left:screen.width/2-e/2,top:screen.height/2-t/2}}startWindowObserver(){this.isWindowObserverOpen||(this.windowObserver=setInterval((()=>{this.frame?.closed&&(this.close(),this.onCheckoutClosed?.({orderId:this.orderId}),this.onMessage&&window.removeEventListener("message",this.onMessage))}),300))}stopWindowObserver(){clearInterval(this.windowObserver)}};function ln(e){return hn("paydock-flypay-button",e)}function dn(e){return"flypay-v2-checkout-btn__wrapper__".concat(e)}function hn(e,t){return'\n <div id="'.concat(t,'-loading-overlay"></div>\n <div class="').concat(e,'" tabindex="0">\n <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 125.2 21" data-name="pay-with-flypay"\n style="grid-area: center; width: 100%; height: 100%"\n fill="none"\n >\n <path\n fill="#fff"\n d="M89 .5a.5.5 0 0 1 .5-.5h15a.5.5 0 0 1 0 1h-15a.5.5 0 0 1-.5-.5ZM98 22.5a.5.5 0 0 1 .5-.5h15a.5.5 0 0 1 0 1h-15a.5.5 0 0 1-.5-.5ZM87 3.5a.5.5 0 0 1 .5-.5H121c.758 0 1.42.031 1.974.133.553.102 1.044.284 1.421.618.78.694.849 1.829.598 3.331-.258 1.552-1.025 3.843-1.711 5.715a100.003 100.003 0 0 1-1.211 3.128l-.081.198-.021.051v.001c-.531 1.583-1.345 2.557-2.269 3.126-.92.566-1.898.699-2.7.699H96.5a.5.5 0 1 1 0-1v.5-.5H117c.698 0 1.47-.117 2.175-.55.697-.43 1.382-1.2 1.851-2.608l.005-.017.008-.018.006-.016.021-.05.079-.194a94.823 94.823 0 0 0 1.198-3.094c.689-1.878 1.422-4.087 1.664-5.535.249-1.498.068-2.113-.277-2.42-.186-.165-.476-.296-.938-.381C122.33 4.03 121.742 4 121 4H87.5a.5.5 0 0 1-.5-.5ZM76.512 9.512h3.157V7.34h-3.157v-.01h-.02c.01-1.196.841-2.17 2.52-2.17H81V3h-1.988C75.547 3 74.008 4.936 74 7.326V16h2.512V9.512ZM82 3.55 84.987 3H85v13h-3V3.55Z"\n />\n <path\n fill="#fff"\n d="M91.592 15.365a4.557 4.557 0 0 1-1.595.33c-2.391 0-4-1.68-3.997-4.092V7.546l2.41-.543V11.6c0 1.118.536 1.738 1.59 1.738 1.055 0 1.592-.622 1.592-1.738V7.543L94 7v9.855C94 19.41 92.497 21 90.073 21h-.596v-2.359h.59c.71 0 1.525-.641 1.525-1.786v-1.49Z"\n />\n <path\n fill="#fff"\n fill-rule="evenodd"\n d="M2.54 11.6h2.598c1.356 0 2.399-.299 3.129-.896.731-.598 1.096-1.62 1.096-3.063 0-1.323-.365-2.3-1.096-2.93-.73-.631-1.71-.947-2.938-.947H0V16h2.54v-4.4Zm4.291-3.943c0 .637-.166 1.102-.498 1.395-.337.293-.808.44-1.411.44H2.54V5.889h2.382c.603 0 1.071.136 1.403.407.337.271.506.725.506 1.361ZM14.651 6.736c-1.522 0-2.596.398-3.221 1.195-.393.51-.614 1.16-.664 1.95h2.283c.055-.348.166-.624.332-.83.232-.276.628-.414 1.187-.414.498 0 .874.072 1.128.216.261.138.391.392.391.763 0 .305-.169.529-.507.673-.188.083-.501.152-.938.207l-.805.1c-.913.116-1.605.31-2.075.58-.858.499-1.287 1.304-1.287 2.416 0 .858.266 1.522.797 1.993.537.464 1.215.697 2.034.697.642 0 1.217-.147 1.726-.44a4.83 4.83 0 0 0 1.129-.905c.017.205.039.388.067.548.027.16.077.332.149.515h2.573v-.349a.843.843 0 0 1-.348-.274c-.078-.11-.125-.32-.141-.63-.011-.41-.017-.759-.017-1.047V9.55c0-1.09-.385-1.832-1.154-2.225-.769-.393-1.649-.59-2.639-.59Zm-.648 7.828c-.321 0-.592-.092-.813-.274-.227-.177-.341-.468-.341-.872 0-.454.183-.788.548-1.004.216-.128.573-.236 1.071-.324l.531-.1c.266-.05.473-.102.623-.157.155-.061.307-.139.456-.233v.88c-.016.791-.24 1.336-.672 1.635a2.39 2.39 0 0 1-1.403.449Z"\n clip-rule="evenodd"\n />\n <path\n fill="#fff"\n d="m26.097 6.952-1.867 6.674-1.976-6.674h-2.631l3.32 9.446c.022.066-.028.25-.149.548-.117.299-.244.495-.382.59-.144.099-.321.162-.531.19a3.752 3.752 0 0 1-.665.025l-.298-.017v1.893c.254.017.445.025.572.025.128.005.296.008.507.008 1.046 0 1.743-.207 2.092-.622.348-.41.821-1.472 1.419-3.188l3.104-8.898h-2.515ZM40.192 9.409l1.419 6.59h2.433l2.623-9.047h-2.466l-1.411 6.516-1.378-6.516h-2.399l-1.303 6.491-1.411-6.491h-2.54L36.299 16h2.457l1.436-6.591ZM50.41 16V6.952h-2.399V16h2.399ZM50.41 5.873V3.689h-2.399v2.184h2.399ZM56.852 16.083v-1.768l-.241.016h-.224c-.482 0-.769-.044-.863-.133-.094-.094-.142-.326-.142-.697V8.72h1.47V7.035h-1.47V4.51h-2.34v2.524H51.78V8.72h1.262v5.57c0 .564.132.982.398 1.253.41.426 1.173.62 2.291.581l1.121-.041ZM66.547 16v-5.313c0-.808-.028-1.389-.083-1.743a2.347 2.347 0 0 0-.457-1.046 2.656 2.656 0 0 0-1.128-.888 3.836 3.836 0 0 0-1.519-.29c-.499 0-.974.104-1.428.315-.448.204-.844.57-1.187 1.095V3.806h-2.358V16h2.358v-4.898c0-.775.16-1.37.481-1.785.327-.42.803-.63 1.428-.63.603 0 1.013.21 1.228.63.167.3.25.692.25 1.18V16h2.415Z"\n />\n <path\n fill="#fff"\n fill-rule="evenodd"\n d="M103 16h1.997l1.276-2.003h3.56l.265 2.003H112l-1.337-9h-1.778L103 16Zm6.231-6.674.383 2.954h-2.237l1.854-2.954ZM98.02 16l.754-2.72h1.752a6.36 6.36 0 0 0 1.762-.228c.512-.139.992-.37 1.412-.683.398-.299.721-.677.95-1.107.24-.465.36-.978.349-1.496 0-.772-.239-1.389-.716-1.85a2.871 2.871 0 0 0-1.195-.7A5.816 5.816 0 0 0 101.401 7h-2.926L96 16h2.02Zm3.307-7.205c.257-.007.512.026.757.097.194.06.368.165.51.304.101.098.18.215.232.344a.977.977 0 0 1 .072.402c.012.232-.039.463-.147.671-.108.209-.27.387-.471.519-.413.279-.955.418-1.635.418h-1.38l.751-2.752h1.314l-.003-.003Z"\n clip-rule="evenodd"\n />\n <path\n fill="#fff"\n d="m113.439 16 .982-3.548L112.5 7h2.266l1.087 3.73L119.112 7h2.388l-5.078 5.63-.939 3.37h-2.044Z"\n />\n </svg>\n </div>\n ')}var pn=function(e){function n(e,i){var r;return o(this,n),(r=t(this,n,[e,i])).widgetId=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(2,10),r.onFlypayV2ButtonClick=function(){var e=function(e){var t,n=document.getElementById((t=r.widgetId,"".concat(t,"-loading-overlay")));n&&(n.style.display=e)};r.disable(),e("flex"),r.handleMerchantOnButtonClickEvent().then((function(){var t=function(t){var n;e("none"),r.background=r.initBackground(),r.orderId?(null===(n=r.background)||void 0===n||n.initControl(),r.flypayV2Checkout(r.orderId)):r.eventEmitter.emit(Ft.UNAVAILABLE)};r.orderId?t(r.orderId):r.getOrderId().then((function(e){r.orderId=e,t()})).catch((function(t){!function(t){var n;null===(n=r.background)||void 0===n||n.clear(),e("none"),r.enable(),r.eventEmitter.emit(Ft.UNAVAILABLE,{err:t})}(t)}))})).catch((function(t){e("none"),r.enable()}))},r.accessToken=null==i?void 0:i.access_token,r.refreshToken=null==i?void 0:i.refresh_token,r.link=new ae(""),r}return l(n,e),s(n,[{key:"load",value:function(e){this.mount(e)}},{key:"setEnv",value:function(e){return this.link.setEnv(e),p(d(n.prototype),"setEnv",this).call(this,e)}},{key:"enable",value:function(){var e=document.getElementById(this.widgetId);e&&(e.disabled=!1,this.flypayV2Button.innerHTML=ln(this.widgetId))}},{key:"disable",value:function(){var e=document.getElementById(this.widgetId);e&&(e.disabled=!0,this.flypayV2Button.innerHTML=hn("paydock-flypay-button paydock-flypay-button__disabled",this.widgetId))}},{key:"mount",value:function(e){this.flypayV2Button=this.getButton(),this.flypayV2Button.onclick=this.onFlypayV2ButtonClick,e.getElement().appendChild(this.flypayV2Button)}},{key:"getButton",value:function(){var e,t,n=document.createElement("style");return n.innerHTML=(e=this.widgetId,t=dn(e),"\n .".concat(t," {\n position: relative;\n height: 100%;\n width: 100%;\n border: none; /* Remove borders */\n background: transparent; /* Make the button background transparent */\n cursor: pointer; /* Make it look clickable */\n outline: none; /* Remove focus outline */\n padding: 0; /* Remove any default padding */\n }\n\n .").concat(t,' .paydock-flypay-button {\n background-color: #212121;\n border-radius: 9999px;\n width: 100%; /* set hard pixel dimensions here for a button with intrinsic dimensions */\n height: 100%; /* and leave the 100% settings for the Coles use case (enabled by extra param object flag) */\n display: grid;\n grid-template-columns: 20% 1fr 20%;\n grid-template-rows: 20% 1fr 20%;\n grid-template-areas:\n ". . ."\n ". center ."\n ". . .";\n box-sizing: border-box;\n }\n \n .').concat(t," .paydock-flypay-button:hover {\n background-color: #3d3d3d;\n }\n \n .").concat(t," .paydock-flypay-button:focus-visible {\n outline-color: transparent;\n box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #2670ee;\n outline-color: transparent;\n }\n \n .").concat(t," .paydock-flypay-button:active {\n background-color: #6f6f6f;\n }\n \n .").concat(t," .paydock-flypay-button:disabled,\n .").concat(t," .paydock-flypay-button__disabled {\n opacity: 25%;\n cursor: not-allowed;\n }\n \n #").concat(e,"-loading-overlay {\n position: absolute;\n height: 100%;\n width: 100%;\n background: rgba(255, 255, 255, 0.7);\n display: none;\n justify-content: center;\n align-items: center;\n cursor: not-allowed; /* Make it look not clickable */ \n }\n \n #").concat(e,'-loading-overlay::after {\n content: "";\n height: 60%;\n aspect-ratio: 1 / 1;\n display: inline-block;\n border: 4px solid #ccc;\n border-top-color: #333;\n border-radius: 50%;\n /* Vendor prefixes for animation property */\n -webkit-animation: spin 1s infinite linear;\n -moz-animation: spin 1s infinite linear;\n -o-animation: spin 1s infinite linear;\n animation: spin 1s infinite linear;\n }\n \n @-webkit-keyframes spin {\n 0% {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg); \n }\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n }\n \n @-moz-keyframes spin {\n 0% {\n -moz-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -moz-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n }\n \n @-o-keyframes spin {\n 0% {\n -o-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -o-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n }\n \n @keyframes spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n } \n ')),document.head.appendChild(n),this.flypayV2Button=document.createElement("button"),this.flypayV2Button.classList.add(dn(this.widgetId)),this.flypayV2Button.setAttribute("type","button"),this.flypayV2Button.setAttribute("aria-label","Pay with flypay"),this.flypayV2Button.setAttribute("id",this.widgetId),this.flypayV2Button.innerHTML=ln(this.widgetId),this.flypayV2Button}},{key:"handleMerchantOnButtonClickEvent",value:function(){var e=this;return new Promise((function(t,n){var i;e.eventEmitter.emit(Ft.BUTTON_CLICK,{attachResult:function(e){i=e}}),i instanceof Promise?i.then(t).catch(n):!1===i?n():t()}))}},{key:"getOrderId",value:function(){var e=this;return new Promise((function(t,n){return e.eventEmitter.emit(Ft.CALLBACK,{data:{request_type:"CREATE_SESSION"},onSuccess:function(e){return t(e.id)},onError:function(e){return n(e.error)}})}))}},{key:"flypayV2Checkout",value:function(e){var t,n,i=this;this.checkout=new cn(c(c({orderId:e},this.accessToken&&this.refreshToken&&{auth:{access_token:this.accessToken,refresh_token:this.refreshToken},mode:"express"}),{clientId:"live"===(null===(t=this.meta)||void 0===t?void 0:t.gateway_mode)?"dbbd114e-3583-4db5-915e-59f1b3dcd08b":"924ac1ce-00f4-44e4-8277-06cae751ef1a",url:"live"===(null===(n=this.meta)||void 0===n?void 0:n.gateway_mode)?"https://checkout.cxbflypay.com.au":"https://checkout.sandbox.cxbflypay.com.au",onCheckoutClosed:function(){var e;i.eventEmitter.emit(Ft.CHECKOUT_CLOSE),null===(e=i.background)||void 0===e||e.clear(),i.enable()},onError:function(e){return i.eventEmitter.emit(Ft.PAYMENT_ERROR,{error:e})},onPaymentSuccess:function(e){return i.eventEmitter.emit(Ft.PAYMENT_SUCCESS,e)},onPaymentError:function(e){return i.eventEmitter.emit(Ft.PAYMENT_ERROR,{error:e})},onTokensChanged:function(e){var t=e.accessToken,n=e.refreshToken;i.accessToken=t,i.refreshToken=n,i.eventEmitter.emit(Ft.AUTH_TOKENS_CHANGED,{accessToken:t,refreshToken:n})}})),this.checkout.open(),this.checkout.isCheckoutOpen&&this.eventEmitter.emit(Ft.CHECKOUT_OPEN,{}),this.checkout.listenMessage()}},{key:"initBackground",value:function(){var e=this,t=new Ht(this.link.getNetUrl()+oe,!1,!1);return t.setBackdropTitle(""),t.setBackdropDescription(""),t.onTrigger(Ge,(function(){var t;e.checkout.close(),null===(t=e.background)||void 0===t||t.clear(),e.enable()})),t.onTrigger(Je,(function(){return e.checkout.open()})),t}}])}(Bt),fn="unavailable",vn="update",mn="paymentSuccessful",yn="paymentError",gn="paymentInReview",kn="authTokensChanged",En="onClick",_n="onCheckoutOpen",bn="onCheckoutClose",wn=function(){return s((function e(t,n,i){o(this,e),this.hasUpdateHandler=!1;var r=C.validateJWT(n);if(!r)throw new Error("Invalid charge token");this.eventEmitter=new Oe,this.container=new ue(t);var a=C.extractMeta(r.body);switch(this.api=new Ce(n,g.TOKEN),a.gateway.type){case Ie.STRIPE:this.service=new rn(a.credentials.client_auth,c(c({},i),{amount:a.charge.amount,currency:a.charge.currency}));break;case Ie.FLYPAY:this.service=new jt(n,c(c({},i),{id:a.charge.id,gateway_mode:a.gateway.mode,amount:a.charge.amount,currency:a.charge.currency,reference:a.charge.reference}));break;case Ie.FLYPAY_V2:this.service=new pn(n,c(c({},i),{id:a.charge.id,gateway_mode:a.gateway.mode,amount:a.charge.amount,currency:a.charge.currency,reference:a.charge.reference}));break;case Ie.PAYPAL:this.service=new zt(a.credentials.client_auth,c(c({},i),{id:a.charge.id,gateway_mode:a.gateway.mode,amount:a.charge.amount,currency:a.charge.currency,capture:a.charge.capture}));break;case Ie.MASTERCARD:this.service=new sn("",c(c({},i),{credentials:a.gateway.credentials,amount:a.charge.amount,currency:a.charge.currency,gateway_mode:a.gateway.mode}));break;case Ie.AFTERPAY:this.service=new un(n,c(c({},i),{id:a.charge.id,gateway_mode:a.gateway.mode,amount:a.charge.amount,currency:a.charge.currency,reference:a.charge.reference}))}}),[{key:"load",value:function(){try{this.setupServiceCallbacks(),this.service.load(this.container)}catch(e){throw this.eventEmitter.emit(fn,null),e}}},{key:"update",value:function(e){this.service.update(e)}},{key:"setEnv",value:function(e,t){this.api.setEnv(e,t),this.service.setEnv(e)}},{key:"enable",value:function(){this.service.enable()}},{key:"disable",value:function(){this.service.disable()}},{key:"close",value:function(){"function"==typeof this.service.close&&this.service.close()}},{key:"on",value:function(e,t){var n=this;return e===vn&&(this.hasUpdateHandler=!0),"function"==typeof t?this.eventEmitter.subscribe(e,t):new Promise((function(t){return n.eventEmitter.subscribe(e,(function(e){return t(e)}))}))}},{key:"onUnavailable",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(fn,e):new Promise((function(e){return t.eventEmitter.subscribe(fn,(function(){return e()}))}))}},{key:"onUpdate",value:function(e){var t=this;return this.hasUpdateHandler=!0,"function"==typeof e?this.eventEmitter.subscribe(vn,e):new Promise((function(e){return t.eventEmitter.subscribe(vn,(function(t){return e(t)}))}))}},{key:"onPaymentSuccessful",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(mn,e):new Promise((function(e){return t.eventEmitter.subscribe(mn,(function(t){return e(t)}))}))}},{key:"onPaymentInReview",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(gn,e):new Promise((function(e){return t.eventEmitter.subscribe(gn,(function(t){return e(t)}))}))}},{key:"onPaymentError",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(yn,e):new Promise((function(e){return t.eventEmitter.subscribe(yn,(function(t){return e(t)}))}))}},{key:"onAuthTokensChanged",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(kn,e):new Promise((function(e){return t.eventEmitter.subscribe(kn,(function(t){return e(t)}))}))}},{key:"onClick",value:function(e){if("function"==typeof e)return this.eventEmitter.subscribe(En,e)}},{key:"onCheckoutOpen",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(_n,e):new Promise((function(e){return t.eventEmitter.subscribe(_n,(function(t){return e(t)}))}))}},{key:"onCheckoutClose",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(bn,e):new Promise((function(e){return t.eventEmitter.subscribe(bn,(function(t){return e(t)}))}))}},{key:"setupServiceCallbacks",value:function(){this.setupUnavailableCallback(),this.setupUpdateCallback(),this.setupWalletCallback(),this.setupPaymentCallback(),this.setupPaymentSuccessCallback(),this.setupPaymentInReviewCallback(),this.setupPaymentErrorCallback(),this.setupAuthTokensChangedCallback(),this.setupOnClickCallback(),this.setupOnCheckoutOpenCallback(),this.setupOnCheckoutCloseCallback()}},{key:"setupUnavailableCallback",value:function(){var e=this;this.service.on(Ft.UNAVAILABLE,(function(t){return e.eventEmitter.emit(fn,{event:fn,data:t})}))}},{key:"setupUpdateCallback",value:function(){var e=this;this.service.on(Ft.UPDATE,(function(t){return e.hasUpdateHandler?e.eventEmitter.emit(vn,{event:vn,data:t}):e.update({success:!0})}))}},{key:"setupOnClickCallback",value:function(){var e=this;this.service.on(Ft.BUTTON_CLICK,(function(t){return e.eventEmitter.emit(En,{event:En,data:t})}))}},{key:"setupOnCheckoutOpenCallback",value:function(){var e=this;this.service.on(Ft.CHECKOUT_OPEN,(function(t){return e.eventEmitter.emit(_n,{event:_n,data:t})}))}},{key:"setupOnCheckoutCloseCallback",value:function(){var e=this;this.service.on(Ft.CHECKOUT_CLOSE,(function(t){return e.eventEmitter.emit(bn,{event:bn,data:t})}))}},{key:"setupWalletCallback",value:function(){var e=this;this.service.on(Ft.CALLBACK,(function(t){var n=t.data,i=t.onSuccess,r=t.onError;e.api.charge().walletCallback(n).then((function(e){return i(e)}),(function(e){return r(e.message)}))}))}},{key:"setupPaymentCallback",value:function(){var e=this;this.service.on(Ft.PAYMENT_METHOD_SELECTED,(function(t){var n=t.data,i=t.onSuccess,r=t.onError;e.api.charge().walletCapture(n).then((function(t){"function"==typeof i&&i();var r="inreview"===t.status?gn:mn;e.eventEmitter.emit(r,{event:r,data:c(c({},t),n.customer&&{payer_name:n.customer.payer_name,payer_email:n.customer.payer_email,payer_phone:n.customer.payer_phone})})}),(function(t){"function"==typeof r&&r(t),e.eventEmitter.emit(yn,{event:yn,data:t})}))}))}},{key:"setupPaymentSuccessCallback",value:function(){var e=this;this.service.on(Ft.PAYMENT_SUCCESS,(function(t){return e.eventEmitter.emit(mn,{event:mn,data:t})}))}},{key:"setupPaymentInReviewCallback",value:function(){var e=this;this.service.on(Ft.PAYMENT_IN_REVIEW,(function(t){return e.eventEmitter.emit(gn,{event:gn,data:t})}))}},{key:"setupPaymentErrorCallback",value:function(){var e=this;this.service.on(Ft.PAYMENT_ERROR,(function(t){return e.eventEmitter.emit(yn,{event:yn,data:t})}))}},{key:"setupAuthTokensChangedCallback",value:function(){var e=this;this.service.on(Ft.AUTH_TOKENS_CHANGED,(function(t){return e.eventEmitter.emit(kn,{event:kn,data:t})}))}}])}(),Cn={CARD:"card",GIFT_CARD:"gift_card",BANK_ACCOUNT:"bank_account",CHECKOUT:"checkout"},Sn={PAYMENT_SOURCE:"payment_source",CARD_PAYMENT_SOURCE_WITH_CVV:"card_payment_source_with_cvv",CARD_PAYMENT_SOURCE_WITHOUT_CVV:"card_payment_source_without_cvv"},Tn=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Cn.CARD,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Sn.PAYMENT_SOURCE;if(o(this,e),-1===wt.values(Cn).indexOf(n))throw new Error("unsupported payment type");if(n===Cn.CHECKOUT)throw new Error('Payment type "checkout" is deprecated. Use CheckoutButton for this type of payments https://www.npmjs.com/package/@paydock/client-sdk#checkout-button');if(-1===wt.values(Sn).indexOf(i))throw new Error("unsupported purpose");this.env=new X(Y),this.configs={purpose:i,meta:{},dynamic_fields_position:!0,predefined_fields:{gateway_id:t,type:n,card_scheme:null,card_processing_network:null}}}return s(e,[{key:"setWebHookDestination",value:function(e){this.configs.webhook_destination=e}},{key:"setSuccessRedirectUrl",value:function(e){this.configs.success_redirect_url=e}},{key:"setErrorRedirectUrl",value:function(e){this.configs.error_redirect_url=e}},{key:"setFormFields",value:function(e){for(var t in Array.isArray(this.configs.defined_form_fields)||(this.configs.defined_form_fields=[]),e)e.hasOwnProperty(t)&&(-1!==wt.values(De).indexOf(e[t].replace("*",""))?this.configs.defined_form_fields.push(e[t]):console.warn("Configuration::setFormFields: unsupported form field ".concat(e[t])))}},{key:"setMeta",value:function(e){for(var t in e)e.hasOwnProperty(t)&&(-1!==je.indexOf(t)?this.configs.meta[t]=e[t]:console.warn("Configuration::setMeta: unsupported meta key ".concat(t)))}},{key:"setEnv",value:function(e,t){this.env.setEnv(e,t)}},{key:"setLabel",value:function(e){this.configs.label=e}},{key:"getEnv",value:function(){return this.env.getEnv()}},{key:"createToken",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(e){};this.send(e,(function(e,i){if(i>=200&&i<300)return t(e.resource.data.configuration_token);void 0===e.error||void 0===e.error.message?n("unknown error"):n(e.error.message)}))}},{key:"send",value:function(e,t){var n=new XMLHttpRequest;n.open("POST",this.getUrl(),!0),n.setRequestHeader("Content-Type","application/json; charset=UTF-8"),n.setRequestHeader(C.getAccessHeaderNameByToken(e),e),$.version&&(n.setRequestHeader($.headerKeys.version,$.version),n.setRequestHeader($.headerKeys.type,$.type)),n.send(JSON.stringify(this.getConfigs())),n.onload=function(){var e={};try{e=JSON.parse(n.responseText)}catch(e){}t(e,n.status)}}},{key:"getConfigs",value:function(){return this.configs}},{key:"getUrl",value:function(){return this.env.getConf().url+"/v1/remote-action/configs"}},{key:"setGiftCardSchemeData",value:function(e,t){if(this.configs.predefined_fields.type!==Cn.GIFT_CARD)throw new Error("unsupported payment type");if(!e||!t)throw new Error("");this.configs.predefined_fields.card_scheme=e,this.configs.predefined_fields.card_processing_network=t}}],[{key:"createEachToken",value:function(t,n,i){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(e){},o=new Array(n.length),a=[],s=0,u=function(u){n.hasOwnProperty(u)&&n[u].createToken(t,(function(t){o[u]=t,s++,n.length===s&&e.finishCreatingEachToken(o,a,i,r)}),(function(t){a.push("gateway: ".concat(n[u].getConfigs().predefined_fields.gateway_id," | ").concat(t)),s++,n.length===s&&e.finishCreatingEachToken(o,a,i,r)}))};for(var c in n)u(c)}},{key:"finishCreatingEachToken",value:function(e,t,n,i){t.length>=1?i(t):n(e)}}])}(),On={INPUT:"input",SUBMIT_BUTTON:"submit_button",LABEL:"label",TITLE:"title",TITLE_DESCRIPTION:"title_description"},An={ERROR:"error",FOCUS:"focus",HOVER:"hover"},Pn=[{element:On.INPUT,states:[An.FOCUS,An.ERROR],styles:["color","border","border_radius","background_color","height","text_decoration","font_size","font_family","line_height","font_weight","padding","margin","transition"]},{element:On.SUBMIT_BUTTON,states:[An.HOVER],styles:["color","border","border_radius","background_color","text_decoration","font_size","font_family","line_height","font_weight","padding","margin","transition","opacity"]},{element:On.LABEL,states:[],styles:["color","text_decoration","font_size","font_family","line_height","font_weight","padding","margin"]},{element:On.TITLE,states:[],styles:["color","text_decoration","font_size","font_family","line_height","font_weight","padding","margin","text_align"]},{element:On.TITLE_DESCRIPTION,states:[],styles:["color","text_decoration","font_size","font_family","line_height","font_weight","padding","margin","text_align"]}],Rn=function(){return s((function e(){o(this,e)}),null,[{key:"check",value:function(e,t,n,i){for(var r in e)if(e.hasOwnProperty(r)&&e[r].element===t){if(-1===e[r].states.indexOf(n)&&n)return!1;for(var o in i)if(i.hasOwnProperty(o)&&-1===e[r].styles.indexOf(o.replace("-","_")))return!1;return!0}return!1}},{key:"encode",value:function(e,t,n){var i=[];for(var r in n)n.hasOwnProperty(r)&&i.push("".concat(r.replace("_","-"),":").concat(n[r]));var o=i.join(";");return t?"".concat(e,"::").concat(t,"{").concat(o,"}"):"".concat(e,"{").concat(o,"}")}},{key:"decode",value:function(e){var t=(e.match("::(.*){")||["",null])[1],n=null!==t?(e.match("(.*)::")||["",""])[1].trim():(e.match("(.*){")||["",""])[1].trim(),i=(e.match("{(.*)}")||["",""])[1].split(";"),r={};for(var o in i)if(i.hasOwnProperty(o)){var a=i[o].split(":");(a||2===a.length)&&(r[a[0].trim()]=(a[1]||"").trim())}return{element:n,state:t,styles:r}}}])}(),xn=function(){return s((function e(t,n){if(o(this,e),this.configs=[],this.configTokens=[],this.link=new ae("/remote-action"),$.version&&this.link.setParams({sdk_version:$.version,sdk_type:$.type}),C.validateJWT(t)?this.link.setParams({token:t}):this.link.setParams({public_key:t}),this.accessToken=t,!n||Array.isArray(n)&&!n.length)throw Error("configuration token is required");if("string"==typeof n)this.configTokens.push(n);else if(n instanceof Tn)this.configs.push(n);else if(Array.isArray(n)&&"string"==typeof n[0])this.configTokens=n;else{if(!(Array.isArray(n)&&n[0]instanceof Tn))throw Error("Unsupported type of configuration token");this.configs=n}}),[{key:"setStyles",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setStyle(t,e[t])}},{key:"usePhoneCountryMask",value:function(e){return e?!e.only_countries||/^[a-z]+$/.test(e.only_countries.join(""))&&2*e.only_countries.length===e.only_countries.join("").length?!e.preferred_countries||/^[a-z]+$/.test(e.preferred_countries.join(""))&&2*e.preferred_countries.length===e.preferred_countries.join("").length?e.default_country&&2!==e.default_country.length?console.warn("Widget::usePhoneCountryMask[s: default_country - incorrect value length"):(this.link.setParams({use_country_phone_mask:!0}),e.only_countries&&this.link.setParams({phone_mask_only_countries:e.only_countries.join(",")}),e.preferred_countries&&this.link.setParams({phone_mask_preferred_countries:e.preferred_countries.join(",")}),void(e.default_country&&this.link.setParams({phone_mask_default_country:e.default_country}))):console.warn("Widget::usePhoneCountryMask[s: preferred_countries - unsupported symbols or incorrect length of value"):console.warn("Widget::usePhoneCountryMask[s: only_countries - unsupported symbols or incorrect length of value"):this.link.setParams({use_country_phone_mask:!0})}},{key:"setStyle",value:function(e,t){-1!==wt.values(Me).indexOf(e)?this.link.setParams(u({},e,t)):console.warn("Widget::setStyle[s: unsupported style param ".concat(e))}},{key:"setTexts",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setText(t,e[t])}},{key:"setText",value:function(e,t){-1!==wt.values(He).indexOf(e)?this.link.setParams(u({},e,t)):console.warn("Widget::setText[s: unsupported text param ".concat(e))}},{key:"setElementStyle",value:function(e,t,n){var i=3===arguments.length?t:null,r=3===arguments.length?n:t;if(!Rn.check(Pn,e,i,r))return console.warn('Styles for "'.concat(e,'" element with "').concat(i||"default",'" state was ignored because some of the arguments are unacceptable'));this.link.concatParams({element_styles:Rn.encode(e,i,r)})}},{key:"setFormValues",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setFormValue(t,e[t])}},{key:"setFormValue",value:function(e,t){return-1===wt.values(De).indexOf(e)?console.warn("Widget::setFormValues[s: unsupported field ".concat(e)):/\,/.test(t)||/\:/.test(t)?console.warn("Widget::setFormValues[s: ".concat(e," - unsupported symbols (: or ,) in value")):void("string"==typeof this.link.getParams().form_values&&this.link.getParams().form_values.length?this.link.setParams({form_values:"".concat(this.link.getParams().form_values,",").concat(e,":").concat(t)}):this.link.setParams({form_values:"".concat(e,":").concat(t)}))}},{key:"setFormLabels",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setFormLabel(t,e[t])}},{key:"setFormLabel",value:function(e,t){if(-1===wt.values(De).indexOf(e))return console.warn("Widget::setFormLabel[s: unsupported field ".concat(e));var n=null===t||""===t?" ":t;if(/\,/.test(n)||/\:/.test(n))return console.warn("Widget::setFormLabel[s: ".concat(e," - unsupported symbols (: or ,) in value"));this.link.concatParams({form_labels:"".concat(e,":").concat(n)})}},{key:"setFormPlaceholders",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setFormPlaceholder(t,e[t])}},{key:"setFormPlaceholder",value:function(e,t){if(-1===wt.values(De).indexOf(e))return console.warn("Widget::setFormPlaceholder[s: unsupported field ".concat(e));var n=null===t||""===t?" ":t;if(/\,/.test(n)||/\:/.test(n))return console.warn("Widget::setFormPlaceholder[s: ".concat(e," - unsupported symbols (: or ,) in value"));this.link.concatParams({form_placeholders:"".concat(e,":").concat(n)})}},{key:"setFormElements",value:function(e){var t=this;e.forEach((function(e){return t.setFormElement(e)}))}},{key:"setFormElement",value:function(e){e.value&&this.setFormValue(e.field,e.value),e.label&&this.setFormLabel(e.field,e.label),e.placeholder&&this.setFormPlaceholder(e.field,e.placeholder)}},{key:"setIcons",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setIcon(t,e[t])}},{key:"setIcon",value:function(e,t){if(/\,/.test(t)||/\:/.test(t))return console.warn("Widget::setIcon[s: ".concat(e," - unsupported symbols (: or ,) in value"));"string"==typeof this.link.getParams().icons&&this.link.getParams().icons.length?this.link.setParams({icons:"".concat(this.link.getParams().icons,",").concat(e,":").concat(t)}):this.link.setParams({icons:"".concat(e,":").concat(t)})}},{key:"setHiddenElements",value:function(e){var t=[],n=wt.values(Fe).concat(wt.values(De));for(var i in e)e.hasOwnProperty(i)&&(-1!==n.indexOf(e[i])?t.push(e[i]):console.warn("Widget::setHiddenElements: unsupported element ".concat(e[i])));t.length&&this.link.concatParams({hidden_elements:t.join(",")})}},{key:"setRefId",value:function(e){this.link.setParams({ref_id:e})}},{key:"useGatewayFieldValidation",value:function(){this.link.setParams({fields_validation:!0})}},{key:"setSupportedCardIcons",value:function(e,t){var n=[];for(var i in e)e.hasOwnProperty(i)&&(-1!==wt.values(Be).indexOf(e[i])?n.push(e[i]):console.warn("Widget::cardTypes: unsupported type of cards ".concat(e[i])));n.length&&this.link.concatParams({supported_card_types:n.join(",")}),t&&this.link.setParams({validate_card_types:t})}},{key:"setEnv",value:function(e,t){for(var n in this.link.setEnv(e,t),this.configs)this.configs.hasOwnProperty(n)&&this.configs[n].setEnv(e,t)}},{key:"getEnv",value:function(){this.link.getEnv()}},{key:"loadIFrameUrl",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(e){};if(this.link.setParams({configuration_tokens:""}),this.configTokens.length)return this.link.setParams({configuration_tokens:this.configTokens.join(",")}),e(this.link.getUrl());Tn.createEachToken(this.accessToken,this.configs,(function(n){return t.link.concatParams({configuration_tokens:n.join(",")}),e(t.link.getUrl())}),(function(e){n(e)}))}},{key:"setLanguage",value:function(e){this.link.setParams({language:e})}}])}(),In=function(){return s((function e(t){o(this,e),this.intercepted=!1,this.selector=t}),[{key:"getElement",value:function(){return document.querySelector(this.selector)}},{key:"isExist",value:function(){return!!this.getElement()}},{key:"beforeSubmit",value:function(e){var t=this;this.isExist()&&this.subscribe(this.getElement(),(function(n){n.preventDefault(),t.intercepted=!0,e.apply(t,[])}))}},{key:"continueSubmit",value:function(){var e=this;this.isExist()&&this.intercepted&&(this.intercepted=!1,setTimeout((function(){e.getElement().submit()}),50))}},{key:"subscribe",value:function(e,t){e.addEventListener?e.addEventListener("submit",t):e.attachEvent("onsubmit",t)}}])}(),Un=function(e){function n(e,i,r){var a;return o(this,n),(a=t(this,n,[i,r])).validationData={},a.container=new ue(e),a.iFrame=new ce(a.container),a.triggerElement=new xt(a.iFrame),a.event=new de(window),a}return l(n,e),s(n,[{key:"load",value:function(){var e=this;this.setStyles(this.container.getStyles(wt.values(Me))),this.setTexts(this.container.getAttr(wt.values(He))),this.loadIFrameUrl((function(t){e.iFrame.load(t,{title:"Card details"}),e.afterLoad()}),(function(e){for(var t in console.error("Errors when creating a token[s, widget will not be load:"),e)e.hasOwnProperty(t)&&console.error("--- | ".concat(e[t]))}))}},{key:"afterLoad",value:function(){var e=this;this.on(le.VALIDATION,(function(t){e.validationData=t}))}},{key:"on",value:function(e,t){var n=this;return"function"==typeof t?this.event.on(e,this.link.getParams().widget_id,t):new Promise((function(t){return n.event.on(e,n.link.getParams().widget_id,(function(e){return t(e)}))}))}},{key:"trigger",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.triggerElement.push(e,t)}},{key:"getValidationState",value:function(){return this.validationData}},{key:"isValidForm",value:function(){return!!this.validationData.form_valid}},{key:"isInvalidField",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!!this.validationData.invalid_fields&&-1!==this.validationData.invalid_fields.indexOf(e)}},{key:"isFieldErrorShowed",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!!this.validationData.invalid_showed_fields&&-1!==this.validationData.invalid_showed_fields.indexOf(e)}},{key:"isInvalidFieldByValidator",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0,n=!1;if(!this.validationData.validators)return n;var i=this.validationData.validators[t];return i?-1!==i.indexOf(e):n}},{key:"hide",value:function(e){this.iFrame.hide(e)}},{key:"show",value:function(){this.iFrame.show()}},{key:"reload",value:function(){this.iFrame.remove(),this.load()}},{key:"hideElements",value:function(e){var t=[],n=wt.values(Fe).concat(wt.values(De));for(var i in e)e.hasOwnProperty(i)&&(-1!==n.indexOf(e[i])?t.push(e[i]):console.warn("Widget::hideElements: unsupported element ".concat(e[i])));t.length&&this.trigger(Rt.HIDE_ELEMENTS,{elements:t.join(",")})}},{key:"showElements",value:function(e){var t=[],n=wt.values(Fe).concat(wt.values(De));for(var i in e)e.hasOwnProperty(i)&&(-1!==n.indexOf(e[i])?t.push(e[i]):console.warn("Widget::showElements: unsupported element ".concat(e[i])));t.length&&this.trigger(Rt.SHOW_ELEMENTS,{elements:t.join(",")})}},{key:"updateFormValues",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.updateFormValue(t,e[t])}},{key:"updateFormValue",value:function(e,t){return-1===wt.values(De).indexOf(e)?console.warn("Widget::setFormValues[s: unsupported field ".concat(e)):/\,/.test(t)||/\:/.test(t)?console.warn("Widget::setFormValues[s: ".concat(e," - unsupported symbols (: or ,) in value")):void this.trigger(Rt.UPDATE_FORM_VALUES,{form_values:"".concat(e,":").concat(t)})}},{key:"onFinishInsert",value:function(e,t){this.on(le.FINISH,(function(n){se.insertToInput(e,t,n)}))}},{key:"interceptSubmitForm",value:function(e){var t=this;this.setHiddenElements([Fe.SUBMIT_BUTTON]);var n=new In(e);n.beforeSubmit((function(){t.triggerElement.push(Rt.SUBMIT_FORM,{}),t.event.on(le.FINISH,t.link.getParams().widget_id,(function(){n.continueSubmit()}))}))}},{key:"useCheckoutAutoSubmit",value:function(){var e=this;this.setHiddenElements([Fe.SUBMIT_BUTTON]),this.on(le.CHECKOUT_SUCCESS,(function(t){e.trigger(Rt.SUBMIT_FORM)})),this.on(le.VALIDATION_ERROR,(function(t){e.trigger(Rt.REFRESH_CHECKOUT)})),this.on(le.SYSTEM_ERROR,(function(t){e.trigger(Rt.REFRESH_CHECKOUT)}))}},{key:"useAutoResize",value:function(){var e=this;this.on(le.RESIZE,(function(t){e.iFrame.getElement()&&(e.iFrame.getElement().scrolling="no",t.height&&e.iFrame.setStyle("height",t.height+"px"))}))}}])}(xn),Ln=function(e){function n(e,i){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"default",a=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;return o(this,n),t(this,n,[e,i,new Tn(r,a,s)])}return l(n,e),s(n,[{key:"setWebHookDestination",value:function(e){this.configs[0].setWebHookDestination(e)}},{key:"setSuccessRedirectUrl",value:function(e){this.configs[0].setSuccessRedirectUrl(e)}},{key:"setErrorRedirectUrl",value:function(e){this.configs[0].setErrorRedirectUrl(e)}},{key:"setFormFields",value:function(e){this.configs[0].setFormFields(e)}},{key:"setFormElements",value:function(e){var t=this;e.forEach((function(e){return t.setFormElement(e)}))}},{key:"setFormElement",value:function(e){this.configs[0].setFormFields([e.field]),p(d(n.prototype),"setFormElement",this).call(this,c(c({},e),{field:e.field.replace("*","")}))}},{key:"setMeta",value:function(e){this.configs[0].setMeta(e)}},{key:"setGiftCardScheme",value:function(e,t){this.configs[0].setGiftCardSchemeData(e,t)}}])}(Un);e.AfterpayCheckoutButton=_t,e.Api=te,e.CHECKOUT_BUTTON_EVENT=xe,e.Canvas3ds=Re,e.ClickToPay=Pt,e.Configuration=Tn,e.ELEMENT=Fe,e.EVENT=le,e.ExternalCheckoutBuilder=qe,e.ExternalCheckoutChecker=Ke,e.FORM_FIELD=De,e.HtmlMultiWidget=Un,e.HtmlPaymentSourceWidget=St,e.HtmlWidget=Ln,e.MultiWidget=xn,e.PAYMENT_TYPE=Cn,e.PURPOSE=Sn,e.PaymentSourceBuilder=yt,e.PaymentSourceWidget=Ct,e.PaypalCheckoutButton=bt,e.STYLABLE_ELEMENT=On,e.STYLABLE_ELEMENT_STATE=An,e.STYLE=Me,e.SUPPORTED_CARD_TYPES=Be,e.TEXT=He,e.TRIGGER=Rt,e.TYPE=mt,e.VAULT_DISPLAY_STYLE={BACKGROUND_COLOR:"background_color",TEXT_COLOR:"text_color",BORDER_COLOR:"border_color",BUTTON_COLOR:"button_color",FONT_SIZE:"font_size",FONT_FAMILY:"font_family"},e.VaultDisplayWidget=Lt,e.WalletButtons=wn,e.ZipmoneyCheckoutButton=Et}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("isomorphic-dompurify")):"function"==typeof define&&define.amd?define(["exports","isomorphic-dompurify"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).paydock={})}(this,(function(e){"use strict";function t(e,t,i){return t=d(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,n()?Reflect.construct(t,i||[],d(e).constructor):t.apply(e,i))}function n(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(n=function(){return!!e})()}function i(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,i(r.key),r)}}function s(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function u(e,t,n){return(t=i(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},c.apply(this,arguments)}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}function d(e){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},d(e)}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function p(){return p="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=d(e)););return e}(e,t);if(i){var r=Object.getOwnPropertyDescriptor(i,t);return r.get?r.get.call(arguments.length<3?e:n):r.value}},p.apply(this,arguments)}function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t);else for(;!(u=(i=o.call(n)).done)&&(s.push(i.value),s.length!==t);u=!0);}catch(e){c=!0,r=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw r}}return s}}(e,t)||m(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e){return function(e){if(Array.isArray(e))return y(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||m(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(e,t){if(e){if("string"==typeof e)return y(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(e,t):void 0}}function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}var g,k=function(){return s((function e(){o(this,e)}),null,[{key:"isFacebook",value:function(){return-1!==navigator.userAgent.indexOf("FBSN/iOS")&&-1!==navigator.userAgent.indexOf("AppleWebKit")&&-1!==navigator.userAgent.indexOf("(KHTML, like Gecko)")}},{key:"isInstagram",value:function(){return-1!==navigator.userAgent.indexOf("iOS")&&-1!==navigator.userAgent.indexOf("Instagram")&&-1!==navigator.userAgent.indexOf("(KHTML, like Gecko)")}},{key:"isSupportPopUp",value:function(){return!this.isFacebook()&&!this.isInstagram()}},{key:"getLanguage",value:function(){return window.navigator.language||""}},{key:"getTimezoneOffset",value:function(){return(new Date).getTimezoneOffset()}},{key:"getBrowserName",value:function(){var e=navigator.userAgent;return e.indexOf("Firefox")>-1?"Mozilla Firefox":e.indexOf("Opera")>-1?"Opera":e.indexOf("Trident")>-1?"Microsoft Internet Explorer":e.indexOf("Edge")>-1?"Microsoft Edge":e.indexOf("Chrome")>-1?"Google Chrome or Chromium":e.indexOf("Safari")>-1?"Apple Safari":"unknown"}},{key:"isJavaEnabled",value:function(){return navigator.javaEnabled()}},{key:"getColorDepth",value:function(){return screen.colorDepth}},{key:"getScreenHeight",value:function(){return screen.height}},{key:"getScreenWidth",value:function(){return screen.width}},{key:"getBrowserInfo",value:function(){var e,t=navigator.userAgent,n=t.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];return/trident/i.test(n[1])?{name:"IE",version:(e=/\brv[ :]+(\d+)/g.exec(t)||[])[1]||""}:"Chrome"===n[1]&&null!=(e=t.match(/\bOPR|Edge\/(\d+)/))?{name:"Opera",version:e[1]}:(n=n[2]?[n[1],n[2]]:[navigator.appName,navigator.appVersion,"-?"],null!=(e=t.match(/version\/(\d+)/i))&&n.splice(1,1,e[1]),{name:n[0],version:n[1]})}}])}(),E="/v1/charges/3ds",_=function(){return s((function e(t){o(this,e),this.api=t}),[{key:"preAuth",value:function(e,t){return"function"==typeof t?this.api.getClient("POST",E).send(c(c({},e),{_3ds:c(c({},e._3ds),{browser_details:{name:k.getBrowserName(),java_enabled:k.isJavaEnabled().toString(),language:k.getLanguage(),screen_height:k.getScreenHeight().toString(),screen_width:k.getScreenWidth().toString(),time_zone:k.getTimezoneOffset().toString(),color_depth:k.getColorDepth().toString()}})}),(function(e){t(e)})):this.api.getClientPromise("POST",E).send(c(c({},e),{_3ds:c(c({},e._3ds),{browser_details:{name:k.getBrowserName(),java_enabled:k.isJavaEnabled().toString(),language:k.getLanguage(),screen_height:k.getScreenHeight().toString(),screen_width:k.getScreenWidth().toString(),time_zone:k.getTimezoneOffset().toString(),color_depth:k.getColorDepth().toString()}})}))}}])}(),b="x-access-token",w="x-user-public-key",C=function(){function e(){o(this,e)}return s(e,null,[{key:"validateJWT",value:function(e){if(!e)return null;var t=f(e.split("."),3),n=t[0],i=t[1],r=t[2];if(!n||!i||!r)return null;if(2+n.length+i.length+r.length!==e.length)return null;try{return{head:JSON.parse(atob(n)),body:JSON.parse(atob(i)),signature:r}}catch(e){return null}}},{key:"extractData",value:function(e){try{return JSON.parse(atob(e.meta))}catch(e){return null}}},{key:"extractMeta",value:function(e){try{return JSON.parse(atob(e.meta)).meta}catch(e){return null}}},{key:"getAccessHeaderNameByToken",value:function(t){return e.validateJWT(t)?b:w}}])}(),S="sandbox",T="sandbox-kovena",O="sandbox-demo-kovena",A="production",P="staging",R="staging_1",x="staging_2",I="staging_3",U="staging_4",L="staging_5",N="staging_6",D="staging_7",M="staging_8",H="staging_9",F="staging_10",B="staging_11",j="staging_12",z="staging_13",V="staging_14",q="staging_15",K=[{env:S,url:"https://widget-sandbox."},{env:T,url:"https://widget-sandbox."},{env:"sandbox-demo",url:"https://widget-sandbox-demo."},{env:O,url:"https://widget-sandbox-demo."},{env:A,url:"https://widget."},{env:P,url:"https://widsta."},{env:R,url:"https://widsta-1."},{env:x,url:"https://widsta-2."},{env:I,url:"https://widsta-3."},{env:U,url:"https://widsta-4."},{env:L,url:"https://widsta-5."},{env:N,url:"https://widsta-6."},{env:D,url:"https://widsta-7."},{env:M,url:"https://widsta-8."},{env:H,url:"https://widsta-9."},{env:F,url:"https://widsta-10."},{env:B,url:"https://widsta-11."},{env:j,url:"https://widsta-12."},{env:z,url:"https://widsta-13."},{env:V,url:"https://widsta-14."},{env:q,url:"https://widsta-15."}],Y=[{env:S,url:"https://api-sandbox."},{env:A,url:"https://api."},{env:P,url:"https://apista."},{env:R,url:"https://apista-1."},{env:x,url:"https://apista-2."},{env:I,url:"https://apista-3."},{env:U,url:"https://apista-4."},{env:L,url:"https://apista-5."},{env:N,url:"https://apista-6."},{env:D,url:"https://apista-7."},{env:M,url:"https://apista-8."},{env:H,url:"https://apista-9."},{env:F,url:"https://apista-10."},{env:B,url:"https://apista-11."},{env:j,url:"https://apista-12."},{env:z,url:"https://apista-13."},{env:V,url:"https://apista-14."},{env:q,url:"https://apista-15."}],W=[T,O],G=S,J="paydock.com",Z="kovena.com",X=function(){return s((function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:G;o(this,e),this.configs=t,this.setEnv(n)}),[{key:"setEnv",value:function(e,t){if(!this.isValidMode(this.configs,e))throw new Error("unknown env: "+e);if(this.env=e,t&&!t.match("^([a-zA-Z0-9](?:(?:[a-zA-Z0-9-.]*(?!-)\\.(?![-.]))*[a-zA-Z0-9]+)?)$"))throw new Error("invalid: "+t);t?this.alias=t:-1!==W.indexOf(this.env)?this.alias=Z:this.alias=J}},{key:"getEnv",value:function(){return this.env}},{key:"getConf",value:function(){for(var e in this.configs)if(this.configs.hasOwnProperty(e)&&this.configs[e].env===this.getEnv())return{url:-1!==this.configs[e].url.indexOf("localhost")?this.configs[e].url:this.configs[e].url+this.alias,env:this.configs[e].env};throw new Error("invalid env")}},{key:"isValidMode",value:function(e,t){for(var n in e)if(e.hasOwnProperty(n)&&e[n].env===t)return!0;return!1}}])}(),$=function(){function e(){o(this,e)}return s(e,null,[{key:"version",get:function(){return e._version.trim()||null}}])}();$.type="client",$.headerKeys=Object.freeze({version:"x-sdk-version",type:"x-sdk-type"}),$._version="v1.107.1",function(e){e[e.PUBLIC_KEY=0]="PUBLIC_KEY",e[e.TOKEN=1]="TOKEN"}(g||(g={}));var Q,ee=function(){return s((function e(t,n){o(this,e),this.auth=t,this.authType=n||this.setAuthType(),this.env=new X(Y)}),[{key:"setEnv",value:function(e,t){return this.env.setEnv(e,t),this}},{key:"setAuthType",value:function(){return this.authType=C.validateJWT(this.auth)?g.TOKEN:g.PUBLIC_KEY}},{key:"getClient",value:function(e,t){var n=this,i=new XMLHttpRequest;return i.open(e,this.env.getConf().url+t,!0),i.setRequestHeader("Content-Type","application/json; charset=UTF-8"),this.setAuthHeader(i),$.version&&(i.setRequestHeader($.headerKeys.version,$.version),i.setRequestHeader($.headerKeys.type,$.type)),{config:i,send:function(e,t,r){i.onload=function(){return n.parser({text:i.responseText,status:i.status},t,r)},i.send(JSON.stringify(e))}}}},{key:"getClientPromise",value:function(e,t){var n=this,i=new XMLHttpRequest;return i.open(e,this.env.getConf().url+t,!0),i.setRequestHeader("Content-Type","application/json; charset=UTF-8"),this.setAuthHeader(i),$.version&&(i.setRequestHeader($.headerKeys.version,$.version),i.setRequestHeader($.headerKeys.type,$.type)),{config:i,send:function(e){return new Promise((function(t,n){i.onload=function(){return t({text:i.responseText,status:i.status})},i.send(JSON.stringify(e))})).then((function(e){return n.parserPromise(e)}))}}}},{key:"parser",value:function(e,t,n){var i=e.text,r=e.status;try{var o=JSON.parse(i);if(r>=200&&r<300||302===r)return t(o.resource.data);n(o.error||{message:"unknown error"})}catch(e){}}},{key:"parserPromise",value:function(e){var t=e.text,n=e.status;try{var i=JSON.parse(t);return n>=200&&n<300||302===n?Promise.resolve(i.resource.data):Promise.reject(i.error||{message:"unknown error"})}catch(e){return Promise.reject(e)}}},{key:"setAuthHeader",value:function(e){switch(this.authType){case g.PUBLIC_KEY:e.setRequestHeader("x-user-public-key",this.auth);break;case g.TOKEN:e.setRequestHeader("x-access-token",this.auth)}}}])}(),te=function(e){function n(e){var i;return o(this,n),(i=t(this,n,[e])).publicKey=i.auth,i}return l(n,e),s(n,[{key:"getBrowserDetails",value:function(){return{name:k.getBrowserName(),java_enabled:k.isJavaEnabled().toString(),language:k.getLanguage(),screen_height:k.getScreenHeight().toString(),screen_width:k.getScreenWidth().toString(),time_zone:k.getTimezoneOffset().toString(),color_depth:k.getColorDepth().toString()}}},{key:"charge",value:function(){return new _(this)}}])}(ee),ne=function(){return s((function e(){o(this,e)}),null,[{key:"extendSearchParams",value:function(e,t,n){return e.replace(new RegExp("([?&]"+t+"(?=[=&#]|$)[^#&]*|(?=#|$))"),"&"+t+"="+encodeURIComponent(n)).replace(/^([^?&]+)&/,"$1?")}},{key:"serialize",value:function(e){return Object.keys(e).map((function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])})).join("&")}}])}(),ie=function(){return s((function e(){o(this,e)}),null,[{key:"generate",value:function(){if("undefined"!=typeof window&&void 0!==window.crypto&&void 0!==window.crypto.getRandomValues){var e=new Uint16Array(8);return window.crypto.getRandomValues(e),this.hash(e[0])+this.hash(e[1])+"-"+this.hash(e[2])+"-"+this.hash(e[3])+"-"+this.hash(e[4])+"-"+this.hash(e[5])+this.hash(e[6])+this.hash(e[7])}return this.random()+this.random()+"-"+this.random()+"-"+this.random()+"-"+this.random()+"-"+this.random()+this.random()+this.random()}},{key:"hash",value:function(e){for(var t=e.toString(16);t.length<4;)t="0"+t;return t}},{key:"random",value:function(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}}])}(),re="/wallet/flypay",oe="/images/logo.png",ae=function(){return s((function e(t){o(this,e),this.params={},this.widgetId=ie.generate(),this.linkResource=t,this.env=new X(K),this.setParams({widget_id:this.widgetId})}),[{key:"getNetUrl",value:function(){return this.env.getConf().url+this.linkResource}},{key:"getUrl",value:function(){var e=this.getNetUrl(),t=this.getParams();for(var n in t)t.hasOwnProperty(n)&&(e=ne.extendSearchParams(e,n,t[n]));return e}},{key:"setParams",value:function(e){this.params=c({},this.params,e)}},{key:"concatParams",value:function(e){for(var t in e)e.hasOwnProperty(t)&&e[t].length&&("string"!=typeof this.params[t]&&(this.params[t]=""),this.params[t].length?this.params[t]+=","+e[t]:this.params[t]+=e[t])}},{key:"getParams",value:function(){return this.params}},{key:"setEnv",value:function(e,t){this.env.setEnv(e,t)}},{key:"getEnv",value:function(){return this.env.getEnv()}},{key:"getBaseUrl",value:function(){return this.env.getConf().url}}])}(),se=function(){return s((function e(){o(this,e)}),null,[{key:"insertToInput",value:function(e,t,n){if(void 0!==n[t]){var i=document.querySelector(e);i&&(i.value=n[t])}}},{key:"subscribe",value:function(e,t,n){t.addEventListener?t.addEventListener(e,n):t.attachEvent("on".concat(e),n)}}])}(),ue=function(){return s((function e(t){o(this,e),this.selector=t}),[{key:"isExist",value:function(){return!!this.getElement()}},{key:"getStyles",value:function(e){if(this.isExist()){var t=this.getElement().getAttribute("widget-style");if(!t)return{};var n=t.split(";");return void 0===n||n.length?this.convertConfigs(n,e):{}}}},{key:"on",value:function(e,t){this.isExist()&&se.subscribe(e,this.getElement(),t)}},{key:"getAttr",value:function(e){if(this.isExist()){var t=this.getElement(),n=[];for(var i in e)if(e.hasOwnProperty(i)){var r=e[i].replace(/_/g,"-"),o=t.getAttribute(r);o&&n.push("".concat(e[i],":").concat(o))}return void 0===n||n.length?this.convertConfigs(n,e):{}}}},{key:"getElement",value:function(){return document.querySelector(this.selector)}},{key:"getSelector",value:function(){return this.selector}},{key:"convertConfigs",value:function(e,t){var n={};for(var i in e)if(e.hasOwnProperty(i)){var r=e[i].split(":"),o=r[0].replace(/-/g,"_").trim();-1!==t.indexOf(o)&&(n[o]=r[1].trim())}return n}}])}(),ce=function(){return s((function e(t){o(this,e),this.container=t}),[{key:"load",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.container.isExist()&&!this.isExist()){var n=document.createElement("iframe");n.setAttribute("src",e),t.title&&(n.title=t.title),this.container.getElement().appendChild(n)}}},{key:"loadFromHtml",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.container.isExist()&&!this.isExist()){var n=document.createElement("iframe");n.setAttribute("height","100%"),n.setAttribute("width","100%"),t.title&&(n.title=t.title);this.container.getElement().appendChild(n);var i=this.getElement().contentDocument;i.open(),i.write("<html><head><style>html, body {margin: 0;} iframe {border: 0; width: 100%}</style><title></title></head><body>{{content}}</body></html>".replace("{{content}}",e)),i.close()}}},{key:"remove",value:function(){if(this.container.isExist()&&this.isExist()){var e=this.getElement();this.container.getElement().removeChild(e)}}},{key:"show",value:function(){this.isExist()&&(this.setStyle("visibility","visible"),this.setStyle("display","block"))}},{key:"hide",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.isExist()&&(e?this.setStyle("visibility","hidden"):this.setStyle("display","none"))}},{key:"isExist",value:function(){return!!this.getElement()}},{key:"getElement",value:function(){return this.container.isExist()?this.container.getElement().querySelector("iframe"):null}},{key:"setStyle",value:function(e,t){this.getElement().style[e]=t}}])}(),le={AFTER_LOAD:"afterLoad",SUBMIT:"submit",FINISH:"finish",VALIDATION_ERROR:"validationError",SYSTEM_ERROR:"systemError",CHECKOUT_SUCCESS:"checkoutSuccess",CHECKOUT_READY:"checkoutReady",CHECKOUT_ERROR:"checkoutError",CHECKOUT_COMPLETED:"checkoutCompleted",CHECKOUT_POPUP_OPEN:"checkoutPopupOpen",CHECKOUT_POPUP_CLOSE:"checkoutPopupClose",VALIDATION:"validation",SELECT:"select",UNSELECT:"unselect",NEXT:"next",PREV:"prev",META_CHANGE:"metaChange",RESIZE:"resize",CHARGE_AUTH_SUCCESS:"chargeAuthSuccess",CHARGE_AUTH_REJECT:"chargeAuthReject",CHARGE_AUTH_CANCELLED:"chargeAuthCancelled",ADDITIONAL_DATA_SUCCESS:"additionalDataCollectSuccess",ADDITIONAL_DATA_REJECT:"additionalDataCollectReject",CHARGE_AUTH:"chargeAuth",DISPATCH_SUCCESS:"dispatchSuccess",DISPATCH_ERROR:"dispatchError"},de=function(){return s((function e(t){var n=this;o(this,e),this.listeners=[],t&&se.subscribe("message",t,(function(e){var t;try{t=JSON.parse(e.data)}catch(e){}t&&n.emit(t)}))}),[{key:"emit",value:function(e){for(var t in this.listeners)this.listeners[t].event===e.event&&e.widget_id===this.listeners[t].widget_id&&this.listeners[t].listener.apply(this,[e])}},{key:"on",value:function(e,t,n){for(var i in le)le.hasOwnProperty(i)&&e===le[i]&&this.listeners.push({event:e,listener:n,widget_id:t})}},{key:"clear",value:function(){this.listeners=[]}},{key:"subscribe",value:function(e,t){e.addEventListener?e.addEventListener("message",t):e.attachEvent("onmessage",t)}}])}(),he={visibility:"hidden",border:"0",width:"0",height:"0"};!function(e){e.SUCCESS="success",e.ERROR="error",e.PENDING="pending"}(Q||(Q={}));var pe,fe="chargeAuthSuccess",ve="chargeAuthReject",me="chargeAuthDecoupled",ye="chargeAuthChallenge",ge="chargeAuthInfo",ke="error",Ee=function(){return s((function e(t,n,i){o(this,e),this.container=t,this.api=n,this.eventEmitter=i,this.resultRead=!1,this.iFrameEvent=new de(window)}),[{key:"load",value:function(e,t){var n=e.initialization_url,i=e.secondary_url,r=e.charge_3ds_id;try{this.setupIFrameEvents(r),this.initializeIFrames(n,i,t)}catch(e){this.eventEmitter.emit(ke,this.parseError(e,r))}}},{key:"initializeIFrames",value:function(e,t,n){var i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],r=this.container.getElement();if(r){var o=document.createElement("div");if(o.setAttribute("id","paydock_authorization_iframe"),r.appendChild(o),this.browserAndChallengeContainer=new ue("#paydock_authorization_iframe"),this.iFrameAuthorization=new ce(this.browserAndChallengeContainer),this.iFrameAuthorization.load(e,{title:n}),t){var a=document.createElement("div");a.setAttribute("id","paydock_secondary_iframe"),r.appendChild(a),this.monitoringContainer=new ue("#paydock_secondary_iframe"),this.iFrameSecondaryUrl=new ce(this.monitoringContainer),this.iFrameSecondaryUrl.load(t,{title:n})}else this.iFrameSecondaryUrl=void 0;this.hideIframes(i)}}},{key:"hideIframes",value:function(){var e,t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];for(var n in he)he.hasOwnProperty(n)&&(t&&this.iFrameAuthorization.setStyle(n,he[n]),null===(e=this.iFrameSecondaryUrl)||void 0===e||e.setStyle(n,he[n]))}},{key:"setupIFrameEvents",value:function(e){var t=this;this.iFrameEvent.on(le.CHARGE_AUTH,e,(function(e){"MethodSkipped"===e.status||"MethodFinished"===e.status?(e.info&&t.eventEmitter.emit(ge,{info:e.info}),t.performAuthentication(e)):"AuthTimedOut"!==e.status&&"invalid_event"!==e.status||t.eventEmitter.emit(ve,t.parseHandleResponse({status:e.status},e.charge_3ds_id))})),this.iFrameEvent.on(le.CHARGE_AUTH_SUCCESS,e,(function(e){t.processResult(e.charge_3ds_id)}))}},{key:"parseResultData",value:function(e,t){return{status:e.status,charge_3ds_id:t}}},{key:"parseHandleResponse",value:function(e,t){var n=e.status,i=e.result;return{status:n,charge_3ds_id:t,result:{description:null==i?void 0:i.description}}}},{key:"parseError",value:function(e,t){return{charge_3ds_id:t,error:e}}},{key:"processResult",value:function(e){var t=this;this.resultRead||(this.resultRead=!0,this.api.charge().standalone3dsHandle().then((function(n){var i;t.iFrameAuthorization.remove(),null===(i=t.iFrameSecondaryUrl)||void 0===i||i.remove(),n.status===Q.SUCCESS?t.eventEmitter.emit(fe,t.parseResultData(n,e)):t.eventEmitter.emit(ve,t.parseResultData(n,e))}),(function(n){t.eventEmitter.emit(ke,t.parseError(n,e))})))}},{key:"externalAPI",value:function(e,t){var n=new XMLHttpRequest;return n.open(e,t,!0),new Promise((function(e,t){n.onload=function(){try{var i=JSON.parse(n.responseText);e(i)}catch(e){t(e)}},n.send()}))}},{key:"doPolling",value:function(e,t){var n=this;this.externalAPI("GET",e).then((function(i){if(i.event&&"AuthResultNotReady"!==i.event){if("AuthResultReady"!==i.event)throw new Error("Event not supported");n.processResult(t)}else setTimeout((function(){n.doPolling(e,t)}),2e3)})).catch((function(e){return n.eventEmitter.emit(ke,n.parseError(e,t))}))}},{key:"performAuthentication",value:function(e){var t,n=this,i=e.charge_3ds_id;this.iFrameAuthorization.remove(),null===(t=this.iFrameSecondaryUrl)||void 0===t||t.remove(),this.api.charge().standalone3dsProcess({charge_3ds_id:i}).then((function(e){var t,r;if("success"===e.status)n.eventEmitter.emit(fe,n.parseHandleResponse(e,i));else{if("pending"!==e.status)return n.eventEmitter.emit(ve,n.parseHandleResponse(e,i));(null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.challenge)?(n.eventEmitter.emit(ye,n.parseHandleResponse(e,i)),n.initializeIFrames(e.result.challenge_url,void 0,"Authentication Challenge",!1),e.result.secondary_url&&n.doPolling(e.result.secondary_url,i)):(null===(r=null==e?void 0:e.result)||void 0===r?void 0:r.decoupled_challenge)&&(n.eventEmitter.emit(me,n.parseHandleResponse(e,i)),e.result.secondary_url&&n.doPolling(e.result.secondary_url,i))}}),(function(e){n.eventEmitter.emit(ke,n.parseError(e,i))}))}}])}(),_e=function(){return s((function e(t){o(this,e),this.api=t}),[{key:"walletCapture",value:function(e){return this.api.getClientPromise("POST","/v1/charges/wallet/capture").send(e)}},{key:"walletCallback",value:function(e){return this.api.getClientPromise("POST","/v1/charges/wallet/callback").send(e)}},{key:"standalone3dsProcess",value:function(e){return this.api.getClientPromise("POST","/v1/charges/standalone-3ds/process").send(e)}},{key:"standalone3dsHandle",value:function(){return this.api.getClientPromise("GET","/v1/charges/standalone-3ds/handle").send(void 0)}}])}(),be=function(){return s((function e(t){o(this,e),this.api=t}),[{key:"getConfig",value:function(e){var t="/v1/services/:service_id/config".replace(":service_id",e);return this.api.getClientPromise("GET",t).send(void 0)}}])}();!function(e){e.VISA_SRC="VisaSRC",e.MASTERCARD_SRC="ClickToPay"}(pe||(pe={}));var we,Ce=function(e){function n(){return o(this,n),t(this,n,arguments)}return l(n,e),s(n,[{key:"charge",value:function(){return new _e(this)}},{key:"service",value:function(){return new be(this)}}])}(ee),Se="GPayments",Te=function(){return s((function e(t,n){o(this,e),this.env=G,this.container=t,this.eventEmitter=n}),[{key:"load",value:function(e,t){var n=C.validateJWT(e);if(!n)throw new Error("Invalid charge token");var i=C.extractData(n.body),r=new Ce(e,g.TOKEN);if(r.setEnv(this.env,this.alias),i.service_type===Se)new Ee(this.container,r,this.eventEmitter).load(i,t.title)}},{key:"setEnv",value:function(e,t){this.env=e,this.alias=t}}])}(),Oe=function(){return s((function e(){o(this,e),this.events={}}),[{key:"emit",value:function(e,t){var n=this.events[e];n&&n.forEach((function(e){e.call(null,t)}))}},{key:"subscribe",value:function(e,t){var n=this;return this.events[e]||(this.events[e]=[]),this.events[e].push(t),function(){n.events[e]=n.events[e].filter((function(e){return t!==e}))}}}])}();!function(e){e.HTML="html",e.URL="url",e.STANDALONE_3DS="standalone_3ds"}(we||(we={}));var Ae,Pe,Re=function(){return s((function e(t,n){o(this,e),this.configs=[],this.link=new ae("/3ds/webhook"),this.token=e.extractToken(n),this.link.setParams({ref_id:this.token.charge_3ds_id}),this.container=new ue(t),this.iFrame=new ce(this.container),this.eventEmitter=new Oe,this.standalone3dsService=new Te(this.container,this.eventEmitter),this.event=new de(window)}),[{key:"load",value:function(){this.token.format===we.HTML?this.iFrame.loadFromHtml(this.token.content,{title:"3d secure authentication"}):this.token.format===we.URL?this.iFrame.load(this.token.content,{title:"3d secure authentication"}):this.token.format===we.STANDALONE_3DS?this.standalone3dsService.load(this.token.content,{title:"3d secure authentication"}):console.error("Token contain unsupported payload")}},{key:"setEnv",value:function(e,t){for(var n in this.link.setEnv(e,t),this.standalone3dsService.setEnv(e,t),this.configs)this.configs.hasOwnProperty(n)&&this.configs[n].setEnv(e,t)}},{key:"getEnv",value:function(){return this.link.getEnv()}},{key:"on",value:function(e,t){var n=this;return this.token.format===we.STANDALONE_3DS?"function"==typeof t?this.eventEmitter.subscribe(e,t):new Promise((function(t){return n.eventEmitter.subscribe(e,(function(e){return t(e)}))})):"function"==typeof t?this.event.on(e,this.link.getParams().ref_id,t):new Promise((function(t){return n.event.on(e,n.link.getParams().ref_id,(function(e){return t(e)}))}))}},{key:"hide",value:function(e){this.iFrame.hide(e)}},{key:"show",value:function(){this.iFrame.show()}},{key:"reload",value:function(){this.iFrame.remove(),this.load()}}],[{key:"extractToken",value:function(e){return JSON.parse(window.atob(e))}}])}(),xe={CLICK:"click",POPUP_REDIRECT:"popupRedirect",REDIRECT:"redirect",ERROR:"error",REFERRED:"referred",DECLINED:"declined",CANCELLED:"cancelled",ACCEPTED:"accepted",FINISH:"finish",CLOSE:"close"};!function(e){e.CONTEXTUAL="contextual",e.REDIRECT="redirect"}(Ae||(Ae={})),function(e){e.ZIPMONEY="Zipmoney",e.PAYPAL="PaypalClassic",e.AFTERPAY="Afterpay"}(Pe||(Pe={}));var Ie,Ue,Le="[Paydock:CheckoutButton]",Ne={CARD:"card",BANK_ACCOUNT:"bank_account",CHECKOUT:"checkout"},De={CARD_NAME:"card_name",CARD_NUMBER:"card_number",EXPIRE_MONTH:"expire_month",EXPIRE_YEAR:"expire_year",CARD_CCV:"card_ccv",CARD_PIN:"card_pin",ACCOUNT_NAME:"account_name",ACCOUNT_BSB:"account_bsb",ACCOUNT_NUMBER:"account_number",ACCOUNT_ROUTING:"account_routing",ACCOUNT_HOLDER_TYPE:"account_holder_type",ACCOUNT_BANK_NAME:"account_bank_name",ACCOUNT_TYPE:"account_type",FIRST_NAME:"first_name",LAST_NAME:"last_name",EMAIL:"email",PHONE:"phone",PHONE2:"phone2",ADDRESS_LINE1:"address_line1",ADDRESS_LINE2:"address_line2",ADDRESS_STATE:"address_state",ADDRESS_COUNTRY:"address_country",ADDRESS_CITY:"address_city",ADDRESS_POSTCODE:"address_postcode",ADDRESS_COMPANY:"address_company"},Me={BACKGROUND_COLOR:"background_color",BACKGROUND_ACTIVE_COLOR:"background_active_color",TEXT_COLOR:"text_color",BORDER_COLOR:"border_color",ICON_SIZE:"icon_size",BUTTON_COLOR:"button_color",ERROR_COLOR:"error_color",SUCCESS_COLOR:"success_color",FONT_SIZE:"font_size",FONT_FAMILY:"font_family"},He={TITLE:"title",TITLE_H1:"title_h1",TITLE_H2:"title_h2",TITLE_H3:"title_h3",TITLE_H4:"title_h4",TITLE_H5:"title_h5",TITLE_H6:"title_h6",FINISH:"finish_text",TITLE_DESCRIPTION:"title_description",SUBMIT_BUTTON:"submit_button",SUBMIT_BUTTON_PROCESSING:"submit_button_processing"},Fe={SUBMIT_BUTTON:"submit_button",TABS:"tabs"},Be={AMEX:"amex",AUSBC:"ausbc",DINERS:"diners",DISCOVER:"discover",JAPCB:"japcb",LASER:"laser",MASTERCARD:"mastercard",SOLO:"solo",VISA:"visa",VISA_WHITE:"visa_white"},je=[].concat(["brand_name","cart_border_color","reference","email","hdr_img","logo_img","pay_flow_color","first_name","last_name","address_line","address_line2","address_city","address_state","address_postcode","address_country","phone","hide_shipping_address"],["first_name","last_name","phone","tokenize","email","gender","date_of_birth","charge","statistics","hide_shipping_address"],["amount","currency","email","first_name","last_name","address_line","address_line2","address_city","address_state","address_postcode","address_country","phone"],["customer_storage_number","tokenise_algorithm"]);!function(e){e.STRIPE="Stripe",e.FLYPAY="Flypay",e.FLYPAY_V2="FlypayV2",e.PAYPAL="Paypal",e.MASTERCARD="MasterCard",e.AFTERPAY="Afterpay"}(Ie||(Ie={})),function(e){e.GOOGLE="google",e.APPLE="apple",e.FLYPAY="flypay",e.FLYPAY_V2="flypayV2",e.PAYPAL="paypal",e.AFTERPAY="afterpay"}(Ue||(Ue={}));var ze,Ve=function(){return s((function e(){o(this,e),this.env=new X(Y)}),[{key:"setEnv",value:function(e,t){this.env.setEnv(e,t)}},{key:"getEnv",value:function(){return this.env.getEnv()}},{key:"getUrl",value:function(){return this.env.getConf().url+this.getLink()}},{key:"create",value:function(e,t,n,i){var r=this,o=new XMLHttpRequest;o.onload=function(){r.parser(o.responseText,o.status,n,i)},o.open("POST",this.getUrl(),!0),o.setRequestHeader("Content-Type","application/json; charset=UTF-8"),o.setRequestHeader(C.getAccessHeaderNameByToken(e),e),$.version&&(o.setRequestHeader($.headerKeys.version,$.version),o.setRequestHeader($.headerKeys.type,$.type)),o.send(JSON.stringify(t))}},{key:"get",value:function(e,t,n){var i=this,r=new XMLHttpRequest;r.onload=function(){i.parser(r.responseText,r.status,t,n)},r.open("GET",this.getUrl(),!0),r.setRequestHeader("Content-Type","application/json; charset=UTF-8"),r.setRequestHeader(C.getAccessHeaderNameByToken(e),e),$.version&&(r.setRequestHeader($.headerKeys.version,$.version),r.setRequestHeader($.headerKeys.type,$.type)),r.send()}},{key:"parser",value:function(e,t,n,i){var r={};try{r=JSON.parse(e)}catch(e){}if(t>=200&&t<300||302===t)return n(r.resource.data,t);i(r.error||{message:"unknown error"},t)}}])}(),qe=function(e){function n(e,i,r){var a;return o(this,n),(a=t(this,n)).body={gateway_id:e,meta:{},success_redirect_url:i,error_redirect_url:r,redirect_url:i},a}return l(n,e),s(n,[{key:"getLink",value:function(){return"/v1/payment_sources/external_checkout"}},{key:"setDescriptions",value:function(e){this.body.description=e}},{key:"setMeta",value:function(e){for(var t in e)e.hasOwnProperty(t)&&(-1!==je.indexOf(t)?this.body.meta[t]=e[t]:console.warn("ExternalCheckout::setMeta: unsupported meta key ".concat(t)))}},{key:"getConfigs",value:function(){return this.body}},{key:"send",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(e,t){};this.create(e,this.getConfigs(),(function(e,n){t(e)}),(function(e,t){void 0===e.message?n("".concat(t,": unknown error"),"unknown_error"):n(e.message,e.code)}))}}])}(Ve),Ke=function(e){function n(e){var i;return o(this,n),(i=t(this,n)).token=e,i}return l(n,e),s(n,[{key:"getLink",value:function(){return"/v1/payment_sources/external_checkout/:token".replace(":token",this.token)}},{key:"send",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(e){};this.get(e,(function(e,n){t(e)}),(function(e,t){void 0===e.message?n("".concat(t,": unknown error")):n(e.message)}))}}])}(Ve),Ye='\n <div class="cs-loader">\n <div class="cs-loader-inner">\n <label>\t●</label>\n <label>\t●</label>\n <label>\t●</label>\n <label>\t●</label>\n <label>\t●</label>\n <label>\t●</label>\n </div>\n </div>\n',We="\n <style> \n .cs-loader {\n position: absolute;\n top: 0;\n left: 0;\n height: 100%;\n width: 100%;\n }\n \n .cs-loader-inner {\n transform: translateY(-50%);\n top: 50%;\n position: absolute;\n width: calc(100% - 200px);\n color: #8e8d8c;\n padding: 0 100px;\n text-align: center;\n }\n \n \n .cs-loader-inner label {\n font-size: 20px;\n opacity: 0;\n display:inline-block;\n }\n \n @keyframes lol {\n 0% {\n opacity: 0;\n transform: translateX(-300px);\n }\n 33% {\n opacity: 1;\n transform: translateX(0px);\n }\n 66% {\n opacity: 1;\n transform: translateX(0px);\n }\n 100% {\n opacity: 0;\n transform: translateX(300px);\n }\n }\n \n @-webkit-keyframes lol {\n 0% {\n opacity: 0;\n -webkit-transform: translateX(-300px);\n }\n 33% {\n opacity: 1;\n -webkit-transform: translateX(0px);\n }\n 66% {\n opacity: 1;\n -webkit-transform: translateX(0px);\n }\n 100% {\n opacity: 0;\n -webkit-transform: translateX(300px);\n -moz-transform: translateX(300px);\n }\n }\n \n .cs-loader-inner label:nth-child(6) {\n -webkit-animation: lol 3s infinite ease-in-out;\n -moz-animation: lol 3s infinite ease-in-out;\n animation: lol 3s infinite ease-in-out;\n }\n \n .cs-loader-inner label:nth-child(5) {\n -webkit-animation: lol 3s 100ms infinite ease-in-out;\n -moz-animation: lol 3s 100ms infinite ease-in-out;\n animation: lol 3s 100ms infinite ease-in-out;\n }\n \n .cs-loader-inner label:nth-child(4) {\n -webkit-animation: lol 3s 200ms infinite ease-in-out;\n -moz-animation: lol 3s 200ms infinite ease-in-out;\n animation: lol 3s 200ms infinite ease-in-out;\n }\n \n .cs-loader-inner label:nth-child(3) {\n -webkit-animation: lol 3s 300ms infinite ease-in-out;\n -moz-animation: lol 3s 300ms infinite ease-in-out;\n animation: lol 3s 300ms infinite ease-in-out;\n }\n \n .cs-loader-inner label:nth-child(2) {\n -webkit-animation: lol 3s 400ms infinite ease-in-out;\n -moz-animation: lol 3s 400ms infinite ease-in-out;\n animation: lol 3s 400ms infinite ease-in-out;\n }\n \n .cs-loader-inner label:nth-child(1) {\n -webkit-animation: lol 3s 500ms infinite ease-in-out;\n -moz-animation: lol 3s 500ms infinite ease-in-out;\n animation: lol 3s 500ms infinite ease-in-out;\n }\n </style>\n",Ge="close",Je="focus",Ze=function(){return s((function e(){o(this,e),this.description="Don't see the secure checkout browser? We'll help you re-launch the window to complete your purchase",this.title="Checkout",this.overlay=null,this.style=null,this.showControl=!0,this.showLoader=!0,this.eventEmitter=new Oe}),[{key:"initControl",value:function(){if(!this.isInit()&&this.showControl){if(!k.isSupportPopUp())return this.createLoader();this.createTemplate(),this.createStyles(),this.eventHandler()}}},{key:"initLoader",value:function(){!this.isInit()&&this.showLoader&&(this.createStyles(),this.createLoader())}},{key:"eventHandler",value:function(){var e=this,t=document.querySelector("[data-close]"),n=document.querySelector("[data-continue]");t&&se.subscribe("click",t,(function(){return e.eventEmitter.emit(Ge,{})})),n&&se.subscribe("click",n,(function(){return e.eventEmitter.emit(Je,{})}))}},{key:"clear",value:function(){(this.style||this.overlay)&&(this.style.parentNode.removeChild(this.style),this.overlay.parentNode.removeChild(this.overlay),this.style=null,this.overlay=null)}},{key:"createLoader",value:function(){var e=this,t=document.body||document.getElementsByTagName("body")[0];this.overlay=document.createElement("div"),this.overlay.classList.add("checkout-overlay"),this.overlay.setAttribute("checkout-overlay"," "),this.overlay.innerHTML=We+Ye,t.appendChild(this.overlay),setTimeout((function(){e.isInit()&&e.overlay.classList.add("display")}),5)}},{key:"createTemplate",value:function(){var e=this,t=document.body||document.getElementsByTagName("body")[0],n=String('\n <div class="checkout-container">\n <strong class="checkout-title" data-title>{{title}}</strong>\n <p data-description>{{description}}</p>\n <a href="#" data-continue>Continue</a>\n <a href="#" data-close>Close</a>\n </div>\n');n=(n=n.replace("{{description}}",this.description)).replace("{{title}}",this.title),this.overlay=document.createElement("div"),this.overlay.classList.add("checkout-overlay"),this.overlay.setAttribute("checkout-overlay"," "),this.overlay.innerHTML=n,t.appendChild(this.overlay),setTimeout((function(){e.isInit()&&e.overlay.classList.add("display")}),5)}},{key:"createStyles",value:function(){var e=document.head||document.getElementsByTagName("head")[0],t=String("\n .hide-continue-button [data-continue] {\n display: none;\n }\n\n .checkout-overlay .cs-loader-inner {\n color: #ddd;\n }\n\n .checkout-overlay {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(0,0,0, 0.5);\n text-align: center;\n color: #fff;\n opacity: 0;\n }\n .checkout-overlay.display {\n opacity: 1;\n transition: opacity 0.7s ease-out;\n }\n .checkout-overlay a { color: #00f; }\n .checkout-container {\n position: absolute;\n top: 50%;\n left: 0;\n width: 100%;\n margin-top: -{{width}}px;\n }\n .checkout-title {\n font-size: 24px;\n display: block;\n text-transform: uppercase;\n }\n [data-close] {\n position: fixed;\n right: 32px;\n top: 32px;\n width: 32px;\n height: 32px;\n opacity: 0.3;\n overflow: hidden;\n text-indent: -9999px;\n }\n [data-close]:hover { opacity: 1; }\n [data-close]:before, [data-close]:after {\n position: absolute;\n left: 15px;\n content: ' ';\n height: 33px;\n width: 2px;\n background-color: #00f;\n }\n [data-close]:before { transform: rotate(45deg); }\n [data-close]:after { transform: rotate(-45deg); }\n"),n=document.querySelector(".checkout-container");t=t.replace("{{width}}",n?String(n.offsetHeight/2):"0"),this.style=document.createElement("style"),this.style.type="text/css",this.style.appendChild(document.createTextNode(t)),e.appendChild(this.style)}},{key:"setBackdropDescription",value:function(e){this.description=e}},{key:"setBackdropTitle",value:function(e){this.title=e}},{key:"onTrigger",value:function(e,t){this.eventEmitter.subscribe(e,t)}},{key:"isInit",value:function(){return!(!this.overlay||!this.style)}},{key:"hideContinueControl",value:function(){this.isInit()&&this.overlay.classList.add("hide-continue-button")}},{key:"turnOffControl",value:function(){this.showControl=!1}},{key:"turnOffLoader",value:function(){this.showLoader=!1}}])}(),Xe=function(){return s((function e(){o(this,e),this.widgetEnv=new X(K)}),[{key:"error",value:function(e,t,n){n(!0)}},{key:"setEnv",value:function(e,t){this.widgetEnv.setEnv(e,t)}}])}();function $e(){return function(e){function n(){var e;o(this,n);for(var i=arguments.length,r=new Array(i),a=0;a<i;a++)r[a]=arguments[a];return(e=t(this,n,[].concat(r))).background=new Ze,e.background.onTrigger(Je,(function(){return e.continue()})),e.background.onTrigger(Ge,(function(){return e.stop()})),e}return l(n,e),s(n,[{key:"continue",value:function(){}},{key:"stop",value:function(){}},{key:"error",value:function(e,t,n){n(!0)}},{key:"setSuspendedRedirectUri",value:function(e){this.suspendedRedirectUri=e}},{key:"setBackgroundTitle",value:function(e){this.background.setBackdropTitle(e)}},{key:"setBackgroundDescription",value:function(e){this.background.setBackdropDescription(e)}},{key:"turnOffBackdrop",value:function(){this.background.turnOffControl(),this.background.turnOffLoader()}}])}(arguments.length>0&&void 0!==arguments[0]?arguments[0]:Xe)}!function(e){e.SUCCESS="success",e.DECLINED="declined",e.CLOSE="close",e.REFERRED="referred",e.ERROR="error"}(ze||(ze={}));var Qe="paydock-dispatcher",et=function(){return s((function e(t){o(this,e),this.messageSource=t,this.env=new X(K)}),[{key:"restartDispatcher",value:function(){var e=document.getElementById(Qe);e&&e.parentNode&&e.parentNode.removeChild(e);var t=document.createElement("iframe");t.setAttribute("src",this.env.getConf().url+"/dispatcher"),t.id=Qe,t.style.display="none",document.body.appendChild(t)}},{key:"on",value:function(e,t){var n=this;se.subscribe("message",window,(function(i){var r=null;try{r=JSON.parse(i.data)}catch(e){}r&&r.message_source===n.messageSource&&r.event===e&&t(r)}))}},{key:"setEnv",value:function(e,t){this.env.setEnv(e,t),this.restartDispatcher()}}])}(),tt="close",nt=function(){return s((function e(){o(this,e),this.configs={width:500,height:500,scrollbars:!0,resizable:!0,top:0,left:0},this.eventEmitter=new Oe}),[{key:"isExist",value:function(){return!(!this.getElement()||this.getElement().closed)}},{key:"getElement",value:function(){return this.window}},{key:"init",value:function(){var e=this;if(!k.isSupportPopUp())return this.window=window;var t=this.getConfigs();this.window=window.open("about:blank","_blank","noopener=false,width=".concat(t.width,",height=").concat(t.height,",top=").concat(t.top,",left=").concat(t.left,",scrollbars=").concat(t.scrollbars?"yes":"no",",resizable=").concat(t.resizable?"yes":"no")),this.showLoader();var n=setInterval((function(){e.isExist()||(clearInterval(n),e.eventEmitter.emit(tt,{}))}),200)}},{key:"redirect",value:function(e){this.isExist()&&(this.window.location.href=e)}},{key:"close",value:function(){this.isExist()&&this.getElement().close&&(this.getElement().close(),this.window=null)}},{key:"focus",value:function(){this.isExist()&&this.getElement().focus&&this.getElement().focus()}},{key:"setConfigs",value:function(e){this.configs=c(this.configs,e)}},{key:"getNetConfigs",value:function(){return c({},this.configs)}},{key:"getConfigs",value:function(){var e=this.getNetConfigs();return e.left=window.screenX+(window.screen.width/2-e.width/2),e.top=window.screenY+(window.screen.height/2-e.height/2),e}},{key:"onClose",value:function(e){this.eventEmitter.subscribe(tt,e)}},{key:"initError",value:function(e){this.getElement().document.write("."),(this.getElement().document.body||this.getElement().document.getElementsByTagName("body")[0]).innerHTML="<style>\n .error-wrapper {\n color: #ff0000;\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100%;\n }\n </style>"+'<div class="error-wrapper"><div>{{error}}</div></div>'.replace("{{error}}",e)}},{key:"showLoader",value:function(){this.getElement().document.write(".");var e=this.getElement().document.body||this.getElement().document.getElementsByTagName("body")[0];if(e.innerHTML=We+Ye,this.env===P&&this.env===R&&this.env===x&&this.env===I&&this.env===U&&this.env===L&&this.env===N&&this.env===D&&this.env===M&&this.env===H&&this.env===F&&this.env===B&&this.env===j&&this.env===z&&this.env===V&&this.env===q){var t=0;se.subscribe("click",e,(function(){5===++t&&(e.innerHTML='\n <style>\n html{width: 100%;height: 100%;}\n body{margin: 0px;padding: 0px;background-color: #111;}\n \n .eye{\n width: 20px; height: 8px;\n background-color: #eee;\n border-radius:0px 0px 20px 20px;\n position: relative;\n top: 40px;\n left: 10px;\n box-shadow: 40px 0px 0px 0px #eee; \n }\n \n .head{\n -webkit-backface-visibility: hidden;\n -moz-backface-visibility: hidden;\n backface-visibility: hidden; \n position: relative;\n margin: -250px auto;\n width: 80px; height: 80px;\n background-color: #111;\n border-radius:50px;\n box-shadow: inset -4px 2px 0px 0px #eee;\n -webkit-animation:node 1.5s infinite alternate;\n -webkit-animation-timing-function:ease-out;\n -moz-animation:node 1.5s infinite alternate;\n -moz-animation-timing-function:ease-out;\n animation:node 1.5s infinite alternate;\n animation-timing-function:ease-out;\n }\n .body{ \n position: relative;\n margin: 90px auto;\n width: 140px; height: 120px;\n background-color: #111;\n border-radius: 50px/25px ;\n box-shadow: inset -5px 2px 0px 0px #eee;\n -webkit-animation:node2 1.5s infinite alternate;\n -webkit-animation-timing-function:ease-out; \n -moz-animation:node2 1.5s infinite alternate;\n -moz-animation-timing-function:ease-out; \n animation:node2 1.5s infinite alternate;\n animation-timing-function:ease-out; \n }\n \n @keyframes node {0%{ top:0px; }50%{ top:10px; }100% { top:0px;} }\n @keyframes node2 {0%{ top:-5px; }50%{ top:10px; }100% { top:-5px;}}\n @-moz-keyframes node {0%{ top:0px; }50%{ top:10px; }100% { top:0px;} }\n @-moz-keyframes node2 {0%{ top:-5px; }50%{ top:10px; }100% { top:-5px;}}\n @-webkit-keyframes node {0%{ top:0px; }50%{ top:10px; }100% { top:0px;} }\n @-webkit-keyframes node2 {0%{ top:-5px; }50%{ top:10px; }100% { top:-5px;}}\n \n \n .circ{\n -webkit-backface-visibility: hidden;\n -moz-backface-visibility: hidden;\n backface-visibility: hidden;\n margin: 60px auto;\n width: 180px; height: 180px;\n background-color: #111;\n border-radius: 0px 0px 50px 50px;\n position: relative;\n z-index: -1; \n left: 0%;\n top: 20%;\n overflow: hidden;\n }\n \n .hands{\n -webkit-backface-visibility: hidden;\n -moz-backface-visibility: hidden;\n backface-visibility: hidden;\n margin-top: 140px;\n width: 120px;height: 120px;\n position: absolute;\n background-color: #111;\n border-radius:20px;\n box-shadow:-1px -4px 0px 0px #eee;\n transform:rotate(45deg);\n -webkit-transform:rotate(45deg);\n -mox-transform:rotate(45deg);\n top:75%;left: 16%;\n z-index: 1;\n -webkit-animation:node2 1.5s infinite alternate;\n -webkit-animation-timing-function:ease-out;\n -moz-animation:node2 1.5s infinite alternate;\n -moz-animation-timing-function:ease-out;\n animation:node2 1.5s infinite alternate;\n animation-timing-function:ease-out;\n }\n \n .load{ position: absolute;\n width: 100px; height: 20px;\n margin: -10px auto;\n -webkit-font-smoothing: antialiased;\n -moz-font-smoothing: antialiased;\n font-smoothing: antialiased;\n font-family: \'Julius Sans One\', sans-serif;\n font-size:30px;\n font-weight:400;\n color:#eee;\n left: 10%;\n top: 5%;\n }\n </style>\n\n <div class="circ">\n <div class="load">A little patience ...</div>\n <div class="hands"></div>\n <div class="body"></div>\n <div class="head">\n <div class="eye"></div>\n </div>\n </div>\n')}))}}},{key:"setEnv",value:function(e){this.env=e}}])}(),it=function(e){function n(e){var i;return o(this,n),(i=t(this,n)).publicKey=e,i.checkout=null,i.dispatcher=new et("checkout.paydock"),setTimeout((function(){return i.dispatcher.restartDispatcher()}),200),i.popup=new nt,i}return l(n,e),s(n,[{key:"run",value:function(){this.isRunning()||(this.popup.init(),this.background.initControl())}},{key:"isRunning",value:function(){return this.popup.isExist()}},{key:"next",value:function(e){this.checkout=e,k.isSupportPopUp()||window.localStorage.setItem("paydock_checkout_token",JSON.stringify(this.checkout)),this.popup.redirect(this.checkout.link)}},{key:"continue",value:function(){this.popup.focus()}},{key:"stop",value:function(){this.popup.close()}},{key:"onStop",value:function(e){var t=this;this.popup.onClose((function(){t.background.clear(),t.checkout=null,e()}))}},{key:"onCheckout",value:function(e,t){var n=this;this.dispatcher.on(e,(function(e){if(n.checkout&&n.checkout.reference_id===e.reference_id)n.background.clear(),t(n.checkout);else if(!k.isSupportPopUp()){var i=window.localStorage.getItem("paydock_checkout_token");if(!i)return;var r=JSON.parse(i);r&&r.reference_id===e.reference_id&&(window.localStorage.removeItem("paydock_checkout_token"),n.checkout=r,n.background.clear(),t(n.checkout))}}))}},{key:"setEnv",value:function(e,t){p(d(n.prototype),"setEnv",this).call(this,e,t),this.dispatcher.setEnv(e,t),this.popup.setEnv(e)}}])}($e());function rt(e){return"run"in e}function ot(e){return"setRedirectUrl"in e}!function e(t,n,i){function r(a,s){if(!n[a]){if(!t[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);var c=Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[a]={exports:{}};t[a][0].call(l.exports,(function(e){return r(t[a][1][e]||e)}),l,l.exports,e,t,n,i)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;a<i.length;a++)r(i[a]);return r}({1:[function(e,t,n){function i(){throw Error("setTimeout has not been defined")}function r(){throw Error("clearTimeout has not been defined")}function o(e){if(l===setTimeout)return setTimeout(e,0);if((l===i||!l)&&setTimeout)return l=setTimeout,setTimeout(e,0);try{return l(e,0)}catch(t){try{return l.call(null,e,0)}catch(t){return l.call(this,e,0)}}}function a(){v&&p&&(v=!1,p.length?f=p.concat(f):m=-1,f.length&&s())}function s(){if(!v){var e=o(a);v=!0;for(var t=f.length;t;){for(p=f,f=[];++m<t;)p&&p[m].run();m=-1,t=f.length}p=null,v=!1,function(e){if(d===clearTimeout)return clearTimeout(e);if((d===r||!d)&&clearTimeout)return d=clearTimeout,clearTimeout(e);try{return d(e)}catch(t){try{return d.call(null,e)}catch(t){return d.call(this,e)}}}(e)}}function u(e,t){this.fun=e,this.array=t}function c(){}var l,d,h=t.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:i}catch(e){l=i}try{d="function"==typeof clearTimeout?clearTimeout:r}catch(e){d=r}}();var p,f=[],v=!1,m=-1;h.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];f.push(new u(e,t)),1!==f.length||v||o(s)},u.prototype.run=function(){this.fun.apply(null,this.array)},h.title="browser",h.browser=!0,h.env={},h.argv=[],h.version="",h.versions={},h.on=c,h.addListener=c,h.once=c,h.off=c,h.removeListener=c,h.removeAllListeners=c,h.emit=c,h.prependListener=c,h.prependOnceListener=c,h.listeners=function(e){return[]},h.binding=function(e){throw Error("process.binding is not supported")},h.cwd=function(){return"/"},h.chdir=function(e){throw Error("process.chdir is not supported")},h.umask=function(){return 0}},{}],2:[function(e,t,n){(function(e){!function(e){if("function"==typeof bootstrap)bootstrap("promise",e);else if("object"==r(n)&&"object"==r(t))t.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeQ=e}else{if("undefined"==typeof window&&"undefined"==typeof self)throw Error("This environment was not anticipated by Q. Please file a bug.");var i="undefined"!=typeof window?window:self,o=i.Q;i.Q=e(),i.Q.noConflict=function(){return i.Q=o,this}}}((function(){function t(e){return function(){return x.apply(e,arguments)}}function n(e,t){if(S&&t.stack&&"object"==r(e)&&null!==e&&e.stack){for(var n=[],o=t;o;o=o.source)o.stack&&(!e.__minimumStackCounter__||e.__minimumStackCounter__>o.stackCounter)&&(M(e,"__minimumStackCounter__",{value:o.stackCounter,configurable:!0}),n.unshift(o.stack));n.unshift(e.stack),M(e,"stack",{value:function(e){for(var t=e.split("\n"),n=[],r=0;r<t.length;++r){var o=t[r];a(o)||i(o)||!o||n.push(o)}return n.join("\n")}(n.join("\n"+j+"\n")),configurable:!0})}}function i(e){return-1!==e.indexOf("(module.js:")||-1!==e.indexOf("(node.js:")}function o(e){var t=/at .+ \((.+):(\d+):(?:\d+)\)$/.exec(e);if(t)return[t[1],Number(t[2])];var n=/at ([^ ]+):(\d+):(?:\d+)$/.exec(e);if(n)return[n[1],Number(n[2])];var i=/.*@(.+):(\d+)$/.exec(e);return i?[i[1],Number(i[2])]:void 0}function a(e){var t=o(e);if(!t)return!1;var n=t[0],i=t[1];return n===T&&i>=A&&i<=G}function s(){if(S)try{throw Error()}catch(n){var e=n.stack.split("\n"),t=o(e[0].indexOf("@")>0?e[1]:e[2]);if(!t)return;return T=t[0],t[1]}}function u(e){var t,n;return e instanceof h?e:m(e)?(t=e,n=c(),u.nextTick((function(){try{t.then(n.resolve,n.reject,n.notify)}catch(e){n.reject(e)}})),n.promise):k(e)}function c(){function e(e){t=e,u.longStackSupport&&S&&(o.source=e),U(n,(function(t,n){u.nextTick((function(){e.promiseDispatch.apply(e,n)}))}),void 0),n=void 0,i=void 0}var t,n=[],i=[],r=D(c.prototype),o=D(h.prototype);if(o.promiseDispatch=function(e,r,o){var a=I(arguments);n?(n.push(a),"when"===r&&o[1]&&i.push(o[1])):u.nextTick((function(){t.promiseDispatch.apply(t,a)}))},o.valueOf=function(){if(n)return o;var e=f(t);return v(e)&&(t=e),e},o.inspect=function(){return t?t.inspect():{state:"pending"}},u.longStackSupport&&S)try{throw Error()}catch(e){o.stack=e.stack.substring(e.stack.indexOf("\n")+1),o.stackCounter=z++}return r.promise=o,r.resolve=function(n){t||e(u(n))},r.fulfill=function(n){t||e(k(n))},r.reject=function(n){t||e(g(n))},r.notify=function(e){t||U(i,(function(t,n){u.nextTick((function(){n(e)}))}),void 0)},r}function l(e){if("function"!=typeof e)throw TypeError("resolver must be a function.");var t=c();try{e(t.resolve,t.reject,t.notify)}catch(e){t.reject(e)}return t.promise}function d(e){return l((function(t,n){for(var i=0,r=e.length;i<r;i++)u(e[i]).then(t,n)}))}function h(e,t,n){void 0===t&&(t=function(e){return g(Error("Promise does not support operation: "+e))}),void 0===n&&(n=function(){return{state:"unknown"}});var i=D(h.prototype);if(i.promiseDispatch=function(n,r,o){var a;try{a=e[r]?e[r].apply(i,o):t.call(i,r,o)}catch(e){a=g(e)}n&&n(a)},i.inspect=n,n){var r=n();"rejected"===r.state&&(i.exception=r.reason),i.valueOf=function(){var e=n();return"pending"===e.state||"rejected"===e.state?i:e.value}}return i}function p(e,t,n,i){return u(e).then(t,n,i)}function f(e){if(v(e)){var t=e.inspect();if("fulfilled"===t.state)return t.value}return e}function v(e){return e instanceof h}function m(e){var t;return(t=e)===Object(t)&&"function"==typeof e.then}function y(){q.length=0,K.length=0,W||(W=!0)}function g(t){var n,i,o=h({when:function(n){return n&&function(t){if(W){var n=L(K,t);-1!==n&&("object"==r(e)&&"function"==typeof e.emit&&u.nextTick.runAfter((function(){var i=L(Y,t);-1!==i&&(e.emit("rejectionHandled",q[n],t),Y.splice(i,1))})),K.splice(n,1),q.splice(n,1))}}(this),n?n(t):this}},(function(){return this}),(function(){return{state:"rejected",reason:t}}));return n=o,i=t,W&&("object"==r(e)&&"function"==typeof e.emit&&u.nextTick.runAfter((function(){-1!==L(K,n)&&(e.emit("unhandledRejection",i,n),Y.push(n))})),K.push(n),i&&void 0!==i.stack?q.push(i.stack):q.push("(no stack) "+i)),o}function k(e){return h({when:function(){return e},get:function(t){return e[t]},set:function(t,n){e[t]=n},delete:function(t){delete e[t]},post:function(t,n){return null==t?e.apply(void 0,n):e[t].apply(e,n)},apply:function(t,n){return e.apply(t,n)},keys:function(){return F(e)}},void 0,(function(){return{state:"fulfilled",value:e}}))}function E(e,t,n){return u(e).spread(t,n)}function _(e,t,n){return u(e).dispatch(t,n)}function b(e){return p(e,(function(e){var t=0,n=c();return U(e,(function(i,r,o){var a;v(r)&&"fulfilled"===(a=r.inspect()).state?e[o]=a.value:(++t,p(r,(function(i){e[o]=i,0==--t&&n.resolve(e)}),n.reject,(function(e){n.notify({index:o,value:e})})))}),void 0),0===t&&n.resolve(e),n.promise}))}function w(e){if(0===e.length)return u.resolve();var t=u.defer(),n=0;return U(e,(function(i,r,o){var a=e[o];n++,p(a,(function(e){t.resolve(e)}),(function(e){0==--n&&(e.message="Q can't get fulfillment value from any promise, all promises were rejected. Last error message: "+e.message,t.reject(e))}),(function(e){t.notify({index:o,value:e})}))}),void 0),t.promise}function C(e){return p(e,(function(e){return e=N(e,u),p(b(N(e,(function(e){return p(e,P,P)}))),(function(){return e}))}))}var S=!1;try{throw Error()}catch(e){S=!!e.stack}var T,O,A=s(),P=function(){},R=function(){function t(){for(var e,t;i.next;)e=(i=i.next).task,i.task=void 0,(t=i.domain)&&(i.domain=void 0,t.enter()),n(e,t);for(;c.length;)n(e=c.pop());a=!1}function n(e,n){try{e()}catch(e){if(u)throw n&&n.exit(),setTimeout(t,0),n&&n.enter(),e;setTimeout((function(){throw e}),0)}n&&n.exit()}var i={task:void 0,next:null},o=i,a=!1,s=void 0,u=!1,c=[];if(R=function(t){o=o.next={task:t,domain:u&&e.domain,next:null},a||(a=!0,s())},"object"==r(e)&&"[object process]"===e.toString()&&e.nextTick)u=!0,s=function(){e.nextTick(t)};else if("function"==typeof setImmediate)s="undefined"!=typeof window?setImmediate.bind(window,t):function(){setImmediate(t)};else if("undefined"!=typeof MessageChannel){var l=new MessageChannel;l.port1.onmessage=function(){s=d,l.port1.onmessage=t,t()};var d=function(){l.port2.postMessage(0)};s=function(){setTimeout(t,0),d()}}else s=function(){setTimeout(t,0)};return R.runAfter=function(e){c.push(e),a||(a=!0,s())},R}(),x=Function.call,I=t(Array.prototype.slice),U=t(Array.prototype.reduce||function(e,t){var n=0,i=this.length;if(1===arguments.length)for(;;){if(n in this){t=this[n++];break}if(++n>=i)throw TypeError()}for(;n<i;n++)n in this&&(t=e(t,this[n],n));return t}),L=t(Array.prototype.indexOf||function(e){for(var t=0;t<this.length;t++)if(this[t]===e)return t;return-1}),N=t(Array.prototype.map||function(e,t){var n=this,i=[];return U(n,(function(r,o,a){i.push(e.call(t,o,a,n))}),void 0),i}),D=Object.create||function(e){function t(){}return t.prototype=e,new t},M=Object.defineProperty||function(e,t,n){return e[t]=n.value,e},H=t(Object.prototype.hasOwnProperty),F=Object.keys||function(e){var t=[];for(var n in e)H(e,n)&&t.push(n);return t},B=t(Object.prototype.toString);O="undefined"!=typeof ReturnValue?ReturnValue:function(e){this.value=e};var j="From previous event:";u.resolve=u,u.nextTick=R,u.longStackSupport=!1;var z=1;"object"==r(e)&&e&&e.env&&e.env.Q_DEBUG&&(u.longStackSupport=!0),u.defer=c,c.prototype.makeNodeResolver=function(){var e=this;return function(t,n){t?e.reject(t):arguments.length>2?e.resolve(I(arguments,1)):e.resolve(n)}},u.Promise=l,u.promise=l,l.race=d,l.all=b,l.reject=g,l.resolve=u,u.passByCopy=function(e){return e},h.prototype.passByCopy=function(){return this},u.join=function(e,t){return u(e).join(t)},h.prototype.join=function(e){return u([this,e]).spread((function(e,t){if(e===t)return e;throw Error("Q can't join: not the same: "+e+" "+t)}))},u.race=d,h.prototype.race=function(){return this.then(u.race)},u.makePromise=h,h.prototype.toString=function(){return"[object Promise]"},h.prototype.then=function(e,t,i){var r=this,o=c(),a=!1;return u.nextTick((function(){r.promiseDispatch((function(t){a||(a=!0,o.resolve(function(t){try{return"function"==typeof e?e(t):t}catch(e){return g(e)}}(t)))}),"when",[function(e){a||(a=!0,o.resolve(function(e){if("function"==typeof t){n(e,r);try{return t(e)}catch(e){return g(e)}}return g(e)}(e)))}])})),r.promiseDispatch(void 0,"when",[void 0,function(e){var t,n,r=!1;try{t=e,n="function"==typeof i?i(t):t}catch(e){if(r=!0,!u.onerror)throw e;u.onerror(e)}r||o.notify(n)}]),o.promise},u.tap=function(e,t){return u(e).tap(t)},h.prototype.tap=function(e){return e=u(e),this.then((function(t){return e.fcall(t).thenResolve(t)}))},u.when=p,h.prototype.thenResolve=function(e){return this.then((function(){return e}))},u.thenResolve=function(e,t){return u(e).thenResolve(t)},h.prototype.thenReject=function(e){return this.then((function(){throw e}))},u.thenReject=function(e,t){return u(e).thenReject(t)},u.nearer=f,u.isPromise=v,u.isPromiseAlike=m,u.isPending=function(e){return v(e)&&"pending"===e.inspect().state},h.prototype.isPending=function(){return"pending"===this.inspect().state},u.isFulfilled=function(e){return!v(e)||"fulfilled"===e.inspect().state},h.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},u.isRejected=function(e){return v(e)&&"rejected"===e.inspect().state},h.prototype.isRejected=function(){return"rejected"===this.inspect().state};var V,q=[],K=[],Y=[],W=!0;u.resetUnhandledRejections=y,u.getUnhandledReasons=function(){return q.slice()},u.stopUnhandledRejectionTracking=function(){y(),W=!1},y(),u.reject=g,u.fulfill=k,u.master=function(e){return h({isDef:function(){}},(function(t,n){return _(e,t,n)}),(function(){return u(e).inspect()}))},u.spread=E,h.prototype.spread=function(e,t){return this.all().then((function(t){return e.apply(void 0,t)}),t)},u.async=function(e){return function(){function t(e,t){var o,a;if("undefined"==typeof StopIteration){try{o=n[e](t)}catch(e){return g(e)}return o.done?u(o.value):p(o.value,i,r)}try{o=n[e](t)}catch(e){return"[object StopIteration]"===B(a=e)||a instanceof O?u(e.value):g(e)}return p(o,i,r)}var n=e.apply(this,arguments),i=t.bind(t,"next"),r=t.bind(t,"throw");return i()}},u.spawn=function(e){u.done(u.async(e)())},u.return=function(e){throw new O(e)},u.promised=function(e){return function(){return E([this,b(arguments)],(function(t,n){return e.apply(t,n)}))}},u.dispatch=_,h.prototype.dispatch=function(e,t){var n=this,i=c();return u.nextTick((function(){n.promiseDispatch(i.resolve,e,t)})),i.promise},u.get=function(e,t){return u(e).dispatch("get",[t])},h.prototype.get=function(e){return this.dispatch("get",[e])},u.set=function(e,t,n){return u(e).dispatch("set",[t,n])},h.prototype.set=function(e,t){return this.dispatch("set",[e,t])},u.del=u.delete=function(e,t){return u(e).dispatch("delete",[t])},h.prototype.del=h.prototype.delete=function(e){return this.dispatch("delete",[e])},u.mapply=u.post=function(e,t,n){return u(e).dispatch("post",[t,n])},h.prototype.mapply=h.prototype.post=function(e,t){return this.dispatch("post",[e,t])},u.send=u.mcall=u.invoke=function(e,t){return u(e).dispatch("post",[t,I(arguments,2)])},h.prototype.send=h.prototype.mcall=h.prototype.invoke=function(e){return this.dispatch("post",[e,I(arguments,1)])},u.fapply=function(e,t){return u(e).dispatch("apply",[void 0,t])},h.prototype.fapply=function(e){return this.dispatch("apply",[void 0,e])},u.try=u.fcall=function(e){return u(e).dispatch("apply",[void 0,I(arguments,1)])},h.prototype.fcall=function(){return this.dispatch("apply",[void 0,I(arguments)])},u.fbind=function(e){var t=u(e),n=I(arguments,1);return function(){return t.dispatch("apply",[this,n.concat(I(arguments))])}},h.prototype.fbind=function(){var e=this,t=I(arguments);return function(){return e.dispatch("apply",[this,t.concat(I(arguments))])}},u.keys=function(e){return u(e).dispatch("keys",[])},h.prototype.keys=function(){return this.dispatch("keys",[])},u.all=b,h.prototype.all=function(){return b(this)},u.any=w,h.prototype.any=function(){return w(this)},u.allResolved=(V=C,function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn("allResolved is deprecated, use allSettled instead.",Error("").stack),V.apply(V,arguments)}),h.prototype.allResolved=function(){return C(this)},u.allSettled=function(e){return u(e).allSettled()},h.prototype.allSettled=function(){return this.then((function(e){return b(N(e,(function(e){function t(){return e.inspect()}return(e=u(e)).then(t,t)})))}))},u.fail=u.catch=function(e,t){return u(e).then(void 0,t)},h.prototype.fail=h.prototype.catch=function(e){return this.then(void 0,e)},u.progress=function(e,t){return u(e).then(void 0,void 0,t)},h.prototype.progress=function(e){return this.then(void 0,void 0,e)},u.fin=u.finally=function(e,t){return u(e).finally(t)},h.prototype.fin=h.prototype.finally=function(e){if(!e||"function"!=typeof e.apply)throw Error("Q can't apply finally callback");return e=u(e),this.then((function(t){return e.fcall().then((function(){return t}))}),(function(t){return e.fcall().then((function(){throw t}))}))},u.done=function(e,t,n,i){return u(e).done(t,n,i)},h.prototype.done=function(t,i,o){var a=function(e){u.nextTick((function(){if(n(e,s),!u.onerror)throw e;u.onerror(e)}))},s=t||i||o?this.then(t,i,o):this;"object"==r(e)&&e&&e.domain&&(a=e.domain.bind(a)),s.then(void 0,a)},u.timeout=function(e,t,n){return u(e).timeout(t,n)},h.prototype.timeout=function(e,t){var n=c(),i=setTimeout((function(){t&&"string"!=typeof t||((t=Error(t||"Timed out after "+e+" ms")).code="ETIMEDOUT"),n.reject(t)}),e);return this.then((function(e){clearTimeout(i),n.resolve(e)}),(function(e){clearTimeout(i),n.reject(e)}),n.notify),n.promise},u.delay=function(e,t){return void 0===t&&(t=e,e=void 0),u(e).delay(t)},h.prototype.delay=function(e){return this.then((function(t){var n=c();return setTimeout((function(){n.resolve(t)}),e),n.promise}))},u.nfapply=function(e,t){return u(e).nfapply(t)},h.prototype.nfapply=function(e){var t=c(),n=I(e);return n.push(t.makeNodeResolver()),this.fapply(n).fail(t.reject),t.promise},u.nfcall=function(e){var t=I(arguments,1);return u(e).nfapply(t)},h.prototype.nfcall=function(){var e=I(arguments),t=c();return e.push(t.makeNodeResolver()),this.fapply(e).fail(t.reject),t.promise},u.nfbind=u.denodeify=function(e){if(void 0===e)throw Error("Q can't wrap an undefined function");var t=I(arguments,1);return function(){var n=t.concat(I(arguments)),i=c();return n.push(i.makeNodeResolver()),u(e).fapply(n).fail(i.reject),i.promise}},h.prototype.nfbind=h.prototype.denodeify=function(){var e=I(arguments);return e.unshift(this),u.denodeify.apply(void 0,e)},u.nbind=function(e,t){var n=I(arguments,2);return function(){var i=n.concat(I(arguments)),r=c();return i.push(r.makeNodeResolver()),u((function(){return e.apply(t,arguments)})).fapply(i).fail(r.reject),r.promise}},h.prototype.nbind=function(){var e=I(arguments,0);return e.unshift(this),u.nbind.apply(void 0,e)},u.nmapply=u.npost=function(e,t,n){return u(e).npost(t,n)},h.prototype.nmapply=h.prototype.npost=function(e,t){var n=I(t||[]),i=c();return n.push(i.makeNodeResolver()),this.dispatch("post",[e,n]).fail(i.reject),i.promise},u.nsend=u.nmcall=u.ninvoke=function(e,t){var n=I(arguments,2),i=c();return n.push(i.makeNodeResolver()),u(e).dispatch("post",[t,n]).fail(i.reject),i.promise},h.prototype.nsend=h.prototype.nmcall=h.prototype.ninvoke=function(e){var t=I(arguments,1),n=c();return t.push(n.makeNodeResolver()),this.dispatch("post",[e,t]).fail(n.reject),n.promise},u.nodeify=function(e,t){return u(e).nodeify(t)},h.prototype.nodeify=function(e){if(!e)return this;this.then((function(t){u.nextTick((function(){e(null,t)}))}),(function(t){u.nextTick((function(){e(t)}))}))},u.noConflict=function(){throw Error("Q.noConflict only works when Q is used as a global")};var G=s();return u}))}).call(this,e("_process"))},{_process:1}],3:[function(e,t,n){var i=function(e){switch(r(e)){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,n,o){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==r(e)?Object.keys(e).map((function(r){var o=encodeURIComponent(i(r))+n;return Array.isArray(e[r])?e[r].map((function(e){return o+encodeURIComponent(i(e))})).join(t):o+encodeURIComponent(i(e[r]))})).join(t):o?encodeURIComponent(i(o))+n+encodeURIComponent(i(e)):""}},{}],4:[function(e,t,n){function i(e){return e&&e.__esModule?e:{default:e}}function r(e,t,n){return l.default.information("zip:checkout:init"),d.default.Promise((function(t,n){return e.onCheckout(t,n,{})})).then((function(i){var r=i.redirect_uri||i.redirectUri||i.data&&(i.data.redirect_uri||i.data.redirectUri);if(!r)return l.default.debug("zip:checkout:error","Response does not contain redirectUri property"),n(i),void e.onError({code:"checkout_error",message:"The response does not contain the redirectUri property",detail:i});l.default.debug("zip:checkout:success",i),t({redirectUri:r})})).catch((function(t){l.default.debug("zip:checkout:error",t),n(t),e.onError({code:"checkout_error",message:"Checkout response error",detail:t})}))}Object.defineProperty(n,"__esModule",{value:!0}),n.Checkout=void 0;var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),a=i(e("./modal")),s=i(e("./options")),u=i(e("./utility")),l=i(e("./console")),d=i((e("./events"),e("q"))),h=function(){function e(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e)}return o(e,null,[{key:"init",value:function(e){var t,n;if("function"!=typeof Object.assign&&(Object.assign=function(e){if(null==e)throw TypeError("Cannot convert undefined or null to object");e=Object(e);for(var t=1;t<arguments.length;t++){var n=arguments[t];if(null!=n)for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}),e=c({},s.default,e),!this._validate(e))return l.default.setLevel(e.logLevel),e.redirect?r(e,(function(t){return e.redirectFn(t.redirectUri)})):(t=e,(n=new a.default).onClose=t.onComplete.bind(t),n.build(),void r(t,(function(e){return n.setUri(e.redirectUri)}),(function(e){return n.close(!1)})))}},{key:"attachButton",value:function(e,t){var n=document.querySelectorAll(e);if(!n.length)return config.onError({code:"attach_error",message:"Cannot find button to attach zipMoney checkout"});for(var i=0;i<n.length;i++)u.default.addEventHandler(n[i],"click",(function(){return Zip.Checkout.init(t)}))}},{key:"_validate",value:function(e){return 0>["error","information","debug"].indexOf(e.logLevel.toLowerCase())&&(e.logLevel="error"),0>["standard","express"].indexOf(e.request.toLowerCase())&&(e.request="standard"),e.onComplete=e.onComplete||function(){},e.onError=e.onError||function(){},e.checkoutUri||e.onCheckout!==s.default.onCheckout?"express"===e.request?e.onError({code:"not_implemented",message:"This feature is not yet implemented"}):e.redirect||e.onComplete!==s.default.onComplete||e.redirectUri?void 0:e.onError({code:"validation",message:"if onComplete function is not specified then redirectUri must be specified"}):e.onError({code:"validation",message:"if onCheckout function is not specified then checkoutUri must be specified"})}}]),e}();n.Checkout=h},{"./console":5,"./events":6,"./modal":8,"./options":9,"./utility":10,q:2}],5:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});var i="error";n.default={error:function(){var e;(e=window.console).log.apply(e,arguments)},information:function(){var e;"error"!==i&&(e=window.console).log.apply(e,arguments)},debug:function(){var e;"debug"===i&&(e=window.console).log.apply(e,arguments)},setLevel:function(e){i=e}}},{}],6:[function(e,t,n){(function(t){Object.defineProperty(n,"__esModule",{value:!0}),n.EventListener=void 0;var i,r=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();if(((i=e("./utility"))&&i.__esModule?i:{default:i}).default.isIe){var o=function(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n};o.prototype=t.Event.prototype,t.CustomEvent=o}var a={},s=n.EventListener=function(){function e(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e)}return r(e,null,[{key:"constructor",value:function(){a={}}},{key:"on",value:function(e,t){a[e]=t}},{key:"off",value:function(e){a[e]=null}}]),e}();s.Event=function(e,t){this.eventType=e,this.data=t||{}},s.Event.eventTypes={resize:"resize",transition:"transition",close:"close",complete:"complete",clear:"clear"};var u=window.addEventListener?"addEventListener":"attachEvent",c=window[u];c("attachEvent"==u?"onmessage":"message",(function(e){var n,i;e.data.zipmoney&&(n=e.data.msg,i=new t.CustomEvent("zipmoney",{detail:n}),t.dispatchEvent(i))}),!1),c("zipmoney",(function(e){var t,n=a[e.detail.eventType];n?n(e.detail.data||{}):(t=e,console.log("Unexpected Event",t))}),!1)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./utility":10}],7:[function(e,t,n){(function(t){var n=e("./checkout"),i=e("./events");t.Zip=t.Zip||{},t.Zip.Checkout=n.Checkout,t.zipMoneyEvent=i.EventListener.ZipEvent}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./checkout":4,"./events":6}],8:[function(e,t,n){function i(e){return e&&e.__esModule?e:{default:e}}function r(){return Math.max(document.documentElement.clientHeight,window.innerHeight||0)}function o(){var e=document.body,t=document.documentElement;return Math.max(e.scrollHeight,e.offsetHeight,t.clientHeight,t.scrollHeight,t.offsetHeight)}function a(e){for(var t=document.querySelectorAll("html, body"),n=0;n<t.length;n++)t[n].style.overflowY=e}function s(e){var t=document.body.currentStyle||window.getComputedStyle(document.body),n=document.body.offsetHeight+(parseInt(t.marginTop,10)+parseInt(t.marginBottom,10))-parseInt(t.height,10);document.body.style.height=e-n+"px"}Object.defineProperty(n,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),l=i(e("./utility")),d=e("./events"),h=(i(e("./console")),{iframeWidth:400,iframeMinWidth:320,iframeInitialHeight:704,iframeMinHeight:600,verticalMargin:35}),p=["resize","transition","close","complete","clear"],f="https://d3k1w8lx8mqizo.cloudfront.net/zm/",v=function(){function e(){var t=this;(function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")})(this,e),this._events=[],this._isMobile=l.default.isMobileDevice(),p.forEach((function(e){return d.EventListener.on(d.EventListener.Event.eventTypes[e],t[e].bind(t))}))}return u(e,[{key:"build",value:function(){this._initialHtmlHeight=o(),window.scrollTo(0,0);var e=this._frame=(t=this._frameUri,n=this._isMobile,(i=document.createElement("iframe")).id="zipmoney-iframe",i.frameborder=0,c(i.style,{padding:"0",border:"none",zIndex:"999999",backgroundColor:"#FFF",backgroundImage:"url("+f+"spinner.gif)",backgroundRepeat:"no-repeat",backgroundPosition:"50% 50%"}),c(i.style,n?{overflow:"scroll",width:"100%",height:"100%",position:"absolute",top:"0",bottom:"0",left:"0",right:"0",margin:"0"}:{width:h.iframeWidth+"px",minWidth:h.iframeMinWidth+"px",height:h.iframeInitialHeight+"px",margin:h.verticalMargin+"px auto 0 auto",display:"table-row",backgroundSize:"25%",textAlign:"center",boxShadow:"0px 0px 70px 0px rgb(0, 0, 0)"}),i.src=t||"",i);if(!this._isMobile){var t,n,i,r,u,l=((r=document.createElement("img")).src=f+"icon-close.png",c(r.style,{width:"50px",height:"50px",position:"absolute",top:"20px",right:"20px",cursor:"pointer"}),r);l.onclick=this.close.bind(this),this._overlay=((u=document.createElement("div")).className="zipmoney-overlay",c(u.style,{position:"absolute",left:"0",top:"0",display:"table-cell",textAlign:"center",verticalAlign:"middle",background:"rgba(0, 0, 0, 0.75)",zIndex:"10000",height:"100%",width:"100%"}),u),this._overlay.appendChild(l),this._overlay.appendChild(this._frame),e=this._overlay}document.body.appendChild(e),this._isMobile&&s(this._frame.offsetHeight),a("auto"),this._startMonitoringWindowResize()}},{key:"setUri",value:function(e){this._frameUri=e,this._frame&&(this._frame.src=e)}},{key:"resize",value:function(e){var t=this._isMobile?16:0,n=(e=e>=h.iframeMinHeight?e:h.iframeMinHeight,(e+=t)+2*h.verticalMargin),i=r();this._frame.style.height=e+"px",this._overlay&&(this._overlay.style.height=Math.max(i,this._initialHtmlHeight,n)+"px"),this._isMobile&&s(e)}},{key:"transition",value:function(){window.scroll(0,0)}},{key:"close",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t={state:"cancelled"};this._events.length&&(t=this._events.pop()),this._destroy(),this.onClose&&e&&this.onClose(t)}},{key:"complete",value:function(e){this._events.push(e)}},{key:"clear",value:function(e){this._events=[]}},{key:"_startMonitoringWindowResize",value:function(){var e=this;this._resizeHandler=l.default.debounce((function(){var t,n,i,a;return t=e,n=r(),i=o(),a=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,t._overlay&&(t._overlay.style.height=Math.max(n,i)+"px"),void(t._isMobile||a<h.iframeWidth?t._frame.style.width="100%":t._frame.style.width=h.iframeWidth+"px")}),250),l.default.addEventHandler(window,"resize",this._resizeHandler)}},{key:"_stopMonitoringWindowResize",value:function(){l.default.removeEventHandler(window,"resize",this._resizeHandler)}},{key:"_destroy",value:function(){this._stopMonitoringWindowResize(),this._overlay?document.body.removeChild(this._overlay):document.body.removeChild(this._frame),this._isMobile&&(document.body.style.height="initial"),a("initial"),this._overlay=this._frame=null,p.forEach((function(e){return d.EventListener.off(d.EventListener.Event.eventTypes[e])}))}}]),e}();n.default=v},{"./console":5,"./events":6,"./utility":10}],9:[function(e,t,n){function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var r=i(e("./xr")),o=i(e("./console"));r.default.configure({headers:{"X-Requested-With":"XMLHttpRequest"}}),n.default={request:"standard",redirect:!1,logLevel:"Error",onCheckout:function(e,t,n){r.default.post(this.checkoutUri).then((function(t){return e(t.data)})).catch(t)},onShippingAddressChanged:function(e,t,n){r.default.post(this.shippingUri).then(e).catch(t)},onComplete:function(e){if(o.default.information("zip:completed",e),"cancelled"!==e.state){var t=e.checkoutId?"&checkoutId="+e.checkoutId:"";this.redirectFn(this.redirectUri+"?result="+e.state+t)}},onError:function(e){o.default.error(e)},redirectFn:function(e){window.location.href=e}}},{"./console":5,"./xr":11}],10:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),r=function(){function e(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e)}return i(e,null,[{key:"isIe",value:function(){var e=-1,t=window.navigator.userAgent,n=t.indexOf("MSIE "),i=t.indexOf("Trident/");if(n>0)e=parseInt(t.substring(n+5,t.indexOf(".",n)),10);else if(i>0){var r=t.indexOf("rv:");e=parseInt(t.substring(r+3,t.indexOf(".",r)),10)}return e>-1?e:void 0}},{key:"isMobileDevice",value:function(){var e=navigator.userAgent||navigator.vendor||window.opera;return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4))}},{key:"debounce",value:function(e,t){var n;return function(){var i=this,r=arguments,o=!n;clearTimeout(n),n=setTimeout((function(){n=null,e.apply(i,r)}),t),o&&e.apply(i,r)}}},{key:"addEventHandler",value:function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent&&e.attachEvent("on"+t,n)}},{key:"removeEventHandler",value:function(e,t,n){e.removeEventListener?e.removeEventListener(t,n,!1):e.detachEvent&&e.detachEvent("on"+t,n)}}]),e}();n.default=r},{}],11:[function(e,t,n){function i(e){return e&&e.__esModule?e:{default:e}}function o(e,t){return{status:e.status,response:e.response,data:t,xhr:e}}function a(e){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];for(var r in n)if({}.hasOwnProperty.call(n,r)){var o=n[r];if("object"===(void 0===o?"undefined":u(o)))for(var a in o)({}).hasOwnProperty.call(o,a)&&(e[a]=o[a])}return e}function s(e){var t,n;return n=function(t,n){var i=a({},p,f,e),r=i.xmlHttpRequest();for(var s in i.abort&&e.abort((function(){n(o(r)),r.abort()})),r.open(i.method,i.params?i.url.split("?")[0]+"?"+(0,c.default)(i.params):i.url,!0),r.withCredentials=i.withCredentials,r.addEventListener(h.LOAD,(function(){if(r.status>=200&&r.status<300){var e=null;r.responseText&&(e=!0===i.raw?r.responseText:i.load(r.responseText)),t(o(r,e))}else n(o(r))})),r.addEventListener(h.ABORT,(function(){return n(o(r))})),r.addEventListener(h.ERROR,(function(){return n(o(r))})),r.addEventListener(h.TIMEOUT,(function(){return n(o(r))})),i.headers)({}).hasOwnProperty.call(i.headers,s)&&r.setRequestHeader(s,i.headers[s]);for(var l in i.events)({}).hasOwnProperty.call(i.events,l)&&r.addEventListener(l,i.events[l].bind(null,r),!1);var d="object"!==u(i.data)||i.raw?i.data:i.dump(i.data);void 0!==d?r.send(d):r.send()},((t=e)&&t.promise?t.promise:f.promise||p.promise)(n)}Object.defineProperty(n,"__esModule",{value:!0});var u="function"==typeof Symbol&&"symbol"==r(Symbol.iterator)?function(e){return r(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":r(e)},c=i(e("querystring/encode")),l=i(e("q")),d={GET:"GET",POST:"POST",PUT:"PUT",DELETE:"DELETE",PATCH:"PATCH",OPTIONS:"OPTIONS"},h={READY_STATE_CHANGE:"readystatechange",LOAD_START:"loadstart",PROGRESS:"progress",ABORT:"abort",ERROR:"error",LOAD:"load",TIMEOUT:"timeout",LOAD_END:"loadend"},p={method:d.GET,data:void 0,headers:{Accept:"application/json","Content-Type":"application/json"},dump:JSON.stringify,load:JSON.parse,xmlHttpRequest:function(){return new XMLHttpRequest},promise:function(e){return l.default.Promise(e)},withCredentials:!1},f={};s.assign=a,s.encode=c.default,s.configure=function(e){f=a({},f,e)},s.Methods=d,s.Events=h,s.defaults=p,s.get=function(e,t,n){return s(a({url:e,method:d.GET,params:t},n))},s.put=function(e,t,n){return s(a({url:e,method:d.PUT,data:t},n))},s.post=function(e,t,n){return s(a({url:e,method:d.POST,data:t},n))},s.patch=function(e,t,n){return s(a({url:e,method:d.PATCH,data:t},n))},s.del=function(e,t){return s(a({url:e,method:d.DELETE},t))},s.options=function(e,t){return s(a({url:e,method:d.OPTIONS},t))},n.default=s},{q:2,"querystring/encode":3}]},{},[7]);var at,st=function(e){function n(){var e;return o(this,n),(e=t(this,n)).apiEnv=new X(Y),e}return l(n,e),s(n,[{key:"setEnv",value:function(e,t){p(d(n.prototype),"setEnv",this).call(this,e,t),this.apiEnv.setEnv(e,t)}},{key:"getCheckoutUri",value:function(e){return this.apiEnv.getConf().url+"/v1/echo?"+ne.serialize({json_body:JSON.stringify({redirect_uri:e})})}}])}(Xe),ut=function(e){function n(){var e;return o(this,n),(e=t(this,n)).runs=!1,e.eventEmitter=new Oe,e}return l(n,e),s(n,[{key:"run",value:function(){this.runs=!0,this.background.initLoader()}},{key:"isRunning",value:function(){return this.runs}},{key:"next",value:function(e){var t=this;this.background.clear(),this.checkout=e;var n=this.getCheckoutUri(this.checkout.link);Zip.Checkout.init({checkoutUri:n,onComplete:function(e){return t.eventHandler(e)},onError:function(e){return t.eventHandler(e)}})}},{key:"getSuccessRedirectUri",value:function(){return this.suspendedRedirectUri?this.suspendedRedirectUri:this.widgetEnv.getConf().url+String("/checkout/zipmoney/suspended")}},{key:"getErrorRedirectUri",value:function(){return this.getSuccessRedirectUri()}},{key:"stop",value:function(){p(d(n.prototype),"stop",this).call(this),this.runs=!1;var e=document.querySelector(".zipmoney-overlay");e&&e.remove(),this.eventEmitter.emit(ze.CLOSE)}},{key:"onStop",value:function(e){var t=this;this.eventEmitter.subscribe(ze.CLOSE,(function(){t.background.clear(),e()}))}},{key:"onCheckout",value:function(e,t){var n=this;this.eventEmitter.subscribe(e,(function(){t(n.checkout)}))}},{key:"eventHandler",value:function(e){switch(this.runs=!1,e.state){case"approved":this.eventEmitter.emit(ze.CLOSE),this.eventEmitter.emit(ze.SUCCESS);break;case"declined":this.eventEmitter.emit(ze.CLOSE),this.eventEmitter.emit(ze.DECLINED);break;case"cancelled":this.eventEmitter.emit(ze.CLOSE);break;case"referred":this.eventEmitter.emit(ze.CLOSE),this.eventEmitter.emit(ze.REFERRED);break;default:console.warn("".concat("[CheckoutButton:Zipmoney]"," Unknown gateway status."))}}}])}($e(st)),ct="[Paydock:StorageDispatcher]";!function(e){e.WIDGET_SESSION="widget-session"}(at||(at={}));var lt,dt,ht=function(){return s((function e(t){o(this,e),this.messageSource=t,this.defaultPayload={destination:"widget.paydock"},this.env=new X(K),this.defaultPayload.source=t,this.iframeEvent=new de(window)}),[{key:"create",value:function(e){this.onLoadCallback=e,this.dispatcherFrame&&this.destroy(),this.widgetId=ie.generate(),this.setupIframeEventListeners();var t=document.createElement("iframe");return t.setAttribute("src",this.env.getConf().url+"/storage-dispatcher"+"?widgetId=".concat(this.widgetId)),t.setAttribute("id","pd-storage-dispatcher"),t.style.display="none",document.body.appendChild(t),this.dispatcherFrame=t,console.info("".concat(ct," initialized.")),t}},{key:"destroy",value:function(){this.dispatcherFrame&&this.dispatcherFrame.parentNode&&this.dispatcherFrame.parentNode.removeChild(this.dispatcherFrame),this.iframeEvent.clear(),this.widgetId=void 0,this.dispatcherFrame=void 0}},{key:"push",value:function(e,t){var n;if(this.pushCallbacks=t,this.dispatcherFrame){var i=c(c({},this.defaultPayload),e);null===(n=this.dispatcherFrame.contentWindow)||void 0===n||n.postMessage(i,this.env.getConf().url)}else console.error("".concat(ct," dispatcher is not initialized."))}},{key:"setEnv",value:function(e,t){this.env.setEnv(e,t),this.create(this.onLoadCallback)}},{key:"setupIframeEventListeners",value:function(){var e=this;this.widgetId&&(this.iframeEvent.on(le.AFTER_LOAD,this.widgetId,(function(t){var n;null===(n=e.onLoadCallback)||void 0===n||n.call(e)})),this.iframeEvent.on(le.DISPATCH_SUCCESS,this.widgetId,(function(t){var n,i;null===(i=null===(n=e.pushCallbacks)||void 0===n?void 0:n.onSuccess)||void 0===i||i.call(n)})),this.iframeEvent.on(le.DISPATCH_ERROR,this.widgetId,(function(t){var n,i;null===(i=null===(n=e.pushCallbacks)||void 0===n?void 0:n.onError)||void 0===i||i.call(n)})))}}])}(),pt=function(e){function n(){var e;return o(this,n),(e=t(this,n)).storageDispatcher=new ht("zipmoney.checkout.paydock"),e}return l(n,e),s(n,[{key:"getProxyRedirectUrl",value:function(){return this.widgetEnv.getConf().url+"/checkout/zipmoney/response"}},{key:"next",value:function(e,t){var n=this;this.storageDispatcher.create((function(){var i={merchant_redirect_url:n.getRedirectUrl(),checkout_token:e.token,public_key:t.public_key,gateway_id:t.gateway_id};n.storageDispatcher.push({intent:at.WIDGET_SESSION,data:i},{onSuccess:function(){var t=n.getCheckoutUri(e.link);Zip.Checkout.init({checkoutUri:t,redirect:!0})},onError:function(){console.error("Error initializing Zip Checkout")}})}))}},{key:"getSuccessRedirectUri",value:function(){return this.getProxyRedirectUrl()}},{key:"getErrorRedirectUri",value:function(){return this.getProxyRedirectUrl()}},{key:"setEnv",value:function(e,t){p(d(n.prototype),"setEnv",this).call(this,e,t),this.storageDispatcher.setEnv(e,t)}}])}(function(){return function(e){function n(){return o(this,n),t(this,n,arguments)}return l(n,e),s(n,[{key:"setRedirectUrl",value:function(e){this.merchantRedirectUrl=e}},{key:"getRedirectUrl",value:function(){return this.merchantRedirectUrl}},{key:"error",value:function(e,t,n){n(!1)}}])}(arguments.length>0&&void 0!==arguments[0]?arguments[0]:Xe)}(st)),ft=function(e){function n(){return o(this,n),t(this,n,arguments)}return l(n,e),s(n,[{key:"getSuccessRedirectUri",value:function(){return this.widgetEnv.getConf().url+ne.extendSearchParams("/checkout/success","merchant",encodeURIComponent(window.location.href))}},{key:"getErrorRedirectUri",value:function(){return this.widgetEnv.getConf().url+ne.extendSearchParams("/checkout/error","merchant",encodeURIComponent(window.location.href))}}])}(it),vt=function(e){function n(){return o(this,n),t(this,n,arguments)}return l(n,e),s(n,[{key:"getSuccessRedirectUri",value:function(){return this.widgetEnv.getConf().url+"/checkout/afterpay/merchant/{{merchant}}/success".replace("{{merchant}}",encodeURIComponent(window.btoa(window.location.href)))}},{key:"getErrorRedirectUri",value:function(){return this.widgetEnv.getConf().url+"/checkout/afterpay/merchant/{{merchant}}/error".replace("{{merchant}}",encodeURIComponent(window.btoa(window.location.href)))}},{key:"next",value:function(e,t){this.checkout=e,k.isSupportPopUp()||window.localStorage.setItem("paydock_checkout_token",JSON.stringify(this.checkout)),this.popup.redirect(this.getRedirectUrl(this.checkout,t))}},{key:"error",value:function(e,t,n){return!t||t&&"invalid_amount"!==t?n(!0):(this.popup.initError(e),n(!1))}},{key:"run",value:function(){this.isRunning()||(this.popup.setConfigs({width:420,height:715}),this.popup.init(),this.background.initControl())}},{key:"getRedirectUrl",value:function(e,t){return this.widgetEnv.getConf().url+"/checkout/afterpay/init?"+ne.serialize(c(c({},t),{token:e.reference_id,env:"live"===e.mode?"live":"test"}))}}])}(it),mt={EXTERNAL_CHECKOUT_TOKEN:"external_checkout_token",CHECKOUT_TOKEN:"checkout_token",BANK_ACCOUNT:"bank_account",CARD:"card"},yt=function(e){function n(e,i){var r,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:mt.CARD;switch(o(this,n),(r=t(this,n)).body={gateway_id:e,type:a},a){case mt.CARD:case mt.BANK_ACCOUNT:delete i.gateway_id,delete i.type,delete i.checkout_token,r.body=c(r.body,i);break;case mt.CHECKOUT_TOKEN:case mt.EXTERNAL_CHECKOUT_TOKEN:r.body.checkout_token=i;break;default:throw new Error("Unsupported type of PaymentSourceToken")}return r}return l(n,e),s(n,[{key:"getLink",value:function(){return"/v1/payment_sources/tokens"}},{key:"send",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(e){};this.create(e,this.getConfigs(),(function(e,n){return t(e)}),(function(e,t){void 0===e.message?n("unknown error"):n(e.message)}))}},{key:"getConfigs",value:function(){return this.body}}])}(Ve),gt=function(){return s((function e(t,n,i,r){var a=this;o(this,e),this.background=t,this.runner=n,this.eventEmitter=i,this.params=r,this.runner.onStop((function(){a.eventEmitter.emit(xe.CLOSE)}))}),[{key:"init",value:function(e){var t=this;this.setEnv(e),this.runner.onCheckout(ze.SUCCESS,(function(e){t.eventEmitter.emit(xe.ACCEPTED,{}),t.background.initLoader(),t.runner.stop(),t.checkToken(e.token,(function(){t.createOneTimeToken(e.token)}))})),this.runner.onCheckout(ze.ERROR,(function(){t.eventEmitter.emit(xe.ERROR),console.error("".concat(Le," Error from checkout server.")),t.runner.stop()})),this.runner.onCheckout(ze.REFERRED,(function(){t.eventEmitter.emit(xe.REFERRED),t.runner.stop()})),this.runner.onCheckout(ze.DECLINED,(function(){t.eventEmitter.emit(xe.DECLINED),t.runner.stop()})),this.eventEmitter.subscribe(xe.ERROR,(function(){t.runner.stop()})),this.eventEmitter.subscribe(xe.FINISH,(function(e){t.background.clear()}))}},{key:"setEnv",value:function(e){this.env=e}},{key:"checkToken",value:function(e,t){var n=this,i=new Ke(e);i.setEnv(this.env),i.send(this.params.accessToken,(function(e){n.details=e,t()}),(function(){n.eventEmitter.emit(xe.ERROR,{}),console.error("".concat(Le," Error during creating payment source token."))}))}},{key:"createOneTimeToken",value:function(e){var t=this,n=new yt(this.params.gatewayId,e,mt.CHECKOUT_TOKEN);n.setEnv(this.env),n.send(this.params.accessToken,(function(e){t.eventEmitter.emit(xe.FINISH,{payment_source_token:e,checkout_email:t.details.checkout_email,checkout_holder:t.details.checkout_holder,gateway_type:t.details.gateway_type})}),(function(){t.eventEmitter.emit(xe.ERROR,{}),console.error("".concat(Le," Error during creating payment source token."))}))}}])}(),kt=function(){return s((function e(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"default",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Pe.PAYPAL,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:Ae.CONTEXTUAL;o(this,e),this.accessToken=n,this.gatewayId=i,this.gatewayType=r,this.mode=a,this.window=window,this.meta={},this.env=G,this.eventEmitter=new Oe,this.container=new ue(t),this.initCheckout(this.container),this.chooseRunner(r,a)}),[{key:"chooseRunner",value:function(e,t){var n=this.getRunnerByMode(e,t);this.runner=new n(this.accessToken),rt(this.runner)?(this.background=new Ze,this.checkoutHandler=new gt(this.background,this.runner,this.eventEmitter,{accessToken:this.accessToken,gatewayId:this.gatewayId}),this.checkoutHandler.init(this.env)):(this.background=void 0,this.checkoutHandler=void 0)}},{key:"buildAdditionalParams",value:function(){return{}}},{key:"initCheckout",value:function(e){var t=this;e.on("click",(function(e){if(rt(t.runner)){if(t.runner.isRunning())return;t.runner.run()}else if(ot(t.runner)&&!t.runner.getRedirectUrl())throw Error("".concat(Le," The merchant redirect URL should is required in the '").concat(t.mode,"' mode."));t.eventEmitter.emit(xe.CLICK);var n=new qe(t.gatewayId,t.runner.getSuccessRedirectUri(),t.runner.getErrorRedirectUri());n.setMeta(t.meta),n.setEnv(t.env),n.send(t.accessToken,(function(e){var n=rt(t.runner)?xe.POPUP_REDIRECT:xe.REDIRECT;t.eventEmitter.emit(n),t.runner.next(e,t.buildAdditionalParams())}),(function(e,n){console.error("".concat(Le," ").concat(e)),t.eventEmitter.emit(xe.ERROR,{error:e,code:n}),t.runner.error(e,n,(function(e){e&&t.close()}))}))}))}},{key:"on",value:function(e,t){this.eventEmitter.subscribe(e,t)}},{key:"close",value:function(){this.assertMethodSupport(this.runner,Ae.CONTEXTUAL)&&this.runner.stop()}},{key:"onFinishInsert",value:function(e,t){this.on(xe.FINISH,(function(n){se.insertToInput(e,t,n)}))}},{key:"setMeta",value:function(e){this.meta=c(this.meta,e)}},{key:"setBackdropDescription",value:function(e){this.assertMethodSupport(this.runner,Ae.CONTEXTUAL)&&this.runner.setBackgroundDescription(e)}},{key:"setBackdropTitle",value:function(e){this.assertMethodSupport(this.runner,Ae.CONTEXTUAL)&&this.runner.setBackgroundTitle(e)}},{key:"setSuspendedRedirectUri",value:function(e){this.assertMethodSupport(this.runner,Ae.CONTEXTUAL)&&this.runner.setSuspendedRedirectUri(e)}},{key:"setRedirectUrl",value:function(e){this.assertMethodSupport(this.runner,Ae.REDIRECT)&&this.runner.setRedirectUrl(e)}},{key:"getSuccessRedirectUri",value:function(){return this.runner.getSuccessRedirectUri()}},{key:"turnOffBackdrop",value:function(){this.turnOffControlBackdrop(),this.turnOffLoaderBackdrop()}},{key:"turnOffControlBackdrop",value:function(){this.assertMethodSupport(this.runner,Ae.CONTEXTUAL)&&this.runner.turnOffBackdrop()}},{key:"turnOffLoaderBackdrop",value:function(){var e;null===(e=this.background)||void 0===e||e.turnOffLoader()}},{key:"setEnv",value:function(e,t){var n;this.env=e,this.alias=t,null===(n=this.checkoutHandler)||void 0===n||n.setEnv(e),this.runner.setEnv(e,t)}},{key:"getEnv",value:function(){return this.env}},{key:"getRunnerByMode",value:function(e,t){if(e===Pe.PAYPAL){if(t===Ae.REDIRECT)throw Error("".concat(Le," Gateway '").concat(e,"' do not support '").concat(t,"' mode"));return ft}if(e===Pe.AFTERPAY){if(t===Ae.REDIRECT)throw Error("".concat(Le," Gateway '").concat(e,"' do not support '").concat(t,"' mode"));return vt}if(e===Pe.ZIPMONEY)return t===Ae.CONTEXTUAL?ut:pt;throw Error("".concat(Le," Unsupported gateway."))}},{key:"assertMethodSupport",value:function(e,t){var n="".concat(Le," The method is not supported in the '").concat(t,"' mode.");switch(t){case Ae.CONTEXTUAL:if(rt(e))return!0;console.warn(n);break;case Ae.REDIRECT:if(ot(e))return!0;console.warn(n)}return!1}}])}(),Et=function(e){function n(e,i){var r,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"default",s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Ae.CONTEXTUAL;return o(this,n),(r=t(this,n,[e,i,a,Pe.ZIPMONEY,s])).publicKey=i,r.gatewayId=a,r.mode=s,r}return l(n,e),s(n,[{key:"setSuspendedRedirectUri",value:function(e){p(d(n.prototype),"setSuspendedRedirectUri",this).call(this,e)}},{key:"setRedirectUrl",value:function(e){rt(this.runner)&&(p(d(n.prototype),"chooseRunner",this).call(this,Pe.ZIPMONEY,Ae.REDIRECT),p(d(n.prototype),"setEnv",this).call(this,this.env,this.alias)),p(d(n.prototype),"setRedirectUrl",this).call(this,e)}},{key:"buildAdditionalParams",value:function(){return c(c({},p(d(n.prototype),"buildAdditionalParams",this).call(this)),{public_key:this.publicKey,gateway_id:this.gatewayId})}}])}(kt),_t=function(e){function n(e,i){var r,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"default";return o(this,n),(r=t(this,n,[e,i,a,Pe.AFTERPAY])).accessToken=i,r.gatewayId=a,r.showETP=!1,r}return l(n,e),s(n,[{key:"showEnhancedTrackingProtectionPopup",value:function(e){var t=k.getBrowserInfo(),n=t.name,i=t.version;e&&"Firefox"===n&&+i>=100&&(this.showETP=!0)}},{key:"buildAdditionalParams",value:function(){var e=p(d(n.prototype),"buildAdditionalParams",this).call(this);return this.showETP&&(e.show_etp=!0),e}}])}(kt),bt=function(e){function n(e,i){var r,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"default";return o(this,n),(r=t(this,n,[e,i,a,Pe.PAYPAL])).publicKey=i,r.gatewayId=a,r}return l(n,e),s(n)}(kt),wt=function(){return s((function e(){o(this,e)}),null,[{key:"values",value:function(e){return Object.keys(e).map((function(t){return e[t]}))}}])}(),Ct=function(){return s((function e(t,n){o(this,e),this.configs=[],this.configTokens=[],this.link=new ae("/payment-sources"),this.link.setParams(c({query_token:n},C.validateJWT(t)?{access_token:t}:{public_key:t})),$.version&&this.link.setParams({sdk_version:$.version,sdk_type:$.type})}),[{key:"setStyles",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setStyle(t,e[t])}},{key:"setStyle",value:function(e,t){-1!==wt.values(Me).indexOf(e)?this.link.setParams(u({},e,t)):console.warn("Widget::setStyle[s: unsupported style param ".concat(e))}},{key:"setRefId",value:function(e){this.link.setParams({ref_id:e})}},{key:"setLimit",value:function(e){this.link.setParams({limit:e})}},{key:"setEnv",value:function(e,t){for(var n in this.link.setEnv(e,t),this.configs)this.configs.hasOwnProperty(n)&&this.configs[n].setEnv(e,t)}},{key:"getEnv",value:function(){this.link.getEnv()}},{key:"getIFrameUrl",value:function(){return this.link.getUrl()}},{key:"filterByGatewayIds",value:function(e){this.link.setParams({gateway_ids:e.join(",")})}},{key:"filterByTypes",value:function(e){var t,n=[],i=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=m(e))||t){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}(e);try{for(i.s();!(t=i.n()).done;){var r=t.value;e.hasOwnProperty(r)&&(-1===wt.values(Ne).indexOf(r)?console.warn("PaymentSourceWidget::filterByTypes: unsupported type ".concat(r)):n.push(r))}}catch(e){i.e(e)}finally{i.f()}this.link.setParams({payment_source_types:n.join(",")})}},{key:"setLanguage",value:function(e){this.link.setParams({language:e})}}])}(),St=function(e){function n(e,i,r){var a;return o(this,n),(a=t(this,n,[i,r])).container=new ue(e),a.iFrame=new ce(a.container),a.event=new de(window),a}return l(n,e),s(n,[{key:"load",value:function(){this.iFrame.load(this.getIFrameUrl(),{title:"Payment Sources"})}},{key:"on",value:function(e,t){this.event.on(e,this.link.getParams().widget_id,t)}},{key:"hide",value:function(e){console.info("PayDock SDK"),this.iFrame.hide(e)}},{key:"show",value:function(){this.iFrame.show()}},{key:"reload",value:function(){this.iFrame.remove(),this.load()}},{key:"onSelectInsert",value:function(e,t){this.on(le.SELECT,(function(n){se.insertToInput(e,t,n)}))}}])}(Ct);!function(e){e.IFRAME_LOADED="iframeLoaded",e.CHECKOUT_READY="checkoutReady",e.CHECKOUT_COMPLETED="checkoutCompleted",e.CHECKOUT_ERROR="checkoutError",e.CHECKOUT_POPUP_OPEN="checkoutPopupOpen",e.CHECKOUT_POPUP_CLOSE="checkoutPopupClose"}(lt||(lt={})),function(e){e.CRITICAL_ERROR="CriticalError",e.USER_ERROR="UserError",e.SUCCESS="Success"}(dt||(dt={}));var Tt,Ot={PRIMARY_BUTTON_COLOR:"primary_button_color",SECONDARY_BUTTON_COLOR:"secondary_button_color",PRIMARY_BUTTON_TEXT_COLOR:"primary_button_text_color",SECONDARY_BUTTON_TEXT_COLOR:"secondary_button_text_color",FONT_FAMILY:"font_family",ENABLE_SRC_POPUP:"enable_src_popup"},At=function(){return s((function e(t,n,i,r,a,s,u,l){o(this,e),this.meta=r,this.eventEmitter=a,this.autoResize=s,this.link=new ae("/secure-remote-commerce/mastercard"),this.link.setParams(c({service_id:n,public_key:i},r&&{meta:JSON.stringify(r)})),$.version&&this.link.setParams({sdk_version:$.version,sdk_type:$.type}),u&&this.link.setEnv(u,l),this.iFrameContainer=new ue(t),this.iFrame=new ce(this.iFrameContainer),this.iFrameEvent=new de(window),this.setupIFrameEvents()}),[{key:"setupIFrameEvents",value:function(){var e=this,t=this.link.getParams().widget_id;t&&(this.iFrameEvent.on(lt.CHECKOUT_READY,t,(function(t){var n=t.data;e.eventEmitter.emit(lt.CHECKOUT_READY,n)})),this.iFrameEvent.on(lt.CHECKOUT_COMPLETED,t,(function(t){var n=t.data;e.eventEmitter.emit(lt.CHECKOUT_COMPLETED,n)})),this.iFrameEvent.on(lt.CHECKOUT_POPUP_OPEN,t,(function(t){var n=t.data;e.eventEmitter.emit(lt.CHECKOUT_POPUP_OPEN,n)})),this.iFrameEvent.on(lt.CHECKOUT_POPUP_CLOSE,t,(function(t){var n=t.data;e.eventEmitter.emit(lt.CHECKOUT_POPUP_CLOSE,n)})),this.iFrameEvent.on(lt.CHECKOUT_ERROR,t,(function(t){var n=t.data;e.eventEmitter.emit(lt.CHECKOUT_ERROR,n)})),this.autoResize&&this.useAutoResize(!0))}},{key:"load",value:function(){var e=this;this.iFrame.load(this.link.getUrl(),{title:"Click To Pay checkout"});var t=this.iFrame.getElement();this.iFrame.setStyle("width","100%"),t&&(t.onload=function(){return e.eventEmitter.emit(lt.IFRAME_LOADED,{})})}},{key:"getEnv",value:function(){return this.link.getEnv()}},{key:"hideCheckout",value:function(e){this.iFrame&&this.iFrame.hide()}},{key:"showCheckout",value:function(){this.iFrame&&this.iFrame.show()}},{key:"reload",value:function(){this.iFrame.remove(),this.load()}},{key:"useAutoResize",value:function(e){var t=this;if(!this.autoResize||e){this.autoResize=!0;var n=this.link.getParams();(null==n?void 0:n.widget_id)&&this.iFrameEvent.on("resize",n.widget_id,(function(e){var n,i,r=e.data,o=t.iFrame.getElement();o&&(o.scrolling="no",(null===(n=null==r?void 0:r.data)||void 0===n?void 0:n.height)&&t.iFrame.setStyle("height",(null===(i=null==r?void 0:r.data)||void 0===i?void 0:i.height)+"px"))}))}}}])}(),Pt=function(e){function n(e,i,r,a){var s;return o(this,n),(s=t(this,n,[e,i,r,a])).iframe_selector=e,s.service_id=i,s.public_key_or_access_token=r,s.meta=a,s}return l(n,e),s(n,[{key:"load",value:function(){this.provider||(this.meta.customizations=this.style,this.provider=new At(this.iframe_selector,this.service_id,this.public_key_or_access_token,this.meta,this.eventEmitter,this.autoResize,this.env,this.alias),this.provider.load())}}])}(function(){return s((function e(t,n,i,r){o(this,e),this.iframe_selector=t,this.service_id=n,this.public_key_or_access_token=i,this.meta=r,this.autoResize=!1,this.style={},this.api=new Ce(i,g.PUBLIC_KEY),this.eventEmitter=new Oe}),[{key:"setStyles",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setStyle(t,e[t])}},{key:"setStyle",value:function(e,t){-1!==wt.values(Ot).indexOf(e)?this.style[e]=t:console.warn("Widget::setStyle[s: unsupported style param ".concat(e))}},{key:"load",value:function(){var e=this;this.provider||this.api.service().getConfig(this.service_id).then((function(t){var n=t.type;if(e.meta.customizations=e.style,n===pe.MASTERCARD_SRC)e.provider=new At(e.iframe_selector,e.service_id,e.public_key_or_access_token,e.meta,e.eventEmitter,e.autoResize,e.env,e.alias);e.provider&&e.provider.load()}))}},{key:"setEnv",value:function(e,t){this.provider||(this.env=e,this.alias=t,this.api.setEnv(e,t))}},{key:"getEnv",value:function(){return this.provider?this.provider.getEnv():this.env}},{key:"on",value:function(e,t){var n=this;return"function"==typeof t?this.eventEmitter.subscribe(e,t):new Promise((function(t){return n.eventEmitter.subscribe(e,(function(e){return t(e)}))}))}},{key:"hideCheckout",value:function(e){this.provider&&"function"==typeof this.provider.hideCheckout&&this.provider.hideCheckout(e)}},{key:"showCheckout",value:function(){this.provider&&"function"==typeof this.provider.showCheckout&&this.provider.showCheckout()}},{key:"reload",value:function(){this.provider&&this.provider.reload()}},{key:"useAutoResize",value:function(){this.autoResize=!0,this.provider&&"function"==typeof this.provider.useAutoResize&&this.provider.useAutoResize()}}])}()),Rt={SUBMIT_FORM:"submit_form",CHANGE_TAB:"tab",HIDE_ELEMENTS:"hide_elements",SHOW_ELEMENTS:"show_elements",REFRESH_CHECKOUT:"refresh_checkout",UPDATE_FORM_VALUES:"update_form_values",INIT_CHECKOUT:"init_checkout"},xt=function(){return s((function e(t){o(this,e),this.iFrame=t}),[{key:"push",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.iFrame.isExist()){-1===wt.values(Rt).indexOf(e)&&console.warn("unsupported trigger type");var n={trigger:e,destination:"widget.paydock",data:t};this.iFrame.getElement().contentWindow.postMessage(JSON.stringify(n),"*")}}}])}();!function(e){e.AFTER_LOAD="after_load",e.SYSTEM_ERROR="system_error",e.CVV_SECURE_CODE_REQUESTED="cvv_secure_code_requested",e.CARD_NUMBER_SECURE_CODE_REQUESTED="card_number_secure_code_requested",e.ACCESS_FORBIDDEN="access_forbidden",e.SESSION_EXPIRED="session_expired",e.OPERATION_FORBIDDEN="operation_forbidden"}(Tt||(Tt={}));var It,Ut=function(e){function n(){return o(this,n),t(this,n,arguments)}return l(n,e),s(n,[{key:"on",value:function(e,t,n){for(var i in Tt)Tt.hasOwnProperty(i)&&e===Tt[i]&&this.listeners.push({event:e,listener:n,widget_id:t})}}])}(de),Lt=function(){return s((function e(t,n){o(this,e),this.validationData={},this.configs=[],this.container=new ue(t),this.iFrame=new ce(this.container),this.triggerElement=new xt(this.iFrame),this.event=new Ut(window),this.vaultDisplayToken=n,this.link=new ae("/vault-display"),this.link.setParams({vault_display_token:n})}),[{key:"setEnv",value:function(e,t){this.link.setEnv(e,t)}},{key:"on",value:function(e,t){var n=this;return"function"==typeof t?this.event.on(e,this.link.getParams().widget_id,t):new Promise((function(t){return n.event.on(e,n.link.getParams().widget_id,(function(e){return t(e)}))}))}},{key:"setStyles",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setStyle(t,e[t])}},{key:"setStyle",value:function(e,t){-1!==wt.values(Me).indexOf(e)?this.link.setParams(u({},e,t)):console.warn("Widget::setStyle[s: unsupported style param ".concat(e))}},{key:"load",value:function(){this.iFrame.load(this.link.getUrl(),{title:"Vault Display"})}}])}();!function(e){e.AFTER_LOAD="after_load",e.UNAVAILABLE="unavailable",e.START_LOADING="start_loading",e.END_LOADING="end_loading",e.UPDATE="update",e.PAYMENT_SUCCESSFUL="payment_successful",e.PAYMENT_IN_REVIEW="payment_in_review",e.PAYMENT_ERROR="payment_error"}(It||(It={}));var Nt=function(e){function n(){return o(this,n),t(this,n,arguments)}return l(n,e),s(n,[{key:"on",value:function(e,t,n){for(var i in It)It.hasOwnProperty(i)&&e===It[i]&&this.listeners.push({event:e,listener:n,widget_id:t})}}])}(de),Dt={CLOSE:"close",UPDATED:"updated"},Mt=function(e){function n(e,i){var r;return o(this,n),(r=t(this,n,[e])).widgetId=i,r}return l(n,e),s(n,[{key:"push",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.iFrame.isExist()){-1===wt.values(Dt).indexOf(e)&&console.warn("unsupported trigger type");var n={message_source:"wallet.paydock",reference_id:this.widgetId,trigger:e,destination:"widget.paydock",data:t};this.iFrame.getElement().contentWindow.postMessage(JSON.stringify(n),"*")}}}])}(xt),Ht=function(e){function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return o(this,n),(i=t(this,n)).bgImageUrl=e,i.hideCloseButton=r,i.hideContinueButton=a,i.imageStyle=null,i}return l(n,e),s(n,[{key:"initControl",value:function(){this.imageStyle||this.createImageStyles(),p(d(n.prototype),"initControl",this).call(this)}},{key:"clear",value:function(){this.imageStyle&&this.imageStyle.parentNode.removeChild(this.imageStyle),this.imageStyle=null,p(d(n.prototype),"clear",this).call(this)}},{key:"createTemplate",value:function(){var e=this,t=document.body||document.getElementsByTagName("body")[0],n=String('\n <div class="checkout-container">\n <div class="checkout-bg-logo"></div>\n <a href="#" data-continue>Continue</a>\n <a href="#" data-close>Close</a>\n </div>\n');!0===this.hideCloseButton&&(n=n.replace('<a href="#" data-close>Close</a>',"")),!0===this.hideContinueButton&&(n=n.replace('<a href="#" data-continue>Continue</a>',"")),this.overlay=document.createElement("div"),this.overlay.classList.add("checkout-overlay"),this.overlay.setAttribute("checkout-overlay"," "),this.overlay.innerHTML=n,t.appendChild(this.overlay),setTimeout((function(){e.isInit()&&e.overlay.classList.add("display")}),5)}},{key:"createImageStyles",value:function(){var e=document.head||document.getElementsByTagName("head")[0],t=String("\n .checkout-bg-logo {\n display: block;\n background: url({{url}}) no-repeat;\n width: 100px;\n height: 50px;\n margin: 0 auto;\n border-radius: 10px;\n background-size: contain;\n }\n [data-continue] {\n margin-top: 24px;\n display: block;\n font-family: Helvetica, sans-serif;\n text-decoration: none;\n color: #fff !important;\n border: 1px solid white;\n width: 100px;\n border-radius: 16px;\n padding: 5px;\n }\n [data-continue]:hover {\n background-color: #f2f2f2;\n border: none;\n color: rgba(0, 0, 0, 0.7) !important;\n }\n .checkout-container {\n display: flex;\n flex-direction: column;\n align-items: center;\n }\n\n .checkout-overlay {\n z-index: 2147483647;\n }\n\n .checkout-container [data-close] {\n opacity: 1;\n }\n .checkout-container [data-close]:before,\n .checkout-container [data-close]:after {\n background-color: #fff;\n }\n");document.querySelector(".checkout-container"),t=t.replace("{{url}}",this.bgImageUrl),this.imageStyle=document.createElement("style"),this.imageStyle.type="text/css",this.imageStyle.appendChild(document.createTextNode(t)),e.appendChild(this.imageStyle)}}])}(Ze),Ft={UNAVAILABLE:"unavailable",UPDATE:"update",PAYMENT_METHOD_SELECTED:"payment_method_selected",PAYMENT_SUCCESS:"payment_success",PAYMENT_IN_REVIEW:"payment_in_review",PAYMENT_ERROR:"payment_error",CALLBACK:"callback",AUTH_TOKENS_CHANGED:"auth_tokens_changed",BUTTON_CLICK:"button_click",CHECKOUT_OPEN:"checkout_open",CHECKOUT_CLOSE:"checkout_close"},Bt=function(){return s((function e(t,n){o(this,e),this.publicKey=t,this.meta=n,this.env=G,this.eventEmitter=new Oe,this.initializeChildWallets()}),[{key:"initializeChildWallets",value:function(){this.childWallets=[]}},{key:"getGatewayName",value:function(){throw new Error("Method not implemented")}},{key:"setEnv",value:function(e){return this.env=e,this}},{key:"load",value:function(e){this.childWallets.forEach((function(t){return t.load(e)}))}},{key:"update",value:function(e){}},{key:"enable",value:function(){}},{key:"disable",value:function(){}},{key:"on",value:function(e,t){var n=this;if(-1===wt.values(Ft).indexOf(e))throw new Error("invalid wallet event");return"function"==typeof t?this.eventEmitter.subscribe(e,t):new Promise((function(t){return n.eventEmitter.subscribe(e,(function(e){return t(e)}))}))}}])}(),jt=function(e){function n(e,i){var r;o(this,n),(r=t(this,n,[e,i])).link=new ae(re);var a=i.amount,s=i.currency,u=i.id,l=i.gateway_mode,d=i.reference,h=i.request_shipping;return r.link.setParams(c({token:e,amount:a,currency:s,gateway_mode:l,credentials:d||u},h?{request_shipping:h}:{})),$.version&&r.link.setParams({sdk_version:$.version,sdk_type:$.type}),r.token=e,r.event=new Nt(window),r}return l(n,e),s(n,[{key:"load",value:function(e){this.container=e,this.iFrame=new ce(this.container);var t=this.link.getParams().widget_id;this.triggerElement=new Mt(this.iFrame,t),this.setupIFrameEvents(t),this.background=this.initBackground(),this.iFrame.load(this.link.getUrl())}},{key:"close",value:function(){this.triggerElement.push(Dt.CLOSE),this.background.clear()}},{key:"update",value:function(e){this.triggerElement.push(Dt.UPDATED,e)}},{key:"setEnv",value:function(e){return this.link.setEnv(e),this}},{key:"initBackground",value:function(){var e=this,t=new Ht(this.link.getNetUrl().replace(re,oe));return t.setBackdropTitle(""),t.setBackdropDescription(""),t.onTrigger(Ge,(function(){return e.triggerElement.push(Dt.CLOSE)})),t}},{key:"setupIFrameEvents",value:function(e){var t=this;this.event.on(It.UNAVAILABLE,e,(function(e){return t.eventEmitter.emit(Ft.UNAVAILABLE,null)})),this.event.on(It.START_LOADING,e,(function(e){return t.background.initControl()})),this.event.on(It.END_LOADING,e,(function(e){return t.background.clear()})),this.event.on(It.UPDATE,e,(function(e){t.eventEmitter.emit(Ft.UPDATE,t.parseUpdateData(e))})),this.event.on(It.PAYMENT_SUCCESSFUL,e,(function(e){t.eventEmitter.emit(Ft.PAYMENT_SUCCESS,t.parsePaymentSuccessfulData(e)),t.iFrame.getElement()||t.background.clear()})),this.event.on(It.PAYMENT_IN_REVIEW,e,(function(e){t.eventEmitter.emit(Ft.PAYMENT_IN_REVIEW,t.parsePaymentSuccessfulData(e)),t.iFrame.getElement()||t.background.clear()})),this.event.on(It.PAYMENT_ERROR,e,(function(e){t.eventEmitter.emit(Ft.PAYMENT_ERROR,e),t.iFrame.getElement()||t.background.clear()}))}},{key:"parsePaymentSuccessfulData",value:function(e){var t;return{id:this.meta.id,amount:e.amount,currency:e.currencyCode,status:null===(t=e.charge)||void 0===t?void 0:t.status}}},{key:"parseUpdateData",value:function(e){return c(c(c({wallet_response_code:e.responseCode,wallet_session_id:e.sessionId},e.paymentMethodDetails?{payment_source:{wallet_payment_method_id:e.paymentMethodDetails.paymentMethodId,card_number_last4:e.paymentMethodDetails.lastFourDigitsOfPan,card_scheme:e.paymentMethodDetails.paymentScheme}}:{}),e.loyaltyAccountSummary?{wallet_loyalty_account:{id:e.loyaltyAccountSummary.loyaltyAccountId,barcode:e.loyaltyAccountSummary.loyaltyAccountBarcode}}:{}),e.deliveryAddressDetails?{shipping:{address_line1:e.deliveryAddressDetails.line1,address_line2:e.deliveryAddressDetails.line2,address_postcode:e.deliveryAddressDetails.postalCode,address_city:e.deliveryAddressDetails.city,address_state:e.deliveryAddressDetails.state,address_country:e.deliveryAddressDetails.countryCode,address_company:e.deliveryAddressDetails.companyName,wallet_address_id:e.deliveryAddressDetails.addressId,post_office_box_number:e.deliveryAddressDetails.postOfficeBoxNumber,wallet_address_created_timestamp:e.deliveryAddressDetails.createdTimestamp,wallet_address_updated_timestamp:e.deliveryAddressDetails.updatedTimestamp,wallet_address_name:e.deliveryAddressDetails.name}}:{})}}])}(Bt),zt=function(e){function n(){return o(this,n),t(this,n,arguments)}return l(n,e),s(n,[{key:"load",value:function(e){return window.Promise?(!0===this.meta.standalone?this.renderPaypalStandaloneComponent(e):this.renderPaypalCommonComponent(e),Promise.resolve()):(this.eventEmitter.emit(Ft.UNAVAILABLE,null),Promise.resolve())}},{key:"update",value:function(e){var t=this;if(this.latestShippingChangePromiseResolve&&this.latestShippingChangePromiseReject)return e.success?void this.eventEmitter.emit(Ft.CALLBACK,{data:{request_type:"UPDATE_TRANSACTION",shipping:this.latestShippingData},onSuccess:function(e){return t.latestShippingChangePromiseResolve(!0)},onError:function(){return t.latestShippingChangePromiseReject()}}):this.latestShippingChangePromiseReject()}},{key:"renderPaypalCommonComponent",value:function(e){var t,n=this,i=(null===(t=e.getElement())||void 0===t?void 0:t.id)||"",r=document.createElement("script");r.src="https://www.paypal.com/sdk/js?client-id=".concat(this.publicKey,"¤cy=").concat(this.meta.currency).concat(!0===this.meta.pay_later?"&enable-funding=paylater&disable-funding=card":"&disable-funding=credit,card").concat(this.meta.capture?"":"&intent=authorize"),r.async=!0,r.onload=function(){window.paypal?(n.paypal=window.paypal,n.paypal.Buttons(c({},n.paypalSharedProps())).render("#".concat(i))):n.eventEmitter.emit(Ft.UNAVAILABLE,null)},document.head.appendChild(r)}},{key:"renderPaypalStandaloneComponent",value:function(e){var t,n,i=this,r=(null===(t=e.getElement())||void 0===t?void 0:t.id)||"",o=document.createElement("script");o.src="https://www.paypal.com/sdk/js?client-id=".concat(this.publicKey,"¤cy=").concat(this.meta.currency,"&components=buttons,funding-eligibility,messages&enable-funding=paylater").concat(this.meta.capture?"":"&intent=authorize").concat("live"===(null===(n=this.meta)||void 0===n?void 0:n.gateway_mode)?"":"&buyer-country=AU"),o.async=!0,o.onload=function(){if(window.paypal){i.paypal=window.paypal;var e=!!i.meta.pay_later,t=i.paypal.Buttons(c({fundingSource:e?i.paypal.FUNDING.PAYLATER:i.paypal.FUNDING.PAYPAL},i.paypalSharedProps()));if(t.isEligible()){if(t.render("#".concat(r)),e)i.paypal.Messages(c({amount:i.meta.amount,currency:i.meta.currency,placement:"payment"},i.meta.style&&i.meta.style.messages&&{style:i.meta.style.messages})).render("#".concat(r))}else i.eventEmitter.emit(Ft.UNAVAILABLE,null)}else i.eventEmitter.emit(Ft.UNAVAILABLE,null)},document.head.appendChild(o)}},{key:"paypalSharedProps",value:function(){var e=this;return c(c({},this.meta.style&&{style:this.meta.style}),{onClick:function(t,n){var i;return e.eventEmitter.emit(Ft.BUTTON_CLICK,{attachResult:function(e){i=e&&e instanceof Promise?e.then((function(){return n.resolve()})).catch((function(){return n.reject()})):e}}),i},createOrder:function(){return new Promise((function(t,n){e.eventEmitter.emit(Ft.CALLBACK,{data:c({request_type:"CREATE_TRANSACTION"},e.meta.request_shipping&&{request_shipping:e.meta.request_shipping}),onSuccess:function(e){return t(e.id)},onError:function(e){return n(e)}})}))},onShippingChange:function(t,n){return new Promise((function(n,i){var r=e.parseUpdateData(t);e.latestShippingData=r.shipping,e.latestShippingChangePromiseResolve=n,e.latestShippingChangePromiseReject=i,e.eventEmitter.emit(Ft.UPDATE,r)}))},onApprove:function(t){return e.pendingApprovalPromise=e.pendingApprovalPromise||new Promise((function(n,i){return e.eventEmitter.emit(Ft.PAYMENT_METHOD_SELECTED,{data:{payment_method_id:t.orderID,customer:{payment_source:{external_payer_id:t.payerID}}},onSuccess:function(){e.pendingApprovalPromise=void 0,n(!0)},onError:function(t){e.pendingApprovalPromise=void 0,i(t)}})})),e.pendingApprovalPromise},onCancel:function(){return e.eventEmitter.emit(Ft.CHECKOUT_CLOSE)},onError:function(e){}})}},{key:"parseUpdateData",value:function(e){var t;return c(c({wallet_order_id:e.orderID,wallet_session_id:e.paymentID,payment_source:{wallet_payment_method_id:e.paymentToken}},e.shipping_address&&{shipping:{address_city:e.shipping_address.city,address_state:e.shipping_address.state,address_postcode:e.shipping_address.postal_code,address_country:e.shipping_address.country_code}}),e.selected_shipping_option&&{selected_shipping_option:{id:e.selected_shipping_option.id,label:e.selected_shipping_option.label,amount:e.selected_shipping_option.amount.value,currency:e.selected_shipping_option.amount.currency_code,type:null===(t=e.selected_shipping_option)||void 0===t?void 0:t.type}})}}])}(Bt),Vt={};function qt(e){return qt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},qt(e)}Object.defineProperty(Vt,"__esModule",{value:!0});var Kt,Yt="https://js.stripe.com/v3",Wt=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,Gt="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used",Jt=null,Zt=function(e){return null!==Jt||(Jt=new Promise((function(t,n){if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(Gt),window.Stripe)t(window.Stripe);else try{var i=function(){for(var e=document.querySelectorAll('script[src^="'.concat(Yt,'"]')),t=0;t<e.length;t++){var n=e[t];if(Wt.test(n.src))return n}return null}();i&&e?console.warn(Gt):i||(i=function(e){var t=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",n=document.createElement("script");n.src="".concat(Yt).concat(t);var i=document.head||document.body;if(!i)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return i.appendChild(n),n}(e)),i.addEventListener("load",(function(){window.Stripe?t(window.Stripe):n(new Error("Stripe.js not available"))})),i.addEventListener("error",(function(){n(new Error("Failed to load Stripe.js"))}))}catch(e){return void n(e)}else t(null)}))),Jt},Xt=function(e){var t="invalid load parameters; expected object of shape\n\n {advancedFraudSignals: boolean}\n\nbut received\n\n ".concat(JSON.stringify(e),"\n");if(null===e||"object"!==qt(e))throw new Error(t);if(1===Object.keys(e).length&&"boolean"==typeof e.advancedFraudSignals)return e;throw new Error(t)},$t=!1,Qt=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];$t=!0;var i=Date.now();return Zt(Kt).then((function(e){return function(e,t,n){if(null===e)return null;var i=e.apply(void 0,t);return function(e,t){e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",version:"1.54.2",startTime:t})}(i,n),i}(e,t,i)}))};Qt.setLoadParameters=function(e){if($t&&Kt){var t=Xt(e);if(Object.keys(t).reduce((function(t,n){var i;return t&&e[n]===(null===(i=Kt)||void 0===i?void 0:i[n])}),!0))return}if($t)throw new Error("You cannot change load parameters after calling loadStripe");Kt=Xt(e)},Vt.loadStripe=Qt;var en=Vt,tn="success",nn="fail",rn=function(e){function n(){return o(this,n),t(this,n,arguments)}return l(n,e),s(n,[{key:"initPaymentRequest",value:function(){return this.stripe.paymentRequest({country:this.meta.country.toUpperCase(),currency:this.meta.currency.toLowerCase(),total:{label:this.meta.amount_label,amount:Math.floor(100*this.meta.amount)},requestPayerName:!0===this.meta.request_payer_name,requestPayerEmail:!0===this.meta.request_payer_email,requestPayerPhone:!0===this.meta.request_payer_phone})}},{key:"createWalletButton",value:function(){return this.stripe.elements().create("paymentRequestButton",{paymentRequest:this.paymentRequest})}},{key:"load",value:function(e){var t=this;return en.loadStripe(this.publicKey).then((function(e){t.stripe=e,t.paymentRequest=t.initPaymentRequest()})).then((function(){return t.checkAvailability()})).then((function(n){return t.mount(e,n)})).then((function(){return t.setOnPaymentMethodSelected()}))}},{key:"checkAvailability",value:function(){var e=this;return this.paymentRequest.canMakePayment().then((function(t){if(t){var n=!e.meta.wallets||e.meta.wallets.includes(Ue.GOOGLE),i=!e.meta.wallets||e.meta.wallets.includes(Ue.APPLE);return{google_pay:n&&!t.applePay,apple_pay:i&&t.applePay,flypay:!1}}}))}},{key:"mount",value:function(e,t){if(!t||!t.apple_pay&&!t.google_pay)return this.eventEmitter.emit(Ft.UNAVAILABLE,null);this.createWalletButton().mount(e.getElement())}},{key:"setOnPaymentMethodSelected",value:function(){var e=this;this.paymentRequest.on("paymentmethod",(function(t){var n,i,r=t.paymentMethod,o=r.id,a=r.card,s=r.billing_details,u=s.name,c=s.address,l={payment_method_id:o,customer:{payer_name:t.payerName,payer_email:t.payerEmail,payer_phone:t.payerPhone,payment_source:{wallet_type:e.getWalletType(null===(n=null==a?void 0:a.wallet)||void 0===n?void 0:n.type),card_name:u,type:null===(i=null==a?void 0:a.wallet)||void 0===i?void 0:i.type,card_scheme:null==a?void 0:a.brand,card_number_last4:null==a?void 0:a.last4,expire_month:null==a?void 0:a.exp_month,expire_year:null==a?void 0:a.exp_year,address_line1:c.line1,address_line2:c.line2,address_city:c.city,address_postcode:c.postal_code,address_state:c.state,address_country:c.country}}};e.eventEmitter.emit(Ft.PAYMENT_METHOD_SELECTED,{data:l,onSuccess:function(){return t.complete(tn)},onError:function(e){return t.complete(nn)}})}))}},{key:"getWalletType",value:function(e){return e?"google_pay"===e?Ue.GOOGLE:Ue.APPLE:null}}])}(Bt),on=function(e){function n(e,i,r,a){var s;return o(this,n),(s=t(this,n,[e,i])).gatewayName=r,s.eventEmitter=a,s.latestShippingData={},s.onCancelPayment=function(e){return s.eventEmitter.emit(Ft.CHECKOUT_CLOSE)},s.onValidateMerchant=function(e){s.handleMerchantOnButtonClickEvent().then((function(){s.getMerchantSession().then((function(e){s.paymentSession.completeMerchantValidation(e)})).catch((function(e){console.error("Error fetching merchant session",e),s.paymentSession.abort()}))})).catch((function(e){console.error("Error while processing merchant callback",e),s.paymentSession.abort()}))},s.onPaymentAuthorized=function(e){var t,n=e.payment,i=n.token,r=n.billingContact,o=n.shippingContact;s.latestShippingData.shippingContact=o;var a=null===(t=s.selectedShippingOption)||void 0===t?void 0:t.type,u=[null==o?void 0:o.givenName,null==o?void 0:o.familyName].join(" ").trim();s.eventEmitter.emit(Ft.PAYMENT_METHOD_SELECTED,{data:c({customer:{payment_source:c(c({wallet_type:Ue.APPLE},u&&{card_name:u}),{type:i.paymentMethod.type,card_scheme:i.paymentMethod.network,address_line1:null==r?void 0:r.addressLines[0],address_line2:null==r?void 0:r.addressLines[1],address_country:null==r?void 0:r.countryCode,address_city:null==r?void 0:r.locality,address_postcode:null==r?void 0:r.postalCode,address_state:null==r?void 0:r.administrativeArea,ref_token:i.paymentData?JSON.stringify(i.paymentData):""})}},s.meta.request_shipping&&o&&{shipping:c(c(c({},a&&{method:a}),s.hasShippingOptions()&&{options:s.meta.shipping_options}),{address_line1:o.addressLines[0],address_line2:o.addressLines[1],address_country:o.countryCode,address_city:o.locality,address_postcode:o.postalCode,address_state:o.administrativeArea,contact:{first_name:o.givenName,last_name:o.familyName,email:o.emailAddress,phone:o.phoneNumber}})}),onSuccess:function(){return s.paymentSession.completePayment(ApplePaySession.STATUS_SUCCESS)},onError:function(){return s.paymentSession.completePayment(ApplePaySession.STATUS_FAILURE)}})},s.onShippingContactSelected=function(e){s.latestShippingData.shippingContact=e.shippingContact;var t=s.parseUpdateData(s.latestShippingData);return s.eventEmitter.emit(Ft.UPDATE,t),new Promise((function(e,t){s.latestShippingChangePromiseResolve=e,s.latestShippingChangePromiseReject=t}))},s.onShippingMethodSelected=function(e){var t,n;s.latestShippingData.shippingMethod=e.shippingMethod;var i={newTotal:{label:s.meta.amount_label||(null===(n=null===(t=s.getMetaRawDataInitialization())||void 0===t?void 0:t.total)||void 0===n?void 0:n.label),amount:s.meta.amount.toString(),type:"final"}};s.paymentSession.completeShippingMethodSelection(i)},s.parseUpdateData=function(e){var t,n,i,r,o,a,s,u;return c({shipping:{address_city:null===(t=null==e?void 0:e.shippingContact)||void 0===t?void 0:t.locality,address_state:null===(n=null==e?void 0:e.shippingContact)||void 0===n?void 0:n.administrativeArea,address_postcode:null===(i=null==e?void 0:e.shippingContact)||void 0===i?void 0:i.postalCode,address_country:null===(r=null==e?void 0:e.shippingContact)||void 0===r?void 0:r.countryCode}},(null==e?void 0:e.shippingMethod)&&{selected_shipping_option:{id:null===(o=null==e?void 0:e.shippingMethod)||void 0===o?void 0:o.identifier,label:null===(a=null==e?void 0:e.shippingMethod)||void 0===a?void 0:a.label,detail:null===(s=null==e?void 0:e.shippingMethod)||void 0===s?void 0:s.detail,amount:null===(u=null==e?void 0:e.shippingMethod)||void 0===u?void 0:u.amount}})},s.formatShippingOptions=function(e){return e.map((function(e){return{identifier:e.id,label:e.label,detail:(null==e?void 0:e.detail)||"",amount:e.amount}}))},s.eventEmitter=a,s}return l(n,e),s(n,[{key:"getGatewayName",value:function(){return this.gatewayName}},{key:"getMerchantId",value:function(){var e,t,n;return(null===(n=null===(t=null===(e=this.meta)||void 0===e?void 0:e.credentials)||void 0===t?void 0:t[Ue.APPLE])||void 0===n?void 0:n.merchant)||""}},{key:"getMetaStyles",value:function(){var e,t,n;if((null===(e=this.meta)||void 0===e?void 0:e.style)&&"object"===r(null===(t=this.meta)||void 0===t?void 0:t.style)){var i=JSON.parse(JSON.stringify(null===(n=this.meta)||void 0===n?void 0:n.style));return"google"in i&&(null==i||delete i.google),"apple"in i?null==i?void 0:i.apple:i}return null}},{key:"getMetaRawDataInitialization",value:function(){var e,t,n,i;if((null===(e=this.meta)||void 0===e?void 0:e.raw_data_initialization)&&(null===(t=this.meta)||void 0===t?void 0:t.raw_data_initialization)&&"object"===r(null===(n=this.meta)||void 0===n?void 0:n.raw_data_initialization)){var o=JSON.parse(JSON.stringify(null===(i=this.meta)||void 0===i?void 0:i.raw_data_initialization));return"google"in o&&(null==o||delete o.google),"apple"in o?null==o?void 0:o.apple:o}return null}},{key:"isShippingRequired",value:function(){var e;return null===(e=this.meta)||void 0===e?void 0:e.request_shipping}},{key:"hasShippingOptions",value:function(){var e,t;return(null===(e=this.meta)||void 0===e?void 0:e.request_shipping)&&!!(null===(t=this.meta)||void 0===t?void 0:t.shipping_options)}},{key:"load",value:function(e){var t=this;if(window.Promise)return this.checkAvailability().then((function(n){var i;n?(t.isShippingRequired()&&t.hasShippingOptions()&&(t.selectedShippingOption=null===(i=t.meta)||void 0===i?void 0:i.shipping_options[0],t.latestShippingData.shippingMethod=t.formatShippingOptions([t.selectedShippingOption])[0]),t.mount(e)):t.eventEmitter.emit(Ft.UNAVAILABLE,{wallet:Ue.APPLE})})).catch((function(e){return console.error("Error checking ApplePay availability",e)}));this.eventEmitter.emit(Ft.UNAVAILABLE,{wallet:Ue.APPLE})}},{key:"update",value:function(e){var t,n,i;if(this.latestShippingChangePromiseResolve&&this.latestShippingChangePromiseReject){if(!e.success||!e.body)return this.latestShippingChangePromiseReject();var r=null===(t=null==e?void 0:e.body)||void 0===t?void 0:t.amount,o=null===(n=null==e?void 0:e.body)||void 0===n?void 0:n.shipping_options;r&&(this.meta.amount=r),o&&(this.meta.shipping_options=o,this.selectedShippingOption=o?o[0]:void 0);var a=c({newTotal:{label:null===(i=this.meta)||void 0===i?void 0:i.amount_label,amount:this.meta.amount.toString(),type:"final"}},this.isShippingRequired()&&this.hasShippingOptions()&&{newShippingMethods:this.formatShippingOptions(this.meta.shipping_options)});this.paymentSession.completeShippingContactSelection(a),this.latestShippingChangePromiseResolve({})}}},{key:"checkAvailability",value:function(){var e=this;return new Promise((function(t,n){window.ApplePaySession&&ApplePaySession||t(!1),ApplePaySession.canMakePaymentsWithActiveCard(e.getMerchantId()).then((function(e){return t(e)})).catch((function(e){return t(!1)}))}))}},{key:"mount",value:function(e){var t=this,n=document.createElement("style");n.innerHTML=this.createButtonStyle(),document.head.appendChild(n);var i=document.createElement("div");i.onclick=function(){return t.onApplePayButtonClicked()},i.classList.add("paydock-apple-container","apple-pay-button","apple-pay-button-black"),i.setAttribute("tabindex","0"),i.setAttribute("role","button"),e.getElement().appendChild(i)}},{key:"onApplePayButtonClicked",value:function(){this.paymentSession=new ApplePaySession(3,this.createRequest()),this.paymentSession.onvalidatemerchant=this.onValidateMerchant,this.paymentSession.onpaymentauthorized=this.onPaymentAuthorized,this.paymentSession.oncancel=this.onCancelPayment,this.paymentSession.onshippingcontactselected=this.onShippingContactSelected,this.paymentSession.onshippingmethodselected=this.onShippingMethodSelected,this.paymentSession.begin()}},{key:"createRequest",value:function(){var e,t=this.getMetaRawDataInitialization();return t&&"object"===r(t)&&("object"===r(t.total)?t.total.amount=this.meta.amount.toString():t.total={label:(null===(e=this.meta)||void 0===e?void 0:e.amount_label)||"",amount:this.meta.amount.toString()},this.isShippingRequired()&&this.hasShippingOptions()&&(t.shippingMethods=this.formatShippingOptions(this.meta.shipping_options))),t||c(c(c({countryCode:this.meta.country.toUpperCase(),currencyCode:this.meta.currency.toUpperCase(),merchantCapabilities:["supports3DS","supportsCredit","supportsDebit"],supportedNetworks:["visa","masterCard","amex","discover"]},this.meta.show_billing_address&&{requiredBillingContactFields:["name","postalAddress"]}),this.isShippingRequired()&&c({requiredShippingContactFields:["postalAddress","name","phone","email"]},this.hasShippingOptions()&&{shippingMethods:this.formatShippingOptions(this.meta.shipping_options)})),{total:{label:this.meta.amount_label,amount:this.meta.amount.toString(),type:"final"}})}},{key:"getMerchantSession",value:function(){var e=this;return new Promise((function(t,n){return e.eventEmitter.emit(Ft.CALLBACK,{data:c({request_type:"CREATE_SESSION",wallet_type:Ue.APPLE,session_id:window.location.hostname},e.isShippingRequired()&&{request_shipping:e.meta.request_shipping}),onSuccess:function(e){return t(e)},onError:function(e){return n(e)}})}))}},{key:"handleMerchantOnButtonClickEvent",value:function(){var e=this;return new Promise((function(t,n){var i;e.eventEmitter.emit(Ft.BUTTON_CLICK,{attachResult:function(e){i=e}}),i instanceof Promise?i.then(t).catch(n):!1===i?n():t()}))}},{key:"createButtonStyle",value:function(){var e,t;return"\n .paydock-apple-container {\n width: 100%;\n height: 40px;\n }\n\n @supports (-webkit-appearance: -apple-pay-button) {\n .apple-pay-button {\n display: inline-block;\n -webkit-appearance: -apple-pay-button;\n -apple-pay-button-type: ".concat((null===(e=this.getMetaStyles())||void 0===e?void 0:e.button_type)||"plain","\n }\n .apple-pay-button-black {\n -apple-pay-button-style: black;\n }\n .apple-pay-button-white {\n -apple-pay-button-style: white;\n }\n .apple-pay-button-white-with-line {\n -apple-pay-button-style: white-outline;\n }\n }\n\n @supports not (-webkit-appearance: -apple-pay-button) {\n .apple-pay-button {\n display: inline-block;\n background-size: 100% 60%;\n background-repeat: no-repeat;\n background-position: 50% 50%;\n border-radius: 5px;\n padding: 0px;\n box-sizing: border-box;\n min-width: 200px;\n min-height: 32px;\n max-height: 64px;\n -apple-pay-button-type: ").concat((null===(t=this.getMetaStyles())||void 0===t?void 0:t.button_type)||"plain","\n }\n .apple-pay-button-black {\n background-image: -webkit-named-image(apple-pay-logo-white);\n background-color: black;\n }\n .apple-pay-button-white {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n }\n .apple-pay-button-white-with-line {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n border: .5px solid black;\n }\n }\n ")}}])}(Bt),an=function(e){function n(e,i,r,a){var s;return o(this,n),(s=t(this,n,[e,i])).gatewayName=r,s.eventEmitter=a,s.processingButtonClick=!1,s.parseUpdateData=function(e){var t,n,i,r,o,a,u=null===(n=null===(t=s.meta)||void 0===t?void 0:t.shipping_options)||void 0===n?void 0:n.find((function(t){var n;return t.id===(null===(n=null==e?void 0:e.shippingOptionData)||void 0===n?void 0:n.id)}));return c({shipping:{address_city:null===(i=e.shippingAddress)||void 0===i?void 0:i.locality,address_state:null===(r=e.shippingAddress)||void 0===r?void 0:r.administrativeArea,address_postcode:null===(o=null==e?void 0:e.shippingAddress)||void 0===o?void 0:o.postalCode,address_country:null===(a=null==e?void 0:e.shippingAddress)||void 0===a?void 0:a.countryCode}},u&&{selected_shipping_option:{id:null==u?void 0:u.id,label:null==u?void 0:u.label,detail:null==u?void 0:u.detail,type:null==u?void 0:u.type}})},s.formatShippingOptions=function(e){return e.map((function(e){return{id:e.id,label:e.label,description:(null==e?void 0:e.detail)||""}}))},s.eventEmitter=a,s}return l(n,e),s(n,[{key:"getGatewayName",value:function(){return this.gatewayName}},{key:"getMerchantId",value:function(){var e,t,n;return null===(n=null===(t=null===(e=this.meta)||void 0===e?void 0:e.credentials)||void 0===t?void 0:t[Ue.GOOGLE])||void 0===n?void 0:n.merchant}},{key:"getMetaStyles",value:function(){var e,t,n,i;return"object"===r(null===(e=this.meta)||void 0===e?void 0:e.style)&&"google"in(null===(t=this.meta)||void 0===t?void 0:t.style)?null===(i=null===(n=this.meta)||void 0===n?void 0:n.style)||void 0===i?void 0:i.google:null}},{key:"getMetaRawDataInitialization",value:function(){var e,t,n,i,o;return(null===(e=this.meta)||void 0===e?void 0:e.raw_data_initialization)&&"object"===r(null===(t=this.meta)||void 0===t?void 0:t.raw_data_initialization)&&"google"in(null===(n=this.meta)||void 0===n?void 0:n.raw_data_initialization)?null===(o=null===(i=this.meta)||void 0===i?void 0:i.raw_data_initialization)||void 0===o?void 0:o.google:null}},{key:"isShippingRequired",value:function(){return!!this.meta.request_shipping}},{key:"hasShippingOptions",value:function(){return this.meta.request_shipping&&!!this.meta.shipping_options}},{key:"load",value:function(e){var t=this;if(window.Promise)return new Promise((function(n,i){var r=document.createElement("script");r.type="text/javascript",r.src="https://pay.google.com/gp/p/js/pay.js",r.async=!0,r.onload=function(){var r,o,a,s;if(!window.google)return t.eventEmitter.emit(Ft.UNAVAILABLE,{wallet:Ue.GOOGLE}),void i();t.isShippingRequired()&&t.hasShippingOptions()&&(t.selectedShippingOption=null===(r=t.meta)||void 0===r?void 0:r.shipping_options[0]),t.paymentsClient=new google.payments.api.PaymentsClient(c({merchantInfo:c(c({},(null===(o=t.meta)||void 0===o?void 0:o.merchant_name)?{merchantName:null===(a=t.meta)||void 0===a?void 0:a.merchant_name}:{}),{merchantId:t.getMerchantId()}),paymentDataCallbacks:c({onPaymentAuthorized:function(e){return t.onPaymentAuthorized(e)}},t.isShippingRequired()&&{onPaymentDataChanged:function(e){return t.onPaymentDataChanged(e)}})},"live"===(null===(s=t.meta)||void 0===s?void 0:s.gateway_mode)?{environment:"PRODUCTION"}:{environment:"TEST"})),t.checkAvailability().then((function(r){if(!r)return t.eventEmitter.emit(Ft.UNAVAILABLE,{wallet:Ue.GOOGLE}),void i();t.mount(e),n()}))},document.head.appendChild(r)}));this.eventEmitter.emit(Ft.UNAVAILABLE,{wallet:Ue.GOOGLE})}},{key:"update",value:function(e){var t,n,i,r;if(this.latestShippingChangePromiseResolve&&this.latestShippingChangePromiseReject){if(!e.success)return this.latestShippingChangePromiseReject();var o=(null===(t=null==e?void 0:e.body)||void 0===t?void 0:t.amount)||this.meta.amount,a=null===(n=null==e?void 0:e.body)||void 0===n?void 0:n.shipping_options;o&&(this.meta.amount=o),a&&(this.meta.shipping_options=a,this.selectedShippingOption=a?a[0]:void 0);var s=c({newTransactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:this.meta.amount_label,totalPrice:null===(i=this.meta.amount)||void 0===i?void 0:i.toString(),currencyCode:this.meta.currency.toUpperCase(),countryCode:this.meta.country.toUpperCase()}},this.isShippingRequired()&&this.hasShippingOptions()&&a&&{newShippingOptionParameters:{defaultSelectedOptionId:null===(r=this.selectedShippingOption)||void 0===r?void 0:r.id,shippingOptions:this.formatShippingOptions(this.meta.shipping_options)}});this.latestShippingChangePromiseResolve(s)}}},{key:"checkAvailability",value:function(){return this.paymentsClient.isReadyToPay(this.createRequest()).then((function(e){return!!e.result})).catch((function(e){return console.error("Error checking GooglePay availability",e),!1}))}},{key:"mount",value:function(e){var t,n,i,r=this;e.getElement().appendChild(this.paymentsClient.createButton({onClick:function(){return r.onGooglePayButtonClicked()},buttonType:(null===(t=this.getMetaStyles())||void 0===t?void 0:t.button_type)||"pay",buttonSizeMode:(null===(n=this.getMetaStyles())||void 0===n?void 0:n.button_size_mode)||"fill",buttonColor:(null===(i=this.getMetaStyles())||void 0===i?void 0:i.button_color)||"default"}))}},{key:"onGooglePayButtonClicked",value:function(){var e=this;this.processingButtonClick||(this.processingButtonClick=!0,this.handleMerchantOnButtonClickEvent().then((function(){e.loadPaymentData().finally((function(){e.processingButtonClick=!1}))})).catch((function(t){e.processingButtonClick=!1,console.error("Error while processing merchant callback",t)})))}},{key:"handleMerchantOnButtonClickEvent",value:function(){var e=this;return new Promise((function(t,n){var i;e.eventEmitter.emit(Ft.BUTTON_CLICK,{attachResult:function(e){i=e}}),i instanceof Promise?i.then(t).catch(n):!1===i?n():t()}))}},{key:"loadPaymentData",value:function(){var e=this;return this.paymentsClient.loadPaymentData(this.createPaymentDataRequest()).catch((function(t){throw e.eventEmitter.emit(Ft.CHECKOUT_CLOSE),console.error("Error while loading payment data",t),t}))}},{key:"onPaymentAuthorized",value:function(e){var t,n,i,r,o,a,s,u,l,d,h,p,f,v,m,y=this,g=null===(i=null===(n=null===(t=e.paymentMethodData)||void 0===t?void 0:t.info)||void 0===n?void 0:n.billingAddress)||void 0===i?void 0:i.address1,k=null===(a=null===(o=null===(r=e.paymentMethodData)||void 0===r?void 0:r.info)||void 0===o?void 0:o.billingAddress)||void 0===a?void 0:a.address2,E=null===(s=null==e?void 0:e.shippingAddress)||void 0===s?void 0:s.address1,_=null===(u=null==e?void 0:e.shippingAddress)||void 0===u?void 0:u.address2,b=null===(l=this.selectedShippingOption)||void 0===l?void 0:l.type,w=null===(d=null==e?void 0:e.shippingAddress)||void 0===d?void 0:d.countryCode,C=null===(h=null==e?void 0:e.shippingAddress)||void 0===h?void 0:h.locality,S=null===(p=null==e?void 0:e.shippingAddress)||void 0===p?void 0:p.postalCode,T=null===(f=null==e?void 0:e.shippingAddress)||void 0===f?void 0:f.administrativeArea,O=null===(v=null==e?void 0:e.shippingAddress)||void 0===v?void 0:v.name,A=null==e?void 0:e.email,P=null===(m=null==e?void 0:e.shippingAddress)||void 0===m?void 0:m.phoneNumber;return new Promise((function(t){var n,i,r,o,a,s,u,l,d,h,p,f,v,m;return y.eventEmitter.emit(Ft.PAYMENT_METHOD_SELECTED,{data:c({customer:{payment_source:c(c(c(c({wallet_type:Ue.GOOGLE,type:e.paymentMethodData.type,card_scheme:null===(i=null===(n=e.paymentMethodData)||void 0===n?void 0:n.info)||void 0===i?void 0:i.cardNetwork},g&&{address_line1:g}),k&&{address_line2:k}),k&&{address_line2:k}),{address_country:null===(a=null===(o=null===(r=e.paymentMethodData)||void 0===r?void 0:r.info)||void 0===o?void 0:o.billingAddress)||void 0===a?void 0:a.countryCode,address_city:null===(l=null===(u=null===(s=e.paymentMethodData)||void 0===s?void 0:s.info)||void 0===u?void 0:u.billingAddress)||void 0===l?void 0:l.locality,address_postcode:null===(p=null===(h=null===(d=e.paymentMethodData)||void 0===d?void 0:d.info)||void 0===h?void 0:h.billingAddress)||void 0===p?void 0:p.postalCode,address_state:null===(m=null===(v=null===(f=e.paymentMethodData)||void 0===f?void 0:f.info)||void 0===v?void 0:v.billingAddress)||void 0===m?void 0:m.administrativeArea,ref_token:e.paymentMethodData.tokenizationData.token})}},y.isShippingRequired()&&{shipping:c(c(c(c(c(c(c(c(c({},b&&{method:b}),y.hasShippingOptions()&&{options:y.meta.shipping_options}),E&&{address_line1:E}),_&&{address_line2:_}),w&&{address_country:w}),C&&{address_city:C}),S&&{address_postcode:S}),T&&{address_state:T}),{contact:c(c(c({},O&&{first_name:O}),A&&{email:A}),P&&{phone:P})})}),onSuccess:function(){return t({transactionState:"SUCCESS"})},onError:function(e){return t({transactionState:"ERROR",error:{intent:"PAYMENT_AUTHORIZATION",message:(null==e?void 0:e.message)||"Error processing payment",reason:"PAYMENT_DATA_INVALID"}})}})}))}},{key:"onPaymentDataChanged",value:function(e){var t=this;if(this.isShippingRequired()){var n=this.parseUpdateData(e),i=new Promise((function(e,n){t.latestShippingChangePromiseResolve=e,t.latestShippingChangePromiseReject=n}));return this.eventEmitter.emit(Ft.UPDATE,n),i}}},{key:"createRequest",value:function(){var e="Apple Safari"===k.getBrowserName();return{apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:[this.createCardData()],existingPaymentMethodRequired:!e}}},{key:"createPaymentDataRequest",value:function(){var e,t,n,i;this.isShippingRequired()&&this.hasShippingOptions()&&(this.selectedShippingOption=null===(e=this.meta)||void 0===e?void 0:e.shipping_options[0]);var r=this.getMerchantId();return c({apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:[c(c({},this.createCardData()),{tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"paydock",gatewayMerchantId:r}}})],transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:this.meta.amount_label,totalPrice:this.meta.amount.toString(),currencyCode:this.meta.currency.toUpperCase(),countryCode:this.meta.country.toUpperCase()},merchantInfo:c(c({},(null===(t=this.meta)||void 0===t?void 0:t.merchant_name)?{merchantName:null===(n=this.meta)||void 0===n?void 0:n.merchant_name}:{}),{merchantId:r}),callbackIntents:["PAYMENT_AUTHORIZATION"].concat(v(this.isShippingRequired()?["SHIPPING_ADDRESS"]:[]),v(this.hasShippingOptions()?["SHIPPING_OPTION"]:[]))},this.isShippingRequired()&&c({shippingAddressRequired:!0},this.hasShippingOptions()&&{shippingOptionRequired:!0,shippingOptionParameters:{defaultSelectedOptionId:null===(i=this.selectedShippingOption)||void 0===i?void 0:i.id,shippingOptions:this.formatShippingOptions(this.meta.shipping_options)}}))}},{key:"createCardData",value:function(){return this.getMetaRawDataInitialization()||{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:["AMEX","DISCOVER","INTERAC","JCB","MASTERCARD","VISA"],billingAddressRequired:!!this.meta.show_billing_address}}}}])}(Bt),sn=function(e){function n(){return o(this,n),t(this,n,arguments)}return l(n,e),s(n,[{key:"initializeChildWallets",value:function(){var e,t,n,i,r,o;this.childWallets=[];var a=!!(null===(n=null===(t=null===(e=this.meta)||void 0===e?void 0:e.credentials)||void 0===t?void 0:t.apple)||void 0===n?void 0:n.merchant),s=!!(null===(o=null===(r=null===(i=this.meta)||void 0===i?void 0:i.credentials)||void 0===r?void 0:r.google)||void 0===o?void 0:o.merchant);!a||this.meta.wallets&&!this.meta.wallets.includes(Ue.APPLE)||this.childWallets.push(new on(this.publicKey,this.meta,this.getGatewayName(),this.eventEmitter)),!s||this.meta.wallets&&!this.meta.wallets.includes(Ue.GOOGLE)||this.childWallets.push(new an(this.publicKey,this.meta,this.getGatewayName(),this.eventEmitter))}},{key:"getGatewayName",value:function(){return Ie.MASTERCARD}},{key:"setEnv",value:function(e){return this.childWallets.forEach((function(t){return t.setEnv(e)})),this}},{key:"update",value:function(e){this.childWallets.forEach((function(t){return t.update(e)}))}}])}(Bt),un=function(e){function n(e,i){var r;return o(this,n),(r=t(this,n,[e,i])).token=e,r.storageDispatcher=new ht("afterpay.wallet.paydock"),r}return l(n,e),s(n,[{key:"load",value:function(e){var t=this;this.storageDispatcher.create((function(){return t.mount(e)}))}},{key:"setEnv",value:function(e){return p(d(n.prototype),"setEnv",this).call(this,e),this.storageDispatcher.setEnv(e),this}},{key:"mount",value:function(e){var t,n,i,o,a=this,s={};(null===(t=this.meta)||void 0===t?void 0:t.style)&&"object"===r(null===(n=this.meta)||void 0===n?void 0:n.style)&&(s=JSON.parse(JSON.stringify((null===(i=this.meta)||void 0===i?void 0:i.style.afterpay)||(null===(o=this.meta)||void 0===o?void 0:o.style))));var u=this.getButton(s);u.onclick=function(){return a.onAfterPayButtonClicked()};var c=this.getButtonStyle(s);e.getElement().appendChild(u),e.getElement().appendChild(c)}},{key:"onAfterPayButtonClicked",value:function(){var e,t,n=this,i=document.createElement("script"),r=null===(e=this.meta)||void 0===e?void 0:e.country;i.type="text/javascript",i.src="live"===(null===(t=this.meta)||void 0===t?void 0:t.gateway_mode)?"https://portal.afterpay.com/afterpay.js":"https://portal.sandbox.afterpay.com/afterpay.js",i.async=!0,i.defer=!0,i.onload=function(){window.AfterPay.initialize({countryCode:r}),n.storageDispatcher.push({intent:at.WIDGET_SESSION,data:{token:n.token}},{onSuccess:function(){n.getCheckoutSession().then((function(e){window.AfterPay.redirect({token:e.ref_token})})).catch((function(e){window.AfterPay.close(),n.eventEmitter.emit(Ft.UNAVAILABLE,{err:e})}))},onError:function(){console.error("Error initializing Afterpay wallet"),window.AfterPay.close(),n.eventEmitter.emit(Ft.UNAVAILABLE,{})}})},document.head.appendChild(i)}},{key:"getCheckoutSession",value:function(){var e=this;return new Promise((function(t,n){return e.eventEmitter.emit(Ft.CALLBACK,{data:{request_type:"CREATE_SESSION",wallet_type:Ue.AFTERPAY},onSuccess:function(e){t(e)},onError:function(e){n(e)}})}))}},{key:"getButton",value:function(e){var t=document.createElement("button");return t.classList.add("afterpay-checkout-btn"),t.setAttribute("type","button"),t.innerHTML='\n <div class="afterpay-checkout-btn__wrapper">\n <svg viewBox="0 0 390 94"\n height="'.concat(this.getHeight(e),'"\n xmlns="http://www.w3.org/2000/svg">\n <g fill="currentColor">\n <path\n d="M388.6 21.4l-34.8 71.8h-14.4l13-26.8-20.5-45h14.8l13.2 30.1 14.3-30.1zM41 46.9c0-8.6-6.2-14.6-13.9-14.6s-13.9 6.1-13.9 14.6c0 8.4 6.2 14.6 13.9 14.6 7.6 0 13.9-6.1 13.9-14.6m.1 25.5v-6.6c-3.8 4.6-9.4 7.4-16.1 7.4C11 73.2.4 62 .4 46.9c0-15 11-26.4 24.9-26.4 6.5 0 12 2.9 15.8 7.3v-6.4h12.5v51H41.1zM114.6 61.1c-4.4 0-5.6-1.6-5.6-5.9V32.5h8.1V21.4H109V8.9H96.1v12.4H79.5v-5.1c0-4.3 1.6-5.9 6.1-5.9h2.8V.4h-6.2C71.6.4 66.6 3.9 66.6 14.5v6.8h-7.1v11.1h7.1v39.9h12.9V32.5h16.6v25c0 10.4 4 14.9 14.4 14.9h6.6V61.1h-2.5zM160.7 42.3c-.9-6.6-6.3-10.6-12.6-10.6s-11.5 3.9-12.9 10.6h25.5zm-25.6 7.9c.9 7.5 6.3 11.8 13.2 11.8 5.4 0 9.6-2.6 12-6.6h13.2c-3.1 10.8-12.7 17.7-25.5 17.7-15.4 0-26.2-10.8-26.2-26.2 0-15.4 11.4-26.5 26.5-26.5 15.2 0 26.2 11.2 26.2 26.5 0 1.1-.1 2.2-.3 3.3h-39.1zM256.2 46.9c0-8.3-6.2-14.6-13.9-14.6s-13.9 6.1-13.9 14.6c0 8.4 6.2 14.6 13.9 14.6 7.6 0 13.9-6.4 13.9-14.6m-40.4 46.3V21.4h12.5V28c3.8-4.7 9.4-7.5 16.1-7.5 13.8 0 24.6 11.3 24.6 26.3s-11 26.4-24.9 26.4c-6.4 0-11.7-2.6-15.4-6.8v26.8h-12.9zM314.2 46.9c0-8.6-6.2-14.6-13.9-14.6-7.6 0-13.9 6.1-13.9 14.6 0 8.4 6.2 14.6 13.9 14.6s13.9-6.1 13.9-14.6m.1 25.5v-6.6c-3.8 4.6-9.4 7.4-16.1 7.4-14 0-24.6-11.2-24.6-26.3 0-15 11-26.4 24.9-26.4 6.5 0 12 2.9 15.8 7.3v-6.4h12.5v51h-12.5zM193.2 26.4s3.2-5.9 11-5.9c3.3 0 5.5 1.2 5.5 1.2v13s-4.7-2.9-9.1-2.3c-4.3.6-7.1 4.6-7.1 9.9v30.2h-13v-51H193v4.9h.2z" />\n </g>\n </svg>\n <svg viewBox="0 0 107 96"\n height="').concat(this.getHeight(e),'"\n xmlns="http://www.w3.org/2000/svg">\n <path\n d="M99 19.5L84.2 11l-15-8.6c-10-5.7-22.4 1.5-22.4 13v1.9c0 1.1.6 2 1.5 2.6l7 4c1.9 1.1 4.4-.3 4.4-2.5v-4.6c0-2.3 2.5-3.7 4.4-2.6l13.8 7.9L91.6 30c2 1.1 2 4 0 5.1L77.9 43l-13.8 7.9c-2 1.1-4.4-.3-4.4-2.6V46c0-11.5-12.4-18.7-22.4-13l-15 8.6-14.8 8.5c-10 5.7-10 20.2 0 26l14.8 8.5 15 8.6c10 5.7 22.4-1.5 22.4-13v-1.9c0-1.1-.6-2-1.5-2.6l-7-4c-1.9-1.1-4.4.3-4.4 2.5v4.6c0 2.3-2.5 3.7-4.4 2.6l-13.8-7.9-13.7-7.9c-2-1.1-2-4 0-5.1l13.7-7.9 13.8-7.9c2-1.1 4.4.3 4.4 2.6v2.3c0 11.5 12.4 18.7 22.4 13l15-8.6L99 45.5c10.1-5.8 10.1-20.2 0-26"\n fill="currentColor" />\n </svg>\n </div>\n '),t}},{key:"getButtonStyle",value:function(e){var t=document.createElement("style"),n=this.generateButtonColor(e.button_type);return t.innerText="\n .afterpay-checkout-btn {\n outline: none;\n border: none;\n border-radius: ".concat(this.getHeight(e),";\n padding: 0;\n margin: 0;\n transition: all 300ms;\n cursor: pointer;\n }\n\n .afterpay-checkout-btn:active {\n opacity: 0.7;\n }\n\n .afterpay-checkout-btn__wrapper {\n display: flex;\n align-items: center;\n padding: 10px 20px;\n color: ").concat(n.color,";\n background-color: ").concat(n.background,";\n border-radius: ").concat(this.getHeight(e),";\n }\n "),t}},{key:"generateButtonColor",value:function(e){switch(e){case"black":return{color:"#B2FCE3",background:"#000"};case"mint":return{color:"#000",background:"#B2FCE3"};default:return{color:"#fff",background:"#000"}}}},{key:"getHeight",value:function(e){return e.height?Number.isNaN(Number(e.height))?e.height:"".concat(e.height,"px"):"40px"}}])}(Bt);var cn=class{DEFAULT_WIDTH=450;DEFAULT_HEIGHT=750;DEFAULT_FEATURES={resizable:"no"};auth;callback;error;frame;isCheckoutOpen;onMessage;url;orderId;accessToken;refreshToken;clientId;onCheckoutClosed;rootUrl;targetOrigin;title;windowFeatures;windowObserver;constructor({auth:e,url:t,clientId:n,mode:i,orderId:r,onCheckoutClosed:o,onError:a,onTokensChanged:s,onPaymentSuccess:u,onPaymentError:c,title:l,windowFeatures:d}){this.callback={ERROR({error:e,orderId:t}){a?.({error:e,orderId:t})},PAYMENT_ERROR({error:e,orderId:t}){c?.({error:e,orderId:t})},PAYMENT_SUCCESS({orderId:e}){u?.({orderId:e})},TOKENS_CHANGED({accessToken:e,refreshToken:t}){s?.({accessToken:e,refreshToken:t})}},this.auth=e,this.isCheckoutOpen=!1,this.error=void 0,this.frame=void 0,this.onMessage=e=>{const{data:n,origin:i}=e;i===t&&(!0===n?.isDomReady&&this.postMessage(),n?.isPaymentSuccessful&&this.callback.PAYMENT_SUCCESS({orderId:n.orderId}),!n?.isPaymentSuccessful&&n?.error&&this.callback.PAYMENT_ERROR({orderId:n.orderId,error:n.error}),!n?.paymentFlowState&&n?.error&&this.callback.ERROR({orderId:n.orderId,error:n.error}),n?.accessToken&&n?.refreshToken&&this.callback.TOKENS_CHANGED({accessToken:n.accessToken,refreshToken:n.refreshToken}))};const h=i||"default";this.rootUrl=t,this.targetOrigin=window.location.href.replace(/\/$/,""),this.url=`${t}?orderId=${r}&merchantUrl=${encodeURIComponent(this.targetOrigin)}&mode=${h}`,this.orderId=r,this.clientId=n,this.onCheckoutClosed=o,this.title=l,this.windowFeatures=d,this.windowObserver=void 0}get isWindowObserverOpen(){return!!this.windowObserver}open=()=>{this.isCheckoutOpen?this.frame?.focus():(this.frame=window.open(this.url,this.title,this.getFeatures()),this.isCheckoutOpen=!0,this.startWindowObserver())};close=()=>{this.frame=void 0,this.isCheckoutOpen=!1,this.stopWindowObserver()};listenMessage=()=>{this.onMessage&&window.addEventListener("message",this.onMessage,!1)};postMessage=()=>{this.frame&&this.rootUrl&&this.frame.postMessage({auth:{...this.auth}},this.rootUrl)};getFeatures(){const e=this.windowFeatures?.width||this.DEFAULT_WIDTH,t=this.windowFeatures?.height||this.DEFAULT_HEIGHT,n={...this.DEFAULT_FEATURES,...this.windowFeatures};return function(e,t="="){return Object.keys(e).length?Object.entries(e).reduce(((e,[n,i])=>[...e,`${n}${t}${i}`]),[]).join(","):""}({...this.getCenteredPosition(e,t),...n,width:e,height:t})}getCenteredPosition(e,t){return{left:screen.width/2-e/2,top:screen.height/2-t/2}}startWindowObserver(){this.isWindowObserverOpen||(this.windowObserver=setInterval((()=>{this.frame?.closed&&(this.close(),this.onCheckoutClosed?.({orderId:this.orderId}),this.onMessage&&window.removeEventListener("message",this.onMessage))}),300))}stopWindowObserver(){clearInterval(this.windowObserver)}};function ln(e){return hn("paydock-flypay-button",e)}function dn(e){return"flypay-v2-checkout-btn__wrapper__".concat(e)}function hn(e,t){return'\n <div id="'.concat(t,'-loading-overlay"></div>\n <div class="').concat(e,'" tabindex="0">\n <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 125.2 21" data-name="pay-with-flypay"\n style="grid-area: center; width: 100%; height: 100%"\n fill="none"\n >\n <path\n fill="#fff"\n d="M89 .5a.5.5 0 0 1 .5-.5h15a.5.5 0 0 1 0 1h-15a.5.5 0 0 1-.5-.5ZM98 22.5a.5.5 0 0 1 .5-.5h15a.5.5 0 0 1 0 1h-15a.5.5 0 0 1-.5-.5ZM87 3.5a.5.5 0 0 1 .5-.5H121c.758 0 1.42.031 1.974.133.553.102 1.044.284 1.421.618.78.694.849 1.829.598 3.331-.258 1.552-1.025 3.843-1.711 5.715a100.003 100.003 0 0 1-1.211 3.128l-.081.198-.021.051v.001c-.531 1.583-1.345 2.557-2.269 3.126-.92.566-1.898.699-2.7.699H96.5a.5.5 0 1 1 0-1v.5-.5H117c.698 0 1.47-.117 2.175-.55.697-.43 1.382-1.2 1.851-2.608l.005-.017.008-.018.006-.016.021-.05.079-.194a94.823 94.823 0 0 0 1.198-3.094c.689-1.878 1.422-4.087 1.664-5.535.249-1.498.068-2.113-.277-2.42-.186-.165-.476-.296-.938-.381C122.33 4.03 121.742 4 121 4H87.5a.5.5 0 0 1-.5-.5ZM76.512 9.512h3.157V7.34h-3.157v-.01h-.02c.01-1.196.841-2.17 2.52-2.17H81V3h-1.988C75.547 3 74.008 4.936 74 7.326V16h2.512V9.512ZM82 3.55 84.987 3H85v13h-3V3.55Z"\n />\n <path\n fill="#fff"\n d="M91.592 15.365a4.557 4.557 0 0 1-1.595.33c-2.391 0-4-1.68-3.997-4.092V7.546l2.41-.543V11.6c0 1.118.536 1.738 1.59 1.738 1.055 0 1.592-.622 1.592-1.738V7.543L94 7v9.855C94 19.41 92.497 21 90.073 21h-.596v-2.359h.59c.71 0 1.525-.641 1.525-1.786v-1.49Z"\n />\n <path\n fill="#fff"\n fill-rule="evenodd"\n d="M2.54 11.6h2.598c1.356 0 2.399-.299 3.129-.896.731-.598 1.096-1.62 1.096-3.063 0-1.323-.365-2.3-1.096-2.93-.73-.631-1.71-.947-2.938-.947H0V16h2.54v-4.4Zm4.291-3.943c0 .637-.166 1.102-.498 1.395-.337.293-.808.44-1.411.44H2.54V5.889h2.382c.603 0 1.071.136 1.403.407.337.271.506.725.506 1.361ZM14.651 6.736c-1.522 0-2.596.398-3.221 1.195-.393.51-.614 1.16-.664 1.95h2.283c.055-.348.166-.624.332-.83.232-.276.628-.414 1.187-.414.498 0 .874.072 1.128.216.261.138.391.392.391.763 0 .305-.169.529-.507.673-.188.083-.501.152-.938.207l-.805.1c-.913.116-1.605.31-2.075.58-.858.499-1.287 1.304-1.287 2.416 0 .858.266 1.522.797 1.993.537.464 1.215.697 2.034.697.642 0 1.217-.147 1.726-.44a4.83 4.83 0 0 0 1.129-.905c.017.205.039.388.067.548.027.16.077.332.149.515h2.573v-.349a.843.843 0 0 1-.348-.274c-.078-.11-.125-.32-.141-.63-.011-.41-.017-.759-.017-1.047V9.55c0-1.09-.385-1.832-1.154-2.225-.769-.393-1.649-.59-2.639-.59Zm-.648 7.828c-.321 0-.592-.092-.813-.274-.227-.177-.341-.468-.341-.872 0-.454.183-.788.548-1.004.216-.128.573-.236 1.071-.324l.531-.1c.266-.05.473-.102.623-.157.155-.061.307-.139.456-.233v.88c-.016.791-.24 1.336-.672 1.635a2.39 2.39 0 0 1-1.403.449Z"\n clip-rule="evenodd"\n />\n <path\n fill="#fff"\n d="m26.097 6.952-1.867 6.674-1.976-6.674h-2.631l3.32 9.446c.022.066-.028.25-.149.548-.117.299-.244.495-.382.59-.144.099-.321.162-.531.19a3.752 3.752 0 0 1-.665.025l-.298-.017v1.893c.254.017.445.025.572.025.128.005.296.008.507.008 1.046 0 1.743-.207 2.092-.622.348-.41.821-1.472 1.419-3.188l3.104-8.898h-2.515ZM40.192 9.409l1.419 6.59h2.433l2.623-9.047h-2.466l-1.411 6.516-1.378-6.516h-2.399l-1.303 6.491-1.411-6.491h-2.54L36.299 16h2.457l1.436-6.591ZM50.41 16V6.952h-2.399V16h2.399ZM50.41 5.873V3.689h-2.399v2.184h2.399ZM56.852 16.083v-1.768l-.241.016h-.224c-.482 0-.769-.044-.863-.133-.094-.094-.142-.326-.142-.697V8.72h1.47V7.035h-1.47V4.51h-2.34v2.524H51.78V8.72h1.262v5.57c0 .564.132.982.398 1.253.41.426 1.173.62 2.291.581l1.121-.041ZM66.547 16v-5.313c0-.808-.028-1.389-.083-1.743a2.347 2.347 0 0 0-.457-1.046 2.656 2.656 0 0 0-1.128-.888 3.836 3.836 0 0 0-1.519-.29c-.499 0-.974.104-1.428.315-.448.204-.844.57-1.187 1.095V3.806h-2.358V16h2.358v-4.898c0-.775.16-1.37.481-1.785.327-.42.803-.63 1.428-.63.603 0 1.013.21 1.228.63.167.3.25.692.25 1.18V16h2.415Z"\n />\n <path\n fill="#fff"\n fill-rule="evenodd"\n d="M103 16h1.997l1.276-2.003h3.56l.265 2.003H112l-1.337-9h-1.778L103 16Zm6.231-6.674.383 2.954h-2.237l1.854-2.954ZM98.02 16l.754-2.72h1.752a6.36 6.36 0 0 0 1.762-.228c.512-.139.992-.37 1.412-.683.398-.299.721-.677.95-1.107.24-.465.36-.978.349-1.496 0-.772-.239-1.389-.716-1.85a2.871 2.871 0 0 0-1.195-.7A5.816 5.816 0 0 0 101.401 7h-2.926L96 16h2.02Zm3.307-7.205c.257-.007.512.026.757.097.194.06.368.165.51.304.101.098.18.215.232.344a.977.977 0 0 1 .072.402c.012.232-.039.463-.147.671-.108.209-.27.387-.471.519-.413.279-.955.418-1.635.418h-1.38l.751-2.752h1.314l-.003-.003Z"\n clip-rule="evenodd"\n />\n <path\n fill="#fff"\n d="m113.439 16 .982-3.548L112.5 7h2.266l1.087 3.73L119.112 7h2.388l-5.078 5.63-.939 3.37h-2.044Z"\n />\n </svg>\n </div>\n ')}var pn=function(e){function n(e,i){var r;return o(this,n),(r=t(this,n,[e,i])).widgetId=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(2,10),r.onFlypayV2ButtonClick=function(){var e=function(e){var t,n=document.getElementById((t=r.widgetId,"".concat(t,"-loading-overlay")));n&&(n.style.display=e)};r.disable(),e("flex"),r.handleMerchantOnButtonClickEvent().then((function(){var t=function(t){var n;e("none"),r.background=r.initBackground(),r.orderId?(null===(n=r.background)||void 0===n||n.initControl(),r.flypayV2Checkout(r.orderId)):r.eventEmitter.emit(Ft.UNAVAILABLE)};r.orderId?t(r.orderId):r.getOrderId().then((function(e){r.orderId=e,t()})).catch((function(t){!function(t){var n;null===(n=r.background)||void 0===n||n.clear(),e("none"),r.enable(),r.eventEmitter.emit(Ft.UNAVAILABLE,{err:t})}(t)}))})).catch((function(t){e("none"),r.enable()}))},r.accessToken=null==i?void 0:i.access_token,r.refreshToken=null==i?void 0:i.refresh_token,r.link=new ae(""),r}return l(n,e),s(n,[{key:"load",value:function(e){this.mount(e)}},{key:"setEnv",value:function(e){return this.link.setEnv(e),p(d(n.prototype),"setEnv",this).call(this,e)}},{key:"enable",value:function(){var e=document.getElementById(this.widgetId);e&&(e.disabled=!1,this.flypayV2Button.innerHTML=ln(this.widgetId))}},{key:"disable",value:function(){var e=document.getElementById(this.widgetId);e&&(e.disabled=!0,this.flypayV2Button.innerHTML=hn("paydock-flypay-button paydock-flypay-button__disabled",this.widgetId))}},{key:"mount",value:function(e){this.flypayV2Button=this.getButton(),this.flypayV2Button.onclick=this.onFlypayV2ButtonClick,e.getElement().appendChild(this.flypayV2Button)}},{key:"getButton",value:function(){var e,t,n=document.createElement("style");return n.innerHTML=(e=this.widgetId,t=dn(e),"\n .".concat(t," {\n position: relative;\n height: 100%;\n width: 100%;\n border: none; /* Remove borders */\n background: transparent; /* Make the button background transparent */\n cursor: pointer; /* Make it look clickable */\n outline: none; /* Remove focus outline */\n padding: 0; /* Remove any default padding */\n }\n\n .").concat(t,' .paydock-flypay-button {\n background-color: #212121;\n border-radius: 9999px;\n width: 100%; /* set hard pixel dimensions here for a button with intrinsic dimensions */\n height: 100%; /* and leave the 100% settings for the Coles use case (enabled by extra param object flag) */\n display: grid;\n grid-template-columns: 20% 1fr 20%;\n grid-template-rows: 20% 1fr 20%;\n grid-template-areas:\n ". . ."\n ". center ."\n ". . .";\n box-sizing: border-box;\n }\n \n .').concat(t," .paydock-flypay-button:hover {\n background-color: #3d3d3d;\n }\n \n .").concat(t," .paydock-flypay-button:focus-visible {\n outline-color: transparent;\n box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #2670ee;\n outline-color: transparent;\n }\n \n .").concat(t," .paydock-flypay-button:active {\n background-color: #6f6f6f;\n }\n \n .").concat(t," .paydock-flypay-button:disabled,\n .").concat(t," .paydock-flypay-button__disabled {\n opacity: 25%;\n cursor: not-allowed;\n }\n \n #").concat(e,"-loading-overlay {\n position: absolute;\n height: 100%;\n width: 100%;\n background: rgba(255, 255, 255, 0.7);\n display: none;\n justify-content: center;\n align-items: center;\n cursor: not-allowed; /* Make it look not clickable */ \n }\n \n #").concat(e,'-loading-overlay::after {\n content: "";\n height: 60%;\n aspect-ratio: 1 / 1;\n display: inline-block;\n border: 4px solid #ccc;\n border-top-color: #333;\n border-radius: 50%;\n /* Vendor prefixes for animation property */\n -webkit-animation: spin 1s infinite linear;\n -moz-animation: spin 1s infinite linear;\n -o-animation: spin 1s infinite linear;\n animation: spin 1s infinite linear;\n }\n \n @-webkit-keyframes spin {\n 0% {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg); \n }\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n }\n \n @-moz-keyframes spin {\n 0% {\n -moz-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -moz-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n }\n \n @-o-keyframes spin {\n 0% {\n -o-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -o-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n }\n \n @keyframes spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n } \n ')),document.head.appendChild(n),this.flypayV2Button=document.createElement("button"),this.flypayV2Button.classList.add(dn(this.widgetId)),this.flypayV2Button.setAttribute("type","button"),this.flypayV2Button.setAttribute("aria-label","Pay with flypay"),this.flypayV2Button.setAttribute("id",this.widgetId),this.flypayV2Button.innerHTML=ln(this.widgetId),this.flypayV2Button}},{key:"handleMerchantOnButtonClickEvent",value:function(){var e=this;return new Promise((function(t,n){var i;e.eventEmitter.emit(Ft.BUTTON_CLICK,{attachResult:function(e){i=e}}),i instanceof Promise?i.then(t).catch(n):!1===i?n():t()}))}},{key:"getOrderId",value:function(){var e=this;return new Promise((function(t,n){return e.eventEmitter.emit(Ft.CALLBACK,{data:{request_type:"CREATE_SESSION"},onSuccess:function(e){return t(e.id)},onError:function(e){return n(e.error)}})}))}},{key:"flypayV2Checkout",value:function(e){var t,n,i=this;this.checkout=new cn(c(c({orderId:e},this.accessToken&&this.refreshToken&&{auth:{access_token:this.accessToken,refresh_token:this.refreshToken},mode:"express"}),{clientId:"live"===(null===(t=this.meta)||void 0===t?void 0:t.gateway_mode)?"dbbd114e-3583-4db5-915e-59f1b3dcd08b":"924ac1ce-00f4-44e4-8277-06cae751ef1a",url:"live"===(null===(n=this.meta)||void 0===n?void 0:n.gateway_mode)?"https://checkout.cxbflypay.com.au":"https://checkout.sandbox.cxbflypay.com.au",onCheckoutClosed:function(){var e;i.eventEmitter.emit(Ft.CHECKOUT_CLOSE),null===(e=i.background)||void 0===e||e.clear(),i.enable()},onError:function(e){return i.eventEmitter.emit(Ft.PAYMENT_ERROR,{error:e})},onPaymentSuccess:function(e){return i.eventEmitter.emit(Ft.PAYMENT_SUCCESS,e)},onPaymentError:function(e){return i.eventEmitter.emit(Ft.PAYMENT_ERROR,{error:e})},onTokensChanged:function(e){var t=e.accessToken,n=e.refreshToken;i.accessToken=t,i.refreshToken=n,i.eventEmitter.emit(Ft.AUTH_TOKENS_CHANGED,{accessToken:t,refreshToken:n})}})),this.checkout.open(),this.checkout.isCheckoutOpen&&this.eventEmitter.emit(Ft.CHECKOUT_OPEN,{}),this.checkout.listenMessage()}},{key:"initBackground",value:function(){var e=this,t=new Ht(this.link.getNetUrl()+oe,!1,!1);return t.setBackdropTitle(""),t.setBackdropDescription(""),t.onTrigger(Ge,(function(){var t;e.checkout.close(),null===(t=e.background)||void 0===t||t.clear(),e.enable()})),t.onTrigger(Je,(function(){return e.checkout.open()})),t}}])}(Bt),fn="unavailable",vn="update",mn="paymentSuccessful",yn="paymentError",gn="paymentInReview",kn="authTokensChanged",En="onClick",_n="onCheckoutOpen",bn="onCheckoutClose",wn=function(){return s((function e(t,n,i){o(this,e),this.hasUpdateHandler=!1;var r=C.validateJWT(n);if(!r)throw new Error("Invalid charge token");this.eventEmitter=new Oe,this.container=new ue(t);var a=C.extractMeta(r.body);switch(this.api=new Ce(n,g.TOKEN),a.gateway.type){case Ie.STRIPE:this.service=new rn(a.credentials.client_auth,c(c({},i),{amount:a.charge.amount,currency:a.charge.currency}));break;case Ie.FLYPAY:this.service=new jt(n,c(c({},i),{id:a.charge.id,gateway_mode:a.gateway.mode,amount:a.charge.amount,currency:a.charge.currency,reference:a.charge.reference}));break;case Ie.FLYPAY_V2:this.service=new pn(n,c(c({},i),{id:a.charge.id,gateway_mode:a.gateway.mode,amount:a.charge.amount,currency:a.charge.currency,reference:a.charge.reference}));break;case Ie.PAYPAL:this.service=new zt(a.credentials.client_auth,c(c({},i),{id:a.charge.id,gateway_mode:a.gateway.mode,amount:a.charge.amount,currency:a.charge.currency,capture:a.charge.capture}));break;case Ie.MASTERCARD:this.service=new sn("",c(c({},i),{credentials:a.gateway.credentials,amount:a.charge.amount,currency:a.charge.currency,gateway_mode:a.gateway.mode}));break;case Ie.AFTERPAY:this.service=new un(n,c(c({},i),{id:a.charge.id,gateway_mode:a.gateway.mode,amount:a.charge.amount,currency:a.charge.currency,reference:a.charge.reference}))}}),[{key:"load",value:function(){try{this.setupServiceCallbacks(),this.service.load(this.container)}catch(e){throw this.eventEmitter.emit(fn,null),e}}},{key:"update",value:function(e){this.service.update(e)}},{key:"setEnv",value:function(e,t){this.api.setEnv(e,t),this.service.setEnv(e)}},{key:"enable",value:function(){this.service.enable()}},{key:"disable",value:function(){this.service.disable()}},{key:"close",value:function(){"function"==typeof this.service.close&&this.service.close()}},{key:"on",value:function(e,t){var n=this;return e===vn&&(this.hasUpdateHandler=!0),"function"==typeof t?this.eventEmitter.subscribe(e,t):new Promise((function(t){return n.eventEmitter.subscribe(e,(function(e){return t(e)}))}))}},{key:"onUnavailable",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(fn,e):new Promise((function(e){return t.eventEmitter.subscribe(fn,(function(){return e()}))}))}},{key:"onUpdate",value:function(e){var t=this;return this.hasUpdateHandler=!0,"function"==typeof e?this.eventEmitter.subscribe(vn,e):new Promise((function(e){return t.eventEmitter.subscribe(vn,(function(t){return e(t)}))}))}},{key:"onPaymentSuccessful",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(mn,e):new Promise((function(e){return t.eventEmitter.subscribe(mn,(function(t){return e(t)}))}))}},{key:"onPaymentInReview",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(gn,e):new Promise((function(e){return t.eventEmitter.subscribe(gn,(function(t){return e(t)}))}))}},{key:"onPaymentError",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(yn,e):new Promise((function(e){return t.eventEmitter.subscribe(yn,(function(t){return e(t)}))}))}},{key:"onAuthTokensChanged",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(kn,e):new Promise((function(e){return t.eventEmitter.subscribe(kn,(function(t){return e(t)}))}))}},{key:"onClick",value:function(e){if("function"==typeof e)return this.eventEmitter.subscribe(En,e)}},{key:"onCheckoutOpen",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(_n,e):new Promise((function(e){return t.eventEmitter.subscribe(_n,(function(t){return e(t)}))}))}},{key:"onCheckoutClose",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(bn,e):new Promise((function(e){return t.eventEmitter.subscribe(bn,(function(t){return e(t)}))}))}},{key:"setupServiceCallbacks",value:function(){this.setupUnavailableCallback(),this.setupUpdateCallback(),this.setupWalletCallback(),this.setupPaymentCallback(),this.setupPaymentSuccessCallback(),this.setupPaymentInReviewCallback(),this.setupPaymentErrorCallback(),this.setupAuthTokensChangedCallback(),this.setupOnClickCallback(),this.setupOnCheckoutOpenCallback(),this.setupOnCheckoutCloseCallback()}},{key:"setupUnavailableCallback",value:function(){var e=this;this.service.on(Ft.UNAVAILABLE,(function(t){return e.eventEmitter.emit(fn,{event:fn,data:t})}))}},{key:"setupUpdateCallback",value:function(){var e=this;this.service.on(Ft.UPDATE,(function(t){return e.hasUpdateHandler?e.eventEmitter.emit(vn,{event:vn,data:t}):e.update({success:!0})}))}},{key:"setupOnClickCallback",value:function(){var e=this;this.service.on(Ft.BUTTON_CLICK,(function(t){return e.eventEmitter.emit(En,{event:En,data:t})}))}},{key:"setupOnCheckoutOpenCallback",value:function(){var e=this;this.service.on(Ft.CHECKOUT_OPEN,(function(t){return e.eventEmitter.emit(_n,{event:_n,data:t})}))}},{key:"setupOnCheckoutCloseCallback",value:function(){var e=this;this.service.on(Ft.CHECKOUT_CLOSE,(function(t){return e.eventEmitter.emit(bn,{event:bn,data:t})}))}},{key:"setupWalletCallback",value:function(){var e=this;this.service.on(Ft.CALLBACK,(function(t){var n=t.data,i=t.onSuccess,r=t.onError;e.api.charge().walletCallback(n).then((function(e){return i(e)}),(function(e){return r(e.message)}))}))}},{key:"setupPaymentCallback",value:function(){var e=this;this.service.on(Ft.PAYMENT_METHOD_SELECTED,(function(t){var n=t.data,i=t.onSuccess,r=t.onError;e.api.charge().walletCapture(n).then((function(t){"function"==typeof i&&i();var r="inreview"===t.status?gn:mn;e.eventEmitter.emit(r,{event:r,data:c(c({},t),n.customer&&{payer_name:n.customer.payer_name,payer_email:n.customer.payer_email,payer_phone:n.customer.payer_phone})})}),(function(t){"function"==typeof r&&r(t),e.eventEmitter.emit(yn,{event:yn,data:t})}))}))}},{key:"setupPaymentSuccessCallback",value:function(){var e=this;this.service.on(Ft.PAYMENT_SUCCESS,(function(t){return e.eventEmitter.emit(mn,{event:mn,data:t})}))}},{key:"setupPaymentInReviewCallback",value:function(){var e=this;this.service.on(Ft.PAYMENT_IN_REVIEW,(function(t){return e.eventEmitter.emit(gn,{event:gn,data:t})}))}},{key:"setupPaymentErrorCallback",value:function(){var e=this;this.service.on(Ft.PAYMENT_ERROR,(function(t){return e.eventEmitter.emit(yn,{event:yn,data:t})}))}},{key:"setupAuthTokensChangedCallback",value:function(){var e=this;this.service.on(Ft.AUTH_TOKENS_CHANGED,(function(t){return e.eventEmitter.emit(kn,{event:kn,data:t})}))}}])}(),Cn={CARD:"card",GIFT_CARD:"gift_card",BANK_ACCOUNT:"bank_account",CHECKOUT:"checkout"},Sn={PAYMENT_SOURCE:"payment_source",CARD_PAYMENT_SOURCE_WITH_CVV:"card_payment_source_with_cvv",CARD_PAYMENT_SOURCE_WITHOUT_CVV:"card_payment_source_without_cvv"},Tn=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Cn.CARD,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Sn.PAYMENT_SOURCE;if(o(this,e),-1===wt.values(Cn).indexOf(n))throw new Error("unsupported payment type");if(n===Cn.CHECKOUT)throw new Error('Payment type "checkout" is deprecated. Use CheckoutButton for this type of payments https://www.npmjs.com/package/@paydock/client-sdk#checkout-button');if(-1===wt.values(Sn).indexOf(i))throw new Error("unsupported purpose");this.env=new X(Y),this.configs={purpose:i,meta:{},dynamic_fields_position:!0,predefined_fields:{gateway_id:t,type:n,card_scheme:null,card_processing_network:null}}}return s(e,[{key:"setWebHookDestination",value:function(e){this.configs.webhook_destination=e}},{key:"setSuccessRedirectUrl",value:function(e){this.configs.success_redirect_url=e}},{key:"setErrorRedirectUrl",value:function(e){this.configs.error_redirect_url=e}},{key:"setFormFields",value:function(e){for(var t in Array.isArray(this.configs.defined_form_fields)||(this.configs.defined_form_fields=[]),e)e.hasOwnProperty(t)&&(-1!==wt.values(De).indexOf(e[t].replace("*",""))?this.configs.defined_form_fields.push(e[t]):console.warn("Configuration::setFormFields: unsupported form field ".concat(e[t])))}},{key:"setMeta",value:function(e){for(var t in e)e.hasOwnProperty(t)&&(-1!==je.indexOf(t)?this.configs.meta[t]=e[t]:console.warn("Configuration::setMeta: unsupported meta key ".concat(t)))}},{key:"setEnv",value:function(e,t){this.env.setEnv(e,t)}},{key:"setLabel",value:function(e){this.configs.label=e}},{key:"getEnv",value:function(){return this.env.getEnv()}},{key:"createToken",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(e){};this.send(e,(function(e,i){if(i>=200&&i<300)return t(e.resource.data.configuration_token);void 0===e.error||void 0===e.error.message?n("unknown error"):n(e.error.message)}))}},{key:"send",value:function(e,t){var n=new XMLHttpRequest;n.open("POST",this.getUrl(),!0),n.setRequestHeader("Content-Type","application/json; charset=UTF-8"),n.setRequestHeader(C.getAccessHeaderNameByToken(e),e),$.version&&(n.setRequestHeader($.headerKeys.version,$.version),n.setRequestHeader($.headerKeys.type,$.type)),n.send(JSON.stringify(this.getConfigs())),n.onload=function(){var e={};try{e=JSON.parse(n.responseText)}catch(e){}t(e,n.status)}}},{key:"getConfigs",value:function(){return this.configs}},{key:"getUrl",value:function(){return this.env.getConf().url+"/v1/remote-action/configs"}},{key:"setGiftCardSchemeData",value:function(e,t){if(this.configs.predefined_fields.type!==Cn.GIFT_CARD)throw new Error("unsupported payment type");if(!e||!t)throw new Error("");this.configs.predefined_fields.card_scheme=e,this.configs.predefined_fields.card_processing_network=t}}],[{key:"createEachToken",value:function(t,n,i){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(e){},o=new Array(n.length),a=[],s=0,u=function(u){n.hasOwnProperty(u)&&n[u].createToken(t,(function(t){o[u]=t,s++,n.length===s&&e.finishCreatingEachToken(o,a,i,r)}),(function(t){a.push("gateway: ".concat(n[u].getConfigs().predefined_fields.gateway_id," | ").concat(t)),s++,n.length===s&&e.finishCreatingEachToken(o,a,i,r)}))};for(var c in n)u(c)}},{key:"finishCreatingEachToken",value:function(e,t,n,i){t.length>=1?i(t):n(e)}}])}(),On={INPUT:"input",SUBMIT_BUTTON:"submit_button",LABEL:"label",TITLE:"title",TITLE_DESCRIPTION:"title_description"},An={ERROR:"error",FOCUS:"focus",HOVER:"hover"},Pn=[{element:On.INPUT,states:[An.FOCUS,An.ERROR],styles:["color","border","border_radius","background_color","height","text_decoration","font_size","font_family","line_height","font_weight","padding","margin","transition"]},{element:On.SUBMIT_BUTTON,states:[An.HOVER],styles:["color","border","border_radius","background_color","text_decoration","font_size","font_family","line_height","font_weight","padding","margin","transition","opacity"]},{element:On.LABEL,states:[],styles:["color","text_decoration","font_size","font_family","line_height","font_weight","padding","margin"]},{element:On.TITLE,states:[],styles:["color","text_decoration","font_size","font_family","line_height","font_weight","padding","margin","text_align"]},{element:On.TITLE_DESCRIPTION,states:[],styles:["color","text_decoration","font_size","font_family","line_height","font_weight","padding","margin","text_align"]}],Rn=function(){return s((function e(){o(this,e)}),null,[{key:"check",value:function(e,t,n,i){for(var r in e)if(e.hasOwnProperty(r)&&e[r].element===t){if(-1===e[r].states.indexOf(n)&&n)return!1;for(var o in i)if(i.hasOwnProperty(o)&&-1===e[r].styles.indexOf(o.replace("-","_")))return!1;return!0}return!1}},{key:"encode",value:function(e,t,n){var i=[];for(var r in n)n.hasOwnProperty(r)&&i.push("".concat(r.replace("_","-"),":").concat(n[r]));var o=i.join(";");return t?"".concat(e,"::").concat(t,"{").concat(o,"}"):"".concat(e,"{").concat(o,"}")}},{key:"decode",value:function(e){var t=(e.match("::(.*){")||["",null])[1],n=null!==t?(e.match("(.*)::")||["",""])[1].trim():(e.match("(.*){")||["",""])[1].trim(),i=(e.match("{(.*)}")||["",""])[1].split(";"),r={};for(var o in i)if(i.hasOwnProperty(o)){var a=i[o].split(":");(a||2===a.length)&&(r[a[0].trim()]=(a[1]||"").trim())}return{element:n,state:t,styles:r}}}])}(),xn=function(){return s((function e(t,n){if(o(this,e),this.configs=[],this.configTokens=[],this.link=new ae("/remote-action"),$.version&&this.link.setParams({sdk_version:$.version,sdk_type:$.type}),C.validateJWT(t)?this.link.setParams({token:t}):this.link.setParams({public_key:t}),this.accessToken=t,!n||Array.isArray(n)&&!n.length)throw Error("configuration token is required");if("string"==typeof n)this.configTokens.push(n);else if(n instanceof Tn)this.configs.push(n);else if(Array.isArray(n)&&"string"==typeof n[0])this.configTokens=n;else{if(!(Array.isArray(n)&&n[0]instanceof Tn))throw Error("Unsupported type of configuration token");this.configs=n}}),[{key:"setStyles",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setStyle(t,e[t])}},{key:"usePhoneCountryMask",value:function(e){return e?!e.only_countries||/^[a-z]+$/.test(e.only_countries.join(""))&&2*e.only_countries.length===e.only_countries.join("").length?!e.preferred_countries||/^[a-z]+$/.test(e.preferred_countries.join(""))&&2*e.preferred_countries.length===e.preferred_countries.join("").length?e.default_country&&2!==e.default_country.length?console.warn("Widget::usePhoneCountryMask[s: default_country - incorrect value length"):(this.link.setParams({use_country_phone_mask:!0}),e.only_countries&&this.link.setParams({phone_mask_only_countries:e.only_countries.join(",")}),e.preferred_countries&&this.link.setParams({phone_mask_preferred_countries:e.preferred_countries.join(",")}),void(e.default_country&&this.link.setParams({phone_mask_default_country:e.default_country}))):console.warn("Widget::usePhoneCountryMask[s: preferred_countries - unsupported symbols or incorrect length of value"):console.warn("Widget::usePhoneCountryMask[s: only_countries - unsupported symbols or incorrect length of value"):this.link.setParams({use_country_phone_mask:!0})}},{key:"setStyle",value:function(e,t){-1!==wt.values(Me).indexOf(e)?this.link.setParams(u({},e,t)):console.warn("Widget::setStyle[s: unsupported style param ".concat(e))}},{key:"setTexts",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setText(t,e[t])}},{key:"setText",value:function(e,t){-1!==wt.values(He).indexOf(e)?this.link.setParams(u({},e,t)):console.warn("Widget::setText[s: unsupported text param ".concat(e))}},{key:"setElementStyle",value:function(e,t,n){var i=3===arguments.length?t:null,r=3===arguments.length?n:t;if(!Rn.check(Pn,e,i,r))return console.warn('Styles for "'.concat(e,'" element with "').concat(i||"default",'" state was ignored because some of the arguments are unacceptable'));this.link.concatParams({element_styles:Rn.encode(e,i,r)})}},{key:"setFormValues",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setFormValue(t,e[t])}},{key:"setFormValue",value:function(e,t){return-1===wt.values(De).indexOf(e)?console.warn("Widget::setFormValues[s: unsupported field ".concat(e)):/\,/.test(t)||/\:/.test(t)?console.warn("Widget::setFormValues[s: ".concat(e," - unsupported symbols (: or ,) in value")):void("string"==typeof this.link.getParams().form_values&&this.link.getParams().form_values.length?this.link.setParams({form_values:"".concat(this.link.getParams().form_values,",").concat(e,":").concat(t)}):this.link.setParams({form_values:"".concat(e,":").concat(t)}))}},{key:"setFormLabels",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setFormLabel(t,e[t])}},{key:"setFormLabel",value:function(e,t){if(-1===wt.values(De).indexOf(e))return console.warn("Widget::setFormLabel[s: unsupported field ".concat(e));var n=null===t||""===t?" ":t;if(/\,/.test(n)||/\:/.test(n))return console.warn("Widget::setFormLabel[s: ".concat(e," - unsupported symbols (: or ,) in value"));this.link.concatParams({form_labels:"".concat(e,":").concat(n)})}},{key:"setFormPlaceholders",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setFormPlaceholder(t,e[t])}},{key:"setFormPlaceholder",value:function(e,t){if(-1===wt.values(De).indexOf(e))return console.warn("Widget::setFormPlaceholder[s: unsupported field ".concat(e));var n=null===t||""===t?" ":t;if(/\,/.test(n)||/\:/.test(n))return console.warn("Widget::setFormPlaceholder[s: ".concat(e," - unsupported symbols (: or ,) in value"));this.link.concatParams({form_placeholders:"".concat(e,":").concat(n)})}},{key:"setFormElements",value:function(e){var t=this;e.forEach((function(e){return t.setFormElement(e)}))}},{key:"setFormElement",value:function(e){e.value&&this.setFormValue(e.field,e.value),e.label&&this.setFormLabel(e.field,e.label),e.placeholder&&this.setFormPlaceholder(e.field,e.placeholder)}},{key:"setIcons",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setIcon(t,e[t])}},{key:"setIcon",value:function(e,t){if(/\,/.test(t)||/\:/.test(t))return console.warn("Widget::setIcon[s: ".concat(e," - unsupported symbols (: or ,) in value"));"string"==typeof this.link.getParams().icons&&this.link.getParams().icons.length?this.link.setParams({icons:"".concat(this.link.getParams().icons,",").concat(e,":").concat(t)}):this.link.setParams({icons:"".concat(e,":").concat(t)})}},{key:"setHiddenElements",value:function(e){var t=[],n=wt.values(Fe).concat(wt.values(De));for(var i in e)e.hasOwnProperty(i)&&(-1!==n.indexOf(e[i])?t.push(e[i]):console.warn("Widget::setHiddenElements: unsupported element ".concat(e[i])));t.length&&this.link.concatParams({hidden_elements:t.join(",")})}},{key:"setRefId",value:function(e){this.link.setParams({ref_id:e})}},{key:"useGatewayFieldValidation",value:function(){this.link.setParams({fields_validation:!0})}},{key:"setSupportedCardIcons",value:function(e,t){var n=[];for(var i in e)e.hasOwnProperty(i)&&(-1!==wt.values(Be).indexOf(e[i])?n.push(e[i]):console.warn("Widget::cardTypes: unsupported type of cards ".concat(e[i])));n.length&&this.link.concatParams({supported_card_types:n.join(",")}),t&&this.link.setParams({validate_card_types:t})}},{key:"setEnv",value:function(e,t){for(var n in this.link.setEnv(e,t),this.configs)this.configs.hasOwnProperty(n)&&this.configs[n].setEnv(e,t)}},{key:"getEnv",value:function(){this.link.getEnv()}},{key:"loadIFrameUrl",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(e){};if(this.link.setParams({configuration_tokens:""}),this.configTokens.length)return this.link.setParams({configuration_tokens:this.configTokens.join(",")}),e(this.link.getUrl());Tn.createEachToken(this.accessToken,this.configs,(function(n){return t.link.concatParams({configuration_tokens:n.join(",")}),e(t.link.getUrl())}),(function(e){n(e)}))}},{key:"setLanguage",value:function(e){this.link.setParams({language:e})}}])}(),In=function(){return s((function e(t){o(this,e),this.intercepted=!1,this.selector=t}),[{key:"getElement",value:function(){return document.querySelector(this.selector)}},{key:"isExist",value:function(){return!!this.getElement()}},{key:"beforeSubmit",value:function(e){var t=this;this.isExist()&&this.subscribe(this.getElement(),(function(n){n.preventDefault(),t.intercepted=!0,e.apply(t,[])}))}},{key:"continueSubmit",value:function(){var e=this;this.isExist()&&this.intercepted&&(this.intercepted=!1,setTimeout((function(){e.getElement().submit()}),50))}},{key:"subscribe",value:function(e,t){e.addEventListener?e.addEventListener("submit",t):e.attachEvent("onsubmit",t)}}])}(),Un=function(e){function n(e,i,r){var a;return o(this,n),(a=t(this,n,[i,r])).validationData={},a.container=new ue(e),a.iFrame=new ce(a.container),a.triggerElement=new xt(a.iFrame),a.event=new de(window),a}return l(n,e),s(n,[{key:"load",value:function(){var e=this;this.setStyles(this.container.getStyles(wt.values(Me))),this.setTexts(this.container.getAttr(wt.values(He))),this.loadIFrameUrl((function(t){e.iFrame.load(t,{title:"Card details"}),e.afterLoad()}),(function(e){for(var t in console.error("Errors when creating a token[s, widget will not be load:"),e)e.hasOwnProperty(t)&&console.error("--- | ".concat(e[t]))}))}},{key:"afterLoad",value:function(){var e=this;this.on(le.VALIDATION,(function(t){e.validationData=t}))}},{key:"on",value:function(e,t){var n=this;return"function"==typeof t?this.event.on(e,this.link.getParams().widget_id,t):new Promise((function(t){return n.event.on(e,n.link.getParams().widget_id,(function(e){return t(e)}))}))}},{key:"trigger",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.triggerElement.push(e,t)}},{key:"getValidationState",value:function(){return this.validationData}},{key:"isValidForm",value:function(){return!!this.validationData.form_valid}},{key:"isInvalidField",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!!this.validationData.invalid_fields&&-1!==this.validationData.invalid_fields.indexOf(e)}},{key:"isFieldErrorShowed",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!!this.validationData.invalid_showed_fields&&-1!==this.validationData.invalid_showed_fields.indexOf(e)}},{key:"isInvalidFieldByValidator",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0,n=!1;if(!this.validationData.validators)return n;var i=this.validationData.validators[t];return i?-1!==i.indexOf(e):n}},{key:"hide",value:function(e){this.iFrame.hide(e)}},{key:"show",value:function(){this.iFrame.show()}},{key:"reload",value:function(){this.iFrame.remove(),this.load()}},{key:"hideElements",value:function(e){var t=[],n=wt.values(Fe).concat(wt.values(De));for(var i in e)e.hasOwnProperty(i)&&(-1!==n.indexOf(e[i])?t.push(e[i]):console.warn("Widget::hideElements: unsupported element ".concat(e[i])));t.length&&this.trigger(Rt.HIDE_ELEMENTS,{elements:t.join(",")})}},{key:"showElements",value:function(e){var t=[],n=wt.values(Fe).concat(wt.values(De));for(var i in e)e.hasOwnProperty(i)&&(-1!==n.indexOf(e[i])?t.push(e[i]):console.warn("Widget::showElements: unsupported element ".concat(e[i])));t.length&&this.trigger(Rt.SHOW_ELEMENTS,{elements:t.join(",")})}},{key:"updateFormValues",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.updateFormValue(t,e[t])}},{key:"updateFormValue",value:function(e,t){return-1===wt.values(De).indexOf(e)?console.warn("Widget::setFormValues[s: unsupported field ".concat(e)):/\,/.test(t)||/\:/.test(t)?console.warn("Widget::setFormValues[s: ".concat(e," - unsupported symbols (: or ,) in value")):void this.trigger(Rt.UPDATE_FORM_VALUES,{form_values:"".concat(e,":").concat(t)})}},{key:"onFinishInsert",value:function(e,t){this.on(le.FINISH,(function(n){se.insertToInput(e,t,n)}))}},{key:"interceptSubmitForm",value:function(e){var t=this;this.setHiddenElements([Fe.SUBMIT_BUTTON]);var n=new In(e);n.beforeSubmit((function(){t.triggerElement.push(Rt.SUBMIT_FORM,{}),t.event.on(le.FINISH,t.link.getParams().widget_id,(function(){n.continueSubmit()}))}))}},{key:"useCheckoutAutoSubmit",value:function(){var e=this;this.setHiddenElements([Fe.SUBMIT_BUTTON]),this.on(le.CHECKOUT_SUCCESS,(function(t){e.trigger(Rt.SUBMIT_FORM)})),this.on(le.VALIDATION_ERROR,(function(t){e.trigger(Rt.REFRESH_CHECKOUT)})),this.on(le.SYSTEM_ERROR,(function(t){e.trigger(Rt.REFRESH_CHECKOUT)}))}},{key:"useAutoResize",value:function(){var e=this;this.on(le.RESIZE,(function(t){e.iFrame.getElement()&&(e.iFrame.getElement().scrolling="no",t.height&&e.iFrame.setStyle("height",t.height+"px"))}))}}])}(xn),Ln=function(e){function n(e,i){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"default",a=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;return o(this,n),t(this,n,[e,i,new Tn(r,a,s)])}return l(n,e),s(n,[{key:"setWebHookDestination",value:function(e){this.configs[0].setWebHookDestination(e)}},{key:"setSuccessRedirectUrl",value:function(e){this.configs[0].setSuccessRedirectUrl(e)}},{key:"setErrorRedirectUrl",value:function(e){this.configs[0].setErrorRedirectUrl(e)}},{key:"setFormFields",value:function(e){this.configs[0].setFormFields(e)}},{key:"setFormElements",value:function(e){var t=this;e.forEach((function(e){return t.setFormElement(e)}))}},{key:"setFormElement",value:function(e){this.configs[0].setFormFields([e.field]),p(d(n.prototype),"setFormElement",this).call(this,c(c({},e),{field:e.field.replace("*","")}))}},{key:"setMeta",value:function(e){this.configs[0].setMeta(e)}},{key:"setGiftCardScheme",value:function(e,t){this.configs[0].setGiftCardSchemeData(e,t)}}])}(Un);e.AfterpayCheckoutButton=_t,e.Api=te,e.CHECKOUT_BUTTON_EVENT=xe,e.Canvas3ds=Re,e.ClickToPay=Pt,e.Configuration=Tn,e.ELEMENT=Fe,e.EVENT=le,e.ExternalCheckoutBuilder=qe,e.ExternalCheckoutChecker=Ke,e.FORM_FIELD=De,e.HtmlMultiWidget=Un,e.HtmlPaymentSourceWidget=St,e.HtmlWidget=Ln,e.MultiWidget=xn,e.PAYMENT_TYPE=Cn,e.PURPOSE=Sn,e.PaymentSourceBuilder=yt,e.PaymentSourceWidget=Ct,e.PaypalCheckoutButton=bt,e.STYLABLE_ELEMENT=On,e.STYLABLE_ELEMENT_STATE=An,e.STYLE=Me,e.SUPPORTED_CARD_TYPES=Be,e.TEXT=He,e.TRIGGER=Rt,e.TYPE=mt,e.VAULT_DISPLAY_STYLE={BACKGROUND_COLOR:"background_color",TEXT_COLOR:"text_color",BORDER_COLOR:"border_color",BUTTON_COLOR:"button_color",FONT_SIZE:"font_size",FONT_FAMILY:"font_family"},e.VaultDisplayWidget=Lt,e.WalletButtons=wn,e.ZipmoneyCheckoutButton=Et}));
|
|
2
2
|
//# sourceMappingURL=widget.umd.min.js.map
|
package/package.json
CHANGED
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
}
|
|
105
105
|
},
|
|
106
106
|
"name": "@paydock/client-sdk",
|
|
107
|
-
"version": "1.107.
|
|
107
|
+
"version": "1.107.1",
|
|
108
108
|
"scripts": {
|
|
109
109
|
"build:doc": "node docs/html/marked.js",
|
|
110
110
|
"build:js": "rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript",
|