!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).efoxPay={})}(this,(function(e){"use strict";
/*! *****************************************************************************
    Copyright (c) Microsoft Corporation.

    Permission to use, copy, modify, and/or distribute this software for any
    purpose with or without fee is hereby granted.

    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
    REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
    AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
    INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
    LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
    OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
    PERFORMANCE OF THIS SOFTWARE.
    ***************************************************************************** */var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,n)};function n(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var i=function(){return(i=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var l in t=arguments[n])Object.prototype.hasOwnProperty.call(t,l)&&(e[l]=t[l]);return e}).apply(this,arguments)};function l(e,t,n,i){return new(n||(n=Promise))((function(l,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function r(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?l(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,r)}d((i=i.apply(e,t||[])).next())}))}function o(e,t){var n,i,l,o,a={label:0,sent:function(){if(1&l[0])throw l[1];return l[1]},trys:[],ops:[]};return o={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function r(o){return function(r){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(l=2&o[0]?i.return:o[0]?i.throw||((l=i.return)&&l.call(i),0):i.next)&&!(l=l.call(i,o[1])).done)return l;switch(i=0,l&&(o=[2&o[0],l.value]),o[0]){case 0:case 1:l=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,i=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(l=a.trys,(l=l.length>0&&l[l.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!l||o[1]>l[0]&&o[1]<l[3])){a.label=o[1];break}if(6===o[0]&&a.label<l[1]){a.label=l[1],l=o;break}if(l&&a.label<l[2]){a.label=l[2],a.ops.push(o);break}l[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],i=0}finally{n=l=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,r])}}}const a=new Set(["a","altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","animation","audio","canvas","circle","clipPath","color-profile","cursor","defs","desc","discard","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","handler","hkern","iframe","image","line","linearGradient","listener","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","prefetch","radialGradient","rect","script","set","solidColor","stop","style","svg","switch","symbol","tbreak","text","textArea","textPath","title","tref","tspan","unknown","use","video","view","vkern"]);a.delete("a"),a.delete("audio"),a.delete("canvas"),a.delete("iframe"),a.delete("script"),a.delete("video");const r=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,d=(e,t)=>{for(let[n,i]of Object.entries(t))"number"!=typeof i||r.test(n)||(i+="px"),e.style[n]=i},u=e=>"string"==typeof e?a.has(e)?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e):(e=>e===DocumentFragment)(e)?document.createDocumentFragment():e(),s=(e,t,n)=>{null!=n&&(/^xlink[AHRST]/.test(t)?e.setAttributeNS("http://www.w3.org/1999/xlink",t.replace("xlink","xlink:").toLowerCase(),n):e.setAttribute(t,n))},p=(e,t)=>{for(const n of t)n instanceof Node?e.appendChild(n):Array.isArray(n)?p(e,n):"boolean"!=typeof n&&null!=n&&e.appendChild(document.createTextNode(n))},c=(e,t,...n)=>{var i;const l=u(e);if(p(l,n),l instanceof DocumentFragment||!t)return l;for(let[e,n]of Object.entries(t))if("htmlFor"===e&&(e="for"),"class"===e||"className"===e){const e=null!==(i=l.getAttribute("class"))&&void 0!==i?i:"";s(l,"class",(e+" "+String(n)).trim())}else if("style"===e)d(l,n);else if(e.startsWith("on")){const t=e.slice(2).toLowerCase();l.addEventListener(t,n)}else"dangerouslySetInnerHTML"===e&&"__html"in n?l.innerHTML=n.__html:"key"!==e&&!1!==n&&s(l,e,!0===n?"":n);return l};var v=function(){function e(){}return e.prototype.renderToDom=function(e,t){t.length>0?document.querySelector("#"+t).appendChild(e):document.querySelector("body").append(e)},e}();"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var m=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,t){e.exports=function(){var e=function(){},t={},n={},i={};function l(e,t){if(e){var l=i[e];if(n[e]=t,l)for(;l.length;)l[0](e,t),l.splice(0,1)}}function o(t,n){t.call&&(t={success:t}),n.length?(t.error||e)(n):(t.success||e)(t)}function a(t,n,i,l){var o,r,d=document,u=i.async,s=(i.numRetries||0)+1,p=i.before||e,c=t.replace(/[\?|#].*$/,""),v=t.replace(/^(css|img)!/,"");l=l||0,/(^css!|\.css$)/.test(c)?((r=d.createElement("link")).rel="stylesheet",r.href=v,(o="hideFocus"in r)&&r.relList&&(o=0,r.rel="preload",r.as="style")):/(^img!|\.(png|gif|jpg|svg|webp)$)/.test(c)?(r=d.createElement("img")).src=v:((r=d.createElement("script")).src=t,r.async=void 0===u||u),r.onload=r.onerror=r.onbeforeload=function(e){var d=e.type[0];if(o)try{r.sheet.cssText.length||(d="e")}catch(e){18!=e.code&&(d="e")}if("e"==d){if((l+=1)<s)return a(t,n,i,l)}else if("preload"==r.rel&&"style"==r.as)return r.rel="stylesheet";n(t,d,e.defaultPrevented)},!1!==p(t,r)&&d.head.appendChild(r)}function r(e,n,i){var r,d;if(n&&n.trim&&(r=n),d=(r?i:n)||{},r){if(r in t)throw"LoadJS";t[r]=!0}function u(t,n){!function(e,t,n){var i,l,o=(e=e.push?e:[e]).length,r=o,d=[];for(i=function(e,n,i){if("e"==n&&d.push(e),"b"==n){if(!i)return;d.push(e)}--o||t(d)},l=0;l<r;l++)a(e[l],i,n)}(e,(function(e){o(d,e),t&&o({success:t,error:n},e),l(r,e)}),d)}if(d.returnPromise)return new Promise(u);u()}return r.ready=function(e,t){return function(e,t){e=e.push?e:[e];var l,o,a,r=[],d=e.length,u=d;for(l=function(e,n){n.length&&r.push(e),--u||t(r)};d--;)o=e[d],(a=n[o])?l(o,a):(i[o]=i[o]||[]).push(l)}(e,(function(e){o(t,e)})),r},r.done=function(e){l(e,[])},r.reset=function(){t={},n={},i={}},r.isDefined=function(e){return e in t},r}()})),y=function(e){function t(t,n){var i=e.call(this)||this;console.log("publicKey",t,"initialData",n),i.publicKey=t,i.initialData=n;var a=(new Date).getTime();return m(["https://2pay-js.2checkout.com/v1/2pay.js"],(function(){var e,r;console.log("2checkout.js loaded"),window.addEventListener("load",(function(){var e,a,r,d,u,s;i.jsPaymentClient=new TwoPayClient(t.key),n.language&&i.jsPaymentClient.setup.setLanguage(n.language),i.component=i.jsPaymentClient.components.create("card",(e=n.styleOption,a=null==e?void 0:e.commonStyle,r=null==e?void 0:e.componentStyle,d=null==r?void 0:r.cardInputStyle,u=null==r?void 0:r.expirationInputStyle,s=null==r?void 0:r.cvvInputStyle,{margin:0,fontFamily:(null==a?void 0:a.fontFamily)||"Helvetica, sans-serif",fontSize:(null==a?void 0:a.fontSize)||"1rem",fontWeight:(null==a?void 0:a.fontWeight)||"400",color:(null==a?void 0:a.color)||"#212529",textAlign:(null==a?void 0:a.textAlign)||"left",backgroundColor:(null==a?void 0:a.backgroundColor)||"#ffffff","*":{boxSizing:(null==a?void 0:a.boxSizing)||"border-box"},".card-number .control-label":(null==d?void 0:d.labelStyle)||{},".card-number .input-wrapper":(null==d?void 0:d.inputWrapperStyle)||{},".card-number .form-control":(null==d?void 0:d.inputStyle)||{},".card-number .validation-message":(null==d?void 0:d.messageStyle)||{},".card-expiration-date .control-label":(null==u?void 0:u.labelStyle)||{},".card-expiration-date .input-wrapper":(null==u?void 0:u.inputWrapperStyle)||{},".card-expiration-date .form-control":(null==u?void 0:u.inputStyle)||{},".card-expiration-date .validation-message":(null==u?void 0:u.messageStyle)||{},".card-security-code .control-label":(null==s?void 0:s.labelStyle)||{},".card-security-code .input-wrapper":(null==s?void 0:s.inputWrapperStyle)||{},".card-security-code .form-control":(null==s?void 0:s.inputStyle)||{},".card-security-code .validation-message":(null==s?void 0:s.messageStyle)||{},".no-gutters":{marginRight:0,marginLeft:0},".row":{display:"flex",flexWrap:"wrap"},".col":{flexBasis:"0",flexGrow:"1",maxWidth:"100%",padding:"0",position:"relative",width:"100%"},div:{display:"block"},".field-container":{paddingBottom:"14px"},".field-wrapper":{paddingRight:"25px"},".input-wrapper":{position:"relative"},label:{display:"inline-block",marginBottom:"9px",color:"#313131",fontWeight:"300",fontSize:"14px",lineHeight:"17px"},input:{outline:"none",position:"absolute",overflow:"visible",margin:0,fontFamily:"inherit",display:"block",width:"100%",height:"42px",padding:"10px 12px",fontSize:"18px",fontWeight:"400",lineHeight:"22px",color:"#313131",backgroundColor:"#fff",backgroundClip:"padding-box",border:"1px solid #CBCBCB",borderRadius:"3px",transition:"border-color .15s ease-in-out,box-shadow .15s ease-in-out",ontline:"0"},".form-control":{position:"relative"},"input:focus":{border:"1px solid #5D5D5D",backgroundColor:"#FFFDF2"},".is-error input":{border:"1px solid #D9534F"},".is-error input:focus":{backgroundColor:"#D9534F0B"},".is-valid input":{border:"1px solid #1BB43F"},".is-valid input:focus":{backgroundColor:"#1BB43F0B"},".validation-message":{color:"#D9534F",fontSize:"10px",fontStyle:"italic",marginTop:"6px",marginBottom:"-5px",display:"block",lineHeight:"1"},".card-expiration-date":{paddingRight:".5rem"},".is-empty input":{color:"#EBEBEB"},".lock-icon":{top:"calc(50% - 7px)",right:"10px"},".valid-icon":{top:"calc(50% - 8px)",right:"-25px"},".error-icon":{top:"calc(50% - 8px)",right:" -25px"},".card-icon":{top:"calc(50% - 10px)",left:"10px",display:"none"},".is-empty .card-icon":{display:"block"},".is-focused .card-icon":{display:"none"},".card-type-icon":{right:"30px",display:"block"},".card-type-icon.visa":{top:"calc(50% - 14px)"},".card-type-icon.mastercard":{top:"calc(50% - 14.5px)"},".card-type-icon.amex":{top:"calc(50% - 14px)"},".card-type-icon.discover":{top:"calc(50% - 14px)"},".card-type-icon.jcb":{top:"calc(50% - 14px)"},".card-type-icon.dankort":{top:"calc(50% - 14px)"},".card-type-icon.cartebleue":{top:"calc(50% - 14px)"},".card-type-icon.diners":{top:"calc(50% - 14px)"},".card-type-icon.elo":{top:"calc(50% - 14px)"}})),i.component.mount("#card-element"),i.initialData.btnText&&document.getElementById("payment-form").addEventListener("submit",(function(e){return l(i,void 0,void 0,(function(){var t,n,i,l;return o(this,(function(o){switch(o.label){case 0:return e.preventDefault(),t=(null===(l=null===(i=this.initialData)||void 0===i?void 0:i.fieldData)||void 0===l?void 0:l.userName)||document.querySelector("#name").value,[4,this.generateToken(this.jsPaymentClient,this.component,t)];case 1:return n=o.sent(),this.initialData.createToken&&this.initialData.createToken(n),[2]}}))}))}))})),i.renderHtml();var d=(new Date).getTime()-a;null===(r=null===(e=i.initialData)||void 0===e?void 0:e.reportSDKLoading)||void 0===r||r.call(e,{time:d})})),i}return n(t,e),t.prototype.generateToken=function(e,t,n){return l(this,void 0,void 0,(function(){var i,l;return o(this,(function(o){switch(o.label){case 0:this.nameOnblur(),i={name:n},o.label=1;case 1:return o.trys.push([1,3,,4]),[4,e.tokens.generate(t,i)];case 2:return[2,o.sent()];case 3:return l=o.sent(),[2,{error:l.toString().trim().split("\n")[0]}];case 4:return[2]}}))}))},t.prototype.getToken=function(e){return l(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=e||document.querySelector("#name").value,[4,this.generateToken(this.jsPaymentClient,this.component,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.nameOnblur=function(){var e=document.querySelector("#name-field-wrapper"),t=document.querySelector("#name").value,n=document.querySelector("#name-message");t?(n.style.display="none",e.setAttribute("class","name-field-wrapper is-valid")):(n.style.display="inline-block",e.setAttribute("class","name-field-wrapper is-error"))},t.prototype.renderHtml=function(){var e,t,n,l,o,a,r=function(e){var t,n,l,o,a,r,d,u,s,p;return{common:(null==e?void 0:e.commonStyle)||{},form:i({fontFamily:"Helvetica, sans-serif"},(null===(t=null==e?void 0:e.componentStyle)||void 0===t?void 0:t.formStyle)||{}),name:{wrapper:i({paddingBottom:"14px",paddingRight:"25px"},(null===(l=null===(n=null==e?void 0:e.componentStyle)||void 0===n?void 0:n.nameInputStyle)||void 0===l?void 0:l.inputWrapperStyle)||{}),label:i({display:"inline-block",marginBottom:"9px",color:"#313131",fontSize:"14px",fontWeight:"300",lineHeight:"17px"},(null===(a=null===(o=null==e?void 0:e.componentStyle)||void 0===o?void 0:o.nameInputStyle)||void 0===a?void 0:a.labelStyle)||{}),input:i({padding:"10px 12px",outline:"none",margin:0,fontFamily:"inherit",display:"block",width:"100%",height:"42px",fontSize:"18px",fontWeight:"400",lineHeight:"22px",color:"#313131",backgroundClip:"padding-box",borderRadius:"3px",transition:"border-color .15s ease-in-out,box-shadow .15s ease-in-out",ontline:"0"},(null===(d=null===(r=null==e?void 0:e.componentStyle)||void 0===r?void 0:r.nameInputStyle)||void 0===d?void 0:d.inputStyle)||{}),message:i({display:"none",color:"#D9534F",fontSize:"10px",fontStyle:"italic",marginTop:"6px",marginBottom:"-5px",lineHeight:"1"},(null===(s=null===(u=null==e?void 0:e.componentStyle)||void 0===u?void 0:u.nameInputStyle)||void 0===s?void 0:s.messageStyle)||{})},submit:{wrapper:{paddingRight:"25px",width:"100%",textAlign:"center"},button:i({color:"#fff",backgroundColor:"#007bff",borderColor:"#007bff",display:"inline-block",fontWeight:"400",textAlign:"center",verticalAlign:"middle",border:"1px solid transparent",padding:".375rem .75rem",fontSize:"1rem",lineHeight:"1.5",borderRadius:".25rem"},(null===(p=null==e?void 0:e.componentStyle)||void 0===p?void 0:p.btnStyle)||{})}}}(null===(e=this.initialData)||void 0===e?void 0:e.styleOption),d={nameOnblur:this.nameOnblur,nameInputText:null===(n=null===(t=this.initialData)||void 0===t?void 0:t.label)||void 0===n?void 0:n.userNameLabel,submitBtnText:null===(l=this.initialData)||void 0===l?void 0:l.btnText,nameMessageText:null===(a=null===(o=this.initialData)||void 0===o?void 0:o.errorTips)||void 0===a?void 0:a.userNameErrorTips,style:r};this.renderToDom(function(e){return c("div",{className:"two-checkout",style:e.style.common},c("div",{dangerouslySetInnerHTML:{__html:"<style>\n        .two-checkout * {\n          box-sizing: border-box;\n        }\n        .name-input {\n          border: 1px solid #CBCBCB;\n          background-color: #fff,\n        }\n        input:focus {\n          border          : 1px solid #5D5D5D;\n          background-color: #FFFDF2;\n        }\n        \n        .is-error input {\n          border: 1px solid #D9534F;\n        }\n        \n        .is-error input:focus {\n          background-color: #D9534F0B;\n        }\n        \n        .is-valid input {\n          border: 1px solid #1BB43F;\n        }\n        \n        .is-valid input:focus {\n          background-color: #1BB43F0B;\n        }\n                </style>"}}),c("form",{type:"post",id:"payment-form",style:e.style.form},c("div",{className:"twocheckout-group"},(null==e?void 0:e.nameInputText)?c("div",{id:"name-field-wrapper",class:"name-field-wrapper",style:e.style.name.wrapper},c("label",{for:"name",class:"name-label",style:e.style.name.label},null==e?void 0:e.nameInputText),c("input",{type:"text",id:"name",name:"name",class:"name-input",style:e.style.name.input,oninput:function(e){e.target.value=e.target.value.replace(/[1-9]/g,"")},onblur:function(){e.nameOnblur()}}),c("span",{id:"name-message",style:e.style.name.message},e.nameMessageText||"Card holder name is empty.")):null,c("div",{id:"card-element",className:"card-element"}),(null==e?void 0:e.submitBtnText)?c("div",{style:e.style.submit.wrapper},c("button",{className:"twocheckout-btn",style:e.style.submit.button,type:"submit"},null==e?void 0:e.submitBtnText)):null)))}(d),this.initialData.domId)},t}(v);var b=function(e){function t(t,n){var i=e.call(this)||this;return i.publicKey=t,i.initialData=n,i.userNameErrorTips="",i.cardNumberErrorTips="",i.expirationErrorTips="",i.cvvErrorTips="",i.userName="",i.cardNumber="",i.expiration="",i.cvv="",i.loadEBANXJS(),i.renderHtml(),i}return n(t,e),t.prototype.loadEBANXJS=function(){var e,t,n=this,i=(new Date).getTime();m(["https://js.ebanx.com/assets/songbird/songbird-"+(null!==(t=null===(e=this.initialData)||void 0===e?void 0:e.env)&&void 0!==t?t:"dev")+".js","https://js.ebanx.com/ebanx-libjs-latest.min.js"],(function(){var e,t,l,o;console.log("success",EBANX),EBANX.config.setMode("prod"===(null===(e=n.initialData)||void 0===e?void 0:e.env)?"production":"test"),EBANX.config.setPublishableKey(n.publicKey.key),EBANX.config.setCountry((null===(t=n.initialData)||void 0===t?void 0:t.country)||"br");var a=(new Date).getTime()-i;null===(o=null===(l=n.initialData)||void 0===l?void 0:l.reportSDKLoading)||void 0===o||o.call(l,{time:a})}))},t.prototype.renderHtml=function(){var e,t,n,l,o,a,r=function(e){null==e||e.commonStyle;var t=null==e?void 0:e.componentStyle,n=null==t?void 0:t.formStyle,l=null==t?void 0:t.nameInputStyle,o=null==t?void 0:t.cardInputStyle,a=null==t?void 0:t.expirationInputStyle,r=null==t?void 0:t.cvvInputStyle,d=null==t?void 0:t.btnStyle;return{ebanx_payment_form:i({width:"100%"},n||{}),ebanx_nameInputStyle_inputWrapperStyle:i({width:"100%",margin:"10px 0"},(null==l?void 0:l.inputWrapperStyle)||{}),ebanx_nameInputStyle_labelStyle:i({display:"block",fontWeight:400,fontSize:"15px",marginBottom:"8px"},(null==l?void 0:l.labelStyle)||{}),ebanx_nameInputStyle_inputStyle:i({width:"100%",padding:"18px 15px",borderRadius:"6px",color:"#000000",background:"#F3F3F3",border:"0px",fontSize:"16px",outline:"none"},(null==l?void 0:l.inputStyle)||{}),ebanx_nameInputStyle_messageStyle:{},ebanx_cardInputStyle_inputWrapperStyle:i({width:"100%",margin:"10px 0"},(null==o?void 0:o.inputWrapperStyle)||{}),ebanx_cardInputStyle_labelStyle:i({display:"block",fontWeight:400,fontSize:"15px",marginBottom:"8px"},(null==o?void 0:o.labelStyle)||{}),ebanx_cardInputStyle_inputStyle:i({width:"100%",padding:"18px 15px",borderRadius:"6px",color:"#000000",background:"#F3F3F3",border:"0px",fontSize:"16px",outline:"none"},(null==o?void 0:o.inputStyle)||{}),ebanx_cardInputStyle_messageStyle:{},ebanx_flex_style:{display:"flex",justifyContent:"space-between",alignItems:"center"},ebanx_expirationInputStyle_inputWrapperStyle:i({width:"48%",margin:"10px 0"},(null==a?void 0:a.inputWrapperStyle)||{}),ebanx_expirationInputStyle_labelStyle:i({display:"block",fontWeight:400,fontSize:"15px",marginBottom:"8px"},(null==a?void 0:a.labelStyle)||{}),ebanx_expirationInputStyle_inputStyle:i({width:"100%",padding:"18px 15px",borderRadius:"6px",color:"#000000",background:"#F3F3F3",border:"0px",fontSize:"16px",outline:"none"},(null==a?void 0:a.inputStyle)||{}),ebanx_expirationInputStyle_messageStyle:{},ebanx_cvvInputStyle_inputWrapperStyle:i({width:"48%",margin:"10px 0"},(null==r?void 0:r.inputWrapperStyle)||{}),ebanx_cvvInputStyle_labelStyle:i({display:"block",fontWeight:400,fontSize:"15px",marginBottom:"8px"},(null==r?void 0:r.labelStyle)||{}),ebanx_cvvInputStyle_inputStyle:i({width:"100%",padding:"18px 15px",borderRadius:"6px",color:"#000000",background:"#F3F3F3",border:"0px",fontSize:"16px",outline:"none"},(null==r?void 0:r.inputStyle)||{}),ebanx_cvvInputStyle_messageStyle:{},ebanx_error_tips:i(i(i(i({marginTop:"-10px",lineHeight:"18px",minHeight:"20px",color:"red"},(null==l?void 0:l.messageStyle)||{}),(null==o?void 0:o.messageStyle)||{}),(null==a?void 0:a.messageStyle)||{}),(null==r?void 0:r.messageStyle)||{}),ebanx_submit_btn:i({width:"100%",color:"#ffffff",padding:"15px",fontSize:"16px",opacity:1,background:(null==d?void 0:d.disableBackground)||(null==d?void 0:d.background)||"#dddddd",outline:"none",border:"0px",borderRadius:"6px"},d)}}(null===(e=this.initialData)||void 0===e?void 0:e.styleOption);this.renderToDom(function(e){var t,n,i,l,o,a,r,d,u,s,p,v,m,y,b,f,h,x,g,S,_,k,N,T,w,D,I,E,C,B,O,F;return c("div",{className:"ebanx_cover"},c("div",{dangerouslySetInnerHTML:{__html:"<style>\n        .ebanx_cover * {\n          box-sizing: border-box !important;\n          margin: 0;\n          padding: 0;\n        }\n        .ebanx_cover input::placeholder{\n          color: #999999 !important;\n        }\n        </style>"}}),c("div",{className:"ebanx_payment_form",style:e.styleOption.ebanx_payment_form},!e.userName&&c("div",{calssName:"ebanx_nameInputStyle_inputWrapperStyle",style:e.styleOption.ebanx_nameInputStyle_inputWrapperStyle},(null===(t=null==e?void 0:e.label)||void 0===t?void 0:t.userNameLabel)&&c("label",{for:"ebanx_user_name",className:"ebanx_nameInputStyle_labelStyle",style:null===(n=e.styleOption)||void 0===n?void 0:n.ebanx_nameInputStyle_labelStyle},null!==(l=null===(i=null==e?void 0:e.label)||void 0===i?void 0:i.userNameLabel)&&void 0!==l?l:"User Name"),c("input",{placeholder:""+(null!==(a=null===(o=null==e?void 0:e.placeholder)||void 0===o?void 0:o.userNamePlaceholder)&&void 0!==a?a:"User Name"),type:"text",id:"ebanx_user_name",className:"ebanx_nameInputStyle_inputStyle",style:null===(r=e.styleOption)||void 0===r?void 0:r.ebanx_nameInputStyle_inputStyle,onkeyup:function(t){e.changeUserName(t,"onkeyup")},onblur:function(t){e.changeUserName(t,"onblur")}})),c("div",{className:"ebanx_cardInputStyle_inputWrapperStyle",style:e.styleOption.ebanx_cardInputStyle_inputWrapperStyle},(null===(d=null==e?void 0:e.label)||void 0===d?void 0:d.cardNumberLabel)&&c("label",{for:"ebanx_card_number",className:"ebanx_cardInputStyle_labelStyle",style:null===(u=e.styleOption)||void 0===u?void 0:u.ebanx_cardInputStyle_labelStyle},null!==(p=null===(s=null==e?void 0:e.label)||void 0===s?void 0:s.cardNumberLabel)&&void 0!==p?p:"Card Number"),c("div",null,c("input",{placeholder:""+(null!==(m=null===(v=null==e?void 0:e.placeholder)||void 0===v?void 0:v.cardNumberPlaceholder)&&void 0!==m?m:"Card Number"),type:"number",id:"ebanx_card_number",className:"ebanx_cardInputStyle_inputStyle",style:null===(y=e.styleOption)||void 0===y?void 0:y.ebanx_cardInputStyle_inputStyle,onkeyup:function(t){e.changeCardNumber(t,"onkeyup")},onblur:function(t){e.changeCardNumber(t,"onblur")}}))),c("div",{className:"ebanx_flex_style",style:e.styleOption.ebanx_flex_style},c("div",{className:"ebanx_expirationInputStyle_inputWrapperStyle",style:e.styleOption.ebanx_expirationInputStyle_inputWrapperStyle},(null===(b=null==e?void 0:e.label)||void 0===b?void 0:b.expirationLabel)&&c("label",{for:"ebanx_card_due_date",className:"ebanx_expirationInputStyle_labelStyle",style:null===(f=e.styleOption)||void 0===f?void 0:f.ebanx_expirationInputStyle_labelStyle},null!==(x=null===(h=null==e?void 0:e.label)||void 0===h?void 0:h.expirationLabel)&&void 0!==x?x:"Card Due Date"),c("input",{placeholder:(null!==(S=null===(g=null==e?void 0:e.placeholder)||void 0===g?void 0:g.expiryMonthPlaceholder)&&void 0!==S?S:"MM")+"/"+(null!==(k=null===(_=null==e?void 0:e.placeholder)||void 0===_?void 0:_.expiryYearPlaceholder)&&void 0!==k?k:"YYYY"),type:"text",id:"ebanx_card_due_date",className:"ebanx_expirationInputStyle_inputStyle",style:null===(N=e.styleOption)||void 0===N?void 0:N.ebanx_expirationInputStyle_inputStyle,onblur:function(t){e.changeExpiration(t,"onblur")},onkeyup:function(t){var n,i,l;t.target.value=null===(l=null===(i=null===(n=t.target.value)||void 0===n?void 0:n.replace(/\D/g,""))||void 0===i?void 0:i.slice(0,6))||void 0===l?void 0:l.replace(/^(\d{2})\/?(\d{0,})$/,(function(e,t,n){return""+t+(n?"/"+n:n)})),e.changeExpiration(t,"onkeyup")}})),c("div",{className:"ebanx_cvvInputStyle_inputWrapperStyle",style:e.styleOption.ebanx_cvvInputStyle_inputWrapperStyle},(null===(T=null==e?void 0:e.label)||void 0===T?void 0:T.cvvLabel)&&c("label",{for:"ebanx_card_cvv",className:"ebanx_cvvInputStyle_labelStyle",style:null===(w=e.styleOption)||void 0===w?void 0:w.ebanx_cvvInputStyle_labelStyle},null!==(I=null===(D=null==e?void 0:e.label)||void 0===D?void 0:D.cvvLabel)&&void 0!==I?I:"Card Cvv"),c("input",{placeholder:""+(null!==(C=null===(E=null==e?void 0:e.placeholder)||void 0===E?void 0:E.cvvPlaceholder)&&void 0!==C?C:"Cvv"),type:"number",id:"ebanx_card_cvv",className:"ebanx_cvvInputStyle_inputStyle",style:null===(B=e.styleOption)||void 0===B?void 0:B.ebanx_cvvInputStyle_inputStyle,onkeyup:function(t){e.changeCVV(t,"onkeyup")},onblur:function(t){e.changeCVV(t,"onblur")}}))),c("div",{id:"ebanx_error_tips",className:"ebanx_error_tips",style:e.styleOption.ebanx_error_tips}),(null==e?void 0:e.btnText)&&c("button",{type:"submit",id:"ebanx_submit_btn",className:"ebanx_submit_btn",style:null===(O=e.styleOption)||void 0===O?void 0:O.ebanx_submit_btn,disabled:!0,onClick:function(t){null==e||e.submit(t)}},null!==(F=null==e?void 0:e.btnText)&&void 0!==F?F:"OK")))}({submit:this.submit.bind(this),changeUserName:this.changeUserName.bind(this),changeCardNumber:this.changeCardNumber.bind(this),changeExpiration:this.changeExpiration.bind(this),changeCVV:this.changeCVV.bind(this),label:null===(t=this.initialData)||void 0===t?void 0:t.label,placeholder:null===(n=this.initialData)||void 0===n?void 0:n.placeholder,btnText:null===(l=this.initialData)||void 0===l?void 0:l.btnText,styleOption:r,userName:null===(a=null===(o=this.initialData)||void 0===o?void 0:o.fieldData)||void 0===a?void 0:a.userName}),this.initialData.domId)},t.prototype.fieldOnChange=function(e,t){var n,i,l,o,a,r;e.message||(this.userNameErrorTips&&!(null===(i=null===(n=this.initialData)||void 0===n?void 0:n.fieldData)||void 0===i?void 0:i.userName)&&(e.message=this.userNameErrorTips,e.param="username"),this.cardNumberErrorTips&&(e.message=this.cardNumberErrorTips,e.param="cardnumber"),this.expirationErrorTips&&(e.message=this.expirationErrorTips,e.param="expiration"),this.cvvErrorTips&&(e.message=this.cvvErrorTips,e.param="cvv")),"onblur"!==t&&e.message||(document.getElementById("ebanx_error_tips").innerText=e.message),"onblur"===t&&(null===(o=null===(l=this.initialData)||void 0===l?void 0:l.fieldOnBlur)||void 0===o||o.call(l,e)),"onkeyup"===t&&(null===(r=null===(a=this.initialData)||void 0===a?void 0:a.fieldOnChange)||void 0===r||r.call(a,e)),this.fieldComplete()},t.prototype.fieldComplete=function(){var e,t,n,i,l,o,a,r,d,u,s,p,c=document.getElementById("ebanx_submit_btn");((null===(t=null===(e=this.initialData)||void 0===e?void 0:e.fieldData)||void 0===t?void 0:t.userName)||!this.userNameErrorTips&&this.userName)&&!this.cardNumberErrorTips&&!this.expirationErrorTips&&!this.cvvErrorTips&&this.cardNumber&&this.expiration&&this.cvv?(console.log("表单填写完成"),c.removeAttribute("disabled"),c.style.background=(null===(o=null===(l=null===(i=null===(n=this.initialData)||void 0===n?void 0:n.styleOption)||void 0===i?void 0:i.componentStyle)||void 0===l?void 0:l.btnStyle)||void 0===o?void 0:o.normalBackground)||"#ffc102",null===(r=null===(a=this.initialData)||void 0===a?void 0:a.fieldComplete)||void 0===r||r.call(a,{userName:this.userName,cardNumber:this.cardNumber,expiration:this.expiration,cvv:this.cvv})):(console.log("表单没填写完成"),c.setAttribute("disabled","disabled"),c.style.background=(null===(p=null===(s=null===(u=null===(d=this.initialData)||void 0===d?void 0:d.styleOption)||void 0===u?void 0:u.componentStyle)||void 0===s?void 0:s.btnStyle)||void 0===p?void 0:p.disableBackground)||"#dddddd")},t.prototype.changeUserName=function(e,t){var n,i,l;this.userName=e.target.value,l=this.userName,/^[\s\S]{2,50}$/.test(l)?this.userNameErrorTips="":this.userNameErrorTips=(null===(i=null===(n=this.initialData)||void 0===n?void 0:n.errorTips)||void 0===i?void 0:i.userNameErrorTips)||"The username is incorrect.",this.fieldOnChange({message:this.userNameErrorTips,param:"username"},t)},t.prototype.changeCardNumber=function(e,t,n){var i,a;return l(this,void 0,void 0,(function(){return o(this,(function(l){return this.cardNumber=e.target.value,n&&this.cardNumber.length!==n||(o=this.cardNumber,/^\d{12,19}$/.test(o)?this.cardNumberErrorTips="":this.cardNumberErrorTips=(null===(a=null===(i=this.initialData)||void 0===i?void 0:i.errorTips)||void 0===a?void 0:a.cardNumberErrorTips)||"The card number is incorrect.",this.fieldOnChange({message:this.cardNumberErrorTips,param:"cardnumber"},t)),[2];var o}))}))},t.prototype.changeExpiration=function(e,t){var n,i,l,o,a,r,d,u,s;this.expiration=e.target.value,l=this.expiration,o=new Date,a=o.getFullYear(),r=o.getMonth()+1,d=l.split("/"),u=Number(d[1]),s=Number(d[0]),this.expirationErrorTips=s<1||s>12||!(a<u||a===u&&r<=s)?(null===(i=null===(n=this.initialData)||void 0===n?void 0:n.errorTips)||void 0===i?void 0:i.expirationErrorTips)||"The card’s expiration date is incorrect.":"",this.fieldOnChange({message:this.expirationErrorTips,param:"expiration"},t)},t.prototype.changeCVV=function(e,t){var n,i,l;this.cvv=e.target.value,l=this.cvv,/^\d{3,4}$/.test(l)?this.cvvErrorTips="":this.cvvErrorTips=(null===(i=null===(n=this.initialData)||void 0===n?void 0:n.errorTips)||void 0===i?void 0:i.cvvErrorTips)||"The card’s security code is incorrect.",this.fieldOnChange({message:this.cvvErrorTips,param:"cvv"},t)},t.prototype.submit=function(e){var t,n,i=this,l=document.getElementById("ebanx_submit_btn");l.setAttribute("disabled","disabled"),EBANX.card.createToken({card_number:document.getElementById("ebanx_card_number").value,card_name:(null===(n=null===(t=this.initialData)||void 0===t?void 0:t.fieldData)||void 0===n?void 0:n.userName)||document.getElementById("ebanx_user_name").value,card_due_date:document.getElementById("ebanx_card_due_date").value,card_cvv:document.getElementById("ebanx_card_cvv").value},(function(e){var t,n,o,a,r,d,u;if(l.removeAttribute("disabled"),null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.hasOwnProperty("status"));else{var s=(null===(o=null===(n=null==e?void 0:e.error)||void 0===n?void 0:n.err)||void 0===o?void 0:o.status_message)||(null===(r=null===(a=null==e?void 0:e.error)||void 0===a?void 0:a.err)||void 0===r?void 0:r.message)||"";document.getElementById("ebanx_error_tips").textContent=s}null===(u=null===(d=i.initialData)||void 0===d?void 0:d.createToken)||void 0===u||u.call(d,e)}))},t.prototype.getToken=function(){return l(this,void 0,void 0,(function(){var e=this;return o(this,(function(t){return console.log("getToken"),[2,new Promise((function(t,n){var i,l;EBANX.card.createToken({card_number:document.getElementById("ebanx_card_number").value,card_name:(null===(l=null===(i=e.initialData)||void 0===i?void 0:i.fieldData)||void 0===l?void 0:l.userName)||document.getElementById("ebanx_user_name").value,card_due_date:document.getElementById("ebanx_card_due_date").value,card_cvv:document.getElementById("ebanx_card_cvv").value},(function(e){var i,l,o,a,r;if(null===(i=null==e?void 0:e.data)||void 0===i?void 0:i.hasOwnProperty("status"))t(e);else{var d=(null===(o=null===(l=null==e?void 0:e.error)||void 0===l?void 0:l.err)||void 0===o?void 0:o.status_message)||(null===(r=null===(a=null==e?void 0:e.error)||void 0===a?void 0:a.err)||void 0===r?void 0:r.message)||"";document.getElementById("ebanx_error_tips").textContent=d,n(e)}}))}))]}))}))},t}(v),f=function(){function e(e,t){this.publicKey=e,this.initialData=t,this.initSDK()}return e.prototype.checkKey=function(e){return console.log(e),!0},e.prototype.getToken=function(e){return l(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this.sdk.getToken(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.initSDK=function(){return l(this,void 0,void 0,(function(){return o(this,(function(e){if(!this.checkKey(this.publicKey))return[2];switch(this.initialData.sdkName){case"2checkout":this.sdk=new y(this.publicKey,this.initialData);break;case"ebanx":this.sdk=new b(this.publicKey,this.initialData)}return[2]}))}))},e}();e.Ebanx=b,e.TwoCheckOut=y,e.default=f,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=index.js.map
