(()=>{"use strict";var e={20:(e,t,s)=>{var n=s(609),r=Symbol.for("react.element"),o=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,c=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function p(e,t,s){var n,o={},p=null,l=null;for(n in void 0!==s&&(p=""+s),void 0!==t.key&&(p=""+t.key),void 0!==t.ref&&(l=t.ref),t)i.call(t,n)&&!a.hasOwnProperty(n)&&(o[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===o[n]&&(o[n]=t[n]);return{$$typeof:r,type:e,key:p,ref:l,props:o,_owner:c.current}}t.Fragment=o,t.jsx=p,t.jsxs=p},609:e=>{e.exports=window.React},848:(e,t,s)=>{e.exports=s(20)}},t={};const s=window.wp.element,n=window.wc.wcBlocksRegistry,r=window.wp.htmlEntities,o=window.wc.wcSettings,i="mercadopago_blocks_update_cart";var c=function s(n){var r=t[n];if(void 0!==r)return r.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,s),o.exports}(848);const a=({title:e,description:t,linkText:s,linkSrc:n})=>(0,c.jsx)("div",{className:"mp-test-mode-container",children:(0,c.jsx)("test-mode",{title:e,description:t,"link-text":s,"link-src":n})}),p=({title:e,subtitle:t,alt:s,linkSrc:n})=>(0,c.jsx)("pix-template",{title:e,subtitle:t,alt:s,src:n}),l=({description:e,linkText:t,linkSrc:s,checkoutClass:n="pro"})=>(0,c.jsx)("div",{className:`mp-checkout-${n}-terms-and-conditions`,children:(0,c.jsx)("terms-and-conditions",{description:e,"link-text":t,"link-src":s})}),d=({text:e,imgSrc:t,id:s})=>(0,c.jsxs)("div",{id:s,className:"row-image-select",children:[(0,c.jsx)("img",{src:t}),(0,c.jsx)("p",{children:e})]});var m;const u="mp_checkout_blocks",_="woo-mercado-pago-pix",x=(0,o.getSetting)("woo-mercado-pago-pix_data",{}),k=(0,r.decodeEntities)(x.title)||"Checkout Pix",h=()=>{const e=(0,r.decodeEntities)(x?.params?.fee_title||""),t=`${k} ${e}`;return(0,c.jsx)(d,{text:t,imgSrc:x.params.icon})},S=e=>{(e=>{const{extensionCartUpdate:t}=wc.blocksCheckout,{eventRegistration:n,emitResponse:r}=e,{onPaymentSetup:o,onCheckoutSuccess:c,onCheckoutFail:a}=n;(0,s.useEffect)((()=>{((e,t)=>{e({namespace:i,data:{action:"add",gateway:t}})})(t,_);const e=o((()=>({type:r.responseTypes.SUCCESS,meta:{paymentMethodData:{...window.mpHiddenInputDataFromBlocksCheckout}}})));return()=>(((e,t)=>{e({namespace:i,data:{action:"remove",gateway:t}})})(t,_),e())}),[o]),(0,s.useEffect)((()=>{const e=c((async e=>{e.processingResponse.message=_;const t=e.processingResponse;return sendMetric("MP_PIX_BLOCKS_SUCCESS",t.paymentStatus,u),{type:r.responseTypes.SUCCESS}}));return()=>e()}),[c]),(0,s.useEffect)((()=>{const e=a((e=>{"undefined"!=typeof MPCheckoutErrorDispatcher&&MPCheckoutErrorDispatcher.dispatchEventWhenBlocksCheckoutErrorOccurred(e);const t=e.processingResponse;return sendMetric("MP_PIX_BLOCKS_ERROR",t.paymentStatus,u),{type:r.responseTypes.FAIL,messageContext:r.noticeContexts.PAYMENTS,message:t.paymentDetails.message}}));return()=>e()}),[a])})(e);const{test_mode_title:t,test_mode_description:n,pix_template_title:r,pix_template_subtitle:o,pix_template_src:d,pix_template_alt:m,terms_and_conditions_description:k,terms_and_conditions_link_text:h,terms_and_conditions_link_src:S,test_mode:y,amount:w,message_error_amount:f}=x.params;return null==w?(0,c.jsx)(c.Fragment,{children:(0,c.jsx)("p",{className:"alert-message",children:f})}):(0,c.jsx)("div",{className:"mp-checkout-container",children:(0,c.jsxs)("div",{className:"mp-checkout-pix-container",children:[(0,c.jsxs)("div",{className:"mp-checkout-pix-content",children:[y?(0,c.jsx)(a,{title:t,description:n}):null,(0,c.jsx)(p,{title:r,subtitle:o,alt:m,linkSrc:d})]}),(0,c.jsx)(l,{description:k,linkText:h,linkSrc:S,checkoutClass:"pix"})]})})},y={name:_,label:(0,c.jsx)(h,{}),content:(0,c.jsx)(S,{}),edit:(0,c.jsx)(S,{}),canMakePayment:()=>!0,ariaLabel:k,supports:{features:null!==(m=x?.supports)&&void 0!==m?m:[]}};(0,n.registerPaymentMethod)(y)})();