1class MPCardForm{TIMEOUT_TO_WAIT_INIT_CARD_FORM=1e4;constructor(){this.form=null,this.formMounted=!1,this.mpFormId="checkout",this.amount=null,this.onReadyDebounce=null,this.fields=null,this.initCardFormTimeoutReference=null,this.isLoading=!1,this.dispatcherMissingReported=!1,this.hasFiredCheckoutOpenedEvent=!1,this.hasReportedAmountTrackingDropped=!1,this.lastTrackedAmount=null,this.cardBinIsValid=!0,this.cardNumberValidity=null,this.cardNumberValidityMessage=null,this.cardBinInvalidMessage=null,this.lastVerdictBin=null,this.currentBin=null,this.sendMelidataTimeToLoadMetric()}async initCardForm(e=this.getAmount()){if(this.amount=e,this.cardNumberFilledValidator=!1,this.stabilizeZeroDollarInitialCitInstallments(),this.dispatchCheckoutAmountEvent(e),!window.mpSdkInstance){const e=new MercadoPago(wc_mercadopago_custom_checkout_params.public_key,{locale:wc_mercadopago_custom_checkout_params.locale});window.mpSdkInstance=e,document.dispatchEvent(new CustomEvent("mp_sdk_instance_ready"))}return new Promise(((t,r)=>{this.createTimeoutToWaitInitCardForm(r),this.form=window.mpSdkInstance.cardForm({amount:e,iframe:!0,form:this.getCardFormConfig(),callbacks:this.getCardFormCallbacks(t,r)})})).then((()=>{this.clearTimeoutToWaitInitCardForm(),this.sendMetric("MP_CARDFORM_SUCCESS","Security fields loaded","mp_custom_checkout_security_fields_client"),CheckoutPage.verifyCardholderNameOnFocus(),CheckoutPage.clearDocumentLabelErrorOnInput(),CheckoutPage.setSecureFieldInstructions()})).catch((e=>{this.clearTimeoutToWaitInitCardForm();const t=this.handleCardFormErrors(e);this.sendMetric("MP_CARDFORM_ERROR",t,"mp_custom_checkout_security_fields_client"),console.error("Mercado Pago cardForm error: ",t)}))}createTimeoutToWaitInitCardForm(e=()=>{}){this.initCardFormTimeoutReference=setTimeout((()=>{this.removeLoadSpinner(),e(new Error(MPCardFormErrorCodes.INIT_CARD_FORM_TIMEOUT))}),this.TIMEOUT_TO_WAIT_INIT_CARD_FORM)}clearTimeoutToWaitInitCardForm(){clearTimeout(this.initCardFormTimeoutReference)}getCardFormConfig(){const e={fontSize:"16px",height:"48px",padding:"14px",textAlign:"left",fontFamily:"Inter ",fontWeight:"400",placeholderColor:"#0000008C"},t={src:"https://fonts.googleapis.com/css2?family=Inter"};return{id:this.mpFormId,cardNumber:{id:"form-checkout__cardNumber-container",placeholder:"1234 1234 1234 1234",style:e,customFonts:[t],enableLuhnValidation:!0},cardholderName:{id:"form-checkout__cardholderName",placeholder:wc_mercadopago_custom_checkout_params.placeholders.cardholderName},cardExpirationDate:{id:"form-checkout__expirationDate-container",placeholder:wc_mercadopago_custom_checkout_params.placeholders.cardExpirationDate,mode:"short",style:e,customFonts:[t]},securityCode:{id:"form-checkout__securityCode-container",placeholder:wc_mercadopago_custom_card_form_params.security_code_placeholder_text_3_digits,style:e,customFonts:[t]},identificationType:{id:"form-checkout__identificationType"},identificationNumber:{id:"form-checkout__identificationNumber"},issuer:{id:"form-checkout__issuer",placeholder:wc_mercadopago_custom_checkout_params.placeholders.issuer},installments:{id:"form-checkout__installments",placeholder:wc_mercadopago_custom_checkout_params.placeholders.installments}}}getCardFormCallbacks(e,t){return{onReady:t=>{this.fields=t,this.cardBinIsValid=!0,this.cardNumberValidity=null,this.cardNumberValidityMessage=null,this.cardBinInvalidMessage=null,this.lastVerdictBin=null,this.currentBin=null,this.setupSecureFieldsStylesAndAddListeners(),e()},onFormMounted:t=>{this.formMounted=!0,document.dispatchEvent(new CustomEvent("mp_card_form_mounted")),e(),t&&this.sendMetric("MP_CARDFORM_MOUNT_ERROR",t?.message||"unknown","mp_custom_checkout_security_fields_client")},onFormUnmounted:t=>{this.formMounted=!1,CheckoutPage.clearInputs(),this.stabilizeZeroDollarInitialCitInstallments(),e(),t&&this.sendMetric("MP_CARDFORM_UNMOUNT_ERROR",t?.message||"unknown","mp_custom_checkout_security_fields_client")},onInstallmentsReceived:(e,t)=>{if(this.isZeroDollarInitialCitContext()&&(!e||e?.message?.includes("payer_costs")))this.stabilizeZeroDollarInitialCitInstallments();else{if(e){const t=wc_mercadopago_custom_checkout_params.error_messages;return this.addErrorAlert(t.installments[e.message]??t.default),void console.warn("Installments handling error: ",e)}CheckoutPage.setChangeEventOnInstallments(t)}},onCardTokenReceived:e=>{e&&console.error("Token handling error: ",e)},onBinChange:e=>{const t="string"==typeof e?e:e&&e.bin||"";this.currentBin=t,t&&t!==this.lastVerdictBin&&(this.cardBinIsValid=!0,this.cardBinInvalidMessage=null,CheckoutPage.setDisplayOfError("fcCardNumberContainer","remove","mp-error"),CheckoutPage.setDisplayOfInputHelper("mp-card-number","none"),"super_token"!==document.querySelector("#mp_checkout_type")?.value&&CheckoutPage.setValueOn("paymentMethodId",""))},onPaymentMethodsReceived:(e,t)=>{if(this.lastVerdictBin=this.currentBin,e){console.error("Payment methods handling error: ",e),this.cardBinIsValid=!1;const t=e?.message?.includes(MPCardFormErrorCodes.NO_PAYMENT_METHODS_FOUND)||e?.toString?.().includes(MPCardFormErrorCodes.NO_PAYMENT_METHODS_FOUND);this.cardBinInvalidMessage=(e?.message||"").replace("MercadoPago.js - ","")||"unknown error message",CheckoutPage.clearCardState(),this.stabilizeZeroDollarInitialCitInstallments();const r=CheckoutPage.getHelperMessage("cardNumber");return r&&(r.innerHTML=t?wc_mercadopago_custom_checkout_params.input_helper_message?.cardNumber?.invali
1d_value??wc_mercadopago_custom_checkout_params.input_helper_message?.cardNumber?.invalid_length??"":wc_mercadopago_custom_checkout_params.input_helper_message?.cardNumber?.invalid_length??""),CheckoutPage.setDisplayOfError("fcCardNumberContainer","add","mp-error"),void CheckoutPage.setDisplayOfInputHelper("mp-card-number","flex")}try{if(t){this.cardBinIsValid=!0,CheckoutPage.clearInputs();const e=t[0];CheckoutPage.setValueOn("paymentMethodId",e.id),CheckoutPage.setCvvConfig(e.settings[0].security_code),CheckoutPage.setImageCard(e.secure_thumbnail||e.thumbnail,e.name),CheckoutPage.setSecureFieldInstructions(e.settings[0].card_number?.length,e.settings[0].security_code?.length);const r=CheckoutPage.loadAdditionalInfo(e.additional_info_needed);CheckoutPage.additionalInfoHandler(r),CheckoutPage.setDisplayOfError("fcCardNumberContainer","remove","mp-error"),CheckoutPage.setDisplayOfInputHelper("mp-card-number","none"),CheckoutPage.setDisplayOfError("mpCardholderNameInputLabel","remove","mp-label-error"),CheckoutPage.setDisplayOfError("mpDocumentInputLabel","remove","mp-label-error"),CheckoutPage.setDisplayOfInputHelper("mp-card-holder-name","none"),CheckoutPage.setDisplayOfInputHelperInfo("mp-card-holder-name","flex"),CheckoutPage.shouldEnableInstallmentsComponent(e.payment_type_id),this.stabilizeZeroDollarInitialCitInstallments()}else this.cardBinIsValid=!1,CheckoutPage.clearCardState(),this.stabilizeZeroDollarInitialCitInstallments(),CheckoutPage.setDisplayOfError("fcCardNumberContainer","add","mp-error"),CheckoutPage.setDisplayOfInputHelper("mp-card-number","flex")}catch(e){if(e)return void console.error("Payment methods handling error: ",e);this.cardBinIsValid=!1,CheckoutPage.setDisplayOfError("fcCardNumberContainer","add","mp-error"),CheckoutPage.setDisplayOfInputHelper("mp-card-number","flex")}},onSubmit:e=>{e.preventDefault()},onValidityChange:(e,t)=>
1{if("cardNumber"===t){if(this.cardNumberFilledValidator=!0,e&&!e[0])return"function"==typeof sendMetric&&sendMetric("MP_CUSTOM_CHECKOUT_CARD_VALIDATION_BLOCKED","unexpected_error_format","mp_custom_card_validation",{reason:"unexpected_error_format"}),this.cardNumberValidity=null,void(this.cardNumberValidityMessage=null);this.cardNumberValidity=e?e[0].code:null,this.cardNumberValidityMessage=e?e[0].message:null}if(e){let r=CheckoutPage.getHelperMessage(t),a=wc_mercadopago_custom_checkout_params.input_helper_message[t][e[0].code];if(r&&(r.innerHTML=a||wc_mercadopago_custom_checkout_params.input_helper_message[t].invalid_length),"cardNumber"===t){if("invalid_type"===e[0].code){const e="super_token"===document.querySelector("#mp_checkout_type")?.value;CheckoutPage.setBackground("fcCardNumberContainer","no-repeat #fff"),CheckoutPage.removeAdditionFields(!e),CheckoutPage.clearInputs(),this.stabilizeZeroDollarInitialCitInstallments()}CheckoutPage.cardholderNameHasError()||CheckoutPage.setDisplayOfInputHelperInfo("mp-card-holder-name","flex")}let o=CheckoutPage.findContainerField(t);return CheckoutPage.setDisplayOfError(o,"add","mp-error"),"cardholderName"===t&&CheckoutPage.verifyCardholderName(),CheckoutPage.setDisplayOfInputHelper(CheckoutPage.inputHelperName(t),"flex")}if("cardholderName"===t&&!CheckoutPage.verifyCardholderName())return;if("cardNumber"===t&&!this.cardBinIsValid)return;let r=CheckoutPage.findContainerField(t);return CheckoutPage.setDisplayOfError(r,"removed","mp-error"),CheckoutPage.setDisplayOfInputHelper(CheckoutPage.inputHelperName(t),"none")},onError:e=>{this.isZeroDollarInitialCitContext()&&e.length>0&&e.every((e=>e?.message?.includes("payer_costs")))||CheckoutPage.verifyCardholderName(),e.forEach((e=>(this.removeBlockOverlay(),e.message.includes(MPCardFormErrorCodes.TIMED_OUT)?t(e):e.message.includes("cardNumber")?(CheckoutPage.setDisplayOfError("fcCardNumberContainer","add","mp-error"),CheckoutPage.setDisplayOfInputHelper("mp-card-number","flex")):e.message.includes("cardholderName")?(CheckoutPage.setDisplayOfError("fcCardholderName","add","mp-error"),CheckoutPage.setDisplayOfInputHelperInfo("mp-card-holder-name","none"),CheckoutPage.setDisplayOfError("mpCardholderNameInputLabel","add","mp-label-error"),CheckoutPage.setDisplayOfInputHelper("mp-card-holder-name","flex")):e.message.includes("expirationMonth")||e.message.includes("expirationYear")?(CheckoutPage.setDisplayOfError("fcCardExpirationDateContainer","add","mp-error"),CheckoutPage.setDisplayOfInputHelper("mp-expiration-date","flex")):e.message.includes("securityCode")?(e.message.includes(MPCardFormErrorCodes.SECURITY_CODE_INVALID_NUMBER)||e.message.includes(MPCardFormErrorCodes.SECURITY_CODE_INVALID_LENGTH)?CheckoutPage.setDisplayOfInputHelperMessage("mp-security-code",wc_mercadopago_custom_checkout_params.input_helper_message.securityCode.invalid_length):CheckoutPage.setDisplayOfInputHelperMessage("mp-security-code",wc_mercadopago_custom_checkout_params.input_helper_message.securityCode.invalid_type),CheckoutPage.setDisplayOfError("fcSecurityNumberContainer","add","mp-error"),CheckoutPage.setDisplayOfInputHelper("mp-security-code","flex")):e.message.includes("identificationNumber")?(CheckoutPage.setDisplayOfError("fcIdentificationNumberContainer","add","mp-error"),CheckoutPage.setDisplayOfInputHelper("mp-doc-number","flex")):t(e))))}}}scrollToCardForm(){const e=document.querySelector("#mp-checkout-custom-root.mp-checkout-container");e&&e.scrollIntoView({behavior:"smooth"})}getCardValidationReason(){const e=CARD_VALIDATION_REASON_BY_CODE[this.cardNumberValidity];
1return e||(!1===this.cardBinIsValid?"invalid_bin":this.cardNumberValidity||"empty_field")}getCardValidationDetail(){return this.cardNumberValidity?this.cardNumberValidityMessage?`${this.cardNumberValidity}:${this.cardNumberValidityMessage}`:this.cardNumberValidity:!1===this.cardBinIsValid?this.cardBinInvalidMessage||"invalid_bin":""}getAmount(){const e=document.getElementById("mp-amount");if(!e)return this.amount;const t=parseFloat(e.value.replace(",","."));return String(t)}isZeroDollarInitialCitContext(){const e=document.getElementById("mp-amount"),t=document.querySelector("#mp_checkout_type")?.value,r=this.amount;if("custom"!==t||"true"!==e?.dataset.mpCitInitialContext||"string"!=typeof r&&"number"!=typeof r||"string"==typeof r&&""===r.trim())return!1;const a=Number(r);return Number.isFinite(a)&&0===a}stabilizeZeroDollarInitialCitInstallments(){return!!this.isZeroDollarInitialCitContext()&&(CheckoutPage.setZeroDollarInitialCitInstallmentsState(),!0)}formatTrackingAmount(e=""){const t=String(e??"").replace(/[^\d.,]/g,"");if(!t)return null;const r=t.lastIndexOf(",")>t.lastIndexOf("."),a=t.replace(/[.,]/g,(e=>r?","===e?".":"":"."===e?".":"")),o=parseFloat(a);return isNaN(o)?null:o.toFixed(2)}reportAmountTrackingDroppedOnce(e,t){this.hasReportedAmountTrackingDropped||(this.hasReportedAmountTrackingDropped=!0,this.sendMetric("true",`melidataReady rejected on ${e}: ${t?.message||"unknown error"}`,"mp_checkout_amount_tracking_dropped"))}emitWhenMelidataReady(e,t){const r=window.melidataReady;r&&"function"==typeof r.then?r.then((()=>document.dispatchEvent(new CustomEvent(e,{detail:t})))).catch((t=>this.reportAmountTrackingDroppedOnce(e,t))):this.reportAmountTrackingDroppedOnce(e,new Error("melidataReady is not a Promise"))}dispatchCheckoutAmountEvent(e){const t=this.formatTrackingAmount(e),r=this.lastTrackedAmount;this.hasFiredCheckoutOpenedEvent?r&&r!==t&&(this.lastTrackedAmount=t,this.emitWhenMelidataReady("mp_amount_changed",{amount:t,oldAmount:r})):(this.hasFiredCheckoutOpenedEvent=!0,this.lastTrackedAmount=t,this.emitWhenMelidataReady("mp_checkout_opened",{amount:t}))}handleCardFormErrors(e){if(e.length){const t=[];return e.forEach((e=>{t.push(e.description||e.message)})),t.join(",")}return e.description||e.message}sendMetric(e,t,r){"function"==typeof window.sendMetric&&window.sendMetric(e,t,r)}isClassicCheckout(){return!!document.querySelector(".payment_method_woo-mercado-pago-custom")}startLoadingOnClassicCheckout(){jQuery("form.checkout")?.block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}stopLoadingOnClassicCheckout(){jQuery("form.checkout")?.unblock()}getMelidataReadyPromise(){return window.melidataReady?window.melidataReady:Promise.reject(new Error("melidataReady is undefined"))}createLoadSpinner(){if(this.isLoading)return;const e=document.querySelector("#mp-checkout-custom-root.mp-checkout-container"),t=document.querySelector(".mp-checkout-custom-load");this.isLoading=!0,e?.classList.add("mp-hidden"),e?.classList.add("mp-display-none"),t?.classList.remove("mp-hidden"),t?.classList.remove("mp-display-none");const r=Date.now(),a=!!window.melidata;this.getMelidataReadyPromise().then((()=>
1{if(!a){const e=Math.round((Date.now()-r)/10)/100;sendMetric(e,"time in seconds waiting for melidata client at loading start","mp_custom_checkout_melidata_load_start_delay")}document.dispatchEvent(new CustomEvent("mp_super_token_loading_start",{detail:{dateNowInMilliseconds:r}}))})).catch((e=>{sendMetric("MP_MELIDATA_CLIENT_UNDEFINED",`Loading started but melidata client failed to load: ${e?.message||"unknown error"}`,"mp_custom_checkout_melidata_client_undefined")}))}removeLoadSpinner(){const e=document.querySelector(".mp-checkout-custom-load"),t=e&&"none"!==window.getComputedStyle(e).display;if(!this.isLoading&&!t)return;const r=document.querySelector("#mp-checkout-custom-root.mp-checkout-container"),a=document.querySelector(".mp-checkout-custom-load");this.isLoading=!1;window.mpSuperTokenTriggerHandler?window.mpSuperTokenTriggerHandler.isSuperTokenPaymentMethodsLoaded()&&a?.classList.add("mp-hidden"):"function"==typeof sendMetric&&sendMetric("MP_SUPER_TOKEN_TRIGGER_HANDLER_MISSING","removeLoadSpinner","mp_cardform_trigger_handler_missing"),setTimeout((()=>{a?.classList.add("mp-hidden"),a?.classList.add("mp-display-none"),r?.classList.remove("mp-hidden"),r?.classList.remove("mp-display-none")}),800);const o=Date.now(),i=!!window.melidata;this.getMelidataReadyPromise().then((()=>
1{if(!i){const e=Math.round((Date.now()-o)/10)/100;sendMetric(e,"time in seconds waiting for melidata client at loading end","mp_custom_checkout_melidata_load_end_delay")}document.dispatchEvent(new CustomEvent("mp_super_token_loading_end",{detail:{dateNowInMilliseconds:o}}))})).catch((e=>{sendMetric("MP_MELIDATA_CLIENT_UNDEFINED",`Loading ended but melidata client failed to load: ${e?.message||"unknown error"}`,"mp_custom_checkout_melidata_client_undefined")}))}removeBlockOverlay(){jQuery("form#order_review").length>0&&jQuery(".blockOverlay").css("display","none")}addErrorAlert(e){this.removeElementsByClass("woocommerce-NoticeGroup-checkout"),jQuery(window.mpCheckoutForm).prepend(`\n <div class="woocommerce-NoticeGroup woocommerce-NoticeGroup-checkout">\n <ul class="woocommerce-error" role="alert">\n <li>${e}<li>\n </ul>\n </div>\n `),window.scrollTo(0,0)}removeElementsByClass(e){const t=document.getElementsByClassName(e);for(;t.length>0;)t[0].parentNode.removeChild(t[0])}setupSecureFieldsStylesAndAddListeners(){if(!this.fields)return;"undefined"!=typeof MPCheckoutFieldsDispatcher||"function"!=typeof sendMetric||this.dispatcherMissingReported||(sendMetric("MP_CHECKOUT_FIELDS_DISPATCHER_MISSING","setupSecureFieldsStylesAndAddListeners","mp_checkout_init_error"),this.dispatcherMissingReported=!0);const e=[{field:this.fields.cardNumber,fieldName:"cardNumber",containerId:"form-checkout__cardNumber-container",focusEventName:"card_number_focused",blurEventName:"card_number_filled",validator:()=>this.cardNumberFilledValidator},{field:this.fields.expirationDate,containerId:"form-checkout__expirationDate-container"},{field:this.fields.securityCode,containerId:"form-checkout__securityCode-container"}];for(const t of e)t.field&&"function"==typeof t.field.on&&(t.field.on("focus",(()=>{this.addOrRemoveCssClass(t.containerId,"mp-checkout-custom-card-form-focus","add"),t.focu
1sEventName&&"undefined"!=typeof MPCheckoutFieldsDispatcher&&MPCheckoutFieldsDispatcher.addEventListenerDispatcher(null,"focus",t.focusEventName,{onlyDispatch:!0})})),t.field.on("blur",(()=>{let e=!1;this.addOrRemoveCssClass(t.containerId,"mp-checkout-custom-card-form-focus"),t.validator&&(e="function"==typeof t.validator?t.validator():t.validator),t.blurEventName&&e&&"undefined"!=typeof MPCheckoutFieldsDispatcher&&(MPCheckoutFieldsDispatcher.addEventListenerDispatcher(null,"blur",t.blurEventName,{onlyDispatch:!0}),t.fieldName&&this.updateFieldValidator(t.fieldName))})))}addOrRemoveCssClass(e,t,r="remove"){const a=document.getElementById(e);a?.classList["add"===r?"add":"remove"](t)}updateFieldValidator(e){"cardNumber"===e&&(this.cardNumberFilledValidator=!1)}sendMelidataTimeToLoadMetric(){const e=Date.now(),t=setInterval((()=>{if(window.melidata){clearInterval(t);const r=Date.now();sendMetric((r-e)/1e3,"time in seconds to load melidata client","mp_custom_checkout_melidata_time_to_load")}}),100);setTimeout((()=>{clearInterval(t)}),2e4)}}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.