import{a as e}from"./chunk-BNv3lrIs.js";import{n as t,t as n}from"./jsx-runtime-pmtNMKr4.js";import{Ki as r}from"./index-CBXvBSuP.js";import{t as i}from"./openPay-4KSuxreV.js";var a=e(t(),1),o=n();function s(){r();let e=()=>`${new Date().getTime()}-${Math.random().toString(36).substring(2,15)}`,[t,n]=(0,a.useState)(``),[s,c]=(0,a.useState)({customer:{name:`Juan`,last_name:`Vazquez Juarez`,phone_number:`7731440261`,email:`albertoalmarazmeza@gmail.com`},order_id:e(),amount:10,method:`bank_account`,due_date:new Date(Date.now()+1440*60*1e3).toISOString(),description:`pago`}),l=e=>{let{name:t,value:n}=e.target;c({...s,[t]:n})};return(0,o.jsx)(o.Fragment,{children:(0,o.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault();try{let e=await i(s);if(e.status===`in_progress`){console.log(`El pago está en progreso:`,e);let t=e.payment_method;t?window.open(t.url_spei):console.error(`No se encontraron detalles del método de pago:`,e)}else e.status===`completed`?console.log(`Pago completado:`,e):console.error(`Estado del pago no manejado:`,e)}catch(e){console.error(`Error al realizar el pago:`,e.message||e)}},children:[(0,o.jsx)(`input`,{type:`text`,name:`amount`,placeholder:`Monto`,value:s.amount,onChange:l}),(0,o.jsx)(`input`,{type:`text`,name:`description`,placeholder:`Descripción`,value:s.description,onChange:l}),(0,o.jsx)(`button`,{type:`submit`,children:`Realizar Cargo`})]})})}export{s as default};