1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3860],{3065:function(e,t,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/maintenance/facturacion-adm",function(){return a(30118)}])},63733:function(e,t,a){"use strict";a.d(t,{Z:function(){return l}});let l=(0,a(48391).Z)("badge-check",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]])},73865:function(e,t,a){"use strict";a.d(t,{Z:function(){return l}});let l=(0,a(48391).Z)("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]])},38197:function(e,t,a){"use strict";a.d(t,{Z:function(){return l}});let l=(0,a(48391).Z)("ellipsis-vertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]])},61136:function(e,t,a){"use strict";a.d(t,{Z:function(){return l}});let l=(0,a(48391).Z)("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]])},62154:function(e,t,a){"use strict";a.d(t,{Z:function(){return l}});let l=(0,a(48391).Z)("funnel",[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]])},36767:function(e,t,a){"use strict";a.d(t,{Z:function(){return l}});let l=(0,a(48391).Z)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},27820:function(e,t,a){"use strict";a.d(t,{Z:function(){return l}});let l=(0,a(48391).Z)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]])},47254:function(e,t,a){"use strict";a.d(t,{Z:function(){return l}});let l=(0,a(48391).Z)("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},10958:function(e,t,a){"use strict";a.d(t,{Z:function(){return l}});let l=(0,a(48391).Z)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},30118:function(e,t,a){"use strict";a.r(t),a.d(t,{__N_SSG:function(){return W},default:function(){return Y}});var l=a(74817),n=a(71248),s=a(36497),r=a(36217),i=a(24109),o=a(1441),d=a(34146),c=a(63733),u=a(27820),x=a(62154),m=a(28321),b=a(36767),p=a(48391);let h=(0,p.Z)("landmark",[["line",{x1:"3",x2:"21",y1:"22",y2:"22",key:"j8o0r"}],["line",{x1:"6",x2:"6",y1:"18",y2:"11",key:"10tf0k"}],["line",{x1:"10",x2:"10",y1:"18",y2:"11",key:"54lgf6"}],["line",{x1:"14",x2:"14",y1:"18",y2:"11",key:"380y"}],["line",{x1:"18",x2:"18",y1:"18",y2:"11",key:"1kevvc"}],["polygon",{points:"12 2 20 7 4 7",key:"jkujk7"}]]),g=(0,p.Z)("receipt",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 17.5v-11",key:"1jc1ny"}]]);var f=a(73865),v=a(38197),j=a(54312),y=a(10958),N=a(61136);let w=(0,p.Z)("file-up",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]]);var _=a(47254),k=a(64229),S=a(54593);let C={language:"es",country:"AR",timezone:"America/Argentina/Buenos_Aires"};function A(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"ARS",a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"es-AR";return"".concat(t," ").concat(new Intl.NumberFormat(a,{minimumFractionDigits:2,maximumFractionDigits:2}).format(function(e){let t=Number(e);return Number.isFinite(t)?t:0}(e)))}function P(e){return/^\d{4}-\d{2}-\d{2}$/.test(String(e||""))}function F(e){let t=String(e||"").toLowerCase();return t.includes("responsable")?"A":(t.includes("monotrib")||t.includes("exent"),"B")}function E(e){if(!e)return"";let t=new Date(e);return Number.isNaN(t.getTime())?"":t.toISOString().slice(0,10)}function D(e){if(null==e)return"";let t=Number(e);return Number.isFinite(t)?String(t):""}
1function Z(){let e=(0,S.getApiBase)(),[t,a]=(0,n.useState)(C),[s,r]=(0,n.useState)("payments"),[i,o]=(0,n.useState)(!1),[p,N]=(0,n.useState)(!1),[w,_]=(0,n.useState)(!1),[F,E]=(0,n.useState)(""),[D,Z]=(0,n.useState)("all"),[U,G]=(0,n.useState)("all"),[H,J]=(0,n.useState)("all"),[$,X]=(0,n.useState)(""),[K,Q]=(0,n.useState)(""),[W,Y]=(0,n.useState)([]),[ee,et]=(0,n.useState)([]),[ea,el]=(0,n.useState)({count:0,gross:0,net:0,fee:0,taxes:0}),[en,es]=(0,n.useState)([]),[er,ei]=(0,n.useState)({count:0,gross:0,net:0,fee:0,taxes:0}),[eo,ed]=(0,n.useState)(null),[ec,eu]=(0,n.useState)(null),[ex,em]=(0,n.useState)(null),[eb,ep]=(0,n.useState)(null),[eh,eg]=(0,n.useState)(null),[ef,ev]=(0,n.useState)(null),ej=(0,n.useMemo)(()=>(function(e){let t=String((null==e?void 0:e.language)||"es").toLowerCase(),a=String((null==e?void 0:e.country)||"AR").toUpperCase();return"".concat(t,"-").concat(a)})(t),[t]),ey=(0,n.useCallback)(e=>{if(!e)return"â";let a=new Date(e);return Number.isNaN(a.getTime())?"â":new Intl.DateTimeFormat(ej,{day:"2-digit",month:"short",year:"numeric",timeZone:t.timezone||"UTC"}).format(a).replace(/\./g,"").toLowerCase()},[t.timezone,ej]),eN=(0,n.useCallback)(function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],t=sessionStorage.getItem("token");return{...e?{"Content-Type":"application/json"}:{},...t?{Authorization:"Bearer ".concat(t)}:{}}},[]),ew=(0,n.useCallback)(async()=>{try{let t=await fetch("".concat(e,"/api/profile/prefs/app"),{headers:eN(!1)}),l=await t.json().catch(()=>({}));t.ok&&(null==l?void 0:l.prefs)&&a({language:String(l.prefs.language||"es"),country:String(l.prefs.country||"AR"),timezone:String(l.prefs.timezone||"America/Argentina/Buenos_Aires")})}catch(e){}},[e,eN]),e_=(0,n.useCallback)(async()=>{let t=await fetch("".concat(e,"/api/admin/billing/companies"),{headers:eN(!1)}),a=await t.json().catch(()=>({}));if(!t.ok||!(null==a?void 0:a.ok))throw Error((null==a?void 0:a.message)||"No se pudieron cargar empresas");Y(a.companies||[])},[e,eN]),ek=(0,n.useCallback)(async()=>{let t=new URLSearchParams;F.trim()&&t.set("q",F.trim()),"all"!==D&&t.set("status",D),"all"!==H&&t.set("company_id",String(H)),P($)&&t.set("from",$),P(K)&&t.set("to",K),t.set("limit","400");let a=await fetch("".concat(e,"/api/admin/billing/payments?").concat(t.toString()),{headers:eN(!1)}),l=await a.json().catch(()=>({}));if(!a.ok||!(null==l?void 0:l.ok))throw Error((null==l?void 0:l.message)||"No se pudieron cargar pagos");et(l.rows||[]),el(l.totals||{count:0,gross:0,net:0,fee:0,taxes:0})},[e,eN,H,$,D,F,K]),eS=(0,n.useCallback)(async()=>{let t=new URLSearchParams;F.trim()&&t.set("q",F.trim()),"all"!==U&&t.set("status",U),"all"!==H&&t.set("company_id",String(H)),t.set("limit","400");let a=await fetch("".concat(e,"/api/admin/billing/invoices?").concat(t.toString()),{headers:eN(!1)}),l=await a.json().catch(()=>({}));if(!a.ok||!(null==l?void 0:l.ok))throw Error((null==l?void 0:l.message)||"No se pudieron cargar facturas");es(l.rows||[]),ei(l.totals||{count:0,gross:0,net:0,fee:0,taxes:0})},[e,eN,H,U,F]),eC=(0,n.useCallback)(async()=>{N(!0);try{await Promise.all([e_(),ek(),eS()])}catch(e){k.Am.error((null==e?void 0:e.message)||"Error cargando Facturacion Adm")}finally{N(!1)}},[e_,eS,ek]);(0,n.useEffect)(()=>{ew()},[ew]),(0,n.useEffect)(()=>{eC()},[eC]);let eA=(0,n.useCallback)(async t=>{_(!0);try{let a=await fetch("".concat(e,"/api/admin/billing/payments/").concat(t),{headers:eN(!1)}),l=await a.json().catch(()=>({}));if(!a.ok||!(null==l?void 0:l.ok))throw Error((null==l?void 0:l.message)||"No se pudo abrir el pago");ed(l.payment)}catch(e){k.Am.error((null==e?void 0:e.message)||"No se pudo abrir el detalle")}finally{_(!1)}},[e,eN]),eP=(0,n.useCallback)(async t=>{_(!0);try{let a=await fetch("".concat(e,"/api/admin/billing/invoices/").concat(t),{headers:eN(!1)}),l=await a.json().catch(()=>({}));if(!a.ok||!(null==l?void 0:l.ok))throw Error((null==l?void 0:l.message)||"No se pudo abrir la factura");eu(l.invoice)}catch(e){k.Am.error((null==e?void 0:e.message)||"No se pudo abrir la factura")}finally{_(!1)}},[e,eN]),eF=(0,n.useCallback)(async t=>{let a=await fetch("".concat(e,"/api/admin/billing/invoices/").concat(t,"/pdf"),{method:"DELETE",headers:eN(!1)}),l=await a.json().catch(()=>({}));if(!a.ok||!(null==l?void 0:l.ok))throw Error((null==l?void 0:l.message)||"No se pudo eliminar el PDF");await Promise.all([eC(),eP(t)]),k.Am.success("PDF eliminado")},[e,eN,eC,eP]),eE=(0,n.useMemo)(()=>(ee||[]).filter(e=>{var t;return"accredited"===e.status&&(null===(t=e.invoice)||void 0===t?void 0:t.status)==="missing"}).length,[ee]);return(0,l.jsxs)("div",{className:"min-h-screen bg-neutral-50 text-neutral-900",children:[eo?(0,l.jsx)(z,{payment:eo,onClose:()=>ed(null),locale:ej,formatDate:ey,onGenerateInvoice:()=>{em(eo),ed(null)},onAttachPdf:()=>{ev(null),ep(eo),ed(null)},onOpenInvoice:()=>{let e=en.find(e=>e.payment_row_id===eo.id||e.mp_payment_id===eo.mp_payment_id);e&&(eP(e.id),ed(null))}}):null,ec?(0,l.jsx)(B,{invoice:ec,onClose:()=>eu(null),locale:ej,formatDate:ey,onDeletePdf:()=>eF(ec.id),onReplacePdf:()=>{ev(ec.id),ep({id:ec.payment_row_id,mp_payment_id:ec.mp_payment_id,company_name:ec.company_name,company_tax_condition:ec.company_tax_condition}),eu(null)}}):null,ex?(0,l.jsx)(O,{payment:ex,apiBase:e,authHeaders:eN,onClose:()=>em(null),onSaved:()=>{em(null),eC()}}):null,eb?(0,l.jsx)(L,{payment:eb,apiBase:e,authHeaders:eN,onClose:()=>{ep(null),ev(null)},onSaved:async()=>{ev(null),ep(null),await eC(),ef&&await eP(ef)}}):null,eh?(0,l.jsx)(q,{seed:eh,apiBase:e,authHeaders:eN,onClose:()=>eg(null),onSaved:async()=>{await eC()}}):null,(0,l.jsxs)("div",{className:"rounded-2xl border border-neutral-200 bg-white/85 backdrop-blur shadow-[0_1px_2px_rgba(0,0,0,.06),_0_10px_24px_rgba(0,0,0,.06)]",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-3 px-6 py-5 md:flex-row md:items-center",children:[(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"text-lg font-semibold",children:"Facturacion Adm"}),(0,l.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-neutral-100 px-2 py-0.5 text-xs font-semibold text-neutral-700 ring-1 ring-neutral-200",children:[(0,l.jsx)(c.Z,{className:"h-3.5 w-3.5"})," Superadmin"]})]}),(0,l.jsx)("div",{className:"mt-1 text-sm text-neutral-500",children:"Panel interno para conciliar pagos Mercado Pago y adju
1ntar/generar facturas."})]}),(0,l.jsxs)("div",{className:"ml-auto flex w-full max-w-2xl flex-col gap-2 md:flex-row md:items-center",children:[(0,l.jsxs)("label",{className:"relative block w-full",children:[(0,l.jsx)("span",{className:"pointer-events-none absolute inset-y-0 left-3 flex items-center",children:(0,l.jsx)(u.Z,{className:"h-4 w-4 text-neutral-400"})}),(0,l.jsx)("input",{className:"w-full rounded-xl border border-neutral-200 bg-neutral-50 px-10 py-2.5 text-sm text-neutral-900 placeholder:text-neutral-400 shadow-sm focus:border-indigo-300 focus:bg-white focus:outline-none focus:ring-2 focus:ring-indigo-200",placeholder:"Buscar por empresa, pago MP, factura, sub_*, email, CUIT...",value:F,onChange:e=>E(e.target.value)})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsxs)("button",{onClick:()=>o(e=>!e),className:i?"inline-flex items-center gap-2 rounded-xl border border-indigo-200 bg-indigo-50 px-3 py-2.5 text-sm font-semibold text-indigo-900 shadow-sm":"inline-flex items-center gap-2 rounded-xl border border-neutral-200 bg-white px-3 py-2.5 text-sm font-semibold text-neutral-700 shadow-sm hover:bg-neutral-50",children:[(0,l.jsx)(x.Z,{className:"h-4 w-4"}),"Filtros",(0,l.jsx)(m.Z,{className:"h-4 w-4 text-neutral-400"})]}),(0,l.jsxs)("button",{onClick:eC,className:"inline-flex items-center gap-2 rounded-xl bg-neutral-900 px-3 py-2.5 text-sm font-semibold text-white shadow-sm hover:bg-neutral-800",disabled:p,children:[(0,l.jsx)(b.Z,{className:"h-4 w-4 ".concat(p?"animate-spin":"")})," ",p?"Actualizando":"Actualizar"]}),(0,l.jsxs)("button",{onClick:()=>eg({}),className:"inline-flex items-center gap-2 rounded-xl border border-neutral-200 bg-white px-3 py-2.5 text-sm font-semibold text-neutral-700 shadow-sm hover:bg-neutral-50",children:[(0,l.jsx)(h,{className:"h-4 w-4"}),"Registrar transferencia"]})]})]})]}),(0,l.jsx)("div",{className:"px-6 pb-4",children:(0,l.jsxs)("div",{className:"flex flex-col gap-3 md:flex-row md:items-center",children:[(0,l.jsxs)("div",{className:"inline-flex rounded-2xl bg-neutral-100 p-1 ring-1 ring-neutral-200",children:[(0,l.jsx)(R,{active:"payments"===s,onClick:()=>r("payments"),icon:g,label:"Pagos",hint:"Mercado Pago"}),(0,l.jsx)(R,{active:"invoices"===s,onClick:()=>r("invoices"),icon:d.Z,label:"Facturas",hint:"PDF / borrador"})]}),(0,l.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,l.jsxs)("button",{className:"inline-flex items-center gap-2 rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm font-semibold text-neutral-700 hover:bg-neutral-50",children:[(0,l.jsx)(f.Z,{className:"h-4 w-4 text-neutral-600"}),"Ciclo",(0,l.jsx)(m.Z,{className:"h-4 w-4 text-neutral-400"})]}),(0,l.jsx)("button",{className:"inline-flex items-center gap-2 rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm font-semibold text-neutral-700 hover:bg-neutral-50",children:(0,l.jsx)(v.Z,{className:"h-4 w-4"})})]})]})}),i?(0,l.jsx)(M,{companies:W,company:H,onCompany:J,paymentStatus:D,onPaymentStatus:Z,invoiceStatus:U,onInvoiceStatus:G,fromDate:$,onFromDate:X,toDate:K,onToDate:Q,activeTab:s,onClose:()=>o(!1)}):null,(0,l.jsx)("div",{className:"px-6 pb-5",children:"payments"===s?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"grid gap-4 md:grid-cols-4",children:[(0,l.jsx)(V,{title:"Pagos",value:ea.count,sub:"Segun filtros",icon:g,tone:"indigo"}),(0,l.jsx)(V,{title:"Bruto",value:A(ea.gross,"ARS",ej),sub:"Total cobrado",icon:j.Z,tone:"fuchsia"}),(0,l.jsx)(V,{title:"Comision MP",value:A(ea.fee,"ARS",ej),sub:"Fees",icon:b.Z,tone:"amber"}),(0,l.jsx)(V,{title:"Neto",value:A(ea.net,"ARS",ej),sub:"Recibido",icon:c.Z,tone:"emerald"})]}),eE>0?(0,l.jsx)("div",{className:"mt-4 rounded-2xl border border-amber-200 bg-amber-50 p-4",children:(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[(0,l.jsx)("div",{className:"grid h-10 w-10 place-items-center rounded-xl bg-white ring-1 ring-amber-200",children:(0,l.jsx)(y.Z,{className:"h-5 w-5 text-amber-700"})}),(0,l.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,l.jsx)("div",{className:"text-sm font-semibold text-amber-900",children:"Pagos sin factura asociada"}),(0,l.jsxs)("div",{className:"mt-1 text-sm text-amber-800",children:["Hay ",(0,l.jsx)("b",{children:eE}),' pagos acreditados sin factura. Usa "Facturar".']})]})]})}):null]}):(0,l.jsxs)("div",{className:"grid gap-4 md:grid-cols-5",children:[(0,l.jsx)(V,{title:"Facturas",value:er.count,sub:"Segun filtros",icon:d.Z,tone:"indigo"}),(0,l.jsx)(V,{title:"Bruto",value:A(er.gross,"ARS",ej),sub:"Total facturado",icon:j.Z,tone:"fuchsia"}),(0,l.jsx)(V,{title:"Neto",value:A(er.net,"ARS",ej),sub:"Cobrado",icon:c.Z,tone:"emerald"}),(0,l.jsx)(V,{title:"Comision",value:A(er.fee,"ARS",ej),sub:"Costo MP",icon:g,tone:"amber"}),(0,l.jsx)(V,{title:"Impuestos",value:A(er.taxes,"ARS",ej),sub:"Retenciones",icon:b.Z,tone:"amber"})]})})]}),"payments"===s?(0,l.jsx)(I,{rows:ee,locale:ej,formatDate:ey,onOpen:eA,onAttach:e=>{ev(null),ep(e)},onGenerate:e=>em(e),onRegisterTransfer:e=>eg({subscription_id:e.subscription_id,company_name:e.company_name,bot_name:e.bot_name,currency:e.currency})}):(0,l.jsx)(T,{rows:en,locale:ej,formatDate:ey,onOpen:e=>eP(e.id)}),w?(0,l.jsx)("div",{className:"py-3 text-xs text-neutral-500",children:"Cargando detalle..."}):null]})}function R(e){let{active:t,onClick:a,icon:n,label:s,hint:r}=e;return(0,l.jsxs)("button",{onClick:a,className:t?"inline-flex items-center gap-2 rounded-xl bg-white px-3 py-2 text-sm font-extrabold text-neutral-900 shadow-sm ring-1 ring-neutral-200":"inline-flex items-center gap-2 rounded-xl px-3 py-2 text-sm font-semibold text-neutral-600 hover:bg-white/60",children:[(0,l.jsx)(n,{className:"h-4 w-4"}),s,(0,l.jsx)("span",{className:"hidden rounded-full bg-neutral-100 px-2 py-0.5 text-[11px] font-semibold text-neutral-600 ring-1 ring-neutral-200 md:inline-flex",children:r})]})}
1function M(e){let{companies:t,company:a,onCompany:n,paymentStatus:s,onPaymentStatus:r,invoiceStatus:i,onInvoiceStatus:o,fromDate:d,onFromDate:c,toDate:u,onToDate:x,activeTab:m,onClose:b}=e;return(0,l.jsx)("div",{className:"border-t border-neutral-200/70 px-6 py-4",children:(0,l.jsxs)("div",{className:"grid gap-3 md:grid-cols-[1.2fr_0.8fr_0.8fr_0.8fr_auto] md:items-end",children:[(0,l.jsx)(G,{label:"Empresa",children:(0,l.jsx)(H,{value:a,onChange:n,options:[{value:"all",label:"Todas"},...(t||[]).map(e=>({value:String(e.id),label:e.name}))]})}),(0,l.jsx)(G,{label:"payments"===m?"Estado pago":"Estado factura",children:"payments"===m?(0,l.jsx)(H,{value:s,onChange:r,options:[{value:"all",label:"Todos"},{value:"accredited",label:"Acreditado"},{value:"pending",label:"Pendiente"},{value:"failed",label:"Fallido"},{value:"refunded",label:"Reintegrado"}]}):(0,l.jsx)(H,{value:i,onChange:o,options:[{value:"all",label:"Todos"},{value:"attached",label:"Adjunta"},{value:"draft",label:"Borrador"}]})}),(0,l.jsx)(G,{label:"Desde",children:(0,l.jsx)("input",{type:"date",value:d,onChange:e=>c(e.target.value),className:"w-full rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm shadow-sm focus:border-indigo-300 focus:outline-none focus:ring-2 focus:ring-indigo-200"})}),(0,l.jsx)(G,{label:"Hasta",children:(0,l.jsx)("input",{type:"date",value:u,onChange:e=>x(e.target.value),className:"w-full rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm shadow-sm focus:border-indigo-300 focus:outline-none focus:ring-2 focus:ring-indigo-200"})}),(0,l.jsx)("div",{className:"flex gap-2",children:(0,l.jsx)("button",{className:"w-full rounded-xl bg-neutral-900 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-neutral-800",onClick:b,children:"Aplicar"})})]})})}function I(e){let{rows:t,locale:a,formatDate:n,onOpen:s,onAttach:r,onGenerate:i,onRegisterTransfer:o}=e;return(0,l.jsxs)("div",{className:"mt-4 overflow-hidden rounded-2xl border border-neutral-200 bg-white shadow-sm",children:[(0,l.jsx)("div",{className:"flex flex-wrap items-center gap-3 border-b border-neutral-200/70 px-5 py-4",children:(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"text-sm font-semibold",children:"Pagos y transferencias"}),(0,l.jsx)("div",{className:"text-sm text-neutral-500",children:"Incluye cobros autom\xe1ticos y acreditaciones manuales por transferencia."})]})}),(0,l.jsx)("div",{className:"overflow-auto",children:(0,l.jsxs)("table",{className:"min-w-full text-left text-sm",children:[(0,l.jsx)("thead",{className:"bg-neutral-50 text-neutral-600",children:(0,l.jsxs)("tr",{className:"border-b border-neutral-200/70",children:[(0,l.jsx)("th",{className:"px-5 py-3 font-semibold",children:"Empresa"}),(0,l.jsx)("th",{className:"px-5 py-3 font-semibold",children:"Referencia"}),(0,l.jsx)("th",{className:"px-5 py-3 font-semibold",children:"Fecha"}),(0,l.jsx)("th",{className:"px-5 py-3 font-semibold",children:"Estado"}),(0,l.jsx)("th",{className:"px-5 py-3 font-semibold",children:"Origen"}),(0,l.jsx)("th",{className:"px-5 py-3 font-semibold",children:"Bruto"}),(0,l.jsx)("th",{className:"px-5 py-3 font-semibold",children:"Comision"}),(0,l.jsx)("th",{className:"px-5 py-3 font-semibold",children:"Impuestos"}),(0,l.jsx)("th",{className:"px-5 py-3 font-semibold",children:"Neto"}),(0,l.jsx)("th",{className:"px-5 py-3 font-semibold",children:"Factura"}),(0,l.jsx)("th",{className:"px-5 py-3 text-right font-semibold",children:"Acciones"})]})}),(0,l.jsxs)("tbody",{className:"divide-y divide-neutral-200/70",children:[(t||[]).map(e=>{var t,d,c;let u=(null==e?void 0:e.is_accredited_payment)&&(null==e?void 0:null===(t=e.invoice)||void 0===t?void 0:t.status)==="missing";return(0,l.jsxs)("tr",{className:"hover:bg-neutral-50",children:[(0,l.jsxs)("td",{className:"px-5 py-4",children:[(0,l.jsx)("div",{className:"font-semibold text-neutral-900",children:e.company_name||"â"}),(0,l.jsxs)("div",{className:"mt-0.5 text-xs text-neutral-500",children:[e.company_tax_id||"â"," ⢠",e.company_tax_condition||"â"]})]}),(0,l.jsxs)("td",{className:"px-5 py-4",children:[(0,l.jsx)("button",{onClick:()=>s(e.id),className:"font-extrabold text-indigo-700 hover:underline",children:e.mp_payment_id||e.source_reference||"â"}),(0,l.jsx)("div",{className:"mt-0.5 text-xs text-neutral-500",children:e.source_reference||e.external_reference||"â"})]}),(0,l.jsxs)("td",{className:"px-5 py-4",children:[(0,l.jsx)("div",{className:"font-semibold",children:n(e.created_at)}),(0,l.jsxs)("div",{className:"mt-0.5 text-xs text-neutral-500",children:["Aprobado: ",n(e.approved_at)]})]}),(0,l.jsx)("td",{className:"px-5 py-4",children:(0,l.jsx)($,{status:e.status})}),(0,l.jsx)("td",{className:"px-5 py-4",children:(0,l.jsx)("span",{className:"inline-flex items-center rounded-full bg-neutral-100 px-2 py-0.5 text-[11px] font-semibold text-neutral-700 ring-1 ring-neutral-200",children:"BANK_TRANSFER"===String(e.payment_source||"MERCADO_PAGO").toUpperCase()?"Transferencia":"Mercado Pago"})}),(0,l.jsx)("td",{className:"px-5 py-4 font-extrabold",children:A(e.gross_amount,e.currency,a)}),(0,l.jsxs)("td",{className:"px-5 py-4",children:[(0,l.jsx)("div",{className:"font-semibold",children:A(e.fee_amount,e.currency,a)}),(0,l.jsx)("div",{className:"mt-0.5 text-xs text-neutral-500",children:"Fee MP"})]}),(0,l.jsxs)("td",{className:"px-5 py-4",children:[(0,l.jsx)("div",{className:"font-semibold",children:A(e.taxes_amount,e.currency,a)}),(0,l.jsx)("div",{className:"mt-0.5 text-xs text-neutral-500",children:"Ret./Imp."})]}),(0,l.jsxs)("td",{className:"px-5 py-4",children:[(0,l.jsx)("div",{className:"font-extrabold",children:A(e.net_received,e.currency,a)}),(0,l.jsx)("div",{className:"mt-0.5 text-xs text-neutral-500",children:"Neto"})]}),(0,l.jsxs)("td",{className:"px-5 py-4",children:[(0,l.jsx)(X,{status:null==e?void 0:null===(d=e.invoice)||void 0===d?void 0:d.status}),(null==e?void 0:null===(c=e.invoice)||void 0===c?void 0:c.number)?(0,l.jsx)("div",{className:"mt-1 text-xs text-neutral-500",children:e.invoice.number}):null]}),(0,l.jsxs)("td",{className:"px-5 py-4 text-right",children:[(0,l.jsx)(K,{title:"Ver detalle",icon:N.Z,onClick:()=>s(e.id)}),(0,l.jsx)(K,{title:"Adjuntar PDF",icon:w,onClick:()=>r(e)}),(0,l.jsx)(K,{title:"Registrar transferencia",icon:h,onClick:()=>null==o?void 0:o(e)}),u?(0,l.jsxs)("button",{onClick:()=>i(e),className:"ml-2 inline-flex items-center gap-2 rounded-xl bg-neutral-900 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-neutral-800",children:[(0,l.jsx)(g,{className:"h-4 w-4"})," Facturar"]}):(0,l.jsxs)("button",{disabled:!0,className:"ml-2 inline-flex items-center gap-2 rounded-xl bg-neutral-200 px-3 py-2 text-sm font-semibold text-neutral-500",title:"Disponible solo para pagos acreditados sin factura",children:[(0,l.jsx)(g,{className:"h-4 w-4"})," Facturar"]})]})]},e.id)}),0===(t||[]).length?(0,l.jsx)("tr",{children:(0,l.jsx)("td",{colSpan:11,className:"px-5 py-10",children:(0,l.jsx)("div",{className:"rounded-2xl border border-neutral-200 bg-white p-6 text-center text-sm text-neutral-600 shadow-sm",children:"No hay pagos para los filtros actuales."})})}):null]})]})})]})}function T(e){let{rows:t,locale:a,formatDate:n,onOpen:s}=e;return(0,l.jsxs)("div",{className:"mt-4 grid gap-4 md:grid-cols-3",children:[(t||[]).map(e=>{var t,r,i,o;return(0,l.jsxs)("button",{onClick:s?()=>s(e):void 0,className:"text-left rounded-2xl border border-neutral-200 bg-white p-5 shadow-sm hover:shadow-md transition",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"text-sm font-extrabold",children:e.number||"(sin numero)"}),(0,l.jsx)("span",{className:"rounded-full bg-neutral-100 px-2 py-0.5 text-[11px] font-semibold text-neutral-700 ring-1 ring-neutral-200",children:e.type||"â"})]}),(0,l.jsx)("div",{className:"mt-1 text-sm text-neutral-600",children:e.company_name}),(0,l.jsxs)("div",{className:"mt-1 text-xs text-neutral-500",children:["Pago MP: ",e.mp_payment_id||"â"]}
1)]}),(0,l.jsx)(X,{status:e.status})]}),(0,l.jsxs)("div",{className:"mt-4 grid grid-cols-2 gap-3",children:[(0,l.jsx)(J,{label:"Bruto",value:A(null===(t=e.amounts)||void 0===t?void 0:t.gross,"ARS",a)}),(0,l.jsx)(J,{label:"Neto",value:A(null===(r=e.amounts)||void 0===r?void 0:r.net,"ARS",a),bold:!0}),(0,l.jsx)(J,{label:"Comision",value:A(null===(i=e.amounts)||void 0===i?void 0:i.fee,"ARS",a)}),(0,l.jsx)(J,{label:"Impuestos",value:A(null===(o=e.amounts)||void 0===o?void 0:o.taxes,"ARS",a)})]}),(0,l.jsxs)("div",{className:"mt-4 flex items-center justify-between rounded-xl bg-neutral-50 p-3 ring-1 ring-neutral-200",children:[(0,l.jsx)("div",{className:"text-xs text-neutral-600",children:e.pdf_name?"PDF: ".concat(e.pdf_name):"Sin PDF adjunto"}),(0,l.jsxs)("div",{className:"inline-flex items-center gap-2 text-xs font-semibold text-neutral-700",children:["Ver ",(0,l.jsx)(N.Z,{className:"h-4 w-4"})]})]}),(0,l.jsxs)("div",{className:"mt-2 text-xs text-neutral-500",children:["Emitida: ",n(e.issued_at)]})]},e.id)}),0===(t||[]).length?(0,l.jsx)("div",{className:"md:col-span-3 rounded-2xl border border-neutral-200 bg-white p-8 text-center text-sm text-neutral-600 shadow-sm",children:"No hay facturas para los filtros actuales."}):null]})}function z(e){var t,a,n,s,r;let{payment:i,onClose:o,locale:d,formatDate:c,onGenerateInvoice:u,onAttachPdf:x,onOpenInvoice:m}=e,b=(null==i?void 0:i.is_accredited_payment)&&(null==i?void 0:null===(t=i.invoice)||void 0===t?void 0:t.status)==="missing";return(0,l.jsxs)("div",{className:"fixed inset-0 z-[1200]",children:[(0,l.jsx)("button",{className:"absolute inset-0 bg-neutral-900/30 backdrop-blur-[1px]",onClick:o,"aria-label":"Close"}),(0,l.jsx)("div",{className:"relative flex min-h-full items-center justify-center p-4",children:(0,l.jsxs)("div",{className:"w-full max-w-[920px] overflow-hidden rounded-2xl border border-neutral-200 bg-white shadow-[0_22px_60px_rgba(0,0,0,.22)]",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between border-b border-neutral-200/70 px-6 py-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"text-base font-extrabold",children:"Detalle de pago"}),(0,l.jsxs)("div",{className:"mt-1 text-sm text-neutral-500",children:["MP ",i.mp_payment_id||"â"," ⢠",i.company_name||"â"," ⢠",i.external_reference||"â"]})]}),(0,l.jsx)("button",{onClick:o,className:"rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm font-semibold text-neutral-700 hover:bg-neutral-50",children:"Cerrar"})]}),(0,l.jsxs)("div",{className:"grid gap-0 md:grid-cols-[1fr_340px]",children:[(0,l.jsxs)("div",{className:"p-6",children:[(0,l.jsxs)("div",{className:"rounded-2xl border border-neutral-200 bg-neutral-50 p-4",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsx)("div",{className:"text-sm font-semibold text-neutral-900",children:i.company_name||"â"}),(0,l.jsxs)("div",{className:"mt-1 text-xs text-neutral-500",children:[i.company_tax_id||"â"," ⢠",i.company_tax_condition||"â"]}),(0,l.jsx)("div",{className:"mt-3 text-sm text-neutral-700",children:i.description||"Suscripcion Talkza"}),(0,l.jsxs)("div",{className:"mt-2 text-xs text-neutral-500",children:["Metodo: ",i.payment_method||"â"," ⢠Payer: ",(null===(a=i.payer)||void 0===a?void 0:a.email)||"â"," ⢠CUIT ",(null===(n=i.payer)||void 0===n?void 0:n.cuit)||"â"]})]}),(0,l.jsx)($,{status:i.status,compact:!0})]}),(0,l.jsxs)("div",{className:"mt-4 grid grid-cols-2 gap-3",children:[(0,l.jsx)(J,{label:"Bruto",value:A(i.gross_amount,i.currency,d)}),(0,l.jsx)(J,{label:"Neto",value:A(i.net_received,i.currency,d),bold:!0}),(0,l.jsx)(J,{label:"Comision MP",value:A(i.fee_amount,i.currency,d)}),(0,l.jsx)(J,{label:"Impuestos / retenciones",value:A(i.taxes_amount,i.currency,d)})]}),(0,l.jsxs)("div",{className:"mt-4 rounded-xl border border-neutral-200 bg-white p-3",children:[(0,l.jsx)("div",{className:"text-xs font-semibold text-neutral-500",children:"Release"}),(0,l.jsxs)("div",{className:"mt-1 text-sm font-semibold",children:["Estado: ",i.money_release_status||"â"]}
1),(0,l.jsxs)("div",{className:"mt-1 text-xs text-neutral-500",children:["Aprobado: ",c(i.approved_at)," ⢠Creado: ",c(i.created_at)]})]})]}),(0,l.jsxs)("div",{className:"mt-4 rounded-2xl border border-neutral-200 bg-white p-4",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"text-sm font-semibold",children:"Impuestos discriminados"}),(0,l.jsx)("div",{className:"mt-1 text-sm text-neutral-500",children:"Desglose por tipo (fees y retenciones)."})]}),(0,l.jsxs)("span",{className:"rounded-full bg-neutral-100 px-2 py-0.5 text-[11px] font-semibold text-neutral-700 ring-1 ring-neutral-200",children:[(i.taxes_breakdown||[]).length," items"]})]}),(0,l.jsx)("div",{className:"mt-4 overflow-hidden rounded-xl ring-1 ring-neutral-200",children:(0,l.jsxs)("table",{className:"min-w-full text-sm",children:[(0,l.jsx)("thead",{className:"bg-neutral-50 text-neutral-600",children:(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{className:"px-4 py-2 text-left font-semibold",children:"Tipo"}),(0,l.jsx)("th",{className:"px-4 py-2 text-left font-semibold",children:"Detalle"}),(0,l.jsx)("th",{className:"px-4 py-2 text-right font-semibold",children:"Monto"})]})}),(0,l.jsxs)("tbody",{className:"divide-y divide-neutral-200/70",children:[(i.taxes_breakdown||[]).map(e=>(0,l.jsxs)("tr",{children:[(0,l.jsx)("td",{className:"px-4 py-2",children:(0,l.jsx)("span",{className:"rounded-full bg-neutral-100 px-2 py-0.5 text-[11px] font-semibold text-neutral-700 ring-1 ring-neutral-200",children:e.key})}),(0,l.jsx)("td",{className:"px-4 py-2 text-neutral-700",children:e.label}),(0,l.jsx)("td",{className:"px-4 py-2 text-right font-extrabold",children:A(e.amount,i.currency,d)})]},e.key)),0===(i.taxes_breakdown||[]).length?(0,l.jsx)("tr",{children:(0,l.jsx)("td",{colSpan:3,className:"px-4 py-6 text-center text-sm text-neutral-600",children:"No hay desglose de impuestos/fees para este pago."})}):null]})]})})]})]}),(0,l.jsxs)("div",{className:"border-l border-neutral-200/70 p-6",children:[(0,l.jsx)("div",{className:"text-sm font-semibold",children:"Factura"}),(0,l.jsx)("div",{className:"mt-1 text-sm text-neutral-500",children:"Asocia PDF o genera borrador interno."}),(0,l.jsxs)("div",{className:"mt-4 rounded-2xl border border-neutral-200 bg-neutral-50 p-4",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"text-sm font-semibold",children:"Estado"}),(0,l.jsx)("div",{className:"mt-1",children:(0,l.jsx)(X,{status:null==i?void 0:null===(s=i.invoice)||void 0===s?void 0:s.status})}),(null==i?void 0:null===(r=i.invoice)||void 0===r?void 0:r.number)?(0,l.jsxs)("div",{className:"mt-2 text-xs text-neutral-600",children:["Nro: ",i.invoice.number]}):null]}),(0,l.jsx)(g,{className:"h-5 w-5 text-neutral-700"})]}),(0,l.jsxs)("div",{className:"mt-4 grid gap-2",children:[(0,l.jsxs)("button",{onClick:u,disabled:!b,className:b?"inline-flex items-center justify-center gap-2 rounded-xl bg-neutral-900 px-3 py-2 text-sm font-semibold text-white hover:bg-neutral-800":"inline-flex items-center justify-center gap-2 rounded-xl bg-neutral-200 px-3 py-2 text-sm font-semibold text-neutral-500",children:[(0,l.jsx)(g,{className:"h-4 w-4"})," Facturar (borrador)"]}),(0,l.jsxs)("button",{onClick:x,className:"inline-flex items-center justify-center gap-2 rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm font-semibold text-neutral-700 hover:bg-neutral-50",children:[(0,l.jsx)(w,{className:"h-4 w-4"})," Adjuntar PDF"]}),(0,l.jsxs)("button",{onClick:m,className:"inline-flex items-center justify-center gap-2 rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm font-semibold text-neutral-700 hover:bg-neutral-50",children:[(0,l.jsx)(N.Z,{className:"h-4 w-4"})," Ver factura"]})]})]}),(0,l.jsx)("div",{className:"mt-4 rounded-xl bg-neutral-50 p-3 text-xs text-neutral-600 ring-1 ring-neutral-200",children:'Tip: no facturar eventos "scheduled". Solo pagos acreditados.'})]})]})]})})]})}function B(e){var t,a,s,r;let{invoice:i,onClose:o,locale:d,formatDate:c,onDeletePdf:u,onReplacePdf:x}
1=e,[m,b]=(0,n.useState)(!1),p=async()=>{if(u&&window.confirm("Se eliminar\xe1 el PDF adjunto de esta factura. \xbfContinuar?")){b(!0);try{await u()}catch(e){k.Am.error((null==e?void 0:e.message)||"No se pudo eliminar el PDF")}finally{b(!1)}}};return(0,l.jsxs)("div",{className:"fixed inset-0 z-[1200]",children:[(0,l.jsx)("button",{className:"absolute inset-0 bg-neutral-900/30 backdrop-blur-[1px]",onClick:o,"aria-label":"Close"}),(0,l.jsx)("div",{className:"relative flex min-h-full items-center justify-center p-4",children:(0,l.jsxs)("div",{className:"w-full max-w-[880px] overflow-hidden rounded-2xl border border-neutral-200 bg-white shadow-[0_22px_60px_rgba(0,0,0,.22)]",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between border-b border-neutral-200/70 px-6 py-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"text-base font-extrabold",children:"Detalle de factura"}),(0,l.jsxs)("div",{className:"mt-1 text-sm text-neutral-500",children:[i.type||"â"," ",i.number||"(sin numero)"," ⢠",i.company_name||"â"]})]}),(0,l.jsx)("button",{onClick:o,className:"rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm font-semibold text-neutral-700 hover:bg-neutral-50",children:"Cerrar"})]}),(0,l.jsxs)("div",{className:"p-6",children:[(0,l.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,l.jsxs)("div",{className:"rounded-2xl border border-neutral-200 bg-neutral-50 p-4",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"text-sm font-semibold",children:"Empresa"}),(0,l.jsx)("div",{className:"mt-1 text-sm text-neutral-700",children:i.company_name||"â"}),(0,l.jsxs)("div",{className:"mt-1 text-xs text-neutral-500",children:[i.company_tax_id||"â"," ⢠",i.company_tax_condition||"â"]})]}),(0,l.jsx)(X,{status:i.status})]}),(0,l.jsxs)("div",{className:"mt-4 grid grid-cols-2 gap-3",children:[(0,l.jsx)(J,{label:"Bruto",value:A(null===(t=i.amounts)||void 0===t?void 0:t.gross,"ARS",d)}),(0,l.jsx)(J,{label:"Neto",value:A(null===(a=i.amounts)||void 0===a?void 0:a.net,"ARS",d),bold:!0}),(0,l.jsx)(J,{label:"Comision",value:A(null===(s=i.amounts)||void 0===s?void 0:s.fee,"ARS",d)}),(0,l.jsx)(J,{label:"Impuestos",value:A(null===(r=i.amounts)||void 0===r?void 0:r.taxes,"ARS",d)}),(0,l.jsx)(J,{label:"Emitida",value:c(i.issued_at)}),(0,l.jsx)(J,{label:"Pago MP",value:i.mp_payment_id||"â"})]})]}),(0,l.jsxs)("div",{className:"rounded-2xl border border-neutral-200 bg-white p-4",children:[(0,l.jsx)("div",{className:"text-sm font-semibold",children:"PDF"}),(0,l.jsx)("div",{className:"mt-1 text-sm text-neutral-500",children:"Adjunto de factura fisica o export interno."}),(0,l.jsxs)("div",{className:"mt-4 rounded-xl border border-neutral-200 bg-neutral-50 p-4",children:[(0,l.jsx)("div",{className:"text-sm font-semibold",children:i.pdf_name||"Sin PDF adjunto"}),(0,l.jsx)("div",{className:"mt-1 text-xs text-neutral-500 break-all",children:i.pdf_url||"Podes subir o asociar un link de PDF."}),(0,l.jsxs)("div",{className:"mt-3 flex items-center gap-2",children:[i.download_url?(0,l.jsx)("a",{href:i.download_url,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-2 rounded-xl bg-neutral-900 px-3 py-2 text-xs font-semibold text-white hover:bg-neutral-800",children:"Descargar PDF"}):null,i.payment_row_id?(0,l.jsxs)("button",{onClick:x,className:"inline-flex items-center gap-2 rounded-xl border border-neutral-200 bg-white px-3 py-2 text-xs font-semibold text-neutral-700 hover:bg-neutral-50",children:[(0,l.jsx)(w,{className:"h-3.5 w-3.5"}),"Reemplazar PDF"]}):null,i.pdf_url?(0,l.jsxs)("button",{onClick:p,disabled:m,className:"inline-flex items-center gap-2 rounded-xl border border-rose-200 bg-rose-50 px-3 py-2 text-xs font-semibold text-rose-700 hover:bg-rose-100 disabled:opacity-60",children:[(0,l.jsx)(_.Z,{className:"h-3.5 w-3.5"}),m?"Eliminando...":"Eliminar PDF"]}):null]})]}),(0,l.jsx)("div",{className:"mt-4 rounded-xl bg-neutral-50 p-3 text-xs text-neutral-600 ring-1 ring-neutral-200",children:"Nota: al integrar AFIP podras mostrar CAE y vencimiento aqui."})]})]}),(0,l.jsx)("div",{className:"mt-4 text-sm text-neutral-600",children:i.notes||"Sin notas."})]})]})})]})}function O(e){let{payment:t,apiBase:a,authHeaders:s,onClose:r,onSaved:i}
1=e,[o,d]=(0,n.useState)(()=>{var e;return(null==t?void 0:null===(e=t.invoice)||void 0===e?void 0:e.type)||F(null==t?void 0:t.company_tax_condition)}),[c,u]=(0,n.useState)(()=>{var e;return(null==t?void 0:null===(e=t.invoice)||void 0===e?void 0:e.number)||""}),[x,m]=(0,n.useState)(()=>{var e;return E(null==t?void 0:null===(e=t.invoice)||void 0===e?void 0:e.issued_at)}),[b,p]=(0,n.useState)(""),[h,g]=(0,n.useState)(""),[f,v]=(0,n.useState)(()=>{var e;return(null==t?void 0:null===(e=t.invoice)||void 0===e?void 0:e.notes)||""}),[j,y]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let e=(null==t?void 0:t.invoice)||null;d((null==e?void 0:e.type)||F(null==t?void 0:t.company_tax_condition)),u((null==e?void 0:e.number)||""),m(E(null==e?void 0:e.issued_at)),p(D(null==e?void 0:e.subtotal)),g(D(null==e?void 0:e.vat)),v((null==e?void 0:e.notes)||"")},[null==t?void 0:t.id,null==t?void 0:t.invoice,null==t?void 0:t.company_tax_condition]);let N=async()=>{y(!0);try{let e=await fetch("".concat(a,"/api/admin/billing/payments/").concat(t.id,"/invoice-draft"),{method:"POST",headers:s(!0),body:JSON.stringify({invoice_type:o,invoice_number:c||null,issued_at:x||null,invoice_subtotal:b||null,invoice_vat:h||null,notes:f||null})}),l=await e.json().catch(()=>({}));if(!e.ok||!(null==l?void 0:l.ok))throw Error((null==l?void 0:l.message)||"No se pudo guardar borrador");k.Am.success("Borrador de factura creado"),i()}catch(e){k.Am.error((null==e?void 0:e.message)||"Error guardando borrador")}finally{y(!1)}};return(0,l.jsxs)("div",{className:"fixed inset-0 z-[1200]",children:[(0,l.jsx)("button",{className:"absolute inset-0 bg-neutral-900/30 backdrop-blur-[1px]",onClick:r,"aria-label":"Close"}),(0,l.jsx)("div",{className:"relative flex min-h-full items-center justify-center p-4",children:(0,l.jsxs)("div",{className:"w-full max-w-[760px] overflow-hidden rounded-2xl border border-neutral-200 bg-white shadow-[0_22px_60px_rgba(0,0,0,.22)]",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between border-b border-neutral-200/70 px-6 py-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"text-base font-extrabold",children:"Generar factura (borrador)"}),(0,l.jsxs)("div",{className:"mt-1 text-sm text-neutral-500",children:["Pago MP ",t.mp_payment_id||"â"," ⢠",t.company_name||"â"]})]}),(0,l.jsx)("button",{onClick:r,className:"rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm font-semibold text-neutral-700 hover:bg-neutral-50",children:"Cerrar"})]}),(0,l.jsxs)("div",{className:"p-6 space-y-3",children:[(0,l.jsx)(G,{label:"Tipo sugerido",children:(0,l.jsx)(H,{value:o,onChange:d,options:[{value:"A",label:"Factura A"},{value:"B",label:"Factura B"},{value:"C",label:"Factura C"},{value:"E",label:"Factura E"}]})}),(0,l.jsx)(G,{label:"Numero",children:(0,l.jsx)("input",{value:c,onChange:e=>u(e.target.value),className:"w-full rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm shadow-sm focus:border-indigo-300 focus:outline-none focus:ring-2 focus:ring-indigo-200",placeholder:"0001-00001234"})}),(0,l.jsx)(G,{label:"Fecha emision",children:(0,l.jsx)("input",{type:"date",value:x,onChange:e=>m(e.target.value),className:"w-full rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm shadow-sm focus:border-indigo-300 focus:outline-none focus:ring-2 focus:ring-indigo-200"})}),(0,l.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,l.jsx)(G,{label:"Subtotal factura",children:(0,l.jsx)("input",{type:"number",step:"0.01",min:"0",value:b,onChange:e=>p(e.target.value),className:"w-full rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm shadow-sm focus:border-indigo-300 focus:outline-none focus:ring-2 focus:ring-indigo-200",placeholder:"0.00"})}),(0,l.jsx)(G,{label:"IVA factura",children:(0,l.jsx)("input",{type:"number",step:"0.01",min:"0",value:h,onChange:e=>g(e.target.value),className:"w-full rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm shadow-sm focus:border-indigo-300 focus:outline-none focus:ring-2 focus:ring-indigo-200",placeholder:"0.00"})})]}),(0,l.jsx)(G,{label:"Notas internas",children:(0,l.jsx)("textarea",{value:f,onChange:e=>v(e.target.value),rows:3,className:"w-full resize-none rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm shadow-sm focus:border-indigo-300 focus:outline-none focus:ring-2 focus:ring-indigo-200"})})]}),(0,l.jsxs)("div",{className:"flex items-center justify-end gap-2 border-t border-neutral-200/70 px-6 py-4",children:[(0,l.jsx)("button",{onClick:r,className:"rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm font-semibold text-neutral-700 hover:bg-neutral-50",children:"Cancelar"}),(0,l.jsx)("button",{onClick:N,disabled:j,className:"rounded-xl bg-neutral-900 px-3 py-2 text-sm font-semibold text-white hover:bg-neutral-800 disabled:opacity-70",children:j?"Guardando...":"Crear borrador"})]})]})})]})}function L(e){let{payment:t,apiBase:a,authHeaders:s,onClose:r,onSaved:i}
1=e,[o,d]=(0,n.useState)(()=>{var e;return(null==t?void 0:null===(e=t.invoice)||void 0===e?void 0:e.type)||F(null==t?void 0:t.company_tax_condition)}),[c,u]=(0,n.useState)(()=>{var e;return(null==t?void 0:null===(e=t.invoice)||void 0===e?void 0:e.number)||""}),[x,m]=(0,n.useState)(()=>{var e;return E(null==t?void 0:null===(e=t.invoice)||void 0===e?void 0:e.issued_at)}),[b,p]=(0,n.useState)(()=>{var e;return D(null==t?void 0:null===(e=t.invoice)||void 0===e?void 0:e.subtotal)}),[h,g]=(0,n.useState)(()=>{var e;return D(null==t?void 0:null===(e=t.invoice)||void 0===e?void 0:e.vat)}),[f,v]=(0,n.useState)(null),[j,y]=(0,n.useState)(()=>{var e;return(null==t?void 0:null===(e=t.invoice)||void 0===e?void 0:e.notes)||""}),[N,w]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let e=(null==t?void 0:t.invoice)||null;d((null==e?void 0:e.type)||F(null==t?void 0:t.company_tax_condition)),u((null==e?void 0:e.number)||""),m(E(null==e?void 0:e.issued_at)),p(D(null==e?void 0:e.subtotal)),g(D(null==e?void 0:e.vat)),y((null==e?void 0:e.notes)||"")},[null==t?void 0:t.id,null==t?void 0:t.invoice,null==t?void 0:t.company_tax_condition]),(0,n.useEffect)(()=>{let e=!1,l=Number((null==t?void 0:t.id)||0);return l&&(async()=>{try{var n;let r=await fetch("".concat(a,"/api/admin/billing/payments/").concat(l),{headers:s(!1)}),i=await r.json().catch(()=>({}));if(!r.ok||!(null==i?void 0:i.ok)||e)return;let o=(null==i?void 0:null===(n=i.payment)||void 0===n?void 0:n.invoice)||null;if(!o)return;d((null==o?void 0:o.type)||F(null==t?void 0:t.company_tax_condition)),u((null==o?void 0:o.number)||""),m(E(null==o?void 0:o.issued_at)),p(D(null==o?void 0:o.subtotal)),g(D(null==o?void 0:o.vat)),y((null==o?void 0:o.notes)||"")}catch(e){}})(),()=>{e=!0}},[a,s,null==t?void 0:t.id,null==t?void 0:t.company_tax_condition]);let _=e=>new Promise((t,a)=>{let l=new FileReader;l.onerror=()=>a(Error("No se pudo leer el archivo")),l.onload=()=>{let e=String(l.result||""),a=e.indexOf(",");t(a>=0?e.slice(a+1):e)},l.readAsDataURL(e)}),S=async()=>{if(!f){k.Am.error("Selecciona un PDF");return}if(!String((null==f?void 0:f.name)||"").toLowerCase().endsWith(".pdf")){k.Am.error("Solo se permite archivo PDF");return}
1if(f.size>10485760){k.Am.error("El PDF excede 10MB");return}w(!0);try{let e=await _(f),l=await fetch("".concat(a,"/api/admin/billing/payments/").concat(t.id,"/invoice-upload"),{method:"POST",headers:s(!0),body:JSON.stringify({base64:e,filename:f.name,invoice_type:o,invoice_number:c||null,issued_at:x||null,invoice_subtotal:b||null,invoice_vat:h||null,notes:j||null})}),n=await l.json().catch(()=>({}));if(!l.ok||!(null==n?void 0:n.ok))throw Error((null==n?void 0:n.message)||"No se pudo adjuntar la factura");k.Am.success("Factura adjuntada al pago"),await Promise.resolve(null==i?void 0:i())}catch(e){k.Am.error((null==e?void 0:e.message)||"Error adjuntando factura")}finally{w(!1)}};return(0,l.jsxs)("div",{className:"fixed inset-0 z-[1200]",children:[(0,l.jsx)("button",{className:"absolute inset-0 bg-neutral-900/30 backdrop-blur-[1px]",onClick:r,"aria-label":"Close"}),(0,l.jsx)("div",{className:"relative flex min-h-full items-center justify-center p-4",children:(0,l.jsxs)("div",{className:"w-full max-w-[760px] overflow-hidden rounded-2xl border border-neutral-200 bg-white shadow-[0_22px_60px_rgba(0,0,0,.22)]",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between border-b border-neutral-200/70 px-6 py-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"text-base font-extrabold",children:"Adjuntar factura PDF"}),(0,l.jsxs)("div",{className:"mt-1 text-sm text-neutral-500",children:["Pago MP ",t.mp_payment_id||"â"," ⢠",t.company_name||"â"]})]}),(0,l.jsx)("button",{onClick:r,className:"rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm font-semibold text-neutral-700 hover:bg-neutral-50",children:"Cerrar"})]}),(0,l.jsxs)("div",{className:"p-6 space-y-3",children:[(0,l.jsx)(G,{label:"Tipo factura",children:(0,l.jsx)(H,{value:o,onChange:d,options:[{value:"A",label:"Factura A"},{value:"B",label:"Factura B"},{value:"C",label:"Factura C"},{value:"E",label:"Factura E"}]})}),(0,l.jsx)(G,{label:"Numero",children:(0,l.jsx)("input",{value:c,onChange:e=>u(e.target.value),className:"w-full rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm shadow-sm focus:border-indigo-300 focus:outline-none focus:ring-2 focus:ring-indigo-200",placeholder:"0001-00001234"})}),(0,l.jsx)(G,{label:"Fecha emision",children:(0,l.jsx)("input",{type:"date",value:x,onChange:e=>m(e.target.value),className:"w-full rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm shadow-sm focus:border-indigo-300 focus:outline-none focus:ring-2 focus:ring-indigo-200"})}),(0,l.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,l.jsx)(G,{label:"Subtotal factura",children:(0,l.jsx)("input",{type:"number",step:"0.01",min:"0",value:b,onChange:e=>p(e.target.value),className:"w-full rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm shadow-sm focus:border-indigo-300 focus:outline-none focus:ring-2 focus:ring-indigo-200",placeholder:"0.00"})}),(0,l.jsx)(G,{label:"IVA factura",children:(0,l.jsx)("input",{type:"number",step:"0.01",min:"0",value:h,onChange:e=>g(e.target.value),className:"w-full rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm shadow-sm focus:border-indigo-300 focus:outline-none focus:ring-2 focus:ring-indigo-200",placeholder:"0.00"})})]}),(0,l.jsxs)(G,{label:"Nombre archivo PDF",children:[(0,l.jsx)("input",{type:"file",accept:"application/pdf,.pdf",onChange:e=>{var t;return v((null===(t=e.target.files)||void 0===t?void 0:t[0])||null)},className:"w-full rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm shadow-sm file:mr-3 file:rounded-lg file:border-0 file:bg-neutral-100 file:px-3 file:py-1 file:text-xs file:font-semibold file:text-neutral-700 focus:border-indigo-300 focus:outline-none focus:ring-2 focus:ring-indigo-200"}),f?(0,l.jsxs)("div",{className:"mt-1 text-xs text-neutral-500",children:[f.name," ⢠",(f.size/1048576).toFixed(2)," MB"]}):(0,l.jsx)("div",{className:"mt-1 text-xs text-neutral-500",children:"Selecciona un PDF de hasta 10MB."})]}),(0,l.jsx)(G,{label:"Notas",children:(0,l.jsx)("textarea",{value:j,onChange:e=>y(e.target.value),rows:2,className:"w-full resize-none rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm shadow-sm focus:border-indigo-300 focus:outline-none focus:ring-2 focus:ring-indigo-200"})})]}),(0,l.jsxs)("div",{className:"flex items-center justify-end gap-2 border-t border-neutral-200/70 px-6 py-4",children:[(0,l.jsx)("button",{onClick:r,className:"rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm font-semibold text-neutral-700 hover:bg-neutral-50",children:"Cancelar"}),(0,l.jsx)("button",{onClick:S,disabled:N,className:"rounded-xl bg-neutral-900 px-3 py-2 text-sm font-semibold text-white hover:bg-neutral-800 disabled:opacity-70",children:N?"Guardando...":"Adjuntar factura"})]})]})})]})}function U(e){let{action:t}=e;if(!t)return null;let a=String(t.status||"").toUpperCase(),n={PENDING:{label:"Pausa solicitada",cls:"bg-indigo-50 text-indigo-700 ring-indigo-100"},PROCESSING:{label:"Pausa en proceso",cls:"bg-sky-50 text-sky-700 ring-sky-100"},SUCCEEDED:{label:"Pausada correctamente",cls:"bg-emerald-50 text-emerald-700 ring-emerald-100"},RETRYABLE_FAILED:{label:"Reintentando pausa",cls:"bg-amber-50 text-amber-800 ring-amber-100"}
1,MANUAL_ACTION_REQUIRED:{label:"Fall\xf3 la pausa (manual)",cls:"bg-rose-50 text-rose-700 ring-rose-100"}}[a]||{label:a||"Sin estado",cls:"bg-neutral-100 text-neutral-700 ring-neutral-200"};return(0,l.jsx)("span",{className:"inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-semibold ring-1 ".concat(n.cls),children:n.label})}function q(e){let{seed:t,apiBase:a,authHeaders:s,onClose:r,onSaved:i}=e,[o,d]=(0,n.useState)(()=>(null==t?void 0:t.subscription_id)?String(t.subscription_id):""),[c,u]=(0,n.useState)(""),[x,m]=(0,n.useState)(()=>(null==t?void 0:t.currency)||"ARS"),[b,p]=(0,n.useState)(()=>new Date().toISOString().slice(0,10)),[h,g]=(0,n.useState)(""),[f,v]=(0,n.useState)(""),[j,y]=(0,n.useState)(!0),[N,w]=(0,n.useState)(!1),[_,S]=(0,n.useState)(""),[C,A]=(0,n.useState)(null),[P,F]=(0,n.useState)(null),[E,D]=(0,n.useState)(!1),[Z,R]=(0,n.useState)(!1),M=(0,n.useMemo)(()=>(function(e){let t=String(e||"").trim();if(!t)return null;let a=t.replace(/\s/g,"").replace(/\$/g,"");if(!/^[0-9.,]+$/.test(a))return null;let l=a.lastIndexOf(","),n=a.lastIndexOf("."),s=null,r=null;if(l>=0&&n>=0)r=","==(s=l>n?",":".")?".":",";else if(l>=0)s=",";else if(n>=0){let e=a.split(".");(s=(e[e.length-1]||"").length<=2?".":null)||!(e.length>1)||(r=".")}let i=a;if(r&&(i=i.split(r).join("")),s&&"."!==s&&(i=i.replace(s,".")),!/^\d+(\.\d{1,2})?$/.test(i))return null;let o=Number(i);if(!Number.isFinite(o))return null;let d=o.toFixed(2),c=new Intl.NumberFormat("es-AR",{minimumFractionDigits:2,maximumFractionDigits:2}).format(o);return{amount:o,canonical:d,display:c}})(c),[c]),I=(0,n.useMemo)(()=>({subscription_id:Number(o||0)||null,amount:(null==M?void 0:M.canonical)||null,currency:String(x||"").trim().toUpperCase(),paid_at:b,bank_reference:h,notes:f||null,pause_mercadopago:j,override_amount_mismatch:N,override_reason:_||null}),[null==M?void 0:M.canonical,h,x,f,N,_,b,j,o]),T=async()=>{if(!I.subscription_id){k.Am.error("Ingresa una suscripci\xf3n v\xe1lida");return}if(!(null==M?void 0:M.canonical)){k.Am.error("Ingresa un monto v\xe1lido (ej: 338.800,00)");return}if(!I.bank_reference.trim()){k.Am.error("Ingresa la referencia bancaria");return}D(!0);try{let e=await fetch("".concat(a,"/api/admin/billing/manual-transfers/preview"),{method:"POST",headers:s(!0),body:JSON.stringify(I)}),t=await e.json().catch(()=>({}));if(!e.ok||!(null==t?void 0:t.ok))throw Error((null==t?void 0:t.message)||(null==t?void 0:t.code)||"No se pudo previsualizar");A(t.preview||null),F(null)}catch(e){k.Am.error((null==e?void 0:e.message)||"Error en previsualizaci\xf3n")}finally{D(!1)}},z=async()=>{if(!(null==M?void 0:M.canonical)){k.Am.error("Monto inv\xe1lido");return}R(!0);try{let e=await fetch("".concat(a,"/api/admin/billing/manual-transfers"),{method:"POST",headers:s(!0),body:JSON.stringify(I)}),t=await e.json().catch(()=>({}));if(!e.ok||!(null==t?void 0:t.ok))throw Error((null==t?void 0:t.message)||(null==t?void 0:t.code)||"No se pudo registrar la transferencia");F(t),k.Am.success((null==t?void 0:t.idempotent)?"Transferencia ya registrada (idempotencia)":"Transferencia registrada"),i()}catch(e){k.Am.error((null==e?void 0:e.message)||"Error registrando transferencia")}finally{R(!1)}};return(0,l.jsxs)("div",{className:"fixed inset-0 z-[1200]",children:[(0,l.jsx)("button",{className:"absolute inset-0 bg-neutral-900/30 backdrop-blur-[1px]",onClick:r,"aria-label":"Close"}),(0,l.jsx)("div",{className:"relative flex min-h-full items-center justify-center p-4",children:(0,l.jsxs)("div",{className:"w-full max-w-[860px] overflow-hidden rounded-2xl border border-neutral-200 bg-white shadow-[0_22px_60px_rgba(0,0,0,.22)]",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between border-b border-neutral-200/70 px-6 py-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"text-base font-extrabold",children:"Registrar transferencia manual"}),(0,l.jsxs)("div",{className:"mt-1 text-sm text-neutral-500",children:[(null==t?void 0:t.company_name)?"".concat(t.company_name," ⢠"):"",(null==t?void 0:t.bot_name)||"Suscripci\xf3n existente"]})]}),(0,l.jsx)("button",{onClick:r,className:"rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm font-semibold text-neutral-700 hover:bg-neutral-50",children:"Cerrar"})]}),(0,l.jsxs)("div",{className:"grid gap-4 p-6 md:grid-cols-2",children:[(0,l.jsx)(G,{label:"Subscription ID",children:(0,l.jsx)("input",{value:o,onChange:e=>d(e.target.value.replace(/[^\d]/g,"")),className:"w-full rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm shadow-sm focus:border-indigo-300 focus:outline-none focus:ring-2 focus:ring-indigo-200",placeholder:"157"})}),(0,l.jsx)(G,{label:"Fecha pago (paid_at)",children:(0,l.jsx)("input",{type:"date",value:b,onChange:e=>p(e.target.value),className:"w-full rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm shadow-sm focus:border-indigo-300 focus:outline-none focus:ring-2 focus:ring-indigo-200"})}),(0,l.jsxs)(G,{label:"Monto transferencia",children:[(0,l.jsx)("input",{value:c,onChange:e=>u(e.target.value),className:"w-full rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm shadow-sm focus:border-indigo-300 focus:outline-none focus:ring-2 focus:ring-indigo-200",placeholder:"338.800,00 / 338800,00 / 338800.00"}),(0,l.jsx)("div",{className:"mt-1 text-xs text-neutral-500",children:M?"Se enviar\xe1 como ".concat(M.canonical," (").concat(M.display,")"):"Admite formato monetario AR con coma decimal."})]}),(0,l.jsx)(G,{label:"Moneda",children:(0,l.jsx)("input",{value:x,onChange:e=>m(String(e.target.value||"").toUpperCase()),maxLength:8,className:"w-full rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm shadow-sm focus:border-indigo-300 focus:outline-none focus:ring-2 focus:ring-indigo-200"})}),(0,l.jsx)(G,{label:"Referencia bancaria",children:(0,l.jsx)("input",{value:h,onChange:e=>g(e.target.value),className:"w-full rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm shadow-sm focus:border-indigo-300 focus:outline-none focus:ring-2 focus:ring-indigo-200",placeholder:"COMPROBANTE / TXID"})}),(0,l.jsx)(G,{label:"Notas",children:(0,l.jsx)("textarea",{value:f,onChange:e=>v(e.target.value),rows:2,className:"w-full resize-none rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm shadow-sm focus:border-indigo-300 focus:outline-none focus:ring-2 focus:ring-indigo-200"})})]}),(0,l.jsxs)("div",{className:"px-6 pb-4 space-y-3",children:[(0,l.jsxs)("label",{className:"flex items-start gap-2 rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2 text-sm text-neutral-700",children:[(0,l.jsx)("input",{type:"checkbox",checked:j,onChange:e=>y(e.target.checked),className:"mt-1"}),(0,l.jsx)("span",{children:"Intentar pausar la suscripci\xf3n en Mercado Pago (evita nuevos intentos autom\xe1ticos, pero requerir\xe1 reactivaci\xf3n posterior)."})]}),(0,l.jsxs)("label",{className:"flex items-start gap-2 rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2 text-sm text-neutral-700",children:[(0,l.jsx)("input",{type:"checkbox",checked:N,onChange:e=>w(e.target.checked),className:"mt-1"}),(0,l.jsx)("span",{children:"Permitir override si importe/moneda n
1o coinciden con la suscripci\xf3n."})]}),N?(0,l.jsx)(G,{label:"Motivo override (obligatorio)",children:(0,l.jsx)("textarea",{value:_,onChange:e=>S(e.target.value),rows:2,className:"w-full resize-none rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm shadow-sm focus:border-indigo-300 focus:outline-none focus:ring-2 focus:ring-indigo-200"})}):null]}),C?(0,l.jsxs)("div",{className:"mx-6 mb-4 rounded-xl border border-neutral-200 bg-neutral-50 p-4 text-sm text-neutral-700",children:[(0,l.jsx)("div",{className:"font-semibold text-neutral-900",children:"Previsualizaci\xf3n"}),(0,l.jsxs)("div",{className:"mt-2 grid gap-2 md:grid-cols-2",children:[(0,l.jsxs)("div",{children:["Esperado: ",C.expected_currency||"â"," ",C.expected_amount||"â"]}),(0,l.jsxs)("div",{children:["Ingresado: ",C.currency," ",C.amount]}),(0,l.jsxs)("div",{children:["Pr\xf3x. ciclo actual: ",C.next_charge_date_current||"â"]}),(0,l.jsxs)("div",{children:["Pr\xf3x. ciclo nuevo: ",C.next_charge_date_after||"â"]}),(0,l.jsxs)("div",{children:["Cobertura hasta: ",C.paid_through_date_after||"â"]}),(0,l.jsxs)("div",{children:["Gracia: ",C.grace_days," d\xedas"]})]}),Array.isArray(C.issues)&&C.issues.length?(0,l.jsx)("div",{className:"mt-2 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-amber-900",children:C.issues.join(" \xb7 ")}):null]}):null,(null==P?void 0:P.provider_action)?(0,l.jsxs)("div",{className:"mx-6 mb-4 rounded-xl border border-neutral-200 bg-white p-4",children:[(0,l.jsx)("div",{className:"text-sm font-semibold text-neutral-900",children:"Estado de pausa MP"}),(0,l.jsx)("div",{className:"mt-2",children:(0,l.jsx)(U,{action:P.provider_action})})]}):null,(0,l.jsxs)("div",{className:"flex items-center justify-between border-t border-neutral-200/70 px-6 py-4",children:[(0,l.jsx)("button",{onClick:r,className:"rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm font-semibold text-neutral-700 hover:bg-neutral-50",children:"Cancelar"}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("button",{onClick:T,disabled:E,className:"rounded-xl border border-neutral-200 bg-white px-3 py-2 text-sm font-semibold text-neutral-700 hover:bg-neutral-50 disabled:opacity-70",children:E?"Previsualizando...":"Previsualizar"}),(0,l.jsx)("button",{onClick:z,disabled:Z,className:"rounded-xl bg-neutral-900 px-3 py-2 text-sm font-semibold text-white hover:bg-neutral-800 disabled:opacity-70",children:Z?"Registrando...":"Registrar transferencia"})]})]})]})})]})}function G(e){let{label:t,children:a}=e;return(0,l.jsxs)("label",{className:"block",children:[(0,l.jsx)("div",{className:"mb-1 text-xs font-semibold text-neutral-500",children:t}),a]})}function H(e){let{value:t,onChange:a,options:n}=e;return(0,l.jsxs)("div",{className:"relative",children:[(0,l.jsx)("select",{value:t,onChange:e=>a(e.target.value),className:"w-full appearance-none rounded-xl border border-neutral-200 bg-white px-3 py-2 pr-10 text-sm shadow-sm focus:border-indigo-300 focus:outline-none focus:ring-2 focus:ring-indigo-200",children:(n||[]).map(e=>(0,l.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,l.jsx)("span",{className:"pointer-events-none absolute inset-y-0 right-3 flex items-center text-neutral-400",children:(0,l.jsx)(m.Z,{className:"h-4 w-4"})})]})}function V(e){let{title:t,value:a,sub:n,icon:s,tone:r="indigo"}=e,i={indigo:{grad:"from-indigo-500 to-indigo-700",bg:"bg-indigo-50",ring:"ring-indigo-100",fg:"text-indigo-700"},fuchsia:{grad:"from-fuchsia-500 to-fuchsia-700",bg:"bg-fuchsia-50",ring:"ring-fuchsia-100",fg:"text-fuchsia-700"},emerald:{grad:"from-emerald-500 to-emerald-700",bg:"bg-emerald-50",ring:"ring-emerald-100",fg:"text-emerald-700"},amber:{grad:"from-amber-500 to-amber-700",bg:"bg-amber-50",ring:"ring-amber-100",fg:"text-amber-700"}},o=i[r]||i.indigo;return(0,l.jsxs)("div",{className:"relative overflow-hidden rounded-2xl bg-white p-4 shadow-[0_1px_2px_rgba(0,0,0,.06),_0_6px_18px_rgba(0,0,0,.04)] ring-1 ring-neutral-200",children:[(0,l.jsx)("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-1 bg-gradient-to-r ".concat(o.grad)}),(0,l.jsxs)("div",{className:"flex items-start justify-between",children:[(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsx)("div",{className:"text-sm font-medium text-neutral-600",children:t}),(0,l.jsx)("div",{className:"mt-2 truncate text-2xl font-semibold tracking-tight",children:a}),(0,l.jsx)("div",{className:"mt-1 text-sm text-neutral-500",children:n})]}),(0,l.jsx)("div",{className:"grid h-10 w-10 place-items-center rounded-xl ring-1 ".concat(o.bg," ").concat(o.ring," ").concat(o.fg),children:(0,l.jsx)(s,{className:"h-5 w-5"})})]})]})}function J(e){let{label:t,value:a,bold:n}=e;return(0,l.jsxs)("div",{className:"rounded-xl bg-white p-3 ring-1 ring-neutral-200",children:[(0,l.jsx)("div",{className:"text-xs font-semibold text-neutral-500",children:t}),(0,l.jsx)("div",{className:"mt-1 ".concat(n?"text-lg font-extrabold":"text-sm font-semibold"),children:a})]})}function $(e){let{status:t,compact:a}=e,n={accredited:{cls:"bg-emerald-50 text-emerald-700 ring-emerald-100",label:"Acreditado"},pending:{cls:"bg-indigo-50 text-indigo-700 ring-indigo-100",label:"Pendiente"},failed:{cls:"bg-rose-50 text-rose-700 ring-rose-100",label:"Fallido"},refunded:{cls:"bg-amber-50 text-amber-800 ring-amber-100",label:"Reintegrado"}}[t]||{cls:"bg-neutral-100 text-neutral-700 ring-neutral-200",label:t||"â"};return(0,l.jsx)("span",{className:"inline-flex items-center gap-1 rounded-full px-2 py-0.5 font-extrabold ring-1 ".concat(a?"text-[11px]":"text-xs"," ").concat(n.cls),children:n.label})}function X(e){let{status:t}=e;return"attached"===t?(0,l.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-extrabold text-emerald-700 ring-1 ring-emerald-100",children:[(0,l.jsx)(c.Z,{className:"h-3.5 w-3.5"})," Adjunta"]}):"draft"===t?(0,l.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-indigo-50 px-2 py-0.5 text-[11px] font-extrabold text-indigo-700 ring-1 ring-indigo-100",children:[(0,l.jsx)(d.Z,{className:"h-3.5 w-3.5"})," Borrador"]}):(0,l.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-amber-50 px-2 py-0.5 text-[11px] font-extrabold text-amber-800 ring-1 ring-amber-100",children:[(0,l.jsx)(y.Z,{className:"h-3.5 w-3.5"})," Sin factura"]})}function K(e){let{title:t,icon:a,onClick:n}=e;return(0,l.jsx)("button",{title:t,onClick:n,className:"inline-flex items-center justify-center rounded-xl border border-neutral-200 bg-white p-2 text-neutral-700 shadow-sm hover:bg-neutral-50",children:(0,l.jsx)(a,{className:"h-4 w-4"})})}function Q(){return(0,l.jsxs)("div",{className:"min-h-screen bg-neutral-50",children:[(0,l.jsxs)("div",{className:"pointer-events-none fixed inset-0 overflow-hidden",children:[(0,l.jsx)("div",{className:"absolute -top-28 -left-28 h-80 w-80 rounded-full bg-indigo-200/40 blur-3xl"}),(0,l.jsx)("div",{className:"absolute top-28 -right-28 h-80 w-80 rounded-full bg-fuchsia-200/30 blur-3xl"}),(0,l.jsx)("div",{className:"absolute bottom-[-140px] left-1/3 h-[420px] w-[420px] rounded-full bg-emerald-200/25 blur-3xl"})]}),(0,l.jsxs)("div",{className:"relative mx-auto max-w-[1480px] p-6 space-y-4",children:[(0,l.jsxs)("div",{className:"rounded-2xl border border-neutral-200 bg-white/85 backdrop-blur shadow-[0_1px_2px_rgba(0,0,0,.06),_0_10px_24px_rgba(0,0,0,.06)] overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-3 px-6 py-4 md:flex-row md:items-center",children:[(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)("div",{className:"grid h-10 w-10 place-items-center rounded-xl bg-gradient-to-br from-indigo-600 to-fuchsia-600 text-white shadow-[0_10px_22px_rgba(99,102,241,.22)]",children:(0,l.jsx)(d.Z,{className:"h-5 w-5"})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsx)("div",{className:"text-sm font-semibold",children:"Mantenimiento"}),(0,l.jsx)("div",{className:"text-xs text-neutral-500",children:"Solo Superadmin"})]})]}),(0,l.jsx)("div",{className:"ml-auto",children:(0,l.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-50 px-2 py-0.5 text-xs font-semibold text-emerald-700 ring-1 ring-emerald-100",children:[(0,l.jsx)(c.Z,{className:"h-3.5 w-3.5"})," Auditoria"]})})]}),(0,l.jsx)("div",{className:"h-1 w-full bg-gradient-to-r from-indigo-500 via-fuchsia-500 to-emerald-500"})]}),(0,l.jsx)(Z,{})]})]})}var W=!0;function Y(){let{loading:e}=(0,i.Z)(),t=(0,s.useRouter)(),{isSuperadmin:a,loading:r}=(0,o.Z)();return((0,n.useEffect)(()=>{e||r||a||(k.Am.error("Acceso restringido"),t.replace("/dashboard"))},[e,r,a,t]),e||r||!a)?(0,l.jsx)("div",{className:"p-6 text-sm text-slate-500",children:"Verificando acceso..."}):(0,l.jsx)(Q,{})}Y.getLayout=function(e){return(0,l.jsx)(r.Z,{children:e})}}},function(e){e.O(0,[7518,8735,482,1428,6217,2888,9774,179],function(){return e(e.s=3065)}),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.