!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=7)}([function(e,t,n){var r;r=function(){var e=!0;function t(t){function n(e){var n=t.match(e);return n&&n.length>1&&n[1]||""}function r(e){var n=t.match(e);return n&&n.length>1&&n[2]||""}var o,a=n(/(ipod|iphone|ipad)/i).toLowerCase(),s=!/like android/i.test(t)&&/android/i.test(t),l=/nexus\s*[0-6]\s*/i.test(t),u=!l&&/nexus\s*[0-9]+/i.test(t),p=/CrOS/.test(t),c=/silk/i.test(t),d=/sailfish/i.test(t),f=/tizen/i.test(t),y=/(web|hpw)(o|0)s/i.test(t),h=/windows phone/i.test(t),m=(/SamsungBrowser/i.test(t),!h&&/windows/i.test(t)),v=!a&&!c&&/macintosh/i.test(t),g=!s&&!d&&!f&&!y&&/linux/i.test(t),w=r(/edg([ea]|ios)\/(\d+(\.\d+)?)/i),b=n(/version\/(\d+(\.\d+)?)/i),P=/tablet/i.test(t)&&!/tablet pc/i.test(t),_=!P&&/[^-]mobi/i.test(t),k=/xbox/i.test(t);/opera/i.test(t)?o={name:"Opera",opera:e,version:b||n(/(?:opera|opr|opios)[\s\/](\d+(\.\d+)?)/i)}:/opr\/|opios/i.test(t)?o={name:"Opera",opera:e,version:n(/(?:opr|opios)[\s\/](\d+(\.\d+)?)/i)||b}:/SamsungBrowser/i.test(t)?o={name:"Samsung Internet for Android",samsungBrowser:e,version:b||n(/(?:SamsungBrowser)[\s\/](\d+(\.\d+)?)/i)}:/Whale/i.test(t)?o={name:"NAVER Whale browser",whale:e,version:n(/(?:whale)[\s\/](\d+(?:\.\d+)+)/i)}:/MZBrowser/i.test(t)?o={name:"MZ Browser",mzbrowser:e,version:n(/(?:MZBrowser)[\s\/](\d+(?:\.\d+)+)/i)}:/coast/i.test(t)?o={name:"Opera Coast",coast:e,version:b||n(/(?:coast)[\s\/](\d+(\.\d+)?)/i)}:/focus/i.test(t)?o={name:"Focus",focus:e,version:n(/(?:focus)[\s\/](\d+(?:\.\d+)+)/i)}:/yabrowser/i.test(t)?o={name:"Yandex Browser",yandexbrowser:e,version:b||n(/(?:yabrowser)[\s\/](\d+(\.\d+)?)/i)}:/ucbrowser/i.test(t)?o={name:"UC Browser",ucbrowser:e,version:n(/(?:ucbrowser)[\s\/](\d+(?:\.\d+)+)/i)}:/mxios/i.test(t)?o={name:"Maxthon",maxthon:e,version:n(/(?:mxios)[\s\/](\d+(?:\.\d+)+)/i)}:/epiphany/i.test(t)?o={name:"Epiphany",epiphany:e,version:n(/(?:epiphany)[\s\/](\d+(?:\.\d+)+)/i)}:/puffin/i.test(t)?o={name:"Puffin",puffin:e,version:n(/(?:puffin)[\s\/](\d+(?:\.\d+)?)/i)}:/sleipnir/i.test(t)?o={name:"Sleipnir",sleipnir:e,version:n(/(?:sleipnir)[\s\/](\d+(?:\.\d+)+)/i)}:/k-meleon/i.test(t)?o={name:"K-Meleon",kMeleon:e,version:n(/(?:k-meleon)[\s\/](\d+(?:\.\d+)+)/i)}:h?(o={name:"Windows Phone",osname:"Windows Phone",windowsphone:e},w?(o.msedge=e,o.version=w):(o.msie=e,o.version=n(/iemobile\/(\d+(\.\d+)?)/i))):/msie|trident/i.test(t)?o={name:"Internet Explorer",msie:e,version:n(/(?:msie |rv:)(\d+(\.\d+)?)/i)}:p?o={name:"Chrome",osname:"Chrome OS",chromeos:e,chromeBook:e,chrome:e,version:n(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:/edg([ea]|ios)/i.test(t)?o={name:"Microsoft Edge",msedge:e,version:w}:/vivaldi/i.test(t)?o={name:"Vivaldi",vivaldi:e,version:n(/vivaldi\/(\d+(\.\d+)?)/i)||b}:d?o={name:"Sailfish",osname:"Sailfish OS",sailfish:e,version:n(/sailfish\s?browser\/(\d+(\.\d+)?)/i)}:/seamonkey\//i.test(t)?o={name:"SeaMonkey",seamonkey:e,version:n(/seamonkey\/(\d+(\.\d+)?)/i)}:/firefox|iceweasel|fxios/i.test(t)?(o={name:"Firefox",firefox:e,version:n(/(?:firefox|iceweasel|fxios)[ \/](\d+(\.\d+)?)/i)},/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(t)&&(o.firefoxos=e,o.osname="Firefox OS")):c?o={name:"Amazon Silk",silk:e,version:n(/silk\/(\d+(\.\d+)?)/i)}:/phantom/i.test(t)?o={name:"PhantomJS",phantom:e,version:n(/phantomjs\/(\d+(\.\d+)?)/i)}:/slimerjs/i.test(t)?o={name:"SlimerJS",slimer:e,version:n(/slimerjs\/(\d+(\.\d+)?)/i)}:/blackberry|\bbb\d+/i.test(t)||/rim\stablet/i.test(t)?o={name:"BlackBerry",osname:"BlackBerry OS",blackberry:e,version:b||n(/blackberry[\d]+\/(\d+(\.\d+)?)/i)}:y?(o={name:"WebOS",osname:"WebOS",webos:e,version:b||n(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)},/touchpad\//i.test(t)&&(o.touchpad=e)):/bada/i.test(t)?o={name:"Bada",osname:"Bada",bada:e,version:n(/dolfin\/(\d+(\.\d+)?)/i)}:f?o={name:"Tizen",osname:"Tizen",tizen:e,version:n(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i)||b}:/qupzilla/i.test(t)?o={name:"QupZilla",qupzilla:e,version:n(/(?:qupzilla)[\s\/](\d+(?:\.\d+)+)/i)||b}:/chromium/i.test(t)?o={name:"Chromium",chromium:e,version:n(/(?:chromium)[\s\/](\d+(?:\.\d+)?)/i)||b}:/chrome|crios|crmo/i.test(t)?o={name:"Chrome",chrome:e,version:n(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:s?o={name:"Android",version:b}:/safari|applewebkit/i.test(t)?(o={name:"Safari",safari:e},b&&(o.version=b)):a?(o={name:"iphone"==a?"iPhone":"ipad"==a?"iPad":"iPod"},b&&(o.version=b)):o=/googlebot/i.test(t)?{name:"Googlebot",googlebot:e,version:n(/googlebot\/(\d+(\.\d+))/i)||b}:{name:n(/^(.*)\/(.*) /),version:r(/^(.*)\/(.*) /)},!o.msedge&&/(apple)?webkit/i.test(t)?(/(apple)?webkit\/537\.36/i.test(t)?(o.name=o.name||"Blink",o.blink=e):(o.name=o.name||"Webkit",o.webkit=e),!o.version&&b&&(o.version=b)):!o.opera&&/gecko\//i.test(t)&&(o.name=o.name||"Gecko",o.gecko=e,o.version=o.version||n(/gecko\/(\d+(\.\d+)?)/i)),o.windowsphone||!s&&!o.silk?!o.windowsphone&&a?(o[a]=e,o.ios=e,o.osname="iOS"):v?(o.mac=e,o.osname="macOS"):k?(o.xbox=e,o.osname="Xbox"):m?(o.windows=e,o.osname="Windows"):g&&(o.linux=e,o.osname="Linux"):(o.android=e,o.osname="Android");var T="";o.windows?T=function(e){switch(e){case"NT":return"NT";case"XP":return"XP";case"NT 5.0":return"2000";case"NT 5.1":return"XP";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}}(n(/Windows ((NT|XP)( \d\d?.\d)?)/i)):o.windowsphone?T=n(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i):o.mac?T=(T=n(/Mac OS X (\d+([_\.\s]\d+)*)/i)).replace(/[_\s]/g,"."):a?T=(T=n(/os (\d+([_\s]\d+)*) like mac os x/i)).replace(/[_\s]/g,"."):s?T=n(/android[ \/-](\d+(\.\d+)*)/i):o.webos?T=n(/(?:web|hpw)os\/(\d+(\.\d+)*)/i):o.blackberry?T=n(/rim\stablet\sos\s(\d+(\.\d+)*)/i):o.bada?T=n(/bada\/(\d+(\.\d+)*)/i):o.tizen&&(T=n(/tizen[\/\s](\d+(\.\d+)*)/i)),T&&(o.osversion=T);var C=!o.windows&&T.split(".")[0];return P||u||"ipad"==a||s&&(3==C||C>=4&&!_)||o.silk?o.tablet=e:(_||"iphone"==a||"ipod"==a||s||l||o.blackberry||o.webos||o.bada)&&(o.mobile=e),o.msedge||o.msie&&o.version>=10||o.yandexbrowser&&o.version>=15||o.vivaldi&&o.version>=1||o.chrome&&o.version>=20||o.samsungBrowser&&o.version>=4||o.whale&&1===i([o.version,"1.0"])||o.mzbrowser&&1===i([o.version,"6.0"])||o.focus&&1===i([o.version,"1.0"])||o.firefox&&o.version>=20||o.safari&&o.version>=6||o.opera&&o.version>=10||o.ios&&o.osversion&&o.osversion.split(".")[0]>=6||o.blackberry&&o.version>=10.1||o.chromium&&o.version>=20?o.a=e:o.msie&&o.version<10||o.chrome&&o.version<20||o.firefox&&o.version<20||o.safari&&o.version<6||o.opera&&o.version<10||o.ios&&o.osversion&&o.osversion.split(".")[0]<6||o.chromium&&o.version<20?o.c=e:o.x=e,o}var n=t("undefined"!=typeof navigator&&navigator.userAgent||"");function r(e){return e.split(".").length}function o(e,t){var n,r=[];if(Array.prototype.map)return Array.prototype.map.call(e,t);for(n=0;n<e.length;n++)r.push(t(e[n]));return r}function i(e){for(var t=Math.max(r(e[0]),r(e[1])),n=o(e,(function(e){var n=t-r(e);return o((e+=new Array(n+1).join(".0")).split("."),(function(e){return new Array(20-e.length).join("0")+e})).reverse()}));--t>=0;){if(n[0][t]>n[1][t])return 1;if(n[0][t]!==n[1][t])return-1;if(0===t)return 0}}function a(e,r,o){var a=n;"string"==typeof r&&(o=r,r=void 0),void 0===r&&(r=!1),o&&(a=t(o));var s=""+a.version;for(var l in e)if(e.hasOwnProperty(l)&&a[l]){if("string"!=typeof e[l])throw new Error("Browser version in the minVersion map should be a string: "+l+": "+String(e));return i([s,e[l]])<0}return r}return n.test=function(e){for(var t=0;t<e.length;++t){var r=e[t];if("string"==typeof r&&r in n)return!0}return!1},n.isUnsupportedBrowser=a,n.compareVersions=i,n.check=function(e,t,n){return!a(e,t,n)},n._detect=t,n.detect=t,n},e.exports?e.exports=r():n(3)("bowser",r)},function(e,t,n){(function(t,n){
/*!
 * @overview es6-promise - a tiny implementation of Promises/A+.
 * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
 * @license   Licensed under MIT license
 *            See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
 * @version   v4.2.8+1e68dce6
 */
var r;r=function(){"use strict";function e(e){return"function"==typeof e}var r=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},o=0,i=void 0,a=void 0,s=function(e,t){y[o]=e,y[o+1]=t,2===(o+=2)&&(a?a(h):b())},l="undefined"!=typeof window?window:void 0,u=l||{},p=u.MutationObserver||u.WebKitMutationObserver,c="undefined"==typeof self&&void 0!==t&&"[object process]"==={}.toString.call(t),d="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function f(){var e=setTimeout;return function(){return e(h,1)}}var y=new Array(1e3);function h(){for(var e=0;e<o;e+=2)(0,y[e])(y[e+1]),y[e]=void 0,y[e+1]=void 0;o=0}var m,v,g,w,b=void 0;function P(e,t){var n=this,r=new this.constructor(T);void 0===r[k]&&D(r);var o=n._state;if(o){var i=arguments[o-1];s((function(){return q(o,r,i,n._result)}))}else R(n,r,e,t);return r}function _(e){if(e&&"object"==typeof e&&e.constructor===this)return e;var t=new this(T);return S(t,e),t}c?b=function(){return t.nextTick(h)}:p?(v=0,g=new p(h),w=document.createTextNode(""),g.observe(w,{characterData:!0}),b=function(){w.data=v=++v%2}):d?((m=new MessageChannel).port1.onmessage=h,b=function(){return m.port2.postMessage(0)}):b=void 0===l?function(){try{var e=Function("return this")().require("vertx");return void 0!==(i=e.runOnLoop||e.runOnContext)?function(){i(h)}:f()}catch(e){return f()}}():f();var k=Math.random().toString(36).substring(2);function T(){}function C(t,n,r){n.constructor===t.constructor&&r===P&&n.constructor.resolve===_?function(e,t){1===t._state?M(e,t._result):2===t._state?O(e,t._result):R(t,void 0,(function(t){return S(e,t)}),(function(t){return O(e,t)}))}(t,n):void 0===r?M(t,n):e(r)?function(e,t,n){s((function(e){var r=!1,o=function(e,t,n,r){try{e.call(t,n,r)}catch(e){return e}}(n,t,(function(n){r||(r=!0,t!==n?S(e,n):M(e,n))}),(function(t){r||(r=!0,O(e,t))}),e._label);!r&&o&&(r=!0,O(e,o))}),e)}(t,n,r):M(t,n)}function S(e,t){if(e===t)O(e,new TypeError("You cannot resolve a promise with itself"));else if(o=typeof(r=t),null===r||"object"!==o&&"function"!==o)M(e,t);else{var n=void 0;try{n=t.then}catch(t){return void O(e,t)}C(e,t,n)}var r,o}function A(e){e._onerror&&e._onerror(e._result),E(e)}function M(e,t){void 0===e._state&&(e._result=t,e._state=1,0!==e._subscribers.length&&s(E,e))}function O(e,t){void 0===e._state&&(e._state=2,e._result=t,s(A,e))}function R(e,t,n,r){var o=e._subscribers,i=o.length;e._onerror=null,o[i]=t,o[i+1]=n,o[i+2]=r,0===i&&e._state&&s(E,e)}function E(e){var t=e._subscribers,n=e._state;if(0!==t.length){for(var r=void 0,o=void 0,i=e._result,a=0;a<t.length;a+=3)r=t[a],o=t[a+n],r?q(n,r,o,i):o(i);e._subscribers.length=0}}function q(t,n,r,o){var i=e(r),a=void 0,s=void 0,l=!0;if(i){try{a=r(o)}catch(e){l=!1,s=e}if(n===a)return void O(n,new TypeError("A promises callback cannot return that same promise."))}else a=o;void 0!==n._state||(i&&l?S(n,a):!1===l?O(n,s):1===t?M(n,a):2===t&&O(n,a))}var x=0;function D(e){e[k]=x++,e._state=void 0,e._result=void 0,e._subscribers=[]}var j=function(){function e(e,t){this._instanceConstructor=e,this.promise=new e(T),this.promise[k]||D(this.promise),r(t)?(this.length=t.length,this._remaining=t.length,this._result=new Array(this.length),0===this.length?M(this.promise,this._result):(this.length=this.length||0,this._enumerate(t),0===this._remaining&&M(this.promise,this._result))):O(this.promise,new Error("Array Methods must be provided an Array"))}return e.prototype._enumerate=function(e){for(var t=0;void 0===this._state&&t<e.length;t++)this._eachEntry(e[t],t)},e.prototype._eachEntry=function(e,t){var n=this._instanceConstructor,r=n.resolve;if(r===_){var o=void 0,i=void 0,a=!1;try{o=e.then}catch(e){a=!0,i=e}if(o===P&&void 0!==e._state)this._settledAt(e._state,t,e._result);else if("function"!=typeof o)this._remaining--,this._result[t]=e;else if(n===N){var s=new n(T);a?O(s,i):C(s,e,o),this._willSettleAt(s,t)}else this._willSettleAt(new n((function(t){return t(e)})),t)}else this._willSettleAt(r(e),t)},e.prototype._settledAt=function(e,t,n){var r=this.promise;void 0===r._state&&(this._remaining--,2===e?O(r,n):this._result[t]=n),0===this._remaining&&M(r,this._result)},e.prototype._willSettleAt=function(e,t){var n=this;R(e,void 0,(function(e){return n._settledAt(1,t,e)}),(function(e){return n._settledAt(2,t,e)}))},e}(),N=function(){function t(e){this[k]=x++,this._result=this._state=void 0,this._subscribers=[],T!==e&&("function"!=typeof e&&function(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}(),this instanceof t?function(e,t){try{t((function(t){S(e,t)}),(function(t){O(e,t)}))}catch(t){O(e,t)}}(this,e):function(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}())}return t.prototype.catch=function(e){return this.then(null,e)},t.prototype.finally=function(t){var n=this.constructor;return e(t)?this.then((function(e){return n.resolve(t()).then((function(){return e}))}),(function(e){return n.resolve(t()).then((function(){throw e}))})):this.then(t,t)},t}();return N.prototype.then=P,N.all=function(e){return new j(this,e).promise},N.race=function(e){var t=this;return r(e)?new t((function(n,r){for(var o=e.length,i=0;i<o;i++)t.resolve(e[i]).then(n,r)})):new t((function(e,t){return t(new TypeError("You must pass an array to race."))}))},N.resolve=_,N.reject=function(e){var t=new this(T);return O(t,e),t},N._setScheduler=function(e){a=e},N._setAsap=function(e){s=e},N._asap=s,N.polyfill=function(){var e=void 0;if(void 0!==n)e=n;else if("undefined"!=typeof self)e=self;else try{e=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var t=e.Promise;if(t){var r=null;try{r=Object.prototype.toString.call(t.resolve())}catch(e){}if("[object Promise]"===r&&!t.cast)return}e.Promise=N},N.Promise=N,N},e.exports=r()}).call(this,n(4),n(5))},function(e,t,n){(function(e){var n,r,o,i;function a(e){return(a="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})(e)}i=function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),window.ApplePaySession&&(t.PaymentRequest=function(){function e(e,t,n){this.paymentRequestID="",this.shippingAddress=null,this.shippingOption="",this.shippingType="shipping",this.paymentResolver=null,this.paymentRejector=null,this.onshippingaddresschange=null,this.onshippingoptionchange=null,this.onpaymentmethodselected=null,this.validationEndpoint="",this.merchantIdentifier="";var r=!1;this.paymentRequest={countryCode:"",currencyCode:"",lineItems:[],merchantCapabilities:["supports3DS"],supportedNetworks:[],total:null,billingContact:null,requiredBillingContactFields:[],requiredShippingContactFields:[],shippingContact:null,shippingMethods:[],shippingType:"shipping"};for(var o,i=0,a=e;i<a.length;i++)if(-1<(o=a[i]).supportedMethods.indexOf("https://apple.com/apple-pay")){this.paymentRequest.supportedNetworks=o.data.supportedNetworks,this.paymentRequest.countryCode=o.data.countryCode,o.data.billingContact?this.paymentRequest.billingContact=o.data.billingContact:delete this.paymentRequest.billingContact,o.data.shippingContact?this.paymentRequest.shippingContact=o.data.shippingContact:delete this.paymentRequest.shippingContact,o.data.merchantCapabilities&&(this.paymentRequest.merchantCapabilities=o.data.merchantCapabilities),this.validationEndpoint=o.data.validationEndpoint,this.merchantIdentifier=o.data.merchantIdentifier,r=!0;break}if(!r)throw"Payment method not specified for Apple Pay.";t&&(n&&!0!==n.requestShipping&&delete t.shippingOptions,this.updatePaymentDetails(t),this.paymentRequest.shippingMethods&&this.paymentRequest.shippingMethods.length&&(this.shippingOption=this.convertShippingMethod(this.paymentRequest.shippingMethods[0]))),n&&(n.requestShipping&&(this.paymentRequest.requiredBillingContactFields.push("postalAddress"),this.paymentRequest.requiredShippingContactFields.push("postalAddress")),n.requestPayerName&&this.paymentRequest.requiredShippingContactFields.push("name"),n.requestPayerEmail&&this.paymentRequest.requiredShippingContactFields.push("email"),n.requestPayerPhone&&this.paymentRequest.requiredShippingContactFields.push("phone"),this.paymentRequest.shippingType="pickup"===n.shippingType?"servicePickup":n.shippingType||"shipping"),this.session=new ApplePaySession(2,this.paymentRequest),this.session.addEventListener("validatemerchant",this.onValidateMerchant.bind(this)),this.session.addEventListener("paymentauthorized",this.onPaymentAuthorized.bind(this)),this.session.addEventListener("paymentmethodselected",this.onPaymentMethodSelected.bind(this)),this.session.addEventListener("shippingcontactselected",this.onShippingAddressChange.bind(this)),this.session.addEventListener("shippingmethodselected",this.onShippingOptionChange.bind(this)),this.session.addEventListener("cancel",this.onPaymentCanceled.bind(this))}return e.prototype.updatePaymentDetails=function(e){if(e.displayItems){this.paymentRequest.lineItems=[];for(var t=0,n=e.displayItems;t<n.length;t++){var r=n[t],o={type:!0===r.isAmountPending?"pending":"final",label:r.label,amount:r.amount.value};this.paymentRequest.lineItems.push(o)}}if(e.shippingOptions){this.paymentRequest.shippingMethods=[];for(var i=0,a=e.shippingOptions;i<a.length;i++){var s=a[i],l={label:s.label,detail:s.detail||"",amount:s.amount.value,identifier:s.id};this.paymentRequest.shippingMethods.push(l)}}if(!e.total)throw"`total` is required parameter for `PaymentDetails`.";this.paymentRequest.currencyCode=e.total.amount.currency,this.paymentRequest.total={type:!0===e.total.isAmountPending?"pending":"final",label:e.total.label,amount:e.total.amount.value}},e.prototype.updatePaymentMethod=function(){},e.prototype.convertPaymentAddress=function(e){return{country:e.countryCode||"",addressLine:e.addressLines||[],region:e.administrativeArea||"",city:e.locality||"",dependentLocality:"",postalCode:e.postalCode||"",sortingCode:e.country||"",languageCode:"",organization:"",recipient:e.givenName+" "+e.familyName,phone:e.phoneNumber||""}},e.prototype.convertShippingMethod=function(e){for(var t,n=0,r=this.paymentRequest.shippingMethods;n<r.length;n++)if(t=r[n],e.identifier===t.identifier)return t.identifier;return""},e.prototype.convertPaymentResponse=function(e){var t=e.shippingContact?this.convertPaymentAddress(e.shippingContact):void 0,n=e.billingContact?this.convertPaymentAddress(e.billingContact):void 0,r=e.shippingContact||{},o=e.billingContact?e.billingContact.givenName+" "+e.billingContact.familyName:void 0;return{details:{billingAddress:n},methodName:"https://apple.com/apple-pay",payerEmail:r.emailAddress,payerName:o,payerPhone:r.phoneNumber,shippingAddress:t,shippingOption:this.shippingOption,applePayRaw:e,complete:this.onPaymentComplete.bind(this)}},e.prototype.show=function(){var e=this;return this.session.begin(),new Promise((function(t,n){e.paymentResolver=function(e){t(e)},e.paymentRejector=function(e){n(e)}}))},e.prototype.abort=function(){this.session.abort()},e.prototype.canMakePayment=function(){if(this.merchantIdentifier)return ApplePaySession.canMakePaymentsWithActiveCard(this.merchantIdentifier);throw"`merchantIdentifier` is not specified."},e.prototype.completeMerchantValidation=function(e){this.session.completeMerchantValidation(e)},e.prototype.completePaymentMethodSelection=function(e,t){this.session.completePaymentMethodSelection(e,t)},e.prototype.addEventListener=function(e,t){if("shippingaddresschange"!==e&&"shippingoptionchange"!==e&&"paymentmethodselected"!==e&&"validatemerchant"!==e)throw'Unknown event type "'+e+'" for `addEventListener`.';this["on"+e]=t},e.prototype.onValidateMerchant=function(e){if(e.stopPropagation(),this.onvalidatemerchant)this.onvalidatemerchant(e);else{var t=new Headers({"Content-Type":"application/json"});fetch(this.validationEndpoint,{method:"POST",headers:t,body:JSON.stringify({validationURL:e.validationURL})}).then((function(e){if(200===e.status)return e.json();throw"Merchant validation error."})).then((function(e){this.completeMerchantValidation(e)})).catch((function(e){throw e}))}},e.prototype.onPaymentMethodSelected=function(e){if(e.stopPropagation(),this.onpaymentmethodselected)this.onpaymentmethodselected(e);else{var t=this.paymentRequest.total,n=this.paymentRequest.lineItems;this.session.completePaymentMethodSelection(t,n)}},e.prototype.onShippingAddressChange=function(e){var t=this;if(this.onshippingaddresschange){e.stopPropagation();var n=e.shippingContact;this.shippingAddress=this.convertPaymentAddress(n),this.onshippingaddresschange({updateWith:function(e){Promise.resolve(e).then((function(e){t.updatePaymentDetails(e),t.session.completeShippingContactSelection(ApplePaySession.STATUS_SUCCESS,t.paymentRequest.shippingMethods,t.paymentRequest.total,t.paymentRequest.lineItems)}),(function(e){t.updatePaymentDetails(e),t.session.completeShippingContactSelection(ApplePaySession.STATUS_FAILURE,t.paymentRequest.shippingMethods,t.paymentRequest.total,t.paymentRequest.lineItems)}))}})}},e.prototype.onShippingOptionChange=function(e){var t=this;if(this.onshippingoptionchange){e.stopPropagation();var n=e.shippingMethod;this.shippingOption=this.convertShippingMethod(n),this.onshippingoptionchange({updateWith:function(e){Promise.resolve(e).then((function(e){t.updatePaymentDetails(e),t.session.completeShippingMethodSelection(ApplePaySession.STATUS_SUCCESS,t.paymentRequest.total,t.paymentRequest.lineItems)}),(function(e){t.updatePaymentDetails(e),t.session.completeShippingMethodSelection(ApplePaySession.STATUS_FAILURE,null,null)}))}})}},e.prototype.onPaymentAuthorized=function(e){if(this.paymentResolver){var t=this.convertPaymentResponse(e.payment);this.paymentResolver(t),this.paymentResolver=null,this.paymentRejector=null}},e.prototype.onPaymentCanceled=function(e){this.paymentRejector&&(this.paymentRejector(e),this.paymentResolver=null,this.paymentRejector=null)},e.prototype.onPaymentComplete=function(e){if("success"!==e&&"fail"!==e&&"unknown"!==e&&""!==e)throw"Unkown status code for complete().";var t="success"===e?ApplePaySession.STATUS_SUCCESS:"fail"===e||"unknown"===e?ApplePaySession.STATUS_FAILURE:ApplePaySession.STATUS_SUCCESS;this.session.completePayment(t)},e}())}])},"object"==a(t)&&"object"==a(e)?e.exports=i():(r=[],void 0===(o="function"==typeof(n=i)?n.apply(t,r):n)||(e.exports=o))}).call(this,n(6)(e))},function(e,t){e.exports=function(){throw new Error("define cannot be used indirect")}},function(e,t){var n,r,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{r="function"==typeof clearTimeout?clearTimeout:a}catch(e){r=a}}();var l,u=[],p=!1,c=-1;function d(){p&&l&&(p=!1,l.length?u=l.concat(u):c=-1,u.length&&f())}function f(){if(!p){var e=s(d);p=!0;for(var t=u.length;t;){for(l=u,u=[];++c<t;)l&&l[c].run();c=-1,t=u.length}l=null,p=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===a||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function y(e,t){this.fun=e,this.array=t}function h(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];u.push(new y(e,t)),1!==u.length||p||s(f)},y.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=h,o.addListener=h,o.once=h,o.off=h,o.removeListener=h,o.removeAllListeners=h,o.emit=h,o.prependListener=h,o.prependOnceListener=h,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){"use strict";n.r(t);var r,o,i,a=n(0),s=n.n(a),l=n(1);(o=r||(r={})).production="production",o.sandbox="sandboox";var u=function(e){i=e},p=function(e){return i[e]},c="https://js.tappaysdk.com",d={en:"Pay Now",zh:"付款"},f={VISA:1,MASTERCARD:2,JCB:3,UNIONPAY:4,AMEX:5},y={VI:1,MC:2},h={CREDIT:0,DEBIT:1,PREPAID:2},m=0,v=1,g=2,w="card-number",b="expiration-date",P="ccv",_=n(2),k={amex:/^3[47]\d{0,13}/,mastercard:/(^(5[1-5]|2[3-6])\d{0,14})|^(((222[1-9])|(2720))\d{0,12})|^(((22[3-9])|(27[0-1]))\d{0,13})/,jcb:/^(?:2131|1800|35\d{0,2})\d{0,12}/,visa:/^4\d{0,15}/,unionpay:/^(62[0-9]{14,17})$/},T={amex:"AMEX",mastercard:"MASTERCARD",jcb:"JCB",visa:"VISA",unionpay:"UNIONPAY",unknown:"UNKNOWN"},C=function(){return T},S=function(e){return!!T[(e+"").toLowerCase()]},A=function(){return{lower:T.unknown.toLowerCase(),upper:T.unknown}},M=C(),O=function(e){for(var t=[0,2,4,6,8,1,3,5,7,9],n=e.length,r=0,o=0;0<n--;)r+=(o^=1)?e.charCodeAt(n)-48:t[e.charCodeAt(n)-48];return 0==r%10},R=function(e,t){return e=(e+"").replace(/\s+|-/g,""),void 0===t?/^\d{15,19}$/.test(e)&&O(e):t===M.amex?/^\d{15}$/.test(e)&&O(e):/^\d{16,19}$/.test(e)&&O(e)},E=function(e,t){var n,r,o=e;return t+="",!!/^\d+$/.test(o+="")&&!!/^\d+$/.test(t)&&1<=o&&12>=o&&(2===t.length&&(t="20"+t),4===t.length&&(r=new Date(t,o),n=new Date,r.setMonth(r.getMonth()-1),r.setMonth(r.getMonth()+1,1),r>n))},q=function(e){for(var t in k)if(!0===k[t].test(e))return M[t];return"Unknown"},x=function(e,t){return void 0===t?/^\d{3,4}$/.test(e):t===M.amex?/^\d{4}$/.test(e):/^\d{3}$/.test(e)};function D(e){return(D="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})(e)}function j(e,t){for(var n,r=0;r<t.length;r++)(n=t[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function N(e,t){if(t&&("object"===D(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)}function I(e){var t="function"==typeof Map?new Map:void 0;return(I=function(e){function n(){return W(e,arguments,U(this).constructor)}if(null===e||!function(e){return-1!==Function.toString.call(e).indexOf("[native code]")}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),L(n,e)})(e)}function W(){return(W=F()?Reflect.construct.bind():function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&L(o,n.prototype),o}).apply(null,arguments)}function F(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function L(e,t){return(L=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function U(e){return(U=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var z=function(e){function t(e,r){var o;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(o=n.call(this,e)).name=r,o}!function(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&&L(e,t)}(t,e);var n=function(e){var t=F();return function(){var n,r=U(e);if(t){var o=U(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return N(this,n)}}(t);return function(e,t,n){t&&j(e.prototype,t),n&&j(e,n),Object.defineProperty(e,"prototype",{writable:!1})}(t,[{key:"toJSON",value:function(){var e={};return Object.getOwnPropertyNames(this).forEach((function(t){e[t]=this[t]}),this),e}}]),t}(I(Error));function B(e){return(B="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})(e)}function V(e,t){for(var n,r=0;r<t.length;r++)(n=t[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function Y(e,t){return(Y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function G(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=J(e);if(t){var o=J(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return K(this,n)}}function K(e,t){if(t&&("object"===B(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)}function J(e){return(J=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var H=function(e){function t(e){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),n.call(this,e,"TapPayNetworkError")}!function(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&&Y(e,t)}(t,e);var n=G(t);return function(e,t,n){return t&&V(e.prototype,t),n&&V(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}(t)}(z);function X(e){return(X="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})(e)}function $(e,t){for(var n,r=0;r<t.length;r++)(n=t[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function Z(e,t){return(Z=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function Q(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=te(e);if(t){var o=te(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return ee(this,n)}}function ee(e,t){if(t&&("object"===X(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)}function te(e){return(te=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var ne=function(e){function t(e){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),n.call(this,e,"TapPaySDKError")}!function(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&&Z(e,t)}(t,e);var n=Q(t);return function(e,t,n){return t&&$(e.prototype,t),n&&$(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}(t)}(z),re=function(e){if("TapPaySDKError"===e.name){var t=new ne(e.message);return t.stack=e.stack,t}if("TapPayNetworkError"===e.name){var n=new H(e.message);return n.stack=e.stack,n}return e},oe=null,ie=null,ae={},se=function(){return ae},le=function(){return oe},ue=function(e){oe.contentWindow.postMessage(JSON.stringify(e),c)},pe=[c,"https://fraud.tappaysdk.com"],ce=new Map;ce.set("send_device_id",[]),ce.set("fraud_id",[]),ce.set("iframe_get_prime_ready",[]),ce.set("setup_payment_request_done",[]),ce.set("payment_request_not_support_in_iframe",[]),ce.set("payment_request_get_prime_done",[]),ce.set("payment_request_apple_pay_get_prime_done",[]),ce.set("apple_pay_get_session_done",[]),ce.set("samsung_pay_iframe_result",[]),ce.set("line_pay_get_prime_done",[]),ce.set("jko_pay_get_prime_done",[]),ce.set("easy_wallet_get_prime_done",[]),ce.set("google_pay_get_prime_done",[]),ce.set("apple_pay_get_prime_done",[]),ce.set("update",[]),ce.set("cardtype-change",[]),ce.set("field-focus-change",[]),ce.set("field-status-change",[]),ce.set("get_prime_for_tappay_fields_done",[]),ce.set("get_prime_for_card_view_done",[]),ce.set("get_prime_for_ccv_prime_done",[]),ce.set("ccv_prime_field_ready",[]),ce.set("ccv_field_ready",[]),ce.set("atome_get_prime_done",[]),ce.set("pi_wallet_get_prime_done",[]),ce.set("plus_pay_get_prime_done",[]),ce.set("pay_later_get_prime_done",[]);var de=function(e,t){if(ce.has(e)){var n=ce.get(e);n.push(t),ce.set(e,n)}},fe=function(e,t){return e.classList?e.classList.contains(t):!!e.className.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))},ye=function(e){return"function"!=typeof e},he=function(e){return e instanceof Element},me=function(e){return!(e instanceof Element)},ve=function(e){return void 0!==e},ge=function(e){return void 0===e},we=function(e){return"string"==typeof e},be=function(e){return"string"!=typeof e},Pe=function(e){return"boolean"!=typeof e},_e=function(e){return"number"!=typeof e},ke=function(e){return 0>e},Te=function(e,t){return e>t},Ce=function(e,t){e.classList?e.classList.add(t):!fe(e,t)&&(e.className+=" "+t)},Se=function(e){var t,n=window.location.origin;if(null!==URL&&ve(URL))try{t=new URL(e)}catch(e){return!1}else(t=document.createElement("a")).href=n;return("https://sandbox-redirect.tappaysdk.com"===t.origin||"https://prod-redirect.tappaysdk.com"===t.origin)&&"https:"===t.protocol},Ae=function(e){try{var t=e.token.paymentData;if(!t)return!1;if(!t.data||be(t.data))return!1;if(!t.version||be(t.version))return!1;if(!t.signature||be(t.signature))return!1;if(!t.header)return!1;if(!t.header.publicKeyHash||be(t.header.publicKeyHash))return!1;if(!t.header.ephemeralPublicKey||be(t.header.ephemeralPublicKey))return!1;if(!t.header.transactionId||be(t.header.transactionId))return!1}catch(e){return!1}return!0},Me=function(){return window.ApplePaySession?ApplePaySession.canMakePayments()?!("https:"!==location.protocol&&(console.warn("[TapPay] Trying to call an ApplePaySession API from an insecure document."),1)):(console.warn("[TapPay] User Can Not Use Apple Pay"),!1):(console.warn("[TapPay] Your Browser Did Not Support Apple Pay"),!1)},Oe=function(){var e;try{e=(navigator.languages&&navigator.languages.length?navigator.languages[0]:navigator.userLanguage?navigator.userLanguage:navigator.language).split("-")[0].toLowerCase()}catch(e){return d.en}var t=d[e];return t||d.en},Re=function(e){if(!e)return null;var t=e.toUpperCase();return ve(y[t])?y[t]:null},Ee=function(e){var t=e.toUpperCase();return ve(f[t])?f[t]:null},qe=function(e){var t=e.toUpperCase();return ve(h[t])?h[t]:null},xe=function(e){return new Promise((function(t,n){e((function(e,r){return e?void n(e):void t(r)}))}))};function De(e,t){for(var n,r=0;r<t.length;r++)(n=t[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function je(e,t,n){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,n)}function Ne(e,t,n){return function(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}}(e,We(e,t,"set"),n),n}function Ie(e,t){return function(e,t){return t.get?t.get.call(e):t.value}(e,We(e,t,"get"))}function We(e,t,n){if(!t.has(e))throw new TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}var Fe=new WeakMap,Le=new WeakMap,Ue=new WeakMap,ze=new WeakMap,Be=function(){function e(){var t=this;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),je(this,Fe,{writable:!0,value:void 0}),je(this,Le,{writable:!0,value:void 0}),je(this,Ue,{writable:!0,value:void 0}),je(this,ze,{writable:!0,value:function(){de("apple_pay_get_prime_done",(function(e){Ie(t,Ue)&&Ie(t,Ue).call(t,e.err,e.result)})),de("apple_pay_get_session_done",(function(e){Ie(t,Le)&&Ie(t,Le).call(t,e.err,e.result)}))}}),Ie(this,ze).call(this)}return function(e,t,n){t&&De(e.prototype,t),n&&De(e,n),Object.defineProperty(e,"prototype",{writable:!1})}(e,[{key:"checkAvailability",value:function(){return Me()}},{key:"canMakePaymentsWithActiveCard",value:function(e,t){return Me()?void ApplePaySession.canMakePaymentsWithActiveCard(e).then((function(e){t({browserSupportPaymentRequest:!0,canMakePaymentWithActiveCard:e,canMakePaymentError:null})})).catch((function(e){t({browserSupportPaymentRequest:!0,canMakePaymentWithActiveCard:!1,canMakePaymentError:e})})):t({browserSupportPaymentRequest:!1,canMakePaymentWithActiveCard:!1,canMakePaymentError:null})}},{key:"buildSession",value:function(e){var t=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",r=2<arguments.length?arguments[2]:void 0,o=3<arguments.length?arguments[3]:void 0;return"https:"===window.location.protocol?(Ne(this,Fe,new ApplePaySession(1,e)),Ie(this,Fe).onvalidatemerchant=function(e){var r={appId:p("appID"),appKey:p("appKey"),appName:window.location.hostname,appleMerchantId:n,merchant_domain:window.location.hostname,validationURL:e.validationURL,tappay_endpoint:p("endPoint")};Ne(t,Le,(function(e,n){return e?void o({status:403,msg:"[Apple Pay] Get Session error: ".concat(e.status," ").concat(e.msg)}):void Ie(t,Fe).completeMerchantValidation(n)})),ue({event:"apple_pay_get_session",payload:r})},Ie(this,Fe).onpaymentauthorized=function(e){var i=e.payment;if(!Ae(i))return o({status:402,msg:"Parsing Apple Pay result happen error"}),Ie(t,Fe).completePayment(ApplePaySession.STATUS_FAILURE);var a=function(e){Ie(t,Fe).completePayment(e)};Ne(t,Ue,(function(t,n){return t?o(t):0===n.status?void r(n.prime,e,a):o(n)}));var s={app_id:p("appID"),app_key:p("appKey"),app_name:window.location.hostname,pay_token_data:i.token.paymentData,apple_merchant_id:n,platform_type:"2"};ue({event:"apple_pay_get_prime",parameter:s})},Ie(this,Fe)):console.warn("[TapPay] Trying to call an ApplePaySession API from an insecure document.")}}]),e}();function Ve(e,t){for(var n,r=0;r<t.length;r++)(n=t[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function Ye(e,t,n){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,n)}function Ge(e,t){return function(e,t){return t.get?t.get.call(e):t.value}(e,Je(e,t,"get"))}function Ke(e,t,n){return function(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}}(e,Je(e,t,"set"),n),n}function Je(e,t,n){if(!t.has(e))throw new TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}var He=new WeakMap,Xe=new WeakMap,$e=new WeakMap,Ze=new WeakMap,Qe=new WeakMap,et=new WeakMap,tt=new WeakMap,nt=new WeakMap,rt=function(){function e(t){var n=this;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),Ye(this,He,{writable:!0,value:void 0}),Ye(this,Xe,{writable:!0,value:void 0}),Ye(this,$e,{writable:!0,value:void 0}),Ye(this,Ze,{writable:!0,value:void 0}),Ye(this,Qe,{writable:!0,value:void 0}),Ye(this,et,{writable:!0,value:void 0}),Ye(this,tt,{writable:!0,value:void 0}),Ye(this,nt,{writable:!0,value:function(){de("update",(function(e){Ke(n,tt,e.result),Ge(n,Qe).call(n,e.result)})),de("cardtype-change",(function(e){if("tappay-field"===e.field_type){Ge(n,et).cardType=e.result;var t=n.formatTappayFieldUpdate();Ge(n,Qe).call(n,t)}})),de("field-focus-change",(function(e){if("tappay-field"===e.field_type){var t=e.result,r=Ge(n,et)[t.type].el;"focus"===t.state?Ce(r,"tappay-field-focus"):function(e,t){if(e.classList)e.classList.remove(t);else if(fe(e,t)){var n=new RegExp("(\\s|^)"+t+"(\\s|$)");e.className=e.className.replace(n," ")}}(r,"tappay-field-focus")}})),de("field-status-change",(function(e){if("tappay-field"===e.field_type){var t=e.result,r=Ge(n,et).status;t.type===w?r.number=t.status:t.type===b?r.expiry=t.status:t.type===P&&(r.ccv=t.status);var o=n.formatTappayFieldUpdate();Ge(n,Qe).call(n,o)}})),de("get_prime_for_tappay_fields_done",(function(e){Ge(n,$e).call(n,e.result)})),de("get_prime_for_card_view_done",(function(e){Ge(n,Ze).call(n,e.result)}))}}),Ke(this,He,t),Ke(this,Qe,(function(e){return e})),Ge(this,nt).call(this)}return function(e,t,n){t&&Ve(e.prototype,t),n&&Ve(e,n),Object.defineProperty(e,"prototype",{writable:!1})}(e,[{key:"setup",value:function(e,t,n){if(we(e)&&(e=document.querySelector(e)),!e)return console.error("[TapPay] TPDirect.card.setup(element): Missing element param");if(me(e)){var r=e;this.setupTappayFields(r)}else{if(n&&(void 0!==n.isMaskCreditCardNumber||n.isMaskCreditCardNumber)){if(Pe(n.isMaskCreditCardNumber))return console.error("[TapPay] TPDirect.card.setup: failed to setup TapPay fields isMaskCreditCardNumber type error");if(n.isMaskCreditCardNumber){if(_e(n.maskCreditCardNumberRange.beginIndex)||_e(n.maskCreditCardNumberRange.endIndex))return console.error("[TapPay] TPDirect.card.setup: failed to setup TapPay fields maskCreditCardNumberRange type error");if(ke(n.maskCreditCardNumberRange.beginIndex)||ke(n.maskCreditCardNumberRange.endIndex)||Te(n.maskCreditCardNumberRange.beginIndex,n.maskCreditCardNumberRange.endIndex))return console.error("[TapPay] TPDirect.card.setup: failed to setup TapPay fields maskCreditCardNumberRange error")}}var o={appKey:p("appKey"),appID:p("appID"),serverType:p("type"),hostname:window.location.hostname,origin:window.location.origin,style:t,config:n||{isUsedCcv:!0,isMaskCreditCardNumber:!1}};Ke(this,Xe,document.createElement("iframe")),Ge(this,Xe).setAttribute("frameborder","0"),Ge(this,Xe).setAttribute("allowtransparency","true"),Ge(this,Xe).setAttribute("scrolling","no"),Ge(this,Xe).style.border="none",Ge(this,Xe).style.margin="0px",Ge(this,Xe).style.padding="0px",Ge(this,Xe).style.width="1px",Ge(this,Xe).style.minWidth="100%",Ge(this,Xe).style.overflow="hidden",Ge(this,Xe).style.display="block",Ge(this,Xe).style.height="24px",t&&t.lineHeight&&(Ge(this,Xe).style.height=t.lineHeight),Ge(this,Xe).src="https://js.tappaysdk.com/sdk/tpdirect/card-view/html/v5.17.0?"+encodeURIComponent(JSON.stringify(o)),e.appendChild(Ge(this,Xe))}}},{key:"setupTappayFields",value:function(e){if(void 0!==e.isMaskCreditCardNumber||e.isMaskCreditCardNumber){if(Pe(e.isMaskCreditCardNumber))return console.error("[TapPay] TPDirect.card.setup: failed to setup TapPay fields isMaskCreditCardNumber type error");if(e.isMaskCreditCardNumber){if(_e(e.maskCreditCardNumberRange.beginIndex)||_e(e.maskCreditCardNumberRange.endIndex))return console.error("[TapPay] TPDirect.card.setup: failed to setup TapPay fields maskCreditCardNumberRange type error");if(ke(e.maskCreditCardNumberRange.beginIndex)||ke(e.maskCreditCardNumberRange.endIndex)||Te(e.maskCreditCardNumberRange.beginIndex,e.maskCreditCardNumberRange.endIndex))return console.error("[TapPay] TPDirect.card.setup: failed to setup TapPay fields maskCreditCardNumberRange error")}}Ge(this,et)&&(Ge(this,et)["card-number"].iframe.remove(),Ge(this,et)["expiration-date"].iframe.remove(),Ge(this,et).ccv&&Ge(this,et).ccv.iframe.remove());var t=this.setupTappayField(e.fields.number.element,{origin:window.location.origin,type:w,placeholder:e.fields.number.placeholder,styles:e.styles,field_type:"tappay-field",isMaskCreditCardNumber:e.isMaskCreditCardNumber,maskCreditCardNumberRange:e.maskCreditCardNumberRange}),n=this.setupTappayField(e.fields.expirationDate.element,{origin:window.location.origin,type:b,placeholder:e.fields.expirationDate.placeholder,styles:e.styles,field_type:"tappay-field",isMaskCreditCardNumber:e.isMaskCreditCardNumber,maskCreditCardNumberRange:e.maskCreditCardNumberRange}),r=null;void 0!==e.fields.ccv&&(r=this.setupTappayField(e.fields.ccv.element,{origin:window.location.origin,type:P,placeholder:e.fields.ccv.placeholder,styles:e.styles,field_type:"tappay-field",isMaskCreditCardNumber:e.isMaskCreditCardNumber,maskCreditCardNumberRange:e.maskCreditCardNumberRange}));var o=!t||!n;return(o=null==r?o:o||!r)?void console.error("[TapPay] TPDirect.card.setup: failed to setup TapPay fields"):void Ke(this,et,{"card-number":t,"expiration-date":n,ccv:r,cardType:"unknown",status:{number:v,expiry:v,ccv:v}})}},{key:"setupTappayField",value:function(e,t){if(we(e)&&(e=document.querySelector(e)),!me(e)){var n=document.createElement("iframe");return n.setAttribute("frameborder","0"),n.setAttribute("allowtransparency","true"),n.setAttribute("scrolling","no"),n.style.border="none",n.style.width="100%",n.style.height="100%",n.style.float="left",n.src="https://js.tappaysdk.com/sdk/tpdirect/tappay-field/html/v5.17.0?"+encodeURIComponent(JSON.stringify(t)),e.appendChild(n),{el:e,iframe:n}}console.warn("[TapPay] TPDirect.card.setup(): Cannot find element for "+t.type)}},{key:"onUpdate",value:function(e){return ye(e)?console.error("[TapPay] TPDirect.card.onUpdate(callback): callback in not a function"):void Ke(this,Qe,e)}},{key:"getPrime",value:function(e){return ye(e)?console.error("[TapPay] TPDirect.card.getPrime(callback): callback is not a function"):Ge(this,et)?this.getPrimeForTappayFields(e):Ge(this,Xe)?void this.getPrimeForCardView(e):console.error("[TapPay] You need to call TPDirect.card.setup(element) first")}},{key:"getTappayFieldsStatus",value:function(){return this.formatTappayFieldUpdate()}},{key:"getPrimeForTappayFields",value:function(e){return this.formatTappayFieldUpdate().canGetPrime?(Ke(this,$e,e),void ue({event:"get_prime_for_tappay_fields"})):e({status:-5,msg:"[Direct Pay - Fields] canGetPrime is false, not ready to get prime, please use TPDirect.card.getTappayFieldsStatus() to retrive canGetPrime parameter, or detect the canGetPrime parameter with TPDirect.card.onUpdate function"})}},{key:"getPrimeForCardView",value:function(e){return Ge(this,tt)&&Ge(this,tt).canGetPrime?(Ke(this,Ze,e),void ue({event:"get_prime_for_card_view"})):e({status:-5,msg:"[Direct Pay - Card View] canGetPrime is false, not ready to get prime, please listen to update with TPDirect.card.onUpdate"})}},{key:"validate",value:function(e,t,n,r){var o=q(e);return{cardType:o,isCardNumberValid:R(e,o),isExpiryDateValid:E(t,n),isCCVValid:x(r,o)}}},{key:"formatTappayFieldUpdate",value:function(){var e=Ge(this,et).status,t=Ge(this,et).cardType,n=null!=Ge(this,et).ccv,r=e.number===m&&e.expiry===m,o=e.number===g||e.expiry===g;return n?(r=r&&e.ccv===m,o=o||e.ccv===g):e.ccv=m,{canGetPrime:r,hasError:o,cardType:t,status:e}}}]),e}();function ot(e,t){for(var n,r=0;r<t.length;r++)(n=t[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function it(e,t,n){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,n)}function at(e,t,n){return function(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}}(e,lt(e,t,"set"),n),n}function st(e,t){return function(e,t){return t.get?t.get.call(e):t.value}(e,lt(e,t,"get"))}function lt(e,t,n){if(!t.has(e))throw new TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}var ut=new WeakMap,pt=new WeakMap,ct=new WeakMap,dt=new WeakMap,ft=function(){function e(){var t=this;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),it(this,ut,{writable:!0,value:!1}),it(this,pt,{writable:!0,value:void 0}),it(this,ct,{writable:!0,value:function(e){if(le())at(t,pt,(function(t,n){return t?void e(t,null):void e(null,n)})),st(t,ut)&&ue({event:"easy_wallet_get_prime"});else{var n=new ne("Doesn't load pfirame yet");e(n,null)}}}),it(this,dt,{writable:!0,value:function(){de("easy_wallet_get_prime_done",(function(e){st(t,pt).call(t,e.err,e.result)})),de("iframe_get_prime_ready",(function(){at(t,ut,!0),st(t,pt)&&ue({event:"easy_wallet_get_prime"})}))}}),st(this,dt).call(this)}return function(e,t,n){t&&ot(e.prototype,t),n&&ot(e,n),Object.defineProperty(e,"prototype",{writable:!1})}(e,[{key:"getPrime",value:function(e){return ye(e)?xe(st(this,ct)):void st(this,ct).call(this,e)}},{key:"pay",value:function(e){return Se(e)?void(window.location.href=e):console.error("[TapPay] Your payment url is not valid.")}}]),e}(),yt=["status","prime","msg"];function ht(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],0<=t.indexOf(n)||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],0<=t.indexOf(n)||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function mt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function vt(e){for(var t,n=1;n<arguments.length;n++)t=null==arguments[n]?{}:arguments[n],n%2?mt(Object(t),!0).forEach((function(n){gt(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):mt(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}));return e}function gt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function wt(e,t){for(var n,r=0;r<t.length;r++)(n=t[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function bt(e,t,n){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,n)}function Pt(e,t,n){return function(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}}(e,kt(e,t,"set"),n),n}function _t(e,t){return function(e,t){return t.get?t.get.call(e):t.value}(e,kt(e,t,"get"))}function kt(e,t,n){if(!t.has(e))throw new TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}var Tt=new WeakMap,Ct=new WeakMap,St=new WeakMap,At=new WeakMap,Mt=new WeakMap,Ot=new WeakMap,Rt=new WeakMap,Et=function(){function e(){var t=this;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),bt(this,Tt,{writable:!0,value:void 0}),bt(this,Ct,{writable:!0,value:void 0}),bt(this,St,{writable:!0,value:void 0}),bt(this,At,{writable:!0,value:void 0}),bt(this,Mt,{writable:!0,value:void 0}),bt(this,Ot,{writable:!0,value:void 0}),bt(this,Rt,{writable:!0,value:function(){de("google_pay_get_prime_done",(function(e){_t(t,Ot).call(t,e.error,e.result)}))}}),_t(this,Rt).call(this)}return function(e,t,n){t&&wt(e.prototype,t),n&&wt(e,n),Object.defineProperty(e,"prototype",{writable:!1})}(e,[{key:"setupTransactionPrice",value:function(e){_t(this,Ct).transactionInfo={currencyCode:e.currency,totalPrice:e.price,totalPriceStatus:"FINAL"}}},{key:"setupGooglePay",value:function(e){Pt(this,St,e)}},{key:"setupGooglePayButton",value:function(e){var t=_t(this,At).createButton({buttonColor:e.color,buttonType:e.type,onClick:function(){this.loadPaymentDataAndGetPrime(e.getPrimeCallback)}.bind(this)});document.querySelector(e.el).appendChild(t)}},{key:"setupPaymentRequest",value:function(e,t){var n=this,r="production"===p("type")?"PRODUCTION":"TEST";return google?void(!this.parsePaymentRequestData(e)||(Pt(this,At,new google.payments.api.PaymentsClient({environment:r})),_t(this,At).isReadyToPay(_t(this,Mt)).then((function(e){e.result&&Pt(n,Tt,!0),t(null,{canUseGooglePay:_t(n,Tt)})})).catch((function(e){t(e,{canUseGooglePay:!1})})))):console.error("[TapPay] Please includ the google pay sdk https://pay.google.com/gp/p/js/pay.js in front of tappay sdk")}},{key:"getPrime",value:function(e){this.loadPaymentDataAndGetPrime((function(t,n){e(t,n)}))}},{key:"validateItemInSupportedArray",value:function(e,t){return!!(e instanceof Array)&&e.map((function(e){return-1!==t.indexOf(e)})).every((function(e){return!0===e}))}},{key:"parsePaymentRequestData",value:function(e){var t=_t(this,St),n={apiVersion:2,apiVersionMinor:0},r=e.allowedNetworks,o=t.allowedCardAuthMethods;if(!this.validateItemInSupportedArray(r,["AMEX","DISCOVER","JCB","MASTERCARD","VISA"]))return!1;if(!this.validateItemInSupportedArray(o,["PAN_ONLY","CRYPTOGRAM_3DS"]))return!1;var i={type:"CARD",parameters:{allowPrepaidCards:t.allowPrepaidCards,allowedAuthMethods:o,allowedCardNetworks:r,billingAddressParameters:{format:t.billingAddressFormat,phoneNumberRequired:t.phoneNumberRequired},billingAddressRequired:t.billingAddressRequired}},a=vt({},n);a.allowedPaymentMethods=[i];var s=vt(vt({},i),{},{tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"tappay",gatewayMerchantId:"tappay"}}}),l=vt({},n);return l.allowedPaymentMethods=[s],l.transactionInfo={totalPriceStatus:"FINAL",totalPrice:e.price,currencyCode:e.currency},l.merchantInfo={merchantName:t.merchantName,merchantId:t.googleMerchantId},l.emailRequired=t.emailRequired,l.shippingAddressRequired=t.shippingAddressRequired,l.shippingAddressParameters={allowedCountryCodes:t.allowedCountryCodes,phoneNumberRequired:t.phoneNumberRequired},Pt(this,Mt,a),Pt(this,Ct,l),!0}},{key:"loadPaymentDataAndGetPrime",value:function(e){return _t(this,Tt)?void _t(this,At).loadPaymentData(_t(this,Ct)).then(function(t){ue({event:"google_pay_get_prime",payment_data:t}),Pt(this,Ot,(function(t,n){if(t)e(t,null);else if(0===n.status){n.status;var r=n.prime,o=(n.msg,ht(n,yt));o.merchant_reference_info||(o.merchant_reference_info={affiliate_codes:[]}),e(null,r,o)}else e(n,null)}))}.bind(this)).catch((function(t){e({status:2200,msg:"[Google Pay] Unexcept Error",originalError:t},null)})):console.error("[TapPay] Your device doesn't support Google Pay")}}]),e}();function qt(e,t){for(var n,r=0;r<t.length;r++)(n=t[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function xt(e,t,n){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,n)}function Dt(e,t,n){return function(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}}(e,Nt(e,t,"set"),n),n}function jt(e,t){return function(e,t){return t.get?t.get.call(e):t.value}(e,Nt(e,t,"get"))}function Nt(e,t,n){if(!t.has(e))throw new TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}var It=new WeakMap,Wt=new WeakMap,Ft=new WeakMap,Lt=function(){function e(){var t=this;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),xt(this,It,{writable:!0,value:!1}),xt(this,Wt,{writable:!0,value:void 0}),xt(this,Ft,{writable:!0,value:function(){de("jko_pay_get_prime_done",(function(e){jt(t,Wt).call(t,e.err,e.result)})),de("iframe_get_prime_ready",(function(){Dt(t,It,!0),jt(t,Wt)&&ue({event:"jko_pay_get_prime"})}))}}),jt(this,Ft).call(this)}return function(e,t,n){t&&qt(e.prototype,t),n&&qt(e,n),Object.defineProperty(e,"prototype",{writable:!1})}(e,[{key:"getPrime",value:function(e){return ye(e)?console.error("[TapPay] TPDirect.jkoPay.getPrime(callback): callback is not a function"):le()?(Dt(this,Wt,(function(t,n){return t?void e(t):void e(n)})),void(jt(this,It)&&ue({event:"jko_pay_get_prime"}))):console.error("[TapPay] Doesnt load pfirame yet")}},{key:"pay",value:function(e){return Se(e)?void(window.location.href=e):console.error("[TapPay] Your payment url is not valid.")}}]),e}();function Ut(e,t){for(var n,r=0;r<t.length;r++)(n=t[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function zt(e,t,n){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,n)}function Bt(e,t,n){return function(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}}(e,Yt(e,t,"set"),n),n}function Vt(e,t){return function(e,t){return t.get?t.get.call(e):t.value}(e,Yt(e,t,"get"))}function Yt(e,t,n){if(!t.has(e))throw new TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}var Gt=new WeakMap,Kt=new WeakMap,Jt=new WeakMap,Ht=function(){function e(){var t=this;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),zt(this,Gt,{writable:!0,value:!1}),zt(this,Kt,{writable:!0,value:void 0}),zt(this,Jt,{writable:!0,value:function(){de("line_pay_get_prime_done",(function(e){Vt(t,Kt).call(t,e.err,e.result,e.url)})),de("iframe_get_prime_ready",(function(){Bt(t,Gt,!0),Vt(t,Kt)&&ue({event:"line_pay_get_prime"})}))}}),Vt(this,Jt).call(this)}return function(e,t,n){t&&Ut(e.prototype,t),n&&Ut(e,n),Object.defineProperty(e,"prototype",{writable:!1})}(e,[{key:"getPrime",value:function(e){return ye(e)?console.error("[TapPay] TPDirect.linePay.getPrime(callback): callback is not a function"):le()?(Bt(this,Kt,(function(t,n){return t?void e(t):void e(n)})),void(Vt(this,Gt)&&ue({event:"line_pay_get_prime"}))):console.error("[TapPay] Doesnt load pfirame yet")}},{key:"pay",value:function(e){return Se(e)?void(window.location.href=e):console.error("[TapPay] Your payment url is not valid.")}}]),e}(),Xt=["card_last_four","card_type"];function $t(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],0<=t.indexOf(n)||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],0<=t.indexOf(n)||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function Zt(e,t){for(var n,r=0;r<t.length;r++)(n=t[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function Qt(e,t,n){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,n)}function en(e,t){return function(e,t){return t.get?t.get.call(e):t.value}(e,nn(e,t,"get"))}function tn(e,t,n){return function(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}}(e,nn(e,t,"set"),n),n}function nn(e,t,n){if(!t.has(e))throw new TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}var rn=new WeakMap,on=new WeakMap,an=new WeakMap,sn=new WeakMap,ln=new WeakMap,un=new WeakMap,pn=new WeakMap,cn=new WeakMap,dn=new WeakMap,fn=new WeakMap,yn=new WeakMap,hn=new WeakMap,mn=new WeakMap,vn=new WeakMap,gn=new WeakMap,wn=new WeakMap,bn=function(){function e(){var t=this;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),Qt(this,rn,{writable:!0,value:void 0}),Qt(this,on,{writable:!0,value:void 0}),Qt(this,an,{writable:!0,value:void 0}),Qt(this,sn,{writable:!0,value:void 0}),Qt(this,ln,{writable:!0,value:void 0}),Qt(this,un,{writable:!0,value:void 0}),Qt(this,pn,{writable:!0,value:void 0}),Qt(this,cn,{writable:!0,value:void 0}),Qt(this,dn,{writable:!0,value:void 0}),Qt(this,fn,{writable:!0,value:function(){var e={MODE:"",appKey:p("appKey"),appID:p("appID"),serverType:p("type"),hostname:window.location.hostname,origin:window.location.origin,referrer:document.referrer,href:window.location.href,port:window.location.port,protocol:window.location.protocol,sdk_version:p("sdk_version"),payment_request:en(t,on)};tn(t,ln,document.createElement("iframe")),en(t,ln).setAttribute("frameborder","0"),en(t,ln).setAttribute("allowtransparency","true"),en(t,ln).style.zIndex="2147483647",en(t,ln).style.display="block",en(t,ln).style.background="rgba(0, 0, 0, 0.004)",en(t,ln).style.border="0px none transparent",en(t,ln).style.overflowX="hidden",en(t,ln).style.overflowY="auto",en(t,ln).style.margin="0px",en(t,ln).style.padding="0px",en(t,ln).style.webkitTapHighlightColor="transparent",en(t,ln).style.position="fixed",en(t,ln).style.left="0px",en(t,ln).style.top="0px",en(t,ln).style.width="100%",en(t,ln).style.height="100%",en(t,ln).src="https://js.tappaysdk.com/sdk/tpdirect/samsung-pay/html/v5.17.0?"+encodeURIComponent(JSON.stringify(e)),"complete"===document.readyState||"loaded"===document.readyState||"interactive"===document.readyState?(document.body.appendChild(en(t,ln)),en(t,hn).call(t)):document.addEventListener("DOMContentLoaded",(function(){document.body.appendChild(en(this,ln)),en(this,hn).call(this)}))}}),Qt(this,yn,{writable:!0,value:function(){document.body.removeChild(en(t,ln)),en(t,mn).call(t)}}),Qt(this,hn,{writable:!0,value:function(){tn(t,un,document.documentElement.style.height),tn(t,pn,document.documentElement.style.overflowY),tn(t,cn,document.body.style.height),tn(t,dn,document.body.style.overflowY),document.documentElement.style.height="auto",document.documentElement.style.overflowY="hidden",document.body.style.height="auto",document.body.style.overflowY="hidden"}}),Qt(this,mn,{writable:!0,value:function(){document.documentElement.style.height=en(t,un),document.documentElement.style.overflowY=en(t,pn),document.body.style.height=en(t,cn),document.body.style.overflowY=en(t,dn)}}),Qt(this,vn,{writable:!0,value:function(e){if(0!==e.status)return e;var t=e.card_last_four,n=e.card_type,r=$t(e,Xt);return r.merchant_reference_info||(r.merchant_reference_info={affiliate_codes:[]}),Object.assign(r,{card:{lastfour:t,type:Re(n)}})}}),Qt(this,gn,{writable:!0,value:function(e){if(ge(e))return!0;if("[object Array]"!==Object.prototype.toString.call(e))return!1;if(0===e.length)return!1;for(var t=0;t<e.length;t++){var n=e[t];if(!(we(n)||n instanceof String)||""===n)return!1}return!0}}),Qt(this,wn,{writable:!0,value:function(){de("samsung_pay_iframe_result",(function(e){en(t,sn).call(t,e.result)}))}}),tn(this,rn,!1),tn(this,on,{country_code:"tw"}),tn(this,sn,(function(e){en(t,yn).call(t);var n=en(t,vn).call(t,e);en(t,an).call(t,n)})),en(this,wn).call(this)}return function(e,t,n){t&&Zt(e.prototype,t),n&&Zt(e,n),Object.defineProperty(e,"prototype",{writable:!1})}(e,[{key:"setup",value:function(e){en(this,on).country_code=e.country_code}},{key:"setupPaymentRequest",value:function(e){var t=e.total;return t&&t.label&&t.amount&&t.amount.currency&&parseFloat(t.amount.value)?en(this,gn).call(this,e.supportedNetworks)?(en(this,on).allowed_brands=e.supportedNetworks,en(this,on).merchant_name=t.label,en(this,on).currency=t.amount.currency,en(this,on).amount=parseFloat(t.amount.value),void tn(this,rn,!0)):console.error("[TPDirect.samsungPay.setupPaymentRequest] Please check payment request format (supportedNetworks)"):console.error("[TPDirect.samsungPay.setupPaymentRequest] Please check payment request format")}},{key:"getPrime",value:function(e){return ye(e)?console.error("[TapPay] TPDirect.samsungPay.getPrime(callback): callback is not a function"):en(this,rn)?(tn(this,an,e),void en(this,fn).call(this)):e({status:-5,msg:"[TPDirect.samsungPay.getPrime] Setup Samsung Pay with TPDirect.samsungPay.setupPaymentRequest first"})}},{key:"setupSamsungPayButton",value:function(e,t){if(we(e)&&(e=document.querySelector(e)),!he(e))return console.warn("[TapPay] TPDirect.samsungPay.setupSamsungPayButton: No element to setup.");var n={color:"black",type:"pay",shape:"rectangular"};t||(t=n),t.color||(t.color=n.color),t.type||(t.type=n.type),t.shape||(t.shape=n.shape),-1===["black","white"].indexOf(t.color)&&(console.warn("[TapPay] TPDirect.samsungPay.setupSamsungPayButton: Unknown color option "+t.color),t.color=n.color),-1===["pay","buy"].indexOf(t.type)&&(console.warn("[TapPay] TPDirect.samsungPay.setupSamsungPayButton: Unknown type option "+t.type),t.type=n.type),-1===["rectangular","pill"].indexOf(t.shape)&&(console.warn("[TapPay] TPDirect.samsungPay.setupSamsungPayButton: Unknown shape option "+t.shape),t.shape=n.shape);var r="https://js.tappaysdk.com/tpdirect/image/samsung-pay/"+t.type+"_"+t.color+"_"+t.shape+".svg",o=document.createElement("div");o.style.backgroundOrigin="content-box",o.style.backgroundPosition="center",o.style.backgroundRepeat="no-repeat",o.style.backgroundSize="contain",o.style.border="0",o.style.outline="0",o.style.height="100%",o.style.minHeight="40px",o.style.width="100%",o.style.cursor="pointer",o.style.backgroundImage="url("+r+")",e.appendChild(o)}}]),e}();function Pn(e,t){for(var n,r=0;r<t.length;r++)(n=t[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function _n(e,t,n){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,n)}function kn(e,t,n){return function(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}}(e,Cn(e,t,"set"),n),n}function Tn(e,t){return function(e,t){return t.get?t.get.call(e):t.value}(e,Cn(e,t,"get"))}function Cn(e,t,n){if(!t.has(e))throw new TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}var Sn=new WeakMap,An=new WeakMap,Mn=new WeakMap,On=new WeakMap,Rn=new WeakMap,En=new WeakMap,qn=new WeakMap,xn=new WeakMap,Dn=new WeakMap,jn=new WeakMap,Nn=new WeakMap,In=new WeakMap,Wn=new WeakMap,Fn=new WeakMap,Ln=function(){function e(){var t=this;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),_n(this,Sn,{writable:!0,value:void 0}),_n(this,An,{writable:!0,value:void 0}),_n(this,Mn,{writable:!0,value:!1}),_n(this,On,{writable:!0,value:void 0}),_n(this,Rn,{writable:!0,value:void 0}),_n(this,En,{writable:!0,value:function(){}}),_n(this,qn,{writable:!0,value:function(e,n){if(we(e)&&(e=document.querySelector(e)),!me(e)){Tn(t,An)&&Tn(t,An).remove();var r=document.createElement("iframe");return r.setAttribute("frameborder","0"),r.setAttribute("allowtransparency","true"),r.setAttribute("scrolling","no"),r.style.border="none",r.style.width="100%",r.style.height="100%",r.style.float="left",r.src="https://js.tappaysdk.com/sdk/tpdirect/tappay-field/html/v5.17.0?"+encodeURIComponent(JSON.stringify(n)),e.appendChild(r),{el:e,iframe:r}}console.warn("[TapPay] TPDirect.card.setup(): Cannot find element for "+n.type)}}),_n(this,xn,{writable:!0,value:function(e){kn(t,Sn,(function(t,n){return t?void e(t,null):void e(null,n)})),Tn(t,jn).call(t,{event:"get_prime_for_ccv_prime"})}}),_n(this,Dn,{writable:!0,value:function(){var e=Tn(t,Rn);return{canGetPrime:e===m,hasError:e===g,status:{ccv:e}}}}),_n(this,jn,{writable:!0,value:function(e){ue(e)}}),_n(this,Nn,{writable:!0,value:function(e){!function(e,t){e.contentWindow.postMessage(JSON.stringify(t),c)}(Tn(t,An),e)}}),_n(this,In,{writable:!0,value:function(){de("get_prime_for_ccv_prime_done",(function(e){Tn(t,Sn).call(t,e.err,e.result)}))}}),_n(this,Wn,{writable:!0,value:function(){de("ccv_field_ready",(function(e){"ccv-prime"===e.field_type&&(Tn(t,Mn)||(kn(t,Mn,!0),Tn(t,On).call(t,A().lower)))})),de("field-status-change",(function(e){if("ccv-prime"===e.field_type){var n=e.result;kn(t,Rn,n.status);var r=Tn(t,Dn).call(t);Tn(t,En).call(t,r)}}))}}),_n(this,Fn,{writable:!0,value:function(){Tn(t,In).call(t),Tn(t,Wn).call(t)}}),Tn(this,Fn).call(this),kn(this,On,(function(e){return S(e)?void Tn(t,Nn).call(t,{event:"cardtype-change",result:e,field_type:"ccv-prime"}):void console.error("[TapPay] TPDirect.ccv.setupCardType(): Invalid card type")}))}return function(e,t,n){t&&Pn(e.prototype,t),n&&Pn(e,n),Object.defineProperty(e,"prototype",{writable:!1})}(e,[{key:"setup",value:function(e){var t=Tn(this,qn).call(this,e.fields.ccv.element,{origin:window.location.origin,type:P,placeholder:e.fields.ccv.placeholder,styles:e.styles,field_type:"ccv-prime"});kn(this,An,t.iframe)}},{key:"setupCardType",value:function(e){Tn(this,Mn)&&Tn(this,On).call(this,e)}},{key:"getPrime",value:function(e){var t,n=ye(e);return t=Tn(this,Dn).call(this).canGetPrime?Tn(this,xn):function(e){e(new ne("You couldn't get ccv prime because of your ccv is invalid"),null)},n?xe(t):void t(e)}},{key:"onUpdate",value:function(e){return ye(e)?console.error("[TapPay] TPDirect.ccv.onUpdate(callback): callback in not a function"):void kn(this,En,e)}}]),e}(),Un=C(),zn=Object.create(null);Object.keys(Un).map((function(e){zn[e.toLocaleUpperCase()]=Un[e].toLocaleLowerCase()}));var Bn=zn;function Vn(e,t){for(var n,r=0;r<t.length;r++)(n=t[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function Yn(e,t,n){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,n)}function Gn(e,t,n){return function(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}}(e,Jn(e,t,"set"),n),n}function Kn(e,t){return function(e,t){return t.get?t.get.call(e):t.value}(e,Jn(e,t,"get"))}function Jn(e,t,n){if(!t.has(e))throw new TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}var Hn=new WeakMap,Xn=new WeakMap,$n=new WeakMap,Zn=new WeakMap,Qn=function(){function e(){var t=this;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),Yn(this,Hn,{writable:!0,value:!1}),Yn(this,Xn,{writable:!0,value:void 0}),Yn(this,$n,{writable:!0,value:function(e){if(le())Gn(t,Xn,(function(t,n){return t?void e(t,null):void e(null,n)})),Kn(t,Hn)&&ue({event:"atome_get_prime"});else{var n=new ne("Doesn't load pfirame yet");e(n,null)}}}),Yn(this,Zn,{writable:!0,value:function(){de("atome_get_prime_done",(function(e){Kn(t,Xn).call(t,e.err,e.result)})),de("iframe_get_prime_ready",(function(){Gn(t,Hn,!0),Kn(t,Xn)&&ue({event:"atome_get_prime"})}))}}),Kn(this,Zn).call(this)}return function(e,t,n){t&&Vn(e.prototype,t),n&&Vn(e,n),Object.defineProperty(e,"prototype",{writable:!1})}(e,[{key:"getPrime",value:function(e){return ye(e)?xe(Kn(this,$n)):void Kn(this,$n).call(this,e)}},{key:"pay",value:function(e){return Se(e)?void(window.location.href=e):console.error("[TapPay] Your payment url is not valid.")}}]),e}();function er(e,t){for(var n,r=0;r<t.length;r++)(n=t[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function tr(e,t,n){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,n)}function nr(e,t,n){return function(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}}(e,or(e,t,"set"),n),n}function rr(e,t){return function(e,t){return t.get?t.get.call(e):t.value}(e,or(e,t,"get"))}function or(e,t,n){if(!t.has(e))throw new TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}var ir=new WeakMap,ar=new WeakMap,sr=new WeakMap,lr=new WeakMap,ur=function(){function e(){var t=this;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),tr(this,ir,{writable:!0,value:!1}),tr(this,ar,{writable:!0,value:void 0}),tr(this,sr,{writable:!0,value:function(e){if(le())nr(t,ar,(function(t,n){return t?void e(t,null):void e(null,n)})),rr(t,ir)&&ue({event:"pi_wallet_get_prime"});else{var n=new ne("Doesn't load pfirame yet");e(n,null)}}}),tr(this,lr,{writable:!0,value:function(){de("pi_wallet_get_prime_done",(function(e){rr(t,ar).call(t,e.err,e.result)})),de("iframe_get_prime_ready",(function(){nr(t,ir,!0),rr(t,ar)&&ue({event:"pi_wallet_get_prime"})}))}}),rr(this,lr).call(this)}return function(e,t,n){t&&er(e.prototype,t),n&&er(e,n),Object.defineProperty(e,"prototype",{writable:!1})}(e,[{key:"getPrime",value:function(e){return ye(e)?xe(rr(this,sr)):void rr(this,sr).call(this,e)}},{key:"pay",value:function(e){return Se(e)?void(window.location.href=e):console.error("[TapPay] Your payment url is not valid.")}}]),e}();function pr(e,t){for(var n,r=0;r<t.length;r++)(n=t[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function cr(e,t,n){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,n)}function dr(e,t,n){return function(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}}(e,yr(e,t,"set"),n),n}function fr(e,t){return function(e,t){return t.get?t.get.call(e):t.value}(e,yr(e,t,"get"))}function yr(e,t,n){if(!t.has(e))throw new TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}var hr=new WeakMap,mr=new WeakMap,vr=new WeakMap,gr=new WeakMap,wr=function(){function e(){var t=this;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),cr(this,hr,{writable:!0,value:!1}),cr(this,mr,{writable:!0,value:void 0}),cr(this,vr,{writable:!0,value:function(e){if(le())dr(t,mr,(function(t,n){return t?void e(t,null):void e(null,n)})),fr(t,hr)&&ue({event:"plus_pay_get_prime"});else{var n=new ne("Doesn't load pfirame yet");e(n,null)}}}),cr(this,gr,{writable:!0,value:function(){de("plus_pay_get_prime_done",(function(e){fr(t,mr).call(t,e.err,e.result)})),de("iframe_get_prime_ready",(function(){dr(t,hr,!0),fr(t,mr)&&ue({event:"plus_pay_get_prime"})}))}}),fr(this,gr).call(this)}return function(e,t,n){t&&pr(e.prototype,t),n&&pr(e,n),Object.defineProperty(e,"prototype",{writable:!1})}(e,[{key:"getPrime",value:function(e){return ye(e)?xe(fr(this,vr)):void fr(this,vr).call(this,e)}},{key:"pay",value:function(e){return Se(e)?void(window.location.href=e):console.error("[TapPay] Your payment url is not valid.")}}]),e}();function br(e,t){for(var n,r=0;r<t.length;r++)(n=t[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function Pr(e,t,n){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,n)}function _r(e,t,n){return function(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}}(e,Tr(e,t,"set"),n),n}function kr(e,t){return function(e,t){return t.get?t.get.call(e):t.value}(e,Tr(e,t,"get"))}function Tr(e,t,n){if(!t.has(e))throw new TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}var Cr=new WeakMap,Sr=new WeakMap,Ar=new WeakMap,Mr=new WeakMap,Or=function(){function e(){var t=this;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),Pr(this,Cr,{writable:!0,value:!1}),Pr(this,Sr,{writable:!0,value:void 0}),Pr(this,Ar,{writable:!0,value:function(e){if(le())_r(t,Sr,(function(t,n){return t?void e(t,null):void e(null,n)})),kr(t,Cr)&&ue({event:"pay_later_get_prime"});else{var n=new ne("Doesn't load pfirame yet");e(n,null)}}}),Pr(this,Mr,{writable:!0,value:function(){de("pay_later_get_prime_done",(function(e){kr(t,Sr).call(t,e.err,e.result)})),de("iframe_get_prime_ready",(function(){_r(t,Cr,!0),kr(t,Sr)&&ue({event:"pay_later_get_prime"})}))}}),kr(this,Mr).call(this)}return function(e,t,n){t&&br(e.prototype,t),n&&br(e,n),Object.defineProperty(e,"prototype",{writable:!1})}(e,[{key:"getPrime",value:function(e){return ye(e)?xe(kr(this,Ar)):void kr(this,Ar).call(this,e)}},{key:"pay",value:function(e){window.location.href=e}}]),e}();function Rr(e){return(Rr="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})(e)}!function(e){window.addEventListener("message",(function(e){if(-1!==pe.indexOf(e.origin)){var t=JSON.parse(e.data);if(t.err&&(t.err=re(t.err)),t.error&&(t.error=re(t.error)),ce.has(t.event)){var n=ce.get(t.event);if(0===n.length)return;for(var r=0;r<n.length;r++)n[r](t)}}}),!1),e.location.origin||(e.location.origin=e.location.protocol+"//"+e.location.hostname+(e.location.port?":"+e.location.port:""));var t,n,r,o,i,a,c,d,f,y,h,m,v,g={},w=!1,b=[];if("https://js.tappaysdk.com",t=document.querySelectorAll('script[src^="https://js.tappaysdk.com"]'),v=0>=t.length?"v5.17.0":"v"+t[0].src.split("/v")[1],"withCredentials"in new XMLHttpRequest)n=!0;else{if(!e.XDomainRequest)return n=!1,console.warn("[TapPay] It looks like browser not support cors.");n=!0}e.TPDirect?(e.TPDirect.isDoubleLoaded=!0,console.warn("[TapPay] It looks like TPDirect.js was loaded more than one time.")):(e.TPDirect=function(t){return r=e.location.hostname,(t={}).isDoubleLoaded=!1,t.setPublishableKey=function(e,t,n){u({appID:e,appKey:t,type:n,endPoint:"production"===n?"https://prod.tappaysdk.com":"https://sandbox.tappaysdk.com"})},t.setupSDK=function(t,n,r){if(!t||!n||!r)return console.error("[TapPay] TPDirect.setupSDK error, appID = "+t+", appKey = "+n+", serverType = "+r);if(be(r))return console.error('[TapPay] TPDirect.setupSDK error, serverType is not "sandbox" nor "production", serverType = '+r);if("production"!==(r=r.toLowerCase())&&"sandbox"!==r)return console.error('[TapPay] TPDirect.setupSDK error, serverType is not "sandbox" nor "production", serverType = '+r);u({appID:t,appKey:n,type:r,endPoint:"production"===r?"https://prod.tappaysdk.com":"https://sandbox.tappaysdk.com",sdk_version:v});var o={appKey:p("appKey"),appID:p("appID"),serverType:p("type"),hostname:e.location.hostname,origin:e.location.origin,referrer:document.referrer,href:e.location.href,port:e.location.port,protocol:e.location.protocol,sdk_version:p("sdk_version"),mode:"production"};(function(e){de("send_device_id",(function(e){ae=e.result,ue({event:"main_event_data_register",dataset:{ddcaResult:ae}})})),(ie=document.createElement("iframe")).style.display="none",ie.src="https://fraud.tappaysdk.com/ddca/iframe?"+encodeURIComponent(JSON.stringify(e)),"complete"===document.readyState||"loaded"===document.readyState||"interactive"===document.readyState?document.body.appendChild(ie):document.addEventListener("DOMContentLoaded",(function(){document.body.appendChild(ie)}))})(o),(m=document.createElement("iframe")).setAttribute("allowpaymentrequest",!0),m.setAttribute("frameborder","0"),m.setAttribute("allowtransparency","true"),m.setAttribute("scrolling","no"),m.style.display="none",m.src="https://js.tappaysdk.com/sdk/tpdirect/api/html/v5.17.0?"+encodeURIComponent(JSON.stringify(o)),"complete"===document.readyState||"loaded"===document.readyState||"interactive"===document.readyState?document.body.appendChild(m):document.addEventListener("DOMContentLoaded",(function(){document.body.appendChild(m)})),function(e){oe=e}(m)},t.getDeviceId=function(){return se().deviceId||""},t.redirect=function(t){return Se(t)?void(e.location=t):console.error("[TapPay] Your payment url is not valid.")},g=t,t}(g),e.TPDirect.CardType=Bn,e.TPDirect.card=new rt(g),e.TPDirect.googlePay=new Et,e.TPDirect.linePay=new Ht,e.TPDirect.samsungPay=new bn,e.TPDirect.jkoPay=new Lt,e.TPDirect.easyWallet=new ft,e.TPDirect.ccv=new Ln,e.TPDirect.piWallet=new ur,e.TPDirect.atome=new Qn,e.TPDirect.plusPay=new wr,e.TPDirect.payLater=new Or,e.TPDirect.applePay=new Be,e.TPDirect.paymentRequestApi=function(t,n){var u=null;return(n={}).isAmountPending=!1,n.paymentRequest=null,n.pay_with_google_options=null,n.apple_pay_options=null,n.checkAvailability=function(){var t=!1;return e.ApplePaySession?t=Me():e.PaymentRequest&&(t=!0),!1===t?(console.warn("[TapPay] Your Browser Did Not Support Payment Request and Apple Pay"),!1):"https:"!==location.protocol&&"localhost"!==e.location.hostname?(console.warn("[TapPay] Trying to call an PaymentRequest API from an insecure document or http://localhost."),!1):!s.a.msedge||(console.warn("[TapPay] Does not support PaymentRequest on Edge."),!1)},n.availableMethods=function(){return s.a.msedge?[]:Me()?["apple_pay"]:s.a.android&&s.a.check({chrome:"61"})?["card","pay_with_google"]:s.a.android&&ve(e.PaymentRequest)||ve(e.PaymentRequest)?["card"]:[]},n.setupTappayPaymentButton=function(t,r){if(we(t)&&(t=document.querySelector(t)),!he(t))return console.error("[TapPay] TPDirect.paymentRequestApi.setupTappayPaymentButton: Missing element param");if(ye(r))return console.error("[TapPay] TPDirect.paymentRequestApi.setupTappayPaymentButton: Missing callback function");t.style.cursor="pointer";var o,i=!1,a=!1,l=e.TPDirect.paymentRequestApi.paymentRequest.supportedInstruments,u=l.find((function(e){return-1!==e.supportedMethods.indexOf("https://android.com/pay")})),p=l.find((function(e){return-1!==e.supportedMethods.indexOf("https://google.com/pay")}));if(s.a.android&&s.a.check({chrome:"61"})&&p?i=!0:s.a.android&&"undefined"!==e.PaymentRequest&&u&&(a=!0),e.ApplePaySession)(o=document.createElement("div")).style.height="40px",o.style["-webkit-appearance"]="-apple-pay-button",o.style["-apple-pay-button-type"]=y.canMakePaymentWithActiveCard?"buy":"set-up",t.appendChild(o);else if(i)o=document.createElement("div"),Ce(o,"googlepay"),o.style.backgroundColor="white",o.style.backgroundImage="url('data:image/svg+xml,%3Csvg%20width%3D%22102%22%20height%3D%2217%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cg%20fill%3D%22none%22%20fill-rule%3D%22evenodd%22%3E%3Cpath%20d%3D%22M80.526%202.635v4.083h2.518c.6%200%201.096-.202%201.488-.605.403-.402.605-.882.605-1.437%200-.544-.202-1.018-.605-1.422-.392-.413-.888-.62-1.488-.62h-2.518zm0%205.52v4.736h-1.504V1.198h3.99c1.013%200%201.873.337%202.582%201.012.72.675%201.08%201.497%201.08%202.466%200%20.991-.36%201.819-1.08%202.482-.697.665-1.559.996-2.583.996h-2.485v.001zm7.668%202.287c0%20.392.166.718.499.98.332.26.722.391%201.168.391.633%200%201.196-.234%201.692-.701.497-.469.744-1.019.744-1.65-.469-.37-1.123-.555-1.962-.555-.61%200-1.12.148-1.528.442-.409.294-.613.657-.613%201.093m1.946-5.815c1.112%200%201.989.297%202.633.89.642.594.964%201.408.964%202.442v4.932h-1.439v-1.11h-.065c-.622.914-1.45%201.372-2.486%201.372-.882%200-1.621-.262-2.215-.784-.594-.523-.891-1.176-.891-1.96%200-.828.313-1.486.94-1.976s1.463-.735%202.51-.735c.892%200%201.629.163%202.206.49v-.344c0-.522-.207-.966-.621-1.33a2.132%202.132%200%200%200-1.455-.547c-.84%200-1.504.353-1.995%201.062l-1.324-.834c.73-1.045%201.81-1.568%203.238-1.568m11.853.262l-5.02%2011.53H95.42l1.864-4.034-3.302-7.496h1.635l2.387%205.749h.032l2.322-5.75z%22%20fill%3D%22%235F6368%22%2F%3E%3Cpath%20d%3D%22M74.448%207.134c0-.473-.04-.93-.116-1.366h-6.344v2.588h3.634a3.11%203.11%200%200%201-1.344%202.042v1.68h2.169c1.27-1.17%202.001-2.9%202.001-4.944%22%20fill%3D%22%234285F4%22%2F%3E%3Cpath%20d%3D%22M67.988%2013.7c1.816%200%203.344-.595%204.459-1.621l-2.169-1.681c-.603.406-1.38.643-2.29.643-1.754%200-3.244-1.182-3.776-2.774h-2.234v1.731a6.728%206.728%200%200%200%206.01%203.703%22%20fill%3D%22%2334A853%22%2F%3E%3Cpath%20d%3D%22M64.212%208.267a4.034%204.034%200%200%201%200-2.572V3.964h-2.234a6.678%206.678%200%200%200-.717%203.017c0%201.085.26%202.11.717%203.017l2.234-1.731z%22%20fill%3D%22%23FABB05%22%2F%3E%3Cpath%20d%3D%22M67.988%202.921c.992%200%201.88.34%202.58%201.008v.001l1.92-1.918c-1.165-1.084-2.685-1.75-4.5-1.75a6.728%206.728%200%200%200-6.01%203.702l2.234%201.731c.532-1.592%202.022-2.774%203.776-2.774%22%20fill%3D%22%23E94235%22%2F%3E%3Cpath%20d%3D%22M.148%202.976h3.766c.532%200%201.024.117%201.477.35.453.233.814.555%201.085.966.27.41.406.863.406%201.358%200%20.495-.124.924-.371%201.288s-.572.64-.973.826v.084c.504.177.912.471%201.225.882.313.41.469.891.469%201.442a2.6%202.6%200%200%201-.427%201.47c-.285.43-.667.763-1.148%201.001A3.5%203.5%200%200%201%204.082%2013H.148V2.976zm3.696%204.2c.448%200%20.81-.14%201.085-.42.275-.28.413-.602.413-.966s-.133-.684-.399-.959c-.266-.275-.614-.413-1.043-.413H1.716v2.758h2.128zm.238%204.368c.476%200%20.856-.15%201.141-.448.285-.299.427-.644.427-1.036%200-.401-.147-.749-.441-1.043-.294-.294-.688-.441-1.183-.441h-2.31v2.968h2.366zm5.379.903c-.453-.518-.679-1.239-.679-2.163V5.86h1.54v4.214c0%20.579.138%201.013.413%201.302.275.29.637.434%201.085.434.364%200%20.686-.096.966-.287.28-.191.495-.446.644-.763a2.37%202.37%200%200%200%20.224-1.022V5.86h1.54V13h-1.456v-.924h-.084c-.196.336-.5.611-.91.826-.41.215-.845.322-1.302.322-.868%200-1.528-.259-1.981-.777zm9.859.161L16.352%205.86h1.722l2.016%204.858h.056l1.96-4.858H23.8l-4.41%2010.164h-1.624l1.554-3.416zm8.266-6.748h1.666l1.442%205.11h.056l1.61-5.11h1.582l1.596%205.11h.056l1.442-5.11h1.638L36.392%2013h-1.624L33.13%207.876h-.042L31.464%2013h-1.596l-2.282-7.14zm12.379-1.337a1%201%200%200%201-.301-.735%201%201%200%200%201%20.301-.735%201%201%200%200%201%20.735-.301%201%201%200%200%201%20.735.301%201%201%200%200%201%20.301.735%201%201%200%200%201-.301.735%201%201%200%200%201-.735.301%201%201%200%200%201-.735-.301zM39.93%205.86h1.54V13h-1.54V5.86zm5.568%207.098a1.967%201.967%200%200%201-.686-.406c-.401-.401-.602-.947-.602-1.638V7.218h-1.246V5.86h1.246V3.844h1.54V5.86h1.736v1.358H45.75v3.36c0%20.383.075.653.224.812.14.187.383.28.728.28.159%200%20.299-.021.42-.063.121-.042.252-.11.392-.203v1.498c-.308.14-.681.21-1.12.21-.317%200-.616-.051-.896-.154zm3.678-9.982h1.54v2.73l-.07%201.092h.07c.205-.336.511-.614.917-.833.406-.22.842-.329%201.309-.329.868%200%201.53.254%201.988.763.457.509.686%201.202.686%202.079V13h-1.54V8.688c0-.541-.142-.947-.427-1.218-.285-.27-.656-.406-1.113-.406-.345%200-.656.098-.931.294a2.042%202.042%200%200%200-.651.777%202.297%202.297%200%200%200-.238%201.029V13h-1.54V2.976z%22%20fill%3D%22%233C4043%22%2F%3E%3Cpath%20d%3D%22M61%200h41.285v18H61z%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E')",o.style.backgroundOrigin="content-box",o.style.backgroundPosition="center",o.style.backgroundRepeat="no-repeat",o.style.backgroundSize="contain",o.style.border="0",o.style.borderRadius="4px",o.style.boxShadow="0px 1px 3px 0px #6d6d6d",o.style.outline="0",o.style.padding="10px 8px",o.style.height="40px",o.style.minHeight="40px",o.addEventListener("mouseover",(function(){o.style.backgroundColor="#f7f7f7"})),o.addEventListener("mouseleave",(function(){o.style.backgroundColor="white"})),t.appendChild(o);else if(a)(o=document.createElement("div")).style.borderRadius="5px",o.style.boxShadow="0px 1px 3px rgb(116,116,116)",o.style.height="100%",o.style.backgroundSize="auto calc(60% + 2px)",o.style.backgroundRepeat="no-repeat",o.style.backgroundPosition="center",o.style.backgroundColor="#fff",o.style.backgroundImage="url(https://link-pay.tappaysdk.com/images/android_pay_logo.png)",t.appendChild(o);else{(o=document.createElement("div")).style.display="flex",o.style.justifyContent="center",o.style.color="rgb(61,64,67)",o.style.background="#fff",o.style.borderRadius="5px",o.style.boxShadow="0px 1px 3px rgb(116,116,116)",o.style.height="100%",o.style.alignItems="center",o.style.webkitTapHighlightColor="transparent",o.style.cursor="pointer",o.style.webkitUserSelect="none",o.style.MozUserSelect="none",o.style.msUserSelect="none",o.style.userSelect="none",o.style.font="500 16px/21px -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif",o.style.fontWeight="500",o.style.webkitFontSmoothing="antialiased",o.style.MozOsxFontSmoothing="grayscale";var c=document.createElement("img");c.setAttribute("src","https://s3-ap-northeast-1.amazonaws.com/tappay-image-resource/favicon-32x32.png"),c.style.width="20px",c.style.height="20px",c.style.marginRight="5px";var d=document.createElement("span");d.textContent=Oe(),o.appendChild(c),o.appendChild(d),t.appendChild(o)}t.addEventListener("click",(function(){n.getPrime((function(e){r(e)}))}),!1)},n.setupPaymentRequest=function(t,r){ye(r)&&(r=function(e){return e.browserSupportPaymentRequest?void(!e.canMakePaymentWithActiveCard&&console.error("[TapPay] User does not have support payment method.")):void console.error("[TapPay] Browser does not support PaymentRequest or Apple Pay")}),i=function(e){y=e,r(e)};var o=n.checkAvailability();if(!o)return i({browserSupportPaymentRequest:!1,canMakePaymentWithActiveCard:!1,canMakePaymentError:null});var a=s.a.android&&s.a.check({chrome:"61"}),l=-1===t.supportedMethods.indexOf("card")&&-1===t.supportedMethods.indexOf("basic-card"),u=ge(e.ApplePaySession);l&&u&&!a&&(o=!1),1===t.supportedMethods.length&&("pay_with_google"===t.supportedMethods[0]||"https://google.com/pay"===t.supportedMethods[0])&&!a&&(o=!1),1===t.supportedMethods.length&&("apple_pay"===t.supportedMethods[0]||"https://apple.com/apple-pay"===t.supportedMethods[0])&&ge(e.ApplePaySession)&&(o=!1);var p=-1===t.supportedMethods.indexOf("apple_pay")&&-1===t.supportedMethods.indexOf("https://apple.com/apple-pay");if(e.ApplePaySession&&p&&(o=!1),o)if(n.preparePaymentRequest(t))if(e.ApplePaySession){if(!n.apple_pay_options)return void console.error("[TapPay]: You need to call `TPDirect.paymentRequestApi.setupApplePay` before `TPDirect.paymentRequestApi.setupPaymentRequest`");var c=n.apple_pay_options.merchantIdentifier;g.applePay.canMakePaymentsWithActiveCard(c,i)}else{if(s.a.ios&&s.a.chrome)return n.iosChromeSetupPaymentRequest(),void n.iosChromeCheckCanMakePaymentWithActiveCard();var d=function(){ue({event:"setup_payment_request",paymentRequest:n.paymentRequest,pay_with_google_options:n.pay_with_google_options})};w?d():b.push(d)}else console.error("[TapPay] Please check your paymentRequest");else i({browserSupportPaymentRequest:!1,canMakePaymentWithActiveCard:!1,canMakePaymentError:null})},n.setupApplePay=function(e){e.merchantIdentifier&&!be(e.merchantIdentifier)||console.error("[TapPay] TPDirect.paymentRequestApi.setupApplePay: merchantIdentifier is required"),e.countryCode&&(be(e.countryCode)||2!==e.countryCode.length)&&console.error("[TapPay] TPDirect.paymentRequestApi.setupApplePay: countryCode need to be two-letter ISO 3166 country code format."),n.apple_pay_options=e},n.setupPayWithGoogle=function(e){e.allowedPaymentMethods&&e.allowedPaymentMethods.forEach((function(e){-1===["CARD","TOKENIZED_CARD"].indexOf(e)&&console.error("[TapPay] TPDirect.paymentRequestApi.setupPayWithGoogle: allowedPaymentMethods error: "+e)}));var t=Rr(e.allowPrepaidCards);-1===["boolean","undefined"].indexOf(t)&&console.error("[TapPay] TPDirect.paymentRequestApi.setupPayWithGoogle: allowPrepaidCards type error: "+t);var r=Rr(e.billingAddressRequired);if(-1===["boolean","undefined"].indexOf(r)&&console.error("[TapPay] TPDirect.paymentRequestApi.setupPayWithGoogle: billingAddressRequired type error: "+r),e.billingAddressFormat&&-1===["FULL","MIN"].indexOf(e.billingAddressFormat)){var o="[TapPay] TPDirect.paymentRequestApi.setupPayWithGoogle: billingAddressFormat error: "+e.billingAddressFormat;console.error(o)}if(e.allowedCountryCodes&&"[object Array]"!==Object.prototype.toString.call(e.allowedCountryCodes)){var i="[TapPay] TPDirect.paymentRequestApi.setupPayWithGoogle: allowedCountryCodes error: "+e.allowedCountryCodes;console.error(i)}n.pay_with_google_options=e},n.preparePaymentItems=function(e){if(!e.hasOwnProperty("total"))return console.error("[TapPay] You need to setup total in the paymentRequest"),!1;var t=!1,r=!1,o=!ve(e.total.isShowTotalAmount)||e.total.isShowTotalAmount,i=!!ve(e.total.isAmountPending)&&e.total.isAmountPending,a={amount:{currency:null,value:"0.00"}},s=function(e,t,n){return{label:e,amount:{currency:t,value:n}}},l=function(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;return{label:e,amount:{currency:t,value:n},isAmountPending:!0}},u=function(e,t){return parseFloat(e)!==parseFloat(t)},p=0,c=JSON.parse(JSON.stringify(e)),d=!!(c.displayItems&&0<c.displayItems.length);if(d||(c.displayItems=null),d){for(var f,y=[],h=0;h<c.displayItems.length;h++){if(f=c.displayItems[h],a.amount.currency||(a.amount.currency=f.amount.currency),a.amount.currency!==f.amount.currency)return console.error("[TapPay] payment request data have inconsistent currency, please use consistent currency."),!1;if(!f.isAmountPending&&!1===Object.hasOwnProperty.call(f.amount,"value"))return console.error("Your displayItems object should have `amount.value` or `isAmountPending:true`"),!1;if(f.isAmountPending&&Object.hasOwnProperty.call(f.amount,"value"))return console.error("Your displayItems object should only have `amount.value` or `isAmountPending:true`"),!1;f.isAmountPending?(t=!0,y.push(1),Object.assign(f,a)):y.push(-1),p+=parseFloat(f.amount.value)}y.reduce((function(e,t){return e+t}),0)===c.displayItems.length&&(r=!0)}if(a.amount.currency||(a.amount.currency=c.total.amount.currency),a.amount.currency!==c.total.amount.currency)return console.error("[TapPay] payment request data have inconsistent currency, please use consistent currency."),!1;if(!o&&!i)return console.error("[TapPay] `isShowTotalAmount` and `total.isAmountPending` couldn't be false at the same time."),!1;if(d){var m=!(0!==p||!r);if(!(0===p||!t)||null){if(!i)return console.error("[TapPay] `total.isAmountPending` must be true if there is any payment item's amount is `pending`"),!1;if(n.isAmountPending=!0,o){if(u(c.total.amount.value,p))return console.error("[TapPay] Your total amount value is not equal to sum of displayItems value."),!1;c.total=s(c.total.label,a.amount.currency,p)}else c.total=l(c.total.label,a.amount.currency,p)}else if(m){if(!i)return console.error("[TapPay] `total.isAmountPending` must be true if there is any payment item's amount is `pending`"),!1;if(o)return console.error("[TapPay] Total amount couldn’t be displayed if all paymentItems' amount are pending."),!1;n.isAmountPending=!0,c.total=l(c.total.label,a.amount.currency,1)}else if(n.isAmountPending=i,o){var v=c.total.amount.value;if(u(v,p))return console.error("[TapPay] Your total amount value is not equal to sum of displayItems value."),!1;if(0>=parseFloat(v))return console.error("[TapPay] `total.amount.value` must greater than zero when `total.isShowTotalAmount:true`"),!1;c.total=s(c.total.label,a.amount.currency,p)}else c.total=l(c.total.label,a.amount.currency,p)}else if(n.isAmountPending=i,o){if(!1===Object.hasOwnProperty.call(c.total.amount,"value"))return console.error("[TapPay] `total.amount.value` should have value when `total.isShowTotalAmount:true`"),!1;var g=c.total.amount.value;if(0>=parseFloat(g))return console.error("[TapPay] `total.amount.value` must greater than zero when `total.isShowTotalAmount:true`"),!1;c.total=s(c.total.label,a.amount.currency,g)}else c.total=l(c.total.label,a.amount.currency,1);return{displayItems:c.displayItems,total:c.total,shippingOptions:c.shippingOptions||[]}},n.preparePaymentOptions=function(e){var t={};return e.hasOwnProperty("options")&&(t=e.options),t},n.parseSupportMethod=function(e,t){var r=t.supportedNetworks,o=t.options||{},i={};if(-1===["card","pay_with_google","apple_pay","basic-card","https://google.com/pay","https://apple.com/apple-pay"].indexOf(e))return console.error("[TapPay] "+e+" is not supported, supportedMethods: card, pay_with_google, apple_pay");if("card"===e||"basic-card"===e)i={supportedMethods:["basic-card"],data:{supportedNetworks:r.map((function(e){return e.toLowerCase()}))}};else if("pay_with_google"===e||"https://google.com/pay"===e){var a=n.pay_with_google_options||{};i={supportedMethods:["https://google.com/pay"],data:{merchantId:"04234483533225200652",environment:"TEST",apiVersion:1,allowedPaymentMethods:a.allowedPaymentMethods||["CARD","TOKENIZED_CARD"],paymentMethodTokenizationParameters:{tokenizationType:"PAYMENT_GATEWAY",parameters:{gateway:"tappay",gatewayMerchantId:"tappay"}},cardRequirements:{allowedCardNetworks:r,allowPrepaidCards:a.allowPrepaidCards||!0,billingAddressRequired:a.billingAddressRequired||!1,billingAddressFormat:a.billingAddressFormat||"MIN"},phoneNumberRequired:o.requestPayerPhone||!1,emailRequired:o.requestPayerEmail||!1,shippingAddressRequired:o.requestShipping||!1,shippingAddressRequirements:{allowedCountryCodes:a.allowedCountryCodes||void 0}}},"production"===p("type")&&delete i.data.environment}else if("apple_pay"===e||"https://apple.com/apple-pay"===e){var s=n.apple_pay_options||{};i={supportedMethods:["https://apple.com/apple-pay"],data:{supportedNetworks:n.convertToApplePayNetworks(r),countryCode:s.countryCode||"TW",merchantIdentifier:s.merchantIdentifier}}}return i},n.convertToApplePayNetworks=function(e){return e.map((function(e){var t=e.toLowerCase();return"amex"===t?"amex":"jcb"===t?"jcb":"mastercard"===t?"masterCard":"visa"===t?"visa":null})).filter((function(e){return null!==e}))},n.preparePaymentMethods=function(e){return e.hasOwnProperty("supportedMethods")?e.supportedMethods.map((function(t){return n.parseSupportMethod(t,e)})):(console.error('[TapPay] "supportedMthods" is not found in the paymentRequest, you need to setup the right name.'),!1)},n.preparePaymentRequest=function(e){var t=n.preparePaymentMethods(e),r=n.preparePaymentItems(e),o=n.preparePaymentOptions(e);return t&&r&&o?(n.paymentRequest={supportedInstruments:t,details:r,options:o},!0):(n.paymentRequest=null,!1)},n.getPrime=function(t){if(ye(t))return console.error("[TapPay] TPDirect.paymentRequestApi.getPrime(callback): callback is not a function");if(!m)return console.error("[TapPay] Doesnt load pfirame yet");if(!n.paymentRequest)return console.error("[TapPay] You need to setup the complete payment request.");if(e.ApplePaySession)n.applePayGetPrime(t);else if(f)n.iosChromeGetPrime(t);else{a=t;var r=n.paymentRequest,o=r.supportedInstruments,i=r.details,s=r.options,l=new e.PaymentRequest(o,i,s);l.onshippingoptionchange=function(e){var t=JSON.parse(JSON.stringify(r.details));t.shippingOptions=t.shippingOptions.map((function(e){return l.shippingOption===e.id?(e.selected=!0,t.total.amount.value=(parseFloat(t.total.amount.value)+parseFloat(e.amount.value)).toString()):e.selected=!1,e})),e.updateWith(t)},l.onshippingaddresschange=function(e){e.updateWith(r.details)},l.show().then((function(e){h=e,ue({event:"payment_request_get_response_success",response:e})})).catch((function(e){ue({event:"payment_request_get_response_fail",error_message:e.message})}))}},n.iosChromeSetupPaymentRequest=function(){var t=n.paymentRequest,r=t.supportedInstruments,o=t.details,a=t.options;"servicePickup"===a.shippingType&&(a.shippingType="pickup");try{f=new e.PaymentRequest(r,o,a)}catch(e){return void i({browserSupportPaymentRequest:!1,canMakePaymentWithActiveCard:!1})}f.addEventListener("shippingoptionchange",(function(e){var n=JSON.parse(JSON.stringify(t.details));n.shippingOptions=n.shippingOptions.map((function(e){return f.shippingOption===e.id?(e.selected=!0,n.total.amount.value=(parseFloat(n.total.amount.value)+parseFloat(e.amount.value)).toString()):e.selected=!1,e})),e.updateWith(l.Promise.resolve(o))})),f.addEventListener("shippingaddresschange",(function(e){e.updateWith(l.Promise.resolve(t.details))}))},n.iosChromeCheckCanMakePaymentWithActiveCard=function(){var e=l.Promise.resolve(!0);f.canMakePayment&&(e=f.canMakePayment()),e.then((function(e){i({browserSupportPaymentRequest:!0,canMakePaymentWithActiveCard:e})})).catch((function(e){console.error("[TapPay] PaymentRequest.canMakePayment error (see https://developers.google.com/web/fundamentals/payments/deep-dive-into-payment-request#check_payment_method_availability): ",e),i({browserSupportPaymentRequest:!0,canMakePaymentWithActiveCard:!0,canMakePaymentError:e})}))},n.iosChromeGetPrime=function(t){f.show().then((function(n){var r,i=e.TPDirect.paymentRequestApi.paymentRequest,a=i.details.shippingOptions,s=i.details.total.amount.value;if(!0===i.options.requestShipping&&a&&a.length){var l=a.find((function(e){return e.id===n.shippingOption})).amount.value;r=(parseFloat(s)+parseFloat(l)).toString()}else r=s;if("basic-card"===n.methodName||"basic_card"===n.methodName){var u=n.details.cardNumber,p=n.details.expiryMonth,c=n.details.expiryYear.slice(2),d=n.details.cardSecurityCode;o=function(e){0===e.status?(e.payer={email:n.payerEmail,name:n.payerName,phone:n.payerPhone},e.billingAddress=n.details.billingAddress,e.shippingAddress=n.shippingAddress,e.shippingOption=n.shippingOption,e.methodName="card",e.requestId=n.requestId,e.prime=e.card.prime,e.total_amount=r,n.complete("success")):n.complete("fail"),t(e)},ue({event:"get_prime",card:{number:u,exp_month:p,exp_year:c,ccv:d}})}})).catch((function(e){var r={status:401,msg:e.message};t(r),n.iosChromeSetupPaymentRequest()}))},n.applePayGetPrime=function(t){a=t;var o=n.paymentRequest;"pickup"===o.options.shippingType&&(o.options.shippingType="storePickup");var i=new _.PaymentRequest(o.supportedInstruments,o.details,o.options);i.onvalidatemerchant=function(e){var t=e.validationURL,o=n.apple_pay_options.merchantIdentifier,a={appId:p("appID"),appKey:p("appKey"),appName:r,appleMerchantId:o,merchant_domain:r,validationURL:t,tappay_endpoint:p("endPoint")};d=function(e,t){if(e)u=new Error("[Apple Pay] Get Session error: ".concat(e.msg));else if(0===t.status)if(0===t.status&&t.statusMessage){var n=t.statusMessage;u=new Error("[Apple Pay] Get Session error: ".concat(n))}else i.completeMerchantValidation(t);else{var r=t.errorMessage||t.msg;u=new Error("[Apple Pay] Get Session error: ".concat(r))}},ue({event:"apple_pay_get_session",payload:a})},i.onshippingoptionchange=function(t){var n=JSON.parse(JSON.stringify(e.TPDirect.paymentRequestApi.paymentRequest)).details;n.shippingOptions=n.shippingOptions.map((function(e){return i.shippingOption===e.id?(e.selected=!0,n.total.amount.value=(parseFloat(n.total.amount.value)+parseFloat(e.amount.value)).toString()):e.selected=!1,e})),t.updateWith(n)},i.onshippingaddresschange=function(e){var t=JSON.parse(JSON.stringify(n.paymentRequest.details));t.shippingOptions&&t.shippingOptions.length&&(t.total.amount.value=(parseFloat(t.total.amount.value)+parseFloat(t.shippingOptions[0].amount.value)).toString()),e.updateWith(t)},i.show().then((function(e){if(!Ae(e.applePayRaw))return t({status:402,msg:"[Apple Pay] Parsing Apple Pay result happen error"}),e.complete("fail");var i={app_id:p("appID"),app_key:p("appKey"),app_name:r,pay_token_data:e.applePayRaw.token.paymentData,apple_merchant_id:n.apple_pay_options.merchantIdentifier,platform_type:"2",is_amount_pending:n.isAmountPending,device_id:se().deviceId,tappay_sdk_version:p("sdk_version")},a=function(r){var i=r;if(0===i.status){i.merchant_reference_info||(i.merchant_reference_info={affiliate_codes:[]}),i.payer={email:e.payerEmail,name:e.payerName,phone:e.payerPhone},i.billingAddress=e.details.billingAddress,i.shippingAddress=e.shippingAddress,i.shippingOption=e.shippingOption,i.methodName="apple_pay";var a=e.applePayRaw.token.paymentMethod;i.card={lastfour:a.displayName.split(" ")[1],type:Ee(a.network),funding:qe(a.type)};var s=n.paymentRequest,l=o.details.shippingOptions,u=parseFloat(s.details.total.amount.value);if(!0===s.options.requestShipping&&l&&l.length){var p=l.find((function(t){return t.id===e.shippingOption})).amount.value;i.total_amount=(u+parseFloat(p)).toString()}else i.total_amount=u.toString();e.complete("success")}else e.complete("fail");t(i)},s=function(n){t(n),e.complete("fail")};c=function(e,t){return e?void s(e):void a(t)},ue({event:"payment_request_apple_pay_get_prime",parameter:i})})).catch((function(e){var n=null;return u?(n=u.message,t({status:403,msg:n}),void(u=null)):void(e&&t({status:401,msg:"[Apple Pay] Unexcept Error",originalError:e}))}))},n}(0,void 0),e.TPDirect.validate={cardNumber:R,ccv:x,expiry:E,cardType:q,sdkError:function(){return!e.TPDirect.isDoubleLoaded&&n}},de("get_prime_done",(function(e){ve(o)&&o(e.result)})),de("iframe_get_prime_ready",(function(){w=!0,b.forEach((function(e){e()}))})),de("setup_payment_request_done",(function(e){i({browserSupportPaymentRequest:!0,canMakePaymentWithActiveCard:e.result.canMakePaymentWithActiveCard,canMakePaymentError:e.result.error})})),de("payment_request_not_support_in_iframe",(function(){e.TPDirect.paymentRequestApi.iosChromeSetupPaymentRequest(),e.TPDirect.paymentRequestApi.iosChromeCheckCanMakePaymentWithActiveCard()})),de("payment_request_get_prime_done",(function(e){a(e.result),0===e.result.status&&h.complete("success"),402===e.result.status&&h.complete("fail")})),de("payment_request_apple_pay_get_prime_done",(function(e){c(e.err,e.result)})),de("apple_pay_get_session_done",(function(e){d&&d(e.err,e.result)})))}(window)}]);