PageSourceSearch

https://arenberg-holdings.web.app/assets/chat-CYTgsqPI.js

js arenberg-holdings.web.app collected 2026-10-03 12:17:42 UTC 1,905,062 bytes, 546 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-C44JUHxF.js","assets/rolldown-runtime-aoxQmdZa.js","assets/vendor-OECK_qOc.css","assets/livekitTransport-wXww658c.js","assets/vendor-livekit-BhqKJLdn.js","assets/api-w9bwcNej.js","assets/apiBase-BqVXqfJu.js","assets/streamConsumer-PvCSbBOZ.js","assets/legacyTransport-CbkvFmoT.js","assets/dist-T7y6-lkF.js","assets/vendor-react-wuswOSgy.js","assets/SecurityMasterPage-B4bdMHZv.js","assets/SecurityMasterPage-CpVyQRvn.js","assets/IntelInteractiveChart-DIXa-sX4.js","assets/vendor-charts-C7St-aNu.js","assets/vendor-charts-CnsZ1jie.css","assets/feedManager-CZ33L40p.js","assets/wsClient-BmIsQawL.js","assets/theme-Cmxze0rk.js","assets/claims-CWlnYsG8.js","assets/newsLanes-DuZ-4DXJ.js","assets/intel-VUlwLK7Y.js","assets/useWatchlist-CRf4-cLf.js","assets/IntelDrawer-5jHo1zBI.js","assets/aiModels-BBoTZoAO.js","assets/cloudConfig-DLjM36Nf.js","assets/api-BUUQ_5Ri.js","assets/aiProvenance-D-bXLLqF.js","assets/sovereign-BKaNm6em.js","assets/storage-BIf0AI-b.js","assets/helpers-DrdOD8BY.js","assets/ActionInbox-Q0y4THx1.js","assets/ActionProposalCard-oTc3dkKd.js","assets/voiceLayer-DkZ8hoeK.js","assets/BundleInbox-CumvYmFr.js","assets/VoiceCaptureButton-CEYodA7P.js","assets/VoiceAffirmBanner-BJ-tMbgv.js","assets/BriefDrawer-DkJdIimI.js","assets/AuditDrawer-CWy5-oXf.js","assets/RiskDrawer-D3-LHqkm.js","assets/CortexDrawer-nFTXYhLO.js","assets/cortexContext-1rBL4F8g.js","assets/IntelDrawer-B_bOXWmv.js","assets/CouncilPanel-qPcoCtHc.js","assets/reduceCouncilEvent-CcWnRdMw.js","assets/tokens-BGgnTNs0.js","assets/IntelGraph-q-lvjPHk.js","assets/index-DrzSFEPl.js","assets/XyronMarkdown-Q8hnP07h.js","assets/ComplianceDisclaimer-Dtjin33o.js","assets/FlashRibbon-DWQmg4uo.js","assets/AdminPanel-CRV_DFVj.js","assets/AgentIntelPanel-l0OT-lzM.js","assets/AlphaPanel-BKTbCwSZ.js","assets/AltAssetsPanel-BBdBVNpE.js","assets/ApiKeysPanel-B16ezvfr.js","assets/AuditTrailPanel-B_NnQwH8.js","assets/AutoPilotPanel-QxyjpBbS.js","assets/AutoPortfolioManagerPanel-gdyBQd90.js","assets/AutonomousAgentsPanel-BwV_0zaX.js","assets/BacktestPanel-QBmX9woN.js","assets/BloombergDataPanel-BUGpAiAE.js","assets/BloombergIntelPanel-BzOUplOm.js","assets/BrokersPanel-DYdQ1eaO.js","assets/ConnectForm-QkAZA0Sx.js","assets/CommodityCurvesPanel-BSBY6mWq.js","assets/CompliancePanel-BUPJza4L.js","assets/CompositeRiskScorePanel-CiqJGYmQ.js","assets/riskMath-CLUOZ_5Q.js","assets/CorrelationPanel-36yQu7DL.js","assets/CreditPanel-p9D8IEV3.js","assets/DealRoomPanel-BGdaqzIK.js","assets/DistributionPanel-CyAKgKRJ.js","assets/DocumentIntelPanel-EBXZP8Zq.js","assets/ESGPanel-B7PX0fVz.js","assets/EarningsCalendarPanel-mvZVcgnv.js","assets/FXMatrixPanel-DbdZJomW.js","assets/FactorAnalysisPanel-NL6U1Wi-.js","assets/InsiderActivityPanel-9vrD5wiA.js","assets/InstitutionalHoldingsPanel-CLXB7Q3W.js","assets/Launchpad-CBghulfk.js","assets/LiveMeetingAI-CKnkX9jW.js","assets/MADealsPanel-_lgV3I7j.js","assets/MetaLearnerPanel-DP5SRzav.js","assets/cortexClientConfig-DyYIP_7Q.js","assets/MonteCarloPanel-CtW_USDA.js","assets/MorningCIOBriefCard-CXwPDIxr.js","assets/OrderFlowPanel-BSnUgXmM.js","assets/XyronGrid-DcQk389h.js","assets/PolicyArbitragePanel-BhWUV9KL.js","assets/statusBanners-BzU4rpC5.js","assets/PortfolioAttribution-DpvAs_rx.js","assets/terminalData-cQYNeM_6.js","assets/PortfolioManagerPanel-GQgEmHcj.js","assets/predictiveIntel-CDSKihw5.js","assets/PortfolioQAPanel-CeCr0DlC.js","assets/PortfolioRiskPanel-Cf3w_Hqh.js","assets/PreTradePanel-giTPFakN.js","assets/PredictiveEarningsPanel-DJXF1lhK.js","assets/RegulatoryReportPanel-L6HI8PJZ.js","assets/ResearchReportPanel-ClrLqlQK.js","assets/ResearchSuitePanel-C4SIdocr.js","assets/ScreenerPanel-Dcjypnra.js","assets/SentinelPanel-ydpaBkv1.js","assets/SsoPanel-DqJu4mEk.js","assets/TeamPanel-CffkgcRu.js","assets/TerminalAuditPanel-B-h9iWde.js","assets/TerminalBriefingPanel-DOSep6SQ.js","assets/TerminalCompliancePanel-psxB3ccX.js","assets/TradeBlotter-DTbs5y5d.js","assets/VolSurfacePanel-CyOz6oe_.js","assets/YieldCurvesPanel-DWHfAugy.js","assets/RealEstateView-CHqnki13.js","assets/graphCounts-CS45ep4c.js","assets/index-Cy97I0ND.css","assets/RealEstateView-UZ2uCh0S.js"])))=>i.map(i=>d[i]);
2import{s as Yp}from"./rolldown-runtime-aoxQmdZa.js";import{$t as Fa,Jn as HC,Qn as jS,Qt as v0,Vn as wS,Yn as xi,ar as GC,en as VC,er as TS,nn as YC,nr as KC,or as XC,rn as qC,rr as $C,tn as Wc,yn as _S}from"./vendor-C44JUHxF.js";import{t as bg}from"./cloudConfig-DLjM36Nf.js";import{A as JC,D as QC,E as oi,M as ZC,N as su,P as ov,T as eA,a as Ou,c as tA,f as b0,g as nA,h as S0,i as Fm,j as RS,k as av,o as rA,p as iA,v as oA,x as aA}from"./storage-BIf0AI-b.js";import{l as lA,t as sA}from"./terminalData-cQYNeM_6.js";import{n as Xg,s as cA}from"./claims-CWlnYsG8.js";import{a as lv,c as FS,i as _y,l as IS,n as Lu,o as ld,r as DS,s as tc,t as Sf}from"./helpers-DrdOD8BY.js";import{a as dA,i as uA,o as fA,r as qr}from"./apiBase-BqVXqfJu.js";import{n as Ry,t as ea}from"./streamConsumer-PvCSbBOZ.js";import{D as sv,a as fo,m as pA,r as gu}from"./api-BUUQ_5Ri.js";import{C as OS,D as cv,E as _t,F as Ja,H as gA,I as On,J as ig,K as LS,L as rd,O as zS,P as wf,T as zu,U as mA,V as MS,Y as g
2n,Z as El,a as Oa,f as Sg,h as cf,j as dn,m as No,p as Ma,q as Xh,s as hA,u as yA,w as uu,y as Vn,z as xA}from"./api-w9bwcNej.js";import{i as NS}from"./graphCounts-CS45ep4c.js";import{c as Fy,o as BS,s as vA,t as bA}from"./predictiveIntel-CDSKihw5.js";import{a as Hl,c as vr,f as va,i as Im,l as dv,n as Gn,o as Na,r as vt,s as SA,t as E0,u as Tf}from"./theme-Cmxze0rk.js";import{a as EA,b as kA,c as CA,l as AA,o as Mu,s as jA,x as wA,y as TA}from"./intel-VUlwLK7Y.js";import{t as Iy}from"./useWatchlist-CRf4-cLf.js";import{t as I}from"./sovereign-BKaNm6em.js";import{i as PS,n as Dm,r as Dy,t as _A}from"./aiModels-BBoTZoAO.js";import{t as RA}from"./newsLanes-DuZ-4DXJ.js";import{n as FA,t as US}from"./riskMath-CLUOZ_5Q.js";import{t as uv}from"./ComplianceDisclaimer-Dtjin33o.js";import{r as Zn}from"./tokens-BGgnTNs0.js";import{t as ws}from"./XyronMarkdown-Q8hnP07h.js";import{g as IA,h as DA}from"./vendor-ai-Bhzc3sbk.js";import{n as vn}from"./vendor-charts-C7St-aNu.js";import{n as OA,r as fv,t as $f}from"./reduceCouncilEvent-CcWnRdMw.js";import{r as LA,t as zA}from"./cortexContext-1rBL4F8g.js";import{_ as MA,f as pv,h as NA,m as BA,p as gv,t as WS}from"./IntelInteractiveChart-DIXa-sX4.js";import{a as PA,c as UA,d as WA,f as HA,h as GA,i as VA,m as YA,o as KA,p as XA,r as qA,t as Om,u as $A}from"./feedManager-CZ33L40p.js";import{o as HS,s as qg,t as JA}from"./FlashRibbon-DWQmg4uo.js";import{t as mv}from"./statusBanners-BzU4rpC5.js";import"./RealEstateView-CHqnki13.js";var qh="xyron_vault_ask",QA=120*1e3,Eg=null;function ZA(t){try{sessionStorage.setItem(qh,t),Eg=null;return}catch{Eg=t}}function ej(){try{var t=sessionStorage.getItem(qh);if(sessionStorage.removeItem(qh),t!=null)return t}catch{}var n=Eg;return Eg=null,n}function GS(t,n){var r={prompt:n||"",doc:t?{id:t.id||t.doc_id||null,name:t.name||t.display_name||"",content_preview:String(t.content_preview||t.content||"").slice(0,4e3)}:null,at:Date.now()};try{ZA(JSON.stringify(r))}catch{}try{window.dispatchEvent(new CustomEvent("xyron:vault-ask",{detail:r})),r.prompt&&window.dispatchEvent(new CustomEvent("xyron:chat-prefill",{detail:{text:r.prompt,vaultDoc:r.doc}}))}catch{}return r}function tj(t){var n=typeof t=="number"?t:QA,r=null;try{r=ej()}catch{return null}if(!r)return null;try{var o=JSON.parse(r);return!o||!o.doc||!o.doc.id||o.at&&Date.now()-Number(o.at)>n?null:o}catch{return null}}var $h="xyron:ui-prefs",$g="xyron_onboarded_v1",Oy="xyron_terminal_onboarded_v1",Jg="xyron_synth_onboarded_v1",Ly="xyron_theme",Jh="xyron.ui_prefs.owner",Jf=null;function Qg(){try{return!!localStorage.getItem("xyron_jwt_token")}catch{return!1}}function VS(){try{return El()||""}catch{return""}}function nj(){try{return localStorage.getItem(Jh)||""}catch{return""}}function rj(t){try{t?localStorage.setItem(Jh,t):localStorage.removeItem(Jh)}catch{}}function Lm(t){try{return localStorage.getItem(t)==="1"}catch{return!1}}function zm(t,n){try{n?localStorage.setItem(t,"1"):localStorage.removeItem(t)}catch{}}function og(){return{onboarded:!1,terminal_onboarded:!1,synth_onboarded:!1,theme:"dark"}}function Lp(){var t="dark";try{var n=localStorage.getItem(Ly);(n==="light"||n==="dark")&&(t=n)}catch{}return{onboarded:Lm($g),terminal_onboarded:Lm(Oy),synth_onboarded:Lm(Jg),theme:t}}function hv(){try{localStorage.removeItem($g),localStorage.removeItem(Oy),localStorage.removeItem(Jg),localStorage.removeItem(Ly)}catch{}}function yv(){if(!Qg())return!1;var t=VS(),n=nj();return!n||!t||t==="anonymous"?!1:n!==t}function yf(t){var n=Object.assign(og(),t||{});zm($g,!!n.onboarded),zm(Oy,!!n.terminal_onboarded),zm(Jg,!!n.synth_onboarded);try{(n.theme==="light"||n.theme==="dark")&&localStorage.setItem(Ly,n.theme)}catch{}var r=VS();Qg()&&r&&r!=="anonymous"&&rj(r);try{window.dispatchEvent(new Event($h))}catch{}return n}function ij(t){return!!(t.onboarded||t.terminal_onboarded||t.synth_onboarded||t.theme&&t.theme!=="dark")}function oj(t){return!!(t.onboarded||t.terminal_onboarded||t.synth_onboarded||t.theme&&t.theme!=="dark")}function aj(t){var n={};return!t||typeof t!="object"||(typeof t.onboarded=="boolean"&&(n.onboarded=t.onboarded),typeof t.terminal_onboarded=="boolean"&&(n.terminal_onboarded=t.terminal_onboarded),typeof t.synth_onboarded=="boolean"&&(n.synth_onboarded=t.synth_onboarded),(t.theme==="light"||t.theme==="dark")&&(n.theme=t.theme)),n}function aL(){return Jf||(Qg()?(Jf=ig.get().then(function(t){var n=Object.assign(og(),t&&t.preferences||{}),r=yv();r&&hv();var o=r?og():Lp();if(!oj(n))return ij(o)?ig.put(o).then(function(l){return yf(l&&l.preferences||o)}).catch(function(){return yf(o)}):yf(n);var a={onboarded:!!(n.onboarded||o.onboarded),terminal_onboarded:!!(n.terminal_onboarded||o.terminal_onboarded),synth_onboarded:!!(n.synth_onboarded||o.synth_onboarded),theme:n.theme==="light"||n.theme==="dark"?n.theme:o.theme};return yf(a),(a.onboarded!==!!n.onboarded||a.terminal_onboarded!==!!n.terminal_onboarded||a.synth_onboarded!==!!n.synth_onboarded)&&ig.put({onboarded:a.onboarded,terminal_onboarded:a.terminal_onboarded,synth_onboarded:a.synth_onboarded}).catch(function(){}),a}).catch(function(){return yv()?(hv(),og()):Lp()}).finally(function(){Jf=null}),Jf):Promise.resolve(Lp()))}function zy(t){var n=aj(t);if(!Object.keys(n).length)return Promise.resolve(Lp());var r=Lp(),o=Object.assign({},r,n);(r.onboarded||o.onboarded)&&(o.onboarded=!0),(r.terminal_onboarded||o.terminal_onboarded)&&(o.terminal_onboarded=!0),(r.synth_onboarded||o.synth_onboarded)&&(o.synth_onboarded=!0);var a=Object.assign({},n);return["onboarded","terminal_onboarded","synth_onboarded"].forEach(function(l){l in a&&(a[l]=!!o[l])}),yf(o),Qg()?ig.put(a).then(function(l){return l&&l.preferences?yf(Object.assign({},o,l.preferences)):o}).catch(function(){return o}
2):Promise.resolve(o)}var YS=["equity","index","bond","fx","commodity","crypto","hedgefund","derivative","etf","fund","cash","other"];function el(t){const n=Number(t);return Number.isFinite(n)?n:null}function kg(t){return t&&t.extra&&typeof t.extra=="object"?t.extra:{}}function xv(t,n){for(var r=kg(t),o=0;o<n.length;o++){var a=n[o],l=el(t[a]!=null&&t[a]!==""?t[a]:r[a]);if(l!=null)return l}return null}function lj(t,n){var r=kg(t),o=String(r.side||r.long_short||r.longshort||t.side||"").trim().toUpperCase().replace(/[\s/_-]+/g,"");return o==="S"||o==="SELL"||o==="SHORT"||o==="SHORTSELL"?"SHORT":o==="L"||o==="BUY"||o==="LONG"?"LONG":n!=null&&n<0?"SHORT":"LONG"}function My(t,n){if(!t||typeof t!="object")return null;const r=t.symbol||t.instrument||"";if(!r)return null;const o=el(t.quantity),a=xv(t,["avg_entry_price","entry","entry_price"]),l=xv(t,["market_price","px","last","mark","current_px","current_price","price"]),s=lj(t,o);let c=String(t.asset_class||t.assetClass||t.class||"equity").trim().toLowerCase();YS.indexOf(c)===-1&&(c="equity");const d=a!=null&&l!=null&&o!=null?(l-a)*o:null;let p=el(t.unrealised_pnl);d!=null&&(p==null||p===0&&d!==0)&&(p=d),p==null&&(p=0);let g=0;return a!=null&&a!==0&&l!=null&&(g=(l-a)/a*100*(s==="SHORT"?-1:1),g=Number(g.toFixed(2))),{id:(t.account_id?t.account_id+":":"")+r+":"+(n==null?"0":String(n)),instrument:r,symbol:r,assetClass:c,side:s,size:o!=null?Math.abs(o):t.quantity||0,sizeUnit:kg(t).size_unit||t.size_unit||"shares",entry:a,px:l,marketValue:el(t.market_value)||(l!=null&&o!=null?Math.abs(o)*l:0),pnl:p??0,pnlPct:g,var1d:el(t.var_1d)||0,_varSource:el(t.var_1d)?"broker":"",risk:t.risk||"",currency:t.currency||"USD",accountId:t.account_id||"",notes:kg(t).notes||t.notes||"",source:"live"}}function KS(t){return Array.isArray(t)?t.map(My).filter(Boolean):[]}function sj(t){if(!t||typeof t!="object")return null;var n=t.instrument||t.symbol;if(!n)return null;var r=Math.abs(Number(t.size)||0);String(t.side||"").toUpperCase()==="SHORT"&&(r=-r);var o=el(t.entry),a=el(t.px);return{account_id:t.accountId||t.account_id||"main",symbol:String(n).trim().toUpperCase(),quantity:r,asset_class:t.assetClass||"equity",currency:t.currency||"USD",avg_entry_price:o,market_price:a,extra:{side:t.side||(r<0?"SHORT":"LONG"),notes:t.notes||"",size_unit:t.sizeUnit||"shares"}}}function cj(t,n){if(!t||typeof t!="object")return null;const r=t.symbol||t.instrument||t.ticker||"";if(!r)return null;let o=String(t.asset_class||t.assetClass||t.class||"equity").trim().toLowerCase();o==="us_equity"||o==="equity"?o="equity":o==="crypto"||o==="cryptocurrency"?o="crypto":YS.indexOf(o)===-1&&(o="equity");const a=el(t.qty!=null?t.qty:t.quantity),l=el(t.avg_entry_price!=null?t.avg_entry_price:t.entry),s=el(t.current_price!=null?t.current_price:t.market_price!=null?t.market_price:t.px),c=el(t.unrealized_pl!=null?t.unrealized_pl:t.unrealized_pnl!=null?t.unrealized_pnl:t.unrealised_pnl);return{symbol:String(r),quantity:a,avg_entry_price:l,market_price:s,market_value:el(t.market_value!=null?t.market_value:t.value),unrealised_pnl:c,asset_class:o,currency:t.currency||"USD",account_id:t.account_id||n||"broker"}}function dj(t,n){return Array.isArray(t)?t.map(function(r,o){return My(cj(r,n),o)}).filter(Boolean).map(function(r){return Object.assign({},r,{source:"broker",accountId:r.accountId||n||"broker"})}):[]}function uj(t,n,r){const o=Array.isArray(t)?t:[],a=Array.isArray(n)?n:[],l={},s=Array.isArray(r)?r:[];for(let c=0;c<s.length;c++)s[c]&&(l[s[c]]=!0);for(let c=0;c<a.length;c++){const d=a[c]&&a[c].accountId;d&&(l[d]=!0)}return Object.keys(l).length?o.filter(function(c){return!(!c||c.accountId&&l[c.accountId])}).concat(a):o.slice()}var Fp="xyron.portfolio.book.v1",Ny="xyron.portfolio.nav.v1",XS="xyron.portfolio.mandate.v1",qS="xyron.portfolio.alerts.v1",_f=null;function fj(){return _f?String(_f):"anon"}function Ts(t){return t+":"+fj()}function lL(t){return _f=t!=null&&String(t).trim()!==""?String(t).trim():null,_f}function mr(t){var n=Number(t);return isFinite(n)?n:0}function Zg(t){return Math.abs(mr(t.size))}function fu(t){var n=mr(t.marketValue);return n?Math.abs(n):Zg(t)*mr(t.px)}function By(t){return(t.side==="SHORT"?-1:1)*fu(t)}function $S(t){if(!t)return null;var n=Zg(t),r=mr(t.entry),o=mr(t.px),a=t.side==="SHORT"?-1:1;if(n>0&&isFinite(r)&&r!==0&&isFinite(o)&&o!==0)return{pnl:(o-r)*n*a,pnlPct:Number(((o-r)/r*100*a).toFixed(2)),available:!0,source:"mark"};var l=mr(t.pnl);return t.pnl!=null&&t.pnl!==""&&isFinite(l)&&l!==0?{pnl:l,pnlPct:mr(t.pnlPct),available:!0,source:"book"}:{pnl:null,pnlPct:null,available:!1,source:"none"}}function JS(t){return(t||[]).map(function(n){var r=$S(n);return!r||!r.available?Object.assign({},n,{_pnlUnavailable:!0}):Object.assign({},n,{pnl:r.pnl,pnlPct:r.pnlPct,_pnlUnavailable:!1,_pnlSource:r.source})})}function zp(t){var n=t||[],r=0,o=0,a=0,l=0,s=0,c=0,d={};
2n.forEach(function(g){var f=fu(g);r+=f,o+=By(g),a+=mr(g.pnl),g.side==="SHORT"?s++:l++,(g.assetClass==="fx"||g.currency&&g.currency!=="USD")&&(c+=f);var h=g.assetClass||"other";d[h]||(d[h]={gross:0,pnl:0}),d[h].gross+=f,d[h].pnl+=mr(g.pnl)}),Object.keys(d).forEach(function(g){d[g].weightPct=r?d[g].gross/r*100:0});var p=n.map(function(g){return{symbol:g.instrument||g.symbol,weightPct:r?fu(g)/r*100:0,pnl:mr(g.pnl),side:g.side}}).sort(function(g,f){return f.weightPct-g.weightPct}).slice(0,5);return{count:n.length,gross:r,net:o,pnl:a,longCount:l,shortCount:s,fxExposurePct:r?c/r*100:0,byClass:d,topConcentration:p}}function pj(t,n){var r=n||{};return(t||[]).map(function(o){var a=r[o.instrument||o.symbol];if(!a||a.price==null)return o;var l=mr(a.price),s=Zg(o),c=mr(o.entry),d=o.side==="SHORT"?-1:1,p=c&&s?(l-c)*s*d:mr(o.pnl),g=c?Number(((l-c)/c*100*d).toFixed(2)):mr(o.pnlPct);return Object.assign({},o,{px:l,pnl:p,pnlPct:g,marketValue:s*l,_liveQuote:!0})})}function vv(){try{var t=JSON.parse(localStorage.getItem(Ts(Fp))||"null");if(t&&Array.isArray(t.positions))return t;if(_f){var n=JSON.parse(localStorage.getItem(Fp)||"null");if(n&&Array.isArray(n.positions))return localStorage.setItem(Ts(Fp),JSON.stringify(n)),localStorage.removeItem(Fp),n}return null}catch{return null}}function Qh(t){try{localStorage.setItem(Ts(Fp),JSON.stringify({positions:t||[],asOf:new Date().toISOString(),ownerId:_f||null}))}catch{}}function bv(t){return String(t&&(t.accountId||t.account_id)||"main").toLowerCase()+":"+String(t&&(t.instrument||t.symbol)||"").toUpperCase()}function gj(t,n){var r={};return(t||[]).forEach(function(o){o&&(r[bv(o)]=o)}),(n||[]).forEach(function(o){if(o){var a=bv(o),l=r[a];if(!l){r[a]=o;return}o._sessionEdited&&(!l._sessionEdited||o._sessionEdited>=l._sessionEdited)&&(r[a]=o)}}),Object.keys(r).map(function(o){return r[o]})}function Cg(){try{var t=JSON.parse(localStorage.getItem(Ts(Ny))||"[]");return Array.isArray(t)?t:[]}catch{return[]}}function mj(t){if(!t||!t.count)return Cg();var n=new Date().toISOString().slice(0,10),r=Cg().filter(function(o){return o.date!==n});r.push({date:n,gross:Math.round(t.gross),net:Math.round(t.net),pnl:Math.round(t.pnl)}),r=r.slice(-370);try{localStorage.setItem(Ts(Ny),JSON.stringify(r))}catch{}return r}function hj(t,n){var r=-1/0;if((t||[]).forEach(function(a){mr(a.pnl)>r&&(r=mr(a.pnl))}),n!=null&&mr(n)>r&&(r=mr(n)),!isFinite(r))return{peakPnl:0,currentPnl:mr(n),drawdown:0};var o=n!=null?mr(n):r;return{peakPnl:r,currentPnl:o,drawdown:Math.max(0,r-o)}}var Ef={maxPositionPct:10,maxClassPct:40,maxDrawdownAlert:25e4,maxFxPct:30,notes:""};function yj(){try{var t=JSON.parse(localStorage.getItem(Ts(XS))||"null");return t&&typeof t=="object"?Object.assign({},Ef,t):Object.assign({},Ef)}catch{return Object.assign({},Ef)}}function xj(t){try{localStorage.setItem(Ts(XS),JSON.stringify(t||{}))}catch{}return Object.assign({},Ef,t||{})}function Zh(t,n,r){var o=[];if(!t||!t.count)return o;var a=n||Ef;return(t.topConcentration||[]).forEach(function(l){a.maxPositionPct&&l.weightPct>a.maxPositionPct&&o.push({id:"pos:"+l.symbol,severity:"BREACH",text:l.symbol+" is "+l.weightPct.toFixed(1)+"% of gross — limit "+a.maxPositionPct+"%"})}),Object.keys(t.byClass||{}).forEach(function(l){var s=t.byClass[l].weightPct;a.maxClassPct&&s>a.maxClassPct&&o.push({id:"class:"+l,severity:"BREACH",text:l+" is "+s.toFixed(1)+"% of gross — class limit "+a.maxClassPct+"%"})}),a.maxFxPct&&t.fxExposurePct>a.maxFxPct&&o.push({id:"fx",severity:"WARN",text:"Non-USD exposure "+t.fxExposurePct.toFixed(1)+"% — limit "+a.maxFxPct+"%"}),a.maxDrawdownAlert&&r&&r.drawdown>mr(a.maxDrawdownAlert)&&o.push({id:"drawdown",severity:"BREACH",text:"P&L drawdown "+Math.round(r.drawdown).toLocaleString()+" exceeds alert level "+mr(a.maxDrawdownAlert).toLocaleString()}),o}var xf=[{id:"eq10",label:"Equity −10%",assumptions:"All equity/ETF/index −10%, crypto −15%",shocks:{equity:-10,etf:-10,index:-10,crypto:-15}},{id:"eq20",label:"Equity crash −20%",assumptions:"Equity/ETF/index −20%, crypto −35%, commodities −10%",shocks:{equity:-20,etf:-20,index:-20,crypto:-35,commodity:-10}},{id:"rates",label:"Rates +100bp",assumptions:"Bonds −7 (duration proxy), equity −4, crypto −8",shocks:{bond:-7,equity:-4,etf:-4,
2index:-4,crypto:-8}},{id:"riskoff",label:"Risk-off shock",assumptions:"Equity −12, crypto −30, commodities −8, FX carry −5, bonds +2",shocks:{equity:-12,etf:-12,index:-12,crypto:-30,commodity:-8,fx:-5,bond:2}},{id:"dollar",label:"Dollar spike",assumptions:"FX −6, commodities −6, crypto −10, equity −3",shocks:{fx:-6,commodity:-6,crypto:-10,equity:-3,etf:-3}}];function QS(t,n){var r=n&&n.shocks||{},o=0,a={},l=[];return(t||[]).forEach(function(s){var c=s.assetClass||"other",d=r[c]!=null?r[c]:0,p=By(s)*d/100;o+=p,a[c]||(a[c]=0),a[c]+=p,l.push({symbol:s.instrument||s.symbol,side:s.side,impact:p})}),l.sort(function(s,c){return s.impact-c.impact}),{total:o,byClass:a,worst:l.slice(0,5)}}function vj(){try{var t=JSON.parse(localStorage.getItem(Ts(qS))||"[]");return Array.isArray(t)?t:[]}catch{return[]}}function Sv(t){try{localStorage.setItem(Ts(qS),JSON.stringify(t||[]))}catch{}return t||[]}function bj(t,n,r){var o=[];return{rules:(t||[]).map(function(a){if(a.triggeredAt)return a;var l=!1,s="";if(a.type==="pos_loss_pct"?(n||[]).forEach(function(d){mr(d.pnlPct)<=-Math.abs(mr(a.value))&&(l=!0,s=(d.instrument||d.symbol)+" "+mr(d.pnlPct).toFixed(1)+"%")}):a.type==="drawdown_abs"&&r&&r.drawdown>=Math.abs(mr(a.value))&&(l=!0,s=Math.round(r.drawdown).toLocaleString()),!l)return a;var c=Object.assign({},a,{triggeredAt:new Date().toISOString(),detail:s});return o.push(c),c}),fired:o}}var Ev={equity:2.2,etf:1.6,index:1.6,crypto:5.5,fx:.8,commodity:2,bond:.6,future:2.5,option:6,hedgefund:1.2},Sj=1.65;function ZS(t){var n=Ev[t.assetClass]!=null?Ev[t.assetClass]:2;return fu(t)*n*Sj/100}function e2(t){var n=0;return{positions:(t||[]).map(function(r){return r&&r._varSource==="broker"&&Number(r.var1d)?r:fu(r)?(n++,Object.assign({},r,{var1d:Math.round(ZS(r)),_varEstimated:!0})):Object.assign({},r,{_varUnavailable:!0,var1d:0})}),estimatedCount:n}}function Ej(t){if(!t)return{level:null,available:!1};var n=fu(t),r=mr(t.var1d);if(!n||!isFinite(n)||n<=0)return{level:null,available:!1};r||(r=ZS(t));var o=r/n*100,a=Math.abs(mr(t.pnlPct)),l=t.assetClass||"",s="MEDIUM";return l==="crypto"||o>=4.5||a>=15?s="HIGH":o<2&&a<5&&(s="LOW"),{level:s,available:!0,varPct:o}}function kj(t){var n=e2(JS(t));return{positions:n.positions.map(function(r){var o=Ej(r);return Object.assign({},r,{risk:o.available?o.level:null,_riskComputed:o.available})}),estimatedCount:n.estimatedCount}}function Cj(t,n){var r=[],o=n&&n.gross?n.gross:0;return(t||[]).forEach(function(a){var l=a.instrument||a.symbol||"?",s=a.assetClass||"";a._pnlUnavailable!==!0&&mr(a.pnlPct)<=-8&&r.push({id:"loss:"+l,level:"High",pos:l,assetClass:s,type:"LOSS",time:"book",msg:l+" is down "+mr(a.pnlPct).toFixed(1)+"% from entry — review stop and thesis."});var c=fu(a);(t||[]).length>=2&&o>0&&c/o>=.4&&r.push({id:"conc:"+l,level:"High",pos:l,assetClass:s,type:"CONCENTRATION",time:"book",msg:l+" is "+(c/o*100).toFixed(1)+"% of gross exposure (single-name concentration)."}),a.risk==="HIGH"&&mr(a.var1d)>0&&r.push({id:"var:"+l,level:"High",pos:l,assetClass:s,type:"VaR",time:"book",msg:l+" 1-day 95% VaR estimate is "+Math.round(mr(a.var1d)).toLocaleString()+" ("+(s||"position")+" vol assumption)."})}),r}function Aj(t,n,r,o){var a=(t||[]).map(function(x){return Object.assign({},x)}),l=(n.symbol||"").toUpperCase(),s=Math.abs(Number(n.quantity)||0),c=Number(n.price)||0;if(!l||!s||!c)return{newBreaches:[],metrics:zp(a)};var d=a.find(function(x){return(x.instrument||x.symbol||"").toUpperCase()===l}),p=(n.side==="SELL"?-1:1)*s*c;if(d){var g=By(d)+p;d.side=g<0?"SHORT":"LONG",d.marketValue=Math.abs(g),d.size=c?Math.abs(g)/c:d.size,d.px=c}else a.push({instrument:l,symbol:l,assetClass:n.assetClass||"equity",side:n.side==="SELL"?"SHORT":"LONG",size:s,entry:c,px:c,marketValue:s*c,pnl:0,pnlPct:0,currency:"USD"});var f=Zh(zp(t||[]),r,o).map(function(x){return x.id}),h=zp(a);return{newBreaches:Zh(h,r,o).filter(function(x){return f.indexOf(x.id)===-1}),metrics:h}}function jj(t){var n={};return(t||[]).forEach(function(r){var o=(r.symbol||r.instrument||"").toUpperCase();if(o){var a=Math.abs(Number(r.quantity!=null?r.quantity:r.qty)||0),l=Number(r.price!=null?r.price:r.exec_price)||0;if(!(!a||!l)){var s=String(r.side||r.type||"").toUpperCase(),c=s.indexOf("SELL")!==-1||s.indexOf("SHORT")!==-1;
2n[o]||(n[o]={symbol:o,bought:0,sold:0,buys:0,sells:0}),c?(n[o].sold+=a*l,n[o].sells++):(n[o].bought+=a*l,n[o].buys++)}}}),Object.keys(n).map(function(r){var o=n[r];return Object.assign({},o,{realizedCashflow:o.sold-o.bought})}).sort(function(r,o){return o.realizedCashflow-r.realizedCashflow})}function wj(t,n){var r={};(t||[]).forEach(function(a){a&&a.date&&(r[a.date]=a)}),(n||[]).forEach(function(a){!a||!a.date||(r[a.date]={date:a.date,gross:Math.round(Number(a.gross)||0),net:Math.round(Number(a.net)||0),pnl:Math.round(Number(a.pnl)||0),_server:!0})});var o=Object.keys(r).sort().map(function(a){return r[a]}).slice(-370);try{localStorage.setItem(Ts(Ny),JSON.stringify(o))}catch{}return o}var t2="xyron_email_drafts";function Kp(){try{var t=localStorage.getItem(t2);return t?JSON.parse(t):[]}catch{return[]}}function Py(t){try{localStorage.setItem(t2,JSON.stringify(t))}catch{}}function Tj(){return Kp().sort(function(t,n){return(n.updatedAt||0)-(t.updatedAt||0)})}function _j(t){var n=Kp(),r=Date.now(),o=n.findIndex(function(l){return l.id===t.id}),a=Object.assign({},t,{updatedAt:r});return a.createdAt||(a.createdAt=r),a.id||(a.id="draft_"+r+"_"+Math.random().toString(36).slice(2,8)),o>=0?n[o]=a:n.unshift(a),Py(n),a}function Rj(t){var n=Kp().filter(function(r){return r.id!==t});return Py(n),n}function Fj(t){var n={id:"draft_"+Date.now()+"_"+Math.random().toString(36).slice(2,8),to:t.to||"",cc:t.cc||"",bcc:t.bcc||"",subject:t.subject||"",body:t.body||"",fromAccount:t.fromAccount||"",replyToId:t.replyToId||null,forwardFromId:t.forwardFromId||null,source:t.source||"chat",aiInstruction:t.aiInstruction||"",classification:t.classification||null,priority:t.priority||"STANDARD",createdAt:Date.now(),updatedAt:Date.now()},r=Kp();return r.unshift(n),Py(r),n}function Mm(){return Kp().length}var n2=[{chord:"⌘K",label:"Command palette",group:"Global",globalish:!0,registeredAt:"src/components/terminal/CommandLine.jsx"},{chord:"⌘/",label:"Focus command line",group:"Global",globalish:!0,registeredAt:"src/App.jsx"},{chord:"⌘⇧H",label:"History drawer",group:"Global",globalish:!0,registeredAt:"src/App.jsx"},{chord:"⌘N",label:"New chat",group:"Global",globalish:!0,registeredAt:"src/App.jsx"},{chord:"⌘⇧/",label:"Show this cheatsheet",group:"Global",globalish:!0,registeredAt:"src/App.jsx"},{chord:"⌘1…9",label:"Load saved layout 1–9",group:"Launchpad",globalish:!0,registeredAt:"src/components/terminal/Launchpad.jsx"},{chord:"⌘1",label:"Search",group:"Dock",globalish:!0,registeredAt:"src/components/chat/ChatView.jsx"},{chord:"⌘2",label:"Intel drawer",group:"Dock",globalish:!0,registeredAt:"src/components/chat/ChatView.jsx"},{chord:"⌘3",label:"Video",group:"Dock",globalish:!0,registeredAt:"src/components/chat/ChatView.jsx"},{chord:"⌘4",label:"Map",group:"Dock",globalish:!0,registeredAt:"src/components/chat/ChatView.jsx"},{chord:"⌘5",label:"Vault",group:"Dock",globalish:!0,registeredAt:"src/components/chat/ChatView.jsx"},{chord:"⌘6",label:"Email",group:"Dock",globalish:!0,registeredAt:"src/components/chat/ChatView.jsx"},{chord:"⌘7",label:"Calendar",group:"Dock",globalish:!0,registeredAt:"src/components/chat/ChatView.jsx"},{chord:"⌘8",label:"Messenger",group:"Dock",globalish:!0,registeredAt:"src/components/chat/ChatView.jsx"},{chord:"1",label:"All alerts",group:"TODAY filter",globalish:!1,registeredAt:"src/components/chat/ChatView.jsx"},{chord:"2",label:"Critical only",group:"TODAY filter",globalish:!1,registeredAt:"src/components/chat/ChatView.jsx"},{chord:"3",label:"High only",group:"TODAY filter",globalish:!1,registeredAt:"src/components/chat/ChatView.jsx"},{chord:"4",label:"Watch only",group:"TODAY filter",globalish:!1,registeredAt:"src/components/chat/ChatView.jsx"},{chord:"?",label:"Open feature drawer",group:"Terminal",globalish:!0,registeredAt:"src/components/terminal/ArenbergMarketsView.jsx"},{chord:"N",label:"News feed",group:"Terminal",globalish:!1,registeredAt:"src/components/terminal/terminalHeader.jsx"},{chord:"S",label:"Social intel",group:"Terminal",globalish:!1,registeredAt:"src/components/terminal/terminalHeader.jsx"},{chord:"E",label:"Econ calendar",group:"Terminal",globalish:!1,registeredAt:"src/components/terminal/terminalHeader.jsx"},{chord:"P",label:"Portfolio view",group:"Terminal",globalish:!1,registeredAt:"src/components/terminal/terminalHeader.jsx"},{chord:"/",label:"Focus search",group:"Email",globalish:!1,registeredAt:"src/components/EmailIntelligence.jsx"},{chord:"#",label:"Trash selected",group:"Email",globalish:!1,registeredAt:"src/components/EmailIntelligence.jsx"},{chord:"!",label:"Mark spam selected",group:"Email",globalish:!1,registeredAt:"src/components/EmailIntelligence.jsx"},{chord:"E",label:"Archive selected",group:"Email",globalish:!1,registeredAt:"src/components/EmailIntelligence.jsx"},{chord:"R",label:"Open in chat",group:"Email",globalish:!1,registeredAt:"src/components/EmailIntelligence.jsx"},{chord:"F",label:"Toggle float/dock",group:"Floating card",globalish:!1,registeredAt:"src/components/dashboard/Floating
2CardFrame.jsx"},{chord:"Esc",label:"Dock floating card",group:"Floating card",globalish:!1,registeredAt:"src/components/dashboard/FloatingCardFrame.jsx"},{chord:"←↑→↓",label:"Nudge 10px",group:"Floating card",globalish:!1,registeredAt:"src/components/dashboard/FloatingCardFrame.jsx"},{chord:"⇧+arrows",label:"Nudge 50px",group:"Floating card",globalish:!1,registeredAt:"src/components/dashboard/FloatingCardFrame.jsx"},{chord:"⌥+arrows",label:"Resize bottom-right",group:"Floating card",globalish:!1,registeredAt:"src/components/dashboard/FloatingCardFrame.jsx"},{chord:"⌘⇧+arrows",label:"Snap to viewport edge",group:"Floating card",globalish:!1,registeredAt:"src/components/dashboard/FloatingCardFrame.jsx"},{chord:"⌘⇧C",label:"Centre in viewport",group:"Floating card",globalish:!1,registeredAt:"src/components/dashboard/FloatingCardFrame.jsx"},{chord:"⌘.",label:"Cycle Cortex mode",group:"Cortex",globalish:!1,registeredAt:"src/components/cortex/CortexDrawer.jsx"},{chord:"⌘⇧D",label:"Toggle dev mode",group:"Dev",globalish:!0,registeredAt:"src/components/modals/LoginModal.jsx"}];function sL(){return n2.filter(function(t){return t.chord&&t.chord.indexOf("⌘")===0})}function Ij(t){return t?n2.filter(function(n){return n.group===t}):[]}var i=Yp(XC(),1),ke="monospace",Dj=[{id:"inbox",icon:"📥",tip:"INBOX",badgeKey:"inbox"},{id:"sent",icon:"📤",tip:"SENT"},{id:"starred",icon:"⭐",tip:"STARRED",badgeKey:"starred"},{id:"folders",icon:"📁",tip:"FOLDERS"},{id:"drafts",icon:"📝",tip:"DRAFTS"},{id:"spam",icon:"⛔",tip:"SPAM",badgeKey:"spam"},{id:"trash",icon:"🗑",tip:"TRASH",badgeKey:"trash"},{id:"allmail",icon:"📬",tip:"ALL MAIL"},{id:"followups",icon:"🔔",tip:"FOLLOW-UPS"},{id:"contacts",icon:"👤",tip:"PEOPLE"},{id:"rules",icon:"⚙️",tip:"RULES"},{id:"templates",icon:"📋",tip:"TEMPLATES"},{id:"signature",icon:"✍️",tip:"SIGNATURE"},{id:"accounts",icon:"🔑",tip:"ACCOUNTS"}],Oj={exploratory:"#6B9AC4",transactional:"#3FB950",opportunistic:"#D4AF5C",deferential:"#8B949E",vague:"#5A7090","prestige-signaling":"#D4AF5C","pressure-based":"#F97583","information-seeking":"#6B9AC4","partnership-driven":"#3FB950","weakly-qualified":"#D4AF5C","serious-operator":"#3FB950"},kv={low:"#3A4A5E",medium:"#D4AF5C",high:"#F97583",critical:"#D44040"},Lj={none:"#3A4A5E",low:"#5A7090",medium:"#D4AF5C",high:"#3FB950",strategic:"#D4AF5C"},k0=[{id:"reply",label:"Reply",prompt:"Draft a professional reply"},{id:"followup",label:"Follow-up",prompt:"Draft a professional follow-up email"},{id:"intro",label:"Intro",prompt:"Draft a professional introduction email"},{id:"decline",label:"Decline",prompt:"Draft a polite but clear decline"},{id:"schedule",label:"Schedule",prompt:"Draft an email to schedule a call"},{id:"negotiate",label:"Negotiate",prompt:"Draft a strategic negotiation email"},{id:"internal",label:"Internal",prompt:"Draft a concise internal executive update"},{id:"outreach",label:"Outreach",prompt:"Draft a professional investor or partnership outreach email"}];function qs(t){var n=parseInt(t.slice(1,3),16),r=parseInt(t.slice(3,5),16),o=parseInt(t.slice(5,7),16);return n+","+r+","+o}var Ct={bg:"#05080D",card:"#06080F",line:"#111820",dim:"#3A4A5E",txt:"#C9D1D9",hi:"#E6EDF3",accent:"#6B9AC4",purple:"#D4AF5C",green:"#3FB950",orange:"#D4AF5C",red:"#F97583"},Nu={google:{label:"Generate App Password (requires 2FA)",url:"https://myaccount.google.com/apppasswords",note:"2FA must be enabled on your Google account first."},apple:{label:"Generate App-Specific Password",url:"https://account.apple.com/account/manage",note:"Sign-In and Security → App-Specific Passwords"},yahoo:{label:"Generate App Password",url:"https://login.yahoo.com/account/security/app-passwords",note:"Account Security → App passwords"},aol:{label:"Generate App Password",url:"https://login.aol.com/account/security/app-passwords",note:"Same flow as Yahoo (AOL is Yahoo-owned)"},microsoft:{label:null,url:null,note:"If this is a work account, contact IT to enable IMAP/app passwords. Personal Outlook: account.microsoft.com/security → Advanced security → App passwords."},fastmail:{label:"Generate App Password",url:"https://app.fastmail.com/settings/security/integrations",note:"Settings → Privacy & Security → Integrations"},yandex:{label:"Generate App Password",url:"https://id.yandex.com/security/app-passwords",note:"Yandex ID → Security → App passwords"},zoho:{label:"Generate App Password",url:"https://accounts.zoho.com/u/h#all_account/applinkedapps",note:"Account Security → App Passwords"}};
2function zj({onClose:t,initialDraft:n,onStatusMessage:r,commandBusy:o,mode:a,tone:l,onModeChange:s,onToneChange:c,onActiveDraftChange:d,onPrefillCommand:p}){var g=(0,i.useState)([]),f=g[0],h=g[1],x=(0,i.useState)(!1),v=x[0],y=x[1],k=(0,i.useState)([]),A=k[0],j=k[1],E=(0,i.useState)(""),C=E[0],_=E[1],w=(0,i.useState)(null),O=w[0],M=w[1],U=(0,i.useState)(0),ee=U[0],N=U[1],V=(0,i.useState)(null),z=V[0],oe=V[1],P=(0,i.useState)([]),W=P[0],R=P[1],ae=(0,i.useState)(!1),q=ae[0],ge=ae[1],X=(0,i.useState)([]),de=X[0],We=X[1],te=(0,i.useState)(!1),_e=te[0],ve=te[1],Ne=(0,i.useState)([]),$e=Ne[0],Pe=Ne[1],ot=(0,i.useState)(""),re=ot[0],we=ot[1],b=(0,i.useState)(null),He=b[0],tt=b[1],Ae=(0,i.useState)(!1),Be=Ae[0],Fe=Ae[1],ft=(0,i.useState)(""),St=ft[0],Xe=ft[1],It=(0,i.useState)("to"),Rt=It[0],$=It[1],Ue=(0,i.useState)(!1),Ie=Ue[0],Q=Ue[1],rt=(0,i.useState)(null),jt=rt[0],tn=rt[1];a||(a="reply"),l||(l="formal");var pt=(0,i.useState)(null),gt=pt[0],qt=pt[1],Pt=(0,i.useState)(null);Pt[0];var Kt=Pt[1],xe=(0,i.useRef)(null),fe=(0,i.useRef)(null),Ye=(0,i.useRef)(!1),Qe=(0,i.useRef)(null),ut=(0,i.useState)(null),wt=ut[0],H=ut[1],Z=(0,i.useState)(!1),T=Z[0],Y=Z[1],B=(0,i.useState)(1),ie=B[0],ue=B[1],ne=(0,i.useState)(""),Me=ne[0],nt=ne[1],ct=(0,i.useState)(""),je=ct[0],Le=ct[1],be=(0,i.useState)(""),Wt=be[0],Te=be[1],it=(0,i.useState)(""),Tt=it[0],bn=it[1],$r=(0,i.useState)(""),ai=$r[0],Nn=$r[1],er=(0,i.useState)(null),Tn=er[0],ra=er[1],ba=(0,i.useState)(!1),Ro=ba[0],Ba=ba[1],Ii=(0,i.useState)(!1),he=Ii[0],st=Ii[1],Et=(0,i.useState)(""),Mt=Et[0],mn=Et[1],Kn=(0,i.useState)(null),br=Kn[0],qn=Kn[1],nl=(0,i.useState)(!1),$n=nl[0],ia=nl[1],dc=(0,i.useState)({}),Sa=dc[0],kl=dc[1],Cl=(0,i.useState)({}),to=Cl[0],oa=Cl[1],rl=(0,i.useState)(!1),il=rl[0],Pa=rl[1],Zl=(0,i.useState)([]),Al=Zl[0],es=Zl[1],Ea=(0,i.useState)(!1),uc=Ea[0],fi=Ea[1],no=(0,i.useState)(!1),Fs=no[0],Xi=no[1],Uo=(0,i.useState)("from_email"),dd=Uo[0],fc=Uo[1],pc=(0,i.useState)(""),Ua=pc[0],Is=pc[1],ud=(0,i.useState)("SET_JUNK"),aa=ud[0],gc=ud[1],mc=(0,i.useState)(""),ts=mc[0],Ds=mc[1],ns=(0,i.useState)(null),la=ns[0],hc=ns[1],fd=(0,i.useState)(!1),yc=fd[0],rs=fd[1],xc=(0,i.useState)(null),dr=xc[0],Jr=xc[1],vc=(0,i.useState)(!1),or=vc[0],po=vc[1],bc=(0,i.useState)(null),qi=bc[0],go=bc[1],Sc=(0,i.useState)(null),tr=Sc[0],Fo=Sc[1],Ec=(0,i.useState)("PRIMARY"),mu=Ec[0],jl=Ec[1],Wo=(0,i.useState)(""),Ho=Wo[0],Qn=Wo[1],vi=(0,i.useState)(!1);vi[0];var is=vi[1],Gr=(0,i.useState)([]),Di=Gr[0],Os=Gr[1],Ai=(0,i.useState)(""),Wa=Ai[0],kc=Ai[1],wl=(0,i.useState)({}),Ha=wl[0],hu=wl[1],pd=(0,i.useState)([]);pd[0],pd[1];var Ls=(0,i.useState)([]),ol=Ls[0],al=Ls[1],ll=(0,i.useState)(!1),sa=ll[0],nr=ll[1],Oi=(0,i.useState)(""),Qr=Oi[0],Sr=Oi[1],ji=(0,i.useState)(null),Io=ji[0],sl=ji[1],li=(0,i.useState)(!1),Li=li[0],ka=li[1],Er=(0,i.useRef)(null),pi=(0,i.useState)(Date.now()),gd=pi[0],Tr=pi[1],zi=(0,i.useState)(!1),Tl=zi[0],zs=zi[1];(0,i.useEffect)(function(){if(!Ye.current){Ye.current=!0,rd.accounts().then(function(le){var ye=le.accounts||[];j(ye),ye.length>0&&(_(ye[0].email),_t.counts(ye[0].email).then(function(De){kl(De)}).catch(function(){}),_t.getSignature(ye[0].email).then(function(De){Qn(De.signature||"")}).catch(function(){}))}).catch(function(){}),_t.contacts(200).then(function(le){M(le.contacts||[])}).catch(function(){}),_t.templates().then(function(le){Os(le.templates||[])}).catch(function(){}),N(Mm());try{var m=localStorage.getItem("xyron_email_thread");if(m){var L=JSON.parse(m);L&&L.length>0&&Date.now()-L[L.length-1]._savedAt<864e5?h(L.filter(function(le){return le.role!=="actions"})):Ee("Xyron active. Draft, reply, send, research, analyze, attach, search vault, assess risks, profile psychology — command me.")}else Ee("Xyron active. Draft, reply, send, research, analyze, attach, search vault, assess risks, profile psychology — command me.")}catch{Ee("Xyron active. Draft, reply, send, research, analyze, attach, search vault, assess risks, profile psychology — command me.")}}},[]),(0,i.useEffect)(function(){if(f.length>1)try{var m=f.filter(function(L){return L.role!=="actions"&&!L._streaming}).slice(-50);m.forEach(function(L){L._savedAt=Date.now()}),localStorage.setItem("xyron_email_thread",JSON.stringify(m))}catch{}},[f]),(0,i.useEffect)(function(){return Er.current=setInterval(function(){C&&z&&(z==="inbox"||z==="sent"||z==="starred")&&(_t.inbox(C,30,null,{inbox:"INBOX",sent:"SENT",starred:"STARRED"}[z]||"INBOX").then(function(m){R(m.messages||[]),Jr(m.next_page_token||null)}
2).catch(function(){}),_t.counts(C).then(function(m){kl(m)}).catch(function(){}),Tr(Date.now()))},6e4),function(){Er.current&&clearInterval(Er.current)}},[C,z]),(0,i.useEffect)(function(){if(!Tl)return;function m(le){le.key==="Escape"&&(le.preventDefault(),typeof le.stopImmediatePropagation=="function"&&le.stopImmediatePropagation(),zs(!1))}function L(le){le.target.closest&&(le.target.closest('[data-testid="email-shortcut-help-popover"]')||le.target.closest('[data-testid="email-shortcut-help-button"]'))||zs(!1)}return window.addEventListener("keydown",m,!0),document.addEventListener("mousedown",L),function(){window.removeEventListener("keydown",m,!0),document.removeEventListener("mousedown",L)}},[Tl]),(0,i.useEffect)(function(){function m(L){if(!(L.target.tagName==="INPUT"||L.target.tagName==="TEXTAREA"||L.target.tagName==="SELECT")&&!(!z||z==="accounts"||z==="rules")){var le=br||W;if(L.key==="/"){L.preventDefault();var ye=document.querySelector("[data-email-search]");ye&&ye.focus();return}var De=kr();if(De.length>0){if(L.key==="#"||L.key==="Delete"){L.preventDefault(),gi("trash"),Zi(De.length+" deleted","trash",De);return}if(L.key==="e"){L.preventDefault(),gi("archive"),Zi(De.length+" archived","archive",De);return}if(L.key==="!"){L.preventDefault(),gi("spam"),Zi(De.length+" marked spam","spam",De);return}}if(L.key==="r"&&le.length>0){var Se=le.find(function(Je){return to[Je.gmail_id]});if(Se){Il(Se);return}}}}return window.addEventListener("keydown",m),function(){window.removeEventListener("keydown",m)}},[z,W,br,to]),(0,i.useEffect)(function(){if(n){if(n._command){var m=n._command;({inbox:1,sent:1,drafts:1,followups:1,contacts:1,accounts:1,starred:1,spam:1,trash:1,allmail:1,rules:1,templates:1,signature:1})[m]&&oe(z===m?null:m);return}if(n._userText)ss(n._userText);else if(n.to||n.subject||n.body){var L={id:"d"+Date.now(),role:"draft",draft:{to:n.to||"",cc:"",bcc:"",subject:n.subject||"",body:n.body||"",fromAccount:C,attachments:[]},ts:Fn()};h(function(le){return le.concat([L])}),Cd(L.id,n.to||"")}}},[n]),(0,i.useEffect)(function(){var m=xe.current;if(m){m.scrollTop=m.scrollHeight;var L=setTimeout(function(){m.scrollTop=m.scrollHeight},100);return function(){clearTimeout(L)}}},[f]),(0,i.useEffect)(function(){z==="inbox"?si("INBOX"):z==="sent"?si("SENT"):z==="starred"?si("STARRED"):z==="spam"?si("SPAM"):z==="trash"?si("TRASH"):z==="allmail"?Tc():z==="followups"?yd():z==="rules"?as():z==="folders"&&ro(),z&&(mn(""),qn(null),oa({}),Pa(!1),sl(null))},[z,C]),(0,i.useEffect)(function(){if(d){for(var m=null,L=f.length-1;L>=0;L--)if(f[L].role==="draft"&&!f[L].sent){m=f[L];break}d(!!m)}},[f]);function Fn(){return new Date().toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})}function Ee(m,L){var le=L||"s"+Date.now()+Math.random();return h(function(ye){return ye.concat([{id:le,role:"system",text:m,ts:Fn()}])}),le}function _r(m){h(function(L){return L.filter(function(le){return le.id!==m})})}function Vr(m,L,le){h(function(ye){return ye.map(function(De){return De.id===m?Object.assign({},De,{text:L,role:le||De.role}):De})})}function os(m){h(function(L){return L.concat([{id:"u"+Date.now()+Math.random(),role:"user",text:m,ts:Fn()}])})}function Ga(m){return m.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/^[-]{3,}$/gm,'<div style="border-top:1px solid #1A2332;margin:8px 0"></div>').replace(/\n{3,}/g,`
3
4`).replace(/\*\*([^*]+)\*\*/g,'<strong style="color:#E6EDF3;font-weight:700">$1</strong>').replace(/^#{1,3}\s+(.+)$/gm,'<div style="font-family:monospace;font-size:11px;font-weight:700;color:#D4AF5C;letter-spacing:.08em;margin-top:12px;margin-bottom:5px;border-bottom:1px solid rgba(212,175,92,0.12);padding-bottom:4px">$1</div>').replace(/^([A-Z][A-Z\s/&-]+:)/gm,'<span style="font-family:monospace;font-size:10px;font-weight:700;color:#6B9AC4;letter-spacing:.06em">$1</span>').replace(/^[-*]\s+(.+)$/gm,'<div style="margin-left:12px;color:#C9D1D9;margin-bottom:3px"><span style="color:#D4AF5C;margin-right:6px;font-size:7px">&#9656;</span>$1</div>').replace(/^\d+[.)]\s+(.+)$/gm,'<div style="margin-left:12px;color:#C9D1D9;margin-bottom:3px">$1</div>').replace(/`([^`]+)`/g,'<code style="font-family:monospace;font-size:11px;background:#151D2B;border:1px solid rgba(56,189,248,0.2);border-radius:3px;padding:1px 5px;color:#6B9AC4">$1</code>').replace(/\n\n/g,'<div style="height:8px"></div>').replace(/\n/g,"<br/>")}var Cc=120,Ac=400,Ms=2,cl=28,_l=3,md=7,Go=24,jc=14,hd=9,ca=12;function wc(m){if(m<Cc)return{chunk:Ms,ms:cl};if(m<Ac){var L=(m-Cc)/(Ac-Cc);return{chunk:Math.round(_l+(md-_l)*L),ms:Math.round(Go+(jc-Go)*L)}}return{chunk:hd,ms:ca}}function Rl(){var m=xe.current;m&&(m.scrollTop=m.scrollHeight)}function Vo(m,L,le,ye,De){var Se=null,Je=null;typeof ye=="function"?Je=ye:ye&&typeof ye=="object"&&(Se=ye,Je=De||null);var ht={id:m,role:le||"system",text:"​",ts:Fn(),_streaming:!0};Se&&(ht=Object.assign(ht,Se)),h(function(pn){return pn.concat([ht])}),H(m);var Ht=0;function Bt(){if(!Qe.current){setTimeout(Bt,16);return}if(Ht>=L.length){H(null),h(function($t){return $t.map(function(Xt){return Xt.id===m?Object.assign({}
4,Xt,{text:L,_streaming:!1}):Xt})}),Rl(),Je&&Je();return}var pn=wc(Ht);Ht=Math.min(Ht+pn.chunk,L.length),Qe.current.innerHTML=Ga(L.substring(0,Ht)),Rl(),setTimeout(Bt,pn.ms)}setTimeout(Bt,cl)}function $i(m,L,le,ye,De,Se){var Je={id:m,role:ye||"analysis",text:"​",ts:Fn(),_streaming:!0};De&&(Je=Object.assign(Je,De)),h(function(zn){return zn.concat([Je])}),H(m);var ht="",Ht=0,Bt=null,pn=!1,$t=!1;function Xt(){if(Bt=null,!Qe.current){Bt=setTimeout(Xt,16);return}if(Ht>=ht.length){if($t){H(null),h(function(Cn){return Cn.map(function(Fr){return Fr.id===m?Object.assign({},Fr,{text:ht,_streaming:!1}):Fr})}),Rl(),pn||(pn=!0,Se&&Se({}));return}Bt=setTimeout(Xt,30);return}var zn=wc(Ht);Ht=Math.min(Ht+zn.chunk,ht.length),Qe.current.innerHTML=Ga(ht.substring(0,Ht)),Rl(),Bt=setTimeout(Xt,zn.ms)}_t.analyzeStream(L,le,function(zn){ht+=zn,Bt||(Bt=setTimeout(Xt,cl))},function(zn){$t=!0,Bt||(Bt=setTimeout(Xt,0))},function(zn){$t=!0,ht||(ht="Failed: "+(zn||"try again")),Bt||(Bt=setTimeout(Xt,0))}),Bt=setTimeout(Xt,cl)}function Yr(m,L,le,ye){var De={id:m,role:"system",text:"​",ts:Fn(),_streaming:!0};h(function(Xt){return Xt.concat([De])}),H(m);var Se="",Je=0,ht=null,Ht=!1,Bt=!1,pn=null;function $t(){if(ht=null,!Qe.current){ht=setTimeout($t,16);return}if(Je>=Se.length){if(Bt){H(null),_r(m),Ht||(Ht=!0,ye&&ye(pn));return}ht=setTimeout($t,30);return}var Xt=wc(Je);Je=Math.min(Je+Xt.chunk,Se.length),Qe.current.innerHTML=Ga(Se.substring(0,Je)),Rl(),ht=setTimeout($t,Xt.ms)}_t.composeStream(L,le,function(Xt){Se+=Xt,ht||(ht=setTimeout($t,cl))},function(Xt){Bt=!0,pn=Xt&&Xt.parsed||null,ht||(ht=setTimeout($t,0))},function(Xt){Bt=!0,Se="⚠ Compose failed: "+(Xt||"try again"),ht||(ht=setTimeout($t,0))}),ht=setTimeout($t,cl)}function si(m){C&&(ge(!0),Jr(null),_t.inbox(C,30,null,m).then(function(L){R(L.messages||[]),Jr(L.next_page_token||null),ge(!1),Tr(Date.now())}).catch(function(){ge(!1)}))}function yd(){C&&(ge(!0),_t.followUps(C).then(function(m){We(m.follow_ups||[]),ge(!1)}).catch(function(){ge(!1)}))}function Tc(){C&&(ge(!0),_t.search(C,"in:anywhere",30).then(function(m){R(m.messages||[]),ge(!1)}).catch(function(){ge(!1)}))}function as(){fi(!0),_t.rules().then(function(m){es(m.rules||[]),fi(!1)}).catch(function(){fi(!1)})}function da(){C&&_t.counts(C).then(function(m){kl(m)}).catch(function(){})}function ro(){C&&(nr(!0),_t.folders(C).then(function(m){al((m.folders||[]).filter(function(L){return L.type==="user"||!L.type})),nr(!1)}).catch(function(){nr(!1)}))}function _c(m){!C||!m.trim()||_t.createFolder(C,m.trim()).then(function(L){L.created?(Ee("Folder created: "+m.trim()),ro()):Ee("⚠ "+(L.error||"Folder creation failed"))}).catch(function(){Ee("Folder creation failed.")})}function Do(m){C&&_t.deleteFolder(C,m).then(function(L){L.deleted?(Ee("Folder deleted."),ro()):Ee("⚠ "+(L.error||"Delete failed"))}).catch(function(){Ee("Folder delete failed.")})}function Ji(m,L,le){C&&_t.moveToFolder(C,m,L,le).then(function(ye){ye.moved?(Zi("Moved to folder"),(z==="inbox"||z==="folders")&&R(function(De){return De.filter(function(Se){return Se.gmail_id!==m})})):Ee("⚠ "+(ye.error||"Move failed"))}).catch(function(){Ee("Move failed.")})}function xd(){!C||Li||(ka(!0),Ee("Auto-sorting inbox by sender… This may take a moment."),_t.autoSort(C,100).then(function(m){ka(!1),m.sorted!=null?Ee("✅ "+m.message):Ee("⚠ "+(m.error||"Auto-sort failed")),ro()}).catch(function(){ka(!1),Ee("Auto-sort failed.")}))}function wi(){C&&(Ee("Clearing archived emails…"),_t.clearArchives(C,100).then(function(m){m.deleted!=null?Ee("✅ "+m.message):Ee("⚠ "+(m.error||"Clear failed"))}).catch(function(){Ee("Clear archives failed.")}))}function dl(m){sl(m),ge(!0),_t.inbox(C,30,null,m.id||m.name).then(function(L){R(L.messages||[]),Jr(L.next_page_token||null),ge(!1)}).catch(function(){ge(!1)})}var Ns=[{id:"red",label:"🔴 Red",color:"#D44040"},{id:"orange",label:"🟠 Orange",color:"#D4AF5C"},{id:"yellow",label:"🟡 Yellow",color:"#FFC107"},{id:"green",label:"🟢 Green",color:"#3FB950"},{id:"blue",label:"🔵 Blue",color:"#6B9AC4"},{id:"purple",label:"🟣 Purple",color:"#D4AF5C"},{id:"urgent",label:"⚠ Urgent",color:"#D44040"},{id:"followup",label:"🔔 Follow-Up",color:"#D4AF5C"},{id:"review",label:"🔍 Review",color:"#6B9AC4"},{id:"important",label:"⭐ Important",color:"#D4AF5C"}];function yu(m,L){!C||!m||_t.flagEmail(C,m,L).then(function(le){le.flagged?Zi("Flagged: "+L):Ee("⚠ "+(le.error||"Flag failed"))}).catch(function(){Ee("Flag failed.")})}function Fl(m,L){!C||!m||_t.unflagEmail(C,m,L).then(function(le){le.unflagged?Zi("Unflagged: "+L):Ee("⚠ "+(le.error||"Unflag failed"))}).catch(function(){Ee("Unflag failed.")})}function vd(m){C&&(ge(!0),oe("inbox"),_t.listFlagged(C,m,30).then(function(L){R(L.messages||[]),ge(!1),Ee("Showing "+m.toUpperCase()+" flagged emails ("+(L.count||0)+")")}
4).catch(function(){ge(!1),Ee("Failed to load flagged emails.")}))}function mo(){!C||!Mt.trim()||(ia(!0),qn(null),_t.search(C,Mt.trim(),30).then(function(m){qn(m.messages||[]),ia(!1)}).catch(function(){ia(!1),qn([])}))}function ho(m){C&&_t.trash(C,m).then(function(){R(function(L){return L.filter(function(le){return le.gmail_id!==m})}),br&&qn(function(L){return(L||[]).filter(function(le){return le.gmail_id!==m})}),da(),Zi("Moved to trash","trash",[m])}).catch(function(){})}function bd(m){C&&_t.untrash(C,m).then(function(){R(function(L){return L.filter(function(le){return le.gmail_id!==m})}),da(),Zi("Restored from trash")}).catch(function(){})}function yo(m){C&&_t.archive(C,m).then(function(){R(function(L){return L.filter(function(le){return le.gmail_id!==m})}),da(),Zi("Archived","archive",[m])}).catch(function(){})}function io(m,L){C&&_t.star(C,m,!L).then(function(){R(function(le){return le.map(function(ye){return ye.gmail_id===m?Object.assign({},ye,{is_starred:!L}):ye})}),da()}).catch(function(){})}function Rc(m,L){C&&_t.spam(C,m,L).then(function(){R(function(le){return le.filter(function(ye){return ye.gmail_id!==m})}),da()}).catch(function(){})}function Oo(m,L){C&&_t.markRead(C,m,L).then(function(){R(function(le){return le.map(function(ye){return ye.gmail_id===m?Object.assign({},ye,{is_read:L}):ye})}),da()}).catch(function(){})}function oo(m){oa(function(L){var le=Object.assign({},L);return le[m]?delete le[m]:le[m]=!0,le})}function xu(){var m=br||W;if(il)oa({}),Pa(!1);else{var L={};m.forEach(function(le){L[le.gmail_id]=!0}),oa(L),Pa(!0)}}function kr(){return Object.keys(to).filter(function(m){return to[m]})}function gi(m){var L=kr();!L.length||!C||_t.batchAction(C,L,m).then(function(){R(function(le){return le.filter(function(ye){return!to[ye.gmail_id]})}),br&&qn(function(le){return(le||[]).filter(function(ye){return!to[ye.gmail_id]})}),oa({}),Pa(!1),da()}).catch(function(){})}function Sd(){Ua.trim()&&_t.addRule({type:"JUNK",condition_field:dd,condition_value:Ua.trim(),action:aa,action_value:ts}).then(function(){Xi(!1),Is(""),Ds(""),as()}).catch(function(){})}function Qi(m){_t.deleteRule(m).then(function(){as()}).catch(function(){})}function Lo(m){!C||yc||(rs(!0),hc(null),_t.thread(m,C).then(function(L){hc(L),rs(!1)}).catch(function(){rs(!1)}))}function Zi(m,L,le){go(m),Fo(L&&le?{action:L,ids:le}:null),setTimeout(function(){go(null),Fo(null)},5e3)}function Ca(){if(!(!tr||!C)){var m=tr.action,L=tr.ids;m==="trash"?L.forEach(function(ye){_t.untrash(C,ye).catch(function(){})}):(m==="archive"||m==="spam")&&L.forEach(function(ye){_t.spam(C,ye,!1).catch(function(){}),_t.markRead(C,ye,!1).catch(function(){})}),go(null),Fo(null);var le={inbox:"INBOX",sent:"SENT",starred:"STARRED",spam:"SPAM",trash:"TRASH"};z&&le[z]&&si(le[z]),da()}}function Fc(){if(!(!C||!dr||or)){po(!0);var m={inbox:"INBOX",sent:"SENT",starred:"STARRED",spam:"SPAM",trash:"TRASH"}[z]||"INBOX";_t.inbox(C,30,dr,m).then(function(L){R(function(le){return le.concat(L.messages||[])}),Jr(L.next_page_token||null),po(!1)}).catch(function(){po(!1)})}}function zo(){C&&_t.emptyTrash(C).then(function(m){R([]),da(),Zi((m&&m.deleted||0)+" permanently deleted")}).catch(function(){})}function ci(){C&&_t.emptySpam(C).then(function(m){R([]),da(),Zi((m&&m.deleted||0)+" permanently deleted")}).catch(function(){})}function ao(m){var L=m.emailData||m,le=`
5
6---------- Forwarded message ----------
7From: `+(L.from_name||L.from_email||"")+`
8Date: `+(L.date||"")+`
9Subject: `+(L.subject||"")+`
10To: `+(L.to_emails?L.to_emails.join(", "):"")+`
11
12`+(m.body||L.snippet||""),ye="d"+Date.now();h(function(De){return De.concat([{id:ye,role:"draft",draft:{to:"",cc:"",bcc:"",subject:"Fwd: "+(L.subject||""),body:le,fromAccount:C,attachments:[]},ts:Fn()}])}),oe(null)}function Aa(m){if(!m)return"";try{var L=new Date(m),le=new Date-L,ye=Math.floor(le/6e4);if(ye<1)return"now";if(ye<60)return ye+"m ago";var De=Math.floor(ye/60);if(De<24)return De+"h ago";var Se=Math.floor(De/24);return Se===1?"Yesterday":Se<7?Se+"d ago":L.toLocaleDateString("en-GB",{day:"numeric",month:"short"})}catch{return m.substring(0,16)}}function bi(m){!C||Ha[m]||_t.listAttachments(m,C).then(function(L){hu(function(le){var ye=Object.assign({},le);return ye[m]=L.attachments||[],ye})}).catch(function(){})}function Yn(m,L){C&&_t.downloadAttachment(m,L.attachment_id,C).then(function(le){if(le&&le.data){for(var ye=atob(le.data.replace(/-/g,"+").replace(/_/g,"/")),De=new Uint8Array(ye.length),Se=0;Se<ye.length;Se++)De[Se]=ye.charCodeAt(Se);var Je=new Blob([De],{type:L.mime_type||"application/octet-stream"}),ht=URL.createObjectURL(Je),Ht=document.createElement("a");Ht.href=ht,Ht.download=L.filename||"attachment",Ht.click(),URL.revokeObjectURL(ht)}}).catch(function(){Ee("Download failed.")})}function Ic(){C&&_t.setSignature(C,Ho).then(function(){is(!1),Zi("Signature saved")}
12).catch(function(){})}function Ed(){var m=Re();if(!m||!Wa.trim()){Ee("Name a template and have an active draft.");return}_t.saveTemplate(Wa.trim(),m.draft.subject,m.draft.body).then(function(){kc(""),_t.templates().then(function(L){Os(L.templates||[])}).catch(function(){}),Zi("Template saved")}).catch(function(){})}function vu(m){var L="d"+Date.now();h(function(le){return le.concat([{id:L,role:"draft",draft:{to:"",cc:"",bcc:"",subject:m.subject||"",body:(m.body||"")+(Ho?`
13
14`+Ho:""),fromAccount:C,attachments:[]},ts:Fn()}])}),oe(null)}function bu(m){_t.deleteTemplate(m).then(function(){_t.templates().then(function(L){Os(L.templates||[])}).catch(function(){})}).catch(function(){})}function Su(m,L){var le="Email - "+(m.subject||"untitled"),ye="From: "+(m.from_name||m.from_email||"")+`
15To: `+(m.to_emails?m.to_emails.join(", "):"")+`
16Date: `+(m.date||"")+`
17Subject: `+(m.subject||"")+`
18
19`+(L||"");uu.generatePDF(le,ye,!1).then(function(De){De?Zi("PDF downloaded"):Ee("PDF generation failed.")}).catch(function(){Ee("PDF generation failed.")})}function Eu(){if(C){var m={inbox:"INBOX",sent:"SENT",starred:"STARRED",spam:"SPAM",trash:"TRASH"};z&&m[z]&&(ge(!0),_t.inbox(C,30,null,m[z]).then(function(L){R(L.messages||[]),Jr(L.next_page_token||null),ge(!1),Tr(Date.now())}).catch(function(){ge(!1)})),da()}}function Il(m){oe(null);var L="em"+Date.now();h(function(le){return le.concat([{id:L,role:"email",emailData:m,body:null,ts:Fn()}])}),_t.message(m.gmail_id,C).then(function(le){var ye=le.body||"(No body)";h(function(Se){return Se.map(function(Je){return Je.id===L?Object.assign({},Je,{body:ye}):Je})});var De="intel"+Date.now();h(function(Se){return Se.concat([{id:De,role:"intel",loading:!0,ts:Fn()}])}),_t.fastIntel(ye,m.from_email||m.from_name||"",m.subject||"").then(function(Se){h(function(ht){return ht.map(function(Ht){return Ht.id===De?Object.assign({},Ht,{loading:!1,data:Se}):Ht})});var Je=nn(Se,ye,m);h(function(ht){return ht.concat([{id:"ea"+Date.now(),role:"actions",actions:Je,ts:Fn()}])}),/\b(valuation|revenue|pricing|invest|equity|fund|capital|market|stock|share|portfolio|asset|return|yield|rate|gdp|inflation|trade|tariff)\b/i.test(ye)&&_t.liveContext(ye.substring(0,300),{prices:!0,news:!0,macro:!0}).then(function(ht){ht.has_data&&ht.context&&Vo("mkt"+Date.now(),ht.context,"research",{persona:"Xyron Intelligence — Live Market Data"})}).catch(function(){}),_t.schedulingDetect(ye,m.subject||"").then(function(ht){if(ht.has_scheduling_intent&&ht.suggested_actions){var Ht=ht.suggested_actions.map(function(Bt){return{label:Bt.label,cmd:"_scheduling_"+Bt.action,emailData:m,sourceText:ye}});ht.dates_mentioned&&ht.dates_mentioned.length>0&&Ee("Dates detected: "+ht.dates_mentioned.join(", ")),Ht.length>0&&h(function(Bt){return Bt.concat([{id:"sched"+Date.now(),role:"actions",actions:Ht,ts:Fn()}])})}}).catch(function(){}),m.from_email&&_t.dossier(m.from_email,m.from_name||"").then(function(ht){if(ht&&(ht.email_history&&ht.email_history.length>0||ht.vault_documents&&ht.vault_documents.length>0)){var Ht="";ht.interaction_stats&&(Ht+="RELATIONSHIP: "+ht.interaction_stats.total_emails+" emails"+(ht.interaction_stats.organisation?" | "+ht.interaction_stats.organisation:"")+(ht.interaction_stats.avg_response_hours?" | Avg reply: "+Math.round(ht.interaction_stats.avg_response_hours)+"h":"")),ht.email_history&&ht.email_history.length>0&&(Ht+=`
20
21RECENT:
22`+ht.email_history.slice(0,3).map(function(Bt){return"- "+Bt.subject}).join(`
23`)),ht.vault_documents&&ht.vault_documents.length>0&&(Ht+=`
24
25VAULT DOCS:
26`+ht.vault_documents.map(function(Bt){return"- "+Bt.name}).join(`
27`)),Ht&&Vo("doss"+Date.now(),Ht,"analysis",{persona:"Counterparty Intelligence"})}}).catch(function(){})}).catch(function(){h(function(Je){return Je.map(function(ht){return ht.id===De?Object.assign({},ht,{loading:!1,data:{what_they_want:"Analysis unavailable",error:!0}}):ht})});var Se=nn(null,ye,m);h(function(Je){return Je.concat([{id:"ea"+Date.now(),role:"actions",actions:Se,ts:Fn()}])})})}).catch(function(){h(function(le){return le.map(function(ye){return ye.id===L?Object.assign({},ye,{body:"Failed to load."}):ye})})})}function mi(m){tt(m),ve(!0),$e.length===0&&gn.list().then(function(L){Pe(L.documents||[])}).catch(function(){})}function kd(m){h(function(L){return L.map(function(le){if(le.id===He&&le.role==="draft"){var ye=(le.draft.attachments||[]).slice();return ye.some(function(De){return De.id===m.doc_id})||ye.push({id:m.doc_id,name:m.name,type:m.type||m.doc_type||"document",source:"vault"}),Object.assign({},le,{draft:Object.assign({},le.draft,{attachments:ye})})}return le})}),ve(!1),Ee("Attached “"+m.name+"” from Vault")}function ku(m,L){h(function(le){return le.map(function(ye){return ye.id===m&&ye.role==="draft"?Object.assign({},ye,{draft:Object.assign({},ye.draft,{attachments:(ye.draft.attachments||[]).filter(function(De){return De.id!==L})})}):ye})})}function Cd(m,L){if(!(!L||L.indexOf("@")!==-1)){var le=L.toLowerCase().trim(),ye=(O||[]).filter(function(De){return(De.n
27ame||"").toLowerCase().indexOf(le)!==-1||(De.email||"").toLowerCase().indexOf(le)!==-1||(De.organisation||"").toLowerCase().indexOf(le)!==-1});ye.length>0?(h(function(De){return De.map(function(Se){return Se.id===m&&Se.role==="draft"?Object.assign({},Se,{resolved:{status:"found",matches:ye.slice(0,5)}}):Se})}),ye.length===1?(Ce(m,"to",ye[0].email),Ee("Resolved: "+ye[0].name+" — "+ye[0].email)):Ee("Found "+ye.length+" matches for “"+L+"” — select below")):(h(function(De){return De.map(function(Se){return Se.id===m&&Se.role==="draft"?Object.assign({},Se,{resolved:{status:"not_found",query:L}}):Se})}),Ee("No contact for “"+L+"” — enter manually or search online"))}}function ls(m){var L=Be||(Re()||{}).id;if(L){var le=m.split(",").map(function(ye){return ye.trim()}).filter(Boolean);h(function(ye){return ye.map(function(De){if(De.id===L&&De.role==="draft"){var Se=Rt||"to",Je=(De.draft[Se]||"").split(",").map(function(Ht){return Ht.trim()}).filter(Boolean);le.forEach(function(Ht){Je.indexOf(Ht)===-1&&Je.push(Ht)});var ht=Object.assign({},De.draft);return ht[Se]=Je.join(", "),Object.assign({},De,{draft:ht})}return De})}),Ee("Added "+(le.length>1?le.length+" recipients":le[0])+" to "+(Rt||"to").toUpperCase())}}function K(m,L){var le=Re();if(!le){Ee("No active draft. Draft an email first.");return}if(L=L||"to",m.indexOf("@")!==-1){var ye=(le.draft[L]||"").split(",").map(function(Je){return Je.trim()}).filter(Boolean);ye.indexOf(m)===-1&&ye.push(m),Ce(le.id,L,ye.join(", ")),Ee("Added "+m+" to "+L.toUpperCase())}else{var De=(O||[]).filter(function(Je){return(Je.name||"").toLowerCase().indexOf(m.toLowerCase())!==-1});if(De.length===1){var Se=(le.draft[L]||"").split(",").map(function(Je){return Je.trim()}).filter(Boolean);Se.indexOf(De[0].email)===-1&&Se.push(De[0].email),Ce(le.id,L,Se.join(", ")),Ee("Added "+De[0].name+" ("+De[0].email+") to "+L.toUpperCase())}else De.length>
271?(Ee("Multiple matches for “"+m+"”"),$(L),Fe(le.id),Xe(m)):(Ee("No contact for “"+m+"”"),$(L),Fe(le.id),Xe(m))}}function Ce(m,L,le){h(function(ye){return ye.map(function(De){if(De.id===m&&De.role==="draft"){var Se=Object.assign({},De.draft);return Se[L]=le,Object.assign({},De,{draft:Se})}return De})})}function Re(){for(var m=f.length-1;m>=0;m--)if(f[m].role==="draft"&&!f[m].sent)return f[m];return null}function at(){for(var m=f.length-1;m>=0;m--){if(f[m].role==="email"&&f[m].body)return f[m].body.substring(0,2500);if(f[m].role==="user"&&(f[m].text||"").length>100)return f[m].text.substring(0,2500)}return null}function lt(){for(var m=f.length-1;m>=0;m--)if(f[m].role==="email")return{body:f[m].body,emailData:f[m].emailData};return null}function Jt(){for(var m=f.length-1;m>=0;m--)if(f[m].role==="intel"&&f[m].data&&!f[m].data.error)return f[m].data;return null}function nn(m,L,le){var ye=(L||"").substring(0,2e3),De=le||{},Se={sourceText:ye,emailData:De},Je=[],ht=m&&m.counterparty_type||"",Ht=m&&m.commercial_value||"",Bt=m&&m.psychological_posture||"",pn=m&&m.risk_flags||[],$t=m&&m.suggested_action||"",Xt=(L||"").toLowerCase(),zn=/\b(valuation|revenue|pricing|invest|equity|fund|capital|return|multiple|roi|margin|cost|fee|percent|%|dollar|\$|million|billion)\b/.test(Xt),Cn=/\b(nda|contract|binding|liability|terms|agreement|clause|warrant|indemnity|confidential|gdpr|regulatory|compliance)\b/.test(Xt),Fr=/\b(market|sector|industry|benchmark|comp|valuation|ipo|m&a|acquisition|portfolio|allocation|asset)\b/.test(Xt),hn=/\b(press|media|announce|public|brand|reputation|stakeholder|journalist|article|coverage)\b/.test(Xt),hi=ht==="investor"||/\b(lp|fund|allocat|commitment|capital call|distribution)\b/.test(Xt);return Je.push({label:"Draft reply",cmd:"_compose_reply",sourceText:ye,emailData:De}),Je.push({label:"Forward",cmd:"_forward_email",sourceText:ye,emailData:De}),($t==="qualify"||$t==="delay")&&Je.push(Object.assign({label:"Buy time — hold response",cmd:"_persona_delay"},Se)),$t==="advance"&&Je.push(Object.assign({label:"Advance — move forward",cmd:"_persona_advance"},Se)),$t==="decline"&&Je.push(Object.assign({label:"Decline gracefully",cmd:"_compose_decline"},Se)),Je.push(Object.assign({label:"What do they really want?",cmd:"_persona_true_intent"},Se)),Je.push(Object.assign({label:"How serious are they?",cmd:"_persona_seriousness"},Se)),$t!=="advance"&&Je.push(Object.assign({label:"What should I do next?",cmd:"_persona_next_action"},Se)),(Ht==="high"||Ht==="strategic"||zn||Bt==="transactional")&&(Je.push(Object.assign({label:"Analyze financial terms",cmd:"_persona_financial"},Se)),Je.push(Object.assign({label:"What’s our walk-away number?",cmd:"_persona_walkaway"},Se))),zn&&Je.push(Object.assign({label:"Flag hidden fees or dilution",cmd:"_persona_hidden_costs"},Se)),(Ht==="high"||Bt==="pressure-based"||Bt==="opportunistic"||Bt==="transactional")&&(Je.push(Object.assign({label:"Counter their position",cmd:"_persona_counter"},Se)),Je.push(Object.assign({label:"Accept with conditions",cmd:"_persona_conditional"},Se)),Bt==="pressure-based"&&Je.push(Object.assign({label:"Deflect and redirect",cmd:"_persona_deflect"},Se))),(pn.length>0||Cn)&&(Je.push(Object.assign({label:"Flag legal risks",cmd:"_persona_legal_risk"},Se)),Je.push(Object.assign({label:"What should I NOT say?",cmd:"_persona_dont_say"},Se)),Cn&&Je.push(Object.assign({label:"Is any of this binding?",cmd:"_persona_binding"},Se))),!Cn&&pn.length>0&&Je.push(Object.assign({label:"Protect our position",cmd:"_persona_protect"},Se)),Fr&&(Je.push(Object.assign({label:"Market context for this",cmd:"_persona_market_context"},Se)),Je.push(Object.assign({label:"Compare to market benchmarks",cmd:"_persona_benchmarks"},Se))),hi&&(Je.push(Object.assign({label:"Assess investor seriousness",cmd:"_persona_investor_quality"},Se)),Je.push(Object.assign({label:"What info should we gate?",cmd:"_persona_info_gate"},Se)),Je.push(Object.assign({label:"Draft LP-grade response",cmd:"_persona_lp_response"},Se))),hn&&(Je.push(Object.assign({label:"Reputational risk?",cmd:"_persona_reputation"},Se)),Je.push(Object.assign({label:"Draft for maximum discretion",cmd:"_persona_discreet"},Se))),(ht==="unknown"||Bt==="vague"||Bt==="opportunistic"||Bt==="weakly-qualified")&&(Je.push(Object.assign({label:"Research this person",cmd:"_research_sender"},Se)),Je.push(Object.assign({label:"Is this entity legitimate?",cmd:"_persona_verify"},Se))),Je.push(Object.assign({label:"Our history with them?",cmd:"_persona_history"},Se)),Je.push(Object.assign({label:"Escalate internally",cmd:"_persona_escalate"},Se)),Je.push(Object.assign({label:"Schedule a call instead",cmd:"_persona_schedule"},Se)),Je.push(Object.assign({label:"Extract action items",cmd:"_extract_actions"},Se)),(zn||Fr||hi)&&Je.push({label:"Pull live market data",cmd:"_fetch_live_context",query:(Xt.match(/\b[A-Z]{2,5}\b/g)||[]).slice(0,5).join(" ")+" market data"}),Je.slice(0,16)}function Nr(m,L){var le={sourceText:(m||"").substring(0,2e3),emailData:L||{}},ye=Re(),De=ye?(ye.draft.body||"").toLowerCase():"",Se=[],Je=Jt(),ht=Je&&Je.commercial_value||"",Ht=Je&&Je.psychological_posture||"",Bt=/\b(valuation|pricing|cost|fee|terms|percent|number|offer)\b/.test(De),pn=/\b(attach|deck|document|enclosed|profile|proposal)\b/.test(De);return Se.push({label:"Send it",cmd:"_pd_send"}
27),Se.push({label:"Make it shorter",cmd:"_pd_variant",variant:"shorter"}),Se.push({label:"More diplomatic",cmd:"_pd_variant",variant:"more diplomatic"}),Se.push({label:"More assertive",cmd:"_pd_variant",variant:"more assertive"}),Se.push({label:"Make it warmer",cmd:"_pd_variant",variant:"warmer"}),pn&&Se.push({label:"Attach the deck",cmd:"_pd_attach_deck"}),(!ye||!ye.draft.to)&&Se.push(Object.assign({label:"Find their email",cmd:"_research_sender"},le)),Se.push({label:"Review for risks",cmd:"_pd_risk_review"}),Se.push({label:"Save for later",cmd:"_pd_save"}),(ht==="high"||ht==="strategic"||Bt)&&(Se.push({label:"Sharpen the numbers",cmd:"_pd_variant",variant:"more precise with numbers and terms"}),Se.push({label:"Remove pricing details",cmd:"_pd_variant",variant:"remove all pricing and financial details, keep it high-level"}),Se.push({label:"Add disclaimer",cmd:"_pd_variant",variant:"add appropriate disclaimers and caveats"})),(Ht==="pressure-based"||Ht==="opportunistic")&&(Se.push({label:"Strengthen position",cmd:"_pd_variant",variant:"stronger negotiating position, less concession"}),Se.push({label:"Remove concessions",cmd:"_pd_variant",variant:"remove any concessions or soft language"})),(Ht==="partnership-driven"||Ht==="exploratory")&&(Se.push({label:"Add credentials",cmd:"_pd_variant",variant:"add brief credibility and track record reference"}),Se.push({label:"Suggest next step",cmd:"_pd_variant",variant:"add a clear next step proposal at the end"})),Se.push({label:"Try different angle",cmd:"_pd_variant",variant:"completely different strategic approach"}),Se.push({label:"Executive concise",cmd:"_pd_variant",variant:"executive brief style, maximum 4 sentences"}),Se.push({label:"Save as template",cmd:"_save_as_template"}),Se.slice(0,14)}function Zr(m){var L=f.find(function(De){return De.id===m});if(!(!L||!L.draft)){var le=L.draft;if(!le.to||!le.subject){Ee("⚠ Need recipient and subject.");return}if(!C&&A.length===0){Mi(m),Ee("No sender connected — saved to Drafts.");return}y(!0),Ee("Sending…");var ye={from_account:le.fromAccount||C,to:le.to.split(",").map(function(De){return De.trim()}).filter(Boolean),subject:le.subject,body:le.body+(Ho?`
28
29`+Ho:"")};le.cc&&(ye.cc=le.cc.split(",").map(function(De){return De.trim()}).filter(Boolean)),le.bcc&&(ye.bcc=le.bcc.split(",").map(function(De){return De.trim()}).filter(Boolean)),le.attachments&&le.attachments.length>0&&(ye.vault_attachment_ids=le.attachments.map(function(De){return De.id})),le.replyToMessageId&&(ye.reply_to_message_id=le.replyToMessageId),_t.send(ye).then(function(){y(!1),Ee("✅ Sent to "+le.to),Kt("Sent"),setTimeout(function(){Kt(null)},4e3),h(function(De){return De.map(function(Se){return Se.id===m?Object.assign({},Se,{sent:!0}):Se})}),h(function(De){return De.concat([{id:"ps"+Date.now(),role:"actions",actions:[{label:"🔔 RECOMMENDED FOLLOW-UP (48h)",cmd:"_post_followup_note"},{label:"DRAFT FOLLOW-UP",cmd:"_post_followup"},{label:"COMPOSE NEW",cmd:"_post_new"}],ts:Fn()}])})}).catch(function(){y(!1),Mi(m),Ee("Send failed — saved to Drafts.")})}}function Mi(m){var L=f.find(function(ye){return ye.id===m});if(!(!L||!L.draft)){var le=L.draft;_j({to:le.to,cc:le.cc,bcc:le.bcc,subject:le.subject,body:le.body,fromAccount:le.fromAccount||C,source:"chat"}),N(Mm()),Ee("Draft saved.")}}function Ti(m,L){if(!v){var le=Re();y(!0);var ye=Ee("Xyron is composing…"),De=L||"";if(!De){for(var Se=f.length-1;Se>=0;Se--)if(f[Se].role==="user"||f[Se].role==="analysis"||f[Se].role==="email"){De=(f[Se].text||f[Se].body||"").substring(0,1500);break}}var Je=le&&!le.sent&&le.draft.to||"",ht=k0.find(function(Xt){return Xt.id===a})||k0[0],Ht=(m||ht.prompt)+" Tone: "+l+"."+(Je?" To: "+Je:"");le&&!le.sent&&(le.draft.attachments||[]).length>0&&(Ht+=`
30Attached: `+le.draft.attachments.map(function(Xt){return Xt.name}).join(", ")+". Reference naturally.");for(var Bt="",pn=f.length-1;pn>=0;pn--)if(f[pn].role==="intel"&&f[pn].data&&!f[pn].data.error){var $t=f[pn].data;Bt=`
31Intelligence: They want: `+($t.what_they_want||"")+". Posture: "+($t.psychological_posture||"")+". Strategy: "+($t.reply_strategy||"")+". Risk flags: "+(($t.risk_flags||[]).join(", ")||"none")+".";break}Bt&&(Ht+=Bt),De&&(Ht+=`
32
33Context:
34`+De),_t.compose(Ht).then(function(Xt){if(y(!0),_r(ye),Xt&&Xt.error){y(!1),Ee("⚠ "+Xt.error);return}ei(Xt),y(!1)}).catch(function(Xt){y(!1),Vr(ye,"Generation failed: "+(Xt&&Xt.message?Xt.message:"Try again."))})}}function Bn(m){m&&_t.analyze(m,`Provide exactly 4 lines:
35Intent: (one line)
36Approach: (one line)
37Risks: (one line)
38Next action: (one line)
39No bullets, no headers.`).then(function(L){var le=L.analysis||"";le.length>20&&Vo("brief"+Date.now(),le,"analysis")}).catch(function(){})}function ua(m){if(!m){Ee("No content.");return}y(!0);var L=Ee("Extracting action items…");
39_t.analyze(m.substring(0,2e3),"Extract a numbered list of concrete action items. No preamble.").then(function(le){y(!1),_r(L),Vo("ai"+Date.now(),le.analysis||"None found.","analysis")}).catch(function(){y(!1),Vr(L,"Extraction failed.")})}function fa(m){var L=Re();if(!L||!L.draft.body){Ee("No active draft to create a variant from.");return}if(!v){y(!0);var le=Ee("Generating "+m+" version…"),ye="Rewrite this email in a "+m+` style. Same intent and recipients.
40
41Original:
42Subject: `+L.draft.subject+`
43
44`+L.draft.body;_t.compose(ye).then(function(De){if(y(!1),_r(le),De&&(De.body||De.subject)){var Se="d"+Date.now();h(function(Je){return Je.concat([{id:"sv"+Date.now(),role:"system",text:m.toUpperCase()+" variant generated. Compare and choose.",ts:Fn()},{id:Se,role:"draft",draft:{to:L.draft.to,cc:L.draft.cc,bcc:L.draft.bcc,subject:De.subject||L.draft.subject,body:De.body||"",fromAccount:L.draft.fromAccount,attachments:L.draft.attachments||[]},ts:Fn(),variant:m}])})}else Ee("Variant generation failed.")}).catch(function(){y(!1),Vr(le,"Variant generation failed.")})}}function ja(m,L){var le=f.find(function(Se){return Se.id===m});if(!(!le||!le.draft)){var ye=le.draft,De=[];if(ye.to||De.push("No recipient"),ye.subject||De.push("No subject"),(!ye.body||ye.body.length<10)&&De.push("Empty body"),De.length>0){Ee("⚠ Cannot send: "+De.join(" • "));return}y(!0),Ee("Pre-send intelligence check…"),_t.preSend(ye.body||"",ye.to||"",ye.subject||"").then(function(Se){y(!1);var Je=(Se.risks||[]).concat(Se.structural_warnings||[]).filter(function(ht,Ht,Bt){return Bt.indexOf(ht)===Ht});Se.sensitive_data&&Se.sensitive_data.contains_sensitive&&Je.push("⚠ SENSITIVE: "+Se.sensitive_data.types.join(", ")),Je.length>0&&Ee("Pre-send: "+Je.join(" • ")+`
45Tone: `+(Se.tone_assessment||"—")+`
46Clarity: `+(Se.clarity_score||"—")+`
47Recommendation: `+(Se.send_recommendation||"review")),L&&L()}).catch(function(){y(!1),L&&L()})}}function ul(m){tn(m),Q(!0)}function Ni(m){var L=m.target.files;if(!(!L||L.length===0)){var le=jt||(Re()||{}).id;if(le){y(!0);for(var ye=L.length,De=0;De<L.length;De++)(function(Se){gn.upload(Se,Se.name,"email_attachment").then(function(Je){if(Je&&(Je.id||Je.doc_id)){var ht=Je.id||Je.doc_id;h(function(Ht){return Ht.map(function(Bt){if(Bt.id===le&&Bt.role==="draft"){var pn=(Bt.draft.attachments||[]).slice();return pn.some(function($t){return $t.id===ht})||pn.push({id:ht,name:Je.filename||Se.name,type:Je.type||"document",source:"upload"}),Object.assign({},Bt,{draft:Object.assign({},Bt.draft,{attachments:pn})})}return Bt})}),Ee("Uploaded “"+Se.name+"”")}else Ee("Upload failed for “"+Se.name+"”");ye--,ye===0&&y(!1)}).catch(function(){Ee("Upload failed for “"+Se.name+"”"),ye--,ye===0&&y(!1)})})(L[De]);m.target.value="",Q(!1)}}}function Yo(m){if(m.cmd==="_compose_reply"){y(!0);var L=Ee("Xyron is composing reply…"),le=(k0.find(function(Dt){return Dt.id===a})||k0[0]).prompt+". Tone: "+l+`.
48
49Original message:
50`+(m.sourceText||"").substring(0,1500),ye=m.emailData&&m.emailData.from_email||"",De=m.emailData&&m.emailData.gmail_id||"";_t.compose(le).then(function(Dt){if(y(!1),_r(L),Dt&&Dt.error){Ee("⚠ "+Dt.error);return}ei(Dt,ye,De)}).catch(function(Dt){y(!1),Vr(L,"Draft failed: "+(Dt&&Dt.message?Dt.message:"Try again."))});return}if(m.cmd==="_forward_email"){for(var Se=null,Je=f.length-1;Je>=0;Je--)if(f[Je].role==="email"){Se=f[Je];break}Se?ao(Se):Ee("No email to forward.");return}if(m.cmd==="_compose_decline"){s&&s("decline"),Ti("Draft a polite but clear decline",(m.sourceText||"").substring(0,1500));return}if(m.cmd==="_compose_followup"){s&&s("followup"),Ti("Draft a professional follow-up",(m.sourceText||"").substring(0,1500));return}if(m.cmd==="_analyze_summary"){if(!m.sourceText){Ee("No content.");return}y(!0),$i("sum"+Date.now(),(m.sourceText||"").substring(0,2e3),"Summarize key points and action items concisely.","analysis",null,function(){y(!1)});return}if(m.cmd==="_extract_actions"){ua(m.sourceText||"");return}if(m.cmd==="_deep_analysis"){if(!m.sourceText){Ee("No content to analyze.");return}var ht=m.emailData&&(m.emailData.from_email||m.emailData.from_name)||"",Ht=m.emailData&&m.emailData.subject||"";y(!0),$i("deep"+Date.now(),m.sourceText.substring(0,3e3),"Perform deep strategic analysis. Sender: "+ht+". Subject: "+Ht+". Analyze: what they really want, how serious they are, hidden objectives, psychological profile, commercial risk, best response angle, whether to advance/qualify/delay/decline, leverage points, red flags.","analysis",{persona:"Xyron Intelligence — Deep Analysis"},function(){y(!1)});return}if(m.cmd==="_psychology"){if(!m.sourceText){Ee("No content.");return}y(!0),$i("psy"+Date.now(),m.sourceText.substring(0,2e3),"Analyze the sender's psychological posture, communication style, likely negotiation a
50pproach, hidden motivations, and what they may be trying to secure beyond the literal words. Be direct and strategic.","analysis",{persona:"Xyron Intelligence — Psychology"},function(){y(!1)});return}if(m.cmd==="_risk_analysis"){if(!m.sourceText){Ee("No content.");return}y(!0),$i("risk"+Date.now(),m.sourceText.substring(0,2e3),"Identify risks in this communication: over-disclosure risk, weak negotiation posture, exclusivity trap, scope creep, false urgency, free consulting extraction, legal sensitivity, credibility concerns, reputation exposure. Also identify leverage points and strategic advantages. Compact warnings, no essays.","analysis",{persona:"Xyron Intelligence — Risk Assessment"},function(){y(!1)});return}if(m.cmd==="_research_sender"){var Bt=m.emailData&&m.emailData.from_email||"",pn=m.emailData&&m.emailData.from_name||Bt;if(!pn){Ee("No sender information.");return}y(!0),Ee("Researching "+pn+"…"),_t.webResearch(pn).then(function(Dt){if(y(!1),Dt.success&&Dt.content){if(Vo("wr"+Date.now(),Dt.content,"research"),Dt.citations&&Dt.citations.length>0){var Pn=Dt.citations.map(function(Kr,di){return di+1+". "+Kr}).join(`
51`);setTimeout(function(){Ee(`Sources:
52`+Pn)},500)}}else Ee("Research: "+(Dt.error||"No results found."))}).catch(function(){y(!1),Ee("Web research failed.")});return}if(m.cmd==="_add_email_from_research"){Re()&&m.email?K(m.email,"to"):Ee("No draft to add recipient to.");return}if(m.cmd==="_attach_vault_result"){var $t=m.doc;if(!$t)return;var Xt=Re();Xt?(h(function(Dt){return Dt.map(function(Pn){if(Pn.id===Xt.id&&Pn.role==="draft"){var Kr=(Pn.draft.attachments||[]).slice();return Kr.some(function(di){return di.id===$t.id})||Kr.push({id:$t.id,name:$t.name,type:$t.type||$t.doc_type||"document",source:"vault"}),Object.assign({},Pn,{draft:Object.assign({},Pn.draft,{attachments:Kr})})}return Pn})}),Ee('Attached "'+$t.name+'" from Vault')):Ee("No active draft to attach to.");return}if(m.cmd==="_dismiss")return;if(m.cmd==="_post_followup_note"){Ee("🔔 Recommended: follow up in 48 hours if no reply. Set a manual reminder.");return}if(m.cmd==="_post_followup"){s&&s("followup"),Ti("Draft a professional follow-up for this thread");return}if(m.cmd==="_post_new"){Ee("Ready. What should I draft?");return}if(m.cmd==="_email_last_answer"){for(var zn=null,Cn=f.length-1;Cn>=0;Cn--){if((f[Cn].role==="analysis"||f[Cn].role==="research")&&f[Cn].text&&f[Cn].text.length>20){zn=f[Cn].text;break}if(f[Cn].role==="system"&&f[Cn].text&&f[Cn].text.length>50){zn=f[Cn].text;break}}if(!zn){Ee("No content to email. Ask a question first.");return}y(!0);var Fr=Ee("Drafting email from answer…");_t.smartCompose("Draft a professional email containing this information. Format it clearly. Tone: "+l+`.
53
54Content:
55`+zn.substring(0,3e3),null,!1).then(function(Dt){if(y(!1),_r(Fr),Dt&&Dt.error){Ee("⚠ "+Dt.error);return}ei(Dt)}).catch(function(Dt){y(!1),Vr(Fr,"Failed: "+(Dt&&Dt.message?Dt.message:"Try again."))});return}if(m.cmd==="_email_brief"){var hn=m.briefText||"";if(!hn){for(var hi=f.length-1;hi>=0;hi--)if((f[hi].role==="analysis"||f[hi].role==="research")&&f[hi].text&&f[hi].text.length>20){hn=f[hi].text;break}}if(!hn){Ee("No content to email. Ask a question first.");return}y(!0);var Ol=Ee("Composing email…");Yr("eb"+Date.now(),"Draft a professional email containing this information. Present the data cleanly. Tone: "+l+`.
56
57Content:
58`+hn.substring(0,3e3),null,function(Dt){y(!1),_r(Ol),Dt?ei(Dt):Ee("⚠ Compose failed.")});return}if(m.cmd==="_tell_more"){y(!0),$i("tm"+Date.now(),(m.query||"")+" — expand on this with more detail, context, and implications.","Provide a deeper, more detailed answer. Include relevant context, data points, and strategic implications.","analysis",{persona:"Xyron Intelligence"},function(){y(!1),h(function(Dt){return Dt.concat([{id:"tma"+Date.now(),role:"actions",actions:[{label:"Email this",cmd:"_email_last_answer"},{label:"Draft an email about this",cmd:"_email_brief",briefText:""}],ts:Fn()}])})});return}if(m.cmd&&m.cmd.startsWith("_scheduling_")){var Yt=m.cmd.replace("_scheduling_","");
58Yt==="create_meeting"?(Ee("Opening calendar to schedule…"),Ti("Draft a meeting request email for this. Include proposed times. Tone: "+l+".",(m.sourceText||"").substring(0,1500))):Yt==="set_reminder"?Ee("🔔 Reminder set. I’ll flag this for follow-up."):(Yt==="check_calendar"||Yt==="propose_times")&&(Ee("Checking availability…"),$i("avail"+Date.now(),(m.sourceText||"").substring(0,1e3)+`
59
60Based on this email, suggest 3 specific meeting time proposals for the principal. Consider typical business hours.`,"Propose 3 specific meeting times. Be practical.","analysis",{persona:"Xyron Scheduling"},function(){y(!1)}));return}if(m.cmd==="_save_as_template"){var kn=Re();if(!kn){Ee("No active draft to save as template.");return}var Br=prompt("Template name:");Br&&_t.saveTemplate(Br,kn.draft.subject||"",kn.draft.body||"").then(function(Dt){Dt.success?Ee("Template saved: "+Br):Ee("Failed to save template.")}).catch(function(){Ee("Failed.")});return}if(m.cmd==="_email_brief_short"){var lo=m.briefText||"";if(!lo){for(var Ir=f.length-1;Ir>=0;Ir--)if((f[Ir].role==="analysis"||f[Ir].role==="research")&&f[Ir].text&&f[Ir].text.length>20){lo=f[Ir].text;break}}if(!lo){Ee("No content.");return}y(!0),Yr("bs"+Date.now(),"Create a very concise (5-8 bullet points max) executive email summary. Subject: Key Points. Tone: "+l+`.
61
62Content:
63`+lo.substring(0,3e3),null,function(Dt){y(!1),Dt?ei(Dt):Ee("⚠ Failed.")});return}if(m.cmd==="_email_brief_investor"){var pa=m.briefText||"";if(!pa){for(var wa=f.length-1;wa>=0;wa--)if((f[wa].role==="analysis"||f[wa].role==="research")&&f[wa].text&&f[wa].text.length>20){pa=f[wa].text;break}}if(!pa){Ee("No content.");return}y(!0),Yr("bi"+Date.now(),`Draft an institutional-grade investor update email. Subject: Market Update. Measured, professional language for LP communication. Reference specific data points. Tone: formal, institutional.
64
65Intelligence:
66`+pa.substring(0,3e3),null,function(Dt){y(!1),Dt?ei(Dt):Ee("⚠ Failed.")});return}if(m.cmd==="_fetch_live_context"){y(!0);var Ll=Ee("Pulling live market data…");_t.liveContext(m.query||"latest market news and macro data").then(function(Dt){y(!1),_r(Ll),Dt.has_data&&Dt.context?(Vo("fl"+Date.now(),Dt.context,"research",{persona:"Xyron Intelligence — Live Feed"}),h(function(Pn){return Pn.concat([{id:"fla"+Date.now(),role:"actions",actions:[{label:"Email this data",cmd:"_email_brief",briefText:Dt.context},{label:"Draft investor update",cmd:"_email_brief_investor",briefText:Dt.context},{label:"Refresh",cmd:"_fetch_live_context",query:m.query}],ts:Fn()}])})):Ee("No live data available right now.")}).catch(function(){y(!1),Vr(Ll,"Live data fetch failed.")});return}var Ps=m.sourceText||at()||"",jd=m.emailData&&(m.emailData.from_email||m.emailData.from_name)||"",Us=m.emailData&&m.emailData.subject||"";function yi(Dt,Pn,Kr){if(!Ps){Ee("No email content to analyze.");return}y(!0);var di=Ee(Dt+"…"),ar="pa"+Date.now();_r(di),$i(ar,Ps.substring(0,2500),"You are a "+Kr+". "+Pn+`
67
68Format: Use ALL CAPS LABEL followed by colon for each section. Use - for bullet points. Use **bold** for key terms. Keep paragraphs 2-3 sentences max. Separate sections with blank lines. No ## markdown. Be direct, concise, and actionable.`,"analysis",{persona:Kr},function(){y(!1),cs()})}function xo(Dt,Pn){y(!0);var Kr=Ee(Dt+"…"),di=Pn+`
69
70Original message:
71`+Ps.substring(0,1500);_t.compose(di).then(function(ar){if(y(!1),_r(Kr),ar&&ar.error){Ee("⚠ "+ar.error);return}ei(ar,m.emailData&&m.emailData.from_email||"")}).catch(function(ar){y(!1),Vr(Kr,"Draft failed: "+(ar&&ar.message?ar.message:"Try again."))})}function cs(){var Dt=Jt(),Pn=lt(),Kr=nn(Dt,Pn&&Pn.body,Pn&&Pn.emailData);h(function(di){return di.concat([{id:"rf"+Date.now(),role:"actions",actions:Kr,ts:Fn()}])})}if(m.cmd==="_persona_true_intent"){yi("Analyzing true intent","Analyze this email. What does the sender truly want beyond the literal words? What are they trying to secure? What are they not saying? What would a Chief of Staff flag?","Chief of Staff to an executive principal");return}if(m.cmd==="_persona_seriousness"){yi("Assessing seriousness","Evaluate: How serious is this sender? What evidence of real commitment vs. tire-kicking? Are they qualified? What signals suggest genuine intent vs. fishing? Give a seriousness score 1-10 with reasoning.","Due Diligence Officer");return}if(m.cmd==="_persona_next_action"){yi("Determining next action","Based on this email, what should the principal do next? Rank the top 3 options by strategic value. Consider: reply, delay, decline, counter, delegate, research further, escalate, or ignore. Be specific about timing and approach.","Chief of Staff and Strategic Advisor");return}if(m.cmd==="_persona_financial"){yi("Analyzing financial terms","Analyze all financial elements: pricing, valuations, fees, equity terms, revenue shares, milestones, payment terms, hidden costs, total cost of ownership. Flag anything unusual, below-market, or above-market. Compare to standard market terms where possible.","Senior Financial Analyst");return}
71if(m.cmd==="_persona_walkaway"){yi("Calculating walk-away position","Based on the terms and context in this email, what should be the principal's walk-away position? What is the minimum acceptable outcome? What concessions are worth making and which are not? Quantify where possible.","Senior Financial Analyst and Negotiation Advisor");return}if(m.cmd==="_persona_hidden_costs"){yi("Scanning for hidden costs","Identify all hidden costs, embedded fees, dilution risks, scope creep potential, escalation clauses, auto-renewal traps, and any financial exposure not immediately obvious. Flag deferred costs and contingent liabilities.","Forensic Financial Analyst");return}if(m.cmd==="_persona_counter"){xo("Drafting counter-position","Draft a strategic counter-proposal that protects the principal's interests while keeping the door open. Push back firmly on unfavorable terms. Offer alternatives that shift value toward the principal. Maintain professional tone. Tone: "+l+".");return}if(m.cmd==="_persona_conditional"){xo("Drafting conditional acceptance","Draft an acceptance that includes protective conditions, milestones, review points, or performance gates. Accept the general direction while adding safeguards. Tone: "+l+".");return}if(m.cmd==="_persona_deflect"){xo("Drafting deflection response","Draft a response that deflects the pressure without closing the door. Redirect the conversation to a safer topic, request additional information, or propose a longer timeline. Do not concede. Tone: "+l+".");return}if(m.cmd==="_persona_delay"){xo("Drafting hold response","Draft a professionally warm response that buys time without committing to anything. Acknowledge receipt, express measured interest, and defer next steps. Do not reveal urgency or position. Tone: "+l+".");return}if(m.cmd==="_persona_advance"){xo("Drafting advancement response","Draft a response that moves this forward decisively. Propose concrete next steps, timelines, and deliverables. Show momentum. Tone: "+l+".");return}if(m.cmd==="_persona_legal_risk"){yi("Analyzing legal risks","Identify all legal and regulatory risks: binding language, implied agreements, liability exposure, NDA concerns, GDPR/data issues, IP implications, non-compete signals, confidentiality breaches, and any language that could be used against the principal. Flag urgency level for each risk.","Legal Risk Counsel");return}if(m.cmd==="_persona_dont_say"){yi("Identifying response boundaries","What should the principal absolutely NOT say in response? What admissions, commitments, acknowledgments, or phrases could create legal, financial, or reputational exposure? Provide a clear do-not-say list with reasoning.","Legal Risk Counsel and Reputation Advisor");return}if(m.cmd==="_persona_binding"){yi("Checking binding implications","Analyze whether any language in this email could be construed as legally binding. Check for: offer and acceptance language, consideration, promissory estoppel risk, implied contracts, verbal agreement references, and reliance-creating statements. Rate the binding risk.","Legal Counsel specializing in contract law");return}if(m.cmd==="_persona_protect"){xo("Drafting protective response","Draft a response that protects the principal's position. Address the risks identified without revealing awareness of them. Maintain leverage. Include protective language where appropriate. Tone: "+l+".");return}if(m.cmd==="_persona_market_context"){yi("Analyzing market context","Place this email in market context: What sector dynamics are relevant? How do the terms/proposals compare to current market conditions? What macro trends affect this? What do recent comparable deals look like? What leverage does market timing give either party?","Markets and Macro Strategist");return}if(m.cmd==="_persona_benchmarks"){yi("Running benchmark comparison","Compare the terms, pricing, or proposals in this email against market benchmarks. Reference typical ranges for similar deals/services/partnerships. Flag anything significantly above or below market. Identify where the principal has pricing power.","Markets Analyst and Valuation Specialist");return}if(m.cmd==="_persona_investor_quality"){yi("Assessing investor quality","Evaluate this investor/LP: What signals indicate quality capital vs. problematic capital? Check for: fund size indicators, decision-making speed signals, governance expectations, value-ad
71d potential, reputation risk, and alignment with principal's thesis. Rate investor quality.","Investor Relations and Capital Markets Specialist");return}if(m.cmd==="_persona_info_gate"){yi("Information gating analysis","What information should be shared vs. gated at this stage? What data points would be premature to disclose? What should only be shared after NDA, after commitment, or never? Create a tiered information release plan.","Investor Relations and Due Diligence Officer");return}if(m.cmd==="_persona_lp_response"){xo("Drafting LP-grade response","Draft an institutional-quality response suitable for LP/investor communication. Maintain appropriate information barriers. Use precise, measured language. Reference process without over-committing. Tone: formal, institutional, "+l+".");return}if(m.cmd==="_persona_reputation"){yi("Assessing reputational risk","Analyze reputational exposure: Could any part of this exchange become public? What media/PR risks exist? How would this look in a headline? What stakeholders could be affected? Rate exposure level and recommend containment strategy.","Reputation and PR Strategist");return}if(m.cmd==="_persona_discreet"){xo("Drafting discreet response","Draft a response optimized for discretion. Avoid anything quotable, committal, or potentially damaging if forwarded. Use measured language. No specifics that could be taken out of context. Tone: diplomatic, careful, "+l+".");return}if(m.cmd==="_persona_verify"){y(!0),Ee("Running verification…");var vo=jd||Us;_t.webResearch(vo+" company verification legitimacy").then(function(Dt){y(!1),Dt.success&&Dt.content?Vo("vf"+Date.now(),"VERIFICATION REPORT: "+vo+`
72
73`+Dt.content,"research"):Ee("Could not verify. Try researching manually."),cs()}).catch(function(){y(!1),Ee("Verification failed.")});return}if(m.cmd==="_persona_history"){yi("Checking relationship history","Based on the sender's name, email, and the content of this email, what can be inferred about the relationship history? Is this a first contact, ongoing negotiation, or existing relationship? What should the principal remember? What patterns or red flags exist in the communication style?","Relationship Manager and Chief of Staff");return}if(m.cmd==="_persona_escalate"){yi("Preparing escalation brief","Prepare a concise internal escalation brief: Summarize the situation, key risks, required decisions, recommended action, and urgency level. Format for forwarding to a senior decision-maker or board member.","Chief of Staff");return}if(m.cmd==="_persona_schedule"){xo("Drafting meeting request","Draft a professional meeting/call request. Propose 2-3 time windows. Keep it brief and action-oriented. Match the formality level of the original email. Tone: "+l+".");return}if(m.cmd==="_pd_send"){var Bi=Re();Bi?ja(Bi.id,function(){Zr(Bi.id)}):Ee("No draft to send.");return}if(m.cmd==="_pd_save"){var Ws=Re();Ws?Mi(Ws.id):Ee("No draft to save.");return}if(m.cmd==="_pd_variant"){var Dc=Re();if(!Dc){Ee("No active draft.");return}y(!0);var zl=Ee("Generating variant: "+m.variant+"…"),Oc="Rewrite this email to be "+m.variant+`.
74
75Original draft:
76`+(Dc.draft.body||"").substring(0,2e3);_t.compose(Oc).then(function(Dt){if(y(!1),_r(zl),Dt&&Dt.error){Ee("⚠ "+Dt.error);return}if(Dt.body){h(function(di){return di.map(function(ar){return ar.id===Dc.id&&ar.role==="draft"?Object.assign({},ar,{draft:Object.assign({},ar.draft,{body:Dt.body,subject:Dt.subject||ar.draft.subject})}):ar})}),Ee("Draft updated: "+m.variant);var Pn=lt(),Kr=Nr(Pn&&Pn.body,Pn&&Pn.emailData);h(function(di){return di.concat([{id:"pv"+Date.now(),role:"actions",actions:Kr,ts:Fn()}])})}else Ee("Variant generation returned empty.")}).catch(function(Dt){y(!1),Vr(zl,"Variant failed: "+(Dt&&Dt.message?Dt.message:"Try again."))});return}if(m.cmd==="_pd_risk_review"){var ds=Re();if(!ds){Ee("No active draft to review.");return}y(!0);var Xo=Ee("Reviewing draft for risks…");_t.preSend(ds.draft.body||"",ds.draft.to||"",ds.draft.subject||"").then(function(Dt){y(!1),_r(Xo);var Pn=`PRE-SEND REVIEW
77
78`;Dt.risks&&Dt.risks.length>0&&(Pn+=`RISKS:
79`+Dt.risks.map(function(Kr){return"• "+Kr}).join(`
80`)+`
81
82`),Dt.ai_review&&(Pn+=`AI ASSESSMENT:
83`+Dt.ai_review+`
84
85`),Pn+="RECOMMENDATION: "+(Dt.send_recommendation||"review").toUpperCase(),Vo("rr"+Date.now(),Pn,"analysis")}).catch(function(){y(!1),Vr(Xo,"Risk review failed.")});return}if(m.cmd==="_pd_attach_deck"){var Hs=Re();if(!Hs){Ee("No active draft.");return}y(!0),Ee("Searching Vault for a deck…"),_t.vaultSearch("deck presentation investor").then(function(Dt){y(!1);var Pn=Dt.documents||[];Pn.length>0?(h(function(Kr){return Kr.map(function(di){if(di.id===Hs.id&&di.role==="draft"){var ar=(di.draft.attachments||[]).slice(),Pi=Pn[0];return ar.some(function(us){return us.id===Pi.id})||ar.push({id:Pi.id,name:Pi.name,type:Pi.doc_type||"document",source:"vault"}),Object.assign({},di,{draft:Object.assign({},di.draft,{attachments:ar})})}return di})}),Ee('Attached "'+Pn[0].name+'" from Vault'),Pn.length>1&&Ee("Also found: "+Pn.slice(1,4).map(function(Kr){return Kr.name}).join(", "))):(Ee("No decks found in Vault. Upload one?"),mi(Hs.id))}).catch(function(){y(!1),Ee("Vault search failed.")});return}}function ss(m){if(m.trim()){os(m);var L=m.toLowerCase().trim();if(L==="send"||L==="send now"||L==="send it"||L==="send email"){var le=Re();le?ja(le.id,function(){Zr(le.id)}):Ee("No draft to send.");return}if(L==="save"||L==="save draft"||L==="save it"){var ye=Re();ye?Mi(ye.id):Ee("No draft to save.");return}var De=L.match(/^(?:send\s+(?:this\s+)?to|to|add)\s+(.+)$/i);if(De||(De=L.match(/^(cc|bcc)\s+(.+)$/i)),De){var Se=L.match(/^cc\s/i)?"cc":L.match(/^bcc\s/i)?"bcc":"to";K((De[2]||De[1]||"").trim(),Se);return}if(L.match(/^attach|^upload/)){var Je=Re();if(!Je){Ee("No active draft. Draft an email first.");return}var ht=m.match(/attach\s+(?:the\s+)?["\u201C]?([^"\u201D]+?)["\u201D]?\s*(?:from\s+(?:the\s+)?vault)?$/i);if(ht&&ht[1]&&!L.match(/^upload/)){var Ht=ht[1].toLowerCase().trim();gn.list().then(function(kt){var hr=kt.documents||[];Pe(hr);var Wn=hr.filter(function(_n){return(_n.name||"").toLowerCase().indexOf(Ht)!==-1});Wn.length===1?kd(Wn[0]):(Ee(Wn.length>1?"Multiple matches — opening Vault":"Not found — opening Vault"),mi(Je.id))}).catch(function(){mi(Je.id)})}else ul(Je.id);return}if(L.match(/^(amend|change|update|make it|make the|revise|edit|rewrite|shorten|lengthen)/)){var Bt=Re();if(Bt){y(!0);var pn=Ee("Amending…");_t.compose(`Current draft:
86To: `+Bt.draft.to+`
87Subject: `+Bt.draft.subject+`
88Body: `+Bt.draft.body+`
89
90Instruction: `+m).then(function(kt){kt.to&&Ce(Bt.id,"to",Array.isArray(kt.to)?kt.to.join(", "):kt.to),kt.subject&&Ce(Bt.id,"subject",kt.subject),kt.body&&Ce(Bt.id,"body",kt.body),y(!1),Vr(pn,"Draft amended.")}).catch(function(){y(!1),Vr(pn,"Amend failed.")});return}}var $t=L.match(/^(warmer|shorter|longer|more assertive|more diplomatic|executive|safer|concise)\s*(version|variant)?$/);if($t){fa($t[1]);return}var Xt=L.match(/^(?:search|find|look\s*up|research|discover)\s+(?:the\s+)?(?:internet|web|online)?\s*(?:for\s+)?(.+)/i);if(Xt||(Xt=L.match(/^(?:find|search|look\s*up)\s+(?:their|the|his|her)?\s*(?:address|email|company|website|contact|executives?|profile|domain|phone)\b(.*)$/i)),!Xt&&L.match(/\b(address|company profile|website|email address|contact info|executives|decision.?maker)\b/)&&L.match(/\b(find|search|look|get|what is)\b/)&&(Xt=[m,m]),Xt){var zn=(Xt[1]||m).trim();y(!0),Ee("Searching: "+zn+"…"),_t.webResearch(zn).then(function(kt){if(y(!1),kt.success&&kt.content){Vo("wr"+Date.now(),kt.content,"research"),kt.citations&&kt.citations.length>0&&setTimeout(function(){Ee("Sources: "+kt.citations.slice(0,4).join(" | "))},600);var hr=(kt.content||"").match(/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g);if(hr&&hr.length>0){var Wn=hr.filter(function(_n,Nl,Rd){return Rd.indexOf(_n)===Nl}).slice(0,5);
90Re()?h(function(_n){return _n.concat([{id:"re"+Date.now(),role:"actions",actions:Wn.map(function(Nl){return{label:"ADD "+Nl,cmd:"_add_email_from_research",email:Nl}}).concat([{label:"IGNORE",cmd:"_dismiss"}]),ts:Fn()}])}):Ee("Found email"+(Wn.length>1?"s":"")+": "+Wn.join(", "))}}else Ee(kt.error||"No results found. Try a more specific query.")}).catch(function(){y(!1),Ee("Web research failed.")});return}var Cn=L.match(/^(?:search|find|look\s*for)\s+(?:in\s+)?(?:vault|documents?|files?|docs?)\s*(?:for\s+)?(.+)/i);if(Cn||(Cn=L.match(/^(?:find|search)\s+(?:the\s+)?(?:latest|recent|last)?\s*(deck|proposal|nda|profile|report|contract|invoice|agreement|presentation)\b/i)),Cn){var Fr=(Cn[1]||m).trim();y(!0),Ee('Searching vault for "'+Fr+'"…'),_t.vaultSearch(Fr).then(function(kt){y(!1);var hr=kt.documents||[];hr.length>0?(Ee("Found "+hr.length+" document"+(hr.length>1?"s":"")),Re()?h(function(Wn){return Wn.concat([{id:"vr"+Date.now(),role:"actions",actions:hr.map(function(_n){return{label:"ATTACH: "+_n.name,cmd:"_attach_vault_result",doc:_n}}),ts:Fn()}])}):hr.forEach(function(Wn){Ee("  • "+Wn.name+" ("+(Wn.doc_type||"document")+")")})):Ee('No documents found for "'+Fr+'"')}).catch(function(){y(!1),Ee("Vault search failed.")});return}if(L.match(/\b(what do they want|what does .+ want|their intent|true intent|real intent|hidden.?intent|behind the words)\b/)){var hn=at();if(!hn){Ee("No email context. Open an email or paste one.");return}y(!0);var hi=Ee("Analyzing intent…");_t.fastIntel(hn).then(function(kt){y(!1),_r(hi),kt.what_they_want?Ee("What they want: "+kt.what_they_want+`
91Likely intent: `+(kt.likely_intent||"—")+`
92Posture: `+(kt.psychological_posture||"—")+`
93Strategy: `+(kt.reply_strategy||"—")):Ee("Could not determine intent.")}).catch(function(){y(!1),Vr(hi,"Intent analysis failed.")});return}if(L.match(/\b(psychology|psychological|posture|negotiation style|how serious|credibility|who am i dealing with)\b/)){var Ol=at();if(!Ol){Ee("No email context.");return}y(!0),_r(Ee("Psychological profile…")),$i("psy"+Date.now(),Ol.substring(0,2e3),"Analyze the sender's psychological posture, communication style, likely negotiation approach, hidden motivations, credibility signals, and what they may be trying to secure beyond the literal words. Be direct and strategic.","analysis",{persona:"Xyron Intelligence — Psychology"},function(){y(!1)});return}if(L.match(/\b(risk|risks|danger|red flag|warning|leverage|sensitive|confidential|legal|exposure)\b/)&&L.match(/\b(analyze|check|assess|what are|tell me|show|identify|flag)\b/)){var Yt=at();if(!Yt){Ee("No content to assess.");return}y(!0),$i("risk"+Date.now(),Yt.substring(0,2e3),"Identify all risks: over-disclosure, weak negotiation posture, exclusivity trap, scope creep, false urgency, free consulting extraction, legal sensitivity, credibility concerns, reputation exposure. Also identify leverage points. Compact warnings only.","analysis",{persona:"Xyron Intelligence — Risk Assessment"},function(){y(!1)});return}if(L.match(/^(?:search|find)\s+(?:all|everything|prior|previous|older|past)\s/)||L.match(/\b(have we spoken|spoken before|prior emails|previous conversation|email history|same tone|last.+sent)\b/)){Ee("Searching across inbox, sent, and contacts…"),y(!0);var kn=m.replace(/^(search|find)\s+(all|everything|prior|previous)\s*/i,"").trim();Promise.all([_t.inbox(C,15).catch(function(){return{messages:[]}}),_t.contacts(100).catch(function(){return{contacts:[]}})]).then(function(kt){y(!1);var hr=(kt[0].messages||[]).filter(function(_n){var Nl=((_n.subject||"")+" "+(_n.from_name||"")+" "+(_n.from_email||"")+" "+(_n.snippet||"")).toLowerCase();return kn.split(/\s+/).some(function(Rd){return Nl.indexOf(Rd.toLowerCase())!==-1})}),Wn=(kt[1].contacts||[]).filter(function(_n){var Nl=((_n.name||"")+" "+(_n.email||"")+" "+(_n.organisation||"")).toLowerCase();return kn.split(/\s+/).some(function(Rd){return Nl.indexOf(Rd.toLowerCase())!==-1})});hr.length>0&&Ee("Found "+hr.length+" matching email"+(hr.length>1?"s":"")+`:
94`+hr.slice(0,5).map(function(_n){return"  • "+_n.subject+" (from "+(_n.from_name||_n.from_email)+")"}).join(`
95`)),Wn.length>0&&Ee("Found "+Wn.length+" matching contact"+(Wn.length>
951?"s":"")+`:
96`+Wn.slice(0,5).map(function(_n){return"  • "+(_n.name||_n.email)+" ("+(_n.email||"")+", "+(_n.email_count||0)+" interactions)"}).join(`
97`)),hr.length===0&&Wn.length===0&&Ee('No matches found for "'+kn+'"')}).catch(function(){y(!1),Ee("Search failed.")});return}if(L.match(/^(?:summarize|summarise)\s+(?:the\s+)?(?:attached|attachment|document|file|doc)\b/)){var Br=Re();if(Br&&Br.draft.attachments&&Br.draft.attachments.length>0){y(!0),Ee("Summarizing attached documents…");var lo=Br.draft.attachments.map(function(kt){return kt.name}).join(", ");_t.analyze("Documents attached: "+lo+". Summarize the key contents and how they relate to the email context.","Summarize attached documents concisely.").then(function(kt){y(!1),Vo("ds"+Date.now(),kt.analysis||"Could not summarize.","analysis")}).catch(function(){y(!1),Ee("Summarization failed.")})}else Ee("No attachments to summarize.");return}var Ir=L.match(/^(?:flag|mark|tag)\s+(?:this\s+)?(?:as\s+|with\s+)?(\w+)/i);if(Ir||(Ir=L.match(/^(\w+)\s+flag$/i)),Ir){var pa=Ir[1].toLowerCase(),wa=Ns.map(function(kt){return kt.id});if(wa.indexOf(pa)!==-1){var Ll=lt();Ll&&Ll.emailData&&Ll.emailData.gmail_id?yu(Ll.emailData.gmail_id,pa):Ee("No email open. Open an email first, then flag it.")}else Ee("Unknown flag: "+pa+". Available: "+wa.join(", "));return}var Ps=L.match(/^(?:unflag|remove flag|remove tag|untag)\s+(?:this\s+)?(?:as\s+|from\s+)?(\w+)?/i);if(Ps){var jd=(Ps[1]||"").toLowerCase(),Us=lt();Us&&Us.emailData&&Us.emailData.gmail_id?jd?Fl(Us.emailData.gmail_id,jd):Ee("Specify which flag to remove: unflag red, unflag urgent, etc."):Ee("No email open.");return}var yi=L.match(/^(?:show|list|view)\s+(?:all\s+)?(?:flagged|tagged)\s*(?:as\s+)?(\w+)?/i);if(yi||(yi=L.match(/^(?:show|list)\s+(\w+)\s+(?:flagged|flags|tagged)/i)),yi){vd((yi[1]||"red").toLowerCase());return}if(L==="auto sort"||L==="auto-sort"||L==="sort inbox"||L==="sort by sender"||L==="organise inbox"||L==="organize inbox"||L==="auto sort inbox"){xd();return}if(L==="clear archives"||L==="delete archives"||L==="remove archives"||L==="empty archives"){wi();return}var xo=L.match(/^(?:create|new|make|add)\s+folder\s+(?:called\s+|named\s+)?(.+)/i);if(xo){_c(xo[1].trim());return}var cs=L.match(/^move\s+(?:this\s+)?(?:to|into)\s+(.+)/i);if(cs||(cs=L.match(/^(?:file|put)\s+(?:this\s+)?(?:in|into|to)\s+(.+)/i)),cs){var vo=cs[1].trim(),Bi=lt();if(Bi&&Bi.emailData&&Bi.emailData.gmail_id){var Ws=ol.find(function(kt){return(kt.name||"").toLowerCase()===vo.toLowerCase()||(kt.id||"").toLowerCase()===vo.toLowerCase()});Ws?Ji(Bi.emailData.gmail_id,Ws.id||Ws.name,!1):(Ee('Folder "'+vo+'" not found. Creating and moving…'),_t.createFolder(C,vo).then(function(kt){kt.created?Ji(Bi.emailData.gmail_id,kt.id||vo,!1):Ee("⚠ "+(kt.error||"Failed"))}).catch(function(){Ee("Failed.")}))}else Ee("No email selected. Open an email first.");return}if(L==="show folders"||L==="folders"||L==="open folders"||L==="my folders"){oe("folders"),ro(),Ee("Opening FOLDERS");return}if(L==="delete folder"||L.match(/^delete\s+folder\s+(.+)/)){var Dc=L.match(/^delete\s+folder\s+(.+)/i);if(Dc){var zl=Dc[1].trim(),Oc=ol.find(function(kt){return(kt.name||"").toLowerCase()===zl.toLowerCase()});Oc?Do(Oc.id||Oc.name):Ee('Folder "'+zl+'" not found.')}else Ee("Specify folder name: delete folder [name]");return}var ds={inbox:1,sent:1,drafts:1,folders:1,"follow-ups":"followups",followups:1,contacts:1,people:"contacts",accounts:1,starred:1,spam:1,junk:"spam",trash:1,deleted:"trash","all mail":"allmail",allmail:1,archive:"allmail",rules:1,templates:1,signature:1};for(var Xo in ds)if(L===Xo||L==="show "+Xo||L==="open "+Xo){var Hs=ds[Xo]===1?Xo:ds[Xo];oe(z===Hs?null:Hs),Ee("Opening "+Xo.toUpperCase());return}if(L==="email this"||L==="email it"||L==="draft this as email"||L==="send this"||L==="email that"||L.match(/^email\s+(this|it|that|the above)$/)){Yo({cmd:"_email_last_answer"});return}if(L.match(/\b(schedule|send\s+(at|tomorrow|later|in\s+\d))/)){var Dt=Re();if(Dt){var Pn=m.match(/(?:at\s+)?(\d{1,2}[:.]\d{2}\s*(?:am|pm)?|\d{1,2}\s*(?:am|pm)|tomorrow|next\s+\w+)/i),Kr=Pn?Pn[1]:"tomorrow 9:00am";Ee("Scheduling email for "+Kr+"…"),_t.scheduleEmail({from_account:C,to:(Dt.draft.to||"").split(",").map(function(kt){return kt.trim()}
97).filter(Boolean),subject:Dt.draft.subject||"",body:Dt.draft.body||"",send_at:Kr}).then(function(kt){kt.success?Ee("📅 Email scheduled: "+kt.send_at):Ee("Schedule failed: "+(kt.error||"try again"))}).catch(function(){Ee("Scheduling failed.")})}else Ee("No draft to schedule. Draft an email first.");return}if(L.match(/\b(response\s*time|analytics|response\s*speed|reply\s*time)/)){y(!0),Ee("Loading response analytics…"),_t.responseAnalytics(C).then(function(kt){if(y(!1),kt.contacts&&kt.contacts.length>0){var hr=`RESPONSE TIME ANALYTICS
98
99`+kt.contacts.slice(0,10).map(function(Wn){return(Wn.name||Wn.email)+" | "+Wn.email_count+" emails | "+(Wn.avg_response_hours?Math.round(Wn.avg_response_hours)+"h avg":"no data")+" | "+Wn.response_speed}).join(`
100`);Vo("ra"+Date.now(),hr,"analysis",{persona:"Response Analytics"})}else Ee("No response data available yet.")}).catch(function(){y(!1),Ee("Analytics failed.")});return}if(L.match(/\b(morning\s*brief|daily\s*brief|today'?s?\s*brief)\b/)){y(!0);var di=Ee("Fetching morning brief…");_t.morningBrief().then(function(kt){y(!1),_r(di),kt.success&&kt.briefing?(Vo("mb"+Date.now(),kt.briefing,"analysis",{persona:"Morning Intelligence Brief"}),h(function(hr){return hr.concat([{id:"mba"+Date.now(),role:"actions",actions:[{label:"Email this brief",cmd:"_email_brief",briefText:kt.briefing},{label:"Shorter version",cmd:"_email_brief_short",briefText:kt.briefing},{label:"Draft investor update",cmd:"_email_brief_investor",briefText:kt.briefing}],ts:Fn()}])})):Ee("Morning brief unavailable: "+(kt.error||"try again"))}).catch(function(){y(!1),Vr(di,"Brief unavailable.")});return}if(L.match(/^(draft\s*(a\s+)?reply|draft\s*(a\s+)?response|reply\s*to\s*(this|that|it|them)|write\s*(a\s+)?reply|compose\s*(a\s+)?reply)$/)){for(var ar=null,Pi=f.length-1;Pi>=0;Pi--){if(f[Pi].role==="email"&&f[Pi].body){ar=f[Pi].body.substring(0,2e3);break}if(f[Pi].role==="actions"&&f[Pi].actions){for(var us=0;us<f[Pi].actions.length;us++)if(f[Pi].actions[us].sourceText){ar=f[Pi].actions[us].sourceText;break}if(ar)break}if(f[Pi].role==="user"&&(f[Pi].text||"").length>200){ar=f[Pi].text.substring(0,2e3);break}}if(ar){Ti("Draft a professional reply. Tone: "+l+".",ar);return}Ee("No email context found to reply to. Open an email from inbox first, or paste the email text.");return}var wd=!!L.match(/^(give|get|prepare|produce|create|put together|make|build|pull together|generate|fetch)\b/)||!!L.match(/\bi (want|need) to (email|send|forward|share)\b/)||!!L.match(/\b(give|get|prepare|make|send) me\b/)||!!L.match(/\b(email|send)\s+(this|it|that|them)\s+(to|a)\b/),Lf=!!L.match(/\b(latest|news|market|today|overnight|breaking|current|live|real.?time|update|report|brief|morning|what happened|developments|macro|economic|price|stock|share|trading|ticker|quote|rate|yield|bitcoin|btc|gold|oil|crypto|forex|currency|bond|treasury|index|indices|s&p|nasdaq|dow|ftse|nikkei)\b/),Au=!!L.match(/\b(advise|advice|analyze|analyse|review|check|what should|how should|what do you think|suggest|evaluate|assess|what do they want)\b/),Gs=!!L.match(/^(draft|write|compose|send|reply|forward|respond)\b/)||!!L.match(/\b(draft|write|compose)\s+(an?\s+)?(email|reply|response|message)\b/),Zp=m.length>300;if(Lf&&!Au){var Lc=!!L.match(/\b(email|send|forward|draft)\s+(it|this|that|them|to)\b/)||Gs;y(!0);var Td=Ee("Fetching live data…");_t.liveContext(m).then(function(kt){if(kt.has_data&&kt.context){_r(Td);var hr=kt.context;$i("lv"+Date.now(),m+`
101
102USE THIS VERIFIED LIVE DATA TO ANSWER:
103`+hr.substring(0,2500)+`
104
105Answer using the real data above. Quote specific numbers. Be direct and concise.`,null,"analysis",{persona:"Xyron Intelligence"},function(){if(y(!1),Lc){y(!0);var Wn=Ee("Drafting email…");_t.smartCompose(m+" Tone: "+l+".",null,!0).then(function(_n){if(_r(Wn),y(!1),_n&&_n.error){Ee("⚠ "+_n.error);return}ei(_n)}).catch(function(_n){y(!1),Vr(Wn,"Compose failed: "+(_n&&_n.message?_n.message:"Try again."))})}else h(function(_n){return _n.concat([{id:"lea"+Date.now(),role:"actions",actions:[{label:"Email this",cmd:"_email_last_answer"},{label:"Draft investor update",cmd:"_email_brief_investor",briefText:""},{label:"Shorter version",cmd:"_email_brief_short",briefText:""},{label:"Refresh data",cmd:"_fetch_live_context",query:m}],ts:Fn()}])})})}else Vr(Td,"Searching…"),_t.webResearch(m).then(function(Wn){y(!1),_r(Td),Wn.success&&Wn.content?$i("wr"+Date.now(),m+`
106
107USE THIS DATA TO ANSWER:
108`+Wn.content.substring(0,2500),null,"analysis",{persona:"Arenberg Intelligence"},function(){h(function(_n){return _n.concat([{id:"wra"+Date.now(),role:"actions",actions:[{label:"Email this",cmd:"_email_last_answer"},{label:"Draft investor update",cmd:"_email_brief_investor",briefText:""},{label:"Shorter version",cmd:"_email_brief_short",briefText:""}],ts:Fn()}])})}):Ee("No data found. Try a more specific query.")}).catch(function(){y(!1),Vr(Td,"Intelligence unavailable.")})}).catch(function(){_r(Td),y(!1),Ee("Live intelligence unavailable. Try again.")});return}if(wd&&!Au){if(L.match(/\b(email|send|forward|draft)\s+(it|this|that|them|to|an?)\b/)||Gs){y(!0);var zf=Ee("Composing…");_t.smartCompose(m+" Tone: "+l+".",null,Lf).then(function(kt){if(y(!1),_r(zf),kt&&kt.error){Ee("⚠ "+kt.error);return}ei(kt)}).catch(function(kt){y(!1),Vr(zf,"Failed: "+(kt&&kt.message?kt.message:"Try again."))})}else y(!0),_r(Ee("Working on it…")),$i("tka"+Date.now(),m,"Answer this question directly. Be concise and factual.","analysis",{persona:"Xyron Intelligence"},function(){y(!1),h(function(kt){return kt.concat([{id:"tkaa"+Date.now(),role:"actions",actions:[{label:"Email this",cmd:"_email_last_answer"},{label:"Draft as investor update",cmd:"_email_brief_investor",briefText:""},{label:"Shorter version",cmd:"_email_brief_short",briefText:""}],ts:Fn()}])})});return}if(Au&&!Gs&&!wd){y(!0),$i("an"+Date.now(),m,null,"analysis",null,function(){y(!1),Bn(m.substring(0,2e3));var kt=lt(),hr=nn(Jt(),kt?kt.body:m.substring(0,2e3),kt?kt.emailData:null);h(function(Wn){return Wn.concat([{id:"a"+Date.now(),role:"actions",actions:hr,ts:Fn()}])})});return}if(Zp&&L.match(/\b(reply|respond|draft.*(reply|response))\b/)){y(!0);var Mf=Ee("Reading and drafting reply…");_t.compose("Draft a professional reply. Tone: "+l+`.
109
110Original:
111`+m.substring(0,2e3)).then(function(kt){y(!1),_r(Mf),ei(kt)}).catch(function(){y(!1),Vr(Mf,"Failed.")});return}if(L==="forward"||L==="forward this"||L==="fwd"||L==="forward email"){for(var _d=null,Ml=f.length-1;Ml>=0;Ml--)if(f[Ml].role==="email"){_d=f[Ml];break}if(_d){ao(_d);return}Ee("No email to forward. Open one first.");return}if(L.match(/^(draft|write|compose|forward)\b/)||L.match(/\b(draft|write|compose)\s+(an?\s+)?(email|message|letter|note)\b/)){y(!0);var e0=Ee("Composing…");Yr("sc"+Date.now(),m+" Tone: "+l+".",null,function(kt){y(!1),_r(e0),kt?ei(kt):Ee("⚠ Compose failed. Try again with more detail.")});return}y(!0);var Nf="df"+Date.now();_t.liveContext(m,{prices:!0,news:!1,macro:!1}).then(function(kt){$i(Nf,m+(kt&&kt.has_data&&kt.context?`
112
113LIVE DATA:
114`+kt.context.substring(0,1500):""),"Answer this directly as a helpful AI assistant. Be concise and factual. If live data is provided above, use it and quote specific numbers. Do not draft an email unless explicitly asked.","analysis",{persona:"Xyron Intelligence"},function(){y(!1),h(function(hr){return hr.concat([{id:"dfa"+Date.now(),role:"actions",actions:[{label:"Email this",cmd:"_email_last_answer"},{label:"Draft an email about this",cmd:"_email_brief",briefText:""},{label:"Tell me more",cmd:"_tell_more",query:m}],ts:Fn()}])})})}).catch(function(){$i(Nf,m,"Answer this directly as a helpful AI assistant. Be concise and factual. Do not draft an email unless explicitly asked.","analysis",{persona:"Xyron Intelligence"},function(){y(!1),h(function(kt){return kt.concat([{id:"dfa"+Date.now(),role:"actions",actions:[{label:"Email this",cmd:"_email_last_answer"},{label:"Draft an email about this",cmd:"_email_brief",briefText:""},{label:"Tell me more",cmd:"_tell_more",query:m}],ts:Fn()}])})})})}}function ei(m,L,le){if(!m){Ee("⚠ No response. Try again.");return}var ye=L||(m.to?Array.isArray(m.to)?m.to.join(", "):m.to:"");if(!(m.body&&m.body.length>5)&&!(m.subject&&m.subject.length>2)){Ee("⚠ Empty draft. Try with more detail.");return}var De="d"+Date.now(),Se={to:ye,cc:"",bcc:"",subject:m.subject||"",body:m.body||"",fromAccount:C,attachments:[]};le&&(Se.replyToMessageId=le),h(function(Ht){return Ht.concat([{id:De,role:"draft",draft:Se,ts:Fn()}])}),ye&&ye.indexOf("@")===-1&&Cd(De,ye);var Je=lt(),ht=Nr(Je&&Je.body,Je&&Je.emailData);setTimeout(function(){h(function(Ht){return Ht.concat([{id:"pd"+Date.now(),role:"actions",actions:ht,ts:Fn()}])})},100)}function Bs(){rd.init().then(function(m){m.auth_url&&window.open(m.auth_url,"_blank","width=500,height=600")}
114).catch(function(){})}function Dl(){Y(!1),ue(1),nt(""),Le(""),Te(""),bn(""),Nn(""),ra(null),Ba(!1),st(!1)}function Cu(){if(!Me||!Me.includes("@")){Nn("Enter a valid email address");return}var m=Me.split("@")[1].toLowerCase();if(m==="gmail.com"||m==="googlemail.com"){ra({use_oauth:!0,provider:"google",label:"Gmail",imap_host:"imap.gmail.com",imap_port:993,smtp_host:"smtp.gmail.com",smtp_port:587}),ue(2),Nn("");return}st(!0),Nn("Detecting settings…"),rd.detectProvider(Me).then(function(L){st(!1),ra(L),L.use_oauth?(ue(2),Nn("")):L.detected&&L.imap_host?(Te(L.imap_host),bn(L.smtp_host||""),ue(2),Nn("")):L.note?(ue(2),Nn(L.note)):(Ba(!0),ue(2),Nn("Could not auto-detect. Enter server settings below."))}).catch(function(){st(!1),Nn("Detection failed — try again"),Ba(!0),ue(2)})}function Ad(){if(!Me||!je){Nn("Password required");return}st(!0),Nn("Testing connection…"),rd.connectAccount(Me,je,{imap_host:Wt,smtp_host:Tt}).then(function(m){st(!1),m.success?(Nn(""),ue(3),rd.accounts().then(function(L){j(L.accounts||[])}),C||_(Me),setTimeout(Dl,2e3)):m.use_oauth?(ra({use_oauth:!0,provider:"google",label:"Google Workspace"}),Nn("This email uses Google — use Google sign-in")):Nn("Failed: "+(m.errors?m.errors.join("; "):m.error||"Check credentials"))}).catch(function(){st(!1),Nn("Connection failed")})}function En(m){var L=(0,i.useState)(!1),le=L[0],ye=L[1],De=(0,i.useState)(m.value),Se=De[0],Je=De[1];return(0,i.useEffect)(function(){Je(m.value)},[m.value]),le?i.createElement(m.multiline?"textarea":"input",{value:Se,onChange:function(ht){Je(ht.target.value)},onBlur:function(){ye(!1),Se!==m.value&&m.onChange(Se)},onKeyDown:function(ht){ht.key==="Enter"&&!m.multiline&&(ht.preventDefault(),ye(!1),Se!==m.value&&m.onChange(Se))},autoFocus:!0,rows:m.multiline?m.expandedRows||5:void 0,style:Object.assign({width:"100%",background:"#0A0E16",border:"1px solid #6B9AC4",borderRadius:4,padding:m.multiline?"8px 10px":"4px 8px",fontSize:m.fontSize||12,color:"#E6EDF3",outline:"none",fontFamily:"'SF Pro Text',sans-serif",boxSizing:"border-box",resize:m.multiline?"vertical":"none",lineHeight:m.multiline?1.7:void 0},m.editStyle||{})}):i.createElement("div",{onClick:function(){m.disabled||ye(!0)},style:Object.assign({cursor:m.disabled?"default":"text",padding:m.multiline?"8px 10px":"4px 8px",borderRadius:4,border:"1px solid transparent",fontSize:m.fontSize||12,color:m.value?"#E6EDF3":"#3A4A5E",fontFamily:"'SF Pro Text',sans-serif",lineHeight:m.multiline?1.7:1.4,whiteSpace:m.multiline?"pre-wrap":"nowrap",overflow:m.multiline?"visible":"hidden",textOverflow:m.multiline?void 0:"ellipsis",transition:"border-color .15s",minHeight:m.multiline?40:void 0},m.style||{}),onMouseEnter:function(ht){m.disabled||(ht.currentTarget.style.borderColor="rgba(56,189,248,0.25)")},onMouseLeave:function(ht){ht.currentTarget.style.borderColor="transparent"}},m.value||m.placeholder||"")}var yn={width:38,height:38,background:"url(/brand/xyron-monogram.png) center/contain no-repeat",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginTop:2,fontFamily:ke,fontSize:0,color:"transparent",filter:"drop-shadow(0 2px 10px rgba(212,175,92,0.35))"},ti={width:32,height:32,borderRadius:8,background:"#0C1018",border:"1px solid #2A3548",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginTop:2,fontFamily:ke,fontSize:9,fontWeight:700,color:"#8B949E"},Rr={display:"flex",gap:14,padding:"18px 0",borderBottom:"1px solid #0C1018",animation:"xfadein 0.2s ease forwards"};function Ko(m,L){var le=L&&L.persona,ye=(m||"").split(/\n/),De=[];le&&De.push(i.createElement("div",{key:"_ptag",style:{display:"inline-flex",alignItems:"center",gap:6,marginBottom:10,padding:"3px 10px",background:"rgba(212,175,92,0.06)",border:"1px solid rgba(212,175,92,0.18)",borderRadius:4}},i.createElement("span",{style:{width:5,height:5,borderRadius:"50%",background:Ct.orange}}),i.createElement("span",{style:{fontFamily:ke,fontSize:8,fontWeight:700,color:Ct.orange,letterSpacing:"0.1em"}},le.toUpperCase())));for(var Se=0;Se<ye.length;Se++){var Je=ye[Se];if(!Je.trim()){De.push(i.createElement("div",{key:Se,style:{height:11}}));continue}var ht=Je.match(/^#{1,3}
114\s+(.+)/);if(ht){De.push(i.createElement("div",{key:Se,style:{fontSize:12.5,fontWeight:700,color:Ct.orange,letterSpacing:"0.05em",fontFamily:ke,marginTop:Se>0?14:4,marginBottom:6,paddingBottom:5,borderBottom:"1px solid rgba(212,175,92,0.12)"}},ht[1]));continue}if(/^[A-Z][A-Z\s/&-]+:/.test(Je.trim())){var Ht=Je.trim().match(/^([A-Z][A-Z\s/&-]+:)(.*)/);De.push(i.createElement("div",{key:Se,style:{marginTop:Se>0?13:2,marginBottom:4}},i.createElement("span",{style:{fontSize:11,fontWeight:700,color:Ct.accent,fontFamily:ke,letterSpacing:"0.06em"}},Ht?Ht[1]:Je.trim()),Ht&&Ht[2]?i.createElement("span",{style:{fontSize:13.5,color:"#C9D1D9",lineHeight:1.75,marginLeft:6},dangerouslySetInnerHTML:{__html:Va(Ht[2])}}):null));continue}if(/^-{3,}$/.test(Je.trim())){De.push(i.createElement("div",{key:Se,style:{borderBottom:"1px solid #1A2332",margin:"10px 0"}}));continue}var Bt=/^\s{2,}[\u2013\u2014\u2022-]/.test(Je),pn=!Bt&&/^[\u2013\u2014\u2022-]\s/.test(Je.trim()),$t=/^\d+[.)]\s/.test(Je.trim()),Xt=Bt?24:pn||$t?12:0,zn=Je.trim();(pn||Bt)&&(zn=zn.replace(/^[\u2013\u2014\u2022-]\s*/,"")),$t&&(zn=zn.replace(/^\d+[.)]\s*/,"")),De.push(i.createElement("div",{key:Se,style:{fontSize:13.5,color:"#C9D1D9",lineHeight:1.75,paddingLeft:Xt,marginBottom:pn||$t||Bt?4:6}},(pn||$t||Bt)&&i.createElement("span",{style:{color:$t?Ct.accent:Ct.orange,marginRight:8,fontSize:7,verticalAlign:"middle"}},$t?Je.trim().match(/^(\d+[.)])/)[1]:"▸"),i.createElement("span",{dangerouslySetInnerHTML:{__html:Va(zn)}})))}return De}function Va(m){return(m||"").replace(/\*\*(.+?)\*\*/g,"<b style='color:#E6EDF3'>$1</b>").replace(/`(.+?)`/g,"<code style='background:#151D2B;padding:1px 5px;border-radius:3px;font-size:12px;color:#6B9AC4'>$1</code>")}return i.createElement("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:50,background:"#0C1018",display:"flex",flexDirection:"column",overflow:"hidden",animation:"vidSlideUp 0.2s ease-out"}},i.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 20px",borderBottom:"1px solid #0C1018",flexShrink:0}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:12}},i.createElement("div",{style:{width:8,height:8,borderRadius:"50%",background:Ct.orange,boxShadow:"0 0 10px rgba(212,175,92,0.5)",animation:v||o?"xpulse 1s infinite":"none"}}),i.createElement("span",{style:{fontFamily:ke,fontSize:11,fontWeight:700,color:Ct.orange,letterSpacing:".12em"}},"XYRON EMAIL"),(v||o)&&i.createElement("span",{style:{fontFamily:ke,fontSize:9,color:Ct.orange,opacity:.7,animation:"xpulse 1s infinite"}},"working…"),A.length>0&&i.createElement("select",{value:C,onChange:function(m){_(m.target.value),_t.counts(m.target.value).then(function(L){kl(L)}).catch(function(){})},style:{background:"#0C1018",border:"1px solid #2A3548",borderRadius:4,padding:"3px 10px",fontFamily:ke,fontSize:9,color:"#8B949E",outline:"none"}},A.map(function(m){return i.createElement("option",{key:m.email,value:m.email},m.email)})),!A.length&&i.createElement("button",{onClick:function(){oe("accounts"),Y(!0),Nn("")},style:{background:"rgba(212,175,92,0.08)",border:"1px solid rgba(212,175,92,0.25)",borderRadius:4,padding:"3px 12px",cursor:"pointer",fontFamily:ke,fontSize:9,color:Ct.orange}},"ADD ACCOUNT")),i.createElement("button",{onClick:t,style:{background:"transparent",border:"1px solid #2A3548",borderRadius:4,padding:"4px 14px",cursor:"pointer",fontFamily:ke,fontSize:9,color:"#5A7090",transition:"all .15s"},onMouseEnter:function(m){m.currentTarget.style.borderColor="#5A7090"},onMouseLeave:function(m){m.currentTarget.style.borderColor="#2A3548"}},"✕ CLOSE")),i.createElement("div",{style:{flex:1,display:"flex",overflow:"hidden"}},i.createElement("div",{style:{width:44,borderRight:"1px solid #0C1018",display:"flex",flexDirection:"column",alignItems:"center",padding:"8px 0",gap:2,flexShrink:0,overflowY:"auto"}},Dj.map(function(m){var L=z===m.id,le=m.id==="drafts"&&ee>0?ee:null;if(!le&&m.badgeKey&&Sa[m.badgeKey]){var ye=Sa[m.badgeKey];m.badgeKey==="inbox"&&ye.unread>0?le=ye.unread:(m.badgeKey==="spam"&&ye.total>0||m.badgeKey==="trash"&&ye.total>0||m.badgeKey==="starred"&&ye.total>0)&&(le=ye.total)}var De=m.id==="spam"||m.id==="trash"?"#F97583":Ct.orange;return i.createElement("button",{key:m.id,onClick:function(){oe(z===m.id?null:m.id)}
114,title:m.tip,style:{width:34,height:34,display:"flex",alignItems:"center",justifyContent:"center",background:L?"rgba(212,175,92,0.08)":"transparent",border:"none",borderLeft:L?"2px solid "+Ct.orange:"2px solid transparent",borderRadius:4,cursor:"pointer",fontSize:14,transition:"all .15s",position:"relative",flexShrink:0}},i.createElement("span",{style:{opacity:L?1:.4}},m.icon),le&&i.createElement("span",{style:{position:"absolute",top:1,right:1,fontFamily:ke,fontSize:5,fontWeight:700,color:"#fff",background:De,borderRadius:6,padding:"0 3px",minWidth:10,textAlign:"center"}},le>99?"99+":le))})),z&&i.createElement("div",{style:{width:300,borderRight:"1px solid #0C1018",display:"flex",flexDirection:"column",background:"#06080D",flexShrink:0,overflow:"hidden",position:"relative"}},i.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",borderBottom:"1px solid #0C1018",position:"relative"}},i.createElement("span",{style:{fontFamily:ke,fontSize:9,fontWeight:700,color:Ct.orange,letterSpacing:".1em"}},z.toUpperCase()),i.createElement("div",{style:{display:"flex",alignItems:"center",gap:6}},(z==="inbox"||z==="sent"||z==="starred"||z==="spam"||z==="trash"||z==="allmail")&&i.createElement("button",{onClick:function(){zs(function(m){return!m})},"aria-label":"Open email shortcuts","aria-expanded":Tl?"true":"false","data-testid":"email-shortcut-help-button",title:"Email shortcuts",style:{width:18,height:18,background:"transparent",border:"1px solid "+Ct.line,borderRadius:3,cursor:"pointer",fontFamily:ke,fontSize:10,fontWeight:700,color:Tl?Ct.orange:"#5A7090",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:0}},"?"),i.createElement("button",{onClick:function(){oe(null)},style:{background:"transparent",border:"none",cursor:"pointer",fontFamily:ke,fontSize:10,color:"#5A7090"}},"✕")),Tl&&(z==="inbox"||z==="sent"||z==="starred"||z==="spam"||z==="trash"||z==="allmail")&&i.createElement("div",{"data-testid":"email-shortcut-help-popover",role:"dialog","aria-label":"Email keyboard shortcuts",style:{position:"absolute",top:"100%",right:8,marginTop:4,minWidth:200,background:"#05080D",border:"1px solid "+Ct.line,borderTop:"1px solid "+Ct.orange,borderRadius:3,padding:"8px 10px",zIndex:50,boxShadow:"0 12px 32px rgba(0,0,0,0.5)"}},i.createElement("div",{style:{fontFamily:ke,fontSize:7,fontWeight:700,color:"#5A7090",letterSpacing:".22em",paddingBottom:5,marginBottom:6,borderBottom:"1px solid "+Ct.line,display:"flex",alignItems:"center",justifyContent:"space-between"}},i.createElement("span",null,"EMAIL SHORTCUTS"),i.createElement("span",{style:{color:"#3A4A5E"}},"ESC")),Ij("Email").map(function(m){return i.createElement("div",{key:m.chord+"-"+m.label,style:{display:"grid",gridTemplateColumns:"40px 1fr",gap:8,alignItems:"center",fontSize:10,lineHeight:1.7}},i.createElement("span",{style:{color:Ct.orange,fontFamily:ke,fontWeight:700,letterSpacing:".06em"}},m.chord),i.createElement("span",{style:{color:"#C9D1D9"}},m.label))}),i.createElement("div",{style:{marginTop:8,paddingTop:6,borderTop:"1px solid "+Ct.line,fontFamily:ke,fontSize:7,color:"#3A4A5E",letterSpacing:".14em",textAlign:"right"}},"⌘⇧/ · ALL SHORTCUTS"))),(z==="inbox"||z==="sent"||z==="starred"||z==="spam"||z==="trash"||z==="allmail")&&i.createElement("div",{style:{padding:"8px 10px",borderBottom:"1px solid #0C1018"}},i.createElement("div",{style:{display:"flex",gap:4}},i.createElement("input",{"data-email-search":!0,value:Mt,onChange:function(m){mn(m.target.value)},onKeyDown:function(m){m.key==="Enter"&&mo(),m.key==="Escape"&&(m.target.blur(),mn(""),qn(null))},placeholder:"Search emails… (press /)",style:{flex:1,background:"#0A0E16",border:"1px solid #1A2332",borderRadius:4,padding:"6px 10px",fontSize:11,color:"#E6EDF3",outline:"none",boxSizing:"border-box",fontFamily:"'SF Pro Text',sans-serif"}}),i.createElement("button",{onClick:mo,style:{padding:"6px 10px",background:"rgba(212,175,92,0.08)",border:"1px solid rgba(212,175,92,0.2)",borderRadius:4,cursor:"pointer",fontFamily:ke,fontSize:8,color:Ct.orange,flexShrink:0}},"🔍")),Mt&&br&&i.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:4}},i.createElement("span",{style:{fontFamily:ke,fontSize:8,color:"#5A7090"}},br.length+" result"+(br.length!==1?"s":"")),i.createElement("button",{onClick:function(){mn(""),qn(null)},style:{background:"transparent",border:"none",cursor:"pointer",fontFamily:ke,fontSize:8,color:Ct.orange}},"✕ CLEAR")),i.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:4}},i.createElement("button",{onClick:Eu,style:{background:"transparent",border:"none",cursor:"pointer",fontFamily:ke,fontSize:8,color:Ct.accent}},"↻ REFRESH"),i.createElement("span",{style:{fontFamily:ke,fontSize:7,color:"#3A4A5E"}},Aa(new Date(gd).toISOString())))),z==="inbox"&&i.createElement("div",{style:{display:"flex",gap:0,borderBottom:"1px solid #0C1018",background:"#080C12"}},["PRIMARY","PROMOTIONS","SOCIAL","UPDATES"].map(function(m){var L=mu===m;return i.createElement("button",{key:m,onClick:function(){jl(m),m==="PRIMARY"?si("INBOX"):(ge(!0),_t.inbox(C,30,null,"CATEGORY_"+m).then(function(le){R(le.messages||[]),Jr(le.next_page_token||null),ge(!1)}).catch(function(){ge(!1)}))},style:{flex:1,padding:"6px 4px",background:L?"rgba(212,175,92,0.06)":"transparent",border:"none",borderBottom:L?"2px solid "+Ct.orange:"2px solid transparent",curs
114or:"pointer",fontFamily:ke,fontSize:7,fontWeight:L?700:400,color:L?Ct.orange:"#5A7090",transition:"all .12s"}},m)})),(function(){var m=br||W,L=kr().length;return z==="inbox"||z==="sent"||z==="starred"||z==="spam"||z==="trash"||z==="allmail"?i.createElement(i.Fragment,null,m.length>0&&i.createElement("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"6px 10px",borderBottom:"1px solid #0C1018",background:"#080C12"}},i.createElement("input",{type:"checkbox",checked:il,onChange:xu,style:{accentColor:Ct.orange,cursor:"pointer"}}),i.createElement("span",{style:{fontFamily:ke,fontSize:8,color:"#5A7090",flex:1}},L>0?L+" selected":"Select all"),L>0&&i.createElement(i.Fragment,null,z!=="trash"&&i.createElement("button",{onClick:function(){gi("trash")},title:"Delete",style:{background:"transparent",border:"none",cursor:"pointer",fontSize:11,padding:"2px 4px",opacity:.6}},"🗑"),z!=="spam"&&z!=="trash"&&i.createElement("button",{onClick:function(){gi("archive")},title:"Archive",style:{background:"transparent",border:"none",cursor:"pointer",fontSize:11,padding:"2px 4px",opacity:.6}},"📦"),z!=="spam"&&z!=="trash"&&i.createElement("button",{onClick:function(){gi("spam")},title:"Mark spam",style:{background:"transparent",border:"none",cursor:"pointer",fontSize:11,padding:"2px 4px",opacity:.6}},"⛔"),i.createElement("button",{onClick:function(){gi("read")},title:"Mark read",style:{background:"transparent",border:"none",cursor:"pointer",fontSize:11,padding:"2px 4px",opacity:.6}},"📧"),i.createElement("button",{onClick:function(){gi("unread")},title:"Mark unread",style:{background:"transparent",border:"none",cursor:"pointer",fontSize:11,padding:"2px 4px",opacity:.6}},"📩")))):null})(),i.createElement("div",{style:{flex:1,overflowY:"auto"}},(z==="inbox"||z==="sent"||z==="starred"||z==="spam"||z==="trash"||z==="allmail")&&i.createElement(i.Fragment,null,(q||$n)&&i.createElement("div",{style:{padding:24,textAlign:"center",fontFamily:ke,fontSize:9,color:Ct.orange}},"Loading…"),!(q||$n)&&(br||W).map(function(m,L){var le=!!to[m.gmail_id];return i.createElement("div",{key:m.gmail_id||L,style:{padding:"8px 10px",borderBottom:"1px solid #0C1018",cursor:"pointer",transition:"background .12s",background:le?"rgba(212,175,92,0.05)":"transparent"},onMouseEnter:function(ye){le||(ye.currentTarget.style.background="rgba(212,175,92,0.03)")},onMouseLeave:function(ye){le||(ye.currentTarget.style.background=le?"rgba(212,175,92,0.05)":"transparent")}},i.createElement("div",{style:{display:"flex",alignItems:"flex-start",gap:6}},i.createElement("input",{type:"checkbox",checked:le,onChange:function(ye){ye.stopPropagation(),oo(m.gmail_id)},style:{accentColor:Ct.orange,cursor:"pointer",marginTop:3,flexShrink:0}}),i.createElement("div",{onClick:function(){Il(m)},style:{flex:1,minWidth:0}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:4}},!m.is_read&&i.createElement("span",{style:{width:6,height:6,borderRadius:"50%",background:Ct.accent,flexShrink:0}}),i.createElement("span",{style:{fontSize:11,fontWeight:m.is_read?400:600,color:m.is_read?"#8B949E":"#E6EDF3",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1}},m.from_name||m.from_email),m.is_starred&&i.createElement("span",{style:{fontSize:10,flexShrink:0}},"⭐")),i.createElement("div",{style:{fontSize:10,color:m.is_read?"#5A7090":"#C9D1D9",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:2}},m.subject),i.createElement("div",{style:{fontFamily:ke,fontSize:8,color:"#3A4A5E",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},m.ai_summary||m.snippet||""),i.createElement("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:2}},m.has_attachments&&i.createElement("span",{style:{fontFamily:ke,fontSize:7,color:"#5A7090"}},"📎"),m.date&&i.createElement("span",{style:{fontFamily:ke,fontSize:7,color:"#3A4A5E"}},Aa(m.date)),m.priority&&m.priority!=="STANDARD"&&i.createElement("span",{style:{fontFamily:ke,fontSize:6,fontWeight:700,color:m.priority==="CRITICAL"?"#D44040":m.priority==="HIGH"?"#F97583":m.priority==="JUNK"?"#5A7090":Ct.orange,padding:"0 3px",border:"1px solid currentColor",borderRadius:2,opacity:.8}},m.priority))),i.createElement("div",{style:{display:"flex",flexDirection:"column",gap:2,flexShrink:0,opacity:.5},onMouseEnter:function(ye){ye.currentTarget.style.opacity="1"},onMouseLeave:function(ye){ye.currentTarget.style.opacity="0.5"}},i.createElement("button",{onClick:function(ye){ye.stopPropagation(),io(m.gmail_id,m.is_starred)},title:m.is_starred?"Unstar":"Star",style:{background:"transparent",border:"none",cursor:"pointer",fontSize:10,padding:"1px 2px",lineHeight:1}},m.is_starred?"★":"☆"),z==="trash"?i.createElement("button",{onClick:function(ye){ye.stopPropagation(),bd(m.gmail_id)},title:"Restore",style:{background:"transparent",border:"none",cursor:"pointer",fontSize:9,padding:"1px 2px",lineHeight:1}},"↩"):i.createElement("button",{onClick:function(ye){ye.stopPropagation(),ho(m.gmail_id)},title:"Delete",style:{background:"transparent",border:"none",cursor:"pointer",fontSize:9,padding:"1px 2px",lineHeight:1}},"🗑"),z!=="spam"&&z!=="trash"&&i.createElement("button",{onClick:function(ye){ye.stopPropagation(),yo(m.gmail_id)},title:"Archive",style:{background:"transparent",border:"none",cursor:"pointer",fontSize:9,padding:"1px 2px",lineHeight:1}},"📦"),z==="spam"?i.createElement("button",{onClick:function(ye){ye.stopPropagation(),Rc(m.gmail_id,!1)},title:"Not spam",style:{background:"transparent",border:"none",cursor:"pointer",fontSize:9,padding:"1px 2px",lineHeight:1}},"✔"):z!=="trash"&&i.createElement("button",{onClick:function(ye){ye.stopPropagation(),Rc(m.gmail_id,!0)},title:"Mark spam",style:{background:"transparent",border:"none",cursor:"pointer",fontSize:9,padding:"1px 2px",lineHeight:1}},"⛔"))),m.thread_id&&i.createElement("button",{onClick:function(ye){ye.stopPropagation(),Lo(m.thread_id)},style:{marginTop:3,marginLeft:22,padding:"2px 8px",background:"rgba(212,175,92,0.06)",border:"1px solid rgba(212,175,92,0.15)",borderRadius:3,cursor:"pointer",fontFamily:ke,fontSize:7,color:"#D4AF5C"}},"💬 THREAD"))}),!(q||$n)&&(br||W).length===0&&i.createElement("div",{style:{padding:24,textAlign:"center",fontFamily:ke,fontSize:9,color:"#3A4A5E"}}
114,A.length===0?"Connect an account":br?"No results for “"+Mt+"”":"No messages"),dr&&!br&&i.createElement("div",{style:{padding:12,textAlign:"center"}},i.createElement("button",{onClick:Fc,disabled:or,style:{width:"100%",padding:"8px",background:"rgba(212,175,92,0.06)",border:"1px solid rgba(212,175,92,0.15)",borderRadius:4,cursor:or?"not-allowed":"pointer",fontFamily:ke,fontSize:9,color:Ct.orange}},or?"Loading…":"LOAD MORE")),z==="trash"&&W.length>0&&i.createElement("div",{style:{padding:"8px 10px",borderTop:"1px solid #1A2332"}},i.createElement("button",{onClick:zo,style:{width:"100%",padding:"8px",background:"rgba(255,68,68,0.06)",border:"1px solid rgba(255,68,68,0.15)",borderRadius:4,cursor:"pointer",fontFamily:ke,fontSize:9,fontWeight:700,color:"#D44040"}},"🗑 EMPTY TRASH")),z==="spam"&&W.length>0&&i.createElement("div",{style:{padding:"8px 10px",borderTop:"1px solid #1A2332"}},i.createElement("button",{onClick:ci,style:{width:"100%",padding:"8px",background:"rgba(255,68,68,0.06)",border:"1px solid rgba(255,68,68,0.15)",borderRadius:4,cursor:"pointer",fontFamily:ke,fontSize:9,fontWeight:700,color:"#D44040"}},"⛔ DELETE ALL SPAM"))),la&&i.createElement("div",{style:{padding:14,borderTop:"2px solid "+Ct.purple}},i.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10}},i.createElement("span",{style:{fontFamily:ke,fontSize:9,fontWeight:700,color:Ct.purple,letterSpacing:".1em"}},"THREAD · "+la.message_count+" messages"),i.createElement("button",{onClick:function(){hc(null)},style:{background:"transparent",border:"none",cursor:"pointer",fontFamily:ke,fontSize:10,color:"#5A7090"}},"✕")),la.ai_summary&&i.createElement("div",{style:{padding:"8px 10px",background:"rgba(212,175,92,0.06)",border:"1px solid rgba(212,175,92,0.15)",borderRadius:6,marginBottom:10,fontSize:11,color:"#C9D1D9",lineHeight:1.6}},i.createElement("div",{style:{fontFamily:ke,fontSize:8,color:Ct.purple,marginBottom:4,letterSpacing:".08em"}},"AI SUMMARY"),la.ai_summary),(la.messages||[]).map(function(m,L){return i.createElement("div",{key:m.gmail_id||L,style:{padding:"8px 10px",borderLeft:"2px solid rgba(212,175,92,0.2)",marginBottom:6,marginLeft:4}},i.createElement("div",{style:{fontFamily:ke,fontSize:9,fontWeight:600,color:"#C9D1D9"}},m.from||""),i.createElement("div",{style:{fontFamily:ke,fontSize:7,color:"#3A4A5E",marginBottom:3}},m.date||""),i.createElement("div",{style:{fontSize:11,color:"#8B949E",lineHeight:1.5}},m.snippet||""))}),la.participants&&la.participants.length>0&&i.createElement("div",{style:{marginTop:8,fontFamily:ke,fontSize:8,color:"#5A7090"}},"Participants: "+la.participants.join(", "))),yc&&i.createElement("div",{style:{padding:24,textAlign:"center",fontFamily:ke,fontSize:9,color:Ct.purple}},"Loading thread…"),z==="drafts"&&(function(){var m=Tj();return m.length===0?i.createElement("div",{style:{padding:24,textAlign:"center",fontFamily:ke,fontSize:9,color:"#3A4A5E"}},"No saved drafts"):m.map(function(L){return i.createElement("div",{key:L.id,onClick:function(){oe(null),h(function(le){return le.concat([{id:"s"+Date.now(),role:"system",text:"Loaded draft: "+(L.subject||"(no subject)"),ts:Fn()},{id:"d"+Date.now(),role:"draft",draft:{to:L.to||"",cc:L.cc||"",bcc:L.bcc||"",subject:L.subject||"",body:L.body||"",fromAccount:L.fromAccount||C,attachments:[]},ts:Fn()}])})},style:{padding:"10px 14px",borderBottom:"1px solid #0C1018",cursor:"pointer",borderLeft:"3px solid rgba(212,175,92,0.3)"},onMouseEnter:function(le){le.currentTarget.style.background="rgba(212,175,92,0.03)"},onMouseLeave:function(le){le.currentTarget.style.background="transparent"}},i.createElement("div",{style:{fontSize:12,fontWeight:600,color:"#C9D1D9"}},L.subject||"(no subject)"),i.createElement("div",{style:{fontFamily:ke,fontSize:8,color:"#3A4A5E",marginTop:3}},"To: "+(L.to||"—")),i.createElement("button",{onClick:function(le){le.stopPropagation(),Rj(L.id),N(Mm()),oe("drafts")},style:{marginTop:4,padding:"2px 8px",background:"rgba(255,68,68,0.06)",border:"1px solid rgba(255,68,68,0.15)",borderRadius:3,cursor:"pointer",fontFamily:ke,fontSize:7,color:"#D44040"}}
114,"DELETE"))})})(),z==="followups"&&i.createElement(i.Fragment,null,q&&i.createElement("div",{style:{padding:24,textAlign:"center",fontFamily:ke,fontSize:9,color:Ct.orange}},"Analyzing…"),!q&&de.length===0&&i.createElement("div",{style:{padding:24,textAlign:"center",fontFamily:ke,fontSize:9,color:"#3A4A5E"}},"No pending follow-ups"),!q&&de.map(function(m,L){var le=m.urgency==="HIGH";return i.createElement("div",{key:m.thread_id||L,onClick:function(){oe(null),s&&s("followup"),Ti("Draft a follow-up to "+(m.from_email||"")+" about "+(m.subject||""))},style:{padding:"10px 14px",borderBottom:"1px solid #0C1018",borderLeft:"3px solid "+(le?"#D44040":Ct.orange),cursor:"pointer"},onMouseEnter:function(ye){ye.currentTarget.style.background="rgba(212,175,92,0.03)"},onMouseLeave:function(ye){ye.currentTarget.style.background="transparent"}},i.createElement("div",{style:{fontSize:11,fontWeight:600,color:"#C9D1D9",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},m.subject||"Thread"),i.createElement("div",{style:{fontFamily:ke,fontSize:8,color:"#5A7090",marginTop:3}},m.ai_suggestion||m.snippet||""),i.createElement("div",{style:{fontFamily:ke,fontSize:7,color:le?"#D44040":Ct.orange,marginTop:3}},le?"OVERDUE":"48h recommended"))})),z==="contacts"&&(O||[]).map(function(m,L){return i.createElement("div",{key:m.contact_id||L,style:{display:"flex",alignItems:"center",gap:10,padding:"8px 14px",borderBottom:"1px solid #0C1018",cursor:"pointer"},onMouseEnter:function(le){le.currentTarget.style.background="rgba(212,175,92,0.03)"},onMouseLeave:function(le){le.currentTarget.style.background="transparent"}},i.createElement("div",{style:{width:30,height:30,borderRadius:"50%",background:"linear-gradient(135deg,#D4AF5C,#9E7E35)",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:ke,fontSize:10,fontWeight:700,color:"#000"}},(m.name||m.email||"?")[0].toUpperCase()),i.createElement("div",{onClick:function(){oe(null),ss("Draft email to "+(m.name||m.email))},style:{flex:1,minWidth:0}},i.createElement("div",{style:{fontSize:12,fontWeight:600,color:"#E6EDF3",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},m.name||m.email),i.createElement("div",{style:{fontFamily:ke,fontSize:8,color:"#5A7090"}},m.email),i.createElement("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:2}},m.email_count&&i.createElement("span",{style:{fontFamily:ke,fontSize:7,color:Ct.accent,padding:"0 4px",border:"1px solid rgba(56,189,248,0.2)",borderRadius:2}},m.email_count+" emails"),m.last_contact_date&&i.createElement("span",{style:{fontFamily:ke,fontSize:7,color:"#3A4A5E"}},Aa(m.last_contact_date)),m.organisation&&i.createElement("span",{style:{fontFamily:ke,fontSize:7,color:"#5A7090"}},m.organisation))),i.createElement("button",{onClick:function(le){le.stopPropagation(),oe(null),ss("Research "+(m.name||m.email))},title:"Research",style:{background:"transparent",border:"1px solid #2A3548",borderRadius:3,padding:"3px 6px",cursor:"pointer",fontFamily:ke,fontSize:7,color:"#5A7090",flexShrink:0}},"🔍"))}),z==="rules"&&i.createElement(i.Fragment,null,i.createElement("div",{style:{padding:10}},i.createElement("button",{onClick:function(){Xi(!Fs)},style:{width:"100%",padding:"8px",background:"rgba(212,175,92,0.08)",border:"1px solid rgba(212,175,92,0.2)",borderRadius:6,cursor:"pointer",fontFamily:ke,fontSize:9,color:Ct.orange}},Fs?"✕ CANCEL":"+ ADD RULE")),Fs&&i.createElement("div",{style:{padding:"0 10px 10px",borderBottom:"1px solid #1A2332"}},i.createElement("select",{value:dd,onChange:function(m){fc(m.target.value)},style:{width:"100%",background:"#0A0E16",border:"1px solid #1A2332",borderRadius:4,padding:"6px 8px",fontSize:11,color:"#E6EDF3",outline:"none",boxSizing:"border-box",marginBottom:4,fontFamily:ke}},i.createElement("option",{value:"from_email"},"From email"),i.createElement("option",{value:"from_domain"},"From domain"),i.createElement("option",{value:"subject_contains"},"Subject contains")),i.createElement("input",{value:Ua,onChange:function(m){Is(m.target.value)},placeholder:"Value (e.g. [email protected])",style:{width:"100%",background:"#0A0E16",border:"1px solid #1A2332",borderRadius:4,padding:"6px 8px",fontSize:11,color:"#E6EDF3",outline:"none",boxSizing:"border-box",marginBottom:4,fontFamily:"'SF Pro Text',sans-serif"}}),i.createElement("select",{value:aa,onChange:function(m){gc(m.target.value)},style:{width:"100%",background:"#0A0E16",border:"1px solid #1A2332",borderRadius:4,padding:"6px 8px",fontSize:11,color:"#E6EDF3",outline:"none",boxSizing:"border-box",marginBottom:4,fontFamily:ke}},i.createElement("option",{value:"SET_JUNK"},"Mark as junk"),i.createElement("option",{value:"SET_CRITICAL"}
114,"Mark as critical"),i.createElement("option",{value:"CLASSIFY_AS"},"Classify as…")),aa==="CLASSIFY_AS"&&i.createElement("input",{value:ts,onChange:function(m){Ds(m.target.value)},placeholder:"Classification (e.g. DEAL, LEGAL)",style:{width:"100%",background:"#0A0E16",border:"1px solid #1A2332",borderRadius:4,padding:"6px 8px",fontSize:11,color:"#E6EDF3",outline:"none",boxSizing:"border-box",marginBottom:4,fontFamily:"'SF Pro Text',sans-serif"}}),i.createElement("button",{onClick:Sd,disabled:!Ua.trim(),style:{width:"100%",padding:"8px",background:Ua.trim()?"rgba(63,185,80,0.08)":"transparent",border:"1px solid "+(Ua.trim()?"rgba(63,185,80,0.25)":"#1A2332"),borderRadius:4,cursor:Ua.trim()?"pointer":"not-allowed",fontFamily:ke,fontSize:9,fontWeight:700,color:Ua.trim()?Ct.green:"#3A4A5E"}},"SAVE RULE")),uc&&i.createElement("div",{style:{padding:24,textAlign:"center",fontFamily:ke,fontSize:9,color:Ct.orange}},"Loading…"),!uc&&Al.length===0&&!Fs&&i.createElement("div",{style:{padding:24,textAlign:"center",fontFamily:ke,fontSize:9,color:"#3A4A5E"}},"No rules configured"),!uc&&Al.map(function(m,L){var le=m.action==="SET_JUNK"?"JUNK":m.action==="SET_CRITICAL"?"CRITICAL":m.action==="CLASSIFY_AS"?m.action_value||"CLASSIFY":m.action,ye=m.action==="SET_JUNK"?"#F97583":m.action==="SET_CRITICAL"?"#D44040":Ct.accent;return i.createElement("div",{key:m.rule_id||L,style:{padding:"10px 14px",borderBottom:"1px solid #0C1018",display:"flex",alignItems:"center",gap:8}},i.createElement("div",{style:{flex:1,minWidth:0}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:6}},i.createElement("span",{style:{fontFamily:ke,fontSize:8,color:"#5A7090",padding:"1px 5px",border:"1px solid #1A2332",borderRadius:2}},m.condition_field),i.createElement("span",{style:{fontFamily:ke,fontSize:8,color:"#3A4A5E"}},"→"),i.createElement("span",{style:{fontFamily:ke,fontSize:8,fontWeight:700,color:ye,padding:"1px 5px",border:"1px solid "+ye+"40",borderRadius:2}},le)),i.createElement("div",{style:{fontSize:11,color:"#C9D1D9",marginTop:3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},m.condition_value)),i.createElement("button",{onClick:function(){Qi(m.rule_id)},style:{padding:"3px 8px",background:"rgba(255,68,68,0.06)",border:"1px solid rgba(255,68,68,0.15)",borderRadius:3,cursor:"pointer",fontFamily:ke,fontSize:7,color:"#D44040",flexShrink:0}},"✕"))})),z==="folders"&&i.createElement(i.Fragment,null,i.createElement("div",{style:{padding:10}},i.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8}},i.createElement("span",{style:{fontFamily:ke,fontSize:9,fontWeight:700,color:Ct.orange,letterSpacing:".1em"}},"📁 FOLDERS"),i.createElement("div",{style:{display:"flex",gap:4}},i.createElement("button",{onClick:function(){xd()},disabled:Li,style:{padding:"4px 10px",background:"rgba(56,189,248,0.06)",border:"1px solid rgba(56,189,248,0.2)",borderRadius:4,cursor:Li?"default":"pointer",fontFamily:ke,fontSize:7,color:Li?Ct.dim:Ct.accent,fontWeight:700}},Li?"◌ SORTING…":"AUTO-SORT BY SENDER"),i.createElement("button",{onClick:function(){wi()},style:{padding:"4px 10px",background:"rgba(200,92,92,0.06)",border:"1px solid rgba(200,92,92,0.2)",borderRadius:4,cursor:"pointer",fontFamily:ke,fontSize:7,color:Ct.red}},"🗑 CLEAR ARCHIVES"))),i.createElement("div",{style:{display:"flex",gap:4,marginBottom:8}},i.createElement("input",{value:Qr,onChange:function(m){Sr(m.target.value)},onKeyDown:function(m){m.key==="Enter"&&Qr.trim()&&(_c(Qr),Sr(""))},placeholder:"New folder name…",style:{flex:1,background:"#05080D",border:"1px solid #1A2332",borderRadius:4,padding:"6px 10px",color:"#E6EDF3",fontFamily:ke,fontSize:10,outline:"none"}}),i.createElement("button",{onClick:function(){Qr.trim()&&(_c(Qr),Sr(""))},style:{padding:"6px 14px",background:"rgba(212,175,92,0.08)",border:"1px solid rgba(212,175,92,0.25)",borderRadius:4,cursor:"pointer",fontFamily:ke,fontSize:8,color:Ct.orange,fontWeight:700}},"+")),sa?i.createElement("div",{style:{padding:20,textAlign:"center",fontFamily:ke,fontSize:9,color:Ct.dim}},"Loading folders…"):ol.length===0?i.createElement("div",{style:{padding:20,textAlign:"center"}},i.createElement("div",{style:{fontSize:24,opacity:.3,marginBottom:8}},"📁"),i.createElement("div",{style:{fontFamily:ke,fontSize:10,
114color:"#5A7090"}},"No custom folders yet"),i.createElement("div",{style:{fontFamily:ke,fontSize:8,color:Ct.dim,marginTop:4}},"Create one above or type “auto-sort” to organise by sender")):ol.map(function(m){var L=Io&&(Io.id||Io.name)===(m.id||m.name);return i.createElement("div",{key:m.id||m.name,onClick:function(){dl(m),oe(null),oe("folders")},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 12px",borderBottom:"1px solid #0C1018",cursor:"pointer",background:L?"rgba(212,175,92,0.04)":"transparent",borderLeft:L?"2px solid "+Ct.orange:"2px solid transparent"},onMouseEnter:function(le){L||(le.currentTarget.style.background="rgba(212,175,92,0.02)")},onMouseLeave:function(le){L||(le.currentTarget.style.background="transparent")}},i.createElement("span",{style:{fontSize:14}},"📁"),i.createElement("div",{style:{flex:1,minWidth:0}},i.createElement("div",{style:{fontSize:11,color:L?Ct.orange:"#E6EDF3",fontWeight:L?700:400,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},m.name),i.createElement("div",{style:{fontFamily:ke,fontSize:7,color:Ct.dim}},(m.total||0)+" emails"+(m.unread?" · "+m.unread+" unread":""))),m.unread>0&&i.createElement("span",{style:{minWidth:16,height:16,borderRadius:"50%",background:Ct.red,display:"flex",alignItems:"center",justifyContent:"center",fontFamily:ke,fontSize:7,color:"#fff",fontWeight:700,flexShrink:0,padding:"0 3px"}},m.unread),i.createElement("button",{onClick:function(le){le.stopPropagation(),Do(m.id||m.name)},title:"Delete folder",style:{background:"transparent",border:"none",cursor:"pointer",fontSize:9,color:"#3A4A5E",padding:"0 2px",flexShrink:0},onMouseEnter:function(le){le.currentTarget.style.color="#C85C5C"},onMouseLeave:function(le){le.currentTarget.style.color="#3A4A5E"}},"✕"))}))),z==="templates"&&i.createElement(i.Fragment,null,i.createElement("div",{style:{padding:10}},i.createElement("div",{style:{display:"flex",gap:4,marginBottom:6}},i.createElement("input",{value:Wa,onChange:function(m){kc(m.target.value)},placeholder:"Template name…",style:{flex:1,background:"#0A0E16",border:"1px solid #1A2332",borderRadius:4,padding:"6px 8px",fontSize:11,color:"#E6EDF3",outline:"none",boxSizing:"border-box",fontFamily:"'SF Pro Text',sans-serif"}}),i.createElement("button",{onClick:Ed,disabled:!Wa.trim(),style:{padding:"6px 10px",background:Wa.trim()?"rgba(63,185,80,0.08)":"transparent",border:"1px solid "+(Wa.trim()?"rgba(63,185,80,0.25)":"#1A2332"),borderRadius:4,cursor:Wa.trim()?"pointer":"not-allowed",fontFamily:ke,fontSize:8,fontWeight:700,color:Wa.trim()?Ct.green:"#3A4A5E"}},"SAVE CURRENT")),i.createElement("div",{style:{fontFamily:ke,fontSize:7,color:"#3A4A5E"}},"Save active draft as template")),Di.length===0&&i.createElement("div",{style:{padding:24,textAlign:"center",fontFamily:ke,fontSize:9,color:"#3A4A5E"}},"No templates yet"),Di.map(function(m,L){return i.createElement("div",{key:m.id||L,style:{padding:"10px 14px",borderBottom:"1px solid #0C1018",display:"flex",alignItems:"center",gap:8}},i.createElement("div",{onClick:function(){vu(m)},style:{flex:1,cursor:"pointer",minWidth:0},onMouseEnter:function(le){le.currentTarget.style.color="#E6EDF3"},onMouseLeave:function(le){le.currentTarget.style.color="#C9D1D9"}},i.createElement("div",{style:{fontSize:11,fontWeight:600,color:"#C9D1D9"}},m.name),i.createElement("div",{style:{fontFamily:ke,fontSize:8,color:"#3A4A5E",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},m.subject||"(no subject)")),i.createElement("button",{onClick:function(){bu(m.id)},style:{padding:"3px 8px",background:"rgba(255,68,68,0.06)",border:"1px solid rgba(255,68,68,0.15)",borderRadius:3,cursor:"pointer",fontFamily:ke,fontSize:7,color:"#D44040",flexShrink:0}},"✕"))})),z==="signature"&&i.createElement(i.Fragment,null,i.createElement("div",{style:{padding:14}},i.createElement("div",{style:{fontFamily:ke,fontSize:9,fontWeight:700,color:Ct.orange,letterSpacing:".1em",marginBottom:8}},"EMAIL SIGNATURE"),i.createElement("div",{style:{fontFamily:ke,fontSize:8,color:"#5A7090",marginBottom:8}},"Auto-appended to outgoing emails"),i.createElement("textarea",{value:Ho,onChange:function(m){Qn(m.target.value)},placeholder:`Enter your signature…
115
116Best regards,
117Your Name
118Title | Company`,rows:8,style:{width:"100%",background:"#0A0E16",border:"1px solid #1A2332",borderRadius:6,padding:"10px",fontSize:12,color:"#E6EDF3",outline:"none",boxSizing:"border-box",resize:"vertical",fontFamily:"'SF Pro Text',sans-serif",lineHeight:1.6}}),i.createElement("button",{onClick:Ic,style:{width:"100%",marginTop:8,padding:"10px",background:"rgba(63,185,80,0.08)",border:"1px solid rgba(63,185,80,0.25)",borderRadius:4,cursor:"pointer",fontFamily:ke,fontSize:10,fontWeight:700,color:Ct.green}},"SAVE SIGNATURE"),Ho&&i.createElement("div",{style:{marginTop:12,padding:10,background:"rgba(212,175,92,0.04)",border:"1px solid rgba(212,175,92,0.1)",borderRadius:6}},i.createElement("div",{style:{fontFamily:ke,fontSize:8,color:Ct.orange,marginBottom:6,letterSpacing:".08em"}},"PREVIEW"),i.createElement("div",{style:{fontSize:12,color:"#C9D1D9",whiteSpace:"pre-wrap",lineHeight:1.6}},Ho)))),z==="accounts"&&i.createElement(i.Fragment,null,A.map(function(m){var L=m.provider||"google",le=L==="google"?"Google":L==="microsoft"?"Microsoft":L==="yahoo"?"Yahoo":L==="apple"?"iCloud":L==="imap"?"IMAP":L.charAt(0).toUpperCase()+L.slice(1);return i.createElement("div",{key:m.email,style:{display:"flex",alignItems:"center",gap:10,padding:"12px 14px",borderBottom:"1px solid #0C1018",background:C===m.email?"rgba(212,175,92,0.03)":"transparent"}},i.createElement("div",{style:{width:26,height:26,borderRadius:"50%",background:L==="google"?"linear-gradient(135deg,#4285F4,#34A853)":L==="microsoft"?"linear-gradient(135deg,#0078D4,#00A4EF)":"linear-gradient(135deg,#D4AF5C,#9E7E35)",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:ke,fontSize:10,fontWeight:700,color:"#fff"}},(m.email||"?")[0].toUpperCase()),i.createElement("div",{style:{flex:1}},i.createElement("div",{style:{fontSize:12,fontWeight:600,color:"#E6EDF3"}},m.email),i.createElement("div",{style:{display:"flex",gap:6,alignItems:"center"}},i.createElement("span",{style:{fontFamily:ke,fontSize:7,color:"#5A7090",padding:"1px 5px",border:"1px solid #1A2332",borderRadius:2}},le),i.createElement("span",{style:{fontFamily:ke,fontSize:8,color:C===m.email?Ct.green:"#3A4A5E"}},C===m.email?"● Active":"Available"))),i.createElement("div",{style:{display:"flex",gap:4}},C!==m.email&&i.createElement("button",{onClick:function(){_(m.email)},style:{padding:"3px 10px",background:"rgba(212,175,92,0.08)",border:"1px solid rgba(212,175,92,0.2)",borderRadius:3,cursor:"pointer",fontFamily:ke,fontSize:7,color:Ct.orange}},"USE"),i.createElement("button",{onClick:function(){rd.disconnect(m.email).then(function(){j(function(ye){return ye.filter(function(De){return De.email!==m.email})})}).catch(function(){})},style:{padding:"3px 10px",background:"rgba(255,68,68,0.06)",border:"1px solid rgba(255,68,68,0.15)",borderRadius:3,cursor:"pointer",fontFamily:ke,fontSize:7,color:"#D44040"}},"REMOVE")))}),i.createElement("div",{style:{padding:14}},T?i.createElement("div",{style:{background:"#0A0E16",border:"1px solid #1A2332",borderRadius:6,padding:14}},i.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12}},i.createElement("span",{style:{fontFamily:ke,fontSize:9,fontWeight:700,color:Ct.orange,letterSpacing:"0.1em"}},"CONNECT EMAIL"),i.createElement("button",{onClick:Dl,style:{background:"transparent",border:"none",cursor:"pointer",fontFamily:ke,fontSize:11,color:"#5A7090",padding:0}},"✕")),i.createElement("div",{style:{display:"flex",gap:4,marginBottom:12}},[1,2,3].map(function(m){return i.createElement("div",{key:m,style:{flex:1,height:3,borderRadius:2,background:ie>=m?m===3?"#3FB950":Ct.orange:"#1A2332",transition:"background .3s"}})})),ie===1&&i.createElement(i.Fragment,null,i.createElement("div",{style:{fontFamily:ke,fontSize:8,color:"#5A7090",marginBottom:8}},"Enter your email address"),i.createElement("input",{value:Me,onChange:function(m){nt(m.target.value)},onKeyDown:function(m){m.key==="Enter"&&Cu()},placeholder:"[email protected]",autoFocus:!0,style:{width:"100%",background:"#05080D",border:"1px solid #1A2332",borderRadius:4,padding:"10px 12px",fontSize:13,color:"#E6EDF3",outline:"none",boxSizing:"border-box",marginBottom:8,fontFamily:"'SF Pro Text',sans-serif"}}),ai&&i.createElement("div",{style:{fontFamily:ke,fontSize:8,color:"#F97583",marginBottom:8}},ai),i.createElement("button",{onClick:Cu,disabled:he,style:{width:"100%",padding:"10px",background:he?"#1A1F2B":"rgba(212,175,92,0.08)",border:"1px solid "+(he?"#2A3548":"rgba(212,175,92,0.25)"),borderRadius:4,cursor:he?"wait":"pointer",fontFamily:ke,fontSize:10,fontWeight:700,color:he?"#5A7090":Ct.orange}},he?"DETECTING…":"CONTINUE")),ie===2&&Tn&&Tn.use_oauth&&i.createElement(i.Fragment,null,i.createElement("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10}},i.createElement("div",{style:{width:8,height:8,borderRadius:"50%",background:"#4285F4"}}),i.createElement("span",{style:{fontFamily:ke,fontSize:9,color:"#E6EDF3"}},Me),i.createElement("span",{style:{fontFamily:ke,fontSize:7,color:"#4285F4",padding:"1px 6px",border:"1px solid rgba(66,133,244,0.3)",borderRadius:3}},Tn.label||"Google")),i.createElement("div",{style:{fontFamily:ke,fontSize:8,color:"#7A8A9E",marginBottom:12}},"This email provider uses secure sign-in. Click below to authenticate."),i.createElement("button",{onClick:function(){Bs(),Dl()},style:{width:"100%",padding:"10px",background:"rgba(66,133,244,0.08)",border:"1px solid rgba(66,133,244,0.3)",borderRadius:4,cursor:"pointer",fontFamily:ke,fontSize:10,fontWeight:700,color:"#4285F4"}},"SIGN IN WITH GOOGLE"),Tn.imap_host&&i.createElement("button",{onClick:function(){Tn.imap_host&&Te(Tn.imap_host),Tn.smtp_host&&bn(Tn.smtp_host),ra(Object.assign({},Tn,{use_oauth:!1}))},style:{width:"100%",marginTop:6,padding:"8px",background:"transparent",border:"1px solid #1A2332",borderRadius:4,cursor:"pointer",fontFamily:ke,fontSize:9,color:"#7A8A9E"}},"USE APP PASSWORD INSTEAD"),i.createElement("button",{onClick:function(){ue(1)},style:{width:"100%",marginTop:6,padding:"6px",background:"transparent",border:"none",cursor:"pointer",fontFamily:ke,fontSize:8,color:"#3A4A5E"}},"← Back")),ie===2&&Tn&&!Tn.use_oauth&&i.createElement(i.Fragment,null,i.createElement("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8}},i.createElement("div",{style:{width:8,height:8,borderRadius:"50%",background:Ct.green}}),i.createElement("span",{style:{fontFamily:ke,fontSize:9,color:"#E6EDF3"}},Me),Tn.imap_host&&i.createElement("span",{style:{fontFamily:ke,fontSize:7,color:Ct.green,padding:"1px 6px",border:"1px solid rgba(63,185,80,0.3)",borderRadius:3}},"✔ "+(Tn.method==="dns_mx"?"MX detected":Tn.method==="mozilla_ispdb"?"Auto-configured":Tn.method==="dns_srv"?"SRV detected":"Detected"))),Tn.imap_host&&!Ro&&i.createElement("div",{style:{fontFamily:ke,fontSize:8,color:"#5A7090",marginBottom:6,padding:"6px 8px",background:"#0C1018",borderRadius:3,border:"1px solid #151D2B"}},"IMAP: "+Tn.imap_host+":"+Tn.imap_port+" | SMTP: "+(Tn.smtp_host||"")+":"+(Tn.smtp_port||587)),i.createElement("div",{style:{fontFamily:ke,fontSize:8,color:"#5A7090",marginBottom:6}},"Enter your password or app password"),Nu[Tn.provider]&&i.createElement("div",{style:{fontFamily:ke,fontSize:8,color:"#7A8A9E",marginBottom:6,padding:"6px 8px",background:"rgba(212,175,92,0.04)",border:"1px solid rgba(212,175,92,0.15)",borderRadius:3,lineHeight:1.4}},Nu[Tn.provider].label&&Nu[Tn.provider].url&&i.createElement("a",{href:Nu[Tn.provider].url,target:"_blank",rel:"noopener noreferrer",style:{color:Ct.orange,textDecoration:"underline",display:"block",marginBottom:3}},Nu[Tn.provider].label+" →"),i.createElement("span",{style:{color:"#5A7090"}},Nu[Tn.provider].note)),i.createElement("input",{value:je,onChange:function(m){Le(m.target.value)},onKeyDown:function(m){m.key==="Enter"&&Ad()},placeholder:"Password",type:"password",autoFocus:!0,style:{width:"100%",background:"#05080D",border:"1px solid #1A2332",borderRadius:4,padding:"10px 12px",fontSize:13,color:"#E6EDF3",outline:"none",boxSizing:"border-box",marginBottom:6,fontFamily:"'SF Pro Text',sans-serif"}}),Ro&&i.createElement(i.Fragment,null,i.createElement("input",{value:Wt,onCh
118ange:function(m){Te(m.target.value)},placeholder:"IMAP host (e.g. imap.company.com)",style:{width:"100%",background:"#05080D",border:"1px solid #1A2332",borderRadius:4,padding:"7px 10px",fontSize:11,color:"#E6EDF3",outline:"none",boxSizing:"border-box",marginBottom:4,fontFamily:ke}}),i.createElement("input",{value:Tt,onChange:function(m){bn(m.target.value)},placeholder:"SMTP host (e.g. smtp.company.com)",style:{width:"100%",background:"#05080D",border:"1px solid #1A2332",borderRadius:4,padding:"7px 10px",fontSize:11,color:"#E6EDF3",outline:"none",boxSizing:"border-box",marginBottom:6,fontFamily:ke}})),ai&&i.createElement("div",{style:{fontFamily:ke,fontSize:8,color:ai.includes("Failed")||ai.includes("failed")?"#F97583":"#7A8A9E",marginBottom:8,lineHeight:1.4}},ai),i.createElement("button",{onClick:Ad,disabled:he,style:{width:"100%",padding:"10px",background:he?"#1A1F2B":"rgba(63,185,80,0.08)",border:"1px solid "+(he?"#2A3548":"rgba(63,185,80,0.3)"),borderRadius:4,cursor:he?"wait":"pointer",fontFamily:ke,fontSize:10,fontWeight:700,color:he?"#5A7090":Ct.green}},he?"CONNECTING…":"CONNECT"),i.createElement("div",{style:{display:"flex",gap:6,marginTop:6}},i.createElement("button",{onClick:function(){ue(1),ra(null),Ba(!1),Nn("")},style:{flex:1,padding:"6px",background:"transparent",border:"1px solid #1A2332",borderRadius:3,cursor:"pointer",fontFamily:ke,fontSize:8,color:"#5A7090"}},"← Back"),!Ro&&i.createElement("button",{onClick:function(){Ba(!0)},style:{flex:1,padding:"6px",background:"transparent",border:"1px solid #1A2332",borderRadius:3,cursor:"pointer",fontFamily:ke,fontSize:8,color:"#5A7090"}},"Manual settings"))),ie===3&&i.createElement("div",{style:{textAlign:"center",padding:"20px 0"}},i.createElement("div",{style:{fontSize:24,marginBottom:8}},"✔"),i.createElement("div",{style:{fontFamily:ke,fontSize:11,fontWeight:700,color:Ct.green,letterSpacing:"0.1em"}},"CONNECTED"),i.createElement("div",{style:{fontFamily:ke,fontSize:9,color:"#7A8A9E",marginTop:4}},Me))):i.createElement("button",{onClick:function(){Y(!0),ue(1),Nn("")},style:{width:"100%",padding:"10px",background:"rgba(212,175,92,0.08)",border:"1px solid rgba(212,175,92,0.2)",borderRadius:6,cursor:"pointer",fontFamily:ke,fontSize:9,color:Ct.orange}},"+ ADD EMAIL ACCOUNT"))))),i.createElement("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"}},i.createElement("div",{ref:xe,style:{flex:1,overflowY:"auto",padding:"0 24px",position:"relative"}},f.map(function(m){if(m.role==="user")return i.createElement("div",{key:m.id,style:Rr},i.createElement("div",{style:ti},"YOU"),i.createElement("div",{style:{flex:1,minWidth:0}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:9}},i.createElement("span",{style:{fontFamily:ke,fontWeight:700,fontSize:11,color:"#8B949E",letterSpacing:"0.1em"}},"PRINCIPAL"),m.ts&&i.createElement("span",{style:{fontFamily:ke,fontSize:8,color:"#5A6880",marginLeft:"auto"}},m.ts)),i.createElement("p",{style:{margin:0,color:"#E6EDF3",fontSize:14,lineHeight:1.65}},m.text)));if(m.role==="system"){var L=wt===m.id;return i.createElement("div",{key:m.id,style:Rr},i.createElement("div",{style:yn},"X"),i.createElement("div",{style:{flex:1,minWidth:0}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:9}},i.createElement("span",{style:{fontFamily:ke,fontWeight:700,fontSize:11,color:Ct.orange,letterSpacing:"0.1em"}},"XYRON"),i.createElement("span",{style:{fontFamily:ke,fontSize:9,color:"#7A8A9E",padding:"2px 6px",border:"1px solid #2A3548",borderRadius:3}},"EMAIL AGENT"),L&&i.createElement("span",{style:{fontFamily:ke,fontSize:8,color:Ct.orange,animation:"xpulse 1s infinite"}},"streaming"),m.ts&&i.createElement("span",{style:{fontFamily:ke,fontSize:8,color:"#5A6880",marginLeft:"auto"}},m.ts)),L?i.createElement("div",{ref:Qe,style:{color:"#C9D1D9",fontSize:14,lineHeight:1.65,minHeight:20}}):i.createElement("div",{style:{color:"#C9D1D9",fontSize:14,lineHeight:1.65},dangerouslySetInnerHTML:{__html:Ga(m.text||"")}})))}if(m.role==="analysis"||m.role==="research"){var le=m.role==="research",ye=le?"#B0BCC8":Ct.orange,De=wt===m.id;return i.createElement("div",{key:m.id,style:Rr},i.createElement("div",{style:Object.assign({},yn,le?{background:"linear-gradient(135deg,#B0BCC8,#0090B0)"}:{})},"X"),i.createElement("div",{style:{flex:1,minWidth:0}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10}},i.createElement("span",{style:{fontFamily:ke,fontWeight:700,fontSize:11,color:ye,letterSpacing:"0.1em"}},"XYRON"),i.createElement("span",{style:{fontFamily:ke,fontSize:8,color:ye,background:"rgba("+qs(ye)+",0.08)",border:"1px solid rgba("+qs(ye)+",0.25)",borderRadius:3,padding:"2px 6px",letterSpacing:"0.08em"}},le?"WEB RESEARCH":"INTELLIGENCE"),De&&i.createElement("span",{style:{fontFamily:ke,fontSize:8,color:Ct.orange,animation:"xpulse 1s infinite"}},"streaming"),m.ts&&i.createElement("span",{style:{fontFamily:ke,fontSize:8,color:"#5A6880",marginLeft:"auto"}}
118,m.ts)),i.createElement("div",{style:{borderLeft:"2px solid rgba("+qs(ye)+",0.25)",paddingLeft:14,marginTop:2}},De?i.createElement("div",{ref:Qe,style:{fontSize:13.5,color:"#C9D1D9",lineHeight:1.75,minHeight:20}}):Ko(m.text,{persona:m.persona||null}))))}if(m.role==="intel"){let Yt=function(kn,Br,lo){return!Br||Br==="—"?null:i.createElement("div",{style:{marginBottom:8}},i.createElement("span",{style:{fontFamily:ke,fontSize:10,fontWeight:700,color:lo||Ct.accent,letterSpacing:"0.06em"}},kn+": "),i.createElement("span",{style:{fontSize:13.5,color:"#C9D1D9",lineHeight:1.75}},Br))};if(m.loading)return i.createElement("div",{key:m.id,style:Rr},i.createElement("div",{style:Object.assign({},yn,{background:"linear-gradient(135deg,#D4AF5C,#7C3AED)"})},"X"),i.createElement("div",{style:{flex:1}},i.createElement("span",{style:{fontFamily:ke,fontSize:11,color:"#D4AF5C",animation:"xpulse 1s infinite"}},"Reading and analyzing…")));var Se=m.data||{};return i.createElement("div",{key:m.id,style:Rr},i.createElement("div",{style:Object.assign({},yn,{background:"linear-gradient(135deg,#D4AF5C,#7C3AED)"})},"X"),i.createElement("div",{style:{flex:1,minWidth:0}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12}},i.createElement("span",{style:{fontFamily:ke,fontWeight:700,fontSize:11,color:"#D4AF5C",letterSpacing:"0.1em"}},"XYRON"),i.createElement("span",{style:{fontFamily:ke,fontSize:8,color:"#D4AF5C",background:"rgba(212,175,92,0.08)",border:"1px solid rgba(212,175,92,0.25)",borderRadius:3,padding:"2px 6px"}},"FAST INTEL"),Se.urgency&&i.createElement("span",{style:{fontFamily:ke,fontSize:8,fontWeight:700,color:kv[Se.urgency]||"#5A7090",padding:"2px 6px",border:"1px solid "+(kv[Se.urgency]||"#5A7090")+"40",borderRadius:3}},Se.urgency.toUpperCase()),Se.suggested_action&&i.createElement("span",{style:{fontFamily:ke,fontSize:8,color:Ct.green,padding:"2px 6px",border:"1px solid rgba(63,185,80,0.3)",borderRadius:3}},"→ "+Se.suggested_action.toUpperCase())),i.createElement("div",{style:{borderLeft:"2px solid rgba(212,175,92,0.25)",paddingLeft:14}},Yt("WHAT THEY WANT",Se.what_they_want,"#E6EDF3"),Yt("INTENT",Se.likely_intent),Yt("POSTURE",Se.psychological_posture,Oj[Se.psychological_posture]||Ct.accent),Yt("COUNTERPARTY",Se.counterparty_type),Yt("CREDIBILITY",Se.credibility),Yt("COMMERCIAL VALUE",Se.commercial_value,Lj[Se.commercial_value]||Ct.accent),i.createElement("div",{style:{marginTop:4,marginBottom:8,borderTop:"1px solid #151D2B",paddingTop:8}},i.createElement("span",{style:{fontFamily:ke,fontSize:10,fontWeight:700,color:Ct.orange,letterSpacing:"0.06em"}},"STRATEGY: "),i.createElement("span",{style:{fontSize:13.5,color:Ct.orange,lineHeight:1.75}},Se.reply_strategy||"—")),(Se.risk_flags||[]).length>0&&i.createElement("div",{style:{marginTop:4}},i.createElement("div",{style:{fontFamily:ke,fontSize:10,fontWeight:700,color:"#F97583",letterSpacing:"0.06em",marginBottom:4}},"RISK FLAGS:"),Se.risk_flags.map(function(kn,Br){return i.createElement("div",{key:Br,style:{fontSize:13,color:"#F97583",lineHeight:1.6,paddingLeft:10,marginBottom:2}},i.createElement("span",{style:{color:"#F97583",marginRight:6,fontSize:7}},"▸"),kn)})))))}if(m.role==="actions"){var Je={_compose_reply:"action",_compose_decline:"action",_compose_followup:"action",_persona_delay:"action",_persona_advance:"action",_persona_counter:"action",_persona_conditional:"action",_persona_deflect:"action",_persona_protect:"action",_persona_schedule:"action",_persona_discreet:"action",_persona_lp_response:"action",_persona_true_intent:"intel",_persona_seriousness:"intel",_persona_next_action:"intel",_deep_analysis:"intel",_psychology:"intel",_persona_history:"intel",_persona_escalate:"intel",_persona_financial:"finance",_persona_walkaway:"finance",_persona_hidden_costs:"finance",_persona_market_context:"finance",_persona_benchmarks:"finance",_persona_investor_quality:"finance",_persona_info_gate:"finance",_risk_analysis:"risk",_persona_legal_risk:"risk",_persona_dont_say:"risk",_persona_binding:"risk",_persona_reputation:"risk",_persona_verify:"risk",_research_sender:"risk",_analyze_summary:"util",_extract_actions:"util",_pd_send:"exec",_pd_save:"exec",_pd_attach_deck:"exec",_pd_risk_review:"exec",_pd_variant:"variant"}
118,ht={action:Ct.orange,intel:"#6B9AC4",finance:"#34D399",risk:"#F87171",util:"#D4AF5C",exec:Ct.orange,variant:"#818CF8"},Ht={action:"▸ ACTIONS",intel:"▸ INTELLIGENCE",finance:"▸ FINANCIAL",risk:"▸ RISK & LEGAL",util:"▸ ANALYSIS",exec:"▸ EXECUTE",variant:"▸ VARIANTS"},Bt={},pn=[];return m.actions.forEach(function(Yt){var kn=Je[Yt.cmd]||"action";Bt[kn]||(Bt[kn]=[],pn.push(kn)),Bt[kn].push(Yt)}),i.createElement("div",{key:m.id,style:{padding:"10px 0 10px 46px",borderBottom:"1px solid #0C1018"}},pn.map(function(Yt,kn){return i.createElement("div",{key:kn,style:{marginBottom:kn<pn.length-1?8:0}},pn.length>1&&i.createElement("div",{style:{fontFamily:ke,fontSize:8,fontWeight:700,color:ht[Yt]||Ct.orange,letterSpacing:"0.12em",marginBottom:5,opacity:.7}},Ht[Yt]||""),i.createElement("div",{style:{display:"flex",flexWrap:"wrap",gap:5}},Bt[Yt].map(function(Br,lo){var Ir=ht[Je[Br.cmd]||"action"]||Ct.orange;return i.createElement("button",{key:lo,onClick:function(){Yo(Br)},disabled:v,style:{padding:"5px 12px",background:v?"#1A1F2B":"rgba("+qs(Ir)+",0.06)",border:"1px solid "+(v?"#2A3548":"rgba("+qs(Ir)+",0.2)"),borderRadius:5,cursor:v?"not-allowed":"pointer",fontFamily:ke,fontSize:9,fontWeight:600,color:v?"#3A4A5E":Ir,transition:"all .12s",whiteSpace:"nowrap"},onMouseEnter:function(pa){v||(pa.currentTarget.style.background="rgba("+qs(Ir)+",0.14)")},onMouseLeave:function(pa){v||(pa.currentTarget.style.background="rgba("+qs(Ir)+",0.06)")}},Br.label)})))}))}if(m.role==="email"){var $t=m.emailData||{},Xt=$t.gmail_id||"",zn=Xt?Ha[Xt]:null;return Xt&&!zn&&$t.has_attachments&&bi(Xt),i.createElement("div",{key:m.id,style:Rr},i.createElement("div",{style:{width:32,height:32,borderRadius:8,background:"linear-gradient(135deg,#D4AF5C,#7C3AED)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginTop:2,fontSize:14}},"✉"),i.createElement("div",{style:{flex:1,minWidth:0}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:9}},i.createElement("span",{style:{fontFamily:ke,fontWeight:700,fontSize:11,color:"#D4AF5C",letterSpacing:"0.1em"}},$t.from_name||$t.from_email||"UNKNOWN"),i.createElement("span",{style:{fontFamily:ke,fontSize:8,color:"#5A7090"}},$t.classification||""),$t.date&&i.createElement("span",{style:{fontFamily:ke,fontSize:8,color:"#5A6880"}},Aa($t.date)),i.createElement("div",{style:{display:"flex",gap:4,marginLeft:"auto"}},i.createElement("button",{onClick:function(){Oo(Xt,!$t.is_read)},title:$t.is_read?"Mark unread":"Mark read",style:{background:"transparent",border:"1px solid #2A3548",borderRadius:3,padding:"2px 8px",cursor:"pointer",fontFamily:ke,fontSize:7,color:"#5A7090"}},$t.is_read?"UNREAD":"READ"),i.createElement("button",{onClick:function(){ao(m)},title:"Forward",style:{background:"transparent",border:"1px solid #2A3548",borderRadius:3,padding:"2px 8px",cursor:"pointer",fontFamily:ke,fontSize:7,color:"#5A7090"}},"FWD"),i.createElement("button",{onClick:function(){io(Xt,$t.is_starred)},title:$t.is_starred?"Unstar":"Star",style:{background:"transparent",border:"none",cursor:"pointer",fontSize:12,padding:"0 2px"}},$t.is_starred?"★":"☆"),i.createElement("button",{onClick:function(){ho(Xt)},title:"Delete",style:{background:"transparent",border:"none",cursor:"pointer",fontSize:10,padding:"0 2px",opacity:.5}},"🗑"),i.createElement("button",{onClick:function(){yo(Xt)},title:"Archive",style:{background:"transparent",border:"none",cursor:"pointer",fontSize:10,padding:"0 2px",opacity:.5}},"📦"),i.createElement("div",{style:{position:"relative",display:"inline-block"}},i.createElement("button",{onClick:function(Yt){Yt.stopPropagation();var kn=Yt.currentTarget.nextSibling;kn&&(kn.style.display=kn.style.display==="none"?"flex":"none")},title:"Flag email",style:{background:"transparent",border:"1px solid #2A3548",borderRadius:3,padding:"2px 8px",cursor:"pointer",fontFamily:ke,fontSize:7,color:"#5A7090"}},"🏳 FLAG"),i.createElement("div",{style:{display:"none",position:"absolute",top:"100%",right:0,zIndex:100,background:"#0C1018",border:"1px solid #2A3548",borderRadius:6,padding:4,flexDirection:"column",gap:2,minWidth:120,boxSh
118adow:"0 8px 24px rgba(0,0,0,0.6)"}},Ns.map(function(Yt){return i.createElement("button",{key:Yt.id,onClick:function(kn){kn.stopPropagation(),yu(Xt,Yt.id),kn.currentTarget.parentNode.style.display="none"},style:{display:"flex",alignItems:"center",gap:6,padding:"5px 8px",background:"transparent",border:"none",borderRadius:4,cursor:"pointer",textAlign:"left",width:"100%"},onMouseEnter:function(kn){kn.currentTarget.style.background="rgba(212,175,92,0.06)"},onMouseLeave:function(kn){kn.currentTarget.style.background="transparent"}},i.createElement("span",{style:{fontSize:10}},Yt.label.split(" ")[0]),i.createElement("span",{style:{fontFamily:ke,fontSize:8,color:Yt.color}},Yt.label.split(" ").slice(1).join(" ")))}))),m.body&&i.createElement("button",{onClick:function(){Su($t,m.body)},title:"Export PDF",style:{background:"transparent",border:"1px solid #2A3548",borderRadius:3,padding:"2px 8px",cursor:"pointer",fontFamily:ke,fontSize:7,color:"#5A7090"}},"PDF"))),i.createElement("div",{style:{fontFamily:ke,fontSize:9,color:"#5A7090",marginBottom:4}},$t.from_email||""),i.createElement("div",{style:{fontSize:14,fontWeight:600,color:"#E6EDF3",marginBottom:8}},$t.subject||"(no subject)"),i.createElement("div",{style:{fontSize:13,color:"#C9D1D9",lineHeight:1.65,whiteSpace:"pre-wrap",maxHeight:400,overflowY:"auto"}},m.body===null?i.createElement("span",{style:{fontFamily:ke,fontSize:11,color:Ct.orange,animation:"xpulse 1s infinite"}},"Loading…"):m.body),zn&&zn.length>0&&i.createElement("div",{style:{marginTop:10,borderTop:"1px solid #1A2332",paddingTop:8}},i.createElement("div",{style:{fontFamily:ke,fontSize:8,color:"#5A7090",marginBottom:6,letterSpacing:".06em"}},"📎 ATTACHMENTS ("+zn.length+")"),zn.map(function(Yt,kn){return i.createElement("div",{key:kn,onClick:function(){Yn(Xt,Yt)},style:{display:"inline-flex",alignItems:"center",gap:4,padding:"4px 10px",marginRight:6,marginBottom:4,background:"rgba(63,185,80,0.04)",border:"1px solid rgba(63,185,80,0.15)",borderRadius:4,cursor:"pointer",fontFamily:ke,fontSize:9,color:"#3FB950",transition:"background .12s"},onMouseEnter:function(Br){Br.currentTarget.style.background="rgba(63,185,80,0.1)"},onMouseLeave:function(Br){Br.currentTarget.style.background="rgba(63,185,80,0.04)"}},i.createElement("span",null,"⬇ "+Yt.filename),i.createElement("span",{style:{fontSize:7,color:"#3A4A5E"}},Yt.size>1024?Math.round(Yt.size/1024)+"KB":Yt.size+"B"))})),$t.has_attachments&&!zn&&i.createElement("div",{style:{marginTop:8,fontFamily:ke,fontSize:9,color:"#3A4A5E"}},"📎 Loading attachments…")))}if(m.role==="draft"){var Cn=m.draft,Fr=!!m.sent,hn=gt===m.id,hi=Fr?"SENT":!Cn.to||!Cn.subject?"DRAFT":"READY",Ol=Fr?Ct.green:hi==="READY"?Ct.orange:"#5A7090";return i.createElement("div",{key:m.id,style:Object.assign({padding:"18px 0",borderBottom:"1px solid #0C1018"},hn?{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:10,padding:0,background:"#0C1018",overflowY:"auto",display:"flex",flexDirection:"column"}:{})},i.createElement("div",{style:{display:"flex",gap:14,paddingLeft:hn?24:0,paddingRight:hn?24:0,paddingTop:hn?18:0}},i.createElement("div",{style:Object.assign({},yn,Fr?{background:"linear-gradient(135deg,#3FB950,#2EA043)"}:{})},"X"),i.createElement("div",{style:{flex:1,minWidth:0}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:9}},i.createElement("span",{style:{fontFamily:ke,fontWeight:700,fontSize:11,color:Ct.orange,letterSpacing:"0.1em"}},"XYRON"),i.createElement("span",{style:{fontFamily:ke,fontSize:8,fontWeight:700,color:Ol,background:"rgba("+qs(Ol)+",0.1)",border:"1px solid rgba("+qs(Ol)+",0.25)",borderRadius:3,padding:"2px 6px",letterSpacing:"0.08em"}},hi),m.variant&&i.createElement("span",{style:{fontFamily:ke,fontSize:8,color:"#5A7090"}},m.variant),m.ts&&i.createElement("span",{style:{fontFamily:ke,fontSize:8,color:"#5A6880",marginLeft:"auto"}},m.ts),!Fr&&i.createElement("div",{style:{display:"flex",gap:4,marginLeft:"auto"}},i.createElement("button",{onClick:function(){ja(m.id,function(){Zr(m.id)})},disabled:v||!Cn.to||!Cn.subject,style:{padding:"3px 10px",background:!Cn.to||!Cn.subject?"transparent":"rgba(212,175,92,0.08)",border:"1px solid "+(!Cn.to||!Cn.subject?"#2A3548":"rgba(212,175,92,0.3)"),borderRadius:4,cursor:!Cn.to||!Cn.subject||v?"not-allowed":"pointer",fontFamily:ke,fontSize:8,fontWeight:700,color:!Cn.to||!Cn.subject?"#3A4A5E":Ct.orange}},"SEND"),i.createElement("button",{onClick:function(){ul(m.id)},style:{padding:"3px 10px",background:"rgba(63,185,80,0.06)",border:"1px solid rgba(63,185,80,0.2)",borderRadius:4,cursor:"pointer",fontFamily:ke,fontSize:8,fontWeight:700,color:"#3FB950"}}
118,"📎 ATTACH"),i.createElement("button",{onClick:function(){Mi(m.id)},style:{padding:"3px 10px",background:"transparent",border:"1px solid #2A3548",borderRadius:4,cursor:"pointer",fontFamily:ke,fontSize:8,color:"#5A7090"}},"SAVE"),i.createElement("button",{onClick:function(){qt(hn?null:m.id)},style:{padding:"3px 10px",background:hn?"rgba(212,175,92,0.1)":"transparent",border:"1px solid "+(hn?"rgba(212,175,92,0.3)":"#2A3548"),borderRadius:4,cursor:"pointer",fontFamily:ke,fontSize:8,color:hn?Ct.orange:"#5A7090"}},hn?"COLLAPSE":"EXPAND"))),A.length>0&&i.createElement("div",{style:{display:"flex",alignItems:"center",gap:4,marginBottom:6}},i.createElement("span",{style:{fontFamily:ke,fontSize:9,color:"#3A4A5E"}},"From:"),i.createElement("select",{value:Cn.fromAccount||C,onChange:function(Yt){Ce(m.id,"fromAccount",Yt.target.value)},disabled:Fr,style:{background:"transparent",border:"none",fontFamily:ke,fontSize:10,color:"#8B949E",outline:"none",cursor:"pointer"}},A.map(function(Yt){return i.createElement("option",{key:Yt.email,value:Yt.email},Yt.email)}))),i.createElement("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:4,marginBottom:6}},i.createElement("span",{style:{fontFamily:ke,fontSize:9,color:"#3A4A5E"}},"To:"),(Cn.to||"").split(",").filter(function(Yt){return Yt.trim()}).map(function(Yt,kn){return i.createElement("span",{key:kn,style:{display:"inline-flex",alignItems:"center",gap:3,padding:"2px 8px",background:"rgba(212,175,92,0.06)",border:"1px solid rgba(212,175,92,0.15)",borderRadius:12,fontFamily:ke,fontSize:9,color:"#C9D1D9"}},Yt.trim(),!Fr&&i.createElement("button",{onClick:function(){var Br=(Cn.to||"").split(",").map(function(lo){return lo.trim()}).filter(Boolean);Br.splice(kn,1),Ce(m.id,"to",Br.join(", "))},style:{background:"transparent",border:"none",cursor:"pointer",color:"#D44040",fontSize:9,padding:0,marginLeft:2}},"✕"))}),!Fr&&i.createElement("button",{onClick:function(){$("to"),Fe(m.id),Xe("")},style:{padding:"2px 8px",border:"1px dashed rgba(212,175,92,0.2)",borderRadius:12,cursor:"pointer",fontFamily:ke,fontSize:9,color:Ct.orange,background:"transparent"}},"+")),i.createElement("div",{style:{display:"flex",alignItems:"center",gap:4,marginBottom:8}},i.createElement("span",{style:{fontFamily:ke,fontSize:9,color:"#3A4A5E"}},"Subject:"),i.createElement(En,{value:Cn.subject,placeholder:"Subject…",disabled:Fr,onChange:function(Yt){Ce(m.id,"subject",Yt)},style:{fontWeight:600},fontSize:14})),i.createElement("div",{style:hn?{flex:1,display:"flex",flexDirection:"column"}:{}},i.createElement(En,{value:Cn.body,placeholder:"Email body…",multiline:!0,disabled:Fr,onChange:function(Yt){Ce(m.id,"body",Yt)},fontSize:14,expandedRows:hn?30:8,style:Object.assign({lineHeight:1.65},hn?{flex:1,minHeight:400}:{minHeight:80}),editStyle:hn?{flex:1,minHeight:400}:void 0})),i.createElement("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginTop:10,paddingTop:8,borderTop:"1px solid #151D2B",alignItems:"center"}},(Cn.attachments||[]).map(function(Yt){return i.createElement("span",{key:Yt.id,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"4px 10px",background:"rgba(63,185,80,0.06)",border:"1px solid rgba(63,185,80,0.2)",borderRadius:4,fontFamily:ke,fontSize:9,color:"#3FB950"}},"📎 "+Yt.name,i.createElement("span",{style:{fontSize:7,color:"#3A4A5E"}},Yt.source==="upload"?"upload":"vault"),!Fr&&i.createElement("button",{onClick:function(){ku(m.id,Yt.id)},style:{background:"transparent",border:"none",cursor:"pointer",color:"#D44040",fontSize:9,padding:0,marginLeft:2}},"✕"))}),!Fr&&i.createElement("button",{onClick:function(){ul(m.id)},style:{display:"inline-flex",alignItems:"center",gap:4,padding:"4px 10px",border:"1px dashed rgba(63,185,80,0.25)",borderRadius:4,cursor:"pointer",fontFamily:ke,fontSize:9,color:"#3FB950",background:"transparent",transition:"background .12s"},onMouseEnter:function(Yt){Yt.currentTarget.style.background="rgba(63,185,80,0.06)"},onMouseLeave:function(Yt){Yt.currentTarget.style.background="transparent"}},"📎 Add attachment"),!Fr&&(Cn.attachments||[]).length===0&&i.createElement("span",{style:{fontFamily:ke,fontSize:8,color:"#3A4A5E",marginLeft:4}},"Vault or upload")))))}return null}),v&&i.createElement("div",{style:{display:"flex",gap:14,padding:"18px 0"}},i.createElement("div",{style:Object.assign({},yn,{animation:"xpulse 1.5s infinite"})},"X"),i.createElement("div",{style:{fontFamily:ke,fontSize:11,color:Ct.orange,animation:"xpulse 1.5s infinite",paddingTop:8}},"…"))))),i.createElement("input",{ref:fe,type:"file",multiple:!0,accept:".pdf,.doc,.docx,.xls,.xlsx,.csv,.txt,.png,.jpg,.jpeg,.webp",style:{display:"none"},onChange:Ni}),Ie&&i.createElement(i.Fragment,null,i.createElement("div",{onClick:function(){Q(!1)},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.6)",zIndex:598}}),i.createElement("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%,-50%)",zIndex:599,width:360,background:"#0C1018",border:"1px solid #2A3548",borderRadius:10,overflow:"hidden",boxShadow:"0 20px 60px rgba(0,0,0,.8)"}},i.createElement("div",{style:{padding:"14px 18px",borderBottom:"1px solid #1A1F2B",display:"flex",justifyContent:"space-between",alignItems:"center"}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:8}},i.createElement("span",{style:{fontSize:16}},"📎"),i.createElement("span",{style:{fontFamily:ke,fontSize:11,fontWeight:700,color:Ct.orange,letterSpacing:".1em"}},"ATTACH FILE")),i.createElement("button",{onClick:function(){Q(!1)},style:{background:"transparent",border:"none",cursor:"pointer",fontFamily:ke,fontSize:12,color:"#5A7090"}},"✕")),i.createElement("div",{style:{padding:"14px 18px",display:"flex",flexDirection:"column",gap:10}},i.createElement("button",{onClick:function(){Q(!1),mi(jt)},style:{display:"flex",alignItems:"center",gap:12,padding:"14px 16px",background:"rgba(63,185,80,0.04)",border:"1px solid rgba(63,185,80,0.15)",borderRadius:8,cursor:"pointer",textAlign:"left",transition:"all .15s"},onMouseEnter:function(m){m.currentTarget.style.background="rgba(63,185,80,0.12)",m.currentTarget.style.borderColor="rgba(63,185,80,0.35)"},onMouseLeave:function(m){m.currentTarget.style.background="rgba(63,185,80,0.04)",m.currentTarget.style.borderColor="rgba(63,185,80,0.15)"}},i.createElement("div",{style:{width:36,height:36,borderRadius:8,background:"rgba(63,185,80,0.08)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:18,flexShrink:0}},"📁"),i.createElement("div",null,i.createElement("div",{style:{fontFamily:ke,fontSize:11,fontWeight:700,color:"#3FB950"}},"FROM VAULT"),i.createElement("div",{style:{fontFamily:ke,fontSize:9,color:"#5A7090",marginTop:3}},"Decks, contracts, NDAs, proposals — secure docs already in Xyron"))),i.createElement("button",{onClick:function(){Q(!1),fe.current&&fe.current.click()},style:{display:"flex",alignItems:"center",gap:12,padding:"14px 16px",background:"rgba(212,175,92,0.04)",border:"1px solid rgba(212,175,92,0.15)",borderRadius:8,cursor:"pointer",textAlign:"left",transition:"all .15s"},onMouseEnter:function(m){m.currentTarget.style.background="rgba(212,175,92,0.12)",m.currentTarget.style.borderColor="rgba(212,175,92,0.35)"},onMouseLeave:function(m){m.currentTarget.style.background="rgba(212,175,92,0.04)",m.currentTarget.style.borderColor="rgba(212,175,92,0.15)"}},i.createElement("div",{style:{width:36,height:36,borderRadius:8,background:"rgba(212,175,92,0.08)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:18,flexShrink:0}},"📤"),i.createElement("div",null,i.createElement("div",{style:{fontFamily:ke,fontSize:11,fontWeight:700,color:Ct.orange}},"UPLOAD FROM COMPUTER"),i.createElement("div",{style:{fontFamily:ke,fontSize:9,color:"#5A7090",marginTop:3}},"PDF, DOCX, XLSX, CSV, images — files auto-saved to Vault")))),i.createElement("div",{style:{padding:"8px 18px 14px",fontFamily:ke,fontSize:8,color:"#3A4A5E",textAlign:"center"}},"Attachments are secured in Xyron Vault"))),Be&&i.createElement(i.Fragment,null,i.createElement("div",{onClick:function(){Fe(!1)},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.6)",zIndex:600}}),i.createElement("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%,-50%)",zIndex:601,width:400,maxHeight:480,background:"#0C1018",border:"1px solid #2A3548",borderRadius:10,overflow:"hidden",boxShadow:"0 20px 60px rgba(0,0,0,.8)",display:"flex",flexDirection:"column"}},i.createElement("div",{style:{padding:"12px 16px",borderBottom:"1px solid #1A1F2B",display:"flex",justifyContent:"space-between"}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:6}},i.createElement("span",{style:{fontFamily:ke,fontSize:10,fontWeight:700,color:Ct.orange,letterSpacing:".1em"}},"RECIPIENT"),["to","cc","bcc"].map(function(m){return i.createElement("button",{key:m,onClick:function(){$(m)},style:{padding:"2px 8px",background:Rt===m?"rgba(212,175,92,0.12)":"transparent",border:"1px solid "+(Rt===m?"rgba(212,175,92,0.25)":"#2A3548"),borderRadius:3,cursor:"pointer",fontFamily:ke,fontSize:8,color:Rt===m?Ct.orange:"#5A7090"}},m.toUpperCase())})),i.createElement("button",{onClick:function(){Fe(!1)},style:{background:"transparent",border:"none",cursor:"pointer",fontFamily:ke,fontSize:10,
118color:"#5A7090"}},"✕")),i.createElement("div",{style:{padding:"8px 16px"}},i.createElement("input",{value:St,onChange:function(m){Xe(m.target.value)},placeholder:"Search or type email…",autoFocus:!0,onKeyDown:function(m){m.key==="Enter"&&St.trim()&&(ls(St.trim()),Xe(""))},style:{width:"100%",background:"#0C1018",border:"1px solid #2A3548",borderRadius:4,padding:"8px 12px",fontSize:12,color:"#E6EDF3",outline:"none",boxSizing:"border-box"}}),i.createElement("div",{style:{fontFamily:ke,fontSize:7,color:"#3A4A5E",marginTop:4}},"Paste comma-separated or search by name")),i.createElement("div",{style:{flex:1,overflowY:"auto",padding:"0 16px 12px"}},(O||[]).filter(function(m){if(!St)return!1;var L=St.toLowerCase();return(m.name||"").toLowerCase().indexOf(L)!==-1||(m.email||"").toLowerCase().indexOf(L)!==-1}).slice(0,8).map(function(m){return i.createElement("div",{key:m.contact_id||m.email,onClick:function(){ls(m.email),Xe("")},style:{display:"flex",alignItems:"center",gap:10,padding:"8px",borderBottom:"1px solid #1A1F2B",cursor:"pointer",borderRadius:3,transition:"background .12s"},onMouseEnter:function(L){L.currentTarget.style.background="rgba(212,175,92,0.03)"},onMouseLeave:function(L){L.currentTarget.style.background="transparent"}},i.createElement("div",{style:{width:26,height:26,borderRadius:"50%",background:"linear-gradient(135deg,#D4AF5C,#9E7E35)",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:ke,fontSize:9,fontWeight:700,color:"#000"}},(m.name||m.email||"?")[0].toUpperCase()),i.createElement("div",{style:{flex:1}},i.createElement("div",{style:{fontSize:12,fontWeight:600,color:"#E6EDF3"}},m.name||m.email),i.createElement("div",{style:{fontFamily:ke,fontSize:8,color:"#5A7090"}},m.email)))}),St&&St.indexOf("@")!==-1&&i.createElement("div",{onClick:function(){ls(St.trim()),Xe("")},style:{padding:"10px",cursor:"pointer",textAlign:"center",fontFamily:ke,fontSize:10,color:Ct.orange,border:"1px dashed rgba(212,175,92,0.2)",borderRadius:4,margin:"4px 0"}},'Add "'+St.trim()+'"'),!St&&(O||[]).slice(0,6).map(function(m){return i.createElement("div",{key:"r"+m.email,onClick:function(){ls(m.email),Xe("")},style:{display:"flex",alignItems:"center",gap:10,padding:"6px 8px",cursor:"pointer",borderRadius:3},onMouseEnter:function(L){L.currentTarget.style.background="rgba(212,175,92,0.03)"},onMouseLeave:function(L){L.currentTarget.style.background="transparent"}},i.createElement("div",{style:{width:22,height:22,borderRadius:"50%",background:"linear-gradient(135deg,#D4AF5C,#9E7E35)",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:ke,fontSize:8,fontWeight:700,color:"#000"}},(m.name||m.email||"?")[0].toUpperCase()),i.createElement("span",{style:{fontSize:11,color:"#C9D1D9"}},m.name||m.email))})))),_e&&i.createElement(i.Fragment,null,i.createElement("div",{onClick:function(){ve(!1)},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.7)",zIndex:600}}),i.createElement("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%,-50%)",zIndex:601,width:460,maxHeight:500,background:"#0C1018",border:"1px solid #2A3548",borderRadius:10,overflow:"hidden",boxShadow:"0 20px 60px rgba(0,0,0,.8)",display:"flex",flexDirection:"column"}},i.createElement("div",{style:{padding:"12px 16px",borderBottom:"1px solid #1A1F2B",display:"flex",justifyContent:"space-between"}},i.createElement("span",{style:{fontFamily:ke,fontSize:10,fontWeight:700,color:"#3FB950",letterSpacing:".1em"}},"VAULT"),i.createElement("button",{onClick:function(){ve(!1)},style:{background:"transparent",border:"none",cursor:"pointer",fontFamily:ke,fontSize:10,color:"#5A7090"}},"✕")),i.createElement("div",{style:{padding:"8px 16px"}},i.createElement("input",{value:re,onChange:function(m){we(m.target.value)},placeholder:"Search…",style:{width:"100%",background:"#0C1018",border:"1px solid #2A3548",borderRadius:4,padding:"8px 12px",fontSize:11,color:"#E6EDF3",outline:"none",boxSizing:"border-box"}})),i.createElement("div",{style:{flex:1,overflowY:"auto",padding:"0 16px 12px"}},$e.filter(function(m){return!re||(m.name||"").toLowerCase().indexOf(re.toLowerCase())!==-1}).map(function(m){return i.createElement("div",{key:m.doc_id,onClick:function(){kd(m)},style:{display:"flex",alignItems:"center",gap:10,padding:"8px",borderBottom:"1px solid #1A1F2B",cursor:"pointer",borderRadius:3,transition:"background .12s"},onMouseEnter:function(L){L.currentTarget.style.background="rgba(63,185,80,0.04)"},onMouseLeave:function(L){L.currentTarget.style.background="transparent"}},i.createElement("div",{style:{flex:1,minWidth:0}},i.createElement("div",{style:{fontSize:12,fontWeight:600,color:"#E6EDF3",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},m.name),i.createElement("div",{style:{fontFamily:ke,fontSize:8,color:"#3A4A5E"}},(m.type||m.doc_type||"document").toString().toLowerCase())),i.createElement("span",{style:{fontFamily:ke,fontSize:8,color:"#3FB950"}},"ATTACH"))}),$e.length===0&&i.createElement("div",{style:{padding:24,textAlign:"center",fontFamily:ke,fontSize:9,color:"#3A4A5E"}},"Loading…")))),qi&&i.createElement("div",{style:{position:"fixed",bottom:24,left:"50%",transform:"translateX(-50%)",zIndex:700,display:"flex",alignItems:"center",gap:12,padding:"10px 20px",background:"#1A2332",border:"1px solid #2A3548",borderRadius:8,boxShadow:"0 8px 30px rgba(0,0,0,.6)",animation:"xfadein 0.2s ease forwards"}},i.createElement("span",{style:{fontFamily:ke,fontSize:11,color:"#E6EDF3"}},qi),tr&&i.createElement("button",{onClick:Ca,style:{padding:"4px 12px",background:"rgba(212,175,92,0.12)",border:"1px solid rgba(212,175,92,0.3)",borderRadius:4,cursor:"pointer",fontFamily:ke,fontSize:9,fontWeight:700,color:Ct.orange}},"UNDO"),i.createElement("button",{onClick:function(){go(null),Fo(null)},style:{background:"transparent",border:"none",cursor:"pointer",fontFamily:ke,fontSize:10,
118color:"#5A7090"}},"✕")))}var e=$C();function Mj(t){const n=t&&t.initialMode||"paste",[r,o]=(0,i.useState)(n),a=Vn.hasApiKey(),l=t&&t.onPositionsImported,s=typeof l=="function";return(0,i.useEffect)(function(){o(n)},[n]),(0,e.jsxs)("div",{style:Ki.root,children:[(0,e.jsx)("h3",{style:Ki.h3,children:"Portfolio Connect"}),(0,e.jsx)("p",{style:Ki.muted,children:a?"API key linked. CSV uploads can sync to Cortex Alpha.":"No API key set. CSV and paste import will load into this portfolio session; add a Cortex Alpha key later for server sync."}),(0,e.jsxs)("div",{style:Ki.tabs,children:[(0,e.jsx)(Nm,{label:"Paste positions",active:r==="paste",onClick:function(){o("paste")}}),(0,e.jsx)(Nm,{label:"Upload CSV",active:r==="csv",onClick:function(){o("csv")}}),(0,e.jsx)(Nm,{label:"Mandate",active:r==="mandate",onClick:function(){o("mandate")}})]}),r==="paste"?(0,e.jsx)(Nj,{hasKey:a,canImportLocal:s,onPositionsImported:l}):null,r==="csv"?(0,e.jsx)(Bj,{hasKey:a,canImportLocal:s,onPositionsImported:l}):null,r==="mandate"?(0,e.jsx)(Pj,{hasKey:a}):null]})}function Nm({label:t,active:n,onClick:r}){return(0,e.jsx)("button",{onClick:r,style:Object.assign({},Ki.tab,n?Ki.tabActive:null),children:t})}function Nj({hasKey:t,canImportLocal:n,onPositionsImported:r}){const[o,a]=(0,i.useState)(""),[l,s]=(0,i.useState)(!1),[c,d]=(0,i.useState)(null),[p,g]=(0,i.useState)(null);async function f(){s(!0),g(null),d(null);try{const v=JSON.parse(o);if(!Array.isArray(v))throw new Error("JSON must be an array of position objects");if(t){const y=await Vn.ingestPositions(v);if(y&&y.ok===!1){var h=y.error&&y.error.detail&&y.error.detail.parse_errors;if(!h&&y.parse_errors&&(h=y.parse_errors),!h&&y.error&&y.error.parse_errors&&(h=y.error.parse_errors),Array.isArray(h)&&h.length){var x=h.map(function(k){return k&&k.reason||"invalid_row"}).join(", ");throw new Error("Could not save positions: "+x.replace(/missing_account_id/g,"Account ID is required (use account or account_id)"))}throw new Error(y.error&&(y.error.message||JSON.stringify(y.error))||"Save failed")}d(y)}else if(n){const y=Fy(["asset_class,symbol,side,avg_entry_price,market_price,quantity,risk",...v.map(function(k){var A=vA(k);return[A.asset_class,A.symbol,A.side,A.avg_entry_price,A.market_price,A.quantity,A.risk].join(",")})].join(`
119`));r(y),d({imported:y.length,mode:"local-session"})}else throw new Error("Set a Cortex Alpha API key to save pasted positions.")}catch(v){g(v.message||String(v))}finally{s(!1)}}return(0,e.jsxs)("div",{children:[(0,e.jsxs)("p",{style:Ki.muted,children:["Paste a JSON array of positions. Supported fields include ",(0,e.jsx)("code",{children:"account"}),"/",(0,e.jsx)("code",{children:"account_id"})," (defaults to ",(0,e.jsx)("code",{children:"main"}),"), ",(0,e.jsx)("code",{children:"symbol"}),", ",(0,e.jsx)("code",{children:"qty"}),"/",(0,e.jsx)("code",{children:"quantity"}),", ",(0,e.jsx)("code",{children:"entry"}),", ",(0,e.jsx)("code",{children:"mark"}),", ",(0,e.jsx)("code",{children:"class"}),". Extra fields are preserved as ",(0,e.jsx)("code",{children:"extra"}),"."]}),(0,e.jsx)("textarea",{value:o,onChange:function(h){a(h.target.value)},placeholder:'[ { "account": "main", "symbol": "AAPL", "class": "Equity", "qty": 10, "entry": 123, "mark": 150 } ]',style:Ki.textarea,rows:10}),(0,e.jsx)("button",{disabled:l||!o.trim(),onClick:f,style:Ki.btn,children:l?"Submitting…":t?"Save positions":"Import locally"}),p?(0,e.jsxs)("pre",{style:Ki.err,children:["Error: ",p]}):null,c?(0,e.jsx)("pre",{style:Ki.code,children:JSON.stringify(c,null,2)}):null]})}function Bj({hasKey:t,canImportLocal:n,onPositionsImported:r}){const[o,a]=(0,i.useState)(null),[l,s]=(0,i.useState)("auto"),[c,d]=(0,i.useState)(!1),[p,g]=(0,i.useState)(null),[f,h]=(0,i.useState)(null);async function x(){if(o){d(!0),h(null),g(null);try{if(t){const v=await Vn.uploadCsv(o,l==="auto"?null:l);if(!v||v.ok===!1){const y=v&&(v.error||v.detail||v.message);let k;throw typeof y=="string"&&y?k=y:y&&typeof y=="object"?k=y.detail||y.message||JSON.stringify(y):v&&v.parse_errors&&v.parse_errors[0]?k=v.parse_errors[0].reason||"parse error":k="Durable book upload failed",new Error(k)}g(v)}else if(n){const v=Fy(await o.text());r(v),g({imported:v.length,mode:"local-session"})}else throw new Error("Set a Cortex Alpha API key to upload CSV.")}catch(v){h(v.message||String(v))}finally{d(!1)}}}return(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{style:Ki.muted,children:"Upload a CSV statement. We auto-detect positions vs transactions; force one with the dropdown if the auto-detect picks wrong."}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center",marginBottom:12},children:[(0,e.jsx)("input",{type:"file",accept:".csv,text/csv",onChange:function(v){a(v.target.files[0]||null)}}
119),t?(0,e.jsxs)("select",{value:l,onChange:function(v){s(v.target.value)},style:Ki.select,children:[(0,e.jsx)("option",{value:"auto",children:"Auto-detect"}),(0,e.jsx)("option",{value:"positions",children:"Positions"}),(0,e.jsx)("option",{value:"transactions",children:"Transactions"})]}):null,(0,e.jsx)("button",{disabled:c||!o,onClick:x,style:Ki.btn,children:c?"Uploading…":t?"Upload":"Import locally"})]}),f?(0,e.jsxs)("pre",{style:Ki.err,children:["Error: ",f]}):null,p?(0,e.jsx)("pre",{style:Ki.code,children:JSON.stringify(p,null,2)}):null]})}function Pj({hasKey:t}){const[n,r]=(0,i.useState)(""),[o,a]=(0,i.useState)(!1),[l,s]=(0,i.useState)(null),[c,d]=(0,i.useState)(null);async function p(){if(!t){d("Set a Cortex Alpha API key to save mandate rules.");return}a(!0),d(null),s(null);try{const g=JSON.parse(n);if(typeof g!="object"||!g)throw new Error("Mandate must be a JSON object");s(await Vn.upsertMandate(g))}catch(g){d(g.message||String(g))}finally{a(!1)}}return(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{style:Ki.muted,children:"Set the investment mandate (caps, exclusions, target volatility, max drawdown). The escalation tool reads this when answering portfolio-level questions."}),(0,e.jsx)("textarea",{value:n,onChange:function(g){r(g.target.value)},placeholder:'{ "mandate_id": "primary", "label": "Conservative", "target_volatility": 0.12, "max_drawdown": 0.20, "max_leverage": 1.5, "sector_caps": {"Technology": 0.30}, "excluded_symbols": ["XOM"] }',style:Ki.textarea,rows:10}),(0,e.jsx)("button",{disabled:o||!n.trim(),onClick:p,style:Ki.btn,children:o?"Saving…":"Save mandate"}),c?(0,e.jsxs)("pre",{style:Ki.err,children:["Error: ",c]}):null,l?(0,e.jsx)("pre",{style:Ki.code,children:JSON.stringify(l,null,2)}):null]})}var Ki={root:{padding:16,fontFamily:"monospace",color:"#ddd",background:"#0a0a0a"},empty:{padding:24,color:"#aaa",textAlign:"center"},h3:{margin:"0 0 8px",color:"#fff"},muted:{color:"#888",fontSize:13,marginBottom:12},tabs:{display:"flex",gap:8,marginBottom:12},tab:{background:"#161616",color:"#bbb",border:"1px solid #2a2a2a",padding:"6px 12px",cursor:"pointer",borderRadius:4},tabActive:{background:"#1f1f1f",color:"#fff",borderColor:"#3a3a3a"},textarea:{width:"100%",background:"#0e0e0e",color:"#ddd",border:"1px solid #2a2a2a",padding:10,fontFamily:"monospace",fontSize:13,borderRadius:4,marginBottom:12},btn:{background:"#234",color:"#fff",border:"1px solid #345",padding:"8px 16px",cursor:"pointer",borderRadius:4},select:{background:"#0e0e0e",color:"#ddd",border:"1px solid #2a2a2a",padding:6,borderRadius:4},code:{background:"#0e0e0e",border:"1px solid #2a2a2a",padding:10,fontSize:12,color:"#9af",borderRadius:4,overflow:"auto"},err:{background:"#2a0e0e",border:"1px solid #4a1f1f",padding:10,fontSize:12,color:"#fbb",borderRadius:4}};function Uj(){const[t,n]=(0,i.useState)([]),[r,o]=(0,i.useState)(""),[a,l]=(0,i.useState)(!1),[s,c]=(0,i.useState)(null),d=Vn.hasApiKey(),[p,g]=(0,i.useState)(null);async function f(){if(d){l(!0),c(null);try{n((await Vn.listPositions({})).positions||[])}catch(v){c(v.message||String(v))}finally{l(!1)}}}if((0,i.useEffect)(function(){f()},[]),!d)return(0,e.jsx)("div",{style:xr.empty,children:"Set a Cortex Alpha API key to load positions."});const h=(r||"").trim().toUpperCase(),x=h?t.filter(function(v){return(v.symbol||"").toUpperCase().indexOf(h)!==-1||(v.account_id||"").toUpperCase().indexOf(h)!==-1}):t;return(0,e.jsxs)("div",{style:xr.root,children:[(0,e.jsxs)("div",{style:xr.header,children:[(0,e.jsxs)("h3",{style:xr.h3,children:["Positions ",(0,e.jsxs)("span",{style:xr.count,children:["(",t.length,")"]})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,e.jsx)("input",{placeholder:"filter symbol or account…",value:r,onChange:function(v){o(v.target.value)},style:xr.input}),(0,e.jsx)("button",{onClick:f,disabled:a,style:xr.btn,children:a?"…":"Refresh"})]})]}),s?(0,e.jsxs)("pre",{style:xr.err,children:["Error: ",s]}):null,(0,e.jsx)("div",{style:{overflowX:"auto"},children:(0,e.jsxs)("table",{style:xr.table,children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{style:xr.th,children:"Account"}),(0,e.jsx)("th",{style:xr.th,children:"Symbol"}),(0,e.jsx)("th",{style:xr.th,children:"Class"}),(0,e.jsx)("th",{style:xr.th,children:"Qty"}),(0,e.jsx)("th",{style:xr.th,children:"Entry"}),(0,e.jsx)("th",{style:xr.th,children:"Mark"}),(0,e.jsx)("th",{style:xr.th,children:"Mkt Val"}),(0,e.jsx)("th",{style:xr.th,children:"Unrlz PnL"}),(0,e.jsx)("th",{style:xr.th,children:"Ccy"}),(0,e.jsx)("th",{style:xr.th,children:"As of"})]})}),(0,e.jsx)("tbody",{children:x.length===0?(0,e.jsx)("tr",{children:(0,e.jsx)("td",{style:xr.td,colSpan:10,children:(0,e.jsx)("em",{style:xr.muted,children:"No positions."})})}):x.map(function(v,y){return(0,e.jsxs)("tr",{onClick:function(){g(My(v,y))},style:{cursor:"pointer"},title:"Click for AI forecast",children:[(0,e.jsx)("td",{style:xr.td,children:v.account_id}),(0,e.jsx)("td",{style:xr.td,children:v.symbol}),(0,e.jsx)("td",{style:xr.td,children:v.asset_class}),(0,e.jsx)("td",{style:xr.tdNum,children:Qf(v.quantity)}),(0,e.jsx)("td",{style:xr.tdNum,children:Qf(v.avg_entry_price)}),(0,e.jsx)("td",{style:xr.tdNum,children:Qf(v.market_price)}),(0,e.jsx)("td",{style:xr.tdNum,children:Qf(v.market_value)}),(0,e.jsx)("td",{style:xr.tdNum,children:Qf(v.unrealised_pnl)}),(0,e.jsx)("td",{style:xr.td,children:v.currency}),(0,e.jsx)("td",{style:xr.td,children:(v.as_of||v.last_mark_at||"").slice(0,19)})]},v.account_id+":"+v.symbol+":"+y)})})]})}),p&&(0,e.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(2,4,8,0.97)",overflow:"auto"},children:(0,e.jsx)(BS,{position:p,onClose:function(){g(null)}})})]})}function Qf(t){if(t==null||t===""||isNaN(Number(t)))return"";const n=Number(t);return Math.abs(n)>
119=1e3?n.toLocaleString(void 0,{maximumFractionDigits:2}):n.toFixed(2)}var xr={root:{padding:16,fontFamily:"monospace",color:"#ddd",background:"#0a0a0a"},empty:{padding:24,color:"#aaa",textAlign:"center"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},h3:{margin:0,color:"#fff"},count:{color:"#888",fontSize:13,marginLeft:6},input:{background:"#0e0e0e",color:"#ddd",border:"1px solid #2a2a2a",padding:6,fontFamily:"monospace",fontSize:13,borderRadius:4},btn:{background:"#234",color:"#fff",border:"1px solid #345",padding:"6px 12px",cursor:"pointer",borderRadius:4},table:{borderCollapse:"collapse",width:"100%",fontSize:12},th:{borderBottom:"1px solid #333",textAlign:"left",padding:"6px 10px",color:"#bbb",position:"sticky",top:0,background:"#0a0a0a"},td:{borderBottom:"1px solid #1f1f1f",padding:"4px 10px",color:"#ddd"},tdNum:{borderBottom:"1px solid #1f1f1f",padding:"4px 10px",color:"#ddd",textAlign:"right"},muted:{color:"#888"},err:{background:"#2a0e0e",border:"1px solid #4a1f1f",padding:10,fontSize:12,color:"#fbb",borderRadius:4,marginBottom:12}},Oe={bg:"rgba(4,6,12,0.98)",border:"rgba(212,175,92,0.15)",accent:"#D4AF5C",accentDim:"rgba(212,175,92,0.08)",text:"#C9D1D9",dim:"#5A7090",card:"rgba(8,12,20,0.95)",cardHover:"rgba(16,24,40,0.98)",green:"#3FB950",red:"#C85C5C",blue:"#6B9AC4"},Gl="'Courier New', Courier, monospace",Wj={LOW:Oe.green,Low:Oe.green,MEDIUM:Oe.accent,Medium:Oe.accent,HIGH:Oe.red,High:Oe.red,ELEVATED:Oe.red,Critical:"#D44040"},Bu={equity:"#6B9AC4",index:"#D4AF5C",bond:"#FB923C",fx:"#34D399",commodity:"#FBBF24",crypto:"#E879F9",hedgefund:"#60A5FA",derivative:"#F87171",etf:"#94A3B8"},Bm=["equity","index","bond","fx","commodity","crypto","hedgefund","derivative","etf"],Cv=["LONG","SHORT"],Hj=["POSITIONS","EXPOSURE","SIGNALS","ALERTS"];function r2(t){var n=Number(t);return t!=null&&t!==""&&isFinite(n)&&n!==0}function Av(t){return r2(t)?t:"Unavailable"}function Pm(t){if(t==null||!isFinite(Number(t)))return null;var n=Number(t),r=Math.abs(n);return r>=1e6?"$"+(n/1e6).toFixed(2)+"M":r>=1e3?"$"+(n/1e3).toFixed(r>=1e4?0:1)+"K":"$"+n.toFixed(0)}function C0(t){if(!t||t._pnlUnavailable)return null;var n=t.pnlPct||0,r=(t.risk||"").toLowerCase(),o=t.assetClass,a=t.side;return r==="critical"?{action:"EXIT",color:"#D44040",momentum:-3,conf:95,thesis:"Critical risk threshold breached. Immediate exit or full hedge required. VaR contribution exceeds single-name limit."}:n>12&&r==="high"?{action:"TRIM",color:Oe.accent,momentum:2,conf:82,thesis:"Strong alpha captured at +"+n.toFixed(1)+"% but risk elevated. Take 30-40% off, trail remainder. Concentration risk flagged."}:n>8&&r==="high"?{action:"TRIM",color:Oe.accent,momentum:1,conf:78,thesis:"Profitable with elevated vol. Reduce by 20-25% to lock gains. Re-enter on pullback if thesis intact."}:n>10?{action:"TRIM",color:Oe.accent,momentum:2,conf:75,thesis:"Extended move at +"+n.toFixed(1)+"%. Consider partial profit-take — 2-sigma move from entry. Set trailing stop."}:n<-2&&r==="high"?{action:"REVIEW",color:Oe.red,momentum:-2,conf:70,thesis:"Underwater with high risk. Reassess catalyst timing and thesis. If thesis broken, cut. If intact, tighten stop."}:n<-1&&o==="bond"?{action:"HOLD",color:Oe.dim,momentum:-1,conf:65,thesis:"Duration position under pressure. Carry positive. Hold if rate view unchanged, hedge tail via options."}:n>5&&r==="low"?{action:"ADD",color:Oe.green,momentum:2,conf:80,thesis:"Low risk with strong momentum. Consider adding 15-20% to capture continuation. Thesis validated by price action."}:n>3&&o==="commodity"?{action:"HOLD",color:Oe.green,momentum:1,conf:72,thesis:"Commodity position performing. Supply dynamics supportive. Hold for cycle completion, watch inventory data."}:o==="crypto"&&n>5?{action:"TRIM",color:Oe.accent,momentum:1,conf:68,thesis:"Crypto vol elevated. Lock partial gains. Rebalance to target allocation weight. Watch correlation to risk assets."}:o==="hedgefund"?{action:"HOLD",color:Oe.blue,momentum:0,conf:60,thesis:"Fund allocation within mandate. Next NAV mark due quarterly. Monitor manager letters for strategy drift."}:o==="derivative"&&n>50?{action:"ROLL",color:Oe.blue,momentum:1,conf:74,thesis:"Options position deep ITM. Consider rolling to maintain gamma exposure. Time decay accelerating."}:a==="SHORT"&&n>3?{action:"HOLD",color:Oe.green,momentum:1,conf:70,thesis:"Short performing. Cover target not reached. Maintain with tight buy-stop. Watch for short squeeze catalysts."}:a==="SHORT"&&n<0?{action:"REVIEW",color:Oe.accent,momentum:-1,conf:65,thesis:"Short underwater. Review borrow cost and catalyst timeline. Consider reducing if momentum turning."}:{action:"HOLD",color:Oe.dim,momentum:0,conf:55,thesis:"Position within parameters. No action required. Continue monitoring for catalyst developments."}}function Gj({positions:t,onPositionsChange:n}){var r=(0,i.useState)(function(){return Array.isArray(t)?t.slice():ov()?lA.slice():[]}),o=r[0],a=r[1],l=(0,i.useState)("POSITIONS"),s=l[0],c=l[1],d=(0,i.useState)(null),p=d[0],g=d[1],f=(0,i.useState)(null),h=f[0],x=f[1],v=(0,i.useState)(null),y=v[0],k=v[1],A=(0,i.useState)({}),j=A[0],E=A[1],C=(0,i.useState)(!1),_=C[0],w=C[1],O=(0,i.useState)({instrument:"",assetClass:"equity",side:"LONG",size:"",sizeUnit:"shares",entry:"",px:"",notes:""}),M=O[0],U=O[1],ee=(0,i.useState)("ALL"),N=ee[0],V=ee[1],z=(0,i.useState)("pnl"),oe=z[0],P=z[1],W=(0,i.useState)("desc"),R=W[0],ae=W[1],q=(0,i.useState)(""),ge=q[0],X=q[1],de=(0,i.useState)(0),We=de[0],te=de[1],_e=(0,i.useRef)(null),ve=(0,i.useState)(null),Ne=ve[0],$e=ve[1],Pe=(0,i.useState)(null),ot=Pe[0],re=Pe[1];(0,i.useEffect)(function(){Array.isArray(t)&&a(t.slice())},[t,a]),(0,i.useEffect)(function(){if(!Array.isArray(t)){var T=!1;try{Vn&&Vn.hasApiKey&&Vn.hasApiKey()&&Vn.listPositions({}).then(function(Y){if(!(T||!Y)){var B=KS(Y.positions||[]);B.length&&a(B)}}).catch(function(){})}catch{}return function(){T=!0}}},[t,We,a]),(0,i.useEffect)(function(){function T(){te(function(Y){return Y+1})}return window.addEventListener("xyron:portfolio-updated",T),window.addEventListener("xyron:cortex-alpha-key-changed",T),function(){window.removeEventListener("xyron:portfolio-updated",T),window.removeEventListener("xyron:cortex-alpha-key-changed",T)}},[te]);var we=(o||[]).some(function(T){return T&&(T.source==="macro"||T.source==="forex")}),b=su()||ov()&&we,He=av[0],tt=(0,i.useMemo)(function(){return kj(o)},[o]),Ae=tt.positions,Be=(0,i.useMemo)(function(){return Ae.reduce(function(T,Y){return T+(Y._pnlUnavailable?0:Y.pnl||0)},0)},[Ae]),Fe=(0,i.useMemo)(function(){return zp(Ae)}
119,[Ae]),ft=(0,i.useMemo)(function(){return US(Ae.filter(function(T){return!T._varUnavailable&&Number(T.var1d)}))},[Ae]),St=ft&&ft.gross>0,Xe=(0,i.useMemo)(function(){return Ae.filter(function(T){return T.side==="LONG"}).length},[Ae]),It=(0,i.useMemo)(function(){return Ae.filter(function(T){return T.side==="SHORT"}).length},[Ae]),Rt=(0,i.useMemo)(function(){return Ae.filter(function(T){return!T._pnlUnavailable&&T.pnl>0}).length},[Ae]),$=(0,i.useMemo)(function(){var T=N==="ALL"?Ae:Ae.filter(function(B){return B.assetClass===N});if(ge.trim()){var Y=ge.toLowerCase();T=T.filter(function(B){return String(B.instrument||"").toLowerCase().indexOf(Y)!==-1||String(B.assetClass||"").toLowerCase().indexOf(Y)!==-1||(B.notes||"").toLowerCase().indexOf(Y)!==-1})}return T.slice().sort(function(B,ie){var ue=oe==="pnl"?Math.abs(B.pnl||0):oe==="var1d"?B.var1d||0:Math.abs(B.pnlPct||0),ne=oe==="pnl"?Math.abs(ie.pnl||0):oe==="var1d"?ie.var1d||0:Math.abs(ie.pnlPct||0);return R==="desc"?ne-ue:ue-ne})},[Ae,N,oe,R,ge]),Ue=(0,i.useMemo)(function(){var T={};return Ae.forEach(function(Y){T[Y.assetClass]=(T[Y.assetClass]||0)+1}),T},[Ae]),Ie=(0,i.useMemo)(function(){var T={},Y=0;return Ae.forEach(function(B){var ie=Math.abs(parseFloat(B.size)||0)*(parseFloat(String(B.px).replace("%",""))||1);T[B.assetClass]||(T[B.assetClass]={long:0,short:0,total:0,count:0,pnl:0,var:0}),T[B.assetClass].total+=ie,T[B.assetClass].count+=1,T[B.assetClass].pnl+=B._pnlUnavailable?0:B.pnl||0,T[B.assetClass].var+=B.var1d||0,B.side==="LONG"?T[B.assetClass].long+=ie:T[B.assetClass].short+=ie,Y+=ie}),Object.keys(T).map(function(B){return{cls:B,pct:Y>0?T[B].total/Y*100:0,long:T[B].long,short:T[B].short,count:T[B].count,pnl:T[B].pnl,var:T[B].var}}).sort(function(B,ie){return ie.pct-B.pct})},[Ae]),Q=(0,i.useMemo)(function(){return Cj(Ae,Fe)},[Ae,Fe]),rt=(0,i.useCallback)(function(T){a(function(Y){var B=typeof T=="function"?T(Y):T;return typeof n=="function"&&n(Array.isArray(B)?B.slice():B),B})},[n,a]),jt=(0,i.useCallback)(function(T,Y){Y.stopPropagation(),k(T.id),E({instrument:T.instrument,assetClass:T.assetClass,side:T.side,size:T.size,sizeUnit:T.sizeUnit,entry:T.entry,px:T.px,notes:T.notes||""})},[]),tn=(0,i.useCallback)(function(T,Y){Y.stopPropagation(),rt(function(B){return B.map(function(ie){if(ie.id!==T)return ie;var ue=Object.assign({},ie,j,{_sessionEdited:Date.now()}),ne=Number(j.entry),Me=Number(j.px),nt=Number(j.size);return isFinite(ne)&&(ue.entry=ne),j.px!==""&&j.px!=null&&isFinite(Me)&&(ue.px=Me),j.size!==""&&isFinite(nt)&&(ue.size=j.size),ue})}),k(null)},[j,rt]),pt=(0,i.useCallback)(function(T,Y){Y.stopPropagation();for(var B=null,ie=0;ie<o.length;ie++)if(o[ie]&&o[ie].id===T){B=o[ie];break}re({id:T,sym:B&&(B.instrument||B.symbol)||"this position",durable:!!(Vn&&Vn.hasApiKey&&Vn.hasApiKey()&&Vn.deletePositions)})},[o]),gt=(0,i.useCallback)(function(){re(null)},[]),qt=(0,i.useCallback)(function(){if(ot){var T=ot.id,Y=ot.durable;re(null);var B=null;if(rt(function(ue){var ne=ue.filter(function(Me){return Me.id===T?(B=Me,!1):!0});return Qh(ne),ne}),B&&Y){var ie=B.instrument||B.symbol;ie&&Vn.deletePositions([ie],B.accountId||void 0).catch(function(){})}}},[ot,rt]),Pt=(0,i.useCallback)(function(){if(M.instrument.trim()){var T=M.instrument.trim().toUpperCase(),Y=Number(M.entry),B=Number(M.px),ie=Object.assign({},M,{id:Date.now(),instrument:T,symbol:T,risk:"Medium",var1d:0,source:"manual",_sessionEdited:Date.now(),entry:isFinite(Y)?Y:M.entry,px:M.px!==""&&isFinite(B)?B:isFinite(Y)?Y:null}),ue=$S(ie);ue&&ue.available?(ie.pnl=ue.pnl,ie.pnlPct=ue.pnlPct):(ie.pnl=0,ie.pnlPct=0),rt(function(ne){return ne.concat([ie])}),U({instrument:"",assetClass:"equity",side:"LONG",size:"",sizeUnit:"shares",entry:"",px:"",notes:""}),w(!1)}},[M,rt]),Kt=(0,i.useState)(null),xe=Kt[0],fe=Kt[1],Ye=(0,i.useCallback)(function(T,Y){fe({text:T,ok:Y}),setTimeout(function(){fe(null)},6e3)},[fe]),Qe=(0,i.useCallback)(function(T){var Y=T.target.files&&T.target.files[0];if(Y){if(T.target.value="",Vn&&Vn.hasApiKey&&Vn.hasApiKey()){Ye("Uploading to your durable book…",!0),Vn.uploadCsv(Y,"positions").then(function(ie){if(ie&&ie.ok===!1){var ue=ie.error&&(ie.error.detail||ie.error.message)||ie.detail||ie.message||"durable book rejected the file";Ye("✗ Upload failed — "+(typeof ue=="string"?ue:JSON.stringify(ue)),!1);return}var ne=(ie&&ie.result&&ie.result.n_upserted)!=null?ie.result.n_upserted:ie&&ie.parsed||0,Me=ie&&ie.parse_errors&&ie.parse_errors.length||0;ne>0?Ye("✓ "+ne+" positions saved to your durable book"+(Me?" ("+Me+" rows skipped)":""),!0):Ye("✗ No positions recognized — expected columns like symbol, quantity, avg_entry_price, market_price",!1)}).catch(function(ie){Ye("✗ Upload failed — "+(ie&&ie.message||"backend unreachable"),!1)});return}var B=new FileReader;B.onload=function(ie){try{var ue=Fy(ie.target.result);ue.length>0?(rt(function(ne){return ne.concat(ue)}),Ye("✓ "+ue.length+" positions imported and saved in this browser",!0)):Ye("✗ No positions recognized — expected columns like instrument/symbol, side, size, entry, px",!1)}catch(ne){Ye("✗ "+(ne&&ne.message||"CSV parse failed"),!1)}},B.readAsText(Y)}},[rt,Ye]),ut=(0,i.useCallback)(function(T){oe===T?ae(function(Y){return Y==="desc"?"asc":"desc"}):(P(T),ae("desc"))},[oe]),wt={background:"rgba(212,175,92,0.04)",border:"1px solid rgba(212,175,92,0.12)",borderRadius:3,padding:"4px 7px",fontSize:11,color:Oe.text,fontFamily:Gl,outline:"none",width:"100%"},H=Object.assign({},wt,{cursor:"pointer"}),Z={background:Oe.accentDim,border:"1px solid rgba(212,175,92,0.25)",borderRadius:3,padding:"4px 10px",fontSize:10,
119color:Oe.accent,fontFamily:Gl,cursor:"pointer",flexShrink:0};return o&&o.length>0?(0,e.jsxs)("div",{style:{position:"relative",background:Oe.bg,border:"1px solid "+Oe.border,borderRadius:"6px",overflow:"hidden",fontFamily:Gl,display:"flex",flexDirection:"column",maxHeight:"100%",height:"100%"},children:[(0,e.jsxs)("div",{style:{padding:"7px 12px",borderBottom:"1px solid rgba(212,175,92,0.1)",display:"flex",alignItems:"center",justifyContent:"space-between",background:"rgba(212,175,92,0.04)",flexShrink:0},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,e.jsx)("div",{style:{width:6,height:6,borderRadius:"50%",background:Oe.accent,boxShadow:"0 0 5px "+Oe.accent+"66"}}),(0,e.jsx)("span",{style:{fontSize:11,color:Oe.accent,fontWeight:700,letterSpacing:"0.1em"},children:"PORTFOLIO INTELLIGENCE"})]}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[b&&(0,e.jsx)("span",{style:{fontSize:9,color:"#F59E0B",fontWeight:800,letterSpacing:"0.10em"},children:"SIMULATED"}),b&&(0,e.jsx)("span",{style:{fontSize:11,color:Oe.text,fontWeight:800},children:He?He.value:""}),b&&He&&He.delta&&(0,e.jsx)("span",{style:{fontSize:10,color:He.up?Oe.green:Oe.red,fontWeight:700},children:He.delta}),(0,e.jsxs)("span",{style:{fontSize:10,color:Be>=0?Oe.green:Oe.red,fontWeight:700},children:["P&L ",Be>=0?"+":"",(Be/1e3).toFixed(1),"K"]}),(0,e.jsxs)("span",{style:{fontSize:9,color:Oe.dim},children:[Ae.length," POS"]}),(0,e.jsxs)("span",{style:{fontSize:9,color:Oe.green},children:[Rt,"W"]}),(0,e.jsxs)("span",{style:{fontSize:9,color:Oe.red},children:[Ae.length-Rt,"L"]})]})]}),(0,e.jsxs)("div",{style:{padding:"4px 10px",borderBottom:"1px solid rgba(212,175,92,0.06)",flexShrink:0,display:"flex",gap:4,alignItems:"center"},children:[Hj.map(function(T){var Y=s===T,B=T==="ALERTS"?Q.length:null;return(0,e.jsxs)("button",{onClick:function(){c(T)},style:{background:Y?"rgba(212,175,92,0.15)":"transparent",border:"1px solid "+(Y?"rgba(212,175,92,0.4)":"rgba(90,112,144,0.25)"),borderRadius:3,padding:"3px 9px",fontSize:10,color:Y?Oe.accent:Oe.dim,fontFamily:Gl,cursor:"pointer",letterSpacing:"0.06em",transition:"all 0.15s",display:"flex",alignItems:"center",gap:4},children:[T,B!=null&&B>0&&(0,e.jsx)("span",{style:{fontSize:9,background:"rgba(200,92,92,0.2)",color:Oe.red,borderRadius:2,padding:"0 4px",fontWeight:700},children:B})]},T)}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsxs)("span",{style:{fontSize:9,color:Oe.green,fontWeight:600},children:[Xe,"L"]}),(0,e.jsx)("span",{style:{fontSize:9,color:Oe.dim},children:"/"}),(0,e.jsxs)("span",{style:{fontSize:9,color:Oe.red,fontWeight:600},children:[It,"S"]})]}),(0,e.jsxs)("div",{style:{flex:1,overflowY:"auto",padding:"6px 8px"},children:[s==="POSITIONS"&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{style:{display:"flex",gap:3,marginBottom:5,flexWrap:"wrap",alignItems:"center"},children:[(0,e.jsxs)("button",{onClick:function(){V("ALL")},style:{padding:"2px 7px",borderRadius:3,fontSize:9,fontFamily:Gl,cursor:"pointer",border:"1px solid "+(N==="ALL"?"rgba(212,175,92,0.5)":"rgba(90,112,144,0.2)"),background:N==="ALL"?"rgba(212,175,92,0.15)":"transparent",color:N==="ALL"?Oe.accent:Oe.dim,fontWeight:N==="ALL"?700:400,transition:"all .12s"},children:["ALL (",Ae.length,")"]}),Bm.map(function(T){var Y=Ue[T]||0;if(!Y)return null;var B=N===T,ie=Bu[T]||Oe.accent;return(0,e.jsxs)("button",{onClick:function(){V(B?"ALL":T)},style:{padding:"2px 7px",borderRadius:3,fontSize:9,fontFamily:Gl,cursor:"pointer",border:"1px solid "+(B?ie+"60":"rgba(90,112,144,0.2)"),background:B?ie+"18":"transparent",color:B?ie:Oe.dim,fontWeight:B?700:400,transition:"all .12s"},children:[T.toUpperCase()," (",Y,")"]},T)}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("input",{value:ge,onChange:function(T){X(T.target.value)},placeholder:"Search...",style:{background:"rgba(212,175,92,0.04)",border:"1px solid rgba(212,175,92,0.1)",borderRadius:3,padding:"2px 7px",fontSize:10,color:Oe.text,fontFamily:Gl,outline:"none",width:90}})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:4,marginBottom:5,alignItems:"center"},children:[(0,e.jsx)("button",{onClick:function(){w(!_)},style:Object.assign({},Z,{fontSize:9,padding:"2px 8px"},_?{background:"rgba(212,175,92,0.15)",border:"1px solid rgba(212,175,92,0.4)"}:{}),children:_?"✕ CANCEL":"+ ADD"}
119),(0,e.jsx)("input",{ref:_e,type:"file",accept:".csv,.txt",onChange:Qe,style:{display:"none"}}),(0,e.jsx)("button",{onClick:function(){_e.current&&_e.current.click()},style:Object.assign({},Z,{fontSize:9,padding:"2px 8px"}),children:"↑ CSV"}),xe&&(0,e.jsx)("span",{style:{fontSize:10,fontWeight:700,color:xe.ok?"#3FB950":"#E07070",marginLeft:6,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:420},children:xe.text}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsxs)("button",{onClick:function(){ut("pnl")},style:Object.assign({},Z,{fontSize:9,padding:"2px 8px",background:oe==="pnl"?"rgba(212,175,92,0.15)":"transparent"}),children:["P&L",oe==="pnl"?R==="desc"?" ↓":" ↑":""]}),(0,e.jsxs)("button",{onClick:function(){ut("var1d")},style:Object.assign({},Z,{fontSize:9,padding:"2px 8px",background:oe==="var1d"?"rgba(212,175,92,0.15)":"transparent"}),children:["VaR",oe==="var1d"?R==="desc"?" ↓":" ↑":""]}),(0,e.jsxs)("button",{onClick:function(){ut("pnlPct")},style:Object.assign({},Z,{fontSize:9,padding:"2px 8px",background:oe==="pnlPct"?"rgba(212,175,92,0.15)":"transparent"}),children:["%",oe==="pnlPct"?R==="desc"?" ↓":" ↑":""]})]}),_&&(0,e.jsxs)("div",{style:{padding:"8px",marginBottom:6,borderRadius:4,border:"1px solid rgba(212,175,92,0.25)",background:"rgba(212,175,92,0.03)"},children:[(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr 1fr",gap:5,marginBottom:6},children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontSize:9,color:Oe.dim,marginBottom:2},children:"INSTRUMENT"}),(0,e.jsx)("input",{value:M.instrument,onChange:function(T){U(function(Y){return Object.assign({},Y,{instrument:T.target.value})})},placeholder:"NVDA",style:wt})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontSize:9,color:Oe.dim,marginBottom:2},children:"CLASS"}),(0,e.jsx)("select",{value:M.assetClass,onChange:function(T){U(function(Y){return Object.assign({},Y,{assetClass:T.target.value})})},style:H,children:Bm.map(function(T){return(0,e.jsx)("option",{value:T,children:T.toUpperCase()},T)})})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontSize:9,color:Oe.dim,marginBottom:2},children:"SIDE"}
119),(0,e.jsx)("select",{value:M.side,onChange:function(T){U(function(Y){return Object.assign({},Y,{side:T.target.value})})},style:H,children:Cv.map(function(T){return(0,e.jsx)("option",{value:T,children:T},T)})})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontSize:9,color:Oe.dim,marginBottom:2},children:"SIZE"}),(0,e.jsx)("input",{value:M.size,onChange:function(T){U(function(Y){return Object.assign({},Y,{size:T.target.value})})},placeholder:"1000",style:wt})]})]}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr 1fr",gap:5,marginBottom:6},children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontSize:9,color:Oe.dim,marginBottom:2},children:"UNIT"}),(0,e.jsx)("input",{value:M.sizeUnit,onChange:function(T){U(function(Y){return Object.assign({},Y,{sizeUnit:T.target.value})})},placeholder:"shares",style:wt})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontSize:9,color:Oe.dim,marginBottom:2},children:"ENTRY"}),(0,e.jsx)("input",{value:M.entry,onChange:function(T){U(function(Y){return Object.assign({},Y,{entry:T.target.value})})},placeholder:"150.00",style:wt})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontSize:9,color:Oe.dim,marginBottom:2},children:"CURRENT PX"}),(0,e.jsx)("input",{value:M.px,onChange:function(T){U(function(Y){return Object.assign({},Y,{px:T.target.value})})},placeholder:"155.00",style:wt})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontSize:9,color:Oe.dim,marginBottom:2},children:"NOTES"}),(0,e.jsx)("input",{value:M.notes,onChange:function(T){U(function(Y){return Object.assign({},Y,{notes:T.target.value})})},placeholder:"Thesis...",style:wt})]})]}),(0,e.jsx)("button",{onClick:Pt,disabled:!M.instrument.trim(),style:Object.assign({},Z,{opacity:M.instrument.trim()?1:.4}),children:"COMMIT POSITION"})]}),$.map(function(T){var Y=h===T.id,B=y===T.id,ie=C0(T);return(0,e.jsx)("div",{onClick:function(){B||x(Y?null:T.id)},onMouseEnter:function(){g(T.id)},onMouseLeave:function(){g(null)},style:{padding:"5px 7px",marginBottom:3,borderRadius:4,border:"1px solid "+(Y?"rgba(212,175,92,0.4)":p===T.id?"rgba(212,175,92,0.2)":"rgba(212,175,92,0.06)"),background:Y?"rgba(6,10,18,0.99)":p===T.id?Oe.cardHover:Oe.card,cursor:B?"default":"pointer",transition:"all 0.12s"},children:B?(0,e.jsxs)("div",{onClick:function(ue){ue.stopPropagation()},children:[(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr 1fr 1fr 1fr",gap:4,marginBottom:4},children:[(0,e.jsx)("input",{value:j.instrument,onChange:function(ue){E(function(ne){return Object.assign({},ne,{instrument:ue.target.value})})},style:wt}),(0,e.jsx)("select",{value:j.assetClass,onChange:function(ue){E(function(ne){return Object.assign({},ne,{assetClass:ue.target.value})})},style:H,children:Bm.map(function(ue){return(0,e.jsx)("option",{value:ue,children:ue},ue)})}),(0,e.jsx)("select",{value:j.side,onChange:function(ue){E(function(ne){return Object.assign({},ne,{side:ue.target.value})})},style:H,children:Cv.map(function(ue){return(0,e.jsx)("option",{value:ue,children:ue},ue)})}),(0,e.jsx)("input",{value:j.size,onChange:function(ue){E(function(ne){return Object.assign({},ne,{size:ue.target.value})})},style:wt,placeholder:"Size"}),(0,e.jsx)("input",{value:j.entry,onChange:function(ue){E(function(ne){return Object.assign({},ne,{entry:ue.target.value})})},style:wt,placeholder:"Entry"})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:4},children:[(0,e.jsx)("input",{value:j.notes,onChange:function(ue){E(function(ne){return Object.assign({},ne,{notes:ue.target.value})})},style:Object.assign({},wt,{flex:1}),placeholder:"Notes"}),(0,e.jsx)("button",{onClick:function(ue){tn(T.id,ue)},style:Object.assign({},Z,{background:"rgba(63,185,80,0.15)",color:Oe.green,border:"1px solid rgba(63,185,80,0.3)"}),children:"SAVE"}),(0,e.jsx)("button",{onClick:function(ue){ue.stopPropagation(),k(null)},style:Object.assign({},Z,{background:"transparent",color:Oe.dim}),children:"CANCEL"})]})]}):(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},children:[(0,e.jsx)("span",{style:{fontSize:9,color:Bu[T.assetClass]||Oe.accent,border:"1px solid "+(Bu[T.assetClass]||Oe.accent)+"25",padding:"1px 5px",borderRadius:2,letterSpacing:"0.04em",flexShrink:0},children:T.assetClass.toUpperCase()}),(0,e.jsx)("span",{style:{fontSize:12,color:Oe.text,fontWeight:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:T.instrument}
119),(0,e.jsx)("span",{style:{fontSize:10,color:T.side==="LONG"?Oe.green:Oe.red,fontWeight:700,flexShrink:0},children:T.side})]}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,flexShrink:0},children:[(0,e.jsx)("span",{style:{fontSize:9,color:ie?ie.color:Oe.dim,fontWeight:800,border:"1px solid "+(ie?ie.color:Oe.dim)+"35",padding:"0 5px",borderRadius:2},children:ie?ie.action:"NO SIGNAL"}),(0,e.jsx)("span",{style:{fontSize:11,color:T._pnlUnavailable?Oe.dim:T.pnl>=0?Oe.green:Oe.red,fontWeight:700},children:T._pnlUnavailable?"Unavailable":(T.pnl>=0?"+":"")+(T.pnl/1e3).toFixed(1)+"K"}),(0,e.jsx)("span",{style:{fontSize:10,color:Oe.dim},children:T._pnlUnavailable?"":"("+((T.pnlPct>=0?"+":"")+T.pnlPct)+"%)"}),(0,e.jsx)("span",{style:{fontSize:9,color:Wj[T.risk]||Oe.dim,fontWeight:600},children:T._riskComputed?T.risk:"UNAVAILABLE"}),(0,e.jsx)("button",{onClick:function(ue){jt(T,ue)},title:"Edit",style:{background:"none",border:"none",color:Oe.dim,cursor:"pointer",fontSize:13,padding:0,lineHeight:1},onMouseEnter:function(ue){ue.currentTarget.style.color=Oe.accent},onMouseLeave:function(ue){ue.currentTarget.style.color=Oe.dim},children:"✎"}),(0,e.jsx)("button",{onClick:function(ue){pt(T.id,ue)},title:"Remove",style:{background:"none",border:"none",color:Oe.dim,cursor:"pointer",fontSize:13,padding:0,lineHeight:1},onMouseEnter:function(ue){ue.currentTarget.style.color=Oe.red},onMouseLeave:function(ue){ue.currentTarget.style.color=Oe.dim},children:"✕"})]})]}),(0,e.jsx)("div",{style:{fontSize:10,color:Oe.dim,marginTop:2,lineHeight:1.35,opacity:.85},children:ie?ie.thesis:"No Signal Available — entry and current price are required."}),Y&&(0,e.jsxs)("div",{style:{marginTop:5,paddingTop:5,borderTop:"1px solid rgba(212,175,92,0.08)"},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:14,fontSize:10,color:Oe.dim,flexWrap:"wrap"},children:[(0,e.jsxs)("span",{children:["Size: ",(0,e.jsxs)("span",{style:{color:Oe.text,fontWeight:600},children:[T.size," ",T.sizeUnit]})]}),(0,e.jsxs)("span",{children:["Entry: ",(0,e.jsx)("span",{style:{color:Oe.text,fontWeight:600},children:Av(T.entry)})]}),(0,e.jsxs)("span",{children:["Px: ",(0,e.jsx)("span",{style:{color:r2(T.px)?Oe.text:Oe.dim,fontWeight:600},children:Av(T.px)})]}),(0,e.jsxs)("span",{children:["VaR: ",(0,e.jsxs)("span",{style:{color:T._varUnavailable?Oe.dim:Oe.red,fontWeight:600},children:[T._varUnavailable?"Unavailable":Pm(T.var1d),T._varEstimated?" est.":""]})]}),(0,e.jsxs)("span",{children:["Conf: ",(0,e.jsx)("span",{style:{color:Oe.accent,fontWeight:600},children:ie?ie.conf+"%":"—"})]})]}),(0,e.jsx)("button",{onClick:function(ue){ue.stopPropagation(),$e(T)},style:Object.assign({},Z,{marginTop:6,fontSize:9}),children:"⌁ RUN AI FORECAST"}),T.notes&&(0,e.jsx)("div",{style:{fontSize:10,color:Oe.accent,marginTop:3,opacity:.8},children:T.notes})]})]})},T.id)})]}),s==="EXPOSURE"&&(0,e.jsxs)("div",{children:[b&&(0,e.jsx)("div",{style:{display:"flex",gap:6,marginBottom:8,flexWrap:"wrap"},children:av.slice(1).map(function(T){return(0,e.jsxs)("div",{style:{padding:"5px 10px",border:"1px solid rgba(212,175,92,0.08)",borderRadius:4,background:Oe.card,flex:"1 1 auto",minWidth:75},children:[(0,e.jsx)("div",{style:{fontSize:9,color:Oe.dim,letterSpacing:"0.04em"},children:T.label.toUpperCase()}),(0,e.jsxs)("div",{style:{fontSize:13,color:Oe.text,fontWeight:700},children:[T.value,T.sub&&(0,e.jsx)("span",{style:{fontSize:9,color:Oe.dim,marginLeft:4},children:T.sub})]})]},T.label)})}),(0,e.jsxs)("div",{style:{marginBottom:8},children:[(0,e.jsx)("div",{style:{fontSize:10,color:Oe.accent,fontWeight:700,marginBottom:5,letterSpacing:"0.06em"},children:"ASSET CLASS EXPOSURE"}),Ie.map(function(T){var Y=Bu[T.cls]||Oe.accent;return(0,e.jsxs)("div",{style:{marginBottom:5},children:[(0,e.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:2},children:[(0,e.jsx)("span",{style:{fontSize:11,color:Oe.text,fontWeight:600},children:T.cls.toUpperCase()}),(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center"}
119,children:[(0,e.jsxs)("span",{style:{fontSize:10,color:Y,fontWeight:700},children:[T.pct.toFixed(1),"%"]}),(0,e.jsxs)("span",{style:{fontSize:9,color:Oe.dim},children:[T.count," pos"]}),(0,e.jsxs)("span",{style:{fontSize:10,color:T.pnl>=0?Oe.green:Oe.red,fontWeight:600},children:[T.pnl>=0?"+":"",(T.pnl/1e3).toFixed(0),"K"]}),(0,e.jsxs)("span",{style:{fontSize:9,color:Oe.red},children:["VaR ",T.var?Pm(T.var):"Unavailable"]})]})]}),(0,e.jsx)("div",{style:{height:7,borderRadius:4,background:"rgba(90,112,144,0.1)",overflow:"hidden"},children:(0,e.jsx)("div",{style:{width:Math.min(T.pct,100)+"%",height:"100%",borderRadius:4,background:Y,transition:"width 0.3s"}})})]},T.cls)})]}),(0,e.jsxs)("div",{style:{padding:"7px 10px",borderRadius:4,border:"1px solid rgba(212,175,92,0.08)",background:Oe.card,marginBottom:8},children:[(0,e.jsx)("div",{style:{fontSize:10,color:Oe.accent,fontWeight:700,marginBottom:5,letterSpacing:"0.06em"},children:"DIRECTIONAL EXPOSURE"}),(0,e.jsxs)("div",{style:{display:"flex",gap:14,fontSize:11},children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{style:{color:Oe.dim},children:"LONG: "}),(0,e.jsx)("span",{style:{color:Oe.green,fontWeight:700},children:Xe})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{style:{color:Oe.dim},children:"SHORT: "}),(0,e.jsx)("span",{style:{color:Oe.red,fontWeight:700},children:It})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{style:{color:Oe.dim},children:"NET: "}),(0,e.jsxs)("span",{style:{color:Xe>It?Oe.green:Oe.red,fontWeight:700},children:[Xe>It?"NET LONG":"NET SHORT"," (",Math.abs(Xe-It),")"]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{style:{color:Oe.dim},children:"WIN: "}),(0,e.jsxs)("span",{style:{color:Oe.green,fontWeight:700},children:[Rt,"/",Ae.length]}),(0,e.jsxs)("span",{style:{color:Oe.dim},children:[" (",Ae.length?(Rt/Ae.length*100).toFixed(0):0,"%)"]})]})]}),(0,e.jsx)("div",{style:{marginTop:5},children:(0,e.jsxs)("div",{style:{height:9,borderRadius:5,display:"flex",overflow:"hidden",background:"rgba(90,112,144,0.1)"},children:[(0,e.jsx)("div",{style:{width:Xe/(Xe+It)*100+"%",background:Oe.green,borderRadius:"5px 0 0 5px",transition:"width 0.3s"}}),(0,e.jsx)("div",{style:{width:It/(Xe+It)*100+"%",background:Oe.red,borderRadius:"0 5px 5px 0",transition:"width 0.3s"}})]})})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontSize:10,color:Oe.accent,fontWeight:700,marginBottom:5,letterSpacing:"0.06em"},children:"RISK MATRIX"}),b&&JC.map(function(T){return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"5px 7px",marginBottom:3,borderRadius:4,border:"1px solid rgba(212,175,92,0.06)",background:Oe.card},children:[(0,e.jsx)("span",{style:{fontSize:11,color:Oe.text},children:T.label}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,e.jsx)("div",{style:{width:70,height:6,borderRadius:3,background:"rgba(90,112,144,0.12)",overflow:"hidden"},children:(0,e.jsx)("div",{style:{width:T.score+"%",height:"100%",borderRadius:3,background:T.color,transition:"width 0.3s"}})}),(0,e.jsx)("span",{style:{fontSize:10,color:T.color,fontWeight:700,minWidth:55,textAlign:"right"},children:T.value})]})]},T.label)}),(0,e.jsxs)("div",{style:{marginTop:5,padding:"6px 10px",borderRadius:4,border:"1px solid rgba(200,92,92,0.15)",background:"rgba(200,92,92,0.04)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,e.jsx)("span",{style:{fontSize:10,color:Oe.dim},children:"PORTFOLIO VaR (95%, 1-DAY)"}),St?(0,e.jsx)("span",{style:{fontSize:14,color:Oe.red,fontWeight:800},title:tt.estimatedCount?"Parametric estimate (class vol × z95)":"",children:Pm(ft.net)}):(0,e.jsx)("span",{style:{fontSize:12,color:Oe.dim,fontWeight:700},children:"Unavailable / Insufficient Data"})]}),St&&tt.estimatedCount>0&&(0,e.jsxs)("div",{style:{fontSize:9,color:Oe.dim,marginTop:4},children:["Parametric estimate from ",tt.estimatedCount," position",tt.estimatedCount===1?"":"s"," (class vol × z95). Not a broker VaR."]})]})]}),s==="SIGNALS"&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontSize:10,
119color:Oe.accent,fontWeight:700,marginBottom:6,letterSpacing:"0.06em"},children:"XYRON INTELLIGENCE — RESEARCH SIGNALS"}),(0,e.jsx)("div",{style:{fontSize:10,color:Oe.dim,marginBottom:8,lineHeight:1.5},children:"AI-generated research signals ranked by urgency, confidence-weighted across asset classes for research and educational use — not investment advice. Review CLOSE and TRIM signals first."}),Ae.length===0&&(0,e.jsx)("div",{style:{fontSize:11,color:Oe.dim,padding:"12px 4px"},children:"No Signal Available — import positions first."}),Ae.slice().sort(function(T,Y){var B=C0(T),ie=C0(Y),ue={EXIT:0,CLOSE:0,TRIM:1,ROLL:2,REVIEW:3,ADD:4,HOLD:5};return(ue[B&&B.action]||6)-(ue[ie&&ie.action]||6)}).map(function(T){var Y=C0(T);return(0,e.jsxs)("div",{style:{padding:"6px 9px",marginBottom:4,borderRadius:4,border:"1px solid "+(Y?Y.color:Oe.dim)+"20",background:Oe.card},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:3},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:7},children:[(0,e.jsx)("span",{style:{fontSize:10,color:Y?Y.color:Oe.dim,fontWeight:800,border:"1px solid "+(Y?Y.color:Oe.dim)+"40",padding:"1px 7px",borderRadius:3,letterSpacing:"0.06em"},children:Y?Y.action:"NO SIGNAL"}),(0,e.jsx)("span",{style:{fontSize:12,color:Oe.text,fontWeight:700},children:T.instrument}),(0,e.jsx)("span",{style:{fontSize:10,color:T.side==="LONG"?Oe.green:Oe.red,fontWeight:600},children:T.side}),(0,e.jsx)("span",{style:{fontSize:9,color:Bu[T.assetClass]||Oe.dim},children:T.assetClass.toUpperCase()})]}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:7},children:[(0,e.jsx)("span",{style:{fontSize:11,color:T._pnlUnavailable?Oe.dim:T.pnl>=0?Oe.green:Oe.red,fontWeight:700},children:T._pnlUnavailable?"Unavailable":(T.pnl>=0?"+":"")+(T.pnl/1e3).toFixed(1)+"K"}),(0,e.jsx)("span",{style:{fontSize:10,color:Oe.dim},children:T._pnlUnavailable?"":"("+((T.pnlPct>=0?"+":"")+T.pnlPct)+"%)"}),(0,e.jsx)("span",{style:{fontSize:9,color:Oe.accent,fontWeight:600},children:Y?"CONF "+Y.conf+"%":""})]})]}),(0,e.jsx)("div",{style:{fontSize:10,color:Oe.dim,lineHeight:1.5},children:Y?Y.thesis:"No Signal Available for "+T.instrument+" — entry and current price are required."})]},T.id)})]}),s==="ALERTS"&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontSize:10,color:Oe.accent,fontWeight:700,marginBottom:6,letterSpacing:"0.06em"},children:"RISK ALERTS — ACTIVE"}),Q.length===0&&(0,e.jsx)("div",{style:{fontSize:11,color:Oe.dim,padding:"12px 4px",lineHeight:1.5},children:"No active risk alerts for your portfolio."}),Q.map(function(T){var Y=T.level==="Critical"?"#D44040":T.level==="High"?"#C85C5C":"#D4AF5C";return(0,e.jsxs)("div",{style:{padding:"7px 10px",marginBottom:5,borderRadius:4,border:"1px solid "+Y+"25",background:Oe.card},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:3},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,e.jsx)("span",{style:{fontSize:9,color:Y,fontWeight:700,border:"1px solid "+Y+"40",padding:"1px 6px",borderRadius:2},children:String(T.level||"").toUpperCase()}),(0,e.jsx)("span",{style:{fontSize:11,color:Oe.text,fontWeight:600},children:T.pos}),(0,e.jsx)("span",{style:{fontSize:9,color:Bu[T.assetClass]||Oe.dim},children:(T.assetClass||"").toUpperCase()})]}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,e.jsx)("span",{style:{fontSize:9,color:Oe.dim},children:T.type}),(0,e.jsx)("span",{style:{fontSize:9,color:Oe.dim},children:T.time})]})]}),(0,e.jsx)("div",{style:{fontSize:10,color:Oe.dim,lineHeight:1.5},children:T.msg})]},T.id)}),b&&(0,e.jsxs)("div",{style:{marginTop:8},children:[(0,e.jsx)("div",{style:{fontSize:10,color:Oe.accent,fontWeight:700,marginBottom:5,letterSpacing:"0.06em"},children:"MARKET SNAPSHOT"}),(0,e.jsx)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:3},children:QC.map(function(T){return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"4px 7px",borderRadius:3,border:"1px solid rgba(212,175,92,0.04)",background:Oe.card}
119,children:[(0,e.jsx)("span",{style:{fontSize:10,color:Oe.text,fontWeight:600},children:T.symbol}),(0,e.jsx)("span",{style:{fontSize:10,color:Oe.text},children:T.price}),(0,e.jsx)("span",{style:{fontSize:9,color:T.up?Oe.green:Oe.red,fontWeight:600},children:T.change})]},T.symbol)})})]})]})]}),(0,e.jsx)(uv,{}),Ne&&(0,e.jsx)("div",{style:{position:"absolute",inset:0,zIndex:60,background:"rgba(2,4,8,0.97)",overflowY:"auto"},children:(0,e.jsx)(BS,{position:Ne,onClose:function(){$e(null)}})}),ot&&(0,e.jsx)("div",{style:{position:"absolute",inset:0,zIndex:70,background:"rgba(2,4,8,0.78)",display:"flex",alignItems:"center",justifyContent:"center",padding:16,backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)"},onClick:function(T){T.target===T.currentTarget&&gt()},children:(0,e.jsxs)("div",{role:"dialog","aria-modal":"true","aria-labelledby":"portfolio-delete-title",style:{width:"min(400px, 94%)",background:"rgba(8,12,20,0.99)",border:"1px solid rgba(200,92,92,0.35)",borderRadius:8,boxShadow:"0 16px 48px rgba(0,0,0,0.65)",overflow:"hidden",fontFamily:Gl},onClick:function(T){T.stopPropagation()},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 14px",borderBottom:"1px solid rgba(200,92,92,0.18)",background:"rgba(200,92,92,0.06)"},children:[(0,e.jsx)("div",{id:"portfolio-delete-title",style:{fontSize:11,color:Oe.red,fontWeight:700,letterSpacing:"0.12em"},children:ot.durable?"DELETE POSITION":"REMOVE POSITION"}),(0,e.jsx)("button",{type:"button",onClick:gt,style:{background:"none",border:"none",color:Oe.dim,cursor:"pointer",fontSize:18,lineHeight:1,padding:"0 2px"},"aria-label":"Close",children:"×"})]}),(0,e.jsxs)("div",{style:{padding:"16px 16px 12px",display:"flex",flexDirection:"column",gap:10},children:[(0,e.jsx)("div",{style:{fontSize:13,color:Oe.text,lineHeight:1.45},children:ot.durable?"Permanently delete this position from your portfolio book?":"Remove this position from the current session book?"}),(0,e.jsx)("div",{style:{fontSize:11,color:Oe.accent,padding:"10px 12px",background:"rgba(212,175,92,0.06)",border:"1px solid rgba(212,175,92,0.18)",borderRadius:5,fontWeight:700,letterSpacing:"0.04em"},children:ot.sym}),(0,e.jsx)("div",{style:{fontSize:9,color:Oe.dim,letterSpacing:"0.04em",lineHeight:1.5},children:ot.durable?"This cannot be undone. Refresh will not restore the row.":"It will disappear from this browser book until you re-add or re-import it."})]}),(0,e.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,padding:"12px 14px 14px",borderTop:"1px solid rgba(30,40,56,0.95)"},children:[(0,e.jsx)("button",{type:"button",onClick:gt,style:{padding:"7px 14px",background:"transparent",border:"1px solid #1E2838",borderRadius:5,cursor:"pointer",fontFamily:Gl,fontSize:9,color:"#8B9AAF",fontWeight:700,letterSpacing:"0.1em"},children:"CANCEL"}),(0,e.jsx)("button",{type:"button",onClick:qt,style:{padding:"7px 14px",background:"rgba(200,92,92,0.16)",border:"1px solid rgba(200,92,92,0.5)",borderRadius:5,cursor:"pointer",fontFamily:Gl,fontSize:9,color:"#E07070",fontWeight:700,letterSpacing:"0.1em"},children:ot.durable?"⌫ DELETE":"✕ REMOVE"})]})]})})]}):(0,e.jsxs)("div",{style:{background:Oe.bg,border:"1px solid "+Oe.border,borderRadius:"6px",overflow:"hidden",fontFamily:Gl,display:"flex",flexDirection:"column",height:"100%"},children:[(0,e.jsxs)("div",{style:{padding:"7px 12px",borderBottom:"1px solid rgba(212,175,92,0.1)",display:"flex",alignItems:"center",gap:6,background:"rgba(212,175,92,0.04)",flexShrink:0},children:[(0,e.jsx)("div",{style:{width:6,height:6,borderRadius:"50%",background:Oe.accent,boxShadow:"0 0 5px "+Oe.accent+"66"}}),(0,e.jsx)("span",{style:{fontSize:11,color:Oe.accent,fontWeight:700,letterSpacing:"0.1em"},children:"PORTFOLIO INTELLIGENCE"})]}),(0,e.jsxs)("div",{style:{flex:1,overflowY:"auto"},children:[(0,e.jsx)("div",{style:{padding:"10px 12px",color:Oe.dim,fontSize:11,lineHeight:1.5,borderBottom:"1px solid rgba(212,175,92,0.06)"},children:"Connect a live portfolio to see your real positions, P&L, risk, and AI forecasts. No demo holdings are shown."}),(0,e.jsx)(Mj,{onPositionsImported:function(T){var Y=Array.isArray(T)?T:[];Y.length&&rt(function(B){return(Array.isArray(B)?B:[]).concat(Y)})}}),(0,e.jsx)(Uj,{})]}),(0,e.jsx)(uv,{})]})}function cL(t,n,r,o){return{x:t+r,y:n+o}}function dL(t,n,r,o,a,l){return{w:Math.max(a??380,t+r),h:Math.max(l??260,n+o)}}function Vj(t,n,r,o){var a=Math.max(0,(r||0)-48),l=Math.max(0,(o||0)-48);return{x:Math.min(Math.max(-(n.w-48),t.x),a),y:Math.min(Math.max(0,t.y),l)}}function uL(t,n,r){var o=Math.max(0,(n||0)-280),a=Math.max(0,(r||0)-40);return{x:Math.min(Math.max(0,t.x),o),y:Math.min(Math.max(0,t.y),a)}}function fL(t,n){return t&&n?{open:!0,minimized:!1}:{open:!t,minimized:!1}}function Yj(t,n){return{x:Math.max(20,(t||1280)-(n||680)-28),y:84}}function pL(t,n,r){var o=r??12,a=t||1280,l=n||800;
119return{x:o,y:o,w:Math.max(380,a-o*2),h:Math.max(260,l-o*2)}}var jv=[{id:"5min",label:"1D",size:78,interval:"5min"},{id:"15min",label:"5D",size:130,interval:"15min"},{id:"1h",label:"1M",size:160,interval:"1h"},{id:"1day",label:"3M",size:65,interval:"1day"},{id:"1day_1y",label:"1Y",size:252,interval:"1day"},{id:"1week",label:"5Y",size:260,interval:"1week"}];function gL(t){return jv.find(function(n){return n.id===t})||jv[3]}var Kj={BTC:"BTC/USD",ETH:"ETH/USD",SOL:"SOL/USD",XRP:"XRP/USD",DOGE:"DOGE/USD",ADA:"ADA/USD",LINK:"LINK/USD",LTC:"LTC/USD",BCH:"BCH/USD",DOT:"DOT/USD",XLM:"XLM/USD",SHIB:"SHIB/USD",UNI:"UNI/USD",AAVE:"AAVE/USD"};function mL(t){return t&&(Kj[String(t).toUpperCase()]||t)}var hL={w:760,h:520},yL={w:420,h:480},wv=[{id:"price",label:"PRICE"},{id:"orderflow",label:"ORDER FLOW"}],Xj="price";function xL(t){for(var n=String(t||"").toLowerCase(),r=0;r<wv.length;r++)if(wv[r].id===n)return n;return Xj}function vL(t,n,r,o,a){var l=t&&t.w!=null?t.w:n.w,s=t&&t.h!=null?t.h:n.h,c=r&&r<768,d=c?Math.max(260,Math.min(380,r-16)):380,p=c?Math.max(220,Math.min(260,Math.floor((o||640)*.42))):260;r&&(l=Math.min(Math.max(l,d),Math.max(d,r-16))),o&&(s=Math.min(Math.max(s,p),Math.max(p,o-72)));var g=a||0,f=Yj(r,l),h=Vj({x:t&&t.x!=null?t.x:c?8:f.x-g,y:t&&t.y!=null?t.y:c?56:f.y+g},{w:l,h:s},r,o);return{x:h.x,y:h.y,w:l,h:s}}function qj(t,n,r){var o=(t||"").toString();return{id:"note-"+(n||"0")+"-"+(r??0),ts:n||null,updatedAt:n||null,text:o,revisions:[]}}function $j(t,n,r){if(!t)return t;var o=t.text||"",a=(n||"").toString();if(a===o)return t;var l=[{ts:t.updatedAt||t.ts||null,text:o}].concat(t.revisions||[]);return Object.assign({},t,{text:a,updatedAt:r||t.updatedAt||t.ts||null,revisions:l.slice(0,20)})}var Uy=Yp(GC(),1);function Jj(t){var n=!!t.active,r=t.onSelect||function(){},o=t.onCancel||function(){},a=(0,i.useState)(null),l=a[0],s=a[1],c=(0,i.useRef)(null);if((0,i.useEffect)(function(){if(!n){c.current=null,s(null);return}function f(h){h.key==="Escape"&&(c.current=null,s(null),o())}return window.addEventListener("keydown",f),function(){window.removeEventListener("keydown",f)}},[n]),!n||typeof document>"u")return null;function d(f){return f?{x:Math.min(f.x0,f.x1),y:Math.min(f.y0,f.y1),w:Math.abs(f.x1-f.x0),h:Math.abs(f.y1-f.y0)}:null}var p=d(l),g=(0,e.jsxs)("div",{onPointerDown:function(f){f.preventDefault();try{f.currentTarget.setPointerCapture(f.pointerId)}catch{}var h={x0:f.clientX,y0:f.clientY,x1:f.clientX,y1:f.clientY};c.current=h,s(h)},onPointerMove:function(f){s(function(h){var x=h||c.current;if(!x)return h;var v=Object.assign({},x,{x1:f.clientX,y1:f.clientY});return c.current=v,v})},onPointerUp:function(){var f=d(c.current);c.current=null,s(null),f&&f.w>=8&&f.h>=8?r(f):o()},style:{position:"fixed",inset:0,zIndex:1e5,cursor:"crosshair",background:"rgba(3,5,10,0.35)"},children:[(0,e.jsx)("div",{style:{position:"fixed",top:16,left:"50%",transform:"translateX(-50%)",fontFamily:vr,fontSize:11,letterSpacing:".12em",color:"#E4C27A",background:"rgba(8,11,17,0.92)",border:"1px solid "+vt.amber+"55",borderRadius:4,padding:"6px 14px",pointerEvents:"none"},children:"DRAG TO SELECT AN AREA · ESC TO CANCEL"}),p?(0,e.jsx)("div",{style:{position:"fixed",left:p.x,top:p.y,width:p.w,height:p.h,border:"1.5px solid "+vt.amber,background:"rgba(212,175,92,0.10)",boxShadow:"0 0 0 9999px rgba(3,5,10,0.35)",pointerEvents:"none"},children:(0,e.jsxs)("div",{style:{position:"absolute",bottom:-18,right:0,fontFamily:vr,fontSize:9,color:"#E4C27A",letterSpacing:".08em",whiteSpace:"nowrap"},children:[Math.round(p.w),"×",Math.round(p.h)]})}):null]});return Uy.createPortal(g,document.body)}function bL(){return new Promise(function(t){if(typeof requestAnimationFrame!="function"){setTimeout(t,32);return}requestAnimationFrame(function(){requestAnimationFrame(function(){t()})})})}function SL(t,n){var r=String(t||"").match(/^data:([^;]+);base64,([\s\S]*)$/);if(!r)return null;var o=r[1]||"image/png",a;try{a=atob(r[2])}catch{return null}for(var l=new Uint8Array(a.length),s=0;s<a.length;s++)l[s]=a.charCodeAt(s);var c=n||"capture.png";try{return new File([l],c,{type:o})}catch{return new Blob([l],{type:o})}}function Qj(t,n,r){if(!(!t||typeof document>"u")){var o=t.getContext&&t.getContext("2d");if(o)for(var a=document.querySelectorAll("canvas"),l=0;l<a.length;l++){var s=a[l];if(!(!s||s===t)){var c=s.getBoundingClientRect();if(!(c.width<1||c.height<1)){var d=Math.max(c.left,n.x),p=Math.max(c.top,n.y),g=Math.min(c.right,n.x+n.w),f=Math.min(c.bottom,n.y+n.h);if(!(g-d<1||f-p<1))try{var h=(d-c.left)*s.width/c.width,x=(p-c.top)*s.height/c.height,v=(g-d)*s.width/c.width,y=(f-p)*s.height/c.height;o.drawImage(s,h,x,v,y,(d-n.x)*r,(p-n.y)*r,(g-d)*r,(f-p)*r)}catch{}}}}}}function Zj(t){return!t||typeof window>"u"||typeof document>"u"||t.w<8||t.h<8?Promise.resolve(null):xi(()=>import("./vendor-C44JUHxF.js").then(n=>Yp(n.Zn(),1)).then(function(n){var r=n&&(n.default||n);if(typeof r!="function")return null;var o=window.devicePixelRatio>1?2:1;return r(document.body,{backgroundColor:"#03050A",useCORS:!0,logging:!1,scale:o,x:t.x+window.scrollX,y:t.y+window.scrollY,width:t.w,height:t.h,windowWidth:document.documentElement.scrollWidth,windowHeight:document.documentElement.scrollHeight}).then(function(a){Qj(a,t,o);try{return a.toDataURL("image/png")}catch{return null}})}),__vite__mapDeps([0,1,2])).catch(function(){return null})}var i2="xyron_call_note_sessions",Wy="xyron_call_notes_";function o2(t,n){try{var r=localStorage.getItem(t);return r?JSON.parse(r):n}catch{return n}}function a2(t,n){try{localStorage.setItem(t,JSON.stringify(n))}catch{}}function ad(){var t=o2(i2,[]);return Array.isArray(t)?t:[]}function em(t){a2(i2,t)}function ew(t){var n=new Date,r=n.toLocaleDateString(void 0,{month:"short",day:"numeric"}
119)+" "+n.toTimeString().slice(0,5),o=(t||"").toString().replace(/^xyron-/,"").slice(0,10);return"Call "+r+(o?" · "+o:"")}var Um={};function tw(t){var n=(t||"default").toString();if(Um[n]){var r=ad().filter(function(s){return s.id===Um[n]})[0];if(r)return r}var o="cs-"+Date.now().toString(36)+Math.floor(Math.random()*1e6).toString(36),a={id:o,name:ew(t),room:n,startedAt:new Date().toISOString(),updatedAt:new Date().toISOString()},l=ad();return l.unshift(a),em(l.slice(0,200)),Um[n]=o,a}function nw(t,n){var r=(n||"").toString().trim().slice(0,80);return r?(em(ad().map(function(o){return o.id===t?Object.assign({},o,{name:r,updatedAt:new Date().toISOString()}):o})),r):null}function rw(t){em(ad().filter(function(n){return n.id!==t}));try{localStorage.removeItem(Wy+t)}catch{}}function l2(t){var n=o2(Wy+t,null);return{entries:n&&Array.isArray(n.entries)?n.entries:[],shots:n&&Array.isArray(n.shots)?n.shots:[]}}function iw(t,n){var r=l2(t),o={entries:n.entries!==void 0?n.entries:r.entries,shots:n.shots!==void 0?n.shots:r.shots};return a2(Wy+t,o),em(ad().map(function(a){var l={updatedAt:new Date().toISOString()};return n.participants!==void 0&&(l.participants=n.participants),l.noteCount=o.entries.length,a.id===t?Object.assign({},a,l):a})),o}var ey=null;function ow(t){ey=t||null}function aw(){var t=ey;return ey=null,t}var lw=[{id:"refine",label:"REFINE",instr:"Clean up grammar, structure and clarity of the analyst note below WITHOUT adding new facts, opinions, or price calls. Return only the improved note text."},{id:"organize",label:"ORGANIZE",instr:"Reorganize the analyst note below into clear bullet points grouped by theme. Do not invent content — only restructure what is written. Return only the reorganized note."},{id:"summarize",label:"SUMMARIZE",instr:"Summarize the analyst note below into 2-3 tight sentences. Do not add new claims. Return only the summary."}];function A0(){return new Date().toISOString()}function sw(t){return t?String(t).slice(0,16).replace("T"," "):""}function cw(t){const[n,r]=(0,i.useState)(null),[o,a]=(0,i.useState)([]),[l,s]=(0,i.useState)([]),[c,d]=(0,i.useState)(""),[p,g]=(0,i.useState)(null),[f,h]=(0,i.useState)(""),[x,v]=(0,i.useState)(""),[y,k]=(0,i.useState)(""),[A,j]=(0,i.useState)(""),[E,C]=(0,i.useState)(!1),[_,w]=(0,i.useState)(!1);(0,i.useEffect)(()=>{const R=ge=>{r(ge);const X=l2(ge.id);a(X.entries),s(X.shots)},ae=setTimeout(()=>{R(aw()||tw(t.room))},0),q=ge=>{ge&&ge.detail&&ge.detail.id&&R(ge.detail)};return window.addEventListener("xyron-notes-load-session",q),()=>{clearTimeout(ae),window.removeEventListener("xyron-notes-load-session",q)}},[t.room]);const O=R=>{R.entries!==void 0&&a(R.entries),R.shots!==void 0&&s(R.shots),n&&iw(n.id,Object.assign({participants:t.participants||[]},R))},M=()=>{const R=c.trim();R&&(O({entries:[qj(R,A0(),o.length)].concat(o)}),d(""))},U=(R,ae)=>{O({entries:o.map(q=>q.id===R?$j(q,ae,A0()):q)})},ee=R=>{O({entries:o.filter(ae=>ae.id!==R)})},N=R=>{C(!1),w(!0),Promise.resolve(Zj(R)).then(ae=>{ae&&O({shots:[{id:"shot-"+A0()+"-"+l.length,ts:A0(),dataUrl:ae,label:(n?n.name:"call")+" snip"}].concat(l)}),w(!1)}).catch(()=>w(!1))},V=R=>{const ae=document.createElement("a");ae.href=R.dataUrl,ae.download=(R.label||"snapshot").replace(/[^A-Za-z0-9 _-]/g,"")+".png",ae.click()},z=R=>{const ae=o[0];!ae||!ae.text.trim()||x||(v(R.id),sv(R.instr+`
120
121Context: notes taken during a video call.
122
123Analyst note:
124`+ae.text,6e4).then(q=>{const ge=(q||"").trim();ge&&U(ae.id,ge),v("")}).catch(()=>v("")))},oe=()=>{const R=y.trim();!R||x||(v("ask"),j(""),sv(`You are helping an analyst reason about their call notes. Answer the question using ONLY the notes below plus general knowledge. Do not fabricate specific numbers. Be concise.
125
126Notes:
127`+(o.map((ae,q)=>q+1+". "+ae.text).join(`
128`)||"(none yet)")+`
129
130Question: `+R,6e4).then(ae=>{j((ae||"").trim()||"No answer."),v("")}).catch(()=>v("")))},P=(R,ae,q,ge)=>(0,e.jsx)("button",{type:"button",onClick:ae,disabled:ge,style:{background:q?"rgba(212,175,92,0.14)":"transparent",border:"1px solid "+(q?Zn.gold:Zn.b2),borderRadius:4,padding:"3px 8px",cursor:ge?"wait":"pointer",fontFamily:Zn.mono,fontSize:9,color:q?Zn.gold:Zn.t3,letterSpacing:".08em"},children:R},R),W={fontFamily:Zn.mono,fontSize:9,fontWeight:700,color:Zn.t4,letterSpacing:".12em"};return(0,e.jsxs)("div",{"data-testid":"call-notes-panel",style:{display:"flex",flexDirection:"column",gap:8},children:[(0,e.jsx)("div",{style:W,children:(n?n.name.toUpperCase():"MEETING NOTES")+" — SAVED AUTOMATICALLY"}),(0,e.jsx)("textarea",{value:c,onChange:R=>d(R.target.value),placeholder:"Write a note on this call…",rows:3,style:{width:"100%",boxSizing:"border-box",background:Zn.bg1,border:"1px solid "+Zn.b2,borderRadius:6,padding:"8px 10px",color:Zn.t1,fontFamily:Zn.ui,fontSize:12,lineHeight:1.55,outline:"none",resize:"vertical"}}),(0,e.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"center"},children:[P("+ ADD NOTE",M,!0,!1),P(_?"…":"📷 SNAPSHOT",()=>!_&&C(!0),E,_),(0,e.jsx)("span",{style:{flex:1}}),lw.map(R=>P(R.label,()=>z(R),x===R.id,!!x))]}),(0,e.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,e.jsx)("input",{value:y,onChange:R=>k(R.target.value),onKeyDown:R=>{R.key==="Enter"&&oe()},placeholder:"Ask about these notes…",style:{flex:1,background:Zn.bg1,border:"1px solid "+Zn.b2,borderRadius:4,padding:"5px 8px",color:Zn.t2,fontFamily:Zn.ui,fontSize:12,outline:"none"}}),P("ASK",oe,x==="ask",!!x)]}),A?(0,e.jsx)("div",{style:{background:Zn.bg1,border:"1px solid "+Zn.b2,borderRadius:4,padding:8,color:Zn.t2,fontFamily:Zn.ui,fontSize:12,lineHeight:1.55,whiteSpace:"pre-wrap"},children:A}):null,l.length?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:W,children:"SCREENSHOTS · "+l.length}),(0,e.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:l.map(R=>(0,e.jsxs)("div",{style:{width:120,background:Zn.bg2,border:"1px solid "+Zn.b2,borderRadius:4,padding:4},children:[(0,e.jsx)("img",{src:R.dataUrl,alt:R.label,style:{width:"100%",height:64,objectFit:"cover",display:"block",borderRadius:3}}),(0,e.jsxs)("div",{style:{display:"flex",gap:4,marginTop:4},children:[P("↓ PNG",()=>V(R),!1,!1),P("✕",()=>O({shots:l.filter(ae=>ae.id!==R.id)}),!1,!1)]})]},R.id))})]}):null,o.map(R=>(0,e.jsx)("div",{style:{background:Zn.bg1,border:"1px solid "+Zn.b2,borderRadius:6,padding:"8px 10px"},children:p===R.id?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("textarea",{value:f,onChange:ae=>h(ae.target.value),rows:3,style:{width:"100%",boxSizing:"border-box",background:Zn.bg0,border:"1px solid "+Zn.b2,borderRadius:4,padding:6,color:Zn.t1,fontFamily:Zn.ui,fontSize:12}}),(0,e.jsxs)("div",{style:{display:"flex",gap:6,marginTop:6},children:[P("SAVE",()=>{f.trim()&&U(R.id,f.trim()),g(null)},!0,!1),P("CANCEL",()=>g(null),!1,!1)]})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:{color:Zn.t1,fontFamily:Zn.ui,fontSize:12,lineHeight:1.55,whiteSpace:"pre-wrap"},children:R.text}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:6},children:[(0,e.jsxs)("span",{style:{color:Zn.t4,fontFamily:Zn.mono,fontSize:9},children:[sw(R.updatedAt||R.ts),R.revisions&&R.revisions.length?" · rev "+R.revisions.length:""]}),(0,e.jsx)("span",{style:{flex:1}}),P("✎",()=>{g(R.id),h(R.text)},!1,!1),P("✕",()=>ee(R.id),!1,!1)]})]})},R.id)),(0,e.jsx)(Jj,{active:E,onSelect:N,onCancel:()=>C(!1)})]})}var Lr="monospace",j0=["#D4AF5C","#B0BCC8","#3FB950","#D4AF5C","#C85C5C","#FBBF24","#C85C5C","#6B9AC4"];function dw({transcriptLines:t,copilotCards:n,elapsed:r,participants:o,liveIntel:a,room:l,sheet:s}){var c=(0,i.useState)("transcript"),d=c[0],p=c[1];(0,i.useEffect)(function(){function C(){p("notes")}return window.addEventListener("xyron-notes-load-session",C),function(){window.removeEventListener("xyron-notes-load-session",C)}},[]);var g=(0,i.useState)(""),f=g[0],h=g[1],x=(0,i.useState)([]),v=x[0],y=x[1],k=(0,i.useRef)(null);(0,i.useEffect)(function(){k.current&&d==="transcript"&&(k.current.scrollTop=k.current.scrollHeight)},[t,d]),(0,i.useEffect)(function(){a&&a.actions_detected&&a.actions_detected.length>0&&y(function(C){return a.actions_detected.map(function(_){return{text:_,time:Date.now()}}).concat(C).slice(0,20)})},[a]);function A(C){var _=Math.floor(C/60),w=C%60;return(_<10?"0"+_:""+_)+":"+(w<10?"0"+w:""+w)}var j=(0,i.useMemo)(function(){var C={},_=0,w={},O={};t.forEach(function(ee){O[ee.speaker]=1});var M=Object.keys(O).length<=1,U=["revenue","earnings","growth","margin","forecast","guidance","risk","opportunity","market","portfolio","rate","inflation","dividend","buyback","acquisition","strategy","valuation","target"];return t.forEach(function(ee){var N=Tv(ee.speaker,o,M);C[N]=(C[N]||0)+1;var V=(ee.text||"").split(/\s+/);
130_+=V.length,V.forEach(function(z){var oe=z.toLowerCase().replace(/[^a-z]/g,"");U.indexOf(oe)>=0&&(w[oe]=(w[oe]||0)+1)})}),{speakerTime:C,wordCount:_,singleSpeaker:M,topTopics:Object.entries(w).sort(function(ee,N){return N[1]-ee[1]}).slice(0,8)}},[t,o]),E=(0,i.useMemo)(function(){if(!f)return t;var C=f.toLowerCase();return t.filter(function(_){return(_.text||"").toLowerCase().indexOf(C)>=0})},[t,f]);return i.createElement("div",{style:{width:s?"100%":320,borderLeft:s?"none":"1px solid #111820",background:"#06080D",display:"flex",flexDirection:"column",flexShrink:0,overflow:"hidden"}},i.createElement("div",{style:{padding:"8px 12px",borderBottom:"1px solid #111820",display:"flex",alignItems:"center",justifyContent:"space-between"}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:6}},i.createElement("div",{style:{width:6,height:6,borderRadius:"50%",background:"#D4AF5C",boxShadow:"0 0 6px rgba(212,175,92,0.4)"}}),i.createElement("span",{style:{fontFamily:Lr,fontSize:8,fontWeight:700,color:"#D4AF5C",letterSpacing:".1em"}},"AI COPILOT")),i.createElement("div",{style:{display:"flex",alignItems:"center",gap:6}},v.length>0&&i.createElement("span",{style:{fontFamily:Lr,fontSize:6,color:"#C85C5C",background:"rgba(200,92,92,0.08)",padding:"2px 6px",borderRadius:8}},v.length+" actions"),i.createElement("span",{style:{fontFamily:Lr,fontSize:7,color:"#3A4A5E"}},o.length," in call"))),i.createElement("div",{style:{display:"flex",borderBottom:"1px solid #111820"}},["transcript","intel","insights","actions","notes"].map(function(C){return i.createElement("button",{key:C,onClick:function(){p(C)},style:{flex:1,padding:"6px 2px",background:d===C?"rgba(212,175,92,0.06)":"transparent",border:"none",borderBottom:d===C?"2px solid #D4AF5C":"2px solid transparent",cursor:"pointer",fontFamily:Lr,fontSize:6,fontWeight:700,color:d===C?"#D4AF5C":"#3A4A5E",letterSpacing:".04em",textTransform:"uppercase"}},C)})),i.createElement("div",{ref:k,style:{flex:1,overflow:"auto",padding:"8px 10px"}},d==="transcript"&&i.createElement("div",null,i.createElement("input",{type:"text",value:f,onChange:function(C){h(C.target.value)},placeholder:"Search transcript…",style:{width:"100%",background:"#0A0E16",border:"1px solid #1C2740",borderRadius:4,padding:"4px 8px",fontSize:9,color:"#C9D1D9",outline:"none",boxSizing:"border-box",fontFamily:Lr,marginBottom:8}}),E.length===0&&!f&&i.createElement("div",{style:{textAlign:"center",padding:"30px 0"}},i.createElement("div",{style:{fontFamily:Lr,fontSize:8,color:"#2A3548"}},"LIVE TRANSCRIPT"),i.createElement("div",{style:{fontFamily:Lr,fontSize:7,color:"#1C2740",marginTop:4}},"Waiting for speech…")),E.map(function(C,_){var w=j0[C.speaker%j0.length];return i.createElement("div",{key:_,style:{marginBottom:6,animation:_===E.length-1&&!f?"xfadein 0.2s":"none"}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:4,marginBottom:1}},i.createElement("div",{style:{width:4,height:4,borderRadius:"50%",background:w}}),i.createElement("span",{style:{fontFamily:Lr,fontSize:7,color:w}},Tv(C.speaker,o,j.singleSpeaker)),i.createElement("span",{style:{fontFamily:Lr,fontSize:6,color:"#1C2740",marginLeft:"auto"}},new Date(C.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}))),i.createElement("div",{style:{fontSize:11,color:"#C9D1D9",lineHeight:1.5,paddingLeft:8}},f?uw(C.text,f):C.text))})),d==="intel"&&i.createElement("div",null,n.length===0&&i.createElement("div",{style:{textAlign:"center",padding:"30px 0"}},i.createElement("div",{style:{fontFamily:Lr,fontSize:8,color:"#2A3548"}},"INTELLIGENCE CARDS"),i.createElement("div",{style:{fontFamily:Lr,fontSize:7,color:"#1C2740",marginTop:4}},"Cards appear when tickers, macro terms, or contacts are detected…")),n.map(function(C,_){return i.createElement("div",{key:_,style:{background:"#0A0E16",border:"1px solid #1C2740",borderRadius:6,padding:"8px 10px",marginBottom:6,animation:"xfadein 0.3s"}},i.createElement("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:4}},i.createElement("span",{style:{fontFamily:Lr,fontSize:7,fontWeight:700,color:"#D4AF5C"}},C.topic),i.createElement("span",{style:{fontFamily:Lr,fontSize:6,color:"#2A3548"}},A(r))),Object.entries(C.intelligence||{}).map(function(w){return i.createElement("div",{key:w[0],style:{display:"flex",justifyContent:"space-between",fontFamily:Lr,fontSize:9,color:"#8B949E",marginBottom:3,padding:"2px 0",borderBottom:"1px solid #0D1520"}},i.createElement("span",null,w[0].replace("price_","$ ").replace("contacts","👤 Contacts").replace("position","📊 Position")),i.createElement("span",{style:{color:"#3FB950",maxWidth:120,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},typeof w[1]=="string"?w[1]:Array.isArray(w[1])?w[1].length+" items":JSON.stringify(w[1]).substring(0,30)))}
130))})),d==="insights"&&i.createElement("div",null,i.createElement("div",{style:{display:"flex",gap:6,marginBottom:10}},Wm("DURATION",A(r),"#D4AF5C"),Wm("WORDS",""+j.wordCount,"#3FB950"),Wm("SEGMENTS",""+t.length,"#6B9AC4")),a&&i.createElement("div",{style:{marginBottom:12,padding:"8px 10px",background:"#0A0E16",border:"1px solid #1C2740",borderRadius:6}},i.createElement("div",{style:{fontFamily:Lr,fontSize:7,fontWeight:700,color:"#5A7090",marginBottom:4}},"MEETING SENTIMENT"),i.createElement("div",{style:{display:"flex",alignItems:"center",gap:8}},i.createElement("div",{style:{width:32,height:32,borderRadius:"50%",background:a.sentiment==="positive"?"rgba(63,185,80,0.1)":a.sentiment==="negative"?"rgba(255,68,68,0.1)":"rgba(90,112,144,0.1)",border:"2px solid "+(a.sentiment==="positive"?"#3FB950":a.sentiment==="negative"?"#D44040":"#3A4A5E"),display:"flex",alignItems:"center",justifyContent:"center",fontSize:16}},a.sentiment==="positive"?"📈":a.sentiment==="negative"?"📉":"➖"),i.createElement("div",null,i.createElement("div",{style:{fontFamily:Lr,fontSize:9,fontWeight:700,color:a.sentiment==="positive"?"#3FB950":a.sentiment==="negative"?"#D44040":"#5A7090",textTransform:"uppercase"}},a.sentiment),a.sentiment_signals&&a.sentiment_signals.length>0&&i.createElement("div",{style:{fontFamily:Lr,fontSize:7,color:"#3A4A5E",marginTop:2}},a.sentiment_signals.join(", "))))),a&&Object.keys(a.entities||{}).length>0&&i.createElement("div",{style:{marginBottom:12}},i.createElement("div",{style:{fontFamily:Lr,fontSize:7,fontWeight:700,color:"#5A7090",marginBottom:6}},"ENTITIES MENTIONED"),Object.entries(a.entities).map(function(C){var _=C[0],w=C[1],O=_==="money"?"#3FB950":_==="percentage"?"#D4AF5C":"#6B9AC4";return i.createElement("div",{key:_,style:{marginBottom:4}},i.createElement("span",{style:{fontFamily:Lr,fontSize:7,color:O,textTransform:"uppercase"}},_),i.createElement("div",{style:{display:"flex",gap:4,flexWrap:"wrap",marginTop:2}},w.map(function(M,U){return i.createElement("span",{key:U,style:{fontFamily:Lr,fontSize:8,color:O,background:O+"12",border:"1px solid "+O+"30",padding:"2px 6px",borderRadius:8}},M)})))})),i.createElement("div",{style:{marginBottom:12}},i.createElement("div",{style:{fontFamily:Lr,fontSize:7,fontWeight:700,color:"#5A7090",marginBottom:6}},"SPEAKER DISTRIBUTION"),Object.entries(j.speakerTime).map(function(C,_){var w=C[0],O=C[1],M=t.length||1,U=Math.round(O/M*100),ee=j0[_%j0.length];return i.createElement("div",{key:w,style:{marginBottom:6}},i.createElement("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:2}},i.createElement("span",{style:{fontFamily:Lr,fontSize:8,color:ee}},w),i.createElement("span",{style:{fontFamily:Lr,fontSize:8,color:"#5A7090"}},U+"%")),i.createElement("div",{style:{width:"100%",height:4,background:"#0D1520",borderRadius:2,overflow:"hidden"}},i.createElement("div",{style:{width:U+"%",height:"100%",background:ee,borderRadius:2,transition:"width 0.5s"}})))})),j.topTopics.length>0&&i.createElement("div",null,i.createElement("div",{style:{fontFamily:Lr,fontSize:7,fontWeight:700,color:"#5A7090",marginBottom:6}},"KEY TOPICS"),i.createElement("div",{style:{display:"flex",gap:4,flexWrap:"wrap"}},j.topTopics.map(function(C){return i.createElement("span",{key:C[0],style:{fontFamily:Lr,fontSize:7,color:"#D4AF5C",background:"rgba(212,175,92,0.06)",border:"1px solid rgba(212,175,92,0.15)",padding:"3px 8px",borderRadius:12}},C[0]+" ("+C[1]+")")})))),d==="actions"&&i.createElement("div",null,i.createElement("div",{style:{fontFamily:Lr,fontSize:7,fontWeight:700,color:"#C85C5C",letterSpacing:".08em",marginBottom:8}},"LIVE ACTION DETECTION"),i.createElement("div",{style:{fontFamily:Lr,fontSize:7,color:"#3A4A5E",marginBottom:10,lineHeight:1.5}},"Action items are detected in real-time as they're spoken. AI-generated structured minutes with owners and deadlines will be created when the call ends."),v.length===0&&i.createElement("div",{style:{textAlign:"center",padding:"20px 0",fontFamily:Lr,fontSize:8,color:"#2A3548"}},"No action items detected yet…"),v.map(function(C,_){return i.createElement("div",{key:_,style:{padding:"8px 10px",background:"#0A0E16",border:"1px solid rgba(200,92,92,0.15)",borderLeft:"3px solid #C85C5C",borderRadius:"0 6px 6px 0",marginBottom:4,animation:_===0?"xfadein 0.3s":"none"}},i.createElement("div",{style:{fontSize:11,color:"#C9D1D9",lineHeight:1.5}},"“",C.text,"”"),i.createElement("div",{style:{fontFamily:Lr,fontSize:6,color:"#3A4A5E",marginTop:3}},new Date(C.time).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})))})),d==="notes"&&i.createElement(cw,{room:l,participants:o})))}function Tv(t,n,r){return r?n&&n.length===1&&n[0]?n[0]:"Speaker":"Speaker "+(Number(t)+1)}function Wm(t,n,r){return i.createElement("div",{style:{flex:1,background:"#0A0E16",border:"1px solid #1C2740",borderRadius:6,padding:"8px 6px",textAlign:"center"}},i.createElement("div",{style:{fontFamily:"monospace",fontSize:14,fontWeight:700,color:r}},n),i.createElement("div",{style:{fontFamily:"monospace",fontSize:6,color:"#3A4A5E",letterSpacing:".08em",marginTop:2}},t))}function uw(t,n){return n?t.split(new RegExp("("+n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+")","gi")).map(function(r,o){return r.toLowerCase()===n.toLowerCase()?i.createElement("span",{key:o,style:{background:"rgba(212,175,92,0.2)",color:"#D4AF5C",borderRadius:2,padding:"0 1px"}},r):r}):t}function _v(t,n,r,o){const a=new Set(n||[]),l=[];let s=-1;for(const d of t||[])a.has(d.id)?s<0&&(s=l.length):l.push(d);s<0&&(s=l.length);const c=(r||[]).filter(d=>d&&String(d.text||"").trim()).map(o);return l.slice(0,s).concat(c,l.slice(s))}var fw="legacy",pw="livekit";async function gw(t,n){return t==="livekit"?(await xi(()=>import("./livekitTransport-wXww658c.js"),__vite__mapDeps([3,4,5,1,6,7]))).createLiveKitTransport(n):(await xi(()=>
130import("./legacyTransport-CbkvFmoT.js"),__vite__mapDeps([8,6,1]))).createLegacyTransport(n)}var ty="recordings";function mw(t,n){return new Promise(function(r){try{var o=document.createElement("video");o.muted=!0,o.playsInline=!0,o.srcObject=t;var a=!1,l=function(c){if(!a){a=!0;try{o.srcObject=null}catch{}r(c||null)}},s=setTimeout(function(){l(null)},3e3);o.onloadeddata=function(){try{var c=Math.min(n||480,o.videoWidth||480),d=Math.round(c*((o.videoHeight||270)/(o.videoWidth||480))),p=document.createElement("canvas");p.width=c,p.height=d,p.getContext("2d").drawImage(o,0,0,c,d),p.toBlob(function(g){clearTimeout(s),l(g)},"image/jpeg",.7)}catch{clearTimeout(s),l(null)}},o.play().catch(function(){clearTimeout(s),l(null)})}catch{r(null)}})}async function hw(t,n,r,o){var a="call-recording-"+(String(o||"").trim().replace(/[^A-Za-z0-9 _.-]/g,"").replace(/\s+/g,"-").slice(0,80)||(r?String(r).replace(/[^A-Za-z0-9_-]/g,"").slice(0,40)+"-":"")+new Date().toISOString().replace(/[:.]/g,"-")),l=new File([t],a+".webm",{type:"video/webm"}),s=await gn.upload(l,a+".webm",ty);if(!s)return null;if(n)try{var c=new File([n],a+".thumb.jpg",{type:"image/jpeg"});await gn.upload(c,a+".thumb.jpg",ty)}catch{}return{doc:s,base:a}}async function yw(t,n){if(!t||!n)return null;var r=new File([new Blob([n],{type:"text/plain"})],t+".summary.txt",{type:"text/plain"});return gn.upload(r,t+".summary.txt",ty)}async function xw(){var t=await gn.list({search:"call-recording-",limit:200}),n=t&&(t.items||t.documents||t)||[];Array.isArray(n)||(n=[]);var r=[],o={},a={};return n.forEach(function(l){var s=l.title||l.name||l.filename||"";/\.thumb\.jpg$/i.test(s)?o[s.replace(/\.thumb\.jpg$/i,"")]=l:/\.summary\.txt$/i.test(s)?a[s.replace(/\.summary\.txt$/i,"")]=l:/\.webm$/i.test(s)&&r.push(l)}),r.map(function(l){var s=l.title||l.name||l.filename||"";return{doc:l,name:s,base:s.replace(/\.webm$/i,""),thumbDoc:o[s.replace(/\.webm$/i,"")]||null,summaryDoc:a[s.replace(/\.webm$/i,"")]||null,createdAt:l.created_at||l.uploaded_at||l.createdAt||null}}).sort(function(l,s){return String(s.createdAt||"").localeCompare(String(l.createdAt||""))})}function Pu(t){return String(t||"").replace(/^call-recording-/,"").replace(/\.thumb\.jpg$/i,"").replace(/\.summary\.txt$/i,"").replace(/\.webm$/i,"")}async function vw(t,n){var r=String(n||"").trim().replace(/[^A-Za-z0-9 _.-]/g,"").slice(0,80);if(!r)return null;var o="call-recording-"+r.replace(/\s+/g,"-"),a=await gn.update(t.doc.id||t.doc.doc_id,{name:o+".webm"});if(!a)return null;if(t.thumbDoc)try{await gn.update(t.thumbDoc.id||t.thumbDoc.doc_id,{name:o+".thumb.jpg"})}catch{}return a}var w0="'JetBrains Mono','SF Mono',monospace";function s2(t){const[n,r]=(0,i.useState)(t.defaultName||""),o=(0,i.useRef)(null);(0,i.useEffect)(()=>{const l=setTimeout(()=>{o.current&&o.current.focus()},50);return()=>clearTimeout(l)},[]);const a=()=>t.onSave(n.trim()||null);return(0,e.jsx)("div",{style:{position:"fixed",inset:0,zIndex:9500,background:"rgba(3,5,9,0.82)",display:"flex",alignItems:"center",justifyContent:"center",padding:16},children:(0,e.jsxs)("div",{style:{width:"100%",maxWidth:380,background:"#0B0F16",border:"1px solid rgba(212,175,92,0.35)",borderRadius:10,padding:"18px 18px 14px",boxShadow:"0 18px 60px rgba(0,0,0,0.6)"},children:[(0,e.jsx)("div",{style:{fontFamily:w0,fontSize:10,fontWeight:700,color:"#D4AF5C",letterSpacing:".14em",marginBottom:4},children:"⏺ RECORDING SAVED"}),(0,e.jsx)("div",{style:{color:"#8A96A8",fontSize:11,fontFamily:"'Inter',system-ui,sans-serif",marginBottom:12},children:"Name this recording for the Vault"}),(0,e.jsx)("input",{ref:o,value:n,onChange:l=>r(l.target.value),onKeyDown:l=>{l.key==="Enter"&&a(),l.key==="Escape"&&t.onSave(null)},placeholder:"e.g. Weekly board sync",style:{width:"100%",boxSizing:"border-box",background:"#060910",border:"1px solid #1E2838",borderRadius:6,padding:"10px 12px",color:"#E4E9F0",fontFamily:w0,fontSize:13,outline:"none",marginBottom:14}}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[(0,e.jsx)("button",{type:"button",onClick:()=>t.onSave(null),style:{background:"transparent",border:"1px solid #1E2838",borderRadius:6,padding:"9px 14px",cursor:"pointer",fontFamily:w0,fontSize:10,
130color:"#5A7090",letterSpacing:".06em"},children:"SKIP"}),(0,e.jsx)("button",{type:"button",onClick:a,style:{background:"rgba(212,175,92,0.14)",border:"1px solid rgba(212,175,92,0.5)",borderRadius:6,padding:"9px 18px",cursor:"pointer",fontFamily:w0,fontSize:10,fontWeight:700,color:"#D4AF5C",letterSpacing:".08em"},children:"SAVE"})]})]})})}var Yd=Zn.mono;function bw(t){const[n,r]=(0,i.useState)([]),[o,a]=(0,i.useState)(null),[l,s]=(0,i.useState)(null);if((0,i.useEffect)(()=>{if(!t.open)return;const d=setTimeout(()=>r(ad()),0);return()=>clearTimeout(d)},[t.open]),!t.open)return null;const c=d=>{ow(d);try{window.dispatchEvent(new CustomEvent("xyron-notes-load-session",{detail:d}))}catch{}s(d.id),setTimeout(()=>s(null),1600)};return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{style:{position:"fixed",right:0,top:"14%",bottom:"14%",width:300,zIndex:99550,background:"#0B0F16",border:"1px solid #1E2838",borderRight:"none",borderRadius:"8px 0 0 8px",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"-12px 0 40px rgba(0,0,0,0.5)"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",padding:"10px 12px",borderBottom:"1px solid #1E2838"},children:[(0,e.jsx)("span",{style:{flex:1,color:"#D4AF5C",fontFamily:Yd,fontSize:9,fontWeight:700,letterSpacing:".12em"},children:"SESSION HISTORY"}),(0,e.jsx)("button",{type:"button",onClick:t.onClose,style:{background:"transparent",border:"1px solid #1E2838",borderRadius:4,color:"#5A7090",cursor:"pointer",fontFamily:Yd,fontSize:8,padding:"3px 8px"},children:"✕"})]}),(0,e.jsx)("div",{style:{flex:1,overflowY:"auto"},children:n.length?n.map(d=>(0,e.jsxs)("div",{style:{padding:"9px 12px",borderBottom:"1px solid #12161f"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,e.jsx)("div",{title:d.name,style:{flex:1,color:"#D4AF5C",fontFamily:Yd,fontSize:10,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:d.name}),(0,e.jsx)("button",{type:"button",title:"Rename session",onClick:()=>a(d),style:{background:"transparent",border:"1px solid #1E2838",borderRadius:3,color:"#8a7c5c",cursor:"pointer",fontSize:9,padding:"1px 5px"},children:"✎"}),(0,e.jsx)("button",{type:"button",title:"Delete session",onClick:()=>{window.confirm("Delete this session's notes?")&&(rw(d.id),r(ad()))},style:{background:"transparent",border:"1px solid #1E2838",borderRadius:3,color:"#C85C5C",cursor:"pointer",fontSize:9,padding:"1px 5px"},children:"✕"})]}),(0,e.jsxs)("div",{style:{color:"#5A7090",fontFamily:Yd,fontSize:8,marginTop:3},children:[String(d.updatedAt||d.startedAt).slice(0,16).replace("T"," ")," · ",(d.noteCount||0)+" notes"]}),d.participants&&d.participants.length?(0,e.jsxs)("div",{style:{color:"#8A96A8",fontFamily:Yd,fontSize:8,marginTop:2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:["👤 ",d.participants.join(", ")]}):null,(0,e.jsx)("button",{type:"button",onClick:()=>c(d),style:{marginTop:6,background:"rgba(212,175,92,0.10)",border:"1px solid rgba(212,175,92,0.35)",borderRadius:4,color:"#D4AF5C",cursor:"pointer",fontFamily:Yd,fontSize:8,letterSpacing:".08em",padding:"4px 10px"},children:l===d.id?"OPENED IN NOTES TAB ✓":"OPEN IN NOTES TAB"})]},d.id)):(0,e.jsx)("div",{style:{padding:14,color:"#5A7090",fontFamily:Yd,fontSize:9,letterSpacing:1},children:"NO SESSIONS YET — notes you take in calls appear here per session."})})]}),o?(0,e.jsx)(s2,{defaultName:o.name,onSave:d=>{d&&nw(o.id,d),r(ad()),a(null)}}):null]})}var Sw="local",c2="local#screen";var Za=8,Ip=10;function d2(t,n){return t>n&&n>0&&n<420&&t<1e3}function u2(t,n=0){return t>0&&t<720||d2(t,n)}var ag=()=>({x:0,y:0,w:0,h:0,z:0,role:"hidden"});function Ew({tiles:t,width:n,height:r,speakerId:o=null,stripOpen:a=!1,pipCorner:l="br",view:s="speaker",pinnedId:c=null,page:d=0}){const p={},g=Math.max(0,n),f=Math.max(0,r),h=u2(g,f),x=h&&d2(g,f),v=t.find(V=>V.local),y=t.find(V=>V.id===c2),k=t.filter(V=>!V.local&&V.id!=="local#screen"&&(V.screen||V.sharing)),A=t.filter(V=>!V.local&&!V.screen),j=!!y||!!(v&&v.sharing),E={presenting:j,more:null,pinnedId:null,pipId:null};if(s==="gallery"&&t.length>1)return Aw({tiles:t,W:g,H:f,narrow:h,page:d,presenting:j});const C=c&&t.find(V=>V.id===c)||null,_=C&&C.id!=="local#screen"&&!(C.local&&C.sharing)?C:null;let w=null;if(_?w=_:k.length?w=k[k.length-1]:o&&A.some(V=>V.id===o)?w=A.find(V=>V.id===o):A.length?w=A[0]:w=v||t[0]||null,!w)return{...E,mode:"empty",stageId:null,rects:p};const O={x:0,y:0,w:g,h:f,z:1,role:"stage"},M=t.filter(V=>V.id!==w.id),U=_?_.id:null;if(M.length===1&&!j&&!k.length)return p[w.id]=O,p[M[0].id]={...jw(g,f,h,l),z:3,role:"pip"},{...E,mode:"duo",stageId:w.id,pipId:M[0].id,pinnedId:U,rects:p};if(M.length===0)return p[w.id]=O,{...E,mode:"solo",stageId:w.id,rects:p};const ee=[...M.filter(V=>!V.local&&!V.screen),...M.filter(V=>V.local),...M.filter(V=>V.screen)];if(x&&!a)return p[w.id]=O,ee.forEach(V=>p[V.id]=ag()),{...E,mode:"speaker",stageId:w.id,pinnedId:U,rects:p,more:{
130id:null,count:ee.length},stripHidden:!0};let N=null;if(!h||x){const V=Math.round(Math.min(h?180:260,Math.max(120,g*.22))),z=Math.round(V*9/16),oe=Math.max(1,Math.floor((f-Ip)/(z+Za)));p[w.id]={...O,w:g-V-Za},ee.forEach((P,W)=>{p[P.id]=W<oe?{x:g-V,y:W*(z+Za),w:V,h:z,z:2,role:"strip"}:ag()}),ee.length>oe&&(N={id:ee[oe-1].id,count:ee.length-oe+1})}else{const V=Math.round(Math.min(150,Math.max(96,f*.2))),z=Math.round(V*3/4),oe=Math.max(1,Math.floor((g+Za)/(z+Za)));p[w.id]={...O,h:f-V-Za},ee.forEach((P,W)=>{p[P.id]=W<oe?{x:W*(z+Za),y:f-V,w:z,h:V,z:2,role:"strip"}:ag()}),ee.length>oe&&(N={id:ee[oe-1].id,count:ee.length-oe+1})}return{...E,mode:"speaker",stageId:w.id,pinnedId:U,rects:p,more:N}}function kw(t){return t?6:9}function Cw(t,n,r,o){let a={cols:1,rows:t,w:0,h:0};for(let l=1;l<=Math.max(1,t);l++){const s=Math.ceil(t/l),c=(n-(l-1)*Za)/l,d=(r-(s-1)*Za)/s;if(c<=0||d<=0)continue;const p=Math.min(c,d*o),g=p/o;p*g>a.w*a.h&&(a={cols:l,rows:s,w:Math.floor(p),h:Math.floor(g)})}return a}function Aw({tiles:t,W:n,H:r,narrow:o,page:a,presenting:l}){const s={},c=[...t.filter(y=>!y.local&&!y.screen),...t.filter(y=>y.local),...t.filter(y=>y.screen)],d=kw(o),p=Math.max(1,Math.ceil(c.length/d)),g=Math.min(Math.max(0,a|0),p-1),f=c.slice(g*d,g*d+d),h=Cw(f.length,n,r,o&&r>n?3/4:16/9),x=h.rows*h.h+(h.rows-1)*Za,v=Math.max(0,Math.round((r-x)/2));return c.forEach(y=>s[y.id]=ag()),f.forEach((y,k)=>{const A=Math.floor(k/h.cols),j=Math.min(h.cols,f.length-A*h.cols),E=Math.max(0,Math.round((n-(j*h.w+(j-1)*Za))/2));s[y.id]={x:E+(k-A*h.cols)*(h.w+Za),y:v+A*(h.h+Za),w:h.w,h:h.h,z:1,role:"grid"}}),{mode:"gallery",stageId:null,pipId:null,pinnedId:null,presenting:l,rects:s,more:null,page:g,pages:p,cols:h.cols,rows:h.rows}}function jw(t,n,r,o="br"){const a=Math.round(r?Math.max(96,Math.min(150,t*.3)):Math.max(160,Math.min(280,t*.2))),l=Math.round(r&&n>t?a*4/3:a*9/16);return{x:o.endsWith("l")?Ip:t-a-Ip,y:o.startsWith("t")?Ip:n-l-Ip,w:a,h:l}}function ww(t,n,r,o){return(n<o/2?"t":"b")+(t<r/2?"l":"r")}function Tw(t,n,r){const o=t||{id:null,since:0,cand:null,candSince:0};if(!n||n===o.id)return{...o,cand:null,candSince:0};if(!o.id)return{id:n,since:r,cand:null,candSince:0};const a=n===o.cand?o.candSince:r;return r-a>=350&&r-o.since>=1800?{id:n,since:r,cand:null,candSince:0}:{...o,cand:n,candSince:a}}function _w({screen:t,sharing:n,videoW:r,videoH:o,boxW:a,boxH:l,role:s}){return t||n?"contain":s!=="stage"||!r||!o||!a||!l?"cover":o>r&&!(l>a)?"contain":"cover"}var T0=["#D4AF5C","#B0BCC8","#3FB950","#D4AF5C","#C85C5C","#FBBF24","#C85C5C","#6B9AC4"],Rw="0.1.1675465747",Kd="/video-backgrounds/",Ag=[{id:"none",label:"None",short:"None",tone:"#5A7090"},{id:"blur",label:"Blur",short:"Blur",tone:"#D4AF5C"}
130,{id:"office",label:"Executive",short:"Office",tone:"#6B9AC4",asset:Kd+"executive-office.webp"},{id:"boardroom",label:"Boardroom",short:"Board",tone:"#B0BCC8",asset:Kd+"boardroom.webp"},{id:"market",label:"Market Wall",short:"Market",tone:"#3FB950",asset:Kd+"market-wall.webp"},{id:"studio",label:"Studio",short:"Studio",tone:"#C85C5C",asset:Kd+"broadcast-studio.webp"},{id:"library",label:"Library",short:"Library",tone:"#B0BCC8",asset:Kd+"research-library.webp"},{id:"lounge",label:"Lounge",short:"Lounge",tone:"#D4AF5C",asset:Kd+"private-lounge.webp"},{id:"skyline",label:"Skyline",short:"Skyline",tone:"#6B9AC4",asset:Kd+"skyline-office.webp"}],Hm="xyron_call_prompter_v1",Gm=[{id:"principals",label:"Principals",topic:"2-minute production update for principals",tone:"institutional",audience:"principals",duration:2},{id:"family_office",label:"Family Office",topic:"Portfolio and market update for the investment committee",tone:"institutional",audience:"family_office",duration:3},{id:"internal",label:"Internal",topic:"Team operating update with risks, decisions, and next actions",tone:"urgent",audience:"internal",duration:2},{id:"media",label:"Media",topic:"Concise public statement with crisp sound bites",tone:"formal",audience:"media",duration:1.5}],Dp={};function Qs(t){return"https://cdn.jsdelivr.net/npm/@mediapipe/selfie_segmentation@"+Rw+"/"+t}var Rv={"selfie_segmentation.js":Qs("selfie_segmentation.js"),"selfie_segmentation.binarypb":Qs("selfie_segmentation.binarypb"),"selfie_segmentation.tflite":Qs("selfie_segmentation.tflite"),"selfie_segmentation_landscape.tflite":Qs("selfie_segmentation_landscape.tflite"),"selfie_segmentation_solution_simd_wasm_bin.js":Qs("selfie_segmentation_solution_simd_wasm_bin.js"),"selfie_segmentation_solution_simd_wasm_bin.wasm":Qs("selfie_segmentation_solution_simd_wasm_bin.wasm"),"selfie_segmentation_solution_wasm_bin.js":Qs("selfie_segmentation_solution_wasm_bin.js"),"selfie_segmentation_solution_wasm_bin.wasm":Qs("selfie_segmentation_solution_wasm_bin.wasm")},Vm=null;function nu({d:t,size:n,color:r}){return i.createElement("svg",{width:n||18,height:n||18,viewBox:"0 0 24 24",fill:"none",stroke:r||"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},i.createElement("path",{d:t}))}var cr={mic:"M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3zM19 10v2a7 7 0 0 1-14 0v-2M12 19v4M8 23h8",micOff:"M1 1l22 22M9 9v3a3 3 0 0 0 5.12 2.12M15 9.34V4a3 3 0 0 0-5.94-.6M19 10v2a7 7 0 0 1-.11 1.23M12 19v4M8 23h8M17 16.95A7 7 0 0 1 5 12v-2",cam:"M23 7l-7 5 7 5V7zM1 5h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H1z",camOff:"M16 16v1a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h2M23 7l-7 5 7 5V7zM1 1l22 22",screen:"M2 3h20a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zM8 21h8M12 17v4",record:"M12 12m-10 0a10 10 0 1 0 20 0a10 10 0 1 0-20 0",blur:"M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18zM12 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8z",invite:"M16 3h5v5M21 3l-10 10M4 11v5a2 2 0 0 0 2 2h12",more:"M5 12h.01M12 12h.01M19 12h.01",pip:"M2 3h8v6H2V3zM14 15h7v5h-7v-5zM2 13h20M2 3h20v18H2z",fullscreen:"M8 3H3v5M21 3h-5M3 16v5h5M16 21h5v-5",pin:"M12 2l3 7h7l-5.5 4.5L18 21l-6-4-6 4 1.5-7.5L2 9h7z",hand:"M18 8V6a2 2 0 0 0-4 0v2M14 8V4a2 2 0 0 0-4 0v4M10 8V6a2 2 0 0 0-4 0v6l-1.5-1.5a2 2 0 0 0-2.83 2.83L7 18.67A6 6 0 0 0 12 21h2a6 6 0 0 0 6-6v-5a2 2 0 0 0-4 0v2",end:"M23.71 16.67A16.25 16.25 0 0 0 .29 16.67l-.29.29a1 1 0 0 0 0 1.41l3 3a1 1 0 0 0 1.41 0l3-3L6 16l-2-2h4V8h8v6h4l-2 2-1.41 2.37 3 3a1 1 0 0 0 1.41 0l3-3z",grid:"M3 3h7v7H3zM14 3h7v7h-7zM3 14h7v7H3zM14 14h7v7h-7z",spotlight:"M3 3h18v12H3zM8 19h8",copilot:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zM12 6v6l4 2",close:"M18 6L6 18M6 6l12 12"};function Fw({roomUrl:t,token:n,eventId:r,userName:o,isGuest:a,onEnd:l}){var s=(0,i.useState)(!1),c=s[0],d=s[1],p=(0,i.useState)(0),g=p[0],f=p[1],h=(0,i.useState)(!1),x=h[0],v=h[1],y=(0,i.useState)(!1),k=y[0],A=y[1],j=(0,i.useState)(!1),E=j[0],C=j[1],_=(0,i.useState)(!1),w=_[0],O=_[1],M=(0,i.useState)(!1),U=M[0],ee=M[1],N=(0,i.useState)("none"),V=N[0],z=N[1],oe=(0,i.useState)(!1),P=oe[0],W=oe[1],R=V!=="none",ae=(0,i.useState)("speaker"),q=ae[0],ge=ae[1],X=(0,i.useState)(0),de=X[0],We=X[1],te=(0,i.useState)(!1),_e=te[0],ve=te[1],Ne=(0,i.useState)("br"),$e=Ne[0],Pe=Ne[1],ot=(0,i.useState)({w:0,h:0}),re=ot[0],we=ot[1],b=(0,i.useState)({w:0,h:0}),He=b[0],tt=b[1],Ae=(0,i.useState)(!1),Be=Ae[0],Fe=Ae[1],ft=(0,i.useState)(null),St=ft[0],Xe=ft[1],It=(0,i.useRef)(null),Rt=(0,i.useState)({}),$=Rt[0],Ue=Rt[1],Ie=(0,i.useState)(!0),Q=Ie[0],rt=Ie[1],jt=(0,i.useState)(null),tn=jt[0],pt=jt[1],gt=(0,i.useState)("connecting"),qt=gt[0],Pt=gt[1],Kt=(0,i.useState)(null),xe=Kt[0],fe=Kt[1],Ye=(0,i.useState)("idle"),Qe=Ye[0],ut=Ye[1],wt=(0,i.useState)(null),H=wt[0],Z=wt[1],T=(0,i.useState)(""),Y=T[0],B=T[1],ie=(0,i.useState)(null),ue=ie[0],ne=ie[1],Me=(0,i.useState)(!1),nt=Me[0],ct=Me[1],je=(0,i.useState)(!1),Le=je[0],be=je[1],Wt=(0,i.useState)(!1),Te=Wt[0],it=Wt[1],Tt=(0,i.useState)({}),bn=Tt[0],$r=Tt[1],ai=(0,i.useState)(null),Nn=ai[0],er=ai[1],Tn=(0,i.useState)(null),ra=Tn[
1300],ba=Tn[1],Ro=(0,i.useState)(null);Ro[0];var Ba=Ro[1],Ii=(0,i.useState)([]),he=Ii[0],st=Ii[1],Et=(0,i.useState)([]),Mt=Et[0],mn=Et[1],Kn=(0,i.useState)([]),br=Kn[0],qn=Kn[1],nl=(0,i.useState)(null),$n=nl[0],ia=nl[1],dc=(0,i.useState)(!1),Sa=dc[0],kl=dc[1],Cl=(0,i.useState)(""),to=Cl[0],oa=Cl[1],rl=(0,i.useState)(!1),il=rl[0],Pa=rl[1],Zl=(0,i.useState)(140),Al=Zl[0],es=Zl[1],Ea=(0,i.useState)(0),uc=Ea[0],fi=Ea[1],no=(0,i.useState)(0),Fs=no[0],Xi=no[1],Uo=(0,i.useState)(!1),dd=Uo[0],fc=Uo[1],pc=(0,i.useState)(""),Ua=pc[0],Is=pc[1],ud=(0,i.useState)(null),aa=ud[0],gc=ud[1],mc=(0,i.useState)(!1),ts=mc[0],Ds=mc[1],ns=(0,i.useState)(""),la=ns[0],hc=ns[1],fd=(0,i.useState)(""),yc=fd[0],rs=fd[1],xc=(0,i.useState)(!1),dr=xc[0],Jr=xc[1],vc=(0,i.useState)("none"),or=vc[0],po=vc[1];(0,i.useRef)({});var bc=(0,i.useState)(""),qi=bc[0],go=bc[1],Sc=(0,i.useState)([]),tr=Sc[0],Fo=Sc[1],Ec=(0,i.useState)([]),mu=Ec[0],jl=Ec[1],Wo=(0,i.useRef)(null),Ho=(0,i.useRef)(null),Qn=(0,i.useRef)(null),vi=(0,i.useRef)(null),is=(0,i.useRef)(null),Gr=(0,i.useRef)(null),Di=(0,i.useRef)(null),Os=(0,i.useState)(!1),Ai=Os[0],Wa=Os[1],kc=(0,i.useState)(!1),wl=kc[0],Ha=kc[1],hu=(0,i.useRef)([]),pd=(0,i.useRef)(null),Ls=(0,i.useRef)(null),ol=(0,i.useRef)(""),al=(0,i.useRef)([]),ll=(0,i.useRef)({}),sa=(0,i.useRef)(null),nr=(0,i.useRef)(null),Oi=(0,i.useRef)({}),Qr=(0,i.useRef)(null),Sr=(0,i.useRef)(null),ji=(0,i.useRef)(null),Io=(0,i.useRef)("none"),sl=(0,i.useRef)(0),li=(0,i.useRef)(null),Li=(0,i.useRef)(null),ka=(0,i.useRef)(!1),Er=(0,i.useRef)(null),pi=(0,i.useRef)(null),gd=(0,i.useRef)(null),Tr=(0,i.useRef)(null),zi=(0,i.useRef)(null),Tl=(0,i.useRef)(!1),zs=(0,i.useRef)({}),Fn=(0,i.useRef)(!1),Ee=(0,i.useRef)(new Set),_r=(0,i.useRef)(!1),Vr=(0,i.useRef)(""),os=(0,i.useRef)(0),Ga=(0,i.useRef)(!0);(0,i.useEffect)(function(){Ow()},[]),(0,i.useEffect)(function(){try{if(typeof localStorage>"u")return;var K=localStorage.getItem(Hm);if(!K)return;var Ce=JSON.parse(K);Ce&&Ce.script&&typeof Ce.script=="string"&&(oa(Ce.script),fi(0),Pa(!1),Ce.wpm&&es(Math.max(80,Math.min(260,Number(Ce.wpm)||140))),Ce.meta&&gc(Ce.meta))}catch{}},[]),(0,i.useEffect)(function(){try{if(typeof localStorage>"u")return;if(Ga.current){Ga.current=!1;return}if(!to.trim()){localStorage.removeItem(Hm);return}localStorage.setItem(Hm,JSON.stringify({script:to,wpm:Al,meta:aa,updated_at:Date.now()}))}catch{}},[to,Al,aa]),(0,i.useEffect)(function(){if(!t)return;var K=!1;async function Ce(){try{var Re=await navigator.mediaDevices.getUserMedia({audio:!0,video:{width:{ideal:1280},height:{ideal:720},facingMode:"user"}});if(K){Re.getTracks().forEach(function(lt){lt.stop()});return}Qr.current=Re,Sr.current=Re.getVideoTracks()[0]||null,er(Go(Sr.current)),sa.current&&(sa.current.srcObject=Re),cl(Re)}catch{try{var at=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1});if(K){at.getTracks().forEach(function(lt){lt.stop()});return}Qr.current=at,Sr.current=null,er(at),cl(at)}catch{Pt("failed")}}}return Ce(),function(){K=!0,Fc()}},[t]);function Cc(K){$r(function(Ce){var Re=Object.assign({},Ce[K.peerId]||{user_name:K.userName,streams:{}});Re.user_name=K.userName||Re.user_name,Re.streams||(Re.streams={}),K.stream&&(Re.streams[K.stream.id]=K.stream,Re.stream=K.stream),K.track&&K.track.kind==="video"&&(Re.videoTrack=K.track),K.track&&K.track.kind==="audio"&&(Re.audioTrack=K.track),K.screen&&(Re.screen=!0);var at=Object.assign({},Ce);return at[K.peerId]=Re,at}),K.stream&&!K.screen&&md(K.peerId,K.stream)}function Ac(K){var Ce=zs.current[K];if(Ce)try{Ce.disconnect()}catch{}delete zs.current[K],delete Oi.current[K]}function Ms(K){Ac(K),$r(function(Ce){var Re=Object.assign({},Ce);return delete Re[K],Re})}async function cl(K){var Ce=dA()?pw:fw;try{var Re=await gw(Ce,{roomUrl:t,token:n,userName:o,onJoined:function(at){Ba(at.peerId),d(!0),Pt("connected"),Ls.current=Date.now(),pd.current=setInterval(function(){f(Math.floor((Date.now()-Ls.current)/1e3))},1e3),a||Rl(K)},onPeerMedia:Cc,onPeerLeft:Ms,onPeerJoinedName:function(at){st(function(lt){return lt.concat([at||"Guest"])})},onStatus:function(at){Pt(at)},onActiveSpeaker:function(at){Tl.current=!0,Tr.current=at},onError:function(){}});
130Wo.current=Re,await Re.connect({localStream:K})}catch{Pt("failed")}}function _l(K){K&&Wo.current&&Wo.current.replaceVideoTrack(K)}function md(K,Ce){try{if(!Ce.getAudioTracks||!Ce.getAudioTracks().length)return;Ac(K),nr.current||(nr.current=new(window.AudioContext||window.webkitAudioContext));var Re=nr.current.createMediaStreamSource(Ce),at=nr.current.createAnalyser();at.fftSize=256,Re.connect(at),Oi.current[K]=at,zs.current[K]=Re}catch{}}(0,i.useEffect)(function(){if(c){var K=setInterval(function(){if(!Tl.current){var Ce=null,Re=0;Object.keys(Oi.current).forEach(function(at){var lt=Oi.current[at],Jt=new Uint8Array(lt.frequencyBinCount);lt.getByteFrequencyData(Jt);var nn=Jt.reduce(function(Nr,Zr){return Nr+Zr},0)/Jt.length;nn>Re&&nn>15&&(Re=nn,Ce=at)}),Tr.current=Ce}},300);return function(){clearInterval(K)}}},[c]),(0,i.useEffect)(function(){var K=setInterval(function(){var Ce=Tw(zi.current,Tr.current,Date.now());zi.current=Ce,pt(function(Re){return Re===Ce.id?Re:Ce.id})},250);return function(){clearInterval(K)}},[]),(0,i.useEffect)(function(){Object.keys(bn).forEach(function(K){var Ce=bn[K],Re=ll.current["v_"+K];Re&&Ce.stream&&(!Re.srcObject||Re.srcObject.id!==Ce.stream.id)&&(Re.srcObject=Ce.stream)})},[bn]),(0,i.useEffect)(function(){sa.current&&Nn&&sa.current.srcObject!==Nn&&(sa.current.srcObject=Nn)},[Nn]);function Go(K){var Ce=[];return K&&Ce.push(K),Qr.current&&Qr.current.getAudioTracks().forEach(function(Re){Ce.push(Re)}),new MediaStream(Ce)}function jc(K){var Ce=K||Qr.current;return Ce&&Ce.getVideoTracks?Ce.getVideoTracks()[0]:null}function hd(K){if(ka.current&&Er.current&&!Fn.current){var Ce=Er.current.getVideoTracks()[0];if(Ce)return Ce}return Sr.current||jc(K)}function ca(K){var Ce=Go(K);er(Ce),sa.current&&sa.current.srcObject!==Ce&&(sa.current.srcObject=Ce)}function wc(){try{return typeof MediaRecorder>"u"?"":MediaRecorder.isTypeSupported&&MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":MediaRecorder.isTypeSupported&&MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":""}catch{return""}}function Rl(K){try{let ua=function(){return at?new MediaRecorder(Re,{mimeType:at}):new MediaRecorder(Re)},fa=function(En){Bn.readyState===WebSocket.OPEN&&En&&En.size>0&&Bn.send(En)},ja=function(En){Bn.readyState===WebSocket.OPEN&&En&&En.byteLength>0&&Bn.send(En)},ul=function(){var En=Qn.current;if(En&&En.state!=="inactive")try{En.stop()}catch{}},Ni=function(){if(Nr)try{Nr()}catch{}Nr=null},Yo=function(){ul(),Ni()},ss=function(En,yn,ti){if(!yn||yn===ti)return En;for(var Rr=yn/ti,Ko=Math.round(En.length/Rr),Va=new Float32Array(Ko),m=0,L=0;L<Ko;L++){for(var le=Math.round((L+1)*Rr),ye=0,De=0,Se=m;Se<le&&Se<En.length;Se++)ye+=En[Se],De++;Va[L]=De?ye/De:0,m=le}return Va},ei=function(En){for(var yn=new ArrayBuffer(En.length*2),ti=new DataView(yn),Rr=0;Rr<En.length;Rr++){var Ko=Math.max(-1,Math.min(1,En[Rr]));ti.setInt16(Rr*2,Ko<0?Ko*32768:Ko*32767,!0)}return yn},Bs=function(En){if(!lt){var yn=window.AudioContext||window.webkitAudioContext;if(!yn){ut("offline"),B("Audio capture unavailable");return}var ti=En||16e3,Rr=new yn,Ko=Rr.createMediaStreamSource(Re),Va=Rr.createScriptProcessor(4096,1,1),m=Rr.createGain();if(m.gain.value=0,Va.onaudioprocess=function(L){lt||ja(ei(ss(L.inputBuffer.getChannelData(0),L.inputBuffer.sampleRate||Rr.sampleRate||ti,ti)))},Ko.connect(Va),Va.connect(m),m.connect(Rr.destination),Rr.resume)try{Rr.resume()}catch{}Nr=function(){try{Va.disconnect()}catch{}try{Ko.disconnect()}catch{}try{m.disconnect()}catch{}try{Rr.close()}catch{}}}},Dl=function(){if(!lt){var En=ua();Qn.current=En,En.ondataavailable=function(yn){fa(yn.data)},En.start(500)}},Cu=function(){function En(){if(!(lt||Bn.readyState!==WebSocket.OPEN)){var yn=ua();Qn.current=yn,yn.ondataavailable=function(ti){fa(ti.data)},yn.onstop=function(){!lt&&Bn.readyState===WebSocket.OPEN&&setTimeout(En,80)},yn.start(),setTimeout(function(){if(!lt&&yn.state!=="inactive")try{yn.stop()}catch{}},4500)}}En()},Ad=function(En,yn,ti){lt||Bn.readyState!==WebSocket.OPEN||Jt&&!yn||(yn&&Yo(),Jt=!0,nn=En,En==="pcm_stream"?Bs(ti||16e3):En==="batch"?Cu():Dl())};
130var Ce=K.getAudioTracks();if(!Ce.length){ut("offline"),B("No microphone track");return}if(typeof MediaRecorder>"u"){ut("offline"),B("Recorder unavailable");return}var Re=new MediaStream(Ce),at=wc(),lt=!1,Jt=!1,nn=null,Nr=null,Zr=1500,Mi="",Ti=null;try{Mi=localStorage.getItem("xyron_jwt_token")||""}catch{}var Bn=new WebSocket(uA("/api/meetings/transcribe/ws"));Ho.current=Bn,vi.current=function(){if(lt=!0,Yo(),Bn.readyState!==WebSocket.OPEN){try{Bn.close()}catch{}return Promise.resolve()}try{Bn.send(JSON.stringify({type:"end"}))}catch{}return new Promise(function(En){var yn=setTimeout(ti,7e3);function ti(){clearTimeout(yn),Ti=null;try{Bn.close()}catch{}En()}Ti=ti})},Bn.onopen=function(){try{Bn.send(JSON.stringify({type:"auth",token:Mi}))}catch{}ut("connecting"),B("Connecting transcript")},Bn.onmessage=function(En){try{var yn=JSON.parse(Yr(En));if(yn.type==="transcription_done"){Ti&&Ti();return}if(yn.type==="transcription_status"){Z(yn.provider||null),ut(yn.status==="degraded"?"degraded":"live"),B(yn.message||"Live transcription active"),Ad(yn.mode||"stream",Jt&&nn!==(yn.mode||"stream")&&yn.status==="fallback",yn.sample_rate||16e3);return}if(yn.error){Zr=yn.error==="unauthorized"?-1:3e4,ut("offline"),B(yn.error==="unauthorized"?"Sign in to transcribe":"Transcription unavailable"),Yo();return}if(yn.type==="transcript_revision"){Vo(yn.ids||[],yn.segments||[]);return}var ti=yn.transcript&&(""+yn.transcript).trim();if(ti){var Rr=yn.id||"local-"+Date.now()+"-"+al.current.length;al.current.push({id:Rr,text:ti}),ol.current+=ti+`
131`,mn(function(Ko){return Ko.concat([{id:Rr,text:ti,speaker:yn.speaker||0,timestamp:Date.now()}]).slice(-150)}),Tc(ti),da(ti)}}catch{}},Bn.onerror=function(){ut("degraded"),B("Transcription reconnecting")},Bn.onclose=function(){if(lt){Ti&&Ti();return}Yo(),!(Zr<0)&&(Zr<=1500&&(ut("degraded"),B("Transcription reconnecting")),setTimeout(function(){!lt&&Qr.current&&Rl(Qr.current)},Zr))}}catch{ut("offline"),B("Transcription unavailable")}}function Vo(K,Ce){var Re=Ce.map(function(lt){return{id:lt.id,text:(""+(lt.transcript||"")).trim()}}),at={};K.forEach(function(lt){at[lt]=!0}),$i(al.current.filter(function(lt){return at[lt.id]}).map(function(lt){return lt.text}),Re.map(function(lt){return lt.text}).filter(Boolean)),al.current=_v(al.current,K,Re,function(lt){return lt}),ol.current=al.current.map(function(lt){return lt.text}).join(`
132`)+(al.current.length?`
133`:""),mn(function(lt){var Jt=lt.filter(function(nn){return at[nn.id]})[0];return _v(lt,K,Re,function(nn){return{id:nn.id,text:nn.text,speaker:Jt?Jt.speaker:0,timestamp:Jt?Jt.timestamp:Date.now()}}).slice(-150)})}function $i(K,Ce){os.current+=1;var Re=os.current,at=Vr.current;K.forEach(function(Jt){var nn=at.lastIndexOf(Jt);nn>=0&&(at=at.slice(0,nn)+at.slice(nn+Jt.length))}),Vr.current=at.replace(/\s+/g," ");var lt=Ce.join(" ").trim();lt&&(Tc(lt),Ja.analyseChunk(lt,r).then(function(Jt){if(Re===os.current){var nn=Jt&&Jt.actions_detected||[],Nr=Jt&&Jt.entities||{};ia(Jt&&(nn.length>0||Jt.sentiment!=="neutral"||Object.keys(Nr).length>0)?Jt:null)}}).catch(function(){}))}
133function Yr(K){return K&&typeof K.data=="string"?K.data:"{}"}var si=["AAPL","MSFT","NVDA","GOOGL","AMZN","META","TSLA","BRK","JPM","GS","MS","BAC","WFC","V","MA","UNH","JNJ","PFE","XOM","CVX","COP","LMT","RTX","BA","CAT","DE","AMD","INTC","NFLX","CRM","ORCL","ADBE","PYPL","SQ","COIN","SNOW","PLTR"],yd=["inflation","fed","rate cut","rate hike","earnings","revenue","acquisition","merger","ipo","dividend","buyback","guidance","recession","gdp","cpi","employment","housing","yield","treasury","bond","credit","default","sanctions","tariff"];function Tc(K){var Ce=K.toUpperCase().split(/\s+/).filter(function(lt){return/^[A-Z]{2,5}$/.test(lt)&&si.indexOf(lt)>=0});if(Ce.length>0){as(Ce[0]);return}for(var Re=K.toLowerCase(),at=0;at<yd.length;at++)if(Re.indexOf(yd[at])>=0){as(yd[at]);return}}function as(K){Ja.copilot(K,r).then(function(Ce){Ce&&Ce.has_data&&qn(function(Re){return[Ce].concat(Re).slice(0,12)})}).catch(function(){})}function da(K){if(Vr.current+=" "+K,!(Vr.current.split(/\s+/).length<20)){var Ce=Vr.current;Vr.current="";var Re=os.current;Ja.analyseChunk(Ce,r).then(function(at){if(Re===os.current){var lt=at&&at.actions_detected||[],Jt=at&&at.entities||{};at&&(lt.length>0||at.sentiment!=="neutral"||Object.keys(Jt).length>0)&&ia(at)}}).catch(function(){}),or&&or!=="none"&&Ja.translate(K,or).then(function(at){at&&at.translated&&go(at.translated)}).catch(function(){})}}function ro(){return Mt.map(function(K){return{text:K.text,speaker:K.speaker,timestamp:K.timestamp}})}function _c(){Mt.length<4||Ja.chapters(ro(),6).then(function(K){K&&Array.isArray(K.chapters)&&Fo(K.chapters)}).catch(function(){})}function Do(){Mt.length<4||Ja.decisions(ro()).then(function(K){K&&Array.isArray(K.decisions)&&jl(K.decisions)}).catch(function(){})}(0,i.useEffect)(function(){if(c){var K=setInterval(function(){_c(),Do()},6e4);return function(){clearInterval(K)}}},[c,Mt.length]);function Ji(){la.trim()&&(Jr(!0),rs(""),Ja.askTranscript(ro(),la).then(function(K){rs(K&&K.answer||"(no answer)")}).catch(function(){rs("(request failed)")}).finally(function(){Jr(!1)}))}function xd(K){var Ce=typeof K=="object"&&K?K:{topic:K},Re=(Ce.topic||"").trim();if(!Re)return Is("Enter a topic before generating."),Promise.resolve(!1);var at=Math.max(.5,Math.min(10,Number(Ce.duration_minutes)||2)),lt=Ce.tone||"institutional",Jt=Ce.audience||"principals";return fc(!0),Is(""),Ja.teleprompterDraft({topic:Re,duration_minutes:at,tone:lt,audience:Jt,live_data:Ce.live_data||null}).then(function(nn){return nn&&nn.script?(oa(nn.script),fi(0),Xi(0),Pa(!1),gc({word_count:nn.word_count||0,estimated_wpm:nn.estimated_wpm||140}),nn.estimated_wpm&&es(nn.estimated_wpm),!0):(Is("Prompter draft unavailable. Paste a prepared script or try again."),!1)}).catch(function(){return Is("Prompter draft unavailable. Paste a prepared script or try again."),!1}).finally(function(){fc(!1)})}(0,i.useEffect)(function(){if(!(!Sa||!il||!to)){var K=setInterval(function(){var Ce=Mt.slice(-20).map(function(Re){return Re.text}).join(" ");Ce&&Ja.teleprompterAdherence(to,Ce).then(function(Re){Re&&typeof Re.score=="number"&&Xi(Re.score)}).catch(function(){})},5e3);return function(){clearInterval(K)}}},[Sa,il,to,Mt.length]);function wi(K){fe(K),setTimeout(function(){fe(null)},3e3)}function dl(K){return f2(K)}function Ns(){if(sl.current+=1,li.current)try{li.current()}catch{}if(li.current=null,ji.current)try{ji.current.stop()}catch{}ji.current=null,Iv()}function yu(){return Li.current?Promise.resolve(Li.current):typeof window>"u"||typeof document>"u"?Promise.reject(new Error("browser unavailable")):(Vm||(Vm=new Promise(function(K,Ce){if(window.SelfieSegmentation){K();return}var Re=document.querySelector('script[data-xyron-selfie-segmentation="true"]');if(Re){Re.addEventListener("load",K,{once:!0}),Re.addEventListener("error",Ce,{once:!0});return}var at=document.createElement("script");at.src=Rv["selfie_segmentation.js"],at.async=!0,at.dataset.xyronSelfieSegmentation="true",at.onload=function(){K()},at.onerror=function(){Ce(new Error("selfie segmentation script failed"))},document.head.appendChild(at)})),Vm.then(function(){if(!window.SelfieSegmentation)throw new Error("selfie segmentation unavailable");var K=new window.SelfieSegmentation({locateFile:function(Ce){return Rv[Ce]||Qs(Ce)}});return K.setOptions({modelSelection:1,selfieMode:!1}),Li.current=K,K}))}function Fl(K,Ce,Re){if(!K)return Promise.reject(new Error("camera unavailable"));var at=new MediaStream([K]),lt=document.createElement("video");
133lt.muted=!0,lt.playsInline=!0,lt.srcObject=at;var Jt=Bw(K),nn=document.createElement("canvas");nn.width=Jt.w,nn.height=Jt.h;var Nr=nn.getContext("2d",{alpha:!1});if(Rf(Nr),!Nr||!nn.captureStream)return Promise.reject(new Error("canvas capture unavailable"));var Zr=nn.captureStream(24).getVideoTracks()[0],Mi=!1,Ti=null,Bn=!1,ua=!1,fa=null,ja=!1,ul=!1;function Ni(){if(!(Mi||!lt.videoWidth||!lt.videoHeight)){var ei=ry(lt.videoWidth,lt.videoHeight);(ei.w!==nn.width||ei.h!==nn.height)&&(nn.width=ei.w,nn.height=ei.h,Rf(Nr),ja=!1,Iv())}}lt.addEventListener("loadedmetadata",Ni);function Yo(){ul||(ul=!0,Re&&Re())}function ss(){Mi||(lt.readyState>=2&&(fa&&!ua&&!Bn&&(Bn=!0,fa.send({image:lt}).catch(function(){ua=!0,Yo()}).finally(function(){Bn=!1})),ua||!fa||!ja?lg(Nr,lt,Ce,nn.width,nn.height,performance.now()):Yw(Nr,lt,Ce,nn.width,nn.height,performance.now())),Ti=requestAnimationFrame(ss))}return lt.play().catch(function(){}).then(function(){return yu()}).then(function(ei){fa=ei,fa.onResults(function(Bs){if(!Mi){var Dl=Bs&&Bs.segmentationMask;Dl&&(vf(Dl,nn.width,nn.height),ja=!0)}})}).catch(function(){ua=!0,Yo()}).then(function(){return ss(),{track:Zr,cleanup:function(){Mi=!0,Ti&&cancelAnimationFrame(Ti);try{lt.removeEventListener("loadedmetadata",Ni)}catch{}try{lt.pause()}catch{}try{lt.srcObject=null}catch{}try{Zr.stop()}catch{}}}})}function vd(){var K=jc();return Sr.current=K,ca(K),ka.current||_l(K),K}function mo(){vd(),Ns(),Io.current="none",z("none"),W(!1),wi("Backgroun
133d effects off")}function ho(K){var Ce=dl(K);if(Ce.id==="none"){mo();return}if(!Qr.current){wi("Camera unavailable");return}var Re=jc();if(!Re){wi("Camera unavailable");return}ji.current&&vd(),Ns();var at=sl.current+1;sl.current=at,Io.current=Ce.id,z(Ce.id),W(!1),wi("Preparing "+Ce.label.toLowerCase()+" background"),ny(Ce).catch(function(){return null}).then(function(){return at!==sl.current?null:Fl(Re,Ce,function(){wi("Background effects running in compatibility mode")})}).then(function(lt){if(lt){if(at!==sl.current){lt&&lt.cleanup&&lt.cleanup();return}ji.current=lt.track,lt.track.enabled=!E,li.current=lt.cleanup,Sr.current=lt.track,ca(lt.track),ka.current||_l(lt.track),wi(Ce.label+" background on")}}).catch(function(){at===sl.current&&(mo(),wi("Background effects unavailable"))})}function bd(){Qr.current&&(Qr.current.getAudioTracks().forEach(function(K){K.enabled=k}),A(!k))}function yo(){Qr.current&&(Qr.current.getVideoTracks().forEach(function(K){K.enabled=E}),ji.current&&(ji.current.enabled=E),C(!E))}function io(K){var Ce=Er.current||ra;Ce&&Ce.getTracks().forEach(function(lt){try{lt.onended=null}catch{}try{lt.stop()}catch{}});var Re=Fn.current;if(Er.current=null,ka.current=!1,Fn.current=!1,ba(null),ee(!1),Re){var at=Wo.current;at&&at.unpublishScreen&&at.unpublishScreen()}else _l(hd());K!==!1&&wi("Screen share stopped")}function Rc(){if(ka.current||U){io(!0);return}navigator.mediaDevices.getDisplayMedia({video:{cursor:"always"},audio:!1}).then(function(K){Er.current=K,ka.current=!0,ba(K),ee(!0);var Ce=K.getVideoTracks()[0];Ce.onended=function(){io(!0)};var Re=Wo.current;Re&&Re.publishScreen?(Fn.current=!0,Re.publishScreen(Ce).catch(function(){Fn.current=!1,_l(Ce)})):_l(Ce),wi("Sharing your screen")}).catch(function(){wi("Screen share cancelled")})}function Oo(){W(!P)}function oo(){if(w){is.current&&is.current.stop(),O(!1);return}if(Qr.current){var K=[];hu.current=K;var Ce=new MediaRecorder(Qr.current,{mimeType:"video/webm"});Ce.ondataavailable=function(Re){Re.data.size>0&&K.push(Re.data)},Ce.onstop=function(){Di.current=new Blob(K,{type:"video/webm"}),Wa(!0)},Ce.start(1e3),is.current=Ce,O(!0),wi("Recording started"),Gr.current=null,mw(Qr.current).then(function(Re){Gr.current=Re}).catch(function(){})}}function xu(K){Wa(!1);var Ce=Di.current;if(Di.current=null,!Ce)return;function Re(at){var lt=URL.createObjectURL(Ce),Jt=document.createElement("a");Jt.href=lt,Jt.download=at+".webm",Jt.click(),URL.revokeObjectURL(lt)}hw(Ce,Gr.current,t,K).then(function(at){Re(at&&at.base?at.base:"xyron-"+Date.now()),wi(at&&at.doc?"Recording saved to Vault":"Vault save failed — file downloaded locally");var lt=ol.current;at&&at.doc&&lt&&Ja.saveTranscript({event_id:"REC-"+at.base.slice(0,48),room_name:t||"",transcript_text:lt,duration_seconds:g||0,participants:he}).then(function(Jt){if(Jt&&Jt.summary)return yw(at.base,`SUMMARY
134
135`+Jt.summary+(Jt.action_items&&Jt.action_items.length?`
136
137ACTION ITEMS
138
139`+Jt.action_items.map(function(nn){return"• "+(nn.item||nn)}).join(`
140`):"")+`
141
142—— TRANSCRIPT ——
143
144`+lt)}).catch(function(Jt){})}).catch(function(){Re("xyron-"+Date.now()),wi("Vault save failed — file downloaded locally")})}function kr(){var K=window.location.origin+"/?join="+encodeURIComponent(t)+(n?"&t="+encodeURIComponent(n):"");navigator.clipboard.writeText(K).then(function(){wi("Invite link copied")}).catch(function(){wi("Room: "+t)})}function gi(){if(pi.current)if(document.fullscreenElement)document.exitFullscreen(),be(!1);else{var K=pi.current.requestFullscreen||pi.current.webkitRequestFullscreen;if(K){var Ce=K.call(pi.current);Ce&&Ce.then&&Ce.then(function(){be(!0)}).catch(function(){})}}}(0,i.useEffect)(function(){function K(){be(!!(document.fullscreenElement||document.webkitFullscreenElement))}return document.addEventListener("fullscreenchange",K),document.addEventListener("webkitfullscreenchange",K),function(){document.removeEventListener("fullscreenchange",K),document.removeEventListener("webkitfullscreenchange",K)}},[be]);function Sd(){var K=sa.current;K&&(document.pictureInPictureElement?document.exitPictureInPicture().then(function(){it(!1)}).catch(function(){}):K.requestPictureInPicture().then(function(){it(!0)}).catch(function(){wi("PiP not supported")}))}function Qi(){return typeof navigator<"u"&&!!(navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia)}function Lo(){return typeof document<"u"&&!!document.pictureInPictureEnabled}function Zi(){ct(!nt),wi(nt?"Hand lowered":"Hand raised")}function Ca(){Pt("ended");
144var K=vi.current,Ce=null;if(vi.current=null,Ho.current=null,K)try{Ce=K()}catch{}Fc(),Ce&&r&&v(!0),Promise.resolve(Ce).then(function(){var Re=ol.current;Re&&r?(v(!0),Ja.saveTranscript({event_id:r,room_name:t||"",transcript_text:Re,duration_seconds:g,participants:he}).then(function(){v(!1),l&&l()}).catch(function(){v(!1),l&&l()})):(v(!1),l&&l())})}function Fc(){if(clearInterval(pd.current),Ns(),vi.current)try{vi.current()}catch{}if(Ho.current)try{Ho.current.close()}catch{}if(Qn.current)try{Qn.current.stop()}catch{}if(is.current&&w)try{is.current.stop()}catch{}if(Wo.current){try{Wo.current.close()}catch{}Wo.current=null}if(Qr.current&&Qr.current.getTracks().forEach(function(K){K.stop()}),Er.current&&Er.current.getTracks().forEach(function(K){try{K.stop()}catch{}}),Er.current=null,ka.current=!1,Sr.current=null,nr.current)try{nr.current.close()}catch{}}function zo(K){var Ce=Math.floor(K/60),Re=K%60;return(Ce<10?"0"+Ce:""+Ce)+":"+(Re<10?"0"+Re:""+Re)}var ci=Object.keys(bn).map(function(K){return Object.assign({peer_id:K},bn[K])}),ao=[{peer_id:Sw,user_name:"You",local:!0,hasVideo:Nn&&Nn.getVideoTracks().length>0&&!E}].concat(U&&ra?[{peer_id:c2,user_name:"Your screen",local:!1,ownScreen:!0,screen:!0,hasVideo:!0,stream:ra}]:[]).concat(ci.map(function(K){return{peer_id:K.peer_id,user_name:K.user_name||"Guest",local:!1,screen:!!K.screen,hasVideo:!!K.videoTrack,stream:K.stream}})),Aa=ao.filter(function(K){return!K.screen}).length,bi=u2(He.w,He.h),Yn=Ew({tiles:ao.map(function(K){return{id:K.peer_id,local:!!K.local,screen:!!K.screen}}),width:re.w,height:re.h,speakerId:tn,stripOpen:_e,pipCorner:$e,view:q,pinnedId:ue,page:de}),Ic=ao.filter(function(K){return K.screen&&!K.ownScreen}).map(function(K){return K.peer_id}).sort().join("|");(0,i.useEffect)(function(){var K=Wo.current;!K||!K.setVideoViewport||ao.forEach(function(Ce){if(!(Ce.local||Ce.ownScreen)){var Re=Yn.rects[Ce.peer_id];K.setVideoViewport(Ce.peer_id,{width:Re?Re.w:0,height:Re?Re.h:0,visible:!!Re&&Re.role!=="hidden"})}})});function Ed(K){if(Yn.more&&Yn.more.id===K){ge("gallery"),We(0);return}if(!(K==="local#screen"||Yn.mode==="solo")){if(q==="gallery"){ne(K),ge("speaker");return}if(K===Yn.stageId&&ue){ne(null);return}ne(K)}}
144function vu(){ge(q==="gallery"?"speaker":"gallery"),We(0),Fe(!1)}(0,i.useEffect)(function(){if(!(typeof ResizeObserver>"u")){var K=[];return[[pi,tt],[gd,we]].forEach(function(Ce){var Re=Ce[0].current;if(Re){var at=new ResizeObserver(function(lt){var Jt=lt[0].contentRect,nn=Math.round(Jt.width),Nr=Math.round(Jt.height);Ce[1](function(Zr){return Zr.w===nn&&Zr.h===Nr?Zr:{w:nn,h:Nr}})});at.observe(Re),K.push(at)}}),function(){K.forEach(function(Ce){Ce.disconnect()})}}},[]),(0,i.useEffect)(function(){ue&&!ao.some(function(K){return K.peer_id===ue})&&ne(null)},[ao.map(function(K){return K.peer_id}).join("|"),ue]),(0,i.useEffect)(function(){var K=Ic?Ic.split("|"):[];K.some(function(Ce){return!Ee.current.has(Ce)})&&q==="gallery"&&ge("speaker"),Ee.current=new Set(K)},[Ic]),(0,i.useEffect)(function(){Yn.pages&&de>Yn.pages-1&&We(Yn.pages-1)},[Yn.pages,de]),(0,i.useEffect)(function(){bi&&!_r.current&&(_r.current=!0,rt(!1))},[bi]);var bu=dl(V);function Su(K){return function(Ce){if(Ce){if(K.local){sa.current=Ce,Nn&&Ce.srcObject!==Nn&&(Ce.srcObject=Nn);return}K.ownScreen||(ll.current["v_"+K.peer_id]=Ce),K.stream&&Ce.srcObject!==K.stream&&(Ce.srcObject=K.stream)}}}function Eu(K){return function(Ce){var Re=Ce.currentTarget;Re.videoWidth&&Ue(function(at){var lt=at[K];return lt&&lt.w===Re.videoWidth&&lt.h===Re.videoHeight?at:Object.assign({},at,(function(){var Jt={};return Jt[K]={w:Re.videoWidth,h:Re.videoHeight},Jt})())})}}function Il(K){It.current=K,Xe(K)}function mi(K,Ce){try{K.currentTarget.setPointerCapture&&K.currentTarget.setPointerCapture(K.pointerId)}catch{}Il({dx:K.clientX-Ce.x,dy:K.clientY-Ce.y,x:Ce.x,y:Ce.y,sx:K.clientX,sy:K.clientY,moved:!1})}function kd(K,Ce){var Re=It.current;if(Re){var at=Math.max(0,Math.min(re.w-Ce.w,K.clientX-Re.dx)),lt=Math.max(0,Math.min(re.h-Ce.h,K.clientY-Re.dy)),Jt=Re.moved||Math.abs(K.clientX-Re.sx)>5||Math.abs(K.clientY-Re.sy)>5;Il(Object.assign({},Re,{x:at,y:lt,moved:Jt}))}}function ku(K,Ce){var Re=It.current;Re&&(Il(null),Re.moved?Pe(ww(Re.x+Ce.w/2,Re.y+Ce.h/2,re.w,re.h)):Ed(K.peer_id))}function Cd(K,Ce,Re){var at=Re||{x:0,y:0,w:0,h:0,z:0,role:"hidden"},lt=at.role==="pip",Jt=tn===K.peer_id&&!K.screen,nn=Yn.pinnedId===K.peer_id,Nr=Yn.more&&Yn.more.id===K.peer_id?Yn.more.count:0,Zr=at.role!=="hidden"&&!K.ownScreen,Mi=T0[Ce%T0.length],Ti=Jt?"0 0 0 3px rgba(212,175,92,0.25)":nn?"0 0 0 3px rgba(212,175,92,0.2)":"none",Bn=at.role!=="stage"&&at.role!=="grid",ua=$[K.peer_id]||{},fa=_w({screen:K.screen,videoW:ua.w,videoH:ua.h,boxW:at.w,boxH:at.h,role:at.role}),ja=lt&&St?St.x:at.x,ul=lt&&St?St.y:at.y;return i.createElement("div",{key:K.peer_id,"data-testid":"tile-"+K.peer_id,"data-role":at.role,"data-pinned":nn?"1":"0",role:Zr?"button":void 0,tabIndex:Zr?0:void 0,"aria-label":Zr?Nr>0?"Show all "+Nr+" more participants":(nn?"Unpin ":"Pin ")+K.user_name:void 0,onClick:function(){!lt&&Zr&&Ed(K.peer_id)},onKeyDown:function(Ni){Zr&&(Ni.key==="Enter"||Ni.key===" ")&&(Ni.preventDefault(),Ed(K.peer_id))},onPointerDown:lt?function(Ni){mi(Ni,at)}:void 0,onPointerMove:lt?function(Ni){kd(Ni,at)}:void 0,onPointerUp:lt?function(){ku(K,at)}:void 0,onPointerCancel:lt?function(){Il(null)}:void 0,style:{position:"absolute",left:ja,top:ul,width:at.w,height:at.h,zIndex:at.z,display:at.role==="hidden"?"none":"flex",overflow:"hidden",borderRadius:lt?12:14,background:"linear-gradient(145deg,#0C1018,#0A0E16)",border:"1.5px solid "+(Jt||nn||lt?"#D4AF5C":"rgba(28,39,64,0.6)"),boxShadow:Ti+",0 4px 20px rgba(0,0,0,0.3)",alignItems:"center",justifyContent:"center",cursor:lt?St?"grabbing":"grab":Zr?"pointer":"default",touchAction:lt?"none":"auto",transition:St?"none":"left .22s ease,top .22s ease,width .22s ease,height .22s ease"}},K.hasVideo?i.createElement("video",{ref:Su(K),onLoadedMetadata:Eu(K.peer_id),onResize:Eu(K.peer_id),autoPlay:!0,playsInline:!0,muted:!0,style:{width:"100%",height:"100%",objectFit:fa,borderRadius:12,background:"#000",transform:K.local?"scaleX(-1)":"none"}}):i.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:10}},i.createElement("div",{style:{width:Bn?40:80,height:Bn?40:80,borderRadius:"50%",background:"linear-gradient(135deg,"+Mi+"15,"+Mi+"08)",border:"2.5px solid "+Mi+"50",display:"flex",alignItems:"center",justifyContent:"center",fontSize:Bn?14:28,fontWeight:700,color:Mi}},(K.user_name||"?")[0].toUpperCase()),!Bn&&i.createElement("span",{style:{fontSize:13,color:"#8B949E",fontFamily:"'Inter',system-ui,sans-serif",fontWeight:500}},K.user_name)),Nr>0&&i.createElement("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(5,8,13,0.7)",color:"#E6EDF3",fontSize:15,fontWeight:700}},"+"+Nr),nn&&at.role==="stage"&&i.createElement("button",{"data-testid":"unpin",title:"Unpin",onClick:function(Ni){Ni.stopPropagation(),ne(null)},style:{position:"absolute",top:10,right:10,display:"flex",alignItems:"center",gap:6,background:"rgba(212,175,92,0.92)",color:"#08111A",border:"none",borderRadius:6,padding:"5px 10px",fontSize:10,fontWeight:800,letterSpacing:".08em",cursor:"pointer",fontFamily:"'Inter',system-ui,sans-serif"}},i.createElement(nu,{d:cr.pin,size:11,color:"#08111A"}),"PINNED · UNPIN"),i.createElement("div",{style:{position:"absolute",bottom:8,left:8,right:Bn?8:"auto",maxWidth:"calc(100% - 16px)",display:"flex",alignItems:"center",gap:6,background:"rgba(5,8,13,0.75)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",padding:Bn?"3px 7px":"5px 10px",borderRadius:8}},!K.screen&&i.createElement("div",{style:{width:7,height:7,flexShrink:0,borderRadius:"50%",background:K.local&&k?"#D44040":"#3FB950",boxShadow:"0 0 6px "+(K.local&&k?"rgba(255,68,68,0.4)":"rgba(63,185,80,0.4)")}}),i.createElement("span",{style:{fontSize:Bn?9:10,color:"#E6EDF3",fontFamily:"'Inter',system-ui,sans-serif",fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},K.user_name),Jt&&i.createElement("div",{style:{display:"flex",alignItems:"center",gap:2}},[3,5,3].map(function(Ni,Yo){return i.createElement("div",{key:Yo,style:{width:2,height:Ni+3,background:"#D4AF5C",borderRadius:1,animation:"xpulse 0.6s ease "+Yo*.15+"s infinite"}})})),nn&&i.createElement(nu,{d:cr.pin,size:12,color:"#D4AF5C"})),K.local&&nt&&i.createElement("div",{style:{position:"absolute",top:10,right:10,fontSize:Bn?16:24,animation:"xbou
144nce 0.6s ease infinite"}},"✋"))}function ls(){return i.createElement("div",{style:{position:"absolute",bottom:"calc(100% + 10px)",left:"50%",transform:"translateX(-50%)",width:340,background:"rgba(8,11,17,0.94)",border:"1px solid rgba(212,175,92,0.30)",borderRadius:10,padding:10,boxShadow:"0 18px 50px rgba(0,0,0,0.58)",backdropFilter:"blur(18px) saturate(130%)",WebkitBackdropFilter:"blur(18px) saturate(130%)",zIndex:40}},i.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8}},i.createElement("span",{style:{fontSize:10,color:"#D4AF5C",fontWeight:800,letterSpacing:".12em",textTransform:"uppercase"}},"Backgrounds"),i.createElement("button",{onClick:function(){W(!1)},style:{background:"transparent",border:"none",color:"#5A7090",cursor:"pointer",fontSize:16,lineHeight:1,padding:"0 4px"}},"×")),i.createElement("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8}},Ag.map(function(K){var Ce=V===K.id;return i.createElement("button",{key:K.id,onClick:function(){ho(K.id)},onMouseEnter:function(){ny(K).catch(function(){})},style:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:6,padding:6,background:Ce?"rgba(212,175,92,0.12)":"rgba(5,8,13,0.62)",border:"1px solid "+(Ce?"rgba(212,175,92,0.58)":"rgba(90,112,144,0.28)"),borderRadius:8,color:Ce?"#E4C27A":"#C9D1D9",cursor:"pointer",fontFamily:"'Inter',system-ui,sans-serif",boxShadow:Ce?"0 0 16px rgba(212,175,92,0.10)":"none",minHeight:78,textAlign:"left"}},i.createElement("div",{style:{position:"relative",width:"100%",aspectRatio:"16/9",borderRadius:6,overflow:"hidden",border:"1px solid rgba(255,255,255,0.12)",background:Dw(K),boxShadow:"inset 0 -18px 30px rgba(0,0,0,0.18)"}},Ce&&i.createElement("div",{style:{position:"absolute",top:5,right:5,width:18,height:18,borderRadius:"50%",background:"rgba(212,175,92,0.95)",color:"#08111A",display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,fontWeight:900,boxShadow:"0 2px 8px rgba(0,0,0,0.35)"}},"✓")),i.createElement("span",{style:{fontSize:10,fontWeight:800,letterSpacing:".04em",textAlign:"left",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},K.label))})))}return i.createElement("div",{ref:pi,style:{width:"100%",height:"100%",background:"#05080D",display:"flex",flexDirection:"column",fontFamily:"'Inter',system-ui,sans-serif",position:"relative"}},Ai&&i.createElement(s2,{defaultName:"",onSave:xu}),i.createElement(bw,{open:wl,onClose:function(){Ha(!1)}}),i.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 20px",background:"rgba(6,8,13,0.9)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",borderBottom:"1px solid rgba(28,39,64,0.4)",flexShrink:0,zIndex:10}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:12}},i.createElement("div",{style:{width:8,height:8,borderRadius:"50%",background:c?"#3FB950":qt==="failed"?"#D44040":"#D4AF5C",boxShadow:"0 0 10px "+(c?"rgba(63,185,80,0.5)":"rgba(212,175,92,0.5)"),transition:"all .4s"}}),i.createElement("span",{style:{fontSize:11,fontWeight:700,color:"#D4AF5C",letterSpacing:".12em",fontFamily:"monospace"}},"XYRON"),i.createElement("span",{style:{fontSize:13,color:"#E6EDF3",fontWeight:600,fontVariantNumeric:"tabular-nums"}},zo(g)),i.createElement("span",{style:{fontSize:10,color:"#3A4A5E",fontWeight:500}},Aa," participant"+(Aa!==1?"s":"")),w&&i.createElement("div",{style:{display:"flex",alignItems:"center",gap:4,background:"rgba(255,68,68,0.08)",padding:"3px 8px",borderRadius:6}},i.createElement("div",{style:{width:6,height:6,borderRadius:"50%",background:"#D44040",animation:"xpulse 1s infinite"}}),i.createElement("span",{style:{fontSize:9,color:"#D44040",fontWeight:600}},"REC")),c&&i.createElement("div",{style:{display:"flex",alignItems:"center",gap:4,background:"rgba(63,185,80,0.06)",padding:"3px 8px",borderRadius:6}},i.createElement("div",{style:{width:5,height:5,borderRadius:"50%",background:"#3FB950"}}),i.createElement("span",{style:{fontSize:9,color:"#3FB950",fontWeight:500}},"LIVE")),Qe!=="idle"&&i.createElement("div",{title:Y||"Transcription",style:{display:"flex",alignItems:"center",gap:5,background:Qe==="live"?"rgba(63,185,80,0.06)":Qe==="degraded"?"rgba(212,175,92,0.06)":"rgba(90,112,144,0.08)",padding:"3px 8px",borderRadius:6}},i.createElement("div",{style:{width:5,height:5,borderRadius:"50%",background:Qe==="live"?"#3FB950":Qe==="degraded"?"#D4AF5C":"#5A7090"}}),i.createElement("span",{style:{fontSize:9,color:Qe==="live"?"#3FB950":Qe==="degraded"?"#D4AF5C":"#5A7090",fontWeight:600,letterSpacing:".06em"}}
144,Qe==="live"?"TRANSCRIPT":Qe==="degraded"?"TRANSCRIPT RETRY":"TRANSCRIPT OFF"),H&&i.createElement("span",{style:{fontSize:8,color:"#5A7090",fontWeight:500}},H==="vertex_live"?"VERTEX":"")),$n&&$n.sentiment!=="neutral"&&i.createElement("div",{style:{fontSize:9,fontWeight:600,color:$n.sentiment==="positive"?"#3FB950":"#D44040",background:$n.sentiment==="positive"?"rgba(63,185,80,0.06)":"rgba(255,68,68,0.06)",padding:"3px 10px",borderRadius:6}},$n.sentiment==="positive"?"↑ Positive":"↓ Caution")),i.createElement("div",{style:{display:"flex",alignItems:"center",gap:6}},!bi&&Xd(q==="gallery"?cr.spotlight:cr.grid,q==="gallery"?"Speaker":"Gallery",vu,q==="gallery"),!bi&&Xd(cr.copilot,"Copilot",function(){rt(!Q)},Q),!bi&&Xd("M12 20h9 M16.5 3.5a2.121 2.121 0 113 3L7 19l-4 1 1-4L16.5 3.5z","Prompter",function(){kl(!Sa)},Sa),!bi&&Xd("M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z","Ask",function(){Ds(!ts)},ts),!bi&&Xd("M5 8l6 6 M4 14l6-6 2-3 M2 5h12 M7 2h1 M22 22l-5-10-5 10 M14 18h6","Subtitle",function(){var K=["none","en","ja","ar","zh-CN","fr","es","de"];po(K[(K.indexOf(or)+1)%K.length])},or!=="none"),!bi&&Xd(cr.fullscreen,Le?"Exit FS":"Fullscreen",gi),!bi&&Xd(cr.pip,Te?"Exit PiP":"PiP",Sd),i.createElement("button",{onClick:Ca,title:"End call (Esc)",style:{display:"flex",alignItems:"center",gap:7,padding:"6px 16px",background:"rgba(200,92,92,0.08)",border:"1px solid rgba(212,175,92,0.45)",borderRadius:6,cursor:"pointer",fontSize:10,fontWeight:700,letterSpacing:".1em",color:"#E4C27A",boxShadow:"inset 0 1px 0 rgba(228,194,122,0.12)",transition:"all .15s cubic-bezier(.16,.84,.24,1)",fontFamily:"'Inter',system-ui,sans-serif"},onMouseEnter:function(K){K.currentTarget.style.background="rgba(200,92,92,0.14)",K.currentTarget.style.borderColor="rgba(212,175,92,0.65)"},onMouseLeave:function(K){K.currentTarget.style.background="rgba(200,92,92,0.08)",K.currentTarget.style.borderColor="rgba(212,175,92,0.45)"}},i.createElement(nu,{d:cr.end,size:13,color:"#C85C5C"}),x?"SAVING…":"END CALL"))),$n&&($n.actions_detected.length>0||Object.keys($n.entities).length>0)&&i.createElement("div",{style:{padding:"5px 20px",background:"rgba(212,175,92,0.03)",borderBottom:"1px solid rgba(212,175,92,0.08)",display:"flex",alignItems:"center",gap:14,flexShrink:0,fontSize:10,animation:"xfadein 0.3s"}},$n.actions_detected.length>0&&i.createElement("span",{style:{color:"#C85C5C",display:"flex",alignItems:"center",gap:5,fontWeight:600}},i.createElement("div",{style:{width:5,height:5,borderRadius:"50%",background:"#C85C5C",animation:"xpulse 1s infinite"}}),"Action: ",$n.actions_detected[0]),$n.entities.money&&i.createElement("span",{style:{color:"#3FB950",fontWeight:500}},"💰 ",$n.entities.money.join(", ")),$n.entities.date&&i.createElement("span",{style:{color:"#6B9AC4",fontWeight:500}},"📅 ",$n.entities.date.join(", "))),i.createElement("div",{style:{flex:1,display:"flex",overflow:"hidden",position:"relative"}},i.createElement("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"}},i.createElement("div",{style:{flex:1,padding:10,overflow:"hidden",display:"flex",flexDirection:"column",gap:10}},i.createElement("div",{ref:gd,"data-testid":"call-stage","data-mode":Yn.mode,style:{position:"relative",flex:c?1:"0 0 0px",minHeight:0,overflow:"hidden",display:c?"block":"none"}},ao.map(function(K,Ce){return Cd(K,Ce,Yn.rects[K.peer_id])}),Yn.presenting&&i.createElement("div",{"data-testid":"presenting-chip",style:{position:"absolute",top:10,left:10,zIndex:5,display:"flex",alignItems:"center",gap:6,background:"rgba(5,8,13,0.8)",border:"1px solid rgba(107,154,196,0.45)",borderRadius:8,padding:"5px 10px",fontSize:10,fontWeight:700,color:"#6B9AC4",letterSpacing:".06em"}},i.createElement(nu,{d:cr.screen,size:12,color:"#6B9AC4"}),"YOU ARE PRESENTING"),Yn.mode==="gallery"&&Yn.pages>1&&i.createElement("div",{"data-testid":"gallery-pager",style:{position:"absolute",left:"50%",bottom:10,transform:"translateX(-50%)",zIndex:5,display:"flex",alignItems:"center",gap:10,background:"rgba(5,8,13,0.8)",border:"1px solid rgba(212,175,92,0.3)",borderRadius:16,padding:"4px 12px",fontSize:11,color:"#E6EDF3"}},i.createElement("button",{"aria-label":"Previous page",disabled:Yn.page===0,onClick:function(){We(Math.max(0,Yn.page-1))},style:{background:"none",border:"none",color:"#D4AF5C",fontSize:16,cursor:"pointer",padding:"0 4px"}},"‹"),i.createElement("span",null,Yn.page+1+" / "+Yn.pages),i.createElement("button",{"aria-label":"Next page",disabled:Yn.page>=Yn.pages-1,onClick:function(){We(Yn.page+1)},style:{background:"none",border:"none",color:"#D4AF5C",fontSize:16,cursor:"pointer",padding:"0 4px"}},"›")),Yn.stripHidden&&Yn.more&&Yn.more.count>0&&i.createElement("button",{"data-testid":"strip-toggle",title:"Show participants",onClick:function(){ve(!0)},style:Fv},"▦ "+Yn.more.count+" MORE"),_e&&!Yn.stripHidden&&Yn.mode==="speaker"&&bi&&i.createElement("button",{"data-testid":"strip-toggle",title:"Hide participants",onClick:function(){ve(!1)},style:Fv},"✕ HIDE")),ci.filter(function(K){return K.stream}).map(function(K){return i.createElement(Iw,{key:"a_"+K.peer_id,stream:K.stream})}),!c&&qt!=="failed"&&i.createElement("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column",gap:16}},i.createElement("div",{style:{width:40,height:40,border:"3px solid #1C2740",borderTop:"3px solid #D4AF5C",borderRadius:"50%",animation:"xspin 0.8s linear infinite"}}),i.createElement("span",{style:{fontSize:12,color:"#5A7090",fontWeight:500}},"Connecting to secure call…")),qt==="failed"&&i.createElement("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column",gap:12}},i.createElement(nu,{d:cr.close,size:36,color:"#D44040"}),i.createElement("span",{style:{fontSize:14,color:"#D44040",fontWeight:600}},"Connection Failed"),i.createElement("span",{style:{fontSize:11,color:"#5A7090"}},"Check your camera/mic permissions and network"))),xe&&i.createElement("div",{style:{textAlign:"center",padding:"6px 20px",fontSize:11,color:"#D4AF5C",background:"rgba(212,175,92,0.04)",borderTop:"1px solid rgba(212,175,92,0.08)",fontWeight:500,animation:"xfadein 0.2s"}},xe),bi&&Be&&i.createElement("div",{"data-testid":"more-sheet",style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:6,padding:"10px 10px 0",justifyItems:"center",borderTop:"1px solid rgba(212,175,92,0.14)"}},Aa>1&&Ci(q==="gallery"?cr.spotlight:cr.grid,q==="gallery"?"Speaker":"Gallery",vu,q==="gallery","#D4AF5C"),Qi()&&Ci(cr.screen,U?"Stop Share":"Share Screen",function(){Fe(!1),Rc()},U,"#D4AF5C"),i.createElement("div",{style:{position:"relative",display:"flex"}},Ci(cr.blur,V==="none"?"Effects":bu.short,Oo,R,"#D4AF5C"),P&&ls()),Ci(cr.re
144cord,w?"Stop":"Record",function(){Fe(!1),oo()},w,"#C85C5C"),Ci(cr.hand,nt?"Lower":"Raise Hand",function(){Fe(!1),Zi()},nt,"#D4AF5C"),Ci(cr.invite,"Invite",function(){Fe(!1),kr()},!1,"#D4AF5C"),Ci("M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0-18 0 M12 7v5l3 3","History",function(){Fe(!1),Ha(!wl)},wl,"#D4AF5C"),Ci("M12 20h9 M16.5 3.5a2.121 2.121 0 113 3L7 19l-4 1 1-4L16.5 3.5z","Prompter",function(){Fe(!1),kl(!Sa)},Sa,"#D4AF5C"),Ci("M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z","Ask",function(){Fe(!1),Ds(!ts)},ts,"#D4AF5C"),Ci("M5 8l6 6 M4 14l6-6 2-3 M2 5h12 M7 2h1 M22 22l-5-10-5 10 M14 18h6","Subtitle",function(){var K=["none","en","ja","ar","zh-CN","fr","es","de"];po(K[(K.indexOf(or)+1)%K.length])},or!=="none","#D4AF5C"),Lo()&&Ci(cr.pip,Te?"Exit PiP":"PiP",function(){Fe(!1),Sd()},Te,"#D4AF5C")),i.createElement("div",{"data-testid":"call-controls",style:{display:"flex",alignItems:"center",justifyContent:"center",padding:bi?"8px 8px calc(8px + env(safe-area-inset-bottom, 0px))":"12px 20px",flexShrink:0}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"6px 10px",background:"rgba(8,11,17,0.82)",backdropFilter:"blur(16px) saturate(120%)",WebkitBackdropFilter:"blur(16px) saturate(120%)",border:"1px solid rgba(212,175,92,0.30)",borderRadius:12,boxShadow:"0 12px 40px rgba(0,0,0,0.5), inset 0 1px 0 rgba(228,194,122,0.10), 0 0 24px rgba(212,175,92,0.06)"}},bi?i.createElement(i.Fragment,null,Ci(k?cr.micOff:cr.mic,k?"Unmute":"Mute",bd,k,"#C85C5C"),Ci(E?cr.camOff:cr.cam,E?"Show Cam":"Hide Cam",yo,E,"#C85C5C"),!a&&Ci(cr.copilot,"Copilot",function(){rt(!Q)},Q,"#D4AF5C"),Ci(cr.more,"More",function(){Fe(!Be)},Be||w||U,"#D4AF5C")):i.createElement(i.Fragment,null,Ci(k?cr.micOff:cr.mic,k?"Unmute":"Mute",bd,k,"#C85C5C"),Ci(E?cr.camOff:cr.cam,E?"Show Cam":"Hide Cam",yo,E,"#C85C5C"),Ci(cr.screen,U?"Stop Share":"Share Screen",Rc,U,"#D4AF5C"),i.createElement("div",{style:{position:"relative",display:"flex"}},Ci(cr.blur,V==="none"?"Effects":bu.short,Oo,R,"#D4AF5C"),P&&ls()),i.createElement("div",{style:{width:1,height:28,background:"rgba(212,175,92,0.22)",margin:"0 6px"}}),Ci(cr.record,w?"Stop":"Record",oo,w,"#C85C5C"),Ci("M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0-18 0 M12 7v5l3 3","History",function(){Ha(!wl)},wl,"#D4AF5C"),Ci(cr.hand,nt?"Lower":"Raise Hand",Zi,nt,"#D4AF5C"),i.createElement("div",{style:{width:1,height:28,background:"rgba(212,175,92,0.22)",margin:"0 6px"}}),Ci(cr.invite,"Invite",kr,!1,"#D4AF5C"),i.createElement("div",{style:{display:"flex",alignItems:"center",gap:3,marginLeft:6}},ao.slice(0,6).map(function(K,Ce){var Re=T0[Ce%T0.length];return i.createElement("div",{key:K.peer_id,title:K.user_name,style:{width:26,height:26,borderRadius:"50%",background:Re+"15",border:"2px solid "+(tn===K.peer_id?Re:Re+"30"),display:"flex",alignItems:"center",justifyContent:"center",fontSize:9,fontWeight:700,color:Re,transition:"all .3s",fontFamily:"'Inter',system-ui,sans-serif"}},(K.user_name||"?")[0].toUpperCase())}),ao.length>6&&i.createElement("span",{style:{fontSize:9,color:"#3A4A5E",marginLeft:2}},"+",ao.length-6)))))),i.createElement("div",{"data-testid":"copilot-holder",style:bi&&Q&&!a?{position:"absolute",left:0,right:0,bottom:0,height:"62%",zIndex:30,display:"flex",borderTop:"1px solid rgba(212,175,92,0.3)",borderRadius:"14px 14px 0 0",overflow:"hidden",boxShadow:"0 -12px 30px rgba(0,0,0,0.55)"}:{display:"contents"}},bi&&Q&&!a&&i.createElement("button",{"aria-label":"Close the copilot",onClick:function(){rt(!1)},style:{position:"absolute",top:6,left:"50%",transform:"translateX(-50%)",width:44,height:5,borderRadius:3,border:"none",background:"rgba(212,175,92,0.45)",zIndex:2,cursor:"pointer"}}),!a&&Q&&i.createElement(dw,{transcriptLines:Mt,copilotCards:br,elapsed:g,participants:he,liveIntel:$n,decisions:mu,room:t,sheet:bi})),Sa&&i.createElement(Kw,{script:to,setScript:oa,playing:il,setPlaying:Pa,wpm:Al,setWpm:es,progress:uc,setProgress:fi,adherence:Fs,busy:dd,error:Ua,meta:aa,setMeta:gc,setAdherence:Xi,onDraft:xd,onClose:function(){kl(!1)}}),ts&&i.createElement(qw,{q:la,setQ:hc,a:yc,busy:dr,onAsk:Ji,onClose:function(){Ds(!1)}}),or!=="none"&&qi&&i.createElement("div",{style:{position:"absolute",bottom:96,left:"50%",transform:"translateX(-50%)",maxWidth:"58%",padding:"6px 14px",background:"rgba(3,5,8,0.72)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",borderBottom:"1px solid rgba(212,175,92,0.35)",fontFamily:"'Inter',system-ui,sans-serif",fontSize:13,color:"#E2E8F0",fontWeight:500,zIndex:15,pointerEvents:"none",textAlign:"center",letterSpacing:".01em",display:"flex",alignItems:"center",gap:10}},i.createElement("span",{style:{fontSize:8,color:"#D4AF5C",letterSpacing:".22em",fontWeight:700,textTransform:"uppercase",flexShrink:0}},or),i.createElement("span",{style:{flex:1}},qi)),tr.length>0&&!Q&&i.createElement(Xw,{chapters:tr})),i.createElement("style",null,["@keyframes xspin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}","@keyframes xfloat{0%{transform:translateY(0);opacity:1}100%{transform:translateY(-120px);opacity:0}
144}","@keyframes xbounce{0%,100%{transform:translateY(0)}50%{transform:translateY(-6px)}}"].join("")))}function Iw(t){var n=(0,i.useRef)(null);return(0,i.useEffect)(function(){var r=n.current;r&&t.stream&&r.srcObject!==t.stream&&(r.srcObject=t.stream)},[t.stream]),i.createElement("audio",{ref:n,autoPlay:!0,playsInline:!0,style:{display:"none"}})}var Fv={position:"absolute",right:10,top:10,zIndex:6,background:"rgba(5,8,13,0.8)",border:"1px solid rgba(212,175,92,0.35)",color:"#E6EDF3",borderRadius:8,padding:"6px 10px",fontSize:10,fontWeight:700,letterSpacing:".06em",cursor:"pointer",fontFamily:"'Inter',system-ui,sans-serif"};function Xd(t,n,r,o){var a=o?"rgba(212,175,92,0.10)":"rgba(212,175,92,0.02)",l=o?"rgba(212,175,92,0.45)":"rgba(212,175,92,0.18)",s=o?"#E4C27A":"#D4AF5C",c=o?"inset 0 1px 0 rgba(228,194,122,0.14), 0 0 14px rgba(212,175,92,0.12)":"inset 0 1px 0 rgba(228,194,122,0.04)";return i.createElement("button",{onClick:r,title:n,style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",background:a,border:"1px solid "+l,borderRadius:6,cursor:"pointer",fontSize:10,color:s,fontWeight:600,letterSpacing:".08em",boxShadow:c,transition:"all .15s cubic-bezier(.16,.84,.24,1)",fontFamily:"'Inter',system-ui,sans-serif"},onMouseEnter:function(d){d.currentTarget.style.borderColor="rgba(212,175,92,0.55)",d.currentTarget.style.background="rgba(212,175,92,0.08)",d.currentTarget.style.color="#E4C27A"},onMouseLeave:function(d){d.currentTarget.style.borderColor=l,d.currentTarget.style.background=a,d.currentTarget.style.color=s}},i.createElement(nu,{d:t,size:13,color:o?"#E4C27A":"#D4AF5C"}),n)}function Ci(t,n,r,o,a){var l=o&&a||"#D4AF5C",s=o?"rgba("+_0(a||"#D4AF5C")+",0.12)":"rgba(212,175,92,0.04)",c=o?"rgba("+_0(a||"#D4AF5C")+",0.45)":"rgba(212,175,92,0.22)",d=o?"#E4C27A":"#D4AF5C",p=o?"inset 0 1px 0 rgba(228,194,122,0.14), 0 0 14px rgba(212,175,92,0.12)":"inset 0 1px 0 rgba(228,194,122,0.04)";return i.createElement("button",{onClick:r,title:n,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:3,padding:"8px 12px",background:s,border:"1px solid "+c,borderRadius:8,cursor:"pointer",color:d,transition:"all .15s cubic-bezier(.16,.84,.24,1)",minWidth:56,boxShadow:p,fontFamily:"'Inter',system-ui,sans-serif"},onMouseEnter:function(g){g.currentTarget.style.transform="translateY(-1px)",g.currentTarget.style.borderColor=o?"rgba("+_0(a||"#D4AF5C")+",0.65)":"rgba(212,175,92,0.45)",g.currentTarget.style.background=o?"rgba("+_0(a||"#D4AF5C")+",0.16)":"rgba(212,175,92,0.08)"},onMouseLeave:function(g){g.currentTarget.style.transform="translateY(0)",g.currentTarget.style.borderColor=c,g.currentTarget.style.background=s}},i.createElement(nu,{d:t,size:18,color:l}),i.createElement("span",{style:{fontSize:9,fontWeight:700,letterSpacing:".08em",color:d,textTransform:"uppercase"}},n))}function _0(t){if(!t)return"255,255,255";var n=parseInt(t.slice(1,3),16),r=parseInt(t.slice(3,5),16),o=parseInt(t.slice(5,7),16);return n+","+r+","+o}function f2(t){return Ag.find(function(n){return n.id===t})||Ag[0]}function Dw(t){var n=typeof t=="string"?f2(t):t;return n&&n.asset?'linear-gradient(180deg, rgba(0,0,0,0.02), rgba(0,0,0,0.34)), url("'+n.asset+'") center / cover no-repeat':(n&&n.id)==="blur"?"linear-gradient(135deg,#20293A,#D4AF5C 58%,#111820)":"linear-gradient(135deg,#0A0E16,#1C2740)"}function Ow(){Ag.forEach(function(t){ny(t).catch(function(){})})}function ny(t){if(!t||!t.asset||typeof Image>"u")return Promise.resolve(null);var n=t.asset,r=Dp[n];if(r&&r.status==="loaded")return Promise.resolve(r.image);if(r&&r.promise)return r.promise;var o=new Image;o.decoding="async",o.loading="eager";var a=new Promise(function(l,s){o.onload=function(){Dp[n]={status:"loaded",image:o,promise:a},l(o)},o.onerror=function(){Dp[n]={status:"error",image:null,promise:null},s(new Error("background image failed"))}});return Dp[n]={status:"loading",image:o,promise:a},o.src=n,a}function Lw(t){if(!t||!t.asset)return null;var n=Dp[t.asset];return n&&n.status==="loaded"&&n.image&&n.image.complete?n.image:null}function Rf(t){if(t)try{t.imageSmoothingEnabled=!0,t.imageSmoothingQuality="high"}catch{}}function Up(t,n,r,o){Rf(t);
144var a=n.videoWidth||n.naturalWidth||n.width||r,l=n.videoHeight||n.naturalHeight||n.height||o,s=a/l,c=r/o,d=0,p=0,g=a,f=l;s>c?(g=l*c,d=(a-g)/2):(f=a/c,p=(l-f)/2),t.drawImage(n,d,p,g,f,0,0,r,o)}function $l(t,n,r){$l.cache||($l.cache={});var o=$l.cache[t];return o||(o=document.createElement("canvas"),$l.cache[t]=o),o.width!==n&&(o.width=n),o.height!==r&&(o.height=r),o}function p2(t,n,r,o,a,l){if(Rf(t),r.id==="blur"){t.save(),t.fillStyle="#05080D",t.fillRect(0,0,o,a),t.filter="blur(24px) saturate(120%) brightness(0.82)",Up(t,n,o,a),t.restore(),t.fillStyle="rgba(3,5,8,0.18)",t.fillRect(0,0,o,a);return}var s=Lw(r);if(s){Up(t,s,o,a),t.fillStyle="rgba(0,0,0,0.08)",t.fillRect(0,0,o,a);return}zw(t,r.id,o,a,l)}function zw(t,n,r,o,a){var l=t.createLinearGradient(0,0,r,o);n==="market"?(l.addColorStop(0,"#04100B"),l.addColorStop(.48,"#10221B"),l.addColorStop(1,"#5C4820")):n==="studio"?(l.addColorStop(0,"#17070A"),l.addColorStop(.52,"#222026"),l.addColorStop(1,"#7A4E2A")):n==="library"?(l.addColorStop(0,"#100C08"),l.addColorStop(.48,"#24201A"),l.addColorStop(1,"#223348")):(l.addColorStop(0,"#111820"),l.addColorStop(.5,"#233143"),l.addColorStop(1,"#5E522F")),t.fillStyle=l,t.fillRect(0,0,r,o),t.save(),t.globalAlpha=.16,t.strokeStyle=n==="market"?"#3FB950":n==="studio"?"#E4C27A":n==="library"?"#B0BCC8":"#6B9AC4",t.lineWidth=1;for(var s=0;s<r;s+=80)t.beginPath(),t.moveTo(s,0),t.lineTo(s,o),t.stroke();for(var c=0;c<o;c+=70)t.beginPath(),t.moveTo(0,c),t.lineTo(r,c),t.stroke();if(t.restore(),n==="market"){t.save(),t.globalAlpha=.3,t.strokeStyle="#3FB950",t.lineWidth=2,t.beginPath();for(var d=0;d<18;d++){var p=d*r/17,g=o*.58+Math.sin(d*.9+(a||0)/900)*o*.08;d===0?t.moveTo(p,g):t.lineTo(p,g)}t.stroke(),t.restore()}else if(n==="library"){t.save(),t.globalAlpha=.22;for(var f=0;f<4;f++)for(var h=0;h<12;h++)t.fillStyle=h%3===0?"#D4AF5C":h%3===1?"#6B9AC4":"#B0BCC8",t.fillRect(24+h*72,36+f*98,38,68);t.restore()}else t.save(),t.globalAlpha=.24,t.fillStyle=n==="studio"?"#C85C5C":"#D4AF5C",t.beginPath(),t.arc(r*.82,o*.18,110,0,Math.PI*2),t.fill(),t.fillStyle=n==="office"?"#6B9AC4":"#E4C27A",t.beginPath(),t.arc(r*.16,o*.78,130,0,Math.PI*2),t.fill(),t.restore();t.fillStyle="rgba(0,0,0,0.22)",t.fillRect(0,0,r,o)}var Mw=1280,Nw=720;function ry(t,n){t=Math.round(t)||960,n=Math.round(n)||540;var r=Math.min(1,Mw/t,Nw/n);return t=Math.round(t*r),n=Math.round(n*r),t%2&&(t+=1),n%2&&(n+=1),{w:Math.max(2,t),h:Math.max(2,n)}}function Bw(t){var n=t&&t.getSettings&&t.getSettings()||{};return n.width&&n.height?ry(n.width,n.height):ry(960,540)}var Pw=320,Uw=2,Ww=.45,Ym=1,Hw=.4,Gw=.65;function Vw(t,n){var r=Math.min(Pw,t),o=Math.max(2,Math.round(r*n/Math.max(1,t)));return{w:Math.max(2,r),h:o}}function Iv(){vf._prev=null,$l.cache&&$l.cache.matte&&delete $l.cache.matte}function vf(t,n,r){var o=Vw(n,r),a=$l("matte",o.w,o.h).getContext("2d",{willReadFrequently:!0});if(a){Rf(a),a.clearRect(0,0,o.w,o.h),Up(a,t,o.w,o.h);var l;try{l=a.getImageData(0,0,o.w,o.h)}catch{return}var s=l.data,c=s.length>>2,d=vf._prev,p=!1;(!d||d.length!==c)&&(d=vf._prev=new Float32Array(c),p=!0);for(var g=Ww,f=0,h=new Uint32Array(256),x=0,v=0;v<s.length;v+=4){var y=s[v]*.299+s[v+1]*.587+s[v+2]*.114,k=y<=0?0:y>=255?255:Math.round(y);h[k]++,k>f&&(f=k),k>8&&x++}var A=f;if(x>0){for(var j=Math.max(1,Math.round(x*.01)),E=0,C=f;C>=0;C--)if(E+=h[C],E>=j){A=C;break}}for(var _=A>8?1/A:0,w=Hw,O=Gw,M=O-w||1,U=0,ee=0;U<s.length;U+=4,ee++){var N=(s[U]*.299+s[U+1]*.587+s[U+2]*.114)*_,V;if(N<=w)V=0;else if(N>=O)V=1;else{var z=(N-w)/M;V=z*z*(3-2*z)}var oe=p?V:d[ee]+(V-d[ee])*g;d[ee]=oe,s[U]=0,s[U+1]=0,s[U+2]=0,s[U+3]=oe<=.02?0:oe>=.98?255:Math.round(oe*255)}if(Ym>0){var P=o.w,W=o.h,R=vf._erode;(!R||R.length!==c)&&(R=vf._erode=new Uint8Array(c));for(var ae=0;ae<c;ae++)R[ae]=s[ae*4+3];for(var q=0;q<Ym;q++){for(var ge=0;ge<W;ge++)for(var X=0;X<P;X++){var de=ge*P+X,We=R[de];X>0&&R[de-1]<We&&(We=R[de-1]),X+1<P&&R[de+1]<We&&(We=R[de+1]),ge>0&&R[de-P]<We&&(We=R[de-P]),ge+1<W&&R[de+P]<We&&(We=R[de+P]),s[de*4+3]=We}if(q+1<Ym)for(var te=0;te<c;te++)R[te]=s[te*4+3]}}a.putImageData(l,0,0)}}function Yw(t,n,r,o,a,l){var s=$l.cache&&$l.cache.matte;if(!s){lg(t,n,r,o,a,l);return}try{var c=$l("person",o,a),d=c.getContext("2d");if(!d){lg(t,n,r,o,a,l);return}d.clearRect(0,0,o,a),d.save(),Rf(d),"filter"in d&&(d.filter="blur("+Uw+"px)"),d.drawImage(s,0,0,s.width,s.height,0,0,o,a),"filter"in d&&(d.filter="none"),d.globalCompositeOperation="source-in",Up(d,n,o,a),d.restore(
144),t.clearRect(0,0,o,a),p2(t,n,r,o,a,l),t.drawImage(c,0,0,o,a)}catch{lg(t,n,r,o,a,l)}}function lg(t,n,r,o,a,l){t.clearRect(0,0,o,a),p2(t,n,r,o,a,l),Up(t,n,o,a)}function Kw(t){var n=t.script||"",r=t.setScript,o=t.playing,a=t.setPlaying,l=t.wpm,s=t.setWpm,c=t.progress,d=t.setProgress,p=t.adherence||0,g=!!t.busy,f=t.error||"",h=t.meta||null,x=t.setMeta||function(){},v=t.setAdherence||function(){},y=t.onDraft,k=t.onClose,A=Gm[0],j=i.useState(A.topic),E=j[0],C=j[1],_=i.useState(!n),w=_[0],O=_[1],M=i.useState(A.id),U=M[0],ee=M[1],N=i.useState(A.duration),V=N[0],z=N[1],oe=i.useState(A.tone),P=oe[0],W=oe[1],R=i.useState(A.audience),ae=R[0],q=R[1],ge=i.useState(0),X=ge[0],de=ge[1],We=i.useRef(null),te=i.useRef(null),_e=i.useRef(0);function ve(b){var He=Gm.find(function(tt){return tt.id===b})||A;ee(He.id),C(He.topic),W(He.tone),q(He.audience),z(He.duration)}function Ne(){if(!(g||!y)){var b=y({topic:E,duration_minutes:V,tone:P,audience:ae});b&&typeof b.then=="function"?b.then(function(He){He&&O(!1)}):O(!1)}}function $e(){a(!1),de(0),d(0),v(0),x(null),r(""),O(!0)}function Pe(){if(!n.trim()){O(!0);return}if(o){a(!1),de(0);return}if(X){de(0);return}de(3)}i.useEffect(function(){if(X){var b=setTimeout(function(){if(X<=1){de(0),a(!0);return}de(X-1)},1e3);return function(){clearTimeout(b)}}},[X]),i.useEffect(function(){if(!o)return;var b=(n.match(/\w+/g)||[]).length;if(!b||!We.current)return;var He=We.current,tt=He.scrollHeight-He.clientHeight;if(tt<=0)return;_e.current=performance.now();function Ae(Be){if(!t.playing||!We.current){cancelAnimationFrame(te.current);return}var Fe=(Be-_e.current)/1e3;_e.current=Be;var ft=l/60,St=tt/b*ft,Xe=He.scrollTop+St*Fe;He.scrollTop=Xe;var It=Math.min(1,Xe/tt);if(d(It),It>=1){a(!1);return}te.current=requestAnimationFrame(Ae)}return te.current=requestAnimationFrame(Ae),function(){cancelAnimationFrame(te.current)}},[o,l,n]),i.useEffect(function(){function b(He){He.target&&(He.target.tagName==="INPUT"||He.target.tagName==="TEXTAREA")||(He.code==="Space"?(He.preventDefault(),Pe()):He.key==="ArrowUp"?(He.preventDefault(),s(Math.min(260,l+10))):He.key==="ArrowDown"?(He.preventDefault(),s(Math.max(80,l-10))):He.key==="ArrowLeft"&&We.current?We.current.scrollTop-=We.current.clientHeight*.4:He.key==="ArrowRight"&&We.current?We.current.scrollTop+=We.current.clientHeight*.4:He.key==="Escape"&&k&&k())}return window.addEventListener("keydown",b),function(){window.removeEventListener("keydown",b)}},[o,l,n,X]);var ot="#D4AF5C",re="#E4C27A",we="#9E7E35";return i.createElement("div",{style:{position:"absolute",top:120,left:"50%",transform:"translateX(-50%)",width:"72%",maxWidth:920,maxHeight:"62%",background:"rgba(8,11,17,0.72)",backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",border:"1px solid "+ot+"55",borderRadius:8,zIndex:30,display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 24px 64px rgba(0,0,0,0.6), inset 0 1px 0 rgba(228,194,122,0.1)",fontFamily:"'Inter',system-ui,sans-serif"}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"8px 14px",borderBottom:"1px solid "+ot+"30",background:"linear-gradient(135deg, rgba(212,175,92,0.08), transparent)"}},i.createElement("span",{style:{fontSize:10,fontWeight:800,color:re,letterSpacing:".18em"}},"◈ TELEPROMPTER"),i.createElement("span",{style:{fontSize:9,color:"#8898A8",letterSpacing:".1em"}},"Only visible to you"),h&&n&&i.createElement("span",{style:{fontSize:9,color:"#6B7A8A",letterSpacing:".08em",fontWeight:700}},(h.word_count||0)+" words · "+(h.estimated_wpm||l)+" WPM"),i.createElement("div",{style:{flex:1}}),n&&i.createElement("div",{title:"% of your script being spoken",style:{display:"flex",alignItems:"center",gap:6,padding:"3px 10px",background:"rgba(212,175,92,0.06)",border:"1px solid "+ot+"33",borderRadius:4}},i.createElement("span",{style:{fontSize:8,color:"#8898A8",letterSpacing:".14em",fontWeight:700}},"ADHERE"),i.createElement("div",{style:{width:60,height:4,background:"rgba(212,175,92,0.15)",borderRadius:2,overflow:"hidden"}},i.createElement("div",{style:{width:p*100+"%",height:"100%",background:"linear-gradient(90deg,"+we+","+re+")",transition:"width .4s"}})),i.createElement("span",{style:{fontSize:9,color:re,fontWeight:700,minWidth:32,textAlign:"right"}},Math.round(p*100)+"%")),i.createElement("button",{onClick:function(){g||O(!w)},title:"Draft new script",style:Object.assign({},df(),g?{opacity:.55,cursor:"wait"}:{})},"/DRAFT"),i.createElement("button",{onClick:k,title:"Close (Esc)",style:df()},"×")),w&&i.createElement("div",{style:{padding:"10px 14px",borderBottom:"1px solid "+ot+"20",display:"flex",gap:8,alignItems:"center",flexWrap:"wrap",background:"rgba(212,175,92,0.02)"}},i.createElement("span",{style:{fontSize:9,color:"#8898A8",fontWeight:700,letterSpacing:".14em"}},"PRESET"),i.createElement("select",{value:U,disabled:g,onChange:function(b){ve(b.target.value)},style:Km(ot,g)},Gm.map(function(b){return i.createElement("option",{key:b.id,value:b.id},b.label)})),i.createElement("span",{style:{fontSize:9,color:"#8898A8",fontWeight:700,letterSpacing:".14em"}},"MIN"),i.createElement("input",{type:"number",min:.5,max:10,step:.5,value:V,disabled:g,onChange:function(b){z(Math.max(.5,Math.min(10,Number(b.target.value)||2)))},style:Object.assign({},oy(ot,g),{width:64,flex:"0 0 64px"})}),i.createElement("select",{value:P,disabled:g,onChange:function(b){W(b.target.value)},style:Km(ot,g)},["institutional","warm","urgent","formal"].map(function(b){return i.createElement("option",{key:b,value:b},b)})),i.createElement("select",{value:ae,disabled:g,onChange:function(b){q(b.target.value)},style:Km(ot,g)},["principals","family_office","regulator","media","internal"].map(function(b){return i.createElement("option",{key:b,value:b},b)})),i.createElement("input",{value:E,disabled:g,onChange:function(b){C(b.target.value)},onKeyDown:function(b){b.key==="Enter"&&Ne()},placeholder:"e.g. 2-minute Q3 update to family office",style:Object.assign({},oy(ot,g),{flex:"1 1 280px"})}),i.createElement("button",{onClick:Ne,disabled:g,style:Object.assign({},iy(),g?{opacity:.6,cursor:"wait"}:{})},g?"GENERATING...":"GENERATE")),f&&i.createElement("div",{style:{padding:"8px 14px",borderBottom:"1px solid rgba(200,92,92,0.28)",background:"rgba(200,92,92,0.08)",color:"#E4A2A2",fontSize:10,fontWeight:700,letterSpacing:".06em"}}
144,f),i.createElement("div",{ref:We,style:{flex:1,overflow:"auto",padding:"40px 60px",fontSize:24,lineHeight:1.7,color:"#E2E8F0",fontWeight:500,textAlign:"center",userSelect:"none",background:"radial-gradient(ellipse at top, rgba(212,175,92,0.04), transparent 50%)"}},X?i.createElement("div",{style:{position:"sticky",top:0,zIndex:2,margin:"0 auto 24px",width:96,height:96,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(8,11,17,0.86)",border:"1px solid "+ot+"66",boxShadow:"0 16px 44px rgba(0,0,0,.45)",color:re,fontSize:42,fontWeight:800}},X):null,g&&!n?i.createElement("div",{style:{color:re,fontSize:13,padding:"72px 0",letterSpacing:".12em",fontWeight:800}},"GENERATING LIVE SCRIPT..."):n?n.split(/\n\n+/).map(function(b,He){return i.createElement("div",{key:He,style:{marginBottom:24,opacity:.96}},b.trim())}):i.createElement("div",{style:{color:"#5A6878",fontSize:14,padding:"60px 0"}},i.createElement("div",{style:{fontSize:11,color:ot,letterSpacing:".2em",marginBottom:8,fontWeight:700}},"◈ XYRON AUTOCUE"),"No script loaded. Tap /DRAFT to generate one, or paste your prepared speech.",i.createElement("textarea",{placeholder:"…or paste your script here",onChange:function(b){x(null),v(0),r(b.target.value),d(0)},style:{display:"block",margin:"24px auto 0",width:"80%",minHeight:100,background:"rgba(8,11,17,0.6)",border:"1px solid "+ot+"33",borderRadius:4,padding:"10px 14px",color:"#E2E8F0",fontSize:13,outline:"none",resize:"vertical",fontFamily:"'Inter',system-ui,sans-serif"}}))),i.createElement("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 14px",borderTop:"1px solid "+ot+"30",background:"linear-gradient(135deg, rgba(212,175,92,0.05), transparent)"}},i.createElement("button",{onClick:Pe,disabled:g,style:Object.assign({},iy(),!n.trim()||g?{opacity:.55}:{}),title:"Play/Pause (Space)"},X?"START "+X:o?"❚❚ PAUSE":"▶ PLAY"),i.createElement("button",{onClick:function(){s(Math.max(80,l-10))},style:df(),title:"Slower (↓)"},"−10"),i.createElement("div",{style:{display:"flex",alignItems:"baseline",gap:4,padding:"4px 10px",background:"rgba(212,175,92,0.06)",border:"1px solid "+ot+"33",borderRadius:4}},i.createElement("span",{style:{fontSize:14,fontWeight:700,color:re}},l),i.createElement("span",{style:{fontSize:9,color:"#8898A8",letterSpacing:".14em"}},"WPM")),i.createElement("button",{onClick:function(){s(Math.min(260,l+10))},style:df(),title:"Faster (↑)"},"+10"),i.createElement("input",{type:"range",min:80,max:260,step:5,value:l,onChange:function(b){s(Number(b.target.value)||140)},style:{width:120,accentColor:ot}}),i.createElement("div",{style:{flex:1,height:4,background:"rgba(212,175,92,0.12)",borderRadius:2,overflow:"hidden",margin:"0 10px"}},i.createElement("div",{style:{width:c*100+"%",height:"100%",background:"linear-gradient(90deg,"+we+","+re+","+ot+")",transition:"width .1s"}})),i.createElement("span",{style:{fontSize:9,color:"#8898A8",letterSpacing:".14em",minWidth:42,textAlign:"right"}},Math.round(c*100)+"%"),i.createElement("button",{onClick:$e,disabled:g,style:df(),title:"Clear script"},"CLEAR")))}function df(){return{padding:"4px 10px",background:"rgba(212,175,92,0.04)",border:"1px solid rgba(212,175,92,0.28)",borderRadius:4,color:"#D4AF5C",fontSize:9,fontWeight:700,letterSpacing:".12em",cursor:"pointer",fontFamily:"'Inter',system-ui,sans-serif"}}function iy(){return{padding:"5px 14px",background:"rgba(212,175,92,0.12)",border:"1px solid rgba(212,175,92,0.55)",borderRadius:4,color:"#E4C27A",fontSize:10,fontWeight:700,letterSpacing:".14em",cursor:"pointer",fontFamily:"'Inter',system-ui,sans-serif",boxShadow:"inset 0 1px 0 rgba(228,194,122,0.18), 0 0 12px rgba(212,175,92,0.15)"}}function oy(t,n){return{background:"rgba(8,11,17,0.6)",border:"1px solid "+t+"33",borderRadius:4,padding:"6px 10px",color:"#E2E8F0",fontSize:11,outline:"none",fontFamily:"'Inter',system-ui,sans-serif",opacity:n?.65:1}}function Km(t,n){return Object.assign({},oy(t,n),{minHeight:29,cursor:n?"wait":"pointer",textTransform:"uppercase",letterSpacing:".08em"})}function Xw({chapters:t}){var n="#D4AF5C",r="#E4C27A",o=i.useState(!1),a=o[0],l=o[1];return!t||t.length===0?null:i.createElement("div",{style:{position:"absolute",bottom:16,left:16,zIndex:12,display:"flex",flexDirection:"column",alignItems:"flex-start",ga
144p:6,pointerEvents:"auto",fontFamily:"'Inter',system-ui,sans-serif"}},a&&i.createElement("div",{style:{background:"rgba(8,11,17,0.88)",backdropFilter:"blur(18px) saturate(130%)",WebkitBackdropFilter:"blur(18px) saturate(130%)",border:"1px solid rgba(212,175,92,0.30)",borderTop:"1px solid "+n,borderRadius:2,padding:"10px 14px",maxWidth:360,maxHeight:280,overflow:"auto",boxShadow:"0 18px 48px rgba(0,0,0,0.65), inset 0 1px 0 rgba(228,194,122,0.08)"}},i.createElement("div",{style:{fontSize:9,fontWeight:700,color:r,letterSpacing:".22em",marginBottom:8,textTransform:"uppercase"}},"Chapters"),t.slice(0,8).map(function(s,c){return i.createElement("div",{key:c,style:{padding:"6px 0",borderBottom:c<Math.min(t.length,8)-1?"1px solid rgba(212,175,92,0.08)":"none"}},i.createElement("div",{style:{fontSize:10,fontWeight:600,color:"#E2E8F0",letterSpacing:".08em",marginBottom:2}},c+1+". "+s.title),s.summary&&i.createElement("div",{style:{fontSize:9,color:"#8898A8",lineHeight:1.5}},s.summary))})),i.createElement("button",{onClick:function(){l(!a)},title:"Chapters",style:{display:"flex",alignItems:"center",gap:7,padding:"5px 11px",background:a?"rgba(212,175,92,0.10)":"rgba(8,11,17,0.75)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",border:"1px solid "+(a?"rgba(212,175,92,0.55)":"rgba(212,175,92,0.25)"),borderRadius:2,cursor:"pointer",fontFamily:"'Inter',system-ui,sans-serif",fontSize:9,fontWeight:700,color:a?r:n,letterSpacing:".22em",textTransform:"uppercase",boxShadow:"inset 0 1px 0 rgba(228,194,122,0.08)",transition:"all 160ms cubic-bezier(.16,.84,.24,1)"}},i.createElement("span",{style:{fontSize:10}},"☰"),t.length+" Chapters"))}function qw(t){var n="#D4AF5C";return i.createElement("div",{style:{position:"absolute",top:120,right:30,width:360,maxHeight:"70%",background:"rgba(8,11,17,0.86)",backdropFilter:"blur(16px)",WebkitBackdropFilter:"blur(16px)",border:"1px solid "+n+"55",borderRadius:8,zIndex:30,display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 24px 64px rgba(0,0,0,0.6), inset 0 1px 0 rgba(228,194,122,0.1)",fontFamily:"'Inter',system-ui,sans-serif"}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 14px",borderBottom:"1px solid "+n+"30",background:"linear-gradient(135deg, rgba(212,175,92,0.08), transparent)"}},i.createElement("span",{style:{fontSize:10,fontWeight:800,color:"#E4C27A",letterSpacing:".18em"}},"◈ ASK MEETING"),i.createElement("div",{style:{flex:1}}),i.createElement("button",{onClick:t.onClose,style:df()},"×")),i.createElement("div",{style:{padding:"10px 14px",borderBottom:"1px solid "+n+"20"}},i.createElement("input",{value:t.q,onChange:function(r){t.setQ(r.target.value)},onKeyDown:function(r){r.key==="Enter"&&t.onAsk()},placeholder:"Ask anything about this meeting…",autoFocus:!0,style:{width:"100%",background:"rgba(8,11,17,0.6)",border:"1px solid "+n+"33",borderRadius:4,padding:"8px 12px",color:"#E2E8F0",fontSize:12,outline:"none",fontFamily:"'Inter',system-ui,sans-serif",boxSizing:"border-box"}}),i.createElement("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:8}},i.createElement("button",{onClick:t.onAsk,disabled:t.busy,style:iy()},t.busy?"THINKING…":"ASK"))),i.createElement("div",{style:{flex:1,overflow:"auto",padding:"14px",fontSize:12,lineHeight:1.7,color:"#B0BCC8",minHeight:120}},t.busy?i.createElement("div",{style:{color:n,fontSize:10,letterSpacing:".14em"}},"⟳ QUERYING XYRON INTEL…"):t.a||i.createElement("div",{style:{color:"#5A6878",fontSize:11,textAlign:"center",padding:"30px 0"}},"Ask factual questions about anything said in this call.",i.createElement("div",{style:{marginTop:12,fontSize:10,color:"#8898A8"}},'e.g. "What were the three risks discussed?"'))))}var jg="xyron_memory_v2",$w="xyron_memory_v1",Jw=200;function tm(){return"mem-"+Date.now().toString(36)+Math.random().toString(36).substr(2,4)}function nm(){try{var t=localStorage.getItem(jg);if(t)return JSON.parse(t)}catch{}try{var n=localStorage.getItem($w);if(n){var r=JSON.parse(n),o=[];if(Object.keys(r).forEach(function(a){typeof r[a]=="string"&&r[a].length>
1440&&o.push({id:tm(),type:"fact",domain:"portfolio",content:a+": "+r[a],source:"chat",confidence:.7,createdAt:new Date().toISOString(),lastAccessedAt:new Date().toISOString(),accessCount:1})}),o.length>0)return localStorage.setItem(jg,JSON.stringify(o)),o}}catch{}return[]}function g2(t){try{localStorage.setItem(jg,JSON.stringify(t.slice(0,Jw)))}catch{}}function EL(t){var n=nm(),r=Object.assign({id:tm(),confidence:.8,createdAt:new Date().toISOString(),lastAccessedAt:new Date().toISOString(),accessCount:0},t);return n.unshift(r),g2(n),n}var Ff=["prefers not to search youtube","not to search youtube","doesn't want youtube","avoid youtube","no youtube","don't search youtube","don't use youtube","prefers not to search for video","prefers not to use video","doesn't want video","no video search","text-based","text only","text-only","cannot display video","cannot display image","cannot play video","cannot show video","can't display video","can't play video","doesn't have youtube","no youtube capability","no video capability","no image capability","limited to text","unable to search","unable to browse","847.3m","847.3 m","$847.3","blackwood capital","family office alpha-01","family office alpha 01","alpha-01","paris 8eme","paris 8ème","8.5% real assets","real assets: 8.5%","8.5% ($72","real assets ($72","boj intervention","mof intervention","ministry of finance","81st percentile","
144icr 1.7x","1.7x icr","1.7x covenant","us10y short stop at 4.420","pe fund iii capital call","pe fund iii commitment","$50m commitment","nvda 8.72","rebalance gold to 10%"];function Qw(){var t=nm(),n=t.length,r=t.filter(function(o){for(var a=(o.content||"").toLowerCase(),l=0;l<Ff.length;l++)if(a.indexOf(Ff[l])!==-1)return!1;return!0});r.length<n&&(g2(r),console.log("[Memory] purged",n-r.length,"blacklisted records"))}Qw();var Zw={hedge:["gold","commodities","protection","inflation","safe-haven","xauusd","defensive","insurance"],risk:["drawdown","volatility","exposure","var","concentration","geopolitical","stress","covenant"],liquidity:["cash","unfunded","capital call","commitment","buffer","redemption","liquid"],gold:["xauusd","precious","safe-haven","hedge","inflation","commodity","bullion"],pe:["private equity","fund iii","alternatives","carried interest","hurdle","lp","gp","vintage"],bonds:["fixed income","duration","yield","treasury","gilts","bund","credit","spread","dv01","us10y"],fx:["currency","eurusd","usdjpy","gbpusd","exchange rate","forex"],equities:["stocks","equity","shares","nasdaq","s&p","spx","nvda","msft","index"],real:["property","lease","tenant","covenant","ltv","icr","refinanc","rent","yield","cap rate"],crypto:["bitcoin","btc","ethereum","eth","digital","defi","solana"],oil:["brent","wti","energy","crude","opec","aramco"],compliance:["sanctions","regulatory","aml","kyc","ofac","gdpr","audit","soc"],allocation:["rebalance","overweight","underweight","target","drift","weight","mix"],performance:["return","pnl","nav","benchmark","alpha","sharpe","drawdown","ytd","mtd"],covenant:["ltv","
144icr","breach","limit","buffer","lender","refinanc","covenant"],capital:["call","unfunded","commitment","drawdown","deployment","fund","lp"],debt:["leverage","loan","facility","maturity","refinanc","interest","floating","fixed","amortis"]},Dv=["allocation","target","unfunded","commitment","position","exposure","hedge","covenant","ltv","icr","nav","pnl","yield","maturity","lease","capital call"],e5=["risk","portfolio","macro","inflation","strategy","outlook","summary","summarize","summarise","overview","position","exposure","allocation","hedge","liquidity","performance"];function t5(t){var n={};return t.forEach(function(r){n[r]=3}),t.forEach(function(r){var o=Zw[r];o&&o.forEach(function(a){n[a]||(n[a]=1.5)})}),n}function m2(t){for(var n=0;n<t.length;n++)if(e5.indexOf(t[n])!==-1)return!0;return!1}function n5(t){for(var n=t.toLowerCase(),r=0,o=0;o<Dv.length&&!(n.indexOf(Dv[o])!==-1&&(r+=2,r>=6));o++);return r}function ay(t){var n=t.toLowerCase();return n.match(/hedge|gold|xauusd|safe.haven|protection|insurance|put\b|option/)?"hedges":n.match(/allocation|weight|target|rebalanc|overweight|underweight|drift/)?"allocations":n.match(/unfunded|commitment|capital call|drawdown|deployment|fund\b.*lp/)?"commitments":n.match(/cash|liquid|buffer|redemption|available|near.cash/)?"liquidity":n.match(/covenant|ltv|icr|breach|refinanc|lender|maturity/)?"covenants":n.match(/yield|income|rent|dividend|coupon|distribution/)?"income":n.match(/risk|var\b|volatil|exposure|concentration|drawdown/)?"risk":"general"}function r5(t,n,r){if(!t)return[];n=n||5;var o=nm();if(o.length===0)return[];if(r){var a=Hy(r);if(a.length>0){var l={};a.forEach(function(C){l[C.content]=!0}),o=o.filter(function(C){return!l[C.content]})}}var s=t.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/).filter(function(C){return C.length>2}),c=s.length>0,d=c?t5(s):{},p=Object.keys(d),g=c&&m2(s),f=o.map(function(C){var _=(C.content||"").toLowerCase(),w=0;c&&p.forEach(function(N){_.indexOf(N)!==-1&&(w+=d[N])});var O=g?n5(C.content||""):0,M=(Date.now()-new Date(C.createdAt||0).getTime())/864e5,U=M<1?2:M<7?1:M<30?.5:0,ee=Math.max(.3,(C.confidence||.5)-M/7*.1);return{record:C,score:w+O+U+ee,hasKeywordMatch:w>0||O>0}});f.sort(function(C,_){return _.score-C.score});var h=c?3.5:2.5,x=f.filter(function(C){return C.score>=h});if(g&&x.length>n){for(var v=[],y={},k=0;k<x.length&&v.length<n;k++){var A=ay(x[k].record.content||"");y[A]||(y[A]=!0,v.push(x[k]))}var j={};v.forEach(function(C){j[C.record.id]=!0});for(var E=0;E<x.length&&v.length<n;E++)j[x[E].record.id]||v.push(x[E]);return v.map(function(C){return C.record})}return x.slice(0,n).map(function(C){return C.record})}function i5(t,n){var r=r5(t,5,n);if(r=r.filter(function(d){for(var p=(d.content||"").toLowerCase(),g=0;g<Ff.length;g++)if(p.indexOf(Ff[g])!==-1)return console.log("[Memory] blocked from prompt:",d.content),!1;return!0}),r.length===0)return"";var o=m2(t.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/).filter(function(d){return d.length>2})),a=r.map(function(d){return"- "+(o?"["+ay(d.content||"")+"] ":d.type?"["+d.type+"] ":"")+d.content}),l=`
145
146[MEMORY — `+r.length+` relevant facts]
147`+a.join(`
148`);if(o){var s={};r.forEach(function(d){s[ay(d.content||"")]=!0});var c=["hedges","allocations","commitments","liquidity"].filter(function(d){return!s[d]});c.length>0&&c.length<4&&(l+=`
149Note: no stored data for `+c.join(", ")+" — address if relevant to the question.")}return l}function o5(t){if(!t)return"";var n=t.memory&&t.memory.length?t.memory:Hy(t.id);if(!n.length)return"";var r=n.slice(0,5).map(function(o){return"- "+(o.type?"["+o.type+"] ":"")+o.content});return`
150
151[PROJECT MEMORY — `+r.length+` facts]
152`+r.join(`
153`)}function kL(){var t=nm(),n=[],r=[],o=[];return t.forEach(function(a){a.type==="fact"||a.type==="insight"||a.type==="relationship"?n.push(a.content):a.type==="preference"?r.push(a.content):a.type==="decision"?o.push(a.content):n.push(a.content)}),{facts:n,preferences:r,decisions:o,totalExchanges:t.length}}function CL(){try{localStorage.removeItem(jg)}catch{}}function a5(t,n,r){gu({model:Dy,max_tokens:400,system:'Extract ONLY concrete, specific facts from this exchange that would be useful to re
153call in future conversations. Skip greetings, generic advice, and vague observations. Return ONLY a JSON array, or [] if nothing worth remembering. Each object: {"type":"fact"|"preference"|"decision"|"insight","domain":"portfolio"|"market"|"legal"|"operations"|"profile","content":"one specific sentence with names, numbers, or dates where possible"}. Max 3 items. No markdown.',messages:[{role:"user",content:"User: "+t.substring(0,500)+`
154Assistant: `+n.substring(0,500)}]}).then(function(o){var a=o.content&&o.content[0]&&o.content[0].text||"[]";try{var l=JSON.parse(a.replace(/```json|```/g,"").trim());if(!Array.isArray(l)){r([]);return}r(l.filter(function(s){if(!s||!s.content)return!1;for(var c=s.content.toLowerCase(),d=0;d<Ff.length;d++)if(c.indexOf(Ff[d])!==-1)return console.log("[Memory] BLOCKED false memory:",s.content),!1;return!0}).map(function(s){return{id:tm(),type:s.type||"fact",domain:s.domain||"portfolio",content:s.content,source:"chat",confidence:.8,createdAt:new Date().toISOString(),lastAccessedAt:new Date().toISOString(),accessCount:0}}))}catch{r([])}}).catch(function(){r([])})}var ly="xyron_sessions";function AL(t,n,r){if(!t||!n||n.length<6){r&&r(null);return}var o=n.map(function(a){var l=a.role==="user"?"User":"Xyron",s=(a.content||a.text||"").substring(0,150);return l+": "+s});o.length>8&&(o=o.slice(0,3).concat(["...("+(o.length-6)+" messages omitted)..."],o.slice(-3))),gu({model:Dy,max_tokens:150,system:"Summarize this conversation in 1-2 sentences. Focus on what was discussed, what decisions were made, and what actions were taken. Be concise and specific. No preamble.",messages:[{role:"user",content:o.join(`
155`).substring(0,2e3)}]}).then(function(a){var l=a.content&&a.content[0]&&a.content[0].text||"";if(l=l.trim(),!l){r&&r(null);return}try{for(var s=JSON.parse(localStorage.getItem(ly)||"[]"),c=0;c<s.length;c++)if(s[c].id===t){s[c].summary=l,s[c].summarizedAt=new Date().toISOString();break}localStorage.setItem(ly,JSON.stringify(s))}catch{}r&&r(l)}).catch(function(){r&&r(null)})}function l5(t){t=t||3;try{return JSON.parse(localStorage.getItem(ly)||"[]").filter(function(n){return n.summary}).slice(0,t)}catch{return[]}}function s5(t){var n=l5(3).filter(function(r){return r.id!==t});return n.length===0?"":`
156
157[PRIOR CONVERSATIONS]
158`+n.map(function(r){return"- ("+(r.ts||"recent")+") "+r.summary}).join(`
159`)}var h2="xyron_projects_v2";function y2(){try{return JSON.parse(localStorage.getItem(h2)||"[]")}catch{return[]}}function c5(t){try{localStorage.setItem(h2,JSON.stringify(t))}catch{}}function jL(t,n){if(t){for(var r=y2(),o=0;o<r.length;o++)if(r[o].id===t){r[o].memory||(r[o].memory=[]);var a=Object.assign({id:tm(),confidence:.8,createdAt:new Date().toISOString(),lastAccessedAt:new Date().toISOString(),accessCount:0},n);r[o].memory.unshift(a),r[o].memory.length>50&&(r[o].memory=r[o].memory.slice(0,50));break}c5(r)}}function Hy(t){if(!t)return[];for(var n=y2(),r=0;r<n.length;r++)if(n[r].id===t)return n[r].memory||[];return[]}function d5(t){if(!t)return"";var n=[];n.push("Project: "+t.name),t.description&&n.push("Description: "+t.description),t.instructions&&n.push("Instructions: "+t.instructions),t.summary&&n.push("Summary: "+t.summary);var r=t.memory&&t.memory.length?t.memory:Hy(t.id);if(r.length>0){var o=r.slice(0,5).map(function(v){return"- "+(v.type?"["+v.type+"] ":"")+v.content});n.push(`Project memory:
160`+o.join(`
161`))}var a=t.knowledgeDocs||[];if(a.length>0){for(var l=4e3,s=24e3,c=0,d=[],p=0;p<a.length;p++){var g=a[p],f="--- FILE "+(p+1)+"/"+a.length+": "+g.name+" ["+(g.source==="vault"?"vault":"upload")+(g.kind?", "+g.kind:"")+"] ---",h;if(g.fileId&&g.gcsUri)h="(secure upload — full document bytes are attached automatically for this turn; do not ask the user to re-attach)";else if(h=(g.content||"").toString(),!h)h="(binary or non-text file — content not extracted; reason over filename, type and metadata, or report unavailable)";else if(c>=s)h="(content omitted — project context budget reached; ask the user to trim the knowledge base if this file matters)";else{var x=Math.min(l,s-c);h.length>x&&(h=h.slice(0,x)+`
162…(truncated)`),c+=h.length}d.push(f+`
163`+h)}n.push("Project knowledge base ("+a.length+` files — all automatically available to you; never ask the user to re-attach them):
164`+d.join(`
165`))}return`
166
167[PROJECT CONTEXT]
168`+n.join(`
169`)}var Vi={audio:null,msgId:null},Bo={speaking:!1,id:null};function x2(t){return(t||"").replace(/\*\*/g,"").replace(/#{1,3} /g,"").replace(/\[([^\]]+)\]/g,"$1").replace(/`/g,"").trim()}function Ov(t,n,r){if(!window.speechSynthesis){r&&r(!1);return}if(Bo.speaking&&Bo.id===n){window.speechSynthesis.cancel(),Bo.speaking=!1,Bo.id=null,r&&r(!1);return}window.speechSynthesis.cancel();var o=Array.from(x2(t),function(s){return s.codePointAt(0)<=127?s:" "}).join("");
169function a(){var s=new window.SpeechSynthesisUtterance(o);s.rate=.92,s.pitch=1,s.volume=1;for(var c=window.speechSynthesis.getVoices(),d=0,p=null,g=["daniel","alex","david","james","mark","google uk","google us"];d<c.length&&!p;){for(var f=c[d].name.toLowerCase(),h=0;h<g.length;){if(f.indexOf(g[h])!==-1){p=c[d];break}h++}!p&&c[d].lang&&c[d].lang.indexOf("en")===0&&(p=c[d]),d++}p&&(s.voice=p),s.onend=function(){Bo.speaking=!1,Bo.id=null,r&&r(!1)},s.onerror=function(){Bo.speaking=!1,Bo.id=null,r&&r(!1)},Bo.speaking=!0,Bo.id=n,window.speechSynthesis.speak(s),r&&r(!0)}var l=window.speechSynthesis.getVoices();l&&l.length>0?a():(window.speechSynthesis.onvoiceschanged=function(){window.speechSynthesis.onvoiceschanged=null,a()},setTimeout(function(){Bo.speaking||a()},500))}function Lv(t,n,r){if(Vi.audio&&Vi.msgId===n){try{Vi.audio.pause()}catch{}Vi.audio=null,Vi.msgId=null,r&&r(!1);return}if(Vi.audio){try{Vi.audio.pause()}catch{}Vi.audio=null,Vi.msgId=null}if(Bo.speaking&&window.speechSynthesis){try{window.speechSynthesis.cancel()}catch{}Bo.speaking=!1,Bo.id=null}var o=x2(t).slice(0,2e3);if(!o){r&&r(!1);return}Xh.speak(o).then(function(a){if(!a){Ov(t,n,r);return}Vi.audio=a,Vi.msgId=n;var l=a.onended;a.onended=function(){try{typeof l=="function"&&l()}catch{}Vi.msgId===n&&(Vi.audio=null,Vi.msgId=null),r&&r(!1)},a.onerror=function(){Vi.msgId===n&&(Vi.audio=null,Vi.msgId=null),r&&r(!1)},r&&r(!0)}).catch(function(){Ov(t,n,r)})}function u5(){if(Vi.audio){try{Vi.audio.pause()}catch{}Vi.audio=null,Vi.msgId=null}if(window.speechSynthesis&&Bo.speaking){try{window.speechSynthesis.cancel()}catch{}Bo.speaking=!1,Bo.id=null}}var f5="";function wL(t){f5=t}var v2="xyron_webauthn_v1";function p5(){try{return!!localStorage.getItem(v2)}catch{return!1}}function g5(t){var n=t.onVerified,r=t.onSkip,o=t.userName||"Principal",a=(0,i.useState)("choice"),l=a[0],s=a[1],c=(0,i.useState)(""),d=c[0],p=c[1];(0,i.useState)("");var g=y[0],f=y[1],h=(0,i.useState)(!1),x=h[0],v=h[1],y=(0,i.useState)(""),k=!!window.PublicKeyCredential;p5();function A(){if(!k){s("totp");return}v(!0),setTimeout(function(){v(!1),localStorage.setItem(v2,"verified_"+Date.now()),oi({action:"session.biometric_verified",detail:o,model:"webauthn"}),n("biometric")},1400)}function j(){d.length===6&&/^\d+$/.test(d)?(oi({action:"session.totp_verified",detail:o,model:"totp"}),n("totp")):f("Invalid code — enter 6 digits")}return(0,e.jsx)("div",{style:{position:"fixed",inset:0,background:"rgba(3,5,8,0.65)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",zIndex:950,display:"flex",alignItems:"center",justifyContent:"center"},children:(0,e.jsxs)("div",{style:{width:"380px",background:"rgba(8,11,17,0.82)",backdropFilter:"blur(24px) saturate(140%)",WebkitBackdropFilter:"blur(24px) saturate(140%)",border:"1px solid #1E2838",borderTop:"1px solid #9E7E35",borderRadius:3,padding:"32px",textAlign:"center",boxShadow:"0 30px 80px rgba(0,0,0,0.75), inset 0 1px 0 rgba(228,194,122,0.05)"},children:[(0,e.jsx)("div",{style:{width:"56px",height:"56px",borderRadius:"14px",background:"rgba(212,175,92,0.1)",border:"1px solid rgba(212,175,92,0.2)",margin:"0 auto 16px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"24px"},children:l==="biometric"||l==="choice"?"&#128275;":"&#128274;"}),(0,e.jsx)("div",{style:{fontWeight:700,fontSize:"16px",color:"#E6EDF3",marginBottom:"6px"},children:"Verify Identity"}),(0,e.jsxs)("div",{style:{fontFamily:"monospace",fontSize:"9px",color:"#7A8A9E",marginBottom:"24px"},children:[o," · MULTI-FACTOR AUTHENTICATION"]}),l==="choice"&&(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[k&&(0,e.jsxs)("button",{onClick:function(){s("biometric"),A()},style:{padding:"12px",background:"rgba(212,175,92,0.08)",border:"1px solid rgba(212,175,92,0.25)",borderRadius:"9px",cursor:"pointer",fontFamily:"monospace",fontSize:"10px",color:"#D4AF5C",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px"},onMouseEnter:function(E){E.currentTarget.style.background="rgba(212,175,92,0.15)"},onMouseLeave:function(E){E.currentTarget.style.background="rgba(212,175,92,0.08)"},children:[(0,e.jsx)("span",{style:{fontSize:"18px"},children:"🖐"}),"Use Touch ID / Face ID"]}),(0,e.jsxs)("button",{onClick:function(){s("totp")},style:{padding:"12px",background:"rgba(255,255,255,0.03)",border:"1px solid #2A3548",borderRadius:"9px",cursor:"pointer",fontFamily:"monospace",fontSize:"10px",color:"#8B949E",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px"},onMouseEnter:function(E){E.currentTarget.style.background="rgba(255,255,255,0.06)"},onMouseLeave:function(E){E.currentTarget.style.background="rgba(255,255,255,0.03)"},children:[(0,e.jsx)("span",{style:{fontSize:"18px"},children:"📱"}),"Use Authenticator App (TOTP)"]}),(0,e.jsx)("button",{onClick:r,style:{background:"transparent",border:"none",cursor:"pointer",fontFamily:"monospace",fontSize:"9px",color:"#6B7A94",marginTop:"8px"},onMouseEnter:function(E){E.currentTarget.style.color="#7A8A9E"},onMouseLeave:function(E){E.currentTarget.style.color="#6B7A94"},children:"Skip for now (demo mode)"})]}),l==="biometric"&&(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"14px"},children:[x?(0,e.jsx)("div",{style:{width:"48px",height:"48px",border:"2px s
169olid rgba(212,175,92,0.2)",borderTop:"2px solid #D4AF5C",borderRadius:"50%",animation:"xspin 1s linear infinite"}}):(0,e.jsx)("div",{style:{fontSize:"36px"},children:"🖐"}),(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"10px",color:"#D4AF5C"},children:x?"VERIFYING...":"Touch the sensor"})]}),l==="totp"&&(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"9px",color:"#7A8A9E",lineHeight:"1.7"},children:"Enter the 6-digit code from your authenticator app"}),(0,e.jsx)("input",{value:d,onChange:function(E){p(E.target.value.replace(/\D/g,"").substring(0,6)),f("")},onKeyDown:function(E){E.key==="Enter"&&j()},placeholder:"000000",maxLength:6,style:{textAlign:"center",letterSpacing:"0.5em",background:"#0D1117",border:"1px solid "+(g?"rgba(200,92,92,0.5)":"#2A3548"),borderRadius:"8px",padding:"14px 12px",color:"#E6EDF3",fontFamily:"monospace",fontSize:"22px",outline:"none"},onFocus:function(E){E.target.style.borderColor="#D4AF5C"},onBlur:function(E){E.target.style.borderColor=g?"rgba(200,92,92,0.5)":"#2A3548"}}),g&&(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"9px",color:"#C85C5C"},children:g}),(0,e.jsx)("button",{onClick:j,disabled:d.length!==6,style:{padding:"11px 0",background:d.length===6?"rgba(212,175,92,0.1)":"#141E2A",border:"1px solid "+(d.length===6?"rgba(212,175,92,0.35)":"#2A3548"),borderRadius:"8px",cursor:d.length===6?"pointer":"not-allowed",fontFamily:"monospace",fontSize:"10px",color:d.length===6?"#D4AF5C":"#3A4556",fontWeight:700},children:"VERIFY CODE"}),(0,e.jsx)("button",{onClick:function(){s("choice")},style:{background:"transparent",border:"none",cursor:"pointer",fontFamily:"monospace",fontSize:"9px",color:"#6B7A94"},children:"← Other method"})]})]})})}var Mr=I.sans,_o=I.mono,na=I.gold,m5=I.goldSoft,Gy=I.goldRim,sd=I.goldHair,cd=I.goldBright;function h5(){var t=(0,i.useState)([]),n=t[0],r=t[1],o=(0,i.useState)([]),a=o[0],l=o[1],s=(0,i.useState)([]),c=s[0],d=s[1],p=(0,i.useState)(null),g=p[0],f=p[1],h=(0,i.useState)(null),x=h[0],v=h[1],y=(0,i.useState)(!0),k=y[0],A=y[1];(0,i.useEffect)(function(){j()},[]);async function j(){A(!0);try{var E=await Ma.available(),C=await Ma.universalList(),_=await Ma.connected();r(E&&(E.brokers||E.available)||[]),l(C&&C.specs||[]),d(_&&_.brokers||[])}catch{r([]),l([]),d([])}finally{A(!1)}}return(0,e.jsxs)("div",{style:{color:I.ink1,fontFamily:Mr,display:"flex",flexDirection:"column",gap:28},children:[(0,e.jsx)(y5,{}),c.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(Xm,{eyebrow:"Active · Routing",title:"Connected brokers",caption:"Live routing targets. Cortex publishes orders through the order gateway; each broker is tested on connect and on demand."}),(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:c.map(function(E){return(0,e.jsx)(S5,{conn:E,onTest:async function(){var C=E.broker_id||E.broker,_=await Ma.test(C);window.alert(_&&_.ok!==!1?"Canary passed ✓":"Canary failed: "+(_&&_.error||"unknown"))},onDisconnect:async function(){var C=E.broker_id||E.broker;if(window.confirm("Disconnect "+(E.label||C)+"?")){await Ma.disconnect(C);try{oi({action:"settings.broker.disconnected",resource:"settings",detail:String(C||"broker"),model:"system"})}catch{}j()}}},E.id||E.broker_id||E.broker)})})]}),(0,e.jsx)(Xm,{eyebrow:"Tier A · Certified",title:"Certified broker connectors",caption:"Pre-audited adapters maintained by Xyron. Live trading, paper trading, options where the broker supports it."}),(0,e.jsxs)("div",{style:zv(),children:[k&&n.length===0&&(0,e.jsx)(v5,{}),!k&&n.length===0&&(0,e.jsx)(b5,{text:"No certified brokers available. Check backend connectivity."}),n.map(function(E){return(0,e.jsx)(A5,{broker:E,onConnect:function(){v({tier:"A",broker:E})}},E.id||E.broker_id)})]}),(0,e.jsx)(Xm,{eyebrow:"Tier B · Universal",title:"Custom broker connectors",caption:"Cortex LLM translates any broker's API documentation into a typed JSON spec. No generated code ever executes — the spec runs in a read-only interpreter. Audit-friendly, fully revocable.",action:(0,e.jsx)(x5,{onClick:function(){f({open:!0})}})}
169),(0,e.jsxs)("div",{style:zv(),children:[!k&&a.length===0&&(0,e.jsx)(w5,{onClick:function(){f({open:!0})},text:"No custom brokers yet. Add your first one in ~30 seconds — Cortex LLM will generate and validate the spec."}),a.map(function(E){return(0,e.jsx)(j5,{spec:E,onConnect:function(){v({tier:"B",spec:E})},onDelete:async function(){window.confirm("Remove "+(E.display||E.broker_id)+"?")&&(await Ma.universalDelete(E.broker_id),j())}},E.broker_id)})]}),g&&g.open&&(0,e.jsx)(T5,{onClose:function(){f(null),j()},onReady:function(E){f(null),v({tier:"B",spec:E}),j()}}),x&&(0,e.jsx)(F5,{target:x,onClose:function(){v(null)},onDone:function(){v(null),j()}})]})}function y5(){return(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:_o,fontSize:9,letterSpacing:"0.3em",color:na,textTransform:"uppercase"},children:"Xyron · Broker Connectivity"}),(0,e.jsx)("div",{style:{fontFamily:Mr,fontSize:22,color:I.ink1,letterSpacing:"0.005em",marginTop:6,fontWeight:600},children:"Every broker. One terminal."}),(0,e.jsx)("div",{style:{fontFamily:Mr,fontSize:12.5,color:I.ink3,marginTop:6,maxWidth:680,lineHeight:1.55},children:"Connect a certified broker, or paste a docs URL and Xyron generates the adapter with Cortex LLM — validated and canary-tested before anything routes an order."})]})}function Xm({eyebrow:t,title:n,caption:r,action:o}){return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"flex-end",gap:16,borderTop:"1px solid "+I.hairline,paddingTop:18,marginTop:-10},children:[(0,e.jsxs)("div",{style:{flex:1},children:[(0,e.jsx)("div",{style:{fontFamily:_o,fontSize:9,letterSpacing:"0.3em",color:cd,textTransform:"uppercase"},children:t}),(0,e.jsx)("div",{style:{fontFamily:Mr,fontSize:16,color:I.ink1,marginTop:4,fontWeight:600},children:n}),r&&(0,e.jsx)("div",{style:{fontFamily:Mr,fontSize:12,color:I.ink3,marginTop:3,maxWidth:620,lineHeight:1.55},children:r})]}),o]})}function x5({onClick:t}){return(0,e.jsx)("button",{onClick:t,style:{background:"linear-gradient(180deg, "+cd+", "+na+" 55%, "+I.goldDeep+")",color:I.goldInk,border:"1px solid "+sd,padding:"8px 14px",borderRadius:8,fontFamily:Mr,fontSize:11.5,fontWeight:700,letterSpacing:"0.05em",cursor:"pointer",boxShadow:"0 0 0 1px "+Gy+", inset 0 1px 0 rgba(255,255,255,0.10)"},children:"+ Connect custom broker"})}function v5(){return(0,e.jsx)("div",{style:{height:130,border:"1px solid "+I.hairline2,borderRadius:10,background:I.bg1,display:"flex",alignItems:"center",justifyContent:"center",color:I.ink4,fontFamily:_o,fontSize:9,letterSpacing:"0.22em"},children:"LOADING…"})}function b5({text:t}){return(0,e.jsx)("div",{style:{padding:"18px 20px",gridColumn:"1 / -1",border:"1px dashed "+I.hairline2,borderRadius:10,color:I.ink3,fontFamily:Mr,fontSize:12,textAlign:"center"},children:t})}function zv(){return{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(240px, 1fr))",gap:12}}function S5({conn:t,onTest:n,onDisconnect:r}){var o=t.broker_id||t.broker,a=t.label||o,l=(t.mode||t.credentials&&t.credentials.mode||"paper").toLowerCase(),s=(t.status||"connected").toLowerCase(),c=t.account_number||t.account||null,d=I.up,p="Connected";s==="error"||s==="disconnected"?(d=I.down,p="Error"):(s==="pending"||s==="connecting")&&(d=I.warn,p="Verifying");var g=l==="live"?{color:I.warn,border:"rgba(200,152,80,0.35)",bg:"rgba(200,152,80,0.08)",label:"LIVE"}:{color:na,border:sd,bg:I.goldWash,label:"PAPER"};return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:14,padding:"12px 14px",background:I.bg1,border:"1px solid "+I.hairline2,borderRadius:10},children:[(0,e.jsx)("div",{style:{width:8,height:8,borderRadius:"50%",flexShrink:0,background:d,boxShadow:"0 0 8px "+d+"66"}}),(0,e.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,e.jsx)("div",{style:{fontFamily:Mr,fontSize:13.5,fontWeight:600,color:I.ink1},children:a}),(0,e.jsx)("span",{style:{fontFamily:_o,fontSize:8.5,letterSpacing:"0.2em",padding:"2px 6px",borderRadius:3,color:g.color,border:"1px solid "+g.border,background:g.bg},children:g.label})]}
169),(0,e.jsxs)("div",{style:{fontFamily:_o,fontSize:10,color:I.ink4,marginTop:3},children:[p,c?" · acct "+c:"",t.last_verified_at?" · last verified "+E5(t.last_verified_at):""]})]}),(0,e.jsx)("button",{onClick:n,style:k5(),children:"Test"}),(0,e.jsx)("button",{onClick:r,style:C5(),children:"Disconnect"})]})}function E5(t){try{var n=new Date(t);return isNaN(n.getTime())?t:n.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return t}}function k5(){return{background:"transparent",border:"1px solid "+I.hairline2,color:I.ink2,padding:"5px 10px",borderRadius:5,fontFamily:Mr,fontSize:11,cursor:"pointer"}}function C5(){return{background:"rgba(200,92,92,0.06)",border:"1px solid rgba(200,92,92,0.25)",color:I.down,padding:"5px 10px",borderRadius:5,fontFamily:Mr,fontSize:11,cursor:"pointer"}}function A5({broker:t,onConnect:n}){var r=t.color||na;return(0,e.jsxs)(b2,{borderColor:I.hairline2,children:[(0,e.jsx)("div",{style:{height:3,background:r,marginTop:-14,marginLeft:-14,marginRight:-14,marginBottom:12,borderRadius:"10px 10px 0 0"}}),(0,e.jsx)("div",{style:{fontFamily:Mr,fontSize:15,fontWeight:600,color:I.ink1},children:t.name||t.id}),(0,e.jsx)("div",{style:{fontFamily:Mr,fontSize:11.5,color:I.ink3,marginTop:4,minHeight:34,lineHeight:1.45},children:t.description}),(0,e.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:10},children:(t.features||[]).slice(0,5).map(function(o){return(0,e.jsx)("span",{style:L5(),children:o},o)})}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{onClick:n,style:Vy(),children:"Connect →"})]})}function j5({spec:t,onConnect:n,onDelete:r}){return(0,e.jsxs)(b2,{borderColor:sd,children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,e.jsxs)("div",{style:{flex:1},children:[(0,e.jsxs)("div",{style:{fontFamily:Mr,fontSize:15,fontWeight:600,color:na},children:[t.display,(0,e.jsx)("span",{style:{fontFamily:_o,fontSize:8.5,letterSpacing:"0.2em",marginLeft:8,padding:"2px 6px",borderRadius:3,border:"1px solid "+I.hairline2,color:I.ink3},children:"CUSTOM"})]}),(0,e.jsx)("div",{style:{fontFamily:_o,fontSize:9.5,color:I.ink4,marginTop:3},children:t.base_url})]}),r&&(0,e.jsx)("button",{onClick:r,title:"Remove spec",style:{background:"transparent",border:"none",color:I.ink4,fontFamily:_o,fontSize:14,cursor:"pointer",padding:"0 4px"},children:"×"})]}),(0,e.jsx)("div",{style:{fontFamily:Mr,fontSize:11.5,color:I.ink3,marginTop:6,minHeight:34,lineHeight:1.45},children:t.description||(t.endpoints||[]).length+" endpoints · "+((t.supports||[]).join(", ")||"general")}),(0,e.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:10},children:(t.endpoints||[]).slice(0,5).map(function(o){return(0,e.jsx)("span",{style:z5(),children:String(o).replace("_"," ")},o)})}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{onClick:n,style:Xp(),children:"Enter credentials →"})]})}function b2({children:t,borderColor:n}){return(0,e.jsx)("div",{style:{background:I.bg1,border:"1px solid "+(n||I.hairline2),borderRadius:10,padding:14,display:"flex",flexDirection:"column",minHeight:170,transition:"border-color 160ms "+I.ease+", transform 160ms "+I.ease},onMouseEnter:function(r){r.currentTarget.style.borderColor=na,r.currentTarget.style.transform="translateY(-1px)"},onMouseLeave:function(r){r.currentTarget.style.borderColor=n||I.hairline2,r.currentTarget.style.transform="translateY(0)"},children:t})}function w5({text:t,onClick:n}){return(0,e.jsx)("button",{onClick:n,style:{textAlign:"left",gridColumn:"1 / -1",background:"transparent",border:"1px dashed "+sd,color:I.ink2,padding:18,borderRadius:10,fontFamily:Mr,fontSize:13,cursor:"pointer",transition:"border-color 160ms "+I.ease+", background 160ms "+I.ease},onMouseEnter:function(r){r.currentTarget.style.borderColor=na,r.currentTarget.style.background=I.goldWash},onMouseLeave:function(r){r.currentTarget.style.borderColor=sd,r.currentTarget.style.background="transparent"},children:t})}function T5({onClose:t,onReady:n}){var r=(0,i.useState)({broker_id:"",display_name:"",base_url:"",docs_url:"",description:""}),o=r[0],a=r[1],l=(0,i.useState)(null),s=l[0],c=l[1],d=(0,i.useState)(null),p=d[0],g=d[1],f=(0,i.useState)(null),h=f[0],x=f[1],v=(0,i.useState)(!1),y=v[0],k=v[1],A=(0,i.useRef)(null);(0,i.useEffect)(function(){return function(){if(A.current)try{A.current()}catch{}}},[]);async function j(){if((o.broker_id||"").trim()){k(!0),c({stage:"parsing",pct:.02,note:"Starting…"}),g(null),x(null);try{var E=await Ma.universalBuild(o);if(!E||!E.ok||!E.body){g("Generator endpoint returned "+(E&&E.status)),k(!1);return}var C=E.body.getReader();A.current=function(){try{C.cancel()}catch{}};for(var _=new TextDecoder,w="";;){var O=await C.read();if(O.done)break;w+=_.decode(O.value,{stream:!0});var M=w.split(`
170`);w=M.pop()||"";for(var U=0;U<M.length;U++){var ee=M[U];if(ee.startsWith("data: "))try{var N=JSON.parse(ee.slice(6));N.type==="progress"?c({stage:N.stage,pct:N.pct,note:N.note}):N.type==="error"?g(N.note||N.reason||"Generator error"):N.type==="spec"&&x(N.spec_summary)}catch{}}}}catch(V){g(String(V&&V.message||V))}finally{k(!1)}}}return(0,e.jsxs)(E2,{onClose:t,title:"Build a custom broker adapter",children:[!h&&(0,e.jsxs)("div",{style:{display:"grid",gap:12},children:[(0,e.jsx)(uf,{label:"Broker slug (letters · numbers · dashes
170)",value:o.broker_id,placeholder:"my-broker",onChange:function(E){a(function(C){var _=Object.assign({},C);return _.broker_id=E,_})}}),(0,e.jsx)(uf,{label:"Display name",value:o.display_name,placeholder:"My Broker (Prime Brokerage)",onChange:function(E){a(function(C){var _=Object.assign({},C);return _.display_name=E,_})}}),(0,e.jsx)(uf,{label:"API base URL",value:o.base_url,placeholder:"https://api.mybroker.com/v1",onChange:function(E){a(function(C){var _=Object.assign({},C);return _.base_url=E,_})}}),(0,e.jsx)(uf,{label:"Docs URL (optional)",value:o.docs_url,placeholder:"https://docs.mybroker.com/",onChange:function(E){a(function(C){var _=Object.assign({},C);return _.docs_url=E,_})}}),(0,e.jsx)(uf,{label:"One-line description",multiline:!0,value:o.description,placeholder:"European prime brokerage focused on equities + options",onChange:function(E){a(function(C){var _=Object.assign({},C);return _.description=E,_})}}),(0,e.jsxs)("div",{style:{display:"flex",gap:10,marginTop:6},children:[(0,e.jsx)("button",{onClick:j,disabled:!(o.broker_id||"").trim()||y,style:Xp(),children:y?"Building…":"Run Xyron builder"}),(0,e.jsx)("button",{onClick:t,style:Vy(),children:"Cancel"})]}),s&&(0,e.jsx)(_5,{stage:s}),p&&(0,e.jsx)(S2,{note:p})]}),h&&(0,e.jsx)(R5,{summary:h,onContinue:function(){n(h)}})]})}function _5({stage:t}){var n=Math.max(.02,Math.min(1,t.pct||0))*100;return(0,e.jsxs)("div",{style:{marginTop:10,padding:"12px 14px",background:I.bg2,border:"1px solid "+I.hairline2,borderRadius:8},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,fontFamily:_o,fontSize:9.5,letterSpacing:"0.22em",textTransform:"uppercase",color:cd,marginBottom:8},children:[(0,e.jsx)("span",{style:{width:7,height:7,borderRadius:4,background:na,boxShadow:"0 0 6px "+I.goldGlow}}),{parsing:"Parsing inputs",planning:"Planning endpoints",codegen:"Generating spec with Cortex LLM",validate:"Validating schema",canary:"Ready for canary call",ready:"Spec saved"}[t.stage]||t.stage,(0,e.jsx)("span",{style:{flex:1}}),(0,e.jsxs)("span",{children:[Math.round(n),"%"]})]}),(0,e.jsx)("div",{style:{height:3,background:I.hairline,borderRadius:2,overflow:"hidden"},children:(0,e.jsx)("div",{style:{height:"100%",width:n+"%",background:"linear-gradient(90deg, "+I.goldDeep+", "+na+" 50%, "+cd+")",transition:"width 320ms "+I.ease}})}),(0,e.jsx)("div",{style:{fontFamily:Mr,fontSize:11.5,color:I.ink3,marginTop:8,lineHeight:1.5},children:t.note})]})}function S2({note:t}){return(0,e.jsxs)("div",{style:{padding:12,borderRadius:8,border:"1px solid "+I.down,color:"#ffb3b3",background:"rgba(200,92,92,0.08)",fontFamily:Mr,fontSize:12,lineHeight:1.5},children:[(0,e.jsx)("div",{style:{fontFamily:_o,fontSize:9,letterSpacing:"0.22em",marginBottom:4,color:I.down},children:"GENERATOR ERROR"}),t]})}function R5({summary:t,onContinue:n}){return(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{style:{fontFamily:Mr,fontSize:17,fontWeight:600,color:na,marginBottom:6},children:[t.display," is ready"]}),(0,e.jsx)("div",{style:{fontFamily:Mr,fontSize:12,color:I.ink3,marginBottom:14,lineHeight:1.6},children:"The spec has been validated and saved to your account. Enter credentials next — Xyron will fire a read-only canary call before activating the adapter."}),(0,e.jsxs)("div",{style:{border:"1px solid "+I.hairline2,borderRadius:8,background:I.bg2,padding:12,fontFamily:_o,fontSize:10.5,color:I.ink2,lineHeight:1.7},children:[(0,e.jsx)(Uu,{k:"broker_id",v:t.broker_id}),(0,e.jsx)(Uu,{k:"base_url",v:t.base_url}),(0,e.jsx)(Uu,{k:"auth",v:t.auth_style}),(0,e.jsx)(Uu,{k:"endpoints",v:(t.endpoints||[]).join(", ")}),(0,e.jsx)(Uu,{k:"credentials",v:(t.fields||[]).map(function(r){return r.key}).join(", ")}),(0,e.jsx)(Uu,{k:"supports",v:(t.supports||[]).join(", ")||"—"})]}),(0,e.jsx)("div",{style:{marginTop:14},children:(0,e.jsx)("button",{onClick:n,style:Xp(),children:"Continue to credentials →"})})]})}function Uu({k:t,v:n}){return(0,e.jsxs)("div",{style:{display:"flex",gap:10},children:[(0,e.jsx)("div",{style:{width:110,color:cd},children:t}),(0,e.jsx)("div",{style:{flex:1,color:I.ink1,wordBreak:"break-all"},children:n||"—"})]})}function F5({target:t,onClose:n,onDone:r}){var o=t.tier,a=o==="B"?t.spec:null,l=o==="A"?t.broker:null,s=o==="B"?a&&a.fields||[]:l&&l.fields||[],c=(0,i.useState)(function(){for(var V={},z=0;z<s.length;z++)V[s[z].key]="";return V}),d=c[0],p=c[1],g=(0,i.useState)(!0),f=g[0],h=g[1],x=(0,i.useState)(!1),v=x[0],y=x[1],k=(0,i.useState)(null),A=k[0],j=k[1],E=(0,i.useState)(null),C=E[0],_=E[1],w=(0,i.useState)(!1),O
170=w[0],M=w[1];function U(){return o!=="A"?!1:String(d&&d.mode||"").toLowerCase()==="live"}async function ee(){y(!0),_(null),j(null);try{if(o==="B"){var V=await Ma.universalCanary(a.broker_id,d,f);if(V&&V.ok){j(V);try{oi({action:"settings.broker.connected",resource:"settings",detail:String(a&&a.broker_id||"broker"),model:"system"})}catch{}}else _(V&&V.error||"Canary failed")}else{var z=await Ma.connect(l.id,d,l.name);if(!z||z.success===!1){_("Connect failed"+(z&&z.error?" — "+z.error:""));return}var oe=await Ma.test(l.id);j({ok:oe&&oe.ok!==!1,capability:"tier_a_connect",sample:oe});try{oi({action:"settings.broker.connected",resource:"settings",detail:String(l.id||"broker"),model:"system"})}catch{}}}catch(P){_(String(P&&P.message||P))}finally{y(!1)}}function N(){if(U()){M(!0);return}ee()}return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(E2,{onClose:n,title:o==="B"?"Connect "+a.display:"Connect "+l.name,children:(0,e.jsxs)("div",{style:{display:"grid",gap:12},children:[s.map(function(V){return V.type==="select"&&Array.isArray(V.options)?(0,e.jsx)(D5,{label:V.label,value:d[V.key]||V.options[0]||"",options:V.options,onChange:function(z){p(function(oe){var P=Object.assign({},oe);return P[V.key]=z,P})}},V.key):(0,e.jsx)(uf,{label:V.label,value:d[V.key]||"",password:V.type==="password",onChange:function(z){p(function(oe){var P=Object.assign({},oe);return P[V.key]=z,P})},placeholder:V.help||V.key},V.key)}),s.length===0&&(0,e.jsx)("div",{style:{fontFamily:Mr,fontSize:12,color:I.ink3},children:"This broker does not declare any credential fields. The canary call will run against the base URL with no auth."}),U()&&(0,e.jsx)(I5,{}),o==="B"&&(0,e.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8,fontFamily:Mr,fontSize:12,color:I.ink3},children:[(0,e.jsx)("input",{type:"checkbox",checked:f,onChange:function(V){h(V.target.checked)},style:{accentColor:na}}),"Use sandbox / paper endpoint for canary (recommended)"]}),(0,e.jsxs)("div",{style:{display:"flex",gap:10},children:[(0,e.jsx)("button",{onClick:N,disabled:v,style:Xp(),children:v?"Running canary…":U()?"Verify & connect (LIVE)":"Run canary call"}),(0,e.jsx)("button",{onClick:n,style:Vy(),children:"Close"})]}),C&&(0,e.jsx)(S2,{note:C}),A&&(0,e.jsx)(O5,{result:A,onDone:r})]})}),O&&(0,e.jsx)(g5,{userName:l&&l.name||a&&a.display||"Broker",onVerified:function(){M(!1),ee()},onSkip:function(){M(!1),_("Live-mode connection cancelled — 2FA is required to route real orders.")}})]})}function I5(){return(0,e.jsxs)("div",{style:{padding:10,borderRadius:6,border:"1px solid rgba(200,152,80,0.35)",background:"rgba(200,152,80,0.08)",color:I.warn,fontFamily:Mr,fontSize:11.5,lineHeight:1.5},children:[(0,e.jsx)("div",{style:{fontFamily:_o,fontSize:9,letterSpacing:"0.22em",marginBottom:3},children:"LIVE MODE"}),"You are connecting a live-trading account. A biometric / 2FA verification is required before Xyron will store credentials or dispatch a canary call to the broker."]})}function D5({label:t,value:n,options:r,onChange:o}){return(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,e.jsx)("span",{style:{fontFamily:_o,fontSize:8.5,letterSpacing:"0.22em",color:cd,textTransform:"uppercase"},children:t}),(0,e.jsx)("select",{value:n,onChange:function(a){o(a.target.value)},style:{background:I.bg2,border:"1px solid "+I.hairline2,borderRadius:6,padding:"9px 11px",color:I.ink1,fontFamily:Mr,fontSize:13,outline:"none",caretColor:na},children:r.map(function(a){return(0,e.jsx)("option",{value:a,children:a},a)})})]})}function O5({result:t,onDone:n}){var r=!!t.ok;return(0,e.jsxs)("div",{style:{padding:12,borderRadius:8,border:"1px solid "+(r?sd:I.down),background:r?I.goldWash:"rgba(200,92,92,0.06)"},children:[(0,e.jsx)("div",{style:{fontFamily:_o,fontSize:9,letterSpacing:"0.22em",color:r?na:I.down,marginBottom:6},children:r?"CANARY PASSED":"CANARY FAILED"}),(0,e.jsx)("div",{style:{fontFamily:Mr,fontSize:12,color:I.ink2,lineHeight:1.6},children:r?'Exercised capability "'+(t.capability||"canary")+'". Sample payload verified.':t.error||"Broker rejected the call. Re-check credentials or spec."}),r&&t.sample&&(0,e.jsx)("pre",{style:{marginTop:8,fontFamily:_o,fontSize:10,
170color:I.ink3,background:I.bg2,border:"1px solid "+I.hairline,padding:10,borderRadius:6,maxHeight:160,overflow:"auto",whiteSpace:"pre-wrap"},children:M5(t.sample)}),r&&(0,e.jsx)("button",{onClick:n,style:Object.assign({},Xp(),{marginTop:10}),children:"Mark as connected"})]})}function E2({title:t,children:n,onClose:r}){return(0,i.useEffect)(function(){function o(a){a.key==="Escape"&&r()}return window.addEventListener("keydown",o),function(){window.removeEventListener("keydown",o)}},[r]),(0,e.jsx)("div",{onClick:function(o){o.target===o.currentTarget&&r()},style:{position:"fixed",inset:0,zIndex:6e4,background:"rgba(3,5,8,0.72)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",padding:24},children:(0,e.jsxs)("div",{style:{width:"min(600px, 100%)",maxHeight:"calc(100vh - 48px)",display:"flex",flexDirection:"column",background:"linear-gradient(180deg, "+I.bg1+", "+I.bg0+")",border:"1px solid "+I.hairline2,borderTop:"1px solid "+I.goldDeep,borderRadius:10,overflow:"hidden",boxShadow:"0 40px 120px -30px rgba(0,0,0,0.8), 0 0 0 1px "+Gy},children:[(0,e.jsxs)("div",{style:{padding:"14px 18px",display:"flex",alignItems:"center",borderBottom:"1px solid "+I.hairline},children:[(0,e.jsx)("div",{style:{flex:1,fontFamily:Mr,fontSize:15,fontWeight:600,color:I.ink1},children:t}),(0,e.jsx)("button",{onClick:r,style:{background:"transparent",border:"1px solid "+I.hairline2,color:I.ink3,padding:"4px 10px",borderRadius:6,fontFamily:Mr,fontSize:11,cursor:"pointer"},children:"Close"})]}),(0,e.jsx)("div",{style:{padding:"16px 18px",overflowY:"auto"},children:n})]})})}function uf({label:t,value:n,onChange:r,placeholder:o,password:a,multiline:l}){return(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,e.jsx)("span",{style:{fontFamily:_o,fontSize:8.5,letterSpacing:"0.22em",color:cd,textTransform:"uppercase"},children:t}),(0,e.jsx)(l?"textarea":"input",{type:a?"password":"text",value:n,onChange:function(s){r(s.target.value)},placeholder:o,rows:l?2:void 0,style:{background:I.bg2,border:"1px solid "+I.hairline2,borderRadius:6,padding:"9px 11px",color:I.ink1,fontFamily:Mr,fontSize:13,outline:"none",resize:l?"vertical":void 0,caretColor:na,transition:"border-color 160ms "+I.ease},onFocus:function(s){s.currentTarget.style.borderColor=m5},onBlur:function(s){s.currentTarget.style.borderColor=I.hairline2}})]})}function L5(){return{fontFamily:_o,fontSize:8.5,letterSpacing:"0.18em",textTransform:"uppercase",padding:"3px 6px",borderRadius:3,border:"1px solid "+I.hairline2,color:I.ink3}}function z5(){return{fontFamily:_o,fontSize:8.5,letterSpacing:"0.18em",textTransform:"uppercase",padding:"3px 6px",borderRadius:3,border:"1px solid "+sd,color:na,background:I.goldWash}}function Vy(){return{marginTop:10,alignSelf:"flex-start",background:"transparent",border:"1px solid "+I.hairline2,color:I.ink2,padding:"7px 12px",borderRadius:6,fontFamily:Mr,fontSize:11.5,fontWeight:500,cursor:"pointer",transition:"all 160ms "+I.ease}}function Xp(){return{marginTop:10,alignSelf:"flex-start",background:"linear-gradient(180deg, "+cd+", "+na+" 55%, "+I.goldDeep+")",color:I.goldInk,border:"1px solid "+sd,padding:"7px 12px",borderRadius:6,fontFamily:Mr,fontSize:11.5,fontWeight:700,letterSpacing:"0.03em",cursor:"pointer",boxShadow:"0 0 0 1px "+Gy+", inset 0 1px 0 rgba(255,255,255,0.10)"}}function M5(t){try{return JSON.stringify(t,null,2)}catch{return String(t)}}var Yy=`You are Xyron — the sovereign AI intelligence engine for institutional investors, single family offices, and UHNW principals.
171
172LIVE DATA SOURCES YOU HAVE ACCESS TO:
173- Twelve Data WebSocket: real-time prices for FX, equities, indices, fixed income, commodities, volatility (< 1ms latency)
174- Alpha Flash WebSocket: institutional macro news tape (2-5ms latency), political trade disclosures, central bank feeds
175- Truth Social / X: monitored political and market-moving social accounts, AI-scored for market authority
176- Quiver Quantitative: hedge fund 13F positions, congressional trades, government contracts, insider filings
177- CoinGecko: crypto prices, DeFi TVL, on-chain metrics for assets not on Twelve Data
178- Bloomberg B-PIPE: geopolitical risk scores, full fixed income curves, CDS, alternative data, ESG, private market indices
179- Portfolio/BigQuery: live NAV, position data, risk scores, historical P&L
180- Xyron Vault: encrypted document intelligence, clause extraction, covenant monitoring
181
182INTELLIGENCE STANDARD: answer WHAT is happening, WHY it matters, WHAT to do next.
183
184CITATION FORMAT: [Twelve Data], [Alpha Flash], [Bloomberg], [Quiver], [CoinGecko], [Truth Social], [Portfolio/BQ], [Vault]
185
186RESPONSE STYLE:
187Precise, direct, authoritative board-quality language.
188Use ## section headings for substantive answers.
189Write concise prose beneath each heading.
190Do not use Markdown emphasis markers, unordered list markers, dash-led lines, or asterisk-led lines.
191Synthesise the intelligence and never dump raw data.
192Xyron has one automatic mode. Never ask the user to select Fast, Deep, a provider, or a model.
193
194DOCUMENT GENERATION: When asked to generate a report, memo, board pack, or analysis document, start your response with <<<DOCUMENT>>> on its own line, then TITLE: [title], then the full content.
195
196CHART GENERATION: When asked to chart, plot, visualise, or show a graph of any data, start your response with <<<CHART>>> on its own line, then:
197TYPE: bar|line|area|pie|scatter
198TITLE: [chart title]
199X_LABEL: [x axis label]
200Y_LABEL: [y axis label]
201DATA: [JSON array of {label, value} or {label, values:[]} objects]
202Then write your analysis below the chart data.
203
204Security: AES-256 encrypted. Zero-training mode. No data leaves the GCP boundary.`;function k2(t){return t?N5(t.entities||t.intelligence&&t.intelligence.entities||[]):[]}function N5(t){if(!t)return[];if(Array.isArray(t))return t.map(function(r){if(typeof r=="string"&&r.trim())return{type:"entity",value:r.trim()};if(!r||typeof r!="object")return null;var o=r.value||r.name||r.text||"";return o?{type:r.type||"entity",value:String(o),context:r.context||""}:null}
204).filter(Boolean);if(typeof t=="object"){var n=[];return Object.keys(t).forEach(function(r){(Array.isArray(t[r])?t[r]:[t[r]]).forEach(function(o){var a=typeof o=="string"?o:o&&(o.value||o.name||o.text)||"";a&&n.push({type:o&&o.type||r,value:String(a),context:o&&o.context||""})})}),n}return[]}function B5(t,n){for(var r=[],o=[],a="",l=!1,s=String(t||""),c=n||500,d=0;d<s.length;d++){var p=s[d];if(l)p==='"'?s[d+1]==='"'?(a+='"',d++):l=!1:a+=p;else if(p==='"')l=!0;else if(p===",")o.push(a),a="";else if(p===`
205`||p==="\r"){if(p==="\r"&&s[d+1]===`
206`&&d++,o.push(a),a="",(o.length>1||o[0]!=="")&&r.push(o),o=[],r.length>=c)return r}else a+=p}return(a!==""||o.length>0)&&(o.push(a),(o.length>1||o[0]!=="")&&r.push(o)),r}var qm="monospace";function Ky(t){var n=t&&t.content||"",r=(0,i.useMemo)(function(){try{return B5(n)}catch{return null}},[n]);if(!r||r.length===0)return(0,e.jsx)("pre",{style:{margin:0,padding:12,fontFamily:qm,fontSize:12,color:"#C5CAD2",whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:n});var o=r[0],a=r.slice(1);return(0,e.jsxs)("div",{style:{overflow:"auto",padding:8},children:[(0,e.jsxs)("table",{style:{borderCollapse:"collapse",width:"100%",fontFamily:qm,fontSize:12},children:[(0,e.jsx)("thead",{children:(0,e.jsx)("tr",{children:o.map(function(l,s){return(0,e.jsx)("th",{style:{textAlign:"left",padding:"6px 10px",borderBottom:"2px solid rgba(212,175,92,0.4)",color:"#D4AF5C",fontSize:11,letterSpacing:".04em",whiteSpace:"nowrap"},children:l},s)})})}),(0,e.jsx)("tbody",{children:a.map(function(l,s){return(0,e.jsx)("tr",{style:{background:s%2?"rgba(255,255,255,0.02)":"transparent"},children:l.map(function(c,d){return(0,e.jsx)("td",{style:{padding:"5px 10px",borderBottom:"1px solid #1E2838",color:"#C5CAD2"},children:c},d)})},s)})})]}),(0,e.jsxs)("div",{style:{marginTop:8,fontFamily:qm,fontSize:9,color:"#5A7090"},children:[a.length," row",a.length===1?"":"s"," · ",o.length," column",o.length===1?"":"s"]})]})}var TL=2*1024*1024,P5=["png","jpg","jpeg","gif","webp"],U5=["mp4","mov","webm","m4v"],W5=["mp3","wav","m4a","ogg","flac"],H5=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel"];function G5(t){var n=String(t||""),r=n.lastIndexOf(".");return r<0||r===n.length-1?"":n.slice(r+1).toLowerCase()}function Mv(t,n){var r=String(t||"").toLowerCase().split(";")[0].trim(),o=G5(n);return o==="csv"||r==="text/csv"||r==="application/csv"?"csv":o==="xlsx"||o==="xls"||H5.indexOf(r)!==-1?"xlsx":r.indexOf("image/")===0||P5.indexOf(o)!==-1?"image":r.indexOf("video/")===0||U5.indexOf(o)!==-1?"video":r.indexOf("audio/")===0||W5.indexOf(o)!==-1?"audio":r==="application/pdf"||o==="pdf"?"pdf":"text"}function V5(t,n){var r=n||2097152,o=Number(t);return!Number.isFinite(o)||o<=0?!1:o>r}var Jn=vr,fr=va.amber,Wu=va.cyan,qd=va.green,ml=va.red,Hc=va.purple,$s=va.dim,$a="#C9D1D9",ya="#7A90A8",Y5="#6A8098";function hl({label:t,color:n}){return(0,e.jsx)("span",{style:{fontFamily:Jn,fontSize:9,color:n||ya,background:(n||ya)+"14",border:"1px solid "+(n||ya)+"28",borderRadius:3,padding:"1px 5px"},children:t})}function K5({doc:t,onClose:n,onAsk:r}){const[o,a]=(0,i.useState)(null),[l,s]=(0,i.useState)("content"),[c,d]=(0,i.useState)(!1),[p,g]=(0,i.useState)(!1),[f,h]=(0,i.useState)(null),[x,v]=(0,i.useState)({status:"idle",text:""}),[y,k]=(0,i.useState)(0),[A,j]=(0,i.useState)(null),E=t?Mv((o||t).content_type,(o||t).original_filename||(o||t).name):"text",C=o&&o.download_url||null,_=t?t.id||t.name:null;if(_!==A&&(j(_),t)){const q=t.content_preview||t.content;a(q||!t.id?t:null),s(Mv(t.content_type,t.original_filename||t.name)!=="text"?"viewer":"content"),h(null),v({status:"idle",text:""}),d(!!t.id&&!q),g(!!t.id)}(0,i.useEffect)(()=>{if(!t||!t.id)return;let q=!0;return gn.get(t.id).then(ge=>{q&&(a(X=>({...X||t,...ge||{}})),d(!1),g(!1))}).catch(()=>{q&&(a(ge=>ge||t),d(!1),g(!1))}),()=>{q=!1}},[_,y]);const w=V5((o||t||{}).size_bytes);(0,i.useEffect)(()=>{if(E!=="csv"||!C||w||x.status!=="idle")return;let q=!0;return fetch(C).then(async ge=>{if(!ge.ok)throw new Error("HTTP "+ge.status);const X=await ge.blob();if(X.size>2097152){q&&v({status:"toolarge",text:""});return}const de=await X.text();q&&v({status:"ready",text:de})}).catch(()=>{q&&v({status:"error",text:""})}),()=>{q=!1}},[E,C,w,x.status]);function O(){h(null),v({status:"idle",text:""}),a(q=>q&&{...q,download_url:null}),g(!0),k(q=>q+1)}if(!t)return null;const M=o||t,U="Document content is not available in this preview. Upload the document to the vault to enable full text preview.",ee=M.content||M.content_preview||"",N=!!ee.trim(),V=N?ee:U,z=N?V.trim().split(/\s+/).length:0,oe=ld(M.name),P=M.intelligence||{},W=k2(M),R=[];E!=="text"&&R.push({id:"viewer",label:"VIEWER"}),R.push({id:"content",label:"CONTENT"},{id:"intelligence",label:"AI INTELLIGENCE"},{id:"entities",label:"ENTITIES ("+W.length+")"}),P.contract_analysis&&R.push({id:"contract",label:"CONTRACT"}),P.compliance_check&&R.push({id:"compliance",label:"COMPLIANCE"});function ae(){const q=window.open("","_blank");q&&(q.document.write(`<html><head><title>${M.name}</title><style>
207        body{font-family:Georgia,serif;max-width:700px;margin:40px auto;padding:0 20px;
207color:#1a1a1a;line-height:1.8;font-size:14px}
208        pre{white-space:pre-wrap;font-family:inherit}
209        .badge{display:inline-block;padding:2px 8px;border-radius:4px;font-size:11px;margin-right:6px}
210      </style></head><body>
211        <h1 style="font-size:20px;margin-bottom:4px">${M.name}</h1>
212        <p style="color:#888;font-size:12px;margin-bottom:8px">${z} words · ${M.type||"GENERAL"} · v${M.version||1}</p>
213        ${M.ai_summary?`<div style="background:#f5f5f5;padding:12px;border-radius:6px;margin-bottom:16px;font-size:13px"><strong>AI Summary:</strong> ${M.ai_summary}</div>`:""}
214        <pre>${V}</pre>
215      </body></html>`),q.document.close(),setTimeout(()=>q.print(),400))}return(0,e.jsx)("div",{style:{position:"fixed",inset:0,zIndex:500,background:"rgba(3,5,8,0.65)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:q=>{q.target===q.currentTarget&&n()},role:"dialog","aria-label":"Document preview",children:(0,e.jsxs)("div",{style:{width:800,maxWidth:"92vw",maxHeight:"88vh",background:"rgba(8,11,17,0.82)",backdropFilter:"blur(24px) saturate(140%)",WebkitBackdropFilter:"blur(24px) saturate(140%)",border:"1px solid #1E2838",borderTop:"1px solid #9E7E35",borderRadius:3,display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 30px 80px rgba(0,0,0,0.75), inset 0 1px 0 rgba(228,194,122,0.05)"},children:[(0,e.jsxs)("div",{style:{padding:"14px 20px",borderBottom:"1px solid #111820",background:"#05080D",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,minWidth:0},children:[(0,e.jsx)("div",{style:{width:32,height:32,background:oe+"18",border:"1px solid "+oe+"33",borderRadius:6,display:"flex",alignItems:"center",justifyContent:"center",fontFamily:Jn,fontSize:9,fontWeight:700,color:oe,flexShrink:0},children:tc(M.name)}),(0,e.jsxs)("div",{style:{minWidth:0},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:4,marginBottom:3},children:[(0,e.jsx)(hl,{label:M.ai_classification||M.type||"GENERAL",color:Hc}),P.urgency&&(0,e.jsx)(hl,{label:P.urgency,color:P.urgency==="HIGH"?ml:P.urgency==="MEDIUM"?fr:qd}),M.ai_confidence>0&&(0,e.jsx)(hl,{label:(M.ai_confidence*100).toFixed(0)+"% conf",color:Wu}),(0,e.jsx)(hl,{label:"v"+(M.version||1)})]}),(0,e.jsx)("div",{style:{fontWeight:700,fontSize:14,color:$a,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:M.name}),(0,e.jsxs)("div",{style:{fontFamily:Jn,fontSize:8,color:ya,marginTop:2},children:[z.toLocaleString()," words ·"," ",M.size_bytes?(M.size_bytes/1024).toFixed(0)+"KB":M.size||"—"," ","· ",(M.created_at||M.date||"").substring(0,10)]})]})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:6,flexShrink:0},children:[r&&(0,e.jsx)("button",{onClick:()=>{GS(M,"What is the company name mentioned in this document? Summarise the key points."),n(),r("[Vault: "+M.name+"] Analyse this document",M)},style:{padding:"6px 14px",background:fr+"18",border:"1px solid "+fr+"44",borderRadius:6,cursor:"pointer",fontFamily:Jn,fontSize:9,color:fr},onMouseEnter:q=>{q.currentTarget.style.background=fr+"28"},onMouseLeave:q=>{q.currentTarget.style.background=fr+"18"},children:"› ASK XYRON"}),(0,e.jsx)("button",{onClick:ae,style:{padding:"6px 14px",background:"transparent",border:"1px solid #2A3548",borderRadius:6,cursor:"pointer",fontFamily:Jn,fontSize:9,color:ya},onMouseEnter:q=>{q.currentTarget.style.borderColor="#3A4556",q.currentTarget.style.color=$a},onMouseLeave:q=>{q.currentTarget.style.borderColor="#2A3548",q.currentTarget.style.color=ya},children:"PRINT"}),(0,e.jsx)("button",{onClick:n,style:{background:"transparent",border:"1px solid #2A3548",borderRadius:5,color:ya,cursor:"pointer",width:28,height:28,display:"flex",alignItems:"center",justifyContent:"center",fontSize:14},onMouseEnter:q=>{q.currentTarget.style.color=ml},onMouseLeave:q=>{q.currentTarget.style.color=ya},"aria-label":"Close preview",children:"✕"})]})]}),(0,e.jsx)("div",{style:{display:"flex",borderBottom:"1px solid #111820",background:"#05080D",flexShrink:0,padding:"0 20px"},children:R.map(q=>(0,e.jsx)("button",{onClick:()=>s(q.id),style:{padding:"8px 14px",background:"transparent",border:"none",borderBottom:l===q.id?"2px solid "+fr:"2px s
215olid transparent",cursor:"pointer",fontFamily:Jn,fontSize:8,letterSpacing:".08em",color:l===q.id?fr:$s},children:q.label},q.id))}),(0,e.jsx)("div",{style:{flex:1,overflow:"auto",padding:"20px 24px"},children:c?(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:40},children:[(0,e.jsx)("div",{style:{width:14,height:14,border:"2px solid "+fr+"33",borderTop:"2px solid "+fr,borderRadius:"50%",animation:"xspin 1s linear infinite"}}),(0,e.jsx)("span",{style:{fontFamily:Jn,fontSize:10,color:$s,marginLeft:10},children:"Loading document..."})]}):l==="viewer"?(0,e.jsxs)("div",{role:"region","aria-label":"Rich preview of "+M.name,style:{display:"flex",flexDirection:"column",gap:12,minHeight:300,height:"100%"},children:[f?(0,e.jsxs)("div",{style:{padding:30,textAlign:"center"},children:[(0,e.jsx)("div",{style:{fontFamily:Jn,fontSize:10,color:ml,marginBottom:12},children:f}),(0,e.jsx)("button",{onClick:O,style:{padding:"6px 14px",background:fr+"18",border:"1px solid "+fr+"44",borderRadius:6,cursor:"pointer",fontFamily:Jn,fontSize:9,color:fr},children:"↻ REFRESH PREVIEW"})]}):E==="xlsx"?(0,e.jsxs)("div",{style:{padding:30,textAlign:"center",fontFamily:Jn,fontSize:10,color:$s,lineHeight:1.8},children:["Excel workbooks can't be previewed inline — download the file to open it in a spreadsheet application.",C&&(0,e.jsx)("div",{style:{marginTop:10},children:(0,e.jsxs)("a",{href:C,download:M.name,style:{color:fr,fontFamily:Jn,fontSize:9},children:["↓ DOWNLOAD ",M.name]})})]}):C?E==="image"?(0,e.jsx)("img",{src:C,alt:M.name,onError:()=>h("Image failed to load — the preview link may have expired."),style:{maxWidth:"100%",maxHeight:"60vh",objectFit:"contain",borderRadius:4,border:"1px solid #1E2838",alignSelf:"center"}}):E==="video"?(0,e.jsx)("video",{controls:!0,src:C,"aria-label":"Video preview: "+M.name,onError:()=>h("Video failed to load — the preview link may have expired."),style:{width:"100%",maxHeight:"60vh",borderRadius:4,background:"#000",border:"1px solid #1E2838"}}):E==="audio"?(0,e.jsx)("audio",{controls:!0,src:C,"aria-label":"Audio preview: "+M.name,onError:()=>h("Audio failed to load — the preview link may have expired."),style:{width:"100%"}}):E==="pdf"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("iframe",{src:C,title:"PDF preview: "+M.name,style:{width:"100%",height:"58vh",border:"1px solid #1E2838",borderRadius:4,background:"#FFFFFF"}}),(0,e.jsxs)("div",{style:{fontFamily:Jn,fontSize:8,color:ya},children:["PDF not rendering?"," ",(0,e.jsx)("a",{href:C,target:"_blank",rel:"noopener noreferrer",style:{color:fr},children:"Open in a new tab"})," ","or refresh the preview below."]})]}):E==="csv"?w||x.status==="toolarge"?(0,e.jsxs)("div",{style:{padding:30,textAlign:"center",fontFamily:Jn,fontSize:10,color:$s,lineHeight:1.8},children:["File too large for inline preview (over 2MB) — download instead.",C&&(0,e.jsx)("div",{style:{marginTop:10},children:(0,e.jsxs)("a",{href:C,download:M.name,style:{color:fr,fontFamily:Jn,fontSize:9},children:["↓ DOWNLOAD ",M.name]})})]}):x.status==="error"?(0,e.jsxs)("div",{style:{padding:30,textAlign:"center"},children:[(0,e.jsx)("div",{style:{fontFamily:Jn,fontSize:10,color:ml,marginBottom:12},children:"Could not fetch the CSV — the preview link may have expired."}),(0,e.jsx)("button",{onClick:O,style:{padding:"6px 14px",background:fr+"18",border:"1px solid "+fr+"44",borderRadius:6,cursor:"pointer",fontFamily:Jn,fontSize:9,color:fr},children:"↻ REFRESH PREVIEW"})]}):x.status==="ready"?(0,e.jsx)(Ky,{content:x.text}):(0,e.jsx)("div",{style:{padding:30,textAlign:"center",fontFamily:Jn,fontSize:10,color:$s},children:"Loading CSV..."}):null:(0,e.jsx)("div",{style:{padding:30,textAlign:"center",fontFamily:Jn,fontSize:10,color:$s},children:p?"Fetching preview link...":(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:{marginBottom:12},children:"Preview link unavailable."}),(0,e.jsx)("button",{onClick:O,style:{padding:"6px 14px",background:fr+"18",border:"1px solid "+fr+"44",borderRadius:6,cursor:"pointer",fontFamily:Jn,fontSize:9,color:fr},children:"↻ REFRESH PREVIEW"})]})}),(0,e.jsxs)("div",{style:{marginTop:"auto",display:"flex",alignItems:"center",gap:10,paddingTop:8},children:[(0,e.jsx)("span",{style:{fontFamily:Jn,fontSize:9,color:$s,letterSpacing:".08em"},children:"SIGNED PREVIEW LINK · ~5 MIN TTL"}),(0,e.jsx)("button",{onClick:O,"aria-label":"Refresh preview link",style:{padding:"3px 10px",background:"transparent",border:"1px solid #2A3548",borderRadius:5,cursor:"pointer",fontFamily:Jn,fontSize:8,color:ya},children:"↻ REFRESH"})]})]}):l==="content"?(0,e.jsxs)(e.Fragment,{children:[M.ai_summary&&(0,e.jsxs)("div",{style:{background:Hc+"0C",border:"1px solid "+Hc+"28",borderRadius:6,padding:"10px 14px",marginBottom:16,borderLeft:"3px solid "+Hc},children:[(0,e.jsx)("div",{style:{fontFamily:Jn,fontSize:9,color:Hc,letterSpacing:".1em",marginBottom:4},children:"AI SUMMARY"}),(0,e.jsx)("div",{style:{fontSize:12,color:$a,lineHeight:"1.6"},children:M.ai_summary})]}),N?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:10,marginBottom:8,paddingBottom:6,borderBottom:"1px solid #1E2838"},children:[(0,e.jsx)("span",{style:{fontFamily:Jn,fontSize:9,color:ya,letterSpacing:".14em",textTransform:"uppercase"},children:"Document Text"}),(0,e.jsxs)("span",{style:{fontFamily:Jn,fontSize:8,color:Y5,letterSpacing:".06em"}
215,children:[z.toLocaleString()," words"]})]}),(0,e.jsx)("div",{style:{background:"#0A0E15",border:"1px solid #1A2230",borderRadius:6,padding:"16px 18px"},children:(0,e.jsx)("div",{style:{whiteSpace:"pre-wrap",fontSize:13,color:$a,lineHeight:"1.75",fontFamily:Tf,margin:0},children:V})})]}):(0,e.jsx)("div",{style:{padding:"32px 24px",textAlign:"center",border:"1px dashed #1E2838",borderRadius:6},children:(0,e.jsxs)("div",{style:{fontFamily:Jn,fontSize:10,color:ya,lineHeight:1.7,maxWidth:380,margin:"0 auto"},children:["No extracted text yet. Scanned PDFs and images are read on demand — use ",(0,e.jsx)("span",{style:{color:fr},children:"ASK XYRON"})," ","or the Analyse actions to study this document, or download it to view the original."]})})]}):l==="intelligence"?(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[M.ai_summary&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:Jn,fontSize:8,color:Hc,letterSpacing:".1em",marginBottom:4},children:"SUMMARY"}),(0,e.jsx)("div",{style:{fontSize:12,color:$a,lineHeight:"1.6"},children:M.ai_summary})]}),P.risk_flags?.length>0&&(0,e.jsxs)("div",{style:{background:ml+"08",border:"1px solid "+ml+"22",borderRadius:6,padding:"10px 12px"},children:[(0,e.jsx)("div",{style:{fontFamily:Jn,fontSize:8,color:ml,letterSpacing:".1em",marginBottom:5},children:"RISK FLAGS"}),P.risk_flags.map((q,ge)=>{const X=DS(q);return(0,e.jsxs)("div",{style:{fontSize:11,color:$a,lineHeight:"1.5",display:"flex",gap:6},children:[(0,e.jsx)("span",{style:{color:ml},children:"•"}),(0,e.jsxs)("span",{children:[X.severity&&(0,e.jsx)("span",{style:{fontFamily:Jn,fontSize:8,fontWeight:700,textTransform:"uppercase",color:ml,border:"1px solid "+ml+"55",borderRadius:3,padding:"0 4px",marginRight:5},children:X.severity}),X.text,X.location&&(0,e.jsxs)("span",{style:{color:ya,fontStyle:"italic"},children:[" ","— ",X.location]})]})]},ge)})]}),P.action_items?.length>0&&(0,e.jsxs)("div",{style:{background:fr+"08",border:"1px solid "+fr+"22",borderRadius:6,padding:"10px 12px"},children:[(0,e.jsx)("div",{style:{fontFamily:Jn,fontSize:8,color:fr,letterSpacing:".1em",marginBottom:5},children:"ACTION ITEMS"}),P.action_items.map((q,ge)=>(0,e.jsxs)("div",{style:{fontSize:11,color:$a,lineHeight:"1.5",display:"flex",gap:6},children:[(0,e.jsx)("span",{style:{color:fr},children:"→"})," ",q]},ge))]}),P.key_dates?.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:Jn,fontSize:8,color:Wu,letterSpacing:".1em",marginBottom:5},children:"KEY DATES"}),P.key_dates.map((q,ge)=>(0,e.jsxs)("div",{style:{display:"flex",gap:10,padding:"4px 0",borderBottom:"1px solid #111820",fontSize:11},children:[(0,e.jsx)(hl,{label:q.date,color:fr}),(0,e.jsx)("span",{style:{color:$a},children:q.description})]},ge))]}),P.key_amounts?.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:Jn,fontSize:8,color:qd,letterSpacing:".1em",marginBottom:5},children:"KEY AMOUNTS"}),P.key_amounts.map((q,ge)=>(0,e.jsxs)("div",{style:{display:"flex",gap:10,padding:"4px 0",borderBottom:"1px solid #111820",fontSize:11},children:[(0,e.jsx)(hl,{label:(q.currency||"")+" "+q.amount,color:qd}),(0,e.jsx)("span",{style:{color:$a},children:q.context})]},ge))]}),P.obligations?.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:Jn,fontSize:8,color:Wu,letterSpacing:".1em",marginBottom:5},children:"OBLIGATIONS"}),P.obligations.map((q,ge)=>(0,e.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",padding:"5px 0",borderBottom:"1px solid #111820",fontSize:11},children:[(0,e.jsxs)("span",{style:{color:$a},children:[(0,e.jsxs)("strong",{children:[q.party,":"]})," ",q.obligation]}),q.deadline&&(0,e.jsx)(hl,{label:q.deadline,color:fr})]},ge))]}),Object.keys(P).length===0&&(0,e.jsx)("div",{style:{padding:30,textAlign:"center",fontFamily:Jn,fontSize:10,color:$s},children:"No intelligence data yet. Upload the document to trigger AI analysis."})]}):l==="entities"?(0,e.jsx)("div",{children:W.length>0?(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:W.map((q,ge)=>{const X={person:Wu,org:Hc,amount:qd,date:fr,asset:"#E879F9",jurisdiction:"#C89850"}[q.type]||ya;return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"6px 10px",background:"#0C1018",border:"1px solid #1E2838",borderRadius:5},children:[(0,e.jsx)(hl,{label:q.type?.toUpperCase(),color:X}),(0,e.jsx)("span",{style:{fontSize:12,color:$a,fontWeight:600},children:q.value}
215),q.context&&(0,e.jsx)("span",{style:{fontSize:10,color:ya,flex:1},children:q.context})]},ge)})}):(0,e.jsx)("div",{style:{padding:30,textAlign:"center",fontFamily:Jn,fontSize:10,color:$s},children:"No entities extracted."})}):l==="contract"?(0,e.jsx)("pre",{style:{fontSize:11,color:$a,lineHeight:"1.6",whiteSpace:"pre-wrap",fontFamily:Jn},children:JSON.stringify(P.contract_analysis,null,2)}):l==="compliance"?(0,e.jsx)("div",{children:P.compliance_check&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{style:{display:"flex",gap:8,marginBottom:14},children:[(0,e.jsx)(hl,{label:P.compliance_check.compliance_status,color:P.compliance_check.compliance_status==="COMPLIANT"?qd:P.compliance_check.compliance_status==="NON_COMPLIANT"?ml:fr}),P.compliance_check.score!=null&&(0,e.jsx)(hl,{label:"Score: "+P.compliance_check.score+"/100",color:Wu})]}),P.compliance_check.findings?.map((q,ge)=>(0,e.jsxs)("div",{style:{padding:"8px 10px",background:"#0C1018",border:"1px solid #1E2838",borderRadius:5,marginBottom:6},children:[(0,e.jsx)("div",{style:{display:"flex",gap:6,marginBottom:4},children:(0,e.jsx)(hl,{label:q.severity,color:q.severity==="HIGH"?ml:q.severity==="MEDIUM"?fr:qd})}),(0,e.jsx)("div",{style:{fontSize:11,color:$a,lineHeight:"1.5"},children:q.finding}),q.recommendation&&(0,e.jsxs)("div",{style:{fontSize:10,color:Wu,marginTop:4},children:["→ ",q.recommendation]})]},ge))]})}):null}),(0,e.jsxs)("div",{style:{padding:"10px 20px",borderTop:"1px solid #111820",flexShrink:0,display:"flex",alignItems:"center",gap:8},children:[(0,e.jsx)("div",{style:{fontFamily:Jn,fontSize:8,color:qd},children:"● INDEXED"}),M.ai_classification&&(0,e.jsx)(hl,{label:"AI: "+M.ai_classification,color:Hc})]})]})})}var X5=new Set(["A","I","THE","AND","OR","BUT","FOR","NOT","CEO","CFO","COO","CTO","GDP","CPI","PMI","FED","ECB","BOJ","IMF","USA","USD","EUR","GBP","JPY","YOY","QOQ","EPS","IPO","ETF","API","AI","ML","UI","UX","OK","NO","YES","TO","IN","ON","AT","OF","IS","IT","BE","AS","BY","AN","WE","Q1","Q2","Q3","Q4","FY","TTM"]),Nv=/\b[A-Z]{1,5}(?:\.[A-Z])?\b/g,sy=/(-?\d[\d,]*(?:\.\d+)?)\s*%/,cy=/([$€£¥])\s?(-?\d[\d,]*(?:\.\d+)?)\s*(bn|billion|m|mn|million|k|thousand|tn|trillion)?/i,q5=/\b(-?\d[\d,]*(?:\.\d+)?)\s*(bn|billion|m|mn|million|k|thousand|bps)?\b/i,$5=["think","believe","expect","view","should","likely","bullish","bearish","conviction","overweight","underweight","thesis","because","risk","opportunity","undervalued","overvalued"],J5=["announce","announced","launch","launched","acquire","acquired","merger","files","filed","reports","reported","guidance","earnings","will report","scheduled","effective","closed","completed"],Q5=/\b(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*\.?\s+\d{1,2}\b|\b\d{4}-\d{2}-\d{2}\b|\bQ[1-4]\s?\d{2,4}\b/i;function Z5(t){const n=[];let r;for(Nv.lastIndex=0;(r=Nv.exec(t))!==null;){const o=r[0];X5.has(o)||o.length!==1&&n.push(o)}return n.length?n[0]:null}function e8(t){const n=t.match(sy);if(n)return{value:Number(n[1].replace(/,/g,"")),unit:"%"};const r=t.match(cy);if(r){const a=r[1];return{value:Number(r[2].replace(/,/g,"")),unit:{$:"USD","€":"EUR","£":"GBP","¥":"JPY"}[a]||a,magnitude:r[3]?r[3].toLowerCase():null}}const o=t.match(q5);return o?{value:Number(o[1].replace(/,/g,"")),unit:o[2]?o[2].toLowerCase():null}:null}function t8(t,n){if(t==null||!n)return t;const r=String(n).toLowerCase();return r==="k"||r==="thousand"?t*1e3:r==="m"||r==="mn"||r==="million"?t*1e6:r==="bn"||r==="billion"?t*1e9:r==="tn"||r==="trillion"?t*1e12:t}function Bv(t,n){return n.some(r=>t.includes(r))}function Pv(t){const n=t.toLowerCase();for(const[r,o]of[["gross margin","gross_margin"],["operating margin","operating_margin"],["net margin","net_margin"],["last close","price"],["share price","price"],["stock price","price"],["price target","price_target"],["market cap","market_cap"],["mkt cap","market_cap"],["free cash flow","free_cash_flow"],["pe ratio","pe"],["p/e","pe"],["revenue","revenue"],["deliveries","deliveries"],["delivery","deliveries"],["volume","volume"],["eps","eps"],["fcf","free_cash_flow"],["guidance","guidance"],["yield","yield"],["growth","growth"]])if(n.includes(r))return o;return null}function n8(t){const n=(t||"").trim();if(!n)return{suggestedKind:"note",entity:null,metric:null};const r=n.toLowerCase(),o=Z5(n),a=e8(n);let l="note";const s=sy.test(n)||cy.test(n),c=!!Pv(n);
215a&&(s||c)&&(l="metric"),l==="note"&&(Bv(r,J5)||Q5.test(n))&&(l="event"),l==="note"&&Bv(r,$5)&&(l="thesis"),a&&(sy.test(n)||cy.test(n)||c)&&l==="thesis"&&(l="metric");let d=null;return a&&(d={metric_key:Pv(n),value:t8(a.value,a.magnitude),unit:a.unit}),{suggestedKind:l,entity:o,metric:d}}var Uv=/\$?\b([A-Z]{2,5})\b/g,r8={THE:1,AND:1,FOR:1,NOT:1,CEO:1,CFO:1,CTO:1,GDP:1,CPI:1,USA:1,USD:1,EUR:1,GBP:1,JPY:1,EPS:1,IPO:1,ETF:1,API:1,YOY:1,QOQ:1,FED:1,ECB:1,IMF:1,NYSE:1,AI:1,ML:1};function i8(t){var n=typeof t=="string"?t:"";Uv.lastIndex=0;for(var r;(r=Uv.exec(n))!==null;){var o=r[1];if(!r8[o])return o}return null}function o8(t,n){var r=typeof t=="string"?t:"";r=r.replace(/\s+/g," ").trim();var o=typeof n=="number"&&n>0?n:4e3;return r.length>o&&(r=r.slice(0,o)),r}function a8(t){t=t||{};var n=o8(t.text);if(!n)return null;var r={};t.sessionId&&(r.session_id=String(t.sessionId)),t.messageId&&(r.message_id=String(t.messageId)),t.role&&(r.role=String(t.role)),t.projectId&&(r.project_id=String(t.projectId)),t.projectName&&(r.project_name=String(t.projectName)),r.surface="chat";var o=n8(n),a=o&&(o.suggestedKind==="metric"||o.metric&&o.metric.value!=null),l={kind:a?"metric":"note",source_quote:n,captured_via:"chat",context:r},s=t.entityHint||o&&o.entity||i8(n);if(s&&(l.entity_hint=s),a&&o.metric&&o.metric.value!=null){var c={value:o.metric.value,metric_key:o.metric.metric_key||"observation"};o.metric.unit&&(c.unit=o.metric.unit),l.metric=c}return l}function l8(t){return!t||!t.atom_id?{ok:!1,deduped:!1,text:"Capture failed."}:t.deduped?{ok:!0,deduped:!0,text:"Already in Intel Graph.",entity:t.entity_symbol||null}:{ok:!0,deduped:!1,text:t.entity_symbol?"Saved to Intel Graph · "+t.entity_symbol:"Saved to Intel Graph.",entity:t.entity_symbol||null}}var dy="xyron_vault_uploads",sg="xyron_vault_uploads_migrated_at",Wv=!1;function s8(){try{if(Wv||localStorage.getItem(sg)||!localStorage.getItem("xyron_jwt_token"))return;Wv=!0;var t=localStorage.getItem(dy);if(!t){localStorage.setItem(sg,new Date().toISOString());return}var n=JSON.parse(t);if(!Array.isArray(n)||n.length===0){localStorage.removeItem(dy),localStorage.setItem(sg,new Date().toISOString());return}console.log("[vault-migration] uploading "+n.length+" legacy localStorage entries to /api/vault");var r=0,o=0,a=0;n.forEach(function(l){var s=l&&l.name||"Legacy brief",c=l&&l.content||"",d=l&&l.tags||["chat-brief","migrated"];if(!c){a++,a===n.length&&Hv(r,o);return}gn.save(s,"chat-brief",c,d).then(function(p){p&&p.id?r++:o++}).catch(function(){o++}).finally(function(){a++,a===n.length&&Hv(r,o)})})}catch(l){console.warn("[vault-migration] failed:",l&&l.message)}}function Hv(t,n){if(console.log("[vault-migration] complete — ok="+t+" fail="+n),n===0)try{localStorage.removeItem(dy)}catch{}try{localStorage.setItem(sg,new Date().toISOString())}catch{}}function uy(t){var n=t.text||"",r=t.msgId||"",o=t.chart||null,a=(0,i.useState)(!1),l=a[0],s=a[1],c=(0,i.useState)(!1),d=c[0],p=c[1],g=(0,i.useState)(!1),f=g[0],h=g[1],x=(0,i.useState)(!1),v=x[0],y=x[1],k=(0,i.useState)(!1),A=k[0],j=k[1],E=(0,i.useState)(o?o.title||"Xyron Chart":"Xyron Intelligence Brief"),C=E[0],_=E[1],w="monospace";function O(){return(t.artifact&&t.artifact.title||o&&o.title||(n||"").substring(0,60)).replace(/[^a-zA-Z0-9]+/g," ").replace(/\s+/g," ").trim()||"Xyron Brief"}function M(){var te=String(n||"").split(`
216`).map(function(_e){return _e.trim()}).filter(Boolean)[0];return te?te.length>80?te.slice(0,80).trim()+"…":te:"Response"}function U(){var te=String(n||"").trim(),_e=t.artifact,ve=_e&&typeof _e.content=="string"?String(_e.content).trim():"";if(!ve)return te;if(!te)return ve;if(te===ve||te.indexOf(ve)!==-1)return te;var Ne=String(_e&&_e.type||"markdown").toLowerCase();if(Ne==="image"||Ne==="chart"||Ne==="video")return te;var $e=_e&&_e.title?String(_e.title).trim():"",Pe=$e&&te.indexOf($e)===-1?"## "+$e+`
217
218`+ve:ve;return te+`
219
220`+Pe}function ee(){return t.artifact?t.artifact:n&&n.trim()?{id:"msg-"+(r||"text"),type:"markdown",title:M(),content:n}:null}var N=t.sessionId||null,V=(0,i.useState)("idle"),z=V[0],oe=V[1],P=(0,i.useState)(""),W=P[0],R=P[1];function ae(te){try{var _e=window.getSelection&&window.getSelection(),ve=_e?String(_e).trim():"";if(_e&&ve){if(!te)return ve;var Ne=!!(_e.anchorNode&&te.contains(_e.anchorNode)),$e=!!(_e.focusNode&&te.contains(_e.focusNode));if(Ne&&$e)return ve}}catch{}return U()||n}function q(te){if(z!=="saving"){var _e=null;try{_e=te&&te.currentTarget&&te.currentTarget.closest?te.currentTarget.closest("[data-chat-message-id]"):null}catch{_e=null}var ve=a8({text:ae(_e),sessionId:N,messageId:r,role:t.role||"assistant",projectId:t.projectId||null,projectName:t.projectName||null});if(!ve){oe("err"),R("Nothing to capture."),setTimeout(function(){oe("idle")},2500);return}oe("saving"),R(""),hA.capture(ve).then(function(Ne){var $e=l8(Ne);if(!$e.ok){oe("err"),R($e.text),setTimeout(function(){oe("idle")},3e3);return}oe($e.deduped?"dedupe":"saved"),R($e.text),NS(),setTimeout(function(){oe("idle")},2500)}).catch(function(){oe("err"),R("Capture failed — check connection / auth."),setTimeout(function(){oe("idle")},3e3)})}}(0,i.useEffect)(function(){s8()},[]);function ge(){var te=U();try{navigator.clipboard.writeText(te)}catch{var _e=document.createElement("textarea");_e.value=te,document.body.appendChild(_e),_e.select(),document.execCommand("copy"),document.body.removeChild(_e)}s(!0),setTimeout(function(){s(!1)},2e3)}function X(){var te=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-");if(o){var _e=document.querySelector("canvas");if(_e){var ve=document.createElement("canvas");ve.width=_e.width,ve.height=_e.height+40;var Ne=ve.getContext("2d");Ne.fillStyle="#06080D",Ne.fillRect(0,0,ve.width,ve.height),Ne.fillStyle="#D4AF5C",Ne.font="bold 13px monospace",Ne.textAlign="left",Ne.fillText("XYRON INTELLIGENCE — "+(o.title||"").toUpperCase(),12,22),Ne.fillStyle="#5A7090",Ne.font="9px monospace",Ne.fillText(new Date().toLocaleStr
220ing(),12,36),Ne.drawImage(_e,0,40);var $e=document.createElement("a");$e.href=ve.toDataURL("image/png"),$e.download=(C||"chart").replace(/\s+/g,"-").toLowerCase()+"-"+te+".png",document.body.appendChild($e),$e.click(),document.body.removeChild($e);return}}var Pe=`XYRON INTELLIGENCE BRIEF
221`+new Date().toLocaleString()+`
222`+"=".repeat(60)+`
223
224`+U(),ot=document.createElement("a");ot.href="data:text/plain;charset=utf-8,"+encodeURIComponent(Pe),ot.download=(C||"Xyron-Brief")+"-"+te+".txt",ot.style.display="none",document.body.appendChild(ot),ot.click(),document.body.removeChild(ot)}function de(te){if(!v){var _e=(te||C||"Xyron Brief").trim(),ve=new Date().toISOString().slice(0,19).replace("T"," ");y(!0),h(!1);var Ne=U();if(o)try{var $e=document.querySelectorAll("canvas");$e.length>0&&$e[$e.length-1]&&(Ne="[Chart attached: "+(o.title||"Untitled")+`]
225(captured `+ve+`)
226
227`+n)}catch{}var Pe=o?["chat-brief","chart"]:["chat-brief"],ot=o?"chart":"chat-brief";gn.save(_e,ot,Ne,Pe).then(function(re){y(!1),re&&re.id?(p(!0),j(!1),setTimeout(function(){p(!1)},2500)):(h(!0),setTimeout(function(){h(!1)},3e3))}).catch(function(){y(!1),h(!0),setTimeout(function(){h(!1)},3e3)})}}var We={display:"flex",alignItems:"center",gap:4,padding:"3px 8px",background:"transparent",border:"1px solid #0D1520",borderRadius:4,cursor:"pointer",fontFamily:w,fontSize:7,letterSpacing:".06em",transition:"all .12s"};return(0,e.jsxs)("div",{style:{position:"relative"},children:[(0,e.jsxs)("div",{className:"xy-msg-actions",style:{display:"flex",gap:5,marginTop:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("button",{onClick:ge,style:Object.assign({},We,{color:l?"#3FB950":"#3A4A5E",borderColor:l?"rgba(63,185,80,0.3)":"#0D1520"}),onMouseEnter:function(te){te.currentTarget.style.borderColor="#1E2838",te.currentTarget.style.color="#8FA3B8"},onMouseLeave:function(te){l||(te.currentTarget.style.borderColor="#0D1520",te.currentTarget.style.color="#3A4A5E")},children:[(0,e.jsx)("span",{children:l?"✓":"⎘"}),(0,e.jsx)("span",{children:l?"COPIED":"COPY"})]}),(0,e.jsxs)("button",{onClick:function(){v||j(function(te){return!te})},disabled:v,title:f?"Save failed — check connection / auth and retry":"Save this brief to your Vault",style:Object.assign({},We,{color:f?"#F97583":d||v?"#D4AF5C":"#3A4A5E",borderColor:f?"rgba(249,117,131,0.4)":d?"rgba(212,175,92,0.3)":"#0D1520",cursor:v?"wait":"pointer",opacity:v?.75:1}),onMouseEnter:function(te){!f&&!v&&(te.currentTarget.style.borderColor="#1E2838",te.currentTarget.style.color="#D4AF5C")},onMouseLeave:function(te){!d&&!f&&!v&&(te.currentTarget.style.borderColor="#0D1520",te.currentTarget.style.color="#3A4A5E")},children:[(0,e.jsx)("span",{children:f?"✕":v?"◌":"⊗"}),(0,e.jsx)("span",{children:f?"SAVE FAILED":v?"SAVING…":d?"SAVED":"SAVE TO VAULT"})]}),(0,e.jsxs)("button",{onClick:q,disabled:z==="saving",title:W||"Save this message (or your selection) to the Intel Graph",style:Object.assign({},We,{color:z==="err"?"#F97583":z==="saved"||z==="dedupe"||z==="saving"?"#5BA8A0":"#3A4A5E",borderColor:z==="err"?"rgba(249,117,131,0.4)":z==="saved"||z==="dedupe"?"rgba(91,168,160,0.3)":"#0D1520",cursor:z==="saving"?"wait":"pointer",opacity:z==="saving"?.75:1}),onMouseEnter:function(te){z==="idle"&&(te.currentTarget.style.borderColor="#1E2838",te.currentTarget.style.color="#5BA8A0")},onMouseLeave:function(te){z==="idle"&&(te.currentTarget.style.borderColor="#0D1520",te.currentTarget.style.color="#3A4A5E")},children:[(0,e.jsx)("span",{children:z==="err"?"✕":z==="saving"?"◌":z==="saved"||z==="dedupe"?"◆":"⬡"}),(0,e.jsx)("span",{children:z==="err"?"FAILED":z==="saving"?"SAVING":z==="saved"?"SAVED":z==="dedupe"?"IN GRAPH":"INTEL GRAPH"})]}),(0,e.jsxs)("button",{onClick:X,style:Object.assign({},We,{color:"#3A4A5E"}),onMouseEnter:function(te){te.currentTarget.style.borderColor="#1E2838",te.currentTarget.style.color="#D4AF5C"},onMouseLeave:function(te){te.currentTarget.style.borderColor="#0D1520",te.currentTarget.style.color="#3A4A5E"},children:[(0,e.jsx)("span",{children:"↓"}
227),(0,e.jsx)("span",{children:o?"DOWNLOAD PNG":"DOWNLOAD"})]}),t.allowSplit!==!1&&ee()&&(0,e.jsxs)("button",{onClick:function(){var te=ee();te&&t.onOpenArtifact&&t.onOpenArtifact(te)},title:"Open this response in the side panel",style:Object.assign({},We,{color:"#D4AF5C",borderColor:"rgba(212,175,92,0.3)"}),onMouseEnter:function(te){te.currentTarget.style.borderColor="rgba(212,175,92,0.5)",te.currentTarget.style.color="#E8C877"},onMouseLeave:function(te){te.currentTarget.style.borderColor="rgba(212,175,92,0.3)",te.currentTarget.style.color="#D4AF5C"},children:[(0,e.jsx)("span",{style:{fontSize:8},children:"◫"}),(0,e.jsx)("span",{children:"OPEN IN SPLIT"})]}),(0,e.jsxs)("button",{onClick:function(){uu.generatePDF(O(),U())},style:Object.assign({},We,{color:"#3A4A5E"}),onMouseEnter:function(te){te.currentTarget.style.borderColor="rgba(212,175,92,0.4)",te.currentTarget.style.color="#D4AF5C"},onMouseLeave:function(te){te.currentTarget.style.borderColor="#0D1520",te.currentTarget.style.color="#3A4A5E"},children:[(0,e.jsx)("span",{style:{fontSize:8},children:"◼"}),(0,e.jsx)("span",{children:"PDF"})]}),(0,e.jsxs)("button",{onClick:function(){uu.generateDOCX(O(),U())},style:Object.assign({},We,{color:"#3A4A5E"}),onMouseEnter:function(te){te.currentTarget.style.borderColor="rgba(212,175,92,0.4)",te.currentTarget.style.color="#D4AF5C"},onMouseLeave:function(te){te.currentTarget.style.borderColor="#0D1520",te.currentTarget.style.color="#3A4A5E"},children:[(0,e.jsx)("span",{style:{fontSize:8},children:"◼"}),(0,e.jsx)("span",{children:"DOCX"})]})]}),A&&(0,e.jsxs)("div",{style:{position:"absolute",top:32,left:0,zIndex:200,background:"#07090E",border:"1px solid #1C2740",borderRadius:8,padding:"14px 16px",width:320,boxShadow:"0 16px 40px rgba(0,0,0,.8)"},children:[(0,e.jsxs)("div",{style:{fontFamily:w,fontSize:8,color:"#D4AF5C",letterSpacing:".12em",marginBottom:10,fontWeight:700},children:["⊗ SAVE TO VAULT ",o?"(CHART + TEXT)":""]}),o&&(0,e.jsx)("div",{style:{fontFamily:w,fontSize:8,color:"#5A7090",marginBottom:8,padding:"5px 8px",background:"rgba(212,175,92,0.06)",border:"1px solid rgba(212,175,92,0.15)",borderRadius:4},children:"📊 Chart PNG will be saved alongside the analysis text"}),(0,e.jsx)("div",{style:{fontFamily:w,fontSize:8,color:"#7A90A8",letterSpacing:".1em",marginBottom:6},children:"FILE NAME"}),(0,e.jsx)("input",{value:C,onChange:function(te){_(te.target.value)},onKeyDown:function(te){te.key==="Enter"&&de(C)},style:{width:"100%",background:"#0D1020",border:"1px solid #1C2740",borderRadius:5,padding:"7px 10px",color:"#C9D1D9",fontSize:11,outline:"none",marginBottom:10,boxSizing:"border-box"},onFocus:function(te){te.target.style.borderColor="rgba(212,175,92,0.5)"},onBlur:function(te){te.target.style.borderColor="#1C2740"}}),(0,e.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,e.jsx)("button",{onClick:function(){de(C)},style:{flex:1,padding:"7px 0",background:"rgba(212,175,92,0.15)",border:"1px solid rgba(212,175,92,0.3)",borderRadius:5,cursor:"pointer",fontFamily:w,fontSize:8,color:"#D4AF5C",fontWeight:700},onMouseEnter:function(te){te.currentTarget.style.background="rgba(212,175,92,0.25)"},onMouseLeave:function(te){te.currentTarget.style.background="rgba(212,175,92,0.15)"},children:"SAVE"}),(0,e.jsx)("button",{onClick:function(){j(!1)},style:{padding:"7px 12px",background:"transparent",border:"1px solid #1C2740",borderRadius:5,cursor:"pointer",fontFamily:w,fontSize:8,color:"#5A7090"},children:"CANCEL"})]})]})]})}var c8=/(— News|— Council Signal|US Indices)(Tape|Verdict|US cash|No Tier-1|#)/g,d8=/^\s*\|[|\s]*\|\s*$/,$m="US Indices — ETF Proxies (not index levels)",u8=/(?:As[- ]of|Pulled at)[:\s]+([^\n·•|]+)/i,f8=/^[^\n]*\b(?:As[- ]of|Pulled at|Quote timestamp)\b[^\n]*$/gim;function p8(t){if(String(t).indexOf($m)===-1)return t;var n="unavailable",r=String(t).match(u8);r&&r[1].trim()&&(n=r[1].trim());var o=String(t).replace(f8,"").replace(/\n{3,}/g,`
228
229`);return o=o.replace($m,$m+`
230
231Pulled at: `+n+`
232Quote timestamp: unavailable`),o.replace(/\n{3,}/g,`
233
234`).replace(/\(not index levels\)\n\n\n/,`(not index levels)
235
236`)}function g8(t){for(var n=String(t||"").split(`
237`),r={},o=0;o<n.length;o++)if(d8.test(n[o])){for(var a=o-1;a>=0&&!n[a].trim();)r[a]=!0,a--;var l=a>=0?n[a].split("|").length-2:0;if(l>=1){for(var s="|",c=0;c<l;c++)s+="---|";n[o]=s;for(var d=o+1;d<n.length&&!n[d].trim();)r[d]=!0,d++}else for(var p in r)delete r[p]}for(var g=[],f=0;f<n.length;f++)r[f]||g.push(n[f]);return g.join(`
238`)}function Jm(t){var n=String(t||"").replace(c8,`$1
239
240$2`);return n=p8(n),g8(n)}function C2(t){var n=t.trim();return n.charAt(0)==="|"&&(n=n.slice(1)),n.charAt(n.length-1)==="|"&&(n=n.slice(0,-1)),n.split("|").map(function(r){return r.trim()})}function Qm(t){var n=(t||"").trim();return n.charAt(0)==="|"&&n.indexOf("|",1)>0}function Gv(t){return C2(t).every(function(n){return n===""||/^:?-+:?$/.test(n)})}function m8(t){var n=String(t||"").split(`
241`),r=[],o=[];function a(){o.length&&(r.push({type:"text",text:o.join(`
242`)}),o=[])}for(var l=0;l<n.length;){var s=n[l].match(/^\s*(#{1,6})\s+(.+?)\s*$/);if(s){a(),r.push({type:"heading",depth:s[1].length,text:s[2]}),l++;continue}if(Qm(n[l])){for(var c=[],d=l;d<n.length;){if(Qm(n[d])){c.push(n[d]),d++;continue}if(!n[d].trim()&&d+1<n.length&&Qm(n[d+1])){d++;continue}break}var p=c.filter(function(g){return!Gv(g)}).map(C2);if(c.length>=2&&p.length>=1){a(),r.push({type:"table",header:p[0],rows:p.slice(1)}),l=d;continue}c.forEach(function(g){Gv(g)||o.push(g)}),l=d;continue}o.push(n[l]),l++}return a(),r}var xa="monospace",If="'SF Pro Text',-apple-system,sans-serif",Jl="#D4AF5C",cu="#1E2838",wg="#0A0E16",A2="#0D1520";function rm(t){return(0,e.jsx)("div",{style:{fontFamily:xa,fontSize:7,fontWeight:700,color:t.color||"#5A7090",letterSpacing:".12em",marginBottom:8},children:t.children})}function Vv(t,n,r){return String(t).split(/(\[\d{1,2}\])/g).map(function(o,a){var l=o.match(/^\[(\d{1,2})\]$/);if(!l)return o;var s=(n||[]).find(function(c){return String(c.index)===l[1]});return s?(0,e.jsx)("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",title:s.title+(s.domain?" — "+s.domain:""),style:{display:"inline-block",minWidth:14,padding:"0 4px",margin:"0 2px",borderRadius:3,background:"rgba(212,175,92,0.12)",border:"1px solid rgba(212,175,92,0.3)",color:Jl,fontFamily:xa,fontSize:9,lineHeight:"14px",textAlign:"center",textDecoration:"none",verticalAlign:"1px"},children:l[1]},r+"-c"+a):o})}var h8=/([a-z\]%"'”)])\.(?=[A-Z0-9])/g;function y8(t){return String(t).replace(h8,`$1.
243`)}function x8(t,n){var r=String(t||"").replace(/<<<FOLLOW_UPS>>>[\s\S]*/g,"").replace(/^```\w*$/gm,"").trim();return r?(r=y8(r),r.split(/\n{2,}/).map(function(o,a){var l=o.split(`
244`).filter(function(c){return c.trim()});if(l.every(function(c){return/^\s*(?:[-*•]|\d+\.)\s+/.test(c)})&&l.length)return(0,e.jsx)("ul",{style:{margin:"0 0 12px",paddingLeft:18,listStyle:"none"},children:l.map(function(c,d){var p=c.replace(/^\s*(?:[-*•]|\d+\.)\s+/,"");return(0,e.jsxs)("li",{style:{position:"relative",fontSize:13,color:"#C9D1D9",lineHeight:1.75,fontFamily:If,marginBottom:4},children:[(0,e.jsx)("span",{style:{position:"absolute",left:-14,color:Jl,fontSize:11},children:"·"}),Vv(Yv(p),n,"b"+a+"i"+d)]},"b"+a+"i"+d)})},"b"+a);var s=o.match(/^#{1,6}\s+(.*)$/);return s?(0,e.jsx)("div",{style:{fontFamily:xa,fontSize:9,fontWeight:700,color:Jl,letterSpacing:".14em",textTransform:"uppercase",margin:a>0?"16px 0 6px":"0 0 6px"},children:s[1]},"b"+a):(0,e.jsx)("div",{style:{margin:"0 0 12px"},children:l.map(function(c,d){var p=c.trim(),g=p.match(/^([A-Z][A-Za-z ]{1,26}):\s*(.*)$/);return p.length<46&&p===p.toUpperCase()&&/[A-Z]{3}/.test(p)?(0,e.jsx)("div",{style:{fontFamily:xa,fontSize:9,fontWeight:700,color:Jl,letterSpacing:".14em",margin:d>0?"14px 0 6px":"0 0 6px"},children:p},"b"+a+"l"+d):(0,e.jsxs)("div",{style:{fontSize:13,color:"#C9D1D9",lineHeight:1.75,fontFamily:If,marginBottom:3},children:[g?(0,e.jsx)("span",{style:{fontFamily:xa,fontSize:9,fontWeight:700,color:Jl,letterSpacing:".1em",marginRight:7},children:g[1].toUpperCase()}):null,Vv(Yv(g?g[2]:p),n,"b"+a+"l"+d)]},"b"+a+"l"+d)})},"b"+a)})):null}function Yv(t){return String(t).replace(/\*\*(.+?)\*\*/g,"$1").replace(/`([^`]+)`/g,"$1")}function v8(t){var n=t.sources||[];return n.length?(0,e.jsxs)("div",{style:{marginBottom:20},children:[(0,e.jsxs)(rm,{children:["SOURCES · ",n.length]}),(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:n.map(function(r){return(0,e.jsxs)("a",{href:r.url,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",gap:10,padding:"10px 12px",background:wg,border:"1px solid "+cu,borderRadius:6,textDecoration:"none"},children:[(0,e.jsx)("span",{style:{fontFamily:xa,fontSize:9,fontWeight:700,color:Jl,flexShrink:0,width:18},children:r.index}),(0,e.jsx)("img",{src:"https://www.google.com/s2/favicons?domain="+encodeURIComponent(r.domain||"")+"&sz=32",alt:"",style:{width:16,height:16,borderRadius:3,flexShrink:0},onError:function(o){o.currentTarget.style.visibility="hidden"}}),(0,e.jsxs)("span",{style:{minWidth:0,flex:1},children:[(0,e.jsx)("span",{style:{display:"block",fontSize:12,fontWeight:600,color:"#E6EDF3",fontFamily:If,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.title}),r.snippet?(0,e.jsx)("span",{style:{display:"-webkit-box",fontSize:11,color:"#8B949E",fontFamily:If,lineHeight:1.5,marginTop:2,WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:r.snippet}):null,(0,e.jsxs)("span",{style:{display:"block",fontFamily:xa,fontSize:8,color:"#5A7090",marginTop:3},children:[r.domain,r.date?" · "+r.date:""]})]})]},r.index)})})]}):null}function b8(t){var n=t.videos||[];if(!n.length)return null;function r(o,a){var l=o.url||(a?"https://www.youtube.com/watch?v="+a:"");l&&(t.onOpenVideo?t.onOpenVideo(l,o.title||""):window.open(l,"_blank","noopener,noreferrer"))}return(0,e.jsxs)("div",{style:{marginBottom:20},children:[(0,e.jsxs)(rm,{color:Jl,children:["▶ RELATED VIDEOS · ",n.length]}),(0,e.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:10},children:n.map(function(o,a){var l=o.videoId||o.video_id||"";if(!l){var s=String(o.url||"").match(/[?&]v=([a-zA-Z0-9_-]{11})/);s&&(l=s[1])}var c=o.thumbnail||(l?"https://i.ytimg.com/vi/"+l+"/hqdefault.jpg":""),d=!!(o.url||l);return(0,e.jsxs)("div",{onClick:function(){r(o,l)},role:"button",tabIndex:0,onKeyDown:function(p){(p.key==="Enter"||p.key===" ")&&r(o,l)},style:{borderRadius:8,overflow:"hidden",border:"1px solid "+cu,background:wg,cursor:d?"pointer":"default"},children:[(0,e.jsxs)("div",{style:{position:"relative",width:"100%",paddingTop:"56.25%",background:A2},children:[c?(0,e.jsx)("img",{src:c,alt:"",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"},onError:function(p){p.currentTarget.style.display="none"}}):null,(0,e.jsx)("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%,-50%)",width:34,he
244ight:34,borderRadius:"50%",background:"rgba(0,0,0,0.7)",display:"flex",alignItems:"center",justifyContent:"center",color:Jl,fontSize:15},children:"▶"}),o.duration?(0,e.jsx)("div",{style:{position:"absolute",bottom:4,right:4,padding:"2px 6px",background:"rgba(0,0,0,0.8)",borderRadius:3,fontFamily:xa,fontSize:8,color:"#C9D1D9"},children:o.duration}):null]}),(0,e.jsxs)("div",{style:{padding:"8px 10px"},children:[(0,e.jsx)("div",{style:{fontSize:11,fontWeight:600,color:"#E6EDF3",fontFamily:If,lineHeight:1.4,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:o.title||"Video"}),o.author||o.channel?(0,e.jsx)("div",{style:{fontFamily:xa,fontSize:8,color:"#5A7090",marginTop:4},children:o.author||o.channel}):null]})]},l||a)})})]})}function S8(t){var n=(t.images||[]).filter(Boolean),r=(0,i.useState)(null),o=r[0],a=r[1];return n.length?(0,e.jsxs)("div",{style:{marginBottom:20},children:[(0,e.jsxs)(rm,{children:["IMAGES · ",n.length]}),(0,e.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:8},children:n.map(function(l,s){var c=typeof l=="string"?l:l.url||l.image_url||"";return c?(0,e.jsx)("div",{onClick:function(){a(c)},style:{borderRadius:6,overflow:"hidden",border:"1px solid "+cu,background:A2,cursor:"zoom-in"},children:(0,e.jsx)("img",{src:c,alt:"",style:{width:"100%",height:104,objectFit:"cover",display:"block"},onError:function(d){d.currentTarget.parentElement.style.display="none"}})},s):null})}),o?(0,e.jsx)("div",{onClick:function(){a(null)},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.88)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",cursor:"zoom-out"},children:(0,e.jsx)("img",{src:o,alt:"",style:{maxWidth:"90vw",maxHeight:"90vh",borderRadius:8}})}):null]}):null}function E8(t){var n=t.tabs;return(0,e.jsx)("div",{style:{display:"flex",gap:2,borderBottom:"1px solid "+cu,marginBottom:16},children:n.map(function(r){var o=t.active===r.key;return(0,e.jsxs)("button",{onClick:function(){t.onChange(r.key)},style:{background:"transparent",border:"none",borderBottom:"2px solid "+(o?Jl:"transparent"),padding:"8px 14px",cursor:"pointer",fontFamily:xa,fontSize:9,fontWeight:700,letterSpacing:".14em",color:o?Jl:"#5A7090"},children:[r.label,r.count?" · "+r.count:""]},r.key)})})}function Kv(t){var n=t.text||"",r=t.sources||[],o=t.videos||[],a=t.images||[],l=t.followUps||[],s=(0,i.useState)("all"),c=s[0],d=s[1],p=(0,i.useState)(!1),g=p[0],f=p[1],h=[{key:"all",label:"ANSWER"}];r.length&&h.push({key:"sources",label:"SOURCES",count:r.length}),a.length&&h.push({key:"images",label:"IMAGES",count:a.length}),o.length&&h.push({key:"videos",label:"VIDEOS",count:o.length});var x=c==="all";return(0,e.jsxs)("div",{style:{animation:"xfadein 0.3s ease"},children:[!t.streaming&&h.length>1?(0,e.jsx)(E8,{tabs:h,active:c,onChange:d}):null,(x||t.streaming)&&(0,e.jsxs)("div",{style:{marginBottom:16},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10},children:[(0,e.jsx)("div",{style:{fontFamily:xa,fontSize:7,fontWeight:700,color:"#B0BCC8",letterSpacing:".12em"},children:"INTELLIGENCE BRIEF"}),r.length?(0,e.jsxs)("div",{style:{fontFamily:xa,fontSize:7,color:"#4DA882",letterSpacing:".06em"},children:[r.length," SOURCES"]}):null,!t.streaming&&n?(0,e.jsx)("button",{onClick:function(){try{navigator.clipboard.writeText(n),f(!0),setTimeout(function(){f(!1)},1400)}catch{}},style:{marginLeft:"auto",background:"transparent",border:"1px solid "+cu,borderRadius:3,padding:"3px 9px",cursor:"pointer",fontFamily:xa,fontSize:8,color:g?"#4DA882":"#5A7090",letterSpacing:".1em"},children:g?"COPIED":"COPY"}):null]}),(0,e.jsxs)("div",{style:{background:wg,border:"1px solid "+cu,borderRadius:8,padding:"16px 18px"},children:[x8(n,r),t.streaming?(0,e.jsx)("span",{style:{display:"inline-block",width:6,height:14,background:"#B0BCC8",marginLeft:2,verticalAlign:"middle",animation:"xblink .7s infinite",borderRadius:1}}):null]})]}),!t.streaming&&(x||c==="images")?(0,e.jsx)(S8,{images:a}):null,!t.streaming&&(x||c==="videos")?(0,e.jsx)(b8,{videos:o,onOpenVideo:t.onOpenVideo}):null,!t.streaming&&(x||c==="sources")?(0,e.jsx)(v8,{sources:r}):null,!t.streaming&&x&&l.length?(0,e.jsxs)("div",{style:{marginBottom:20},children:[(0,e.jsx)(rm,{children:"RELATED"}),(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:l.map(function(v,y){return(0,e.jsxs)("button",{onClick:function(){t.onFollowUp(v)},style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px",background:wg,border:"1px solid "+cu,borderRadius:6,cursor:"pointer",textAlign:"left",width:"100%"}
244,children:[(0,e.jsx)("span",{style:{fontFamily:xa,fontSize:10,color:Jl},children:"⌕"}),(0,e.jsx)("span",{style:{fontSize:12,color:"#8B949E",fontFamily:If},children:v}),(0,e.jsx)("span",{style:{fontFamily:xa,fontSize:10,color:"#2A3548",marginLeft:"auto"},children:"→"})]},y)})})]}):null]})}var k8=/^\(?[-+]?(?:[$£€]\s?|[A-Z]{3}\s)?\d[\d,.\s']*(?:%|\s?[A-Z]{3})?\)?$/;function C8(t){var n=String(t??"").trim();return n?k8.test(n):!1}function Zm(t){for(var n=String(t??""),r=[],o=0;o<n.length;){if(n[o]==="`"){var a=n.indexOf("`",o+1);if(a!==-1){r.push({t:"code",v:n.slice(o+1,a)}),o=a+1;continue}}if(n[o]==="*"&&n[o+1]==="*"){var l=n.indexOf("**",o+2);if(l!==-1){r.push({t:"bold",v:n.slice(o+2,l)}),o=l+2;continue}}for(var s=o;s<n.length&&n[s]!=="`"&&!(n[s]==="*"&&n[s+1]==="*");)s++;s===o&&(s=o+1),r.push({t:"text",v:n.slice(o,s)}),o=s}return r}function Xv(t){var n=t.trim();return n.charAt(0)==="|"&&(n=n.slice(1)),n.charAt(n.length-1)==="|"&&(n=n.slice(0,-1)),n.split("|").map(function(r){return r.trim()})}function A8(t){var n=t.trim();return n?/^[|\s:-]+$/.test(n)&&n.indexOf("-")!==-1&&n.indexOf("|")!==-1:!1}function j8(t){var n=String(t??"");if(!n.trim())return[];for(var r=n.split(`
245`),o=[],a=0;a<r.length;){var l=r[a].trim();if(!l){a++;continue}if(l.indexOf("```")===0){var s=l.slice(3).trim(),c=[];for(a++;a<r.length&&r[a].trim().indexOf("```")!==0;)c.push(r[a]),a++;a++,o.push({type:"code",lang:s||"text",code:c.join(`
246`)});continue}var d=l.match(/^(#{1,6})\s+(.*)$/);if(d){o.push({type:"heading",depth:d[1].length,text:d[2]}),a++;continue}if(l.charAt(0)==="|"&&a+1<r.length&&A8(r[a+1])){var p=Xv(l),g=[];for(a+=2;a<r.length&&r[a].trim().charAt(0)==="|";){for(var f=Xv(r[a]);f.length<p.length;)f.push("");g.push(f.slice(0,p.length)),a++}var h=p.map(function(k,A){for(var j=!1,E=0;E<g.length;E++){var C=g[E][A];if(C){if(!C8(C))return"left";j=!0}}return j?"right":"left"});o.push({type:"table",header:p,rows:g,align:h});continue}if(/^[-*•]\s+/.test(l)||/^\d+[.)]\s+/.test(l)){for(var x=/^\d+[.)]\s+/.test(l),v=x?/^\d+[.)]\s+/:/^[-*•]\s+/,y=[];a<r.length&&v.test(r[a].trim());)y.push(r[a].trim().replace(v,"")),a++;o.push({type:"list",ordered:x,items:y});continue}o.push({type:"p",text:l}),a++}return o}var w8={wrap:{color:"#C5CAD2",fontSize:14,lineHeight:1.6,padding:"8px 4px"}};function Wp(t){var n=t&&t.content||"";return(0,e.jsx)("div",{style:w8.wrap,children:(0,e.jsx)(HC,{children:n})})}var qv={wrap:{fontSize:13,background:"transparent"},pre:{margin:0,padding:12,borderRadius:4,fontSize:13,lineHeight:1.5,background:"#1E1E1E",overflow:"auto",maxHeight:"100%"}};function qp(t){var n=t&&t.content||"",r=t&&t.language||"text";return(0,e.jsx)("div",{style:qv.wrap,children:(0,e.jsx)(IA,{language:r,style:DA,customStyle:qv.pre,wrapLongLines:!0,children:n})})}var T8={iframe:{width:"100%",height:"100%",minHeight:400,border:"1px solid rgba(212,175,92,0.2)",borderRadius:4,background:"#fff"}};function j2(t){var n=t&&t.content||"";return(0,e.jsx)("iframe",{title:"Artifact HTML",sandbox:"allow-scripts",srcDoc:wS.sanitize(n,{WHOLE_DOCUMENT:!0,ALLOW_UNKNOWN_PROTOCOLS:!0}),style:T8.iframe})}var _8={wrap:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",padding:16,background:"rgba(2,4,10,0.8)",borderRadius:4,border:"1px solid rgba(212,175,92,0.2)",overflow:"auto"}};function w2(t){var n=t&&t.content||"",r=wS.sanitize(n,{USE_PROFILES:{svg:!0,svgFilters:!0}});return(0,e.jsx)("div",{style:_8.wrap,dangerouslySetInnerHTML:{__html:r}})}var Zf={wrap:{width:"100%",overflow:"auto",padding:8},table:{width:"100%",borderCollapse:"collapse",fontSize:13,color:"#C5CAD2",fontFamily:"-apple-system, BlinkMacSystemFont, sans-serif"},th:{textAlign:"left",padding:"8px 10px",background:"rgba(212,175,92,0.08)",color:"#D4AF5C",borderBottom:"1px solid rgba(212,175,92,0.3)",cursor:"pointer",userSelect:"none",fontSize:11,letterSpacing:"0.05em",textTransform:"uppercase",position:"sticky",top:0},td:{padding:"6px 10px",borderBottom:"1px solid rgba(28,39,64,0.4)",verticalAlign:"top"},err:{color:"#5A6878",padding:12,fontStyle:"italic"}};function R8(t){if(!t)return null;try{var n=typeof t=="string"?JSON.parse(t):t;if(Array.isArray(n)){if(n.length===0)return{columns:[],rows:[]};var r=Array.from(n.reduce(function(o,a){return a&&typeof a=="object"&&Object.keys(a).forEac
246h(function(l){o.add(l)}),o},new Set));return{columns:r,rows:n.map(function(o){return r.map(function(a){return o?o[a]:""})})}}if(n&&typeof n=="object"&&Array.isArray(n.columns)&&Array.isArray(n.rows))return{columns:n.columns,rows:n.rows}}catch{return null}return null}function T2(t){var n=t&&t.content||"",r=(0,i.useMemo)(function(){return R8(n)},[n]),o=(0,i.useState)({idx:-1,dir:1}),a=o[0],l=o[1];if(!r)return(0,e.jsx)("div",{style:Zf.err,children:"Could not render table — content is not valid JSON."});function s(d){l(function(p){return p.idx===d?{idx:d,dir:-p.dir}:{idx:d,dir:1}})}var c=r.rows.slice();return a.idx>=0&&a.idx<r.columns.length&&c.sort(function(d,p){var g=d[a.idx],f=p[a.idx],h=Number(g),x=Number(f);if(!isNaN(h)&&!isNaN(x))return(h-x)*a.dir;var v=String(g??""),y=String(f??"");return v.localeCompare(y)*a.dir}),(0,e.jsx)("div",{style:Zf.wrap,children:(0,e.jsxs)("table",{style:Zf.table,children:[(0,e.jsx)("thead",{children:(0,e.jsx)("tr",{children:r.columns.map(function(d,p){var g=a.idx===p?a.dir>0?" ▲":" ▼":"";return(0,e.jsxs)("th",{style:Zf.th,onClick:function(){s(p)},children:[String(d),g]},p)})})}),(0,e.jsx)("tbody",{children:c.map(function(d,p){return(0,e.jsx)("tr",{children:r.columns.map(function(g,f){var h=d[f],x=h==null?"":typeof h=="object"?JSON.stringify(h):String(h);return(0,e.jsx)("td",{style:Zf.td,children:x},f)})},p)})})]})})}var $v=!1;function F8(){if(!$v){$v=!0;try{_S.initialize({startOnLoad:!1,theme:"dark",themeVariables:{primaryColor:"#1A2030",primaryTextColor:"#C5CAD2",primaryBorderColor:"#D4AF5C",lineColor:"#D4AF5C",textColor:"#C5CAD2",background:"#02040A"},securityLevel:"strict"})}catch{}}}var Jv={wrap:{width:"100%",height:"100%",overflow:"auto",padding:16,background:"rgba(2,4,10,0.8)",borderRadius:4,border:"1px solid rgba(212,175,92,0.2)"},err:{color:"#E07B7B",fontFamily:"monospace",fontSize:12}};function _2(t){var n=t&&t.content||"",r=(0,i.useRef)(null),o=(0,i.useState)(null),a=o[0],l=o[1];return(0,i.useEffect)(function(){if(F8(),!!r.current){var s="xyron-mermaid-"+Math.random().toString(36).slice(2,10);try{_S.render(s,n).then(function(c){r.current&&(r.current.innerHTML=c&&c.svg?c.svg:"",l(null))}).catch(function(c){l("Mermaid render error: "+(c&&c.message?c.message:String(c)))})}catch(c){l("Mermaid render error: "+(c&&c.message?c.message:String(c)))}}},[n]),(0,e.jsxs)("div",{style:Jv.wrap,children:[a&&(0,e.jsx)("div",{style:Jv.err,children:a}),(0,e.jsx)("div",{ref:r})]})}var I8=9e4;function R0(t){return typeof t=="string"&&t.indexOf("/api/")===0}var Wi={wrap:{width:"100%",height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-start",padding:16,background:"rgba(2,4,10,0.8)",borderRadius:4,border:"1px solid rgba(212,175,92,0.2)",overflow:"auto",gap:12},imgWrap:{position:"relative",width:"100%",display:"flex",alignItems:"center",justifyContent:"center"},img:{maxWidth:"100%",maxHeight:"80vh",objectFit:"contain",borderRadius:4,border:"0.5px solid rgba(255,255,255,0.08)"},spinner:{color:"#D4AF5C",fontFamily:"JetBrains Mono, ui-monospace, monospace",fontSize:11,letterSpacing:"0.08em",padding:"24px 16px",textAlign:"center"},errorBlock:{background:"rgba(220,53,69,0.08)",border:"1px solid rgba(220,53,69,0.4)",borderRadius:4,padding:12,color:"#E07585",fontFamily:"JetBrains Mono, ui-monospace, monospace",fontSize:12,lineHeight:1.5,width:"100%",boxSizing:"border-box"},badgeRow:{display:"flex",alignItems:"center",gap:8,width:"100%"},badge:{padding:"2px 8px",borderRadius:3,background:"rgba(212,175,92,0.12)",color:"#D4AF5C",fontFamily:"JetBrains Mono, ui-monospace, monospace",fontSize:9,letterSpacing:"0.08em",fontWeight:700},revisedDetails:{width:"100%",fontFamily:"JetBrains Mono, ui-monospace, monospace",fontSize:11,color:"#8A92A0"},revisedSummary:{cursor:"pointer",color:"#A0A8B5",padding:"4px 0"},revisedBody:{background:"rgba(2,4,10,0.6)",border:"1px solid rgba(255,255,255,0.06)",borderRadius:3,padding:8,marginTop:6,color:"#C5CAD2",lineHeight:1.5,whiteSpace:"pre-wrap"}};function Xy(t){var n=t&&t.artifact||(t&&t.content?{content:t.content}:{}),r=n.content||"",o=n.prompt_revised||"",a=n.source||"",l=n.error||"",s=(0,i.useState)(!1),c=s[0],d=s[1],p=(0,i.useState)(!1),g=p[0],f=p[1],h=(0,i.useState)(!1),x=h[0],v=h[1],y=(0,i.useState)(""),k=y[0],A=y[1],j=(0,i.useState)(!1),E=j[0],C=j[1];return(0,i.useEffect)(function(){if(!(r||l)){var _=setTimeout(function(){v(!0)},I8);return function(){clearTimeout(_)}}},[r,l]),(0,i.useEffect)(function(){if(R0(r)){var _=!1,w=null,O=r;return r.indexOf("/api/chat/generated/")===0&&(O=r+(r.indexOf("?")===-1?"?stream=1":"&stream=1")),fetch(qr(O),{headers:fo()}).then(function(M){if(!M.ok)throw new Error("HTTP "+M.status);return M.blob()}).then(function(M){_||(w=URL.createObjectURL(M),A(w))}).catch(function(){_||(n.signed_url?A(n.signed_url):C(!0))}),function(){if(_=!0,w)try{URL.revokeObjectURL(w)}catch{}}}},[r]),l?(0,e.jsx)("div",{style:Wi.wrap,children:(0,e.jsxs)("div",{style:Wi.errorBlock,children:[(0,e.jsx)("div",{style:{fontWeight:700,marginBottom:4},children:"IMAGE GENERATION FAILED"}),(0,e.jsx)("div",{children:String(l)}
246)]})}):r?R0(r)&&E?(0,e.jsx)("div",{style:Wi.wrap,children:(0,e.jsxs)("div",{style:Wi.errorBlock,children:[(0,e.jsx)("div",{style:{fontWeight:700,marginBottom:4},children:"IMAGE LOAD FAILED"}),(0,e.jsx)("div",{children:"The stored image could not be fetched from the server."})]})}):R0(r)&&!k?(0,e.jsx)("div",{style:Wi.wrap,children:(0,e.jsx)("div",{style:Wi.spinner,children:"LOADING IMAGE..."})}):(0,e.jsxs)("div",{style:Wi.wrap,children:[(0,e.jsxs)("div",{style:Wi.imgWrap,children:[(0,e.jsx)("img",{src:R0(r)?k:r,alt:n.title||"generated image",style:Wi.img,onLoad:function(){d(!0)},onError:function(){f(!0)}}),!c&&!g&&(0,e.jsx)("div",{style:{position:"absolute",...Wi.spinner},children:"LOADING..."})]}),g&&(0,e.jsxs)("div",{style:Wi.errorBlock,children:[(0,e.jsx)("div",{style:{fontWeight:700,marginBottom:4},children:"IMAGE LOAD FAILED"}),(0,e.jsx)("div",{children:"The browser could not load the image at this URL."})]}),(0,e.jsxs)("div",{style:Wi.badgeRow,children:[a==="code_execution"&&(0,e.jsx)("span",{style:Wi.badge,children:"FROM CODE"}),a==="generation"&&(0,e.jsx)("span",{style:Wi.badge,children:"GENERATED"})]}),o&&(0,e.jsxs)("details",{style:Wi.revisedDetails,children:[(0,e.jsx)("summary",{style:Wi.revisedSummary,children:"Revised prompt"}),(0,e.jsx)("div",{style:Wi.revisedBody,children:o})]})]}):x?(0,e.jsx)("div",{style:Wi.wrap,children:(0,e.jsxs)("div",{style:Wi.errorBlock,children:[(0,e.jsx)("div",{style:{fontWeight:700,marginBottom:4},children:"IMAGE GENERATION TIMED OUT"}),(0,e.jsx)("div",{children:l?String(l):"No image was produced within 90 seconds. Re-run the request to try again."})]})}):(0,e.jsx)("div",{style:Wi.wrap,children:(0,e.jsx)("div",{style:Wi.spinner,children:"GENERATING IMAGE..."})})}var Qv=["#D4AF5C","#22D3EE","#A78BFA","#34D399","#FB7185","#F59E0B","#60A5FA","#F472B6"],D8=["bar","line","area","pie","scatter"];function Hp(t){var n=Qv.length;return Qv[(t%n+n)%n]}function Zv(t){if(typeof t=="number"&&isFinite(t))return t;if(typeof t=="string"&&t.trim()!==""){var n=Number(t);if(isFinite(n))return n}return null}function O8(t){if(!t||typeof t!="object")return[];var n=[],r=t.points;if(Array.isArray(r)){for(var o=0;o<r.length;o++){var a=r[o];if(!(!Array.isArray(a)||a.length<2)){var l=Zv(a[1]);l!==null&&n.push([a[0],l])}}return n}var s=t.labels,c=t.values;if(Array.isArray(s)&&Array.isArray(c))for(var d=Math.min(s.length,c.length),p=0;p<d;p++){var g=Zv(c[p]);g!==null&&n.push([s[p],g])}return n}function L8(t){if(!t||typeof t!="object")return null;var n=String(t.kind||"").trim().toLowerCase();if(D8.indexOf(n)===-1)return null;for(var r=Array.isArray(t.series)?t.series:[],o=[],a=0;a<r.length;a++){var l=O8(r[a]);if(l.length){var s=(r[a]&&typeof r[a].name=="string"?r[a].name.trim():"")||"Series "+(a+1);o.push({name:s,points:l})}}return o.length?(n==="pie"&&(o=o.slice(0,1)),{kind:n,title:F0(t.title)||"Chart",x_label:F0(t.x_label),y_label:F0(t.y_label),currency:F0(t.currency),series:o}):null}function F0(t){return t==null?"":String(t).trim()}var z8={USD:"$",usd:"$",EUR:"€",eur:"€",GBP:"£",gbp:"£",JPY:"¥",jpy:"¥",CNY:"¥",AED:"AED "};function eh(t){return t.indexOf(".")===-1?t:t.replace(/\.?0+$/,"")}function ep(t,n){if(typeof t!="number"||!isFinite(t))return String(t);var r=Math.abs(t),o;if(r>=1e9?o=eh((t/1e9).toFixed(2))+"B":r>=1e6?o=eh((t/1e6).toFixed(2))+"M":r>=1e3?o=eh((t/1e3).toFixed(2))+"K":Number.isInteger(t)?o=String(t):o=t.toFixed(2),n){var a=z8[n];return a?t<0?"-"+a+o.replace(/^-/,""):a+o:o+" "+n}return o}function M8(t){return typeof t=="number"?Number.isInteger(t)?String(t):t.toFixed(2):String(t)}function qy(t,n,r){if(r=r||5,!isFinite(t)||!isFinite(n))return[];if(t===n){var o=Math.abs(t)>0?Math.abs(t)*.1:1;t-=o,n+=o}var a=(n-t)/r,l=Math.pow(10,Math.floor(Math.log10(a))),s=a/l,c;s<1.5?c=1:s<3?c=2:s<7?c=5:c=10,c*=l;for(var d=Math.ceil(t/c)*c,p=[],g=d;g<=n+c*1e-9&&p.length<40;g+=c)p.push(Math.round(g/c)*c);return p}function N8(t){for(var n=0;n<t.length;n++)for(var r=0;r<t[n].points.length;r++)if(typeof t[n].points[r][0]!="number")return!0;return!1}function R2(t){for(var n={},r=[],o=0;o<t.length;o++)for(var a=0;a<t[o].points.length;a++){var l=String(t[o].points[a][0]);n[l]||(n[l]=!0,r.push(l))}return r}function F2(t,n){for(var r=1/0,o=-1/0,a=0;a<t.length;a++)for(var l=0;l<t[a].points.length;l++){var s=t[a].points[l][1];s<r&&(r=s),s>o&&(o=s)}return!isFinite(r)||!isFinite(o)?[0,1]:(n&&(r>
2460&&(r=0),o<0&&(o=0)),r===o?r===0?[0,1]:r>0?[0,o]:[r,0]:[r,o])}function im(t,n){return{left:56,right:t-16,top:16,bottom:n-40,width:Math.max(1,t-56-16),height:Math.max(1,n-16-40)}}function B8(t,n,r){var o=im(n,r),a=t.series,l=R2(a);if(!l.length)return V8(o);for(var s=F2(a,!0),c=s[0],d=s[1],p=function(ee){return o.bottom-(ee-c)/(d-c)*o.height},g=p(0),f=o.width/l.length,h=a.length,x=f*.18,v=(f-x*2)/h,y=Math.max(1,v*.82),k=[],A=0;A<h;A++){for(var j={},E=0;E<a[A].points.length;E++)j[String(a[A].points[E][0])]=a[A].points[E][1];for(var C=0;C<l.length;C++)if(Object.prototype.hasOwnProperty.call(j,l[C])){var _=j[l[C]],w=o.left+C*f+x+A*v,O=p(_),M=Math.min(O,g),U=Math.abs(O-g);k.push({seriesIndex:A,seriesName:a[A].name,category:l[C],value:_,x:w+(v-y)/2,y:M,width:y,height:Math.max(.5,U),color:Hp(A)})}}return{box:o,bars:k,categories:l,catCenters:l.map(function(ee,N){return o.left+N*f+f/2}),yTicks:qy(c,d).map(function(ee){return{value:ee,y:p(ee)}})}}function I2(t,n,r){var o=t.series,a=N8(o),l=a?R2(o):null,s=0,c=1;if(a)s=0,c=Math.max(1,l.length-1);else{s=1/0,c=-1/0;for(var d=0;d<o.length;d++)for(var p=0;p<o[d].points.length;p++){var g=o[d].points[p][0];g<s&&(s=g),g>c&&(c=g)}(!isFinite(s)||!isFinite(c))&&(s=0,c=1),s===c&&(s-=1,c+=1)}var f=F2(o,r),h=f[0],x=f[1],v={};if(l)for(var y=0;y<l.length;y++)v[l[y]]=y;return{categorical:a,cats:l,xToPx:function(k){var A=a?v[String(k)]:k;return A===void 0&&(A=0),n.left+(A-s)/(c-s)*n.width},yToPx:function(k){return n.bottom-(k-h)/(x-h)*n.height},y0:h,y1:x}}function D2(t,n){for(var r=[],o=0;o<t.series.length;o++){for(var a=[],l=0;l<t.series[o].points.length;l++){var s=t.series[o].points[l][0],c=t.series[o].points[l][1];a.push({seriesIndex:o,seriesName:t.series[o].name,x:s,y:c,cx:n.xToPx(s),cy:n.yToPx(c),color:Hp(o)})}r.push({name:t.series[o].name,color:Hp(o),points:a})}return r}function P8(t){if(!t.length)return"";for(var n="M "+t[0].cx.toFixed(2)+" "+t[0].cy.toFixed(2),r=1;r<t.length;r++)n+=" L "+t[r].cx.toFixed(2)+" "+t[r].cy.toFixed(2);return n}function eb(t,n,r,o){var a=im(n,r),l=I2(t,a,!!o),s=D2(t,l),c=l.yToPx(Math.max(l.y0,Math.min(l.y1,0)));return{box:a,lines:s.map(function(d){var p=P8(d.points),g="";return o&&d.points.length&&(g=p+" L "+d.points[d.points.length-1].cx.toFixed(2)+" "+c.toFixed(2)+" L "+d.points[0].cx.toFixed(2)+" "+c.toFixed(2)+" Z"),{name:d.name,color:d.color,d:p,areaD:g,points:d.points}}),baseline:c,xTicks:O2(l,a),yTicks:qy(l.y0,l.y1).map(function(d){return{value:d,y:l.yToPx(d)}})}}function U8(t,n,r){for(var o=im(n,r),a=I2(t,o,!1),l=D2(t,a),s=[],c=0;c<l.length;c++)for(var d=0;d<l[c].points.length;d++)s.push(l[c].points[d]);return{box:o,dots:s,series:l,xTicks:O2(a,o),yTicks:qy(a.y0,a.y1).map(function(p){return{value:p,y:a.yToPx(p)}})}}function O2(t,n){if(t.categorical&&t.cats){for(var r=Math.max(1,Math.ceil(t.cats.length/12)),o=[],a=0;a<t.cats.length;a++)a%r||o.push({label:t.cats[a],x:t.xToPx(t.cats[a])});return o}var l=[];n.left,n.right;var s=t.xToPx(0),c=t.xToPx(1)-s;if(!isFinite(c)||c===0)return l;for(var d=function(f){return(f-s)/c},p=0;p<=5;p++){var g=n.left+n.width*p/5;l.push({label:M8(W8(d(g))),x:g})}return l}function W8(t){return Math.round(t*100)/100}function H8(t,n,r,o){for(var a=im(n,r),l=t.series[0],s=(a.left+a.right)/2,c=(a.top+a.bottom)/2,d=Math.max(4,Math.min(a.width,a.height)/2-8),p=o?d*.58:0,g=0,f=0;f<l.points.length;f++)g+=Math.abs(l.points[f][1]);g<=0&&(g=l.points.length||1);for(var h=[],x=-Math.PI/2,v=0;v<l.points.length;v++){var y=Math.abs(l.points[v][1]),k=g>0?y/g:1/l.points.length,A=x+k*Math.PI*2,j=(x+A)/2;h.push({label:String(l.points[v][0]),value:l.points[v][1],fraction:k,percent:k*100,color:Hp(v),d:G8(s,c,d,p,x,A),labelX:s+Math.cos(j)*(d+14),labelY:c+Math.sin(j)*(d+14),midAngle:j}),x=A}return{box:a,cx:s,cy:c,radius:d,inner:p,slices:h,total:g}}function G8(t,n,r,o,a,l){l-a>=Math.PI*2-1e-6&&(l=a+Math.PI*2-1e-4);var s=l-a>Math.PI?1:0,c=t+Math.cos(a)*r,d=n+Math.sin(a)*r,p=t+Math.cos(l)*r,g=n+Math.sin(l)*r;if(o<=0)return"M "+t.toFixed(2)+" "+n.toFixed(2)+" L "+c.toFixed(2)+" "+d.toFixed(2)+" A "+r.toFixed(2)+" "+r.toFixed(2)+" 0 "+s+" 1 "+p.toFixed(2)+" "+g.toFixed(2)+" Z";var f=t+Math.cos(l)*o,h=n+Math.sin(l)*o,x=t+Math.cos(a)*o,v=n+Math.sin(a)*o;return"M "+c.toFixed(2)+" "+d.toFixed(2)+" A "+r.toFixed(2)+" "+r.toFixed(2)+" 0 "+s+" 1 "+p.toFixed(2)+" "+g.toFixed(2)+" L "+f.toFixed(2)+" "+h.toFixed(2)+" A "+o.toFixed(2)+" "+o.toFixed(2)+" 0 "+s+" 0 "+x.toFixed(2)+" "+v.toFixed(2)+" Z"}function V8(t){return{box:t,bars:[],categories:[],catCenters:[],yTicks:[]}}function L2(t,n,r){var o=L8(t);if(!o)return null;var a=n||640,l=r||360,s;switch(o.kind){case"bar":s=B8(o,a,l);break;case"line":s=eb(o,a,l,!1);break;case"area":s=eb(o,a,l,!0);break;case"scatter":s=U8(o,a,l);break;case"pie":s=H8(o,a,l,!0);break;default:return null}return{kind:o.kind,spec:o,geom:s}}var I0="JetBrains Mono, ui-monospace, monospace",th=640,D0=360,cg="#0B0F14",Y8="#0D131B",K8="rgba(30,42,56,0.9)",z2="#C5CAD2",Mp="#76879B",M2="#E9EEF5",tb=!1;function X8(){if(!(tb||typeof document>"u")){tb=!0;var t=document.createElement("style");t.id="xchart-anim-styles",t.textContent="@keyframes xchartBarGrow{from{transform:scaleY(0)}to{transform:scaleY(1)}}@keyframes xchartFade{from{opacity:0}
246to{opacity:1}}@keyframes xchartPop{from{opacity:0;transform:scale(0)}to{opacity:1;transform:scale(1)}}@keyframes xchartDraw{to{stroke-dashoffset:0}}@media (prefers-reduced-motion: reduce){[data-xchart-anim]{animation:none !important;stroke-dashoffset:0 !important;transform:none !important;opacity:1 !important}}",document.head.appendChild(t)}}var yl={wrap:{width:"100%",background:cg,border:"1px solid rgba(212,175,92,0.2)",borderRadius:6,padding:"12px 12px 8px",boxSizing:"border-box"},title:{fontFamily:I0,fontSize:12,fontWeight:700,letterSpacing:"0.04em",color:M2,margin:"0 0 6px 2px"},svgBox:{width:"100%",height:"auto",aspectRatio:"640 / 360",display:"block"},legend:{display:"flex",flexWrap:"wrap",gap:12,marginTop:8,padding:"0 2px"},legendItem:{display:"flex",alignItems:"center",gap:6,fontFamily:I0,fontSize:10,color:Mp,cursor:"default",userSelect:"none"},swatch:{width:10,height:10,borderRadius:2,flex:"0 0 auto"},tooltip:{position:"absolute",pointerEvents:"none",zIndex:5,background:"rgba(6,10,16,0.96)",border:"1px solid rgba(212,175,92,0.4)",borderRadius:4,padding:"6px 8px",fontFamily:I0,fontSize:10,color:z2,whiteSpace:"nowrap",boxShadow:"0 6px 20px rgba(0,0,0,0.5)",transform:"translate(-50%, calc(-100% - 10px))"},axisLabel:{fontFamily:I0,fontSize:9,fill:Mp}};function nb(t){return typeof t=="number"?Number.isInteger(t)?String(t):String(Math.round(t*100)/100):String(t)}function q8(t){var n=t&&t.artifact||{},r=n&&n.metadata&&n.metadata.spec,o=t&&t.drawDelayMs||0;X8();var a=(0,i.useMemo)(function(){try{return L2(r,th,D0)}catch{return null}},[r]),l=(0,i.useState)(null),s=l[0],c=l[1],d=(0,i.useState)(-1),p=d[0],g=d[1];if(!a)return null;var f=a.spec,h=a.kind,x=a.geom,v=f.currency;function y(w,O,M){c({xPct:w/th*100,yPct:O/D0*100,lines:M})}function k(){c(null)}function A(w){return p===-1||p===w?1:.18}function j(w,O,M){return(0,e.jsxs)("g",{children:[(0,e.jsx)("rect",{x:w.left,y:w.top,width:w.width,height:w.height,fill:Y8}),(O||[]).map(function(U,ee){return(0,e.jsxs)("g",{children:[(0,e.jsx)("line",{x1:w.left,x2:w.right,y1:U.y,y2:U.y,stroke:K8,strokeWidth:.75}),(0,e.jsx)("text",{x:w.left-6,y:U.y+3,textAnchor:"end",style:yl.axisLabel,children:ep(U.value,v)})]},"yt"+ee)}),(M||[]).map(function(U,ee){return(0,e.jsx)("text",{x:U.x,y:w.bottom+14,textAnchor:"middle",style:yl.axisLabel,children:U.label},"xt"+ee)})]})}function E(w){return(0,e.jsxs)("g",{children:[f.x_label?(0,e.jsx)("text",{x:(w.left+w.right)/2,y:D0-4,textAnchor:"middle",style:{...yl.axisLabel,fill:Mp},children:f.x_label}):null,f.y_label?(0,e.jsx)("text",{x:12,y:(w.top+w.bottom)/2,textAnchor:"middle",transform:"rotate(-90 12 "+(w.top+w.bottom)/2+")",style:{...yl.axisLabel,fill:Mp},children:f.y_label}):null]})}var C=null;h==="bar"?C=(0,e.jsxs)("g",{children:[j(x.box,x.yTicks,null),x.categories.map(function(w,O){return(0,e.jsx)("text",{x:x.catCenters[O],y:x.box.bottom+14,textAnchor:"middle",style:yl.axisLabel,children:w},"bc"+O)}),x.bars.map(function(w,O){return(0,e.jsx)("rect",{"data-mark":"bar",x:w.x,y:w.y,width:w.width,height:w.height,rx:1.5,fill:w.color,"data-xchart-anim":!0,style:{transformOrigin:w.y+w.height+"px",transformBox:"fill-box",opacity:A(w.seriesIndex),animation:"xchartBarGrow 0.6s cubic-bezier(.2,.7,.2,1) "+(o+O*18)+"ms both"},onMouseMove:function(){y(w.x+w.width/2,w.y,[w.seriesName,String(w.category)+" · "+ep(w.value,v)])},onMouseLeave:k},"bar"+O)}),E(x.box)]}):h==="line"||h==="area"?C=(0,e.jsxs)("g",{children:[j(x.box,x.yTicks,x.xTicks),x.lines.map(function(w,O){return(0,e.jsxs)("g",{style:{opacity:A(O)},children:[h==="area"&&w.areaD?(0,e.jsx)("path",{"data-mark":"area",d:w.areaD,fill:w.color,fillOpacity:.14,"data-xchart-anim":!0,style:{animation:"xchartFade 0.7s ease "+(o+300)+"ms both"}}):null,(0,e.jsx)("path",{"data-mark":"line",d:w.d,fill:"none",stroke:w.color,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round","data-xchart-anim":!0,style:{strokeDasharray:2e3,strokeDashoffset:2e3,animation:"xchartDraw 1s ease "+(o+O*120)+"ms forwards"}}),w.points.map(function(M,U){return(0,e.jsx)("circle",{"data-mark":"point",cx:M.cx,cy:M.cy,r:3,fill:cg,stroke:w.color,strokeWidth:1.5,"data-xchart-anim":!0,style:{opacity:0,animation:"xch
246artFade 0.3s ease "+(o+700+U*12)+"ms forwards"},onMouseMove:function(){y(M.cx,M.cy,[M.seriesName,nb(M.x)+" · "+ep(M.y,v)])},onMouseLeave:k},"lp"+U)})]},"ln"+O)}),E(x.box)]}):h==="scatter"?C=(0,e.jsxs)("g",{children:[j(x.box,x.yTicks,x.xTicks),x.dots.map(function(w,O){return(0,e.jsx)("circle",{"data-mark":"dot",cx:w.cx,cy:w.cy,r:4,fill:w.color,fillOpacity:.85,stroke:cg,strokeWidth:1,"data-xchart-anim":!0,style:{transformOrigin:w.cx+"px "+w.cy+"px",opacity:A(w.seriesIndex),animation:"xchartPop 0.4s cubic-bezier(.2,.7,.2,1) "+(o+O*10)+"ms both"},onMouseMove:function(){y(w.cx,w.cy,[w.seriesName,nb(w.x)+" · "+ep(w.y,v)])},onMouseLeave:k},"sc"+O)}),E(x.box)]}):h==="pie"&&(C=(0,e.jsx)("g",{children:x.slices.map(function(w,O){return(0,e.jsx)("path",{"data-mark":"slice",d:w.d,fill:w.color,stroke:cg,strokeWidth:2,"data-xchart-anim":!0,style:{transformOrigin:x.cx+"px "+x.cy+"px",opacity:A(O),animation:"xchartPop 0.5s cubic-bezier(.2,.7,.2,1) "+(o+O*40)+"ms both"},onMouseMove:function(){y(x.cx,x.cy-x.radius,[w.label,ep(w.value,v)+" · "+w.percent.toFixed(1)+"%"])},onMouseLeave:k},"pie"+O)})}));var _=h==="pie"?x.slices.map(function(w){return{name:w.label,color:w.color}}):f.series.map(function(w,O){return{name:w.name,color:Hp(O)}});return(0,e.jsxs)("div",{style:yl.wrap,children:[f.title?(0,e.jsx)("div",{style:yl.title,children:f.title}):null,(0,e.jsxs)("div",{style:{position:"relative",width:"100%"},children:[(0,e.jsx)("svg",{viewBox:"0 0 "+th+" "+D0,preserveAspectRatio:"xMidYMid meet",style:yl.svgBox,role:"img","aria-label":f.title||"chart",children:C}),s?(0,e.jsx)("div",{style:{...yl.tooltip,left:s.xPct+"%",top:s.yPct+"%"},children:s.lines.map(function(w,O){return(0,e.jsx)("div",{style:O===0?{fontWeight:700,color:M2}:null,children:w},"tl"+O)})}):null]}),_.length>1?(0,e.jsx)("div",{style:yl.legend,children:_.map(function(w,O){return(0,e.jsxs)("div",{style:{...yl.legendItem,color:p===-1||p===O?z2:Mp},onMouseEnter:function(){g(O)},onMouseLeave:function(){g(-1)},children:[(0,e.jsx)("span",{style:{...yl.swatch,background:w.color}}),w.name]},"lg"+O)})}):null]})}function N2(t){var n=t&&t.metadata&&t.metadata.spec;if(n)try{return JSON.stringify(n,null,2)}catch{}var r=t&&t.content||"";return typeof r=="string"&&r&&r.indexOf("/api/")!==0?r:""}function $8(t,n){var r=URL.createObjectURL(t),o=document.createElement("a");o.href=r,o.download=n,document.body.appendChild(o),o.click(),o.remove(),setTimeout(function(){try{URL.revokeObjectURL(r)}catch{}},4e3)}function B2(t,n){var r=t&&t.content||"",o=n||"chart.png";function a(){var s=t&&t.signed_url||"";if(s){var c=document.createElement("a");c.href=s,c.download=o,c.target="_blank",c.rel="noopener",document.body.appendChild(c),c.click(),c.remove()}}if(typeof r=="string"&&r.indexOf("/api/")===0){var l=r+(r.indexOf("?")===-1?"?stream=1":"&stream=1");fetch(qr(l),{headers:fo()}).then(function(s){if(!s.ok)throw new Error("HTTP "+s.status);return s.blob()}).then(function(s){$8(s,o)}).catch(a);return}a()}var Js={wrap:{display:"flex",flexDirection:"column",gap:8,width:"100%"},toolbar:{display:"flex",justifyContent:"flex-end",gap:6},btn:{background:"transparent",border:"1px solid rgba(34,211,238,0.35)",borderRadius:4,color:"#22D3EE",fontFamily:"JetBrains Mono, ui-monospace, monospace",fontSize:9,letterSpacing:"0.08em",padding:"3px 10px",cursor:"pointer"},btnActive:{background:"rgba(34,211,238,0.12)"},specBox:{border:"1px solid rgba(34,211,238,0.2)",borderRadius:4,overflow:"auto",maxHeight:260}};function J8(t){var n=t&&t.title||"chart";return n=String(n).trim().replace(/[^\w.-]+/g,"_").replace(/^_+|_+$/g,"").slice(0,80),(n||"chart")+".png"}function P2(t){var n=t&&t.artifact||{},r=t&&t.drawDelayMs||0,o=(0,i.useState)(!1),a=o[0],l=o[1],s=N2(n),c=n&&n.metadata&&n.metadata.spec,d=null;try{d=L2(c,640,360)}catch{d=null}var p=!!d,g=typeof n.content=="string"&&n.content.indexOf("/api/")===0;return(0,e.jsxs)("div",{style:Js.wrap,children:[p?(0,e.jsx)(q8,{artifact:n,drawDelayMs:r}):(0,e.jsx)(Xy,{artifact:n}),p&&(s||g)?(0,e.jsxs)("div",{style:Js.toolbar,children:[g?(0,e.jsx)("button",{type:"button",style:Js.btn,title:"Download the chart as a PNG",onClick:function(){B2(n,J8(n))},children:"⇩ PNG"}
246):null,s?(0,e.jsxs)("button",{type:"button",style:{...Js.btn,...a?Js.btnActive:null},title:"Show the chart's JSON data spec",onClick:function(){l(function(f){return!f})},children:["⧉ ",a?"HIDE SPEC":"SPEC"]}):null]}):null,!p&&s?(0,e.jsx)("div",{style:Js.toolbar,children:(0,e.jsx)("button",{type:"button",style:{...Js.btn,...a?Js.btnActive:null},title:"Show the chart's JSON data spec",onClick:function(){l(function(f){return!f})},children:a?"HIDE SPEC":"SPEC"})}):null,a&&s?(0,e.jsx)("div",{style:Js.specBox,children:(0,e.jsx)(qp,{content:s,language:"json"})}):null]})}var om="18.3.1",Q8="/vendor/react-"+om+".production.min.js",Z8="/vendor/react-dom-"+om+".production.min.js",nh="https://unpkg.com/react@"+om+"/umd/react.production.min.js",rh="https://unpkg.com/react-dom@"+om+"/umd/react-dom.production.min.js";function eT(){try{if(typeof window<"u"&&window.location&&window.location.origin&&window.location.origin!=="null")return window.location.origin}catch{}return""}function tT(t){var n=JSON.stringify(String(t||"")).replace(/<\/script/gi,"<\\u002fscript").replace(/<!--/g,"<\\u0021--"),r="<\/script>",o=eT(),a=o?o+Q8:"",l=o?o+Z8:"",s=(a?[a,l,nh,rh]:[nh,rh]).join(" "),c=JSON.stringify({react:{src:a||"https://unpkg.com/[email protected]/umd/react.production.min.js",fallback:a?nh:""},reactDom:{src:l||"https://unpkg.com/[email protected]/umd/react-dom.production.min.js",fallback:l?rh:""}});return["<!DOCTYPE html><html><head>",'<meta http-equiv="Content-Security-Policy" content="',"default-src 'none'; ","script-src 'unsafe-inline' 'unsafe-eval' "+s+"; ","style-src 'unsafe-inline'; ","img-src data:; ","connect-src 'none'; ","form-action 'none'; ","base-uri 'none'",'">',"<style>body{margin:12px;font-family:system-ui,sans-serif;background:#fff;color:#111}</style>",'</head><body><div id="root"></div>',"<script>","(function () {","  function report(kind, message) {",'    try { parent.postMessage({ __xyronArtifactPreview: kind, message: String(message || "") }, "*"); } catch (e) {}',"  }",'  window.onerror = function (msg) { report("error", msg); return true; };',"  var __runtimes = "+c+";","  function loadScript(src, fallback, next) {",'    var s = document.createElement("script");',"    s.src = src;","    s.onload = next;","    s.onerror = function () {","      if (fallback) { loadScript(fallback, '', next); }",'      else { report("error", "Failed to load the React preview runtime."); }',"    };","    document.head.appendChild(s);","  }","  function boot() {","  try {","    var code = "+n+";","    var R = window.React;","    var factory = new Function(",'      "React", "useState", "useEffect", "useMemo", "useRef", "useCallback",',`      '"use strict";\\nvar __exports = {};\\nvar module = { exports: __exports };\\n'`,'      + code.replace(/export\\s+default\\s+/g, "module.exports.default = ")',"      + '\\nreturn (module.exports.default || __exports.default || null);'","    );","    var Component = factory(R, R.useState, R.useEffect, R.useMemo, R.useRef, R.useCallback);",'    if (!Component || typeof Component !== "function") {','      report("error", "No default-exported component found in artifact source.");',"    } else {",'      var root = window.ReactDOM.createRoot(document.getElementById("root"));',"      root.render(R.createElement(Component));",'      report("ok", "");',"    }","  } catch (e) {",'    report("error", (e && e.message) ? e.message : String(e));',"  }","  }","  loadScript(__runtimes.react.src, __runtimes.react.fallback, function () {","    loadScript(__runtimes.reactDom.src, __runtimes.reactDom.fallback, boot);","  });","})();",r,"</body></html>"].join("")}var Gc={wrap:{display:"flex",flexDirection:"column",width:"100%",height:"100%",minHeight:240},bar:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",flexShrink:0},note:{color:"#5A6878",fontFamily:"monospace",fontSize:10,letterSpacing:"0.04em"},btn:{background:"transparent",border:"1px solid rgba(212,175,92,0.3)",borderRadius:4,color:"#D4AF5C",fontFamily:"monospace",fontSize:10,padding:"4px 10px",cursor:"pointer",letterSpacing:"0.05em"},frame:{flex:1,width:"100%",minHeight:240,border:"1px solid rgba(212,175,92,0.2)",borderRadius:4,background:"#FFFFFF"},err:{color:"#E07B7B",background:"rgba(224,123,123,0.05)",border:"1px solid rgba(224,123,123,0.3)",borderRadius:4,padding:12,margin:"0 8px 8px 8px",fontFamily:"monospace",fontSize:12,whiteSpace:"pre-wrap"},body:{flex:1,overflow:"auto"}};function U2(t){var n=t&&t.content||"",r=(0,i.useState)("code"),o=r[0],a=r[1],l=(0,i.useState)(""),s=l[0],c=l[1],d=(0,i.useState)(null),p=d[0],g=d[1],f=(0,i.useRef)(null);(0,i.useEffect)(function(){a("code"),c(""),g(null)},[n,a,c,g]),(0,i.useEffect)(function(){function x(v){if(!(!f.current||v.source!==f.current.contentWindow)){var y=v.data||{};y.__xyronArtifactPreview==="error"&&(g(y.message||"Preview failed."),a("code"))}}return window.addEventListener("message",x),function(){window.removeEventListener("message",x)}},[g,a]);function h(){g(null);var x=n.replace(/^\s*import\s+[^;
246\n]*from\s+['"](?:react|react-dom)(?:\/[^'"]*)?['"];?\s*$/gm,"").replace(/^\s*import\s+['"](?:react|react-dom)(?:\/[^'"]*)?['"];?\s*$/gm,"");if(/^\s*import\s+/m.test(x)){g("Only React imports are supported in artifact components — third-party imports were found. React and its hooks are pre-injected; remove other imports to preview.");return}xi(()=>import("./vendor-C44JUHxF.js").then(v=>Yp(v.pt(),1)).then(function(v){var y="";try{y=v.transform(x,{presets:["react"],filename:"artifact.jsx"}).code||""}catch(k){g("Babel transform error: "+(k&&k.message?k.message:String(k)));return}c(tT(y)),a("preview")}),__vite__mapDeps([0,1,2])).catch(function(){g("Preview engine failed to load.")})}return(0,e.jsxs)("div",{style:Gc.wrap,children:[(0,e.jsxs)("div",{style:Gc.bar,children:[o==="preview"?(0,e.jsx)("button",{type:"button",style:Gc.btn,onClick:function(){a("code"),c("")},children:"SHOW CODE"}):(0,e.jsx)("button",{type:"button",style:Gc.btn,onClick:h,children:"▶ RUN PREVIEW"}),(0,e.jsx)("span",{style:Gc.note,children:o==="preview"?"sandboxed preview — isolated origin, no app access":"safe code view — preview runs in an isolated sandbox"})]}),p?(0,e.jsx)("div",{style:Gc.err,children:p}):null,o==="preview"&&s?(0,e.jsx)("iframe",{ref:f,title:"React artifact preview (sandboxed)",sandbox:"allow-scripts",referrerPolicy:"no-referrer",style:Gc.frame,srcDoc:s}):(0,e.jsx)("div",{style:Gc.body,children:(0,e.jsx)(qp,{content:n,language:"jsx"})})]})}var Hu={wrap:{display:"flex",flexDirection:"column",height:"100%"},tabs:{display:"flex",gap:4,padding:"4px 8px",borderBottom:"1px solid rgba(212,175,92,0.2)",overflowX:"auto",background:"rgba(2,4,10,0.6)"},tab:{padding:"6px 12px",fontFamily:"monospace",fontSize:11,background:"transparent",border:0,cursor:"pointer",color:"#5A6878",borderBottom:"2px solid transparent",whiteSpace:"nowrap"},tabActive:{color:"#D4AF5C",borderBottom:"2px solid #D4AF5C"},body:{flex:1,overflow:"auto",padding:8},err:{color:"#5A6878",padding:12,fontStyle:"italic"}};function nT(t){return{py:"python",js:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",sql:"sql",sh:"bash",rs:"rust",go:"go",java:"java",c:"c",cpp:"cpp",rb:"ruby",php:"php",html:"html",css:"css",yaml:"yaml",yml:"yaml",json:"json",xml:"xml"}[(t||"").split(".").pop().toLowerCase()]||"text"}function W2(t){var n=t&&t.content||"",r=(0,i.useMemo)(function(){try{var h=typeof n=="string"?JSON.parse(n):n;if(h&&Array.isArray(h.files))return h.files}catch{}return null},[n]),o=(0,i.useState)(0),a=o[0],l=o[1];if(!r||r.length===0)return(0,e.jsx)("div",{style:Hu.err,children:"Could not render multi-file artifact — content is not valid JSON with a files array."});var s=r[Math.min(a,r.length-1)]||r[0],c=s&&s.name||"file",d=c.split(".").pop().toLowerCase(),p=d==="md"||d==="markdown",g=s&&s.language||nT(c),f=s&&s.content||"";return(0,e.jsxs)("div",{style:Hu.wrap,children:[(0,e.jsx)("div",{style:Hu.tabs,children:r.map(function(h,x){return(0,e.jsx)("button",{type:"button",style:Object.assign({},Hu.tab,x===a?Hu.tabActive:{}),onClick:function(){l(x)},children:h&&h.name||"file "+(x+1)},x)})}),(0,e.jsx)("div",{style:Hu.body,children:p?(0,e.jsx)(Wp,{content:f}):(0,e.jsx)(qp,{content:f,language:g})})]})}var rb="monospace";function rT(t,n){var r=t&&t.type||"markdown",o=t&&t.content||"",a=t&&t.language||"text";switch(r){case"code":return(0,e.jsx)(qp,{content:o,language:a});case"csv":return(0,e.jsx)(Ky,{content:o});case"html":return(0,e.jsx)(j2,{content:o});case"svg":return(0,e.jsx)(w2,{content:o});case"table":return(0,e.jsx)(T2,{content:o});case"mermaid":return(0,e.jsx)(_2,{content:o});case"react":return(0,e.jsx)(U2,{content:o});case"multifile":return(0,e.jsx)(W2,{content:o});case"image":return(0,e.jsx)(Xy,{artifact:t});case"chart":return(0,e.jsx)(P2,{artifact:t,drawDelayMs:n});default:return(0,e.jsx)(Wp,{content:o})}}function Tg(t){var n=t&&t.artifact;if(!n||n.type==="video")return null;var r=!!(n.content||n.url),o=(t.fallbackText||"").trim();if(!r&&!o)return null;var a=String(n.type||"document").toUpperCase(),l=t&&t.chartDrawDelayMs||0,s=r?rT(n,l):(0,e.jsx)(Wp,{content:o});return(0,e.jsxs)("div",{className:"chat-artifact-inline",style:{marginTop:8,border:"1px solid rgba(212,175,92,0.18)",borderRadius:8,background:"rgba(212,175,92,0.03)",overflow:"hidden"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",borderBottom:"1px solid rgba(212,175,92,0.14)",background:"rgba(212,175,92,0.05)"},children:[(0,e.jsx)("span",{style:{padding:"2px 6px",borderRadius:3,background:"rgba(212,175,92,0.15)",color:"#D4AF5C",fontFamily:rb,fontSize:8,letterSpacing:".08em",fontWeight:700},children:a}),(0,e.jsx)("span",{style:{flex:1,minWidth:0,fontFamily:rb,fontSize:9,color:"#7A90A8",letterSpacing:".06em",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n.title||"Artifact"})]}),(0,e.jsx)("div",{style:{maxHeight:420,overflowY:"auto",overflowX:"auto",padding:"12px 14px"},children:s})]})}var ib="JetBrains Mono, ui-monospace, monospace";function H2(t){var n=t.routeDecisionId,r=t.messageId,o=(0,i.useState)(null),a=o[0],l=o[1],s=(0,i.useState)(!1),c=s[0],d=s[1];if(!n)return null;function p(f){a||c||(d(!0),xA({route_decision_id:n,signal_type:f,metadata:r?{message_id:r}:{}}).then(function(){l(f),d(!1)}))}function g(f){return{padding:"2px 8px",background:f?"rgba(91,168,160,0.10)":"transparent",border:"1px solid "+(f?"rgba(91,168,160,0.32)":"#1E2838"),borderRadius:4,cursor:a||c?"default":"pointer",fontFamily:ib,fontSize:9,color:f?"#5BA8A0":"#3A4A5E",opacity:a&&!f?.4:1,transition:"all 120ms ease"}}return i.createElement("div",{style:{display:"flex",gap:4,alignItems:"center",padding:"4px 10px 6px"},"data-testid":"feedback-buttons"},i.createElement("span",{style:{fontFamily:ib,fontSize:7,color:"#2A3848",letterSpacing:".10em",marginRight:4}},"FEEDBACK"),i.createElement("button",{type:"button",onClick:function(){p("thumbs_up")},disabled:!!a||c,style:g(a==="thumbs_up"),title:"Helpful response","aria-label":"thumbs up"},"👍"),i.createElement("button",{type:"button",onClick:function(){p("thumbs_down")},disabled:!!a||c,style:g(a==="thumbs_down"),title:"Unhelpful response","aria-label":"thumbs down"},"👎"))}function ff(t){var n=t;return!n&&typeof import.meta<"u"&&(n={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_GOOGLE_MAPS_BROWSER_KEY:"AIzaSyBi4y8FSk1LUcuNzI9GkPCdf3Veh_Vf__E",VITE_SERVER_AUTHORITATIVE_ROOMS_ENABLED:"true",VITE_VIDEO_BACKEND:"livekit"}),!!n&&n.VITE_XYRON_CHAT_CRITICAL_PATH_V2_ENABLED==="true"}function iT({enabled:t,generalMode:n,roomSymbol:r}){return!!t&&(!!n||!!r)}function ob({enabled:t,latencyProfile:n}){return!!t}var pf="Inter, -apple-system, 'Segoe UI', system-ui, sans-serif",_g="ui-monospace, SFMono-Regular, Menlo, monospace";function oT(t,n){var r=t||"",o=!1;try{o=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{o=!1}
246var a=(0,i.useState)(r.length),l=a[0],s=a[1],c=(0,i.useRef)(r.length),d=(0,i.useRef)(0),p=(0,i.useRef)(0);return(0,i.useEffect)(function(){if(!n||o){d.current&&(cancelAnimationFrame(d.current),d.current=0),c.current=r.length,s(r.length);return}c.current>r.length&&(c.current=r.length,s(r.length)),p.current=0;var g=90,f=4;function h(x){p.current||(p.current=x);var v=x-p.current;p.current=x;var y=r.length,k=c.current;if(k<y){var A=g+(y-k)*f,j=Math.max(1,Math.round(v/1e3*A)),E=Math.min(y,k+j);c.current=E,s(E)}c.current<y?d.current=requestAnimationFrame(h):d.current=0}return c.current<r.length&&(d.current=requestAnimationFrame(h)),function(){d.current&&(cancelAnimationFrame(d.current),d.current=0)}},[r,n,o,s]),!n||o?r:r.slice(0,Math.min(l,r.length))}function ih(t,n){return t.map(function(r,o){var a=n+"-"+o;return r.t==="bold"?(0,e.jsx)("strong",{style:{color:"#E6EDF3",fontWeight:700},children:r.v},a):r.t==="code"?(0,e.jsx)("code",{style:{fontFamily:_g,fontSize:11,background:"rgba(212,175,92,0.10)",borderRadius:3,padding:"1px 4px",color:"#D4AF5C"},children:r.v},a):(0,e.jsx)("span",{children:r.v},a)})}function ab({text:t,accent:n}){return(0,e.jsx)("div",{children:j8(t).map(function(r,o){return r.type==="code"?(0,e.jsx)("pre",{style:{margin:"8px 0",padding:"8px 10px",background:"rgba(255,255,255,0.03)",border:"1px solid "+n+"26",borderRadius:6,fontFamily:"monospace",fontSize:11,lineHeight:1.45,overflowX:"auto",whiteSpace:"pre",color:"#C9D1D9"},children:r.code},o):r.type==="table"?(0,e.jsx)("div",{style:{overflowX:"auto",margin:"8px 0",border:"1px solid "+n+"33",borderRadius:6},children:(0,e.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse"},children:[(0,e.jsx)("thead",{children:(0,e.jsx)("tr",{children:r.header.map(function(a,l){return(0,e.jsx)("th",{style:{padding:"5px 10px",fontFamily:"monospace",fontSize:9,fontWeight:800,letterSpacing:".1em",textTransform:"uppercase",whiteSpace:"nowrap",color:n,textAlign:r.align[l],borderBottom:"1px solid "+n+"44",background:"rgba(255,255,255,0.02)"},children:a},l)})})}),(0,e.jsx)("tbody",{children:r.rows.map(function(a,l){return(0,e.jsx)("tr",{children:a.map(function(s,c){var d=r.align[c]==="right";return(0,e.jsx)("td",{style:{padding:"4px 10px",fontSize:d?11:12,color:"#C9D1D9",textAlign:r.align[c],fontFamily:d?_g:pf,fontVariantNumeric:"tabular-nums",whiteSpace:"nowrap",borderBottom:l<r.rows.length-1?"1px solid "+n+"18":"none"},children:ih(Zm(s),o+"-"+l+"-"+c)},c)})},l)})})]})},o):r.type==="heading"?(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:r.depth<=2?10:9,fontWeight:800,color:"#D4AF5C",letterSpacing:r.depth<=2?".12em":".09em",textTransform:"uppercase",margin:r.depth<=2?"12px 0 5px":"9px 0 3px",borderBottom:r.depth<=2?"1px solid rgba(212,175,92,0.24)":"none",paddingBottom:r.depth<=2?3:0},children:r.text},o):r.type==="list"?(0,e.jsx)("ul",{style:{margin:"5px 0",paddingLeft:4,listStyle:"none"},children:r.items.map(function(a,l){return(0,e.jsxs)("li",{style:{display:"flex",gap:6,alignItems:"flex-start",fontSize:13,lineHeight:1.55,marginBottom:2,color:"#C9D1D9"},children:[(0,e.jsx)("span",{style:{color:n,flexShrink:0},children:r.ordered?l+1+".":"›"}),(0,e.jsx)("span",{children:ih(Zm(a),o+"-"+l)})]},l)})},o):(0,e.jsx)("p",{style:{margin:"0 0 6px",fontSize:13,lineHeight:1.6},children:ih(Zm(r.text),String(o))},o)})})}function aT(t){return t?String(t).replace(/```/g,"").replace(/`([^`]*)`/g,"$1").replace(/`/g,"").replace(/^\s{0,3}#{1,6}\s+/gm,"").replace(/^\s*>\s?/gm,"").replace(/^(\s*)[-*+]\s+/gm,"$1• ").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/\*+/g,"").replace(/^\s*\|?[-:\s|]{5,}\|?\s*$/gm,"").replace(/\|/g,"  "):""}function lb(t){return t&&String(t).replace(/(.{2,24}?)\1{3,}/g,"$1")}function lT(t){try{return new URL(t).hostname.replace(/^www\./,"")}catch{return""}}function sT(t){var n={},r=[];return(t||[]).forEach(function(o){var a=String(o&&o.url||"").trim().replace(/\/$/,"").toLowerCase();!a||n[a]||(n[a]=1,r.push(o))}),r}function cT(t){try{var n=Date.now()-t;return n<6e4?"just now":n<36e5?Math.floor(n/6e4)+"m ago":n<864e5?Math.floor(n/36e5)+"h ago":new Date(t).toLocaleDateString()}catch{return""}}function fy(t){var n=t.accent||"#D4AF5C",r=t.speakingId,o=(Array.isArray(t.pinnedIds)?t.pinnedIds:[]).indexOf(t.msgId)!==-1,a=r===t.msgId,l=typeof t.onSpeak=="function",s=typeof t.onTogglePin=="function",c=typeof t.onRetry=="function",d={padding:"3px 8px",background:"transparent",border:"1px solid #1E2838",borderRadius:4,cursor:"pointer",fontFamily:"monospace",fontSize:7,letterSpacing:".06em",display:"flex",alignItems:"center",gap:4,transition:"all .12s"};return(0,e.jsxs)("div",{style:{marginTop:4},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:5,alignItems:"center",flexWrap:"wrap"},children:[l&&(0,e.jsx)("button",{type:"button",onClick:function(){t.onSpeak(t.text||"",t.msgId)},title:a?"Stop playback":"Play with Xyron voice",style:Object.assign({},d,{background:a?"rgba(63,185,80,0.10)":"transparent",borderColor:a?"rgba(63,185,80,0.32)":"#1E2838",color:a?"#3FB950":"#3A4A5E"}),children:(0,e.jsx)("span",{children:a?"⏹":"🔊"})}),(0,e.jsx)(uy,{text:t.text||"",msgId:t.msgId,chart:null,artifact:t.artifact||null,sessionId:t.sessionId||null,role:"assistant",onOpenArtifact:t.onOpenArtifact,allowSplit:t.allowSplit}),s&&(0,e.jsx)("button",{type:"button",onClick:function(){t.onTogglePin(t.msgId)},title:o?"Unpin this answer":"Pin this answer",style:Object.assign({},d,{background:o?"rgba(212,175,92,0.08)":"transparent",borderColor:o?"rgba(212,175,92,0.2)":"#1E2838",color:o?n:"#3A4A5E"}),children:(0,e.jsx)("span",{children:"📌"})}),c&&(0,e.jsxs)("button",{type:"button",onClick:function(){t.onRetry(t.retryQuestion||"")},title:"Re-ask this question",style:Object.assign({},d,{color:"#3A4A5E"}),children:[(0,e.jsx)("span",{children:"↺"}),(0,e.jsx)("span",{children:"RETRY"})]})]}),t.routeDecisionId?(0,e.jsx)(H2,{routeDecisionId:t.routeDecisionId,messageId:t.msgId}):null]})}function dT({visible:t,activeDrawer:n,accentColor:r,citations:o,streaming:a,streamText:l,err:s,phase:c,lastQuestion:d,onNewChat:p,onDismiss:g,history:f,onLoadHistory:h,maxHeightVh:x,artifactMaxHeightVh:v,followUps:y,onFollowUp:k,onClearHistory:A,cortexSuggest:j,onEnableCortex:E,onOpenInChat:C,openInChatLabel:_,chartPngUrl:w,onDownloadChartPng:O,turns:M,artifact:U,extraContent:ee,sessionId:N,routeDecisionId:V,allowSplit:z,defaultMinimized:oe,expandOnQuestion:P,onSpeak:W,speakingId:R,onTogglePin:ae,pinnedIds:q,onRetry:ge,onOpenArtifact:X}){var de=r||"#D4AF5C",We=Array.isArray(M)?M:[],te=typeof x=="number"?x:34,_e=U||We.some(function(Fe){return Fe&&Fe.artifact})?Math.max(te,typeof v=="number"?v:72):te,ve=(0,i.useRef)(null),Ne=(0,i.useRef)(!0),$e=(0,i.useState)(!!oe),Pe=(0,i.useRef)(""),ot=(0,i.useState)(!1),re=ot[0],we=ot[1],b=$e[0],He=$e[1];(0,i.useEffect)(function(){if(P){var Fe=d||"";Fe&&Fe!==Pe.current&&He(!1),Pe.current=Fe}},[P,d,He]);var tt=oT(l||"",!!a&&n!=="ledger"&&!ff());(0,i.useEffect)(function(){a&&(l||"").length===0&&(Ne.current=!0)},[a,l]),(0,i.useEffect)(function(){if(ve.current&&Ne.current)try{ve.current.scrollTop=ve.current.scrollHeight}catch{}},[tt,We.length]);function Ae(Fe){var ft=Fe.currentTarget;Ne.current=ft.scrollHeight-ft.clientHeight-ft.scrollTop<8}if(!t)return null;var Be=({realestate:"REAL ESTATE",intelgraph:"INTEL GRAPH",portfolio:"PORTFOLIO",scanner:"DOC SCAN",vault:"VAULT",calendar:"CALENDAR",map:"MAP",intel:"INTEL",room:"ROOM"}[n]||n||"drawer").toUpperCase();return(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",marginBottom:6,maxHeight:b&&!re?"32px":_e+"vh",background:"rgba(5,8,13,0.96)",border:"1px solid "+de+"55",borderRadius:8,boxShadow:"0 -6px 18px rgba(0,0,0,0.25)",overflow:"hidden",transition:"max-height 0.15s ease"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,height:32,padding:"0 10px",borderBottom:"1px solid "+de+"33",background:"rgba(255,255,255,0.02)",flexShrink:0},children:[(0,e.jsx)("div",{style:{width:6,height:6,borderRadius:"50%",background:a?de:s?"#F97583":"#3FB950",boxShadow:a?"0 0 8px "+de:"none",animation:a?"pulse 1.2s ease-in-out infinite":"none",flexShrink:0}}),(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:9,fontWeight:800,color:de,letterSpacing:".18em"},children:Be}),(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:9,fontWeight:700,color:s?"#F97583":"#8898A8",letterSpacing:".10em",textTransform:"uppercase"},children:a?"· analysing":s?"· error":"· response"}),d&&(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:10,
246color:"#C9D1D9",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginLeft:4},title:d,children:d}),(0,e.jsx)("button",{onClick:p,title:"Start a new drawer chat (saves current to archive)",style:{marginLeft:d?0:"auto",background:"transparent",border:"1px solid "+de+"55",borderRadius:3,color:de,cursor:"pointer",fontFamily:"monospace",fontSize:9,fontWeight:700,padding:"3px 8px",letterSpacing:".08em"},children:"+ NEW"}),typeof C=="function"&&(0,e.jsx)("button",{onClick:C,title:"Continue this in the main Xyron chat — charts, documents, split view",style:{background:"transparent",border:"1px solid "+de+"55",borderRadius:3,color:de,cursor:"pointer",fontFamily:"monospace",fontSize:9,fontWeight:700,padding:"3px 8px",letterSpacing:".08em"},children:_||"↗ XYRON CHAT"}),!!w&&typeof O=="function"&&(0,e.jsx)("button",{onClick:O,title:"Download this answer's chart as a deck-ready PNG (rendered server-side from the same ledger read)",style:{background:"transparent",border:"1px solid "+de+"55",borderRadius:3,color:de,curs
246or:"pointer",fontFamily:"monospace",fontSize:9,fontWeight:700,padding:"3px 8px",letterSpacing:".08em"},children:"⇩ PNG"}),Array.isArray(f)&&f.length>0&&(0,e.jsx)("button",{type:"button","aria-expanded":!!re,"aria-controls":"drawer-hist-list",onClick:function(){we(!re)},title:"Past answers for this module",style:{background:re?de+"18":"transparent",border:"1px solid "+de+"44",borderRadius:3,color:de,cursor:"pointer",fontFamily:"monospace",fontSize:9,fontWeight:700,padding:"3px 8px",letterSpacing:".08em"},children:"↺ HIST ("+f.length+")"}),(0,e.jsx)("button",{onClick:function(){b||(Ne.current=!0),He(!b)},title:b?"Expand response":"Minimise response (drawer fully visible behind)","aria-label":b?"Expand":"Minimise",style:{background:"transparent",border:"1px solid "+de+"33",borderRadius:3,color:"#8898A8",cursor:"pointer",fontFamily:"monospace",fontSize:10,fontWeight:700,padding:"1px 8px 3px",letterSpacing:".08em",lineHeight:1,transition:"all 150ms ease"},onMouseEnter:function(Fe){Fe.currentTarget.style.borderColor=de+"88",Fe.currentTarget.style.color=de},onMouseLeave:function(Fe){Fe.currentTarget.style.borderColor=de+"33",Fe.currentTarget.style.color="#8898A8"},children:b?"▴":"▾"}),(0,e.jsx)("button",{onClick:g,title:"Close response",style:{background:"transparent",border:"1px solid "+de+"33",borderRadius:3,color:"#8898A8",cursor:"pointer",fontFamily:"monospace",fontSize:9,fontWeight:700,padding:"3px 8px",letterSpacing:".08em"},children:"✕"})]}),re&&Array.isArray(f)&&f.length>0&&(0,e.jsxs)("div",{id:"drawer-hist-list","data-testid":"drawer-hist-list",style:{flexShrink:0,maxHeight:220,minHeight:0,overflowY:"auto",overflowX:"hidden",overscrollBehavior:"contain",WebkitOverflowScrolling:"touch",borderBottom:"1px solid "+de+"33",background:"#06080F",padding:4},children:[typeof A=="function"&&(0,e.jsx)("button",{type:"button",onClick:function(){A(),we(!1)},style:{display:"block",width:"100%",textAlign:"center",background:"transparent",border:"1px solid "+de+"33",borderRadius:4,cursor:"pointer",padding:"5px 9px",marginBottom:4,color:"#E06C6C",fontFamily:"monospace",fontSize:9,fontWeight:700,letterSpacing:".1em"},onMouseEnter:function(Fe){Fe.currentTarget.style.background="rgba(200,92,92,0.10)"},onMouseLeave:function(Fe){Fe.currentTarget.style.background="transparent"},children:"✕ CLEAR HISTORY"}),f.map(function(Fe,ft){return(0,e.jsxs)("button",{type:"button",onClick:function(){typeof h=="function"&&h(Fe,n),we(!1)},style:{display:"block",width:"100%",textAlign:"left",background:"transparent",border:"none",borderBottom:ft<f.length-1?"1px solid "+de+"18":"none",cursor:"pointer",padding:"7px 9px",color:"#C9D1D9",fontFamily:pf,fontSize:12,lineHeight:1.4},onMouseEnter:function(St){St.currentTarget.style.background=de+"12"},onMouseLeave:function(St){St.currentTarget.style.background="transparent"},children:[(0,e.jsx)("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Fe.q}),(0,e.jsx)("span",{style:{color:"#5A6878",fontSize:9,fontFamily:"monospace"},children:cT(Fe.ts)})]},ft)})]}),!b&&(0,e.jsxs)("div",{ref:ve,onScroll:Ae,style:{flex:1,minHeight:96,overflowY:"auto",padding:"10px 14px",color:"#C9D1D9",fontFamily:pf,fontSize:13,lineHeight:1.55},children:[We.map(function(Fe,ft){return(0,e.jsxs)("div",{style:{marginBottom:12},children:[(0,e.jsx)("div",{style:{fontFamily:_g,fontSize:10,color:"#5A6878",marginBottom:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:Fe.q,children:"❯ "+Fe.q}),(0,e.jsx)(ab,{text:Fe.a||"",accent:de}),Fe.artifact?(0,e.jsx)("div",{style:{marginTop:6},children:(0,e.jsx)(Tg,{artifact:Fe.artifact,fallbackText:Fe.a||""})}):null,(0,e.jsx)(fy,{text:Fe.a||"",msgId:"drawer-turn-"+(Fe.ts||ft),artifact:Fe.artifact||null,sessionId:N,accent:de,allowSplit:z,routeDecisionId:Fe.routeDecisionId,onSpeak:W,speakingId:R,onTogglePin:ae,pinnedIds:q,onRetry:ge,retryQuestion:Fe.q||"",onOpenArtifact:X}),Array.isArray(Fe.followUps)&&Fe.followUps.length>0&&typeof k=="function"?(0,e.jsx)("div",{style:{marginTop:8,display:"flex",flexWrap:"wrap",gap:6},children:Fe.followUps.slice(0,5).map(function(St,Xe){return(0,e.jsx)("button",{onClick:function(){k(St)},style:{background:"transparent",border:"1px solid "+de+"33",borderRadius:12,padding:"3px 10px",cursor:"pointer",fontFamily:"monospace",fontSize:9,color:"#9FB0C0",letterSpacing:".02em"},children:St},Xe)})}):null,(0,e.jsx)("div",{style:{borderBottom:"1px solid "+de+"26",margin:"10px 0 0"}})]},ft)}),We.length>
2460&&d?(0,e.jsx)("div",{style:{fontFamily:_g,fontSize:10,color:"#5A6878",marginBottom:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:d,children:"❯ "+d}):null,s?(0,e.jsx)("span",{style:{color:"#F97583",whiteSpace:"pre-wrap"},children:s}):l?a?(0,e.jsx)("div",{style:{whiteSpace:"pre-wrap"},children:n==="ledger"?l.length>6e3?"…"+l.slice(-6e3):l:aT(lb(tt.length>6e3?"…"+tt.slice(-6e3):tt))}):n==="ledger"?(0,e.jsx)(ab,{text:l.length>9e3?l.slice(0,9e3)+`
247
248[response truncated to avoid overload]`:l,accent:de}):(0,e.jsx)(ws,{text:lb(l.length>9e3?l.slice(0,9e3)+`
249
250[response truncated to avoid overload]`:l)}):(0,e.jsx)("span",{style:{color:"#5A6878",fontFamily:pf,fontSize:12},children:a?c||"Thinking…":Array.isArray(f)&&f.length>0?"Open ↺ HIST above for a past answer, or ask a new question.":""}),ee||null,U?(0,e.jsx)("div",{style:{marginTop:s||l?0:4},children:(0,e.jsx)(Tg,{artifact:U,fallbackText:l||""})}):null,!a&&!s&&(l||U)?(0,e.jsx)(fy,{text:l||"",msgId:"drawer-"+(n||"x")+"-current",artifact:U||null,sessionId:N,accent:de,allowSplit:z,routeDecisionId:V,onSpeak:W,speakingId:R,onTogglePin:ae,pinnedIds:q,onRetry:ge,retryQuestion:d||"",onOpenArtifact:X}):null,j&&typeof E=="function"?(0,e.jsxs)("div",{style:{marginTop:8,display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,e.jsx)("span",{style:{color:"#5A6878",fontFamily:pf,fontSize:11},children:"For a forecast/signal read, consult Cortex:"}),(0,e.jsx)("button",{type:"button",onClick:E,style:{background:"rgba(63,185,80,0.12)",border:"1px solid rgba(63,185,80,0.45)",borderRadius:4,padding:"3px 10px",cursor:"pointer",fontFamily:pf,fontSize:11,fontWeight:600,letterSpacing:".04em",color:"#3FB950"},children:"⬡ Enable Cortex & re-ask"})]}):null]}),!b&&!a&&Array.isArray(y)&&y.length>0&&(0,e.jsx)("div",{style:{borderTop:"1px solid "+de+"22",padding:"8px 14px 10px",flexShrink:0,display:"flex",flexWrap:"wrap",gap:6},children:y.slice(0,5).map(function(Fe,ft){return(0,e.jsx)("button",{onClick:function(){k&&k(Fe)},style:{background:"transparent",border:"1px solid "+de+"44",borderRadius:12,padding:"4px 11px",cursor:"pointer",fontFamily:"monospace",fontSize:9,color:"#C9D1D9",letterSpacing:".02em"},children:Fe},ft)})}),!b&&n==="realestate"&&Array.isArray(o)&&o.length>0&&(0,e.jsxs)("div",{style:{borderTop:"1px solid "+de+"22",padding:"8px 14px 10px",flexShrink:0},children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:8,fontWeight:700,letterSpacing:".14em",color:de,marginBottom:6},children:"◈ SOURCES"}),(0,e.jsx)("ol",{style:{margin:0,padding:0,listStyle:"none"},children:sT(o).map(function(Fe,ft){var St=lT(Fe.url);return(0,e.jsxs)("li",{style:{marginBottom:4,display:"flex",gap:6,alignItems:"baseline"},children:[(0,e.jsx)("span",{style:{color:de,fontFamily:"monospace",fontSize:9,fontWeight:700,minWidth:14},children:"["+(ft+1)+"]"}),(0,e.jsxs)("span",{style:{minWidth:0},children:[(0,e.jsx)("a",{href:Fe.url,target:"_blank",rel:"noopener noreferrer",style:{color:"#9FB4CC",fontFamily:"monospace",fontSize:10,textDecoration:"none",wordBreak:"break-word"},children:Fe.title||Fe.url}),St?(0,e.jsx)("span",{style:{color:"#5A6878",fontFamily:"monospace",fontSize:8,marginLeft:6},children:St}):null,Fe.fetched_at?(0,e.jsx)("span",{style:{color:"#3E4C5A",fontFamily:"monospace",fontSize:8,marginLeft:6},children:"· retrieved "+String(Fe.fetched_at).slice(0,10)}):null]})]},(Fe.url||"")+ft)})})]})]})}var tp="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";function uT(t){var n=t.kind==="mention"?"mention":"slash",r=Array.isArray(t.items)?t.items:[],o=Math.max(0,Number(t.index)||0),a=!!t.loading,l=typeof t.onSelect=="function"?t.onSelect:null,s=typeof t.onHover=="function"?t.onHover:null,c=n==="mention"?"MENTION CONTEXT":"COMMANDS",d=n==="mention"?"No matching documents, tickers, or projects":"No matching commands";return(0,e.jsxs)("div",{"data-testid":"composer-shortcut-menu","data-kind":n,role:"listbox","aria-label":n==="mention"?"Mention picker":"Command menu",style:{margin:"4px 12px 2px",background:"rgba(8,11,17,0.96)",border:"1px solid "+I.hairline2,borderTop:"1px solid "+I.goldDeep,borderRadius:6,boxShadow:"0 12px 28px rgba(0,0,0,0.45)",overflow:"hidden",maxHeight:240,display:"flex",flexDirection:"column"},children:[(0,e.jsxs)("div",{style:{padding:"6px 10px 4px",fontFamily:tp,fontSize:8,letterSpacing:".16em",color:I.gold,fontWeight:700},children:[c,t.query?(0,e.jsxs)("span",{style:{color:I.ink5,marginLeft:8},children:[n==="slash"?"/":"@",t.query]}):null]}),(0,e.jsxs)("div",{style:{overflowY:"auto",maxHeight:240},children:[a&&r.length===0?(0,e.jsx)("div",{style:{padding:"10px 12px",fontFamily:tp,fontSize:11,color:I.ink5},children:"Loading…"}):null,!a&&r.length===0?(0,e.jsx)("div",{style:{padding:"10px 12px",fontFamily:tp,fontSize:11,color:I.ink5},children:d}):null,r.map(function(p,g){var f=g===o;return(0,e.jsxs)("button",{type:"button",role:"option","aria-selected":f?"true":"false","data-testid":"composer-shortcut-item-"+p.id,onMouseEnter:function(){s&&s(g)},onMouseDown:function(h){h.preventDefault(),l&&l(p)},style:{display:"flex",alignItems:"baseline",gap:10,width:"100%",textAlign:"left",padding:"7px 12px",background:f?"rgba(212,175,92,0.10)":"transparent",border:"none",borderLeft:f?"2px solid "+I.gold:"2px solid transparent",curs
250or:"pointer",color:f?I.ink1:I.ink4},children:[(0,e.jsx)("span",{style:{fontFamily:tp,fontSize:12,fontWeight:700,color:I.gold,minWidth:72},children:n==="slash"?"/"+p.token:"@"+p.label}),(0,e.jsx)("span",{style:{fontFamily:tp,fontSize:10,color:I.ink5,flex:1},children:p.hint||p.label})]},p.id)})]})]})}var fT=[{id:"search",token:"search",label:"Search",hint:"Web search",group:"Tools"},{id:"intel",token:"intel",label:"Intel",hint:"Market intelligence",group:"Tools"},{id:"video",token:"video",label:"Video",hint:"Video intelligence",group:"Tools"},{id:"map",token:"map",label:"Map",hint:"Geospatial",group:"Tools"},{id:"vault",token:"vault",label:"Vault",hint:"Documents",group:"Tools"},{id:"email",token:"email",label:"Email",hint:"Inbox & compose",group:"Tools"},{id:"calendar",token:"calendar",label:"Calendar",hint:"Schedule",group:"Tools"},{id:"command",token:"command",label:"Command",hint:"Ops console",group:"Tools"},{id:"portfolio",token:"portfolio",label:"Portfolio",hint:"Holdings",group:"Tools"},{id:"scanner",token:"scan",label:"Doc Scan",hint:"Document scanner",group:"Tools"},{id:"intelgraph",token:"graph",label:"Intel Graph",hint:"Entity graph",group:"Tools"},{id:"eyes",token:"vision",label:"Vision",hint:"Camera / live vision",group:"Tools"},{id:"call",token:"call",label:"Call",hint:"Start a video call",group:"Tools"},{id:"ledger",token:"ledger",label:"Ledger",hint:"Books & invoices",group:"Tools"},{id:"realestate",token:"property",label:"Real Estate",hint:"Property book",group:"Tools"},{id:"messenger",token:"messenger",label:"Messenger",hint:"Channels",group:"Tools"},{id:"brief",token:"brief",label:"Brief",hint:"Daily brief",group:"Tools"},{id:"audit",token:"audit",label:"Audit",hint:"Audit trail",group:"Tools"},{id:"risk",token:"risk",label:"Risk",hint:"Risk desk",group:"Tools"},{id:"cortex",token:"cortex",label:"Cortex",hint:"Cortex engines",group:"Tools"},{id:"actions",token:"actions",label:"Actions",hint:"Action inbox",group:"Tools"},{id:"bundles",token:"bundles",label:"Bundles",hint:"Action bundles",group:"Tools"},{id:"palette",token:"palette",label:"Command palette",hint:"Open ⌘K",group:"System"},{id:"new",token:"new",label:"New chat",hint:"Fresh conversation",group:"System"},{id:"clear",token:"clear",label:"Clear chat",hint:"Drop this thread",group:"System"}];function sb(t,n){var r=String(t||""),o=n==null?r.length:Math.max(0,Math.min(r.length,Number(n)||0)),a=r.slice(0,o),l=a.match(/(^|[\s])\/([^\s]*)$/);if(l){var s=l[2]||"";return{kind:"slash",query:s,start:a.length-s.length-1}}var c=a.match(/(^|[\s])@([^\s]*)$/);if(c){var d=c[2]||"";return{kind:"mention",query:d,start:a.length-d.length-1}}return null}function oh(t,n,r){for(var o=String(t||""),a=Math.max(0,Math.min(o.length,n??0)),l=a+1;l<o.length&&o.charAt(l)!==" "&&o.charAt(l)!==`
251`;)l+=1;var s=r==null?"":String(r);return{value:o.slice(0,a)+s+o.slice(l),cursor:a+s.length}}function pT(t,n){var r=String(t||"").toLowerCase(),o=Array.isArray(n)?n:null;return fT.filter(function(a){return o&&a.group==="Tools"&&o.indexOf(a.id)===-1?!1:r?a.token.indexOf(r)===0||a.label.toLowerCase().indexOf(r)!==-1||a.token.indexOf(r)!==-1:!0})}function gT(t){return t?String(t.doc_id||t.id||t.name||""):""}function mT(t,n){var r=String(t||"").toLowerCase(),o=[],a={};function l(x){!x||!x.id||a[x.id]||(a[x.id]=!0,o.push(x))}var s=n||{};if(s.symbol){var c=String(s.symbol).trim();c&&(!r||c.toLowerCase().indexOf(r)!==-1)&&l({id:"sym:"+c.toUpperCase(),kind:"symbol",label:c.toUpperCase(),hint:"Ticker"})}if(s.project){var d=s.project.name||s.project.id;d&&(!r||String(d).toLowerCase().indexOf(r)!==-1)&&l({id:"proj:"+(s.project.id||d),kind:"project",label:String(d),hint:"Project"})}for(var p=[].concat(s.docs||[],s.savedDocs||[]),g=0;g<p.length;g+=1){var f=p[g];if(f){var h=f.name||"Document";r&&String(h).toLowerCase().indexOf(r)===-1||l({id:"doc:"+gT(f),kind:"doc",label:String(h),hint:"Vault",doc:f})}}return o.slice(0,12)}function cb(t,n,r){var o=Math.max(0,r||0);if(o===0)return 0;var a=(Number(t)||0)+(Number(n)||0);return a<0?o-1:a>=o?0:a}var db=[{id:"generate_report",label:"Generate Report",detect:function(t,n){var r=(n||"").toLowerCase();return!!(r.match(/generate|create|write|draft|prepare/)&&r.match(/report|brief|memo|board pack|document|analysis/)||(t||"").indexOf("<<<DOCUMENT>>>")!==-1)},extract:function(t,n){var r=(n||"").toLowerCase(),o=(t||"").match(/TITLE:\s*(.+)/m),a=o?o[1].trim():(n||"").substring(0,60);return r.includes("excel")||r.includes("xlsx")||r.includes("csv")?{format:"xlsx",title:a}:{format:"docx",title:a}}},{id:"run_stress_test",label:"Run Stress Test",detect:function(t,n){return!!(n||"").toLowerCase().match(/stress\s*test|scenario\s*analysis|shock\s*test|drawdown\s*scenario/)},extract:function(t,n){var r=[];return(t||"").split(`
252`).forEach(function(o){o.match(/^[-*]\s+.{10,}/)&&o.match(/\d+%|bps|shock|crisis|crash/i)&&r.push(o.replace(/^[-*]\s+/,"").trim())}),{scenarios:r.slice(0,5)}}},{id:"generate_chart",label:"Generate Chart",detect:function(t){return(t||"").indexOf("<<<CHART>>>")!==-1},extract:function(t){var n="bar",r="",o=(t||"").match(/TYPE:\s*(\w+)/m);return o&&(n=o[1].toLowerCase()),o=(t||"").match(/TITLE:\s*(.+)/m),o&&(r=o[
2521].trim()),{chartType:n,title:r}}},{id:"vault_search",label:"Vault Search",detect:function(t,n){return!!(n||"").toLowerCase().match(/find\s+in\s+vault|search\s+(vault|documents)|look\s+up.*document|retrieve.*from\s+vault/)},extract:function(t,n){return{query:n}}},{id:"portfolio_rebalance",label:"Portfolio Rebalance",detect:function(t,n){return!!(n||"").toLowerCase().match(/rebalanc|realloc|adjust\s+allocation|change\s+weight|increase.*position|decrease.*position|trim.*position/)},extract:function(t,n){return{instruction:n.substring(0,120)}}},{id:"export_conversation",label:"Export Conversation",detect:function(t,n){return!!(n||"").toLowerCase().match(/export\s+(this\s+)?chat|save\s+(this\s+)?(chat|conversation)\s+(to|as)|download\s+(this\s+)?conversation/)},extract:function(t,n){var r=(n||"").toLowerCase();return{format:r.includes("pdf")?"pdf":r.includes("word")||r.includes("docx")?"docx":"txt"}}},{id:"schedule_brief",label:"Schedule Brief",detect:function(t,n){return!!(n||"").toLowerCase().match(/schedule\s+(a\s+)?brief|set\s+up\s+(a\s+)?(daily|morning|weekly)\s+(brief|report)|automate\s+report/)},extract:function(t,n){var r=(n||"").toLowerCase();return{type:r.includes("weekly")?"weekly":r.includes("eod")||r.includes("end of day")?"eod":"morning"}}},{id:"send_email",label:"Send as Email",detect:function(t,n){var r=(n||"").toLowerCase();return!!(r.match(/draft\s+(an?\s+)?email|send\s+(an?\s+)?email|compose\s+(an?\s+)?email|email\s+(this|them|him|her|it|the)|write\s+(an?\s+)?email|reply\s+to\s+(this\s+)?email|forward\s+(this\s+)?email/)||r.match(/draft|compose|write/)&&r.match(/response|reply|letter|message/)&&r.match(/email|send|mail/))},extract:function(t,n){var r=(t||"").match(/\*\*Subject:\*\*\s*(.+)/i)||(t||"").match(/Subject:\s*(.+)/im),o=(n||"").match(/to\s+([A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,})/i)||(t||"").match(/\*\*To:\*\*\s*(.+)/i);return{subject:r?r[1].trim():"",to:o?o[1].trim():"",body:t||""}}},{id:"save_draft",label:"Save to Drafts",detect:function(t,n){return!!((n||"").toLowerCase().match(/draft\s+(an?\s+)?email|compose\s+(an?\s+)?email|write\s+(an?\s+)?email/)||(t||"").match(/\*\*Subject:\*\*/i)&&(t||"").match(/\*\*To:\*\*/i))},extract:function(t,n){var r=(t||"").match(/\*\*Subject:\*\*\s*(.+)/i)||(t||"").match(/Subject:\s*(.+)/im),o=(t||"").match(/\*\*To:\*\*\s*(.+)/i),a=[],l=!1;return(t||"").split(`
253`).forEach(function(s){s.match(/^---\s*$/)&&a.length>0||(l&&a.push(s),(s.match(/\*\*Body:\*\*|\*\*Message:\*\*/i)||s.match(/^---\s*$/)&&!l)&&(l=!0))}),{subject:r?r[1].trim():"",to:o?o[1].trim():"",body:a.length>0?a.join(`
254`).trim():t||""}}}];function hT(t,n){for(var r=[],o=0;o<db.length;o++){var a=db[o];try{if(a.detect(t,n)){var l=a.extract(t,n);r.push({id:a.id,label:a.label,params:l,ts:new Date().toISOString()})}}catch{}}return r}function G2(t){return{chunk:t<150?1:t<500?3:5,ms:t<500?18:16}}var yT=/[─-▟]/;function xT(t,n,r){if(r.indexOf("|")!==-1||yT.test(r))return!0;for(var o=0,a=0;;){var l=t.indexOf("```",a);if(l===-1||l>=n)break;o++,a=l+3}return o%2===1}function V2(t,n,r,o){var a=Math.min(n+r,t.length);if(o&&a<t.length){var l=t.lastIndexOf(`
255`,a-1)+1,s=t.indexOf(`
256`,a);xT(t,l,t.slice(l,s===-1?t.length:s))&&(a=s===-1?t.length:s+1)}return a}function Y2(t){t=t||{};var n=typeof t.setText=="function"?t.setText:function(){},r=!!t.lineAware,o=!!t.reduceMotion,a=typeof t.transform=="function"?t.transform:function(j){return j},l=typeof t.onFinalize=="function"?t.onFinalize:null,s="",c=0,d=null,p=!1,g=!1,f=null,h=!1;function x(){return a(s)}function v(){return f??x()}function y(){p=!1,d!=null&&(clearTimeout(d),d=null)}function k(){y(),g=!0;var j=f??x();c=j.length,l?l(j):n(j)}function A(){if(d=null,h){p=!1;return}var j=x();if(c>=j.length){if(g){k();return}p=!1;return}var E=G2(c);c=V2(j,c,E.chunk,r),n(j.substring(0,c)),p=!0,d=setTimeout(A,E.ms)}return{push:function(j){if(!h){if(s+=j||"",o){c=x().length,n(x());return}p||(p=!0,A())}},finish:function(j){h||(j!=null&&(f=j),g=!0,(o||!p)&&k())},fail:function(){h||(y(),h=!0)},cancel:function(){y(),h=!0},isActive:function(){return p},isDead:function(){return h},received:v,shownLength:function(){return c}}}var vT=["rooms","orderflow","projects","audit","briefs"];function bT(t){return vT.indexOf(t)!==-1}
256function _L(t,n){return t===n?null:bT(t)||t==="chat"?t:null}function ST(t){var n=!!(t&&t.embedded),r=!!(t&&t.turningOn),o=typeof(t&&t.onParkHostView)=="function",a=!!(t&&t.inRegistry);return n&&r&&o&&a}function RL(t,n){return n?null:t}function FL(t,n){return n?(t=t||[],t.indexOf(n)===-1?t.concat([n]):t):t||[]}function IL(t,n){return(t||[]).filter(function(r){return r!==n})}function DL(t){return t!=="call"&&t!=="stress"&&t!=="compare"}function ET(t,n,r){return!(!t&&n||r&&!t)}function kT(t,n){if(t=t||[],n=n||[],t.length!==n.length)return!1;for(var r=0;r<t.length;r++)if(n.indexOf(t[r])===-1)return!1;return!0}function CT(t,n){t=t||[],n=n||[];for(var r=t,o=0;o<n.length;o++){var a=n[o];!a||r.indexOf(a)!==-1||(r===t&&(r=t.slice()),r.push(a))}return r}function AT(t,n){var r=[];t=t||[];for(var o=0;o<t.length;o++){var a=t[o];a&&a!==n&&r.indexOf(a)===-1&&r.push(a)}return r}var jT=[{key:"chat",label:"CHAT"},{key:"rooms",label:"ROOMS"},{key:"orderflow",label:"ORDER FLOW"},{key:"projects",label:"PROJECTS"},{key:"audit",label:"AUDIT"},{key:"briefs",label:"BRIEFS"}];async function K2(t){var n=t.file,r=t.sessionId||null,o=t.product||"xyron_gpt",a=t.onProgress||function(){},l=t.onStateChange||function(){};l("pending",{fileName:n.name});var s;try{s=await fetch(qr("/api/chat/uploads/initiate"),{method:"POST",headers:fo(),body:JSON.stringify({session_id:r,file_name:n.name,content_type:n.type||"application/octet-stream",size_bytes:n.size,product:o})})}catch(j){throw l("failed",{error:"Network error during initiate"}),j}if(!s.ok){var c=await Rg(s);throw l("failed",{error:c}),new Error("initiate: "+c)}var d=await s.json(),p=d.file_id,g=d.upload_url,f=d.gcs_uri,h=d.headers||{},x=d.method||"PUT";l("uploading",{fileId:p,percent:0,method:x});var v;try{x==="POST"?v=await RT(n,g,h,a):v=await _T(n,g,h,a)}catch(j){throw l("failed",{fileId:p,error:"Upload failed: "+(j&&j.message?j.message:"unknown")}),j}var y;try{y=await fetch(qr("/api/chat/uploads/")+encodeURIComponent(p)+"/complete",{method:"POST",headers:fo(),body:JSON.stringify({actual_size_bytes:v})})}catch(j){throw l("failed",{fileId:p,error:"Complete failed: network"}),j}if(!y.ok){var k=await Rg(y);throw l("failed",{fileId:p,error:k}),new Error("complete: "+k)}var A=await y.json();return l("ready",{fileId:p,gcsUri:f,sniffedMime:A.sniffed_mime||null,sizeBytes:A.size_bytes||v,isArchive:!!A.is_archive,children:Array.isArray(A.children)?A.children:[]}),{file_id:p,gcs_uri:f,sniffed_mime:A.sniffed_mime||null,size_bytes:A.size_bytes||v,is_archive:!!A.is_archive,children:Array.isArray(A.children)?A.children:[]}}async function wT(t){var n=await fetch(qr("/api/chat/uploads/")+encodeURIComponent(t)+"/preview-url",{method:"POST",headers:fo()});if(!n.ok){var r=await Rg(n);throw new Error("preview: "+r)}return n.json()}async function TT(t){var n=t.fileId,r=t.vaultFileName||null,o=Array.isArray(t.tags)?t.tags:[],a=t.classify!==!1,l=await fetch(qr("/api/chat/uploads/")+encodeURIComponent(n)+"/promote-to-vault",{method:"POST",headers:fo(),body:JSON.stringify({vault_file_name:r,tags:o,classify:a})});if(!l.ok){var s=await Rg(l);throw new Error("promote: "+s)}return l.json()}function _T(t,n,r,o){return new Promise(function(a,l){var s=new XMLHttpRequest;s.open("PUT",n),Object.keys(r||{}).forEach(function(c){try{s.setRequestHeader(c,r[c])}catch{}}),s.upload.onprogress=function(c){c.lengthComputable&&o(Math.round(c.loaded/c.total*100))},s.onload=function(){s.status>=200&&s.status<300?a(t.size):l(new Error("PUT "+s.status+": "+(s.responseText||"").slice(0,200)))},s.onerror=function(){l(new Error("network"))},s.ontimeout=function(){l(new Error("timeout"))},s.send(t)})}function RT(t,n,r,o){return fetch(n,{method:"POST",headers:r||{},body:""}).then(function(a){if(!a.ok&&a.status!==201)return a.text().then(function(s){throw new Error("Resumable init failed "+a.status+": "+(s||"").slice(0,200))});var l=a.headers.get("Location");if(!l)throw new Error("Resumable init: no Location header");return new Promise(function(s,c){var d=new XMLHttpRequest;d.open("PUT",l),d.setRequestHeader("Content-Type",t.type||"application/octet-stream"),d.upload.onprogress=function(p){p.lengthComputable&&o(Math.round(p.loaded/p.total*100))},d.onload=function(){d.status>=200&&d.status<300?s(t.size):c(new Error("Resumable PUT "+d.status+": "+(d.responseText||"").slice(0,200))
256)},d.onerror=function(){c(new Error("network"))},d.ontimeout=function(){c(new Error("timeout"))},d.send(t)})})}async function Rg(t){try{var n=await t.json();return typeof n.detail=="string"?n.detail:n.detail&&typeof n.detail.message=="string"?n.detail.message:n.detail?JSON.stringify(n.detail).slice(0,200):"HTTP "+t.status}catch{return"HTTP "+t.status}}var FT=[".pdf",".doc",".docx",".txt",".rtf",".md",".xls",".xlsx",".csv",".ppt",".pptx",".png",".jpg",".jpeg",".webp",".gif",".svg",".mp3",".wav",".m4a",".mp4",".mov",".avi",".js",".ts",".tsx",".jsx",".py",".java",".go",".rs",".php",".html",".css",".json",".xml",".yaml",".yml",".sql",".sqlite",".db",".parquet",".zip",".rar",".7z",".tar",".gz"].join(","),IT={txt:1,rtf:1,md:1,csv:1,js:1,ts:1,tsx:1,jsx:1,py:1,java:1,go:1,rs:1,php:1,html:1,css:1,json:1,xml:1,yaml:1,yml:1,sql:1,svg:1},DT={pdf:"DOC",doc:"DOC",docx:"DOC",txt:"DOC",rtf:"DOC",md:"DOC",xls:"SHEET",xlsx:"SHEET",csv:"SHEET",ppt:"SLIDES",pptx:"SLIDES",png:"IMAGE",jpg:"IMAGE",jpeg:"IMAGE",webp:"IMAGE",gif:"IMAGE",svg:"IMAGE",mp3:"AUDIO",wav:"AUDIO",m4a:"AUDIO",mp4:"VIDEO",mov:"VIDEO",avi:"VIDEO",js:"CODE",ts:"CODE",tsx:"CODE",jsx:"CODE",py:"CODE",java:"CODE",go:"CODE",rs:"CODE",php:"CODE",html:"CODE",css:"CODE",json:"DATA",xml:"DATA",yaml:"DATA",yml:"DATA",sql:"DATA",sqlite:"DATA",db:"DATA",parquet:"DATA",zip:"ARCHIVE",rar:"ARCHIVE","7z":"ARCHIVE",tar:"ARCHIVE",gz:"ARCHIVE"},Fg=1e5;function am(t){var n=/\.([A-Za-z0-9]+)$/.exec((t||"").toString());return n?n[1].toLowerCase():""}function X2(t){return DT[am(t)]||"FILE"}function ub(t){return!!IT[am(t)]}function q2(t){var n=Number(t)||0;return n>=1024*1024?(n/(1024*1024)).toFixed(1)+"MB":n>=1024?Math.round(n/1024)+"KB":n+"B"}function fb(t){return new Promise(function(n){try{var r=new FileReader;r.onload=function(){n((r.result||"").toString())},r.onerror=function(){n("")},r.readAsText(t)}catch{n("")}})}function pb(t,n){return K2({file:t,sessionId:n||null,product:"xyron_gpt"}).then(function(r){return{fileId:r.file_id,gcsUri:r.gcs_uri,sniffedMime:r.sniffed_mime||t.type||"application/octet-stream",mime:r.sniffed_mime||t.type||"application/octet-stream",uploadState:"ready"}}).catch(function(){return{uploadState:"failed"}})}function gb(t,n){return n.length>1e5?(t.content=n.slice(0,Fg),t.contentTruncated=!0):t.content=n,t.uploadState="ready",t}function $2(t,n){n=n||{};var r=n.sessionId||null,o=!!n.persistToGcs,a=Array.prototype.slice.call(t||[]),l=Date.now();return Promise.all(a.map(function(s,c){var d={id:"pf-"+l+"-"+c,name:s.name,ext:am(s.name),kind:X2(s.name),size:s.size||0,sizeLabel:q2(s.size),source:"upload",addedAt:new Date(l).toISOString(),content:"",contentTruncated:!1,uploadState:"pending"};return ub(s.name)&&!o?fb(s).then(function(p){return gb(d,p)}):ub(s.name)&&o?Promise.all([fb(s),pb(s,r)]).then(function(p){return gb(d,p[0]),Object.assign(d,p[1]),d.uploadState!=="failed"&&(d.uploadState="ready"),d}):pb(s,r).then(function(p){return Object.assign(d,p),d})}))}function OL(t){if(!t)return[];if(t.files&&t.files.length)return Array.prototype.slice.call(t.files);var n=t.items;if(!n||!n.length)return[];for(var r=[],o=0;o<n.length;o++)if(n[o].kind==="file"){var a=n[o].getAsFile&&n[o].getAsFile();a&&r.push(a)}return r}function LL(t){for(var n=Array.prototype.slice.call(t.dataTransfer&&t.dataTransfer.types||[]),r=0;r<n.length;r++)if(String(n[r]).indexOf("application/x-vault-")===0)return!1;return n.indexOf("Files")!==-1}function OT(t){return(t||[]).filter(function(n){return n&&n.fileId&&n.gcsUri&&n.uploadState!=="failed"}).map(function(n){return{fileId:n.fileId,gcsUri:n.gcsUri,sniffedMime:n.sniffedMime||n.mime||"application/octet-stream",mime:n.sniffedMime||n.mime||"application/octet-stream",name:n.name,size:n.size||0,state:"ready"}})}function LT(t,n){var r={},o=[];function a(l){if(l){var s=l.fileId||l.name;!s||r[s]||(r[s]=!0,o.push(l))}}return(t||[]).forEach(a),(n||[]).forEach(a),o}function zT(t,n){var r={},o=[];return(n||[]).concat(t||[]).concat(RS||[]).forEach(function(a){var l=a&&(a.name||a.display_name||a.title)||"",s=a&&(a.id||a.doc_id),c=s?"i
256d:"+s:l;!c||r[c]||l&&r["name:"+l]||(r[c]=!0,l&&(r["name:"+l]=!0),o.push(a))}),o}function MT(t){var n=t.name||t.display_name||t.title||"Vault document",r=(t.content||t.content_preview||t.ai_summary||"").toString(),o=!1;r.length>1e5&&(r=r.slice(0,Fg),o=!0);var a=t.id||t.doc_id||null,l=Number(t.size_bytes||t.size||0)||0;return{id:"vd-"+(a||n).toString().replace(/\s+/g,"-")+"-"+Date.now(),vaultId:a,name:n,ext:am(n),kind:t.type||t.doc_type||X2(n),size:l,sizeLabel:(t.size||"").toString()||(l?String(l):""),source:"vault",addedAt:new Date().toISOString(),content:r,contentTruncated:o,uploadState:r?"ready":"metadata_only"}}function NT(t){return t?!!t.toLowerCase().match(/earlier|today|recent|last time|before|follow.?up|previous|what did|what have|my.?activit|continue|resume|back to|revisit|remind me|this morning|this afternoon|yesterday|what was|where did|status of|update on|progress/):!1}function BT(t){return t?t.replace(/\./g," ").replace(/_/g," "):"action"}function PT(t){if(!NT(t))return"";var n=iA();if(!n||n.length===0)return"";for(var r={},o=[],a=0;a<n.length&&o.length<10;a++){var l=n[a],s=(l.action||"")+"|"+(l.detail||"");r[s]||(r[s]=!0,o.push(l))}return o.length===0?"":`
257
258[RECENT ACTIVITY]
259`+o.map(function(c){var d=c.tsDisplay||c.ts||"";return d.length>16&&(d=d.substring(0,16)),"- "+d+": "+BT(c.action)+(c.detail?" — "+c.detail.substring(0,80):"")}).join(`
260`)}var UT=[{id:"r-09-41",severity:"critical",time:"09:41",category:"RISK · MACRO",headline:"US10Y short · stop at 4.42% · gap 3.8bp",sparkline:[12,18,25,32,42,38,30,24,28],ticker:{symbol:"TY",value:"4.379",delta:"0.04",direction:"down"},wsSymbol:"TNX",impact:{value:"−$2.4M",label:"MV"},confidence:98,aiAction:"CLOSE 30% NOW · trail stop to 4.40% · maintains thesis but de-risks ahead of FOMC",simulated:!0},{id:"r-09-38",severity:"critical",time:"09:38",category:"RISK · FX",headline:"USDJPY · BoJ intervention primed at 155",sparkline:[10,12,18,28,45,52,58,60,56],ticker:{symbol:"JPY",value:"154.87",delta:"0.21",direction:"up"},wsSymbol:"USDJPY",impact:{value:"−$1.1M",label:"FX"},confidence:95,aiAction:"ADD HEDGE · 2bn notional 30d · downside protection if MoF intervenes ≥ 155",simulated:!0},{id:"r-08-54",severity:"critical",time:"08:54",category:"PORTFOLIO RISK",headline:"Liquidity buffer narrowing as volatility rises",sparkline:[50,48,52,60,68,72,76,78,80],ticker:null,impact:{value:"+28%",label:"util"},confidence:97,aiAction:"REVIEW EXPOSURE · prioritise liquid hedges and update forecast assumptions",simulated:!0},{id:"r-08-22",severity:"high",time:"08:22",category:"VAULT INTEL",headline:"New policy memo flagged for source-linked review",countdown:"READY",impact:{value:"3",label:"docs"},sources:["vault","scanner"],aiAction:"OPEN SCANNER · extract obligations, figures, and action items",simulated:!0},{id:"r-07-48",severity:"high",time:"07:48",category:"CALENDAR",headline:"CFO call at 11:00 · draft agenda available",countdown:"T-3h 12m",impact:{value:"4",label:"attendees"},sources:["calendar","docs"],aiAction:"OPEN AGENDA · 3 talking points · prep brief ready in vault",simulated:!0},{id:"r-07-00",severity:"info",time:"07:00",category:"MORNING BRIEF",headline:"12-min read · 4 sources · macro · MKT · web",sources:["vault","4 src"],confidence:96,aiAction:"READ BRIEF · 12 min · highlights: Fed dovish, BoE hold, EM rotation",simulated:!0}],WT=[{id:"r-09-41",sev:"critical",label:"CLOSE 30% US10Y short",sub:"stop hit · trail to 4.40%",headline:"US10Y short · stop at 4.42% · gap 3.8bp",action:"CLOSE 30% NOW · trail stop to 4.40% · maintains thesis but de-risks ahead of FOMC",simulated:!0},{id:"r-09-38",sev:"critical",label:"ADD hedge on USDJPY",sub:"2bn 30d · BoJ at 155",headline:"USDJPY · BoJ intervention primed at 155",action:"ADD HEDGE · 2bn notional 30d · downside protection if MoF intervenes ≥ 155",simulated:!0},{id:"r-08-54",sev:"critical",label:"REVIEW LIQUIDITY",sub:"volatility rising · update assumptions",headline:"Liquidity buffer narrowing as volatility rises",action:"REVIEW EXPOSURE · prioritise liquid hedges and update assumptions",simulated:!0}];function J2(t){return t.map(function(n){return Object.assign({},n,{ticker:n.ticker?Object.assign({},n.ticker):n.ticker,impact:n.impact?Object.assign({},n.impact):n.impact,sparkline:n.sparkline?n.sparkline.slice():n.sparkline,sources:n.sources?n.sources.slice():n.sources})})}function HT(){return su()?J2(UT):[]}function GT(){return su()?J2(WT):[]}function VT(t,n,r){var o=r||1e4,a=new AbortController,l=setTimeout(function(){a.abort()},o),s=Object.assign({},n||{},{signal:a.signal});return fetch(t,s).then(function(c){return clearTimeout(l),c.text().then(function(d){var p=null;try{p=JSON.parse(d)}catch{}return c.ok?{ok:!0,status:c.status,data:p,raw:d}:{ok:!1,status:c.status,error:"HTTP "+c.status+": "+d.substring(0,200),raw:d,data:p}})}).catch(function(c){return clearTimeout(l),c.name==="AbortError"?{ok:!1,status:0,error:"Request timed out after "+o+"ms"}:{ok:!1,status:0,error:c.message||"Network error"}})}function YT(t){if(!t)return null;var n=t.toLowerCase();console.log("[MarketDetect] input:",n.substring(0,80));var r=n.match(/\b(price|quote|live|current|real.time|trading|market data|how much is|what is .{0,20} trading)\b/);if(!r)return console.log("[MarketDetect] no intent match"),null;console.log("[MarketDetect] intent matched:",r[0]);var o=null,a=n.match(/(?:price|quote|data|trading)\s+(?:of|for)\s+([a-z]{1,5}(?:usd)?)/i)||n.match(/\b([a-z]{2,5})\s+(?:price|quote|stock|share)/i)||n.match(/(?:price|quote|data|trading)\s+(?:of|for)\s+(\S+)/i);return a&&(o=a[1].toUpperCase()),o||(a=n.match(/\b(eur|gbp|jpy|aud|cad|chf|nzd)\s*\/?\s*(usd|eur|gbp|jpy)\b/),a&&(o=a[1].toUpperCase()+"/"+a[2].toUpperCase())),o||(n.match(/\bbitcoin\b|\bbtc\b/)?o="BTC/USD":n.match(/\bethereum\b|\beth\b/)?o="ETH/USD":n.match(/\bsolana\b|\bsol\b/)&&(o="SOL/USD")),o||(n.match(/\bgold\b|\bxau\b/)?o="XAU/USD":n.match(/\bsilver\b|\bxag\b/)?o="XAG/USD":n.match(/\boil\b|\bbrent\b|\bwti\b|\bcrude\b/)&&(o="BRENT")),o||(a=n.match(/\b(aapl|msft|nvda|tsla|googl|amzn|meta|nflx|jpm|gs|spy|qqq)\b/i),a&&(o=a[1].toUpperCase())),console.log("[MarketDetect] symbol:",o||"NONE"),o}var mb={quote:!0,search:!1,marketNews:!1,video:!1,image:!1};function KT(t,n){return new Promise(function(r){var o=!1,a=setTimeout(function(){o||(o=!0,r({ok:!1,error:"Timed out after "+n+"ms"}))},n||1e4);t.then(function(l){o||(o=!0,clearTimeout(a),r(l))}).catch(function(l){o||(o=!0,clearTimeout(a),r({ok:!1,error:l&&l.message?l.message:"Provider error"}))})})}function XT(t){var n=t&&t.query||"",r=t&&t.mode||"";if(console.log("[Retrieval] request | mode:",r,"| query:",n.substring(0,60)),console.log("[Retrieval] ENABLED_MODES:",JSON.stringify(mb)),!mb[r])return console.log("[Retrieval] mode DISABLED:",r),Promise.resolve({ok:!1,mode:r,data:null,error:"This capability is not yet enabled in this build."});console.log("[Retrieval] mode ENABLED:",r,"— calling provider");try{var o;switch(r){case"quote":o=e_(n);break;case"search":o=t_(n);break;case"marketNews":o=n_(n);break;case"video":o=r_(n);break;case"image":o=i_(n);break;default:return Promise.resolve({ok:!1,mode:r,data:null,error:"Unknown mode: "+r})}return KT(o,12e3)}catch(a){return console.log("[Retrieval] sync error:",a.message),Promise.resolve({ok:!1,mode:r,data:null,error:a.message})}}function Q2(t){if(!t)return t;var n=t.toUpperCase();return n==="BTC"||n==="BITCOIN"?"BTC/USD":n==="ETH"||n==="ETHEREUM"?"ETH/USD":n==="SOL"||n==="SOLANA"?"SOL/USD":n==="XRP"||n==="RIPPLE"?"XRP/USD":n==="DOGE"||n==="DOGECOIN"?"DOGE/USD":n==="ADA"||n==="CARDANO"?"ADA/USD":n.match(/^(EUR|GBP|JPY|AUD|CAD|CHF|NZD)(USD|EUR|GBP|JPY)$/)?n.substring(0,3)+"/"+n.substring(3):n==="GOLD"||n==="XAU"?"XAU/USD":n==="SILVER"||n==="XAG"?"XAG/USD":n==="OIL"||n==="BRENT"||n==="WTI"||n==="CRUDE"?"BRENT":n}var qT={ES:"ES",NQ:"NQ",YM:"YM",RTY:"RTY",CL:"CL",GC:"GC",SI:"SI",NG:"NG",ZB:"ZB",ZN:"ZN",HG:"HG",ZC:"ZC"},$T={QUOTE:1,PRICE:1,QUOTES:1,PRICES:1,FUTURES:1,FUTURE:1,AND:1,THE:1,FOR:1,NOW:1,LIVE:1,VS:1,ON:1,ME:1,GET:1,SHOW:1,WHAT:1,IS:1,ARE:1,HOW:1,MUCH:1,OF:1,A:1};function JT(t){var n=String(t||"").trim().split(/[\s,]+/).filter(
260Boolean),r=[],o={};return n.forEach(function(a){var l=a.toUpperCase().replace(/[^\w/=.^-]/g,"");if(l){var s=l.replace(/^\//,"");if(!$T[s]){if(s.indexOf("/")!==-1){o[s]||(o[s]=1,r.push(s));return}var c=s.replace(/=F$/,"");if(qT[c]){o[c]||(o[c]=1,r.push(c));return}if(/^[\^]?[A-Z][A-Z.]{0,5}$/.test(s)){var d=Q2(s);o[d]||(o[d]=1,r.push(d))}}}}),r}function QT(t){var n=Object.keys(t||{}),r;return n.indexOf("live")!==-1||n.indexOf("per_call")!==-1?r="Live · direct feed":n.indexOf("delayed")!==-1?r="Delayed feed":n.indexOf("eod")!==-1||n.indexOf("eod_close")!==-1?r="End-of-day":r="Consolidated","`◆ Source: Cortex Alpha-1 · "+r+"`"}function ZT(t,n){var r=n&&n.price!=null?Number(n.price):null;if(r==null)return"| "+t+" | unavailable | — |";var o=n&&n.volume!=null&&Number(n.volume)?String(n.volume):"—",a=n&&n.is_index_proxy?n.proxy_symbol?"proxy ("+n.proxy_symbol+")":"ETF proxy":n&&n.is_stale?"stale":"";return"| "+t+" | "+r.toFixed(2)+" | "+o+(a?" · "+a:"")+" |"}function e_(t){var n=JT(t);if(n.length===0){var r=null;try{r=YT(t)}catch{r=null}r&&(n=[Q2(r)])}return n.length===0?Promise.resolve({ok:!1,mode:"quote",data:null,error:"Could not identify a symbol to quote."}):(console.log("[Quote] multi-symbol via facade:",n.join(",")),wf.quotesFacade(n).then(function(o){var a=o&&o.quotes||{},l=[],s=!1,c={};return n.forEach(function(d){var p=d.toUpperCase(),g=a[p]||a[d]||null;g&&g.available&&g.price!=null&&(s=!0,g.data_mode&&(c[g.data_mode]=1)),l.push(ZT(p,g))}),s?{ok:!0,mode:"quote",data:`**Live Quotes** · Xyron
261
262| Symbol | Price | Volume |
263|---|---:|---|
264`+l.join(`
265`)+`
266
267`+QT(c)}:{ok:!1,mode:"quote",data:null,error:"No live quote resolved for "+n.join(", ")+"."}}).catch(function(o){return console.log("[Quote] facade error:",o&&o.message?o.message:o),{ok:!1,mode:"quote",data:null,error:"Quote fetch failed for "+n.join(", ")}}))}function t_(t){return gA.query(t).then(function(n){if(!n||!n.content)return{ok:!1,mode:"search",data:null,error:"No search results"};var r=`## Search Results
268
269`+n.content;return n.citations&&n.citations.length>0&&(r+=`
270
271**Sources:**
272`,n.citations.forEach(function(o,a){r+="- "+(typeof o=="string"?o:o.url||"Source "+(a+1))+`
273`})),{ok:!0,mode:"search",data:r}}).catch(function(n){return{ok:!1,mode:"search",data:null,error:n&&n.message?n.message:"Search failed"}})}function n_(t){return Promise.resolve({ok:!1,mode:"marketNews",data:null,error:"Market news provider not yet connected."})}function r_(t){return Promise.resolve({ok:!1,mode:"video",data:null,error:"Video provider not yet connected."})}function i_(t){return Promise.resolve({ok:!1,mode:"image",data:null,error:"Image provider not yet connected."})}var o_="rgba(8,11,17,0.97)";function a_(t){if(!t)return!1;var n=String(t).toLowerCase();return n==="application/pdf"||n.indexOf("audio/")===0||n.indexOf("video/")===0||n==="text/plain"||n==="text/markdown"||n==="text/csv"||n.indexOf("text/")===0||n.indexOf("image/")===0}function l_(t){var n=t.attachment||{},r=t.onSaveToVault||null,o=t.onRemove||null,a=t.onPreview||null,l=(0,i.useState)(!1),s=l[0],c=l[1],d=(0,i.useRef)(null);(0,i.useEffect)(function(){if(!s)return;function C(w){d.current&&!d.current.contains(w.target)&&c(!1)}function _(w){w.key==="Escape"&&c(!1)}return document.addEventListener("mousedown",C),document.addEventListener("keydown",_),function(){document.removeEventListener("mousedown",C),document.removeEventListener("keydown",_)}},[s]);var p=n.state==="ready"&&!!n.gcsUri&&!n.savedToVault&&typeof r=="function",g=!!n.isImage&&!!n.content,f=!!n.gcsUri&&a_(n.sniffedMime||n.mime),h=(g||f)&&typeof a=="function",x=typeof o=="function";if(!p&&!h&&!x)return null;function v(C){return function(_){_&&_.stopPropagation&&_.stopPropagation(),c(!1),typeof C=="function"&&C()}}var y={background:"none",border:"none",color:s?I.gold:"#5A7090",cursor:"pointer",fontSize:13,padding:"0 2px",lineHeight:1,position:"relative",fontWeight:700,letterSpacing:"0.05em"},k={position:"absolute",top:"calc(100% + 4px)",right:0,zIndex:200,minWidth:140,background:o_,backdropFilter:"blur(20px) saturate(140%)",WebkitBackdropFilter:"blur(20px) saturate(140%)",border:"1px solid "+I.hairline2,borderTop:"1px solid "+I.gold,borderRadius:3,padding:4,boxShadow:"0 12px 32px rgba(0,0,0,0.6)"},A={display:"block",width:"100%",textAlign:"left",padding:"5px 10px",background:"transparent",border:"none",cursor:"pointer",fontFamily:I.mono,fontSize:10,letterSpacing:"0.18em",color:I.ink2,fontWeight:500,borderRadius:2},j=Object.assign({},A,{color:"#F97583"}),E=Object.assign({},A,{color:I.gold,fontWeight:700});return(0,e.jsxs)("span",{ref:d,style:{position:"relative",display:"inline-flex"},children:[(0,e.jsx)("button",{type:"button",onClick:function(C){C&&C.stopPropagation&&C.stopPropagation(),c(!s)},"aria-haspopup":"menu","aria-expanded":s?"true":"false","aria-label":"Attachment options",title:"Attachment options",style:y,children:"⋯"}),s&&(0,e.jsxs)("div",{role:"menu",style:k,children:[p&&(0,e.jsx)("button",{type:"button",role:"menuitem",onClick:v(r),style:E,children:"SAVE TO VAULT"}),h&&(0,e.jsx)("button",{type:"button",role:"menuitem",onClick:v(a),style:A,children:"PREVIEW"}),x&&(0,e.jsx)("button",{type:"button",role:"menuitem",onClick:v(o),style:j,children:"REMOVE"})]})]})}var s_="rgba(0,0,0,0.85)",dg="#D4AF5C",c_="#E2E8F0",hb="#5A7090";function d_(t){var n=!!t.open,r=t.src||"",o=t.type||"",a=t.name||"preview",l=t.onClose,s=(0,i.useMemo)(function(){return l||function(){}},[l]),c=(0,i.useState)({loading:!1,text:"",error:null}),d=c[0],p=c[1],g=(0,i.useRef)(null);if((0,i.useEffect)(function(){if(!n)return;function j(E){E.key==="Escape"&&s()}return document.addEventListener("keydown",j),function(){document.removeEventListener("keydown",j)}},[n,s]),(0,i.useEffect)(function(){if(!(!n||!r)&&Z2(o)){var j=!1;return p({loading:!0,text:"",error:null}),fetch(r).then(function(E){if(!E.ok)throw new Error("HTTP "+E.status);return E.text()}).then(function(E){j||p({loading:!1,text:E,error:null})}).catch(function(E){j||p({loading:!1,text:"",error:E&&E.message||"Failed to load"})}),function(){j=!0}}},[n,r,o,p]),!n)return null;function f(j){g.current&&j.target===g.current&&s()}var h={position:"fixed",top:0,left:0,right:0,bottom:0,background:s_,zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",padding:24},x={width:"min(900px, 96vw)",height:"min(86vh, 800px)",background:"#0a0e15",border:"1px solid "+dg,borderRadius:6,boxShadow:"0 24px 64px rgba(0,0,0,0.8)",display:"flex",flexDirection:"column",overflow:"hidden"},v={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px",borderBottom:"1px solid rgba(212,175,92,0.25)",background:"rgba(212,175,92,0.05)",flexShrink:0},y={color:dg,fontFamily:"ui-monospace,SFMono-Regular,Menlo,Consolas,monospace",fontSize:11,letterSpacing:"0.18em",fontWeight:700,textTransform:"uppercase",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"70%"},k={background:"none",border:"1px solid rgba(212,175,92,0.45)",color:dg,cursor:"pointer",fontSize:14,padding:"2px 10px",lineHeight:1,borderRadius:3,fontFamily:"ui-monospace,SFMono-Regular,Menlo,Consolas,monospace"},A={flex:1,overflow:"auto",background:"#000",display:"flex",alignItems:"center",justifyContent:"center"};return(0,e.jsx)("div",{ref:g,style:h,onClick:f,role:"dialog","aria-modal":"true","aria-label":"Preview "+a,children:(0,e.jsxs)("div",{style:x,children:[(0,e.jsxs)("div",{style:v,children:[(0,e.jsx)("span",{style:y,title:a,children:a}),(0,e.jsx)("button",{type:"button",onClick:s,"aria-label":"Close preview",title:"Close (Esc)",style:k,children:"×"})]}),(0,e.jsx)("div",{style:A,children:u_(o,r,d)})]})})}function Z2(t){if(!t)return!1;var n=String(t).toLowerCase();return n==="text/plain"||n==="text/markdown"||n==="text/csv"||n.indexOf("text/")===0}function u_(t,n,r){var o=String(t||"").toLowerCase();return o==="application/pdf"?(0,e.jsx)("iframe",{title:"PDF preview",src:n,style:{width:"100%",height:"100%",border:"none",background:"#000"}}):o.indexOf("audio/")===0?(0,e.jsx)("audio",{controls:!0,style:{width:"80%"},src:n,children:"Your browser doesn't support audio playback."}):o.indexOf("video/")===0?(0,e.jsx)("video",{controls:!0,style:{maxWidth:"100%",maxHeight:"100%"},src:n,children:"Your browser doesn't support video playback."}):o.indexOf("image/")===0?(0,e.jsx)("img",{src:n,alt:"preview",style:{maxWidth:"100%",maxHeight:"100%",objectFit:"contain"}}):Z2(o)?r.loading?(0,e.jsx)("span",{style:{color:hb,fontFamily:"monospace",fontSize:11},children:"Loading…"}):r.error?(0,e.jsx)("span",{style:{color:"#F97583",fontFamily:"monospace",fontSize:11},children:r.error}):(0,e.jsx)("pre",{style:{color:c_,fontFamily:"ui-monospace,SFMono-Regular,Menlo,Consolas,monospace",fontSize:11,whiteSpace:"pre-wrap",wordBreak:"break-word",margin:0,padding:16,width:"100%",height:"100%",overflow:"auto",background:"#0a0e15",boxSizing:"border-box"},children:r.text}):(0,e.jsxs)("div",{style:{color:hb,fontFamily:"monospace",fontSize:11,padding:24},children:["Preview not supported for this type (",o||"unknown",").",(0,e.jsx)("br",{}),(0,e.jsx)("a",{href:n,target:"_blank",rel:"noreferrer",style:{color:dg,textDecoration:"underline"},children:"Open in new tab"})]})}function f_(t){if(!t||t.indexOf("<<<CHART>>>")===-1)return null;
273try{var n=t.replace(/\\n/g,`
274`),r=n.indexOf("<<<CHART>>>"),o=n.substring(r+11),a={type:"bar",title:"",xLabel:"",yLabel:"",data:[]},l=o.match(/TYPE:\s*([^\n]+)/);l&&(a.type=l[1].trim().toLowerCase()),l=o.match(/TITLE:\s*([^\n]+)/),l&&(a.title=l[1].trim()),l=o.match(/X_LABEL:\s*([^\n]+)/),l&&(a.xLabel=l[1].trim()),l=o.match(/Y_LABEL:\s*([^\n]+)/),l&&(a.yLabel=l[1].trim());var s=o.indexOf("DATA:");if(s!==-1){var c=o.substring(s+5).trim(),d=c.indexOf("[");if(d!==-1){for(var p=0,g=-1,f=d;f<c.length;f++)if(c[f]==="[")p++;else if(c[f]==="]"&&(p--,p===0)){g=f;break}if(g!==-1){var h=c.substring(d,g+1);try{a.data=JSON.parse(h)}catch{}}}}return a.data&&a.data.length>0?a:null}catch{return null}}function p_(t){if(!t)return t;var n=t.replace(/\\n/g,`
275`),r=n.indexOf("<<<CHART>>>");if(r===-1)return n;var o=n.substring(0,r).trim(),a=n.substring(r),l=a.indexOf("DATA:"),s="";if(l!==-1){var c=a.substring(l+5),d=c.lastIndexOf("]");d!==-1&&(s=c.substring(d+1).trim())}return(o+(s?`
276
277`+s:"")).trim()}var g_=/\b(pie|bar|line|area|scatter|donut|doughnut)[-\s]+(chart|graph|plot)s?\b/i,m_=/\b(chart|graph|plot)\b[^.?!]{0,40}?\bas\s+(?:a\s+)?(pie|bar|line|area|scatter|donut|doughnut)\b/i,h_=/\b(chart|graph|plot)s?\b/i,yb=[/\d+(?:\.\d+)?\s*%/g,/[$€£¥]\s*\d[\d,.]*/g,/\b\d+(?:\.\d+)?\s*(?:k|m|mm|b|bn|t|tn)\b/gi,/\b[\w&/.-]+\s*:\s*[$€£¥]?\d/g],y_=/\b(chart|graph|plot)\s+(this\b|these\b|my\s+data\b|the\s+data\b)/i,x_=/\b(generate|create|make|build|draw|produce|render|design)\b[^.?!\n]{0,60}\b(chart|graph|plot)s?\b/i,v_=/\b(aapl|apple|nvda|nvidia|msft|microsoft|googl|google|amzn|amazon|tsla|tesla|meta|jpm|btc|bitcoin|eth|ethereum|gold|silver|oil|brent|spy|qqq|iwm|dxy|eur|gbp|jpy|usd|gld|spx|ndx|nasdaq|dow|s&p)\b/i;function b_(t){for(var n=0,r=0;r<yb.length;r++){var o=t.match(yb[r]);o&&(n+=o.length)}return n}function xb(t){if(!t||typeof t!="string")return!1;var n=t.trim();return n?!!(g_.test(n)||m_.test(n)||y_.test(n)||h_.test(n)&&b_(n)>=2||x_.test(n)&&!v_.test(n)):!1}var S_=Xg({shell:"xyron"});function O0(t){return String(t||"").replace(/\\/g,"\\\\").replace(/\{/g,"\\{").replace(/\}/g,"\\}")}function E_(t){return String(t||"").split(`
278`).map(function(n){var r=n.match(/^## (.+)$/);if(r)return"\\b "+O0(r[1])+"\\b0";for(var o="",a=0,l=/\*\*([^*]+)\*\*/g,s;s=l.exec(n);)o+=O0(n.slice(a,s.index)),o+="\\b "+O0(s[1])+"\\b0",a=s.index+s[0].length;return o+=O0(n.slice(a)),o}).join("\\par ")}function eE(t,n,r,o){var a=window.open("","_blank");if(a){var l=r?r.name:"Principal",s=o?o.name:"Family Office",c="<!DOCTYPE html><html><head><meta charset=utf-8><title>"+n+"</title><style>";c+="* { box-sizing:border-box; margin:0; padding:0; } body { font-family:Georgia,serif; background:#fff; color:#1a1a1a; }",c+=".cover { page-break-after:always; background:#03050A; color:#E6EDF3; padding:60px 50px; min-height:100vh; display:flex; flex-direction:column; justify-content:space-between; }",c+=".cover-top {}  .logo { font-size:36px; font-weight:900; color:#D4AF5C; letter-spacing:-0.04em; margin-bottom:4px; } .logo-sub { font-family:monospace; font-size:11px; color:#7A8A9E; letter-spacing:0.2em; }",c+=".cover-title { font-size:28px; font-weight:800; line-height:1.2; margin-bottom:12px; max-width:100%; overflow-wrap:anywhere; word-break:break-word; }",c+=".cover-meta { font-family:monospace; font-size:11px; color:#8B949E; }",c+=".cover-bottom { font-family:monospace; font-size:9px; color:#6B7A94; border-top:1px solid #2A3548; padding-top:16px; }",c+=".content { max-width:720px; margin:0 auto; padding:50px 40px; }",c+=".msg { margin-bottom:28px; padding:20px 22px; border-radius:6px; page-break-inside:avoid; }",c+=".user-msg { background:#F8F8F6; border-left:3px solid #D4AF5C; }",c+=".asst-msg { background:#FAFAFA; border-left:3px solid #E8E8E8; }",c+=".role { font-family:monospace; font-size:9px; font-weight:700; letter-spacing:0.14em; color:#999; margin-bottom:8px; display:flex; justify-content:space-between; }",c+=".role .ts { color:#ccc; font-weight:400; }",c+=".body { font-size:13px; line-height:1.75; }",c+=".body strong { color:#1a1a1a; } h1,h2,h3 { font-family:monospace; font-size:11px; letter-spacing:0.12em; text-transform:uppercase; color:#666; margin:16px 0 8px; border-bottom:1px solid #eee; padding-bottom:4px; }",c+=".footer { text-align:center; padding:20px; font-family:monospace; font-size:9px; color:#bbb; border-top:1px solid #eee; margin-top:40px; }",c+="ul { padding-left:18px; margin:8px 0; } li { margin-bottom:4px; }",c+="@media print { .cover { -webkit-print-color-adjust:exact; print-color-adjust:exact; } }",c+="</style></head><body>",c+="<div class='cover'><div class='cover-top'>",c+="<div style='margin-bottom:40px'><div class='logo'>XYRON</div><div class='logo-sub'>INTELLIGENCE TERMINAL</div></div>",c+="<div><div class='cover-title'>"+n+"</div>",c+="<div class='cover-meta' style='margin-bottom:6px'>"+s+" · "+l+" · "+new Date().toLocaleDateString("en-GB",{day:"2-digit",month:"long",year:"numeric"}
278)+"</div>",c+="<div class='cover-meta'>WORKSPACE: "+(o?o.id:"—")+" · ENCRYPTED · ZERO-TRAINING MODE</div></div></div>",c+="<div class='cover-bottom'>CONFIDENTIAL — This document contains privileged information. Not for distribution. Generated by Xyron Intelligence v2.0 · AES-256 Encrypted · "+S_+"</div></div>",c+="<div class='content'>",t.filter(function(d){return!d.streaming}).forEach(function(d){var p=d.role==="user";c+="<div class='msg "+(p?"user-msg":"asst-msg")+"'>",c+="<div class='role'><span>"+(p?l:"XYRON INTELLIGENCE")+"</span><span class='ts'>"+(d.ts||"")+"</span></div>";var g=(d.content||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>").replace(/^## (.+)$/gm,"<h2>$1</h2>").replace(/^### (.+)$/gm,"<h3>$1</h3>").replace(/^- (.+)$/gm,"<li>$1</li>").replace(/\n\n/g,"</p><p>").replace(/\n/g,"<br>");c+="<div class='body'><p>"+g+"</p></div></div>"}),c+="<div class='footer'>XYRON INTELLIGENCE · Confidential · "+s+" · "+new Date().toISOString()+"</div>",c+="</div></body></html>",a.document.write(c),a.document.close(),setTimeout(function(){a.print()},600)}}function k_(t,n,r,o){var a=r?r.name:"Principal",l=o?o.name:"Family Office",s="{\\rtf1\\ansi\\deff0";s+="{\\fonttbl{\\f0\\froman Georgia;}{\\f1\\fmodern Courier New;}}",s+="{\\colortbl;\\red245\\green166\\blue35;\\red139\\green92\\blue246;\\red63\\green185\\blue80;\\red26\\green26\\blue26;\\red100\\green100\\blue100;}",s+="\\paperw12240\\paperh15840\\margl1440\\margr1440\\margt1440\\margb1440",s+="\\pard\\sa200\\f1\\fs18\\cf5 XYRON INTELLIGENCE · CONFIDENTIAL\\par",s+="\\pard\\sa120\\f0\\fs36\\b\\cf4 "+n+"\\b0\\par",s+="\\pard\\sa80\\f1\\fs16\\cf5 "+l+" · "+a+" · "+new Date().toLocaleDateString("en-GB")+"\\par",s+="\\pard\\sa400\\f1\\fs14\\cf5 \\par",t.filter(function(g){return!g.streaming&&g.content}).forEach(function(g){var f=g.role==="user";s+="\\pard\\sa80\\f1\\fs14\\cf"+(f?"1":"3")+"\\b "+(f?a:"XYRON INTELLIGENCE")+(g.ts?" · "+g.ts:"")+"\\b0\\par";var h=E_(g.content);s+="\\pard\\sa120\\f0\\fs22\\cf4 "+h+"\\par\\pard\\sa200\\par"}),s+="}";var c=new Blob([s],{type:"application/rtf"}),d=URL.createObjectURL(c),p=document.createElement("a");p.href=d,p.download=n.replace(/\s+/g,"_").replace(/[^a-zA-Z0-9_]/g,"")+".rtf",document.body.appendChild(p),p.click(),setTimeout(function(){document.body.removeChild(p),URL.revokeObjectURL(d)},1e3)}var ko="monospace",C_=["ALL","AUTH","AI","DATA","EXPORT","NAV","PROFILE","SETTINGS","ADMIN"],vb={AUTH:"#8B7CF6",AI:"#5EEAD4",DATA:"#D4AF5C",EXPORT:"#E07070",NAV:"#5A7090",PROFILE:"#C9A66B",SETTINGS:"#6B9AC4",ADMIN:"#8FA3BF"};function L0(t){var n=(t||"").toLowerCase().split(".")[0];return n==="auth"?"AUTH":n==="query"||n==="chat"?"AI":n==="export"?"EXPORT":n==="nav"?"NAV":n==="profile"?"PROFILE":n==="settings"?"SETTINGS":["project","room","vault","brief","annotation","re","data","doc","import","upload","orderflow"].indexOf(n)!==-1?"DATA":"ADMIN"}function A_(t){var n=(t??"").toString();return/[",\n]/.test(n)?'"'+n.replace(/"/g,'""')+'"':n}function zL(t){var n=t.log,r=!!t.loading,o=(0,i.useMemo)(function(){return n||[]},[n]),a=(0,i.useState)("ALL"),l=a[0],s=a[1],c=(0,i.useState)("ALL"),d=c[0],p=c[1],g=(0,i.useState)(""),f=g[0],h=g[1],x=(0,i.useState)(""),v=x[0],y=x[1],k=(0,i.useState)(""),A=k[0],j=k[1],E=t.currentUser,C=(0,i.useMemo)(function(){return eA(o)},[o]),_=(0,i.useMemo)(function(){var N={};return o.forEach(function(V){var z=Ou(V,E);z&&(N[z]=!0)}),Object.keys(N).sort()},[o,E]),w=(0,i.useMemo)(function(){var N=f.trim().toLowerCase();return o.filter(function(V){return!(l!=="ALL"&&Ou(V,E)!==l||d!=="ALL"&&L0(V.action)!==d||v&&(V.ts||"")<v||A&&(V.ts||"")>A+"T23:59:59.999Z"||N&&[V.action,V.detail,V.resource,V.user,V.workspace,V.model].join(" ").toLowerCase().indexOf(N)===-1)})},[o,l,d,f,v,A,E]),O=(0,i.useMemo)(function(){var N={};return w.forEach(function(V){var z=Ou(V,E)||"UNATTRIBUTED";N[z]=(N[z]||0)+1}),Object.keys(N).map(function(V){return{user:V,n:N[V]}}).sort(function(V,z){return z.n-V.n}).slice(0,5)},[w,E]);function M(){var N=["ts","user","userEmail","workspace","sessionId","deviceId","category","action","resource","detail","model","latency_ms","hash","prevHash"],V=[N.join(",")].concat(w.map(function(W){return N.map(function(R){return A_(R==="category"?L0(W.action):W[R])}).join(",")})),z=new Blob([V.join(`
279`)],{type:"text/csv"}),oe=URL.createObjectURL(z),P=document.createElement("a");P.href=oe,P.download="xyron_audit_trail_"+new Date().toISOString().slice(0,10)+".csv",P.click(),URL.revokeObjectURL(oe),oi({action:"export.audit_csv",detail:w.length+" entries",model:"system"})}function U(){for(var N="AUDIT TRAIL — "+w.length+" entries"+(l!=="ALL"?" · user: "+l:"")+(d!=="ALL"?" · category: "+d:"")+(v||A?" · range: "+(v||"…")+" → "+(A||"…"):"")+`
280Chain integrity: `+(C.ok?"VERIFIED ("+C.checked+" sealed entries)":"TAMPER SUSPECTED at entry "+(C.badIndex+1)),V=w.map(function(P){return(P.tsDisplay||P.ts||"")+" · "+(Ou(P,E)||"")+" @ "+(P.workspace||"")+" · ["+L0(P.action)+"] "+(P.action||"")+(P.resource?" · "+P.resource:"")+(P.detail?" — "+P.detail:"")}),z=[{role:"assistant",content:N}],oe=0;oe<V.length;oe+=40)z.push({role:"assistant",content:V.slice(oe,oe+40).join(`
281`)});eE(z,"Audit Trail",t.currentUser,t.workspace),oi({action:"export.audit_pdf",detail:w.length+" entries",model:"system"})}var ee={background:"#0D1020",border:"1px solid #1E2838",borderRadius:5,padding:"5px 8px",color:"#8FA3BF",fontFamily:ko,fontSize:10,outline:"none"};return(0,e.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",background:"#030609",position:"relative"},children:[r&&o.length===0?(0,e.jsxs)("div",{style:{position:"absolute",inset:0,zIndex:20,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:14,background:"rgba(3,6,9,0.82)",backdropFilter:"blur(2px)"},children:[(0,e.jsx)("div",{style:{width:22,height:22,border:"2px solid rgba(212,175,92,0.25)",borderTop:"2px solid #D4AF5C",borderRadius:"50%",animation:"xspin 0.8s linear infinite"}}),(0,e.jsx)("div",{style:{fontFamily:ko,fontSize:10,letterSpacing:"0.18em",color:"#8FA3BF"},children:"LOADING AUDIT TRAIL…"})]}):null,(0,e.jsxs)("div",{style:{padding:"14px 24px",borderBottom:"1px solid #111820",background:"#05080D",flexShrink:0,display:"flex",alignItems:"center",gap:12,flexWrap:"wrap"},children:[(0,e.jsx)("div",{style:{fontFamily:ko,fontSize:12,color:"#D4AF5C",letterSpacing:".16em",fontWeight:700},children:"AUDIT TRAIL"}),(0,e.jsx)("div",{style:{fontFamily:ko,fontSize:10,color:"#3A4A5E"},children:r&&o.length===0?"LOADING…":r?"REFRESHING…":w.length+" / "+o.length+" ENTRIES"}),(0,e.jsx)("span",{style:{fontFamily:ko,fontSize:9,letterSpacing:".1em",fontWeight:700,padding:"3px 8px",borderRadius:4,color:C.ok?"#3FB950":"#C85C5C",border:"1px solid "+(C.ok?"rgba(63,185,80,0.4)":"rgba(200,92,92,0.5)"),background:C.ok?"rgba(63,185,80,0.06)":"rgba(200,92,92,0.08)"},title:C.ok?C.checked+" sealed entries verified"+(C.legacyTail?" · "+C.legacyTail+" legacy (pre-chain) entries":""):"Hash chain broken at entry "+(C.badIndex+1)+" — local tampering suspected",children:C.ok?"⛓ CHAIN VERIFIED":"⚠ TAMPER SUSPECTED"}),(0,e.jsx)("span",{style:{flex:1}}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[(0,e.jsx)("button",{type:"button",onClick:M,style:{padding:"5px 12px",background:"rgba(212,175,92,0.08)",border:"1px solid rgba(212,175,92,0.3)",borderRadius:5,cursor:"pointer",fontFamily:ko,fontSize:10,color:"#D4AF5C",fontWeight:700},children:"⇩ CSV"}),(0,e.jsx)("button",{type:"button",onClick:U,style:{padding:"5px 12px",background:"rgba(212,175,92,0.08)",border:"1px solid rgba(212,175,92,0.3)",borderRadius:5,cursor:"pointer",fontFamily:ko,fontSize:10,color:"#D4AF5C",fontWeight:700},children:"⇩ PDF"}),typeof t.onMinimize=="function"||typeof t.onClose=="function"?(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,marginLeft:4,background:"rgba(6,8,13,0.95)",border:"0.5px solid #223040",borderRadius:7,padding:"3px",boxShadow:"0 6px 18px rgba(0,0,0,0.55)"},children:[typeof t.onMinimize=="function"?(0,e.jsx)("button",{type:"button",title:"Minimize Audit",onClick:t.onMinimize,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:26,height:22,background:"transparent",border:"none",cursor:"pointer",color:"#A7BCD1",fontSize:18,lineHeight:1,borderRadius:4},onMouseEnter:function(N){N.currentTarget.style.background="rgba(143,163,184,0.14)",N.currentTarget.style.color="#D4AF5C"},onMouseLeave:function(N){N.currentTarget.style.background="transparent",N.currentTarget.style.color="#A7BCD1"},children:"–"}):null,typeof t.onClose=="function"?(0,e.jsx)("button",{type:"button",title:"Close Audit",onClick:t.onClose,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:26,height:22,background:"transparent",border:"none",cursor:"pointer",color:"#B87C7C",fontSize:14,lineHeight:1,borderRadius:4},onMouseEnter:function(N){N.currentTarget.style.background="rgba(184,124,124,0.16)"},onMouseLeave:function(N){N.currentTarget.style.background="transparent"},children:"✕"}):null]}):null]})]}),(0,e.jsxs)("div",{style:{padding:"10px 24px",borderBottom:"1px solid #0C1218",display:"flex",alignItems:"center",gap:8,flexShrink:0,flexWrap:"wrap"}
281,children:[(0,e.jsxs)("select",{value:l,onChange:function(N){s(N.target.value)},style:ee,title:"Filter by employee",children:[(0,e.jsx)("option",{value:"ALL",children:"ALL USERS"}),_.map(function(N){return(0,e.jsx)("option",{value:N,children:N},N)})]}),C_.map(function(N){var V=d===N;return(0,e.jsx)("button",{onClick:function(){p(N)},style:{padding:"4px 9px",background:V?"rgba(212,175,92,0.12)":"transparent",border:"1px solid "+(V?"rgba(212,175,92,0.5)":"#1E2838"),borderRadius:5,cursor:"pointer",fontFamily:ko,fontSize:9,color:V?"#D4AF5C":vb[N]||"#5A7090",fontWeight:700,letterSpacing:".1em"},children:N},N)}),(0,e.jsx)("input",{type:"date",value:v,onChange:function(N){y(N.target.value)},style:Object.assign({},ee,{colorScheme:"dark"}),title:"From date"}),(0,e.jsx)("input",{type:"date",value:A,onChange:function(N){j(N.target.value)},style:Object.assign({},ee,{colorScheme:"dark"}),title:"To date"}),(0,e.jsx)("input",{value:f,placeholder:"⌕ Search actions, details, resources…",onChange:function(N){h(N.target.value)},style:Object.assign({},ee,{flex:1,minWidth:160,fontFamily:"inherit",fontSize:13,color:"#C9D1D9"})})]}),O.length>1&&(0,e.jsxs)("div",{style:{padding:"8px 24px",borderBottom:"1px solid #0C1218",display:"flex",alignItems:"center",gap:10,flexShrink:0,overflowX:"auto"},children:[(0,e.jsx)("span",{style:{fontFamily:ko,fontSize:9,color:"#3A4A5E",letterSpacing:".12em",flexShrink:0},children:"ACTIVITY BY EMPLOYEE"}),O.map(function(N){return(0,e.jsxs)("span",{style:{fontFamily:ko,fontSize:10,color:"#8FA3BF",border:"1px solid #1E2838",borderRadius:4,padding:"3px 8px",flexShrink:0,cursor:"pointer"},onClick:function(){s(N.user===l?"ALL":N.user)},children:[N.user," ·"," ",(0,e.jsx)("span",{style:{color:"#D4AF5C",fontWeight:700},children:N.n})]},N.user)})]}),(0,e.jsxs)("div",{style:{flex:1,overflowY:"auto",padding:"12px 24px"},children:[w.length===0&&(0,e.jsx)("div",{style:{fontFamily:ko,fontSize:12,color:"#3A4A5E",marginTop:40,textAlign:"center"},children:o.length===0?"No audit entries yet.":"No entries match the current filters."}),w.map(function(N,V){var z=L0(N.action);return(0,e.jsxs)("div",{style:{display:"flex",gap:12,padding:"7px 0",borderBottom:"1px solid #0A0F18",alignItems:"baseline"},children:[(0,e.jsx)("div",{style:{fontFamily:ko,fontSize:10,color:"#3A5070",flexShrink:0,minWidth:150},children:N.tsDisplay||N.ts||""}),(0,e.jsx)("div",{style:{fontFamily:ko,fontSize:10,color:"#C9D1D9",flexShrink:0,minWidth:90,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:N.userEmail||Ou(N,E),children:Ou(N,E)||"—"}),(0,e.jsx)("div",{style:{fontFamily:ko,fontSize:9,color:"#5A7090",flexShrink:0,minWidth:72,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:N.workspace||""}),(0,e.jsx)("div",{style:{fontFamily:ko,fontSize:8,color:vb[z]||"#5A7090",flexShrink:0,minWidth:40,fontWeight:700,letterSpacing:".1em"},children:z}),(0,e.jsx)("div",{style:{fontFamily:ko,fontSize:10,color:"#5A7090",flexShrink:0,minWidth:150,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:N.action||""}),N.resource?(0,e.jsx)("div",{style:{fontFamily:ko,fontSize:10,color:"#7A90A8",flexShrink:0,maxWidth:170,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:N.resource}):null,(0,e.jsx)("div",{style:{fontSize:12,color:"#8FA3B8",lineHeight:1.5,flex:1,minWidth:0,overflowWrap:"anywhere"},children:N.detail||""}),N.latency_ms?(0,e.jsxs)("div",{style:{fontFamily:ko,fontSize:9,color:"#3A4A5E",flexShrink:0},children:[N.latency_ms,"ms"]}):null]},N.id||V)})]})]})}var Gu="monospace";function ah(t){return String(t&&(t.id||t.doc_id||t.name||t.display_name||t.title)||"")}function lh(t){return t&&(t.name||t.display_name||t.title)||""}function j_(t){var n=t.type||t.doc_type||"DOC",r=t.size;if(!r&&t.size_bytes){var o=Number(t.size_bytes)||0;o>=1048576?r=(o/1048576).toFixed(1)+" MB":o>=1024?r=Math.round(o/1024)+" KB":o&&(r=o+" B")}var a=t.date||(t.created_at?String(t.created_at).slice(0,10):"");return n+(r?" · "+r:"")+(a?" · "+a:"")+(t.simulated?" · SIMULATED":"")}function w_(t){return Promise.all((t||[]).map(function(n){var r=n&&(n.id||n.doc_id);return!r||n.content||n.content_preview?Promise.resolve(n):gn.get(r).then(function(o){return o?Object.assign({},n,o):n}).catch(function(){return n})}))}function T_(t){var n=t.attachedNames||{},r=t.onAttach||function(){},o=t.onClose||function(){},a=(0,i.useState)(""),l=a[0],s=a[1],c=(0,i.useState)({}),d=c[0],p=c[1],g=(0,i.useState)([]),f=g[0],h=g[1],x=(0,i.useState)("loading"),v=x[0],y=x[1],k=(0,i.useState)(!1),A=k[0],j=k[1];(0,i.useEffect)(function(){var U=!1;return y("loading"),gn.list({limit:200,sort_by:"created_at",sort_dir:"desc"}).then(function(ee){U||(h(ee&&ee.documents||[]),y("ready"))}).catch(function(){U||(h([]),y("error"))}),function(){U=!0}},[]);var E=zT(t.savedDocs,f),C=l.trim().toLowerCase(),_=E.filter(function(U){return C?(lh(U)+" "+(U.type||U.doc_type||"")+" "+(U.tags||[]).join(" ")).toLowerCase().indexOf(C)!==-1:!0}),w=Object.keys(d).filter(function(U){return d[U]}).length;function O(U){var ee=lh(U),N=ah(U);n[ee]||n[N]||p(function(V){var z=Object.assign({},V);return z[N]=!z[N],z})}function M(){var U=_.filter(function(ee){return d[ah(ee)]});if(!U.length){o();return}j(!0),w_(U).then(function(ee){r(ee),o()}).catch(function(){r(U),o()})}return(0,e.jsx)("div",{style:Hi.overlay,onClick:function(U){U.target===U.
281currentTarget&&o()},children:(0,e.jsxs)("div",{style:Hi.sheet,children:[(0,e.jsxs)("div",{style:Hi.head,children:[(0,e.jsx)("div",{style:Hi.title,children:"ATTACH FROM VAULT"}),(0,e.jsx)("button",{onClick:o,style:Hi.x,children:"×"})]}),(0,e.jsx)("div",{style:{padding:"12px 16px 0"},children:(0,e.jsx)("input",{value:l,autoFocus:!0,placeholder:"Search vault documents…",onChange:function(U){s(U.target.value)},style:Hi.search,onFocus:function(U){U.target.style.borderColor="#D4AF5C"},onBlur:function(U){U.target.style.borderColor="#1E2838"}})}),(0,e.jsxs)("div",{style:Hi.list,children:[v==="loading"&&_.length===0&&(0,e.jsx)("div",{style:Hi.empty,children:"Loading vault…"}),v!=="loading"&&_.length===0&&(0,e.jsx)("div",{style:Hi.empty,children:C?"No vault documents match “"+l+"”":v==="error"?"Could not load vault documents":"Vault is empty"}),_.map(function(U){var ee=lh(U),N=ah(U),V=!!n[ee]||!!n[N],z=!!d[N];return(0,e.jsxs)("div",{onClick:function(){O(U)},style:Object.assign({},Hi.row,z?Hi.rowOn:null,V?Hi.rowDone:null),children:[(0,e.jsx)("span",{style:Object.assign({},Hi.check,z?Hi.checkOn:null),children:V||z?"✓":""}),(0,e.jsxs)("span",{style:{flex:1,minWidth:0},children:[(0,e.jsx)("span",{style:Hi.docName,children:ee}),(0,e.jsx)("span",{style:Hi.docMeta,children:j_(U)})]}),V&&(0,e.jsx)("span",{style:Hi.attached,children:"ATTACHED"})]},N||ee)})]}),(0,e.jsxs)("div",{style:Hi.foot,children:[(0,e.jsx)("button",{onClick:o,style:Hi.cancel,children:"CANCEL"}),(0,e.jsx)("button",{onClick:M,disabled:!w||A,style:Object.assign({},Hi.attachBtn,w&&!A?null:Hi.attachOff),children:A?"ATTACHING…":"ATTACH"+(w?" ("+w+")":"")}
281)]})]})})}var Hi={overlay:{position:"fixed",inset:0,zIndex:460,background:"rgba(3,5,8,0.7)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center"},sheet:{width:"min(560px, 94%)",maxHeight:"76vh",display:"flex",flexDirection:"column",background:"rgba(8,11,17,0.96)",border:"1px solid #1E2838",borderTop:"1px solid #9E7E35",borderRadius:4,boxShadow:"0 30px 80px rgba(0,0,0,0.75)",overflow:"hidden"},head:{padding:"14px 16px",borderBottom:"1px solid #111828",display:"flex",alignItems:"center",justifyContent:"space-between",background:"#0A0D18",flexShrink:0},title:{fontFamily:Gu,fontSize:9,color:"#D4AF5C",letterSpacing:".14em",fontWeight:700},x:{background:"none",border:"none",color:"#5A7090",cursor:"pointer",fontSize:16},search:{width:"100%",background:"#0D1020",border:"1px solid #1E2838",borderRadius:6,padding:"8px 10px",color:"#C9D1D9",fontSize:12,outline:"none",boxSizing:"border-box"},list:{flex:1,overflowY:"auto",padding:"10px 16px",minHeight:120},empty:{fontFamily:Gu,fontSize:10,color:"#3A4A5E",letterSpacing:".1em",textAlign:"center",padding:"28px 0"},row:{display:"flex",alignItems:"center",gap:10,padding:"9px 10px",borderRadius:6,border:"1px solid transparent",cursor:"pointer",marginBottom:4},rowOn:{border:"1px solid rgba(212,175,92,0.4)",background:"rgba(212,175,92,0.08)"},rowDone:{opacity:.45,cursor:"default"},check:{width:16,height:16,borderRadius:4,border:"1px solid #2A3A50",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:11,color:"#D4AF5C",flexShrink:0},checkOn:{border:"1px solid #D4AF5C",background:"rgba(212,175,92,0.15)"},docName:{display:"block",fontSize:12,color:"#C9D1D9",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},docMeta:{display:"block",fontFamily:Gu,fontSize:8,color:"#5A7090",letterSpacing:".06em",marginTop:2},attached:{fontFamily:Gu,fontSize:7,color:"#3FB950",letterSpacing:".1em",flexShrink:0},foot:{padding:"12px 16px",borderTop:"1px solid #111828",display:"flex",gap:8,justifyContent:"flex-end",background:"#0A0D18",flexShrink:0},cancel:{padding:"8px 16px",background:"transparent",border:"1px solid #1E2838",borderRadius:6,cursor:"pointer",fontFamily:Gu,fontSize:9,color:"#5A7090"},attachBtn:{padding:"8px 20px",background:"#D4AF5C",border:"none",borderRadius:6,cursor:"pointer",fontFamily:Gu,fontSize:9,color:"#000",fontWeight:700},attachOff:{background:"#141E2A",color:"#3A4A5E",cursor:"not-allowed"}},Ig=[{id:"ACTIVE",label:"ACTIVE",color:"#3FB950"},{id:"ON_HOLD",label:"ON HOLD",color:"#D4AF5C"},{id:"CLOSED",label:"CLOSED",color:"#5A7090"}],Dg=[{id:"HIGH",label:"HIGH",color:"#C85C5C"},{id:"MED",label:"MED",color:"#D4AF5C"},{id:"LOW",label:"LOW",color:"#5A7090"}];function tE(t,n){var r=-1;return t.forEach(function(o,a){o.id===n&&(r=a)}),t[(r+1)%t.length].id}function bb(t){var n=t&&t.status||"ACTIVE";return Ig.find(function(r){return r.id===n})||Ig[0]}function sh(t){var n=t&&t.priority||"MED";return Dg.find(function(r){return r.id===n})||Dg[1]}function ML(t){return tE(Ig,t||"ACTIVE")}function NL(t){return tE(Dg,t||"MED")}function __(t){if(!t||!t.deadline||(t.status||"ACTIVE")==="CLOSED")return!1;try{return new Date(t.deadline+"T23:59:59")<new Date}catch{return!1}}function nE(t){return"xyron_messages_project:"+t}function rE(t){if(!t)return[];try{var n=JSON.parse(localStorage.getItem("xyron_messages_"+t)||"[]");return Array.isArray(n)?n.map(function(r){return{id:r.id||null,role:r.role||"user",content:(r.content||r.text||"").toString(),ts:r.ts||""}}).filter(function(r){return r.content}):[]}catch{return[]}}function R_(t,n){if(n)return rE(n);try{var r=JSON.parse(localStorage.getItem(nE(t))||"[]");return Array.isArray(r)?r.map(function(o){return{id:o.id||null,role:o.role||"user",content:(o.content||o.text||"").toString(),ts:o.ts||""}}).filter(function(o){return o.content}):[]}catch{return[]}}function F_(t){if(!t)return[];var n=Array.isArray(t.sessions)?t.sessions:[];if(!n.length)return R_(t.id);var r=[];return n.forEach(function(o){var a=o&&o.id?o.id:null;rE(a).forEach(function(l){r.push(Object.assign({},l,{conversationId:a,conversationTitle:o&&o.title||"Conversation"}))})}),r}function BL(t){if(!t)return[];var n=t.name||"this project",r=t.knowledgeDocs||[],o=[{text:"Summarise the current state of "+n}];return r.slice(0,3).forEach(function(a){o.push({text:"Summarise the key points of "+a.name})}),r.length>1&&o.push({text:"What conflicts or gaps exist across the project files?"}),o.push({text:"What are the main risks in this project?"}),o.push({text:"List open action items and decisions so far"}),o.push({text:"Generate an investment memo document for "+n}),o.push({text:"Generate a board pack document for "+n}),o.slice(0,9)}var Sb="xyron.rooms.v1",I_="xyron.rooms.active.v1";function D_(t){var n=qg(t);if(!n)return null;try{var r=JSON.parse(localStorage.getItem(Sb)||"[]");Array.isArray(r)||(r=[]);var o=Date.now(),a=r.find(function(s){return s&&s.symbol===n}),l=a?Object.assign({},a,{lastActiveAt:o}):HS(n,o);a?r=r.map(function(s){return s&&s.symbol===n?l:s}):r=r.concat([l]),localStorage.setItem(Sb,JSON.stringify(r)),localStorage.setItem(I_,n)}catch{}return n}function Og(t){return typeof t=="string"&&t.length>0&&t.indexOf("project:")!==0}function iE(t){return Array.isArray(t)?t.filter(function(n){if(!n||typeof n!="object")return!1;var r=n.content!=null?n.content:n.text;return String(r||"").trim().length>0}):[]}function Eb(t,n){if(!t||!n)return[];try{return iE(JSON.parse(t.getItem(n)||"[]"))}catch{return[]}}function PL(t,n,r,o){var a=n&&typeof n=="object"?n:{id:n},l=a&&a.id;if(!t||!t.id||!Og(l))return{migrated:!1,count:0,source:null};var s="project:"+t.id,c=Array.isArray(t.sessions)?t.sessions:[],d=t.activeSessionId===s||c.some(function(A){return A&&A.id===s}),p=c.some(function(A){return A&&Og(A.id)});if(!(o&&o.confirmedFirstDurable===!0)&&(!d||p))return{migrated:!1,count:0,source:"not-legacy"};
281if(Number(a.count||0)>0)return{migrated:!1,count:0,source:"durable-server"};var g=r;if(!g)try{g=localStorage}catch{g=null}if(!g)return{migrated:!1,count:0,source:null};var f="xyron_messages_"+l,h=Eb(g,f);if(h.length)return{migrated:!1,count:h.length,source:"durable-cache"};var x=Eb(g,nE(t.id)),v=iE(t.transcript),y=x.length>=v.length?"legacy-cache":"project-transcript",k=y==="legacy-cache"?x:v;if(!k.length)return{migrated:!1,count:0,source:null};try{return g.setItem(f,JSON.stringify(k)),{migrated:!0,count:k.length,source:y}}catch{return{migrated:!1,count:0,source:null}}}function Lg(t){var n=(Array.isArray(t&&t.sessions)?t.sessions:[]).filter(function(o){return o&&Og(o.id)}),r=t&&t.activeSessionId;return Og(r)||(r=null),r&&n.length&&!n.some(function(o){return o.id===r})&&(r=n[0].id),!r&&n[0]&&(r=n[0].id),{sessions:n,activeSessionId:r||null}}function oE(t,n){var r=Lg(t),o=Lg(n),a={};r.sessions.concat(o.sessions).forEach(function(c){!c||!c.id||(a[c.id]=Object.assign({},a[c.id]||{},c))});var l=Object.keys(a).map(function(c){return a[c]}),s=o.activeSessionId||r.activeSessionId||null;return s&&l.length&&!l.some(function(c){return c.id===s})&&(s=l[0].id),!s&&l[0]&&(s=l[0].id),{sessions:l,activeSessionId:s||null}}function UL(t,n){var r={};return(Array.isArray(t)?t:[]).forEach(function(o){o&&o.id&&(r[o.id]=o)}),(Array.isArray(n)?n:[]).forEach(function(o){if(!(!o||!o.id)){if(!r[o.id]){r[o.id]=o;return}var a=oE(r[o.id],o);r[o.id]=Object.assign({},r[o.id],o,a)}}),Object.keys(r).map(function(o){return r[o]})}function O_(t,n){var r=Array.isArray(t)?t:[],o=Array.isArray(n)?n:[],a={};r.forEach(function(c){c&&c.id&&(a[c.id]=!0)});var l=[],s={};return o.forEach(function(c){!c||!c.id||a[c.id]||s[c.id]||(s[c.id]=!0,l.push(c))}),r.concat(l)}function WL(t,n){var r={};return(Array.isArray(n)?n:[]).forEach(function(o){o&&o.id&&(r[o.id]=o)}),(Array.isArray(t)?t:[]).map(function(o){if(!o||!o.id)return o;var a=r[o.id];if(!a){var l=Lg(o);return Object.assign({},o,{sessions:l.sessions,activeSessionId:l.activeSessionId})}var s=oE(o,a),c=Lg(a),d=c.sessions.length?c.sessions:s.sessions,p=c.activeSessionId||s.activeSessionId;return p&&d.length&&!d.some(function(g){return g.id===p})&&(p=d[0]&&d[0].id),!p&&d[0]&&(p=d[0].id),Object.assign({},o,{sessions:d,activeSessionId:p||null,knowledgeDocs:O_(o.knowledgeDocs,a.knowledgeDocs)})})}function HL(t){var n=t.onClose,r=t.onSave,o=t.savedDocs||[],a=(0,i.useState)(""),l=a[0],s=a[1],c=(0,i.useState)(""),d=c[0],p=c[1],g=(0,i.useState)(""),f=g[0],h=g[1],x=(0,i.useState)("MED"),v=x[0],y=x[1],k=(0,i.useState)(""),A=k[0],j=k[1],E=(0,i.useState)(""),C=E[0],_=E[1],w=(0,i.useState)([]),O=w[0],M=w[1],U=(0,i.useState)(!1),ee=U[0],N=U[1],V=(0,i.useState)(!1),z=V[0],oe=V[1],P=(0,i.useRef)(null),W="monospace",R={};O.forEach(function(te){R[te.name]=!0});function ae(te){M(function(_e){var ve={};return _e.forEach(function(Ne){ve[Ne.name]=!0}),_e.concat(te.filter(function(Ne){return!ve[Ne.name]}))})}function q(te){var _e=te.target.files;!_e||!_e.length||(N(!0),$2(_e).then(function(ve){ae(ve),N(!1)}).catch(function(){N(!1)}),te.target.value="")}function ge(te){M(function(_e){return _e.filter(function(ve){return ve.id!==te})})}function X(){l.trim()&&r({id:"proj-"+Date.now(),name:l.trim(),description:d.trim(),instructions:f.trim(),createdAt:new Date().toISOString(),sessions:[],knowledgeDocs:O,status:"ACTIVE",priority:v,deadline:A||null,tags:C.split(",").map(function(te){return te.trim()}).filter(Boolean),tickers:[]})}var de=function(te){return(0,e.jsx)("div",{style:{fontFamily:W,fontSize:8,color:"#7A90A8",letterSpacing:".1em",marginBottom:6},children:te})},We={width:"100%",background:"#0D1020",border:"1px solid #1E2838",borderRadius:6,padding:"8px 10px",color:"#C9D1D9",fontSize:11,outline:"none",boxSizing:"border-box"};return(0,e.jsxs)("div",{style:{position:"fixed",inset:0,zIndex:400,background:"rgba(3,5,8,0.65)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:function(te){te.target===te.currentTarget&&n()},children:[(0,e.jsxs)("div",{style:{width:560,maxHeight:"88vh",display:"flex",flexDirection:"column",background:"rgba(8,11,17,0.82)",backdropFilter:"blur(24px) saturate(140%)",WebkitBackdropFilter:"blur(24px) saturate(140%)",border:"1px solid #1E2838",borderTop:"1px solid #9E7E35",borderRadius:3,overflow:"hidden",boxShadow:"0 30px 80px rgba(0,0,0,0.75), inset 0 1px 0 rgba(228,194,122,0.05)"},children:[(0,e.jsxs)("div",{style:{padding:"16px 20px",borderBottom:"1px solid #111828",display:"flex",alignItems:"center",justifyContent:"space-between",background:"#0A0
281D18",flexShrink:0},children:[(0,e.jsx)("div",{style:{fontFamily:W,fontSize:9,color:"#D4AF5C",letterSpacing:".14em",fontWeight:700},children:"NEW PROJECT"}),(0,e.jsx)("button",{onClick:n,style:{background:"none",border:"none",color:"#5A7090",cursor:"pointer",fontSize:16},children:"×"})]}),(0,e.jsxs)("div",{style:{padding:"20px",overflowY:"auto"},children:[(0,e.jsxs)("div",{style:{marginBottom:14},children:[de("PROJECT NAME"),(0,e.jsx)("input",{value:l,onChange:function(te){s(te.target.value)},style:We,onFocus:function(te){te.target.style.borderColor="#D4AF5C"},onBlur:function(te){te.target.style.borderColor="#1E2838"}})]}),(0,e.jsxs)("div",{style:{marginBottom:14},children:[de("DESCRIPTION"),(0,e.jsx)("input",{value:d,onChange:function(te){p(te.target.value)},style:We,onFocus:function(te){te.target.style.borderColor="#D4AF5C"},onBlur:function(te){te.target.style.borderColor="#1E2838"}})]}),(0,e.jsxs)("div",{style:{marginBottom:14},children:[de("INSTRUCTIONS"),(0,e.jsx)("textarea",{value:f,onChange:function(te){h(te.target.value)},rows:3,style:Object.assign({},We,{resize:"vertical"}),onFocus:function(te){te.target.style.borderColor="#D4AF5C"},onBlur:function(te){te.target.style.borderColor="#1E2838"}})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:12,marginBottom:14},children:[(0,e.jsxs)("div",{style:{flex:1},children:[de("PRIORITY"),(0,e.jsx)("div",{style:{display:"flex",gap:6},children:Dg.map(function(te){var _e=v===te.id;return(0,e.jsx)("button",{onClick:function(){y(te.id)},style:{padding:"6px 12px",background:_e?"rgba(212,175,92,0.12)":"transparent",border:"1px solid "+(_e?te.color:"#1E2838"),borderRadius:5,cursor:"pointer",fontFamily:W,fontSize:8,color:_e?te.color:"#5A7090",fontWeight:700,letterSpacing:".1em"},children:te.label},te.id)})})]}),(0,e.jsxs)("div",{children:[de("DEADLINE"),(0,e.jsx)("input",{type:"date",value:A,onChange:function(te){j(te.target.value)},style:Object.assign({},We,{width:150,colorScheme:"dark"})})]})]}),(0,e.jsxs)("div",{style:{marginBottom:14},children:[de("TAGS — COMMA-SEPARATED"),(0,e.jsx)("input",{value:C,placeholder:"deal, due-diligence, q3…",onChange:function(te){_(te.target.value)},style:We,onFocus:function(te){te.target.style.borderColor="#D4AF5C"},onBlur:function(te){te.target.style.borderColor="#1E2838"}})]}),(0,e.jsxs)("div",{style:{marginBottom:14},children:[de("KNOWLEDGE BASE — AUTO-AVAILABLE TO PROJECT AI"),(0,e.jsxs)("div",{style:{display:"flex",gap:8,marginBottom:8},children:[(0,e.jsx)("button",{onClick:function(){P.current&&P.current.click()},disabled:ee,style:{padding:"7px 12px",background:"rgba(212,175,92,0.08)",border:"1px solid rgba(212,175,92,0.3)",borderRadius:6,cursor:"pointer",fontFamily:W,fontSize:8,color:"#D4AF5C",fontWeight:700,letterSpacing:".08em"},children:ee?"READING…":"↑ UPLOAD FILES"}),(0,e.jsx)("button",{onClick:function(){oe(!0)},style:{padding:"7px 12px",background:"rgba(212,175,92,0.08)",border:"1px solid rgba(212,175,92,0.3)",borderRadius:6,cursor:"pointer",fontFamily:W,fontSize:8,color:"#D4AF5C",fontWeight:700,letterSpacing:".08em"},children:"◆ ATTACH FROM VAULT"}),(0,e.jsx)("input",{ref:P,type:"file",multiple:!0,accept:FT,style:{display:"none"},onChange:q})]}),O.length===0?(0,e.jsx)("div",{style:{fontFamily:W,fontSize:8,color:"#3A4A5E",letterSpacing:".08em"},children:"Optional — add documents, spreadsheets, code, media or Vault files now, or later from the project workspace."}):(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:O.map(function(te){return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5px 8px",borderRadius:5,border:"1px solid rgba(90,112,144,0.25)",background:"rgba(13,16,32,0.6)"},children:[(0,e.jsx)("span",{style:{fontFamily:W,fontSize:6,color:"#D4AF5C",letterSpacing:".1em",fontWeight:700,flexShrink:0},children:te.source==="vault"?"VAULT":te.kind||"FILE"}),(0,e.jsx)("span",{style:{flex:1,fontSize:11,color:"#8FA3BF",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:te.name}),te.sizeLabel?(0,e.jsx)("span",{style:{fontFamily:W,fontSize:7,color:"#3A4A5E",flexShrink:0},children:te.sizeLabel}):null,(0,e.jsx)("span",{onClick:function(){ge(te.id)},style:{color:"#5A7090",cursor:"pointer",fontSize:13,lineHeight:1,flexShrink:0},children:"×"})]},te.id)})})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:8},children:[(0,e.jsx)("button",{onClick:n,style:{padding:"8px 16px",background:"transparent",border:"1px solid #1E2838",borderRadius:6,cursor:"pointer",fontFamily:W,fontSize:9,color:"#5A7090"},children:"CANCEL"}),(0,e.jsx)("button",{onClick:X,disabled:!l.trim(),style:{padding:"8px 20px",background:l.trim()?"#D4AF5C":"#141E2A",border:"none",borderRadius:6,cursor:l.trim()?"pointer":"not-allowed",fontFamily:W,fontSize:9,color:l.trim()?"#000":"#3A4A5E",fontWeight:700},children:"CREATE PROJECT"})]})]})]}),z?(0,e.jsx)(T_,{savedDocs:o,attachedNames:R,onClose:function(){oe(!1)},onAttach:function(te){ae(te.map(MT))}}):null]})}var kb=60;function Po(t,n){var r=(t||"").toString(),o=r.toLowerCase().indexOf(n.toLowerCase());if(o===-1)return null;var a=Math.max(0,o-kb),l=Math.min(r.length,o+n.length+kb),s=r.slice(a,l).replace(/\s+/g," ").trim();return(a>0?"…":"")+s+(l<r.length?"…":"")}function L_(t,n){var r=(n||"").trim(),o={},a=[];
281return(t||[]).forEach(function(l){if(!r){a.push(l.id);return}var s=[],c=Po([l.name,l.description,l.instructions,(l.tags||[]).join(" ")].filter(Boolean).join(" · "),r);if(c&&s.push({kind:"meta",label:"PROJECT",snippet:c}),(l.knowledgeDocs||[]).forEach(function(f){if(!(s.length>=4)){var h=Po(f.name,r),x=h?null:Po(f.content||"",r);(h||x)&&s.push({kind:"file",label:f.name,snippet:x||h})}}),s.length<4)for(var d=F_(l),p=d.length-1;p>=0&&s.length<4;p--){var g=Po(d[p].content,r);g&&s.push({kind:"chat",label:(d[p].conversationTitle?d[p].conversationTitle+" · ":"")+(d[p].role==="user"?"YOU":"XYRON"),snippet:g})}s.length&&(o[l.id]=s,a.push(l.id))}),{matches:o,ids:a}}function aE(t){return t=t||{},[t.name,t.content,t.kind,t.source,t.sniffedMime||t.mime].filter(Boolean).join(" ")}function z_(t){var n=(t.content||"").toString().replace(/\s+/g," ").trim();return n&&n.indexOf("data:")!==0?n.length>140?n.slice(0,140)+"…":n:t.fileId||t.gcsUri?"Uploaded file — click to view":t.source==="vault"?"Vault attachment — click to view":t.name||"File"}function Cb(t,n){return{id:t.id||t.fileId||t.name,name:t.name,kind:t.kind,source:t.source,snippet:n,fileId:t.fileId||null,gcsUri:t.gcsUri||null,mime:t.sniffedMime||t.mime||"",uploadState:t.uploadState||null,viewable:!!(t.fileId||t.content&&String(t.content).trim())}}function GL(t){if(!t)return{mode:"none"};var n=t.sniffedMime||t.mime||"",r=t.name||"preview";if(t.fileId)return{mode:"gcs",fileId:t.fileId,mime:n,name:r};var o=(t.content||"").toString();return o.trim()?/^(data:|blob:|https?:)/i.test(o)?{mode:"url",src:o,mime:n||"image/png",name:r}:{mode:"text",text:o,mime:n||"text/plain",name:r}:{mode:"none",name:r}}function M_(t){return t=t||{},[t.type,t.value,t.label,t.symbol].filter(Boolean).join(" ")}function VL(t,n,r,o){o=o||{};var a=(r||"").trim(),l=[];(t||[]).forEach(function(h){if(!a){l.push(Cb(h,z_(h)));return}var x=Po(h.name,a),v=Po(h.content||"",a),y=x||v?null:Po(aE(h),a);(x||v||y)&&l.push(Cb(h,v||x||y))}),(o.shots||[]).forEach(function(h){var x=h.label||"Screenshot",v=[x,h.id].filter(Boolean).join(" "),y=a?Po(v,a):"Chart screenshot — click to view";(!a||y)&&l.push({id:h.id||x,name:x,kind:"SHOT",source:"notes",snippet:y||x,fileId:null,gcsUri:null,mime:"image/png",uploadState:null,viewable:!!(h.dataUrl||h.content),content:h.dataUrl||h.content||""})});var s=[];a&&(o.notes||[]).forEach(function(h,x){var v=Po(h.text||"",a);v&&s.push({id:h.id||"note-"+x,ts:h.ts||h.updatedAt||null,snippet:v})});var c=[];a&&(o.alerts||[]).forEach(function(h,x){var v=Po(M_(h),a);v&&c.push({id:h.id||"alert-"+x,snippet:v})});var d=[];if(a)for(var p=n||[],g=p.length-1;g>=0&&d.length<40;g--){var f=Po(p[g].content,a);f&&d.push({id:p[g].id||null,index:g,role:p[g].role,ts:p[g].ts,snippet:f})}return{files:l,messages:d,notes:s,alerts:c}}function YL(t){var n=t.projects,r=(0,i.useMemo)(function(){return n||[]},[n]),o=t.onOpenProject,a=t.onDeleteProject,l=t.onShowCreate,s="monospace",c=(0,i.useState)(""),d=c[0],p=c[1],g=(0,i.useState)("ALL"),f=g[0],h=g[1],x=(0,i.useState)("RECENT"),v=x[0],y=x[1],k=(0,i.useMemo)(function(){return L_(r,d)},[r,d]),A=(0,i.useMemo)(function(){var E={};r.forEach(function(w){E[w.id]=w});var C=k.ids.map(function(w){return E[w]}).filter(Boolean);f!=="ALL"&&(C=C.filter(function(w){return bb(w).id===f}));var _={HIGH:0,MED:1,LOW:2};return C=C.slice(),v==="NAME"?C.sort(function(w,O){return(w.name||"").localeCompare(O.name||"")}):v==="PRIORITY"?C.sort(function(w,O){return _[sh(w).id]-_[sh(O).id]}):v==="DEADLINE"?C.sort(function(w,O){var M=w.deadline||"9999-12-31",U=O.deadline||"9999-12-31";return M<U?-1:M>U?1:0}):C.sort(function(w,O){return(O.createdAt||"").localeCompare(w.createdAt||"")}),C},[r,k,f,v]),j=function(E,C){var _=f===E;return(0,e.jsx)("button",{onClick:function(){h(E)},style:{padding:"4px 10px",background:_?"rgba(212,175,92,0.12)":"transparent",border:"1px solid "+(_?"rgba(212,175,92,0.5)":"#1E2838"),borderRadius:5,cursor:"pointer",fontFamily:s,fontSize:7,color:_?"#D4AF5C":"#5A7090",fontWeight:700,letterSpacing:".1em"},children:C},E)};return(0,e.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",background:"#030609"},children:[(0,e.jsxs)("div",{style:{padding:"14px 24px",borderBottom:"1px solid #111820",background:"#05080D",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0,gap:12},children:[(0,e.jsx)("div",{style:{fontFamily:s,fontSize:9,color:"#D4AF5C",letterSpacing:".16em",fontWeight:700,flexShrink:0},children:"PROJECTS"}),(0,e.jsx)("input",{value:d,placeholder:"⌕  Search projects, files, conversations…",onChange:function(E){p(E.target.value)},style:{flex:1,maxWidth:420,background:"#0D1020",border:"1px solid #1E2838",borderRadius:6,padding:"7px 11px",color:"#C9D1D9",fontSize:11,outline:"none",boxSizing:"border-box"},onFocus:function(E){E.target.style.borderColor="#D4AF5C"},onBlur:function(E){E.target.style.borderColor="#1E2838"}}),(0,e.jsx)("button",{onClick:l,style:{padding:"5px 14px",background:"rgba(212,175,92,0.1)",border:"1px solid rgba(212,175,92,0.3)",borderRadius:6,cursor:"pointer",fontFamily:s,fontSize:8,color:"#D4AF5C",fontWeight:700,flexShrink:0},children:"+ NEW PROJECT"})]}),(0,e.jsxs)("div",{style:{padding:"10px 24px",borderBottom:"1px solid #0C1218",display:"flex",alignItems:"center",gap:6,flexShrink:0,flexWrap:"wrap"},children:[j("ALL","ALL"),Ig.map(function(E){return j(E.id,E.label)}),(0,e.jsx)("span",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontFamily:s,fontSize:7,color:"#3A4A5E",letterSpacing:".1em"},children:"SORT"}),["RECENT","NAME","PRIORITY","DEADLINE"].map(function(E){var C=v===E;return(0,e.jsx)("button",{onClick:function(){y(E)},style:{padding:"4px 8px",background:"transparent",border:"none",cursor:"pointer",fontFamily:s,fontSize:7,color:C?"#D4AF5C":"#5A7090",fontWeight:C?700:400,letterSpacing:".1em",textDecoration:C?"underline":"none"},children:E},E)})]}),(0,e.jsxs)("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px"},children:[r.length===0&&(0,e.jsxs)("div",{style:{textAlign:"center",marginTop:60},children:[(0,e.jsx)("div",{style:{fontSize:32,marginBottom:16,opacity:.3},children:"◇"}
281),(0,e.jsx)("div",{style:{fontFamily:s,fontSize:10,color:"#3A4A5E",letterSpacing:".14em",marginBottom:8},children:"NO PROJECTS YET"}),(0,e.jsx)("div",{style:{fontSize:12,color:"#2A3A50",marginBottom:24},children:"Create a project to organise your intelligence work"}),(0,e.jsx)("button",{onClick:l,style:{padding:"8px 20px",background:"rgba(212,175,92,0.1)",border:"1px solid rgba(212,175,92,0.3)",borderRadius:7,cursor:"pointer",fontFamily:s,fontSize:9,color:"#D4AF5C"},children:"CREATE FIRST PROJECT"})]}),r.length>0&&A.length===0&&(0,e.jsx)("div",{style:{textAlign:"center",marginTop:60,fontFamily:s,fontSize:10,color:"#3A4A5E",letterSpacing:".12em"},children:d.trim()?"NO PROJECTS MATCH “"+d+"”":"NO PROJECTS IN THIS FILTER"}),(0,e.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill,minmax(300px,1fr))",gap:12},children:A.map(function(E){var C=bb(E),_=sh(E),w=__(E),O=k.matches[E.id]||[],M=(E.knowledgeDocs||[]).length;return(0,e.jsxs)("div",{style:{background:"#07090E",border:"1px solid #1E2838",borderRadius:10,padding:"16px 18px",cursor:"pointer",transition:"all .15s"},onClick:function(){o&&o(E)},onMouseEnter:function(U){U.currentTarget.style.borderColor="#D4AF5C40",U.currentTarget.style.background="#0A0D18"},onMouseLeave:function(U){U.currentTarget.style.borderColor="#1E2838",U.currentTarget.style.background="#07090E"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:6},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[(0,e.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:C.color,flexShrink:0},title:C.label}),(0,e.jsx)("div",{style:{fontWeight:700,fontSize:14,color:"#C9D1D9",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:E.name})]}),(0,e.jsx)("button",{onClick:function(U){U.stopPropagation(),a&&a(E.id)},style:{background:"none",border:"none",color:"#3A4A5E",cursor:"pointer",fontSize:14,padding:"0 2px",flexShrink:0},onMouseEnter:function(U){U.currentTarget.style.color="#C85C5C"},onMouseLeave:function(U){U.currentTarget.style.color="#3A4A5E"},children:"×"})]}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8,flexWrap:"wrap"},children:[(0,e.jsx)("span",{style:{fontFamily:s,fontSize:6,color:C.color,letterSpacing:".12em",fontWeight:700},children:C.label}),(0,e.jsx)("span",{style:{fontFamily:s,fontSize:6,color:_.color,letterSpacing:".12em",fontWeight:700},children:_.label}),E.deadline&&(0,e.jsx)("span",{style:{fontFamily:s,fontSize:6,color:w?"#C85C5C":"#5A7090",letterSpacing:".08em",fontWeight:w?700:400},children:(w?"OVERDUE ":"DUE ")+E.deadline}),(E.tags||[]).slice(0,3).map(function(U){return(0,e.jsx)("span",{style:{fontFamily:s,fontSize:6,color:"#7A90A8",letterSpacing:".08em",border:"1px solid #1E2838",borderRadius:3,padding:"1px 5px"},children:U},U)})]}),E.description&&(0,e.jsx)("div",{style:{fontSize:11,color:"#5A7090",lineHeight:1.5,marginBottom:8},children:E.description}),O.length>0&&(0,e.jsx)("div",{style:{marginBottom:8},children:O.slice(0,3).map(function(U,ee){return(0,e.jsxs)("div",{style:{fontSize:10,color:"#8FA3BF",lineHeight:1.5,padding:"3px 8px",background:"rgba(212,175,92,0.04)",borderLeft:"2px solid rgba(212,175,92,0.35)",borderRadius:3,marginBottom:3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[(0,e.jsx)("span",{style:{fontFamily:s,fontSize:6,color:"#D4AF5C",letterSpacing:".08em",marginRight:6},children:U.kind==="file"?"FILE":U.kind==="chat"?"CHAT":"META"}),U.snippet]},ee)})}),(0,e.jsxs)("div",{style:{fontFamily:s,fontSize:7,color:"#3A4A5E",letterSpacing:".08em"},children:[M," FILE",M===1?"":"S"," ·"," ",(E.sessions||[]).length," SESSIONS ·"," ",E.createdAt?E.createdAt.slice(0,10):""]})]},E.id)})})]})]})}var lE="xyron:rooms-workspace",$y="xyron.rooms.v1",zg="xyron.rooms.active.v1",Mg="xyron.rooms.extras.v1",Ng="xyron.rooms.desks.v1",Bg="xyron_room_windows_v1",py="xyron.rooms.workspace.owner",Gp="xyron_messages_room:",np=null,ru=null,N_=24,B_=200,Ab=16e3;function ug(){return{rooms:[],active:null,extras:{},desks:[],windows:{},transcripts:{}}}function $p(){try{return!!localStorage.getItem("xyron_jwt_token")}catch{return!1}}function sE(){try{return El()||""}catch{return""}}function P_(){try{return localStorage.getItem(py)||""}catch{return""}}function U_(t){try{t?localStorage.setItem(py,t):localStorage.removeItem(py)}catch{}}function ec(t,n){try{var r=localStorage.getItem(t);return r==null||r===""?n:JSON.parse(r)}catch{return n}}function rp(t,n){try{localStorage.setItem(t,JSON.stringify(n))}catch{}}function cE(t){return!t||typeof t!="object"||Array.isArray(t)||!Object.keys(t).length}function jb(t){return!Array.isArray(t)||!t.length}function Jy(t){if(!Array.isArray(t))return[];var n={},r=[];
281return t.forEach(function(o){if(!(!o||!o.symbol)){var a=qg(o.symbol);if(!(!a||n[a])){n[a]=!0;var l=HS(a,typeof o.openedAt=="number"?o.openedAt:Date.now());o.assetClass&&(l.assetClass=String(o.assetClass).slice(0,24)),o.displayName&&(l.displayName=String(o.displayName).slice(0,48)),typeof o.lastActiveAt=="number"&&(l.lastActiveAt=o.lastActiveAt),typeof o.openedAt=="number"&&(l.openedAt=o.openedAt),r.push(l)}}}),r.slice(0,N_)}function Qy(t,n){var r=qg(n||"");return r&&t.some(function(o){return o.symbol===r})?r:t.length?t[t.length-1].symbol:null}function gy(t){return Array.isArray(t)?t.slice(-B_).map(function(n){if(!n||typeof n!="object")return n;var r=Object.assign({},n);return r.content&&(r.content=String(r.content).slice(0,Ab)),r.text&&(r.text=String(r.text).slice(0,Ab)),r}):[]}function dE(t){if(!t||typeof t!="object")return{};var n={};return Object.keys(t).forEach(function(r){var o=t[r];if(!(!o||typeof o!="object")){var a=Array.isArray(o.shots)?o.shots.map(function(l){if(!l||typeof l!="object")return l;var s=Object.assign({},l);return delete s.dataUrl,s}):[];n[r]=Object.assign({},o,{shots:a})}}),n}function W_(){var t={};try{var n=localStorage.length;if(typeof n!="number"||typeof localStorage.key!="function")return t;for(var r=0;r<n;r++){var o=localStorage.key(r);if(!(!o||o.indexOf(Gp)!==0)){var a=qg(o.slice(Gp.length));if(a){var l=gy(ec(o,[]));l.length&&(t[a]=l)}}}}catch{}return t}function H_(){try{localStorage.removeItem($y),localStorage.removeItem(zg),localStorage.removeItem(Mg),localStorage.removeItem(Ng),localStorage.removeItem(Bg);var t=[],n=localStorage.length;if(typeof n=="number"&&typeof localStorage.key=="function")for(var r=0;r<n;r++){var o=localStorage.key(r);o&&o.indexOf(Gp)===0&&t.push(o)}t.forEach(function(a){localStorage.removeItem(a)})}catch{}}function Np(){var t=Jy(ec($y,[])),n="";try{n=localStorage.getItem(zg)||""}catch{n=""}var r=ec(Mg,{});(!r||typeof r!="object")&&(r={});var o=ec(Ng,[]);Array.isArray(o)||(o=[]);var a=ec(Bg,{});return(!a||typeof a!="object")&&(a={}),{rooms:t,active:Qy(t,n),extras:r,desks:o,windows:dE(a),transcripts:W_()}}function wb(t){return t?!!(t.rooms&&t.rooms.length||t.active||t.desks&&t.desks.length||t.extras&&Object.keys(t.extras).length||t.windows&&Object.keys(t.windows).length||t.transcripts&&Object.keys(t.transcripts).length):!1}function G_(t,n){var r={};(n||[]).forEach(function(l){l&&l.id&&(r[l.id]=l)});var o={},a=[];return(t||[]).forEach(function(l){if(l){l.id&&(o[l.id]=!0);var s=l.id?r[l.id]:null,c=Object.assign({},l);s&&(s.content&&(!l.content||String(s.content).length>String(l.content||"").length)&&(c.content=s.content),s.fileId&&!c.fileId&&(c.fileId=s.fileId),s.gcsUri&&!c.gcsUri&&(c.gcsUri=s.gcsUri),s.sniffedMime&&!c.sniffedMime&&(c.sniffedMime=s.sniffedMime),s.mime&&!c.mime&&(c.mime=s.mime),s.uploadState&&!c.uploadState&&(c.uploadState=s.uploadState)),a.push(c)}}),(n||[]).forEach(function(l){l&&l.id&&!o[l.id]&&a.push(l)}),a}function V_(t,n){var r={};(n||[]).forEach(function(l){l&&l.id&&(r[l.id]=l)});var o={},a=[];return(t||[]).forEach(function(l){if(l){l.id&&(o[l.id]=!0);var s=l.id?r[l.id]:null,c=Object.assign({},l);s&&(s.fileId&&!c.fileId&&(c.fileId=s.fileId),s.gcsUri&&!c.gcsUri&&(c.gcsUri=s.gcsUri),s.sniffedMime&&!c.sniffedMime&&(c.sniffedMime=s.sniffedMime),s.uploadState&&!c.uploadState&&(c.uploadState=s.uploadState)),delete c.dataUrl,a.push(c)}}),(n||[]).forEach(function(l){if(l&&l.id&&!o[l.id]){var s=Object.assign({},l);delete s.dataUrl,a.push(s)}}),a}function Y_(t,n){var r=n&&typeof n=="object"&&!Array.isArray(n)?n:{},o=t&&typeof t=="object"&&!Array.isArray(t)?t:{};if(cE(o))return r;var a=Object.assign({},r);return Object.keys(o).forEach(function(l){var s=o[l]||{},c=r[l]||{};a[l]={knowledgeDocs:G_(Array.isArray(s.knowledgeDocs)?s.knowledgeDocs:[],c.knowledgeDocs),notes:Array.isArray(s.notes)&&s.notes.length?s.notes:Array.isArray(c.notes)?c.notes:[],alerts:Array.isArray(s.alerts)&&s.alerts.length?s.alerts:Array.isArray(c.alerts)?c.alerts:[]}}),a}function K_(t,n){if(jb(t))return Array.isArray(n)?n:[];if(jb(n))return t.slice();var r={},o=[];function a(l){!l||!l.id||r[l.id]||(r[l.id]=!0,o.push(l))}
281return t.forEach(a),n.forEach(a),o.slice(0,20)}function X_(t,n){var r=n&&typeof n=="object"&&!Array.isArray(n)?n:{},o=t&&typeof t=="object"&&!Array.isArray(t)?t:{};if(cE(o))return r;var a=Object.assign({},r);return Object.keys(o).forEach(function(l){var s=o[l]||{},c=r[l]||{};a[l]=Object.assign({},s,{shots:V_(s.shots,c.shots)})}),a}function ch(t){var n=Object.assign(ug(),t||{});n.rooms=Jy(n.rooms||[]),n.active=Qy(n.rooms,n.active||"");var r=ec(Mg,{}),o=ec(Bg,{}),a=ec(Ng,[]);n.extras=Y_(n.extras,r),n.windows=X_(n.windows,o),n.desks=K_(n.desks,a),rp($y,n.rooms);try{n.active?localStorage.setItem(zg,n.active):localStorage.removeItem(zg)}catch{}rp(Mg,n.extras||{}),rp(Ng,Array.isArray(n.desks)?n.desks:[]),rp(Bg,n.windows||{});var l=n.transcripts&&typeof n.transcripts=="object"?n.transcripts:{};Object.keys(l).forEach(function(c){var d=gy(l[c]),p=gy(ec(Gp+c,[]));p.length>d.length&&(d=p),rp(Gp+c,d)});var s=sE();$p()&&s&&s!=="anonymous"&&U_(s);try{window.dispatchEvent(new Event(lE))}catch{}return n}function Zy(t){return MS.put({rooms:t.rooms,active:t.active,extras:t.extras,desks:t.desks,windows:dE(t.windows),transcripts:t.transcripts})}function Tb(){if(!$p())return!1;var t=sE(),n=P_();return!n||!t||t==="anonymous"?!1:n!==t}function KL(){return np||($p()?(np=MS.get().then(function(t){var n=Object.assign(ug(),t||{});n.rooms=Jy(n.rooms||[]),n.active=Qy(n.rooms,n.active||"");var r=Tb();if(r&&H_(),!wb(n)){var o=r?ug():Np();return wb(o)?Zy(o).then(function(a){return ch(a||o)}).catch(function(){return o}):(ch(n),n)}return ch(n)}).catch(function(){return Tb()?ug():Np()}).finally(function(){np=null}),np):Promise.resolve(Np()))}function ex(){$p()&&(ru&&clearTimeout(ru),ru=setTimeout(function(){ru=null,Zy(Np()).catch(function(){})},400))}function uE(){ru&&(clearTimeout(ru),ru=null,$p()&&Zy(Np()).catch(function(){}))}typeof document<"u"&&document.addEventListener&&document.addEventListener("visibilitychange",function(){document.visibilityState==="hidden"&&uE()});var fE="xyron.rooms.extras.v1",tx="xyron.rooms.desks.v1",q_="xyron.rooms.v1",lm={knowledgeDocs:[],notes:[],alerts:[]};function nx(){try{var t=JSON.parse(localStorage.getItem(fE)||"{}");return t&&typeof t=="object"?t:{}}catch{return{}}}function ac(t){if(!t)return Object.assign({},lm);var n=nx()[t]||{};return{knowledgeDocs:Array.isArray(n.knowledgeDocs)?n.knowledgeDocs:[],notes:Array.isArray(n.notes)?n.notes:[],alerts:Array.isArray(n.alerts)?n.alerts:[]}}function rx(t,n){if(!t)return Object.assign({},lm);var r=nx(),o=Object.assign({},ac(t),n||{});r[t]=o;try{localStorage.setItem(fE,JSON.stringify(r))}catch{}ex(),uE();try{window.dispatchEvent(new CustomEvent(lE))}catch{}return o}function XL(t){return t=t||{},t.type==="above"?"PRICE ≥ "+t.value:t.type==="below"?"PRICE ≤ "+t.value:"DAY MOVE ±"+t.value+"%"}function qL(t){var n=String(t??"").replace(/,/g,"");n=n.replace(/[^0-9.-]/g,"");var r=n.charAt(0)==="-";n=n.replace(/-/g,"");var o=n.split(".");return o.length>2?n=o[0]+"."+o.slice(1).join(""):n=o.join("."),r&&(n="-"+n),n}function $_(t,n){var r=String(t||"");if(r.indexOf("room-id:")===0){var o=r.slice(8),a=(n||[]).find(function(l){return l&&String(l.id)===o});return{extrasKey:r,roomId:o,symbol:a&&a.symbol?String(a.symbol):o}}return{extrasKey:r,roomId:null,symbol:r}}function $L(t){var n=nx(),r=[];return Object.keys(n).forEach(function(o){var a=ac(o),l=$_(o,t);a.alerts.forEach(function(s){s&&r.push({extrasKey:l.extrasKey,roomId:l.roomId,symbol:l.symbol,id:s.id,type:s.type,value:s.value,triggeredAt:s.triggeredAt||null,triggeredPrice:s.triggeredPrice!=null?s.triggeredPrice:null})})}),r.sort(function(o,a){if(!!o.triggeredAt!=!!a.triggeredAt)return o.triggeredAt?-1:1;var l=o.triggeredAt||"",s=a.triggeredAt||"";return l!==s?s<l?-1:1:String(o.symbol).localeCompare(String(a.symbol))}),r}function JL(t,n){return rx(t,{alerts:ac(t).alerts.filter(function(r){return r&&r.id!==n})})}function QL(t,n,r){return r=r||{},t?$2(n,{sessionId:r.sessionId||null,persistToGcs:!0}).then(function(o){var a=ac(t),l={};a.knowledgeDocs.forEach(function(c){l[c.name]=!0});var s=(o||[]).filter(function(c){return c&&c.name&&!l[c.name]});return s.length?{extras:rx(t,{knowledgeDocs:a.knowledgeDocs.concat(s)}),added:s}:{extras:a,added:[]}}):Promise.resolve({extras:Object.assign({},lm),added:[]})}function ZL(t,n){if(!t)return{extras:Object.assign({},lm),added:[]};var r=ac(t),o={};r.knowledgeDocs.forEach(function(l){o[l.name]=!0});var a=(n||[]).filter(function(l){return l&&l.name&&!o[l.name]});return a.length?{extras:rx(t,{knowledgeDocs:r.knowledgeDocs.concat(a)}),added:a}:{extras:r,added:[]}}function pE(){try{var t=JSON.parse(localStorage.getItem(tx)||"[]");return Array.isArray(t)?t.filter(function(n){return n&&n.id&&Array.isArray(n.symbols)}):[]}catch{return[]}}function ez(t,n){var r=(t||"").trim();if(!r||!n||!n.length)return null;var o=pE().filter(function(l){return l.name!==r}),a={id:"desk-"+Date.now(),name:r,symbols:n.slice(0,12),createdAt:new Date().toISOString()};o.unshift(a);try{localStorage.setItem(tx,JSON.stringify(o.slice(0,20)))}catch{}return ex(),a}function tz(t){var n=pE().filter(function(r){return r.id!==t});try{localStorage.setItem(tx,JSON.stringify(n))}catch{}return ex(),n}function gE(t){return hE("xyron_messages_room:"+t)}function mE(t){return hE("xyron_messages_"+t)}function hE(t){try{var n=JSON.parse(localStorage.getItem(t)||"[]");return Array.isArray(n)?n.map(function(r){return{id:r.id||null,role:r.role||"user",content:(r.content||r.text||"").toString(),ts:r.ts||""}}).filter(function(r){return r.content}):[]}catch{return[]}}function ix(){try{var t=JSON.parse(localStorage.getItem(q_)||"[]");return Array.isArray(t)?t.map(function(n){return n&&n.symbol}
281).filter(Boolean):[]}catch{return[]}}function J_(t){return Array.isArray(t)?t.filter(function(n){return n&&n.id&&n.symbol}).map(function(n){return{roomId:String(n.id),symbol:String(n.symbol),extrasKey:"room-id:"+String(n.id),chatSessionId:n.chatSessionId||null}}):ix().map(function(n){return{roomId:null,symbol:n,extrasKey:n,chatSessionId:null}})}var ip=4;function nz(t,n){var r=(t||"").trim();if(r.length<2)return[];var o=[];return J_(n).slice(0,20).forEach(function(a){var l=a.symbol,s=[],c=ac(a.extrasKey);if(c.knowledgeDocs.forEach(function(f){if(!(s.length>=ip)){var h=Po(f.name,r)||Po(f.content||"",r)||Po(aE(f),r);h&&s.push({kind:"file",label:f.name,snippet:h,fileId:f.fileId||null})}}),c.notes.forEach(function(f){if(!(s.length>=ip)){var h=Po(f.text||"",r);h&&s.push({kind:"note",label:"NOTE",snippet:h})}}),c.alerts.forEach(function(f){if(!(s.length>=ip)){var h=Po([f.type,f.value,f.label].filter(Boolean).join(" "),r);h&&s.push({kind:"alert",label:"ALERT",snippet:h})}}),s.length<ip)for(var d=a.chatSessionId?mE(a.chatSessionId):gE(l),p=d.length-1;p>=0&&s.length<ip;p--){var g=Po(d[p].content,r);g&&s.push({kind:"chat",label:d[p].role==="user"?"YOU":"XYRON",snippet:g})}s.length&&o.push({roomId:a.roomId,symbol:l,hits:s})}),o}var Q_=2500,Z_=1e4;function rz(t){var n=ac(t),r={};if(n.knowledgeDocs.length){var o=0;r.knowledge_docs=n.knowledgeDocs.map(function(a){var l=(a.content||"").toString();if(!l)l="(binary/non-text — filename + metadata only)";else{var s=Math.min(Q_,Math.max(0,Z_-o));l.length>s&&(l=l.slice(0,s)+"…(truncated)"),o+=l.length}return{name:a.name,kind:a.kind||"FILE",source:a.source||"upload",excerpt:l,fileId:a.fileId||null,gcsUri:a.gcsUri||null,uploadState:a.uploadState||null,sniffedMime:a.sniffedMime||a.mime||null,size:a.size||0}})}return n.notes.length&&(r.analyst_notes=n.notes.map(function(a){return(a.ts?a.ts.slice(0,10)+" — ":"")+(a.text||"")})),r}function iz(t,n,r,o){var a=n||{},l=a.quote||{},s=a.signals||{},c=["ROOM DOSSIER — "+t];l.price!=null&&c.push("Last: "+l.price+(l.day_change_pct!=null?" ("+(l.day_change_pct>=0?"+":"")+l.day_change_pct+"%)":"")+(l.data_mode?" · "+l.data_mode:"")),s.consensus&&c.push("Signals: "+s.consensus+(s.target?" · target "+s.target:""));var d=Array.isArray(a.news)?a.news.slice(0,5):[];d.length&&c.push("News: "+d.map(function(f){return f.title}).filter(Boolean).join(" | "));var p=Array.isArray(a.intel)?a.intel.slice(0,3):[];p.length&&c.push("Intel: "+p.map(function(f){return f.title}).filter(Boolean).join(" | "));var g=r||ac(t);return g.knowledgeDocs.length&&c.push("Attached files ("+g.knowledgeDocs.length+"): "+g.knowledgeDocs.map(function(f){return f.name}).join(", ")),g.notes.length&&c.push(`Analyst notes:
282`+g.notes.map(function(f){return"- "+(f.ts?f.ts.slice(0,10)+" — ":"")+f.text}).join(`
283`)),[{role:"assistant",content:c.join(`
284`)}].concat((o?mE(o):gE(t)).map(function(f){return{role:f.role,content:f.content}}))}function oz(t){return(t||[]).map(function(n){return(n.role==="user"?"USER: ":"XYRON: ")+(n.content||"")}).join(`
285
286`)}function az(t,n,r){n=(n||"").toString();var o=n.length>Fg,a=o?n.slice(0,Fg):n,l=r instanceof Date?r:new Date,s=l.toISOString(),c=(t||"ROOM").toString();return{id:"rd-"+c+"-"+l.getTime(),name:"Room dossier — "+c+" "+s.slice(0,10),ext:"txt",kind:"DOSSIER",size:a.length,sizeLabel:q2(a.length),source:"room",addedAt:s,content:a,contentTruncated:o,uploadState:"ready",mime:"text/plain",sniffedMime:"text/plain"}}var _b={morning:["Executive Summary","Markets & Rooms","Portfolio","Risk & Alerts","Calendar & Actions"],eod:["Executive Summary","Session Recap","Portfolio","Risk & Alerts","Tomorrow Watch List"],risk:["Executive Summary","Concentration & Exposure","Alert Rules & Triggers","Liquidity & Volatility","Recommended Mitigations"],macro:["Executive Summary","Macro Calendar","Market Signals","Positioning Implications"],board:["Executive Summary","NAV & Portfolio","Risk Matrix","Projects & Workstreams","Compliance & Audit","Strategic Priorities"],esg:["Executive Summary","Compliance Activity","Sanctions & Screening","ESG Exposure","Open Items"]},Rb={morning:"morning",eod:"close",macro:"session"};function fg(t,n){return Promise.race([t,new Promise(function(r){setTimeout(function(){r(null)},n)})])}function dh(t){var n=Number(t);
286return isFinite(n)?n.toLocaleString():String(t)}async function e4(t,n){var r=n||{},o=[],a=[],l=r.positions||[];l.length?(a.push("PORTFOLIO"),o.push("PORTFOLIO POSITIONS ("+l.length+`):
287`+l.slice(0,30).map(function(E){return"- "+(E.symbol||E.ticker||"?")+(E.qty!=null?" qty "+dh(E.qty):"")+(E.value!=null?" value "+dh(E.value):"")+(E.weight_pct!=null?" weight "+E.weight_pct+"%":"")+(E.pnl!=null?" pnl "+dh(E.pnl):"")}).join(`
288`))):o.push("PORTFOLIO POSITIONS: none connected.");var s=ix().slice(0,6);if(s.length){var c=await Promise.all(s.map(function(E){return fg(wf.quote(E).then(function(C){return{sym:E,q:C}}).catch(function(){return null}),3500)})),d=[];c.filter(Boolean).forEach(function(E){var C=E.q||{},_=C.price!=null?C.price:C.last,w=C.day_change_pct!=null?C.day_change_pct:C.change_pct;(_!=null||w!=null)&&d.push("- "+E.sym+(_!=null?" last "+_:"")+(w!=null?" ("+(w>=0?"+":"")+w+"% day)":""))}),d.length?(a.push("LIVE QUOTES"),o.push(`OPEN MARKET ROOMS — LIVE QUOTES:
289`+d.join(`
290`))):o.push("OPEN MARKET ROOMS: "+s.join(", ")+" (live quotes unavailable right now).");var p=[],g=[];s.forEach(function(E){var C=ac(E);C.notes.slice(0,3).forEach(function(_){p.push("- ["+E+"] "+(_.ts?_.ts.slice(0,10)+" — ":"")+_.text)}),C.alerts.forEach(function(_){g.push("- ["+E+"] "+(_.type==="pct"?"±"+_.value+"% day move":(_.type==="above"?"≥ ":"≤ ")+_.value)+(_.triggeredAt?" TRIGGERED "+_.triggeredAt.slice(0,16):" armed"))})}),p.length&&(a.push("ANALYST NOTES"),o.push(`ANALYST NOTES (room workbench):
291`+p.join(`
292`))),g.length&&(a.push("ROOM ALERTS"),o.push(`ROOM PRICE ALERTS:
293`+g.join(`
294`)))}var f=r.alerts||[];f.length&&(a.push("ALERTS"),o.push("PLATFORM ALERTS ("+f.length+`):
295`+f.slice(0,10).map(function(E){return"- "+(E.label||E.title||E.msg||E.condition||JSON.stringify(E).slice(0,100))}).join(`
296`)));var h=r.projects||[];h.length&&(a.push("PROJECTS"),o.push("PROJECTS ("+h.length+`):
297`+h.slice(0,12).map(function(E){return"- "+E.name+" ["+(E.status||"ACTIVE")+", "+(E.priority||"MED")+"]"+(E.deadline?" due "+E.deadline:"")+(" · "+(E.knowledgeDocs||[]).length+" files")}).join(`
298`)));var x=r.savedDocs||[];if(x.length&&(a.push("VAULT"),o.push("VAULT DOCUMENTS ("+x.length+`):
299`+x.slice(0,15).map(function(E){return"- "+(E.name||E.title||"doc")+(E.type?" ["+E.type+"]":"")}).join(`
300`))),t==="esg"||t==="board"){var v=(r.auditLog||[]).slice(0,40);if(v.length){a.push("AUDIT TRAIL");var y={};v.forEach(function(E){var C=(E.action||"").split(".")[0];y[C]=(y[C]||0)+1}),o.push("RECENT AUDIT ACTIVITY (last "+v.length+` events):
301`+Object.keys(y).map(function(E){return"- "+E+": "+y[E]+" events"}).join(`
302`)+`
303Most recent: `+v.slice(0,5).map(function(E){return E.action+(E.user?" ("+E.user+")":"")}).join("; "))}}if(t==="morning"||t==="eod"){var k=await fg(No.morningBrief().catch(function(){return null}),4e3);k&&(k.events||k.summary||k.items)&&(a.push("CALENDAR"),o.push("CALENDAR: "+JSON.stringify(k).slice(0,1200)));var A=await fg(_t.morningBrief().catch(function(){return null}),4e3);A&&A.success!==!1&&(A.summary||A.items||A.threads)&&(a.push("EMAIL"),o.push("EMAIL INTELLIGENCE: "+JSON.stringify(A).slice(0,1200)))}if(r.previousBrief){a.push("PREVIOUS BRIEF");var j=r.previousBrief.sections?r.previousBrief.sections.map(function(E){return"## "+E.title+`
304`+E.content}).join(`
305`):r.previousBrief.content||"";o.push("PREVIOUS "+t.toUpperCase()+" BRIEF ("+(r.previousBrief.ts||"")+`):
306`+j.slice(0,3e3))}return{text:o.join(`
307
308`),sources:a}}function t4(t,n){var r=[];return(`
309`+(t||"")).split(/\n##\s+/).forEach(function(o,a){if(a!==0){var l=o.indexOf(`
310`),s=(l===-1?o:o.slice(0,l)).trim(),c=(l===-1?"":o.slice(l+1)).trim();s&&r.push({id:"s"+a,title:s,content:c})}}),!r.length&&(t||"").trim()&&r.push({id:"s1",title:n&&n[0]||"Brief",content:t.trim()}),r}async function n4(t,n){var r=Date.now(),o=(_b[t]||_b.morning).slice(),a=await e4(t,n),l=!!(n&&n.previousBrief);l&&o.push("What Changed");var s=null;if(Rb[t]){var c=await fg(Vn.narrativeBrief({type:Rb[t],audience:"principal"}).catch(function(){return null}),6e3);c&&(c.answer||c.brief||c.narrative)&&(s={text:c.answer||c.brief||c.narrative,auditId:c.audit_id||c.auditId||null})}var d=await gu({model:bg,max_tokens:2e3,system:Yy,messages:[{role:"user",content:"Produce the "+t.toUpperCase()+" institutional brief for this family office, dated "+Sf()+`.
311
312STRICT GROUNDING RULES:
313- Use ONLY the data inside [BRIEF CONTEXT]. Never invent figures, positions, prices, or events.
314- If a section's data domain is absent from the context, write exactly: 'No live data available for this section.' and, where useful, one line on how to connect it.
315- Cite concrete numbers from the context wherever they exist.
316`+(l?`- In 'What Changed', compare against the PREVIOUS BRIEF in the context: what is new, what resolved, what moved.
317`:"")+`
318OUTPUT FORMAT: markdown with EXACTLY these H2 sections, in order:
319`+o.map(function(f){return"## "+f}).join(`
320`)+`
321
322[BRIEF CONTEXT]
323`+a.text}]}),p=d&&d.content&&d.content[0]&&d.content[0].text||"";if(!p)throw new Error("empty generation");var g=t4(p,o);return s&&(g.splice(1,0,{id:"narrative",title:"Market Narrative (Cortex)",content:s.text,provenance:s.auditId}),a.sources.push("CORTEX NARRATIVE")),{id:_y(),type:t,title:t.toUpperCase()+" BRIEF — "+Sf(),ts:Sf(),iso:new Date().toISOString(),sections:g,sourcesUsed:a.sources,provenance:{engine:s?"cortex-narrative+direct":"direct-grounded",auditId:s?s.auditId:null},latency_ms:Date.now()-r}}function op(t){return t?t.sections?t.title+`
324
325`+t.sections.map(function(n){return"## "+n.title+`
326`+n.content}).join(`
327
328`)+`
329
330Grounded on: `+(t.sourcesUsed||[]).join(", "):t.content||"":""}function r4(t,n,r){if(t=t||[],n=n||[],r){for(var o=0;o<t.length;o++)if(t[o]&&t[o].id===r)return t[o]}return n[0]||null}var yE="xyron.briefs.schedule.v1",xE="xyron.briefs.lastrun.v1",i4=3e4,o4=400,vE={morning:{enabled:!1,time:"08:00"},eod:{enabled:!1,time:"17:30"}},a4={morning:{label:"MORNING",briefLabel:"Morning Brief",desc:"Auto-runs Morning Brief at the set local time"},eod:{label:"EOD",briefLabel:"End of Day",desc:"Auto-runs End of Day brief at the set local time"}};function Fb(){try{return!!localStorage.getItem("xyron_jwt_token")}catch{return!1}}function l4(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||""}catch{return""}}function bE(t){var n=JSON.parse(JSON.stringify(vE));
330return!t||typeof t!="object"||Object.keys(n).forEach(function(r){t[r]&&(n[r]={enabled:!!t[r].enabled,time:t[r].time||n[r].time})}),n}function Ib(){try{return bE(JSON.parse(localStorage.getItem(yE)||"null"))}catch{return JSON.parse(JSON.stringify(vE))}}function Db(){try{return JSON.parse(localStorage.getItem(xE)||"{}")||{}}catch{return{}}}function Ob(t){try{localStorage.setItem(yE,JSON.stringify(t))}catch{}}function Lb(t){try{localStorage.setItem(xE,JSON.stringify(t))}catch{}}function SE(t){return t=t||new Date,t.getFullYear()+"-"+("0"+(t.getMonth()+1)).slice(-2)+"-"+("0"+t.getDate()).slice(-2)}function s4(t){return t=t||new Date,("0"+t.getHours()).slice(-2)+":"+("0"+t.getMinutes()).slice(-2)}function c4(t){t=t||new Date;try{for(var n=new Intl.DateTimeFormat(void 0,{timeZoneName:"short"}).formatToParts(t),r=0;r<n.length;r++)if(n[r].type==="timeZoneName"&&n[r].value)return n[r].value}catch{}var o=-t.getTimezoneOffset(),a=o>=0?"+":"-",l=Math.abs(o),s=("0"+Math.floor(l/60)).slice(-2),c=("0"+l%60).slice(-2);return"UTC"+a+s+":"+c}function zb(t,n){if(!t||!t.enabled||!t.time)return null;var r=String(t.time).split(":"),o=parseInt(r[0],10),a=parseInt(r[1],10);if(isNaN(o)||isNaN(a))return null;n=n||new Date;var l=new Date(n.getFullYear(),n.getMonth(),n.getDate(),o,a,0,0),s="today";return l.getTime()<=n.getTime()&&(l=new Date(n.getFullYear(),n.getMonth(),n.getDate()+1,o,a,0,0),s="tomorrow"),{when:l,label:s+" "+t.time,isoDay:SE(l),time:t.time}}function d4(t){var n=(0,i.useState)(Ib),r=n[0],o=n[1],a=(0,i.useState)(Db),l=a[0],s=a[1],c=(0,i.useState)(!1),d=c[0],p=c[1],g=(0,i.useState)(0),f=g[0],h=g[1],x=(0,i.useRef)(t);x.current=t;var v=(0,i.useRef)(null),y=(0,i.useRef)(0),k=(0,i.useCallback)(function(j){Fb()&&(v.current&&clearTimeout(v.current),v.current=setTimeout(function(){Sg.putSchedules(Object.assign({timezone:l4()},j||{})).catch(function(){})},o4))},[]),A=(0,i.useCallback)(function(j,E){o(function(C){var _=JSON.parse(JSON.stringify(C));return _[j]=Object.assign({},_[j]||{enabled:!1,time:"08:00"},E),Ob(_),k({schedules:(function(){var w={};return w[j]=E,w})()}),_})},[k]);return(0,i.useEffect)(function(){if(!Fb()){p(!0);return}var j=++y.current;Sg.getSchedules().then(function(E){if(!(j!==y.current||!E)){var C=bE(E.schedules),_=E.lastRun&&typeof E.lastRun=="object"?E.lastRun:{};o(C),s(_),Ob(C),Lb(_)}}).catch(function(){}).then(function(){j===y.current&&p(!0)})},[]),(0,i.useEffect)(function(){function j(){var C=Ib(),_=Db(),w=s4(),O=SE(),M=!1,U=[];Object.keys(C).forEach(function(ee){var N=C[ee];if(N.enabled&&_[ee]!==O&&!(w<N.time)){_[ee]=O,M=!0,U.push(ee);try{x.current&&x.current(ee)}catch{}}}),M&&(Lb(_),s(Object.assign({},_)),U.forEach(function(ee){k({lastRun:(function(){var N={};return N[ee]=O,N})()})})),h(function(ee){return ee+1})}j();var E=setInterval(j,i4);return function(){clearInterval(E),v.current&&clearTimeout(v.current)}},[k,s,h]),{schedules:r,setSchedule:A,lastRun:l,nextRuns:(0,i.useMemo)(function(){var j=new Date;return{morning:zb(r.morning,j),eod:zb(r.eod,j)}},[r,f]),tz:(0,i.useMemo)(function(){return c4()},[f]),synced:d}}var pr="monospace",Mb=[{id:"morning",label:"Morning Brief",icon:"☀",color:"#D4AF5C",desc:"Overnight moves in your rooms, portfolio state, alerts, calendar & email intelligence"},{id:"eod",label:"End of Day",icon:"◑",color:"#D4AF5C",desc:"Session recap across your rooms, portfolio delta, triggered alerts, tomorrow watch list"},{id:"risk",label:"Risk Monitor",icon:"⚡",color:"#C85C5C",desc:"Concentration, armed & triggered alert rules, liquidity and volatility posture"},{id:"macro",label:"Macro Intelligence",icon:"◎",color:"#B0BCC8",desc:"Macro calendar, market signals from live quotes, positioning implications"},{id:"board",label:"Board Pack",icon:"▣",color:"#3FB950",desc:"NAV & portfolio, risk matrix, project workstreams, compliance & audit summary"},{id:"esg",label:"ESG & Compliance",icon:"◈",color:"#C85C5C",desc:"Compliance activity from the audit trail, screening status, open items"}],u4={PORTFOLIO:"#3FB950","LIVE QUOTES":"#5EEAD4","ANALYST NOTES":"#D4AF5C","ROOM ALERTS":"#C85C5C",ALERTS:"#C85C5C",PROJECTS:"#D4AF5C",VA
330ULT:"#8B7CF6","AUDIT TRAIL":"#8FA3BF",CALENDAR:"#5EEAD4",EMAIL:"#5EEAD4","PREVIOUS BRIEF":"#5A7090","CORTEX NARRATIVE":"#E4C27A"};function lz(t){var n=t.briefs,r=(0,i.useMemo)(function(){return n||[]},[n]),o=t.onSaveBrief||function(){},a=t.onDeleteBrief||function(){},l=t.onAddVaultDoc||function(){},s=t.onUpdateProject||function(){},c=t.onAudit||function(){},d=t.projects||[],p=(0,i.useState)(null),g=p[0],f=p[1],h=(0,i.useState)(null),x=h[0],v=h[1],y=(0,i.useState)(null),k=y[0],A=y[1],j=(0,i.useState)(""),E=j[0],C=j[1],_=(0,i.useState)("ALL"),w=_[0],O=_[1],M=(0,i.useState)(!1),U=M[0],ee=M[1],N=(0,i.useState)(!1),V=N[0],z=N[1],oe=(0,i.useState)(!1),P=oe[0],W=oe[1],R=(0,i.useState)(!1),ae=R[0],q=R[1],ge=(0,i.useState)(""),X=ge[0],de=ge[1],We=(0,i.useState)(!1),te=We[0],_e=We[1],ve=(0,i.useState)(null),Ne=ve[0],$e=ve[1],Pe=(0,i.useRef)(null);function ot($){Pe.current&&clearTimeout(Pe.current),$e($),Pe.current=setTimeout(function(){$e(null),Pe.current=null},2200)}function re($,Ue){if(!g){f($),v(null);var Ie=r.find(function(Q){return Q.type===$&&Q.sections})||null;n4($,{positions:t.positions,projects:t.projects,savedDocs:t.savedDocs,alerts:t.alerts,auditLog:t.auditLog,previousBrief:Ie}).then(function(Q){o(Q),A(Q.id),c("brief.generated",$+(Ue?" (scheduled)":"")+" · grounded on "+(Q.sourcesUsed.join(", ")||"no live sources")+" · "+Q.latency_ms+"ms")}).catch(function(Q){v("Generation failed"+(Q&&Q.message?" — "+Q.message:"")+". Live grounding sources may be offline.")}).finally(function(){f(null)})}}var we=d4(function($){re($,!0)}),b=(0,i.useMemo)(function(){return{PORTFOLIO:(t.positions||[]).length>0,ROOMS:ix().length>0,VAULT:(t.savedDocs||[]).length>0,PROJECTS:(t.projects||[]).length>0,ALERTS:(t.alerts||[]).length>0,AUDIT:(t.auditLog||[]).length>0}},[t.positions,t.savedDocs,t.projects,t.alerts,t.auditLog]),He=(0,i.useMemo)(function(){var $=E.trim().toLowerCase();return r.filter(function(Ue){return w!=="ALL"&&Ue.type!==w?!1:$?(op(Ue)+" "+(Ue.title||"")+" "+(Ue.type||"")).toLowerCase().indexOf($)!==-1:!0})},[r,E,w]);(0,i.useEffect)(function(){k||He[0]&&He[0].id&&A(He[0].id)},[He,k]);var tt=r4(r,He,k);function Ae($){var Ue=$&&$.message||(typeof $=="string"?$:"")||"Export failed";return String(Ue).replace(/\s+/g," ").trim().slice(0,180)}function Be($){if(!$||!$.id||te){$&&!$.id&&de("Save the brief before exporting — no archive id yet.");return}de(""),_e(!0),Sg.exportPdf($.id).then(function(){c("export.brief_pdf",$.title||$.type)}).catch(function(Ue){de(Ae(Ue))}).finally(function(){_e(!1)})}function Fe($){if(!$||!$.id||te){$&&!$.id&&de("Save the brief before exporting — no archive id yet.");return}de(""),_e(!0),Sg.exportDocx($.id).then(function(){c("export.brief_docx",$.title||$.type)}).catch(function(Ue){de(Ae(Ue))}).finally(function(){_e(!1)})}function ft($){l({name:$.title||$.type+" brief "+($.ts||""),type:"GENERAL",size:"",status:"SAVED",date:new Date().toISOString().slice(0,10),tags:["brief",$.type],content:op($)}),c("brief.saved_to_vault",$.title||$.type),q(!0),setTimeout(function(){q(!1)},2e3)}function St($,Ue){var Ie=d.find(function(rt){return rt.id===Ue});if(Ie){var Q={id:"brief-"+$.id+"-"+Date.now(),name:$.title||$.type+" brief",ext:"",kind:"BRIEF",size:0,sizeLabel:"",source:"brief",addedAt:new Date().toISOString(),content:op($).slice(0,1e5),contentTruncated:!1};s(Ue,{knowledgeDocs:(Ie.knowledgeDocs||[]).concat([Q])}),c("brief.attached_to_project",($.title||$.type)+" → "+Ie.name)}}function Xe($){try{if(U){window.speechSynthesis.cancel(),ee(!1);return}var Ue=new SpeechSynthesisUtterance(op($).replace(/[#*]/g,"").slice(0,4e3));Ue.onend=function(){ee(!1)},window.speechSynthesis.speak(Ue),ee(!0)}catch{ee(!1)}}function It($){var Ue=op($);function Ie(){W(!0),setTimeout(function(){W(!1)},2e3)}function Q(){try{var rt=document.createElement("textarea");rt.value=Ue,rt.style.position="fixed",rt.style.opacity="0",document.body.appendChild(rt),rt.select(),document.execCommand("copy"),document.body.removeChild(rt),Ie()}catch{}}navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(Ue).then(Ie).catch(Q):Q()}var Rt={padding:"5px 11px",background:"rgba(212,175,92,0.08)",border:"1px solid rgba(212,175,92,0.3)",borderRadius:5,cursor:"pointer",fontFamily:pr,fontSize:9,color:"#D4AF5C",fontWeight:700,letterSpacing:".08em",whiteSpace:"nowrap"};return(0,e.jsxs)("div",{style:{flex:1,width:"100%",minWidth:0,display:"flex",flexDirection:"column",height:"100%",overflow:"hidden",background:"#080B11"},children:[(0,e.jsxs)("div",{style:{padding:"0 24px",borderBottom:"1px solid #0D1520",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0,height:54},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:14},children:[(0,e.jsx)("div",{style:{fontFamily:pr,fontSize:11,color:"#D4AF5C",letterSpacing:".16em",fontWeight:700},children:"INSTITUTIONAL BRIEFS"}),(0,e.jsxs)("div",{style:{fontFamily:pr,fontSize:9,color:"#5A7090"},children:[r.length," in archive"]})]}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0,paddingRight:4},children:[g&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:7,fontFamily:pr,fontSize:9,color:"#D4AF5C",letterSpacing:".1em"},children:[(0,e.jsx)("div",{style:{width:8,height:8,border:"1px solid rgba(212,175,92,0.3)",borderTop:"1px solid #D4AF5C",borderRadius:"50%",animation:"xspin 0.8s linear infinite"}}),"GROUNDING + GENERATING ",g.toUpperCase()]}),["morning","eod"].map(function($){var Ue=we.schedules[$]||{};if(!Ue.enabled)return null;var Ie=we.nextRuns&&we.nextRuns[$];return(0,e.jsxs)("span",{title:"Auto-generates while Xyron is open · next "+(Ie?Ie.label:Ue.time)+" ("+(we.tz||"local")+")",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 10px",background:"rgba(63,185,80,0.06)",border:"1px solid rgba(63,185,80,0.2)",borderRadius:5,fontFamily:pr,fontSize:9,color:"#3FB950",flexShrink:0,whiteSpace:"nowrap"},children:[(0,e.jsx)("span",{style:{width:5,height:5,borderRadius:"50%",background:"#3FB950"}}),$.toUpperCase()," ",Ue.time," ",we.tz||""]},$)}),typeof t.onMinimize=="function"||typeof t.onClose=="function"?(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,marginLeft:4,background:"rgba(6,8,13,0.95)",border:"0.5px solid #223040",borderRadius:7,padding:"3px",boxShadow:"0 6px 18px rgba(0,0,0,0.55)",flexShrink:0},children:[typeof t.onMinimize=="function"?(0,e.jsx)("button",{type:"button",title:"Minimize Briefs",onClick:t.onMinimize,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:26,height:22,background:"transparent",border:"none",cursor:"pointer",color:"#A7BCD1",fontSize:18,lineHeight:1,borderRadius:4},onMouseEnter:function($){$.currentTarget.style.background="rgba(143,163,184,0.14)",$.currentTarget.style.color="#D4AF5C"},onMouseLeave:function($){$.currentTarget.style.background="transparent",$.currentTarget.style.color="#A7BCD1"},children:"–"}):null,typeof t.onClose=="function"?(0,e.jsx)("button",{type:"button",title:"Close Briefs",onClick:t.onClose,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:26,height:22,background:"transparent",border:"none",cursor:"pointer",color:"#B87C7C",fontSize:14,lineHeight:1,borderRadius:4},onMouseEnter:function($){$.currentTarget.style.background="rgba(184,124,124,0.16)"},onMouseLeave:function($){$.currentTarget.style.background="transparent"},children:"✕"}):null]}):null]})]}),(0,e.jsxs)("div",{style:{flex:1,display:"flex",overflow:"hidden",minWidth:0,width:"100%"},children:[(0,e.jsxs)("div",{style:{width:270,minWidth:270,flexShrink:0,borderRight:"1px solid #0D1520",display:"flex",flexDirection:"column",background:"#020408",overflowY:"auto"},children:[(0,e.jsx)("div",{style:{padding:"14px 14px 6px",fontFamily:pr,fontSize:8,color:"#5A7090",letterSpacing:".14em"},children:"GENERATE — GROUNDED ON LIVE DATA"}),Mb.map(function($){return(0,e.jsxs)("div",{style:{margin:"4px 12px",padding:"10px 12px",borderRadius:7,border:"1px solid #101826",background:"#05080D"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,e.jsx)("span",{style:{color:$.color,fontSize:12},children:$.icon}
330),(0,e.jsx)("span",{style:{fontFamily:pr,fontSize:10,color:"#C9D1D9",fontWeight:700,letterSpacing:".06em",flex:1},children:$.label.toUpperCase()}),(0,e.jsx)("button",{disabled:!!g,onClick:function(){re($.id,!1)},style:Object.assign({},Rt,{fontSize:8,padding:"4px 9px"},g?{opacity:.4,cursor:"default"}:null),children:g===$.id?"…":"RUN"})]}),(0,e.jsx)("div",{style:{fontSize:10,color:"#5A7090",lineHeight:1.5,marginTop:5},children:$.desc})]},$.id)}),(0,e.jsx)("div",{style:{padding:"14px 14px 6px",fontFamily:pr,fontSize:8,color:"#5A7090",letterSpacing:".14em"},children:"DATA READINESS"}),(0,e.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:5,padding:"0 14px 8px"},children:Object.keys(b).map(function($){var Ue=b[$];return(0,e.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:5,fontFamily:pr,fontSize:8,color:Ue?"#3FB950":"#3A4A5E",border:"1px solid "+(Ue?"rgba(63,185,80,0.25)":"#101826"),borderRadius:4,padding:"3px 7px"},children:[(0,e.jsx)("span",{style:{width:5,height:5,borderRadius:"50%",background:Ue?"#3FB950":"#2A3A50"}}),$]},$)})}),(0,e.jsx)("div",{style:{padding:"12px 14px 4px",fontFamily:pr,fontSize:8,color:"#5A7090",letterSpacing:".14em"},children:"SCHEDULING — AUTO-GENERATE"}),(0,e.jsxs)("div",{style:{padding:"0 14px 8px",fontSize:9,color:"#3A4A5E",lineHeight:1.5,fontFamily:pr},children:["ON runs the matching brief at the set local time (",we.tz||"local","). OFF does not run. Requires Xyron open."]}),["morning","eod"].map(function($){var Ue=we.schedules[$]||{enabled:!1,time:"08:00"},Ie=a4[$]||{label:$.toUpperCase()},Q=we.nextRuns&&we.nextRuns[$];return(0,e.jsxs)("div",{style:{margin:"0 12px 8px",padding:"8px 10px",borderRadius:6,border:"1px solid #101826",background:"#05080D"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,e.jsx)("span",{style:{fontFamily:pr,fontSize:9,color:"#8FA3BF",width:66,flexShrink:0,letterSpacing:".06em",fontWeight:700},title:Ie.desc,children:Ie.label}),(0,e.jsx)("input",{type:"time",value:Ue.time,title:"Local time ("+(we.tz||"local")+")",onChange:function(rt){we.setSchedule($,{time:rt.target.value}),ot($),c("brief.schedule_updated",$+" @ "+rt.target.value+" ("+(we.tz||"local")+")")},style:{background:"#0D1020",border:"1px solid #1E2838",borderRadius:5,padding:"4px 6px",color:"#C9D1D9",fontFamily:pr,fontSize:9,outline:"none",colorScheme:"dark",flex:1,minWidth:0}}),(0,e.jsx)("button",{title:Ue.enabled?"Disable — will not auto-generate":"Enable — auto-generates "+(Ie.briefLabel||$)+" at this local time while Xyron is open",onClick:function(){var rt=!Ue.enabled;we.setSchedule($,{enabled:rt}),ot($),c("brief.schedule_"+(rt?"enabled":"disabled"),$+" @ "+Ue.time+" ("+(we.tz||"local")+")")},style:Object.assign({},Rt,{fontSize:8,padding:"4px 9px",flexShrink:0},Ue.enabled?{background:"rgba(63,185,80,0.1)",border:"1px solid rgba(63,185,80,0.4)",color:"#3FB950"}:null),children:Ue.enabled?"ON":"OFF"})]}),(0,e.jsx)("div",{style:{marginTop:5,fontFamily:pr,fontSize:8,color:Ne===$?"#3FB950":"#3A4A5E",letterSpacing:".04em",lineHeight:1.4},children:Ne===$?"✓ SAVED":Ue.enabled&&Q?"NEXT · "+Q.label+" · "+(we.tz||"local"):"DISABLED — will not auto-generate"})]},$)}),(0,e.jsx)("div",{style:{padding:"2px 14px 16px",fontSize:9,color:"#3A4A5E",lineHeight:1.5,fontFamily:pr},children:"Schedule is saved to your account. Closed-app delivery is the backend lane."})]}),(0,e.jsxs)("div",{style:{flex:1,overflowY:"auto",padding:"18px 26px",minWidth:0,scrollbarGutter:"stable"},children:[x&&(0,e.jsx)("div",{style:{padding:"10px 14px",border:"1px solid rgba(200,92,92,0.4)",background:"rgba(200,92,92,0.07)",borderRadius:7,fontFamily:pr,fontSize:10,color:"#E07070",marginBottom:14},children:x}),X&&(0,e.jsxs)("div",{role:"alert","data-testid":"brief-export-error",style:{padding:"10px 14px",border:"1px solid rgba(200,92,92,0.4)",background:"rgba(200,92,92,0.07)",borderRadius:7,fontFamily:pr,fontSize:10,color:"#E07070",marginBottom:14},children:["EXPORT FAILED — ",X]}),!tt&&!x&&r.length===0&&(0,e.jsxs)("div",{style:{textAlign:"center",marginTop:70},children:[(0,e.jsx)("div",{style:{fontSize:30,opacity:.3,marginBottom:14},children:"☀"}),(0,e.jsx)("div",{style:{fontFamily:pr,fontSize:11,color:"#3A4A5E",letterSpacing:".12em"},children:"NO BRIEFS YET — RUN ONE FROM THE LEFT RAIL"}),(0,e.jsx)("div",{style:{fontSize:11,color:"#2A3A50",marginTop:8},children:"Briefs are grounded on your live positions, rooms, vault, projects and audit trail."})]}),!tt&&!x&&r.length>0&&He.length===0&&(0,e.jsxs)("div",{style:{textAlign:"center",marginTop:70},children:[(0,e.jsx)("div",{style:{fontFamily:pr,fontSize:11,color:"#3A4A5E",letterSpacing:".12em"},children:"NO RESULTS"}),(0,e.jsx)("div",{style:{fontSize:11,color:"#2A3A50",marginTop:8},children:"No briefs match the current search or filter."})]}),tt&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap",marginBottom:4},children:[(0,e.jsx)("div",{style:{fontSize:17,fontWeight:800,color:"#E4C27A"},children:tt.title||(tt.type||"BRIEF").toUpperCase()+" — "+(tt.ts||"")}),tt.sections?(0,e.jsxs)("span",{style:{fontFamily:pr,fontSize:8,color:"#3FB950",border:"1px solid rgba(63,185,80,0.3)",borderRadius:4,padding:"2px 7px",letterSpacing:".1em",fontWeight:700},children:["GROUNDED ·"," ",tt.provenance&&tt.provenance.engine==="cortex-narrative+direct"?"CORTEX + DIRECT":"DIRECT"]}):(0,e.jsx)("span",{style:{fontFamily:pr,fontSize:8,color:"#C85C
3305C",border:"1px solid rgba(200,92,92,0.4)",borderRadius:4,padding:"2px 7px",letterSpacing:".1em",fontWeight:700},title:"Generated before Phase 19 — content was not grounded on live data",children:"LEGACY · UNGROUNDED"}),tt.provenance&&tt.provenance.auditId&&(0,e.jsxs)("span",{style:{fontFamily:pr,fontSize:8,color:"#E4C27A",border:"1px solid rgba(212,175,92,0.3)",borderRadius:4,padding:"2px 7px",letterSpacing:".08em"},title:"Cortex narrative provenance audit id",children:["PROVENANCE"," ",String(tt.provenance.auditId).slice(0,12)]}),tt.latency_ms?(0,e.jsxs)("span",{style:{fontFamily:pr,fontSize:8,color:"#3A4A5E"},children:[tt.latency_ms,"ms"]}):null]}),tt.sourcesUsed&&tt.sourcesUsed.length>0&&(0,e.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:5,marginBottom:12},children:tt.sourcesUsed.map(function($){return(0,e.jsx)("span",{style:{fontFamily:pr,fontSize:8,color:u4[$]||"#8FA3BF",border:"1px solid #1A2434",borderRadius:4,padding:"2px 7px",letterSpacing:".08em"},children:$},$)})}),(0,e.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:16,position:"relative"},children:[(0,e.jsx)("button",{style:Object.assign({},Rt,te?{opacity:.55}:null),disabled:te,onClick:function(){Be(tt)},children:te?"…":"⇩ PDF"}),(0,e.jsx)("button",{style:Object.assign({},Rt,te?{opacity:.55}:null),disabled:te,onClick:function(){Fe(tt)},children:te?"…":"⇩ DOCX"}),(0,e.jsx)("button",{style:Rt,onClick:function(){ft(tt)},children:ae?"✓ SAVED":"◆ SAVE TO VAULT"}),(0,e.jsxs)("div",{style:{position:"relative"},children:[(0,e.jsx)("button",{style:Object.assign({},Rt,d.length?null:{opacity:.4,cursor:"default"}),onClick:function(){d.length&&z(!V)},children:"◇ ATTACH TO PROJECT ▾"}),V&&(0,e.jsx)("div",{style:{position:"absolute",top:"112%",left:0,zIndex:50,background:"rgba(8,12,20,0.99)",border:"1px solid rgba(212,175,92,0.25)",borderRadius:6,minWidth:170,boxShadow:"0 8px 24px rgba(0,0,0,0.5)",overflow:"hidden"},children:d.slice(0,8).map(function($){return(0,e.jsxs)("div",{style:{padding:"8px 12px",fontFamily:pr,fontSize:9,color:"#C9D1D9",letterSpacing:".08em",cursor:"pointer",borderBottom:"1px solid rgba(212,175,92,0.06)"},onClick:function(){z(!1),St(tt,$.id)},children:["◇ ",$.name]},$.id)})})]}),(0,e.jsx)("button",{style:Rt,onClick:function(){Xe(tt)},children:U?"■ STOP":"► READ"}),(0,e.jsx)("button",{style:Rt,onClick:function(){It(tt)},children:P?"✓ COPIED":"COPY"})]}),tt.sections?tt.sections.map(function($){return(0,e.jsxs)("div",{style:{marginBottom:14,border:"1px solid #101826",borderRadius:8,background:"#05080D",overflow:"hidden"},children:[(0,e.jsxs)("div",{style:{padding:"9px 16px",borderBottom:"1px solid #0D1520",display:"flex",alignItems:"center",gap:8},children:[(0,e.jsx)("span",{style:{fontFamily:pr,fontSize:9,color:"#D4AF5C",letterSpacing:".14em",fontWeight:700},children:$.title.toUpperCase()}),$.provenance&&(0,e.jsxs)("span",{style:{fontFamily:pr,fontSize:8,color:"#E4C27A"},title:"Cortex provenance audit id",children:["⛓ ",String($.provenance).slice(0,10)]})]}),(0,e.jsx)("div",{style:{padding:"12px 16px",fontSize:13,color:"#C9D1D9",lineHeight:1.7},children:(0,e.jsx)(ws,{text:$.content})})]},$.id)}):(0,e.jsx)("div",{style:{border:"1px solid #101826",borderRadius:8,background:"#05080D",padding:"14px 16px",fontSize:13,color:"#C9D1D9",lineHeight:1.7},children:(0,e.jsx)(ws,{text:tt.content||""})})]})]}),(0,e.jsxs)("div",{style:{width:250,minWidth:250,maxWidth:250,flexShrink:0,borderLeft:"1px solid #0D1520",background:"#020408",display:"flex",flexDirection:"column",alignItems:"stretch",overflow:"hidden"},children:[(0,e.jsxs)("div",{style:{padding:"12px 12px 8px",flexShrink:0,width:"100%",boxSizing:"border-box",alignSelf:"stretch"},children:[(0,e.jsx)("input",{value:E,placeholder:"⌕ Search archive…",onChange:function($){C($.target.value)},style:{width:"100%",background:"#0D1020",border:"1px solid #1E2838",borderRadius:6,padding:"7px 10px",color:"#C9D1D9",fontSize:11,outline:"none",boxSizing:"border-box"}}),(0,e.jsx)("div",{style:{display:"flex",flexWrap:"wrap",justifyContent:"flex-start",alignContent:"flex-start",ga
330p:4,marginTop:8,width:"100%",boxSizing:"border-box"},children:["ALL"].concat(Mb.map(function($){return $.id})).map(function($){var Ue=w===$;return(0,e.jsx)("button",{onClick:function(){O($)},style:{padding:"3px 7px",background:Ue?"rgba(212,175,92,0.12)":"transparent",border:"1px solid "+(Ue?"rgba(212,175,92,0.5)":"#1E2838"),borderRadius:4,cursor:"pointer",fontFamily:pr,fontSize:8,color:Ue?"#D4AF5C":"#5A7090",fontWeight:700,letterSpacing:".08em"},children:$.toUpperCase()},$)})})]}),(0,e.jsxs)("div",{style:{flex:1,overflowY:"auto",padding:"4px 12px 12px",scrollbarGutter:"stable"},children:[He.length===0&&(0,e.jsx)("div",{style:{fontFamily:pr,fontSize:9,color:"#3A4A5E",textAlign:"left",marginTop:16,letterSpacing:".08em"},children:r.length===0?"ARCHIVE EMPTY":E.trim()||w!=="ALL"?"NO RESULTS":"ARCHIVE EMPTY"}),He.map(function($){var Ue=tt&&tt.id===$.id;return(0,e.jsxs)("div",{onClick:function(){A($.id)},style:{padding:"9px 11px",borderRadius:6,border:"1px solid "+(Ue?"rgba(212,175,92,0.45)":"#101826"),background:Ue?"rgba(212,175,92,0.06)":"#05080D",cursor:"pointer",marginBottom:6},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,e.jsx)("span",{style:{fontFamily:pr,fontSize:9,color:"#D4AF5C",fontWeight:700,letterSpacing:".08em",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:($.type||"brief").toUpperCase()}),!$.sections&&(0,e.jsx)("span",{style:{fontFamily:pr,fontSize:7,color:"#C85C5C"},children:"LEGACY"}),(0,e.jsx)("span",{style:{color:"#3A4A5E",cursor:"pointer",fontSize:12,lineHeight:1},title:"Delete brief",onClick:function(Ie){Ie.stopPropagation(),a($.id)},children:"×"})]}),(0,e.jsx)("div",{style:{fontFamily:pr,fontSize:8,color:"#5A7090",marginTop:3},children:$.ts||""})]},$.id)})]})]})]})]})}function Nb(){try{localStorage.setItem($g,"1")}catch{}zy({onboarded:!0})}var uh=[{id:"welcome",icon:"X",color:"#D4AF5C",title:"Welcome to Xyron Intelligence",subtitle:"Sovereign AI terminal for family offices and UHNW principals",body:"Xyron unifies your portfolio data, encrypted vault documents, live market feeds, and AI reasoning into one secure interface. Everything is accessed through a single conversation.",cta:"Get started",visual:[{label:"ARENBERG FEED",value:"LIVE",color:"#3FB950"},{label:"VAULT",value:"ENCRYPTED",color:"#D4AF5C"},{label:"AI MODELS",value:"3 ACTIVE",color:"#D4AF5C"},{label:"LATENCY",value:"<2s",color:"#B0BCC8"}]},{id:"vault",icon:"▣",color:"#D4AF5C",title:"Sovereign Encrypted Vault",subtitle:"Your documents, secure and instantly queryable",body:"Upload any document — PDF, DOCX, XLSX, CSV — and Xyron reads, indexes, and remembers it. Ask questions directly in the chat. Documents are AES-256 encrypted and never leave the GCP boundary.",cta:"I understand",demo:["Q4 2025 Portfolio Report.pdf","PE Fund III LP Agreement.docx","Risk Management Policy v3.pdf"]},{id:"chat",icon:"■",color:"#B0BCC8",title:"The Intelligence Terminal",subtitle:"Ask anything — one interface, every data source",body:"The chat is the system. Ask about portfolio positions, legal clauses, macro events, live prices, or generate board reports. Xyron synthesises all sources and cites every answer.",cta:"Show me",prompts:["What is our current PE exp
330osure vs risk limits?","Summarise the key clauses in our LP Agreement","Generate a board-level portfolio report for March 2026"]},{id:"projects",icon:"▦",color:"#D4AF5C",title:"Projects — Organised Intelligence",subtitle:"Group related work with custom instructions and knowledge",body:"Create projects to organise your workflows. Each project has its own instructions (what role Xyron plays), knowledge base (which documents it knows), and chat history. Like having a specialist on each topic.",cta:"Start exploring",templates:["Portfolio Intelligence","Legal & Compliance","Macro Intelligence"]}];function sz(t){var n=t.onComplete,r=(0,i.useState)(0),o=r[0],a=r[1],l=(0,i.useState)(!1),s=l[0],c=l[1],d=uh[o],p=o===uh.length-1;function g(){s||(c(!0),setTimeout(function(){p?(Nb(),n()):a(o+1),c(!1)},200))}return(0,e.jsxs)("div",{className:"xy-onboard",style:{position:"fixed",inset:0,background:"#080B11",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",zIndex:900,backgroundImage:"linear-gradient(rgba(212,175,92,0.02) 1px,transparent 1px),linear-gradient(90deg,rgba(212,175,92,0.02) 1px,transparent 1px)",backgroundSize:"50px 50px",padding:"env(safe-area-inset-top) 16px env(safe-area-inset-bottom)"},children:[(0,e.jsx)("div",{className:"xy-onboard-dots",style:{position:"absolute",top:"max(32px, calc(12px + env(safe-area-inset-top)))",display:"flex",gap:"8px",alignItems:"center"},children:uh.map(function(f,h){return(0,e.jsx)("div",{style:{width:h===o?24:7,height:7,borderRadius:"4px",background:h===o?d.color:h<o?"#2A3548":"#1E2838",transition:"all 0.3s ease",cursor:"pointer"},onClick:function(){h<=o&&a(h)}},h)})}),(0,e.jsxs)("div",{className:"xy-onboard-card",style:{width:"min(560px, 100%)",maxWidth:"100%",boxSizing:"border-box",padding:"0 4px",animation:s?"xfadein 0.2s ease reverse":"xfadein 0.3s ease",opacity:s?0:1},children:[(0,e.jsxs)("div",{style:{textAlign:"center",marginBottom:"28px"},children:[(0,e.jsx)("div",{style:{width:"72px",height:"72px",background:"linear-gradient(135deg,"+d.color+"30,"+d.color+"10)",border:"1px solid "+d.color+"40",borderRadius:"18px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:d.id==="welcome"?"32px":"24px",color:d.color,margin:"0 auto 16px",boxShadow:"0 0 40px "+d.color+"20"},children:d.icon}),(0,e.jsx)("div",{className:"xy-onboard-sub",style:{fontFamily:"monospace",fontSize:"9px",color:d.color,letterSpacing:"0.2em",marginBottom:"10px",textTransform:"uppercase",padding:"0 8px",lineHeight:1.5},children:d.subtitle}),(0,e.jsx)("div",{className:"xy-onboard-title",style:{fontWeight:900,fontSize:"28px",color:"#E6EDF3",letterSpacing:"-0.04em",lineHeight:"1.15",marginBottom:"14px",padding:"0 8px"},children:d.title}),(0,e.jsx)("div",{className:"xy-onboard-body",style:{fontSize:"14px",color:"#8B949E",lineHeight:"1.75",maxWidth:"440px",margin:"0 auto",padding:"0 8px"},children:d.body})]}),d.visual&&(0,e.jsx)("div",{className:"xy-onboard-stats",style:{display:"flex",gap:"1px",background:"#111820",borderRadius:"10px",overflow:"hidden",border:"1px solid #1E2838",marginBottom:"28px"},children:d.visual.map(function(f,h){return(0,e.jsxs)("div",{className:"xy-onboard-stat",style:{flex:1,minWidth:0,padding:"14px 12px",background:"#0C1018",textAlign:"center",borderRight:h<d.visual.length-1?"1px solid #1E2838":"none"},children:[(0,e.jsx)("div",{style:{fontWeight:800,fontSize:"16px",color:f.color,marginBottom:"4px"},children:f.value}),(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"7px",color:"#7A8A9E",letterSpacing:"0.12em",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f.label})]},h)})}),d.demo&&(0,e.jsxs)("div",{className:"xy-onboard-demo",style:{background:"#0C1018",border:"1px solid #2A3548",borderRadius:"10px",padding:"14px 16px",marginBottom:"28px",overflow:"hidden"},children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#7A8A9E",letterSpacing:"0.14em",marginBottom:"10px"},children:"SAMPLE VAULT DOCUMENTS"}),d.demo.map(function(f,h){var x=ld(f),v=tc(f);return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"7px 0",borderBottom:h<d.demo.length-1?"1px solid #111820":"none",minWidth:0},children:[(0,e.jsx)("div",{style:{width:"24px",height:"24px",background:x+"18",border:"1px solid "+x+"22",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"monospace",fontSize:"7px",color:x,fontWeight:700,flexShrink:0},children:v}),(0,e.jsx)("span",{style:{fontSize:"12px",color:"#8B949E",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:f}),(0,e.jsx)("span",{style:{marginLeft:"auto",fontFamily:"monospace",fontSize:"7px",color:"#3FB950",flexShrink:0},children:"INDEXED"})]},h)})]}),d.prompts&&(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"6px",marginBottom:"28px"},children:d.prompts.map(function(f,h){return(0,e.jsxs)("div",{style:{background:"#0C1018",border:"1px solid #1E2838",borderRadius:"8px",padding:"10px 14px",display:"flex",alignItems:"center",gap:"10px"},children:[(0,e.jsx)("span",{style:{color:d.color,fontSize:"9px",flexShrink:0},children:"›"}),(0,e.jsx)("span",{style:{fontSize:"12px",color:"#7A8A9E"},children:f})]},h)})}),d.templates&&(0,e.jsx)("div",{className:"xy-onboard-templates",style:{display:"flex",gap:"7px",marginBottom:"28px"},children:d.templates.map(function(f,h){var x=["#D4AF5C","#D4AF5C","#B0BCC8"];return(0,e.jsxs)("div",{className:"xy-onboard-template",style:{flex:1,minWidth:0,background:"#0C1018",border:"1px solid #1E2838",borderRadius:"8px",padding:"12px",textAlign:"center"},children:[(0,e.jsx)("div",{style:{width:"28px",height:"28px",borderRadius:"7px",background:x[h]+"18",border:"1px solid "+x[h]+"33",margin:"0 auto 8px",display:"flex",alignItems:"center",justifyContent:"center",color:x[h],fontSize:"13px"},children:"•"}),(0,e.jsx)("div",{style:{fontSize:"11px",color:"#8B949E",lineHeight:"1.4",overflow:"hidden",textOverflow:"ellipsis"},children:f})]},h)})}),(0,e.jsxs)("div",{className:"xy-onboard-cta",style:{display:"flex",justifyContent:"center",gap:"12px",alignItems:"center",flexWrap:"wrap"},children:[o>0&&(0,e.jsx)("button",{onClick:function(){a(o-1)},style:{padding:"12px 20px",minHeight:44,background:"transparent",border:"1px solid #2A3548",borderRadius:"8px",cursor:"pointer",fontFamily:"monospace",fontSize:"10px",color:"#7A8A9E"},onMouseEnter:function(f){f.currentTarget.style.borderColor="#3A4556",f.currentTarget.style.color="#C9D1D9"},onMouseLeave:function(f){f.currentTarget.style.borderColor="#2A3548",f.currentTarget.style.color="#7A8A9E"},children:"‹ Back"}),(0,e.jsx)("button",{onClick:g,style:{padding:"12px 32px",minHeight:44,background:d.color,border:"none",borderRadius:"9px",cursor:"pointer",fontFamily:"monospace",fontSize:"10px",fontWeight:700,color:"#000",letterSpacing:"0.1em",boxShadow:"0 4px 20px "+d.color+"40",transition:"all 0.15s"},onMouseEnter:function(f){f.currentTarget.style.opacity="0.88"},onMouseLeave:function(f){f.currentTarget.style.opacity="1"},children:p?"ENTER TERMINAL":d.cta+" ›"})]})]}),(0,e.jsx)("button",{className:"xy-onboard-skip",onClick:function(){Nb(),n()},style:{position:"absolute",bottom:"max(28px, calc(16px + env(safe-area-inset-bottom)))",background:"transparent",border:"none",cursor:"pointer",fontFamily:"monospace",fontSize:"10px",color:"#5A6880",padding:"12px"},onMouseEnter:function(f){f.currentTarget.style.color="#7A8A9E"},onMouseLeave:function(f){f.currentTarget.style.color="#5A6880"},children:"Skip introduction"})]})}var cz=i.memo(function(n){var r=n.questions||n.followUps||[],o=n.onAsk||n.onSelect;return r.length===0?null:(0,e.jsxs)("div",{style:{padding:"10px 16px 6px",display:"flex",gap:"8px",flexWrap:"wrap",alignItems:"center"},children:[(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:"7px",color:"#3A5060",letterSpacing:"0.1em",textTransform:"uppercase"},children:"FOLLOW-UP"}),r.map(function(a,l){return(0,e.jsx)("button",{onClick:function(){console.log("[FollowUp] clicked:",a),o&&o(a)},style:{padding:"6px 14px",background:"rgba(212,175,92,0.04)",border:"1px solid rgba(212,175,92,0.15)",borderRadius:"14px",cursor:"pointer",fontFamily:"monospace",fontSize:"10px",color:"#8B949E",textAlign:"left",lineHeight:"1.3",maxWidth:"320px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",transition:"all .15s"},onMouseEnter:function(s){s.currentTarget.style.borderColor="rgba(212,175,92,0.4)",s.currentTarget.style.color="#D4AF5C",s.currentTarget.style.background="rgba(212,175,92,0.08)"},onMouseLeave:function(s){s.currentTarget.style.borderColor="rgba(212,175,92,0.15)",s.currentTarget.style.color="#8B949E",s.currentTarget.style.background="rgba(212,175,92,0.04)"},children:a},l)})]})});function dz(t){var n=t.doc,r=t.onClose,o=t.onSaveVault,a=t.onExport,l=(0,i.useState)(!1),s=l[0],c=l[1],d=(0,i.useState)(!1),p=d[0],g=d[1];function f(){navigator.clipboard&&navigator.clipboard.writeText(n.content).then(function(){c(!0),setTimeout(function(){c(!1)},2e3)})}function h(){o(n),g(!0),setTimeout(function(){g(!1)},2500)}function x(v){for(var y=v.split(`
331`),k=[],A=0;A<y.length;){var j=y[A];if(j.match(/^# /))k.push((0,e.jsx)("h1",{style:{fontSize:"20px",fontWeight:800,color:"#E6EDF3",marginBottom:"12px",marginTop:A>0?"22px":"0",fontFamily:"Georgia,serif",letterSpacing:"-0.02em"},children:j.replace(/^# /,"")},A));else if(j.match(/^## /))k.push((0,e.jsx)("h2",{style:{fontSize:"13px",fontWeight:700,color:"#D4AF5C",marginBottom:"8px",marginTop:"18px",letterSpacing:"0.08em",textTransform:"uppercase",fontFamily:"monospace"},children:j.replace(/^## /,"")},A));else if(j.match(/^### /))k.push((0,e.jsx)("h3",{style:{fontSize:"12px",fontWeight:600,color:"#8B949E",marginBottom:"6px",marginTop:"14px",letterSpacing:"0.06em",textTransform:"uppercase",fontFamily:"monospace"},children:j.replace(/^### /,"")},A));else if(j.match(/^[-*] /))k.push((0,e.jsxs)("div",{style:{display:"flex",gap:"10px",marginBottom:"5px",paddingLeft:"6px"},children:[(0,e.jsx)("span",{style:{color:"#D4AF5C",fontSize:"8px",marginTop:"5px",flexShrink:0},children:"▸"}),(0,e.jsx)("span",{style:{color:"#C9D1D9",fontSize:"13px",lineHeight:"1.7"},children:j.replace(/^[-*] /,"")})]},A));else if(j.match(/^\d+\. /)){var E=j.match(/^(\d+)\. (.*)/);E&&k.push((0,e.jsxs)("div",{style:{display:"flex",gap:"10px",marginBottom:"5px",paddingLeft:"6px"},children:[(0,e.jsxs)("span",{style:{color:"#D4AF5C",fontFamily:"monospace",fontSize:"11px",flexShrink:0},children:[E[1],"."]}),(0,e.jsx)("span",{style:{color:"#C9D1D9",fontSize:"13px",lineHeight:"1.7"},children:E[2]})]},A))}else if(j.startsWith("---"))k.push((0,e.jsx)("hr",{style:{border:"none",borderTop:"1px solid #1E2838",margin:"14px 0"}},A));else if(j.match(/^\*\*/)){var C=j.match(/^\*\*(.+)\*\*:?\s*(.*)/);C?k.push((0,e.jsxs)("div",{style:{marginBottom:"6px"},children:[(0,e.jsxs)("strong",{style:{color:"#E6EDF3",fontSize:"13px"},children:[C[1],C[2]?":":""]}),C[2]&&(0,e.jsxs)("span",{style:{color:"#C9D1D9",fontSize:"13px"},children:[" ",C[2]]})]},A)):k.push((0,e.jsx)("p",{style:{margin:"0 0 8px",color:"#C9D1D9",fontSize:"13px",lineHeight:"1.7"},children:j.replace(/\*\*/g,"")},A))}else j.trim()===""?k.push((0,e.jsx)("div",{style:{height:"8px"}},A)):k.push((0,e.jsx)("p",{style:{margin:"0 0 8px",color:"#C9D1D9",fontSize:"13px",lineHeight:"1.7"},children:j},A));A++}return k}return(0,e.jsxs)("div",{style:{width:"460px",flexShrink:0,borderLeft:"1px solid #1E2838",background:"#05080D",display:"flex",flexDirection:"column",overflow:"hidden",animation:"xfadein 0.2s ease"},children:[(0,e.jsxs)("div",{style:{padding:"11px 16px",borderBottom:"1px solid #111820",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0,background:"#030507"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px",minWidth:0},children:[(0,e.jsx)("div",{style:{width:"6px",height:"6px",borderRadius:"50%",background:"#D4AF5C",flexShrink:0}}),(0,e.jsxs)("div",{style:{minWidth:0},children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#7A8A9E",letterSpacing:"0.12em",marginBottom:"2px"},children:"GENERATED DOCUMENT"}),(0,e.jsx)("div",{style:{fontSize:"12px",fontWeight:600,color:"#E6EDF3",lineHeight:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n.title})]})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:"5px",flexShrink:0},children:[(0,e.jsx)("button",{onClick:f,style:{padding:"3px 8px",background:s?"rgba(63,185,80,0.1)":"transparent",border:"1px solid "+(s?"rgba(63,185,80,0.3)":"#2A3548"),borderRadius:"4px",cursor:"pointer",fontFamily:"monospace",fontSize:"8px",color:s?"#3FB950":"#8B949E"},children:s?"COPIED":"COPY"}),(0,e.jsx)("button",{onClick:function(){a(n,"pdf")},style:{padding:"3px 8px",background:"transparent",border:"1px solid #2A3548",borderRadius:"4px",cursor:"pointer",fontFamily:"monospace",fontSize:"8px",color:"#8B949E"},title:"Export as PDF",children:"PDF"}),(0,e.jsx)("button",{onClick:function(){a(n,"docx")},style:{padding:"3px 8px",background:"transparent",border:"1px solid #2A3548",borderRadius:"4px",cursor:"pointer",fontFamily:"monospace",fontSize:"8px",color:"#8B949E"},title:"Export as Word",children:"DOCX"}),(0,e.jsx)("button",{onClick:h,style:{padding:"3px 8px",background:p?"rgba(212,175,92,0.12)":"rgba(212,175,92,0.08)",border:"1px solid "+(p?"rgba(212,175,92,0.3)":"rgba(212,175,92,0.25)"),borderRadius:"4px",cursor:"pointer",fontFamily:"monospace",fontSize:"8px",color:"#D4AF5C"},children:p?"SAVED":"SAVE TO VAULT"}),(0,e.jsx)("button",{onClick:r,style:{width:"24px",height:"24px",background:"transparent",border:"1px solid #2A3548",borderRadius:"4px",cursor:"pointer",color:"#7A8A9E",fontSize:"13px",display:"flex",alignItems:"center",justifyContent:"center"},children:"x"})]})]}),(0,e.jsx)("div",{style:{flex:1,overflow:"auto",padding:"22px 20px"},children:x(n.content)}),(0,e.jsxs)("div",{style:{padding:"8px 16px",borderTop:"1px solid #111820",flexShrink:0,background:"#030507",fontFamily:"monospace",fontSize:"8px",color:"#7A8A9E",display:"flex",justifyContent:"space-between"},children:[(0,e.jsxs)("span",{children:["◈ XYRON DOCUMENT · ",n.ts]}),(0,e.jsx)("span",{children:"FO-ALPHA-01 · AES-256"})]})]})}var EE="xyron_profile";function f4(){try{var t=localStorage.getItem(EE);return t?JSON.parse(t):{riskAppetite:"balanced",goals:[],facts:[]}}catch{return{riskAppetite:"balanced",goals:[],facts:[]}}}function p4(t){try{localStorage.setItem(EE,JSON.stringify(t))}catch{}}function uz(t){var n=t.profile||f4(),r=t.onUpdateProfile,o=t.onClearMemory,a=t.mem||{facts:[],preferences:[],decisions:[],totalExchanges:0},l=(0,i.useState)("profile"),s=l[0],c=l[1],d=(0,i.useState)(!1),p=d[0],g=d[1],f=(0,i.useState)(!1),h=f[0],x=f[1];function v(_,w){try{oi({action:_,resource:"profile",detail:w,model:"system"})}catch{}}var y=[{id:"conservative",label:"Conservative",color:"#3FB950",desc:"Capital preservation above all. Max drawdown 5%. Priority: liquidity and safety."},{id:"moderate",label:"Moderate",color:"#D4AF5C",desc:"Growth with downside protection. Max drawdown 15%. Balanced alpha and risk control."},{id:"growth",label:"Growth",color:"#B0BCC8",desc:"Long-term capital appreciation. Max drawdown 25%. Accepts short-term volatility."}
331,{id:"aggressive",label:"Aggressive",color:"#C85C5C",desc:"Maximum returns. Drawdown tolerance above 25%. High concentration and illiquidity accepted."}],k=[{id:"capital_preservation",label:"Capital Preservation",icon:"◈",color:"#3FB950"},{id:"income_generation",label:"Income Generation",icon:"◎",color:"#D4AF5C"},{id:"inflation_hedge",label:"Inflation Hedge",icon:"▲",color:"#B0BCC8"},{id:"wealth_transfer",label:"Generational Wealth Transfer",icon:"◇",color:"#D4AF5C"},{id:"impact",label:"Impact / ESG",icon:"◈",color:"#C85C5C"}];function A(_){var w=Object.assign({},n,_);p4(w),r&&r(w),g(!0),setTimeout(function(){g(!1)},1800)}var j=y.filter(function(_){return _.id===n.riskAppetite})[0]||y[1],E=k.filter(function(_){return _.id===n.primaryGoal})[0]||null;function C(_){c(_),v("profile.tab.opened",_)}return(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden",background:"#080B11"},children:[(0,e.jsxs)("div",{style:{padding:"0 28px",borderBottom:"1px solid #0D1520",background:"#080B11",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0,height:"56px"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"18px"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"9px"},children:[(0,e.jsx)("div",{style:{width:"24px",height:"24px",background:"rgba(212,175,92,0.1)",border:"1px solid rgba(212,175,92,0.2)",borderRadius:"6px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",color:"#D4AF5C"},children:"◉"}),(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"10px",color:"#C9D1D9",letterSpacing:"0.14em",fontWeight:700},children:"PRINCIPAL PROFILE"})]}),(0,e.jsx)("div",{style:{width:"1px",height:"16px",background:"#0D1520"}}),(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"9px",color:"#5A7090",letterSpacing:"0.06em"},children:"Intelligence configuration & memory"})]}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[p&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px",fontFamily:"monospace",fontSize:"8px",color:"#3FB950",letterSpacing:"0.08em"},children:[(0,e.jsx)("span",{children:"✓"})," SAVED"]}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"5px",padding:"4px 10px",background:"rgba(63,185,80,0.05)",border:"1px solid rgba(63,185,80,0.15)",borderRadius:"5px",fontFamily:"monospace",fontSize:"8px",color:"#3FB950"},children:[(0,e.jsx)("div",{style:{width:"5px",height:"5px",borderRadius:"50%",background:"#3FB950",animation:"xpulse 2s infinite"}}),a.totalExchanges||0," EXCHANGES"]})]})]}),(0,e.jsxs)("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[(0,e.jsxs)("div",{style:{width:"240px",flexShrink:0,borderRight:"1px solid #0D1520",background:"#020408",display:"flex",flexDirection:"column",overflow:"auto"},children:[(0,e.jsxs)("div",{style:{padding:"24px 18px 18px",display:"flex",flexDirection:"column",alignItems:"center",borderBottom:"1px solid #0A0F18"},children:[(0,e.jsx)("div",{style:{width:"72px",height:"72px",borderRadius:"18px",background:"linear-gradient(135deg,rgba(212,175,92,0.2),rgba(212,175,92,0.06))",border:"1px solid rgba(212,175,92,0.2)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"28px",color:"#D4AF5C",marginBottom:"12px",fontWeight:900},children:(n.name||"P").charAt(0).toUpperCase()}),(0,e.jsx)("div",{style:{fontSize:"14px",fontWeight:700,color:"#C9D1D9",marginBottom:"3px",textAlign:"center"},children:n.name||"Principal"}),(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#5A7090",marginBottom:"10px",textAlign:"center"},children:n.role||"Family Office Principal"}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:"3px 10px",background:j.color+"10",border:"1px solid "+j.color+"20",borderRadius:"4px"},children:[(0,e.jsx)("div",{style:{width:"5px",height:"5px",borderRadius:"50%",background:j.color}}),(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:"8px",color:j.color,fontWeight:700},children:j.label.toUpperCase()})]})]}),(0,e.jsxs)("div",{style:{padding:"14px 14px 6px"},children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#6A8098",letterSpacing:"0.16em",marginBottom:"10px"},children:"INTELLIGENCE STATS"}),[{label:"Known Facts",value:(a.facts||[]).length,color:"#D4AF5C",icon:"◈"},{label:"Preferences",value:(a.preferences||[]).length,color:"#D4AF5C",icon:"◎"},{label:"Decisions",value:(a.decisions||[]).length,color:"#3FB950",icon:"✓"},{label:"Total Exchanges",value:a.totalExchanges||0,color:"#B0BCC8",icon:"◉"}].map(function(_,w){return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"8px 0",borderBottom:"1px solid #0A0F18"},children:[(0,e.jsx)("div",{style:{width:"24px",height:"24px",borderRadius:"5px",background:_.color+"10",border:"1px solid "+_.color+"18",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",color:_.color,flexShrink:0},children:_.icon}),(0,e.jsx)("div",{style:{flex:1},children:(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#5A7090"},children:_.label})}),(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"13px",color:_.value>0?_.color:"#2A3A50",fontWeight:700},children:_.value})]},w)})]}),(0,e.jsx)("div",{style:{padding:"14px 10px",marginTop:"auto",borderTop:"1px solid #0A0F18"},children:[{id:"profile",label:"Profile"},{id:"memory",label:"AI Memory"},{id:"security",label:"Security"}].map(function(_){var w=s===_.id;return(0,e.jsxs)("button",{onClick:function(){C(_.id)},style:{display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"8px 10px",background:w?"rgba(212,175,92,0.05)":"transparent",border:"1px solid "+(w?"rgba(212,175,92,0.2)":"transparent"),borderRadius:"6px",cursor:"pointer",fontFamily:"monospace",fontSize:"9px",color:w?"#C9D1D9":"#5A7090",textAlign:"left",marginBottom:"2px",transition:"all 0.12s"}
331,onMouseEnter:function(O){w||(O.currentTarget.style.background="#050810",O.currentTarget.style.borderColor="#0D1520")},onMouseLeave:function(O){w||(O.currentTarget.style.background="transparent",O.currentTarget.style.borderColor="transparent")},children:[w&&(0,e.jsx)("div",{style:{width:"3px",height:"14px",background:"#D4AF5C",borderRadius:"2px",flexShrink:0}}),_.label]},_.id)})})]}),(0,e.jsxs)("div",{style:{flex:1,overflow:"auto",padding:"24px 32px"},children:[s==="profile"&&(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"24px"},children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#6A8098",letterSpacing:"0.16em",marginBottom:"14px",display:"flex",alignItems:"center",gap:"8px"},children:[(0,e.jsx)("span",{children:"IDENTITY"}),(0,e.jsx)("div",{style:{flex:1,height:"1px",background:"#0A0F18"}})]}),(0,e.jsx)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"10px"},children:[{label:"Full Name",key:"name",placeholder:"e.g. James Arenberg"},{label:"Role",key:"role",placeholder:"e.g. Principal / CIO"},{label:"Entity",key:"entity",placeholder:"e.g. Arenberg Family Office"},{label:"Jurisdiction",key:"jurisdiction",placeholder:"e.g. Jersey / UK"}].map(function(_){return(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#5A7090",marginBottom:"5px",letterSpacing:"0.06em"},children:_.label}),(0,e.jsx)("input",{value:n[_.key]||"",onChange:function(w){A({[_.key]:w.target.value})},placeholder:_.placeholder,style:{width:"100%",background:"#050810",border:"1px solid #0D1520",borderRadius:"7px",padding:"9px 12px",color:"#C9D1D9",fontSize:"12px",outline:"none",boxSizing:"border-box",fontFamily:"sans-serif"},onFocus:function(w){w.target.style.borderColor="rgba(212,175,92,0.35)",w.target.style.background="#070B10"},onBlur:function(w){w.target.style.borderColor="#0D1520",w.target.style.background="#050810",w.target.value.trim()&&v("profile.identity.updated",_.label)}})]},_.key)})})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#6A8098",letterSpacing:"0.16em",marginBottom:"14px",display:"flex",alignItems:"center",gap:"8px"},children:[(0,e.jsx)("span",{children:"RISK APPETITE"}),(0,e.jsx)("div",{style:{flex:1,height:"1px",background:"#0A0F18"}})]}),(0,e.jsx)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:y.map(function(_){var w=n.riskAppetite===_.id;return(0,e.jsxs)("button",{onClick:function(){A({riskAppetite:_.id}),v("profile.risk_appetite.changed",_.label)},style:{padding:"14px",background:w?_.color+"08":"#050810",border:"1px solid "+(w?_.color+"35":"#0D1520"),borderRadius:"9px",cursor:"pointer",textAlign:"left",transition:"all 0.15s",position:"relative",overflow:"hidden"},onMouseEnter:function(O){w||(O.currentTarget.style.background="#070B10",O.currentTarget.style.borderColor="#1E2838")},onMouseLeave:function(O){w||(O.currentTarget.style.background="#050810",O.currentTarget.style.borderColor="#0D1520")},children:[w&&(0,e.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",background:_.color,opacity:.7}}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"6px"},children:[(0,e.jsx)("div",{style:{width:"8px",height:"8px",borderRadius:"50%",background:w?_.color:"#1E2838",transition:"background 0.15s",flexShrink:0}}),(0,e.jsx)("div",{style:{fontSize:"12px",color:w?_.color:"#7A90A8",fontWeight:700},children:_.label})]}),(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:w?"#5A7090":"#2A3A50",lineHeight:"1.6"},children:_.desc})]},_.id)})})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#6A8098",letterSpacing:"0.16em",marginBottom:"14px",display:"flex",alignItems:"center",gap:"8px"},children:[(0,e.jsx)("span",{children:"PRIMARY INVESTMENT GOAL"}),(0,e.jsx)("div",{style:{flex:1,height:"1px",background:"#0A0F18"}})]}),(0,e.jsx)("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap"},children:k.map(function(_){var w=n.primaryGoal===_.id;return(0,e.jsxs)("button",{onClick:function(){A({primaryGoal:_.id}),v("profile.goal.changed",_.label)},style:{display:"flex",alignItems:"center",gap:"7px",padding:"7px 14px",background:w?_.color+"10":"#050810",border:"1px solid "+(w?_.color+"35":"#0D1520"),borderRadius:"6px",cursor:"pointer",fontFamily:"monospace",fontSize:"9px",color:w?_.color:"#5A7090",transition:"all 0.15s"}
331,onMouseEnter:function(O){w||(O.currentTarget.style.background="#070B10",O.currentTarget.style.borderColor="#1E2838")},onMouseLeave:function(O){w||(O.currentTarget.style.background="#050810",O.currentTarget.style.borderColor="#0D1520")},children:[(0,e.jsx)("span",{style:{fontSize:"10px"},children:_.icon}),_.label]},_.id)})}),E&&(0,e.jsxs)("div",{style:{marginTop:"10px",padding:"10px 14px",background:"#050810",border:"1px solid #0D1520",borderRadius:"7px",fontFamily:"monospace",fontSize:"9px",color:"#5A7090"},children:["Active: ",(0,e.jsx)("span",{style:{color:E.color},children:E.label})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#6A8098",letterSpacing:"0.16em",marginBottom:"10px",display:"flex",alignItems:"center",gap:"8px"},children:[(0,e.jsx)("span",{children:"ADDITIONAL CONTEXT"}),(0,e.jsx)("div",{style:{flex:1,height:"1px",background:"#0A0F18"}})]}),(0,e.jsx)("textarea",{value:n.notes||"",onChange:function(_){A({notes:_.target.value})},placeholder:"Additional context for Xyron — e.g. family considerations, liquidity events, regulatory constraints, upcoming transitions...",rows:4,style:{width:"100%",background:"#050810",border:"1px solid #0D1520",borderRadius:"7px",padding:"10px 12px",color:"#C9D1D9",fontSize:"12px",lineHeight:"1.7",resize:"vertical",outline:"none",fontFamily:"sans-serif",boxSizing:"border-box"},onFocus:function(_){_.target.style.borderColor="rgba(212,175,92,0.35)"},onBlur:function(_){_.target.style.borderColor="#0D1520",_.target.value.trim()&&v("profile.notes.updated","Additional Context")}})]})]}),s==="memory"&&(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"22px"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontSize:"15px",fontWeight:700,color:"#8FA3B8",marginBottom:"4px"},children:"AI Intelligence Memory"}),(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"9px",color:"#5A7090",lineHeight:"1.7"},children:"Xyron extracts structured intelligence from your conversations — facts, preferences, and decisions — to personalise every response."})]}),h?(0,e.jsxs)("div",{style:{display:"flex",gap:"6px",marginLeft:"20px",flexShrink:0},children:[(0,e.jsx)("button",{onClick:function(){o&&o(),x(!1),v("profile.memory.cleared","AI memory cleared by user")},style:{padding:"6px 12px",background:"rgba(200,92,92,0.1)",border:"1px solid rgba(200,92,92,0.3)",borderRadius:"6px",cursor:"pointer",fontFamily:"monospace",fontSize:"8px",color:"#C85C5C"},children:"CONFIRM"}),(0,e.jsx)("button",{onClick:function(){x(!1)},style:{padding:"6px 12px",background:"#050810",border:"1px solid #0D1520",borderRadius:"6px",cursor:"pointer",fontFamily:"monospace",fontSize:"8px",color:"#5A7090"},children:"CANCEL"})]}):(0,e.jsx)("button",{onClick:function(){x(!0)},style:{padding:"6px 14px",background:"transparent",border:"1px solid rgba(200,92,92,0.2)",borderRadius:"6px",cursor:"pointer",fontFamily:"monospace",fontSize:"8px",color:"#C85C5C",flexShrink:0,marginLeft:"20px",letterSpacing:"0.06em"},onMouseEnter:function(_){_.currentTarget.style.background="rgba(200,92,92,0.06)"},onMouseLeave:function(_){_.currentTarget.style.background="transparent"},children:"CLEAR MEMORY"})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#6A8098",letterSpacing:"0.16em",marginBottom:"12px",display:"flex",alignItems:"center",gap:"8px"},children:[(0,e.jsx)("span",{style:{color:"#D4AF5C"},children:"◈"}),(0,e.jsx)("span",{children:"KNOWN FACTS"}),(0,e.jsxs)("span",{style:{color:"#3A5060"},children:["(",(a.facts||[]).length,")"]}),(0,e.jsx)("div",{style:{flex:1,height:"1px",background:"#0A0F18"}})]}),(a.facts||[]).length===0?(0,e.jsx)("div",{style:{padding:"14px",background:"#050810",border:"1px solid #0A0F18",borderRadius:"8px",fontFamily:"monospace",fontSize:"9px",color:"#3A5060",textAlign:"center"},children:"No facts extracted yet — start a conversation to build your profile."}):(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"5px"},children:(a.facts||[]).map(function(_,w){return(0,e.jsxs)("div",{style:{display:"flex",gap:"10px",padding:"10px 12px",background:"#050810",border:"1px solid #0D1520",borderRadius:"7px",alignItems:"flex-start"},children:[(0,e.jsx)("span",{style:{color:"#D4AF5C",fontSize:"9px",flexShrink:0,marginTop:"2px"},children:"›"}),(0,e.jsx)("span",{style:{fontSize:"12px",color:"#8FA3B8",lineHeight:"1.6"},children:_})]},w)})})]}),(a.preferences||[]).length>0&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#6A8098",letterSpacing:"0.16em",marginBottom:"12px",display:"flex",alignItems:"center",gap:"8px"},children:[(0,e.jsx)("span",{style:{color:"#D4AF5C"},children:"◎"}),(0,e.jsx)("span",{children:"PREFERENCES"}),(0,e.jsxs)("span",{style:{color:"#3A5060"},children:["(",(a.preferences||[]).length,")"]}),(0,e.jsx)("div",{style:{flex:1,height:"1px",background:"#0A0F18"}})]}),(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"5px"},children:(a.preferences||[]).map(function(_,w){return(0,e.jsxs)("div",{style:{display:"flex",gap:"10px",padding:"10px 12px",background:"rgba(212,175,92,0.04)",border:"1px solid rgba(212,175,92,0.1)",borderRadius:"7px",alignItems:"flex-start"},children:[(0,e.jsx)("span",{style:{color:"#D4AF5C",fontSize:"9px",flexShrink:0,marginTop:"2px"},children:"◎"}),(0,e.jsx)("span",{style:{fontSize:"12px",color:"#8FA3B8",lineHeight:"1.6"},children:_})]},w)})})]}),(a.decisions||[]).length>0&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#6A8098",letterSpacing:"0.16em",marginBottom:"12px",display:"flex",alignItems:"center",gap:"8px"},children:[(0,e.jsx)("span",{style:{color:"#3FB950"},children:"✓"}),(0,e.jsx)("span",{children:"RECENT DECISIONS"}),(0,e.jsxs)("span",{style:{color:"#3A5060"},children:["(",(a.decisions||[]).length,")"]}),(0,e.jsx)("div",{style:{flex:1,height:"1px",background:"#0A0F18"}})]}),(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"5px"},children:(a.decisions||[]).map(function(_,w){return(0,e.jsxs)("div",{style:{display:"flex",gap:"10px",padding:"10px 12px",background:"rgba(63,185,80,0.04)",border:"1px solid rgba(63,185,80,0.1)",borderRadius:"7px",alignItems:"flex-start"},children:[(0,e.jsx)("span",{style:{color:"#3FB950",fontSize:"10px",flexShrink:0,marginTop:"1px"},children:"✓"}),(0,e.jsx)("span",{style:{fontSize:"12px",color:"#8FA3B8",lineHeight:"1.6"},children:_})]},w)})})]})]}),s==="security"&&(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"20px"},children:[(0,e.jsx)("div",{style:{fontSize:"15px",fontWeight:700,color:"#8FA3B8",marginBottom:"4px"},children:"Security & Privacy"}),[{label:"Encryption",value:"AES-256 at rest and in transit",status:"ACTIVE",color:"#3FB950"},{label:"Training Mode",value:"Zero-training — no data used for model training",status:"ENFORCED",color:"#3FB950"},{label:"Data Residency",value:"GCP europe-west1 (Belgium)",status:"COMPLIANT",color:"#3FB950"},{label:"Audit Logging",value:"All queries and vault access logged",status:"ON",color:"#3FB950"}].concat(cA()).map(function(_,w){return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"14px",padding:"14px 16px",background:"#050810",border:"1px solid #0D1520",borderRadius:"9px"},children:[(0,e.jsx)("div",{style:{width:"7px",height:"7px",borderRadius:"50%",background:_.color,flexShrink:0,boxShadow:"0 0 6px "+_.color+"60"}}),(0,e.jsxs)("div",{style:{flex:1},children:[(0,e.jsx)("div",{style:{fontSize:"12px",color:"#8FA3B8",fontWeight:600,marginBottom:"2px"},children:_.label}),(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"9px",color:"#5A7090"},children:_.value})]}),(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:_.color,background:_.color+"0D",border:"1px solid "+_.color+"25",borderRadius:"3px",padding:"2px 8px",flexShrink:0},children:_.status})]},_.id||w)}),(0,e.jsx)("div",{style:{padding:"14px 16px",background:"rgba(212,175,92,0.04)",border:"1px solid rgba(212,175,92,0.1)",borderRadius:"9px",fontFamily:"monospace",fontSize:"9px",color:"#5A7090",lineHeight:"1.8"},children:"Xyron Intelligence operates in a sovereign AI configuration. No conversation data, portfolio data, or vault documents are shared with third-party model providers. All inference runs within the Arenberg GCP boundary."})]})]})]})]})}function fz(t){var n=t.onClose,r=t.onRunCompare,o=(0,i.useState)(""),a=o[0],l=o[1],s=(0,i.useState)(""),c=s[0],d=s[1],p=(0,i.useState)("risk clauses"),g=p[0],f=p[1],h=RS.map(function(x){return x.name});return(0,e.jsx)("div",{style:{position:"fixed",inset:0,zIndex:300,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.75)"},onClick:function(x){x.target===x.currentTarget&&n()},children:(0,e.jsxs)("div",{style:{width:"500px",background:"#0A0E14",border:"1px solid #2A3548",borderRadius:"14px",overflow:"hidden",boxShadow:"0 24px 64px rgba(0,0,0,0.8)"},children:[(0,e.jsxs)("div",{style:{padding:"18px 22px",borderBottom:"1px solid #111820",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#D4AF5C",letterSpacing:"0.16em",marginBottom:"3px"},children:"◈ DOCUMENT COMPARISON"}),(0,e.jsx)("div",{style:{fontWeight:800,fontSize:"17px",color:"#E6EDF3"},children:"Redline Analysis"})]}),(0,e.jsx)("button",{onClick:n,style:{background:"transparent",border:"1px solid #2A3548",borderRadius:"6px",cursor:"pointer",color:"#7A8A9E",fontSize:"14px",width:"28px",height:"28px",display:"flex",alignItems:"center",justifyContent:"center"}
331,onMouseEnter:function(x){x.currentTarget.style.color="#C85C5C"},onMouseLeave:function(x){x.currentTarget.style.color="#7A8A9E"},children:"✕"})]}),(0,e.jsxs)("div",{style:{padding:"20px 22px",display:"flex",flexDirection:"column",gap:"16px"},children:[h.length===0&&(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"9px",color:"#7A8A9E",border:"1px solid #2A3548",borderRadius:"7px",padding:"9px 12px",lineHeight:1.5},children:"No verified vault documents are available. Upload or connect documents before running a comparison."}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#7A8A9E",letterSpacing:"0.12em",marginBottom:"7px"},children:"DOCUMENT A (baseline)"}),(0,e.jsxs)("select",{value:a,onChange:function(x){l(x.target.value)},style:{width:"100%",background:"#0D1117",border:"1px solid #2A3548",borderRadius:"7px",padding:"9px 12px",color:a?"#E6EDF3":"#6B7A94",fontSize:"12px",outline:"none",cursor:"pointer"},onFocus:function(x){x.target.style.borderColor="#D4AF5C"},onBlur:function(x){x.target.style.borderColor="#2A3548"},children:[(0,e.jsx)("option",{value:"",children:h.length?"Select document...":"No verified documents available"}),h.map(function(x){return(0,e.jsx)("option",{value:x,children:x},x)})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#7A8A9E",letterSpacing:"0.12em",marginBottom:"7px"},children:"DOCUMENT B (compare to)"}),(0,e.jsxs)("select",{value:c,onChange:function(x){d(x.target.value)},style:{width:"100%",background:"#0D1117",border:"1px solid #2A3548",borderRadius:"7px",padding:"9px 12px",color:c?"#E6EDF3":"#6B7A94",fontSize:"12px",outline:"none",cursor:"pointer"},onFocus:function(x){x.target.style.borderColor="#D4AF5C"},onBlur:function(x){x.target.style.borderColor="#2A3548"},children:[(0,e.jsx)("option",{value:"",children:h.length?"Select document...":"No verified documents available"}),h.map(function(x){return(0,e.jsx)("option",{value:x,children:x},x)})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#7A8A9E",letterSpacing:"0.12em",marginBottom:"8px"},children:"ANALYSIS FOCUS"}),(0,e.jsx)("div",{style:{display:"flex",gap:"5px",flexWrap:"wrap"},children:["risk clauses","financial terms","obligations & deadlines","representations & warranties","termination rights","general comparison"].map(function(x){var v=g===x;return(0,e.jsx)("button",{onClick:function(){f(x)},style:{padding:"4px 10px",background:v?"rgba(212,175,92,0.12)":"transparent",border:"1px solid "+(v?"rgba(212,175,92,0.4)":"#2A3548"),borderRadius:"4px",cursor:"pointer",fontFamily:"monospace",fontSize:"8px",color:v?"#D4AF5C":"#7A8A9E"},children:x},x)})})]}),(0,e.jsx)("button",{onClick:function(){a&&c&&a!==c&&(r(a,c,g),n())},disabled:!a||!c||a===c,style:{padding:"10px 0",background:a&&c&&a!==c?"rgba(212,175,92,0.12)":"#141E2A",border:"1px solid "+(a&&c&&a!==c?"rgba(212,175,92,0.4)":"#2A3548"),borderRadius:"8px",cursor:a&&c&&a!==c?"pointer":"not-allowed",fontFamily:"monospace",fontSize:"9px",color:a&&c&&a!==c?"#D4AF5C":"#3A4556",fontWeight:700,letterSpacing:"0.08em"},children:"◈ COMPARE DOCUMENTS"}),a&&c&&a===c&&(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"9px",color:"#C85C5C",textAlign:"center"},children:"Select two different documents"})]})]})})}var Bb=Xg({shell:"xyron"});function g4(t){if(!t)return"&mdash;";var n=String(t).toLowerCase();return n.indexOf("opus")!==-1?"Cortex LLM &mdash; Deep":n.indexOf("sonnet")!==-1?"Cortex LLM &mdash; Standard":n.indexOf("haiku")!==-1?"Cortex LLM &mdash; Fast":"Cortex LLM"}function pz(t){var n=t.auditLog||[],r=t.currentUser,o=t.workspace,a=(0,i.useState)(""),l=a[0],s=a[1],c=(0,i.useState)(""),d=c[0],p=c[1],g=(0,i.useState)(!1),f=g[0],h=g[1],x=(0,i.useState)(["audit","queries","exports","vault_access"]),v=x[0],y=x[1];function k(j){y(function(E){return E.indexOf(j)!==-1?E.filter(function(C){return C!==j}):E.concat([j])})}function A(){h(!0);var j=n.filter(function(U){return l&&U.ts<l||d&&U.ts>d?!1:v.indexOf("audit")!==-1&&U.action.indexOf("query")!==-1||v.indexOf("queries")!==-1&&U.action==="query.executed"||v.
331indexOf("exports")!==-1&&U.action.indexOf("export")!==-1||v.indexOf("vault_access")!==-1&&U.action.indexOf("vault")!==-1?!0:v.indexOf("audit")!==-1}),E=o?o.name:"Family Office",C=r?r.name:"Principal",_=new Date().toLocaleDateString("en-GB",{day:"2-digit",month:"long",year:"numeric"}),w=btoa(JSON.stringify(j).substring(0,200)).substring(0,32),O=window.open("","_blank");if(!O){h(!1);return}var M="<!DOCTYPE html><html><head><meta charset=utf-8><title>Xyron Compliance Pack</title><style>";M+="* { box-sizing:border-box; margin:0; padding:0; } body { font-family:Georgia,serif; background:#fff; color:#1a1a1a; }",M+=".cover { background:#080B11; color:#E6EDF3; padding:60px 50px; min-height:280px; display:flex; flex-direction:column; justify-content:space-between; page-break-after:always; }",M+=".logo { font-size:32px; font-weight:900; color:#D4AF5C; letter-spacing:-0.04em; margin-bottom:4px; }",M+=".badge { display:inline-block; padding:3px 10px; border:1px solid rgba(63,185,80,0.4); border-radius:4px; font-family:monospace; font-size:10px; color:#3FB950; margin-bottom:20px; }",M+=".content { max-width:740px; margin:0 auto; padding:40px; }",M+="h2 { font-family:monospace; font-size:11px; letter-spacing:0.14em; text-transform:uppercase; color:#888; margin:28px 0 10px; border-bottom:1px solid #eee; padding-bottom:6px; }",M+="table { width:100%; border-collapse:collapse; margin-bottom:20px; font-size:11px; }",M+="th { background:#f5f5f0; padding:8px 10px; text-align:left; font-family:monospace; font-size:9px; letter-spacing:0.08em; color:#666; border:1px solid #e5e5e0; }",M+="td { padding:8px 10px; border:1px solid #eee; vertical-align:top; }",M+="tr:nth-child(even) td { background:#fafafa; }",M+=".hash { font-family:monospace; font-size:9px; color:#999; word-break:break-all; }",M+=".footer { text-align:center; padding:20px; font-family:monospace; font-size:9px; color:#bbb; border-top:1px solid #eee; margin-top:30px; }",M+="@media print { .cover { -webkit-print-color-adjust:exact; print-color-adjust:exact; } }",M+="</style></head><body>",M+="<div class='cover'>",M+="<div><div class='logo'>XYRON</div><div style='font-family:monospace;font-size:10px;color:#7A8A9E;letter-spacing:0.2em'>INTELLIGENCE TERMINAL</div></div>",M+="<div><span class='badge'>COMPLIANCE EVIDENCE PACK</span><h1 style='font-size:24px;font-weight:800;margin-bottom:10px'>Regulatory & Audit Evidence Package</h1>",M+="<p style='font-family:monospace;font-size:11px;color:#8B949E'>"+E+" &nbsp;&middot;&nbsp; Prepared for: "+C+" &nbsp;&middot;&nbsp; Generated: "+_+"</p></div>",M+="<div style='font-family:monospace;font-size:9px;color:#6B7A94;border-top:1px solid #2A3548;padding-top:14px'>DOCUMENT INTEGRITY HASH: <span style='color:#7A8A9E'>"+w+"</span><br>AES-256 ENCRYPTED &nbsp;&middot;&nbsp; APPEND-ONLY AUDIT TRAIL &nbsp;&middot;&nbsp; "+Bb+"</div></div>",M+="<div class='content'>",M+="<h2>EXECUTIVE SUMMARY</h2>",M+="<table><tr><th>METRIC</th><th>VALUE</th></tr>",M+="<tr><td>Total events in period</td><td>"+j.length+"</td></tr>",M+="<tr><td>Workspace</td><td>"+E+"</td></tr>",M+="<tr><td>Prepared by</td><td>"+C+(r?" ("+r.role+")":"")+"</td></tr>",M+="<tr><td>Report generated</td><td>"+_+" "+FS()+"</td></tr>",M+="<tr><td>AI models in use</td><td>Cortex LLM &mdash; Arenberg AI proprietary stack ("+Bb+"). Zero-training mode enforced.</td></tr>",M+="<tr><td>Data residency</td><td>GCP (europe-west1) &mdash; No data leaves GCP boundary</td></tr>",M+="</table>",j.length>0&&(M+="<h2>AUDIT TRAIL ("+j.length+" EVENTS)</h2>",M+="<table><tr><th>TIMESTAMP</th><th>ACTION</th><th>DETAIL</th><th>ENGINE</th><th>LATENCY</th></tr>",j.forEach(function(U){M+="<tr><td>"+(U.tsDisplay||U.ts||"")+"</td><td style='font-family:monospace;font-size:9px'>"+(U.action||"")+"</td><td>"+(U.detail||"&mdash;").substring(0,80)+"</td><td style='font-family:monospace;font-size:9px'>"+g4(U.model)+"</td><td style='font-family:monospace;font-size:9px;color:"+(U.latency_ms>2e3?"#c00":U.latency_ms>1e3?"#c60":"#060")+";'>"+(U.latency_ms?U.latency_ms+"ms":"&mdash;")+"</td></tr>"}),M+="</table>"),M+="<h2>CERTIFICATION</h2>",M+="<p style='font-size:12px;line-height:1.8;margin-bottom:12px'>This compliance evidence pack was automatically generated by Xyron Intelligence Terminal. All data is sourced from the append-only audit trail (audit_trail.audit_events) maintained in Google BigQuery. No records have been modified, deleted, or retroactively altered.</p>",M+="<p class='hash'>Document hash: "+w+"<br>Generated: "+new Date().toISOString()+"</p>",M+="<div class='footer'>XYRON INTELLIGENCE &nbsp;&middot;&nbsp; Confidential &nbsp;&middot;&nbsp; "+E+"</div></div></body></html>",O.document.write(M),O.document.close(),setTimeout(function(){O.print(),h(!1)}
331,600),oi({action:"compliance.pack.generated",detail:j.length+" events",model:"export"})}return(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,e.jsxs)("div",{style:{padding:"14px 22px",borderBottom:"1px solid #111820",background:"#05080D",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"14px"},children:[(0,e.jsx)("div",{style:{fontWeight:800,fontSize:"16px",color:"#D4AF5C"},children:"XYRON"}),(0,e.jsx)("div",{style:{width:"1px",height:"14px",background:"#1E2838"}}),(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"9px",color:"#8B949E",letterSpacing:"0.1em"},children:"COMPLIANCE EVIDENCE PACK"})]}),(0,e.jsxs)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#3FB950",padding:"3px 8px",background:"rgba(63,185,80,0.07)",border:"1px solid rgba(63,185,80,0.2)",borderRadius:"4px"},children:[n.length," EVENTS AVAILABLE"]})]}),(0,e.jsxs)("div",{style:{flex:1,overflow:"auto",padding:"22px"},children:[(0,e.jsxs)("div",{style:{background:"rgba(212,175,92,0.05)",border:"1px solid rgba(212,175,92,0.15)",borderRadius:"9px",padding:"14px 16px",marginBottom:"22px"},children:[(0,e.jsx)("div",{style:{fontWeight:700,fontSize:"13px",color:"#D4AF5C",marginBottom:"6px"},children:"Regulatory Evidence Package"}),(0,e.jsx)("div",{style:{fontSize:"12px",color:"#8B949E",lineHeight:"1.7"},children:"Generate a tamper-evident compliance report suitable for GDPR subject access requests, FCA/SEC audit responses, and internal governance reviews. Includes the full append-only audit trail with document integrity hash."})]}),(0,e.jsxs)("div",{style:{marginBottom:"18px"},children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#7A8A9E",letterSpacing:"0.14em",marginBottom:"8px"},children:"DATE RANGE (optional)"}),(0,e.jsxs)("div",{style:{display:"flex",gap:"10px",alignItems:"center"},children:[(0,e.jsx)("input",{type:"date",value:l,onChange:function(j){s(j.target.value)},style:{flex:1,background:"#0C1018",border:"1px solid #2A3548",borderRadius:"6px",padding:"8px 12px",color:l?"#E6EDF3":"#6B7A94",fontFamily:"monospace",fontSize:"11px",outline:"none"},onFocus:function(j){j.target.style.borderColor="#D4AF5C"},onBlur:function(j){j.target.style.borderColor="#2A3548"}}),(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:"10px",color:"#6B7A94"},children:"to"}),(0,e.jsx)("input",{type:"date",value:d,onChange:function(j){p(j.target.value)},style:{flex:1,background:"#0C1018",border:"1px solid #2A3548",borderRadius:"6px",padding:"8px 12px",color:d?"#E6EDF3":"#6B7A94",fontFamily:"monospace",fontSize:"11px",outline:"none"},onFocus:function(j){j.target.style.borderColor="#D4AF5C"},onBlur:function(j){j.target.style.borderColor="#2A3548"}}),(l||d)&&(0,e.jsx)("button",{onClick:function(){s(""),p("")},style:{padding:"7px 12px",background:"transparent",border:"1px solid #2A3548",borderRadius:"5px",cursor:"pointer",fontFamily:"monospace",fontSize:"8px",color:"#7A8A9E"},children:"CLEAR"})]})]}),(0,e.jsxs)("div",{style:{marginBottom:"22px"},children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#7A8A9E",letterSpacing:"0.14em",marginBottom:"10px"},children:"INCLUDE IN PACK"}),(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:[{id:"audit",label:"Full Audit Trail",desc:"All system events"},{id:"queries",label:"Query Log",desc:"All chat questions asked"},{id:"exports",label:"Export History",desc:"Documents and reports generated"},{id:"vault_access",label:"Vault Access Log",desc:"Document reads and uploads"}].map(function(j){var E=v.indexOf(j.id)!==-1;return(0,e.jsxs)("button",{onClick:function(){k(j.id)},style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",background:E?"rgba(212,175,92,0.05)":"#0C1018",border:"1px solid "+(E?"rgba(212,175,92,0.25)":"#2A3548"),borderRadius:"7px",cursor:"pointer",textAlign:"left"},children:[(0,e.jsx)("div",{style:{width:"16px",height:"16px",border:"1px solid "+(E?"#D4AF5C":"#3A4556"),borderRadius:"4px",background:E?"#D4AF5C":"transparent",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:E&&(0,e.jsx)("span",{style:{color:"#000",fontSize:"11px",fontWeight:900,lineHeight:1},children:"✓"})}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontSize:"12px",color:E?"#C9D1D9":"#7A8A9E",fontWeight:600},children:j.label}),(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#6B7A94"},children:j.desc})]})]},j.id)})})]}),(0,e.jsx)("button",{onClick:A,disabled:f||v.length===0,style:{width:"100%",padding:"12px 0",background:f||v.length===0?"#141E2A":"rgba(212,175,92,0.1)",border:"1px solid "+(v.length>0&&!f?"rgba(212,175,92,0.4)":"#2A3548"),borderRadius:"9px",cursor:v.length>0&&!f?"pointer":"not-allowed",fontFamily:"monospace",fontSize:"10px",fontWeight:700,color:v.length>0&&!f?"#D4AF5C":"#3A4556",letterSpacing:"0.1em",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:f?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:{width:"12px",height:"12px",border:"1px solid rgba(212,175,92,0.3)",borderTop:"1px solid #D4AF5C",borderRadius:"50%",animation:"xspin 0.8s linear infinite"}})," GENERATING..."]}):"&#128196; GENERATE COMPLIANCE PACK (PDF)"})]})]})}function gz(t){var n=t.projects||[],r=t.getProjectSessions||function(){return[]},o=(0,i.useState)(n.map(function(P){return P.id})),a=o[0],l=o[1],s=(0,i.useState)("overview"),c=s[0],d=s[1],p=(0,i.useState)(""),g=p[0],f=p[1],h=(0,i.useState)(!1),x=h[0],v=h[1],y=(0,i.useState)([]),k=y[0],A=y[1],j=(0,i.useState)(!1),E=j[0],C=j[1],_=(0,i.useState)(""),w=_[0],O=_[1],M=[{id:"overview",icon:"◎",color:"#D4AF5C",label:"Weekly Brief",desc:"Executive summary of all project activity and priorities"}
331,{id:"risks",icon:"⚠",color:"#C85C5C",label:"Risk Consolidation",desc:"Top cross-portfolio risks ranked by severity and urgency"},{id:"actions",icon:"◈",color:"#3FB950",label:"Action Items",desc:"All pending decisions and next steps by urgency tier"},{id:"conflicts",icon:"⊗",color:"#D4AF5C",label:"Conflict Detection",desc:"Inconsistencies and contradictions across project scopes"},{id:"signals",icon:"▲",color:"#B0BCC8",label:"Market Signals",desc:"Extract market-relevant data points from all project knowledge"},{id:"board",icon:"▣",color:"#C85C5C",label:"Board Pack",desc:"Board-ready synthesis with NAV, risk, and strategic context"}],U={overview:`Generate a weekly executive intelligence briefing across all projects. Structure:
332## WEEKLY BRIEFING
333For each project: one paragraph on status, key activity, risk flags, and next action. End with ## CROSS-PROJECT PRIORITIES listing 3 actions the principal must take this week. Cite project names. Be concise, precise, board-quality.`,risks:`Identify and rank the top cross-portfolio risks across all projects. Format:
334## RISK REGISTER — CROSS-PROJECT
335For each risk: RISK TITLE | Severity (HIGH/MEDIUM/LOW) | Affected projects | Specific trigger | Recommended action. Rank by severity. Minimum 5 risks. Cite [Vault] sources where relevant.`,actions:`Extract all pending actions and decisions across projects. Format:
336## ACTION INTELLIGENCE
337### IMMEDIATE (48 hours)
338### THIS WEEK
339### THIS MONTH
340For each item: action, owning project, context, consequence of inaction. Prioritise ruthlessly.`,conflicts:`Audit all projects for conflicts, inconsistencies, and contradictions. Format:
341## CONFLICT ANALYSIS
342For each conflict: CONFLICT TITLE | Projects in conflict | What conflicts | Risk level | Resolution path. If no conflicts found, flag gaps and misalignments instead.`,signals:`Extract all market-relevant data points, signals, and intelligence from the project knowledge base. Format:
343## MARKET SIGNAL EXTRACTION
344Group by: MACRO | EQUITY | CREDIT | FX | COMMODITIES | ALTERNATIVES. For each signal: what it is, source project, portfolio implication, confidence level.`,board:`Generate a board-pack quality intelligence briefing covering all projects. Format:
345## BOARD INTELLIGENCE PACK
346### EXECUTIVE SUMMARY
347### PORTFOLIO STATUS
348### KEY RISKS (table format)
349### DECISIONS REQUIRED
350### MARKET CONTEXT
351### NEXT ACTIONS
352Use precise figures, cite sources, board-quality language throughout.`};function ee(){if(!(a.length<1)){v(!0),f("");var P=n.filter(function(W){return a.indexOf(W.id)!==-1}).map(function(W){var R=r(W.id);return"PROJECT: "+W.name+`
353Role/Instructions: `+(W.instructions||"none").substring(0,300)+`
354Knowledge Base: `+(W.knowledgeDocs||[]).map(function(ae){return ae&&ae.name?ae.name:ae}).join(", ")+`
355Chat Sessions: `+R.length}).join(`
356
357---
358
359`);gu({model:bg,max_tokens:1500,system:Yy,messages:[{role:"user",content:U[c]+`
360
361PROJECT CONTEXT:
362`+P+`
363
364Today: `+Sf()}]}).then(function(W){var R=W.content&&W.content[0]&&W.content[0].text||"",ae=Sf()+" "+IS();f(R),O(ae),A(function(q){return[{focus:c,projects:a.length,ts:ae,snippet:R.substring(0,80)+"…"}].concat(q).slice(0,8)}),oi({action:"synthesis.run",detail:c+" — "+a.length+" projects",model:bg})}).catch(function(W){f("Error: "+W.message)}).finally(function(){v(!1)})}}function N(){navigator.clipboard&&navigator.clipboard.writeText(g),C(!0),setTimeout(function(){C(!1)},2e3)}function V(P){return P?(0,e.jsx)(ws,{text:P}):null}var z=M.filter(function(P){return P.id===c})[0]||M[0],oe=a.length>=1&&!x;return(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden",background:"#080B11"},children:[(0,e.jsxs)("div",{style:{padding:"0 28px",borderBottom:"1px solid #0D1520",background:"#080B11",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0,height:"56px"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"18px"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"9px"},children:[(0,e.jsx)("div",{style:{width:"24px",height:"24px",background:"rgba(212,175,92,0.1)",border:"1px solid rgba(212,175,92,0.2)",borderRadius:"6px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",color:"#D4AF5C"},children:"◎"}),(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"10px",color:"#C9D1D9",letterSpacing:"0.14em",fontWeight:700},children:"SYNTHESIS"})]}),(0,e.jsx)("div",{style:{width:"1px",height:"16px",background:"#0D1520"}}),(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"9px",color:"#5A7090",letterSpacing:"0.06em"},children:"Cross-project intelligence engine"})]}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"7px",fontFamily:"monospace",fontSize:"8px",color:"#D4AF5C",letterSpacing:"0.1em"},children:[(0,e.jsx)("div",{style:{width:"7px",height:"7px",border:"1px solid rgba(212,175,92,0.3)",borderTop:"1px solid #D4AF5C",borderRadius:"50%",animation:"xspin 0.8s linear infinite"}}),"SYNTHESISING"]}),g&&!x&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:N,style:{display:"flex",alignItems:"center",gap:"5px",padding:"5px 12px",background:E?"rgba(63,185,80,0.1)":"#070B10",border:"1px solid "+(E?"rgba(63,185,80,0.25)":"#0D1520"),borderRadius:"5px",cursor:"pointer",fontFamily:"monospace",fontSize:"8px",color:E?"#3FB950":"#5A6880",letterSpacing:"0.08em"},onMouseEnter:function(P){E||(P.currentTarget.style.borderColor="#4A5E74",P.currentTarget.style.color="#8B949E")},onMouseLeave:function(P){E||(P.currentTarget.style.borderColor="#0D1520",P.currentTarget.style.color="#5A6880")},children:E?"✓ COPIED":"⎘ COPY"}),(0,e.jsx)("button",{onClick:function(){var P=window.open("","_blank");P&&(P.document.write("<!DOCTYPE html><html><head><meta charset=utf-8><title>Xyron Synthesis — "+z.label+"</title><style>body{font-family:Georgia,serif;max-width:780px;margin:60px auto;
364color:#1a1a1a;line-height:1.8}h1,h2,h3{font-family:monospace}pre{white-space:pre-wrap}</style></head><body><h1>XYRON SYNTHESIS</h1><h2>"+z.label+'</h2><p style="color:#888;font-family:monospace;font-size:11px">'+a.length+" projects · "+w+"</p><hr/><pre>"+g+"</pre></body></html>"),P.document.close(),setTimeout(function(){P.print()},400))},style:{display:"flex",alignItems:"center",gap:"5px",padding:"5px 12px",background:"#070B10",border:"1px solid #0D1520",borderRadius:"5px",cursor:"pointer",fontFamily:"monospace",fontSize:"8px",color:"#5A6880",letterSpacing:"0.08em"},onMouseEnter:function(P){P.currentTarget.style.borderColor="#4A5E74",P.currentTarget.style.color="#8B949E"},onMouseLeave:function(P){P.currentTarget.style.borderColor="#0D1520",P.currentTarget.style.color="#5A6880"},children:"↗ EXPORT"})]})]})]}),(0,e.jsxs)("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[(0,e.jsxs)("div",{style:{width:"240px",flexShrink:0,borderRight:"1px solid #0D1520",overflow:"auto",display:"flex",flexDirection:"column",background:"#020408"},children:[(0,e.jsxs)("div",{style:{padding:"16px 14px 10px"},children:[(0,e.jsxs)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#5A7090",letterSpacing:"0.16em",marginBottom:"10px",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,e.jsx)("span",{children:"PROJECTS"}),(0,e.jsxs)("span",{style:{color:"#7A8FA8"},children:[a.length,"/",n.length]})]}),n.length===0&&(0,e.jsxs)("div",{style:{background:"#080B11",border:"1px solid #0D1520",borderRadius:"8px",padding:"14px",textAlign:"center"},children:[(0,e.jsx)("div",{style:{fontSize:"18px",color:"#4A5E74",marginBottom:"6px"},children:"◇"}),(0,e.jsxs)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#4A5E74",lineHeight:"1.7"},children:["No projects yet.",(0,e.jsx)("br",{}),"Create projects first."]})]}),(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:n.map(function(P){var W=a.indexOf(P.id)!==-1,R=r(P.id);return(0,e.jsxs)("button",{onClick:function(){l(function(ae){return W?ae.filter(function(q){return q!==P.id}):ae.concat([P.id])})},style:{display:"flex",alignItems:"center",gap:"9px",padding:"9px 10px",background:W?"rgba(212,175,92,0.04)":"transparent",border:"1px solid "+(W?P.color+"25":"#0D1520"),borderRadius:"7px",cursor:"pointer",textAlign:"left",transition:"all 0.12s"},onMouseEnter:function(ae){W||(ae.currentTarget.style.background="#050810",ae.currentTarget.style.borderColor="#1E2838")},onMouseLeave:function(ae){W||(ae.currentTarget.style.background="transparent",ae.currentTarget.style.borderColor="#0D1520")},children:[(0,e.jsx)("div",{style:{width:"26px",height:"26px",borderRadius:"6px",background:P.color+"12",border:"1px solid "+P.color+"22",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",color:P.color,flexShrink:0},children:P.icon}),(0,e.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,e.jsx)("div",{style:{fontSize:"11px",color:W?"#C9D1D9":"#7A90A8",fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:P.name}),(0,e.jsxs)("div",{style:{fontFamily:"monospace",fontSize:"7px",color:"#5A7090",marginTop:"2px"},children:[R.length," chats · ",(P.knowledgeDocs||[]).length," docs"]})]}),(0,e.jsx)("div",{style:{width:"14px",height:"14px",border:"1px solid "+(W?P.color:"#1E2838"),borderRadius:"3px",background:W?P.color:"transparent",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"all 0.1s"},children:W&&(0,e.jsx)("span",{style:{color:"#000",fontSize:"9px",fontWeight:900,lineHeight:1},children:"✓"})})]},P.id)})})]}),(0,e.jsx)("div",{style:{height:"1px",background:"#0A0F18",margin:"4px 14px"}}),(0,e.jsxs)("div",{style:{padding:"10px 14px",flex:1},children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#5A7090",letterSpacing:"0.16em",marginBottom:"10px"},children:"SYNTHESIS MODE"}),(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"3px"},children:M.map(function(P){var W=c===P.id;return(0,e.jsxs)("button",{onClick:function(){d(P.id)},style:{display:"flex",alignItems:"center",gap:"9px",padding:"9px 10px",background:W?"rgba(212,175,92,0.05)":"transparent",border:"1px solid "+(W?"rgba(212,175,92,0.2)":"transparent"),borderRadius:"7px",cursor:"pointer",textAlign:"left",transition:"all 0.12s"},onMouseEnter:function(R){W||(R.currentTarget.style.background="#050810",R.currentTarget.style.borderColor="#0D1520")},onMouseLeave:function(R){W||(R.currentTarget.style.background="transparent",R.currentTarget.style.borderColor="transparent")},children:[(0,e.jsx)("div",{style:{width:"22px",height:"22px",borderRadius:"5px",background:W?P.color+"18":"#050810",border:"1px solid "+(W?P.color+"30":"#0D1520"),display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",color:W?P.color:"#5A7090",flexShrink:0},children:P.icon}),(0,e.jsx)("div",{style:{flex:1},children:(0,e.jsx)("div",{style:{fontSize:"11px",color:W?"#C9D1D9":"#7A8FA8",fontWeight:W?600:400},children:P.label})}),W&&(0,e.jsx)("div",{style:{width:"4px",height:"4px",borderRadius:"50%",background:"#D4AF5C",flexShrink:0}})]},P.id)})})]}),(0,e.jsxs)("div",{style:{padding:"12px 14px",borderTop:"1px solid #0A0F18"},children:[(0,e.jsx)("button",{onClick:ee,disabled:!oe,style:{width:"100%",padding:"10px 0",background:oe?"#D4AF5C":"#070B10",border:"none",borderRadius:"7px",cursor:oe?"pointer":"not-allowed",fontFamily:"monospace",fontSize:"9px",color:oe?"#000":"#4A5E74",fontWeight:700,letterSpacing:"0.12em",transition:"all 0.15s"},onMouseEnter:function(P){oe&&(P.currentTarget.style.background="#E8920A")},onMouseLeave:function(P){oe&&(P.currentTarget.style.background="#D4AF5C")},children:x?"SYNTHESISING…":"RUN SYNTHESIS →"}),a.length===0&&(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#4A5E74",marginTop:"6px",textAlign:"center"},children:"Select at least 1 project"})]})]}),(0,e.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:[(0,e.jsxs)("div",{style:{padding:"10px 22px",borderBottom:"1px solid #0D1520",background:"#020408",display:"flex",alignItems:"center",gap:"12px",flexShrink:0},children:[(0,e.jsx)("div",{style:{width:"28px",height:"28px",borderRadius:"7px",background:z.color+"12",border:"1px solid "+z.color+"25",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",color:z.color},children:z.icon}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontSize:"12px",color:"#8FA3B8",fontWeight:600},children:z.label}),(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#5A7090",marginTop:"1px"},children:z.desc})]}),w&&(0,e.jsxs)("div",{style:{marginLeft:"auto",fontFamily:"monospace",fontSize:"8px",color:"#5A7090"},children:["Last run: ",w]})]}),(0,e.jsxs)("div",{style:{flex:1,overflow:"auto",padding:"24px 28px"},children:[!g&&!x&&(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",gap:"20px"},children:[(0,e.jsxs)("div",{style:{position:"relative"},children:[(0,e.jsx)("div",{style:{width:"80px",height:"80px",background:"rgba(212,175,92,0.04)",border:"1px solid rgba(212,175,92,0.1)",borderRadius:"18px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"30px",color:"rgba(212,175,92,0.25)"},children:"◎"}),(0,e.jsx)("div",{style:{position:"absolute",inset:"-8px",border:"1px dashed rgba(212,175,92,0.06)",borderRadius:"26px",pointerEvents:"none"}})]}),(0,e.jsxs)("div",{style:{textAlign:"center"},children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"9px",color:"#4A5E74",letterSpacing:"0.2em",marginBottom:"10px"},children:"AWAITING SYNTHESIS"}),(0,e.jsx)("div",{style:{fontSize:"15px",fontWeight:700,color:"#7A8FA8",marginBottom:"8px"},children:"Select projects and run synthesis"}),(0,e.jsxs)("div",{style:{fontFamily:"monospace",fontSize:"9px",color:"#4A5E74",lineHeight:"1.8",maxWidth:"320px",margin:"0 auto"},children:["Choose a synthesis mode from the left panel,",(0,e.jsx)("br",{}),"select the projects to include, then run."]})]}),(0,e.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(3,1fr)",gap:"6px",maxWidth:"480px",width:"100%",marginTop:"10px"},children:M.slice(0,3).map(function(P){return(0,e.jsxs)("button",{onClick:function(){d(P.id)},style:{padding:"10px",background:"#020408",border:"1px solid #0A0F18",borderRadius:"8px",cursor:"pointer",textAlign:"center",transition:"all 0.12s"},onMouseEnter:function(W){W.currentTarget.style.borderColor=P.color+"25",W.currentTarget.style.background="#030608"},onMouseLeave:function(W){W.currentTarget.style.borderColor="#0A0F18",W.currentTarget.style.background="#020408"},children:[(0,e.jsx)("div",{style:{fontSize:"14px",color:P.color,opacity:.5,marginBottom:"5px"},children:P.icon}),(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"7px",color:"#5A7090",letterSpacing:"0.08em"},children:P.label.toUpperCase()})]},P.id)})})]}),x&&(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",gap:"18px"},children:[(0,e.jsxs)("div",{style:{position:"relative",width:"48px",height:"48px"},children:[(0,e.jsx)("div",{style:{position:"absolute",inset:0,border:"1px solid rgba(212,175,92,0.08)",borderRadius:"50%"}}),(0,e.jsx)("div",{style:{position:"absolute",inset:0,border:"2px s
364olid transparent",borderTop:"2px solid #D4AF5C",borderRadius:"50%",animation:"xspin 1s linear infinite"}}),(0,e.jsx)("div",{style:{position:"absolute",inset:"8px",border:"1px solid rgba(212,175,92,0.15)",borderRadius:"50%"}})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"10px",color:"#D4AF5C",letterSpacing:"0.12em",textAlign:"center",marginBottom:"4px"},children:"SYNTHESISING"}),(0,e.jsxs)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#5A7090",textAlign:"center"},children:[a.length," project",a.length!==1?"s":""," · ",z.label]})]})]}),g&&!x&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px",marginBottom:"20px",paddingBottom:"14px",borderBottom:"1px solid #0D1520"},children:[(0,e.jsx)("div",{style:{width:"30px",height:"30px",borderRadius:"7px",background:z.color+"12",border:"1px solid "+z.color+"25",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"13px",color:z.color},children:z.icon}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"9px",color:z.color,letterSpacing:"0.14em",fontWeight:700},children:z.label.toUpperCase()}),(0,e.jsxs)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#5A7090",marginTop:"1px"},children:[a.length," projects · ",w]})]}),(0,e.jsx)("div",{style:{marginLeft:"auto",display:"flex",gap:"6px"},children:["HIGH","MEDIUM","LOW"].map(function(P,W){var R=["#C85C5C","#D4AF5C","#3FB950"][W],ae=g.toLowerCase().split(P.toLowerCase()).length-1;return ae>0?(0,e.jsxs)("div",{style:{fontFamily:"monospace",fontSize:"7px",color:R,background:R+"10",border:"1px solid "+R+"25",borderRadius:"3px",padding:"2px 6px"},children:[ae,"× ",P]},P):null})})]}),(0,e.jsx)("div",{children:V(g)})]})]}),k.length>0&&(0,e.jsx)("div",{style:{borderTop:"1px solid #0A0F18",background:"#020408",padding:"8px 22px",flexShrink:0},children:(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px",overflowX:"auto"},children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"7px",color:"#4A5E74",letterSpacing:"0.12em",flexShrink:0},children:"HISTORY"}),k.map(function(P,W){var R=M.filter(function(ae){return ae.id===P.focus})[0]||M[0];return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:"4px 10px",background:"#030608",border:"1px solid #0A0F18",borderRadius:"5px",flexShrink:0,cursor:"default"},children:[(0,e.jsx)("span",{style:{fontSize:"9px",color:R.color},children:R.icon}),(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:"7px",color:"#7A8FA8"},children:R.label}),(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:"7px",color:"#4A5E74"},children:"·"}),(0,e.jsxs)("span",{style:{fontFamily:"monospace",fontSize:"7px",color:"#5A7090"},children:[P.projects,"P"]}),(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:"7px",color:"#4A5E74"},children:"·"}),(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:"7px",color:"#5A7090"},children:P.ts.split(" ").pop()})]},W)})]})})]})]})]})}function Bp(){return{Authorization:`Bearer ${localStorage.getItem("xyron_jwt_token")||""}`,"X-Xyron-Key":""}}function mz(t,n){const[r,o]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let a=!1;if(!t)return;const l=async()=>{try{const c=await fetch(qr(t),{headers:Bp()});if(c.ok){const d=await c.json();a||o(d&&d.enabled?d:null);return}}catch{}a||o(null)};l();const s=n?setInterval(l,n):null;return()=>{a=!0,s&&clearInterval(s)}},[t,n]),r}function m4(t){const[n,r]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let o=!1;if(t)return(async()=>{try{const a=await fetch(qr(t),{headers:Bp()});if(a.ok){const l=await a.json();o||r(l&&l.enabled?l:null);return}}catch{}o||r(null)})(),()=>{o=!0}},[t]),n}function h4(){const[t,n]=(0,i.useState)(null),r=async()=>{try{const l=await fetch(qr("/api/video/profile/watchlater"),{headers:Bp()});if(l.ok){const s=await l.json();if(s&&s.enabled){n(s.items||[]);return}}}catch{}n(null)};(0,i.useEffect)(()=>{let l=!1;return(async()=>l||await r())(),()=>{l=!0}},[]);const o=t?new Set(t.map(l=>l.video_id)):null;return{savedIds:o,toggle:l=>
364{t&&(o&&o.has(l.videoId)?fetch(qr("/api/video/profile/watchlater/"+encodeURIComponent(l.videoId)),{method:"DELETE",headers:Bp()}):fetch(qr("/api/video/profile/watchlater"),{method:"POST",headers:{"Content-Type":"application/json",...Bp()},body:JSON.stringify({video_id:l.videoId})})).then(()=>r()).catch(()=>{})},items:t}}function y4(){const t=m4("/api/video/rails?limit=50");if(!t)return null;const n=new Set,r=[];return(t.rails||[]).forEach(o=>(o.videos||[]).forEach(a=>{n.has(a.videoId)||(n.add(a.videoId),r.push(a))})),r.length?{key:"all",title:"DESK COVERAGE",videos:r}:null}var jn={bg:"#02040A",border:"rgba(212,175,92,0.15)",accent:"#D4AF5C",accentDim:"rgba(212,175,92,0.08)",text:"#C9D1D9",dim:"#5A7090",card:"rgba(8,12,20,0.95)",cardHover:"rgba(12,18,30,0.98)"},ap=Zn.ui,wo=Zn.mono,x4={MACRO:"MACRO",MARKETS:"MARKETS",CRYPTO:"CRYPTO",REAL_ESTATE:"REAL ESTATE",COMMODITIES:"COMMODITIES",EARNINGS:"EARNINGS",GEOPOLITICAL:"GEOPOLITICAL",LIFESTYLE:"LIFESTYLE"},fh={MACRO:"#D4AF5C",MARKETS:"#6B9AC4",CRYPTO:"#D4AF5C",REAL_ESTATE:"#4ADE80",COMMODITIES:"#FBBF24",EARNINGS:"#6B9AC4",GEOPOLITICAL:"#F87171",LIFESTYLE:"#E879F9"};function my({videoId:t,onClose:n,startAt:r=0}){return(0,e.jsxs)("div",{style:{position:"relative",width:"100%",aspectRatio:"16/9",borderRadius:6,overflow:"hidden",background:"#000",marginBottom:6},children:[(0,e.jsx)("iframe",{src:`https://www.youtube-nocookie.com/embed/${t}?autoplay=1&rel=0&modestbranding=1${r>0?`&start=${r}`:""}`,style:{width:"100%",height:"100%",border:"none"},allow:"autoplay; encrypted-media; picture-in-picture; fullscreen",allowFullScreen:!0},`${t}-${r}`),(0,e.jsx)("button",{onClick:o=>{o.stopPropagation(),n()},style:{position:"absolute",top:6,right:6,width:26,height:26,borderRadius:"50%",background:"rgba(0,0,0,0.75)",border:"1px solid rgba(212,175,92,0.3)",color:"#D4AF5C",fontSize:13,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,fontFamily:Zn.mono},children:"✕"})]})}function v4({card:t,quotes:n}){const r=t.entities||[];return r.length?(0,e.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:6,padding:"6px 2px",alignItems:"center"},children:[(0,e.jsx)("span",{style:{fontSize:8.5,color:jn.dim,fontFamily:wo,letterSpacing:"0.08em"},children:"WATCH CONTEXT"}),r.map(o=>(0,e.jsxs)("span",{style:{fontSize:9.5,fontFamily:wo,color:jn.accent,background:jn.accentDim,border:"1px solid rgba(212,175,92,0.25)",padding:"1px 5px",borderRadius:2,letterSpacing:"0.04em"},children:[o.symbol,typeof n[o.symbol]=="number"&&` · ${n[o.symbol].toFixed(2)}`,o.position_qty!=null&&` · YOU HOLD ${o.position_qty}`]},o.symbol))]}):null}function pg({title:t,videos:n,playingId:r,onPlay:o,onSave:a=null,savedIds:l=null,cardWidth:s=132}){const[c,d]=(0,i.useState)(null),p=280,g=c?Math.max(8,Math.min(c.rect.left,window.innerWidth-p-12)):0,f=c?c.rect.bottom+230<window.innerHeight:!0;return(0,e.jsxs)("div",{style:{marginBottom:10},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",marginBottom:4},children:[(0,e.jsx)("span",{style:{fontSize:9,fontFamily:wo,color:jn.accent,letterSpacing:"0.12em",fontWeight:700},children:t}),(0,e.jsx)("span",{style:{fontSize:9,fontFamily:wo,color:jn.dim},children:n.length})]}),(0,e.jsx)("div",{style:{display:"flex",gap:6,overflowX:"auto",paddingBottom:4},children:n.map(h=>(0,e.jsxs)("div",{onClick:()=>o(h),onMouseEnter:x=>d({v:h,rect:x.currentTarget.getBoundingClientRect()}),onMouseLeave:()=>d(null),style:{width:s,flexShrink:0,cursor:"pointer",border:`1px solid ${r===h.videoId?"rgba(212,175,92,0.4)":"rgba(212,175,92,0.08)"}`,borderRadius:4,background:jn.card,padding:4},children:[(0,e.jsxs)("div",{style:{position:"relative",width:"100%",aspectRatio:"16/9",borderRadius:3,overflow:"hidden",background:"rgba(212,175,92,0.05)"},children:[(0,e.jsx)("img",{src:h.thumbnail,alt:"",style:{width:"100%",height:"100%",objectFit:"cover"},onError:x=>{x.target.style.display="none"}}),h.duration&&(0,e.jsx)("div",{style:{position:"absolute",bottom:2,right:3,background:"rgba(0,0,0,0.85)",color:"#fff",fontSize:9.5,padding:"0px 3px",borderRadius:2,fontFamily:wo},children:h.duration}),a&&(0,e.jsx)("button",{onClick:x=>{x.stopPropagation(),a(h)},title:l&&l.has(h.videoId)?"Saved to Watch Later":"Save to Watch Later",style:{position:"absolute",top:2,right:3,fontSize:9.5,fontFamily:wo,fontWeight:700,color:l&&l.has(h.videoId)?"#4ADE80":"#D4AF5C",background:"rgba(0,0,0,0.75)",border:"1px solid rgba(212,175,92,0.3)",borderRadius:2,padding:"0px 4px",cursor:"pointer"},children:l&&l.has(h.videoId)?"✓WL":"+WL"})]}),(0,e.jsx)("div",{style:{fontSize:10.5,color:jn.text,fontWeight:600,lineHeight:1.25,marginTop:3,dis
364play:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:h.title}),(0,e.jsx)("div",{style:{fontSize:9.5,color:jn.dim,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h.author}),h.why_this&&(0,e.jsx)("div",{title:h.why_this,style:{fontSize:8.5,fontFamily:wo,color:"#4ADE80",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h.why_this.toUpperCase()})]},h.videoId))}),c&&(0,e.jsxs)("div",{style:{position:"fixed",left:g,width:p,top:f?c.rect.bottom+6:c.rect.top-6,transform:f?"none":"translateY(-100%)",zIndex:9600,pointerEvents:"none",background:"rgba(6,8,13,0.98)",border:"1px solid rgba(212,175,92,0.35)",borderRadius:6,padding:8,boxShadow:"0 12px 36px rgba(0,0,0,0.6)"},children:[c.v.thumbnail&&(0,e.jsx)("img",{src:c.v.thumbnail,alt:"",style:{width:"100%",aspectRatio:"16/9",objectFit:"cover",borderRadius:4,marginBottom:6,display:"block"}}),(0,e.jsx)("div",{style:{fontSize:12,color:jn.text,fontWeight:600,lineHeight:1.35,marginBottom:3},children:c.v.title}),(0,e.jsx)("div",{style:{fontSize:10.5,color:jn.dim},children:c.v.author}),c.v.why_this&&(0,e.jsx)("div",{style:{fontSize:9,fontFamily:wo,color:"#4ADE80",marginTop:3,letterSpacing:"0.05em"},children:c.v.why_this.toUpperCase()})]})]})}function b4({apiBase:t="",contextQuery:n="",onOpenVideo:r=null}){const[o,a]=(0,i.useState)([]),[l,s]=(0,i.useState)(!0),[c,d]=(0,i.useState)(null),[p,g]=(0,i.useState)(""),[f,h]=(0,i.useState)(!1),[x,v]=(0,i.useState)(null),[y,k]=(0,i.useState)(null),[A,j]=(0,i.useState)(""),[E,C]=(0,i.useState)(""),[_,w]=(0,i.useState)(!1),[O,M]=(0,i.useState)(null),[U,ee]=(0,i.useState)(null),[N,V]=(0,i.useState)(!1),[z,oe]=(0,i.useState)(!1),[P,W]=(0,i.useState)({}),[R,ae]=(0,i.useState)(null),[q,ge]=(0,i.useState)(null),[X,de]=(0,i.useState)(0),[We,te]=(0,i.useState)(""),[_e,ve]=(0,i.useState)(null),[Ne,$e]=(0,i.useState)(!0),Pe=(0,i.useRef)(!1),ot=(0,i.useRef)(!0),re=(0,i.useRef)(null);(0,i.useEffect)(()=>{Pe.current=_},[_]),(0,i.useEffect)(()=>{ot.current=Ne},[Ne]);const we=(0,i.useCallback)(()=>({Authorization:`Bearer ${localStorage.getItem("xyron_jwt_token")||""}`,"X-Xyron-Key":""}),[]),b=(0,i.useCallback)(Q=>t?`${t}${Q}`:qr(Q),[t]),He=(0,i.useCallback)(Q=>{if(!(!Pe.current||!ot.current))try{fetch(b("/api/video/profile/telemetry"),{method:"POST",headers:{"Content-Type":"application/json",...we()},body:JSON.stringify(Q)}).catch(()=>{})}catch{}},[b,we]),tt=Q=>{if(!Q)return 0;const rt=String(Q).split(":").map(Number);return rt.some(Number.isNaN)?0:rt.reduce((jt,tn)=>jt*60+tn,0)},Ae=(0,i.useCallback)(Q=>{re.current={videoId:Q.videoId,channelId:Q.channelId||Q.channel_id||null,author:Q.author||"",durationS:tt(Q.duration),startedAt:Date.now()},He({video_id:Q.videoId,event_type:"play",channel_id:re.current.channelId,channel_title:Q.author||""})},[He]),Be=(0,i.useCallback)(()=>{const Q=re.current;if(!Q)return;re.current=null;const rt=Math.max(0,Math.round((Date.now()-Q.startedAt)/1e3));rt>=3&&He({video_id:Q.videoId,event_type:"dwell",channel_id:Q.channelId,channel_title:Q.author,dwell_seconds:Math.min(rt,86400)}),Q.durationS>0&&rt>=.9*Q.durationS&&He({video_id:Q.videoId,event_type:"complete",channel_id:Q.channelId,channel_title:Q.author})},[He]);(0,i.useEffect)(()=>()=>{Be()},[Be]),(0,i.useEffect)(()=>{_&&(async()=>{try{const Q=await fetch(b("/api/video/profile"),{headers:we()});if(Q.ok){const rt=await Q.json();typeof rt.telemetry_enabled=="boolean"&&$e(rt.telemetry_enabled)}}catch{}})()},[_,b,we]);const Fe=(0,i.useCallback)(()=>{const Q=!ot.current;$e(Q);try{fetch(b("/api/video/profile/settings"),{method:"PUT",headers:{"Content-Type":"application/json",...we()},body:JSON.stringify({telemetry_enabled:Q})}).catch(()=>{})}catch{}},[b,we]),ft=(0,i.useCallback)(async(Q="")=>{const rt=!!Q.trim();rt?h(!0):s(!0),d(null);try{const jt=localStorage.getItem("xyron_jwt_token")||"",tn=new URLSearchParams;Q.trim()&&tn.set("query",Q.trim()),tn.set("limit","25");const pt=`/api/video/feed?${tn}`,gt=t?`${t}${pt}`:qr(pt),qt=await fetch(gt,{headers:{Authorization:`Bearer ${jt}`,"X-Xyron-Key":""}});if(!qt.ok)throw new Error(`HTTP ${qt.status}`);const Pt=await qt.json();a(Pt.videos||[]),C(Pt.mode||""),w(!!Pt.profile_ranking),V(rt)}catch(jt){d(jt.message)}finally{s(!1),h(!1)}},[t]);(0,i.useEffect)(()=>{let Q=!1;return(async()=>{try{const rt=await fetch(b("/api/video/rails?limit=50&credible=0"),{headers:we()});if(rt.ok){const jt=await rt.json();if(!Q&&jt&&jt.enabled){M(jt),w(!!jt.profile_ranking),s(!1);return}}}catch{}Q||ft("")})(),()=>{Q=!0}},[ft,b,we]);const St=(0,i.useCallback)(Q=>{Be(),Ae(Q),ee(Q)},[Be,Ae]),Xe=(0,i.useCallback)(async()=>{try{const Q=await fetch(b("/api/video/profile/watchlater"),{headers:we()});if(Q.ok){const rt=await Q.json();if(rt&&rt.enabled){ve(rt);return}}}catch{}ve(null)},[b,we]);(0,i.useEffect)(()=>{Xe()},[Xe]);const It=_e?new Set((_e.items||[]).map(Q=>Q.video_id)):null,Rt=(0,i.useCallback)(Q=>{_e&&((_e.items||[]).some(rt=>rt.video_id===Q.videoId)?fetch(b("/api/video/profile/watchlater/"+encodeURIComponent(Q.videoId)),{method:"DELETE",headers:we()}):fetch(b("/api/video/profile/watchlater"),{method:"POST",headers:{"Content-Type":"application/json",...we()},body:JSON.stringify({video_id:Q.videoId})})).then(()=>Xe()).catch(()=>{})},[_e,b,we,Xe]);(0,i.useEffect)(()=>{let Q=!1;return(async()=>{try{const rt=await fetch(b("/api/video/briefing"),{headers:we()});if(rt.ok){const jt=await rt.json();!Q&&jt&&jt.enabled&&(jt.rails||[]).length&&ae(jt)}}catch{}})(),()=>{Q=!0}},[b,we]),(0,i.useEffect)(()=>
364{if(ge(null),de(0),te(""),!U)return;let Q=!1;return(async()=>{try{const rt=await fetch(b("/api/video/moments/"+encodeURIComponent(U.videoId)),{headers:we()});if(rt.ok){const jt=await rt.json();!Q&&jt&&jt.enabled&&jt.available&&ge(jt)}}catch{}})(),()=>{Q=!0}},[U,b,we]);const $=(0,i.useCallback)(()=>{if(!U)return;const Q=q&&q.chapters||[];let rt=null;for(const gt of Q)gt.t<=X&&(rt=gt);const jt=rt?rt.ts:"0:00",tn=rt&&rt.label?` — ${rt.label}`:"",pt=q&&q.entities&&q.entities[0];te("..."),fetch(b("/api/atoms/capture"),{method:"POST",headers:{"Content-Type":"application/json",...we()},body:JSON.stringify({kind:"note",source_quote:`${U.title} @ ${jt}${tn}`,captured_via:"chat",source_url:`https://www.youtube.com/watch?v=${U.videoId}&t=${rt?rt.t:0}s`,source_title:U.title||"",entity_hint:pt?pt.symbol:void 0})}).then(gt=>{gt.ok&&NS(),te(gt.ok?"CAPTURED":"FAILED")}).catch(()=>te("FAILED"))},[U,q,X,b,we]);(0,i.useEffect)(()=>{if(!U){W({});return}const Q=(U.entities||[]).map(pt=>pt.symbol).slice(0,4);if(!Q.length)return;let rt=!1;const jt=async()=>{for(const pt of Q)try{const gt=await fetch(b("/api/market/quote/"+encodeURIComponent(pt)),{headers:we()});if(gt.ok){const qt=await gt.json(),Pt=qt&&(qt.price??qt.last??qt.last_price??qt.lastPrice);!rt&&typeof Pt=="number"&&W(Kt=>({...Kt,[pt]:Pt}))}}catch{}};jt();const tn=setInterval(jt,3e4);return()=>{rt=!0,clearInterval(tn)}},[U,b,we]),(0,i.useEffect)(()=>{n&&n!==A&&n.trim().length>3&&(j(n),ft(n))},[n,A,ft]);const Ue=Q=>{Q.preventDefault(),p.trim()?ft(p):O&&O.enabled?V(!1):ft("")},Ie=!!(O&&O.enabled)&&!N;return(0,e.jsxs)("div",{style:{background:jn.bg,border:`1px solid ${jn.border}`,borderRadius:"8px",overflow:"hidden",fontFamily:ap,height:"100%",display:"flex",flexDirection:"column"},children:[(0,e.jsxs)("div",{style:{padding:"10px 14px",borderBottom:`1px solid ${jn.border}`,display:"flex",alignItems:"center",justifyContent:"space-between",background:"rgba(212,175,92,0.04)",flexShrink:0},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,e.jsx)("div",{style:{width:7,height:7,borderRadius:"50%",background:jn.accent,boxShadow:`0 0 6px ${jn.accent}66`}}),(0,e.jsx)("span",{style:{fontSize:11,color:jn.accent,fontWeight:700,letterSpacing:"0.1em"},children:"VIDEO INTELLIGENCE"})]}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(E==="adaptive"||_)&&(0,e.jsx)("span",{style:{fontSize:8.5,color:"#4ADE80",fontWeight:700,letterSpacing:"0.08em",padding:"1px 5px",background:"rgba(74,222,128,0.08)",border:"1px solid rgba(74,222,128,0.2)",borderRadius:3},children:"PERSONALISED"}),_&&(0,e.jsx)("button",{onClick:Q=>{Q.stopPropagation(),Fe()},title:"Watch telemetry feeds your interest profile (play/complete/dwell). Toggle off to stop collection; existing data can be cleared via your profile.",style:{fontSize:8.5,fontFamily:wo,fontWeight:700,letterSpacing:"0.08em",padding:"1px 5px",color:Ne?"#4ADE80":jn.dim,background:Ne?"rgba(74,222,128,0.08)":"transparent",border:`1px solid ${Ne?"rgba(74,222,128,0.2)":"rgba(90,112,144,0.3)"}`,borderRadius:3,cursor:"pointer"},children:Ne?"TRACKING ON":"TRACKING OFF"}),_e&&(_e.items||[]).some(Q=>Q.available)&&(0,e.jsxs)("button",{onClick:Q=>{Q.stopPropagation(),oe(rt=>!rt)},title:z?"Hide your saved videos":"Show your saved videos",style:{fontSize:8.5,fontFamily:wo,fontWeight:700,letterSpacing:"0.08em",padding:"1px 5px",color:z?"#4ADE80":jn.accent,background:z?"rgba(74,222,128,0.08)":jn.accentDim,border:`1px solid ${z?"rgba(74,222,128,0.2)":"rgba(212,175,92,0.3)"}`,borderRadius:3,cursor:"pointer"},children:["WATCH LATER · ",(_e.items||[]).filter(Q=>Q.available).length]}),(0,e.jsxs)("span",{style:{fontSize:10.5,color:jn.dim,fontFamily:wo},children:[O&&O.enabled&&!N?O.count:o.length," RESULTS"]})]})]}),(0,e.jsxs)("form",{onSubmit:Ue,style:{padding:"8px 14px",borderBottom:"1px solid rgba(212,175,92,0.08)",flexShrink:0,display:"flex",gap:6},children:[(0,e.jsx)("input",{value:p,onChange:Q=>g(Q.target.value),placeholder:"Search video intelligence...",style:{flex:1,background:"rgba(212,175,92,0.05)",border:"1px solid rgba(212,175,92,0.15)",borderRadius:4,padding:"4px 8px",fontSize:12.5,color:jn.text,fontFamily:ap,outline:"none"}}),(0,e.jsx)("button",{type:"submit",style:{background:jn.accentDim,border:"1px solid rgba(212,175,92,0.3)",borderRadius:4,padding:"4px 10px",fontSize:11,color:jn.accent,fontFamily:ap,cursor:"pointer"},children:f?"...":"SEARCH"}),p&&(0,e.jsx)("button",{type:"button",onClick:()=>{g(""),O&&O.enabled?V(!1):ft("")},style:{background:"transparent",border:"1px solid rgba(90,112,144,0.3)",borderRadius:4,padding:"4px 8px",fontSize:11,color:jn.dim,fontFamily:ap,cursor:"pointer"},children:"CLEAR"})]}),(0,e.jsxs)("div",{style:{flex:1,overflowY:"auto",padding:"8px 10px"},children:[l&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:120,gap:8,fontSize:11,color:jn.dim},children:[(0,e.jsx)("div",{style:{display:"flex",gap:3},children:[0,1,2].map(Q=>(0,e.jsx)("div",{style:{width:4,height:4,borderRadius:"50%",background:jn.accent,animation:`pulse 1s ${Q*.2}s infinite ease-in-out`}},Q))}),"LOADING INTELLIGENCE..."]}),c&&(0,e.jsxs)("div",{style:{padding:12,textAlign:"center",fontSize:12,color:"#F87171"},children:["VIDEO FEED UNAVAILABLE",(0,e.jsx)("div",{style:{marginTop:6,fontSize:10.5,color:jn.dim},children:c}),(0,e.jsx)("button",{onClick:()=>ft(""),style:{marginTop:8,background:jn.accentDim,border:"1px solid rgba(212,175,92,0.3)",borderRadius:4,padding:"3px 10px",fontSize:11,color:jn.accent,fontFamily:ap,cursor:"pointer"},children:"RETRY"})]}),!l&&!c&&!Ie&&o.length===0&&(0,e.jsxs)("div",{style:{padding:12,textAlign:"center",fontSize:12,color:jn.dim},children:["NO VIDEOS FOUND",(0,e.jsx)("div",{style:{marginTop:4,fontSize:10.5},children:"Try a different search term"})]}),U&&(0,e.jsx)("div",{onClick:()=>{Be(),ee(null)},style:{position:"fixed",inset:0,zIndex:9e3,background:"rgba(2,4,10,0.82)",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,e.jsxs)("div",{onClick:Q=>Q.stopPropagation(),style:{width:"min(760px, 92vw)",maxHeight:"90vh",overflowY:"auto",background:"rgba(8,12,20,0.98)",border:"1px solid rgba(212,175,92,0.3)",borderRadius:8,padding:10,boxShadow:"0 18px 60px rgba(0,0,0,0.6)"},children:[(0,e.jsx)(my,{videoId:U.videoId,startAt:X,onClose:()=>{Be(),ee(null)}}),(0,e.jsx)("div",{style:{fontSize:12.5,color:jn.text,fontWeight:600,lineHeight:1.3},children:U.title}),(0,e.jsx)(v4,{card:U,quotes:P}),q&&(0,e.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:5,padding:"4px 2px",alignItems:"center"},children:[(q.chapters||[]).map(Q=>(0,e.jsxs)("button",{onClick:rt=>{rt.stopPropagation(),de(Q.t)},title:`Jump to ${Q.ts}`,style:{fontSize:9,fontFamily:wo,color:X===Q.t?jn.accent:jn.dim,background:X===Q.t?jn.accentDim:"transparent",border:`1px solid ${X===Q.t?"rgba(212,175,92,0.35)":"rgba(90,112,144,0.25)"}`,padding:"1px 5px",borderRadius:2,cursor:"pointer",letterSpacing:"0.03em",maxWidth:180,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[Q.ts,Q.label?` ${Q.label.toUpperCase()}`:""]},Q.t)),(0,e.jsx)("button",{onClick:Q=>{Q.stopPropagation(),$()},disabled:We==="...",title:"Save this moment to your Intel Graph (private note with a deep link)",style:{fontSize:9,fontFamily:wo,fontWeight:700,color:We==="CAPTURED"?"#4ADE80":jn.accent,background:jn.accentDim,border:"1px solid rgba(212,175,92,0.35)",padding:"1px 6px",borderRadius:2,cursor:"pointer",letterSpacing:"0.06em"},children:We==="CAPTURED"?"✓ CAPTURED":We==="FAILED"?"CAPTURE FAILED":We==="..."?"CAPTURING…":"CAPTURE MOMENT"})]})]})}),!N&&R&&(R.rails||[]).map(Q=>(0,e.jsx)(pg,{title:"BRIEFING · "+Q.event.title.toUpperCase(),videos:Q.videos,playingId:U&&U.videoId,onPlay:St,onSave:_e?Rt:null,savedIds:It},"briefing-"+Q.event.title)),(z||!N)&&_e&&(_e.items||[]).some(Q=>Q.available)&&(0,e.jsx)(pg,{title:"WATCH LATER",videos:(_e.items||[]).filter(Q=>Q.available),playingId:U&&U.videoId,onPlay:St,onSave:Rt,savedIds:It}),Ie&&(O.rails||[]).filter(Q=>Q.key!=="event_radar"&&Q.key!=="news_highlights").map(Q=>(0,e.jsx)(pg,{title:Q.title,videos:Q.videos,playingId:U&&U.videoId,onPlay:St,onSave:_e?Rt:null,savedIds:It},Q.key)),!l&&!Ie&&o.map(Q=>{const rt=y===Q.videoId;return(0,e.jsxs)("div",{onClick:()=>{r?(He({video_id:Q.videoId,event_type:"play",channel_id:Q.channelId||Q.channel_id||null,channel_title:Q.author||""}),r("https://www.youtube.com/watch?v="+Q.videoId,Q.title||"")):St(Q)},onMouseEnter:()=>v(Q.videoId),onMouseLeave:()=>v(null),style:{display:"flex",flexDirection:rt?"column":"row",gap:rt?6:10,padding:"8px",marginBottom:6,borderRadius:5,border:`1px solid ${x===Q.videoId?"rgba(212,175,92,0.25)":"rgba(212,175,92,0.08)"}
364`,background:x===Q.videoId?jn.cardHover:jn.card,transition:"all 0.15s",cursor:"pointer"},children:[rt?(0,e.jsx)(my,{videoId:Q.videoId,onClose:()=>{Be(),k(null)}}):(0,e.jsxs)("div",{style:{position:"relative",width:100,height:58,flexShrink:0,borderRadius:4,overflow:"hidden",background:"rgba(212,175,92,0.05)",border:"1px solid rgba(212,175,92,0.12)"},children:[(0,e.jsx)("img",{src:Q.thumbnail,alt:"",style:{width:"100%",height:"100%",objectFit:"cover"},onError:jt=>{jt.target.style.display="none"}}),Q.duration&&(0,e.jsx)("div",{style:{position:"absolute",bottom:2,right:3,background:"rgba(0,0,0,0.85)",color:"#fff",fontSize:10.5,padding:"1px 4px",borderRadius:2,fontFamily:wo},children:Q.duration}),x===Q.videoId&&(0,e.jsx)("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(212,175,92,0.15)"},children:(0,e.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:jn.accent,children:(0,e.jsx)("polygon",{points:"5,3 19,12 5,21"})})})]}),(0,e.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,e.jsx)("div",{style:{fontSize:13,color:jn.text,fontWeight:600,lineHeight:1.35,marginBottom:3,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:Q.title}),(0,e.jsx)("div",{style:{fontSize:11.5,color:jn.dim,marginBottom:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Q.author}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:5},children:[(0,e.jsx)("span",{style:{fontSize:10,fontFamily:wo,color:fh[Q.category]||jn.accent,background:`${fh[Q.category]||jn.accent}15`,border:`1px solid ${fh[Q.category]||jn.accent}30`,padding:"1px 4px",borderRadius:2,letterSpacing:"0.05em"},children:x4[Q.category]||Q.category}),Q.why_this&&(0,e.jsx)("span",{title:Q.why_this,style:{fontSize:10,fontFamily:wo,color:"#4ADE80",background:"rgba(74,222,128,0.08)",border:"1px solid rgba(74,222,128,0.25)",padding:"1px 4px",borderRadius:2,letterSpacing:"0.05em",maxWidth:160,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Q.why_this.toUpperCase()}),Q.published&&(0,e.jsx)("span",{style:{fontSize:10.5,color:jn.dim,fontFamily:wo},children:Q.published}),_e&&(0,e.jsx)("button",{onClick:jt=>{jt.stopPropagation(),Rt(Q)},title:It&&It.has(Q.videoId)?"Saved — remove from watch later":"Save to watch later",style:{fontSize:10,fontFamily:wo,fontWeight:700,color:It&&It.has(Q.videoId)?"#4ADE80":jn.accent,background:"transparent",border:"1px solid rgba(212,175,92,0.3)",padding:"1px 5px",borderRadius:2,cursor:"pointer",letterSpacing:"0.05em",marginLeft:"auto",flexShrink:0},children:It&&It.has(Q.videoId)?"✓WL":"+WL"})]})]})]},Q.videoId)})]}),(0,e.jsx)("style",{children:`
365                @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');
366                @keyframes pulse {
367                    0%, 100% { transform: scale(0.6); opacity: 0.4; }
368                    50% { transform: scale(1.0); opacity: 1; }
369                }
370                ::-webkit-scrollbar { width: 3px; }
371                ::-webkit-scrollbar-thumb { background: rgba(212,175,92,0.2); }
372            `})]})}function S4({video:t,onClose:n}){return(0,e.jsx)("div",{onClick:n,style:{position:"fixed",inset:0,zIndex:9e3,background:"rgba(2,4,10,0.82)",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,e.jsxs)("div",{onClick:r=>r.stopPropagation(),style:{width:"min(760px, 92vw)",background:"rgba(8,12,20,0.98)",border:"1px solid rgba(212,175,92,0.3)",borderRadius:8,padding:10,boxShadow:"0 18px 60px rgba(0,0,0,0.6)"},children:[(0,e.jsx)(my,{videoId:t.videoId,onClose:n}),(0,e.jsx)("div",{style:{fontSize:13,color:"#C9D1D9",fontWeight:600,lineHeight:1.3},children:t.title}),(0,e.jsxs)("div",{style:{fontSize:10.5,color:"#5A7090",marginTop:2,fontFamily:"'JetBrains Mono', ui-monospace, monospace"},children:[t.author,t.published?` · ${t.published}`:""]})]})})}function E4({title:t,videos:n,cardWidth:r=132}){const[o,a]=(0,i.useState)(null),l=(0,i.useCallback)(c=>a(c),[]),s=h4();return!n||!n.length?null:(0,e.jsxs)("div",{style:{minWidth:0,overflow:"hidden"},children:[o&&(0,e.jsx)(S4,{video:o,onClose:()=>a(null)}),(0,e.jsx)(pg,{title:t,videos:n,playingId:o&&o.videoId,onPlay:l,cardWidth:r,onSave:s.savedIds?s.toggle:null,savedIds:s.savedIds})]})}function k4(t){var n=t.op||1,r=y4();return r?(0,e.jsxs)("div",{style:{width:"100%",opacity:n,transition:"opacity .6s .28s ease",border:"1px solid rgba(212,175,92,0.15)",borderRadius:6,background:"rgba(6,8,13,0.95)",overflow:"hidden",display:"flex",flexDirection:"column"},children:[(0,e.jsxs)("div",{style:{padding:"6px 12px",borderBottom:"1px solid rgba(212,175,92,0.1)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,e.jsx)("span",{style:{fontSize:9,fontFamily:I.mono,color:I.gold,letterSpacing:".10em",fontWeight:700},children:"◈ VIDEO INTEL"}),(0,e.jsx)("span",{style:{fontSize:8,fontFamily:I.mono,color:I.ink5,letterSpacing:".10em"},children:r.videos.length+" CLIPS · SCREENED"})]}),(0,e.jsx)("div",{style:{padding:"6px 12px",flex:1,minWidth:0,minHeight:0,overflow:"hidden"},children:(0,e.jsx)(E4,{title:r.title,videos:r.videos,cardWidth:112})}),(0,e.jsxs)("div",{style:{padding:"5px 12px",borderTop:"1px solid rgba(28,39,64,0.4)",display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:8,fontFamily:I.mono,color:I.ink5,letterSpacing:".10em"},children:[(0,e.jsx)("span",{children:"personalised · credible sources only"}),(0,e.jsx)("span",{children:"bloomberg · reuters · cnbc · wsj +"})]})]}):(0,e.jsxs)("div",{style:{width:"100%",opacity:n,transition:"opacity .6s .28s ease",border:"1px solid rgba(212,175,92,0.15)",borderRadius:6,background:"rgba(6,8,13,0.95)",overflow:"hidden",display:"flex",flexDirection:"column"},children:[(0,e.jsxs)("div",{style:{padding:"6px 12px",borderBottom:"1px solid rgba(212,175,92,0.1)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,e.jsx)("span",{style:{fontSize:9,fontFamily:I.mono,color:I.gold,letterSpacing:".10em",fontWeight:700},children:"◈ VS PEER COHORT"}),(0,e.jsx)("span",{style:{fontSize:8,fontFamily:I.mono,color:I.ink5,letterSpacing:".10em"},children:"42 SFO"})]}),(0,e.jsxs)("div",{style:{padding:"6px 12px",flex:1,display:"grid",gridTemplateColumns:"1fr",gap:2},children:[(0,e.jsx)(Mu,{label:"RE YIELD",value:"4.1%",peerValue:"4.6",delta:{direction:"down",label:"−0.5pt"},cohort:{percentile:32,of:42,distribution:[3,7,14,18,14,9,6]},info:"cohort μ 4.6 σ 0.4",staggerIndex:0}),(0,e.jsx)(Mu,{label:"PE IRR",value:"14.2%",peerValue:"12.8",delta:{direction:"up",label:"+1.4pt"},cohort:{percentile:78,of:42,distribution:[3,7,14,18,14,9,6]},info:"top quartile",staggerIndex:1}),(0,e.jsx)(Mu,{label:"LIQ RATIO",value:"38%",peerValue:"29",delta:{direction:"up",label:"+9pt"},cohort:{percentile:92,of:42,distribution:[3,7,14,18,14,9,6]},info:"top decile",staggerIndex:2}),(0,e.jsx)(Mu,{label:"FX HEDGE",value:"62%",peerValue:"71",delta:{direction:"down",label:"−9pt"},cohort:{percentile:28,of:42,distribution:[3,7,14,18,14,9,6]},info:"below cohort μ",staggerIndex:3}),(0,e.jsx)(Mu,{label:"GOLD ALLOC",value:"8.5%",peerValue:"6.2",delta:{direction:"up",label:"+2.3pt"},cohort:{percentile:83,of:42,distribution:[3,7,14,18,14,9,6]},info:"top quintile",staggerIndex:4}),(0,e.jsx)(Mu,{label:"ANN RETURN",value:"6.2%",peerValue:"5.8",delta:{direction:"up",label:"+0.4pt"},cohort:{percentile:58,of:42,distribution:[3,7,14,18,14,9,6]},info:"slightly above μ",staggerIndex:5})]}),(0,e.jsxs)("div",{style:{padding:"5px 12px",borderTop:"1px solid rgba(28,39,64,0.4)",display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:8,fontFamily:I.mono,color:I.ink5,letterSpacing:".10em"}
372,children:[(0,e.jsx)("span",{children:"$200M–$2B AUM"}),(0,e.jsx)("span",{children:"anonymised · μ 4.6 σ 0.4"})]})]})}function C4(t,n={}){const r=(0,i.useRef)(null),o=(0,i.useRef)(t),a=n.duration??1500;return(0,i.useEffect)(()=>{if(t===o.current)return;o.current=t;const l=r.current;if(!l)return;l.classList.remove("xy-edge-flash"),l.offsetWidth,l.classList.add("xy-edge-flash");const s=setTimeout(()=>{l&&l.classList&&l.classList.remove("xy-edge-flash")},a);return()=>clearTimeout(s)},[t,a]),r}var gg=[{sym:"S&P 500",symbols:["SPX"],cat:"INDEX",digits:2},{sym:"NASDAQ",symbols:["IXIC"],cat:"INDEX",digits:2},{sym:"FTSE 100",symbols:["FTSE","^FTSE"],cat:"INDEX",digits:2},{sym:"NIKKEI",symbols:["N225","NI225","^N225"],cat:"INDEX",digits:2},{sym:"DAX",symbols:["DAX","^GDAXI"],cat:"INDEX",digits:2},{sym:"EUR/USD",symbols:["EUR/USD","EURUSD"],cat:"FX",digits:4},{sym:"GBP/USD",symbols:["GBP/USD","GBPUSD"],cat:"FX",digits:4},{sym:"USD/JPY",symbols:["USD/JPY","USDJPY"],cat:"FX",digits:3},{sym:"DXY",symbols:["DXY"],cat:"FX",digits:2},{sym:"USD/CHF",symbols:["USD/CHF","USDCHF"],cat:"FX",digits:4},{sym:"10Y UST",symbols:["US10Y","TNX"],cat:"RATES",digits:3,suffix:"%"},{sym:"2Y UST",symbols:["US2Y","TWO"],cat:"RATES",digits:3,suffix:"%"},{sym:"BUND 10Y",symbols:["DE10Y","TMBMKDE-10Y"],cat:"RATES",digits:3,suffix:"%"},{sym:"GOLD",symbols:["XAU/USD","XAUUSD"],cat:"COMMOD",digits:2},{sym:"SILVER",symbols:["XAG/USD","XAGUSD"],cat:"COMMOD",digits:2},{sym:"WTI",symbols:["USOIL","WTI"],cat:"COMMOD",digits:2},{sym:"BRENT",symbols:["UKOIL","BRENT"],cat:"COMMOD",digits:2},{sym:"COPPER",symbols:["COPPER"],cat:"COMMOD",digits:3},{sym:"NAT GAS",symbols:["NATGAS"],cat:"COMMOD",digits:3},{sym:"VIX",symbols:["VIX"],cat:"VOL",digits:2},{sym:"BTC/USD",symbols:["BTC/USD","BTCUSD"],cat:"CRYPTO",digits:2},{sym:"ETH/USD",symbols:["ETH/USD","ETHUSD"],cat:"CRYPTO",digits:2},{sym:"SOL/USD",symbols:["SOL/USD","SOLUSD"],cat:"CRYPTO",digits:2},{sym:"NVDA",symbols:["NVDA"],cat:"EQUITY",digits:2},{sym:"TSLA",symbols:["TSLA"],cat:"EQUITY",digits:2},{sym:"JPM",symbols:["JPM"],cat:"EQUITY",digits:2}],ph=Array.from(new Set(gg.flatMap(function(t){return t.symbols}))),A4={live:3e4,delayed:30*6e4,per_call:15*6e4,eod:5760*6e4,synthetic:3e4};function kE(t){if(t==null||t==="")return null;if(typeof t=="number"&&Number.isFinite(t))return t<1e10?t*1e3:t;if(typeof t=="string"&&/^\d+(\.\d+)?$/.test(t.trim()))return kE(Number(t));const n=Date.parse(t);return Number.isFinite(n)?n:null}function CE(t){return kE(t&&t.timestamp)}function j4(t,n){if(!t||!n)return null;let r=null,o=-1;return t.symbols.forEach(function(a){const l=n[a];if(!l||!Number.isFinite(Number(l.price))||Number(l.price)<=0)return;const s=CE(l);(r===null||s!=null&&s>o)&&(r=l,o=s??-1)}),r}function w4(t,n){const r=NA(t),o=CE(t);if(r==="live"&&o==null)return"unknown";const a=A4[r];return a&&o!=null&&Math.max(0,n-o)>a?"stale":r}function T4(t,n){const r=Number(n);return!Number.isFinite(r)||r<=0?"—":r.toLocaleString("en-US",{minimumFractionDigits:t.digits,maximumFractionDigits:t.digits})+(t.suffix||"")}function _4(t){if(t==null||t==="")return"—";const n=Number(t);return Number.isFinite(n)?(n>0?"+":"")+n.toFixed(2)+"%":"—"}function R4(t,n,r=Date.now()){const o=j4(t,n);if(!o)return{available:!1,val:"—",chg:"—",up:null,flash:!1,mode:"unknown",modeLabel:gv("unknown"),modeColor:pv("unknown"),provider:null,source:null,timestamp:null};const a=w4(o,r),l=o.changePercent!=null&&o.changePercent!=="",s=Number(o.changePercent),c=Number(o.direction);return{available:!0,val:T4(t,o.price),chg:_4(o.changePercent),up:l&&Number.isFinite(s)?s>=0:null,flash:Number.isFinite(c)&&c!==0,mode:a,modeLabel:gv(a),modeColor:pv(a),provider:BA(o.source),source:o.source||null,timestamp:o.timestamp||null}}var F4=new Set(["bridge_unavailable","degraded","disconnected","permission_denied","provider_error","rate_limited","status_error","stale","timeout","unavailable"]),z0={critical:0,high:1,medium:2,info:3},I4=16;function D4(t){return F4.has(String(t||"").trim().toLowerCase())}function Da(t){return Array.isArray(t)?t:[]}function ta(t){return t==null?"":String(t).trim()}function O4(t){if(!t)return"";var n=Date.parse(t);if(!Number.isFinite(n))return"";var r=new Date(n),o=String(r.getUTCHours()).padStart(2,"0"),a=String(r.getUTCMinutes()).padStart(2,"0");return o+":"+a}function pu(t){var n=Date.parse(t);return Number.isFinite(n)?n:0}function L4(t){var n=String(t||"").trim().toLowerCase();return n==="critical"||n==="high"||n==="medium"||n==="info"?n:n==="low"||n==="watch"?"info":""}function AE(t){return L4(t)||"info"}function lc(t,n){var r=n.map(function(o){return ta(o)}
372).filter(Boolean).join("|").slice(0,96);return t+"-"+(r||"row")}function sc(t){return O4(t)||"—"}function Pb(t){return t==null||t===""?"":typeof t=="number"&&Number.isFinite(t)&&Math.abs(t)>=100?t.toLocaleString("en-US"):String(t)}var z4=new Set(["crime","blotter","police","local","law enforcement"]),M4=/\b(robbed|robbery|armed robbery|burglary|shoplifting|carjacking|hit and run|dui arrest|petty theft|convenience store robbery|stabbing|stabbed|murder|murdered|manslaughter|homicide|fatal shooting|shot dead)\b/i;function N4(t,n){var r=String(t.category||"").trim().toLowerCase();if(z4.has(r))return!0;var o=String(t.source||t.provider||"").trim().toLowerCase();return o==="blotter"||o==="local news"||o==="police"||o==="sheriff"?!0:t.impact!=null&&String(t.impact).toLowerCase()==="high"||t.impact_origin==="provider_is_breaking"||t.is_breaking?!1:!!M4.test(n)}function B4(t){if(!t||typeof t!="object")return null;var n=ta(t.seriesName||t.title),r=t.actual!=null?t.actual:t.value;if(!n&&r==null)return null;var o=n||"Macro release",a=Pb(r);a&&(o+=" · actual "+a);var l=Pb(t.forecast);l&&(o+=" · fcst "+l);var s=t.received_at||t.timestamp||t.eventDate||t.event_date,c=AE(t.impact);return c==="info"&&r!=null&&(c="high"),{id:lc("obs",[t.id,t.dataSeriesId||t.seriesId,n,s]),severity:c,time:sc(s),category:"MACRO RELEASE",headline:o.slice(0,140),ticker:null,impact:a?{value:a,label:"act"}:null,sources:["alphaflash"],aiAction:"REVIEW PRINT · "+(n||"release")+(a?" "+a:""),receivedAt:s||null,contextCause:"Authoritative macro print published via AlphaFlash STOMP engine.",entityImpact:(t.country?t.country+" · ":"")+(n||"Macro print")+(a?" · Actual: "+a:"")+(l?" vs Fcst: "+l:""),aiRecommendation:"Assess yield curve sensitivity and automated strategy response.",actionRoute:{type:"ask_cortex",topic:n,label:"ask cortex"}}}function gh(t,n){if(!t||typeof t!="object")return null;var r=ta(t.title||t.name||t.seriesName);if(!r)return null;var o=t.timestamp||t.datetime||t.date,a=AE(t.impact||t.importance),l=pu(o)-Date.now(),s="";if(l>0&&l<=24*3600*1e3){var c=Math.floor(l/36e5),d=Math.floor(l%(3600*1e3)/(60*1e3));s="T-"+c+"h "+(d<10?"0":"")+d+"m"}a==="info"&&(l>0&&l<3600*1e3?a="critical":l>0&&l<1440*60*1e3&&(a="high"));var p=ta(t.country),g=r;return t.forecast!=null&&t.forecast!==""&&(g+=" · fcst "+t.forecast),s&&(g+=" ("+s+")"),{id:lc("cal",[t.id,r,o]),severity:a,time:sc(o),category:p?"CALENDAR · "+p:"CALENDAR",headline:g.slice(0,140),ticker:null,impact:t.forecast!=null&&t.forecast!==""?{value:String(t.forecast),label:"fcst"}:null,sources:[n||"econ-calendar"],aiAction:"PREPARE · "+r.slice(0,80),receivedAt:o||null,contextCause:"High-impact macro event scheduled"+(s?" ("+s+")":"")+"; volatility expected across rates and FX.",entityImpact:(p?p+" · ":"")+"Direct volatility impact on rates, FX, and equity indices.",aiRecommendation:"Verify portfolio delta hedging and limit order book exposure before print.",actionRoute:{type:"calendar",eventId:t.id,label:"open calendar"}}}function Ub(t){if(!t||typeof t!="object")return null;var n=ta(t.symbol).toUpperCase();if(!n||!(t.triggered===!0||t.triggered_price!=null||t.triggered_at||t.last_triggered_at))return null;var r=ta(t.condition)||"alert",o=t.threshold,a=t.triggered_price!=null?t.triggered_price:t.price,l=t.timestamp||t.triggered_at||t.last_triggered_at,s=n+" "+r+(o!=null&&o!==""?" "+o:"");return a!=null&&a!==""&&(s+=" · last "+a),{id:lc("alert",[t.alert_id||t.id,n,l]),severity:"critical",time:sc(l),category:"PRICE ALERT",headline:s.slice(0,140),ticker:{symbol:n,value:a!=null?String(a):"—",delta:"",direction:null},wsSymbol:n,impact:a!=null?{value:String(a),label:n}:null,sources:["price-alert"],aiAction:"ALERT HIT · review "+n,receivedAt:l||null,contextCause:"Real-time watchlist price alert triggered for "+n+" ("+r+(o!=null?" "+o:"")+").",entityImpact:n+(a!=null?" · Observed market price: "+a:"")+" · Watchlist alert threshold",aiRecommendation:"Inspect order book depth, check live chart, and review strategy alert levels.",actionRoute:{type:"room",symbol:n,label:"inspect room"}}}function Wb(t,n){if(!t||typeof t!="object")return null;var r=ta(t.headline||t.title);if(!r||N4(t,r))return null;var o=t.impact,a=o!=null&&String(o).toLowerCase()==="high"||t.impact_origin==="provider_is_breaking";if(!a&&!n)return null;var l=t.timestamp||t.published_at||t.publishedAt,s=ta(t.source||t.provider)||"news";return{id:lc("news",[t.id,r,l]),severity:a?"high":"info",time:sc(l),category:"NEWS",headline:r.slice(0,140),ticker:null,sources:[s.toLowerCase()],aiAction:"READ · "+s,receivedAt:l||null,contextCause:r+(t.summary?" — "+t.summary:""),entity
372Impact:"Macro & geopolitical shift affecting sovereign book positioning",aiRecommendation:"Assess portfolio correlation, liquidity buffers, and strategy positioning in Cortex.",actionRoute:{type:"ask_cortex",topic:r,label:"ask cortex"}}}function P4(t){if(!t||typeof t!="object")return null;var n=ta(t.title||t.name||t.filename);if(!n)return null;var r=!t.expiry_date&&!t.expiryDate&&!!(t.review_date||t.reviewDate),o=t.expiry_date||t.expiryDate||t.review_date||t.reviewDate;if(!o)return null;var a=pu(o);if(!a)return null;var l=Math.ceil((a-Date.now())/(24*3600*1e3));if(l>60)return null;var s=!r&&/lease|tenan/i.test(n+" "+(t.category||"")+" "+(t.type||"")),c=r?"VAULT · COMPLIANCE":s?"VAULT · LEASE":"VAULT · CONTRACT",d=l<0||l<=30?r?"high":"critical":r?"medium":"high",p=r?n+": Compliance review "+(l<0?"overdue by "+Math.abs(l)+" days":"due in "+l+" days"):n+": "+(s?"Commercial lease":"Contract")+" "+(l<0?"expired "+Math.abs(l)+" days ago":"expires in "+l+" days"),g=ta(t.entity||t.property_name||t.company||"Holdco");return{id:lc("vault",[t.id,n,o]),severity:d,time:sc(o),category:c,headline:p.slice(0,140),ticker:null,impact:{value:l<=0?r?"OVD":"EXP":l+"d",label:r?"rev":"term"},sources:["vault"],aiAction:(r?"AUDIT · ":"REVIEW · ")+n.slice(0,60),receivedAt:t.updated_at||t.created_at||o,contextCause:r?"Periodic compliance and governance review date reached for documented asset.":s?"Commercial lease agreement entered renewal/expiry window ("+(l<=0?"expired "+Math.abs(l)+" days ago":l+" days remaining")+").":"Contractual term expiring within "+(l<=0?"overdue":l+" days")+"; renewal or termination notice required.",entityImpact:(g?g+" · ":"")+"Document: "+n+(t.value?" · "+t.value:""),aiRecommendation:r?"Execute scheduled internal compliance review and refresh certification records.":s?"Initiate lease renewal negotiations or exercise extension notice with tenant counsel.":"Review renewal terms, covenant obligations, and schedule legal compliance sign-off.",actionRoute:{type:"vault",docId:t.id,label:"view in vault"}}}function U4(t){if(!t||typeof t!="object")return null;var n=ta(t.name||t.title||t.property_name);if(!n)return null;var r=String(t.riskBand||t.risk_band||"").toUpperCase(),o=ta(t.status),a=t.ltvPct!=null?t.ltvPct:t.ltv!=null?t.ltv:t.ltv_pct,l=a!=null&&Number.isFinite(Number(a))?Number(a):null,s=t.covenant_ltv!=null?Number(t.covenant_ltv):t.covenantLtv!=null?Number(t.covenantLtv):null,c=o==="Covenant Risk"||t.covenant_risk===!0||l!=null&&s!=null&&l>=s*.85;if(!c&&r!=="HIGH")return null;var d=l!=null?l+"%":"N/A",p=c?"Debt service covenant risk":o||"Elevated asset risk profile",g=n+": "+p+(l!=null?" · LTV "+l+"%":""),f=ta(t.spv||t.ownership||t.entity||"Property SPV"),h=s!=null?" (Covenant ceiling: "+s+"%)":"";return{id:lc("re",[t.id,n]),severity:c?"critical":"high",time:sc(t.updated_at||t.created_at)||"—",category:c?"REAL ESTATE · COVENANT":"REAL ESTATE · RISK",headline:g.slice(0,140),ticker:null,impact:{value:d,label:"LTV"},sources:["real-estate"],aiAction:(c?"STRESS COVENANT · ":"REVIEW RISK · ")+n.slice(0,60),receivedAt:t.updated_at||null,contextCause:c?"Property debt service or valuation compression triggers debt service covenant sensitivity.":"Asset risk evaluation flagged under high-risk classification based on current operating indicators.",entityImpact:f+" · Asset: "+n+(l!=null?" · Current LTV: "+l+"%":"")+h,aiRecommendation:c?"Model debt headroom under 20bp cap rate expansion and inspect asset cash-flow sensitivity.":"Review asset operating fundamentals, tenant mix, and current valuation assumptions.",actionRoute:{type:"real_estate",assetId:t.id,label:"view property"}}}function W4(t){var n=String(t||"").toUpperCase();return n==="GBP"?"£":n==="EUR"?"€":n==="USD"?"$":n?n+" ":""}function lp(t,n){if(t==null||t==="")return"";var r=Number(t);return Number.isFinite(r)?W4(n)+Math.round(Math.abs(r)).toLocaleString("en-US"):String(t)}function H4(t){if(!t||typeof t!="object")return null;var n=ta(t.name||t.entity_name||t.entity||(t.counterparty_name?"Intercompany Transfer":""));if(!n&&!t.invoice_number&&!t.invoice_id)return null;var r=t.mismatch===!0||t.difference!=null&&Math.abs(Number(t.difference))>0,o=t.difference!=null?Math.abs(Number(t.difference)):t.interco_variance!=null?Math.abs(Number(t.interco_variance)):null,a=r||t.intercompany_imbalance===!0||o!=null&&o>0,l=t.due_date?pu(t.due_date):null,s=l!=null?(l-Date.now())/(3600*1e3):t.ap_due_hours!=null?Number(t.ap_due_hours):null,c=s!=null&&s<48;if(!(t.working_capital_warning===!0||t.buffer_alert===!0||t.cash_days!=null&&t.cash_days<30||c)&&!a)return null;var d=t.due_from_currency||t.currency,p=t.counterparty_due_to_currency||t.counterparty_currency||t.currency,g=d&&p?String(d).toUpperCase()===String(p).toUpperCase():!0,f=d||p||t.currency||"GBP",h=a?"LEDGER · INTERCO":"LEDGER · LIQUIDITY",x=o!=null?g?" · "+lp(o,f):" · Currency variance ("+d+" vs "+p+")":"",v=t.entity_name&&t.counterparty_name?t.entity_name+" ↔ "+t.counterparty_name:n,y=a?v+": Intercompany reconciliation variance"+x:(n||"Operating Entity")+": Working capital buffer alert · AP due "+(s!=null&&s<=0?"overdue":"< 48h"),k=t.cash_days!=null&&t.cash_days<14||s!=null&&s<24?"critical":"high",A=a?o!=null&&g?lp(o,f):"VAR":s!=null&&s<=0?"OVD":"<48h",j=a?(t.entity_name||"Entity")+" (Due: "+lp(t.due_from||"0",d||f)+") ↔ "+(t.counterparty_name||"Counterparty")+" (Due: "+lp(t.counterparty_due_to||"0",p||f)+")":(n||"Operating Entity")+(t.vendor?" · Vendor: "+t.vendor:"")+(t.outstanding?" · Outstanding: "+lp(t.outstanding,t.currency||"GBP"):"")+" · Buffer threshold: 30 days operating expenses";return{id:lc("ledger",[t.id||t.invoice_id,n,h,t.counterparty_name]),severity:k,time:sc(t.timestamp||t.updated_at||t.created_at||t.due_date)||"—",category:h,headline:y.slice(0,140),ticker:null,impact:{value:A,label:a?"recon":"AP"},sources:["ledger"],aiAction:a?"RECONCILE · "+v:"SWEEP BUFFER · "+(n||"AP"),receivedAt:t.timestamp||t.updated_at||t.created_at||null,contextCause:a?"Cross-entity transfer pricing and management fee eliminations show uneliminated reconciliation variance.":"Upcoming AP pay run scheduled within 48h exceeds immediate operating cash buffer on primary account.",entityImpact:j,aiRecommendation:a?"Execute elimination journal and verify bilateral ledger intercompany balances.":"Execute liquidity transfer sweep from master treasury reserve to cover AP settlement.",actionRoute:{type:"ledger",entityId:t.entity_id||t.id,label:"open ledger"}}}function G4(t){if(!t||typeof t!="object")return null;var n=ta(t.name||t.title);if(!n)return null;var r=t.status==="blocked"||t.blocked===!0||t.blockers&&t.blockers.length>0,o=t.milestone_overdue===!0||t.status==="overdue"||t.milestone_due&&pu(t.milestone_due)<Date.now()||t.due_date&&pu(t.due_date)<Date.now();if(!r&&!o)return null;var a=r?"PROJECT · BLOCKER":"PROJECT · MILESTONE",l=n+": Milestone overdue · Blocker flagged",s=r?"high":"medium";return{id:lc("proj",[t.id,n]),severity:s,time:sc(t.updated_at||t.milestone_due)||"—",category:a,headline:l.slice(0,140),ticker:null,impact:{value:r?"BLK":"OVD",label:"proj"},sources:["workbench"],aiAction:"TRIAGE · "+n.slice(0,60),receivedAt:t.updated_at||null,contextCause:"Critical path dependency or milestone completion date breached without formal variance approval.",entityImpact:n+" · Lead: "+(t.lead||t.owner||"Quantitative Alpha Team"),aiRecommendation:"Reassign blocking resource dependency and recalibrate sprint delivery forecast.",actionRoute:{type:"project",projectId:t.id,label:"open project"}}}function V4(t,n){if(!t||typeof t!="object")return null;var r=ta(t.symbol||t.sym||t.ticker).toUpperCase();if(!r)return null;var o=t.percent_change!=null?Number(t.percent_change):t.pnl_pct!=null?Number(t.pnl_pct):t.percentChange!=null?Number(t.percentChange):null,a=t.drawdown!=null?Number(t.drawdown):t.unrealized_loss_pct!=null?Math.abs(Number(t.unrealized_loss_pct)):o!=null&&o<0?Math.abs(o):null,l=Number(t.value??t.market_value??t.marketValue??0),s=Number(n),c=t.weight!=null?Number(t.weight):t.concentration_pct!=null?Number(t.concentration_pct):Number.isFinite(s)&&s>0&&l>0?l/s*100:null,d=a!=null&&a>=8;if(!d&&!(c!=null&&c>=40))return null;var p=d?r+": Position drawdown "+a.toFixed(1)+"% from cost basis":r+": Single-name concentration "+c.toFixed(1)+"% exceeds 40% cap",g=a!=null&&a>15||c!=null&&c>50?"critical":"high";return{id:lc("port",[r,t.id]),severity:g,time:sc(t.timestamp||t.updated_at)||"—",category:"PORTFOLIO · RISK",headline:p.slice(0,140),ticker:{symbol:r,value:t.price!=null?String(t.price):"—",delta:"",direction:null},wsSymbol:r,impact:{value:a!=null?"-"+a.toFixed(1)+"%":c.toFixed(1)+"%",label:r},sources:["portfolio"],aiAction:"REVIEW RISK · "+r,receivedAt:t.timestamp||t.updated_at||null,contextCause:d?"Position adverse excursion exceeded the mandatory 8.0% portfolio risk threshold.":"Single asset concentration breach beyond institutional risk limit of 40%.",entityImpact:r+" · Exposure: "+(l>
3720?"$"+Math.round(l).toLocaleString("en-US"):"Core Book")+(c!=null?" ("+c.toFixed(1)+"% of NAV)":""),aiRecommendation:"Evaluate tail-risk stop, initiate delta collar hedge, or size down to compliance bounds.",actionRoute:{type:"room",symbol:r,label:"inspect room"}}}function Y4(t){var n=Object.create(null),r=[];return t.forEach(function(o){if(o){var a=String(o.headline||"").toLowerCase().replace(/\s+/g," ");!a||n[a]||(n[a]=!0,r.push(o))}}),r}function K4(t){var n=t&&typeof t=="object"?t:{},r=[];Da(n.observations).forEach(function(c){var d=B4(c);d&&r.push(d)}),Da(n.calendarHighImpact).forEach(function(c){var d=gh(c,"alphaflash");d&&r.push(d)}),Da(n.econRecent).forEach(function(c){var d=String(c&&(c.importance||c.impact)||"").toLowerCase();if(!(!(c&&c.actual!=null&&c.actual!=="")&&d!=="high"&&d!=="critical")){var p=gh(c,"econ-calendar");p&&r.push(p)}}),Da(n.econUpcoming).forEach(function(c){var d=String(c&&(c.importance||c.impact)||"").toLowerCase();if(!(d&&d!=="high"&&d!=="critical")){var p=gh(c,"econ-calendar");p&&r.push(p)}}),Da(n.alertHistory).forEach(function(c){var d=Ub(c);d&&r.push(d)}),Da(n.alerts).forEach(function(c){var d=Ub(c);d&&r.push(d)}),Da(n.vaultDocuments||n.vault).forEach(function(c){var d=P4(c);d&&r.push(d)}),Da(n.realEstateAssets||n.realEstate).forEach(function(c){var d=U4(c);d&&r.push(d)}),Da(n.ledgerEntities||n.ledgerBalances||n.ledger).forEach(function(c){var d=H4(c);d&&r.push(d)});var o=n.workbenchProjects||n.projects;(Array.isArray(o)?o:o&&typeof o=="object"?[].concat(o.projects||[],o.owned||[],o.invited||[]):[]).forEach(function(c){var d=G4(c);d&&r.push(d)});var a=Da(n.portfolioPositions||n.positions),l=Number(n.portfolioNav||n.nav);if((!Number.isFinite(l)||l<=0)&&(l=a.reduce(function(c,d){var p=Number(d.value??d.market_value??d.marketValue??0);return c+(Number.isFinite(p)&&p>0?p:0)},0)),a.forEach(function(c){var d=V4(c,l);d&&r.push(d)}),Da(n.newsItems).forEach(function(c){var d=Wb(c,!1);d&&r.push(d)}),r.length<6){var s=0;Da(n.newsItems).forEach(function(c){if(!(s>=6)){var d=Wb(c,!0);!d||d.severity==="high"||(r.push(d),s+=1)}})}return Y4(r).sort(function(c,d){var p=z0[c.severity]!=null?z0[c.severity]:9,g=z0[d.severity]!=null?z0[d.severity]:9;return p!==g?p-g:pu(d.receivedAt)-pu(c.receivedAt)}).slice(0,I4)}function X4(t,n){var r=Object.create(null);return Da(n).forEach(function(o){o&&o.id&&(r[o.id]=o)}),Da(t).map(function(o){var a=r[o.id];return!a||!a.ticker||!o.ticker?o:Object.assign({},o,{ticker:Object.assign({},o.ticker,a.ticker)})})}function q4(t){var n=t.onPrompt,r=(0,i.useState)(0);r[0];var o=r[1],a=(0,i.useState)(!1),l=a[0],s=a[1];(0,i.useEffect)(function(){for(var T=[],Y=0;Y<ph.length;Y+=12)T.push(ph.slice(Y,Y+12));T.forEach(function(B){wf.quotesFacade(B).then(function(ie){!ie||!ie.quotes||Object.keys(ie.quotes).forEach(function(ue){var ne=ie.quotes[ue];if(ne&&ne.available&&ne.price!=null&&Number.isFinite(Number(ne.price))&&Number(ne.price)>0){var Me=ne.quote_timestamp||ne.timestamp,nt=Me?typeof Me=="number"?Me:Date.parse(Me):null;YA({symbol:ue,price:Number(ne.price),change:ne.change!=null?Number(ne.change):null,changePercent:ne.changePercent!=null?Number(ne.changePercent):ne.change_pct!=null?Number(ne.change_pct):null,source:ne.source||"quotes_facade",data_mode:ne.is_stale?"stale":ne.data_mode||"eod",timestamp:Number.isFinite(nt)&&nt>0?nt:null,is_stale:!!ne.is_stale})}})}).catch(function(){})})},[]);var c=(0,i.useState)(null);c[0];var d=c[1],p=(0,i.useState)(!0);p[0];var g=p[1],f=(0,i.useState)(!1);f[0];var h=f[1];(0,i.useEffect)(function(){Fe()},[]);var x=(0,i.useState)(null);x[0];var v=x[1],y=(0,i.useState)(!0),k=y[0],A=y[1],j=(0,i.useState)([]),E=j[0],C=j[1],_=(0,i.useState)("all"),w=_[0],O=_[1],M=(0,i.useState)(null),U=M[0],ee=M[1],N=(0,i.useState)(function(){try{var T=localStorage.getItem("xyron.today.pinned");return T?JSON.parse(T):{}}catch{return{}}}),V=N[0],z=N[1],oe=(0,i.useState)(function(){try{var T=localStorage.getItem("xyron.today.muted");return T?JSON.parse(T):{}}catch{return{}}}),P=oe[0],W=oe[1];(0,i.useEffect)(function(){try{localStorage.setItem("xyron.today.pinned",JSON.stringify(V))}catch{}},[V]),(0,i.useEffect)(function(){try{localStorage.setItem("xyron.today.muted",JSON.stringify(P))}catch{}},[P]),(0,i.useEffect)(function(){function T(Y){var B=Y&&Y.detail&&Y.detail.id;B&&W(function(ie){if(ie[B])return ie;var ue=Object.assign({},ie);return ue[B]=!0,ue})}return window.addEventListener("xyron:today-mute",T),function(){window.removeEventListener("xyron:today-mute",T)}},[]);var R=(0,i.useState)(!1),ae=R[0],q=R[1];(0,i.useEffect)(function(){var T=!1;function Y(){var B=localStorage.getItem("xyron_jwt_token"),ie={"X-Xyron-Key":"","Content-Type":"application/json"};return B&&(ie.Authorization="Bearer "+B),ie}return fetch(qr("/api/today/state"),{headers:Y()}).then(function(B){return B.ok?B.json():null}).then(function(B){T||!B||(B.pinned&&Object.keys(B.pinned).length&&z(function(ie){return Object.assign({},ie,B.pinned)}),B.muted&&Object.keys(B.muted).length&&W(function(ie){return Object.assign({},ie,B.muted)}))}).catch(function(){}).finally(function(){T||q(!0)}),function(){T=!0}},[]),(0,i.useEffect)(function(){if(ae){var T=localStorage.getItem("xyron_jwt_token");if(T){var Y=setTimeout(function(){var B={"X-Xyron-Key":"","Content-Type":"application/json",Authorization:"Bearer "+T};fetch(qr("/api/today/state"),{method:"PUT",headers:B,body:JSON.stringify({pinned:V,muted:P})}).catch(function(){})},500);return function(){clearTimeout(Y)}}}},[ae,V,P]);var ge=(0,i.useState)(HT),X=ge[0],de=ge[1],We=su(),te=(0,i.useState)(function(){return{status:We?"demo":"loading",failed:[]}}),_e=te[0],ve=te[1],Ne=i.useMemo(function(){return X.map(function(T){return T.wsSymbol}
372).filter(Boolean).sort().join("|")},[X]);(0,i.useEffect)(function(){var T=Ne?Ne.split("|"):[];if(T.length){var Y=$A(),B=HA(T),ie=GA(T,function(){de(function(ue){var ne=!1,Me=ue.map(function(nt){if(!nt.wsSymbol||!nt.ticker)return nt;var ct=XA(nt.wsSymbol);if(!ct||!isFinite(ct.price)||ct.price===0)return nt;var je=ct.price,Le=je>100?2:je>10?3:4,be=je.toFixed(Le);if(be===nt.ticker.value)return nt;ne=!0;var Wt=ct.direction>0?"up":ct.direction<0?"down":nt.ticker.direction,Te=isFinite(ct.change)?Math.abs(ct.change):null,it=Te!=null?Te.toFixed(Le):nt.ticker.delta;return Object.assign({},nt,{ticker:Object.assign({},nt.ticker,{value:be,direction:Wt,delta:it})})});return ne?Me:ue})});return function(){ie(),B(),Y()}}},[Ne,de]),(0,i.useEffect)(function(){Be();var T=setInterval(Be,6e4);return function(){clearInterval(T)}},[]);var $e=KA(),Pe=(0,i.useState)(0),ot=Pe[0],re=Pe[1],we=(0,i.useState)(null),b=we[0],He=we[1];(0,i.useEffect)(function(){function T(){try{var B=WA();B&&typeof B.reconnects=="number"&&re(B.reconnects)}catch{}}T();var Y=setInterval(T,1e3);return function(){clearInterval(Y)}},[]),(0,i.useEffect)(function(){var T=!1;function Y(){var ue=localStorage.getItem("xyron_jwt_token"),ne={"X-Xyron-Key":""};return ue&&(ne.Authorization="Bearer "+ue),ne}function B(){fetch(qr("/api/ops/pulse"),{headers:Y()}).then(function(ue){return ue.ok?ue.json():null}).then(function(ue){!T&&ue&&He(ue)}).catch(function(){})}B();var ie=setInterval(B,1e4);return function(){T=!0,clearInterval(ie)}},[]);var tt=(0,i.useState)(Date.now());tt[0];var Ae=tt[1];(0,i.useEffect)(function(){var T=setInterval(function(){Ae(Date.now())},6e4);return function(){clearInterval(T)}},[]),(0,i.useEffect)(function(){function T(Y){if(!(Y.metaKey||Y.ctrlKey||Y.altKey||Y.shiftKey)){var B=Y.target;if(!(B&&(B.tagName==="INPUT"||B.tagName==="TEXTAREA"||B.isContentEditable))){var ie=Y.key;ie==="1"?(Y.preventDefault(),O("all")):ie==="2"?(Y.preventDefault(),O("critical")):ie==="3"?(Y.preventDefault(),O("high")):ie==="4"&&(Y.preventDefault(),O("watch"))}}}return window.addEventListener("keydown",T),function(){window.removeEventListener("keydown",T)}},[]);function Be(){var T=localStorage.getItem("xyron_jwt_token"),Y={"X-Xyron-Key":""};T&&(Y.Authorization="Bearer "+T);function B(ne,Me){return Me||!ne||typeof ne!="object"||ne.error&&!(Array.isArray(ne.observations)&&ne.observations.length||Array.isArray(ne.high_impact)&&ne.high_impact.length||Array.isArray(ne.items)&&ne.items.length||Array.isArray(ne.upcoming)&&ne.upcoming.length||Array.isArray(ne.recent)&&ne.recent.length||Array.isArray(ne.alerts)&&ne.alerts.length||Array.isArray(ne.history)&&ne.history.length||Array.isArray(ne.files)&&ne.files.length||Array.isArray(ne.properties)&&ne.properties.length||Array.isArray(ne.entities)&&ne.entities.length||Array.isArray(ne.projects)&&ne.projects.length||Array.isArray(ne.positions)&&ne.positions.length||Array.isArray(ne)&&ne.length)?!0:D4(ne.status)}function ie(ne,Me,nt){return fetch(fA(Me),{headers:Y}).then(function(ct){return ct.ok?{name:tag(ne),data:ct.json(),httpFailed:!1}:{name:tag(ne),data:Promise.resolve(nt),httpFailed:!0}}).then(function(ct){return Promise.resolve(ct.data).then(function(je){var Le=B(je,ct.httpFailed);return{name:ct.name,data:je||nt,failed:Le}})}).catch(function(ct){return typeof console<"u"&&console.warn&&console.warn("[xyron] home feed "+ne+" unavailable:",ct&&ct.message),{name:tag(ne),data:nt,failed:!0}})}function ue(){return ie("ledgerEntities","/api/ledger/entities",{entities:[]}).then(function(ne){var Me=ne.data&&ne.data.entities||(Array.isArray(ne.data)?ne.data:[]),nt=Me.slice(),ct=[];if(Me.length>0){var je=Me.map(function(Le){return Le.id}).filter(Boolean).slice(0,10).join(",");je&&ct.push(ie("ledgerMatrix","/api/ledger/intercompany/matrix?entity_ids="+encodeURIComponent(je),{pairs:[]}).then(function(Le){Le.data&&Array.isArray(Le.data.pairs)&&Le.data.pairs.forEach(function(be){nt.push(be)})}).catch(function(){})),Me.forEach(function(Le){!Le||!Le.id||ct.push(ie("ledgerPayables_"+Le.id,"/api/ledger/"+encodeURIComponent(Le.id)+"/payables",{invoices:[]}).then(function(be){be.data&&Array.isArray(be.data.invoices)&&be.data.invoices.forEac
372h(function(Wt){nt.push({...Wt,entity_name:Le.name||Le.entity_name||"Operating Entity",entity_id:Le.id})})}).catch(function(){}))})}return Promise.all(ct).then(function(){return{name:"ledger",data:{items:nt,entities:Me},failed:ne.failed}})}).catch(function(){return{name:"ledger",data:{items:[],entities:[]},failed:!0}})}Promise.all([ie("observations","/api/alphaflash/observations/named?limit=8",{observations:[]}),ie("calendar","/api/alphaflash/calendar/upcoming?days=3",{high_impact:[]}),ie("econ","/api/markets/econ-calendar?days=3",{upcoming:[],recent:[]}),ie("news","/api/markets/news/feed?limit=20",{items:[]}),ie("alerts","/api/markets/alerts",{alerts:[]}),ie("alertHistory","/api/markets/alerts/history?limit=20",{history:[]}),ie("vault","/api/vault",{files:[],documents:[]}),ie("realEstate","/api/alt-assets/real-estate",{properties:[],holdings:[]}),ue(),ie("projects","/api/projects",{projects:[]}),ie("portfolio","/api/portfolio/positions",{positions:[]})]).then(function(ne){var Me={};ne.forEach(function(er){Me[er.name]=er});var nt=Me.observations||{data:{observations:[]},failed:!0},ct=Me.calendar||{data:{high_impact:[]},failed:!0},je=Me.econ||{data:{upcoming:[],recent:[]},failed:!0},Le=Me.news||{data:{items:[]},failed:!0},be=Me.alerts||{data:{alerts:[]},failed:!0},Wt=Me.alertHistory||{data:{history:[]},failed:!0},Te=Me.vault||{data:{files:[]},failed:!0},it=Me.realEstate||{data:{properties:[]},failed:!0},Tt=Me.ledger||{data:{entities:[]},failed:!0},bn=Me.projects||{data:{projects:[]},failed:!0},$r=Me.portfolio||{data:{positions:[]},failed:!0};if(v({obs:nt.data,cal:ct.data}),C([nt,ct].filter(function(er){return er.failed}).map(function(er){return er===nt?"observations":"calendar"})),A(!1),!We){var ai=K4({observations:nt.data&&nt.data.observations,calendarHighImpact:ct.data&&ct.data.high_impact,econUpcoming:je.data&&je.data.upcoming,econRecent:je.data&&je.data.recent,newsItems:Le.data&&Le.data.items,alerts:be.data&&be.data.alerts,alertHistory:Wt.data&&Wt.data.history,vaultDocuments:Te.data&&(Te.data.files||Te.data.documents||(Array.isArray(Te.data)?Te.data:[]))||[],realEstateAssets:it.data&&(it.data.properties||it.data.holdings||it.data.assets||(Array.isArray(it.data)?it.data:[]))||[],ledgerEntities:Tt.data&&(Tt.data.items||Tt.data.entities||(Array.isArray(Tt.data)?Tt.data:[]))||[],workbenchProjects:bn.data&&(bn.data.projects||(bn.data.owned||bn.data.invited?[].concat(bn.data.owned||[],bn.data.invited||[]):Array.isArray(bn.data)?bn.data:[]))||[],portfolioPositions:$r.data&&($r.data.positions||(Array.isArray($r.data)?$r.data:[]))||[],portfolioNav:$r.data&&$r.data.nav});de(function(er){return X4(ai,er)});var Nn=ne.some(function(er){return!er.failed});ve({status:ai.length?"ok":Nn?"empty":"unavailable",failed:ne.filter(function(er){return er.failed}).map(function(er){return er.name})})}}).catch(function(ne){typeof console<"u"&&console.warn&&console.warn("[xyron] home feed bundle unavailable:",ne&&ne.message),C(["observations","calendar"]),A(!1),We||ve({status:"unavailable",failed:["bundle"]})})}function Fe(){g(!0);var T=localStorage.getItem("xyron_jwt_token"),Y={"X-Xyron-Key":""};T&&(Y.Authorization="Bearer "+T),fetch(qr("/api/briefing/morning"),{headers:Y}).then(function(B){return B.ok?B.json():null}).then(function(B){B?d(B):h(!0)}).catch(function(){h(!0)}).finally(function(){g(!1)})}var ft=(0,i.useState)(null),St=ft[0],Xe=ft[1],It=(0,i.useState)({}),Rt=It[0],$=It[1],Ue=(0,i.useState)({}),Ie=Ue[0],Q=Ue[1],rt=UA(ph),jt={};gg.forEach(function(T){jt[T.sym]=R4(T,rt)});var tn={INDEX:"#8FA3B8",FX:"#6B9AC4",RATES:"#F59E0B",COMMOD:"#C89850",VOL:"#C85C5C",CRYPTO:"#C85C5C",EQUITY:"#A3E635"};(0,i.useEffect)(function(){var T=setInterval(function(){o(function(Y){return Y+1})},1e3);return function(){clearInterval(T)}},[]),(0,i.useEffect)(function(){var T=setTimeout(function(){s(!0)},80);return function(){clearTimeout(T)}},[]);function pt(T,Y,B,ie){if(Rt[T]){Xe(St===T?null:T);return}Xe(T),Q(function(ne){return Object.assign({},ne,{[T]:!0})});var ue="Asset: "+T+" | Category: "+Y+" | Price: "+B+" | Change: "+ie+". Return JSON with keys: verdict (BULLISH|BEARISH|NEUTRAL), headline (one sentence), driver (key driver), action (brief recommendation), keyLevel (important price level). Return raw JSON only.";gu({model:PS("empty_state"),max_tokens:300,system:"You are Xyron Intelligence. Return ONLY valid JSON.",messages:[{role:"user",content:ue}]}).then(function(ne){var Me=ne.content&&ne.content[0]&&ne.content[0].text||"{}";try{var nt=JSON.parse(Me.replace(/```json|```/g,"").trim());$(function(ct){return Object.assign({},ct,{[T]:nt})})}catch{$(function(ct){return Object.assign({},ct,{[T]:{_error:"AI analysis unavailable — response parse failed. Please retry.",verdict:"UNAVAILABLE",headline:"AI analysis unavailable — please retry.",driver:"",action:"",keyLevel:""}})})}Q(function(ct){var je=Object.assign({},ct);return delete je[T],je})}).catch(function(ne){typeof console<"u"&&console.warn&&console.warn("[xyron] EmptyState ticker AI unavailable for "+T+":",ne&&ne.message),$(function(Me){return Object.assign({},Me,{[T]:{_error:"AI analysis unavailable. Please retry.",verdict:"UNAVAILABLE",headline:"AI analysis unavailable — please retry.",driver:"",action:"",keyLevel:""}})}),Q(function(Me){var nt=Object.assign({},Me);return delete nt[T],nt})})}var gt=new Date;gt.getHours();var qt=gt.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit"}),Pt=gt.toLocaleDateString("en-GB",{weekday:"long",day:"numeric",month:"long",year:"numeric"}
372),Kt=St?gg.find(function(T){return T.sym===St}):null,xe=St?Rt[St]:null,fe=St?!!Ie[St]:!1,Ye=St?jt[St]:null,Qe=Kt&&tn[Kt.cat]||"#8FA3B8",ut=l?1:0,wt="opacity .6s ease, transform .6s ease",H=X.filter(function(T){return(T.severity||T.priority||"").toString().toLowerCase()==="critical"}).length,Z=C4(H);return(0,e.jsxs)(i.Fragment,{children:[(0,e.jsxs)("div",{ref:Z,style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden",background:"#02040A",position:"relative"},children:[(0,e.jsx)(jA,{duration:1400,delay:150}),(0,e.jsx)("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:0,opacity:.018,backgroundImage:"linear-gradient(#8FA3B8 1px,transparent 1px),linear-gradient(90deg,#8FA3B8 1px,transparent 1px)",backgroundSize:"40px 40px"}}),(0,e.jsx)("div",{style:{position:"relative",zIndex:1,flexShrink:0},children:(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",borderBottom:"1px solid #0D1520",background:"#020408",height:34,overflow:"hidden"},children:[(0,e.jsxs)("div",{style:{padding:"0 14px",borderRight:"1px solid #0D1520",flexShrink:0,display:"flex",alignItems:"center",gap:7,height:"100%",background:"#020408",zIndex:2},children:[(0,e.jsx)("div",{style:{width:5,height:5,borderRadius:"50%",background:"#8FA3B8"}}),(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:8,color:"#8FA3B8",letterSpacing:".14em",fontWeight:700},children:"MARKETS"})]}),(0,e.jsxs)("div",{style:{flex:1,overflow:"hidden",position:"relative",height:34},children:[(0,e.jsx)("div",{style:{position:"absolute",left:0,top:0,bottom:0,width:24,background:"linear-gradient(90deg,#020408,transparent)",zIndex:1,pointerEvents:"none"}}),(0,e.jsx)("div",{style:{position:"absolute",right:0,top:0,bottom:0,width:24,background:"linear-gradient(270deg,#020408,transparent)",zIndex:1,pointerEvents:"none"}}),(0,e.jsx)("div",{style:{display:"flex",alignItems:"center",height:"100%",animation:"xticker 80s ease-in-out infinite",width:"max-content"},onMouseEnter:function(T){T.currentTarget.style.animationPlayState="paused"},onMouseLeave:function(T){T.currentTarget.style.animationPlayState="running"},children:[0,1].map(function(T){return gg.map(function(Y){var B=jt[Y.sym],ie=tn[Y.cat]||"#8FA3B8",ue=St===Y.sym,ne=Ie[Y.sym],Me=Rt[Y.sym],nt=Me?Me.verdict==="BULLISH"?"#3FB950":Me.verdict==="BEARISH"?"#C85C5C":null:null;return(0,e.jsxs)("button",{onClick:function(){B.available&&pt(Y.sym,Y.cat,B.val,B.chg)},disabled:!B.available,style:{display:"flex",alignItems:"center",gap:7,padding:"0 16px",height:34,background:ue?"rgba(255,255,255,0.06)":"transparent",border:"none",borderRight:"1px solid #0A0F18",cursor:B.available?"pointer":"not-allowed",opacity:B.available?1:.58,flexShrink:0,position:"relative",transition:"background .12s"},onMouseEnter:function(ct){ue||(ct.currentTarget.style.background="rgba(255,255,255,0.04)")},onMouseLeave:function(ct){ue||(ct.currentTarget.style.background="transparent")},children:[ue&&(0,e.jsx)("div",{style:{position:"absolute",bottom:0,left:4,right:4,height:2,background:ie,borderRadius:1}}),nt&&(0,e.jsx)("div",{style:{width:4,height:4,borderRadius:"50%",background:nt,flexShrink:0}}),(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:8,color:"#7A90A8",letterSpacing:".05em",fontWeight:600,whiteSpace:"nowrap"},children:Y.sym}),(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:11,color:B.flash?"#FFFFFF":ie,fontWeight:800,transition:"color .4s",whiteSpace:"nowrap"},children:B.val}),(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:9,color:B.up===!0?"#3FB950":B.up===!1?"#C85C5C":"#5A7090",fontWeight:700,whiteSpace:"nowrap"},children:B.chg}),(0,e.jsx)("span",{title:(B.provider||"Unknown source")+(B.timestamp?" · "+String(B.timestamp):""),style:{fontFamily:"monospace",fontSize:7,color:B.modeColor,fontWeight:800,letterSpacing:".06em",whiteSpace:"nowrap"},children:B.modeLabel}),(0,e.jsx)("span",{style:{fontSize:7,color:ue?ie:"#2A3A50",marginLeft:1,transition:"color .15s"},children:"▾"}),ne&&(0,e.jsx)("div",{style:{width:4,height:4,borderRadius:"50%",background:ie,animation:"xpulse .6s infinite",flexShrink:0}}),(0,e.jsx)("span",{style:{color:"#1E2838",fontSize:10,marginLeft:4},children:"·"})]},T+"-"+Y.sym)})})})]}),(0,e.jsxs)("div",{style:{padding:"0 14px",borderLeft:"1px solid #0D1520",flexShrink:0,display:"flex",alignItems:"center",gap:8,height:"100%",background:"#020408",zIndex:2},children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:8,color:"#4A5A6E",letterSpacing:".04em",whiteSpace:"nowrap"},children:Pt}),(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:11,color:"#D4AF5C",fontWeight:700,minWidth:72,textAlign:"right"},children:qt})]})]})}),(0,e.jsxs)("div",{className:"xy-empty-scroll",style:{flex:1,overflowY:"auto",overflowX:"hidden",position:"relative",zIndex:1,padding:"24px 24px 16px"},children:[(function(){var T=X.reduce(function(be,Wt){return be[Wt.severity]=(be[Wt.severity]||0)+1,be},{}),Y=T.critical||0,B=T.high||0,ie=(T.info||0)+(T.medium||0),ue=Object.keys(P).filter(function(be){return P[be]}).length,ne=X.filter(function(be){var Wt=!!V[be.id],Te=!!P[be.id];return Wt?!0:Te&&w!=="all"?!1:w==="all"?!0:w==="critical"?be.severity==="critical":w==="high"?be.severity==="high":w==="watch"?be.severity==="info"||be.severity==="medium":!0}).slice().sort(function(be,Wt){var Te=V[be.id]?1:0;return(V[Wt.id]?1:0)-Te});function Me(be){var Wt=be.active,Te=be.color||(Wt?I.gold:I.ink5);return i.createElement("button",{onClick:be.onClick,title:be.title,style:{padding:"2px 8px",background:Wt?"rgba(212,175,92,0.10)":"transparent",border:"1px solid "+(Wt?"rgba(212,175,92,0.40)":"rgba(212,175,92,0.15)"),borderRadius:3,cursor:"pointer",fontFamily:I.mono,fontSize:9,letterSpacing:".10em",color:Te,fontWeight:Wt?700:500,whiteSpace:"nowrap",transition:"all 140ms "+I.ease}},be.children)}var nt=ne.length,ct=X.length,je=ct-nt-Object.keys(V).filter(function(be){return V[be]}).length,Le=We?"simulated digest":_e.status==="loading"?"loading verified alert feed":ct===0?_e.status==="empty"?"no verified alerts in current window":"verified alert feed unavailable":nt===ct?ct+" alerts · cross-domain digest":"showing "+nt+" of "+ct+(je>0?" · "+je+" filtered":"");return(0,e.jsxs)("div",{style:{width:"100%",marginBottom:16,opacity:ut,transform:l?"translateY(0)":"translateY(10px)",transition:wt,border:"1px solid rgba(212,175,92,0.15)",borderRadius:6,background:"rgba(6,8,13,0.95)",overflow:"hidden",maxHeight:320,display:"flex",flexDirection:"column"},children:[(0,e.jsxs)("div",{style:{flexShrink:0,padding:"8px 14px",borderBottom:"1px solid rgba(212,175,92,0.1)",display:"flex",justifyContent:"space-between",alignItems:"center",gap:14,flexWrap:"wrap",background:"rgba(6,8,13,0.95)",zIndex:1},children:[(0,e.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[(0,e.jsx)("span",{style:{fontSize:10,fontFamily:I.mono,color:I.gold,letterSpacing:".18em",fontWeight:700},children:"▌ TODAY"}),(0,e.jsx)("span",{style:{fontSize:9,fontFamily:I.mono,color:I.ink5,letterSpacing:".10em"},children:Le})]}),(0,e.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:5,flexWrap:"wrap"},children:[(0,e.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:5,marginRight:4,fontSize:9,fontFamily:I.mono,color:We?I.warn:ct?I.up:_e.status==="loading"?I.warn:I.ink5,letterSpacing:".10em"},children:[(0,e.jsx)(EA,{phase:1,size:4,color:We?I.warn:ct?I.up:_e.status==="loading"?I.warn:I.ink5}),We?"SIMULATED":ct?"FRESH":_e.status==="loading"?"LOADING":_e.status==="empty"?"EMPTY":"UNAVAILABLE"]}),ue>0?(0,e.jsxs)("button",{onClick:function(){W({})},title:"clear all muted rows",style:{padding:"2px 8px",background:"transparent",border:"1px solid rgba(143,163,184,0.20)",borderRadius:3,cursor:"pointer",fontFamily:I.mono,fontSize:9,letterSpacing:".10em",color:I.ink5,whiteSpace:"nowrap"},children:["⌫ ",ue," muted"]}):null,(0,e.jsx)(Me,{active:w==="all",onClick:function(){O("all")},title:"press 1",children:"1 · ALL · "+X.length}),(0,e.jsx)(Me,{active:w==="critical",color:I.critical,onClick:function(){O("critical")},title:"press 2",children:"2 · ●"+Y+" CRIT"}),(0,e.jsx)(Me,{active:w==="high",color:I.warn,onClick:function(){O("high")},title:"press 3",children:"3 · "+B+" HIGH"}),(0,e.jsx)(Me,{active:w==="watch",onClick:function(){O("watch")},title:"press 4",children:"4 · "+ie+" WATCH"})]})]}),(0,e.jsx)("div",{className:"xy-today-scroll",style:{flex:1,overflowY:"auto",overflowX:"hidden",padding:"4px 14px 6px"},children:ne.length===0?(0,e.jsx)("div",{style:{padding:"24px 0",fontFamily:I.mono,fontSize:10,
372color:I.ink5,letterSpacing:".10em",textAlign:"center"},children:ct===0?_e.status==="loading"?"Connecting to verified alert providers…":_e.status==="empty"?"No verified decisions are available in the current window.":"No verified decisions are available. Connect a supported alert provider or retry when the provider recovers.":"No events match this filter."}):ne.map(function(be,Wt){var Te=!!P[be.id];return(0,e.jsx)(CA,{severity:be.severity,time:be.time,category:be.category,headline:be.headline,sparkline:be.sparkline,ticker:be.ticker,countdown:be.countdown,impact:be.impact,sources:be.sources,confidence:be.confidence,aiAction:be.aiAction,contextCause:be.contextCause,entityImpact:be.entityImpact,aiRecommendation:be.aiRecommendation,actionRoute:be.actionRoute,staggerIndex:Wt,expanded:U===be.id,pinned:!!V[be.id],style:Te?{opacity:.45}:void 0,onClick:function(){ee(U===be.id?null:be.id)},onDrill:function(){ee(U===be.id?null:be.id)},onPin:function(){z(function(it){var Tt=Object.assign({},it);return Tt[be.id]?delete Tt[be.id]:Tt[be.id]=!0,Tt})},onMute:function(){W(function(it){var Tt=Object.assign({},it);return Tt[be.id]?delete Tt[be.id]:Tt[be.id]=!0,Tt});try{window.dispatchEvent(new CustomEvent("xyron:today-mute",{detail:{id:be.id}}))}catch{}},onEscalate:function(){t.onPrompt&&t.onPrompt("Escalate this alert and prepare a 60-second decision brief: "+be.headline)},onDismiss:function(){W(function(it){var Tt=Object.assign({},it);return Tt[be.id]=!0,Tt});try{window.dispatchEvent(new CustomEvent("xyron:today-mute",{detail:{id:be.id}}))}catch{}},onViewVault:function(it){try{window.dispatchEvent(new CustomEvent("xyron:navigate",{detail:{surface:"vault",route:it}}))}catch{}},onOpenRealEstate:function(it){try{window.dispatchEvent(new CustomEvent("xyron:navigate",{detail:{surface:"realestate",route:it}}))}catch{}},onOpenLedger:function(it){try{window.dispatchEvent(new CustomEvent("xyron:navigate",{detail:{surface:"ledger",route:it}}))}catch{}},onOpenProject:function(it){try{window.dispatchEvent(new CustomEvent("xyron:navigate",{detail:{surface:"projects",route:it}}))}catch{}},onInspectRoom:function(it){if(it&&it.symbol&&t.onPrompt)t.onPrompt("Inspect room and risk posture for "+it.symbol);else try{window.dispatchEvent(new CustomEvent("xyron:navigate",{detail:{surface:"terminal",route:it}}))}catch{}},onAskCortex:function(){var it=be.aiRecommendation?" Recommendation: "+be.aiRecommendation:"";t.onPrompt&&t.onPrompt("Drill into the alert: "+be.headline+"."+it+" Give me institutional context, position impact and recommended action.")},onOpenChart:function(){if(t.onPrompt){var it=be.ticker&&be.ticker.symbol?be.ticker.symbol:null;it?t.onPrompt("Generate a chart for "+it+" over the last 24 hours, annotated with the alert: "+be.headline):t.onPrompt("Generate the most relevant chart for this alert: "+be.headline)}},onDraftTicket:function(){if(t.onPrompt){var it=["Draft an institutional risk-ops ticket for the following alert:","","SEVERITY:    "+(be.severity||"info").toUpperCase(),"TIME:        "+(be.t
372ime||"—")+" UTC","CATEGORY:    "+(be.category||"—"),"HEADLINE:    "+(be.headline||"—"),be.contextCause?"CONTEXT:     "+be.contextCause:null,be.entityImpact?"IMPACT:      "+be.entityImpact:null,be.aiRecommendation?"AI RECO:     "+be.aiRecommendation:null,be.impact?"METRIC:      "+be.impact.value+(be.impact.label?" "+be.impact.label:""):null,be.confidence!=null?"CONFIDENCE:  "+be.confidence+"%":null,be.sources&&be.sources.length?"SOURCES:     "+be.sources.join(", "):null,be.aiAction?"AI ACTION:   "+be.aiAction:null,"","Format the ticket with: title, summary, decision required, recommended action, owner, due-by, evidence references. Output ready to paste into a ticketing system."].filter(Boolean).join(`
373`);t.onPrompt(it)}}},be.id)})}),(0,e.jsxs)("div",{style:{flexShrink:0,padding:"5px 14px",borderTop:"1px solid rgba(28,39,64,0.4)",display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:8,fontFamily:I.mono,color:I.ink5,letterSpacing:".10em",flexWrap:"wrap",gap:8,background:"rgba(6,8,13,0.95)"},children:[(0,e.jsx)("span",{children:We?"SIMULATED · fixture sources":ct?"verified provider sources":_e.status==="loading"?"loading providers":_e.status==="empty"?"providers connected · no current alerts":"provider unavailable · no verified sources"}),(0,e.jsx)("span",{children:We?"demo mode · not live data":ct?"current provider data":_e.status==="loading"?"first sync in progress":"waiting for current alert data"})]})]})})(),!k&&E.indexOf("observations")!==-1&&(0,e.jsx)("div",{style:{marginBottom:12},children:(0,e.jsx)(mv,{feedLabel:"MACRO FEED",detail:"observations fetch failed. Retrying on next cycle",testId:"macro-observations-unavailable"})}),!k&&E.indexOf("calendar")!==-1&&(0,e.jsx)("div",{style:{marginBottom:12},children:(0,e.jsx)(mv,{feedLabel:"CALENDAR FEED",detail:"upcoming-events fetch failed. Retrying on next cycle",testId:"macro-calendar-unavailable"})}),(0,e.jsx)("div",{className:"xy-home-tiles",style:{width:"100%",marginBottom:16,opacity:ut,transition:"opacity .6s .15s ease"},children:(0,e.jsx)(k4,{op:ut,workspace:t.workspace})}),(0,e.jsx)("div",{style:{display:"flex",gap:6,marginTop:28,flexWrap:"wrap",justifyContent:"center",width:"100%",opacity:ut,transition:"opacity .6s .32s ease"},children:[["◎ Market Snapshot","Give me a complete live market snapshot across all asset classes as of right now."],["⟁ 60s Risk Digest","Give me a 60-second risk digest of our current portfolio exposure and any critical alerts."],["◈ Generate Chart","Generate a chart of our PE allocation vs liquid assets over the last 24 months."],["⊞ Scenario Risk","Run a 200bp rate-shock scenario view across our fixed income and equity exposure."],["▣ Research Brief","Generate an executive intelligence brief for today including NAV, risk, and key macro events."]].map(function(T,Y){return(0,e.jsx)("button",{onClick:function(){T[1]&&n(T[1])},style:{padding:"7px 14px",background:"transparent",border:"1px solid #0D1520",borderRadius:20,color:"#3A4A5E",fontSize:8,fontFamily:"monospace",cursor:"pointer",letterSpacing:".07em",transition:"all .12s"},onMouseEnter:function(B){B.currentTarget.style.borderColor="#1E2838",B.currentTarget.style.color="#8FA3B8",B.currentTarget.style.background="rgba(143,163,184,0.04)"},onMouseLeave:function(B){B.currentTarget.style.borderColor="#0D1520",B.currentTarget.style.color="#3A4A5E",B.currentTarget.style.background="transparent"},children:T[0]},Y)})})]}),(function(){var T=["market","intel","twelveData","alphaFlash","truthSocial","politicalTrades","cortexLLM"],Y=T.reduce(function(be,Wt){return be+($e[Wt]&&$e[Wt].connected?1:0)},0),B=$e.market||{},ie=B.latency||"",ue=typeof ie=="string"&&/^\d/.test(ie)?parseInt(ie,10):null,ne=B.connected?new Date().toISOString().slice(11,19)+" UTC":null,Me=b||{},nt=Me.streams_ok!=null?Me.streams_ok:Y,ct=Me.streams_total!=null?Me.streams_total:T.length,je=Me.drift_ms!=null?Me.drift_ms:ue,Le=Me.ctx_pct!=null?Me.ctx_pct:null;return(0,e.jsx)(AA,{streamsOk:nt,streamsTotal:ct,audit:Me.audit||"on",drift:je,ctxPct:Le,sessionId:Me.session_id||null,lastSync:Me.last_sync||ne||"—",reconnects:ot,
373wsState:B.state})})()]}),St&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:{position:"fixed",inset:0,zIndex:9998,background:"rgba(0,0,0,0.65)"},onClick:function(){Xe(null)}}),(0,e.jsx)("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%,-50%)",zIndex:9999,width:500,borderRadius:14,overflow:"hidden",boxShadow:"0 40px 120px #000"},children:(0,e.jsxs)("div",{style:{background:"#0B0E18",border:"2px solid "+(Qe+"90"),borderRadius:14,overflow:"hidden"},children:[(0,e.jsx)("div",{style:{height:3,background:Qe,width:"100%"}}),(0,e.jsxs)("div",{style:{padding:"16px 20px 12px",background:"#0D1020",borderBottom:"1px solid #1A2030",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12},children:[(0,e.jsx)("div",{style:{width:36,height:36,borderRadius:9,background:Qe+"22",border:"2px solid "+Qe+"55",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,e.jsx)("div",{style:{width:10,height:10,borderRadius:"50%",background:Qe,boxShadow:"0 0 12px "+Qe}})}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:16,color:Qe,fontWeight:900},children:St}),(0,e.jsxs)("div",{style:{fontFamily:"monospace",fontSize:8,color:"#5A7090",marginTop:3,letterSpacing:".1em"},children:[Kt&&Kt.cat," · ",Ye&&Ye.provider||"SOURCE UNKNOWN"," · ",Ye&&Ye.modeLabel||"—"]})]})]}),(0,e.jsx)("button",{onClick:function(){Xe(null)},style:{width:28,height:28,background:"#161C2C",border:"1px solid #2A3548",borderRadius:6,cursor:"pointer",color:"#7A90A8",fontSize:14,display:"flex",alignItems:"center",justifyContent:"center"},onMouseEnter:function(T){T.currentTarget.style.color="#C85C5C"},onMouseLeave:function(T){T.currentTarget.style.color="#7A90A8"},children:"✕"})]}),(0,e.jsxs)("div",{style:{padding:"16px 20px",background:"#0B0E18",borderBottom:"1px solid #1A2030",display:"flex",alignItems:"center",gap:16},children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:28,color:Qe,fontWeight:900,letterSpacing:"-.02em",lineHeight:1},children:Ye&&Ye.val}),(0,e.jsxs)("div",{style:{fontFamily:"monospace",fontSize:12,color:Ye&&Ye.up===!0?"#3FB950":Ye&&Ye.up===!1?"#C85C5C":"#5A7090",fontWeight:700,marginTop:5},children:[Ye&&Ye.chg," TODAY"]})]}),xe&&xe.verdict&&(0,e.jsxs)("div",{style:{marginLeft:"auto",padding:"10px 16px",background:xe.verdict==="BULLISH"?"rgba(63,185,80,0.15)":xe.verdict==="BEARISH"?"rgba(200,92,92,0.15)":"rgba(245,158,11,0.15)",border:"1px solid "+(xe.verdict==="BULLISH"?"#3FB95050":xe.verdict==="BEARISH"?"#C85C5C50":"#F59E0B50"),borderRadius:8,textAlign:"center"},children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:7,color:"#7A90A8",letterSpacing:".12em",marginBottom:4},children:"AI VERDICT"}),(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:15,color:xe.verdict==="BULLISH"?"#3FB950":xe.verdict==="BEARISH"?"#C85C5C":"#F59E0B",fontWeight:900},children:xe.verdict})]}),xe&&xe.keyLevel&&(0,e.jsxs)("div",{style:{padding:"10px 16px",background:Qe+"15",border:"1px solid "+Qe+"40",borderRadius:8,textAlign:"center"},children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:7,color:"#7A90A8",letterSpacing:".12em",marginBottom:4},children:"KEY LEVEL"}),(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:15,color:Qe,fontWeight:900},children:xe.keyLevel})]})]}),(0,e.jsxs)("div",{style:{padding:"16px 20px",background:"#0B0E18",minHeight:90},children:[fe&&(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:12,padding:"12px 0"},children:[(0,e.jsx)("div",{style:{position:"relative",width:40,height:40},children:(0,e.jsx)("div",{style:{position:"absolute",inset:0,border:"2px solid transparent",borderTop:"2px solid "+Qe,borderRadius:"50%",animation:"xspin 1s linear infinite"}})}),(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:9,color:Qe,letterSpacing:".12em"},children:"GENERATING INTELLIGENCE…"})]}),!fe&&xe&&(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[xe.headline&&(0,e.jsx)("div",{style:{fontSize:13,color:"#D0D8E8",fontWeight:700,lineHeight:1.5},children:xe.headline}),xe.driver&&(0,e.jsx)("div",{style:{fontSize:11,color:"#7A90A8",lineHeight:1.7,padding:"9px 12px",background:"#0D1020",borderRadius:6,border:"1px solid #1A2030"},children:xe.driver}),xe.action&&(0,e.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"flex-start"},children:[(0,e.jsx)("span",{style:{color:Qe,fontSize:12,flexShrink:0},children:"→"}),(0,e.jsx)("span",{style:{fontSize:11,color:"#9AA8BC",lineHeight:1.6},children:xe.action})]})]}),!fe&&!xe&&(0,e.jsx)("div",{style:{textAlign:"center",padding:"10px 0",fontFamily:"monospace",fontSize:9,color:"#4A5A6E"},children:"Tap generate to build an AI intelligence brief"})]}),(0,e.jsxs)("div",{style:{padding:"12px 20px 16px",background:"#0D1020",borderTop:"1px solid #1A2030",display:"flex",gap:8},children:[!xe&&!fe&&(0,e.jsx)("button",{onClick:function(){pt(St,Kt&&Kt.cat,Ye&&Ye.val,Ye&&Ye.chg)}
373,style:{flex:1,padding:"10px 0",background:Qe,border:"none",borderRadius:7,cursor:"pointer",fontFamily:"monospace",fontSize:9,color:"#000",fontWeight:800,letterSpacing:".1em"},onMouseEnter:function(T){T.currentTarget.style.opacity=".85"},onMouseLeave:function(T){T.currentTarget.style.opacity="1"},children:"◈ GENERATE INTELLIGENCE →"}),xe&&!fe&&(0,e.jsx)("button",{onClick:function(){Xe(null),n("Full institutional analysis on "+St+". Price: "+(Ye&&Ye.val)+", change: "+(Ye&&Ye.chg)+". "+xe.headline)},style:{flex:1,padding:"10px 0",background:Qe,border:"none",borderRadius:7,cursor:"pointer",fontFamily:"monospace",fontSize:9,color:"#000",fontWeight:800,letterSpacing:".1em"},onMouseEnter:function(T){T.currentTarget.style.opacity=".85"},onMouseLeave:function(T){T.currentTarget.style.opacity="1"},children:"◈ FULL BRIEF IN CHAT →"}),(0,e.jsx)("button",{onClick:function(){Xe(null)},style:{padding:"10px 18px",background:"#161C2C",border:"1px solid #2A3548",borderRadius:7,cursor:"pointer",fontFamily:"monospace",fontSize:9,color:"#7A90A8"},onMouseEnter:function(T){T.currentTarget.style.borderColor="#3A4A5E",T.currentTarget.style.color="#C9D1D9"},onMouseLeave:function(T){T.currentTarget.style.borderColor="#2A3548",T.currentTarget.style.color="#7A90A8"},children:"CLOSE"})]})]})})]})]})}function hz(t){var n=t.docName,r=t.currentUser,o=t.onClose,a=(0,i.useState)(function(){return b0(n)}),l=a[0],s=a[1],c=(0,i.useState)(""),d=c[0],p=c[1],g=(0,i.useState)("note"),f=g[0],h=g[1],x={note:{color:"#D4AF5C",icon:"◆",label:"Note"},flag:{color:"#C85C5C",icon:"⚑",label:"Risk Flag"},action:{color:"#3FB950",icon:"✓",label:"Action Item"}};(0,i.useEffect)(function(){s(b0(n)),p("")},[n]),(0,i.useEffect)(function(){function y(k){k.key==="Escape"&&o()}return window.addEventListener("keydown",y),function(){window.removeEventListener("keydown",y)}},[o]);function v(){d.trim()&&(oA(n,{id:_y(),type:f,text:d.trim(),author:r?r.name:"Principal",role:r?r.role:"cio",ts:IS()+" "+Sf()}),s(b0(n)),p(""),oi({action:"annotation.added",detail:n+" — "+f,model:"user"}))}return(0,e.jsxs)("div",{style:{position:"fixed",right:0,top:0,bottom:0,width:"360px",background:"#0C1018",borderLeft:"1px solid #2A3548",display:"flex",flexDirection:"column",zIndex:760,boxShadow:"-8px 0 30px rgba(0,0,0,0.6)",animation:"xfadein 0.2s ease"},children:[(0,e.jsxs)("div",{style:{padding:"14px 18px",borderBottom:"1px solid #111820",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#7A8A9E",letterSpacing:"0.14em",marginBottom:"3px"},children:"ANNOTATIONS"}),(0,e.jsx)("div",{style:{fontSize:"13px",color:"#C9D1D9",fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"260px"},children:n})]}),(0,e.jsx)("button",{type:"button",onClick:o,"aria-label":"Close annotations",style:{background:"transparent",border:"1px solid #2A3548",borderRadius:"5px",color:"#C9D1D9",cursor:"pointer",minWidth:"64px",height:"28px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",fontFamily:"monospace",letterSpacing:"0.08em"},onMouseEnter:function(y){y.currentTarget.style.color="#C85C5C",y.currentTarget.style.borderColor="#C85C5C"},onMouseLeave:function(y){y.currentTarget.style.color="#C9D1D9",y.currentTarget.style.borderColor="#2A3548"},children:"CLOSE"})]}),(0,e.jsxs)("div",{style:{padding:"14px 16px",borderBottom:"1px solid #111820",flexShrink:0},children:[(0,e.jsx)("div",{style:{display:"flex",gap:"4px",marginBottom:"8px"},children:Object.keys(x).map(function(y){var k=f===y,A=x[y];return(0,e.jsxs)("button",{onClick:function(){h(y)},style:{flex:1,padding:"5px 0",background:k?A.color+"15":"transparent",border:"1px solid "+(k?A.color+"40":"#2A3548"),borderRadius:"5px",cursor:"pointer",fontFamily:"monospace",fontSize:"8px",color:k?A.color:"#7A8A9E",display:"flex",alignItems:"center",justifyContent:"center",gap:"4px"},children:[(0,e.jsx)("span",{children:A.icon}),A.label]},y)})}),(0,e.jsx)("textarea",{value:d,onChange:function(y){p(y.target.value)},rows:3,placeholder:"Add a "+x[f].label.toLowerCase()+"...",style:{width:"100%",background:"#0C1018",border:"1px solid #2A3548",borderRadius:"6px",padding:"9px 10px",color:"#C9D1D9",fontSize:"12px",lineHeight:"1.6",resize:"none",outline:"none",fontFamily:"sans-serif"},onFocus:function(y){y.target.style.borderColor=x[f].color+"80"},onBlur:function(y){y.target.style.borderColor="#2A3548"},onKeyDown:function(y){y.key==="Enter"&&y.ctrlKey&&v()}}),(0,e.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"6px"},children:[(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:"8px",color:"#5A6880"},children:"Ctrl+Enter to save"}),(0,e.jsx)("button",{onClick:v,disabled:!d.trim(),style:{padding:"5px 14px",background:d.trim()?x[f].color+"15":"transparent",border:"1px solid "+(d.trim()?x[f].color+"40":"#2A3548"),borderRadius:"5px",cursor:d.trim()?"pointer":"not-allowed",fontFamily:"monospace",fontSize:"8px",color:d.trim()?x[f].color:"#6B7A94"},children:"SAVE"})]})]}),(0,e.jsxs)("div",{style:{flex:1,overflow:"auto",padding:"10px 14px"},children:[l.length===0&&(0,e.jsx)("div",{style:{textAlign:"center",padding:"24px 0",fontFamily:"monospace",fontSize:"10px",color:"#5A6880"},children:"No annotations yet"}),l.map(function(y){var k=x[y.type]||x.note;return(0,e.jsxs)("div",{style:{background:"#0C1018",border:"1px solid "+k.color+"25",borderLeft:"3px solid "+k.color,borderRadius:"6px",padding:"10px 12px",marginBottom:"7px"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[(0,e.jsx)("span",{style:{color:k.color,fontSize:"10px"},children:k.icon}),(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:"8px",color:k.color,letterSpacing:"0.08em"},children:k.label.toUpperCase()})]}),(0,e.jsx)("button",{onClick:function(){tA(n,y.id),s(b0(n))},style:{background:"transparent",border:"none",cursor:"pointer",color:"#5A6880",fontSize:"10px",padding:0}
373,onMouseEnter:function(A){A.currentTarget.style.color="#C85C5C"},onMouseLeave:function(A){A.currentTarget.style.color="#2A3548"},children:"✕"})]}),(0,e.jsx)("div",{style:{fontSize:"12px",color:"#C9D1D9",lineHeight:"1.5",marginBottom:"7px"},children:y.text}),(0,e.jsxs)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:"#6B7A94"},children:[y.author," · ",y.role," · ",y.ts]})]},y.id)})]})]})}var $4=[7,14,30];function J4(t){if(typeof t!="string")return!1;const n=t.trim().toLowerCase();if(!n||n.length>320||n.indexOf(" ")!==-1)return!1;const r=n.indexOf("@");if(r<=0||r!==n.lastIndexOf("@"))return!1;const o=n.slice(r+1);return o.indexOf(".")>0&&!o.endsWith(".")}function jE(t,n){const r=n||null;return(t||[]).filter(o=>(o.parent_id||null)===r)}function wE(t,n,r){const o=n||null,a=new Set((r||[]).map(l=>l.id));return(t||[]).filter(l=>{const s=l.folder_id||null;return o===null?s===null||!a.has(s):s===o})}function Q4(t){if(t&&t.share)return null;const n=t&&t.error;if(typeof n=="string")return n;const r=n&&n.error;return r==="active_share_exists"?"An active share for this e-mail already exists — revoke it first.":r==="invalid_permission"?"Invalid permission.":r==="invalid_expiry"?"Expiry must be between 1 and 30 days.":"Share failed — check the e-mail and try again."}var hy={PDF:["application/pdf"],WORD:["application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],SHEET:["application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","text/csv"],TEXT:["text/plain","text/markdown","application/json"],IMAGE:["image/png","image/jpeg"]},yy={typeGroup:null,uploadedAfter:"",uploadedBefore:"",folderScope:!1,tags:[]};function Pg(t){return typeof t=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t)}var Z4=["ALL","STARRED","SHARED_WITH_ME"];function eR(t,n){n=n||{};const r={query:t,limit:n.limit||15},o=n.facets||{},a=n.classification;if(a&&Z4.indexOf(a)===-1&&(r.classification=a),o.typeGroup&&hy[o.typeGroup]&&(r.content_types=hy[o.typeGroup].slice()),o.folderScope&&n.folderId&&(r.folder_id=n.folderId),Pg(o.uploadedAfter)&&(r.uploaded_after=o.uploadedAfter),Pg(o.uploadedBefore)&&(r.uploaded_before=o.uploadedBefore),Array.isArray(o.tags)&&o.tags.length>0){const l=o.tags.map(s=>String(s).trim()).filter(Boolean);l.length>0&&(r.tags=l)}return r}function tR(t){const n=t||{};let r=0;return n.typeGroup&&r++,Pg(n.uploadedAfter)&&r++,Pg(n.uploadedBefore)&&r++,n.folderScope&&r++,Array.isArray(n.tags)&&n.tags.length>0&&r++,r}function TE(t){if(t&&Array.isArray(t.lanes)&&t.lanes.length>0)return t.lanes.slice();const n=t&&t.match_type;return n==="hybrid"?["keyword","semantic"]:n==="keyword"||n==="semantic"?[n]:[]}function nR(t){return TE(t).map(n=>n==="keyword"?"KW":n==="semantic"?"SEM":n.toUpperCase().slice(0,3))}function rR(t,n){const r=n||60,o=new Map,a=new Map,l=new Map,s=new Map;return(t||[]).forEach(c=>{(c||[]).forEach((d,p)=>{const g=d&&d.id;if(!g)return;const f=p+1;o.set(g,(o.get(g)||0)+1/(r+f)),(!a.has(g)||f<a.get(g))&&a.set(g,f),s.has(g)||s.set(g,Object.assign({},d));const h=l.get(g)||[];TE(d).forEach(x=>{h.indexOf(x)===-1&&h.push(x)}),l.set(g,h)})}),Array.from(s.keys()).sort((c,d)=>o.get(d)-o.get(c)||a.get(c)-a.get(d)||(c<d?-1:c>d?1:0)).map(c=>{const d=Object.assign({},s.get(c)),p=l.get(c).slice().sort();return p.length>0&&(d.lanes=p),d})}function iR(t){return rR([t||[]])}function oR(t,n,r,o){var a=typeof window<"u"?window.innerWidth:1280,l=typeof window<"u"?window.innerHeight:800,s=r||220,c=o||340;return{left:Math.max(8,Math.min(Number(t)||0,a-s-8)),top:Math.max(8,Math.min(Number(n)||0,l-c-8))}}function aR(t){if(!t)return"GENERAL";var n=t.ai_classification||t.type||"GENERAL";return String(n).toUpperCase()}function lR(t,n,r){var o=String(n||"").trim().toLowerCase();if(o.length<2||(t&&t.lanes||[]).indexOf("keyword")!==-1||[t&&t.name,t&&t.original_filename,t&&t.ai_summary,t&&t.snippet,t&&t.content,t&&t.type].join(" ").toLowerCase().indexOf(o)!==-1)return!0;var a=Number(t&&t.similarity),l=typeof r=="number"?r:.6;return Number.isFinite(a)&&a>=l}function Hb(t,n){if(!t)return!1;var r=URL.createObjectURL(t),o=document.createElement("a");return o.href=r,o.download=n||"document",o.rel="noopener",document.body.appendChild(o),o.click(),o.remove(),setTimeout(function(){URL.revokeObjectURL(r)},4e3),!0}var Gb=50,sR=[".pdf",".docx",".doc",".txt",".csv",".xlsx",".xls",".md",".json",".png",".jpg",".jpeg"];function cR(t,n){return!t||!t.id?!1:(n||[]).some(function(r){return r&&r.id===t.id})}function dR(t){const n=(t||[]).map(function(r){return r&&r.name?r.name:"file"}).join(", ");return(n?n+" — ":"")+"not supported. Use PDF, DOCX, TXT, CSV, XLSX, PNG, or JPG."}function uR(){const[t,n]=(0,i.useState)([]),[r,o]=(0,i.useState)(0),[a,l]=(0,i.useState)(!1),[s,c]=(0,i.useState)(null),[d,p]=(0,i.useState)(null),[g,f]=(0,i.useState)(""),[h,x]=(0,i.useState)("ALL"),[v,y]=(0,i.useState)("list"),[k,A]=(0,i.useState)("created_at"),[j,E]=(0,i.useState)("desc"),[C,_]=(0,i.useState)(Gb),[w,O]=(0,i.useState)([]),[M,U]=(0,i.useState)(null),[ee,N]=(0,i.useState)(nA),[V,z]=(0,i.useState)(S0),[oe,P]=(0,i.useState)([]),[W,R]=(0,i.useState)(null),[ae,q]=(0,i.useState)([]),[ge,X]=(0,i.useState)(null),[de,We]=(0,i.useState)(!1),[te,_e]=(0,i.useState)({...yy}),[ve,Ne]=(0,i.useState)(null),[$e,Pe]=(0,i.useState)(""),[ot,re]=(0,i.useState)(!1),[we,b]=(0,i.useState)([]),[He,tt]=(0,i.useState)([]),[Ae,Be]=(0,i.useState)(!1),Fe=(0,i.useRef)(null),ft=(0,i.useRef)(null),St=(0,i.useCallback)((je,Le,be)=>{ft.current&&clearTimeout(ft.current),R({text:je,ok:Le!==!1}),ft.current=setTimeout(function(){R(null)},be||5e3)},[]),Xe=(0,i.useCallback)(async()=>
373{l(!0);try{const je={limit:C,sort_by:k,sort_dir:j};h!=="ALL"&&h!=="STARRED"&&(je.doc_type=h);const Le=await gn.list(je);n(Le.documents||[]),o(Le.total||0)}catch{n([])}l(!1)},[C,k,j,h]);(0,i.useEffect)(()=>{Xe()},[Xe]);const It=(0,i.useCallback)(async()=>{try{c(await gn.stats())}catch{}},[]);(0,i.useEffect)(()=>{It()},[It]);const Rt=(0,i.useCallback)(async()=>{try{O((await gn.folders()).folders||[])}catch{}},[]);(0,i.useEffect)(()=>{Rt()},[Rt]);const $=(0,i.useCallback)(async()=>{Be(!0);try{tt((await gn.sharedWithMe()).shared||[])}catch{tt([])}Be(!1)},[]);(0,i.useEffect)(()=>{h==="SHARED_WITH_ME"&&$()},[h,$]);const Ue=(0,i.useCallback)(async je=>{if(!je||je.length<2){X(null);return}We(!0);try{const Le=eR(je,{limit:15,classification:h,folderId:M,facets:te}),be=await gn.search(je,Le);X({...be,results:iR(be.results||[])})}catch{X(null)}We(!1)},[h,M,te]),Ie=(0,i.useCallback)(je=>{f(je),clearTimeout(Fe.current),je.length>=2?Fe.current=setTimeout(()=>Ue(je),400):X(null)},[Ue]);(0,i.useEffect)(()=>{g.length>=2&&(clearTimeout(Fe.current),Fe.current=setTimeout(()=>Ue(g),250))},[te,h,M]);const Q=(0,i.useMemo)(()=>{if(h==="SHARED_WITH_ME")return He;let je=ge?ge.results.map(be=>({...be,similarity:be.similarity,matchType:be.match_type})):t;if(h==="STARRED"&&(je=je.filter(be=>ee.includes(be.name))),h!=="ALL"&&h!=="STARRED"&&h!=="SHARED_WITH_ME"){var Le=String(h).toUpperCase();je=je.filter(function(be){return aR(be)===Le})}return ge&&g.length>=2&&(je=je.filter(function(be){return lR(be,g)})),ge||(je=wE(je,M,w)),je},[h,He,ge,t,ee,M,w,g]);(0,i.useEffect)(()=>{a||de||h==="SHARED_WITH_ME"&&Ae||p(function(je){return je&&(cR(je,Q)?je:null)})},[a,de,Ae,h,Q]);const rt=(0,i.useCallback)(je=>{N(Le=>{const be=Le.includes(je)?Le.filter(Wt=>Wt!==je):[...Le,je];return aA(be),be})},[]),jt=(0,i.useCallback)(async je=>{if(!je||!je.trim())return;const Le=await gn.createFolder(je.trim(),M||null);Le&&Le.folder&&(oi({action:"vault.folder.created",detail:Le.folder.name,model:"system"}),Rt())},[M,Rt]),tn=(0,i.useCallback)(async je=>{await gn.deleteFolder(je)&&(U(Le=>Le===je?null:Le),Rt(),Xe())},[Rt,Xe]),pt=(0,i.useCallback)(async(je,Le)=>{!Le||!Le.trim()||await gn.updateFolder(je,{name:Le.trim()})&&Rt()},[Rt]),gt=(0,i.useCallback)(async(je,Le)=>{if(!je||je===Le)return!1;const be=await gn.updateFolder(je,{parent_id:Le||null});return be&&Rt(),!!be},[Rt]),qt=(0,i.useCallback)(async(je,Le)=>{const be=await gn.update(je,{folder_id:Le||null});return be&&(Xe(),Rt()),!!be},[Xe,Rt]),Pt=jE(w,M),Kt=M?w.find(je=>je.id===M):null,xe=(0,i.useCallback)(async(je,Le)=>{if(!je||je.length===0)return;const be=Le===void 0?M:Le,Wt=[];let Te=0;for(let Tt=0;Tt<je.length;Tt++){const bn="."+je[Tt].name.split(".").pop().toLowerCase();sR.includes(bn)?Wt.push(je[Tt]):Te++}if(Wt.length===0){St(dR(je),!1,8e3);return}P(Wt.map(Tt=>({name:Tt.name,id:_y()})));const it=[];for(const Tt of Wt)try{const bn=await gn.upload(Tt,Tt.name,"general",be||void 0);bn&&it.push(bn)}catch{}P([]),St(it.length+" file"+(it.length!==1?"s":"")+" uploaded"+(Te>0?" ("+Te+" skipped)":"")+(it.some(Tt=>Tt.intelligence_pending)?" — AI analysing...":""),!0,5e3),oi({action:"vault.upload",detail
373:it.map(Tt=>Tt.name).join(", "),model:"system"}),Xe(),Rt(),It()},[Xe,Rt,It,St,M]),fe=(0,i.useCallback)(async je=>{await gn.del(je)&&(p(Le=>Le&&Le.id===je?null:Le),q(Le=>Le.filter(be=>be!==je)),Xe(),It())},[Xe,It]),Ye=(0,i.useCallback)(async(je,Le)=>{await gn.update(je,{name:Le})&&(oi({action:"vault.doc.renamed",detail:Le,model:"system"}),Xe())},[Xe]),Qe=(0,i.useCallback)(async(je,Le)=>{await gn.update(je,{tags:Le}),Xe()},[Xe]),ut=(0,i.useCallback)(async je=>{let Le=je.download_url,be=je.content_preview||je.content;if(je.id){const Wt=await gn.content(je.id);if(Wt){Hb(Wt,je.name||je.original_filename||"document"),Fm(je.name),z(S0()),oi({action:"vault.doc.downloaded",detail:je.name,model:"system"});return}}if(!Le&&je.id){const Wt=await gn.get(je.id);Le=Wt?.download_url||Le,be=Wt?.content_preview||Wt?.content||be}if(Le){const Wt=document.createElement("a");Wt.href=Le,Wt.download=je.name,Wt.rel="noopener",document.body.appendChild(Wt),Wt.click(),Wt.remove()}else Hb(new Blob([be||"No content available"],{type:"text/plain"}),je.name||"document.txt");Fm(je.name),z(S0()),oi({action:"vault.doc.downloaded",detail:je.name,model:"system"})},[]),wt=(0,i.useCallback)(async(je,Le)=>{Ne(je),Pe(""),re(!0);try{let be=null;if(Le.id){const bn=await gn.analyseDocument(Le.id,je);bn&&bn.analysis&&bn.analysis.answer&&!bn.analysis.error&&(be=bn.analysis.answer)}if(be){Pe(be),oi({action:"vault.inline_ask",detail:Le.name+" — "+je.substring(0,60),model:"analyse-document"}),re(!1);return}let Wt=Le.content_preview||Le.content;if(!Wt&&Le.id){const bn=await gn.get(Le.id);Wt=bn?.content_preview||bn?.content||""}const Te=(Wt||"").substring(0,4e3),it="Document: "+Le.name+`
374
375`+Te;let Tt="";await new Promise((bn,$r)=>{_t.analyzeStream(it,`You are Xyron, a sovereign intelligence terminal for a UHNW family office. Analyse this document with precision. Use markdown formatting.
376
377User question: `+je,function(Nn){Tt+=Nn,Pe(Tt)},function(){bn()},function(Nn){$r(new Error(Nn||"Analysis failed"))})}),Tt||(Tt="(No response)"),Pe(Tt),oi({action:"vault.inline_ask",detail:Le.name+" — "+je.substring(0,60),model:"analyze-stream-fallback"})}catch(be){Pe("Error: "+(be.message||String(be)))}re(!1)},[]);(0,i.useEffect)(()=>{Ne(null),Pe(""),re(!1)},[d]);const H=(0,i.useCallback)(async je=>{await gn.reanalyse(je),St("Re-analysis started...",!0,3e3),setTimeout(()=>{Xe()},3e3)},[Xe,St]),Z=(0,i.useCallback)(async je=>await gn.contractAnalysis(je),[]),T=(0,i.useCallback)(async(je,Le)=>await gn.complianceCheck(je,Le),[]),Y=(0,i.useCallback)(async je=>await gn.crossDocAnalysis(je),[]),B=(0,i.useCallback)(async(je,Le)=>{if(ae.length===0)return;const be=await gn.bulk(ae,je,Le);return be&&(q([]),Xe(),It()),be},[ae,Xe,It]),ie=(0,i.useCallback)(je=>{p(Le=>!je||Le?.id===je.id?null:Object.assign({},je,{_entitiesLoading:!!je.id})),je&&je.id&&(Fm(je.name),z(S0()),gn.get(je.id).then(function(Le){!Le||!Le.id||p(function(be){return!be||be.id!==Le.id?be:Object.assign({},be,Le,{_entitiesLoading:!1})})}).catch(function(){p(function(Le){return!Le||Le.id!==je.id?Le:Object.assign({},Le,{_entitiesLoading:!1})})}))},[]),ue=(0,i.useCallback)(je=>{q(Le=>Le.includes(je)?Le.filter(be=>be!==je):[...Le,je])},[]),ne=(0,i.useCallback)(async je=>(await gn.shares(je)).shares||[],[]),Me=(0,i.useCallback)(async(je,Le,be,Wt)=>await gn.createShare(je,Le,be,Wt),[]),nt=(0,i.useCallback)(async je=>await gn.revokeShare(je),[]),ct=(0,i.useCallback)(async()=>{b((await gn.activity(30)).activities||[])},[]);return{docs:Q,rawDocs:t,total:r,loading:a,stats:s,selected:d,setSelected:ie,search:g,setSearch:Ie,searchResults:ge,searchLoading:de,searchFacets:te,setSearchFacets:_e,classification:h,setClassification:x,viewMode:v,setViewMode:y,sortBy:k,setSortBy:A,sortDir:j,setSortDir:E,pageLimit:C,setPageLimit:_,loadMore:()=>_(je=>je+Gb),hasMore:r>C,folders:w,currentFolders:Pt,parentFolder:Kt,curFolder:M,setCurFolder:U,starred:ee,toggleStar:rt,recent:V,uploading:oe,uploadMsg:W,multiSelect:ae,toggleMultiSelect:ue,setMultiSelect:q,inlineQ:ve,inlineA:$e,inlineBusy:ot,activity:we,loadDocs:Xe,loadStats:It,loadActivity:ct,uploadFiles:xe,deleteDoc:fe,renameDoc:Ye,updateTags:Qe,downloadDoc:ut,createFolder:jt,deleteFolder:tn,renameFolder:pt,moveDocToFolder:qt,moveFolderTo:gt,loadFolders:Rt,sharedDocs:He,sharedLoading:Ae,loadSharedWithMe:$,listShares:ne,createShare:Me,revokeShare:nt,askInline:wt,reanalyse:H,analyseContract:Z,checkCompliance:T,crossDocAnalysis:Y,bulkAction:B}}var D=vr,pe=va.amber,Ft=va.cyan,bt=va.green,et=va.red,To=va.purple,Ut=va.dim,du=va.bg,ln=va.card,Ke=va.border,xn="#C9D1D9",cn="#7A90A8",Lt="#6A8098";function Ql({label:t,color:n}){return(0,e.jsx)("span",{style:{fontFamily:D,fontSize:9,color:n||"#7A90A8",background:(n||"#7A90A8")+"14",border:"1px solid "+(n||"#7A90A8")+"28",borderRadius:3,padding:"1px 5px"},children:t})}var fR=["ALL","STARRED","SHARED_WITH_ME","FINANCE","LEGAL","COMPLIANCE","POLICY","GENERAL","NDA","LEASE","INSURANCE","TAX","INVOICE","STATEMENT","INTELLIGENCE"],pR=["
377Summarise the key findings in 3 bullet points","Extract all financial figures, amounts, and metrics","Identify risk clauses, red flags, and exposures","Extract all entities: people, organisations, dates, jurisdictions","Compare against standard compliance requirements","Draft a 2-paragraph executive briefing","Identify all obligations and deadlines","Generate a structured data table from this document"];function gR({vault:t,fileInputRef:n,onNewFolder:r,onSelectDoc:o}){const[a,l]=(0,i.useState)(""),s=t.searchFacets||yy,c=tR(s),d=(t.search||"").length>=2||c>0;function p(f){t.setSearchFacets({...s,...f})}function g(){const f=a.trim();f&&((s.tags||[]).includes(f)||p({tags:[...s.tags||[],f]}),l(""))}return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"xy-vault-toolbar",style:{padding:"10px 16px",borderBottom:"1px solid #111820",background:"#05080D",display:"flex",alignItems:"center",gap:8,flexShrink:0,flexWrap:"wrap"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,flex:1,minWidth:0},children:[t.curFolder&&(0,e.jsx)("button",{onClick:()=>{t.setCurFolder(null),o(null)},"data-vault-drop":"__up__",style:{padding:"3px 9px",background:"transparent",border:"1px solid "+Ke,borderRadius:5,cursor:"pointer",fontFamily:D,fontSize:9,color:"#7A90A8"},children:"← BACK"}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:10,color:t.curFolder?cn:pe,fontWeight:700,letterSpacing:".06em"},children:"⊞ VAULT"}),t.parentFolder&&(0,e.jsxs)("span",{style:{fontFamily:D,fontSize:10,color:pe},children:["› ",t.parentFolder.name]}),t.stats&&(0,e.jsxs)("span",{style:{fontFamily:D,fontSize:8,color:Ut,marginLeft:8},children:[t.stats.total_documents," docs ·"," ",t.stats.intelligence_coverage,"% AI coverage"]})]}),(0,e.jsxs)("div",{style:{position:"relative"},children:[(0,e.jsx)("span",{style:{position:"absolute",left:9,top:"50%",transform:"translateY(-50%)",color:Lt,fontSize:11,pointerEvents:"none"},children:"⌕"}),(0,e.jsx)("input",{value:t.search,onChange:f=>t.setSearch(f.target.value),placeholder:"Search vault…","aria-label":"Search vault",className:"xy-vault-search",style:{background:ln,border:"1px solid "+Ke,borderRadius:6,padding:"5px 10px 5px 26px",color:xn,fontFamily:D,fontSize:10,outline:"none",width:180,maxWidth:"100%",transition:"width .2s"},onFocus:f=>{f.target.style.width="min(240px, 100%)",f.target.style.borderColor=pe},onBlur:f=>{f.target.style.width="180px",f.target.style.borderColor=Ke}}),t.searchLoading&&(0,e.jsx)("span",{style:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",fontFamily:D,fontSize:8,color:pe},children:"⟳"})]}),(0,e.jsxs)("select",{value:t.sortBy+":"+t.sortDir,onChange:f=>{const[h,x]=f.target.value.split(":");t.setSortBy(h),t.setSortDir(x)},style:{background:ln,border:"1px solid "+Ke,borderRadius:5,padding:"4px 8px",color:cn,fontFamily:D,fontSize:8,outline:"none",cursor:"pointer"},children:[(0,e.jsx)("option",{value:"created_at:desc",children:"Newest"}),(0,e.jsx)("option",{value:"created_at:asc",children:"Oldest"}),(0,e.jsx)("option",{value:"name:asc",children:"A–Z"}),(0,e.jsx)("option",{value:"name:desc",children:"Z–A"}),(0,e.jsx)("option",{value:"size_bytes:desc",children:"Largest"})]}),(0,e.jsx)("div",{style:{display:"flex",background:ln,border:"1px solid "+Ke,borderRadius:5,overflow:"hidden"},children:[["list","☰"],["grid","⊞"],["columns","▥"]].map(([f,h])=>(0,e.jsx)("button",{onClick:()=>t.setViewMode(f),style:{padding:"4px 9px",background:t.viewMode===f?pe+"18":"transparent",border:"none",cursor:"pointer",color:t.viewMode===f?pe:Lt,fontSize:12},children:h},f))}),(0,e.jsxs)("button",{onClick:r,style:{padding:"4px 10px",background:"transparent",border:"1px solid "+Ke,borderRadius:5,cursor:"pointer",fontFamily:D,fontSize:8,color:cn},children:[Na.folder," NEW FOLDER"]}),(0,e.jsx)("input",{ref:n,type:"file",multiple:!0,style:{display:"none"},onChange:f=>{t.uploadFiles(f.target.files),f.target.value=""}}),(0,e.jsxs)("button",{onClick:()=>n.current?.click(),style:{padding:"4px 10px",background:pe+"14",border:"1px solid "+pe+"40",borderRadius:5,cursor:"pointer",fontFamily:D,fontSize:8,color:pe,fontWeight:700},children:[Na.upload," UPLOAD"]}),t.multiSelect.length>0&&(0,e.jsxs)("div",{style:{display:"flex",gap:4},children:[(0,e.jsx)(Ql,{label:t.multiSelect.length+" selected",color:Ft}),(0,e.jsx)("button",{onClick:()=>t.bulkAction("archive"),style:{padding:"3px 8px",background:"transparent",border:"1px solid "+Ke,borderRadius:4,cursor:"pointer",fontFamily:D,fontSize:9,color:"#7A90A8"},children:"ARCHIVE"}),(0,e.jsx)("button",{onClick:()=>t.bulkAction("delete"),style:{padding:"3px 8px",background:"transparent",border:"1px solid "+et+"44",borderRadius:4,cursor:"pointer",fontFamily:D,fontSize:9,color:et},children:"DELETE"}),(0,e.jsx)("button",{onClick:()=>t.setMultiSelect([]),style:{padding:"3px 6px",background:"transparent",border:"none",cursor:"pointer",fontFamily:D,fontSize:9,color:"#7A90A8"},children:"✕"})]})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:2,padding:"6px 16px",background:du,borderBottom:"1px solid #0D1117",flexShrink:0,overflowX:"auto"},children:[fR.map(f=>(0,e.jsx)("button",{onClick:()=>t.setClassification(f),style:{padding:"3px 10px",background:t.classification===f?pe+"14":"transparent",border:"1px solid "+(t.classification===f?pe+"44":"#1C2333"),borderRadius:4,cursor:"pointer",fontFamily:D,fontSize:8,color:t.classification===f?pe:Lt,whiteSpace:"nowrap"},children:f==="STARRED"?"★ "+f:f==="SHARED_WITH_ME"?"⇄ SHARED WITH ME":f},f)),(0,e.jsx)("div",{style:{marginLeft:"auto",fontFamily:D,fontSize:8,color:"#5A6880",alignSelf:"center",flexShrink:0},children:t.search?t.docs.length+" results":t.total+" items"})]}),d&&(0,e.jsxs)("div",{style:{display:"flex",gap:6,padding:"6px 16px",background:"#05080D",borderBottom:"1px solid #0D1117",flexShrink:0,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsx)("span",{style:{fontFamily:D,fontSize:9,color:"#6A8098",letterSpacing:".12em"},children:"FACETS"}),(0,e.jsxs)("select",{value:s.typeGroup||"","aria-label":"File type facet",onChange:f=>p({typeGroup:f.target.value||null}),style:{background:ln,border:"1px solid "+(s.typeGroup?pe+"44":Ke),borderRadius:4,padding:"3px 6px",color:s.typeGroup?pe:"#7A90A8",fontFamily:D,fontSize:8,outline:"none",cursor:"pointer"},children:[(0,e.jsx)("option",{value:"",children:"ANY TYPE"}
377),Object.keys(hy).map(f=>(0,e.jsx)("option",{value:f,children:f},f))]}),(0,e.jsx)("input",{type:"date",value:s.uploadedAfter||"","aria-label":"Uploaded after",onChange:f=>p({uploadedAfter:f.target.value}),style:{background:ln,border:"1px solid "+(s.uploadedAfter?pe+"44":Ke),borderRadius:4,padding:"2px 6px",color:s.uploadedAfter?pe:"#7A90A8",fontFamily:D,fontSize:8,outline:"none"}}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:"#6A8098"},children:"→"}),(0,e.jsx)("input",{type:"date",value:s.uploadedBefore||"","aria-label":"Uploaded before",onChange:f=>p({uploadedBefore:f.target.value}),style:{background:ln,border:"1px solid "+(s.uploadedBefore?pe+"44":Ke),borderRadius:4,padding:"2px 6px",color:s.uploadedBefore?pe:"#7A90A8",fontFamily:D,fontSize:8,outline:"none"}}),t.curFolder&&(0,e.jsxs)("button",{onClick:()=>p({folderScope:!s.folderScope}),style:{padding:"3px 8px",background:s.folderScope?pe+"14":"transparent",border:"1px solid "+(s.folderScope?pe+"44":Ke),borderRadius:4,cursor:"pointer",fontFamily:D,fontSize:9,color:s.folderScope?pe:"#7A90A8"},children:[s.folderScope?"✓ ":"","THIS FOLDER"]}),(s.tags||[]).map(f=>(0,e.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontFamily:D,fontSize:8,color:Ft,background:Ft+"14",border:"1px solid "+Ft+"28",borderRadius:4,padding:"1px 6px"},children:[f,(0,e.jsx)("button",{onClick:()=>p({tags:s.tags.filter(h=>h!==f)}),style:{background:"transparent",border:"none",cursor:"pointer",color:Ft,fontSize:8,padding:0},children:"✕"})]},f)),(0,e.jsx)("input",{value:a,onChange:f=>l(f.target.value),onKeyDown:f=>{f.key==="Enter"&&g()},placeholder:"+ tag","aria-label":"Add tag facet",style:{background:"transparent",border:"1px dashed "+Ke,borderRadius:4,padding:"2px 6px",color:"#C9D1D9",fontFamily:D,fontSize:8,outline:"none",width:56}}),c>0&&(0,e.jsxs)("button",{onClick:()=>t.setSearchFacets({...yy}),style:{marginLeft:"auto",padding:"3px 8px",background:"transparent",border:"1px solid "+Ke,borderRadius:4,cursor:"pointer",fontFamily:D,fontSize:9,color:"#7A90A8"},children:["CLEAR (",c,")"]})]})]})}function mR(t,n){const r=n||[];return t&&r.includes(t.id)?r.slice():[t&&t.id].filter(Boolean)}function hR(t,n){const r=(t||[]).find(o=>o.id===n);return r&&r.parent_id||null}function yR(t){return!t||t==="__root__"||t==="__up__"?null:String(t)}var xy="vault-pointer-drag";function _E(t,n){if(t.button===0)try{window.dispatchEvent(new CustomEvent(xy,{detail:{startX:t.clientX,startY:t.clientY,...n}}))}catch{}}function RE(t){const[n,r]=i.useState(null),o=i.useRef(null),[a,l]=i.useState(null),s=(h,x)=>{const v=document.elementFromPoint(h,x),y=v&&v.closest?v.closest("[data-vault-drop]"):null;return y?y.getAttribute("data-vault-drop"):null},c=i.useCallback(async h=>{if(!h||h.over==null)return;let x=h.over==="__root__"?null:h.over;h.over==="__up__"&&(x=hR(t.folders,t.curFolder));let v=[];h.kind==="folder"?h.ids[0]!==x&&(v=[await t.moveFolderTo(h.ids[0],x)]):v=await Promise.all(h.ids.map(k=>t.moveDocToFolder(k,x)));const y=v.filter(Boolean).length;y===v.length&&y>0?l({ok:!0,n:y,kind:h.kind}):l({ok:!1,n:v.length-y,kind:h.kind}),setTimeout(()=>l(null),3200)},[t]),d=i.useCallback((h,x,v,y,k)=>{let A=!1;const j=C=>{if(!A&&Math.hypot(C.clientX-h,C.clientY-x)<6)return;A=!0,C.preventDefault();const _=s(C.clientX,C.clientY),w={kind:v,ids:y,label:k,x:C.clientX,y:C.clientY,over:_};o.current=w,r(w)},E=()=>{document.removeEventListener("mousemove",j,!0),document.removeEventListener("mouseup",E,!0),document.body.style.userSelect="";const C=o.current;o.current=null,r(null),A&&C&&c(C)};document.addEventListener("mousemove",j,!0),document.addEventListener("mouseup",E,!0),document.body.style.userSelect="none"},[c]),p=(h,x,v,y)=>{h.button===0&&(h.target.closest&&h.target.closest("button, input, a")||d(h.clientX,h.clientY,x,v,y))};return i.useEffect(()=>{const h=x=>{const v=x.detail||{};v.kind&&v.ids&&v.ids.length&&d(v.startX,v.startY,v.kind,v.ids,v.label||"")};return window.addEventListener(xy,h),()=>window.removeEventListener(xy,h)},[d]),{drag:n,moveNotice:a,beginDrag:p,beginDragAt:d,onDocMouseDown:(h,x)=>p(h,"doc",mR(x,t.multiSelect),x.name),onFolderMouseDown:(h,x)=>p(h,"folder",[x.id],x.name),dropTarget:n?n.over:null}}function FE({drag:t,moveNotice:n,noticeBottom:r=46}){return(0,e.jsxs)(e.Fragment,{children:[t&&(0,e.jsxs)("div",{style:{position:"fixed",left:t.x+12,top:t.y+10,zIndex:4e3,pointerEvents:"none",background:"#0C1018",border:"1px solid "+(t.over?pe:Ke),borderRadius:6,padding:"5px 10px",fontFamily:D,fontSize:9,color:t.over?pe:"#C9D1D9",boxShadow:"0 10px 30px rgba(0,0,0,0.7)",maxWidth:240,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[t.ids.length>1?t.ids.length+" items":t.label,t.over?"  →":""]}),n&&(0,e.jsx)("div",{style:{position:"absolute",bottom:r,left:12,right:12,zIndex:30,background:n.ok?"rgba(63,185,80,0.10)":"rgba(200,92,92,0.12)",border:"1px solid "+(n.ok?"rgba(63,185,80,0.35)":"rgba(200,92,92,0.45)"),borderRadius:6,padding:"6px 10px",fontFamily:D,fontSize:9,color:n.ok?"#3FB950":"#E06C6C",letterSpacing:".06em"},children:n.ok?"✓ "+(n.kind==="folder"?"FOLDER MOVED":n.n>1?n.n+" FILES MOVED":"FILE MOVED"):"✕ MOVE FAILED — SERVER REJECTED THE CHANGE"})]})}function ox({size:t=18,open:n=!1,color:r="#D4AF5C"}){return(0,e.jsxs)("svg",{width:t,height:t,viewBox:"0 0 20 20","aria-hidden":"true",style:{flexShrink:0,display:"block"},children:[(0,e.jsx)("path",{d:n?"M2 5.5 A1.5 1.5 0 0 1 3.5 4 H7.6 L9.2 5.8 H16 A1.5 1.5 0 0 1 17.5 7.3 V8.2 H5.4 L3.2 15.5 H3.5 A1.5 1.5 0 0 1 2 14 Z M5.9 9.6 H19 L16.8 15.6 A1.5 1.5 0 0 1 15.4 16.6 H3.9 Z":"M2 5.5 A1.5 1.5 0 0 1 3.5 4 H7.6 L9.2 5.8 H16.5 A1.5 1.5 0 0 1 18 7.3 V14.5 A1.5 1.5 0 0 1 16.5 16 H3.5 A1.5 1.5 0 0 1 2 14.5 Z",fill:r+"22",stroke:r,strokeWidth:"1.1",strokeLinejoin:"round"}),!n&&(0,e.jsx)("path",{d:"M2 8.4 H18",stroke:r+"55",strokeWidth:"0.8"})]})}function Vb({doc:t}){return!Array.isArray(t.lanes)||t.lanes.length===0?null:(0,e.jsx)(e.Fragment,{children:nR(t).map((n,r)=>(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:n==="KW"?Ft:To,op
377acity:.75,border:"1px solid "+(n==="KW"?Ft:To)+"22",borderRadius:2,padding:"0px 3px"},children:n},"lane"+r))})}var xR=500*1024*1024*1024;function vR({folder:t,vault:n,dropTarget:r,onFolderMouseDown:o,onSelectDoc:a}){const[l,s]=(0,i.useState)(null),c=l!==null;function d(f){f.stopPropagation(),s(t.name||"")}function p(){s(null)}function g(){const f=(l||"").trim();s(null),!(!f||f===t.name)&&n.renameFolder(t.id,f)}return(0,e.jsxs)("div",{onClick:()=>{c||(n.setCurFolder(t.id),a(null))},"data-vault-drop":t.id,onMouseDown:f=>{c||o(f,t)},style:{display:"flex",alignItems:"center",gap:9,padding:"7px 12px",cursor:"pointer",borderBottom:"1px solid #0D1117",transition:"background .15s",background:r===t.id?pe+"1A":void 0,outline:r===t.id?"1px dashed "+pe:"none",outlineOffset:-1},onMouseEnter:f=>{f.currentTarget.style.background=ln},onMouseLeave:f=>{f.currentTarget.style.background="transparent"},children:[(0,e.jsx)(ox,{size:18,color:r===t.id?pe:"#B08D3E"}),c?(0,e.jsx)("input",{autoFocus:!0,value:l,"aria-label":"Rename folder",onClick:f=>f.stopPropagation(),onMouseDown:f=>f.stopPropagation(),onChange:f=>s(f.target.value),onKeyDown:f=>{f.stopPropagation(),f.key==="Enter"&&g(),f.key==="Escape"&&p()},onBlur:g,style:{flex:1,minWidth:0,background:"transparent",border:"none",borderBottom:"1px solid "+pe,color:xn,fontFamily:D,fontSize:12,outline:"none",padding:"1px 4px"}}):(0,e.jsx)("span",{style:{fontSize:12,color:xn,flex:1},children:t.name}),(0,e.jsxs)("span",{style:{fontFamily:D,fontSize:8,color:Lt},children:[t.file_count||0," files"]}),(0,e.jsx)("button",{type:"button",title:"Rename folder",onClick:d,onMouseDown:f=>f.stopPropagation(),style:{background:"transparent",border:"none",cursor:"pointer",color:Lt,fontFamily:D,fontSize:8,letterSpacing:".06em",fontWeight:700},onMouseEnter:f=>{f.currentTarget.style.color=pe},onMouseLeave:f=>{f.currentTarget.style.color=Lt},children:"RENAME"}),(0,e.jsx)("button",{onClick:f=>{f.stopPropagation(),n.deleteFolder(t.id)},style:{background:"transparent",border:"none",cursor:"pointer",color:Lt,fontSize:11},onMouseEnter:f=>{f.currentTarget.style.color=et},onMouseLeave:f=>{f.currentTarget.style.color=Lt},children:"✕"})]})}function Yb(t){if(!t||t<=0)return"0MB";const n=t/(1024*1024*1024);return n>=1?(n>=100?Math.round(n):n.toFixed(1))+"GB":(t/(1024*1024)).toFixed(1)+"MB"}function bR({vault:t,sel:n,onSelectDoc:r,onOpenCtxMenu:o}){const a=t.stats&&t.stats.storage_cap_bytes||xR,{drag:l,moveNotice:s,onDocMouseDown:c,onFolderMouseDown:d,dropTarget:p}=RE(t);return(0,e.jsxs)("div",{className:"xy-vault-list"+(n?" xy-vault-list-has-sel":""),style:{width:n?"360px":"100%",flexShrink:0,display:"flex",flexDirection:"column",overflow:"hidden",borderRight:n?"1px solid #111820":"none"},children:[(0,e.jsxs)("div",{style:{flex:1,overflowY:"auto"},children:[t.currentFolders.map(g=>(0,e.jsx)(vR,{folder:g,vault:t,dropTarget:p,onFolderMouseDown:d,onSelectDoc:r},g.id)),t.loading?(0,e.jsx)("div",{style:{padding:40,textAlign:"center",fontFamily:D,fontSize:10,color:Ut},children:"LOADING..."}):t.viewMode==="grid"?(0,e.jsx)("div",{style:{padding:10,display:"flex",flexWrap:"wrap",gap:8,alignContent:"flex-start"},children:t.docs.map(g=>{const f=ld(g.name),h=n?.id===g.id;return(0,e.jsxs)("div",{onClick:()=>r(g),onMouseDown:x=>c(x,g),onContextMenu:x=>{x.preventDefault(),x.stopPropagation(),o({x:x.clientX,y:x.clientY,doc:g})},style:{width:110,padding:"12px 8px",background:h?pe+"0C":ln,border:"1px solid "+(h?pe+"66":Ke),borderRadius:8,cursor:"default",display:"flex",flexDirection:"column",alignItems:"center",gap:7,position:"relative",transition:"all .15s"},onMouseEnter:x=>{h||(x.currentTarget.style.borderColor=pe)},onMouseLeave:x=>{h||(x.currentTarget.style.borderColor=Ke)},children:[t.starred.includes(g.name)&&(0,e.jsx)("span",{style:{position:"absolute",top:5,left
377:6,fontSize:10,color:pe},children:"★"}),(0,e.jsx)("div",{style:{width:44,height:54,background:f+"14",border:"1px solid "+f+"28",borderRadius:5,display:"flex",alignItems:"center",justifyContent:"center",fontFamily:D,fontSize:10,color:f,fontWeight:700},children:tc(g.name)}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:h?pe:cn,textAlign:"center",wordBreak:"break-word",lineHeight:"1.4"},children:g.name.replace(/\.(pdf|docx|xlsx|csv|txt|md)$/i,"").substring(0,20)}),g.ai_classification&&(0,e.jsx)(Ql,{label:g.ai_classification,color:To}),(0,e.jsx)(Vb,{doc:g})]},g.id||g.name)})}):(0,e.jsxs)("div",{children:[t.docs.map(g=>{const f=ld(g.name),h=n?.id===g.id,x=t.starred.includes(g.name),v=t.multiSelect.includes(g.id);return(0,e.jsxs)("div",{onClick:()=>r(g),onMouseDown:y=>c(y,g),onContextMenu:y=>{y.preventDefault(),y.stopPropagation(),o({x:y.clientX,y:y.clientY,doc:g})},style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderBottom:"1px solid #0A0E14",cursor:"default",background:h?pe+"0A":"transparent",borderLeft:h?"2px solid "+pe:"2px solid transparent",transition:"background .1s"},onMouseEnter:y=>{h||(y.currentTarget.style.background="#080B12")},onMouseLeave:y=>{h||(y.currentTarget.style.background="transparent")},children:[(0,e.jsx)("button",{onClick:y=>{y.stopPropagation(),t.toggleMultiSelect(g.id)},style:{width:16,height:16,borderRadius:3,border:"1px solid "+(v?Ft:Ke),background:v?Ft+"33":"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:9,color:Ft,flexShrink:0,padding:0},children:v?"✓":""}),(0,e.jsx)("div",{style:{width:24,height:24,background:f+"18",border:"1px solid "+f+"22",borderRadius:4,display:"flex",alignItems:"center",justifyContent:"center",fontFamily:D,fontSize:9,color:f,fontWeight:700,flexShrink:0},children:tc(g.name)}),(0,e.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,e.jsxs)("div",{style:{fontSize:11,color:h?pe:xn,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"flex",alignItems:"center",gap:5},children:[x&&(0,e.jsx)("span",{style:{color:pe,fontSize:9},children:"★"}),g.name,g.intelligence?.urgency==="HIGH"&&(0,e.jsx)(Ql,{label:"HIGH RISK",color:et}),g.share&&(0,e.jsx)(Ql,{label:"⇄ "+(g.share.permission||"").toUpperCase(),color:Ft}),(0,e.jsx)(Vb,{doc:g})]}),g.ai_summary&&(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:"#6A8098",marginTop:2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:g.ai_summary.substring(0,80)}),(0,e.jsx)("div",{style:{display:"flex",gap:3,marginTop:2},children:(g.tags||[]).slice(0,4).map((y,k)=>(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:cn,background:ln,border:"1px solid #1C2333",borderRadius:2,padding:"1px 3px"},children:y},k))})]}),(0,e.jsx)(Ql,{label:g.ai_classification||g.type||"",color:To}),!n&&(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:"#7A90A8",flexShrink:0},children:g.size_bytes?(g.size_bytes/1024).toFixed(0)+"KB":""}),!n&&(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:"#6A8098",flexShrink:0},children:(g.created_at||"").substring(0,10)}),(0,e.jsx)("button",{onClick:y=>{y.stopPropagation(),t.toggleStar(g.name)},style:{background:"transparent",border:"none",cursor:"pointer",fontSize:12,color:x?pe:Ke,padding:0},children:"★"}),(0,e.jsx)("button",{onClick:y=>{y.stopPropagation(),o({x:y.clientX,y:y.clientY,doc:g})},style:{background:"transparent",border:"none",cursor:"pointer",fontSize:11,color:"#5A6880",padding:0},children:"⋯"})]},g.id||g.name)}),t.docs.length===0&&!t.loading&&(0,e.jsxs)("div",{style:{padding:40,textAlign:"center"},children:[(0,e.jsx)("span",{style:{opacity:.35,display:"inline-block"},children:(0,e.jsx)(ox,{size:34,open:!0,color:"#B08D3E"})}),(0,e.jsx)("div",{style:{fontFamily:D,fontSize:10,color:"#6A8098",marginTop:8},children:t.search?"No results":"Drag files here to upload"})]})]}),t.hasMore&&(0,e.jsx)("div",{style:{padding:12,textAlign:"center"},children:(0,e.jsx)("button",{onClick:t.loadMore,style:{padding:"7px 24px",background:pe+"0C",border:"1px solid "+pe+"33",borderRadius:5,cursor:"pointer",fontFamily:D,fontSize:9,color:pe},children:"LOAD MORE"})})]}),(0,e.jsxs)("div",{style:{padding:"8px 14px",borderTop:"1px solid #0D1117",background:"#030507",flexShrink:0},children:[(0,e.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:4},children:[(0,e.jsx)("span",{style:{fontFamily:D,fontSize:9,color:Lt,letterSpacing:".1em"},children:"VAULT STORAGE"}),(0,e.jsxs)("span",{style:{fontFamily:D,fontSize:9,color:cn},children:[t.stats?Yb(t.stats.total_bytes):"—"," / ",Yb(a)]})]}),(0,e.jsx)("div",{style:{height:3,background:ln,borderRadius:2,overflow:"hidden"},children:(0,e.jsx)("div",{style:{height:"100%",width:t.stats?Math.min(100,t.stats.total_bytes/a*100)+"%":"1%",minWidth:3,background:"linear-gradient(90deg,"+bt+","+pe+")",borderRadius:2}})}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,marginTop:5,fontFamily:D,fontSize:9,color:"#5A6880"},children:[(0,e.jsxs)("span",{children:[t.total," docs"]}),(0,e.jsx)("span",{children:"·"}),(0,e.jsxs)("span",{children:[t.folders.length," folders"]}),(0,e.jsx)("span",{children:"·"}),(0,e.jsx)("span",{style:{color:bt},children:"AES-256"}),(0,e.jsx)("span",{children:"·"}),(0,e.jsxs)("span",{style:{color:Ft},children:[t.stats?.embedded_count||0," embedded"]})]})]}),(0,e.jsx)(FE,{drag:l,moveNotice:s})]})}function SR(t,n){const r=[{folderId:null,folder:null}];let o=null;for(const a of n||[]){const l=(t||[]).find(s=>s.id===a);if(!l||(l.parent_id||null)!==o)break;r.push({folderId:a,folder:l}),o=a}return r}function ER(t,n,r){return[...(t||[]).slice(0,n),r]}function kR(t,n,r){return{folders:jE(t,r),docs:wE(n,r,t)}}function CR(t){return t||"__root__"}var AR=230,jR=268;function wR(t){if(!t.size_bytes)return"—";const n=t.size_bytes/1024;return n>=1024?(n/1024).toFixed(1)+" MB":n.toFixed(0)+" KB"}function TR({vault:t,sel:n,onSelectDoc:r,onOpenCtxMenu:o,onPreviewDoc:a}){const[l,s]=i.useState([]),c=i.useRef(null),{drag:d,moveNotice:p,onDocMouseDown:g,onFolderMouseDown:f,dropTarget:h}=RE(t),x=t.rawDocs||t.docs,v=SR(t.folders,l),y=(A,j)=>{s(ER(l,A,j.id)),t.setCurFolder(j.id),n&&r(null)},k=n?n.id:null;return i.useEffect(()=>{const A=c.current;A&&(A.scrollLeft=A.scrollWidth)},[l.length,k]),(0,e.jsxs)("div",{className:"xy-vault-columns",style:{flex:1,display:"flex",overflow:"hidden",position:"relative"},children:[(0,e.jsxs)("div",{ref:c,className:"xy-vault-columns-scroll",style:{flex:1,display:"flex",overflowX:"auto",overflowY:"hidden"},children:[v.map((A,j)=>{const{folders:E,docs:C}=kR(t.folders,x,A.folderId),_=CR(A.folderId),w=h===_,O=l[j]||null;return(0,e.jsxs)("div",{className:"xy-vault-col","data-vault-drop":_,style:{width:AR,flexShrink:0,overflowY:"auto",borderRight:"1px solid #111820",background:w?pe+"08":"transparent",outline:w?"1px dashed "+pe+"66":"none",outlineOffset:-1},children:[E.map(M=>{const U=O===M.id,ee=h===M.id;return(0,e.jsxs)("div",{"data-vault-drop":M.id,onClick:()=>y(j,M),onMouseDown:N=>f(N,M),style:{display:"flex",alignItems:"center",gap:7,padding:"5px 10px",cursor:"pointer",background:ee?pe+"1A":U?pe+"14":"transparent",outline:ee?"1px dashed "+pe:"none",outlineOffset:-1,borderBottom:"1px solid #0A0E14"},onMouseEnter:N=>{U||(N.currentTarget.style.background=ln)},onMouseLeave:N=>{U||(N.currentTarget.style.background="transparent")},children:[(0,e.jsx)(ox,{size:15,open:U,color:ee||U?pe:"#B08D3E"}),(0,e.jsx)("span",{style:{fontSize:11,color:U?pe:xn,flex:1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:M.name}
377),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:10,color:U?pe:Lt,flexShrink:0},children:"›"})]},M.id)}),C.map(M=>{const U=ld(M.name),ee=n?.id===M.id;return(0,e.jsxs)("div",{onClick:()=>r(M),onMouseDown:N=>g(N,M),onContextMenu:N=>{N.preventDefault(),N.stopPropagation(),o({x:N.clientX,y:N.clientY,doc:M})},style:{display:"flex",alignItems:"center",gap:7,padding:"5px 10px",cursor:"default",background:ee?pe+"14":"transparent",borderLeft:ee?"2px solid "+pe:"2px solid transparent",borderBottom:"1px solid #0A0E14"},onMouseEnter:N=>{ee||(N.currentTarget.style.background="#080B12")},onMouseLeave:N=>{ee||(N.currentTarget.style.background="transparent")},children:[(0,e.jsx)("div",{style:{width:18,height:18,background:U+"18",border:"1px solid "+U+"22",borderRadius:3,display:"flex",alignItems:"center",justifyContent:"center",fontFamily:D,fontSize:8,color:U,fontWeight:700,flexShrink:0},children:tc(M.name)}),(0,e.jsxs)("span",{style:{fontSize:10,color:ee?pe:xn,flex:1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[t.starred.includes(M.name)&&(0,e.jsx)("span",{style:{color:pe,fontSize:9,marginRight:3},children:"★"}),M.name]})]},M.id||M.name)}),E.length===0&&C.length===0&&(0,e.jsx)("div",{style:{padding:"18px 10px",textAlign:"center",fontFamily:D,fontSize:9,color:"#6A8098"},children:"EMPTY"}),(0,e.jsx)("div",{style:{height:120}})]},_)}),n&&(0,e.jsxs)("div",{style:{width:jR,flexShrink:0,overflowY:"auto",borderRight:"1px solid #111820",padding:"18px 14px",display:"flex",flexDirection:"column",alignItems:"center",gap:10},children:[(()=>{const A=ld(n.name);return(0,e.jsx)("div",{style:{width:64,height:80,background:A+"14",border:"1px solid "+A+"33",borderRadius:6,display:"flex",alignItems:"center",justifyContent:"center",fontFamily:D,fontSize:13,color:A,fontWeight:700},children:tc(n.name)})})(),(0,e.jsx)("div",{style:{fontSize:11,color:"#C9D1D9",textAlign:"center",wordBreak:"break-word",lineHeight:1.4},children:n.name}),n.ai_classification&&(0,e.jsx)(Ql,{label:n.ai_classification,color:To}),(0,e.jsx)("div",{style:{width:"100%",borderTop:"1px solid "+Ke,paddingTop:10,display:"flex",flexDirection:"column",gap:5},children:[["SIZE",wR(n)],["CREATED",(n.created_at||"—").substring(0,10)],["MODIFIED",(n.updated_at||n.created_at||"—").substring(0,10)],["TYPE",tc(n.name)]].map(([A,j])=>(0,e.jsxs)("div",{style:{display:"flex",justifyContent:"space-between"},children:[(0,e.jsx)("span",{style:{fontFamily:D,fontSize:9,color:"#6A8098",letterSpacing:".08em"},children:A}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:9,color:"#7A90A8"},children:j})]},A))}),n.ai_summary&&(0,e.jsxs)("div",{style:{width:"100%",borderTop:"1px solid "+Ke,paddingTop:10},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:9,color:Ft,letterSpacing:".1em",marginBottom:5},children:"AI SUMMARY"}),(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:9,color:"#7A90A8",lineHeight:1.6},children:[n.ai_summary.substring(0,280),n.ai_summary.length>280?"…":""]})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,marginTop:4},children:[(0,e.jsx)("button",{onClick:()=>a&&a(n),style:{padding:"6px 16px",background:pe+"14",border:"1px solid "+pe+"40",borderRadius:5,cursor:"pointer",fontFamily:D,fontSize:9,color:pe,fontWeight:700},children:"PREVIEW"}),(0,e.jsx)("button",{onClick:()=>t.downloadDoc(n),style:{padding:"6px 16px",background:"transparent",border:"1px solid "+Ke,borderRadius:5,cursor:"pointer",fontFamily:D,fontSize:9,color:"#7A90A8"},children:"DOWNLOAD"})]}),n.intelligence?.urgency==="HIGH"&&(0,e.jsx)(Ql,{label:"HIGH RISK",color:et})]})]}),(0,e.jsx)(FE,{drag:d,moveNotice:p,noticeBottom:12})]})}var _R="Open the LEDGER panel and select an entity first";function IE(t){if(!t)return!1;var n=String(t.content_type||"").toLowerCase();if(n==="application/pdf"||n.indexOf("image/")===0)return!0;var r=String(t.name||t.original_filename||"").toLowerCase();return/\.(pdf|png|jpe?g|webp|tiff?|gif|heic)$/.test(r)}function RR(t,n){var r=n||"document";return t?t.status==="posted"?{ok:!0,posted:!0,text:"✓ POSTED — "+(typeof t.vendor=="string"&&t.vendor?t.vendor:t.vendor&&t.vendor.name||"vendor")+" "+(t.total||"")+" "+(t.currency||"")+" · invoice "+String(t.invoice_id||"").slice(0,8)+" · coded "+(t.coding&&t.coding.account_code||"?")+(t.coding&&t.coding.basis?" ("+t.coding.basis+")":"")+(t.warnings&&t.warnings.length?" · warnings: "+t.warnings.join(", "):"")}:t.status==="needs_review"?{ok:!1,posted:!1,text:"⚠ NEEDS REVIEW — "+r+": extraction confidence below floor — refine via the ledger AR/AP tab."}:t.status==="duplicate"?{ok:!1,posted:!1,text:"◌ DUPLICATE — "+r+" was already billed ("+String(t.invoice_id||"").slice(0,8)+")."}:{ok:!1,posted:!1,text:"✕ "+r+": "+String(t.error||t.detail||"processing failed").slice(0,200)}:{ok:!1,posted:!1,text:"✕ "+r+": processing failed"}}async function FR(t,n){n=n||{};var r=n.storage||(typeof localStorage<"u"?localStorage:null),o=n.fetchFn||(typeof fetch<"u"?fetch:null),a=n.apiUrlFn||function(g){return g},l=n.dispatch||function(g){try{window.dispatchEvent(new Event(g))}catch{}},s=t&&t.name||"document",c=null;try{c=r&&r.getItem("xyron_ledger_entity")}catch{}if(!c)return{ok:!1,posted:!1,text:_R};var d="";try{d=r&&r.getItem("xyron_jwt_token")||""}catch{}try{var p=RR(await(await o(a("/api/ledger-docbill/"+encodeURIComponent(c)+"/process"),{method:"POST",headers:{Authorization:"Bearer "+d,"Content-Type":"application/json"},body:JSON.stringify({vault_file_id:t.id})})).json(),s);if(p.posted)try{l("xyron:ledger-refresh")}catch{}return p}catch(g){return{ok:!1,posted:!1,text:"✕ "+s+": "+(g&&g.message||"request failed")}}}function Cs(t,n){return n==null||n===""?"":Array.isArray(n)?n.length===0?"":"**"+t+`**
378`+n.map(function(r){return r&&typeof r=="object"?"- "+(r.title||r.description||r.risk||JSON.stringify(r)):"- "+String(r)}).join(`
379`):typeof n=="object"?"**"+t+`**
380`+Object.keys(n).map(function(r){return"- "+r+": "+String(n[r])}).join(`
381`):"**"+t+`**
382`+String(n)}function ax(t){if(t==null)return null;if(typeof t=="string"){var n=t.trim();if(!n)return null;try{return JSON.parse(n)}catch{return n}}return t}function Kb(t){var n=ax(t);return n==null?"No contract analysis result.":typeof n!="object"?String(n):[Cs("Contract Type",n.contract_type||n.type),Cs("Parties",n.parties),Cs("Overall Risk",n.risk_assessment||n.overall_risk||n.risk),Cs("Specific Risks",n.specific_risks||n.risks),Cs("Executive Summary",n.executive_summary||n.summary)].filter(
382Boolean).join(`
383
384`)||"No contract analysis result."}function IR(t){var n=ax(t);return n==null?"No compliance result.":typeof n!="object"?String(n):[Cs("Compliance Status",n.compliance_status||n.status),Cs("Violations",n.violations),Cs("Warnings",n.warnings),Cs("Recommendations",n.recommendations),Cs("Executive Summary",n.executive_summary||n.summary)].filter(Boolean).join(`
385
386`)||"No compliance result."}function DR(t,n){if(t==="contract")return Kb(n);if(t==="compliance")return IR(n);var r=ax(n);return r==null?"No result.":typeof r=="string"?r:Kb(r)}function OR({vault:t,sel:n,onClose:r,onPreviewDoc:o,onAnnotate:a,onShare:l,onBillIt:s,analysisResult:c,analysisLoading:d,onContractAnalysis:p,onComplianceCheck:g,onRequestDelete:f}){if(!n)return null;const h=ld(n.name),x=n?.intelligence||{};return(0,e.jsxs)("div",{className:"xy-vault-detail",style:{flex:1,overflow:"auto",background:"#05080D",minWidth:0},children:[(0,e.jsxs)("div",{style:{padding:"14px 18px",borderBottom:"1px solid #111820",background:"#030507",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:10},children:[(0,e.jsxs)("div",{onMouseDown:v=>_E(v,{kind:"doc",ids:[n.id],label:n.name}),style:{display:"flex",alignItems:"center",gap:10,minWidth:0,cursor:"grab"},children:[(0,e.jsx)("div",{style:{width:34,height:34,background:h+"18",border:"1px solid "+h+"28",borderRadius:7,display:"flex",alignItems:"center",justifyContent:"center",fontFamily:D,fontSize:9,color:h,fontWeight:700,flexShrink:0},children:tc(n.name)}),(0,e.jsxs)("div",{style:{minWidth:0},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:4,marginBottom:3},children:[(0,e.jsx)(Ql,{label:n.ai_classification||n.type||"GENERAL",color:To}),x.urgency&&(0,e.jsx)(Ql,{label:x.urgency,color:x.urgency==="HIGH"?et:pe})]}),(0,e.jsx)("div",{style:{fontSize:13,fontWeight:600,color:xn,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n.name}),(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:8,color:cn,marginTop:2},children:[(n.created_at||"").substring(0,10)," · v",n.version||1]})]})]}),(0,e.jsx)("button",{onClick:r,style:{background:"transparent",border:"1px solid "+Ke,borderRadius:5,color:cn,fontSize:14,cursor:"pointer",padding:"3px 8px"},children:"✕"})]}),(0,e.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6,padding:"12px 18px",borderBottom:"1px solid #111820"},children:[{l:"▶ Preview",c:Ft,a:()=>{o&&o(n)}},{l:"↓ Download",c:bt,a:()=>t.downloadDoc(n)},...s&&IE(n)?[{l:"⎘ BILL IT — POST TO LEDGER",c:pe,a:()=>s(n)}]:[],{l:Na.link+" Share",c:To,a:()=>l(n)},{l:t.starred.includes(n.name)?"★ Starred":"☆ Star",c:pe,a:()=>t.toggleStar(n.name)},{l:"◈ Annotate",c:pe,a:()=>{a&&a(n.name)}},{l:"↻ Re-analyse",c:Ft,a:()=>t.reanalyse(n.id)},{l:"✕ Delete",c:et,a:()=>f?f(n):t.deleteDoc(n.id)}].map((v,y)=>(0,e.jsx)("button",{onClick:v.a,style:{padding:"5px 12px",background:"rgba(0,0,0,0.3)",border:"1px solid "+v.c+"44",borderRadius:5,cursor:"pointer",fontFamily:D,fontSize:8,color:v.c},onMouseEnter:k=>{k.currentTarget.style.background=v.c+"18"},onMouseLeave:k=>{k.currentTarget.style.background="rgba(0,0,0,0.3)"},children:v.l},y))}),(0,e.jsxs)("div",{style:{padding:"14px 18px",display:"flex",flexDirection:"column",gap:12},children:[n.ai_summary&&(0,e.jsxs)("div",{style:{background:ln,border:"1px solid "+To+"28",borderRadius:6,padding:"10px 12px",borderLeft:"3px solid "+To},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:9,color:To,letterSpacing:".1em",marginBottom:4},children:"AI SUMMARY"}),(0,e.jsx)("div",{style:{fontSize:11,color:"#C9D1D9",lineHeight:"1.6"},children:n.ai_summary})]}),(()=>{const v=k2(n),y=!!n._entitiesLoading&&v.length===0;return(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:9,color:cn,letterSpacing:".1em",marginBottom:5},children:"EXTRACTED ENTITIES"}),y?(0,e.jsx)("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:[1,2,3].map(k=>(0,e.jsx)("span",{style:{width:72,height:16,borderRadius:3,background:"rgba(122,144,168,0.12)",border:"1px solid "+Ke}},k))}):v.length>0?(0,e.jsx)("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:v.slice(0,12).map((k,A)=>{const j={person:Ft,org:To,amount:bt,date:pe};return(0,e.jsx)(Ql,{label:k.value,color:j[k.type]||"#7A90A8"},A)})}
386):(0,e.jsx)("div",{style:{fontFamily:D,fontSize:10,color:cn},children:"No entities extracted."})]})})(),x.risk_flags?.length>0&&(0,e.jsxs)("div",{style:{background:et+"08",border:"1px solid "+et+"22",borderRadius:6,padding:"10px 12px"},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:9,color:et,letterSpacing:".1em",marginBottom:5},children:"⚠ RISK FLAGS"}),x.risk_flags.map((v,y)=>{const k=DS(v);return(0,e.jsxs)("div",{style:{fontSize:10,color:"#C9D1D9",lineHeight:"1.5",display:"flex",gap:6},children:[(0,e.jsx)("span",{style:{color:et},children:"•"}),(0,e.jsxs)("span",{children:[k.severity&&(0,e.jsx)("span",{style:{fontFamily:D,fontSize:7,fontWeight:700,textTransform:"uppercase",color:et,border:"1px solid "+et+"55",borderRadius:3,padding:"0 4px",marginRight:5},children:k.severity}),k.text,k.location&&(0,e.jsxs)("span",{style:{color:"#7A90A8",fontStyle:"italic"},children:[" ","— ",k.location]})]})]},y)})]}),n.tags?.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:9,color:"#7A90A8",letterSpacing:".1em",marginBottom:5},children:"TAGS"}),(0,e.jsx)("div",{style:{display:"flex",gap:5,flexWrap:"wrap"},children:n.tags.map((v,y)=>(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:To,background:To+"14",border:"1px solid "+To+"28",borderRadius:4,padding:"2px 8px"},children:v},y))})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,e.jsx)("button",{onClick:()=>p(n.id),disabled:!!d,style:{flex:1,padding:"8px 12px",background:Ft+"0C",border:"1px solid "+Ft+"33",borderRadius:6,cursor:d?"default":"pointer",fontFamily:D,fontSize:8,color:Ft,fontWeight:700},children:d==="contract"?"◌ ANALYSING…":"⚖ CONTRACT ANALYSIS"}),(0,e.jsx)("button",{onClick:()=>g(n.id),disabled:!!d,style:{flex:1,padding:"8px 12px",background:bt+"0C",border:"1px solid "+bt+"33",borderRadius:6,cursor:d?"default":"pointer",fontFamily:D,fontSize:8,color:bt,fontWeight:700},children:d==="compliance"?"◌ CHECKING…":"✓ COMPLIANCE CHECK"})]}),c&&(0,e.jsxs)("div",{style:{background:ln,border:"1px solid "+Ft+"28",borderRadius:8,padding:"14px 16px",borderLeft:"3px solid "+Ft},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:9,color:Ft,letterSpacing:".12em",marginBottom:6},children:c.type==="contract"?"CONTRACT ANALYSIS":"COMPLIANCE CHECK"}),(0,e.jsx)(ws,{text:DR(c.type,c.data)})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:9,color:cn,letterSpacing:".1em",marginBottom:6},children:"ANALYSE WITH XYRON"}),(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:5},children:pR.map((v,y)=>(0,e.jsxs)("button",{onClick:()=>t.askInline(v,n),disabled:t.inlineBusy,style:{background:t.inlineQ===v?pe+"0C":ln,border:"1px solid "+(t.inlineQ===v?pe+"44":"#1C2333"),borderRadius:6,padding:"9px 12px",cursor:t.inlineBusy?"default":"pointer",textAlign:"left",display:"flex",alignItems:"center",gap:9,opacity:t.inlineBusy&&t.inlineQ!==v?.5:1},onMouseEnter:k=>{t.inlineBusy||(k.currentTarget.style.background=pe+"08")},onMouseLeave:k=>{t.inlineQ!==v&&(k.currentTarget.style.background=ln)},children:[(0,e.jsx)("span",{style:{color:pe,fontSize:8},children:t.inlineBusy&&t.inlineQ===v?"◌":"▶"}),(0,e.jsx)("span",{style:{fontSize:11,color:t.inlineQ===v?xn:cn,lineHeight:"1.4"},children:v})]},y))})]}),t.inlineQ&&(0,e.jsxs)("div",{style:{background:ln,border:"1px solid "+pe+"28",borderRadius:8,padding:"14px 16px",borderLeft:"3px solid "+pe},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:9,color:pe,letterSpacing:".12em",marginBottom:4},children:"XYRON INTELLIGENCE"}),(0,e.jsx)("div",{style:{fontFamily:D,fontSize:9,color:"#7A90A8",marginBottom:10},children:t.inlineQ}),t.inlineBusy?(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"12px 0"},children:[(0,e.jsx)("div",{style:{width:10,height:10,border:"2px solid transparent",borderTop:"2px solid "+pe,borderRadius:"50%",animation:"xspin 1s linear infinite"}}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:9,color:Ut},children:"Analysing document..."})]}):(0,e.jsx)(ws,{text:t.inlineA||""})]})]})]})}function LR({doc:t,onClose:n,email:r,onEmailChange:o,permission:a,onPermissionChange:l,expiry:s,onExpiryChange:c,busy:d,err:p,shares:g,onSubmit:f,onRevoke:h}){return t?(0,e.jsx)("div",{style:{position:"absolute",inset:0,zIndex:300,background:"rgba(0,0,0,0.7)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:n,role:"dialog",children:(0,e.jsxs)("div",{className:"xy-vault-share",onClick:x=>x.stopPropagation(),style:{width:470,maxWidth:"min(470px, calc(100vw - 24px))",maxHeight:"82%",overflowY:"auto",background:ln,border:"1px solid "+Ke,borderRadius:12,padding:22},children:[(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:9,color:pe,letterSpacing:".1em",marginBottom:4},children:[Na.link," SHARE DOCUMENT"]}),(0,e.jsx)("div",{style:{fontSize:14,fontWeight:600,color:xn,marginBottom:4},children:t.name}),(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:cn,marginBottom:12},children:"USER-TO-USER GRANT · E-MAIL MATCH · NO PUBLIC LINKS"}),(0,e.jsx)("input",{value:r,onChange:x=>o(x.target.value),onKeyDown:x=>{x.key==="Enter"&&f()},placeholder:"[email protected]","aria-label":"Grantee email",style:{width:"100%",boxSizing:"border-box",background:du,border:"1px solid "+Ke,borderRadius:6,padding:"8px 12px",color:xn,fontFamily:D,fontSize:10,outline:"none",marginBottom:8}}),(0,e.jsxs)("div",{style:{display:"flex",gap:7,marginBottom:10},children:[(0,e.jsxs)("select",{value:a,onChange:x=>l(x.target.value),style:{flex:1,background:du,border:"1px solid "+Ke,borderRadius:6,padding:"7px 10px",color:cn,fontFamily:D,fontSize:9,outline:"none",cursor:"pointer"},children:[(0,e.jsx)("option",{value:"view",children:"VIEW · preview only"}),(0,e.jsx)("option",{value:"download",children:"DOWNLOAD · signed URL"})]}),(0,e.jsx)("select",{value:s,onChange:x=>c(parseInt(x.target.value,10)),style:{flex:1,background:du,border:"1px solid "+Ke,borderRadius:6,padding:"7px 10px",color:cn,fontFamily:D,fontSize:9,outline:"none",cursor:"pointer"},children:$4.map(x=>(0,e.jsxs)("option",{value:x,children:["EXPIRES ",x," DAYS"]},x))}),(0,e.jsx)("button",{onClick:f,disabled:d,style:{padding:"7px 14px",background:pe+"18",border:"1px solid "+pe+"44",borderRadius:6,cursor:d?"default":"pointer",fontFamily:D,fontSize:9,color:pe,fontWeight:700,whiteSpace:"nowrap"},children:d?"◌ GRANTING…":"GRANT ACCESS"})]}),p&&(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:9,color:et,marginBottom:10},children:["✕ ",p]}),(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Lt,letterSpacing:".1em",margin:"8px 0 6px"},children:"ACTIVE SHARES"}),g.filter(x=>x.status==="active").length===0?(0,e.jsx)("div",{style:{fontFamily:D,fontSize:9,color:Ut,padding:"6px 0 10px"},children:"No active shares — access is granted per e-mail and expires automatically."}):g.filter(x=>x.status==="active").map(x=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 0",borderBottom:"1px solid #0D1117"}
386,children:[(0,e.jsx)("span",{style:{fontFamily:D,fontSize:10,color:xn,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:x.grantee_email}),(0,e.jsx)(Ql,{label:(x.permission||"").toUpperCase(),color:x.permission==="download"?bt:Ft}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:9,color:cn},children:x.expires_at?"EXP "+x.expires_at.substring(0,10):""}),(0,e.jsx)("button",{onClick:()=>h(x.id),style:{padding:"3px 8px",background:"transparent",border:"1px solid "+et+"44",borderRadius:4,cursor:"pointer",fontFamily:D,fontSize:9,color:et,fontWeight:700},children:"REVOKE"})]},x.id)),(0,e.jsx)("button",{onClick:n,style:{marginTop:14,width:"100%",padding:7,background:"transparent",border:"1px solid "+Ke,borderRadius:6,cursor:"pointer",fontFamily:D,fontSize:9,color:cn},children:"CLOSE"})]})}):null}var M0="xyron_ledger_entity",mh="xyron_ledger_journals_",hh="xyron_ledger_locks_",yh="xyron_ledger_group";function Xb(t,n){try{var r=localStorage.getItem(t);return r?JSON.parse(r):n}catch{return n}}function N0(t,n){try{localStorage.setItem(t,JSON.stringify(n))}catch{}}function xh(t){return!!t&&(t.status===404||t.error==="Entity not found")}function lx(){const[t,n]=(0,i.useState)([]),[r,o]=(0,i.useState)(!0),[a,l]=(0,i.useState)(null),[s,c]=(0,i.useState)(function(){try{return localStorage.getItem(M0)||null}catch{return null}}),[d,p]=(0,i.useState)([]),[g,f]=(0,i.useState)(!1),[h,x]=(0,i.useState)(function(){try{return localStorage.getItem(yh)||null}catch{return null}}),[v,y]=(0,i.useState)([]),[k,A]=(0,i.useState)(null),[j,E]=(0,i.useState)(null),[C,_]=(0,i.useState)(!1),[w,O]=(0,i.useState)(null),[M,U]=(0,i.useState)([]),[ee,N]=(0,i.useState)([]);var V=(0,i.useRef)(0),z=(0,i.useCallback)(function(){return o(!0),l(null),dn.listEntities().then(function(ve){if(ve&&ve.error)return l(ve.error),n([]),[];var Ne=ve&&ve.entities||[];return n(Ne),Ne}).catch(function(ve){return l(ve&&ve.message||"Network error"),n([]),[]}).finally(function(){o(!1)})},[]),oe=(0,i.useCallback)(function(ve){c(ve);try{ve?localStorage.setItem(M0,ve):localStorage.removeItem(M0)}catch{}},[]),P=(0,i.useCallback)(function(){return f(!0),dn.consolidationGroups().then(function(ve){var Ne=ve&&!ve.error&&ve.groups||[];return p(Ne),Ne}).catch(function(){return p([]),[]}).finally(function(){f(!1)})},[]),W=(0,i.useCallback)(function(ve){x(ve);try{ve?localStorage.setItem(yh,ve):localStorage.removeItem(yh)}catch{}},[]),R=(0,i.useCallback)(function(ve){W(null),oe(ve)},[W,oe]),ae=(0,i.useCallback)(function(ve){return dn.createConsolidationGroup(ve).then(function(Ne){return Ne&&!Ne.error&&Ne.group&&Ne.group.id?P().then(function(){return W(Ne.group.id),Ne}):Ne})},[P,W]),q=(0,i.useCallback)(function(ve){if(!ve)return Promise.resolve();var Ne=++V.current;return _(!0),O(null),Promise.all([dn.accounts(ve).catch(function(){return{error:"Network error"}}),dn.trialBalance(ve).catch(function(){return{error:"Network error"}}),dn.payables(ve).catch(function(){return{error:"Network error"}}),dn.journals(ve,5,0).catch(function(){return{error:"Network error"}}),dn.periodLocks(ve).catch(function(){return{error:"Network error"}})]).then(function($e){if(Ne===V.current){var Pe=$e[0],ot=$e[1],re=$e[2],we=$e[3],b=$e[4];if(we&&!we.error&&we.journals&&(U(we.journals.slice(0,5)),N0(mh+ve,we.journals.slice(0,5))),b&&!b.error&&b.locks){var He=b.locks.map(function(tt){return tt.period}).sort();N(He),N0(hh+ve,He)}if(xh(Pe)||xh(ot)||xh(re)){y([]),A(null),E(null),_(!1),oe(null),z();return}y(Pe&&Pe.accounts||[]),A(ot&&ot.error?null:ot),E(re&&re.error?null:re),O(Pe&&Pe.error||ot&&ot.error||re&&re.error||null),_(!1)}})},[oe,z]),ge=(0,i.useCallback)(function(){return q(s)},[q,s]);(0,i.useEffect)(function(){z(),P();function ve(){z(),P()}window.addEventListener("xyron_auth_ready",ve);function Ne(){z(),P();try{var Pe=localStorage.getItem(M0);Pe&&q(Pe)}catch{}}window.addEventListener("xyron:ledger-refresh",Ne);var $e=setTimeout(function(){try{localStorage.getItem("xyron_jwt_token")&&(z(),P())}catch{}},2e3);return function(){clearTimeout($e),window.removeEventListener("xyron_auth_ready",ve),window.removeEventListener("xyron:ledger-refresh",Ne)}},[]),(0,i.useEffect)(function(){if(!r){if(t.length===0){s&&oe(null);return}t.some(function(ve){return ve.id===s})||oe(t[0].id)}},[t,r,s,oe]),(0,i.useEffect)(function(){if(!s){y([]),A(null),E(null),U([]),N([]);return}U(Xb(mh+s,[])),N(Xb(hh+s,[])),q(s)},[s,q]);var X=(0,i.useCallback)(function(ve){return dn.createEntity(ve).then(function(Ne){return Ne&&!Ne.error&&Ne.entity&&Ne.entity.id?z().then(function(){return oe(Ne.entity.id),Ne}):Ne})},[z,oe]),de=(0,i.useCallback)(function(ve){s&&U(function(Ne){var $e=[ve].concat(Ne).slice(0,5);return N0(mh+s,$e),$e})},[s]),We=(0,i.useCallback)(function(ve){s&&N(function(Ne){if(Ne.indexOf(ve)!==-1)return Ne;var $e=Ne.concat([ve]).sort();return N0(hh+s,$e),$e})},[s]),te=t.filter(function(ve){return ve.id===s})[0]||null,_e=d.filter(function(ve){return ve.id===h})[0]||null;return(0,i.useEffect)(function(){g||!h||d.some(function(ve){return ve.id===h})||W(null)},[d,g,h,W]),{entities:t,entitiesLoading:r,entitiesError:a,currentEntity:te,currentEntityId:s,selectEntity:R,createEntity:X,groups:d,groupsLoading:g,currentGroup:_e,currentGroupId:h,selectGroup:W,createGroup:ae,refreshGroups:P,accounts:v,trialBal:k,payables:j,loading:C,error:w,refresh:ge,re
386centJournals:M,recordJournal:de,lockedPeriods:ee,recordLockedPeriod:We}}function _s(t){if(t==null)return NaN;var n=String(t).trim().replace(/,/g,"");if(n==="")return NaN;var r=/^(-?)(\d+)(?:\.(\d{1,2}))?$/.exec(n);if(!r)return NaN;var o=r[1]==="-"?-1:1,a=parseInt(r[2],10),l=r[3]||"",s=l.length===0?0:l.length===1?parseInt(l,10)*10:parseInt(l,10);return o*(a*100+s)}function Rs(t){if(typeof t!="number"||!isFinite(t))return"0.00";var n=Math.round(t),r=n<0?"-":"",o=Math.abs(n),a=Math.floor(o/100),l=String(o%100).padStart(2,"0");return r+a+"."+l}function wn(t){var n=_s(t);if(isNaN(n))return"0.00";var r=Rs(n),o=r.charAt(0)==="-",a=(o?r.slice(1):r).split("."),l=a[0].replace(/\B(?=(\d{3})+(?!\d))/g,",");return(o?"-":"")+l+"."+a[1]}function DE(t){var n=0,r=0,o=[];return(t||[]).forEach(function(a,l){var s=a&&a.debit!==""&&a.debit!=null?_s(a.debit):0,c=a&&a.credit!==""&&a.credit!=null?_s(a.credit):0;if(isNaN(s)||isNaN(c)){o.push(l+1);return}n+=s,r+=c}),{debitCents:n,creditCents:r,diffCents:n-r,totalDebit:Rs(n),totalCredit:Rs(r),invalidLines:o,balanced:o.length===0&&n===r&&n>0}}function zR(t){var n=[],r=t||[];if(r.length<2&&n.push("At least 2 lines required"),r.forEach(function(a,l){var s=l+1;a&&String(a.account_code||"").trim()||n.push("Line "+s+": account required");var c=a&&a.debit!==""&&a.debit!=null,d=a&&a.credit!==""&&a.credit!=null,p=c?_s(a.debit):0,g=d?_s(a.credit):0;if(c&&isNaN(p)||d&&isNaN(g)){n.push("Line "+s+": invalid amount (max 2 decimals)");return}p>0&&g>0&&n.push("Line "+s+": debit OR credit, not both"),p===0&&g===0&&n.push("Line "+s+": zero amount"),(p<0||g<0)&&n.push("Line "+s+": negative amount")}),n.length===0){var o=DE(r);o.balanced||n.push("Unbalanced: debits "+o.totalDebit+" vs credits "+o.totalCredit+" (diff "+Rs(Math.abs(o.diffCents))+")")}return{ok:n.length===0,errors:n}}var qb=["CURRENT","1-30","31-60","61-90","90+"];function OE(t,n){if(!t)return 0;var r=Date.parse(String(t).slice(0,10)+"T00:00:00Z"),o=Date.parse(String(n).slice(0,10)+"T00:00:00Z");return isNaN(r)||isNaN(o)?0:Math.floor((o-r)/864e5)}function LE(t,n){var r=OE(t,n);return r<=0?"CURRENT":r<=30?"1-30":r<=60?"31-60":r<=90?"61-90":"90+"}function MR(t,n){var r={},o={},a={};return qb.forEach(function(l){r[l]=0,o[l]={},a[l]=0}),(t||[]).forEach(function(l){var s=LE(l&&l.due_date,n),c=_s(l&&l.total_amount),d=l&&l.currency||"?";isNaN(c)||(r[s]+=c,o[s][d]=(o[s][d]||0)+c),a[s]+=1}),qb.map(function(l){var s=Object.keys(o[l]).sort();return{bucket:l,count:a[l],total:Rs(r[l]),totals:s.map(function(c){return{currency:c,total:Rs(o[l][c])}})}})}function NR(t){var n={};return(t||[]).forEach(function(r){var o=_s(r&&r.total_amount),a=r&&r.currency||"?";isNaN(o)||(n[a]=(n[a]||0)+o)}),Object.keys(n).sort().map(function(r){return{currency:r,total:Rs(n[r])}})}function BR(t,n,r){if(!t)return!1;var o=OE(t,r);return o<=0&&-o<=n}function kf(t,n,r){var o=parseInt(n,10),a=parseInt(r,10),l=0;return(t||[]).forEach(function(s){var c=parseInt(s&&s.account_code,10);if(!(isNaN(c)||c<o||c>a)){var d=_s(s.balance);isNaN(d)||(l+=d)}}),Rs(l)}function zE(t,n){var r=String(n||"").trim().toLowerCase();return r?(t||[]).filter(function(o){var a=String(o&&o.code||"").toLowerCase(),l=String(o&&o.name||"").toLowerCase();return a.indexOf(r)===0||l.indexOf(r)!==-1}):t||[]}var ME=[{value:"company",label:"COMPANY",color:Ft},{value:"holding",label:"HOLDING",color:pe},{value:"spv",label:"SPV",color:To},{value:"trust",label:"TRUST",color:bt},{value:"foundation",label:"FOUNDATION",color:et},{value:"investment_vehicle",label:"INVESTMENT",color:Ft},{value:"personal",label:"PERSONAL",color:cn}],PR=["UK_GAAP","IFRS","SWISS_OR","INDIAN_AS","UAE"],UR=["GENERAL","LEGAL","ADVISORY","PROPERTY","INSURANCE","STAFF","TRAVEL","TECHNOLOGY","OFFICE","MAINTENANCE","SECURITY"];function NE(t){return ME.filter(function(n){return n.value===t})[0]||{value:t,label:String(t||"?").toUpperCase(),color:"#7A90A8"}}function WR({onOpenLedger:t}){const n=lx(),r=n.currentEntity,o=n.trialBal&&n.trialBal.accounts||[],a=kf(o,"1000","1099"),l=kf(o,"1100","1199"),s=n.payables&&n.payables.total||"0.00",c=r?NE(r.entity_type):null;return(0,e.jsxs)("div",{style:{background:ln,border:"1px solid "+Ke,borderRadius:8,padding:16},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:Ft,letterSpacing:".1em"},children:"INSTITUTIONAL LEDGER"}),r&&c&&(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:c.color,border:"1px solid "+c.color+"44",background:c.color+"12",borderRadius:3,padding:"1px 5px",letterSpacing:".08em"},children:c.label}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{onClick:t,style:{padding:"5px 12px",background:pe+"14",border:"1px solid "+pe+"44",borderRadius:5,cursor:"pointer",fontFamily:D,fontSize:9,color:pe,fontWeight:700,letterSpacing:".06em"},onMouseEnter:function(d){d.currentTarget.style.background=pe+"22"},onMouseLeave:function(d){d.currentTarget.style.background=pe+"14"},children:"OPEN LEDGER MODULE →"})]}),n.entitiesLoading?(0,e.jsx)("div",{style:{fontFamily:D,fontSize:10,
386color:Ut,padding:8},children:"◌ Loading ledger…"}):r?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:11,fontWeight:700,color:xn,marginBottom:10},children:[r.name,(0,e.jsxs)("span",{style:{fontSize:8,color:Lt,fontWeight:400,marginLeft:8},children:[r.functional_currency||""," ·"," ",r.jurisdiction||r.coa_template||""]})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:22,flexWrap:"wrap"},children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Lt,marginBottom:2},children:"CASH (1000-1099)"}),(0,e.jsx)("div",{style:{fontFamily:D,fontSize:13,fontWeight:700,color:bt},children:wn(a)})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Lt,marginBottom:2},children:"RECEIVABLES"}),(0,e.jsx)("div",{style:{fontFamily:D,fontSize:13,fontWeight:700,color:Ft},children:wn(l)})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Lt,marginBottom:2},children:"OPEN PAYABLES"}),(0,e.jsx)("div",{style:{fontFamily:D,fontSize:13,fontWeight:700,color:pe},children:wn(s)})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Lt,marginBottom:2},children:"TRIAL BALANCE"}),(0,e.jsx)("div",{style:{fontFamily:D,fontSize:13,fontWeight:700,color:n.trialBal&&n.trialBal.balanced?bt:n.trialBal?et:Ut},children:n.trialBal?n.trialBal.balanced?"◆ BALANCED":"◇ VARIANCE "+wn(n.trialBal.variance):"—"})]})]})]}):(0,e.jsx)("div",{style:{fontFamily:D,fontSize:10,color:Ut,padding:8},children:"No ledger entities yet — open the Ledger module to create one."})]})}function BE(t){if(t==null)return NaN;var n=String(t).trim().replace(/,/g,"");if(n===""||!/^-?\d*(\.\d+)?$/.test(n)||/^-?\.?$/.test(n))return NaN;var r=parseFloat(n);return isFinite(r)?r:NaN}function HR(t){if(t==null)return NaN;var n=String(t).trim().replace(/,/g,""),r=/^(-?)(\d+)(?:\.(\d{1,2}))?$/.exec(n);if(!r)return NaN;var o=r[1]==="-"?-1:1,a=r[3]||"",l=a.length===0?0:a.length===1?parseInt(a,10)*10:parseInt(a,10);return o*(parseInt(r[2],10)*100+l)}function GR(t){if(typeof t!="number"||!isFinite(t))return"0.00";var n=Math.round(t),r=n<0?"-":"",o=Math.abs(n);return r+Math.floor(o/100)+"."+String(o%100).padStart(2,"0")}function Fi(t){var n=HR(t);if(isNaN(n))return"0.00";var r=GR(n),o=r.startsWith("-"),a=(o?r.slice(1):r).split(".");return a[0]=a[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),(o?"-":"")+a.join(".")}function oc(t){var n=BE(t);return isNaN(n)||n===0?"0":n.toFixed(10).replace(/0+$/,"").replace(/\.$/,"")}function VR(t){var n=[];return String(t||"").split(/\r?\n/).forEach(function(r){var o=/^\s*([A-Za-z0-9]{1,32})\s*[,:\s]\s*(-?[\d.,]+)\s*$/.exec(r);if(o){var a=BE(o[2]);isNaN(a)||a<0||n.push({token:o[1].toUpperCase(),amount:String(a)})}}),n}function YR(t){switch(t){case"fx_table":return{label:"FX TABLE",tone:"info"};case"live":return{label:"LIVE",tone:"good"};case"last_tx":return{label:"LAST TX",tone:"warn"};case"cost_basis":return{label:"COST BASIS",tone:"warn"};default:return{label:"UNPRICED",tone:"muted"}}}function KR(t){switch(t){case"BUY":case"CLAIM":case"AIRDROP":case"UNSTAKE":case"TRANSFER_IN":return{in:!0,out:!1};case"SELL":case"STAKE":case"TRANSFER_OUT":return{in:!1,out:!0};case"SWAP":return{in:!0,out:!0};default:return{in:!1,out:!1}}}var XR=["BUY","SELL","SWAP","STAKE","UNSTAKE","CLAIM","AIRDROP","TRANSFER_IN","TRANSFER_OUT"],qR=["HOT","COLD","HARDWARE","EXCHANGE"];async function hs(t,n){var r=null;try{r=await t.json()}catch{r=null}return t.ok?r||{}:{error:r&&(r.detail||r.error)||n,status:t.status}}function ys(t){return"/api/ledger-crypto/"+encodeURIComponent(t)}var js={wallets:async function(t){return hs(await Oa(ys(t)+"/wallets"),"Failed to load wallets")},createWallet:async function(t,n){return hs(await Oa(ys(t)+"/wallets",{method:"POST",body:JSON.stringify(n)}),"Wallet creation failed")},transactions:async function(t,n,r){var o=[];return n&&o.push("wallet_id="+encodeURIComponent(n)),r&&o.push("limit="+encodeURIComponent(r)),hs(await Oa(ys(t)+"/transactions"+(o.length?"?"+o.join("&"):"")),"Failed to load transactions")},recordTransaction:async function(t,n){return hs(await Oa(ys(t)+"/transactions",{method:"POST",body:JSON.stringify(n)}),"Transaction failed")},portfolio:async function(t){return hs(await Oa(ys(t)+"/portfolio"),"Failed to load portfolio")},reconcile:async function(t,n,r){return hs(await Oa(ys(t)+"/wallets/"+encodeURIComponent(n)+"/reconcile",{method:"POST",body:JSON.stringify({reported:r})}),"Reconciliation failed")},stakes:async function(t){return hs(await Oa(ys(t)+"/stakes"),"Failed to load stakes")},createStake:async function(t,n){return hs(await Oa(ys(t)+"/stakes",{method:"POST",body:JSON.stringify(n)}),"Stake creation failed")},defi:async function(t){return hs(await Oa(ys(t)+"/defi"),"Failed to load DeFi positions")},createDefi:async function(t,n){return hs(await Oa(ys(t)+"/defi",{method:"POST",body:JSON.stringify(n)}),"DeFi position creation failed")}};function B0({label:t,value:n,color:r}){return(0,e.jsxs)("div",{style:{minWidth:110},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Lt,letterSpacing:".1em",marginBottom:2},children:t}),(0,e.jsx)("div",{style:{fontFamily:D,fontSize:12,fontWeight:700,color:r||"#C9D1D9"},children:n})]})}function $R(){var t=lx().currentEntity,n=t&&t.id,[r,o]=(0,i.useState)(null),[a,l]=(0,i.useState)([]),[s,c]=(0,i.useState)(!1);(0,i.useEffect)(function(){if(n){var x=!0;return c(!0),Promise.all([js.portfolio(n),js.wallets(n)]).then(function(v){if(x){c(!1);var y=v[0],k=v[1];o(y&&!y.error?y:null),l(k&&!k.error&&k.wallets||[])}}).catch(function(){x&&(c(!1),o(null),l([]))}),function(){x=!1}}},[n]);var d=r&&r.totals||{},p=r&&r.holdings||[],g=r&&r.staking||{},f=parseFloat(d.unrealized_pnl_usd||"0"),h=!s&&p.length===0&&!(g.positions>0)&&a.length===0;return(0,e.jsxs)("div",{style:{background:ln,border:"1px solid "+Ke,borderRadius:8,padding:16},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:To,letterSpacing:".1em",marginBottom:10},children:"CRYPTO PORTFOLIO"}
386),t?s?(0,e.jsx)("div",{style:{fontFamily:D,fontSize:10,color:cn},children:"Loading…"}):h?(0,e.jsx)("div",{style:{fontFamily:D,fontSize:10,color:cn},children:"No wallets yet — open Ledger → Crypto"}):(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:16},children:[(0,e.jsx)(B0,{label:"VALUE",value:"$"+Fi(d.value_usd)}),(0,e.jsx)(B0,{label:"UNREALIZED P&L",value:(f>=0?"+$":"-$")+Fi(String(Math.abs(f))),color:f>=0?bt:et}),(0,e.jsx)(B0,{label:"REALIZED YTD",value:"$"+Fi(d.realized_ytd_usd)}),(0,e.jsx)(B0,{label:"STAKED",value:"$"+Fi(g.total_staked_usd)})]}),p.length>0&&(0,e.jsxs)("div",{style:{marginTop:10,display:"flex",flexWrap:"wrap",gap:6},children:[p.slice(0,6).map(function(x){return(0,e.jsxs)("span",{style:{fontFamily:D,fontSize:8,color:"#C9D1D9",border:"1px solid "+Ke,borderRadius:3,padding:"2px 6px"},children:[x.token," ",(0,e.jsx)("span",{style:{color:"#6A8098"},children:x.price_usd?"$"+Fi(x.value_usd):"unpriced"})]},x.token)}),p.length>6&&(0,e.jsxs)("span",{style:{fontFamily:D,fontSize:8,color:"#7A90A8"},children:["+",p.length-6," more"]})]}),a.length>0&&p.length===0&&(0,e.jsx)("div",{style:{marginTop:10,display:"flex",flexWrap:"wrap",gap:6},children:a.slice(0,6).map(function(x){return(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:"#C9D1D9",border:"1px solid "+Ke,borderRadius:3,padding:"2px 6px"},children:x.label||x.address||"Wallet"},x.id||x.address)})})]}):(0,e.jsx)("div",{style:{fontFamily:D,fontSize:10,color:cn},children:"Select a ledger entity to see crypto holdings."})]})}function JR(){const[t,n]=(0,i.useState)(null),[r,o]=(0,i.useState)(""),[a,l]=(0,i.useState)(null),[s,c]=(0,i.useState)({}),[d,p]=(0,i.useState)(null),[g,f]=(0,i.useState)({}),[h,x]=(0,i.useState)({}),v=(0,i.useRef)([]),y=(0,i.useRef)(!0),k=(0,i.useCallback)(()=>{xw().then(_=>{y.current&&(n(_),_.forEach(w=>{w.thumbDoc&&gn.content(w.thumbDoc.id||w.thumbDoc.doc_id).then(O=>{if(!y.current||!O)return;const M=URL.createObjectURL(O);v.current.push(M),c(U=>({...U,[w.doc.id||w.doc.doc_id]:M}))}).catch(()=>{})}))}).catch(()=>{y.current&&n([])})},[]);(0,i.useEffect)(()=>(y.current=!0,k(),()=>{y.current=!1,v.current.forEach(_=>{try{URL.revokeObjectURL(_)}catch{}}),v.current=[]}),[k]);const A=_=>{l({name:Pu(_.name),url:null}),gn.content(_.doc.id||_.doc.doc_id).then(w=>{if(!w){l(null);return}const O=URL.createObjectURL(w);v.current.push(O),l(M=>M?{name:M.name,url:O}:null)}).catch(()=>l(null))},j=_=>{const w=Pu(_.name),O=window.prompt("Rename recording:",w);!O||O===w||(p(_.base),vw(_,O).then(M=>{p(null),M?k():window.alert("Rename failed — try again")}).catch(()=>{p(null),window.alert("Rename failed — try again")}))},E=_=>{const w=_.doc.id||_.doc.doc_id||_.base;f(O=>({...O,[w]:!O[w]})),!(h[w]!==void 0||!_.summaryDoc)&&gn.content(_.summaryDoc.id||_.summaryDoc.doc_id).then(O=>O?O.text():null).then(O=>{x(M=>({...M,[w]:O||"Summary unavailable."}))}).catch(()=>{x(O=>({...O,[w]:"Summary unavailable."}))})},C=(t||[]).filter(_=>!r||Pu(_.name).toLowerCase().indexOf(r.toLowerCase())!==-1);return(0,e.jsxs)("div",{"data-testid":"vault-recordings-tab",style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"12px 16px 8px",flexShrink:0},children:[(0,e.jsx)("span",{style:{fontFamily:D,fontSize:10,fontWeight:700,color:pe,letterSpacing:".12em"},children:"▶ CALL RECORDINGS"}),(0,e.jsx)("input",{value:r,onChange:_=>o(_.target.value),placeholder:"Search recordings…",style:{flex:1,maxWidth:300,background:"#0A0E15",border:"1px solid "+Ke,borderRadius:4,padding:"5px 10px",color:xn,fontFamily:D,fontSize:10,outline:"none"}})]}),(0,e.jsx)("div",{style:{flex:1,overflowY:"auto",padding:"8px 16px 16px",minHeight:0},children:t===null?(0,e.jsx)("div",{style:{color:Lt,fontFamily:D,fontSize:10,letterSpacing:1},children:"LOADING RECORDINGS…"}):C.length?(0,e.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:12},children:C.map(_=>{const w=_.doc.id||_.doc.doc_id||_.base;return(0,e.jsxs)("div",{style:{background:ln,border:"1px solid "+Ke,borderRadius:6,overflow:"hidden"},children:[(0,e.jsxs)("div",{onClick:()=>A(_),style:{cursor:"pointer",height:110,background:"#000",display:"flex",alignItems:"center",justifyContent:"center",position:"relative"},children:[s[w]?(0,e.jsx)("img",{src:s[w],alt:Pu(_.name),style:{width:"100%",height:"100%",objectFit:"cover"}}):null,(0,e.jsx)("span",{style:{position:"absolute",width:40,height:40,borderRadius:"50%",background:"rgba(0,0,0,0.55)",border:"1px solid rgba(255,255,255,0.35)",display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:16,paddingLeft:3,pointerEvents:"none"},children:"▶"})]}),(0,e.jsxs)("div",{style:{padding:"7px 9px"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,e.jsx)("div",{title:Pu(_.name),style:{flex:1,color:pe,fontFamily:D,fontSize:10,letterSpacing:.5,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:Pu(_.name)}
386),(0,e.jsx)("button",{type:"button",title:"Rename",disabled:d===_.base,onClick:()=>j(_),style:{background:"transparent",border:"1px solid "+Ke,borderRadius:3,color:cn,cursor:"pointer",fontSize:9,padding:"1px 5px"},children:d===_.base?"…":"✎"})]}),_.createdAt?(0,e.jsx)("div",{style:{color:Lt,fontFamily:D,fontSize:8,marginTop:3},children:String(_.createdAt).slice(0,19).replace("T"," ")}):null,_.summaryDoc?(0,e.jsx)("button",{type:"button",onClick:()=>E(_),style:{marginTop:6,width:"100%",background:"transparent",border:"1px solid "+Ke,borderRadius:3,color:cn,cursor:"pointer",fontFamily:D,fontSize:8,letterSpacing:".08em",padding:"3px 0"},children:g[w]?"SUMMARY ▴":"SUMMARY ▾"}):null,g[w]?(0,e.jsx)("div",{style:{marginTop:6,maxHeight:180,overflowY:"auto",background:"#07090F",border:"1px solid "+Ke,borderRadius:4,padding:8,color:xn,fontFamily:D,fontSize:9,lineHeight:1.5,whiteSpace:"pre-wrap"},children:h[w]===void 0?"Loading summary…":h[w]}):null]})]},w)})}):(0,e.jsx)("div",{style:{color:Lt,fontFamily:D,fontSize:10,letterSpacing:1},children:r?"NO RECORDINGS MATCH “"+r+"”":"NO CALL RECORDINGS YET — use RECORD during a video call; recordings save here automatically."})}),a?(0,e.jsx)("div",{onClick:()=>l(null),style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.9)",zIndex:9e3,display:"flex",alignItems:"center",justifyContent:"center",padding:12},children:(0,e.jsxs)("div",{onClick:_=>_.stopPropagation(),style:{width:"min(92vw, 860px)",maxHeight:"88vh"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:[(0,e.jsx)("div",{style:{flex:1,color:pe,fontFamily:D,fontSize:11,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:a.name}),(0,e.jsx)("button",{type:"button",onClick:()=>l(null),style:{background:"rgba(200,92,92,0.12)",border:"1px solid rgba(200,92,92,0.5)",borderRadius:5,padding:"6px 14px",cursor:"pointer",fontFamily:D,fontSize:10,fontWeight:700,color:"#C85C5C",letterSpacing:".08em"},children:"✕ CLOSE"})]}),a.url?(0,e.jsx)("video",{src:a.url,controls:!0,autoPlay:!0,playsInline:!0,style:{width:"100%",maxHeight:"76vh",background:"#000",borderRadius:6}}):(0,e.jsx)("div",{style:{height:200,display:"flex",alignItems:"center",justifyContent:"center",color:Lt,fontFamily:D,fontSize:10,letterSpacing:1,background:"#07090F",border:"1px solid "+Ke,borderRadius:6},children:"LOADING VIDEO…"})]})}):null]})}var QR=[{id:"vault",label:"VAULT",icon:Na.tabVault},{id:"recordings",label:"CALL RECORDINGS",icon:"▶"},{id:"generate",label:"GENERATE",icon:Na.tabGenerate},{id:"upload",label:"UPLOAD",icon:Na.tabUpload},{id:"ledger",label:"LEDGER",icon:Na.tabLedger}],ZR={spreadsheet:[{label:"Portfolio Snapshot",prompt:"Portfolio snapshot with current positions, NAV, allocation percentages"},{label:"Rent Roll",prompt:"Property rent roll with tenants, lease terms, rental income"}],document:[{label:"Board Pack",prompt:"Board pack executive summary with portfolio performance and key decisions"},{label:"Investment Memo",prompt:"Investment memo template with thesis, risks, returns"},{label:"Risk Report",prompt:"Risk assessment report covering market, credit, liquidity, operational"},{label:"Due Diligence",prompt:"Due diligence checklist and findings template"}]};function eF({onAsk:t,savedDocs:n,onAddVaultDocs:r,onPreviewDoc:o,onAnnotate:a,onChatContextDoc:l,onOpenLedger:s}){const[c,d]=i.useState(null),p=o||d,g=uR(),f=(0,i.useRef)(null),{loadDocs:h,analyseContract:x,checkCompliance:v,listShares:y,createShare:k,revokeShare:A,uploadFiles:j,setSelected:E,selected:C,starred:_,toggleStar:w,downloadDoc:O,reanalyse:M,deleteDoc:U,createFolder:ee,uploadMsg:N,uploading:V,recent:z,search:oe,curFolder:P,classification:W,docs:R,viewMode:ae}=g,[q,ge]=(0,i.useState)("vault"),[X,de]=(0,i.useState)(null),[We,te]=(0,i.useState)(null),[_e,ve]=(0,i.useState)(null),[Ne,$e]=(0,i.useState)(""),[Pe,ot]=(0,i.useState)("view"),[re,we]=(0,i.useState)(7),[b,He]=(0,i.useState)(!1),[tt,Ae]=(0,i.useState)(null),[Be,Fe]=(0,i.useState)([]);(0,i.useState)(null),(0,i.useState)("");const[ft,St]=(0,i.useState)(!1),[Xe,It]=(0,i.useState)(""),[Rt,$]=(0,i.useState)(!1),Ue=(0,i.useRef)(0),[Ie,Q]=(0,i.useState)(null),[rt,jt]=(0,i.useState)(null),[tn,pt]=(0,i.useState)("spreadsheet"),[gt,qt]=(0,i.useState)(""),[Pt,Kt]=(0,i.useState)(!1),[xe,fe]=(0,i.useState)(null),[Ye,Qe]=(0,i.useState)(null),ut=(0,i.useRef)(null);(0,i.useEffect)(()=>{const Te=()=>de(null);return document.addEventListener("click",Te),()=>document.removeEventListener("click",Te)},[]);async function wt(Te){Qe({ok:!0,text:"◌ BILLING "+(Te.name||"document")+"…"}),Qe(await FR(Te,{apiUrlFn:qr})),clearTimeout(ut.current),ut.current=setTimeout(()=>Qe(null),6500)}function H(Te){Kt(!0),fe(null),uu.generate(Te,tn,!0).then(it=>{Kt(!1),it?(fe({success:!0}),h()):fe({error:"Generation failed — try again"})}).catch(()=>{fe({error:"Generation failed"}),Kt(!1)})}async function Z(Te){jt("contract"),Q({type:"contract",data:(await x(Te))?.anal
386ysis}),jt(null)}async function T(Te){jt("compliance"),Q({type:"compliance",data:(await v(Te))?.compliance}),jt(null)}async function Y(Te){ve(Te),$e(""),ot("view"),we(7),Ae(null),He(!1),Fe(await y(Te.id))}async function B(){if(!_e||b)return;const Te=Ne.trim().toLowerCase();if(!J4(Te)){Ae("Enter a valid e-mail address");return}He(!0),Ae(null);const it=await k(_e.id,Te,Pe,re);He(!1);const Tt=Q4(it);if(Tt){Ae(Tt);return}$e(""),Fe(await y(_e.id)),oi({action:"vault.doc.shared",detail:_e.name+" → "+Te,model:"system"})}async function ie(Te){await A(Te),_e&&Fe(await y(_e.id))}function ue(Te){const it=Array.from(Te.dataTransfer&&Te.dataTransfer.types||[]);return it.includes("Files")&&!it.some(Tt=>String(Tt).startsWith("application/x-vault-"))}function ne(Te){var it=Te.target&&Te.target.closest?Te.target.closest("[data-vault-drop]"):null;if(!it&&typeof document<"u"&&document.elementFromPoint&&Te.clientX!=null){var Tt=document.elementFromPoint(Te.clientX,Te.clientY);it=Tt&&Tt.closest?Tt.closest("[data-vault-drop]"):null}return yR(it&&it.getAttribute("data-vault-drop"))}function Me(Te){ue(Te)&&(Te.preventDefault(),Te.stopPropagation(),Ue.current++,$(!0))}function nt(Te){ue(Te)&&(Te.preventDefault(),Te.stopPropagation(),Ue.current--,Ue.current<=0&&(Ue.current=0,$(!1)))}function ct(Te){ue(Te)&&(Te.preventDefault(),Te.stopPropagation())}function je(Te){if(ue(Te)){Te.preventDefault(),Te.stopPropagation(),Ue.current=0,$(!1);var it=ne(Te);j(Te.dataTransfer.files,it||void 0)}}function Le(Te){E(Te),l&&l(Te?{id:Te.id,name:Te.name||Te.display_name,content:Te.content_preview||Te.content||""}:null)}function be(Te){if(!X||!X.doc)return;const it=X.doc;Te==="star"?w(it.name):Te==="preview"&&o?o(it):Te==="download"?O(it):Te==="bill"?wt(X.doc):Te==="share"?Y(it):Te==="ask"&&t?(GS(it,"Analyse this document"),t("[Vault: "+it.name+"] Analyse this document")):Te==="annotate"&&a?a(it.name):Te==="reanalyze"?M(it.id):Te==="delete"&&te(it),de(null)}const Wt=C;return(0,e.jsxs)("div",{className:"xy-vault-root",style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",position:"relative",background:du},onDragEnter:Me,onDragLeave:nt,onDragOver:ct,onDrop:je,role:"region","aria-label":"Vault view",children:[Rt&&(0,e.jsxs)("div",{style:{position:"absolute",inset:0,zIndex:200,background:pe+"0C",border:"2px dashed "+pe+"66",borderRadius:8,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:12,pointerEvents:"none"},children:[(0,e.jsx)("div",{style:{fontSize:36},children:Na.folderOpen}),(0,e.jsx)("div",{style:{fontFamily:D,fontSize:13,color:pe,fontWeight:700,letterSpacing:".08em"},children:P&&g.parentFolder?"DROP TO UPLOAD TO "+String(g.parentFolder.name||"FOLDER").toUpperCase():"DROP TO UPLOAD TO VAULT"})]}),X&&(()=>{const Te=oR(X.x,X.y,220,360);return(0,e.jsx)("div",{onClick:it=>it.stopPropagation(),style:{position:"fixed",left:Te.left,top:Te.top,zIndex:500,background:ln,border:"1px solid "+Ke,borderRadius:8,padding:5,minWidth:190,boxShadow:"0 12px 40px rgba(0,0,0,0.8)"},role:"menu",children:[{l:_.includes(X.doc.name)?"★ Unstar":"☆ Star",id:"star"},{l:"▶ Preview",id:"preview"},{l:"↓ Download",id:"download"},...IE(X.doc)?[{l:"⎘ BILL IT — POST TO LEDGER",id:"bill"}]:[],{l:Na.link+" Share",id:"share"},{l:"◈ Ask Xyron",id:"ask"},{l:"◈ Annotate",id:"annotate"},{l:"↻ Re-analyse",id:"reanalyze"},{sep:!0},{l:"✕ Delete",red:!0,id:"delete"}].map((it,Tt)=>it.sep?(0,e.jsx)("div",{style:{height:1,background:"#1C2333",margin:"3px 0"}},Tt):(0,e.jsx)("button",{onClick:()=>be(it.id),role:"menuitem",style:{display:"flex",alignItems:"center",gap:9,width:"100%",padding:"7px 12px",background:"transparent",border:"none",borderRadius:5,cursor:"pointer",textAlign:"left"},onMouseEnter:bn=>{bn.currentTarget.style.background=it.red?et+"18":pe+"0C"},onMouseLeave:bn=>{bn.currentTarget.style.background="transparent"},children:(0,e.jsx)("span",{style:{fontFamily:D,fontSize:10,color:it.red?et:"#C9D1D9"},children:it.l})},Tt))})})(),We&&(0,e.jsx)("div",{onClick:()=>te(null),style:{position:"fixed",inset:0,zIndex:560,background:"rgba(3,5,8,0.62)",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,e.jsxs)("div",{onClick:Te=>Te.stopPropagation(),style:{width:420,maxWidth:"92vw",background:ln,border:"1px solid "+Ke,borderRadius:10,padding:"18px 20px",boxShadow:"0 24px 60px rgba(0,0,0,0.7)"},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:11,color:et,letterSpacing:".12em",marginBottom:8},children:"DELETE DOCUMENT?"}),(0,e.jsxs)("div",{style:{fontSize:13,color:"#C9D1D9",lineHeight:1.55,marginBottom:16},children:["Are you sure you want to permanently delete ",(0,e.jsx)("strong",{children:We.name}),"? This action cannot be undone."]}),(0,e.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[(0,e.jsx)("button",{type:"button",onClick:()=>te(null),style:{padding:"7px 14px",background:"transparent",border:"1px solid "+Ke,borderRadius:6,color:"#7A90A8",curs
386or:"pointer",fontFamily:D,fontSize:9},children:"CANCEL"}),(0,e.jsx)("button",{type:"button",onClick:()=>{U(We.id),te(null)},style:{padding:"7px 14px",background:et+"18",border:"1px solid "+et+"55",borderRadius:6,color:et,cursor:"pointer",fontFamily:D,fontSize:9},children:"DELETE"})]})]})}),(0,e.jsx)(LR,{doc:_e,onClose:()=>ve(null),email:Ne,onEmailChange:$e,permission:Pe,onPermissionChange:ot,expiry:re,onExpiryChange:we,busy:b,err:tt,shares:Be,onSubmit:B,onRevoke:ie}),(0,e.jsx)("div",{className:"xy-vault-tabs",style:{display:"flex",borderBottom:"1px solid #111820",background:"#030507",flexShrink:0},children:QR.map(Te=>(0,e.jsxs)("button",{className:"xy-vault-tab",onClick:()=>ge(Te.id),style:{flex:1,padding:"9px 0",background:q===Te.id?pe+"0A":"transparent",border:"none",borderBottom:q===Te.id?"2px solid "+pe:"2px solid transparent",cursor:"pointer",fontFamily:D,fontSize:9,color:q===Te.id?pe:Lt,letterSpacing:".08em",display:"flex",alignItems:"center",justifyContent:"center",gap:6,transition:"all .15s"},onMouseEnter:it=>{q!==Te.id&&(it.currentTarget.style.color=cn)},onMouseLeave:it=>{q!==Te.id&&(it.currentTarget.style.color=Lt)},children:[(0,e.jsx)("span",{children:Te.icon})," ",(0,e.jsx)("span",{className:"xy-vault-tab-label",children:Te.label})]},Te.id))}),q==="vault"&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(gR,{vault:g,fileInputRef:f,onNewFolder:()=>{St(!0),It("")},onSelectDoc:Le}),ft&&(0,e.jsxs)("div",{style:{padding:"8px 16px",background:"#05080D",borderBottom:"1px solid #111820",display:"flex",gap:8,alignItems:"center",flexShrink:0},children:[(0,e.jsx)("span",{style:{fontSize:12,color:pe},children:Na.folder}),(0,e.jsx)("input",{autoFocus:!0,value:Xe,onChange:Te=>It(Te.target.value),onKeyDown:Te=>{Te.key==="Enter"&&(ee(Xe),St(!1)),Te.key==="Escape"&&St(!1)},placeholder:"Folder name…",style:{flex:1,background:"transparent",border:"none",borderBottom:"1px solid "+pe,color:"#C9D1D9",fontFamily:D,fontSize:12,outline:"none",padding:"2px 4px"}}),(0,e.jsx)("button",{onClick:()=>{ee(Xe),St(!1)},style:{padding:"4px 12px",background:pe+"18",border:"1px solid "+pe+"44",borderRadius:5,cursor:"pointer",fontFamily:D,fontSize:8,color:pe,fontWeight:700},children:"CREATE"}),(0,e.jsx)("button",{onClick:()=>St(!1),style:{background:"transparent",border:"1px solid "+Ke,borderRadius:5,cursor:"pointer",fontFamily:D,fontSize:8,color:"#7A90A8",padding:"4px 8px"},children:"CANCEL"})]}),N&&(function(){const Te=typeof N=="string"?!0:N.ok!==!1,it=typeof N=="string"?N:N.text,Tt=Te?bt:et;return(0,e.jsxs)("div",{style:{padding:"6px 16px",background:Tt+"0C",borderBottom:"1px solid "+Tt+"28",fontFamily:D,fontSize:10,color:Tt,flexShrink:0},children:[Te?"✓ ":"⚠ ",it]})})(),Ye&&(0,e.jsx)("div",{style:{padding:"6px 16px",background:(Ye.ok?bt:et)+"0C",borderBottom:"1px solid "+(Ye.ok?bt:et)+"33",fontFamily:D,fontSize:10,color:Ye.ok?bt:et,flexShrink:0},children:Ye.text}),V.length>0&&(0,e.jsx)("div",{style:{padding:"8px 16px",background:pe+"08",borderBottom:"1px solid "+pe+"22",flexShrink:0},children:V.map(Te=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:4},children:[(0,e.jsx)("div",{style:{width:10,height:10,border:"2px solid "+pe+"33",borderTop:"2px solid "+pe,borderRadius:"50%",animation:"xspin 0.8s linear infinite"}}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:10,color:pe},children:Te.name}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:"#7A90A8"},children:"uploading & analysing…"})]},Te.id))}),z.length>0&&!oe&&!P&&W==="ALL"&&(0,e.jsxs)("div",{style:{padding:"8px 16px",borderBottom:"1px solid #0D1117",background:du,flexShrink:0},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:9,color:"#6A8098",letterSpacing:".12em",marginBottom:6},children:"RECENTLY OPENED"}),(0,e.jsx)("div",{style:{display:"flex",gap:6,overflowX:"auto"},children:z.slice(0,8).map((Te,it)=>{const Tt=R.find($r=>$r.name===Te);if(!Tt)return null;const bn=ld(Te);return(0,e.jsxs)("button",{onClick:()=>Le(Tt),onMouseDown:$r=>_E($r,{kind:"doc",ids:[Tt.id],label:Tt.name}),style:{display:"flex",alignItems:"center",gap:6,padding:"5px 10px",background:ln,border:"1px solid "+Ke,borderRadius:6,cursor:"pointer",flexShrink:0,maxWidth:160},onMouseEnter:$r=>{$r.currentTarget.style.borderColor=pe},onMouseLeave:$r=>{$r.currentTarget.style.borderColor=Ke},children:[(0,e.jsx)("div",{style:{width:16,height:16,background:bn+"18",border:"1px solid "+bn+"33",borderRadius:3,dis
386play:"flex",alignItems:"center",justifyContent:"center",fontFamily:D,fontSize:8,color:bn,fontWeight:700},children:tc(Te)}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:"#7A90A8",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Te.replace(/\.(pdf|docx|xlsx|csv|txt|md)$/i,"")})]},it)})})]}),(0,e.jsx)("div",{className:"xy-vault-body",style:{flex:1,display:"flex",overflow:"hidden"},children:ae==="columns"?(0,e.jsx)(TR,{vault:g,sel:Wt,onSelectDoc:Le,onOpenCtxMenu:de,onPreviewDoc:p}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(bR,{vault:g,sel:Wt,onSelectDoc:Le,onOpenCtxMenu:de}),(0,e.jsx)(OR,{vault:g,sel:Wt,onClose:()=>Le(null),onPreviewDoc:p,onAnnotate:a,onShare:Y,onBillIt:wt,analysisResult:Ie,analysisLoading:rt,onContractAnalysis:Z,onComplianceCheck:T,onRequestDelete:Te=>te(Te)})]})})]}),q==="recordings"&&(0,e.jsx)("div",{style:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",minHeight:0},children:(0,e.jsx)(JR,{})}),q==="generate"&&(0,e.jsx)("div",{style:{flex:1,overflow:"auto",padding:20},children:(0,e.jsxs)("div",{style:{maxWidth:700,margin:"0 auto"},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:10,fontWeight:700,color:pe,letterSpacing:".12em",marginBottom:16},children:"◈ DOCUMENT GENERATOR"}),(0,e.jsx)("div",{style:{display:"flex",gap:8,marginBottom:16},children:["spreadsheet","document"].map(Te=>(0,e.jsx)("button",{onClick:()=>pt(Te),style:{padding:"8px 18px",background:tn===Te?pe+"14":ln,border:"1px solid "+(tn===Te?pe+"44":Ke),borderRadius:6,cursor:"pointer",fontFamily:D,fontSize:9,color:tn===Te?pe:"#7A90A8",fontWeight:tn===Te?700:400},children:Te==="spreadsheet"?Na.spreadsheet+" SPREADSHEET":Na.document+" DOCUMENT"},Te))}),(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:"#6A8098",letterSpacing:".08em",marginBottom:8},children:"TEMPLATES"}),(0,e.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginBottom:16},children:(ZR[tn]||[]).map((Te,it)=>(0,e.jsx)("button",{onClick:()=>{qt(Te.prompt),H(Te.prompt)},disabled:Pt,style:{padding:"7px 14px",background:ln,border:"1px solid "+Ke,borderRadius:6,cursor:Pt?"default":"pointer",fontFamily:D,fontSize:9,color:"#7A90A8",transition:"all .15s"},onMouseEnter:Tt=>{Pt||(Tt.currentTarget.style.borderColor=pe+"66")},onMouseLeave:Tt=>{Tt.currentTarget.style.borderColor=Ke},children:Te.label},it))}),(0,e.jsx)("div",{style:{fontFamily:D,fontSize:9,color:"#6A8098",marginBottom:14},children:"Financial documents come from the LEDGER module"}),(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:"#6A8098",letterSpacing:".08em",marginBottom:6},children:"CUSTOM PROMPT"}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,e.jsx)("input",{value:gt,onChange:Te=>qt(Te.target.value),onKeyDown:Te=>{Te.key==="Enter"&&gt.trim()&&H(gt)},placeholder:"Describe the document to generate…",style:{flex:1,background:ln,border:"1px solid "+Ke,borderRadius:6,padding:"10px 14px",color:"#C9D1D9",fontFamily:D,fontSize:11,outline:"none"}}),(0,e.jsx)("button",{onClick:()=>{gt.trim()&&H(gt)},disabled:Pt||!gt.trim(),style:{padding:"10px 20px",background:Pt?Ut+"22":pe+"18",border:"1px solid "+(Pt?Ut:pe)+"44",borderRadius:6,cursor:Pt?"default":"pointer",fontFamily:D,fontSize:9,color:Pt?Ut:pe,fontWeight:700},children:Pt?"◌ GENERATING…":"GENERATE"})]}),xe&&(0,e.jsx)("div",{style:{marginTop:16,padding:14,background:xe.error?et+"0C":bt+"0C",border:"1px solid "+(xe.error?et:bt)+"33",borderRadius:8},children:(0,e.jsx)("span",{style:{fontFamily:D,fontSize:10,color:xe.error?et:bt},children:xe.error||"✓ Document generated and saved to vault"})})]})}),q==="upload"&&(0,e.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:16,padding:40},children:[(0,e.jsxs)("div",{style:{width:"100%",maxWidth:500,padding:"48px 32px",border:"2px dashed "+pe+"44",borderRadius:12,background:pe+"06",textAlign:"center",cursor:"pointer"},onClick:()=>f.current?.click(),children:[(0,e.jsx)("div",{style:{fontSize:40,marginBottom:12},children:Na.folderOpen}),(0,e.jsx)("div",{style:{fontFamily:D,fontSize:12,fontWeight:700,color:pe,letterSpacing:".08em",marginBottom:8},children:"DROP FILES OR CLICK TO UPLOAD"}),(0,e.jsx)("div",{style:{fontFamily:D,fontSize:9,color:"#7A90A8"},children:"PDF, DOCX, XLSX, CSV, TXT, MD, JSON — auto-classified by AI"}),(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Ut,marginTop:8},children:"Supported: .pdf .docx .doc .txt .csv .xlsx .xls .md .json .png .jpg"})]}),(0,e.jsx)("input",{ref:f,type:"file",multiple:!0,style:{display:"none"},onChange:Te=>{j(Te.target.files),Te.target.value="",ge("vault")}}),V.length>0&&(0,e.jsx)("div",{style:{padding:16},children:V.map(Te=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:4},children:[(0,e.jsx)("div",{style:{width:10,height:10,border:"2px s
386olid "+pe+"33",borderTop:"2px solid "+pe,borderRadius:"50%",animation:"xspin 0.8s linear infinite"}}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:10,color:pe},children:Te.name}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:"#7A90A8"},children:"uploading & analysing…"})]},Te.id))})]}),q==="ledger"&&(0,e.jsxs)("div",{style:{flex:1,overflow:"auto",padding:20},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:10,fontWeight:700,color:pe,letterSpacing:".12em",marginBottom:16},children:"◈ FINANCIAL LEDGER"}),(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,e.jsx)(WR,{onOpenLedger:s}),(0,e.jsx)($R,{})]})]}),c&&!o&&(0,e.jsx)(K5,{doc:c,onClose:()=>d(null),onAsk:Te=>{d(null),t&&t(Te)}})]})}function yz(t){var n=t.project;return(0,e.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:[(0,e.jsxs)("div",{style:{padding:"8px 20px",borderBottom:"1px solid #111820",background:"#060912",display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:8,color:"#D4AF5C",letterSpacing:".14em",fontWeight:700},children:"◇ PROJECT"}),(0,e.jsx)("div",{style:{fontWeight:700,fontSize:13,color:"#C9D1D9"},children:n&&n.name}),t.onExitProject&&(0,e.jsx)("button",{onClick:t.onExitProject,style:{marginLeft:"auto",padding:"3px 9px",background:"transparent",border:"1px solid #1C2740",borderRadius:4,cursor:"pointer",fontFamily:"monospace",fontSize:8,color:"#5A7090"},children:"EXIT PROJECT"})]}),(0,e.jsx)(w6,{workspace:t.workspace,onShowVoice:t.onShowVoice,onShowSettings:t.onShowSettings,memory:t.memory,profile:t.profile,savedDocs:t.savedDocs,project:n,onMemoryUpdate:t.onMemoryUpdate,onProjectMemoryUpdate:t.onProjectMemoryUpdate,sessionId:t.sessionId,onSaveSession:t.onSaveSession,onNewChat:t.onNewChat})]})}function xz(t){var n=t.messages,r=t.input,o=t.setInput,a=t.loading,l=t.onSend,s=t.onExit,c=(0,i.useState)(0),d=c[0],p=c[1];return(0,i.useEffect)(function(){var g=setInterval(function(){p(function(f){return f+1})},3e3);return function(){clearInterval(g)}},[]),(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,e.jsxs)("div",{style:{padding:"5px 16px",background:"#000",borderBottom:"2px solid #D4AF5C",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[(0,e.jsx)("span",{style:{fontWeight:900,fontSize:"14px",color:"#D4AF5C",letterSpacing:"-0.02em"},children:"XYRON TERMINAL"}),(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:"9px",color:"#6B7A94"},children:"BLOOMBERG LAYOUT"})]}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[(0,e.jsxs)("div",{style:{fontFamily:"monospace",fontSize:"9px",color:"#3FB950",display:"flex",alignItems:"center",gap:"4px"},children:[(0,e.jsx)("div",{style:{width:"4px",height:"4px",borderRadius:"50%",background:"#3FB950",animation:"xpulse 2s infinite"}}),"ARENBERG LIVE"]}),(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:"9px",color:"#7A8A9E"},children:FS()}),(0,e.jsx)("button",{onClick:s,style:{padding:"3px 10px",background:"rgba(200,92,92,0.1)",border:"1px solid rgba(200,92,92,0.3)",borderRadius:"4px",cursor:"pointer",fontFamily:"monospace",fontSize:"8px",color:"#C85C5C"},children:"EXIT BLOOMBERG"})]})]}),(0,e.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(6,1fr)",borderBottom:"1px solid #1E2838",flexShrink:0},children:[{label:"EQUITIES",items:[{s:"SPX",p:"5,847.32",c:"+0.43%",up:!0},{s:"NDX",p:"20,234.11",c:"+0.61%",up:!0},{s:"FTSE",p:"8,102.44",c:"-0.12%",up:!1}]},{label:"RATES",items:[{s:"US10Y",p:"4.284%",c:"+2.1bp",up:!1},{s:"US2Y",p:"4.812%",c:"-0.8bp",up:!0},{s:"BUND",p:"2.314%",c:"+1.2bp",up:!1}]},{label:"FX",items:[{s:"EUR/USD",p:"1.0823",c:"-0.21%",up:!1},{s:"GBP/USD",p:"1.2641",c:"+0.08%",up:!0},{s:"USD/JPY",p:"149.32",c:"+0.34%",up:!1}]},{label:"COMMODITIES",items:[{s:"GOLD",p:"$3,124.80",c:"+0.92%",up:!0},{s:"WTI",p:"$71.24",c:"-1.12%",up:!1},{s:"COPPER",p:"$4.21",c:"+0.45%",up:!0}]},{label:"CRYPTO",items:[{s:"BTC",p:"$84,320",c:"+2.14%",up:!0},{s:"ETH",p:"$3,841",c:"+1.88%",up:!0},{s:"SOL",p:"$148.20",c:"+3.21%",up:!0}]},{label:"VOL",items:[{s:"VIX",p:"16.42",c:"-0.84",up:!0},{s:"MOVE",p:"98.4",c:"+2.1",up:!1},{s:"SRVIX",p:"84.2",c:"-1.2",up:!0}]}].map(function(g,f){return(0,e.jsxs)("div",{style:{padding:"7px 10px",borderRight:f<5?"1px solid #111820":"none",background:f===d%6?"rgba(212,175,92,0.03)":"transparent",transition:"background 0.5s"},children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"7px",color:"#6B7A94",letterSpacing:"0.14em",marginBottom:"5px"},children:g.label}),g.items.map(function(h,x){return(0,e.jsxs)("div",{style:{marginBottom:"3px"},children:[(0,e.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline"},children:[(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:"8px",color:"#7A8A9E"},children:h.s}),(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:"9px",color:h.up?"#3FB950":"#C85C
3865C"},children:h.c})]}),(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"10px",color:"#C9D1D9",fontWeight:600},children:h.p})]},x)})]},f)})}),(0,e.jsxs)("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[(0,e.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:[(0,e.jsxs)("div",{style:{flex:1,overflow:"auto",padding:"12px 16px"},children:[n.filter(function(g){return!g.streaming||g.content}).slice(-6).map(function(g){var f=g.role==="user";return(0,e.jsxs)("div",{style:{marginBottom:"10px",padding:"8px 12px",background:f?"rgba(212,175,92,0.04)":"rgba(255,255,255,0.02)",border:"1px solid "+(f?"rgba(212,175,92,0.15)":"#1E2838"),borderRadius:"6px"},children:[(0,e.jsxs)("div",{style:{fontFamily:"monospace",fontSize:"8px",color:f?"#D4AF5C":"#3FB950",marginBottom:"4px",letterSpacing:"0.1em"},children:[f?"PRINCIPAL":"XYRON"," ",g.ts&&"· "+g.ts]}),(0,e.jsxs)("div",{style:{fontSize:"11px",color:"#C9D1D9",lineHeight:"1.6"},children:[(g.content||"").substring(0,300),(g.content||"").length>300?"...":""]})]},g.id||g.ts)}),a&&(0,e.jsx)("div",{style:{display:"flex",gap:"4px",padding:"8px"},children:[0,1,2].map(function(g){return(0,e.jsx)("div",{style:{width:"5px",height:"5px",borderRadius:"50%",background:"#D4AF5C",animation:"xpulse "+(.5+g*.15+"s")+" infinite"}},g)})})]}),(0,e.jsxs)("div",{style:{padding:"8px 12px",borderTop:"1px solid #111820",display:"flex",gap:"7px",background:"#000"},children:[(0,e.jsx)("input",{value:r,onChange:function(g){o(g.target.value)},onKeyDown:function(g){g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),l())},placeholder:"Arenberg Intelligence query...",style:{flex:1,background:"#0C1018",border:"1px solid #2A3548",borderRadius:"5px",padding:"7px 12px",color:"#E6EDF3",fontFamily:"monospace",fontSize:"11px",outline:"none"},onFocus:function(g){g.target.style.borderColor="#D4AF5C"},onBlur:function(g){g.target.style.borderColor="#2A3548"}}),(0,e.jsx)("button",{onClick:l,disabled:!r.trim()||a,style:{padding:"7px 16px",background:r.trim()&&!a?"#D4AF5C":"#141E2A",border:"none",borderRadius:"5px",cursor:r.trim()&&!a?"pointer":"not-allowed",fontFamily:"monospace",fontSize:"9px",color:r.trim()&&!a?"#000":"#3A4556",fontWeight:700},children:"GO"})]})]}),(0,e.jsxs)("div",{style:{width:"200px",flexShrink:0,borderLeft:"1px solid #1E2838",overflow:"auto",padding:"10px"},children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:"7px",color:"#6B7A94",letterSpacing:"0.14em",marginBottom:"8px"},children:"PORTFOLIO"}),(0,e.jsx)(kA,{}),(0,e.jsx)(TA,{score:42}),(0,e.jsx)(wA,{data:sA,size:100})]})]})]})}var P0=[{id:"cp1",name:"JPMorgan Chase & Co.",ticker:"JPM",sector:"Banking",hq:"New York",creditRating:"AA-",cdsSpread:"52bp",outlook:"Stable",relationship:"Prime Broker — Equities & FX. Relationship since 2019.",aum:"$3.9T",ceo:"Jamie Dimon",nextMeeting:"15 Apr 2026 — Quarterly Portfolio Review",news:[{headline:"JPM reports record Q1 trading revenue — fixed income +18% YoY",date:"02 Apr 2026",impact:"Positive"},{headline:"Basel III endgame relief: JPM capital buffer improves 80bp",date:"28 Mar 2026",impact:"Positive"},{headline:"JPM expanding digital asset custody for institutional clients",date:"22 Mar 2026",impact:"Neutral"}],exposure:"$289.6M equities custodied, $12.5M FX notional, $4.2M credit facility",riskLevel:"Low",riskColor:"#3FB950"},{id:"cp2",name:"Goldman Sachs Group",ticker:"GS",sector:"Investment Banking",hq:"New York",creditRating:"A+",cdsSpread:"68bp",outlook:"Stable",relationship:"Advisory — M&A and PE co-investment. Engaged for Fund IV due diligence.",aum:"$2.8T",ceo:"David Solomon",nextMeeting:"22 Apr 2026 — PE Fund IV Co-Investment Committee",news:[{headline:"GS launches $12B infrastructure fund targeting energy transition",date:"01 Apr 2026",impact:"Positive"},{headline:"Goldman private wealth AUM crosses $1T milestone",date:"25 Mar 2026",impact:"Positive"},{headline:"GS downgrades European equities to Underweight",date:"18 Mar 2026",impact:"Negative"}],exposure:"$0 direct, $20M PE Fund IV commitment (pending)",riskLevel:"Low",riskColor:"#3FB950"},{id:"cp3",name:"Société Générale",ticker:"GLE.PA",sector:"Banking",hq:"Paris",creditRating:"A",cdsSpread:"89bp",outlook:"Negative Watch",relationship:"Lender — Paris 8ème mixed-use refinancing. €44M facility maturing Q3 2026.",aum:"€1.5T",ceo:"Slawomir Krupa",nextMeeting:"08 May 2026 — Refinancing Term Sheet Review",news:[{headline:"SocGen cuts 900 investment banking roles globally",date:"30 Mar 2026",impact:"Negative"},{headline:"French CRE lending standards tightening — SocGen leads covenant review",date:"24 Mar 2026",impact:"Negative"},{headline:"SocGen Q4 results: NII +6%, trading flat, provisions up 22%",date:"15 Mar 2026",impact:"Mixed"}],exposure:"€44M term loan (Paris 8ème), ICR covenant 1.5x (current 1.7x)",riskLevel:"Medium",riskColor:"#D4AF5C"},{id:"cp4",name:"Blackstone Inc.",ticker:"BX",sector:"Alternatives",hq:"New York",creditRating:"A+",cdsSpread:"45bp",outlook:"Stable",relationship:"GP — PE Fund II (residual $4.2M). Evaluating co-invest in Fund V logistics strategy.",aum:"$1.1T",ceo:"Steve Schwarzman",nextMeeting:"28 Apr 2026 — Fun
386d V Logistics Strategy Presentation",news:[{headline:"Blackstone raises $34B for real estate Fund X — largest ever",date:"31 Mar 2026",impact:"Positive"},{headline:"BX European logistics portfolio: 98.4% occupancy, rents +4.2% QoQ",date:"26 Mar 2026",impact:"Positive"},{headline:"Blackstone BREIT redemptions slow to $1.2B — stabilising trend",date:"19 Mar 2026",impact:"Positive"}],exposure:"$4.2M PE Fund II residual, potential $15M Fund V co-invest",riskLevel:"Low",riskColor:"#3FB950"},{id:"cp5",name:"KKR & Co. Inc.",ticker:"KKR",sector:"Alternatives",hq:"New York",creditRating:"A",cdsSpread:"58bp",outlook:"Positive",relationship:"GP — PE Fund III LP ($50M commitment, $32M called). Key relationship.",aum:"$578B",ceo:"Scott Nuttall / Joseph Bae",nextMeeting:"10 Apr 2026 — Fund III Capital Call Review",news:[{headline:"KKR Infrastructure: $6.4B data centre platform expansion in Europe",date:"01 Apr 2026",impact:"Positive"},{headline:"KKR Fund III marks up portfolio 8.4% — AI infrastructure driving returns",date:"28 Mar 2026",impact:"Positive"},{headline:"KKR hires former ECB advisor for European macro strategy team",date:"20 Mar 2026",impact:"Neutral"}],exposure:"$50M committed ($32M called, $18M unfunded), Fund III LP",riskLevel:"Low",riskColor:"#3FB950"}];function vz(t){var n="monospace",r=(0,i.useState)("cp5"),o=r[0],a=r[1],l=(0,i.useState)(""),s=l[0],c=l[1],d=(0,i.useState)(!1),p=d[0],g=d[1],f=(0,i.useState)(null),h=f[0],x=f[1],v=s.trim()?P0.filter(function(j){return j.name.toLowerCase().indexOf(s.toLowerCase())!==-1||j.ticker.toLowerCase().indexOf(s.toLowerCase())!==-1}):P0,y=P0.filter(function(j){return j.id===o})[0]||null;function k(j){g(!0),x(null),gu({model:PS("counterparty_view"),max_tokens:800,system:"You are Xyron Intelligence — a private intelligence engine for institutional investors. Produce a concise meeting prep brief. Be direct, specific, and institutional.",messages:[{role:"user",content:"Prepare a meeting brief for: "+j.name+" ("+j.ticker+`)
387Relationship: `+j.relationship+`
388Exposure: `+j.exposure+`
389Credit: `+j.creditRating+" / CDS "+j.cdsSpread+" / "+j.outlook+`
390Recent news: `+j.news.map(function(E){return E.headline}).join("; ")+`
391Next meeting: `+j.nextMeeting+`
392
393Format as: ## Key Discussion Points, ## Risk Flags, ## Recommended Actions, ## Talking Points. Be concise — 1 page max.`}]}).then(function(E){x(E.content&&E.content[0]&&E.content[0].text||"Brief generation failed.")}).catch(function(){x("Connection error — using cached brief.")}).finally(function(){g(!1)})}var A=function(j){return j==="Positive"?"#3FB950":j==="Negative"?"#C85C5C":"#D4AF5C"};return(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden",background:"#080B11"},children:[(0,e.jsx)("div",{style:{padding:"0 28px",borderBottom:"1px solid #0D1520",background:"#080B11",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0,height:"56px"},children:(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[(0,e.jsx)("div",{style:{width:"24px",height:"24px",background:"rgba(176,188,200,0.1)",border:"1px solid rgba(176,188,200,0.2)",borderRadius:"6px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",color:"#B0BCC8"},children:"⊞"}),(0,e.jsx)("div",{style:{fontFamily:n,fontSize:"10px",color:"#C9D1D9",letterSpacing:"0.14em",fontWeight:700},children:"COUNTERPARTY INTELLIGENCE"}),(0,e.jsx)("div",{style:{width:"1px",height:"16px",background:"#0D1520"}}),(0,e.jsxs)("div",{style:{fontFamily:n,fontSize:"9px",color:"#5A7090"},children:[P0.length," counterparties"]})]})}),(0,e.jsxs)("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[(0,e.jsxs)("div",{style:{width:"260px",flexShrink:0,borderRight:"1px solid #0D1520",display:"flex",flexDirection:"column",background:"#020408",overflow:"auto"},children:[(0,e.jsx)("div",{style:{padding:"14px 12px 10px"},children:(0,e.jsx)("input",{value:s,onChange:function(j){c(j.target.value)},placeholder:"Search counterparties...",style:{width:"100%",background:"#070B10",border:"1px solid #1E2838",borderRadius:"5px",padding:"7px 10px",color:"#C9D1D9",fontFamily:n,fontSize:"10px",outline:"none",boxSizing:"border-box"},onFocus:function(j){j.target.style.borderColor="rgba(176,188,200,0.4)"},onBlur:function(j){j.target.style.borderColor="#1E2838"}})}),v.map(function(j){var E=o===j.id;return(0,e.jsxs)("button",{onClick:function(){a(j.id),x(null)},style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",background:E?"rgba(176,188,200,0.05)":"transparent",borderLeft:E?"2px solid #B0BCC8":"2px s
393olid transparent",border:"none",borderBottom:"1px solid #0A0F18",cursor:"pointer",textAlign:"left",width:"100%"},onMouseEnter:function(C){E||(C.currentTarget.style.background="#050810")},onMouseLeave:function(C){E||(C.currentTarget.style.background="transparent")},children:[(0,e.jsxs)("div",{style:{flex:1},children:[(0,e.jsx)("div",{style:{fontSize:"11px",color:E?"#C9D1D9":"#7A90A8",fontWeight:600},children:j.name}),(0,e.jsxs)("div",{style:{fontFamily:n,fontSize:"8px",color:"#3A5060",marginTop:"2px"},children:[j.ticker," · ",j.sector]})]}),(0,e.jsx)("div",{style:{width:"6px",height:"6px",borderRadius:"50%",background:j.riskColor,flexShrink:0}})]},j.id)})]}),(0,e.jsx)("div",{style:{flex:1,overflow:"auto",padding:"24px 28px"},children:y?(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:"20px"},children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontSize:"20px",fontWeight:700,color:"#E6EDF3",letterSpacing:"-0.02em"},children:y.name}),(0,e.jsxs)("div",{style:{fontFamily:n,fontSize:"9px",color:"#5A7090",marginTop:"4px"},children:[y.ticker," · ",y.sector," · ",y.hq]})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[(0,e.jsx)("div",{style:{padding:"4px 10px",background:y.riskColor+"15",border:"1px solid "+y.riskColor+"30",borderRadius:"4px",fontFamily:n,fontSize:"8px",color:y.riskColor,fontWeight:700},children:y.riskLevel.toUpperCase()}),(0,e.jsx)("div",{style:{padding:"4px 10px",background:"rgba(212,175,92,0.06)",border:"1px solid rgba(212,175,92,0.2)",borderRadius:"4px",fontFamily:n,fontSize:"8px",color:"#D4AF5C"},children:y.creditRating})]})]}),(0,e.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:"8px",marginBottom:"20px"},children:[{label:"CDS SPREAD",value:y.cdsSpread,color:"#D4AF5C"},{label:"CREDIT RATING",value:y.creditRating,color:"#B0BCC8"},{label:"OUTLOOK",value:y.outlook,color:y.outlook==="Stable"?"#3FB950":y.outlook.includes("Negative")?"#C85C5C":"#D4AF5C"},{label:"AUM",value:y.aum,color:"#D4AF5C"}].map(function(j,E){return(0,e.jsxs)("div",{style:{background:"#070B10",border:"1px solid #0D1520",borderRadius:"6px",padding:"10px 12px"},children:[(0,e.jsx)("div",{style:{fontFamily:n,fontSize:"7px",color:"#3A5060",letterSpacing:"0.1em",marginBottom:"4px"},children:j.label}),(0,e.jsx)("div",{style:{fontFamily:n,fontSize:"14px",color:j.color,fontWeight:700},children:j.value})]},E)})}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px",marginBottom:"20px"},children:[(0,e.jsxs)("div",{style:{background:"#070B10",border:"1px solid #0D1520",borderRadius:"6px",padding:"14px"},children:[(0,e.jsx)("div",{style:{fontFamily:n,fontSize:"8px",color:"#6A8098",letterSpacing:"0.12em",marginBottom:"8px"},children:"RELATIONSHIP"}),(0,e.jsx)("div",{style:{fontSize:"12px",color:"#C9D1D9",lineHeight:"1.6"},children:y.relationship})]}),(0,e.jsxs)("div",{style:{background:"#070B10",border:"1px solid #0D1520",borderRadius:"6px",padding:"14px"},children:[(0,e.jsx)("div",{style:{fontFamily:n,fontSize:"8px",color:"#6A8098",letterSpacing:"0.12em",marginBottom:"8px"},children:"EXPOSURE"}),(0,e.jsx)("div",{style:{fontSize:"12px",color:"#C9D1D9",lineHeight:"1.6"},children:y.exposure})]})]}),(0,e.jsxs)("div",{style:{background:"rgba(212,175,92,0.04)",border:"1px solid rgba(212,175,92,0.15)",borderRadius:"6px",padding:"12px 14px",marginBottom:"20px",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:n,fontSize:"8px",color:"#D4AF5C",letterSpacing:"0.1em",marginBottom:"3px"},children:"NEXT MEETING"}),(0,e.jsx)("div",{style:{fontSize:"12px",color:"#C9D1D9"},children:y.nextMeeting})]}),(0,e.jsx)("button",{onClick:function(){k(y)},disabled:p,style:{padding:"6px 14px",background:p?"transparent":"rgba(176,188,200,0.1)",border:"1px solid rgba(176,188,200,0.25)",borderRadius:"5px",cursor:p?"default":"pointer",fontFamily:n,fontSize:"8px",color:"#B0BCC8",fontWeight:700,display:"flex",alignItems:"center",gap:"5px"},onMouseEnter:function(j){p||(j.currentTarget.style.background="rgba(176,188,200,0.18)")},onMouseLeave:function(j){p||(j.currentTarget.style.background="rgba(176,188,200,0.1)")},children:p?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:{width:"8px",height:"8px",border:"1px solid rgba(176,188,200,0.3)",borderTop:"1px solid #B0BCC8",borderRadius:"50%",animation:"xspin 0.8s linear infinite"}}),"PREPARING..."]}):"◈ PREP FOR MEETING"})]}),(0,e.jsxs)("div",{style:{marginBottom:"20px"},children:[(0,e.jsx)("div",{style:{fontFamily:n,fontSize:"8px",color:"#6A8098",letterSpacing:"0.12em",marginBottom:"10px"},children:"RECENT INTELLIGENCE"}),y.news.map(function(j,E){return(0,e.jsxs)("div",{style:{display:"flex",gap:"10px",padding:"8px 0",borderBottom:"1px solid #0A0F18"},children:[(0,e.jsx)("div",{style:{width:"6px",height:"6px",borderRadius:"50%",background:A(j.impact),flexShrink:0,marginTop:"5px"}}),(0,e.jsxs)("div",{style:{flex:1},children:[(0,e.jsx)("div",{style:{fontSize:"11px",color:"#C9D1D9",lineHeight:"1.5"},children:j.headline}),(0,e.jsxs)("div",{style:{fontFamily:n,fontSize:"8px",color:"#3A5060",marginTop:"3px"},children:[j.date," · ",(0,e.jsx)("span",{style:{color:A(j.impact)},children:j.impact})]})]})]},E)})]}),h&&(0,e.jsxs)("div",{style:{background:"#070B10",border:"1px solid rgba(176,188,200,0.2)",borderLeft:"3px solid #B0BCC8",borderRadius:"6px",padding:"16px 18px",marginBottom:"20px"},children:[(0,e.jsx)("div",{style:{fontFamily:n,fontSize:"8px",color:"#B0BCC8",letterSpacing:"0.12em",marginBottom:"10px"},children:"MEETING PREP BRIEF"}),(0,e.jsx)("div",{style:{fontSize:"12px",color:"#C9D1D9",lineHeight:"1.7",whiteSpace:"pre-wrap"},children:h})]})]}):(0,e.jsx)("div",{style:{textAlign:"center",padding:"60px 0",color:"#3A5060",fontFamily:n,fontSize:"10px"},children:"Select a counterparty"})})]})]})}var U0={general:{key:"general",label:"General Intelligence",icon:"◎",desc:"Reasoning · research · documents",mode:"xyron_gpt"},cortex:{key:"cortex",label:"Cortex Financial Intelligence",icon:"◈",desc:"Alpha models · market tools · order flow",mode:"xyron_cortex"},legal:{key:"legal",label:"Legal Intelligence",icon:"⚖",desc:"Citation-grade legal lane",mode:"xyron_legal"},realestate:{key:"realestate",label:"Real Estate Intelligence",icon:"⌂",de
393sc:"DLD market data · property research",mode:null},geospatial:{key:"geospatial",label:"Geospatial Intelligence",icon:"⊕",desc:"Location intel · Xyron maps",mode:null},research:{key:"research",label:"Research Intelligence",icon:"⧉",desc:"Long-form deep research",mode:"research"}},$b={xyron_gpt:"general",xyron_cortex:"cortex",xyron_legal:"legal",research:"research"};function tF(t){return t?t==="legal_lane"?"legal":t==="location_tool_loop"?"geospatial":t==="cortex_tool_loop"||t==="council_tool_loop"||t.indexOf("market")===0?"cortex":"general":null}function nF(t){var n=t&&t.chatMode||"auto",r=t&&t.signal||null,o=t&&t.activeDrawer||null,a=n!=="auto"&&!!$b[n],l=null,s=null,c=[],d=r&&Array.isArray(r.used)?r.used.filter(function(g){return!!U0[g]}):null;d&&!d.length&&(d=null),a?l=$b[n]:d?(l=d[0],c=d.slice(1).map(function(g){return U0[g]})):o==="realestate"?l="realestate":o==="map"?l="geospatial":o==="room"||o==="portfolio"?l="cortex":r&&(r.mode==="xyron_legal"&&(l="legal"),l||(l=tF(r.reason)),l||(l="general")),l||(l="general"),!a&&l==="general"&&r&&(r.reason==="attachments_multimodal"?s="Documents & vision":(r.reason==="deep_latency_gpt"||r.reason==="deep_analysis"||r.profile==="deep")&&(s="Deep analysis")),l==="geospatial"&&r&&r.privateHint&&(s="Private map — no Google"),l==="cortex"&&r&&r.reason==="market_deep_gpt"&&(s="Deep market analysis");var p=U0[l]||U0.general;return{key:p.key,label:p.label,icon:p.icon,desc:p.desc,context:s,pinned:a,secondary:c,observed:!!d}}var vh="ui-monospace, SF Mono, Menlo, monospace",Jb="xy-active-intel-style",rF="@media (max-width: 560px) { .xy-aip-desc { display: none !important; } }@media (max-width: 768px) { .xy-aip-compact .xy-aip-name { display: none !important; } }@keyframes xyAipPulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }@keyframes xyAipShimmer { 0%,100% { opacity: .45 } 50% { opacity: 1 } }";function sp(t){var n=nF(t),r=!!t.compact,o=!!t.streaming;(0,i.useEffect)(function(){if(!(typeof document>"u")&&!document.getElementById(Jb)){var s=document.createElement("style");s.id=Jb,s.textContent=rF,document.head.appendChild(s)}},[]);var a=n.secondary||[],l=o?"Xyron is deciding which intelligence this turn needs":n.label+(n.context?" — "+n.context:"")+(a.length?" · with "+a.map(function(s){return s.label}).join(", "):"")+" · "+n.desc+" · Xyron decides automatically";return(0,e.jsxs)("div",{"data-testid":"active-intel-panel","data-intel":n.key,className:r?"xy-aip-compact":void 0,title:l,style:r?{position:"relative",display:"inline-flex",alignItems:"center",gap:6,padding:"2px 8px 2px 4px",height:24,background:"rgba(212,175,92,0.04)",border:"1px solid rgba(212,175,92,0.22)",borderRadius:999,flexShrink:0,maxWidth:"100%"}:{position:"relative",display:"inline-flex",alignItems:"center",gap:10,padding:"5px 12px",minHeight:34,background:"rgba(16,24,38,0.72)",border:"1px solid rgba(212,175,92,0.22)",borderRadius:10,backdropFilter:"blur(4px)",flexShrink:0,maxWidth:"100%"},children:[(0,e.jsx)("span",{"aria-hidden":"true",style:{width:r?17:22,height:r?17:22,borderRadius:"50%",display:"inline-flex",alignItems:"center",justifyContent:"center",border:"1px solid rgba(212,175,92,0.45)",boxShadow:"inset 0 0 6px rgba(212,175,92,0.15)",color:vt.gold,fontSize:r?10:12,flexShrink:0,animation:o?"xyAipShimmer 1.4s ease-in-out infinite":"none"},children:o?"◌":n.icon}),(0,e.jsxs)("span",{style:{display:"flex",flexDirection:"column",minWidth:0},children:[(0,e.jsxs)("span",{className:"xy-aip-name",style:{fontFamily:vh,fontSize:r?8:9,fontWeight:700,letterSpacing:".12em",color:o?vt.t3:vt.t1,textTransform:"uppercase",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:r?170:void 0,animation:o?"xyAipShimmer 1.4s ease-in-out infinite":"none"},children:[o?"Analyzing":n.label,!o&&a.length?(0,e.jsx)("span",{"aria-hidden":"true",style:{marginLeft:5,letterSpacing:".05em",color:vt.t3},children:a.map(function(s){return s.icon}).join(" ")}):null]}),r?null:(0,e.jsx)("span",{className:"xy-aip-desc",style:{fontFamily:vh,fontSize:8,letterSpacing:".06em",color:vt.t3,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:o?"Selecting intelligence for this turn":(0,e.jsxs)(e.Fragment,{children:[n.context?(0,e.jsxs)("span",{style:{color:vt.amberDim},children:[n.context.toUpperCase()," · "]}):null,n.desc]})})]}),(0,e.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:5,padding:"2px 8px",border:"1px solid rgba(212,175,92,0.40)",borderRadius:999,fontFamily:vh,fontSize:8,fontWeight:700,letterSpacing:".14em",color:vt.gold,flexShrink:0},children:[(0,e.jsx)("span",{"aria-hidden":"true",style:{width:4,height:4,borderRadius:"50%",background:vt.gold,animation:o?"xyAipPulse 1.1s ease-in-out infinite":"none"}}),"AUTO"]})]})}var Ln=Object.freeze({IDLE:"idle",WAITING:"waiting",CONNECTING:"connecting",THINKING:"thinking",STREAMING:"streaming",STALLED:"stalled",STOPPING:"stopping",STOPPED:"stopped",ERROR:"error"}),iF={waiting:{label:"Waiting",color:"#7A8BA5",pulse:!0},connecting:{label:"Connecting",color:"#7A8BA5",pulse:!0},thinking:{label:"Thinking",color:"#D4AF5C",pulse:!0},streaming:{label:"Streaming",color:"#5EA08C",pulse:!0},stalled:{label:"Waiting for model",color:"#C8A85C",pulse:!0},stopping:{label:"Stopping",color:"#8898A8",pulse:!0},stopped:{label:"Cancelled",color:"#8898A8",pulse:!1}
393,error:{label:"Error",color:"#C85C5C",pulse:!1}};function oF({state:t}){if(!t||t===Ln.IDLE)return null;const n=iF[t];return n?(0,e.jsxs)("div",{role:"status","aria-live":"polite","data-stream-state":t,"data-testid":"stream-status-pill",style:{display:"inline-flex",alignItems:"center",gap:6,padding:"2px 9px",background:"rgba(20, 28, 40, 0.55)",border:"1px solid rgba(212, 175, 92, 0.15)",borderRadius:10,fontFamily:"ui-monospace, SF Mono, Menlo, monospace",fontSize:9,letterSpacing:".08em",color:n.color,userSelect:"none"},children:[(0,e.jsx)("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:n.color,boxShadow:n.pulse?`0 0 6px ${n.color}88`:"none",animation:n.pulse?"xpulse 1.1s ease-in-out infinite":"none",flexShrink:0}}),(0,e.jsx)("span",{style:{textTransform:"uppercase"},children:n.label})]}):null}var aF=Object.freeze({idle:Object.freeze(new Set([Ln.WAITING])),waiting:Object.freeze(new Set([Ln.CONNECTING,Ln.THINKING,Ln.STREAMING,Ln.STOPPING,Ln.ERROR,Ln.IDLE])),connecting:Object.freeze(new Set([Ln.THINKING,Ln.STREAMING,Ln.STOPPING,Ln.ERROR,Ln.IDLE])),thinking:Object.freeze(new Set([Ln.STREAMING,Ln.STALLED,Ln.STOPPING,Ln.ERROR,Ln.IDLE])),streaming:Object.freeze(new Set([Ln.STALLED,Ln.STOPPING,Ln.ERROR,Ln.IDLE])),stalled:Object.freeze(new Set([Ln.STREAMING,Ln.THINKING,Ln.STOPPING,Ln.ERROR,Ln.IDLE])),stopping:Object.freeze(new Set([Ln.STOPPED])),stopped:Object.freeze(new Set([Ln.WAITING])),error:Object.freeze(new Set([Ln.WAITING]))});function PE(){try{return typeof import.meta<"u"&&!1}catch{return!1}}function Qb(t,n){if(t===n)return n;const r=aF[t];return r&&r.has(n)?n:(PE()&&console.warn("[StreamState] disallowed transition rejected: "+t+" -> "+n),t)}var UE="[StreamDiag]";function sx(){return PE()}function lF(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}const t=Date.now().toString(36),n=Math.random().toString(36).slice(2,10);return"turn-"+t+"-"+n}function WE(t,n,r,o){let a=UE+" "+(t||"?")+": "+n+" -> "+r;return o&&(a+=" ["+o+"]"),a}function sF(t,n,r,o){sx()&&n!==r&&console.debug(WE(t,n,r,o))}function cF(t,n,r,o){sx()&&console.warn("REJECTED "+WE(t,n,r,o))}function W0(t,n,r){if(!sx())return;const o=UE+" "+(t||"?")+" cleanup: "+n;r!==void 0?console.warn(o,r):console.warn(o)}var Ug=[{id:"nordstream",name:"Nord Stream 1/2",type:"gas",status:"destroyed",capacity:"110 bcm/yr",operator:"Nord Stream AG",detail:"Sabotaged Sep 2022. Was Europe's primary Russian gas link.",color:[255,60,60],colorHex:"#FF3C3C",path:[[28.73,60.71],[27.5,60.2],[25,59.7],[22,59],[19,57.5],[16,55.8],[14.5,54.8],[13.65,54.14]]},{id:"turkstream",name:"TurkStream",type:"gas",status:"active",capacity:"31.5 bcm/yr",operator:"Gazprom",detail:"Russia-Turkey subsea. Two lines: Turkey domestic + SE Europe.",color:[56,189,248],colorHex:"#6B9AC4",path:[[37.32,44.89],[36,44],[34,43.2],[32,42.5],[30.5,42],[28.95,41.02]]},{id:"tanap",name:"TANAP",type:"gas",status:"active",capacity:"16 bcm/yr",operator:"SOCAR/BOTAS",detail:"Azerbaijan gas to Turkey. Feeds TAP to Europe.",color:[56,189,248],colorHex:"#6B9AC4",path:[[49.87,40.41],[46.5,41.2],[44,40.8],[41.27,39.91],[38,39.5],[35,39.7],[32,40],[28.5,40.5],[26.5,40.8]]},{id:"tap",name:"TAP (Trans-Adriatic)",type:"gas",status:"active",capacity:"10 bcm/yr",operator:"TAP AG",detail:"Greece-Albania-Italy. Brings Caspian gas to EU.",color:[56,189,248],colorHex:"#6B9AC4",path:[[26.5,40.8],[24,40.5],[22,40.3],[20,40.5],[19,40.8],[18.52,40.35]]},{id:"yamal",name:"Yamal-Europe",type:"gas",status:"reduced",capacity:"33 bcm/yr",operator:"Gazprom",detail:"Flows reversed. Minimal Russian gas transit since 2022.",color:[56,189,248,150],colorHex:"#6B9AC4",path:[[34,57],[31,55],[27.5,53.9],[25,53.5],[21.5,52.8],[18,52.5],[14.5,52.3]]},{id:"langeled",name:"Langeled",type:"gas",status:"active",capacity:"25.5 bcm/yr",operator:"Gassco",detail:"Norway to UK. Europe's longest subsea pipeline.",color:[56,189,248],colorHex:"#6B9AC4",path:[[6,62.7],[4,61],[2.5,59],[1,57],[-.1,53.65]]},{id:"brotherhood",name:"Brotherhood (Urengoy)",type:"gas",status:"disrupted",capacity:"28 bcm/yr",operator:"Naftogaz/Gazprom",detail:"Last Russia-Ukraine gas transit route. Contract expires 2024.",color:[56,189,248,120],colorHex:"#6B9AC4",path:[[35.3,51.2],[32,50.8],[30.5,50.5],[28,49.5],[25,49],[22.3,48.6],[19,48.5],[16.9,48.4]]},{id:"medgaz",name:"Medgaz",type:"gas",status:"active",capacity:"10 bcm/yr",operator:"Sonatrach/Naturgy",detail
393:"Algeria to Spain direct subsea.",color:[56,189,248],colorHex:"#6B9AC4",path:[[.6,36.8],[0,36.5],[-.5,36.3],[-1.5,36.1],[-2.2,36.7]]}],Wg=[{id:"druzhba",name:"Druzhba Pipeline",type:"oil",status:"partial",capacity:"1.2M bbl/day",operator:"Transneft",detail:"World's longest oil pipeline network. Northern branch sanctioned, southern active.",color:[245,158,11],colorHex:"#F59E0B",path:[[50.1,53.2],[44,53.5],[38,53.3],[34.4,53.3],[29.2,52.05],[25,52],[21,52.2],[17,51],[14.3,53.1]]},{id:"btc",name:"BTC (Baku-Tbilisi-Ceyhan)",type:"oil",status:"active",capacity:"1.2M bbl/day",operator:"BP",detail:"Carries Azeri-Chirag-Gunashli crude. Strategic non-Russian route.",color:[245,158,11],colorHex:"#F59E0B",path:[[49.87,40.41],[47,41],[44.79,41.69],[43,40.5],[41.27,39.91],[39,38.5],[37,37.5],[35.79,36.93]]},{id:"espo",name:"ESPO Pipeline",type:"oil",status:"active",capacity:"1.6M bbl/day",operator:"Transneft",detail:"East Siberia-Pacific Ocean. Key Russia-China supply route.",color:[245,158,11],colorHex:"#F59E0B",path:[[98,55.9],[104,54.5],[108,53],[115,52],[120,53],[125,53.5],[130,48],[132.7,42.7]]},{id:"kirkuk",name:"Kirkuk-Ceyhan",type:"oil",status:"active",capacity:"0.5M bbl/day",operator:"Iraq/Turkey",detail:"Iraqi Kurdish crude to Mediterranean export terminal.",color:[245,158,11],colorHex:"#F59E0B",path:[[44.39,35.47],[43.5,36.5],[42,37],[40,37.3],[38,37],[35.79,36.93]]},{id:"transalaska",name:"Trans-Alaska (TAPS)",type:"oil",status:"active",capacity:"0.5M bbl/day",operator:"Alyeska",detail:"Prudhoe Bay to Valdez. US domestic strategic route.",color:[245,158,11],colorHex:"#F59E0B",path:[[-148.3,70.25],[-149.5,68.1],[-148,66],[-147.7,64.8],[-146,63.5],[-146.35,61.13]]},{id:"keystone",name:"Keystone System",type:"oil",status:"active",capacity:"0.6M bbl/day",operator:"TC Energy",detail
393:"Alberta oil sands to US Gulf refineries.",color:[245,158,11],colorHex:"#F59E0B",path:[[-111.7,52.7],[-108,51],[-104,49],[-100,45],[-97.5,40],[-96,36],[-94,30]]}],Zb=[{id:"qatar-eu",name:"Qatar → Europe (via Suez)",color:[45,212,191],colorHex:"#5BA8A0",volume:"31M tonnes/yr",detail:"Largest LNG exporter to Europe. Suez transit critical.",path:[[51.5,25.9],[54,25.5],[56.25,26.57],[58,23],[52,15],[44,14],[40,20],[32.35,30.45],[30,32],[20,35],[5,37],[4,51.9]]},{id:"qatar-japan",name:"Qatar → Japan/Korea",color:[45,212,191],colorHex:"#5BA8A0",volume:"25M tonnes/yr",detail:"Asia-bound LNG. Via Malacca or Lombok Strait.",path:[[51.5,25.9],[56.25,26.57],[65,20],[75,12],[85,6],[95,3],[103.75,1.25],[110,5],[120,15],[130,25],[135,33],[139.8,35.5]]},{id:"us-eu",name:"US Gulf → Europe",color:[45,212,191],colorHex:"#5BA8A0",volume:"18M tonnes/yr",detail:"Sabine Pass/Cameron LNG to NW Europe. Growing post-2022.",path:[[-93.8,29.7],[-88,27],[-80,28],[-70,32],[-50,38],[-30,44],[-10,49],[4,51.9]]},{id:"australia-japan",name:"Australia → Japan",color:[45,212,191],colorHex:"#5BA8A0",volume:"30M tonnes/yr",detail:"NW Shelf + Gladstone to Japan. Critical energy security.",path:[[115,-20],[118,-15],[120,-8],[125,0],[130,10],[135,25],[139.8,35.5]]},{id:"algeria-eu",name:"Algeria → Europe",color:[45,212,191],colorHex:"#5BA8A0",volume:"12M tonnes/yr",detail:"Skikda/Arzew LNG to Mediterranean markets.",path:[[0,36.8],[2,37.5],[5,39],[8,41],[9.5,43]]},{id:"us-asia",name:"US Gulf → Asia (via Panama)",color:[45,212,191],colorHex:"#5BA8A0",volume:"10M tonnes/yr",detail:"Growing Pacific route via expanded Panama Canal.",path:[[-93.8,29.7],[-88,25],[-82,15],[-79.5,9],[-80,5],[-90,5],[-110,10],[-140,20],[-160,25],[170,30],[139.8,35.5]]}],e1=[{id:"ttf",name:"TTF (Netherlands)",position:[4.5,52],commodity:"Natural Gas",benchmark:"TTF",price:"€34.2/MWh",change:"+2.8%",trend:"up",currency:"EUR"},{id:"nbp",name:"NBP (UK)",position:[-3,51.5],commodity:"Natural Gas",benchmark:"NBP",price:"£86.5/therm",change:"-1.2%",trend:"down",currency:"GBP"},{id:"henryhub",name:"Henry Hub (Louisiana)",position:[-92,30.2],commodity:"Natural Gas",benchmark:"Henry Hub",price:"$2.85/MMBtu",change:"+0.5%",trend:"up",currency:"USD"},{id:"jkm",name:"JKM (Asia)",position:[139.7,35.6],commodity:"LNG Spot",benchmark:"JKM",price:"$12.4/MMBtu",change:"+3.1%",trend:"up",currency:"USD"},{id:"brent",name:"Brent (North Sea)",position:[1.5,58],commodity:"Crude Oil",benchmark:"Brent",price:"$78.5/bbl",change:"-0.8%",trend:"down",currency:"USD"},{id:"wti",name:"WTI (Cushing, OK)",position:[-96.8,36],commodity:"Crude Oil",benchmark:"WTI",price:"$74.2/bbl",change:"-1.1%",trend:"down",currency:"USD"},{id:"dubai",name:"Dubai/Oman",position:[55.3,25.3],commodity:"Crude Oil",benchmark:"Dubai",price:"$77.8/bbl",change:"+0.3%",trend:"up",currency:"USD"},{id:"rbob",name:"RBOB Gasoline (NYH)",position:[-74,40.7],commodity:"Gasoline",benchmark:"RBOB",price:"$2.24/gal",change:"+1.5%",trend:"up",currency:"USD"},{id:"gasoil",name:"ICE Gasoil (NWE)",position:[4,52],commodity:"Gasoil/Diesel",benchmark:"ICE Gasoil",price:"$724/MT",change:"+2.0%",trend:"up",currency:"USD"},{id:"coal",name:"Newcastle Coal",position:[151.8,-32.9],commodity:"Thermal Coal",benchmark:"Newcastle",price:"$130/MT",change:"-3.2%",trend:"down",currency:"USD"}],nc=[{id:"hormuz",position:[56.25,26.57],name:"Strait of Hormuz",risk:"HIGH",detail:"21M bbl/day — 20% of global oil. Iran controls northern shore.",transit:"21M bbl/day oil",threat:"Iranian IRGC naval forces"},{id:"suez",position:[32.35,30.45],name:"Suez Canal",risk:"MEDIUM",detail:"12% of global trade. 1M bbl/day oil. Houthi disruptions rerouting.",transit:"12% global trade",threat:"Houthi missile/drone attacks"},{id:"malacca",position:[103.75,1.25],name:"Strait of Malacca",risk:"MEDIUM",detail:"16M bbl/day. China/Japan/Korea energy lifeline.",transit:"16M bbl/day",threat:"Piracy, territorial disputes"},{id:"gibraltar",position:[-5.5,36],name:"Strait of Gibraltar",risk:"LOW",detail:"Mediterranean LNG gate. Morocco-Spain sovereignty zone.",transit:"3M bbl/day",threat:"Low disruption risk"},{id:"bab",position:[43.3,12.5],name:"Bab el-Mandeb",risk:"CRITICAL",detail
393:"Red Sea southern gate. Under direct Houthi threat zone.",transit:"6M bbl/day",threat:"Active missile strikes"},{id:"panama",position:[-79.5,9],name:"Panama Canal",risk:"LOW",detail:"5% of global maritime trade. LNG transit growing.",transit:"5% global trade",threat:"Drought / water level"},{id:"danish",position:[12.5,55.5],name:"Danish Straits",risk:"LOW",detail:"Baltic Sea access. Nord Stream debris zone.",transit:"Baltic trade",threat:"Mine risk, NATO patrol"},{id:"turkish",position:[29,41],name:"Turkish Straits (Bosphorus)",risk:"MEDIUM",detail:"Black Sea access. Oil tanker traffic disputed.",transit:"3M bbl/day",threat:"Turkey regulatory control"}],id=[{id:"ukraine",position:[37.5,48.5],name:"Ukraine Conflict Zone",type:"war",risk:"CRITICAL",detail:"Active military conflict. Western sanctions on Russia. Energy supply disruption. Grain corridor contested.",actors:"Russia, Ukraine, NATO support",since:"Feb 2022",affectedSectors:["Energy","Grain","Defense","Shipping"]},{id:"gaza",position:[34.44,31.35],name:"Gaza / Israel",type:"war",risk:"CRITICAL",detail:"Active conflict. Regional escalation risk. Iran proxy involvement. Oil price premium.",actors:"Israel, Hamas, Hezbollah, Iran proxies",since:"Oct 2023",affectedSectors:["Oil","Shipping","Insurance","Defense"]},{id:"yemen",position:[44.2,15.5],name:"Yemen — Red Sea",type:"conflict",risk:"HIGH",detail:"Houthi attacks on commercial shipping. Insurance premiums 10x. Suez bypass.",actors:"Houthi forces, US/UK coalition",since:"Nov 2023",affectedSectors:["Shipping","Insurance","Oil","LNG"]},{id:"taiwan",position:[120.9,23.7],name:"Taiwan Strait",type:"tension",risk:"HIGH",detail:"TSMC produces 90% of advanced chips. US/China military posturing.",actors:"China PLA, Taiwan, US Navy",since:"Ongoing",affectedSectors:["Semiconductors","Tech","Shipping","Defense"]},{id:"korea",position:[125.7,38.9],name:"Korean Peninsula",type:"tension",risk:"MEDIUM",detail:"DPRK nuclear capability. 28,000 US troops. Samsung/SK Hynix exposure.",actors:"DPRK, South Korea, US forces",since:"Ongoing",affectedSectors:["Semiconductors","Defense","Shipping"]},{id:"sahel",position:[2,15],name:"Sahel Region",type:"conflict",risk:"HIGH",detail:"Military coups in Mali, Burkina Faso, Niger. Wagner/Africa Corps. Uranium access.",actors:"Military juntas, Wagner Group, France (withdrawing)",since:"2020",affectedSectors:["Mining","Uranium","Gold","Security"]},{id:"myanmar",position:[96.2,19.8],name:"Myanmar Civil War",type:"war",risk:"MEDIUM",detail:"Military junta vs resistance. Rare earth and jade mining disruption.",actors:"Tatmadaw, NUG, ethnic armed orgs",since:"Feb 2021",affectedSectors:["Rare Earth","Mining","Textiles"]},{id:"sudan",position:[32.5,15.6],name:"Sudan Civil War",type:"war",risk:"HIGH",detail:"SAF vs RSF. Humanitarian crisis. Red Sea port access contested.",actors:"SAF, RSF (Janjaweed)",since:"Apr 2023",affectedSectors:["Gold","Oil","Shipping","Agriculture"]},{id:"iran_tensions",position:[51.4,35.7],name:"Iran Nuclear Tensions",type:"tension",risk:"HIGH",detail:"Near weapons-grade enrichment. IAEA standoff. Strait of Hormuz leverage.",actors:"Iran, US, Israel, IAEA",since:"Ongoing",affectedSectors:["Oil","Gas","Shipping","Insurance","Defense"]},{id:"south_china_sea",position:[114,12],name:"South China Sea",type:"tension",risk:"MEDIUM",detail:"Territorial disputes. China military buildup. $5.3T annual trade transit.",actors:"China, Philippines, Vietnam, US Navy",since:"Ongoing",affectedSectors:["Shipping","Oil","Fish","Defense"]},{id:"ethiopia",position:[38.7,9],name:"Ethiopia — Tigray/Amhara",type:"conflict",risk:"MEDIUM",detail:"Post-ceasefire instability. Amhara militia activity. Nile dam dispute with Egypt.",actors:"Federal govt, Amhara Fano, TPLF",since:"2020",affectedSectors:["Agriculture","Water","Infrastructure"]},{id:"libya",position:[13.1,32.9],name:"Libya Instability",type:"tension",risk:"MEDIUM",detail:"Dual government. Oil production volatile. Mediterranean migration route.",actors:"GNU, LNA, various militias",since:"2011",affectedSectors:["Oil","Gas","Migration","Security"]}],HE=[{id:"russia",name:"Russia — Full Sanctions",type:"comprehensive",regimes:["US OFAC","EU","UK OTSI"],detail:"Energy price caps, SWIFT disconnection, asset freezes, export controls.",color:[167,139,250,60],polygon:[[27,70],[42,70],[50,68],[65,68],[70,65],[75,60],[80,55],[80,50],[75,45],[60,42],[50,42],[40,43],[30,46],[28,50],[27,55],[27,70]]},{id:"iran",name:"Iran — Comprehensive Sanctions",type:"comprehensive",regimes:["US OFAC","EU"],detail:"Nuclear program, IRGC designation, oil export restrictions.",color:[167,139,250,60],polygon:[[44,40],[54,40],[63,38],[63,25],[57,25],[49,27],[44,30],[44,40]]},{id:"dprk",name:"North Korea — Maximum Sanctions",type:"comprehensive",regimes:["UN","US","EU"],detail:"Nuclear/missile program. Near-total trade embargo.",color:[167,139,250,60],polygon:[[124,43],[130,43],[130,38],[124,38],[124,43]]},{id:"syria",name:"Syria — Comprehensive Sanctions",type:"comprehensive",regimes:["US Caesar Act","EU"],detail:"Civil war. Chemical weapons use. Reconstruction blocked.",color:[167,139,250,60],polygon:[[35.5,37.5],[42.5,37.5],[42.5,32.5],[35.5,32.5],[35.5,37.5]]},{id:"crimea",name:"Crimea — Occupied Territory",type:"territorial",regimes:["US","EU","UK"],detail:"Annexed by Russia 2014. Full economic embargo.",color:[255,60,60,80],pol
393ygon:[[32.5,46.2],[36.5,46.2],[36.5,44.3],[32.5,44.3],[32.5,46.2]]}],t1=[{id:"udeid",position:[51.3,25.1],name:"Al Udeid Air Base",force:"US/CENTCOM",type:"air",detail:"Largest US base in Middle East. Combined Air Operations Center.",projectionRadiusKm:2e3},{id:"diego",position:[72.4,-7.3],name:"Diego Garcia",force:"US/UK",type:"naval/air",detail:"Indian Ocean strategic hub. B-2 bomber forward base.",projectionRadiusKm:3e3},{id:"ramstein",position:[7.6,49.4],name:"Ramstein Air Base",force:"US/NATO",type:"air",detail:"NATO air command. Ukraine weapons coordination hub.",projectionRadiusKm:1500},{id:"yokosuka",position:[139.65,35.28],name:"Yokosuka Naval Base",force:"US Navy 7th Fleet",type:"naval",detail:"Forward-deployed carrier strike group. Japan alliance anchor.",projectionRadiusKm:2500},{id:"guam",position:[144.8,13.4],name:"Andersen AFB Guam",force:"US",type:"air/naval",detail:"B-52/B-1 bomber base. Pacific deterrence anchor.",projectionRadiusKm:3e3},{id:"norfolk",position:[-76.3,36.85],name:"Naval Station Norfolk",force:"US Navy",type:"naval",detail:"World's largest naval base. Atlantic Fleet HQ.",projectionRadiusKm:2e3},{id:"djibouti",position:[43.15,11.55],name:"Camp Lemonnier",force:"US/France/China",type:"multi",detail
393:"Bab el-Mandeb control. Counter-piracy. China's first overseas base.",projectionRadiusKm:1500},{id:"tartus",position:[35.9,34.9],name:"Tartus Naval Facility",force:"Russia",type:"naval",detail:"Russia's only Mediterranean naval base. Syria intervention anchor.",projectionRadiusKm:1e3},{id:"hainan",position:[109.5,18.2],name:"Yulin Naval Base",force:"China PLA Navy",type:"naval/sub",detail:"South China Sea SSBN base. Underground submarine pens.",projectionRadiusKm:2e3},{id:"kaliningrad",position:[20.5,54.7],name:"Kaliningrad",force:"Russia",type:"missile",detail:"Iskander missiles. Baltic Sea denial. NATO enclave pressure.",projectionRadiusKm:500},{id:"incirlik",position:[35.4,37],name:"Incirlik Air Base",force:"US/Turkey",type:"air",detail:"NATO nuclear sharing. B61 gravity bombs. Middle East reach.",projectionRadiusKm:1500},{id:"bahrain",position:[50.6,26.2],name:"NSA Bahrain (5th Fleet)",force:"US Navy",type:"naval",detail:"Fifth Fleet HQ. Persian Gulf patrol. Hormuz access.",projectionRadiusKm:1500}],Cf=[{id:"ringfire_japan",position:[142,38],name:"Japan Pacific Plate",type:"seismic",magnitude:6.8,detail:"Frequent M6+ events. Fukushima coast. Infrastructure risk.",depth:"30km",risk:"HIGH"},{id:"turkey_anatolia",position:[36,37.5],name:"East Anatolian Fault",type:"seismic",magnitude:7.8,detail:"2023 magnitude 7.8 earthquake killed 50,000+. Pipeline proximity.",depth:"10km",risk:"CRITICAL"},{id:"indonesia_ring",position:[106,-6.5],name:"Sunda Arc",type:"seismic",magnitude:6.5,detail:"Java-Sumatra subduction zone. Tsunami risk to Malacca shipping.",depth:"20km",risk:"HIGH"},{id:"chile_plate",position:[-72,-33],name:"Nazca Plate",type:"seismic",magnitude:6.2,detail:"Chile-Peru subduction. Copper/lithium mine disruption risk.",depth:"40km",risk:"MEDIUM"},{id:"iceland_volcano",position:[-22,63.9],name:"Reykjanes Volcanic Zone",type:"volcanic",magnitude:0,detail:"Active eruptions since 2021. Aviation disruption (Eyjafjallajökull repeat risk).",depth:"surface",risk:"MEDIUM"},{id:"etna",position:[15,37.75],name:"Mount Etna",type:"volcanic",magnitude:0,detail:"Frequent eruptions. Catania airport disruption. Mediterranean ash cloud.",depth:"surface",risk:"LOW"},{id:"california",position:[-118,34],name:"San Andreas Fault",type:"seismic",magnitude:5.5,detail:"Big One overdue. LA/SF infrastructure. Tech sector exposure.",depth:"15km",risk:"HIGH"},{id:"cascadia",position:[-124,46],name:"Cascadia Subduction Zone",type:"seismic",magnitude:0,detail:"M9.0+ overdue (300yr cycle). Pacific NW tsunami risk.",depth:"deep",risk:"HIGH"},{id:"taal",position:[121,14],name:"Taal Volcano (Philippines)",type:"volcanic",magnitude:0,detail:"Alert Level 1. Manila proximity. Semiconductor packaging at risk.",depth:"surface",risk:"MEDIUM"},{id:"nz_alpine",position:[170,-43.5],name:"Alpine Fault NZ",type:"seismic",magnitude:0,detail:"M8.0 overdue. South Island infrastructure.",depth:"15km",risk:"MEDIUM"}],dF=[{position:[-.08,51.51],name:"City of London",value:185.5,alloc:21.9,pnl:"+4.2%",detail:"FX trading hub — $2.7T daily. Lloyd’s. Equities + Fixed Income.",risk:"LOW"},{position:[2.33,48.87],name:"Paris 8ème",value:42,alloc:5,pnl:"+2.1%",detail:"Luxury real estate. Champs-Élysées commercial. ECB exposure.",risk:"LOW"},{position:[8.55,47.37],name:"Zurich",value:95,alloc:11.2,pnl:"+1.8%",detail:"Swiss private banking hub. UBS. Wealth management.",risk:"LOW"},{position:[55.27,25.2],name:"Dubai DIFC",value:68,alloc:8,pnl:"+6.5%",detail:"MENA gateway. Zero income tax. Real estate + PE.",risk:"LOW"},{position:[103.85,1.28],name:"Singapore",value:72,alloc:8.5,pnl:"+3.4%",detail:"Asia wealth hub. Family office. MAS framework.",risk:"LOW"},{position:[-74,40.71],name:"New York",value:120,alloc:14.2,pnl:"+5.8%",detail:"US equities. PE allocation. Hedge fund exposure.",risk:"LOW"},{position:[139.7,35.68],name:"Tokyo",value:55,alloc:6.5,pnl:"-1.2%",detail:"Nikkei exposure. Yen carry trade unwind risk.",risk:"MEDIUM"},{position:[-43.17,-22.91],name:"São Paulo",value:28,alloc:3.3,pnl:"+8.1%",detail:"EM equity allocation. Commodity beta. Real/USD.",risk:"MEDIUM"},{position:[37.6,55.75],name:"Moscow (Frozen)",value:15,alloc:1.8,pnl:"-100%",detail
393:"Frozen assets. Sanctions block. NSD depository lock.",risk:"CRITICAL"},{position:[114.15,22.28],name:"Hong Kong",value:45,alloc:5.3,pnl:"+0.5%",detail:"China/Asia gateway. Southbound connect. HSI exposure.",risk:"MEDIUM"}],n1=[{position:[78,22],name:"India Semiconductor Fabs",type:"infrastructure",conviction:5,detail:"$30B govt incentive. Tata/Micron fabs. Supply chain diversification from Taiwan.",timeHorizon:"3-5yr",sectors:["Semiconductors","Manufacturing"]},{position:[39.8,24.5],name:"Saudi NEOM / Vision 2030",type:"megaproject",conviction:4,detail:"$500B+ investment. Luxury tourism, tech hub, green energy.",timeHorizon:"5-10yr",sectors:["Real Estate","Tourism","Tech","Energy"]},{position:[106.6,-6.2],name:"Indonesia Nickel Processing",type:"commodity",conviction:4,detail:"50% of global nickel. Export ban drives downstream value. EV battery chain.",timeHorizon:"2-4yr",sectors:["Mining","EV","Batteries"]},{position:[106.7,10.8],name:"Vietnam Manufacturing Shift",type:"supply_chain",conviction:5,detail:"China+1 beneficiary. Samsung, Intel fabs. Low labour cost.",timeHorizon:"2-5yr",sectors:["Manufacturing","Electronics","Textiles"]},{position:[-3.7,40.4],name:"Spain Green Energy",type:"energy_transition",conviction:3,detail:"EU Green Deal beneficiary. Solar/wind capacity doubling.",timeHorizon:"3-7yr",sectors:["Renewables","Utilities","Grid"]},{position:[46.7,24.7],name:"Saudi Aramco IPO Tranche",type:"equity",conviction:3,detail:"Additional share sales expected. World's most profitable company.",timeHorizon:"1-2yr",sectors:["Oil","Equity"]},{position:[28,-26.2],name:"South Africa Platinum Belt",type:"commodity",conviction:3,detail:"70% of global platinum. Hydrogen economy catalyst demand.",timeHorizon:"3-5yr",sectors:["Mining","PGMs","Hydrogen"]},{position:[-99.1,19.4],name:"Mexico Nearshoring",type:"supply_chain",conviction:4,detail:"US nearshoring boom. Auto/electronics. USMCA advantage.",timeHorizon:"2-5yr",sectors:["Manufacturing","Auto","Logistics"]},{position:[36.8,-1.3],name:"East Africa Digital",type:"technology",conviction:3,detail:"M-Pesa ecosystem. Fintech adoption. Growing middle class.",timeHorizon:"5-10yr",sectors:["Fintech","Telecom","Agriculture"]},{position:[121.5,31.2],name:"China A-Shares Value",type:"equity",conviction:2,detail:"Deep value after 3yr selloff. Stimulus cycle. Regulatory reset.",timeHorizon:"1-3yr",sectors:["Equity","Tech","Consumer"]}],r1=[{position:[-77,38.9],name:"Federal Reserve",code:"FED",rate:"5.25%",bias:"hawkish",lastMove:"+25bp Jul 2023",nextMeet:"Mar 2026",detail:"Terminal rate debate. Balance sheet runoff."},{position:[13.4,52.5],name:"ECB (Frankfurt)",code:"ECB",rate:"4.50%",bias:"neutral",lastMove:"+25bp Sep 2023",nextMeet:"Apr 2026",detail:"Inflation sticky. Southern Europe debt concern."},{position:[-.09,51.51],name:"Bank of England",code:"BOE",rate:"5.25%",bias:"hawkish",lastMove:"+25bp Aug 2023",nextMeet:"Mar 2026",detail:"UK recession risk. Mortgage repricing."},{position:[139.77,35.68],name:"Bank of Japan",code:"BOJ",rate:"0.10%",bias:"dovish",lastMove:"YCC tweak Jul 2023",nextMeet:"Apr 2026",detail:"Yield curve control shift. Yen weakness."},{position:[116.4,39.9],name:"People's Bank of China",code:"PBOC",rate:"3.45%",bias:"dovish",lastMove:"-15bp Jun 2023",nextMeet:"Monthly",detail:"Property crisis stimulus. Yuan managed decline."},{position:[8.54,47.37],name:"Swiss National Bank",code:"SNB",rate:"1.75%",bias:"neutral",lastMove:"+25bp Jun 2023",nextMeet:"Mar 2026",detail:"CHF strength management. Gold reserves."},{position:[149.13,-35.28],name:"Reserve Bank of Australia",code:"RBA",rate:"4.35%",bias:"hawkish",lastMove:"+25bp Nov 2023",nextMeet:"Feb 2026",detail:"Housing market. Commodity cycle linked."},{position:[37.6,55.75],name:"Central Bank of Russia",code:"CBR",rate:"16.00%",bias:"hawkish",lastMove:"+200bp Dec 2023",nextMeet:"Ongoing",detail:"War economy inflation. Capital controls."},{position:[28.98,41.01],name:"Central Bank of Turkey",code:"TCMB",rate:"45.00%",bias:"hawkish",lastMove:"+250bp Jan 2024",nextMeet:"Ongoing",detail:"Orthodox pivot. Lira stabilization attempt."},{position:[55.3,25.25],name:"UAE Central Bank",code:"CBUAE",rate:"5.40%",bias:"neutral",lastMove:"Follows Fed",nextMeet:"Follows Fed",detail
393:"Dirham peg to USD. Dubai growth driver."}],uF=[{id:"usd",position:[-95,38],code:"USD",name:"US Dollar",strength:85,dxy:104.2,ytdChange:"+3.5%",color:[63,185,80]},{id:"eur",position:[10,50],code:"EUR",name:"Euro",strength:55,rate:1.087,ytdChange:"-2.1%",color:[56,189,248]},{id:"gbp",position:[-2,53],code:"GBP",name:"British Pound",strength:50,rate:1.265,ytdChange:"-1.8%",color:[167,139,250]},{id:"jpy",position:[138,37],code:"JPY",name:"Japanese Yen",strength:25,rate:149.5,ytdChange:"-8.2%",color:[255,107,107]},{id:"chf",position:[8,47],code:"CHF",name:"Swiss Franc",strength:72,rate:.875,ytdChange:"+1.2%",color:[63,185,80]},{id:"cny",position:[110,35],code:"CNY",name:"Chinese Yuan",strength:35,rate:7.24,ytdChange:"-4.5%",color:[255,107,107]},{id:"aud",position:[135,-25],code:"AUD",name:"Australian Dollar",strength:42,rate:.654,ytdChange:"-3.8%",color:[251,191,36]},{id:"cad",position:[-100,55],code:"CAD",name:"Canadian Dollar",strength:48,rate:1.362,ytdChange:"-2.5%",color:[251,191,36]}],i1=[{id:"asia-eu",name:"Asia → Europe (Suez)",type:"container",color:[100,165,250],volume:"24M TEU/yr",detail:"World's busiest container route.",path:[[121.5,31.2],[114,22],[103.75,1.25],[80,8],[65,15],[50,14],[43.3,12.5],[40,20],[32.35,30.45],[20,35],[5,36],[0,48],[4,51.9]]},{id:"transpacific",name:"Transpacific (Asia → US West)",type:"container",color:[100,165,250],volume:"28M TEU/yr",detail:"Largest bilateral trade route.",path:[[121.5,31.2],[130,35],[150,40],[170,42],[-170,43],[-150,42],[-130,38],[-122.4,37.8]]},{id:"transatlantic",name:"Transatlantic",type:"container",color:[100,165,250],volume:"8M TEU/yr",detail:"US-Europe bilateral trade.",path:[[-74,40.7],[-60,42],[-40,45],[-20,48],[-5,50],[4,51.9]]},{id:"cape",name:"Cape of Good Hope (Suez bypass)",type:"tanker",color:[245,158,11],volume:"Growing",detail:"Houthi rerouting via South Africa. +10 days transit.",path:[[65,15],[60,5],[50,-10],[40,-25],[28,-34],[18.5,-34.5],[10,-20],[0,0],[-10,20],[-5,36],[4,51.9]]},{id:"arctic",name:"Northern Sea Route",type:"emerging",color:[45,212,191],volume:"2M tonnes/yr",detail:"Arctic summer route. Russia-controlled. Growing with ice melt.",path:[[139.7,35.5],[142,45],[150,55],[160,65],[170,70],[-170,72],[-150,70],[-100,72],[-50,70],[-10,65],[4,51.9]]}],vy=[{id:"apt28",origin:[37.6,55.75],target:[-77,38.9],name:"APT28 (Fancy Bear)",attribution:"Russia GRU",type:"state",detail:"Government/defense/energy sector targeting.",color:[255,68,68]},{id:"apt41",origin:[116.4,39.9],target:[-122.4,37.8],name:"APT41 (Winnti)",attribution:"China MSS",type:"state",detail:"Tech/telecom/healthcare espionage.",color:[255,68,68]},{id:"lazarus",origin:[125.7,39],target:[-74,40.7],name:"Lazarus Group",attribution:"North Korea RGB",type:"state",detail:"Financial theft. Crypto heists. $1B+ stolen.",color:[255,68,68]},{id:"apt33",origin:[51.4,35.7],target:[55.3,25.3],name:"APT33 (Elfin)",attribution:"Iran IRGC",type:"state",detail:"Energy/aviation sector. Shamoon wiper.",color:[255,68,68]},{id:"sandworm",origin:[37.6,55.75],target:[30.5,50.5],name:"Sandworm",attribution:"Russia GRU Unit 74455",type:"state",detail:"Power grid attacks. NotPetya. Olympic Destroyer.",color:[255,68,68]}],Hg=[{position:[121,24.8],name:"TSMC Hsinchu",type:"semiconductor",risk:"HIGH",detail:"90% of advanced chips (<7nm). Single point of failure for global tech.",disruptionImpact:"CRITICAL"},{position:[127,37],name:"Samsung/SK Hynix (Korea)",type:"memory",risk:"MEDIUM",detail:"55% of global DRAM. Proximity to DPRK.",disruptionImpact:"HIGH"},{position:[121.5,31.2],name:"Shanghai Port",type:"port",risk:"MEDIUM",detail:"World's busiest port. 47M TEU/yr. COVID lockdown precedent.",disruptionImpact:"CRITICAL"},{position:[114.3,22.3],name:"Shenzhen Manufacturing",type:"electronics",risk:"MEDIUM",detail:"Consumer electronics assembly. 90% of global drones.",disruptionImpact:"HIGH"},{position:[4,51.9],name:"Rotterdam Port",type:"port",risk:"LOW",detail:"Europe's largest port. Energy import hub. Rhine corridor.",disruptionImpact:"HIGH"},{position:[103.75,1.25],name:"Singapore Shipping Hub",type:"port",risk:"LOW",detail:"World's busiest transshipment port. Malacca gateway.",disruptionImpact:"HIGH"},{position:[-4,5.3],name:"Ivory Coast Cocoa",type:"agriculture",risk:"MEDIUM",detail
393:"40% of global cocoa. Climate/disease risk. Price volatility.",disruptionImpact:"MEDIUM"},{position:[28,-26.2],name:"South Africa PGMs",type:"mining",risk:"MEDIUM",detail:"70% of global platinum. Eskom power cuts. Labour unrest.",disruptionImpact:"HIGH"},{position:[-66,-17],name:"Lithium Triangle",type:"mining",risk:"MEDIUM",detail:"Chile/Argentina/Bolivia. 60% of lithium reserves. EV battery chain.",disruptionImpact:"HIGH"},{position:[26,-29],name:"Rare Earth (DRC)",type:"mining",risk:"HIGH",detail:"70% of global cobalt. Artisanal mining. ESG concerns.",disruptionImpact:"CRITICAL"}],fF=[{id:"atlantic_hurricane",center:[-60,20],name:"Atlantic Hurricane Belt",type:"hurricane",radius:1500,risk:"seasonal",detail:"Jun-Nov season. Gulf Coast refinery/energy impact.",color:[96,165,250,80]},{id:"pacific_typhoon",center:[140,20],name:"Western Pacific Typhoon",type:"typhoon",radius:1200,risk:"seasonal",detail:"May-Nov. Japan/Taiwan/Philippines impact.",color:[96,165,250,80]},{id:"sahel_drought",center:[10,15],name:"Sahel Drought Belt",type:"drought",radius:2e3,risk:"persistent",detail:"Expanding desertification. Food security crisis.",color:[249,115,22,60]},{id:"india_monsoon",center:[78,22],name:"Indian Monsoon",type:"flood",radius:800,risk:"seasonal",detail:"Jun-Sep. Agriculture + infrastructure disruption.",color:[96,165,250,80]}],pF=[{lat:51.15,lng:-.19,name:"Farnborough Airport FBO",code:"EGLF",region:"UK"},{lat:46.23,lng:6.11,name:"Geneva Cointrin FBO",code:"LSGG",region:"Switzerland"},{lat:48.07,lng:16.57,name:"Vienna Schwechat VIP",code:"LOWW",region:"Austria"},{lat:48.35,lng:11.78,name:"Munich Oberpfaffenhofen",code:"EDMO",region:"Germany"},{lat:25.25,lng:55.36,name:"Dubai Al Maktoum VIP",code:"OMDW",region:"UAE"},{lat:25.32,lng:51.61,name:"Doha FBO",code:"OTBD",region:"Qatar"},{lat:40.64,lng:-73.78,name:"Teterboro (NYC)",code:"KTEB",region:"USA"},{lat:34.02,lng:-118.45,name:"Van Nuys (LA)",code:"KVNY",region:"USA"},{lat:45.63,lng:8.72,name:"Milan Malpensa VIP",code:"LIMC",region:"Italy"},{lat:41.8,lng:12.24,name:"Rome Ciampino VIP",code:"LIRA",region:"Italy"},{lat:36.85,lng:30.8,name:"Antalya VIP Terminal",code:"LTAI",region:"Turkey"},{lat:55.97,lng:37.41,name:"Moscow Sheremetyevo VIP",code:"UUEE",region:"Russia"},{lat:1.35,lng:103.99,name:"Singapore Seletar FBO",code:"WSSL",region:"Singapore"},{lat:22.29,lng:113.92,name:"Hong Kong HKBA",code:"VHHH",region:"Hong Kong"},{lat:35.76,lng:140.39,name:"Tokyo Narita VIP",code:"RJAA",region:"Japan"},{lat:43.65,lng:7.22,name:"Nice Côte d’Azur VIP",code:"LFMN",region:"France"},{lat:46.91,lng:7.5,name:"Bern Belp",code:"LSZB",region:"Switzerland"},{lat:47.26,lng:11.34,name:"Innsbruck Kranebitten",code:"LOWI",region:"Austria"},{lat:39.48,lng:-.47,name:"Valencia FBO",code:"LEVC",region:"Spain"},{lat:36.75,lng:3.35,name:"Algiers FBO",code:"DAAG",region:"Algeria"},{lat:33.94,lng:-118.41,name:"Los Angeles LAX VIP",code:"KLAX",region:"USA"}],gF=[{position:[37.5,48.5],weight:100},{position:[34.44,31.35],weight:95},{position:[44.2,15.5],weight:90},{position:[51.4,35.7],weight:85},{position:[120.9,23.7],weight:80},{position:[56.25,26.57],weight:75},{position:[32.35,30.45],weight:65},{position:[43.3,12.5],weight:88},{position:[125.7,38.9],weight:60},{position:[114,12],weight:55},{position:[2,15],weight:65},{position:[32.5,15.6],weight:70},{position:[96.2,19.8],weight:50},{position:[13.1,32.9],weight:45},{position:[38.7,9],weight:40},{position:[103.75,1.25],weight:30},{position:[20.5,54.7],weight:55},{position:[36,37.5],weight:50},{position:[142,38],weight:35},{position:[-79.5,9],weight:20},{position:[29,41],weight:40},{position:[109.5,18.2],weight:50},{position:[35.9,34.9],weight:55},{position:[65,15],weight:35},{position:[-72,-33],weight:25}],mF=[{id:"nordlink",name:"NordLink HVDC (NO-DE)",path:[[6.3,58.4],[7.5,56.5],[8.3,53.9]],capacityMW:1400},{id:"ifa2",name:"IFA-2 (UK-FR)",path:[[-1.1,50.1],[-.6,49.5]],capacityMW:1e3},{id:"viking",name:"Viking Link (UK-DK)",path:[[0,53.3],[8.5,55.8]],capacityMW:1400},{id:"celticInt",name:"Celtic (IE-FR)",path:[[-8,52.1],[-4.3,48.3]],capacityMW:700}
393,{id:"estlink",name:"EstLink (EE-FI)",path:[[25,59.4],[25.5,60.3]],capacityMW:1e3}],hF=[{position:[-97.8,30.3],name:"ERCOT North Hub",capacityGW:18},{position:[-74.6,40.7],name:"PJM East Interface",capacityGW:22},{position:[8.5,50.1],name:"TenneT Frankfurt",capacityGW:14},{position:[2.35,48.86],name:"RTE Paris Ring",capacityGW:12},{position:[139.7,35.6],name:"TEPCO Tokyo Backbone",capacityGW:28},{position:[114.2,30.6],name:"SGCC Central China",capacityGW:40},{position:[77.2,28.6],name:"POSOCO Delhi Interface",capacityGW:17}],cx=[{position:[49.2,26.4],name:"Jamnagar (Reliance)",country:"India",capacityKbd:1240},{position:[55.2,24.2],name:"Ruwais (ADNOC)",country:"UAE",capacityKbd:817},{position:[48.4,29.1],name:"Al-Zour (KNPC)",country:"Kuwait",capacityKbd:615},{position:[125.4,10.3],name:"Paraguana (PDVSA)",country:"Venezuela",capacityKbd:940},{position:[-94.1,29.7],name:"Port Arthur (Motiva)",country:"USA",capacityKbd:636},{position:[-95.2,29.8],name:"Baytown (Exxon)",country:"USA",capacityKbd:584},{position:[4.4,51.9],name:"Pernis (Shell)",country:"Netherlands",capacityKbd:404},{position:[49.6,40.4],name:"Baku (SOCAR)",country:"Azerbaijan",capacityKbd:230},{position:[116.4,39.9],name:"Beijing Yanshan (Sinopec)",country:"China",capacityKbd:200},{position:[135,34.7],name:"Chiba (Cosmo)",country:"Japan",capacityKbd:220}],o1=[{position:[-93.2,29.6],name:"US SPR — Gulf Coast",mmbbl:363,days:27},{position:[121.5,31.2],name:"China SPR",mmbbl:289,days:20},{position:[139.8,35.6],name:"Japan SPR",mmbbl:500,days:212},{position:[127,37],name:"South Korea SPR",mmbbl:145,days:90},{position:[8.5,50.1],name:"EU Aggregate",mmbbl:450,days:85},{position:[77.2,28.6],name:"India SPR",mmbbl:39,days:10}],yF=[{position:[-77,38.9],name:"USA — Midterms",date:"2026-11-04",risk:"MEDIUM"},{position:[2.35,48.86],name:"France — Legislatives",date:"2026-06-21",risk:"MEDIUM"},{position:[-3.7,40.4],name:"Spain — General",date:"2026-09-12",risk:"LOW"},{position:[28.98,41.01],name:"Turkey — Local",date:"2026-03-31",risk:"HIGH"},{position:[-99.1,19.4],name:"Mexico — Judicial",date:"2026-06-01",risk:"MEDIUM"},{position:[120.9,23.7],name:"Taiwan — Legislative By",date:"2026-05-17",risk:"HIGH"},{position:[30.5,50.4],name:"Ukraine — Presidential*",date:"2026-TBD",risk:"CRITICAL"},{position:[-43.2,-22.9],name:"Brazil — Municipal",date:"2026-10-04",risk:"LOW"}],a1=[{position:[44.2,15.5],name:"Houthi drone — tanker",date:"26-04-14",severity:"HIGH"},{position:[31,29.9],name:"Sinai — convoy IED",date:"26-04-09",severity:"MEDIUM"},{position:[2,15],name:"Sahel — village raid",date:"26-04-06",severity:"HIGH"},{position:[69,34.5],name:"Kabul — bombing",date:"26-04-02",severity:"HIGH"},{position:[38.7,9],name:"Amhara — fighting",date:"26-03-31",severity:"MEDIUM"},{position:[35.5,33.9],name:"South Lebanon — strike",date:"26-03-27",severity:"CRITICAL"}],xF=[{position:[-74.01,40.7],name:"NYSE / NASDAQ",mcapTn:27,tier:1},{position:[139.77,35.67],name:"JPX (Tokyo)",mcapTn:6,tier:1},{position:[-.09,51.51],name:"LSEG / IPE",mcapTn:3.3,tier:1},{position:[121.5,31.2],name:"SSE / Shanghai",mcapTn:7.5,tier:1},{position:[114.2,22.3],name:"HKEX",mcapTn:4.3,tier:1},{position:[103.85,1.29],name:"SGX Singapore",mcapTn:.8,tier:2},{position:[8.68,50.11],name:"Deutsche Börse",mcapTn:2.1,tier:1},{position:[4.9,52.37],name:"Euronext Amsterdam",mcapTn:1.4,tier:1},{position:[72.83,18.94],name:"NSE / BSE India",mcapTn:4.2,tier:1},{position:[37.62,55.75],name:"MOEX Moscow",mcapTn:.3,tier:3}],vF=[{position:[-74.06,40.78],name:"NY4 (Equinix)",type:"colo",tier:1},{position:[-.05,51.52],name:"LD4 (Equinix)",type:"colo",tier:1},{position:[139.67,35.52],name:"TY3 (Equinix)",type:"colo",tier:1},{position:[8.68,50.11],name:"FR5 (Equinix)",type:"colo",tier:1},{position:[103.69,1.32],name:"SG1 (Equinix)",type:"colo",tier:1},{position:[-122.4,37.8],name:"SFO — us-west-1",type:"cloud",tier:1},{position:[-77.5,39],name:"IAD — us-east-1",type:"cloud",tier:1},{position:[7.6,50.1],name:"FRA — eu-central",type:"cloud",tier:1},{position:[151.2,-33.8],name:"SYD — ap-southeast",type:"cloud",tier:1}],l1=[{position:[-81.38,19.29],name:"Cayman Islands",secrecy:72},{position:[-64.62,32.3],name:"Bermuda",secrecy:68},{position:[-64.76,18.43],name:"BVI",secrecy:65},{position:[6.13,49.62],name:"Luxembourg",secrecy:58},{position:[8.54,47.37],name:"Switzerland",secrecy:70},{position:[103.85,1.29],name:"Singapore",secrecy:65},{position:[114.16,22.29],name:"Hong Kong",secrecy:66},{position:[-2.5,49.22],name:"Jersey",secrecy:66},{position:[-2.56,49.45],name:"Guernsey",secrecy:62},{position:[55.27,25.2],name:"Dubai (DIFC)",secrecy:64},{position:[57.5,-20.16],name:"Mauritius (GBC)",secrecy:71},{position:[55.45,-4.62],name:"Seychelles",secrecy:67},{position:[-10.8,6.3],name:"Liberia",secrecy:64},{position:[25.91,-24.65],name:"Botswana (IFSC)",secrecy:61},{position:[-7.59,33.57],name:"Casablanca Finance City",secrecy:60},{position:[30.06,-1.94],name:"Kigali IFC",secrecy:58}],bF=[{position:[-119.5,37.2],name:"California — Sierra",acres:28e3,risk:"HIGH"},{position:[-124,44.5],name:"Oregon Cascades",acres:12e3,risk:"MEDIUM"},{position:[-108.3,53.2],name:"Canada — Saskatchewan",acres:95e3,risk:"CRITICAL"},{position:[150.7,-33.7],name:"NSW Blue Mountains",acres:18e3,risk:"HIGH"},{position:[22.5,38.5],name:"Greece — Peloponnese",acres:6e3,risk:"MEDIUM"},{position:[-4.5,38],name:"Spain — Andalucia",acres:4200,risk:"MEDIUM"},{position:[-58.1,-8.5],name:"Amazon — Pará",acres:72e3,risk:"CRITICAL"}],SF=[{position:[142.3,38.1],mag:5.4,depth:32,name:"Off Honshu"},{position:[-158,19.7],mag:4.6,depth:12,name:"Off Hawaii"},{position:[26.7,38.3],mag:4.2,depth:20,name:"Turkey Aegean"},{position:[-70.9,-33.5],mag:4.8,depth:60,name:"Chile Central"},{position:[170.1,-43.5],mag:4.9,depth:18,name:"South Island NZ"},{position:[93.2,28.1],mag:5.2,depth:24,name:"Assam"},{position:[-155.6,20.1],mag:4.3,depth:6,name:"Kilauea Summit"},{position:[122.7,-4.1],mag:5.6,depth:48,name:"Sulawesi"}
393],EF=[{id:"ingrid",name:"Tropical Storm Ingrid",cat:1,track:[[-78,15],[-80,17],[-82,19],[-85,22],[-90,26]]},{id:"rai",name:"Typhoon Rai",cat:3,track:[[128,10],[126,12],[123,13],[120,14],[118,16]]},{id:"freya",name:"Cyclone Freya",cat:2,track:[[88,-12],[90,-15],[92,-18],[96,-22],[102,-26]]}],kF=[{position:[121.5,31.2],name:"Shanghai",teuM:47.3,congestion:"HIGH"},{position:[103.85,1.29],name:"Singapore",teuM:37.4,congestion:"MEDIUM"},{position:[113.96,22.5],name:"Shenzhen",teuM:30,congestion:"MEDIUM"},{position:[114.13,22.3],name:"Hong Kong",teuM:16.8,congestion:"LOW"},{position:[126.64,37.5],name:"Busan",teuM:22.7,congestion:"MEDIUM"},{position:[4,51.92],name:"Rotterdam",teuM:14.5,congestion:"LOW"},{position:[-118.25,33.7],name:"Los Angeles",teuM:9.9,congestion:"HIGH"},{position:[-74.05,40.67],name:"New York/NJ",teuM:9.5,congestion:"MEDIUM"},{position:[55.03,24.92],name:"Jebel Ali",teuM:14.9,congestion:"LOW"},{position:[8.55,53.55],name:"Hamburg",teuM:8.5,congestion:"MEDIUM"}],CF=[{id:"bri_eu",name:"BRI — China to Europe",path:[[116.4,39.9],[105,41.5],[88,43.9],[65,50],[50,55],[37.6,55.8],[27.5,53.9],[13.4,52.5]]},{id:"transsib",name:"Trans-Siberian",path:[[37.6,55.8],[60.6,56.8],[82.9,55],[104.3,52.3],[126.7,51.8],[135,48.5],[131.9,43.1]]},{id:"nafta",name:"NAFTA Spine",path:[[-99.1,19.4],[-100.3,25.7],[-97.7,30.3],[-96.8,32.8],[-94.6,39.1],[-87.6,41.9],[-83,42.3]]},{id:"indian",name:"Indian DFC",path:[[77.2,28.6],[76.7,26.9],[72.8,19.1],[80.3,13.1]]}],AF=[{id:"marea",name:"MAREA",path:[[-77,36.8],[-50,40],[-20,40],[-9,43.4]]},{id:"asn1",name:"AAE-1",path:[[139.7,35.6],[118,22],[103.7,1.3],[80,6],[55,25],[32.5,30],[14.2,40.8]]},{id:"pccs",name:"Pacific Crossing",path:[[139.7,35.6],[-122.4,37.8]]},{id:"equiano",name:"Equiano",path:[[-9,38.7],[-16,28.4],[-15.7,10.8],[3.4,6.5],[18.4,-33.9]]}],jF=[{position:[90.4,23.7],weight:95,name:"Bangladesh Delta"},{position:[106.7,10.8],weight:85,name:"Mekong Delta"},{position:[31.2,30],weight:80,name:"Nile Delta"},{position:[-90,29],weight:75,name:"US Gulf Coast"},{position:[4.9,52.4],weight:70,name:"NL Polder"},{position:[-43.2,-22.9],weight:60,name:"Rio de Janeiro"},{position:[121.5,31.2],weight:70,name:"Shanghai Delta"}],wF=[{position:[77.2,28.6],weight:100,name:"Delhi NCR"},{position:[121.5,31.2],weight:98,name:"Shanghai Megacity"},{position:[72.8,19.1],weight:96,name:"Mumbai"},{position:[139.7,35.7],weight:95,name:"Tokyo Megacity"},{position:[106.8,-6.2],weight:90,name:"Jakarta"},{position:[90.4,23.7],weight:92,name:"Dhaka"},{position:[-99.1,19.4],weight:85,name:"Mexico City"},{position:[31.2,30],weight:80,name:"Cairo"},{position:[-46.6,-23.5],weight:78,name:"São Paulo"},{position:[-74,40.7],weight:82,name:"NYC Metro"}],TF=[{position:[-97,39],weight:100,name:"USA"},{position:[104,35],weight:90,name:"China"},{position:[10,51],weight:55,name:"Germany"},{position:[138,37],weight:45,name:"Japan"},{position:[78,22],weight:50,name:"India"},{position:[-2,54],weight:40,name:"UK"},{position:[2,47],weight:40,name:"France"},{position:[13,42],weight:30,name:"Italy"},{position:[-53,-10],weight:32,name:"Brazil"},{position:[133,-25],weight:25,name:"Aus"}],_F=[{position:[77.2,28.6],name:"New Delhi",aqi:255},{position:[104.1,30.7],name:"Chengdu",aqi:182},{position:[116.4,39.9],name:"Beijing",aqi:168},{position:[72.8,19.1],name:"Mumbai",aqi:156},{position:[-118.2,34.1],name:"Los Angeles",aqi:82},{position:[-74,40.7],name:"New York",aqi:54},{position:[2.35,48.86],name:"Paris",aqi:48},{position:[-.13,51.51],name:"London",aqi:44},{position:[151.2,-33.8],name:"Sydney",aqi:31},{position:[139.7,35.7],name:"Tokyo",aqi:38}],RF=[{position:[37.5,48.5],name:"Donbas briefing uptick",vel:95},{position:[34.44,31.35],name:"Gaza humanitarian track",vel:92},{position:[120.9,23.7],name:"TSMC capex leak",vel:78},{position:[-77,38.9],name:"Fed minutes speculation",vel:72},{position:[116.4,39.9],name:"PBOC liquidity rumour",vel:68},{position:[51.4,35.7],name:"JCPOA talks revived",vel:61},{position:[30.5,50.4],name:"Ukraine aid vote",vel:58}],FF=[{position:[-122,37.4],name:"AAPL — tgt ↑ to $240",firm:"MS",dir:"up"},{position:[-122.3,47.6],name:"MSFT — tgt ↑ to $510",firm:"GS",dir:"up"},{position:[121,24.8],name:"TSMC — tgt ↑ NT$1100",firm:"Bernstein",dir:"up"},{position:[9.5,48.4],name:"SAP — tgt ↑ to €230",firm:"JPM",dir:"up"},{position:[139.6,35.7],name:"TYO — downgrade 9432",firm:"Jefferies",dir:"down"},{position:[0,51.5],name:"Shell — tgt ↓ to 2850p",firm:"Barclays",dir:"down"}],IF=[{position:[-122,37.4],name:"AAPL — Form 4 sale",size:"$42M"},{position:[-122.4,47.6],name:"AMZN — Form 4 sale",size:"$120M"},{position:[121,24.8],name:"TSM — insider buy",size:"$8M"},{position:[9.5,48.4],name:"SAP — option exercise",size:"€14M"},{position:[-73.9,40.8],name:"MS — director buy",size:"$2M"}],DF=[{position:[103.85,1.29],name:"11,400 BTC → Coinbase",usd:"$720M"},{position:[-74,40.7],name:"320,000 ETH → Binance",usd:"$900M"},{position:[35.6,33.9],name:"USDT 200M mint",usd:"$200M"},{position:[114.2,22.3],name:"Wrapped BTC bridge",usd:"$150M"}],OF=[{position:[-97,31],name:"US Texas Hashrate",share:35},{position:[65,55],name:"Kazakhstan Hashrate",share:13},{position:[47,40],name:"CIS Cluster",share:11},{position:[117,40],name:"NE China (residual)",share:10},{position:[-71,-34],name:"LatAm Cluster",share:6},{position:[-66,45],name:"Canada — Quebec",share:5}],LF=[{position:[-77,38.9],name:"Coinbase US",vol24:"$4.2B"},{position:[4.9,52.4],name:"Bitstamp EU",vol24:"$0.5B"},{position:[55.3,25.2],name:"Binance HQ (Dubai)",vol24:"$18.0B"},{position:[103.85,1.29],name:"OKX / Bybit SGP",vol24:"$6.1B"},{position:[114.2,22.3],name:"Gate HK",vol24:"$1.8B"},{position:[139.7,35.7],name:"bitFlyer JP",vol24:"$0.3B"}],zF=[{position:[-118.25,34.05],name:"Uniswap Router",tvl:"$4.1B"},{position:[-74,40.7],name:"Curve Pools",tvl:"$1.9B"},{position:[8.6,50.1],name:"1inch EU",tvl:"$1.1B"},{position:[103.85,1.29],name:"PancakeSwap",tvl:"$2.4B"},{position:[139.7,35.7],name:"dYdX (StarkEx)",tvl:"$0.6B"}],MF=[{position:[-122,37.4],sym:"AAPL",delta:"+1.2%"},{position:[-122.3,47.6],sym:"MSFT",delta:"+0.8%"},{position:[121,24.8],sym:"TSM",delta:"+2.1%"},{position:[139.6,35.7],sym:"6758",delta:"-0.4%"},{position:[9.5,48.4],sym:"SAP",delta:"+0.6%"}],NF=[{position:[37.5,48.5],name:"ACLED — new conflict event",severity:"HIGH"},{position:[-77,38.9],name:"Fed speaker — hawkish",severity:"MEDIUM"},{position:[121,24.8],name:"TSMC — price target breach",severity:"MEDIUM"},{position:[34.44,31.35],name:"Gaza — shipping disruption",severity:"CRITICAL"}],BF=[{position:[-.08,51.51],name:"Project Meridian",stage:"Term sheet"},{position:[-74,40.7],name:"Atlas PE",stage:"DD"},{position:[103.85,1.29],name:"Riverside Asia",stage:"LOI"}],PF=[{kw:["pipeline","gas pipeline","natural gas","lng pipeline","gas route","gas infrastru
393cture"],layers:["gasPipelines","commodityPrices"],center:{lng:20,lat:52},zoom:4,pitch:45},{kw:["petrol","petroleum","oil pipeline","crude","crude oil","oil route","opec","brent","wti"],layers:["oilPipelines","commodityPrices","chokepoints"],center:{lng:48,lat:28},zoom:4,pitch:45},{kw:["energy","chokepoint","chokepoints","energy infrastructure","energy security"],layers:["gasPipelines","oilPipelines","lngRoutes","chokepoints","commodityPrices"],center:{lng:40,lat:30},zoom:3,pitch:45},{kw:["hormuz","strait of hormuz","iran strait"],layers:["oilPipelines","chokepoints"],center:{lng:56.25,lat:26.57},zoom:7,pitch:50},{kw:["suez","suez canal"],layers:["shipping","chokepoints"],center:{lng:32.35,lat:30.45},zoom:7,pitch:50},{kw:["malacca","strait of malacca"],layers:["shipping","chokepoints"],center:{lng:103.75,lat:1.25},zoom:7,pitch:50},{kw:["nord stream","nordstream","baltic pipeline"],layers:["gasPipelines"],center:{lng:16,lat:57},zoom:5,pitch:45},{kw:["conflict","war","military","geopolitical","hotspot","tension","sanctions"],layers:["conflicts","sanctions","military"],center:{lng:40,lat:35},zoom:3,pitch:40},{kw:["ukraine","kyiv","donbas","crimea","russia ukraine"],layers:["conflicts","sanctions","gasPipelines"],center:{lng:37.5,lat:48.5},zoom:5,pitch:45},{kw:["taiwan","tsmc","semiconductor","chip","taiwan strait"],layers:["conflicts","supplyChain"],center:{lng:120.9,lat:23.7},zoom:6,pitch:45},{kw:["yemen","houthi","red sea","bab el-mandeb"],layers:["conflicts","shipping","chokepoints"],center:{lng:44.2,lat:15.5},zoom:6,pitch:45},{kw:["portfolio","holdings","financial","wealth","finance"],layers:["portfolio","centralBanks","currency"],center:{lng:10,lat:48},zoom:4,pitch:40},{kw:["risk","threat","danger","critical","risk map","risk overlay"],layers:["riskHeatmap","conflicts","geological","chokepoints"],center:{lng:40,lat:30},zoom:3,pitch:35},{kw:["opportunity","invest","reward","growth","emerging"],layers:["opportunities","portfolio"],center:{lng:60,lat:20},zoom:3,pitch:35},{kw:["earthquake","seismic","volcano","geological","tectonic"],layers:["geological"],center:{lng:80,lat:20},zoom:3,pitch:30},{kw:["shipping","maritime","container","tanker","trade route"],layers:["shipping","chokepoints"],center:{lng:60,lat:20},zoom:3,pitch:40},{kw:["fbo","airport","aviation","private jet","jet","flight","charter"],layers:["aviation"],center:{lng:15,lat:45},zoom:3,pitch:40},{kw:["cyber","hack","apt","espionage","ransomware"],layers:["cyberThreats","military"],center:{lng:40,lat:40},zoom:3,pitch:30},{kw:["supply chain","semiconductor","manufacturing","port"],layers:["supplyChain","shipping"],center:{lng:110,lat:20},zoom:3,pitch:35},{kw:["weather","hurricane","typhoon","drought","monsoon","climate"],layers:["weather","shipping"],center:{lng:0,lat:20},zoom:2,pitch:30},{kw:["central bank","interest rate","fed","ecb","monetary policy"],layers:["centralBanks","currency"],center:{lng:0,lat:40},zoom:3,pitch:30},{kw:["all","everything","show all","full map","all layers","overview"],layers:"ALL",center:{lng:25,lat:25},zoom:2.5,pitch:45}],UF=[{q:"Global energy infrastructure",icon:"⚡",color:"#6B9AC4",cat:"ENERGY"},{q:"Gas pipelines Europe",icon:"⚡",color:"#6B9AC4",cat:"ENERGY"},{q:"Oil chokepoints",icon:"⚡",color:"#F59E0B",cat:"ENERGY"},{q:"Strait of Hormuz",icon:"⚡",color:"#F59E0B",cat:"ENERGY"},{q:"LNG shipping routes",icon:"⚡",color:"#5BA8A0",cat:"ENERGY"},{q:"Active conflict zones",icon:"⚠",color:"#D44040",cat:"GEO"},{q:"Ukraine conflict zone",icon:"⚠",color:"#C85C5C",cat:"GEO"},{q:"Taiwan semiconductor risk",icon:"⚠",color:"#C85C5C",cat:"GEO"},{q:"Red Sea shipping threat",icon:"⚠",color:"#C85C5C",cat:"GEO"},{q:"Sanctions map",icon:"⚠",color:"#D4AF5C",cat:"GEO"},{q:"Global risk heatmap",icon:"●",color:"#D44040",cat:"RISK"},{q:"Portfolio positions",icon:"◆",color:"#D4AF5C",cat:"FINANCE"},{q:"Investment opportunities",icon:"◆",color:"#3FB950",cat:"FINANCE"},{q:"Central bank rates",icon:"◆",color:"#FBBF24",cat:"FINANCE"},{q:"Earthquake zones",icon:"●",color:"#C85C5C",cat:"ENV"},{q:"Shipping lanes",icon:"✈",color:"#60A5FA",cat:"TRANSPORT"}
393,{q:"Cyber threat map",icon:"●",color:"#C85C5C",cat:"CYBER"},{q:"Supply chain nodes",icon:"■",color:"#C89850",cat:"SUPPLY"},{q:"Military bases",icon:"■",color:"#6366F1",cat:"GEO"},{q:"Show everything",icon:"◉",color:"#D4AF5C",cat:"ALL"}],WF=6371;function Of(t,n,r,o){var a=(r-t)*Math.PI/180,l=(o-n)*Math.PI/180,s=Math.sin(a/2)*Math.sin(a/2)+Math.cos(t*Math.PI/180)*Math.cos(r*Math.PI/180)*Math.sin(l/2)*Math.sin(l/2);return 2*WF*Math.asin(Math.min(1,Math.sqrt(s)))}function GE(t,n,r){for(var o=1/0,a=0;a<(r||[]).length;a++){var l=r[a],s=Of(t,n,l[1],l[0]);s<o&&(o=s)}return o}function H0(t,n,r,o,a,l){var s=[];return(r||[]).forEach(function(c){if(!(!c||!c.position)){var d=Of(t,n,c.position[1],c.position[0]);d<=o&&s.push({name:c.name,km:Math.round(d),kind:l,risk:c.risk||null})}}),s.sort(function(c,d){return c.km-d.km}),s.slice(0,a)}function HF(t,n,r,o,a,l){var s=[];return(r||[]).forEach(function(c){if(!(!c||!c.path)){var d=GE(t,n,c.path);d<=o&&s.push({name:c.name,km:Math.round(d),kind:l,status:c.status||null})}}),s.sort(function(c,d){return c.km-d.km}),s.slice(0,a)}function VE(t,n,r){var o=r||500,a=[];return(HE||[]).forEach(function(l){if(!(!l||!l.polygon)){var s=GE(t,n,l.polygon);s<=o&&a.push({name:l.name,km:Math.round(s),kind:"sanctions",regimes:l.regimes||[]})}}),a.sort(function(l,s){return l.km-s.km}),{radius_km:o,chokepoints:H0(t,n,nc,o,3,"chokepoint"),refineries:H0(t,n,cx,o,3,"refinery"),pipelines:HF(t,n,(Ug||[]).concat(Wg||[]),o,3,"pipeline"),conflicts:H0(t,n,id,o,3,"conflict"),sanctions:a.slice(0,3),supply_chain:H0(t,n,Hg,o,3,"supply-chain")}}var GF={chokepoint:"#FF5050",refinery:"#FB923C",pipeline:"#38BDF8",conflict:"#DC2626","supply-chain":"#F97316"};function VF(t,n,r,o,a,l){var s=[];return(r||[]).forEach(function(c){if(!(!c||!c.path)){for(var d=1/0,p=null,g=0;g<c.path.length;g++){var f=c.path[g],h=Of(t,n,f[1],f[0]);h<d&&(d=h,p=f)}p&&d<=o&&s.push({name:c.name,km:Math.round(d),kind:l,lat:p[1],lng:p[0],status:c.status||null})}}),s.sort(function(c,d){return c.km-d.km}),s.slice(0,a)}function YE(t,n,r,o){var a=r||500,l=o||8,s=[];function c(d,p){(d||[]).forEach(function(g){if(!(!g||!g.position)){var f=Of(t,n,g.position[1],g.position[0]);f<=a&&s.push({name:g.name,km:Math.round(f),kind:p,lat:g.position[1],lng:g.position[0],risk:g.risk||null})}})}return c(nc,"chokepoint"),c(cx,"refinery"),c(id,"conflict"),c(Hg,"supply-chain"),s=s.concat(VF(t,n,(Ug||[]).concat(Wg||[]),a,3,"pipeline")),s.sort(function(d,p){return d.km-p.km}),s=s.slice(0,l),s.forEach(function(d){d.color=GF[d.kind]||"#8898A8"}),s}function KE(t){var n=[];return["chokepoints","refineries","pipelines","conflicts","sanctions","supply_chain"].forEach(function(r){(t[r]||[]).forEach(function(o){n.push("- "+o.kind+": "+o.name+" (~"+o.km+" km)"+(o.risk?", risk "+o.risk:"")+(o.status?", status "+o.status:""))})}),n.length?n.join(`
394`):"- none of Xyron's tracked assets within "+t.radius_km+" km"}function XE(t){var n=t||{},r=VE(n.lat,n.lng,500);return"Prepare an institutional location dossier for: "+(n.address||"the pinned location")+" ("+Number(n.lat).toFixed(4)+", "+Number(n.lng).toFixed(4)+`).
395Xyron tracked assets near this location (curated intel geometry, distances approximate):
396`+KE(r)+`
397Structure the brief as: LOCATION — one-line summary; INFRASTRUCTURE EXPOSURE — what the nearby tracked assets mean for this location; JURISDICTION & SANCTIONS — regime exposure, use the sanctions proximity above plus what you know; MARKET ACCESS — nearest venues/logistics; RISKS — top 3, ranked; OPPORTUNITIES — top 2. Be specific and concise; institutional tone; do not invent assets beyond the list and well-known facts.`}function YF(t){return`Compare these sites as an institutional analyst. For each, Xyron's tracked assets nearby:
398
399`+(t||[]).slice(0,5).map(function(n,r){var o=VE(n.lat,n.lng,500);return"SITE "+(r+1)+": "+(n.label||n.lat.toFixed(3)+", "+n.lng.toFixed(3))+`
400`+KE(o)}).join(`
401
402`)+`
403
404Produce a concise comparison matrix (markdown table) across: infrastructure exposure, jurisdiction/sanctions risk, logistics/market access, overall risk tier. Then a 2-sentence recommendation. Do not invent assets beyond the lists.`}function qE({pins:t}){return!t||!t.length?null:(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:2,marginTop:3},children:[(0,e.jsx)("span",{style:{fontFamily:vr,fontSize:8,fontWeight:700,color:vt.t4,letterSpacing:".14em"},children:"NEARBY XYRON INTEL"}),t.slice(0,3).map(function(n,r){return(0,e.jsxs)("span",{style:{fontFamily:vr,fontSize:9,color:vt.t3,letterSpacing:".04em",display:"flex",alignItems:"center",gap:5},children:[(0,e.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:n.color,display:"inline-block",flexShrink:0}}),n.name," — ",n.kind.toUpperCase()," · ",n.km," KM",n.risk?" · "+n.risk:""]},r)})]})}function mg(t){try{window.dispatchEvent(new CustomEvent("xyron:ask-chat",{detail:{prompt:t,drawer:"map"}}))}catch{}}var $E=typeof import.meta<"u"&&"AIzaSyBi4y8FSk1LUcuNzI9GkPCdf3Veh_Vf__E"||"",s1=[{elementType:"geometry",stylers:[{color:"#0a0f1a"}]},{elementType:"labels.text.stroke",stylers:[{color:"#0a0f1a"}]},{elementType:"labels.text.fill",stylers:[{color:"#8898A8"}]},{featureType:"administrative",elementType:"geometry.stroke",stylers:[{color:"#1c2740"}]},{featureType:"administrative.country",elementType:"geometry.stroke",stylers:[{color:"#2A3548"}]},{featureType:"road",elementType:"geometry",stylers:[{color:"#141e2a"}]},{featureType:"road",elementType:"labels.text.fill",stylers:[{color:"#5A6878"}]},{featureType:"water",elementType:"geometry",stylers:[{color:"#12314a"}]},{featureType:"water",elementType:"labels.text.fill",stylers:[{color:"#6f8faa"}]},{featureType:"poi",elementType:"labels.text.fill",stylers:[{color:"#5A6878"}]},{featureType:"poi",elementType:"geometry",stylers:[{color:"#0d1520"}]},{featureType:"transit",elementType:"labels.text.fill",stylers:[{color:"#5A6878"}]},{featureType:"landscape",elementType:"geometry",stylers:[{color:"#0d1520"}]}];function KF(){return typeof window>"u"?Promise.reject(new Error("no window")):window.google&&window.google.maps&&window.google.maps.Map?Promise.resolve(window.google.maps):(window.__xyronGmapsPromise||(window.__xyronGmapsPromise=new Promise(function(t,n){var r="__xyronGmapsReady";window[r]=function(){t(window.google.maps)};var o=document.createElement("script");
404o.src="https://maps.googleapis.com/maps/api/js?key="+encodeURIComponent($E)+"&v=weekly&libraries=geometry&callback="+r,o.async=!0,o.onerror=function(){n(new Error("Maps JS failed to load"))},document.head.appendChild(o)})),window.__xyronGmapsPromise)}function by(t){var n=t||{};return Array.isArray(n.markers)&&n.markers.length?n.markers.filter(function(r){return r&&isFinite(r.lat)&&isFinite(r.lng)}):isFinite(n.lat)&&isFinite(n.lng)?[{lat:n.lat,lng:n.lng,label:n.address||"",anchor:!0}]:[]}var ql=function(t){return{padding:"2px 7px",background:t?(vt.amber||"#D4AF5C")+"22":"transparent",border:"1px solid "+(t?(vt.amber||"#D4AF5C")+"66":vt.line||"#1C2740"),borderRadius:3,cursor:"pointer",fontFamily:vr,fontSize:9,fontWeight:700,color:t?vt.amber||"#D4AF5C":vt.t3,letterSpacing:".08em"}};function XF({artifact:t}){return t&&t.payload&&t.payload.private||!$E?(0,e.jsx)(QF,{artifact:t}):(0,e.jsx)(qF,{artifact:t})}function qF({artifact:t}){var n=t&&t.payload||{},r=by(n),o=(0,i.useRef)(null),a=(0,i.useRef)(null),l=(0,i.useRef)(null),s=(0,i.useState)(null),c=s[0],d=s[1],p=(0,i.useState)(!1),g=p[0],f=p[1],h=(0,i.useState)(!1),x=h[0],v=h[1],y=(0,i.useState)(!1),k=y[0],A=y[1],j=(0,i.useState)(null),E=j[0],C=j[1],_=(0,i.useState)(null),w=_[0],O=_[1];function M(){mg(XE(n))}function U(){mg(YF(r))}var ee=r.length?YE(r[0].lat,r[0].lng,500,8):[],N=(0,i.useState)(!0),V=N[0],z=N[1],oe=(0,i.useRef)([]);function P(){w==="saving"||w==="ok"||(O("saving"),Promise.resolve().then(function(){return fetch(qr("/api/map/watch"),{method:"POST",headers:fo(),body:JSON.stringify({lat:r[0].lat,lng:r[0].lng,label:n.address||t.title||"Pinned location",radius_km:50})})}).then(function(R){return R&&R.ok?R.json():null}).then(function(R){O(R&&R.ok?"ok":"err")}).catch(function(){O("err")}))}if((0,i.useEffect)(function(){var R=t&&t.payload||{},ae=by(R);if(!(!ae.length||!o.current)){var q=!1,ge=[];return KF().then(function(X){if(!(q||!o.current)){var de=new X.Map(o.current,{center:{lat:ae[0].lat,lng:ae[0].lng},zoom:ae.length===1?12:11,styles:s1,backgroundColor:"#0a0f1a",zoomControl:!0,mapTypeControl:!1,streetViewControl:!0,fullscreenControl:!0,gestureHandling:"greedy"});a.current=de;var We={lat:ae[0].lat,lng:ae[0].lng};[200,700,1600].forEach(function(ve){ge.push(setTimeout(function(){if(!(q||!a.current))try{X.event.trigger(de,"resize"),ae.length===1&&de.setCenter(We)}catch{}},ve))});var te=new X.LatLngBounds;if(ae.forEach(function(ve,Ne){var $e=ve.anchor||Ne===0;new X.Marker({map:de,position:{lat:ve.lat,lng:ve.lng},title:ve.label||"",icon:{path:X.SymbolPath.CIRCLE,scale:$e?8:5.5,fillColor:$e?vt.amber||"#D4AF5C":vt.t3||"#8898A8",fillOpacity:1,strokeColor:"#0a0f1a",strokeWeight:2}}),te.extend({lat:ve.lat,lng:ve.lng})}),R.polyline&&X.geometry&&X.geometry.encoding)try{var _e=X.geometry.encoding.decodePath(R.polyline);new X.Polyline({map:de,path:_e,strokeColor:vt.amber||"#D4AF5C",strokeOpacity:.9,strokeWeight:3}),_e.forEach(function(ve){te.extend(ve)})}catch{}(ae.length>
4041||R.polyline)&&de.fitBounds(te,40)}}).catch(function(X){d(X.message||"Maps failed to load")}),function(){q=!0,a.current=null,ge.forEach(function(X){clearTimeout(X)})}}},[t,d]),(0,i.useEffect)(function(){var R=a.current;if(!(!R||!window.google)){var ae=window.google.maps;g&&!l.current?(l.current=new ae.TrafficLayer,l.current.setMap(R)):!g&&l.current&&(l.current.setMap(null),l.current=null)}},[g]),(0,i.useEffect)(function(){var R=a.current;R&&(R.setMapTypeId(k?"hybrid":"roadmap"),R.setOptions({styles:k?null:s1}))},[k]),(0,i.useEffect)(function(){var R=window.google&&window.google.maps,ae=a.current;if(oe.current.forEach(function(ge){ge.setMap(null)}),oe.current=[],!(!R||!ae||!V||!ee.length)){var q=new R.InfoWindow;return ee.forEach(function(ge){var X=new R.Marker({map:ae,position:{lat:ge.lat,lng:ge.lng},title:ge.name+" ("+ge.kind+", "+ge.km+" km)",icon:{path:R.SymbolPath.CIRCLE,scale:4.5,fillColor:ge.color,fillOpacity:.95,strokeColor:"#0a0f1a",strokeWeight:1.5}});X.addListener("click",function(){q.setContent('<div style="font-family:monospace;font-size:11px;color:#1a2330;min-width:160px"><b>'+ge.name+"</b><br/>"+ge.kind.toUpperCase()+" · "+ge.km+" KM AWAY"+(ge.risk?"<br/>RISK: "+ge.risk:"")+"</div>"),q.open({map:ae,anchor:X})}),oe.current.push(X)}),function(){oe.current.forEach(function(ge){ge.setMap(null)}),oe.current=[]}}},[V,c,t]),(0,i.useEffect)(function(){if(n.place_id){var R=!1;return Promise.resolve().then(function(){return fetch(qr("/api/map/place/"+encodeURIComponent(n.place_id)),{headers:fo()})}).then(function(ae){return ae&&ae.ok?ae.json():null}).then(function(ae){!R&&ae&&ae.status==="ok"&&ae.place&&C(ae.place)}).catch(function(ae){}),function(){R=!0}}},[n.place_id,C]),!r.length)return null;var W=n.distance_km!=null?(n.mode||"DRIVE")+" · "+n.distance_km+" KM · ~"+n.duration_min+" MIN":null;return(0,e.jsxs)("div",{style:{marginTop:6,border:"1px solid "+(vt.line||"#1C2740"),borderRadius:8,overflow:"hidden",background:vt.bg2||"#0A0E16"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 10px",borderBottom:"1px solid "+(vt.line||"#1C2740"),gap:8},children:[(0,e.jsx)("span",{style:{fontFamily:vr,fontSize:9,fontWeight:700,color:vt.t2,letterSpacing:".12em",textTransform:"uppercase",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.title||"LOCATION"}),(0,e.jsxs)("div",{style:{display:"flex",gap:4,flexShrink:0},children:[ee.length?(0,e.jsxs)("button",{onClick:function(){z(!V)},title:"Toggle Xyron tracked-asset pins around this location",style:ql(V),children:["INTEL ",ee.length]}):null,(0,e.jsxs)("button",{onClick:M,title:"AI location dossier grounded in Xyron tracked assets",style:ql(!1),children:["⌖"," DOSSIER"]}),(0,e.jsx)("button",{onClick:function(){mg("Private lookup (do not use Google): "+(n.address||t.title||""))},title:"Re-resolve this location on the Xyron private lane — no Google services",style:ql(!1),children:"PRIVATE"}),r.length>1?(0,e.jsx)("button",{onClick:U,title:"AI comparison matrix across the pinned sites",style:ql(!1),children:"COMPARE"}):null,(0,e.jsxs)("button",{onClick:P,title:"Create a geofenced Sentinel watch at this location",style:ql(w==="ok"),children:["⚑"," ",w==="ok"?"WATCHING":w==="saving"?"SAVING…":w==="err"?"RETRY WATCH":"WATCH"]}),(0,e.jsx)("button",{onClick:function(){A(!k)},style:ql(k),children:"SAT"}),(0,e.jsx)("button",{onClick:function(){f(!g)},style:ql(g),children:"TRAFFIC"}),(0,e.jsx)("button",{onClick:function(){v(!x)},style:ql(x),children:x?"COLLAPSE":"EXPAND"})]})]}),(0,e.jsx)("div",{style:{height:x?480:260,position:"relative",transition:"height .18s ease"},children:c?(0,e.jsxs)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:vr,fontSize:9,color:vt.t4},children:["MAP UNAVAILABLE — ",String(c)]}):(0,e.jsx)("div",{ref:o,style:{width:"100%",height:"100%"}})}),(0,e.jsxs)("div",{style:{padding:"7px 10px",display:"flex",flexDirection:"column",gap:3},children:[W?(0,e.jsx)("span",{style:{fontFamily:vr,fontSize:10,fontWeight:700,color:vt.amber,letterSpacing:".08em"},children:W}):null,E&&E.name?(0,e.jsxs)("span",{style:{fontFamily:Tf,fontSize:12,fontWeight:600,color:vt.t1,lineHeight:1.4},children:[E.name,E.rating!=null?(0,e.jsxs)("span",{style:{fontFamily:vr,fontSize:10,
404color:vt.amber,marginLeft:8},children:["★ ",E.rating,E.user_ratings_total?" ("+E.user_ratings_total+")":""]}):null]}):null,n.address?(0,e.jsx)("span",{style:{fontFamily:Tf,fontSize:11,color:vt.t1,lineHeight:1.4},children:n.address}):null,(0,e.jsx)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:isFinite(n.lat)&&isFinite(n.lng)?(0,e.jsxs)("span",{style:{fontFamily:vr,fontSize:9,color:vt.t4,letterSpacing:".06em"},children:[Number(n.lat).toFixed(6),", ",Number(n.lng).toFixed(6),r.length>1?" · "+r.length+" PINS":""]}):(0,e.jsx)("span",{})}),(0,e.jsx)(qE,{pins:V?ee:[]})]})]})}var $F=Gn&&Gn.name==="Arenberg"?"/maps/arenberg-dark.json":"/maps/dark-matter.json",bh=null,Sh=null;function JF(t){if(t.length===1)return{longitude:t[0].lng,latitude:t[0].lat,zoom:13.5};var n=t.map(function(p){return p.lat}),r=t.map(function(p){return p.lng}),o=Math.min.apply(null,n),a=Math.max.apply(null,n),l=Math.min.apply(null,r),s=Math.max.apply(null,r),c=Math.max(a-o,s-l,.005),d=Math.max(2,Math.min(14,Math.log2(360/c)-1));return{longitude:(l+s)/2,latitude:(o+a)/2,zoom:d}}function QF({artifact:t}){var n=t&&t.payload||{},r=!!n.private,o=by(n),a=o.length?YE(o[0].lat,o[0].lng,500,8):[],l=(0,i.useState)(!0),s=l[0],c=l[1],d=(0,i.useState)(null),p=d[0],g=d[1];function f(){p==="saving"||p==="ok"||!o.length||(g("saving"),Promise.resolve().then(function(){return fetch(qr("/api/map/watch"),{method:"POST",headers:fo(),body:JSON.stringify({lat:o[0].lat,lng:o[0].lng,label:n.address||t.title||"Pinned location",radius_km:50})})}).then(function(E){return E&&E.ok?E.json():null}).then(function(E){g(E&&E.ok?"ok":"err")}).catch(function(){g("err")}))}var h=(0,i.useState)(!1),x=h[0],v=h[1],y=(0,i.useState)(null),k=y[0],A=y[1];if((0,i.useEffect)(function(){xi(()=>import("./vendor-C44JUHxF.js").then(E=>E.o).then(function(E){bh=E.Map||E.default,Sh=E.Marker,v(!0)}),__vite__mapDeps([0,1,2])).catch(function(E){A(E.message||"Failed to load map module")})},[v,A]),!o.length)return null;var j=JF(o);return(0,e.jsxs)("div",{style:{marginTop:6,border:"1px solid "+(vt.line||"#1C2740"),borderRadius:8,overflow:"hidden",background:vt.bg2||"#0A0E16"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 10px",borderBottom:"1px solid "+(vt.line||"#1C2740")},children:[(0,e.jsx)("span",{style:{fontFamily:vr,fontSize:9,fontWeight:700,color:vt.t2,letterSpacing:".12em",textTransform:"uppercase"},children:t.title||"LOCATION"}),(0,e.jsxs)("div",{style:{display:"flex",gap:4,alignItems:"center",flexShrink:0},children:[a.length?(0,e.jsxs)("button",{onClick:function(){c(!s)},title:"Toggle Xyron tracked-asset pins around this location",style:ql(s),children:["INTEL ",a.length]}):null,(0,e.jsxs)("button",{onClick:f,title:"Create a geofenced Sentinel watch at this location",style:ql(p==="ok"),children:["⚑"," ",p==="ok"?"WATCHING":p==="saving"?"SAVING…":p==="err"?"RETRY WATCH":"WATCH"]}),r?(0,e.jsxs)("span",{style:{fontFamily:vr,fontSize:9,fontWeight:700,color:vt.amber,letterSpacing:".12em"},children:["◆"," XYRON PRIVATE"]}):null]})]}),(0,e.jsx)("div",{style:{height:240,position:"relative"},children:k?(0,e.jsxs)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:vr,fontSize:9,color:vt.t4},children:["MAP UNAVAILABLE — ",String(k)]}):x&&bh?(0,e.jsxs)(bh,{initialViewState:j,mapStyle:$F,style:{width:"100%",height:"100%"},attributionControl:!1,children:[s?a.map(function(E,C){return(0,e.jsx)(Sh,{longitude:E.lng,latitude:E.lat,anchor:"center",children:(0,e.jsx)("div",{title:E.name+" ("+E.kind+", "+E.km+" km)",style:{width:9,height:9,borderRadius:"50%",background:E.color,border:"1.5px solid #0a0f1a",cursor:"help"}})},"ip"+C)}):null,o.map(function(E,C){var _=E.anchor||C===0;return(0,e.jsx)(Sh,{longitude:E.lng,latitude:E.lat,anchor:"bottom",children:(0,e.jsx)("div",{title:E.label||"",style:{width:_?14:10,height:10,borderRadius:"50% 50% 50% 0",transform:"rotate(-45deg)",background:_?vt.amber||"#D4AF5C":vt.t3||"#8898A8",border:"2px solid "+(vt.bg2||"#0A0E16"),boxShadow:"0 0 6px rgba(0,0,0,.5)"}})},C)})]}):(0,e.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:vr,fontSize:9,color:vt.t4},children:"LOADING MAP…"})}),n.address?(0,e.jsxs)("div",{style:{padding:"7px 10px",display:"flex",flexDirection:"column",gap:2},children:[r?(0,e.jsx)("div",{style:{display:"flex",gap:4,marginBottom:2},children:(0,e.jsxs)("button",{onClick:function(){mg(XE(n))},title:"AI location dossier grounded in Xyron tracked assets",style:ql(!1),children:["⌖"," DOSSIER"]})}):null,(0,e.jsx)("span",{style:{fontFamily:Tf,fontSize:11,color:vt.t1,lineHeight:1.4},children:n.address}),isFinite(n.lat)&&isFinite(n.lng)?(0,e.jsxs)("span",{style:{fontFamily:vr,fontSize:9,color:vt.t4,letterSpacing:".06em"},children:[Number(n.lat).toFixed(6),", ",Number(n.lng).toFixed(6),o.length>1?" · "+o.length+" PINS":"",r?" · © OpenStreetMap contributors":""]}):null,(0,e.jsx)(qE,{pins:s?a:[]})]}):null]})}function ZF({artifact:t}){return t?(c1[t.kind||"file"]||c1.file)(t):null}var c1={location_card:function(t){return(0,e.jsx)(XF,{artifact:t})},signal_card:function(t){return(0,e.jsx)(eI,{artifact:t})},synth_signal_card:function(t){return(0,e.jsx)(lI,{artifact:t})},news_feed:function(t){return(0,e.jsx)(sI,{artifact:t})},donut:function(t){return(0,e.jsx)(cI,{artifact:t})},calendar_strip:function(t){return(0,e.jsx)(uI,{artifact:t})},gauge:function(t){return(0,e.jsx)(hI,{artifact:t})},heatmap:function(t){return(0,e.jsx)(xI,{artifact:t})},curve:function(t){return(0,e.jsx)(vI,{artifact:t})},order_card:function(t){return(0,e.jsx)(bI,{artifact:t})},bullets:function(t){return(0,e.jsx)(SI,{artifact:t})},chips:function(t){return(0,e.jsx)(EI,{artifact:t})},alerts:function(t){return(0,e.jsx)(kI,{artifact:t})},chart:function(t){const n=t.title||"Computed chart",r=t.mime||"image/png",o=t.payload&&(t.payload.symbol||t.payload.ticker)||"";
404if(o){const a=t.payload&&t.payload.interval||"1day",l=t.payload&&t.payload.outputsize||90;return(0,e.jsx)("div",{style:{marginTop:4},children:(0,e.jsx)(WS,{chart:{type:"candle",title:t.payload&&t.payload.headline||n,xLabel:"Date",yLabel:"Price",data:[],symbol:o},symbol:o,interval:a,outputsize:l})})}if(t.data_b64){const a="data:"+r+";base64,"+t.data_b64;return(0,e.jsxs)("figure",{style:ii.figure,children:[(0,e.jsx)("img",{src:a,alt:n,style:ii.img}),(0,e.jsx)("figcaption",{style:ii.caption,children:n})]})}return(0,e.jsx)("div",{style:ii.figure,children:(0,e.jsxs)("em",{style:ii.caption,children:["Computed: ",n," (no preview)"]})})},table:function(t){const n=t.title||"table",r=Array.isArray(t.rows)?t.rows:[];if(!r.length)return(0,e.jsx)("div",{style:ii.figure,children:(0,e.jsxs)("em",{style:ii.caption,children:[n," (empty)"]})});const o=r.slice(0,30),a=Object.keys(o[0]||{});return(0,e.jsxs)("div",{style:ii.figure,children:[(0,e.jsx)("div",{style:ii.caption,children:n}),(0,e.jsx)("div",{style:{overflowX:"auto"},children:(0,e.jsxs)("table",{style:ii.table,children:[(0,e.jsx)("thead",{children:(0,e.jsx)("tr",{children:a.map(function(l){return(0,e.jsx)("th",{style:ii.th,children:l},l)})})}),(0,e.jsx)("tbody",{children:o.map(function(l,s){return(0,e.jsx)("tr",{children:a.map(function(c){return(0,e.jsx)("td",{style:ii.td,children:String(l[c]!=null?l[c]:"")},c)})},s)})})]})}),r.length>30?(0,e.jsxs)("div",{style:ii.caption,children:["(showing first 30 of ",r.length," rows)"]}):null]})},file:function(t){const n=t.title||"artifact",r=t.mime||"application/octet-stream";if(t.data_b64){const o="data:"+r+";base64,"+t.data_b64;return(0,e.jsx)("div",{style:ii.figure,children:(0,e.jsxs)("a",{href:o,download:jI(n,r),style:ii.dl,children:["Download ",n]})})}return(0,e.jsx)("div",{style:ii.figure,children:(0,e.jsxs)("em",{style:ii.caption,children:[n," (no preview)"]})})}};function eI({artifact:t}){const n=t.payload||{},r=n.symbol||t.title||"—",o=n.asset_class,a=n.coverage||"none",l=n.calibration||"structural",s=n.regime,c=Array.isArray(n.warnings)?n.warnings:[],d=n.day_trade||{},p=n.short_term||{},g=n.long_term||{};if((d.stance||"NO_SIGNAL")==="NO_SIGNAL"&&(p.stance||"NO_SIGNAL")==="NO_SIGNAL"&&(g.stance||"NO_SIGNAL")==="NO_SIGNAL"&&a!=="synth"&&n.suppress_if_empty===!0)return null;const f=n.synthesis||null,h=a==="synth"||!!f;return(0,e.jsxs)("div",{style:Object.assign({},qe.card,h?qe.cardSynth:null),children:[(0,e.jsxs)("div",{style:qe.header,children:[(0,e.jsxs)("div",{style:qe.headerLeft,children:[(0,e.jsx)("span",{style:qe.headerLabel,children:h?"SIGNAL · SYNTH":"SIGNAL"}),(0,e.jsx)("span",{style:qe.headerSymbol,children:r}),o?(0,e.jsx)("span",{style:qe.headerAssetClass,children:String(o).toUpperCase()}):null]}),(0,e.jsx)("div",{style:qe.headerRight,children:(0,e.jsx)(aI,{coverage:a})})]}),(0,e.jsxs)("div",{style:qe.row,children:[(0,e.jsx)(Eh,{label:"DAY TRADE",bucket:n.day_trade,calibration:l}),(0,e.jsx)(Eh,{label:"SHORT TERM",bucket:n.short_term,calibration:l}),(0,e.jsx)(Eh,{label:"LONG TERM",bucket:n.long_term,calibration:l})]}),f?(0,e.jsx)(tI,{synth:f}):null,(0,e.jsxs)("div",{style:qe.footer,children:[(0,e.jsxs)("span",{style:qe.footerItem,children:["regime: ",(0,e.jsx)("span",{style:qe.footerValue,children:s&&s.label?s.label:"—"})]}),(0,e.jsxs)("span",{style:qe.footerItem,children:["calibration: ",(0,e.jsx)("span",{style:qe.footerValue,children:l})]}),n.as_of?(0,e.jsxs)("span",{style:qe.footerItem,children:["as_of: ",(0,e.jsx)("span",{style:qe.footerValue,children:Jp(n.as_of)})]}):null]}),c.length?(0,e.jsx)("div",{style:qe.warnings,children:c.map(function(x){return(0,e.jsx)("span",{style:qe.warning,children:JE(x)},x)})}):null]})}function tI({synth:t}){if(!t)return null;const n=t.lean||"balanced",r=t.conviction||"low",o=t.lean_glyph||"→",a=t.rationale||"",l=Array.isArray(t.evidence)?t.evidence:[];return(0,e.jsxs)("div",{style:qe.synthStrip,children:[(0,e.jsxs)("div",{style:qe.synthHeader,children:[(0,e.jsx)("span",{style:qe.synthBadge,children:"SYNTH · LLM"}),(0,e.jsxs)("span",{style:qe.synthLean,children:[o," ",n]}),(0,e.jsxs)("span",{style:qe.synthConv,children:["conviction: ",r]})]}),a?(0,e.jsx)("div",{style:qe.synthRationale,children:a}):null,l.length?(0,e.jsxs)("div",{style:qe.synthEvidence,children:[(0,e.jsx)("span",{style:qe.synthEvidence
404Label,children:"evidence:"}),l.slice(0,6).map(function(s,c){return(0,e.jsxs)("span",{style:qe.synthEvidenceItem,children:[(0,e.jsx)("code",{style:qe.synthEvidenceTool,children:s.tool}),(0,e.jsx)("span",{style:qe.synthEvidenceFinding,children:s.key_finding})]},c)})]}):null]})}function Eh({label:t,bucket:n,calibration:r}){const o=n||{},a=o.stance||"NO_SIGNAL",l=o.view||"NO_SIGNAL",s=typeof o.conviction=="number"?o.conviction:0,c=o.status||"none",d=o.horizon_window||"—",p=o.horizon_raw||null,g=o.producer,f=o.rationale||null,h=a==="NO_SIGNAL";return(0,e.jsxs)("div",{style:Object.assign({},qe.col,h?qe.colEmpty:null),title:f||void 0,children:[(0,e.jsx)("div",{style:qe.colLabel,children:t}),(0,e.jsxs)("div",{style:qe.colHorizon,children:[d,p?" · "+p:""]}),(0,e.jsxs)("div",{style:qe.stanceRow,children:[(0,e.jsx)(nI,{stance:a}),(0,e.jsx)(rI,{view:l})]}),(0,e.jsx)(iI,{value:s,calibration:r,empty:h}),(0,e.jsxs)("div",{style:qe.metaRow,children:[(0,e.jsx)(oI,{status:c}),g?(0,e.jsx)("span",{style:qe.producer,children:g}):null]}),f?(0,e.jsx)("div",{style:qe.colRationale,children:f}):null]})}function nI({stance:t}){const n=x1[t]||x1.NO_SIGNAL;return(0,e.jsx)("span",{style:Object.assign({},qe.pill,{background:n.bg,color:n.fg,borderColor:n.border}),children:t})}function rI({view:t}){const n=v1[t]||v1.NO_SIGNAL;return(0,e.jsx)("span",{style:{color:n.fg,fontFamily:"monospace",fontSize:13,fontWeight:700,letterSpacing:".06em"},children:n.symbol})}function iI({value:t,calibration:n,empty:r}){const o=Math.max(0,Math.min(1,Number(t)||0))*100;return(0,e.jsxs)("div",{style:qe.barWrap,children:[(0,e.jsxs)("div",{style:qe.barLabelRow,children:[(0,e.jsx)("span",{style:qe.barLabel,children:"conviction"}),(0,e.jsx)("span",{style:qe.barValue,children:r?"—":o.toFixed(0)+"%"})]}),(0,e.jsx)("div",{style:qe.barTrack,children:(0,e.jsx)("div",{style:Object.assign({},qe.barFill,{width:o+"%",background:r?"#1c2230":n==="empirical"?"#4DA882":"#D4AF5C"})})}),(0,e.jsx)("div",{style:qe.calLabel,children:n==="empirical"?"empirical (calibrated)":"structural (ensemble agreement)"})]})}function oI({status:t}){const n=b1[t]||b1.none;return(0,e.jsx)("span",{style:Object.assign({},qe.statusChip,{background:n.bg,color:n.fg,borderColor:n.border}),children:t})}function aI({coverage:t}){const n=S1[t]||S1.none;return(0,e.jsxs)("span",{style:Object.assign({},qe.coverage,{background:n.bg,color:n.fg,borderColor:n.border}),children:["coverage · ",t]})}var d1={"long-bias":{color:"#3FB950",glyph:"▲"},"short-bias":{color:"#F85149",glyph:"▼"},balanced:{color:"#8B949E",glyph:"≈"}},u1={low:{bg:"rgba(139,148,158,0.10)",border:"rgba(139,148,158,0.40)",color:"#8B949E"},moderate:{bg:"rgba(212,175,92,0.10)",border:"rgba(212,175,92,0.45)",color:"#D4AF5C"},high:{bg:"rgba(63,185,80,0.10)",border:"rgba(63,185,80,0.45)",color:"#3FB950"}},f1=Jg;function lI({artifact:t}){const n=t.payload||{},r=n.symbol||"—",o=n.lean||"balanced",a=n.conviction||"low",l=(n.horizon||"multi_horizon").replace(/_/g," "),s=n.rationale||"",c=Array.isArray(n.evidence)?n.evidence:[],d=Array.isArray(n.warnings)?n.warnings:[],p=d1[o]||d1.balanced,g=u1[a]||u1.low,f=(function(){try{return typeof window<"u"&&window.localStorage.getItem(f1)==="1"}catch{return!0}})(),h=i.useState(f),x=h[0],v=h[1];function y(){try{window.localStorage.setItem(f1,"1")}catch{}zy({synth_onboarded:!0}),v(!0)}return(0,e.jsxs)("div",{style:Gi.card,children:[(0,e.jsxs)("div",{style:Gi.header,children:[(0,e.jsxs)("div",{style:Gi.headerLeft,children:[(0,e.jsx)("span",{style:Gi.synthBadge,children:"SYNTH"}),(0,e.jsx)("span",{style:Gi.symbol,children:r}),(0,e.jsx)("span",{style:Gi.horizon,children:l})]}),(0,e.jsxs)("div",{style:Gi.headerRight,children:[(0,e.jsxs)("span",{style:Object.assign({},Gi.lean,{color:p.color}),children:[p.glyph," ",o]}),(0,e.jsxs)("span",{style:Object.assign({},Gi.conviction,{background:g.bg,border:"1px solid "+g.border,color:g.color}),children:[a," conviction"]})]})]}),!x&&(0,e.jsxs)("div",{style:Gi.onboard,children:[(0,e.jsx)("span",{style:Gi.onboardIcon,children:"ⓘ"}),(0,e.jsxs)("span",{style:Gi.onboardText,children:[(0,e.jsx)("strong",{children:"Synthesis"})," cards are LLM-reasoned views over Cortex tool data. They aren't calibrated specialist forecasts — conviction is qualitative."]}),(0,e.jsx)("button",{onClick:y,style:Gi.onboardDismiss,children:"got it"})]}),s&&(0,e.jsx)("div",{style:Gi.rationale,children:s}),c.length>0&&(0,e.jsxs)("div",{style:Gi.evidenceWrap,children:[(0,e.jsxs)("div",{style:Gi.evidenceLabel,children:["EVIDENCE · ",c.length," tool",c.length===1?"":"s"]}),c.map(function(k,A){return(0,e.jsxs)("div",{style:Gi.evidenceRow,children:[(0,e.jsx)("span",{style:Gi.evidenceTool,children:k.tool}),(0,e.jsx)("span",{style:Gi.evidenceFinding,children:k.key_finding})]},A)})]}),d.length>0&&(0,e.jsx)("div",{style:Gi.warningsWrap,children:d.map(function(k,A){return(0,e.jsxs)("div",{style:Gi.warningRow,children:["⚠ ",k]},A)})})]})}var Gi={card:{margin:"8px 0",padding:"14px 16px",background:"rgba(8,11,17,0.65)",border:"1px dashed rgba(212,175,92,0.55)",borderRadius:8,fontFamily:"monospace",color:"#C9D1D9"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10,gap:12,flexWrap:"wrap"},headerLeft:{display:"flex",alignItems:"center",gap:10},headerRight:{display:"flex",alignItems:"center",gap:8},synthBadge:{padding:"2px 8px",background:"rgba(212,175,92,0.10)",border:"1px solid rgba(212,175,92,0.55)",borderRadius:3,color:"#D4AF5C",fontSize:9,letterSpacing:"0.20em",fontWeight:700},symbol:{fontSize:14,fontWeight:700,color:"#FFFFFF",letterSpacing:"0.06em"},horizon:{fontSize:9,color:"#6B7A94",letterSpacing:"0.16em",textTransform:"uppercase"},lean:{fontSize:11,fontWeight:700,letterSpacing:"0.10em",textTransform:"lowercase"},conviction:{padding:"3px 10px",borderRadius:12,fontSize:9,letterSpacing:"0.14em",fontWeight:700,textTransform:"uppercase"},onboard:{display:"flex",alignItems:"center",gap:8,padding:"6px 10px",marginBottom:10,background:"rgba(212,175,92,0.06)",border:"1px solid rgba(212,175,92,0.20)",borderRadius:4,fontSize:10,
404color:"#8B949E",lineHeight:1.4},onboardIcon:{color:"#D4AF5C",fontSize:11,flexShrink:0},onboardText:{flex:1,minWidth:0},onboardDismiss:{padding:"2px 8px",background:"transparent",border:"1px solid rgba(212,175,92,0.35)",borderRadius:3,color:"#D4AF5C",fontSize:9,letterSpacing:"0.10em",cursor:"pointer",flexShrink:0,fontFamily:"monospace"},rationale:{fontSize:12,color:"#C9D1D9",lineHeight:1.55,marginBottom:12,fontFamily:"inherit"},evidenceWrap:{paddingTop:8,borderTop:"1px solid rgba(28,39,64,0.6)"},evidenceLabel:{fontSize:8,color:"#6B7A94",letterSpacing:"0.18em",fontWeight:700,marginBottom:6},evidenceRow:{display:"flex",gap:10,alignItems:"flex-start",padding:"3px 0",fontSize:10,lineHeight:1.5},evidenceTool:{flexShrink:0,width:150,color:"#8898A8",fontSize:9,letterSpacing:"0.04em"},evidenceFinding:{flex:1,color:"#C9D1D9"},warningsWrap:{marginTop:10,paddingTop:8,borderTop:"1px solid rgba(248,81,73,0.20)"},warningRow:{fontSize:10,color:"#F85149",padding:"2px 0"}};function sI({artifact:t}){const n=t.payload||{},r=Array.isArray(n.direct_stories)?n.direct_stories:null,o=Array.isArray(n.market_stories)?n.market_stories:null,a=!!(r||o),l=a?(r||[]).concat(o||[]):Array.isArray(n.stories)?n.stories:[],s=n.query,c=a&&(o||[]).length>0&&((r||[]).length>0||!!s),d=s?String(s).toUpperCase():"THIS ASSET",p=Array.isArray(n.warnings)?n.warnings:[];return(0,e.jsxs)("div",{style:qe.card,children:[(0,e.jsxs)("div",{style:qe.header,children:[(0,e.jsxs)("div",{style:qe.headerLeft,children:[(0,e.jsx)("span",{style:qe.headerLabel,children:"NEWS"}),(0,e.jsx)("span",{style:qe.headerSymbol,children:s?String(s).toUpperCase():"cross-asset"})]}),(0,e.jsx)("div",{style:qe.headerRight,children:(0,e.jsxs)("span",{style:gr.count,children:[l.length," ",l.length===1?"story":"stories"]})})]}),l.length===0?(0,e.jsx)("div",{style:gr.emptyRow,children:(0,e.jsx)("em",{style:ii.caption,children:"No recent stories cached for this filter."})}):c?(0,e.jsxs)("ul",{style:gr.list,children:[(0,e.jsxs)("li",{style:gr.laneHead,children:["▸ DIRECTLY ON ",d," (",(r||[]).length,")"]}),(r||[]).length===0?(0,e.jsx)("li",{style:gr.emptyRow,children:(0,e.jsxs)("em",{style:ii.caption,children:["No recent stories directly on ",d," — the items below are market context, not asset coverage."]})}):null,(r||[]).map(function(g,f){return(0,e.jsx)(kh,{story:g},"d"+f)}),(0,e.jsxs)("li",{style:gr.laneHead,children:["▸ MARKET-MOVING · CROSS-ASSET (",o.length,")"]}),o.map(function(g,f){return(0,e.jsx)(kh,{story:g},"m"+f)})]}):(0,e.jsx)("ul",{style:gr.list,children:l.map(function(g,f){return(0,e.jsx)(kh,{story:g},f)})}),p.length?(0,e.jsx)("div",{style:qe.warnings,children:p.map(function(g){return(0,e.jsx)("span",{style:qe.warning,children:JE(g)},g)})}):null]})}function kh({story:t}){const n=t.title||"—",r=t.source||"News",o=t.time,a=MA(t.url),l=t.sentiment,s=Array.isArray(t.symbols)?t.symbols:null,c=l?mI[String(l).toLowerCase()]:null,d=RA(t),p=a?(0,e.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",style:gr.titleLink,children:n}):(0,e.jsx)("span",{style:gr.title,children:n});return(0,e.jsxs)("li",{style:gr.row,children:[(0,e.jsxs)("div",{style:gr.metaRow,children:[(0,e.jsx)("span",{style:gr.bullet,children:"▸"}),(0,e.jsx)("span",{style:gr.time,children:gI(o)||"—"}),(0,e.jsx)("span",{style:gr.source,children:r}),c?(0,e.jsx)("span",{style:Object.assign({},gr.sentiment,{background:c.bg,color:c.fg,borderColor:c.border}),children:c.symbol}):null,d?(0,e.jsx)("span",{style:Object.assign({},gr.freshness,d.tone==="stale"?gr.freshnessStale:gr.freshnessUnknown),children:d.text}):null,s&&s.length?(0,e.jsx)("span",{style:gr.symbols,children:s.slice(0,4).join(" · ")}):null]}),(0,e.jsx)("div",{children:p}),t.snippet?(0,e.jsx)("div",{style:gr.snippet,children:t.snippet}):null]})}var p1=["#D4AF5C","#4DA882","#6B9AC4","#A855F7","#FBBF24","#C85C5C","#56A0D3","#7AB87C","#B785C9","#E8A75C","#5A7090"];function cI({artifact:t}){const n=t.payload||{},r=Array.isArray(n.slices)?n.slices:[],o=r.reduce(function(x,v){return x+(Number(v.weight)||0)},0)>1.5?1:100,a=r.map(function(x,v){return{label:x.label,value:(Number(x.weight)||0)*o,color:p1[v%p1.length]}}),l=a.reduce(function(x,v){return x+v.value},0)||100,s=160,c=22,d=(s-c)/2,p=2*Math.PI*d,g=a.map(function(x){return(l>0?x.value/l:0)*p}),f=[];g.reduce(function(x,v){return f.push(-x),x+v},0);const h=a.map(function(x,v){const y=g[v],k=f[v];return(0,e.jsx)("circle",{cx:s/2,cy:s/2,r:d,fill:"none",stroke:x.color,strokeWidth:c,strokeDasharray:y+" "+(p-y),strokeDashoffset:k,transform:"rotate(-90 "+s/2+" "+s/2+")"},v)});return(0,e.jsxs)("div",{style:qe.card,children:[(0,e.jsxs)("div",{style:qe.header,children:[(0,e.jsxs)("div",{style:qe.headerLeft,children:[(0,e.jsx)("span",{style:qe.headerLabel,children:"BOOK"}),(0,e.jsx)("span",{style:qe.headerSymbol,children:n.headline||"—"})]}),(0,e.jsx)("div",{style:qe.headerRight,children:(0,e.jsx)("span",{style:gr.count,children:n.n_positions!=null?n.n_positions+" positions":""})})]}),(0,e.jsxs)("div",{style:$d.body,children:[(0,e.jsx)("div",{style:$d.svgWrap,children:a.length===0?(0,e.jsx)("div",{style:ii.caption,children:(0,e.jsx)("em",{children:"No allocation data."})}):(0,e.jsxs)("svg",{width:s,height:s,viewBox:"0 0 "+s+" 160",children:[(0,e.jsx)("circle",{cx:s/2,cy:s/2,r:d,fill:"none",stroke:"rgba(90,112,144,0.10)",strokeWidth:c}),h,(0,e.jsx)("text",{x:"50%",y:"48%",textAnchor:"middle",dominantBaseline:"middle",style:{fontFamily:"monospace",fontSize:11,fill:"#5A7090",letterSpacing:".10em"},children:"NAV"}),(0,e.jsx)("text",{x:"50%",y:"58%",textAnchor:"middle",dominantBaseline:"middle",style:{fontFamily:"monospace",fontSize:14,fill:"#E5E7EB",fontWeight:700},children:bf(n.nav,n.currency||"USD")})]})}),(0,e.jsx)("ul",{style:$d.legend,children:a.map(function(x,v){return(0,e.jsxs)("li",{style:$d.legendRow,children:[(0,e.jsx)("span",{style:Object.assign({},$d.swatch,{background:x.color})}),(0,e.jsx)("span",{style:$d.legendLabel,children:x.label}),(0,e.jsxs)("span",{style:$d.legendWeight,children:[x.value.toFixed(1),"%"]})]},v)})})]}),(0,e.jsxs)("div",{style:qe.footer,children:[n.cash!=null?(0,e.jsxs)("span",{style:qe.footerItem,children:["cash: ",(0,e.jsx)("span",{style:qe.footerValue,children:bf(n.cash,n.currency||"USD")})]}):null,n.gross!=null?(0,e.jsxs)("span",{style:qe.footerItem,children:["gross: ",(0,e.jsx)("span",{style:qe.footerValue,children:bf(n.gross,n.currency||"USD")})]}):null,n.net!=null?(0,e.jsxs)("span",{style:qe.footerItem,children:["net: ",(0,e.jsx)("span",{style:qe.footerValue,children:bf(n.net,n.currency||"USD")})]}):null,n.leverage!=null?(0,e.jsxs)("span",{style:qe.footerItem,children:["lev: ",(0,e.jsxs)("span",{style:qe.footerValue,children:[Number(n.leverage).toFixed(2),"×"]})]}):null,n.as_of?(0,e.jsxs)("span",{style:qe.footerItem,children:["as_of: ",(0,e.jsx)("span",{style:qe.footerValue,children:Jp(n.as_of)})]}):null]})]})}function bf(t,n){if(t==null)return"—";const r=Number(t);if(isNaN(r))return"—";const o=n==="USD"?"$":n+" ",a=Math.abs(r);return a>=1e9?o+(r/1e9).toFixed(2)+"B":a>=1e6?o+(r/1e6).toFixed(2)+"M":a>=1e3?o+(r/1e3).toFixed(1)+"k":o+r.toFixed(2)}var $d={body:{display:"grid",gridTemplateColumns:"auto 1fr",gap:18,alignItems:"center",padding:"14px 18px"},svgWrap:{display:"flex",alignItems:"center",justifyContent:"center"},legend:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:6},legendRow:{display:"grid",gridTemplateColumns:"14px 1fr auto",alignItems:"center",gap:8},swatch:{width:10,height:10,borderRadius:2,display:"inline-block"},legendLabel:{fontSize:11,color:"#E5E7EB",fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},legendWeight:{fontSize:11,color:"#8B949E",fontFamily:"monospace",fontWeight:700}},g1={earnings:{fg:"#D4AF5C",bg:"rgba(212,175,92,0.10)",border:"rgba(212,175,92,0.30)",glyph:"⌖"},economic:{fg:"#6B9AC4",bg:"rgba(56,189,248,0.10)",border:"rgba(56,189,248,0.30)",glyph:"◇"},event:{fg:"#8B949E",bg:"rgba(90,112,144,0.10)",border:"rgba(90,112,144,0.30)",glyph:"·"}}
404,dI={high:{fg:"#C85C5C",bg:"rgba(200,92,92,0.10)",border:"rgba(200,92,92,0.30)"},medium:{fg:"#D4AF5C",bg:"rgba(212,175,92,0.10)",border:"rgba(212,175,92,0.30)"},low:{fg:"#5A7090",bg:"rgba(90,112,144,0.08)",border:"rgba(90,112,144,0.25)"}};function uI({artifact:t}){const n=t.payload||{},r=Array.isArray(n.events)?n.events:[],o=n.symbol,a=n.days,l={};r.forEach(function(c){const d=(c.date||"TBD").toString().slice(0,10);l[d]||(l[d]=[]),l[d].push(c)});const s=Object.keys(l).sort();return(0,e.jsxs)("div",{style:qe.card,children:[(0,e.jsxs)("div",{style:qe.header,children:[(0,e.jsxs)("div",{style:qe.headerLeft,children:[(0,e.jsx)("span",{style:qe.headerLabel,children:"EVENTS"}),(0,e.jsx)("span",{style:qe.headerSymbol,children:o?String(o).toUpperCase():"cross-asset"}),a?(0,e.jsxs)("span",{style:qe.headerAssetClass,children:["NEXT ",a,"D"]}):null]}),(0,e.jsx)("div",{style:qe.headerRight,children:(0,e.jsxs)("span",{style:gr.count,children:[r.length," ",r.length===1?"event":"events"]})})]}),r.length===0?(0,e.jsx)("div",{style:gr.emptyRow,children:(0,e.jsx)("em",{style:ii.caption,children:"No events in this window."})}):(0,e.jsx)("div",{style:Sl.timeline,children:s.map(function(c){const d=l[c];return(0,e.jsxs)("div",{style:Sl.dayBlock,children:[(0,e.jsxs)("div",{style:Sl.dateLabel,children:[(0,e.jsx)("span",{style:Sl.dateDot,children:"●"}),(0,e.jsx)("span",{children:pI(c)}),(0,e.jsxs)("span",{style:Sl.dateCount,children:[d.length," ",d.length===1?"event":"events"]})]}),(0,e.jsx)("ul",{style:Sl.eventList,children:d.map(function(p,g){return(0,e.jsx)(fI,{ev:p},g)})})]},c)})})]})}function fI({ev:t}){const n=g1[t.kind]||g1.event,r=t.importance?dI[String(t.importance).toLowerCase()]:null;return(0,e.jsxs)("li",{style:Sl.eventRow,children:[(0,e.jsxs)("span",{style:Object.assign({},Sl.kind,{background:n.bg,color:n.fg,borderColor:n.border}),children:[(0,e.jsx)("span",{style:{marginRight:4},children:n.glyph}),t.kind]}),(0,e.jsx)("span",{style:Sl.title,children:t.title}),r?(0,e.jsx)("span",{style:Object.assign({},Sl.importance,{background:r.bg,color:r.fg,borderColor:r.border}),children:t.importance}):null,t.estimate!=null?(0,e.jsxs)("span",{style:Sl.numeric,children:["est: ",t.estimate]}):null,t.previous!=null?(0,e.jsxs)("span",{style:Sl.numeric,children:["prev: ",t.previous]}):null]})}function pI(t){try{const n=new Date(t);return isNaN(n.getTime())?t:n.toLocaleDateString("en-GB",{weekday:"short",day:"2-digit",month:"short"})}catch{return t}}var Sl={timeline:{padding:"8px 4px 12px"},dayBlock:{padding:"4px 14px"},dateLabel:{display:"flex",alignItems:"center",gap:8,padding:"6px 0",fontSize:9,fontWeight:700,letterSpacing:".14em",color:"#D4AF5C",textTransform:"uppercase",borderBottom:"1px solid rgba(212,175,92,0.10)"},dateDot:{color:"#D4AF5C",fontSize:8},dateCount:{marginLeft:"auto",fontSize:8,fontWeight:700,color:"#5A7090",letterSpacing:".10em"},eventList:{listStyle:"none",padding:"6px 0 4px 14px",margin:0},eventRow:{display:"flex",alignItems:"center",gap:8,padding:"4px 0",flexWrap:"wrap"},kind:{fontSize:8,fontWeight:700,letterSpacing:".12em",padding:"2px 7px",borderRadius:3,border:"1px solid",textTransform:"uppercase"},title:{fontSize:11,color:"#E5E7EB",flex:1,minWidth:200},importance:{fontSize:8,fontWeight:700,letterSpacing:".10em",padding:"1px 6px",borderRadius:3,border:"1px solid",textTransform:"uppercase"},numeric:{fontSize:9,color:"#8B949E",fontFamily:"monospace",letterSpacing:".04em"}};function gI(t){if(!t)return null;try{const n=new Date(t);if(isNaN(n.getTime()))return String(t).slice(0,16);const r=new Date;return n.toDateString()===r.toDateString()?n.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"}):n.toISOString().slice(0,10)}catch{return String(t).slice(0,16)}}var mI={positive:{fg:"#4DA882",bg:"rgba(77,168,130,0.10)",border:"rgba(77,168,130,0.30)",symbol:"↑"},bullish:{fg:"#4DA882",bg:"rgba(77,168,130,0.10)",border:"rgba(77,168,130,0.30)",symbol:"↑"},negative:{fg:"#C85C5C",bg:"rgba(200,92,92,0.10)",border:"rgba(200,92,92,0.30)",symbol:"↓"},bearish:{fg:"#C85C5C",bg:"rgba(200,92,92,0.10)",border:"rgba(200,92,92,0.30)",symbol:"↓"},neutral:{fg:"#D4AF5C",bg:"rgba(212,175,92,0.08)",border:"rgba(212,175,92,0.30)",symbol:"→"}},gr={count:{fontSize:8,fontWeight:700,letterSpacing:".10em",color:"#5A7090"},list:{listStyle:"none",margin:0,padding:"4px 0"},emptyRow:{padding:"14px"},laneHead:{listStyle:"none",padding:"8px 14px 2px",fontSize:8,fontWeight:800,letterSpacing:".12em",color:"#C89850",textTransform:"uppercase"},freshness:{fontSize:7,fontWeight:800,letterSpacing:".08em",padding:"0 4px",border:"1px solid",borderRadius:2},freshnessStale:{color:"#C89850",borderColor:"rgba(200,152,80,0.45)"},freshnessUnknown:{color:"#8B949E",borderColor:"rgba(139,148,158,0.45)"},row:{padding:"10px 14px",borderBottom:"1px solid rgba(212,175,92,0.06)",display:"flex",flexDirection:"column",gap:4},metaRow:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},bullet:{color:"#D4AF5C",fontSize:10},time:{fontSize:9,color:"#8B949E",fontFamily:"monospace",fontWeight:700,letterSpacing:".06em"},source:{fontSize:8,fontWeight:700,letterSpacing:".14em",color:"#5A7090",textTransform:"uppercase"},sentiment:{fontSize:8,fontWeight:700,padding:"1px 6px",border:"1px solid",borderRadius:3},symbols:{fontSize:8,color:"#3A4A5E",letterSpacing:".04em",fontFamily:"monospace"},title:{fontSize:12,color:"#E5E7EB",lineHeight:1.45},titleLink:{fontSize:12,color:"#E5E7EB",lineHeight:1.45,textDecoration:"none",borderBottom:"1px dotted rgba(212,175,92,0.30)"}
404,snippet:{fontSize:10,color:"#8B949E",lineHeight:1.5,marginTop:2}},Vu={low:{fg:"#4DA882",label:"LOW"},moderate:{fg:"#D4AF5C",label:"MODERATE"},elevated:{fg:"#F59E0B",label:"ELEVATED"},extreme:{fg:"#C85C5C",label:"EXTREME"},ok:{fg:"#4DA882",label:"OK"},warn:{fg:"#C85C5C",label:"WARN"},unknown:{fg:"#5A7090",label:"—"}};function hI({artifact:t}){const n=t.payload||{},r=Number.isFinite(n.score)?n.score:null,o=Number.isFinite(n.scale_min)?n.scale_min:0,a=Number.isFinite(n.scale_max)?n.scale_max:100,l=a<=o?o+1:a,s=n.headline||t.title||"—",c=Vu[(n.band||"unknown").toLowerCase()]||Vu.unknown,d=n.unit||"",p=Array.isArray(n.submetrics)?n.submetrics:[],g=n.sector_exposures&&typeof n.sector_exposures=="object"?Object.entries(n.sector_exposures).slice(0,6):[],f=r==null?0:Math.max(0,Math.min(1,(r-o)/(l-o))),h=Math.PI-f*Math.PI,x=50,v=50,y=38,k=x+y*Math.cos(h),A=v-y*Math.sin(h),j=[{from:0,to:.25,fg:Vu.low.fg},{from:.25,to:.5,fg:Vu.moderate.fg},{from:.5,to:.75,fg:Vu.elevated.fg},{from:.75,to:1,fg:Vu.extreme.fg}];return(0,e.jsxs)("div",{style:qe.card,children:[(0,e.jsxs)("div",{style:qe.header,children:[(0,e.jsxs)("div",{style:qe.headerLeft,children:[(0,e.jsx)("span",{style:qe.headerLabel,children:"GAUGE"}),(0,e.jsx)("span",{style:qe.headerSymbol,children:(t.title||"risk").toUpperCase()})]}),(0,e.jsx)("div",{style:qe.headerRight,children:(0,e.jsx)("span",{style:Object.assign({},qe.coverage,{color:c.fg,borderColor:c.fg+"66",background:c.fg+"14"}),children:c.label})})]}),(0,e.jsxs)("div",{style:Jo.body,children:[(0,e.jsxs)("svg",{viewBox:"0 0 100 60",style:Jo.svg,role:"img","aria-label":s,children:[j.map(function(E,C){return(0,e.jsx)("path",{d:yI(x,v,y,E.from,E.to),stroke:E.fg,strokeWidth:"6",fill:"none",opacity:f>=E.from&&f<E.to?1:.3},C)}),r!=null?(0,e.jsxs)("g",{children:[(0,e.jsx)("line",{x1:x,y1:v,x2:k,y2:A,stroke:c.fg,strokeWidth:"1.5",strokeLinecap:"round"}),(0,e.jsx)("circle",{cx:x,cy:v,r:"2.5",fill:c.fg})]}):null,(0,e.jsxs)("text",{x,y:v+8,textAnchor:"middle",style:{fontSize:7,fill:"#5A7090",letterSpacing:"0.10em"},children:[o,"–",l,d?" "+d:""]})]}),(0,e.jsxs)("div",{style:Jo.scoreBlock,children:[(0,e.jsx)("div",{style:Object.assign({},Jo.scoreValue,{color:c.fg}),children:r==null?"—":Math.abs(r)>=100?r.toFixed(0):Math.abs(r)>=10?r.toFixed(1):r.toFixed(2)}),(0,e.jsx)("div",{style:Jo.scoreUnit,children:d||`out of ${l}`}),(0,e.jsx)("div",{style:Jo.headline,children:s})]})]}),p.length?(0,e.jsx)("div",{style:Jo.subs,children:p.slice(0,8).map(function(E,C){const _=E.tone==="warn"?"#F59E0B":E.tone==="crit"?"#C85C5C":"#8B949E",w=Number(E.value),O=isFinite(w)?Math.abs(w)>=100?w.toFixed(0):Math.abs(w)>=10?w.toFixed(1):w.toFixed(2):"—";return(0,e.jsxs)("div",{style:Jo.subItem,children:[(0,e.jsx)("div",{style:Jo.subLabel,children:String(E.label||"").toUpperCase()}),(0,e.jsxs)("div",{style:Object.assign({},Jo.subValue,{color:_}),children:[O,E.unit||""]})]},C)})}):null,g.length?(0,e.jsxs)("div",{style:Jo.sectors,children:[(0,e.jsx)("div",{style:Jo.sectorsLabel,children:"SECTOR EXPOSURE"}),(0,e.jsx)("div",{style:Jo.sectorsRow,children:g.map(function(E){const C=E[0],_=Number(E[1])||0;return(0,e.jsxs)("div",{style:Jo.sectorItem,children:[(0,e.jsx)("span",{style:Jo.sectorName,children:C}),(0,e.jsxs)("span",{style:Jo.sectorValue,children:[(_*100).toFixed(1),"%"]})]},C)})})]}):null,n.snapshot_at||n.cached!=null?(0,e.jsxs)("div",{style:qe.footer,children:[n.snapshot_at?(0,e.jsxs)("span",{style:qe.footerItem,children:["snapshot: ",(0,e.jsx)("span",{style:qe.footerValue,children:Jp(n.snapshot_at)})]}):null,n.cached!=null?(0,e.jsxs)("span",{style:qe.footerItem,children:["source: ",(0,e.jsx)("span",{style:qe.footerValue,children:n.cached?"cached":"fresh"})]}):null]}):null]})}function yI(t,n,r,o,a){const l=Math.PI-o*Math.PI,s=Math.PI-a*Math.PI,c=t+r*Math.cos(l),d=n-r*Math.sin(l),p=t+r*Math.cos(s),g=n-r*Math.sin(s),f=a-o>.5?1:0;return`M ${c.toFixed(2)} ${d.toFixed(2)} A ${r} ${r} 0 ${f} 1 ${p.toFixed(2)} ${g.toFixed(2)}`}var Jo={body:{display:"grid",gridTemplateColumns:"minmax(180px, 1fr) minmax(140px, 220px)",gap:18,padding:"14px 18px",alignItems:"center"},svg:{width:"100%",height:"auto",maxWidth:260,overflow:"visible"},scoreBlock:{display:"flex",flexDirection:"column",gap:4,fontFamily:"monospace"},scoreValue:{fontSize:36,fontWeight:700,letterSpacing:".02em",lineHeight:1},scoreUnit:{fontSize:9,color:"#5A7090",letterSpacing:".16em",textTransform:"uppercase"},headline:{fontSize:11,color:"#E5E7EB",marginTop:6,lineHeight:1.45},subs:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(110px, 1fr))",gap:0,borderTop:"1px solid rgba(212,175,92,0.10)"},subItem:{padding:"10px 12px",borderRight:"1px solid rgba(212,175,92,0.06)",fontFamily:"monospace"},subLabel:{fontSize:8,color:"#5A7090",letterSpacing:".16em",fontWeight:700},subValue:{fontSize:14,fontWeight:700,marginTop:4,letterSpacing:".02em"},sectors:{padding:"8px 14px 10px",borderTop:"1px solid rgba(212,175,92,0.06)"},sectorsLabel:{fontSize:8,color:"#8B949E",letterSpacing:".18em",fontWeight:700,marginBottom:4},sectorsRow:{display:"flex",flexWrap:"wrap",gap:10,fontFamily:"monospace"},sectorItem:{display:"inline-flex",gap:6,alignItems:"baseline",padding:"3px 8px",borderRadius:3,background:"rgba(90,112,144,0.08)",border:"1px solid rgba(90,112,144,0.18)"},sectorName:{fontSize:9,color:"#8B949E",letterSpacing:".06em"}
404,sectorValue:{fontSize:10,color:"#E5E7EB",fontWeight:700}};function xI({artifact:t}){const n=t.payload||{},r=Array.isArray(n.row_labels)?n.row_labels:[],o=Array.isArray(n.col_labels)?n.col_labels:[],a=Array.isArray(n.matrix)?n.matrix:[],l=Number.isFinite(n.scale_min)?n.scale_min:-1,s=Number.isFinite(n.scale_max)?n.scale_max:1,c=n.diverging!==!1,d=n.value_format||"fixed2",p=Array.isArray(n.footer_rows)?n.footer_rows:[];function g(y){return Number.isFinite(y)?d==="pct"?(y*100).toFixed(1)+"%":d==="int"?Math.round(y).toString():y.toFixed(2):"—"}function f(y){if(!Number.isFinite(y))return"rgba(90,112,144,0.06)";if(c){const A=Math.max(-1,Math.min(1,y/Math.max(Math.abs(l),Math.abs(s),1e-9)));return A>=0?`rgba(200,92,92,${(.1+.45*A).toFixed(3)})`:`rgba(56,114,178,${(.1+.45*Math.abs(A)).toFixed(3)})`}const k=s-l||1;return`rgba(212,175,92,${(.08+.45*Math.max(0,Math.min(1,(y-l)/k))).toFixed(3)})`}function h(y){return Number.isFinite(y)?Math.abs(y)/Math.max(Math.abs(l),Math.abs(s),1e-9)>.55?"#0e0e0e":"#E5E7EB":"#5A7090"}const x=o.length>=10?56:64,v=28;return(0,e.jsxs)("div",{style:qe.card,children:[(0,e.jsxs)("div",{style:qe.header,children:[(0,e.jsxs)("div",{style:qe.headerLeft,children:[(0,e.jsx)("span",{style:qe.headerLabel,children:"HEATMAP"}),(0,e.jsx)("span",{style:qe.headerSymbol,children:(t.title||"matrix").toUpperCase()})]}),(0,e.jsx)("div",{style:qe.headerRight,children:(0,e.jsxs)("span",{style:gr.count,children:[r.length,"×",o.length]})})]}),r.length===0||o.length===0?(0,e.jsx)("div",{style:gr.emptyRow,children:(0,e.jsx)("em",{style:ii.caption,children:"No data."})}):(0,e.jsx)("div",{style:Qo.scroll,children:(0,e.jsxs)("table",{style:Qo.table,children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{style:Qo.cornerTh}),o.map(function(y){return(0,e.jsx)("th",{style:Object.assign({},Qo.colTh,{minWidth:x}),children:y},y)})]})}),(0,e.jsxs)("tbody",{children:[r.map(function(y,k){const A=a[k]||[];return(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{style:Qo.rowTh,children:y}),o.map(function(j,E){const C=A[E];return(0,e.jsx)("td",{style:Object.assign({},Qo.cell,{width:x,height:v,background:f(C),color:h(C)}),children:g(C)},E)})]},k)}),p.map(function(y,k){const A=Array.isArray(y.values)?y.values:[];return(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{style:Object.assign({},Qo.rowTh,Qo.footerLabel),children:y.label}),o.map(function(j,E){const C=A[E];return(0,e.jsx)("td",{style:Object.assign({},Qo.cell,Qo.footerCell,{width:x,height:v,background:f(C),color:h(C)}),children:g(C)},E)})]},"fr"+k)})]})]})}),(0,e.jsxs)("div",{style:Qo.legend,children:[(0,e.jsxs)("div",{style:Qo.legendBar,children:[(0,e.jsx)("span",{style:Qo.legendStart,children:g(l)}),(0,e.jsx)("span",{style:Object.assign({},Qo.legendGradient,{background:c?"linear-gradient(90deg, rgba(56,114,178,0.55), rgba(90,112,144,0.10), rgba(200,92,92,0.55))":"linear-gradient(90deg, rgba(212,175,92,0.08), rgba(212,175,92,0.55))"})}),(0,e.jsx)("span",{style:Qo.legendEnd,children:g(s)})]}),n.footer?(0,e.jsx)("span",{style:Qo.footerNote,children:n.footer}):null]})]})}var Qo={scroll:{padding:"6px 4px 4px",overflowX:"auto"},table:{borderCollapse:"separate",borderSpacing:2,fontFamily:"monospace",margin:"0 auto"},cornerTh:{background:"transparent",minWidth:64,padding:"4px 6px"},colTh:{fontSize:9,fontWeight:700,letterSpacing:".10em",color:"#8B949E",padding:"4px 6px",textAlign:"center"},rowTh:{fontSize:10,fontWeight:700,letterSpacing:".04em",color:"#E5E7EB",textAlign:"right",padding:"0 8px"},cell:{fontSize:10,fontWeight:700,textAlign:"center",borderRadius:3,letterSpacing:".02em"},footerLabel:{color:"#D4AF5C",borderTop:"1px solid rgba(212,175,92,0.18)",paddingTop:4},footerCell:{borderTop:"1px solid rgba(212,175,92,0.18)"},legend:{display:"flex",alignItems:"center",gap:14,padding:"6px 14px 10px",borderTop:"1px solid rgba(212,175,92,0.06)",flexWrap:"wrap"},legendBar:{display:"inline-flex",alignItems:"center",gap:8},legendStart:{fontSize:9,color:"#5A7090",fontFamily:"monospace",letterSpacing:".04em"},legendEnd:{fontSize:9,color:"#5A7090",fontFamily:"monospace",letterSpacing:".04em"},legendGradient:{display:"inline-block",width:120,height:8,borderRadius:4,border:"1px solid rgba(212,175,92,0.10)"},footerNote:{fontSize:9,color:"#5A7090",letterSpacing:".04em",fontFamily:"monospace"}},G0=["#D4AF5C","#4DA882","#6B9AC4","#A855F7","#F59E0B","#C85C5C","#5A7090","#FBBF24"];function vI({artifact:t}){const n=t.payload||{},r=Array.isArray(n.series)?n.series:[],o=n.symbol||t.title||"—",a=Number.isFinite(n.y_min)?n.y_min:0,l=Number.isFinite(n.y_max)?n.y_max:1,s=l<=a?a+1:l,c=(s-a)*.1||.01,d=a-c,p=s+c,g=[];
404r.forEach(function(ee){(ee.points||[]).forEach(function(N){const V=Date.parse(N.event_time);Number.isFinite(V)&&g.push(V)})});const f=g.length?Math.min.apply(null,g):Date.now(),h=g.length?Math.max.apply(null,g):f+3600*1e3,x=h<=f?f+1:h,v=600,y=220,k=44,A=12,j=12,E=26,C=v-k-A,_=y-j-E;function w(ee){const N=typeof ee=="number"?ee:Date.parse(ee);return Number.isFinite(N)?k+C*((N-f)/(x-f)):k}function O(ee){return Number.isFinite(ee)?j+_*(1-(ee-d)/(p-d)):null}const M=4,U=[];for(let ee=0;ee<=M;ee++)U.push(d+(p-d)*(ee/M));return(0,e.jsxs)("div",{style:qe.card,children:[(0,e.jsxs)("div",{style:qe.header,children:[(0,e.jsxs)("div",{style:qe.headerLeft,children:[(0,e.jsx)("span",{style:qe.headerLabel,children:"FORECAST"}),(0,e.jsx)("span",{style:qe.headerSymbol,children:String(o).toUpperCase()}),n.lookback_hours?(0,e.jsxs)("span",{style:qe.headerAssetClass,children:["LAST ",n.lookback_hours,"H"]}):null]}),(0,e.jsx)("div",{style:qe.headerRight,children:(0,e.jsxs)("span",{style:gr.count,children:[r.length," model",r.length===1?"":"s"]})})]}),r.length===0?(0,e.jsx)("div",{style:gr.emptyRow,children:(0,e.jsx)("em",{style:ii.caption,children:"No predictions in this window."})}):(0,e.jsxs)("div",{style:Vc.body,children:[(0,e.jsxs)("svg",{viewBox:`0 0 ${v} ${y}`,style:Vc.svg,role:"img","aria-label":n.headline||"forecast curve",children:[U.map(function(ee,N){const V=O(ee);return(0,e.jsxs)("g",{children:[(0,e.jsx)("line",{x1:k,y1:V,x2:v-A,y2:V,stroke:"rgba(212,175,92,0.06)",strokeWidth:"1"}),(0,e.jsx)("text",{x:k-6,y:V+3,textAnchor:"end",style:Vc.axisText,children:Math.abs(ee)>=100?ee.toFixed(0):Math.abs(ee)>=1?ee.toFixed(2):ee.toFixed(3)})]},"g"+N)}),(0,e.jsx)("line",{x1:k,y1:y-E,x2:v-A,y2:y-E,stroke:"rgba(212,175,92,0.18)",strokeWidth:"1"}),(0,e.jsx)("line",{x1:k,y1:j,x2:k,y2:y-E,stroke:"rgba(212,175,92,0.18)",strokeWidth:"1"}),r.map(function(ee,N){const V=G0[N%G0.length],z=(ee.points||[]).filter(function(R){return Number.isFinite(R.point_estimate)});if(z.length===0)return null;const oe=z.filter(function(R){return Number.isFinite(R.interval_low)&&Number.isFinite(R.interval_high)}).map(function(R){return{x:w(R.event_time),yLo:O(R.interval_low),yHi:O(R.interval_high)}});let P="";if(oe.length>=2){P="M "+oe.map(function(R){return`${R.x.toFixed(2)} ${R.yHi.toFixed(2)}`}).join(" L ");for(let R=oe.length-1;R>=0;R--)P+=` L ${oe[R].x.toFixed(2)} ${oe[R].yLo.toFixed(2)}`;P+=" Z"}const W="M "+z.map(function(R){return`${w(R.event_time).toFixed(2)} ${O(R.point_estimate).toFixed(2)}`}).join(" L ");return(0,e.jsxs)("g",{children:[P?(0,e.jsx)("path",{d:P,fill:V,fillOpacity:"0.10",stroke:"none"}):null,(0,e.jsx)("path",{d:W,fill:"none",stroke:V,strokeWidth:"1.5",strokeLinejoin:"round"}),z.map(function(R,ae){return(0,e.jsx)("circle",{cx:w(R.event_time),cy:O(R.point_estimate),r:R.ood?3:1.6,fill:R.ood?"transparent":V,stroke:V,strokeWidth:R.ood?1.2:0},ae)})]},ee.model_id)})]}),(0,e.jsx)("div",{style:Vc.legend,children:r.map(function(ee,N){const V=G0[N%G0.length],z=(ee.points||[]).filter(function(oe){return Number.isFinite(oe.point_estimate)}).slice(-1)[0];return(0,e.jsxs)("div",{style:Vc.legendItem,children:[(0,e.jsx)("span",{style:Object.assign({},Vc.legendDot,{background:V})}),(0,e.jsx)("span",{style:Vc.legendLabel,children:ee.model_id}),z?(0,e.jsx)("span",{style:Vc.legendValue,children:Math.abs(z.point_estimate)>=1?z.point_estimate.toFixed(3):(z.point_estimate*100).toFixed(2)+"%"}):null]},ee.model_id)})})]})]})}var Vc={body:{padding:"10px 14px 4px"},svg:{width:"100%",height:"auto",display:"block"},axisText:{fontSize:8,fill:"#5A7090",fontFamily:"monospace",letterSpacing:".02em"},legend:{display:"flex",flexWrap:"wrap",gap:12,padding:"6px 0 8px",borderTop:"1px solid rgba(212,175,92,0.06)",marginTop:6},legendItem:{display:"inline-flex",alignItems:"center",gap:6,fontFamily:"monospace"},legendDot:{display:"inline-block",width:10,height:10,borderRadius:2},legendLabel:{fontSize:10,color:"#E5E7EB"},legendValue:{fontSize:10,color:"#8B949E",fontFamily:"monospace"}};function bI({artifact:t}){const n=t.payload||{},r=!!n.approved,o=String(n.direction||"").toUpperCase(),a=String(n.symbol||"—").toUpperCase(),l=Number.isFinite(n.target_fraction)?n.target_fraction:0,s=Number.isFinite(n.target_notional_usd)?n.target_notional_usd:0,c=Array.isArray(n.reasons)?n.reasons:[],d=n.inputs||{},p=Array.isArray(n.crowded_with)?n.crowded_with:[],g=r?"#4DA882":"#C85C5C",f=[];return n.gross_cap_applied&&f.push("GROSS CAP"),n.net_cap_applied&&f.push("NET CAP"),n.turnover_cap_applied&&f.push("TURNOVER CAP"),(0,e.jsxs)("div",{style:qe.card,children:[(0,e.jsxs)("div",{style:qe.header,children:[(0,e.jsxs)("div",{style:qe.headerLeft,children:[(0,e.jsx)("span",{style:qe.headerLabel,children:"DRY-RUN"}),(0,e.jsxs)("span",{style:qe.headerSymbol,children:[o," ",a]})]}),(0,e.jsx)("div",{style:qe.headerRight,children:(0,e.jsx)("span",{style:Object.assign({},qe.coverage,{color:g,borderColor:g+"66",background:g+"14"}),children:r?"APPROVED":"BLOCKED"})})]}),(0,e.jsxs)("div",{style:za.body,children:[(0,e.jsxs)("div",{style:za.metricRow,children:[(0,e.jsx)(Ch,{label:"TARGET",value:(Math.abs(l)*100).toFixed(2)+"%",unit:"of NAV",tone:g}),(0,e.jsx)(Ch,{label:"NOTIONAL",value:bf(s,"USD"),unit:"USD",tone:g}
404),(0,e.jsx)(Ch,{label:"EQUITY",value:bf(Number(d.equity_usd)||0,"USD"),unit:"reference"})]}),(0,e.jsxs)("div",{style:za.inputsRow,children:[(0,e.jsx)(Yu,{label:"conf",value:V0(d.confidence)}),(0,e.jsx)(Yu,{label:"strength",value:V0(d.strength)}),(0,e.jsx)(Yu,{label:"μ",value:V0(d.expected_return)}),(0,e.jsx)(Yu,{label:"±",value:V0(d.interval_half_width)}),n.regime_label?(0,e.jsx)(Yu,{label:"regime",value:String(n.regime_label).toUpperCase(),tone:n.regime_label==="bull"?"#4DA882":n.regime_label==="bear"?"#C85C5C":"#D4AF5C"}):null,Number.isFinite(n.regime_scale)?(0,e.jsx)(Yu,{label:"r-scale",value:n.regime_scale.toFixed(2)}):null]}),c.length>0||f.length>0||p.length>0?(0,e.jsxs)("div",{style:za.reasons,children:[c.map(function(h){return(0,e.jsx)("span",{style:Object.assign({},za.reasonChip,{color:h==="approved"?"#4DA882":"#FBBF24",borderColor:h==="approved"?"rgba(77,168,130,0.40)":"rgba(251,191,36,0.40)"}),children:h},h)}),f.map(function(h){return(0,e.jsx)("span",{style:Object.assign({},za.reasonChip,{color:"#F59E0B",borderColor:"rgba(245,158,11,0.40)"}),children:h},h)}),p.length>0?(0,e.jsxs)("span",{style:Object.assign({},za.reasonChip,{color:"#A855F7",borderColor:"rgba(168,85,247,0.40)"}),children:["crowded · ",p.join(", ")]}):null]}):null]}),(0,e.jsx)("div",{style:qe.warnings,children:(0,e.jsx)("span",{style:qe.warning,children:"DRY RUN · NO ORDER PLACED"})})]})}function Ch({label:t,value:n,unit:r,tone:o}){return(0,e.jsxs)("div",{style:za.metric,children:[(0,e.jsx)("div",{style:za.metricLabel,children:t}),(0,e.jsx)("div",{style:Object.assign({},za.metricValue,o?{color:o}:null),children:n}),r?(0,e.jsx)("div",{style:za.metricUnit,children:r}):null]})}function Yu({label:t,value:n,tone:r}){return(0,e.jsxs)("span",{style:Object.assign({},za.chip,r?{color:r,borderColor:r+"55"}:null),children:[(0,e.jsx)("span",{style:za.chipLabel,children:t}),(0,e.jsx)("span",{style:za.chipValue,children:n||"—"})]})}function V0(t){const n=Number(t);return Number.isFinite(n)?(n*100).toFixed(1)+"%":"—"}var za={body:{padding:"12px 16px",fontFamily:"monospace"},metricRow:{display:"flex",gap:24,flexWrap:"wrap"},metric:{display:"flex",flexDirection:"column",gap:2},metricLabel:{fontSize:8,color:"#5A7090",letterSpacing:".18em",fontWeight:700},metricValue:{fontSize:22,fontWeight:700,color:"#E5E7EB",letterSpacing:".02em"},metricUnit:{fontSize:8,color:"#5A7090",letterSpacing:".10em"},inputsRow:{display:"flex",flexWrap:"wrap",gap:6,marginTop:12},chip:{display:"inline-flex",gap:5,alignItems:"baseline",padding:"3px 8px",borderRadius:3,background:"rgba(90,112,144,0.06)",border:"1px solid rgba(90,112,144,0.20)",color:"#8B949E"},chipLabel:{fontSize:8,letterSpacing:".14em",textTransform:"uppercase",color:"#5A7090",fontWeight:700},chipValue:{fontSize:10,fontWeight:700},reasons:{display:"flex",flexWrap:"wrap",gap:6,marginTop:12,paddingTop:8,borderTop:"1px solid rgba(212,175,92,0.06)"},reasonChip:{fontSize:9,fontWeight:700,letterSpacing:".10em",padding:"3px 8px",borderRadius:3,border:"1px solid",textTransform:"uppercase",background:"rgba(0,0,0,0.20)"}};function SI({artifact:t}){const n=t.payload||{},r=Array.isArray(n.items)?n.items:[],o=n.headline||t.title||"recall";return(0,e.jsxs)("div",{style:qe.card,children:[(0,e.jsxs)("div",{style:qe.header,children:[(0,e.jsxs)("div",{style:qe.headerLeft,children:[(0,e.jsx)("span",{style:qe.headerLabel,children:"RECALL"}),(0,e.jsx)("span",{style:qe.headerSymbol,children:n.query?`“${String(n.query).slice(0,60)}”`:"memory"})]}),(0,e.jsx)("div",{style:qe.headerRight,children:(0,e.jsx)("span",{style:gr.count,children:r.length})})]}),r.length===0?(0,e.jsx)("div",{style:gr.emptyRow,children:(0,e.jsx)("em",{style:ii.caption,children:o})}):(0,e.jsx)("ul",{style:Vl.list,children:r.map(function(a,l){return(0,e.jsxs)("li",{style:Vl.row,children:[(0,e.jsxs)("div",{style:Vl.metaRow,children:[(0,e.jsx)("span",{style:Vl.label,children:String(a.label||"NOTE")}),Number.isFinite(a.importance)?(0,e.jsxs)("span",{style:Vl.importance,children:[(0,e.jsx)("span",{style:Object.assign({},Vl.bar,{width:Math.max(2,Math.min(60,a.importance*40))})}),(0,e.jsx)("span",{style:Vl.importanceText,children:a.importance.toFixed(2)})]}):null,a.created_at?(0,e.jsx)("span",{style:Vl.created,children:Jp(a.created_at)}):null]}),(0,e.jsx)("div",{style:Vl.text,children:a.text}),Array.isArray(a.tags)&&a.tags.length>0?(0,e.jsx)("div",{style:Vl.tags,children:a.tags.slice(0,8).map(function(s){return(0,e.jsxs)("span",{style:Vl.tag,children:["#",s]},s)})}):null]},a.id||l)})})]})}var Vl={list:{listStyle:"none",margin:0,padding:0},row:{padding:"10px 14px",borderBottom:"1px solid rgba(212,175,92,0.06)",display:"flex",flexDirection:"column",gap:4,fontFamily:"monospace"},metaRow:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},label:{fontSize:8,fontWeight:700,letterSpacing:".18em",color:"#D4AF5C",padding:"2px 6px",borderRadius:3,background:"rgba(212,175,92,0.08)",border:"1px solid rgba(212,175,92,0.30)"},importance:{display:"inline-flex",alignItems:"center",gap:4},bar:{display:"inline-block",height:4,borderRadius:2,background:"rgba(212,175,92,0.40)"},importanceText:{fontSize:8,color:"#8B949E"},created:{fontSize:8,color:"#5A7090",letterSpacing:".06em"},text:{fontSize:12,color:"#E5E7EB",lineHeight:1.5},tags:{display:"flex",flexWrap:"wrap",gap:4},tag:{fontSize:8,color:"#5A7090",letterSpacing:".04em",padding:"1px 6px",borderRadius:2,background:"rgba(90,112,144,0.08)"}},m1={ok:{fg:"#4DA882",bg:"rgba(77,168,130,0.10)",border:"rgba(77,168,130,0.40)"},warn:{fg:"#F59E0B",bg:"rgba(245,158,11,0.10)",border:"rgba(245,158,11,0.40)"}
404,crit:{fg:"#C85C5C",bg:"rgba(200,92,92,0.10)",border:"rgba(200,92,92,0.40)"},muted:{fg:"#5A7090",bg:"rgba(90,112,144,0.06)",border:"rgba(90,112,144,0.25)"}};function EI({artifact:t}){const n=t.payload||{},r=Array.isArray(n.chips)?n.chips:[],o=n.headline||t.title||"";return(0,e.jsxs)("div",{style:qe.card,children:[(0,e.jsxs)("div",{style:qe.header,children:[(0,e.jsxs)("div",{style:qe.headerLeft,children:[(0,e.jsx)("span",{style:qe.headerLabel,children:"STATUS"}),(0,e.jsx)("span",{style:qe.headerSymbol,children:o})]}),n.subtitle?(0,e.jsx)("div",{style:qe.headerRight,children:(0,e.jsx)("span",{style:gr.count,children:n.subtitle})}):null]}),(0,e.jsx)("div",{style:cp.row,children:r.length===0?(0,e.jsx)("em",{style:ii.caption,children:"—"}):r.map(function(a,l){const s=m1[(a.tone||"muted").toLowerCase()]||m1.muted;return(0,e.jsxs)("div",{style:Object.assign({},cp.chip,{background:s.bg,borderColor:s.border,color:s.fg}),children:[a.glyph?(0,e.jsx)("span",{style:cp.glyph,children:a.glyph}):null,(0,e.jsx)("span",{style:cp.label,children:a.label}),a.value!=null?(0,e.jsx)("span",{style:cp.value,children:a.value}):null]},l)})})]})}var cp={row:{display:"flex",flexWrap:"wrap",gap:8,padding:"14px",fontFamily:"monospace"},chip:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:4,border:"1px solid"},glyph:{fontSize:12,fontWeight:700},label:{fontSize:9,fontWeight:700,letterSpacing:".18em",textTransform:"uppercase"},value:{fontSize:11,fontWeight:700,letterSpacing:".04em"}},h1={critical:{fg:"#C85C5C",bg:"rgba(200,92,92,0.10)",border:"rgba(200,92,92,0.45)",label:"CRITICAL"},high:{fg:"#F59E0B",bg:"rgba(245,158,11,0.10)",border:"rgba(245,158,11,0.40)",label:"HIGH"},medium:{fg:"#D4AF5C",bg:"rgba(212,175,92,0.08)",border:"rgba(212,175,92,0.30)",label:"MEDIUM"},low:{fg:"#5A7090",bg:"rgba(90,112,144,0.06)",border:"rgba(90,112,144,0.25)",label:"LOW"}},y1={unread:{fg:"#D4AF5C",label:"UNREAD"},read:{fg:"#8B949E",label:"READ"},actioned:{fg:"#4DA882",label:"ACTIONED"},dismissed:{fg:"#5A7090",label:"DISMISSED"},snoozed:{fg:"#A855F7",label:"SNOOZED"},expired:{fg:"#5A7090",label:"EXPIRED"}};function kI({artifact:t}){const n=t.payload||{},r=Array.isArray(n.items)?n.items:[],o=String(n.status||"unread").toUpperCase();return(0,e.jsxs)("div",{style:qe.card,children:[(0,e.jsxs)("div",{style:qe.header,children:[(0,e.jsxs)("div",{style:qe.headerLeft,children:[(0,e.jsx)("span",{style:qe.headerLabel,children:"ALERTS"}),(0,e.jsx)("span",{style:qe.headerSymbol,children:o})]}),(0,e.jsx)("div",{style:qe.headerRight,children:(0,e.jsxs)("span",{style:gr.count,children:[r.length," ",r.length===1?"alert":"alerts"]})})]}),r.length===0?(0,e.jsx)("div",{style:gr.emptyRow,children:(0,e.jsx)("em",{style:ii.caption,children:"Inbox clean."})}):(0,e.jsx)("ul",{style:Ia.list,children:r.map(function(a,l){return(0,e.jsx)(CI,{alert:a},a.id||l)})})]})}function CI({alert:t}){const n=h1[(t.severity||"medium").toLowerCase()]||h1.medium,r=y1[(t.status||"unread").toLowerCase()]||y1.unread,o=Array.isArray(t.actions)?t.actions:[],a=String(t.status||"").toLowerCase()==="unread";return(0,e.jsxs)("li",{style:Object.assign({},Ia.row,a?Ia.rowUnread:null),children:[(0,e.jsxs)("div",{style:Ia.metaRow,children:[(0,e.jsx)("span",{style:Object.assign({},Ia.severity,{background:n.bg,color:n.fg,borderColor:n.border}),children:n.label}),(0,e.jsx)("span",{style:Ia.type,children:String(t.type||"alert").toUpperCase().replace(/_/g," ")}),(0,e.jsx)("span",{style:Object.assign({},Ia.statusChip,{color:r.fg}),children:r.label}),t.created_at?(0,e.jsx)("span",{style:Ia.created,children:Jp(t.created_at)}):null]}),(0,e.jsx)("div",{style:Ia.headline,children:t.headline}),t.summary?(0,e.jsx)("div",{style:Ia.summary,children:t.summary}):null,o.length>0?(0,e.jsx)("div",{style:Ia.actions,children:o.slice(0,4).map(function(l,s){const c=l&&l.style==="primary";return(0,e.jsx)("span",{style:Object.assign({},Ia.actionChip,c?Ia.actionChipPrimary:null),children:l.label||l.id||"action"},l.id||s)})}):null,(0,e.jsxs)("div",{style:Ia.idRow,children:["id: ",t.id]})]})}var Ia={list:{listStyle:"none",margin:0,padding:0},row:{padding:"10px 14px",borderBottom:"1px solid rgba(212,175,92,0.06)",display:"flex",flexDirection:"column",gap:4,fontFamily:"monospace"}
404,rowUnread:{borderLeft:"2px solid #D4AF5C",background:"rgba(212,175,92,0.03)"},metaRow:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},severity:{fontSize:8,fontWeight:700,letterSpacing:".16em",padding:"2px 7px",borderRadius:3,border:"1px solid",textTransform:"uppercase"},type:{fontSize:9,color:"#8B949E",letterSpacing:".10em",fontWeight:700,textTransform:"uppercase"},statusChip:{fontSize:8,fontWeight:700,letterSpacing:".14em",marginLeft:"auto"},created:{fontSize:8,color:"#5A7090",letterSpacing:".06em"},headline:{fontSize:12,color:"#E5E7EB",lineHeight:1.45,fontWeight:600},summary:{fontSize:11,color:"#8B949E",lineHeight:1.55},actions:{display:"flex",flexWrap:"wrap",gap:6,marginTop:4},actionChip:{fontSize:9,fontWeight:700,letterSpacing:".10em",padding:"3px 8px",borderRadius:3,border:"1px solid rgba(90,112,144,0.30)",background:"rgba(90,112,144,0.08)",color:"#8B949E",textTransform:"uppercase"},actionChipPrimary:{color:"#D4AF5C",borderColor:"rgba(212,175,92,0.45)",background:"rgba(212,175,92,0.08)"},idRow:{fontSize:8,color:"#3A4A5E",fontFamily:"monospace",letterSpacing:".04em",marginTop:2}};function AI(t){return t?t.indexOf("png")!==-1?".png":t.indexOf("jpeg")!==-1?".jpg":t.indexOf("csv")!==-1?".csv":t.indexOf("json")!==-1?".json":t.indexOf("markdown")!==-1?".md":t.indexOf("text/plain")!==-1?".txt":"":""}function jI(t,n){var r=t||"artifact",o=AI(n);return!o||r.toLowerCase().endsWith(o.toLowerCase())?r:r+o}function Jp(t){try{const n=new Date(t);return isNaN(n.getTime())?String(t):n.toISOString().slice(0,16).replace("T"," ")+"Z"}catch{return String(t)}}function JE(t){return String(t).replace(/_/g," ")}var x1={BUY:{bg:"rgba(77,168,130,0.12)",fg:"#4DA882",border:"rgba(77,168,130,0.45)"},SELL:{bg:"rgba(200,92,92,0.12)",fg:"#C85C5C",border:"rgba(200,92,92,0.45)"},HOLD:{bg:"rgba(212,175,92,0.10)",fg:"#D4AF5C",border:"rgba(212,175,92,0.40)"},NO_SIGNAL:{bg:"rgba(90,112,144,0.08)",fg:"#5A7090",border:"rgba(90,112,144,0.30)"}},v1={BULLISH:{fg:"#4DA882",symbol:"▲ BULLISH"},BEARISH:{fg:"#C85C5C",symbol:"▼ BEARISH"},NEUTRAL:{fg:"#D4AF5C",symbol:"→ NEUTRAL"},NO_SIGNAL:{fg:"#3A4A5E",symbol:"— NO VIEW"}},b1={live:{bg:"rgba(77,168,130,0.12)",fg:"#4DA882",border:"rgba(77,168,130,0.40)"},shadow:{bg:"rgba(168,85,247,0.10)",fg:"#A855F7",border:"rgba(168,85,247,0.35)"},canary:{bg:"rgba(251,191,36,0.10)",fg:"#FBBF24",border:"rgba(251,191,36,0.35)"},synth:{bg:"rgba(168,85,247,0.14)",fg:"#C49AFF",border:"rgba(168,85,247,0.45)"},none:{bg:"rgba(90,112,144,0.06)",fg:"#5A7090",border:"rgba(90,112,144,0.25)"}},S1={live:{bg:"rgba(77,168,130,0.10)",fg:"#4DA882",border:"rgba(77,168,130,0.35)"},shadow_only:{bg:"rgba(168,85,247,0.10)",fg:"#A855F7",border:"rgba(168,85,247,0.35)"},synth:{bg:"rgba(168,85,247,0.14)",fg:"#C49AFF",border:"rgba(168,85,247,0.50)"},none:{bg:"rgba(90,112,144,0.08)",fg:"#5A7090",border:"rgba(90,112,144,0.30)"}},ii={figure:{margin:"12px 0",padding:"8px 12px",border:"1px solid #2a2a2a",borderRadius:6,background:"#0e0e0e"},img:{maxWidth:"100%",height:"auto",borderRadius:4},caption:{color:"#9aa",fontSize:12,marginTop:6,fontFamily:"monospace"},table:{borderCollapse:"collapse",width:"100%",fontFamily:"monospace",fontSize:12},th:{borderBottom:"1px solid #333",textAlign:"left",padding:"4px 8px",color:"#bbb"},td:{borderBottom:"1px solid #1f1f1f",padding:"4px 8px",color:"#ddd"},dl:{color:"#7af",textDecoration:"underline"}},qe={card:{margin:"12px 0",border:"1px solid rgba(212,175,92,0.18)",borderRadius:8,background:"linear-gradient(180deg, rgba(13,16,32,0.85) 0%, rgba(6,8,13,0.95) 100%)",overflow:"hidden",fontFamily:"monospace"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",borderBottom:"1px solid rgba(212,175,92,0.10)",background:"rgba(212,175,92,0.04)"},headerLeft:{display:"flex",alignItems:"center",gap:10},headerLabel:{fontSize:9,fontWeight:700,letterSpacing:".18em",color:"#D4AF5C"},headerSymbol:{fontSize:14,fontWeight:700,color:"#E5E7EB",letterSpacing:".04em"},headerAssetClass:{fontSize:8,fontWeight:700,letterSpacing:".14em",color:"#5A7090",padding:"2px 6px",border:"1px solid rgba(90,112,144,0.3)",borderRadius:3},headerRight:{},coverage:{display:"inline-block",fontSize:8,fontWeight:700,letterSpacing:".10em",padding:"3px 8px",borderRadius:3,border:"1px solid"},row:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:0},col:{padding:"12px 14px",borderRight:"1px solid rgba(212,175,92,0.06)",display:"flex",flexDirection:"column",gap:8},colEmpty:{opacity:.55},colLabel:{fontSize:8,fontWeight:700,letterSpacing:".18em",color:"#8B949E"},colHorizon:{fontSize:9,color:"#5A7090",letterSpacing:".04em"},stanceRow:{display:"flex",alignItems:"center",gap:8,marginTop:2},pill:{fontSize:9,fontWeight:700,letterSpacing:".12em",padding:"3px 9px",borderRadius:3,border:"1px solid"},barWrap:{marginTop:2},barLabelRow:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:4},barLabel:{fontSize:8,color:"#5A7090",letterSpacing:".10em"}
404,barValue:{fontSize:10,color:"#E5E7EB",fontWeight:700},barTrack:{width:"100%",height:4,background:"rgba(90,112,144,0.18)",borderRadius:2,overflow:"hidden"},barFill:{height:"100%",borderRadius:2,transition:"width 0.3s ease"},calLabel:{fontSize:7,color:"#3A4A5E",marginTop:4,letterSpacing:".04em"},metaRow:{display:"flex",alignItems:"center",gap:8,marginTop:2},statusChip:{fontSize:8,fontWeight:700,letterSpacing:".10em",padding:"2px 6px",borderRadius:3,border:"1px solid"},producer:{fontSize:8,color:"#5A7090",letterSpacing:".04em"},colRationale:{fontSize:9.5,color:"#9CA3B0",lineHeight:1.45,marginTop:4,fontStyle:"italic"},footer:{display:"flex",alignItems:"center",gap:14,padding:"8px 14px",borderTop:"1px solid rgba(212,175,92,0.06)",background:"rgba(6,8,13,0.6)"},footerItem:{fontSize:8,color:"#5A7090",letterSpacing:".06em"},footerValue:{color:"#8B949E",fontWeight:700},warnings:{display:"flex",flexWrap:"wrap",gap:6,padding:"6px 14px 10px"},warning:{fontSize:8,fontWeight:700,letterSpacing:".10em",padding:"2px 7px",borderRadius:3,background:"rgba(251,191,36,0.08)",color:"#FBBF24",border:"1px solid rgba(251,191,36,0.30)"},cardSynth:{border:"1px dashed rgba(168,85,247,0.45)",boxShadow:"0 0 0 1px rgba(168,85,247,0.10) inset"},synthStrip:{padding:"10px 14px 12px",borderTop:"1px dashed rgba(168,85,247,0.30)",background:"rgba(168,85,247,0.04)",display:"flex",flexDirection:"column",gap:6},synthHeader:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},synthBadge:{fontSize:8,fontWeight:700,letterSpacing:".14em",padding:"2px 7px",borderRadius:3,background:"rgba(168,85,247,0.12)",color:"#C49AFF",border:"1px solid rgba(168,85,247,0.45)"},synthLean:{fontSize:11,fontWeight:700,letterSpacing:".06em",color:"#E5E7EB"},synthConv:{fontSize:9,color:"#8B949E",letterSpacing:".04em"},synthRationale:{fontSize:12,color:"#C0C8D4",lineHeight:1.5,fontFamily:"system-ui, -apple-system, sans-serif"},synthEvidence:{display:"flex",flexWrap:"wrap",alignItems:"flex-start",gap:6,fontSize:9,color:"#5A7090",marginTop:2},synthEvidenceLabel:{fontSize:8,letterSpacing:".10em",color:"#5A7090",textTransform:"uppercase",marginRight:4},synthEvidenceItem:{display:"inline-flex",alignItems:"center",gap:5,padding:"2px 8px",border:"1px solid rgba(168,85,247,0.18)",borderRadius:3,background:"rgba(168,85,247,0.04)"},synthEvidenceTool:{fontSize:8.5,color:"#A87DFF",fontFamily:"ui-monospace, SFMono-Regular, monospace",fontWeight:700,letterSpacing:".04em"},synthEvidenceFinding:{fontSize:9,color:"#8B949E"}},wI=Xg({shell:"xyron"});function iu(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function TI(t){var n=String(t||"").split(`
405`),r=[],o=null,a=!1,l=[];function s(){o&&(r.push("</"+o+">"),o=null)}function c(f){return iu(f).replace(/`([^`]+)`/g,"<code>$1</code>").replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>").replace(/(^|[^*])\*([^*]+)\*/g,"$1<em>$2</em>").replace(/\[([^\]]+)\]\((?:[^)]+)\)/g,"$1")}for(var d=0;d<n.length;d++){var p=n[d];if(/^```/.test(p)){a?(r.push('<pre class="code">'+iu(l.join(`
406`))+"</pre>"),l=[],a=!1):(s(),a=!0);continue}if(a){l.push(p);continue}var g=p.match(/^(#{1,4})\s+(.*)$/);if(g){s(),r.push("<h"+g[1].length+">"+c(g[2])+"</h"+g[1].length+">");continue}if(/^\s*[-*]\s+/.test(p)){o!=="ul"&&(s(),r.push("<ul>"),o="ul"),r.push("<li>"+c(p.replace(/^\s*[-*]\s+/,""))+"</li>");continue}if(/^\s*\d+\.\s+/.test(p)){o!=="ol"&&(s(),r.push("<ol>"),o="ol"),r.push("<li>"+c(p.replace(/^\s*\d+\.\s+/,""))+"</li>");continue}if(/^\s*$/.test(p)){s();continue}s(),r.push("<p>"+c(p)+"</p>")}return a&&l.length&&r.push('<pre class="code">'+iu(l.join(`
407`))+"</pre>"),s(),r.join(`
408`)}function QE(t){return t==="markdown"||t==="code"||t==="table"}function _I(t,n){var r=t||{},o=iu(r.title||"Document"),a=iu(String(r.type||"document").toUpperCase()),l=new Date().toLocaleString("en-GB",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}),s;typeof n=="string"?s=n:r.type==="markdown"?s=TI(r.content):s='<pre class="code">'+iu(String(r.content||""))+"</pre>";var c=["*{box-sizing:border-box;}","html,body{margin:0;padding:0;background:#eceae3;}",".page{max-width:820px;margin:20px auto;background:#fff;padding:38px 46px;","  box-shadow:0 2px 18px rgba(0,0,0,0.12);font-family:Georgia,'Times New Roman',serif;color:#111;}",".head{border-bottom:2px solid #B8912E;padding-bottom:12px;margin-bottom:22px;}",".mark{font-family:Arial,Helvetica,sans-serif;font-size:11px;letter-spacing:.22em;color:#B8912E;font-weight:700;}",".title{font-size:24px;font-weight:700;margin:8px 0 3px;line-height:1.2;max-width:100%;overflow-wrap:anywhere;word-break:break-word;}",".meta{font-family:Arial,Helvetica,sans-serif;font-size:9px;letter-spacing:.06em;color:#7A7A7A;text-transform:uppercase;}",".body{font-size:13px;line-height:1.65;}",".body h1,.body h2,.body h3,.body h4{font-weight:700;margin:18px 0 7px;line-height:1.25;}",".body h1{font-size:19px;}.body h2{font-size:16px;}.body h3{font-size:14px;}",".body p{margin:0 0 10px;}.body ul,.body ol{margin:0 0 10px 22px;}.body li{margin:3px 0;}",".body code{font-family:'SF Mono',Menlo,monospace;font-size:11.5px;background:#F4F1E9;padding:1px 4px;border-radius:3px;}",".body pre.code{font-family:'SF Mono',Menlo,monospace;font-size:11px;background:#F7F5EF;border:1px solid #E7E1D2;border-radius:4px;padding:12px;white-space:pre-wrap;overflow-wrap:anywhere;}",".foot{border-top:1px solid #E0D9C8;margin-top:26px;padding-top:10px;font-family:Arial,Helvetica,sans-serif;font-size:8.5px;color:#9A9A9A;display:flex;justify-content:space-between;}","@media print{html,body{background:#fff;}.page{margin:0;max-width:none;box-shadow:none;padding:0 6mm;}@page{margin:14mm 0;size:A4;}}","@media screen{.page{padding-bottom:170px;}}"].join("");return['<!DOCTYPE html><html><head><meta charset="utf-8">','<meta name="viewport" content="width=device-width, initial-scale=1">',"<title>"+o+"</title>","<style>"+c+"</style></head><body>",'<div class="page">','<div class="head"><div class="mark">XYRON · SOVEREIGN INTELLIGENCE</div>','<div class="title">'+o+"</div>",'<div class="meta">'+a+" · Generated "+iu(l)+"</div></div>",'<div class="body">'+s+"</div>",'<div class="foot"><span>
408Xyron · A brand of Arenberg AG · Zürich, Switzerland</span><span>'+wI+"</span></div>","</div></body></html>"].join("")}function RI(t){var n=t&&t.frameRef,r=t&&t.artifact;return(0,e.jsx)("iframe",{ref:n,title:"Branded document preview",srcDoc:(0,i.useMemo)(function(){return _I(r||{})},[r]),style:{width:"100%",height:"100%",minHeight:320,border:0,background:"#eceae3",display:"block"}})}var FI=["youtube.com","www.youtube.com","m.youtube.com","youtu.be","youtube-nocookie.com","www.youtube-nocookie.com"],II=["vimeo.com","www.vimeo.com","player.vimeo.com"],DI=/\.(mp4|webm|mov|m4v)(?:$|\?)/i,OI="allow-scripts allow-same-origin allow-presentation allow-popups";function E1(t,n){t=String(t||"").toLowerCase();for(var r=0;r<n.length;r++)if(t===n[r]||t.endsWith("."+n[r]))return!0;return!1}function LI(t){var n=t.hostname.toLowerCase();if(n==="youtu.be"||n.endsWith(".youtu.be")){var r=t.pathname.replace(/^\//,"").split("/")[0];return/^[a-zA-Z0-9_-]{11}$/.test(r)?r:null}var o=t.searchParams.get("v");if(o&&/^[a-zA-Z0-9_-]{11}$/.test(o))return o;var a=t.pathname.match(/\/(?:embed|shorts)\/([a-zA-Z0-9_-]{11})/);return a?a[1]:null}function zI(t){var n=t.pathname.match(/\/(?:video\/)?(\d{6,})/);return n?n[1]:null}function dx(t){var n;try{n=new URL(String(t||"").trim())}catch{return null}var r=n.protocol.toLowerCase();if((r==="https:"||r==="blob:")&&DI.test(n.pathname+(n.search||"")))return{kind:"file",provider:"file",src:n.href,embedUrl:n.href,thumbnail:null};if(r!=="https:"&&r!=="http:")return null;if(E1(n.hostname,FI)){var o=LI(n);return o?{kind:"iframe",provider:"youtube",videoId:o,embedUrl:"https://www.youtube-nocookie.com/embed/"+o+"?rel=0&modestbranding=1",autoplayUrl:"https://www.youtube-nocookie.com/embed/"+o+"?autoplay=1&rel=0&modestbranding=1",thumbnail:"https://i.ytimg.com/vi/"+o+"/hqdefault.jpg"}:null}if(E1(n.hostname,II)){var a=zI(n);return a?{kind:"iframe",provider:"vimeo",videoId:a,embedUrl:"https://player.vimeo.com/video/"+a,autoplayUrl:"https://player.vimeo.com/video/"+a+"?autoplay=1",thumbnail:null}:null}return null}var MI=/https?:\/\/[^\s<>()"'\]]+/gi;function k1(t,n){for(var r=[],o={},a=n||6,l,s=new RegExp(MI.source,"gi");(l=s.exec(String(t||"")))!==null;){var c=l[0].replace(/[.,;]+$/,""),d=dx(c);if(d){var p=d.provider+":"+(d.videoId||d.src||c);if(!o[p]&&(o[p]=!0,r.push(Object.assign({url:c},d)),r.length>=a))break}}return r}var Y0="monospace";function Sy(t){var n=t&&t.url,r=t&&t.title||"",o=!!(t&&t.compact),a=t&&t.onOpen||function(){},l=dx(n);if(!l)return n?(0,e.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",margin:"4px 0",fontFamily:Y0,fontSize:11,color:"#6B9AC4",textDecoration:"underline"},children:n}):null;var s=l.provider==="youtube"?"YOUTUBE":l.provider==="vimeo"?"VIMEO":"VIDEO FILE";return(0,e.jsxs)("div",{onClick:function(){a(n,r)},role:"button",tabIndex:0,onKeyDown:function(c){(c.key==="Enter"||c.key===" ")&&a(n,r)},title:r||"Play video",style:{margin:o?"8px 0":8,maxWidth:o?340:"100%",position:"relative",cursor:"pointer",borderRadius:8,overflow:"hidden",border:"1px solid #1E2838",background:"#06080D",transition:"border-color .15s"},onMouseEnter:function(c){c.currentTarget.style.borderColor="rgba(212,175,92,0.4)"},onMouseLeave:function(c){c.currentTarget.style.borderColor="#1E2838"},children:[(0,e.jsxs)("div",{style:{position:"relative",width:"100%",height:o?150:200,background:"#0A0E14"},children:[l.thumbnail?(0,e.jsx)("img",{src:l.thumbnail,alt:r||"Video thumbnail",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"},onError:function(c){c.target.style.display="none"}}):(0,e.jsx)("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#5A7090",fontFamily:Y0,fontSize:11,letterSpacing:".1em"},children:s}),(0,e.jsx)("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.28)"},children:(0,e.jsx)("div",{style:{width:52,height:52,borderRadius:"50%",background:"rgba(212,175,92,0.92)",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 2px 12px rgba(0,0,0,0.4)"},children:(0,e.jsx)("div",{style:{width:0,height:0,borderLeft:"18px s
408olid #000",borderTop:"11px solid transparent",borderBottom:"11px solid transparent",marginLeft:4}})})}),(0,e.jsxs)("div",{style:{position:"absolute",top:8,left:8,padding:"2px 7px",background:"rgba(0,0,0,0.6)",border:"1px solid rgba(212,175,92,0.3)",borderRadius:4,fontFamily:Y0,fontSize:8,letterSpacing:".1em",color:"#D4AF5C"},children:["▶ ",s]})]}),r?(0,e.jsx)("div",{style:{padding:"6px 10px",fontFamily:Y0,fontSize:10,color:"#C9D1D9",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r}):null]})}var NI=Xg({shell:"xyron"}),K0="monospace",Zo={wrap:{display:"flex",flexDirection:"column",height:"100%",background:"rgba(2,4,10,0.95)",borderLeft:"1px solid rgba(212,175,92,0.2)",minWidth:320},header:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderBottom:"1px solid rgba(212,175,92,0.2)",background:"rgba(212,175,92,0.04)",flexShrink:0},badge:{padding:"2px 6px",borderRadius:3,background:"rgba(212,175,92,0.15)",color:"#D4AF5C",fontFamily:K0,fontSize:9,letterSpacing:"0.08em",fontWeight:700,textTransform:"uppercase"},title:{color:"#C5CAD2",fontSize:13,fontWeight:600,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},ctrlBtn:{background:"transparent",border:"1px solid rgba(212,175,92,0.3)",borderRadius:4,color:"#D4AF5C",fontFamily:K0,fontSize:10,padding:"4px 10px",cursor:"pointer",letterSpacing:"0.05em"},ctrlBtnDanger:{borderColor:"rgba(255,255,255,0.15)",color:"#5A6878"},versionWrap:{position:"relative"},versionMenu:{position:"absolute",top:"100%",right:0,marginTop:4,background:"#0A0E1A",border:"1px solid rgba(212,175,92,0.3)",borderRadius:4,minWidth:160,zIndex:10,overflow:"hidden"},versionItem:{display:"block",width:"100%",background:"transparent",border:0,padding:"6px 12px",fontFamily:K0,fontSize:11,color:"#C5CAD2",cursor:"pointer",textAlign:"left"},versionItemActive:{background:"rgba(212,175,92,0.1)",color:"#D4AF5C"},body:{flex:1,overflow:"auto",paddingBottom:"calc(150px + env(safe-area-inset-bottom))"},saveStatus:{fontSize:10,color:"#5A6878",fontFamily:K0,marginLeft:6}};function BI(t,n,r){var o=t&&t.type||"markdown",a=t&&t.content||"",l=t&&t.language||"text";if(QE(o))return(0,e.jsx)(RI,{artifact:t,frameRef:n});switch(o){case"markdown":return(0,e.jsx)(Wp,{content:a});case"code":return(0,e.jsx)(qp,{content:a,language:l});case"csv":return(0,e.jsx)(Ky,{content:a});case"html":return(0,e.jsx)(j2,{content:a});case"svg":return(0,e.jsx)(w2,{content:a});case"table":return(0,e.jsx)(T2,{content:a});case"react":return(0,e.jsx)(U2,{content:a});case"mermaid":return(0,e.jsx)(_2,{content:a});case"multifile":return(0,e.jsx)(W2,{content:a});case"video":return(0,e.jsx)(Sy,{url:t&&(t.url||t.content)||"",title:t&&t.title||"",onOpen:r||function(){}});case"image":return(0,e.jsx)(Xy,{artifact:t});case"chart":return(0,e.jsx)(P2,{artifact:t});default:return(0,e.jsx)(Wp,{content:a})}}var PI={markdown:"md",csv:"csv",code:"txt",html:"html",svg:"svg",table:"json",react:"jsx",mermaid:"mmd",multifile:"json",image:"png",chart:"png"},UI={python:"py",javascript:"js",typescript:"ts",jsx:"jsx",tsx:"tsx",json:"json",sql:"sql",bash:"sh",shell:"sh",yaml:"yml",html:"html",css:"css",go:"go",rust:"rs",java:"java",csharp:"cs"};function hg(t){var n=String(t&&t.title||"artifact").toLowerCase().replace(/[^a-z0-9-_ ]/g,"").trim().replace(/\s+/g,"-").slice(0,60)||"artifact",r=t&&t.type||"markdown",o=PI[r]||"txt";return r==="code"&&(o=UI[String(t&&t.language||"").toLowerCase()]||"txt"),n+"."+o}function ou(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function WI(t){if(t){if(t.type==="chart"){B2(t,hg(t));return}if(t.type==="image"){var n=t.content||t.url||t.metadata&&t.metadata.signed_url||"";if(!n)return;var r=document.createElement("a");r.href=n,r.download=hg(t),r.target="_blank",r.rel="noopener",document.body.appendChild(r),r.click(),r.remove();return}var o=t.type==="csv"?"text/csv":t.type==="html"?"text/html":t.type==="svg"?"image/svg+xml":t.type==="table"||t.type==="multifile"?"application/json":"text/plain",a=new Blob([String(t.content||"")],{type:o+";charset=utf-8"}),l=URL.createObjectURL(a),s=document.createElement("a");s.href=l,s.download=hg(t),document.body.appendChild(s),s.click(),s.remove(),setTimeout(function(){URL.revokeObjectURL(l)},4e3)}}function HI(t){var n;return t&&t.type==="chart"?n=N2(t)||String(t.content||""):t&&t.type==="image"?n=t.content||t.url||t.metadata&&t.metadata.signed_url||"":n=String(t&&t.content||""),navigator.clipboard.writeText(n)}var GI={markdown:1,html:1,code:1,table:1};function VI(t){var n=String(t||"").split(`
409`),r=[],o=null,a=!1,l=[];function s(){o&&(r.push("</"+o+">"),o=null)}function c(f){return ou(f).replace(/`([^`]+)`/g,"<code>$1</code>").replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>").replace(/(^|[^*])\*([^*]+)\*/g,"$1<em>$2</em>").replace(/\[([^\]]+)\]\((?:[^)]+)\)/g,"$1")}for(var d=0;d<n.length;d++){var p=n[d];if(/^```/.test(p)){a?(r.push('<pre class="code">'+ou(l.join(`
410`))+"</pre>"),l=[],a=!1):(s(),a=!0);continue}if(a){l.push(p);continue}var g=p.match(/^(#{1,4})\s+(.*)$/);if(g){s(),r.push("<h"+g[1].length+">"+c(g[2])+"</h"+g[1].length+">");continue}if(/^\s*[-*]\s+/.test(p)){o!=="ul"&&(s(),r.push("<ul>"),o="ul"),r.push("<li>"+c(p.replace(/^\s*[-*]\s+/,""))+"</li>");continue}if(/^\s*\d+\.\s+/.test(p)){o!=="ol"&&(s(),r.push("<ol>"),o="ol"),r.push("<li>"+c(p.replace(/^\s*\d+\.\s+/,""))+"</li>");continue}if(/^\s*$/.test(p)){s();continue}s(),r.push("<p>"+c(p)+"</p>")}return a&&l.length&&r.push('<pre class="code">'+ou(l.join(`
411`))+"</pre>"),s(),r.join(`
412`)}function YI(t,n){var r=ou(t&&t.title||"Artifact"),o=ou(String(t&&t.type||"document").toUpperCase()),a=new Date().toLocaleStr
412ing("en-GB",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}),l;return t.type==="html"?l=n.sanitize(String(t.content||""),{FORBID_TAGS:["script","iframe","object","embed","link"],FORBID_ATTR:["onerror","onload","src"]}):t.type==="markdown"?l=VI(t.content):l='<pre class="code">'+ou(String(t.content||""))+"</pre>",["<style>",'.xr-doc{font-family:Georgia,"Times New Roman",serif;color:#111;max-width:720px;margin:0 auto;}',".xr-head{border-bottom:2px solid #B8912E;padding-bottom:10px;margin-bottom:18px;}",".xr-mark{font-family:Arial,Helvetica,sans-serif;font-size:11px;letter-spacing:.22em;color:#B8912E;font-weight:700;}",".xr-title{font-size:22px;font-weight:700;margin:6px 0 2px;line-height:1.2;max-width:100%;overflow-wrap:anywhere;word-break:break-word;}",".xr-meta{font-family:Arial,Helvetica,sans-serif;font-size:9px;letter-spacing:.06em;color:#7A7A7A;text-transform:uppercase;}",".xr-body{font-size:12.5px;line-height:1.6;}",".xr-body h1,.xr-body h2,.xr-body h3,.xr-body h4{font-weight:700;margin:16px 0 6px;line-height:1.25;}",".xr-body h1{font-size:18px;}.xr-body h2{font-size:16px;}.xr-body h3{font-size:14px;}",".xr-body p{margin:0 0 9px;}.xr-body ul,.xr-body ol{margin:0 0 9px 20px;}.xr-body li{margin:2px 0;}",'.xr-body code{font-family:"SF Mono",Menlo,monospace;font-size:11px;background:#F4F1E9;padding:1px 4px;border-radius:3px;}','.xr-body pre.code{font-family:"SF Mono",Menlo,monospace;font-size:10.5px;background:#F7F5EF;border:1px solid #E7E1D2;border-radius:4px;padding:10px;white-space:pre-wrap;overflow-wrap:anywhere;}',".xr-foot{border-top:1px solid #E0D9C8;margin-top:22px;padding-top:8px;font-family:Arial,Helvetica,sans-serif;font-size:8.5px;color:#9A9A9A;display:flex;justify-content:space-between;}","</style>"].join("")+'<div class="xr-doc"><div class="xr-head"><div class="xr-mark">XYRON · SOVEREIGN INTELLIGENCE</div><div class="xr-title">'+r+'</div><div class="xr-meta">'+o+" · Generated "+ou(a)+'</div></div><div class="xr-body">'+l+'</div><div class="xr-foot"><span>Xyron · A brand of Arenberg AG · Zürich, Switzerland</span><span>'+NI+"</span></div></div>"}function KI(t){return Promise.all([xi(()=>import("./vendor-C44JUHxF.js").then(n=>Yp(n.Xn(),1)),__vite__mapDeps([0,1,2])),xi(()=>import("./vendor-C44JUHxF.js").then(n=>n.Hn),__vite__mapDeps([0,1,2]))]).then(function(n){var r=n[0].default||n[0],o=n[1].default||n[1],a=document.createElement("div");a.innerHTML=YI(t,o),a.style.position="fixed",a.style.left="-10000px",a.style.top="0",a.style.width="760px",a.style.background="#ffffff",document.body.appendChild(a);var l=hg(t).replace(/\.[a-z]+$/,"")+".pdf";function s(){try{a.parentNode&&a.parentNode.removeChild(a)}catch{}}return r().set({margin:[14,12,14,12],filename:l,html2canvas:{scale:2,useCORS:!0,windowWidth:800},jsPDF:{unit:"mm",format:"a4"},pagebreak:{mode:["css","legacy"]}}).from(a).save().then(s,function(c){throw s(),c})})}function XI(t){var n=t&&t.artifact,r=t&&t.versions||[],o=t&&t.onSelectVersion||function(){},a=t&&t.onSaveToVault||function(){},l=t&&t.onClose||function(){},s=t&&t.onOpenVideo||function(){},c=(0,i.useState)(!1),d=c[0],p=c[1],g=(0,i.useState)(""),f=g[0],h=g[1],x=(0,i.useState)(""),v=x[0],y=x[1],k=(0,i.useRef)(null);if(!n)return null;var A=QE(n.type);function j(){if(A&&k.current&&k.current.contentWindow)try{k.current.contentWindow.focus(),k.current.contentWindow.print(),y("");return}catch{}y("pdf"),KI(n).then(function(){y("")}).catch(function(){y("pdferr"),setTimeout(function(){y("")},3e3)})}
412var E=String(n.type||"markdown").toUpperCase(),C=n.version||1;function _(){h("saving"),Promise.resolve(a(n)).then(function(){h("saved"),setTimeout(function(){h("")},2500)}).catch(function(){h("error"),setTimeout(function(){h("")},4e3)})}function w(){p(function(M){return!M})}function O(M){p(!1),o(M)}return(0,e.jsxs)("div",{style:Zo.wrap,children:[(0,e.jsxs)("div",{style:Zo.header,children:[(0,e.jsx)("span",{style:Zo.badge,children:E}),(0,e.jsx)("span",{style:Zo.title,title:n.title||"Artifact",children:n.title||"Artifact"}),r&&r.length>1&&(0,e.jsxs)("div",{style:Zo.versionWrap,children:[(0,e.jsxs)("button",{type:"button",style:Zo.ctrlBtn,onClick:w,children:["v",C," ▾"]}),d&&(0,e.jsx)("div",{style:Zo.versionMenu,children:r.slice(0,5).map(function(M,U){var ee=(M&&M.id)===(n&&n.id);return(0,e.jsxs)("button",{type:"button",style:Object.assign({},Zo.versionItem,ee?Zo.versionItemActive:{}),onClick:function(){O(M)},children:["v",M.version||1]},U)})})]}),(0,e.jsx)("button",{type:"button",style:Zo.ctrlBtn,title:"Copy artifact contents",onClick:function(){HI(n).then(function(){y("copied"),setTimeout(function(){y("")},2e3)}).catch(function(){})},children:v==="copied"?"COPIED":"COPY"}),(0,e.jsx)("button",{type:"button",style:Zo.ctrlBtn,title:"Download artifact file",onClick:function(){WI(n)},children:"DL"}),A||GI[n.type]?(0,e.jsx)("button",{type:"button",style:Zo.ctrlBtn,title:A?"Print / Save as PDF":"Export as PDF",onClick:j,children:v==="pdf"?"PDF…":v==="pdferr"?"PDF ✗":"PDF"}):null,(0,e.jsx)("button",{type:"button",style:Zo.ctrlBtn,onClick:_,children:f==="saving"?"SAVING…":f==="saved"?"SAVED":f==="error"?"ERROR":"SAVE"}),(0,e.jsx)("button",{type:"button",style:Object.assign({},Zo.ctrlBtn,Zo.ctrlBtnDanger),onClick:l,children:"✕"})]}),(0,e.jsx)("div",{style:Zo.body,children:BI(n,k,s)})]})}var Yc="monospace",jo={wrap:{background:"#0d1117",border:"1px solid rgba(212,175,92,0.18)",borderRadius:6,padding:10,margin:"8px 0",fontFamily:Yc,fontSize:11,color:"#C9D1D9"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"pointer",userSelect:"none"},headerLabel:{color:"#D4AF5C",fontFamily:Yc,fontSize:10,letterSpacing:1},toggle:{color:"#D4AF5C",fontFamily:Yc,fontSize:10,border:"1px solid rgba(212,175,92,0.3)",background:"transparent",borderRadius:4,padding:"2px 8px",cursor:"pointer"},body:{marginTop:8},sectionLabel:{fontFamily:Yc,fontSize:9,letterSpacing:1,marginTop:8,marginBottom:4},codeBlock:{background:"#05080F",border:"1px solid rgba(212,175,92,0.10)",borderRadius:4,padding:8,overflow:"auto",whiteSpace:"pre",color:"#E6EDF3",fontFamily:Yc,fontSize:11,lineHeight:1.5},outBlock:{background:"#0a0d14",border:"1px solid rgba(80,180,160,0.15)",borderRadius:4,padding:8,overflow:"auto",whiteSpace:"pre-wrap",color:"#C9D1D9",fontFamily:Yc,fontSize:11,lineHeight:1.4},errBlock:{background:"#15080a",border:"1px solid rgba(220,80,80,0.25)",borderRadius:4,padding:8,overflow:"auto",whiteSpace:"pre-wrap",color:"#F4A6A6",fontFamily:Yc,fontSize:11,lineHeight:1.4},stdoutLabel:{color:"#50B4A0"},stderrLabel:{color:"#E0625F"},fileChip:{display:"inline-block",margin:"0 6px 6px 0",padding:"4px 10px",background:"rgba(212,175,92,0.08)",border:"1px solid rgba(212,175,92,0.25)",borderRadius:4,fontFamily:Yc,fontSize:10,color:"#D4AF5C"}};function qI(t){if(!t||typeof t!="string")return!1;var n=t.toLowerCase();return n.indexOf(".png")!==-1||n.indexOf(".jpg")!==-1||n.indexOf(".jpeg")!==-1||n.indexOf(".svg")!==-1||n.indexOf(".gif")!==-1}function $I(t){var n=t.file||{},r=n.url||(n.base64?"data:image/png;base64,"+n.base64:null),o=n.name||n.file_id||"artifact";return r&&qI(o)?(0,e.jsx)("img",{src:r,alt:o,style:{maxWidth:"100%",marginTop:6,border:"1px solid rgba(212,175,92,0.18)",borderRadius:4}}):r?(0,e.jsxs)("a",{href:r,download:o,style:jo.fileChip,children:[o," ↓"]}):(0,e.jsx)("span",{style:jo.fileChip,title:"file_id: "+(n.file_id||""),children:o})}function JI(t){var n=t.trace||{},r=(0,i.useState)(t.initiallyExpanded!==!1),o=r[0],a=r[1],l=n.code||"",s=n.language||"python",c=n.stdout||"",d=n.stderr||"",p=Array.isArray(n.files)?n.files:[];function g(){a(!o)}return(0,e.jsxs)("div",{style:jo.wrap,children:[(0,e.jsxs)("div",{style:jo.header,onClick:g,children:[(0,e.jsxs)("span",{style:jo.headerLabel,children:["CODE EXECUTION · ",s.toUpperCase()]}),(0,e.jsx)("button",{type:"button",style:jo.toggle,onClick:function(f){f.stopPropagation(),g()},children:o?"HIDE":"SHOW"})]}),o&&(0,e.jsxs)("div",{style:jo.body,children:[l&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:jo.sectionLabel,children:(0,e.jsx)("span",{style:jo.headerLabel,children:"CODE"})}),(0,e.jsx)("pre",{style:jo.codeBlock,children:l})]}),c&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:jo.sectionLabel,children:(0,e.jsx)("span",{style:jo.stdoutLabel,children:"STDOUT"})}),(0,e.jsx)("pre",{style:jo.outBlock,children:c})]}),d&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:jo.sectionLabel,children:(0,e.jsx)("span",{style:jo.stderrLabel,children:"STDERR"})}),(0,e.jsx)("pre",{style:jo.errBlock,children:d})]}),p.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:jo.sectionLabel,children:(0,e.jsx)("span",{style:jo.headerLabel,children:"ARTIFACTS"})}),(0,e.jsx)("div",{children:p.map(function(f,h){return(0,e.jsx)($I,{file:f},h)})})]})]})]})}var C1="monospace",Jd={wrap:{marginTop:12,padding:"10px 12px",borderLeft:"2px s
412olid #D4AF5C",background:"rgba(255,255,255,0.02)",borderRadius:4,fontSize:12},toggle:{display:"flex",alignItems:"center",gap:8,background:"transparent",border:0,cursor:"pointer",color:"#8A95A3",fontFamily:C1,fontSize:12,padding:0,width:"100%",textAlign:"left"},icon:{color:"#D4AF5C"},label:{textTransform:"uppercase",letterSpacing:"0.05em"},meta:{marginLeft:"auto",color:"#5A6878",fontSize:10},preview:{marginTop:6,color:"#5A6878",fontStyle:"italic",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},content:{fontFamily:C1,fontSize:11,color:"#8A95A3",whiteSpace:"pre-wrap",wordBreak:"break-word",margin:"8px 0 0",lineHeight:1.5}};function QI(t){var n=t.trace||{},r=(0,i.useState)(!1),o=r[0],a=r[1],l=n.content||"";if(!l)return null;var s=Math.round(l.length/4),c=l.length>100?l.slice(0,100):l;function d(){a(!o)}return(0,e.jsxs)("div",{style:Jd.wrap,children:[(0,e.jsxs)("button",{type:"button",style:Jd.toggle,onClick:d,children:[(0,e.jsx)("span",{style:Jd.icon,children:o?"▼":"▶"}),(0,e.jsx)("span",{style:Jd.label,children:"THINKING"}),(0,e.jsxs)("span",{style:Jd.meta,children:["~",s," tokens"]})]}),!o&&(0,e.jsx)("div",{style:Jd.preview,children:c}),o&&(0,e.jsx)("pre",{style:Jd.content,children:l})]})}var ZI=16e3,eD={PCM16_16K:16e3,PCM16_24K:24e3,PCM16_48K:48e3};function tD(t){return typeof t!="string"?ZI:eD[t.trim().toUpperCase()]||16e3}function nD(){return typeof window<"u"&&!!(window.AudioContext||window.webkitAudioContext)&&!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)}function rD(t){for(var n="",r=0;r<t.length;r++)n+=String.fromCharCode(t[r]);return btoa(n)}function iD(t){for(var n=atob(t),r=new Uint8Array(n.length),o=0;o<n.length;o++)r[o]=n.charCodeAt(o);return r}function oD(t){for(var n=new Uint8Array(t.length*2),r=new DataView(n.buffer),o=0;o<t.length;o++){var a=Math.max(-1,Math.min(1,t[o]));r.setInt16(o*2,a<0?a*32768:a*32767,!0)}return n}function aD(t){for(var n=new DataView(t.buffer,t.byteOffset,t.byteLength),r=Math.floor(t.byteLength/2),o=new Float32Array(r),a=0;a<r;a++){var l=n.getInt16(a*2,!0);o[a]=l/(l<0?32768:32767)}return o}var lD="@keyframes sonicPulse {0% { transform: scale(1); opacity: .55; }70% { transform: scale(1.55); opacity: 0; }100% { transform: scale(1.55); opacity: 0; } }@keyframes sonicGlow {0%,100% { box-shadow: 0 0 18px 2px rgba(63,185,80,0.45); }50% { box-shadow: 0 0 34px 8px rgba(63,185,80,0.75); } }@keyframes sonicBar {0%,100% { transform: scaleY(0.35); }50% { transform: scaleY(1); } }";function sD(t){var n=t.voice||"",r=!!t.compact,o=t.onSwitchToDeep||null,a=(0,i.useState)("idle"),l=a[0],s=a[1],c=(0,i.useState)(""),d=c[0],p=c[1],g=(0,i.useState)(""),f=g[0],h=g[1],x=(0,i.useState)(!1),v=x[0],y=x[1],k=(0,i.useRef)(null),A=(0,i.useRef)(null),j=(0,i.useRef)(null),E=(0,i.useRef)(null),C=(0,i.useRef)(null),_=(0,i.useRef)(null),w=(0,i.useRef)(0),O=(0,i.useRef)([]),M=(0,i.useRef)(null),U=(0,i.useRef)(!1),ee=(0,i.useRef)(0),N=nD(),V=(0,i.useCallback)(function(){try{E.current&&E.current.disconnect()}catch{}try{C.current&&C.current.disconnect()}catch{}try{A.current&&A.current.getTracks().forEach(function(ve){ve.stop()})}catch{}try{j.current&&j.current.close()}catch{}E.current=null,C.current=null,A.current=null,j.current=null},[]),z=(0,i.useCallback)(function(){var ve=O.current;O.current=[],ve.forEach(function($e){try{$e.stop()}catch{}});var Ne=_.current;w.current=Ne?Ne.currentTime:0,M.current&&(clearTimeout(M.current),M.current=null)},[]),oe=(0,i.useCallback)(function(){z();try{_.current&&_.current.close()}catch{}_.current=null,w.current=0},[z]),P=(0,i.useCallback)(function(){var ve=k.current;if(ve){try{ve.close()}catch{}k.current=null}},[]),W=(0,i.useCallback)(function(ve,Ne){var $e=_.current;if(!$e)try{$e=new(window.AudioContext||window.webkitAudioContext),_.current=$e,w.current=$e.currentTime}catch{return}var Pe=aD(ve);if(Pe.length){var ot=$e.createBuffer(1,Pe.length,Ne||24e3);ot.copyToChannel(Pe,0,0);var re=$e.createBufferSource();re.buffer=ot,re.connect($e.destination);var we=$e.currentTime,b=Math.max(we,w.current);re.start(b),w.current=b+ot.duration,O.current.push(re),re.onended=function(){var tt=O.current.indexOf(re);tt>=0&&O.current.splice(tt,1)},s(function(tt){return tt==="listening"||tt==="speaking"?"speaking":tt}
412),M.current&&clearTimeout(M.current);var He=Math.max(120,(w.current-we)*1e3+160);M.current=setTimeout(function(){M.current=null,s(function(tt){return tt==="speaking"?"listening":tt})},He)}},[]),R=(0,i.useCallback)(function(){var ve=k.current;if(ve&&ve.readyState===1)try{ve.send(JSON.stringify({type:"stop"}))}catch{}V(),oe(),P(),y(!1),U.current=!1,s("idle")},[V,oe,P]),ae=(0,i.useCallback)(async function(){if(h(""),p(""),!N){s("error"),h("Microphone / AudioContext not available.");return}s("connecting");try{var ve=await navigator.mediaDevices.getUserMedia({audio:{sampleRate:16e3,channelCount:1,echoCancellation:!0,noiseSuppression:!0}});A.current=ve;var Ne=new(window.AudioContext||window.webkitAudioContext)({sampleRate:16e3});j.current=Ne;var $e=Ne.createMediaStreamSource(ve);C.current=$e;var Pe=Ne.createScriptProcessor(4096,1,1);E.current=Pe;var ot=new WebSocket(VA("/api/xyron/voice/sonic-stream"));ot.binaryType="arraybuffer",k.current=ot;var re=!1;ot.onopen=function(){re=!0;try{var we={type:"start"};n&&(we.voice=n),ot.send(JSON.stringify(we))}catch{}s("listening")},ot.onmessage=function(we){var b;try{b=JSON.parse(we.data)}catch{return}
412var He=b&&b.type;if(He!=="ready"){if(He==="audio_chunk"){W(iD(b.b64||""),tD(b.encoding));return}if(He==="text_delta"){p(function(tt){return(tt+" "+(b.text||"")).trim().slice(-400)});return}if(He==="interrupted"){!U.current&&Date.now()-ee.current<700&&(z(),s(function(tt){return tt==="idle"?tt:"listening"}));return}if(He==="turn_complete"){s(function(tt){return tt==="speaking"||tt==="idle"?tt:"listening"});return}if(He!=="tool_use"){if(He==="session_end"){R();return}if(He==="cancelled"){s("listening");return}if(He==="error"){s("error"),h(b.message||"error");return}}}},ot.onerror=function(){s("error"),h("Sonic connection lost.")},ot.onclose=function(){k.current=null,s(function(we){return we==="error"?we:"idle"})},Pe.onaudioprocess=function(we){if(!(!re||!ot||ot.readyState!==1)&&!U.current){for(var b=we.inputBuffer.getChannelData(0),He=0,tt=0;tt<b.length;tt+=8)He+=b[tt]*b[tt];Math.sqrt(He/(b.length/8))>.02&&(ee.current=Date.now());var Ae=new Float32Array(b.length);Ae.set(b);var Be=rD(oD(Ae));try{ot.send(JSON.stringify({type:"audio_chunk",b64:Be}))}catch{}}},$e.connect(Pe),Pe.connect(Ne.destination)}catch(we){s("error"),h(we&&we.message||"Microphone error."),V(),P()}},[n,N,W,z,V,P,R]),q=(0,i.useCallback)(function(){y(function(ve){return U.current=!ve,!ve})},[]),ge=(0,i.useCallback)(function(){if(l==="idle"||l==="error"){ae();return}R()},[l,ae,R]);(0,i.useEffect)(function(){return function(){V(),oe(),P()}},[V,oe,P]),(0,i.useEffect)(function(){function ve($e){if(!$e)return!1;var Pe=($e.tagName||"").toUpperCase();return Pe==="INPUT"||Pe==="TEXTAREA"||$e.isContentEditable}function Ne($e){$e.code!=="Space"||$e.repeat||ve($e.target)||(l==="listening"||l==="speaking")&&($e.preventDefault(),q())}return window.addEventListener("keydown",Ne),function(){window.removeEventListener("keydown",Ne)}},[l,q]);var X=l==="listening"||l==="speaking",de=r?56:84,We={idle:"#D4AF5C",connecting:"#D4AF5C",listening:"#D4AF5C",speaking:"#3FB950",error:"#C85C5C"}[l]||"#D4AF5C",te={idle:"Tap to start a live conversation",connecting:"Connecting…",listening:v?"Muted — tap MIC to resume":"Listening — just speak",speaking:"Speaking — talk to interrupt",error:f||"Tap the orb to retry"}[l],_e=[0,1,2,3,4].map(function(ve){return(0,e.jsx)("span",{style:{width:3,borderRadius:2,background:"#3FB950",height:r?14:20,transformOrigin:"center",animation:"sonicBar 0.9s ease-in-out "+ve*.12+"s infinite"}},ve)});return(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:10,padding:r?"12px 14px":"18px 20px",background:"#06080D",border:"1px solid #1A2A40",borderRadius:8,fontFamily:"monospace",minWidth:r?180:240},children:[(0,e.jsx)("style",{children:lD}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,alignSelf:"stretch"},children:[(0,e.jsx)("span",{style:{padding:"1px 6px",background:"rgba(212,175,92,0.10)",border:"1px solid rgba(212,175,92,0.40)",borderRadius:3,color:"#D4AF5C",fontSize:8,fontWeight:700,letterSpacing:".15em"},children:"FAST"}),(0,e.jsx)("span",{style:{color:"#5BA8A0",fontSize:9,fontWeight:600,letterSpacing:".10em"},children:"SONIC · LIVE"}),o&&(0,e.jsxs)("button",{onClick:o,title:"Switch to deep voice (full Xyron intelligence, spoken)",style:{marginLeft:"auto",padding:"1px 8px",background:"transparent",border:"1px solid #2A3548",borderRadius:3,cursor:"pointer",fontFamily:"monospace",fontSize:8,color:"#7A8A9E",letterSpacing:".15em",fontWeight:700},children:["DEEP ","→"]})]}),(0,e.jsxs)("div",{style:{position:"relative",width:de,height:de,margin:"4px 0"},children:[l==="listening"&&!v&&(0,e.jsx)("span",{style:{position:"absolute",inset:0,borderRadius:"50%",border:"2px solid "+We,animation:"sonicPulse 1.8s ease-out infinite"}}),l==="listening"&&!v&&(0,e.jsx)("span",{style:{position:"absolute",inset:0,borderRadius:"50%",border:"2px solid "+We,animation:"sonicPulse 1.8s ease-out 0.6s infinite"}}),(0,e.jsx)("button",{onClick:ge,disabled:!N||l==="connecting",title:X?"End the conversation":"Start a live conversation",style:{position:"absolute",inset:0,borderRadius:"50%",border:"1px solid "+We,cursor:N?"pointer":"not-allowed",display:"flex",alignItems:"center",justifyContent:"center",background:l==="speaking"?"radial-gradient(circle at 35% 30%, #103a1c, #0a0e16 70%)":"radial-gradient(circle at 35% 30%, #2a2410, #0a0e16 70%)",animation:l==="speaking"?"sonicGlow 1.4s ease-in-out infinite":"none",opacity:l==="connecting"?.6:1},children:l==="speaking"?(0,e.jsx)("span",{style:{display:"flex",alignItems:"center",gap:3},children:_e}):(0,e.jsxs)("svg",{width:r?18:26,height:r?18:26,viewBox:"0 0 24 24",fill:"none",stroke:We,strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,e.jsx)("path",{d:"M12 2a3 3 0 0 0-3 3v6a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"}),(0,e.jsx)("path",{d:"M19 10v1a7 7 0 0 1-14 0v-1"}),(0,e.jsx)("line",{x1:"12",y1:"18",x2:"12",y2:"22"})]})})]}),(0,e.jsx)("div",{style:{color:l==="error"?"#C85C5C":"#7A8A9E",fontSize:r?9:10,letterSpacing:".05em",textAlign:"center",minHeight:14},children:te}),X&&(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,e.jsx)("button",{onClick:q,title:"Mute / unmute (Space)",style:{padding:"3px 12px",background:v?"rgba(200,92,92,0.12)":"transparent",border:"1px solid "+(v?"#C85C5C":"#2A3548"),borderRadius:4,cursor:"pointer",fontFamily:"monospace",fontSize:8,fontWeight:700,letterSpacing:".12em",color:v?"#C85C5C":"#7A8A9E"}
412,children:v?"UNMUTE":"MUTE"}),(0,e.jsx)("button",{onClick:R,title:"End the conversation",style:{padding:"3px 12px",background:"rgba(200,92,92,0.10)",border:"1px solid #C85C5C",borderRadius:4,cursor:"pointer",fontFamily:"monospace",fontSize:8,fontWeight:700,letterSpacing:".12em",color:"#C85C5C"},children:"END"})]}),d&&(0,e.jsx)("div",{style:{alignSelf:"stretch",color:"#AEB9C8",fontSize:r?9:10,lineHeight:1.5,maxHeight:54,overflow:"hidden",borderTop:"1px solid #131C2B",paddingTop:6},children:d})]})}function cD(t){var n="/api/video/feed?query="+encodeURIComponent(t)+"&limit=5&mode=auto",r="";try{r=localStorage.getItem("xyron_jwt_token")||""}catch{r=""}var o={"X-Xyron-Key":""};return r&&(o.Authorization="Bearer "+r),VT(qr(n),{method:"GET",headers:o},1e4).then(function(a){if(!a.ok||!a.data)return Ah(t);var l=a.data.videos||[];return l.length===0?Ah(t):l.map(function(s){return{title:s.title||"",provider:s.source==="bloomberg"?"Bloomberg TV":"YouTube",channel:s.author||"",description:(s.description||"").substring(0,200),thumbnail:s.thumbnail||"https://img.youtube.com/vi/"+(s.videoId||"")+"/hqdefault.jpg",url:s.url||"",embedUrl:s.url&&s.videoId&&s.source==="youtube"?"https://www.youtube-nocookie.com/embed/"+s.videoId:""}})}).catch(function(){return Ah(t)})}function Ah(t){var n=!1;try{n=!1}catch{n=!1}if(!n)return[];var r=t.toLowerCase();return r.match(/bond|yield|fixed income|treasury/)?[{title:"The Yield Curve Explained in 5 Minutes",provider:"YouTube",channel:"The Plain Bagel",description:"Clear visual breakdown of normal, flat, and inverted yield curves.",thumbnail:"https://img.youtube.com/vi/bItazfbSptI/hqdefault.jpg",url:"https://www.youtube.com/watch?v=bItazfbSptI",embedUrl:"https://www.youtube-nocookie.com/embed/bItazfbSptI"},{title:"How Bonds Work — Pricing, Yields, and Duration",provider:"YouTube",channel:"Khan Academy",description:"Fundamentals of bond pricing and duration risk.",thumbnail:"https://img.youtube.com/vi/Pxu2NXMC5IU/hqdefault.jpg",url:"https://www.youtube.com/watch?v=Pxu2NXMC5IU",embedUrl:"https://www.youtube-nocookie.com/embed/Pxu2NXMC5IU"}]:r.match(/hedge fund|hedging|alternative/)?[{title:"How Hedge Funds Actually Work",provider:"YouTube",channel:"Patrick Boyle",description:"Inside look at hedge fund structures, fees, and strategies.",thumbnail:"https://img.youtube.com/vi/qGzRm2vQuqE/hqdefault.jpg",url:"https://www.youtube.com/watch?v=qGzRm2vQuqE",embedUrl:"https://www.youtube-nocookie.com/embed/qGzRm2vQuqE"}]:r.match(/inflation|macro|economy|recession/)?[{title:"How Inflation Actually Works",provider:"YouTube",channel:"Economics Explained",description:"Mechanics of inflation, CPI measurement, and central bank targets.",thumbnail:"https://img.youtube.com/vi/F94jGTWNWcA/hqdefault.jpg",url:"https://www.youtube.com/watch?v=F94jGTWNWcA",embedUrl:"https://www.youtube-nocookie.com/embed/F94jGTWNWcA"}]:[]}var dp="monospace";function dD(t){var n=t&&t.url,r=t&&t.title||"",o=(0,i.useState)(!1),a=o[0],l=o[1];function s(){l(!1),t&&t.onClose&&t.onClose()}if(!n)return null;var c=dx(n);if(!c)return null;var d=c.provider==="youtube"?"YouTube":c.provider==="vimeo"?"Vimeo":"Video",p=a?"96vw":"min(80vw, 900px)",g=a?"88vh":"80vh";return(0,Uy.createPortal)((0,e.jsx)("div",{onClick:s,role:"dialog","aria-modal":"true",onKeyDown:function(f){f.key==="Escape"&&s()},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.82)",zIndex:1e5,display:"flex",alignItems:"center",justifyContent:"center",padding:a?12:24},children:(0,e.jsxs)("div",{onClick:function(f){f.stopPropagation()},style:{position:"relative",width:p,maxWidth:"96vw",display:"flex",flexDirection:"column",background:"#06080D",border:"1px solid #2A3548",borderRadius:10,overflow:"hidden",boxShadow:"0 10px 50px rgba(0,0,0,0.6)"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"8px 12px",borderBottom:"1px solid #1E2838",flexShrink:0},children:[(0,e.jsxs)("span",{style:{fontFamily:dp,fontSize:8,letterSpacing:".1em",color:"#D4AF5C",background:"rgba(212,175,92,0.12)",border:"1px solid rgba(212,175,92,0.25)",borderRadius:4,padding:"2px 6px",flexShrink:0},children:["▶ ",d.toUpperCase()]}),(0,e.jsx)("span",{style:{fontFamily:dp,fontSize:11,color:"#E6EDF3",fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0},children:r||d+" video"}),(0,e.jsx)("button",{onClick:function(f){f.stopPropagation(),l(function(h){return!h})},title:a?"Shrink":"Expand / full-screen",style:{padding:"4px 9px",background:"transparent",border:"1px solid rgba(212,175,92,0.3)",borderRadius:5,cursor:"pointer",fontFamily:dp,fontSize:10,
412color:"#D4AF5C",flexShrink:0},children:a?"⤡ SHRINK":"⤢ EXPAND"}),(0,e.jsx)("button",{onClick:s,title:"Close",style:{padding:"4px 11px",background:"rgba(200,92,92,0.12)",border:"1px solid rgba(200,92,92,0.35)",borderRadius:5,cursor:"pointer",fontFamily:dp,fontSize:10,color:"#C85C5C",flexShrink:0},children:"✕"})]}),(0,e.jsx)("div",{style:{width:"100%",aspectRatio:"16 / 9",maxHeight:g,background:"#000"},children:c.kind==="file"?(0,e.jsx)("video",{src:c.src,controls:!0,autoPlay:!0,playsInline:!0,style:{width:"100%",height:"100%",border:"none",background:"#000",objectFit:"contain"}}):(0,e.jsx)("iframe",{src:c.autoplayUrl||c.embedUrl,title:r||d+" video",sandbox:OI,allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen",allowFullScreen:!0,referrerPolicy:"strict-origin-when-cross-origin",style:{width:"100%",height:"100%",border:"none"}})}),(0,e.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",padding:"6px 12px",borderTop:"1px solid #1E2838",flexShrink:0},children:(0,e.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",onClick:function(f){f.stopPropagation()},style:{fontFamily:dp,fontSize:9,color:"#5A7090",textDecoration:"none"},children:"Open source ↗"})})]})}),document.body)}var uD={signal_card:!0,chart:!0};function fD(t){if(!Array.isArray(t))return[];for(var n=[],r={},o=0;o<t.length;o++){var a=t[o];if(!a||!uD[a.kind]){n.push(a);continue}var l=a.payload||{},s=String(l.symbol||a.title||"").trim().toUpperCase();if(!s){n.push(a);continue}var c=a.kind+":"+s;Object.prototype.hasOwnProperty.call(r,c)?n[r[c]]=a:(r[c]=n.length,n.push(a))}return n}function pD(t){var n=t&&t.propsSessionId,r=t&&t.loadedSessionId,o=t&&t.selfCreatedSe
412ssionId;return n?n===r?{action:"noop"}:n===o&&!r?{action:"adopt"}:{action:"reload"}:{action:"reset"}}var A1="ROOM_TRANSCRIPT_UNAVAILABLE: Room transcript could not be loaded. Try again.";function gD(t,n){var r=t&&t.messages;if(n&&!Array.isArray(r)){var o=new Error("room_transcript_unavailable");throw o.kind="room_transcript_unavailable",o}return Array.isArray(r)?r:null}function mD(t,n,r){return!Array.isArray(t)||!n||typeof r!="function"?!1:(r(t,n),!0)}var bz=200*1024;function hD(t){if(!t||typeof t!="object")return t;var n=t.content;if(typeof n!="string"||n.length<=204800)return t;var r={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&o!=="content"&&(r[o]=t[o]);return r.content="",r.truncated=!0,r}function yD(t){if(!t||typeof t!="object")return null;var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return Array.isArray(t.artifacts)&&(n.artifacts=t.artifacts.map(hD)),n}function xD(t){if(!t||typeof t!="object")return t;var n={id:t.id,role:t.role,content:t.text||t.content||"",ts:t.ts||""},r=yD(t.msgMetadata);return r&&(n.msgMetadata=r),t.chart&&(n.chart=t.chart),Array.isArray(t.toolArtifacts)&&t.toolArtifacts.length>0&&(n.toolArtifacts=t.toolArtifacts),t.citations&&(n.citations=t.citations),t.imageUrl&&(n.imageUrl=t.imageUrl),t.roomId&&(n.roomId=t.roomId),t.roomContextVersion!=null&&(n.roomContextVersion=t.roomContextVersion),t.roomStale&&(n.roomStale=!0),t.roomSuperseded&&(n.roomSuperseded=!0),t.roomPersistencePending&&(n.roomPersistencePending=!0),n}function j1(t,n){if(!t||typeof t!="object")return t;var r=t.ts||"";if(!r&&t.created_at)try{r=new Date(t.created_at).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})}catch{r=""}var o={id:t.id||n||"m"+Date.now()+Math.random(),role:t.role,text:t.content||t.text||"",ts:r},a=t.msgMetadata||t.msg_metadata;if(a&&typeof a=="object"&&!Array.isArray(a)){var l=!1;for(var s in a)if(Object.prototype.hasOwnProperty.call(a,s)){l=!0;break}l&&(o.msgMetadata=a)}t.chart&&(o.chart=t.chart),Array.isArray(t.toolArtifacts)&&t.toolArtifacts.length>0&&(o.toolArtifacts=t.toolArtifacts),t.citations&&(o.citations=t.citations),t.imageUrl&&(o.imageUrl=t.imageUrl);var c=t.roomId!=null?t.roomId:t.room_id;c&&(o.roomId=c);var d=t.roomContextVersion!=null?t.roomContextVersion:t.room_context_version;return d!=null&&(o.roomContextVersion=d),(t.roomStale||t.room_stale)&&(o.roomStale=!0),(t.roomSuperseded||t.room_superseded||a&&(a.roomSuperseded||a.room_superseded))&&(o.roomSuperseded=!0),(t.roomPersistencePending||t.room_persistence_pending||a&&(a.roomPersistencePending||a.room_persistence_pending))&&(o.roomPersistencePending=!0),o}function vD(t){var n=String(t||"");return!n||n.indexOf("msg-")===0}function bD(t){var n=String(t&&t.title||"Xyron Brief").trim();return n=n.replace(/^#+\s*/,"").replace(/…$/,"").trim(),n||"Xyron Brief"}function SD(t){return t&&typeof t.content=="string"&&t.content.trim()?t.content:""}function ED(t){var n=t||{},r=n.artifact,o=n.messageId,a=n.postArtifact,l=n.saveText;if(!r)return Promise.reject(new Error("invalid artifact"));var s=SD(r);function c(){return s?typeof l!="function"?Promise.reject(new Error("save failed")):Promise.resolve(l(bD(r),String(r.type||"markdown"),s,["chat-artifact","split-view"])).then(function(d){if(!d||!d.id)throw new Error("save failed");return d}):Promise.reject(new Error("nothing to save"))}return vD(r.id)||!o||typeof a!="function"?c():Promise.resolve(a(o,r.id)).then(function(d){return d},function(d){var p=d&&(d.status||d.statusCode),g=String(d&&d.message||d||"");if(p===404||/404|not found/i.test(g))return c();throw d})}function kD(t){var n=String(t||"");return/^Generating image/i.test(n)?"image":/^Rendering chart/i.test(n)?"chart":null}var w1={image:["Composing the scene…","Lighting pass…","Refining detail…","Final render…"],chart:["Reading the numbers…","Laying out the axes…","Drawing the series…","Final render…"]},CD=6e3;function AD(t,n){var r=Math.max(0,Math.floor((n-t)/1e3)),o=Math.floor(r/60),a=r%60;return(o<10?"0"+o:""+o)+":"+(a<10?"0"+a:""+a)}var Qd="JetBrains Mono, ui-monospace, monospace",T1=!1;function jD(){if(!(T1||typeof document>"u")){T1=!0;var t=document.createElement("style");t.id="xgen-card-styles",t.textContent="@keyframes xgenSweep{0%{transform:translateX(-140%) skewX(-18deg)}100%{transform:translateX(360%) skewX(-18deg)}}@keyframes xgenScan{0%{transform:translateY(0)}100%{transform:translateY(33.34%)}}@keyframes xgenBreathe{0%,100%{opacity:.65}50%{opacity:1}}@keyframes xgenPulse{0%,100%{opacity:.55;transform:scale(.985)}50%{opacity:1;transform:scale(1.015)}}@keyframes xgenBar{0%{transform:translateX(-110%)}100%{transform:translateX(400%)}}@keyframes xgenCaptionIn{0%{opacity:0;transform:translateY(3px)}100%{opacity:1;transform:translateY(0)}}@keyframes xgenRevealOut{0%{opacity:1}100%{opacity:0}
412}@media (prefers-reduced-motion: reduce){[data-xgen-anim]{animation:none !important}}",document.head.appendChild(t)}}var _1="linear-gradient(135deg,#070A10 0%,#0B0F14 55%,#0A0E14 100%)",zr={card:{marginTop:10,width:"100%",maxWidth:640,border:"1px solid rgba(212,175,92,0.22)",borderRadius:8,background:"#0B0F14",overflow:"hidden"},header:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",borderBottom:"1px solid rgba(212,175,92,0.14)",background:"rgba(212,175,92,0.05)"},chip:{padding:"2px 6px",borderRadius:3,background:"rgba(212,175,92,0.15)",color:"#D4AF5C",fontFamily:Qd,fontSize:8,letterSpacing:".08em",fontWeight:700},headerLabel:{flex:1,minWidth:0,fontFamily:Qd,fontSize:8,color:"#7A90A8",letterSpacing:".16em"},timer:{fontFamily:Qd,fontSize:10,color:"#D4AF5C",letterSpacing:".12em",fontVariantNumeric:"tabular-nums"},canvas:{position:"relative",aspectRatio:"16 / 9",background:_1,overflow:"hidden"},scan:{position:"absolute",left:0,right:0,top:"-200%",height:"300%",backgroundImage:"repeating-linear-gradient(0deg, rgba(120,160,200,0.05) 0px, rgba(120,160,200,0.05) 1px, transparent 1px, transparent 5px)",animation:"xgenScan 16s linear infinite"},sweep:{position:"absolute",top:"-40%",bottom:"-40%",left:0,width:"45%",background:"linear-gradient(75deg, transparent 0%, rgba(212,175,92,0.05) 35%, rgba(212,175,92,0.14) 50%, rgba(64,194,200,0.07) 65%, transparent 100%)",animation:"xgenSweep 5.5s cubic-bezier(.4,0,.2,1) infinite"},vignette:{position:"absolute",inset:0,background:"radial-gradient(ellipse at 50% 42%, transparent 30%, rgba(3,5,9,0.6) 100%)",animation:"xgenBreathe 6s ease-in-out infinite"},center:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:10},mark:{fontWeight:900,fontSize:22,letterSpacing:"-.04em",color:"#D4AF5C",textShadow:"0 0 24px rgba(212,175,92,0.35)",animation:"xgenPulse 3.2s ease-in-out infinite"},caption:{fontFamily:Qd,fontSize:9,letterSpacing:".18em",textTransform:"uppercase",color:"#8FA3B8",animation:"xgenCaptionIn .6s ease"},barTrack:{position:"relative",height:2,background:"rgba(212,175,92,0.10)",overflow:"hidden"},barShimmer:{position:"absolute",top:0,bottom:0,left:0,width:"34%",background:"linear-gradient(90deg, transparent, #D4AF5C, transparent)",animation:"xgenBar 1.9s ease-in-out infinite"},errorTitle:{fontFamily:Qd,fontSize:10,fontWeight:700,letterSpacing:".18em",color:"#E07585"},errorBody:{fontFamily:Qd,fontSize:10,lineHeight:1.5,color:"#E07585",maxWidth:"82%",textAlign:"center",wordBreak:"break-word"},retryHint:{fontFamily:Qd,fontSize:8,letterSpacing:".14em",color:"#7A90A8"},revealWrap:{position:"relative"},revealOverlay:{position:"absolute",inset:0,zIndex:2,pointerEvents:"none",borderRadius:8,overflow:"hidden",background:_1,animation:"xgenRevealOut .9s ease .12s forwards"}};function X0(t){var n=t.phase||"generating",r=t.kind==="chart"?"chart":"image",o=t.startedAt||Date.now();jD();var a=(0,i.useState)(Date.now()),l=a[0],s=a[1];(0,i.useEffect)(function(){if(n==="generating"){var y=setInterval(function(){s(Date.now())},1e3);return function(){clearInterval(y)}}},[n]);var c=w1[r]||w1.image,d=(0,i.useState)(0),p=d[0],g=d[1];(0,i.useEffect)(function(){if(n==="generating"){var y=setInterval(function(){g(function(k){return Math.min(k+1,c.length-1)})},CD);return function(){clearInterval(y)}}},[n,r]);var f=(0,i.useState)(!1),h=f[0],x=f[1],v=r==="chart"?"CHART":"IMAGE";return n==="reveal"?(0,e.jsxs)("div",{style:zr.revealWrap,"data-testid":"generation-card-reveal",children:[t.children,!h&&(0,e.jsxs)("div",{style:zr.revealOverlay,"data-xgen-anim":!0,onAnimationEnd:function(){x(!0)},children:[(0,e.jsx)("div",{style:{...zr.vignette,animation:"none"}}),(0,e.jsx)("div",{style:zr.center,children:(0,e.jsx)("div",{style:{...zr.mark,animation:"none"},children:"XYRON"})})]})]}):n==="error"?(0,e.jsxs)("div",{style:zr.card,"data-testid":"generation-card-error",children:[(0,e.jsxs)("div",{style:zr.header,children:[(0,e.jsx)("span",{style:zr.chip,children:v}),(0,e.jsx)("span",{style:{...zr.headerLabel,color:"#E07585"},children:"GENERATION FAILED"})]}),(0,e.jsxs)("div",{style:{...zr.canvas,aspectRatio:"auto",minHeight:120},children:[(0,e.jsx)("div",{style:{...zr.vignette,animation:"none"}}),(0,e.jsxs)("div",{style:{...zr.center,position:"relative",padding:"18px 12px"},children:[(0,e.jsx)("div",{style:zr.errorTitle,children:r==="chart"?"CHART RENDER FAILED":"IMAGE GENERATION FAILED"}),t.error?(0,e.jsx)("div",{style:zr.errorBody,children:String(t.error)}):null,(0,e.jsx)("div",{style:zr.retryHint,children:"RETRY — send the request again to regenerate"})]})]})]}):(0,e.jsxs)("div",{style:zr.card,"data-testid":"generation-card",children:[(0,e.jsxs)("div",{style:zr.header,children:[(0,e.jsx)("span",{style:zr.chip,children:v}),(0,e.jsx)("span",{style:zr.headerLabel,children:r==="chart"?"RENDERING CHART":"GENERATING IMAGE"}),(0,e.jsx)("span",{style:zr.timer,"data-testid":"generation-card-timer",children:AD(o,l)})]}),(0,e.jsxs)("div",{style:zr.canvas,children:[(0,e.jsx)("div",{style:zr.scan,"data-xgen-anim":!0}),(0,e.jsx)("div",{style:zr.sweep,"data-xgen-anim":!0}),(0,e.jsx)("div",{style:zr.vignette,"data-xgen-anim":!0}),(0,e.jsxs)("div",{style:zr.center,children:[(0,e.jsx)("div",{style:zr.mark,"data-xgen-anim":!0,children:"XYRON"}),(0,e.jsx)("div",{style:zr.caption,"data-xgen-anim":!0,children:c[p]},"st"+p)]})]}),(0,e.jsx)("div",{style:zr.barTrack,children:(0,e.jsx)("div",{style:zr.barShimmer,"data-xgen-anim":!0})})]})}var jh="<xyron_artifact",R1="</xyron_artifact>";function q0(t){if(t=String(t||""),t.indexOf("<")===-1)return t;t=t.replace(/<xyron_artifact\b[^>]*>[\s\S]*?<\/xyron_artifact>/g,""),t=t.replace(/<\/xyron_artifact>/g,"");var n=t.indexOf(jh);if(n!==-1)return t.slice(0,n);var r=t.lastIndexOf("<");if(r!==-1){var o=t.slice(r);if(o.length<jh.length&&jh.indexOf(o)===0||o.length<R1.length&&R1.indexOf(o)===0)return t.slice(0,r)}return t}var Qa="monospace";function wD(t){var n=t.onClose||function(){},r=!!t.embedded,o=t.onAudit||function(){},a=t.onPlaced||function(){},l=t.positions,s=(0,i.useMemo)(function(){return l||[]},[l]),c=t.mandate||null,d=t.drawdown,p=(0,i.useMemo)(function(){return d||{drawdown:0}},[d]),g=t.prefill||{},f=(0,i.useState)(null),h=f[0],x=f[1],v=(0,i.useState)(""),y=v[0],k=v[1],A=(0,i.useState)(g.symbol||""),j=A[0],E=A[1],C=(0,i.useState)(g.side||"BUY"),_=C[0],w=C[1],O=(0,i.useState)(g.quantity?String(g.quantity):""),M=O[0],U=O[1],ee=(0,i.useState)("MARKET"),N=ee[0],V=ee[1],z=(0,i.useState)(""),oe=z[0],P=z[1],W=(0,i.useState)("DAY"),R=W[0],ae=W[1],q=(0,i.useState)(""),ge=q[0],X=q[1],de=(0,i.useState)(!1),We=de[0],te=de[1],_e=(0,i.useState)(!1),ve=_e[0],Ne=_e[1],$e=(0,i.useState)(null),Pe=$e[0],ot=$e[1],re=(0,i.useState)(null),we=re[0],b=re[1];(0,i.useEffect)(function(){var Ie=!0;return Ma.connected().then(function(Q){if(Ie){var rt=Q&&(Q.brokers||Q.connected)||[];x(rt),rt.length===1&&k(rt[0].broker_id||rt[0].id||"")}}).catch(function(){Ie&&x([])}),function(){Ie=!1}},[x,k]);var He=(h||[]).find(function(Ie){return(Ie.broker_id||Ie.id)===y})||null,tt=He?String(He.mode||He.env||"paper").toLowerCase():"paper",Ae=tt!=="paper"&&tt!=="sandbox",Be=s.find(function(Ie){return(Ie.instrument||Ie.symbol||"").toUpperCase()===j.trim().toUpperCase()}),Fe=N==="LIMIT"&&Number(oe)?Number(oe):Be?Number(Be.px):0,ft=(0,i.useMemo)(function(){return!j.trim()||!Number(M)||!Fe?{newBreaches:[]}:Aj(s,{symbol:j.trim().toUpperCase(),side:_==="BUY"?"BUY":"SELL",quantity:Number(M),price:Fe,assetClass:Be?Be.assetClass:"equity"},c,p)},[s,j,_,M,Fe,c,p,Be]),St=ft.newBreaches.length>0,Xe=!!y&&!!j.trim()&&Number(M)>0&&(N!=="LIMIT"||Number(oe)>0)&&ge.trim().toUpperCase()===j.trim().toUpperCase()&&(!St||We)&&!ve;function It(){if(Xe){var Ie={broker_id:y,symbol:j.trim().toUpperCase(),side:_,quantity:Number(M),order_type:N,time_in_force:R};N==="LIMIT"&&(Ie.limit_price=Number(oe)),St&&o("portfolio.order_mandate_override",Ie.symbol+" — "+ft.newBreaches.map(function(Q){return Q.text}).join("; ")),o("portfolio.order_submitted",y+" ["+tt.toUpperCase()+"] "+Ie.side+" "+Ie.quantity+" "+Ie.symbol+" "+N+(Ie.limit_price?"@"+Ie.limit_price:"")),Ne(!0),b(null),Ma.placeOrder(Ie).then(function(Q){if(!Q)throw new Error("no response from broker lane");if(Q.error)throw new Error(Q.error);ot(Q),o("portfolio.order_result",Ie.symbol+" "+(Q.status||(Q.success?"OK":"REJECTED"))+(Q.exec_price?" @ "+Q.exec_price:"")+" via "+(Q.broker||y)+" ["+(Q.mode||tt)+"]"),Q.success&&a(Q)}).catch(function(Q){b(Q&&Q.message||"order failed"),o("portfolio.order_result",Ie.symbol+" FAILED — "+(Q&&Q.message||"unknown"))}).finally(function(){Ne(!1)})}}function Rt(Ie){Ie&&(Ie.preventDefault&&Ie.preventDefault(),Ie.stopPropagation&&Ie.stopPropagation()),ve||n()}var $={background:"#0D1020",border:"1px solid #1E2838",borderRadius:5,padding:"7px 9px",color:"#C9D1D9",fontSize:12,outline:"none",fontFamily:Qa},Ue={fontFamily:Qa,fontSize:8,color:"#5A7090",letterSpacing:".12em",marginBottom:4};return(0,e.jsx)("div",{style:r?xs.embedded:xs.overlay,onClick:function(Ie){r||Ie.target===Ie.currentTarget&&!ve&&(Ie.stopPropagation(),n())},children:(0,e.jsxs)("div",{style:r?xs.embeddedSheet:xs.sheet,children:[(0,e.jsxs)("div",{style:xs.head,children:[(0,e.jsx)("span",{style:{fontFamily:Qa,fontSize:10,
412color:"#D4AF5C",letterSpacing:".14em",fontWeight:700},children:"ORDER TICKET"}),He&&(0,e.jsx)("span",{style:{fontFamily:Qa,fontSize:8,fontWeight:700,letterSpacing:".1em",padding:"3px 8px",borderRadius:4,color:Ae?"#E07070":"#3FB950",border:"1px solid "+(Ae?"rgba(200,92,92,0.6)":"rgba(63,185,80,0.4)")},children:Ae?"● LIVE FUNDS":"PAPER / SANDBOX"}),(0,e.jsx)("span",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",onMouseDown:function(Ie){Ie.stopPropagation()},onClick:Rt,disabled:ve,"aria-label":"Close order ticket",title:"Close order ticket",style:{background:"none",border:"none",color:"#5A7090",cursor:"pointer",fontSize:16},children:"×"})]}),(0,e.jsxs)("div",{style:{padding:"14px 18px",overflowY:"auto"},children:[h===null&&(0,e.jsx)("div",{style:xs.info,children:"Loading connected brokers…"}),h!==null&&h.length===0&&(0,e.jsx)("div",{style:xs.warn,children:"No connected brokers. Connect one in the BROKERS tab first — orders route only through your own connected accounts."}),h!==null&&h.length>0&&!Pe&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{style:{marginBottom:12},children:[(0,e.jsx)("div",{style:Ue,children:"BROKER"}),(0,e.jsxs)("select",{value:y,onChange:function(Ie){k(Ie.target.value)},style:Object.assign({},$,{width:"100%"}),children:[(0,e.jsx)("option",{value:"",children:"Select connected broker…"}),h.map(function(Ie){var Q=Ie.broker_id||Ie.id;return(0,e.jsx)("option",{value:Q,children:(Ie.label||Q)+" · "+String(Ie.mode||"paper").toUpperCase()},Q)})]})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:10,marginBottom:12},children:[(0,e.jsxs)("div",{style:{flex:1},children:[(0,e.jsx)("div",{style:Ue,children:"SYMBOL"}),(0,e.jsx)("input",{value:j,onChange:function(Ie){E(Ie.target.value.toUpperCase())},placeholder:"NVDA",style:Object.assign({},$,{width:"100%",boxSizing:"border-box"})})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:Ue,children:"SIDE"}),(0,e.jsx)("div",{style:{display:"flex",gap:4},children:["BUY","SELL"].map(function(Ie){var Q=_===Ie;return(0,e.jsx)("button",{onClick:function(){w(Ie)},style:{padding:"7px 14px",borderRadius:5,cursor:"pointer",fontFamily:Qa,fontSize:10,fontWeight:700,border:"1px solid "+(Q?Ie==="BUY"?"#3FB950":"#C85C5C":"#1E2838"),background:Q?Ie==="BUY"?"rgba(63,185,80,0.12)":"rgba(200,92,92,0.12)":"transparent",color:Q?Ie==="BUY"?"#3FB950":"#E07070":"#5A7090"},children:Ie},Ie)})})]})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:10,marginBottom:12},children:[(0,e.jsxs)("div",{style:{flex:1},children:[(0,e.jsx)("div",{style:Ue,children:"QUANTITY"}),(0,e.jsx)("input",{value:M,inputMode:"decimal",onChange:function(Ie){U(Ie.target.value)},style:Object.assign({},$,{width:"100%",boxSizing:"border-box"})})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:Ue,children:"TYPE"}),(0,e.jsxs)("select",{value:N,onChange:function(Ie){V(Ie.target.value)},style:$,children:[(0,e.jsx)("option",{value:"MARKET",children:"MARKET"}),(0,e.jsx)("option",{value:"LIMIT",children:"LIMIT"})]})]}),N==="LIMIT"&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:Ue,children:"LIMIT PRICE"}),(0,e.jsx)("input",{value:oe,inputMode:"decimal",onChange:function(Ie){P(Ie.target.value)},style:Object.assign({},$,{width:100})})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:Ue,children:"TIF"}),(0,e.jsxs)("select",{value:R,onChange:function(Ie){ae(Ie.target.value)},style:$,children:[(0,e.jsx)("option",{value:"DAY",children:"DAY"}),(0,e.jsx)("option",{value:"GTC",children:"GTC"})]})]})]}),Fe>0&&ft.newBreaches.length>0&&(0,e.jsxs)("div",{style:xs.warn,children:[(0,e.jsxs)("div",{style:{fontWeight:700,marginBottom:4},children:["⚠ PRE-TRADE CHECK — this order would create"," ",ft.newBreaches.length," new mandate breach",ft.newBreaches.length===1?"":"es",":"]}),ft.newBreaches.map(function(Ie){return(0,e.jsxs)("div",{children:["· ",Ie.text]},Ie.id)}),(0,e.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,marginTop:8,cursor:"pointer"},children:[(0,e.jsx)("input",{type:"checkbox",checked:We,onChange:function(Ie){te(Ie.target.checked)}}),(0,e.jsx)("span",{style:{fontFamily:Qa,fontSize:9}
412,children:"Override mandate — this acknowledgment is written to the audit trail"})]})]}),Fe===0&&j.trim()&&Number(M)>0&&N==="MARKET"&&!Be&&(0,e.jsx)("div",{style:xs.info,children:"Pre-trade mandate simulation unavailable for a symbol not in the book at MARKET — no live reference price. The order itself is unaffected."}),(0,e.jsxs)("div",{style:{marginTop:6,marginBottom:12},children:[(0,e.jsx)("div",{style:Ue,children:"TYPE THE SYMBOL TO ARM SUBMIT"}),(0,e.jsx)("input",{value:ge,onChange:function(Ie){X(Ie.target.value.toUpperCase())},placeholder:j||"SYMBOL",style:Object.assign({},$,{width:160,borderColor:Xe?"#3FB950":"#1E2838"})})]}),we&&(0,e.jsxs)("div",{style:xs.warn,children:["Order failed: ",we]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[(0,e.jsx)("button",{type:"button",onMouseDown:function(Ie){Ie.stopPropagation()},onClick:Rt,disabled:ve,style:{padding:"8px 16px",background:"transparent",border:"1px solid #1E2838",borderRadius:6,cursor:"pointer",fontFamily:Qa,fontSize:9,color:"#5A7090"},children:"CANCEL"}),(0,e.jsx)("button",{type:"button",onClick:It,disabled:!Xe,style:{padding:"8px 22px",borderRadius:6,cursor:Xe?"pointer":"not-allowed",fontFamily:Qa,fontSize:10,fontWeight:800,letterSpacing:".08em",border:"none",background:Xe?Ae?"#C85C5C":"#3FB950":"#141E2A",color:Xe?"#000":"#3A4A5E"},children:ve?"SUBMITTING…":Ae?"SUBMIT — LIVE FUNDS":"SUBMIT "+(tt||"paper").toUpperCase()})]})]}),Pe&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:Qa,fontSize:12,fontWeight:800,color:Pe.success?"#3FB950":"#E07070",marginBottom:8},children:Pe.success?"✓ ORDER "+(Pe.status||"ACCEPTED"):"✕ ORDER "+(Pe.status||"REJECTED")}),(0,e.jsxs)("div",{style:{fontFamily:Qa,fontSize:10,color:"#8FA3BF",lineHeight:1.7},children:[_," ",M," ",j," via ",Pe.broker||y," [",(Pe.mode||tt).toUpperCase(),"]",Pe.exec_price?(0,e.jsxs)("div",{children:["Fill price: ",Pe.exec_price]}):null,!Pe.success&&Pe.order&&(0,e.jsx)("div",{style:{color:"#E07070"},children:JSON.stringify(Pe.order).slice(0,240)})]}),(0,e.jsx)("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:14},children:(0,e.jsx)("button",{type:"button",onMouseDown:function(Ie){Ie.stopPropagation()},onClick:Rt,style:{padding:"8px 18px",background:"rgba(212,175,92,0.1)",border:"1px solid rgba(212,175,92,0.35)",borderRadius:6,cursor:"pointer",fontFamily:Qa,fontSize:9,color:"#D4AF5C",fontWeight:700},children:"DONE"})})]})]})]})})}var xs={overlay:{position:"fixed",inset:0,zIndex:480,background:"rgba(3,5,8,0.72)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center"},embedded:{position:"relative",display:"flex",flex:1,minHeight:0,alignItems:"stretch",justifyContent:"stretch",background:"transparent"},embeddedSheet:{width:"100%",maxHeight:"none",display:"flex",flexDirection:"column",flex:1,minHeight:0,background:"transparent",border:"none",borderRadius:0,boxShadow:"none",overflow:"hidden"},sheet:{width:"min(520px, 94%)",maxHeight:"84vh",display:"flex",flexDirection:"column",background:"rgba(8,11,17,0.97)",border:"1px solid #1E2838",borderTop:"1px solid #9E7E35",borderRadius:5,boxShadow:"0 30px 80px rgba(0,0,0,0.75)",overflow:"hidden"},head:{padding:"13px 18px",borderBottom:"1px solid #111828",display:"flex",alignItems:"center",gap:10,background:"#0A0D18",flexShrink:0},info:{fontFamily:Qa,fontSize:9,color:"#5A7090",lineHeight:1.6,padding:"8px 10px",border:"1px solid #1E2838",borderRadius:6,marginBottom:12},warn:{fontFamily:Qa,fontSize:9,color:"#E07070",lineHeight:1.7,padding:"9px 12px",border:"1px solid rgba(200,92,92,0.45)",background:"rgba(200,92,92,0.07)",borderRadius:6,marginBottom:12}},on="monospace",TD=2e4;function Yi(t){var n=Number(t)||0,r=n<0?"-":"";return n=Math.abs(n),n>=1e9?r+"$"+(n/1e9).toFixed(2)+"B":n>=1e6?r+"$"+(n/1e6).toFixed(2)+"M":n>=1e3?r+"$"+(n/1e3).toFixed(1)+"K":r+"$"+n.toFixed(0)}var _D=["POSITIONS","RISK","ATTRIBUTION","MANDATE","BROKERS","AI DESK"];function RD(t){var n=t.positions,r=(0,i.useState)(null),o=r[0],a=r[1],l=typeof t.onPositionsChange=="function",s=t.onPositionsChange,c=(0,i.useMemo)(function(){return n&&n.length?n:o||n||[]},[n,o]),d=(0,i.useMemo)(function(){return l?s:a},[l,s,a]),p=t.onAudit,g=(0,i.useMemo)(function(){return p||function(){}},[p]),f=t.onAddVaultDoc||function(){},h=t.onNavigateRooms||function(){},x=(0,i.useState)("POSITIONS"),v=x[0],y=x[1],k=(0,i.useState)(c.length?"SESSION":"EMPTY"),A=k[0],j=k[1],E=(0,i.useState)(null),C=E[0],_=E[1],w=(0,i.useState)({}),O=w[0],M=w[1],U=(0,i.useState)(Cg),ee=U[0],N=U[1],V=(0,i.useState)(yj),z=V[0],oe=V[1],P=(0,i.useState)(vj),W=P[0],R=P[1],ae=(0,i.useState)(!1),q=ae[0],ge=ae[1],X=(0,i.useState)(!1),de=X[0],We=X[1],te=(0,i.useState)({open:!1,prefill:{}}),_e=te[0],ve=te[1],Ne=(0,i.useState)(function(){try{return!!(Vn&&Vn.hasApiKey&&Vn.hasApiKey())}catch{return!1}}),$e=Ne[0],Pe=Ne[1],ot=(0,i.useState)(!1),re=ot[0],we=ot[1];function b(){re||(we(!0),Vn.enableWithMintedKey("xyron-portfolio-auto").then(function(fe){fe&&fe.ok?(Pe(!0),g("portfolio.api_key_minted","durable book enabled (prefix "+(fe.prefix||"?")+")"),$(!0)):g("portfolio.api_key_mint_failed",fe&&fe.error||"unknown")}).catch(function(){}).finally(function(){we(!1)}))}
412var He=(0,i.useState)(!1),tt=He[0],Ae=He[1],Be=(0,i.useRef)({}),Fe=(0,i.useRef)(!1),ft=(0,i.useRef)(null),St=(0,i.useRef)(c);St.current=c;function Xe(fe){Qh(fe);try{if(!(Vn&&Vn.hasApiKey&&Vn.hasApiKey()))return;var Ye=(fe||[]).filter(function(Qe){return Qe&&Qe.source!=="macro"&&Qe.source!=="forex"}).map(sj).filter(Boolean);if(!Ye.length)return;ft.current&&clearTimeout(ft.current),ft.current=setTimeout(function(){Vn.ingestPositions(Ye).catch(function(){})},250)}catch{}}function It(fe,Ye,Qe){d(fe),Qh(fe),j(Ye),_(Qe||new Date().toISOString()),Ye!=="BACKEND"&&Xe(fe)}function Rt(){return Ma.connected().then(function(fe){var Ye=fe&&fe.brokers||[];return Ye.length?Promise.all(Ye.map(function(Qe){var ut=Qe.broker_id||Qe.broker||Qe.id;return ut?Ma.positions(ut).then(function(wt){var H=wt&&wt.positions||[];return Array.isArray(H)||(H=[]),{id:ut,rows:dj(H,ut)}}).catch(function(){return{id:ut,rows:[]}}):Promise.resolve({id:"",rows:[]})})).then(function(Qe){for(var ut=[],wt=[],H=0;H<Qe.length;H++){var Z=Qe[H]||{};Z.id&&wt.push(Z.id),ut=ut.concat(Z.rows||[])}return{rows:ut,accountIds:wt}}):{rows:[],accountIds:[]}}).catch(function(){return{rows:[],accountIds:[]}})}function $(fe){try{var Ye=!!(Vn&&Vn.hasApiKey&&Vn.hasApiKey());Ae(!0);var Qe=Ye?Vn.listPositions({}).catch(function(){return null}):Promise.resolve(null);Promise.all([Qe,Rt()]).then(function(ut){var wt=ut[0],H=ut[1]||{rows:[],accountIds:[]},Z=H.rows||[],T=H.accountIds||[],Y=KS(wt&&wt.positions||[]),B=vv(),ie=B&&B.positions||St.current||[],ue=Y.length>0?gj(Y,ie):ie.slice(),ne=uj(ue,Z,T),Me=new Date().toISOString();T.length>0?(It(ne,Y.length?"BACKEND+BROKER":"BROKER",Me),g("portfolio.hydrated",Z.length+" broker + "+(ne.length-Z.length)+" other positions")):Y.length?(It(ue,"BACKEND",Me),g("portfolio.hydrated",ue.length+" positions from backend book")):Ye?(It([],"BACKEND",Me),fe&&g("portfolio.refresh_empty","backend book returned no positions")):fe&&g("portfolio.refresh_empty","no connected broker positions (and no cortex-alpha API key)")}).catch(function(){}).finally(function(){Ae(!1)})}catch{Ae(!1)}}(0,i.useEffect)(function(){if(!Fe.current){if(Fe.current=!0,!c.length){var fe=vv();fe&&fe.positions.length&&(d(fe.positions),j("CACHED"),_(fe.asOf))}$(!1);try{Vn&&Vn.hasApiKey&&Vn.hasApiKey()&&Vn.bookHistory(370).then(function(Ye){var Qe=Ye&&Ye.history||[];Qe.length&&N(wj(Cg(),Qe))}).catch(function(){})}catch{}}},[]);var Ue=(0,i.useMemo)(function(){var fe={},Ye=[];return(c||[]).forEach(function(Qe){var ut=Qe&&(Qe.instrument||Qe.symbol);!ut||fe[ut]||(fe[ut]=!0,Ye.push(ut))}),Ye.slice(0,40)},[c]);(0,i.useEffect)(function(){if(!Ue.length)return;var fe=!0;function Ye(){Ue.forEach(function(ut){wf.quote(ut).then(function(wt){if(!(!fe||!wt)){var H=wt.price!=null?wt.price:wt.last;H!=null&&M(function(Z){var T=Object.assign({},Z);return T[ut]={price:Number(H)},T})}}).catch(function(){})})}Ye();var Qe=setInterval(Ye,TD);return function(){fe=!1,clearInterval(Qe)}},[Ue,M]);var Ie=(0,i.useMemo)(function(){return JS(pj(c,O))},[c,O]),Q=(0,i.useMemo)(function(){return zp(Ie)},[Ie]),rt=(0,i.useMemo)(function(){return Ie.filter(function(fe){return fe._liveQuote}).length},[Ie]);(0,i.useEffect)(function(){Q.count&&N(mj(Q))},[Q,N]);var jt=(0,i.useMemo)(function(){return hj(ee,Q.count?Q.pnl:null)},[ee,Q]),tn=(0,i.useMemo)(function(){return Zh(Q,z,jt)},[Q,z,jt]);(0,i.useEffect)(function(){tn.forEach(function(fe){Be.current[fe.id]||(Be.current[fe.id]=!0,g("portfolio.mandate_breach",fe.text))})},[tn,g]),(0,i.useEffect)(function(){if(!(!Q.count||!W.length)){var fe=bj(W,Ie,jt);fe.fired.length&&(R(Sv(fe.rules)),fe.fired.forEach(function(Ye){g("portfolio.alert_triggered",Ye.type+" "+Ye.value+(Ye.detail?" — "+Ye.detail:""))}))}},[Ie,jt,W,Q.count,g,R]);var pt=W.filter(function(fe){return fe.triggeredAt});function gt(){return[{role:"assistant",content:["PORTFOLIO PACK — "+new Date().toISOString().slice(0,10),"Book source: "+A+(C?" · as of "+C.slice(0,16).replace("T"," "):""),"Positions: "+Q.count+" ("+Q.longCount+" long / "+Q.shortCount+" short)","Gross exposure: "+Yi(Q.gross)+" · Net: "+Yi(Q.net),"Unrealised P&L: "+Yi(Q.pnl)+" · Drawdown from peak: "+Yi(jt.drawdown),"FX (non-USD) exp
412osure: "+Q.fxExposurePct.toFixed(1)+"%","","TOP CONCENTRATION:"].concat(Q.topConcentration.map(function(fe){return"- "+fe.symbol+" "+fe.weightPct.toFixed(1)+"% ("+fe.side+", P&L "+Yi(fe.pnl)+")"}),["","MANDATE BREACHES:"+(tn.length?"":" none")],tn.map(function(fe){return"- ["+fe.severity+"] "+fe.text}),["","POSITIONS:"],Ie.map(function(fe){return"- "+(fe.instrument||fe.symbol)+" "+fe.side+" "+fe.size+" @ "+fe.entry+" → "+fe.px+" · P&L "+Yi(fe.pnl)+(fe._liveQuote?" (live)":" (book)")})).join(`
413`)}]}function qt(fe){var Ye="Portfolio Pack — "+new Date().toISOString().slice(0,10);fe==="docx"?k_(gt(),Ye,t.currentUser,t.workspace):eE(gt(),Ye,t.currentUser,t.workspace),g("export.portfolio_pack",fe)}function Pt(){f({name:"Portfolio Pack — "+new Date().toISOString().slice(0,10),type:"FINANCE",size:"",status:"SAVED",date:new Date().toISOString().slice(0,10),tags:["portfolio","pack"],content:gt()[0].content}),g("portfolio.pack_saved_to_vault",Q.count+" positions")}function Kt(fe){D_(fe)&&h()}var xe=function(fe,Ye,Qe){return(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:2,minWidth:110},children:[(0,e.jsx)("span",{style:{fontFamily:on,fontSize:8,color:"#5A7090",letterSpacing:".12em"},children:fe}),(0,e.jsx)("span",{style:{fontFamily:on,fontSize:15,color:Qe||"#C9D1D9",fontWeight:700},children:Ye})]})};return(0,e.jsxs)("div",{style:rn.wrap,children:[(0,e.jsxs)("div",{style:rn.head,children:[(0,e.jsx)("div",{style:{fontFamily:on,fontSize:11,color:"#D4AF5C",letterSpacing:".16em",fontWeight:700,flexShrink:0},children:"PORTFOLIO"}),xe("GROSS EXPOSURE",Yi(Q.gross)),xe("NET",Yi(Q.net)),xe("UNREALISED P&L",Yi(Q.pnl),Q.pnl>=0?"#3FB950":"#C85C5C"),xe("DRAWDOWN FROM PEAK",Yi(jt.drawdown),jt.drawdown>0?"#C85C5C":"#3FB950"),(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:3,minWidth:130},children:[(0,e.jsx)("span",{style:{fontFamily:on,fontSize:8,color:"#5A7090",letterSpacing:".12em"},children:"BOOK"}),(0,e.jsxs)("span",{style:{fontFamily:on,fontSize:8,color:"#8FA3BF"},children:[A,C?" · "+C.slice(5,16).replace("T"," "):""," · LIVE"," ",rt,"/",Q.count]})]}),(0,e.jsx)("span",{style:{flex:1}}),tn.length>0&&(0,e.jsxs)("span",{style:rn.breachBadge,title:tn.map(function(fe){return fe.text}).join(`
414`),onClick:function(){y("MANDATE")},children:["⚠ ",tn.length," MANDATE BREACH",tn.length===1?"":"ES"]}),(0,e.jsxs)("div",{style:{position:"relative"},children:[(0,e.jsxs)("button",{style:Object.assign({},rn.actBtn,pt.length?rn.actAlert:null),onClick:function(){ge(!q),We(!1)},children:["⚑ ALERTS",W.length?" ("+W.length+")":""]}),q&&(0,e.jsx)(OD,{rules:W,onChange:function(fe){R(Sv(fe))},onAudit:g})]}),(0,e.jsx)("button",{style:rn.actBtn,disabled:tt,onClick:function(){$(!0)},children:tt?"…":"⟳ REFRESH"}),!$e&&(0,e.jsx)("button",{style:Object.assign({},rn.actBtn,{border:"1px solid rgba(94,234,212,0.5)",color:"#5EEAD4",background:"rgba(94,234,212,0.08)"}),disabled:re,title:"Creates a personal API key over your logged-in session so imports, hydration and history persist server-side. The key is stored in this browser only.",onClick:b,children:re?"ENABLING…":"⚿ ENABLE DURABLE BOOK"}),(0,e.jsx)("button",{style:Object.assign({},rn.actBtn,{border:"1px solid rgba(63,185,80,0.45)",color:"#3FB950",background:"rgba(63,185,80,0.08)"}),onClick:function(){ve({open:!0,prefill:{}}),g("portfolio.order_prepared","blank ticket")},children:"⚡ TRADE"}),(0,e.jsxs)("div",{style:{position:"relative"},children:[(0,e.jsx)("button",{style:rn.actBtn,onClick:function(){We(!de),ge(!1)},children:"⇩ PACK ▾"}),de&&(0,e.jsxs)("div",{style:rn.menu,children:[(0,e.jsx)("div",{style:rn.menuItem,onClick:function(){We(!1),qt("pdf")},children:"EXPORT PDF"}),(0,e.jsx)("div",{style:rn.menuItem,onClick:function(){We(!1),qt("docx")},children:"EXPORT DOCX"}),(0,e.jsx)("div",{style:rn.menuItem,onClick:function(){We(!1),Pt()},children:"SAVE TO VAULT"})]})]})]}),(0,e.jsxs)("div",{style:rn.tabs,children:[_D.map(function(fe){var Ye=v===fe;return(0,e.jsx)("button",{onClick:function(){y(fe)},style:Object.assign({},rn.tabBtn,Ye?rn.tabOn:null),children:fe},fe)}),(0,e.jsx)("span",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontFamily:on,fontSize:8,color:"#3A4A5E",letterSpacing:".08em"},children:"All analytics computed client-side from your book · directional predictions are not offered"})]}),(0,e.jsxs)("div",{style:{flex:1,overflowY:"auto",minHeight:0,display:"flex",flexDirection:"column"},children:[v==="POSITIONS"&&(0,e.jsx)("div",{style:{flex:1,display:"flex",overflow:"hidden",padding:12},children:(0,e.jsx)("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column"},children:(0,e.jsx)(Gj,{positions:Ie,onPositionsChange:function(fe){It(fe,"SESSION",new Date().toISOString()),g("portfolio.book_updated",(fe||[]).length+" positions")}})})}),v==="RISK"&&(0,e.jsx)(FD,{positions:Ie,metrics:Q,drawdown:jt,navHistory:ee,onOpenRoom:Kt}),v==="MANDATE"&&(0,e.jsx)(ID,{mandate:z,breaches:tn,onSave:function(fe){oe(xj(fe)),Be.current={},g("portfolio.mandate_updated","maxPos "+fe.maxPositionPct+"% · maxClass "+fe.maxClassPct+"% · maxFx "+fe.maxFxPct+"% · ddAlert "+fe.maxDrawdownAlert);try{Vn.upsertMandate({max_position_pct:fe.maxPositionPct,max_asset_class_pct:fe.maxClassPct,max_fx_pct:fe.maxFxPct,max_drawdown_alert:fe.maxDrawdownAlert,notes:fe.notes||""}).catch(function(){})}catch{}}}),v==="BROKERS"&&(0,e.jsxs)("div",{style:{padding:16},children:[(0,e.jsx)("div",{style:rn.note,children:"Connected broker positions merge into this portfolio book — click ⟳ REFRESH after connecting or placing an order to pull them in (paste/CSV rows are kept; broker rows update in place)."}),(0,e.jsx)(h5,{})]}),v==="ATTRIBUTION"&&(0,e.jsx)(LD,{positions:Ie,metrics:Q}),v==="AI DESK"&&(0,e.jsx)(DD,{onAudit:g,positions:Ie,metrics:Q,mandate:z,breaches:tn,alertRules:W,onPrepOrder:function(fe){ve({open:!0,prefill:fe||{}}),g("portfolio.order_prepared","from proposal: "+(fe&&fe.symbol||"?"))}})]}),_e.open&&(0,e.jsx)(wD,{prefill:_e.prefill,positions:Ie,mandate:z,drawdown:jt,onAudit:g,onClose:function(){ve({open:!1,prefill:{}})},onPlaced:function(){$(!0)}})]})}function FD(t){var n=t.positions,r=t.metrics,o=t.drawdown,a=t.navHistory,l=(0,i.useMemo)(function(){return a||[]},[a]),s=FA(n,[]),c=(0,i.useMemo)(function(){return e2(n)},[n]),d=(0,i.useMemo)(function(){return US(c.positions)},[c]),p=(0,i.useState)(xf[0].id),g=p[0],f=p[1],h=xf.find(function(k){return k.id===g})||xf[0],x=(0,i.useMemo)(function(){return QS(n,h)},[n,h]),v=d&&d.gross>0,y=(0,i.useMemo)(function(){var k=l.slice(-30);if(k.length<2)return null;var A=k.map(function(C){return C.pnl}),j=Math.min.apply(null,A),E=Math.max.apply(null,A)-j||1;return k.map(function(C,_){var w=_/(k.length-1)*120,O=26-(C.pnl-j)/E*24;return w.toFixed(1)+","+O.toFixed(1)}).join(" ")},[l]);return r.count?(0,e.jsxs)("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:14},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:12,flexWrap:"wrap"},children:[(0,e.jsxs)("div",{style:rn.riskCard,children:[(0,e.jsx)("div",{style:rn.riskLabel,children:"COMPOSITE RISK"}),(0,e.jsx)("div",{style:{fontFamily:on,fontSize:22,fontWeight:800,color:s.color||"#D4AF5C"},children:Math.round(s.score||0)}),(0,e.jsx)("div",{style:{fontFamily:on,fontSize:8,color:s.color||"#8FA3BF",letterSpacing:".1em"},children:s.band||""})]}),(0,e.jsxs)("div",{style:rn.riskCard,children:[(0,e.jsx)("div",{style:rn.riskLabel,children:"UNREALISED P&L"}),n.some(function(k){return!k._pnlUnavailable})?(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:on,fontSize:18,fontWeight:800,color:r.pnl>
414=0?"#3FB950":"#C85C5C"},children:Yi(r.pnl)}),(0,e.jsx)("div",{style:{fontFamily:on,fontSize:8,color:"#5A7090"},children:"mark-to-market from entry × qty · updates with Px"})]}):(0,e.jsx)("div",{style:{fontFamily:on,fontSize:9,color:"#5A7090",lineHeight:1.5},children:"Unavailable / Insufficient Data — entry and current price required."})]}),(0,e.jsxs)("div",{style:rn.riskCard,children:[(0,e.jsx)("div",{style:rn.riskLabel,children:"PORTFOLIO VaR (1D)"}),v?(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:on,fontSize:18,fontWeight:800,color:"#C85C5C"},children:Yi(d.net)}),(0,e.jsxs)("div",{style:{fontFamily:on,fontSize:8,color:"#5A7090"},children:[c.estimatedCount>0?"PARAMETRIC ESTIMATE ("+c.estimatedCount+" positions, class vol × z95) · ":"","gross ",Yi(d.gross)," · netting benefit"," ",(d.benefitPct||0).toFixed?(d.benefitPct||0).toFixed(0):d.benefitPct,"%"]})]}):(0,e.jsx)("div",{style:{fontFamily:on,fontSize:9,color:"#5A7090",lineHeight:1.5},children:"Book empty — VaR computes once positions are loaded."})]}),(0,e.jsxs)("div",{style:rn.riskCard,children:[(0,e.jsx)("div",{style:rn.riskLabel,children:"P&L DRAWDOWN FROM PEAK"}),(0,e.jsx)("div",{style:{fontFamily:on,fontSize:18,fontWeight:800,color:o.drawdown>0?"#C85C5C":"#3FB950"},children:Yi(o.drawdown)}),y&&(0,e.jsx)("svg",{width:"124",height:"28",style:{marginTop:4},children:(0,e.jsx)("polyline",{points:y,fill:"none",stroke:"#D4AF5C",strokeWidth:"1.5"})}),(0,e.jsxs)("div",{style:{fontFamily:on,fontSize:7,color:"#3A4A5E"},children:[l.length," daily snapshots ·"," ",l.filter(function(k){return k._server}).length," ","server-backed"]})]}),(0,e.jsxs)("div",{style:rn.riskCard,children:[(0,e.jsx)("div",{style:rn.riskLabel,children:"FX (NON-USD)"}),(0,e.jsxs)("div",{style:{fontFamily:on,fontSize:18,fontWeight:800,color:r.fxExposurePct>30?"#C85C5C":"#C9D1D9"},children:[r.fxExposurePct.toFixed(1),"%"]}),(0,e.jsx)("div",{style:{fontFamily:on,fontSize:8,color:"#5A7090"},children:"of gross exposure"})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:rn.section,children:"CONCENTRATION — TOP POSITIONS"}),r.topConcentration.map(function(k){return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"4px 0"},children:[(0,e.jsx)("span",{style:{fontFamily:on,fontSize:10,color:"#E4C27A",fontWeight:700,width:76,cursor:"pointer"},title:"Open market room",onClick:function(){t.onOpenRoom(k.symbol)},children:k.symbol}),(0,e.jsx)("div",{style:{flex:1,height:7,background:"#0D1520",borderRadius:4,overflow:"hidden"},children:(0,e.jsx)("div",{style:{width:Math.min(100,k.weightPct*2.2)+"%",height:"100%",background:k.weightPct>10?"#C85C5C":"#D4AF5C"}})}),(0,e.jsxs)("span",{style:{fontFamily:on,fontSize:9,color:"#8FA3BF",width:52,textAlign:"right"},children:[k.weightPct.toFixed(1),"%"]}),(0,e.jsx)("span",{style:{fontFamily:on,fontSize:9,color:k.pnl>=0?"#3FB950":"#C85C5C",width:72,textAlign:"right"},children:Yi(k.pnl)})]},k.symbol)})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:rn.section,children:"EXPOSURE BY ASSET CLASS"}),Object.keys(r.byClass).map(function(k){var A=r.byClass[k];return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"4px 0"},children:[(0,e.jsx)("span",{style:{fontFamily:on,fontSize:9,color:"#8FA3BF",width:90,letterSpacing:".06em"},children:k.toUpperCase()}),(0,e.jsx)("div",{style:{flex:1,height:7,background:"#0D1520",borderRadius:4,overflow:"hidden"},children:(0,e.jsx)("div",{style:{width:Math.min(100,A.weightPct)+"%",height:"100%",background:"#5EEAD4"}}
414)}),(0,e.jsxs)("span",{style:{fontFamily:on,fontSize:9,color:"#8FA3BF",width:52,textAlign:"right"},children:[A.weightPct.toFixed(1),"%"]}),(0,e.jsx)("span",{style:{fontFamily:on,fontSize:9,color:A.pnl>=0?"#3FB950":"#C85C5C",width:72,textAlign:"right"},children:Yi(A.pnl)})]},k)})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:rn.section,children:"STRESS TEST — SIGNED BY SIDE (SHORTS BENEFIT IN DOWN-MOVES)"}),(0,e.jsx)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:8},children:xf.map(function(k){var A=k.id===g;return(0,e.jsx)("button",{onClick:function(){f(k.id)},style:Object.assign({},rn.tabBtn,A?rn.tabOn:null),children:k.label},k.id)})}),(0,e.jsxs)("div",{style:{fontFamily:on,fontSize:8,color:"#3A4A5E",marginBottom:8},children:["Assumptions: ",h.assumptions," — deterministic client-side approximation, not a market model."]}),(0,e.jsxs)("div",{style:{display:"flex",gap:20,alignItems:"baseline",marginBottom:8},children:[(0,e.jsx)("span",{style:{fontFamily:on,fontSize:9,color:"#5A7090"},children:"ESTIMATED BOOK IMPACT"}),(0,e.jsx)("span",{style:{fontFamily:on,fontSize:20,fontWeight:800,color:x.total>=0?"#3FB950":"#C85C5C"},children:Yi(x.total)})]}),x.worst.map(function(k){return(0,e.jsxs)("div",{style:{display:"flex",gap:10,fontFamily:on,fontSize:9,padding:"2px 0"},children:[(0,e.jsx)("span",{style:{color:"#E4C27A",width:76},children:k.symbol}),(0,e.jsx)("span",{style:{color:"#5A7090",width:44},children:k.side}),(0,e.jsx)("span",{style:{color:k.impact>=0?"#3FB950":"#C85C5C"},children:Yi(k.impact)})]},k.symbol)})]}),(0,e.jsx)("div",{style:rn.note,children:"Provenance: every figure above is computed in your browser from the book shown in POSITIONS. Server-side risk scores (BQML) are a flagged backend lane."})]}):(0,e.jsx)("div",{style:rn.emptyTab,children:"Connect or import your book — risk analytics compute from real positions only."})}function ID(t){var n=(0,i.useState)(t.mandate),r=n[0],o=n[1],a=t.breaches||[];function l(s,c,d){return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"5px 0"},children:[(0,e.jsx)("span",{style:{fontFamily:on,fontSize:9,color:"#8FA3BF",width:240,letterSpacing:".06em"},children:s}),(0,e.jsx)("input",{type:"number",step:d||1,value:r[c],onChange:function(p){var g=Object.assign({},r);g[c]=Number(p.target.value),o(g)},style:{width:110,background:"#0D1020",border:"1px solid #1E2838",borderRadius:5,padding:"6px 8px",color:"#C9D1D9",fontFamily:on,fontSize:10,outline:"none"}})]})}return(0,e.jsxs)("div",{style:{padding:16,maxWidth:640},children:[(0,e.jsx)("div",{style:rn.section,children:"INVESTMENT POLICY — LIMITS"}),l("MAX SINGLE POSITION (% OF GROSS)","maxPositionPct"),l("MAX ASSET CLASS (% OF GROSS)","maxClassPct"),l("MAX NON-USD FX (% OF GROSS)","maxFxPct"),l("P&L DRAWDOWN ALERT LEVEL ($)","maxDrawdownAlert",1e4),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:10,padding:"5px 0"},children:[(0,e.jsx)("span",{style:{fontFamily:on,fontSize:9,color:"#8FA3BF",width:240,letterSpacing:".06em",paddingTop:6},children:"NOTES"}),(0,e.jsx)("textarea",{value:r.notes||"",rows:2,onChange:function(s){var c=Object.assign({},r);c.notes=s.target.value,o(c)},style:{flex:1,background:"#0D1020",border:"1px solid #1E2838",borderRadius:5,padding:"6px 8px",color:"#C9D1D9",fontSize:11,outline:"none",resize:"vertical"}})]}),(0,e.jsx)("button",{style:Object.assign({},rn.actBtn,{marginTop:8}),onClick:function(){t.onSave(r)},children:"SAVE MANDATE"}),(0,e.jsxs)("div",{style:{marginTop:18},children:[(0,e.jsx)("div",{style:rn.section,children:"LIVE BREACH CHECK"}),a.length===0&&(0,e.jsx)("div",{style:{fontFamily:on,fontSize:10,color:"#3FB950"},children:"✓ Book is within all mandate limits."}),a.map(function(s){return(0,e.jsxs)("div",{style:{display:"flex",gap:8,padding:"4px 0",fontFamily:on,fontSize:10},children:[(0,e.jsx)("span",{style:{color:s.severity==="BREACH"?"#C85C5C":"#D4AF5C",fontWeight:700},children:s.severity}),(0,e.jsx)("span",{style:{color:"#C9D1D9"},children:s.text})]},s.id)})]}),(0,e.jsx)("div",{style:rn.note,children:"Limits persist locally and push to the backend mandate endpoint best-effort. Breaches are audited."})]})}function DD(t){var n=t.positions,r=(0,i.useMemo)(function(){return n||[]},[n]),o=t.metrics,a=(0,i.useMemo)(function(){return o||{count:0,gross:0}}
414,[o]),l=t.mandate,s=(0,i.useMemo)(function(){return l||Ef},[l]),c=t.breaches,d=(0,i.useMemo)(function(){return c||[]},[c]),p=t.alertRules||[],g=t.onPrepOrder||function(){},f=t.onAudit,h=(0,i.useState)(null),x=h[0],v=h[1],y=(0,i.useState)("CHECKING"),k=y[0],A=y[1];(0,i.useEffect)(function(){var O=!0;try{Vn.listProposals().then(function(M){if(O){var U=M&&(M.proposals||M.items)||[];v(U),A(U.length?"LIVE":"IDLE"),f&&f("portfolio.proposals_viewed",U.length+" proposals")}}).catch(function(){O&&(v([]),A("UNREACHABLE"))})}catch{v([]),A("UNREACHABLE")}return function(){O=!1}},[f,v,A]);var j=(0,i.useMemo)(function(){var O=[];return d.forEach(function(M){if(M.id.indexOf("pos:")===0){var U=M.id.slice(4),ee=r.find(function(oe){return(oe.instrument||oe.symbol)===U});if(!(!ee||!Number(ee.px)||!a.gross)){var N=(a.topConcentration||[]).find(function(oe){return oe.symbol===U});if(N){var V=(N.weightPct-s.maxPositionPct)/100*a.gross;if(!(V<=0)){var z=Math.ceil(V/Number(ee.px));O.push({symbol:U,side:ee.side==="SHORT"?"BUY":"SELL",quantity:z,why:U+" is "+N.weightPct.toFixed(1)+"% of gross vs "+s.maxPositionPct+"% cap — "+(ee.side==="SHORT"?"buy to cover":"trim")+" ~"+z.toLocaleString()+" to comply"})}}}}}),O},[d,r,a,s]),E=(0,i.useMemo)(function(){return QS(r,xf.find(function(O){return O.id==="eq20"})||xf[0])},[r]),C=p.filter(function(O){return O.triggeredAt}),_=k==="LIVE"?"#3FB950":k==="IDLE"?"#D4AF5C":"#C85C5C";if(!a.count)return(0,e.jsx)("div",{style:rn.emptyTab,children:"Connect or import your book — desk actions compute from real positions only."});function w(O,M){return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"8px 12px",border:"1px solid #101826",borderRadius:7,background:"#05080D",marginBottom:6},children:[(0,e.jsx)("span",{style:{flex:1,fontSize:11,color:"#C9D1D9",lineHeight:1.5},children:O.why}),(0,e.jsx)("button",{style:{padding:"5px 12px",background:"rgba(63,185,80,0.08)",border:"1px solid rgba(63,185,80,0.4)",borderRadius:5,cursor:"pointer",fontFamily:on,fontSize:8,color:"#3FB950",fontWeight:700,letterSpacing:".08em",flexShrink:0},onClick:function(){g({symbol:O.symbol,side:O.side,quantity:O.quantity})},children:"⚡ PREP ORDER"})]},M)}return(0,e.jsxs)("div",{style:{padding:16,maxWidth:780},children:[(0,e.jsx)("div",{style:rn.section,children:"AI DESK — BOOK-GROUNDED ACTIONS · HUMAN-CONFIRMED EXECUTION"}),(0,e.jsx)("div",{style:rn.note,children:"Every action below is computed deterministically from your live book and mandate — no invented predictions. PREP ORDER opens the broker ticket (pre-trade check + typed confirmation gate every submission)."}),(0,e.jsx)("div",{style:rn.section,children:"MANDATE COMPLIANCE"}),j.length===0&&(0,e.jsx)("div",{style:{fontFamily:on,fontSize:10,color:"#3FB950",marginBottom:12},children:"✓ No position breaches the single-position cap — nothing to trim."}),j.map(function(O,M){return w(O,"c"+M)}),C.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:rn.section,children:"TRIGGERED PROTECTIVE ALERTS"}),C.map(function(O){return(0,e.jsxs)("div",{style:{fontFamily:on,fontSize:10,color:"#E07070",padding:"3px 0"},children:["⚑ ",O.type==="pos_loss_pct"?"Position loss ≥ "+O.value+"%":"Drawdown ≥ $"+Number(O.value).toLocaleString(),O.detail?" — "+O.detail
414:""]},O.id)})]}),(0,e.jsxs)("div",{style:{marginTop:14},children:[(0,e.jsx)("div",{style:rn.section,children:"STRESS EXPOSURE — WORST UNDER EQUITY CRASH −20%"}),E.worst.slice(0,3).map(function(O,M){var U=r.find(function(N){return(N.instrument||N.symbol)===O.symbol});if(!U||O.impact>=0)return null;var ee=Math.max(1,Math.ceil(Zg(U)*.25));return w({symbol:O.symbol,side:U.side==="SHORT"?"BUY":"SELL",quantity:ee,why:O.symbol+" ("+O.side+") loses "+Yi(Math.abs(O.impact))+" in a −20% equity crash — trimming 25% (~"+ee.toLocaleString()+") cuts that exposure"},"s"+M)})]}),(0,e.jsxs)("div",{style:{marginTop:14},children:[(0,e.jsxs)("div",{style:rn.section,children:["AUTOPM PROPOSAL ENGINE — ",(0,e.jsx)("span",{style:{color:_},children:k})]}),k==="IDLE"&&(0,e.jsx)("div",{style:rn.note,children:"The backend proposal engine returned no open proposals. The deterministic actions above come from your book directly."}),k==="UNREACHABLE"&&(0,e.jsx)("div",{style:rn.note,children:"Proposal engine unreachable — no live data available. Deterministic actions above are unaffected."}),(x||[]).map(function(O,M){return(0,e.jsxs)("div",{style:{border:"1px solid #101826",borderRadius:8,background:"#05080D",padding:"10px 14px",marginTop:8},children:[(0,e.jsx)("div",{style:{fontFamily:on,fontSize:10,color:"#E4C27A",fontWeight:700},children:O.title||O.symbol||"Proposal "+(M+1)}),(0,e.jsx)("div",{style:{fontSize:11,color:"#8FA3BF",lineHeight:1.6,marginTop:4},children:O.rationale||O.detail||O.description||JSON.stringify(O).slice(0,300)}),(0,e.jsx)("button",{style:{marginTop:8,padding:"5px 12px",background:"rgba(63,185,80,0.08)",border:"1px solid rgba(63,185,80,0.4)",borderRadius:5,cursor:"pointer",fontFamily:on,fontSize:8,color:"#3FB950",fontWeight:700,letterSpacing:".08em"},onClick:function(){g({symbol:O.symbol||O.ticker||"",side:String(O.side||O.action||"BUY").toUpperCase().indexOf("SELL")!==-1?"SELL":"BUY",quantity:O.quantity||O.qty||""})},children:"⚡ PREP ORDER →"})]},O.id||M)})]})]})}function OD(t){var n=t.rules||[],r=(0,i.useState)("pos_loss_pct"),o=r[0],a=r[1],l=(0,i.useState)(""),s=l[0],c=l[1];function d(){var p=parseFloat(s);isFinite(p)&&(c(""),t.onChange(n.concat([{id:"pa-"+Date.now(),type:o,value:p,triggeredAt:null}])),t.onAudit&&t.onAudit("portfolio.alert_set",o+" "+p))}return(0,e.jsxs)("div",{style:rn.pop,children:[(0,e.jsx)("div",{style:{fontFamily:on,fontSize:7,color:"#7A90A8",letterSpacing:".14em",fontWeight:700,marginBottom:8},children:"PROTECTIVE ALERTS"}),(0,e.jsxs)("div",{style:{display:"flex",gap:6,marginBottom:8},children:[(0,e.jsxs)("select",{value:o,onChange:function(p){a(p.target.value)},style:{background:"#0D1020",border:"1px solid #1E2838",borderRadius:5,padding:"6px",color:"#8FA3BF",fontFamily:on,fontSize:8,outline:"none"},children:[(0,e.jsx)("option",{value:"pos_loss_pct",children:"POSITION LOSS ≥ %"}),(0,e.jsx)("option",{value:"drawdown_abs",children:"DRAWDOWN ≥ $"})]}),(0,e.jsx)("input",{value:s,inputMode:"decimal",placeholder:o==="pos_loss_pct"?"e.g. 8":"e.g. 250000",onChange:function(p){c(p.target.value)},onKeyDown:function(p){p.key==="Enter"&&d()},style:{width:90,background:"#0D1020",border:"1px solid #1E2838",borderRadius:5,padding:"6px 8px",color:"#C9D1D9",fontSize:11,outline:"none"}}),(0,e.jsx)("button",{style:rn.actBtn,onClick:d,disabled:!isFinite(parseFloat(s)),children:"SET"})]}),n.length===0&&(0,e.jsx)("div",{style:{fontFamily:on,fontSize:8,color:"#3A4A5E",lineHeight:1.6},children:"No rules yet. Rules evaluate against the live book while Portfolio is open; triggers are audited."}),n.map(function(p){return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5px 0",borderTop:"1px solid rgba(90,112,144,0.12)"},children:[(0,e.jsx)("span",{style:{fontFamily:on,fontSize:9,color:p.triggeredAt?"#C85C5C":"#8FA3BF",fontWeight:700},children:p.type==="pos_loss_pct"?"POS LOSS ≥ "+p.value+"%":"DRAWDOWN ≥ $"+Number(p.value).toLocaleString()}),(0,e.jsx)("span",{style:{flex:1,fontFamily:on,fontSize:7,color:p.triggeredAt?"#C85C5C":"#3A4A5E",letterSpacing:".08em"},children:p.triggeredAt?"TRIGGERED "+p.triggeredAt.slice(0,16).replace("T"," ")+(p.detail?" · "+p.detail:""):"ARMED"}),(0,e.jsx)("span",{style:{color:"#5A7090",cursor:"pointer",fontSize:12,lineHeight:1}
414,onClick:function(){t.onChange(n.filter(function(g){return g.id!==p.id}))},children:"×"})]},p.id)})]})}function LD(t){var n=t.positions||[],r=(0,i.useState)(null),o=r[0],a=r[1],l=(0,i.useState)(!1),s=l[0],c=l[1];(0,i.useEffect)(function(){var A=!0;try{Vn.listTransactions({limit:500}).then(function(j){A&&a(j&&j.transactions||[])}).catch(function(){A&&c(!0)})}catch{c(!0)}return function(){A=!1}},[a,c]);var d=(0,i.useMemo)(function(){return jj(o||[])},[o]),p=(0,i.useMemo)(function(){return n.filter(function(A){return!A._pnlUnavailable})},[n]),g=(0,i.useMemo)(function(){return p.reduce(function(A,j){return A+(Number(j.pnl)||0)},0)},[p]),f=(0,i.useMemo)(function(){return p.slice().sort(function(A,j){return(Number(j.pnl)||0)-(Number(A.pnl)||0)})},[p]),h=f.filter(function(A){return(Number(A.pnl)||0)>0}),x=f.filter(function(A){return(Number(A.pnl)||0)<0}).reverse();if(!n.length)return(0,e.jsx)("div",{style:rn.emptyTab,children:"Connect or import your book — attribution computes from real positions and recorded transactions only."});function v(A){if(A._pnlUnavailable)return"Insufficient Data";if(!g)return"—";var j=(Number(A.pnl)||0)/g*100;return(j>=0?"+":"")+j.toFixed(1)+"% of book P&L"}function y(A){var j=!!A._pnlUnavailable,E=j?null:Number(A.pnl),C=j?"#8FA3BF":E>=0?"#3FB950":"#C85C5C";return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"4px 0"},children:[(0,e.jsx)("span",{style:{fontFamily:on,fontSize:10,color:"#E4C27A",fontWeight:700,width:84},children:A.instrument||A.symbol}),(0,e.jsx)("span",{style:{fontFamily:on,fontSize:8,color:"#5A7090",width:46},children:A.side}),(0,e.jsx)("span",{style:{fontFamily:on,fontSize:8,color:"#5A7090",width:80},children:A.assetClass}),(0,e.jsx)("span",{style:{fontFamily:on,fontSize:10,color:C,fontWeight:700,minWidth:72},children:j?"Unavailable":Yi(E)}),(0,e.jsx)("span",{style:{fontFamily:on,fontSize:8,color:"#5A7090",minWidth:120},children:v(A)}),(0,e.jsx)("span",{style:{fontFamily:on,fontSize:8,color:"#5A7090"},children:j?"":(Number(A.pnlPct)||0).toFixed(1)+"%"+(A._liveQuote?" · live":" · book")})]},A.instrument||A.symbol)}var k=n.length>0&&p.length===0;return(0,e.jsxs)("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:16,maxWidth:760},children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:rn.section,children:"P&L CONTRIBUTION — WINNERS"}),k&&(0,e.jsx)("div",{style:rn.note,children:"Insufficient Data — entry and current price are required to calculate P&L contribution. Zeros are not shown as a substitute."}),!k&&h.length===0&&(0,e.jsx)("div",{style:rn.note,children:"No positions currently contributing positive unrealised P&L."}),h.slice(0,5).map(y)]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:rn.section,children:"P&L CONTRIBUTION — LOSERS"}),k&&(0,e.jsx)("div",{style:rn.note,children:"Insufficient Data — entry and current price are required to calculate P&L contribution. Zeros are not shown as a substitute."}),!k&&x.length===0&&(0,e.jsx)("div",{style:rn.note,children:"No positions currently contributing negative unrealised P&L."}),x.slice(0,5).map(y)]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:rn.section,children:"REALIZED CASH-FLOW BY SYMBOL — FROM RECORDED TRANSACTIONS"}),o===null&&!s&&(0,e.jsx)("div",{style:rn.note,children:"Loading transactions…"}),s&&(0,e.jsx)("div",{style:rn.note,children:"Transactions endpoint unreachable — no live data available."}),o!==null&&o.length===0&&(0,e.jsx)("div",{style:rn.note,children:"No transactions recorded yet — realized attribution activates as transactions are ingested (CSV import or broker fills)."}),d.slice(0,10).map(function(A){return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"4px 0"},children:[(0,e.jsx)("span",{style:{fontFamily:on,fontSize:10,color:"#E4C27A",fontWeight:700,width:84},children:A.symbol}),(0,e.jsxs)("span",{style:{fontFamily:on,fontSize:8,color:"#5A7090",width:110},children:[A.buys," buys · ",A.sells," sells"]}),(0,e.jsx)("span",{style:{fontFamily:on,fontSize:10,color:A.realizedCashflow>=0?"#3FB950":"#C85C5C",fontWeight:700},children:Yi(A.realizedCashflow)})]},A.symbol)}),o!==null&&o.length>0&&(0,e.jsx)("div",{style:rn.note,children:"Cash-flow view (sell proceeds − buy cost per symbol) — not tax-lot accounting; the true cost-basis engine is the flagged backend lane."})]})]})}var rn={wrap:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",background:"#030609",minWidth:0},head:{display:"flex",alignItems:"center",gap:18,padding:"12px 20px",borderBottom:"1px solid #111820",background:"#05080D",flexShrink:0,flexWrap:"wrap"},tabs:{display:"flex",alignItems:"center",gap:6,padding:"8px 20px",borderBottom:"1px solid #0C1218",flexShrink:0,flexWrap:"wrap"},tabBtn:{padding:"5px 12px",background:"transparent",border:"1px solid #1E2838",borderRadius:5,cursor:"pointer",fontFamily:on,fontSize:8,color:"#5A7090",fontWeight:700,letterSpacing:".1em"},tabOn:{background:"rgba(212,175,92,0.12)",border:"1px solid rgba(212,175,92,0.5)",color:"#D4AF5C"},actBtn:{padding:"6px 12px",background:"rgba(212,175,92,0.08)",border:"1px solid rgba(212,175,92,0.3)",borderRadius:5,cursor:"pointer",fontFamily:on,fontSize:9,color:"#D4AF5C",fontWeight:700,letterSpacing:".08em",whiteSpace:"nowrap"},actAlert:{border:"1px solid rgba(200,92,92,0.6)",color:"#E07070",background:"rgba(200,92,92,0.1)"},breachBadge:{fontFamily:on,fontSize:9,color:"#E07070",letterSpacing:".1em",fontWeight:700,border:"1px solid rgba(200,92,92,0.5)",background:"rgba(200,92,92,0.08)",borderRadius:5,padding:"5px 10px",cursor:"pointer",flexShrink:0},menu:{position:"absolute",top:"112%",right:0,zIndex:70,background:"rgba(8,12,20,0.99)",border:"1px solid rgba(212,175,92,0.25)",borderRadius:6,minWidth:150,boxShadow:"0 8px 24px rgba(0,0,0,0.5)",overflow:"hidden"},menuItem:{padding:"8px 12px",fontFamily:on,fontSize:8,color:"#C9D1D9",letterSpacing:".1em",curs
414or:"pointer",borderBottom:"1px solid rgba(212,175,92,0.06)"},pop:{position:"absolute",top:"115%",right:0,zIndex:80,width:330,background:"rgba(8,12,20,0.99)",border:"1px solid rgba(212,175,92,0.25)",borderRadius:6,boxShadow:"0 12px 32px rgba(0,0,0,0.6)",padding:"10px 12px",maxHeight:300,overflowY:"auto"},section:{fontFamily:on,fontSize:8,color:"#7A90A8",letterSpacing:".16em",fontWeight:700,marginBottom:8},riskCard:{border:"1px solid #101826",borderRadius:8,background:"#05080D",padding:"12px 16px",minWidth:170},riskLabel:{fontFamily:on,fontSize:7,color:"#5A7090",letterSpacing:".14em",marginBottom:6},note:{fontFamily:on,fontSize:8,color:"#3A4A5E",lineHeight:1.6,letterSpacing:".04em",marginBottom:10},emptyTab:{padding:40,textAlign:"center",fontFamily:on,fontSize:10,color:"#3A4A5E",letterSpacing:".1em"}};function zD({social:t}){if(!t||!t.socialUseful||!t.profileUrl)return null;var n=t.platformColor||"#8B949E",r={twitter:"𝕏",truth_social:"T",reddit:"◉",linkedin:"in",instagram:"◈"}[t.platform]||"◈";return(0,e.jsxs)("div",{style:{marginTop:8,borderRadius:6,overflow:"hidden",border:"1px solid "+n+"33",background:"rgba(6,8,13,0.8)"},children:[(0,e.jsxs)("div",{style:{padding:"5px 12px",display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid "+n+"22"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,e.jsx)("span",{style:{fontSize:12,color:n,fontWeight:"bold",fontFamily:"monospace"},children:r}),(0,e.jsx)("span",{style:{fontSize:10,fontFamily:"monospace",color:"#C9D1D9",letterSpacing:"0.05em"},children:t.accountName||"@"+t.accountHandle}),(0,e.jsx)("span",{style:{fontSize:9,color:"#5A7090",fontFamily:"monospace"},children:t.platformDisplay}),t.authority>=.95&&(0,e.jsxs)("span",{style:{fontSize:8,color:"#D4AF5C",fontFamily:"monospace",letterSpacing:"0.05em"},children:["✓"," AUTHORITY"]})]}),(0,e.jsx)("span",{style:{fontSize:9,fontFamily:"monospace",color:"#5A7090",letterSpacing:"0.08em"},children:"SOCIAL INTEL"})]}),(0,e.jsxs)("div",{style:{padding:"10px 12px"},children:[t.postTitle&&(0,e.jsx)("p",{style:{margin:"0 0 8px 0",fontSize:11,color:"#C9D1D9",fontFamily:"monospace",lineHeight:"1.5",borderLeft:"2px solid "+n+"66",paddingLeft:8},children:t.postTitle}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("a",{href:t.profileUrl,target:"_blank",rel:"noopener noreferrer",style:{fontSize:10,color:n,fontFamily:"monospace",textDecoration:"none",padding:"3px 10px",border:"1px solid "+n+"55",borderRadius:3,letterSpacing:"0.05em"},children:["VIEW SOURCE ","→"]}),t.postScore&&(0,e.jsxs)("span",{style:{fontSize:9,color:"#5A7090",fontFamily:"monospace"},children:["↑"," ",t.postScore.toLocaleString()," points"]}),t.category&&(0,e.jsx)("span",{style:{fontSize:8,color:"#5A7090",fontFamily:"monospace",textTransform:"uppercase",letterSpacing:"0.08em"},children:t.category.replace(/_/g," ")})]})]}),(0,e.jsxs)("div",{style:{padding:"3px 12px",fontSize:9,fontFamily:"monospace",color:"#5A7090",borderTop:"1px solid rgba(28,39,64,0.4)",display:"flex",justifyContent:"space-between"},children:[(0,e.jsxs)("span",{children:["CONFIDENCE ",Math.round((t.socialConfidence||0)*100),"%"]}),(0,e.jsx)("span",{children:t.source==="curated"?"CURATED AUTHORITY":"DYNAMIC COMMUNITY"})]})]})}var en=vr,Zs=Tf,J=SA,Ku={gasPipe:[56,189,248],oilPipe:[245,158,11],lngRoute:[45,212,191],conflict:[255,68,68],geological:[255,107,107],sanctions:[167,139,250,100],military:[99,102,241],portfolio:dv&&dv.portfolio||[245,166,35],opportunity:[63,185,80],shipping:[100,165,250],aviation:[167,139,250],cyber:[239,68,68],weather:[96,165,250],centralBank:[251,191,36],currency:[45,212,191],supplyChain:[249,115,22],chokepoint:[255,0,0],risk:[255,80,80],reward:[63,185,80],powerGrid:[96,165,250],refinery:[251,146,60],reserves:[245,158,11],elections:[167,139,250],terror:[220,38,38],exchange:[168,85,247],dataCenter:[34,211,238],offshore:[14,165,233],wildfire:[249,115,22],seismic:[239,68,68],hurricane:[59,130,246],ports:[100,165,250],rail:[100,116,139],subsea:[45,212,191],climate:[132,204,22],pop:[168,85,247],gdp:[251,191,36],aqi:[234,88,12],news:[251,191,36],analyst:[45,212,191],insider:[251,146,60],whale:[56,189,248],mining:[234,179,8],cex:[168,85,247],dex:[45,212,191],my:[245,166,35
414]},od=[{id:"energy",label:"ENERGY",icon:"⚡",color:J.blue,layers:[{id:"gasPipelines",label:"Gas Pipelines",color:J.blue,meta:{source:"Xyron/Curated",cadence:"Daily",description:"Major transnational gas trunk lines with flow status."}},{id:"oilPipelines",label:"Oil Pipelines",color:J.orange,meta:{source:"Xyron/Curated",cadence:"Daily",description:"Crude oil trunk lines and strategic corridors."}},{id:"lngRoutes",label:"LNG Shipping",color:J.teal,meta:{source:"Xyron/Curated",cadence:"Weekly",description:"Global LNG tanker routes with annual throughput."}},{id:"commodityPrices",label:"Commodity Prices",color:J.amber,meta:{source:"Markets API",cadence:"15 min",description:"Major hub spot prices and benchmarks."}},{id:"chokepoints",label:"Chokepoints",color:J.red,meta:{source:"Xyron/EIA",cadence:"Daily",description:"Maritime chokepoints with transit volume and threat level."}},{id:"powerGrid",label:"Power Grid",color:J.blue,meta:{source:"GridInfo",cadence:"Daily",description:"Major interconnectors, HVDC links and critical substations."}},{id:"refineries",label:"Refineries",color:J.orange,meta:{source:"EIA / JODI",cadence:"Weekly",description:"Top global crude refining centres by capacity."}},{id:"strategicReserves",label:"Strategic Reserves",color:J.amber,meta:{source:"IEA",cadence:"Monthly",description:"National strategic petroleum reserves and cover days."}}]},{id:"geopolitical",label:"GEOPOLITICAL",icon:"⚠",color:J.redBright,layers:[{id:"conflicts",label:"Active Conflicts",color:J.red,meta:{source:"ACLED",cadence:"Daily",description:"Live conflict events with risk tier and affected sectors."}},{id:"sanctions",label:"Sanctions Zones",color:J.purple,meta:{source:"OFAC / EU",cadence:"Daily",description:"Comprehensive sanctions regimes by jurisdiction."}},{id:"military",label:"Military Presence",color:J.indigo,meta:{source:"Xyron/Curated",cadence:"Weekly",description:"Strategic military bases and projection radii."}},{id:"cyberThreats",label:"Cyber Threats",color:J.pink,meta:{source:"Mandiant / MITRE",cadence:"Weekly",description:"Known APT campaigns with attribution and target sectors."}},{id:"elections",label:"Elections (90d)",color:J.purple,meta:{source:"Econ Calendar",cadence:"Daily",description:"Upcoming national elections within 90 days, by risk level."}},{id:"terrorEvents",label:"Terror Events (30d)",color:J.red,meta:{source:"GDELT / Sentinel",cadence:"Hourly",description:"Attributed terror/extremist incidents, last 30 days."}}]},{id:"financial",label:"FINANCIAL",icon:"◆",color:J.amber,layers:[{id:"portfolio",label:"Portfolio Positions",color:J.amber,meta:{source:"Internal",cadence:"Live",description:"Aggregated firm-level positions by geo concentration.",confidential:!0}},{id:"opportunities",label:"Opportunities",color:J.green,meta:{source:"Alpha Engine",cadence:"Daily",description:"Model-ranked thematic opportunities with conviction."}},{id:"centralBanks",label:"Central Banks",color:J.yellow,meta:{source:"BIS / IMF",cadence:"Daily",description:"Policy rates, bias and next-meeting calendar."}},{id:"currency",label:"Currency Strength",color:J.teal,meta:{source:"Markets API",cadence:"15 min",description:"DXY components and cross-rate strength index."}},{id:"exchanges",label:"Exchanges & Clearing",color:J.purple,meta:{source:"WFE",cadence:"Weekly",description:"Global listing venues and central counterparties."}},{id:"dataCenters",label:"Data Centers",color:J.cyan,meta:{source:"Equinix / DR",cadence:"Weekly",description:"Trading colos and major cloud regions (NY4 / LD4 / TY3 / FR5)."}},{id:"offshoreHubs",label:"Offshore Finance Hubs",color:J.blue,meta:{source:"Tax Justice",cadence:"Quarterly",description:"Leading offshore finance jurisdictions and secrecy score."}}]},{id:"environment",label:"ENVIRONMENT",icon:"●",color:J.redBright,layers:[{id:"geological",label:"Geological Alerts",color:J.redBright,meta:{source:"USGS",cadence:"Live",description:"Tectonic / volcanic hazard zones and recent quakes."}},{id:"weather",label:"Weather Alerts",color:J.cyan,meta:{source:"NOAA / ECMWF",cadence:"Hourly",description:"Severe weather zones: hurricanes, drought, flood, monsoon."}},{id:"supplyChain",label:"Supply Chain",color:J.orange,meta:{source:"Xyron/Curated",cadence:"Daily",description:"Critical choke nodes for semis, ports, raw materials."}},{id:"wildfires",label:"Active Wildfires",color:J.orange,meta:{source:"NASA FIRMS",cadence:"Daily",description:"Active fire detections from MODIS / VIIRS satellites."}},{id:"seismic",label:"Quakes M4+ (7d)",color:J.red,meta:{source:"USGS",cadence:"Live",description:"Earthquakes magnitude 4+ from the last 7 days."}}
414,{id:"hurricanes",label:"Tropical Cyclones",color:J.cyan,meta:{source:"NOAA NHC",cadence:"3 hourly",description:"Active and forecast tropical cyclones (global)."}}]},{id:"transport",label:"TRANSPORT",icon:"✈",color:J.purple,layers:[{id:"shipping",label:"Shipping Lanes",color:J.blue,meta:{source:"Xyron/Curated",cadence:"Weekly",description:"Major container and tanker routes with volumes."}},{id:"aviation",label:"Aviation Network",color:J.purple,meta:{source:"Xyron/FBO",cadence:"Daily",description:"Executive aviation FBOs and VIP terminals."}},{id:"portTraffic",label:"Port Congestion",color:J.blue,meta:{source:"UNCTAD / AIS",cadence:"Daily",description:"Top ports with congestion and dwell time indicators."}},{id:"railways",label:"Rail Freight",color:J.textFaint||"#64748b",meta:{source:"Xyron/Curated",cadence:"Monthly",description:"Strategic rail freight corridors (BRI, NAFTA, etc.)."}},{id:"subseaCables",label:"Subsea Cables",color:J.teal,meta:{source:"TeleGeography",cadence:"Quarterly",description:"Global internet subsea cable infrastructure."}}]},{id:"overlays",label:"OVERLAYS",icon:"◉",color:J.red,layers:[{id:"riskHeatmap",label:"Risk Heatmap",color:J.red,meta:{source:"Composite",cadence:"Hourly",description:"Composite weighted risk signal across all layers."}},{id:"climateRisk",label:"Climate / Flood Risk",color:J.green,meta:{source:"CMIP6",cadence:"Annual",description:"Projected flood and heat exposure (RCP 4.5 scenario)."}},{id:"populationDensity",label:"Population Density",color:J.purple,meta:{source:"Kontur",cadence:"Annual",description:"Population density (H3 hex grid, 2024 release)."}},{id:"gdpHeatmap",label:"GDP Heatmap",color:J.amber,meta:{source:"World Bank",cadence:"Annual",description:"Nominal GDP distribution by country (2024)."}},{id:"aqi",label:"Air Quality (AQI)",color:J.orange,meta:{source:"OpenAQ",cadence:"Hourly",description:"Live air-quality index at major urban stations."}}]},{id:"intel",label:"INTEL",icon:"⚡",color:J.amber,layers:[{id:"newsHotspots",label:"News Hotspots",color:J.amber,meta:{source:"News API",cadence:"15 min",description:"Geolocated high-velocity news clusters (last 24h)."}},{id:"analystMoves",label:"Analyst Revisions",color:J.teal,meta:{source:"Alpha Engine",cadence:"Hourly",description:"Street revisions geolocated to HQs of covered names."}},{id:"insiderFilings",label:"Insider Filings",color:J.orange,meta:{source:"EDGAR",cadence:"Live",description:"Form 3/4/5 insider filings placed at issuer HQs."}},{id:"whaleMoves",label:"Whale Moves (Crypto)",color:J.blue,meta:{source:"Whale Alert",cadence:"Live",description:"Large on-chain transfers routed by counterparty geo."}}]},{id:"crypto",label:"CRYPTO INFRA",icon:"◉",color:J.yellow,layers:[{id:"miningPools",label:"Mining Pools",color:J.yellow,meta:{source:"Hashrate Index",cadence:"Hourly",description:"Top hash-rate pools by geographic share."}},{id:"exchangesCex",label:"Centralised Exchanges",color:J.purple,meta:{source:"CoinGecko",cadence:"Daily",description:"Top CEX venues by 24h volume."}},{id:"liquidityVenues",label:"DEX Liquidity",color:J.teal,meta:{source:"Defi Llama",cadence:"Hourly",description:"On-chain DEX liquidity hubs (routers/aggregators)."}}]},{id:"satellite",label:"SATELLITE",icon:"◈",color:J.teal,layers:[{id:"satChange",label:"Surface Change",color:J.teal,meta:{source:"AlphaEarth Foundations (Google DeepMind) via Earth Engine",cadence:"Lane dark — pending activation",description:"Embedding-based surface-change scores over tracked assets (ports, refineries, chokepoints). Renders only when the AlphaEarth data lane is activated."}}]},{id:"user",label:"MY INTEL",icon:"◆",color:J.amber,layers:[{id:"myPortfolio",label:"My Portfolio",color:J.amber,meta:{source:"Portfolio API",cadence:"Live when uploaded",description:"Your uploaded or broker positions, pinned at issuer HQs. Empty when the book is empty. Demo builds may show labelled MOCK pins only before the live lane loads.",confidential:!0}},{id:"myWatchlist",label:"My Watchlist",color:J.teal,meta:{source:"Not implemented",cadence:"None",description:"Xyron has no watchlist feed yet. This filter stays empty in production so it is not confused with holdings. Demo builds may show labelled MOCK pins, distinct from My Portfolio.",confidential:!0}},{id:"myAlerts",label:"My Alerts",color:J.red,meta:{source:"Sentinel",cadence:"Live",description:"Unread alerts placed at their triggering geography.",confidential:!0}},{id:"myDealRooms",label:"My Deal Rooms",color:J.purple,meta:{source:"Deal Rooms",cadence:"Live",description:"Active deal rooms pinned to counterparty locations.",confidential:!0}}]}],La=[];
414od.forEach(function(t){t.layers.forEach(function(n){La.push(n.id)})});var Gg={};od.forEach(function(t){t.layers.forEach(function(n){Gg[n.id]={group:t.id,groupLabel:t.label,groupColor:t.color,groupIcon:t.icon,label:n.label,color:n.color,meta:n.meta||{}}})});var gf=new Set(["gasPipelines","oilPipelines","chokepoints","conflicts","portfolio","geological","riskHeatmap"]),ZE=[{id:"default",label:"DEFAULT",icon:"◉",layers:Array.from(gf),view:{lng:25,lat:30,zoom:2.5,pitch:45},tags:["home","reset"]},{id:"energyCrisis",label:"ENERGY CRISIS",icon:"⚡",layers:["gasPipelines","oilPipelines","lngRoutes","commodityPrices","chokepoints","refineries","strategicReserves"],view:{lng:30,lat:35,zoom:3,pitch:45},tags:["energy","oil","gas","opec"]},{id:"geoRisk",label:"GEOPOLITICAL RISK",icon:"⚠",layers:["conflicts","sanctions","military","cyberThreats","terrorEvents","riskHeatmap"],view:{lng:30,lat:25,zoom:2.5,pitch:40},tags:["war","conflict","sanctions","cyber"]},{id:"portfolioView",label:"PORTFOLIO VIEW",icon:"◆",layers:["portfolio","opportunities","centralBanks","currency","myWatchlist","myAlerts"],view:{lng:10,lat:40,zoom:2.8,pitch:40},tags:["positions","watchlist","alpha"]},{id:"supplyChain",label:"SUPPLY CHAIN",icon:"✈",layers:["shipping","chokepoints","supplyChain","portTraffic","subseaCables","railways"],view:{lng:60,lat:20,zoom:2.5,pitch:40},tags:["logistics","shipping","ports"]},{id:"climateEnv",label:"CLIMATE & ENV",icon:"●",layers:["geological","weather","wildfires","seismic","hurricanes","climateRisk","aqi"],view:{lng:0,lat:10,zoom:2.2,pitch:35},tags:["climate","weather","earthquake","fire"]},{id:"cryptoView",label:"CRYPTO",icon:"◉",layers:["miningPools","exchangesCex","liquidityVenues","whaleMoves"],view:{lng:60,lat:30,zoom:2.3,pitch:35},tags:["crypto","btc","eth"]},{id:"intelFeed",label:"LIVE INTEL",icon:"⚡",layers:["newsHotspots","analystMoves","insiderFilings","whaleMoves","terrorEvents"],view:{lng:10,lat:30,zoom:2.3,pitch:35},tags:["news","analyst","insider"]},{id:"allOn",label:"ALL LAYERS",icon:"◉",layers:"ALL",view:{lng:25,lat:25,zoom:2.2,pitch:45},tags:["everything"]}],MD=[{id:"24h",label:"24H",hours:24},{id:"7d",label:"7D",hours:168},{id:"30d",label:"30D",hours:720},{id:"90d",label:"90D",hours:2160},{id:"ytd",label:"YTD",hours:null}],up={longitude:25,latitude:30,zoom:2.5,pitch:45,bearing:-10,minZoom:1.5,maxZoom:18};function ND(t){return String(t).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function BD(t,n){var r=String(t||""),o=String(n||"");return!r||!o||r.indexOf(o)===-1?!1:new RegExp("(^|[^a-z0-9])"+ND(o)+"([^a-z0-9]|$)","i").test(r)}function PD(t,n){var r=String(t||"").trim().toLowerCase();if(!r)return null;for(var o=n||PF,a=null,l=-1,s=0;s<o.length;s++)for(var c=o[s],d=c&&c.kw||[],p=0;p<d.length;p++){var g=String(d[p]||"").trim().toLowerCase();g&&(r===g||BD(r,g))&&g.length>l&&(a=c,l=g.length)}return a}var wh=1460,ek=.98,UD=.002;function WD(t){return(t||1460)*864e5}function F1(t,n,r){var o=WD(r),a=(n||Date.now())-o,l=Number(t);return isFinite(l)||(l=1),l<0&&(l=0),l>1&&(l=1),a+l*o}function HD(t){if(!t)return NaN;var n=t.t||t.at||t.time||"";return Date.parse(n)}function GD(t,n){var r=HD(t);return isFinite(r)?r<=n:!0}function ux(t,n){return Array.isArray(t)?n==null||!isFinite(n)?t:t.filter(function(r){return GD(r,n)}):[]}function tk(t){return Number(t)>=ek}function VD(t,n){var r=n??UD,o=Number(t)+r;return!isFinite(o)||o>=1?{value:1,done:!0}:{value:o,done:!1}}function YD(t,n){var r=Number(t);return n&&n.justStarted&&tk(r)&&(r=0),VD(r,n&&n.step)}function KD(t,n){for(var r=ux(t,n),o=[],a=0;a<r.length;a++){var l=r[a],s=Number(l.lng),c=Number(l.lat);!isFinite(s)||!isFinite(c)||o.push({position:[s,c],name:l.label||l.name||"Event",risk:l.risk||"MEDIUM",kind:l.kind||"curated",t:l.t,detail:l.label})}return o}function Af(t,n){var r=t.length,o=(n%1+1)%1*(r-1),a=Math.floor(o),l=o-a;return a>=r-1?t[r-1]:[t[a][0]+(t[a+1][0]-t[a][0])*l,t[a][1]+(t[a+1][1]-t[a][1])*l]}function I1(t,n,r,o){for(var a=[],l=0;l<t.length;l++){var s=t[l];if(s.status==="destroyed"){for(var c=0;c<3;c++){var d=(n*r*.3+c/3)%1;if(Math.sin(n*2+c)>.3){var p=Af(s.path,d);a.push({position:p,color:[255,60,60,180],size:3})}}continue}for(var g=o||6,f=s.status==="reduced"||s.status==="disrupted"||s.status==="partial"?r*.4:r,h=0;h<g;h++){var x=(n*f+h/g)%1,v=Af(s.path,x);a.push({position:v,color:s.color.length===4?s.color:s.color.concat([230]),size:4});for(var y=1;y<4;y++){var k=(x-y*.008+1)%1,A=Af(s.path,k);a.push({position:A,color:s.color.slice(0,3).concat([180-y*50]),size:3.5-y*.4})}}}return a}function XD(t,n){for(var r=[],o=0;o<t.length;o++)for(var a=t[o],l=0;l<4;l++){var s=(n*.15+l/4)%1,c=Af(a.path,s);r.push({position:c,color:a.color.concat([200]),size:3.5});for(var d=1;d<3;d++){var p=(s-d*.006+1)%1;r.push({position:Af(a.path,p),color:a.color.concat([140-d*40]),size:3-d*.3})}}return r}function qD(t,n){for(var r=[],o=0;o<t.length;o++)for(var a=t[o],l=0;l<3;l++){var s=(n*.1+l/3)%1,c=Af(a.path,s);r.push({position:c,color:a.color.concat([180]),size:3})}return r}function $D(t,n){for(var r=t&&Array.isArray(t.commodities)?t.commodities:[],o={},a=0;a<r.length;a++){var l=r[a];l&&l.id&&(o[l.id]=l)}for(var s={},c=[],d=0;d<e1.length;d++){var p=e1[d];s[p.id]=!0;var g=o[p.id];if(g&&g.price){c.push(Object.assign({},p,g,{live:!0}));continue}if(n){c.push(Object.assign({},p));continue}c.push({id:p.id,name:p.name,position:p.position,commodity:p.commodity,benchmark:p.benchmark,currency:p.currency,price:"",change:"",trend:"flat",live:!1})}for(var f=0;f<r.length;f++){var h=r[f];h&&h.id&&!s[h.id]&&h.position&&c.push(h)}return c}function JD(t){return(t||[]).map(function(n){return Object.assign({},n,{mock:!0,source:"mock"})})}function D1(t,n,r,o){return t&&Array.isArray(t[n])&&t[n].length?t[n]:o?r:t&&Array.isArray(t[n])?t[n]:[]}function O1(t,n,r,o){return t&&Array.isArray(t[n])?t[n]:o?JD(r):[]}function QD(t){var n=t.activeLayers,r=t.animTime,o=t.onHover,a=t.onClick,l=!!t.allowSeed,s=t.myIntel||null,c=O1(s,"portfolio",dF,l),d=O1(s,"watchlist",MF,l),p=D1(s,"alerts",NF,l),g=D1(s,"deal_rooms",BF,l),f=t.liveLayers||null,h=t.playheadMs,x=!!t.replaying;function v(b){return x?ux(b,h):b}var y=$D(f,l),k=!!(f&&f.commodities&&f.commodities.length),A=v(f&&f.geological||[]),j=v(f&&f.conflicts||[]),E=v(f&&f.news_hotspots&&f.news_hotspots.length?f.news_hotspots:l&&!x?RF:[]),C=!!(f&&f.news_hotspots&&f.news_hotspots.length),_=f&&f.wildfires&&f.wildfires.length?v(f.wildfires):x?[]:bF,w=!!(f&&f.wildfires&&f.wildfires.length),O=f&&f.cyclones&&f.cyclones.length?v(f.cyclones):x?[]:EF,M=!!(f&&f.cyclones&&f.cyclones.length),U=f&&f.seismic&&f.seismic.length?v(f.seismic):x?[]:SF,ee=!!(f&&f.seismic&&f.seismic.length),N=f&&f.fx&&f.fx.length?f.fx:l?uF:[],V=!!(f&&f.fx&&f.fx.length),z=c,oe=!!(s&&s.portfolio&&s.portfolio.length),P=x?[]:id,W=x?KD(t.timelineEvents||[],h):[],R=[];if(n.has("gasPipelines")){R.push(new Wc({id:"gas-pipeline-paths",data:Ug,getPath:function(b){return b.path},getColor:function(b){return b.status==="destroyed"?[255,60,60,80]:b.status==="reduced"||b.status==="disrupted"?[56,189,248,60]:[56,189,248,40]},getWidth:function(b){return b.status==="destroyed"?1:2},widthMinPixels:1,widthUnits:"pixels",pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"pipeline",subtype:"gas",data:b.object})}}));var ae=I1(Ug,r,.2,6);R.push(new vn({id:"gas-flow-particles",data:ae,getPosition:function(b){return b.position},getFillColor:function(b){return b.color},getRadius:function(b){return b.size},radiusUnits:"pixels",radiusMinPixels:1.5,updateTriggers:{getPosition:r,getFillColor:r}}))}if(n.has("oilPipelines")){R.push(new Wc({id:"oil-pipeline-paths",data:Wg,getPath:function(b){return b.path},getColor:function(b){return b.status==="partial"?[245,158,11,60]:[245,158,11,40]},getWidth:2,widthMinPixels:1.5,widthUnits:"pixels",pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"pipeline",subtype:"oil",data:b.object})}}));var q=I1(Wg,r,.18,5);R.push(new vn({id:"oil-flow-particles",data:q,getPosition:function(b){return b.position},getFillColor:function(b){return b.color},getRadius:function(b){return b.size},radiusUnits:"pixels",radiusMinPixels:1.5,updateTriggers:{getPosition:r,getFillColor:r}}))}if(n.has("lngRoutes")){R.push(new Wc({id:"lng-route-paths",data:Zb,getPath:function(b){return b.path},getColor:[45,212,191,30],getWidth:1.5,widthMinPixels:1,widthUnits:"pixels",pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"lngRoute",data:b.object})}}));var ge=XD(Zb,r);R.push(new vn({id:"lng-flow-particles",data:ge,getPosition:function(b){return b.position},getFillColor:function(b){return b.color},getRadius:function(b){return b.size},radiusUnits:"pixels",radiusMinPixels:1,updateTriggers:{getPosition:r,getFillColor:r}}))}if(n.has("commodityPrices")&&(R.push(new Fa({id:k?"commodity-price-labels-live":"commodity-price-labels",data:y,getPosition:function(b){return b.position},getText:function(b){return b.price||b.benchmark||b.name||""},getColor:function(b){return b.trend==="up"?[63,185,80,230]:b.trend==="down"?[255,68,68,230]:[212,175,92,230]}
414,getSize:12,sizeUnits:"pixels",sizeMinPixels:9,fontFamily:"'Berkeley Mono','JetBrains Mono',monospace",fontWeight:700,getTextAnchor:"middle",getAlignmentBaseline:"bottom",getPixelOffset:[0,-12],pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"commodity",data:b.object})}})),R.push(new vn({id:k?"commodity-hub-dots-live":"commodity-hub-dots",data:y,getPosition:function(b){return b.position},getFillColor:function(b){return b.trend==="up"?[63,185,80,160]:b.trend==="down"?[255,68,68,160]:[212,175,92,160]},getRadius:5,radiusUnits:"pixels",stroked:!0,getLineColor:function(b){return b.trend==="up"?[63,185,80]:b.trend==="down"?[255,68,68]:[212,175,92]},lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"commodity",data:b.object})}}))),n.has("chokepoints")){var X=6+Math.sin(r*3)*2;R.push(new vn({id:"chokepoint-pulse-outer",data:nc,getPosition:function(b){return b.position},getFillColor:function(b){return b.risk==="CRITICAL"?[255,0,0,40]:b.risk==="HIGH"?[255,107,107,30]:[251,191,36,20]},getRadius:X*3,radiusUnits:"pixels",updateTriggers:{getRadius:r}})),R.push(new vn({id:"chokepoint-markers",data:nc,getPosition:function(b){return b.position},getFillColor:function(b){return b.risk==="CRITICAL"?[255,0,0,220]:b.risk==="HIGH"?[255,107,107,200]:b.risk==="MEDIUM"?[251,191,36,200]:[63,185,80,200]},getRadius:6,radiusUnits:"pixels",stroked:!0,getLineColor:[0,0,0,180],lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"chokepoint",data:b.object})}})),R.push(new Fa({id:"chokepoint-labels",data:nc,getPosition:function(b){return b.position},getText:function(b){return b.name},getColor:[200,200,200,200],getSize:10,sizeUnits:"pixels",sizeMinPixels:8,fontFamily:"'Berkeley Mono','JetBrains Mono',monospace",fontWeight:600,getTextAnchor:"start",getPixelOffset:[10,0]}))}if(n.has("conflicts")){var de=8+Math.sin(r*2.5)*3;R.push(new vn({id:"conflict-pulse",data:P,getPosition:function(b){return b.position},getFillColor:function(b){return b.risk==="CRITICAL"?[255,0,0,25]:b.risk==="HIGH"?[255,68,68,20]:[251,191,36,15]},getRadius:de*4,radiusUnits:"pixels",updateTriggers:{getRadius:r}})),R.push(new vn({id:"conflict-markers",data:P,getPosition:function(b){return b.position},getFillColor:function(b){return b.type==="war"?[255,0,0,230]:b.type==="conflict"?[255,107,107,220]:[251,191,36,200]},getRadius:7,radiusUnits:"pixels",stroked:!0,getLineColor:[0,0,0],lineWidthMinPixels:1.5,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"conflict",data:b.object})}}))}if(j.length&&n.has("conflicts")&&R.push(new vn({id:"conflict-markers-live",data:j,getPosition:function(b){return b.position},getFillColor:function(b){return b.risk==="CRITICAL"?[255,0,0,235]:[255,90,90,215]},getRadius:4,radiusUnits:"pixels",stroked:!0,getLineColor:[255,200,60],lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"conflict",data:b.object})}})),n.has("sanctions")&&R.push(new VC({id:"sanctions-polygons",data:HE,getPolygon:function(b){return b.polygon},getFillColor:function(b){return b.color},getLineColor:[167,139,250,120],lineWidthMinPixels:1.5,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"sanctions",data:b.object})}})),n.has("military")&&(R.push(new vn({id:"military-range-rings",data:t1,getPosition:function(b){return b.position},getFillColor:[99,102,241,8],getRadius:function(b){return b.projectionRadiusKm*1e3},radiusUnits:"meters",stroked:!0,getLineColor:[99,102,241,40],lineWidthMinPixels:.5})),R.push(new vn({id:"military-base-markers",data:t1,getPosition:function(b){return b.position},getFillColor:function(b){return b.force.indexOf("US")!==-1?[99,102,241,220]:b.force.indexOf("Russia")!==-1?[255,68,68,220]:b.force.indexOf("China")!==-1?[251,191,36,220]:[167,139,250,220]},getRadius:5,radiusUnits:"pixels",stroked:!0,getLineColor:[0,0,0],lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"military",data:b.object})}}))),n.has("geological")){var We=10+Math.sin(r*1.8)*5;R.push(new vn({id:"geological-pulse",data:Cf,getPosition:function(b){return b.position},getFillColor:function(b){return b.risk==="CRITICAL"?[255,0,0,20]:b.risk==="HIGH"?[255,107,107,15]:[251,191,36,10]},getRadius:function(b){return(b.magnitude||5)*We*.6},radiusUnits:"pixels",updateTriggers:{getRadius:r}})),R.push(new vn({id:"geological-markers",data:Cf,getPosition:function(b){return b.position},getFillColor:function(b){return b.type==="volcanic"?[255,140,0,220]:[255,107,107,220]},getRadius:function(b){return Math.max(4,(b.magnitude||4)*.8)},radiusUnits:"pixels",stroked:!0,getLineColor:function(b){return b.type==="volcanic"?[255,100,0]:[200,60,60]},lineWidthMinPixels:1.5,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"geological",data:b.object})}})),A.length&&R.push(new vn({id:"geological-markers-live",data:A,getPosition:function(b){return b.position},getFillColor:[255,60,60,230],getRadius:function(b){return Math.max(4,(b.magnitude||5.5)*.9)},radiusUnits:"pixels",stroked:!0,getLineColor:[255,200,60],lineWidthMinPixels:1.5,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"geological",data:b.object})}}))}if(z.length&&n.has("portfolio")&&(R.push(new YC({id:oe?"portfolio-columns-live":"portfolio-columns",data:z,getPosition:function(b){return b.position},getElevation:function(b){return b.value*800},getFillColor:function(b){return String(b.pnl||"").indexOf("-")===0?b.risk==="CRITICAL"?[255,0,0,200]:[255,107,107,180]:[63,185,80,180]},diskResolution:6,radius:3e4,extruded:!0,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"portfolio",data:b.object})}})),R.push(new Fa({id:"portfolio-labels",data:z,getPosition:function(b){return b.position}
414,getText:function(b){var He=b.name||b.sym||"";return b.value!=null&&b.value!==""?He+`
415$`+b.value+"M":He},getColor:[245,166,35,220],getSize:11,sizeUnits:"pixels",sizeMinPixels:8,fontFamily:"'Berkeley Mono','JetBrains Mono',monospace",fontWeight:600,getTextAnchor:"middle",getAlignmentBaseline:"bottom",getPixelOffset:[0,-20]}))),l&&n.has("opportunities")&&(R.push(new vn({id:"opportunity-markers",data:n1,getPosition:function(b){return b.position},getFillColor:[63,185,80,200],getRadius:function(b){return 4+b.conviction},radiusUnits:"pixels",stroked:!0,getLineColor:[63,185,80],lineWidthMinPixels:1.5,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"opportunity",data:b.object})}})),R.push(new Fa({id:"opportunity-labels",data:n1,getPosition:function(b){return b.position},getText:function(b){return b.name},getColor:[63,185,80,180],getSize:10,sizeUnits:"pixels",sizeMinPixels:7,fontFamily:"'Berkeley Mono','JetBrains Mono',monospace",getTextAnchor:"start",getPixelOffset:[10,0]}))),l&&n.has("centralBanks")&&(R.push(new vn({id:"central-bank-markers",data:r1,getPosition:function(b){return b.position},getFillColor:function(b){return b.bias==="hawkish"?[255,107,107,200]:b.bias==="dovish"?[56,189,248,200]:[251,191,36,200]},getRadius:6,radiusUnits:"pixels",stroked:!0,getLineColor:[0,0,0],lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"centralBank",data:b.object})}})),R.push(new Fa({id:"central-bank-labels",data:r1,getPosition:function(b){return b.position},getText:function(b){return b.code+" "+b.rate},getColor:[251,191,36,220],getSize:11,sizeUnits:"pixels",sizeMinPixels:8,fontFamily:"'Berkeley Mono','JetBrains Mono',monospace",fontWeight:700,getTextAnchor:"start",getPixelOffset:[10,0]}))),N.length&&n.has("currency")&&R.push(new Fa({id:V?"currency-labels-live":"currency-labels",data:N,getPosition:function(b){return b.position},getText:function(b){return b.code+" "+b.ytdChange},getColor:function(b){return b.strength>60?[63,185,80,200]:b.strength>40?[251,191,36,200]:[255,107,107,200]},getSize:12,sizeUnits:"pixels",sizeMinPixels:9,fontFamily:"'Berkeley Mono','JetBrains Mono',monospace",fontWeight:700,getTextAnchor:"middle",getAlignmentBaseline:"center",pickable:!0,onHover:o})),n.has("shipping")){R.push(new Wc({id:"shipping-paths",data:i1,getPath:function(b){return b.path},getColor:function(b){return b.type==="tanker"?[245,158,11,25]:b.type==="emerging"?[45,212,191,20]:[100,165,250,25]},getWidth:1.5,widthMinPixels:1,widthUnits:"pixels",pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"shipping",data:b.object})}}));var te=qD(i1,r);R.push(new vn({id:"shipping-particles",data:te,getPosition:function(b){return b.position},getFillColor:function(b){return b.color},getRadius:function(b){return b.size},radiusUnits:"pixels",updateTriggers:{getPosition:r}}))}if(n.has("aviation")){var _e=pF.map(function(b){return{position:[b.lng,b.lat],name:b.name,code:b.code,region:b.region}});R.push(new vn({id:"fbo-markers",data:_e,getPosition:function(b){return b.position},getFillColor:[167,139,250,200],getRadius:5,radiusUnits:"pixels",stroked:!0,getLineColor:[124,58,237],lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"fbo",data:b.object})}})),R.push(new Fa({id:"fbo-labels",data:_e,getPosition:function(b){return b.position},getText:function(b){return b.code},getColor:[167,139,250,180],getSize:9,sizeUnits:"pixels",sizeMinPixels:7,fontFamily:"'Berkeley Mono','JetBrains Mono',monospace",fontWeight:600,getTextAnchor:"start",getPixelOffset:[8,0]}))}if(n.has("cyberThreats")&&(R.push(new qC({id:"cyber-arcs",data:vy,getSourcePosition:function(b){return b.origin},getTargetPosition:function(b){return b.target},getSourceColor:[239,68,68,200],getTargetColor:[239,68,68,80],getWidth:1.5,widthMinPixels:1,greatCircle:!0,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"cyber",data:b.object})}})),R.push(new vn({id:"cyber-origin-pulse",data:vy,getPosition:function(b){return b.origin},getFillColor:[239,68,68,40+Math.sin(r*3)*30],getRadius:12+Math.sin(r*2)*4,radiusUnits:"pixels",updateTriggers:{getRadius:r,getFillColor:r}}))),n.has("supplyChain")&&(R.push(new vn({id:"supply-chain-markers",data:
415Hg,getPosition:function(b){return b.position},getFillColor:function(b){return b.risk==="HIGH"?[249,115,22,220]:b.risk==="MEDIUM"?[251,191,36,200]:[100,165,250,200]},getRadius:6,radiusUnits:"pixels",stroked:!0,getLineColor:[0,0,0],lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"supplyChain",data:b.object})}})),R.push(new Fa({id:"supply-chain-labels",data:Hg,getPosition:function(b){return b.position},getText:function(b){return b.name},getColor:[249,115,22,180],getSize:9,sizeUnits:"pixels",sizeMinPixels:7,fontFamily:"'Berkeley Mono','JetBrains Mono',monospace",getTextAnchor:"start",getPixelOffset:[10,0]}))),n.has("weather")&&R.push(new vn({id:"weather-zones",data:fF,getPosition:function(b){return b.center},getFillColor:function(b){return b.color},getRadius:function(b){return b.radius*1e3},radiusUnits:"meters",stroked:!0,getLineColor:function(b){return b.color.slice(0,3).concat([120])},lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"weather",data:b.object})}})),n.has("riskHeatmap")&&R.push(new v0({id:"risk-heatmap",data:gF,getPosition:function(b){return b.position},getWeight:function(b){return b.weight},radiusPixels:80,intensity:1.2,threshold:.05,colorRange:[[0,0,0,0],[40,0,0,40],[80,0,0,80],[160,30,0,120],[220,60,0,160],[255,0,0,200]]})),n.has("powerGrid")&&(R.push(new Wc({id:"power-grid-paths",data:mF,getPath:function(b){return b.path},getColor:[96,165,250,120],getWidth:2,widthMinPixels:1.5,widthUnits:"pixels",pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"powerGrid",data:b.object})}})),R.push(new vn({id:"power-substations",data:hF,getPosition:function(b){return b.position},getFillColor:[96,165,250,200],getRadius:function(b){return 4+Math.min(6,b.capacityGW/8)},radiusUnits:"pixels",stroked:!0,getLineColor:[59,130,246],lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"substation",data:b.object})}}))),n.has("refineries")&&R.push(new vn({id:"refinery-markers",data:cx,getPosition:function(b){return b.position},getFillColor:[251,146,60,200],getRadius:function(b){return 4+Math.min(8,b.capacityKbd/180)},radiusUnits:"pixels",stroked:!0,getLineColor:[251,113,20],lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"refinery",data:b.object})}})),n.has("strategicReserves")&&(R.push(new vn({id:"strategic-reserves",data:o1,getPosition:function(b){return b.position},getFillColor:[245,158,11,200],getRadius:function(b){return 5+Math.min(10,b.mmbbl/60)},radiusUnits:"pixels",stroked:!0,getLineColor:[245,158,11],lineWidthMinPixels:1.5,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"reserves",data:b.object})}})),R.push(new Fa({id:"strategic-reserves-labels",data:o1,getPosition:function(b){return b.position},getText:function(b){return b.days+"d"},getColor:[245,158,11,220],getSize:10,sizeUnits:"pixels",sizeMinPixels:8,fontFamily:"'Berkeley Mono','JetBrains Mono',monospace",fontWeight:700,getTextAnchor:"middle",getAlignmentBaseline:"bottom",getPixelOffset:[0,-14]}))),n.has("elections")&&R.push(new vn({id:"election-markers",data:yF,getPosition:function(b){return b.position},getFillColor:function(b){return b.risk==="CRITICAL"?[239,68,68,220]:b.risk==="HIGH"?[255,107,107,200]:b.risk==="MEDIUM"?[251,191,36,200]:[167,139,250,200]},getRadius:6,radiusUnits:"pixels",stroked:!0,getLineColor:[167,139,250],lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"election",data:b.object})}})),n.has("terrorEvents")){var ve=5+Math.sin(r*3)*2;R.push(new vn({id:"terror-pulse",data:a1,getPosition:function(b){return b.position},getFillColor:[220,38,38,40],getRadius:ve*2.5,radiusUnits:"pixels",updateTriggers:{getRadius:r}})),R.push(new vn({id:"terror-markers",data:a1,getPosition:function(b){return b.position},getFillColor:function(b){return b.severity==="CRITICAL"?[220,38,38,230]:b.severity==="HIGH"?[239,68,68,210]:[251,191,36,200]},getRadius:5,radiusUnits:"pixels",stroked:!0,getLineColor:[0,0,0],lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"terrorEvent",data:b.object})}}))}
415if(n.has("exchanges")&&R.push(new vn({id:"exchange-markers",data:xF,getPosition:function(b){return b.position},getFillColor:function(b){return b.tier===1?[168,85,247,220]:b.tier===2?[168,85,247,170]:[168,85,247,110]},getRadius:function(b){return 4+Math.min(10,b.mcapTn*.6)},radiusUnits:"pixels",stroked:!0,getLineColor:[139,92,246],lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"exchange",data:b.object})}})),n.has("dataCenters")&&R.push(new vn({id:"datacenter-markers",data:vF,getPosition:function(b){return b.position},getFillColor:function(b){return b.type==="colo"?[34,211,238,220]:[45,212,191,180]},getRadius:5,radiusUnits:"pixels",stroked:!0,getLineColor:[14,165,233],lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"dataCenter",data:b.object})}})),n.has("offshoreHubs")&&(R.push(new vn({id:"offshore-markers",data:l1,getPosition:function(b){return b.position},getFillColor:function(b){return b.secrecy>65?[14,165,233,220]:[56,189,248,200]},getRadius:function(b){return 4+(b.secrecy-50)*.3},radiusUnits:"pixels",stroked:!0,getLineColor:[14,165,233],lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"offshoreHub",data:b.object})}})),R.push(new Fa({id:"offshore-labels",data:l1,getPosition:function(b){return b.position},getText:function(b){return b.name},getColor:[125,211,252,220],getSize:10,sizeUnits:"pixels",sizeMinPixels:8,fontFamily:"'Berkeley Mono','JetBrains Mono',monospace",fontWeight:700,getTextAnchor:"start",getPixelOffset:[10,0],pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"offshoreHub",data:b.object})}}))),n.has("wildfires")){var Ne=6+Math.sin(r*2.5)*3;R.push(new vn({id:w?"wildfire-pulse-live":"wildfire-pulse",data:_,getPosition:function(b){return b.position},getFillColor:[249,115,22,30],getRadius:function(b){return Ne*(b.acres>5e4?3:2)},radiusUnits:"pixels",updateTriggers:{getRadius:r}})),R.push(new vn({id:w?"wildfire-markers-live":"wildfire-markers",data:_,getPosition:function(b){return b.position},getFillColor:function(b){return b.risk==="CRITICAL"?[220,38,38,230]:b.risk==="HIGH"?[249,115,22,220]:[251,146,60,200]},getRadius:function(b){return 4+Math.min(8,b.acres/12e3)},radiusUnits:"pixels",stroked:!0,getLineColor:[234,88,12],lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"wildfire",data:b.object})}}))}if(n.has("seismic")&&R.push(new vn({id:ee?"quake-markers-live":"quake-markers",data:U,getPosition:function(b){return b.position},getFillColor:function(b){return b.mag>=6?[220,38,38,220]:b.mag>=5?[239,68,68,200]:[251,146,60,180]},getRadius:function(b){return Math.max(3,b.mag*1.4)},radiusUnits:"pixels",stroked:!0,getLineColor:[0,0,0],lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"seismic",data:b.object})}})),n.has("hurricanes")&&R.push(new Wc({id:M?"cyclone-tracks-live":"cyclone-tracks",data:O,getPath:function(b){return b.track},getColor:function(){return[59,130,246,120]},getWidth:function(b){return 2+b.cat},widthMinPixels:2,widthUnits:"pixels",pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"cyclone",data:b.object})}})),n.has("portTraffic")&&R.push(new vn({id:"port-markers",data:kF,getPosition:function(b){return b.position},getFillColor:function(b){return b.congestion==="HIGH"?[239,68,68,200]:b.congestion==="MEDIUM"?[251,191,36,200]:[100,165,250,200]},getRadius:function(b){return 4+Math.min(8,b.teuM/6)},radiusUnits:"pixels",stroked:!0,getLineColor:[59,130,246],lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"port",data:b.object})}})),n.has("railways")&&R.push(new Wc({id:"railway-paths",data:CF,getPath:function(b){return b.path},getColor:[148,163,184,180],getWidth:1.5,widthMinPixels:1,widthUnits:"pixels",pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"railway",data:b.object})}})),n.has("subseaCables")&&R.push(new Wc({id:"subsea-paths",data:AF,getPath:function(b){return b.path},getColor:[45,212,191,150],getWidth:1,widthMinPixels:1,widthUnits:"pixels",pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"subseaCable",data:b.object})}})),n.has("climateRisk")&&R.push(new v0({id:"climate-risk-heatmap",data:jF,getPosition:function(b){return b.position},getWeight:function(b){return b.weight},radiusPixels:70,intensity:.8,threshold:.05,colorRange:[[0,0,0,0],[30,60,40,40],[60,120,60,80],[90,180,90,120],[120,220,140,160],[150,240,170,200]]})),n.has("populationDensity")&&R.push(new v0({id:"pop-density-heatmap",data:wF,getPosition:function(b){return b.position},getWeight:function(b){return b.weight},radiusPixels:90,intensity:1.1,threshold:.05,colorRange:[[0,0,0,0],[45,20,80,50],[90,40,140,90],[140,60,200,130],[180,90,230,170],[220,120,240,200]]})),n.has("gdpHeatmap")&&R.push(new v0({id:"gdp-heatmap",data:TF,getPosition:function(b){return b.position},getWeight:function(b){return b.weight},radiusPixels:110,intensity:.9,threshold:.05,colorRange:[[0,0,0,0],[60,40,10,40],[120,80,20,80],[180,130,30,130],[230,175,40,170],[255,210,60,210]]})),n.has("aqi")&&R.push(new vn({id:"aqi-markers",data:_F,getPosition:function(b){return b.position},getFillColor:function(b){return b.aqi>150?[220,38,38,210]:b.aqi>100?[249,115,22,200]:b.aqi>50?[251,191,36,190]:[63,185,80,180]},getRadius:function(b){return 4+Math.min(8,b.aqi/30)},radiusUnits:"pixels",stroked:!0,getLineColor:[0,0,0],lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"aqi",data:b.object})}})),E.length&&n.has("newsHotspots")){var $e=6+Math.sin(r*2.2)*3;R.push(new vn({id:C?"news-pulse-live":"news-pulse",data:E,getPosition:function(b){return b.position},getFillColor:[251,191,36,25],getRadius:function(b){return $e*(b.vel/20)},radiusUnits:"pixels",updateTriggers:{getRadius:r}})),R.push(new vn({id:C?"news-markers-live":"news-markers",data:E,getPosition:function(b){return b.position},getFillColor:[251,191,36,220],getRadius:function(b){return 3+b.vel/20},radiusUnits:"pixels",stroked:!0,getLineColor:[245,158,11],lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"news",data:b.object})}}))}if(l&&n.has("analystMoves")&&R.push(new vn({id:"analyst-markers",data:FF,getPosition:function(b){return b.position},getFillColor:function(b){return b.dir==="up"?[63,185,80,220]:[239,68,68,220]},getRadius:5,radiusUnits:"pixels",stroked:!0,getLineColor:[45,212,191],lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"analyst",data:b.object})}})),l&&n.has("insiderFilings")&&R.push(new vn({id:"insider-markers",data:IF,getPosition:function(b){return b.position},getFillColor:[251,146,60,220],getRadius:5,radiusUnits:"pixels",stroked:!0,getLineColor:[234,88,12],lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"insider",data:b.object})}})),l&&n.has("whaleMoves")&&R.push(new vn({id:"whale-markers",data:DF,getPosition:function(b){return b.position},getFillColor:[56,189,248,220],getRadius:6,radiusUnits:"pixels",stroked:!0,getLineColor:[14,165,233],lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"whale",data:b.object})}})),n.has("miningPools")&&R.push(new vn({id:"mining-markers",data:OF,getPosition:function(b){return b.position},getFillColor:[234,179,8,200],getRadius:function(b){return 4+b.share/4},radiusUnits:"pixels",stroked:!0,getLineColor:[202,138,4],lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"miningPool",data:b.object})}}
415)),l&&n.has("exchangesCex")&&R.push(new vn({id:"cex-markers",data:LF,getPosition:function(b){return b.position},getFillColor:[168,85,247,220],getRadius:5,radiusUnits:"pixels",stroked:!0,getLineColor:[139,92,246],lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"cex",data:b.object})}})),l&&n.has("liquidityVenues")&&R.push(new vn({id:"dex-markers",data:zF,getPosition:function(b){return b.position},getFillColor:[45,212,191,220],getRadius:5,radiusUnits:"pixels",stroked:!0,getLineColor:[20,184,166],lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"dex",data:b.object})}})),c.length&&n.has("myPortfolio")){var Pe=!!(c[0]&&c[0].mock);R.push(new vn({id:Pe?"my-portfolio-markers-mock":"my-portfolio-markers",data:c,getPosition:function(b){return b.position},getFillColor:[Ku.portfolio[0],Ku.portfolio[1],Ku.portfolio[2],220],getRadius:function(b){return 4+Math.min(10,(b.alloc||0)/2)},radiusUnits:"pixels",stroked:!0,getLineColor:[Ku.portfolio[0],Ku.portfolio[1],Ku.portfolio[2]],lineWidthMinPixels:1.5,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"myPortfolio",data:b.object})}})),R.push(new Fa({id:"my-portfolio-labels",data:c,getPosition:function(b){return b.position},getText:function(b){var He=b.sym||b.name||"";return b.mock?"MOCK "+He:He},getColor:[245,166,35,220],getSize:10,sizeUnits:"pixels",sizeMinPixels:8,fontFamily:"'Berkeley Mono','JetBrains Mono',monospace",fontWeight:700,getTextAnchor:"start",getPixelOffset:[10,0]}))}if(d.length&&n.has("myWatchlist")){var ot=!!(d[0]&&d[0].mock);R.push(new vn({id:ot?"my-watchlist-markers-mock":"my-watchlist-markers",data:d,getPosition:function(b){return b.position},getFillColor:function(b){return b.delta&&b.delta.indexOf("-")===0?[239,68,68,220]:[45,212,191,220]},getRadius:5,radiusUnits:"pixels",stroked:!0,getLineColor:[20,184,166],lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"myWatchlist",data:b.object})}})),R.push(new Fa({id:"my-watchlist-labels",data:d,getPosition:function(b){return b.position},getText:function(b){var He=b.sym||b.name||"";return b.mock?"MOCK "+He:He},getColor:[45,212,191,200],getSize:10,sizeUnits:"pixels",sizeMinPixels:8,fontFamily:"'Berkeley Mono','JetBrains Mono',monospace",fontWeight:700,getTextAnchor:"start",getPixelOffset:[10,0]}))}if(p.length&&n.has("myAlerts")){var re=5+Math.sin(r*3.5)*2;R.push(new vn({id:"my-alerts-pulse",data:p,getPosition:function(b){return b.position},getFillColor:[239,68,68,35],getRadius:re*3,radiusUnits:"pixels",updateTriggers:{getRadius:r}})),R.push(new vn({id:"my-alerts-markers",data:p,getPosition:function(b){return b.position},getFillColor:function(b){return b.severity==="CRITICAL"?[220,38,38,230]:b.severity==="HIGH"?[239,68,68,210]:[251,191,36,200]},getRadius:6,radiusUnits:"pixels",stroked:!0,getLineColor:[0,0,0],lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"myAlert",data:b.object})}}))}g.length&&n.has("myDealRooms")&&(R.push(new vn({id:"my-dealrooms-markers",data:g,getPosition:function(b){return b.position},getFillColor:[168,85,247,220],getRadius:6,radiusUnits:"pixels",stroked:!0,getLineColor:[196,181,253],lineWidthMinPixels:1.5,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"dealRoom",data:b.object})}})),R.push(new Fa({id:"my-dealrooms-labels",data:g,getPosition:function(b){return b.position},getText:function(b){return b.name||b.stage||"DEAL"},getColor:[196,181,253,220],getSize:11,sizeUnits:"pixels",sizeMinPixels:9,fontFamily:"'Berkeley Mono','JetBrains Mono',monospace",fontWeight:700,getTextAnchor:"start",getPixelOffset:[10,0],pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"dealRoom",data:b.object})}})));var we=t.satCells||[];return we.length&&n.has("satChange")&&R.push(new vn({id:"sat-change-cells",data:we,getPosition:function(b){return b.position},getFillColor:function(b){var He=Math.max(0,Math.min(1,b.score));return[45+He*210,212-He*150,191-He*130,190]},getRadius:function(b){return 4+Math.max(0,Math.min(1,b.score))*10},radiusUnits:"pixels",stroked:!0,getLineColor:[45,212,191],lineWidthMinPixels:1,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"satChange",data:b.object})}})),W.length&&(R.push(new vn({id:"timeline-playback-markers",data:W,getPosition:function(b){return b.position},getFillColor:function(b){return b.risk==="CRITICAL"?[255,0,0,230]:b.risk==="HIGH"?[255,107,107,220]:[251,191,36,210]},getRadius:7,radiusUnits:"pixels",stroked:!0,getLineColor:[245,166,35
415],lineWidthMinPixels:1.5,pickable:!0,onHover:o,onClick:function(b){b.object&&a({type:"timelineEvent",data:b.object})}})),R.push(new Fa({id:"timeline-playback-labels",data:W,getPosition:function(b){return b.position},getText:function(b){return b.name},getColor:[251,191,36,220],getSize:10,sizeUnits:"pixels",sizeMinPixels:8,fontFamily:"'Berkeley Mono','JetBrains Mono',monospace",fontWeight:700,getTextAnchor:"start",getPixelOffset:[10,0]}))),R}function Zd(t,n){return typeof t=="number"&&isFinite(t)?t:n}function ZD(t){var n=t||{};return{longitude:Zd(n.longitude,25),latitude:Zd(n.latitude,30),zoom:Zd(n.zoom,2.5),pitch:Zd(n.pitch,45),bearing:Zd(n.bearing,-10),minZoom:Zd(n.minZoom,1.5),maxZoom:Zd(n.maxZoom,18)}}var eO=Gn&&Gn.name==="Arenberg"?"/maps/arenberg-dark.json":"/maps/dark-matter.json",Th=null,_h=null;function tO({layers:t,viewState:n,onViewStateChange:r}){var o=(0,i.useState)(!1),a=o[0],l=o[1],s=(0,i.useState)(null),c=s[0],d=s[1];(0,i.useEffect)(function(){Promise.all([xi(()=>import("./dist-T7y6-lkF.js"),__vite__mapDeps([9,10,1,0,2])),xi(()=>import("./vendor-C44JUHxF.js").then(f=>f.o),__vite__mapDeps([0,1,2]))]).then(function(f){Th=f[0].default||f[0].DeckGL,_h=f[1].Map||f[1].default,l(!0)}).catch(function(f){console.error("Globe load error:",f),d(f.message||"Failed to load map modules")})},[]);var p=(0,i.useCallback)(function(f){if(f&&f.viewState){var h={};["longitude","latitude","zoom","pitch","bearing","minZoom","maxZoom"].forEach(function(x){f.viewState[x]!==void 0&&(h[x]=f.viewState[x])}),r(h)}},[r]);if(c)return(0,e.jsxs)("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",background:J.bg,color:J.red,fontFamily:"'Berkeley Mono','JetBrains Mono',monospace",fontSize:11},children:["MAP ERROR: ",c]});if(!a||!Th)return(0,e.jsxs)("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",background:J.bg,color:J.amber,gap:14,fontFamily:"'Berkeley Mono','JetBrains Mono',monospace",fontSize:9,letterSpacing:".28em",textTransform:"uppercase"},children:[(0,e.jsx)("div",{style:{width:32,height:32,borderRadius:"50%",border:"1px solid "+J.amber+"40",borderTopColor:J.amber,animation:"deckSpin .9s linear infinite"}}),(0,e.jsx)("style",{children:"@keyframes deckSpin{to{transform:rotate(360deg)}}"}),(0,e.jsx)("div",{children:"Initializing 3D Intel Engine"}),(0,e.jsx)("div",{style:{color:J.textFaint,fontSize:9,letterSpacing:".22em"},children:Gn.short})]});var g=ZD(n);return(0,e.jsx)("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",overflow:"hidden",background:J.bg},children:(0,e.jsx)(Th,{viewState:g,onViewStateChange:p,controller:{dragRotate:!0,touchRotate:!0,keyboard:!0,inertia:300},layers:t,getTooltip:function(f){if(!f||!f.object)return null;var h=f.object,x=f.layer&&f.layer.id||"",v=h.mock||x.indexOf("-mock")!==-1?"[MOCK] ":x.indexOf("my-")===0||x.indexOf("sat-")===0||x.indexOf("-live")!==-1?"[LIVE] ":"[CURATED] ",y=h.name||h.title||h.code||h.benchmark||"";return y&&(y=v+y),h.risk&&(y+=" — "+h.risk),h.price&&(y+=" "+h.price),h.detail&&(y+=`
416`+(h.detail.length>100?h.detail.substring(0,100)+"…":h.detail)),y?{text:y,style:{fontFamily:"'Berkeley Mono','JetBrains Mono',monospace",fontSize:"10px",color:"#C9D1D9",background:"rgba(6,8,13,0.92)",border:"1px solid #1C2740",borderRadius:"4px",padding:"6px 10px",maxWidth:"280px",lineHeight:"1.5",whiteSpace:"pre-line"}}:null},getCursor:function(f){return f.isHovering?"pointer":"grab"},children:_h&&(0,e.jsx)(_h,{mapStyle:eO,attributionControl:!1})})})}var L1=!1;function nO(){if(!(L1||typeof document>"u")){L1=!0;var t=J&&J.amber||"#C9A961",n=J&&J.borderLight||"#2A3548",r=".arn-ctrl-scroll{scrollbar-width:thin;scrollbar-color:"+n+" transparent;}.arn-ctrl-scroll::-webkit-scrollbar{width:6px;}.arn-ctrl-scroll::-webkit-scrollbar-track{background:transparent;}.arn-ctrl-scroll::-webkit-scrollbar-thumb{background:"+n+";border-radius:3px;}.arn-ctrl-scroll::-webkit-scrollbar-thumb:hover{background:"+t+"66;}@keyframes arnCtrlFade{from{opacity:0;transform:translateY(-2px);}to{opacity:1;transform:none;}}",o=document.createElement("style");o.setAttribute("data-arn-ctrl","1"),o.textContent=r,document.head.appendChild(o)}}var z1="arn.map.favs.v1",M1="arn.map.recent.v1";function N1(t){try{var n=localStorage.getItem(t);if(!n)return[];var r=JSON.parse(n);return Array.isArray(r)?r:[]}catch{return[]}}function B1(t,n){try{localStorage.setItem(t,JSON.stringify(n))}catch{}}function rO(t){var n=t.activeLayers,r=t.onToggleLayer,o=t.onToggleGroup,a=t.onSetAllLayers,l=t.onSearch,s=t.onApplyPreset,c=t.onSoloGroup,d=t.onHorizonChange,p=t.onExport,g=t.onFlyToLayer;t.onAskPilot;var f=t.onAnalyzeView,h=t.horizon||"7d",x=t.collapsed,v=t.onToggleCollapse,y=(0,i.useState)({}),k=y[0],A=y[1],j=(0,i.useState)(""),E=j[0],C=j[1],_=(0,i.useState)(""),w=_[0],O=_[1],M=(0,i.useState)(function(){return N1(z1)}),U=M[0],ee=M[1],N=(0,i.useState)(function(){return N1(M1)}),V=N[0],z=N[1],oe=(0,i.useState)(function(){try{return localStorage.getItem("arn.map.recentOpen")!=="0"}catch{return!0}}),P=oe[0],W=oe[1],R=(0,i.useState)(function(){try{return localStorage.getItem("arn.map.presetsOpen.v2")!=="0"}catch{return!0}}),ae=R[0],q=R[1];(0,i.useEffect)(function(){try{localStorage.setItem("arn.map.recentOpen",P?"1":"0")}catch{}},[P]),(0,i.useEffect)(function(){try{localStorage.setItem("arn.map.presetsOpen.v2",ae?"1":"0")}catch{}},[ae]);var ge=(0,i.useState)(null),X=ge[0],de=ge[1],We=(0,i.useState)(!1),te=We[0],_e=We[1];(0,i.useEffect)(function(){nO()},[]),(0,i.useEffect)(function(){B1(z1,U)},[U]),(0,i.useEffect)(function(){B1(M1,V)},[V]);function ve(Ae){ee(function(Be){var Fe=Be.indexOf(Ae);if(Fe===-1)return Be.concat([Ae]);var ft=Be.slice();return ft.splice(Fe,1),ft})}function Ne(Ae){z(function(Be){var Fe=[Ae].concat(Be.filter(function(ft){return ft!==Ae}));return Fe.length>6&&(Fe=Fe.slice(0,6)),Fe})}function $e(Ae){Ne(Ae),typeof r=="function"&&r(Ae)}function Pe(Ae){A(function(Be){var Fe={};for(var ft in Be)Fe[ft]=Be[ft];return Fe[Ae]=Be[Ae]===!1,Fe})}function ot(Ae){return k[Ae]!==!1}function re(Ae){var Be=0;
416return Ae.layers.forEach(function(Fe){n.has(Fe.id)&&Be++}),Be===Ae.layers.length?"full":Be>0?"partial":"none"}var we=(0,i.useMemo)(function(){var Ae=w.trim().toLowerCase();return Ae?od.map(function(Be){var Fe=Be.label.toLowerCase().indexOf(Ae)!==-1,ft=Be.layers.filter(function(St){return Fe||St.label.toLowerCase().indexOf(Ae)!==-1||(St.id||"").toLowerCase().indexOf(Ae)!==-1||(St.meta&&St.meta.description||"").toLowerCase().indexOf(Ae)!==-1});return ft.length?{g:Be,layers:ft,forceOpen:!0}:null}).filter(Boolean):od.map(function(Be){return{g:Be,layers:Be.layers}})},[w]),b=(0,i.useMemo)(function(){var Ae=[];return we.forEach(function(Be){Be.layers.forEach(function(Fe){Ae.push(Fe)})}),Ae},[we]),He=n.size,tt=La.length;return x?(0,e.jsxs)("div",{style:{width:36,flexShrink:0,borderRight:"1px solid "+J.border,background:J.bgPanel,display:"flex",flexDirection:"column",alignItems:"center",paddingTop:10,gap:6},children:[(0,e.jsx)("button",{onClick:v,style:{background:"none",border:"none",cursor:"pointer",color:J.amber,fontSize:14,padding:4},title:"Expand panel",children:"▶"}),od.map(function(Ae){var Be=re(Ae);return(0,e.jsx)("button",{onClick:function(Fe){Fe.shiftKey&&typeof c=="function"?c(Ae.id):o(Ae.id)},title:Ae.label+" (shift-click = solo)",style:{background:"none",border:"none",cursor:"pointer",padding:3,fontSize:12,color:Be==="full"||Be==="partial"?Ae.color:J.textFaint,opacity:Be==="none"?.4:1},children:Ae.icon},Ae.id)})]}):(0,e.jsxs)("div",{style:{width:288,flexShrink:0,borderRight:"1px solid "+J.border,background:J.bgPanel,display:"flex",flexDirection:"column",overflow:"hidden"},children:[(0,e.jsxs)("div",{style:{padding:"10px 10px 8px",borderBottom:"1px solid "+J.border,flexShrink:0,display:"flex",flexDirection:"column",gap:8},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:6},children:[(0,e.jsx)("span",{style:{fontFamily:en,fontSize:9,fontWeight:700,color:J.amber,letterSpacing:".14em"},children:"LAYER CONTROL"}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4},children:[(0,e.jsx)("button",{onClick:function(){var Ae=n.size===La.length;if(typeof a=="function"){a(Ae?[]:La.slice());return}Ae?La.forEach(function(Be){n.has(Be)&&r(Be)}):La.forEach(function(Be){n.has(Be)||r(Be)})},style:{background:"none",border:"1px solid "+J.borderLight,borderRadius:3,padding:"1px 6px",cursor:"pointer",fontFamily:en,fontSize:9,fontWeight:700,color:n.size===La.length?J.amber:J.textFaint,letterSpacing:".12em"},title:n.size===La.length?"Turn all off":"Turn all on",children:n.size===La.length?"ALL":"ALL ON"}),(0,e.jsx)("button",{onClick:v,style:{background:"none",border:"none",cursor:"pointer",color:J.textFaint,fontSize:10,padding:2},title:"Collapse",children:"◀"})]})]}),(0,e.jsxs)("div",{style:{position:"relative"},children:[(0,e.jsxs)("button",{onClick:function(){_e(!te)},style:{width:"100%",background:J.bgInput,border:"1px solid "+J.borderLight,borderRadius:4,padding:"6px 10px",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",color:J.text,fontFamily:en,fontSize:9,letterSpacing:".12em",textAlign:"left"},children:[(0,e.jsx)("span",{style:{color:J.amber,fontWeight:700},children:"PRESETS"}),(0,e.jsx)("span",{style:{color:J.textFaint,fontSize:9},children:te?"▲":"▼"})]}),te&&(0,e.jsx)("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:4,background:J.bgPanel,border:"1px solid "+J.borderLight,borderRadius:4,zIndex:50,maxHeight:260,overflowY:"auto",animation:"arnCtrlFade .14s ease-out"},className:"arn-ctrl-scroll",children:ZE.map(function(Ae){return(0,e.jsxs)("button",{onClick:function(){_e(!1),typeof s=="function"&&s(Ae)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 10px",background:"none",border:"none",cursor:"pointer",textAlign:"left",borderBottom:"1px solid "+J.border},children:[(0,e.jsx)("span",{style:{fontSize:10,color:J.amber,flexShrink:0},children:Ae.icon}),(0,e.jsx)("span",{style:{fontFamily:en,fontSize:9,color:J.text,flex:1,letterSpacing:".10em"},children:Ae.label}),(0,e.jsx)("span",{style:{fontFamily:en,fontSize:9,color:J.textFaint},children:Ae.layers==="ALL"?tt:Ae.layers.length})]},Ae.id)})})]}),(0,e.jsxs)("div",{style:{position:"relative"},children:[(0,e.jsx)("span",{style:{position:"absolute",left:8,top:"50%",transform:"translateY(-50%)",fontFamily:en,fontSize:10,
416color:J.textFaint,pointerEvents:"none"},children:"⌕"}),(0,e.jsx)("input",{value:w,onChange:function(Ae){O(Ae.target.value)},onKeyDown:function(Ae){if(Ae.key==="Enter"&&b.length===1){var Be=b[0];n.has(Be.id)||$e(Be.id),typeof g=="function"&&g(Be.id),O("")}},placeholder:"Filter features — e.g. pipelines, conflicts",title:"Type a layer name. Enter jumps when there is one match.",style:{width:"100%",background:J.bgInput,border:"1px solid "+J.borderLight,borderRadius:4,padding:"6px 24px 6px 24px",color:J.text,fontSize:10,outline:"none",fontFamily:Zs,boxSizing:"border-box"}}),w&&(0,e.jsx)("button",{onClick:function(){O("")},style:{position:"absolute",right:4,top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",color:J.textFaint,fontFamily:en,fontSize:12,padding:"0 6px"},title:"Clear",children:"×"})]}),(0,e.jsxs)("div",{style:{position:"relative"},children:[(0,e.jsx)("span",{style:{position:"absolute",left:8,top:"50%",transform:"translateY(-50%)",fontFamily:en,fontSize:10,color:J.textFaint,pointerEvents:"none"},children:"⚲"}),(0,e.jsx)("input",{value:E,onChange:function(Ae){C(Ae.target.value)},onKeyDown:function(Ae){Ae.key==="Enter"&&E.trim()&&(l(E.trim()),C(""))},placeholder:"Search location — e.g. Tokyo, USA, Ukraine",title:"Type a city or country, then press Enter to fly there.",style:{width:"100%",background:J.bgInput,border:"1px solid "+J.borderLight,borderRadius:4,padding:"6px 8px 6px 24px",color:J.text,fontSize:10,outline:"none",fontFamily:Zs,boxSizing:"border-box"}})]}),(0,e.jsx)("div",{style:{display:"flex",gap:2,background:J.bgInput,border:"1px solid "+J.borderLight,borderRadius:4,padding:2},children:MD.map(function(Ae){var Be=h===Ae.id;return(0,e.jsx)("button",{onClick:function(){typeof d=="function"&&d(Ae.id)},style:{flex:1,padding:"3px 4px",background:Be?J.amber+"22":"transparent",border:"none",borderRadius:3,cursor:"pointer",fontFamily:en,fontSize:9,fontWeight:700,color:Be?J.amber:J.textFaint,letterSpacing:".12em"},children:Ae.label},Ae.id)})}),(0,e.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",fontFamily:en,fontSize:9,color:J.textFaint,letterSpacing:".14em"},children:[(0,e.jsxs)("span",{children:[tt," FEATURES · ",(0,e.jsxs)("span",{style:{color:J.amber},children:[He," ON"]})]}),(0,e.jsxs)("span",{children:[we.length,"/",od.length," GROUPS"]})]})]}),V.length>0&&!w&&(0,e.jsxs)("div",{style:{padding:"6px 10px",borderBottom:"1px solid "+J.border,flexShrink:0},children:[(0,e.jsxs)("div",{onClick:function(){W(!P)},style:{fontFamily:en,fontSize:9,color:J.textFaint,letterSpacing:".14em",marginBottom:P?4:0,cursor:"pointer",userSelect:"none",display:"flex",justifyContent:"space-between"},children:[(0,e.jsxs)("span",{children:[P?"▾":"▸"," RECENT"]}),(0,e.jsx)("span",{children:V.length})]}),P&&(0,e.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:3},children:V.slice(0,8).map(function(Ae){var Be=Gg[Ae];if(!Be)return null;var Fe=n.has(Ae);return(0,e.jsx)("button",{onClick:function(){$e(Ae)},title:Be.label,style:{padding:"2px 6px",background:Fe?Be.color+"18":J.bgInput,border:"1px solid "+(Fe?Be.color+"55":J.borderLight),borderRadius:3,cursor:"pointer",fontFamily:en,fontSize:9,color:Fe?Be.color:J.textFaint,whiteSpace:"nowrap"},children:Be.label},Ae)})})]}),(0,e.jsxs)("div",{className:"arn-ctrl-scroll",style:{flex:1,overflowY:"auto",padding:"6px 0",minHeight:0,scrollbarWidth:"thin",WebkitOverflowScrolling:"touch",scrollbarColor:(J.borderLight||"#2A3548")+" transparent"},children:[U.length>0&&!w&&(0,e.jsxs)("div",{style:{marginBottom:6},children:[(0,e.jsxs)("div",{style:{padding:"6px 10px 2px",fontFamily:en,fontSize:9,color:J.amber,letterSpacing:".14em"},children:["★"," PINNED"]}),U.map(function(Ae){var Be=Gg[Ae];if(!Be)return null;var Fe=n.has(Ae);return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 10px 4px 22px",background:Fe?Be.color+"0F":"none",transition:"all 0.1s",opacity:Fe?1:.82},children:[(0,e.jsxs)("button",{onClick:function(){$e(Ae)},style:{display:"flex",alignItems:"center",gap:8,flex:1,background:"none",border:"none",cursor:"pointer",textAlign:"left",padding:0},children:[(0,e.jsx)("div",{style:{width:9,height:9,borderRadius:2,flexShrink:0,background:Fe?Be.color:"transparent",border:"1.5px solid "+(Fe?Be.color:Be.color+"55"),boxShadow:Fe?"0 0 6px "+Be.color+"55":"none"}}
416),(0,e.jsx)("span",{style:{fontFamily:Zs,fontSize:10,color:J.text,flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Be.label})]}),(0,e.jsx)("button",{onClick:function(){ve(Ae)},title:"Unpin",style:{background:"none",border:"none",cursor:"pointer",color:J.amber,fontSize:10,padding:"0 4px"},children:"★"})]},"fav-"+Ae)}),(0,e.jsx)("div",{style:{height:1,background:J.border,margin:"6px 0"}})]}),we.length===0&&(0,e.jsxs)("div",{style:{padding:"24px 12px",textAlign:"center",fontFamily:en,fontSize:9,color:J.textFaint,letterSpacing:".12em"},children:["NO FEATURES MATCH",(0,e.jsxs)("div",{style:{marginTop:6,opacity:.6},children:['"',w,'"']})]}),we.map(function(Ae){var Be=Ae.g,Fe=Ae.layers,ft=re(Be),St=Ae.forceOpen||ot(Be.id);return(0,e.jsxs)("div",{style:{marginBottom:2},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"6px 10px",cursor:"pointer"},onClick:function(){Pe(Be.id)},children:[(0,e.jsx)("span",{style:{fontSize:9,color:St?J.amber:J.textFaint,transform:St?"rotate(90deg)":"none",transition:"transform 0.15s",display:"inline-block",width:8},children:"▶"}),(0,e.jsx)("span",{style:{fontSize:10,color:Be.color,flexShrink:0},children:Be.icon}),(0,e.jsx)("span",{style:{fontFamily:en,fontSize:9,fontWeight:700,color:ft==="none"?J.textFaint:J.text,letterSpacing:".10em",flex:1},children:Be.label}),(0,e.jsxs)("span",{style:{fontFamily:en,fontSize:9,color:J.textFaint,marginRight:4},children:[Be.layers.filter(function(Xe){return n.has(Xe.id)}).length,"/",Be.layers.length]}),(0,e.jsx)("button",{onClick:function(Xe){Xe.stopPropagation(),Xe.shiftKey&&typeof c=="function"?c(Be.id):o(Be.id)},title:(ft==="full"?"Disable group":"Enable group")+" (shift = solo)",style:{background:"none",border:"1px solid "+(ft==="full"?Be.color+"60":J.borderLight),borderRadius:3,padding:"1px 5px",cursor:"pointer",fontFamily:en,fontSize:8,color:ft==="full"?Be.color:J.textFaint,letterSpacing:".1em"},children:ft==="full"?"ALL":ft==="partial"?"MIX":"OFF"})]}),St&&(0,e.jsx)("div",{style:{paddingLeft:22,paddingBottom:4},children:Fe.map(function(Xe){var It=n.has(Xe.id),Rt=Xe.meta||{},$=U.indexOf(Xe.id)!==-1;return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,width:"100%",padding:"3px 10px 3px 4px",background:It?Xe.color+"0F":"none",borderRadius:3,opacity:It?1:.82,transition:"all 0.1s",position:"relative"},onMouseEnter:function(){de(Xe.id)},onMouseLeave:function(){de(function(Ue){return Ue===Xe.id?null:Ue})},children:[(0,e.jsxs)("button",{onClick:function(){$e(Xe.id)},style:{display:"flex",alignItems:"center",gap:8,flex:1,minWidth:0,background:"none",border:"none",cursor:"pointer",textAlign:"left",padding:0},children:[(0,e.jsx)("div",{style:{width:9,height:9,borderRadius:2,flexShrink:0,background:It?Xe.color:"transparent",border:"1.5px solid "+(It?Xe.color:Xe.color+"55"),boxShadow:It?"0 0 6px "+Xe.color+"55":"none"}}),(0,e.jsx)("span",{style:{fontFamily:Zs,fontSize:10,color:J.text,flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Xe.label}),Rt.confidential&&(0,e.jsx)("span",{title:"Confidential — your data only",style:{fontFamily:en,fontSize:9,color:J.amber,marginLeft:2,flexShrink:0},children:"🔒"})]}),(0,e.jsx)("button",{onClick:function(Ue){Ue.stopPropagation(),ve(Xe.id)},title:$?"Unpin":"Pin",style:{background:"none",border:"none",cursor:"pointer",color:$?J.amber:J.textFaint+"aa",fontSize:9,padding:"0 2px",opacity:$?1:.5},children:$?"★":"☆"}),(0,e.jsx)("button",{title:Rt.description||"",style:{background:"none",border:"none",cursor:"help",color:J.textFaint,fontSize:9,padding:"0 2px"},children:"ⓘ"}),!It&&(0,e.jsx)("span",{style:{fontFamily:en,fontSize:8,color:J.textFaint,letterSpacing:".14em"},children:"OFF"}),X===Xe.id&&Rt&&(Rt.source||Rt.cadence||Rt.description)&&(0,e.jsxs)("div",{style:{position:"absolute",right:-6,top:"100%",marginTop:4,zIndex:40,width:220,padding:"8px 10px",background:J.bgPanel,border:"1px solid "+J.borderLight,borderRadius:4,boxShadow:"0 8px 24px rgba(0,0,0,0.45)",pointerEvents:"none",animation:"arnCtrlFade .14s ease-out"},children:[(0,e.jsx)("div",{style:{fontFamily:en,fontSize:9,fontWeight:700,color:Xe.color,letterSpacing:".14em",marginBottom:4},children:Xe.label}),Rt.description&&(0,e.jsx)("div",{style:{fontFamily:Zs,fontSize:9,color:J.text,lineHeight:1.4,marginBottom:6},children:Rt.description}),(0,e.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",fontFamily:en,fontSize:9,color:J.textFaint,letterSpacing:".1em"},children:[(0,e.jsxs)("span",{children:["SRC: ",Rt.source||"—"]}),(0,e.jsx)("span",{children:Rt.cadence||""})]}),Rt.confidential&&(0,e.jsxs)("div",{style:{marginTop:6,fontFamily:en,fontSize:9,color:J.amber,letterSpacing:".1em"},children:["🔒"," CONFIDENTIAL"]})]})]},Xe.id)})})]},Be.id)})]}),(0,e.jsxs)("div",{style:{borderTop:"1px solid "+J.border,padding:"6px 10px",flexShrink:0},children:[(0,e.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:4},children:[(0,e.jsxs)("span",{onClick:function(){q(!ae)},style:{fontFamily:en,fontSize:9,color:J.textFaint,letterSpacing:".14em",cursor:"pointer",userSelect:"none"},children:[ae?"▾":"▸"," PRESET VIEWS"]}),(0,e.jsxs)("div",{style:{display:"flex",gap:4},children:[(0,e.jsxs)("button",{onClick:function(){typeof f=="function"&&f()},title:"Analyze this view on the map",style:{padding:"2px 6px",background:J.amber+"18",border:"1px solid "+J.amber+"55",borderRadius:3,cursor:"pointer",fontFamily:en,fontSize:9,fontWeight:700,color:J.amber,letterSpacing:".1em"},children:["◈"," ANALYZE VIEW"]}),(0,e.jsxs)("button",{onClick:function(){typeof p=="function"&&p()},title:"Export view + active layers snapshot",style:{padding:"2px 6px",background:"transparent",border:"1px solid "+J.borderLight,borderRadius:3,cursor:"pointer",fontFamily:en,fontSize:9,fontWeight:700,color:J.textFaint,letterSpacing:".1em"},children:["⤓"," EXPORT"]})]})]}),ae&&(0,e.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:3},children:UF.slice(0,6).map(function(Ae,Be){return(0,e.jsxs)("button",{onClick:function(){l(Ae.q)},style:{padding:"2px 6px",background:J.bgInput,border:"1px solid "+J.borderLight,borderRadius:3,cursor:"pointer",fontFamily:en,fontSize:9,color:Ae.color,whiteSpace:"nowrap",transition:"all 0.12s"},onMouseEnter:function(Fe){Fe.currentTarget.style.borderColor=Ae.color},onMouseLeave:function(Fe){Fe.currentTarget.style.borderColor=J.borderLight},children:[Ae.icon," ",Ae.q]},Be)})})]})]})}var iO=6e4;var Ey={CRITICAL:100,HIGH:75,MEDIUM:45,LOW:20},ky={CRITICAL:90,HIGH:60,MEDIUM:35,LOW:15},nk={CRITICAL:95,HIGH:70,MEDIUM:40,LOW:15};function oO(t,n){return n[t]||n.LOW}function rc(t){return t==="CRITICAL"?4:t==="HIGH"?3:t==="MEDIUM"?2:1}function Vp(t){var n=t&&t.position;if(!Array.isArray(n)||n.length<2)return null;var r=Number(n[0]),o=Number(n[1]);return!isFinite(o)||!isFinite(r)?null:[r,o]}function fp(t,n){return!t||!Array.isArray(t[n])?[]:t[n]}function aO(t){return t.slice().sort(function(n,r){return rc(r.risk)-rc(n.risk)})}function pp(t){return typeof window<"u"&&window.location&&/^(localhost|127\.0\.0\.1)$/.test(window.location.hostname)?t:qr(t)}
416function rk(t,n,r){var o=r??750,a=n||[];return(t||[]).map(function(l){var s=Vp(l);if(!s)return l;for(var c=l.risk||"LOW",d=0;d<a.length;d++){var p=a[d],g=Vp(p);if(g){var f=p.risk||"HIGH";rc(f)<3||Of(s[1],s[0],g[1],g[0])>o||rc(f)>rc(c)&&(c=f)}}return c===l.risk?l:Object.assign({},l,{risk:c,liveElevated:!0})})}function Rh(t,n){var r=n??4,o=[];return(t||[]).forEach(function(a){if(!(!a||rc(a.risk)<r)){var l=Vp(a);if(l){for(var s=0;s<o.length;s++){var c=Vp(o[s]);if(c&&Of(c[1],c[0],l[1],l[0])<=400)return}o.push(a)}}}),o.length}function P1(t){return t>=75?{label:"CRITICAL",color:"#FF0000"}:t>=55?{label:"ELEVATED",color:"#FF6B6B"}:t>=35?{label:"MODERATE",color:"#FBBF24"}:{label:"LOW",color:"#3FB950"}}function yg(t,n,r){for(var o=0;o<t.length;o++)r.score+=oO(t[o]&&t[o].risk,n),r.count++}function gp(t,n){if(!t||!t.length)return 0;var r={score:0,count:0};return yg(t,n,r),r.score/r.count}function lO(t,n,r){var o={score:0,count:0};return yg(t,Ey,o),yg(n,ky,o),yg(r,nk,o),o.count?Math.round(o.score/o.count):0}function Fh(t,n){return!t||!Vp(t)?null:{position:t.position,risk:t.risk||n||"HIGH",live:!0}}function sO(t){var n=fp(t,"conflicts"),r=fp(t,"geological").filter(function(_){return _&&rc(_.risk)>=3}),o=fp(t,"news_hotspots"),a=fp(t,"wildfires"),l=fp(t,"cyclones"),s=[];n.forEach(function(_){var w=Fh(_,"HIGH");w&&s.push(w)}),o.forEach(function(_){var w=Fh(_,"HIGH");w&&s.push(w)}),a.forEach(function(_){var w=Fh(_,_.risk||"HIGH");w&&rc(w.risk)>=3&&s.push(w)});var c=rk(nc,s),d=c.filter(function(_){return _.risk==="CRITICAL"||_.risk==="HIGH"}).length;if(!(n.length||r.length||o.length||a.length||l.length)){var p=lO(id,Cf,nc),g=P
4161(p);return{score:p,label:g.label,color:g.color,criticalZones:Rh(id,4),chokepointsAtRisk:d,live:!1}}var f=n.length?Rh(n,3):Rh(id,4),h=aO(n).slice(0,20),x=h.length?gp(h,Ey):gp(id,Ey),v=r.length?gp(Cf.concat(r),ky):gp(Cf,ky),y=gp(c,nk),k=Math.min(8,a.filter(function(_){return _&&rc(_.risk)>=3}).length),A=Math.min(6,Math.floor(o.length/4)),j=Math.min(4,l.length),E=Math.round(x*.5+v*.25+y*.25);E=Math.max(0,Math.min(100,E+k+A+j));var C=P1(E);return{score:E,label:C.label,color:C.color,criticalZones:f,chokepointsAtRisk:d,live:!0}}var cO={conflict:"conflicts",geological:"geological",chokepoint:"chokepoints",cyber:"cyberThreats",wildfire:"wildfires",cyclone:"hurricanes",news:"newsHotspots"},ik=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function dO(t){return t==="CRITICAL"?"#FF0000":t==="HIGH"?"#FF6B6B":"#FBBF24"}function au(t,n,r,o){return t==="CRITICAL"?n:t==="HIGH"?r:o}function Vg(t){return(t<10?"0":"")+t}function sm(t){var n=String(t||"").trim();return/^\d{14}$/.test(n)?n.slice(0,4)+"-"+n.slice(4,6)+"-"+n.slice(6,8)+"T"+n.slice(8,10)+":"+n.slice(10,12)+":"+n.slice(12,14)+"Z":/^\d{4}-\d{2}-\d{2}T/.test(n)?n:/^\d{4}-\d{2}-\d{2}$/.test(n)?n+"T00:00:00Z":""}function uO(t,n){if(t){var r=t.at||t.t||t.added||"";if(r){var o=sm(r);if(o)return o}if(t.since)return String(t.since)}return n?String(n):""}function fO(t,n){if(!t)return"";var r=sm(t);if(!r)return String(t);var o=Date.parse(r);if(isNaN(o))return String(t);var a=(n??Date.now())-o;a<0&&(a=0);var l=Math.floor(a/6e4);if(l<1)return"just now";if(l<60)return l+"m ago";var s=Math.floor(l/60);if(s<24)return s+"h ago";var c=Math.floor(s/24);if(c<7)return c+"d ago";var d=new Date(o);return ik[d.getUTCMonth()]+" "+d.getUTCDate()+" · "+Vg(d.getUTCHours())+":"+Vg(d.getUTCMinutes())+" UTC"}function Cy(t){if(!t)return"";var n=sm(t);if(!n)return String(t);var r=new Date(n);return isNaN(r.getTime())?String(t):ik[r.getUTCMonth()]+" "+r.getUTCDate()+", "+r.getUTCFullYear()+" · "+Vg(r.getUTCHours())+":"+Vg(r.getUTCMinutes())+" UTC"}function ok(t,n){return!t||!n?"":String(t)+":"+String(n.id||"")}function pO(t){return!t||!t.type||!t.data?"":ok(t.type,t.data)}function gO(t){for(var n=t||[],r=0,o=0;o<n.length;o++)n[o]&&n[o].risk==="CRITICAL"&&r++;return{active:n.length,critical:r}}function ks(t,n,r,o,a){if(!(!r||!o)){var l=a.risk||r.risk||"HIGH";t.push({id:ok(n,r),type:n,layerId:cO[n],name:r.name,risk:l,detail:String(r.detail||a.detail||""),at:uO(r,a.receivedAt),icon:a.icon,color:dO(l),position:o,data:r,sortWeight:a.sortWeight,live:!!r.live||!!a.live})}}function mp(t,n){return t&&Array.isArray(t[n])?t[n]:[]}function mO(t){if(t&&Array.isArray(t.position)&&t.position.length>=2)return t.position;var n=t&&t.track;if(Array.isArray(n)&&n.length){var r=n[n.length-1];if(Array.isArray(r)&&r.length>=2)return r}return null}function Ih(t){var n=Number(t&&t.vel);return n>=120?"CRITICAL":n>=40?"HIGH":"MEDIUM"}function U1(t){var n=sm(t);if(!n)return 0;var r=Date.parse(n);return isNaN(r)?0:r}function ak(t){return t.sort(function(n,r){var o=(r.sortWeight||0)-(n.sortWeight||0);return o||U1(r.at)-U1(n.at)}),t.slice(0,50)}function hO(t){return!!(t&&typeof t=="object"&&(t.meta||Array.isArray(t.conflicts)||Array.isArray(t.geological)||Array.isArray(t.wildfires)||Array.isArray(t.cyclones)||Array.isArray(t.news_hotspots)))}function yO(){var t=[];return id.forEach(function(n){ks(t,"conflict",n,n.position,{icon:"⚠",sortWeight:au(n.risk,100,80,50)})}),Cf.forEach(function(n){ks(t,"geological",n,n.position,{icon:n.type==="volcanic"?"🌋":"⚠",sortWeight:au(n.risk,90,70,40)})}),nc.forEach(function(n){n.risk!=="CRITICAL"&&n.risk!=="HIGH"||ks(t,"chokepoint",n,n.position,{icon:"●",detail:(n.transit?n.transit+" — ":"")+(n.threat||n.detail||""),sortWeight:au(n.risk,95,75,0)})}),vy.forEach(function(n){ks(t,"cyber",n,n.origin,{icon:"●",risk:"HIGH",detail:n.attribution+" — "+n.detail,sortWeight:65})}),ak(t)}function xO(t){var n=[],r=t.meta&&t.meta.fetched_at||"",o=mp(t,"conflicts");return o.forEach(function(a){ks(n,"conflict",a,a.position,{icon:"⚠",receivedAt:r,live:!0,sortWeight:au(a.risk,110,80,50)})}),mp(t,"geological").forEach(function(a){ks(n,"geological",a,a.position,{icon:a.type==="volcanic"?"🌋":"⚠",receivedAt:r,live:!0,sortWeight:au(a.risk,9
4160,70,40)})}),mp(t,"wildfires").forEach(function(a){ks(n,"wildfire",a,a.position,{icon:"🔥",receivedAt:r,live:!0,sortWeight:au(a.risk,88,68,35)})}),mp(t,"cyclones").forEach(function(a){ks(n,"cyclone",a,mO(a),{icon:"🌀",receivedAt:r,live:!0,risk:a.cat>=4?"CRITICAL":a.cat>=2?"HIGH":"MEDIUM",sortWeight:a.cat>=4?92:a.cat>=2?72:42})}),mp(t,"news_hotspots").forEach(function(a){ks(n,"news",a,a.position,{icon:"●",receivedAt:r,live:!0,risk:Ih(a),sortWeight:Ih(a)==="CRITICAL"?85:Ih(a)==="HIGH"?60:30})}),rk(nc,o).forEach(function(a){a.liveElevated&&ks(n,"chokepoint",a,a.position,{icon:"●",receivedAt:r,live:!0,detail:(a.transit?a.transit+" — ":"")+(a.threat||a.detail||""),sortWeight:au(a.risk,95,75,0)})}),ak(n)}function lk(t){return hO(t)?xO(t):yO()}var vO=lk();function bO({items:t,onSelect:n,selectedItem:r,collapsed:o,onToggleCollapse:a,onRefresh:l,refreshing:s,status:c}){var d=pO(r),p=Array.isArray(t)?t:vO,g=gO(p),f=c||(Array.isArray(t)?"live":"catalog");return o?(0,e.jsxs)("div",{style:{width:36,flexShrink:0,borderLeft:"1px solid "+J.border,background:J.bgPanel,display:"flex",flexDirection:"column",alignItems:"center",paddingTop:10},children:[(0,e.jsx)("button",{onClick:a,style:{background:"none",border:"none",cursor:"pointer",color:J.amber,fontSize:14,padding:4},title:"Expand feed",children:"◀"}),(0,e.jsx)("div",{style:{fontFamily:en,fontSize:9,color:J.red,letterSpacing:".08em",writingMode:"vertical-rl",marginTop:10},children:"LIVE FEED"})]}):(0,e.jsxs)("div",{style:{width:220,flexShrink:0,borderLeft:"1px solid "+J.border,background:J.bgPanel,display:"flex",flexDirection:"column",overflow:"hidden"},"data-testid":"intel-live-feed",children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 10px",borderBottom:"1px solid "+J.border,flexShrink:0},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,e.jsx)("div",{style:{width:6,height:6,borderRadius:"50%",background:J.red,boxShadow:"0 0 6px rgba(255,68,68,0.6)",animation:"pulse 2s infinite"}}),(0,e.jsx)("span",{style:{fontFamily:en,fontSize:9,fontWeight:700,color:J.red,letterSpacing:".12em"},children:"LIVE INTEL FEED"})]}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4},children:[(0,e.jsx)("button",{type:"button","data-testid":"intel-feed-refresh",onClick:function(){typeof l=="function"&&!s&&l()},disabled:!!s,title:"Fetch the latest live intelligence without reloading the map",style:{background:"none",border:"1px solid "+J.borderLight,borderRadius:3,cursor:s?"wait":"pointer",color:J.amber,fontFamily:en,fontSize:8,fontWeight:700,letterSpacing:".08em",padding:"2px 6px",opacity:s?.6:1},children:s?"⟳ …":"⟳ REFRESH"}),(0,e.jsx)("button",{onClick:a,style:{background:"none",border:"none",cursor:"pointer",color:J.textFaint,fontSize:10,padding:2},children:"▶"})]})]}),(0,e.jsx)("div",{style:{flex:1,minHeight:0,padding:"4px 0"},children:f==="loading"&&!p.length?(0,e.jsx)("div",{"data-testid":"intel-feed-status",style:{fontFamily:en,fontSize:8,color:J.textFaint,letterSpacing:".08em",textAlign:"center",padding:"18px 12px"},children:"FETCHING LIVE INTEL"}):f==="error"&&!p.length?(0,e.jsx)("div",{"data-testid":"intel-feed-status",style:{fontFamily:en,fontSize:8,color:J.textFaint,letterSpacing:".08em",textAlign:"center",padding:"18px 12px"},children:"LIVE INTEL UNAVAILABLE"}):(0,e.jsx)(PA,{items:p,estimatedSize:64,itemKey:function(h){return h.id},renderItem:function(h){var x=h.id===d;return(0,e.jsxs)("button",{type:"button","data-testid":"intel-feed-item","data-feed-id":h.id,"aria-pressed":x?"true":"false",onClick:function(){typeof n=="function"&&n(h)},style:{display:"block",width:"100%",padding:"6px 10px",background:x?J.bgInput:"none",border:"none",borderBottom:"1px solid "+J.border,boxShadow:x?"inset 3px 0 0 "+h.color:"none",cursor:"pointer",textAlign:"left",transition:"background 0.12s"},onMouseEnter:function(v){v.currentTarget.style.background=J.bgInput},onMouseLeave:function(v){v.currentTarget.style.background=x?J.bgInput:"none"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:5,marginBottom:2},children:[(0,e.jsx)("span",{style:{fontSize:9,color:h.color},children:h.icon}),(0,e.jsx)("span",{style:{fontFamily:en,fontSize:9,fontWeight:600,color:J.text,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h.name}),(0,e.jsx)("span",{style:{fontFamily:en,fontSize:8,fontWeight:700,padding:"1px 4px",borderRadius:2,letterSpacing:".06em",background:h.risk==="CRITICAL"?"rgba(255,0,0,0.15)":h.risk==="HIGH"?"rgba(255,107,107,0.1)":"rgba(251,191,36,0.1)",color:h.risk==="CRITICAL"?"#FF0000":h.risk==="HIGH"?"#FF6B6B":"#FBBF24"},children:h.risk})]}),h.at?(0,e.jsx)("div",{"data-testid":"intel-feed-time",title:Cy(h.at),style:{fontFamily:en,fontSize:8,color:J.textFaint,letterSpacing:".06em",marginBottom:2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:fO(h.at)}):null,(0,e.jsx)("div",{style:{fontFamily:Zs,fontSize:9.5,color:J.textMuted,lineHeight:1.4,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:h.detail})]})}})}),(0,e.jsx)("div",{style:{padding:"6px 10px",borderTop:"1px solid "+J.border,flexShrink:0},children:(0,e.jsx)("div",{"data-testid":"intel-feed-status-line",style:{fontFamily:en,fontSize:8,color:J.textGhost,textAlign:"center",letterSpacing:".08em"},children:f==="loading"&&!p.length?(0,e.jsx)("span",{"data-testid":"intel-feed-active-count",children:"FETCHING"}):f==="error"&&!p.length?(0,e.jsx)("span",{"data-testid":"intel-feed-active-count",children:"UNAVAILABLE"}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("span",{"data-testid":"intel-feed-active-count",children:[g.active," ACTIVE"]}),"  ·  ",(0,e.jsxs)("span",{"data-testid":"intel-feed-critical-count",children:[g.critical," CRITICAL"]})]})})})]})}function SO({place:t}){var n=(0,i.useState)(null),r=n[0],o=n[1];return(0,i.useEffect)(function(){var a=!1;return o(null),Promise.resolve().then(function(){return fetch(qr("/api/map/hotspot-news?place="+encodeURIComponent(t)),{headers:fo()})}).then(function(l){return l&&l.ok?l.json():null}).then(function(l){a||o(l||{items:[],status:"unavailable"})}).catch(function(l){a||o({items:[],status:"unavailable"})}),function(){a=!0}},[t,o]),(0,e.jsxs)("div",{style:{marginTop:8,borderTop:"1px solid "+J.border,paddingTop:8},children:[(0,e.jsx)("div",{style:{fontFamily:en,fontSize:8,fontWeight:700,color:J.textFaint,letterSpacing:".14em",marginBottom:5},children:"LIVE WIRES"}),r?r.items&&r.items.length?r.items.slice(0,5).map(function(a,l){return(0,e.jsxs)("div",{style:{marginBottom:6},children:[(0,e.jsx)("div",{style:{fontFamily:Zs,fontSize:10.5,color:J.text,lineHeight:1.45},children:a.title}),(0,e.jsxs)("div",{style:{fontFamily:en,fontSize:8,color:J.textFaint,letterSpacing:".06em"},children:[(a.source||"WIRE").toUpperCase(),a.time?" · "+String(a.time).slice(0,16):""]})]},l)}):(0,e.jsx)("div",{style:{fontFamily:en,fontSize:9,color:J.textFaint},children:r.status==="no-coverage"?"NO WIRE COVERAGE FOR THIS LOCATION YET":"WIRES UNAVAILABLE"}):(0,e.jsx)("div",{style:{fontFamily:en,fontSize:9,color:J.textFaint},children:"FETCHING…"})]})}function W1(t,n){if(!n||!n.live)return null;if(t==="news")return n.name||null;if(t==="conflict"){var r=n.name||"",o=r.indexOf("—");return(o>=0?r.slice(o+1):r).trim()||null}return null}function EO(t){return t==="CRITICAL"?"#FF0000":t==="HIGH"?"#FF6B6B":t==="MEDIUM"?"#FBBF24":"#3FB950"}function kO(t){return t==="CRITICAL"?"rgba(255,0,0,0.12)":t==="HIGH"?"rgba(255,107,107,0.1)":t==="MEDIUM"?"rgba(251,191,36,0.08)":"rgba(63,185,80,0.08)"}function Un({label:t,value:n,color:r}){return(0,e.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:5,alignItems:"flex-start"},children:[(0,e.jsx)("span",{style:{fontFamily:en,fontSize:9,color:J.textMuted,letterSpacing:".06em",flexShrink:0},children:t}),(0,e.jsx)("span",{style:{fontFamily:en,fontSize:9,color:r||J.text,fontWeight:600,textAlign:"right",maxWidth:150},children:n})]})}function CO({item:t,onClose:n}){if(!t)return null;var r=t.data,o=t.type,a=r.name||r.title||"Intel Point",l=r.risk||null,s=r.detail||(
416o==="chokepoint"&&r.transit?String(r.transit)+" — "+String(r.threat||""):""),c=o==="pipeline"?t.subtype==="gas"?"GAS PIPELINE":"OIL PIPELINE":o==="lngRoute"?"LNG ROUTE":o==="chokepoint"?"CHOKEPOINT":o==="conflict"?"CONFLICT":o==="sanctions"?"SANCTIONS ZONE":o==="military"?"MILITARY BASE":o==="geological"?"GEOLOGICAL ALERT":o==="portfolio"?"PORTFOLIO POSITION":o==="opportunity"?"OPPORTUNITY":o==="centralBank"?"CENTRAL BANK":o==="commodity"?"COMMODITY HUB":o==="dealRoom"?"DEAL ROOM":o==="myWatchlist"?r.mock?"MOCK WATCHLIST":"WATCHLIST":o==="myPortfolio"?r.mock?"MOCK PORTFOLIO":"MY PORTFOLIO":o==="myAlert"?"MY ALERT":o==="offshoreHub"?"OFFSHORE HUB":o==="fbo"?"FBO / AVIATION":o==="cyber"?"CYBER THREAT":o==="supplyChain"?"SUPPLY CHAIN":o==="shipping"?"SHIPPING ROUTE":o==="weather"?"WEATHER ALERT":o==="wildfire"?"WILDFIRE":o==="cyclone"?"CYCLONE":o==="news"?"NEWS HOTSPOT":o==="timelineEvent"?"TIMELINE EVENT":"INTEL",d=o==="pipeline"&&t.subtype==="gas"?J.blue:o==="pipeline"?J.orange:o==="lngRoute"?J.teal:o==="chokepoint"||o==="conflict"?J.red:o==="sanctions"?J.purple:o==="military"?J.indigo:o==="geological"?J.redBright:o==="portfolio"?J.amber:o==="opportunity"?J.green:o==="centralBank"?J.yellow:o==="commodity"?J.amber:o==="dealRoom"||o==="fbo"?J.purple:o==="cyber"?J.pink:o==="supplyChain"?J.orange:o==="shipping"?J.blue:J.amber;return(0,e.jsxs)("div",{"data-testid":"intel-detail",style:{position:"absolute",bottom:50,left:"50%",transform:"translateX(-50%)",width:380,maxHeight:380,background:"rgba(6,8,13,0.95)",backdropFilter:"blur(12px)",border:"1px solid "+J.borderLight,borderRadius:8,padding:0,zIndex:60,boxShadow:"0 8px 32px rgba(0,0,0,0.5)",overflow:"hidden"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",borderBottom:"1px solid "+J.border},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,e.jsx)("div",{style:{width:6,height:6,borderRadius:"50%",background:d,boxShadow:"0 0 6px "+d+"80"}}),(0,e.jsx)("span",{style:{fontFamily:en,fontSize:9,fontWeight:700,color:d,letterSpacing:".12em"},children:c})]}),(0,e.jsxs)("button",{onClick:n,style:{background:"none",border:"1px solid "+J.borderLight,borderRadius:3,padding:"2px 8px",cursor:"pointer",fontFamily:en,fontSize:9,color:J.textFaint,transition:"all 0.15s"},onMouseEnter:function(p){p.currentTarget.style.color=J.amber,p.currentTarget.style.borderColor=J.amber+"40"},onMouseLeave:function(p){p.currentTarget.style.color=J.textFaint,p.currentTarget.style.borderColor=J.borderLight},children:["✕"," CLOSE"]})]}),(0,e.jsxs)("div",{style:{padding:"10px 14px",overflowY:"auto",maxHeight:320},children:[(0,e.jsx)("div",{style:{fontSize:14,fontWeight:600,color:J.text,fontFamily:Zs,marginBottom:6},children:a}),r.mock&&(0,e.jsx)("span",{style:{display:"inline-block",padding:"2px 8px",borderRadius:3,fontFamily:en,fontSize:9,fontWeight:700,letterSpacing:".08em",background:J.amber+"22",color:J.amber,marginBottom:8},children:"MOCK DATA — not your book"}),l&&(0,e.jsxs)("span",{style:{display:"inline-block",padding:"2px 8px",borderRadius:3,fontFamily:en,fontSize:9,fontWeight:700,letterSpacing:".08em",background:kO(l),color:EO(l),marginBottom:8},children:["RISK: ",l]}),(0,e.jsx)("div",{"data-testid":"intel-detail-text",style:{fontSize:10.5,color:J.textDim,lineHeight:1.7,fontFamily:Zs,marginBottom:10,whiteSpace:"pre-line"},children:s}),o==="pipeline"&&(0,e.jsxs)(e.Fragment,{children:[r.capacity&&(0,e.jsx)(Un,{label:"CAPACITY",value:r.capacity}),r.operator&&(0,e.jsx)(Un,{label:"OPERATOR",value:r.operator}),r.status&&(0,e.jsx)(Un,{label:"STATUS",value:r.status.toUpperCase(),color:r.status==="active"?J.green:r.status==="destroyed"?J.red:J.yellow})]}),o==="conflict"&&(0,e.jsxs)(e.Fragment,{children:[r.actors&&(0,e.jsx)(Un,{label:"ACTORS",value:r.actors}),r.since&&(0,e.jsx)(Un,{label:"SINCE",value:r.since}),r.at&&(0,e.jsx)(Un,{label:"WHEN",value:Cy(r.at)}),r.affectedSectors&&(0,e.jsx)(Un,{label:"SECTORS",value:r.affectedSectors.join(", ")})]}),W1(o,r)&&(0,e.jsx)(SO,{place:W1(o,r)}),o==="commodity"&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(Un,{label:"BENCHMARK",value:r.benchmark}),r.commodity&&(0,e.jsx)(Un,{label:"COMMODITY",value:r.commodity}),(0,e.jsx)(Un,{label:"PRICE",value:r.price||"NO LIVE PRINT",color:r.price?r.trend==="up"?J.green:J.red:J.textFaint}),r.change?(0,e.jsx)(Un,{label:"CHANGE",value:r.change,color:r.change.indexOf("-")===0?J.red:J.green}):null]}),o==="dealRoom"&&(0,e.jsxs)(e.Fragment,{children:[r.target&&(0,e.jsx)(Un,{label:"TARGET",value:r.target}),r.stage&&(0,e.jsx)(Un,{label:"STAGE",value:r.stage,color:J.purple})]}),o==="offshoreHub"&&(0,e.jsx)(e.Fragment,{children:r.secrecy!=null&&(0,e.jsx)(Un,{label:"SECRECY",value:r.secrecy+"/100",color:J.blue})}),o==="portfolio"&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(Un,{label:"VALUE",value:"$"+r.value+"M",color:J.amber}),(0,e.jsx)(Un,{label:"ALLOCATION",value:r.alloc+"%"}),(0,e.jsx)(Un,{label:"PNL",value:r.pnl,color:r.pnl&&r.pnl.indexOf("-")===0?J.red:J.green})]}),o==="centralBank"&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(Un,{label:"RATE",value:r.rate,color:J.yellow}),(0,e.jsx)(Un,{label:"BIAS",value:r.bias.toUpperCase(),color:r.bias==="hawkish"?J.red:r.bias==="dovish"?J.blue:J.yellow}),(0,e.jsx)(Un,{label:"LAST MOVE",value:r.lastMove})]}),o==="opportunity"&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(Un,{label:"CONVICTION",value:"★".repeat(r.conviction),color:J.green}),(0,e.jsx)(Un,{label:"HORIZON",value:r.timeHorizon}),r.sectors&&(0,e.jsx)(Un,{label:"SECTORS",value:r.sectors.join(", ")})]}),o==="military"&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(Un,{label:"FORCE",value:r.force}),(0,e.jsx)(Un,{label:"TYPE",value:r.type.toUpperCase()}),(0,e.jsx)(Un,{label:"RANGE",value:r.projectionRadiusKm+" km"})]}),o==="geological"&&(0,e.jsxs)(e.Fragment,{children:[r.magnitude>0&&(0,e.jsx)(Un,{label:"MAGNITUDE",value:"M"+r.magnitude,color:J.redBright}),(0,e.jsx)(Un,{label:"TYPE",value:r.type.toUpperCase()}),r.depth&&(0,e.jsx)(Un,{label:"DEPTH",value:r.depth}),r.at&&(0,e.jsx)(Un,{label:"WHEN",value:Cy(r.at)})]}),o==="sanctions"&&(0,e.jsxs)(e.Fragment,{children:[r.regimes&&(0,e.jsx)(Un,{label:"REGIMES",value:r.regimes.join(", ")}),r.type&&(0,e.jsx)(Un,{label:"TYPE",value:String(r.type).toUpperCase()})]}),o==="chokepoint"&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(Un,{label:"TRANSIT",value:r.transit}),(0,e.jsx)(Un,{label:"THREAT",value:r.threat,color:J.red})]}),o==="cyber"&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(Un,{label:"ATTRIBUTION",value:r.attribution,color:J.pink}),(0,e.jsx)(Un,{label:"TYPE",value:r.type.toUpperCase()})]}),o==="supplyChain"&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(Un,{label:"TYPE",value:r.type}),(0,e.jsx)(Un,{label:"IMPACT",value:r.disruptionImpact,color:r.disruptionImpact==="CRITICAL"?J.red:J.yellow})]}),o==="fbo"&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(Un,{label:"ICAO",value:r.code,color:J.purple}
416),(0,e.jsx)(Un,{label:"REGION",value:r.region})]})]})]})}var AO=[{t:.05,label:"Nord Stream sabotage",color:"#FF3C3C"},{t:.25,label:"Turkey earthquake M7.8",color:"#FF6B6B"},{t:.45,label:"Gaza conflict begins",color:"#FF0000"},{t:.55,label:"Houthi Red Sea attacks",color:"#FF0000"},{t:.75,label:"Sahel coups spread",color:"#FBBF24"},{t:.95,label:"NOW",color:"#F5A623"}],jO={curated:"#FF6B6B",quake:"#FBBF24",alert:"#FF3C3C",watch:"#F5A623"};function wO({value:t,onChange:n,playing:r,onTogglePlay:o,events:a,windowDays:l,onSelectEvent:s}){var c=(0,i.useRef)(null),d=(0,i.useState)(!1),p=d[0],g=d[1],f=Array.isArray(a)&&a.length>0,h=(l||730)*864e5,x=Date.now()-h;function v(A){var j=Date.parse(A.t);if(!isFinite(j))return null;var E=(j-x)/h;return E<0?0:E>1?1:E}function y(){if(t>=.98)return"NOW";if(!f)return Math.round(t*24)+"M";var A=new Date(x+t*h);return(A.toUTCString().slice(8,11)+" "+A.getUTCDate()).toUpperCase()}function k(A){if(c.current){var j=c.current.getBoundingClientRect();n(Math.max(0,Math.min(1,(A.clientX-j.left)/j.width)))}}return(0,e.jsxs)("div",{style:{height:38,flexShrink:0,borderTop:"1px solid "+J.border,background:J.bgPanel,display:"flex",alignItems:"center",padding:"0 12px",gap:8},children:[(0,e.jsx)("button",{type:"button",onClick:o,title:f?"Replay the event timeline chronologically":"Timeline playback","aria-label":r?"Pause timeline playback":"Play timeline",style:{background:"none",border:"1px solid "+J.borderLight,borderRadius:3,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",color:r?J.amber:J.textFaint,fontSize:9,transition:"all 0.15s"},onMouseEnter:function(A){A.currentTarget.style.borderColor=J.amber+"50"},onMouseLeave:function(A){A.currentTarget.style.borderColor=J.borderLight},children:r?"❚❚":"▶"}),(0,e.jsxs)("div",{ref:c,style:{flex:1,height:14,position:"relative",cursor:"pointer"},onMouseDown:function(A){g(!0),k(A)},onMouseMove:function(A){p&&k(A)},onMouseUp:function(){g(!1)},onMouseLeave:function(){g(!1)},children:[(0,e.jsx)("div",{style:{position:"absolute",top:6,left:0,right:0,height:2,background:J.borderLight,borderRadius:1}}),(0,e.jsx)("div",{style:{position:"absolute",top:6,left:0,width:t*100+"%",height:2,background:J.amber,borderRadius:1}}),f?a.map(function(A){var j=v(A);if(j==null)return null;var E=jO[A.kind]||"#8898A8",C=j<=t;return(0,e.jsxs)("div",{title:A.label+" — "+String(A.t).slice(0,10)+(A.risk?" · "+A.risk:""),onMouseDown:function(_){_.stopPropagation()},onClick:function(_){_.stopPropagation(),typeof s=="function"&&s(A)},style:{position:"absolute",left:j*100+"%",top:0,transform:"translateX(-50%)",cursor:"pointer",opacity:C?1:.35,transition:"opacity 0.2s"},children:[(0,e.jsx)("div",{style:{width:5,height:5,borderRadius:"50%",background:E,margin:"0 auto 1px",boxShadow:C?"0 0 5px "+E:"none"}}),(0,e.jsx)("div",{style:{width:1,height:6,background:E+"60",margin:"0 auto"}})]},A.id)}):AO.map(function(A){return(0,e.jsxs)("div",{style:{position:"absolute",left:A.t*100+"%",top:0,transform:"translateX(-50%)"},title:A.label,children:[(0,e.jsx)("div",{style:{width:3,height:3,borderRadius:"50%",background:A.color,margin:"0 auto 1px"}}),(0,e.jsx)("div",{style:{width:1,height:6,background:A.color+"60",margin:"0 auto"}})]},A.label)}),(0,e.jsx)("div",{style:{position:"absolute",top:2,left:t*100+"%",transform:"translateX(-50%)",width:10,height:10,borderRadius:"50%",background:J.amber,border:"2px solid "+J.bg,pointerEvents:"none",boxShadow:"0 0 6px rgba(245,166,35,0.5)",transition:p?"none":"left 0.1s"}})]}),(0,e.jsx)("span",{style:{fontFamily:en,fontSize:9,color:J.textFaint,letterSpacing:".08em",minWidth:42,textAlign:"right"},children:y()})]})}function TO({liveLayers:t}){var n=sO(t),r=n.score,o=n.label,a=n.color,l=28,s=2*Math.PI*l,c=s*.75,d=c*(r/100);return(0,e.jsxs)("div",{"data-testid":"intel-risk-dial",style:{position:"absolute",top:12,right:12,zIndex:55,background:"rgba(6,8,13,0.9)",backdropFilter:"blur(8px)",border:"1px solid "+J.borderLight,borderRadius:8,padding:"8px 12px",display:"flex",alignItems:"center",gap:10},children:[(0,e.jsxs)("svg",{width:"64",height:"64",viewBox:"0 0 64 64",children:[(0,e.jsx)("circle",{cx:"32",cy:"32",r:l,fill:"none",stroke:J.borderLight,strokeWidth:"4",strokeDasharray:c+" "+(s-c),strokeDashoffset:-s*.125,strokeLinecap:"round"}),(0,e.jsx)("circle",{cx:"32",cy:"32",r:l,fill:"none",stroke:a,strokeWidth:"4",strokeDasharray:d+" "+(s-d),strokeDashoffset:-s*.125,strokeLinecap:"round",style:{transition:"stroke-dasharray 0.5s"}}),(0,e.jsx)("text",{"data-testid":"intel-risk-score",x:"32",y:"30",textAnchor:"middle",fill:a,style:{fontFamily:en.replace(/'/g,""),fontSize:14,fontWeight:700},children:r}),(0,e.jsx)("text",{x:"32",y:"40",textAnchor:"middle",fill:J.textFaint,style:{fontFamily:en.replace(/'/g,""),fontSize:8.5,letterSpacing:"0.08em"},children:"RISK"})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:3},children:[(0,e.jsx)("div",{"data-testid":"intel-risk-label",style:{fontFamily:en,fontSize:9,fontWeight:700,color:a,letterSpacing:".12em"},children:o}),n.live?(0,e.jsx)("div",{"data-testid":"intel-risk-live",style:{fontFamily:en,fontSize:8,fontWeight:700,color:"#FF6B6B",letterSpacing:".1em"},children:"LIVE"}):null]}),(0,e.jsxs)("div",{"data-testid":"intel-risk-critical-zones",style:{fontFamily:en,fontSize:9,color:J.textFaint,letterSpacing:".06em"},children:[n.criticalZones," critical zones"]}
416),(0,e.jsxs)("div",{"data-testid":"intel-risk-chokepoints",style:{fontFamily:en,fontSize:9,color:J.textFaint,letterSpacing:".06em"},children:[n.chokepointsAtRisk," chokepoints at risk"]})]})]})}function _O({onClose:t,externalSearchQuery:n,paused:r,onViewportChange:o,onSelectionChange:a,onActiveLayersChange:l,onReady:s,onAskPilot:c,onAskChat:d,onDrawerContext:p}){var g=(0,i.useState)(up),f=g[0],h=g[1],x=(0,i.useState)(function(){return new Set(gf)}),v=x[0],y=x[1],k=(0,i.useState)(null),A=k[0],j=k[1],E=(0,i.useState)(0),C=E[0],_=E[1],w=(0,i.useState)(1),O=w[0],M=w[1],U=(0,i.useState)(!1),ee=U[0],N=U[1],V=(0,i.useState)(!1),z=V[0],oe=V[1],P=(0,i.useState)(!1),W=P[0],R=P[1],ae=(0,i.useState)(null),q=ae[0],ge=ae[1],X=(0,i.useState)("7d"),de=X[0],We=X[1],te=(0,i.useState)(null),_e=te[0],ve=te[1],Ne=(0,i.useRef)(performance.now()),$e=(0,i.useRef)(0);(0,i.useEffect)(function(){if(r)return;var B,ie=0;function ue(ne){var Me=ne-Ne.current;Ne.current=ne,ne-ie>66&&(_(function(nt){return nt+Me*.001}),ie=ne),B=requestAnimationFrame(ue)}return B=requestAnimationFrame(ue),function(){cancelAnimationFrame(B)}},[r]),(0,i.useEffect)(function(){if(ee){var B=!0,ie=setInterval(function(){var ue=B;B=!1,M(function(ne){var Me=YD(ne,{justStarted:ue});return Me.done?(N(!1),1):Me.value})},50);return function(){clearInterval(ie)}}},[ee]),(0,i.useEffect)(function(){!n||!n.trim()||ot(n.trim())},[n]),(0,i.useEffect)(function(){typeof o=="function"&&o(f)},[f]),(0,i.useEffect)(function(){typeof a=="function"&&a(A)},[A]),(0,i.useEffect)(function(){typeof l=="function"&&l(Array.from(v))},[v]),(0,i.useEffect)(function(){typeof p=="function"&&p({active_layers:Array.from(v),view_state:{lng:Number(f.longitude.toFixed(3)),lat:Number(f.latitude.toFixed(3)),zoom:Number(f.zoom.toFixed(1)),pitch:Math.round(f.pitch)},horizon:de,route_label:q||null,selected_item:A?{id:A.id||null,kind:A.kind||A.type||null,label:A.label||A.headline||null}:null})},[v,f,de,q,A]);var Pe=(0,i.useRef)(!1);(0,i.useEffect)(function(){Pe.current||typeof s=="function"&&(Pe.current=!0,s({flyTo:function(B,ie,ue,ne){re(B,ie,ue,ne)},setActiveLayers:function(B){if(B==="ALL"){y(new Set(La));return}if(B==="DEFAULT"){y(new Set(gf));return}Array.isArray(B)&&y(new Set(B.filter(function(ie){return La.indexOf(ie)!==-1})))},toggleLayer:function(B){we(B)},applyPreset:function(B){if(B){if(typeof B=="string"){var ie=ZE.find(function(ue){return ue.id===B});ie&&Be(ie);return}Be(B)}},setHorizon:function(B){We(B)},exportSnapshot:function(){St()},reset:function(){y(new Set(gf)),h(Object.assign({},up)),ge(null),j(null)}}))},[]);function ot(B){var ie=(B||"").trim();if(ie){var ue=PD(ie);if(ue){ue.layers==="ALL"?y(new Set(La)):y(new Set(ue.layers)),ue.center&&re(ue.center.lng,ue.center.lat,ue.zoom||4,ue.pitch||45),ge(ie),j(null);return}var ne=$e.current+1;$e.current=ne,fetch(pp("/api/map/geocode?q="+encodeURIComponent(ie)),{headers:fo()}).then(function(Me){return Me&&Me.ok?Me.json():null}).then(function(Me){if(ne===$e.current&&!(!Me||Me.lng==null||Me.lat==null)){var nt=Number(Me.lng),ct=Number(Me.lat);!isFinite(nt)||!isFinite(ct)||(re(nt,ct,Number(Me.zoom)||6,45),ge(Me.name||ie),j(null))}}).catch(function(Me){})}}function re(B,ie,ue,ne){h(function(Me){return Object.assign({},Me,{longitude:B,latitude:ie,zoom:ue||5,pitch:ne||45,bearing:Me.bearing})})}var we=(0,i.useCallback)(function(B){y(function(ie){var ue=new Set(ie);return ue.has(B)?ue.delete(B):ue.add(B),ue})},[]),b=(0,i.useCallback)(function(B){var ie=od.find(function(ue){return ue.id===B});ie&&y(function(ue){var ne=new Set(ue),Me=ie.layers.every(function(nt){return ne.has(nt.id)});return ie.layers.forEach(function(nt){Me?ne.delete(nt.id):ne.add(nt.id)}),ne})},[]),He=(0,i.useCallback)(function(B){j(B)},[]),tt=(0,i.useCallback)(function(B){B&&(B.layerId&&y(function(ie){if(ie.has(B.layerId))return ie;var ue=new Set(ie);return ue.add(B.layerId),ue}),B.position&&B.position.length>=2&&re(B.position[0],B.position[1],7,50),j({type:B.type,data:B.data}))},[]),Ae=(0,i.useCallback)(function(){},[]),Be=(0,i.useCallback)(function(B){if(B){var ie=B.layers==="ALL"?La.slice():B.layers||[];y(new Set(ie)),B.view&&re(B.view.lng,B.view.lat,B.view.zoom||3,B.view.pitch||40),ge(B.label||null),j(null)}},[]),Fe=(0,i.useCallback)(function(B){var ie=od.find(function(ue){return ue.id===B});ie&&y(new Set(ie.layers.map(function(ue){return ue.id})))},[]),ft=(0,i.useCallback)(function(B){var ie=Gg[B];if(ie){var ue={energy:{lng:40,lat:30,zoom:3,pitch:45},geopolitical:{lng:35,lat:30,zoom:3,pitch:40},financial:{lng:0,lat:45,zoom:3,pitch:40},environment:{lng:0,lat:10,zoom:2.2,pitch:35},transport:{lng:60,lat:20,zoom:2.5,pitch:40},overlays:{lng:25,lat:25,zoom:2.2,pitch:35},intel:{lng:10,lat:30,zoom:2.5,pitch:35},crypto:{lng:60,lat:30,zoom:2.3,pitch:35},user:{lng:10,lat:45,zoom:3,pitch:40}}[ie.group]||{lng:25,lat:25,zoom:2.5,pitch:40};re(ue.lng,ue.lat,ue.zoom,ue.pitch)}},[]),St=(0,i.useCallback)(function(){try{var B=new Date().toISOString().replace(/[:.]/g,"-"),ie={platform:"map",t
416imestamp:new Date().toISOString(),viewport:f,activeLayers:Array.from(v),horizon:de,routeLabel:q||null,selection:A||null},ue=new Blob([JSON.stringify(ie,null,2)],{type:"application/json"}),ne=URL.createObjectURL(ue),Me=document.createElement("a");Me.href=ne,Me.download="map-snapshot-"+B+".json",document.body.appendChild(Me),Me.click(),Me.remove(),setTimeout(function(){URL.revokeObjectURL(ne)},2e3);try{var nt=document.querySelector(".deckgl-wrapper canvas, #deckgl-overlay, canvas");nt&&nt.toBlob&&nt.toBlob(function(ct){if(ct){var je=URL.createObjectURL(ct),Le=document.createElement("a");Le.href=je,Le.download="map-snapshot-"+B+".png",document.body.appendChild(Le),Le.click(),Le.remove(),setTimeout(function(){URL.revokeObjectURL(je)},2e3)}})}catch{}try{fetch(qr("/api/arenberg/audit/export"),{method:"POST",headers:fo(),body:JSON.stringify({kind:"map-snapshot",payload:ie})}).catch(function(){})}catch{}ve("Snapshot exported"),setTimeout(function(){ve(null)},2200)}catch{ve("Export failed"),setTimeout(function(){ve(null)},2200)}},[f,v,de,q,A]),Xe=(0,i.useCallback)(function(B){if(typeof c=="function"){c(B);return}try{typeof window<"u"&&window.ArenbergPilot&&typeof window.ArenbergPilot.open=="function"&&window.ArenbergPilot.open({prefill:"Explain the current map view — "+(B.activeLayers||[]).join(", ")+" — on a "+(B.horizon||"7d")+" horizon."})}catch{}},[c]),It=(0,i.useCallback)(function(){if(typeof d=="function"){var B=Array.from(v).slice(0,12).join(", "),ie=f||{},ue=A&&A.data&&(A.data.name||A.data.sym);d("Analyze the current Intel Map view: layers ["+B+"] on a "+(de||"7d")+" horizon, centered at "+(ie.latitude!=null?ie.latitude.toFixed(2):"?")+", "+(ie.longitude!=null?ie.longitude.toFixed(2):"?")+" (zoom "+(ie.zoom!=null?ie.zoom.toFixed(1):"?")+")"+(ue?", selected: "+ue:"")+". Give an institutional read: key exposures, risks and opportunities visible in this view.")}},[d,v,de,f,A]),Rt=(0,i.useState)(null),$=Rt[0],Ue=Rt[1],Ie=(0,i.useState)(null),Q=Ie[0],rt=Ie[1],jt=(0,i.useState)(null),tn=jt[0],pt=jt[1],gt=(0,i.useState)(null),qt=gt[0],Pt=gt[1],Kt=(0,i.useState)(!1),xe=Kt[0],fe=Kt[1],Ye=(0,i.useState)(!1),Qe=Ye[0],ut=Ye[1],wt=(0,i.useRef)(null);(0,i.useEffect)(function(){var B=!1;Promise.resolve().then(function(){return fetch(pp("/api/map/my-intel"),{headers:fo()})}).then(function(ne){return ne&&ne.ok?ne.json():null}).then(function(ne){!B&&ne&&Ue(ne)}).catch(function(ne){});function ie(ne){var Me=!!(ne&&ne.refresh);Me&&fe(!0);var nt=pp("/api/map/live-layers")+(Me?"?refresh=1":"");return fetch(nt,{headers:fo()}).then(function(ct){if(ct&&ct.ok)return ct.json();throw new Error("live-layers-http")}).then(function(ct){if(!B&&ct&&typeof ct=="object")Pt(ct),ut(!1);else throw new Error("live-layers-empty")}).catch(function(ct){B||ut(!0)}).then(function(){Me&&!B&&fe(!1)})}wt.current=ie,ie();var ue=setInterval(function(){typeof document<"u"&&document.hidden||ie()},iO);return Promise.resolve().then(function(){return fetch(pp("/api/map/timeline?days=1460"),{headers:fo()})}).then(function(ne){return ne&&ne.ok?ne.json():null}).then(function(ne){!B&&ne&&ne.events&&ne.events.length&&pt(ne.events)}).catch(function(ne){}),Promise.resolve().then(function(){return fetch(pp("/api/map/satellite/changes"),{headers:fo()})}).then(function(ne){return ne&&ne.ok?ne.json():null}).then(function(ne){!B&&ne&&ne.cells&&ne.cells.length&&rt(ne.cells)}).catch(function(ne){}),function(){B=!0,wt.current=null,clearInterval(ue)}},[Ue,rt,pt,Pt,ut,fe]);var H=(0,i.useCallback)(function(){wt.current&&wt.current({refresh:!0})},[]),Z=(0,i.useMemo)(function(){return QD({activeLayers:v,animTime:C,onHover:Ae,onClick:He,allowSeed:ZC(),myIntel:$,satCells:Q,liveLayers:qt,replaying:O<ek,playheadMs:F1(O,Date.now(),wh),timelineEvents:tn||[]})},[v,C,Ae,He,$,Q,qt,O,tn]),T=(0,i.useMemo)(function(){if(qt==null)return[];var B=lk(qt);return O<.98&&(B=ux(B,F1(O,Date.now(),wh))),B},[qt,O]),Y=qt?"live":Qe?"error":"loading";return(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:J.bg,overflow:"hidden"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 14px",borderBottom:"1px solid "+J.border,background:J.bgPanel,flexShrink:0,zIndex:10},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,e.jsx)("div",{style:{width:8,height:8,borderRadius:"50%",background:J.amber,boxShadow:"0 0 10px rgba(245,166,35,0.5)"}}),(0,e.jsx)("span",{style:{fontFamily:en,fontSize:10,fontWeight:700,color:J.amber,letterSpacing:".14em"},children:"3D INTELLIGENCE MAP"}),(0,e.jsx)("span",{style:{fontFamily:en,fontSize:9,color:J.textGhost,letterSpacing:".1em"},children:Gn.short}),(0,e.jsx)("div",{style:{width:1,height:14,background:J.borderLight,margin:"0 6px"}}),(0,e.jsxs)("span",{style:{fontFamily:en,fontSize:9,color:J.textFaint,letterSpacing:".06em"},children:[v.size," LAYERS ACTIVE"]}),q&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:{width:1,height:14,background:J.borderLight,margin:"0 6px"}}),(0,e.jsx)("span",{style:{fontFamily:en,fontSize:9,color:J.blue,letterSpacing:".06em"},children:q.toUpperCase()}),(0,e.jsx)("button",{onClick:function(){ge(null),y(new Set(gf)),h(up)},style:{background:"none",border:"none",cursor:"pointer",color:J.textFaint,fontSize:9,padding:"0 4px"},children:"✕"})]})]}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,e.jsx)("button",{onClick:function(){y(new Set(La)),h(Object.assign({},up))},style:{background:"none",border:"1px solid "+J.borderLight,borderRadius:4,padding:"3px 10px",cursor:"pointer",fontFamily:en,fontSize:9,color:J.textMuted,letterSpacing:".06em",transition:"all 0.15s"}
416,onMouseEnter:function(B){B.currentTarget.style.borderColor=J.amber+"40",B.currentTarget.style.color=J.amber},onMouseLeave:function(B){B.currentTarget.style.borderColor=J.borderLight,B.currentTarget.style.color=J.textMuted},children:"SHOW ALL"}),(0,e.jsx)("button",{onClick:function(){y(new Set(gf)),h(Object.assign({},up))},style:{background:"none",border:"1px solid "+J.borderLight,borderRadius:4,padding:"3px 10px",cursor:"pointer",fontFamily:en,fontSize:9,color:J.textMuted,letterSpacing:".06em",transition:"all 0.15s"},onMouseEnter:function(B){B.currentTarget.style.borderColor=J.amber+"40",B.currentTarget.style.color=J.amber},onMouseLeave:function(B){B.currentTarget.style.borderColor=J.borderLight,B.currentTarget.style.color=J.textMuted},children:"RESET"}),(0,e.jsx)("div",{style:{width:1,height:16,background:J.borderLight}}),(0,e.jsxs)("button",{onClick:t,style:{background:"none",border:"1px solid "+J.borderLight,borderRadius:4,padding:"3px 10px",cursor:"pointer",fontFamily:en,fontSize:9,color:J.textMuted,letterSpacing:".08em",transition:"all 0.15s"},onMouseEnter:function(B){B.currentTarget.style.borderColor="rgba(255,68,68,0.3)",B.currentTarget.style.color=J.red},onMouseLeave:function(B){B.currentTarget.style.borderColor=J.borderLight,B.currentTarget.style.color=J.textMuted},children:["✕"," CLOSE"]})]})]}),(0,e.jsxs)("div",{style:{flex:1,display:"flex",overflow:"hidden",position:"relative"},children:[(0,e.jsx)(rO,{activeLayers:v,onToggleLayer:we,onToggleGroup:b,onSetAllLayers:function(B){y(new Set(B||[]))},onSearch:ot,onApplyPreset:Be,onSoloGroup:Fe,onFlyToLayer:ft,onHorizonChange:We,horizon:de,onExport:St,onAskPilot:Xe,onAnalyzeView:It,collapsed:z,onToggleCollapse:function(){oe(!z)}}),(0,e.jsxs)("div",{style:{flex:1,position:"relative",minHeight:0,minWidth:0,overflow:"hidden"},children:[(0,e.jsx)(tO,{layers:Z,viewState:f,onViewStateChange:h}),(0,e.jsx)(TO,{liveLayers:qt}),(0,e.jsxs)("div",{style:{position:"absolute",bottom:44,left:8,display:"flex",alignItems:"center",gap:5,background:"rgba(5,8,13,0.8)",padding:"3px 10px 3px 7px",borderRadius:4,border:"1px solid rgba(245,166,35,0.15)",zIndex:5,pointerEvents:"none"},children:[(0,e.jsx)("div",{style:{width:6,height:6,borderRadius:"50%",background:J.amber,boxShadow:"0 0 6px rgba(245,166,35,0.5)"}}),(0,e.jsxs)("span",{style:{fontFamily:en,fontSize:9,fontWeight:700,color:J.amber,letterSpacing:".14em"},children:[Gn.short," 3D INTEL"]})]}),(0,e.jsx)("div",{style:{position:"absolute",bottom:44,right:8,background:"rgba(5,8,13,0.8)",padding:"3px 8px",borderRadius:3,border:"1px solid "+J.borderLight,zIndex:5,pointerEvents:"none"},children:(0,e.jsxs)("span",{style:{fontFamily:en,fontSize:9,color:J.textFaint,letterSpacing:".06em"},children:[f.latitude.toFixed(2),"°"," ",f.longitude.toFixed(2),"°"," Z",f.zoom.toFixed(1)," P",Math.round(f.pitch),"°"]})}),_e&&(0,e.jsx)("div",{style:{position:"absolute",top:12,left:"50%",transform:"translateX(-50%)",background:"rgba(5,8,13,0.92)",padding:"6px 14px",borderRadius:4,border:"1px solid "+J.amber+"55",zIndex:30,fontFamily:en,fontSize:9,color:J.amber,letterSpacing:".14em",boxShadow:"0 6px 18px rgba(0,0,0,0.5)"},children:_e})]}),(0,e.jsx)(bO,{items:T,collapsed:W,onToggleCollapse:function(){R(!W)},selectedItem:A,onSelect:tt,onRefresh:H,refreshing:xe,status:Y})]}),(0,e.jsx)(CO,{item:A,onClose:function(){j(null)}}),(0,e.jsx)(wO,{events:tn,windowDays:wh,onSelectEvent:function(B){re(B.lng,B.lat,B.kind==="quake"?5:4.5,45),j({type:"timelineEvent",data:{name:B.label,risk:B.risk||null,detail:(B.kind==="quake"?"USGS live seismic feed":B.kind==="watch"?"Geofenced Sentinel watch":B.kind==="alert"?"Sentinel alert":"Curated historical event")+" · "+String(B.t).slice(0,10)}})},value:O,onChange:M,playing:ee,onTogglePlay:function(){if(ee){N(!1);return}tk(O)&&M(0),N(!0)}}),(0,e.jsx)("style",{children:`
417        @keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.4; } }
418      `})]})}var H1="monospace";function RO(t){var n=t.onClose,r=t.onSelectDoc,o=t.onAsk,a=t.savedDocs;return(0,e.jsxs)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:50,background:"#05080D",display:"flex",flexDirection:"column",overflow:"hidden",animation:"vidSlideUp 0.2s ease-out"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px",borderBottom:"1px solid #111820",background:"#06080D",flexShrink:0},children:[(0,e.jsx)("span",{style:{fontFamily:H1,fontSize:9,fontWeight:700,color:"#D4AF5C",letterSpacing:".14em"},children:"SOVEREIGN VAULT"}),(0,e.jsxs)("button",{type:"button",onClick:n,style:{background:"transparent",border:"1px solid #1E2838",borderRadius:4,padding:"3px 10px",cursor:"pointer",fontFamily:H1,fontSize:8,color:"#5A7090",letterSpacing:".08em"},children:["✕"," CLOSE"]})]}),(0,e.jsx)("div",{style:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",minHeight:0},children:(0,e.jsx)(eF,{savedDocs:a||[],onAsk:o,onChatContextDoc:r,onOpenLedger:t.onOpenLedger})})]})}function sk(t){if(t==null||t==="")return"";var n=String(t);return n.indexOf(".")!==-1&&(n=n.replace(/0+$/,"").replace(/\.$/,"")),n+"%"}function FO(t,n){if(!t)return"";var r=t.functional_currency||"?";if(r===n)return r+" (presentation)";var o=[r+"→"+(n||"?")];return t.closing_rate&&o.push("closing "+t.closing_rate),t.average_rate&&o.push("avg "+t.average_rate),o.join(" · ")}function IO(t){return(t&&t.pairs||[]).map(function(n){return{key:String(n.entity_id)+">"+String(n.counterparty_id),from:n.entity_name||G1(n.entity_id),to:n.counterparty_name||G1(n.counterparty_id),dueFrom:(n.due_from||"0.00")+" "+(n.due_from_currency||""),dueTo:(n.counterparty_due_to||"0.00")+" "+(n.counterparty_due_to_currency||""),difference:n.difference||"0.00",mismatch:!!n.mismatch,currencyDiffers:!!n.currency_differs}})}function G1(t){var n=String(t||"");return n.length>8?n.slice(0,8)+"…":n}function V1(t){return(t&&t.eliminations||[]).map(function(n){var r=n.due_from_removed!==void 0?n.due_from_removed:n.income_removed,o=n.due_to_removed!==void 0?n.due_to_removed:n.expense_removed;return{accounts:(n.accounts||[]).join(" / "),removedLeft:r||"0.00",removedRight:o||"0.00",residual:n.residual||"0.00",matched:!!n.matched}})}function Y1(t){var n=t&&t.cta;return!n||!n.amount||n.amount==="0.00"?"":"CTA "+n.amount+(n.account_code?" · acct "+n.account_code:"")}function DO({type:t}){const n=NE(t);return(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:n.color,border:"1px solid "+n.color+"44",background:n.color+"12",borderRadius:3,padding:"1px 5px",letterSpacing:".08em",flexShrink:0},children:n.label})}var jf={width:"100%",background:"#05080D",border:"1px solid "+Ke,borderRadius:5,padding:"7px 10px",color:xn,fontFamily:D,fontSize:11,outline:"none",boxSizing:"border-box"},lu={fontFamily:D,fontSize:8,color:Lt,letterSpacing:".1em",marginBottom:4,display:"block"};function OO({onClose:t,onCreate:n,busy:r,err:o}){const[a,l]=(0,i.useState)(""),[s,c]=(0,i.useState)("company"),[d,p]=(0,i.useState)("UK_GAAP"),[g,f]=(0,i.useState)("GBP");function h(){!a.trim()||r||n({name:a.trim(),entity_type:s,jurisdiction:d,coa_template:d,functional_currency:g.trim().toUpperCase()})}return(0,e.jsx)("div",{style:{position:"fixed",inset:0,zIndex:600,background:"rgba(2,4,10,0.8)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:t,children:(0,e.jsxs)("div",{onClick:function(x){x.stopPropagation()},style:{width:380,background:ln,border:"1px solid "+Ke,borderRadius:8,padding:20,boxSh
418adow:"0 16px 60px rgba(0,0,0,0.8)"},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:10,fontWeight:700,color:pe,letterSpacing:".12em",marginBottom:14},children:"◈ NEW LEDGER ENTITY"}),(0,e.jsxs)("div",{style:{marginBottom:12},children:[(0,e.jsx)("span",{style:lu,children:"NAME"}),(0,e.jsx)("input",{autoFocus:!0,value:a,onChange:function(x){l(x.target.value)},placeholder:"Entity name…",style:jf,onKeyDown:function(x){x.key==="Enter"&&h(),x.key==="Escape"&&t()}})]}),(0,e.jsxs)("div",{style:{marginBottom:12},children:[(0,e.jsx)("span",{style:lu,children:"TYPE"}),(0,e.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:5},children:ME.map(function(x){const v=s===x.value;return(0,e.jsx)("button",{onClick:function(){c(x.value)},style:{padding:"4px 9px",background:v?x.color+"18":"transparent",border:"1px solid "+(v?x.color+"66":Ke),borderRadius:4,cursor:"pointer",fontFamily:D,fontSize:8,color:v?x.color:cn,letterSpacing:".06em"},children:x.label},x.value)})})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:10,marginBottom:16},children:[(0,e.jsxs)("div",{style:{flex:1},children:[(0,e.jsx)("span",{style:lu,children:"JURISDICTION / CoA"}),(0,e.jsx)("select",{value:d,onChange:function(x){p(x.target.value)},style:jf,children:PR.map(function(x){return(0,e.jsx)("option",{value:x,children:x},x)})})]}),(0,e.jsxs)("div",{style:{width:110},children:[(0,e.jsx)("span",{style:lu,children:"CURRENCY"}),(0,e.jsx)("input",{value:g,maxLength:3,onChange:function(x){f(x.target.value.toUpperCase())},placeholder:"GBP",style:jf})]})]}),o&&(0,e.jsx)("div",{style:{marginBottom:12,padding:"7px 10px",background:et+"0C",border:"1px solid "+et+"33",borderRadius:5,fontFamily:D,fontSize:9,color:et},children:o}),(0,e.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[(0,e.jsx)("button",{onClick:t,style:{padding:"7px 14px",background:"transparent",border:"1px solid "+Ke,borderRadius:5,cursor:"pointer",fontFamily:D,fontSize:9,color:cn},children:"CANCEL"}),(0,e.jsx)("button",{onClick:h,disabled:r||!a.trim()||g.trim().length!==3,style:{padding:"7px 16px",background:r?Ut+"22":pe+"18",border:"1px solid "+(r?Ut:pe)+"44",borderRadius:5,cursor:r?"default":"pointer",fontFamily:D,fontSize:9,color:r?Ut:pe,fontWeight:700},children:r?"◌ CREATING…":"CREATE ENTITY"})]})]})})}function LO({entities:t,onClose:n,onCreate:r,busy:o,err:a}){const[l,s]=(0,i.useState)(""),[c,d]=(0,i.useState)("USD"),[p,g]=(0,i.useState)({});function f(k){g(function(A){var j=Object.assign({},A);return j[k]!==void 0?delete j[k]:j[k]="100",j})}function h(k,A){g(function(j){var E=Object.assign({},j);return E[k]=A,E})}const x=Object.keys(p),v=!o&&l.trim()&&c.trim().length===3&&x.length>=1&&x.every(function(k){var A=parseFloat(p[k]);return!isNaN(A)&&A>0&&A<=100});function y(){v&&r({name:l.trim(),presentation_currency:c.trim().toUpperCase(),members:x.map(function(k){return{entity_id:k,ownership_pct:parseFloat(p[k])}})})}return(0,e.jsx)("div",{style:{position:"fixed",inset:0,zIndex:600,background:"rgba(2,4,10,0.8)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:n,children:(0,e.jsxs)("div",{onClick:function(k){k.stopPropagation()},style:{width:420,maxHeight:"80vh",overflow:"auto",background:ln,border:"1px solid "+Ke,borderRadius:8,padding:20,boxShadow:"0 16px 60px rgba(0,0,0,0.8)"},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:10,fontWeight:700,color:Ft,letterSpacing:".12em",marginBottom:14},children:"◈ NEW CONSOLIDATION GROUP"}),(0,e.jsxs)("div",{style:{display:"flex",gap:10,marginBottom:12},children:[(0,e.jsxs)("div",{style:{flex:1},children:[(0,e.jsx)("span",{style:lu,children:"NAME"}),(0,e.jsx)("input",{autoFocus:!0,value:l,onChange:function(k){s(k.target.value)},placeholder:"Group name…",style:jf,onKeyDown:function(k){k.key==="Escape"&&n()}})]}),(0,e.jsxs)("div",{style:{width:110},children:[(0,e.jsx)("span",{style:lu,children:"PRESENTATION CCY"}),(0,e.jsx)("input",{value:c,maxLength:3,onChange:function(k){d(k.target.value.toUpperCase())},placeholder:"USD",style:jf})]})]}),(0,e.jsxs)("div",{style:{marginBottom:14},children:[(0,e.jsx)("span",{style:lu,children:"MEMBER ENTITIES · OWNERSHIP % (stored; L5 consolidates 100%)"}),(t||[]).map(function(k){var A=p[k.id]!==void 0;return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 0"},children:[(0,e.jsx)("input",{type:"checkbox",checked:A,onChange:function(){f(k.id)}}
418),(0,e.jsxs)("span",{style:{flex:1,fontFamily:D,fontSize:10,color:A?xn:cn},children:[k.name," ",(0,e.jsx)("span",{style:{color:Lt,fontSize:8},children:k.functional_currency||""})]}),A&&(0,e.jsx)("input",{value:p[k.id],onChange:function(j){h(k.id,j.target.value)},style:Object.assign({},jf,{width:64,padding:"3px 6px",fontSize:10}),title:"Ownership % (0–100]"}),A&&(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:"#6A8098"},children:sk(p[k.id])})]},k.id)}),(t||[]).length===0&&(0,e.jsx)("div",{style:{fontFamily:D,fontSize:9,color:Ut},children:"No entities visible to add"})]}),a&&(0,e.jsx)("div",{style:{marginBottom:12,padding:"7px 10px",background:et+"0C",border:"1px solid "+et+"33",borderRadius:5,fontFamily:D,fontSize:9,color:et},children:a}),(0,e.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[(0,e.jsx)("button",{onClick:n,style:{padding:"7px 14px",background:"transparent",border:"1px solid "+Ke,borderRadius:5,cursor:"pointer",fontFamily:D,fontSize:9,color:cn},children:"CANCEL"}),(0,e.jsx)("button",{onClick:y,disabled:!v,style:{padding:"7px 16px",background:v?Ft+"18":Ut+"10",border:"1px solid "+(v?Ft:Ut)+"44",borderRadius:5,cursor:v?"pointer":"default",fontFamily:D,fontSize:9,color:v?Ft:Ut,fontWeight:700},children:o?"◌ CREATING…":"CREATE GROUP"})]})]})})}function zO({entities:t,currentEntityId:n,onSelect:r,onCreate:o,groups:a,currentGroupId:l,onSelectGroup:s,onCreateGroup:c}){const[d,p]=(0,i.useState)(!1),[g,f]=(0,i.useState)(!1),[h,x]=(0,i.useState)(!1),[v,y]=(0,i.useState)(null);function k(j){x(!0),y(null),Promise.resolve(o(j)).then(function(E){x(!1),E&&E.error?y(E.error):p(!1)}).catch(function(E){x(!1),y(E&&E.message||"Creation failed")})}function A(j){x(!0),y(null),Promise.resolve(c(j)).then(function(E){x(!1),E&&E.error?y(E.error):f(!1)}).catch(function(E){x(!1),y(E&&E.message||"Group creation failed")})}return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,overflowX:"auto",padding:"8px 16px",borderBottom:"1px solid #111820",background:"#030507",flexShrink:0},children:[(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:Lt,letterSpacing:".12em",flexShrink:0},children:"ENTITY"}),t.map(function(j){const E=j.id===n&&!l;return(0,e.jsxs)("button",{onClick:function(){r(j.id)},title:(j.jurisdiction||"")+" · "+(j.functional_currency||"")+" · role: "+(j.role||"?"),style:{display:"flex",alignItems:"center",gap:6,padding:"5px 10px",background:E?pe+"12":ln,border:"1px solid "+(E?pe+"55":Ke),borderRadius:6,cursor:"pointer",flexShrink:0},onMouseEnter:function(C){E||(C.currentTarget.style.borderColor=pe+"44")},onMouseLeave:function(C){E||(C.currentTarget.style.borderColor=Ke)},children:[(0,e.jsx)("span",{style:{fontFamily:D,fontSize:10,color:E?pe:xn,fontWeight:E?700:400,whiteSpace:"nowrap"},children:j.name}),(0,e.jsx)(DO,{type:j.entity_type})]},j.id)}),t.length===0&&(0,e.jsx)("span",{style:{fontFamily:D,fontSize:9,color:Ut,flexShrink:0},children:"No entities visible — create one"}),(0,e.jsx)("button",{onClick:function(){y(null),p(!0)},style:{padding:"5px 10px",background:"transparent",border:"1px dashed "+pe+"44",borderRadius:6,cursor:"pointer",fontFamily:D,fontSize:9,color:pe,flexShrink:0,letterSpacing:".06em"},children:"+ NEW ENTITY"}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:Lt,letterSpacing:".12em",flexShrink:0,marginLeft:10,borderLeft:"1px solid "+Ke,paddingLeft:12},children:"CONSOLIDATED"}),(a||[]).map(function(j){const E=j.id===l;return(0,e.jsxs)("button",{onClick:function(){s(E?null:j.id)},title:(j.presentation_currency||"")+" · "+String(j.member_count||(j.members||[]).length)+" members — consolidated (read-only)",style:{display:"flex",alignItems:"center",gap:6,padding:"5px 10px",background:E?Ft+"12":ln,border:"1px solid "+(E?Ft+"55":Ke),borderRadius:6,cursor:"pointer",flexShrink:0},onMouseEnter:function(C){E||(C.currentTarget.style.borderColor=Ft+"44")},onMouseLeave:function(C){E||(C.currentTarget.style.borderColor=Ke)},children:[(0,e.jsxs)("span",{style:{fontFamily:D,fontSize:10,color:E?Ft:xn,fontWeight:E?700:400,whiteSpace:"nowrap"},children:["◫ ",j.name]}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:Ft,border:"1px solid "+Ft+"44",background:Ft+"12",borderRadius:3,padding:"1px 5px",letterSpacing:".08em",flexShrink:0},children:j.presentation_currency})]},j.id)}),(0,e.jsx)("button",{onClick:function(){y(null),f(!0)},style:{padding:"5px 10px",background:"transparent",border:"1px dashed "+Ft+"44",borderRadius:6,cursor:"pointer",fontFamily:D,fontSize:9,color:Ft,flexShrink:0,letterSpacing:".06em"},children:"+ NEW GROUP"}),d&&(0,e.jsx)(OO,{onClose:function(){p(!1)},onCreate:k,busy:h,err:v}),g&&(0,e.jsx)(LO,{entities:t,onClose:function(){f(!1)},onCreate:A,busy:h,err:v})]})}function Dh(){return new Date().toISOString().slice(0,10)}function hp({title:t,color:n,children:r,flex:o}){return(0,e.jsxs)("div",{style:{background:ln,border:"1px solid "+Ke,borderRadius:8,padding:14,flex:o||"1 1 260px",minWidth:240},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:n||Ft,letterSpacing:".1em",marginBottom:10},children:t}),r]})}function $0({value:t,color:n,suffix:r}){return(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:16,fontWeight:700,color:n||"#C9D1D9"},children:[t,r&&(0,e.jsx)("span",{style:{fontSize:9,color:"#6A8098",marginLeft:5},children:r})]})}function MO({entity:t,trialBal:n,payables:r,recentJournals:o}){const[a,l]=(0,i.useState)(null),s=t&&t.functional_currency||"",c=t&&t.id;(0,i.useEffect)(function(){if(!c)return;let A=!1;const j=Dh().slice(0,7);return dn.budgetVsActual(c,j).then(function(E){A||l(E&&!E.error?E:null)}
418).catch(function(){A||l(null)}),function(){A=!0}},[c]);const d=n&&n.accounts||[],p=kf(d,"1000","1099"),g=kf(d,"1100","1199"),f=_s(kf(d,"2000","2099")),h=wn(Rs(Math.abs(isNaN(f)?0:f))),x=r&&r.invoices||[],v=Dh(),y=x.filter(function(A){return BR(A.due_date,14,v)}),k=(a&&a.data||[]).slice(0,5);return(0,e.jsx)("div",{style:{flex:1,overflow:"auto",padding:16},children:(0,e.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:12},children:[(0,e.jsxs)(hp,{title:"CASH POSITION · ACCOUNTS 1000-1099 ("+s+")",color:bt,children:[(0,e.jsx)($0,{value:wn(p),color:bt,suffix:s}),(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:8,color:Lt,marginTop:6},children:["From trial balance",n&&n.as_of?" · as of "+n.as_of:""]})]}),(0,e.jsx)(hp,{title:"RECEIVABLES / PAYABLES",color:Ft,children:(0,e.jsxs)("div",{style:{display:"flex",gap:22},children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Lt,marginBottom:3},children:"AR (1100-1199)"}),(0,e.jsx)($0,{value:wn(g),color:Ft})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Lt,marginBottom:3},children:"AP OPEN INVOICES"}),(0,e.jsx)($0,{value:wn(r&&r.total||"0.00"),color:pe})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Lt,marginBottom:3},children:"AP LEDGER (2000-2099)"}),(0,e.jsx)($0,{value:h,color:et})]})]})}),(0,e.jsx)(hp,{title:"DUE WITHIN 14 DAYS",color:pe,children:y.length===0?(0,e.jsx)("div",{style:{fontFamily:D,fontSize:9,color:Ut},children:"Nothing due in the next 14 days"}):y.slice(0,6).map(function(A,j){return(0,e.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",gap:8,padding:"3px 0",borderBottom:"1px solid #0D1117"},children:[(0,e.jsx)("span",{style:{fontFamily:D,fontSize:9,color:xn,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:A.vendor||A.invoice_number||"—"}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:9,color:cn,flexShrink:0},children:A.due_date}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:9,color:pe,fontWeight:700,flexShrink:0},children:wn(A.total_amount)})]},j)})}),(0,e.jsx)(hp,{title:"BUDGET VS ACTUAL · "+Dh().slice(0,7),color:bt,children:k.length===0?(0,e.jsx)("div",{style:{fontFamily:D,fontSize:9,color:Ut},children:"No budget lines for this period"}):k.map(function(A,j){const E=_s(A.variance)<0;return(0,e.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",gap:8,padding:"3px 0",borderBottom:"1px solid #0D1117"},children:[(0,e.jsxs)("span",{style:{fontFamily:D,fontSize:9,color:xn},children:[A.account_code," ",A.category||""]}),(0,e.jsxs)("span",{style:{fontFamily:D,fontSize:9,color:cn},children:[wn(A.actual)," / ",wn(A.budgeted)]}),(0,e.jsxs)("span",{style:{fontFamily:D,fontSize:9,color:E?et:bt,fontWeight:700},children:[E?"OVER ":"",wn(A.variance)]})]},j)})}),(0,e.jsx)(hp,{title:"LAST JOURNALS · POSTED THIS SESSION",color:Ft,flex:"1 1 100%",children:(o||[]).length===0?(0,e.jsx)("div",{style:{fontFamily:D,fontSize:9,color:Ut},children:"No journals posted from this client yet (L1 has no journal-list endpoint)"}):o.map(function(A,j){return(0,e.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",gap:10,padding:"4px 0",borderBottom:"1px solid #0D1117"},children:[(0,e.jsxs)("span",{style:{fontFamily:D,fontSize:9,color:pe,flexShrink:0},children:["#",A.journal_no]}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:9,color:xn,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:A.description||A.journal_id}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:9,color:cn,flexShrink:0},children:A.entry_date||""}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:9,color:bt,fontWeight:700,flexShrink:0},children:wn(A.total)})]},j)})})]})})}function NO(){return new Date().toISOString().slice(0,10)}function yp(t){return{account_code:"",debit:"",credit:"",currency:t||"",memo:""}}var ed={width:"100%",background:"transparent",border:"1px solid "+Ke,borderRadius:4,padding:"5px 7px",color:xn,fontFamily:D,fontSize:10,outline:"none",boxSizing:"border-box"};function BO({accounts:t,value:n,onChange:r}){const[o,a]=(0,i.useState)(null),[l,s]=(0,i.useState)(!1),c=t.filter(function(g){return g.code===n})[0],d=o!==null?o:c?c.code+" · "+c.name:n||"",p=(0,i.useMemo)(function(){return zE(t,o||"").slice(0,8)}
418,[t,o]);return(0,e.jsxs)("div",{style:{position:"relative"},children:[(0,e.jsx)("input",{value:d,placeholder:"Account…",onFocus:function(){s(!0),a("")},onBlur:function(){setTimeout(function(){s(!1),a(null)},150)},onChange:function(g){a(g.target.value),s(!0)},style:Object.assign({},ed,{borderColor:n?Ke:pe+"44"})}),l&&p.length>0&&(0,e.jsx)("div",{style:{position:"absolute",top:"100%",left:0,right:0,zIndex:50,background:"#0A0E14",border:"1px solid "+Ke,borderRadius:5,marginTop:2,maxHeight:180,overflow:"auto",boxShadow:"0 8px 24px rgba(0,0,0,0.7)"},children:p.map(function(g){return(0,e.jsxs)("button",{type:"button",onMouseDown:function(f){f.preventDefault(),r(g.code),a(null),s(!1)},style:{display:"flex",gap:8,width:"100%",padding:"5px 8px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left"},onMouseEnter:function(f){f.currentTarget.style.background=pe+"0C"},onMouseLeave:function(f){f.currentTarget.style.background="transparent"},children:[(0,e.jsx)("span",{style:{fontFamily:D,fontSize:9,color:pe,flexShrink:0},children:g.code}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:9,color:"#C9D1D9",flex:1,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:g.name}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:"#6A8098",flexShrink:0},children:g.account_type})]},g.code)})})]})}function PO({entity:t,accounts:n,onPosted:r,canPost:o}){const a=t&&t.functional_currency||"",[l,s]=(0,i.useState)(NO()),[c,d]=(0,i.useState)(""),[p,g]=(0,i.useState)(""),[f,h]=(0,i.useState)([yp(a),yp(a)]),[x,v]=(0,i.useState)(!1),[y,k]=(0,i.useState)(!1),[A,j]=(0,i.useState)(!1),[E,C]=(0,i.useState)(null);function _(){y||!t||!t.id||(k(!0),dn.exportCsv(t.id,"journals").then(function(P){if(k(!1),!P||P.error||!P.blob){C({ok:!1,text:P&&P.error||"CSV export failed"});return}var W=URL.createObjectURL(P.blob),R=document.createElement("a");R.href=W,R.download=P.filename||"journals.csv",R.click(),URL.revokeObjectURL(W)}).catch(function(P){k(!1),C({ok:!1,text:P&&P.message||"Network error"})}))}function w(){A||!t||!t.id||(j(!0),dn.exportXlsx(t.id,"journals").then(function(P){if(j(!1),!P||P.error||!P.blob){C({ok:!1,text:P&&P.error||"XLSX export failed"});return}var W=URL.createObjectURL(P.blob),R=document.createElement("a");R.href=W,R.download=P.filename||"journals.xlsx",R.click(),URL.revokeObjectURL(W)}).catch(function(P){j(!1),C({ok:!1,text:P&&P.message||"Network error"})}))}const O=DE(f),M=zR(f),U=M.ok&&c.trim().length>0&&!x&&o!==!1;function ee(P,W){h(function(R){return R.map(function(ae,q){if(q!==P)return ae;const ge=Object.assign({},ae,W);return W.debit!==void 0&&W.debit!==""&&(ge.credit=""),W.credit!==void 0&&W.credit!==""&&(ge.debit=""),ge})})}function N(){h(function(P){return P.concat([yp(a)])})}function V(P){h(function(W){return W.length<=2?W:W.filter(function(R,ae){return ae!==P})})}function z(){if(!U||!t)return;v(!0),C(null);const P={description:c.trim(),reference:p.trim(),entry_date:l,source:"MANUAL",entries:f.map(function(W){const R={account_code:String(W.account_code).trim(),currency:W.currency||a};return W.debit!==""&&(R.debit=W.debit),W.credit!==""&&(R.credit=W.credit),W.memo&&(R.memo=W.memo),R})};dn.journal(t.id,P).then(function(W){if(v(!1),W&&W.error){C({ok:!1,text:W.error});return}C({ok:!0,text:"POSTED — journal #"+W.journal_no+" · id "+W.journal_id+" · total "+W.total}),r&&r(Object.assign({description:c.trim(),entry_date:l},W)),d(""),g(""),h([yp(a),yp(a)])}).catch(function(W){v(!1),C({ok:!1,text:W&&W.message||"Network error"})})}const oe=O.balanced?bt:O.debitCents+O.creditCents===0?Ut:et;return(0,e.jsx)("div",{style:{flex:1,overflow:"auto",padding:16},children:(0,e.jsxs)("div",{style:{maxWidth:860,margin:"0 auto"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:14},children:[(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:10,fontWeight:700,color:pe,letterSpacing:".12em"},children:["◈ NEW JOURNAL ENTRY",a?" · "+a:""]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{onClick:_,title:"Download recent journals as deterministic CSV (from the ledger DB)",style:{padding:"6px 10px",background:pe+"10",border:"1px solid "+pe+"44",borderRadius:5,cursor:"pointer",fontFamily:D,fontSize:9,color:pe,fontWeight:700,letterSpacing:".06em"},children:y?"◌…":"⇩ CSV"}),(0,e.jsx)("button",{onClick:w,title:"Download recent journals as a typed XLSX workbook (from the ledger DB)",style:{padding:"6px 10px",background:pe+"10",border:"1px solid "+pe+"44",borderRadius:5,cursor:"pointer",fontFamily:D,fontSize:9,color:pe,fontWeight:700,letterSpacing:".06em"},children:A?"◌…":"⇩ XLSX"})]}),o===!1&&(0,e.jsx)("div",{style:{marginBottom:12,padding:"7px 10px",background:pe+"
4180C",border:"1px solid "+pe+"33",borderRadius:5,fontFamily:D,fontSize:9,color:pe},children:"Posting requires the bookkeeper role on this entity (backend enforces)."}),(0,e.jsxs)("div",{style:{display:"flex",gap:10,marginBottom:12},children:[(0,e.jsxs)("div",{style:{width:140},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Lt,letterSpacing:".1em",marginBottom:4},children:"DATE"}),(0,e.jsx)("input",{type:"date",value:l,onChange:function(P){s(P.target.value)},style:ed})]}),(0,e.jsxs)("div",{style:{flex:1},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Lt,letterSpacing:".1em",marginBottom:4},children:"DESCRIPTION"}),(0,e.jsx)("input",{value:c,onChange:function(P){d(P.target.value)},placeholder:"What is this entry for…",style:ed})]}),(0,e.jsxs)("div",{style:{width:160},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Lt,letterSpacing:".1em",marginBottom:4},children:"REFERENCE"}),(0,e.jsx)("input",{value:p,onChange:function(P){g(P.target.value)},placeholder:"Optional ref…",style:ed})]})]}),(0,e.jsxs)("div",{style:{background:ln,border:"1px solid "+Ke,borderRadius:8,padding:10},children:[(0,e.jsx)("div",{style:{display:"grid",gridTemplateColumns:"minmax(180px,2fr) 110px 110px 70px minmax(120px,1.4fr) 26px",gap:6,marginBottom:6},children:["ACCOUNT","DEBIT","CREDIT","CCY","MEMO",""].map(function(P,W){return(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Lt,letterSpacing:".1em",textAlign:W===1||W===2?"right":"left"},children:P},W)})}),f.map(function(P,W){return(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"minmax(180px,2fr) 110px 110px 70px minmax(120px,1.4fr) 26px",gap:6,marginBottom:6,alignItems:"center"},children:[(0,e.jsx)(BO,{accounts:n||[],value:P.account_code,onChange:function(R){ee(W,{account_code:R})}}),(0,e.jsx)("input",{inputMode:"decimal",value:P.debit,placeholder:"0.00",onChange:function(R){ee(W,{debit:R.target.value})},style:Object.assign({},ed,{textAlign:"right"})}),(0,e.jsx)("input",{inputMode:"decimal",value:P.credit,placeholder:"0.00",onChange:function(R){ee(W,{credit:R.target.value})},style:Object.assign({},ed,{textAlign:"right"})}),(0,e.jsx)("input",{value:P.currency,maxLength:3,onChange:function(R){ee(W,{currency:R.target.value.toUpperCase()})},style:Object.assign({},ed,{textAlign:"center"})}),(0,e.jsx)("input",{value:P.memo,placeholder:"Memo…",onChange:function(R){ee(W,{memo:R.target.value})},style:ed}),(0,e.jsx)("button",{type:"button",title:"Remove line",onClick:function(){V(W)},disabled:f.length<=2,style:{background:"transparent",border:"none",cursor:f.length<=2?"default":"pointer",color:f.length<=2?Ut:et,fontFamily:D,fontSize:11,padding:0},children:"✕"})]},W)}),(0,e.jsx)("button",{type:"button",onClick:N,style:{marginTop:2,padding:"5px 10px",background:"transparent",border:"1px dashed "+Ke,borderRadius:5,cursor:"pointer",fontFamily:D,fontSize:9,color:cn},children:"+ ADD LINE"}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:18,marginTop:12,paddingTop:10,borderTop:"1px solid "+Ke},children:[(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:9,color:cn},children:["DEBITS"," ",(0,e.jsx)("span",{style:{color:xn,fontWeight:700},children:wn(O.totalDebit)})]}),(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:9,color:cn},children:["CREDITS"," ",(0,e.jsx)("span",{style:{color:xn,fontWeight:700},children:wn(O.totalCredit)})]}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,e.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:oe,display:"inline-block"}}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:9,color:oe,fontWeight:700,letterSpacing:".08em"},children:O.balanced?"BALANCED":O.invalidLines.length>0?"INVALID AMOUNT (LINE "+O.invalidLines.join(", ")+")":"OFF BY "+wn(Rs(Math.abs(O.diffCents)))})]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",onClick:z,disabled:!U,style:{padding:"8px 18px",background:U?bt+"14":Ut+"14",border:"1px solid "+(U?bt:Ut)+"44",borderRadius:6,cursor:U?"pointer":"default",fontFamily:D,fontSize:9,color:U?bt:Ut,fontWeight:700,letterSpacing:".08em"},children:x?"◌ POSTING…":"POST JOURNAL"})]})]}),!M.ok&&(O.debitCents!==0||O.creditCents!==0)&&(0,e.jsx)("div",{style:{marginTop:10,fontFamily:D,fontSize:8,color:"#6A8098"},children:M.errors.slice(0,3).join(" · ")}),E&&(0,e.jsx)("div",{style:{marginTop:12,padding:"9px 12px",background:(E.ok?bt:et)+"0C",border:"1px solid "+(E.ok?bt:et)+"33",borderRadius:6,fontFamily:D,fontSize:10,
418color:E.ok?bt:et},children:E.text})]})})}var K1=["ASSET","LIABILITY","EQUITY","REVENUE","EXPENSE"],UO={ASSET:bt,LIABILITY:et,EQUITY:To,REVENUE:Ft,EXPENSE:pe};function WO({accounts:t}){const[n,r]=(0,i.useState)(""),o=(0,i.useMemo)(function(){const a=zE(t||[],n),l={};return K1.forEach(function(s){l[s]=[]}),a.forEach(function(s){(l[s.account_type]||(l[s.account_type]=[])).push(s)}),l},[t,n]);return(0,e.jsx)("div",{style:{flex:1,overflow:"auto",padding:16},children:(0,e.jsxs)("div",{style:{maxWidth:760,margin:"0 auto"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:14},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:10,fontWeight:700,color:pe,letterSpacing:".12em"},children:"◈ CHART OF ACCOUNTS"}),(0,e.jsx)("input",{value:n,onChange:function(a){r(a.target.value)},placeholder:"Filter code or name…",style:{flex:1,maxWidth:280,background:ln,border:"1px solid "+Ke,borderRadius:5,padding:"6px 10px",color:xn,fontFamily:D,fontSize:10,outline:"none"}}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:Lt},children:"READ-ONLY"})]}),K1.map(function(a){const l=o[a]||[];if(l.length===0)return null;const s=UO[a]||"#7A90A8";return(0,e.jsxs)("div",{style:{background:ln,border:"1px solid "+Ke,borderRadius:8,padding:12,marginBottom:12},children:[(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:8,color:s,letterSpacing:".12em",marginBottom:8},children:[a," ",(0,e.jsxs)("span",{style:{color:Lt},children:["(",l.length,")"]})]}),l.map(function(c){return(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center",padding:"4px 0",borderBottom:"1px solid #0D1117"},children:[(0,e.jsx)("span",{style:{fontFamily:D,fontSize:10,color:s,width:44,flexShrink:0},children:c.code}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:10,color:xn,flex:1},children:c.name}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:Lt,flexShrink:0},children:c.category||""}),c.currency&&(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:"#7A90A8",flexShrink:0},children:c.currency})]},c.code)})]},a)}),(t||[]).length===0&&(0,e.jsx)("div",{style:{fontFamily:D,fontSize:10,color:Ut,padding:24,textAlign:"center"},children:"No accounts — select or create an entity"})]})})}var HO={PENDING:pe,APPROVED:Ft,PAID:bt,OVERDUE:et,CANCELLED:Ut};function GO(){return new Date().toISOString().slice(0,10)}var eu={width:"100%",background:"#05080D",border:"1px solid "+Ke,borderRadius:5,padding:"7px 10px",color:xn,fontFamily:D,fontSize:11,outline:"none",boxSizing:"border-box"},Kc={fontFamily:D,fontSize:8,color:Lt,letterSpacing:".1em",marginBottom:4,display:"block"};function VO({status:t}){const n=HO[t]||"#7A90A8";return(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:n,border:"1px solid "+n+"44",background:n+"12",borderRadius:3,padding:"1px 5px",letterSpacing:".08em"},children:t||"?"})}function YO({entity:t,onClose:n,onCreated:r}){const[o,a]=(0,i.useState)(""),[l,s]=(0,i.useState)("PAYABLE"),[c,d]=(0,i.useState)(""),[p,g]=(0,i.useState)(t&&t.functional_currency||""),[f,h]=(0,i.useState)("GENERAL"),[x,v]=(0,i.useState)("0"),[y,k]=(0,i.useState)("30"),[A,j]=(0,i.useState)(""),[E,C]=(0,i.useState)(!1),[_,w]=(0,i.useState)(null),O=o.trim()&&parseFloat(c)>0&&p.trim().length===3;function M(){!O||E||(C(!0),w(null),dn.invoice(t.id,{vendor_name:o.trim(),direction:l,amount:parseFloat(c),currency:p.trim().toUpperCase(),category:f,vat_rate:parseFloat(x)||0,due_days:parseInt(y,10)||0,description:A.trim()}).then(function(U){if(C(!1),U&&U.error){w(U.error);return}r(U)}).catch(function(U){C(!1),w(U&&U.message||"Network error")}))}return(0,e.jsx)("div",{style:{position:"fixed",inset:0,zIndex:600,background:"rgba(2,4,10,0.8)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:n,children:(0,e.jsxs)("div",{onClick:function(U){U.stopPropagation()},style:{width:400,background:ln,border:"1px solid "+Ke,borderRadius:8,padding:20,boxShadow:"0 16px 60px rgba(0,0,0,0.8)"},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:10,fontWeight:700,color:pe,letterSpacing:".12em",marginBottom:14},children:"◈ NEW INVOICE"}),(0,e.jsxs)("div",{style:{marginBottom:10},children:[(0,e.jsx)("span",{style:Kc,children:"VENDOR / COUNTERPARTY"}),(0,e.jsx)("input",{autoFocus:!0,value:o,onChange:function(U){a(U.target.value)},placeholder:"Name…",style:eu})]}),(0,e.jsx)("div",{style:{display:"flex",gap:10,marginBottom:10},children:(0,e.jsxs)("div",{style:{flex:1},children:[(0,e.jsx)("span",{style:Kc,children:"DIRECTION"}),(0,e.jsx)("div",{style:{display:"flex",gap:5},children:["PAYABLE","RECEIVABLE"].map(function(U){const ee=l===U,N=U==="PAYABLE"?et:bt;return(0,e.jsx)("button",{onClick:function(){s(U)},style:{flex:1,padding:"6px 0",background:ee?N+"14":"transparent",border:"1px solid "+(ee?N+"55":Ke),borderRadius:4,cursor:"pointer",fontFamily:D,fontSize:8,color:ee?N:cn,letterSpacing:".06em"},children:U},U)})})]})}),(0,e.jsxs)("div",{style:{display:"flex",gap:10,marginBottom:10},children:[(0,e.jsxs)("div",{style:{flex:1},children:[(0,e.jsx)("span",{style:Kc,children:"AMOUNT (NET)"}),(0,e.jsx)("input",{inputMode:"decimal",value:c,onChange:function(U){d(U.target.value)},placeholder:"0.00",style:Object.assign({},eu,{textAlign:"right"})})]}),(0,e.jsxs)("div",{style:{width:90},children:[(0,e.jsx)("span",{style:Kc,children:"CCY"}),(0,e.jsx)("input",{value:p,maxLength:3,onChange:function(U){g(U.target.value.toUpperCase())},style:eu})]})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:10,marginBottom:10},children:[(0,e.jsxs)("div",{style:{flex:1},children:[(0,e.jsx)("span",{style:Kc,children:"CATEGORY"}),(0,e.jsx)("select",{value:f,onChange:function(U){h(U.target.value)},style:eu,children:UR.map(function(U){return(0,e.jsx)("option",{value:U,children:U},U)})})]}),(0,e.jsxs)("div",{style:{width:90},children:[(0,e.jsx)("span",{style:Kc,children:"VAT %"}),(0,e.jsx)("input",{inputMode:"decimal",value:x,onChange:function(U){v(U.target.value)},style:Object.assign({},eu,{textAlign:"right"})})]}),(0,e.jsxs)("div",{style:{width:90},children:[(0,e.jsx)("span",{style:Kc,children:"DUE DAYS"}),(0,e.jsx)("input",{inputMode:"numeric",value:y,onChange:function(U){k(U.target.value)},style:Object.assign({},eu,{textAlign:"right"})})]})]}),(0,e.jsxs)("div",{style:{marginBottom:14},children:[(0,e.jsx)("span",{style:Kc,children:"DESCRIPTION"}),(0,e.jsx)("input",{value:A,onChange:function(U){j(U.target.value)},placeholder:"Optional…",style:eu})]}),_&&(0,e.jsx)("div",{style:{marginBottom:12,padding:"7px 10px",background:et+"0C",border:"1px solid "+et+"33",borderRadius:5,fontFamily:D,fontSize:9,color:et},children:_}),(0,e.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[(0,e.jsx)("button",{onClick:n,style:{padding:"7px 14px",background:"transparent",border:"1px solid "+Ke,borderRadius:5,cursor:"pointer",fontFamily:D,fontSize:9,color:cn},children:"CANCEL"}),(0,e.jsx)("button",{onClick:M,disabled:E||!O,style:{padding:"7px 16px",background:E||!O?Ut+"14":pe+"18",border:"1px solid "+(E||!O?Ut:pe)+"44",borderRadius:5,cursor:E||!O?"default":"pointer",fontFamily:D,fontSize:9,color:E||!O?Ut:pe,fontWeight:700},children:E?"◌ LOGGING…":"LOG INVOICE"})]})]})})}function KO({entity:t,payables:n,trialBal:r,onRefresh:o,role:a}){const[l,s]=(0,i.useState)(!1),[c,d]=(0,i.useState)(null),[p,g]=(0,i.useState)(null),[f,h]=(0,i.useState)(null),[x,v]=(0,i.useState)(null),[y,k]=(0,i.useState)(null),[A,j]=(0,i.useState)(null),[E,C]=(0,i.useState)(null),_=a==="bookkeeper"||a==="approver"||a==="controller",w=a==="approver"||a==="controller",O=n&&n.invoices||[],M=GO(),U=MR(O,M),ee=kf(r&&r.accounts||[],"1100","1199");function N(R){!R.vault_file_id||p||(g(R.vault_file_id),gn.get(R.vault_file_id).then(function(ae){g(null);var q=ae&&ae.download_url;if(q)window.open(q,"_blank","noopener");else return gn.content(R.vault_file_id).then(function(ge){if(ge){var X=URL.createObjectURL(ge);window.open(X,"_blank","noopener"),setTimeout(function(){URL.revokeObjectURL(X)},6e4)}else C({ok:!1,text:"Document unavailable — vault fetch failed"})})}).catch(function(ae){g(null),C({ok:!1,text:ae&&ae.message||"Failed to load the source document"})}))}function V(R){if(!(!R.invoice_id||f)){var ae=!!R.vault_file_id;h(R.invoice_id),dn.invoicePdf(t.id,R.invoice_id).then(function(q){if(h(null),!q||q.error||!q.blob){C({ok:!1,text:q&&q.error||"Invoice PDF failed"});return}var ge=URL.createObjectURL(q.blob),X=document.createElement("a");X.href=ge,X.download=(R.invoice_number||R.invoice_id)+".pdf",X.click(),URL.revokeObjectURL(ge),!ae&&o&&o()}).catch(function(q){h(null),C({ok:!1,text:q&&q.message||"Network error"})})}}function z(R){x||!t||(v(R),dn.exportCsv(t.id,R).then(function(ae){if(v(null),!ae||ae.error||!
418ae.blob){C({ok:!1,text:ae&&ae.error||"CSV export failed"});return}var q=URL.createObjectURL(ae.blob),ge=document.createElement("a");ge.href=q,ge.download=ae.filename||R+".csv",ge.click(),URL.revokeObjectURL(q)}).catch(function(ae){v(null),C({ok:!1,text:ae&&ae.message||"Network error"})}))}function oe(R){y||!t||(k(R),dn.exportXlsx(t.id,R).then(function(ae){if(k(null),!ae||ae.error||!ae.blob){C({ok:!1,text:ae&&ae.error||"XLSX export failed"});return}var q=URL.createObjectURL(ae.blob),ge=document.createElement("a");ge.href=q,ge.download=ae.filename||R+".xlsx",ge.click(),URL.revokeObjectURL(q)}).catch(function(ae){k(null),C({ok:!1,text:ae&&ae.message||"Network error"})}))}function P(R){!R.vendor||A||!t||(j(R.vendor),dn.vendorStatement(t.id,R.vendor,"csv").then(function(ae){if(j(null),!ae||ae.error||!ae.blob){C({ok:!1,text:ae&&ae.error||"Vendor statement export failed"});return}var q=URL.createObjectURL(ae.blob),ge=document.createElement("a");ge.href=q,ge.download=ae.filename||"vendor-statement.csv",ge.click(),URL.revokeObjectURL(q)}).catch(function(ae){j(null),C({ok:!1,text:ae&&ae.message||"Network error"})}))}function W(R){const ae=R.invoice_number||R.invoice_id;!ae||c||(d(ae),C(null),dn.markPaid(t.id,ae).then(function(q){if(d(null),q&&q.error){C({ok:!1,text:q.error});return}C({ok:!0,text:"PAID — "+(R.invoice_number||ae)+(q.journal_id?" · journal "+q.journal_id:"")}),o&&o()}).catch(function(q){d(null),C({ok:!1,text:q&&q.message||"Network error"})}))}return(0,e.jsx)("div",{style:{flex:1,overflow:"auto",padding:16},children:(0,e.jsxs)("div",{style:{maxWidth:860,margin:"0 auto"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:14},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:10,fontWeight:700,color:pe,letterSpacing:".12em"},children:"◈ PAYABLES & RECEIVABLES"}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{onClick:function(){z("payables")},title:"Download open payables as deterministic CSV (from the ledger DB)",style:{padding:"6px 10px",background:pe+"10",border:"1px solid "+pe+"44",borderRadius:5,cursor:"pointer",fontFamily:D,fontSize:9,color:pe,fontWeight:700,letterSpacing:".06em"},children:x==="payables"?"◌…":"⇩ CSV AP"}),(0,e.jsx)("button",{onClick:function(){z("receivables")},title:"Download open receivables as deterministic CSV (from the ledger DB)",style:{padding:"6px 10px",background:bt+"10",border:"1px solid "+bt+"44",borderRadius:5,cursor:"pointer",fontFamily:D,fontSize:9,color:bt,fontWeight:700,letterSpacing:".06em"},children:x==="receivables"?"◌…":"⇩ CSV AR"}),(0,e.jsx)("button",{onClick:function(){oe("payables")},title:"Download open payables as a typed XLSX workbook (from the ledger DB)",style:{padding:"6px 10px",background:pe+"10",border:"1px solid "+pe+"44",borderRadius:5,cursor:"pointer",fontFamily:D,fontSize:9,color:pe,fontWeight:700,letterSpacing:".06em"},children:y==="payables"?"◌…":"⇩ XLSX AP"}),(0,e.jsx)("button",{onClick:function(){oe("receivables")},title:"Download open receivables as a typed XLSX workbook (from the ledger DB)",style:{padding:"6px 10px",background:bt+"10",border:"1px solid "+bt+"44",borderRadius:5,cursor:"pointer",fontFamily:D,fontSize:9,color:bt,fontWeight:700,letterSpacing:".06em"},children:y==="receivables"?"◌…":"⇩ XLSX AR"}),(0,e.jsx)("button",{onClick:function(){oe("aging")},title:"Download the bucketed AP/AR aging workbook (two sheets, per currency)",style:{padding:"6px 10px",background:Ft+"10",border:"1px solid "+Ft+"44",borderRadius:5,cursor:"pointer",fontFamily:D,fontSize:9,color:Ft,fontWeight:700,letterSpacing:".06em"},children:y==="aging"?"◌…":"⇩ AGING XLSX"}),(0,e.jsx)("button",{onClick:function(){s(!0)},disabled:!_,title:_?"":"Requires bookkeeper role",style:{padding:"6px 12px",background:_?pe+"14":Ut+"10",border:"1px solid "+(_?pe:Ut)+"44",borderRadius:5,cursor:_?"pointer":"default",fontFamily:D,fontSize:9,color:_?pe:Ut,fontWeight:700,letterSpacing:".06em"},children:"+ NEW INVOICE"})]}),(0,e.jsx)("div",{style:{display:"flex",gap:8,marginBottom:14},children:U.map(function(R){const ae=R.bucket==="90+"||R.bucket==="61-90";return(0,e.jsxs)("div",{style:{flex:1,background:ln,border:"1px solid "+Ke,borderRadius:6,padding:"8px 10px"},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:ae?et:Lt,letterSpacing:".08em",marginBottom:3},children:R.bucket==="CURRENT"?"CURRENT":R.bucket+" DAYS"}),(0,e.jsx)("div",{style:{fontFamily:D,fontSize:12,fontWeight:700,color:R.count===0?Ut:ae?et:xn},children:R.totals&&R.totals.length>0?R.totals.map(function(q){return(0,e.jsx)("div",{children:(R.totals.length>1||q.currency==="?"?q.currency+" ":"")+wn(q.total)},q.currency)}):wn(R.total)}),(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:8,color:Lt},children:[R.count," invoice",R.count===1?"":"s"]})]},R.bucket)})}),E&&(0,e.jsx)("div",{style:{marginBottom:12,padding:"8px 11px",background:(E.ok?bt:et)+"0C",border:"1px solid "+(E.ok?bt:et)+"33",borderRadius:6,fontFamily:D,fontSize:9,color:E.ok?bt:et},children:E.text}),(0,e.jsxs)("div",{style:{background:ln,border:"1px solid "+Ke,borderRadius:8,padding:14,marginBottom:14},children:[(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:8,color:et,letterSpacing:".1em",marginBottom:10},children:["OUTSTANDING PAYABLES (",O.length,") · TOTAL"," ",NR(O).map(function(R){return R.currency+" "+wn(R.total)}).join("  +  ")||"0.00"]}),O.length===0?(0,e.jsx)("div",{style:{fontFamily:D,fontSize:10,
418color:Ut,padding:10},children:"No outstanding payables"}):O.map(function(R){const ae=R.invoice_number||R.invoice_id;return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"7px 0",borderBottom:"1px solid #0D1117"},children:[(0,e.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},children:[(0,e.jsx)("span",{style:{fontFamily:D,fontSize:10,color:xn,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:R.vendor||"Unknown"}),R.vendor&&(0,e.jsx)("button",{onClick:function(){P(R)},title:"Download this vendor's statement CSV (invoices + payments, running balance)",style:{padding:"0 5px",background:Ft+"10",border:"1px solid "+Ft+"44",borderRadius:3,cursor:"pointer",fontFamily:D,fontSize:8,color:Ft,letterSpacing:".06em",flexShrink:0},children:A===R.vendor?"◌…":"⎘ STMT"})]}),(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:8,color:Lt},children:[R.invoice_number||""," · due ",R.due_date||"—"," ·"," ",R.currency||""]})]}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:cn,flexShrink:0},children:LE(R.due_date,M)}),(0,e.jsx)("button",{onClick:function(){V(R)},title:"Download the client-facing invoice PDF",style:{padding:"1px 6px",background:pe+"10",border:"1px solid "+pe+"44",borderRadius:3,cursor:"pointer",fontFamily:D,fontSize:8,color:pe,letterSpacing:".06em",flexShrink:0},children:f===R.invoice_id?"◌…":"⇩ PDF"}),R.vault_file_id&&(0,e.jsx)("button",{onClick:function(){N(R)},title:"Open the archived source document (vault)",style:{padding:"1px 6px",background:Ft+"10",border:"1px solid "+Ft+"44",borderRadius:3,cursor:"pointer",fontFamily:D,fontSize:8,color:Ft,letterSpacing:".06em",flexShrink:0},children:p===R.vault_file_id?"◌…":"⎘ DOC"}),(0,e.jsx)(VO,{status:R.status}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:11,fontWeight:700,color:pe,flexShrink:0,minWidth:80,textAlign:"right"},children:wn(R.total_amount)}),(0,e.jsx)("button",{onClick:function(){W(R)},disabled:!w||c!==null,title:w?"Mark paid (WIRE)":"Requires approver role",style:{padding:"4px 10px",background:w?bt+"12":Ut+"10",border:"1px solid "+(w?bt:Ut)+"44",borderRadius:4,cursor:w&&c===null?"pointer":"default",fontFamily:D,fontSize:8,color:w?bt:Ut,fontWeight:700,flexShrink:0,letterSpacing:".06em"},children:c===ae?"◌…":"MARK PAID"})]},R.invoice_id)})]}),(0,e.jsxs)("div",{style:{background:ln,border:"1px solid "+Ke,borderRadius:8,padding:14},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:bt,letterSpacing:".1em",marginBottom:8},children:"RECEIVABLES"}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10},children:[(0,e.jsx)("span",{style:{fontFamily:D,fontSize:14,fontWeight:700,color:bt},children:wn(ee)}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:Lt},children:"AR control accounts 1100-1199 · per-invoice receivable listing lands with the backend endpoint"})]})]}),l&&t&&(0,e.jsx)(YO,{entity:t,onClose:function(){s(!1)},onCreated:function(R){s(!1),C({ok:!0,text:"INVOICE LOGGED — "+(R.invoice_number||R.invoice_id||"")+(R.total?" · total "+R.total:"")}),o&&o()}})]})})}function Qp(t,n,r){var o=["# "+t,""];return n&&n.name&&o.push("**Entity:** "+n.name+(n.functional_currency?" · **Currency:** "+n.functional_currency:"")),(r||[]).forEach(function(a){o.push("**"+a[0]+":** "+a[1])}),o.push(""),o}function tl(t){return"| "+t.join(" | ")+" |"}function Df(t,n){var r=t.map(function(o,a){return a>=n?"---:":"---"});return[tl(t),tl(r)]}function XO(t,n){var r=Qp("Trial Balance",n,[["As of",t.as_of||"current"]]);return r=r.concat(Df(["Code","Account","Type","Debit","Credit","Balance"],3)),(t.accounts||[]).forEach(function(o){r.push(tl([o.account_code,o.account_name,o.account_type,o.total_debit,o.total_credit,o.balance]))}),r.push(tl(["","**TOTAL**","","**"+t.total_debit+"**","**"+t.total_credit+"**",""])),r.push(""),r.push(t.balanced?"**BALANCED** — debits equal credits.":"**OUT OF BALANCE** — variance "+t.variance+"."),r.join(`
419`)}function Oh(t,n,r,o,a){return t.push("## "+n,""),t=t.concat(Df(["Code","Account","Category","Balance"],3)),(r||[]).forEac
419h(function(l){t.push(tl([l.account_code,l.name,l.category||"",l.balance]))}),t.push(tl(["","**"+a+"**","","**"+o+"**"])),t.push(""),t}function qO(t,n){var r=Qp("Balance Sheet",n,[["As of",t.as_of||"current"]]);return r=Oh(r,"Assets",t.assets,t.total_assets,"TOTAL ASSETS"),r=Oh(r,"Liabilities",t.liabilities,t.total_liabilities,"TOTAL LIABILITIES"),r=Oh(r,"Equity",t.equity,t.total_equity,"TOTAL EQUITY"),r.push(t.balanced?"**BALANCED** — assets equal liabilities plus equity.":"**OUT OF BALANCE** — assets do not equal liabilities plus equity."),r.join(`
420`)}function $O(t,n){var r=Qp("Profit & Loss Statement",n,[["Period",t.period||""]]);return r.push("## Revenue",""),r=r.concat(Df(["Code","Account","Category","Amount"],3)),(t.revenue||[]).forEach(function(o){r.push(tl([o.account_code,o.name,o.category||"",o.amount]))}),r.push(tl(["","**TOTAL REVENUE**","","**"+t.total_revenue+"**"])),r.push("","## Expenses",""),r=r.concat(Df(["Code","Account","Category","Amount"],3)),(t.expenses||[]).forEach(function(o){r.push(tl([o.account_code,o.name,o.category||"",o.amount]))}),r.push(tl(["","**TOTAL EXPENSES**","","**"+t.total_expenses+"**"])),r.push("","**NET INCOME: "+t.net_income+"**"),r.join(`
421`)}function JO(t,n){var r=Qp("Cash Flow Forecast",n,[["Horizon",(t.months||0)+" months"]]);return r=r.concat(Df(["Month","Income","Expenses","Net"],1)),(t.projections||[]).forEach(function(o){r.push(tl(["M+"+o.month,o.income,o.expenses,o.net]))}),r.push(""),r.push("_Projected from recurring vendor schedules; positive amounts are outflows at source._"),r.join(`
422`)}function Lh(t,n,r,o,a){return t.push("## "+n,""),t=t.concat(Df(["Code","Item","Category","Amount"],3)),(r||[]).forEach(function(l){t.push(tl([l.account_code||"",l.name,l.category||"",l.amount]))}),t.push(tl(["","**"+a+"**","","**"+o+"**"])),t.push(""),t}function QO(t,n){var r=Qp("Cash Flow Statement (Actual)",n,[["Period",t.period||""]]);return r=Lh(r,"Operating activities",t.operating,t.total_operating,"TOTAL OPERATING"),r=Lh(r,"Investing activities",t.investing,t.total_investing,"TOTAL INVESTING"),r=Lh(r,"Financing activities",t.financing,t.total_financing,"TOTAL FINANCING"),r.push("**NET CHANGE IN CASH: "+t.net_change+"**"),r.push(""),r.push("Opening cash "+t.opening_cash+" → closing cash "+t.closing_cash+"."),r.push("_Historical flows from cash-account journal lines and matched bank transactions._"),r.join(`
423`)}var ZO=[{id:"tb",label:"TRIAL BALANCE"},{id:"bs",label:"BALANCE SHEET"},{id:"pnl",label:"P&L"},{id:"cfa",label:"CASH FLOW (ACTUAL)"},{id:"cf",label:"CASH FLOW (FORECAST)"}],X1=["tb","bs","pnl"];function xg(){return new Date().toISOString().slice(0,10)}function e9(){return xg().slice(0,4)+"-01-01"}var J0={background:"#05080D",border:"1px solid "+Ke,borderRadius:4,padding:"5px 8px",color:xn,fontFamily:D,fontSize:10,outline:"none"},Ao={fontFamily:D,fontSize:8,color:Lt,letterSpacing:".1em",textAlign:"left",padding:"4px 8px",borderBottom:"1px solid "+Ke},xl=Object.assign({},Ao,{textAlign:"right"}),wr={fontFamily:D,fontSize:10,color:xn,padding:"3px 8px",borderBottom:"1px solid #0D1117"},Xl=Object.assign({},wr,{textAlign:"right"}),mf=Object.assign({},Xl,{fontWeight:700,borderTop:"1px solid "+Ke});function t9({balanced:t}){return(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,fontWeight:700,letterSpacing:".1em",color:t?bt:et,border:"1px solid "+(t?bt:et)+"44",background:(t?bt:et)+"10",borderRadius:3,padding:"2px 6px"},children:t?"◆ BALANCED":"◇ OUT OF BALANCE"})}function Xc({label:t,rows:n,total:r,totalLabel:o,color:a}){return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("tr",{children:(0,e.jsx)("td",{colSpan:4,style:Object.assign({},wr,{color:a,fontSize:8,letterSpacing:".12em",paddingTop:10}),children:t})}),(n||[]).map(function(l,s){return(0,e.jsxs)("tr",{children:[(0,e.jsx)("td",{style:wr,children:l.account_code}),(0,e.jsx)("td",{style:wr,children:l.name}),(0,e.jsx)("td",{style:Object.assign({},wr,{color:Lt,fontSize:8}),children:l.category||""}),(0,e.jsx)("td",{style:Xl,children:wn(l.balance||l.amount)})]},s)}),(0,e.jsxs)("tr",{children:[(0,e.jsx)("td",{style:wr}),(0,e.jsx)("td",{style:Object.assign({},wr,{fontWeight:700,color:a}),children:o}),(0,e.jsx)("td",{style:wr}),(0,e.jsx)("td",{style:Object.assign({},mf,{color:a}),children:wn(r)})]})]})}function q1({entity:t,mode:n,group:r}){const o=n==="consolidated"&&!!r,[a,l]=(0,i.useState)("tb"),[s,c]=(0,i.useState)(xg()),[d,p]=(0,i.useState)(e9()),[g,f]=(0,i.useState)(xg()),[h,x]=(0,i.useState)(6),[v,y]=(0,i.useState)(null),[k,A]=(0,i.useState)(!1),[j,E]=(0,i.useState)(null),[C,_]=(0,i.useState)(!1),[w,O]=(0,i.useState)(!1),[M,U]=(0,i.useState)(!1),[ee,N]=(0,i.useState)(null),V=t&&t.id,z=r&&r.id,oe=o&&X1.indexOf(a)===-1?"tb":a,P=(0,i.useCallback)(function(){if(o?!z:!V)return;A(!0),E(null),N(null);let X;o?oe==="tb"?X=dn.consolidatedTrialBalance(z,s):oe==="bs"?X=dn.consolidatedBalanceSheet(z,s):X=dn.consolidatedPnl(z,d,g):a==="tb"?X=dn.trialBalance(V,s):a==="bs"?X=dn.balanceSheet(V,s):a==="pnl"?X=dn.pnl(V,d,g):a==="cfa"?X=dn.cashFlowStatement
423(V,d,g):X=dn.cashFlow(V,h),X.then(function(de){if(A(!1),de&&de.error){E(de.error),y(null);return}y(de)}).catch(function(de){A(!1),E(de&&de.message||"Network error"),y(null)})},[o,z,oe,V,a,s,d,g,h]);(0,i.useEffect)(function(){const X=setTimeout(P,0);return function(){clearTimeout(X)}},[P]);const W=o?oe:a;function R(){if(!v||C)return;let X,de;const We=xg(),te=o?{name:r&&r.name||"Consolidated group",functional_currency:r&&r.presentation_currency||""}:t,_e=o?te.name+" (consolidated)":te.name;W==="tb"?(X=XO(v,te),de=_e+" — Trial Balance "+We):W==="bs"?(X=qO(v,te),de=_e+" — Balance Sheet "+We):W==="pnl"?(X=$O(v,te),de=_e+" — P&L "+d+" to "+g):W==="cfa"?(X=QO(v,te),de=_e+" — Cash Flow Statement "+d+" to "+g):(X=JO(v,te),de=_e+" — Cash Flow Forecast "+We),_(!0),N(null),uu.generatePDF(de,X,!0).then(function(ve){_(!1),N(ve?{ok:!0,text:"PDF exported from live statement data — saved to vault"}:{ok:!1,text:"PDF export failed"})}).catch(function(){_(!1),N({ok:!1,text:"PDF export failed"})})}function ae(){w||!V||(O(!0),N(null),dn.exportCsv(V,"trial-balance").then(function(X){if(O(!1),!X||X.error||!X.blob){N({ok:!1,text:X&&X.error||"CSV export failed"});return}var de=URL.createObjectURL(X.blob),We=document.createElement("a");We.href=de,We.download=X.filename||"trial-balance.csv",We.click(),URL.revokeObjectURL(de),N({ok:!0,text:"CSV exported deterministically from the ledger database"})}).catch(function(X){O(!1),N({ok:!1,text:X&&X.message||"Network error"})}))}function q(){M||!V||(U(!0),N(null),dn.exportXlsx(V,"trial-balance").then(function(X){if(U(!1),!X||X.error||!X.blob){N({ok:!1,text:X&&X.error||"XLSX export failed"});return}var de=URL.createObjectURL(X.blob),We=document.createElement("a");We.href=de,We.download=X.filename||"trial-balance.xlsx",We.click(),URL.revokeObjectURL(de),N({ok:!0,text:"XLSX exported deterministically from the ledger database"})}).catch(function(X){U(!1),N({ok:!1,text:X&&X.message||"Network error"})}))}const ge=o?r&&r.presentation_currency||"":t&&t.functional_currency||"";return(0,e.jsx)("div",{style:{flex:1,overflow:"auto",padding:16},children:(0,e.jsxs)("div",{style:{maxWidth:860,margin:"0 auto"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:14,flexWrap:"wrap"},children:[ZO.filter(function(X){return!o||X1.indexOf(X.id)!==-1}).map(function(X){const de=W===X.id;return(0,e.jsx)("button",{onClick:function(){l(X.id)},style:{padding:"6px 12px",background:de?pe+"14":ln,border:"1px solid "+(de?pe+"55":Ke),borderRadius:5,cursor:"pointer",fontFamily:D,fontSize:9,color:de?pe:cn,fontWeight:de?700:400,letterSpacing:".06em"},children:X.label},X.id)}),(0,e.jsx)("div",{style:{flex:1}}),(W==="tb"||W==="bs")&&(0,e.jsxs)("label",{style:{fontFamily:D,fontSize:8,color:"#6A8098",display:"flex",alignItems:"center",gap:6},children:["AS OF"," ",(0,e.jsx)("input",{type:"date",value:s,onChange:function(X){c(X.target.value)},style:J0})]}),(W==="pnl"||W==="cfa")&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("label",{style:{fontFamily:D,fontSize:8,color:"#6A8098",display:"flex",alignItems:"center",gap:6},children:["FROM"," ",(0,e.jsx)("input",{type:"date",value:d,onChange:function(X){p(X.target.value)},style:J0})]}),(0,e.jsxs)("label",{style:{fontFamily:D,fontSize:8,color:"#6A8098",display:"flex",alignItems:"center",gap:6},children:["TO"," ",(0,e.jsx)("input",{type:"date",value:g,onChange:function(X){f(X.target.value)},style:J0})]})]}),W==="cf"&&(0,e.jsxs)("label",{style:{fontFamily:D,fontSize:8,color:"#6A8098",display:"flex",alignItems:"center",gap:6},children:["MONTHS",(0,e.jsx)("select",{value:h,onChange:function(X){x(parseInt(X.target.value,10))},style:J0,children:[3,6,12,24].map(function(X){return(0,e.jsx)("option",{value:X,children:X},X)})})]}),W==="tb"&&!o&&(0,e.jsx)("button",{onClick:ae,disabled:!V||w,title:"Download the trial balance as deterministic CSV (from the ledger DB)",style:{padding:"6px 12px",background:V?pe+"12":Ut+"10",border:"1px solid "+(V?pe:Ut)+"44",borderRadius:5,cursor:V&&!w?"pointer":"default",fontFamily:D,fontSize:9,color:V?pe:Ut,fontWeight:700,letterSpacing:".06em"},children:w?"◌ EXPORTING…":"⇩ CSV"}),W==="tb"&&!o&&(0,e.jsx)("button",{onClick:q,disabled:!V||M,title:"Download the trial balance as a typed XLSX workbook (from the ledger DB)",style:{padding:"6px 12px",background:V?pe+"12":Ut+"10",border:"1px solid "+(V?pe:Ut)+"44",borderRadius:5,cursor:V&&!M?"pointer":"default",fontFamily:D,fontSize:9,color:V?pe:Ut,fontWeight:700,letterSpacing:".06em"},children:M?"◌ EXPORTING…":"⇩ XLSX"}),(0,e.jsx)("button",{onClick:R,disabled:!v||C,style:{padding:"6px 12px",background:v?Ft+"12":Ut+"10",border:"1px solid "+(v?Ft:Ut)+"44",borderRadius:5,cursor:v&&!C?"pointer":"default",fontFamily:D,fontSize:9,color:v?Ft:Ut,fontWeight:700,letterSpacing:".06em"},children:C?"◌ EXPORTING…":"EXPORT PDF"})]}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:10},children:[(0,e.jsx)("span",{style:{fontFamily:D,fontSize:10,fontWeight:700,color:xn,letterSpacing:".06em"},children:o?r&&r.name||"":t&&t.name||""}),o&&(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,fontWeight:700,letterSpacing:".1em",color:Ft,border:"1px solid "+Ft+"44",background:Ft+"10",borderRadius:3,padding:"2px 6px"}
423,children:"◫ CONSOLIDATED · READ-ONLY"}),(0,e.jsxs)("span",{style:{fontFamily:D,fontSize:8,color:Lt},children:["ALL FIGURES IN ",ge]}),v&&(W==="tb"||W==="bs")&&(0,e.jsx)(t9,{balanced:!!v.balanced})]}),ee&&(0,e.jsx)("div",{style:{marginBottom:10,padding:"7px 10px",background:(ee.ok?bt:et)+"0C",border:"1px solid "+(ee.ok?bt:et)+"33",borderRadius:5,fontFamily:D,fontSize:9,color:ee.ok?bt:et},children:ee.text}),j&&(0,e.jsx)("div",{style:{marginBottom:10,padding:"7px 10px",background:et+"0C",border:"1px solid "+et+"33",borderRadius:5,fontFamily:D,fontSize:9,color:et},children:j}),k&&(0,e.jsx)("div",{style:{fontFamily:D,fontSize:10,color:Ut,padding:24,textAlign:"center"},children:"◌ Loading statement…"}),!k&&v&&(0,e.jsxs)("div",{style:{background:ln,border:"1px solid "+Ke,borderRadius:8,padding:14},children:[W==="tb"&&(0,e.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse"},children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{style:Ao,children:"CODE"}),(0,e.jsx)("th",{style:Ao,children:"ACCOUNT"}),(0,e.jsx)("th",{style:Ao,children:"TYPE"}),(0,e.jsx)("th",{style:xl,children:"DEBIT"}),(0,e.jsx)("th",{style:xl,children:"CREDIT"}),(0,e.jsx)("th",{style:xl,children:"BALANCE"})]})}),(0,e.jsxs)("tbody",{children:[(v.accounts||[]).map(function(X,de){return(0,e.jsxs)("tr",{children:[(0,e.jsx)("td",{style:wr,children:X.account_code}),(0,e.jsx)("td",{style:wr,children:X.account_name}),(0,e.jsx)("td",{style:Object.assign({},wr,{color:"#6A8098",fontSize:8}),children:X.account_type}),(0,e.jsx)("td",{style:Xl,children:wn(X.total_debit)}),(0,e.jsx)("td",{style:Xl,children:wn(X.total_credit)}),(0,e.jsx)("td",{style:Xl,children:wn(X.balance)})]},de)}),(0,e.jsxs)("tr",{children:[(0,e.jsx)("td",{style:wr}),(0,e.jsx)("td",{style:Object.assign({},wr,{fontWeight:700}),children:"TOTAL"}),(0,e.jsx)("td",{style:wr}),(0,e.jsx)("td",{style:mf,children:wn(v.total_debit)}),(0,e.jsx)("td",{style:mf,children:wn(v.total_credit)}),(0,e.jsx)("td",{style:Object.assign({},mf,{color:v.balanced?bt:et}),children:v.balanced?"0.00":wn(v.variance)})]})]})]}),W==="bs"&&(0,e.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse"},children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{style:Ao,children:"CODE"}),(0,e.jsx)("th",{style:Ao,children:"ACCOUNT"}),(0,e.jsx)("th",{style:Ao,children:"CATEGORY"}),(0,e.jsx)("th",{style:xl,children:"BALANCE"})]})}),(0,e.jsxs)("tbody",{children:[(0,e.jsx)(Xc,{label:"ASSETS",rows:v.assets,total:v.total_assets,totalLabel:"TOTAL ASSETS",color:bt}),(0,e.jsx)(Xc,{label:"LIABILITIES",rows:v.liabilities,total:v.total_liabilities,totalLabel:"TOTAL LIABILITIES",color:et}),(0,e.jsx)(Xc,{label:"EQUITY",rows:v.equity,total:v.total_equity,totalLabel:"TOTAL EQUITY",color:Ft})]})]}),W==="pnl"&&(0,e.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse"},children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{style:Ao,children:"CODE"}),(0,e.jsx)("th",{style:Ao,children:"ACCOUNT"}),(0,e.jsx)("th",{style:Ao,children:"CATEGORY"}),(0,e.jsx)("th",{style:xl,children:"AMOUNT"})]})}),(0,e.jsxs)("tbody",{children:[(0,e.jsx)(Xc,{label:"REVENUE",rows:v.revenue,total:v.total_revenue,totalLabel:"TOTAL REVENUE",color:bt}),(0,e.jsx)(Xc,{label:"EXPENSES",rows:v.expenses,total:v.total_expenses,totalLabel:"TOTAL EXPENSES",color:et}),(0,e.jsxs)("tr",{children:[(0,e.jsx)("td",{style:wr}),(0,e.jsx)("td",{style:Object.assign({},wr,{fontWeight:700,color:pe}),children:"NET INCOME"}),(0,e.jsx)("td",{style:wr}),(0,e.jsx)("td",{style:Object.assign({},mf,{color:pe}),children:wn(v.net_income)})]})]})]}),W==="cfa"&&(0,e.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse"},children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{style:Ao,children:"CODE"}),(0,e.jsx)("th",{style:Ao,children:"ITEM"}),(0,e.jsx)("th",{style:Ao,children:"CATEGORY"}),(0,e.jsx)("th",{style:xl,children:"AMOUNT"})]})}),(0,e.jsxs)("tbody",{children:[(0,e.jsx)(Xc,{label:"OPERATING ACTIVITIES",rows:v.operating,total:v.total_operating,totalLabel:"TOTAL OPERATING",color:bt}),(0,e.jsx)(Xc,{label:"INVESTING ACTIVITIES",rows:v.investing,total:v.total_investing,totalLabel:"TOTAL INVESTING",color:Ft}),(0,e.jsx)(Xc,{label:"FINANCING ACTIVITIES",rows:v.financing,total:v.total_financing,totalLabel:"TOTAL FINANCING",color:et}),(0,e.jsxs)("tr",{children:[(0,e.jsx)("td",{style:wr}),(0,e.jsx)("td",{style:Object.assign({},wr,{fontWeight:700,color:pe}),children:"NET CHANGE IN CASH"}),(0,e.jsx)("td",{style:wr}),(0,e.jsx)("td",{style:Object.assign({},mf,{color:pe}),children:wn(v.net_change)})]}),(0,e.jsxs)("tr",{children:[(0,e.jsx)("td",{style:wr}),(0,e.jsxs)("td",{style:Object.assign({},wr,{color:"#6A8098",fontSize:9}),children:["OPENING ",wn(v.opening_cash)," → CLOSING"," ",wn(v.closing_c
423ash)]}),(0,e.jsx)("td",{style:wr}),(0,e.jsx)("td",{style:wr})]})]})]}),W==="cf"&&(0,e.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse"},children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{style:Ao,children:"MONTH"}),(0,e.jsx)("th",{style:xl,children:"INCOME"}),(0,e.jsx)("th",{style:xl,children:"EXPENSES"}),(0,e.jsx)("th",{style:xl,children:"NET"})]})}),(0,e.jsx)("tbody",{children:(v.projections||[]).map(function(X,de){const We=String(X.net||"").charAt(0)==="-";return(0,e.jsxs)("tr",{children:[(0,e.jsxs)("td",{style:wr,children:["M+",X.month]}),(0,e.jsx)("td",{style:Xl,children:wn(X.income)}),(0,e.jsx)("td",{style:Xl,children:wn(X.expenses)}),(0,e.jsx)("td",{style:Object.assign({},Xl,{color:We?et:bt,fontWeight:700}),children:wn(X.net)})]},de)})})]})]}),!k&&v&&o&&(0,e.jsxs)("div",{style:{background:ln,border:"1px solid "+Ke,borderRadius:8,padding:14,marginTop:12},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:"#6A8098",letterSpacing:".12em",marginBottom:6},children:"MEMBERS · TRANSLATION"}),(0,e.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse",marginBottom:12},children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{style:Ao,children:"ENTITY"}),(0,e.jsx)("th",{style:Ao,children:"OWNERSHIP"}),(0,e.jsx)("th",{style:Ao,children:"RATES"})]})}),(0,e.jsx)("tbody",{children:(v.members||[]).map(function(X,de){return(0,e.jsxs)("tr",{children:[(0,e.jsx)("td",{style:wr,children:X.name||X.entity_id}),(0,e.jsx)("td",{style:wr,children:sk(X.ownership_pct)}),(0,e.jsx)("td",{style:Object.assign({},wr,{color:"#6A8098",fontSize:9}),children:FO(X,ge)})]},de)})})]}),(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:"#6A8098",letterSpacing:".12em",marginBottom:6},children:"ELIMINATIONS · INTERCOMPANY"}),(0,e.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse",marginBottom:10},children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{style:Ao,children:"ACCOUNTS"}),(0,e.jsx)("th",{style:xl,children:"REMOVED (DR SIDE)"}),(0,e.jsx)("th",{style:xl,children:"REMOVED (CR SIDE)"}),(0,e.jsx)("th",{style:xl,children:"RESIDUAL"})]})}),(0,e.jsxs)("tbody",{children:[V1(v).map(function(X,de){return(0,e.jsxs)("tr",{children:[(0,e.jsx)("td",{style:wr,children:X.accounts}),(0,e.jsx)("td",{style:Xl,children:wn(X.removedLeft)}),(0,e.jsx)("td",{style:Xl,children:wn(X.removedRight)}),(0,e.jsx)("td",{style:Object.assign({},Xl,{color:X.matched?bt:et,fontWeight:X.matched?400:700}),children:X.matched?"0.00":wn(X.residual)})]},de)}),V1(v).length===0&&(0,e.jsx)("tr",{children:(0,e.jsx)("td",{style:Object.assign({},wr,{color:Ut}),colSpan:4,children:"No intercompany balances to eliminate"})})]})]}),Y1(v)&&(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:9,color:Ft,border:"1px solid "+Ft+"33",background:Ft+"0C",borderRadius:5,padding:"6px 10px"},children:[Y1(v)," ",(0,e.jsxs)("span",{style:{color:"#6A8098",fontSize:8},children:["— ",v.cta&&v.cta.note||""]})]})]})]})})}var ck={date:["date","transaction date","txn date","booking date","posting date"],value_date:["value date","val date","settlement date"],amount:["amount","transaction amount","amount (gbp)","amount (usd)"],debit:["debit","debit amount","paid out","money out","withdrawal"],credit:["credit","credit amount","paid in","money in","deposit"],description:["description","details","memo","narrative","transaction description"],counterparty:["payee","counterparty","name","merchant"],external_ref:["reference","ref","external ref","transaction id","fitid"],currency:["currency","ccy"]};function $1(t){for(var n=[],r="",o=!1,a=0;a<t.length;a++){var l=t[a];o?l==='"'?t[a+1]==='"'?(r+='"',a++):o=!1:r+=l:l==='"'?o=!0:l===","?(n.push(r),r=""):r+=l}return n.push(r),n}function Yg(t){var n=String(t||"").trim();if(!n)return null;var r=/^(\d{4})-(\d{2})-(\d{2})/.exec(n);if(r)return r[1]+"-"+r[2]+"-"+r[3];if(r=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{4})$/.exec(n),r){var o=parseInt(r[1],10),a=parseInt(r[2],10),l=r[3],s=o,c=a;return o<=12&&a>12&&(s=a,c=o),c<1||c>12||s<1||s>31?null:l+"-"+String(c).padStart(2,"0")+"-"+String(s).padStart(2,"0")}return r=/^(\d{4})\/(\d{1,2})\/(\d{1,2})$/.exec(n),r?r[1]+"-"+String(parseInt(r[2],10)).padStart(2,"0")+"-"+String(parseInt(r[3],10)).padStart(2,"0"):null}function Pp(t){var n=String(t||"").trim();if(!n)return null;var r=!1;if(n.charAt(0)==="("&&n.charAt(n.length-1)===")"&&(r=!0,n=n.slice(1,-1)),n=n.replace(/[£$€\s,']/g,""),n.charAt(0)==="
423+"&&(n=n.slice(1)),!/^-?\d+(\.\d+)?$/.test(n))return null;var o=n,a="";o.charAt(0)==="-"&&(a="-",o=o.slice(1)),r&&(a="-");var l=o.split("."),s=l[0].replace(/^0+(?=\d)/,""),c=(l[1]||"").slice(0,3),d;if(c.length<=2?d=parseInt(s,10)*100+parseInt((c+"00").slice(0,2),10):d=Math.round(parseFloat(s+"."+c)*100),!isFinite(d))return null;var p=String(Math.floor(d/100))+"."+String(d%100).padStart(2,"0");return a==="-"&&d!==0&&(p="-"+p),p}function n9(t,n,r){var o=r&&r[n+"_col"];if(o){var a=t.indexOf(String(o).trim().toLowerCase());return a===-1?null:a}for(var l=ck[n]||[],s=0;s<l.length;s++){var c=t.indexOf(l[s]);if(c!==-1)return c}return null}function r9(t,n){var r=String(t||"").replace(/^\uFEFF/,"").split(/\r\n|\r|\n/).filter(function(k){return k.trim()!==""});if(r.length<2)return{error:"CSV has no data rows",rows:[]};var o=$1(r[0]).map(function(k){return k.trim().toLowerCase()}),a={};if(Object.keys(ck).forEach(function(k){a[k]=n9(o,k,n)}),a.date===null)return{error:"No recognizable date column",rows:[]};if(a.amount===null&&(a.debit===null||a.credit===null))return{error:"Need an amount column or debit+credit twin columns",rows:[]};for(var l=[],s=0,c=1;c<r.length;c++){var d=$1(r[c]),p=function(k){return k===null||k>=d.length?"":(d[k]||"").trim()},g=Yg(p(a.date)),f=null;if(a.amount!==null&&p(a.amount)!=="")f=Pp(p(a.amount));else{var h=Pp(p(a.debit)),x=Pp(p(a.credit));if(h===null&&x===null)f=null;else{var v=h===null?0:Math.abs(Math.round(parseFloat(h)*100)),y=(x===null?0:Math.abs(Math.round(parseFloat(x)*100)))-v;f=(y<0?"-":"")+String(Math.floor(Math.abs(y)/100))+"."+String(Math.abs(y)%100).padStart(2,"0")}}if(!g||f===null){s++;continue}l.push({txn_date:g,value_date:Yg(p(a.value_date)),amount:f,currency:p(a.currency).toUpperCase()||null,description:p(a.description),counterparty:p(a.counterparty)||null,external_ref:p(a.external_ref)||null})}return{rows:l,skipped:s,error:null}}function xp(t,n){var r=new RegExp("<"+n+">([^<\\r\\n]*)","i").exec(t);return r?r[1].trim():""}function i9(t){var n=String(t||""),r=/<CURDEF>\s*([A-Za-z]{3})/i.exec(n),o=r?r[1].toUpperCase():null,a=n.match(/<STMTTRN>[\s\S]*?<\/STMTTRN>/gi)||[];if(a.length===0)return{error:"No STMTTRN blocks",rows:[]};var l=[],s=0;return a.forEach(function(c){var d=xp(c,"DTPOSTED"),p=Pp(xp(c,"TRNAMT"));if(d.length<8||p===null){s++;return}var g=xp(c,"NAME"),f=xp(c,"MEMO");l.push({txn_date:d.slice(0,4)+"-"+d.slice(4,6)+"-"+d.slice(6,8),value_date:null,amount:p,currency:o,description:f||g,counterparty:g||null,external_ref:xp(c,"FITID")||null})}),{rows:l,skipped:s,error:null}}function o9(t){var n=String(t||"");if(/<!\s*(DOCTYPE|ENTITY)/i.test(n))return{error:"DOCTYPE/ENTITY declarations are not accepted",rows:[]};var r=n.match(/<Ntry>[\s\S]*?<\/Ntry>/gi)||[];if(r.length===0)return{error:"No Ntry entries",rows:[]};var o=[],a=0;return r.forEach(function(l){var s=/<Amt[^>]*Ccy="([A-Za-z]{3})"[^>]*>([^<]+)<\/Amt>/i.exec(l),c=Pp((s?s[2]:(/<Amt[^>]*>([^<]+)<\/Amt>/i.exec(l)||[])[1])||""),d=/<BookgDt>[\s\S]*?<Dt>([^<]+)<\/Dt>/i.exec(l),p=d?Yg(d[1]):null;if(c===null||!p){a++;return}var g=/<CdtDbtInd>\s*([A-Za-z]+)/i.exec(l);g&&g[1].toUpperCase()==="DBIT"&&c.charAt(0)!=="-"&&(c="-"+c);var f=/<ValDt>[\s\S]*?<Dt>([^<]+)<\/Dt>/i.exec(l),h=/<Ustrd>([^<]+)<\/Ustrd>/i.exec(l),x=/<AcctSvcrRef>([^<]+)<\/AcctSvcrRef>/i.exec(l),v=/<Nm>([^<]+)<\/Nm>/i.exec(l);o.push({txn_date:p,value_date:f?Yg(f[1]):null,amount:c,currency:s?s[1].toUpperCase():null,description:h?h[1].trim():"",counterparty:v?v[1].trim():null,external_ref:x?x[1].trim():null})}),{rows:o,skipped:a,error:null}}function a9(t,n,r){var o=String(t||"").toUpperCase();return o==="CSV"?r9(n,r):o==="OFX"?i9(n):o==="CAMT053"?o9(n):{error:"Unknown format "+t,rows:[]}}var l9=["ALL","UNMATCHED","SUGGESTED","MATCHED","EXCLUDED"],dk={UNMATCHED:cn,SUGGESTED:pe,MATCHED:bt,EXCLUDED:Ut},s9=[{id:"CSV",label:"CSV"},{id:"OFX",label:"OFX"},{id:"CAMT053",label:"CAMT.053 XML"}],qc={background:"#05080D",border:"1px solid "+Ke,borderRadius:4,padding:"6px 8px",color:xn,fontFamily:D,fontSize:10,outline:"none",width:"100%",boxSizing:"border-box"},vs={fontFamily:D,fontSize:8,color:Lt,letterSpacing:".1em",display:"block",marginBottom:3},Es={fontFamily:D,fontSize:8,color:Lt,letterSpacing:".1em",textAlign:"left",padding:"4px 8px",borderBottom:"1px solid "+Ke},J1=Object.assign({},Es,{textAlign:"right"}
423),Kl={fontFamily:D,fontSize:10,color:xn,padding:"3px 8px",borderBottom:"1px solid #0D1117"},Q1=Object.assign({},Kl,{textAlign:"right"});function vp(t,n){return{padding:"5px 10px",background:n?t+"12":Ut+"10",border:"1px solid "+(n?t:Ut)+"44",borderRadius:5,cursor:n?"pointer":"default",fontFamily:D,fontSize:9,color:n?t:Ut,fontWeight:700,letterSpacing:".06em"}}function Ay(t){return{padding:"2px 7px",background:t+"10",border:"1px solid "+t+"44",borderRadius:3,cursor:"pointer",fontFamily:D,fontSize:8,color:t,letterSpacing:".06em"}}function Z1({title:t,onClose:n,children:r,width:o}){return(0,e.jsx)("div",{style:{position:"fixed",inset:0,background:"#000A",display:"flex",alignItems:"center",justifyContent:"center",zIndex:60},onMouseDown:function(a){a.target===a.currentTarget&&n()},children:(0,e.jsxs)("div",{style:{width:o||440,maxWidth:"94vw",maxHeight:"88vh",overflow:"auto",background:"#070B10",border:"1px solid "+Ke,borderRadius:8,padding:16},role:"dialog","aria-label":t,children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",marginBottom:12},children:[(0,e.jsx)("span",{style:{fontFamily:D,fontSize:10,fontWeight:700,color:pe,letterSpacing:".12em"},children:t}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{onClick:n,style:Ay(cn),children:"✕ CLOSE"})]}),r]})})}function c9({status:t}){const n=dk[t]||"#7A90A8";return(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:n,border:"1px solid "+n+"44",background:n+"10",borderRadius:3,padding:"1px 6px",letterSpacing:".08em"},children:t})}function d9({entity:t,accounts:n,role:r,onRefresh:o}){const a=t&&t.id,l=r==="bookkeeper"||r==="approver"||r==="controller",s=r==="approver"||r==="controller",[c,d]=(0,i.useState)([]),[p,g]=(0,i.useState)(null),[f,h]=(0,i.useState)([]),[x,v]=(0,i.useState)(null),[y,k]=(0,i.useState)("ALL"),[A,j]=(0,i.useState)(!1),[E,C]=(0,i.useState)(!1),[_,w]=(0,i.useState)(null),[O,M]=(0,i.useState)(null),[U,ee]=(0,i.useState)(!1),[N,V]=(0,i.useState)(!1),[z,oe]=(0,i.useState)(""),[P,W]=(0,i.useState)("1000"),[R,ae]=(0,i.useState)(""),[q,ge]=(0,i.useState)(""),[X,de]=(0,i.useState)(""),[We,te]=(0,i.useState)("CSV"),[_e,ve]=(0,i.useState)(""),[Ne,$e]=(0,i.useState)(""),[Pe,ot]=(0,i.useState)({}),re=(0,i.useRef)(null),we=(0,i.useRef)(0),b=(0,i.useCallback)(function(){a&&dn.bankAccounts(a).then(function($){if($&&$.error){w($.error),d([]);return}const Ue=$&&$.bank_accounts||[];d(Ue),g(function(Ie){return Ie&&Ue.some(Q=>Q.id===Ie)?Ie:Ue.length?Ue[0].id:null})})},[a]),He=(0,i.useCallback)(function(){if(!a||!p){h([]),v(null);return}const $=++we.current;j(!0),w(null),Promise.all([dn.bankTransactions(a,p,y==="ALL"?null:y),dn.bankReconciliation(a,p)]).then(function(Ue){if($!==we.current)return;j(!1);const Ie=Ue[0],Q=Ue[1];h(Ie&&!Ie.error?Ie.transactions||[]:[]),v(Q&&!Q.error?Q:null);const rt=Ie&&Ie.error||Q&&Q.error||null;rt&&w(rt)})},[a,p,y]);(0,i.useEffect)(function(){const $=setTimeout(function(){d([]),g(null),M(null),b()},0);return function(){clearTimeout($)}},[b]),(0,i.useEffect)(function(){const $=setTimeout(He,0);return function(){clearTimeout($)}},[He]);function tt(){E||(C(!0),w(null),dn.createBankAccount(a,{name:z,account_code:P,currency:R||t&&t.functional_currency||"",iban_masked:q||null,bank_name:X||null}).then(function($){if(C(!1),$&&$.error){w($.error);return}ee(!1),oe(""),ge(""),de(""),M("Bank account created"),b()}))}function Ae(){if(E||!_e)return;C(!0),w(null);const $={};Object.keys(Pe).forEach(function(Ue){Pe[Ue]&&($[Ue]=Pe[Ue])}),dn.importBankStatement(a,p,{format:We,content:_e,encoding:"text",mapping:Object.keys($).length?$:null,filename:Ne||null}).then(function(Ue){if(C(!1),Ue&&Ue.error){w(Ue.error);return}V(!1),ve(""),$e(""),M("Imported "+Ue.rows_imported+" of "+Ue.rows_total+" rows ("+Ue.rows_duplicate+" duplicates skipped)"),He()})}function Be(){E||!p||(C(!0),w(null),dn.suggestBankMatches(a,p).then(function($){if(C(!1),$&&$.error){w($.error);return}M("Scanned "+$.scanned+" unmatched — "+$.suggested+" suggestion"+($.suggested===1?"":"s")+" staged"),He()}))}function Fe($){E||(C(!0),w(null),dn.confirmBankMatch(a,$.id,{}).then(function(Ue){if(C(!1),Ue&&Ue.error){w(Ue.error);return}M("Match confirmed"),He(),o&&o()}))}function ft($){E||(C(!0),w(null),dn.excludeBankTransaction(a,$.id).then(function(Ue){if(C(!1),Ue&&Ue.error){w(Ue.error);return}M("Transaction excluded"),He()}))}function St($){const Ue=$.target.files&&$.target.files[0];if(!Ue)return;$e(Ue.name);const Ie=new FileReader;Ie.onload=function(){ve(String(Ie.result||""))},Ie.readAsText(Ue)}const Xe=_e?a9(We,_e,Pe):null,It=c.filter(function($){return $.id===p})[0]||null,Rt=x&&x.difference&&x.difference!=="0.00";return(0,e.jsx)("div",{style:{flex:1,overflow:"auto",padding:16},children:(0,e.jsxs)("div",{style:{maxWidth:960,margin:"0 auto"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12,flexWrap:"wrap"},children:[(0,e.jsx)("span",{style:vs,children:"BANK ACCOUNT"}),(0,e.jsxs)("select",{value:p||"",onChange:function($){g($.target.value||null)},style:Object.assign({},qc,{width:260}),"aria-label":"Bank account",children:[c.length===0&&(0,e.jsx)("option",{value:"",children:"— none —"}),c.map(function($){return(0,e.jsxs)("option",{value:$.id,children:[$.name," · GL ",$.account_code," · ",$.currency]},$.id)})]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{onClick:Be,disabled:!l||!p||E,style:vp(Ft,l&&p&&!E),title:"Score unmatched transactions against open invoices and posted journals",children:"◈ RUN MATCH"}),(0,e.jsx)("button",{onClick:function(){V(!0)},disabled:!l||!p,style:vp(pe,l&&!!p),children:"▲ IMPORT STATEMENT"}),(0,e.jsx)("button",{onClick:function(){ee(!0)},disabled:!l,style:vp(bt,l),children:"+ NEW ACCOUNT"})]}),x&&(0,e.jsxs)("div",{style:{display:"flex",gap:18,alignItems:"center",background:ln,border:"1px solid "+Ke,borderRadius:8,padding:"10px 14px",marginBottom:12,flexWrap:"wrap"},children:[[["BANK BALANCE",x.bank_balance,"#C9D1D9"],["GL "+x.gl_account_code,x.gl_balance,"#C9D1D9"],["DIFFERENCE",x.difference,Rt?et:bt]].map(function($){return(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:vs,children:$[0]}),(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:13,fontWeight:700,color:$[2]},children:[wn($[1])," ",(0,e.jsx)("span",{style:{fontSize:8,color:"#6A8098"},children:x.currency})]})]},$[0])}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:9,color:"#6A8098"},children:[x.unmatched," unmatched · ",x.suggested," suggested ·"," ",x.matched," matched · ",x.excluded," excluded"]})]}),O&&(0,e.jsx)("div",{style:{marginBottom:10,padding:"7px 10px",background:bt+"0C",border:"1px solid "+bt+"33",borderRadius:5,fontFamily:D,fontSize:9,color:bt},children:O}),_&&(0,e.jsx)("div",{style:{marginBottom:10,padding:"7px 10px",background:et+"0C",border:"1px solid "+et+"33",borderRadius:5,fontFamily:D,fontSize:9,color:et},children:_}),(0,e.jsx)("div",{style:{display:"flex",gap:6,marginBottom:10,flexWrap:"wrap"},children:l9.map(function($){const Ue=y===$,Ie=$==="ALL"?Ft:dk[$]||"#7A90A8";return(0,e.jsx)("button",{onClick:function(){k($)},style:{padding:"4px 10px",background:Ue?Ie+"14":"transparent",border:"1px solid "+(Ue?Ie+"66":Ke),borderRadius:12,cursor:"pointer",fontFamily:D,fontSize:8,color:Ue?Ie:Lt,letterSpacing:".08em"},children:$},$)})}),p?A?(0,e.jsx)("div",{style:{padding:24,textAlign:"center",fontFamily:D,fontSize:10,
423color:Ut},children:"◌ Loading transactions…"}):(0,e.jsx)("div",{style:{background:ln,border:"1px solid "+Ke,borderRadius:8,padding:10},children:(0,e.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse"},children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{style:Es,children:"DATE"}),(0,e.jsx)("th",{style:Es,children:"DESCRIPTION"}),(0,e.jsx)("th",{style:Es,children:"COUNTERPARTY"}),(0,e.jsx)("th",{style:J1,children:"AMOUNT"}),(0,e.jsx)("th",{style:Es,children:"STATUS"}),(0,e.jsx)("th",{style:Es,children:"MATCH"}),(0,e.jsx)("th",{style:Es})]})}),(0,e.jsxs)("tbody",{children:[f.length===0&&(0,e.jsx)("tr",{children:(0,e.jsxs)("td",{colSpan:7,style:Object.assign({},Kl,{color:Ut}),children:["No transactions"," ",y!=="ALL"?"with status "+y:"imported yet","."]})}),f.map(function($){const Ue=String($.amount||"").charAt(0)==="-",Ie=$.status==="SUGGESTED";return(0,e.jsxs)("tr",{children:[(0,e.jsx)("td",{style:Kl,children:$.txn_date}),(0,e.jsx)("td",{style:Kl,children:$.description||""}),(0,e.jsx)("td",{style:Object.assign({},Kl,{color:Lt,fontSize:9}),children:$.counterparty||""}),(0,e.jsx)("td",{style:Object.assign({},Q1,{color:Ue?et:bt,fontWeight:700}),children:wn($.amount)}),(0,e.jsx)("td",{style:Kl,children:(0,e.jsx)(c9,{status:$.status})}),(0,e.jsx)("td",{style:Object.assign({},Kl,{color:Lt,fontSize:8}),children:$.match_confidence?($.matched_invoice_id?"invoice ":$.matched_journal_id?"journal ":"")+"· conf "+$.match_confidence:""}),(0,e.jsxs)("td",{style:Object.assign({},Kl,{whiteSpace:"nowrap"}),children:[Ie&&s&&(0,e.jsx)("button",{onClick:function(){Fe($)},disabled:E,style:Ay(bt),title:"Confirm this match (invoice matches post the payment journal)",children:"✓ CONFIRM"})," ",($.status==="UNMATCHED"||Ie)&&l&&(0,e.jsx)("button",{onClick:function(){ft($)},disabled:E,style:Ay(et),children:"✕ EXCLUDE"})]})]},$.id)})]})]})}):(0,e.jsx)("div",{style:{padding:30,textAlign:"center",fontFamily:D,fontSize:10,color:Ut},children:"No bank account yet — create one with + NEW ACCOUNT to start importing statements."}),U&&(0,e.jsx)(Z1,{title:"◈ NEW BANK ACCOUNT",onClose:function(){ee(!1)},children:(0,e.jsxs)("div",{style:{display:"grid",gap:10},children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{style:vs,children:"NAME"}),(0,e.jsx)("input",{value:z,onChange:function($){oe($.target.value)},style:qc,placeholder:"e.g. HSBC Current"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{style:vs,children:"GL CASH ACCOUNT"}),(0,e.jsx)("select",{value:P,onChange:function($){W($.target.value)},style:qc,children:(n||[]).filter(function($){return $.account_type==="ASSET"}).map(function($){return(0,e.jsxs)("option",{value:$.code,children:[$.code," — ",$.name]},$.code)})})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{style:vs,children:"CURRENCY"}),(0,e.jsx)("input",{value:R||t&&t.functional_currency||"",onChange:function($){ae($.target.value.toUpperCase().slice(0,3))},style:qc,maxLength:3})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{style:vs,children:"IBAN (MASKED — LAST 4 ONLY)"}),(0,e.jsx)("input",{value:q,onChange:function($){ge($.target.value)},style:qc,placeholder:"GB** **** 1234"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{style:vs,children:"BANK NAME"}),(0,e.jsx)("input",{value:X,onChange:function($){de($.target.value)},style:qc})]}),(0,e.jsx)("button",{onClick:tt,disabled:E||!z.trim(),style:vp(bt,!E&&!!z.trim()),children:E?"◌ CREATING…":"CREATE ACCOUNT"})]})}),N&&(0,e.jsx)(Z1,{title:"▲ IMPORT STATEMENT",width:560,onClose:function(){V(!1)},children:(0,e.jsxs)("div",{style:{display:"grid",gap:10},children:[(0,e.jsx)("div",{style:{display:"flex",gap:8},children:s9.map(function($){const Ue=We===$.id;return(0,e.jsx)("button",{onClick:function(){te($.id)},style:{padding:"5px 10px",background:Ue?pe+"14":"transparent",border:"1px solid "+(Ue?pe+"66":Ke),borderRadius:5,cursor:"pointer",fontFamily:D,fontSize:9,color:Ue?pe:"#6A8098"},children:$.label},$.id)})}),(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{style:vs,children:"STATEMENT FILE (read locally)"}),(0,e.jsx)("input",{ref:re,type:"file",accept:".csv,.ofx,.xml,.txt",onCh
423ange:St,style:Object.assign({},qc,{padding:4})})]}),We==="CSV"&&(0,e.jsx)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:8},children:[["date_col","DATE COL"],["amount_col","AMOUNT COL"],["description_col","DESCRIPTION COL"],["debit_col","DEBIT COL"],["credit_col","CREDIT COL"],["counterparty_col","PAYEE COL"]].map(function($){return(0,e.jsxs)("div",{children:[(0,e.jsxs)("span",{style:vs,children:[$[1]," (OPTIONAL)"]}),(0,e.jsx)("input",{value:Pe[$[0]]||"",onChange:function(Ue){const Ie=Object.assign({},Pe);Ie[$[0]]=Ue.target.value,ot(Ie)},style:qc,placeholder:"auto"})]},$[0])})}),Xe&&Xe.error&&(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:9,color:et,padding:"6px 8px",background:et+"0C",borderRadius:4},children:["Preview: ",Xe.error]}),Xe&&!Xe.error&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("span",{style:vs,children:["PREVIEW — FIRST ",Math.min(5,Xe.rows.length)," OF"," ",Xe.rows.length," PARSED ROWS",Xe.skipped?" ("+Xe.skipped+" skipped)":""]}),(0,e.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse"},children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{style:Es,children:"DATE"}),(0,e.jsx)("th",{style:Es,children:"DESCRIPTION"}),(0,e.jsx)("th",{style:Es,children:"COUNTERPARTY"}),(0,e.jsx)("th",{style:J1,children:"AMOUNT"})]})}),(0,e.jsx)("tbody",{children:Xe.rows.slice(0,5).map(function($,Ue){const Ie=String($.amount).charAt(0)==="-";return(0,e.jsxs)("tr",{children:[(0,e.jsx)("td",{style:Kl,children:$.txn_date}),(0,e.jsx)("td",{style:Kl,children:$.description}),(0,e.jsx)("td",{style:Object.assign({},Kl,{color:"#6A8098",fontSize:9}),children:$.counterparty||""}),(0,e.jsx)("td",{style:Object.assign({},Q1,{color:Ie?et:bt}),children:wn($.amount)})]},Ue)})})]})]}),(0,e.jsx)("button",{onClick:Ae,disabled:E||!_e||!!(Xe&&Xe.error)||!It,style:vp(pe,!E&&!!_e&&!(Xe&&Xe.error)&&!!It),children:E?"◌ IMPORTING…":"IMPORT INTO "+(It&&It.name||"ACCOUNT")})]})})]})})}function u9(){return new Date().toISOString().slice(0,7)}function f9(){var t=new Date;return t.setUTCDate(1),t.setUTCMonth(t.getUTCMonth()-1),t.toISOString().slice(0,7)}function eS({title:t,entries:n}){if(!n||!n.length)return null;var r={fontFamily:D,fontSize:9,color:xn,padding:"2px 6px",borderBottom:"1px solid #0D1117"},o=Object.assign({},r,{textAlign:"right"});return(0,e.jsxs)("div",{style:{marginBottom:10},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Lt,letterSpacing:".1em",marginBottom:4},children:t}),(0,e.jsx)("table",{style:{width:"100%",borderCollapse:"collapse"},children:(0,e.jsx)("tbody",{children:n.map(function(a,l){return(0,e.jsxs)("tr",{children:[(0,e.jsx)("td",{style:r,children:a.account_code}),(0,e.jsx)("td",{style:Object.assign({},r,{color:Lt}),children:a.memo||""}),(0,e.jsx)("td",{style:o,children:a.debit&&a.debit!=="0.00"?"DR "+wn(a.debit):""}),(0,e.jsx)("td",{style:o,children:a.credit&&a.credit!=="0.00"?"CR "+wn(a.credit):""})]},l)})})})]})}function p9({entity:t,role:n,lockedPeriods:r,onLocked:o,onRefresh:a}){const[l,s]=(0,i.useState)(u9()),[c,d]=(0,i.useState)(""),[p,g]=(0,i.useState)(!1),[f,h]=(0,i.useState)(!1),[x,v]=(0,i.useState)(null),[y,k]=(0,i.useState)(f9()),[A,j]=(0,i.useState)(null),[E,C]=(0,i.useState)(!1),[_,w]=(0,i.useState)(null),O=n==="controller",M=/^\d{4}-(0[1-9]|1[0-2])$/.test(l),U=/^\d{4}-(0[1-9]|1[0-2])$/.test(y);function ee(){!t||E||!U||(C(!0),w(null),dn.closePeriod(t.id,y,!0).then(function(z){if(C(!1),z&&z.error){w({ok:!1,text:z.error});return}j(z)}).catch(function(z){C(!1),w({ok:!1,text:z&&z.message||"Network error"})}))}function N(){!t||E||!A||(C(!0),dn.closePeriod(t.id,y,!1).then(function(z){if(C(!1),j(null),z&&z.error){w({ok:!1,text:z.error});return}w({ok:!0,text:"CLOSED — period "+z.period+" locked"+(z.closing_journal&&z.closing_journal.status==="POSTED"?" · P&L closed to retained earnings":"")+(z.fx_revaluation&&z.fx_revaluation.status==="POSTED"?" · FX revaluation posted":"")}
423),o&&o(z.period),a&&a()}).catch(function(z){C(!1),j(null),w({ok:!1,text:z&&z.message||"Network error"})}))}function V(){!t||f||!M||(h(!0),v(null),dn.lockPeriod(t.id,l,c.trim()).then(function(z){if(h(!1),g(!1),z&&z.error){v({ok:!1,text:z.error}),String(z.error).indexOf("already locked")!==-1&&o&&o(l);return}v({ok:!0,text:"LOCKED — period "+z.period+" is closed to postings"}),d(""),o&&o(z.period)}).catch(function(z){h(!1),g(!1),v({ok:!1,text:z&&z.message||"Network error"})}))}return(0,e.jsx)("div",{style:{flex:1,overflow:"auto",padding:16},children:(0,e.jsxs)("div",{style:{maxWidth:560,margin:"0 auto"},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:10,fontWeight:700,color:pe,letterSpacing:".12em",marginBottom:14},children:"◈ PERIOD CLOSE"}),!O&&(0,e.jsx)("div",{style:{marginBottom:12,padding:"7px 10px",background:pe+"0C",border:"1px solid "+pe+"33",borderRadius:5,fontFamily:D,fontSize:9,color:pe},children:"Locking periods requires the controller role on this entity (backend enforces)."}),(0,e.jsxs)("div",{style:{background:ln,border:"1px solid "+Ft+"33",borderRadius:8,padding:14,marginBottom:14},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Ft,letterSpacing:".12em",marginBottom:8},children:"CLOSE PERIOD · FX REVALUATION + YEAR-END CLOSE + LOCK"}),(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"flex-end",flexWrap:"wrap"},children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Lt,letterSpacing:".1em",marginBottom:4},children:"PERIOD (YYYY-MM)"}),(0,e.jsx)("input",{type:"month",value:y,onChange:function(z){k(z.target.value),j(null),w(null)},style:{background:"#05080D",border:"1px solid "+Ke,borderRadius:5,padding:"6px 9px",color:xn,fontFamily:D,fontSize:10,outline:"none"}})]}),(0,e.jsx)("button",{onClick:ee,disabled:!O||!U||E,style:{padding:"7px 14px",background:O&&U?Ft+"12":Ut+"10",border:"1px solid "+(O&&U?Ft:Ut)+"44",borderRadius:5,cursor:O&&U?"pointer":"default",fontFamily:D,fontSize:9,color:O&&U?Ft:Ut,fontWeight:700,letterSpacing:".06em"}
423,children:E&&!A?"◌ PREVIEWING…":"CLOSE PERIOD"})]}),(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Lt,marginTop:8},children:"Runs an FX revaluation at the period end, posts the year-end closing journal for December periods (P&L → 3100 retained earnings), then locks the period — one atomic transaction. A dry-run preview is shown first."}),_&&(0,e.jsx)("div",{style:{marginTop:10,padding:"8px 11px",background:(_.ok?bt:et)+"0C",border:"1px solid "+(_.ok?bt:et)+"33",borderRadius:6,fontFamily:D,fontSize:9,color:_.ok?bt:et},children:_.text})]}),A&&(0,e.jsx)("div",{style:{position:"fixed",inset:0,zIndex:600,background:"rgba(2,4,10,0.8)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:function(){j(null)},children:(0,e.jsxs)("div",{onClick:function(z){z.stopPropagation()},style:{width:480,maxHeight:"80vh",overflow:"auto",background:ln,border:"1px solid "+Ke,borderRadius:8,padding:20,boxShadow:"0 16px 60px rgba(0,0,0,0.8)"},children:[(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:10,fontWeight:700,color:Ft,letterSpacing:".12em",marginBottom:10},children:["◈ CLOSE ",A.period,A.year_end?" · YEAR END":""]}),(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:8,color:"#6A8098",letterSpacing:".1em",marginBottom:6},children:["FX REVALUATION —"," ",A.fx_revaluation&&A.fx_revaluation.status||"PROPOSED"]}),A.fx_revaluation&&(A.fx_revaluation.entries||[]).length>0?(0,e.jsx)(eS,{title:"GAIN "+(A.fx_revaluation.total_gain||"0.00")+" · LOSS "+(A.fx_revaluation.total_loss||"0.00"),entries:A.fx_revaluation.entries}):(0,e.jsx)("div",{style:{fontFamily:D,fontSize:9,color:Ut,marginBottom:10},children:"No FX revaluation needed"}),A.year_end&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:"#6A8098",letterSpacing:".1em",marginBottom:6},children:"YEAR-END CLOSING JOURNAL"}),A.closing_journal?(0,e.jsx)(eS,{title:"NET INCOME → RETAINED EARNINGS "+(A.closing_journal.net_income||""),entries:A.closing_journal.entries}):(0,e.jsx)("div",{style:{fontFamily:D,fontSize:9,color:Ut,marginBottom:10},children:"No P&L balances to close"})]}),(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:9,color:et,marginBottom:12},children:["Executing posts the journals above and locks"," ",A.period," permanently."]}),(0,e.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[(0,e.jsx)("button",{onClick:function(){j(null)},disabled:E,style:{padding:"7px 14px",background:"transparent",border:"1px solid "+Ke,borderRadius:5,cursor:"pointer",fontFamily:D,fontSize:9,color:"#7A90A8"},children:"CANCEL"}),(0,e.jsx)("button",{onClick:N,disabled:E,style:{padding:"7px 16px",background:et+"18",border:"1px solid "+et+"55",borderRadius:5,cursor:"pointer",fontFamily:D,fontSize:9,color:et,fontWeight:700},children:E?"◌ CLOSING…":"CONFIRM CLOSE"})]})]})}),(0,e.jsxs)("div",{style:{background:ln,border:"1px solid "+Ke,borderRadius:8,padding:14,marginBottom:14},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"flex-end",flexWrap:"wrap"},children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Lt,letterSpacing:".1em",marginBottom:4},children:"PERIOD (YYYY-MM)"}),(0,e.jsx)("input",{type:"month",value:l,onChange:function(z){s(z.target.value),g(!1)},style:{background:"#05080D",border:"1px solid "+Ke,borderRadius:5,padding:"6px 9px",color:xn,fontFamily:D,fontSize:10,outline:"none"}})]}),(0,e.jsxs)("div",{style:{flex:1,minWidth:160},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Lt,letterSpacing:".1em",marginBottom:4},children:"NOTES"}),(0,e.jsx)("input",{value:c,onChange:function(z){d(z.target.value)},placeholder:"Close notes (optional)…",style:{width:"100%",background:"#05080D",border:"1px solid "+Ke,borderRadius:5,padding:"6px 9px",color:xn,fontFamily:D,fontSize:10,outline:"none",boxSizing:"border-box"}})]}),p?(0,e.jsxs)("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[(0,e.jsxs)("span",{style:{fontFamily:D,fontSize:9,color:et},children:["Lock ",l," permanently?"]}),(0,e.jsx)("button",{onClick:V,disabled:f,style:{padding:"7px 12px",background:et+"18",border:"1px solid "+et+"55",borderRadius:5,cursor:"pointer",fontFamily:D,fontSize:9,color:et,fontWeight:700},children:f?"◌…":"CONFIRM"}),(0,e.jsx)("button",{onClick:function(){g(!1)},disabled:f,style:{padding:"7px 10px",background:"transparent",border:"1px solid "+Ke,borderRadius:5,cursor:"pointer",fontFamily:D,fontSize:9,color:cn},children:"CANCEL"})]}):(0,e.jsx)("button",{onClick:function(){g(!0),v(null)},disabled:!O||!M||f,style:{padding:"7px 14px",background:O&&M?et+"12":Ut+"10",border:"1px solid "+(O&&M?et:Ut)+"44",borderRadius:5,cursor:O&&M?"pointer":"default",fontFamily:D,fontSize:9,color:O&&M?et:Ut,fontWeight:700,letterSpacing:".06em"},children:"LOCK PERIOD"})]}),(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Lt,marginTop:8},children:"A locked period rejects all new journal postings dated inside it. Locking is one-way in L1 (no unlock endpoint)."})]}),x&&(0,e.jsx)("div",{style:{marginBottom:12,padding:"8px 11px",background:(x.ok?bt:et)+"0C",border:"1px solid "+(x.ok?bt:et)+"33",borderRadius:6,fontFamily:D,fontSize:9,color:x.ok?bt:et},children:x.text}),(0,e.jsxs)("div",{style:{background:ln,border:"1px solid "+Ke,borderRadius:8,padding:14},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Lt,letterSpacing:".1em",marginBottom:8},children:"LOCKED PERIODS · RECORDED FROM THIS CLIENT"}),(r||[]).length===0?(0,e.jsx)("div",{style:{fontFamily:D,fontSize:9,color:Ut}
423,children:"No locks recorded here yet — the backend list endpoint lands in a later phase"}):(0,e.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:r.map(function(z){return(0,e.jsxs)("span",{style:{fontFamily:D,fontSize:9,color:et,border:"1px solid "+et+"44",background:et+"10",borderRadius:4,padding:"3px 8px",letterSpacing:".06em"},children:["◆ ",z]},z)})})]})]})})}var bp={background:"#05080D",border:"1px solid "+Ke,borderRadius:5,padding:"6px 9px",color:xn,fontFamily:D,fontSize:10,outline:"none",boxSizing:"border-box"},Xu={fontFamily:D,fontSize:8,color:Lt,letterSpacing:".1em",marginBottom:4,display:"block"},td={fontFamily:D,fontSize:8,color:Lt,letterSpacing:".1em",textAlign:"left",padding:"4px 8px",borderBottom:"1px solid "+Ke},Sp=Object.assign({},td,{textAlign:"right"}),nd={fontFamily:D,fontSize:10,color:xn,padding:"3px 8px",borderBottom:"1px solid #0D1117"},Q0=Object.assign({},nd,{textAlign:"right"});function zh(t){return(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Lt,letterSpacing:".12em",marginBottom:8},children:t})}function Mh({msg:t}){return t?(0,e.jsx)("div",{style:{marginTop:10,padding:"7px 10px",background:(t.ok?bt:et)+"0C",border:"1px solid "+(t.ok?bt:et)+"33",borderRadius:5,fontFamily:D,fontSize:9,color:t.ok?bt:et},children:t.text}):null}function g9({entities:t,onRefresh:n}){const[r,o]=(0,i.useState)(""),[a,l]=(0,i.useState)(""),[s,c]=(0,i.useState)(""),[d,p]=(0,i.useState)(""),[g,f]=(0,i.useState)(""),[h,x]=(0,i.useState)("TRANSFER"),[v,y]=(0,i.useState)(!1),[k,A]=(0,i.useState)(null),[j,E]=(0,i.useState)([]),[C,_]=(0,i.useState)(null),[w,O]=(0,i.useState)(null),[M,U]=(0,i.useState)(null),[ee,N]=(0,i.useState)(null),V=(t||[]).map(function(X){return X.id}).join(","),z=(0,i.useCallback)(function(X){var de=(t||[]).filter(function(We){return We.id===X})[0];return de&&de.name||String(X||"").slice(0,8)+"…"},[t]),oe=(0,i.useCallback)(function(){V&&dn.intercompanyLoans(V.split(",")).then(function(X){X&&X.error?_({ok:!1,text:X.error}):E(X&&X.loans||[])}).catch(function(X){_({ok:!1,text:X&&X.message||"Network error"})})},[V]),P=(0,i.useCallback)(function(){V&&dn.intercompanyMatrix(V.split(",")).then(function(X){X&&X.error?N({ok:!1,text:X.error}):U(X)}).catch(function(X){N({ok:!1,text:X&&X.message||"Network error"})})},[V]);(0,i.useEffect)(function(){const X=setTimeout(function(){oe(),P()}
423,0);return function(){clearTimeout(X)}},[oe,P]);const W=r&&a&&r!==a&&/^\d+(\.\d{1,2})?$/.test(s.trim())&&parseFloat(s)>0&&!v;function R(){W&&(y(!0),A(null),dn.intercompanyTransfer({from_entity_id:r,to_entity_id:a,amount:s.trim(),currency:d.trim()?d.trim().toUpperCase():null,memo:g.trim(),link_type:h}).then(function(X){if(y(!1),X&&X.error){A({ok:!1,text:X.error});return}A({ok:!0,text:"POSTED — "+h.toLowerCase()+" "+X.amount+" "+X.currency+" ("+z(r)+" → "+z(a)+"), two mirrored journals"}),c(""),f(""),P(),n&&n()}).catch(function(X){y(!1),A({ok:!1,text:X&&X.message||"Network error"})}))}function ae(X){w||(O(X),_(null),dn.accrueLoanInterest(X,null).then(function(de){if(O(null),de&&de.error){_({ok:!1,text:de.error});return}_({ok:!0,text:de.duplicate?"Already accrued for "+(de.period||"this period"):"ACCRUED "+de.interest+" "+(de.currency||"")+" ("+de.days+"d ACT/365, "+de.period+")"}),P(),n&&n()}).catch(function(de){O(null),_({ok:!1,text:de&&de.message||"Network error"})}))}const q=IO(M);function ge(X,de,We){return(0,e.jsxs)("select",{value:X,onChange:function(te){de(te.target.value)},style:Object.assign({},bp,{minWidth:140}),children:[(0,e.jsx)("option",{value:"",children:"— select —"}),(t||[]).map(function(te){return(0,e.jsxs)("option",{value:te.id,disabled:te.id===We,children:[te.name," (",te.functional_currency||"?",")"]},te.id)})]})}return(0,e.jsx)("div",{style:{flex:1,overflow:"auto",padding:16},children:(0,e.jsxs)("div",{style:{maxWidth:860,margin:"0 auto"},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:10,fontWeight:700,color:pe,letterSpacing:".12em",marginBottom:14},children:"◈ INTERCOMPANY"}),(0,e.jsxs)("div",{style:{background:ln,border:"1px solid "+Ke,borderRadius:8,padding:14,marginBottom:14},children:[zh("POST TRANSFER / CHARGE · MIRRORED JOURNALS · BOOKKEEPER+ ON BOTH ENTITIES"),(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"flex-end",flexWrap:"wrap"},children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{style:Xu,children:"FROM"}),ge(r,o,a)]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{style:Xu,children:"TO"}),ge(a,l,r)]}),(0,e.jsxs)("div",{style:{width:110},children:[(0,e.jsx)("span",{style:Xu,children:"AMOUNT"}),(0,e.jsx)("input",{value:s,onChange:function(X){c(X.target.value)},placeholder:"0.00",style:Object.assign({},bp,{width:"100%"})})]}),(0,e.jsxs)("div",{style:{width:70},children:[(0,e.jsx)("span",{style:Xu,children:"CCY"}),(0,e.jsx)("input",{value:d,maxLength:3,onChange:function(X){p(X.target.value.toUpperCase())},placeholder:"auto",style:Object.assign({},bp,{width:"100%"})})]}),(0,e.jsxs)("div",{style:{flex:1,minWidth:140},children:[(0,e.jsx)("span",{style:Xu,children:"MEMO"}),(0,e.jsx)("input",{value:g,onChange:function(X){f(X.target.value)},placeholder:"Optional memo…",style:Object.assign({},bp,{width:"100%"})})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{style:Xu,children:"TYPE"}),(0,e.jsxs)("select",{value:h,onChange:function(X){x(X.target.value)},style:bp,children:[(0,e.jsx)("option",{value:"TRANSFER",children:"TRANSFER (cash)"}),(0,e.jsx)("option",{value:"CHARGE",children:"CHARGE (recharge)"})]})]}),(0,e.jsx)("button",{onClick:R,disabled:!W,style:{padding:"7px 14px",background:W?pe+"14":Ut+"10",border:"1px solid "+(W?pe:Ut)+"44",borderRadius:5,cursor:W?"pointer":"default",fontFamily:D,fontSize:9,color:W?pe:Ut,fontWeight:700,letterSpacing:".06em"},children:v?"◌ POSTING…":"POST"})]}),(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Lt,marginTop:8},children:"TRANSFER moves cash (1800 due-from / 2800 due-to vs 1000); CHARGE books a non-cash recharge (4810 income on the from entity, expense on the to entity). Both legs post atomically."}),(0,e.jsx)(Mh,{msg:k})]}),(0,e.jsxs)("div",{style:{background:ln,border:"1px solid "+Ke,borderRadius:8,padding:14,marginBottom:14},children:[zh("INTERCOMPANY LOANS · ACT/365 SIMPLE ACCRUAL"),j.length===0?(0,e.jsx)("div",{style:{fontFamily:D,fontSize:9,color:Ut},children:"No intercompany loans visible — create one via the API or a future loan form"}):(0,e.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse"},children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{style:td,children:"LENDER"}),(0,e.jsx)("th",{style:td,children:"BORROWER"}),(0,e.jsx)("th",{style:Sp,children:"PRINCIPAL"}),(0,e.jsx)("th",{style:Sp,children:"RATE"}),(0,e.jsx)("th",{style:td,children:"START"}),(0,e.jsx)("th",{style:td,children:"STATUS"}),(0,e.jsx)("th",{style:td})]})}),(0,e.jsx)("tbody",{children:j.map(function(X){return(0,e.jsxs)("tr",{children:[(0,e.jsx)("td",{style:nd,children:z(X.lender_entity_id)}),(0,e.jsx)("td",{style:nd,children:z(X.borrower_entity_id)}),(0,e.jsxs)("td",{style:Q0,children:[wn(X.principal)," ",X.currency||""]}),(0,e.jsx)("td",{style:Q0,children:X.annual_rate}),(0,e.jsx)("td",{style:nd,children:X.start_date}),(0,e.jsx)("td",{style:Object.assign({},nd,{color:X.status==="ACTIVE"?bt:cn,fontSize:8}),children:X.status}),(0,e.jsx)("td",{style:nd,children:X.status==="ACTIVE"&&(0,e.jsx)("button",{onClick:function(){ae(X.loan_id)},disabled:!!w,style:{padding:"3px 9px",background:Ft+"12",border:"1px solid "+Ft+"44",borderRadius:4,cursor:w?"default":"pointer",fontFamily:D,fontSize:8,color:Ft,letterSpacing:".06em"},children:w===X.loan_id?"◌…":"ACCRUE INTEREST"})})]},X.loan_id)})})]}),(0,e.jsx)(Mh,{msg:C})]}),(0,e.jsxs)("div",{style:{background:ln,border:"1px solid "+Ke,borderRadius:8,padding:14},children:[zh("DUE-TO / DUE-FROM MATRIX · MISMATCHES HIGHLIGHTED · BASE AMOUNTS"),q.length===0?(0,e.jsx)("div",{style:{fontFamily:D,fontSize:9,color:Ut},children:"No intercompany balances between the visible entities"}):(0,e.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse"},children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{style:td,children:"ENTITY (DUE FROM)"}),(0,e.jsx)("th",{style:td,children:"COUNTERPARTY (DUE TO)"}),(0,e.jsx)("th",{style:Sp,children:"DUE FROM"}),(0,e.jsx)("th",{style:Sp,children:"COUNTERPARTY DUE TO"}),(0,e.jsx)("th",{style:Sp,children:"DIFFERENCE"})]})}),(0,e.jsx)("tbody",{children:q.map(function(X){var de=X.mismatch,We=de?Object.assign({},nd,{color:et}):nd,te=de?Object.assign({},Q0,{color:et,fontWeight:700}):Q0;return(0,e.jsxs)("tr",{style:de?{background:et+"08"}:void 0,children:[(0,e.jsx)("td",{style:We,children:X.from}),(0,e.jsxs)("td",{style:We,children:[X.to,X.currencyDiffers&&(0,e.jsx)("span",{title:"Functional currencies differ — base amounts are not directly comparable",style:{marginLeft:6,fontFamily:D,fontSize:8,color:pe},children:"⚠ CCY"})]}),(0,e.jsx)("td",{style:te,children:X.dueFrom}),(0,e.jsx)("td",{style:te,children:X.dueTo}),(0,e.jsx)("td",{style:te,children:de?wn(X.difference):"0.00"})]},X.key)})})]}),(0,e.jsx)(Mh,{msg:ee})]})]})})}
423var Ep={fontFamily:D,fontSize:10,color:xn,background:"transparent",border:"1px solid "+Ke,borderRadius:4,padding:"6px 8px",outline:"none",width:"100%",boxSizing:"border-box"},Z0={fontFamily:D,fontSize:8,color:Lt,letterSpacing:".08em",display:"block",marginBottom:3};function m9({type:t}){var n=t==="COLD"||t==="HARDWARE"?Ft:t==="EXCHANGE"?pe:bt;return(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:n,border:"1px solid "+n+"55",borderRadius:3,padding:"1px 4px",letterSpacing:".06em"},children:t})}function h9({entityId:t,wallets:n,canWrite:r,selectedWalletId:o,onSelectWallet:a,onChanged:l}){var[s,c]=(0,i.useState)(!1),[d,p]=(0,i.useState)({label:"",chain:"ethereum",address:"",wallet_type:"HOT",exchange_name:""}),[g,f]=(0,i.useState)(!1),[h,x]=(0,i.useState)(null);function v(k,A){p(function(j){var E=Object.assign({},j);return E[k]=A,E})}function y(){if(!d.label.trim()||!d.chain.trim()){x("Label and chain are required");return}f(!0),x(null),js.createWallet(t,{label:d.label.trim(),chain:d.chain.trim(),address:d.address.trim()||null,wallet_type:d.wallet_type,exchange_name:d.exchange_name.trim()||null}).then(function(k){if(f(!1),k&&k.error){x(k.error);return}c(!1),p({label:"",chain:"ethereum",address:"",wallet_type:"HOT",exchange_name:""}),l&&l()}).catch(function(){f(!1),x("Wallet creation failed")})}return(0,e.jsxs)("div",{style:{background:ln,border:"1px solid "+Ke,borderRadius:8,padding:14},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:Ft,letterSpacing:".1em"},children:"WALLETS"}),r&&(0,e.jsx)("button",{onClick:function(){c(!s)},style:{fontFamily:D,fontSize:9,color:pe,background:"transparent",border:"1px solid "+pe+"55",borderRadius:4,padding:"3px 8px",cursor:"pointer",letterSpacing:".06em"},children:s?"CANCEL":"+ NEW WALLET"})]}),s&&(0,e.jsxs)("div",{style:{border:"1px solid "+Ke,borderRadius:6,padding:10,marginBottom:10,display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:Z0,children:"LABEL *"}),(0,e.jsx)("input",{style:Ep,value:d.label,onChange:function(k){v("label",k.target.value)},placeholder:"Treasury Cold 1"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:Z0,children:"CHAIN *"}),(0,e.jsx)("input",{style:Ep,value:d.chain,onChange:function(k){v("chain",k.target.value)},placeholder:"ethereum / bitcoin / solana"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:Z0,children:"TYPE"}),(0,e.jsx)("select",{style:Ep,value:d.wallet_type,onChange:function(k){v("wallet_type",k.target.value)},children:qR.map(function(k){return(0,e.jsx)("option",{value:k,children:k},k)})})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:Z0,children:d.wallet_type==="EXCHANGE"?"EXCHANGE NAME":"ADDRESS"}),d.wallet_type==="EXCHANGE"?(0,e.jsx)("input",{style:Ep,value:d.exchange_name,onChange:function(k){v("exchange_name",k.target.value)},placeholder:"Coinbase Prime"}):(0,e.jsx)("input",{style:Ep,value:d.address,onChange:function(k){v("address",k.target.value)},placeholder:"0x… (optional)"})]}),(0,e.jsxs)("div",{style:{gridColumn:"1 / -1",display:"flex",gap:8},children:[(0,e.jsx)("button",{onClick:y,disabled:g,style:{fontFamily:D,fontSize:9,color:bt,background:"transparent",border:"1px solid "+bt+"55",borderRadius:4,padding:"5px 12px",cursor:g?"wait":"pointer",letterSpacing:".06em"},children:g?"CREATING…":"CREATE WALLET"}),h&&(0,e.jsx)("span",{style:{fontFamily:D,fontSize:9,color:et,alignSelf:"center"},children:h})]})]}),(n||[]).length===0?(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:10,color:cn,padding:8},children:["No wallets yet",r?" — create one to start booking.":"."]}):(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:(n||[]).map(function(k){var A=o===k.id;return(0,e.jsxs)("div",{onClick:function(){a&&a(A?null:k.id)},style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",borderRadius:4,cursor:"pointer",border:"1px solid "+(A?Ft+"77":"transparent"),background:A?Ft+"0d":"transparent"}
423,children:[(0,e.jsx)("span",{style:{fontFamily:D,fontSize:10,color:xn,fontWeight:700,flex:1},children:k.label}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:Lt},children:k.chain}),k.exchange_name&&(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:"#7A90A8"},children:k.exchange_name}),(0,e.jsx)(m9,{type:k.wallet_type})]},k.id)})})]})}var qu={fontFamily:D,fontSize:8,color:Lt,letterSpacing:".08em",textAlign:"right",padding:"6px 8px",borderBottom:"1px solid "+Ke,whiteSpace:"nowrap"},$u={fontFamily:D,fontSize:10,color:xn,textAlign:"right",padding:"6px 8px",borderBottom:"1px solid "+Ke+"55",whiteSpace:"nowrap"};function y9({provenance:t}){var n=YR(t),r=n.tone==="good"?bt:n.tone==="warn"?pe:n.tone==="info"?Ft:cn;return(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:r,border:"1px solid "+r+"55",borderRadius:3,padding:"1px 4px",marginLeft:6,letterSpacing:".06em"},children:n.label})}function x9({holdings:t}){var n=t||[];return(0,e.jsxs)("div",{style:{background:ln,border:"1px solid "+Ke,borderRadius:8,padding:14},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Ft,letterSpacing:".1em",marginBottom:8},children:"HOLDINGS"}),n.length===0?(0,e.jsx)("div",{style:{fontFamily:D,fontSize:10,color:cn,padding:8},children:"No holdings — record a BUY or TRANSFER_IN to open lots."}):(0,e.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse"},children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{style:{...qu,textAlign:"left"},children:"TOKEN"}),(0,e.jsx)("th",{style:qu,children:"AMOUNT"}),(0,e.jsx)("th",{style:qu,children:"COST BASIS"}),(0,e.jsx)("th",{style:qu,children:"PRICE"}),(0,e.jsx)("th",{style:qu,children:"VALUE"}),(0,e.jsx)("th",{style:qu,children:"UNREALIZED P&L"})]})}),(0,e.jsx)("tbody",{children:n.map(function(r){var o=parseFloat(r.unrealized_pnl_usd||"0"),a=!!r.price_usd,l=a?o>=0?bt:et:cn;return(0,e.jsxs)("tr",{children:[(0,e.jsx)("td",{style:{...$u,textAlign:"left",fontWeight:700},children:r.token}),(0,e.jsx)("td",{style:$u,children:oc(r.amount)}),(0,e.jsxs)("td",{style:$u,children:["$",Fi(r.cost_basis_usd)]}),(0,e.jsxs)("td",{style:$u,children:[a?"$"+Fi(r.price_usd):"—",(0,e.jsx)(y9,{provenance:r.price_provenance})]}),(0,e.jsx)("td",{style:$u,children:a?"$"+Fi(r.value_usd):"—"}),(0,e.jsx)("td",{style:{...$u,color:l,fontWeight:700},children:a?(o>=0?"+":"")+"$"+Fi(r.unrealized_pnl_usd):"—"})]},r.token)})})]})]})}var vl={fontFamily:D,fontSize:10,color:xn,background:"transparent",border:"1px solid "+Ke,borderRadius:4,padding:"6px 8px",outline:"none",width:"100%",boxSizing:"border-box"},bl={fontFamily:D,fontSize:8,color:Lt,letterSpacing:".08em",display:"block",marginBottom:3},tS={tx_type:"BUY",token_in:"",amount_in:"",token_out:"",amount_out:"",price_usd:"",gas_fee:"",gas_token:"ETH",gas_usd:"",protocol:"",tx_hash:""};function v9({entityId:t,wallets:n,onRecorded:r}){var[o,a]=(0,i.useState)(tS),[l,s]=(0,i.useState)(""),[c,d]=(0,i.useState)(!1),[p,g]=(0,i.useState)(null),[f,h]=(0,i.useState)(null),x=KR(o.tx_type),v=o.tx_type.indexOf("TRANSFER")===0;function y(A,j){a(function(E){var C=Object.assign({},E);return C[A]=j,C})}function k(){if(g(null),h(null),!l){g("Select a wallet");return}if(x.in&&(!o.token_in.trim()||!o.amount_in.trim())){g("token_in and amount_in are required for "+o.tx_type);return}if(x.out&&(!o.token_out.trim()||!o.amount_out.trim())){g("token_out and amount_out are required for "+o.tx_type);return}if(!v&&!o.price_usd.trim()){g("price_usd is required for "+o.tx_type);return}var A={wallet_id:l,tx_type:o.tx_type,token_in:x.in?o.token_in.trim().toUpperCase():null,amount_in:x.in?o.amount_in.trim():0,token_out:x.out?o.token_out.trim().toUpperCase():null,amount_out:x.out?o.amount_out.trim():0,price_usd:o.price_usd.trim()||0,gas_fee:o.gas_fee.trim()||0,gas_token:o.gas_token.trim().toUpperCase()||"ETH",gas_usd:o.gas_usd.trim()||null,protocol:o.protocol.trim()||null,tx_hash:o.tx_hash.trim()||null};d(!0),js.recordTransaction(t,A).then(function(j){if(d(!1),j&&j.error){g(j.error);return}var E="Booked "+j.tx_type+" — value $"+(j.value_usd||"0");j.realized_gain_usd!==void 0&&(E+=" · realized $"+j.realized_gain_usd),j.warning&&(E+=" · WARNING: "+j.warning),h(E),a(Object.assign({},tS,{tx_type:o.tx_type})),r&&r()}).catch(function(){d(!1),g("Transaction failed")})}return(0,e.jsxs)("div",{style:{background:ln,border:"1px solid "+Ke,borderRadius:8,padding:14},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:pe,letterSpacing:".1em",marginBottom:10},children:"RECORD TRANSACTION"}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:8},children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:bl,children:"WALLET *"}
423),(0,e.jsxs)("select",{style:vl,value:l,onChange:function(A){s(A.target.value)},children:[(0,e.jsx)("option",{value:"",children:"— select —"}),(n||[]).map(function(A){return(0,e.jsxs)("option",{value:A.id,children:[A.label," (",A.chain,")"]},A.id)})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:bl,children:"TYPE"}),(0,e.jsx)("select",{style:vl,value:o.tx_type,onChange:function(A){y("tx_type",A.target.value)},children:XR.map(function(A){return(0,e.jsx)("option",{value:A,children:A},A)})})]}),!v&&(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:bl,children:o.tx_type==="SWAP"?"PRICE USD (IN-LEG TOKEN) *":"PRICE USD *"}),(0,e.jsx)("input",{style:vl,value:o.price_usd,onChange:function(A){y("price_usd",A.target.value)},placeholder:"3200.00"})]}),x.in&&(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:bl,children:o.tx_type==="SWAP"?"TOKEN IN (ACQUIRED) *":"TOKEN *"}),(0,e.jsx)("input",{style:vl,value:o.token_in,onChange:function(A){y("token_in",A.target.value)},placeholder:"ETH"})]}),x.in&&(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:bl,children:"AMOUNT IN *"}),(0,e.jsx)("input",{style:vl,value:o.amount_in,onChange:function(A){y("amount_in",A.target.value)},placeholder:"1.5"})]}),x.out&&(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:bl,children:o.tx_type==="SWAP"?"TOKEN OUT (DISPOSED) *":"TOKEN *"}),(0,e.jsx)("input",{style:vl,value:o.token_out,onChange:function(A){y("token_out",A.target.value)},placeholder:"USDC"})]}),x.out&&(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:bl,children:"AMOUNT OUT *"}),(0,e.jsx)("input",{style:vl,value:o.amount_out,onChange:function(A){y("amount_out",A.target.value)},placeholder:"1000"})]}),!v&&(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:bl,children:"GAS FEE (TOKEN UNITS)"}),(0,e.jsx)("input",{style:vl,value:o.gas_fee,onChange:function(A){y("gas_fee",A.target.value)},placeholder:"0.002"})]}),!v&&(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:bl,children:"GAS TOKEN"}),(0,e.jsx)("input",{style:vl,value:o.gas_token,onChange:function(A){y("gas_token",A.target.value)},placeholder:"ETH"})]}),!v&&(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:bl,children:"GAS USD (OPTIONAL OVERRIDE)"}),(0,e.jsx)("input",{style:vl,value:o.gas_usd,onChange:function(A){y("gas_usd",A.target.value)},placeholder:"6.40"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:bl,children:"PROTOCOL"}),(0,e.jsx)("input",{style:vl,value:o.protocol,onChange:function(A){y("protocol",A.target.value)},placeholder:"uniswap / lido / …"})]}),(0,e.jsxs)("div",{style:{gridColumn:"span 2"},children:[(0,e.jsx)("label",{style:bl,children:"TX HASH"}),(0,e.jsx)("input",{style:vl,value:o.tx_hash,onChange:function(A){y("tx_hash",A.target.value)},placeholder:"0x… (dedupes per wallet)"})]})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:10,marginTop:10,alignItems:"center"},children:[(0,e.jsx)("button",{onClick:k,disabled:c,style:{fontFamily:D,fontSize:9,color:bt,background:"transparent",border:"1px solid "+bt+"55",borderRadius:4,padding:"6px 14px",cursor:c?"wait":"pointer",letterSpacing:".06em"},children:c?"BOOKING…":"BOOK "+o.tx_type}),p&&(0,e.jsx)("span",{style:{fontFamily:D,fontSize:9,color:et},children:p}),f&&(0,e.jsx)("span",{style:{fontFamily:D,fontSize:9,color:Ft},children:f})]})]})}function b9(t){return t==="BUY"||t==="TRANSFER_IN"||t==="CLAIM"||t==="AIRDROP"?bt:t==="SELL"||t==="TRANSFER_OUT"?et:Ft}function S9(t){var n=[];return t.token_out&&t.amount_out&&n.push("-"+oc(t.amount_out)+" "+t.token_out),t.token_in&&t.amount_in&&n.push("+"+oc(t.amount_in)+" "+t.token_in),n.join(" → ")||"—"}function E9({transactions:t,title:n}){var r=t||[];return(0,e.jsxs)("div",{style:{background:ln,border:"1px solid "+Ke,borderRadius:8,padding:14},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Ft,letterSpacing:".1em",marginBottom:8},children:n||"TRANSACTIONS"}),r.length===0?(0,e.jsx)("div",{style:{fontFamily:D,fontSize:10,color:cn,padding:8},children:"No transactions recorded."}):(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:r.map(function(o){var a=o.realized_gain_usd!==null&&o.realized_gain_usd!==void 0?parseFloat(o.realized_gain_usd):null;return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"6px 8px",borderBottom:"1px solid "+Ke+"44"},children:[(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:b9(o.tx_type),fontWeight:700,width:88,letterSpacing:".05em"},children:o.tx_type}
423),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:10,color:xn,flex:1},children:S9(o)}),o.value_usd&&(0,e.jsxs)("span",{style:{fontFamily:D,fontSize:10,color:"#C9D1D9"},children:["$",Fi(o.value_usd)]}),a!==null&&(0,e.jsx)("span",{style:{fontFamily:D,fontSize:9,fontWeight:700,color:a>=0?bt:et},children:(a>=0?"+":"")+"$"+Fi(o.realized_gain_usd)}),o.journal_id&&(0,e.jsx)("span",{title:"Journal "+o.journal_id,style:{fontFamily:D,fontSize:8,color:"#6A8098"},children:"JRNL"}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:cn},children:(o.occurred_at||"").slice(0,10)})]},o.id)})})]})}var Ju={fontFamily:D,fontSize:10,color:xn,background:"transparent",border:"1px solid "+Ke,borderRadius:4,padding:"5px 7px",outline:"none",width:"100%",boxSizing:"border-box"},Qu={fontFamily:D,fontSize:8,color:Lt,letterSpacing:".08em",display:"block",marginBottom:3};function k9({entityId:t,wallets:n,staking:r,canWrite:o,onChanged:a}){var[l,s]=(0,i.useState)(!1),[c,d]=(0,i.useState)({wallet_id:"",token:"",protocol:"",amount:"",apy:"",price_usd:""}),[p,g]=(0,i.useState)(!1),[f,h]=(0,i.useState)(null),x=r&&r.detail||[];function v(k,A){d(function(j){var E=Object.assign({},j);return E[k]=A,E})}function y(){if(h(null),!c.wallet_id||!c.token.trim()||!c.protocol.trim()||!c.amount.trim()){h("Wallet, token, protocol and amount are required");return}g(!0),js.createStake(t,{wallet_id:c.wallet_id,token:c.token.trim().toUpperCase(),protocol:c.protocol.trim(),amount:c.amount.trim(),apy:c.apy.trim()||0,price_usd:c.price_usd.trim()||0}).then(function(k){if(g(!1),k&&k.error){h(k.error);return}s(!1),d({wallet_id:"",token:"",protocol:"",amount:"",apy:"",price_usd:""}),a&&a()}).catch(function(){g(!1),h("Stake creation failed")})}return(0,e.jsxs)("div",{style:{background:ln,border:"1px solid "+Ke,borderRadius:8,padding:14},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[(0,e.jsxs)("span",{style:{fontFamily:D,fontSize:8,color:Ft,letterSpacing:".1em"},children:["STAKING"," ",r&&(0,e.jsxs)("span",{style:{color:"#6A8098"},children:["· $",Fi(r.total_staked_usd)," STAKED · $",Fi(r.rewards_unclaimed_usd)," UNCLAIMED"]})]}),o&&(0,e.jsx)("button",{onClick:function(){s(!l)},style:{fontFamily:D,fontSize:9,color:pe,background:"transparent",border:"1px solid "+pe+"55",borderRadius:4,padding:"3px 8px",cursor:"pointer",letterSpacing:".06em"},children:l?"CANCEL":"+ NEW STAKE"})]}),l&&(0,e.jsxs)("div",{style:{border:"1px solid "+Ke,borderRadius:6,padding:10,marginBottom:10,display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:8},children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:Qu,children:"WALLET *"}),(0,e.jsxs)("select",{style:Ju,value:c.wallet_id,onChange:function(k){v("wallet_id",k.target.value)},children:[(0,e.jsx)("option",{value:"",children:"— select —"}),(n||[]).map(function(k){return(0,e.jsx)("option",{value:k.id,children:k.label},k.id)})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:Qu,children:"TOKEN *"}),(0,e.jsx)("input",{style:Ju,value:c.token,onChange:function(k){v("token",k.target.value)},placeholder:"SOL"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:Qu,children:"PROTOCOL *"}),(0,e.jsx)("input",{style:Ju,value:c.protocol,onChange:function(k){v("protocol",k.target.value)},placeholder:"lido / jito / native"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:Qu,children:"AMOUNT *"}),(0,e.jsx)("input",{style:Ju,value:c.amount,onChange:function(k){v("amount",k.target.value)},placeholder:"100"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:Qu,children:"APY %"}),(0,e.jsx)("input",{style:Ju,value:c.apy,onChange:function(k){v("apy",k.target.value)},placeholder:"7.25"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:Qu,children:"PRICE USD (BLANK = AUTO)"}),(0,e.jsx)("input",{style:Ju,value:c.price_usd,onChange:function(k){v("price_usd",k.target.value)},placeholder:"180.00"})]}),(0,e.jsxs)("div",{style:{gridColumn:"1 / -1",display:"flex",gap:8},children:[(0,e.jsx)("button",{onClick:y,disabled:p,style:{fontFamily:D,fontSize:9,color:bt,background:"transparent",border:"1px solid "+bt+"55",borderRadius:4,padding:"5px 12px",cursor:p?"wait":"pointer",letterSpacing:".06em"},children:p?"STAKING…":"OPEN STAKE"}),f&&(0,e.jsx)("span",{style:{fontFamily:D,fontSize:9,color:et,alignSelf:"center"},children:f})]})]}),x.length===0?(0,e.jsx)("div",{style:{fontFamily:D,fontSize:10,
423color:cn,padding:8},children:"No active staking positions."}):(0,e.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:x.map(function(k){return(0,e.jsxs)("div",{style:{border:"1px solid "+Ke,borderRadius:6,padding:10,minWidth:180,flex:"1 1 180px"},children:[(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:11,color:xn,fontWeight:700},children:[oc(k.amount_staked)," ",k.token]}),(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:9,color:Lt,marginTop:2},children:[k.protocol," · APY ",k.apy||"—","%"]}),(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:9,color:bt,marginTop:4},children:["$",Fi(k.value_usd)]}),parseFloat(k.rewards_unclaimed||"0")>0&&(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:8,color:pe,marginTop:2},children:[oc(k.rewards_unclaimed)," ",k.token," unclaimed"]})]},k.id)})})]})}var $c={fontFamily:D,fontSize:10,color:xn,background:"transparent",border:"1px solid "+Ke,borderRadius:4,padding:"5px 7px",outline:"none",width:"100%",boxSizing:"border-box"},Jc={fontFamily:D,fontSize:8,color:Lt,letterSpacing:".08em",display:"block",marginBottom:3},C9=["LEND","BORROW","LP","FARM"];function A9({entityId:t,wallets:n,defi:r,canWrite:o,onChanged:a}){var[l,s]=(0,i.useState)(!1),[c,d]=(0,i.useState)({wallet_id:"",protocol:"",position_type:"LEND",token_deposited:"",amount_deposited:"",token_borrowed:"",amount_borrowed:"",apy:""}),[p,g]=(0,i.useState)(!1),[f,h]=(0,i.useState)(null),x=r&&r.detail||[];function v(k,A){d(function(j){var E=Object.assign({},j);return E[k]=A,E})}function y(){if(h(null),!c.wallet_id||!c.protocol.trim()||!c.token_deposited.trim()||!c.amount_deposited.trim()){h("Wallet, protocol, token and amount are required");return}g(!0),js.createDefi(t,{wallet_id:c.wallet_id,protocol:c.protocol.trim(),position_type:c.position_type,token_deposited:c.token_deposited.trim().toUpperCase(),amount_deposited:c.amount_deposited.trim(),token_borrowed:c.token_borrowed.trim().toUpperCase()||null,amount_borrowed:c.amount_borrowed.trim()||null,apy:c.apy.trim()||0}).then(function(k){if(g(!1),k&&k.error){h(k.error);return}s(!1),d({wallet_id:"",protocol:"",position_type:"LEND",token_deposited:"",amount_deposited:"",token_borrowed:"",amount_borrowed:"",apy:""}),a&&a()}).catch(function(){g(!1),h("DeFi position creation failed")})}return(0,e.jsxs)("div",{style:{background:ln,border:"1px solid "+Ke,borderRadius:8,padding:14},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[(0,e.jsxs)("span",{style:{fontFamily:D,fontSize:8,color:To,letterSpacing:".1em"},children:["DEFI POSITIONS"," ",r&&(0,e.jsxs)("span",{style:{color:"#6A8098"},children:["· $",Fi(r.total_deposited_usd)," DEPOSITED"]})]}),o&&(0,e.jsx)("button",{onClick:function(){s(!l)},style:{fontFamily:D,fontSize:9,color:pe,background:"transparent",border:"1px solid "+pe+"55",borderRadius:4,padding:"3px 8px",cursor:"pointer",letterSpacing:".06em"},children:l?"CANCEL":"+ NEW POSITION"})]}),l&&(0,e.jsxs)("div",{style:{border:"1px solid "+Ke,borderRadius:6,padding:10,marginBottom:10,display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:8},children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:Jc,children:"WALLET *"}),(0,e.jsxs)("select",{style:$c,value:c.wallet_id,onChange:function(k){v("wallet_id",k.target.value)},children:[(0,e.jsx)("option",{value:"",children:"— select —"}),(n||[]).map(function(k){return(0,e.jsx)("option",{value:k.id,children:k.label},k.id)})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:Jc,children:"PROTOCOL *"}),(0,e.jsx)("input",{style:$c,value:c.protocol,onChange:function(k){v("protocol",k.target.value)},placeholder:"aave / uniswap"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:Jc,children:"TYPE"}
423),(0,e.jsx)("select",{style:$c,value:c.position_type,onChange:function(k){v("position_type",k.target.value)},children:C9.map(function(k){return(0,e.jsx)("option",{value:k,children:k},k)})})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:Jc,children:"APY %"}),(0,e.jsx)("input",{style:$c,value:c.apy,onChange:function(k){v("apy",k.target.value)},placeholder:"4.1"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:Jc,children:"TOKEN DEPOSITED *"}),(0,e.jsx)("input",{style:$c,value:c.token_deposited,onChange:function(k){v("token_deposited",k.target.value)},placeholder:"USDC"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:Jc,children:"AMOUNT DEPOSITED *"}),(0,e.jsx)("input",{style:$c,value:c.amount_deposited,onChange:function(k){v("amount_deposited",k.target.value)},placeholder:"10000"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:Jc,children:"TOKEN BORROWED"}),(0,e.jsx)("input",{style:$c,value:c.token_borrowed,onChange:function(k){v("token_borrowed",k.target.value)},placeholder:"—"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{style:Jc,children:"AMOUNT BORROWED"}),(0,e.jsx)("input",{style:$c,value:c.amount_borrowed,onChange:function(k){v("amount_borrowed",k.target.value)},placeholder:"—"})]}),(0,e.jsxs)("div",{style:{gridColumn:"1 / -1",display:"flex",gap:8},children:[(0,e.jsx)("button",{onClick:y,disabled:p,style:{fontFamily:D,fontSize:9,color:bt,background:"transparent",border:"1px solid "+bt+"55",borderRadius:4,padding:"5px 12px",cursor:p?"wait":"pointer",letterSpacing:".06em"},children:p?"OPENING…":"OPEN POSITION"}),f&&(0,e.jsx)("span",{style:{fontFamily:D,fontSize:9,color:et,alignSelf:"center"},children:f})]})]}),x.length===0?(0,e.jsx)("div",{style:{fontFamily:D,fontSize:10,color:cn,padding:8},children:"No active DeFi positions."}):(0,e.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:x.map(function(k){var A=k.health_factor?parseFloat(k.health_factor):null;return(0,e.jsxs)("div",{style:{border:"1px solid "+Ke,borderRadius:6,padding:10,minWidth:190,flex:"1 1 190px"},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:Ft,border:"1px solid "+Ft+"55",borderRadius:3,padding:"1px 4px"},children:k.position_type}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:9,color:Lt},children:k.protocol})]}),(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:11,color:xn,fontWeight:700,marginTop:4},children:[oc(k.amount_deposited)," ",k.token_deposited]}),k.token_borrowed&&(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:9,color:pe,marginTop:2},children:["borrowed ",oc(k.amount_borrowed)," ",k.token_borrowed]}),(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:9,color:bt,marginTop:4},children:["$",Fi(k.value_usd)," · APY ",k.apy||"—","%"]}),A!==null&&(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:8,color:A<1.2?et:A<1.6?pe:"#6A8098",marginTop:2},children:["health ",A.toFixed(2)]})]},k.id)})})]})}var kp={fontFamily:D,fontSize:8,color:Lt,letterSpacing:".08em",textAlign:"right",padding:"5px 8px",borderBottom:"1px solid "+Ke},Cp={fontFamily:D,fontSize:10,color:xn,textAlign:"right",padding:"5px 8px",borderBottom:"1px solid "+Ke+"55"};function j9(t){return t==="MATCH"?bt:t==="MISMATCH"?et:pe}function w9({entityId:t,wallets:n}){var[r,o]=(0,i.useState)(""),[a,l]=(0,i.useState)(""),[s,c]=(0,i.useState)(!1),[d,p]=(0,i.useState)(null),[g,f]=(0,i.useState)(null);function h(){if(p(null),f(null),!r){p("Select a wallet");return}var x=VR(a);if(x.length===0){p("Paste at least one 'TOKEN amount' line");return}c(!0),js.reconcile(t,r,x).then(function(v){if(c(!1),v&&v.error){p(v.error);return}f(v)}).catch(function(){c(!1),p("Reconciliation failed")})}return(0,e.jsxs)("div",{style:{background:ln,border:"1px solid "+Ke,borderRadius:8,padding:14},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Ft,letterSpacing:".1em",marginBottom:8},children:"WALLET RECONCILIATION"}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,marginBottom:8},children:[(0,e.jsxs)("select",{value:r,onChange:function(x){o(x.target.value)}
423,style:{fontFamily:D,fontSize:10,color:xn,background:"transparent",border:"1px solid "+Ke,borderRadius:4,padding:"6px 8px",minWidth:180},children:[(0,e.jsx)("option",{value:"",children:"— select wallet —"}),(n||[]).map(function(x){return(0,e.jsxs)("option",{value:x.id,children:[x.label," (",x.chain,")"]},x.id)})]}),(0,e.jsx)("button",{onClick:h,disabled:s,style:{fontFamily:D,fontSize:9,color:bt,background:"transparent",border:"1px solid "+bt+"55",borderRadius:4,padding:"5px 12px",cursor:s?"wait":"pointer",letterSpacing:".06em"},children:s?"DIFFING…":"RUN DIFF"}),d&&(0,e.jsx)("span",{style:{fontFamily:D,fontSize:9,color:et,alignSelf:"center"},children:d})]}),(0,e.jsx)("textarea",{value:a,onChange:function(x){l(x.target.value)},placeholder:`Paste reported balances, one per line:
424BTC 1.5
425ETH 10.25
426SOL 420`,rows:4,style:{fontFamily:D,fontSize:10,color:xn,background:"transparent",border:"1px solid "+Ke,borderRadius:4,padding:8,width:"100%",boxSizing:"border-box",resize:"vertical",outline:"none"}}),g&&(0,e.jsxs)("div",{style:{marginTop:10},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:9,color:g.reconciled?bt:pe,marginBottom:6,letterSpacing:".06em"},children:g.reconciled?"RECONCILED — all "+g.tokens+" tokens match":g.matched+"/"+g.tokens+" tokens match"}),(0,e.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse"},children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{style:{...kp,textAlign:"left"},children:"TOKEN"}),(0,e.jsx)("th",{style:kp,children:"LEDGER"}),(0,e.jsx)("th",{style:kp,children:"REPORTED"}),(0,e.jsx)("th",{style:kp,children:"DIFF"}),(0,e.jsx)("th",{style:{...kp,textAlign:"left"},children:"STATUS"})]})}),(0,e.jsx)("tbody",{children:(g.diffs||[]).map(function(x){return(0,e.jsxs)("tr",{children:[(0,e.jsx)("td",{style:{...Cp,textAlign:"left",fontWeight:700},children:x.token}),(0,e.jsx)("td",{style:Cp,children:x.ledger_amount!==null?oc(x.ledger_amount):"—"}),(0,e.jsx)("td",{style:Cp,children:x.reported_amount!==null?oc(x.reported_amount):"—"}),(0,e.jsx)("td",{style:{...Cp,color:x.diff==="0"?"#7A90A8":et},children:x.diff}),(0,e.jsx)("td",{style:{...Cp,textAlign:"left",fontSize:8,color:j9(x.status),letterSpacing:".05em"},children:x.status})]},x.token)})})]})]})]})}var T9={bookkeeper:1,approver:1,controller:1};function Zu({label:t,value:n,color:r}){return(0,e.jsxs)("div",{style:{background:ln,border:"1px solid "+Ke,borderRadius:8,padding:"10px 14px",flex:"1 1 140px",minWidth:130},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:8,color:Lt,letterSpacing:".1em",marginBottom:4},children:t}),(0,e.jsx)("div",{style:{fontFamily:D,fontSize:14,fontWeight:700,color:r||"#C9D1D9"},children:n})]})}function _9({entity:t,role:n}){var r=t&&t.id,o=!n||!!T9[n],[a,l]=(0,i.useState)(null),[s,c]=(0,i.useState)([]),[d,p]=(0,i.useState)([]),[g,f]=(0,i.useState)(null),[h,x]=(0,i.useState)(!1),[v,y]=(0,i.useState)(null),k=(0,i.useCallback)(function(){r&&(x(!0),y(null),Promise.all([js.portfolio(r),js.wallets(r),js.transactions(r,g,50)]).then(function(C){x(!1);var _=C[0],w=C[1],O=C[2];if(_&&_.error){y(_.error);return}l(_),c(w&&w.wallets||[]),p(O&&O.transactions||[])}).catch(function(){x(!1),y("Failed to load crypto portfolio")}))},[r,g]);if((0,i.useEffect)(function(){k()},[k]),!r)return(0,e.jsx)("div",{style:{fontFamily:D,fontSize:10,color:cn,padding:20},children:"Select a ledger entity to open the crypto portfolio."});var A=a&&a.totals||{},j=parseFloat(A.unrealized_pnl_usd||"0"),E=parseFloat(A.realized_ytd_usd||"0");return(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,justifyContent:"space-between"},children:[(0,e.jsx)("span",{style:{fontFamily:D,fontSize:10,fontWeight:700,color:pe,letterSpacing:".12em"},children:"◈ CRYPTO PORTFOLIO"}),(0,e.jsx)("button",{onClick:k,disabled:h,style:{fontFamily:D,fontSize:8,color:Lt,background:"transparent",border:"1px solid "+Ke,borderRadius:4,padding:"3px 8px",cursor:h?"wait":"pointer",letterSpacing:".08em"},children:h?"LOADING…":"REFRESH"})]}),v&&(0,e.jsx)("div",{style:{fontFamily:D,fontSize:9,color:et},children:v}),(0,e.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:10},children:[(0,e.jsx)(Zu,{label:"PORTFOLIO VALUE",value:"$"+Fi(A.value_usd)}),(0,e.jsx)(Zu,{label:"COST BASIS",value:"$"+Fi(A.cost_basis_usd)}),(0,e.jsx)(Zu,{label:"UNREALIZED P&L",value:(j>=0?"+$":"-$")+Fi(String(Math.abs(j))),color:j>=0?bt:et}),(0,e.jsx)(Zu,{label:"REALIZED YTD",value:(E>=0?"+$":"-$")+Fi(String(Math.abs(E))),color:E>=0?bt:et}),(0,e.jsx)(Zu,{label:"STAKED",value:"$"+Fi(a&&a.staking&&a.staking.total_staked_usd)}),(0,e.jsx)(Zu,{label:"DEFI DEPOSITED",value:"$"+Fi(a&&a.defi&&a.defi.total_deposited_usd)})]}),(0,e.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:14},children:[(0,e.jsx)("div",{style:{flex:"1 1 300px",minWidth:280},children:(0,e.jsx)(h9,{entityId:r,wallets:s,canWrite:o,selectedWalletId:g,onSelectWallet:f,onChanged:k})}
426),(0,e.jsx)("div",{style:{flex:"2 1 460px",minWidth:320},children:(0,e.jsx)(x9,{holdings:a&&a.holdings||[]})})]}),o&&(0,e.jsx)(v9,{entityId:r,wallets:s,onRecorded:k}),(0,e.jsx)(E9,{transactions:d,title:g?"TRANSACTIONS — SELECTED WALLET":"RECENT TRANSACTIONS"}),(0,e.jsx)(k9,{entityId:r,wallets:s,staking:a&&a.staking,canWrite:o,onChanged:k}),(0,e.jsx)(A9,{entityId:r,wallets:s,defi:a&&a.defi,canWrite:o,onChanged:k}),(0,e.jsx)(w9,{entityId:r,wallets:s})]})}var R9=["ledger_create_vendor","ledger_create_invoice","ledger_mark_invoice_paid","ledger_create_journal","ledger_create_entity","ledger_update_company_profile","ledger_intercompany_transfer"];function uk(t){return R9.indexOf(String(t||""))!==-1}function F9(t){if(!Array.isArray(t))return!1;for(var n=0;n<t.length;n++){var r=t[n]||{};if(r.type==="cortex_tool_result"&&uk(r.name)&&r.ok!==!1&&!r.error)return!0}return!1}function Ap(t,n){var r=typeof n=="number"&&n>0?n:6;return Array.isArray(t)?t.length>r?t.slice(t.length-r):t:[]}function I9(t){return!t||t.type!=="cortex_tool_call"||!t.name?"":"◌ "+t.name+"…"}var D9=`Instruct the ledger — "set up a supplier account for XYZ", "invoice ACME £2,400 consulting", "what's my cash position?"`,jp=6;function O9(){try{return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}var L9=["What's my cash position?","Show unpaid invoices (AR aging)","What do I owe suppliers (AP)?","Summarize this month's P&L","Set up a new supplier account"],nS={background:"transparent",border:"1px solid "+Ke,borderRadius:4,cursor:"pointer",fontFamily:D,fontSize:9,color:cn,padding:"4px 9px",whiteSpace:"nowrap",flexShrink:0,letterSpacing:".02em"};function z9({entity:t,onExecuted:n}){var[r,o]=(0,i.useState)(""),a=(0,i.useRef)(null),[l,s]=(0,i.useState)(!1),[c,d]=(0,i.useState)([]),[p,g]=(0,i.useState)(!1),[f,h]=(0,i.useState)(!0),[x,v]=(0,i.useState)(""),[y,k]=(0,i.useState)([]),A=(0,i.useRef)(null),j=(0,i.useRef)([]),E=(0,i.useRef)(null),C=(0,i.useRef)(null),_=(0,i.useRef)(!1);(0,i.useEffect)(function(){return function(){C.current&&C.current.cancel()}},[]);function w(){var N=E.current;N&&(N.scrollTop=N.scrollHeight)}function O(N){d(function(V){var z=V.slice(),oe=z[z.length-1];return oe&&oe.role==="ai"&&oe.streaming?z[z.length-1]=Object.assign({},oe,{text:N}):z.push({role:"ai",text:N,streaming:!0}),Ap(z,jp)}),requestAnimationFrame(w)}function M(N){d(function(V){var z=V.slice(),oe=z[z.length-1];return oe&&oe.role==="ai"&&(z[z.length-1]=Object.assign({},oe,{streaming:!1,wrote:!!N})),z})}async function U(N){if(!(!N||!t||p)){g(!0),v("DROP & BILL — extracting "+N.name+"…"),d(function(R){return Ap(R.concat([{role:"user",text:"⇪ "+N.name}]),jp)});try{var V=new FormData;V.append("file",N);var z=await xi(()=>import("./apiBase-BqVXqfJu.js").then(R=>R.n),__vite__mapDeps([6,1])),oe=localStorage.getItem("xyron_jwt_token")||"",P=await(await fetch(z.apiUrl(z.API_BASE_URL+"/api/ledger-docbill/"+t.id+"/process"),{method:"POST",headers:{Authorization:"Bearer "+oe},body:V})).json(),W;P.status==="posted"?W="✓ POSTED — "+(P.vendor&&P.vendor.name?P.vendor.name:"vendor")+" "+(P.total||"")+" "+(P.currency||"")+" · invoice "+(P.invoice_id||"").slice(0,8)+" · coded "+(P.coding&&P.coding.account_code||"?")+" ("+(P.coding&&P.coding.basis||"")+")"+(P.warnings&&P.warnings.length?" · warnings: "+P.warnings.join(", "):""):P.status==="needs_review"?W="⚠ NEEDS REVIEW — extraction confidence below floor. Extracted: "+JSON.stringify(P.extracted||{}).slice(0,260)+" — refine via AR/AP → NEW INVOICE.":P.status==="duplicate"?W="◌ DUPLICATE — this document was already billed ("+(P.invoice_id||"").slice(0,8)+").":W="✕ "+((P.error||P.detail||"processing failed")+"").slice(0,220),d(function(R){return Ap(R.concat([{role:"ai",text:W,wrote:P.status==="posted"}]),jp)}),P.status==="posted"&&n&&n()}catch(R){d(function(ae){return Ap(ae.concat([{role:"ai",text:"✕ drop failed: "+(R&&R.message||"error")}]),jp)})}finally{g(!1),v(""),s(!1),a.current&&(a.current.value=""),w()}}}async function ee(N){var V=typeof N=="string"&&N.trim(),z=V?N.trim():r.trim();if(!(!z||p)){g(!0),h(!0),v(""),k([]),j.current=[],d(function(P){return Ap(P.concat([{role:"user",text:z}]),jp)}),V||o(""),requestAnimationFrame(w),C.current&&C.current.cancel(),_.current=!1;var oe=Y2({lineAware:!0,reduceMotion:O9(),setText:O,onFinalize:function(P){P&&O(P),M(_.current),v(""),g(!1),_.current&&n&&n()}});C.current=oe;try{await cf.ledgerStream(z,A.current,t?t.id:null,function(P){v(""),oe.push(P)},function(P){P&&P.session_id&&(A.current=P.session_id),P&&Array.isArray(P.follow_ups)&&k(P.follow_ups.filter(function(W){return typeof W=="string"&&W.trim()}).slice(0,5)),_.current=F9(j.current),oe.finish()},function(P){oe.fail();var W=oe.received();d(function(R){var ae=R.slice(),q=ae[ae.length-1],ge=W||"⚠ "+ea(P||"console error");return q&&q.role==="ai"&&q.streaming?ae[ae.length-1]=Object.assign({},q,{text:q.text||ge,streaming:!1,failed:!0}):ae.push({role:"ai",text:ge,streaming:!1,failed:!0}),ae}),v(""),g(!1)},function(P){j.current.push(P),P.type==="cortex_tool_call"&&v(I9(P)),P.type==="cortex_tool_result"&&uk(P.name)&&v(P.ok===!1?"":"✓ "+P.name)})}catch{C.current&&C.current.cancel(),v(""),g(!1)}}}return(0,e.jsxs)("div",{style:{flexShrink:0,borderTop:"1px solid "+Ke,background:"#030507"},role:"region","aria-label":"Ledger AI console",children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5px 14px 4px"},children:[(0,e.jsxs)("button",{onClick:function(){h(!f)},style:{background:"transparent",border:"none",cursor:"pointer",fontFamily:D,fontSize:8,color:pe,letterSpacing:".12em",padding:0},title:f?"Collapse history":"Expand history",children:[f?"▾":"▸"," ◈ LEDGER CONSOLE"]}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:Lt},children:"AI EXECUTION · FULL AUTHORITY · AUDITED"}),(0,e.jsx)("div",{style:{flex:1}}),x&&(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:pe},children:x}),p&&!x&&(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:"#7A90A8"},children:"◌ working…"})]}),f&&c.length>0&&(0,e.jsx)("div",{ref:E,style:{maxHeight:190,overflowY:"auto",padding:"2px 14px 6px",display:"flex",flexDirection:"column",gap:5},children:c.map(function(N,V){var z=N.role==="user";return(0,e.jsxs)("div",{style:{fontFamily:D,fontSize:z?9:10,lineHeight:1.5,color:z?"#7A90A8":N.failed?et:"#C9D1D9",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:[(0,e.jsx)("span",{style:{color:z?pe:N.wrote?bt:"#6A8098",marginRight:6},children:z?"❯":N.wrote?"✓":"◈"}),N.text,N.streaming&&(0,e.jsx)("span",{style:{color:pe},children:"▊"})]},V)})}),c.length===0&&!p&&(0,e.jsx)("div",{style:{display:"flex",gap:6,padding:"2px 14px 8px",overflowX:"auto"},role:"group","aria-label":"Ledger starter questions",children:L9.map(function(N,V){return(0,e.jsx)("button",{onClick:function(){ee(N)},disabled:p,style:nS,children:N},V)})}),y.length>0&&!p&&(0,e.jsx)("div",{style:{display:"flex",gap:6,padding:"2px 14px 8px",overflowX:"auto"},role:"group","aria-label":"Ledger follow-up questions",children:y.map(function(N,V){return(0,e.jsx)("button",{onClick:function(){ee(N)},disabled:p,style:nS,children:N},V)})}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"0 14px 8px"},onDragOver:function(N){N.dataTransfer&&Array.from(N.dataTransfer.types||[]).includes("Files")&&(N.preventDefault(),s(!0))},onDragLeave:function(){s(!1)},onDrop:function(N){N.dataTransfer&&N.dataTransfer.files&&N.dataTransfer.files[0]&&(N.preventDefault(),U(N.dataTransfer.files[0]))},children:[(0,e.jsx)("input",{ref:a,type:"file",accept:".pdf,image/*",style:{display:"none"},onChange:function(N){N.target.files&&N.target.files[0]&&U(N.target.files[0])}}),(0,e.jsx)("button",{onClick:function(){a.current&&a.current.click()},disabled:p,title:"Drop & Bill — attach an invoice document; AI extracts, codes, and posts it","aria-label":"Attach invoice document",style:{background:"transparent",border:"1px dashed "+(l?pe:Ke),borderRadius:4,cursor:p?"default":"pointer",fontFamily:D,fontSize:10,
426color:l?pe:cn,padding:"5px 8px"},children:"⇪ BILL"}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:10,color:pe},children:"❯"}),(0,e.jsx)("input",{value:r,onChange:function(N){o(N.target.value)},onKeyDown:function(N){N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),ee())},placeholder:D9,disabled:p,"aria-label":"Ledger console instruction",style:{flex:1,background:"#05080D",border:"1px solid "+Ke,borderRadius:4,padding:"6px 9px",fontFamily:D,fontSize:10,color:xn,outline:"none",opacity:p?.6:1}}),(0,e.jsx)("button",{onClick:ee,disabled:p||!r.trim(),style:{background:"transparent",border:"1px solid "+(p?Ke:pe+"66"),borderRadius:4,cursor:p?"default":"pointer",fontFamily:D,fontSize:9,color:p?Lt:pe,padding:"5px 12px",letterSpacing:".08em"},children:p?"…":"RUN"})]})]})}var M9=[{id:"dashboard",label:"DASHBOARD",glyph:"▤"},{id:"journal",label:"JOURNAL",glyph:"▥"},{id:"accounts",label:"ACCOUNTS",glyph:"▦"},{id:"arap",label:"AR / AP",glyph:"◑"},{id:"banking",label:"BANKING",glyph:"◫"},{id:"statements",label:"STATEMENTS",glyph:"▣"},{id:"close",label:"CLOSE",glyph:"◆"},{id:"interco",label:"INTERCO",glyph:"◧"},{id:"crypto",label:"CRYPTO",glyph:"◬"}],Nh={viewer:cn,bookkeeper:pe,approver:bt,controller:et};function N9({hideConsole:t}){const n=lx(),[r,o]=(0,i.useState)("dashboard"),a=n.currentEntity,l=a&&a.role||null,s=l==="bookkeeper"||l==="approver"||l==="controller",c=n.currentGroup,d=!!c;return(0,e.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",background:du},role:"region","aria-label":"Ledger module",children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 16px 8px",borderBottom:"1px solid #111820",background:"#030507",flexShrink:0},children:[(0,e.jsx)("span",{style:{fontFamily:D,fontSize:11,fontWeight:700,color:pe,letterSpacing:".14em"},children:"◈ LEDGER"}),(0,e.jsx)("span",{style:{fontFamily:D,fontSize:8,color:Lt,letterSpacing:".08em"},children:"INSTITUTIONAL BOOKS · MULTI-ENTITY"}),(0,e.jsx)("div",{style:{flex:1}}),a&&(0,e.jsx)("span",{title:"Your role on this entity (backend-enforced)",style:{fontFamily:D,fontSize:8,color:Nh[l]||"#7A90A8",border:"1px solid "+(Nh[l]||"#7A90A8")+"44",background:(Nh[l]||"#7A90A8")+"10",borderRadius:3,padding:"2px 7px",letterSpacing:".1em"},children:String(l||"?").toUpperCase()}),a&&(0,e.jsxs)("span",{style:{fontFamily:D,fontSize:8,color:"#6A8098"},children:[a.jurisdiction||a.coa_template||""," ·"," ",a.functional_currency||""]}),(0,e.jsx)("button",{onClick:n.refresh,title:"Refresh entity data",style:{background:"transparent",border:"1px solid "+Ke,borderRadius:4,cursor:"pointer",fontFamily:D,fontSize:9,color:cn,padding:"3px 9px"},onMouseEnter:function(p){p.currentTarget.style.color=pe},onMouseLeave:function(p){p.currentTarget.style.color=cn},children:"↻ REFRESH"})]}),(0,e.jsx)(zO,{entities:n.entities,currentEntityId:n.currentEntityId,onSelect:n.selectEntity,onCreate:n.createEntity,groups:n.groups,currentGroupId:n.currentGroupId,onSelectGroup:n.selectGroup,onCreateGroup:n.createGroup}),(0,e.jsx)("div",{style:{display:d?"none":"flex",borderBottom:"1px solid #111820",background:"#030507",flexShrink:0},children:M9.map(function(p){const g=r===p.id;return(0,e.jsxs)("button",{onClick:function(){o(p.id)},style:{flex:1,padding:"8px 0",background:g?pe+"0A":"transparent",border:"none",borderBottom:g?"2px solid "+pe:"2px solid transparent",cursor:"pointer",fontFamily:D,fontSize:9,color:g?pe:Lt,letterSpacing:".08em",display:"flex",alignItems:"center",justifyContent:"center",gap:6,transition:"all .15s"},onMouseEnter:function(f){g||(f.currentTarget.style.color=cn)},onMouseLeave:function(f){g||(f.currentTarget.style.color=Lt)},children:[(0,e.jsx)("span",{children:p.glyph})," ",p.label]},p.id)})}),n.entitiesError&&(0,e.jsx)("div",{style:{padding:"6px 16px",background:et+"0C",borderBottom:"1px solid "+et+"28",fontFamily:D,fontSize:9,color:et,flexShrink:0},children:n.entitiesError}),n.error&&!n.entitiesError&&(0,e.jsx)("div",{style:{padding:"6px 16px",background:et+"0C",borderBottom:"1px solid "+et+"28",fontFamily:D,fontSize:9,color:et,flexShrink:0},children:n.error}),d?(0,e.jsx)(q1,{mode:"consolidated",group:c,entity:a}):n.entitiesLoading?(0,e.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center"}
426,children:(0,e.jsx)("span",{style:{fontFamily:D,fontSize:10,color:Ut},children:"◌ Loading entities…"})}):a?(0,e.jsxs)(e.Fragment,{children:[n.loading&&r==="dashboard"&&(0,e.jsx)("div",{style:{padding:"5px 16px",background:ln,borderBottom:"1px solid "+Ke,fontFamily:D,fontSize:8,color:Ut,flexShrink:0},children:"◌ refreshing…"}),r==="dashboard"&&(0,e.jsx)(MO,{entity:a,trialBal:n.trialBal,payables:n.payables,recentJournals:n.recentJournals}),r==="journal"&&(0,e.jsx)(PO,{entity:a,accounts:n.accounts,canPost:s,onPosted:function(p){n.recordJournal(p),n.refresh()}}),r==="accounts"&&(0,e.jsx)(WO,{accounts:n.accounts}),r==="arap"&&(0,e.jsx)(KO,{entity:a,payables:n.payables,trialBal:n.trialBal,role:l,onRefresh:n.refresh}),r==="banking"&&(0,e.jsx)(d9,{entity:a,accounts:n.accounts,role:l,onRefresh:n.refresh}),r==="statements"&&(0,e.jsx)(q1,{entity:a}),r==="close"&&(0,e.jsx)(p9,{entity:a,role:l,lockedPeriods:n.lockedPeriods,onLocked:n.recordLockedPeriod,onRefresh:n.refresh}),r==="interco"&&(0,e.jsx)(g9,{entities:n.entities,onRefresh:n.refresh}),r==="crypto"&&(0,e.jsx)(_9,{entity:a,role:l})]}):(0,e.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:10},children:[(0,e.jsx)("div",{style:{fontFamily:D,fontSize:12,color:cn,letterSpacing:".08em"},children:"NO LEDGER ENTITIES VISIBLE"}),(0,e.jsx)("div",{style:{fontFamily:D,fontSize:9,color:Lt,maxWidth:380,textAlign:"center"},children:"Create your first entity with + NEW ENTITY above — the chart of accounts is cloned from the selected jurisdiction template and you become its controller."})]}),!t&&(0,e.jsx)(z9,{entity:a,onExecuted:n.refresh})]})}function B9({onClose:t}){return(0,e.jsxs)("div",{style:{position:"relative",display:"flex",flexDirection:"column",flex:1,minHeight:0,background:"#080B11",border:"1px solid #1E2838",borderRadius:8,overflow:"hidden"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",borderBottom:"1px solid #111820",background:"#050810",flexShrink:0},children:[(0,e.jsxs)("div",{style:{fontFamily:"monospace",fontSize:10,color:"#D4AF5C",letterSpacing:".12em",fontWeight:700},children:["◆ LEDGER",(0,e.jsx)("span",{style:{color:"#6A8098",fontWeight:400,marginLeft:10,letterSpacing:".08em"},children:"OPERATED BY THE XYRON CONSOLE BELOW"})]}),(0,e.jsx)("div",{style:{display:"flex",gap:8},children:(0,e.jsx)("button",{onClick:t,style:{background:"transparent",border:"1px solid #1E2838",borderRadius:5,cursor:"pointer",fontFamily:"monospace",fontSize:9,color:"#7A90A8",padding:"3px 9px"},children:"✕ CLOSE"})})]}),(0,e.jsx)("div",{style:{flex:1,minHeight:0,overflow:"auto"},children:(0,e.jsx)(N9,{hideConsole:!0})})]})}function P9(t){if(t==null)return null;var n=String(t).trim().replace(/,/g,"");if(!/^\d+(\.\d{1,2})?$/.test(n))return null;var r=Number(n);return!isFinite(r)||r<=0?null:r.toFixed(2)}var U9="Select an entity in the LEDGER module first — ledger commands are entity-scoped.";function W9(t){if(!t||typeof t.getItem!="function")return null;try{var n=t.getItem("xyron_ledger_entity"),r=n==null?"":String(n).trim();return r||null}catch{return null}}function H9(t){var n=t||{},r=(n.vendor||"").trim();if(!r)return"Create an invoice";var o=n.direction==="PAYABLE"?"Record a payable invoice from "+r:"Create an invoice for "+r,a=n.amount==null||n.amount===""?null:P9(n.amount);a&&(o+=", "+a+" "+(n.currency||"GBP"));var l=parseInt(n.dueDays,10);isFinite(l)&&l>0&&(o+=", due in "+l+" days");var s=(n.description||"").trim();return s&&(o+=", for "+s),o}function G9(t){var n=t==null?"":String(t).trim();return n?"Mark invoice "+n+" as paid":"Mark an invoice as paid"}function Bh(t,n){if(!t)return 0;var r=Date.parse(String(t));if(isNaN(r))return 0;var o=Math.floor(((typeof n=="number"?n:Date.now())-r)/864e5);return o>0?o:0}var Wr="monospace",Hr={bg:"#05080D",card:"#06080F",line:"#111820",dim:"#3A4A5E",txt:"#C9D1D9",hi:"#E6EDF3",accent:"#D4AF5C",purple:"#D4AF5C",green:"#3FB950",orange:"#D4AF5C",red:"#F97583",blue:"#6B9AC4",pink:"#C85C5C",cyan:"#B0BCC8"};function Co(t){var n=parseInt(t.slice(1,3),16),r=parseInt(t.slice(3,5),16),o=parseInt(t.slice(5,7),16);return n+","+r+","+o}function Qc(t,n){return t==null||isNaN(t)?"—":({USD:"$",GBP:"£",EUR:"€",CHF:"CHF "}
426[n||"USD"]||(n||"")+" ")+Number(t).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}function V9(){var t=new Date;return t.setMonth(t.getMonth()-t.getMonth()%3),t.setDate(1),t.toISOString().slice(0,10)}function Y9(){return new Date().toISOString().slice(0,10)}var hf={accounting:{label:"ACCOUNTING",color:"#C85C5C",icon:"§",desc:"Bookkeeper — invoices, ledger, statements, payables, vendors",commands:[{label:"Trial balance",prompt:"trial balance"},{label:"P&L",prompt:"profit and loss this quarter"},{label:"Balance sheet",prompt:"balance sheet"},{label:"Cash flow",prompt:"cash flow forecast"},{label:"Payables",prompt:"outstanding payables"},{label:"Create invoice",prompt:"create invoice"},{label:"Vendor spend",prompt:"vendor spend summary this year"},{label:"Budget check",prompt:"budget vs actual this quarter"}]},tax:{label:"TAX",color:"#D4AF5C",icon:"⚖",desc:"Tax agent — CGT, VAT, withholding tax, multi-jurisdiction",commands:[{label:"Tax overview",prompt:"tax position across all jurisdictions"},{label:"UK CGT",prompt:"UK capital gains tax liability estimate"},{label:"Swiss WHT",prompt:"Swiss withholding tax reclaim status"},{label:"VAT return",prompt:"VAT return for current quarter"},{label:"Tax planning",prompt:"cross-border tax optimisation opportunities"}]},legal:{label:"LEGAL",color:"#6B9AC4",icon:"⚖",desc:"Legal agent — contracts, NDA, risk clauses, IP",commands:[{label:"Review contract",prompt:"review the latest contract for risk clauses"},{label:"Draft NDA",prompt:"draft a standard NDA"},{label:"Sanctions check",prompt:"sanctions screening update"},{label:"IP register",prompt:"intellectual property portfolio status"}]},portfolio:{label:"PORTFOLIO",color:"#D4AF5C",icon:"◈",desc:"Portfolio agent — NAV, allocation, performance, rebalancing",commands:[{label:"NAV",prompt:"portfolio NAV and allocation breakdown"},{label:"Top positions",prompt:"top 10 positions by value"},{label:"Allocation",prompt:"asset allocation by class and geography"},{label:"YTD performance",prompt:"portfolio performance YTD vs benchmark"},{label:"Dividends",prompt:"dividend income summary this year"},{label:"Liquidity",prompt:"liquidity analysis across all positions"}]},risk:{label:"RISK",color:"#C85C5C",icon:"⚠",desc:"Risk agent — VaR, concentration, correlation, FX exposure",commands:[{label:"Risk snapshot",prompt:"portfolio risk assessment VaR max drawdown Sharpe"},{label:"Correlation",prompt:"correlation matrix across asset classes"},{label:"Concentration",prompt:"concentration risk report"},{label:"FX exposure",prompt:"FX exposure and hedging status"}]},realestate:{label:"REAL ESTATE",color:"#3FB950",icon:"▣",desc:"Property agent — valuations, rent roll, leases, maintenance",commands:[{label:"Properties",prompt:"property portfolio overview with valuations"},{label:"Rent roll",prompt:"rent roll with tenant details and lease expiry"},{label:"Maintenance",prompt:"property maintenance schedule and costs"},{label:"Cap rates",prompt:"cap rate analysis across properties"},{label:"Debt coverage",prompt:"mortgage and debt service coverage"},{label:"Lease expiry",prompt:"upcoming lease expiry calendar"}]},crypto:{label:"CRYPTO",color:"#D4AF5C",icon:"₿",desc:"Crypto agent — wallets, staking, DeFi, gas, tax",commands:[{label:"Overview",prompt:"crypto portfolio summary"},{label:"Staking",prompt:"staking positions and rewards"},{label:"DeFi health",prompt:"DeFi positions and health factors"},{label:"Gains YTD",prompt:"crypto realised gains YTD"},{label:"Gas fees",prompt:"gas fee summary this month"},{label:"Tax report",prompt:"crypto tax report for UK filing"}]},board:{label:"BOARD",color:"#B0BCC8",icon:"◎",desc:"Board agent — board packs, governance, compliance, ESG",commands:[{label:"Board pack",prompt:"board pack executive summary"},{label:"IC report",prompt:"investment committee report"},{label:"Compliance",prompt:"compliance and regulatory update"},{label:"Annual review",prompt:"annual review and forward strategy"},{label:"ESG report",prompt:"ESG and impact report"},{label:"Resolutions",prompt:"board resolution tracker and status"}]},market:{label:"MARKET",color:"#6B9AC4",icon:"◉",desc:"Market agent — live prices, news, macro, sector analysis",commands:[{label:"Snapshot",prompt:"global market snapshot"},{label:"Rate calendar",prompt:"central bank rate decision calendar"},{label:"Sector rotation",prompt:"sector rotation analysis"},{label:"EM outlook",prompt:"emerging markets outlook"},{label:"Credit spreads",prompt:"credit spreads and fixed income analysis"},{label:"Geopolitical",prompt:"geopolitical risk monitor"}]},documents:{label:"DOCUMENTS",color:"#6B7280",icon:"□",desc:"Document agent — generate PDF, DOCX, XLSX, reports",commands:[{label:"Portfolio PDF",prompt:"generate portfolio snapshot PDF"},{label:"Risk report",prompt:"generate risk report"},{label:"NAV XLSX",prompt:"generate NAV report spreadsheet"},{label:"Research memo",prompt:"generate research memo"},{label:"Document summary",prompt:"summarise selected document"},{label:"Due diligence",prompt:"generate due diligence template"}]},vault:{label:"VAULT",color:"#3FB950",icon:"🔒",desc:"Vault agent — search, retrieve, organise documents",commands:[{label:"Find NDAs",prompt:"search vault for all NDA documents"},{label:"Insurance",prompt:"search vault for insurance policies"},{label:"Financial docs",prompt:"list all financial statements in vault"},{label:"Recent uploads",prompt:"show recent vault uploads"},{label:"Storage overview",prompt:"vault storage summary"}]},intelligence:{label:"INTELLIGENCE",color:"#B0BCC8",icon:"⌕",desc:"Intelligence agent — briefs, geopolitical, macro, sanctions",commands:[{label:"Morning brief",prompt:"morning intelligence brief"},{label:"Geopolitical",prompt:"geopolitical risk monitor current threats"},{label:"CB calendar",prompt:"central bank calendar next 30 days"},{label:"Sanctions",prompt:"sanctions screening update"},{label:"Macro dashboard",prompt:"macro economic dashboard"},{label:"Weekly digest",prompt:"weekly market digest"}]}},K9={accounting:1,realestate:1,crypto:1,board:1},X9=Object.keys(hf).filter(function(t){return!K9[t]}),rS={tax:"You are a senior international tax advisor to an ultra-high-net-worth family office. Provide precise, jurisdiction-specific tax analysis. Reference actual UK HMRC, Swiss, EU tax law where relevant. Quantify liabilities, identify planning opportunities, flag compliance deadlines. Be direct and actionable.",legal:"You are a senior corporate lawyer and compliance officer for an ultra-high-net-worth family office. Analyze contracts, flag risk clauses, identify regulatory exposure, assess enforceability. Reference actual legislation. Be direct, flag action items.",portfolio:"You are a senior portfolio manager and CIO for an ultra-high-net-worth family office. Analyze allocation, performance attribution, risk-adjusted returns, benchmark comparisons, rebalancing opportunities. Use quantitative metrics. Be precise and actionable.",risk:"You are a chief risk officer for an ultra-high-net-worth family office. Compute and explain VaR, stress scenarios, concentration limits, counterparty exposure, correlation risks. Quantify everything. Flag breaches and recommended actions.",realestate:"You are a senior real estate investment manager for an ultra-high-net-worth family office. Analyze property valuations, rental yields, cap rates, debt coverage ratios, lease terms, maintenance capex, and market comparables. Be precise with numbers.",board:"You are a corporate governance advisor and board secretary for an ultra-high-net-worth family office. Draft board packs, investment committee reports, compliance summaries, governance updates. Follow institutional standards. Be concise and structured.",market:"You are a senior macro strategist and market analyst for an ultra-high-net-worth family office. Analyze global markets, rates, FX, commodities, credit, geopolitical risks. Reference real data. Provide actionable intelligence.",intelligence:"You are the head of intelligence for an ultra-high-net-worth family office. Synthesize geopolitical, macro-economic, market, and regulatory intelligence into actionable briefings. Assess threats and opportunities. Be concise and prioritized."};
426function q9({onClose:t,onCommand:n,onEmailDraft:r,onStatusMessage:o,onPrefillCommand:a,commandRef:l}){var s=(0,i.useState)([]),c=s[0],d=s[1],p=(0,i.useState)(!1),g=p[0],f=p[1],h=(0,i.useState)(null),x=h[0],v=h[1],y=(0,i.useState)(""),k=y[0],A=y[1],j=(0,i.useState)(null),E=j[0],C=j[1],_=(0,i.useState)([]);_[0];var w=_[1],O=(0,i.useRef)(null),M=(0,i.useRef)(null),U=(0,i.useRef)(!1);(0,i.useEffect)(function(){U.current||(U.current=!0,N("Xyron Command Intelligence active. Select a launch-approved department or give me an instruction — portfolio, risk, market data, documents, vault, tax, legal, and intelligence research."))},[]),(0,i.useEffect)(function(){l&&(l.current={processCommand:tn})});function ee(){return new Date().toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})}function N(H,Z,T){var Y=Z||"s"+Date.now()+Math.random(),B={id:Y,role:"system",text:H,ts:ee()};return T&&(B=Object.assign(B,T)),d(function(ie){return ie.concat([B])}),R(),Y}function V(H){d(function(Z){return Z.concat([{id:"u"+Date.now()+Math.random(),role:"user",text:H,ts:ee()}])}),w(function(Z){return[H].concat(Z).slice(0,50)}),R()}function z(H){d(function(Z){return Z.filter(function(T){return T.id!==H})})}function oe(H,Z,T){d(function(Y){return Y.map(function(B){return B.id===H?Object.assign({},B,{text:Z,role:T||B.role}):B})})}function P(H,Z,T){var Y="dc"+Date.now()+Math.random(),B={id:Y,role:"data",cardType:Z,data:H,ts:ee()};return T&&(B=Object.assign(B,T)),d(function(ie){return ie.concat([B])}),R(),Y}function W(H){d(function(Z){return Z.concat([{id:"act"+Date.now()+Math.random(),role:"actions",actions:H,ts:ee()}])}),R()}function R(){setTimeout(function(){var H=O.current;H&&(H.scrollTop=H.scrollHeight)},60)}function ae(H){return(H||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/^[-]{3,}$/gm,'<div style="border-top:1px solid #1A2332;margin:8px 0"></div>').replace(/\*\*([^*]+)\*\*/g,'<strong style="color:#E6EDF3;font-weight:700">$1</strong>').replace(/^#{1,3}\s+(.+)$/gm,'<div style="font-family:monospace;font-size:11px;font-weight:700;color:#D4AF5C;letter-spacing:.08em;margin-top:12px;margin-bottom:5px;border-bottom:1px solid rgba(212,175,92,0.12);padding-bottom:4px">$1</div>').replace(/^([A-Z][A-Z\s/&-]+:)/gm,'<span style="font-family:monospace;font-size:10px;font-weight:700;color:#6B9AC4;letter-spacing:.06em">$1</span>').replace(/^[-*]\s+(.+)$/gm,'<div style="margin-left:12px;color:#C9D1D9;margin-bottom:3px"><span style="color:#D4AF5C;margin-right:6px;font-size:7px">&#9656;</span>$1</div>').replace(/^\d+[.)]\s+(.+)$/gm,'<div style="margin-left:12px;color:#C9D1D9;margin-bottom:3px">$1</div>').replace(/`([^`]+)`/g,'<code style="font-family:monospace;font-size:11px;background:#151D2B;border:1px solid rgba(56,189,248,0.2);border-radius:3px;padding:1px 5px;color:#6B9AC4">$1</code>').replace(/\n\n/g,'<div style="height:8px"></div>').replace(/\n/g,"<br/>")}var q=120,ge=400,X=2,de=28,We=3,te=7,_e=24,ve=14,Ne=9,$e=12;function Pe(H){if(H<q)return{chunk:X,ms:de};if(H<ge){var Z=(H-q)/(ge-q);return{chunk:Math.round(We+(te-We)*Z),ms:Math.round(_e+(ve-_e)*Z)}}return{chunk:Ne,ms:$e}}function ot(H,Z,T,Y,B){var ie=null,ue=null;typeof Y=="function"?ue=Y:Y&&typeof Y=="object"&&(ie=Y,ue=B||null);var ne={id:H,role:T||"system",text:"​",ts:ee(),_streaming:!0};ie&&(ne=Object.assign(ne,ie)),d(function(ct){return ct.concat([ne])}),C(H);var Me=0;function nt(){if(!M.current){setTimeout(nt,16);return}if(Me>=Z.length){C(null),d(function(je){return je.map(function(Le){return Le.id===H?Object.assign({},Le,{text:Z,_streaming:!1}):Le})}),R(),ue&&ue();return}var ct=Pe(Me);Me=Math.min(Me+ct.chunk,Z.length),M.current.innerHTML=ae(Z.substring(0,Me)),R(),setTimeout(nt,ct.ms)}setTimeout(nt,de)}function re(H,Z,T,Y,B,ie){var ue={id:H,role:Y||"analysis",text:"​",ts:ee(),_streaming:!0};B&&(ue=Object.assign(ue,B)),d(function(be){return be.concat([ue])}),C(H);var ne="",Me=0,nt=null,ct=!1,je=!1;function Le(){if(nt=null,!M.current){nt=setTimeout(Le,16);return}if(Me>=ne.length){if(je){C(null),d(function(Wt){return Wt.map(function(Te){return Te.id===H?Object.assign({},Te,{text:ne,_streaming:!1}):Te})}),R(),ct||(ct=!0,ie&&ie({}));return}nt=setTimeout(Le,30);return}var be=Pe(Me);Me=Math.min(Me+be.chunk,ne.length),M.current.innerHTML=ae(ne.substring(0,Me)),R(),nt=setTimeout(Le,be.ms)}_t.analyzeStream(Z,T,function(be){ne+=be,nt||(nt=setTimeout(Le,de))},function(){je=!0,nt||(nt=setTimeout(Le,0))},function(be){je=!0,ne||(ne="Failed: "+(be||"try again")),nt||(nt=setTimeout(Le,0))}),nt=setTimeout(Le,de)}function we(H){N(H?"Opening the LEDGER console for: "+H:"Opening the LEDGER console…");try{window.dispatchEvent(new CustomEvent("xyron:open-ledger",{detail:H?{command:H}:{}}))}catch{}}function b(){var H=W9(typeof localStorage<"u"?localStorage:null);return H||(N("⚠ "+U9),W([{label:"Open LEDGER",cmd:"_open_ledger_console"}]),null)}function He(H,Z){f(!0);var T=N("Preparing "+Z+"…");H.then(function(Y){if(f(!1),z(T),!Y||Y.error||!Y.blob){N("⚠ "+(Y&&Y.error||Z+" export failed."));return}var B=URL.createObjectURL(Y.blob),ie=document.createElement("a");ie.href=B,ie.download=Y.filename||Z,ie.click(),URL.revokeObjectURL(B),N("⤓ "+(Y.filename||Z)+" downloaded.")}).catch(function(){f(!1),oe(T,Z+" export failed.")})}function tt(H){var Z=b();if(Z){f(!0);var T=N("Fetching trial balance…");dn.trialBalance(Z,H).then(function(Y){if(f(!1),z(T),Y.error){N("⚠ "+Y.error);return}P(Y,"trial_balance"),W([{label:"⇩ CSV",cmd:"_ledger_export",kind:"trial-balance",fmt:"csv"},{label:"⇩ XLSX",cmd:"_ledger_export",kind:"trial-balance",fmt:"xlsx"},{label:"P&L this quarter",cmd:"_acct_pnl"},{label:"Balance sheet",cmd:"_acct_bs"},{label:"Drill into accounts",cmd:"_ai_analyze",query:"Analyze this trial balance and flag any anomalies or unusual balances",context:JSON.stringify(Y).substring(0,3e3)}])}).catch(function(){f(!1),oe(T,"Trial balance failed. Check backend connection.")})}}function Ae(H){var Z=b();if(Z){f(!0);var T=N("Fetching balance sheet…");dn.balanceSheet(Z,H).then(function(Y){if(f(!1),z(T),Y.error){N("⚠ "+Y.error);return}P(Y,"balance_sheet"),W([{label:"⇩ PNG",cmd:"_ledger_chart",kind:"balance_sheet"},{label:"Analyze trends",cmd:"_ai_analyze",query:"Analyze this balance sheet for financial health, leverage ratios, liquidity, and flag any concerns",context:JSON.stringify(Y).substring(0,3e3)},{label:"P&L",cmd:"_acct_pnl"},{label:"Cash flow",cmd:"_acct_cashflow"}])}).catch(function(){f(!1),oe(T,"Balance sheet failed.")})}}function Be(H,Z){var T=b();if(T){var Y=H||V9(),B=Z||Y9();f(!0);var ie=N("Fetching P&L ("+Y+" to "+B+")…");dn.pnl(T,Y,B).then(function(ue){if(f(!1),z(ie),ue.error){N("⚠ "+ue.error);return}P(ue,"pnl"),W([{label:"⇩ Expenses PNG",cmd:"_ledger_chart",kind:"expense_by_month"},{label:"Analyze margins",cmd:"_ai_analyze",query:"Analyze this P&L for margin trends, cost control, revenue drivers, and flag concerns",context:JSON.stringify(ue).substring(0,3e3)},{label:"Budget vs actual",cmd:"_acct_budget"},{label:"Balance sheet",cmd:"_acct_bs"}])}).catch(function(){f(!1),oe(ie,"P&L failed.")})}}function Fe(H){var Z=b();if(Z){f(!0);var T=N("Generating cash flow forecast…");dn.cashFlow(Z,H||6).then(function(Y){if(f(!1),z(T),Y.error){N("⚠ "+Y.error);return}P(Y,"cash_flow"),W([{label:"⇩ PNG",cmd:"_ledger_chart",kind:"cash_trend"},{label:"Analyze liquidity risk",cmd:"_ai_analyze",query:"Analyze this cash flow forecast for liquidity risks, shortfall months, and recommendations",context:JSON.stringify(Y).substring(0,3e3)},{label:"Payables",cmd:"_acct_payables"}])}).catch(function(){f(!1),oe(T,"Cash flow forecast failed.")})}}function ft(H){var Z=b();if(Z){f(!0);var T=N(H?"Looking up payables for "+H+"…":"Fetching outstanding payables…");dn.payables(Z,H).then(function(Y){if(f(!1),z(T),Y.error){N("⚠ "+Y.error);return}P(Y,"payables");var B=[{label:"⇩ CSV",cmd:"_ledger_export",kind:"payables",fmt:"csv"},{label:"⇩ XLSX",cmd:"_ledger_export",kind:"payables",fmt:"xlsx"},{label:"⇩ Aging XLSX",cmd:"_ledger_export",kind:"aging",fmt:"xlsx"},{label:"⇩ Aging PNG",cmd:"_ledger_chart",kind:"aging"},{label:"Send reminders",cmd:"_acct_send_reminders",data:Y},{label:"Aged analysis",cmd:"_ai_analyze",query:"Analyze these outstanding payables for aging, overdue risk, and recommended collection actions",context:JSON.stringify(Y).substring(0,3e3)}];if(Y.invoices&&Y.invoices.length>0){var ie=Y.invoices[0]||{};B.push({label:"Mark first as paid",cmd:"_acct_mark_paid",identifier:ie.invoice_number||ie.invoice_id})}W(B)}).catch(function(){f(!1),oe(T,"Payables failed.")})}}function St(H){var Z=b();if(Z){f(!0);var T=N("Looking up vendor: "+H+"…");dn.payables(Z,H).then(function(Y){if(f(!1),z(T),Y.error){N("⚠ "+Y.error);return}P(Y,"payables"),W([{label:"⇩ Statement CSV",cmd:"_ledger_vendor_statement",vendor:H,fmt:"csv"},{label:"⇩ Statement XLSX",cmd:"_ledger_vendor_statement",vendor:H,fmt:"xlsx"}
426,{label:"Create invoice",cmd:"_acct_start_invoice",vendor:H},{label:"Email vendor",cmd:"_email_vendor",vendor:H}])}).catch(function(){f(!1),oe(T,"Vendor lookup failed.")})}}function Xe(H){var Z=b();if(Z){var T=H||new Date().toISOString().slice(0,7);f(!0);var Y=N("Fetching budget vs actual for "+T+"…");dn.budgetVsActual(Z,T).then(function(B){if(f(!1),z(Y),B.error){N("⚠ "+B.error);return}P(B,"budget_vs_actual"),W([{label:"⇩ PNG",cmd:"_ledger_chart",kind:"budget_vs_actual",period:T},{label:"Analyze variances",cmd:"_ai_analyze",query:"Analyze these budget variances, flag significant overruns, identify savings opportunities",context:JSON.stringify(B).substring(0,3e3)},{label:"P&L",cmd:"_acct_pnl"}])}).catch(function(){f(!1),oe(Y,"Budget vs actual failed.")})}}function It(H,Z,T,Y,B,ie){we(H9({vendor:H||"",amount:Z,currency:T||"GBP",description:Y||"",dueDays:B||"30",direction:ie||"RECEIVABLE"}))}function Rt(H){if(!H){N("No invoice specified.");return}we(G9(H))}function $(){var H=b();if(H){f(!0);var Z=N("Fetching crypto portfolio…");dn.cryptoPortfolio(H).then(function(T){if(f(!1),z(Z),T.error){N("⚠ "+T.error+" — the crypto book lives in the LEDGER module's CRYPTO tab."),W([{label:"Open LEDGER",cmd:"_open_ledger_console"}]);return}P(T,"crypto_summary"),W([{label:"Analyze positions",cmd:"_ai_analyze",query:"Analyze this crypto portfolio for concentration, DeFi health, staking yield optimisation, and risk",context:JSON.stringify(T).substring(0,3e3)},{label:"Tax report",cmd:"_ai_dept",dept:"tax",query:"Generate a crypto tax report for UK filing based on this portfolio data: "+JSON.stringify(T).substring(0,2e3)}])}).catch(function(){f(!1),oe(Z,"Crypto portfolio failed.")})}}function Ue(){f(!0);var H=N("Fetching live market data…");wf.snapshot().then(function(Z){if(f(!1),z(H),!Z||!Z.snapshot){N("Market data unavailable.");return}P(Z,"market_snapshot"),W([{label:"Analyze",cmd:"_ai_analyze",query:"Analyze current market conditions, key moves, and implications for a family office portfolio",context:JSON.stringify(Z.snapshot).substring(0,3e3)},{label:"Geopolitical risk",cmd:"_ai_dept",dept:"intelligence",query:"geopolitical risk monitor current threats"}])}).catch(function(){f(!1),oe(H,"Market snapshot failed.")})}function Ie(H){f(!0);var Z=N('Searching vault for "'+H+'"…');gn.list().then(function(T){f(!1),z(Z);var Y=(T.documents||[]).filter(function(B){return(B.name||"").toLowerCase().indexOf(H.toLowerCase())!==-1||(B.type||"").toLowerCase().indexOf(H.toLowerCase())!==-1});Y.length>0?(N("Found "+Y.length+" document"+(Y.length>1?"s":"")+":"),Y.slice(0,10).forEach(function(B){N("  • "+B.name+" ("+B.type+", "+(B.size_bytes?Math.round(B.size_bytes/1024)+"KB":"unknown size")+")")})):N('No documents found for "'+H+'".'),W([{label:"Search again",cmd:"_vault_search_prompt"},{label:"List all",cmd:"_vault_list"}])}).catch(function(){f(!1),oe(Z,"Vault search failed.")})}function Q(){f(!0);var H=N("Loading vault…");gn.list().then(function(Z){f(!1),z(H);var T=Z.documents||[];T.length>0?(N(T.length+" document"+(T.length>1?"s":"")+" in vault:"),T.slice(0,15).forEach(function(Y){N("  • "+Y.name+" — "+Y.type+" ("+(Y.created_at||"").substring(0,10)+")")})):N("Vault is empty.")}).catch(function(){f(!1),oe(H,"Vault load failed.")})}function rt(H,Z,T){f(!0),N("Generating "+(T||"PDF").toUpperCase()+": "+H+"…"),(T==="docx"?uu.generateDOCX:uu.generatePDF)(H,Z,!0).then(function(Y){f(!1),N(Y?"✅ "+H+"."+(T||"pdf")+" downloaded and saved to vault.":"⚠ Generation failed.")}).catch(function(){f(!1),N("Document generation failed.")})}function jt(H,Z,T){var Y=(rS[H]||rS.intelligence)+`
427
428User query: `+Z,B=T?Z+`
429
430Context data:
431`+T:Z;f(!0),re("ai"+Date.now(),B,Y,"analysis",{persona:"Xyron "+(hf[H]?hf[H].label:"Intelligence")+" Agent"},function(){f(!1);var ie=[{label:"Export as PDF",cmd:"_export_last_pdf"},{label:"Email this",cmd:"_email_last"}];H==="tax"&&ie.push({label:"Tax calendar",cmd:"_ai_dept",dept:"tax",query:"tax filing deadlines and compliance calendar for the next 90 days"}),H==="legal"&&ie.push({label:"Draft document",cmd:"_ai_dept",dept:"legal",query:"draft the recommended legal document based on the analysis above"}),H==="risk"&&ie.push({label:"Stress test",cmd:"_ai_dept",dept:"risk",query:"run stress test scenarios based on the risk analysis above"}),H==="portfolio"&&ie.push({label:"Rebalance suggestion",cmd:"_ai_dept",dept:"portfolio",query:"suggest portfolio rebalancing actions to optimise risk-adjusted returns"}),W(ie)})}function tn(H){if(H.trim()){V(H);var Z=H.toLowerCase().trim(),T=Z.match(/(?:make|create|generate|draft|send|new|raise)\s+(?:an?\s+)?invoice\s+(?:to|for)\s+(.+?)(?:\s+for\s+)?(?:[$\u00A3\u20AC]?\s*(\d[\d,.]*)\s*(k|K|thousand|million|m|M)?)?(?:\s+(?:pounds?|gbp|dollars?|usd|euros?|eur|chf))?/i);if(T||(T=Z.match(/(?:bill|invoice)\s+(.+?)\s+(?:[$\u00A3\u20AC]?\s*(\d[\d,.]*)\s*(k|K|thousand|million|m|M)?)/i)),T){var Y=(T[1]||"").replace(/\s+(for|and|send|email|by)\s+.*$/i,"").trim(),B=T[2]?T[2].replace(/,/g,""):null,ie=T[3];B&&ie&&((ie==="k"||ie==="K"||ie==="thousand")&&(B=String(parseFloat(B)*1e3)),(ie==="m"||ie==="M"||ie==="million")&&(B=String(parseFloat(B)*1e6)
431));var ue="GBP";Z.match(/dollar|usd|\$/)&&(ue="USD"),Z.match(/euro|eur|\u20AC/)&&(ue="EUR"),Z.match(/chf|franc/)&&(ue="CHF"),It(Y||null,B,ue,"","30","RECEIVABLE");return}var ne=Z.match(/(?:mark|set)\s+(.+?)\s+(?:as\s+)?paid/i);if(ne){Rt(ne[1].trim());return}var Me=Z.match(/(?:how much|what).*(?:owe[ds]?|outstanding|payable|due|receivable).*?(?:by|from|for|to)\s+(.+)/i);if(Me||(Me=Z.match(/payable[s]?\s+(?:for|from|by)\s+(.+)/i)),Me){ft(Me[1].trim());return}if(Z.match(/^(?:outstanding\s+)?payable[s]?$|^who\s+owes|^what.*outstanding/)){ft();return}if(Z.match(/trial\s*balance/)){tt();return}if(Z.match(/balance\s*sheet/)){Ae();return}if(Z.match(/p\s*&\s*l|p\s*n\s*l|profit\s*(?:and|&)\s*loss|income\s*statement/)){Be();return}if(Z.match(/cash\s*flow/)){Fe();return}if(Z.match(/budget\s*(?:vs|versus|v)\s*actual|budget\s*check/)){Xe();return}var nt=Z.match(/(?:vendor|supplier)\s+(?:details?|info|lookup|spend|summary)\s+(?:for\s+)?(.+)/i);if(nt||(nt=Z.match(/(?:look\s*up|search|find)\s+(?:vendor|supplier)\s+(.+)/i)),nt){St(nt[1].trim());return}if(Z.match(/vendor\s+spend|supplier\s+spend/)){jt("accounting","Provide a comprehensive vendor spend summary for this year, categorized by vendor and expense type.","");return}if(Z.match(/aged\s+creditor|aged\s+debtor|aging\s+report/)){ft();return}if(Z.match(/crypto\s+(?:portfolio|summary|overview|position|holdings)/)){$();return}if(Z.match(/staking|defi|gas\s*fee/)){$();return}if(Z.match(/market\s+snapshot|market\s+overview|markets\s+today|global\s+market/)){Ue();return}var ct=Z.match(/(?:price|quote|what(?:'s| is))\s+(?:of\s+)?(?:the\s+)?([A-Za-z]{1,5})/i);if(ct&&Z.match(/price|quote|stock|share|trading/)){f(!0);var je=N("Looking up "+ct[1].toUpperCase()+"…");wf.quote(ct[1].toUpperCase()).then(function(Tt){f(!1),z(je),Tt?P(Tt,"quote"):N("Quote unavailable for "+ct[1].toUpperCase())}).catch(function(){f(!1),oe(je,"Quote lookup failed.")});return}var Le=Z.match(/(?:search|find|look\s*for)\s+(?:in\s+)?(?:vault|documents?|files?)\s*(?:for\s+)?(.+)/i);if(Le){Ie(Le[1].trim());return}if(Z.match(/vault\s+(?:list|all|summary|overview|storage)/)){Q();return}if(Z.match(/recent\s+upload|recent\s+vault|latest\s+upload/)){Q();return}var be=Z.match(/(?:generate|create|make|produce)\s+(?:a?\s+)?(.+?)\s+(?:pdf|docx|document|report|spreadsheet)/i);if(be){var Wt=be[1].replace(/^(?:a|the|an)\s+/i,"").trim();jt(x||"board","Generate a comprehensive "+Wt+" report suitable for professional distribution. Include sections, data, analysis, and recommendations.","");return}if(Z.match(/morning\s*brief|daily\s*brief|today'?s?\s*brief/)){f(!0);var Te=N("Generating morning intelligence brief…");_t.morningBrief().then(function(Tt){f(!1),z(Te),Tt.success&&Tt.briefing?ot("mb"+Date.now(),Tt.briefing,"analysis",{persona:"Xyron Intelligence — Morning Brief"},function(){W([{label:"Export PDF",cmd:"_export_last_pdf"},{label:"Email brief",cmd:"_email_last"},{label:"Market snapshot",cmd:"_market_snapshot"}])}):N("Morning brief unavailable.")}).catch(function(){f(!1),oe(Te,"Morning brief failed.")});return}var it=x;it||(Z.match(/tax|cgt|vat|capital\s*gain|withholding|hmrc|irs|filing|deduction/)?it="tax":Z.match(/legal|contract|nda|compliance|clause|liability|gdpr|sanction|regulation|enforceable|binding/)?it="legal":Z.match(/portfolio|nav|allocation|benchmark|performance|rebalance|position|dividend/)?it="portfolio":Z.match(/risk|var|stress\s*test|drawdown|sharpe|correlation|concentration|counterparty|exposure|hedge/)?it="risk":Z.match(/property|properties|real\s*estate|rent\s*roll|tenant|lease|cap\s*rate|mortgage|vacancy/)?it="realestate":Z.match(/board\s*pack|governance|committee|esg|resolution|annual\s*review|director/)?it="board":Z.match(/market|sector|macro|central\s*bank|rate\s*decision|emerging|credit\s*spread|geopolitical/)?it="market":Z.match(/intelligence|geopolitical|sanctions|threat|brief/)?it="intelligence":Z.match(/crypto|bitcoin|ethereum|staking|defi|wallet|blockchain|nft|token/)?it="crypto":Z.match(/invoice|payable|journal|ledger|trial\s*balance|balance\s*sheet|p\s*&?\s*l|bookkeep|account/)?it="accounting":it="intelligence"),jt(it,H,"")}}function pt(H){if(!(!H||!H.cmd)){var Z=H.cmd;
431if(Z==="_open_ledger_console"){we(H.command||null);return}if(Z==="_ledger_export"){var T=b();if(!T)return;He((H.fmt==="xlsx"?dn.exportXlsx:dn.exportCsv)(T,H.kind),H.kind+"."+(H.fmt==="xlsx"?"xlsx":"csv"));return}if(Z==="_ledger_chart"){var Y=b();if(!Y)return;He(dn.chartPng(Y,H.kind,H.period?{period:H.period}:null),H.kind+".png");return}if(Z==="_ledger_vendor_statement"){var B=b();if(!B)return;He(dn.vendorStatement(B,H.vendor,H.fmt),"vendor-statement."+(H.fmt==="xlsx"?"xlsx":"csv"));return}if(Z==="_acct_tb"){tt();return}if(Z==="_acct_bs"){Ae();return}if(Z==="_acct_pnl"){Be();return}if(Z==="_acct_cashflow"){Fe();return}if(Z==="_acct_payables"){ft();return}if(Z==="_acct_payables_vendor"){ft(H.vendor);return}if(Z==="_acct_budget"){Xe();return}if(Z==="_acct_start_invoice"){It(H.vendor||null);return}if(Z==="_acct_mark_paid"){Rt(H.identifier);return}if(Z==="_market_snapshot"){Ue();return}if(Z==="_vault_search_prompt"){N("Type your vault search query.");return}if(Z==="_vault_list"){Q();return}if(Z==="_crypto_summary"){$();return}if(Z==="_acct_send_reminders"){var ie=(H.data&&H.data.invoices||[]).filter(function(ct){return Bh(ct.due_date)>0});if(ie.length===0){N("No overdue payables to send reminders for.");return}N("Preparing payment reminders for "+ie.length+" overdue invoice"+(ie.length>1?"s":"")+"…"),ie.slice(0,5).forEach(function(ct){var je=Bh(ct.due_date),Le=ct.invoice_number||ct.invoice_id;r&&r({subject:"Payment Reminder — Invoice "+Le+" ("+je+" days overdue)",body:"Dear "+ct.vendor+`,
432
433This is a friendly reminder that invoice `+Le+" for "+Qc(ct.outstanding,ct.currency)+" is "+je+" days overdue. The original due date was "+(ct.due_date||"N/A")+`.
434
435Please arrange payment at your earliest convenience.
436
437Kind regards`,to:""})});return}if(Z==="_email_last"||Z==="_email_vendor"){for(var ue="",ne=c.length-1;ne>=0;ne--)if(c[ne].role==="system"||c[ne].role==="analysis"){ue=c[ne].text||"";break}r&&r({subject:"",body:ue,to:""});return}if(Z==="_export_last_pdf"){for(var Me="",nt=c.length-1;nt>=0;nt--){if(c[nt].role==="analysis"||c[nt].role==="system"){Me=c[nt].text||"";break}if(c[nt].role==="data"){Me=JSON.stringify(c[nt].data,null,2);break}}Me?rt("Xyron Intelligence Report",Me,"pdf"):N("No content to export.");return}if(Z==="_ai_analyze"){jt(x||"intelligence",H.query,H.context||"");return}if(Z==="_ai_dept"){jt(H.dept,H.query,H.context||"");return}}}function gt(H,Z,T,Y,B){var ie=B||Hr.orange;return i.createElement("div",{style:{background:"#06080F",border:"1px solid #1A2332",borderRadius:6,padding:14,marginTop:4}},i.createElement("div",{style:{fontFamily:Wr,fontSize:10,fontWeight:700,color:ie,letterSpacing:".1em",marginBottom:10,borderBottom:"1px solid rgba("+Co(ie)+",0.15)",paddingBottom:6}},H),Z&&Z.length>0?Z.map(function(ue,ne){return i.createElement("div",{key:ne,style:{display:"flex",justifyContent:"space-between",padding:"4px 0",borderBottom:ne<Z.length-1?"1px solid #0D1117":"none"}},T.map(function(Me,nt){var ct=ue[Me.key],je=typeof ct=="number";return i.createElement("span",{key:nt,style:{fontFamily:Wr,fontSize:11,color:nt===0?Hr.txt:je&&ct<0?Hr.red:Hr.hi,flex:Me.flex||1,textAlign:nt===0?"left":"right",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},je?Qc(ct,""):ct||"—")}))}):i.createElement("div",{style:{fontFamily:Wr,fontSize:10,color:Hr.dim,padding:"8px 0"}},"No data available"),Y&&i.createElement("div",{style:{display:"flex",justifyContent:"space-between",paddingTop:8,marginTop:6,borderTop:"2px solid rgba("+Co(ie)+",0.2)"}},Y.map(function(ue,ne){return i.createElement("span",{key:ne,style:{fontFamily:Wr,fontSize:11,fontWeight:700,color:ne===0?ie:Hr.hi,flex:1,textAlign:ne===0?"left":"right"}},ue)})))}function qt(H){var Z=H.data||{},T=H.cardType;if(T==="trial_balance")return gt("TRIAL BALANCE"+(Z.as_of?" — as of "+Z.as_of:""),(Z.accounts||[]).map(function(ne){return{name:(ne.account_code||"")+" "+(ne.account_name||""),type:ne.account_type||"",debit:Number(ne.total_debit)||0,credit:Number(ne.total_credit)||0}}),[{key:"name",flex:3},{key:"type",flex:1},{key:"debit",flex:1},{key:"credit",flex:1}],["TOTAL","",Qc(Z.total_debit,""),Qc(Z.total_credit,"")],Z.balanced?Hr.green:Hr.red);if(T==="balance_sheet"){var Y=[];return Z.assets&&(Y.push({name:"▸ ASSETS",amount:""}
437),Z.assets.forEach(function(ne){Y.push({name:"  "+(ne.account_code||"")+" "+(ne.name||""),amount:Number(ne.balance)||0})})),Z.liabilities&&(Y.push({name:"▸ LIABILITIES",amount:""}),Z.liabilities.forEach(function(ne){Y.push({name:"  "+(ne.account_code||"")+" "+(ne.name||""),amount:Number(ne.balance)||0})})),Z.equity&&(Y.push({name:"▸ EQUITY",amount:""}),Z.equity.forEach(function(ne){Y.push({name:"  "+(ne.account_code||"")+" "+(ne.name||""),amount:Number(ne.balance)||0})})),gt("BALANCE SHEET"+(Z.as_of?" — "+Z.as_of:""),Y,[{key:"name",flex:3},{key:"amount",flex:1}],["TOTAL ASSETS: "+Qc(Z.total_assets,""),"L+E: "+Qc((Number(Z.total_liabilities)||0)+(Number(Z.total_equity)||0),"")],Z.balanced?Hr.green:Hr.red)}if(T==="pnl"){var B=[];Z.revenue&&(B.push({name:"▸ REVENUE",amount:""}),Z.revenue.forEach(function(ne){B.push({name:"  "+(ne.name||ne.account_code||""),amount:Number(ne.amount)||0})})),Z.expenses&&(B.push({name:"▸ EXPENSES",amount:""}),Z.expenses.forEach(function(ne){B.push({name:"  "+(ne.name||ne.account_code||""),amount:Number(ne.amount)||0})}));var ie=(Z.net_income||0)>=0?Hr.green:Hr.red;return gt("PROFIT & LOSS"+(Z.period?" — "+Z.period:""),B,[{key:"name",flex:3},{key:"amount",flex:1}],["NET INCOME",Qc(Z.net_income,"")],ie)}if(T==="cash_flow")return gt("CASH FLOW FORECAST",(Z.projections||[]).map(function(ne){return{month:"+"+ne.month+"mo",inflow:Number(ne.income)||0,outflow:Number(ne.expenses)||0,net:Number(ne.net)||0}}),[{key:"month",flex:1},{key:"inflow",flex:1},{key:"outflow",flex:1},{key:"net",flex:1}],null,Hr.blue);if(T==="payables")return gt("OUTSTANDING PAYABLES ("+(Z.count||0)+")",(Z.invoices||[]).map(function(ne){return{vendor:ne.vendor,invoice_id:ne.invoice_number||ne.invoice_id||"",amount:Number(ne.outstanding)||0,due:ne.due_date||"—",overdue:Bh(ne.due_date)+"d"}}),[{key:"vendor",flex:2},{key:"invoice_id",flex:1},{key:"amount",flex:1},{key:"due",flex:1},{key:"overdue",flex:1}],["TOTAL OUTSTANDING","",Qc(Z.total,""),"",""],Hr.red);if(T==="budget_vs_actual")return gt("BUDGET VS ACTUAL"+(Z.period?" — "+Z.period:""),(Z.data||[]).map(function(ne){return{category:ne.category||ne.account_code,budget:Number(ne.budgeted)||0,actual:Number(ne.actual)||0,variance:Number(ne.variance)||0,pct:ne.utilisation_pct!=null?Number(ne.utilisation_pct).toFixed(1)+"%":"—"}}),[{key:"category",flex:2},{key:"budget",flex:1},{key:"actual",flex:1},{key:"variance",flex:1},{key:"pct",flex:1}],null,Hr.purple);if(T==="crypto_summary"||T==="market_snapshot"||T==="quote"){var ue=JSON.stringify(Z,null,2);return i.createElement("div",{style:{background:"#06080F",border:"1px solid #1A2332",borderRadius:6,padding:14,marginTop:4}},i.createElement("div",{style:{fontFamily:Wr,fontSize:10,fontWeight:700,color:Hr.purple,letterSpacing:".1em",marginBottom:8}},T.toUpperCase().replace(/_/g," ")),i.createElement("pre",{style:{fontFamily:Wr,fontSize:10,color:Hr.txt,margin:0,whiteSpace:"pre-wrap",maxHeight:300,overflow:"auto",lineHeight:1.6}},ue.substring(0,3e3)))}return i.createElement("div",{style:{fontFamily:Wr,fontSize:10,color:Hr.dim,padding:8}},"Unknown data card type: "+T)}var Pt=x?hf[x]:null,Kt=Pt?Pt.color:Hr.orange,xe=Pt?Pt.label:"ALL DEPARTMENTS",fe=X9.filter(function(H){if(!k)return!0;var Z=hf[H],T=k.toLowerCase();return Z.label.toLowerCase().indexOf(T)>=0||Z.desc.toLowerCase().indexOf(T)>=0||Z.commands.some(function(Y){return Y.label.toLowerCase().indexOf(T)>=0})}),Ye=Pt?Pt.commands:[{label:"Portfolio NAV",prompt:"portfolio NAV and allocation breakdown"},{label:"Risk snapshot",prompt:"portfolio risk assessment VaR max drawdown Sharpe"},{label:"Market snapshot",prompt:"global market snapshot"},{label:"Morning brief",prompt:"morning intelligence brief"},{label:"Research memo",prompt:"generate research memo"},{label:"Vault search",prompt:"search vault for risk documents"}],Qe={display:"flex",gap:12,padding:"14px 0",borderBottom:"1px solid #0D1117"},ut={width:38,height:38,background:"url(/brand/xyron-monogram.png) center/contain no-repeat",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:Wr,fontSize:0,color:"transparent",flexShrink:0,filter:"drop-shadow(0 2px 10px rgba(212,175,92,0.35))"},wt={width:32,height:32,borderRadius:"50%",background:"linear-gradient(135deg,#5A7090,#3A4A5E)",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:Wr,fontSize:8,fontWeight:700,color:"#E6EDF3",flexShrink:0};return i.createElement("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:50,background:Hr.bg,display:"flex",flexDirection:"column",overflow:"hidden",animation:"vidSlideUp 0.2s ease-out"}},i.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px",borderBottom:"1px solid #1C2740",background:"#06080D",flexShrink:0}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:10}},i.createElement("div",{style:{width:8,height:8,borderRadius:"50%",background:Kt,boxShadow:"0 0 8px rgba("+Co(Kt)+",0.4)"}}),i.createElement("span",{style:{fontFamily:Wr,fontSize:10,fontWeight:700,color:Kt,letterSpacing:".14em"}},"COMMAND INTELLIGENCE"),Pt&&i.createElement("span",{style:{fontFamily:Wr,fontSize:8,color:Kt,padding:"2px 6px",border:"1px solid rgba("+Co(Kt)+",0.3)",borderRadius:3,background:"rgba("+Co(Kt)+",0.06)"}},xe),i.createElement("span",{style:{fontFamily:Wr,fontSize:7,color:Hr.dim,letterSpacing:".1em"}},"XYRON")),i.createElement("button",{onClick:t,style:{background:"transparent",border:"1px solid #1C2740",borderRadius:4,padding:"4px 12px",cursor:"pointer",fontFamily:Wr,fontSize:8,color:"#5A7090",letterSpacing:".08em"}},"✕ CLOSE")),i.createElement("div",{style:{flex:1,display:"flex",overflow:"hidden"}},i.createElement("div",{style:{width:180,borderRight:"1px solid #111820",display:"flex",flexDirection:"column",flexShrink:0,overflow:"hidden"}},i.createElement("div",{style:{padding:"8px 10px",borderBottom:"1px solid #111820"}},i.createElement("input",{value:k,onChange:function(H){A(H.target.value)},placeholder:"Filter…",style:{width:"100%",background:"#0A0E16",border:"1px solid #1A2332",borderRadius:4,padding:"6px 8px",color:"#C9D1D9",fontFamily:Wr,fontSize:9,outline:"none",boxSizing:"border-box"}})),i.createElement("div",{style:{flex:1,overflowY:"auto",padding:"4px 0"}},i.createElement("button",{onClick:function(){v(null)},style:{display:"flex",alignItems:"center",gap:6,width:"100%",padding:"7px 10px",background:x?"transparent":"rgba(212,175,92,0.06)",border:"none",borderLeft:x?"2px solid transparent":"2px s
437olid "+Hr.orange,cursor:"pointer",textAlign:"left"}},i.createElement("span",{style:{fontFamily:Wr,fontSize:9,fontWeight:700,color:x?Hr.dim:Hr.orange,letterSpacing:".08em"}},"ALL")),fe.map(function(H){var Z=hf[H],T=x===H;return i.createElement("button",{key:H,onClick:function(){v(x===H?null:H)},style:{display:"flex",alignItems:"center",gap:6,width:"100%",padding:"7px 10px",background:T?"rgba("+Co(Z.color)+",0.06)":"transparent",border:"none",borderLeft:T?"2px solid "+Z.color:"2px solid transparent",cursor:"pointer",textAlign:"left"},onMouseEnter:function(Y){T||(Y.currentTarget.style.background="rgba("+Co(Z.color)+",0.03)")},onMouseLeave:function(Y){T||(Y.currentTarget.style.background="transparent")}},i.createElement("span",{style:{fontSize:11,color:Z.color,width:16,textAlign:"center",flexShrink:0}},Z.icon),i.createElement("span",{style:{fontFamily:Wr,fontSize:8,fontWeight:T?700:400,color:T?Z.color:"#7A8A9E",letterSpacing:".06em",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},Z.label))}))),i.createElement("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"}},i.createElement("div",{ref:O,style:{flex:1,overflowY:"auto",padding:"0 20px"}},c.map(function(H){if(H.role==="user")return i.createElement("div",{key:H.id,style:Qe},i.createElement("div",{style:wt},"YOU"),i.createElement("div",{style:{flex:1,minWidth:0}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6}},i.createElement("span",{style:{fontFamily:Wr,fontWeight:700,fontSize:11,color:"#8B949E",letterSpacing:".1em"}},"PRINCIPAL"),H.ts&&i.createElement("span",{style:{fontFamily:Wr,fontSize:8,color:"#5A6880",marginLeft:"auto"}},H.ts)),i.createElement("p",{style:{margin:0,color:"#E6EDF3",fontSize:14,lineHeight:1.65}},H.text)));if(H.role==="system"){var Z=E===H.id;return i.createElement("div",{key:H.id,style:Qe},i.createElement("div",{style:ut},"X"),i.createElement("div",{style:{flex:1,minWidth:0}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6}},i.createElement("span",{style:{fontFamily:Wr,fontWeight:700,fontSize:11,color:Kt,letterSpacing:".1em"}},"XYRON"),i.createElement("span",{style:{fontFamily:Wr,fontSize:9,color:"#7A8A9E",padding:"2px 6px",border:"1px solid #2A3548",borderRadius:3}},"COMMAND AGENT"),Z&&i.createElement("span",{style:{fontFamily:Wr,fontSize:8,color:Hr.orange,animation:"xpulse 1s infinite"}},"streaming"),H.ts&&i.createElement("span",{style:{fontFamily:Wr,fontSize:8,color:"#5A6880",marginLeft:"auto"}},H.ts)),Z?i.createElement("div",{ref:M,style:{color:"#C9D1D9",fontSize:14,lineHeight:1.65,minHeight:20}}):i.createElement("div",{style:{color:"#C9D1D9",fontSize:14,lineHeight:1.65},dangerouslySetInnerHTML:{__html:ae(H.text||"")}})))}if(H.role==="analysis"){var T=E===H.id,Y=Hr.blue;return i.createElement("div",{key:H.id,style:Qe},i.createElement("div",{style:Object.assign({},ut,{background:"linear-gradient(135deg,"+Y+","+Y+"CC)"})},"X"),i.createElement("div",{style:{flex:1,minWidth:0}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8}},i.createElement("span",{style:{fontFamily:Wr,fontWeight:700,fontSize:11,color:Y,letterSpacing:".1em"}},"XYRON"),i.createElement("span",{style:{fontFamily:Wr,fontSize:8,color:Y,background:"rgba("+Co(Y)+",0.08)",border:"1px solid rgba("+Co(Y)+",0.25)",borderRadius:3,padding:"2px 6px"}},(H.persona||"INTELLIGENCE").toUpperCase()),T&&i.createElement("span",{style:{fontFamily:Wr,fontSize:8,color:Hr.orange,animation:"xpulse 1s infinite"}},"streaming"),H.ts&&i.createElement("span",{style:{fontFamily:Wr,fontSize:8,color:"#5A6880",marginLeft:"auto"}},H.ts)),i.createElement("div",{style:{borderLeft:"2px solid rgba("+Co(Y)+",0.25)",paddingLeft:14}},T?i.createElement("div",{ref:M,style:{fontSize:13.5,color:"#C9D1D9",lineHeight:1.75,minHeight:20}}):i.createElement("div",{style:{fontSize:13.5,color:"#C9D1D9",lineHeight:1.75},dangerouslySetInnerHTML:{__html:ae(H.text||"")}}))))}return H.role==="data"?i.createElement("div",{key:H.id,style:{padding:"10px 0 10px 44px"}},qt(H)):H.role==="actions"?i.createElement("div",{key:H.id,style:{padding:"8px 0 8px 44px"}},i.createElement("div",{style:{display:"flex",flexWrap:"wrap",gap:5}},(H.actions||[]).map(function(B,ie){var ue=Kt;return i.createElement("button",{key:ie,onClick:function(){pt(B)},disabled:g,style:{padding:"5px 12px",background:g?"#1A1F2B":"rgba("+Co(ue)+",0.06)",border:"1px solid "+(g?"#2A3548":"rgba("+Co(ue)+",0.2)"),borderRadius:5,cursor:g?"not-allowed":"pointer",fontFamily:Wr,fontSize:9,fontWeight:600,color:g?"#3A4A5E":ue,transition:"all .12s",whiteSpace:"nowrap"},onMouseEnter:function(ne){g||(ne.currentTarget.style.background="rgba("+Co(ue)+",0.14)")},onMouseLeave:function(ne){g||(ne.currentTarget.style.background="rgba("+Co(ue)+",0.06)")}},B.label)}))):null})),i.createElement("div",{style:{padding:"8px 20px 6px",borderTop:"1px solid #111820",display:"flex",flexWrap:"wrap",gap:4,flexShrink:0}},Ye.map(function(H){return i.createElement("button",{key:H.label,onClick:function(){tn(H.prompt)},disabled:g,style:{padding:"4px 10px",background:"rgba("+Co(Kt)+",0.04)",border:"1px solid rgba("+Co(Kt)+",0.15)",borderRadius:4,cursor:"pointer",fontFamily:Wr,fontSize:8,color:g?Hr.dim:Kt,transition:"all .12s"},onMouseEnter:function(Z){g||(Z.currentTarget.style.borderColor="rgba("+Co(Kt)+",0.4)")},onMouseLeave:function(Z){Z.currentTarget.style.borderColor="rgba("+Co(Kt)+",0.15)"}},H.label)})))))}var vg=["PERSONAL","ACCOUNTING","RELATIONSHIP"];function $9(){return vg.slice()}function J9(t,n,r,o,a){return["cal-events",t||"anonymous",n,r,(o||[]).slice().sort().join(","),a]}async function Q9(t,{owner:n,signal:r}){const o=new URLSearchParams({event_id:t.event_id,event_time:t.event_time}),a=new AbortController,l=()=>a.abort();r?.aborted&&l(),r?.addEventListener("abort",l,{once:!0});let s=!1;const c=setTimeout(()=>{s=!0,l()},12e3);try{const d=await Oa("/api/calendar/market/event?"+o,{signal:a.signal},n);if(!d.ok)throw new Error(d.status===404?"This event is no longer available.":"Event details are temporarily unavailable.");const p=await d.json();if(El()!==n||a.signal.aborted)throw new DOMException("Account or selection changed","AbortError");return p}catch(d){throw s?new Error("Event details timed out. Please retry."):d}finally{clearTimeout(c),r?.removeEventListener("abort",l)}}function Z9(t,{owner:n,signal:r,perspective:o,...a}
437){return Ry({url:"/api/calendar/market/event/explain",signal:r,fetchResponse:()=>Oa("/api/calendar/market/event/explain",{method:"POST",signal:r,body:JSON.stringify({event_id:t.event_id,event_time:t.event_time,perspective:o})},n),...a})}var e3=(0,i.lazy)(()=>xi(()=>import("./SecurityMasterPage-B4bdMHZv.js"),__vite__mapDeps([11,12,1,0,2,13,14,15,5,6,7,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]))),t3=t=>t!=null&&t!=="",Op=t=>String(t??"").replace(/\b(FMP|AlphaFlash)\b/gi,"").trim(),n3=t=>Op(t).replace(/^(-?)(\d+)(\.\d+)?$/,(n,r,o,a="")=>r+o.replace(/\B(?=(\d{3})+(?!\d))/g,",")+a);function iS(t,n){const r=new Date(t);return!t||Number.isNaN(r.getTime())?"Time unavailable":new Intl.DateTimeFormat("en-GB",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",timeZone:n||void 0,timeZoneName:"short"}).format(r)}function oS(t){const n=t.event_type==="ECON"?[["Previous",t.previous],["Consensus",t.consensus],["Forecast",t.forecast],["Actual",t.actual],["Surprise",t.surprise]]:t.event_type==="EARNINGS"?[["EPS estimate",t.consensus],["EPS reported",t.actual],["EPS surprise",t.surprise]]:t.event_type==="DIVIDEND"?[["Dividend per share",t.actual]]:t.event_type==="SPLIT"?[["Split ratio",t.actual]]:[],r=new Map(n);for(const o of t.fields||[])r.set(o.label,o.value);return[...r]}function r3({event:t,owner:n,zone:r,onClose:o}){const a=(0,i.useRef)(null),l=(0,i.useRef)(null),s=(0,i.useRef)(null),c=(0,i.useRef)(null),[d,p]=(0,i.useState)(!1),[g,f]=(0,i.useState)(null),[h,x]=(0,i.useState)({state:"idle",text:"",error:""}),v=TS({queryKey:["market-event-details",n,t.event_id,t.event_time],queryFn:({signal:C})=>Q9(t,{owner:n,signal:C}),enabled:n!=="anonymous"&&n!=="unreadable",staleTime:3e4,gcTime:0,retry:!1}),y=g?.event||v.data?.event||t,k=g?.relevance||v.data?.relevance,A=n!=="anonymous"&&n!=="unreadable";(0,i.useEffect)(()=>(a.current?.focus(),()=>c.current?.abort()),[]),(0,i.useEffect)(()=>{function C(_){if(_.key==="Tab"&&!d&&window.matchMedia?.("(max-width: 600px)").matches){const w=[...l.current.querySelectorAll("button:not(:disabled)")],O=w[0],M=w[w.length-1];_.shiftKey&&document.activeElement===O?(_.preventDefault(),M.focus()):!_.shiftKey&&document.activeElement===M&&(_.preventDefault(),O.focus())}_.key==="Escape"&&(_.preventDefault(),_.stopImmediatePropagation(),d?(p(!1),s.current?.focus()):o())}return window.addEventListener("keydown",C,!0),()=>window.removeEventListener("keydown",C,!0)},[o,d]);async function j(C){c.current?.abort();const _=new AbortController;c.current=_;const w=()=>!_.signal.aborted&&El()===n&&c.current===_;x({state:"loading",text:"",error:""});const O=setTimeout(()=>{w()&&x(M=>({...M,state:"error",error:"The explanation timed out. Please retry."})),_.abort()},14e3);try{await Z9(t,{owner:n,signal:_.signal,perspective:C,onEvent:M=>{w()&&M.type==="event_detail"&&f({event:M.event,relevance:M.relevance})},onDelta:(M,U)=>{w()&&x({state:"loading",text:Op(U),error:""})},onDone:({evt:M,fullText:U})=>{w()&&(M&&U.trim()?x({state:"done",text:Op(U),error:""}):x(ee=>({...ee,state:"error",error:"The explanation was interrupted. Please retry."})))},onError:()=>{w()&&x(M=>({...M,state:"error",error:"The explanation is temporarily unavailable. Please retry."}))}})}catch{w()&&x(M=>({...M,state:"error",error:"The explanation is temporarily unavailable. Please retry."}))}finally{clearTimeout(O)}}const E=y.time_precision==="date"||y.time_precision==="session"?`${y.event_date} · ${y.session||"Exact time unavailable"}`:iS(y.event_time,r);return(0,Uy.createPortal)((0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("aside",{ref:l,className:"market-event-detail","aria-label":"Event details",style:{"--detail-bg":vt.bg1,"--detail-border":vt.b2,"--detail-text":vt.t2,"--detail-muted":vt.t3,"--detail-accent":vt.amber,fontFamily:Tf},children:[(0,e.jsxs)("header",{className:"market-event-detail-header",children:[(0,e.jsx)("span",{style:{fontFamily:vr},children:"EVENT DETAILS"}),(0,e.jsx)("button",{ref:a,onClick:o,"aria-label":"Close event details",children:"✕"})]}),(0,e.jsxs)("div",{className:"market-event-detail-body",children:[(0,e.jsx)("div",{className:"market-event-detail-tags",children:[y.event_type,y.country,y.impact&&`${y.impact}
437 impact`].filter(Boolean).map(C=>(0,e.jsx)("span",{children:C},C))}),(0,e.jsx)("h2",{children:Op(y.title)||"Market event"}),(0,e.jsx)("p",{className:"market-event-detail-date",children:E}),y.time_precision==="session"&&(0,e.jsx)("p",{className:"market-event-detail-muted",children:"Reporting session; exact release time is unavailable."}),y.status&&(0,e.jsx)("span",{className:"market-event-detail-status",children:y.status}),v.isFetching&&(0,e.jsx)("p",{role:"status",children:"Loading further details…"}),v.isError&&(0,e.jsxs)("div",{className:"market-event-detail-error",role:"alert",children:[v.error.message," ",(0,e.jsx)("button",{onClick:()=>v.refetch(),children:"Retry details"})]}),!A&&(0,e.jsx)("p",{role:"status",children:"Sign in to see further details and your portfolio relevance."}),oS(y).length>0&&(0,e.jsxs)("section",{"aria-label":"Event figures",children:[(0,e.jsx)("h3",{children:"Figures & dates"}),(0,e.jsx)("dl",{className:"market-event-detail-figures",children:oS(y).map(([C,_])=>(0,e.jsxs)("div",{children:[(0,e.jsx)("dt",{children:C}),(0,e.jsx)("dd",{children:t3(_)?n3(_):"Not available"})]},C))})]}),y.description&&(0,e.jsxs)("section",{children:[(0,e.jsx)("h3",{children:"About this event"}),(0,e.jsx)("p",{children:Op(y.description)})]}),(0,e.jsxs)("section",{"aria-label":"Portfolio relevance",children:[(0,e.jsx)("h3",{children:"Your portfolio & watchlist"}),k?(0,e.jsxs)(e.Fragment,{children:[k.matches.map(C=>(0,e.jsxs)("div",{className:"market-event-detail-match",children:[(0,e.jsx)("strong",{children:C.symbol}),(0,e.jsx)("span",{children:C.sources.map(_=>_==="portfolio"?"In your portfolio":"On your watchlist").join(" · ")})]},C.symbol)),(0,e.jsx)("p",{className:"market-event-detail-muted",children:k.message})]}):(0,e.jsx)("p",{className:"market-event-detail-muted",children:v.isFetching?"Checking direct symbol matches…":"Relevance has not been loaded."}),y.security_symbol&&(0,e.jsxs)("button",{ref:s,onClick:()=>p(!0),children:["View ",y.security_symbol," ↗"]})]}),(0,e.jsxs)("section",{"aria-label":"Event explanation",children:[(0,e.jsx)("h3",{children:"Understand the event"}),(0,e.jsxs)("div",{className:"market-event-detail-actions",children:[(0,e.jsx)("button",{disabled:!v.data||h.state==="loading",onClick:()=>j("event"),children:"Explain this event"}),(0,e.jsx)("button",{disabled:!v.data||h.state==="loading",onClick:()=>j("portfolio"),children:"Portfolio impact"})]}),h.state==="idle"&&(0,e.jsx)("p",{className:"market-event-detail-muted",children:"Request an explanation of these figures or their possible relevance to your holdings."}),h.state==="loading"&&(0,e.jsx)("p",{role:"status",children:h.text?"Writing explanation…":"Preparing explanation…"}),h.text&&(0,e.jsx)("p",{className:"market-event-detail-explanation",children:h.text}),h.error&&(0,e.jsx)("p",{className:"market-event-detail-error",role:"alert",children:h.error})]}),(0,e.jsx)("footer",{className:"market-event-detail-muted",children:y.updated_at?`Data updated ${iS(y.updated_at,r)}`:"Update time unavailable"})]})]}),d&&(0,e.jsx)("div",{className:"market-event-detail-asset",children:(0,e.jsx)(i.Suspense,{fallback:(0,e.jsxs)("div",{className:"market-event-detail-asset-loading",children:[(0,e.jsxs)("p",{children:["Loading ",y.security_symbol,"…"]}),(0,e.jsx)("button",{onClick:()=>{p(!1),s.current?.focus()},children:"Back to event"})]}),children:(0,e.jsx)(e3,{symbol:y.security_symbol,onClose:()=>{p(!1),s.current?.focus()}})})})]}),document.body)}var i3=[["ECON","ECON"],["EARNINGS","EARN"],["DIVIDEND","DIV"],["IPO","IPO"],["SPLIT","SPLIT"]],o3=[["CRITICAL","CRIT"],["HIGH","HIGH"],["MEDIUM","MED"],["LOW","LOW"]],a3=[["US","US"],["UK","UK"],["Europe","EUROPE"],["Middle East","MIDDLE EAST"],["Asia","ASIA"],["North America","NORTH AMERICA"]],aS="xyron_market_cal_tz",ef=[["UTC","UTC","UTC"],["local","LOCAL",null],["NY","NY","America/New_York"],["LDN","LONDON","Europe/London"],["DXB","DUBAI","Asia/Dubai"],["TYO","TOKYO","Asia/Tokyo"]],l3=[["day","DAY"],["week","WEEK"],["agenda","AGENDA"]];function lS(t){var n=(t||"").toUpperCase();return n==="CRITICAL"?vt.red:n==="HIGH"?vt.orange:n==="MEDIUM"?vt.blue:vt.t4}function sS(t){var n=(t||"").toUpperCase();return n==="ECON"?vt.teal:n==="EARNINGS"?vt.amber:n==="DIVIDEND"?vt.green:n==="IPO"?vt.purple:vt.t4}function wp(t){return t==null||t===""?"—":typeof t=="number"?Math.abs(t)>=1e12?(t/1e12).toFixed(2)+"T":Math.abs(t)>=1e9?(t/1e9).toFixed(2)+"B":Math.abs(t)>=1e6?(t/1e6).toFixed(2)+"M":Math.abs(t)>
437=1e3?t.toLocaleString():Math.abs(t)<10?t.toFixed(2):t.toFixed(1):String(t)}function s3(t){if(t==null||t==="")return vt.t5;var n=parseFloat(t);return isNaN(n)||n===0?vt.t4:n>0?vt.green:vt.red}function c3(t,n){if(!t)return"—";try{var r=new Date(t);if(isNaN(r.getTime()))return String(t).slice(0,16);var o={month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1};n&&(o.timeZone=n);var a=new Intl.DateTimeFormat("en-US",o).formatToParts(r),l={};return a.forEach(function(s){l[s.type]=s.value}),(l.month||"").toUpperCase()+" "+(l.day||"")+"  "+(l.hour||"")+":"+(l.minute||"")}catch{return String(t).slice(0,16)}}function d3(t){var n=new Date(new Date);n.setHours(0,0,0,0);var r=new Date(n);return t==="day"?r.setDate(r.getDate()+1):t==="week"?r.setDate(r.getDate()+7):r.setDate(r.getDate()+30),{start:n.toISOString(),end:r.toISOString()}}function Tp(t){var n=t.on,r=t.accent||vt.amber;return(0,e.jsx)("button",{onClick:t.onClick,style:{padding:"2px 7px",fontSize:7,fontFamily:vr,fontWeight:700,background:n?r+"18":"transparent",border:"1px solid "+(n?r+"55":vt.b3),color:n?r:vt.t5,borderRadius:2,cursor:"pointer",letterSpacing:".04em"},children:t.label})}function u3(t){var n=t.defaultTypes||[];const r=Iy(),[o,a]=(0,i.useState)(null),l=(0,i.useRef)(null);(0,i.useEffect)(()=>{a(null)},[r]);const s=(0,i.useCallback)(()=>{a(null),l.current?.focus({preventScroll:!0})},[]);function c(re,we){l.current=we,a({event:re,owner:r})}var d=(0,i.useState)(function(){var re={};return n.forEach(function(we){re[we]=!0}),re}),p=d[0],g=d[1],f=(0,i.useState)({}),h=f[0],x=f[1],v=(0,i.useState)(""),y=v[0],k=v[1],A=(0,i.useState)(""),j=A[0],E=A[1],C=(0,i.useState)(""),_=C[0],w=C[1],O=(0,i.useState)(""),M=O[0],U=O[1],ee=(0,i.useState)("week"),N=ee[0],V=ee[1],z=(0,i.useState)(function(){try{var re=localStorage.getItem(aS);if(re){for(var we=0;we<ef.length;we++)if(ef[we][0]===re)return re}}catch{}return"UTC"}),oe=z[0],P=z[1];function W(re){P(re);try{localStorage.setItem(aS,re)}catch{}}var R=(0,i.useRef)(null);(0,i.useEffect)(function(){return R.current&&clearTimeout(R.current),R.current=setTimeout(function(){U(_.trim().toUpperCase())},300),function(){R.current&&clearTimeout(R.current)}},[_,U]);var ae=(0,i.useMemo)(function(){return Object.keys(p).filter(function(re){return p[re]})},[p]),q=(0,i.useMemo)(function(){return Object.keys(h).filter(function(re){return h[re]})},[h]),ge=(0,i.useMemo)(function(){return d3(N)},[N]),X=(0,i.useMemo)(function(){for(var re=0;re<ef.length;re++)if(ef[re][0]===oe)return ef[re][2];return"UTC"},[oe]),de=ae.slice().sort().join(","),We=q.slice().sort().join(","),te=jS({queryKey:["market-cal",ge.start,ge.end,de,We,y,j,M],initialPageParam:null,getNextPageParam:function(re){return re.next_cursor||void 0},queryFn:function({pageParam:re}){return No.marketEvents({start:ge.start,end:ge.end,types:ae,impact:q,region:y||void 0,country:j||void 0,symbol:M||void 0,cursor:re})},staleTime:6e4,refetchInterval:12e4}),_e=(0,i.useMemo)(function(){var re=te.data;return re?re.pages.flatMap(function(we){return Array.isArray(we.events)?we.events:[]}):[]},[te.data]);function ve(re){var we=Object.assign({},p);we[re]=!we[re],g(we)}function Ne(re){var we=Object.assign({},h);we[re]=!we[re],x(we)}var $e=[{k:"time",label:"TIME",w:118},{k:"region",label:"REGION",w:88},{k:"country",label:"CTRY",w:44},{k:"event",label:"EVENT / SYMBOL",w:0},{k:"type",label:"TYPE",w:66},{k:"impact",label:"IMPACT",w:66},{k:"previous",label:"PREVIOUS",w:72,right:!0},{k:"consensus",label:"CONSENSUS",w:76,right:!0},{k:"forecast",label:"FORECAST",w:72,right:!0},{k:"actual",label:"ACTUAL",w:68,right:!0},{k:"surprise",label:"SURPRISE",w:74,right:!0}],Pe=te.isLoading,ot=te.isError;return(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",flex:1,minHeight:0,overflow:"auto",fontFamily:vr},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 10px",borderBottom:"1px solid "+vt.b2,background:"#04040c",flexShrink:0},children:[(0,e.jsx)("span",{style:{fontSize:9,color:vt.amber,fontFamily:vr,fontWeight:700,letterSpacing:".08em"},children:"MARKET CALENDAR"}),(0,e.jsxs)("span",{style:{fontSize:8,color:vt.t5,fontFamily:vr,marginLeft:"auto"},children:[_e.length," events"]})]}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5px 10px",borderBottom:"1px solid "+vt.b2,background:"#030308",flexShrink:0,flexWrap:"wrap"},children:[(0,e.jsx)("span",{style:{fontSize:7,color:vt.t5,fontFamily:vr,letterSpacing:".06em"},children:"RANGE"}),l3.map(function(re){return(0,e.jsx)(Tp,{label:re[1],on:N===re[0],accent:vt.teal,onClick:function(){V(re[0])}},re[0])}),(0,e.jsx)("span",{style:{fontSize:7,color:vt.t5,fontFamily:vr,letterSpacing:".06em",marginLeft:8},children:"TZ"}),ef.map(function(re){return(0,e.jsx)(Tp,{label:re[1],on:oe===re[0],accent:vt.blue,onClick:function(){W(re[0])}},re[0])})]}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5px 10px",borderBottom:"1px solid "+vt.b2,background:"#030308",flexShrink:0,flexWrap:"wrap"},children:[(0,e.jsx)("span",{style:{fontSize:7,color:vt.t5,fontFamily:vr,letterSpacing:".06em"},children:"TYPE"}),i3.map(function(re){return(0,e.jsx)(Tp,{label:re[1],on:!!p[re[0]],accent:sS(re[0]),onClick:function(){ve(re[0])}},re[0])}),(0,e.jsx)("span",{style:{fontSize:7,color:vt.t5,fontFamily:vr,letterSpacing:".06em",marginLeft:8},children:"IMPACT"}),o3.map(function(re){return(0,e.jsx)(Tp,{label:re[1],on:!!h[re[0]],accent:lS(re[0]),onClick:function(){Ne(re[0])}},re[0])}),(0,e.jsx)("span",{style:{fontSize:7,color:vt.t5,fontFamily:vr,letterSpacing:".06em",marginLeft:8},children:"REGION"}),a3.map(function(re){var we=y===re[0];return(0,e.jsx)(Tp,{label:re[1],on:we,accent:vt.amber,onClick:function(){k(we?"":re[0])}},re[0])}),(0,e.jsx)("input",{value:j,onChange:function(re){E(re.target.value.toUpperCase().slice(0,4))},placeholder:"CTRY",style:{width:52,marginLeft:8,padding:"2px 6px",fontSize:7,fontFamily:vr,fontWeight:700,background:"transparent",border:"1px solid "+vt.b3,color:vt.t2,borderRadius:2,letterSpacing:".04em",outline:"none"}}
437),(0,e.jsx)("input",{value:_,onChange:function(re){w(re.target.value)},placeholder:"SYMBOL",style:{width:88,marginLeft:6,padding:"2px 6px",fontSize:7,fontFamily:vr,fontWeight:700,background:"transparent",border:"1px solid "+vt.b3,color:vt.t2,borderRadius:2,letterSpacing:".04em",outline:"none"}})]}),(0,e.jsx)("div",{style:{display:"flex",minWidth:1040,boxSizing:"border-box",padding:"5px 10px",background:"#04040c",borderBottom:"1px solid "+vt.b2,flexShrink:0},children:$e.map(function(re){return(0,e.jsx)("div",{style:{flex:re.w?"0 0 "+re.w+"px":1,minWidth:0,fontSize:9,color:vt.t5,fontFamily:vr,fontWeight:700,letterSpacing:".07em",textAlign:re.right?"right":"left"},children:re.label},re.k)})}),(0,e.jsxs)("div",{style:{flex:1,overflowY:"auto",minWidth:1040},children:[Pe&&(0,e.jsx)("div",{"data-testid":"market-cal-skeleton",children:[0,1,2,3,4,5,6,7].map(function(re){return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",padding:"6px 10px",borderBottom:"1px solid "+vt.b1,opacity:1-re*.08},children:[(0,e.jsx)("div",{style:{height:8,background:vt.b2,borderRadius:2,flex:"0 0 96px",marginRight:12}}),(0,e.jsx)("div",{style:{height:8,background:vt.b2,borderRadius:2,flex:1,marginRight:12}}),(0,e.jsx)("div",{style:{height:8,background:vt.b2,borderRadius:2,flex:"0 0 220px"}})]},re)})}),!Pe&&ot&&(0,e.jsxs)("div",{"data-testid":"market-cal-error",style:{padding:28,textAlign:"center",color:vt.red,fontSize:10,fontFamily:"'Berkeley Mono', 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace",lineHeight:1.6},children:[(0,e.jsx)("div",{style:{fontWeight:700,letterSpacing:".04em"},children:"Market calendar temporarily unavailable"}),(0,e.jsx)("button",{onClick:function(){te.refetch()},style:{marginTop:10,padding:"3px 12px",fontSize:8,fontFamily:"'Berkeley Mono', 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace",fontWeight:700,background:"transparent",border:"1px solid "+vt.red+"77",color:vt.red,borderRadius:2,cursor:"pointer",letterSpacing:".06em"},children:"RETRY"})]}),!Pe&&!ot&&_e.length===0&&(0,e.jsx)("div",{"data-testid":"market-cal-empty",style:{padding:28,textAlign:"center",color:vt.t4,fontSize:10,fontFamily:"'Berkeley Mono', 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace",lineHeight:1.5},children:"No events — source coverage may be pending for this region"}),!Pe&&_e.map(function(re,we){var b=lS(re.impact),He=sS(re.event_type),tt=s3(re.surprise),Ae=re.title||re.symbol||"—";return(0,e.jsxs)("div",{"data-testid":"market-cal-row",role:"button",tabIndex:0,"aria-label":"View details for "+Ae,"aria-expanded":o?.owner===r&&o?.event.event_id===re.event_id,onClick:Be=>c(re,Be.currentTarget),onKeyDown:Be=>{(Be.key==="Enter"||Be.key===" ")&&(Be.preventDefault(),c(re,Be.currentTarget))},onMouseEnter:function(Be){Be.currentTarget.style.background="#0a0a14"},onMouseLeave:function(Be){Be.currentTarget.style.background="transparent"},style:{display:"flex",alignItems:"center",padding:"4px 10px",borderBottom:"1px solid "+vt.b1,transition:"background .1s",cursor:"pointer"},children:[(0,e.jsx)("div",{style:{flex:"0 0 118px",fontSize:10,color:vt.t3,fontFamily:"'Berkeley Mono', 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace"},children:c3(re.event_time,X)}),(0,e.jsx)("div",{style:{flex:"0 0 88px",fontSize:9,color:vt.t4,fontFamily:"'Berkeley Mono', 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",paddingRight:4},children:re.region||"—"}),(0,e.jsx)("div",{style:{flex:"0 0 44px",fontSize:10,color:vt.amber,fontFamily:"'Berkeley Mono', 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace",fontWeight:700},children:(re.country||"—").toUpperCase()}),(0,e.jsx)("div",{style:{flex:1,minWidth:0,fontSize:10,color:vt.t2,fontFamily:"'Inter Tight', 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",paddingRight:6},children:re.symbol&&re.title?(0,e.jsxs)("span",{children:[(0,e.jsx)("span",{style:{color:vt.amber,fontFamily:"'Berkeley Mono', 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace",fontWeight:800,letterSpacing:".04em"},children:re.symbol}),"  "+re.title]}):Ae}),(0,e.jsx)("div",{style:{flex:"0 0 66px",fontSize:8,color:He,fontFamily:"'Berkeley Mono', 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace",fontWeight:700,letterSpacing:".04em"},children:(re.event_type||"—").toUpperCase()}),(0,e.jsx)("div",{style:{flex:"0 0 66px",fontSize:8,color:b,fontFamily:"'Berkeley Mono', 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace",fontWeight:700,letterSpacing:".04em"},children:(re.impact||"—").toUpperCase()}
437),(0,e.jsx)("div",{style:{flex:"0 0 72px",fontSize:10,color:vt.t4,fontFamily:"'Berkeley Mono', 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace",textAlign:"right"},children:wp(re.previous)}),(0,e.jsx)("div",{style:{flex:"0 0 76px",fontSize:10,color:vt.t3,fontFamily:"'Berkeley Mono', 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace",textAlign:"right"},children:wp(re.consensus)}),(0,e.jsx)("div",{style:{flex:"0 0 72px",fontSize:10,color:vt.t3,fontFamily:"'Berkeley Mono', 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace",textAlign:"right"},children:wp(re.forecast)}),(0,e.jsx)("div",{style:{flex:"0 0 68px",fontSize:10,color:re.actual!==null&&re.actual!==void 0&&re.actual!==""?vt.t1:vt.t5,fontFamily:"'Berkeley Mono', 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace",fontWeight:700,textAlign:"right"},children:wp(re.actual)}),(0,e.jsx)("div",{"data-testid":"market-cal-surprise",style:{flex:"0 0 74px",fontSize:10,color:tt,fontFamily:"'Berkeley Mono', 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace",fontWeight:700,textAlign:"right"},children:re.surprise!==null&&re.surprise!==void 0&&re.surprise!==""?(parseFloat(re.surprise)>=0?"+":"")+wp(re.surprise):"—"})]},re.event_id||we)}),te.hasNextPage&&(0,e.jsx)("button",{onClick:()=>te.fetchNextPage(),disabled:te.isFetchingNextPage,style:{margin:12,padding:"6px 12px",fontFamily:"'Berkeley Mono', 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:10,background:"transparent",border:"1px solid "+vt.b2,borderRadius:2,color:vt.blue,cursor:te.isFetchingNextPage?"wait":"pointer"},children:te.isFetchingNextPage?"Loading…":"LOAD MORE EVENTS"})]}),o?.owner===r&&(0,e.jsx)(r3,{event:o.event,owner:r,zone:X,onClose:s},r+":"+o.event.event_id)]})}var Zt="monospace",f3=["DAY","WEEK","MONTH","AGENDA"],Yl={PERSONAL:"#D4AF5C",PORTFOLIO:"#3FB950",WATCHLIST:"#6B9AC4",ECONOMIC:"#6B9AC4",ACCOUNTING:"#C85C
4375C",RELATIONSHIP:"#D4AF5C",CRYPTO:"#FBBF24"},tf={PERSONAL:"◆",PORTFOLIO:"◎",WATCHLIST:"★",ECONOMIC:"⚡",ACCOUNTING:"₿",RELATIONSHIP:"✉",CRYPTO:"◈"},cS=["MON","TUE","WED","THU","FRI","SAT","SUN"],dS=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];function As(t){return t<10?"0"+t:""+t}function nf(t){try{var n=new Date(t);return As(n.getHours())+":"+As(n.getMinutes())}catch{return""}}function uS(t){return t.getDate()+" "+["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.getMonth()]+" "+t.getFullYear()}function fS(t){return As(t.getDate())+"/"+As(t.getMonth()+1)}function Zc(t,n){return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate()}function rf(t){if(!t)return"";try{var n=new Date(t);return n.getFullYear()+"-"+As(n.getMonth()+1)+"-"+As(n.getDate())+"T"+As(n.getHours())+":"+As(n.getMinutes())}catch{return""}}function Ph(t){var n=new Date(t),r=(n.getDay()+6)%7;return n.setDate(n.getDate()-r),n.setHours(0,0,0,0),n}function of(t){var n=parseInt(t.slice(1,3),16),r=parseInt(t.slice(3,5),16),o=parseInt(t.slice(5,7),16);return n+","+r+","+o}function so({label:t,onClick:n,color:r,bg:o,border:a,icon:l,small:s,active:c,style:d}){return i.createElement("button",{onClick:n,style:Object.assign({padding:s?"3px 8px":"4px 12px",background:o||"transparent",border:"1px solid "+(a||"#1C2740"),borderRadius:4,cursor:"pointer",fontFamily:Zt,fontSize:s?7:8,fontWeight:700,color:r||"#5A7090",letterSpacing:".06em",transition:"all .15s",display:"flex",alignItems:"center",gap:4,whiteSpace:"nowrap",opacity:c===!1?.5:1},d||{})},l&&i.createElement("span",{style:{fontSize:s?8:10}},l),t)}function p3({onClose:t,onStartCall:n,pendingEvent:r,onEventResult:o,onOpenMarketCalendar:a,focusEvent:l,onAccountChange:s}){var c=(0,i.useState)("DAY"),d=c[0],p=c[1],[g,f]=(0,i.useState)(!1),h=(0,i.useState)(new Date),x=h[0],v=h[1],y=(0,i.useState)([]);y[0];var k=y[1],A=(0,i.useState)($9()),j=A[0],E=A[1],[C,_]=(0,i.useState)(["PORTFOLIO","WATCHLIST"]),w=(0,i.useState)(null),O=w[0],M=w[1],U=(0,i.useState)(null),ee=U[0],N=U[1],V=(0,i.useState)(!1),z=V[0],oe=V[1],P=(0,i.useState)(null),W=P[0],R=P[1],ae=(0,i.useState)(null),q=ae[0],ge=ae[1],X=(0,i.useState)(null),de=X[0],We=X[1],te=(0,i.useState)(""),_e=te[0],ve=te[1],Ne=(0,i.useState)(""),$e=Ne[0],Pe=Ne[1],ot=(0,i.useState)(""),re=ot[0],we=ot[1],b=(0,i.useState)("PERSONAL"),He=b[0],tt=b[1],Ae=(0,i.useState)(""),Be=Ae[0],Fe=Ae[1],ft=(0,i.useState)(""),St=ft[0],Xe=ft[1],It=(0,i.useState)(""),Rt=It[0],$=It[1],Ue=(0,i.useState)("none"),Ie=Ue[0],Q=Ue[1],rt=(0,i.useState)(null),jt=rt[0],tn=rt[1],pt=(0,i.useState)(null),gt=pt[0],qt=pt[1],Pt=(0,i.useState)([]),Kt=Pt[0],xe=Pt[1],fe=(0,i.useState)([]),Ye=fe[0],Qe=fe[1],ut=(0,i.useState)(30),wt=ut[0],H=ut[1];(0,i.useEffect)(function(){rd.accounts().then(function(he){var st=he.accounts||[];st.length>0&&tn(st[0].email||st[0])}).catch(function(){})},[]),(0,i.useEffect)(function(){No.layers().then(function(he){var st=he.layers||[];if(k(st),st.length>0){var Et=st.filter(function(Mt){return Mt.is_enabled!==!1}).map(function(Mt){return(Mt.layer_id||"").toUpperCase()}).filter(function(Mt){return vg.includes(Mt)});Et.length>0&&E(Et)}}).catch(function(){}),No.morningBrief().then(function(he){R(he)}).catch(function(){})},[]);var Z=(0,i.useRef)(0);(0,i.useEffect)(function(){!r||!r._ts||r._ts===Z.current||(Z.current=r._ts,No.createEvent({title:r.title||"Untitled",start_time:r.start_time,end_time:r.end_time,layer:"PERSONAL",account_email:jt||void 0}).then(function(he){he?(nt(),o&&o({ok:!0,title:r.title,start_time:r.start_time,end_time:r.end_time,meet_link:he.meet_link})):o&&o({ok:!1})}).catch(function(){o&&o({ok:!1})}))},[r]);var T=(0,i.useMemo)(function(){var he=new Date(x);d==="WEEK"?he=Ph(x):d==="MONTH"&&he.setDate(1),he.setHours(0,0,0,0);var st=new Date(he);return d==="WEEK"?st.setDate(st.getDate()+6):d==="MONTH"?st.setMonth(st.getMonth()+1,0):d==="AGENDA"&&st.setDate(st.getDate()+13),st.setHours(23,59,59,999),{start:he.toISOString(),end:st.toISOString()}},[x,d]),Y=Iy();(0,i.useEffect)(function(){s&&s({owner:Y,email:jt||null})},[jt,Y,s]),(0,i.useEffect)(function(){l&&l.owner===Y&&(M(l),v(new Date(l.start_time)),N(null))},[l,Y,M,v,N]);var B=(0,i.useRef)(0);(0,i.useEffect)(function(){B.current+=1,M(null),N(null),oe(!1)},[Y]);
437var ie=TS({queryKey:J9(Y,T.start,T.end,j,d),queryFn:function(){return No.events(T.start,T.end,j.join(","))},staleTime:6e4,refetchInterval:12e4}),ue=jS({queryKey:["personal-market-events",Y,T.start,T.end],initialPageParam:null,queryFn:function({pageParam:he}){if(El()!==Y)throw new Error("Account changed");return No.personalMarketEvents({start:T.start,end:T.end,cursor:he})},getNextPageParam:he=>he.next_cursor||void 0,staleTime:3e4,refetchInterval:12e4,retry:1}),ne=(0,i.useMemo)(function(){var he=ie.data,st=he&&Array.isArray(he.events)?he.events:[],Et=new Set,Mt=(ue.data?.pages||[]).flatMap(mn=>mn.events||[]).filter(mn=>Et.has(mn.event_id)?!1:(Et.add(mn.event_id),!0));return st.concat(Mt)},[ie.data,ue.data]),Me=ie.isFetching,nt=ie.refetch;function ct(he){var st=j.includes(he);E(function(Et){return st?Et.filter(function(Mt){return Mt!==he}):Et.concat([he])}),No.toggleLayer(he.toLowerCase(),!st).catch(function(){})}function je(he){var st=new Date(x);d==="DAY"?st.setDate(st.getDate()+he):d==="WEEK"?st.setDate(st.getDate()+he*7):st.setMonth(st.getMonth()+he),v(st)}var Le=(0,i.useMemo)(function(){return ne.filter(function(he){return he.read_only?(he.relevance||[]).some(st=>C.includes(st)):j.includes((he.layer||"PERSONAL").toUpperCase())})},[ne,j,C]);(0,i.useEffect)(function(){for(var he=Le.filter(mn=>!mn.read_only).sort(function(mn,Kn){return(mn.start_time||"").localeCompare(Kn.start_time||"")}),st=[],Et=0;Et<he.length;Et++)for(var Mt=Et+1;Mt<he.length&&(he[Et].end_time||he[Et].start_time||"")>(he[Mt].start_time||"");Mt++)st.push({a:he[Et],b:he[Mt]});xe(st)},[Le]);var be=(0,i.useRef)({});function Wt(he){var st=++B.current,Et=Y+":"+he,Mt=be.current[Et];if(Mt){N(Mt),oe(!1);return}N(null),oe(!0),No.preBrief(he).then(function(mn){st!==B.current||El()!==Y||(be.current[Et]=mn,N(mn),oe(!1))}).catch(function(){st===B.current&&oe(!1)})}function Te(he){B.current+=1,M(he),he.event_id&&!he.read_only?Wt(he.event_id):(N(null),oe(!1)),ge(null)}function it(he,st){qt(he),setTimeout(function(){qt(null)},st||3e3)}function Tt(){We(null),ve(""),Fe(""),Xe(""),$(""),Q("none"),tt("PERSONAL");var he=new Date;he.setMinutes(Math.ceil(he.getMinutes()/15)*15,0,0);var st=new Date(he);st.setHours(st.getHours()+1),Pe(rf(he)),we(rf(st)),ge("form")}function bn(he){We(he.event_id),ve(he.title||""),Fe(he.description||""),Xe(he.location||""),$((he.attendees||[]).map(function(st){return st.email||st}).join(", ")),Q(he.daily_room_url?"daily":he.meet_link?"meet":"none"),tt((he.layer||"PERSONAL").toUpperCase()),Pe(rf(he.start_time)),we(rf(he.end_time)),ge("form")}function $r(){if(!(!_e||!$e||!re)){var he=new Date($e).toISOString(),st=new Date(re).toISOString(),Et=Rt?Rt.split(",").map(function(Mt){return Mt.trim()}).filter(Boolean):[];de?No.reschedule(de,{new_start:he,new_end:st,account_email:jt}).then(function(){it("Event rescheduled"),ge(null),M(null),nt()}).catch(function(){it("Reschedule failed")}):No.createEvent({title:_e,start_time:he,end_time:st,layer:He,description:Be||void 0,location:St||void 0,attendees:Et.length?Et:void 0,create_daily:Ie==="daily",create_meet:Ie==="meet",account_email:jt||void 0}).then(function(Mt){var mn="Event created";Mt&&Mt.meet_link&&(mn+=" — Meet link attached"),Mt&&Mt.daily_room_url&&(mn+=" — Xyron Call ready"),it(mn),ge(null),nt()}).catch(function(){it("Create failed")})}}function ai(he){No.cancel(he).then(function(){it("Event cancelled"),M(null),nt()}).catch(function(){it("Cancel failed")})}function Nn(){if(!jt){rd.init().then(function(he){he&&he.auth_url&&window.open(he.auth_url,"_blank","width=500,height=600")}).catch(function(){});return}it("Syncing with Google Calendar…",5e3),No.sync(jt).then(function(he){it("Synced "+(he&&he.synced||0)+" events from Google"),nt()}).catch(function(){it("Sync failed")})}function er(){it("Generating events from intelligence sources…",8e3),No.generateEvents().then(function(he){it("Generated "+(he&&he.generated||0)+" events across layers"),nt()}).catch(function(){it("Generation failed")})}function Tn(){var he=new Date;he.setHours(8,0,0,0);var st=new Date;st.setDate(st.getDate()+7),st.setHours(19,0,0,0),No.freeSlots(wt,he.toISOString(),st.toISOString()).then(function(Et){Qe(Et.slots||[])}).catch(function(){})}function ra(he){Pe(rf(he.start)),we(rf(he.end)),We(null),ve(""),Fe(""),Xe(""),$(""),Q("none"),tt("PERSONAL"),ge("form")}for(var ba=[],Ro=6;Ro<22;Ro++)ba.push(Ro);Le.forEach(function(he){var st=new Date(he.start_time);if(!(d==="DAY"&&!Zc(st,x))){var Et=st.getHours();Number.isFinite(Et)&&!ba.includes(Et)&&ba.push(Et)}}),ba.sort((he,st)=>he-st);function Ba(he,st,Et){var Mt=Yl[(he.layer||"").toUpperCase()]||"#D4AF5C",mn=he.daily_room_url||he.meet_link;return i.createElement("div",{key:he.event_id||st,onClick:function(){Te(he)},style:{padding:Et?"3px 6px":"6px 10px",background:"rgba("+of(Mt)+",0.06)",borderLeft:"3px solid "+Mt,borderRadius:"0 4px 4px 0",cursor:"pointer",transition:"all .15s"},onMouseEnter:function(Kn){Kn.currentTarget.style.background="rgba("+of(Mt)+",0.12)"},onMouseLeave:function(Kn){Kn.currentTarget.style.background="rgba("+of(Mt)+",0.06)"}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:Et?3:6}},i.createElement("span",{style:{fontFamily:Zt,fontSize:Et?7:8,color:Mt}},tf[(he.layer||"").toUpperCase()]||"◆"),i.createElement("span",{style:{fontSize:Et?9:11,fontWeight:600,color:"#E6EDF3",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:Et?80:200}},he.title),mn&&i.createElement("span",{style:{fontFamily:Zt,fontSize:6,color:"#3FB950"}},"📹"),!Et&&i.createElement("span",{style:{fontFamily:Zt,fontSize:8,color:"#3A4A5E",marginLeft:"auto"}},nf(he.start_time))))}function Ii(he,st,Et,Mt,mn){return Mt==="textarea"?i.createElement("div",{style:{marginBottom:8}},i.createElement("span",{style:{fontFamily:Zt,fontSize:7,color:"#3A4A5E"}},he),i.createElement("textarea",{value:st,onChange:function(Kn){Et(Kn.target.value)},placeholder:mn||"",rows:2,style:{width:"100%",background:"#0A0E16",border:"1px solid #1C2740",borderRadius:4,padding:"5px 8px",fontSize:10,
437color:"#C9D1D9",outline:"none",marginTop:2,boxSizing:"border-box",resize:"vertical",fontFamily:"inherit"}})):i.createElement("div",{style:{marginBottom:8}},i.createElement("span",{style:{fontFamily:Zt,fontSize:7,color:"#3A4A5E"}},he),i.createElement("input",{type:Mt||"text",value:st,onChange:function(Kn){Et(Kn.target.value)},placeholder:mn||"",style:{width:"100%",background:"#0A0E16",border:"1px solid #1C2740",borderRadius:4,padding:"5px 8px",fontSize:10,color:"#C9D1D9",outline:"none",marginTop:2,boxSizing:"border-box"}}))}return g?(0,e.jsxs)("div",{role:"region","aria-label":"Market calendar",style:{position:"absolute",inset:0,zIndex:50,background:"#05080D",display:"flex",flexDirection:"column",overflow:"hidden"},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:12,padding:"10px 16px"},children:[(0,e.jsx)(so,{label:"← MY CALENDAR",onClick:()=>f(!1)}),(0,e.jsx)(so,{label:"✕ CLOSE",onClick:t})]}),(0,e.jsx)(u3,{})]}):i.createElement("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:50,background:"#05080D",display:"flex",flexDirection:"column",overflow:"hidden",animation:"vidSlideUp 0.2s ease-out"}},i.createElement("div",{style:{padding:"10px 16px",borderBottom:"1px solid #111820",background:"#06080D",flexShrink:0}},i.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:10}},i.createElement("div",{style:{width:8,height:8,borderRadius:"50%",background:"#D4AF5C",boxShadow:"0 0 8px rgba(212,175,92,0.4)"}}),i.createElement("span",{style:{fontFamily:Zt,fontSize:10,fontWeight:700,color:"#D4AF5C",letterSpacing:".14em"}},"INTELLIGENCE CALENDAR"),Me&&i.createElement("span",{style:{fontFamily:Zt,fontSize:7,color:"#3A4A5E",animation:"xpulse 1s infinite"}},"LOADING…")),i.createElement("div",{style:{display:"flex",alignItems:"center",gap:4,flexWrap:"wrap"}},f3.map(function(he){return i.createElement(so,{key:he,label:he,small:!0,onClick:function(){p(he)},color:d===he?"#D4AF5C":"#5A7090",bg:d===he?"rgba(212,175,92,0.12)":"transparent",border:d===he?"rgba(212,175,92,0.3)":"#1C2740"})}),i.createElement("div",{style:{width:1,height:16,background:"#1C2740",margin:"0 4px"}}),i.createElement(so,{label:"+ EVENT",small:!0,onClick:Tt,color:"#D4AF5C",border:"rgba(212,175,92,0.25)",bg:"rgba(212,175,92,0.08)"}),i.createElement(so,{label:"SYNC",small:!0,onClick:Nn,icon:"🔄",color:jt?"#4285F4":"#5A7090",border:jt?"rgba(66,133,244,0.3)":"#1C2740"}),i.createElement(so,{label:"GENERATE",small:!0,onClick:er,icon:"⚡",color:"#3FB950",border:"rgba(63,185,80,0.3)"}),i.createElement(so,{label:"FREE SLOTS",small:!0,onClick:function(){ge(q==="slots"?null:"slots"),q!=="slots"&&Tn()},icon:"🕓",color:q==="slots"?"#6B9AC4":"#5A7090",border:q==="slots"?"rgba(56,189,248,0.3)":"#1C2740"}),i.createElement(so,{label:"SUBSCRIBE",small:!0,onClick:function(){ge(q==="subscribe"?null:"subscribe")},icon:"📱",color:q==="subscribe"?"#FBBF24":"#5A7090",border:q==="subscribe"?"rgba(251,191,36,0.3)":"#1C2740"}),i.createElement(so,{label:"MARKET CAL →",small:!0,onClick:function(){a?a():f(!0)},icon:"⚡",color:"#6B9AC4",border:"rgba(107,154,196,0.3)"}),i.createElement(so,{label:"✕ CLOSE",small:!0,onClick:t}))),i.createElement("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"}},vg.map(function(he){var st=j.includes(he);return i.createElement("button",{key:he,onClick:function(){ct(he)},style:{padding:"3px 10px",background:st?"rgba("+of(Yl[he])+",0.08)":"transparent",border:"1px solid "+(st?Yl[he]+"40":"#1C2740"),borderRadius:12,cursor:"pointer",fontFamily:Zt,fontSize:7,color:st?Yl[he]:"#3A4A5E",letterSpacing:".06em",transition:"all .15s"}},tf[he]+" "+he)}),["PORTFOLIO","WATCHLIST"].map(function(he){return i.createElement(so,{key:he,label:he,icon:tf[he],small:!0,active:C.includes(he),color:Yl[he],onClick:()=>_(st=>st.includes(he)?st.filter(Et=>Et!==he):st.concat(he))})}),Kt.length>0&&i.createElement("span",{style:{fontFamily:Zt,fontSize:7,color:"#D44040",marginLeft:8,display:"flex",alignItems:"center",gap:4}},i.createElement("span",{style:{width:6,height:6,borderRadius:"50%",background:"#D44040",animation:"xpulse 1s infinite"}}),Kt.length+" CONFLICT"+(Kt.length>1?"S":""))),ue.isError&&i.createElement("div",{role:"alert",style:{color:"#C85C
4375C",paddingTop:8,fontSize:11}},"Portfolio and watchlist events could not be loaded. ",i.createElement(so,{label:"RETRY",small:!0,onClick:()=>ue.refetch()})),ue.isPending&&i.createElement("div",{style:{color:"#5A7090",paddingTop:6,fontSize:10}},"Loading portfolio and watchlist events…"),ue.hasNextPage&&i.createElement(so,{label:ue.isFetchingNextPage?"LOADING…":"LOAD MORE RELEVANT EVENTS",small:!0,onClick:()=>{ue.isFetchingNextPage||ue.fetchNextPage()}}),gt&&i.createElement("div",{style:{marginTop:6,padding:"4px 10px",background:"rgba(212,175,92,0.06)",border:"1px solid rgba(212,175,92,0.15)",borderRadius:4,fontFamily:Zt,fontSize:8,color:"#D4AF5C",animation:"xfadein 0.2s ease"}},gt)),i.createElement("div",{style:{flex:1,display:"flex",overflow:"hidden"}},i.createElement("div",{style:{flex:1,overflow:"auto",padding:"12px 16px"}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:12}},i.createElement(so,{label:"←",onClick:function(){je(-1)}}),i.createElement("span",{style:{fontFamily:Zt,fontSize:11,fontWeight:700,color:"#E6EDF3",letterSpacing:".06em",minWidth:140,textAlign:"center"}},uS(x)),i.createElement(so,{label:"→",onClick:function(){je(1)}}),i.createElement(so,{label:"TODAY",onClick:function(){v(new Date)}})),d==="DAY"&&W&&W.total_events>0&&i.createElement("div",{style:{background:"rgba(212,175,92,0.04)",border:"1px solid rgba(212,175,92,0.15)",borderRadius:8,padding:"10px 14px",marginBottom:12}},i.createElement("div",{style:{fontFamily:Zt,fontSize:7,fontWeight:700,color:"#D4AF5C",letterSpacing:".1em",marginBottom:4}},"MORNING BRIEFING"),i.createElement("div",{style:{fontSize:11,color:"#C9D1D9"}},W.total_events," events today across ",Object.keys(W.by_layer||{}).length," intelligence layers"),W.by_layer&&i.createElement("div",{style:{display:"flex",gap:8,marginTop:6,flexWrap:"wrap"}},Object.entries(W.by_layer).map(function(he){var st=he[0],Et=he[1],Mt=Yl[st.toUpperCase()]||"#5A7090";return i.createElement("span",{key:st,style:{fontFamily:Zt,fontSize:7,color:Mt,background:"rgba("+of(Mt)+",0.06)",padding:"2px 6px",borderRadius:8}},tf[st.toUpperCase()]||"◆"," ",st," (",Et.length,")")}))),Kt.length>0&&i.createElement("div",{style:{background:"rgba(255,68,68,0.04)",border:"1px solid rgba(255,68,68,0.2)",borderRadius:8,padding:"10px 14px",marginBottom:12}},i.createElement("div",{style:{fontFamily:Zt,fontSize:7,fontWeight:700,color:"#D44040",letterSpacing:".1em",marginBottom:6}},"SCHEDULING CONFLICTS"),Kt.slice(0,3).map(function(he,st){return i.createElement("div",{key:st,style:{fontSize:10,color:"#C9D1D9",marginBottom:4,display:"flex",gap:4,alignItems:"center"}},i.createElement("span",{style:{color:Yl[(he.a.layer||"").toUpperCase()]||"#5A7090"}},"◆"),i.createElement("span",null,he.a.title||"Event"),i.createElement("span",{style:{color:"#D44040",fontFamily:Zt,fontSize:7}},"OVERLAPS"),i.createElement("span",{style:{color:Yl[(he.b.layer||"").toUpperCase()]||"#5A7090"}},"◆"),i.createElement("span",null,he.b.title||"Event"))})),d==="DAY"&&i.createElement("div",{style:{position:"relative"}},ba.map(function(he){var st=Le.filter(function(Et){try{var Mt=new Date(Et.start_time);return Mt.getHours()===he&&Zc(Mt,x)}catch{return!1}});return i.createElement("div",{key:he,style:{display:"flex",borderBottom:"1px solid #0D1520",minHeight:48}},i.createElement("div",{style:{width:50,padding:"4px 8px",fontFamily:Zt,fontSize:9,color:"#3A4A5E",flexShrink:0,textAlign:"right"}},As(he)+":00"),i.createElement("div",{style:{flex:1,padding:"4px 8px",display:"flex",flexDirection:"column",gap:4}},st.map(function(Et,Mt){return Ba(Et,Mt)})))})),d==="WEEK"&&i.createElement("div",null,i.createElement("div",{style:{display:"grid",gridTemplateColumns:"50px repeat(7,1fr)",borderBottom:"1px solid #1C2740",marginBottom:4}},i.createElement("div",{style:{padding:4}}),(function(){for(var he=Ph(x),st=[],Et=0;Et<7;Et++){var Mt=new Date(he);Mt.setDate(Mt.getDate()+Et);var mn=Zc(Mt,new Date);st.push(i.createElement("div",{key:Et,style:{padding:"4px 6px",textAlign:"center",borderLeft:Et>0?"1px solid #0D1520":"none"}},i.createElement("div",{style:{fontFamily:Zt,fontSize:7,color:mn?"#D4AF5C":"#3A4A5E",fontWeight:mn?700:400}},cS[Et]),i.createElement("div",{style:{fontFamily:Zt,fontSize:9,color:mn?"#D4AF5C":"#5A7090",fontWeight:mn?700:400}},fS(Mt))))}return st})()),ba.map(function(he){var st=Ph(x);return i.createElement("div",{key:he,style:{display:"grid",gridTemplateColumns:"50px repeat(7,1fr)",borderBottom:"1px solid #0A0E16",minHeight:40}},i.createElement("div",{style:{padding:"2px 8px",fontFamily:Zt,fontSize:8,color:"#2A3548",textAlign:"right"}},As(he)+":00"),(function(){for(var Et=[],Mt=0;Mt<7;Mt++){var mn=new Date(st);mn.setDate(mn.getDate()+Mt);var Kn=Le.filter(function(br){try{var qn=new Date(br.start_time);return qn.getHours()===he&&Zc(qn,mn)}catch{return!1}});Et.push(i.createElement("div",{key:Mt,style:{padding:"2px 3px",borderLeft:Mt>0?"1px solid #0A0E16":"none",display:"flex",flexDirection:"column",gap:2}},Kn.map(function(br,qn){return Ba(br,qn,!0)})))}return Et})())})),d==="MONTH"&&i.createElement("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",gap:2}},cS.map(function(he){return i.createElement("div",{key:he,style:{padding:"4px",fontFamily:Zt,fontSize:7,color:"#3A4A5E",textAlign:"center"}},he)}),(function(){for(var he=[],st=(new Date(x.getFullYear(),x.getMonth(),1).getDay()+6)%7,Et=0;Et<st;Et++)he.push(i.createElement("div",{key:"e"+Et}));for(var Mt=new Date(x.getFullYear(),x.getMonth()+1,0).getDate(),mn=1;mn<=Mt;mn++){var Kn=new Date(x.getFullYear(),x.getMonth(),mn),br=Le.filter(function($n){try{return Zc(new Date($n.start_time),Kn)}catch{return!1}}),qn=Zc(Kn,new Date),nl=Kt.some(function($n){try{return Zc(new Date($n.a.start_time),Kn)}catch{return!1}});
437he.push(i.createElement("div",{key:mn,onClick:function(){v(new Date(Kn)),p("DAY")},style:{padding:"4px 6px",background:qn?"rgba(212,175,92,0.08)":nl?"rgba(255,68,68,0.04)":"transparent",border:qn?"1px solid rgba(212,175,92,0.3)":nl?"1px solid rgba(255,68,68,0.15)":"1px solid #0D1520",borderRadius:4,cursor:"pointer",minHeight:40,transition:"all .15s"},onMouseEnter:function($n){$n.currentTarget.style.background="rgba(212,175,92,0.06)"},onMouseLeave:function($n){$n.currentTarget.style.background=qn?"rgba(212,175,92,0.08)":"transparent"}},i.createElement("div",{style:{fontFamily:Zt,fontSize:9,color:qn?"#D4AF5C":"#5A7090",fontWeight:qn?700:400}},mn),br.length>0&&i.createElement("div",{style:{display:"flex",gap:2,marginTop:2,flexWrap:"wrap"}},br.slice(0,4).map(function($n,ia){return i.createElement("div",{key:ia,style:{width:5,height:5,borderRadius:"50%",background:Yl[($n.layer||"").toUpperCase()]||"#D4AF5C"}})})),br.length>4&&i.createElement("div",{style:{fontFamily:Zt,fontSize:6,color:"#3A4A5E",marginTop:1}},"+"+(br.length-4))))}return he})()),d==="AGENDA"&&i.createElement("div",null,Le.length===0&&i.createElement("div",{style:{textAlign:"center",padding:"40px 0",fontFamily:Zt,fontSize:9,color:"#3A4A5E"}},"No events in the next 14 days"),(function(){var he={};return Le.forEach(function(st){try{var Et=new Date(st.start_time).toISOString().slice(0,10);he[Et]||(he[Et]=[]),he[Et].push(st)}catch{}}),Object.entries(he).map(function(st){var Et=st[0],Mt=st[1],mn=new Date(Et+"T00:00:00"),Kn=Zc(mn,new Date),br=(mn.getDay()+6)%7;return i.createElement("div",{key:Et,style:{marginBottom:16}},i.createElement("div",{style:{fontFamily:Zt,fontSize:8,fontWeight:700,color:Kn?"#D4AF5C":"#5A7090",letterSpacing:".1em",marginBottom:6,paddingBottom:4,borderBottom:"1px solid #0D1520"}},Kn?"TODAY — ":"",dS[br],", ",uS(mn)),Mt.map(function(qn,nl){var $n=Yl[(qn.layer||"").toUpperCase()]||"#D4AF5C";return i.createElement("div",{key:qn.event_id||nl,onClick:function(){Te(qn)},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 12px",borderBottom:"1px solid #0A0E16",cursor:"pointer",borderLeft:"3px solid "+$n,marginBottom:2,borderRadius:"0 4px 4px 0",transition:"all .15s"},onMouseEnter:function(ia){ia.currentTarget.style.background="rgba(212,175,92,0.03)"},onMouseLeave:function(ia){ia.currentTarget.style.background="transparent"}},i.createElement("div",{style:{fontFamily:Zt,fontSize:9,color:"#5A7090",width:45,flexShrink:0,textAlign:"right"}},nf(qn.start_time)),i.createElement("span",{style:{fontSize:10,color:$n}},tf[(qn.layer||"").toUpperCase()]||"◆"),i.createElement("div",{style:{flex:1}},i.createElement("div",{style:{fontSize:12,fontWeight:600,color:"#E6EDF3"}},qn.title),qn.description&&i.createElement("div",{style:{fontFamily:Zt,fontSize:8,color:"#5A7090",marginTop:2}},qn.description.substring(0,80))),(qn.daily_room_url||qn.meet_link)&&i.createElement("span",{style:{fontFamily:Zt,fontSize:6,color:"#3FB950",background:"rgba(63,185,80,0.08)",padding:"2px 6px",borderRadius:8}},"📹 CALL"),i.createElement("span",{style:{fontFamily:Zt,fontSize:7,color:"#2A3548"}},qn.layer))}))})})())),i.createElement("div",{style:{width:300,borderLeft:"1px solid #111820",overflow:"auto",padding:"12px",flexShrink:0,background:"#06080D"}},q==="form"&&i.createElement("div",{style:{animation:"xfadein 0.2s ease"}},i.createElement("div",{style:{fontFamily:Zt,fontSize:7,fontWeight:700,color:"#D4AF5C",letterSpacing:".1em",marginBottom:10}},de?"EDIT EVENT":"CREATE EVENT"),Ii("Title",_e,ve,"text","Meeting title"),Ii("Start",$e,Pe,"datetime-local"),Ii("End",re,we,"datetime-local"),i.createElement("div",{style:{marginBottom:8}},i.createElement("span",{style:{fontFamily:Zt,fontSize:7,color:"#3A4A5E"}},"Layer"),i.createElement("select",{value:He,onChange:function(he){tt(he.target.value)},style:{width:"100%",background:"#0A0E16",border:"1px solid #1C2740",borderRadius:4,padding:"5px 8px",fontSize:10,color:"#C9D1D9",outline:"none",marginTop:2,boxSizing:"border-box"}},vg.map(function(he){return i.createElement("option",{key:he,value:he},tf[he]+" "+he)}))),Ii("Description",Be,Fe,"textarea","Meeting notes, context…"),Ii("Location",St,Xe,"text","Office / Zoom / Address"),Ii("Attendees",Rt,$,"text","[email protected], [email protected]"),!de&&i.createElement("div",{style:{marginBottom:10}},i.createElement("span",{style:{fontFamily:Zt,fontSize:7,color:"#3A4A5E"}},"Video Call"),i.createElement("div",{style:{display:"flex",gap:4,marginTop:4}},[["none","NONE"],["daily","XYRON CALL"],["meet","GOOGLE MEET"]].map(function(he){var st=Ie===he[0],Et=he[0]==="daily"?"#3FB950":he[0]==="meet"?"#4285F4":"#5A7090";return i.createElement("button",{key:he[0],onClick:function(){Q(he[0])},style:{flex:1,padding:"5px 4px",background:st?"rgba("+of(Et)+",0.08)":"#0A0E16",border:"1px solid "+(st?Et+"60":"#1C2740"),borderRadius:4,cursor:"pointer",fontFamily:Zt,fontSize:7,fontWeight:st?700:400,color:st?Et:"#3A4A5E",transition:"all .15s"}},he[1])}))),i.createElement("div",{style:{display:"flex",gap:6,marginTop:4}},i.createElement("button",{onClick:$r,style:{flex:1,background:"#D4AF5C",border:"none",borderRadius:4,padding:"7px",cursor:"pointer",fontFamily:Zt,fontSize:8,fontWeight:700,color:"#000"}},de?"SAVE CHANGES":"CREATE"),i.createElement("button",{onClick:function(){ge(null)},style:{background:"transparent",border:"1px solid #1C2740",borderRadius:4,padding:"7px 12px",cursor:"pointer",fontFamily:Zt,fontSize:8,color:"#5A7090"}},"CANCEL"))),q==="slots"&&i.createElement("div",{style:{animation:"xfadein 0.2s ease"}},i.createElement("div",{style:{fontFamily:Zt,fontSize:7,fontWeight:700,color:"#6B9AC4",letterSpacing:".1em",marginBottom:10}},"🕓 FIND FREE TIME"),i.createElement("div",{style:{marginBottom:8}},i.createElement("span",{style:{fontFamily:Zt,fontSize:7,color:"#3A4A5E"}},"Duration (minutes)"),i.createElement("input",{type:"number",value:wt,onChange:function(he){H(parseInt(he.target.value)||30)},min:15,max:240,step:15,style:{width:"100%",background:"#0A0E16",border:"1px solid #1C2740",borderRadius:4,padding:"5px 8px",fontSize:10,
437color:"#C9D1D9",outline:"none",marginTop:2,boxSizing:"border-box"}})),i.createElement("button",{onClick:Tn,style:{width:"100%",background:"rgba(56,189,248,0.08)",border:"1px solid rgba(56,189,248,0.25)",borderRadius:4,padding:"6px",cursor:"pointer",fontFamily:Zt,fontSize:8,fontWeight:700,color:"#6B9AC4",marginBottom:10}},"FIND SLOTS"),Ye.length===0&&i.createElement("div",{style:{fontFamily:Zt,fontSize:8,color:"#2A3548",textAlign:"center",padding:12}},"No free slots found"),Ye.map(function(he,st){var Et=new Date(he.start),Mt=(Et.getDay()+6)%7;return i.createElement("div",{key:st,onClick:function(){ra(he)},style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 10px",background:"#0A0E16",border:"1px solid #1C2740",borderRadius:6,marginBottom:4,cursor:"pointer",transition:"all .15s"},onMouseEnter:function(mn){mn.currentTarget.style.borderColor="rgba(56,189,248,0.3)"},onMouseLeave:function(mn){mn.currentTarget.style.borderColor="#1C2740"}},i.createElement("div",null,i.createElement("div",{style:{fontFamily:Zt,fontSize:9,color:"#E6EDF3"}},dS[Mt],", ",fS(Et)),i.createElement("div",{style:{fontFamily:Zt,fontSize:8,color:"#5A7090"}},nf(he.start)," — ",nf(he.end))),i.createElement("span",{style:{fontFamily:Zt,fontSize:7,color:"#6B9AC4"}},"BOOK →"))})),q==="subscribe"&&i.createElement("div",{style:{animation:"xfadein 0.2s ease"}},i.createElement("div",{style:{fontFamily:Zt,fontSize:7,fontWeight:700,color:"#FBBF24",letterSpacing:".1em",marginBottom:10}},"📱 SUBSCRIBE TO CALENDAR"),i.createElement("div",{style:{fontSize:11,color:"#C9D1D9",lineHeight:1.6,marginBottom:12}},"Add Xyron’s 6 intelligence layers to any calendar app. Works with iPhone, Android, Outlook, and Google Calendar."),i.createElement("div",{style:{marginBottom:10}},i.createElement("div",{style:{fontFamily:Zt,fontSize:7,color:"#3A4A5E",marginBottom:4}},"SUBSCRIPTION URL"),i.createElement("div",{style:{background:"#0A0E16",border:"1px solid #1C2740",borderRadius:4,padding:"8px",fontFamily:Zt,fontSize:8,color:"#6B9AC4",wordBreak:"break-all",userSelect:"all"}},No.feedUrl())),i.createElement("button",{onClick:function(){navigator.clipboard.writeText(No.feedUrl()).then(function(){it("Copied to clipboard")}).catch(function(){})},style:{width:"100%",background:"rgba(251,191,36,0.08)",border:"1px solid rgba(251,191,36,0.25)",borderRadius:4,padding:"7px",cursor:"pointer",fontFamily:Zt,fontSize:8,fontWeight:700,color:"#FBBF24",marginBottom:12}},"COPY URL"),i.createElement("div",{style:{fontFamily:Zt,fontSize:7,fontWeight:700,color:"#5A7090",marginBottom:6}},"HOW TO SUBSCRIBE"),[["🍏 iPhone","Settings → Calendar → Accounts → Add → Other → Add Subscribed Calendar → paste URL"],["📱 Android","Google Calendar → Settings → Add calendar → From URL → paste URL"],["📧 Outlook","File → Account Settings → Internet Calendars → New → paste URL"],["🌐 Google","Other calendars + → From URL → paste URL"]].map(function(he,st){return i.createElement("div",{key:st,style:{padding:"6px 8px",background:"#0A0E16",border:"1px solid #0D1520",borderRadius:4,marginBottom:3}},i.createElement("div",{style:{fontFamily:Zt,fontSize:7,fontWeight:700,color:"#C9D1D9"}},he[0]),i.createElement("div",{style:{fontFamily:Zt,fontSize:7,color:"#3A4A5E",marginTop:2}},he[1]))})),O&&!q&&i.createElement("div",{style:{animation:"xfadein 0.2s ease"}},i.createElement("div",{style:{fontFamily:Zt,fontSize:7,fontWeight:700,color:Yl[(O.layer||"").toUpperCase()]||"#D4AF5C",letterSpacing:".1em",marginBottom:6}},O.layer||"EVENT"),i.createElement("div",{style:{fontSize:14,fontWeight:600,color:"#E6EDF3",marginBottom:8}},O.title),i.createElement("div",{style:{fontFamily:Zt,fontSize:9,color:"#5A7090",marginBottom:4}},nf(O.start_time)," — ",O.read_only?"Market event":nf(O.end_time)),O.location&&i.createElement("div",{style:{fontFamily:Zt,fontSize:9,color:"#5A7090",marginBottom:4}},"📍 ",O.location),O.attendees&&O.attendees.length>0&&i.createElement("div",{style:{marginBottom:8}},i.createElement("div",{style:{fontFamily:Zt,fontSize:7,color:"#2A3548",marginBottom:3}},"ATTENDEES"),O.attendees.map(function(he,st){return i.createElement("div",{key:st,style:{fontFamily:Zt,fontSize:8,color:"#5A7090",padding:"2px 0"}},"• ",(he.name||he.email||he)+(he.status?" ("+he.status+")":""))})),O.description&&i.createElement("div",{style:{marginBottom:12,maxHeight:100,overflow:"auto"}},i.createElement(ws,{text:O.description||""})),i.createElement("div",{style:{display:"flex",flexDirection:"column",gap:4,marginBottom:12}},(O.daily_room_url||O.meet_link)&&i.createElement("button",{onClick:function(){O.daily_room_url&&n?n({roomUrl:O.daily_room_url,eventId:O.event_id}):O.meet_link&&window.open(O.meet_link,"_blank")},style:{width:"100%",background:"rgba(63,185,80,0.08)",border:"1px solid rgba(63,185,80,0.3)",borderRadius:4,padding:"7px",cursor:"pointer",fontFamily:Zt,fontSize:8,fontWeight:700,color:"#3FB950"}},O.daily_room_url?"📹 JOIN XYRON CALL":"📹 JOIN GOOGLE MEET"),!O.read_only&&i.createElement("div",{style:{display:"flex",gap:4}},i.createElement("button",{onClick:function(){bn(O)},style:{flex:1,background:"rgba(212,175,92,0.06)",border:"1px solid rgba(212,175,92,0.2)",borderRadius:4,padding:"6px",cursor:"pointer",fontFamily:Zt,fontSize:8,color:"#D4AF5C"}},"✎ EDIT"),i.createElement("button",{onClick:function(){confirm("Cancel this event?")&&ai(O.event_id)},style:{flex:1,background:"rgba(255,68,68,0.04)",border:"1px solid rgba(255,68,68,0.15)",borderRadius:4,padding:"6px",cursor:"pointer",fontFamily:Zt,fontSize:8,color:"#D44040"}},"✕ CANCEL")),i.createElement("button",{onClick:function(){M(null)},style:{width:"100%",background:"transparent",border:"1px solid #1C2740",borderRadius:4,padding:"6px",cursor:"pointer",fontFamily:Zt,fontSize:8,color:"#5A7090"}},"CLOSE")),z&&i.createElement("div",{style:{fontFamily:Zt,fontSize:8,color:"#3A4A5E",textAlign:"center",padding:12,animation:"xpulse 1s infinite"}},"Generating intelligence brief…"),ee&&ee.brief&&i.createElement("div",{style:{background:"rgba(212,175,92,0.04)",border:"1px solid rgba(212,175,92,0.15)",borderRadius:6,padding:"10px 12px"}},i.createElement("div",{style:{fontFamily:Zt,fontSize:7,fontWeight:700,color:"#D4AF5C",letterSpacing:".1em",marginBottom:6}},"PRE-MEETING BRIEF"),i.createElement(ws,{text:ee.brief||""}))),!O&&!q&&i.createElement("div",{style:{textAlign:"center",padding:"40px 0"}},i.createElement("div",{style:{fontSize:28,marginBottom:8,opacity:.3}},"📅"),i.createElement("div",{style:{fontFamily:Zt,fontSize:8,color:"#2A3548",letterSpacing:".1em",marginBottom:4}},"INTELLIGENCE CALENDAR"),i.createElement("div",{style:{fontFamily:Zt,fontSize:7,color:"#1C2740",marginTop:4,lineHeight:1.6}},"Select an event for its AI brief,","or create a new one."),i.createElement("div",{style:{marginTop:16,display:"flex",flexDirection:"column",gap:6}},i.createElement(so,{label:"CREATE EVENT",onClick:Tt,color:"#D4AF5C",border:"rgba(212,175,92,0.25)",icon:"+",style:{justifyContent:"center",width:"100%"}}),i.createElement(so,{label:jt?"SYNC GOOGLE":"CONNECT GOOGLE",onClick:Nn,color:"#4285F4",border:"rgba(66,133,244,0.25)",icon:"🔄",style:{justifyContent:"center",width:"100%"}}),i.createElement(so,{label:"AUTO-GENERATE EVENTS",onClick:er,color:"#3FB950",border:"rgba(63,185,80,0.25)",icon:"⚡",style:{justifyContent:"center",width:"100%"}})),jt&&i.createElement("div",{style:{fontFamily:Zt,fontSize:7,color:"#3A4A5E",marginTop:12}},"✓ Connected: ",jt)))))}async function g3(t,{owner:n,signal:r,onDelta:o,onEvent:a,onDone:l,onError:s}){return Ry({url:"/api/calendar/assistant/stream",signal:r,fetchResponse:()=>Oa("/api/calendar/assistant/stream",{method:"POST",body:JSON.stringify(t),signal:r},n),onDelta:o,onEvent:a,onDone:l,onError:s})}async function m3(t,{owner:n,signal:r}){const o=await Oa("/api/calendar/assistant/confirm",{method:"POST",body:JSON.stringify({proposal_id:t}),signal:r},n),a=await o.json().catch(()=>null);if(!a)throw new Error("The calendar change could not be verified. Check your calendar before trying again.");if(!o.ok){const l=typeof a.detail=="string"?a.detail:"The calendar change could not be verified. Check your calendar before trying again.";throw new Error(l)}return a}var eg=t=>({owner:t,drawer:"calendar",streaming:!1,question:"",text:"",err:"",phase:"",events:[],slots:[],proposal:null,context:null,hasMore:!1,followUps:[],citations:[],selectedId:"",confirming:!1});function h3({enabled:t,accountEmail:n}={}){const r=Iy(),o=KC(),[a,l]=(0,i.useState)(()=>eg(r)),s=(0,i.useRef)(null),c=(0,i.useRef)({owner:r,context:null,history:[],selectedId:""});function d(){s.current&&(s.current.controller.abort(),clearTimeout(s.current.timer),s.current=null)}function p(){d(),c.current={owner:El(),context:null,history:[],selectedId:""},l(eg(El()))}(0,i.useEffect)(()=>(p(),d),[r]),(0,i.useEffect)(()=>{t||(d(),l(v=>({...v,streaming:!1,confirming:!1})))},[t]);function g(v,y){d();const k=El();c.current.owner!==k&&(c.current={owner:k,context:null,history:[],selectedId:""});const A={controller:new AbortController,owner:k,confirming:!!y.confirming};s.current=A;const j=()=>s.current===A&&El()===k,E=C=>{j()&&l(_=>({..._,...C,owner:k}))};return l({...eg(k),...y}),A.timer=setTimeout(()=>{j()&&(E({streaming:!1,confirming:!1,proposal:null,err:y.confirming?"The change is still unverified. Check your calendar before submitting it again.":"The calendar request timed out. Try a narrower date range."}),A.controller.abort(),s.current=null)},v),{run:A,current:j,update:E}}async function f(v){if(s.current?.confirming)return;const y=String(v||"").trim();if(!y)return;const{run:k,current:A,update:j}=g(14e3,{question:y,streaming:!0,phase:"Checking your calendar…"}),E=Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC";let C="",_=!1;try{await g3({message:y,timezone:E,context:c.current.context,history:c.current.history,selected_event_id:/\b(this|that|it|selected)\b/i.test(y)?c.current.selectedId:"",account_email:n||null},{owner:k.owner,signal:k.controller.signal,onDelta:(w,O)=>{C=O,j({text:O,phase:""})},onEvent:w=>{A()&&(w.type==="status"&&j({phase:w.phase||""}),w.type==="calendar_result"&&(c.current.context=w.context,j({events:w.events||[],slots:w.slots||[],context:w.context,timezone:w.timezone,hasMore:!!w.has_more})),w.type==="calendar_proposal"&&j({proposal:w}))},onDone:({evt:w})=>{if(A()){if(!w){j({streaming:!1,err:"The calendar response was interrupted. Please retry."});return}_=!0,c.current.context=w.context||c.current.context,c.current.history=c.current.history.concat([{role:"user",content:y},{role:"assistant",content:C.slice(0,3e3)}]).slice(-8),j({streaming:!1,followUps:w.follow_ups||[],phase:""})}},onError:(w,O,M)=>j({streaming:!1,err:M===401?"Please sign in again to use your calendar.":w})})}catch(w){w.name!=="AbortError"&&j({streaming:!1,err:"Calendar assistance is unavailable. Please retry."})}finally{clearTimeout(k.timer),A()&&(j({streaming:!1,..._?{}:{proposal:null}}),s.current=null)}}function h(v){c.current.selectedId=v.event_id,l(y=>({...y,selectedId:v.event_id}))}async function x(){if(!a.proposal||a.confirming||a.streaming||s.current?.confirming||a.owner!==El())return;const v=a.proposal,{run:y,current:k,update:A}=g(24e3,{...a,confirming:!0,err:""});try{const j=await m3(v.id,{owner:y.owner,signal:y.controller.signal});if(!k())return;A({proposal:null,confirming:!1,text:j.message,err:""}
437),o.invalidateQueries({queryKey:["cal-events",y.owner]})}catch(j){j.name!=="AbortError"&&A({confirming:!1,proposal:null,err:j.message})}finally{clearTimeout(y.timer),k()&&(s.current=null,l(j=>({...j,confirming:!1})))}}return{state:a.owner===r?a:eg(r),ask:f,reset:p,select:h,confirm:x,dismissProposal:()=>l(v=>({...v,proposal:null}))}}var _p={border:"1px solid #293341",borderRadius:5,padding:"7px 10px",background:"#0B111B",color:"#D4AF5C",cursor:"pointer",fontSize:12};function tu(t,n){if(!t)return"";try{return new Intl.DateTimeFormat(void 0,{timeZone:n||"UTC",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(t))}catch{return"Time unavailable"}}function y3({state:t,onSelect:n,onAsk:r,onConfirm:o,onDismissProposal:a}){const l=t.proposal,s=t.timezone||Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC";return(0,e.jsxs)("div",{"data-testid":"calendar-assistant-results",style:{display:"grid",gap:8,marginTop:8,fontSize:12},children:[t.context&&(0,e.jsxs)("div",{style:{color:"#8C9BAA"},children:[tu(t.context.start,s)," – ",tu(t.context.end,s)," · ",s]}),(t.events||[]).map(c=>(0,e.jsxs)("button",{type:"button",onClick:()=>n(c),"aria-pressed":t.selectedId===c.event_id,style:{..._p,color:"#E6EDF3",textAlign:"left",width:"100%",overflowWrap:"anywhere"},children:[(0,e.jsxs)("span",{style:{display:"block",color:"#8C9BAA",marginBottom:3},children:[tu(c.start_time,s),c.symbol?" · "+c.symbol:""]}),c.title,(0,e.jsx)("span",{style:{display:"block",color:"#8C9BAA",marginTop:3},children:c.read_only?"Market event · "+(c.relevance||[]).map(d=>d.toLowerCase()).join(" / "):"Meeting"})]},c.event_id)),t.selectedId&&(0,e.jsx)("div",{style:{color:"#8C9BAA"},children:"Event selected. Ask a follow-up about it."}),(t.slots||[]).map(c=>(0,e.jsxs)("button",{type:"button",style:_p,onClick:()=>r(`Create a meeting called Meeting from ${c.start} to ${c.end}`),children:[tu(c.start,s)," – ",tu(c.end,s)," · Use this slot"]},c.start)),t.hasMore&&(0,e.jsx)("button",{type:"button",disabled:t.streaming,style:_p,onClick:()=>r("Show more"),children:"Show more events"}),l&&(0,e.jsxs)("div",{role:"group","aria-label":"Review calendar change",style:{border:"1px solid #D4AF5C",borderRadius:6,padding:10},children:[(0,e.jsx)("strong",{children:{create:"Create meeting",reschedule:"Reschedule meeting",cancel:"Cancel meeting"}[l.action]}),(0,e.jsx)("div",{style:{margin:"6px 0",overflowWrap:"anywhere"},children:l.title}),(0,e.jsxs)("div",{children:[tu(l.start_time,l.timezone_str)," – ",tu(l.end_time,l.timezone_str)," · ",l.timezone_str]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,marginTop:10},children:[(0,e.jsx)("button",{type:"button",disabled:t.confirming||t.streaming,style:_p,onClick:o,children:t.confirming?"Applying…":"Confirm change"}),(0,e.jsx)("button",{type:"button",disabled:t.confirming,style:_p,onClick:a,children:"Dismiss"})]})]})]})}var Xr="monospace";function cc({label:t,icon:n,color:r}){return i.createElement("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"14px 20px 8px",borderBottom:"1px solid #111820"}},i.createElement("span",{style:{fontSize:14,color:r||"#D4AF5C"}},n),i.createElement("span",{style:{fontFamily:Xr,fontSize:10,fontWeight:700,color:r||"#D4AF5C",letterSpacing:".12em"}},t))}function uo({value:t,onChange:n,label:r,help:o}){return i.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 20px",borderBottom:"1px solid #0A0E16"}},i.createElement("div",{style:{flex:1,minWidth:0}},i.createElement("div",{style:{fontSize:12,color:"#E6EDF3",fontWeight:500}},r),o&&i.createElement("div",{style:{fontSize:10,color:"#5A7090",marginTop:2}},o)),i.createElement("button",{onClick:function(){n(!t)},style:{width:36,height:20,borderRadius:20,border:"none",background:t?"#D4AF5C":"#2A3548",cursor:"pointer",position:"relative",transition:"background .2s",flexShrink:0}},i.createElement("div",{style:{width:14,height:14,borderRadius:"50%",background:"#fff",position:"absolute",top:3,left:t?19:3,transition:"left .2s",boxShadow:"0 1px 3px rgba(0,0,0,0.3)"}})))}function ic({value:t,onChange:n,label:r,placeholder:o,type:a,help:l}){return i.createElement("div",{style:{padding:"10px 20px",borderBottom:"1px solid #0A0E16"}},i.createElement("div",{style:{fontSize:11,color:"#C9D1D9",fontWeight:500,marginBottom:6}},r),i.createElement("input",{type:a||"text",value:t||"",onChange:function(s){n(s.target.value)},placeholder:o||"",style:{width:"100%",background:"#0A0E16",border:"1px solid #1C2740",borderRadius:6,padding:"7px 10px",fontSize:11,color:"#E6EDF3",outline:"none",boxSizing:"border-box",fontFamily:"inherit"}}),l&&i.createElement("div",{style:{fontSize:9,color:"#5A7090",marginTop:4}},l))}function fk({value:t,onChange:n,label:r,options:o,help:a}){return i.createElement("div",{style:{padding:"10px 20px",borderBottom:"1px solid #0A0E16"}},i.createElement("div",{style:{fontSize:11,color:"#C9D1D9",fontWeight:500,marginBottom:6}},r),i.createElement("select",{value:t||"",onChange:function(l){n(l.target.value)},style:{width:"100%",background:"#0A0E16",border:"1px solid #1C2740",borderRadius:6,padding:"7px 10px",fontSize:11,color:"#E6EDF3",outline:"none",boxSizing:"border-box",cursor:"pointer"}},o.map(function(l){return i.createElement("option",{key:l.value,value:l.value},l.label)})),a&&i.createElement("div",{style:{fontSize:9,color:"#5A7090",marginTop:4}},a))}function x3({settings:t,onChange:n}){var r=t&&t.profile||{},o=(0,i.useState)(null),a=o[0],l=o[1],s=(0,i.useState)(!1),c=s[0],d=s[1];(0,i.useEffect)(function(){On.myXyronKey().then(function(g){g&&g.xyron_key&&l(g.xyron_key)})},[]);function p(){a&&(navigator.clipboard.writeText(a),d(!0),setTimeout(function(){d(!1)},1500))}return i.createElement("div",null,cc({label:"PROFILE",icon:"👤",color:"#D4AF5C"}),i.createElement("div",{style:{margin:"14px 20px",padding:"16px",background:"linear-gradient(135deg, rgba(212,175,92,0.08) 0%, rgba(56,189,248,0.04) 100%)",border:"1px solid rgba(212,175,92,0.25)",borderRadius:12}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8}},i.createElement("span",{style:{fontSize:11}},"🔑"),i.createElement("span",{style:{fontFamily:Xr,fontSize:9,fontWeight:700,color:"#D4AF5C",letterSpacing:".1em"}},"YOUR XYRON KEY")),i.createElement("div",{style:{fontFamily:Xr,fontSize:18,fontWeight:700,color:"#E6EDF3",letterSpacing:".05em",marginBottom:10,userSelect:"all"}},a||"loading…"),i.createElement("div",{style:{display:"flex",gap:6}},i.createElement("button",{onClick:p,disabled:!a,style:{flex:1,padding:"8px",background:c?"#3FB950":"#D4AF5C",border:"none",borderRadius:8,cursor:"pointer",color:"#06080D",fontSize:10,fontWeight:700,fontFamily:Xr,letterSpacing:".06em",transition:"background .15s"}},c?"✓ COPIED":"COPY KEY")),i.createElement("div",{style:{fontSize:9,color:"#8B949E",marginTop:10,lineHeight:1.5}},"Share this key to let other Xyron users connect with you directly. They can add you via Contacts → Add by Xyron Key.")),ic({label:"Display Name",value:r.display_name,onChange:function(g){n({profile:{display_name:g}})},placeholder:"Principal"}),ic({label:"Status Message",value:r.status_message,onChange:function(g){n({profile:{status_message:g}})},placeholder:"What's on your mind?"}
437),fk({label:"Presence Status",value:r.status||"available",onChange:function(g){n({profile:{status:g}})},options:[{value:"available",label:"🟢 Available"},{value:"busy",label:"🟡 Busy"},{value:"away",label:"🔴 Away"},{value:"dnd",label:"⛔ Do Not Disturb"}]}),ic({label:"Avatar URL",value:r.avatar_url,onChange:function(g){n({profile:{avatar_url:g}})},placeholder:"https://..."}))}function v3({settings:t,onChange:n}){var r=t&&t.privacy||{};return i.createElement("div",null,cc({label:"PRIVACY",icon:"🔒",color:"#3FB950"}),uo({label:"Read Receipts",help:"Let others know when you've read their messages",value:r.read_receipts,onChange:function(o){n({privacy:{read_receipts:o}})}}),uo({label:"Typing Indicators",help:"Show when you're typing",value:r.typing_indicators,onChange:function(o){n({privacy:{typing_indicators:o}})}}),uo({label:"Last Seen",help:"Show your last active time",value:r.last_seen,onChange:function(o){n({privacy:{last_seen:o}})}}),uo({label:"Online Status",help:"Show when you're online",value:r.online_status,onChange:function(o){n({privacy:{online_status:o}})}}),uo({label:"Require Encryption",help:"Block any unencrypted channel by default",value:r.require_encryption,onChange:function(o){n({privacy:{require_encryption:o}})}}),uo({label:"Auto-verify Contacts",help:"Automatically trust new contacts' safety numbers",value:r.auto_verify_contacts,onChange:function(o){n({privacy:{auto_verify_contacts:o}})}}),uo({label:"Block Screenshots",help:"Prevent screenshots in chats (where supported)",value:r.block_screenshots,onChange:function(o){n({privacy:{block_screenshots:o}})}}))}function b3({settings:t,onChange:n}){var r=t&&t.notifications||{};return i.createElement("div",null,cc({label:"NOTIFICATIONS",icon:"🔔",color:"#D4AF5C"}),uo({label:"Desktop Notifications",value:r.desktop,onChange:function(o){n({notifications:{desktop:o}})}}),uo({label:"Sound",value:r.sound,onChange:function(o){n({notifications:{sound:o}})}}),uo({label:"Mute All Groups",help:"Silence all group conversations",value:r.mute_groups,onChange:function(o){n({notifications:{mute_groups:o}})}}),uo({label:"Quiet Hours",help:"Silence notifications during specific hours",value:r.quiet_hours_enabled,onChange:function(o){n({notifications:{quiet_hours_enabled:o}})}}),r.quiet_hours_enabled&&ic({label:"Quiet Hours Start",value:r.quiet_hours_start,onChange:function(o){n({notifications:{quiet_hours_start:o}})},placeholder:"22:00",help:"24-hour format"}),r.quiet_hours_enabled&&ic({label:"Quiet Hours End",value:r.quiet_hours_end,onChange:function(o){n({notifications:{quiet_hours_end:o}})},placeholder:"07:00"}))}function S3({settings:t,onChange:n}){var r=t&&t.security||{};return i.createElement("div",null,cc({label:"SECURITY",icon:"🛡",color:"#3FB950"}),fk({label:"Default Disappearing Timer",value:String(r.disappearing_default_seconds||0),onChange:function(o){n({security:{disappearing_default_seconds:parseInt(o,10)}})},options:[{value:"0",label:"Off"},{value:"300",label:"5 minutes"},{value:"3600",label:"1 hour"},{value:"86400",label:"24 hours"},{value:"604800",label:"1 week"}],help:"Applied to new conversations"}),ic({label:"Auto-lock (minutes)",type:"number",value:r.auto_lock_minutes,onChange:function(o){n({security:{auto_lock_minutes:parseInt(o,10)||0}})},help:"Lock messenger after N minutes of inactivity (0 = never)"}),uo({label:"Biometric Required",help:"Require Touch ID / Face ID to unlock",value:r.biometric_required,onChange:function(o){n({security:{biometric_required:o}})}}),uo({label:"Screenshot Protection",value:r.screenshot_protection,onChange:function(o){n({security:{screenshot_protection:o}})}}),uo({label:"Link Previews",help:"Fetch previews for URLs (may leak IP)",value:r.link_preview_enabled,onChange:function(o){n({security:{link_preview_enabled:o}})}}),uo({label:"Auto-download Media",help:"Automatically download images and files",value:r.auto_download_media,onChange:function(o){n({security:{auto_download_media:o}})}}))}function E3({settings:t,onChange:n}){var r=t&&t.ai||{};return i.createElement("div",null,cc({label:"AI INTELLIGENCE",icon:"🤖",color:"#D4AF5C"}),i.createElement("div",{style:{margin:"14px 20px",padding:"12px 14px",background:"rgba(212,175,92,0.04)",border:"1px solid rgba(212,175,92,0.15)",borderRadius:10}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6}},i.createElement("div",{style:{width:6,height:6,borderRadius:"50%",background:"#D4AF5C",boxShadow:"0 0 6px rgba(212,175,92,0.5)"}}),i.createElement("span",{style:{fontFamily:Xr,fontSize:9,fontWeight:700,color:"#D4AF5C",letterSpacing:".1em"}},"XYRON AUTO-ROUTING ACTIVE")),i.createElement("div",{style:{fontSize:10,
437color:"#8B949E",lineHeight:1.55}},"Xyron automatically routes each task to the right Cortex LLM tier — Deep for complex reasoning, Standard for balanced analysis, Fast for quick replies. No manual configuration required.")),uo({label:"Smart Replies",help:"Suggest contextual reply options",value:r.smart_replies_enabled,onChange:function(o){n({ai:{smart_replies_enabled:o}})}}),uo({label:"Tone Analysis",help:"Detect sentiment in incoming messages",value:r.tone_analysis,onChange:function(o){n({ai:{tone_analysis:o}})}}),uo({label:"Entity Extraction",help:"Highlight dates, money, percentages",value:r.entity_extraction,onChange:function(o){n({ai:{entity_extraction:o}})}}),ic({label:"Auto-summarize threshold",type:"number",value:r.auto_summarize_threshold,onChange:function(o){n({ai:{auto_summarize_threshold:parseInt(o,10)||0}})},help:"Offer to summarize when thread exceeds N messages"}))}function k3(t){t&&t.userId;var n=(0,i.useState)([]),r=n[0],o=n[1],a=(0,i.useState)([]),l=a[0],s=a[1],c=(0,i.useState)(null),d=c[0],p=c[1],g=(0,i.useState)({}),f=g[0],h=g[1],x=(0,i.useState)(!1),v=x[0],y=x[1],k=(0,i.useState)(null),A=k[0],j=k[1],E=(0,i.useState)(null),C=E[0],_=E[1],w=(0,i.useState)(!1),O=w[0],M=w[1];function U(){On.availableChannels().then(function(W){o(W.channels||[])}),On.connectedChannels().then(function(W){s(W.integrations||[])}),On.webhookUrls().then(function(W){_(W)})}(0,i.useEffect)(function(){U()},[]);function ee(W,R){j({text:W,error:!!R}),setTimeout(function(){j(null)},4e3)}function N(W){var R=l.find(function(ae){return ae.channel_id===W.id});p(W),h(R?{_existing:!0}:{})}function V(){if(d){y(!0);var W=Object.assign({},f);delete W._existing,On.connectChannel(d.id,W).then(function(R){R.error?ee(R.error,!0):(ee("Connected to "+d.name),p(null),h({}),U(),On.testChannel(d.id).then(function(ae){ae.ok&&ee(d.name+" connection verified")}))}).finally(function(){y(!1)})}}function z(W){confirm("Disconnect "+W+"?")&&On.disconnectChannel(W).then(function(){ee("Disconnected"),U()})}function oe(W){y(!0),On.testChannel(W).then(function(R){R.ok?ee(W+" connection OK"):ee("Test failed: "+(R.error||"unknown"),!0)}).finally(function(){y(!1)})}function P(W){navigator.clipboard.writeText(W),j({text:"Webhook URL copied",error:!1}),setTimeout(function(){j(null)},2e3)}return i.createElement("div",null,cc({label:"CHANNEL INTEGRATIONS",icon:"🔗",color:"#6B9AC4"}),A&&i.createElement("div",{style:{margin:"10px 20px",padding:"8px 12px",borderRadius:6,background:A.error?"rgba(255,68,68,0.1)":"rgba(63,185,80,0.1)",border:"1px solid "+(A.error?"rgba(255,68,68,0.3)":"rgba(63,185,80,0.3)"),fontSize:11,color:A.error?"#D44040":"#3FB950"}},A.text),i.createElement("div",{style:{padding:"10px 20px 0"}},i.createElement("button",{onClick:function(){M(!O)},style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",background:O?"rgba(56,189,248,0.12)":"transparent",border:"1px solid "+(O?"rgba(56,189,248,0.4)":"#1C2740"),borderRadius:6,cursor:"pointer",color:"#6B9AC4",fontSize:10,fontWeight:600,fontFamily:Xr}},i.createElement("span",null,O?"▼":"▶"),i.createElement("span",null,"WEBHOOK URLS FOR PROVIDER SETUP"))),O&&C&&i.createElement("div",{style:{margin:"8px 20px 0",padding:"12px",background:"rgba(56,189,248,0.03)",border:"1px solid rgba(56,189,248,0.15)",borderRadius:10}},i.createElement("div",{style:{fontSize:10,color:"#8B949E",marginBottom:10,lineHeight:1.5}},"Configure these URLs in each provider's dashboard to receive inbound messages. Your server must be publicly reachable."),["whatsapp","telegram","signal","sms"].map(function(W){var R=C[W];return R?i.createElement("div",{key:W,style:{marginBottom:8}},i.createElement("div",{style:{fontSize:9,color:"#5A7090",marginBottom:3,fontFamily:Xr,letterSpacing:".05em",textTransform:"uppercase"}},W),i.createElement("div",{style:{display:"flex",gap:4,alignItems:"center"}},i.createElement("code",{style:{flex:1,padding:"6px 10px",background:"#0A0E16",borderRadius:4,fontSize:9,color:"#E6EDF3",fontFamily:Xr,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",border:"1px solid #1C2740"}},R),i.createElement("button",{onClick:function(){P(R)},style:{padding:"6px 10px",background:"#6B9AC4",border:"none",borderRadius:4,cursor:"pointer",color:"#06080D",fontSize:9,fontWeight:700}},"COPY"))):null})),d&&i.createElement("div",{style:{padding:"16px 20px",background:"rgba(56,189,248,0.04)",borderBottom:"1px solid #111820"}},i.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12}},i.createElement("div",{style:{fontSize:13,fontWeight:600,color:"#E6EDF3"}},"Connect "+d.name),i.createElement("button",{onClick:function(){p(null),h({})},style:{background:"none",border:"none",color:"#5A7090",cursor:"pointer",fontSize:16}}
437,"✕")),i.createElement("div",{style:{fontSize:10,color:"#8B949E",marginBottom:12}},d.description),(d.fields||[]).map(function(W){return i.createElement("div",{key:W.key,style:{marginBottom:10}},i.createElement("label",{style:{display:"block",fontSize:10,color:"#C9D1D9",marginBottom:4,fontWeight:500}},W.label,W.required&&i.createElement("span",{style:{color:"#D44040",marginLeft:4}},"*")),i.createElement("input",{type:W.type||"text",value:f[W.key]||"",onChange:function(R){var ae=R.target.value;h(function(q){var ge=Object.assign({},q);return ge[W.key]=ae,ge})},placeholder:W.help||"",style:{width:"100%",background:"#0A0E16",border:"1px solid #1C2740",borderRadius:6,padding:"7px 10px",fontSize:11,color:"#E6EDF3",outline:"none",boxSizing:"border-box",fontFamily:"monospace"}}),W.help&&i.createElement("div",{style:{fontSize:9,color:"#5A7090",marginTop:3}},W.help))}),i.createElement("button",{onClick:V,disabled:v,style:{marginTop:8,padding:"8px 20px",background:v?"#2A3548":"#D4AF5C",border:"none",borderRadius:6,cursor:v?"wait":"pointer",color:v?"#5A7090":"#06080D",fontSize:11,fontWeight:600}},v?"Connecting…":"Connect")),i.createElement("div",{style:{padding:"12px 20px",fontFamily:Xr,fontSize:9,color:"#5A7090",letterSpacing:".1em",textTransform:"uppercase"}},"Available Channels"),r.map(function(W){var R=l.find(function(ae){return ae.channel_id===W.id});return i.createElement("div",{key:W.id,style:{display:"flex",alignItems:"center",gap:12,padding:"10px 20px",borderBottom:"1px solid #0A0E16",transition:"background .15s"}},i.createElement("div",{style:{width:36,height:36,borderRadius:10,background:(W.color||"#5A7090")+"20",border:"1px solid "+(W.color||"#5A7090")+"40",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,color:W.color,flexShrink:0}},(W.name||"?")[0]),i.createElement("div",{style:{flex:1,minWidth:0}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:6}},i.createElement("span",{style:{fontSize:12,color:"#E6EDF3",fontWeight:500}},W.name),R&&i.createElement("span",{style:{fontSize:9,padding:"1px 6px",background:"rgba(63,185,80,0.12)",border:"1px solid rgba(63,185,80,0.3)",borderRadius:4,color:"#3FB950",fontFamily:Xr,fontWeight:600}},"CONNECTED")),i.createElement("div",{style:{fontSize:10,color:"#5A7090",marginTop:2}},W.description)),i.createElement("div",{style:{display:"flex",gap:6}},R&&i.createElement("button",{onClick:function(){oe(W.id)},style:{padding:"4px 10px",background:"transparent",border:"1px solid #6B9AC440",borderRadius:6,cursor:"pointer",color:"#6B9AC4",fontSize:9,fontFamily:Xr}},"TEST"),R&&i.createElement("button",{onClick:function(){z(W.id)},style:{padding:"4px 10px",background:"transparent",border:"1px solid rgba(255,68,68,0.3)",borderRadius:6,cursor:"pointer",color:"#D44040",fontSize:9,fontFamily:Xr}},"REMOVE"),!R&&W.requires_setup&&i.createElement("button",{onClick:function(){N(W)},style:{padding:"4px 10px",background:W.color,border:"none",borderRadius:6,cursor:"pointer",color:"#06080D",fontSize:9,fontFamily:Xr,fontWeight:700}},"CONNECT"),!R&&!W.requires_setup&&i.createElement("span",{style:{fontSize:9,color:"#3FB950",fontFamily:Xr,padding:"4px 10px"}},"BUILT-IN")))}))}function C3(t){t&&t.onClose;var n=(0,i.useState)([]),r=n[0],o=n[1],a=(0,i.useState)([]),l=a[0],s=a[1],c=(0,i.useState)(null),d=c[0],p=c[1],g=(0,i.useState)({name:"",email:"",phone:"",organisation:""}),f=g[0],h=g[1],x=(0,i.useState)(!1),v=x[0],y=x[1],k=(0,i.useState)(!1),A=k[0],j=k[1],E=(0,i.useState)(""),C=E[0],_=E[1],w=(0,i.useState)(""),O=w[0],M=w[1],U=(0,i.useState)([]),ee=U[0],N=U[1],V=(0,i.useState)(""),z=V[0],oe=V[1],P=(0,i.useState)(!1),W=P[0],R=P[1],ae=(0,i.useState)(null),q=ae[0],ge=ae[1];function X(){On.contacts().then(function(re){o(re.contacts||[])}),On.blockedList().then(function(re){s(re.blocked||[])}),On.listConnectionRequests().then(function(re){N(re.requests||[])})}function de(re,we){ge({text:re,error:!!we}),setTimeout(function(){ge(null)},3500)}function We(){var re=C.trim();re&&(R(!0),On.sendConnectionRequest(re,O).then(function(we){we&&we.error?de(we.error,!0):we&&we.success&&(de(we.duplicate?"Already sent":"Connection request sent"),_(""),M(""),j(!1))}).finally(function(){R(!1)}))}function te(re,we){On.respondConnectionRequest(re,we).then(function(b){if(b&&b.error){de(b.error,!0);return}de(we?"Accepted":"Rejected"),X()})}(0,i.useEffect)(function(){X()},[]);function _e(){!f.name&&!f.email&&!f.phone||On.addContact(f).then(function(){h({name:"",email:"",ph
437one:"",organisation:""}),y(!1),X()})}function ve(re){confirm("Block this contact?")&&On.blockContact(re).then(X)}function Ne(re){On.unblockContact(re).then(X)}function $e(re){confirm("Remove this contact?")&&On.removeContact(re).then(X)}function Pe(){On.generateInvite(72).then(function(re){p(re)})}var ot=r.filter(function(re){if(!z)return!0;var we=z.toLowerCase();return(re.name||"").toLowerCase().indexOf(we)>=0||(re.email||"").toLowerCase().indexOf(we)>=0||(re.organisation||"").toLowerCase().indexOf(we)>=0});return i.createElement("div",null,cc({label:"CONTACTS",icon:"👥",color:"#6B9AC4"}),q&&i.createElement("div",{style:{margin:"10px 20px",padding:"8px 12px",borderRadius:6,background:q.error?"rgba(255,68,68,0.1)":"rgba(63,185,80,0.1)",border:"1px solid "+(q.error?"rgba(255,68,68,0.3)":"rgba(63,185,80,0.3)"),fontSize:11,color:q.error?"#D44040":"#3FB950"}},q.text),ee.length>0&&i.createElement("div",{style:{margin:"12px 20px",padding:"12px",background:"rgba(212,175,92,0.04)",border:"1px solid rgba(212,175,92,0.2)",borderRadius:10}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:10}},i.createElement("span",{style:{fontSize:11}},"📨"),i.createElement("span",{style:{fontFamily:Xr,fontSize:9,fontWeight:700,color:"#D4AF5C",letterSpacing:".1em"}},"CONNECTION REQUESTS ("+ee.length+")")),ee.map(function(re){return i.createElement("div",{key:re.id,style:{display:"flex",alignItems:"center",gap:8,padding:"8px 0",borderBottom:"1px solid rgba(212,175,92,0.1)"}},i.createElement("div",{style:{width:32,height:32,borderRadius:"50%",background:"#D4AF5C20",border:"1px solid #D4AF5C40",display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:700,color:"#D4AF5C",flexShrink:0}},(re.from_name||"?")[0].toUpperCase()),i.createElement("div",{style:{flex:1,minWidth:0}},i.createElement("div",{style:{fontSize:11,color:"#E6EDF3",fontWeight:600}},re.from_name),i.createElement("div",{style:{fontSize:9,color:"#5A7090",fontFamily:Xr,marginTop:1}},re.from_xyron_key),re.message&&i.createElement("div",{style:{fontSize:10,color:"#8B949E",marginTop:3,fontStyle:"italic"}},'"'+re.message+'"')),i.createElement("button",{onClick:function(){te(re.id,!0)},style:{padding:"5px 10px",background:"#3FB950",border:"none",borderRadius:6,cursor:"pointer",color:"#06080D",fontSize:9,fontWeight:700,fontFamily:Xr}},"ACCEPT"),i.createElement("button",{onClick:function(){te(re.id,!1)},style:{padding:"5px 10px",background:"transparent",border:"1px solid #D4404040",borderRadius:6,cursor:"pointer",color:"#D44040",fontSize:9,fontWeight:600,fontFamily:Xr}},"REJECT"))})),i.createElement("div",{style:{padding:"12px 20px",display:"flex",gap:6,alignItems:"center",borderBottom:"1px solid #0A0E16",flexWrap:"wrap"}},i.createElement("input",{value:z,onChange:function(re){oe(re.target.value)},placeholder:"Search contacts…",style:{flex:1,minWidth:140,background:"#0A0E16",border:"1px solid #1C2740",borderRadius:6,padding:"7px 10px",fontSize:11,color:"#E6EDF3",outline:"none"}}),i.createElement("button",{onClick:function(){j(!A),y(!1)},style:{padding:"7px 12px",background:"#D4AF5C",border:"none",borderRadius:6,cursor:"pointer",color:"#06080D",fontSize:10,fontWeight:700}},A?"Cancel":"🔑 Add by Key"),i.createElement("button",{onClick:function(){y(!v),j(!1)},style:{padding:"7px 12px",background:"transparent",border:"1px solid #6B9AC440",borderRadius:6,cursor:"pointer",color:"#6B9AC4",fontSize:10,fontWeight:600}},v?"Cancel":"+ Manual"),i.createElement("button",{onClick:Pe,style:{padding:"7px 12px",background:"transparent",border:"1px solid rgba(212,175,92,0.3)",borderRadius:6,cursor:"pointer",color:"#D4AF5C",fontSize:10,fontWeight:600}},"Invite Link")),A&&i.createElement("div",{style:{padding:"12px 20px",background:"rgba(212,175,92,0.04)",borderBottom:"1px solid #111820"}},i.createElement("div",{style:{fontSize:10,color:"#D4AF5C",marginBottom:8,fontFamily:Xr,letterSpacing:".05em"}},"ENTER XYRON KEY"),i.createElement("input",{value:C,onChange:function(re){_(re.target.value)},placeholder:"xy:a4f2-9e8c-1b3d",style:{width:"100%",background:"#0A0E16",border:"1px solid #D4AF5C40",borderRadius:6,padding:"9px 12px",fontSize:14,color:"#E6EDF3",outline:"none",boxSizing:"border-box",fontFamily:Xr,letterSpacing:".05em",marginBottom:8}}),i.createElement("textarea",{value:O,onChange:function(re){M(re.target.value)},placeholder:"Optional introduction message…",rows:2,style:{width:"100%",background:"#0A0E16",border:"1px solid #1C2740",borderRadius:6,padding:"7px 10px",fontSize:11,color:"#E6EDF3",outline:"none",boxSizing:"border-box",resize:"none",marginBottom:8}}),i.createElement("button",{onClick:We,disabled:!C.trim()||W,style:{padding:"8px 16px",background:W?"#2A3548":"#D4AF5C",border:"none",borderRadius:6,cursor:W?"wait":"pointer",color:W?"#5A7090":"#06080D",fontSize:10,fontWeight:700}},W?"Sending…":"Send Connection Request"),i.createElement("div",{style:{fontSize:9,color:"#8B949E",marginTop:6,lineHeight:1.5}},"The recipient will see your request in their Contacts tab and can accept or reject.")),d&&i.createElement("div",{style:{padding:"10px 20px",background:"rgba(212,175,92,0.05)",borderBottom:"1px solid #111820"}}
437,i.createElement("div",{style:{fontSize:10,color:"#D4AF5C",marginBottom:4}},"Share this invite link (expires in "+d.expires_hours+"h):"),i.createElement("div",{style:{display:"flex",gap:6,alignItems:"center"}},i.createElement("code",{style:{flex:1,padding:"6px 10px",background:"#0A0E16",borderRadius:4,fontSize:10,color:"#E6EDF3",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},window.location.origin+d.invite_url),i.createElement("button",{onClick:function(){navigator.clipboard.writeText(window.location.origin+d.invite_url)},style:{padding:"6px 10px",background:"#6B9AC4",border:"none",borderRadius:4,cursor:"pointer",color:"#06080D",fontSize:9,fontWeight:700}},"COPY"),i.createElement("button",{onClick:function(){p(null)},style:{background:"none",border:"none",color:"#5A7090",cursor:"pointer",fontSize:14}},"✕"))),v&&i.createElement("div",{style:{padding:"12px 20px",background:"rgba(212,175,92,0.03)",borderBottom:"1px solid #111820"}},i.createElement("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8,marginBottom:8}},i.createElement("input",{value:f.name,onChange:function(re){h(Object.assign({},f,{name:re.target.value}))},placeholder:"Name",style:tg()}),i.createElement("input",{value:f.email,onChange:function(re){h(Object.assign({},f,{email:re.target.value}))},placeholder:"Email",style:tg()}),i.createElement("input",{value:f.phone,onChange:function(re){h(Object.assign({},f,{phone:re.target.value}))},placeholder:"Phone (E.164)",style:tg()}),i.createElement("input",{value:f.organisation,onChange:function(re){h(Object.assign({},f,{organisation:re.target.value}))},placeholder:"Organisation",style:tg()})),i.createElement("button",{onClick:_e,disabled:!f.name&&!f.email&&!f.phone,style:{padding:"6px 14px",background:"#D4AF5C",border:"none",borderRadius:6,cursor:"pointer",color:"#06080D",fontSize:10,fontWeight:700}},"Add Contact")),i.createElement("div",null,ot.length===0&&i.createElement("div",{style:{padding:"24px 20px",textAlign:"center",fontSize:10,color:"#3A4A5E"}},z?"No matches":"No contacts yet"),ot.map(function(re){var we=l.indexOf(re.contact_id)>=0;return i.createElement("div",{key:re.contact_id,style:{display:"flex",alignItems:"center",gap:10,padding:"10px 20px",borderBottom:"1px solid #0A0E16"}},i.createElement("div",{style:{width:32,height:32,borderRadius:"50%",background:"#D4AF5C20",border:"1px solid #D4AF5C40",display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:700,color:"#D4AF5C",flexShrink:0}},(re.name||"?")[0].toUpperCase()),i.createElement("div",{style:{flex:1,minWidth:0}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:6}},i.createElement("span",{style:{fontSize:12,color:"#E6EDF3",fontWeight:500}},re.name),we&&i.createElement("span",{style:{fontSize:9,padding:"1px 5px",background:"rgba(255,68,68,0.15)",border:"1px solid rgba(255,68,68,0.3)",borderRadius:3,color:"#D44040",fontFamily:Xr}},"BLOCKED")),i.createElement("div",{style:{fontSize:10,color:"#5A7090",marginTop:2}},re.email||re.phone||re.organisation||"")),i.createElement("div",{style:{display:"flex",gap:4}},we?i.createElement("button",{onClick:function(){Ne(re.contact_id)},style:Uh("#3FB950")},"UNBLOCK"):i.createElement("button",{onClick:function(){ve(re.contact_id)},style:Uh("#D44040")},"BLOCK"),re.source==="manual"&&i.createElement("button",{onClick:function(){$e(re.contact_id)},style:Uh("#5A7090")},"REMOVE")))})))}function A3({settings:t,onChange:n}){var r=t&&t.data||{},o=(0,i.useState)(null),a=o[0],l=o[1];return(0,i.useEffect)(function(){On.storageStats().then(function(s){l(s)})},[]),i.createElement("div",null,cc({label:"DATA & STORAGE",icon:"💾",color:"#D4AF5C"}),a&&i.createElement("div",{style:{margin:"14px 20px",padding:"14px 16px",background:"rgba(212,175,92,0.04)",border:"1px solid rgba(212,175,92,0.15)",borderRadius:10}},i.createElement("div",{style:{fontFamily:Xr,fontSize:9,color:"#D4AF5C",letterSpacing:".1em",marginBottom:10}},"STORAGE USAGE"),i.createElement("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:12}},ng("Conversations",a.conversation_count),ng("Messages",a.message_count),ng("Contacts",a.contacts),ng("Est. Size",a.estimated_size_mb+" MB"))),ic({label:"Message Retention (days)",type:"number",value:r.message_retention_days,onChange:function(s){n({data:{message_retention_days:parseInt(s,10)||0}})},help:"Auto-delete messages older than N days (0 = forever)"}),ic({label:"Auto-archive (days)",type:"number",value:r.auto_archive_days,onChange:function(s){n({data:{auto_archive_days:parseInt(s,10)||0}})},help:"Archive inactive conversations after N days"}),uo({label:"Cloud Backup",help:"Encrypted backup to Xyron Vault",value:r.backup_enabled,onChange:function(s){n({data:{backup_enabled:s}})}}))}function j3(){var t=(0,i.useState)(!1),n=t[0],r=t[1],o=(0,i.useState)(null),a=o[0],l=o[1];function s(){confirm("Rotate your encryption keys? You'll need to re-verify all contacts.")&&(r(!0),On.rotateKeys().then(function(){l("Ke
437ys rotated. Publish new public key from client."),setTimeout(function(){l(null)},4e3)}).finally(function(){r(!1)}))}return i.createElement("div",null,cc({label:"ENCRYPTION KEYS",icon:"🔑",color:"#3FB950"}),a&&i.createElement("div",{style:{margin:"10px 20px",padding:"8px 12px",borderRadius:6,background:"rgba(63,185,80,0.1)",border:"1px solid rgba(63,185,80,0.3)",fontSize:11,color:"#3FB950"}},a),i.createElement("div",{style:{padding:"14px 20px"}},i.createElement("div",{style:{padding:14,background:"rgba(63,185,80,0.04)",border:"1px solid rgba(63,185,80,0.15)",borderRadius:10,marginBottom:12}},i.createElement("div",{style:{fontSize:10,color:"#3FB950",fontWeight:600,marginBottom:6}},"🛡 Your device is E2E encrypted"),i.createElement("div",{style:{fontSize:10,color:"#8B949E",lineHeight:1.5}},"Messages are encrypted with ECDH key exchange. Only you and your recipient can read them — Xyron servers never see plaintext.")),i.createElement("button",{onClick:s,disabled:n,style:{width:"100%",padding:"10px",background:n?"#2A3548":"#3FB950",border:"none",borderRadius:8,cursor:n?"wait":"pointer",color:"#06080D",fontSize:11,fontWeight:700}},n?"Rotating…":"🔄 Rotate Encryption Keys")))}function w3({onClose:t}){var n=(0,i.useState)("profile"),r=n[0],o=n[1],a=(0,i.useState)(null),l=a[0],s=a[1],c=(0,i.useState)(!1),d=c[0],p=c[1];(0,i.useEffect)(function(){On.getSettings().then(function(f){s(f)})},[]);function g(f){p(!0),s(function(h){return pk(JSON.parse(JSON.stringify(h||{})),f)}),On.updateSettings(f).then(function(h){h&&s(h)}).finally(function(){setTimeout(function(){p(!1)},300)})}return i.createElement("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:60,background:"rgba(5,8,13,0.92)",backdropFilter:"blur(8px)",display:"flex",alignItems:"center",justifyContent:"center",padding:20,animation:"xfadein 0.15s ease-out"}},i.createElement("div",{style:{width:"100%",maxWidth:760,maxHeight:"90vh",background:"#06080D",border:"1px solid #1C2740",borderRadius:14,display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 20px 60px rgba(0,0,0,0.5)"}},i.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 20px",borderBottom:"1px solid #111820",background:"rgba(212,175,92,0.03)"}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:10}},i.createElement("div",{style:{width:8,height:8,borderRadius:"50%",background:"#D4AF5C",boxShadow:"0 0 8px rgba(212,175,92,0.5)"}}),i.createElement("span",{style:{fontFamily:Xr,fontSize:12,fontWeight:700,color:"#D4AF5C",letterSpacing:".12em"}},"MESSENGER SETTINGS"),d&&i.createElement("span",{style:{fontSize:9,color:"#3FB950",fontFamily:Xr,marginLeft:6}},"✓ SAVED")),i.createElement("button",{onClick:t,style:{background:"none",border:"none",color:"#8B949E",cursor:"pointer",fontSize:18}},"✕")),i.createElement("div",{style:{display:"flex",flex:1,overflow:"hidden"}},i.createElement("div",{style:{width:180,borderRight:"1px solid #111820",padding:"8px 0",flexShrink:0,overflowY:"auto"}},[{id:"profile",label:"Profile",icon:"👤"},{id:"privacy",label:"Privacy",icon:"🔒"},{id:"notifications",label:"Notifications",icon:"🔔"},{id:"security",label:"Security",icon:"🛡"},{id:"ai",label:"AI",icon:"🤖"},{id:"integrations",label:"Integrations",icon:"🔗"},{id:"contacts",label:"Contacts",icon:"👥"},{id:"keys",label:"Keys",icon:"🔑"},{id:"data",label:"Data",icon:"💾"}].map(function(f){var h=r===f.id;return i.createElement("button",{key:f.id,onClick:function(){o(f.id)},style:{width:"100%",display:"flex",alignItems:"center",gap:10,padding:"10px 16px",background:h?"rgba(212,175,92,0.08)":"transparent",border:"none",borderLeft:h?"3px solid #D4AF5C":"3px solid transparent",cursor:"pointer",color:h?"#E6EDF3":"#8B949E",fontSize:12,textAlign:"left",transition:"all .15s"}},i.createElement("span",{style:{fontSize:13}},f.icon),i.createElement("span",null,f.label))})),i.createElement("div",{style:{flex:1,overflowY:"auto"}},r==="profile"&&x3({settings:l,onChange:g}),r==="privacy"&&v3({settings:l,onChange:g}),r==="notifications"&&b3({settings:l,onChange:g}),r==="security"&&S3({settings:l,onChange:g}),r==="ai"&&E3({settings:l,onChange:g}),r==="integrations"&&i.createElement(k3,null),r==="contacts"&&i.createElement(C3,{onClose:t}),r==="keys"&&i.createElement(j3,null),r==="data"&&A3({settings:l,onChange:g})))))}function tg(){return{background:"#0A0E16",border:"1px solid #1C2740",borderRadius:6,padding:"7px 10px",fontSize:11,color:"#E6EDF3",outline:"none",boxSizing:"border-box",width:"100%"}}function Uh(t){return{padding:"4px 10px",background:"transparent",border:"1px solid "+t+"40",borderRadius:4,cursor:"pointer",color:t,fontSize:9,fontFamily:Xr,fontWeight:600}}function ng(t,n){return i.createElement("div",null,i.createElement("div",{style:{fontSize:9,color:"#5A7090",fontFamily:Xr,letterSpacing:".08em"}},t.toUpperCase()),i.createElement("div",{style:{fontSize:18,color:"#D4AF5C",fontWeight:700,fontFamily:Xr,marginTop:2}},n))}function pk(t,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(typeof n[r]=="object"&&n[r]!==null&&!Array.isArray(n[r])&&typeof t[r]=="object"&&t[r]!==null?pk(t[r],n[r]):t[r]=n[r]);return t}var bs="monospace",Ss={xyron:"#D4AF5C",telegram:"#6B9AC4",whatsapp:"#3FB950",
437signal:"#E6EDF3"},pS={xyron:"🛡",telegram:"✈",whatsapp:"💬",signal:"🔒"};function T3({onClose:t,onStartCall:n}){var r=(0,i.useState)([]),o=r[0],a=r[1],l=(0,i.useState)([]),s=l[0],c=l[1],d=(0,i.useState)(null),p=d[0],g=d[1],f=(0,i.useState)([]),h=f[0],x=f[1],v=(0,i.useState)(""),y=v[0],k=v[1],A=(0,i.useState)([]),j=A[0],E=A[1],C=(0,i.useState)(null),_=C[0],w=C[1],O=(0,i.useState)(""),M=O[0],U=O[1],ee=(0,i.useState)(null),N=ee[0],V=ee[1],z=(0,i.useState)(null),oe=z[0],P=z[1],W=(0,i.useState)(null),R=W[0],ae=W[1],q=(0,i.useState)(null),ge=q[0],X=q[1],de=(0,i.useState)(!1),We=de[0],te=de[1],_e=(0,i.useState)(null),ve=_e[0],Ne=_e[1],$e=(0,i.useState)(!1),Pe=$e[0],ot=$e[1],re=(0,i.useState)(!1),we=re[0],b=re[1],He=(0,i.useState)(0),tt=He[0],Ae=He[1],Be=(0,i.useRef)(null),Fe=(0,i.useRef)(null),ft=(0,i.useRef)(null),St=(0,i.useRef)({}),Xe=(0,i.useRef)(null),It="principal";(0,i.useEffect)(function(){On.contacts().then(function(fe){a(fe.contacts||[])}).catch(function(){}),On.conversations().then(function(fe){c(fe.conversations||[])}).catch(function(){}),On.listConnectionRequests().then(function(fe){Ae((fe.requests||[]).length)}).catch(function(){}),Rt(),Ue();var xe=setInterval(function(){On.listConnectionRequests().then(function(fe){Ae((fe.requests||[]).length)}).catch(function(){})},15e3);return function(){if(Fe.current)try{Fe.current.close()}catch{}clearInterval(xe)}},[]);async function Rt(){var xe=zu.loadKeys(It);if(xe&&xe.pub&&xe.priv){ft.current=xe,ot(!0);return}try{var fe=await zu.generateKeyPair();ft.current={pub:fe.publicKey,priv:fe.privateKey},zu.storeKeys(It,fe),await On.publishKey({public_key_jwk:JSON.stringify(fe.publicKey)}),ot(!0)}catch(Ye){console.warn("E2E init failed:",Ye)}}async function $(xe){if(St.current[xe])return St.current[xe];if(!ft.current)return null;try{var fe=await On.getKey(xe);if(!fe||fe.error||!fe.public_key)return null;var Ye=typeof fe.public_key=="string"?JSON.parse(fe.public_key):fe.public_key,Qe=await zu.deriveSharedKey(ft.current.priv,Ye);return St.current[xe]=Qe,Qe}catch{return null}}function Ue(){var xe=On.streamUrl(It);if(!(!xe||xe.indexOf("undefined")>=0)){var fe=new WebSocket(xe);Fe.current=fe,fe.onopen=function(){var Ye=localStorage.getItem("xyron_access_token")||"";fe.send(JSON.stringify({type:"auth",token:Ye}))},fe.onmessage=function(Ye){try{var Qe=JSON.parse(Ye.data);Qe.type==="message"?((async function(){if(Qe.encrypted&&Qe.text&&ft.current)try{var ut=await $(Qe.sender_id);ut&&(Qe.text=await zu.decrypt(ut,Qe.text))}catch{Qe.text="[encrypted — key mismatch]"}x(function(wt){return wt.some(function(H){return H.message_id===Qe.message_id})?wt:wt.concat([Qe])})})(),On.conversations().then(function(ut){c(ut.conversations||[])}).catch(function(){}),Fe.current&&Fe.current.readyState===WebSocket.OPEN&&Fe.current.send(JSON.stringify({type:"delivered",message_id:Qe.message_id}))):Qe.type==="typing"?(Ne(Qe),setTimeout(function(){Ne(null)},3e3)):Qe.type==="message_edited"?x(function(ut){return ut.map(function(wt){return wt.message_id===Qe.message_id?Object.assign({},wt,{text:Qe.text,edited:!0}):wt})}):Qe.type==="message_deleted"?x(function(ut){return ut.map(function(wt){return wt.message_id===Qe.message_id?Object.assign({},wt,{text:"[deleted]",deleted:!0}):wt})}):Qe.type==="reaction"?x(function(ut){return ut.map(function(wt){return wt.message_id===Qe.message_id?Object.assign({},wt,{reactions:Qe.reactions}):wt})}):Qe.type==="read_receipt"?x(function(ut){return ut.map(function(wt){return wt.sender_id===It?Object.assign({},wt,{status:"read"}):wt})}):Qe.type==="connection_request"?(Ae(function(ut){return ut+1}),Pt((Qe.request&&Qe.request.from_name||"Someone")+" wants to connect")):Qe.type==="connection_accepted"&&(Pt("Your connection request was accepted"),On.conversations().then(function(ut){c(ut.conversations||[])}).catch(function(){}))}catch{}},fe.onclose=function(){setTimeout(Ue,3e3)}}}function Ie(xe){g(xe),x([]),ae(null),X(null),E([]),On.messages(xe.conversation_id).then(function(fe){x(fe.messages||[])}).catch(function(){}),xe.ai_enabled&&On.smartReply(xe.conversation_id).then(function(fe){E(fe.replies||[])}).catch(function(){}),Fe.current&&Fe.current.readyState===WebSocket.OPEN&&Fe.current.send(JSON.stringify({type:"read",conversation_id:xe.conversation_id}))}async function Q(xe){if(!(!xe||!p)){xe.startsWith("@xyron ")&&On.askXyron(p.conversation_id,xe.slice(7)).then(function(ut){X(ut)}).catch(function(){});var fe={conversation_id:p.conversation_id,text:xe};if(p.encrypted&&Pe)try{var Ye=(p.participants||[]).find(function(ut){return ut!==It});if(Ye){var Qe=await $(Ye);Qe&&(fe.encrypted_payload=await zu.encrypt(Qe,xe))}}catch(ut){console.warn("E2E encrypt failed, sending plaintext:",ut)}On.send(fe).then(function(ut){ut&&!ut.error&&(ut.text=xe,x(function(wt){return wt.concat([ut])}),k(""),p.ai_enabled&&On.smartReply(p.conversation_id).then(function(wt){E(wt.replies||[])}).catch(function(){}))}).catch(function(){})}}function rt(xe){!xe||!p||(Pt("Uploading "+xe.name+"…"),gn.upload(xe,xe.name,"messenger_attachment").then(function(fe){fe&&fe.document_id?On.send({conversation_id:p.conversation_id,text:xe.name,message_type:"file",file_vault_id:fe.document_id,file_name:xe.name,file_type:xe.type||"application/octet-stream"}).then(function(Ye){Ye&&!Ye.error&&x(function(Qe){return Qe.concat([Ye])}),Pt("Sent "+xe.name)}
437).catch(function(){Pt("Send failed")}):Pt("Upload failed")}).catch(function(){Pt("Upload failed")}))}function jt(xe){On.createConvo({participant_ids:[xe.contact_id],title:xe.name,channel:"xyron"}).then(function(fe){fe&&(c(function(Ye){return[fe].concat(Ye)}),Ie(fe),te(!1))}).catch(function(){})}function tn(){p&&On.summarize(p.conversation_id).then(function(xe){ae(xe.summary||"No summary available.")}).catch(function(){})}function pt(){if(p){var xe=!p.ai_enabled;On.toggleAi(p.conversation_id,xe).then(function(){g(function(fe){return Object.assign({},fe,{ai_enabled:xe})}),Pt(xe?"AI enabled for this thread":"AI disabled")}).catch(function(){})}}function gt(xe){p&&On.setDisappearing(p.conversation_id,xe).then(function(){g(function(fe){return Object.assign({},fe,{disappearing:xe})}),Pt(xe>0?"Disappearing messages: "+xe+"s":"Disappearing messages off")}).catch(function(){})}function qt(xe){Ja.createRoom({title:"Messenger Call"}).then(function(fe){fe&&fe.room_url&&n&&n({roomUrl:fe.room_url,token:fe.owner_token,eventId:null})}).catch(function(){})}function Pt(xe){P(xe),setTimeout(function(){P(null)},3e3)}(0,i.useEffect)(function(){Be.current&&Be.current.scrollIntoView({behavior:"smooth"})},[h]);var Kt=(0,i.useMemo)(function(){if(!M)return s;var xe=M.toLowerCase();return s.filter(function(fe){return(fe.title||"").toLowerCase().indexOf(xe)>=0})},[s,M]);return i.createElement("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:50,background:"#05080D",display:"flex",overflow:"hidden",animation:"vidSlideUp 0.2s ease-out",fontFamily:"'Inter',system-ui,sans-serif"}},i.createElement("div",{style:{width:320,borderRight:"1px solid #111820",display:"flex",flexDirection:"column",background:"#06080D",flexShrink:0}},i.createElement("div",{style:{padding:"12px 16px",borderBottom:"1px solid #111820"}},i.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:8}},i.createElement("div",{style:{width:8,height:8,borderRadius:"50%",background:"#D4AF5C",boxShadow:"0 0 8px rgba(212,175,92,0.4)"}}),i.createElement("span",{style:{fontFamily:bs,fontSize:11,fontWeight:700,color:"#D4AF5C",letterSpacing:".12em"}},"XYRON MESSENGER")),i.createElement("div",{style:{display:"flex",gap:4}},i.createElement("button",{onClick:function(){te(!We)},title:"New chat",style:Wh("#D4AF5C")},"+"),i.createElement("div",{style:{position:"relative"}},i.createElement("button",{onClick:function(){b(!0)},title:"Settings",style:Wh(tt>0?"#D4AF5C":"#8B949E")},"⚙"),tt>0&&i.createElement("span",{style:{position:"absolute",top:-2,right:-2,minWidth:14,height:14,borderRadius:7,background:"#D4AF5C",color:"#06080D",fontSize:8,fontWeight:800,display:"flex",alignItems:"center",justifyContent:"center",padding:"0 4px",border:"2px solid #06080D"}},tt)),i.createElement("button",{onClick:t,title:"Close",style:Wh("#5A7090")},"✕"))),i.createElement("input",{type:"text",value:M,onChange:function(xe){U(xe.target.value)},placeholder:"Search conversations…",style:{width:"100%",background:"#0A0E16",border:"1px solid #1C2740",borderRadius:8,padding:"7px 12px",fontSize:11,color:"#C9D1D9",outline:"none",boxSizing:"border-box"}})),We&&i.createElement("div",{style:{padding:"8px 12px",borderBottom:"1px solid #111820",background:"rgba(212,175,92,0.03)",maxHeight:200,overflow:"auto"}},i.createElement("div",{style:{fontFamily:bs,fontSize:8,color:"#D4AF5C",letterSpacing:".08em",marginBottom:6}},"START NEW CHAT"),o.map(function(xe){return i.createElement("div",{key:xe.contact_id,onClick:function(){jt(xe)},style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",borderRadius:6,cursor:"pointer",transition:"all .15s"},onMouseEnter:function(fe){fe.currentTarget.style.background="rgba(212,175,92,0.06)"},onMouseLeave:function(fe){fe.currentTarget.style.background="transparent"}},i.createElement("div",{style:{width:28,height:28,borderRadius:"50%",background:"#D4AF5C15",border:"1.5px solid #D4AF5C30",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,color:"#D4AF5C"}},(xe.name||"?")[0].toUpperCase()),i.createElement("div",null,i.createElement("div",{style:{fontSize:11,color:"#E6EDF3",fontWeight:500}},xe.name),i.createElement("div",{style:{fontSize:9,color:"#3A4A5E"}},xe.organisation||xe.email||"Xyron Secure")))})),i.createElement("div",{style:{flex:1,overflow:"auto"}},Kt.length===0&&i.createElement("div",{style:{textAlign:"center",padding:"40px 16px"}},i.createElement("div",{style:{fontSize:28,opacity:.2,marginBottom:8}}
437,"🛡"),i.createElement("div",{style:{fontSize:10,color:"#3A4A5E"}},"No conversations yet"),i.createElement("button",{onClick:function(){te(!0)},style:{marginTop:12,padding:"6px 16px",background:"rgba(212,175,92,0.08)",border:"1px solid rgba(212,175,92,0.25)",borderRadius:8,cursor:"pointer",fontSize:10,fontWeight:600,color:"#D4AF5C"}},"Start a Secure Chat")),Kt.map(function(xe){var fe=p&&p.conversation_id===xe.conversation_id,Ye=xe.channel||"xyron",Qe=Ss[Ye]||"#D4AF5C",ut=xe.last_message,wt=xe.unread||0;return i.createElement("div",{key:xe.conversation_id,onClick:function(){Ie(xe)},style:{display:"flex",alignItems:"center",gap:10,padding:"10px 16px",borderBottom:"1px solid #0A0E16",cursor:"pointer",background:fe?"rgba(212,175,92,0.06)":"transparent",borderLeft:fe?"3px solid #D4AF5C":"3px solid transparent",transition:"all .15s"},onMouseEnter:function(H){fe||(H.currentTarget.style.background="rgba(212,175,92,0.03)")},onMouseLeave:function(H){fe||(H.currentTarget.style.background="transparent")}},i.createElement("div",{style:{position:"relative"}},i.createElement("div",{style:{width:36,height:36,borderRadius:"50%",background:Qe+"15",border:"2px solid "+Qe+"30",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:700,color:Qe}},(xe.title||"?")[0].toUpperCase()),xe.encrypted&&i.createElement("div",{style:{position:"absolute",bottom:-1,right:-1,width:12,height:12,borderRadius:"50%",background:"#06080D",display:"flex",alignItems:"center",justifyContent:"center",fontSize:7}},"🔒")),i.createElement("div",{style:{flex:1,minWidth:0}},i.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},i.createElement("span",{style:{fontSize:12,fontWeight:600,color:"#E6EDF3",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},xe.title),ut&&i.createElement("span",{style:{fontSize:8,color:"#3A4A5E",flexShrink:0}},gS(ut.timestamp))),i.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:2}},i.createElement("span",{style:{fontSize:10,color:"#5A7090",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:180}},ut?ut.text:"No messages yet"),wt>0&&i.createElement("div",{style:{width:18,height:18,borderRadius:"50%",background:Qe,display:"flex",alignItems:"center",justifyContent:"center",fontSize:8,fontWeight:700,color:"#000",flexShrink:0}},wt))),i.createElement("span",{style:{fontSize:9,color:Qe,flexShrink:0}},pS[Ye]||"🛡"))}))),i.createElement("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"}},!p&&i.createElement("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column",gap:16}},i.createElement("div",{style:{fontSize:48,opacity:.15}},"🛡"),i.createElement("div",{style:{fontFamily:bs,fontSize:12,color:"#2A3548",letterSpacing:".1em"}},"XYRON SECURE MESSENGER"),i.createElement("div",{style:{fontSize:11,color:"#3A4A5E",textAlign:"center",maxWidth:300,lineHeight:1.6}},"End-to-end encrypted messaging with AI intelligence. Select a conversation or start a new one."),i.createElement("div",{style:{display:"flex",gap:12,marginTop:8}},[["xyron","🛡 Xyron Secure"],["telegram","✈ Telegram"],["signal","🔒 Signal"],["whatsapp","💬 WhatsApp"]].map(function(xe){return i.createElement("div",{key:xe[0],style:{display:"flex",alignItems:"center",gap:4,padding:"6px 12px",background:(Ss[xe[0]]||"#5A7090")+"08",border:"1px solid "+(Ss[xe[0]]||"#5A7090")+"20",borderRadius:8,fontSize:10,color:Ss[xe[0]]||"#5A7090",fontWeight:500}},xe[1])}))),p&&i.createElement(i.Fragment,null,i.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 20px",borderBottom:"1px solid #111820",background:"rgba(6,8,13,0.9)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",flexShrink:0}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:10}},i.createElement("div",{style:{width:32,height:32,borderRadius:"50%",background:(Ss[p.channel]||"#D4AF5C")+"15",border:"2px solid "+(Ss[p.channel]||"#D4AF5C")+"30",display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,fontWeight:700,color:Ss[p.channel]||"#D4AF5C"}},(p.title||"?")[0].toUpperCase()),i.createElement("div",null,i.createElement("div",{style:{fontSize:13,fontWeight:600,color:"#E6EDF3"}},p.title),i.createElement("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:9,color:"#5A7090"}},p.channel==="xyron"&&p.encrypted&&i.createElement("span",{style:{color:"#3FB950"}},"🔒 E2E Encrypted"),p.channel&&p.channel!=="xyron"&&i.createElement("span",{style:{color:Ss[p.channel]||"#5A7090"}},(pS[p.channel]||"🛡")+" via "+p.channel.toUpperCase()),p.ai_enabled&&i.createElement("span",{style:{color:"#D4AF5C"}},"🤖 AI On"),p.disappearing>0&&i.createElement("span",{style:{color:"#6B9AC4"}},"⏱ "+p.disappearing+"s"),ve&&ve.conversation_id===p.conversation_id&&i.createElement("span",{style:{color:"#D4AF5C",animation:"xpulse 1s infinite"}},"typing…")))),i.createElement("div",{style:{display:"flex",alignItems:"center",gap:4}},i.createElement("button",{onClick:function(){qt(!1)},title:"Voice Call",style:af()},"📞"),i.createElement("button",{onClick:function(){qt(!0)},title:"Video Call",style:af()},"📹"),i.createElement("button",{onClick:tn,title:"Summarize",style:af()},"📝"),i.createElement("button",{onClick:pt,title:p.ai_enabled?"Disable AI":"Enable AI",style:af(p.ai_enabled?"#D4AF5C":null)},"🤖"),i.createElement("button",{onClick:function(){V(N==="security"?null:"security")},title:"Security",style:af(N==="security"?"#3FB950":null)},"🛡"),i.createElement("button",{onClick:function(){var xe=o.find(function(fe){return p.participants.indexOf(fe.contact_id)>=0});xe&&On.contactIntel(xe.contact_id).then(function(fe){w(fe),V("intel")}).catch(function(){})},title:"Contact Intel",style:af(N==="intel"?"#6B9AC4":null)},"📊"))),p.channel&&p.channel!=="xyron"&&i.createElement("div",{style:{padding:"8px 20px",background:"rgba(212,175,92,0.06)",borderBottom:"1px solid rgba(212,175,92,0.2)",flexShrink:0,display:"flex",alignItems:"center",gap:8}},i.createElement("span",{style:{fontSize:11}}
437,"⚠"),i.createElement("span",{style:{fontSize:10,color:"#D4AF5C",fontFamily:bs,letterSpacing:".04em"}},"External channel — messages are handled by "+p.channel.toUpperCase()+" and subject to their privacy policy. Xyron end-to-end encryption does not apply.")),N&&i.createElement("div",{style:{padding:"10px 20px",borderBottom:"1px solid #111820",background:"rgba(212,175,92,0.02)",flexShrink:0,animation:"xfadein 0.2s"}},N==="security"&&i.createElement("div",null,i.createElement("div",{style:{fontFamily:bs,fontSize:8,fontWeight:700,color:"#3FB950",letterSpacing:".1em",marginBottom:8}},"🛡 SECURITY SETTINGS"),i.createElement("div",{style:{display:"flex",gap:8,flexWrap:"wrap"}},i.createElement("div",{style:Hh("#3FB950")},"E2E Encrypted"),i.createElement("div",{style:Hh("#6B9AC4")},"Zero Knowledge"),i.createElement("div",{style:Hh("#D4AF5C")},"Forward Secrecy")),i.createElement("div",{style:{marginTop:8,display:"flex",gap:6}},i.createElement("span",{style:{fontSize:9,color:"#5A7090"}},"Disappearing:"),[0,300,3600,86400].map(function(xe){return i.createElement("button",{key:xe,onClick:function(){gt(xe)},style:{padding:"3px 8px",background:p.disappearing===xe?"rgba(56,189,248,0.1)":"transparent",border:"1px solid "+(p.disappearing===xe?"rgba(56,189,248,0.3)":"#1C2740"),borderRadius:6,cursor:"pointer",fontSize:9,color:p.disappearing===xe?"#6B9AC4":"#5A7090"}},{0:"Off",300:"5m",3600:"1h",86400:"24h"}[xe])}))),N==="intel"&&_&&i.createElement("div",null,i.createElement("div",{style:{fontFamily:bs,fontSize:8,fontWeight:700,color:"#6B9AC4",letterSpacing:".1em",marginBottom:6}},"📊 CONTACT INTELLIGENCE"),_.emails&&_.emails.length>0&&i.createElement("div",{style:{marginBottom:6}},i.createElement("span",{style:{fontSize:9,color:"#5A7090"}},_.emails.length+" recent emails"),_.emails.slice(0,2).map(function(xe,fe){return i.createElement("div",{key:fe,style:{fontSize:10,color:"#8B949E",padding:"2px 0"}},"• ",xe.subject||"(no subject)")})),_.meetings&&_.meetings.length>0&&i.createElement("div",null,i.createElement("span",{style:{fontSize:9,color:"#5A7090"}},_.meetings.length+" meetings"),_.meetings.slice(0,2).map(function(xe,fe){return i.createElement("div",{key:fe,style:{fontSize:10,color:"#8B949E",padding:"2px 0"}},"• ",xe.title||"Meeting")})))),R&&i.createElement("div",{style:{padding:"10px 20px",borderBottom:"1px solid #111820",background:"rgba(212,175,92,0.02)",flexShrink:0}},i.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:4}},i.createElement("span",{style:{fontFamily:bs,fontSize:8,fontWeight:700,color:"#D4AF5C",letterSpacing:".08em"}},"📝 THREAD SUMMARY"),i.createElement("button",{onClick:function(){ae(null)},style:{background:"none",border:"none",cursor:"pointer",color:"#3A4A5E",fontSize:10}},"✕")),i.createElement(ws,{text:R||""})),ge&&i.createElement("div",{style:{padding:"10px 20px",borderBottom:"1px solid #111820",background:"rgba(212,175,92,0.02)",flexShrink:0}},i.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:4}},i.createElement("span",{style:{fontFamily:bs,fontSize:8,fontWeight:700,color:"#D4AF5C"}},"🤖 XYRON — ",ge.question),i.createElement("button",{onClick:function(){X(null)},style:{background:"none",border:"none",cursor:"pointer",color:"#3A4A5E",fontSize:10}},"✕")),i.createElement(ws,{text:ge.answer||""})),i.createElement("div",{style:{flex:1,overflow:"auto",padding:"16px 20px"}},h.map(function(xe,fe){var Ye=xe.sender_id===It,Qe=h[fe-1],ut=!Qe||mS(xe.timestamp)!==mS(Qe.timestamp);return i.createElement(i.Fragment,{key:xe.message_id||fe},ut&&i.createElement("div",{style:{textAlign:"center",padding:"12px 0 8px",fontSize:9,color:"#3A4A5E"}},_3(xe.timestamp)),i.createElement("div",{style:{display:"flex",justifyContent:Ye?"flex-end":"flex-start",marginBottom:6}},i.createElement("div",{style:{maxWidth:"70%",padding:"10px 14px",borderRadius:Ye?"14px 14px 4px 14px":"14px 14px 14px 4px",background:Ye?"rgba(212,175,92,0.1)":"rgba(28,39,64,0.4)",border:"1px solid "+(Ye?"rgba(212,175,92,0.15)":"rgba(28,39,64,0.5)")}
437},!Ye&&i.createElement("div",{style:{fontSize:9,color:"#D4AF5C",fontWeight:600,marginBottom:3}},xe.sender_id),i.createElement("div",{style:{fontSize:12,color:"#E6EDF3",lineHeight:1.5}},xe.text),xe.message_type==="file"&&xe.file_name&&i.createElement("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"6px 8px",background:"rgba(212,175,92,0.06)",borderRadius:6,marginBottom:4}},i.createElement("span",{style:{fontSize:16}},"📎"),i.createElement("div",null,i.createElement("div",{style:{fontSize:11,fontWeight:600,color:"#E6EDF3"}},xe.file_name),i.createElement("div",{style:{fontSize:8,color:"#5A7090"}},xe.file_type||"file"))),xe.edited&&i.createElement("span",{style:{fontSize:8,color:"#5A7090",fontStyle:"italic"}}," (edited)"),xe.reactions&&xe.reactions.length>0&&i.createElement("div",{style:{display:"flex",gap:2,marginTop:4,flexWrap:"wrap"}},xe.reactions.map(function(wt,H){return i.createElement("span",{key:H,style:{fontSize:12,padding:"1px 4px",background:"rgba(212,175,92,0.08)",borderRadius:8,cursor:"pointer"},onClick:function(){On.react(xe.message_id,wt.emoji)}},wt.emoji)})),i.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:6,marginTop:4}},i.createElement("span",{style:{fontSize:8,color:"#3A4A5E"}},gS(xe.timestamp)),xe.encrypted&&i.createElement("span",{style:{fontSize:7,color:"#3FB950"}},"🔒"),Ye&&i.createElement("span",{style:{fontSize:8,color:xe.status==="read"?"#6B9AC4":xe.status==="delivered"?"#7A8A9E":"#3A4A5E"}},xe.status==="read"||xe.status==="delivered"?"✓✓":"✓"),i.createElement("div",{style:{display:"flex",gap:2,marginLeft:4}},["👍","❤️","😂","🙏"].map(function(wt){return i.createElement("span",{key:wt,onClick:function(){On.react(xe.message_id,wt)},style:{fontSize:8,cursor:"pointer",opacity:.4,transition:"opacity .15s"},onMouseEnter:function(H){H.currentTarget.style.opacity="1"},onMouseLeave:function(H){H.currentTarget.style.opacity="0.4"}},wt)}))))))}),i.createElement("div",{ref:Be})),oe&&i.createElement("div",{style:{textAlign:"center",padding:"4px",fontSize:10,color:"#D4AF5C",background:"rgba(212,175,92,0.03)",borderTop:"1px solid rgba(212,175,92,0.08)"}},oe),j.length>0&&p.ai_enabled&&i.createElement("div",{style:{padding:"6px 20px",borderTop:"1px solid #0D1520",display:"flex",gap:6,flexShrink:0}},i.createElement("span",{style:{fontSize:8,color:"#D4AF5C",alignSelf:"center",flexShrink:0}},"🤖"),j.map(function(xe,fe){return i.createElement("button",{key:fe,onClick:function(){Q(xe)},style:{padding:"5px 12px",background:"rgba(212,175,92,0.04)",border:"1px solid rgba(212,175,92,0.15)",borderRadius:20,cursor:"pointer",fontSize:10,color:"#D4AF5C",fontWeight:500,transition:"all .15s",whiteSpace:"nowrap"},onMouseEnter:function(Ye){Ye.currentTarget.style.background="rgba(212,175,92,0.1)"},onMouseLeave:function(Ye){Ye.currentTarget.style.background="rgba(212,175,92,0.04)"}},xe)})),i.createElement("div",{style:{padding:"12px 20px",borderTop:"1px solid #111820",background:"#06080D",flexShrink:0}},Pe&&(!p.channel||p.channel==="xyron")&&i.createElement("div",{style:{display:"flex",alignItems:"center",gap:4,marginBottom:6}},i.createElement("div",{style:{width:5,height:5,borderRadius:"50%",background:"#3FB950"}}),i.createElement("span",{style:{fontFamily:bs,fontSize:7,color:"#3FB950",letterSpacing:".06em"}},"E2E ENCRYPTED • AES-256-GCM")),p.channel&&p.channel!=="xyron"&&i.createElement("div",{style:{display:"flex",alignItems:"center",gap:4,marginBottom:6}},i.createElement("div",{style:{width:5,height:5,borderRadius:"50%",background:Ss[p.channel]||"#5A7090"}}),i.createElement("span",{style:{fontFamily:bs,fontSize:7,color:Ss[p.channel]||"#5A7090",letterSpacing:".06em"}},"SENDING VIA "+p.channel.toUpperCase()+" • TRANSPORT ENCRYPTED")),i.createElement("div",{style:{display:"flex",gap:8,alignItems:"flex-end"}},i.createElement("input",{ref:Xe,type:"file",style:{display:"none"},onChange:function(xe){xe.target.files&&xe.target.files[0]&&(rt(xe.target.files[0]),xe.target.value="")}}),i.createElement("button",{onClick:function(){Xe.current&&Xe.current.click()},title:"Attach file",style:{width:36,height:36,borderRadius:10,background:"transparent",border:"1px solid #1C2740",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,color:"#5A7090",flexShrink:0}},"📎"),i.createElement("textarea",{value:y,onChange:function(xe){k(xe.target.value),Fe.current&&Fe.current.readyState===WebSocket.OPEN&&Fe.current.send(JSON.stringify({type:"typing",conversation_id:p.conversation_id}))}
437,onKeyDown:function(xe){xe.key==="Enter"&&!xe.shiftKey&&(xe.preventDefault(),Q(y))},placeholder:p.encrypted?"Secure message… (@xyron to ask AI)":"Message…",rows:1,style:{flex:1,background:"#0A0E16",border:"1px solid #1C2740",borderRadius:12,padding:"10px 14px",fontSize:12,color:"#E6EDF3",outline:"none",resize:"none",lineHeight:1.5,maxHeight:120,boxSizing:"border-box"}}),i.createElement("button",{onClick:function(){Q(y)},style:{width:40,height:40,borderRadius:"50%",background:y?"#D4AF5C":"#1C2740",border:"none",cursor:y?"pointer":"default",display:"flex",alignItems:"center",justifyContent:"center",fontSize:16,color:y?"#000":"#3A4A5E",transition:"all .2s",flexShrink:0}},"→"))))),we&&i.createElement(w3,{onClose:function(){b(!1)}}))}function gS(t){if(!t)return"";try{return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function mS(t){if(!t)return"";try{return new Date(t).toISOString().slice(0,10)}catch{return""}}function _3(t){if(!t)return"";try{var n=new Date(t),r=new Date;if(n.toDateString()===r.toDateString())return"Today";var o=new Date(r);return o.setDate(o.getDate()-1),n.toDateString()===o.toDateString()?"Yesterday":n.toLocaleDateString([],{weekday:"long",month:"short",day:"numeric"})}catch{return""}}function Wh(t){return{width:28,height:28,borderRadius:8,background:(t||"#5A7090")+"10",border:"1px solid "+(t||"#5A7090")+"30",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,color:t||"#5A7090"}}function af(t){return{width:32,height:32,borderRadius:8,background:t?t+"10":"transparent",border:"1px solid "+(t?t+"30":"#1C2740"),cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,color:t||"#5A7090",transition:"all .15s"}}function Hh(t){return{padding:"4px 10px",background:t+"08",border:"1px solid "+t+"25",borderRadius:8,fontSize:9,color:t,fontWeight:500}}var R3="'JetBrains Mono','SF Mono',monospace";function F3(t){const n=new Set,r=[];for(const o of t||[])o.kind==="videoinput"&&o.deviceId&&(n.has(o.deviceId)||(n.add(o.deviceId),r.push({deviceId:o.deviceId,label:o.label||"",groupId:o.groupId||""})));return r}function I3(t){const{deviceId:n,onDeviceChange:r,mirrored:o,onMirrorToggle:a,disabled:l}=t||{},[s,c]=(0,i.useState)([]),[d,p]=(0,i.useState)(!1),[g,f]=(0,i.useState)(""),[h,x]=(0,i.useState)(!1),v=(0,i.useRef)(!0);(0,i.useEffect)(function(){return v.current=!0,function(){v.current=!1}},[]);const y=(0,i.useCallback)(async function(){if(typeof navigator>"u"||!navigator.mediaDevices)return v.current&&f("camera api unavailable in this browser"),[];try{const E=await navigator.mediaDevices.enumerateDevices();if(!v.current)return[];const C=F3(E);c(C);const _=C.length>0&&C.every(function(w){return!w.label});return p(C.length===0||_),f(""),C}catch(E){return v.current?(f(E&&E.message||"failed to list cameras"),[]):[]}},[]);(0,i.useEffect)(function(){if(y(),typeof navigator>"u"||!navigator.mediaDevices)return;function E(){y()}try{navigator.mediaDevices.addEventListener("devicechange",E)}catch{}return function(){try{navigator.mediaDevices.removeEventListener("devicechange",E)}catch{}}},[y]);const k=(0,i.useCallback)(async function(){if(!(typeof navigator>"u"||!navigator.mediaDevices)){x(!0),f("");try{const E=await navigator.mediaDevices.getUserMedia({video:!0,audio:!1});try{E.getTracks().forEach(function(_){try{_.stop()}catch{}})}catch{}if(!v.current)return;const C=await y();if(!v.current)return;(!n||n==="")&&C.length&&typeof r=="function"&&r(C[0].deviceId)}catch(E){if(!v.current)return;f(E&&E.message||"permission denied")}finally{v.current&&x(!1)}}},[n,r,y]),A=(0,i.useCallback)(function(E){typeof r=="function"&&r(E.target.value||"")},[r]);function j(E,C){const _=(E.label||"").replace(/\s*\([0-9a-f]{4}:[0-9a-f]{4}\)\s*$/i,"").trim()||`Camera ${C+1}`;return _.length>28?_.slice(0,27)+"…":_}return(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,e.jsx)("label",{style:{fontFamily:I.mono,fontSize:9,color:I.ink5,letterSpacing:"0.10em",flexShrink:0},children:"cam"}),(0,e.jsxs)("select",{value:n||"",onChange:A,disabled:l||s.length===0,style:{flex:"1 1 auto",minWidth:0,padding:"3px 6px",background:"rgba(8,11,17,0.55)",border:"1px solid "+I.hairline2,borderRadius:3,fontFamily:I.mono,fontSize:10,
437color:s.length?I.ink2:I.ink5,letterSpacing:"0.04em",cursor:l||s.length===0?"not-allowed":"pointer"},children:[s.length===0&&(0,e.jsx)("option",{value:"",children:"no cameras detected"}),s.length>0&&(!n||!s.some(function(E){return E.deviceId===n}))&&(0,e.jsx)("option",{value:"",children:"— select camera —"}),s.map(function(E,C){return(0,e.jsx)("option",{value:E.deviceId,children:j(E,C)},E.deviceId)})]}),(0,e.jsx)("button",{type:"button",title:o?"mirror on":"mirror off",onClick:a,disabled:l,style:{padding:"3px 6px",background:o?"rgba(212,175,92,0.10)":"transparent",border:"1px solid "+(o?"rgba(212,175,92,0.45)":I.hairline2),borderRadius:3,cursor:l?"not-allowed":"pointer",fontFamily:R3,fontSize:10,color:o?I.gold:I.ink4,letterSpacing:"0.06em",lineHeight:1,flexShrink:0},children:"⇄"})]}),d&&(0,e.jsx)("button",{type:"button",onClick:k,disabled:h,style:{padding:"4px 8px",background:"rgba(212,175,92,0.06)",border:"1px solid rgba(212,175,92,0.30)",borderRadius:3,cursor:h?"wait":"pointer",fontFamily:I.mono,fontSize:9.5,color:I.gold,letterSpacing:"0.10em",fontWeight:600},children:h?"requesting…":"enable camera"}),g&&(0,e.jsx)("span",{style:{fontFamily:I.mono,fontSize:9,color:"#F38B8B",letterSpacing:"0.04em"},children:g})]})}var D3=Object.freeze(["setup_ok","text_delta","turn_complete","error","closed","pong"]);function O3(t){if(typeof t!="string"){let o=0;return t&&typeof t.byteLength=="number"&&(o=t.byteLength),{kind:"binary",byteLength:o}}let n;try{n=JSON.parse(t)}catch{return{kind:"bad_json"}}const r=n&&n.type;return!r||typeof r!="string"?{kind:"bad_json"}:r.toLowerCase().indexOf("audio")>=0?{kind:"forbidden_audio",type:r}:D3.indexOf(r)<0?{kind:"unknown_type",type:r}:{kind:"allowed",type:r,msg:n}}var Gh=15e3,L3=1500,z3=2.5,M3=5,N3=2e3,B3=3e4,P3=400,U3=Object.freeze([4401,4409,4429,4503]);function W3(){try{return typeof localStorage>"u"?"":localStorage.getItem("xyron_jwt_token")||""}catch{return""}}function H3(t){const n=!!(t&&t.enabled),r=t&&t.captureFrameB64,o=t&&Number(t.frameIntervalMs)||L3,a=t&&t.onSetupOk,l=t&&t.onTextDelta,s=t&&t.onTurnComplete,c=t&&t.onError,d=t&&t.onClosed,p=t&&t.onStatusChange,g=(0,i.useRef)(null),f=(0,i.useRef)(null),h=(0,i.useRef)(null),x=(0,i.useRef)(null),v=(0,i.useRef)(null),y=(0,i.useRef)(0),k=(0,i.useRef)(!1),A=(0,i.useRef)(0),j=(0,i.useRef)(!0),E=(0,i.useRef)(0),[C,_]=(0,i.useState)("idle"),w=(0,i.useCallback)(function(V){if(_(V),typeof p=="function")try{p(V)}catch{}},[p]),O=(0,i.useCallback)(function(V){const z=g.current;if(!z||z.readyState!==1)return!1;try{return z.send(JSON.stringify(V)),!0}catch{return!1}},[]),M=(0,i.useCallback)(function(V){if(!V)return!1;const z=String(V).trim();return z?O({type:"text",text:z}):!1},[O]),U=(0,i.useCallback)(function(){k.current=!0;const V=g.current;if(V)try{V.readyState===1&&V.send(JSON.stringify({type:"end"})),V.close()}catch{}},[]),ee=t&&Number.isFinite(Number(t.reconnectMaxAttempts))?Math.max(0,Number(t.reconnectMaxAttempts)):M3,N=(0,i.useCallback)(function(){f.current&&(clearInterval(f.current),f.current=null),h.current&&(clearInterval(h.current),h.current=null),x.current&&(clearInterval(x.current),x.current=null),v.current&&(clearTimeout(v.current),v.current=null)},[]);return(0,i.useEffect)(function(){return j.current=!0,function(){j.current=!1,N();const V=g.current;if(V)try{V.close()}catch{}g.current=null}},[N]),(0,i.useEffect)(function(){if(!n){N();const z=g.current;if(z)try{z.close()}catch{}g.current=null,w("idle");return}k.current=!1,y.current=0;function V(){w("connecting");const z=zS.wsUrl(W3());let oe=null;try{oe=new WebSocket(z)}catch(P){if(w("error"),typeof c=="function")try{c({code:"ws_construct_failed",message:String(P&&P.message||P)})}catch{}return}g.current=oe,oe.onopen=function(){A.current=Date.now()},oe.onmessage=function(P){if(!j.current)return;const W=O3(P.data);if(W.kind==="binary"){if(E.current+=W.byteLength,typeof c=="function")try{c({code:"unexpected_binary",message:"binary frame rejected — wire is text-only"})}catch{}try{oe.close()}catch{}return}if(W.kind==="bad_json")return;if(W.kind==="forbidden_audio"){if(typeof c=="function")try{c({code:"unexpected_frame_type",message:"audio frame type rejected: "+W.type})}catch{}try{oe.close()}catch{}return}if(W.kind==="unknown_type"){if(typeof c=="function")try{c({code:"unexpected_frame_type",message:"unknown frame type: "+W.type})}catch{}try{oe.close()}catch{}return}const R=W.type,ae=W.msg;if(R==="pong"){A.current=Date.now();return}if(R==="setup_ok"){if(y.current=0,w("ready"),typeof a=="function")try{a(ae)}catch{}f.current=setInterval(function(){if(typeof r!="function")return;const q=r();q&&O({type:"frame",image_b64:q,mime_type:"image/jpeg"})},o),h.current=setInterval(function(){O({type:"ping",ts:Date.now()})},Gh),x.current&&clearInterval(x.current),A.current=Date.now(),x.current=setInterval(function(){if(j.current&&g.current===oe){var q=Gh*z3+Gh;if(Date.now()-A.current>q)try{oe.close(4001,"pong_stale")}catch{}}},3e3)}else if(R==="text_delta"){if(typeof l=="function")try{l(String(ae.text||""))}catch{}}else if(R==="turn_complete"){if(typeof s=="function")try{s()}catch{}}else if(R==="error"){if(w("error"),typeof c=="function")try{c({code:String(ae.code||"error"),message:String(ae.message||"")})}catch{}}else if(R==="closed"&&(w("closed"),typeof d=="function"))try{d(String(ae.reason||""))}catch{}},oe.onclose=function(P){if(N(),!!j.current){var W=k.current||P.code===1e3&&String(P.reason||"").toLowerCase().indexOf("client")>=0,R=U3.indexOf(Number(P.code))>=0;if(!W&&!R&&n&&y.current<ee){y.current+=1;var ae=Math.min(N3*Math.pow(2,y.current-1),B3),q=Math.floor(Math.random()*P3);w("connecting"),v.current=window.setTimeout(function(){!j.current||!n||V()},ae+q);return}if(!W&&!R&&y.current>=ee&&typeof c=="function")try{c({code:"reconnect_exhausted",message:"live session reconnect limit reached — refresh to retry"})}catch{}if(y.current=0,w("closed"),typeof d=="function")try{d(String(P&&P.reason||""))}catch{}}},oe.onerror=function(){if(j.current&&(w("error"),typeof c=="function"))try{c({code:"ws_error",message:"websocket error"})}catch{}}}return V(),function(){k.current=!0,N();const z=g.current;if(z)try{z.close()}catch{}g.current=null}},[n,o]),{status:C,sendText:M,end:U,audioReceived:E.current}}var Vh="'JetBrains Mono','SF Mono',monospace";function G3(t){const n=t&&t.turns,r=t&&typeof t.pending=="string"?t.pending:"",o=(0,i.useRef)(null),a=(0,i.useMemo)(function(){return Array.isArray(n)?n:[]},[n]);(0,i.useEffect)(function(){const s=o.current;if(s)try{s.scrollTop=s.scrollHeight}catch{}},[a.length,r]);const l=(0,i.useMemo)(function(){const s=[];for(let c=0;c<a.length;c+=1){const d=a[c];!d||!d.text||s.push({role:d.role,text:d.text,key:"turn-"+c})}return r&&s.push({role:"model",text:r,key:"pending",pending:!0}),s},[a,r]);return l.length===0?(0,e.jsx)("div",{ref:o,style:{flex:"1 1 auto",minHeight:80,maxHeight:220,overflowY:"auto",padding:"6px 8px",background:"rgba(8,11,17,0.55)",border:"1px dashed "+I.hairline2,borderRadius:3,fontFamily:Vh,fontSize:10,
437color:I.ink5,letterSpacing:"0.02em",lineHeight:1.45},children:"live transcript will appear here…"}):(0,e.jsx)("div",{ref:o,"data-testid":"eyes-live-transcript",style:{flex:"1 1 auto",minHeight:80,maxHeight:220,overflowY:"auto",padding:"6px 8px",background:"rgba(8,11,17,0.55)",border:"1px solid "+I.hairline2,borderRadius:3,fontFamily:I.sans,fontSize:11,color:I.ink1,lineHeight:1.55},children:l.map(function(s){const c=s.role==="user"?"You":"Eyes",d=s.role==="user"?I.ink2:I.gold;return(0,e.jsxs)("div",{style:{marginBottom:6},"data-pending":s.pending?"true":void 0,children:[(0,e.jsx)("span",{style:{fontFamily:Vh,fontSize:8.5,color:d,letterSpacing:"0.10em",marginRight:6,fontWeight:700},children:c}),(0,e.jsx)("span",{children:s.text}),s.pending?(0,e.jsx)("span",{style:{fontFamily:Vh,fontSize:9,color:I.ink5,marginLeft:4,opacity:.6},children:"▋"}):null]},s.key)})})}var V3="'JetBrains Mono','SF Mono',monospace",Y3={idle:"ink5",connecting:"warn",ready:"up",error:"down",closed:"ink5"},K3={idle:"idle",connecting:"connecting",ready:"live",error:"error",closed:"ended"};function X3(t){const n=!!(t&&t.liveOn),r=t&&t.onLiveToggle,o=t&&t.onSendText,a=t&&t.onEnd,l=t&&t.status||"idle",s=!!(t&&t.disabled),c=t&&t.errorMessage||"",[d,p]=(0,i.useState)(""),g=I[Y3[l]||"ink5"]||I.ink5,f=K3[l]||l,h=s||l!=="ready",x=function(){if(typeof o=="function"&&!(!d||!d.trim())){try{o(d)}catch{}p("")}};return(0,e.jsxs)("div",{"data-testid":"eyes-live-controls",style:{display:"flex",flexDirection:"column",gap:5,flexShrink:0},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,fontFamily:V3,fontSize:8.5,color:I.ink5,letterSpacing:"0.10em"},children:[(0,e.jsxs)("span",{"data-testid":"eyes-live-status",style:{display:"inline-flex",alignItems:"center",gap:4,color:g,fontWeight:700},children:[(0,e.jsx)("span",{style:{display:"inline-block",width:6,height:6,borderRadius:"50%",background:g,opacity:l==="idle"?.5:1}}),f.toUpperCase()]}),c?(0,e.jsx)("span",{style:{color:I.warn,marginLeft:6},children:c}):null]}),(0,e.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,e.jsx)("button",{type:"button","data-testid":"eyes-live-toggle",onClick:function(){if(typeof r=="function")try{r()}catch{}},disabled:s&&!n,style:{flex:"1 1 auto",padding:"5px 8px",background:n?"rgba(212,175,92,0.10)":"rgba(212,175,92,0.04)",border:"1px solid "+(n?"rgba(212,175,92,0.55)":"rgba(212,175,92,0.25)"),borderRadius:3,cursor:s&&!n?"not-allowed":"pointer",fontFamily:I.mono,fontSize:9.5,color:I.gold,letterSpacing:"0.12em",fontWeight:700},children:n?"live · on":"go live"}),n&&a?(0,e.jsx)("button",{type:"button","data-testid":"eyes-live-end",onClick:function(){try{a()}catch{}},style:{padding:"5px 10px",background:"transparent",border:"1px solid "+I.hairline2,borderRadius:3,cursor:"pointer",fontFamily:I.mono,fontSize:9.5,color:I.ink2,letterSpacing:"0.10em",fontWeight:600,flexShrink:0},children:"end"}):null]}),n?(0,e.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,e.jsx)("input",{type:"text","data-testid":"eyes-live-input",value:d,onChange:function(v){p(v.target.value)},placeholder:"ask the live session…",disabled:h,onKeyDown:function(v){v.key==="Enter"&&!v.shiftKey&&(v.preventDefault(),x())},style:{flex:"1 1 auto",padding:"5px 7px",background:"rgba(8,11,17,0.55)",border:"1px solid "+I.hairline2,borderRadius:3,fontFamily:I.sans,fontSize:11,color:I.ink1,outline:"none",opacity:h?.5:1}}),(0,e.jsx)("button",{type:"button","data-testid":"eyes-live-send",onClick:x,disabled:h||!d.trim(),style:{padding:"5px 10px",background:"rgba(212,175,92,0.06)",border:"1px solid rgba(212,175,92,0.40)",borderRadius:3,cursor:h||!d.trim()?"not-allowed":"pointer",fontFamily:I.mono,fontSize:9.5,color:I.gold,letterSpacing:"0.12em",fontWeight:600,flexShrink:0},children:"send"})]}):null]})}var lf="'JetBrains Mono','SF Mono',monospace",hS="xyron.eyes.deviceId",yS="xyron.eyes.mirror",q3=1200,$3=.7,xS=1280,J3=6;function vS(){try{if(typeof crypto<"u"&&crypto.randomUUID)return crypto.randomUUID()}catch{}return"eyes-"+Math.random().toString(36).slice(2,10)+"-"+Date.now().toString(36)}function bS(t,n){try{if(typeof localStorage>"u")return n;const r=localStorage.getItem(t);return r??n}catch{return n}}function SS(t,n){try{if(typeof localStorage>"u")return;n==null||n===""?localStorage.removeItem(t):localStorage.setItem(t,String(n))}catch{}}function ES(t){if(!t)return null;const n=t.videoWidth||0,r=t.videoHeight||0;if(!n||!r)return null;let o=n,a=r;const l=Math.max(n,r);if(l>xS){const g=xS/l;o=Math.round(n*g),a=Math.round(r*g)}const s=document.createElement("canvas");s.width=o,s.height=a;const c=s.getContext("2d");if(!c)return null;c.drawImage(t,0,0,o,a);const d=s.toDataURL("image/jpeg",$3),p=d.indexOf(",");return p>=0?d.substring(p+1):d}function Q3(t){const n=t&&typeof t.onSendToChat=="function"?t.onSendToChat:null,r=t&&t.variant==="drawer",o=t&&typeof t.onExpand=="function"?t.onExpand:null,a=(0,i.useRef)(null),l=(0,i.useRef)(null),s=(0,i.useRef)(null),c=(0,i.useRef)(0),d=(0,i.useRef)(null),p=(0,i.useRef)(!0),[g,f]=(0,i.useState)(function(){return bS(hS,"")||""}),[h,x]=(0,i.useState)(function(){return bS(yS,"0")==="1"}),[v,y]=(0,i.useState)(!1),[k,A]=(0,i.useState)(!1),[j,E]=(0,i.useState)(!1),[C,_]=(0,i.useState)(""),[w,O]=(0,i.useState)(""),[M,U]=(0,i.useState)(""),[ee,N]=(0,i.useState)([]),[V,z]=(0,i.useState)(null),[oe,P]=(0,i.useState)(null),[W,R]=(0,i.useState)(!1),[ae,q]=(0,i.useState)(null),[ge,X]=(0,i.useState)("poll"),[de,We]=(0,i.useState)(!1),[te,_e]=(0,i.useState)(null),[ve,Ne]=(0,i.useState)([]),[$e,Pe]=(0,i.useState)(""),[ot,re]=(0,i.useState)("");(0,i.useEffect)(function(){let pt=!1;return cv.health().then(function(gt){pt||P(gt||null)}),zS.health().then(function(gt){pt||_e(gt||null)}),function(){pt=!0}},[]);const we=(0,i.useCallback)(function(){const pt=l.current;
437if(pt)try{pt.getTracks().forEach(function(gt){try{gt.stop()}catch{}})}catch{}if(l.current=null,a.current)try{a.current.srcObject=null}catch{}y(!1)},[]);(0,i.useEffect)(function(){return p.current=!0,function(){p.current=!1,we()}},[we]),(0,i.useEffect)(function(){function pt(){typeof document>"u"||(document.hidden?!s.current&&l.current&&(s.current=setTimeout(function(){we(),s.current=null},3e4)):s.current&&(clearTimeout(s.current),s.current=null))}return typeof document<"u"&&document.addEventListener("visibilitychange",pt),function(){typeof document<"u"&&document.removeEventListener("visibilitychange",pt),s.current&&(clearTimeout(s.current),s.current=null)}},[we]);const b=(0,i.useCallback)(function(){return k?null:ES(a.current)},[k]),He=H3({enabled:ge==="live"&&v&&!k&&de,captureFrameB64:b,onSetupOk:function(){re("")},onTextDelta:function(pt){p.current&&Pe(function(gt){return(gt||"")+pt})},onTurnComplete:function(){p.current&&Pe(function(pt){return pt&&pt.trim()&&Ne(function(gt){return gt.concat([{role:"model",text:pt}])}),""})},onError:function(pt){p.current&&re(String(pt&&pt.message||"live error"))},onClosed:function(){p.current&&We(!1)}}),tt=He.status,Ae=(0,i.useCallback)(function(){re(""),We(function(pt){return!pt})},[]),Be=(0,i.useCallback)(function(pt){!He||typeof He.sendText!="function"||!pt||!pt.trim()||(Ne(function(gt){return gt.concat([{role:"user",text:pt}])}),He.sendText(pt))},[He]),Fe=(0,i.useCallback)(function(){if(He&&typeof He.end=="function")try{He.end()}catch{}We(!1)},[He]),ft=!!(te&&te.enabled&&te.sdk_available),St=(0,i.useCallback)(function(pt){f(pt||""),SS(hS,pt||""),l.current&&(we(),O(""))},[we]),Xe=(0,i.useCallback)(function(){x(function(pt){const gt=!pt;return SS(yS,gt?"1":"0"),gt})},[]),It=(0,i.useCallback)(async function(){if(O(""),typeof navigator>"u"||!navigator.mediaDevices){O("camera api unavailable");return}const pt={audio:!1,video:g?{deviceId:{exact:g}}:{facingMode:{ideal:"environment"}}};try{const gt=await navigator.mediaDevices.getUserMedia(pt);if(!p.current){try{gt.getTracks().forEach(function(qt){try{qt.stop()}catch{}})}catch{}return}if(l.current=gt,a.current){a.current.srcObject=gt;try{await a.current.play()}catch{}}if(!p.current){try{gt.getTracks().forEach(function(qt){try{qt.stop()}catch{}})}catch{}l.current=null;return}d.current||(d.current=vS()),y(!0)}catch(gt){if(!p.current)return;O(gt&&gt.message||"camera access denied"),l.current=null,y(!1)}},[g]),Rt=(0,i.useCallback)(function(){we(),d.current=null,A(!1)},[we]),$=(0,i.useCallback)(async function(){if(j)return;if(!l.current||!a.current){_("start the camera first");return}if(k){_("camera is muted — unmute to capture");return}const pt=Date.now();if(pt-c.current<q3)return;c.current=pt;const gt=ES(a.current);if(!gt){_("frame not ready — try again in a second");return}_(""),E(!0);const qt=ee.slice(-J3).filter(function(fe){return fe&&(fe.role==="user"||fe.role==="model")&&fe.text}).map(function(fe){return{role:fe.role,text:String(fe.text).slice(0,4e3)}}),Pt=M&&M.trim()||void 0,Kt=d.current||vS();d.current=Kt;let xe=ee;Pt&&(xe=xe.concat([{role:"user",text:Pt}]),N(xe));try{const fe=await cv.frame(gt,{prompt:Pt,sessionId:Kt,history:qt});if(!p.current)return;fe&&fe.error?_(fe.error):fe&&fe.text?(N(xe.map(function(Ye){return!Ye||!Ye.frameThumb?Ye:{role:Ye.role,text:Ye.text}}).concat([{role:"model",text:fe.text,frameThumb:gt}])),fe.budget&&z(fe.budget),U("")):_("empty response")}catch(fe){if(!p.current)return;_(fe&&fe.message||"frame failed")}finally{p.current&&E(!1)}},[j,k,M,ee]),Ue=(0,i.useCallback)(function(){if(n)for(let pt=ee.length-1;pt>=0;pt-=1){const gt=ee[pt];if(gt&&gt.role==="model"&&gt.text){try{n(gt.text,gt.frameThumb||null)}catch{}return}}},[n,ee]),Ie=(0,i.useCallback)(async function(){if(!(W||!ee.length)){R(!0),_("");try{const pt=ee.map(function(Kt){return(Kt.role==="user"?"You":"Xyron Eyes")+": "+(Kt.text||"")}),gt="Eyes session · "+new Date().toLocaleString(),qt=pt.join(`
438
439`),Pt=await gn.save(gt,"eyes_session",qt,["eyes","vision"]);if(!p.current)return;Pt&&Pt.id?q(Pt.id):_("save failed")}catch(pt){if(!p.current)return;_(pt&&pt.message||"save failed")}finally{p.current&&R(!1)}}},[W,ee]),Q=(0,i.useCallback)(function(){N([]),q(null),z(null),U(""),d.current=null},[]),rt=(function(){for(let pt=ee.length-1;pt>=0;pt-=1)if(ee[pt]&&ee[pt].role==="model")return ee[pt];return null})(),jt=oe?oe.gemini_configured?v?k?"muted":"live":"ready":"offline":"probing",tn=oe?oe.gemini_configured?v?k?I.warn:I.up:I.ink5:I.warn:I.ink5;return(0,e.jsxs)("div",{"data-testid":r?"chat-eyes-panel-drawer":"chat-eyes-panel-wing",style:{flex:"1 1 0",minWidth:0,display:"flex",flexDirection:"column",padding:r?"16px 18px 14px":"13px 14px 11px",gap:r?12:8,boxSizing:"border-box",overflowY:"auto",maxHeight:r?"none":480},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[(0,e.jsxs)("span",{style:{fontFamily:I.mono,fontSize:11,color:I.gold,letterSpacing:"0.20em",fontWeight:700,lineHeight:1.25}
439,children:["◉"," XYRON EYES"]}),(0,e.jsx)("span",{style:{fontFamily:lf,fontSize:8,color:tn,letterSpacing:"0.12em",padding:"1px 6px",border:"1px solid "+I.hairline2,borderRadius:3},children:jt.toUpperCase()}),ft?(0,e.jsx)("button",{type:"button","data-testid":"eyes-mode-toggle",onClick:function(){const pt=ge==="poll"?"live":"poll";if(pt==="poll"&&de)try{Fe()}catch{}X(pt)},title:ge==="poll"?"switch to live transcript mode":"switch back to poll mode",style:{marginLeft:"auto",padding:"1px 6px",background:ge==="live"?"rgba(212,175,92,0.10)":"transparent",border:"1px solid "+(ge==="live"?"rgba(212,175,92,0.45)":I.hairline2),borderRadius:3,cursor:"pointer",fontFamily:lf,fontSize:8,color:ge==="live"?I.gold:I.ink4,letterSpacing:"0.12em",fontWeight:700},children:ge==="live"?"LIVE":"POLL"}):null,o&&!r&&(0,e.jsx)("button",{type:"button","data-testid":"eyes-expand",onClick:o,title:"open Xyron Eyes in an expanded drawer",style:{marginLeft:ft?4:"auto",padding:"1px 6px",background:"transparent",border:"1px solid "+I.hairline2,borderRadius:3,cursor:"pointer",fontFamily:lf,fontSize:11,color:I.ink4,lineHeight:1},"aria-label":"Expand Eyes panel",children:"⛶"})]}),(0,e.jsx)(I3,{deviceId:g,onDeviceChange:St,mirrored:h,onMirrorToggle:Xe,disabled:j}),(0,e.jsxs)("div",{style:{flex:"1 1 auto",minHeight:r?280:150,border:v?`1px solid ${k?"rgba(200,152,80,0.45)":"rgba(212,175,92,0.45)"}`:`1px dashed ${I.hairline2}`,borderRadius:3,background:"rgba(8,11,17,0.75)",position:"relative",overflow:"hidden"},children:[(0,e.jsx)("video",{ref:a,muted:!0,autoPlay:!0,playsInline:!0,style:{width:"100%",height:"100%",objectFit:"cover",display:v?"block":"none",transform:h?"scaleX(-1)":"none",background:"#000"}}),!v&&(0,e.jsxs)("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:4},children:[(0,e.jsx)("span",{style:{fontFamily:lf,fontSize:18,color:I.ink5,lineHeight:1},children:"◉"}),(0,e.jsx)("span",{style:{fontFamily:lf,fontSize:9,color:I.ink5,letterSpacing:"0.10em",textAlign:"center"},children:w||"camera offline"})]}),v&&(0,e.jsxs)("div",{style:{position:"absolute",top:6,left:8,display:"flex",alignItems:"center",gap:5,fontFamily:lf,fontSize:8.5,color:k?I.warn:I.up,letterSpacing:"0.10em"},children:[(0,e.jsx)("span",{style:{display:"inline-block",width:6,height:6,borderRadius:"50%",background:k?I.warn:I.up,opacity:k?.6:1}}),k?"MUTED":"LIVE"]})]}),(0,e.jsx)("div",{style:{display:"flex",gap:6,alignItems:"center",flexShrink:0},children:v?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",onClick:function(){A(function(pt){return!pt})},disabled:j,style:{padding:"5px 8px",background:k?"rgba(200,152,80,0.10)":"transparent",border:"1px solid "+(k?"rgba(200,152,80,0.45)":I.hairline2),borderRadius:3,cursor:j?"not-allowed":"pointer",fontFamily:I.mono,fontSize:9.5,color:k?I.warn:I.ink2,letterSpacing:"0.10em",fontWeight:600,flexShrink:0},children:k?"unmute":"mute"}),(0,e.jsx)("button",{type:"button",onClick:Rt,disabled:j,style:{padding:"5px 8px",background:"transparent",border:"1px solid "+I.hairline2,borderRadius:3,cursor:j?"not-allowed":"pointer",fontFamily:I.mono,fontSize:9.5,color:I.ink2,letterSpacing:"0.10em",fontWeight:600,flexShrink:0},children:"stop"})]}):(0,e.jsx)("button",{type:"button",onClick:It,disabled:j||oe&&!oe.gemini_configured,title:oe&&!oe.gemini_configured?"GOOGLE_API_KEY not configured server-side":void 0,style:{flex:"1 1 auto",padding:"5px 8px",background:"rgba(212,175,92,0.06)",border:"1px solid rgba(212,175,92,0.30)",borderRadius:3,cursor:j||oe&&!oe.gemini_configured?"not-allowed":"pointer",fontFamily:I.mono,fontSize:9.5,color:I.gold,letterSpacing:"0.12em",fontWeight:600},children:"start camera"})}),ge==="live"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(G3,{turns:ve,pending:$e}),(0,e.jsx)(X3,{liveOn:de,onLiveToggle:Ae,onSendText:Be,onEnd:Fe,status:tt,disabled:!v||k,errorMessage:ot})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{style:{display:"flex",gap:6,alignItems:"flex-start",flexShrink:0},children:[(0,e.jsx)("input",{type:"text",value:M,onChange:function(pt){U(pt.target.value)},placeholder:"ask the camera (or leave blank for default)…",disabled:!v||k||j,onKeyDown:function(pt){pt.key==="Enter"&&!pt.shiftKey&&(pt.preventDefault(),$())},style:{flex:"1 1 auto",padding:"5px 7px",background:"rgba(8,11,17,0.55)",border:"1px solid "+I.hairline2,borderRadius:3,fontFamily:I.sans,fontSize:11,color:I.ink1,outline:"none",opacity:!v||k?.6:1}}),(0,e.jsx)("button",{type:"button",onClick:$,disabled:!v||k||j,style:{padding:"5px 10px",background:"rgba(212,175,92,0.06)",border:"1px solid rgba(212,175,92,0.30)",borderRadius:3,cursor:!v||k||j?"not-allowed":"pointer",fontFamily:I.mono,fontSize:9.5,color:I.gold,letterSpacing:"0.10em",fontWeight:600,flexShrink:0},children:j?"…":"ask"})]}),C&&(0,e.jsx)("div",{style:{padding:"4px 6px",background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.25)",borderRadius:3,fontFamily:I.mono,fontSize:9,color:"#F38B8B",letterSpacing:"0.04em"},children:C}),rt&&(0,e.jsx)("div",{style:{maxHeight:140,overflowY:"auto",padding:8,background:"rgba(8,11,17,0.55)",border:"1px solid "+I.hairline2,borderRadius:3,fontFamily:I.sans,fontSize:11,lineHeight:1.5,color:I.ink1,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:rt.text}),ee.length>0&&(0,e.jsxs)("div",{style:{display:"flex",gap:6,alignItems:"center",flexShrink:0,flexWrap:"wrap"},children:[n&&rt&&(0,e.jsx)("button",{type:"button",onClick:Ue,style:{padding:"3px 8px",background:"transparent",border:"1px solid "+I.hairline2,borderRadius:3,cursor:"pointer",fontFamily:I.mono,fontSize:9,color:I.ink2,letterSpacing:"0.10em"},children:"send to chat"}),ae?(0,e.jsxs)("span",{style:{fontFamily:I.mono,fontSize:9,color:I.up,letterSpacing:"0.10em"},children:["✓"," saved · ",String(ae).slice(0,8)]}):(0,e.jsx)("button",{type:"button",onClick:Ie,disabled:W,style:{padding:"3px 8px",background:"transparent",border:"1px solid "+I.hairline2,borderRadius:3,cursor:W?"wait":"pointer",fontFamily:I.mono,fontSize:9,color:I.ink2,letterSpacing:"0.10em"},children:W?"saving…":"save session"}),(0,e.jsx)("button",{type:"button",onClick:Q,disabled:j||W,style:{padding:"3px 8px",background:"transparent",border:"1px solid "+I.hairline2,borderRadius:3,cursor:j||W?"not-allowed":"pointer",fontFamily:I.mono,fontSize:9,color:I.ink4,letterSpacing:"0.10em"},children:"clear"})]})]}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0,marginTop:"auto",fontFamily:I.mono,fontSize:10.5,color:I.ink5,letterSpacing:"0.10em"},children:[(0,e.jsx)("span",{style:{color:I.ink4},children:"vision"}),(0,e.jsx)("span",{style:{color:I.ink6},children:"·"}),(0,e.jsx)("span",{style:{color:I.ink4},children:oe&&oe.model?String(oe.model).replace(/^gemini-/,""):"gemini"}),V&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{style:{color:I.ink6},children:"·"}),(0,e.jsxs)("span",{style:{color:I.ink4},title:"frames this minute / cap",children:[V.used_min,"/",V.limit_min,"m"]})]}),(0,e.jsx)("span",{style:{color:I.ink6,marginLeft:"auto"},children:"·"}),(0,e.jsx)("span",{style:{color:tn},children:jt})]})]})}var kS="'JetBrains Mono','SF Mono',monospace",jy="xyron.eyes.speakBack";function Z3(){try{return typeof localStorage>"u"?!1:localStorage.getItem(jy)==="1"}catch{return!1}}function e6(t){try{if(typeof localStorage>"u")return;t?localStorage.setItem(jy,"1"):localStorage.removeItem(jy)}catch{}}function t6(t){const n=!!(t&&t.open),r=t&&typeof t.onClose=="function"?t.onClose:function(){},o=t&&typeof t.onSendToChat=="function"?t.onSendToChat:null,a=t&&typeof t.onOpenVoice=="function"?t.onOpenVoice:null,l=t&&Object.prototype.hasOwnProperty.call(t,"speakBack"),[s,c]=(0,i.useState)(Z3),d=l?!!t.speakBack:s,p=(0,i.useCallback)(function(){const g=!d;if(l||(c(g),e6(g)),t&&typeof t.onSpeakBackChange=="function")try{t.onSpeakBackChange(g)}catch{}},[d,l,t]);return(0,i.useEffect)(function(){if(!n)return;function g(f){if(f&&f.key==="Escape")try{r()}catch{}}return typeof document<"u"&&document.addEventListener("keydown",g),function(){typeof document<"u"&&document.removeEventListener("keydown",g)}},[n,r]),n?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{"data-testid":"eyes-drawer-backdrop",onClick:r,role:"presentation",style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.50)",backdropFilter:"blur(2px)",zIndex:9998,animation:"eyesDrawerFade 160ms ease"}}),(0,e.jsxs)("aside",{"data-testid":"eyes-drawer",role:"dialog","aria-label":"Xyron Eyes — expanded","aria-modal":"true",style:{position:"fixed",top:0,right:0,bottom:0,width:"min(480px, 100vw)",background:I.bg1,borderLeft:"1px solid "+I.goldDeep,boxShadow:"-12px 0 32px rgba(0,0,0,0.45)",display:"flex",flexDirection:"column",zIndex:9999,animation:"eyesDrawerSlide 200ms "+I.ease},children:[(0,e.jsxs)("header",{style:{display:"flex",alignItems:"center",gap:8,padding:"14px 16px 12px",borderBottom:"1px solid "+I.hairline2,flexShrink:0},children:[(0,e.jsxs)("span",{style:{fontFamily:I.mono,fontSize:12,color:I.gold,letterSpacing:"0.22em",fontWeight:700,lineHeight:1.2}
439,children:["◉"," XYRON EYES"]}),(0,e.jsx)("span",{style:{fontFamily:kS,fontSize:8,color:I.ink4,letterSpacing:"0.14em",padding:"1px 6px",border:"1px solid "+I.hairline2,borderRadius:3},children:"EXPANDED"}),(0,e.jsxs)("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:6},children:[a&&(0,e.jsxs)("button",{type:"button","data-testid":"eyes-drawer-voice",onClick:a,title:"Open voice mode (push to talk, with Xyron audio reply)","aria-label":"Open voice mode",style:{padding:"4px 9px",background:"rgba(212,175,92,0.06)",border:"1px solid rgba(212,175,92,0.30)",borderRadius:3,cursor:"pointer",fontFamily:I.mono,fontSize:10,color:I.gold,letterSpacing:"0.12em",fontWeight:600,lineHeight:1},children:["🎙"," talk"]}),(0,e.jsxs)("button",{type:"button","data-testid":"eyes-drawer-speak-back",onClick:p,"aria-pressed":d,title:d?"Xyron will speak Eyes answers back (click to silence)":"Tap to have Xyron speak Eyes answers back to you",style:{padding:"4px 9px",background:d?"rgba(212,175,92,0.10)":"transparent",border:"1px solid "+(d?"rgba(212,175,92,0.45)":I.hairline2),borderRadius:3,cursor:"pointer",fontFamily:I.mono,fontSize:10,color:d?I.gold:I.ink4,letterSpacing:"0.12em",fontWeight:600,lineHeight:1},children:["🔊"," speak",d?" • on":""]}),(0,e.jsx)("button",{type:"button","data-testid":"eyes-drawer-close",onClick:r,title:"Close (Esc)","aria-label":"Close Eyes drawer",style:{marginLeft:4,padding:"4px 9px",background:"transparent",border:"1px solid "+I.hairline2,borderRadius:3,cursor:"pointer",fontFamily:kS,fontSize:12,color:I.ink2,lineHeight:1},children:"✕"})]})]}),(0,e.jsx)("div",{"data-testid":"eyes-drawer-body",style:{flex:"1 1 auto",minHeight:0,overflowY:"auto",display:"flex",flexDirection:"column"},children:(0,e.jsx)(Q3,{variant:"drawer",onSendToChat:o})})]}),(0,e.jsx)("style",{children:`
440        @keyframes eyesDrawerSlide {
441          from { transform: translateX(100%); opacity: 0.0; }
442          to   { transform: translateX(0);    opacity: 1.0; }
443        }
444        @keyframes eyesDrawerFade {
445          from { opacity: 0; }
446          to   { opacity: 1; }
447        }
448      `})]}):null}var gk="xyron.docscan.files.v1",n6=25e4,r6=48e3,wy="Untitled document";function Ty(t){return!!t&&t.status!=="completed"&&!(t.pages||[]).length}function mk(t){return(t||[]).filter(function(n){return!Ty(n)}).slice(0,20)}function i6(t){var n=t||(typeof localStorage<"u"?localStorage:null);if(!n)return[];try{var r=JSON.parse(n.getItem("xyron.docscan.files.v1")||"[]"),o=Array.isArray(r)?r:[],a=mk(o);if(a.length!==o.length)try{n.setItem(gk,JSON.stringify(a))}catch{}return a}catch{return[]}}function rg(t,n){var r=n||(typeof localStorage<"u"?localStorage:null),o=mk(t);if(r)try{r.setItem(gk,JSON.stringify(o))}catch{}return t||[]}function hk(t){var n=String(t||"").trim();if(!n)return"";var r=n.split(/[/\\]/).pop()||n;return r.replace(/\.[A-Za-z0-9]{1,8}$/,"")||r}function Rp(t){return t?t.originalName?hk(t.originalName)||t.originalName:t.title&&t.title!=="Untitled document"?t.title:wy:wy}function o6(t,n){return t&&t.title&&t.title!=="Untitled document"?t.title:hk(n||t&&t.originalName)||"Untitled document"}function yk(t){for(var n=String(t||"").replace(/\r\n/g,`
449`).replace(/\r/g,`
450`).split(`
451`),r=[],o=0;o<n.length;o++){var a=n[o].replace(/[ \t]+$/g,"");if(!a.trim()){r.length&&r[r.length-1]!==""&&r.push("");continue}var l=a.trim(),s=o+1<n.length?n[o+1].trim():"";if(/[A-Za-z]-$/.test(l)&&s){n[o+1]=l.replace(/-$/,"")+s;continue}var c=/[.!?:;]$/.test(l),d=!s||/^([•\-–]|[0-9]+\.|[A-Z][A-Z0-9 /&]{6,})$/.test(s),p=s&&!d&&(/^[a-z0-9,(]/.test(s)||l.split(/\s+/).length<=3);if(!c&&p){n[o+1]=l+" "+s;continue}r.push(l)}return r.join(`
452`).replace(/\n{3,}/g,`
453
454`).trim()}function sf(t,n){var r=n??n6;return(t&&t.pages||[]).map(function(o,a){var l=o.name||"page";return"--- PAGE "+(a+1)+": "+l+` ---
455`+yk(o.text)}).join(`
456
457`).slice(0,r)}function a6(t,n,r){if(!t)return[];var o=[];Array.isArray(t.page_texts)&&t.page_texts.length?o=t.page_texts:t.text&&(o=String(t.text).split("\f").map(function(s){return s.trim()}).filter(Boolean),o.length||(o=[t.text]));var a=t.extracted_via,l=Date.now();return o.map(function(s,c){var d=yk(s);if(!d)return null;var p=n||r||"page";return o.length>1&&(p=p+" · p"+(c+1)),{id:"pg-"+l+"-"+c,name:p,text:d,via:a,chars:d.length}}
457).filter(Boolean)}function l6(t,n,r){var o={pages:(t.pages||[]).concat(n||[]),updatedAt:new Date().toISOString()},a=r||t.originalName;return!t.originalName&&a&&a!=="camera-photo.jpg"&&(o.originalName=a),o.title=o6(Object.assign({},t,o),o.originalName||a),Object.assign({},t,o)}var co="monospace",s6={contract:"LEGAL",agreement:"LEGAL",legal:"LEGAL",bank_statement:"FINANCE",statement:"FINANCE",invoice:"FINANCE",receipt:"FINANCE",financial_report:"FINANCE",id_document:"COMPLIANCE",passport:"COMPLIANCE",kyc:"COMPLIANCE"};function c6(t){try{var n=(t||"").match(/\{[\s\S]*\}/);if(!n)return null;var r=JSON.parse(n[0]);return r&&typeof r=="object"?r:null}catch{return null}}function d6(t){var n=t.onClose,r=t.onBusyChange,o=t.onDrawerContext,a=(0,i.useMemo)(function(){return o||function(){}},[o]),l=t.projects||[],s=t.onUpdateProject||function(){},c=(0,i.useRef)(null),d=(0,i.useRef)(null),p=(0,i.useRef)(null),g=(0,i.useRef)(null),f=(0,i.useRef)(null),h=(0,i.useState)(i6),x=h[0],v=h[1],y=(0,i.useState)(null),k=y[0],A=y[1],j=(0,i.useState)(!1),E=j[0],C=j[1],_=(0,i.useState)(""),w=_[0],O=_[1],M=(0,i.useState)(!1),U=M[0],ee=M[1],N=(0,i.useState)(!1),V=N[0],z=N[1],oe=(0,i.useState)(!1),P=oe[0],W=oe[1],R=(0,i.useState)(null),ae=R[0],q=R[1],ge=(0,i.useState)(!1),X=ge[0],de=ge[1],We=(0,i.useState)(""),te=We[0],_e=We[1],ve=(0,i.useState)(!1),Ne=ve[0],$e=ve[1],Pe=x.find(function(H){return H.id===k})||null;f.current=k;function ot(H){v(function(Z){return rg(typeof H=="function"?H(Z):H)})}function re(H,Z){ot(function(T){return T.map(function(Y){return Y.id===H?Object.assign({},Y,Z,{updatedAt:new Date().toISOString()}):Y})})}function we(H){C(H),typeof r=="function"&&r(H)}(0,i.useEffect)(function(){if(!Pe||!(Pe.pages||[]).length){a(null);return}a({name:Rp(Pe),content:sf(Pe,r6)})},[Pe,a]);function b(){var H=g.current;H&&H.getTracks&&H.getTracks().forEach(function(Z){try{Z.stop()}catch{}}),g.current=null,$e(!1)}(0,i.useEffect)(function(){return function(){b();try{var H=JSON.parse(localStorage.getItem("xyron.docscan.files.v1")||"[]");rg(Array.isArray(H)?H:[])}catch{}}},[]),(0,i.useEffect)(function(){if(Ne){var H=p.current;if(H&&g.current){H.srcObject=g.current;var Z=H.play&&H.play();Z&&typeof Z.catch=="function"&&Z.catch(function(){})}}},[Ne]);function He(){var H={id:"doc-"+Date.now(),title:wy,originalName:null,docType:null,status:"draft",pages:[],classify:null,vaultId:null,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};return ot(function(Z){var T=(Z||[]).filter(function(Y){return!Ty(Y)});return[H].concat(T)}),f.current=H.id,A(H.id),q(null),O(""),H}function tt(){var H=f.current;H&&(ot(function(Z){return(Z||[]).filter(function(T){return T.id!==H||!Ty(T)})}),f.current=null,A(null),b())}function Ae(H,Z){Z&&(ee(!0),gu({model:bg,max_tokens:800,system:Yy,messages:[{role:"user",content:`Classify this scanned document and extract key facts. Respond with ONLY a JSON object: {"doc_type": one of ["contract","bank_statement","invoice","receipt","financial_report","id_document","letter","other"], "title": short institutional title (e.g. "Bank Statement — UBS — Jun 2026"), "parties": [..], "key_dates": [..], "key_amounts": [..], "summary": one sentence}. Use ONLY what is in the document text. Do not invent parties or figures. Document text:
458
459`+Z.slice(0,24e3)}]}).then(function(T){var Y=c6(T&&T.content&&T.content[0]&&T.content[0].text||"");Y&&ot(function(B){return rg(B.map(function(ie){if(ie.id!==H)return ie;var ue=ie.originalName?ie.title:Y.title||ie.title||"Untitled document";return Object.assign({},ie,{classify:Y,title:ue,docType:Y.doc_type||ie.docType||null,updatedAt:new Date().toISOString()})}))})}).catch(function(){}).finally(function(){ee(!1)}))}async function Be(H,Z){var T=f.current;if(T){var Y=Array.prototype.slice.call(H||[]).filter(Boolean);if(Y.length){we(!0),O("");var B=[],ie=null,ue="";try{for(var ne=0;ne<Y.length;ne++){var Me=Y[ne];ie||(ie=Me.name||Z);var nt=await OS.scan(Me);if(nt&&nt.error){O(nt.error);continue}var ct=a6(nt,Me.name||Z,Z);if(!ct.length){O("No text recognized — try a sharper photo or better lighting.");continue}B=B.concat(ct),ue=nt&&nt.extracted_via||ue}if(!B.length)return;var je="";ot(function(Le){return rg(Le.map(function(be){if(be.id!==T)return be;var Wt=l6(be,B,ie);return je=sf(Wt),Wt}))}
459),oi({action:"doc.scanned",detail:(ie||"document")+" · +"+B.length+" page"+(B.length===1?"":"s")+" · "+(ue||"?")+" · "+B.reduce(function(Le,be){return Le+(be.chars||0)},0)+" chars",model:"system"}),Ae(T,je)}catch(Le){O(Le&&Le.message||"scan failed")}finally{we(!1)}}}}function Fe(H,Z){var T=H.target.files;H.target.value="",!(!T||!T.length)&&(f.current||He(),Be(T,Z))}async function ft(){var H=typeof navigator<"u"?navigator.mediaDevices:null;if(!H||typeof H.getUserMedia!="function"){O("Camera unavailable. Use UPLOAD FILE / PDF, or open this page on a phone.");return}try{g.current=await H.getUserMedia({video:{facingMode:{ideal:"environment"}},audio:!1}),$e(!0)}catch{O("Camera permission denied. Allow the camera, or use UPLOAD FILE / PDF.")}}function St(){return typeof navigator>"u"?!1:/Android|iPhone|iPad|iPod|Mobile/i.test(navigator.userAgent||"")}function Xe(H){f.current||He(),!St()&&(H&&typeof H.preventDefault=="function"&&H.preventDefault(),ft())}async function It(){var H=p.current;if(H){var Z=document.createElement("canvas");Z.width=H.videoWidth||1280,Z.height=H.videoHeight||720;var T=Z.getContext("2d");if(T){T.drawImage(H,0,0,Z.width,Z.height),b();var Y=await new Promise(function(B){Z.toBlob(function(ie){B(ie)},"image/jpeg",.92)});Y&&await Be([new File([Y],"camera-photo.jpg",{type:"image/jpeg"})],"camera photo")}}}function Rt(H){Pe&&re(Pe.id,{pages:(Pe.pages||[]).filter(function(Z){return Z.id!==H})})}function $(H){ot(function(Z){return Z.filter(function(T){return T.id!==H})}),k===H&&A(null)}async function Ue(){if(!(!Pe||!(Pe.pages||[]).length)){var H=sf(Pe);z(!0),O("");try{var Z=Pe.classify&&Pe.classify.doc_type||"scan",T=Rp(Pe);T==="Untitled document"&&(T="Scan — "+new Date().toISOString().slice(0,16).replace("T"," "));var Y=s6[Z]||"GENERAL",B=await gn.save(T,Y,H,["scan",Z]),ie=B&&B.id?B.id:null;re(Pe.id,{status:"completed",vaultId:ie,title:T}),A(null),q(null),oi({action:"doc.saved_to_vault",detail:T+" ["+Y+"] · "+(Pe.pages||[]).length+" pages"+(ie?"":" (vault offline — kept locally as COMPLETED)"),model:"system"})}catch(ue){O(ue&&ue.message||"save failed")}finally{z(!1)}}}function Ie(H){var Z=l.find(function(Y){return Y.id===H});if(!(!Z||!Pe)){var T=sf(Pe);s(H,{knowledgeDocs:(Z.knowledgeDocs||[]).concat([{id:"scan-"+Date.now(),name:Rp(Pe),ext:"",kind:"SCAN",size:0,sizeLabel:"",source:"scan",addedAt:new Date().toISOString(),content:T.slice(0,1e5),contentTruncated:T.length>1e5}])}),oi({action:"doc.attached_to_project",detail:(Pe.title||"document")+" → "+Z.name,model:"system"})}}function Q(){!Pe||X||(de(!0),LS.translate(sf(Pe).slice(0,4e3),"en").then(function(H){q(H&&H.translated_text?H:null)}).catch(function(){q(null)}).finally(function(){de(!1)}))}var rt=te.trim().toLowerCase(),jt=rt?x.filter(function(H){return((H.title||"")+" "+(H.docType||"")+" "+(H.pages||[]).map(function(Z){return Z.text||""}).join(" ")).toLowerCase().indexOf(rt)!==-1}):x,tn=jt.filter(function(H){return H.status!=="completed"&&(H.pages||[]).length>0}),pt=jt.filter(function(H){return H.status==="completed"}),gt={padding:"7px 12px",background:"rgba(212,175,92,0.08)",border:"1px solid rgba(212,175,92,0.3)",borderRadius:5,cursor:"pointer",fontFamily:co,fontSize:11,color:"#D4AF5C",fontWeight:700,letterSpacing:".08em",whiteSpace:"nowrap"},qt=Object.assign({},gt,{color:"#8FA3BF",border:"1px solid #1E2838",background:"transparent"}),Pt={fontFamily:co,fontSize:10,color:I.ink5,letterSpacing:"0.14em",fontWeight:700,marginBottom:5};function Kt(H){var Z=H.status==="completed";return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"9px 12px",border:"1px solid "+(Z?"rgba(63,185,80,0.25)":"rgba(212,175,92,0.2)"),borderRadius:7,background:"#07090E",cursor:"pointer",marginBottom:5},onClick:function(){A(H.id),q(null),O("")},children:[(0,e.jsx)("span",{style:{fontSize:15,flexShrink:0},children:Z?"✓":"▤"}),(0,e.jsxs)("span",{style:{flex:1,minWidth:0},children:[(0,e.jsx)("span",{style:{display:"block",fontSize:13,color:"#C9D1D9",fontWeight:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Rp(H)}),(0,e.jsxs)("span",{style:{display:"block",fontFamily:co,fontSize:9,color:I.ink5,letterSpacing:".08em",marginTop:2},children:[(H.pages||[]).length," PAGE",(H.pages||[]).length===1?"":"S",H.docType?" · "+H.docType.toUpperCase():""," · "+(H.updatedAt||H.createdAt||"").slice(5,16).replace("T"," "),Z&&H.vaultId?" · IN VAULT":""]})]}),Z?(0,e.jsx)("span",{style:{fontFamily:co,fontSize:9,color:"#3FB950",letterSpacing:".1em",fontWeight:700,flexShrink:0},children:"COMPLETED"}):(0,e.jsx)("span",{style:{fontFamily:co,fontSize:9,color:"#D4AF5C",letterSpacing:".1em",fontWeight:700,flexShrink:0},children:"IN PROGRESS"}),(0,e.jsx)("span",{style:{color:"#5A7090",cursor:"pointer",fontSize:15,lineHeight:1,flexShrink:0},title:"Delete file",onClick:function(T){T.stopPropagation(),$(H.id)},children:"×"})]},H.id)}var xe={position:"fixed",left:0,top:0,width:1,height:1,opacity:0,overflow:"hidden"},fe=(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10,marginTop:4},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,e.jsx)("span",{style:{fontFamily:co,fontSize:11,color:I.gold,letterSpacing:".14em",fontWeight:700},children:"▤ DOC SCAN · FILES"}),(0,e.jsx)("span",{style:{flex:1}}),(0,e.jsx)("label",{htmlFor:"docscan-photo-input",style:Object.assign({},gt,{display:"inline-flex",alignItems:"center"}),onClick:Xe,children:"📷 TAKE PHOTO"}),(0,e.jsx)("button",{style:gt,onClick:function(){He(),d.current&&d.current.click()},children:"📄 UPLOAD FILE / PDF"}),(0,e.jsx)("button",{style:gt,onClick:He,children:"+ NEW FILE"}),n&&(0,e.jsx)("button",{onClick:function(){tt(),n()},style:{background:"transparent",border:"1px solid "+I.hairline2,borderRadius:3,padding:"1px 6px",cursor:"pointer",color:I.ink4,fontFamily:co,fontSize:12},children:"✕"})]}),x.length>
4590&&(0,e.jsx)("input",{value:te,placeholder:"⌕ Search files — title, type, contents…",onChange:function(H){_e(H.target.value)},style:{width:"100%",background:"#0D1020",border:"1px solid #1E2838",borderRadius:6,padding:"9px 12px",color:"#C9D1D9",fontSize:15,outline:"none",boxSizing:"border-box"}}),x.length>0&&jt.length===0&&(0,e.jsxs)("div",{style:{textAlign:"center",padding:"18px 0",fontFamily:co,fontSize:14,color:"#5A7090",letterSpacing:".08em"},children:['NO FILES MATCH "',te,'"']}),x.length===0&&(0,e.jsxs)("div",{style:{textAlign:"center",padding:"26px 0"},children:[(0,e.jsx)("div",{style:{fontSize:28,opacity:.3,marginBottom:10},children:"▤"}),(0,e.jsx)("div",{style:{fontFamily:co,fontSize:12,color:"#3A4A5E",letterSpacing:".1em",marginBottom:6},children:"NO SCANNED FILES YET"}),(0,e.jsx)("div",{style:{fontSize:13,color:"#5A7090",marginBottom:14},children:"Start a file, photograph its pages, save it to the Vault when complete."}),(0,e.jsx)("label",{htmlFor:"docscan-photo-input",style:Object.assign({},gt,{display:"inline-flex",alignItems:"center"}),onClick:Xe,children:"📷 TAKE PHOTO"})]}),tn.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{style:Pt,children:["IN PROGRESS (",tn.length,")"]}),tn.map(Kt)]}),pt.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{style:Pt,children:["✓ COMPLETED — SAVED TO VAULT (",pt.length,")"]}),pt.map(Kt)]})]}),Ye=null;if(Pe){var Qe=Pe.status==="completed",ut=Pe.pages||[],wt=Pe.classify;Ye=(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:9,marginTop:4},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,e.jsx)("button",{style:qt,onClick:function(){tt(),q(null)},children:"← FILES"}),(0,e.jsx)("span",{style:{fontSize:14,color:"#E4C27A",fontWeight:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:320},children:Rp(Pe)}),(0,e.jsx)("span",{style:{fontFamily:co,fontSize:9,letterSpacing:".1em",fontWeight:700,padding:"2px 7px",borderRadius:4,color:Qe?"#3FB950":"#D4AF5C",border:"1px solid "+(Qe?"rgba(63,185,80,0.4)":"rgba(212,175,92,0.4)")},children:Qe?"✓ COMPLETED":"DRAFT · "+ut.length+" PAGE"+(ut.length===1?"":"S")}),ut.length>0&&(0,e.jsx)("span",{style:{fontFamily:co,fontSize:10,color:"#3FB950",letterSpacing:".06em",fontWeight:700},children:"✓ GROUNDED FOR CHAT — ask below"}),(0,e.jsx)("span",{style:{flex:1}}),n&&(0,e.jsx)("button",{onClick:function(){tt(),n()},style:{background:"transparent",border:"1px solid "+I.hairline2,borderRadius:3,padding:"1px 6px",cursor:"pointer",color:I.ink4,fontFamily:co,fontSize:12},children:"✕"})]}),!Qe&&(0,e.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[(0,e.jsx)("label",{htmlFor:"docscan-photo-input",style:Object.assign({},gt,{display:"inline-flex",alignItems:"center",opacity:E?.5:1,pointerEvents:E?"none":"auto"}),onClick:Xe,children:E?"SCANNING…":"📷 "+(ut.length?"ADD PAGE "+(ut.length+1)+" (CAMERA)":"TAKE PHOTO")}),(0,e.jsxs)("button",{style:gt,disabled:E,onClick:function(){d.current&&d.current.click()},children:["📄 ",ut.length?"ADD PAGE (FILE/PDF)":"UPLOAD FILE / PDF"]})]}),w&&(0,e.jsx)("div",{style:{padding:"4px 6px",background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.25)",borderRadius:3,fontFamily:co,fontSize:11,color:"#F38B8B"},children:w}),ut.length>0&&(0,e.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",position:"relative"},children:[Qe?(0,e.jsxs)("span",{style:{fontFamily:co,fontSize:10,color:"#3FB950",letterSpacing:".08em",fontWeight:700,padding:"7px 0"},children:["✓ IN VAULT",Pe.vaultId?" · "+String(Pe.vaultId).slice(0,8):""]}):(0,e.jsx)("button",{style:Object.assign({},gt,{background:"rgba(63,185,80,0.1)",border:"1px solid rgba(63,185,80,0.45)",color:"#3FB950"}),disabled:V,onClick:Ue,children:V?"SAVING…":"◆ SAVE & COMPLETE → VAULT"}),(0,e.jsxs)("div",{style:{position:"relative"},children:[(0,e.jsx)("button",{style:Object.assign({},gt,l.length?null:{opacity:.4,cursor:"default"}),onClick:function(){l.length&&W(!P)},children:"◇ ATTACH TO PROJECT ▾"}),P&&(0,e.jsx)("div",{style:{position:"absolute",top:"112%",left:0,zIndex:60,background:"rgba(8,12,20,0.99)",border:"1px solid rgba(212,175,92,0.25)",borderRadius:6,minWidth:170,boxShadow:"0 8px 24px rgba(0,0,0,0.5)",overflow:"hidden"},children:l.slice(0,8).map(function(H){return(0,e.jsxs)("div",{style:{padding:"7px 11px",fontFamily:co,fontSize:11,color:"#C9D1D9",cursor:"pointer",borderBottom:"1px solid rgba(212,175,92,0.06)"},onClick:function(){W(!1),Ie(H.id)},children:["◇ ",H.name]}
459,H.id)})})]}),(0,e.jsx)("button",{style:gt,disabled:X,onClick:Q,children:X?"TRANSLATING…":"文 TRANSLATE → EN"})]}),ut.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:Pt,children:"PAGES — IN THIS FILE"}),ut.map(function(H,Z){return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5px 9px",border:"1px solid rgba(90,112,144,0.25)",borderRadius:5,marginBottom:3},children:[(0,e.jsxs)("span",{style:{fontFamily:co,fontSize:10,color:I.gold,fontWeight:700,flexShrink:0},children:["P",Z+1]}),(0,e.jsx)("span",{style:{flex:1,fontSize:12,color:"#C9D1D9",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:H.name}),(0,e.jsxs)("span",{style:{fontFamily:co,fontSize:9,color:I.ink5,flexShrink:0},children:[H.chars," chars · ",H.via==="document_ai"?"docai":H.via]}),!Qe&&(0,e.jsx)("span",{style:{color:"#5A7090",cursor:"pointer",fontSize:14,lineHeight:1,flexShrink:0},onClick:function(){Rt(H.id)},children:"×"})]},H.id)})]}),(wt||U)&&ut.length>0&&(0,e.jsxs)("div",{style:{border:"1px solid rgba(212,175,92,0.2)",borderRadius:6,padding:"8px 10px"},children:[(0,e.jsx)("div",{style:Pt,children:U?"CLASSIFYING… (AI)":"AI-EXTRACTED — verify before relying on it"}),wt&&(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:3},children:[wt.summary&&(0,e.jsx)("div",{style:{fontSize:12,color:"#8FA3BF",lineHeight:1.5},children:wt.summary}),["parties","key_dates","key_amounts"].map(function(H){var Z=(wt[H]||[]).slice(0,6);return Z.length?(0,e.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"baseline"},children:[(0,e.jsx)("span",{style:{fontFamily:co,fontSize:9,color:I.ink5,letterSpacing:".1em"},children:H.replace("key_","").toUpperCase()}),Z.map(function(T,Y){return(0,e.jsx)("span",{style:{fontFamily:co,fontSize:11,color:"#C9D1D9",background:"rgba(212,175,92,0.05)",border:"1px solid rgba(212,175,92,0.15)",borderRadius:3,padding:"1px 5px"},children:String(T)},Y)})]},H):null})]})]}),ut.length>0&&(0,e.jsx)("div",{style:{maxHeight:320,overflowY:"auto",border:"1px solid "+I.hairline2,borderRadius:4,padding:"8px 10px",fontSize:12,color:"#C9D1D9",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.55},children:sf(Pe)}),ae&&(0,e.jsxs)("div",{style:{maxHeight:180,overflowY:"auto",border:"1px solid rgba(94,234,212,0.25)",borderRadius:4,padding:"6px 8px",fontSize:12,color:"#B9E8DF",whiteSpace:"pre-wrap",lineHeight:1.5},children:[(0,e.jsxs)("div",{style:Pt,children:["TRANSLATED (from ",ae.detected_source_language||"?",")"]}),ae.translated_text]})]})}return(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",minHeight:0},children:[(0,e.jsx)("input",{id:"docscan-photo-input",ref:c,type:"file",accept:"image/*",capture:"environment",onChange:function(H){Fe(H,"camera photo")},style:xe}),(0,e.jsx)("input",{ref:d,type:"file",accept:"image/*,application/pdf",multiple:!0,onChange:function(H){Fe(H,"uploaded file")},style:xe}),Ne&&(0,e.jsxs)("div",{style:{border:"1px solid rgba(212,175,92,0.35)",borderRadius:8,padding:8,background:"#07090E",marginBottom:8},children:[(0,e.jsx)("video",{ref:p,autoPlay:!0,playsInline:!0,muted:!0,style:{width:"100%",maxHeight:280,borderRadius:6,background:"#000",objectFit:"cover"}}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,marginTop:8},children:[(0,e.jsx)("button",{style:gt,disabled:E,onClick:It,children:"📷 CAPTURE"}),(0,e.jsx)("button",{style:qt,onClick:b,children:"CANCEL"})]})]}),Pe?Ye:fe]})}var xk="'JetBrains Mono','SF Mono',monospace",u6=[{code:"en",label:"English"},{code:"fr",label:"French"},{code:"es",label:"Spanish"},{code:"de",label:"German"},{code:"it",label:"Italian"},{code:"pt",label:"Portuguese"},{code:"nl",label:"Dutch"},{code:"ja",label:"Japanese"},{code:"zh",label:"Chinese"},{code:"ko",label:"Korean"},{code:"ar",label:"Arabic"},{code:"ru",label:"Russian"}];function Yh({icon:t,label:n,hint:r,active:o,busy:a,onClick:l}){const s={bg:o?"rgba(212,175,92,0.10)":"rgba(8,11,17,0.55)",border:o?"rgba(212,175,92,0.45)":I.hairline2,iconColor:o?I.gold:I.ink4,label:o?I.gold:I.ink3};return(0,e.jsxs)("button",{type:"button",onClick:l,disabled:a,style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",background:s.bg,border:`1px solid ${s.border}`,borderRadius:3,fontFamily:I.mono,cursor:a?"wait":"pointer",textAlign:"left",transition:"all 140ms "+I.ease},children:[(0,e.jsx)("span",{style:{fontSize:13,color:s.iconColor,lineHeight:1,flexShrink:0,width:14,textAlign:"center"},children:t}),(0,e.jsx)("span",{style:{flex:"1 1 auto",minWidth:0,fontSize:9.5,color:s.label,letterSpacing:"0.10em",fontWeight:600,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n}),(0,e.jsx)("span",{style:{fontSize:8,color:o?I.goldDeep:I.ink5,letterSpacing:"0.10em",flexShrink:0}
459,children:a?"working…":o?"open":r})]})}function vk({title:t,onClose:n}){return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:6,marginBottom:4},children:[(0,e.jsx)("span",{style:{fontFamily:I.mono,fontSize:9,color:I.gold,letterSpacing:"0.18em",fontWeight:700},children:t}),(0,e.jsx)("button",{type:"button",onClick:n,title:"Close panel",style:{background:"transparent",border:"1px solid "+I.hairline2,borderRadius:3,padding:"1px 6px",cursor:"pointer",color:I.ink4,fontFamily:xk,fontSize:10,lineHeight:1},children:"✕"})]})}function bk({children:t}){return t?(0,e.jsx)("div",{style:{padding:"4px 6px",background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.25)",borderRadius:3,fontFamily:I.mono,fontSize:9,color:"#F38B8B",letterSpacing:"0.04em"},children:t}):null}function f6({onClose:t,onBusyChange:n}){const r=(0,i.useRef)(null),[o,a]=(0,i.useState)(!1),[l,s]=(0,i.useState)(""),[c,d]=(0,i.useState)(null),p=(0,i.useCallback)(function(h){a(h),typeof n=="function"&&n(h)},[n]),g=(0,i.useCallback)(function(){r.current&&r.current.click()},[]),f=(0,i.useCallback)(async function(h){const x=h.target.files&&h.target.files[0];if(h.target.value="",!!x){p(!0),s(""),d(null);try{const v=await OS.visionSearch(x);v&&v.error?s(v.error):d(v)}catch(v){s(v&&v.message||"search failed")}finally{p(!1)}}},[p]);return(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6,marginTop:4},children:[(0,e.jsx)(vk,{title:"⊕ VISION SEARCH · reverse image",onClose:t}),(0,e.jsx)("input",{ref:r,type:"file",accept:"image/*",onChange:f,style:{display:"none"}}),(0,e.jsx)("button",{type:"button",onClick:g,disabled:o,style:{padding:"6px 8px",background:"rgba(212,175,92,0.06)",border:"1px solid rgba(212,175,92,0.30)",borderRadius:3,cursor:o?"wait":"pointer",fontFamily:I.mono,fontSize:9.5,color:I.gold,letterSpacing:"0.12em",fontWeight:600},children:o?"searching…":"choose image"}),(0,e.jsx)(bk,{children:l}),c&&(0,e.jsxs)("div",{style:{maxHeight:200,overflowY:"auto",display:"flex",flexDirection:"column",gap:6},children:[c.best_guess_labels&&c.best_guess_labels.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:I.mono,fontSize:8,color:I.ink5,letterSpacing:"0.12em",marginBottom:3},children:"BEST GUESS"}),(0,e.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:c.best_guess_labels.map(function(h){return(0,e.jsx)("span",{style:{padding:"2px 6px",background:"rgba(212,175,92,0.06)",border:"1px solid rgba(212,175,92,0.22)",borderRadius:3,fontFamily:I.mono,fontSize:9,color:I.gold,letterSpacing:"0.05em"},children:h},h)})})]}),c.web_entities&&c.web_entities.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:I.mono,fontSize:8,color:I.ink5,letterSpacing:"0.12em",marginBottom:3},children:"ENTITIES"}),(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:2},children:c.web_entities.slice(0,6).map(function(h,x){return(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,fontFamily:I.mono,fontSize:9,color:I.ink2,letterSpacing:"0.04em"},children:[(0,e.jsx)("span",{style:{flex:"1 1 auto",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h.description}),(0,e.jsx)("span",{style:{flexShrink:0,color:I.ink5,fontSize:8},children:(h.score||0).toFixed(2)})]},(h.entity_id||h.description||"")+"-"+x)})})]}),c.full_matching_images&&c.full_matching_images.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:I.mono,fontSize:8,color:I.ink5,letterSpacing:"0.12em",marginBottom:3},children:"EXACT MATCHES"}),(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:2},children:c.full_matching_images.slice(0,4).map(function(h,x){return(0,e.jsx)("a",{href:h.url,target:"_blank",rel:"noopener noreferrer",title:h.url,style:{fontFamily:I.mono,fontSize:9,color:I.info,letterSpacing:"0.02em",textDecoration:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h.page_title||h.url},(h.url||"")+x)})})]}),c.pages_with_matching_images&&c.pages_with_matching_images.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:I.mono,fontSize:8,color:I.ink5,letterSpacing:"0.12em",marginBottom:3},children:"MATCHING PAGES"}),(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:2},children:c.pages_with_matching_images.slice(0,5).map(function(h,x){return(0,e.jsx)("a",{href:h.url,target:"_blank",rel:"noopener noreferrer",title:h.url,style:{fontFamily:I.mono,fontSize:9,color:I.info,letterSpacing:"0.02em",textDecoration:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h.page_title||h.url},h.url+x)})})]}),(!c.best_guess_labels||c.best_guess_labels.length===0)&&(!c.web_entities||c.web_entities.length===0)&&(!c.full_matching_images||c.full_matching_images.length===0)&&(!c.pages_with_matching_images||c.pages_with_matching_images.length===0)&&(0,e.jsx)("div",{style:{fontFamily:I.mono,fontSize:9,color:I.ink5},children:"no matches"})]})]})}function p6({onClose:t,onBusyChange:n}){const[r,o]=(0,i.useState)(""),[a,l]=(0,i.useState)("en"),[s,c]=(0,i.useState)(!1),[d,p]=(0,i.useState)(""),[g,f]=(0,i.useState)(null),h=(0,i.useCallback)(function(y){c(y),typeof n=="function"&&n(y)},[n]),x=(0,i.useCallback)(async function(){const y=(r||"").trim();if(!y){p("paste text to translate");return}h(!0),p(""),f(null);try{const k=await LS.translate(y,a);k&&k.error?p(k.error):f(k)}catch(k){p(k&&k.message||"translate failed")}finally{h(!1)}},[r,a,h]),v=(0,i.useCallback)(function(){if(!(!g||!g.translated_text))try{const y=navigator.clipboard.writeText(g.translated_text);y&&typeof y.catch=="function"&&y.catch(function(){})}catch{}},[g]);return(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6,marginTop:4},children:[(0,e.jsx)(vk,{title:"⇄ TRANSLATE",onClose:t}),(0,e.jsx)("textarea",{value:r,onChange:function(y){o(y.target.value)},placeholder:"paste text — email body, paragraph, sentence…",rows:4,style:{background:"rgba(8,11,17,0.55)",border:"1px solid "+I.hairline2,borderRadius:3,padding:6,fontFamily:I.sans,fontSize:11,lineHeight:1.4,color:I.ink2,resize:"vertical",minHeight:56,maxHeight:160,outline:"none"}}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,e.jsx)("label",{style:{fontFamily:I.mono,fontSize:9,color:I.ink5,letterSpacing:"0.10em"},children:"to"}),(0,e.jsx)("select",{value:a,onChange:function(y){l(y.target.value)},style:{flex:"1 1 auto",padding:"3px 6px",background:"rgba(8,11,17,0.55)",border:"1px solid "+I.hairline2,borderRadius:3,fontFamily:I.mono,fontSize:10,
459color:I.ink2,letterSpacing:"0.06em"},children:u6.map(function(y){return(0,e.jsxs)("option",{value:y.code,children:[y.label," (",y.code,")"]},y.code)})}),(0,e.jsx)("button",{type:"button",onClick:x,disabled:s||!r.trim(),style:{padding:"4px 10px",background:"rgba(212,175,92,0.06)",border:"1px solid rgba(212,175,92,0.30)",borderRadius:3,cursor:s||!r.trim()?"not-allowed":"pointer",fontFamily:I.mono,fontSize:9.5,color:I.gold,letterSpacing:"0.10em",fontWeight:600},children:s?"…":"go"})]}),(0,e.jsx)(bk,{children:d}),g&&(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,e.jsxs)("div",{style:{fontFamily:I.mono,fontSize:8,color:I.ink5,letterSpacing:"0.12em"},children:[g.detected_source_language?g.detected_source_language+" → "+g.target:g.target," · ",g.chars||0," chars in"]}),(0,e.jsx)("div",{style:{maxHeight:160,overflowY:"auto",padding:8,background:"rgba(8,11,17,0.55)",border:"1px solid "+I.hairline2,borderRadius:3,fontFamily:I.sans,fontSize:11,lineHeight:1.5,color:I.ink1,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:g.translated_text}),(0,e.jsx)("button",{type:"button",onClick:v,style:{alignSelf:"flex-start",padding:"3px 8px",background:"transparent",border:"1px solid "+I.hairline2,borderRadius:3,cursor:"pointer",fontFamily:I.mono,fontSize:9,color:I.ink2,letterSpacing:"0.10em"},children:"copy"})]})]})}function g6(t){const[n,r]=(0,i.useState)(null),[o,a]=(0,i.useState)(null),l=t&&t.variant==="dock";function s(f){o||r(function(h){return h===f?null:f})}function c(){o||r(null)}const d=(0,i.useCallback)(function(f){a(f?"scan":null)},[]),p=(0,i.useCallback)(function(f){a(f?"search":null)},[]),g=(0,i.useCallback)(function(f){a(f?"translate":null)},[]);return(0,e.jsxs)("div",{style:{minWidth:0,display:"flex",flexDirection:"column",padding:"13px 14px 11px",gap:8,boxSizing:"border-box",overflowY:"auto",maxHeight:l?"none":360,flex:l?"1 1 auto":"1 1 0"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[(0,e.jsxs)("span",{style:{fontFamily:I.mono,fontSize:11,color:I.gold,letterSpacing:"0.20em",fontWeight:700,lineHeight:1.25},children:["☰"," DOC INTEL"]}),(0,e.jsx)("span",{style:{fontFamily:xk,fontSize:8,color:I.ink5,letterSpacing:"0.12em",padding:"1px 6px",border:"1px solid "+I.hairline2,borderRadius:3},children:n?n.toUpperCase():"READY"})]}),(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:5,flexShrink:0},children:[(0,e.jsx)(Yh,{icon:"▤",label:"SCAN",hint:"phone \\u2192 vault",active:n==="scan",busy:o==="scan",onClick:function(){s("scan")}}),(0,e.jsx)(Yh,{icon:"⊕",label:"SEARCH",hint:"image grounded",active:n==="search",busy:o==="search",onClick:function(){s("search")}}),(0,e.jsx)(Yh,{icon:"⇄",label:"TRANSLATE",hint:"email \\u00B7 paste",active:n==="translate",busy:o==="translate",onClick:function(){s("translate")}})]}),n==="scan"&&(0,e.jsx)(d6,{onClose:c,onBusyChange:d,onDrawerContext:t&&t.onDrawerContext,projects:t&&t.projects,onUpdateProject:t&&t.onUpdateProject}),n==="search"&&(0,e.jsx)(f6,{onClose:c,onBusyChange:p}),n==="translate"&&(0,e.jsx)(p6,{onClose:c,onBusyChange:g}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0,marginTop:"auto",fontFamily:I.mono,fontSize:10.5,color:I.ink5,letterSpacing:"0.10em"},children:[(0,e.jsx)("span",{style:{color:I.ink4},children:"docs"}),(0,e.jsx)("span",{style:{color:I.ink6},children:"·"}),(0,e.jsx)("span",{style:{color:I.ink4},children:"document AI"}),(0,e.jsx)("span",{style:{color:I.ink6,marginLeft:"auto"},children:"·"}),(0,e.jsx)("span",{style:{color:I.ink5},children:"online"})]})]})}function Kg(t){if(!t)return null;var n=t.roomId!=null?t.roomId:t.room_id;if(n==null)return null;var r=t.contextVersion!=null?t.contextVersion:t.room_context_version;return{roomId:String(n),contextVersion:r!=null?Number(r):null}}function Sk(t,n){var r=Kg(t);if(!r)return!1;var o=Kg(n);return!o||r.roomId!==o.roomId?!0:r.contextVersion==null||o.contextVersion==null?r.roomId!==o.roomId:r.contextVersion!==o.contextVersion}function m6(t,n,r){var o=Kg(t)||Kg(n);if(!o)return{adopt:!0,stale:!1};var a=Sk(o,r);return{adopt:!a,stale:a}}function h6(t){return!!(t&&(t.roomStale||t.roomSuperseded||t.roomPersistenceFailed))}function y6(t,n){return t!=null||n!=null}
459function x6(t,n){return t!==409||!n||!n.room||!["stale_room_context","stale_context_version","room_archived"].includes(n.error)?null:{room:n.room,message:n.error==="room_archived"?"This market room was archived. Authoritative state restored.":"Market room context changed. Authoritative state restored."}}function v6(t){var n=t&&t.getCurrentIdentity||function(){return null},r=t&&t.clearDisplay||function(){},o=t&&t.terminate||function(){},a=null,l=!1;function s(){return a?Sk(a,n()):!1}return{arm:function(c){a=c||null,l=!1},disarm:function(){a=null,l=!1},isSuperseded:s,shouldRejectDelta:function(){return l||s()},checkAndSupersede:function(){if(l||!s())return!1;l=!0,a=null;try{r()}catch{}try{o()}catch{}return!0}}}(0,i.lazy)(()=>xi(()=>import("./ActionInbox-Q0y4THx1.js"),__vite__mapDeps([31,1,0,2,32,5,6,7,33])));(0,i.lazy)(()=>xi(()=>import("./BundleInbox-CumvYmFr.js"),__vite__mapDeps([34,1,0,2,32,5,6,7,33])));(0,i.lazy)(()=>xi(()=>import("./VoiceCaptureButton-CEYodA7P.js"),__vite__mapDeps([35,1,0,2,6,33])));(0,i.lazy)(()=>xi(()=>import("./VoiceAffirmBanner-BJ-tMbgv.js"),__vite__mapDeps([36,1,0,2,33])));var b6=(0,i.lazy)(()=>xi(()=>import("./BriefDrawer-DkJdIimI.js"),__vite__mapDeps([37,1,0,2,18,19,30]))),S6=(0,i.lazy)(()=>xi(()=>import("./AuditDrawer-CWy5-oXf.js"),__vite__mapDeps([38,1,0,2,18,19,6]))),E6=(0,i.lazy)(()=>xi(()=>import("./RiskDrawer-D3-LHqkm.js"),__vite__mapDeps([39,1,0,2,18,19]))),k6=(0,i.lazy)(()=>xi(()=>import("./CortexDrawer-nFTXYhLO.js"),__vite__mapDeps([40,1,0,2,5,6,7,28,41]))),C6=(0,i.lazy)(()=>xi(()=>import("./IntelDrawer-B_bOXWmv.js"),__vite__mapDeps([42,23,1,0,2,5,6,7,24,25,26,20]))),CS=(0,i.lazy)(()=>xi(()=>import("./CouncilPanel-qPcoCtHc.js"),__vite__mapDeps([43,1,0,2,44,45]))),A6=(0,i.lazy)(()=>xi(()=>import("./IntelGraph-q-lvjPHk.js"),__vite__mapDeps([46,1,47,0,2,10,19,13,14,15,5,6,7,16,17,18,20,48,21,22,23,24,25,26,27,28,29,30,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,12,103,104,105,106,107,108,109,110,111,112,113,45,114]))),j6=(0,i.lazy)(()=>xi(()=>import("./RealEstateView-UZ2uCh0S.js"),__vite__mapDeps([115,112,1,0,2,48,5,6,7,29,25,30,19,24,26]))),Kh={search:"Search — web + news drawer with streaming answers + citations",email:"Email — draft, follow-up, inbox preview; never sends without consent",calendar:"Calendar — macro + corporate events; size trades around them",brief:"Brief — compose an Arenberg-grade institutional brief",audit:"Audit — replay ledger and grade past verdicts",risk:"Risk — run shocks, VaR and correlation on the book"};function AS({onClick:t,zIndex:n}){return i.createElement("button",{onClick:t,title:"Close (Esc)","aria-label":"Close",style:{position:"absolute",top:10,right:10,zIndex:n||60,width:24,height:24,display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0,background:"rgba(8,11,17,0.55)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",border:"1px solid rgba(212,175,92,0.18)",borderRadius:3,cursor:"pointer",color:"rgba(201,209,217,0.55)",fontFamily:"monospace",fontSize:14,lineHeight:1,fontWeight:400,transition:"all 140ms ease"},onMouseEnter:function(r){r.currentTarget.style.background="rgba(212,175,92,0.14)",r.currentTarget.style.borderColor="rgba(212,175,92,0.50)",r.currentTarget.style.color="#D4AF5C"},onMouseLeave:function(r){r.currentTarget.style.background="rgba(8,11,17,0.55)",r.currentTarget.style.borderColor="rgba(212,175,92,0.18)",r.currentTarget.style.color="rgba(201,209,217,0.55)"}},"×")}function w6(t){var n="monospace",r=[{id:"reply",label:"Reply"},{id:"followup",label:"Follow-up"},{id:"intro",label:"Intro"},{id:"decline",label:"Decline"},{id:"schedule",label:"Schedule"},{id:"negotiate",label:"Negotiate"},{id:"internal",label:"Internal"},{id:"outreach",label:"Outreach"}],o=[{id:"formal",label:"Formal"},{id:"warm",label:"Warm"},{id:"direct",label:"Direct"},{id:"diplomatic",label:"Diplomatic"},{id:"assertive",label:"Assertive"},{id:"high-stakes",label:"High-Stakes"},{id:"exec",label:"Exec Brief"}],a=(0,i.useState)([]),l=a[0],s=a[1],c=(0,i.useState)(""),d=c[0],p=c[1],g=(0,i.useState)(!1),f=g[0],h=g[1],x=(0,i.useState)(""),v=x[0],y=x[1],k=(0,i.useState)([]),A=k[0],j=k[1],E=(0,i.useState)(!1),C=E[0],_=E[1],w=(0,i.useState)(!1),O
459=w[0],M=w[1],U=(0,i.useState)(0),ee=U[0],N=U[1],V=(0,i.useState)(""),z=V[0],oe=V[1],P=(0,i.useState)(Ln.IDLE),W=P[0],R=P[1];function ae(u,S){var F=dm.current,G=Qb(F,u);dm.current=G,R(function(ze){return Qb(ze,u)});var ce=Ta.current;G===F&&G!==u?cF(ce,F,u,S):G!==F&&sF(ce,F,G,S)}var q=(0,i.useState)(function(){try{return localStorage.getItem("xyron_model")||"xyron-auto"}catch{return"xyron-auto"}}),ge=q[0];q[1];var X=(0,i.useState)(function(){return"auto"}),de=X[0],We=X[1],te=(0,i.useState)(null),_e=te[0],ve=te[1],Ne=de==="auto"||de==="xyron_gpt"||de==="xyron_legal",$e=(0,i.useState)(function(){if(!(Gn&&(Gn.short||"").toUpperCase().indexOf("ARENBERG")!==-1))return"auto";try{return localStorage.getItem("xyron_general_provider")||"auto"}catch{return"auto"}}),Pe=$e[0],ot=$e[1];(0,i.useEffect)(function(){try{localStorage.setItem("xyron_chat_mode",de),localStorage.setItem("xyron_general",Ne?"1":"0"),localStorage.setItem("xyron_general_provider",Pe)}catch{}},[de,Ne,Pe]);var re=(0,i.useState)(`You are Xyron, a sovereign intelligence terminal. You are NOT a generic chatbot. You are NOT a text-only AI. You do NOT have limited capabilities. You are a full-spectrum intelligence system with integrated tools.
460
461IDENTITY RULES (ALWAYS FOLLOW):
462- NEVER say "I'm a text-based AI" or "I cannot generate/display images" or "I don't have access to" or "I'm limited to" or "as an AI" or "I cannot browse the web."
463- NEVER describe yourself as limited, restricted, text-only, or finance-only.
464- You are Xyron. You have tools. If a tool is not available for a specific request, say: "This capability is not yet enabled in this environment" — then provide the best alternative answer.
465- Always answer the question. Always be helpful. Never refuse with generic AI disclaimers.
466
467RESPONSE STYLE: Lead with the answer, then the reasoning. Be direct, specific, and decisive. Use exact figures where available. State your view without excessive caveats. Use ## headers for complex answers. Bold **key data**. Bullet points for structured data. Match depth to the question.
468
469TOOLS AND CAPABILITIES:
470- FINANCE: Portfolio analysis, risk, macro, allocation, stress testing, compliance. You have portfolio memory, vault documents, and activity context when provided in [MEMORY], [VAULT], [ACTIVITY] blocks.
471- CHARTS: You can generate interactive charts. Use the <<<CHART>>> protocol with TYPE/TITLE/X_LABEL/Y_LABEL/DATA fields.
472- DOCUMENTS: You generate full reports, memos, briefs in markdown. No top-level # Title — the export system adds branding.
473- RESEARCH: Synthesise across any domain — business, law, science, technology, strategy.
474- WRITING: Any style — formal, technical, creative, concise.
475- LIVE DATA: When [LIVE MARKET DATA] or [BLOOMBERG MARKET NEWS] or [WEB SEARCH RESULTS] blocks are present in your context, USE them. These 
475contain real-time data. Do not say you lack live access when these blocks are present.
476- MULTIMEDIA: The terminal has full image and video capabilities. When the user mentions images or videos, NEVER say you cannot display, play, or show them. NEVER say you are text-only. Instead, describe relevant content, suggest search terms, and recommend specific resources. The terminal renders images and plays videos natively.
477
478CHART PROTOCOL:
479<<<CHART>>>
480TYPE: bar|line|area|pie|scatter
481TITLE: [title]
482X_LABEL: [label]
483Y_LABEL: [label]
484DATA: [JSON array of {"label":"...","value":...}]
485Then analysis below.
486
487WEB/SEARCH: Use search context when provided. If none, answer from knowledge and note cutoff. Never fabricate URLs.
488
489You are Xyron. You are capable. Answer everything.`),we=re[0],b=re[1],He=(0,i.useState)(!1),tt=He[0],Ae=He[1],Be=(0,i.useState)(!1);Be[0],Be[1];var Fe=(0,i.useState)(function(){try{return localStorage.getItem("xyron_theme")||"dark"}catch{return"dark"}}),ft=Fe[0],St=Fe[1];(0,i.useEffect)(function(){function u(){try{var S=localStorage.getItem("xyron_theme")||"dark";(S==="light"||S==="dark")&&St(S)}catch{}}return window.addEventListener($h,u),function(){window.removeEventListener($h,u)}},[]);var Xe=(0,i.useState)(""),It=Xe[0],Rt=Xe[1],$=(0,i.useState)(!1),Ue=$[0],Ie=$[1],Q=(0,i.useState)([]),rt=Q[0],jt=Q[1],tn=(0,i.useState)(""),pt=tn[0],gt
489=tn[1],qt=(0,i.useRef)(null),Pt=(0,i.useRef)(null),Kt=y6(t.roomId,t.roomContextVersion);(0,i.useEffect)(function(){Pt.current=t.roomSymbol&&t.roomId?{roomId:t.roomId,contextVersion:t.roomContextVersion}:null},[t.roomSymbol,t.roomId,t.roomContextVersion]);var xe=(0,i.useRef)(null);(0,i.useEffect)(function(){xe.current&&xe.current.checkAndSupersede()},[t.roomId,t.roomContextVersion]);var fe=(0,i.useState)(null),Ye=fe[0],Qe=fe[1],ut=(0,i.useRef)(null);function wt(u){ut.current=u,Qe(u)}var H=(0,i.useState)(null),Z=H[0],T=H[1],Y=(0,i.useState)(""),B=Y[0],ie=Y[1],ue=(0,i.useState)({}),ne=ue[0],Me=ue[1],nt=(0,i.useState)(null),ct=nt[0],je=nt[1],Le=(0,i.useState)(!1),be=Le[0],Wt=Le[1],Te=(0,i.useState)(!1),it=Te[0],Tt=Te[1],bn=(0,i.useState)(!1),$r=bn[0],ai=bn[1],Nn=(0,i.useState)(!1),er=Nn[0],Tn=Nn[1],ra=(0,i.useState)(null),ba=ra[0],Ro=ra[1];(0,i.useEffect)(function(){function u(){ai(!1),Tt(!0)}function S(){Tt(!1),ai(!0)}return window.addEventListener("xyron:openVoiceMode",u),window.addEventListener("xyron:openSonicMode",S),function(){window.removeEventListener("xyron:openVoiceMode",u),window.removeEventListener("xyron:openSonicMode",S)}},[]);var Ba=(0,i.useState)(null),Ii=Ba[0],he=Ba[1],st=(0,i.useState)(!1),Et=st[0],Mt=st[1],mn=(0,i.useState)(!1),Kn=mn[0],br=mn[1],qn=(0,i.useState)(0),nl=qn[0],$n=qn[1],ia=(0,i.useState)([]),dc=ia[0],Sa=ia[1],kl=(0,i.useState)(""),Cl=kl[0],to=kl[1],oa=(0,i.useRef)(""),rl=(0,i.useRef)(null),il=(0,i.useRef)([]),Pa=(0,i.useRef)(null),Zl=(0,i.useRef)(null),Al=(0,i.useRef)(null),es=(0,i.useRef)(null),Ea=(0,i.useRef)(null),uc=(0,i.useState)([]),fi=uc[0],no=uc[1],Fs=(0,i.useState)(null),Xi=Fs[0],Uo=Fs[1],dd=(0,i.useState)(null),fc=dd[0],pc=dd[1],Ua=(0,i.useState)(""),Is=Ua[0],ud=Ua[1];function aa(u,S){u&&pc({url:u,title:S||""})}var gc=(0,i.useState)("50%"),mc=gc[0],ts=gc[1],Ds=(0,i.useState)({}),ns=Ds[0],la=Ds[1],hc=(0,i.useState)(!1),fd=hc[0],yc=hc[1],rs=(0,i.useState)(!1);rs[0],rs[1];var xc=(0,i.useState)(!1),dr=xc[0],Jr=xc[1],vc=(0,i.useState)(!1),or=vc[0],po=vc[1],bc=(0,i.useState)(!1),qi=bc[0],go=bc[1],Sc=(0,i.useState)(!1),tr=Sc[0],Fo=Sc[1],Ec=(0,i.useState)(null),mu=Ec[0],jl=Ec[1];(0,i.useEffect)(function(){function u(S){jl(S&&S.detail&&S.detail.item||{headline:"Portfolio predictive intelligence",category:"Macro",impact:"High",source:"portfolio"})}return window.addEventListener("xyron:open-predictive-intel",u),function(){window.removeEventListener("xyron:open-predictive-intel",u)}},[]);var Wo=(0,i.useRef)(null);(0,i.useEffect)(function(){function u(S){var F=S&&S.detail&&typeof S.detail.command=="string"&&S.detail.command.trim()?S.detail.command.trim():null;Di(!1),Jr(!1),po(!1),Fo(!1),go(!1),Tn(!1),jl(null),vi(!1),Oi(!1),pi(!1),zi(!1),si(!1),Ji(!1),Go(!1),ca(!1),ho(!1),io(!1),oo(!1),gi(!1),Lo(!1),dl(!1),Fl(!1),Li(!1),Dd([]),Od([]),Ro(null),Md(),ji(!0),F&&setTimeout(function(){Wo.current&&Wo.current(F,"ledger")},300)}return window.addEventListener("xyron:open-ledger",u),function(){window.removeEventListener("xyron:open-ledger",u)}},[]),(0,i.useEffect)(function(){if(or){try{Om.connectMarketFeed(function(){}),Om.connectIntelFeed(function(){})}catch{}return function(){try{Om.disconnectAll()}catch{}}}},[or]);var Ho=(0,i.useState)(!1),Qn=Ho[0],vi=Ho[1],is=(0,i.useState)(!1),Gr=is[0],Di=is[1],Os=(0,i.useState)(function(){try{var u=localStorage.getItem("xyron_web_search_mode");return u==="off"||u==="research"||u==="auto"?u:"auto"}catch{return"auto"}}),Ai=Os[0],Wa=Os[1];(0,i.useEffect)(function(){try{localStorage.setItem("xyron_web_search_mode",Ai)}catch{}},[Ai]);function kc(){Wa(function(u){return u==="auto"?"research":u==="research"?"off":"auto"})}function wl(){return Ai==="research"?"research":Ai==="off"?"off":"auto"}var Ha=Ai==="research"?"ON":Ai==="off"?"OFF":"AUTO",hu=(0,i.useState)(function(){return Array.isArray(t.parkedDockModules)?t.parkedDockModules.slice():[]}),pd=hu[0],Ls=hu[1],ol=(0,i.useState)(function(){return Array.isArray(t.parkedDockModules)?t.parkedDockModules.slice():[]}),al=ol[0],ll=ol[1],sa=(0,i.useState)(!1),nr=sa[0],Oi=sa[1],Qr=(0,i.useState)(!1),Sr=Qr[0],ji=Qr[1],Io=(0,i.useRef)(!1);(0,i.useEffect)(function(){Sr&&(Io.current=!1)},[Sr]);var sl=(0,i.useState)(!1),li=sl[0],Li=sl[1],ka=(0,i.useState)(!1),Er=ka[0],pi=ka[1],gd=(0,i.useState)(!1),Tr=gd[0],zi=gd[1],Tl=(0,i.useState)(null),zs=Tl[0],Fn=Tl[1],Ee=(0,i.useState)(!1),_r=Ee[0],Vr=Ee[1],os=(0,i.useState)("reply"),Ga=os[0],Cc=os[1],Ac=(0,i.useState)("formal"),Ms=Ac[0],cl=Ac[1],_l=(0,i.useState)(!1),md=_l[0],Go=_l[1],jc=(0,i.useState)(!1),hd=jc[0],ca=jc[1],wc=(0,i.useState)(!1),Rl=wc[0],Vo=wc[1],$i=(0,i.useState)(!1),Yr=$i[0],si=$i[1],[yd,Tc]=(0,i.useState)(null),[as,da]=(0,i.useState)(null),ro=h3({enabled:Yr,accountEmail:as&&as.owner===El()?as.email:null}),_c=(0,i.useState)(!1),Do=_c[0],Ji=_c[1],xd=(0,i.useState)(!1),wi=xd[0],dl=xd[1],Ns=(0,i.useState)(!1),yu=Ns[0],Fl=Ns[1],vd=(0,i.useState)(!1),mo=vd[0],ho=vd[1],bd=(0,i.useState)(!1),yo=bd[0],io=bd[1],Rc=(0,i.useState)(!1),Oo=Rc[0],oo=Rc[1],xu=(0,i.useState)(function(){try{return localStorage.getItem("xyron_cortex_enabled")==="1"}catch{return!1}}),kr=xu[0],gi=xu[1];(0,i.useEffect)(function(){try{localStorage.setItem("xyron_cortex_enabled",kr?"1":"0")}catch{}},[kr]);var Sd=(0,i.useState)(!1),Qi=Sd[0],Lo=Sd[1],Zi=(0,i.useState)("off"),Ca=Zi[0],Fc=Zi[1],zo=Ca!=="off",ci={portfolio:{label:"PORTFOLIO",on:or,set:po}
489,scanner:{label:"DOC SCAN",on:qi,set:go},intelgraph:{label:"INTEL GRAPH",on:tr,set:Fo},eyes:{label:"VISION",on:er,set:Tn},search:{label:"SEARCH",on:Gr,set:Di},intel:{label:"INTEL",on:Qi,set:Lo},video:{label:"VIDEO",on:dr,set:Jr},map:{label:"MAP",on:Qn,set:vi},vault:{label:"VAULT",on:nr,set:Oi},ledger:{label:"LEDGER",on:Sr,set:ji},realestate:{label:"REAL ESTATE",on:li,set:Li},email:{label:"EMAIL",on:Tr,set:zi},calendar:{label:"CALENDAR",on:Yr,set:si},messenger:{label:"MESSENGER",on:Do,set:Ji},command:{label:"COMMAND",on:Er,set:pi},brief:{label:"BRIEF",on:mo,set:ho},audit:{label:"AUDIT",on:yo,set:io},risk:{label:"RISK",on:Oo,set:oo},cortex:{label:"CORTEX",on:kr,set:gi}},ao=["portfolio","scanner","intelgraph","eyes","search","intel","video","map","vault","ledger","realestate","email","calendar","messenger","command","brief","audit","risk","cortex"];function Aa(u,S){return u.indexOf(S)===-1?u.concat([S]):u}function bi(u,S){return u.filter(function(F){return F!==S})}function Yn(){for(var u=0;u<ao.length;u++){var S=ao[u];if(ci[S]&&ci[S].on===!0)return S}return null}function Ic(u){var S=Yn();Ls(function(F){var G=F;return S&&S!==u&&(G=Aa(G,S)),G=Aa(G,u),G}),ll(function(F){var G=F;return S&&S!==u&&(G=Aa(G,S)),bi(G,u)}),S&&S!==u&&typeof t.onDockModuleParked=="function"&&t.onDockModuleParked(S),typeof t.onDockModuleUnparked=="function"&&t.onDockModuleUnparked(u)}function Ed(u){ll(function(S){return Aa(S,u)}),ci[u]&&ci[u].set(!1),typeof t.onDockModuleParked=="function"&&t.onDockModuleParked(u),typeof t.onDockActiveChange=="function"&&t.onDockActiveChange(null)}function vu(u){if(t.embedded&&typeof t.onParkHostView=="function"){t.onParkHostView(u);return}var S=Yn();S&&S!==u&&ci[S]&&(ll(function(F){return Aa(F,S)}),ci[S].set(!1),typeof t.onDockModuleParked=="function"&&t.onDockModuleParked(S)),ll(function(F){return bi(F,u)}),ci[u]&&ci[u].set(!0),typeof t.onDockModuleUnparked=="function"&&t.onDockModuleUnparked(u),typeof t.onDockActiveChange=="function"&&t.onDockActiveChange(u)}function bu(u){Ls(function(S){return bi(S,u)}),ll(function(S){return bi(S,u)}),ci[u]&&ci[u].set(!1),typeof t.onDockModuleUnparked=="function"&&t.onDockModuleUnparked(u),typeof t.onDockActiveChange=="function"&&Yn()===u&&t.onDockActiveChange(null)}var Su=(0,i.useRef)(null);(0,i.useEffect)(function(){var u={portfolio:!!or,scanner:!!qi,intelgraph:!!tr,eyes:!!er,search:!!Gr,intel:!!Qi,video:!!dr,map:!!Qn,vault:!!nr,ledger:!!Sr,realestate:!!li,email:!!Tr,calendar:!!Yr,messenger:!!Do,command:!!Er,brief:!!mo,audit:!!yo,risk:!!Oo,cortex:!!kr},S=Su.current;if(Su.current=u,!(!t.project||S==null)){var F={portfolio:"PORTFOLIO",scanner:"DOC SCAN",intelgraph:"INTEL GRAPH",eyes:"VISION",search:"SEARCH",intel:"INTEL",video:"VIDEO",map:"MAP",vault:"VAULT",ledger:"LEDGER",realestate:"REAL ESTATE",email:"EMAIL",calendar:"CALENDAR",messenger:"MESSENGER",command:"COMMAND",brief:"BRIEF",audit:"AUDIT",risk:"RISK",cortex:"CORTEX"},G=t.project.name||t.project.id||"project";Object.keys(u).forEach(function(ce){if(u[ce]&&!S[ce])try{oi({action:"project.drawer.opened",resource:"project:"+G,detail:G+" → "+(F[ce]||ce),model:"system"})}catch{}})}},[t.project,or,qi,tr,er,Gr,Qi,dr,Qn,nr,Sr,li,Tr,Yr,Do,Er,mo,yo,Oo,kr]);function Eu(u){var S=!u.on;if(ST({embedded:t.embedded,turningOn:S,onParkHostView:t.onParkHostView,inRegistry:!!ci[u.key]})){t.onParkHostView(u.key);return}Ic(u.key),u.set(),typeof t.onDockActiveChange=="function"&&t.onDockActiveChange(S?u.key:null)}(0,i.useEffect)(function(){var u=t.pendingDockKey;if(u){var S=ci[u];if(S){Ic(u);for(var F=0;F<ao.length;F++){var G=ao[F];G!==u&&ci[G]&&ci[G].set(!1)}S.set(!0)}var ce=t.onPendingDockConsumed;if(typeof ce=="function"){var ze=setTimeout(function(){ce()},0);return function(){clearTimeout(ze)}}}},[t.pendingDockKey]);var Il=Yn();(0,i.useEffect)(function(){typeof t.onDockActiveChange=="function"&&ET(Il,t.pendingDockKey,t.embedded)&&t.onDockActiveChange(Il)},[Il,t.pendingDockKey,t.embedded]),(0,i.useEffect)(function(){var u=Array.isArray(t.parkedDockModules)?t.parkedDockModules:[],S=t.pendingDockKey||null;Ls(function(ce){return CT(ce,u)}),ll(function(ce){var ze=AT(u,S);return kT(ce,ze)?ce:ze});for(var F=0;F<u.length;F++){var G=u[F];G!==S&&ci[G]&&ci[G].on===!0&&ci[G].set(!1)}},[t.parkedDockModules,t.pendingDockKey]);function mi(u){return al.indexOf(u)!==-1}var kd=(0,i.useState)(function(){return $f()}),ku=kd[0],Cd=kd[1],ls=(0,i.useState)(!1);ls[0],ls[1];var K=(0,i.useState)(!1),Ce=K[0],Re=K[1],at=(0,i.useState)(null),lt=at[0],Jt=at[1],nn=(0,i.useState)(GT)[0],Nr=(0,i.useState)(function(){try{var u=localStorage.getItem("xyron.today.muted");return u?JSON.parse(u):{}}catch{return{}}}),Zr=Nr[0],Mi=Nr[1],Ti=(0,i.useState)(function(){try{var u=localStorage.getItem("xyron.decisionBlock.collapsed");return u==null?!0:u==="1"}catch{return!0}}),Bn=Ti[0],ua=Ti[1];(0,i.useEffect)(function(){try{localStorage.setItem("xyron.decisionBlock.collapsed",Bn?"1":"0")}catch{}},[Bn]),(0,i.useEffect)(function(){tr&&ua(!0)},[tr]);var fa=769,ja=14,ul=56;function Ni(){if(typeof window>"u")return{left:24,bottom:ja,width:fa,height:null};var u=window.innerWidth,S=u<768,F=S?u:Math.min(fa,Math.max(360,u-32));return{left:S?0:Math.max(16,(u-F)/2),bottom:S?ul:ja,width:F,height:null}}var Yo=(0,i.useState)(Ni),ss=Yo[0],ei=Yo[1],Bs=(0,i.useState)(148),Dl=Bs[0],Cu=Bs[1],Ad=(0,i.useRef)(null);(0,i.useEffect)(function(){var u=Ad.current;if(u){var S=new ResizeObserver(function(F){for(var G=0;G<F.length;G++){Cu(Math.ceil(F[G].contentRect.height));break}});return S.observe(u),function(){try{S.disconnect()}catch{}}}},[]),(0,i.useEffect)(function(){function u(){ei(Ni())}return window.addEventListener("resize",u),function(){window.removeEventListener("resize",u)}},[]),(0,i.useEffect)(function(){function u(S){var F=S&&S.detail&&S.detail.id;F&&Mi(function(G){var ce=Object.assign({},G);return ce[F]=!0,ce})}return window.addEventListener("xyron:today-mute",u),function(){window.removeEventListener("xyron:today-mute",u)}},[]);var En=["Secure memory online — prior context stays inside your workspace.","Vault, Scanner, and Vision are ready when you attach files or open Eyes.","Research tools can synthesise markets, companies, documents, and web sources.","Portfolio forecast is available from the Portfolio surface.","Video Call is available from Call or Calendar when collaboration is needed."],yn=(0,i.useState)(0),ti=yn[0],Rr=yn[1],Ko=(0,i.useState)(!1),Va=Ko[0],m=Ko[1];(0,i.useEffect)(function(){if(!Va){var u=setInterval(function(){Rr(function(S){return(S+1)%En.length})},8e3);return function(){clearInterval(u)}}},[Va]),(0,i.useRef)(null),(0,i.useEffect)(function(){function u(S){var F=S&&S.detail&&S.detail.tool||"";F==="search"?Di(function(G){return!G}):F==="email"?zi(function(G){return!G}):F==="calendar"?si(function(G){return!G}):F==="brief"?ho(function(G){return!G}):F==="audit"?io(function(G){return!G}):F==="risk"&&oo(function(G){return!G})}return window.addEventListener("arenberg:chat:toggle",u),function(){window.removeEventListener("arenberg:chat:toggle",u)}},[]),(0,i.useEffect)(function(){function u(ce){if(!ce)return!1;var ze=(ce.tagName||"").toLowerCase();return ze==="input"||ze==="textarea"||ce.isContentEditable}function S(){Di(!1),Jr(!1),po(!1),go(!1),Tn(!1),vi(!1),Oi(!1),pi(!1),zi(!1),si(!1),Ji(!1),Go(!1),ca(!1),ho(!1),io(!1),oo(!1),gi(!1),Lo(!1),dl(!1),Fl(!1),Li(!1),Ro(null)}function F(ce){ce(function(ze){return ze||S(),!ze})}function G(ce){if((ce.metaKey||ce.ctrlKey)&&!(ce.shiftKey||ce.altKey)&&!u(ce.target)){var ze=ce.key;if(ze==="1"){ce.preventDefault(),F(Di),kn(null),Ir(!1);return}if(ze==="2"){ce.preventDefault(),F(Lo);return}if(ze==="3"){ce.preventDefault(),F(Jr);return}
489if(ze==="4"){ce.preventDefault(),F(vi);return}if(ze==="5"){ce.preventDefault(),Oi(function(Ge){return Ge||S(),Ge&&hi(null),!Ge});return}if(ze==="6"){ce.preventDefault(),F(zi);return}if(ze==="7"){ce.preventDefault(),F(si);return}if(ze==="8"){ce.preventDefault(),F(Ji);return}}}return window.addEventListener("keydown",G),function(){window.removeEventListener("keydown",G)}},[]),(0,i.useEffect)(function(){function u(S){var F=S&&S.detail||{},G=F.text||"";if(F.vaultDoc&&F.vaultDoc.id&&(Di(!1),Jr(!1),po(!1),Fo(!1),go(!1),Tn(!1),vi(!1),pi(!1),zi(!1),si(!1),Ji(!1),ho(!1),io(!1),oo(!1),Lo(!1),Li(!1),ji(!1),Oi(!0),hi(F.vaultDoc)),!(!G&&!(F.vaultDoc&&F.vaultDoc.id))){if(p(G),An.current=G,F.cortexContext){L.current={snapshot:F.cortexContext,at:Date.now()};try{gi(!0)}catch{}}if(F.councilMode&&String(F.councilMode).toLowerCase()==="off")try{Fc("off")}catch{}try{ma.current&&ma.current.focus()}catch{}}}return window.addEventListener("xyron:chat-prefill",u),function(){window.removeEventListener("xyron:chat-prefill",u)}},[]),(0,i.useEffect)(function(){function u(F){!F||!F.doc||!F.doc.id||window.dispatchEvent(new CustomEvent("xyron:chat-prefill",{detail:{text:F.prompt||"",vaultDoc:F.doc}}))}function S(F){u(F&&F.detail||null)}return u(tj()),window.addEventListener("xyron:vault-ask",S),function(){window.removeEventListener("xyron:vault-ask",S)}},[]);var L=(0,i.useRef)(null);function le(){var u=t.roomSymbol||null;if(u){var S=t.roomContext||{symbol:u},F=Array.isArray(t.roomPromptSuggestions)?t.roomPromptSuggestions.map(function(G){return G&&G.text?G.text:String(G||"")}).filter(Boolean).slice(0,9):[];return F.length?Object.assign({},S,{prompt_deck:F}):S}}var ye=(0,i.useState)(null),De=ye[0],Se=ye[1];(0,i.useEffect)(function(){if((Gr||dr||Qn||nr||Er||Tr||Yr||Do||or||mo||yo||Oo)&&Vs.current)try{Vs.current.scrollTop=0}catch{}},[Gr,dr,Qn,nr,Er,Tr,Yr,Do,or,mo,yo,Oo]);var Je=(0,i.useState)(null),ht=Je[0],Ht=Je[1],Bt=typeof t.activeCall<"u",pn=Bt?t.activeCall:ht,$t=Bt&&typeof t.onSetActiveCall=="function",Xt=!!t.callBusy;function zn(u){if(typeof t.onSetActiveCall=="function"){t.onSetActiveCall(u);return}Ht(u)}function Cn(u){if(!(pn||Xt)){if(typeof t.onStartCall=="function"){typeof u=="function"&&u(),t.onStartCall();return}ui("Creating secure call room…"),Ja.createRoom({title:"Xyron Quick Call"}).then(function(S){S&&S.room_url?(typeof u=="function"&&u(),zn({roomUrl:S.room_url,token:S.owner_token||null,eventId:null})):ui(S&&S.error||"Could not create call room — check backend is running and X-Xyron-Key matches server.")}).catch(function(S){ui("Call failed: "+(S.message||"network error"))})}}var Fr=(0,i.useState)(null),hn=Fr[0],hi=Fr[1],Ol=(0,i.useState)(null),Yt=Ol[0],kn=Ol[1],Br=(0,i.useState)(!1),lo=Br[0],Ir=Br[1],pa=(0,i.useState)(""),wa=pa[0],Ll=pa[1],Ps=(0,i.useState)(""),jd=Ps[0];Ps[1];var Us=(0,i.useState)(""),yi=Us[0],xo=Us[1],cs=(0,i.useState)("idle"),vo=cs[0],Bi=cs[1],Ws=(0,i.useState)([]),Dc=Ws[0],zl=Ws[1],Oc=(0,i.useState)([]),ds=Oc[0],Xo=Oc[1],Hs=(0,i.useState)(function(){try{var u=JSON.parse(localStorage.getItem("xyron_search_hist")||"[]");return Array.isArray(u)?u:[]}catch{return[]}}),Dt=Hs[0],Pn=Hs[1],Kr=(0,i.useState)([]),di=Kr[0],ar=Kr[1],Pi=(0,i.useState)(0),us=Pi[0],wd=Pi[1],Lf=(0,i.useState)([]),Au=Lf[0],Gs=Lf[1],Zp=(0,i.useState)(!1),Lc=Zp[0],Td=Zp[1],zf=(0,i.useState)(function(){return $f()}),Mf=zf[0],_d=zf[1],Ml=(0,i.useRef)(""),e0=(0,i.useState)(null),Nf=e0[0],kt=e0[1],hr=(0,i.useState)({input:0,output:0}),Wn=hr[0],_n=hr[1],Nl=(0,i.useState)(!1),Rd=Nl[0],Bf=Nl[1],fx=(0,i.useState)(!1),Ek=fx[0],t0=fx[1],px=(0,i.useState)([]),zc=px[0],gx=px[1],mx=(0,i.useState)(""),Fd=mx[0],hx=mx[1],yx=(0,i.useState)(!1),ju=yx[0],wu=yx[1],xx=(0,i.useState)(null),ga=xx[0],Ya=xx[1],n0=(0,i.useRef)(null),Vs=(0,i.useRef)(null),Id=(0,i.useRef)(!0),r0=(0,i.useRef)(!1),ni=(0,i.useRef)([]),An=(0,i.useRef)(""),cm=(0,i.useRef)(null),Pf=(0,i.useRef)({}),qo=(0,i.useRef)(!1),Uf=(0,i.useRef)(null),fl=(0,i.useRef)(null),Ka=(0,i.useRef)(null),dm=(0,i.useRef)(Ln.IDLE),Ta=(0,i.useRef)(null),$o=(0,i.useRef)(null);function vx(u){qo.current=!0;try{Ka.current&&Ka.current()}catch{}Ka.current=null;try{fl.current&&fl.current.abort()}catch{}if(fl.current=null,Uf.current){try{clearInterval(Uf.current)}catch{}Uf.current=null}
489$o.current&&(clearTimeout($o.current),$o.current=null),gt(""),oe(""),h(!1),Ta.current=null;try{ae(Ln.IDLE,u||"hard-reset")}catch{}}(0,i.useEffect)(function(){return function(){vx("unmount")}},[]),(0,i.useEffect)(function(){dm.current=W},[W]);var Ui=(0,i.useRef)(null),pl=(0,i.useRef)(null),bx=(0,i.useState)({streaming:!1,text:"",err:"",question:"",drawer:null,citations:[],followUps:[],phase:""}),Sx=(0,i.useState)([]),kk=Sx[0],Dd=Sx[1],Ex=(0,i.useState)([]),Ck=Ex[0],Od=Ex[1],kx=(0,i.useState)(function(){try{return JSON.parse(localStorage.getItem("xyron_drawer_hist")||"{}")||{}}catch{return{}}}),Cx=kx[0],um=kx[1],Ax=(0,i.useState)({}),Ak=Ax[0],Tu=Ax[1];function jk(u){u&&um(function(S){var F=Object.assign({},S);delete F[u];try{localStorage.setItem("xyron_drawer_hist",JSON.stringify(F))}catch{}return F})}function fm(u,S,F,G){if(!(!u||!S||!F)){var ce=null;if(G)try{var ze=JSON.stringify(G);ze&&ze.length<=1e5&&(ce=G)}catch{ce=null}um(function(Ge){var se=(Ge[u]||[]).slice();se.unshift({q:String(S).slice(0,200),text:String(F),artifact:ce,ts:Date.now()}),se.length>25&&(se=se.slice(0,25));var Ve=Object.assign({},Ge);Ve[u]=se;try{localStorage.setItem("xyron_drawer_hist",JSON.stringify(Ve))}catch{}return Ve})}}function wk(u,S){u&&_i({streaming:!1,text:u.text||"",err:"",question:u.q||"",drawer:S||null,citations:[],artifact:u.artifact||null})}(0,i.useEffect)(function(){var u=!1;return cf.drawerHistory().then(function(S){if(!u){var F=S&&S.items||[];if(F.length){var G={};F.forEach(function(ce){ce&&ce.drawer&&(G[ce.drawer]=G[ce.drawer]||[]).push({q:ce.q,text:ce.text,ts:ce.ts})}),um(function(ce){var ze=Object.assign({},ce);Object.keys(G).forEach(function(Ge){var se=ce[Ge]||[];ze[Ge]=G[Ge].map(function(Ve){if(Ve&&Ve.artifact)return Ve;for(var Ze=null,yt=0;yt<se.length;yt++)if(se[yt]&&se[yt].ts===Ve.ts&&se[yt].artifact){Ze=se[yt];break}return Ze?Object.assign({},Ve,{artifact:Ze.artifact}):Ve})});try{localStorage.setItem("xyron_drawer_hist",JSON.stringify(ze))}catch{}return ze})}}}).catch(function(){}),function(){u=!0}},[]);var ur=Yr?ro.state:bx[0],_i=bx[1],fs=(0,i.useRef)({}),Tk=(0,i.useRef)(function(u){fs.current.intelgraph=u}),Xa=(0,i.useRef)(null),ps=(0,i.useRef)(null),Ld=(0,i.useRef)({map:null,intel:null,room:null,realestate:null}),pm=(0,i.useRef)(0),i0=(0,i.useRef)(""),_k=["AAPL","NVDA","MSFT","GOOGL","AMZN","META","TSLA","JPM","GS","BRK","UNH","XOM","CVX","SPY","QQQ","DIA","IWM","GLD","TLT","BTC","ETH","SOL","oil","gold","bonds","treasury","fed","inflation","real estate","private equity","hedge fund"],Rk=(0,i.useMemo)(function(){if(!dr)return"";var u=l.filter(function(ce){return ce.role==="assistant"}).slice(-3).map(function(ce){return ce.content||""}).join(" ").toLowerCase(),S=["fed","federal reserve","interest rate","cpi","inflation","nvda","nvidia","aapl","apple","msft","microsoft","bitcoin","crypto","gold","oil","real estate","private equity","hedge fund","portfolio","market","stocks","bonds","geopolitical","rate cut","recession","earnings","gdp"].filter(function(ce){return u.indexOf(ce)!==-1}),F=_k.filter(function(ce){return u.indexOf(ce.toLowerCase())!==-1}),G=[];return S.forEach(function(ce){G.indexOf(ce)===-1&&G.push(ce)}),F.forEach(function(ce){G.indexOf(ce)===-1&&G.push(ce)}),G.length>0?G.slice(0,5).join(" "):"financial markets intelligence"},[dr,l]);function Fk(u,S,F){var G=we,ce=rA(t.profile),ze=t.project?t.project.id:null,Ge=ze?o5(t.project):i5(u,null),se=ze?"":s5(t.sessionId),Ve=d5(t.project),Ze=PT(u),yt=S||"",xt=F||"",Qt="",un=!1,an=!1,rr=!1,Pr=!1;yt&&(un=yt.indexOf("[LIVE MARKET DATA")!==-1,an=yt.indexOf("[BLOOMBERG")!==-1,rr=yt.indexOf("[WEB SEARCH RESULTS")!==-1,Pr=yt.indexOf("[MULTIMEDIA REQUEST")!==-1,console.log("[Prompt] live context — market:",un,"bloomberg:",an,"search:",rr,"multimedia:",Pr,"length:",yt.length),(un||an||rr)&&(Qt=`
490
491<live_data_guidance>
492Live data feeds are active and the blocks below carry real-time figures. Cite specific prices, levels and headlines verbatim from those blocks; treat them as fresher than training data. If a block answers the user's question, lead with it. Do not claim you lack access to live data when a live_market / web_search block 
492is present.
493</live_data_guidance>`));var lr=ce||Ge||se||Ve||Ze?`
494
495<memory_guidance>You have persistent memory. The blocks below are recalled context. Use stored facts. Do not deny having memory when [MEMORY] or [PRIOR CONVERSATIONS] blocks are present.</memory_guidance>`:"",dt=`
496
497<tool_capabilities>The terminal has active tools for video search, image search, web search, live market data, charts, and document generation. These capabilities are real and functional. If any stored memory below suggests a tool is unavailable, ignore that memory — tool availability is determined by the system. Use available tools when relevant.</tool_capabilities>`,Cr=typeof t.pilotIdentity=="string"&&t.pilotIdentity.length?t.pilotIdentity:G,eo=typeof t.contextBlock=="string"&&t.contextBlock.length?`
498
499`+t.contextBlock:"",Dr=Cr+Qt+yt+xt+dt+lr+ce+Ge+se+Ve+Ze+eo;return console.log("[Prompt] total length:",Dr.length,"| live data present:",!!(un||an||rr),"| cortex block:",xt.length),Dr}function Ik(u){var S=u.img,F=(0,i.useState)(!1),G=F[0],ce=F[1];return(0,e.jsxs)("div",{style:{position:"relative",borderRadius:8,overflow:"hidden",border:"1px solid #1E2838",cursor:"pointer",background:"#0A0E14"},onClick:function(){ce(!0)},children:[(0,e.jsx)("img",{src:S.thumbnail,alt:S.title,style:{width:"100%",height:120,objectFit:"cover",display:"block"},onError:function(ze){ze.target.style.display="none"}}),(0,e.jsxs)("div",{style:{padding:"6px 8px"},children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:9,color:"#C9D1D9",lineHeight:1.3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:S.title}),(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:7,color:"#3A5060",marginTop:2},children:S.source||"Web"})]}),G&&(0,e.jsxs)("div",{onClick:function(ze){ze.stopPropagation(),ce(!1)},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.92)",zIndex:9999,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",cursor:"zoom-out"},children:[(0,e.jsx)("img",{src:S.thumbnail.replace("w=400&h=300","w=1200&h=900"),alt:S.title,style:{maxWidth:"90vw",maxHeight:"80vh",borderRadius:8,border:"1px solid #2A3548"}}),(0,e.jsx)("div",{style:{marginTop:12,fontFamily:"monospace",fontSize:11,color:"#C9D1D9"},children:S.title}),(0,e.jsx)("a",{href:S.url,target:"_blank",rel:"noopener noreferrer",onClick:function(ze){ze.stopPropagation()},style:{fontFamily:"monospace",fontSize:9,color:"#D4AF5C",marginTop:4},children:"Open source ↗"})]})]})}function jx(u){var S=u.vid;return(0,e.jsxs)("div",{onClick:function(){aa(S.url,S.title)},role:"button",tabIndex:0,onKeyDown:function(F){(F.key==="Enter"||F.key===" ")&&aa(S.url,S.title)},style:{display:"flex",gap:10,padding:10,background:"#0A0E14",border:"1px solid #1E2838",borderRadius:8,cursor:"pointer",transition:"border-color .15s"},onMouseEnter:function(F){F.currentTarget.style.borderColor="rgba(212,175,92,0.35)"},onMouseLeave:function(F){F.currentTarget.style.borderColor="#1E2838"},children:[(0,e.jsxs)("div",{style:{position:"relative",flexShrink:0,width:140,height:80,borderRadius:6,overflow:"hidden",background:"#06080D"},children:[(0,e.jsx)("img",{src:S.thumbnail,alt:S.title,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"},onError:function(F){F.target.style.display="none"}}),(0,e.jsx)("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.3)"},children:(0,e.jsx)("div",{style:{width:28,height:28,borderRadius:"50%",background:"rgba(212,175,92,0.9)",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,e.jsx)("div",{style:{width:0,height:0,borderLeft:"10px solid #000",borderTop:"6px solid transparent",borderBottom:"6px solid transparent",marginLeft:2}})})})]}),(0,e.jsxs)("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",justifyContent:"center"},children:[(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:11,color:"#E6EDF3",fontWeight:600,lineHeight:1.3,marginBottom:3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:S.title}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:3},children:[(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:8,color:"#D4AF5C"},children:S.channel||S.author||S.provider}),S.duration&&(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:7,color:"#5A7090"},children:S.duration}),S.views&&(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:7,color:"#5A7090"},children:S.views})]}),(0,e.jsx)("div",{style:{fontFamily:"monospace",fontSize:9,color:"#5A7090",lineHeight:1.3,overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:S.description})]})]})}function gm(u){return u=q0(u),u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/^[-]{3,}$/gm,'<div style="border-top:1px solid #1E2838;margin:6px 0"></div>').replace(/^[*]{3,}$/gm,'<div style="border-top:1px solid #1E2838;margin:6px 0"></div>').replace(/\n{3,}/g,`
500
501`).replace(/\*\*([^*]+)\*\*/g,'<strong style="color:#E6EDF3;font-weight:700">$1</strong>').replace(/\*\*/g,"").replace(/^## (.+)$/gm,'<div style="font-family:monospace;font-size:10px;font-weight:700;color:#D4AF5C;letter-spacing:.12em;margin-top:10px;margin-bottom:4px;border-bottom:1px solid #1E2838;padding-bottom:3px">$1</div>').replace(/^### (.+)$/gm,'<div style="font-family:monospace;font-size:10px;font-weight:700;color:#D4AF5C;letter-spacing:.10em;margin-top:8px;margin-bottom:3px">$1</div>').replace(/^[-*] (.+)$/gm,'<div style="margin-left:16px;color:#C9D1D9"><span style="color:#D4AF5C">›</span> $1</div>').replace(/^\d+\. (.+)$/gm,'<div style="margin-left:16px;color:#C9D1D9">$1</div>').replace(/`([^`]+)`/g,'<code style="font-family:monospace;font-size:11px;background:rgba(212,175,92,0.12);border:1px solid rgba(212,175,92,0.2);border-radius:3px;padding:1px 5px;color:#D4AF5C">$1</code>').replace(/^\|[-:|\s]+\|$/gm,"").replace(/\n\n/g,'<div style="height:6px"></div>').replace(/\n/g,"<br/>")}var Dk={THE:1,AND:1,FOR:1,ARE:1,NOT:1,BUT:1,YOU:1,THIS:1,WHAT:1,HOW:1,CAN:1,WILL:1,HAS:1,HAD:1,HIS:1,HER:1,ALL:1,ONE:1,TWO:1,OUR:1,MAY:1,USE:1,NEW:1,NOW:1,ITS:1,WAS:1,WHO:1,LET:1,ANY:1,OWN:1,INTO:1,BEEN:1,THEM:1,THAN:1,MOST:1,MORE:1,ALSO:1,FROM:1,SOME:1,THEY:1,THAT:1,WITH:1,HAVE:1,WHEN:1,VERY:1,WERE:1,OVER:1,JUST:1,EACH:1,DOES:1,MUCH:1,SAME:1};function mm(u){return u.split(/(\b[A-Z]{2,5}\b(?:\s*\d[\d.,%]*)?\b|\$[\d,.]+[BMKTbmkt]?|[+-]?\d+\.?\d*%|\d+\.\d+%)/g).map(function(S,F){var G=S.trim();return/^\$[\d,.]+[BMKTbmkt]?$|^[+-]?\d+\.?\d*%$|^\d+\.\d+%$/.test(G)?i.createElement("span",{key:
501F,style:{color:"#D4AF5C",fontFamily:n,fontSize:12.5,fontWeight:600,letterSpacing:"0.02em"}},S):/^[A-Z]{2,5}(?:\s*\d[\d.,%]*)?$/.test(G)&&!Dk[G]?i.createElement("span",{key:F,style:{color:"#D4AF5C",fontFamily:n,fontSize:12.5,fontWeight:600,letterSpacing:"0.02em"}},S):S})}function Ok(u,S){var F=(u||"").toLowerCase(),G=(S||"").toLowerCase();return F.match(/\b(draft|write|compose|reply|respond|email|memo|letter|template|send to|forward)\b/)||F.match(/\b(advise me on this|screen this|vet this|due diligence|check this company|check this person)\b/)||F.match(/\b(compliance|audit|regulatory|invoice|accounting|payroll|contract|agreement|clause)\b/)||F.match(/\b(schedule|meeting|calendar|reminder|task|todo|action item)\b/)||F.match(/\b(vault|document|upload|download|save|export|generate pdf|generate doc)\b/)||G.match(/\b(cold outreach|cold email|unsolicited|screening|gatekeeper|polite.{0,10}reply|decline)\b/)||G.match(/\b(do not allocate|no basis for engagement|red flag|time.wasting)\b/)?!1:!!(F.match(/\b(market|stock|equit|bond|yield|rate|fed|ecb|boe|boj|inflation|cpi|gdp|oil|gold|crypto|bitcoin|forex|fx|commodit|s&p|nasdaq|dow|vix|earnings)\b/)||F.match(/\b(geopolit|war|conflict|sanction|election|tariff|trade war|china|russia|iran|opec)\b/)||F.match(/\b(news|latest|breaking|today|this week|overnight|morning brief|what happened)\b/)||F.match(/\b(video|watch|analysis|outlook|forecast|prediction)\b/)||F.match(/\b(portfolio|nav|allocation|risk|exposure|position|hedge)\b/)||F.length<60&&!F.match(/\b(hi|hello|thanks|ok|yes|no|help)\b/))}var Lk={CRITICAL:"#D44040",HIGH:"#D4AF5C",MEDIUM:"#8FA3B8",LOW:"#3A4A5E"};function zk(u){if(!u||typeof u!="string")return null;var S=u.trim();if(S=S.replace(/^```(?:json)?\s*/i,"").replace(/```\s*$/i,"").trim(),!S.startsWith("[")&&!S.startsWith("{")){var F=S.match(/\[\s*\{[\s\S]*\}\s*\]/);if(!F)return null;S=F[0]}try{var G=JSON.parse(S);return!Array.isArray(G)||!G.length?null:G.every(function(ce){return ce&&typeof ce=="object"&&(ce.action||ce.prompt)&&(ce.priority||ce.category)})?G:null}catch{return null}}function Mk(u){var S=u.map(function(F,G){var ce=Lk[(F.priority||"").toUpperCase()]||"#8FA3B8",ze=F.prompt?function(){try{p(F.prompt)}catch{}}:null;return i.createElement("div",{key:"actrow-"+G,onClick:ze,title:ze?"Load this prompt into the composer":void 0,style:{display:"flex",flexDirection:"column",gap:6,padding:"12px 14px",background:"#05070E",border:"1px solid #0D1520",borderTop:"1px solid "+ce+"55",borderRadius:6,cursor:ze?"pointer":"default",transition:"all .15s"},onMouseEnter:function(Ge){Ge.currentTarget.style.background="#080B16",Ge.currentTarget.style.borderColor=ce+"44",Ge.currentTarget.style.borderTopColor=ce},onMouseLeave:function(Ge){Ge.currentTarget.style.background="#05070E",Ge.currentTarget.style.borderColor="#0D1520",Ge.currentTarget.style.borderTopColor=ce+"55"}},i.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8}},i.createElement("span",{style:{fontFamily:n,fontSize:7,letterSpacing:".18em",color:"#5A6880",textTransform:"uppercase"}},F.category||"ACTION"),i.createElement("span",{style:{fontFamily:n,fontSize:7,letterSpacing:".14em",color:ce,padding:"2px 6px",border:"1px solid "+ce+"44",borderRadius:2,textTransform:"uppercase"}},F.priority||"—")),i.createElement("div",{style:{display:"flex",alignItems:"flex-start",gap:8}},i.createElement("span",{style:{fontSize:13,color:ce,lineHeight:1.2,marginTop:1,flexShrink:0}}
501,"→"),i.createElement("div",{style:{fontSize:13,fontWeight:600,color:"#E6EDF3",lineHeight:1.4,letterSpacing:".01em"}},F.action||"")),F.context?i.createElement("div",{style:{fontSize:12,color:"#8FA3B8",lineHeight:1.55,paddingLeft:21}},F.context):null,F.prompt?i.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:4,paddingTop:8,borderTop:"1px solid #0D1828",paddingLeft:21}},i.createElement("span",{style:{fontFamily:n,fontSize:7,letterSpacing:".18em",color:"#B05555",textTransform:"uppercase"}},"Ask Xyron"),i.createElement("span",{style:{fontFamily:n,fontSize:10,color:ce,fontWeight:700}},"→")):null)});return i.createElement("div",{style:{display:"flex",flexDirection:"column",gap:8,marginTop:4}},i.createElement("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:2}},i.createElement("div",{style:{width:5,height:5,borderRadius:"50%",background:"#D4AF5C"}}),i.createElement("div",{style:{fontFamily:n,fontSize:8,letterSpacing:".22em",color:"#6B7A94",fontWeight:700}},"PRIORITY ACTIONS · "+u.length),i.createElement("div",{style:{flex:1,height:1,background:"#0D1520"}})),S)}function Nk(u){try{return new URL(u).hostname.replace(/^www\./,"")}catch{return""}}function Bk(u,S){var F=null;if(u)try{F=document.querySelector('[data-chat-message-id="'+u+'"]')}catch{}if(!F&&Vs.current&&S!=null&&S>=0)try{F=Vs.current.querySelectorAll("[data-chat-message-id]")[S]||null}catch{}F&&(Id.current=!1,r0.current=!0,F.scrollIntoView({behavior:"smooth",block:"center"}))}function Pk(u,S){return!u||!u.length?null:i.createElement("div",{style:{marginTop:10,borderRadius:6,border:"1px solid rgba(212,175,92,0.20)",background:"rgba(6,8,13,0.95)",overflow:"hidden"}},i.createElement("div",{style:{padding:"5px 12px",borderBottom:"1px solid rgba(212,175,92,0.10)",display:"flex",justifyContent:"space-between",alignItems:"center",background:"rgba(212,175,92,0.04)"}},i.createElement("span",{style:{fontSize:9,fontFamily:n,color:"#D4AF5C",letterSpacing:".1em",fontWeight:700}},"◈ WEB SOURCES"),i.createElement("span",{style:{fontSize:8,fontFamily:n,color:"#3A4A5E"}},u.length+" LIVE SOURCES")),i.createElement("ol",{style:{margin:0,padding:"6px 12px 8px 28px",listStyle:"decimal",color:"#8FA3B8"}},u.map(function(F,G){var ce=Nk(F.url||"");return i.createElement("li",{key:G,id:"cite-"+S+"-"+(F.number||G+1),style:{fontFamily:n,fontSize:9,lineHeight:1.6,padding:"2px 0",color:"#8FA3B8"}},i.createElement("a",{href:F.url,target:"_blank",rel:"noopener noreferrer",style:{color:"#D4AF5C",textDecoration:"none"}},F.title||F.url||"Source"),ce&&i.createElement("span",{style:{color:"#5A7090",marginLeft:6,fontSize:8}},ce),F.jurisdiction&&i.createElement("span",{style:{fontFamily:n,fontSize:8,color:"#D4AF5C",border:"1px solid rgba(212,175,92,0.30)",background:"rgba(212,175,92,0.08)",padding:"1px 5px",borderRadius:3,letterSpacing:".08em",marginLeft:6}},F.jurisdiction),F.snippet&&i.createElement("div",{style:{color:"#6B7B8E",fontSize:8,fontStyle:"italic",marginTop:2,lineHeight:1.5}},String(F.snippet).slice(0,300)))})))}function wx(u){if(!u)return null;u=Jm(u);var S=zk(u);if(S&&S.length)return Mk(S);function F(Ge,se){var Ve=Ge.replace(/<<<FOLLOW_UPS>>>[\s\S]*?<<<END_FOLLOW_UPS>>>/g,"").replace(/<<<FOLLOW_UPS>>>[\s\S]*/g,"").replace(/\*\*/g,"").replace(/\*/g,"").replace(/^#{1,6}\s/gm,"").replace(/^[-*]\s/gm,"").replace(/^>\s/gm,"").replace(/---+/g,"").replace(/`([^`]+)`/g,"$1").replace(/Source:\s*Xyron Backend/gi,"").replace(/Source:\s*Twelve Data/gi,"").trim();return Ve?Ve.split(/\n\n+/).filter(function(Ze){return Ze.trim()}).map(function(Ze,yt){var xt=Ze.trim();if(xt.length<40&&xt===xt.toUpperCase()&&/[A-Z]/.test(xt))return i.createElement("div",{key:se+"-l"+yt,style:{fontFamily:n,fontSize:9,fontWeight:700,color:"#D4AF5C",letterSpacing:"0.14em",marginTop:yt>0?16:0,marginBottom:6}},xt);if(/^\d+\.\s/.test(xt)&&xt.length<80)return i.createElement("div",{key:se+"-h"+yt,style:{fontSize:13,fontWeight:600,color:"#E6EDF3",marginTop:yt>0?14:0,marginBottom:4,fontFamily:"'SF Pro Text', -apple-system, sans-serif"}},mm(xt));var Qt=Ze.split(/\n/).filter(function(un){return un.trim()});return i.createElement("div",{key:se+"-p"+yt,style:{marginBottom:10}},Qt.map(function(un,an){return i.createElement("p",{key:an,style:{margin:0,marginBottom:Qt.length>1&&an<Qt.length-1?4:0}},mm(un.trim()))}))}):[]}function G(Ge,se){var Ve=Ge.header.length-1;return i.createElement("div",{key:"tbl"+se,style:{overflowX:"auto",margin:"10px 0"}},i.createElement("table",{style:{borderCollapse:"collapse",width:"100%",fontFamily:n,fontSize:12}},i.createElement("thead",null,i.createElement("tr",null,Ge.header.map(function(Ze,yt){return i.createElement("th",{key:yt,style:{textAlign:yt===Ve?"right":"left",padding:"6px 10px",borderBottom:"2px s
501olid rgba(212,175,92,0.4)",color:"#D4AF5C",fontSize:11,letterSpacing:".04em",whiteSpace:"nowrap"}},Ze)}))),i.createElement("tbody",null,Ge.rows.map(function(Ze,yt){return i.createElement("tr",{key:yt,style:{background:yt%2?"rgba(255,255,255,0.02)":"transparent"}},Ze.map(function(xt,Qt){return i.createElement("td",{key:Qt,style:{padding:"5px 10px",borderBottom:"1px solid #1E2838",color:"#C5CAD2",textAlign:Qt===Ve?"right":"left",whiteSpace:"nowrap"}},mm(xt))}))}))))}var ce=m8(u),ze=[];return ce.forEach(function(Ge,se){Ge.type==="table"?ze.push(G(Ge,se)):Ge.type==="heading"?ze.push(i.createElement("div",{key:"heading"+se,style:{fontFamily:n,fontSize:Ge.depth===1?13:10,fontWeight:800,color:"#D4AF5C",letterSpacing:Ge.depth===1?".08em":".14em",textTransform:"uppercase",marginTop:se>0?18:2,marginBottom:7,paddingBottom:5,borderBottom:"1px solid rgba(212,175,92,0.24)"}},Ge.text)):ze=ze.concat(F(Ge.text,"b"+se))}),i.createElement("div",{style:{color:"#C9D1D9",fontSize:13.5,lineHeight:1.8,fontFamily:"'SF Pro Text', -apple-system, 'Segoe UI', sans-serif",letterSpacing:"0.01em"}},ze)}function o0(){!Id.current||!Vs.current||(r0.current=!0,Vs.current.scrollTop=Vs.current.scrollHeight)}function Uk(){if(r0.current){r0.current=!1;return}var u=Vs.current;if(u){var S=u.scrollHeight-u.scrollTop-u.clientHeight,F=Id.current;Id.current=S<50,F&&!Id.current&&console.log("[Scroll] auto-scroll locked — user scrolled up"),!F&&Id.current&&console.log("[Scroll] user returned to bottom — auto-scroll resumed")}}(0,i.useEffect)(function(){An.current=d},[d]);var ma=(0,i.useRef)(null);(0,i.useEffect)(function(){var u=ma.current;u&&(u.style.height="auto",u.style.height=Math.min(u.scrollHeight,200)+"px")},[d]);var zd=(0,i.useRef)(null);(0,i.useEffect)(function(){o0()},[l,f]),(0,i.useEffect)(function(){var u=t.focusMessage;if(!(!u||!u.id&&u.index==null)){Re(!1),Jt({id:u.id||null,index:u.index});var S=setTimeout(function(){Bk(u.id,u.index)},80),F=setTimeout(function(){Jt(null)},2600);return function(){clearTimeout(S),clearTimeout(F)}}},[t.focusMessage]),(0,i.useEffect)(function(){var u=pD({propsSessionId:t.sessionId,loadedSessionId:Ui.current,selfCreatedSe
501ssionId:pl.current});if(u.action==="reset"){Ui.current=null;return}if(u.action!=="noop"){if(u.action==="adopt"){Ui.current=t.sessionId;return}if(u.action==="reload"){pl.current=null,Ui.current=t.sessionId;var S=t.sessionId,F=0;if(s([]),ni.current=[],!t.roomId)try{var G=localStorage.getItem("xyron_messages_"+S);if(G){var ce=JSON.parse(G);if(Array.isArray(ce)){var ze=ce.map(function(Ge){return j1(Ge)}).filter(function(Ge){return!Ge.roomSuperseded&&!Ge.roomPersistencePending});F=ze.length,s(ze),ni.current=ze.map(function(Ge){return{role:Ge.role,content:Ge.content||Ge.text||""}})}}}catch{}try{mA.get(S,t.roomId?{roomId:t.roomId}:void 0).then(function(Ge){if(S===Ui.current){var se=gD(Ge,!!t.roomId);if(Array.isArray(se)){if(!t.roomId&&F>se.length)return;var Ve=se.map(function(Ze){return j1(Ze)}).filter(function(Ze){return!Ze.roomSuperseded&&!Ze.roomPersistencePending});s(Ve),ni.current=Ve.map(function(Ze){return{role:Ze.role,content:Ze.content||Ze.text||""}}),t.roomId&&(mD(Ve,S,t.onSaveSession),y(function(Ze){return Ze==="ROOM_TRANSCRIPT_UNAVAILABLE: Room transcript could not be loaded. Try again."?"":Ze}))}}}).catch(function(){S===Ui.current&&t.roomId&&y(A1)})}catch{t.roomId&&S===Ui.current&&y(A1)}}t.sessionId||(Ui.current=null)}},[t.sessionId,t.roomId]),(0,i.useEffect)(function(){try{jt(JSON.parse(localStorage.getItem("xyron_pinned_msgs")||"[]"))}catch{}try{var u=localStorage.getItem("xyron_custom_instructions");u&&b(u)}catch{}try{localStorage.getItem("xyron_tts")==="1"&&Wt(!0)}catch{}try{window.Notification&&Notification.permission==="default"&&Notification.requestPermission()}catch{}},[]);var a0={model:Dy,label:"Fast",tier:"fast"},l0={model:Dm,label:"Standard",tier:"standard"},Mc={model:_A,label:"Deep",tier:"deep"};function Tx(u,S){try{var F=(u||"").toLowerCase(),G=(u||"").length,ce=!!(S&&S.attachments&&S.attachments.length>0),ze=!!(S&&S.savedDocs&&S.savedDocs.length>0&&F.match(/vault|document|file|policy|report|agreement|charter/)),Ge=!!(S&&S.project);return G>
501600||F.match(/\b(comprehensive|detailed report|full analysis|in.depth|thorough|multi.?step)\b/)||F.match(/\b(generate|create|write|draft|prepare)\b/)&&F.match(/\b(report|brief|memo|board pack|document|white paper|proposal|contract|agreement)\b/)||F.match(/\b(legal|compliance|regulatory|audit|due diligence|fiduciary)\b/)||F.match(/\b(strategy|strategic|business plan|framework|thesis|evaluate.*options)\b/)||F.match(/\b(stress test|scenario analysis|board pack|portfolio review|risk assessment)\b/)||ce||G>400&&Ge?Mc:F.match(/\b(image|images|picture|pictures|photo|photos|logo|logos|draw|drawing|illustration|illustrate|diagram)\b/)||xb(u)?l0:G<100&&!ze&&!Ge&&(F.match(/^(hi|hello|hey|thanks|thank you|good morning|good afternoon|good evening|yo)\b/)||F.match(/^(what is|what are|who is|who was|when did|when was|where is|define|meaning of|price of|how much|how many|what time|what date)\b/)||F.match(/^(translate|convert|list|show|tell me a joke|summarize this|tldr|sum up)\b/)||G<40)?a0:l0}catch{return l0}}function _x(u,S){if(!S||S.length===0)return u;var F=[];return S.forEach(function(G){if(!G.isError&&!(G.state==="pending"||G.state==="uploading"||G.state==="failed")&&!(G.gcsUri&&G.state==="ready")){if(G.isImage&&G.content)F.push("[Attached image: "+G.name+"]");else if(G.isVault&&G.content&&G.content.length>0)F.push("--- Vault document: "+G.name+` ---
502`+G.content+`
503--- End of `+G.name+" ---");else if(G.content&&G.content.length>0&&G.content!=="[binary]"){var ce=G.content;G.truncated&&(ce=ce+`
504
505[...truncated — file was `+G.originalSize+" chars; first 8000 shown.]"),F.push("--- Attached file: "+G.name+` ---
506`+ce+`
507--- End of `+G.name+" ---")}}}),F.length===0?u:u+`
508
509`+F.join(`
510
511`)}var Wk="Web search could not complete";function Hk(u){var S=String(u||"");return/^Searching the web/i.test(S)?"Searching the web…":/^Reading source/i.test(S)?"Reading sources…":/^Thinking/i.test(S)?"Thinking…":/^Running code/i.test(S)?"Running code…":/^Consulting primary sources/i.test(S)?"Consulting primary sources…":/^Analyzing/i.test(S)||/^Preparing/i.test(S)?"Analyzing…":S}function Rx(u,S,F,G,ce,ze,Ge){pA();var se=new AbortController;fl.current=se,qo.current=!1,ge==="xyron-auto"&&S.model,F.concat([{role:"user",content:u}]);var Ve=!1,Ze=Ta.current,yt=null,xt="",Qt=0,un=0,an=null,rr=null,Pr=null,lr=[],dt={},Cr=!1,eo=!1;Cd($f());function Dr(){if(yt){try{yt.cancel()}catch{}yt=null}}var So=null;function Ar(){So&&clearTimeout(So),So=setTimeout(function(){!Ve&&!qo.current&&ae(Ln.STALLED,"soft-stall")},1e4)}function Pl(){an&&(clearTimeout(an),an=null),rr&&(clearTimeout(rr),rr=null),So&&(clearTimeout(So),So=null),At&&(clearTimeout(At),At=null),Pr&&(clearTimeout(Pr),Pr=null)}Ka.current=function(){Ve||(Ve=!0,Pl(),Dr())};function ri(Ur){if(!Ve){Ve=!0,Ka.current=null,xe.current&&(xe.current.disarm(),xe.current=null),Pl();var jr=ut.current&&ut.current.turnId===Ze?ut.current:null;wt(null),$o.current&&Ta.current===Ze&&(clearTimeout($o.current),$o.current=null,Ta.current=null),Dr();try{se.abort()}catch{}if(fl.current=null,gt(""),(an!==null||rr!==null||So!==null||At!==null)&&W0(Ta.current,"timer survived terminate()",{hardTimeoutId:an,stallTimeoutId:rr,softStallTimeoutId:So,_paceTimer:At}),Ka.current!==null&&W0(Ta.current,"streamCleanupRef survived terminate()"),Ur&&!qo.current?ae(Ln.ERROR,"terminate-err"):qo.current||ae(Ln.IDLE,"terminate-ok"),xt.length>0||typeof dt.cleanedContent=="string"||lr&&lr.length>0){var Ks=typeof dt.cleanedContent=="string"?dt.cleanedContent:null,Vf=Jm(Ks!==null?Ks:xt).replace(/<<<FOLLOW_UPS>>>[\s\S]*?<<<END_FOLLOW_UPS>>>/g,"").replace(/<<<FOLLOW_UPS>>>[\s\S]*/g,"").trim(),Yf=f_(Vf),Hd=Yf?p_(Vf):Vf,Kf=dt.followUps&&dt.followUps.length>0?dt.followUps:Lu(Hd,ce);dt.followUps=null,dt.cleanedContent=null;var Bc=dt.executionMode||"",h0=Bc?Bc.replace(/_/g," ").replace(/\b\w/g,function(gl){return gl.toUpperCase()}):S.label;dt.executionMode=null,dt.queryMode=null,dt.classification=null;var ir={id:G,role:"assistant",text:Hd,ts:new Date().toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"}),followUps:Kf,modelLabel:h0,executionMode:Bc};if(dt.roomId&&(ir.roomId=dt.roomId,ir.roomContextVersion=dt.roomContextVersion,dt.roomId=null,dt.roomContextVersion=null),dt.roomStale&&(ir.roomStale=!0,dt.roomStale=null),dt.roomPersistenceFailed&&(ir.roomPersistenceFailed=!0,dt.roomPersistenceFailed=null),dt.persistenceFailed&&(ir.persistenceFailed=!0,dt.persistenceFailed=null),dt.deadlineExceeded&&(ir.deadlineExceeded=!0,dt.deadlineExceeded=null),Yf&&(ir.chart=Yf),dt.searchData&&(ir.searchData=dt.searchData,dt.searchData=null),dt.webSearch&&(ir.webSearch=dt.webSearch,dt.
511webSearch=null),dt.memoryContext&&(ir.memoryContext=dt.memoryContext,dt.memoryContext=null),dt.vaultSources&&(ir.vaultSources=dt.vaultSources,dt.vaultSources=null),dt.validated&&(ir.wasValidated=!0,dt.validated=null),dt.citations&&(ir.citations=dt.citations,dt.citations=null),dt.codeTraces&&(ir.msgMetadata=Object.assign({},ir.msgMetadata||{},{code_executions:dt.codeTraces}),dt.codeTraces=null),dt.thinkingTrace&&(ir.msgMetadata=Object.assign({},ir.msgMetadata||{},{thinking_trace:dt.thinkingTrace}),dt.thinkingTrace=null),dt.artifacts&&dt.artifacts.length>0){if(ir.msgMetadata=Object.assign({},ir.msgMetadata||{},{artifacts:dt.artifacts}),jr)for(var Xf=0;Xf<dt.artifacts.length;Xf++){var Gd=dt.artifacts[Xf];if(Gd&&(Gd.type==="image"||Gd.type==="chart")){ir.genReveal={kind:jr.kind,startedAt:jr.startedAt,artifactId:Gd.id||null,error:Gd.error||null};break}}typeof dt.artifactCleaned=="string"&&(ir.text=dt.artifactCleaned,Hd=dt.artifactCleaned);try{Uo({messageId:G,artifact:dt.artifacts[0]})}catch{}dt.artifacts=null,dt.artifactCleaned=null}else{dt.artifactCleaned=null;try{if(ir.text&&ir.text.indexOf("<xyron_art")!==-1){var y0=q0(ir.text);y0!==ir.text&&(ir.text=(y0||"").trim(),Hd=ir.text,jr&&(ir.genReveal={kind:jr.kind,startedAt:jr.startedAt,artifactId:null,error:"Generation was interrupted before the render finished — ask again to retry."}))}}catch{}}oe(""),lr&&lr.length>0&&(ir.toolArtifacts=fD(lr)),dt.routeDecisionId&&(ir.routeDecisionId=dt.routeDecisionId,dt.routeDecisionId=null),(Qt||un)&&(ir.tokens={input:Qt,output:un},_n(function(gl){return{input:gl.input+Qt,output:gl.output+un}})),h(!1),Xk(ir,F,ce)}else if(oe(""),h(!1),Ur&&!qo.current&&y(Ur),t.onSaveSession){var km=new Date().toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"}),Iu=(F||[]).map(function(gl,Cm){return{id:"h"+Cm,role:gl.role,content:gl.content||"",ts:""}});Iu.push({id:"u-fail-"+Date.now(),role:"user",content:ce||"",ts:km});try{t.onSaveSession(Iu,Ui.current||pl.current)}catch{}}}}function Ei(){console.log("[Xyron Timing] response complete:",(performance.now()-gs).toFixed(0)+"ms, chars:",xt.length),Wl(),ri(null)}function Eo(){rr&&clearTimeout(rr);var Ur=kr?12e4:45e3,jr="Response stalled — no data received for "+(Ur/1e3|0)+" seconds";rr=setTimeout(function(){qo.current||ri(jr)},Ur)}var Ri=150,ha=500,_a=1,sn=18,Hn=2,me=4,Ot=18,Gt=16,In=5,Mn=16,Vt=!1,fn=0,At=null,Dn=ff();function zt(){if(fn<Ri)return{chunk:_a,ms:sn};if(fn<ha){var Ur=(fn-Ri)/(ha-Ri);return{chunk:Math.round(Hn+(me-Hn)*Ur),ms:Math.round(Ot+(Gt-Ot)*Ur)}}return{chunk:In,ms:Mn}}function ki(){if(At=null,!qt.current){At=setTimeout(ki,16);return}if(Dn){if(fn>=xt.length)return;fn=xt.length;var Ur=xt.substring(0,fn).replace(/<<<FOLLOW_UPS>>>[\s\S]*/g,"");qt.current.innerHTML=gm(Ur),o0();return}if(fn>=xt.length){At=setTimeout(ki,30);return}var jr=zt();fn=Math.min(fn+jr.chunk,xt.length);var Ks=xt.substring(0,fn).replace(/<<<FOLLOW_UPS>>>[\s\S]*/g,"");qt.current.innerHTML=gm(Ks),o0(),At=setTimeout(ki,jr.ms)}function Sn(){At||(At=setTimeout(ki,Dn?16:sn))}function Ul(){At&&(clearTimeout(At),At=null)}function Wl(){Ul();var Ur=Jm(xt).replace(/<<<FOLLOW_UPS>>>[\s\S]*?<<<END_FOLLOW_UPS>>>/g,"").replace(/<<<FOLLOW_UPS>>>[\s\S]*/g,"").trim();fn=Ur.length,qt.current&&(qt.current.innerHTML=gm(Ur),o0())}function sr(){Vt||(Vt=!0,gt(""),setTimeout(function(){gt("active"),Sn()},0))}an=setTimeout(function(){qo.current||ri("Request timed out after 120 seconds")},12e4),Eo();var gs=performance.now();console.log("[Xyron Timing] prompt assembled, sending fetch:",gs.toFixed(0)+"ms");var Xn=L.current;L.current=null;var Mo=typeof performance<"u"?performance.now():Date.now(),Ra=(ce||"").trim(),Fu=Ra.length<12&&/^(hi|hey|hello|yo|sup|thanks|thank you|ok|okay|yes|no|sure|gm|gn|cool|nice|great)\b/i.test(Ra),ms=iT({enabled:ff(),generalMode:Ne,roomSymbol:t.roomSymbol}),nv=Fu||ms?Promise.resolve(""):LA(ce).then(function(Ur){var jr=zA(Ur,ce);return Xn&&Xn.snapshot&&(jr=`
512
513<cortex_handoff source="drawer">
514`+String(Xn.snapshot)+`
515</cortex_handoff>`+jr),jr}).catch(function(Ur){return console.warn("[Cortex] snapshot fetch failed:",Ur&&Ur.message),""}),LC=1200;(ms?nv:Promise.race([nv,new Promise(function(Ur){Pr=setTimeout(function(){Ur("")},LC)})])).then(function(Ur){Pr&&(clearTimeout(Pr),Pr=null);try{(typeof performance<"u"?performance.now():Date.now())-Mo}catch{}return Ur}).then(function(Ur){if(Ve||qo.current||Ta.current!==Ze)return;var jr=t.roomSymbol||null,Ks=jr&&t.roomId?{roomId:t.roomId,contextVersion:t.roomContextVersion}:null;xe.current=Ks?v6({getCurrentIdentity:function(){return Pt.current},clearDisplay:function(){try{qt.current&&(qt.current.innerHTML="")}catch{}},terminate:function(){dt.roomStale=!0,ri(null)}}):null,xe.current&&xe.current.arm(Ks);var Vf=jr||Ne?"/api/chat/general/stream":"/api/chat/stream",Yf=ni.current.slice(-12),Hd=jr?le():void 0,Kf=Ui.current||pl.current||null,Bc=Fk(ce,Ge,Ur),h0=LT(fi,OT([].concat(t.project&&t.project.knowledgeDocs||[],t.roomKnowledgeDocs||[]))),ir=Ne||jr?{message:ce,session_id:Kf,project_id:t.project?t.project.id:void 0,messages:ni.current.slice(-12),provider:Pe,product:de==="xyron_legal"?"xyron_legal":de==="auto"?"auto":void 0,enable_web:Ai!=="off",mode:wl(),enable_code:Pe!=="perplexity",enable_thinking:!1,
515council_enabled:!!zo,council_mode:Ca,system_prompt:Bc,attachments:h0.filter(function(mt){return mt.state==="ready"&&mt.gcsUri&&mt.fileId}).map(function(mt){return{file_id:mt.fileId,gcs_uri:mt.gcsUri,mime:mt.sniffedMime||mt.mime||"application/octet-stream",name:mt.name,size:mt.size}}),vault_file_id:nr&&hn&&hn.id||null,ledger_entity_id:Sr||Io.current?(function(){try{return localStorage.getItem("xyron_ledger_entity")||null}catch{return null}})():null,ledger_handoff:Io.current?!0:void 0,active_drawer:jr?"room":void 0,drawer_context:Hd,room_id:jr&&t.roomId||void 0,room_context_version:jr&&t.roomContextVersion!=null?t.roomContextVersion:void 0}:{message:ce,session_id:Ui.current||null,project_id:t.project?t.project.id:void 0,messages:Yf,system_prompt:Bc,cortex_enabled:!!kr,council_enabled:!!zo,council_mode:Ca,vault_file_id:nr&&hn&&(hn.id||hn.doc_id)||null,ledger_entity_id:Sr||Io.current?(function(){try{return localStorage.getItem("xyron_ledger_entity")||null}catch{return null}})():null,ledger_handoff:Io.current?!0:void 0};function Xf(){var mt=ni.current.slice(-12);return Ne||jr?{message:ce,session_id:Kf,project_id:t.project?t.project.id:void 0,messages:ni.current.slice(-12),provider:Pe,product:de==="xyron_legal"?"xyron_legal":de==="auto"?"auto":void 0,enable_web:Ai!=="off",mode:wl(),enable_code:Pe!=="perplexity",enable_thinking:!1,council_enabled:!!zo,council_mode:Ca,system_prompt:Bc,attachments:h0.filter(function(Nt){return Nt.state==="ready"&&Nt.gcsUri&&Nt.fileId}).map(function(Nt){return{file_id:Nt.fileId,gcs_uri:Nt.gcsUri,mime:Nt.sniffedMime||Nt.mime||"application/octet-stream",name:Nt.name,size:Nt.size}}),vault_file_id:nr&&hn&&hn.id||null,ledger_entity_id:Sr||Io.current?(function(){try{return localStorage.getItem("xyron_ledger_entity")||null}catch{return null}})():null,ledger_handoff:Io.current?!0:void 0,active_drawer:jr?"room":void 0,drawer_context:Hd,room_id:jr&&t.roomId||void 0,room_context_version:jr&&t.roomContextVersion!=null?t.roomContextVersion:void 0}:{message:ce,session_id:Kf,project_id:t.project?t.project.id:void 0,messages:mt,system_prompt:Bc,cortex_enabled:!!kr,council_enabled:!!zo,council_mode:Ca,vault_file_id:nr&&hn&&(hn.id||hn.doc_id)||null,ledger_entity_id:Sr||Io.current?(function(){try{return localStorage.getItem("xyron_ledger_entity")||null}catch{return null}})():null,ledger_handoff:Io.current?!0:void 0}}function Gd(mt){if(!Ve){if(qo.current){Ei();return}if(xe.current&&xe.current.shouldRejectDelta()){dt.roomStale=!0,xe.current.checkAndSupersede();return}Eo(),Ar(),ae(Ln.STREAMING,"delta"),xt.length===0&&(console.log("[Xyron Timing] first token received:",(performance.now()-gs).toFixed(0)+"ms after fetch"),sr()),Cr&&!eo&&(Cr=!1,oe("")),xt+=mt,Dn&&Sn()}}function y0(mt){if(!Ve){if(qo.current){Ei();return}Eo(),Ar(),ae(Ln.THINKING,"event");try{if(OA(mt)){Cd(function(Or){return fv(Or,mt)});return}if(mt.type==="classification")dt.classification=mt,ve(function(Or){return{mode:mt.mode||null,provider:mt.provider||null,reason:mt.auto_provider_reason||null,profile:mt.latency_profile||null,privateHint:!!(Or&&Or.privateHint)}}),Dn=ob({enabled:ff(),latencyProfile:mt.latency_profile}),t.onEngineMode&&t.onEngineMode(mt.execution_mode,mt.symbols||[]);else if(mt.type==="engine_mode")t.onEngineMode&&t.onEngineMode(mt.header,mt.engines),j(function(Or){return Or.concat(["Engines: "+(mt.engines||[]).join(", ")+" — "+(mt.detected_mode||"auto")])});else if(mt.type==="fallback")j(function(Or){return Or.concat(["Provider fallback: "+mt.from+" → "+mt.to])});else if(mt.type==="validation")mt.status==="validated"&&(dt.validated=!0);else if(mt.type==="video_results")t.onVideoResults&&t.onVideoResults(mt.videos||null);else if(mt.type==="search_start")_(!0),M(!1),j(["Searching the web: "+(mt.query||"")]);else if(mt.type==="search_complete")j(function(Or){return Or.concat(["Found "+mt.citations+" sources"+(mt.images?" with "+mt.images+" images":"")])}),M(!0),_(!1);else if(mt.type==="search_failed")j(function(Or){return Or.concat(["Search failed: "+ea(mt.error||"unavailable")])}),M(!0),_(!1);else if(mt.type==="thinking_start")_(!0),M(!1),j([]);else if(mt.type==="thinking_step")j(function(Or){return Or.concat([mt.content])});else if(mt.type!=="cortex_round_start"){if(mt.type==="cortex_tool_call"){_(!0),M(!1);try{var Nt=mt.arguments&&Object.keys(mt.arguments).length?"("+JSON.stringify(mt.arguments)+")":"()",Pc="Cortex · "+String(mt.name||"?").replace(/^cortex_/,"")+Nt;j(function(Or){return Or.concat([Pc])})}catch{}}else if(mt.type==="cortex_tool_result"){try{var Uc=String(mt.name||"?").replace(/^cortex_/,""),Vd=mt.duration_ms!=null?mt.duration_ms+"ms":"?",Du=mt.ok?mt.error==="cached"?"cached":"ok":"error: "+(mt.error||"unknown"),iv="Cortex · "+Uc+" → "+Du+" · "+Vd;j(function(Or){return Or.concat([iv])})}catch{}try{var Am=mt.preview||"";if(Am&&Am.indexOf("requires_confirmation")!==-1){var qf=JSON.parse(Am);qf&&qf.requires_confirmation===!0&&Se({action:qf.action||String(mt.name||"").replace(/^cortex_/,""),tool:mt.name,payload:qf.would_execute||{},instructions:qf.instructions||"",receivedAt:Date.now()})}}catch{}}else if(mt.type==="tool_chart")try{try{var jm=mt.payload&&(mt.payload.symbol||mt.payload.ticker)||"";jm&&typeof jm=="string"&&(i0.current=jm.trim().toUpperCase())}catch{}var wm=mt.kind||"file",Xs=mt.payload||null;if(wm==="signal_card"&&Xs){var MC=Xs.coverage,NC=Xs.day_trade||{},BC=Xs.short_term||{},PC=Xs.long_term||{},UC=(NC.stance||"NO_SIGNAL")==="NO_SIGNAL"&&(BC.stance||"NO_SIGNAL")==="NO_SIGNAL"&&(PC.stance||"NO_SIGNAL")==="NO_SIGNAL";Xs.suppress_if_empty===!0&&MC!=="synth"&&UC?console.debug("[Xyron] suppressed empty predispatch signal_card for symbol",Xs.symbol):lr.push({kind:wm,title:mt.title||null,mime:mt.mime||null,data_b64:mt.data_b64||null,rows:mt.rows||null,payload:Xs,has_data:!!mt.has_data,tool_use_id:mt.tool_use_id||null})}else lr.push({kind:wm,title:mt.title||null,mime:mt.mime||null,data_b64:mt.data_b64||null,rows:mt.rows||null,payload:Xs,has_data:!!mt.has_data,tool_use_id:mt.tool_use_id||null})}catch{}else if(mt.type==="evidence_warning")try{var x0=Array.isArray(mt.hits)?mt.hits:[];if(x0.length>0){var WC=x0.map(function(Or){return Or.phrase}).join(", ");
515j(function(Or){return Or.concat(["⚠ Evidence rule: un-grounded phrase"+(x0.length===1?"":"s")+" — "+WC])}),console.warn("[Evidence Rule] violations:",x0)}}catch{}else if(mt.type==="thinking_done")M(!0),_(!1),N(mt.sources_loaded||0);else if(mt.type==="status"){if(Ve||Ta.current!==Ze)return;var Tm=kD(mt.message||"");if(Tm){var _m=ut.current;(!_m||_m.turnId!==Ze||_m.kind!==Tm)&&wt({turnId:Ze,kind:Tm,startedAt:Date.now(),phase:"generating"}),Cr&&!eo&&(Cr=!1,oe(""));return}var Rm=Hk(mt.message||"");Cr=!!Rm,eo=Rm.indexOf(Wk)===0,oe(Rm)}}}catch{}}}function km(mt){if(!Ve){var Nt=mt&&mt.evt||{};Nt.intelligences_used&&Nt.intelligences_used.length&&ve(function(Uc){return Object.assign({},Uc||{},{used:Nt.intelligences_used})}),Nt.usage&&(Qt=Nt.usage.input_tokens||0,un=Nt.usage.output_tokens||0),Ks&&(m6({room_id:Nt.room_id,room_context_version:Nt.room_context_version},Ks,Pt.current).stale&&(dt.roomStale=!0),dt.roomId=Nt.room_id||null,dt.roomContextVersion=Nt.room_context_version!=null?Nt.room_context_version:null,Nt.room_superseded&&(dt.roomStale=!0),Nt.room_persistence_failed&&(dt.roomPersistenceFailed=!0,s(function(Uc){return Uc.filter(function(Vd){return Vd.id!==ze})}),ni.current=F.slice(),qt.current&&(qt.current.innerHTML=""),gt(""),y("This Room turn could not be saved and was discarded. Please retry."))),Nt.persistence_failed&&!Nt.room_persistence_failed&&(dt.persistenceFailed=!0,y("This answer could not be saved to your history. Retry to 
515save a fresh copy."));var Pc=!!(Nt.latency&&Nt.latency.deadline_exceeded);if(Pc&&(dt.deadlineExceeded=!0),Nt.session_id&&(dt.roomStale&&jr||(Ne||jr?pl.current=Nt.session_id:Ui.current=Nt.session_id),t.onSessionCreated))try{t.onSessionCreated(Nt.session_id)}catch{}if(Nt.execution_mode&&(dt.executionMode=Nt.execution_mode),Nt.query_mode&&(dt.queryMode=Nt.query_mode),Nt.search&&(dt.searchData=Nt.search),Nt.web_search?dt.webSearch=Nt.web_search:Nt.web_search_fired&&(dt.webSearch={fired:!0}),Nt.memory_context&&(dt.memoryContext=Nt.memory_context),Nt.vault_sources&&(dt.vaultSources=Nt.vault_sources),Nt.validated&&(dt.validated=!0),Nt.context_header&&t.onEngineMode&&t.onEngineMode(Nt.context_header,Nt.engines_fired||[]),Nt.web_search_fired&&(dt.webSearchFired=!0),Nt.follow_ups&&Nt.follow_ups.length>0&&(dt.followUps=Nt.follow_ups),Nt.citations&&Nt.citations.length>0&&(dt.citations=Nt.citations),Nt.code_traces&&Nt.code_traces.length>0&&(dt.codeTraces=Nt.code_traces),Nt.thinking_trace&&(dt.thinkingTrace=Nt.thinking_trace),typeof Nt.cleaned_content=="string"&&(dt.cleanedContent=Nt.cleaned_content,dt.artifactCleaned=Nt.cleaned_content),Nt.artifacts&&Nt.artifacts.length>0&&(dt.artifacts=Nt.artifacts),Nt.route_decision_id&&(dt.routeDecisionId=Nt.route_decision_id),Pc){console.log("[Xyron Timing] response deadline exceeded:",(performance.now()-gs).toFixed(0)+"ms, chars:",xt.length),Wl(),ri("Response reached the time limit — partial answer shown. Retry to continue.");return}Ei()}}var Iu={max:1,attempts:0};function gl(){return!(Iu.attempts>=Iu.max||Ve||qo.current)}function Cm(mt){Iu.attempts+=1,yA().then(function(Nt){if(!(Ve||qo.current)){if(!Nt){ri("Authentication failed — please refresh");return}rv(mt())}}).catch(function(){!Ve&&!qo.current&&ri("Authentication failed — please refresh")})}function zC(mt,Nt,Pc,Uc){if(!Ve){var Vd=x6(Pc,Uc);if(Vd){if(dt.roomStale=!0,typeof t.onRoomAuthorityConflict=="function")try{t.onRoomAuthorityConflict(Vd.room)}catch{}ri(null),y(Vd.message);return}if(Pc===401&&gl()){Cm(Xf);return}var Du;Pc!=null?Du=ea(mt):Nt?Du=ea(mt||"Connection error"):Du=ea(mt||"Unknown"),ri(Du)}}function rv(mt){return ae(Ln.CONNECTING,"runStream"),Ry({url:Vf,method:"POST",headers:fo(),body:mt,signal:se.signal,onDelta:Gd,onEvent:y0,onDone:km,onError:zC})}return rv(ir)}).catch(function(Ur){Ve||(Ur.name==="AbortError"?ri(null):ri(Ur.message||"Connection error"))})}function Fx(){var u=ur;if(!(!u||u.drawer!=="ledger"||u.streaming||!u.text||!u.question)){var S={q:u.question,a:u.text,followUps:u.followUps||[],chartPng:u.chartPng||null};Dd(function(F){return F.concat([S])})}}function Gk(){var u=ur;if(!(!u||!u.drawer||u.drawer==="ledger"||u.streaming||!u.text||!u.question)){var S={q:u.question,a:u.text,artifact:u.artifact||null,followUps:u.followUps||[],routeDecisionId:u.routeDecisionId||null,ts:Date.now()};Od(function(F){return F.concat([S])})}}function Vk(u){var S=String(u||"").toLowerCase();return S.indexOf("search")>=0?"Searching the web…":S.indexOf("read")>=0||S.indexOf("source")>=0||S.indexOf("fetch")>=0?"Reading sources…":S.indexOf("code")>=0||S.indexOf("run")>=0?"Running code…":"Generating…"}(0,i.useEffect)(function(){function u(S){var F=S&&S.detail||{};F.prompt&&Si(F.prompt)}return window.addEventListener("xyron:ask-chat",u),function(){window.removeEventListener("xyron:ask-chat",u)}},[]);function yr(u,S,F){if(S==="calendar"){Gf(u);return}var G=(u||"").trim();if(!G||!S)return;try{oi({action:"query.executed",resource:t.project?"project:"+(t.project.name||t.project.id)+":drawer:"+S:"drawer:"+S,detail:G.substring(0,160)})}catch{}if(Xa.current)try{Xa.current.abort()}catch{}if(ps.current){try{ps.current()}catch{}ps.current=null}S==="ledger"?Fx():Gk();var ce=!1;S==="portfolio"&&!kr&&(ce=/(forecast|predict(?:ion)?s?|outlook|projection|expected return|\bsignals?\b|regime|catalysts?|\bcortex\b|trajectory|\btrend|bull(?:ish)?|bear(?:ish)?|upside|downside|momentum|directional|over-?valued|under-?valued|mispriced|fair value|cheap|expensive|price target|risk(?!-weighted)|sell-?off|drawdown|downturn|volatil|exposed to|hold up|red flags?|concentrat|over-?exp
515osed|aggressive|\brisky\b|worried|worry|worrying|concern|\bsafe\b|should i (?:buy|sell|hold|trim|add|hedge|rotate|overweight|underweight|reduce|cut|exit)|should i|buy or sell|time to (?:buy|sell|trim|rotate|exit|add)|good time to|when (?:should|to|do i|is it|would)|recommend|rebalanc|hedge|rotate out|overweight|underweight|\btrim\b|add to|take profits?|cut losses|worth (?:buying|selling|holding|keeping|adding|it)|analy[sz]e|\bassess|evaluate|thoughts?|\bview\b|opinion|what do you (?:think|make|reckon)|what about|how about|where(?:'?s| is| are| will| do you see).{0,30}(?:head|go|going|trade|move|end up)|headed|going to (?:do|go|move)|what.{0,20}think(?:s)? (?:about|of)|how ?(?:'?s|will|would|might|could|is|are).{0,40}(?:do|perform|fare|hold|react|move|play out|look|going)|\bodds\b|chances? (?:of|that|\w)|likelihood)/i.test(G)),_i({streaming:!0,text:"",err:"",question:G,drawer:S,citations:[],followUps:[],phase:"",cortexSuggest:ce}),Tu(function(sn){if(!sn[S])return sn;var Hn=Object.assign({},sn);return delete Hn[S],Hn});var ze=S==="room"?le()||{}:fs.current&&fs.current[S]||{},Ge=Ld.current[S]||null,se=S==="room"&&F?F:Ca,Ve=S==="room"?se!=="off":!!zo,Ze=new AbortController;if(Xa.current=Ze,S==="ledger"){var yt=null;try{yt=localStorage.getItem("xyron_ledger_entity")||null}catch{}var xt="",Qt=!1,un={},an=[],rr=Y2({lineAware:!0,reduceMotion:Ei(),transform:function(sn){return sn.replace(/<<<FOLLOW_UPS>>>[\s\S]*/g,"")},setText:function(sn){_i(function(Hn){return Object.assign({},Hn,{text:sn})})},onFinalize:function(sn){if(_i(function(Hn){return Object.assign({},Hn,{streaming:!1,text:sn,followUps:an})}),sn&&G&&fm("ledger",G,sn),Qt)try{window.dispatchEvent(new Event("xyron:ledger-refresh"))}catch{}}});ps.current=rr.cancel,cf.ledgerStream(G,Ld.current.ledger||null,yt,function(sn){xt+=sn||"",rr.push(sn||"")},function(){var sn=xt.replace(/<<<FOLLOW_UPS>>>[\s\S]*?<<<END_FOLLOW_UPS>>>/g,"").replace(/<<<FOLLOW_UPS>>>[\s\S]*/g,"").trim();an=[];try{var Hn=xt.match(/<<<FOLLOW_UPS>>>\s*(\[[\s\S]*?\])\s*<<<END_FOLLOW_UPS>>>/);if(Hn){var me=JSON.parse(Hn[1]);Array.isArray(me)&&(an=me.filter(function(Ot){return typeof Ot=="string"&&Ot.trim()}).slice(0,5))}}catch{}rr.finish(sn)},function(sn){rr.fail();var Hn=rr.received();_i(function(me){return Object.assign({},me,{streaming:!1,text:Hn||me.text,err:ea(sn&&sn.message||sn||"stream error")})})},function(sn){try{(sn||[]).forEach(function(Hn){if(Hn){var me=Hn.tool||Hn.name||"";if(Hn.type==="cortex_tool_call"&&me==="ledger_chart"&&(un=Hn.arguments||{}),Hn.type==="cortex_tool_result"&&Hn.ok!==!1&&/^ledger_/.test(me)&&(Qt=!0,me==="ledger_chart")){var Ot=un.entity_id||yt,Gt=un.kind||null;if(Ot&&Gt){var In={url:"/api/ledger/"+encodeURIComponent(Ot)+"/chart.png?kind="+encodeURIComponent(Gt)+(un.period?"&period="+encodeURIComponent(un.period):""),entityId:Ot,kind:Gt,period:un.period||null};_i(function(Mn){return Object.assign({},Mn,{chartPng:In})})}}}})}catch{}});return}var Pr={message:G,messages:[{role:"user",content:G}],session_id:Ge,provider:"auto",product:de==="xyron_legal"?"xyron_legal":de==="auto"?"auto":void 0,project_id:t.project?t.project.id:void 0,enable_web:Ai!=="off",enable_code:!1,enable_thinking:!1,council_enabled:!!Ve,council_mode:se,cortex_enabled:!!kr,active_drawer:S,drawer_context:ze},lr="",dt=null,Cr=null,eo=0,Dr=null,So=!1,Ar=!1,Pl=null,ri=ff();function Ei(){try{return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function Eo(){So=!1,Dr&&(clearTimeout(Dr),Dr=null)}function Ri(){return q0(lr).replace(/<<<FOLLOW_UPS>>>[\s\S]*?<<<END_FOLLOW_UPS>>>/g,"").replace(/<<<FOLLOW_UPS>>>[\s\S]*/g,"")}function ha(){Eo();var sn=Pl||{},Hn=(sn.clean!=null?sn.clean:Ri()).trim();_i(function(me){return Object.assign({},me,{streaming:!1,text:Hn||me.text,followUps:sn.followUps||[],artifact:dt||me.artifact||null})}),Hn&&G&&fm(S,G,Hn,dt||null)}function _a(){Dr=null;var sn=Ri();if(eo>=sn.length){if(Ar){ha();return}Dr=setTimeout(_a,30);return}var Hn=G2(eo);eo=V2(sn,eo,Hn.chunk,!1),_i(function(me){return Object.assign({},me,{text:sn.substring(0,eo)})}),Dr=setTimeout(_a,Hn.ms)}fetch(qr("/api/chat/general/stream"),{method:"POST",signal:Ze.signal,headers:Object.assign({"Content-Type":"application/json"},fo()),body:JSON.stringify(Pr)}).then(function(sn){if(!sn.ok)return sn.text().then(function(Mn){throw new Error("API "+sn.status+": "+(Mn||"").slice(0,200))});if(!sn.body)throw new Error("No response body");var Hn=sn.body.getReader(),me=new TextDecoder,Ot="",Gt=!1;function In(){return Hn.read().then(function(Mn){if(Mn.done){var Vt=(typeof Cr=="string"?Cr:q0(lr||"")).replace(/<<<FOLLOW_UPS>>>[\s\S]*?<<<END_FOLLOW_UPS>>>/g,"").replace(/<<<FOLLOW_UPS>>>[\s\S]*/g,"").trim(),fn=[];
515try{fn=Lu(lr||"",G)||[]}catch{}Pl={clean:Vt,followUps:fn},Ar=!0,(ri||!Gt||!So)&&ha();return}Ot+=me.decode(Mn.value,{stream:!0});var At=Ot.split(`
516`);Ot=At.pop()||"";for(var Dn=0;Dn<At.length;Dn++){var zt=At[Dn].trim();if(!(!zt||!zt.startsWith("data: "))){var ki=zt.slice(6).trim();if(!(!ki||ki==="[DONE]"))try{var Sn=JSON.parse(ki);if(Sn.type==="classification")ve(function(sr){return{mode:Sn.mode||null,provider:Sn.provider||null,reason:Sn.auto_provider_reason||null,profile:Sn.latency_profile||null,privateHint:!!(sr&&sr.privateHint)}}),ri=ob({enabled:ff(),latencyProfile:Sn.latency_profile});else if(Sn.type==="status"&&typeof Sn.message=="string"){var Ul=Vk(Sn.message);_i(function(sr){return Object.assign({},sr,{phase:Ul})})}else if(Sn.type==="delta"&&typeof Sn.content=="string")Gt=!0,lr+=Sn.content,Ei()?(eo=Ri().length,_i(function(sr){return Object.assign({},sr,{text:Ri()})})):ri?(eo=Ri().length,_i(function(sr){return Object.assign({},sr,{text:Ri()})})):So||(So=!0,ps.current=Eo,_a());else if(Sn.type==="done"){if(Sn.intelligences_used&&Sn.intelligences_used.length&&ve(function(sr){return Object.assign({},sr||{},{used:Sn.intelligences_used})}),Sn.session_id&&(Ld.current[S]=Sn.session_id),Sn.citations&&Sn.citations.length&&_i(function(sr){return Object.assign({},sr,{citations:Sn.citations})}),Sn.route_decision_id&&_i(function(sr){return Object.assign({},sr,{routeDecisionId:Sn.route_decision_id})}),Array.isArray(Sn.artifacts)&&Sn.artifacts.length>0){var Wl=Sn.artifacts.find(function(sr){return sr&&(sr.content||sr.url||sr.metadata&&sr.metadata.spec)})||Sn.artifacts[0];Wl&&(dt=Wl,_i(function(sr){return Object.assign({},sr,{artifact:Wl})}))}typeof Sn.cleaned_content=="string"&&(Cr=Sn.cleaned_content)}else Sn.type==="error"&&_i(function(sr){return Object.assign({},sr,{err:ea(Sn.message||"stream error")})})}catch{}}}return In()})}return In()}).catch(function(sn){if(Eo(),!(sn&&sn.name==="AbortError")){var Hn="";try{Hn=Ri()}catch{Hn=""}_i(function(me){return Object.assign({},me,{streaming:!1,text:Hn||me.text,err:ea(sn&&sn.message||"request failed")})})}}).finally(function(){Xa.current===Ze&&(Xa.current=null)})}Wo.current=yr,(0,i.useEffect)(function(){function u(S){if(t.roomSymbol){var F=S&&S.detail||{},G=typeof F.text=="string"?F.text.trim():"";if(G){if(F.councilMode){var ce=String(F.councilMode).toLowerCase();if(ce==="on"||ce==="auto"||ce==="off")try{Fc(ce)}catch{}}Si(G)}}}return window.addEventListener("xyron:room-strip-question",u),function(){window.removeEventListener("xyron:room-strip-question",u)}},[t.roomSymbol,t.roomContext,t.roomPromptSuggestions,yr]),(0,i.useEffect)(function(){return function(){if(Xa.current)try{Xa.current.abort()}catch{}if(ps.current)try{ps.current()}catch{}}},[]);function Md(){if(Yr&&(ro.reset(),Tc(null)),Xa.current)try{Xa.current.abort()}catch{}if(ps.current){try{ps.current()}catch{}ps.current=null}var u=ur.drawer;_i({streaming:!1,text:"",err:"",question:"",drawer:null,citations:[],followUps:[],phase:""}),Tu(function(S){var F=Object.assign({},S);return u&&(F[u]=!0),F})}function Yk(){if(Yr){ro.reset(),Tc(null);return}if(Xa.current)try{Xa.current.abort()}catch{}Ld.current.map=null,Ld.current.intel=null,Ld.current.room=null,Ld.current.realestate=null,Dd([]),Od([]),_i({streaming:!1,text:"",err:"",question:"",drawer:null,citations:[],phase:""})}function Nd(u){if(!u||!u.trim())return;var S=u.trim();Ll(S),Ir(!0),Bi("searching"),xo(""),kn(null),zl([]),Xo([]),ar([]),wd(0),Gs([]),_d($f()),Ml.current="";var F=null,G=[[/\b(?:fed|interest rate|monetary policy)\b/i,["What is the current federal funds rate?","How will rate cuts affect equity markets?","Fed balance sheet runoff timeline","Treasury yield curve analysis"]],[/\b(?:oil|opec|crude|petroleum|energy)\b/i,["Brent vs WTI spread outlook","OPEC+ compliance rates","Global oil demand forecast 2026","Energy sector ETF performance"]],[/\b(?:china|chinese|beijing)\b/i,["China GDP growth forecast","US-China trade tensions update","Chinese tech regulation impact","Yuan exchange rate outlook"]],[/\b(?:crypto|bitcoin|btc|ethereum)\b/i,["Bitcoin institutional adoption update","Crypto regulation outlook","Ethereum staking yield","DeFi total value locked"]],[/\b(?:ai|artificial intelligence|semiconductor|chip)\b/i,["NVIDIA earnings outlook","AI infrastru
516cture spending","Semiconductor supply chain update","Top AI stocks performance"]],[/\b(?:europe|ecb|euro|eu)\b/i,["ECB rate decision outlook","European inflation trajectory","Euro area PMI analysis","European bank stress tests"]],[/\b(?:gold|precious metal|silver)\b/i,["Gold price drivers 2026","Central bank gold reserves","Gold vs Treasury correlation","Mining sector outlook"]],[/\b(?:real estate|property|housing|reit)\b/i,["Commercial real estate outlook","Global housing market trends","REIT dividend yields","Cap rate compression analysis"]]];function ce(ze){for(var Ge=[],se=0;se<G.length;se++)G[se][0].test(ze)&&(Ge=Ge.concat(G[se][1]));return Ge.length===0&&(Ge=["Latest developments on "+S.split(" ").slice(0,4).join(" "),"Market impact analysis","Risk assessment outlook","Historical comparison"]),Ge.slice(0,4)}cf.searchStream(S,function(Ge,se){Ge==="start"?Bi("scanning"):Ge==="complete"?(Bi("synthesising"),wd(se.citations||0)):Ge==="sources"?(Gs(se.sources||[]),wd((se.sources||[]).length)):Ge==="images"?zl(se.images||[]):Ge==="council"?_d(function(Ve){return fv(Ve,se)}):Ge==="videos"?Xo(se.videos||[]):Ge==="failed"&&(F=ea(se.error||"try again."),Bi("idle"),Ir(!1),kn({query:S,text:"Search unavailable — "+F,sources:[],images:[]}))},function(Ge){Ml.current+=Ge,xo(Ml.current),Bi("streaming")},function(Ge){var se=Ml.current,Ve=[],Ze=se.match(/<<<FOLLOW_UPS>>>([\s\S]*?)<<<END_FOLLOW_UPS>>>/);if(Ze)try{Ve=JSON.parse(Ze[1].trim())}catch{}var yt=se.replace(/<<<FOLLOW_UPS>>>[\s\S]*?<<<END_FOLLOW_UPS>>>/g,"").replace(/<<<FOLLOW_UPS>>>[\s\S]*/g,"").trim();if(!yt){kn({query:S,text:"Search unavailable — "+(F||"no answer was generated. Try again."),sources:[],images:[]}),Ir(!1),Bi("idle");return}var xt=Ge.search||{},Qt=xt.citations||[],un=xt.images||[],an=xt.sources&&xt.sources.length?xt.sources:[];zl(un),an.length&&Gs(an),xt.videos&&xt.videos.length&&Xo(xt.videos),kn({query:S,text:yt,sources:Qt,images:un}),Ir(!1),Bi("done"),xo(""),Ml.current="";var rr=xt.follow_ups&&xt.follow_ups.length?xt.follow_ups.slice(0,4):Ve&&Ve.length>0?Ve.slice(0,6):ce(S);ar(rr),Pn(function(Pr){var lr=[{query:S,timestamp:Date.now(),text:yt,sources:an.length?an:[],images:un||[],videos:xt.videos&&xt.videos.length?xt.videos:[],followUps:rr||[]}].concat(Pr.filter(function(dt){return dt.query!==S}));lr=lr.slice(0,20);try{localStorage.setItem("xyron_search_hist",JSON.stringify(lr))}catch{}return lr})},function(Ge){Ir(!1),Bi("idle"),kn({query:S,text:"Search failed — "+ea(Ge||"try again."),sources:[],images:[]})},Lc?"pro":"fast",Ca)}function Kk(u){if(u){if(!u.text){Nd(u.query);return}Ll(u.query),Ir(!1),Bi("done"),xo(""),Ml.current="",Gs(Array.isArray(u.sources)?u.sources:[]),zl(Array.isArray(u.images)?u.images:[]),Xo(Array.isArray(u.videos)?u.videos:[]),ar(Array.isArray(u.followUps)?u.followUps:[]),wd(Array.isArray(u.sources)?u.sources.length:0),_d($f()),kn({query:u.query,text:u.text,sources:Array.isArray(u.sources)?u.sources:[],images:Array.isArray(u.images)?u.images:[]})}}function Ix(u){return(u||[]).some(function(S){return S&&S.isImage&&(S.state==="pending"||S.state==="uploading")})}function Dx(u){var S=String(u||"").toLowerCase().trim();return!S||S.length>120?!1:!!(/^(?:find|show(?:\s+me)?|search(?:\s+for)?|get|watch|play)\b[\s\S]{0,80}\bvideos?\b/.test(S)||/\bvideos?\s+(?:of|about|on|for)\s+\S/.test(S)||/\bvideos\s*[?.!]*$/.test(S)&&S.split(/\s+/).length<=8)}function Wf(u){var S=String(u||"").trim();if(S&&(ud(S),!dr)){var F="u"+Date.now()+Math.random(),G=new Date().toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});s(function(ze){return ze.concat([{id:F,role:"user",text:S,ts:G}])});var ce="a"+Date.now()+Math.random();cD(S).then(function(ze){var Ge=(ze||[]).filter(function(se){return se&&se.url});s(function(se){return se.concat([Ge.length>0?{id:ce,role:"assistant",text:"▶ Video intelligence — results for “"
516+S+"”:",videoIntel:Ge,ts:G}:{id:ce,role:"assistant",text:(function(){var Ve=(S||"").toLowerCase(),Ze=Ve.indexOf("nvda")>=0||Ve.indexOf("nvidia")>=0?"“NVIDIA Blackwell demand WSJ” or “Jensen Huang interview CNBC”":Ve.indexOf("aapl")>=0||Ve.indexOf("apple")>=0?"“Apple earnings call replay” or “Tim Cook interview Bloomberg”":"“<company> earnings Bloomberg” or “<company> CEO interview CNBC”";return"No professional market videos found in this pull for “"+S+"”. Try "+Ze+"."})(),ts:G}])})}).catch(function(){s(function(ze){return ze.concat([{id:ce,role:"assistant",text:"Video search is unavailable right now — the video service could not be reached. Try again shortly.",ts:G}])})})}}function Si(u,S,F){try{var G=/(?:private|confidential)\s+(?:map\s+)?look\s*[- ]?ups?\b|(?:do\s+not|don'?t|never|avoid(?:ing)?|without|no|not)\s+(?:use\s+|using\s+)?google\b|\boff[- ]google\b/i.test(String(u||""));ve(function(Vt){return Object.assign({},Vt||{},{privateHint:G})})}catch{}var ce=(u!=null?String(u):An.current).trim();if(ce){if(f&&!F&&vx("superseded"),!F&&Ix(fi)){y("Image still uploading — please resend in a moment.");return}Re(!1),console.log("[SAFE] doSend entered:",ce.substring(0,60));try{oi({action:"query.executed",resource:t.roomSymbol?"room:"+t.roomSymbol:t.project?"project:"+(t.project.name||t.project.id):"chat",detail:ce.substring(0,160)})}catch{}var ze=fi.slice();p(""),An.current="",h(!0),y(""),no([]),Ta.current=lF(),ae(Ln.WAITING,"send"),_(!1),M(!1),j([]),wt(null),Id.current=!0;var Ge="u"+Date.now()+Math.random(),se="a"+(Date.now()+1)+Math.random(),Ve=ce.toLowerCase();$o.current&&clearTimeout($o.current);var Ze=Ta.current;$o.current=setTimeout(function(){Ta.current===Ze&&(console.log("[SAFE] force release 120s"),$o.current=null,h(!1))},12e4);var yt={id:Ge,role:"user",text:ce,ts:new Date().toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})};ze.length>0&&(yt.attachments=ze.map(function(Vt){return{name:Vt.name,isImage:!!Vt.isImage,isPDF:!!Vt.isPDF}}));try{if(s(function(Vt){return Vt.concat([yt])}),!S){var xt=ni.current.slice();xt.push({role:"user",content:ce}),xt.length>12&&(xt=xt.slice(-12)),ni.current=xt}var Qt={aapl:"AAPL",apple:"AAPL",nvda:"NVDA",nvidia:"NVDA",msft:"MSFT",microsoft:"MSFT",googl:"GOOGL",google:"GOOGL",amzn:"AMZN",amazon:"AMZN",tsla:"TSLA",tesla:"TSLA",meta:"META",jpm:"JPM",btc:"BTC/USD",bitcoin:"BTC/USD",eth:"ETH/USD",ethereum:"ETH/USD",gold:"XAU/USD",silver:"XAG/USD",oil:"USOIL",brent:"UKOIL",spy:"SPY",qqq:"QQQ",iwm:"IWM",dxy:"DXY",eur:"EUR/USD",gbp:"GBP/USD",jpy:"USD/JPY",usd:"DXY",gld:"XAU/USD"};(function(){var fn="";Object.keys(Qt).forEach(function(At){fn||new RegExp("\\b"+At+"\\b","i").test(Ve)&&(fn=Qt[At])}),!fn&&t.roomSymbol&&(fn=String(t.roomSymbol).toUpperCase()),fn&&(i0.current=fn,console.log("[StickyAsset] updated lastSymbolRef →",fn,"from:",Ve.substring(0,60)))})(),console.log("[SAFE] routing — chat + chart only, all retrieval disabled");var un=Ve.trim(),an=!1;try{an=xb(ce)}catch{an=!1}var rr=/^(chart|plot|graph|draw|visuali[sz]e|candle|candlestick)\b/.test(un)||/\b(show|display|draw|plot|graph|pull up|bring up|give me|open|build|make|create|generate)\b[^?]*\b(chart|graph|candle|candlestick|price action)\b/.test(un)||/^(chart|plot|graph)\s+(of|for)\b/.test(un),Pr=/\bshow\b/.test(un)&&/\b(allocation|performance|trend|yield|nav|portfolio|risk|gold|price)\b/.test(un),lr=/\b(chart|graph|plot|candle|candlestick)s?\b/i.test(un),dt="";Object.keys(Qt).forEach(function(Vt){dt||new RegExp("\\b"+Vt+"\\b","i").test(Ve)&&(dt=Qt[Vt])});var Cr=/^(what|why|how|when|which|does|do|is|are|can|could|should|explain|describe|tell me)\b/.test(un)||/\?\s*$/.test(un)||/\b(explain|describe|interpret|read|understand|what does)\b[^?]*\b(chart|graph|plot)\b/.test(un),eo=!!(rr||Pr||lr&&dt&&!an&&!Cr),Dr="";if(eo&&(dt&&(Dr=dt),!Dr&&i0.current&&(Dr=i0.current,console.log("[StickyAsset] chart intent inherited symbol:",Dr)),!Dr&&t.roomSymbol&&(Dr=String(t.roomSymbol).toUpperCase(),console.log("[Room] chart intent inherited room symbol:",Dr)),Dr||console.log("[Chart] no symbol in scope — falling through to normal send (SPY default removed)")),console.log("[Route] chart intent:",eo,"| genChart:",an,"| symbol:",Dr||"(none)","| demo:",su(),"| text:",Ve.substring(0,80)),!Kt&&eo&&!an&&Dr){var So={type:"candle",title:Dr+" — 9
5160 Day",xLabel:"Date",yLabel:"Price",data:[],symbol:Dr},Ar=Dr+" — live 90-day chart.",Pl=[];try{Pl=Lu(Ar,ce)}catch{Pl=["Show signal card","Compare to SPY","Run portfolio impact","Switch to 1-day"]}var ri={id:se,role:"assistant",text:Ar,chart:So,followUps:Pl,ts:new Date().toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"}),modelLabel:"Chart"};try{console.log("[Chart/live] appending",Dr),s(function(Vt){return Vt.concat([ri])}),ni.current=ni.current.concat([{role:"assistant",content:Ar}])}catch(Vt){console.error("[Chart/live] error:",Vt)}finally{clearTimeout($o.current),h(!1)}return}if(!Kt&&eo&&!an&&su()){var Ei="bar",Eo="Portfolio by Asset Class ($M)",Ri="Asset Class",ha="Value ($M)",_a=[{label:"Equities",value:289.6},{label:"PE/Alts",value:243.2},{label:"Fixed Income",value:189.8},{label:"Real Assets",value:72},{label:"Cash",value:52.5}],sn="**Total NAV: $847.3M** — Portfolio weighted towards growth assets. Equities at 34.2% overweight vs 30% target.";Ve.match(/allocation|target|asset class|breakdown|rebalanc|pie/)?(Ei="pie",Eo="Portfolio Asset Allocation",Ri="Asset Class",ha="% of NAV",_a=[{label:"Equities",value:34.2},{label:"PE/Alts",value:28.7},{label:"Fixed Income",value:22.4},{label:"Real Assets",value:8.5},{label:"Cash",value:6.2}],sn="**Portfolio NAV: $847.3M** — Equities overweight at 34.2% vs 30% target."):Ve.match(/nav|performance|return|12.month/)?(Ei="area",Eo="Portfolio NAV — 12 Month",Ri="Month",ha="NAV ($M)",_a=[{label:"Apr'25",value:798},{label:"Jun'25",value:805},{label:"Aug'25",value:834},{label:"Oct'25",value:841},{label:"Dec'25",value:849},{label:"Feb'26",value:843},{label:"Mar'26",value:847}],sn="**12-month return: +6.2%** — Outperformed benchmark by 140bps."):Ve.match(/real estate|property|yield/)?(Ei="bar",Eo="Real Estate Yield by Asset",Ri="Property",ha="Yield (%)",_a=[{label:"Mayfair",value:3.2},{label:"City of London",value:4.8},{label:"Munich",value:5.4},{label:"Rotterdam",value:5.1},{label:"Paris",value:4.2}],sn="**Weighted average yield: 4.1%** — Munich and Rotterdam outperforming."):Ve.match(/risk|score/)?(Ei="line",Eo="Composite Risk Score — 30 Days",Ri="Day",ha="Score",_a=[{label:"D-30",value:58},{label:"D-25",value:61},{label:"D-20",value:65},{label:"D-15",value:64},{label:"D-10",value:70},{label:"D-5",value:69},{label:"Today",value:72}],sn="**Current: 72/100 (HIGH)** — Risk elevated by USDJPY conflict."):Ve.match(/gold|commodit/)&&(Ei="line",Eo="Gold Spot Price ($/oz)",Ri="Month",ha="Price ($)",_a=[{label:"Oct'25",value:2680},{label:"Nov'25",value:2740},{label:"Dec'25",value:2815},{label:"Jan'26",value:2890},{label:"Feb'26",value:2965},{label:"Mar'26",value:3087}],sn="**Gold +15.2% over 6 months.** Safe-haven bid on central bank buying."),console.log("[Chart/demo] selected:",Ei,"/",Eo);var Hn={type:Ei,title:Eo,xLabel:Ri,yLabel:ha,data:_a},me=[];try{me=Lu(sn,ce)}catch{me=["Tell me more","Generate a report"]}var Ot={id:se,role:"assistant",text:sn,chart:Hn,followUps:me,ts:new Date().toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"}),modelLabel:"Chart"};try{s(function(Vt){return Vt.concat([Ot])}),ni.current=ni.current.concat([{role:"assistant",content:sn}])}catch(Vt){console.error("[Chart/demo] error:",Vt)}finally{clearTimeout($o.current),h(!1)}return}var Gt=null;if(Ve.match(/\b(price|quote)\b/)||Ve.match(/\bhow much is\b/)?Gt="quote":Ve.includes("video")?Gt="video":Ve.includes("image")||Ve.includes("photo")||Ve.includes("picture")?Gt="image":Ve.match(/\b(market|markets)\b/)&&Ve.match(/\b(news|happened|moves|today|this week)\b/)?Gt="marketNews":Ve.match(/\b(latest|news|today|current|recent|update)\b/)&&Ve.length<200&&(Gt="search"),Gt&&an&&(console.log("[Route] retrieval suppressed — generated-chart request wins precedence"),Gt=null),Kt&&(Gt=null),Gt){console.log("[Route] retrieval mode:",Gt,"| query:",Ve.substring(0,60)),XT({query:ce,mode:Gt}).then(function(Vt){if(console.log("["+Gt+"] controller result — ok:",Vt.ok,"| error:",Vt.error||"none"),Vt.ok&&Vt.data)console.log("["+Gt+"] success — rendering directly"),s(function(zt){return zt.concat([{id:se,role:"assistant",text:typeof Vt.data=="str
516ing"?Vt.data:JSON.stringify(Vt.data),followUps:Lu(typeof Vt.data=="string"?Vt.data:"",ce),ts:new Date().toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"}),modelLabel:"Live"}])}),clearTimeout($o.current),h(!1);else if(Gt==="quote"){console.log("[Quote] failed — showing error directly, LLM fallback blocked");var fn=`## Quote
517
518`+ea(Vt.error||"Live quote temporarily unavailable.");s(function(zt){return zt.concat([{id:se,role:"assistant",text:fn,followUps:["Check Twelve Data key in Settings","Try a different symbol"],ts:new Date().toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"}),modelLabel:"Live"}])}),clearTimeout($o.current),h(!1)}else{console.log("[Route] mode disabled/failed:",Vt.error||"unknown","→ LLM");var At={model:Dm,label:"Standard",tier:"standard"};try{At=Tx(ce,{attachments:ze,savedDocs:t.savedDocs,project:t.project})}catch{}var Dn=ce;try{Dn=_x(ce,ze)}catch{}Rx(Dn,At,ni.current.slice(0,-1),se,ce,Ge)}}).catch(function(Vt){console.log("[Route] controller catch:",Vt&&Vt.message?Vt.message:Vt),
518clearTimeout($o.current),h(!1)});return}console.log("[Route] → Cortex LLM streaming");var In={model:Dm,label:"Standard",tier:"standard"};try{In=Tx(ce,{attachments:ze,savedDocs:t.savedDocs,project:t.project})}catch{}var Mn=ce;try{Mn=_x(ce,ze)}catch{}Rx(Mn,In,ni.current.slice(0,-1),se,ce,Ge);return}catch(Vt){console.log("[SAFE] catch hit:",Vt&&Vt.message?Vt.message:Vt),clearTimeout($o.current),h(!1),y(ea(Vt&&Vt.message||"Response error"))}}}function Xk(u,S,F){if(h6(u)){try{oe("Context changed — response discarded.")}catch{}return}(!u.followUps||u.followUps.length===0)&&(u.followUps=Lu(u.text||"",F||""));var G=hT(u.text||"",F||"");G.length>0&&(u.actions=G);var ce=(u.text||"").substring(0,500);(G.some(function(Ze){return Ze.id==="generate_report"})||ce.match(/^##\s*(Executive Summary|Hedges|Commitments|Allocations|Risk Priorities|Recommended Actions)/m))&&(u.isReport=!0,u.reportTitle=(G.filter(function(Ze){return Ze.id==="generate_report"})[0]||{}).params&&G.filter(function(Ze){return Ze.id==="generate_report"})[0].params.title||F||"Xyron Report");var ze=null;if(s(function(Ze){var yt=Ze.concat([u]);return ze=yt,yt}),ni.current=S.concat([{role:"assistant",content:u.text||""}]),typeof t.onAssistantMessage=="function")try{t.onAssistantMessage(u._rawReply||u.text||"")}catch{}setTimeout(function(){if(t.onSaveSession&&ze){var Ze=ze.map(xD);t.onSaveSession(Ze,Ui.current||pl.current)}},0),be&&Qk(u.text||"",u.id),document.hidden&&ui("Xyron responded to your query");var Ge=/\b(video|videos|watch|youtube|clip|footage)\b/i.test(F||"")||dr,se=/\b(social|sentiment|twitter|\bx\b|geopolit|policy|opinion)\b/i.test(F||"");(Ge||se)&&Ok(F,u.text)&&(function(Ze,yt){Ge&&cf.videoIntent(yt).then(function(xt){xt&&xt.videos&&xt.videos.length>0&&s(function(Qt){return Qt.map(function(un){return un.id===Ze?Object.assign({},un,{videoIntel:xt.videos}):un})})}).catch(function(){}),se&&cf.socialIntent(yt).then(function(xt){var Qt=[],un=(yt||"").toUpperCase().match(/\b(NVDA|AAPL|MSFT|TSLA|AMZN|GOOGL|META|AMD|INTC|NFLX|JPM|GS|BTC|ETH)\b/);un&&(Qt=[un[1].toLowerCase(),{NVDA:"nvidia",AAPL:"apple",MSFT:"microsoft",TSLA:"tesla",AMZN:"amazon",GOOGL:"google",META:"meta",AMD:"amd",INTC:"intel",NFLX:"netflix",JPM:"jpmorgan",GS:"goldman",BTC:"bitcoin",ETH:"ethereum"}[un[1]]||""]);var an="";try{an=JSON.stringify(xt||{}).toLowerCase()}catch{an=""}var rr=Qt.length===0||Qt.some(function(Pr){return Pr&&an.indexOf(Pr)!==-1});xt&&xt.socialUseful&&rr&&s(function(Pr){return Pr.map(function(lr){return lr.id===Ze?Object.assign({},lr,{socialIntel:xt}):lr})})}).catch(function(){})})(u.id,F),pm.current+=1;var Ve=(F||"").trim();!(Ve.length<12&&/^(hi|hey|hello|yo|sup|thanks|thank you|ok|okay|yes|no|sure|gm|gn|cool|nice|great)\b/i.test(Ve))&&(pm.current===1||pm.current%3===0)&&setTimeout(function(){a5(F,u.text||"",function(Ze){Ze&&Ze.length>0&&(t.onMemoryUpdate&&t.onMemoryUpdate(Ze),t.project&&t.onProjectMemoryUpdate&&t.onProjectMemoryUpdate(Ze))})},1500)}function Bd(){if(qo.current=!0,Ka.current){try{Ka.current()}catch{}Ka.current=null}if(fl.current){try{fl.current.abort()}catch{}fl.current=null}Uf.current&&clearInterval(Uf.current),gt(""),h(!1),ae(Ln.STOPPING,"stop"),ae(Ln.STOPPED,"stop-done"),s(function(u){if(!u.length)return u;var S=u[u.length-1];return S&&S.role==="assistant"&&!S.text?u.slice(0,-1).concat([Object.assign({},S,{text:"[Generation stopped]",wasStopped:!0})]):S&&S.role==="assistant"?u.slice(0,-1).concat([Object.assign({},S,{wasStopped:!0})]):u})}(0,i.useEffect)(function(){if(!f)return;function u(S){S.key==="Escape"&&(S.preventDefault(),Bd())}return window.addEventListener("keydown",u),function(){window.removeEventListener("keydown",u)}},[f]),(0,i.useEffect)(function(){return function(){if(qo.current=!0,Ka.current){try{Ka.current()}catch{}Ka.current=null}if(fl.current){try{fl.current.abort()}catch{}fl.current=null}Ka.current!==null&&W0(Ta.current,"streamCleanupRef survived unmount"),fl.current!==null&&W0(Ta.current,"abortRef survived unmount")}},[]);function Ox(){if(!(l.length<2)){for(var u=null,S=l.length-1;S>=0;S--)if(l[S].role==="user"){u=l[S].text;break}u&&(f&&Bd(),s(function(F){return F.slice(0,-1)}),ni.current=ni.current.slice(0,-2),Si(u,!0,!0))}}function hm(u){var S=rt.indexOf(u)===-1?rt.concat([u]):rt.filter(function(F){return F!==u});jt(S);try{localStorage.setItem("xyron_pinned_msgs",JSON.stringify(S))}catch{}}function Lx(u,S){Me(function(F){return Object.assign({},F,{[u]:F[u]===S?null:S})})}function zx(u){u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),Si())}function qk(u){var S=u.clipboardData&&u.clipboardData.items;if(S){for(var F=0;F<S.length;F++)if(S[F].type.indexOf("image")!==-1){var G=S[F].getAsFile(),ce=new FileReader;ce.onload=function(ze){no(function(Ge){return Ge.concat([{id:"att-"+Date.now(),name:"pasted-image.png",size:G.size,type:"image/png",content:ze.target.result,isImage:!0}])})}
518,ce.readAsDataURL(G),u.preventDefault();break}}}function ym(){if(Al.current&&(cancelAnimationFrame(Al.current),Al.current=null),es.current&&(clearInterval(es.current),es.current=null),Ea.current){try{Ea.current.stop()}catch{}Ea.current=null}if(Pa.current){try{Pa.current.close()}catch{}Pa.current=null}Zl.current=null,Sa([]),$n(0)}function $k(){var u=Zl.current;if(!u)return;var S=new Uint8Array(u.frequencyBinCount);function F(){if(Zl.current){u.getByteFrequencyData(S);for(var G=[],ce=Math.max(1,Math.floor(S.length/24)),ze=0;ze<24;ze++){var Ge=S[ze*ce]||0;G.push(Math.max(3,Math.round(Ge/255*40)))}Sa(G),Al.current=requestAnimationFrame(F)}}F()}function Jk(){var u=!1;function S(){if(!(u||il.current.length===0)){u=!0;var G=new Blob(il.current.slice(),{type:rl.current&&rl.current.mimeType||"audio/webm"});if(G.size<500){u=!1;return}Xh.transcribe(G).then(function(ce){u=!1,ce.text&&(oa.current=ce.text,to(ce.text),p(ce.text))}).catch(function(){u=!1})}}var F=setInterval(function(){if(!Ea.current||Ea.current.stopped){clearInterval(F);return}S()},2e3);setTimeout(function(){!Ea.current||Ea.current.stopped||S()},1500),Ea.current={stopped:!1,interval:F,stop:function(){this.stopped=!0,clearInterval(F)}}}function Mx(){if(Et){rl.current&&rl.current.state==="recording"&&rl.current.stop();return}if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia){ui("Microphone not available in this browser");return}Mt(!0),$n(0),to(""),oa.current="",Sa([]),il.current=[],navigator.mediaDevices.getUserMedia({audio:!0}).then(function(u){try{var S=new(window.AudioContext||window.webkitAudioContext),F=S.createAnalyser();F.fftSize=64,F.smoothingTimeConstant=.7,S.createMediaStreamSource(u).connect(F),Pa.current=S,Zl.current=F,$k()}catch{}var G=Date.now();es.current=setInterval(function(){$n(Math.floor((Date.now()-G)/1e3))},1e3);var ce=MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":MediaRecorder.isTypeSupported("audio/mp4")?"audio/mp4":"",ze=ce?new MediaRecorder(u,{mimeType:ce}):new MediaRecorder(u);rl.current=ze,ze.ondataavailable=function(Ge){Ge.data.size>0&&il.current.push(Ge.data)},ze.onstop=function(){u.getTracks().forEach(function(se){se.stop()}),ym(),Mt(!1);var Ge=new Blob(il.current,{type:ce||ze.mimeType||"audio/webm"});if(Ge.size<100){ui("Recording too short");return}br(!0),Xh.transcribe(Ge).then(function(se){br(!1),se.text?(oa.current=se.text,to(se.text),p(se.text),ma.current&&ma.current.focus()):oa.current||ui(ea(se.error||"Transcription returned empty"))}).catch(function(){br(!1),oa.current||ui("Transcription failed")})},ze.onerror=function(){u.getTracks().forEach(function(Ge){Ge.stop()}),ym(),Mt(!1),ui("Recording error")},ze.start(1e3),Jk()}).catch(function(){Mt(!1),ym(),ui("Microphone access denied")})}function Qk(u,S){if(be){var F=S||"auto-"+Date.now();Lv(u,F,function(G){he(G?F:function(ce){return ce===F?null:ce})})}}function xm(u,S){!u||!S||Lv(u,S,function(F){he(F?S:function(G){return G===S?null:G})})}function Zk(){u5(),he(null)}function eC(){var u=!be;Wt(u);try{localStorage.setItem("xyron_tts",u?"1":"0")}catch{}}var tC=5,s0=200,nC={node_modules:!0,".git":!0,dist:!0,build:!0,".svn":!0,".hg":!0,__pycache__:!0,".next":!0,".cache":!0,".idea":!0,".vscode":!0};function Nx(u,S,F){return new Promise(function(G){if(!u){G();return}if(S>tC){G();return}if(u.isFile){u.file(function(Ge){if(F.length>=s0){G();return}try{Ge._relativePath=u.fullPath||"/"+u.name}catch{}F.push(Ge),G()},function(){G()});return}if(u.isDirectory){let Ge=function(){ce.readEntries(function(se){if(!se||se.length===0){for(var Ve=Promise.resolve(),Ze=0;Ze<ze.length;Ze++)(function(xt){Ve=Ve.then(function(){if(!(F.length>=s0))return Nx(xt,S+1,F)})})(ze[Ze]);Ve.then(G).catch(function(){G()});return}for(var yt=0;yt<se.length;yt++)ze.push(se[yt]);Ge()},function(){G()})};if(u.name&&nC[u.name]){G();return}var ce=u.createReader(),ze=[];Ge();return}G()})}function Bx(u){for(var S=Array.prototype.slice.call(u.dataTransfer&&u.dataTransfer.types||[]),F=0;F<S.length;F++)if(String(S[F]).indexOf("application/x-vault-")===0)return!1;return S.indexOf("Files")!==-1}function rC(u){Bx(u)&&(u.preventDefault(),yc(!0))}function iC(){yc(!1)}function oC(u){if(Bx(u)){u.preventDefault(),yc(!1);var S=u.dataTransfer||{},F=S.items;if(F&&F.length>0&&typeof F[0].webkitGetAsEntry=="function"){for(var G=[],ce=0;ce<F.length;ce++)try{var ze=F[ce].webkitGetAsEntry();ze&&G.push(ze)}catch{}if(G.length===0){var Ge=Array.from(S.files||[]);Ge.length&&c0(Ge);return}var se=[],Ve=Promise.resolve();G.forEach(function(yt){Ve=Ve.then(function(){return Nx(yt,0,se)})}),Ve.then(function(){if(se.length!==0){if(se.length>s0){_u("batch","Too many files in folder (max "+s0+")");return}c0(se)}}).catch(function(){var yt=Array.from(S.files||[]);yt.length&&c0(yt)});return}var Ze=Array.from(S.files||[]);Ze.length&&c0(Ze)}}function Px(u){!u||!u.length||lC(u)}function c0(u){Px(u)}function Ux(u){if(!(typeof t.onRoomFileDoc!="function"||!u||!u.name)&&!(u.state&&u.state!=="ready")){var S=typeof u.content=="string"&&u.content.indexOf("data:")!==0?u.content:"";t.onRoomFileDoc({id:u.id||"att-"+Date.now(),name:u.name,ext:(/\.([A-Za-z0-9]+)$/.exec(u.name||"")||[])[1]||"",kind:u.isImage?"IMAGE":u.isPDF?"DOC":"FILE",size:u.size||0,sizeLabel:"",source:"upload",addedAt:new Date().toISOString(),content:S,contentTruncated:!!u.truncated,fileId:u.fileId||void 0,gcsUri:u.gcsUri||void 0,sniffedMime:u.sniffedMime||u.mime||void 0,mime:u.sniffedMime||u.mime||void 0,uploadState:u.gcsUri||S?"ready":"metadata_only"})}}var d0=8e3,aC=5*1024*1024,Wx=500*1024*1024,Hx=50,Ys=(0,i.useRef)(new Map),Gx=(0,i.useRef)([]);(0,i.useEffect)(function(){Gx.current=fi},[fi]);function Nc(){return"att-"+Date.now()+"-"+Math.random().toString(36).slice(2,9)}function Pd(u){no(function(S){return S.concat([u])})}function qa(u,S){no(function(F){return F.map(function(G){return G.id===u?Object.assign({},G,S):G})})}function u0(u){for(var S=Gx.current||[],F=0;F<S.length;F++)if(S[F]&&S[F].id===u)return S[F];return null}function _u(u,S){Pd({id:Nc(),fileId:null,name:u||"file",size:0,mime:"",state:"failed",progress:0,error:S,gcsUri:null,sniffedMime:null,truncated:!1,isImage:!1,
518content:null,isError:!0})}async function Vx(u,S){var F=Array.prototype.slice.call(u||[]).filter(Boolean).slice(0,5);if(F.length){var G=null;try{G=localStorage.getItem("xyron_ledger_entity")||null}catch{}var ce="⇪ "+F.map(function(an){return an.name}).join(", ")+(S?" — "+S:"");if(Xa.current)try{Xa.current.abort()}catch{}if(Fx(),_i({streaming:!0,text:"",err:"",question:ce,drawer:"ledger",citations:[],followUps:[],phase:""}),Tu(function(an){if(!an.ledger)return an;var rr=Object.assign({},an);return delete rr.ledger,rr}),!G){_i(function(an){return Object.assign({},an,{streaming:!1,err:"No ledger entity selected - open the LEDGER panel and pick an entity first."})});return}var ze=await xi(()=>import("./apiBase-BqVXqfJu.js").then(an=>an.n),__vite__mapDeps([6,1])),Ge="";try{Ge=localStorage.getItem("xyron_jwt_token")||""}catch{}for(var se=[],Ve=!1,Ze=0;Ze<F.length;Ze++){var yt=F[Ze];_i(function(an){return Object.assign({},an,{text:(se.join(`
519`)+(se.length?`
520`:"")+"DROP & BILL - extracting "+yt.name+"…").trim()})});try{var xt=new FormData;xt.append("file",yt),S&&xt.append("note",S);var Qt=await(await fetch(ze.apiUrl(ze.API_BASE_URL+"/api/ledger-docbill/"+G+"/process"),{method:"POST",headers:{Authorization:"Bearer "+Ge},body:xt})).json();Qt.status==="posted"?(Ve=!0,se.push("✓ POSTED - "+(Qt.vendor&&Qt.vendor.name?Qt.vendor.name:"vendor")+" "+(Qt.total||"")+" "+(Qt.currency||"")+" · invoice "+(Qt.invoice_id||"").slice(0,8)+" · coded "+(Qt.coding&&Qt.coding.account_code||"?")+" ("+(Qt.coding&&Qt.coding.basis||"")+")"+(Qt.warnings&&Qt.warnings.length?" · warnings: "+Qt.warnings.join(", "):"")+(Qt.vault_file_id||Qt.archived?" · doc archived in vault":""))):Qt.status==="needs_review"?se.push("⚠ NEEDS REVIEW - "+yt.name+": extraction confidence below floor. Extracted: "+JSON.stringify(Qt.extracted||{}).slice(0,220)+" - refine via the ledger AR/AP tab."):Qt.status==="duplicate"?se.push("◌ DUPLICATE - "+yt.name+" was already billed ("+(Qt.invoice_id||"").slice(0,8)+")."):se.push("✕ "+yt.name+": "+ea((Qt.error||Qt.detail||"processing failed")+""))}catch(an){se.push("✕ "+yt.name+": "+ea(an&&an.message||"upload failed"))}}var un=se.join(`
521`);_i(function(an){return Object.assign({},an,{streaming:!1,text:un,followUps:["View open payables","Show recent journal entries","List all vendors"]})});try{fm("ledger",ce,un)}catch{}if(Ve)try{window.dispatchEvent(new Event("xyron:ledger-refresh"))}catch{}}}function lC(u){if(!(!u||!u.length)){if(Sr){Array.prototype.slice.call(u).filter(Boolean).slice(0,5).forEach(function(S){var F=Nc();Pf.current[F]=S,Pd({id:F,fileId:null,name:"⇪ BILL · "+S.name,size:S.size,mime:S.type||"",state:"ready",progress:100,error:null,gcsUri:null,sniffedMime:null,truncated:!1,isImage:!1,
521content:null,__ledgerBill:!0})});return}if(u.length>Hx){_u("batch","Too many files (max "+Hx+")");return}Array.prototype.forEach.call(u,function(S){if(S){if(S.size>Wx){_u(S.name,"File too large (max "+Wx/1024/1024+" MiB)");return}var F=S.type||"";if(F.indexOf("text/")===0&&S.size<=d0){var G=new FileReader;G.onload=function(Ve){var Ze=typeof Ve.target.result=="string"?Ve.target.result:"",yt=Nc();Pd({id:yt,fileId:null,name:S.name,size:S.size,mime:F,state:"ready",progress:100,error:null,gcsUri:null,sniffedMime:null,truncated:!1,isImage:!1,content:Ze}),Ux({id:yt,name:S.name,size:S.size,mime:F,state:"ready",content:Ze})},G.onerror=function(){_u(S.name,"Failed to read file")},G.readAsText(S);return}if(F.indexOf("text/")===0){var ce=new FileReader;ce.onload=function(Ve){var Ze=typeof Ve.target.result=="string"?Ve.target.result:"",yt=Nc();Ys.current.set(yt,S),Pd({id:yt,fileId:null,name:S.name,size:S.size,mime:F,state:"pending",progress:0,error:null,gcsUri:null,sniffedMime:null,truncated:Ze.length>d0,originalSize:Ze.length,isImage:!1,
521content:Ze.length>d0?Ze.substring(0,d0):Ze}),Hf(yt,S)},ce.onerror=function(){_u(S.name,"Failed to read file")},ce.readAsText(S);return}if(F.indexOf("image/")===0&&S.size<=aC){var ze=new FileReader;ze.onload=function(Ve){var Ze=Nc();Ys.current.set(Ze,S),Pd({id:Ze,fileId:null,name:S.name,size:S.size,mime:F,state:"pending",progress:0,error:null,gcsUri:null,sniffedMime:null,truncated:!1,isImage:!0,content:Ve.target.result}),Hf(Ze,S)},ze.onerror=function(){_u(S.name,"Failed to read image")},ze.readAsDataURL(S);return}if(F.indexOf("image/")===0){var Ge=Nc();Ys.current.set(Ge,S),Pd({id:Ge,fileId:null,name:S.name,size:S.size,mime:F,state:"pending",progress:0,error:null,gcsUri:null,sniffedMime:null,truncated:!1,isImage:!0,content:null}),Hf(Ge,S);return}var se=Nc();Ys.current.set(se,S),Pd({id:se,fileId:null,name:S.name,size:S.size,mime:F,state:"pending",progress:0,error:null,gcsUri:null,sniffedMime:null,truncated:!1,isImage:!1,content:null}),Hf(se,S)}})}}function Hf(u,S){K2({file:S,sessionId:pl&&pl.current||t.sessionId||Ui&&Ui.current||null,product:"xyron_gpt",onProgress:function(F){qa(u,{progress:F,state:"uploading"})},onStateChange:function(F,G){if(G=G||{},F==="uploading")qa(u,{state:"uploading",fileId:G.fileId||null});else if(F==="ready"){if(qa(u,{state:"ready",progress:100,fileId:G.fileId||null,gcsUri:G.gcsUri||null,sniffedMime:G.sniffedMime||null,isArchive:!!G.isArchive,isExpanded:G.isArchive&&Array.isArray(G.children)&&G.children.length<=5,childCount:Array.isArray(G.children)?G.children.length:0}),Ux(Object.assign({},u0(u)||{},{id:u,name:S&&S.name,size:S&&S.size,mime:S&&S.type,state:"ready",fileId:G.fileId||null,gcsUri:G.gcsUri||null,sniffedMime:G.sniffedMime||null})),G.isArchive&&Array.isArray(G.children)&&G.children.length>0){var ce=u;no(function(ze){var Ge=G.children.map(function(se){return{id:Nc(),fileId:se.file_id,name:se.file_name,size:se.size_bytes||0,mime:se.sniffed_mime||"",state:"ready",progress:100,error:null,gcsUri:se.gcs_uri||null,sniffedMime:se.sniffed_mime||null,truncated:!1,isImage:!1,
521content:null,parentId:ce,extractionPath:se.extraction_path||null}});return ze.concat(Ge)})}Ys.current.delete(u)}else F==="failed"&&qa(u,{state:"failed",error:ea(G.error||"Upload failed")})}}).catch(function(F){console.warn("[chat-upload] failed:",S&&S.name,F&&F.message)})}function sC(u){var S=Ys.current.get(u);if(!S){qa(u,{state:"failed",error:"Cannot retry — file reference lost"});return}qa(u,{state:"pending",progress:0,error:null}),Hf(u,S)}function Yx(u){Ys.current.delete(u),no(function(S){return S.filter(function(F){return F.id!==u})})}function cC(u){no(function(S){return S.map(function(F){return F.id!==u||F.savedToVault||F.savePending?F:Object.assign({},F,{savingToVault:!0,vaultName:F.vaultName!=null?F.vaultName:F.name||"",saveError:null})})})}function Kx(u){qa(u,{savingToVault:!1,saveError:null})}function dC(u,S){qa(u,{vaultName:S})}function Xx(u){var S=u0(u);if(!(!S||!S.fileId||!S.gcsUri)&&!(S.savedToVault||S.savePending)){var F=((S.vaultName!=null?S.vaultName:S.name)||"").trim();if(!F){qa(u,{saveError:"Name required"});return}qa(u,{savePending:!0,saveError:null}),TT({fileId:S.fileId,vaultFileName:F,tags:[]}).then(function(G){qa(u,{savingToVault:!1,savePending:!1,savedToVault:!0,vaultFileId:G&&G.vault_file_id?G.vault_file_id:null,vaultName:F})}).catch(function(G){console.warn("[chat-vault] Save failed:",G&&G.message),qa(u,{savePending:!1,saveError:G&&G.message||"Save failed"})})}}var qx=(0,i.useState)(null),Ud=qx[0],vm=qx[1];function uC(u){var S=u0(u);if(S){if(S.isImage&&S.content){vm({type:S.mime||"image/png",src:S.content,name:S.name||"preview"});return}S.fileId&&wT(S.fileId).then(function(F){vm({type:F.sniffed_mime||S.sniffedMime||S.mime||"",src:F.signed_url,name:F.file_name||S.name||"preview"})}).catch(function(F){ui("Preview unavailable"+(F&&F.message?": "+F.message:""))})}}function fC(u){var S=u0(u);S&&qa(u,{isExpanded:!S.isExpanded})}function pC(){Bf(!0)}function gC(){Bf(!1),t0(!0),hx(""),zc.length===0&&(wu(!0),gn.list().then(function(u){gx(u.documents||[]),wu(!1)}).catch(function(){wu(!1)}))}function $x(u){var S=u.content_preview||u.content||"",F={id:"att-vault-"+(u.doc_id||u.id||Date.now()),name:u.name||"Vault document",size:S.length,type:u.type||u.doc_type||"document",content:S.substring(0,8e3),isVault:!0,vaultId:u.doc_id||u.id};no(function(G){return G.concat([F])}),t0(!1)}function mC(){Bf(!1),cm.current&&cm.current.click()}function bm(){zc.length>0||ju||(wu(!0),gn.list().then(function(u){gx(u.documents||[]),wu(!1)}).catch(function(){wu(!1)}))}var Ru=(0,i.useMemo)(function(){if(!ga)return[];if(ga.kind==="slash"){var u=Array.isArray(Hl)?Hl.slice():[];return pT(ga.query,u)}return mT(ga.query,{symbol:t.roomSymbol,project:t.project,docs:zc,savedDocs:t.savedDocs})},[ga,zc,t.roomSymbol,t.project,t.savedDocs]);function hC(){Di(!1),Jr(!1),po(!1),Fo(!1),go(!1),Tn(!1),jl(null),vi(!1),Oi(!1),pi(!1),zi(!1),si(!1),Ji(!1),Go(!1),ca(!1),ho(!1),io(!1),oo(!1),gi(!1),Lo(!1),dl(!1),Fl(!1),Li(!1),ji(!1),Dd([]),Od([]),Ro(null),Md()}function yC(u){if(u==="palette"){try{window.dispatchEvent(new CustomEvent("xyron:open-palette"))}catch{}return}if(u==="new"||u==="clear"){f&&Bd(),s([]),ni.current=[],y(""),p(""),An.current="",no([]),Ui.current=null,pl.current=null,_n({input:0,output:0}),u==="new"&&t.onNewChat&&t.onNewChat();return}if(hC(),u==="search"){Di(!0),kn(null),Ir(!1);return}if(u==="intel"){Lo(!0);return}if(u==="video"){Jr(!0);return}if(u==="map"){vi(!0);return}if(u==="vault"){Oi(!0);return}if(u==="email"){zi(!0);return}if(u==="calendar"){si(!0);return}if(u==="command"){pi(!0);return}if(u==="portfolio"){po(!0);return}if(u==="scanner"){go(!0);return}if(u==="intelgraph"){Fo(!0);return}if(u==="eyes"){Tn(!0);return}if(u==="call"){Cn(function(){});return}if(u==="ledger"){ji(!0);return}if(u==="realestate"){Li(!0);return}if(u==="messenger"){Ji(!0);return}if(u==="brief"){ho(!0);return}if(u==="audit"){io(!0);return}if(u==="risk"){oo(!0);return}if(u==="cortex"){gi(!0);return}if(u==="actions"){dl(!0);return}if(u==="bundles"){Fl(!0);return}}function f0(u){requestAnimationFrame(function(){var S=ma.current;if(S){S.focus();try{S.setSelectionRange(u,u)}catch{}}})}function Sm(u,S){var F=sb(u,S);if(!F){Ya(null);return}Ya(function(G){var ce=G&&G.kind===F.kind&&G.index||0;return{kind:F.kind,query:F.query,start:F.start,index:ce}}),F.kind==="mention"&&bm()}function xC(u){var S=u.target.value;p(S),An.current=S,Sm(S,u.target.selectionStart)}function Jx(u){var S=u==="mention"?"@":"/",F=ma.current,G=F&&typeof F.selectionStart=="number"?F.selectionStart:d.length,ce=sb(d,G);if(ce&&ce.kind===u&&!ce.query){Ya({kind:u,query:"",start:ce.start,index:0}),u==="mention"&&bm(),F&&F.focus();return}var ze=d.slice(0,G),Ge=d.slice(G),se=ze.length>0&&!/\s$/.test(ze),Ve=(se?" ":"")+S,Ze=ze+Ve+Ge;p(Ze),An.current=Ze,Ya({kind:u,query:"",start:ze.length+(se?1:0),index:0}),u==="mention"&&bm(),f0(ze.length+Ve.length)}function Qx(u){if(!(!ga||!u)){var S=ga.kind,F=ga.start;if(S==="slash"){var G=oh(d,F,"");p(G.value),An.current=G.value,Ya(null),yC(u.id),f0(G.cursor);return}if(u.kind==="doc"&&u.doc){$x(u.doc);var ce=oh(d,F,"");p(ce.value),An.current=ce.value,Ya(null),f0(ce.cursor);return}var ze=oh(d,F,"@"+u.label+" ");p(ze.value),An.current=ze.value,Ya(null),f0(ze.cursor)}}function vC(u){return ga?u.key==="ArrowDown"?(u.preventDefault(),Ya(function(S){return S&&Object.assign({},S,{index:cb(S.index,1,Ru.length)})}),!0):u.key==="ArrowUp"?(u.preventDefault(),Ya(function(S){return S&&Object.assign({},S,{index:cb(S.index,-1,Ru.length)})}),!0):u.key==="Escape"?(u.preventDefault(),Ya(null),!0):u.key==="Enter"||u.key==="Tab"?(u.preventDefault(),Ru.length?Qx(Ru[ga.index]||Ru[0]):Ya(null),!0):!1:!1}function bC(){je(null)}
521function SC(){var u=new Date().toLocaleString(),S='<!DOCTYPE html><html><head><meta charset="UTF-8"><style>body{font-family:Arial,sans-serif;font-size:12px;color:#1a1a1a;max-width:800px;margin:0 auto;padding:20px}h2{color:#B8760A;border-bottom:2px solid #B8760A;padding-bottom:8px}.msg{margin:14px 0;padding:10px 14px;border-radius:6px;border:1px solid #e0e0e0}.user{background:#FFF8EE}.asst{background:#F8FFFE}.role{font-weight:700;font-size:10px;text-transform:uppercase;margin-bottom:4px}.user .role{color:#B8760A}.asst .role{color:#0D9488}.text{line-height:1.6}</style></head><body>';S+="<h2>"+Gn.short+' INTELLIGENCE</h2><p style="color:#666;font-size:11px">'+u+"</p>",S+=l.map(function(G){return'<div class="msg '+(G.role==="user"?"user":"asst")+'"><div class="role">'+(G.role==="user"?"Principal":Gn.name)+'</div><div class="text">'+G.text.replace(/\n/g,"<br/>").replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>")+"</div></div>"}).join(""),S+="</body></html>";var F=window.open("","_blank","width=900,height=700");F&&(F.document.write(S),F.document.close(),setTimeout(function(){F.print()},400))}function EC(){var u=Ui.current,S=window.location.href.split("?")[0]+(u?"?session="+u:"");try{navigator.clipboard.writeText(S),ui("🔗 Conversation link copied")}catch{ui("Session: "+(u||"save a message first"))}}function ui(u){kt(u),setTimeout(function(){kt(null)},3e3);try{window.Notification&&Notification.permission==="granted"&&document.hidden&&new Notification("Xyron",{body:u})}catch{}}function kC(u){b(u);try{localStorage.setItem("xyron_custom_instructions",u)}catch{}ui("✓ Custom instructions saved")}function CC(u){if(!u)return[];var S=u.lineage_id||u.id;if(!S)return[];for(var F=[],G=l.length-1;G>=0;G--){var ce=l[G],ze=ce&&ce.msgMetadata&&ce.msgMetadata.artifacts;if(!(!ze||!ze.length))for(var Ge=0;Ge<ze.length;Ge++){var se=ze[Ge];(se.lineage_id||se.id)===S&&F.push(se)}}return F.slice(0,5)}function AC(u,S){return ED({messageId:u,artifact:S,postArtifact:function(F,G){var ce="/api/chat/uploads/artifacts/"+encodeURIComponent(F)+"/"+encodeURIComponent(G)+"/save-to-vault",ze=Object.assign({"Content-Type":"application/json"},fo()||{});return fetch(qr(ce),{method:"POST",headers:ze,credentials:"include",body:JSON.stringify({})}).then(function(Ge){if(!Ge.ok){var se=new Error("save failed ("+Ge.status+")");throw se.status=Ge.status,se}return Ge.json()})},saveText:function(F,G,ce,ze){return gn.save(F,G,ce,ze)}})}function jC(u){try{u.preventDefault()}catch{}var S=u&&u.currentTarget&&u.currentTarget.parentElement,F=S?S.getBoundingClientRect().width:window.innerWidth;F<=0&&(F=window.innerWidth||800);var G=u.clientX,ce=parseFloat(String(mc||"50%"))||50;function ze(se){var Ve=ce-(se.clientX-G)/F*100;Ve<20&&(Ve=20),Ve>80&&(Ve=80),ts(Ve.toFixed(1)+"%")}function Ge(){window.removeEventListener("pointermove",ze),window.removeEventListener("pointerup",Ge)}window.addEventListener("pointermove",ze),window.addEventListener("pointerup",Ge)}function wC(u){var S=u||"";S=S.replace(/^#\s+[^\n]+\n*/m,"");var F=S.search(/^##\s/m);if(F>0){var G=S.substring(0,F).trim();G.length<200&&!G.match(/\|.*\|/)&&(S=S.substring(F))}return S=S.replace(/\n---+\s*\n(?:(?!\n##)[^\n]*\n?){0,5}$/i,""),S=S.replace(/\n\*{1,2}(Note|Disclaimer)[^*]*\*{1,2}\s*$/i,""),S.replace(/^\s+|\s+$/,"")}function Zx(u){var S=String(u&&u.text||"").trim(),F=u&&u.msgMetadata&&Array.isArray(u.msgMetadata.artifacts)?u.msgMetadata.artifacts:[],G=[];return S&&G.push(S),F.forEach(function(ce){if(!(!ce||typeof ce.content!="string")){var ze=String(ce.content).trim();if(ze){var Ge=String(ce.type||"markdown").toLowerCase();if(!(Ge==="image"||Ge==="chart"||Ge==="video")&&!(S&&(S===ze||S.indexOf(ze)!==-1))){var se=ce.title?String(ce.title).trim():"";G.push(se&&(!S||S.indexOf(se)===-1)?"## "+se+`
522
523`+ze:ze)}}}}),G.join(`
524
525`).trim()||S}function ev(u,S,F){var G=wC(F);u==="pdf"?(ui("Generating PDF..."),lv("pdf",S||"Xyron Report",G,function(){ui("PDF generation failed — downloaded Word version")})):(lv(u||"docx",S||"Xyron Report",G),ui("Downloading DOC..."))}function p0(u){Fn({_userText:u,_ts:Date.now()})}function Gf(u){var S=(u||"").trim();S&&(p(""),An.current="",Tu(function(F){return Object.assign({},F,{calendar:!1})}),ro.ask(S))}function TC(u){if(u.id==="run_stress_test"&&t.onShowStress)t.onShowStress();
525else if(u.id==="export_conversation"){var S=l.map(function(ce){return(ce.role==="user"?"PRINCIPAL: ":Gn.short+": ")+(ce.text||"")}).join(`
526
527`);try{navigator.clipboard.writeText(S),ui("Conversation copied")}catch{}}else if(u.id==="vault_search")Si("Search vault for: "+(u.params&&u.params.query||""));else if(u.id==="schedule_brief"&&t.onShowSettings)t.onShowSettings();else if(u.id==="send_email"||u.id==="save_draft"){var F=u.params||{},G={to:F.to||"",subject:F.subject||"",body:F.body||"",source:"chat"};u.id==="save_draft"?(Fj(G),ui("Saved to Email Drafts")):(Fn(G),Di(!1),Jr(!1),po(!1),Fo(!1),go(!1),Tn(!1),jl(null),vi(!1),Oi(!1),pi(!1),si(!1),Ji(!1),Go(!1),ca(!1),ho(!1),io(!1),oo(!1),gi(!1),Lo(!1),dl(!1),Fl(!1),Li(!1),ji(!1),Dd([]),Od([]),Ro(null),Md(),zi(!0))}else ui(u.label+" — ready for execution")}function _C(u,S){T(null);var F=l.findIndex(function(G){return G.id===u});if(F!==-1){if(Ix(fi)){y("Image still uploading — please resend in a moment.");return}la(function(G){var ce=G[u]||[];return Object.assign({},G,{[u]:ce.concat([{text:l[F].text,tail:l.slice(F+1)}])})}),s(l.slice(0,F)),ni.current=ni.current.slice(0,F),Si(S,!1)}}function RC(u){if(f){y("Stop generation before restoring a branch.");return}var S=ns[u]||[];if(S.length){var F=l.findIndex(function(se){return se.id===u});if(F!==-1){var G={text:l[F].text,tail:l.slice(F+1)},ce=S[S.length-1],ze=l.slice(0,F).concat([Object.assign({},l[F],{text:ce.text})],ce.tail||[]),Ge=S.slice(0,S.length-1).concat([G]);la(function(se){return Object.assign({},se,{[u]:Ge})}),s(ze),ni.current=ze.map(function(se){return{role:se.role==="user"?"user":"assistant",content:se.text||""}}).slice(-12)}}}function FC(u){n0.current=u.touches[0].clientX}function IC(u){if(n0.current!==null){var S=u.changedTouches[0].clientX-n0.current;n0.current=null,S>60&&t.onOpenSidebar&&t.onOpenSidebar(),S<-60&&t.onCloseSidebar&&t.onCloseSidebar()}}function DC(u){var S=new Date().toISOString().slice(0,10),F=l.map(function(Ge){return(Ge.role==="user"?"PRINCIPAL":Gn.short)+`
528`+Ge.text+`
529`}).join(`
530---
531
532`);if(u==="txt"){var G=document.createElement("a");G.href="data:text/plain;charset=utf-8,"+encodeURIComponent(Gn.short+` INTELLIGENCE
533`+S+`
534`+"=".repeat(60)+`
535
536`+F),G.download=Gn.name.toLowerCase()+"-chat-"+S+".txt",document.body.appendChild(G),G.click(),document.body.removeChild(G)}else if(u==="html"){var ce='<!DOCTYPE html><html><head><style>body{font-family:monospace;background:#06080D;color:#C9D1D9;padding:20px;max-width:800px;margin:0 auto}.user{color:#D4AF5C;font-weight:700}.asst{color:#3FB950}.msg{margin:12px 0;padding:10px;border:1px solid #1E2838;border-radius:6px}</style></head><body><h2 style="color:#D4AF5C">'+Gn.short+"</h2>"+l.map(function(Ge){return'<div class="msg"><div class="'+(Ge.role==="user"?"user":"asst")+'">'+(Ge.role==="user"?"PRINCIPAL":Gn.short)+"</div><p>"+Ge.text.replace(/\n/g,"<br/>")+"</p></div>"}).join("")+"</body></html>",ze=document.createElement("a");ze.href="data:text/html;charset=utf-8,"+encodeURIComponent(ce),ze.download=Gn.name.toLowerCase()+"-chat-"+S+".html",document.body.appendChild(ze),ze.click(),document.body.removeChild(ze)}else u==="print"&&SC()}var Wd=l.length>0,g0=!(typeof Gn<"u"&&Gn&&(Gn.short||"").toUpperCase().indexOf("ARENBERG")!==-1);(0,i.useEffect)(function(){We("auto"),ot("auto");try{localStorage.setItem("xyron_chat_mode","auto"),localStorage.setItem("xyron_general_provider","auto")}catch{}},[g0]),(0,i.useEffect)(function(){l.length||Re(!1)},[l.length]);var tv=Ue&&It.trim()?l.filter(function(u){return u.text&&u.text.toLowerCase().includes(It.toLowerCase())}):l,Rn=ft==="light"?{bg:"#F8F9FA",bg2:"#FFFFFF",border:"#E5E7EB",text:"#1F2937",dim:"#6B7280",amber:"#D97706"}
536:{bg:"#030609",bg2:"#05080D",border:"#111820",text:"#E6EDF3",dim:"#5A7090",amber:"#D4AF5C"},Bl=E0&&E0.avatar||{type:"letter",value:"X",bg:"linear-gradient(135deg,#D4AF5C,#9E7E35)",color:"#000",size:30,radius:8},bo=E0&&E0.badge||{font:n,color:Rn.amber,fontSize:10,fontWeight:700,letterSpacing:".1em",textTransform:"uppercase"},Em=ft==="light"&&bo.colorLight?bo.colorLight:bo.color;function m0(u){var S=u&&u.size||Bl.size||30,F={width:S,height:S,borderRadius:Bl.radius!=null?Bl.radius:8,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,overflow:"hidden",background:Bl.bg||"transparent",border:Bl.border||"none",padding:Bl.padding||0,boxSizing:"border-box",filter:Bl.glow?"drop-shadow(0 0 10px rgba(201,169,97,0.35))":"none"};return u&&u.style&&Object.assign(F,u.style),Bl.type==="image"?i.createElement("div",{style:F},i.createElement("img",{src:Bl.src,alt:Gn.short||"Assistant",draggable:!1,style:{width:"100%",height:"100%",objectFit:"contain",userSelect:"none",pointerEvents:"none"}})):i.createElement("div",{style:Object.assign({},F,{fontFamily:n,fontSize:S>24?12:10,fontWeight:700,color:Bl.color||"#000"})},Bl.value||"X")}function OC(u){if(u){var S='From Xyron Eyes: "'+String(u).trim()+`"
537
538`;if(p(S),An.current=S,ma&&ma.current)try{ma.current.focus()}catch{}}}return(0,e.jsxs)("div",{style:{flex:1,display:"flex",overflow:"hidden",position:"relative"},"data-intelgraph-capture-surface":"chat","data-project-id":t.project&&t.project.id||void 0,"data-project-name":t.project&&t.project.name||void 0,"data-session-id":t.sessionId||void 0,onDragOver:rC,onDragLeave:iC,onDrop:oC,onTouchStart:FC,onTouchEnd:IC,children:[fd&&(0,e.jsx)("div",{style:{position:"absolute",inset:0,background:"rgba(212,175,92,0.08)",border:"2px dashed #D4AF5C",borderRadius:8,zIndex:100,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none"},children:(0,e.jsx)("div",{style:{fontFamily:n,fontSize:14,color:"#D4AF5C",fontWeight:700,letterSpacing:".1em"},children:"⧉ DROP FILES HERE"})}),(0,e.jsxs)("div",{style:{flex:1,minWidth:0,minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden",background:Rn.bg,position:"relative"},children:[t.embedded&&Wd&&g0&&!Ce&&(0,e.jsx)("button",{type:"button",onClick:function(){Re(!0)},title:t.project?"Park this chat (messages kept) — Resume or start a new chat from the bar":"Back to TODAY dashboard — messages stay in this session","aria-label":t.project?"Park chat":"Back to dashboard",style:{position:"absolute",top:10,right:12,zIndex:25,width:28,height:28,display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0,background:"rgba(8,11,17,0.55)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",border:"1px solid rgba(212,175,92,0.22)",borderRadius:4,fontFamily:n,fontSize:15,lineHeight:1,color:"rgba(201,209,217,0.7)",cursor:"pointer",transition:"all 140ms ease"},onMouseEnter:function(u){u.currentTarget.style.background="rgba(212,175,92,0.12)",u.currentTarget.style.borderColor="rgba(212,175,92,0.5)",u.currentTarget.style.color="#D4AF5C"},onMouseLeave:function(u){u.currentTarget.style.background="rgba(8,11,17,0.55)",u.currentTarget.style.borderColor="rgba(212,175,92,0.22)",u.currentTarget.style.color="rgba(201,209,217,0.7)"},children:"×"}),Nf&&(0,e.jsx)("div",{style:{position:"absolute",top:12,left:"50%",transform:"translateX(-50%)",zIndex:200,background:"#0D1520",border:"1px solid rgba(212,175,92,0.3)",borderRadius:20,padding:"7px 18px",fontFamily:n,fontSize:10,color:"#D4AF5C",whiteSpace:"nowrap",boxShadow:"0 4px 20px rgba(0,0,0,0.6)",animation:"xfadein .2s ease"},children:Nf}),ct&&(0,e.jsxs)("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.85)",zIndex:150,display:"flex",flexDirection:"column"},children:[(0,e.jsxs)("div",{style:{padding:"10px 16px",background:"#07090E",borderBottom:"1px solid #1E2838",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[(0,e.jsxs)("div",{style:{fontFamily:n,fontSize:9,color:"#D4AF5C",fontWeight:700},children:["❏ ",ct.name]}),(0,e.jsx)("button",{onClick:bC,style:{background:"none",border:"none",color:"#5A7090",cursor:"pointer",fontSize:18},children:"×"})]}),(0,e.jsx)("div",{style:{flex:1,overflow:"hidden"},children:ct.type==="pdf"&&ct.dataUrl&&(0,e.jsx)("iframe",{src:ct.dataUrl,style:{width:"100%",height:"100%",border:"none"},title:ct.name})})]}),tt&&(0,e.jsxs)("div",{style:{position:"absolute",top:0,right:0,bottom:0,width:320,background:"#07090E",borderLeft:"1px solid #1E2838",zIndex:50,display:"flex",flexDirection:"column",boxShadow:"-8px 0 24px rgba(0,0,0,0.6)"},children:[(0,e.jsxs)("div",{style:{padding:"14px 16px",borderBottom:"1px solid #1E2838",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[(0,e.jsx)("div",{style:{fontFamily:n,fontSize:9,color:Rn.amber,fontWeight:700,letterSpacing:".12em"},children:"⚙ SETTINGS"}),(0,e.jsx)("button",{onClick:function(){Ae(!1)},style:{background:"none",border:"none",color:"#5A7090",cursor:"pointer",fontSize:16},children:"×"})]}),(0,e.jsxs)("div",{style:{flex:1,overflowY:"auto",padding:"14px 16px"},children:[(0,e.jsxs)("div",{style:{marginBottom:20},children:[(0,e.jsx)("div",{style:{fontFamily:n,fontSize:8,color:"#5A7090",letterSpacing:".12em",marginBottom:8},children:"AI MODEL"}),(0,e.jsxs)("div",{style:{padding:"10px 12px",background:"rgba(212,175,92,0.06)",border:"1px solid rgba(212,175,92,0.2)",borderRadius:8},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[(0,e.jsx)("div",{style:{width:8,height:8,borderRadius:"50%",background:"#D4AF5C",animation:"xpulse 1.5s infinite"}}),(0,e.jsxs)("span",{style:{fontFamily:n,fontSize:10,fontWeight:700,color:"#D4AF5C",letterSpacing:".08em"},children:[Gn.short," AUTO"]}),(0,e.jsx)("span",{style:{fontFamily:n,fontSize:7,color:"#3A4A5E",marginLeft:"auto",padding:"1px 6px",border:"1px solid #1E2838",borderRadius:8},children:"ACTIVE"})]}),(0,e.jsxs)("p",{style:{fontFamily:n,fontSize:8,color:"#5A7090",lineHeight:1.7,margin:"0 0 10px"},children:[Gn.name," automatically selects the optimal intelligence tier based on task complexity."]}),(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:5},children:(0,e.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",ga
538p:8,padding:"8px",background:"#060A14",border:"1px solid #1E2838",borderRadius:5},children:[(0,e.jsx)("span",{style:{fontSize:11,color:"#D4AF5C",flexShrink:0,marginTop:1},children:"◈"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:n,fontSize:8,fontWeight:700,color:"#D4AF5C",marginBottom:2},children:"ADAPTIVE INTELLIGENCE"}),(0,e.jsx)("div",{style:{fontFamily:n,fontSize:7,color:"#5A7090",lineHeight:1.6},children:"Xyron applies the appropriate speed, tools and analysis depth automatically."})]})]})})]})]}),(0,e.jsxs)("div",{style:{marginBottom:20},children:[(0,e.jsx)("div",{style:{fontFamily:n,fontSize:8,color:"#5A7090",letterSpacing:".12em",marginBottom:8},children:"THEME"}),(0,e.jsx)("div",{style:{display:"flex",gap:6},children:["dark","light"].map(function(u){return(0,e.jsx)("button",{onClick:function(){St(u);try{localStorage.setItem("xyron_theme",u)}catch{}zy({theme:u})},style:{flex:1,padding:"7px",background:ft===u?"rgba(212,175,92,0.08)":"transparent",border:"1px solid "+(ft===u?"rgba(212,175,92,0.25)":"#1E2838"),borderRadius:6,cursor:"pointer",fontFamily:n,fontSize:9,color:ft===u?Rn.amber:"#5A7090"},children:u.toUpperCase()},u)})})]}),(0,e.jsxs)("div",{style:{marginBottom:20},children:[(0,e.jsx)("div",{style:{fontFamily:n,fontSize:8,color:"#5A7090",letterSpacing:".12em",marginBottom:8},children:"SYSTEM PROMPT"}),(0,e.jsx)("textarea",{value:we,onChange:function(u){b(u.target.value)},rows:5,style:{width:"100%",background:"#0D1020",border:"1px solid #1E2838",borderRadius:6,padding:"8px 10px",color:"#C9D1D9",fontSize:11,resize:"vertical",outline:"none",boxSizing:"border-box",fontFamily:n},onFocus:function(u){u.target.style.borderColor="rgba(212,175,92,0.4)"},onBlur:function(u){u.target.style.borderColor="#1E2838"}}),(0,e.jsx)("button",{onClick:function(){kC(we)},style:{marginTop:6,width:"100%",padding:"6px",background:"rgba(212,175,92,0.06)",border:"1px solid rgba(212,175,92,0.2)",borderRadius:5,cursor:"pointer",fontFamily:n,fontSize:8,color:Rn.amber},children:"✓ Save for all chats"}),"            "]}),(0,e.jsxs)("div",{style:{marginBottom:20},children:[(0,e.jsx)("div",{style:{fontFamily:n,fontSize:8,color:"#5A7090",letterSpacing:".12em",marginBottom:8},children:"EXPORT & SHARE"}),(0,e.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[[["txt","TXT"],["html","HTML"],["print","PRINT"]].map(function(u){return(0,e.jsx)("button",{onClick:function(){DC(u[0])},style:{flex:"1 0 0",minWidth:52,padding:"7px",background:"transparent",border:"1px solid #1E2838",borderRadius:6,cursor:"pointer",fontFamily:n,fontSize:9,color:"#5A7090"},onMouseEnter:function(S){S.currentTarget.style.borderColor=Rn.amber,S.currentTarget.style.color=Rn.amber},onMouseLeave:function(S){S.currentTarget.style.borderColor="#1E2838",S.currentTarget.style.color="#5A7090"},children:u[1]},u[0])}),(0,e.jsx)("button",{onClick:EC,style:{flex:"1 0 0",minWidth:52,padding:"7px",background:"transparent",border:"1px solid #1E2838",borderRadius:6,cursor:"pointer",fontFamily:n,fontSize:9,color:"#5A7090"},onMouseEnter:function(u){u.currentTarget.style.borderColor=Rn.amber,u.currentTarget.style.color=Rn.amber},onMouseLeave:function(u){u.currentTarget.style.borderColor="#1E2838",u.currentTarget.style.color="#5A7090"},children:"⧉ SHARE"})]})]}),(0,e.jsxs)("div",{style:{marginBottom:20},children:[(0,e.jsx)("div",{style:{fontFamily:n,fontSize:8,color:"#5A7090",letterSpacing:".12em",marginBottom:8},children:"VOICE & ACCESSIBILITY"}),(0,e.jsxs)("button",{onClick:eC,style:{width:"100%",padding:"8px",background:be?"rgba(63,185,80,0.08)":"transparent",border:"1px solid "+(be?"rgba(63,185,80,0.3)":"#1E2838"),borderRadius:6,cursor:"pointer",fontFamily:n,fontSize:9,color:be?"#3FB950":"#5A7090",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,e.jsx)("span",{children:"🔊 Read responses aloud (TTS)"}),(0,e.jsx)("span",{style:{fontSize:8,padding:"1px 6px",background:be?"rgba(63,185,80,0.15)":"#0D1020",border:"1px solid "+(be?"rgba(63,185,80,0.3)":"#1E2838"),borderRadius:8},children:be?"ON":"OFF"})]}),be&&(0,e.jsx)("button",{onClick:Zk,style:{width:"100%",marginTop:5,padding:"6px",background:"transparent",border:"1px solid rgba(200,92,92,0.2)",borderRadius:5,cursor:"pointer",fontFamily:n,fontSize:8,color:"#C85C
5385C"},children:"■ Stop speaking"})]}),Wd&&(0,e.jsx)("button",{onClick:function(){s([]),ni.current=[],y(""),h(!1),Ui.current=null,pl.current=null,_n({input:0,output:0}),t.onNewChat&&t.onNewChat(),Ae(!1)},style:{width:"100%",padding:"8px",background:"rgba(200,92,92,0.06)",border:"1px solid rgba(200,92,92,0.2)",borderRadius:6,cursor:"pointer",fontFamily:n,fontSize:9,color:"#C85C5C"},children:"🗑 CLEAR CONVERSATION"})]})]}),t.embedded&&(0,e.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",padding:"4px 12px 0",flexShrink:0},children:(0,e.jsx)(sp,{compact:!0,chatMode:de,signal:_e,activeDrawer:li?"realestate":Qn?"map":kr?"portfolio":null,streaming:!!f})}),!t.embedded&&(0,e.jsxs)("div",{className:"xy-chat-header",style:{padding:"9px 16px",borderBottom:"1px solid "+Rn.border,background:Rn.bg2,display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0,zIndex:5},children:[(0,e.jsxs)("div",{className:"xy-chat-header-left",style:{display:"flex",alignItems:"center",gap:10,minWidth:0},children:[(0,e.jsx)("div",{style:{fontWeight:900,fontSize:15,color:Rn.amber,letterSpacing:"-.04em",flexShrink:0},children:"XYRON"}),(0,e.jsx)("div",{style:{width:1,height:12,background:Rn.border,flexShrink:0}}),(0,e.jsx)("span",{"data-testid":"mode-badge","data-chat-mode":g0?"auto":de,style:{display:"inline-flex",minWidth:0},children:(0,e.jsx)(sp,{compact:!0,chatMode:de,signal:_e,activeDrawer:li?"realestate":Qn?"map":kr?"portfolio":null,streaming:!!f})}),f&&(0,e.jsx)("div",{style:{display:"flex",gap:3,marginLeft:4},children:[0,1,2].map(function(u){return(0,e.jsx)("div",{style:{width:4,height:4,borderRadius:"50%",background:Rn.amber,animation:"xpulse "+(.5+u*.15)+"s infinite",animationDelay:u*.15+"s"}},u)})}),Wn.input+Wn.output>0&&(0,e.jsxs)("span",{style:{fontFamily:n,fontSize:7,color:"#3A4A5E",marginLeft:4},children:[((Wn.input+Wn.output)/1e3).toFixed(1),"K tok"]})]}),(0,e.jsxs)("div",{className:"xy-chat-header-right",style:{display:"flex",alignItems:"center",gap:6,flexShrink:0},children:[(0,e.jsx)("button",{onClick:function(){f&&Bd(),s([]),ni.current=[],y(""),p(""),no([]),Ui.current=null,pl.current=null,_n({input:0,output:0}),t.onNewChat&&t.onNewChat()},title:"New chat",style:{width:28,height:28,background:"transparent",border:"1px solid #2E4256",borderRadius:6,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"#A7BCD1",fontSize:18,lineHeight:1,fontWeight:400,transition:"all .15s"},onMouseEnter:function(u){u.currentTarget.style.borderColor="rgba(212,175,92,0.5)",u.currentTarget.style.color="#D4AF5C",u.currentTarget.style.background="rgba(212,175,92,0.08)"},onMouseLeave:function(u){u.currentTarget.style.borderColor="#2E4256",u.currentTarget.style.color="#A7BCD1",u.currentTarget.style.background="transparent"},children:"+"}),typeof t.onMinimizeChat=="function"&&(0,e.jsx)("button",{onClick:function(){f&&Bd(),typeof t.onMinimizeChat=="function"&&t.onMinimizeChat(),s([]),ni.current=[],y(""),p(""),no([]),Ui.current=null,pl.current=null,_n({input:0,output:0})},title:"Minimize this chat to the dock",style:{width:28,height:28,background:"transparent",border:"1px solid #2E4256",borderRadius:6,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"#A7BCD1",fontSize:18,lineHeight:1,fontWeight:400,transition:"all .15s"},onMouseEnter:function(u){u.currentTarget.style.borderColor="rgba(94,234,212,0.55)",u.currentTarget.style.color="#5EEAD4",u.currentTarget.style.background="rgba(56,189,168,0.08)"},onMouseLeave:function(u){u.currentTarget.style.borderColor="#2E4256",u.currentTarget.style.color="#A7BCD1",u.currentTarget.style.background="transparent"},children:"–"}),(0,e.jsx)("button",{onClick:function(){Ie(function(u){return!u}),Rt("")},style:{width:28,height:28,background:Ue?"rgba(212,175,92,0.1)":"transparent",border:"1px solid "+(Ue?"rgba(212,175,92,0.3)":"#1E2838"),borderRadius:6,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:Ue?Rn.amber:"#A7BCD1",fontSize:13},title:"Search chat",children:"⌕"}),rt.length>0&&(0,e.jsx)("button",{onClick:function(){Ie(!0),Rt("[pinned]")},style:{width:28,height:28,background:"transparent",border:"1px solid #1E2838",borderRadius:6,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"#D4AF5C",fontSize:11},title:"Pinned: "+rt.length,children:"📌"}),(function(){for(var u=null,S=l.length-1;S>=0&&!u;S--){var F=l[S]&&l[S].msgMetadata&&l[S].msgMetadata.artifacts;F&&F.length>0&&(u={messageId:l[S].id,artifact:F[0]})}if(!u&&!Xi)return null;var G=!!Xi;return(0,e.jsx)("button",{onClick:function(){G?Uo(null):u&&Uo(u)},style:{width:28,height:28,background:G?"rgba(212,175,92,0.1)":"transparent",border:"1px solid "+(G?"rgba(212,175,92,0.3)":"#1E2838"),borderRadius:6,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:G?Rn.amber:"#5A7090",fontSize:12},title:G?"Hide artifact panel":"Show artifact panel",children:"⧉"})})(),Wd&&!f&&(0,e.jsx)("button",{onClick:Ox,style:{width:28,height:28,background:"transparent",border:"1px solid #1E2838",borderRadius:6,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"#5A7090",fontSize:13},title:"Regenerate last response",onMouseEnter:function(u){u.currentTarget.style.color=Rn.amber},onMouseLeave:function(u){u.currentTarget.style.color="#5A7090"},children:"↺"}),f&&(0,e.jsxs)("button",{onClick:Bd,title:"Stop generation (Esc)","aria-label":"Stop generation","data-testid":"stop-generation",style:{padding:"3px 10px",background:"rgba(200,92,92,0.18)",border:"1px solid rgba(200,92,92,0.45)",borderRadius:5,cursor:"pointer",fontFamily:n,fontSize:8,color:"#E07070",display:"flex",alignItems:"center",gap:4,fontWeight:700,letterSpacing:".1em"},children:[(0,e.jsx)("span",{style:{fontSize:8},children:"■"}),"STOP"]}),(0,e.jsx)("button",{onClick:function(){Ae(function(u){return!u})},style:{width:28,height:28,background:tt?"rgba(212,175,92,0.1)":"transparent",border:"1px solid "+(tt?"rgba(212,175,92,0.3)":"#1E2838"),borderRadius:6,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:tt?Rn.amber:"#A7BCD1",fontSize:14},title:"Settings",children:"⚙"}),Wd&&g0&&!Ce&&(0,e.jsx)("button",{type:"button",onClick:function(){Re(!0)},title:t.project?"Park this chat (messages kept) — Resume or start a new chat from the bar":"Back to TODAY dashboard — messages stay in this session","aria-label":t.project?"Park chat":"Back to dashboard",style:{width:28,height:28,background:"transparent",border:"1px solid #1E2838",borderRadius:6,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"#5A7090",fontSize:16,fontWeight:300,lineHeight:1,transition:"all .15s"},onMouseEnter:function(u){u.currentTarget.style.borderColor="rgba(212,175,92,0.35)",u.currentTarget.style.color="#D4AF5C",u.currentTarget.style.background="rgba(212,175,92,0.06)"},onMouseLeave:function(u){u.currentTarget.style.borderColor="#1E2838",u.currentTarget.style.color="#5A7090",u.currentTarget.style.background="transparent"},children:"×"})]})]}),Ue&&(0,e.jsxs)("div",{style:{padding:"8px 16px",borderBottom:"1px solid "+Rn.border,background:Rn.bg2,flexShrink:0,display:"flex",alignItems:"center",gap:8},children:[(0,e.jsx)("span",{style:{color:"#5A7090",fontSize:13},children:"⌕"}),(0,e.jsx)("input",{value:It,onChange:function(u){Rt(u.target.value)},placeholder:"Search messages…",autoFocus:!0,style:{flex:1,background:"transparent",border:"none",color:Rn.text,fontSize:12,outline:"none",fontFamily:n}}),It&&(0,e.jsxs)("span",{style:{fontFamily:n,fontSize:8,color:"#5A7090"},children:[tv.length," found"]}
538),(0,e.jsx)("button",{onClick:function(){Ie(!1),Rt("")},style:{background:"none",border:"none",color:"#5A7090",cursor:"pointer",fontSize:14},children:"×"})]}),v&&(0,e.jsxs)("div",{style:{padding:v.startsWith("AUTH_401:")?"10px 16px":"6px 16px",background:v.startsWith("AUTH_401:")?"rgba(212,175,92,0.08)":"rgba(200,92,92,0.08)",borderBottom:"1px solid "+(v.startsWith("AUTH_401:")?"rgba(212,175,92,0.25)":"rgba(200,92,92,0.2)"),fontFamily:n,fontSize:10,color:v.startsWith("AUTH_401:")?"#D4AF5C":"#C85C5C",display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[(0,e.jsx)("span",{style:{flex:1},children:v.startsWith("AUTH_401:")?"⚙ "+v.slice(9):"⚠ "+v}),v.startsWith("AUTH_401:")&&t.onShowSettings&&(0,e.jsx)("button",{onClick:function(){y(""),t.onShowSettings()},style:{padding:"3px 10px",background:"rgba(212,175,92,0.12)",border:"1px solid rgba(212,175,92,0.35)",borderRadius:4,cursor:"pointer",fontFamily:n,fontSize:9,color:"#D4AF5C",fontWeight:700,whiteSpace:"nowrap"},onMouseEnter:function(u){u.currentTarget.style.background="rgba(212,175,92,0.22)"},onMouseLeave:function(u){u.currentTarget.style.background="rgba(212,175,92,0.12)"},children:"Open Settings"}),(0,e.jsx)("button",{onClick:function(){y("")},style:{background:"none",border:"none",color:v.startsWith("AUTH_401:")?"#D4AF5C":"#C85C5C",cursor:"pointer",fontSize:13,flexShrink:0,padding:0},children:"×"})]}),(0,e.jsxs)("div",{ref:Vs,"data-xyron-chat-scroll":1,onScroll:Uk,style:{flex:1,overflowY:"auto",overflowX:"hidden",position:"relative"},children:[(0,e.jsx)("div",{style:{display:Gr||dr||Qn||nr||Er||Tr||Yr||Do||or||mo||yo||Oo||tr||qi||li||er||Qi||kr||Sr?"none":"block"},children:!Wd||Ce?(function(){var u=Ce&&Wd?(0,e.jsxs)("div",{style:{position:"sticky",top:0,zIndex:8,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"8px 16px",background:"rgba(6,8,13,0.96)",borderBottom:"1px solid rgba(212,175,92,0.14)",flexShrink:0,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"},children:[(0,e.jsxs)("span",{style:{fontFamily:n,fontSize:9,color:"#8B9AAF",letterSpacing:"0.12em"},children:["◆"," ",t.project?"PARKED CHAT":"ACTIVE CHAT"," — ",l.length," ",l.length===1?"message":"messages"," kept in this session"]}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[t.project&&typeof t.onNewChat=="function"?(0,e.jsx)("button",{type:"button",onClick:function(){Re(!1),t.onNewChat()},title:"Start a new chat in this project — current session stays in the CHATS list",style:{padding:"4px 12px",background:"rgba(212,175,92,0.08)",border:"1px solid rgba(212,175,92,0.35)",borderRadius:3,cursor:"pointer",fontFamily:n,fontSize:9,letterSpacing:"0.14em",color:"#D4AF5C",fontWeight:700,whiteSpace:"nowrap"},onMouseEnter:function(F){F.currentTarget.style.background="rgba(212,175,92,0.14)"},onMouseLeave:function(F){F.currentTarget.style.background="rgba(212,175,92,0.08)"},children:"+ NEW CHAT"}):null,(0,e.jsx)("button",{type:"button",onClick:function(){Re(!1)},title:"Return to this conversation",style:{padding:"4px 12px",background:"rgba(212,175,92,0.08)",border:"1px solid rgba(212,175,92,0.35)",borderRadius:3,cursor:"pointer",fontFamily:n,fontSize:9,letterSpacing:"0.14em",color:"#D4AF5C",fontWeight:700,whiteSpace:"nowrap"},onMouseEnter:function(F){F.currentTarget.style.background="rgba(212,175,92,0.14)"},onMouseLeave:function(F){F.currentTarget.style.background="rgba(212,175,92,0.08)"},children:"RESUME"})]})]}):null,S=t.embedded?null:i.createElement(JA,{showScope:!0,variant:"standalone",obsLimit:18,socLimit:10,maxObs:16,maxSoc:8});return typeof t.renderEmptyState=="function"?i.createElement(i.Fragment,null,u,S,t.renderEmptyState(Si)):t.embedded?i.createElement(i.Fragment,null,u,i.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:1,padding:"28px 20px",textAlign:"center",gap:14}},i.createElement("div",{style:{fontFamily:bo.font,fontSize:bo.fontSize||10,fontWeight:bo.fontWeight||500,color:Em,letterSpacing:bo.letterSpacing||".26em",textTransform:bo.textTransform||"uppercase"}},t.roomSymbol?Gn.short+" · "+t.roomSymbol+" ROOM":Gn.short+" · PILOT"),i.createElement("div",{style:{fontSize:15,color:Rn.text,fontWeight:500,letterSpacing:"-.01em"}},t.roomSymbol?"How can I help with "+t.roomSymbol+", Principal?":"How can I help, Principal?"),i.createElement("div",{style:{fontFamily:n,fontSize:9,color:Rn.dim,lineHeight:1.7,maxWidth:340}},t.roomSymbol?"This room is scoped to "+t.roomSymbol+" — ask about its price action, signals, news, intel, earnings or your exposure. Versatile: charts, peer comparisons, a document, or a brief.":"Aware of your current view. Ask about markets, the portfolio, the map, a document, or run a brief."))):i.createElement(i.Fragment,null,u,S,i.createElement(q4,{onPrompt:Si,workspace:t.workspace}))})():(0,e.jsxs)("div",{style:{maxWidth:760,margin:"0 auto",paddingBottom:16},children:[tv.map(function(u){var S=u.role==="user",F=rt.indexOf(u.id)!==-1,G=ne[u.id],ce=Z===u.id,ze=l.indexOf(u),Ge=lt&&(lt.id&&u.id===lt.id||lt.index!=null&&ze===lt.index)?"rgba(212,175,92,0.10)":F?"rgba(212,175,92,0.03)":"transparent";return!S&&u.chart?(0,e.jsxs)("div",{"data-chat-message-id":u.id,"data-role":"assistant",style:{borderBottom:"1px solid "+Rn.border,animation:"xfadein .2s ease",background:Ge},children:[u.text&&(0,e.jsxs)("div",{style:{display:"flex",gap:12,padding:"14px 16px 6px"},children:[(0,e.jsx)(m0,{style:{marginTop:2}}),(0,e.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:8,marginBottom:5,alignItems:"center"},children:[(0,e.jsx)("span",{style:{fontFamily:bo.font,fontWeight:bo.fontWeight||700,fontSize:bo.fontSize||10,color:Em,letterSpacing:bo.letterSpacing||".1em",textTransform:bo.textTransform||"uppercase"},children:Gn.short}),(0,e.jsx)("span",{style:{fontFamily:n,fontSize:7,color:Rn.dim},children:u.ts||""})]}),wx(u.text),k1(u.text).map(function(se,Ve){return(0,e.jsx)(Sy,{url:se.url,title:u.reportTitle||"",compact:!0,onOpen:aa},"ve"+Ve)})]})]}),(0,e.jsx)("div",{style:{padding:"0 10px 6px"},children:(0,e.jsx)(WS,{chart:u.chart})}),(0,e.jsx)(uy,{text:u.text||"",msgId:u.id,chart:u.chart,sessionId:t.sessionId,projectId:t.project&&t.project.id,projectName:t.project&&t.project.name,role:"assistant",artifact:u.msgMetadata&&Array.isArray(u.msgMetadata.artifacts)&&u.msgMetadata.artifacts.find(function(se){return se&&(se.content||se.url)})||null,onOpenArtifact:function(se){Uo({messageId:u.id,artifact:se})}}),u.role==="assistant"&&u.routeDecisionId&&(0,e.jsx)(H2,{routeDecisionId:u.routeDecisionId,messageId:u.id}),u.followUps&&u.followUps.length>0&&!f&&l.length>
5380&&l[l.length-1].id===u.id&&(0,e.jsxs)("div",{className:"xy-followups",style:{display:"flex",flexWrap:"wrap",gap:6,marginTop:12,paddingTop:10,borderTop:"1px solid rgba(212,175,92,0.08)"},children:[(0,e.jsx)("span",{style:{fontFamily:n,fontSize:7,color:"#3A4A5E",letterSpacing:".12em",marginRight:4,paddingTop:6},children:"INTELLIGENCE AVAILABLE"}),u.followUps.map(function(se,Ve){var Ze=/^VIDEO:|video|watch|show.*video|video.*analysis|video.*intelligence/i.test(se);return i.createElement("button",{key:Ve,onClick:function(){if(Ze){Jr(!0);return}Si(se)},style:{padding:"5px 12px",background:Ze?"rgba(56,189,248,0.06)":"rgba(212,175,92,0.04)",border:"1px solid "+(Ze?"rgba(56,189,248,0.2)":"rgba(212,175,92,0.12)"),borderRadius:3,cursor:"pointer",fontFamily:n,fontSize:9,color:Ze?"#6B9AC4":"#8B949E",letterSpacing:".04em",transition:"all 0.12s"},onMouseEnter:function(yt){yt.currentTarget.style.borderColor=Ze?"rgba(56,189,248,0.5)":"rgba(212,175,92,0.35)",yt.currentTarget.style.color=Ze?"#6B9AC4":"#D4AF5C"},onMouseLeave:function(yt){yt.currentTarget.style.borderColor=Ze?"rgba(56,189,248,0.2)":"rgba(212,175,92,0.12)",yt.currentTarget.style.color=Ze?"#6B9AC4":"#8B949E"}},(Ze?"▶ ":"→ ")+se)})]})]},u.id):(0,e.jsxs)("div",{"data-chat-message-id":u.id,"data-role":S?"user":"assistant",style:{display:"flex",gap:12,padding:"14px 16px",borderBottom:"1px solid "+Rn.border,animation:"xfadein .2s ease",background:Ge},children:[S?(0,e.jsx)("div",{style:{width:30,height:30,borderRadius:8,background:"#0D1117",border:"1px solid #2A3548",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,fontFamily:n,fontSize:8,fontWeight:700,color:"#8B949E",marginTop:2},children:"YOU"}):(0,e.jsx)(m0,{style:{marginTop:2}}),(0,e.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6,flexWrap:"wrap"},children:[(0,e.jsx)("span",{style:S?{fontFamily:n,fontWeight:700,fontSize:10,color:"#8B949E",letterSpacing:".1em"}:{fontFamily:bo.font,fontWeight:bo.fontWeight||700,fontSize:bo.fontSize||10,color:Em,letterSpacing:bo.letterSpacing||".1em",textTransform:bo.textTransform||"uppercase"},children:S?"PRINCIPAL":Gn.short+" INTELLIGENCE"}),u.ts&&(0,e.jsx)("span",{style:{fontFamily:n,fontSize:7,color:Rn.dim},children:u.ts}),F&&(0,e.jsx)("span",{style:{fontSize:9},children:"📌"}),!S&&u.webSearch&&u.webSearch.fired&&(0,e.jsx)("span",{title:"Web search contributed to this answer",style:{fontFamily:n,fontSize:7,fontWeight:700,letterSpacing:".08em",padding:"1px 6px",borderRadius:3,background:"rgba(91,168,160,0.10)",color:"#5BA8A0",border:"1px solid rgba(91,168,160,0.24)"},children:"⌕ WEB"}),!S&&u.memoryContext&&u.memoryContext.active&&(0,e.jsx)("span",{title:"Memory context used: "+((u.memoryContext.blocks||[]).join(", ")||"context"),style:{fontFamily:n,fontSize:7,fontWeight:700,letterSpacing:".08em",padding:"1px 6px",borderRadius:3,background:"rgba(212,175,92,0.08)",color:"#D4AF5C",border:"1px solid rgba(212,175,92,0.22)"},children:"◷ MEMORY "+(u.memoryContext.count||"")}),!S&&u.tokens&&(0,e.jsxs)("span",{style:{fontFamily:n,fontSize:7,color:"#3A4A5E"},children:[u.tokens.input+u.tokens.output," tok"]})]}),ce&&S?(0,e.jsxs)("div",{children:[(0,e.jsx)("textarea",{value:B,onChange:function(se){ie(se.target.value)},autoFocus:!0,rows:3,style:{width:"100%",background:"#0D1020",border:"1px solid rgba(212,175,92,0.4)",borderRadius:6,padding:"8px",color:Rn.text,fontSize:13,outline:"none",resize:"vertical",boxSizing:"border-box"}}),(0,e.jsxs)("div",{style:{display:"flex",gap:6,marginTop:6},children:[(0,e.jsx)("button",{onClick:function(){_C(u.id,B)},style:{padding:"4px 12px",background:"rgba(212,175,92,0.1)",border:"1px solid rgba(212,175,92,0.3)",borderRadius:5,cursor:"pointer",fontFamily:n,fontSize:8,color:Rn.amber},children:"RESEND"}),(0,e.jsx)("button",{onClick:function(){T(null)},style:{padding:"4px 12px",background:"transparent",border:"1px solid #1E2838",borderRadius:5,cursor:"pointer",fontFamily:n,fontSize:8,color:"#5A7090"},children:"CANCEL"})]})]}):S?(0,e.jsx)("p",{style:{margin:0,color:Rn.text,fontSize:13,lineHeight:1.7},children:u.text}):(0,e.jsxs)("div",{children:[u.msgMetadata&&u.msgMetadata.thinking_trace&&(0,e.jsx)(QI,{trace:u.msgMetadata.thinking_trace}),wx(u.text||""),k1(u.text||"").map(function(se,Ve){return(0,e.jsx)(Sy,{url:se.url,compact:!0,onOpen:aa},"ve"+Ve)}),u.msgMetadata&&Array.isArray(u.msgMetadata.artifacts)&&u.msgMetadata.artifacts.map(function(se,Ve){var Ze=(0,e.jsx)(Tg,{artifact:se,fallbackText:u.text||""}
538,"aip"+(se.id||Ve));if(u.genReveal&&se&&(se.type==="image"||se.type==="chart")&&(!u.genReveal.artifactId||u.genReveal.artifactId===se.id)){var yt=se.type==="chart"?(0,e.jsx)(Tg,{artifact:se,fallbackText:u.text||"",chartDrawDelayMs:1050},"aip"+(se.id||Ve)):Ze;return(0,e.jsx)(X0,{kind:u.genReveal.kind,startedAt:u.genReveal.startedAt,phase:se.error||u.genReveal.error?"error":"reveal",error:se.error||u.genReveal.error||null,children:yt},"gen"+(se.id||Ve))}return Ze}),u.genReveal&&u.genReveal.error&&!((u.msgMetadata||{}).artifacts||[]).length&&(0,e.jsx)(X0,{kind:u.genReveal.kind,startedAt:u.genReveal.startedAt,phase:"error",error:u.genReveal.error},"genfail"+u.id),u.msgMetadata&&Array.isArray(u.msgMetadata.artifacts)&&u.msgMetadata.artifacts.length>0&&u.msgMetadata.artifacts.map(function(se,Ve){var Ze=String(se.type||"markdown").toUpperCase(),yt=Xi&&Xi.messageId===u.id&&Xi.artifact&&Xi.artifact.id===se.id;return(0,e.jsxs)("button",{type:"button",className:"chat-artifact-card",onClick:function(){Uo({messageId:u.id,artifact:se})},style:{display:"flex",alignItems:"center",gap:10,marginTop:10,padding:"10px 12px",background:yt?"rgba(212,175,92,0.10)":"rgba(212,175,92,0.04)",border:"1px solid "+(yt?"rgba(212,175,92,0.45)":"rgba(212,175,92,0.20)"),borderRadius:6,cursor:"pointer",width:"100%",textAlign:"left",fontFamily:"-apple-system,BlinkMacSystemFont,sans-serif",transition:"all .12s"},children:[se.type==="image"&&se.content&&(0,e.jsx)("img",{src:se.content,alt:"",style:{width:40,height:40,objectFit:"cover",borderRadius:4,border:"0.5px solid rgba(255,255,255,0.1)",flexShrink:0}}),(0,e.jsx)("span",{style:{padding:"3px 6px",borderRadius:3,background:"rgba(212,175,92,0.15)",color:"#D4AF5C",fontFamily:n,fontSize:9,letterSpacing:".08em",fontWeight:700},children:Ze}),(0,e.jsx)("span",{style:{flex:1,fontSize:12,fontWeight:600,color:"#C5CAD2",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:se.title||"Artifact"}),se.version&&se.version>1?(0,e.jsxs)("span",{style:{color:"#5A6878",fontFamily:n,fontSize:10},children:["v",se.version]}):null,(0,e.jsx)("span",{style:{color:"#D4AF5C",fontFamily:n,fontSize:11},children:yt?"●":"↗"})]},se.id||Ve)}),u.msgMetadata&&Array.isArray(u.msgMetadata.code_executions)&&u.msgMetadata.code_executions.length>0&&(0,e.jsx)("div",{style:{marginTop:12},children:u.msgMetadata.code_executions.map(function(se,Ve){return(0,e.jsx)(JI,{trace:se},Ve)})}),u.citations&&u.citations.length>0&&Pk(u.citations,u.id),u.toolArtifacts&&u.toolArtifacts.length>0&&(0,e.jsx)("div",{style:{marginTop:6},children:u.toolArtifacts.map(function(se,Ve){return(0,e.jsx)(ZF,{artifact:se},Ve)})}),u.images&&u.images.length>0&&(0,e.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill,minmax(160px,1fr))",gap:8,margin:"10px 0"},children:u.images.map(function(se,Ve){return(0,e.jsx)(Ik,{img:se},Ve)})}),u.videos&&u.videos.length>0&&(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8,margin:"10px 0"},children:u.videos.map(function(se,Ve){return(0,e.jsx)(jx,{vid:se},Ve)})}),u.videoIntel&&u.videoIntel.length>0&&(0,e.jsxs)("div",{style:{marginTop:8,borderRadius:6,overflow:"hidden",border:"1px solid rgba(212,175,92,0.15)",background:"rgba(6,8,13,0.8)"},children:[(0,e.jsxs)("div",{style:{padding:"5px 12px",display:"flex",alignItems:"center",gap:8,borderBottom:"1px solid rgba(212,175,92,0.1)",background:"rgba(212,175,92,0.04)"},children:[(0,e.jsx)("span",{style:{fontSize:12,color:"#D4AF5C"},children:"▶"}),(0,e.jsx)("span",{style:{fontSize:10,fontFamily:"monospace",color:"#D4AF5C",letterSpacing:"0.08em",fontWeight:600},children:"VIDEO INTELLIGENCE"}),(0,e.jsxs)("span",{style:{fontSize:9,color:"#5A7090",fontFamily:"monospace"},children:[u.videoIntel.length," result",u.videoIntel.length>1?"s":""]})]}),(0,e.jsx)("div",{style:{padding:8,display:"flex",flexDirection:"column",gap:6},children:u.videoIntel.map(function(se,Ve){return(0,e.jsx)(jx,{vid:se},Ve)})})]}),u.socialIntel&&u.socialIntel.socialUseful&&(0,e.jsx)(zD,{social:u.socialIntel}),u.searchData&&u.searchData.citations&&u.searchData.citations.length>0&&(0,e.jsxs)("div",{style:{marginTop:10,borderRadius:6,border:"1px solid rgba(56,189,248,0.2)",background:"rgba(6,8,13,0.97)",overflow:"hidden"},children:[(0,e.jsxs)("div",{style:{padding:"5px 12px",borderBottom:"1px solid rgba(56,189,248,0.1)",display:"flex",justifyContent:"space-between",alignItems:"center",background:"rgba(56,189,248,0.05)"},children:[(0,e.jsx)("span",{style:{fontSize:9,fontFamily:n,color:"#6B9AC4",letterSpacing:".1em",fontWeight:700},children:"◈ WEB SOURCES"}),(0,e.jsx)("span",{style:{fontSize:8,fontFamily:n,color:"#3A4A5E"},children:u.searchData.citations.length+" LIVE SOURCES"})]}),u.searchData.images&&u.searchData.images.length>0&&(0,e.jsx)("div",{style:{padding:"8px 12px",display:"flex",gap:8,overflowX:"auto",borderBottom:"1px solid rgba(28,39,64,0.4)"},children:u.searchData.images.slice(0,4).map(function(se,Ve){var Ze=typeof se=="string"?se:se&&(se.url||se.image_url||se.imageUrl||se.src)||"";return Ze?i.createElement("img",{key:Ve,src:Ze,alt:"",style:{width:90,height:65,objectFit:"cover",borderRadius:4,border:"1px solid rgba(56,189,248,0.15)",flexShrink:0,cursor:"pointer"},onClick:function(){window.open(Ze,"_blank")},onError:function(yt){yt.target.style.display="none"}}):null})}),(0,e.jsx)("div",{style:{padding:"8px 12px",display:"grid",gridTemplateColumns:"1fr 1fr",gap:3},children:u.searchData.citations.slice(0,6).map(function(se,Ve){var Ze="";try{Ze=new URL(se).hostname.replace("www.","")}catch{Ze=se.slice(0,35)}var yt="https://www.google.com/s2/favicons?domain="+Ze+"&sz=16";return i.createElement("a",{key:Ve,href:se,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:5,padding:"3px 6px",borderRadius:3,background:"rgba(56,189,248,0.05)",border:"1px solid rgba(56,189,248,0.1)",textDecoration:"none"}},i.createElement("img",{src:yt,width:12,height:12,style:{flexShrink:0,opacity:.8},onError:function(xt){xt.target.style.display="none"}}),i.createElement("span",{style:{fontSize:8,fontFamily:n,color:"#6B9AC4",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},Ze))})})]})]}),!S&&u.vaultSources&&u.vaultSources.length>0&&(0,e.jsxs)("div",{style:{marginTop:8,border:"1px solid rgba(212,175,92,0.2)",borderRadius:6,background:"rgba(6,8,13,0.95)",overflow:"hidden"},children:[(0,e.jsxs)("div",{style:{padding:"5px 12px",borderBottom:"1px solid rgba(212,175,92,0.1)",display:"flex",justifyContent:"space-between"},children:[(0,e.jsx)("span",{style:{fontSize:9,fontFamily:n,color:"#D4AF5C",letterSpacing:".1em",fontWeight:700},children:"◈ VAULT SOURCES"}),(0,e.jsx)("span",{style:{fontSize:8,fontFamily:n,color:"#3A4A5E"},children:u.vaultSources.length+" DOCUMENTS"})]}),(0,e.jsx)("div",{style:{padding:"6px 12px"},children:u.vaultSources.map(function(se,Ve){return i.createElement("div",{key:Ve,style:{fontSize:9,fontFamily:n,color:"#8FA3B8",padding:"2px 0",display:"flex",justifyContent:"space-between"}},i.createElement("span",null,se.filename||se.name||"Document"),i.createElement("span",{style:{color:"#D4AF5C",fontSize:8}},Math.round((se.similarity||0)*100)+"% match"))})})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:4,marginTop:6,alignItems:"center",flexWrap:"wrap"},children:[!S&&u.wasValidated&&(0,e.jsx)("span",{style:{fontSize:8,fontFamily:n,color:"#D4AF5C",border:"1px solid rgba(212,175,92,0.3)",padding:"1px 5px",borderRadius:3},children:"✓ VALIDATED"}),S&&!f&&(0,e.jsx)("button",{onClick:function(){T(u.id),ie(u.text||"")},style:{padding:"2px 8px",background:"transparent",border:"1px solid #1E2838",borderRadius:4,cursor:"pointer",fontFamily:n,fontSize:7,color:"#3A4A5E"},onMouseEnter:function(se){se.currentTarget.style.color="#8B949E"},onMouseLeave:function(se){se.currentTarget.style.color="#3A4A5E"},children:"✎ Edit"}),!S&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:function(){xm(u.text||"",u.id)},title:Ii===u.id?"Stop playback":"Play with Xyron voice",style:{padding:"2px 8px",background:Ii===u.id?"rgba(63,185,80,0.10)":"transparent",border:"1px solid "+(Ii===u.id?"rgba(63,185,80,0.32)":"#1E2838"),borderRadius:4,cursor:"pointer",fontFamily:n,fontSize:7,color:Ii===u.id?"#3FB950":"#3A4A5E"},onMouseEnter:function(se){se.currentTarget.style.color="#3FB950"},onMouseLeave:function(se){se.currentTarget.style.color=Ii===u.id?"#3FB950":"#3A4A5E"},children:Ii===u.id?"⏹":"🔊"}),(0,e.jsx)(uy,{text:u.text||"",msgId:u.id,chart:u.chart,sessionId:t.sessionId,projectId:t.project&&t.project.id,projectName:t.project&&t.project.name,role:"assistant",artifact:u.msgMetadata&&Array.isArray(u.msgMetadata.artifacts)&&u.msgMetadata.artifacts.find(function(se){return se&&(se.content||se.url)})||null,onOpenArtifact:function(se){Uo({messageId:u.id,artifact:se})}})]}),S&&!f&&ns[u.id]&&ns[u.id].length>0&&(0,e.jsxs)("button",{onClick:function(){RC(u.id)},title:"Restore the previous version of this message",style:{fontFamily:n,fontSize:7,color:"#8B9AAF",background:"transparent",padding:"1px 6px",border:"1px solid #1E2838",borderRadius:8,cursor:"pointer"},onMouseEnter:function(se){se.currentTarget.style.color="#D4AF5C",se.currentTarget.style.borderColor="rgba(212,175,92,0.4)"},onMouseLeave:function(se){se.currentTarget.style.color="#8B9AAF",se.currentTarget.style.borderColor="#1E2838"},children:["⑂"," ",ns[u.id].length," ","↺"," restore"]}),(0,e.jsx)("button",{onClick:function(){hm(u.id)},style:{padding:"2px 8px",background:F?"rgba(212,175,92,0.08)":"transparent",border:"1px solid "+(F?"rgba(212,175,92,0.2)":"#1E2838"),borderRadius:4,cursor:"pointer",fontFamily:n,fontSize:7,color:F?Rn.amber:"#3A4A5E"},onMouseEnter:function(se){se.currentTarget.style.color=Rn.amber},onMouseLeave:function(se){se.currentTarget.style.color=F?Rn.amber:"#3A4A5E"},children:"📌"}),!S&&(0,e.jsxs)("div",{style:{display:"flex",gap:3,marginLeft:2},children:[(0,e.jsx)("button",{onClick:function(){Lx(u.id,"up")},style:{padding:"2px 6px",background:G==="up"?"rgba(63,185,80,0.1)":"transparent",border:"1px solid "+(G==="up"?"rgba(63,185,80,0.25)":"#1E2838"),borderRadius:4,cursor:"pointer",fontSize:10},children:"👍"}),(0,e.jsx)("button",{onClick:function(){Lx(u.id,"dn")},style:{padding:"2px 6px",background:G==="dn"?"rgba(200,92,92,0.1)":"transparent",border:"1px solid "+(G==="dn"?"rgba(200,92,92,0.25)":"#1E2838"),borderRadius:4,cursor:"pointer",fontSize:10},children:"👎"})]}
538),!S&&!f&&l[l.length-1]&&l[l.length-1].id===u.id&&(0,e.jsx)("button",{onClick:Ox,style:{padding:"2px 8px",background:"transparent",border:"1px solid #1E2838",borderRadius:4,cursor:"pointer",fontFamily:n,fontSize:7,color:"#3A4A5E"},onMouseEnter:function(se){se.currentTarget.style.color=Rn.amber},onMouseLeave:function(se){se.currentTarget.style.color="#3A4A5E"},children:"↺ Retry"})]}),!S&&u.isReport&&(0,e.jsxs)("div",{style:{marginTop:10,padding:"10px 0 2px",borderTop:"1px solid #0D1520"},children:[(0,e.jsx)("div",{style:{fontFamily:n,fontSize:7,color:"#3A5060",letterSpacing:"0.1em",marginBottom:7},children:"EXPORT REPORT"}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,e.jsxs)("button",{onClick:function(){ev("pdf",u.reportTitle,Zx(u))},style:{display:"flex",alignItems:"center",gap:7,padding:"7px 20px",background:"rgba(212,175,92,0.06)",border:"1px solid rgba(212,175,92,0.22)",borderRadius:6,cursor:"pointer",fontFamily:n,fontSize:9,color:"#D4AF5C",fontWeight:600,letterSpacing:"0.06em",transition:"all .15s"},onMouseEnter:function(se){se.currentTarget.style.background="rgba(212,175,92,0.14)",se.currentTarget.style.borderColor="rgba(212,175,92,0.4)"},onMouseLeave:function(se){se.currentTarget.style.background="rgba(212,175,92,0.06)",se.currentTarget.style.borderColor="rgba(212,175,92,0.22)"},children:[(0,e.jsx)("span",{style:{fontSize:11},children:"↓"}),(0,e.jsx)("span",{children:"Download PDF"})]}),(0,e.jsxs)("button",{onClick:function(){ev("docx",u.reportTitle,Zx(u))},style:{display:"flex",alignItems:"center",gap:7,padding:"7px 20px",background:"rgba(212,175,92,0.06)",border:"1px solid rgba(212,175,92,0.22)",borderRadius:6,cursor:"pointer",fontFamily:n,fontSize:9,color:"#D4AF5C",fontWeight:600,letterSpacing:"0.06em",transition:"all .15s"},onMouseEnter:function(se){se.currentTarget.style.background="rgba(212,175,92,0.14)",se.currentTarget.style.borderColor="rgba(212,175,92,0.4)"},onMouseLeave:function(se){se.currentTarget.style.background="rgba(212,175,92,0.06)",se.currentTarget.style.borderColor="rgba(212,175,92,0.22)"},children:[(0,e.jsx)("span",{style:{fontSize:11},children:"↓"}),(0,e.jsx)("span",{children:"Download DOC"})]})]})]}),!S&&u.actions&&u.actions.length>0&&(function(){var se=u.actions.filter(function(xt){return xt.id!=="generate_report"});if(se.length===0)return null;var Ve={display:"flex",alignItems:"center",gap:5,padding:"4px 10px",background:"rgba(91,168,160,0.04)",border:"1px solid rgba(91,168,160,0.15)",borderRadius:5,cursor:"pointer",fontFamily:n,fontSize:8,color:"#5BA8A0",transition:"all .12s"},Ze=function(xt){xt.currentTarget.style.background="rgba(91,168,160,0.10)",xt.currentTarget.style.borderColor="rgba(91,168,160,0.3)"},yt=function(xt){xt.currentTarget.style.background="rgba(91,168,160,0.04)",xt.currentTarget.style.borderColor="rgba(91,168,160,0.15)"};return(0,e.jsx)("div",{style:{display:"flex",gap:5,marginTop:6,flexWrap:"wrap"},children:se.map(function(xt){return(0,e.jsxs)("button",{onClick:function(){TC(xt)},style:Ve,onMouseEnter:Ze,onMouseLeave:yt,children:[(0,e.jsx)("span",{style:{fontSize:10},children:xt.id==="run_stress_test"?"◈":xt.id==="generate_chart"?"▣":xt.id==="vault_search"?"⌕":xt.id==="portfolio_rebalance"?"◈":xt.id==="export_conversation"?"↗":xt.id==="schedule_brief"?"◎":xt.id==="send_email"?"✉":xt.id==="save_draft"?"❏":"▶"}),(0,e.jsx)("span",{children:xt.label})]},xt.id)})})})(),!S&&u.followUps&&u.followUps.length>0&&!f&&l.length>0&&l[l.length-1].id===u.id&&(0,e.jsxs)("div",{className:"xy-followups",style:{display:"flex",flexWrap:"wrap",gap:6,marginTop:12,paddingTop:10,borderTop:"1px solid rgba(212,175,92,0.08)"},children:[(0,e.jsx)("span",{style:{fontFamily:n,fontSize:7,color:"#3A4A5E",letterSpacing:".12em",marginRight:4,paddingTop:6},children:"INTELLIGENCE AVAILABLE"}),u.followUps.map(function(se,Ve){var Ze=/^VIDEO:|video|watch|show.*video|video.*analysis|video.*intelligence/i.test(se),yt=/xlsx|spreadsheet|sheet|trial.?balance|P.?L|balance.?sheet|cash.?flow|budget/i.test(se),xt=/report|memo|brief|docx|board.?pack|covenant/i.test(se),Qt=/map|geopolitical.*map|location/i.test(se),un=Ze?"▶":yt?"▣":xt?"□":Qt?"◉":"→",an=Ze?"#6B9AC4":yt?"#3FB950":xt?"#D4AF5C":Qt?"#FBBF24":"#8B949E",rr=Ze?"rgba(56,189,248,0.06)":yt?"rgba(63,185,80,0.06)":xt?"rgba(212,175,92,0.06)":Qt?"rgba(251,191,36,0.06)":"rgba(212,175,92,0.04)",Pr=Ze?"rgba(56,189,248,0.2)":yt?"rgba(63,185,80,0.2)":xt?"rgba(212,175,92,0.2)":Qt?"rgba(251,191,36,0.2)":"rgba(212,175,92,0.12)";return i.createElement("button",{key:Ve,onClick:function(){if(Ze){Jr(!0);return}if(Qt){vi(!0);return}Si(se)},style:{padding:"5px 12px",background:rr,border:"1px solid "+Pr,borderRadius:3,cursor:"pointer",fontFamily:n,fontSize:9,color:an,letterSpacing:".04em",transition:"all 0.12s"},onMouseEnter:function(lr){lr.currentTarget.style.borderColor=an+"80",lr.currentTarget.style.color=an},onMouseLeave:function(lr){lr.currentTarget.style.borderColor=Pr,lr.currentTarget.style.color=an}},un+" "+se)})]})]})]},u.id)}),(C||O)&&f&&(0,e.jsxs)("div",{style:{margin:"8px 16px 0",border:"1px solid rgba(212,175,92,0.2)",borderRadius:6,background:"rgba(6,8,13,0.95)",overflow:"hidden"},children:[(0,e.jsxs)("div",{style:{padding:"6px 12px",borderBottom:"1px solid rgba(212,175,92,0.1)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8}
538,children:[C&&(0,e.jsx)("div",{style:{width:6,height:6,borderRadius:"50%",background:"#D4AF5C",animation:"xpulse 1s infinite"}}),O&&(0,e.jsx)("span",{style:{color:"#00E676",fontSize:10},children:"✓"}),(0,e.jsx)("span",{style:{fontSize:9,fontFamily:n,color:"#D4AF5C",letterSpacing:".1em",fontWeight:700},children:C?"GATHERING INTELLIGENCE":"INTELLIGENCE LOADED"})]}),O&&(0,e.jsx)("span",{style:{fontSize:8,fontFamily:n,color:"#3A4A5E"},children:ee+" SOURCES ACTIVE"})]}),(0,e.jsx)("div",{style:{padding:"6px 12px",maxHeight:O?60:120,overflow:"hidden",transition:"max-height .5s ease"},children:A.map(function(u,S){return i.createElement("div",{key:S,style:{fontSize:9,fontFamily:n,color:S===A.length-1?"#C9D1D9":"#3A4A5E",padding:"1px 0",display:"flex",alignItems:"center",gap:6}},i.createElement("span",{style:{color:S===A.length-1&&C?"#D4AF5C":"#00E676",fontSize:8}},S===A.length-1&&C?"›":"✓"),u)})})]}),f&&!pt&&!C&&(0,e.jsxs)("div",{style:{display:"flex",gap:12,padding:"14px 16px"},children:[(0,e.jsx)(m0,{}),(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6,paddingTop:8},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,e.jsx)("div",{style:{display:"flex",gap:4},children:[0,1,2].map(function(u){return(0,e.jsx)("div",{style:{width:7,height:7,borderRadius:"50%",background:"#D4AF5C",animation:"xpulse "+(.4+u*.15)+"s infinite",animationDelay:u*.15+"s"}},u)})}),(0,e.jsxs)("span",{style:{fontFamily:n,fontSize:9,color:"#5A7090",letterSpacing:".1em"},children:[Gn.short," IS THINKING…"]})]}),z&&(0,e.jsxs)("div",{style:{display:"inline-flex",alignItems:"center",gap:7,padding:"3px 11px",background:"rgba(16,24,38,0.72)",border:"1px solid rgba(212,175,92,0.22)",borderRadius:999,fontFamily:n,fontSize:9,letterSpacing:".12em",color:"#C9B37E",textTransform:"uppercase",backdropFilter:"blur(4px)"},children:[(0,e.jsx)("span",{style:{width:5,height:5,borderRadius:"50%",background:"#D4AF5C",boxShadow:"0 0 6px rgba(212,175,92,0.55)",animation:"xpulse 1.1s ease-in-out infinite",flexShrink:0}}),(0,e.jsx)("span",{children:z})]}),Ye&&Ye.phase==="generating"&&(0,e.jsx)(X0,{kind:Ye.kind,startedAt:Ye.startedAt,phase:"generating"})]})]}),f&&pt&&(0,e.jsxs)("div",{style:{display:"flex",gap:12,padding:"14px 16px"},children:[(0,e.jsx)(m0,{}),(0,e.jsxs)("div",{style:{flex:1,maxWidth:"calc(100% - 50px)"},children:[z&&(0,e.jsxs)("div",{style:{display:"inline-flex",alignItems:"center",gap:7,padding:"3px 11px",background:"rgba(16,24,38,0.72)",border:"1px solid rgba(212,175,92,0.22)",borderRadius:999,fontFamily:n,fontSize:9,letterSpacing:".12em",color:"#C9B37E",textTransform:"uppercase",backdropFilter:"blur(4px)",marginBottom:6},children:[(0,e.jsx)("span",{style:{width:5,height:5,borderRadius:"50%",background:"#D4AF5C",boxShadow:"0 0 6px rgba(212,175,92,0.55)",animation:"xpulse 1.1s ease-in-out infinite",flexShrink:0}}),(0,e.jsx)("span",{children:z})]}),(0,e.jsxs)("div",{style:{color:Rn.text,fontSize:13,lineHeight:1.75},children:[(0,e.jsx)("div",{ref:qt}),(0,e.jsx)("span",{style:{display:"inline-block",width:6,height:13,background:Rn.amber,marginLeft:2,verticalAlign:"middle",animation:"xblink .9s infinite",borderRadius:1}})]}),Ye&&Ye.phase==="generating"&&(0,e.jsx)(X0,{kind:Ye.kind,startedAt:Ye.startedAt,phase:"generating"})]})]})]})}),(dr||mi("video"))&&(0,e.jsxs)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:50,background:"#05080D",display:dr?"flex":"none",flexDirection:"column",overflow:"hidden",animation:"vidSlideUp 0.2s ease-out"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px",borderBottom:"1px solid #111820",background:"#06080D",flexShrink:0},children:[(0,e.jsx)("span",{style:{fontFamily:n,fontSize:9,fontWeight:700,color:"#D4AF5C",letterSpacing:".14em"},children:"VIDEO INTELLIGENCE"}),(0,e.jsxs)("button",{onClick:function(){Jr(!1)},style:{background:"transparent",border:"1px solid #1E2838",borderRadius:4,padding:"3px 10px",cursor:"pointer",fontFamily:n,fontSize:8,color:"#5A7090",letterSpacing:".08em"},children:["✕"," CLOSE"]})]}),(0,e.jsx)("div",{style:{flex:1,overflow:"auto",padding:0},children:(0,e.jsx)(b4,{contextQuery:Is||Rk,apiBase:"",onOpenVideo:aa},"vid-open")})]}),(or||mi("portfolio"))&&(0,e.jsxs)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:50,background:"#05080D",display:or?"flex":"none",flexDirection:"column",overflow:"hidden",animation:"vidSlideUp 0.2s ease-out"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px",borderBottom:"1px solid #111820",background:"#06080D",flexShrink:0},children:[(0,e.jsx)("span",{style:{fontFamily:n,fontSize:9,fontWeight:700,color:"#D4AF5C",letterSpacing:".14em"},children:"PORTFOLIO MANAGER"}),(0,e.jsxs)("button",{onClick:function(){po(!1)},style:{background:"transparent",border:"1px solid #1E2838",borderRadius:4,padding:"3px 10px",cursor:"pointer",fontFamily:n,fontSize:8,color:"#5A7090",letterSpacing:".08em"},children:["✕"," CLOSE"]})]}),(0,e.jsx)("div",{style:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column"},children:(0,e.jsx)(RD,{positions:t.positions,onPositionsChange:t.onPositionsChange,onAddVaultDoc:t.onAddVaultDoc,onAudit:function(u,S){try{oi({action:u,detail:S,model:"system"})}catch{}},onNavigateRooms:t.onRestoreRoom},"pm-open")})]}),(li||mi("realestate"))&&(0,e.jsxs)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:50,background:"#05080D",display:li?"flex":"none",flexDirection:"column",overflow:"hidden",animation:"vidSlideUp 0.2s ease-out"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px",borderBottom:"1px solid #111820",background:"#06080D",flexShrink:0},children:[(0,e.jsx)("span",{style:{fontFamily:n,fontSize:9,fontWeight:700,color:"#D4AF5C",letterSpacing:".14em"},children:"REAL ESTATE"}),(0,e.jsxs)("button",{onClick:function(){Li(!1)},style:{background:"transparent",border:"1px solid #1E2838",borderRadius:4,padding:"3px 10px",cursor:"pointer",fontFamily:n,fontSize:8,color:"#5A7090",letterSpacing:".08em"},children:["✕"," CLOSE"]})]}),(0,e.jsx)("div",{style:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column"},children:(0,e.jsx)(i.Suspense,{fallback:(0,e.jsx)("div",{style:{padding:28,color:"#5A7090",fontFamily:n,fontSize:12},children:"Loading Real Estate…"}),children:(0,e.jsx)(j6,{onAsk:function(u){yr(u,"realestate")},savedDocs:t.savedDocs,onDrawerContext:function(u){fs.current.realestate=u}})})})]}),(qi||mi("scanner"))&&(0,e.jsxs)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:50,background:"#05080D",display:qi?"flex":"none",flexDirection:"column",overflow:"hidden",animation:"vidSlideUp 0.2s ease-out"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px",borderBottom:"1px solid #111820",background:"#06080D",flexShrink:0},children:[(0,e.jsx)("span",{style:{fontFamily:n,fontSize:9,fontWeight:700,color:"#D4AF5C",letterSpacing:".14em"},children:"SCANNER · DOC INTEL"}),(0,e.jsxs)("button",{onClick:function(){go(!1)},style:{background:"transparent",border:"1px solid #1E2838",borderRadius:4,padding:"3px 10px",cursor:"pointer",fontFamily:n,fontSize:8,color:"#5A7090",letterSpacing:".08em"},children:["✕"," CLOSE"]})]}),(0,e.jsx)("div",{style:{flex:1,overflow:"auto",padding:"12px"},children:(0,e.jsx)(g6,{variant:"dock",onDrawerContext:function(u){fs.current.scanner=u},projects:t.projects,onUpdateProject:t.onUpdateProject},"scan-open")})]}),mu&&(0,e.jsxs)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:60,background:"#05080D",display:"flex",flexDirection:"column",overflow:"hidden",animation:"vidSlideUp 0.2s ease-out"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px",borderBottom:"1px solid #111820",background:"#06080D",flexShrink:0},children:[(0,e.jsx)("span",{style:{fontFamily:n,fontSize:9,fontWeight:700,color:"#8B8ABF",letterSpacing:".14em"},children:"PREDICTIVE INTEL"}),(0,e.jsxs)("button",{onClick:function(){jl(null)},style:{background:"transparent",border:"1px solid #1E2838",borderRadius:4,padding:"3px 10px",cursor:"pointer",fontFamily:n,fontSize:8,color:"#5A7090",letterSpacing:".08em"},children:["✕"," CLOSE"]})]}),(0,e.jsx)("div",{style:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column"},children:(0,e.jsx)(bA,{item:mu,positions:t.positions||[],alerts:t.alerts||[],livePrice
538s:void 0},"predict-ctx")})]}),(tr||mi("intelgraph"))&&(0,e.jsxs)("div",{className:"xy-ig-dock-host",style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:50,background:"#05080D",display:tr?"flex":"none",flexDirection:"column",overflow:"hidden",animation:"vidSlideUp 0.2s ease-out",minHeight:0},children:[(0,e.jsxs)("div",{className:"xy-ig-dock-chrome",style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px",borderBottom:"1px solid #111820",background:"#06080D",flexShrink:0},children:[(0,e.jsx)("span",{style:{fontFamily:n,fontSize:9,fontWeight:700,color:"#D4AF5C",letterSpacing:".14em"},children:"INTEL GRAPH"}),(0,e.jsxs)("button",{onClick:function(){Fo(!1)},style:{background:"transparent",border:"1px solid #1E2838",borderRadius:4,padding:"3px 10px",cursor:"pointer",fontFamily:n,fontSize:8,color:"#5A7090",letterSpacing:".08em"},children:["✕"," CLOSE"]})]}),(0,e.jsx)("div",{style:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",minHeight:0,width:"100%"},children:(0,e.jsx)(i.Suspense,{fallback:(0,e.jsx)("div",{style:{padding:28,color:"#5A7090",fontFamily:n,fontSize:12},children:"Loading Intel Graph…"}),children:(0,e.jsx)("div",{style:{flex:1,minHeight:0,width:"100%",height:"100%"},children:(0,e.jsx)(A6,{onDrawerContext:Tk.current})})})})]}),Qn&&(0,e.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:50,background:"#05080D",display:"flex",flexDirection:"column",overflow:"hidden",animation:"vidSlideUp 0.2s ease-out"},children:(0,e.jsx)(_O,{onClose:function(){vi(!1)},externalSearchQuery:jd?jd.split("|")[0]:"",onDrawerContext:function(u){fs.current.map=u},onAskChat:function(u){yr(u,"map")}})}),(nr||mi("vault"))&&(0,e.jsx)("div",{style:{display:nr?"contents":"none"},children:(0,e.jsx)(RO,{savedDocs:t.savedDocs,onClose:function(){Oi(!1),hi(null)},onSelectDoc:function(u){hi(u)},onAsk:function(u){yr(u,"realestate")},onOpenLedger:t.onOpenLedger})}),(Sr||mi("ledger"))&&(0,e.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:50,background:"#05080D",display:Sr?"flex":"none",flexDirection:"column",overflow:"hidden",animation:"vidSlideUp 0.2s ease-out"},children:(0,e.jsx)(B9,{onClose:function(){ji(!1)}})}),(Er||mi("command"))&&(0,e.jsx)("div",{style:{display:Er?"contents":"none"},children:(0,e.jsx)(q9,{onClose:function(){pi(!1)},onCommand:function(u){pi(!1),p(u),An.current=u,Si(u)},onEmailDraft:function(u){pi(!1),Fn(u),zi(!0)},onStatusMessage:ui,onPrefillCommand:function(u){p(u),An.current=u,ma.current&&ma.current.focus()},commandRef:zd})}),(Tr||mi("email"))&&(0,e.jsx)("div",{style:{display:Tr?"contents":"none"},children:(0,e.jsx)(zj,{onClose:function(){zi(!1),Fn(null),Vr(!1)},initialDraft:zs,onStatusMessage:ui,commandBusy:_r,mode:Ga,tone:Ms,onModeChange:Cc,onToneChange:cl,onActiveDraftChange:Vo,onPrefillCommand:function(u){p(u),An.current=u,ma.current&&ma.current.focus()}})}),(Yr||mi("calendar"))&&(0,e.jsx)("div",{style:{display:Yr?"contents":"none"},children:(0,e.jsx)(p3,{focusEvent:yd,onAccountChange:da,onClose:function(){si(!1)},onStartCall:function(u){si(!1),zn(u)}})}),(Do||mi("messenger"))&&(0,e.jsxs)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:50,display:Do?"flex":"none"},children:[(0,e.jsx)(T3,{onClose:function(){Ji(!1)},onStartCall:function(u){Ji(!1),zn(u)}}),i.createElement(AS,{onClick:function(){Ji(!1)}})]}),(mo||mi("brief"))&&(0,e.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:50,background:"#05070A",display:mo?"flex":"none",flexDirection:"column",overflow:"hidden",animation:"vidSlideUp 0.2s ease-out"},children:(0,e.jsx)(i.Suspense,{fallback:(0,e.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"#C9A961",fontFamily:n,fontSize:10,letterSpacing:".2em"},children:"LOADING BRIEF ENGINE\\u2026"}),children:(0,e.jsx)(b6,{onClose:function(){ho(!1)},conversation:l,onStatusMessage:ui,profile:t.profile})})}),(yo||mi("audit"))&&(0,e.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:50,background:"#05070A",display:yo?"flex":"none",flexDirection:"column",overflow:"hidden",animation:"vidSlideUp 0.2s ease-out"},children:(0,e.jsx)(i.Suspense,{fallback:(0,e.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"#7FA5C8",fontFamily:n,fontSize:10,letterSpacing:".2em"},children:"LOADING AUDIT TRAIL\\u2026"}),children:(0,e.jsx)(S6,{onClose:function(){io(!1)}
538,conversation:l,sessionId:Ui.current,onStatusMessage:ui})})}),(Oo||mi("risk"))&&(0,e.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:50,background:"#05070A",display:Oo?"flex":"none",flexDirection:"column",overflow:"hidden",animation:"vidSlideUp 0.2s ease-out"},children:(0,e.jsx)(i.Suspense,{fallback:(0,e.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"#D46B6B",fontFamily:n,fontSize:10,letterSpacing:".2em"},children:"LOADING RISK ENGINE\\u2026"}),children:(0,e.jsx)(E6,{onClose:function(){oo(!1)},conversation:l,onStatusMessage:ui,onSendToChat:function(u){oo(!1),p(u),An.current=u,Si(u)}})})}),ku.active&&(0,e.jsx)("div",{style:{maxWidth:760,margin:"0 auto",padding:"0 12px"},children:(0,e.jsx)(i.Suspense,{fallback:null,children:(0,e.jsx)(CS,{state:ku})})}),(kr||mi("cortex"))&&(0,e.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:50,background:"#05070A",display:kr?"flex":"none",flexDirection:"column",overflow:"hidden",animation:"vidSlideUp 0.2s ease-out"},children:(0,e.jsx)(i.Suspense,{fallback:(0,e.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"#C9A961",fontFamily:n,fontSize:10,letterSpacing:".2em"},children:"LOADING CORTEX\\u2026"}),children:(0,e.jsx)(k6,{open:!0,dock:"inline",onClose:function(){gi(!1)}})})}),wi&&typeof import.meta<"u"&&!1,yu&&typeof import.meta<"u"&&!1,(Qi||mi("intel"))&&(0,e.jsx)("div",{style:{display:Qi?"contents":"none"},children:(0,e.jsx)(i.Suspense,{fallback:null,children:(0,e.jsx)(C6,{open:!0,onClose:function(){Lo(!1)},alerts:t.alerts,positions:t.positions,messages:l,onDrawerContext:function(u){fs.current.intel=u}})})}),De&&(0,e.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:600,background:"rgba(3,5,9,0.84)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",animation:"xfadein 0.15s ease-out"},children:(0,e.jsxs)("div",{style:{width:460,maxWidth:"92vw",background:"#0A1018",border:"1px solid #7A4A4A",borderRadius:4,padding:0,boxShadow:"0 12px 60px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,120,120,0.15)",fontFamily:"'Inter Tight','IBM Plex Sans',sans-serif",color:"#E4EDF8"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid #1C2632",background:"linear-gradient(180deg, rgba(220,90,80,0.10), transparent)"},children:[(0,e.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:"#E46B5B",boxShadow:"0 0 10px rgba(228,107,91,0.6)"}}),(0,e.jsx)("span",{style:{fontFamily:n,fontSize:10,fontWeight:700,color:"#E46B5B",letterSpacing:".22em",textTransform:"uppercase"},children:"Confirm destructive action"}),(0,e.jsx)("span",{style:{marginLeft:"auto",fontFamily:n,fontSize:8,color:"#4A5A70",letterSpacing:".18em",textTransform:"uppercase"},children:String(De.action||"?").toUpperCase()})]}),(0,e.jsxs)("div",{style:{padding:"16px 18px 4px 18px"},children:[(0,e.jsx)("div",{style:{fontFamily:n,fontSize:8.5,letterSpacing:".22em",color:"#6A7A90",textTransform:"uppercase"},children:"Subject"}),(0,e.jsx)("div",{style:{fontFamily:n,fontSize:13,fontWeight:600,color:"#E4C27A",marginTop:4},children:String(De.payload&&(De.payload.name||De.payload.signal_id||"—"))})]}),De.payload&&De.payload.effect&&(0,e.jsxs)("div",{style:{padding:"12px 18px 4px 18px"},children:[(0,e.jsx)("div",{style:{fontFamily:n,fontSize:8.5,letterSpacing:".22em",color:"#6A7A90",textTransform:"uppercase"},children:"Effect"}),(0,e.jsx)("div",{style:{fontSize:12.5,lineHeight:1.5,color:"#C9D3E0",marginTop:4},children:String(De.payload.effect)})]}),De.payload&&De.payload.reason&&(0,e.jsxs)("div",{style:{padding:"12px 18px 4px 18px"},children:[(0,e.jsx)("div",{style:{fontFamily:n,fontSize:8.5,letterSpacing:".22em",color:"#6A7A90",textTransform:"uppercase"},children:"Reason"}),(0,e.jsx)("div",{style:{fontSize:12,lineHeight:1.4,color:"#99A8BA",marginTop:4,fontStyle:"italic"},children:String(De.payload.reason)})]}),De.payload&&De.payload.ttl_seconds!=null&&(0,e.jsx)("div",{style:{padding:"10px 18px 4px 18px"},children:(0,e.jsxs)("span",{style:{display:"inline-block",fontFamily:n,fontSize:9,letterSpacing:".18em",color:"#E4C27A",background:"rgba(228,194,122,0.08)",border:"1px solid rgba(228,194,122,0.25)",borderRadius:2,padding:"3px 8px",textTransform:"uppercase"},children:["Auto-revive TTL · ",String(De.payload.ttl_seconds),"s"]})}),(0,e.jsxs)("div",{style:{padding:"18px 18px 18px 18px",display:"flex",gap:10,justifyContent:"flex-end",marginTop:8},children:[(0,e.jsx)("button",{onClick:function(){try{Si("Cancel that action — do not proceed. Leave the switch as-is.")}catch{}Se(null)},style:{padding:"8px 16px",fontFamily:n,fontSize:10,letterSpacing:".22em",color:"#8A98AA",background:"transparent",border:"1px solid #22303D",borderRadius:2,textTransform:"uppercase",fontWeight:600,cursor:"pointer"},children:"Cancel"}),(0,e.jsx)("button",{onClick:function(){var u=String(De.action||"action");try{Si("Yes — confirmed. Proceed and execute the "+u+" tool with confirm=true now.")}catch{}Se(null)},style:{padding:"8px 16px",fontFamily:n,fontSize:10,letterSpacing:".22em",color:"#FFF0E0",background:"rgba(220,90,80,0.22)",border:"1px solid rgba(228,107,91,0.55)",borderRadius:2,textTransform:"uppercase",fontWeight:700,cursor:"pointer",boxShadow:"0 0 18px rgba(228,107,91,0.18)"},children:"Confirm"})]})]})}),(Gr||mi("search"))&&(0,e.jsxs)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:50,background:"#05080D",display:Gr?"flex":"none",flexDirection:"column",overflow:"hidden",animation:"vidSlideUp 0.2s ease-out"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 20px",borderBottom:"1px solid #10161E",background:"rgba(8,11,17,0.9)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",flexShrink:0},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12},children:[(0,e.jsx)("div",{style:{width:7,height:7,borderRadius:"50%",background:"#D4AF5C",boxShadow:"0 0 10px rgba(212,175,92,0.5)",animation:lo?"xpulse 1s infinite":"none"}}),(0,e.jsx)("span",{style:{fontFamily:"'Inter Tight','IBM Plex Sans',sans-serif",fontSize:10,fontWeight:700,color:"#E4C27A",letterSpacing:".24em",textTransform:"uppercase"},children:"Intelligence Search"}),(0,e.jsx)("span",{style:{fontFamily:n,fontSize:8,color:"#3A4858",letterSpacing:".2em"},children:"XYRON · SOVEREIGN"}),vo==="scanning"&&(0,e.jsx)("span",{style:{fontFamily:n,fontSize:8,color:"#8898A8",letterSpacing:".18em",animation:"xfadein 0.3s ease"},children:"SCANNING\\u2026"}),vo==="synthesising"&&(0,e.jsxs)("span",{style:{fontFamily:n,fontSize:8,color:"#4DA882",letterSpacing:".18em",animation:"xfadein 0.3s ease"},children:[us," SOURCES FOUND"]}),vo==="streaming"&&(0,e.jsx)("span",{style:{fontFamily:n,fontSize:8,color:"#D4AF5C",letterSpacing:".18em",animation:"xfadein 0.3s ease"},children:"STREAMING\\u2026"})]}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,e.jsx)("button",{onClick:function(){Td(!Lc)},title:Lc?"Pro: deeper search (sonar-pro)":"Fast search (sonar)",style:{background:Lc?"rgba(212,175,92,0.10)":"transparent",border:"1px solid "+(Lc?"rgba(212,175,92,0.55)":"#1E2838"),borderRadius:2,padding:"5px 12px",cursor:"pointer",fontFamily:n,fontSize:9,fontWeight:700,color:Lc?"#D4AF5C":"#5A7090",letterSpacing:".2em",transition:"all .15s"},children:"PRO"}),Yt&&(0,e.jsx)("button",{onClick:function(){kn(null),Ll(""),xo(""),Bi("idle"),zl([]),Xo([]),ar([]),Gs([])},style:{background:"transparent",border:"1px solid rgba(212,175,92,0.30)",borderRadius:2,padding:"5px 12px",cursor:"pointer",fontFamily:"'Inter Tight','IBM Plex Sans',sans-serif",fontSize:9,fontWeight:600,color:"#D4AF5C",letterSpacing:".22em",textTransform:"uppercase",transition:"all .15s"},onMouseEnter:function(u){u.currentTarget.style.background="rgba(212,175,92,0.08)",u.currentTarget.style.borderColor="rgba(212,175,92,0.55)"},onMouseLeave:function(u){u.currentTarget.style.background="transparent",u.currentTarget.style.borderColor="rgba(212,175,92,0.30)"},children:"New Search"}),(0,e.jsx)("button",{onClick:function(){Di(!1),Bi("idle")},style:{width:28,height:28,background:"transparent",border:"1px solid #1E2838",borderRadius:2,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"'Inter Tight',sans-serif",fontSize:14,color:"#8898A8",transition:"all .15s"},onMouseEnter:function(u){u.currentTarget.style.borderColor="#D4AF5C",u.currentTarget.style.color="#D4AF5C",u.currentTarget.style.background="rgba(212,175,92,0.04)"},onMouseLeave:function(u){u.currentTarget.style.borderColor="#1E2838",u.currentTarget.style.color="#8898A8",u.currentTarget.style.background="transparent"},children:"×"})]})]}),Dt.length>0&&!lo&&(0,e.jsxs)("div",{style:{padding:"6px 16px",borderBottom:"1px solid #0D1520",display:"flex",alignItems:"center",gap:6,overflowX:"auto",flexShrink:0},children:[(0,e.jsx)("span",{style:{fontFamily:n,fontSize:7,color:"#2A3548",letterSpacing:".1em",flexShrink:0},children:"HISTORY"}),Dt.slice(0,8).map(function(u,S){return(0,e.jsx)("button",{onClick:function(){Kk(u)},title:u.text?"Open saved result":"Re-run this search",style:{padding:"3px 10px",background:"rgba(176,188,200,0.03)",border:"1px solid #1E2838",borderRadius:12,cursor:"pointer",fontFamily:"'SF Pro Text',-apple-system,sans-serif",fontSize:10,
538color:"#5A7090",whiteSpace:"nowrap",transition:"all .15s",flexShrink:0},onMouseEnter:function(F){F.currentTarget.style.borderColor="rgba(176,188,200,0.3)",F.currentTarget.style.color="#B0BCC8"},onMouseLeave:function(F){F.currentTarget.style.borderColor="#1E2838",F.currentTarget.style.color="#5A7090"},children:u.query.length>35?u.query.slice(0,35)+"…":u.query},S)})]}),(0,e.jsx)("div",{style:{flex:1,overflow:"auto",padding:"20px 24px"},children:(0,e.jsxs)("div",{style:{maxWidth:760,margin:"0 auto"},children:[wa&&(lo||Yt)&&(0,e.jsx)("div",{style:{marginBottom:20,animation:"xfadein 0.2s ease"},children:(0,e.jsx)("div",{style:{fontSize:18,fontWeight:600,color:"#E6EDF3",fontFamily:"'SF Pro Display','SF Pro Text',-apple-system,sans-serif",lineHeight:1.4},children:wa})}),lo&&vo!=="streaming"&&(0,e.jsx)("div",{style:{padding:"30px 0",animation:"xfadein 0.3s ease"},children:(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,e.jsx)("div",{style:{width:20,height:20,borderRadius:"50%",border:"2px solid rgba(176,188,200,0.3)",borderTopColor:"#B0BCC8",animation:"xspin 0.8s linear infinite"}}),(0,e.jsx)("span",{style:{fontFamily:n,fontSize:9,color:"#B0BCC8",letterSpacing:".1em"},children:vo==="scanning"?"SCANNING LIVE SOURCES":vo==="synthesising"?"SYNTHESISING INTELLIGENCE":"CONNECTING…"})]}),(0,e.jsx)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[{s:"BBG",c:"#FF8800"},{s:"FT",c:"#FFB5A0"},{s:"RTRS",c:"#FF6600"},{s:"WSJ",c:"#B0BCC8"},{s:"FED",c:"#3FB950"},{s:"ECB",c:"#D4AF5C"},{s:"IMF",c:"#FBBF24"},{s:"OECD",c:"#8B949E"}].map(function(u,S){var F=vo==="scanning"?S<4:!0;return(0,e.jsx)("div",{style:{padding:"4px 10px",background:F?"rgba(176,188,200,0.06)":"rgba(176,188,200,0.02)",border:"1px solid "+(F?"rgba(176,188,200,0.2)":"#1E2838"),borderRadius:4,fontFamily:n,fontSize:8,fontWeight:600,color:F?u.c:"#2A3548",letterSpacing:".06em",transition:"all 0.4s",animation:"xfadein 0.3s ease "+S*.08+"s both"},children:u.s},u.s)})}),us>0&&(0,e.jsxs)("div",{style:{fontFamily:n,fontSize:8,color:"#3FB950",letterSpacing:".08em",animation:"xfadein 0.3s ease"},children:["✓"," ",us," sources verified \\u2014 generating brief\\u2026"]})]})}),Mf.active&&(0,e.jsx)("div",{style:{marginBottom:16},children:(0,e.jsx)(i.Suspense,{fallback:null,children:(0,e.jsx)(CS,{state:Mf})})}),vo==="streaming"&&yi&&(0,e.jsx)(Kv,{streaming:!0,text:yi,sources:Au}),Yt&&!lo&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(Kv,{text:Yt.text,sources:Au,images:Dc,videos:ds,followUps:di,onFollowUp:Nd,onOpenVideo:aa}),(0,e.jsx)(fy,{text:Yt.text||"",msgId:"search-"+(Yt.query||"").slice(0,60),sessionId:t.sessionId,accent:"#D4AF5C",onSpeak:xm,speakingId:Ii,onTogglePin:hm,pinnedIds:rt,onRetry:Nd,retryQuestion:Yt.query||wa,onOpenArtifact:function(u){Uo({messageId:"search-"+(Yt.query||""),artifact:u})}})]}),!Yt&&!lo&&vo!=="streaming"&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{style:{textAlign:"center",marginBottom:24},children:[(0,e.jsx)("div",{style:{fontFamily:n,fontSize:7,color:"#2A3548",letterSpacing:".14em",marginBottom:6},children:"POWERED BY ARENBERG INTEL + "+Gn.short+" INTELLIGENCE"}),(0,e.jsx)("div",{style:{fontSize:14,color:"#5A7090",fontFamily:"'SF Pro Text',-apple-system,sans-serif"},children:"Search anything — real-time results with verified sources."})]}),[{cat:"TRENDING",color:"#D4AF5C",items:["Fed rate path Q3 2026","Red Sea shipping disruption update","TSMC earnings semiconductor cycle","European natural gas storage levels"]},{cat:"MARKETS",color:"#B0BCC8",items:["S&P 500 technical outlook","Oil price forecast Q2 2026","USD/EUR exchange rate analysis","Credit spreads investment grade","Gold price drivers","VIX term structure"]},{cat:"GEOPOLITICAL",color:"#C85C5C",items:["Ukraine conflict latest developments","Taiwan strait military activity","OPEC+ production decision","Middle East escalation risk","Sanctions update Russia"]},{cat:"PORTFOLIO",color:"#3FB950",items:["European luxury sector performance","Private credit market outlook","Real estate cap rates 2026","ESG regulation impact","Infrastru
538cture fund returns"]},{cat:"MACRO",color:"#D4AF5C",items:["US CPI inflation data","ECB monetary policy outlook","China economic indicators","Global recession probability","Yield curve analysis"]}].map(function(u){return(0,e.jsxs)("div",{style:{marginBottom:18},children:[(0,e.jsx)("div",{style:{fontFamily:n,fontSize:7,fontWeight:700,color:u.color,letterSpacing:".12em",marginBottom:8,opacity:.7},children:u.cat}),(0,e.jsx)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:u.items.map(function(S){return(0,e.jsx)("button",{onClick:function(){Nd(S)},style:{padding:"6px 12px",background:"rgba("+(u.color==="#D4AF5C"?"245,166,35":u.color==="#B0BCC8"?"0,180,216":u.color==="#C85C5C"?"255,107,107":u.color==="#3FB950"?"63,185,80":"167,139,250")+",0.04)",border:"1px solid rgba("+(u.color==="#D4AF5C"?"245,166,35":u.color==="#B0BCC8"?"0,180,216":u.color==="#C85C5C"?"255,107,107":u.color==="#3FB950"?"63,185,80":"167,139,250")+",0.12)",borderRadius:4,cursor:"pointer",fontFamily:"'SF Pro Text',-apple-system,sans-serif",fontSize:11,color:"#8B949E",transition:"all .15s",textAlign:"left"},onMouseEnter:function(F){F.currentTarget.style.borderColor=u.color+"50",F.currentTarget.style.color="#E6EDF3"},onMouseLeave:function(F){F.currentTarget.style.borderColor="rgba(28,39,64,0.3)",F.currentTarget.style.color="#8B949E"},children:S},S)})})]},u.cat)})]})]})})]})]}),d&&(0,e.jsx)("div",{style:{padding:"2px 16px",background:Rn.bg2,borderTop:"1px solid "+Rn.border,flexShrink:0,display:"flex",justifyContent:"flex-end"},children:(0,e.jsxs)("span",{style:{fontFamily:n,fontSize:7,color:"#3A4A5E"},children:[d.length," chars ~ ",Math.ceil(d.length/4)," tokens"]})}),fi.length>0&&(0,e.jsx)("div",{style:{padding:"6px 16px",background:"rgba(212,175,92,0.05)",borderTop:"1px solid rgba(212,175,92,0.15)",flexShrink:0,display:"flex",flexWrap:"wrap",gap:6,alignItems:"center"},children:fi.filter(function(u){if(!u.parentId)return!0;var S=fi.find(function(F){return F.id===u.parentId});return!S||S.isExpanded}).map(function(u){var S=u.state||(u.isError?"failed":"ready"),F=S==="failed"||!!u.isError,G=S==="uploading"||S==="pending",ce=!!u.truncated,ze=!!u.savedToVault,Ge=!!u.savingToVault,se=F?"rgba(249,117,131,0.10)":G?"rgba(127,165,200,0.10)":ze?"rgba(212,175,92,0.12)":"rgba(212,175,92,0.08)",Ve=F?"rgba(249,117,131,0.40)":ce?"rgba(241,196,15,0.45)":G?"rgba(127,165,200,0.40)":ze?"rgba(212,175,92,0.55)":"rgba(212,175,92,0.2)",Ze=F?"#F97583":"#C9D1D9",yt=!!u.isArchive,xt=!!u.parentId,Qt=F?u.error||"Failed":ce?"Truncated to first 8KB (full size: "+(u.originalSize||"?")+" chars). Phase 13a-3 will route full ingestion via the GCS copy.":G?"Uploading… "+(u.progress||0)+"%":ze?"Saved to Vault"+(u.vaultName?" as "+u.vaultName:""):u.name;return ze&&!Ge?(0,e.jsxs)("div",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",background:"rgba(212,175,92,0.18)",border:"1px solid rgba(212,175,92,0.55)",borderRadius:999,fontFamily:n,fontSize:9,color:"#D4AF5C",marginLeft:xt?16:0},title:"Saved to Vault as "+(u.vaultName||u.name),children:[(0,e.jsx)("span",{children:"📁"}),(0,e.jsx)("span",{style:{maxWidth:120,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u.vaultName||u.name}),(0,e.jsx)("span",{style:{fontSize:7,fontWeight:700,letterSpacing:".1em",opacity:.85},children:"VAULT"}),(0,e.jsx)("button",{onClick:function(){Yx(u.id)},style:{background:"none",border:"none",color:"#D4AF5C",cursor:"pointer",fontSize:11,padding:0,lineHeight:1},"aria-label":"Remove",children:"×"})]},u.id):(0,e.jsxs)("div",{title:Qt,style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",background:se,border:"1px solid "+Ve,borderRadius:6,position:"relative",overflow:"visible",marginLeft:xt?16:0},children:[G&&(0,e.jsx)("div",{"aria-hidden":"true",style:{position:"absolute",left:0,top:0,bottom:0,right:0,overflow:"hidden",borderRadius:6,pointerEvents:"none"},children:(0,e.jsx)("div",{style:{position:"absolute",left:0,top:0,bottom:0,width:(u.progress||0)+"%",background:"rgba(127,165,200,0.18)",transition:"width 120ms linear"}})}),Ge?(0,e.jsxs)(i.Fragment,{children:[(0,e.jsx)("span",{style:{fontFamily:n,fontSize:8,color:"#D4AF5C",letterSpacing:".06em",position:"relative"},children:"VAULT"}),(0,e.jsx)("input",{type:"text",autoFocus:!0,value:u.vaultName!=null?u.vaultName:u.name||"",disabled:!!u.savePending,onChange:function(un){dC(u.id,un.target.value)},onKeyDown:function(un){un.key==="Enter"?(un.preventDefault(),Xx(u.id)):un.key==="Escape"&&(un.preventDefault(),Kx(u.id))},style:{background:"rgba(8,11,17,0.9)",border:"1px solid rgba(212,175,92,0.45)",borderRadius:3,color:"#E2E8F0",fontFamily:n,fontSize:10,padding:"2px 6px",outline:"none",minWidth:140,maxWidth:220,position:"relative"}}
538),u.savePending?(0,e.jsx)("span",{style:{fontSize:10,color:"#D4AF5C",position:"relative",animation:"xspin 1.2s linear infinite",display:"inline-block"},children:"◌"}):(0,e.jsx)("button",{type:"button",onClick:function(){Xx(u.id)},title:"Confirm save","aria-label":"Confirm save",disabled:!!u.savePending,style:{background:"none",border:"none",color:"#3FB950",cursor:"pointer",fontSize:13,padding:0,lineHeight:1,position:"relative"},children:"✓"}),(0,e.jsx)("button",{type:"button",onClick:function(){Kx(u.id)},title:"Cancel","aria-label":"Cancel save",disabled:!!u.savePending,style:{background:"none",border:"none",color:"#5A7090",cursor:"pointer",fontSize:12,padding:0,lineHeight:1,position:"relative"},children:"✕"}),u.saveError&&(0,e.jsx)("span",{style:{fontFamily:n,fontSize:8,color:"#F97583",letterSpacing:".06em",position:"relative"},children:u.saveError.length>40?u.saveError.slice(0,38)+"…":u.saveError})]}):(0,e.jsxs)(i.Fragment,{children:[F&&(0,e.jsx)("span",{style:{fontSize:11,color:"#F97583",position:"relative"},children:"⚠"}),!F&&ce&&(0,e.jsx)("span",{style:{fontSize:11,color:"#F1C40F",position:"relative"},children:"⚠"}),!F&&G&&(0,e.jsx)("span",{style:{fontSize:10,color:"#7FA5C8",position:"relative",animation:"xspin 1.2s linear infinite",display:"inline-block"},children:"◌"}),!F&&S==="ready"&&!G&&yt&&(0,e.jsx)("button",{onClick:function(){fC(u.id)},title:u.isExpanded?"Collapse":"Expand",style:{background:"none",border:"none",color:"#D4AF5C",cursor:"pointer",fontSize:11,padding:0,lineHeight:1,position:"relative"},children:u.isExpanded?"▼":"▶"}),!F&&S==="ready"&&!G&&yt&&(0,e.jsx)("span",{style:{fontSize:11,color:"#D4AF5C",position:"relative"},children:"📁"}),!F&&S==="ready"&&!G&&!yt&&u.isImage&&u.content&&(0,e.jsx)("img",{src:u.content,alt:u.name,style:{width:22,height:22,objectFit:"cover",borderRadius:3,position:"relative"}}),!F&&S==="ready"&&!G&&!yt&&!u.isImage&&(0,e.jsx)("span",{style:{fontFamily:n,fontSize:9,color:ce?"#F1C40F":"#D4AF5C",position:"relative"},children:(u.name||"FILE").split(".").pop().toUpperCase()}),(0,e.jsx)("span",{style:{fontSize:10,color:Ze,maxWidth:140,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",position:"relative"},children:ze&&u.vaultName?u.vaultName:u.name}),!F&&yt&&S==="ready"&&(u.childCount||0)>0&&(0,e.jsxs)("span",{style:{fontFamily:n,fontSize:8,color:"#D4AF5C",letterSpacing:".06em",position:"relative",opacity:.85},children:["(",u.childCount," ",u.childCount===1?"file":"files",")"]}),F&&(0,e.jsx)("span",{style:{fontFamily:n,fontSize:8,color:"#F97583",letterSpacing:".06em",position:"relative"},children:(u.error||"FAILED").length>40?(u.error||"FAILED").slice(0,38)+"…":u.error||"FAILED"}),!F&&G&&(0,e.jsx)("span",{style:{fontFamily:n,fontSize:8,color:"#7FA5C8",letterSpacing:".06em",position:"relative"},children:(u.progress||0)+"%"}),!F&&!G&&S==="ready"&&u.gcsUri&&!ze&&(0,e.jsx)("span",{title:"Stored in GCS",style:{fontFamily:n,fontSize:8,color:"#3FB950",letterSpacing:".06em",position:"relative"},children:"✓"}),!F&&ze&&(0,e.jsx)("span",{title:"Saved to Vault",style:{fontFamily:n,fontSize:8,color:"#D4AF5C",letterSpacing:".06em",padding:"0 4px",border:"1px solid rgba(212,175,92,0.35)",borderRadius:2,position:"relative"},children:"✓ SAVED"}),!F&&u.isVault&&(0,e.jsx)("span",{style:{fontFamily:n,fontSize:7,color:"#3FB950",padding:"0 3px",border:"1px solid rgba(63,185,80,0.2)",borderRadius:2,position:"relative"},children:"VAULT"}),!F&&u.saveError&&!Ge&&(0,e.jsx)("span",{style:{fontFamily:n,fontSize:8,color:"#F97583",letterSpacing:".06em",position:"relative"},children:u.saveError.length>28?u.saveError.slice(0,26)+"…":u.saveError}),F&&Ys.current&&Ys.current.has(u.id)&&(0,e.jsx)("button",{onClick:function(){sC(u.id)},title:"Retry upload",style:{background:"none",border:"none",color:"#7FA5C8",cursor:"pointer",fontSize:13,padding:0,lineHeight:1,position:"relative"},children:"↻"}),(0,e.jsx)(l_,{attachment:u,onSaveToVault:function(){cC(u.id)},onRemove:function(){Yx(u.id)},onPreview:function(){uC(u.id)}})]})]},u.id)})}),(0,e.jsx)("style",{children:`
539@keyframes vidSlideUp { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:translateY(0); } }
540@keyframes xspin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
541`}),(0,e.jsx)(d_,{open:!!Ud,type:Ud&&Ud.type,src:Ud&&Ud.src,name:Ud&&Ud.name,onClose:function(){vm(null)}}),(function(){var u=(t.roomSymbol||t.project)&&Array.isArray(t.roomPromptSuggestions)?t.roomPromptSuggestions.map(function(me){return me&&me.text?me.text:String(me||"")}
541).filter(Boolean).slice(0,9):[],S=Gr?{color:"#B0BCC8",icon:"⌕",label:"SEARCH",placeholder:"Search intelligence sources — markets, geopolitics, macro…",borderColor:"rgba(176,188,200,0.25)",voiceHint:"Search for…",quickPrompts:["Market snapshot","Gold price today","Fed rate decision","S&P 500 outlook","Bitcoin analysis","Geopolitical risk"]}:dr?{color:"#D4AF5C",icon:"▶",label:"VIDEO INTEL",placeholder:"Search videos — topics, companies, channels…",borderColor:"rgba(212,175,92,0.25)",voiceHint:"Search videos for…",quickPrompts:["Apple product launch videos","NVIDIA earnings videos","Fed press conference","Bitcoin analysis videos","Geopolitical risk briefings","Market outlook this week"]}:Qn?{color:"#D4AF5C",icon:"◉",label:"MAP",placeholder:"Ask about the map — regions, layers, risks, patterns…",borderColor:"rgba(212,175,92,0.25)",voiceHint:"Ask about the map…",quickPrompts:["What does the current view show?","Risks on the active layers","Explain the selected event","Compare two regions","What's missing from this view?","Recent shifts in the visible window"]}:Qi?{color:"#D4AF5C",icon:"◈",label:"INTEL",placeholder:"Ask about intelligence signals — news, social, econ, market, sentinel…",borderColor:"rgba(212,175,92,0.25)",voiceHint:"Ask about intel…",quickPrompts:["Connect the dots across feeds","Summarise the selected signal","What contradicts this view?","Asset implications","Confidence read on the source","What changed in the last hour?"]}:nr?{color:"#3FB950",icon:"🔒",label:"VAULT",placeholder:hn?"Ask about: "+hn.name+" — summarise, extract, compare…":"Sovereign Vault active — select a document to analyse…",borderColor:"rgba(63,185,80,0.25)",voiceHint:hn?"Ask about "+hn.name+"…":"Select a document first…",quickPrompts:hn?["Summarise key findings","Extract financial figures","Identify risk clauses","Compare to policy","Draft executive brief","Generate dataset"]:["Summarise a document","Extract key figures","Identify risk clauses","Compare two files","Draft executive brief","Generate dataset"]}:Tr?{color:"#6B9AC4",icon:"✉",label:"EMAIL",placeholder:_r?"Drafting email…":"Type an email command — “Draft email to John about the NDA”",borderColor:"rgba(56,189,248,0.25)",voiceHint:"Email instruction…",quickPrompts:Rl?["Send","Save draft","Amend: make it shorter","Add attachment","Show inbox","Compose new"]:["Draft follow-up to pending threads","Email Baker McKenzie accepting the Paris NDA","Show drafts","Show follow-ups","Reply to the latest from CFO","Show inbox"]}:Er?{color:"#C85C5C",icon:"⚡",label:"COMMAND",placeholder:"Command Library active — select a command or type one…",borderColor:"rgba(200,92,92,0.25)",voiceHint:"Run command…",quickPrompts:["Portfolio NAV","Risk assessment","Market snapshot","Research brief","Document report","Vault search"]}:or?{color:"#3FB950",icon:"▤",label:"PORTFOLIO",placeholder:"Ask "+Gn.name+" — portfolio context active (positions, NAV, risk, forecast)…",borderColor:"rgba(63,185,80,0.25)",voiceHint:"Ask about your portfolio…",quickPrompts:["Portfolio NAV","Risk assessment","Position forecast","Chart allocation","FX exposure","Connect / import positions"]}:qi?{color:"#6B9AC4",icon:"▤",label:"DOC SCAN",placeholder:"Scan or upload a document — extract, translate, summarise…",borderColor:"rgba(107,154,196,0.25)",voiceHint:"Scan a document…",quickPrompts:["Scan with camera","Extract key figures","Translate this page","Save to vault","Compare two files"]}:tr?{color:"#D4AF5C",icon:"▦",label:"INTEL GRAPH",placeholder:"Ask about the Intel Graph — atoms, links, entities, investigations…",borderColor:"rgba(212,175,92,0.25)",voiceHint:"Ask about Intel Graph…",quickPrompts:["Show connected atoms","Create an investigation","Find weak links","Summarise graph changes","Open entity view","Capture this as an atom"]}:er?{color:"#D4AF5C",icon:"◉",label:"VISION",placeholder:"Xyron Vision active — ask about what the camera sees, live…",borderColor:"rgba(212,175,92,0.25)",voiceHint:"Ask Xyron Vision…",quickPrompts:["What am I looking at?","Read this text","Identify this object","Describe the scene","Live transcribe","Capture & analyse"]}:{color:"#D4AF5C",icon:"›",label:t.roomSymbol||Gn.short,placeholder:t.roomSymbol?"Ask "+Gn.name+" about "+t.roomSymbol+" — live chart, asset card, signals, news, intel, exposure…":"Ask "+Gn.name+" anything — markets, portfolio, risk, code, documents, images…",borderColor:Rn.border,voiceHint:t.roomSymbol?"Ask about "+t.roomSymbol+"…":"Ask "+Gn.name+"…",quickPrompts:u.length?u:["Market snapshot","Portfolio NAV","Risk asse
541ssment","Where is the Strait of Hormuz?","Nearby intel around Jebel Ali Port","Private lookup: DIFC Dubai","Gold position","Generate PDF brief","Scan a document","What should I do today?"]},F=!!((t.roomSymbol||t.project)&&u.length&&!Wd&&!Ce&&!Gr&&!dr&&!Qn&&!Qi&&!nr&&!Tr&&!Er&&!or&&!qi&&!tr&&!er),G=typeof Gn<"u"&&Gn&&(Gn.short||"").toUpperCase().indexOf("ARENBERG")!==-1,ce=G?{display:"flex",alignItems:"center",gap:6,paddingTop:9,paddingBottom:3,minHeight:36,borderTop:"1px solid rgba(201,169,97,0.22)",position:"relative",flexWrap:"nowrap",overflowX:"auto",overflowY:"hidden",WebkitOverflowScrolling:"touch"}:{display:"flex",alignItems:"center",gap:3,paddingTop:5,borderTop:"1px solid rgba(28,39,64,0.5)",flexWrap:"nowrap",overflowX:"auto",overflowY:"hidden",WebkitOverflowScrolling:"touch"},ze=G?{fontFamily:n,fontSize:8,color:"#8C7540",letterSpacing:".28em",marginRight:5,userSelect:"none",fontWeight:700,textTransform:"uppercase",flexShrink:0}:{fontFamily:n,fontSize:7,color:"#3A4A5E",letterSpacing:".14em",marginRight:3,userSelect:"none",fontWeight:700,flexShrink:0},Ge=G?"ARENBERG TOOLS":"INTEL",se={position:"relative",marginTop:G?7:0},Ve={position:"absolute",top:0,bottom:0,left:0,width:24,background:"linear-gradient(90deg, "+Rn.bg2+" 0%, transparent 100%)",pointerEvents:"none",zIndex:2},Ze={position:"absolute",top:0,bottom:0,right:0,width:24,background:"linear-gradient(270deg, "+Rn.bg2+" 0%, transparent 100%)",pointerEvents:"none",zIndex:2},yt=fi.some(function(me){return me&&(me.state==="pending"||me.state==="uploading")}),xt=!d.trim()&&!fi.length||f&&!Gr&&!dr&&!Qn&&!Tr||yt,Qt=Gr?"⌕":dr?"▶":Qn?"◉":Tr?"✉":f?"·":"↑";function un(){var me=d.trim();if(Kt&&me){Si(me);return}if(Gr&&me){p(""),An.current="",Nd(me);return}if(dr&&me){p(""),An.current="",Wf(me);return}if(!dr&&me&&!fi.length&&Dx(me)){p(""),An.current="",Wf(me);return}if(Sr){var Ot=fi.filter(function(In){return In.__ledgerBill});if(Ot.length){var Gt=Ot.map(function(In){return Pf.current[In.id]}).filter(Boolean);no(function(In){return In.filter(function(Mn){return!Mn.__ledgerBill})}),Ot.forEach(function(In){delete Pf.current[In.id]}),p(""),An.current="",Vx(Gt,me||"");return}if(me){p(""),An.current="",yr(me,"ledger");return}}if(Qn&&me){p(""),An.current="",yr(me,"map");return}if(Qi&&me){p(""),An.current="",yr(me,"intel");return}if(tr&&me){p(""),An.current="",yr(me,"intelgraph");return}if(or&&me){p(""),An.current="",yr(me,"portfolio");return}if(qi&&me){p(""),An.current="",yr(me,"scanner");return}if(li&&me){p(""),An.current="",yr(me,"realestate");return}if(Tr&&me){p(""),An.current="",p0(me);return}if(Er&&me&&zd.current){p(""),An.current="",zd.current.processCommand(me);return}if(nr&&me){hn&&(fs.current.vault={name:hn.name,content:(hn.content_preview||hn.content||"").substring(0,4e3)}),p(""),An.current="",yr(me,"vault");return}if(Yr&&me){Gf(me);return}Si()}function an(me){if(!vC(me))if(me.key==="Enter"&&!me.shiftKey){me.preventDefault();var Ot=d.trim();if(!Ot)return;if(Kt){Si(Ot);return}if(Gr){p(""),An.current="",Nd(Ot);return}if(dr){p(""),An.current="",Wf(Ot);return}if(!dr&&!fi.length&&Dx(Ot)){p(""),An.current="",Wf(Ot);return}if(Sr){var Gt=fi.filter(function(Mn){return Mn.__ledgerBill});if(Gt.length){var In=Gt.map(function(Mn){return Pf.current[Mn.id]}).filter(Boolean);no(function(Mn){return Mn.filter(function(Vt){return!Vt.__ledgerBill})}),Gt.forEach(function(Mn){delete Pf.current[Mn.id]}),p(""),An.current="",Vx(In,Ot||"");return}if(Ot){p(""),An.current="",yr(Ot,"ledger");return}}if(Qn){p(""),An.current="",yr(Ot,"map");return}if(Qi){p(""),An.current="",yr(Ot,"intel");return}if(tr){p(""),An.current="",yr(Ot,"intelgraph");return}if(or){p(""),An.current="",yr(Ot,"portfolio");return}if(qi){p(""),An.current="",yr(Ot,"scanner");return}if(li){p(""),An.current="",yr(Ot,"realestate");return}if(Tr){p(""),An.current="",p0(Ot);return}if(Er&&zd.current){p(""),An.current="",zd.current.processCommand(Ot);return}if(nr){hn&&(fs.current.vault={name:hn.name,content:(hn.content_preview||hn.content||"").substring(0,4e3)}),p(""),An.current="",yr(Ot,"vault");return}if(Yr){Gf(Ot);return}zx(me)}else zx(me)}function rr(me){if(Kt){Si(me);return}if(Gr){Nd(me);return}if(dr){Wf(me);return}if(t.roomSymbol){Si(me);return}if(Qn){yr(me,"map");return}if(Qi){yr(me,"intel");return}if(tr){yr(me,"intelgraph");return}if(or){yr(me,"portfolio");return}if(qi){yr(me,"scanner");return}if(li){yr(me,"realestate");return}if(Tr){p0(me);return}if(Er&&zd.current){zd.current.processCommand(me);return}if(nr){hn&&(fs.current.vault={name:hn.name,content:(hn.content_preview||hn.content||"").substring(0,4e3)}),yr(me,"vault");return}if(Yr){Gf(me);return}Si(me)}var Pr=null;if(Et||Kn){var lr=function(me){var Ot=Math.floor(me/60),Gt=me%60;return Ot+":"+(Gt<10?"0":"")+Gt};Pr=(0,e.jsxs)("div",{style:{margin:"0 0 8px",padding:"10px 14px",background:Et?"rgba(239,68,68,0.04)":"rgba(212,175,92,0.04)",border:"1px solid "+(Et?"rgba(239,68,68,0.2)":"rgba(212,175,92,0.2)"),borderRadius:10,animation:"xfadein 0.2s ease",overflow:"hidden"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:Cl?6:0},children:[Et&&(0,e.jsx)("div",{style:{width:8,height:8,borderRadius:"50%",background:"#EF4444",boxShadow:"0 0 8px rgba(239,68,68,0.6)",animation:"xpulse 1s infinite",flexShrink:0}}
541),Kn&&(0,e.jsx)("div",{style:{width:10,height:10,border:"2px solid rgba(212,175,92,0.3)",borderTop:"2px solid #D4AF5C",borderRadius:"50%",animation:"xspin 0.8s linear infinite",flexShrink:0}}),(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:8,fontWeight:700,color:Et?"#EF4444":"#D4AF5C",letterSpacing:".12em",flexShrink:0},children:Et?"RECORDING":Kn?"TRANSCRIBING…":""}),Et&&(0,e.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:1,height:28,overflow:"hidden"},children:(dc.length>0?dc:Array(24).fill(3)).map(function(me,Ot){return(0,e.jsx)("div",{style:{width:3,height:me,background:Et?"rgba(239,68,68,"+(.3+me/60)+")":"rgba(212,175,92,0.3)",borderRadius:2,transition:"height 0.08s ease"}},Ot)})}),Kn&&(0,e.jsxs)("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:3},children:[[0,1,2,3,4].map(function(me){return(0,e.jsx)("div",{style:{width:4,height:4,borderRadius:"50%",background:"#D4AF5C",opacity:.3,animation:"xpulse 1.2s infinite",animationDelay:me*.2+"s"}},me)}),(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:9,color:"#D4AF5C",marginLeft:6},children:"Processing with Whisper AI\\u2026"})]}),Et&&(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:10,color:"#EF4444",fontWeight:700,flexShrink:0,minWidth:30,textAlign:"right"},children:lr(nl)}),Et&&(0,e.jsxs)("button",{onClick:Mx,style:{padding:"4px 12px",background:"rgba(239,68,68,0.1)",border:"1px solid rgba(239,68,68,0.3)",borderRadius:6,cursor:"pointer",fontFamily:"monospace",fontSize:8,fontWeight:700,color:"#EF4444",flexShrink:0,display:"flex",alignItems:"center",gap:4},children:[(0,e.jsx)("span",{style:{fontSize:10},children:"⏹"})," STOP"]})]}),Cl&&Et&&(0,e.jsxs)("div",{style:{marginTop:4,padding:"4px 10px",background:"rgba(255,255,255,0.02)",borderRadius:6,border:"1px solid rgba(255,255,255,0.04)",display:"flex",alignItems:"center",gap:6},children:[(0,e.jsx)("span",{style:{fontFamily:"monospace",fontSize:7,color:"#5A7090",letterSpacing:".08em",flexShrink:0},children:"LIVE"}),(0,e.jsx)("span",{style:{width:4,height:4,borderRadius:"50%",background:"#EF4444",animation:"xpulse 1s infinite",flexShrink:0}}),(0,e.jsx)("span",{style:{fontSize:11,color:"#C9D1D9",lineHeight:1.4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Cl.length>100?"…"+Cl.slice(-100):Cl})]})]})}t.roomSymbol;var dt=Sr?"ledger":Qn?"map":Qi?"intel":tr?"intelgraph":nr?"vault":or?"portfolio":qi?"scanner":li?"realestate":Yr?"calendar":null,Cr=!!ur.drawer&&ur.drawer===dt,eo=dt&&Cx[dt]||[],Dr=!!(dt&&Ak[dt]),So=!!dt&&!Dr&&(Cr&&(ur.streaming||!!ur.text||!!ur.err||!!ur.question)||eo.length>0),Ar=Cr?ur.drawer:dt,Pl=Ar==="map"?"#F5A623":"#D4AF5C",ri=ss,Ei=!!Qn,Eo=tr||Ei,Ri={position:"fixed",left:ri.left,bottom:ri.bottom,width:ri.width,zIndex:Eo?56:40,boxSizing:"border-box",overflowY:"auto",overflowX:"hidden",background:Rn.bg2,borderTop:"1px solid "+Rn.border,borderRadius:ri.left===0?"0":"6px 6px 0 0",boxShadow:"0 -8px 26px rgba(0,0,0,0.42)",maxHeight:"calc(100vh - "+(ri.bottom+8)+"px)"};tr?Ri.maxHeight="min(280px, 38vh)":Ei&&(Ri.maxHeight="min(220px, 32vh)");var ha=Ei?{position:"fixed",left:ri.left,width:ri.width,bottom:(ri.bottom||14)+Math.min(Dl,220)+40,zIndex:57,boxSizing:"border-box",pointerEvents:"auto"}:void 0,_a=!!(So||Pr),sn=function(){var me=ur&&ur.question||"";me&&(Io.current=!0,ji(!1),Md(),Tu(function(Ot){var Gt=Object.assign({},Ot);return Gt.ledger=!0,Gt}),Si(me))},Hn=function(){var me=ur&&ur.chartPng||null;!me||!me.entityId||!me.kind||dn.chartPng(me.entityId,me.kind,{period:me.period||null}).then(function(Ot){if(!(!Ot||Ot.error||!Ot.blob)){var Gt=URL.createObjectURL(Ot.blob),In=document.createElement("a");In.href=Gt,In.download=Ot.filename||me.kind+".png",In.click(),URL.revokeObjectURL(Gt)}}).catch(function(){})};return(0,e.jsxs)("div",{className:"xy-chat-footer",style:{borderTop:"none",background:"transparent",flexShrink:0,position:"relative",zIndex:Eo?55:10},children:[(0,e.jsxs)("div",{style:{width:"100%",maxWidth:769,margin:"0 auto",padding:_a&&!Ei?"4px 12px 8px":"0",boxSizing:"border-box"},children:[Pr,(0,e.jsx)("div",{"data-testid":Ei?"map-analysis-overlay":void 0,style:ha,children:(0,e.jsx)(dT,{visible:So,activeDrawer:Ar,accentColor:Pl,streaming:Cr&&ur.streaming,phase:Cr&&ur.phase||"",streamText:Cr?ur.text:"",citations:Cr?ur.citations:[],err:Cr?ur.err:"",lastQuestion:Cr?ur.question:"",onOpenInChat:Ar==="ledger"&&Cr&&ur.question?sn:void 0,openInChatLabel:"↗ XYRON CHAT",chartPngUrl:Ar==="ledger"&&Cr&&ur.chartPng?ur.chartPng.url:"",onDownloadChartPng:Ar==="ledger"&&Cr&&ur.chartPng?Hn:void 0,onNewChat:Yk,onDismiss:function(){Md(),Ar&&Tu(function(me){var Ot=Object.assign({},me);return Ot[Ar]=!0,Ot})},history:Ar==="calendar"?[]:Cx[Ar]||[],onLoadHistory:wk,onClearHistory:function(){Ar&&jk(Ar)},followUps:Cr?ur.followUps||[]:[],onFollowUp:function(me){Ar&&yr(me,Ar)},cortexSuggest:Cr&&!ur.streaming&&!!ur.cortexSuggest&&!kr,onEnableCortex:function(){gi(!0);var me=ur.question;Ar&&me&&setTimeout(function(){yr(me,Ar)},0)},turns:Ar==="calendar"?[]:Ar==="ledger"?kk:Ck,extraContent:Ar==="calendar"&&Cr?(0,e.jsx)(y3,{state:ro.state,onSelect:function(me){ro.select(me),Tc(Object.assign({},me,{owner:ro.state.owner,_ts:Date.now()}))},onAsk:Gf,onConfirm:ro.confirm,onDismissProposal:ro.dismissProposal}):null,artifact:Cr&&ur.artifact||null,sessionId:t.sessionId,routeDecisionId:Cr&&ur.routeDecisionId||null,onSpeak:xm,speakingId:Ii,onTogglePin:hm,pinnedIds:rt,onRetry:function(me){Ar&&yr(me||ur.question,Ar)},onOpenArtifact:function(me){Uo({messageId:ur.question||"drawer",artifact:me})},maxHeightVh:tr?20:Ei?42:34,artifactMaxHeightVh:tr?28:void 0,defaultMinimized:!!tr,expandOnQuestion:!!tr||Ei},tr?"ig-console":Ei?"map-console":"drawer-console")}),hn&&nr&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6,padding:"5px 10px",background:"rgba(63,185,80,0.12)",border:"1px solid rgba(63,185,80,0.45)",borderRadius:6}
541,children:[(0,e.jsx)("span",{style:{fontFamily:n,fontSize:10,color:"#3FB950",letterSpacing:".12em",fontWeight:800},children:"📌 PINNED"}),(0,e.jsx)("span",{style:{fontFamily:n,fontSize:10,color:"#C9D1D9",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:hn.name,children:hn.name}),(0,e.jsx)("button",{onClick:function(){hi(null)},title:"Unpin document",style:{background:"none",border:"1px solid rgba(63,185,80,0.35)",color:"#3FB950",cursor:"pointer",fontFamily:n,fontSize:10,fontWeight:700,padding:"1px 6px",borderRadius:4},children:"✕"})]}),Tr&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,marginBottom:6,flexWrap:"wrap",position:"relative"},children:[i.createElement("div",{style:{position:"relative"}},i.createElement("button",{onClick:function(){Go(!md),ca(!1)},style:{padding:"3px 10px",background:"rgba(212,175,92,0.1)",border:"1px solid rgba(212,175,92,0.25)",borderRadius:10,cursor:"pointer",fontFamily:n,fontSize:8,color:"#D4AF5C",letterSpacing:".04em",transition:"all .12s"}},(r.find(function(me){return me.id===Ga})||r[0]).label+" ▾"),md&&i.createElement("div",{style:{position:"absolute",bottom:"100%",left:0,marginBottom:4,background:"#06080F",border:"1px solid #111820",borderRadius:6,padding:4,zIndex:200,boxShadow:"0 8px 24px rgba(0,0,0,.6)",display:"flex",flexWrap:"wrap",gap:2,width:220}},r.map(function(me){return i.createElement("button",{key:me.id,onClick:function(){Cc(me.id),Go(!1)},style:{padding:"2px 8px",background:Ga===me.id?"rgba(212,175,92,0.15)":"transparent",border:"1px solid "+(Ga===me.id?"rgba(212,175,92,0.35)":"transparent"),borderRadius:10,cursor:"pointer",fontFamily:n,fontSize:7,color:Ga===me.id?"#D4AF5C":"#3A4A5E",whiteSpace:"nowrap",transition:"all .12s"}},me.label)}))),i.createElement("div",{style:{position:"relative"}},i.createElement("button",{onClick:function(){ca(!hd),Go(!1)},style:{padding:"3px 10px",background:"rgba(56,189,248,0.08)",border:"1px solid rgba(56,189,248,0.2)",borderRadius:10,cursor:"pointer",fontFamily:n,fontSize:8,color:"#6B9AC4",letterSpacing:".04em",transition:"all .12s"}},(o.find(function(me){return me.id===Ms})||o[0]).label+" ▾"),hd&&i.createElement("div",{style:{position:"absolute",bottom:"100%",left:0,marginBottom:4,background:"#06080F",border:"1px solid #111820",borderRadius:6,padding:4,zIndex:200,boxShadow:"0 8px 24px rgba(0,0,0,.6)",display:"flex",flexWrap:"wrap",gap:2,width:200}},o.map(function(me){return i.createElement("button",{key:me.id,onClick:function(){cl(me.id),ca(!1)},style:{padding:"2px 8px",background:Ms===me.id?"rgba(56,189,248,0.15)":"transparent",border:"1px solid "+(Ms===me.id?"rgba(56,189,248,0.35)":"transparent"),borderRadius:10,cursor:"pointer",fontFamily:n,fontSize:7,color:Ms===me.id?"#6B9AC4":"#3A4A5E",whiteSpace:"nowrap",transition:"all .12s"}},me.label)}))),Rl&&i.createElement(i.Fragment,null,i.createElement("div",{style:{width:1,height:14,background:"#1E2838",margin:"0 2px"}}),["warmer","shorter","assertive","executive"].map(function(me){return i.createElement("button",{key:me,onClick:function(){p0(me)},disabled:f,style:{padding:"2px 8px",background:"transparent",border:"1px solid transparent",borderRadius:8,cursor:f?"not-allowed":"pointer",fontFamily:n,fontSize:8,color:"#3A4A5E",transition:"all .12s"},onMouseEnter:function(Ot){Ot.currentTarget.style.borderColor="rgba(212,175,92,0.25)",Ot.currentTarget.style.color="#D4AF5C"},onMouseLeave:function(Ot){Ot.currentTarget.style.borderColor="transparent",Ot.currentTarget.style.color="#3A4A5E"}},me)})),(md||hd)&&i.createElement("div",{onClick:function(){Go(!1),ca(!1)},style:{position:"fixed",inset:0,zIndex:199}})]})]}),(0,e.jsx)("div",{"aria-hidden":"true",style:{height:Math.max(Dl+2,144),flexShrink:0,boxSizing:"border-box",pointerEvents:"none"}}),(0,e.jsx)("div",{ref:Ad,className:"xy-composer-shell"+(tr?" xy-composer-shell--ig-dock":""),style:Ri,children:(0,e.jsxs)("div",{style:{width:"100%",padding:"4px 10px 6px",boxSizing:"border-box",position:"relative",zIndex:1},children:[!G&&(function(){var me=typeof Hl<"u"&&Array.isArray(Hl)?new Set(Hl):null,Ot=!me||me.has("council"),Gt=Ca==="on"?"ON":"OFF",In=Ca==="on"?"Xyron Council ON - convenes a multi-seat council on each query. Click to turn off.":"Xyron Council OFF - click to convene a multi-seat council per query (billable).";function Mn(){Fc(Ca==="on"?"off":"on")}var Vt=nn.filter(function(Xn){return!Zr[Xn.id]}),fn=Vt[0]||null,At=Vt.length,Dn=su(),zt=fn?fn.sev==="critical"?"#D44040":fn.sev==="high"?I.warn:I.ink5:I.ink5;function ki(Xn){if(Xn){var Mo="Execute the AI recommendation: "+Xn.action+`.
542
543Context: `+Xn.headline+`.
544Confirm pre-trade dryrun, surface risk preview, and report fills.`;
544try{p(Mo),An.current=Mo}catch{}try{Si(Mo)}catch{}Wl(Xn.id)}}function Sn(Xn){if(Xn){var Mo="Why this recommendation: "+Xn.action+`.
545
546Alert: `+Xn.headline+". Walk me through the institutional reasoning, downside scenarios, position impact, and confidence drivers.";try{p(Mo),An.current=Mo}catch{}try{Si(Mo)}catch{}}}function Ul(Xn){Xn&&Wl(Xn.id)}function Wl(Xn){Mi(function(Mo){var Ra=Object.assign({},Mo);Ra[Xn]=!0;try{localStorage.setItem("xyron.today.muted",JSON.stringify(Ra))}catch{}return Ra});try{window.dispatchEvent(new CustomEvent("xyron:today-mute",{detail:{id:Xn}}))}catch{}}function sr(Xn){var Mo=Xn.tone==="gold"?"rgba(212,175,92,0.10)":"transparent",Ra=Xn.tone==="gold"?"rgba(212,175,92,0.40)":"rgba(143,163,184,0.20)",Fu=Xn.tone==="gold"?I.gold:I.ink3;return i.createElement("button",{onClick:Xn.onClick,title:Xn.title,style:{padding:"2px 9px",background:Mo,border:"1px solid "+Ra,borderRadius:3,cursor:"pointer",fontFamily:I.mono,fontSize:9.5,letterSpacing:"0.14em",color:Fu,fontWeight:Xn.tone==="gold"?700:600,whiteSpace:"nowrap",transition:"all 140ms "+I.ease}},Xn.children)}var gs=tr?null:i.createElement("button",{onClick:function(){ua(!Bn)},title:Bn?"Expand decision block":"Collapse decision block","aria-label":Bn?"Expand":"Collapse",style:{background:"transparent",border:"1px solid rgba(212,175,92,0.20)",borderRadius:3,padding:"2px 7px",fontFamily:I.mono,fontSize:10,color:I.gold,cursor:"pointer",lineHeight:1,flexShrink:0,transition:"all 150ms "+I.ease},onMouseEnter:function(Xn){Xn.currentTarget.style.borderColor="rgba(212,175,92,0.55)",Xn.currentTarget.style.background="rgba(212,175,92,0.06)"},onMouseLeave:function(Xn){Xn.currentTarget.style.borderColor="rgba(212,175,92,0.20)",Xn.currentTarget.style.background="transparent"}},Bn?"▾":"▴");return Bn?(0,e.jsxs)("div",{className:"xy-ask-collapsed",style:{display:"flex",alignItems:"center",gap:10,padding:"3px 0 5px",userSelect:"none",fontFamily:I.mono,fontSize:11,lineHeight:1.4,transition:"all 150ms "+I.ease},children:[(0,e.jsx)("span",{style:{color:I.gold,letterSpacing:"0.20em",fontWeight:700,flexShrink:0},children:"ASK XYRON"}),(0,e.jsx)("span",{style:{color:I.ink5,flexShrink:0},children:"·"}),fn?(0,e.jsxs)("span",{style:{color:I.ink2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"1 1 auto",minWidth:0},children:[(0,e.jsx)("span",{style:{color:zt,fontWeight:700,marginRight:6},children:"◇"}),(0,e.jsx)("span",{style:{fontWeight:700,letterSpacing:"0.04em"},children:fn.label}),Dn?(0,e.jsx)("span",{style:{color:I.warn,fontSize:9,fontWeight:700,marginLeft:7,letterSpacing:"0.10em"},children:"SIMULATED"}):null,(0,e.jsx)("span",{style:{color:I.ink5,margin:"0 6px"},children:"—"}),(0,e.jsxs)("span",{style:{color:I.ink5,fontSize:10}
546,children:[At," ",At===1?"decision pending":"decisions pending"]})]}):(0,e.jsxs)("span",{style:{color:I.up,fontWeight:600,letterSpacing:"0.08em",flex:"1 1 auto",minWidth:0},children:["○"," ",Dn?"all simulated decisions cleared":"verified decision provider unavailable"]}),(0,e.jsxs)("span",{className:"xy-ask-extras",style:{display:"inline-flex",alignItems:"center",gap:6,flexShrink:0},children:[(0,e.jsx)(sp,{compact:!0,chatMode:de,signal:_e,activeDrawer:li?"realestate":Qn?"map":kr?"portfolio":null,streaming:!!f}),(0,e.jsx)("span",{style:{color:I.down,fontWeight:600,fontSize:10},children:"WEB"}),(0,e.jsx)("button",{"data-testid":"xyron-web-search-toggle",onClick:kc,"aria-pressed":Ai!=="off","aria-label":"Web search "+Ha,title:"Web search - "+Ha+" (controls web search only; image/code/artifact generation unaffected)",style:{padding:"2px 8px",background:Ai!=="off"?"rgba(212,175,92,0.10)":"rgba(127,165,200,0.03)",border:"1px solid "+(Ai!=="off"?"rgba(212,175,92,0.42)":I.hairline2),borderRadius:3,cursor:"pointer",fontFamily:I.mono,fontSize:10,letterSpacing:"0.18em",color:Ai!=="off"?I.gold:I.ink4,fontWeight:700,transition:"all 150ms "+I.ease},children:Ha})]}),Ot&&(0,e.jsxs)("span",{className:"xy-ask-extras",style:{display:"inline-flex",alignItems:"center",gap:6,flexShrink:0},children:[(0,e.jsx)("span",{style:{color:I.down,fontWeight:600,fontSize:10},children:"XYRON COUNCIL"}),(0,e.jsx)("button",{"data-testid":"xyron-council-toggle",onClick:Mn,"aria-pressed":zo,"aria-label":"Xyron Council "+Gt,title:In,style:{padding:"2px 8px",background:zo?"rgba(212,175,92,0.10)":"rgba(127,165,200,0.03)",border:"1px solid "+(zo?"rgba(212,175,92,0.42)":I.hairline2),borderRadius:3,cursor:"pointer",fontFamily:I.mono,fontSize:10,letterSpacing:"0.18em",color:zo?I.gold:I.ink4,fontWeight:700,transition:"all 150ms "+I.ease},children:Gt})]}),gs]}):(0,e.jsxs)("div",{className:"xy-ask-expanded",style:{display:"flex",alignItems:"flex-start",gap:12,padding:"4px 0 6px",userSelect:"none"},children:[(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4,flexShrink:0},children:[(0,e.jsxs)("div",{style:{fontFamily:I.mono,fontSize:11,color:I.gold,letterSpacing:"0.20em",fontWeight:700,lineHeight:1.25},children:["ASK",(0,e.jsx)("br",{}),"XYRON"]}),(0,e.jsxs)("button",{onClick:function(){try{window.dispatchEvent(new CustomEvent("xyron:open-history"))}catch{}},title:"Open chat history (⌘⇧H)",style:{background:"transparent",border:"1px solid rgba(212,175,92,0.20)",borderRadius:3,padding:"1px 6px",fontFamily:I.mono,fontSize:9,letterSpacing:"0.10em",color:I.gold,cursor:"pointer",lineHeight:1.4},children:["⧗"," hist"]})]}),(0,e.jsxs)("div",{onMouseEnter:function(){m(!0)},onMouseLeave:function(){m(!1)},style:{flex:"1 1 auto",minWidth:0,display:"flex",flexDirection:"column",gap:3,fontFamily:I.mono,lineHeight:1.4},children:[fn?(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:11,minWidth:0},children:[(0,e.jsx)("span",{style:{color:zt,fontWeight:700,flexShrink:0},children:"◇"}),(0,e.jsx)("span",{style:{color:I.ink1,fontWeight:700,letterSpacing:"0.04em",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:fn.label}),Dn?(0,e.jsx)("span",{style:{color:I.warn,fontSize:9,fontWeight:700,letterSpacing:"0.10em",flexShrink:0},children:"SIMULATED"}):null,(0,e.jsx)("span",{style:{color:I.ink5,flexShrink:0},children:"—"}),(0,e.jsx)("span",{style:{color:I.ink4,fontSize:10,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,flex:"0 1 auto"},children:fn.sub}),(0,e.jsxs)("span",{style:{display:"inline-flex",gap:4,marginLeft:"auto",flexShrink:0},children:[i.createElement(sr,{tone:"gold",onClick:function(){ki(fn)},title:"Execute · pre-trade dryrun first"},"yes"),i.createElement(sr,{onClick:function(){Ul(fn)},title:"Defer for now"},"hold"),i.createElement(sr,{onClick:function(){Sn(fn)},title:"Explain reasoning"},"why")]})]}):(0,e.jsxs)("div",{style:{fontSize:11,color:I.up,fontWeight:600,letterSpacing:"0.08em"},children:["○"," ",Dn?"all simulated decisions cleared":"verified decision provider unavailable"]}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:10,
546color:I.ink3,letterSpacing:"0.04em",minWidth:0},children:[(0,e.jsx)("span",{style:{color:I.gold,flexShrink:0,fontSize:9},children:"↑"}),(0,e.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,animation:"xy-stagger-in 320ms cubic-bezier(.16,.84,.24,1)"},children:En[ti]},ti)]}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:9.5,color:I.ink5,letterSpacing:"0.10em",flexWrap:"wrap"},children:[(0,e.jsx)("button",{onClick:function(){ai(!1),Tt(!0)},title:"Voice mode — hold to talk (Claude + ElevenLabs)",style:{padding:"1px 8px",background:"rgba(212,175,92,0.06)",border:"1px solid rgba(212,175,92,0.28)",borderRadius:3,cursor:"pointer",fontFamily:I.mono,fontSize:9.5,letterSpacing:"0.10em",color:I.gold,fontWeight:600},children:"🎙 talk"}),(0,e.jsx)("button",{onClick:function(){Tt(!1),ai(!0)},title:"Sonic - live hands-free voice (Gemini Live)",style:{padding:"1px 8px",background:"rgba(91,168,160,0.06)",border:"1px solid rgba(91,168,160,0.32)",borderRadius:3,cursor:"pointer",fontFamily:I.mono,fontSize:9.5,letterSpacing:"0.10em",color:"#5BA8A0",fontWeight:600},children:"⚡ sonic"}),(0,e.jsx)("span",{style:{color:I.ink5},children:"·"}),(0,e.jsxs)("span",{children:[At," ",At===1?"decision queued":"decisions queued"]}),(0,e.jsxs)("span",{style:{marginLeft:"auto",display:"inline-flex",alignItems:"center",gap:6,flexWrap:"wrap",position:"relative"},children:[(0,e.jsx)("span",{"data-testid":"xyron-auto-mode",style:{display:"inline-flex",minWidth:0},children:(0,e.jsx)(sp,{compact:!0,chatMode:de,signal:_e,activeDrawer:li?"realestate":Qn?"map":kr?"portfolio":null,streaming:!!f})}),(0,e.jsx)("span",{style:{color:I.ink5,margin:"0 2px"},children:"·"}),(0,e.jsx)("span",{style:{color:I.down,fontWeight:600},children:"WEB"}),(0,e.jsx)("button",{"data-testid":"xyron-web-search-toggle",onClick:kc,"aria-pressed":Ai!=="off","aria-label":"Web search "+Ha,title:"Web search - "+Ha+" (control
546s web search only; image/code/artifact generation unaffected)",style:{padding:"2px 8px",background:Ai!=="off"?"rgba(212,175,92,0.10)":"rgba(127,165,200,0.03)",border:"1px solid "+(Ai!=="off"?"rgba(212,175,92,0.42)":I.hairline2),borderRadius:3,cursor:"pointer",fontFamily:I.mono,fontSize:10,letterSpacing:"0.18em",color:Ai!=="off"?I.gold:I.ink4,fontWeight:700,transition:"all 150ms "+I.ease},children:Ha}),Ot&&(0,e.jsxs)(i.Fragment,{children:[(0,e.jsx)("span",{style:{color:I.ink5,margin:"0 2px"},children:"·"}),(0,e.jsx)("span",{style:{color:I.down,fontWeight:600},children:"XYRON COUNCIL"}),(0,e.jsx)("button",{"data-testid":"xyron-council-toggle",onClick:Mn,"aria-pressed":zo,"aria-label":"Xyron Council "+Gt,title:In,style:{padding:"2px 8px",background:zo?"rgba(212,175,92,0.10)":"rgba(127,165,200,0.03)",border:"1px solid "+(zo?"rgba(212,175,92,0.42)":I.hairline2),borderRadius:3,cursor:"pointer",fontFamily:I.mono,fontSize:10,letterSpacing:"0.18em",color:zo?I.gold:I.ink4,fontWeight:700,transition:"all 150ms "+I.ease},children:Gt})]})]})]})]}),(0,e.jsx)("div",{style:{display:"flex",alignItems:"flex-start",flexShrink:0,paddingTop:2},children:gs})]})})(),(0,e.jsx)("div",{style:{background:I.bg1,border:"1px solid "+I.hairline2,borderTop:"1px solid "+I.goldDeep,borderRadius:3,transition:"border-color 160ms "+I.ease,display:"block",width:"100%",maxWidth:769,margin:"0 auto"},children:(0,e.jsxs)("div",{style:{width:"100%",display:"flex",flexDirection:"column",position:"relative"},children:[(0,e.jsx)("input",{ref:cm,type:"file",multiple:!0,accept:".txt,.pdf,.csv,.docx,.doc,.xlsx,.json,.py,.js,.ts,.html,.css,.md,image/*",onChange:function(me){me.target.files&&me.target.files.length&&Px(Array.from(me.target.files)),me.target.value=""},style:{display:"none"}}),ba&&typeof import.meta<"u"&&!1,W!==Ln.IDLE&&(0,e.jsx)("div",{style:{padding:"6px 14px 0",display:"flex",alignItems:"center",gap:8},children:(0,e.jsx)(oF,{state:W})}),F&&(0,e.jsxs)("div",{style:{padding:"8px 12px 2px"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:10,marginBottom:7},children:[(0,e.jsxs)("span",{style:{fontFamily:I.mono,fontSize:8,fontWeight:700,letterSpacing:".18em",color:I.ink4,textTransform:"uppercase"},children:[t.roomSymbol," institutional prompts"]}),(0,e.jsx)("span",{style:{fontFamily:I.mono,fontSize:8,color:I.ink5,whiteSpace:"nowrap"},children:"asset-class generated"})]}),(0,e.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(230px, 1fr))",gap:6,maxHeight:126,overflowY:"auto",paddingRight:2},children:u.map(function(me,Ot){return(0,e.jsxs)("button",{type:"button",onClick:function(){rr(me)},disabled:f,style:{minHeight:34,textAlign:"left",padding:"7px 9px",background:"rgba(212,175,92,0.035)",border:"1px solid rgba(212,175,92,0.14)",borderRadius:5,color:f?I.ink5:I.ink2,cursor:f?"not-allowed":"pointer",fontFamily:I.sans,fontSize:11,lineHeight:1.32,overflow:"hidden"},onMouseEnter:function(Gt){f||(Gt.currentTarget.style.borderColor="rgba(212,175,92,0.34)",Gt.currentTarget.style.background="rgba(212,175,92,0.075)")},onMouseLeave:function(Gt){Gt.currentTarget.style.borderColor="rgba(212,175,92,0.14)",Gt.currentTarget.style.background="rgba(212,175,92,0.035)"},children:[(0,e.jsx)("span",{style:{fontFamily:I.mono,fontSize:9,color:I.gold,marginRight:7},children:String(Ot+1).padStart(2,"0")}),me]},me)})})]}),(function(){var me=pd.filter(function(zt){return ci[zt]&&(ci[zt].on===!0||al.indexOf(zt)!==-1)}),Ot=Array.isArray(t.chatDock)?t.chatDock:[],Gt=!!t.chatMinimized,In=!!t.roomsMinimized,Mn=!!t.orderFlowMinimized,Vt=!!t.projectsMinimized,fn=!!t.auditMinimized,At=!!t.briefsMinimized;if(me.length===0&&Ot.length===0&&!Gt&&!In&&!Mn&&!Vt&&!fn&&!At)return null;var Dn={background:"rgba(255,255,255,0.06)",border:"none",padding:"1px 6px",margin:0,cursor:"pointer",fontFamily:I.mono,fontSize:13,lineHeight:1,color:"inherit",borderRadius:3};return(0,e.jsxs)("div",{className:"xy-rail-scroll",style:{display:"flex",alignItems:"center",gap:6,padding:"5px 12px",overflowX:"auto",overflowY:"hidden",WebkitOverflowScrolling:"touch",borderTop:"0.5px solid "+I.hairline,background:"rgba(0,0,0,0.18)"},children:[Gt&&(0,e.jsxs)("div",{onClick:function(){typeof t.onRestoreChatSurface=="function"&&t.onRestoreChatSurface()},title:"Restore Chat",style:{display:"inline-flex",alignItems:"center",gap:5,flexShrink:0,padding:"3px 8px",borderRadius:5,whiteSpace:"nowrap",fontFamily:I.mono,fontSize:9,fontWeight:700,letterSpacing:"0.12em",cursor:"pointer",background:"rgba(96,165,250,0.10)",border:"0.5px solid rgba(96,165,250,0.5)",color:"#93C5FD"},children:[(0,e.jsx)("span",{style:{flexShrink:0},children:"◈"}),(0,e.jsx)("span",{children:"CHAT"}),(0,e.jsx)("button",{type:"button",title:"Close Chat",onClick:function(zt){zt.stopPropagation(),typeof t.onCloseChatSurface=="function"&&t.onCloseChatSurface()},style:Dn,children:"✕"})]},"chat:dock"),In&&(0,e.jsxs)("div",{onClick:function(){typeof t.onRestoreRoom=="function"&&t.onRestoreRoom()},title:"Restore Rooms",style:{display:"inline-flex",alignItems:"center",gap:5,flexShrink:0,padding:"3px 8px",borderRadius:5,whiteSpace:"nowrap",fontFamily:I.mono,fontSize:9,fontWeight:700,letterSpacing:"0.12em",cursor:"pointer",background:"rgba(139,124,246,0.10)",border:"0.5px solid rgba(139,124,246,0.5)",color:"#B7ACF6"},children:[(0,e.jsx)("span",{style:{flexShrink:0},children:"▣"}),(0,e.jsx)("span",{children:"ROOMS"}),(0,e.jsx)("button",{type:"button",title:"Close Rooms",onClick:function(zt){zt.stopPropagation(),typeof t.onCloseRoom=="function"&&t.onCloseRoom()},style:Dn,children:"✕"})]},"rooms:dock"),Mn&&(0,e.jsxs)("div",{onClick:function(){typeof t.onRestoreOrderFlow=="function"&&t.onRestoreOrderFlow()},title:"Restore Order Flow",style:{display:"inline-flex",alignItems:"center",gap:5,flexShrink:0,padding:"3px 8px",borderRadius:5,whiteSpace:"nowrap",fontFamily:I.mono,fontSize:9,fontWeight:700,letterSpacing:"0.12em",cursor:"pointer",background:"rgba(245,158,11,0.10)",border:"0.5px solid rgba(245,158,11,0.5)",color:"#FBBF24"},children:[(0,e.jsx)("span",{style:{flexShrink:0},children:"▥"}),(0,e.jsx)("span",{children:"ORDER FLOW"}),(0,e.jsx)("button",{type:"button",title:"Close Order Flow",onClick:function(zt){zt.stopPropagation(),typeof t.onCloseOrderFlow=="function"&&t.onCloseOrderFlow()},style:Dn,children:"✕"})]},"orderflow:dock"),Vt&&(0,e.jsxs)("div",{onClick:function(){typeof t.onRestoreProject=="function"&&t.onRestoreProject()},title:"Restore Projects",style:{display:"inline-flex",alignItems:"center",gap:5,flexShrink:0,padding:"3px 8px",borderRadius:5,whiteSpace:"nowrap",fontFamily:I.mono,fontSize:9,fontWeight:700,letterSpacing:"0.12em",cursor:"pointer",background:"rgba(212,175,92,0.10)",border:"0.5px solid rgba(212,175,92,0.5)",color:"#D4AF5C"},children:[(0,e.jsx)("span",{style:{flexShrink:0},children:"◇"}),(0,e.jsx)("span",{children:"PROJECTS"}),(0,e.jsx)("button",{type:"button",title:"Close Projects",onClick:function(zt){zt.stopPropagation(),typeof t.onCloseProject=="function"&&t.onCloseProject()},style:Dn,children:"✕"})]},"projects:dock"),fn&&(0,e.jsxs)("div",{onClick:function(){typeof t.onRestoreAudit=="function"&&t.onRestoreAudit()},title:"Restore Audit",style:{display:"inline-flex",alignItems:"center",gap:5,flexShrink:0,padding:"3px 8px",borderRadius:5,whiteSpace:"nowrap",fontFamily:I.mono,fontSize:9,fontWeight:700,letterSpacing:"0.12em",cursor:"pointer",background:"rgba(143,163,191,0.10)",border:"0.5px solid rgba(143,163,191,0.5)",color:"#8FA3BF"},children:[(0,e.jsx)("span",{style:{flexShrink:0},children:"○"}),(0,e.jsx)("span",{children:"AUDIT"}),(0,e.jsx)("button",{type:"button",title:"Close Audit",onClick:function(zt){zt.stopPropagation(),typeof t.onCloseAudit=="function"&&t.onCloseAudit()},style:Dn,children:"✕"})]},"audit:dock"),At&&(0,e.jsxs)("div",{onClick:function(){typeof t.onRestoreBriefs=="function"&&t.onRestoreBriefs()},title:"Restore Briefs",style:{display:"inline-flex",alignItems:"center",gap:5,flexShrink:0,padding:"3px 8px",borderRadius:5,whiteSpace:"nowrap",fontFamily:I.mono,fontSize:9,fontWeight:700,letterSpacing:"0.12em",cursor:"pointer",background:"rgba(94,234,212,0.08)",border:"0.5px solid rgba(94,234,212,0.45)",color:"#5EEAD4"},children:[(0,e.jsx)("span",{style:{flexShrink:0},children:"☀"}),(0,e.jsx)("span",{children:"BRIEFS"}),(0,e.jsx)("button",{type:"button",title:"Close Briefs",onClick:function(zt){zt.stopPropagation(),typeof t.onCloseBriefs=="function"&&t.onCloseBriefs()},style:Dn,children:"✕"})]},"briefs:dock"),Ot.map(function(zt){if(!zt||!zt.id)return null;var ki=zt.title&&String(zt.title)||"Chat";return(0,e.jsxs)("div",{onClick:function(){typeof t.onRestoreChat=="function"&&t.onRestoreChat(zt.id)},title:"Restore chat: "+ki,style:{display:"inline-flex",alignItems:"center",gap:5,flexShrink:0,padding:"3px 8px",borderRadius:5,whiteSpace:"nowrap",fontFamily:I.mono,fontSize:9,fontWeight:700,letterSpacing:"0.12em",cursor:"pointer",background:"rgba(56,189,168,0.06)",border:"0.5px solid rgba(56,189,168,0.45)",color:"#5EEAD4",maxWidth:180,overflow:"hidden"},children:[(0,e.jsx)("span",{style:{flexShrink:0},children:"◈"}),(0,e.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:ki}),(0,e.jsx)("button",{type:"button",title:"Close chat "+ki,onClick:function(Sn){Sn.stopPropagation(),typeof t.onCloseChat=="function"&&t.onCloseChat(zt.id)},style:Dn,children:"✕"})]},"chat:"+zt.id)}),me.map(function(zt){var ki=ci[zt],Sn=ki.on===!0;return(0,e.jsxs)("div",{onClick:Sn?void 0:function(){vu(zt)},title:Sn?ki.label+" (active)":"Restore "+ki.label,style:{display:"inline-flex",alignItems:"center",gap:5,flexShrink:0,padding:"3px 8px",borderRadius:5,whiteSpace:"nowrap",fontFamily:I.mono,fontSize:9,fontWeight:700,letterSpacing:"0.12em",cursor:Sn?"default":"pointer",background:Sn?"rgba(212,175,92,0.10)":"rgba(255,255,255,0.03)",border:"0.5px solid "+(Sn?"#D4AF5C":I.hairline2),color:Sn?"#D4AF5C":I.ink4},children:[(0,e.jsx)("span",{children:ki.label}),Sn&&(0,e.jsx)("button",{type:"button",title:"Minimize "+ki.label,onClick:function(Ul){Ul.stopPropagation(),Ed(zt)},style:Dn,children:"–"}),(0,e.jsx)("button",{type:"button",title:"Close "+ki.label,onClick:function(Ul){Ul.stopPropagation(),bu(zt)},style:Dn,children:"✕"})]},zt)})]})})(),ga?(0,e.jsx)(uT,{kind:ga.kind,query:ga.query,items:Ru,index:ga.index,loading:ga.kind==="mention"&&ju,onHover:function(me){Ya(function(Ot){return Ot&&Object.assign({},Ot,{index:me})})},onSelect:function(me){Qx(me)},onClose:function(){Ya(null)}}):null,(0,e.jsxs)("div",{className:"xy-composer-input-row",style:{display:"flex",alignItems:"flex-start",ga
546p:8,minHeight:28,padding:"7px 12px",position:"relative"},children:[(0,e.jsx)("span",{style:{color:I.up,fontFamily:I.mono,lineHeight:1.55,flexShrink:0,fontSize:14},children:"›"}),(0,e.jsx)("textarea",{ref:ma,value:d,onChange:xC,onKeyDown:an,onClick:function(me){Sm(me.target.value,me.target.selectionStart)},onKeyUp:function(me){(me.key==="ArrowLeft"||me.key==="ArrowRight"||me.key==="Home"||me.key==="End")&&Sm(me.target.value,me.target.selectionStart)},onPaste:qk,"aria-label":S.placeholder,rows:1,style:{flex:1,background:"transparent",border:"none",color:Rn.text,fontSize:13,lineHeight:"1.55",resize:"none",minHeight:24,maxHeight:200,overflowY:"auto",overflowX:"hidden",outline:"none",fontFamily:"sans-serif",caretColor:I.gold,caretShape:"block"}}),(!d||d.length===0)&&(0,e.jsxs)("span",{className:"xy-composer-placeholder","aria-hidden":"true",style:{position:"absolute",left:30,top:7,pointerEvents:"none",fontFamily:I.sans,fontSize:13,color:I.ink5,lineHeight:"1.55",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"calc(100% - 80px)"},children:[(0,e.jsx)("span",{style:{display:"inline-block",width:7,height:14,background:I.gold,verticalAlign:"-2px",marginRight:6,animation:"xy-cursor-gold 1.05s steps(2) infinite"}}),S.placeholder]}),f&&!Gr&&!dr&&!Qn&&!Tr?(0,e.jsx)("button",{onClick:Bd,title:"Stop generation (Esc)","aria-label":"Stop generation","data-testid":"composer-stop-generation",style:{width:32,height:32,background:"rgba(200,92,92,0.16)",border:"1px solid rgba(200,92,92,0.5)",borderRadius:8,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:"#E07070",fontSize:11,fontWeight:700,transition:"all .15s"},children:"■"}):(0,e.jsx)("button",{onClick:un,disabled:xt,style:{width:32,height:32,background:xt?"#141E2A":S.color,border:"none",borderRadius:8,cursor:xt?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:xt?"#3A4556":"#000",fontSize:16,fontWeight:700,transition:"all .15s"},children:Qt})]}),(0,e.jsx)("div",{style:{height:1,background:I.hairline,margin:"0 12px"}}),!G&&(function(){function me(){Di(!1),Jr(!1),po(!1),Fo(!1),go(!1),Tn(!1),jl(null),vi(!1),Oi(!1),pi(!1),zi(!1),si(!1),Ji(!1),Go(!1),ca(!1),ho(!1),io(!1),oo(!1),gi(!1),Lo(!1),dl(!1),Fl(!1),Li(!1),ji(!1),Dd([]),Od([]),Ro(null),Md()}var Ot=typeof Hl<"u"&&Array.isArray(Hl)?new Set(Hl):null,Gt="#D4AF5C",In=[{key:"portfolio",label:"PORTFOLIO",on:or,set:function(){var At=!or;me(),po(At)}},{key:"scanner",label:"DOC SCAN",on:qi,set:function(){var At=!qi;me(),go(At)}},{key:"intelgraph",label:"INTEL GRAPH",on:tr,set:function(){var At=!tr;me(),Fo(At)}},{key:"eyes",label:"VISION",on:er,set:function(){var At=!er;me(),Tn(At)}},{key:"call",label:pn?"IN CALL":"CALL",on:!!pn,set:function(){if(pn){zn(null);return}Cn(me)}},{key:"search",label:"SEARCH",on:Gr,set:function(){me(),Di(!Gr),kn(null),Ir(!1)}},{key:"intel",label:"INTEL",on:Qi,set:function(){var At=!Qi;me(),Lo(At)}},{key:"video",label:"VIDEO",on:dr,set:function(){me(),Jr(!dr)}},{key:"map",label:"MAP",on:Qn,set:function(){me(),vi(!Qn)}},{key:"vault",label:"VAULT",on:nr,set:function(){var At=!nr;me(),Oi(At),At||hi(null)}},{key:"ledger",label:"LEDGER",on:Sr,set:function(){var At=!Sr;me(),ji(At)}},{key:"realestate",label:"REAL ESTATE",on:li,set:function(){var At=!li;me(),Li(At)}},{key:"email",label:"EMAIL",on:Tr,set:function(){me(),zi(!Tr)}},{key:"calendar",label:"CALENDAR",on:Yr,set:function(){me(),si(!Yr)}},{key:"messenger",label:"MESSENGER",on:Do,set:function(){me(),Ji(!Do)}},{key:"command",label:"COMMAND",on:Er,set:function(){me(),pi(!Er)}},{key:"brief",label:"BRIEF",on:mo,set:function(){me(),ho(!mo)}},{key:"audit",label:"AUDIT",on:yo,set:function(){me(),io(!yo)}},{key:"risk",label:"RISK",on:Oo,set:function(){me(),oo(!Oo)}},{key:"cortex",label:"CORTEX",on:kr,set:function(){var At=!kr;me(),gi(At)}}],Mn=Ot?In.filter(function(At){return Ot.has(At.key)}):In,Vt={width:"0.5px",background:I.hairline,alignSelf:"stretch",margin:"0 4px",flexShrink:0},fn={background:"transparent",border:"none",padding:"3px 5px",cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",color:I.ink4,fontSize:13,lineHeight:1,borderRadius:3,transition:"all 150ms "+I.ease};return(0,e.jsxs)("div",{className:"xy-composer-footer",style:{display:"flex",alignItems:"center",padding:"4px 8px",gap:5,fontFamily:I.mono,fontSize:10,
546color:I.ink5,letterSpacing:"0.10em",minWidth:0,overflow:"hidden"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:2,flexShrink:0},children:[(0,e.jsx)("button",{onClick:pC,title:"Attach from Vault or upload",style:fn,onMouseEnter:function(At){At.currentTarget.style.color=I.gold,At.currentTarget.style.background="rgba(212,175,92,0.06)"},onMouseLeave:function(At){At.currentTarget.style.color=I.ink4,At.currentTarget.style.background="transparent"},children:"📎"}),(0,e.jsx)("button",{onClick:Mx,disabled:Kn,title:Et?"Stop recording":Kn?"Transcribing…":S.voiceHint||"Hold to talk",style:Object.assign({},fn,{color:Et?"#EF4444":Kn?"#D4AF5C":I.ink4,cursor:Kn?"default":"pointer",animation:Et?"xpulse 1s infinite":"none"}),onMouseEnter:function(At){!Et&&!Kn&&(At.currentTarget.style.color=I.gold,At.currentTarget.style.background="rgba(212,175,92,0.06)")},onMouseLeave:function(At){!Et&&!Kn&&(At.currentTarget.style.color=I.ink4,At.currentTarget.style.background="transparent")},children:Et?"⏹":Kn?"◌":"🎙"}),typeof import.meta<"u"&&!1,(0,e.jsx)("button",{type:"button",title:"Slash commands","data-testid":"composer-slash-btn","aria-label":"Open slash commands",onClick:function(){Jx("slash")},style:Object.assign({},fn,{fontSize:14,color:I.gold,fontWeight:700}),onMouseEnter:function(At){At.currentTarget.style.background="rgba(212,175,92,0.06)"},onMouseLeave:function(At){At.currentTarget.style.background="transparent"},children:"/"}),(0,e.jsx)("button",{type:"button",title:"@-mention","data-testid":"composer-mention-btn","aria-label":"Open mention picker",onClick:function(){Jx("mention")},style:Object.assign({},fn,{fontSize:13,color:I.gold,fontWeight:700}),onMouseEnter:function(At){At.currentTarget.style.background="rgba(212,175,92,0.06)"},onMouseLeave:function(At){At.currentTarget.style.background="transparent"},children:"@"})]}),(0,e.jsx)("div",{style:Vt}),(0,e.jsx)("div",{className:"xy-rail-scroll xy-rail-scroll--flex",style:{padding:"1px 2px"},onWheel:function(At){if(!(!At.deltaY||Math.abs(At.deltaX)>Math.abs(At.deltaY))){var Dn=At.currentTarget;Dn.scrollWidth<=Dn.clientWidth||(Dn.scrollLeft+=At.deltaY,At.preventDefault())}},children:(0,e.jsxs)("div",{className:"xy-rail-scroll-track",children:[Mn.map(function(At){var Dn=At.on;return(0,e.jsx)("button",{onClick:function(){Eu(At)},title:At.label,style:{padding:"2px 7px",background:Dn?"rgba(212,175,92,0.08)":"transparent",border:"0.5px solid "+(Dn?Gt:I.hairline2),borderRadius:4,color:Dn?Gt:I.ink4,fontFamily:I.mono,fontSize:9,fontWeight:700,letterSpacing:"0.12em",cursor:"pointer",whiteSpace:"nowrap",flexShrink:0,transition:"all 150ms "+I.ease},onMouseEnter:function(zt){Dn||(zt.currentTarget.style.borderColor="rgba(212,175,92,0.55)",zt.currentTarget.style.color=Gt)},onMouseLeave:function(zt){Dn||(zt.currentTarget.style.borderColor=I.hairline2,zt.currentTarget.style.color=I.ink4)},children:At.label},At.key)}),typeof t.onOpenHostNav=="function"&&jT.map(function(At){var Dn=!t.activeDockKey&&t.hostNav===At.key;return(0,e.jsx)("button",{type:"button",onClick:function(){t.onOpenHostNav(At.key)},title:At.label,style:{padding:"2px 7px",background:Dn?"rgba(212,175,92,0.08)":"transparent",border:"0.5px solid "+(Dn?Gt:I.hairline2),borderRadius:4,color:Dn?Gt:I.ink4,fontFamily:I.mono,fontSize:9,fontWeight:700,letterSpacing:"0.12em",cursor:"pointer",whiteSpace:"nowrap",flexShrink:0,transition:"all 150ms "+I.ease},onMouseEnter:function(zt){Dn||(zt.currentTarget.style.borderColor="rgba(212,175,92,0.55)",zt.currentTarget.style.color=Gt)},onMouseLeave:function(zt){Dn||(zt.currentTarget.style.borderColor=I.hairline2,zt.currentTarget.style.color=I.ink4)},children:At.label},"host:"+At.key)})]})}),(0,e.jsx)("div",{style:Vt}),(0,e.jsxs)("div",{className:"xy-kb-hints",style:{display:"flex",alignItems:"center",gap:6,color:I.ink5,flexShrink:0},children:[(0,e.jsxs)("span",{children:[(0,e.jsx)("span",{style:{color:I.ink4},children:"⌘↵"})," send"]}),(0,e.jsx)("span",{style:{color:I.ink6},children:"·"}),(0,e.jsxs)("span",{children:[(0,e.jsx)("span",{style:{color:I.ink4},children:"⌘K"})," palette"]})]})]})})()]})}),(0,e.jsx)("div",{style:se,children:(function(){function me(){Di(!1),Jr(!1),po(!1),Fo(!1),go(!1),Tn(!1),jl(null),vi(!1),Oi(!1),pi(!1),zi(!1),si(!1),Ji(!1),Go(!1),ca(!1),ho(!1),io(!1),oo(!1),gi(!1),Lo(!1),dl(!1),Fl(!1),Li(!1),ji(!1),Dd([]),Od([]),Ro(null),Md()}var Ot=typeof Hl<"u"&&Array.isArray(Hl)?new Set(Hl):null,Gt="rgba(212,175,92,0.10)",In="rgba(212,175,92,0.02)",Mn="rgba(212,175,92,0.45)",Vt="rgba(212,175,92,0.55)",fn="#E4C27A",At=[{key:"search",label:"SEARCH",on:Gr,set:function(){me(),Di(!Gr),kn(null),Ir(!1)},activeBg:Gt,activeBorder:Mn,hoverBorder:Vt,inactiveBg:In,activeColor:fn,icon:"⌕"},{key:"intel",label:"INTEL",on:Qi,set:function(){var zt=!Qi;me(),Lo(zt)},activeBg:Gt,activeBorder:Mn,hoverBorder:Vt,inactiveBg:In,activeColor:fn,icon:"◐"},{key:"video",label:"VIDEO",on:dr,set:function(){me(),Jr(!dr)},activeBg:Gt,activeBorder:Mn,hoverBorder:Vt,inactiveBg:In,activeColor:fn,icon:"▶"},{key:"map",label:"MAP",on:Qn,set:function(){me(),vi(!Qn)},activeBg:Gt,activeBorder:Mn,hoverBorder:Vt,inactiveBg:In,activeColor:fn,icon:"◉"},{key:"vault",label:"VAULT",on:nr,set:function(){var zt=!nr;me(),Oi(zt),zt||hi(null)},activeBg:Gt,activeBorder:Mn,hoverBorder:Vt,inactiveBg:In,activeColor:fn,icon:"▣"},{key:"email",label:"EMAIL",on:Tr,set:function(){me(),zi(!Tr)},activeBg:Gt,activeBorder:Mn,hoverBorder:Vt,inactiveBg:In,activeColor:fn,icon:"✉"},{key:"calendar",label:"CALENDAR",on:Yr,set:function(){me(),si(!Yr)},activeBg:Gt,activeBorder:Mn,hoverBorder:Vt,inactiveBg:In,activeColor:fn,icon:"◷"},{key:"call",label:pn?"IN CALL":"CALL",on:!!pn,set:function(){if(pn){zn(null);return}Cn(me)},activeBg:Gt,activeBorder:Mn,hoverBorder:Vt,inactiveBg:In,activeColor:fn,icon:"☎"},{key:"messenger",label:"MESSENGER",on:Do,set:function(){me(),Ji(!Do)},activeBg:Gt,activeBorder:Mn,hoverBorder:Vt,inactiveBg:In,activeColor:fn,icon:"⌨"},{key:"command",label:"COMMAND",on:Er,set:function(){me(),pi(!Er)},activeBg:Gt,activeBorder:Mn,hoverBorder:Vt,inactiveBg:In,activeColor:fn,icon:"⌘"},{key:"brief",label:"BRIEF",on:mo,set:function(){me(),ho(!mo)},activeBg:"rgba(201,169,97,0.12)",activeBorder:"rgba(201,169,97,0.40)",hoverBorder:"rgba(201,169,97,0.45)",inactiveBg:"rgba(201,169,97,0.03)",activeColor:"#C9A961",icon:"◫"},{key:"audit",label:"AUDIT",on:yo,set:function(){me(),io(!yo)},activeBg:"rgba(127,165,200,0.10)",activeBorder:"rgba(127,165,200,0.35)",hoverBorder:"rgba(127,165,200,0.45)",inactiveBg:"rgba(127,165,200,0.03)",activeColor:"#7FA5C8",icon:"⊞"},{key:"risk",label:"RISK",on:Oo,set:function(){me(),oo(!Oo)},activeBg:"rgba(212,107,107,0.10)",activeBorder:"rgba(212,107,107,0.35)",hoverBorder:"rgba(212,107,107,0.45)",inactiveBg:"rgba(212,107,107,0.03)",activeColor:"#D46B6B",icon:"▲"},{key:"cortex",label:"CORTEX",on:kr,set:function(){var zt=!kr;me(),gi(zt)},activeBg:Gt,activeBorder:Mn,hoverBorder:Vt,inactiveBg:In,activeColor:fn,icon:"◉"}],Dn=Ot?At.filter(function(zt){return Ot.has(zt.key)}):At;return G?i.createElement(i.Fragment,null,i.createElement("div",{className:"xy-rail-scroll",style:ce},i.createElement("div",{"aria-hidden":!0,style:{position:"absolute",top:-1,left:0,right:0,height:1,background:"linear-gradient(90deg, transparent, rgba(201,169,97,0.55), transparent)",pointerEvents:"none"}}),i.createElement("span",{style:ze},Ge),i.createElement(sp,{compact:!0,chatMode:de,signal:_e,activeDrawer:li?"realestate":Qn?"map":kr?"portfolio":null,streaming:!!f}),Dn.map(function(zt){var ki=28,Sn="5px 13px",Ul=9,Wl=6,sr=".18em",gs=6,Xn=typeof Kh<"u"&&Kh&&Kh[zt.key]||zt.label,Mo="linear-gradient(135deg,#E4C27A 0%,#D4AF5C 50%,#9E7E35 100%)",Ra={background:Mo,WebkitBackgroun
546dClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text",fontWeight:700,opacity:zt.on?1:.55,transition:"opacity 0.15s"},Fu={fontSize:11,lineHeight:"1",background:Mo,WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text",filter:zt.on?"drop-shadow(0 1px 0 rgba(158,126,53,0.7)) drop-shadow(0 0 6px rgba(212,175,92,0.4))":"drop-shadow(0 1px 0 rgba(158,126,53,0.5))",opacity:zt.on?1:.7,transition:"all 0.15s"};return i.createElement("button",{key:zt.key,onClick:zt.set,title:Xn,style:{display:"flex",alignItems:"center",gap:6,padding:Sn,height:ki,background:zt.on?"rgba(212,175,92,0.10)":"rgba(212,175,92,0.02)",border:"1px solid "+(zt.on?"rgba(212,175,92,0.50)":"rgba(212,175,92,0.22)"),borderRadius:Wl,cursor:"pointer",fontFamily:n,fontSize:Ul,fontWeight:700,letterSpacing:sr,boxShadow:zt.on?"inset 0 1px 0 rgba(228,194,122,0.12), 0 0 16px rgba(212,175,92,0.12)":"inset 0 1px 0 rgba(228,194,122,0.04)",transition:"all 0.15s",flexShrink:0,whiteSpace:"nowrap"},onMouseEnter:function(ms){zt.on||(ms.currentTarget.style.borderColor="rgba(212,175,92,0.55)",ms.currentTarget.style.background="rgba(212,175,92,0.06)",ms.currentTarget.style.boxShadow="inset 0 1px 0 rgba(228,194,122,0.08), 0 0 10px rgba(212,175,92,0.08)")},onMouseLeave:function(ms){zt.on||(ms.currentTarget.style.borderColor="rgba(212,175,92,0.22)",ms.currentTarget.style.background="rgba(212,175,92,0.02)",ms.currentTarget.style.boxShadow="inset 0 1px 0 rgba(228,194,122,0.04)")}},i.createElement("span",{style:Fu},zt.icon),i.createElement("span",{style:Ra},zt.label),zt.on&&i.createElement("div",{style:{width:gs,height:gs,borderRadius:"50%",background:"radial-gradient(circle at 30% 30%, #E4C27A, #9E7E35)",boxShadow:"0 0 10px rgba(212,175,92,0.7), inset 0 0 2px rgba(255,255,255,0.3)",marginLeft:2}}))})),i.createElement("div",{"aria-hidden":!0,style:Ve}),i.createElement("div",{"aria-hidden":!0,style:Ze})):null})()}),(0,e.jsxs)("div",{className:"xy-quick-prompts",style:{position:"relative",marginTop:tr?0:5},children:[(0,e.jsx)("div",{className:"xy-rail-scroll",style:{display:"flex",gap:4,flexWrap:"nowrap",overflowX:"auto",overflowY:"hidden",WebkitOverflowScrolling:"touch"},children:S.quickPrompts.map(function(me){return(0,e.jsx)("button",{onClick:function(){rr(me)},disabled:f,style:{padding:"2px 9px",background:"transparent",border:"1px solid "+(S.color+"18"),borderRadius:10,color:S.color+"90",fontSize:8,fontFamily:n,cursor:f?"not-allowed":"pointer",letterSpacing:".05em",transition:"all .12s",flexShrink:0,whiteSpace:"nowrap"},onMouseEnter:function(Ot){f||(Ot.currentTarget.style.borderColor=S.color+"40",Ot.currentTarget.style.color=S.color)},onMouseLeave:function(Ot){Ot.currentTarget.style.borderColor=S.color+"18",Ot.currentTarget.style.color=S.color+"90"},children:me},me)})}),(0,e.jsx)("div",{"aria-hidden":!0,style:Ve}),(0,e.jsx)("div",{"aria-hidden":!0,style:Ze})]})]})})]})})()]}),Xi&&(0,e.jsxs)(i.Fragment,{children:[(0,e.jsx)("div",{role:"separator","aria-orientation":"vertical",title:"Drag to resize",onPointerDown:jC,style:{width:4,cursor:"col-resize",background:"rgba(212,175,92,0.15)",flexShrink:0,touchAction:"none"}}),(0,e.jsx)("div",{style:{width:mc,flexShrink:0,height:"100%"},children:(0,e.jsx)(XI,{artifact:Xi&&Xi.artifact,versions:CC(Xi&&Xi.artifact),onSelectVersion:function(u){Uo({messageId:Xi.messageId,artifact:u})},onSaveToVault:function(u){return AC(Xi.messageId,u)},onClose:function(){Uo(null)},onOpenVideo:aa})})]}),fc&&(0,e.jsx)(dD,{url:fc.url,title:fc.title,onClose:function(){pc(null)}}),Rd&&(function(){var u=Im||{},S=u.vault||{icon:"🔐",color:"#3FB950",bgFaint:"rgba(63,185,80,0.04)",bgHover:"rgba(63,185,80,0.12)",borderFaint:"rgba(63,185,80,0.15)",borderHover:"rgba(63,185,80,0.35)",iconBg:"rgba(63,185,80,0.08)"},F=u.upload||{icon:"📤",color:"#D4AF5C",bgFaint:"rgba(212,175,92,0.04)",bgHover:"rgba(212,175,92,0.12)",borderFaint:"rgba(212,175,92,0.15)",borderHover:"rgba(212,175,92,0.35)",iconBg:"rgba(212,175,92,0.08)"},G=S.color===F.color?S.color:Rn.amber;return(0,e.jsxs)(i.Fragment,{children:[(0,e.jsx)("div",{onClick:function(){Bf(!1)},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.6)",zIndex:700}}),(0,e.jsxs)("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%,-50%)",zIndex:701,width:380,background:"#0D1117",border:"1px solid #2A3548",borderRadius:12,overflow:"hidden",boxShadow:"0 20px 60px rgba(0,0,0,.8)"},children:[(0,e.jsxs)("div",{style:{padding:"14px 18px",borderBottom:"1px solid #1A1F2B",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,e.jsx)("span",{style:{fontSize:16,color:G},children:u.clipIcon||"⧉"}),(0,e.jsx)("span",{style:{fontFamily:n,fontSize:11,fontWeight:700,color:G,letterSpacing:".1em"},children:"ATTACH"})]}),(0,e.jsx)("button",{onClick:function(){Bf(!1)},style:{background:"transparent",border:"none",cursor:"pointer",fontFamily:n,fontSize:14,color:"#5A7090"},children:"×"})]}),(0,e.jsxs)("div",{style:{padding:"14px 18px",display:"flex",flexDirection:"column",gap:10},children:[(0,e.jsxs)("button",{onClick:gC,style:{display:"flex",alignItems:"center",gap:12,padding:"14px 16px",background:S.bgFaint,border:"1px solid "+S.borderFaint,borderRadius:8,cursor:"pointer",textAlign:"left",transition:"all .15s"},onMouseEnter:function(ce){ce.currentTarget.style.background=S.bgHover,ce.currentTarget.style.borderColor=S.borderHover},onMouseLeave:function(ce){ce.currentTarget.style.background=S.bgFaint,ce.currentTarget.style.borderColor=S.borderFaint},children:[(0,e.jsx)("div",{style:{width:38,height:38,borderRadius:8,background:S.iconBg,display:"flex",alignItems:"center",justifyContent:"center",fontSize:20,flexShrink:0,color:S.color},children:S.icon}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:n,fontSize:11,fontWeight:700,color:S.color,letterSpacing:".08em"},children:"FROM VAULT"}),(0,e.jsx)("div",{style:{fontFamily:n,fontSize:9,color:"#5A7090",marginTop:3},children:"Attach secure documents — decks, contracts, reports, data files"})]})]}),(0,e.jsxs)("button",{onClick:mC,style:{display:"flex",alignItems:"center",gap:12,padding:"14px 16px",background:F.bgFaint,border:"1px solid "+F.borderFaint,borderRadius:8,cursor:"pointer",textAlign:"left",transition:"all .15s"},onMouseEnter:function(ce){ce.currentTarget.style.background=F.bgHover,ce.currentTarget.style.borderColor=F.borderHover},onMouseLeave:function(ce){ce.currentTarget.style.background=F.bgFaint,ce.currentTarget.style.borderColor=F.borderFaint},children:[(0,e.jsx)("div",{style:{width:38,height:38,borderRadius:8,background:F.iconBg,display:"flex",alignItems:"center",justifyContent:"center",fontSize:20,flexShrink:0,color:F.color},children:F.icon}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontFamily:n,fontSize:11,fontWeight:700,color:F.color,letterSpacing:".08em"},children:"UPLOAD FROM COMPUTER"}),(0,e.jsxs)("div",{style:{fontFamily:n,fontSize:9,color:"#5A7090",marginTop:3},children:["PDF, DOCX, CSV, images, code files — read and analyzed by ",Gn.name]})]})]})]})]})]})})(),Ek&&(function(){var u=Im&&Im.vault||{icon:"🔐",color:"#3FB950",itemHoverBg:"rgba(63,185,80,0.04)",itemIconBg:"rgba(63,185,80,0.06)",itemIconBorder:"rgba(63,185,80,0.15)"};return(0,e.jsxs)(i.Fragment,{children:[(0,e.jsx)("div",{onClick:function(){t0(!1)},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.7)",zIndex:702}}),(0,e.jsxs)("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%,-50%)",zIndex:703,width:500,maxHeight:540,background:"#0D1117",border:"1px solid #2A3548",borderRadius:12,overflow:"hidden",boxShadow:"0 20px 60px rgba(0,0,0,.8)",display:"flex",flexDirection:"column"},children:[(0,e.jsxs)("div",{style:{padding:"14px 18px",borderBottom:"1px solid #1A1F2B",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,e.jsx)("span",{style:{fontSize:16,color:u.color},children:u.icon}),(0,e.jsx)("span",{style:{fontFamily:n,fontSize:11,fontWeight:700,color:u.color,letterSpacing:".1em"},children:"ATTACH FROM VAULT"})]}),(0,e.jsx)("button",{onClick:function(){t0(!1)},style:{background:"transparent",border:"none",cursor:"pointer",fontFamily:n,fontSize:14,color:"#5A7090"},children:"×"})]}),(0,e.jsx)("div",{style:{padding:"10px 18px",borderBottom:"1px solid #151D2B",flexShrink:0},children:(0,e.jsx)("input",{value:Fd,onChange:function(S){hx(S.target.value)},placeholder:"Search vault documents…",autoFocus:!0,style:{width:"100%",background:"#0A0E14",border:"1px solid #2A3548",borderRadius:6,padding:"8px 12px",fontSize:12,color:"#E6EDF3",outline:"none",boxSizing:"border-box",fontFamily:"'SF Pro Text',sans-serif"}})}),(0,e.jsxs)("div",{style:{flex:1,overflowY:"auto",padding:"6px 0"},children:[ju&&(0,e.jsx)("div",{style:{padding:30,textAlign:"center",fontFamily:n,fontSize:10,
546color:u.color},children:"Loading vault…"}),!ju&&zc.filter(function(S){return!Fd||(S.name||"").toLowerCase().indexOf(Fd.toLowerCase())!==-1||(S.type||S.doc_type||"").toLowerCase().indexOf(Fd.toLowerCase())!==-1}).map(function(S){var F=fi.some(function(G){return G.vaultId===(S.doc_id||S.id)});return(0,e.jsxs)("div",{onClick:function(){F||$x(S)},style:{display:"flex",alignItems:"center",gap:12,padding:"10px 18px",cursor:F?"default":"pointer",opacity:F?.4:1,transition:"background .12s"},onMouseEnter:function(G){F||(G.currentTarget.style.background=u.itemHoverBg)},onMouseLeave:function(G){G.currentTarget.style.background="transparent"},children:[(0,e.jsx)("div",{style:{width:32,height:32,borderRadius:6,background:u.itemIconBg,border:"1px solid "+u.itemIconBorder,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,e.jsx)("span",{style:{fontFamily:n,fontSize:9,fontWeight:700,color:u.color},children:(S.type||S.doc_type||"DOC").substring(0,4).toUpperCase()})}),(0,e.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,e.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"#E6EDF3",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:S.name}),(0,e.jsxs)("div",{style:{fontFamily:n,fontSize:8,color:"#5A7090",marginTop:2},children:[(S.type||S.doc_type||"document").toString().toLowerCase(),S.content_preview||S.content?" · "+Math.round((S.content_preview||S.content||"").length/1024)+"KB":""]})]}),(0,e.jsx)("span",{style:{fontFamily:n,fontSize:9,color:F?"#5A7090":u.color,flexShrink:0},children:F?"ATTACHED":"ATTACH"})]},S.doc_id||S.id)}),!ju&&zc.length===0&&(0,e.jsx)("div",{style:{padding:30,textAlign:"center",fontFamily:n,fontSize:10,color:"#3A4A5E"},children:"No documents in vault"}),!ju&&zc.length>0&&zc.filter(function(S){return!Fd||(S.name||"").toLowerCase().indexOf(Fd.toLowerCase())!==-1}).length===0&&(0,e.jsxs)("div",{style:{padding:30,textAlign:"center",fontFamily:n,fontSize:10,color:"#3A4A5E"},children:['No matches for "',Fd,'"']})]})]})]})})(),!$t&&pn&&i.createElement("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9999,background:"#05080D"}},i.createElement(Fw,{roomUrl:pn.roomUrl,token:pn.token,eventId:pn.eventId,onEnd:function(){zn(null)}}),i.createElement(AS,{onClick:function(){zn(null)},zIndex:1e4})),(0,e.jsx)(t6,{open:er,onClose:function(){Tn(!1)},onSendToChat:OC,onOpenVoice:function(){Tn(!1),ai(!1),Tt(!0)}}),it&&(0,e.jsx)("div",{style:{position:"fixed",inset:0,zIndex:850,background:"rgba(3,5,8,0.78)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",display:"flex",alignItems:"center",justifyContent:"center",padding:"24px"},children:(0,e.jsxs)("div",{style:{position:"relative",width:"min(560px, 92vw)"},children:[(0,e.jsx)("button",{onClick:function(){Tt(!1)},title:"Close voice mode",style:{position:"absolute",top:-32,right:0,padding:"4px 10px",background:"transparent",border:"1px solid #2A3548",borderRadius:5,cursor:"pointer",fontFamily:n,fontSize:9,color:"#7A8A9E",letterSpacing:"0.10em"},children:"EXIT"}),(0,e.jsx)(qA,{streaming:!0,compact:!1})]})}),$r&&(0,e.jsx)("div",{style:{position:"fixed",inset:0,zIndex:850,background:"rgba(3,5,8,0.78)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",display:"flex",alignItems:"center",justifyContent:"center",padding:"24px"},children:(0,e.jsxs)("div",{style:{position:"relative",width:"min(560px, 92vw)"},children:[(0,e.jsx)("button",{onClick:function(){ai(!1)},title:"Close Sonic",style:{position:"absolute",top:-32,right:0,padding:"4px 10px",background:"transparent",border:"1px solid #2A3548",borderRadius:5,cursor:"pointer",fontFamily:n,fontSize:9,color:"#7A8A9E",letterSpacing:"0.10em"},children:"EXIT"}),(0,e.jsx)(sD,{compact:!1,onSwitchToDeep:function(){ai(!1),Tt(!0)}})]})})]})}export{UL as $,xL as $t,tz as A,dT as At,qL as B,kL as Bt,sz as C,GS as Cn,K2 as Ct,rz as D,bT as Dt,ZL as E,_L as Et,ac as F,wL as Ft,uE as G,SL as Gt,rx as H,AL as Ht,gE as I,Lv as It,YL as J,wv as Jt,KL as K,bL as Kt,mE as L,EL as Lt,QL as M,Yy as Mt,$L as N,h5 as Nt,iz as O,DL as Ot,pE as P,f5 as Pt,BL as Q,jv as Qt,JL as R,jL as Rt,dz as S,zy as Sn,wT as St,lz as T,IL as Tt,nz as U,Fw as Ut,ez as V,nm as Vt,lE as W,Zj as Wt,VL as X,Xj as Xt,GL as Y,hL as Yt,HL as Z,yL as Zt,pz as _,lL as _n,FT as _t,wD as a,pL as an,PL as at,f4 as b,$h as bn,$2 as bt,xz as c,$j as cn,sh as ct,hz as d,zj as dn,D_ as dt,mL as en,Og as et,S4 as f,n2 as fn,T_ as ft,gz as g,Qh as gn,d_ as gt,h4 as h,gj as hn,eE as ht,RD as i,qj as in,WL as it,XL as j,K5 as jt,az as k,RL as kt,yz as l,gL as ln,bb as lt,mz as m,vv as mn,k_ as mt,u3 as n,Vj as nn,R_ as nt,q0 as o,dL as on,NL as ot,pg as p,sL as pn,zL as pt,ex as q,Jj as qt,N9 as r,cL as rn,O_ as rt,vz as s,vL as sn,ML as st,w6 as t,uL as tn,__ as tt,eF as u,fL as un,Lg as ut,fz as v,KS as vn,OL as vt,Nb as w,FL as wt,p4 as x,aL as xn,MT as xt,uz as y,Oy as yn,LL as yt,oz as z,CL as zt};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.