!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 o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function o(e,t,n,i){return new(n||(n=Promise))((function(o,l){function r(e){try{u(i.next(e))}catch(e){l(e)}}function a(e){try{u(i.throw(e))}catch(e){l(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}u((i=i.apply(e,t||[])).next())}))}function l(e,t){var n,i,o,l,r={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return l={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function a(l){return function(a){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(o=2&l[0]?i.return:l[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,l[1])).done)return o;switch(i=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,i=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(!(o=r.trys,(o=o.length>0&&o[o.length-1])||6!==l[0]&&2!==l[0])){r=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){r.label=l[1];break}if(6===l[0]&&r.label<o[1]){r.label=o[1],o=l;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(l);break}o[2]&&r.ops.pop(),r.trys.pop();continue}l=t.call(e,r)}catch(e){l=[6,e],i=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,a])}}}const r=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"]);r.delete("a"),r.delete("audio"),r.delete("canvas"),r.delete("iframe"),r.delete("script"),r.delete("video");const a=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,u=(e,t)=>{for(let[n,i]of Object.entries(t))"number"!=typeof i||a.test(n)||(i+="px"),e.style[n]=i},d=e=>"string"==typeof e?r.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 o=d(e);if(p(o,n),o instanceof DocumentFragment||!t)return o;for(let[e,n]of Object.entries(t))if("htmlFor"===e&&(e="for"),"class"===e||"className"===e){const e=null!==(i=o.getAttribute("class"))&&void 0!==i?i:"";s(o,"class",(e+" "+String(n)).trim())}else if("style"===e)u(o,n);else if(e.startsWith("on")){const t=e.slice(2).toLowerCase();o.addEventListener(t,n)}else"dangerouslySetInnerHTML"===e&&"__html"in n?o.innerHTML=n.__html:"key"!==e&&!1!==n&&s(o,e,!0===n?"":n);return o};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 o(e,t){if(e){var o=i[e];if(n[e]=t,o)for(;o.length;)o[0](e,t),o.splice(0,1)}}function l(t,n){t.call&&(t={success:t}),n.length?(t.error||e)(n):(t.success||e)(t)}function r(t,n,i,o){var l,a,u=document,d=i.async,s=(i.numRetries||0)+1,p=i.before||e,c=t.replace(/[\?|#].*$/,""),v=t.replace(/^(css|img)!/,"");o=o||0,/(^css!|\.css$)/.test(c)?((a=u.createElement("link")).rel="stylesheet",a.href=v,(l="hideFocus"in a)&&a.relList&&(l=0,a.rel="preload",a.as="style")):/(^img!|\.(png|gif|jpg|svg|webp)$)/.test(c)?(a=u.createElement("img")).src=v:((a=u.createElement("script")).src=t,a.async=void 0===d||d),a.onload=a.onerror=a.onbeforeload=function(e){var u=e.type[0];if(l)try{a.sheet.cssText.length||(u="e")}catch(e){18!=e.code&&(u="e")}if("e"==u){if((o+=1)<s)return r(t,n,i,o)}else if("preload"==a.rel&&"style"==a.as)return a.rel="stylesheet";n(t,u,e.defaultPrevented)},!1!==p(t,a)&&u.head.appendChild(a)}function a(e,n,i){var a,u;if(n&&n.trim&&(a=n),u=(a?i:n)||{},a){if(a in t)throw"LoadJS";t[a]=!0}function d(t,n){!function(e,t,n){var i,o,l=(e=e.push?e:[e]).length,a=l,u=[];for(i=function(e,n,i){if("e"==n&&u.push(e),"b"==n){if(!i)return;u.push(e)}--l||t(u)},o=0;o<a;o++)r(e[o],i,n)}(e,(function(e){l(u,e),t&&l({success:t,error:n},e),o(a,e)}),u)}if(u.returnPromise)return new Promise(d);d()}return a.ready=function(e,t){return function(e,t){e=e.push?e:[e];var o,l,r,a=[],u=e.length,d=u;for(o=function(e,n){n.length&&a.push(e),--d||t(a)};u--;)l=e[u],(r=n[l])?o(l,r):(i[l]=i[l]||[]).push(o)}(e,(function(e){l(t,e)})),a},a.done=function(e){o(e,[])},a.reset=function(){t={},n={},i={}},a.isDefined=function(e){return e in t},a}()})),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 r=(new Date).getTime();return m(["https://2pay-js.2checkout.com/v1/2pay.js"],(function(){var e,a;console.log("2checkout.js loaded"),window.addEventListener("load",(function(){var e,r,a,u,d,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,r=null==e?void 0:e.commonStyle,a=null==e?void 0:e.componentStyle,u=null==a?void 0:a.cardInputStyle,d=null==a?void 0:a.expirationInputStyle,s=null==a?void 0:a.cvvInputStyle,{margin:0,fontFamily:(null==r?void 0:r.fontFamily)||"Helvetica, sans-serif",fontSize:(null==r?void 0:r.fontSize)||"1rem",fontWeight:(null==r?void 0:r.fontWeight)||"400",color:(null==r?void 0:r.color)||"#212529",textAlign:(null==r?void 0:r.textAlign)||"left",backgroundColor:(null==r?void 0:r.backgroundColor)||"#ffffff","*":{boxSizing:(null==r?void 0:r.boxSizing)||"border-box"},".card-number .control-label":(null==u?void 0:u.labelStyle)||{},".card-number .input-wrapper":(null==u?void 0:u.inputWrapperStyle)||{},".card-number .form-control":(null==u?void 0:u.inputStyle)||{},".card-number .validation-message":(null==u?void 0:u.messageStyle)||{},".card-expiration-date .control-label":(null==d?void 0:d.labelStyle)||{},".card-expiration-date .input-wrapper":(null==d?void 0:d.inputWrapperStyle)||{},".card-expiration-date .form-control":(null==d?void 0:d.inputStyle)||{},".card-expiration-date .validation-message":(null==d?void 0:d.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 o(i,void 0,void 0,(function(){var t,n;return l(this,(function(i){switch(i.label){case 0:return e.preventDefault(),t=document.querySelector("#name").value,[4,this.generateToken(this.jsPaymentClient,this.component,t)];case 1:return n=i.sent(),this.initialData.createToken&&this.initialData.createToken(n),[2]}}))}))}))})),i.renderHtml();var u=(new Date).getTime()-r;null===(a=null===(e=i.initialData)||void 0===e?void 0:e.reportSDKLoading)||void 0===a||a.call(e,{time:u})})),i}return n(t,e),t.prototype.generateToken=function(e,t,n){return o(this,void 0,void 0,(function(){var i,o;return l(this,(function(l){switch(l.label){case 0:this.nameOnblur(),i={name:n},l.label=1;case 1:return l.trys.push([1,3,,4]),[4,e.tokens.generate(t,i)];case 2:return[2,l.sent()];case 3:return o=l.sent(),console.log(o),[2,o];case 4:return[2]}}))}))},t.prototype.getToken=function(e){return o(this,void 0,void 0,(function(){var t;return l(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,o,l,r,a=function(e){var t,n,o,l,r,a,u,d,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===(o=null===(n=null==e?void 0:e.componentStyle)||void 0===n?void 0:n.nameInputStyle)||void 0===o?void 0:o.inputWrapperStyle)||{}),label:i({display:"inline-block",marginBottom:"9px",color:"#313131",fontSize:"14px",fontWeight:"300",lineHeight:"17px"},(null===(r=null===(l=null==e?void 0:e.componentStyle)||void 0===l?void 0:l.nameInputStyle)||void 0===r?void 0:r.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===(u=null===(a=null==e?void 0:e.componentStyle)||void 0===a?void 0:a.nameInputStyle)||void 0===u?void 0:u.inputStyle)||{}),message:i({display:"none",color:"#D9534F",fontSize:"10px",fontStyle:"italic",marginTop:"6px",marginBottom:"-5px",lineHeight:"1"},(null===(s=null===(d=null==e?void 0:e.componentStyle)||void 0===d?void 0:d.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),u={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===(o=this.initialData)||void 0===o?void 0:o.btnText,nameMessageText:null===(r=null===(l=this.initialData)||void 0===l?void 0:l.errorTips)||void 0===r?void 0:r.userNameErrorTips,style:a};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)))}(u),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,o,l;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 r=(new Date).getTime()-i;null===(l=null===(o=n.initialData)||void 0===o?void 0:o.reportSDKLoading)||void 0===l||l.call(o,{time:r})}))},t.prototype.renderHtml=function(){var e,t,n,o,l=function(e){null==e||e.commonStyle;var t=null==e?void 0:e.componentStyle,n=null==t?void 0:t.formStyle,o=null==t?void 0:t.nameInputStyle,l=null==t?void 0:t.cardInputStyle,r=null==t?void 0:t.expirationInputStyle,a=null==t?void 0:t.cvvInputStyle,u=null==t?void 0:t.btnStyle;return{ebanx_payment_form:i({width:"100%"},n||{}),ebanx_nameInputStyle_inputWrapperStyle:i({width:"100%",margin:"10px 0"},(null==o?void 0:o.inputWrapperStyle)||{}),ebanx_nameInputStyle_labelStyle:i({display:"block",fontWeight:400,fontSize:"15px",marginBottom:"8px"},(null==o?void 0:o.labelStyle)||{}),ebanx_nameInputStyle_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_nameInputStyle_messageStyle:{},ebanx_cardInputStyle_inputWrapperStyle:i({width:"100%",margin:"10px 0"},(null==l?void 0:l.inputWrapperStyle)||{}),ebanx_cardInputStyle_labelStyle:i({display:"block",fontWeight:400,fontSize:"15px",marginBottom:"8px"},(null==l?void 0:l.labelStyle)||{}),ebanx_cardInputStyle_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_cardInputStyle_messageStyle:{},ebanx_flex_style:{display:"flex",justifyContent:"space-between",alignItems:"center"},ebanx_expirationInputStyle_inputWrapperStyle:i({width:"48%",margin:"10px 0"},(null==r?void 0:r.inputWrapperStyle)||{}),ebanx_expirationInputStyle_labelStyle:i({display:"block",fontWeight:400,fontSize:"15px",marginBottom:"8px"},(null==r?void 0:r.labelStyle)||{}),ebanx_expirationInputStyle_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_expirationInputStyle_messageStyle:{},ebanx_cvvInputStyle_inputWrapperStyle:i({width:"48%",margin:"10px 0"},(null==a?void 0:a.inputWrapperStyle)||{}),ebanx_cvvInputStyle_labelStyle:i({display:"block",fontWeight:400,fontSize:"15px",marginBottom:"8px"},(null==a?void 0:a.labelStyle)||{}),ebanx_cvvInputStyle_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_cvvInputStyle_messageStyle:{},ebanx_error_tips:i(i(i(i({marginTop:"-10px",lineHeight:"18px",minHeight:"20px",color:"red"},(null==o?void 0:o.messageStyle)||{}),(null==l?void 0:l.messageStyle)||{}),(null==r?void 0:r.messageStyle)||{}),(null==a?void 0:a.messageStyle)||{}),ebanx_submit_btn:i({width:"100%",color:"#ffffff",padding:"15px",fontSize:"16px",opacity:1,background:(null==u?void 0:u.disableBackground)||(null==u?void 0:u.background)||"#dddddd",outline:"none",border:"0px",borderRadius:"6px"},u)}}(null===(e=this.initialData)||void 0===e?void 0:e.styleOption);this.renderToDom(function(e){var t,n,i,o,l,r,a,u,d,s,p,v,m,y,b,f,h,x,g,S,_,k,T,w,N,I,D,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},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!==(o=null===(i=null==e?void 0:e.label)||void 0===i?void 0:i.userNameLabel)&&void 0!==o?o:"User Name"),c("input",{placeholder:""+(null!==(r=null===(l=null==e?void 0:e.placeholder)||void 0===l?void 0:l.userNamePlaceholder)&&void 0!==r?r:"User Name"),type:"text",id:"ebanx_user_name",className:"ebanx_nameInputStyle_inputStyle",style:null===(a=e.styleOption)||void 0===a?void 0:a.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===(u=null==e?void 0:e.label)||void 0===u?void 0:u.cardNumberLabel)&&c("label",{for:"ebanx_card_number",className:"ebanx_cardInputStyle_labelStyle",style:null===(d=e.styleOption)||void 0===d?void 0:d.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===(T=e.styleOption)||void 0===T?void 0:T.ebanx_expirationInputStyle_inputStyle,onblur:function(t){e.changeExpiration(t,"onblur")},onkeyup:function(t){var n,i,o;t.target.value=null===(o=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===o?void 0:o.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===(w=null==e?void 0:e.label)||void 0===w?void 0:w.cvvLabel)&&c("label",{for:"ebanx_card_cvv",className:"ebanx_cvvInputStyle_labelStyle",style:null===(N=e.styleOption)||void 0===N?void 0:N.ebanx_cvvInputStyle_labelStyle},null!==(D=null===(I=null==e?void 0:e.label)||void 0===I?void 0:I.cvvLabel)&&void 0!==D?D:"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===(o=this.initialData)||void 0===o?void 0:o.btnText,styleOption:l}),this.initialData.domId)},t.prototype.fieldOnChange=function(e,t){var n,i,o,l;e.message||(this.userNameErrorTips&&(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===(i=null===(n=this.initialData)||void 0===n?void 0:n.fieldOnBlur)||void 0===i||i.call(n,e)),"onkeyup"===t&&(null===(l=null===(o=this.initialData)||void 0===o?void 0:o.fieldOnChange)||void 0===l||l.call(o,e)),this.fieldComplete()},t.prototype.fieldComplete=function(){var e,t,n,i,o,l,r,a,u,d,s=document.getElementById("ebanx_submit_btn");!this.userNameErrorTips&&!this.cardNumberErrorTips&&!this.expirationErrorTips&&!this.cvvErrorTips&&this.userName&&this.cardNumber&&this.expiration&&this.cvv?(console.log("表单填写完成"),s.removeAttribute("disabled"),s.style.background=(null===(i=null===(n=null===(t=null===(e=this.initialData)||void 0===e?void 0:e.styleOption)||void 0===t?void 0:t.componentStyle)||void 0===n?void 0:n.btnStyle)||void 0===i?void 0:i.normalBackground)||"#ffc102",null===(l=null===(o=this.initialData)||void 0===o?void 0:o.fieldComplete)||void 0===l||l.call(o,{userName:this.userName,cardNumber:this.cardNumber,expiration:this.expiration,cvv:this.cvv})):(console.log("表单没填写完成"),s.setAttribute("disabled","disabled"),s.style.background=(null===(d=null===(u=null===(a=null===(r=this.initialData)||void 0===r?void 0:r.styleOption)||void 0===a?void 0:a.componentStyle)||void 0===u?void 0:u.btnStyle)||void 0===d?void 0:d.disableBackground)||"#dddddd")},t.prototype.changeUserName=function(e,t){var n,i,o;this.userName=e.target.value,o=this.userName,/^[\s\S]{2,50}$/.test(o)?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,r;return o(this,void 0,void 0,(function(){return l(this,(function(o){return this.cardNumber=e.target.value,n&&this.cardNumber.length!==n||(l=this.cardNumber,/^\d{12,19}$/.test(l)?this.cardNumberErrorTips="":this.cardNumberErrorTips=(null===(r=null===(i=this.initialData)||void 0===i?void 0:i.errorTips)||void 0===r?void 0:r.cardNumberErrorTips)||"The card number is incorrect.",this.fieldOnChange({message:this.cardNumberErrorTips,param:"cardnumber"},t)),[2];var l}))}))},t.prototype.changeExpiration=function(e,t){var n,i,o,l,r,a,u,d,s;this.expiration=e.target.value,o=this.expiration,l=new Date,r=l.getFullYear(),a=l.getMonth()+1,u=o.split("/"),d=Number(u[1]),s=Number(u[0]),this.expirationErrorTips=s<1||s>12||!(r<d||r===d&&a<=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,o;this.cvv=e.target.value,o=this.cvv,/^\d{3,4}$/.test(o)?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=this,n=document.getElementById("ebanx_submit_btn");n.setAttribute("disabled","disabled"),EBANX.card.createToken({card_number:document.getElementById("ebanx_card_number").value,card_name: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,o,l,r,a,u,d;if(n.removeAttribute("disabled"),null===(i=null==e?void 0:e.data)||void 0===i?void 0:i.hasOwnProperty("status"));else{var s=(null===(l=null===(o=null==e?void 0:e.error)||void 0===o?void 0:o.err)||void 0===l?void 0:l.status_message)||(null===(a=null===(r=null==e?void 0:e.error)||void 0===r?void 0:r.err)||void 0===a?void 0:a.message)||"";document.getElementById("ebanx_error_tips").textContent=s}null===(d=null===(u=t.initialData)||void 0===u?void 0:u.createToken)||void 0===d||d.call(u,e)}))},t.prototype.getToken=function(){return o(this,void 0,void 0,(function(){return l(this,(function(e){return console.log("getToken"),[2,new Promise((function(e,t){EBANX.card.createToken({card_number:document.getElementById("ebanx_card_number").value,card_name: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(n){var i,o,l,r,a;if(null===(i=null==n?void 0:n.data)||void 0===i?void 0:i.hasOwnProperty("status"))e(n);else{var u=(null===(l=null===(o=null==n?void 0:n.error)||void 0===o?void 0:o.err)||void 0===l?void 0:l.status_message)||(null===(a=null===(r=null==n?void 0:n.error)||void 0===r?void 0:r.err)||void 0===a?void 0:a.message)||"";document.getElementById("ebanx_error_tips").textContent=u,t(n)}}))}))]}))}))},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 o(this,void 0,void 0,(function(){return l(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 o(this,void 0,void 0,(function(){return l(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
