PageSourceSearch

https://clubbolivar.com/assets/PaymentAuditTab-C5bENCcY.js

js clubbolivar.com collected 2026-09-24 23:41:09 UTC 38,020 bytes, 17 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/App-BsV2Qj_s.js","assets/index-C86y2ZZw.js","assets/index-Dt1MFC1X.css","assets/client-DMrl-iUj.js"])))=>i.map(i=>d[i]);
2import{j as e,r as y,_ as se}from"./index-C86y2ZZw.js";import{E as Ce}from"./jspdf.es.min-gEygcNRL.js";import{H as me,w as ue,r as Se,t as Le,i as v,d as N,a9 as Y,ap as q,a6 as R,f as g,B as p,G as Te,az as xe,h as S,u as Fe,v as Ee,aG as V,ah as Me,aM as De,ao as A,bL as U,bM as z,bN as $,C as te,cs as re,a8 as Oe,av as Pe}from"./App-BsV2Qj_s.js";import{s as qe}from"./client-DMrl-iUj.js";import{T as G,a as Q,b as w,c as f,d as J,e as j}from"./table-CY4dzb33.js";import{S as pe}from"./SliderOver-Bz7DfWSc.js";import{M as ae}from"./MultiSelectFilter-C9Onx-DA.js";import{T as W,a as K,b as L,c as M}from"./tabs-CCb_Hfd7.js";import{C as he}from"./copy-DChoOhGz.js";import{S as be}from"./server-DiMOpJdc.js";import{A as Z}from"./activity-D_baHP_K.js";import{H as Re}from"./hash-B7qdrpFk.js";import{D as ne}from"./download-Bzf4CL-Y.js";import{Q as Ie}from"./qr-code-CuDlW3Q3.js";import{S as He}from"./sliders-horizontal-Fgp7zIN1.js";/**
3 * @license lucide-react v0.462.0 - ISC
4 *
5 * This source code is licensed under the ISC license.
6 * See the LICENSE file in the root directory of this source tree.
7 */const X=me("FileCode2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/**
8 * @license lucide-react v0.462.0 - ISC
9 *
10 * This source code is licensed under the ISC license.
11 * See the LICENSE file in the root directory of this source tree.
12 */const ge=me("Webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]),Be='<svg width="60" height="69" viewBox="0 0 60 69" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M59.8419 11.0863L59.7635 9.19796L57.8818 9.01903C49.5511 8.22604 39.2606 4.98166 31.0254 0.552363L29.9993 0.000244141L28.9728 0.552363C20.7369 4.98166 10.4462 8.22604 2.11638 9.01903L0.234921 9.19796L0.156537 11.0863C-0.283148 21.6805 -0.127521 35.2781 5.01889 46.4804L5.02894 46.5017C10.5778 58.2449 21.2052 64.7771 29.143 68.1895L29.9989 68.5569L30.8547 68.1895C38.7923 64.7769 49.4197 58.2447 54.9688 46.5017L54.979 46.4804C60.1255 35.2781 60.2831 21.6807 59.8421 11.0863" fill="#1367A3"/><path d="M30.1997 2.09078L30.0009 1.98383L29.8016 2.09078C21.3745 6.62336 10.8301 9.94431 2.28252 10.7581L1.91734 10.7931L1.90226 11.1589C1.57821 18.9761 1.58003 28.4492 3.72178 37.2886L46.6847 8.63371C41.0172 7.06648 35.231 4.79744 30.1988 2.09055" fill="white"/><path d="M11.2837 53.144C16.7825 59.8988 24.0457 64.0975 29.8339 66.5855L30 66.657L30.1659 66.5855C37.8268 63.2926 48.075 57.0052 53.3933 45.7523C56.7881 38.3609 57.9401 29.8293 58.194 21.8553L11.2821 53.1429L11.2837 53.144Z" fill="white"/><path d="M13.3658 53.4342C18.4288 59.1538 24.785 62.8476 30 65.1341C37.3937 61.8926 47.0871 55.826 52.1231 45.1691C55.0417 38.8145 56.2579 31.5535 56.6726 24.549L13.3647 53.4324L13.3658 53.4342Z" fill="#8DD8F8"/></svg>';async function Ae(){return new Promise(s=>{const t=new Image,l=new Blob([Be],{type:"image/svg+xml"}),r=URL.createObjectURL(l);t.onload=()=>{const o=document.createElement("canvas");o.width=120,o.height=138,o.getContext("2d").drawImage(t,0,0,120,138),URL.revokeObjectURL(r),s(o.toDataURL("image/png"))},t.src=r})}async function Ue(s){const t=new Ce({orientation:"portrait",unit:"mm",format:[80,200]}),l=await Ae(),r=80,o=6,u=r-o*2;let a=8;t.addImage(l,"PNG",r/2-8,a,16,18),a+=22,t.setFontSize(10),t.setFont("helvetica","bold"),t.text("CLUB BOLÍVAR",r/2,a,{align:"center"}),a+=4,t.setFontSize(7),t.setFont("helvetica","normal"),t.text("La Paz - Bolivia",r/2,a,{align:"center"}),a+=3,t.text("NIT: 1020713022",r/2,a,{align:"center"}),a+=5,t.setDrawColor(200),t.setLineDashPattern([1,1],0),t.line(o,a,r-o,a),a+=4,t.setFontSize(9),t.setFont("helvetica","bold"),t.text("RECIBO DE PAGO",r/2,a,{align:"center"}),a+=5,t.setFontSize(7),t.setFont("helvetica","normal");const b=(c,_)=>{t.setFont("helvetica","bold"),t.text(c,o,a),t.setFont("helvetica","normal");const k=t.splitTextToSize(_,u-24);t.text(k,o+24,a),a+=k.length*3.5};b("Recibo #:",s.receiptNumber),b("Fecha:",s.date),a+=1,t.line(o,a,r-o,a),a+=4,b("Cliente:",s.clientName),b("Concepto:",s.concept),s.invoiceNumber&&b("Factura:",s.invoiceNumber),s.installmentInfo&&b("Plan:",s.installmentInfo),b("Método:",s.paymentMethod),a+=2,t.line(o,a,r-o,a),a+=5,t.setFontSize(11),t.setFont("helvetica","bold"),t.text("TOTAL",o,a),t.text(`${s.currency} ${s.amount.toFixed(2)}`,r-o,a,{align:"right"}),a+=6,t.line(o,a,r-o,a),a+=5,t.setFontSize(6),t.setFont("helvetica","normal"),t.text("Este recibo es un comprobante de pago",r/2,a,{align:"center"}),a+=3,t.text("válido emitido por Club Bolívar.",r/2,a,{align:"center"}),a+=3,t.text("Conserve este documento.",r/2,a,{align:"center"}),t.save(`recibo-${s.receiptNumber||"pago"}.pdf`)}function ze({text:s,label:t}){return e.jsxs(v,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs gap-1 text-muted-foreground hover:text-foreground",onClick:l=>{l.stopPropagation(),navigator.clipboard.writeText(s),ue.success(`${t} copiado`)},children:[e.jsx(he,{className:"h-3 w-3"}),"Copiar"]})}
12function le({data:s,title:t,defaultExpanded:l=!0}){const[r,o]=y.useState(l);let u=s;if(typeof s=="string")try{u=JSON.parse(s)}catch{u=s}const a=typeof u=="string"?u:JSON.stringify(u,null,2);return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("button",{type:"button",className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors",onClick:()=>o(!r),children:[r?e.jsx(Se,{className:"h-3.5 w-3.5"}):e.jsx(Le,{className:"h-3.5 w-3.5"}),t,e.jsxs("span",{className:"text-muted-foreground/60 ml-1",children:["(",typeof u=="object"&&u?`${Object.keys(u).length} keys`:`${a.length} chars`,")"]})]}),e.jsx(ze,{text:a,label:t})]}),r&&e.jsx("pre",{className:"bg-background/80 text-foreground border border-border/40 p-4 rounded-xl text-xs font-mono whitespace-pre-wrap break-words max-h-[300px] overflow-auto",children:a})]})}function P({label:s,value:t}){const l=r=>{r.stopPropagation(),navigator.clipboard.writeText(t),ue.success(`${s} copiado`)};return e.jsxs("div",{className:"flex items-center gap-1 text-xs group",children:[e.jsxs("span",{className:"text-muted-foreground",children:[s,":"]}),e.jsx("span",{className:"font-mono text-foreground truncate max-w-[120px]",title:t,children:t.length>12?t.slice(0,12)+"...":t}),e.jsx("button",{onClick:l,className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-secondary rounded transition-opacity",title:"Copiar",children:e.jsx(he,{className:"h-3 w-3 text-muted-foreground"})})]})}const $e={generacion_deuda:e.jsx(be,{className:"h-4 w-4"}),callback_recibido:e.jsx(ge,{className:"h-4 w-4"}),cybersource_payment:e.jsx(xe,{className:"h-4 w-4"})};function Ve(s){return s==="success"?"bg-emerald-500":s==="error"?"bg-destructive":"bg-amber-500"}function oe({data:s,title:t}){const l=Object.entries(s).filter(([,r])=>r!=null&&r!=="");return l.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Sin datos"}):e.jsxs("div",{className:"space-y-2",children:[t&&e.jsx("h5",{className:"text-[10px] font-semibold text-muted-foreground uppercase tracking-wider",children:t}),e.jsx("div",{className:"rounded-xl border border-border/30 overflow-hidden",children:e.jsxs(G,{children:[e.jsx(Q,{children:e.jsxs(w,{className:"bg-secondary/40 border-border/20",children:[e.jsx(f,{className:"text-xs text-muted-foreground w-[40%]",children:"Clave"}),e.jsx(f,{className:"text-xs text-muted-foreground",children:"Valor"})]})}),e.jsx(J,{children:l.map(([r,o])=>e.jsxs(w,{className:"border-border/20",children:[e.jsx(j,{className:"text-xs font-mono text-muted-foreground py-2",children:r}),e.jsx(j,{className:"text-xs font-mono text-foreground py-2 break-all",children:typeof o=="object"?JSON.stringify(o):String(o)})]},r))})]})})]})}function Ge({step:s,open:t,onClose:l}){var u;if(!s)return null;const r=s.status==="success"?e.jsx(Y,{className:"h-5 w-5 text-emerald-400"}):s.status==="error"?e.jsx(q,{className:"h-5 w-5 text-destructive"}):e.jsx(R,{className:"h-5 w-5 text-amber-400"}),o=s.type==="callback_recibido";return e.jsx(pe,{open:t,onClose:l,title:s.label,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-xl bg-secondary/60 border border-border/30",children:[r,e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:s.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:g(new Date(s.timestamp),"dd 'de' MMMM, yyyy HH:mm:ss",{locale:S})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.method&&e.jsx(p,{variant:"outline",className:"text-[10px] border-border/50",children:s.method}),s.httpStatus&&e.jsxs(p,{variant:"outline",className:"text-[10px] border-border/50",children:["HTTP ",s.httpStatus]}),s.duration!==null&&s.duration>0&&e.jsxs(p,{className:"text-[10px] bg-secondary text-muted-foreground border-0",children:[s.duration,"ms"]})]})]}),s.errorMessage&&e.jsx("div",{className:"p-3 rounded-xl bg-destructive/10 border border-destructive/20",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(q,{className:"h-4 w-4 text-destructive mt-0.5 shrink-0"}),e.jsx("p",{className:"text-xs text-foreground",children:s.errorMessage})]})}),o?e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mb-1",children:"Tipo"}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:"callback_recibido"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mb-1",children:"Estado"}),e.jsx(p,{className:N("text-xs border-0",s.status==="success"&&"bg-emerald-500/10 text-emerald-400",s.status==="error"&&"bg-destructive/10 text-destructive",s.status==="pending"&&"bg-amber-500/10 text-amber-400"),children:s.status==="success"?"Exitoso":s.status==="error"?"Error":"Pendiente"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mb-1",children:"HTTP Status"}),e.jsx("p",{className:"text-sm font-mono font-bold text-foreground",children:s.httpStatus||200})]})]}),e.jsxs(W,{defaultValue:"envio",className:"w-full",children:[e.jsxs(K,{className:"w-full bg-secondary/60 border border-border/30",children:[e.jsx(L,{value:"envio",className:"flex-1 text-xs",children:"Envío"}),e.jsx(L,{value:"response",className:"flex-1 text-xs",children:"Response"})]}),e.jsxs(M,{value:"envio",className:"mt-3 space-y-4",children:[s.callbackUrl&&e.jsxs("div",{className:"rounded-xl border border-primary/20 bg-primary/5 p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ge,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"Endpoint URL Completa (GET)"})]}),e.jsx("button",{className:"text-xs text-primary hover:underline flex items-center gap-1",onClick:()=>{navigator.clipboard.writeText(s.callbackUrl||""),se(()=>import("./App-BsV2Qj_s.js").then(a=>a.dN),__vite__mapDeps([0,1,2,3])).then(a=>a.toast.success("URL copiada"))},children:"📋 Copiar"})]}
12),e.jsx("pre",{className:"text-xs font-mono text-foreground/80 whitespace-pre-wrap break-all bg-background/60 rounded-lg p-3 border border-border/20 max-h-[200px] overflow-auto",children:s.callbackUrl})]}),s.request&&typeof s.request=="object"&&Object.keys(s.request).length>0&&!s.request._note&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("span",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:["GET Parameters (",Object.keys(s.request).length,")"]})}),e.jsx(oe,{data:s.request,title:""})]})]}),e.jsx(M,{value:"response",className:"mt-3",children:s.response&&typeof s.response=="object"&&Object.keys(s.response).length>0&&!s.response._note?e.jsx(oe,{data:s.response,title:"Response Data"}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"Sin datos de response"})})]}),((u=s.request)==null?void 0:u._note)&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:s.request._note})]}):e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mb-1",children:"Tipo"}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:s.type})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mb-1",children:"Estado"}),e.jsx(p,{className:N("text-xs border-0",s.status==="success"&&"bg-emerald-500/10 text-emerald-400",s.status==="error"&&"bg-destructive/10 text-destructive",s.status==="pending"&&"bg-amber-500/10 text-amber-400"),children:s.status==="success"?"Exitoso":s.status==="error"?"Error":"Pendiente"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mb-1",children:"HTTP Status"}),e.jsx("p",{className:"text-sm font-mono font-bold text-foreground",children:s.httpStatus||200})]})]}),e.jsxs(W,{defaultValue:"envio",className:"w-full",children:[e.jsxs(K,{className:"w-full bg-secondary/60 border border-border/30",children:[e.jsx(L,{value:"envio",className:"flex-1 text-xs",children:"Envío"}),e.jsx(L,{value:"response",className:"flex-1 text-xs",children:"Response"})]}),e.jsxs(M,{value:"envio",className:"mt-3 space-y-4",children:[e.jsxs("div",{className:"rounded-xl border border-primary/20 bg-primary/5 p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:["Endpoint URL Completa (",s.method||"POST",")"]})]}),e.jsx("button",{className:"text-xs text-primary hover:underline flex items-center gap-1",onClick:()=>{navigator.clipboard.writeText("https://api.libelula.bo/rest/deuda/registrar"),se(()=>import("./App-BsV2Qj_s.js").then(a=>a.dN),__vite__mapDeps([0,1,2,3])).then(a=>a.toast.success("URL copiada"))},children:"📋 Copiar"})]}),e.jsx("pre",{className:"text-xs font-mono text-foreground/80 whitespace-pre-wrap break-all bg-background/60 rounded-lg p-3 border border-border/20",children:"https://api.libelula.bo/rest/deuda/registrar"})]}),s.request&&Object.keys(s.request).length>0?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"POST Body (JSON)"})]}),e.jsx(le,{data:s.request,title:`Request Body  (${typeof s.request=="object"?Object.keys(s.request).length+" keys":""})`})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No hay datos de request"})]}),e.jsx(M,{value:"response",className:"mt-3 space-y-4",children:s.response&&(typeof s.response=="string"?s.response:Object.keys(s.response).length>0)?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"Response Body (JSON)"})]}),e.jsx(le,{data:s.response,title:`Response Body  (${typeof s.response=="object"?Object.keys(s.response).length+" keys":""})`})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No hay datos de response"})})]})]})]})})}function Qe({steps:s}){const[t,l]=y.useState(null);return s.length===0?e.jsx("div",{className:"text-center py-6 text-muted-foreground text-sm",children:"No hay pasos registrados"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-2 py-4 px-3 bg-secondary/40 border border-border/30 rounded-xl overflow-x-auto",children:s.map((r,o)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>l(r),className:N("relative flex flex-col items-center gap-1.5 p-3 rounded-xl border transition-all duration-200","hover:scale-105 hover:shadow-lg cursor-pointer min-w-[100px]","bg-card border-border/40 hover:border-primary/40",(t==null?void 0:t.id)===r.id&&"ring-2 ring-primary/50 border-primary/50"),children:[e.jsxs("div",{className:N("absolute -top-1.5 -right-1.5 h-4 w-4 roun
12ded-full border-2 border-card flex items-center justify-center",Ve(r.status)),children:[r.status==="success"&&e.jsx(Y,{className:"h-2.5 w-2.5 text-white"}),r.status==="error"&&e.jsx(q,{className:"h-2.5 w-2.5 text-white"}),r.status==="pending"&&e.jsx(R,{className:"h-2.5 w-2.5 text-white"})]}),e.jsx("div",{className:N("p-2 rounded-lg",r.status==="success"&&"bg-emerald-500/10 text-emerald-400",r.status==="error"&&"bg-destructive/10 text-destructive",r.status==="pending"&&"bg-amber-500/10 text-amber-400"),children:$e[r.type]||e.jsx(X,{className:"h-4 w-4"})}),e.jsx("span",{className:"text-xs font-medium text-foreground text-center max-w-[90px] line-clamp-2",children:r.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:g(new Date(r.timestamp),"HH:mm:ss")}),r.duration!==null&&r.duration>0&&e.jsxs(p,{className:"text-[10px] px-1.5 py-0 bg-secondary text-muted-foreground border-0",children:[r.duration,"ms"]})]}),o<s.length-1&&e.jsx(Te,{className:N("h-5 w-5 shrink-0",r.status==="success"?"text-emerald-500/60":r.status==="error"?"text-destructive/60":"text-amber-500/60")})]},r.id))}),e.jsx("p",{className:"text-[11px] text-muted-foreground/60 text-center",children:"Haz clic en cualquier paso para ver request/response"})]}),e.jsx(Ge,{step:t,open:!!t,onClose:()=>l(null)})]})}function ce({flow:s}){return s.payment_id?s.invoice_status==="paid"&&(s.payment_status==="completed"||s.has_callback)?e.jsxs(p,{className:"bg-emerald-500/10 text-emerald-400 border-0 gap-1",children:[e.jsx(Y,{className:"h-3 w-3"}),"Completado"]}):s.payment_status==="failed"||s.invoice_status==="cancelled"?e.jsxs(p,{className:"bg-destructive/10 text-destructive border-0 gap-1",children:[e.jsx(q,{className:"h-3 w-3"}),"Error"]}):s.has_callback&&s.invoice_status!=="paid"?e.jsxs(p,{className:"bg-amber-500/10 text-amber-400 border-0 gap-1",children:[e.jsx(R,{className:"h-3 w-3"}),"Pendiente"]}):e.jsxs(p,{className:"bg-amber-500/10 text-amber-400 border-0 gap-1",children:[e.jsx(R,{className:"h-3 w-3"}),"En Proceso"]}):e.jsxs(p,{className:"bg-primary/10 text-primary border-0 gap-1",children:[e.jsx(V,{className:"h-3 w-3"}),"Solo Deuda"]})}function ie(s){var r;const t=s.reference_type;if(t==="membership")return"Sociedad";if(t==="subscription")return"Abono";if(t==="ticketing")return"Entrada";const l=((r=s.concept)==null?void 0:r.toLowerCase())||"";return l.includes("socied")||l.includes("membres")?"Sociedad":l.includes("abono")?"Abono":l.includes("entrada")?"Entrada":"Otro"}function de(s){return s.cybersource_transaction_id||s.payment_method==="cybersource"?e.jsxs(p,{className:"bg-violet-500/10 text-violet-400 border-0 gap-1 whitespace-nowrap text-[10px]",children:[e.jsx(xe,{className:"h-3 w-3"}),"Tarjeta"]}):s.payment_method==="qr"||s.payment_method==="libelula_qr"?e.jsxs(p,{className:"bg-primary/10 text-primary border-0 gap-1 whitespace-nowrap text-[10px]",children:[e.jsx(Ie,{className:"h-3 w-3"}),"QR"]}):s.payment_id?e.jsxs(p,{className:"bg-primary/10 text-primary border-0 gap-1 whitespace-nowrap text-[10px]",children:[e.jsx(Z,{className:"h-3 w-3"}),"Pasarela"]}):null}function Je(s){const t=[],l=s.payment_metadata||{},r=l.libelula_request||null,o=l.libelula_response||null;if(t.push({id:`${s.id}-debt`,type:"generacion_deuda",label:"Generación de Deuda",status:"success",timestamp:s.invoice_created_at,duration:null,request:r||null,response:o||null,errorMessage:null,method:"POST"}),!s.payment_id)return t;if(s.cybersource_transaction_id||s.payment_method==="cybersource")t.push({id:`${s.id}-cybersource`,type:"cybersource_payment",label:"Pago CyberSource",status:s.payment_status==="completed"?"success":s.payment_status==="failed"?"error":"pending",timestamp:s.payment_date||s.invoice_created_at,duration:null,request:l.cybersource_request||{transaction_id:s.cybersource_transaction_id},response:l.cybersource_response||{status:s.payment_status},errorMessage:s.payment_status==="failed"?"Pago rechazado por CyberSource":null,method:"POST",httpStatus:s.payment_status==="completed"?200:s.payment_status==="failed"?400:null});else{l.webhook_payload;const u=l.webhook_query||null,a=l.webhook_response||null,b=s.has_callback?s.payment_status==="completed"?"success":s.payment_status==="failed"?"error":"pending":"pending";let c="";if(u&&Object.keys(u).length>0){const _=new URLSearchParams;Object.entries(u).forEach(([k,I])=>_.set(k,String(I))),c=`/libelula-webhook?${_.toString()}`}t.push({id:`${s.id}-callback`,type:"callback_recibido",label:"Callback Pasarela",status:b,timestamp:s.payment_date||s.invoice_created_at,duration:null,request:u||{_note:"Callback aún no recibido"},response:a||{success:!0,payment_id:s.payment_id,status:s.payment_status},errorMessage:b==="error"?"Callback con error":null,method:"GET",httpStatus:s.has_callback?200:null,callbackUrl:c||void 0})}return t}function E(s){return s.payment_id?s.invoice_status==="paid"&&(s.payment_status==="completed"||s.has_callback)?"completed":s.payment_status==="failed"||s.invoice_status==="cancelled"?"error":"pending":"debt_only"}function We(s){var r;const t=s.payment_metadata;if((r=t==null?void 0:t.libelula_request)!=null&&r.lineas_detalle_deuda)return t.libelula_request.lineas_detalle_deuda.map(o=>({name:o.concepto||"Item",qty:o.cantidad||1,price:o.costo_unitario||0}));const l=s.invoice_metadata;return l!=null&&l.items&&Array.isArray(l.items)?l.items:l!=null&&l.membership_name||l!=null&&l.subscription_name?[{name:l.membership_name||l.subscription_name||s.concept,qty:1,price:s.invoice_total}]:[{name:s.concept,qty:1,price:s.invoice_total}]}function ms(){const[s,t]=y.useState([]),[l,r]=y.useState([]),[o,u]=y.useState(),[a,b]=y.useState(),[c,_]=y.useState(null),[k,I]=y.useState("full"),{data:T=[],isLoading:je}=Fe({queryKey:["payment-audit-flows",s,o,a],queryFn:async()=>{let n=qe.from("member_invoices").select(`
13          id, invoice_number, total, status, created_at, currency, concept,
14          reference_type, family_profile_id, metadata,
15          profile:family_profiles!member_invoices_family_profile_id_fkey(full_name, first_name, last_name),
16          payments:member_payments(id, status, payment_date, payment_method_type, libelula_status, libelula_transaction_id, cybersource_transaction_id, metadata)
17        `).eq("is_deleted",!1).order("created_at",{ascending:!1}).limit(300);if(o&&(n=n.gte("created_at",o.toISOString())),a){const d=new Date(a);d.setHours(23,59,59,999),n=n.lte("created_at",d.toISOString())}const{data:m,error:x}=await n;if(x)throw x;return(m||[]).filter(d=>{var C;if(s.length===0)return!0;const i=d.reference_type||"",h=((C=d.concept)==null?void 0:C.toLowerCase())||"";return!!(s.includes("membership")&&(i==="membership"||h.includes("socied"))||s.includes("subscription")&&(i==="subscription"||h.includes("abono"))||s.includes("ticketing")&&(i==="ticketing"||h.includes("entrada")))}).map(d=>{var ee;const i=(ee=d.payments)==null?void 0:ee[0],h=d.profile,C=(h==null?void 0:h.full_name)||`${(h==null?void 0:h.first_name)||""} ${(h==null?void 0:h.last_name)||""}`.trim()||"—",O=(i==null?void 0:i.libelula_status)&&i.libelula_status!=="pending"&&i.libelula_status!=="created";return{id:d.id,profile_id:d.family_profile_id,profile_name:C,invoice_number:d.invoice_number,invoice_total:d.total,invoice_status:d.status,invoice_created_at:d.created_at,currency:d.currency,concept:d.concept,reference_type:d.reference_type,payment_id:(i==null?void 0:i.id)||null,payment_status:(i==null?void 0:i.status)||null,payment_date:(i==null?void 0:i.payment_date)||null,payment_method:(i==null?void 0:i.payment_method_type)||null,libelula_status:(i==null?void 0:i.libelula_status)||null,libelula_transaction_id:(i==null?void 0:i.libelula_transaction_id)||null,cybersource_transaction_id:(i==null?void 0:i.cybersource_transaction_id)||null,has_callback:!!O,payment_metadata:(i==null?void 0:i.metadata)||null,invoice_metadata:d.metadata||null}})}}),{fullFlows:H,debtOnlyFlows:B}=y.useMemo(()=>{const n=[],m=[];return T.forEach(d=>{E(d)==="debt_only"?m.push(d):n.push(d)}),{fullFlows:(d=>l.length===0?d:d.filter(i=>l.includes(E(i))))(n),debtOnlyFlows:m}},[T,l]),F=y.useMemo(()=>{const n=T.filter(m=>m.payment_id);return{total:n.length,completed:n.filter(m=>E(m)==="completed").length,pending:n.filter(m=>E(m)==="pending").length,error:n.filter(m=>E(m)==="error").length,debtOnly:T.filter(m=>!m.payment_id).length}},[T]),ye={membership:"Sociedades",subscription:"Abonos",ticketing:"Entradas"},fe={completed:"Completados",pending:"Pendientes",error:"Con Error"},D=y.useMemo(()=>{const n=[];
17return s.forEach(m=>n.push({key:"module",label:"Tipo",value:m,displayValue:ye[m]||m,onRemove:()=>t(x=>x.filter(d=>d!==m))})),l.forEach(m=>n.push({key:"flow",label:"Estado",value:m,displayValue:fe[m]||m,onRemove:()=>r(x=>x.filter(d=>d!==m))})),o&&n.push({key:"dateFrom",label:"Desde",value:"from",displayValue:g(o,"dd/MM/yyyy"),onRemove:()=>u(void 0)}),a&&n.push({key:"dateTo",label:"Hasta",value:"to",displayValue:g(a,"dd/MM/yyyy"),onRemove:()=>b(void 0)}),n},[s,l,o,a]),Ne=()=>e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-4",children:[e.jsxs(U,{children:[e.jsx(z,{asChild:!0,children:e.jsxs(v,{variant:"outline",size:"sm",className:"h-9 gap-2 border-border/40 bg-card text-xs font-display tracking-wider",children:[e.jsx(He,{className:"h-3.5 w-3.5"}),"FILTROS",D.length>0&&e.jsx(p,{variant:"secondary",className:"ml-1 h-5 min-w-5 px-1 text-[10px] font-bold",children:D.length})]})}),e.jsxs($,{className:"w-80 p-4 space-y-4",align:"start",children:[e.jsx(ae,{label:"Tipo",options:[{value:"membership",label:"Sociedades"},{value:"subscription",label:"Abonos"},{value:"ticketing",label:"Entradas"}],selected:s,onChange:t,placeholder:"Todos los tipos"}),e.jsx(ae,{label:"Estado Flujo",options:[{value:"completed",label:"Completados"},{value:"pending",label:"Pendientes"},{value:"error",label:"Con Error"}],selected:l,onChange:r,placeholder:"Todos los estados"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Desde"}),e.jsxs(U,{children:[e.jsx(z,{asChild:!0,children:e.jsxs(v,{variant:"outline",size:"sm",className:N("w-full h-9 justify-start text-sm gap-2 bg-card border-border/40",!o&&"text-muted-foreground"),children:[e.jsx(te,{className:"h-3.5 w-3.5"}),o?g(o,"dd/MM/yyyy"):"Seleccionar fecha"]})}),e.jsx($,{className:"w-auto p-0",align:"start",children:e.jsx(re,{mode:"single",selected:o,onSelect:u,initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Hasta"}),e.jsxs(U,{children:[e.jsx(z,{asChild:!0,children:e.jsxs(v,{variant:"outline",size:"sm",className:N("w-full h-9 justify-start text-sm gap-2 bg-card border-border/40",!a&&"text-muted-foreground"),children:[e.jsx(te,{className:"h-3.5 w-3.5"}),a?g(a,"dd/MM/yyyy"):"Seleccionar fecha"]})}),e.jsx($,{className:"w-auto p-0",align:"start",children:e.jsx(re,{mode:"single",selected:a,onSelect:b,initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]})]})]}),D.map(n=>e.jsxs(p,{variant:"secondary",className:"gap-1 pl-2 pr-1 py-1 text-xs",children:[e.jsxs("span",{className:"text-muted-foreground",children:[n.label,":"]})," ",n.displayValue,e.jsx("button",{onClick:n.onRemove,className:"ml-0.5 rounded-full hover:bg-muted p-0.5",children:e.jsx(Oe,{className:"h-3 w-3"})})]},`${n.key}-${n.value}`)),D.length>0&&e.jsx(v,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground",onClick:()=>{t([]),r([]),u(void 0),b(void 0)},children:"Limpiar filtros"})]}),ve=()=>e.jsx("div",{className:"flex flex-wrap gap-3 mb-4",children:[{label:"Total",value:F.total,cls:"text-foreground"},{label:"Completados",value:F.completed,cls:"text-emerald-400"},{label:"Pendientes",value:F.pending,cls:"text-amber-400"},{label:"Errores",value:F.error,cls:"text-destructive"},{label:"Solo Deuda",value:F.debtOnly,cls:"text-primary"}].map(n=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-xl bg-card border border-border/30",children:[e.jsx("span",{className:N("text-lg font-bold font-mono",n.cls),children:n.value}),e.jsx("span",{className:"text-xs text-muted-foreground",children:n.label})]},n.label))}),_e=n=>e.jsxs(w,{className:"cursor-pointer hover:bg-secondary/50 transition-colors border-border/20",onClick:()=>_(n),children:[e.jsx(j,{children:e.jsx(ce,{flow:n})}),e.jsx(j,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[de(n),e.jsx(p,{variant:"outline",className:"text-[10px] w-fit border-border/40",children:ie(n)})]})}),e.jsx(j,{children:e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("div",{className:"font-medium text-foreground text-sm",children:n.profile_name}),e.jsx("div",{className:"text-xs text-muted-foreground font-mono",children:n.invoice_number})]})}),e.jsx(j,{className:"text-right",children:e.jsxs("span",{className:"font-medium font-mono text-foreground",translate:"no",children:[n.invoice_total.toLocaleStr
17ing("es-BO")," ",n.currency]})}),e.jsxs(j,{children:[e.jsx("div",{className:"text-sm text-foreground",children:g(new Date(n.invoice_created_at),"dd/MM/yy",{locale:S})}),e.jsx("div",{className:"text-xs text-muted-foreground",children:g(new Date(n.invoice_created_at),"HH:mm:ss",{locale:S})})]}),e.jsx(j,{children:e.jsx(v,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",children:e.jsx(Pe,{className:"h-4 w-4"})})})]},n.id),we=({flow:n})=>{const m=We(n);return e.jsx("div",{className:"rounded-xl border border-border/30 overflow-hidden",children:e.jsxs(G,{children:[e.jsx(Q,{children:e.jsxs(w,{className:"bg-secondary/40 border-border/20",children:[e.jsx(f,{className:"text-xs text-muted-foreground",children:"Item"}),e.jsx(f,{className:"text-xs text-muted-foreground text-center w-[60px]",children:"Cant."}),e.jsx(f,{className:"text-xs text-muted-foreground text-right w-[100px]",children:"Precio"})]})}),e.jsx(J,{children:m.map((x,d)=>e.jsxs(w,{className:"border-border/20",children:[e.jsx(j,{className:"text-sm text-foreground",children:x.name}),e.jsx(j,{className:"text-sm text-center text-muted-foreground",children:x.qty}),e.jsxs(j,{className:"text-sm text-right font-mono text-foreground",children:[(x.price||0).toLocaleString("es-BO")," ",n.currency]})]},d))})]})})},ke=n=>n.invoice_status==="paid"&&(n.payment_status==="completed"||n.has_callback);return e.jsxs(e.Fragment,{children:[e.jsx(Ne,{}),e.jsx(ve,{}),je?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(Ee,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs(W,{value:k,onValueChange:I,className:"w-full",children:[e.jsxs(K,{className:"mb-4 bg-secondary/60 border border-border/30",children:[e.jsxs(L,{value:"full",className:"text-xs gap-1.5",children:[e.jsx(Z,{className:"h-3.5 w-3.5"}),"Flujos Completos (",H.length,")"]}),e.jsxs(L,{value:"debt",className:"text-xs gap-1.5",children:[e.jsx(V,{className:"h-3.5 w-3.5"}),"Solo Deuda (",B.length,")"]})]}),["full","debt"].map(n=>e.jsx(M,{value:n,children:e.jsx("div",{className:"bg-card border border-border/30 rounded-xl overflow-hidden",children:e.jsxs(G,{children:[e.jsx(Q,{children:e.jsxs(w,{className:"bg-secondary/40 border-border/20",children:[e.jsx(f,{className:"w-[130px]",children:"Estado"}),e.jsx(f,{className:"w-[110px]",children:"Tipo"}),e.jsx(f,{children:"Cliente"}),e.jsx(f,{className:"text-right",children:"Monto"}),e.jsx(f,{children:"Fecha"}),e.jsx(f,{className:"w-[50px]"})]})}),e.jsx(J,{children:(n==="full"?H:B).length===0?e.jsx(w,{children:e.jsx(j,{colSpan:6,className:"h-32 text-center",children:e.jsxs("div",{className:"flex flex-col items-center justify-center text-muted-foreground",children:[n==="full"?e.jsx(Z,{className:"h-8 w-8 mb-2 opacity-30"}):e.jsx(V,{className:"h-8 w-8 mb-2 opacity-30"}),e.jsx("p",{children:"No hay registros"})]})})}):(n==="full"?H:B).map(_e)})]})})},n))]}),e.jsx(pe,{open:!!c,onClose:()=>_(null),title:"Detalle del Flujo de Pago",className:"sm:max-w-xl",children:c&&(()=>{const n=Je(c),m=ke(c),x=c.payment_metadata||{};return x.webhook_query,x.webhook_payload,e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx(ce,{flow:c}),de(c),e.jsx(p,{variant:"outline",className:"text-xs border-border/40",children:ie(c)})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-[10px] font-semibold text-muted-foreground uppercase tracking-wider",children:"Cliente"}),e.jsxs("div",{className:"bg-secondary/40 border border-border/20 rounded-xl p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Me,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:c.profile_name})]}),e.jsx(P,{label:"Profile ID",value:c.profile_id})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-[10px] font-semibold text-muted-foreground uppercase tracking-wider",children:"Documento"}),e.jsxs("div",{className:"bg-secondary/40 border border-border/20 rounded-xl p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm font-mono font-medium text-foreground",children:c.invoice_number})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm text-foreground",children:c.concept})]}),e.jsxs("div",{className:"text-sm font-mono font-bold text-primary",children:[c.currency," ",c.invoice_total.toLocaleStr
17ing("es-BO")]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:g(new Date(c.invoice_created_at),"dd 'de' MMMM, yyyy HH:mm:ss",{locale:S})})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-[10px] font-semibold text-muted-foreground uppercase tracking-wider",children:"Items de la Deuda"}),e.jsx(we,{flow:c})]}),(c.libelula_transaction_id||c.cybersource_transaction_id||c.payment_id)&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-[10px] font-semibold text-muted-foreground uppercase tracking-wider",children:"IDs de Transacción"}),e.jsxs("div",{className:"bg-secondary/40 border border-border/20 rounded-xl p-4 space-y-2",children:[c.payment_id&&e.jsx(P,{label:"Payment ID",value:c.payment_id}),c.libelula_transaction_id&&e.jsx(P,{label:"Libélula ID",value:c.libelula_transaction_id}),c.cybersource_transaction_id&&e.jsx(P,{label:"CyberSource ID",value:c.cybersource_transaction_id})]})]}),c.payment_id&&e.jsx("div",{className:"grid grid-cols-2 gap-3",children:[{label:"Estado Pago",value:c.payment_status||"—"},{label:"Método",value:c.payment_method||"—"},{label:"Estado Libélula",value:c.libelula_status||"—"},{label:"Fecha Pago",value:c.payment_date?g(new Date(c.payment_date),"dd/MM/yyyy HH:mm"):"—"}].map(d=>e.jsxs("div",{className:"bg-secondary/30 border border-border/20 rounded-lg p-3",children:[e.jsx(A,{className:"text-[10px] text-muted-foreground",children:d.label}),e.jsx("p",{className:"text-sm mt-0.5 text-foreground",children:d.value})]},d.label))}),m&&(()=>{const i=((x==null?void 0:x.webhook_query)||{}).invoice_url||(x==null?void 0:x.invoice_url),h=!!i,C=async()=>{var O;await Ue({receiptNumber:((O=c.payment_id)==null?void 0:O.slice(0,8))||"—",date:c.payment_date?g(new Date(c.payment_date),"dd/MM/yyyy HH:mm",{locale:S}):g(new Date,"dd/MM/yyyy HH:mm",{locale:S}),clientName:c.profile_name,concept:c.concept,amount:c.invoice_total,currency:c.currency,paymentMethod:c.payment_method||"—",invoiceNumber:c.invoice_number})};return e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-[10px] font-semibold text-muted-foreground uppercase tracking-wider",children:"Comprobante"}),h?e.jsxs(v,{variant:"outline",className:"w-full gap-2 h-11 rounded-xl border-border/40 hover:bg-primary/10 hover:text-primary hover:border-primary/30",onClick:()=>window.open(i,"_blank"),children:[e.jsx(ne,{className:"h-4 w-4"}),"Descargar Factura"]}):e.jsxs(v,{variant:"outline",className:"w-full gap-2 h-11 rounded-xl border-border/40 hover:bg-primary/10 hover:text-primary hover:border-primary/30",onClick:C,children:[e.jsx(ne,{className:"h-4 w-4"}),"Descargar Recibo"]})]})})(),e.jsxs("div",{children:[e.jsx("h4",{className:"text-[10px] font-semibold text-muted-foreground uppercase tracking-wider mb-4",children:"Flujo de la Transacción"}),e.jsx(Qe,{steps:n})]})]})})()})]})}export{ms as default};

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.