File: /home/kbdhpghp/atenaleaders.com.br/wp-content/plugins/woocommerce-mercadopago/build/pse.block.js
(()=>{"use strict";const e=window.React,t=window.wc.wcBlocksRegistry,n=window.wc.wcSettings,a=window.wp.element,o=window.wp.htmlEntities,c="mercadopago_blocks_update_cart",s=({labelMessage:t,helperMessage:n,inputName:a,hiddenId:o,inputDataCheckout:c,selectId:s,selectName:r,selectDataCheckout:i,flagError:l,documents:p,validate:m})=>(0,e.createElement)("div",{className:"mp-checkout-ticket-input-document"},(0,e.createElement)("input-document",{"label-message":t,"helper-message":n,"input-name":a,"hidden-id":o,"input-data-checkout":c,"select-id":s,"select-name":r,"select-data-checkout":i,"flag-error":l,documents:p,validate:m})),r=({description:t,linkText:n,linkSrc:a,checkoutClass:o="pro"})=>(0,e.createElement)("div",{className:`mp-checkout-${o}-terms-and-conditions`},(0,e.createElement)("terms-and-conditions",{description:t,"link-text":n,"link-src":a})),i=({title:t,description:n,linkText:a,linkSrc:o})=>(0,e.createElement)("div",{className:"mp-checkout-pro-test-mode"},(0,e.createElement)("test-mode",{title:t,description:n,"link-text":a,"link-src":o})),l=(e,t,n)=>{const a={name:e,message:t,target:n,plugin:{version:wc_mercadopago_custom_checkout_params.plugin_version},platform:{name:"woocommerce",uri:window.location.href,version:wc_mercadopago_custom_checkout_params.platform_version,location:`${wc_mercadopago_custom_checkout_params.location}_${wc_mercadopago_custom_checkout_params.theme}`}};navigator.sendBeacon("https://api.mercadopago.com/v1/plugins/melidata/errors",JSON.stringify(a))},p=({name:t,label:n,optional:a,options:o,helperMessage:c,hiddenId:s,defaultOption:r})=>(0,e.createElement)("input-select",{name:t,label:n,options:o,optional:a,"helper-message":c,"hidden-id":s,"default-option":r});var m;const d="mp_checkout_blocks",u="woo-mercado-pago-pse",_=(0,n.getSetting)("woo-mercado-pago-pse_data",{}),g=(0,o.decodeEntities)(_.title)||"Checkout Pse",k=t=>{(e=>{const{extensionCartUpdate:t}=wc.blocksCheckout,{eventRegistration:n,emitResponse:o}=e,{onPaymentSetup:s,onCheckoutSuccess:r,onCheckoutFail:i}=n;(0,a.useEffect)((()=>{((e,t)=>{e({namespace:c,data:{action:"add",gateway:t}})})(t,u);const e=s((()=>({type:o.responseTypes.SUCCESS})));return()=>(((e,t)=>{e({namespace:c,data:{action:"remove",gateway:t}})})(t,u),e())}),[s]),(0,a.useEffect)((()=>{const e=r((async e=>{const t=e.processingResponse;return l("MP_PSE_BLOCKS_SUCCESS",t.paymentStatus,d),{type:o.responseTypes.SUCCESS}}));return()=>e()}),[r]),(0,a.useEffect)((()=>{const e=i((e=>{const t=e.processingResponse;return l("MP_PSE_BLOCKS_ERROR",t.paymentStatus,d),{type:o.responseTypes.FAIL,messageContext:o.noticeContexts.PAYMENTS,message:t.paymentDetails.message}}));return()=>e()}),[i])})(t);const{test_mode_title:n,test_mode_description:o,test_mode_link_text:m,test_mode_link_src:g,input_document_label:k,input_document_helper:h,pse_text_label:y,person_type_label:E,amount:S,site_id:f,terms_and_conditions_description:v,terms_and_conditions_link_text:b,terms_and_conditions_link_src:w,test_mode:C,financial_institutions:N,financial_institutions_label:x,financial_institutions_helper:R,financial_placeholder:T,message_error_amount:M}=_.params;if(null==S)return(0,e.createElement)(e.Fragment,null,(0,e.createElement)("p",{className:"alert-message"},M));const P=(0,a.useRef)(null),{eventRegistration:q,emitResponse:O}=t,{onPaymentSetup:I}=q;let U={labelMessage:k,helperMessage:h,validate:"true",selectId:"doc_type",flagError:"mercadopago_pse[docNumberError]",inputName:"mercadopago_pse[docNumber]",selectName:"mercadopago_pse[docType]",documents:'["CC","CE","NIT"]'};return(0,a.useEffect)((()=>{const e=I((async()=>{const e=document.querySelector(".mp-checkout-pse-input-document").querySelector(".mp-input-document > input-helper > div"),t={"mercadopago_pse[site_id]":f,"mercadopago_pse[amount]":S.toString(),"mercadopago_pse[doc_type]":P.current.querySelector("#doc_type")?.value,"mercadopago_pse[doc_number]":P.current.querySelector("#form-checkout__identificationNumber-container > input")?.value,"mercadopago_pse[bank]":P.current.querySelector("#mercadopago_pse\\[bank\\]").value,"mercadopago_pse[person_type]":P.current.querySelector("#mercadopago_pse\\[person_type\\]").value};U.documents&&""===t["mercadopago_pse[doc_number]"]&&o(e,"flex");let n=document.querySelector("#mercadopago_pse\\[bank\\]"),a=document.querySelector(".mp-checkout-pse-bank").querySelector("input-helper > div");function o(e,t){e&&e.style&&(e.style.display=t)}function c(e){return e&&"flex"===e.style.display}return""!==n.value&&{financial_placeholder:T}!==n.value||o(a,"flex"),{type:c(a)||c(e)?O.responseTypes.ERROR:O.responseTypes.SUCCESS,meta:{paymentMethodData:t}}}));return()=>e()}),[O.responseTypes.ERROR,O.responseTypes.SUCCESS,I]),(0,e.createElement)("div",{className:"mp-checkout-container"},(0,e.createElement)("p",{className:"mp-checkout-pse-text","data-cy":"checkout-pse-text"},y),(0,e.createElement)("div",{className:"mp-checkout-pse-container"},(0,e.createElement)("div",{ref:P,className:"mp-checkout-pse-content"},C?(0,e.createElement)(i,{title:n,description:o,"link-text":m,"link-src":g}):null,(0,e.createElement)("div",{className:"mp-checkout-pse-person"},(0,e.createElement)(p,{name:"mercadopago_pse[person_type]",label:E,optional:!1,options:'[{"id":"individual", "description": "individual"},{"id":"association", "description": "asociación"}]'})),(0,e.createElement)("div",{className:"mp-checkout-pse-input-document"},U.documents?(0,e.createElement)(s,{...U}):null),(0,e.createElement)("div",{className:"mp-checkout-pse-bank"},(0,e.createElement)(p,{name:"mercadopago_pse[bank]",label:x,optional:!1,options:N,"hidden-id":"hidden-financial-pse","helper-message":R,"default-option":T})),(0,e.createElement)("div",{id:"mp-box-loading"}))),(0,e.createElement)(r,{description:v,linkText:b,linkSrc:w,checkoutClass:"pse"}))},h={name:u,label:(0,e.createElement)((t=>{const{PaymentMethodLabel:n}=t.components,a=(0,o.decodeEntities)(_?.params?.fee_title||""),c=`${g} ${a}`;return(0,e.createElement)(n,{text:c})}),null),content:(0,e.createElement)(k,null),edit:(0,e.createElement)(k,null),canMakePayment:()=>!0,ariaLabel:g,supports:{features:null!==(m=_?.supports)&&void 0!==m?m:[]}};(0,t.registerPaymentMethod)(h)})();