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