1import{b as i,h as Y,T as M,u as e}from"./vendor-core-HDji_sSf.js";import{X,L as z,n as Q,T as Z,h as ee,aN as ce,aO as ie,aP as I,ac as le,a1 as se,k as re,e as de,v as me,Y as pe,O as q,R as xe,f as ye}from"./vendor-icons-Bus6oV4w.js";const be={amount:"Lâimporto dichiarato dal provider non coincide con il pagamento registrato.",currency:"La valuta dichiarata dal provider non coincide con quella salvata internamente.",status:"Lo stato del provider non coincide con lo stato di pagamento interno.",reference:"Il riferimento della transazione del provider non coincide con quello registrato."},J=a=>JSON.stringify(a??{},null,2),B=a=>a==null||a===""?"Non disponibile":typeof a=="object"?JSON.stringify(a):String(a);async function he(a){const l=await fetch(`/api/admin/payments/discrepancies/${encodeURIComponent(a)}`,{credentials:"include"}),n=await l.json().catch(()=>null);if(!l.ok)throw new Error(n?.error||"Dettaglio discrepanza non disponibile");return n}function ue({recordId:a,onClose:l}){const[n,p]=i(null),[b,g]=i(null);Y(()=>{p(null),g(null),he(a).then(p).catch(o=>g(o instanceof Error?o.message:"Dettaglio non disponibile"))},[a]);const d=M(()=>n?.comparisons.filter(o=>o.different)||[],[n]),N=M(()=>n?{tenantId:n.database.tenantId,order:n.database.order,payment:n.database.payment}:{},[n]);return e("div",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:42",role:"dialog","aria-modal":"true","aria-labelledby":"payment-discrepancy-title",className:"fixed inset-0 z-50 flex items-center justify-center bg-[#0F2033]/60 p-4 backdrop-blur-sm",onMouseDown:l,children:e("section",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:43",className:"max-h-[92vh] w-full max-w-6xl overflow-y-auto rounded-3xl bg-[#F7F5F0] text-[#0F2033] shadow-2xl",onMouseDown:o=>o.stopPropagation(),children:[e("header",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:44",className:"sticky top-0 z-10 flex items-start justify-between gap-5 border-b border-[#0F2033]/10 bg-[#F7F5F0]/95 px-6 py-5 backdrop-blur",children:[e("div",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:44",children:[e("p",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:44",className:"text-xs font-black uppercase tracking-[.16em] text-[#E87A38]",children:"Confronto discrepanza"}),e("h2",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:44",id:"payment-discrepancy-title",className:"mt-1 text-2xl font-black",children:"Webhook e dati registrati"}),e("p",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:44",className:"mt-2 max-w-3xl text-sm leading-6 text-[#0F2033]/65",children:"Il pannello espone esclusivamente metadati sanitizzati del provider e dati operativi autorizzati; non mostra carte, token o segreti."})]}),e("button",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:44",onClick:l,"aria-label":"Chiudi dettaglio discrepanza",className:"rounded-xl border border-[#0F2033]/15 bg-white p-2 text-[#0F2033] hover:border-[#E87A38]",children:e(X,{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:44",size:20})})]}),!n&&!b&&e("div",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:45",className:"flex items-center gap-3 px-6 py-16 text-sm font-black",children:[e(z,{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:45",className:"animate-spin text-[#E87A38]",size:22}),"Caricamento confronto sicuroâ¦"]}),b&&e("div",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:46",className:"m-6 flex items-start gap-3 rounded-2xl border border-red-200 bg-red-50 p-4 text-sm text-red-950",children:[e(Q,{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:46",className:"mt-0.5 shrink-0",size:18}),e("div",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:46",children:[e("p",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:46",className:"font-black",children:"Impossibile aprire il dettaglio"}),e("p",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:4
16",className:"mt-1 leading-6",children:b})]})]}),n&&e("div",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:47",className:"p-6",children:[e("section",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:48",className:`rounded-2xl border p-4 ${d.length?"border-red-200 bg-red-50/70":"border-emerald-200 bg-emerald-50"}`,children:e("div",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:48",className:"flex items-start gap-3",children:[d.length?e(Z,{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:48",className:"mt-0.5 shrink-0 text-red-700",size:20}):e(ee,{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:48",className:"mt-0.5 shrink-0 text-emerald-700",size:20}),e("div",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:48",children:[e("p",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:48",className:"font-black",children:d.length?`${d.length} differenz${d.length===1?"a rilevata":"e rilevate"}`:"Nessuna differenza diretta nei campi confrontabili"}),e("p",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:48",className:"mt-1 text-sm leading-6",children:n.discrepancy||"I dettagli sono disponibili per la verifica operativa e la riconciliazione autorizzata."})]})]})}),e("section",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:49",className:"mt-5 grid gap-3 md:grid-cols-2",children:n.comparisons.map(o=>e("article",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:49",className:`rounded-2xl border p-4 ${o.different?"border-red-200 bg-red-50/70":"border-[#0F2033]/10 bg-white"}`,children:[e("div",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:49",className:"flex items-center justify-between gap-3",children:[e("p",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:49",className:"text-sm font-black",children:o.label}),o.different?e("span",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:49",className:"rounded-full bg-red-100 px-2 py-1 text-[11px] font-black text-red-800",children:"Non allineato"}):e("span",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:49",className:"rounded-full bg-emerald-100 px-2 py-1 text-[11px] font-black text-emerald-800",children:"Allineato"})]}),e("div",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:49",className:"mt-3 grid gap-2 text-xs sm:grid-cols-2",children:[e("div",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:49",className:"rounded-xl bg-white/70 p-2",children:[e("p",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:49",className:"font-black text-[#0F2033]/55",children:"Webhook"}),e("p",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:49",className:"mt-1 break-all font-semibold",children:B(o.webhook)})]}),e("div",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:49",className:"rounded-xl bg-white/70 p-2",children:[e("p",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:49",className:"font-black text-[#0F2033]/55",children:"Database"}),e("p",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:49",className:"mt-1 break-all font-semibold",children:B(o.database)})]})]}),o.different&&e("p",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:49",className:"mt-3 text-xs leading-5 text-red-900",children:[e("b",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:49",children:"Motivo:"})," ",be[o.key]||"I valori non coincidono e richiedono una verifica."]})]},o.key))}),e("section",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:50",className:"mt-6 grid gap-5 lg:grid-cols-2",children:[e("article",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:50",className:"overflow-hidden rounded-2xl border border-[#E87A38]/35 bg-white",children:[e("div",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:50",className:"flex items-center gap-2 border-b border-[#
1E87A38]/20 bg-[#FFF3EA] px-4 py-3",children:[e(ce,{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:50",className:"text-[#E87A38]",size:18}),e("div",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:50",children:[e("p",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:50",className:"text-xs font-black uppercase tracking-[.12em] text-[#E87A38]",children:"Provider"}),e("h3",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:50",className:"font-black",children:"Payload webhook ricevuto"})]})]}),e("div",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:50",className:"p-4 text-xs",children:[e("p",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:50",children:[e("b",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:50",children:"Evento:"})," ",n.webhook?.eventType||"Nessun webhook associato"]}),e("p",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:50",className:"mt-1",children:[e("b",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:50",children:"Firma:"})," ",n.webhook?.verificationStatus||"Non applicabile"," · ",e("b",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:50",children:"Elaborazione:"})," ",n.webhook?.processingStatus||"Non applicabile"]}),e("pre",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:50",className:"mt-4 max-h-80 overflow-auto rounded-xl bg-[#0F2033] p-4 text-[11px] leading-5 text-[#F7F5F0]",children:J(n.webhook?.payload)})]})]}),e("article",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:50",className:"overflow-hidden rounded-2xl border border-[#0F2033]/15 bg-white",children:[e("div",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:50",className:"flex items-center gap-2 border-b border-[#0F2033]/10 bg-[#F1F5F9] px-4 py-3",children:[e(ie,{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:50",className:"text-[#0F2033]",size:18}),e("div",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:50",children:[e("p",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:50",className:"text-xs font-black uppercase tracking-[.12em] text-[#0F2033]/55",children:"RistoAI"}),e("h3",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:50",className:"font-black",children:"Ordine e pagamento registrati"})]})]}),e("div",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:50",className:"p-4 text-xs",children:[e("p",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:50",children:[e("b",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:50",children:"Tenant:"})," ",n.database.tenantId||"Non associato"]}),e("p",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:50",className:"mt-1",children:[e("b",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:50",children:"Ordine:"})," ",n.database.order?.displayOrderId||"Non associato"," · ",e("b",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:50",children:"Cliente:"})," ",n.database.order?.customerName||"Non disponibile"]}),e("pre",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:50",className:"mt-4 max-h-80 overflow-auto rounded-xl bg-[#0F2033] p-4 text-[11px] leading-5 text-[#F7F5F0]",children:J(N)})]})]})]}),e("div",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:51",className:"mt-6 flex items-start gap-3 rounded-2xl border border-amber-200 bg-amber-50 p-4 text-amber-950",children:[e(I,{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:51",className:"mt-0.5 shrink-0",size:18}),e("p",{"data-loc":"client/src/components/PaymentDiscrepancyDetailModal.tsx:51",className:"text-sm leading-6",children:"Confronta i campi evidenziati prima di riconciliare manualmente. Un webhook con firma non verificata non deve essere elaborato o riconciliato."})]})]})]})})}const fe={FIRMA_NON_VERIFICATA:"Firma non verificata",WEBHOOK_FALLITO:"Webhook non elaborato",PAGAMENTO_MANCANTE:"Pagamento non registrato",STATO_NON_ALLINEATO:"Stato non allineato",PAGAMENTO_PENDENTE:"Pagamento pendente"},ge={FIRMA_NON_VERIFICATA:"La firma del webhook non ha superato la verifica. Lâevento non è riconciliabile automaticamente.",WEBHOOK_FALLITO:"Il webhook è stato ricevuto ma lâelaborazione interna è terminata con un errore.",PAGAMENTO_MANCANTE:"Esiste un webhook verificato ma non è stato trovato il relativo pagamento interno.",STATO_NON_ALLINEATO:"Lo stato interno non coincide con lâesito dichiarato dal provider.",PAGAMENTO_PENDENTE:"Il pagamento è ancora in attesa di conferma."},R={stripe:"Stripe",paypal:"PayPal",cash:"Contanti",pos:"POS alla consegna"},w={ALL:"Tutti gli stati",SUCCEEDED:"Riuscito",PENDING:"In attesa",FAILED:"Fallito",DISCREPANCY:"Discrepanza",REFUNDED:"Rimborsato"},E=(a,l="EUR")=>new Intl.NumberFormat("it-IT",{style:"currency",currency:l}).format(Number(a||0)),A=a=>
1a?new Date(a).toLocaleString("it-IT",{dateStyle:"short",timeStyle:"short"}):"â",H=a=>a==="SUCCEEDED"||a==="PROCESSED"||a==="RECONCILED"?"bg-emerald-100 text-emerald-800":a==="FAILED"||a==="REJECTED"?"bg-red-100 text-red-800":a==="REFUNDED"?"bg-violet-100 text-violet-800":"bg-amber-100 text-amber-800",Pe=(a="info")=>a==="success"?"border-emerald-200 bg-emerald-50 text-emerald-950":a==="error"?"border-red-200 bg-red-50 text-red-950":"border-[#E87A38]/25 bg-[#FFF3EA] text-[#0F2033]";async function K(a,l){const n=await fetch(a,{credentials:"include",headers:{"Content-Type":"application/json"},...l}),p=await n.json().catch(()=>null);if(!n.ok)throw new Error(p?.error||"Operazione non disponibile");return p}function De({onBack:a,onLogout:l}){const[n,p]=i(null),[b,g]=i(!0),[d,N]=i(!1),[o,T]=i(!1),[D,L]=i(null),[S,v]=i(null),[F,m]=i(null),[h,O]=i("ALL"),[u,$]=i("ALL"),[P,j]=i(""),[k,U]=i(""),[x,_]=i(""),[y,V]=i(""),W=()=>{const t=new URLSearchParams;return P&&t.set("tenantId",P),x&&t.set("dateFrom",x),y&&t.set("dateTo",y),u!=="ALL"&&t.set("provider",u),h!=="ALL"&&t.set("status",h),t.size?`?${t.toString()}`:""},C=async(t=!1)=>{t?N(!0):g(!0);try{p(await K(`/api/admin/payments/reconciliation${W()}`))}catch(c){m({tone:"error",text:c instanceof Error?c.message:"Registro pagamenti non disponibile"})}finally{g(!1),N(!1)}};Y(()=>{C();const t=window.setInterval(()=>void C(!0),15e3);return()=>window.clearInterval(t)},[P,x,y,u,h]);const te=M(()=>(n?.tenants||[]).filter(t=>`${t.name} ${t.slug}`.toLocaleLowerCase("it-IT").includes(k.toLocaleLowerCase("it-IT"))),[n?.tenants,k]),r=n?.summary||{total:0,totalAmount:0,discrepancies:0,reconciled:0,reconciliationRate:0,pending:0,succeeded:0,failed:0,refunded:0},G=[n?.tenants.find(t=>t.id===P)?.name,u!=="ALL"?R[u]:void 0,h!=="ALL"?w[h]:void 0,x||y?`${x||"inizio"} â ${y||"oggi"}`:void 0].filter(Boolean).join(" · "),ne=async t=>{if(t.receiptId){L(t.id),m({tone:"info",text:`Riconciliazione di ${t.eventType} in corsoâ¦`});try{await K(`/api/admin/payments/webhooks/${encodeURIComponent(t.receiptId)}/reconcile`,{method:"POST",body:JSON.stringify({})}),m({tone:"success",text:`Evento ${t.eventType} riconciliato. Registro aggiornato.`}),await C(!0)}catch(c){m({tone:"error",text:c instanceof Error?c.message:"Riconciliazione non riuscita"})}finally{L(null)}}},ae=async()=>{T(!0),m(null);try{const t=await fetch(`/api/admin/payments/reconciliation/export.csv${W()}`,{credentials:"include"});if(!t.ok){const f=await t.json().catch(()=>null);throw new Error(f?.error||"Esportazione non disponibile")}const c=URL.createObjectURL(await t.blob()),s=document.createElement("a");s.href=c,s.download="ristoai-audit-pagamenti.csv",document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(c),m({tone:"success",text:"CSV dei pagamenti filtrati scaricato correttamente."})}catch(t){m({tone:"error",text:t instanceof Error?t.message:"Esportazione non riuscita"})}finally{T(!1)}},oe=()=>{j(""),U(""),_(""),V(""),O("ALL"),$("ALL"),m(null)};return e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:84",className:"min-h-screen bg-[#F7F5F0] text-[#0F2033]",children:[e("header",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:85",className:"border-b border-[#0F2033]/10 bg-white",children:e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:85",className:"mx-auto flex min-h-20 max-w-7xl items-center justify-between gap-4 px-5",children:[e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:85",children:[e("p",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:85",className:"text-xs font-black uppercase tracking-[.18em] text-[#E87A38]",children:"Risto AI · Admin SaaS"}),e("h1",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:85",className:"mt-1 text-2xl font-black tracking-[-.04em] sm:text-3xl",children:"Audit pagamenti"})]}),e("button",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:85",onClick:l,className:"rounded-xl bg-[#0F2033] px-4 py-2.5 text-sm font-black text-white",children:"Esci"})]})}),e("main",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:86",className:"mx-auto max-w-7xl px-5 py-8",children:[e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:87",className:"flex flex-wrap items-center justify-between gap-3",children:[e("button",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:87",onClick:a,className:"inline-flex items-center gap-2 rounded-xl border border-[#0F2033]/15 bg-white px-4 py-2.5 text-sm font-black",children:[e(le,{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:87",size:16}),"Torna alla dashboard"]}),e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:87",className:"flex flex-wrap items-center gap-2",children:[e("span",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:87",className:"hidden text-xs font-bold text-[#0F2033]/55 sm:block",children:"Aggiornamento automatico ogni 15 s"}),e("button",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:87",onClick:()=>void ae(),disabled:o,className:"inline-flex items-center gap-2 rounded-xl border border-[#0F2033]/15 bg-white px-4 py-2.5 text-sm font-black disabled:opacity-60",children:[e(se,{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:87",size:16}),o?"Esportoâ¦":"Esporta CSV"]}),e("button",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:87",onClick:()=>void C(!0),disabled:d||D!==null,className:"inline-flex items-center gap-2 rounded-xl bg-[#E87A38] px-4 py-2.5 text-sm font-black text-white disabled:opacity-60",children:[e(re,{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:87",size:16,className:d?"animate-spin":""}),d?"Aggiornoâ¦":"Aggiorna"]})]})]}),e("section",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:88",className:"mt-6 rounded-3xl bg-[#0F2033] p-6 text-white",children:e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:88",className:"flex flex-wrap items-start justify-between gap-5",children:[e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:88",children:[e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:88",className:"flex items-center gap-2 text-[#E87A38]",children:[e(de,{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:88",size:18}),e("span",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:88",className:"text-xs font-black uppercase tracking-[.16em]",children:"Registro append-only"})]}),e("h2",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:88",className:"mt-3 text-2xl font-black",children:"Transazioni e webhook riconciliati"}),e("p",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:88",className:"mt-2 max-w-2xl text-sm leading-6 text-white/65",children:"Provider, stati, date e tenant filtrano la query sul server. CSV e riepilogo usano lo stesso perimetro dei dati mostrati."})]}),e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:88",className:"rounded-2xl border border-white/15 bg-white/5 px-4 py-3 text-right",children:[e("p",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:88",className:"text-[11px] font-black uppercase tracking-[.14em] text-white/50",children:"Ultimo aggiornamento"}),e("p",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:88",className:"mt-1 text-sm font-bold",children:A(n?.refreshedAt)})]})]})}),e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:89","aria-live":"polite",children:F&&e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:89",className:`mt-5 flex items-center justify-between gap-3 rounded-2xl border px-4 py-3 text-sm font-bold ${Pe(F.tone)}`,children:[e("span",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:89",children:F.text}),e("button",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:89",onClick:()=>m(null),"aria-label":"Chiudi notifica",className:"rounded-lg p-1",children:e(X,{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:89",size:16})})]})}),e("section",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",className:"mt-6 rounded-3xl border border-[#0F2033]/10 bg-white p-5 sm:p-6",children:[e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",className:"flex items-center gap-2",children:[e(me,{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",className:"text-[#E87A38]",size:18}),e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",children:[e("p",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",className:"text-xs font-black uppercase tracking-[.16em] text-[#E87A38]",children:"Filtri avanzati"}),e("h2",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",className:"mt-1 text-xl font-black",children:"Tenant, periodo, provider e stato"})]})]}),e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",className:"mt-5 grid gap-3 lg:grid-cols-3",children:[e("label",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",className:"block",children:[e("span",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",className:"text-xs font-black uppercase tracking-[.1em] text-[#0F2033]/60",children:"Cerca tenant"}),e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",className:"relative mt-1",children:[e(pe,{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",className:"absolute left-3 top-1/2 -translate-y-1/2 text-[#0F2033]/45",size:16}),e("input",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",value:k,onChange:t=>U(t.target.value),placeholder:"Nome o slug del ristorante",className:"w-full rounded-xl border border-[#0F2033]/15 py-2.5 pl-9 pr-3 text-sm outline-none focus:border-[#
1E87A38]"})]})]}),e("label",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",className:"block",children:[e("span",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",className:"text-xs font-black uppercase tracking-[.1em] text-[#0F2033]/60",children:"Da"}),e("input",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",type:"date",value:x,max:y||void 0,onChange:t=>_(t.target.value),className:"mt-1 w-full rounded-xl border border-[#0F2033]/15 px-3 py-2.5 text-sm outline-none focus:border-[#E87A38]"})]}),e("label",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",className:"block",children:[e("span",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",className:"text-xs font-black uppercase tracking-[.1em] text-[#0F2033]/60",children:"A"}),e("input",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",type:"date",value:y,min:x||void 0,onChange:t=>V(t.target.value),className:"mt-1 w-full rounded-xl border border-[#0F2033]/15 px-3 py-2.5 text-sm outline-none focus:border-[#E87A38]"})]}),e("label",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",className:"block",children:[e("span",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",className:"text-xs font-black uppercase tracking-[.1em] text-[#0F2033]/60",children:"Tenant selezionato"}),e("select",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",value:P,onChange:t=>j(t.target.value),className:"mt-1 w-full rounded-xl border border-[#0F2033]/15 bg-white px-3 py-2.5 text-sm font-bold outline-none focus:border-[#E87A38]",children:[e("option",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",value:"",children:"Tutti i tenant"}),te.map(t=>e("option",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",value:t.id,children:[t.name," · ",t.slug]},t.id))]})]}),e("label",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",className:"block",children:[e("span",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",className:"text-xs font-black uppercase tracking-[.1em] text-[#0F2033]/60",children:"Provider di pagamento"}),e("select",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",value:u,onChange:t=>$(t.target.value),className:"mt-1 w-full rounded-xl border border-[#0F2033]/15 bg-white px-3 py-2.5 text-sm font-bold outline-none focus:border-[#E87A38]",children:[e("option",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",value:"ALL",children:"Tutti i provider"}),Object.entries(R).map(([t,c])=>e("option",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",value:t,children:c},t))]})]}),e("label",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",className:"block",children:[e("span",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",className:"text-xs font-black uppercase tracking-[.1em] text-[#0F2033]/60",children:"Stato transazione/webhook"}),e("select",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",value:h,onChange:t=>O(t.target.value),className:"mt-1 w-full rounded-xl border border-[#0F2033]/15 bg-white px-3 py-2.5 text-sm font-bold outline-none focus:border-[#E87A38]",children:Object.keys(w).map(t=>e("option",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",value:t,children:w[t]},t))})]})]}),e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",className:"mt-4 flex flex-wrap items-center justify-between gap-3",children:[e("p",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",className:"text-xs font-bold text-[#0F2033]/55",children:G?`Filtri attivi: ${G}`:"Nessun filtro applicato: visualizzazione completa."}),e("button",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:90",onClick:oe,className:"rounded-xl bg-[#F7F5F0] px-4 py-2.5 text-sm font-black",children:"Azzera filtri"})]})]}),e("section",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:91",className:"mt-6 grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[["Importo transazioni",E(r.totalAmount),"#0F2033","Somma dei pagamenti nel perimetro filtrato"],["Transazioni gestite",r.total,"#0F2033","Ordini o pagamenti inclusi nei filtri correnti"],["Discrepanze attive",r.discrepancies,"#DC2626","Eventi che richiedono verifica o riconciliazione"],["Riconciliate con successo",`${r.reconciliationRate}%`,"#059669",`${r.reconciled}
1 transazioni allineate su ${r.total}`]].map(([t,c,s,f])=>e("article",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:91",className:"rounded-2xl border border-[#0F2033]/10 bg-white p-4",children:[e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:91",className:"flex items-start justify-between gap-2",children:[e("p",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:91",className:"text-[11px] font-black uppercase tracking-[.12em] text-[#0F2033]/50",children:t}),e("span",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:91",title:String(f),className:"text-[#0F2033]/40",children:e(I,{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:91",size:15})})]}),e("p",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:91",className:"mt-2 text-3xl font-black",style:{color:String(s)},children:c}),e("p",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:91",className:"mt-2 text-xs text-[#0F2033]/55",children:f})]},String(t)))}),e("section",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:92",className:"mt-8 rounded-3xl border border-[#0F2033]/10 bg-white p-5 sm:p-6",children:[e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:92",className:"flex flex-wrap items-end justify-between gap-4",children:[e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:92",children:[e("p",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:92",className:"text-xs font-black uppercase tracking-[.16em] text-[#E87A38]",children:"Riconciliazione"}),e("h2",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:92",className:"mt-1 text-xl font-black",children:"Webhook ricevuti e ordini effettivi"})]}),e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:92",className:"rounded-xl bg-[#F7F5F0] px-3 py-2 text-xs font-black text-[#0F2033]/65",children:[r.succeeded," riusciti · ",r.pending," in attesa · ",r.failed," falliti · ",r.refunded," rimborsati"]})]}),b?e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",className:"mt-6 flex items-center gap-2 rounded-2xl bg-[#F7F5F0] p-6 text-sm font-black",children:[e(z,{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",size:18,className:"animate-spin text-[#E87A38]"}),"Caricamento registro pagamentiâ¦"]}):(n?.receipts||[]).length?e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",className:"mt-5 space-y-3",children:n?.receipts.map(t=>{const c=D===t.id,s=t.discrepancy&&t.discrepancy!=="PAGAMENTO_PENDENTE",f=c?"border-[#E87A38] bg-[#FFF8F3]":s?"border-red-200 bg-red-50/60":t.discrepancy?"border-[#E87A38]/45 bg-[#FFF8F3]":"border-[#0F2033]/10";return e("article",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",className:`rounded-2xl border p-4 ${f}`,children:[e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",className:"flex flex-wrap items-start justify-between gap-4",children:[e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",className:"min-w-[220px] flex-1",children:[e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",className:"flex flex-wrap items-center gap-2",children:[e("span",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",className:`rounded-full px-2.5 py-1 text-[11px] font-black ${H(t.processingStatus)}`,children:t.processingStatus}),e("span",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",className:"rounded-full bg-[#0F2033]/8 px-2.5 py-1 text-[11px] font-black text-[#0F2033]",children:R[t.provider]||t.provider}),t.payment?.status&&e("span",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",className:`rounded-full px-2.5 py-1 text-[11px] font-black ${H(t.payment.status)}`,children:["Pagamento ",t.payment.status]}),t.discrepancy&&e("button",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",type:"button",onClick:()=>v(t.id),title:"Apri il confronto dettagliato tra provider e database",className:`inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-[11px] font-black ${s?"bg-red-100 text-red-800":"bg-[#FFE4D0] text-[#9A3E10]"}`,children:[e(Q,{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",size:12}),fe[t.discrepancy]||t.discrepancy,e(q,{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",size:12})]})]}),e("p",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",className:"mt-3 text-sm font-black",children:t.eventType}),e("p",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",className:"mt-1 break-all text-xs text-[#0F2033]/55",children:t.stripeEventId?`Evento Stripe: ${t.stripeEventId}`:"Transazione senza webhook Stripe associato"})]}),e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",className:"min-w-[180px] text-left sm:text-right",children:[e("p",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",className:"text-sm font-black",children:t.order?.displayOrderId||"Ordine non associato"}),e("p",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",className:"mt-1 text-xs text-[#0F2033]/55",children:[t.order?.customerName||"Cliente non disponibile"," · ",t.payment?E(t.payment.amount,t.payment.currency):"Importo non disponibile"]}),e("p",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",className:"mt-1 text-xs text-[#0F2033]/55",children:["Ricevuto: ",A(t.receivedAt)]})]})]}),t.discrepancy&&e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",className:`mt-3 flex flex-wrap items-center justify-between gap-3 rounded-xl px-3 py-2 text-xs leading-5 ${s?"bg-red-100/70 text-red-900":"bg-[#FFE4D0]/70 text-[#7A320F]"}`,children:[e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",className:"flex gap-2",children:[e(I,{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",className:"mt-0.5 shrink-0",size:14}),e("p",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",children:ge[t.discrepancy]||"à stata rilevata una differenza tra provider e pagamento interno."})]}),e("button",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",type:"button",onClick:()=>v(t.id),className:"inline-flex items-center gap-1 rounded-lg border border-current/20 bg-white/45 px-2 py-1 font-black",children:[e(q,{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",size:13}),"Vedi confronto"]})]}),e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",className:"mt-4 flex flex-wrap items-center justify-between gap-3 border-t border-[#0F2033]/8 pt-3",children:[e("p",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",className:"text-xs text-[#0F2033]/60",children:["Tentativi: ",t.processingAttempts,t.lastError?` · Errore: ${t.lastError}`:""]}),t.discrepancy&&t.receiptId?e("button",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",onClick:()=>void ne(t),disabled:D!==null||t.verificationStatus!=="VERIFIED",title:t.verificationStatus!=="VERIFIED"?"La firma del webhook non è verificata":"Rielabora localmente lâevento Stripe verificato",className:"inline-flex items-center gap-2 rounded-xl bg-[#E87A38] px-3 py-2 text-xs font-black text-white disabled:cursor-not-allowed disabled:opacity-50",children:[c?e(z,{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",size:14,className:"animate-spin"}):e(xe,{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",size:14}),c?"Riconciliazioneâ¦":"Riconcilia evento"]}):t.reconciled?e("span",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",className:"inline-flex items-center gap-1 text-xs font-black text-emerald-700",children:[e(ee,{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",size:15}),"Allineato"]}):e("span",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",className:"text-xs font-black text-[#0F2033]/55",children:"Verifica operativa richiesta"})]})]},t.id)})}):e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:93",className:"mt-6 rounded-2xl bg-[#F7F5F0] p-6 text-sm font-bold text-[#0F2033]/65",children:"Non sono presenti transazioni o webhook per i filtri selezionati."})]}),e("section",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:95",className:"mt-8 rounded-3xl border border-[#0F2033]/10 bg-white p-5 sm:p-6",children:[e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:95",className:"flex items-center gap-2",children:[e(ye,{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:95",className:"text-[#E87A38]",size:18}),e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:95",children:[e("p",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:95",className:"text-xs font-black uppercase tracking-[.16em] text-[#E87A38]",children:"Audit di sistema"}),e("h2",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:95",className:"mt-1 text-xl font-black",children:"Ultimi cambi di stato pagamento"})]})]}),e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:95",className:"mt-5 divi
1de-y divide-[#0F2033]/8",children:[(n?.auditEvents||[]).slice(0,12).map(t=>e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:95",className:"flex flex-wrap items-center justify-between gap-3 py-3",children:[e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:95",children:[e("p",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:95",className:"text-sm font-black",children:t.eventType}),e("p",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:95",className:"mt-1 text-xs text-[#0F2033]/55",children:[R[t.provider]||t.provider," · ",t.paymentStatus||"Stato non disponibile"]})]}),e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:95",className:"text-right",children:[e("p",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:95",className:"text-sm font-black",children:t.amount===null?"â":E(t.amount,t.currency)}),e("p",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:95",className:"mt-1 text-xs text-[#0F2033]/55",children:A(t.occurredAt)})]})]},t.id)),!b&&!(n?.auditEvents||[]).length&&e("p",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:95",className:"py-4 text-sm text-[#0F2033]/60",children:"Nessun evento di audit ancora registrato per i filtri selezionati."})]})]}),e("div",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:96",className:"mt-6 flex items-start gap-3 rounded-2xl border border-amber-200 bg-amber-50 p-4 text-amber-950",children:[e(Z,{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:96",className:"mt-0.5 shrink-0",size:18}),e("p",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:96",className:"text-sm leading-6",children:[e("b",{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:96",children:"Controllo operativo:"})," confronta i valori nel dettaglio prima di riconciliare. I webhook senza firma verificata non sono elaborabili."]})]})]}),S&&e(ue,{"data-loc":"client/src/components/PaymentReconciliationConsole.tsx:98",recordId:S,onClose:()=>v(null)})]})}export{De 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.