(()=>{"use strict";var e={20:(e,t,o)=>{var n=o(609),r=Symbol.for("react.element"),a=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),s=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function d(e,t,o){var n,d={},i=null,p=null;for(n in void 0!==o&&(i=""+o),void 0!==t.key&&(i=""+t.key),void 0!==t.ref&&(p=t.ref),t)a.call(t,n)&&!c.hasOwnProperty(n)&&(d[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===d[n]&&(d[n]=t[n]);return{$$typeof:r,type:e,key:i,ref:p,props:d,_owner:s.current}}t.jsx=d,t.jsxs=d},609:e=>{e.exports=window.React},848:(e,t,o)=>{e.exports=o(20)}},t={};const o=window.wc.wcBlocksRegistry,n=window.wc.wcSettings,r=window.wp.element,a=window.wp.htmlEntities,s="mercadopago_blocks_update_cart";var c=function o(n){var r=t[n];if(void 0!==r)return r.exports;var a=t[n]={exports:{}};return e[n](a,a.exports,o),a.exports}(848);const d=({text:e,imgSrc:t,id:o})=>(0,c.jsxs)("div",{id:o,className:"row-image-select",children:[(0,c.jsx)("img",{src:t}),(0,c.jsx)("span",{children:e})]});var i;const p="mp_checkout_blocks",m="woo-mercado-pago-ticket",u=(0,n.getSetting)("woo-mercado-pago-ticket_data",{}),l=(0,a.decodeEntities)(u.title)||"Checkout Ticket";let _=!1;const y=()=>{const e=(0,a.decodeEntities)(u?.params?.fee_title||""),t=`${l} ${e}`;return(0,c.jsx)(d,{text:t,imgSrc:u.params.icon})},g=e=>{(e=>{const{extensionCartUpdate:t}=wc.blocksCheckout,{eventRegistration:o,emitResponse:n}=e,{onPaymentSetup:a,onCheckoutSuccess:c,onCheckoutFail:d}=o;(0,r.useEffect)((()=>{((e,t)=>{e({namespace:s,data:{action:"add",gateway:t}})})(t,m);const e=a((()=>({type:n.responseTypes.SUCCESS})));return()=>(((e,t)=>{e({namespace:s,data:{action:"remove",gateway:t}})})(t,m),e())}),[a]),(0,r.useEffect)((()=>{const e=c((async e=>{const t=e.processingResponse;return sendMetric("MP_TICKET_BLOCKS_SUCCESS",t.paymentStatus,p),{type:n.responseTypes.SUCCESS}}));return()=>e()}),[c]),(0,r.useEffect)((()=>{const e=d((e=>{"undefined"!=typeof MPCheckoutErrorDispatcher&&MPCheckoutErrorDispatcher.dispatchEventWhenBlocksCheckoutErrorOccurred(e);const t=e.processingResponse;return sendMetric("MP_TICKET_BLOCKS_ERROR",t.paymentStatus,p),{type:n.responseTypes.FAIL,messageContext:n.noticeContexts.PAYMENTS,message:t.paymentDetails.message}}));return()=>e()}),[d])})(e);const{eventRegistration:t,emitResponse:o}=e,{onPaymentSetup:n}=t,a=["address_city","address_federal_unit","address_zip_code","address_street_name","address_street_number","address_neighborhood","address_complement"];return(0,r.useEffect)((()=>{_||("undefined"!=typeof MPCheckoutFieldsDispatcher&&MPCheckoutFieldsDispatcher?.addEventListenerDispatcher(document.getElementById("mp-ticket-gateway-document-input"),"focusout","ticket_document_filled",{dispatchOnlyIf:e=>e?.target?.value.length}),_=!0)}),[]),(0,r.useEffect)((()=>{const e=n((async()=>{var e;const t=document.querySelector(".mp-input"),n=document.getElementById("mp-doc-number-helper"),r=document.getElementById("mp-payment-method-helper"),s={"mercadopago_ticket[site_id]":document.getElementsByName("mercadopago_ticket[site_id]")[0].value,"mercadopago_ticket[amount]":document.getElementsByName("mercadopago_ticket[amount]")[0].value,"mercadopago_ticket[doc_type]":document.getElementsByName("mercadopago_ticket[doc_type]")[0]?.value,"mercadopago_ticket[doc_number]":null!==(e=document.getElementsByName("mercadopago_ticket[doc_number]")[0]?.value)&&void 0!==e?e:document.getElementsByName("mercadopago_ticket[docNumberError]")[0]?.value};if(document.querySelector(".mp-checkout-ticket-container").querySelectorAll(".mp-input-radio-radio").forEach((e=>{e.checked&&(s["mercadopago_ticket[payment_method_id]"]=e.value,r.style.display="none")})),!s["mercadopago_ticket[payment_method_id]"]){const e=document.querySelector('input[name="mercadopago_ticket[payment_method_id]"][type="hidden"]');e&&e.value&&(s["mercadopago_ticket[payment_method_id]"]=e.value,r.style.display="none")}const c=document.getElementsByName("mercadopago_ticket[site_id]")[0].value;"MLB"==c&&a.forEach((e=>{s[`mercadopago_ticket[${e}]`]=document.querySelector(`#form-checkout__${e}`).value})),"MLB"!=c&&"MLU"!=c||""!==s["mercadopago_ticket[doc_number]"]||(t.classList.add("mp-error"),i(n,"flex")),s["mercadopago_ticket[payment_method_id]"]||i(r,"flex");const d="MLB"==c&&!addressFieldsFromTicketRowAreValid();function i(e,t){e&&e.style&&(e.style.display=t)}function p(e){return e&&"flex"===e.style.display}return{type:p(n)||p(r)||d?o.responseTypes.ERROR:o.responseTypes.SUCCESS,meta:{paymentMethodData:{...window.mpHiddenInputDataFromBlocksCheckout,...s}}}}));return()=>e()}),[o.responseTypes.ERROR,o.responseTypes.SUCCESS,n]),(0,c.jsx)("div",{dangerouslySetInnerHTML:{__html:u.params.content}})},k={name:m,label:(0,c.jsx)(y,{}),content:(0,c.jsx)(g,{}),edit:(0,c.jsx)(g,{}),canMakePayment:()=>!0,ariaLabel:l,supports:{features:null!==(i=u?.supports)&&void 0!==i?i:[]}};(0,o.registerPaymentMethod)(k)})();