const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/abt-trading-blotter-B0sG-X-c.js","assets/index-B_1BLMrZ.js","assets/index-ByKBvrJT.css"])))=>i.map(i=>d[i]);
import{u as Ae,r as g,j as e,B as C,Z as Oe,aJ as Ye,G as Qe,ag as De,F as Q,x as k,I as S,h as ct,N as it,k as Xe,aO as dt,L as P,aG as xt,n as z,cl as Je,al as ge,aR as ee,aS as te,aT as ae,aU as se,aV as R,a3 as W,bg as me,ae as Le,o as ve,aa as Ee,V as be,a0 as ye,at as Ue,ad as Ie,bv as pt,H as mt,b6 as ie,aF as ut,P as Se,T as ht,aD as qe,a1 as ze,ab as _e,W as Ke,cd as Ge,ah as ft,a as de,q as V,b as xe,aL as bt,ak as He,aW as Ze,R as gt,be as yt}from"./index-B_1BLMrZ.js";import{F as Ne}from"./file-spreadsheet-DOOKiYyy.js";import{a8 as jt}from"./ai-advisor-toolkit-DagTvBTn.js";import{A as We}from"./arrow-left-right-CVXJTtsW.js";import"./bcp-disclosure-Bs9uMRlI.js";const we="#c5a059",Me="#cd2122";function A(a,t=2){if(a==null||a==="")return"—";const s=typeof a=="string"?parseFloat(a):a;return isNaN(s)?"—":s.toLocaleString("en-US",{minimumFractionDigits:t,maximumFractionDigits:t})}function X(a){return a==null?"—":`${a>=0?"+":""}${A(a)}%`}function Y(a){return a?new Date(a).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"—"}function _(a){if(a==null)return"";let t=String(a);return/^[=+\-@\t\r]/.test(t)&&(t="'"+t),t.includes(",")||t.includes('"')||t.includes(`
`)?`"${t.replace(/"/g,'""')}"`:t}function H(a){return a==null?"":String(a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function O(a){if(a==null||a==="")return"";const t=typeof a=="string"?parseFloat(a):a;return isNaN(t)?"":String(t)}function et(a){const t=[["Symbol","Name","Asset Class","Quantity","Cost Basis","Market Value","Unrealized P&L","P&L %","Weight %"]];for(const s of a.holdings||[])t.push([_(s.ticker),_(s.name),_(s.assetClass),O(s.quantity),O(s.costBasis),O(s.marketValue),O(s.unrealizedPnl),O(s.unrealizedPnlPct),O(s.weight)]);return t.map(s=>s.join(",")).join(`
`)}function tt(a){const t=[["Period","TWRR","MWRR","Annualized","Days"]];for(const s of a.performance?.periods||[])t.push([_(s.label),O(s.twrr),O(s.mwrr),String(!!s.annualized),O(s.days)]);t.push([]),t.push(["Monthly Returns"]),t.push(["Month","Return"]);for(const s of a.performance?.monthlyReturns||[])t.push([_(s.month),String(s.return)]);return t.map(s=>s.join(",")).join(`
`)}function at(a){const t=[["Date","Type","Reference","Description","Amount","Status"]];for(const s of a.transactionSummary?.recentTransactions||[])t.push([_(s.date),_(s.type),_(s.ref),_(s.description),String(s.amount),_(s.status)]);return t.map(s=>s.join(",")).join(`
`)}function st(a){const t=[{title:"Asset Class Allocation",data:a.allocation?.assetClass},{title:"Sector Allocation",data:a.allocation?.sector},{title:"Country/Region Allocation",data:a.allocation?.country},{title:"Style Allocation",data:a.allocation?.style}],s=[];for(const n of t){s.push(n.title),s.push("Name,Value,Weight %");for(const o of n.data||[])s.push(`${_(o.name)},${o.value},${o.pct}`);s.push("")}return s.join(`
`)}function lt(a){const t=a.risk||{};return[["Metric","Value"],["Standard Deviation (Ann.)",String(t.standardDeviation??"")],["Max Drawdown",String(t.maxDrawdown??"")],["Sharpe Ratio",String(t.sharpeRatio??"")],["Sortino Ratio",String(t.sortinoRatio??"")],["Alpha",String(t.alpha??"")],["Beta",String(t.beta??"")],["R-Squared",String(t.rSquared??"")],["Tracking Error",String(t.trackingError??"")],["Information Ratio",String(t.informationRatio??"")],["Treynor Ratio",String(t.treynorRatio??"")],["Calmar Ratio",String(t.calmarRatio??"")],["VaR (95%)",String(t.var95??"")],["CVaR (95%)",String(t.cvar95??"")],["Up Capture Ratio",String(t.upCaptureRatio??"")],["Down Capture Ratio",String(t.downCaptureRatio??"")]].map(n=>n.join(",")).join(`
`)}function Nt(a){const t=[];return t.push("ALHAMBRA BANK & TRUST — CLIENT STATEMENT"),t.push(`Account: ${a.account?.name} (${a.account?.code})`),t.push(`Period: ${Y(a.reportPeriod?.startDate)} to ${Y(a.reportPeriod?.endDate)}`),t.push(`Generated: ${Y(a.generatedAt)}`),t.push(""),t.push("SUMMARY"),t.push(`Total Market Value,${O(a.summary?.totalMarketValue)}`),t.push(`Total Cost Basis,${O(a.summary?.totalCostBasis)}`),t.push(`Unrealized P&L,${O(a.summary?.totalUnrealizedPnl)}`),t.push(`Total Return %,${O(a.summary?.totalReturnPct)}`),t.push(`IRR,${O(a.summary?.irr)}`),t.push(`TWRR,${O(a.summary?.twrr)}`),t.push(`MWRR,${O(a.summary?.mwrr)}`),t.push(""),t.push("HOLDINGS"),t.push(et(a)),t.push(""),t.push("PERFORMANCE"),t.push(tt(a)),t.push(""),t.push("ALLOCATION"),t.push(st(a)),t.push(""),t.push("RISK ANALYTICS"),t.push(lt(a)),t.push(""),t.push("TRANSACTIONS"),t.push(at(a)),t.join(`
`)}function J(a,t,s){const n=new Blob([a],{type:s}),o=URL.createObjectURL(n),r=document.createElement("a");r.href=o,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(o)}function Be(a){const t=(a.holdings||[]).map(x=>`<tr>
      <td style="padding:4px 8px;border-bottom:1px solid #e2e8f0;font-family:monospace;font-weight:bold;color:${we}">${H(x.ticker)||"—"}</td>
      <td style="padding:4px 8px;border-bottom:1px solid #e2e8f0">${H(x.name)||"—"}</td>
      <td style="padding:4px 8px;border-bottom:1px solid #e2e8f0">${H(x.assetClass)||"—"}</td>
      <td style="padding:4px 8px;border-bottom:1px solid #e2e8f0;text-align:right;font-family:monospace">${A(x.quantity,4)}</td>
      <td style="padding:4px 8px;border-bottom:1px solid #e2e8f0;text-align:right;font-family:monospace">$${A(x.costBasis)}</td>
      <td style="padding:4px 8px;border-bottom:1px solid #e2e8f0;text-align:right;font-family:monospace">$${A(x.marketValue)}</td>
      <td style="padding:4px 8px;border-bottom:1px solid #e2e8f0;text-align:right;font-family:monospace;color:${(x.unrealizedPnl||0)>=0?"#16a34a":"#dc2626"}">${X(x.unrealizedPnlPct)}</td>
      <td style="padding:4px 8px;border-bottom:1px solid #e2e8f0;text-align:right;font-family:monospace">${A(x.weight,1)}%</td>
    </tr>`).join(""),s=(a.performance?.periods||[]).map(x=>`<tr>
      <td style="padding:4px 8px;border-bottom:1px solid #e2e8f0;font-weight:bold">${H(x.label)}</td>
      <td style="padding:4px 8px;border-bottom:1px solid #e2e8f0;text-align:right;font-family:monospace;color:${(x.twrr||0)>=0?"#16a34a":"#dc2626"}">${X(x.twrr)}</td>
      <td style="padding:4px 8px;border-bottom:1px solid #e2e8f0;text-align:right;font-family:monospace;color:${(x.mwrr||0)>=0?"#16a34a":"#dc2626"}">${X(x.mwrr)}</td>
      <td style="padding:4px 8px;border-bottom:1px solid #e2e8f0;text-align:right;font-family:monospace">${x.days}d</td>
    </tr>`).join(""),n=(x,p)=>{if(!p||p.length===0)return"";const f=p.map(m=>`<tr>
        <td style="padding:3px 8px;border-bottom:1px solid #f1f5f9">${H(m.name)}</td>
        <td style="padding:3px 8px;border-bottom:1px solid #f1f5f9;text-align:right;font-family:monospace">$${A(m.value)}</td>
        <td style="padding:3px 8px;border-bottom:1px solid #f1f5f9;text-align:right;font-family:monospace">${A(m.pct,1)}%</td>
      </tr>`).join("");return`<h3 style="font-size:13px;color:#334155;margin:16px 0 6px;border-bottom:1px solid #e2e8f0;padding-bottom:4px">${x}</h3>
    <table style="width:100%;border-collapse:collapse;font-size:11px">
      <thead><tr style="background:#f8fafc"><th style="padding:4px 8px;text-align:left">Category</th><th style="padding:4px 8px;text-align:right">Value</th><th style="padding:4px 8px;text-align:right">Weight</th></tr></thead>
      <tbody>${f}</tbody>
    </table>`},o=a.risk||{},c=[["Standard Deviation (Ann.)",o.standardDeviation!=null?`${A(o.standardDeviation)}%`:"—"],["Max Drawdown",o.maxDrawdown!=null?`${A(o.maxDrawdown)}%`:"—"],["Sharpe Ratio",A(o.sharpeRatio)],["Sortino Ratio",A(o.sortinoRatio)],["Alpha",o.alpha!=null?`${X(o.alpha)}`:"—"],["Beta",A(o.beta)],["R²",A(o.rSquared)],["VaR (95%)",o.var95!=null?`${A(o.var95)}%`:"—"],["CVaR (95%)",o.cvar95!=null?`${A(o.cvar95)}%`:"—"],["Up Capture",o.upCaptureRatio!=null?`${A(o.upCaptureRatio)}%`:"—"],["Down Capture",o.downCaptureRatio!=null?`${A(o.downCaptureRatio)}%`:"—"]].map(([x,p])=>`<tr><td style="padding:3px 8px;border-bottom:1px solid #f1f5f9">${x}</td><td style="padding:3px 8px;border-bottom:1px solid #f1f5f9;text-align:right;font-family:monospace">${p}</td></tr>`).join(""),h=(a.transactionSummary?.recentTransactions||[]).slice(0,25).map(x=>`<tr>
      <td style="padding:3px 8px;border-bottom:1px solid #f1f5f9;font-family:monospace;font-size:10px">${Y(x.date)}</td>
      <td style="padding:3px 8px;border-bottom:1px solid #f1f5f9">${H(x.type)||"—"}</td>
      <td style="padding:3px 8px;border-bottom:1px solid #f1f5f9">${H(x.description)||"—"}</td>
      <td style="padding:3px 8px;border-bottom:1px solid #f1f5f9;text-align:right;font-family:monospace">$${A(x.amount)}</td>
    </tr>`).join("");return`<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Client Statement — ${a.account?.name||"Account"}</title>
  <style>
    @page { margin: 0.6in; size: A4; }
    body { font-family: 'Segoe UI', Tahoma, Geneva, sans-serif; font-size: 11px; color: #1e293b; line-height: 1.4; margin: 0; padding: 20px; }
    .header { border-bottom: 3px solid ${we}; padding-bottom: 12px; margin-bottom: 20px; display: flex; justify-content: space-between; align-items: flex-end; }
    .bank-name { font-size: 18px; font-weight: bold; color: ${Me}; letter-spacing: 0.5px; }
    .subtitle { font-size: 10px; color: #64748b; margin-top: 2px; }
    .acct-info { text-align: right; }
    .acct-name { font-size: 14px; font-weight: bold; color: #1e293b; }
    .summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 16px 0; }
    .summary-box { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px; padding: 10px; }
    .summary-label { font-size: 9px; text-transform: uppercase; color: #94a3b8; font-weight: bold; letter-spacing: 0.5px; }
    .summary-value { font-size: 16px; font-weight: bold; margin-top: 2px; font-family: monospace; }
    h2 { font-size: 14px; color: ${Me}; margin: 24px 0 8px; border-bottom: 2px solid ${we}; padding-bottom: 4px; page-break-after: avoid; }
    table { width: 100%; border-collapse: collapse; font-size: 10px; }
    thead tr { background: #f8fafc; }
    th { padding: 5px 8px; text-align: left; font-size: 9px; text-transform: uppercase; color: #64748b; font-weight: bold; }
    .footer { margin-top: 30px; padding-top: 10px; border-top: 2px solid ${we}; font-size: 9px; color: #94a3b8; text-align: center; }
    .page-break { page-break-before: always; }
    @media print { body { padding: 0; } }
  </style>
</head>
<body>
  <div class="header">
    <div>
      <div class="bank-name">ALHAMBRA BANK &amp; TRUST</div>
      <div class="subtitle">Private Banking · Cayman Islands</div>
      <div class="subtitle" style="margin-top:8px;font-weight:bold;color:#1e293b">CLIENT INVESTMENT STATEMENT</div>
    </div>
    <div class="acct-info">
      <div class="acct-name">${H(a.account?.name)||"—"}</div>
      <div class="subtitle">${H(a.account?.code)||"—"} · ${H(a.account?.currency)||"USD"}</div>
      <div class="subtitle">${Y(a.reportPeriod?.startDate)} — ${Y(a.reportPeriod?.endDate)} (${a.reportPeriod?.days||0} days)</div>
      <div class="subtitle">Generated ${Y(a.generatedAt)}</div>
    </div>
  </div>

  <div class="summary-grid">
    <div class="summary-box">
      <div class="summary-label">Total Market Value</div>
      <div class="summary-value" style="color:${Me}">$${A(a.summary?.totalMarketValue)}</div>
    </div>
    <div class="summary-box">
      <div class="summary-label">Total Cost Basis</div>
      <div class="summary-value">$${A(a.summary?.totalCostBasis)}</div>
    </div>
    <div class="summary-box">
      <div class="summary-label">Unrealized P&amp;L</div>
      <div class="summary-value" style="color:${(a.summary?.totalUnrealizedPnl||0)>=0?"#16a34a":"#dc2626"}">$${A(a.summary?.totalUnrealizedPnl)}</div>
    </div>
    <div class="summary-box">
      <div class="summary-label">Total Return</div>
      <div class="summary-value" style="color:${(a.summary?.totalReturnPct||0)>=0?"#16a34a":"#dc2626"}">${X(a.summary?.totalReturnPct)}</div>
    </div>
  </div>

  <div class="summary-grid" style="grid-template-columns: repeat(3, 1fr)">
    <div class="summary-box">
      <div class="summary-label">IRR</div>
      <div class="summary-value">${X(a.summary?.irr)}</div>
    </div>
    <div class="summary-box">
      <div class="summary-label">TWRR</div>
      <div class="summary-value">${X(a.summary?.twrr)}</div>
    </div>
    <div class="summary-box">
      <div class="summary-label">MWRR</div>
      <div class="summary-value">${X(a.summary?.mwrr)}</div>
    </div>
  </div>

  <h2>Performance</h2>
  <table>
    <thead><tr><th>Period</th><th style="text-align:right">TWRR</th><th style="text-align:right">MWRR</th><th style="text-align:right">Duration</th></tr></thead>
    <tbody>${s}</tbody>
  </table>

  <h2>Holdings (${(a.holdings||[]).length} positions)</h2>
  <table>
    <thead><tr><th>Symbol</th><th>Name</th><th>Class</th><th style="text-align:right">Qty</th><th style="text-align:right">Cost</th><th style="text-align:right">Market</th><th style="text-align:right">P&amp;L</th><th style="text-align:right">Wt%</th></tr></thead>
    <tbody>${t}</tbody>
  </table>

  <div class="page-break"></div>

  <h2>Asset Allocation</h2>
  ${n("By Asset Class",a.allocation?.assetClass)}
  ${n("By Sector",a.allocation?.sector)}
  ${n("By Country/Region",a.allocation?.country)}

  <h2>Risk Analytics</h2>
  <table style="width:50%">
    <thead><tr><th>Metric</th><th style="text-align:right">Value</th></tr></thead>
    <tbody>${c}</tbody>
  </table>

  ${(a.transactionSummary?.recentTransactions||[]).length>0?`
  <h2>Recent Activity</h2>
  <div style="margin-bottom:8px;font-size:10px;color:#64748b">
    Transactions: ${a.transactionSummary?.totalTransactions||0} total · Buys: ${a.transactionSummary?.buys||0} · Sells: ${a.transactionSummary?.sells||0} · Dividends: ${a.transactionSummary?.dividends||0} · Fees: ${a.transactionSummary?.fees||0}
  </div>
  <table>
    <thead><tr><th>Date</th><th>Type</th><th>Description</th><th style="text-align:right">Amount</th></tr></thead>
    <tbody>${h}</tbody>
  </table>`:""}

  <div class="footer">
    <p><strong>Alhambra Bank &amp; Trust</strong> · PO Box 309, Ugland House, Grand Cayman, KY1-1104, Cayman Islands</p>
    <p>This report is generated for informational purposes only and does not constitute investment advice. Past performance is not indicative of future results.</p>
    <p>Confidential</p>
  </div>
</body>
</html>`}function vt({statement:a,printRef:t}){const{toast:s}=Ae(),[n,o]=g.useState(!1),[r,c]=g.useState(!1),[h,x]=g.useState(!1),[p,f]=g.useState(""),[m,i]=g.useState(""),[I,F]=g.useState(!1),[w,N]=g.useState(!1),D=g.useRef(null),y=a;if(!y)return null;const B=`ABT_Statement_${y.account?.code||"account"}_${y.reportPeriod?.endDate||"report"}`;function le(){window.print(),o(!1)}function U(){x(!0),o(!1),setTimeout(()=>{if(D.current){const j=D.current.contentDocument||D.current.contentWindow?.document;j&&(j.open(),j.write(Be(y)),j.close())}},100)}function G(){N(!0),o(!1);try{const j=Be(y),je=window.open("","_blank");je?(je.document.write(j),je.document.close(),setTimeout(()=>{je.print(),N(!1)},500)):(J(j,`${B}.html`,"text/html"),s({title:"PDF preview opened — use browser print to save as PDF"}),N(!1))}catch{s({title:"Failed to generate PDF",variant:"destructive"}),N(!1)}}function ue(){o(!1);const j=Be(y);J(j,`${B}.html`,"text/html"),s({title:`Downloaded ${B}.html`})}function l(){o(!1);const j=Nt(y);J(j,`${B}_Full.csv`,"text/csv"),s({title:"Downloaded full statement CSV"})}function d(){o(!1);const j=et(y);J(j,`${B}_Holdings.csv`,"text/csv"),s({title:"Downloaded holdings CSV"})}function b(){o(!1);const j=tt(y);J(j,`${B}_Performance.csv`,"text/csv"),s({title:"Downloaded performance CSV"})}function E(){o(!1);const j=at(y);J(j,`${B}_Transactions.csv`,"text/csv"),s({title:"Downloaded transactions CSV"})}function he(){o(!1);const j=st(y);J(j,`${B}_Allocation.csv`,"text/csv"),s({title:"Downloaded allocation CSV"})}function Pe(){o(!1);const j=lt(y);J(j,`${B}_Risk.csv`,"text/csv"),s({title:"Downloaded risk analytics CSV"})}function rt(){o(!1);const j=JSON.stringify(y,null,2);J(j,`${B}.json`,"application/json"),s({title:"Downloaded statement JSON"})}function nt(){const j=window.location.href;navigator.clipboard.writeText(j).then(()=>{F(!0),setTimeout(()=>F(!1),2e3),s({title:"Link copied to clipboard"})})}function ot(){if(!p){s({title:"Enter an email address",variant:"destructive"});return}const j=encodeURIComponent(`Client Statement — ${y.account?.name} (${y.account?.code})`),je=encodeURIComponent(`Please find the client statement for ${y.account?.name} (${y.account?.code}).

Period: ${Y(y.reportPeriod?.startDate)} — ${Y(y.reportPeriod?.endDate)}
Total Portfolio Value: $${A(y.summary?.totalMarketValue)}
Total Return: ${X(y.summary?.totalReturnPct)}

`+(m?`Note: ${m}

`:"")+`Generated by Alhambra Bank & Trust · ${Y(y.generatedAt)}`);window.open(`mailto:${p}?subject=${j}&body=${je}`),c(!1),s({title:`Opening email client for ${p}`})}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1.5 relative","data-testid":"export-toolbar",children:[e.jsxs(C,{variant:"outline",size:"sm",onClick:U,className:"gap-1 text-xs h-8","data-testid":"button-preview-statement",children:[e.jsx(Oe,{className:"h-3.5 w-3.5"})," Preview"]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:le,className:"gap-1 text-xs h-8","data-testid":"button-print-statement",children:[e.jsx(Ye,{className:"h-3.5 w-3.5"})," Print"]}),e.jsxs("div",{className:"relative",children:[e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>{o(!n),c(!1)},className:"gap-1 text-xs h-8","data-testid":"button-download-menu",children:[e.jsx(Qe,{className:"h-3.5 w-3.5"})," Download ",e.jsx(De,{className:"h-3 w-3"})]}),n&&e.jsxs("div",{className:"absolute right-0 top-9 z-50 bg-white rounded-lg border border-border shadow-xl py-1 w-56","data-testid":"download-dropdown",children:[e.jsx("p",{className:"px-3 py-1.5 text-[9px] text-slate-400 uppercase font-bold tracking-wider",children:"PDF / Print"}),e.jsxs("button",{type:"button",onClick:G,className:"w-full px-3 py-1.5 text-left text-xs hover:bg-slate-50 flex items-center gap-2","data-testid":"download-pdf",children:[e.jsx(Q,{className:"h-3.5 w-3.5 text-red-500"})," Save as PDF (Print Dialog)"]}),e.jsxs("button",{type:"button",onClick:ue,className:"w-full px-3 py-1.5 text-left text-xs hover:bg-slate-50 flex items-center gap-2","data-testid":"download-html",children:[e.jsx(Q,{className:"h-3.5 w-3.5 text-blue-500"})," Download HTML Report"]}),e.jsx("div",{className:"border-t border-border my-1"}),e.jsx("p",{className:"px-3 py-1.5 text-[9px] text-slate-400 uppercase font-bold tracking-wider",children:"CSV Exports"}),e.jsxs("button",{type:"button",onClick:l,className:"w-full px-3 py-1.5 text-left text-xs hover:bg-slate-50 flex items-center gap-2","data-testid":"download-csv-full",children:[e.jsx(Ne,{className:"h-3.5 w-3.5 text-emerald-500"})," Full Statement CSV"]}),e.jsxs("button",{type:"button",onClick:d,className:"w-full px-3 py-1.5 text-left text-xs hover:bg-slate-50 flex items-center gap-2","data-testid":"download-csv-holdings",children:[e.jsx(Ne,{className:"h-3.5 w-3.5 text-emerald-500"})," Holdings Only"]}),e.jsxs("button",{type:"button",onClick:b,className:"w-full px-3 py-1.5 text-left text-xs hover:bg-slate-50 flex items-center gap-2","data-testid":"download-csv-performance",children:[e.jsx(Ne,{className:"h-3.5 w-3.5 text-emerald-500"})," Performance Only"]}),e.jsxs("button",{type:"button",onClick:he,className:"w-full px-3 py-1.5 text-left text-xs hover:bg-slate-50 flex items-center gap-2","data-testid":"download-csv-allocation",children:[e.jsx(Ne,{className:"h-3.5 w-3.5 text-emerald-500"})," Allocation Only"]}),e.jsxs("button",{type:"button",onClick:Pe,className:"w-full px-3 py-1.5 text-left text-xs hover:bg-slate-50 flex items-center gap-2","data-testid":"download-csv-risk",children:[e.jsx(Ne,{className:"h-3.5 w-3.5 text-emerald-500"})," Risk Analytics Only"]}),e.jsxs("button",{type:"button",onClick:E,className:"w-full px-3 py-1.5 text-left text-xs hover:bg-slate-50 flex items-center gap-2","data-testid":"download-csv-transactions",children:[e.jsx(Ne,{className:"h-3.5 w-3.5 text-emerald-500"})," Transactions Only"]}),e.jsx("div",{className:"border-t border-border my-1"}),e.jsx("p",{className:"px-3 py-1.5 text-[9px] text-slate-400 uppercase font-bold tracking-wider",children:"Data"}),e.jsxs("button",{type:"button",onClick:rt,className:"w-full px-3 py-1.5 text-left text-xs hover:bg-slate-50 flex items-center gap-2","data-testid":"download-json",children:[e.jsx(Q,{className:"h-3.5 w-3.5 text-amber-500"})," Raw JSON Data"]})]})]}),e.jsxs("div",{className:"relative",children:[e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>{c(!r),o(!1)},className:"gap-1 text-xs h-8","data-testid":"button-share-menu",children:[e.jsx(jt,{className:"h-3.5 w-3.5"})," Share"]}),r&&e.jsxs("div",{className:"absolute right-0 top-9 z-50 bg-white rounded-lg border border-border shadow-xl p-3 w-72 space-y-3","data-testid":"share-dropdown",children:[e.jsx("p",{className:"text-xs font-bold text-slate-800",children:"Share Statement"}),e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Email To"}),e.jsx(S,{maxLength:254,value:p,onChange:j=>f(j.target.value),placeholder:"colleague@alhambrabank.ky",className:"h-8 text-xs mt-1",type:"email","data-testid":"input-share-email"})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Note (optional)"}),e.jsx(ct,{maxLength:5e3,value:m,onChange:j=>i(j.target.value),placeholder:"Optional message...",className:"text-xs mt-1 h-14","data-testid":"input-share-note"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(C,{size:"sm",onClick:ot,className:"flex-1 gap-1 text-xs",style:{backgroundColor:we},"data-testid":"button-send-email",children:[e.jsx(it,{className:"h-3.5 w-3.5"})," Send via Email"]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:nt,className:"gap-1 text-xs","data-testid":"button-copy-link",children:[I?e.jsx(Xe,{className:"h-3.5 w-3.5 text-emerald-500"}):e.jsx(dt,{className:"h-3.5 w-3.5"}),I?"Copied!":"Copy Link"]})]})]})]})]}),h&&e.jsx("div",{className:"fixed inset-0 z-[100] bg-black/50 flex items-center justify-center p-4",onClick:()=>x(!1),"data-testid":"preview-modal",children:e.jsxs("div",{className:"bg-white rounded-lg shadow-2xl w-full max-w-5xl h-[90vh] flex flex-col",onClick:j=>j.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Oe,{className:"h-4 w-4",style:{color:we}}),e.jsx("span",{className:"text-sm font-bold text-slate-800",children:"Statement Preview"}),e.jsxs("span",{className:"text-xs text-slate-400",children:[y.account?.name," (",y.account?.code,")"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(C,{variant:"outline",size:"sm",onClick:G,className:"gap-1 text-xs","data-testid":"preview-download-pdf",children:[w?e.jsx(P,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Qe,{className:"h-3.5 w-3.5"})," Save as PDF"]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>{D.current?.contentWindow&&D.current.contentWindow.print()},className:"gap-1 text-xs","data-testid":"preview-print",children:[e.jsx(Ye,{className:"h-3.5 w-3.5"})," Print"]}),e.jsx("button",{type:"button",onClick:()=>x(!1),className:"text-slate-400 hover:text-slate-600","data-testid":"preview-close",children:e.jsx(xt,{className:"h-5 w-5"})})]})]}),e.jsx("iframe",{ref:D,className:"flex-1 w-full border-0",title:"Statement Preview","data-testid":"preview-iframe"})]})}),n&&e.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>o(!1)}),r&&e.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>c(!1)})]})}const ke="#c5a059",wt="#cd2122";function u(a,t=2){if(a==null||a==="")return"—";const s=typeof a=="string"?parseFloat(a):a;return isNaN(s)?"—":s.toLocaleString("en-US",{minimumFractionDigits:t,maximumFractionDigits:t})}function L(a,t=2){return a==null?"—":`${a>=0?"+":""}${u(a,t)}%`}function Fe(a){return a?new Date(a).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"—"}const kt=[{value:"1M",label:"1 Month"},{value:"3M",label:"3 Months"},{value:"QTD",label:"Quarter to Date"},{value:"YTD",label:"Year to Date"},{value:"1Y",label:"1 Year"},{value:"2Y",label:"2 Years"},{value:"3Y",label:"3 Years"},{value:"5Y",label:"5 Years"},{value:"R12M",label:"Rolling 12 Months"},{value:"SI",label:"Since Inception"},{value:"custom",label:"Custom Date Range"}],oe=["#c5a059","#cd2122","#2563eb","#16a34a","#9333ea","#ea580c","#0891b2","#be185d","#65a30d","#6366f1","#d97706","#475569","#dc2626","#0d9488","#7c3aed"];function Te({slices:a,title:t}){return a.length?e.jsxs("div",{className:"space-y-2","data-testid":`allocation-${t.toLowerCase().replace(/\s/g,"-")}`,children:[e.jsx("h4",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider",children:t}),e.jsx("div",{className:"flex h-6 rounded-md overflow-hidden border border-border",children:a.map((s,n)=>e.jsx("div",{style:{width:`${Math.max(s.pct,1)}%`,backgroundColor:oe[n%oe.length]},className:"relative group",title:`${s.name}: ${u(s.pct)}%`,children:s.pct>8&&e.jsxs("span",{className:"absolute inset-0 flex items-center justify-center text-[9px] font-bold text-white truncate px-1",children:[u(s.pct,1),"%"]})},s.name))}),e.jsx("div",{className:"flex flex-wrap gap-x-4 gap-y-1",children:a.map((s,n)=>e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm flex-shrink-0",style:{backgroundColor:oe[n%oe.length]}}),e.jsx("span",{className:"text-slate-700 font-medium",children:s.name}),e.jsxs("span",{className:"text-slate-400",children:[u(s.pct,1),"%"]}),e.jsxs("span",{className:"text-slate-400",children:["($",u(s.value),")"]})]},s.name))})]}):null}function ce({slices:a,size:t=160}){const s=t/2-8,n=t/2,o=t/2;let r=-90;const c=a.map((h,x)=>{const p=h.pct/100*360,f=r*Math.PI/180,m=(r+p)*Math.PI/180;r+=p;const i=n+s*Math.cos(f),I=o+s*Math.sin(f),F=n+s*Math.cos(m),w=o+s*Math.sin(m),N=p>180?1:0,D=s*.55,y=n+D*Math.cos(m),B=o+D*Math.sin(m),le=n+D*Math.cos(f),U=o+D*Math.sin(f),G=`M ${i} ${I} A ${s} ${s} 0 ${N} 1 ${F} ${w} L ${y} ${B} A ${D} ${D} 0 ${N} 0 ${le} ${U} Z`;return e.jsx("path",{d:G,fill:oe[x%oe.length],stroke:"white",strokeWidth:"1",children:e.jsxs("title",{children:[h.name,": ",u(h.pct,1),"%"]})},x)});return e.jsx("svg",{width:t,height:t,viewBox:`0 0 ${t} ${t}`,children:a.length>0?c:e.jsx("circle",{cx:n,cy:o,r:s,fill:"#e2e8f0"})})}function T({children:a,className:t=""}){return e.jsx("div",{className:`rounded-lg border border-slate-200 shadow-sm overflow-hidden ${t}`,style:{background:"linear-gradient(180deg, #ffffff 0%, #f8fafc 100%)"},children:a})}function $({icon:a,title:t,sub:s}){return e.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b",style:{borderColor:"#e2e8f0",background:"linear-gradient(90deg, #f1f5f9 0%, #f8fafc 100%)"},children:[e.jsx("div",{className:"flex items-center justify-center h-7 w-7 rounded-md",style:{backgroundColor:"rgba(197, 160, 89, 0.12)"},children:e.jsx(a,{className:"h-4 w-4",style:{color:ke}})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-[13px] font-extrabold tracking-tight",style:{color:"#2d1a0e"},children:t}),s&&e.jsx("p",{className:"text-[10px] text-slate-400 -mt-0.5",children:s})]})]})}function v({label:a,value:t,sub:s,icon:n,color:o,trend:r}){return e.jsxs("div",{className:"rounded-lg border border-slate-200 p-3 space-y-1 shadow-sm",style:{background:"linear-gradient(135deg, #ffffff 0%, #f9f6f1 100%)"},"data-testid":`metric-${a.toLowerCase().replace(/\s/g,"-")}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:a}),n&&e.jsx(n,{className:"h-3.5 w-3.5",style:{color:"rgba(197, 160, 89, 0.4)"}})]}),e.jsxs("div",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-lg font-extrabold tracking-tight",style:{color:o||"#1e293b"},children:t}),r&&(r==="up"?e.jsx(qe,{className:"h-3.5 w-3.5 text-emerald-500"}):r==="down"?e.jsx(De,{className:"h-3.5 w-3.5 text-red-500"}):null)]}),s&&e.jsx("p",{className:"text-[10px] font-medium",style:{color:"#9c8e78"},children:s})]})}function Ct({monthlyReturns:a}){if(!a.length)return null;const t=[...new Set(a.map(n=>n.month.split("-")[0]))],s=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return e.jsx("div",{className:"overflow-x-auto","data-testid":"return-heatmap",children:e.jsxs("table",{className:"text-[10px]",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-2 py-1 text-left text-slate-500 font-bold",children:"Year"}),s.map(n=>e.jsx("th",{className:"px-2 py-1 text-center text-slate-500 font-bold",children:n},n)),e.jsx("th",{className:"px-2 py-1 text-center text-slate-500 font-bold",children:"Annual"})]})}),e.jsx("tbody",{children:t.map(n=>{let o=1;return e.jsxs("tr",{children:[e.jsx("td",{className:"px-2 py-1 font-bold text-slate-700",children:n}),s.map((r,c)=>{const h=`${n}-${String(c+1).padStart(2,"0")}`,x=a.find(m=>m.month===h),p=x?.return||0;x&&(o*=1+p);const f=x?p>.02?"bg-emerald-200 text-emerald-900":p>0?"bg-emerald-100 text-emerald-800":p<-.02?"bg-red-200 text-red-900":p<0?"bg-red-100 text-red-800":"bg-slate-100 text-slate-600":"bg-slate-50";return e.jsx("td",{className:`px-2 py-1 text-center font-mono ${f} border border-white`,children:x?L(p*100,1):""},c)}),e.jsx("td",{className:`px-2 py-1 text-center font-mono font-bold border border-white ${o-1>=0?"bg-emerald-100 text-emerald-900":"bg-red-100 text-red-900"}`,children:L((o-1)*100,1)})]},n)})})]})})}const St=[{id:"summary",label:"Summary",icon:Q},{id:"performance",label:"Performance",icon:W},{id:"holdings",label:"Holdings",icon:me},{id:"allocation",label:"Allocation",icon:Le},{id:"benchmark",label:"Benchmark",icon:ve},{id:"risk",label:"Risk Analytics",icon:Ee},{id:"transactions",label:"Activity",icon:be}];function Rt({accountId:a,onBack:t}){const[s,n]=g.useState("1Y"),[o,r]=g.useState(""),[c,h]=g.useState(""),[x,p]=g.useState("summary"),f=g.useRef(null),m=s==="custom"?`?startDate=${o}&endDate=${c}`:`?period=${s}`,{data:i,isLoading:I,error:F}=z({queryKey:["/api/staff/subledger/statement",a,s,o,c],queryFn:async()=>{const N=await fetch(`/api/staff/subledger/statement/${a}${m}`,{credentials:"include"});if(!N.ok)throw new Error(await N.text());return N.json()},enabled:s!=="custom"||!!o&&!!c});if(I)return e.jsxs("div",{className:"flex items-center justify-center py-24 text-slate-400",children:[e.jsx(P,{className:"h-6 w-6 animate-spin mr-3"}),e.jsx("span",{children:"Generating statement..."})]});if(F)return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(C,{variant:"ghost",onClick:t,className:"gap-2","data-testid":"button-back-statement",children:[e.jsx(Je,{className:"h-4 w-4"})," Back"]}),e.jsxs("div",{className:"text-center py-12 text-red-500",children:[e.jsx(ge,{className:"h-8 w-8 mx-auto mb-2"}),e.jsx("p",{children:"Failed to generate statement"}),e.jsx("p",{className:"text-xs text-slate-400 mt-1",children:F.message})]})]});const w=i;return w?e.jsxs("div",{className:"space-y-4",ref:f,"data-testid":"statement-panel",children:[e.jsxs("div",{className:"rounded-2xl p-5 relative overflow-hidden",style:{background:"linear-gradient(135deg, #cd2122, #8b1a1a)",boxShadow:"0 8px 32px rgba(205,33,34,0.35)"},children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.07]",style:{backgroundImage:"radial-gradient(circle at 20% 50%, white 1px, transparent 1px), radial-gradient(circle at 80% 20%, white 1px, transparent 1px)",backgroundSize:"60px 60px, 40px 40px"}}),e.jsxs("div",{className:"relative flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(C,{variant:"ghost",size:"sm",onClick:t,className:"gap-1 border border-white/20 text-white hover:bg-white/10","data-testid":"button-back-statement",children:[e.jsx(Je,{className:"h-4 w-4"})," Back"]}),e.jsx("div",{className:"rounded-2xl flex items-center justify-center shrink-0",style:{width:52,height:52,background:"rgba(255,255,255,0.18)",border:"1px solid rgba(255,255,255,0.25)",backdropFilter:"blur(8px)",boxShadow:"0 4px 16px rgba(0,0,0,0.15)"},children:e.jsx(Q,{className:"h-6 w-6 text-[#c5a059]"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-black text-white tracking-tight",children:"Client Statement"}),e.jsxs("p",{className:"text-sm",style:{color:"rgba(255,255,255,0.7)"},children:[w.account?.name," (",w.account?.code,") · ",w.account?.currency]})]})]}),e.jsxs("div",{className:"relative flex items-center gap-2 flex-wrap",children:[e.jsxs(ee,{value:s,onValueChange:n,children:[e.jsx(te,{className:"w-[180px] text-xs h-8 border-white/20 bg-white/10 text-white","data-testid":"select-period",children:e.jsx(ae,{placeholder:"Select period"})}),e.jsx(se,{children:kt.map(N=>e.jsx(R,{value:N.value,children:N.label},N.value))})]}),s==="custom"&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(S,{type:"date",value:o,onChange:N=>r(N.target.value),className:"h-8 text-xs w-32 border-white/20 bg-white/10 text-white","data-testid":"input-custom-start"}),e.jsx("span",{className:"text-xs text-white/60",children:"to"}),e.jsx(S,{type:"date",value:c,onChange:N=>h(N.target.value),className:"h-8 text-xs w-32 border-white/20 bg-white/10 text-white","data-testid":"input-custom-end"})]}),e.jsx(vt,{statement:w,printRef:f})]})]})]}),e.jsxs("div",{className:"rounded-xl border shadow-md overflow-hidden",style:{borderColor:"#c5a05940",background:"linear-gradient(135deg, #2d1a0e 0%, #4a2a14 40%, #5c3318 100%)"},children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4 px-5 py-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-widest font-bold",style:{color:"#c5a059"},children:"Report Period"}),e.jsxs("p",{className:"text-base font-extrabold text-white tracking-tight mt-0.5",children:[Fe(w.reportPeriod?.startDate)," — ",Fe(w.reportPeriod?.endDate)]}),e.jsxs("p",{className:"text-[10px] font-medium",style:{color:"#c5a05999"},children:[w.reportPeriod?.days," calendar days · Generated ",new Date(w.generatedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-widest font-bold",style:{color:"#c5a059"},children:"Total Portfolio Value"}),e.jsxs("p",{className:"text-3xl font-black tracking-tight text-white mt-0.5",children:["$",u(w.summary?.totalMarketValue)]}),e.jsxs("p",{className:`text-sm font-bold mt-0.5 ${(w.summary?.totalReturnPct||0)>=0?"text-emerald-400":"text-red-400"}`,children:[L(w.summary?.totalReturnPct)," total return"]})]})]}),e.jsx("div",{className:"h-1",style:{background:`linear-gradient(90deg, ${ke}, ${wt}, ${ke})`}})]}),e.jsx("div",{className:"flex gap-0.5 flex-wrap pb-0",style:{borderBottom:"2px solid #e2e8f0"},children:St.map(N=>{const D=N.icon,y=x===N.id;return e.jsxs("button",{type:"button",onClick:()=>p(N.id),className:`flex items-center gap-1.5 px-3.5 py-2 text-xs font-bold transition-all relative ${y?"text-[#2d1a0e]":"text-slate-400 hover:text-slate-600"}`,style:y?{borderBottom:`2px solid ${ke}`,marginBottom:"-2px"}:{marginBottom:"-2px"},"data-testid":`tab-stmt-${N.id}`,children:[e.jsx(D,{className:"h-3.5 w-3.5",style:y?{color:ke}:void 0}),N.label]},N.id)})}),x==="summary"&&e.jsx(At,{s:w}),x==="performance"&&e.jsx(Tt,{s:w}),x==="holdings"&&e.jsx($t,{s:w}),x==="allocation"&&e.jsx(Dt,{s:w}),x==="benchmark"&&e.jsx(Pt,{s:w}),x==="risk"&&e.jsx(Et,{s:w}),x==="transactions"&&e.jsx(Lt,{s:w}),e.jsxs("div",{className:"text-center pt-4 border-t border-border",children:[e.jsxs("p",{className:"text-[9px] text-slate-400",children:["Statement generated ",new Date(w.generatedAt).toLocaleString()," · Alhambra Bank & Trust Limited · Confidential"]}),e.jsx("p",{className:"text-[9px] text-slate-400",children:"Past performance does not guarantee future results. Values are based on available subledger data."})]})]}):null}function At({s:a}){const t=a.summary||{};return e.jsxs("div",{className:"space-y-5","data-testid":"tab-content-summary",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsx(v,{label:"Market Value",value:`$${u(t.totalMarketValue)}`,icon:me}),e.jsx(v,{label:"Cost Basis",value:`$${u(t.totalCostBasis)}`,icon:me,color:"#6366f1"}),e.jsx(v,{label:"Unrealized P&L",value:`$${u(t.totalUnrealizedPnl)}`,icon:W,color:(t.totalUnrealizedPnl||0)>=0?"#16a34a":"#dc2626",trend:(t.totalUnrealizedPnl||0)>=0?"up":"down"}),e.jsx(v,{label:"Total Return",value:L(t.totalReturnPct),icon:ve,color:(t.totalReturnPct||0)>=0?"#16a34a":"#dc2626",trend:(t.totalReturnPct||0)>=0?"up":"down"}),e.jsx(v,{label:"IRR",value:L(t.irr),icon:be,sub:"Internal Rate of Return"}),e.jsx(v,{label:"TWRR",value:L(t.twrr),icon:ye,sub:"Time-Weighted Return"}),e.jsx(v,{label:"MWRR",value:L(t.mwrr),icon:Ue,sub:"Dollar-Weighted Return"}),e.jsx(v,{label:"Holdings",value:`${t.holdingsCount||0}`,icon:Ie,sub:"Active positions"})]}),a.performance?.periods?.length>0&&e.jsxs(T,{children:[e.jsx($,{icon:W,title:"Performance by Period"}),e.jsx("div",{className:"overflow-x-auto p-4",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"#f1f5f9"},children:[e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Period"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"TWRR"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"MWRR"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Annualized"})]})}),e.jsx("tbody",{children:a.performance.periods.map((s,n)=>e.jsxs("tr",{className:"border-b",style:{borderColor:"#e2e8f0"},"data-testid":`row-period-${s.label}`,children:[e.jsx("td",{className:"px-3 py-2 font-bold",style:{color:"#2d1a0e"},children:s.label}),e.jsx("td",{className:`px-3 py-2 text-right font-mono font-bold ${(s.twrr||0)>=0?"text-emerald-600":"text-red-600"}`,children:L(s.twrr*100)}),e.jsx("td",{className:`px-3 py-2 text-right font-mono ${(s.mwrr||0)>=0?"text-emerald-600":"text-red-600"}`,children:L(s.mwrr*100)}),e.jsx("td",{className:"px-3 py-2 text-right font-mono text-slate-500",children:s.annualized?L(s.annualizedReturn*100):"N/A"})]},n))})]})})]}),a.allocation?.assetClass?.length>0&&e.jsxs(T,{children:[e.jsx($,{icon:Le,title:"Asset Class Overview"}),e.jsxs("div",{className:"flex items-center gap-6 flex-wrap p-4",children:[e.jsx(ce,{slices:a.allocation.assetClass}),e.jsx("div",{className:"flex-1 min-w-[200px]",children:e.jsx(Te,{slices:a.allocation.assetClass,title:"Asset Class Breakdown"})})]})]}),a.risk&&e.jsxs(T,{children:[e.jsx($,{icon:Ee,title:"Key Risk Metrics"}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsx(v,{label:"Std Deviation",value:u(a.risk.standardDeviation)+"%",sub:"Annualized"}),e.jsx(v,{label:"Max Drawdown",value:u(a.risk.maxDrawdown)+"%",color:"#dc2626"}),e.jsx(v,{label:"Sharpe Ratio",value:u(a.risk.sharpeRatio)}),e.jsx(v,{label:"Beta",value:u(a.risk.beta)})]})]})]})}function Tt({s:a}){const t=a.performance||{};return e.jsxs("div",{className:"space-y-5","data-testid":"tab-content-performance",children:[e.jsxs(T,{children:[e.jsx($,{icon:ye,title:"Return Summary by Period"}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-slate-50 border-b border-border",children:[e.jsx("th",{className:"px-3 py-2 text-left font-bold text-slate-500 uppercase tracking-wider",children:"Period"}),e.jsx("th",{className:"px-3 py-2 text-center font-bold text-slate-500 uppercase tracking-wider",children:"Days"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold text-slate-500 uppercase tracking-wider",children:"Time-Weighted (TWRR)"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold text-slate-500 uppercase tracking-wider",children:"Dollar-Weighted (MWRR)"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold text-slate-500 uppercase tracking-wider",children:"Annualized"})]})}),e.jsx("tbody",{children:(t.periods||[]).map((s,n)=>e.jsxs("tr",{className:"border-b border-border bg-white hover:bg-slate-50",children:[e.jsx("td",{className:"px-3 py-2 font-bold text-slate-700",children:s.label}),e.jsx("td",{className:"px-3 py-2 text-center text-slate-500",children:s.days}),e.jsx("td",{className:`px-3 py-2 text-right font-mono font-bold ${(s.twrr||0)>=0?"text-emerald-600":"text-red-600"}`,children:L(s.twrr*100)}),e.jsx("td",{className:`px-3 py-2 text-right font-mono ${(s.mwrr||0)>=0?"text-emerald-600":"text-red-600"}`,children:L(s.mwrr*100)}),e.jsx("td",{className:"px-3 py-2 text-right font-mono text-slate-500",children:s.annualized?L(s.annualizedReturn*100):"—"})]},n))})]})})]}),t.monthlyReturns?.length>0&&e.jsxs(T,{children:[e.jsx($,{icon:pt,title:"Monthly Return Heatmap"}),e.jsx("div",{className:"p-4",children:e.jsx(Ct,{monthlyReturns:t.monthlyReturns})})]}),t.quarterlyReturns?.length>0&&e.jsxs(T,{children:[e.jsx($,{icon:Ue,title:"Quarterly Returns"}),e.jsx("div",{className:"flex items-end gap-2 h-32 px-4 py-4",children:(t.quarterlyReturns||[]).map((s,n)=>{const o=Math.max(...t.quarterlyReturns.map(h=>Math.abs(h.return)),.01),r=Math.abs(s.return)/o*100,c=s.return>=0;return e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-end gap-0.5","data-testid":`bar-quarter-${s.quarter}`,children:[e.jsx("span",{className:`text-[9px] font-mono font-bold ${c?"text-emerald-600":"text-red-600"}`,children:L(s.return*100,1)}),e.jsx("div",{className:`w-full rounded-t ${c?"bg-emerald-400":"bg-red-400"}`,style:{height:`${Math.max(r,4)}%`}}),e.jsx("span",{className:"text-[8px] font-bold",style:{color:"#8c7a5e"},children:s.quarter})]},n)})})]}),t.yearlyReturns?.length>0&&e.jsxs(T,{children:[e.jsx($,{icon:ye,title:"Annual Returns"}),e.jsx("div",{className:"overflow-x-auto p-4",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"#f1f5f9"},children:[e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase",style:{color:"#8c7a5e"},children:"Year"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase",style:{color:"#8c7a5e"},children:"Return"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase",style:{color:"#8c7a5e"},children:"Visual"})]})}),e.jsx("tbody",{children:t.yearlyReturns.map((s,n)=>{const o=Math.max(...t.yearlyReturns.map(c=>Math.abs(c.return)),.01),r=Math.abs(s.return)/o*100;return e.jsxs("tr",{className:"border-b",style:{borderColor:"#e2e8f0"},children:[e.jsx("td",{className:"px-3 py-2 font-bold",style:{color:"#2d1a0e"},children:s.year}),e.jsx("td",{className:`px-3 py-2 text-right font-mono font-bold ${s.return>=0?"text-emerald-600":"text-red-600"}`,children:L(s.return*100)}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("div",{className:"h-3 rounded",style:{width:`${Math.max(r,4)}%`,backgroundColor:s.return>=0?"#10b981":"#ef4444"}})})]},n)})})]})})]})]})}function $t({s:a}){const t=a.holdings||[],[s,n]=g.useState("marketValue"),[o,r]=g.useState("desc"),c=g.useMemo(()=>[...t].sort((x,p)=>{const f=x[s]||0,m=p[s]||0;return o==="desc"?m-f:f-m}),[t,s,o]),h=x=>{s===x?r(p=>p==="desc"?"asc":"desc"):(n(x),r("desc"))};return e.jsxs("div",{className:"space-y-4","data-testid":"tab-content-holdings",children:[e.jsxs(T,{children:[e.jsx($,{icon:Ie,title:"Holdings Detail"}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"#f1f5f9"},children:[e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Ticker"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Name"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Asset Class"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase tracking-wider cursor-pointer",style:{color:"#8c7a5e"},onClick:()=>h("quantity"),children:"Quantity"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase tracking-wider cursor-pointer",style:{color:"#8c7a5e"},onClick:()=>h("closingPrice"),children:"Price"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase tracking-wider cursor-pointer",style:{color:"#8c7a5e"},onClick:()=>h("costBasis"),children:"Cost Basis"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase tracking-wider cursor-pointer",style:{color:"#8c7a5e"},onClick:()=>h("marketValue"),children:"Mkt Value"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase tracking-wider cursor-pointer",style:{color:"#8c7a5e"},onClick:()=>h("unrealizedPnl"),children:"Unreal. P&L"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase tracking-wider cursor-pointer",style:{color:"#8c7a5e"},onClick:()=>h("unrealizedPnlPct"),children:"Return %"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase tracking-wider cursor-pointer",style:{color:"#8c7a5e"},onClick:()=>h("weight"),children:"Weight"})]})}),e.jsx("tbody",{children:c.map((x,p)=>e.jsxs("tr",{className:"border-b hover:bg-[#f8fafc]",style:{borderColor:"#e2e8f0"},"data-testid":`row-holding-${x.ticker}`,children:[e.jsx("td",{className:"px-3 py-2 font-mono font-bold",style:{color:ke},children:x.ticker}),e.jsx("td",{className:"px-3 py-2 font-medium",style:{color:"#2d1a0e"},children:x.name}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-bold",style:{background:"#f1f5f9",color:"#8c7a5e"},children:x.assetClass})}),e.jsx("td",{className:"px-3 py-2 text-right font-mono",style:{color:"#2d1a0e"},children:u(x.quantity,4)}),e.jsxs("td",{className:"px-3 py-2 text-right font-mono",style:{color:"#2d1a0e"},children:["$",u(x.closingPrice)]}),e.jsxs("td",{className:"px-3 py-2 text-right font-mono text-slate-600",children:["$",u(x.costBasis)]}),e.jsxs("td",{className:"px-3 py-2 text-right font-mono font-bold",style:{color:"#2d1a0e"},children:["$",u(x.marketValue)]}),e.jsxs("td",{className:`px-3 py-2 text-right font-mono font-bold ${(x.unrealizedPnl||0)>=0?"text-emerald-600":"text-red-600"}`,children:["$",u(x.unrealizedPnl)]}),e.jsx("td",{className:`px-3 py-2 text-right font-mono font-bold ${(x.unrealizedPnlPct||0)>=0?"text-emerald-600":"text-red-600"}`,children:L(x.unrealizedPnlPct)}),e.jsxs("td",{className:"px-3 py-2 text-right font-mono text-slate-500",children:[u(x.weight,1),"%"]})]},x.instrumentId||p))}),e.jsx("tfoot",{children:e.jsxs("tr",{className:"font-bold text-xs",style:{background:"#f1f5f9",borderTop:"2px solid #c5a059"},children:[e.jsx("td",{className:"px-3 py-2",style:{color:"#2d1a0e"},colSpan:5,children:"PORTFOLIO TOTAL"}),e.jsxs("td",{className:"px-3 py-2 text-right font-mono",style:{color:"#2d1a0e"},children:["$",u(a.summary?.totalCostBasis)]}),e.jsxs("td",{className:"px-3 py-2 text-right font-mono",style:{color:"#2d1a0e"},children:["$",u(a.summary?.totalMarketValue)]}),e.jsxs("td",{className:`px-3 py-2 text-right font-mono ${(a.summary?.totalUnrealizedPnl||0)>=0?"text-emerald-600":"text-red-600"}`,children:["$",u(a.summary?.totalUnrealizedPnl)]}),e.jsx("td",{className:`px-3 py-2 text-right font-mono ${(a.summary?.totalReturnPct||0)>=0?"text-emerald-600":"text-red-600"}`,children:L(a.summary?.totalReturnPct)}),e.jsx("td",{className:"px-3 py-2 text-right font-mono",style:{color:"#2d1a0e"},children:"100.0%"})]})})]})})]}),!t.length&&e.jsxs("div",{className:"text-center py-12 text-slate-400",children:[e.jsx(me,{className:"h-8 w-8 mx-auto mb-2 opacity-30"}),e.jsx("p",{className:"text-sm",children:"No holdings found for this period"})]})]})}function Dt({s:a}){const t=a.allocation||{};return e.jsxs("div",{className:"space-y-5","data-testid":"tab-content-allocation",children:[e.jsxs(T,{children:[e.jsx($,{icon:Le,title:"Asset Class Allocation"}),e.jsxs("div",{className:"flex items-center gap-6 flex-wrap p-4",children:[e.jsx(ce,{slices:t.assetClass||[],size:180}),e.jsxs("div",{className:"flex-1 min-w-[250px]",children:[e.jsx(Te,{slices:t.assetClass||[],title:"By Asset Class"}),e.jsx("div",{className:"mt-3",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:"1px solid #e2e8f0"},children:[e.jsx("th",{className:"px-2 py-1 text-left font-bold",style:{color:"#8c7a5e"},children:"Class"}),e.jsx("th",{className:"px-2 py-1 text-right font-bold",style:{color:"#8c7a5e"},children:"Value"}),e.jsx("th",{className:"px-2 py-1 text-right font-bold",style:{color:"#8c7a5e"},children:"Weight"})]})}),e.jsx("tbody",{children:(t.assetClass||[]).map((s,n)=>e.jsxs("tr",{className:"border-b",style:{borderColor:"#e2e8f0"},children:[e.jsxs("td",{className:"px-2 py-1 flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2 h-2 rounded-sm",style:{backgroundColor:oe[n%oe.length]}}),e.jsx("span",{className:"font-medium",style:{color:"#2d1a0e"},children:s.name})]}),e.jsxs("td",{className:"px-2 py-1 text-right font-mono text-slate-600",children:["$",u(s.value)]}),e.jsxs("td",{className:"px-2 py-1 text-right font-mono font-bold",style:{color:"#2d1a0e"},children:[u(s.pct,1),"%"]})]},s.name))})]})})]})]})]}),e.jsxs(T,{children:[e.jsx($,{icon:Ie,title:"Investment Style Allocation"}),e.jsxs("div",{className:"flex items-center gap-6 flex-wrap p-4",children:[e.jsx(ce,{slices:t.style||[],size:180}),e.jsxs("div",{className:"flex-1 min-w-[250px]",children:[e.jsx(Te,{slices:t.style||[],title:"By Style"}),e.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-2 text-[10px]",children:[e.jsxs("div",{className:"rounded p-2 text-center",style:{background:"#f1f5f9"},children:[e.jsx("p",{className:"font-bold",style:{color:"#8c7a5e"},children:"Value"}),e.jsxs("p",{className:"font-bold",style:{color:"#2d1a0e"},children:[u((t.style||[]).filter(s=>s.name.includes("Value")).reduce((s,n)=>s+n.pct,0),1),"%"]})]}),e.jsxs("div",{className:"rounded p-2 text-center",style:{background:"#f1f5f9"},children:[e.jsx("p",{className:"font-bold",style:{color:"#8c7a5e"},children:"Blend"}),e.jsxs("p",{className:"font-bold",style:{color:"#2d1a0e"},children:[u((t.style||[]).filter(s=>s.name.includes("Blend")||!s.name.includes("Value")&&!s.name.includes("Growth")).reduce((s,n)=>s+n.pct,0),1),"%"]})]}),e.jsxs("div",{className:"rounded p-2 text-center",style:{background:"#f1f5f9"},children:[e.jsx("p",{className:"font-bold",style:{color:"#8c7a5e"},children:"Growth"}),e.jsxs("p",{className:"font-bold",style:{color:"#2d1a0e"},children:[u((t.style||[]).filter(s=>s.name.includes("Growth")).reduce((s,n)=>s+n.pct,0),1),"%"]})]})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs(T,{children:[e.jsx($,{icon:mt,title:"Country / Region Allocation"}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx(ce,{slices:t.country||[],size:150}),e.jsx(Te,{slices:t.country||[],title:"By Country"})]})]}),e.jsxs(T,{children:[e.jsx($,{icon:ie,title:"Sector Allocation"}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx(ce,{slices:t.sector||[],size:150}),e.jsx(Te,{slices:t.sector||[],title:"By Sector"})]})]})]})]})}const Ve=[{name:"Global 60/40",slices:[{name:"US Large Cap Equity",pct:36},{name:"International Developed Equity",pct:15.5},{name:"Emerging Markets Equity",pct:5},{name:"US Small/Mid Cap Equity",pct:3.5},{name:"US Aggregate Bond",pct:24},{name:"International Bond",pct:10},{name:"High Yield Bond",pct:4},{name:"Cash & Equivalents",pct:2}]},{name:"Conservative 30/70",slices:[{name:"US Large Cap Equity",pct:18},{name:"International Equity",pct:8},{name:"Small Cap Equity",pct:4},{name:"US Aggregate Bond",pct:35},{name:"Global Bond",pct:20},{name:"TIPS / Inflation-Protected",pct:10},{name:"Cash & Equivalents",pct:5}]},{name:"Aggressive Growth",slices:[{name:"US Large Cap Growth",pct:30},{name:"US Large Cap Value",pct:15},{name:"US Small Cap",pct:12},{name:"International Developed",pct:18},{name:"Emerging Markets",pct:12},{name:"Real Assets / Commodities",pct:5},{name:"High Yield Bond",pct:5},{name:"Cash",pct:3}]},{name:"Global Bond",slices:[{name:"US Treasury",pct:25},{name:"US Investment Grade Corporate",pct:20},{name:"US Mortgage-Backed (MBS)",pct:15},{name:"International Government Bond",pct:15},{name:"Emerging Markets Bond",pct:8},{name:"High Yield Corporate",pct:7},{name:"TIPS / Inflation-Linked",pct:5},{name:"Cash & Money Market",pct:5}]},{name:"Endowment Model",slices:[{name:"US Equity",pct:20},{name:"International Equity",pct:15},{name:"Private Equity / Alternatives",pct:20},{name:"Real Assets",pct:10},{name:"Hedge Funds",pct:10},{name:"Fixed Income",pct:15},{name:"Natural Resources",pct:5},{name:"Cash",pct:5}]},{name:"Income Focused",slices:[{name:"Dividend Equity",pct:20},{name:"REITs",pct:10},{name:"Preferred Stock",pct:8},{name:"Investment Grade Bond",pct:25},{name:"High Yield Bond",pct:12},{name:"Emerging Market Debt",pct:8},{name:"MLPs / Infrastructure",pct:7},{name:"TIPS",pct:5},{name:"Cash",pct:5}]},{name:"US Equity Only",slices:[{name:"S&P 500 / Large Cap",pct:50},{name:"Mid Cap",pct:20},{name:"Small Cap Value",pct:10},{name:"Small Cap Growth",pct:10},{name:"REITs",pct:5},{name:"Cash",pct:5}]},{name:"Risk Parity",slices:[{name:"US Equity",pct:15},{name:"International Equity",pct:10},{name:"Long-Term Treasuries",pct:30},{name:"TIPS",pct:15},{name:"Commodities",pct:15},{name:"Gold",pct:10},{name:"Cash",pct:5}]}],re=["#2563eb","#16a34a","#c5a059","#9333ea","#ea580c","#0891b2","#be185d","#65a30d","#6366f1","#d97706","#475569","#dc2626","#0d9488","#7c3aed","#cd2122"];function Pt({s:a}){const[t,s]=g.useState(""),[n,o]=g.useState([{name:"US Large Cap Equity",pct:36},{name:"International Developed Equity",pct:15.5},{name:"Emerging Markets Equity",pct:5},{name:"US Small/Mid Cap Equity",pct:3.5},{name:"US Aggregate Bond",pct:24},{name:"International Bond",pct:10},{name:"High Yield Bond",pct:4},{name:"Cash & Equivalents",pct:2}]),r=n.reduce((l,d)=>l+d.pct,0),c=Math.abs(r-100)<.1,h=a.allocation?.assetClass||[],x=l=>{const d=Ve.find(b=>b.name===l);d&&(o(d.slices.map(b=>({...b}))),s(l))},p=(l,d)=>{o(b=>b.map((E,he)=>he===l?{...E,pct:Math.max(0,Math.min(100,d))}:E))},f=(l,d)=>{o(b=>b.map((E,he)=>he===l?{...E,name:d}:E))},m=()=>{const l=Math.max(0,100-r);o(d=>[...d,{name:"New Allocation",pct:l>0?Math.min(l,10):0}])},i=l=>{o(d=>d.filter((b,E)=>E!==l))},I=()=>{r<=0||o(l=>l.map(d=>({...d,pct:Math.round(d.pct/r*1e3)/10})))},F=n.filter(l=>/equity|cap|stock|growth|value|small|mid|large|emerging|international.*eq|reit/i.test(l.name)).reduce((l,d)=>l+d.pct,0),w=n.filter(l=>/bond|fixed|treasury|corporate|mbs|mortgage|tips|inflation|debt|income|yield/i.test(l.name)).reduce((l,d)=>l+d.pct,0),N=n.filter(l=>/alternative|hedge|private|commodity|gold|natural|real.*asset|infrastructure|mlp|preferred/i.test(l.name)).reduce((l,d)=>l+d.pct,0),D=n.filter(l=>/cash|money.*market/i.test(l.name)).reduce((l,d)=>l+d.pct,0),y=100-F-w-N-D,B=h.filter(l=>/equity|etf/i.test(l.name)).reduce((l,d)=>l+d.pct,0),le=h.filter(l=>/fixed|bond/i.test(l.name)).reduce((l,d)=>l+d.pct,0),U=h.filter(l=>/cash/i.test(l.name)).reduce((l,d)=>l+d.pct,0),G=100-B-le-U,ue=[{label:"Equity",portfolio:B,benchmark:F},{label:"Fixed Income",portfolio:le,benchmark:w},{label:"Alternatives",portfolio:0,benchmark:N},{label:"Cash",portfolio:U,benchmark:D},{label:"Other",portfolio:G,benchmark:y>0?y:0}].filter(l=>l.portfolio>.1||l.benchmark>.1);return e.jsxs("div",{className:"space-y-5","data-testid":"tab-content-benchmark",children:[e.jsxs(T,{children:[e.jsx($,{icon:ut,title:"Benchmark Designer"}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsx("div",{className:"flex items-center justify-end gap-2",children:e.jsxs(ee,{value:t,onValueChange:x,children:[e.jsx(te,{className:"w-[200px] text-xs h-8","data-testid":"select-benchmark-preset",children:e.jsx(ae,{placeholder:"Load Preset Benchmark..."})}),e.jsx(se,{children:Ve.map(l=>e.jsx(R,{value:l.name,children:l.name},l.name))})]})}),e.jsx("div",{className:"grid grid-cols-4 gap-2 text-[10px]",children:Ve.map(l=>e.jsxs("button",{type:"button",onClick:()=>x(l.name),className:`p-2 rounded border text-left transition-all ${t===l.name?"border-[#c5a059] bg-[#fdf8ef] shadow-sm":"border-slate-200 hover:border-slate-300"}`,style:t!==l.name?{background:"linear-gradient(180deg, #ffffff 0%, #f8fafc 100%)"}:{},"data-testid":`button-preset-${l.name.replace(/\s+/g,"-").toLowerCase()}`,children:[e.jsx("p",{className:"font-bold truncate",style:{color:"#2d1a0e"},children:l.name}),e.jsxs("p",{className:"mt-0.5",style:{color:"#8c7a5e"},children:[l.slices.length," components"]})]},l.name))})]})]}),e.jsxs(T,{children:[e.jsx($,{icon:Le,title:"Custom Benchmark Allocation"}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between flex-wrap gap-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:`text-xs font-bold px-2 py-0.5 rounded ${c?"bg-emerald-100 text-emerald-800":"bg-amber-100 text-amber-800"}`,"data-testid":"text-benchmark-total",children:[u(r,1),"% ",c?"✓ Balanced":`(${r>100?"Over":"Under"} ${u(Math.abs(100-r),1)}%)`]}),!c&&e.jsxs(C,{variant:"outline",size:"sm",onClick:I,className:"text-[10px] h-7 gap-1","data-testid":"button-normalize",children:[e.jsx(Xe,{className:"h-3 w-3"})," Normalize to 100%"]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:m,className:"text-[10px] h-7 gap-1","data-testid":"button-add-slice",children:[e.jsx(Se,{className:"h-3 w-3"})," Add"]})]})}),e.jsxs("div",{className:"flex gap-6 flex-wrap",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(ce,{slices:n.filter(l=>l.pct>0),size:200})}),e.jsx("div",{className:"flex-1 min-w-[300px] space-y-1.5",children:n.map((l,d)=>e.jsxs("div",{className:"flex items-center gap-2 group","data-testid":`benchmark-slice-${d}`,children:[e.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:re[d%re.length]}}),e.jsx(S,{maxLength:255,value:l.name,onChange:b=>f(d,b.target.value),className:"h-7 text-xs flex-1 min-w-[150px]","data-testid":`input-slice-name-${d}`}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(S,{type:"number",value:l.pct,onChange:b=>p(d,parseFloat(b.target.value)||0),className:"h-7 text-xs w-16 text-right font-mono",step:"0.5",min:"0",max:"100","data-testid":`input-slice-pct-${d}`}),e.jsx("span",{className:"text-[10px] text-slate-400 w-3",children:"%"})]}),e.jsx("input",{type:"range",value:l.pct,onChange:b=>p(d,parseFloat(b.target.value)),min:"0",max:"100",step:"0.5",className:"w-24 h-1.5 accent-[#c5a059] flex-shrink-0","data-testid":`slider-slice-${d}`}),e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>i(d),className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity text-red-400 hover:text-red-600","data-testid":`button-remove-slice-${d}`,children:e.jsx(ht,{className:"h-3 w-3"})})]},d))})]}),e.jsx("div",{className:"flex h-7 rounded-md overflow-hidden border border-border","data-testid":"benchmark-allocation-bar",children:n.filter(l=>l.pct>0).map((l,d)=>e.jsx("div",{style:{width:`${Math.max(l.pct,.5)}%`,backgroundColor:re[d%re.length]},className:"relative group transition-all",title:`${l.name}: ${u(l.pct,1)}%`,children:l.pct>6&&e.jsxs("span",{className:"absolute inset-0 flex items-center justify-center text-[8px] font-bold text-white truncate px-0.5",children:[u(l.pct,0),"%"]})},d))}),e.jsxs("div",{className:"grid grid-cols-4 gap-2 text-[10px] mt-2",children:[e.jsxs("div",{className:"bg-blue-50 rounded p-2 text-center",children:[e.jsx("p",{className:"font-bold text-blue-600",children:"Equity"}),e.jsxs("p",{className:"font-bold text-blue-800",children:[u(F,1),"%"]})]}),e.jsxs("div",{className:"bg-emerald-50 rounded p-2 text-center",children:[e.jsx("p",{className:"font-bold text-emerald-600",children:"Fixed Income"}),e.jsxs("p",{className:"font-bold text-emerald-800",children:[u(w,1),"%"]})]}),e.jsxs("div",{className:"bg-purple-50 rounded p-2 text-center",children:[e.jsx("p",{className:"font-bold text-purple-600",children:"Alternatives"}),e.jsxs("p",{className:"font-bold text-purple-800",children:[u(N,1),"%"]})]}),e.jsxs("div",{className:"bg-slate-50 rounded p-2 text-center",children:[e.jsx("p",{className:"font-bold text-slate-600",children:"Cash"}),e.jsxs("p",{className:"font-bold text-slate-800",children:[u(D,1),"%"]})]})]})]})]}),e.jsxs(T,{children:[e.jsx($,{icon:ye,title:"Portfolio vs. Benchmark Comparison"}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-8 flex-wrap justify-center",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-wider mb-2",style:{color:"#8c7a5e"},children:"Portfolio"}),e.jsx(ce,{slices:h.length>0?h:[{name:"No Data",pct:100}],size:160}),e.jsxs("p",{className:"text-[10px] mt-1",style:{color:"#8c7a5e"},children:[h.length," classes"]})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-wider mb-2",style:{color:"#8c7a5e"},children:"Benchmark"}),e.jsx(ce,{slices:n.filter(l=>l.pct>0),size:160}),e.jsxs("p",{className:"text-[10px] mt-1",style:{color:"#8c7a5e"},children:[n.filter(l=>l.pct>0).length," components"]})]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"#f1f5f9"},children:[e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase",style:{color:"#8c7a5e"},children:"Category"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase",style:{color:"#8c7a5e"},children:"Portfolio %"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase",style:{color:"#8c7a5e"},children:"Benchmark %"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase",style:{color:"#8c7a5e"},children:"Deviation"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase",style:{color:"#8c7a5e"},children:"Visual"})]})}),e.jsx("tbody",{children:ue.map((l,d)=>{const b=l.portfolio-l.benchmark;return e.jsxs("tr",{className:"border-b hover:bg-[#f8fafc]",style:{borderColor:"#e2e8f0"},"data-testid":`row-comparison-${l.label.toLowerCase().replace(/\s/g,"-")}`,children:[e.jsx("td",{className:"px-3 py-2 font-bold",style:{color:"#2d1a0e"},children:l.label}),e.jsxs("td",{className:"px-3 py-2 text-right font-mono",style:{color:"#2d1a0e"},children:[u(l.portfolio,1),"%"]}),e.jsxs("td",{className:"px-3 py-2 text-right font-mono",style:{color:"#2d1a0e"},children:[u(l.benchmark,1),"%"]}),e.jsxs("td",{className:`px-3 py-2 text-right font-mono font-bold ${Math.abs(b)<1?"text-slate-400":b>0?"text-blue-600":"text-amber-600"}`,children:[b>=0?"+":"",u(b,1),"%"]}),e.jsx("td",{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center gap-1 h-4",children:[e.jsx("div",{className:"h-3 rounded bg-blue-400",style:{width:`${Math.max(l.portfolio*.8,2)}px`},title:"Portfolio"}),e.jsx("div",{className:"h-3 rounded bg-slate-300 border border-slate-400 border-dashed",style:{width:`${Math.max(l.benchmark*.8,2)}px`},title:"Benchmark"})]})})]},d)})})]})}),e.jsx("div",{className:"flex items-end gap-3 h-40 px-4 pb-2 rounded-lg pt-4",style:{background:"#f1f5f9",border:"1px solid #e2e8f0"},"data-testid":"benchmark-column-chart",children:ue.map((l,d)=>{const b=Math.max(...ue.map(Pe=>Math.max(Pe.portfolio,Pe.benchmark)),1),E=l.portfolio/b*100,he=l.benchmark/b*100;return e.jsxs("div",{className:"flex-1 flex flex-col items-center gap-0.5",children:[e.jsxs("div",{className:"flex items-end gap-0.5 w-full justify-center",style:{height:"100px"},children:[e.jsx("div",{className:"w-[35%] rounded-t bg-blue-500 transition-all relative group",style:{height:`${Math.max(E,3)}%`},children:e.jsxs("span",{className:"absolute -top-4 left-1/2 -translate-x-1/2 text-[8px] font-mono font-bold text-blue-600 whitespace-nowrap",children:[u(l.portfolio,0),"%"]})}),e.jsx("div",{className:"w-[35%] rounded-t bg-slate-300 border border-dashed border-slate-400 transition-all relative group",style:{height:`${Math.max(he,3)}%`},children:e.jsxs("span",{className:"absolute -top-4 left-1/2 -translate-x-1/2 text-[8px] font-mono font-bold text-slate-500 whitespace-nowrap",children:[u(l.benchmark,0),"%"]})})]}),e.jsx("span",{className:"text-[9px] font-bold text-slate-500 text-center leading-tight mt-1",children:l.label})]},d)})}),e.jsxs("div",{className:"flex items-center justify-center gap-4 text-[10px]",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-3 h-3 rounded bg-blue-500"}),e.jsx("span",{className:"font-medium",style:{color:"#8c7a5e"},children:"Portfolio"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-3 h-3 rounded bg-slate-300 border border-dashed border-slate-400"}),e.jsx("span",{className:"font-medium",style:{color:"#8c7a5e"},children:"Benchmark"})]})]})]})]}),e.jsxs(T,{children:[e.jsx($,{icon:Q,title:"Benchmark Detail"}),e.jsx("div",{className:"overflow-x-auto p-4",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"#f1f5f9"},children:[e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase",style:{color:"#8c7a5e"},children:"#"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase",style:{color:"#8c7a5e"},children:"Component"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase",style:{color:"#8c7a5e"},children:"Weight"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase",style:{color:"#8c7a5e"},children:"Bar"})]})}),e.jsx("tbody",{children:n.filter(l=>l.pct>0).sort((l,d)=>d.pct-l.pct).map((l,d)=>e.jsxs("tr",{className:"border-b",style:{borderColor:"#e2e8f0"},"data-testid":`row-bm-detail-${d}`,children:[e.jsx("td",{className:"px-3 py-2",style:{color:"#8c7a5e"},children:d+1}),e.jsxs("td",{className:"px-3 py-2 flex items-center gap-2",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm flex-shrink-0",style:{backgroundColor:re[d%re.length]}}),e.jsx("span",{className:"font-medium",style:{color:"#2d1a0e"},children:l.name})]}),e.jsxs("td",{className:"px-3 py-2 text-right font-mono font-bold",style:{color:"#2d1a0e"},children:[u(l.pct,1),"%"]}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("div",{className:"h-3 rounded",style:{width:`${Math.max(l.pct,2)}%`,backgroundColor:re[d%re.length]}})})]},d))}),e.jsx("tfoot",{children:e.jsxs("tr",{className:"font-bold",style:{background:"#f1f5f9",borderTop:"2px solid #c5a059"},children:[e.jsx("td",{className:"px-3 py-2",style:{color:"#2d1a0e"},colSpan:2,children:"TOTAL"}),e.jsxs("td",{className:`px-3 py-2 text-right font-mono ${c?"text-emerald-600":"text-amber-600"}`,children:[u(r,1),"%"]}),e.jsx("td",{className:"px-3 py-2"})]})})]})})]})]})}function Et({s:a}){const t=a.risk||{};return e.jsxs("div",{className:"space-y-5","data-testid":"tab-content-risk",children:[e.jsxs(T,{children:[e.jsx($,{icon:Ee,title:"Volatility & Risk Measures"}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 p-4",children:[e.jsx(v,{label:"Std Deviation",value:u(t.standardDeviation)+"%",sub:"Annualized volatility",icon:be}),e.jsx(v,{label:"Max Drawdown",value:u(t.maxDrawdown)+"%",sub:"Peak-to-trough",icon:ge,color:"#dc2626"}),e.jsx(v,{label:"Tracking Error",value:u(t.trackingError)+"%",sub:"vs. benchmark",icon:ve}),e.jsx(v,{label:"VaR (95%)",value:u(t.var95)+"%",sub:"Annual Value at Risk",icon:Ee,color:"#9333ea"})]})]}),e.jsxs(T,{children:[e.jsx($,{icon:ye,title:"Risk-Adjusted Return Ratios"}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 p-4",children:[e.jsx(v,{label:"Sharpe Ratio",value:u(t.sharpeRatio),sub:"Excess return / volatility",icon:W}),e.jsx(v,{label:"Sortino Ratio",value:u(t.sortinoRatio),sub:"Return / downside deviation",icon:W}),e.jsx(v,{label:"Treynor Ratio",value:u(t.treynorRatio)+"%",sub:"Return / beta",icon:W}),e.jsx(v,{label:"Calmar Ratio",value:u(t.calmarRatio),sub:"Return / max drawdown",icon:W}),e.jsx(v,{label:"Information Ratio",value:u(t.informationRatio),sub:"Active return / tracking error",icon:ve})]})]}),e.jsxs(T,{children:[e.jsx($,{icon:ve,title:"Market Sensitivity (CAPM)"}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 p-4",children:[e.jsx(v,{label:"Alpha",value:L(t.alpha),sub:"Excess return vs. CAPM",icon:W,color:(t.alpha||0)>=0?"#16a34a":"#dc2626",trend:(t.alpha||0)>=0?"up":"down"}),e.jsx(v,{label:"Beta",value:u(t.beta),sub:"Market sensitivity",icon:be,color:Math.abs(t.beta-1)<.1?"#6366f1":t.beta>1?"#dc2626":"#16a34a"}),e.jsx(v,{label:"R-Squared",value:u(t.rSquared*100)+"%",sub:"Variance explained by market",icon:ve}),e.jsx(v,{label:"CVaR (95%)",value:u(t.cvar95)+"%",sub:"Expected shortfall",icon:ge,color:"#dc2626"})]})]}),e.jsxs(T,{children:[e.jsx($,{icon:Ue,title:"Capture Ratios"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 p-4",children:[e.jsx(v,{label:"Up Capture",value:u(t.upCaptureRatio)+"%",sub:"Participation in up markets",icon:qe,color:"#16a34a",trend:"up"}),e.jsx(v,{label:"Down Capture",value:u(t.downCaptureRatio)+"%",sub:"Exposure in down markets",icon:De,color:"#dc2626",trend:"down"})]})]}),e.jsxs(T,{children:[e.jsx($,{icon:Q,title:"Complete Risk Dashboard"}),e.jsx("div",{className:"overflow-x-auto p-4",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"#f1f5f9"},children:[e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase",style:{color:"#8c7a5e"},children:"Metric"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase",style:{color:"#8c7a5e"},children:"Value"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase",style:{color:"#8c7a5e"},children:"Description"})]})}),e.jsx("tbody",{children:[{metric:"Standard Deviation",value:u(t.standardDeviation)+"%",desc:"Annualized portfolio volatility measuring total risk"},{metric:"Maximum Drawdown",value:u(t.maxDrawdown)+"%",desc:"Largest peak-to-trough decline"},{metric:"Sharpe Ratio",value:u(t.sharpeRatio),desc:"Risk-adjusted return per unit of total risk (vs. risk-free rate)"},{metric:"Sortino Ratio",value:u(t.sortinoRatio),desc:"Return per unit of downside risk only"},{metric:"Alpha (Jensen's)",value:L(t.alpha),desc:"Excess return vs. CAPM expected return"},{metric:"Beta",value:u(t.beta),desc:"Systematic risk / market sensitivity (1.0 = market)"},{metric:"R-Squared",value:u(t.rSquared*100)+"%",desc:"Proportion of variance explained by benchmark"},{metric:"Treynor Ratio",value:u(t.treynorRatio)+"%",desc:"Risk-adjusted return per unit of systematic risk"},{metric:"Information Ratio",value:u(t.informationRatio),desc:"Active return per unit of tracking error"},{metric:"Tracking Error",value:u(t.trackingError)+"%",desc:"Standard deviation of active returns vs. benchmark"},{metric:"Calmar Ratio",value:u(t.calmarRatio),desc:"Annualized return divided by maximum drawdown"},{metric:"Value at Risk (95%)",value:u(t.var95)+"%",desc:"Max expected annual loss at 95% confidence"},{metric:"CVaR / Expected Shortfall (95%)",value:u(t.cvar95)+"%",desc:"Average loss beyond VaR threshold"},{metric:"Up Capture Ratio",value:u(t.upCaptureRatio)+"%",desc:"Portfolio participation in up-market periods"},{metric:"Down Capture Ratio",value:u(t.downCaptureRatio)+"%",desc:"Portfolio exposure in down-market periods"}].map((s,n)=>e.jsxs("tr",{className:"border-b hover:bg-[#f8fafc]",style:{borderColor:"#e2e8f0"},children:[e.jsx("td",{className:"px-3 py-2 font-bold",style:{color:"#2d1a0e"},children:s.metric}),e.jsx("td",{className:"px-3 py-2 text-right font-mono font-bold",style:{color:"#2d1a0e"},children:s.value}),e.jsx("td",{className:"px-3 py-2 max-w-xs",style:{color:"#8c7a5e"},children:s.desc})]},n))})]})})]})]})}function Lt({s:a}){const t=a.transactionSummary||{};return e.jsxs("div",{className:"space-y-4","data-testid":"tab-content-transactions",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[e.jsx(v,{label:"Total Transactions",value:`${t.totalTransactions||0}`,icon:be}),e.jsx(v,{label:"Buys / Deposits",value:`${t.buys||0}`,icon:qe,color:"#16a34a"}),e.jsx(v,{label:"Sells / Withdrawals",value:`${t.sells||0}`,icon:De,color:"#dc2626"}),e.jsx(v,{label:"Dividends",value:`${t.dividends||0}`,icon:me,color:"#c5a059"}),e.jsx(v,{label:"Fees",value:`${t.fees||0}`,icon:ge,color:"#6366f1"})]}),(t.recentTransactions||[]).length>0&&e.jsxs(T,{children:[e.jsx($,{icon:be,title:"Recent Activity"}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"#f1f5f9"},children:[e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase",style:{color:"#8c7a5e"},children:"Date"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase",style:{color:"#8c7a5e"},children:"Type"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase",style:{color:"#8c7a5e"},children:"Reference"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase",style:{color:"#8c7a5e"},children:"Description"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase",style:{color:"#8c7a5e"},children:"Amount"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase",style:{color:"#8c7a5e"},children:"Status"})]})}),e.jsx("tbody",{children:(t.recentTransactions||[]).map((s,n)=>e.jsxs("tr",{className:"border-b hover:bg-[#f8fafc]",style:{borderColor:"#e2e8f0"},"data-testid":`row-stmt-txn-${n}`,children:[e.jsx("td",{className:"px-3 py-2",style:{color:"#8c7a5e"},children:Fe(s.date)}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-bold",style:{background:"#f1f5f9",color:"#8c7a5e"},children:s.type})}),e.jsx("td",{className:"px-3 py-2 font-mono",style:{color:"#8c7a5e"},children:s.ref||"—"}),e.jsx("td",{className:"px-3 py-2 max-w-[200px] truncate",style:{color:"#2d1a0e"},children:s.description||"—"}),e.jsxs("td",{className:`px-3 py-2 text-right font-mono font-bold ${s.amount>=0?"text-slate-800":"text-red-600"}`,children:["$",u(Math.abs(s.amount))]}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-bold ${s.status==="SETTLED"?"bg-emerald-100 text-emerald-800":s.status==="REVERSED"?"bg-red-100 text-red-800":"bg-amber-100 text-amber-800"}`,children:s.status})})]},n))})]})})]}),!(t.recentTransactions||[]).length&&e.jsxs("div",{className:"text-center py-12 text-slate-400",children:[e.jsx(be,{className:"h-8 w-8 mx-auto mb-2 opacity-30"}),e.jsx("p",{className:"text-sm",children:"No transactions in this period"})]})]})}const It=g.lazy(()=>Ze(()=>import("./abt-trading-blotter-B0sG-X-c.js"),__vite__mapDeps([0,1,2]))),Mt=g.lazy(()=>Ze(()=>import("./index-B_1BLMrZ.js").then(a=>a.dj),__vite__mapDeps([1,2]))),q="#c5a059",K="#cd2122";function M(a,t=2){if(a==null||a==="")return"—";const s=typeof a=="string"?parseFloat(a):a;return isNaN(s)?"—":s.toLocaleString("en-US",{minimumFractionDigits:t,maximumFractionDigits:t})}function fe(a){if(a==null||a==="")return"—";const t=typeof a=="string"?parseInt(a,10):a;return isNaN(t)?"—":t.toLocaleString("en-US")}function Z(a){return a?new Date(a).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"—"}function Ce(a){if(!a)return"—";const t=new Date(a);return t.toLocaleDateString("en-US",{month:"short",day:"numeric"})+" "+t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Re({active:a,onClick:t,children:s,testId:n,activeStyle:o,inactiveClass:r}){return e.jsx("button",{type:"button",onClick:t,"data-testid":n,className:`px-3 py-1.5 text-xs font-bold uppercase rounded-md transition-colors ${a?"":r||"text-slate-500 bg-slate-100 border border-slate-200"}`,style:a?o||{background:K,color:"#fff"}:void 0,children:s})}function $e({open:a,onClose:t,title:s,children:n}){return a?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:t,children:e.jsxs("div",{className:"bg-white rounded-md border border-border shadow-lg w-full max-w-lg max-h-[90vh] overflow-y-auto mx-4",onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border",children:[e.jsx("h3",{className:"text-base font-bold text-slate-800",children:s}),e.jsx("button",{type:"button",onClick:t,className:"text-slate-400 text-lg","data-testid":"button-modal-close",children:"×"})]}),e.jsx("div",{className:"px-5 py-4 space-y-4",children:n})]})}):null}function ne({label:a,value:t,icon:s,color:n}){return e.jsxs("div",{className:"rounded-md border border-border p-4 bg-white",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[e.jsx(s,{className:"h-4 w-4",style:{color:n||q}}),e.jsx("span",{className:"text-2xl font-bold text-slate-800",children:t})]}),e.jsx("p",{className:"text-xs text-slate-500",children:a})]})}function pe({status:a}){const s={ACTIVE:{bg:"bg-emerald-100 text-emerald-800",text:"Active"},INACTIVE:{bg:"bg-slate-100 text-slate-600",text:"Inactive"},PENDING:{bg:"bg-amber-100 text-amber-800",text:"Pending"},SETTLED:{bg:"bg-emerald-100 text-emerald-800",text:"Settled"},REVERSED:{bg:"bg-red-100 text-red-800",text:"Reversed"},MANUAL_REVIEW:{bg:"bg-blue-100 text-blue-800",text:"Manual Review"},CLEAN:{bg:"bg-emerald-100 text-emerald-800",text:"Clean"},BREAKS_FOUND:{bg:"bg-red-100 text-red-800",text:"Breaks Found"},RUNNING:{bg:"bg-blue-100 text-blue-800",text:"Running"},INVESTIGATING:{bg:"bg-amber-100 text-amber-800",text:"Investigating"},RESOLVED:{bg:"bg-emerald-100 text-emerald-800",text:"Resolved"},ESCALATED:{bg:"bg-red-100 text-red-800",text:"Escalated"},OPEN:{bg:"bg-amber-100 text-amber-800",text:"Open"},SNAPSHOT_LOCKED:{bg:"bg-blue-100 text-blue-800",text:"Snapshot Locked"},ALLOCATED:{bg:"bg-emerald-100 text-emerald-800",text:"Allocated"},FAILED:{bg:"bg-red-100 text-red-800",text:"Failed"}}[a]||{bg:"bg-slate-100 text-slate-600",text:a};return e.jsx("span",{className:`inline-block px-2 py-0.5 rounded text-[10px] font-bold uppercase ${s.bg}`,children:s.text})}const Bt=[{id:"dashboard",label:"Dashboard",icon:ye},{id:"accounts",label:"Accounts",icon:ie},{id:"instruments",label:"Instruments",icon:_e},{id:"transactions",label:"Transactions",icon:We},{id:"trading-blotter",label:"Trading Blotter",icon:Ie},{id:"positions",label:"Positions",icon:W},{id:"reconciliation",label:"Reconciliation",icon:Ke},{id:"corporate-actions",label:"Corp Actions",icon:me},{id:"statements",label:"Statements",icon:Q},{id:"trial-balance",label:"Trial Balance",icon:ze},{id:"audit-log",label:"Audit Log",icon:Ge},{id:"portfolio-analyst",label:"Portfolio Analyst",icon:ye}];function Vt(){const{data:a,isLoading:t}=z({queryKey:["/api/staff/subledger/dashboard"]});if(t)return e.jsxs("div",{className:"flex items-center justify-center py-16 text-slate-400",children:[e.jsx(P,{className:"h-5 w-5 animate-spin mr-2"})," Loading dashboard..."]});const s=a||{};return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsx(ne,{label:"Total Accounts",value:fe(s.totalAccounts||0),icon:ie}),e.jsx(ne,{label:"Client Accounts",value:fe(s.clientAccounts||0),icon:ie,color:"#3b82f6"}),e.jsx(ne,{label:"System Accounts",value:fe(s.systemAccounts||0),icon:ie,color:"#8b5cf6"}),e.jsx(ne,{label:"Total Transactions",value:fe(s.totalTransactions||0),icon:We}),e.jsx(ne,{label:"Pending Transactions",value:fe(s.pendingTransactions||0),icon:ft,color:"#f59e0b"}),e.jsx(ne,{label:"Instruments",value:fe(s.totalInstruments||0),icon:_e}),e.jsx(ne,{label:"Open Breaks",value:fe(s.openBreaks||0),icon:ge,color:"#ef4444"}),e.jsx(ne,{label:"Total Position Value",value:`$${M(s.totalPositionValue||0)}`,icon:me,color:"#10b981"})]}),s.lastReconciliation&&e.jsxs("div",{className:"rounded-md border border-border p-4 bg-white",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Ke,{className:"h-4 w-4",style:{color:q}}),e.jsx("span",{className:"text-sm font-bold text-slate-800",children:"Last Reconciliation"})]}),e.jsxs("div",{className:"flex items-center gap-4 flex-wrap text-xs text-slate-600",children:[e.jsx(pe,{status:s.lastReconciliation.runStatus||"CLEAN"}),e.jsx("span",{children:Ce(s.lastReconciliation.runCompletedAt||s.lastReconciliation.runStartedAt)}),s.lastReconciliation.totalBreaks!=null&&e.jsxs("span",{children:[s.lastReconciliation.totalBreaks," breaks found"]})]})]})]})}function Ot(){const{toast:a}=Ae(),[t,s]=g.useState("ALL"),[n,o]=g.useState(!1),[r,c]=g.useState({accountCode:"",accountName:"",accountType:"CLIENT",currency:"USD",clientId:""}),{data:h=[],isLoading:x}=z({queryKey:["/api/staff/subledger/accounts"]}),p=de({mutationFn:async m=>{await xe("POST","/api/staff/subledger/accounts",m)},onSuccess:()=>{V.invalidateQueries({queryKey:["/api/staff/subledger/accounts"]}),V.invalidateQueries({queryKey:["/api/staff/subledger/dashboard"]}),a({title:"Account created"}),o(!1),c({accountCode:"",accountName:"",accountType:"CLIENT",currency:"USD",clientId:""})},onError:()=>a({title:"Failed to create account",variant:"destructive"})}),f=t==="ALL"?h:h.filter(m=>m.accountType===t||m.type===t);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsx("div",{className:"flex gap-1 flex-wrap",children:["ALL","CLIENT","SYSTEM","MASTER"].map(m=>e.jsx(Re,{active:t===m,onClick:()=>s(m),testId:`filter-accounts-${m.toLowerCase()}`,children:m},m))}),e.jsxs(C,{onClick:()=>o(!0),className:"gap-1.5 font-bold",style:{background:K,color:"#fff"},"data-testid":"button-new-account",children:[e.jsx(Se,{className:"h-4 w-4"})," New Account"]})]}),x?e.jsxs("div",{className:"flex items-center justify-center py-12 text-slate-400",children:[e.jsx(P,{className:"h-5 w-5 animate-spin mr-2"})," Loading..."]}):f.length===0?e.jsxs("div",{className:"text-center py-12 text-slate-400",children:[e.jsx(ie,{className:"h-8 w-8 mx-auto mb-2 opacity-30"}),e.jsx("p",{className:"text-sm",children:"No accounts found"})]}):e.jsx("div",{className:"overflow-x-auto rounded-md border",style:{borderColor:"#e2e8f0"},children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",style:{background:"#f1f5f9",borderColor:"#e2e8f0"},children:[e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Code"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Name"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Type"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Subtype"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Currency"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Status"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Opened"})]})}),e.jsx("tbody",{children:f.map((m,i)=>e.jsxs("tr",{className:"border-b hover:bg-[#f8fafc]",style:{borderColor:"#e2e8f0"},"data-testid":`row-account-${m.id||i}`,children:[e.jsx("td",{className:"px-3 py-2 font-mono font-bold",style:{color:q},children:m.accountCode||m.code||"—"}),e.jsx("td",{className:"px-3 py-2 text-slate-800 font-medium",children:m.accountName||m.name||"—"}),e.jsx("td",{className:"px-3 py-2 text-slate-600",children:m.accountType||m.type||"—"}),e.jsx("td",{className:"px-3 py-2 text-slate-600",children:m.accountSubtype||m.subtype||"—"}),e.jsx("td",{className:"px-3 py-2 text-slate-600",children:m.currency||"USD"}),e.jsx("td",{className:"px-3 py-2",children:e.jsx(pe,{status:m.isActive?"ACTIVE":"INACTIVE"})}),e.jsx("td",{className:"px-3 py-2 text-slate-500",children:Z(m.openedDate)})]},m.id||i))})]})}),e.jsxs($e,{open:n,onClose:()=>o(!1),title:"New Account",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Account Code"}),e.jsx(S,{maxLength:100,value:r.accountCode,onChange:m=>c({...r,accountCode:m.target.value}),placeholder:"e.g. CLI-001","data-testid":"input-account-code"})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Account Name"}),e.jsx(S,{maxLength:100,value:r.accountName,onChange:m=>c({...r,accountName:m.target.value}),placeholder:"e.g. John Smith Trading","data-testid":"input-account-name"})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Account Type"}),e.jsxs(ee,{value:r.accountType,onValueChange:m=>c({...r,accountType:m}),children:[e.jsx(te,{"data-testid":"select-account-type",children:e.jsx(ae,{})}),e.jsxs(se,{children:[e.jsx(R,{value:"CLIENT",children:"Client"}),e.jsx(R,{value:"SYSTEM",children:"System"}),e.jsx(R,{value:"MASTER",children:"Master"})]})]})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Currency"}),e.jsxs(ee,{value:r.currency,onValueChange:m=>c({...r,currency:m}),children:[e.jsx(te,{"data-testid":"select-account-currency",children:e.jsx(ae,{})}),e.jsxs(se,{children:[e.jsx(R,{value:"USD",children:"USD"}),e.jsx(R,{value:"EUR",children:"EUR"}),e.jsx(R,{value:"GBP",children:"GBP"}),e.jsx(R,{value:"KYD",children:"KYD"})]})]})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Client ID (optional)"}),e.jsx(S,{maxLength:100,value:r.clientId,onChange:m=>c({...r,clientId:m.target.value}),placeholder:"Optional","data-testid":"input-account-client-id"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(C,{variant:"outline",onClick:()=>o(!1),"data-testid":"button-cancel-account",children:"Cancel"}),e.jsx(C,{onClick:()=>p.mutate(r),disabled:p.isPending||!r.accountCode||!r.accountName,style:{background:K,color:"#fff"},"data-testid":"button-submit-account",children:p.isPending?e.jsx(P,{className:"h-4 w-4 animate-spin"}):"Create Account"})]})]})]})}function Ft(){const{toast:a}=Ae(),[t,s]=g.useState("ALL"),[n,o]=g.useState(!1),[r,c]=g.useState({ticker:"",instrumentName:"",assetClass:"EQUITY",cusip:"",isin:"",exchange:"",ibkrConId:""}),{data:h=[],isLoading:x}=z({queryKey:["/api/staff/subledger/instruments"]}),p=de({mutationFn:async i=>{await xe("POST","/api/staff/subledger/instruments",i)},onSuccess:()=>{V.invalidateQueries({queryKey:["/api/staff/subledger/instruments"]}),V.invalidateQueries({queryKey:["/api/staff/subledger/dashboard"]}),a({title:"Instrument created"}),o(!1),c({ticker:"",instrumentName:"",assetClass:"EQUITY",cusip:"",isin:"",exchange:"",ibkrConId:""})},onError:()=>a({title:"Failed to create instrument",variant:"destructive"})}),f=["ALL","EQUITY","FIXED_INCOME","ETF","FUND","CASH","MONEY_MARKET"],m=t==="ALL"?h:h.filter(i=>i.assetClass===t);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsx("div",{className:"flex gap-1 flex-wrap",children:f.map(i=>e.jsx(Re,{active:t===i,onClick:()=>s(i),testId:`filter-instruments-${i.toLowerCase()}`,children:i.replace("_"," ")},i))}),e.jsxs(C,{onClick:()=>o(!0),className:"gap-1.5 font-bold",style:{background:K,color:"#fff"},"data-testid":"button-new-instrument",children:[e.jsx(Se,{className:"h-4 w-4"})," New Instrument"]})]}),x?e.jsxs("div",{className:"flex items-center justify-center py-12 text-slate-400",children:[e.jsx(P,{className:"h-5 w-5 animate-spin mr-2"})," Loading..."]}):m.length===0?e.jsxs("div",{className:"text-center py-12 text-slate-400",children:[e.jsx(_e,{className:"h-8 w-8 mx-auto mb-2 opacity-30"}),e.jsx("p",{className:"text-sm",children:"No instruments found"})]}):e.jsx("div",{className:"overflow-x-auto rounded-md border",style:{borderColor:"#e2e8f0"},children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",style:{background:"#f1f5f9",borderColor:"#e2e8f0"},children:[e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Ticker"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Name"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Asset Class"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"CUSIP"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"ISIN"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Exchange"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"IBKR ConID"})]})}),e.jsx("tbody",{children:m.map((i,I)=>e.jsxs("tr",{className:"border-b hover:bg-[#f8fafc]",style:{borderColor:"#e2e8f0"},"data-testid":`row-instrument-${i.id||I}`,children:[e.jsx("td",{className:"px-3 py-2 font-mono font-bold",style:{color:q},children:i.ticker||"—"}),e.jsx("td",{className:"px-3 py-2 text-slate-800 font-medium",children:i.instrumentName||"—"}),e.jsx("td",{className:"px-3 py-2 text-slate-600",children:i.assetClass||"—"}),e.jsx("td",{className:"px-3 py-2 text-slate-500 font-mono",children:i.cusip||"—"}),e.jsx("td",{className:"px-3 py-2 text-slate-500 font-mono",children:i.isin||"—"}),e.jsx("td",{className:"px-3 py-2 text-slate-600",children:i.exchange||"—"}),e.jsx("td",{className:"px-3 py-2 text-slate-500 font-mono",children:i.ibkrConId||"—"})]},i.id||I))})]})}),e.jsxs($e,{open:n,onClose:()=>o(!1),title:"New Instrument",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Ticker"}),e.jsx(S,{maxLength:100,value:r.ticker,onChange:i=>c({...r,ticker:i.target.value}),placeholder:"e.g. AAPL","data-testid":"input-instrument-ticker"})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Name"}),e.jsx(S,{maxLength:100,value:r.instrumentName,onChange:i=>c({...r,instrumentName:i.target.value}),placeholder:"e.g. Apple Inc.","data-testid":"input-instrument-name"})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Asset Class"}),e.jsxs(ee,{value:r.assetClass,onValueChange:i=>c({...r,assetClass:i}),children:[e.jsx(te,{"data-testid":"select-instrument-asset-class",children:e.jsx(ae,{})}),e.jsx(se,{children:["EQUITY","FIXED_INCOME","ETF","FUND","CASH","MONEY_MARKET"].map(i=>e.jsx(R,{value:i,children:i.replace("_"," ")},i))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"CUSIP"}),e.jsx(S,{maxLength:100,value:r.cusip,onChange:i=>c({...r,cusip:i.target.value}),placeholder:"Optional","data-testid":"input-instrument-cusip"})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"ISIN"}),e.jsx(S,{maxLength:100,value:r.isin,onChange:i=>c({...r,isin:i.target.value}),placeholder:"Optional","data-testid":"input-instrument-isin"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Exchange"}),e.jsx(S,{maxLength:100,value:r.exchange,onChange:i=>c({...r,exchange:i.target.value}),placeholder:"e.g. NASDAQ","data-testid":"input-instrument-exchange"})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"IBKR ConID"}),e.jsx(S,{maxLength:255,value:r.ibkrConId,onChange:i=>c({...r,ibkrConId:i.target.value}),placeholder:"Optional","data-testid":"input-instrument-conid"})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(C,{variant:"outline",onClick:()=>o(!1),"data-testid":"button-cancel-instrument",children:"Cancel"}),e.jsx(C,{onClick:()=>p.mutate(r),disabled:p.isPending||!r.ticker||!r.instrumentName,style:{background:K,color:"#fff"},"data-testid":"button-submit-instrument",children:p.isPending?e.jsx(P,{className:"h-4 w-4 animate-spin"}):"Create Instrument"})]})]})]})}function Ut(){const{toast:a}=Ae(),[t,s]=g.useState("ALL"),[n,o]=g.useState("ALL"),[r,c]=g.useState(!1),[h,x]=g.useState(null),[p,f]=g.useState({transactionType:"DEPOSIT",tradeDate:"",effectiveDate:"",legs:[{accountId:"",legType:"DR",amount:"",instrumentId:"",quantity:"",unitPrice:""}]}),{data:m=[],isLoading:i}=z({queryKey:["/api/staff/subledger/transactions"]}),I=de({mutationFn:async l=>{await xe("POST","/api/staff/subledger/transactions",l)},onSuccess:()=>{V.invalidateQueries({queryKey:["/api/staff/subledger/transactions"]}),V.invalidateQueries({queryKey:["/api/staff/subledger/dashboard"]}),a({title:"Transaction posted"}),c(!1),f({transactionType:"DEPOSIT",tradeDate:"",effectiveDate:"",legs:[{accountId:"",legType:"DR",amount:"",instrumentId:"",quantity:"",unitPrice:""}]})},onError:()=>a({title:"Failed to post transaction",variant:"destructive"})}),F=de({mutationFn:async l=>{await xe("POST",`/api/staff/subledger/transactions/${l}/reverse`,{})},onSuccess:()=>{V.invalidateQueries({queryKey:["/api/staff/subledger/transactions"]}),V.invalidateQueries({queryKey:["/api/staff/subledger/dashboard"]}),a({title:"Transaction reversed"})},onError:()=>a({title:"Failed to reverse transaction",variant:"destructive"})}),w=de({mutationFn:async l=>{await xe("POST",`/api/staff/subledger/transactions/${l}/approve`,{})},onSuccess:()=>{V.invalidateQueries({queryKey:["/api/staff/subledger/transactions"]}),V.invalidateQueries({queryKey:["/api/staff/subledger/dashboard"]}),a({title:"Transaction approved"})},onError:()=>a({title:"Failed to approve transaction",variant:"destructive"})}),N=["ALL","DEPOSIT","WITHDRAWAL","TRADE_BUY","TRADE_SELL","DIVIDEND","INTEREST","FEE","ADJUSTMENT","REVERSAL"],D=["ALL","PENDING","SETTLED","REVERSED","MANUAL_REVIEW"];let y=m;t!=="ALL"&&(y=y.filter(l=>l.transactionType===t||l.type===t)),n!=="ALL"&&(y=y.filter(l=>l.status===n));function B(){f({...p,legs:[...p.legs,{accountId:"",legType:"CR",amount:"",instrumentId:"",quantity:"",unitPrice:""}]})}function le(l){f({...p,legs:p.legs.filter((d,b)=>b!==l)})}function U(l,d,b){const E=[...p.legs];E[l][d]=b,f({...p,legs:E})}function G(){let l=0,d=0;for(const b of p.legs){const E=parseFloat(b.amount);if(isNaN(E)||E<=0)return!1;b.legType==="DR"?l+=E:d+=E}return Math.abs(l-d)<.01}function ue(){if(!G()){a({title:"DR and CR legs must sum to zero",variant:"destructive"});return}I.mutate(p)}return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex gap-1 flex-wrap",children:N.map(l=>e.jsx(Re,{active:t===l,onClick:()=>s(l),testId:`filter-txn-type-${l.toLowerCase()}`,children:l.replace("_"," ")},l))}),e.jsx("div",{className:"flex gap-1 flex-wrap",children:D.map(l=>e.jsx(Re,{active:n===l,onClick:()=>o(l),testId:`filter-txn-status-${l.toLowerCase()}`,inactiveClass:l==="PENDING"?"text-amber-700 bg-amber-50 border border-amber-200":l==="SETTLED"?"text-emerald-700 bg-emerald-50 border border-emerald-200":l==="REVERSED"?"text-red-700 bg-red-50 border border-red-200":l==="MANUAL_REVIEW"?"text-blue-700 bg-blue-50 border border-blue-200":"text-slate-500 bg-slate-100 border border-slate-200",children:l.replace("_"," ")},l))})]}),e.jsxs(C,{onClick:()=>c(!0),className:"gap-1.5 font-bold",style:{background:K,color:"#fff"},"data-testid":"button-post-transaction",children:[e.jsx(Se,{className:"h-4 w-4"})," Post Transaction"]})]}),i?e.jsxs("div",{className:"flex items-center justify-center py-12 text-slate-400",children:[e.jsx(P,{className:"h-5 w-5 animate-spin mr-2"})," Loading..."]}):y.length===0?e.jsxs("div",{className:"text-center py-12 text-slate-400",children:[e.jsx(We,{className:"h-8 w-8 mx-auto mb-2 opacity-30"}),e.jsx("p",{className:"text-sm",children:"No transactions found"})]}):e.jsx("div",{className:"overflow-x-auto rounded-md border",style:{borderColor:"#e2e8f0"},children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",style:{background:"#f1f5f9",borderColor:"#e2e8f0"},children:[e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Ref"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Type"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Trade Date"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Effective Date"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Status"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Source"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Created By"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Actions"})]})}),e.jsx("tbody",{children:y.map((l,d)=>e.jsxs("tr",{className:"border-b hover:bg-[#f8fafc]",style:{borderColor:"#e2e8f0"},"data-testid":`row-txn-${l.id||d}`,children:[e.jsx("td",{className:"px-3 py-2 font-mono font-bold",style:{color:q},children:l.transactionRef||`TXN-${l.id}`}),e.jsx("td",{className:"px-3 py-2 text-slate-600",children:(l.transactionType||l.type||"—").replace("_"," ")}),e.jsx("td",{className:"px-3 py-2 text-slate-500",children:Z(l.tradeDate)}),e.jsx("td",{className:"px-3 py-2 text-slate-500",children:Z(l.effectiveDate)}),e.jsx("td",{className:"px-3 py-2",children:e.jsx(pe,{status:l.status||"PENDING"})}),e.jsx("td",{className:"px-3 py-2 text-slate-500",children:l.sourceSystem||"MANUAL"}),e.jsx("td",{className:"px-3 py-2 text-slate-500",children:l.createdBy||"—"}),e.jsx("td",{className:"px-3 py-2",children:e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsxs(C,{size:"sm",variant:"outline",className:"gap-1 text-[10px]",onClick:()=>x(l),"data-testid":`button-view-txn-${l.id||d}`,children:[e.jsx(Oe,{className:"h-3 w-3"})," View"]}),l.status==="SETTLED"&&e.jsxs(C,{size:"sm",variant:"outline",className:"gap-1 text-[10px] text-red-600",onClick:()=>F.mutate(l.id),disabled:F.isPending,"data-testid":`button-reverse-txn-${l.id||d}`,children:[e.jsx(bt,{className:"h-3 w-3"})," Reverse"]}),l.status==="MANUAL_REVIEW"&&e.jsxs(C,{size:"sm",variant:"outline",className:"gap-1 text-[10px] text-emerald-600",onClick:()=>w.mutate(l.id),disabled:w.isPending,"data-testid":`button-approve-txn-${l.id||d}`,children:[e.jsx(He,{className:"h-3 w-3"})," Approve"]})]})})]},l.id||d))})]})}),e.jsx($e,{open:!!h,onClose:()=>x(null),title:`Transaction ${h?.transactionRef||""}`,children:h&&e.jsxs("div",{className:"space-y-3 text-xs",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-500 font-bold uppercase text-[10px]",children:"Type"}),e.jsx("p",{className:"text-slate-800",children:h.transactionType||h.type})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-500 font-bold uppercase text-[10px]",children:"Status"}),e.jsx("p",{children:e.jsx(pe,{status:h.status})})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-500 font-bold uppercase text-[10px]",children:"Trade Date"}),e.jsx("p",{className:"text-slate-800",children:Z(h.tradeDate)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-500 font-bold uppercase text-[10px]",children:"Effective Date"}),e.jsx("p",{className:"text-slate-800",children:Z(h.effectiveDate)})]})]}),h.legs&&h.legs.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-500 font-bold uppercase text-[10px]",children:"Legs"}),e.jsx("div",{className:"mt-1 rounded-md border border-border overflow-hidden",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-slate-50",children:[e.jsx("th",{className:"px-2 py-1 text-left",children:"Account"}),e.jsx("th",{className:"px-2 py-1 text-left",children:"Type"}),e.jsx("th",{className:"px-2 py-1 text-right",children:"Amount"}),e.jsx("th",{className:"px-2 py-1 text-left",children:"Instrument"}),e.jsx("th",{className:"px-2 py-1 text-right",children:"Qty"})]})}),e.jsx("tbody",{children:h.legs.map((l,d)=>e.jsxs("tr",{className:"border-t border-border",children:[e.jsx("td",{className:"px-2 py-1 font-mono",children:l.accountId||l.accountCode||"—"}),e.jsx("td",{className:"px-2 py-1",children:e.jsx("span",{className:l.legType==="DR"?"text-red-600 font-bold":"text-emerald-600 font-bold",children:l.legType})}),e.jsx("td",{className:"px-2 py-1 text-right font-mono",children:M(l.amount)}),e.jsx("td",{className:"px-2 py-1",children:l.instrumentId||"—"}),e.jsx("td",{className:"px-2 py-1 text-right",children:l.quantity||"—"})]},d))})]})})]})]})}),e.jsxs($e,{open:r,onClose:()=>c(!1),title:"Post Transaction",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Transaction Type"}),e.jsxs(ee,{value:p.transactionType,onValueChange:l=>f({...p,transactionType:l}),children:[e.jsx(te,{"data-testid":"select-txn-type",children:e.jsx(ae,{})}),e.jsx(se,{children:["DEPOSIT","WITHDRAWAL","TRADE_BUY","TRADE_SELL","DIVIDEND","INTEREST","FEE","ADJUSTMENT"].map(l=>e.jsx(R,{value:l,children:l.replace("_"," ")},l))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Trade Date"}),e.jsx(S,{type:"date",value:p.tradeDate,onChange:l=>f({...p,tradeDate:l.target.value}),"data-testid":"input-txn-trade-date"})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Effective Date"}),e.jsx(S,{type:"date",value:p.effectiveDate,onChange:l=>f({...p,effectiveDate:l.target.value}),"data-testid":"input-txn-effective-date"})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx(k,{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Transaction Legs"}),e.jsxs(C,{size:"sm",variant:"outline",onClick:B,className:"gap-1 text-[10px]","data-testid":"button-add-leg",children:[e.jsx(Se,{className:"h-3 w-3"})," Add Leg"]})]}),p.legs.map((l,d)=>e.jsxs("div",{className:"rounded-md border border-border p-3 mb-2 bg-slate-50 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-[10px] font-bold text-slate-500",children:["Leg ",d+1]}),p.legs.length>1&&e.jsx("button",{type:"button",onClick:()=>le(d),className:"text-red-500 text-[10px] font-bold","data-testid":`button-remove-leg-${d}`,children:"Remove"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] text-slate-400",children:"Account ID"}),e.jsx(S,{maxLength:100,value:l.accountId,onChange:b=>U(d,"accountId",b.target.value),placeholder:"Account","data-testid":`input-leg-account-${d}`})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] text-slate-400",children:"DR/CR"}),e.jsxs(ee,{value:l.legType,onValueChange:b=>U(d,"legType",b),children:[e.jsx(te,{"data-testid":`select-leg-type-${d}`,children:e.jsx(ae,{})}),e.jsxs(se,{children:[e.jsx(R,{value:"DR",children:"DR (Debit)"}),e.jsx(R,{value:"CR",children:"CR (Credit)"})]})]})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] text-slate-400",children:"Amount"}),e.jsx(S,{type:"number",step:"0.01",value:l.amount,onChange:b=>U(d,"amount",b.target.value),placeholder:"0.00","data-testid":`input-leg-amount-${d}`})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] text-slate-400",children:"Instrument (opt)"}),e.jsx(S,{value:l.instrumentId,onChange:b=>U(d,"instrumentId",b.target.value),placeholder:"Optional","data-testid":`input-leg-instrument-${d}`})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] text-slate-400",children:"Quantity (opt)"}),e.jsx(S,{type:"number",value:l.quantity,onChange:b=>U(d,"quantity",b.target.value),placeholder:"Optional","data-testid":`input-leg-quantity-${d}`})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] text-slate-400",children:"Unit Price (opt)"}),e.jsx(S,{type:"number",step:"0.01",value:l.unitPrice,onChange:b=>U(d,"unitPrice",b.target.value),placeholder:"Optional","data-testid":`input-leg-unit-price-${d}`})]})]})]},d)),!G()&&p.legs.some(l=>l.amount)&&e.jsxs("p",{className:"text-red-600 text-[10px] font-bold flex items-center gap-1",children:[e.jsx(ge,{className:"h-3 w-3"})," DR and CR totals must balance to zero"]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(C,{variant:"outline",onClick:()=>c(!1),"data-testid":"button-cancel-transaction",children:"Cancel"}),e.jsx(C,{onClick:ue,disabled:I.isPending||!p.tradeDate||!p.effectiveDate||!G(),style:{background:K,color:"#fff"},"data-testid":"button-submit-transaction",children:I.isPending?e.jsx(P,{className:"h-4 w-4 animate-spin"}):"Post Transaction"})]})]})]})}function qt(){const[a,t]=g.useState(""),{data:s=[],isLoading:n}=z({queryKey:["/api/staff/subledger/positions"]}),o=a?s.filter(r=>(r.accountCode||r.accountId||"").toLowerCase().includes(a.toLowerCase())):s;return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center gap-3 flex-wrap",children:e.jsx(S,{maxLength:100,value:a,onChange:r=>t(r.target.value),placeholder:"Filter by account...",className:"max-w-xs","data-testid":"input-positions-filter"})}),n?e.jsxs("div",{className:"flex items-center justify-center py-12 text-slate-400",children:[e.jsx(P,{className:"h-5 w-5 animate-spin mr-2"})," Loading..."]}):o.length===0?e.jsxs("div",{className:"text-center py-12 text-slate-400",children:[e.jsx(W,{className:"h-8 w-8 mx-auto mb-2 opacity-30"}),e.jsx("p",{className:"text-sm",children:"No positions found"})]}):e.jsx("div",{className:"overflow-x-auto rounded-md border",style:{borderColor:"#e2e8f0"},children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",style:{background:"#f1f5f9",borderColor:"#e2e8f0"},children:[e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Account"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Instrument"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"As-of Date"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Quantity"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Cost Basis"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Market Value"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Closing Price"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Unrealized P&L"})]})}),e.jsx("tbody",{children:o.map((r,c)=>{const h=parseFloat(r.unrealizedPnl||r.unrealizedPL||"0");return e.jsxs("tr",{className:"border-b hover:bg-[#f8fafc]",style:{borderColor:"#e2e8f0"},"data-testid":`row-position-${r.id||c}`,children:[e.jsx("td",{className:"px-3 py-2 font-mono font-bold",style:{color:q},children:r.accountCode||r.accountId||"—"}),e.jsx("td",{className:"px-3 py-2 text-slate-800 font-medium",children:r.instrumentTicker||r.instrumentId||"—"}),e.jsx("td",{className:"px-3 py-2 text-slate-500",children:Z(r.asOfDate)}),e.jsx("td",{className:"px-3 py-2 text-right font-mono text-slate-700",children:M(r.quantity,4)}),e.jsxs("td",{className:"px-3 py-2 text-right font-mono text-slate-700",children:["$",M(r.costBasis)]}),e.jsxs("td",{className:"px-3 py-2 text-right font-mono text-slate-700",children:["$",M(r.marketValue)]}),e.jsxs("td",{className:"px-3 py-2 text-right font-mono text-slate-700",children:["$",M(r.closingPrice)]}),e.jsxs("td",{className:`px-3 py-2 text-right font-mono font-bold ${h>=0?"text-emerald-600":"text-red-600"}`,children:["$",M(h)]})]},r.id||c)})})]})})]})}function zt(){const{toast:a}=Ae(),[t,s]=g.useState({}),{data:n=[],isLoading:o}=z({queryKey:["/api/staff/subledger/reconciliation/runs"]}),{data:r=[],isLoading:c}=z({queryKey:["/api/staff/subledger/breaks"]}),h=de({mutationFn:async()=>{await xe("POST","/api/staff/subledger/reconciliation/run",{})},onSuccess:()=>{V.invalidateQueries({queryKey:["/api/staff/subledger/reconciliation/runs"]}),V.invalidateQueries({queryKey:["/api/staff/subledger/breaks"]}),V.invalidateQueries({queryKey:["/api/staff/subledger/dashboard"]}),a({title:"Reconciliation started"})},onError:()=>a({title:"Failed to start reconciliation",variant:"destructive"})}),x=de({mutationFn:async({id:f,status:m,resolutionNotes:i})=>{await xe("PATCH",`/api/staff/subledger/breaks/${f}`,{status:m,resolutionNotes:i})},onSuccess:()=>{V.invalidateQueries({queryKey:["/api/staff/subledger/breaks"]}),V.invalidateQueries({queryKey:["/api/staff/subledger/dashboard"]}),a({title:"Break status updated"})},onError:()=>a({title:"Failed to update break",variant:"destructive"})}),p=n.length>0?n[0]:null;return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[p&&e.jsxs("div",{className:"rounded-md border border-border p-4 bg-white flex-1 min-w-[250px]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Ke,{className:"h-4 w-4",style:{color:q}}),e.jsx("span",{className:"text-sm font-bold text-slate-800",children:"Latest Run"}),e.jsx(pe,{status:p.runStatus||"CLEAN"})]}),e.jsxs("div",{className:"flex gap-4 text-xs text-slate-500 flex-wrap",children:[e.jsxs("span",{children:["Started: ",Ce(p.runStartedAt)]}),p.runCompletedAt&&e.jsxs("span",{children:["Completed: ",Ce(p.runCompletedAt)]}),p.totalBreaks!=null&&e.jsxs("span",{children:["Breaks: ",p.totalBreaks]})]})]}),e.jsxs(C,{onClick:()=>h.mutate(),disabled:h.isPending,className:"gap-1.5 font-bold",style:{background:K,color:"#fff"},"data-testid":"button-run-reconciliation",children:[h.isPending?e.jsx(P,{className:"h-4 w-4 animate-spin"}):e.jsx(gt,{className:"h-4 w-4"})," Run Reconciliation"]})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-bold text-slate-800 mb-3 flex items-center gap-2",children:[e.jsx(ge,{className:"h-4 w-4 text-amber-500"})," Breaks"]}),c?e.jsxs("div",{className:"flex items-center justify-center py-8 text-slate-400",children:[e.jsx(P,{className:"h-5 w-5 animate-spin mr-2"})," Loading..."]}):r.length===0?e.jsxs("div",{className:"text-center py-8 text-slate-400 rounded-md border border-border bg-white",children:[e.jsx(He,{className:"h-8 w-8 mx-auto mb-2 text-emerald-400"}),e.jsx("p",{className:"text-sm",children:"No breaks found"})]}):e.jsx("div",{className:"overflow-x-auto rounded-md border",style:{borderColor:"#e2e8f0"},children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",style:{background:"#f1f5f9",borderColor:"#e2e8f0"},children:[e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Type"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Amount"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Custodian"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Subledger"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Age"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Status"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Actions"})]})}),e.jsx("tbody",{children:r.map((f,m)=>e.jsxs("tr",{className:"border-b hover:bg-[#f8fafc]",style:{borderColor:"#e2e8f0"},"data-testid":`row-break-${f.id||m}`,children:[e.jsx("td",{className:"px-3 py-2 text-slate-800 font-medium",children:f.breakType||f.type||"—"}),e.jsxs("td",{className:"px-3 py-2 text-right font-mono text-red-600 font-bold",children:["$",M(f.breakAmount)]}),e.jsxs("td",{className:"px-3 py-2 text-right font-mono text-slate-600",children:["$",M(f.custodianValue)]}),e.jsxs("td",{className:"px-3 py-2 text-right font-mono text-slate-600",children:["$",M(f.subledgerValue)]}),e.jsx("td",{className:"px-3 py-2 text-slate-500",children:f.breakAgeDays!=null?`${f.breakAgeDays}d`:"—"}),e.jsx("td",{className:"px-3 py-2",children:e.jsx(pe,{status:f.status||"OPEN"})}),e.jsx("td",{className:"px-3 py-2",children:e.jsxs("div",{className:"flex gap-1 flex-wrap items-center",children:[e.jsxs(ee,{value:"",onValueChange:i=>x.mutate({id:f.id,status:i,resolutionNotes:t[f.id]}),children:[e.jsx(te,{className:"h-7 w-28 text-[10px]","data-testid":`select-break-status-${f.id||m}`,children:e.jsx(ae,{placeholder:"Update..."})}),e.jsxs(se,{children:[e.jsx(R,{value:"INVESTIGATING",children:"Investigating"}),e.jsx(R,{value:"RESOLVED",children:"Resolved"}),e.jsx(R,{value:"ESCALATED",children:"Escalated"})]})]}),e.jsx(S,{maxLength:100,value:t[f.id]||"",onChange:i=>s({...t,[f.id]:i.target.value}),placeholder:"Notes...",className:"h-7 text-[10px] w-32","data-testid":`input-break-notes-${f.id||m}`})]})})]},f.id||m))})]})})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-bold text-slate-800 mb-3 flex items-center gap-2",children:[e.jsx(Ge,{className:"h-4 w-4",style:{color:q}})," Run History"]}),o?e.jsxs("div",{className:"flex items-center justify-center py-8 text-slate-400",children:[e.jsx(P,{className:"h-5 w-5 animate-spin mr-2"})," Loading..."]}):n.length===0?e.jsx("div",{className:"text-center py-8 text-slate-400 rounded-md border border-border bg-white",children:e.jsx("p",{className:"text-sm",children:"No reconciliation runs yet"})}):e.jsx("div",{className:"overflow-x-auto rounded-md border",style:{borderColor:"#e2e8f0"},children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",style:{background:"#f1f5f9",borderColor:"#e2e8f0"},children:[e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Run ID"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Started"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Completed"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Status"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Breaks"})]})}),e.jsx("tbody",{children:n.map((f,m)=>e.jsxs("tr",{className:"border-b hover:bg-[#f8fafc]",style:{borderColor:"#e2e8f0"},"data-testid":`row-run-${f.id||m}`,children:[e.jsx("td",{className:"px-3 py-2 font-mono",style:{color:q},children:f.id}),e.jsx("td",{className:"px-3 py-2 text-slate-500",children:Ce(f.runStartedAt)}),e.jsx("td",{className:"px-3 py-2 text-slate-500",children:Ce(f.runCompletedAt)}),e.jsx("td",{className:"px-3 py-2",children:e.jsx(pe,{status:f.runStatus||"CLEAN"})}),e.jsx("td",{className:"px-3 py-2 text-right font-mono",children:f.totalBreaks??"—"})]},f.id||m))})]})})]})]})}function _t(){const{toast:a}=Ae(),[t,s]=g.useState("ALL"),[n,o]=g.useState(!1),[r,c]=g.useState({caType:"DIVIDEND_CASH",instrumentId:"",recordDate:"",payDate:"",grossAmount:"",perShareAmount:""}),{data:h=[],isLoading:x}=z({queryKey:["/api/staff/subledger/corporate-actions"]}),p=de({mutationFn:async i=>{await xe("POST","/api/staff/subledger/corporate-actions",i)},onSuccess:()=>{V.invalidateQueries({queryKey:["/api/staff/subledger/corporate-actions"]}),V.invalidateQueries({queryKey:["/api/staff/subledger/dashboard"]}),a({title:"Corporate action created"}),o(!1),c({caType:"DIVIDEND_CASH",instrumentId:"",recordDate:"",payDate:"",grossAmount:"",perShareAmount:""})},onError:()=>a({title:"Failed to create corporate action",variant:"destructive"})}),f=["ALL","PENDING","SNAPSHOT_LOCKED","ALLOCATED","FAILED"],m=t==="ALL"?h:h.filter(i=>i.status===t);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsx("div",{className:"flex gap-1 flex-wrap",children:f.map(i=>e.jsx(Re,{active:t===i,onClick:()=>s(i),testId:`filter-corp-action-${i.toLowerCase()}`,children:i.replace("_"," ")},i))}),e.jsxs(C,{onClick:()=>o(!0),className:"gap-1.5 font-bold",style:{background:K,color:"#fff"},"data-testid":"button-new-corp-action",children:[e.jsx(Se,{className:"h-4 w-4"})," New Corporate Action"]})]}),x?e.jsxs("div",{className:"flex items-center justify-center py-12 text-slate-400",children:[e.jsx(P,{className:"h-5 w-5 animate-spin mr-2"})," Loading..."]}):m.length===0?e.jsxs("div",{className:"text-center py-12 text-slate-400",children:[e.jsx(me,{className:"h-8 w-8 mx-auto mb-2 opacity-30"}),e.jsx("p",{className:"text-sm",children:"No corporate actions found"})]}):e.jsx("div",{className:"overflow-x-auto rounded-md border",style:{borderColor:"#e2e8f0"},children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",style:{background:"#f1f5f9",borderColor:"#e2e8f0"},children:[e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Type"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Instrument"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Record Date"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Pay Date"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Gross Amount"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Per Share"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Status"})]})}),e.jsx("tbody",{children:m.map((i,I)=>e.jsxs("tr",{className:"border-b hover:bg-[#f8fafc]",style:{borderColor:"#e2e8f0"},"data-testid":`row-corp-action-${i.id||I}`,children:[e.jsx("td",{className:"px-3 py-2 text-slate-800 font-medium",children:i.caType||"—"}),e.jsx("td",{className:"px-3 py-2 font-mono",style:{color:q},children:i.instrumentTicker||i.instrumentId||"—"}),e.jsx("td",{className:"px-3 py-2 text-slate-500",children:Z(i.recordDate)}),e.jsx("td",{className:"px-3 py-2 text-slate-500",children:Z(i.payDate)}),e.jsxs("td",{className:"px-3 py-2 text-right font-mono text-slate-700",children:["$",M(i.grossAmount)]}),e.jsxs("td",{className:"px-3 py-2 text-right font-mono text-slate-700",children:["$",M(i.perShareAmount,4)]}),e.jsx("td",{className:"px-3 py-2",children:e.jsx(pe,{status:i.status||"PENDING"})})]},i.id||I))})]})}),e.jsxs($e,{open:n,onClose:()=>o(!1),title:"New Corporate Action",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Action Type"}),e.jsxs(ee,{value:r.caType,onValueChange:i=>c({...r,caType:i}),children:[e.jsx(te,{"data-testid":"select-corp-action-type",children:e.jsx(ae,{})}),e.jsxs(se,{children:[e.jsx(R,{value:"DIVIDEND_CASH",children:"Cash Dividend"}),e.jsx(R,{value:"DIVIDEND_STOCK",children:"Stock Dividend"}),e.jsx(R,{value:"INTEREST",children:"Interest"}),e.jsx(R,{value:"STOCK_SPLIT",children:"Stock Split"}),e.jsx(R,{value:"RETURN_OF_CAPITAL",children:"Return of Capital"}),e.jsx(R,{value:"MERGER",children:"Merger"}),e.jsx(R,{value:"SPIN_OFF",children:"Spin Off"})]})]})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Instrument ID"}),e.jsx(S,{maxLength:100,value:r.instrumentId,onChange:i=>c({...r,instrumentId:i.target.value}),placeholder:"Instrument ID or ticker","data-testid":"input-corp-action-instrument"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Record Date"}),e.jsx(S,{type:"date",value:r.recordDate,onChange:i=>c({...r,recordDate:i.target.value}),"data-testid":"input-corp-action-record-date"})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Pay Date"}),e.jsx(S,{type:"date",value:r.payDate,onChange:i=>c({...r,payDate:i.target.value}),"data-testid":"input-corp-action-pay-date"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Gross Amount"}),e.jsx(S,{type:"number",step:"0.01",value:r.grossAmount,onChange:i=>c({...r,grossAmount:i.target.value}),placeholder:"0.00","data-testid":"input-corp-action-gross"})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Per Share Amount"}),e.jsx(S,{type:"number",step:"0.0001",value:r.perShareAmount,onChange:i=>c({...r,perShareAmount:i.target.value}),placeholder:"0.0000","data-testid":"input-corp-action-per-share"})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(C,{variant:"outline",onClick:()=>o(!1),"data-testid":"button-cancel-corp-action",children:"Cancel"}),e.jsx(C,{onClick:()=>p.mutate(r),disabled:p.isPending||!r.instrumentId||!r.recordDate,style:{background:K,color:"#fff"},"data-testid":"button-submit-corp-action",children:p.isPending?e.jsx(P,{className:"h-4 w-4 animate-spin"}):"Create"})]})]})]})}function Kt(){const[a,t]=g.useState(null),{data:s=[],isLoading:n}=z({queryKey:["/api/staff/subledger/accounts"]}),o=s.filter(r=>r.accountType==="CLIENT");return a?e.jsx(Rt,{accountId:a,onBack:()=>t(null)}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"h-5 w-5",style:{color:q}}),e.jsx("h3",{className:"text-sm font-bold text-slate-800",children:"Client Account Statements"})]}),e.jsx("p",{className:"text-xs text-slate-500",children:"Select a client account to generate a comprehensive performance statement with returns analysis, allocation breakdown, and risk metrics."}),n?e.jsxs("div",{className:"flex items-center justify-center py-12 text-slate-400",children:[e.jsx(P,{className:"h-5 w-5 animate-spin mr-2"})," Loading accounts..."]}):o.length===0?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"text-center py-8 text-slate-400 border border-dashed border-border rounded-lg",children:[e.jsx(ie,{className:"h-8 w-8 mx-auto mb-2 opacity-30"}),e.jsx("p",{className:"text-sm font-medium",children:"No client accounts found"}),e.jsx("p",{className:"text-xs mt-1",children:"Create a client account in the Accounts tab first, then generate statements here."})]}),e.jsxs("div",{className:"bg-slate-50 rounded-lg border border-border p-4",children:[e.jsx("h4",{className:"text-xs font-bold text-slate-500 uppercase mb-2",children:"Or generate statement for any account"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:s.map(r=>e.jsxs("button",{type:"button",onClick:()=>t(r.id),className:"flex items-center gap-3 p-3 bg-white rounded-md border border-border hover:border-[#c5a059] hover:shadow-sm transition-all text-left","data-testid":`button-stmt-account-${r.accountCode}`,children:[e.jsx(ie,{className:"h-4 w-4 text-slate-400 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-bold text-slate-800 truncate",children:r.accountName}),e.jsxs("p",{className:"text-[10px] text-slate-400 font-mono",children:[r.accountCode," · ",r.accountType]})]})]},r.id))})]})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:o.map(r=>e.jsxs("button",{type:"button",onClick:()=>t(r.id),className:"flex items-center gap-3 p-4 rounded-lg border hover:border-[#c5a059] hover:shadow-md transition-all text-left group",style:{background:"linear-gradient(180deg, #ffffff 0%, #f8fafc 100%)",borderColor:"#e2e8f0"},"data-testid":`button-stmt-account-${r.accountCode}`,children:[e.jsx("div",{className:"p-2 rounded-md bg-slate-50 group-hover:bg-[#fdf8ef] transition-colors",children:e.jsx(Q,{className:"h-5 w-5 text-slate-400 group-hover:text-[#c5a059] transition-colors"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-bold truncate",style:{color:"#2d1a0e"},children:r.accountName}),e.jsxs("p",{className:"text-[10px] text-slate-400 font-mono",children:[r.accountCode," · ",r.currency||"USD"]}),e.jsxs("p",{className:"text-[10px] text-slate-400",children:["Opened ",Z(r.openedDate)]})]}),e.jsx(De,{className:"h-4 w-4 text-slate-300 -rotate-90 group-hover:text-[#c5a059] transition-colors"})]},r.id))})]})}function Gt(){const{data:a,isLoading:t}=z({queryKey:["/api/staff/subledger/trial-balance"]}),s=a?.accounts||[],n=s.reduce((c,h)=>c+parseFloat(h.drTotal||"0"),0),o=s.reduce((c,h)=>c+parseFloat(h.crTotal||"0"),0),r=Math.abs(n-o)<.01;return e.jsx("div",{className:"space-y-4",children:t?e.jsxs("div",{className:"flex items-center justify-center py-12 text-slate-400",children:[e.jsx(P,{className:"h-5 w-5 animate-spin mr-2"})," Loading..."]}):s.length===0?e.jsxs("div",{className:"text-center py-12 text-slate-400",children:[e.jsx(ze,{className:"h-8 w-8 mx-auto mb-2 opacity-30"}),e.jsx("p",{className:"text-sm",children:"No trial balance data"})]}):e.jsx("div",{className:"overflow-x-auto rounded-md border",style:{borderColor:"#e2e8f0"},children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",style:{background:"#f1f5f9",borderColor:"#e2e8f0"},children:[e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Account Code"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Account Name"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"DR Total"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"CR Total"}),e.jsx("th",{className:"px-3 py-2 text-right font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Balance"})]})}),e.jsx("tbody",{children:s.map((c,h)=>{const x=parseFloat(c.drTotal||"0"),p=parseFloat(c.crTotal||"0"),f=parseFloat(c.balance||"0");return e.jsxs("tr",{className:"border-b hover:bg-[#f8fafc]",style:{borderColor:"#e2e8f0"},"data-testid":`row-trial-balance-${h}`,children:[e.jsx("td",{className:"px-3 py-2 font-mono font-bold",style:{color:q},children:c.account?.accountCode||"—"}),e.jsx("td",{className:"px-3 py-2 text-slate-800 font-medium",children:c.account?.accountName||"—"}),e.jsxs("td",{className:"px-3 py-2 text-right font-mono text-slate-700",children:["$",M(x)]}),e.jsxs("td",{className:"px-3 py-2 text-right font-mono text-slate-700",children:["$",M(p)]}),e.jsxs("td",{className:`px-3 py-2 text-right font-mono font-bold ${f>=0?"text-slate-800":"text-red-600"}`,children:["$",M(f)]})]},c.account?.id||h)})}),e.jsx("tfoot",{children:e.jsxs("tr",{className:"bg-slate-100 border-t-2 border-border font-bold",children:[e.jsx("td",{className:"px-3 py-2 text-slate-800",colSpan:2,children:"TOTALS"}),e.jsxs("td",{className:"px-3 py-2 text-right font-mono text-slate-800",children:["$",M(n)]}),e.jsxs("td",{className:"px-3 py-2 text-right font-mono text-slate-800",children:["$",M(o)]}),e.jsxs("td",{className:`px-3 py-2 text-right font-mono ${r?"text-emerald-600":"text-red-600"}`,children:["$",M(n-o),r&&e.jsx(He,{className:"h-3 w-3 inline ml-1"}),!r&&e.jsx(yt,{className:"h-3 w-3 inline ml-1"})]})]})})]})})})}function Ht(){const[a,t]=g.useState("ALL"),{data:s=[],isLoading:n}=z({queryKey:["/api/staff/subledger/audit-log"]}),o=["ALL","ACCOUNT","TRANSACTION","INSTRUMENT","CORP_ACTION","RECONCILIATION","BREAK"],r=a==="ALL"?s:s.filter(c=>c.entityType===a);return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex gap-1 flex-wrap",children:o.map(c=>e.jsx(Re,{active:a===c,onClick:()=>t(c),testId:`filter-audit-${c.toLowerCase()}`,children:c.replace("_"," ")},c))}),n?e.jsxs("div",{className:"flex items-center justify-center py-12 text-slate-400",children:[e.jsx(P,{className:"h-5 w-5 animate-spin mr-2"})," Loading..."]}):r.length===0?e.jsxs("div",{className:"text-center py-12 text-slate-400",children:[e.jsx(Ge,{className:"h-8 w-8 mx-auto mb-2 opacity-30"}),e.jsx("p",{className:"text-sm",children:"No audit entries found"})]}):e.jsx("div",{className:"overflow-x-auto rounded-md border",style:{borderColor:"#e2e8f0"},children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",style:{background:"#f1f5f9",borderColor:"#e2e8f0"},children:[e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Event Type"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Entity Type"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Entity ID"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"User"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Description"}),e.jsx("th",{className:"px-3 py-2 text-left font-bold uppercase tracking-wider",style:{color:"#8c7a5e"},children:"Timestamp"})]})}),e.jsx("tbody",{children:r.map((c,h)=>e.jsxs("tr",{className:"border-b hover:bg-[#f8fafc]",style:{borderColor:"#e2e8f0"},"data-testid":`row-audit-${c.id||h}`,children:[e.jsx("td",{className:"px-3 py-2 text-slate-800 font-medium",children:c.eventType||c.action||"—"}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-bold bg-slate-100 text-slate-600",children:c.entityType||"—"})}),e.jsx("td",{className:"px-3 py-2 font-mono text-slate-500",children:c.entityId||"—"}),e.jsx("td",{className:"px-3 py-2 text-slate-600",children:c.userId||c.userName||"—"}),e.jsx("td",{className:"px-3 py-2 text-slate-500 max-w-xs truncate",children:c.description||c.details||"—"}),e.jsx("td",{className:"px-3 py-2 text-slate-400",children:Ce(c.createdAt||c.timestamp)})]},c.id||h))})]})})]})}function Zt(){const[a,t]=g.useState(null),s={Dashboard:"Details about Dashboard functionality and capabilities.",Journal:"Details about Journal functionality and capabilities.",Accounts:"Details about Accounts functionality and capabilities.",Positions:"Details about Positions functionality and capabilities.",Reconciliation:"Daily reconciliation of bank, custodian, and client account positions.","Audit Trail":"Immutable audit trail of all transactions with timestamps and user attribution."},[n,o]=g.useState("dashboard");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"rounded-2xl p-5 relative overflow-hidden",style:{background:"linear-gradient(135deg, #cd2122, #8b1a1a)",boxShadow:"0 8px 32px rgba(205,33,34,0.35)"},children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.07]",style:{backgroundImage:"radial-gradient(circle at 20% 50%, white 1px, transparent 1px), radial-gradient(circle at 80% 20%, white 1px, transparent 1px)",backgroundSize:"60px 60px, 40px 40px"}}),e.jsxs("div",{className:"relative flex items-center gap-3.5",children:[e.jsx("div",{className:"rounded-2xl flex items-center justify-center shrink-0",style:{width:52,height:52,background:"rgba(255,255,255,0.18)",border:"1px solid rgba(255,255,255,0.25)",backdropFilter:"blur(8px)",boxShadow:"0 4px 16px rgba(0,0,0,0.15)"},children:e.jsx(ze,{className:"h-6 w-6 text-[#c5a059]"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-black text-white tracking-tight",children:"Subledger Management"}),e.jsx("p",{className:"text-sm",style:{color:"rgba(255,255,255,0.7)"},children:"Double-entry accounting engine, reconciliation, positions, and audit trail"})]})]}),e.jsx("div",{className:"relative flex flex-wrap gap-1.5 mt-3.5",children:["Dashboard","Journal","Accounts","Positions","Reconciliation","Audit Trail"].map(r=>{const c=a===r;return e.jsx("button",{type:"button","data-testid":`badge-${r.toLowerCase().replace(/[\s/]+/g,"-")}`,onClick:()=>t(c?null:r),className:"text-[10px] font-bold px-2.5 py-1 rounded-full cursor-pointer transition-all hover:scale-105",style:c?{background:"rgba(255,255,255,0.95)",color:"#cd2122",border:"1px solid rgba(255,255,255,0.9)",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"}:{background:"rgba(255,255,255,0.15)",color:"rgba(255,255,255,0.9)",border:"1px solid rgba(255,255,255,0.1)"},children:r},r)})})]}),a&&s[a]&&e.jsx("div",{className:"rounded-xl border-l-4 p-4 animate-in fade-in slide-in-from-top-2 duration-200",style:{borderLeftColor:"#cd2122",background:"#fef2f2",border:"1px solid #fecaca"},children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-slate-900 text-sm",children:a}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:s[a]})]}),e.jsx("button",{"data-testid":"btn-abt_subledger_panel-view-1195",type:"button",onClick:()=>t(null),className:"text-slate-400 hover:text-slate-600 p-1",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"m6 6 12 12"})]})})]})}),e.jsx("div",{className:"flex gap-1 flex-wrap border-b border-border pb-2",children:Bt.map(r=>{const c=r.icon,h=n===r.id;return e.jsxs("button",{type:"button",onClick:()=>o(r.id),"data-testid":`tab-subledger-${r.id}`,className:`flex items-center gap-1.5 px-3 py-2 text-xs font-bold rounded-md transition-colors ${h?"text-white":"text-slate-500"}`,style:h?{background:K}:void 0,children:[e.jsx(c,{className:"h-3.5 w-3.5"}),r.label]},r.id)})}),n==="dashboard"&&e.jsx(Vt,{}),n==="accounts"&&e.jsx(Ot,{}),n==="instruments"&&e.jsx(Ft,{}),n==="transactions"&&e.jsx(Ut,{}),n==="trading-blotter"&&e.jsx(g.Suspense,{fallback:e.jsxs("div",{className:"flex items-center justify-center py-12 text-slate-400",children:[e.jsx(P,{className:"h-5 w-5 animate-spin mr-2"})," Loading Trading Blotter..."]}),children:e.jsx(It,{})}),n==="positions"&&e.jsx(qt,{}),n==="reconciliation"&&e.jsx(zt,{}),n==="corporate-actions"&&e.jsx(_t,{}),n==="statements"&&e.jsx(Kt,{}),n==="trial-balance"&&e.jsx(Gt,{}),n==="audit-log"&&e.jsx(Ht,{}),n==="portfolio-analyst"&&e.jsx(g.Suspense,{fallback:e.jsxs("div",{className:"flex items-center justify-center py-12 text-slate-400",children:[e.jsx(P,{className:"h-5 w-5 animate-spin mr-2"})," Loading Portfolio Analyst..."]}),children:e.jsx(Mt,{mode:"staff",apiUrl:"/api/staff/subledger/portfolio-analyst"})})]})}export{Zt as default};
