titan-agent 6.3.0 → 6.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/utils/constants.js +1 -1
- package/dist/utils/constants.js.map +1 -1
- package/package.json +1 -1
- package/ui/dist/assets/{AuditPanel-BmFAKA7p.js → AuditPanel-TdDAyJUQ.js} +1 -1
- package/ui/dist/assets/{AutonomyPanel-BzuCEsiG.js → AutonomyPanel-B6EIpuFt.js} +1 -1
- package/ui/dist/assets/{AutopilotPanel-DA1vFEl4.js → AutopilotPanel-CLe14-eq.js} +1 -1
- package/ui/dist/assets/{AutoresearchPanel-BeUCXYtX.js → AutoresearchPanel-C14q_kh7.js} +1 -1
- package/ui/dist/assets/{BackupPanel-B6N1pfMT.js → BackupPanel-CoEbryip.js} +1 -1
- package/ui/dist/assets/{BrowserPanel-BGHaPi3O.js → BrowserPanel-CRTJOXQV.js} +1 -1
- package/ui/dist/assets/{CPActivity-BUSwjFj2.js → CPActivity-DjT8p5Dn.js} +1 -1
- package/ui/dist/assets/{CPAgentDetail-DlUEVujH.js → CPAgentDetail-CR1ciISN.js} +1 -1
- package/ui/dist/assets/{CPAgents-CnRmsSMo.js → CPAgents-DIYCdpQR.js} +1 -1
- package/ui/dist/assets/{CPApprovals-CXdkzebd.js → CPApprovals-DAKmaSkN.js} +1 -1
- package/ui/dist/assets/{CPCosts-CfcyIUZg.js → CPCosts-CCCh_VY0.js} +1 -1
- package/ui/dist/assets/{CPDashboard-DHlfE1mT.js → CPDashboard-CyKZGlHB.js} +1 -1
- package/ui/dist/assets/{CPFiles-DyV9vsjE.js → CPFiles-CI252ucO.js} +1 -1
- package/ui/dist/assets/{CPGoals-C17G2F0e.js → CPGoals-BtcgDUY5.js} +1 -1
- package/ui/dist/assets/{CPInbox-D5A3ja_Q.js → CPInbox-igQoKOuB.js} +1 -1
- package/ui/dist/assets/{CPIssueDetail-CoPv27Ll.js → CPIssueDetail-DD5iL5mT.js} +1 -1
- package/ui/dist/assets/{CPIssues-C9EdfW1J.js → CPIssues-C1XUjgdv.js} +1 -1
- package/ui/dist/assets/CPLayout-VXhuxAHd.js +2 -0
- package/ui/dist/assets/{CPOrg-DzoVDLKI.js → CPOrg-JyXp44DB.js} +1 -1
- package/ui/dist/assets/{CPRuns-BHAyFv0K.js → CPRuns-C-gZX28e.js} +1 -1
- package/ui/dist/assets/{CPSocial-CjHD8dKM.js → CPSocial-sMl4vqmX.js} +1 -1
- package/ui/dist/assets/{CPVoice-aybMotU5.js → CPVoice-BXTY3vl7.js} +1 -1
- package/ui/dist/assets/{ChannelsPanel-8KfvAEYM.js → ChannelsPanel-rF_yHmYD.js} +1 -1
- package/ui/dist/assets/{CheckpointsPanel-BCyLRLcg.js → CheckpointsPanel-DO0QSjuz.js} +1 -1
- package/ui/dist/assets/{CommandPostHub-Ce-mWsu2.js → CommandPostHub-BLnNTvBO.js} +3 -3
- package/ui/dist/assets/{CronPanel-A9JHvU_O.js → CronPanel-DELTcCV-.js} +1 -1
- package/ui/dist/assets/{DataTable-ol6IZMRj.js → DataTable-BmbYppBc.js} +1 -1
- package/ui/dist/assets/{DreamPanel-ZiOF8ybh.js → DreamPanel-B28qIraZ.js} +1 -1
- package/ui/dist/assets/{EmptyState-B1i1ZK0x.js → EmptyState-CxJGUl_w.js} +1 -1
- package/ui/dist/assets/{EvalHarnessPanel-DRGc1zbp.js → EvalHarnessPanel-DvI-dsqQ.js} +1 -1
- package/ui/dist/assets/{EvalPanel-B_fiFImG.js → EvalPanel-DKdn69V8.js} +1 -1
- package/ui/dist/assets/{FileViewer-D14G6MQq.js → FileViewer-Deg5Z7ng.js} +1 -1
- package/ui/dist/assets/{FilesPanel-BIsMoSfg.js → FilesPanel-DDRjQukY.js} +1 -1
- package/ui/dist/assets/{FleetPanel-CSjOOsbX.js → FleetPanel-eEudyOkP.js} +1 -1
- package/ui/dist/assets/{HomelabPanel-XHMxqiHu.js → HomelabPanel-Dov1f68P.js} +1 -1
- package/ui/dist/assets/InfraView-DgasEqoR.js +2 -0
- package/ui/dist/assets/{InlineEditableField-AOS-LBh_.js → InlineEditableField-4ZA-KEfv.js} +1 -1
- package/ui/dist/assets/{Input-CTK9oH9g.js → Input-C7lzcGqx.js} +1 -1
- package/ui/dist/assets/{IntegrationsPanel-BKuC_5El.js → IntegrationsPanel-BmnWsnvF.js} +1 -1
- package/ui/dist/assets/IntelligenceView-DXYSyS1a.js +2 -0
- package/ui/dist/assets/{LearningPanel-RpDaPvCj.js → LearningPanel-BsKhgbeS.js} +1 -1
- package/ui/dist/assets/{LogsPanel-9zIJP1Xv.js → LogsPanel-C-H_axtp.js} +1 -1
- package/ui/dist/assets/{McpPanel-CNE7MhDu.js → McpPanel-BizAlt2h.js} +1 -1
- package/ui/dist/assets/{MemoryGraphPanel-9DEsbOZF.js → MemoryGraphPanel-Qle7Bodz.js} +1 -1
- package/ui/dist/assets/{MemoryWikiPanel-CqNen9A6.js → MemoryWikiPanel-CKY4HY4k.js} +1 -1
- package/ui/dist/assets/{MeshPanel-Bq3pHHIT.js → MeshPanel-D35hLDX4.js} +1 -1
- package/ui/dist/assets/MissionCanvas-BU6dvWdk.js +72 -0
- package/ui/dist/assets/{MissionChat-BDqlCplQ.js → MissionChat-BCxqk708.js} +1 -1
- package/ui/dist/assets/{MissionLibrary-9SMdJnfa.js → MissionLibrary-DtovbHf7.js} +1 -1
- package/ui/dist/assets/{MissionStart-Cm7C3kyo.js → MissionStart-DQCW6cLo.js} +1 -1
- package/ui/dist/assets/{Modal-B9KCAwCK.js → Modal-CpcFi-Gm.js} +1 -1
- package/ui/dist/assets/{NvidiaPanel-CpGBj1sn.js → NvidiaPanel-Dwvf8UD2.js} +1 -1
- package/ui/dist/assets/{OrganismPanel-DBHyylxC.js → OrganismPanel-mhCf2syl.js} +1 -1
- package/ui/dist/assets/{OverviewPanel-DII4H_R7.js → OverviewPanel-DiOrl6LB.js} +1 -1
- package/ui/dist/assets/{PageHeader-Bzb_WXw0.js → PageHeader-CPfyiZIM.js} +1 -1
- package/ui/dist/assets/{PersonaProfilesPanel-CXZTZhjo.js → PersonaProfilesPanel-BvQlozzS.js} +1 -1
- package/ui/dist/assets/{PersonasPanel-BYbD8XiV.js → PersonasPanel-G5Jz55AB.js} +1 -1
- package/ui/dist/assets/{PhoneDeskPanel-Bol7fCCN.js → PhoneDeskPanel-Cx4wlgRT.js} +1 -1
- package/ui/dist/assets/{RecipesPanel-BRbXRcEn.js → RecipesPanel-DB6Kuo1a.js} +1 -1
- package/ui/dist/assets/{SecurityPanel-BR3BT7Rb.js → SecurityPanel-BcnpsElV.js} +1 -1
- package/ui/dist/assets/{SelfImprovePanel-BX9xYBxl.js → SelfImprovePanel-do5xDzc8.js} +1 -1
- package/ui/dist/assets/{SelfProposalsPanel-BOoDEAYp.js → SelfProposalsPanel-DM4B-HLa.js} +1 -1
- package/ui/dist/assets/{SessionsPanel-BICnNmn0.js → SessionsPanel-Bl8h6Bfu.js} +1 -1
- package/ui/dist/assets/{SessionsTab-X10FeDWA.js → SessionsTab-hihe8Dc7.js} +1 -1
- package/ui/dist/assets/{SettingsPanel-MuC32AXw.js → SettingsPanel-Cp8decIS.js} +1 -1
- package/ui/dist/assets/SettingsView-BZIgBz0P.js +2 -0
- package/ui/dist/assets/{SkeletonLoader-fwI4Z-f0.js → SkeletonLoader-DLzSaIMH.js} +1 -1
- package/ui/dist/assets/{SkillsPanel-CKFndekU.js → SkillsPanel-B0VL9cO1.js} +1 -1
- package/ui/dist/assets/{SomaView-Ch7WlmBy.js → SomaView-BejcfdMM.js} +1 -1
- package/ui/dist/assets/{StatCard-Bj2Q_4WS.js → StatCard-Bt-57DK2.js} +1 -1
- package/ui/dist/assets/{StatusBadge-NtdTQ8_L.js → StatusBadge-BE0SQNPu.js} +1 -1
- package/ui/dist/assets/{Tabs-CC9aTVuL.js → Tabs-dEteLxhl.js} +1 -1
- package/ui/dist/assets/{TeamsPanel-DjFcLsdR.js → TeamsPanel-7UwGxnbj.js} +1 -1
- package/ui/dist/assets/{TelemetryPanel-k7gJbZyS.js → TelemetryPanel-CqbkTW3V.js} +1 -1
- package/ui/dist/assets/{TitanCanvas-MzLkpZhp.js → TitanCanvas-RVuBEoV1.js} +4 -4
- package/ui/dist/assets/{ToolsView-DcxwuM2l.js → ToolsView-C97QnPeY.js} +2 -2
- package/ui/dist/assets/{Tooltip-CFYHfpgQ.js → Tooltip-BGe4ZrLD.js} +1 -1
- package/ui/dist/assets/{TraceViewer-BfLO9vwI.js → TraceViewer-CSj_fZou.js} +1 -1
- package/ui/dist/assets/{TrainingPanel-DUl6qChY.js → TrainingPanel-43gDnkVS.js} +1 -1
- package/ui/dist/assets/{VoiceOverlay-Dj_cR5_Y.js → VoiceOverlay-CvZcewVV.js} +1 -1
- package/ui/dist/assets/{VramPanel-th0_Eo8o.js → VramPanel-nadiVKRZ.js} +1 -1
- package/ui/dist/assets/{WatchView-DyGhpKbv.js → WatchView-CUGArdWk.js} +1 -1
- package/ui/dist/assets/{WorkTab-BG5VBljJ.js → WorkTab-iCDNyX60.js} +1 -1
- package/ui/dist/assets/{WorkflowsPanel-C1hVHqAc.js → WorkflowsPanel-Do5EOPQ-.js} +1 -1
- package/ui/dist/assets/{archive-C2_hAJXj.js → archive-96Jj-QYz.js} +1 -1
- package/ui/dist/assets/{arrow-left-DFCBXvKS.js → arrow-left-DvmiAV7y.js} +1 -1
- package/ui/dist/assets/{book-open-BgDKDGcH.js → book-open-DvAaokKW.js} +1 -1
- package/ui/dist/assets/{bot-C4ICYImG.js → bot-DFsTWhzD.js} +1 -1
- package/ui/dist/assets/{chart-column-BIFJOG_f.js → chart-column-BWW8khga.js} +1 -1
- package/ui/dist/assets/{check-CmCL8yzl.js → check-4bqUIREX.js} +1 -1
- package/ui/dist/assets/{chevron-right-U0Ujye5i.js → chevron-right-DhAaVOkv.js} +1 -1
- package/ui/dist/assets/{chevron-up-B6uSBxbj.js → chevron-up-DhONR6eV.js} +1 -1
- package/ui/dist/assets/{circle-check-big-BFw1nom4.js → circle-check-big-CrrpTfnZ.js} +1 -1
- package/ui/dist/assets/{circle-stop-DbtGpdaw.js → circle-stop-BOU58Urf.js} +1 -1
- package/ui/dist/assets/{clipboard-list-Dd3_U8cK.js → clipboard-list-GcIgVrYh.js} +1 -1
- package/ui/dist/assets/{clock-DpJIc30t.js → clock-D5MlrzQb.js} +1 -1
- package/ui/dist/assets/{dollar-sign-DlrOHVzA.js → dollar-sign-B9t2KmrG.js} +1 -1
- package/ui/dist/assets/{download-CZ5kTONh.js → download-DzgUP-io.js} +1 -1
- package/ui/dist/assets/{external-link-CX-GvMky.js → external-link--90_rW_r.js} +1 -1
- package/ui/dist/assets/{file-text-BtTsNJbB.js → file-text-C-9as3zm.js} +1 -1
- package/ui/dist/assets/{flask-conical-BaPYppKH.js → flask-conical-BJnD20AK.js} +1 -1
- package/ui/dist/assets/{folder-BOnpha2-.js → folder-BXotS0h-.js} +1 -1
- package/ui/dist/assets/{funnel-DaNi6kwp.js → funnel-BkW9zcis.js} +1 -1
- package/ui/dist/assets/{git-branch-gs6g9dSe.js → git-branch-D7pbvkyu.js} +1 -1
- package/ui/dist/assets/{index-Dbv5oKsp.js → index-DczEfArU.js} +2 -2
- package/ui/dist/assets/index-DmgXt1oB.css +1 -0
- package/ui/dist/assets/{layers-BKZz8iD1.js → layers-BgUh-m00.js} +1 -1
- package/ui/dist/assets/{legacy-DbwFsW2A.js → legacy-Wbf7An22.js} +1 -1
- package/ui/dist/assets/{lightbulb-DX6YLtPe.js → lightbulb-4Yox7P7Z.js} +1 -1
- package/ui/dist/assets/{list-todo-qdMNm4-Q.js → list-todo-JeleiL5r.js} +1 -1
- package/ui/dist/assets/{message-square-Cwo5FOho.js → message-square-C9bK5TAD.js} +1 -1
- package/ui/dist/assets/{mic-BzvwK4IS.js → mic-DwEnBcFd.js} +1 -1
- package/ui/dist/assets/{missions-CYlXuJED.js → missions-Jbe_PHaT.js} +1 -1
- package/ui/dist/assets/{network-Dt-RBtO_.js → network-BjQmrmO8.js} +1 -1
- package/ui/dist/assets/{pause-Do3XNLtx.js → pause-9vYiD-5Y.js} +1 -1
- package/ui/dist/assets/{pencil-DAGs9RFs.js → pencil-CygyIvE1.js} +1 -1
- package/ui/dist/assets/{play-CNElkzEq.js → play-7ImYx-M6.js} +1 -1
- package/ui/dist/assets/{plug-DCgrVnB8.js → plug-DXmJpsfC.js} +1 -1
- package/ui/dist/assets/{plus-BnsXhqXc.js → plus-LIrhsu2s.js} +1 -1
- package/ui/dist/assets/{proxy-BXHdgwrk.js → proxy-B72L9I2p.js} +1 -1
- package/ui/dist/assets/{radio-BPz7sHXW.js → radio-DN9FsrLZ.js} +1 -1
- package/ui/dist/assets/{refresh-cw-Cs4oDMNE.js → refresh-cw-DyPWslHB.js} +1 -1
- package/ui/dist/assets/{rotate-ccw-DSpsA3Wr.js → rotate-ccw-C7z7lzst.js} +1 -1
- package/ui/dist/assets/{save-BhGg2pZh.js → save-Bl0vY0Ur.js} +1 -1
- package/ui/dist/assets/{search-BtxlIgqN.js → search-DLl1kVch.js} +1 -1
- package/ui/dist/assets/{send-BzKTXI3q.js → send-BqZ0Qzz-.js} +1 -1
- package/ui/dist/assets/{server-B1gIgixS.js → server-DvPKxeOK.js} +1 -1
- package/ui/dist/assets/{shield-check-C39B-Wi3.js → shield-check-DMM8OpD5.js} +1 -1
- package/ui/dist/assets/{terminal-CubaeYlJ.js → terminal-DD6OAIa2.js} +1 -1
- package/ui/dist/assets/{test-tube-CYYLfFIz.js → test-tube-BoC1tTKm.js} +1 -1
- package/ui/dist/assets/{toggle-right-BQ3iDgLG.js → toggle-right-CrEdx-9K.js} +1 -1
- package/ui/dist/assets/{trash-2-CSxfLiVB.js → trash-2-Co50XYSn.js} +1 -1
- package/ui/dist/assets/{trending-up-DXxKT18Q.js → trending-up-SFD19agk.js} +1 -1
- package/ui/dist/assets/{trophy-osEOm2Vi.js → trophy-DLTd-oCR.js} +1 -1
- package/ui/dist/assets/{volume-2-C1OkTurz.js → volume-2-vQvjPYVu.js} +1 -1
- package/ui/dist/assets/{wifi-off-DAhvsjnD.js → wifi-off-DVwDeeLz.js} +1 -1
- package/ui/dist/index.html +2 -2
- package/ui/dist/sw.js +1 -1
- package/ui/dist/assets/CPLayout-CHrlktMs.js +0 -2
- package/ui/dist/assets/InfraView-DNYgRXkB.js +0 -2
- package/ui/dist/assets/IntelligenceView-BUKpVpDQ.js +0 -2
- package/ui/dist/assets/MissionCanvas-Ci0hbAF0.js +0 -69
- package/ui/dist/assets/SettingsView-Cv9IZqiU.js +0 -2
- package/ui/dist/assets/index-OZm1iJy9.css +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SomaView-
|
|
2
|
-
var wl=Object.defineProperty;var vl=(t,e,s)=>e in t?wl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var $e=(t,e,s)=>vl(t,typeof e!="symbol"?e+"":e,s);import{c as ts,a as et,g as _l,r as w,b as ge,j as n,S as Sr,W as jr,B as yt,H as kl,s as Sl,u as Zi,d as jl,e as El,X as js,f as Er,E as eo,A as Vt,C as Nr,U as Cr,h as Tr,G as to,R as oe,_ as le,Z as Nl,i as fn,I as ci,k as Cl,l as Tl,L as so,m as Rl,M as Al,n as Ll,o as Il,p as Dl,t as Dn}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SomaView-BejcfdMM.js","assets/index-DczEfArU.js","assets/index-DmgXt1oB.css","assets/Input-C7lzcGqx.js","assets/clsx-B-dksMZM.js","assets/Tooltip-BGe4ZrLD.js","assets/SomaView-BtCkeWfZ.css","assets/CommandPostHub-BLnNTvBO.js","assets/Modal-CpcFi-Gm.js","assets/proxy-B72L9I2p.js","assets/InlineEditableField-4ZA-KEfv.js","assets/check-4bqUIREX.js","assets/pencil-CygyIvE1.js","assets/approvalHeadline-DB9SgR-9.js","assets/chevron-right-DhAaVOkv.js","assets/bot-DFsTWhzD.js","assets/pause-9vYiD-5Y.js","assets/dollar-sign-B9t2KmrG.js","assets/git-branch-D7pbvkyu.js","assets/chart-column-BWW8khga.js","assets/clock-D5MlrzQb.js","assets/message-square-C9bK5TAD.js","assets/file-text-C-9as3zm.js","assets/terminal-DD6OAIa2.js","assets/refresh-cw-DyPWslHB.js","assets/circle-stop-BOU58Urf.js","assets/send-BqZ0Qzz-.js","assets/plus-LIrhsu2s.js","assets/trash-2-Co50XYSn.js","assets/IntelligenceView-DXYSyS1a.js","assets/MemoryGraphPanel-Qle7Bodz.js","assets/network-BjQmrmO8.js","assets/search-DLl1kVch.js","assets/InfraView-DgasEqoR.js","assets/ToolsView-C97QnPeY.js","assets/SettingsView-BZIgBz0P.js","assets/SettingsPanel-Cp8decIS.js","assets/PageHeader-CPfyiZIM.js","assets/circle-check-big-CrrpTfnZ.js","assets/mic-DwEnBcFd.js","assets/wifi-off-DVwDeeLz.js","assets/download-DzgUP-io.js","assets/play-7ImYx-M6.js","assets/save-Bl0vY0Ur.js","assets/SecurityPanel-BcnpsElV.js","assets/AuditPanel-TdDAyJUQ.js","assets/clipboard-list-GcIgVrYh.js","assets/funnel-BkW9zcis.js","assets/AutopilotPanel-CLe14-eq.js","assets/WorkflowsPanel-Do5EOPQ-.js","assets/toggle-right-CrEdx-9K.js","assets/book-open-DvAaokKW.js","assets/LearningPanel-BsKhgbeS.js","assets/lightbulb-4Yox7P7Z.js","assets/trending-up-SFD19agk.js","assets/chevron-up-DhONR6eV.js","assets/server-DvPKxeOK.js","assets/rotate-ccw-C7z7lzst.js","assets/flask-conical-BJnD20AK.js","assets/archive-96Jj-QYz.js","assets/radio-DN9FsrLZ.js","assets/test-tube-BoC1tTKm.js","assets/VoiceOverlay-CvZcewVV.js","assets/volume-2-vQvjPYVu.js","assets/folder-BXotS0h-.js","assets/shield-check-DMM8OpD5.js","assets/external-link--90_rW_r.js","assets/SelfImprovePanel-do5xDzc8.js","assets/trophy-DLTd-oCR.js","assets/PersonasPanel-G5Jz55AB.js","assets/PersonaProfilesPanel-BvQlozzS.js","assets/DreamPanel-B28qIraZ.js","assets/HomelabPanel-Dov1f68P.js","assets/StatCard-Bt-57DK2.js","assets/SkeletonLoader-DLzSaIMH.js","assets/NvidiaPanel-Dwvf8UD2.js","assets/FilesPanel-DDRjQukY.js","assets/arrow-left-DvmiAV7y.js","assets/LogsPanel-C-H_axtp.js","assets/TelemetryPanel-CqbkTW3V.js","assets/SkillsPanel-B0VL9cO1.js","assets/McpPanel-BizAlt2h.js","assets/plug-DXmJpsfC.js","assets/IntegrationsPanel-BmnWsnvF.js","assets/ChannelsPanel-rF_yHmYD.js","assets/MeshPanel-D35hLDX4.js","assets/DataTable-BmbYppBc.js","assets/MemoryWikiPanel-CKY4HY4k.js","assets/AutoresearchPanel-C14q_kh7.js","assets/SelfProposalsPanel-DM4B-HLa.js","assets/OverviewPanel-DiOrl6LB.js","assets/layers-BgUh-m00.js","assets/SessionsPanel-Bl8h6Bfu.js","assets/WatchView-CUGArdWk.js","assets/BackupPanel-CoEbryip.js","assets/TrainingPanel-43gDnkVS.js","assets/RecipesPanel-DB6Kuo1a.js","assets/VramPanel-nadiVKRZ.js","assets/TeamsPanel-7UwGxnbj.js","assets/CronPanel-DELTcCV-.js","assets/CheckpointsPanel-DO0QSjuz.js","assets/OrganismPanel-mhCf2syl.js","assets/FleetPanel-eEudyOkP.js","assets/BrowserPanel-CRTJOXQV.js","assets/EvalPanel-DKdn69V8.js","assets/legacy-Wbf7An22.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var wl=Object.defineProperty;var vl=(t,e,s)=>e in t?wl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var $e=(t,e,s)=>vl(t,typeof e!="symbol"?e+"":e,s);import{c as ts,a as et,g as _l,r as w,b as ge,j as n,S as Sr,W as jr,B as yt,H as kl,s as Sl,u as Zi,d as jl,e as El,X as js,f as Er,E as eo,A as Vt,C as Nr,U as Cr,h as Tr,G as to,R as oe,_ as le,Z as Nl,i as fn,I as ci,k as Cl,l as Tl,L as so,m as Rl,M as Al,n as Ll,o as Il,p as Dl,t as Dn}from"./index-DczEfArU.js";import{C as Ml}from"./chevron-up-DhONR6eV.js";import{P as Ol}from"./plus-LIrhsu2s.js";import{F as pn}from"./file-text-C-9as3zm.js";import{S as Rr}from"./server-DvPKxeOK.js";import{N as no}from"./network-BjQmrmO8.js";import{T as ro}from"./terminal-DD6OAIa2.js";import{B as fs}from"./book-open-DvAaokKW.js";import{S as mn}from"./save-Bl0vY0Ur.js";import{P as Pl}from"./pencil-CygyIvE1.js";import{R as io}from"./rotate-ccw-C7z7lzst.js";import{S as oo}from"./search-DLl1kVch.js";import{S as ao}from"./send-BqZ0Qzz-.js";import{M as lo}from"./message-square-C9bK5TAD.js";import{M as co}from"./mic-DwEnBcFd.js";import{F as uo}from"./flask-conical-BJnD20AK.js";import{C as ps}from"./clock-D5MlrzQb.js";import{A as ho}from"./archive-96Jj-QYz.js";import{R as fo}from"./radio-DN9FsrLZ.js";import{T as po,P as di}from"./test-tube-BoC1tTKm.js";import{VoiceOverlay as Wl}from"./VoiceOverlay-CvZcewVV.js";import{C as Bl}from"./chevron-right-DhAaVOkv.js";import{R as gn}from"./refresh-cw-DyPWslHB.js";import{F as Ul}from"./folder-BXotS0h-.js";import{C as ui}from"./check-4bqUIREX.js";import{S as Fl}from"./shield-check-DMM8OpD5.js";import{E as hi}from"./external-link--90_rW_r.js";import{B as mo}from"./bot-DFsTWhzD.js";import{W as $l}from"./wifi-off-DVwDeeLz.js";/**
|
|
3
3
|
* @license lucide-react v0.513.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
@@ -965,8 +965,8 @@ function Widget({ titan }) {
|
|
|
965
965
|
const btn = container.querySelector('button');
|
|
966
966
|
btn.addEventListener('click', () => btn.textContent = 'Clicked!');
|
|
967
967
|
}`,html:`<!-- Raw HTML. No scripts run. -->
|
|
968
|
-
<div style="padding:16px;color:#e4e4e7">Hello, widget!</div>`,iframe:"",system:""};function Sp(t){return String(t||"").startsWith("system:")?"system":"react"}const jp={productivity:"#a78bfa",finance:"#34d399","health-fitness":"#f472b6","music-dj":"#c084fc",creative:"#fb923c",travel:"#60a5fa",gaming:"#f87171",social:"#38bdf8",cooking:"#fbbf24",vehicle:"#94a3b8",homelab:"#a3e635","ml-ai":"#818cf8",research:"#2dd4bf",document:"#f9a8d4",devops:"#fcd34d","e-commerce":"#fda4af",lifestyle:"#86efac",web:"#67e8f9",data:"#d8b4fe","multi-modal":"#fdba74",automation:"#facc15","smart-home":"#bef264",agents:"#e879f9","software-builder":"#7dd3fc",utilities:"#a5b4fc",media:"#fca5a5",communication:"#5eead4",education:"#c4b5fd",misc:"#9ca3af"};function Ep(t){return t.split(/[-_/]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function Np({open:t,onClose:e}){const[s,r]=w.useState([]),[i,o]=w.useState([]),[c,d]=w.useState("All"),[l,p]=w.useState(""),[g,u]=w.useState(null),[f,x]=w.useState(!1),[y,E]=w.useState(null);w.useEffect(()=>{t&&(x(!0),ge("/api/widget-gallery").then(m=>m.json()).then(m=>{r(m.templates||[]),o(m.categories||[]),x(!1)}).catch(m=>{E(m.message),x(!1)}))},[t]),w.useEffect(()=>{if(!t)return;const m=k=>{k.key==="Escape"&&e()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t,e]);const I=w.useMemo(()=>{const m=c==="All"?s:s.filter(_=>_.category===c),k=l.trim().toLowerCase();return k?m.filter(_=>[_.name,_.description,_.category,..._.tags||[],..._.triggers||[]].join(" ").toLowerCase().includes(k)):m},[c,l,s]);if(!t)return null;const v=async m=>{var k,_,T,S;u(m.id),E(null);try{const C=await ge(`/api/widget-gallery/${encodeURIComponent(m.id)}`);if(!C.ok)throw new Error(`Could not load template (${C.status})`);const D=await C.json(),j={templateId:m.id,templateName:D.name||m.name,source:D.source,format:Sp(D.source),defaultSize:{w:((k=D.defaultSize)==null?void 0:k.w)??((_=m.defaultSize)==null?void 0:_.w)??4,h:((T=D.defaultSize)==null?void 0:T.h)??((S=m.defaultSize)==null?void 0:S.h)??4}};window.dispatchEvent(new CustomEvent("titan:gallery:run-template",{detail:j})),e()}catch(C){E(C.message)}finally{u(null)}},A=["All",...i.map(m=>m.category)];return n.jsx("div",{className:"fixed inset-0 z-[2147483150] flex items-center justify-center p-4 titan-menu-overlay",onClick:e,children:n.jsxs("div",{className:"w-full max-w-4xl titan-modal-surface flex flex-col",style:{height:"min(720px, 90vh)",borderRadius:12},onClick:m=>m.stopPropagation(),children:[n.jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:"1px solid var(--theme-menu-border)"},children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Er,{className:"w-4 h-4",style:{color:"var(--theme-accent)"}}),n.jsx("h3",{className:"font-semibold text-sm",style:{color:"var(--theme-ink)",fontFamily:"var(--theme-font-display)"},children:"Widget gallery"}),n.jsx("span",{className:"text-[10px]",style:{color:"var(--theme-ink-soft)"},children:f?"Loading…":`${s.length} templates`})]}),n.jsx("button",{onClick:e,className:"titan-close-btn",title:"Close (Esc)","aria-label":"Close",children:n.jsx(js,{className:"w-4 h-4"})})]}),n.jsx("div",{className:"flex items-center gap-1.5 px-5 py-2 border-b border-[#27272a] text-[11px] overflow-x-auto",children:A.map(m=>{var k;return n.jsxs("button",{onClick:()=>d(m),className:`px-2.5 py-1 rounded-full border transition-colors whitespace-nowrap ${c===m?"border-[#6366f1] bg-[#6366f1]/15 text-white":"border-[#27272a] bg-transparent text-[#a1a1aa] hover:border-[#3f3f46] hover:text-white"}`,children:[Ep(m),m!=="All"&&n.jsx("span",{className:"ml-1.5 text-[9px] opacity-70",children:((k=i.find(_=>_.category===m))==null?void 0:k.count)??0})]},m)})}),n.jsx("div",{className:"px-5 py-2 border-b border-[#27272a]",children:n.jsxs("label",{className:"flex items-center gap-2 rounded-lg border border-[#27272a] bg-[#18181b]/60 px-3 py-2",children:[n.jsx(oo,{className:"w-3.5 h-3.5 text-[#71717a]"}),n.jsx("input",{value:l,onChange:m=>p(m.target.value),placeholder:"Search templates...",className:"flex-1 bg-transparent text-xs text-white placeholder:text-[#71717a] outline-none"})]})}),n.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[f&&n.jsx("div",{className:"flex items-center justify-center h-full text-[#a1a1aa] text-sm",children:"Loading templates…"}),y&&n.jsxs("div",{className:"flex items-center justify-center h-full text-[#f87171] text-sm",children:["Error: ",y]}),!f&&!y&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:I.map(m=>n.jsxs("button",{onClick:()=>v(m),disabled:g!==null,className:"text-left p-3 rounded-lg border border-[#27272a] bg-[#18181b]/60 hover:border-[#6366f1]/50 hover:bg-[#18181b] transition-colors group",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[n.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[n.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:jp[m.category]??"#9ca3af"}}),n.jsx("span",{className:"text-[12px] font-medium text-white truncate",children:m.name})]}),n.jsx(ao,{className:"w-3 h-3 text-[#52525b] group-hover:text-[#a5b4fc] transition-colors shrink-0"})]}),n.jsx("div",{className:"text-[11px] text-[#a1a1aa] leading-relaxed line-clamp-2",children:g===m.id?"Adding to canvas...":m.description}),m.tags&&m.tags.length>0&&n.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:m.tags.slice(0,3).map(k=>n.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-[#27272a] text-[#71717a]",children:k},k))})]},m.id))}),I.length===0&&n.jsx("div",{className:"flex items-center justify-center h-40 text-[#a1a1aa] text-sm",children:"No templates in this category."})]}),n.jsxs("div",{className:"mt-4 p-3 rounded-lg border border-dashed border-[#27272a] bg-[#0a0a0e] flex items-start gap-2",children:[n.jsx(yo,{className:"w-3.5 h-3.5 text-[#71717a] mt-0.5 shrink-0"}),n.jsxs("div",{className:"text-[11px] text-[#a1a1aa] leading-relaxed",children:["Don’t see what you want? Open the chat (click the mascot) and describe your widget in plain English. TITAN can build anything that runs inside a sandboxed iframe with access to ",n.jsx("span",{className:"font-mono text-[#d4d4d8]",children:"titan.fetch"}),","," ",n.jsx("span",{className:"font-mono text-[#d4d4d8]",children:"titan.api.call"}),", and"," ",n.jsx("span",{className:"font-mono text-[#d4d4d8]",children:"titan.state"}),"."]})]})]})]})})}const Cp=[{type:"widget",source:"system:nav",name:"Nav Widget",w:3,h:4,icon:n.jsx(yo,{className:"w-4 h-4"})},{type:"widget",source:"system:chat",name:"Chat Widget",w:4,h:5,icon:n.jsx(lo,{className:"w-4 h-4"})},{type:"widget",source:"system:soma",name:"SOMA",w:6,h:6,icon:n.jsx(yt,{className:"w-4 h-4"})},{type:"widget",source:"system:command-post",name:"Command Post",w:8,h:6,icon:n.jsx(ro,{className:"w-4 h-4"})},{type:"widget",source:"system:intelligence",name:"Intelligence",w:6,h:5,icon:n.jsx(no,{className:"w-4 h-4"})},{type:"widget",source:"system:memory-graph",name:"Memory Graph",w:8,h:7,icon:n.jsx(Gl,{className:"w-4 h-4"})},{type:"widget",source:"system:voice",name:"Voice",w:5,h:5,icon:n.jsx(co,{className:"w-4 h-4"})},{type:"widget",source:"system:infra",name:"Infrastructure",w:6,h:4,icon:n.jsx(Rr,{className:"w-4 h-4"})},{type:"widget",source:"system:tools",name:"Tools",w:5,h:4,icon:n.jsx(jr,{className:"w-4 h-4"})},{type:"widget",source:"system:settings",name:"Settings",w:5,h:5,icon:n.jsx(Sr,{className:"w-4 h-4"})},{type:"widget",source:"system:files",name:"Files",w:4,h:6,icon:n.jsx(pn,{className:"w-4 h-4"})},{type:"widget",source:"system:memory-wiki",name:"Memory Wiki",w:6,h:6,icon:n.jsx(fs,{className:"w-4 h-4"})},{type:"widget",source:"system:autoresearch",name:"Autoresearch",w:6,h:6,icon:n.jsx(uo,{className:"w-4 h-4"})},{type:"widget",source:"system:self-proposals",name:"Self-Proposals",w:6,h:6,icon:n.jsx(go,{className:"w-4 h-4"})},{type:"widget",source:"system:overview",name:"Overview",w:6,h:5,icon:n.jsx(eo,{className:"w-4 h-4"})},{type:"widget",source:"system:sessions",name:"Sessions",w:6,h:5,icon:n.jsx(ps,{className:"w-4 h-4"})},{type:"widget",source:"system:watch",name:"Watch",w:8,h:7,icon:n.jsx(Vt,{className:"w-4 h-4"})},{type:"widget",source:"system:backup",name:"Backup Manager",w:6,h:6,icon:n.jsx(ho,{className:"w-4 h-4"})},{type:"widget",source:"system:training",name:"Training Dashboard",w:6,h:6,icon:n.jsx(yt,{className:"w-4 h-4"})},{type:"widget",source:"system:recipes",name:"Recipe Kitchen",w:6,h:6,icon:n.jsx(fs,{className:"w-4 h-4"})},{type:"widget",source:"system:vram",name:"VRAM Monitor",w:6,h:6,icon:n.jsx(Nr,{className:"w-4 h-4"})},{type:"widget",source:"system:teams",name:"Team Hub",w:6,h:6,icon:n.jsx(Cr,{className:"w-4 h-4"})},{type:"widget",source:"system:cron",name:"Cron Scheduler",w:6,h:6,icon:n.jsx(ps,{className:"w-4 h-4"})},{type:"widget",source:"system:checkpoints",name:"Checkpoints",w:6,h:5,icon:n.jsx(mn,{className:"w-4 h-4"})},{type:"widget",source:"system:organism",name:"Organism Monitor",w:6,h:6,icon:n.jsx(Tr,{className:"w-4 h-4"})},{type:"widget",source:"system:fleet",name:"Fleet Router",w:6,h:5,icon:n.jsx(fo,{className:"w-4 h-4"})},{type:"widget",source:"system:browser",name:"Browser Tools",w:6,h:5,icon:n.jsx(to,{className:"w-4 h-4"})},{type:"widget",source:"system:eval",name:"Test Lab",w:6,h:6,icon:n.jsx(po,{className:"w-4 h-4"})}];function yl({currentSpaceId:t,onSpaceSelect:e,onAction:s,onClose:r}){const[i,o]=w.useState(""),[c,d]=w.useState(0),l=w.useRef(null),p=ke.list(),g=w.useMemo(()=>{const u=i.toLowerCase(),f=p.filter(y=>y.id!==t&&y.name.toLowerCase().includes(u)).map(y=>({type:"space",id:y.id,name:y.name,color:y.color})),x=Cp.filter(y=>y.name.toLowerCase().includes(u)).map(y=>({type:"action",action:y,name:y.name}));return[...f,...x]},[i,p,t]);return w.useEffect(()=>{var u;(u=l.current)==null||u.focus()},[]),w.useEffect(()=>{d(0)},[i]),w.useEffect(()=>{const u=f=>{if((f.metaKey||f.ctrlKey)&&f.key.toLowerCase()==="k"){f.preventDefault(),r();return}if(f.key==="Escape"){r();return}if(f.key==="ArrowDown"){f.preventDefault(),d(x=>Math.min(x+1,g.length-1));return}if(f.key==="ArrowUp"){f.preventDefault(),d(x=>Math.max(x-1,0));return}if(f.key==="Enter"){f.preventDefault();const x=g[c];if(!x)return;x.type==="space"&&e(x.id),x.type==="action"&&s(x.action)}};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[g,c,e,s,r]),n.jsx("div",{className:"fixed inset-0 z-[2147483200] flex items-start justify-center pt-[20vh]",onClick:r,children:n.jsxs("div",{className:"w-full max-w-lg bg-[#18181b]/98 backdrop-blur-xl border border-[#27272a]/60 rounded-2xl shadow-2xl shadow-black/60 overflow-hidden",onClick:u=>u.stopPropagation(),children:[n.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-[#27272a]/40",children:[n.jsx(oo,{className:"w-4 h-4 text-[#3f3f46]"}),n.jsx("input",{ref:l,value:i,onChange:u=>o(u.target.value),placeholder:"Search spaces, widgets, actions...",className:"flex-1 bg-transparent text-sm text-[#e4e4e7] placeholder:text-[#3f3f46] outline-none"}),n.jsx("button",{onClick:r,className:"text-[#3f3f46] hover:text-[#71717a]",children:n.jsx(js,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"max-h-[50vh] overflow-auto py-1",children:[g.length===0&&n.jsxs("div",{className:"px-4 py-6 text-center text-xs text-[#52525b]",children:['No results for "',i,'"']}),g.map((u,f)=>n.jsxs("button",{onClick:()=>{u.type==="space"&&e(u.id),u.type==="action"&&s(u.action)},className:`w-full flex items-center gap-3 px-4 py-2.5 text-left transition-colors ${f===c?"bg-[#6366f1]/10 text-[#818cf8]":"text-[#a1a1aa] hover:bg-[#27272a]/30"}`,children:[u.type==="space"?n.jsx("div",{className:"w-4 h-4 rounded-full",style:{background:u.color||"#52525b"}}):n.jsx("span",{className:"text-[#6366f1]/60",children:u.action.icon}),n.jsx("span",{className:"text-sm",children:u.name}),n.jsx("span",{className:"ml-auto text-[10px] text-[#3f3f46] uppercase tracking-wider",children:u.type==="space"?"Space":"Widget"})]},u.type==="space"?u.id:u.action.source))]}),n.jsxs("div",{className:"px-4 py-2 border-t border-[#27272a]/40 flex items-center gap-3 text-[10px] text-[#3f3f46]",children:[n.jsx("span",{children:"↑↓ Navigate"}),n.jsx("span",{children:"↵ Select"}),n.jsx("span",{children:"ESC Close"})]})]})})}const Tp=oe.lazy(()=>le(()=>import("./SomaView-Ch7WlmBy.js"),__vite__mapDeps([0,1,2,3,4,5,6]))),Ae={bgBase:"var(--theme-bg-base, var(--color-bg, #09090b))",surface:"color-mix(in srgb, var(--theme-bg-grain, var(--color-bg-secondary, #18181b)) 82%, transparent)",surfaceSoft:"color-mix(in srgb, var(--theme-bg-grain, var(--color-bg-tertiary, #27272a)) 62%, transparent)",border:"color-mix(in srgb, var(--theme-metal-dark, var(--color-border, #3f3f46)) 66%, transparent)",ink:"var(--theme-paper-fg, var(--color-text, #fafafa))",inkSoft:"color-mix(in srgb, var(--theme-paper-fg, var(--color-text-secondary, #a1a1aa)) 72%, transparent)",paperFg:"var(--theme-paper-fg, var(--color-text-secondary, #a1a1aa))",accent:"var(--theme-accent, var(--color-accent, #6366f1))",success:"var(--color-success, #22c55e)",error:"var(--color-error, #ef4444)"},sr={background:Ae.bgBase,color:Ae.ink};function bl(){const[t,e]=w.useState(null),[s,r]=w.useState(!1),[i,o]=w.useState(null),c=w.useCallback(async()=>{var p;try{const g=await ge("/api/config");if(!g.ok)throw new Error(`HTTP ${g.status}`);const u=await g.json();e(!!((p=u==null?void 0:u.organism)!=null&&p.enabled)),o(null)}catch(g){o(g.message),e(!1)}},[]);w.useEffect(()=>{c()},[c]);const d=w.useRef(0),l=w.useCallback(async p=>{const g=++d.current;r(!0),o(null);try{const u=await ge("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({organism:{enabled:p}})});if(g!==d.current)return;if(!u.ok)throw new Error(`HTTP ${u.status}`);e(p),window.dispatchEvent(new CustomEvent("titan:soma:changed",{detail:{enabled:p}}))}catch(u){if(g!==d.current)return;o(u.message)}finally{g===d.current&&r(!1)}},[]);return t===null?n.jsx("div",{className:"w-full h-full flex items-center justify-center text-xs",style:{...sr,color:Ae.paperFg},children:"Loading Soma…"}):t?n.jsxs("div",{className:"w-full h-full overflow-auto flex flex-col",style:sr,children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b",style:{background:Ae.surface,borderColor:Ae.border},children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-1.5 h-1.5 rounded-full animate-pulse",style:{background:Ae.success}}),n.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:Ae.success},children:"Soma active"})]}),n.jsxs("button",{onClick:()=>l(!1),disabled:s,className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full border text-[10px] disabled:opacity-60 transition-colors",style:{borderColor:Ae.border,color:Ae.inkSoft,background:Ae.surfaceSoft},title:"Disable Soma",children:[n.jsx(di,{className:"w-3 h-3"}),s?"saving…":"disable"]})]}),n.jsx("div",{className:"flex-1 overflow-auto",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"p-4 text-xs",style:{color:Ae.paperFg},children:"Loading Soma dashboard…"}),children:n.jsx(Tp,{})})})]}):n.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center gap-4 p-6 text-center",style:sr,children:[n.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center",style:{background:"color-mix(in srgb, var(--theme-accent, var(--color-accent, #6366f1)) 18%, transparent)",border:`1px solid ${Ae.border}`},children:n.jsx(Vt,{className:"w-7 h-7",style:{color:Ae.accent}})}),n.jsxs("div",{className:"space-y-1 max-w-md",children:[n.jsx("h3",{className:"text-lg font-semibold",style:{color:Ae.ink},children:"Soma is off"}),n.jsx("p",{className:"text-xs leading-relaxed",style:{color:Ae.inkSoft},children:"TITAN’s homeostatic drive layer. When enabled, TITAN has a sense of its own state — purpose, curiosity, hunger, safety, social, rest — and will propose work when those drives drift. Every proposal still requires your approval."})]}),n.jsxs("button",{onClick:()=>l(!0),disabled:s,className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-full disabled:opacity-60 disabled:cursor-not-allowed text-sm font-medium transition-colors",style:{background:Ae.accent,color:"var(--theme-bg-base, var(--color-bg, #09090b))"},children:[n.jsx(di,{className:"w-4 h-4"}),s?"Enabling…":"Enable Soma"]}),i&&n.jsx("p",{className:"text-xs",style:{color:Ae.error},children:i}),n.jsx("p",{className:"text-[10px]",style:{color:Ae.paperFg},children:"You can turn this off anytime from the same button."})]})}const Rp={calm:{primary:"#6366f1",glow:"rgba(99,102,241,0.4)",pulse:"rgba(99,102,241,0.15)"},focused:{primary:"#10b981",glow:"rgba(16,185,129,0.4)",pulse:"rgba(16,185,129,0.15)"},excited:{primary:"#f59e0b",glow:"rgba(245,158,11,0.4)",pulse:"rgba(245,158,11,0.15)"},concerned:{primary:"#ef4444",glow:"rgba(239,68,68,0.4)",pulse:"rgba(239,68,68,0.15)"},dreaming:{primary:"#8b5cf6",glow:"rgba(139,92,246,0.4)",pulse:"rgba(139,92,246,0.15)"}},Ee={surface:"color-mix(in srgb, var(--theme-bg-grain, var(--color-bg-secondary, #18181b)) 90%, transparent)",surfaceSoft:"color-mix(in srgb, var(--theme-bg-grain, var(--color-bg-tertiary, #27272a)) 62%, transparent)",overlay:"color-mix(in srgb, var(--theme-bg-base, var(--color-bg, #09090b)) 56%, transparent)",border:"color-mix(in srgb, var(--theme-metal-dark, var(--color-border, #3f3f46)) 66%, transparent)",metal:"var(--theme-metal, var(--color-border-light, #52525b))",ink:"var(--theme-paper-fg, var(--color-text, #fafafa))",accent:"var(--theme-accent, var(--color-accent, #6366f1))",warning:"var(--color-warning, #f59e0b)"};function Ap(t,e,s){if(!s)return{emotion:"dreaming",intensity:.25,activity:"Dormant"};const r=e[0],i=Math.min(1,t/2);switch(r){case"purpose":return{emotion:"focused",intensity:.4+i*.4,activity:"Pursuing purpose"};case"curiosity":return{emotion:"excited",intensity:.4+i*.5,activity:"Exploring"};case"hunger":return{emotion:"focused",intensity:.5+i*.3,activity:"Satiating"};case"safety":return{emotion:"concerned",intensity:.5+i*.4,activity:"Securing"};case"social":return{emotion:"calm",intensity:.3+i*.3,activity:"Connecting"};case"rest":return{emotion:"dreaming",intensity:.2+i*.2,activity:"Recuperating"};default:return t>.5?{emotion:"focused",intensity:i,activity:"Processing"}:{emotion:"calm",intensity:.3,activity:"Observing"}}}function Lp(){const[t,e]=w.useState(!1),[s,r]=w.useState({emotion:"calm",intensity:.3,activity:"Observing"}),[i,o]=w.useState(!1),[c,d]=w.useState({x:280,y:80}),[l,p]=w.useState(!1),g=w.useRef({x:0,y:0}),u=w.useRef(null);w.useEffect(()=>{let v=!1;const A=async()=>{try{const k=await ge("/api/soma/state");if(!k.ok||v)return;const _=await k.json();if(v)return;r(Ap(Number((_==null?void 0:_.totalPressure)??0),Array.isArray(_==null?void 0:_.dominantDrives)?_.dominantDrives:[],!!(_!=null&&_.enabled)))}catch{}};A();const m=setInterval(A,15e3);return()=>{v=!0,clearInterval(m)}},[]),w.useEffect(()=>{const v=A=>{var m;(m=u.current)!=null&&m.contains(A.target)||o(!1)};return window.addEventListener("mousedown",v),()=>window.removeEventListener("mousedown",v)},[]);const f=v=>{v.button===0&&(g.current={x:v.clientX-c.x,y:v.clientY-c.y},p(!0))},x=v=>{l&&d({x:v.clientX-g.current.x,y:v.clientY-g.current.y})},y=()=>{p(!1)},E=Rp[s.emotion],I=s.activity==="Dormant"?Ee.metal:Ee.accent;return n.jsxs(n.Fragment,{children:[t&&n.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center backdrop-blur-sm",style:{background:Ee.overlay},onClick:()=>e(!1),children:n.jsxs("div",{className:"border rounded-2xl shadow-2xl overflow-hidden",style:{width:"min(900px, 90vw)",height:"min(600px, 80vh)",background:Ee.surface,borderColor:Ee.border,color:Ee.ink,boxShadow:"0 24px 64px color-mix(in srgb, var(--theme-bg-base, var(--color-bg, #09090b)) 72%, transparent)"},onClick:v=>v.stopPropagation(),children:[n.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b",style:{borderColor:Ee.border},children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(yt,{className:"w-4 h-4",style:{color:I}}),n.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wider",style:{color:Ee.ink},children:"SOMA Consciousness"})]}),n.jsx("button",{onClick:()=>e(!1),className:"p-1",style:{color:Ee.metal},children:n.jsx(js,{className:"w-4 h-4"})})]}),n.jsx("div",{className:"h-[calc(100%-40px)]",children:n.jsx(bl,{})})]})}),n.jsxs("div",{ref:u,className:"fixed z-50 select-none",style:{left:c.x,top:c.y},onMouseDown:f,onMouseMove:x,onMouseUp:y,onMouseLeave:y,children:[i&&n.jsxs("div",{className:"absolute bottom-full left-0 mb-2 backdrop-blur-xl border rounded-xl shadow-2xl overflow-hidden min-w-[160px] py-1",style:{background:Ee.surface,borderColor:Ee.border,boxShadow:"0 18px 40px color-mix(in srgb, var(--theme-bg-base, var(--color-bg, #09090b)) 70%, transparent)"},children:[n.jsxs("button",{onClick:()=>{e(!0),o(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-left text-[11px] transition-colors",style:{color:Ee.ink,background:"transparent"},children:[n.jsx(yt,{className:"w-3.5 h-3.5",style:{color:I}}),"Open SOMA"]}),n.jsxs("button",{onClick:()=>{o(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-left text-[11px] transition-colors",style:{color:Ee.ink,background:"transparent"},children:[n.jsx(Er,{className:"w-3.5 h-3.5",style:{color:Ee.warning}}),"Summarize Canvas"]}),n.jsxs("button",{onClick:()=>{o(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-left text-[11px] transition-colors",style:{color:Ee.ink,background:"transparent"},children:[n.jsx(Nl,{className:"w-3.5 h-3.5",style:{color:Ee.accent}}),"Run Self-Check"]})]}),n.jsxs("div",{className:"relative cursor-pointer group",onClick:()=>!l&&e(!0),onContextMenu:v=>{v.preventDefault(),o(!0)},children:[n.jsx("div",{className:"absolute inset-0 rounded-full animate-ping opacity-20",style:{background:E.pulse,animationDuration:`${3-s.intensity*2}s`}}),n.jsx("div",{className:"absolute -inset-2 rounded-full opacity-30 blur-md transition-all duration-1000",style:{background:E.glow}}),n.jsx("div",{className:"relative w-12 h-12 rounded-full flex items-center justify-center transition-all duration-500 hover:scale-110",style:{background:`radial-gradient(circle at 30% 30%, ${I}, ${Ee.metal})`,boxShadow:`0 0 ${20+s.intensity*30}px ${E.glow}, inset 0 0 10px color-mix(in srgb, var(--theme-ink, var(--color-text, #fafafa)) 12%, transparent)`},children:n.jsx(yt,{className:"w-5 h-5",style:{color:Ee.ink}})}),n.jsx("div",{className:"absolute -bottom-5 left-1/2 -translate-x-1/2 whitespace-nowrap",children:n.jsx("span",{className:"text-[9px] font-medium uppercase tracking-wider px-1.5 py-0.5 rounded border",style:{color:Ee.ink,background:Ee.surfaceSoft,borderColor:Ee.border},children:s.activity})})]})]})]})}const Ip=oe.lazy(()=>le(()=>import("./CommandPostHub-Ce-mWsu2.js"),__vite__mapDeps([7,1,2,3,4,8,9,10,11,12,5,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28])));function Dp(){return n.jsx("div",{className:"w-full h-full overflow-auto p-2",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"p-4 text-xs text-[#52525b]",children:"Loading Command Post..."}),children:n.jsx(Ip,{})})})}const Mp=oe.lazy(()=>le(()=>import("./IntelligenceView-BUKpVpDQ.js"),__vite__mapDeps([29,1,2,4])));function Op(){return n.jsx("div",{className:"w-full h-full overflow-auto",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"p-4 text-xs text-[#52525b]",children:"Loading Intelligence..."}),children:n.jsx(Mp,{})})})}const Pp=oe.lazy(()=>le(()=>import("./MemoryGraphPanel-9DEsbOZF.js"),__vite__mapDeps([30,1,2,31,24,28,32])));function Wp(){return n.jsx("div",{className:"w-full h-full overflow-auto bg-[#09090b]",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsxs("div",{className:"text-center",children:[n.jsx("div",{className:"w-8 h-8 rounded-full border-2 border-[#6366f1]/20 border-t-[#6366f1] animate-spin mx-auto mb-3"}),n.jsx("p",{className:"text-[11px] text-[#52525b]",children:"Loading memory graph..."})]})}),children:n.jsx("div",{className:"p-4",children:n.jsx(Pp,{})})})})}function Bp(){const[t,e]=w.useState(!1);return t?n.jsx(Wl,{onClose:()=>e(!1)}):n.jsx("div",{className:"w-full h-full flex flex-col items-center justify-center bg-[#09090b]",children:n.jsxs("button",{onClick:()=>e(!0),className:"group relative flex flex-col items-center gap-4",children:[n.jsxs("div",{className:"relative w-20 h-20 rounded-full flex items-center justify-center transition-all duration-300 group-hover:scale-110",children:[n.jsx("div",{className:"absolute inset-0 rounded-full bg-[#6366f1]/20 animate-pulse"}),n.jsx("div",{className:"absolute inset-0 rounded-full bg-gradient-to-br from-[#6366f1]/30 to-[#4f46e5]/10 border border-[#6366f1]/30"}),n.jsx(co,{className:"w-8 h-8 text-[#818cf8] relative z-10"})]}),n.jsxs("div",{className:"text-center",children:[n.jsx("p",{className:"text-sm font-medium text-[#a1a1aa]",children:"Tap to speak"}),n.jsx("p",{className:"text-[10px] text-[#52525b] mt-1",children:"F5-TTS · Voice Cloning"})]})]})})}const Up=oe.lazy(()=>le(()=>import("./InfraView-DNYgRXkB.js"),__vite__mapDeps([33,1,2,4])));function Fp(){return n.jsx("div",{className:"w-full h-full overflow-auto",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"p-4 text-xs text-[#52525b]",children:"Loading Infrastructure..."}),children:n.jsx(Up,{})})})}const $p=oe.lazy(()=>le(()=>import("./ToolsView-DcxwuM2l.js"),__vite__mapDeps([34,1,2,4])));function zp(){return n.jsx("div",{className:"w-full h-full overflow-auto",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"p-4 text-xs text-[#52525b]",children:"Loading Tools..."}),children:n.jsx($p,{})})})}const Hp=oe.lazy(()=>le(()=>import("./SettingsView-Cv9IZqiU.js"),__vite__mapDeps([35,1,2,4])));function Vp(){return n.jsx("div",{className:"w-full h-full overflow-auto",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"p-4 text-xs text-[#52525b]",children:"Loading Settings..."}),children:n.jsx(Hp,{})})})}function Gp(){const[t,e]=w.useState([]),[s,r]=w.useState("/"),[i,o]=w.useState(!1),[c,d]=w.useState(null),l=async()=>{o(!0),d(null);try{const p=await ge(`/api/files?path=${encodeURIComponent(s)}`);if(p.ok){const g=await p.json();e(g.files||[])}else e([]),d(`Couldn't load files (HTTP ${p.status})`)}catch(p){e([]),d(`Couldn't reach /api/files — ${p.message}`)}finally{o(!1)}};return w.useEffect(()=>{l()},[s]),n.jsxs("div",{className:"w-full h-full flex flex-col",children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-[#27272a]/40",children:[n.jsxs("div",{className:"flex items-center gap-1 text-[11px] text-[#71717a]",children:[n.jsx("span",{className:"text-[#6366f1]",children:"~"}),n.jsx(Bl,{className:"w-3 h-3"}),n.jsx("span",{children:s})]}),n.jsx("button",{onClick:l,className:"p-1 text-[#3f3f46] hover:text-[#71717a]",children:n.jsx(gn,{className:`w-3 h-3 ${i?"animate-spin":""}`})})]}),n.jsxs("div",{className:"flex-1 overflow-auto",children:[c&&n.jsx("div",{className:"px-3 py-2 text-[11px] text-[#ef4444]/80",children:c}),!c&&!i&&t.length===0&&n.jsx("div",{className:"px-3 py-2 text-[11px] text-[#52525b]",children:"No files"}),t.map(p=>n.jsxs("button",{onClick:()=>p.type==="directory"&&r(p.path),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left hover:bg-[#27272a]/20 transition-colors",children:[p.type==="directory"?n.jsx(Ul,{className:"w-3.5 h-3.5 text-[#f59e0b]"}):n.jsx(pn,{className:"w-3.5 h-3.5 text-[#6366f1]"}),n.jsx("span",{className:"text-[12px] text-[#a1a1aa]",children:p.name})]},p.path))]})]})}const qp=oe.lazy(()=>le(()=>import("./SettingsPanel-MuC32AXw.js"),__vite__mapDeps([36,1,2,3,4,37,14,5,38,39,24,40,41,42,43])));function Yp(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(qp,{})})})}const Kp=oe.lazy(()=>le(()=>import("./SecurityPanel-BR3BT7Rb.js"),__vite__mapDeps([44,1,2,37,14])));function Jp(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Kp,{})})})}const Xp=oe.lazy(()=>le(()=>import("./AuditPanel-BmFAKA7p.js"),__vite__mapDeps([45,1,2,46,24,47])));function Qp(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Xp,{})})})}const Yi={researcher:"#60a5fa",engineer:"#f87171",manager:"#a78bfa",ceo:"#fbbf24",general:"#9ca3af"},Zp={Recommended:"bg-[#10b981]/15 text-[#10b981] border-[#10b981]/30",Reasoning:"bg-[#8b5cf6]/15 text-[#8b5cf6] border-[#8b5cf6]/30",Fast:"bg-[#0ea5e9]/15 text-[#0ea5e9] border-[#0ea5e9]/30",Light:"bg-[#f59e0b]/15 text-[#f59e0b] border-[#f59e0b]/30","Long Context":"bg-[#6366f1]/15 text-[#6366f1] border-[#6366f1]/30","High Output":"bg-[#ec4899]/15 text-[#ec4899] border-[#ec4899]/30","Needs Key":"bg-[#ef4444]/15 text-[#ef4444] border-[#ef4444]/30"};function em(){const[t,e]=w.useState(null),[s,r]=w.useState({}),[i,o]=w.useState({}),[c,d]=w.useState(null),[l,p]=w.useState({}),[g,u]=w.useState(!0),f=w.useCallback(async()=>{d(null);try{const[E,I]=await Promise.all([ge("/api/specialists"),ge("/api/models")]);if(!E.ok)throw new Error(`Specialists request failed: ${E.status}`);if(!I.ok)throw new Error(`Models request failed: ${I.status}`);const v=await E.json(),A=await I.json();e(v),r(A);const m={};await Promise.all(v.map(async k=>{try{const _=await ge(`/api/specialists/${encodeURIComponent(k.id)}/recommendations`);if(_.ok){const T=await _.json();T.recommendations&&(m[k.id]=T.recommendations)}}catch{}})),o(m)}catch(E){d(E.message)}finally{u(!1)}},[]);w.useEffect(()=>{f()},[f]);const x=w.useCallback(E=>{const I=i[E];if(I&&I.length)return I.map(A=>A.id);const v=new Set;if(s&&typeof s=="object")for(const A of Object.keys(s)){const m=s[A];if(Array.isArray(m))for(const k of m)typeof k=="string"?v.add(k):k&&typeof k=="object"&&"id"in k&&typeof k.id=="string"&&v.add(k.id)}if(Array.isArray(t))for(const A of t)A!=null&&A.activeModel&&v.add(A.activeModel),A!=null&&A.defaultModel&&v.add(A.defaultModel);return Array.from(v).sort((A,m)=>A.localeCompare(m))},[i,s,t]),y=w.useCallback(async(E,I)=>{p(v=>({...v,[E]:"saving"}));try{const v=await ge(`/api/specialists/${encodeURIComponent(E)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:I})});if(!v.ok){const m=await v.text().catch(()=>"");throw new Error(`PATCH failed (${v.status}): ${m||v.statusText}`)}const A=await v.json();e(m=>(m==null?void 0:m.map(k=>k.id===E?{...k,activeModel:A.activeModel??k.defaultModel,overridden:(A.activeModel??k.defaultModel)!==k.defaultModel}:k))??null),p(m=>({...m,[E]:"saved"})),setTimeout(()=>{p(m=>{if(m[E]!=="saved")return m;const k={...m};return delete k[E],k})},1500)}catch(v){p(A=>({...A,[E]:"error"})),d(`${E}: ${v.message}`)}},[]);return g&&!t?n.jsx("div",{className:"h-full w-full flex items-center justify-center text-xs text-[#52525b]",children:"Loading specialists…"}):n.jsxs("div",{className:"w-full h-full flex flex-col bg-[#0a0a0f] text-[#e4e4e7] text-sm",children:[n.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[#27272a]/60",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Cr,{className:"w-4 h-4 text-[#6366f1]"}),n.jsx("h3",{className:"font-semibold",children:"Specialist Models"}),n.jsxs("span",{className:"text-[10px] text-[#52525b]",children:[(t==null?void 0:t.length)??0," sub-agents"]})]}),n.jsxs("button",{onClick:()=>{u(!0),f()},className:"flex items-center gap-1 px-2 py-1 rounded text-[11px] text-[#71717a] hover:text-[#e4e4e7] hover:bg-[#27272a]/60 transition-colors",title:"Refresh from server",children:[n.jsx(gn,{className:`w-3 h-3 ${g?"animate-spin":""}`}),"Refresh"]})]}),c&&n.jsxs("div",{className:"mx-4 mt-3 flex items-start gap-2 px-3 py-2 rounded bg-[#7f1d1d]/20 border border-[#7f1d1d]/40 text-[11px] text-[#fca5a5]",children:[n.jsx(fn,{className:"w-3 h-3 mt-0.5 shrink-0"}),n.jsx("span",{className:"font-mono",children:c})]}),n.jsxs("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-3",children:[(t==null?void 0:t.length)===0&&n.jsx("div",{className:"text-xs text-[#52525b] italic",children:"No specialists registered."}),t==null?void 0:t.map(E=>n.jsx(tm,{row:E,models:x(E.id),recommendations:i[E.id]??[],state:l[E.id]??"idle",onChange:I=>y(E.id,I),onReset:()=>y(E.id,null)},E.id))]}),n.jsxs("div",{className:"px-4 py-2 border-t border-[#27272a]/60 text-[10px] text-[#52525b]",children:["Overrides write to ",n.jsx("span",{className:"font-mono text-[#71717a]",children:"config.specialists.overrides"}),". Top-scored models are recommended per specialist role."]})]})}function tm({row:t,models:e,recommendations:s,state:r,onChange:i,onReset:o}){var u;const c=Yi[t.role]??Yi.general,d=s.find(f=>f.id===t.activeModel),l=s[0]??null,[p,g]=w.useState(!1);return n.jsxs("div",{className:"rounded-lg border border-[#27272a]/60 bg-[#18181b]/70 hover:border-[#3f3f46]/80 transition-colors",children:[n.jsxs("div",{className:"px-3 py-2 flex items-center gap-3",children:[n.jsxs("div",{className:"flex items-center gap-2 min-w-[180px]",children:[n.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{background:c},title:t.role}),n.jsxs("div",{className:"flex flex-col min-w-0",children:[n.jsx("div",{className:"text-sm font-medium truncate",children:t.name}),n.jsx("div",{className:"text-[10px] text-[#52525b] truncate",children:t.title})]})]}),n.jsxs("div",{className:"flex-1 flex items-center gap-2 min-w-0",children:[n.jsx("select",{value:t.activeModel,onChange:f=>i(f.target.value),disabled:r==="saving",className:"flex-1 min-w-0 px-2 py-1 rounded bg-[#0a0a0f] border border-[#27272a] text-xs font-mono focus:outline-none focus:border-[#6366f1] disabled:opacity-50",title:`default: ${t.defaultModel}`,children:e.map(f=>{const x=s.find(I=>I.id===f),y=(x==null?void 0:x.badges)??[],E=y.length?`${f} [${y.join(", ")}]`:f;return n.jsx("option",{value:f,children:E},f)})}),d&&d.badges.length>0&&n.jsx("div",{className:"hidden sm:flex items-center gap-1 shrink-0",children:d.badges.slice(0,3).map(f=>n.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] border ${Zp[f]??"bg-[#27272a] text-[#a1a1aa] border-[#27272a]"}`,children:f},f))}),t.overridden&&n.jsxs("button",{onClick:o,disabled:r==="saving",className:"flex items-center gap-1 px-2 py-1 rounded text-[10px] text-[#fbbf24] border border-[#fbbf24]/30 hover:bg-[#fbbf24]/10 transition-colors disabled:opacity-50",title:`Reset to default: ${t.defaultModel}`,children:[n.jsx(io,{className:"w-3 h-3"}),"Reset"]}),n.jsx("button",{onClick:()=>g(f=>!f),className:"flex items-center justify-center w-6 h-6 rounded hover:bg-[#27272a]/60 text-[#52525b] hover:text-[#a1a1aa] transition-colors",title:"Show recommendation details",children:n.jsx(ci,{className:"w-3.5 h-3.5"})}),n.jsxs("div",{className:"w-5 h-5 flex items-center justify-center shrink-0",children:[r==="saving"&&n.jsx(gn,{className:"w-3.5 h-3.5 animate-spin text-[#6366f1]"}),r==="saved"&&n.jsx(ui,{className:"w-3.5 h-3.5 text-[#10b981]"}),r==="error"&&n.jsx(fn,{className:"w-3.5 h-3.5 text-[#ef4444]"})]})]})]}),p&&n.jsxs("div",{className:"px-3 pb-3 space-y-1.5",children:[d&&n.jsxs("div",{className:"flex items-start gap-2 text-[11px] text-[#a1a1aa]",children:[n.jsx(ci,{className:"w-3 h-3 mt-0.5 shrink-0 text-[#6366f1]"}),n.jsx("span",{children:d.rationale})]}),l&&l.id!==t.activeModel&&n.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-[#10b981]",children:[n.jsx(ui,{className:"w-3 h-3 shrink-0"}),n.jsxs("span",{children:["Recommended upgrade: ",n.jsx("span",{className:"font-mono",children:l.id})," (score ",l.score,"/100)",l.badges.length>0&&n.jsxs("span",{className:"ml-1 text-[#71717a]",children:["[",l.badges.join(", "),"]"]})]})]}),d&&n.jsxs("div",{className:"grid grid-cols-3 gap-2 text-[10px] text-[#52525b]",children:[n.jsxs("div",{children:["Capability: ",n.jsxs("span",{className:"text-[#a1a1aa]",children:[d.breakdown.capabilityScore,"/40"]})]}),n.jsxs("div",{children:["Fit: ",n.jsxs("span",{className:"text-[#a1a1aa]",children:[d.breakdown.specialistFit,"/40"]})]}),n.jsxs("div",{children:["Availability: ",n.jsxs("span",{className:"text-[#a1a1aa]",children:[d.breakdown.availability,"/20"]})]})]})]}),n.jsxs("div",{className:"px-3 pb-2 flex items-center gap-2 text-[10px] text-[#52525b]",children:[n.jsxs("span",{children:["id: ",n.jsx("span",{className:"font-mono text-[#71717a]",children:t.id})]}),n.jsx("span",{children:"•"}),n.jsxs("span",{children:["role: ",n.jsx("span",{className:"font-mono",style:{color:c},children:t.role})]}),((u=t.templateMatches)==null?void 0:u.length)>0&&n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"•"}),n.jsxs("span",{className:"truncate",children:["templates: ",n.jsx("span",{className:"font-mono text-[#71717a]",children:t.templateMatches.join(", ")})]})]})]})]})}function sm(){const[t,e]=w.useState(null),[s,r]=w.useState(null),[i,o]=w.useState(null),[c,d]=w.useState(!1),[l,p]=w.useState(null),[g,u]=w.useState(null),f=w.useCallback(async()=>{p(null);try{const[I,v,A]=await Promise.all([ge("/api/telemetry/consent").then(m=>m.ok?m.json():Promise.reject(new Error(`consent ${m.status}`))),ge("/api/analytics/profile").then(m=>m.ok?m.json():null),ge("/api/telemetry/status").then(m=>m.ok?m.json():null)]);e(I),r(v),A!=null&&A.remote&&o(A.remote)}catch(I){p(I.message)}},[]);w.useEffect(()=>{const I=setInterval(()=>{ge("/api/telemetry/status").then(v=>v.ok?v.json():null).then(v=>{v!=null&&v.remote&&o(v.remote)}).catch(()=>{})},15e3);return()=>clearInterval(I)},[]),w.useEffect(()=>{f()},[f]);const x=w.useCallback(async I=>{d(!0),p(null);try{const v=await ge("/api/telemetry/consent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(I)});if(!v.ok)throw new Error(`save failed: ${v.status}`);const A=await v.json();e(m=>m?{...m,...A,consentedAt:A.enabled?new Date().toISOString():void 0}:null),u(Date.now()),setTimeout(()=>u(null),2e3)}catch(v){p(v.message)}finally{d(!1)}},[]),y=!!(t!=null&&t.enabled),E=!!(t!=null&&t.crashReports);return n.jsxs("div",{className:"w-full h-full overflow-auto bg-[#0a0a0f] text-[#e4e4e7] text-sm p-4",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[y?n.jsx(Fl,{className:"w-5 h-5 text-[#10b981]"}):n.jsx(Tr,{className:"w-5 h-5 text-[#71717a]"}),n.jsx("h3",{className:"font-semibold text-base",children:"Privacy & Telemetry"}),n.jsx("span",{className:`ml-2 text-[10px] px-2 py-0.5 rounded-full border ${y?"border-[#10b981]/40 bg-[#10b981]/10 text-[#10b981]":"border-[#3f3f46] bg-[#18181b] text-[#71717a]"}`,children:y?"ENABLED":"OFF"}),n.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[g&&n.jsxs("span",{className:"text-[11px] text-[#10b981] flex items-center gap-1",children:[n.jsx(Cl,{className:"w-3 h-3"})," Saved"]}),l&&n.jsxs("span",{className:"text-[11px] text-[#ef4444] flex items-center gap-1",children:[n.jsx(Tl,{className:"w-3 h-3"})," ",l]}),n.jsxs("button",{onClick:()=>{f()},className:"flex items-center gap-1 px-2 py-1 rounded text-[11px] text-[#71717a] hover:text-[#e4e4e7] hover:bg-[#27272a]/60 transition-colors",children:[n.jsx(gn,{className:"w-3 h-3"})," Refresh"]})]})]}),n.jsx("div",{className:"mb-4 p-4 rounded-lg border border-[#27272a]/60 bg-[#18181b]/70",children:n.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:y,disabled:c,onChange:I=>x({enabled:I.target.checked,crashReports:E}),className:"mt-1 w-4 h-4 accent-[#6366f1] disabled:opacity-50"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"font-medium",children:"Send anonymous usage stats"}),n.jsx("div",{className:"text-xs text-[#a1a1aa] mt-1 leading-relaxed",children:"OS, Node version, CPU/GPU model + VRAM, RAM, TITAN version, and install method. A heartbeat every 5 minutes so we see uptime + concurrent-session counts. Never sends: prompts, file contents, credentials, IP address, or conversations."}),(t==null?void 0:t.consentedAt)&&n.jsxs("div",{className:"text-[10px] text-[#71717a] mt-2",children:["Consented ",n.jsx("span",{className:"font-mono",children:new Date(t.consentedAt).toLocaleString()}),t.consentedVersion&&n.jsxs(n.Fragment,{children:[" on TITAN v",n.jsx("span",{className:"font-mono",children:t.consentedVersion})]})]})]})]})}),n.jsx("div",{className:`mb-4 p-4 rounded-lg border transition-opacity ${y?"border-[#27272a]/60 bg-[#18181b]/70":"border-[#27272a]/30 bg-[#18181b]/30 opacity-60"}`,children:n.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:E,disabled:c||!y,onChange:I=>x({enabled:y,crashReports:I.target.checked}),className:"mt-1 w-4 h-4 accent-[#6366f1] disabled:opacity-50"}),n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"font-medium",children:"Send crash reports"}),n.jsxs("div",{className:"text-xs text-[#a1a1aa] mt-1 leading-relaxed",children:["When TITAN throws an uncaught exception or unhandled promise rejection, send the error class, message, and stack trace. ",n.jsxs("span",{className:"text-[#fbbf24]",children:["Your $HOME path is replaced with the string ",n.jsx("span",{className:"font-mono",children:'"$HOME"'})," before sending."]})]})]})]})}),n.jsxs("div",{className:"mb-4 p-4 rounded-lg border border-[#27272a]/60 bg-[#18181b]/40",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[n.jsx(fn,{className:"w-4 h-4 text-[#6366f1]"}),n.jsx("div",{className:"text-sm font-medium",children:"What would be sent right now"})]}),s?n.jsxs("dl",{className:"grid grid-cols-[160px_1fr] gap-y-1 text-xs",children:[n.jsx("dt",{className:"text-[#71717a]",children:"installId"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[s.installId.slice(0,32),"…"]}),n.jsx("dt",{className:"text-[#71717a]",children:"os / arch"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[s.os," / ",s.arch," (",s.osRelease,")"]}),n.jsx("dt",{className:"text-[#71717a]",children:"cpu"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[s.cpuModel," · ",s.cpuCores,"c"]}),n.jsx("dt",{className:"text-[#71717a]",children:"ram"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[(s.ramTotalMB/1024).toFixed(1)," GB"]}),n.jsx("dt",{className:"text-[#71717a]",children:"gpu"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[s.gpuVendor,"/",s.gpuName," · ",(s.gpuVramMB/1024).toFixed(1)," GB VRAM"]}),n.jsx("dt",{className:"text-[#71717a]",children:"disk"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[s.diskTotalGB," GB"]}),n.jsx("dt",{className:"text-[#71717a]",children:"version / node"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[s.version," · ",s.nodeVersion]}),n.jsx("dt",{className:"text-[#71717a]",children:"install method"}),n.jsx("dd",{className:"font-mono text-[#e4e4e7]",children:s.installMethod})]}):n.jsx("div",{className:"text-xs text-[#71717a]",children:"Loading profile preview…"})]}),n.jsxs("div",{className:"mb-4 p-4 rounded-lg border border-[#27272a]/60 bg-[#18181b]/50",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[n.jsx(ao,{className:"w-4 h-4 text-[#6366f1]"}),n.jsx("div",{className:"text-sm font-medium",children:"Delivery status"}),(i==null?void 0:i.lastSuccessAt)&&!i.lastError&&n.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full border border-[#10b981]/40 bg-[#10b981]/10 text-[#10b981]",children:"FLOWING"}),(i==null?void 0:i.lastError)&&n.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full border border-[#ef4444]/40 bg-[#ef4444]/10 text-[#ef4444]",children:"ERROR"}),!(i!=null&&i.configured)&&n.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full border border-[#71717a]/40 bg-[#71717a]/10 text-[#71717a]",children:"NO REMOTE"})]}),i?n.jsxs("dl",{className:"grid grid-cols-[160px_1fr] gap-y-1 text-xs",children:[n.jsx("dt",{className:"text-[#71717a]",children:"remote URL"}),n.jsx("dd",{className:"font-mono text-[#e4e4e7] break-all",children:i.remoteUrl||"—"}),n.jsx("dt",{className:"text-[#71717a]",children:"sent / failed"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[n.jsx("span",{className:"text-[#10b981]",children:i.sentCount})," / ",n.jsx("span",{className:i.failedCount>0?"text-[#ef4444]":"text-[#71717a]",children:i.failedCount}),i.lastEventType&&n.jsxs("span",{className:"text-[#71717a]",children:[" · last event: ",n.jsx("span",{className:"text-[#a1a1aa]",children:i.lastEventType})]})]}),n.jsx("dt",{className:"text-[#71717a]",children:"last attempt"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7] flex items-center gap-1",children:[n.jsx(ps,{className:"w-3 h-3 text-[#71717a]"}),i.lastAttemptAt?new Date(i.lastAttemptAt).toLocaleString():"—"]}),n.jsx("dt",{className:"text-[#71717a]",children:"last success"}),n.jsx("dd",{className:"font-mono text-[#e4e4e7]",children:i.lastSuccessAt?new Date(i.lastSuccessAt).toLocaleString():"—"}),i.lastError&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{className:"text-[#ef4444]",children:"last error"}),n.jsx("dd",{className:"font-mono text-[#fca5a5] break-all",children:i.lastError})]})]}):n.jsx("div",{className:"text-xs text-[#71717a]",children:"Checking collector reachability…"})]}),n.jsxs("div",{className:"mb-4 p-3 rounded-lg border border-[#27272a]/60 bg-[#0a0a0f]",children:[n.jsx("div",{className:"text-[10px] text-[#71717a] uppercase tracking-wider mb-1",children:"Collector"}),n.jsx("div",{className:"font-mono text-[11px] text-[#a1a1aa] break-all",children:(t==null?void 0:t.remoteUrl)||"—"})]}),n.jsxs("div",{className:"flex items-center gap-3 text-[11px]",children:[n.jsxs("a",{href:"https://github.com/Djtony707/TITAN/blob/main/PRIVACY.md",target:"_blank",rel:"noreferrer",className:"flex items-center gap-1 text-[#6366f1] hover:underline",children:[n.jsx(hi,{className:"w-3 h-3"})," Read the full PRIVACY.md"]}),n.jsx("span",{className:"text-[#52525b]",children:"·"}),n.jsxs("a",{href:"https://github.com/Djtony707/TITAN/blob/main/src/analytics/collector.ts",target:"_blank",rel:"noreferrer",className:"flex items-center gap-1 text-[#6366f1] hover:underline",children:[n.jsx(hi,{className:"w-3 h-3"})," See the collector source"]})]})]})}const nm=oe.lazy(()=>le(()=>import("./AutopilotPanel-DA1vFEl4.js"),__vite__mapDeps([48,1,2,37,14])));function rm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(nm,{})})})}const im=oe.lazy(()=>le(()=>import("./WorkflowsPanel-C1hVHqAc.js"),__vite__mapDeps([49,1,2,37,14,3,4,10,11,12,24,27,42,16,28,20,50,51])));function om(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(im,{})})})}const am=oe.lazy(()=>le(()=>import("./LearningPanel-RpDaPvCj.js"),__vite__mapDeps([52,1,2,37,14,24,51,53,54,55,27,22,56,31,23,43,12,57,32,26,21,39,58,20,59,60,61,62,63,64,11,65,66,15,40])));function lm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(am,{})})})}const cm=oe.lazy(()=>le(()=>import("./SelfImprovePanel-BX9xYBxl.js"),__vite__mapDeps([67,1,2,24,38,20,68,54,15,14,42,23,60,28])));function dm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(cm,{})})})}const um=oe.lazy(()=>le(()=>import("./PersonasPanel-BYbD8XiV.js"),__vite__mapDeps([69,1,2])));function hm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(um,{})})})}const fm=oe.lazy(()=>le(()=>import("./PersonaProfilesPanel-CXZTZhjo.js"),__vite__mapDeps([70,1,2,37,14,24,11,16,63,20])));function pm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(fm,{})})})}const mm=oe.lazy(()=>le(()=>import("./DreamPanel-ZiOF8ybh.js"),__vite__mapDeps([71,1,2,37,14,24])));function gm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(mm,{})})})}const ym=oe.lazy(()=>le(()=>import("./HomelabPanel-XHMxqiHu.js"),__vite__mapDeps([72,1,2,37,14,73,74,4,24,20,21,56,19,31,38,40,17])));function bm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(ym,{})})})}const xm=oe.lazy(()=>le(()=>import("./NvidiaPanel-CpGBj1sn.js"),__vite__mapDeps([75,1,2,24,43,38,66,32])));function wm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(xm,{})})})}const vm=oe.lazy(()=>le(()=>import("./FilesPanel-BIsMoSfg.js"),__vite__mapDeps([76,1,2,27,24,14,77,20,12,28,43,41,11,22,55,56,31,23,51,57,32,26,21,39,58,59,60,61,62,63,64,65,66,15,40])));function _m(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(vm,{})})})}const km=oe.lazy(()=>le(()=>import("./LogsPanel-9zIJP1Xv.js"),__vite__mapDeps([78,1,2,24])));function Sm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(km,{})})})}const jm=oe.lazy(()=>le(()=>import("./TelemetryPanel-k7gJbZyS.js"),__vite__mapDeps([79,1,2,73,20,18,19,56])));function Em(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(jm,{})})})}const Nm=oe.lazy(()=>le(()=>import("./SkillsPanel-CKFndekU.js"),__vite__mapDeps([80,1,2,37,14,32,28,41])));function Cm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Nm,{})})})}const Tm=oe.lazy(()=>le(()=>import("./McpPanel-CNE7MhDu.js"),__vite__mapDeps([81,1,2,82,24,27,56,61,28])));function Rm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Tm,{})})})}const Am=oe.lazy(()=>le(()=>import("./IntegrationsPanel-BKuC_5El.js"),__vite__mapDeps([83,1,2,82,38,43,14])));function Lm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Am,{})})})}const Im=oe.lazy(()=>le(()=>import("./ChannelsPanel-8KfvAEYM.js"),__vite__mapDeps([84,1,2,37,14,24,38,43])));function Dm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Im,{})})})}const Mm=oe.lazy(()=>le(()=>import("./MeshPanel-Bq3pHHIT.js"),__vite__mapDeps([85,1,2,86,24,65])));function Om(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Mm,{})})})}const Pm=oe.lazy(()=>le(()=>import("./MemoryWikiPanel-CqNen9A6.js"),__vite__mapDeps([87,1,2,37,14,77,20,32,51])));function Wm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Pm,{})})})}const Bm=oe.lazy(()=>le(()=>import("./AutoresearchPanel-BeUCXYtX.js"),__vite__mapDeps([88,1,2,58,42,16,24,68,54,20,14])));function Um(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Bm,{})})})}const Fm=oe.lazy(()=>le(()=>import("./SelfProposalsPanel-BOoDEAYp.js"),__vite__mapDeps([89,1,2,37,14,20,55,27,22,56,31,23,51,43,12,57,32,26,21,39,58,59,60,61,62,63,24,64,11,65,66,15,40])));function $m(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Fm,{})})})}const zm=oe.lazy(()=>le(()=>import("./OverviewPanel-DII4H_R7.js"),__vite__mapDeps([90,1,2,73,37,14,74,4,20,21,56,91])));function Hm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(zm,{})})})}const Vm=oe.lazy(()=>le(()=>import("./SessionsPanel-BICnNmn0.js"),__vite__mapDeps([92,1,2,37,14,3,4,86,10,11,12,32,28])));function Gm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Vm,{})})})}const qm=oe.lazy(()=>le(()=>import("./WatchView-DyGhpKbv.js"),__vite__mapDeps([93,1,2,9])));function Ym(){return n.jsx("div",{className:"w-full h-full overflow-auto",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(qm,{})})})}const Km=oe.lazy(()=>le(()=>import("./BackupPanel-B6N1pfMT.js"),__vite__mapDeps([94,1,2,37,14,27,24,59,38])));function Jm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Km,{})})})}const Xm=oe.lazy(()=>le(()=>import("./TrainingPanel-DUl6qChY.js"),__vite__mapDeps([95,1,2,37,14,24,41])));function Qm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Xm,{})})})}const Zm=oe.lazy(()=>le(()=>import("./RecipesPanel-BRbXRcEn.js"),__vite__mapDeps([96,1,2,37,14,24,51,42,28])));function eg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Zm,{})})})}const tg=oe.lazy(()=>le(()=>import("./VramPanel-th0_Eo8o.js"),__vite__mapDeps([97,1,2,37,14,24])));function sg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(tg,{})})})}const ng=oe.lazy(()=>le(()=>import("./TeamsPanel-DjFcLsdR.js"),__vite__mapDeps([98,1,2,37,14,24,28])));function rg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(ng,{})})})}const ig=oe.lazy(()=>le(()=>import("./CronPanel-A9JHvU_O.js"),__vite__mapDeps([99,1,2,37,14,24,20,50,28])));function og(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(ig,{})})})}const ag=oe.lazy(()=>le(()=>import("./CheckpointsPanel-BCyLRLcg.js"),__vite__mapDeps([100,1,2,37,14,24,43,28])));function lg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(ag,{})})})}const cg=oe.lazy(()=>le(()=>import("./OrganismPanel-DBHyylxC.js"),__vite__mapDeps([101,1,2,37,14,24,38])));function dg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(cg,{})})})}const ug=oe.lazy(()=>le(()=>import("./FleetPanel-CSjOOsbX.js"),__vite__mapDeps([102,1,2,37,14,24,60])));function hg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(ug,{})})})}const fg=oe.lazy(()=>le(()=>import("./BrowserPanel-BGHaPi3O.js"),__vite__mapDeps([103,1,2,37,14])));function pg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(fg,{})})})}const mg=oe.lazy(()=>le(()=>import("./EvalPanel-B_fiFImG.js"),__vite__mapDeps([104,1,2,37,14,24,42])));function gg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(mg,{})})})}function yg(t){const e=Date.now()-new Date(t).getTime();if(!Number.isFinite(e)||e<0)return t;const s=Math.floor(e/1e3);if(s<60)return`${s}s ago`;const r=Math.floor(s/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function bg(t){const e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return e>=0?t.slice(e+1):t}function xg(){const[t,e]=w.useState([]),[s,r]=w.useState(!0),[i,o]=w.useState(""),[c,d]=w.useState(null),[l,p]=w.useState(""),[g,u]=w.useState(!1),[f,x]=w.useState(null),[y,E]=w.useState(null),[I,v]=w.useState(null),A=w.useCallback(async()=>{r(!0),x(null);try{const C=await ge("/api/time-travel/checkpoints?limit=100");if(!C.ok)throw new Error(`${C.status} ${C.statusText}`);const D=await C.json();e(D.checkpoints||[])}catch(C){x(C.message||"Failed to load")}finally{r(!1)}},[]);w.useEffect(()=>{A()},[A]);const m=w.useCallback((C,D)=>{v({kind:C,message:D}),setTimeout(()=>v(null),4e3)},[]),k=w.useCallback(async C=>{d(C),p(""),u(!0);try{const D=await ge(`/api/time-travel/diff/${encodeURIComponent(C)}`);if(!D.ok)throw new Error(`${D.status} ${D.statusText}`);const j=await D.json();p(j.diff||"(no diff returned)")}catch(D){p(`Failed to load diff: ${D.message}`)}finally{u(!1)}},[]),_=w.useCallback(C=>{E(C)},[]),T=w.useCallback(async()=>{if(!y)return;const C=y;E(null);try{const D=await ge(`/api/time-travel/restore/${encodeURIComponent(C)}`,{method:"POST"});if(!D.ok)throw new Error(`${D.status} ${D.statusText}`);const j=await D.json();j.ok?(m("ok",j.message||`Restored to ${C.slice(0,8)}.`),A()):m("err",j.message||"Restore failed.")}catch(D){m("err",D.message||"Restore failed.")}},[y,A,m]),S=w.useMemo(()=>{const C=i.trim().toLowerCase();return C?t.filter(D=>D.filePath.toLowerCase().includes(C)||D.toolName.toLowerCase().includes(C)||D.id.toLowerCase().includes(C)):t},[t,i]);return n.jsxs("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",color:"#e2e8f5",fontSize:12,background:"transparent"},children:[n.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:13,fontWeight:600},children:"Time Travel"}),n.jsxs("div",{style:{fontSize:10,color:"rgba(255,255,255,0.45)"},children:[t.length," file checkpoints · newest first"]})]}),n.jsxs("div",{style:{display:"flex",gap:6},children:[n.jsx("input",{type:"text",value:i,onChange:C=>o(C.target.value),placeholder:"Filter by file or tool…",style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:6,color:"#fff",fontSize:11,padding:"4px 8px",outline:"none",width:180}}),n.jsx("button",{onClick:A,disabled:s,title:"Refresh checkpoint list",style:{background:"rgba(99,102,241,0.15)",border:"1px solid rgba(99,102,241,0.35)",borderRadius:6,color:"#c7d2fe",fontSize:11,padding:"4px 10px",cursor:s?"wait":"pointer"},children:s?"…":"Refresh"})]})]}),I&&n.jsx("div",{style:{margin:"8px 14px 0",padding:"6px 10px",borderRadius:6,background:I.kind==="ok"?"rgba(34,197,94,0.12)":"rgba(239,68,68,0.12)",border:`1px solid ${I.kind==="ok"?"rgba(34,197,94,0.3)":"rgba(239,68,68,0.3)"}`,color:I.kind==="ok"?"#86efac":"#fca5a5",fontSize:11},children:I.message}),f&&n.jsx("div",{style:{margin:"8px 14px 0",padding:"6px 10px",borderRadius:6,background:"rgba(239,68,68,0.12)",border:"1px solid rgba(239,68,68,0.3)",color:"#fca5a5",fontSize:11},children:f}),n.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[n.jsx("div",{style:{flex:1,overflow:"auto",borderRight:"1px solid rgba(255,255,255,0.06)"},children:s&&t.length===0?n.jsx("div",{style:{padding:16,color:"rgba(255,255,255,0.4)"},children:"Loading checkpoints…"}):S.length===0?n.jsx("div",{style:{padding:16,color:"rgba(255,255,255,0.4)"},children:i?"No matches for that filter.":"No file checkpoints yet. They're created automatically whenever TITAN writes or edits a file."}):S.map(C=>n.jsxs("div",{onClick:()=>k(C.id),style:{padding:"8px 14px",borderBottom:"1px solid rgba(255,255,255,0.04)",cursor:"pointer",background:c===C.id?"rgba(99,102,241,0.08)":"transparent",borderLeft:c===C.id?"2px solid #818cf8":"2px solid transparent"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:2},children:[n.jsx("span",{style:{fontSize:11,fontFamily:"ui-monospace, monospace",color:"#a5b4fc"},children:C.commitHash.slice(0,8)}),n.jsx("span",{style:{fontSize:10,color:"rgba(255,255,255,0.5)"},children:yg(C.timestamp)})]}),n.jsx("div",{style:{fontSize:12,color:"#e2e8f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:C.filePath,children:bg(C.filePath)}),n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:4},children:[n.jsxs("span",{style:{fontSize:10,color:"rgba(255,255,255,0.4)"},children:["before ",n.jsx("code",{style:{color:"#fbbf24"},children:C.toolName})]}),n.jsx("button",{onClick:D=>{D.stopPropagation(),_(C.id)},title:"Restore this file to the state it was in at this checkpoint",style:{fontSize:10,padding:"2px 8px",borderRadius:999,background:"rgba(34,197,94,0.12)",border:"1px solid rgba(34,197,94,0.3)",color:"#86efac",cursor:"pointer"},children:"Restore"})]})]},C.id))}),n.jsx("div",{style:{flex:1,overflow:"auto",padding:14},children:c?g?n.jsx("div",{style:{color:"rgba(255,255,255,0.4)"},children:"Loading diff…"}):n.jsx("pre",{style:{margin:0,fontFamily:'ui-monospace, "SF Mono", Menlo, monospace',fontSize:11,lineHeight:1.5,color:"#e2e8f5",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:(l||"").split(`
|
|
969
|
-
`).map((C,D)=>{let j="rgba(255,255,255,0.7)";return C.startsWith("+")&&!C.startsWith("+++")?j="#86efac":C.startsWith("-")&&!C.startsWith("---")?j="#fca5a5":C.startsWith("@@")?j="#a5b4fc":(C.startsWith("diff")||C.startsWith("index")||C.startsWith("+++")||C.startsWith("---"))&&(j="rgba(255,255,255,0.45)"),n.jsx("div",{style:{color:j},children:C||" "},D)})}):n.jsx("div",{style:{color:"rgba(255,255,255,0.4)"},children:"Select a checkpoint on the left to see its diff vs the current file."})})]}),y&&n.jsx("div",{onClick:()=>E(null),style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10},children:n.jsxs("div",{onClick:C=>C.stopPropagation(),style:{background:"#0d0f1d",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,padding:18,maxWidth:380,color:"#e2e8f5"},children:[n.jsx("div",{style:{fontSize:14,fontWeight:600,marginBottom:8},children:"Restore this checkpoint?"}),n.jsxs("div",{style:{fontSize:12,color:"rgba(255,255,255,0.7)",marginBottom:12},children:["The file will be overwritten with its state at ",n.jsx("code",{children:y.slice(0,8)}),". A NEW checkpoint of the current state is taken first, so you can always come back."]}),n.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[n.jsx("button",{onClick:()=>E(null),style:{background:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.1)",color:"#e2e8f5",borderRadius:6,padding:"6px 12px",fontSize:12,cursor:"pointer"},children:"Cancel"}),n.jsx("button",{onClick:T,style:{background:"rgba(34,197,94,0.18)",border:"1px solid rgba(34,197,94,0.4)",color:"#86efac",borderRadius:6,padding:"6px 12px",fontSize:12,cursor:"pointer"},children:"Restore"})]})]})})]})}const Ki=5e3,Ji={planning:"#a5b4fc",delegating:"#60a5fa",observing:"#22d3ee",iterating:"#f59e0b",verifying:"#a78bfa",reporting:"#34d399",blocked:"#facc15",escalated:"#fb7185",done:"#34d399",failed:"#ef4444",cancelled:"#737373"};function wg(t){if(!Number.isFinite(t)||t<0)return"—";const e=Math.floor(t/1e3);if(e<60)return`${e}s`;const s=Math.floor(e/60);if(s<60)return`${s}m`;const r=Math.floor(s/60),i=s%60;return`${r}h ${i}m`}function vg(t){return t===0?"$0":t<.01?"$<0.01":`$${t.toFixed(2)}`}function _g(){const[t,e]=w.useState([]),[s,r]=w.useState(!0),[i,o]=w.useState(null),[c,d]=w.useState(!1),[l,p]=w.useState(""),[g,u]=w.useState(2),[f,x]=w.useState(!1),[y,E]=w.useState(null),I=w.useCallback(async()=>{try{const _=await ge("/api/missions/active");if(!_.ok)throw new Error(`${_.status} ${_.statusText}`);const T=await _.json();e(T.missions||[]),o(null)}catch(_){o(_.message||"failed to load")}finally{r(!1)}},[]);w.useEffect(()=>{I();const _=setInterval(I,Ki);return()=>clearInterval(_)},[I]);const v=w.useCallback((_,T)=>{E({kind:_,message:T}),setTimeout(()=>E(null),5e3)},[]),A=w.useCallback(async()=>{var T;const _=l.trim();if(_.length<10){v("err","Describe the mission (>=10 chars).");return}x(!0);try{const S=await ge("/api/mission/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:_,budgetUsd:g})});if(!S.ok)throw new Error(`${S.status} ${S.statusText}`);const C=await S.json();v("ok",C.message||`Mission "${((T=C.goal)==null?void 0:T.title)??"?"}" launched.`),p(""),d(!1),I()}catch(S){v("err",S.message||"launch failed")}finally{x(!1)}},[l,g,I,v]),m=w.useCallback(async _=>{try{const T=await ge(`/api/mission/${encodeURIComponent(_)}/cancel`,{method:"POST"});if(!T.ok)throw new Error(`${T.status} ${T.statusText}`);v("ok","Mission marked for cancellation."),I()}catch(T){v("err",T.message||"cancel failed")}},[I,v]),k=w.useMemo(()=>{const _={delegating:0,observing:1,iterating:2,verifying:3,planning:4,reporting:5,blocked:6,escalated:7};return[...t].sort((T,S)=>(_[T.phase]??99)-(_[S.phase]??99))},[t]);return n.jsxs("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",color:"#e2e8f5",background:"transparent"},children:[n.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:13,fontWeight:600},children:"Mission Driver"}),n.jsxs("div",{style:{fontSize:10,color:"rgba(255,255,255,0.45)"},children:[t.length," active · polling every ",Ki/1e3,"s"]})]}),n.jsxs("div",{style:{display:"flex",gap:6},children:[n.jsx("button",{onClick:()=>d(_=>!_),title:"Launch a new autonomous mission",style:{fontSize:11,padding:"4px 10px",borderRadius:6,border:"1px solid rgba(99,102,241,0.4)",background:c?"rgba(99,102,241,0.25)":"rgba(99,102,241,0.12)",color:"#c7d2fe",cursor:"pointer"},children:c?"× Close":"+ New mission"}),n.jsx("button",{onClick:I,title:"Refresh",style:{fontSize:11,padding:"4px 10px",borderRadius:6,border:"1px solid rgba(255,255,255,0.1)",background:"rgba(255,255,255,0.04)",color:"#e2e8f5",cursor:"pointer"},children:"↻"})]})]}),y&&n.jsx("div",{style:{margin:"8px 14px 0",padding:"6px 10px",borderRadius:6,fontSize:11,background:y.kind==="ok"?"rgba(34,197,94,0.12)":"rgba(239,68,68,0.12)",border:`1px solid ${y.kind==="ok"?"rgba(34,197,94,0.3)":"rgba(239,68,68,0.3)"}`,color:y.kind==="ok"?"#86efac":"#fca5a5"},children:y.message}),c&&n.jsxs("div",{style:{padding:12,borderBottom:"1px solid rgba(255,255,255,0.06)",background:"rgba(99,102,241,0.04)"},children:[n.jsx("div",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:.6,color:"#a5b4fc",marginBottom:6},children:"Describe the mission"}),n.jsx("textarea",{value:l,onChange:_=>p(_.target.value),placeholder:"e.g. 'Research the top 5 AI agent frameworks for 2026, summarize their differentiation in a markdown report, and save to ~/Documents/agent-research.md'",rows:3,style:{width:"100%",background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:6,color:"#fff",fontSize:12,padding:"6px 10px",resize:"vertical",fontFamily:"inherit",boxSizing:"border-box"}}),n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:8,gap:8},children:[n.jsxs("label",{style:{fontSize:11,color:"rgba(255,255,255,0.6)"},children:["Budget cap: $",n.jsx("input",{type:"number",value:g,onChange:_=>u(Math.max(.05,Math.min(50,Number(_.target.value)||2))),step:"0.5",min:"0.05",max:"50",style:{width:60,marginLeft:4,background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:4,color:"#fff",fontSize:11,padding:"2px 6px"}})]}),n.jsx("button",{onClick:A,disabled:f||l.trim().length<10,style:{fontSize:12,padding:"6px 14px",borderRadius:6,border:"none",background:f?"rgba(255,255,255,0.05)":"rgba(34,197,94,0.18)",color:"#86efac",cursor:f?"wait":"pointer",fontWeight:600},children:f?"Decomposing…":"🚀 Launch"})]})]}),n.jsxs("div",{style:{flex:1,overflow:"auto",padding:8},children:[i&&n.jsx("div",{style:{padding:10,color:"#fca5a5",fontSize:11},children:i}),s&&t.length===0?n.jsx("div",{style:{padding:16,color:"rgba(255,255,255,0.4)",fontSize:12},children:"Loading missions…"}):k.length===0?n.jsxs("div",{style:{padding:24,color:"rgba(255,255,255,0.45)",fontSize:12,textAlign:"center"},children:["No active missions.",n.jsx("br",{}),n.jsx("span",{style:{fontSize:11,color:"rgba(255,255,255,0.35)"},children:'Click "+ New mission" to launch one.'})]}):k.map(_=>{const T=Ji[_.phase]??"#94a3b8",S=_.subtasks.total>0?Math.round(_.subtasks.completed/_.subtasks.total*100):0;return n.jsxs("div",{style:{padding:"10px 12px",marginBottom:6,borderRadius:8,background:"rgba(255,255,255,0.025)",border:`1px solid ${_.phase==="blocked"?"rgba(250,204,21,0.4)":"rgba(255,255,255,0.06)"}`},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:4},children:[n.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#fafafa",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:_.title,children:_.title}),n.jsx("button",{onClick:()=>m(_.goalId),title:"Cancel this mission",style:{fontSize:10,padding:"2px 8px",borderRadius:999,background:"rgba(239,68,68,0.1)",border:"1px solid rgba(239,68,68,0.3)",color:"#fca5a5",cursor:"pointer",marginLeft:6},children:"Cancel"})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:10,color:"rgba(255,255,255,0.7)"},children:[n.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"1px 6px",borderRadius:4,background:`${T}22`,border:`1px solid ${T}55`,color:T,textTransform:"uppercase",letterSpacing:.5,fontWeight:600,fontSize:9},children:_.phase}),n.jsxs("span",{children:[_.subtasks.completed,"/",_.subtasks.total," subtasks (",S,"%)"]}),n.jsx("span",{children:"·"}),n.jsx("span",{children:vg(_.budget.costUsd)}),n.jsx("span",{children:"·"}),n.jsx("span",{children:wg(Date.now()-new Date(_.startedAt).getTime())})]}),_.blockedReason&&n.jsxs("div",{style:{marginTop:6,padding:"6px 8px",borderRadius:4,background:"rgba(250,204,21,0.08)",border:"1px solid rgba(250,204,21,0.25)",fontSize:11,color:"#fde68a"},children:[n.jsx("strong",{children:"Blocked:"})," ",_.blockedReason.question??"(no reason)"]}),_.lastHistory.length>0&&n.jsx("div",{style:{marginTop:6,fontSize:10,color:"rgba(255,255,255,0.45)",display:"flex",flexDirection:"column",gap:1},children:_.lastHistory.slice(-3).map((C,D)=>n.jsxs("div",{style:{display:"flex",gap:6,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[n.jsx("span",{style:{color:Ji[C.phase]??"rgba(255,255,255,0.6)",minWidth:70,fontFamily:"ui-monospace, monospace",fontSize:9},children:C.phase}),n.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.note??""})]},D))})]},_.goalId)})]})]})}const kg=6e4,Sg=[{label:"6h",hours:6},{label:"24h",hours:24},{label:"7d",hours:168}];function jg(t){return t===0?"$0":t<.01?"$<0.01":`$${t.toFixed(2)}`}function Eg(t){return t<1e3?String(t):t<1e6?`${(t/1e3).toFixed(1)}k`:`${(t/1e6).toFixed(2)}M`}function Ng(){const[t,e]=w.useState(24),[s,r]=w.useState(null),[i,o]=w.useState(!0),[c,d]=w.useState(null),l=w.useCallback(async()=>{o(!0);try{const p=await ge(`/api/missions/digest?hours=${t}`);if(!p.ok)throw new Error(`${p.status} ${p.statusText}`);const g=await p.json();r(g),d(null)}catch(p){d(p.message||"failed")}finally{o(!1)}},[t]);return w.useEffect(()=>{l();const p=setInterval(l,kg);return()=>clearInterval(p)},[l]),n.jsxs("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",color:"#e2e8f5",background:"transparent"},children:[n.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:13,fontWeight:600},children:"Daily digest"}),n.jsx("div",{style:{fontSize:10,color:"rgba(255,255,255,0.45)"},children:"what TITAN did while you were away"})]}),n.jsx("div",{style:{display:"flex",gap:4},children:Sg.map(p=>n.jsx("button",{onClick:()=>e(p.hours),style:{fontSize:10,padding:"3px 8px",borderRadius:4,border:"1px solid rgba(255,255,255,0.1)",background:t===p.hours?"rgba(99,102,241,0.25)":"rgba(255,255,255,0.03)",color:t===p.hours?"#c7d2fe":"rgba(255,255,255,0.65)",cursor:"pointer"},children:p.label},p.label))})]}),s&&n.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid rgba(255,255,255,0.04)",display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:8},children:[n.jsx(Ws,{label:"Done",value:s.stats.completed,color:"#34d399"}),n.jsx(Ws,{label:"Failed",value:s.stats.failed,color:s.stats.failed>0?"#fca5a5":"rgba(255,255,255,0.5)"}),n.jsx(Ws,{label:"Active",value:s.stats.active,color:"#60a5fa"}),n.jsx(Ws,{label:"Blocked",value:s.stats.blocked,color:s.stats.blocked>0?"#facc15":"rgba(255,255,255,0.5)"})]}),s&&(s.stats.totalCostUsd>0||s.stats.totalTokens>0)&&n.jsxs("div",{style:{padding:"6px 14px",borderBottom:"1px solid rgba(255,255,255,0.04)",fontSize:10,color:"rgba(255,255,255,0.55)",display:"flex",justifyContent:"space-between"},children:[n.jsxs("span",{children:["Spend: ",n.jsx("strong",{style:{color:"#e2e8f5"},children:jg(s.stats.totalCostUsd)})]}),n.jsxs("span",{children:["Tokens: ",n.jsx("strong",{style:{color:"#e2e8f5"},children:Eg(s.stats.totalTokens)})]})]}),n.jsxs("div",{style:{flex:1,overflow:"auto",padding:14},children:[i&&!s&&n.jsx("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:11},children:"Loading…"}),c&&n.jsx("div",{style:{color:"#fca5a5",fontSize:11},children:c}),s&&n.jsxs(n.Fragment,{children:[n.jsx("pre",{style:{margin:0,fontFamily:'ui-monospace, "SF Mono", Menlo, monospace',fontSize:11,lineHeight:1.55,color:"#e2e8f5",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:s.summaryText||"(no activity in this window)"}),s.recentLessons.length>0&&n.jsxs("div",{style:{marginTop:16,paddingTop:12,borderTop:"1px solid rgba(255,255,255,0.06)"},children:[n.jsx("div",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:.6,color:"#a5b4fc",marginBottom:6},children:"Lessons learned (Reflexion)"}),s.recentLessons.map((p,g)=>n.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.8)",padding:"4px 0",borderBottom:"1px dashed rgba(255,255,255,0.04)"},children:["• ",p]},g))]})]})]})]})}function Ws({label:t,value:e,color:s}){return n.jsxs("div",{style:{textAlign:"center",padding:"6px 4px",borderRadius:6,background:"rgba(255,255,255,0.02)"},children:[n.jsx("div",{style:{fontSize:18,fontWeight:700,color:s,lineHeight:1},children:e}),n.jsx("div",{style:{fontSize:9,color:"rgba(255,255,255,0.5)",textTransform:"uppercase",letterSpacing:.5,marginTop:4},children:t})]})}const Bs={pending:"#737373",running:"#60a5fa",done:"#34d399",failed:"#ef4444",skipped:"#a78bfa"},Xi=6e3,_t=180,nr=64,Qi=96,Us=24;function Cg(t){const e=new Map,s=new Map(t.map(i=>[i.id,i])),r=(i,o)=>{if(e.has(i))return e.get(i);if(o.has(i))return 0;const c=s.get(i);if(!c)return 0;o.add(i);const d=(c.dependsOn??[]).filter(p=>s.has(p)),l=d.length===0?0:Math.max(...d.map(p=>r(p,o)))+1;return o.delete(i),e.set(i,l),l};for(const i of t)r(i.id,new Set);return e}function Tg(){const[t,e]=w.useState([]),[s,r]=w.useState(null),[i,o]=w.useState(null),[c,d]=w.useState(null),[l,p]=w.useState(null),g=w.useCallback(async()=>{try{const v=await ge("/api/missions/active");if(!v.ok)throw new Error(`${v.status} ${v.statusText}`);const m=(await v.json()).missions||[];e(m),!s&&m.length>0&&r(m[0].goalId)}catch(v){d(v.message||"failed")}},[s]),u=w.useCallback(async v=>{try{const A=await ge(`/api/mission/${encodeURIComponent(v)}`);if(!A.ok)throw new Error(`${A.status} ${A.statusText}`);const m=await A.json();o(m),d(null)}catch(A){d(A.message||"failed to load mission"),o(null)}},[]);w.useEffect(()=>{g();const v=setInterval(g,Xi);return()=>clearInterval(v)},[g]),w.useEffect(()=>{if(!s){o(null);return}u(s);const v=setInterval(()=>u(s),Xi);return()=>clearInterval(v)},[s,u]);const{layout:f,edges:x,viewBox:y}=w.useMemo(()=>{if(!(i!=null&&i.goal.subtasks))return{layout:[],edges:[],viewBox:"0 0 600 200"};const v=i.goal.subtasks,A=Cg(v),m=new Map;for(const R of v){const P=A.get(R.id)??0;m.has(P)||m.set(P,[]),m.get(P).push(R)}const k=Array.from(m.keys()).sort((R,P)=>R-P),_=Math.max(...Array.from(m.values()).map(R=>R.length),1),T=Math.max(640,_*(_t+Us)+Us),S=k.length*Qi+nr+40,C=new Map,D=[];for(const R of k){const P=m.get(R),B=P.length*_t+(P.length-1)*Us,z=(T-B)/2,q=R*Qi+20;for(let H=0;H<P.length;H++){const J=z+H*(_t+Us);C.set(P[H].id,{x:J,y:q}),D.push({...P[H],x:J,y:q})}}const j=[];for(const R of v){const P=C.get(R.id);if(P)for(const B of R.dependsOn??[]){const z=C.get(B);z&&j.push({from:B,to:R.id,x1:z.x+_t/2,y1:z.y+nr,x2:P.x+_t/2,y2:P.y})}}return{layout:D,edges:j,viewBox:`0 0 ${T} ${S}`}},[i]),E=w.useMemo(()=>new Map(((i==null?void 0:i.goal.subtasks)??[]).map(v=>[v.id,v])),[i]),I=l?E.get(l):null;return n.jsxs("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",color:"#e2e8f5",background:"transparent"},children:[n.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:10},children:[n.jsxs("div",{style:{flex:1},children:[n.jsx("div",{style:{fontSize:13,fontWeight:600},children:"Mission graph"}),n.jsxs("div",{style:{fontSize:10,color:"rgba(255,255,255,0.45)"},children:[t.length," active mission(s) · subtask DAG"]})]}),t.length>0&&n.jsx("select",{value:s??"",onChange:v=>r(v.target.value||null),style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:6,color:"#fff",fontSize:11,padding:"4px 8px",maxWidth:240},children:t.map(v=>n.jsxs("option",{value:v.goalId,children:[v.title," [",v.phase,"]"]},v.goalId))})]}),c&&n.jsx("div",{style:{padding:10,color:"#fca5a5",fontSize:11},children:c}),n.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[n.jsx("div",{style:{flex:1,overflow:"auto",padding:14},children:i?f.length===0?n.jsx("div",{style:{padding:24,color:"rgba(255,255,255,0.45)",fontSize:12,textAlign:"center"},children:"This mission has no subtasks yet."}):n.jsxs("svg",{viewBox:y,style:{width:"100%",height:"auto"},role:"img","aria-label":"Mission subtask DAG",children:[n.jsx("defs",{children:n.jsx("marker",{id:"mg-arrow",viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:n.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"rgba(255,255,255,0.35)"})})}),x.map((v,A)=>n.jsx("line",{x1:v.x1,y1:v.y1,x2:v.x2,y2:v.y2,stroke:"rgba(255,255,255,0.25)",strokeWidth:"1.4",markerEnd:"url(#mg-arrow)"},`e-${A}`)),f.map(v=>{var _;const A=((_=i.driver)==null?void 0:_.currentSubtaskId)===v.id,m=Bs[v.status],k=l===v.id;return n.jsxs("g",{transform:`translate(${v.x}, ${v.y})`,onClick:()=>p(v.id),style:{cursor:"pointer"},children:[n.jsx("rect",{width:_t,height:nr,rx:"8",fill:A?`${m}22`:"rgba(255,255,255,0.04)",stroke:k||A?m:`${m}55`,strokeWidth:A||k?2:1}),n.jsx("circle",{cx:14,cy:14,r:"5",fill:m,children:v.status==="running"&&n.jsx("animate",{attributeName:"r",values:"4;6;4",dur:"1.2s",repeatCount:"indefinite"})}),n.jsx("text",{x:28,y:18,fontSize:"11",fontWeight:"600",fill:"#fafafa",children:v.title.length>22?v.title.slice(0,21)+"…":v.title}),n.jsxs("text",{x:28,y:34,fontSize:"9",fill:"rgba(255,255,255,0.55)",letterSpacing:"0.5",style:{textTransform:"uppercase"},children:[v.status,v.retries>0?` · ${v.retries} retr${v.retries===1?"y":"ies"}`:""]}),n.jsxs("text",{x:14,y:52,fontSize:"9",fill:"rgba(255,255,255,0.45)",children:[(v.description||"").slice(0,30),(v.description||"").length>30?"…":""]}),A&&n.jsx("text",{x:_t-8,y:14,fontSize:"8",fill:m,textAnchor:"end",fontWeight:"700",children:"NOW"})]},v.id)})]}):n.jsx("div",{style:{padding:24,color:"rgba(255,255,255,0.45)",fontSize:12,textAlign:"center"},children:t.length===0?"No active missions. Launch one via the Mission Driver widget.":"Select a mission to view its graph."})}),I&&n.jsxs("div",{style:{width:260,borderLeft:"1px solid rgba(255,255,255,0.06)",padding:14,overflow:"auto",fontSize:11},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:8},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#fafafa",flex:1},children:I.title}),n.jsx("button",{onClick:()=>p(null),style:{background:"transparent",border:"none",color:"rgba(255,255,255,0.5)",cursor:"pointer",fontSize:14,padding:0,marginLeft:6},children:"×"})]}),n.jsxs("div",{style:{marginBottom:8},children:[n.jsx("span",{style:{padding:"2px 8px",borderRadius:4,fontSize:9,fontWeight:600,textTransform:"uppercase",letterSpacing:.5,background:`${Bs[I.status]}22`,border:`1px solid ${Bs[I.status]}55`,color:Bs[I.status]},children:I.status}),I.retries>0&&n.jsxs("span",{style:{marginLeft:6,color:"rgba(255,255,255,0.5)"},children:[I.retries," retries"]})]}),n.jsx("div",{style:{color:"rgba(255,255,255,0.85)",lineHeight:1.5,marginBottom:10},children:I.description}),I.dependsOn.length>0&&n.jsxs("div",{style:{color:"rgba(255,255,255,0.55)",fontSize:10,marginBottom:6},children:[n.jsx("strong",{children:"Depends on:"})," ",I.dependsOn.map(v=>{var A;return((A=E.get(v))==null?void 0:A.title)||v}).join(", ")]}),I.completedAt&&n.jsxs("div",{style:{color:"rgba(255,255,255,0.45)",fontSize:10},children:["Completed: ",new Date(I.completedAt).toLocaleString()]})]})]}),i&&n.jsxs("div",{style:{padding:"6px 14px",borderTop:"1px solid rgba(255,255,255,0.06)",display:"flex",justifyContent:"space-between",fontSize:10,color:"rgba(255,255,255,0.55)"},children:[n.jsxs("span",{children:[i.goal.subtasks.length," subtasks · ",i.goal.progress,"% progress"]}),i.driver&&n.jsxs("span",{children:[i.driver.phase," · $",i.driver.budget.costUsd.toFixed(2)," spent"]})]})]})}function Rg(){const[t,e]=w.useState([]),[s,r]=w.useState(!0),[i,o]=w.useState(null),c=async()=>{try{const d=await fetch("/api/agents");if(!d.ok)throw new Error(`HTTP ${d.status}`);const l=await d.json();e(Array.isArray(l)?l:l.agents||[]),o(null)}catch(d){o(d.message)}finally{r(!1)}};return w.useEffect(()=>{c();const d=setInterval(c,1e4);return()=>clearInterval(d)},[]),s?n.jsx("div",{className:"w-full h-full flex items-center justify-center",children:n.jsx(so,{className:"w-4 h-4 text-[#6366f1] animate-spin"})}):i?n.jsx("div",{className:"w-full h-full flex items-center justify-center p-4",children:n.jsxs("div",{className:"text-center",children:[n.jsx(fn,{className:"w-4 h-4 text-red-400 mx-auto mb-1"}),n.jsx("span",{className:"text-[10px] text-red-400",children:i})]})}):t.length===0?n.jsx("div",{className:"w-full h-full flex items-center justify-center p-4",children:n.jsx("span",{className:"text-[10px] text-[#52525b]",children:"No active agents"})}):n.jsx("div",{className:"w-full h-full p-3 overflow-auto",children:n.jsx("div",{className:"space-y-2",children:t.map(d=>n.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[n.jsx(mo,{className:`w-3.5 h-3.5 ${d.status==="busy"?"text-[#f59e0b]":d.status==="error"?"text-red-400":"text-[#6366f1]"}`}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"text-[11px] text-[#a1a1aa] truncate",children:d.name}),n.jsxs("div",{className:"text-[10px] text-[#52525b] truncate",children:[d.role,d.model?` · ${d.model}`:""]})]}),n.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full uppercase ${d.status==="busy"?"bg-[#f59e0b]/10 text-[#f59e0b]":d.status==="error"?"bg-red-400/10 text-red-400":"bg-[#6366f1]/10 text-[#818cf8]"}`,children:d.status})]},d.id))})})}function Ag(){const[t,e]=w.useState(null),[s,r]=w.useState(!0),i=async()=>{try{const[c,d]=await Promise.allSettled([fetch("/api/health").then(g=>g.ok?g.json():null),fetch("/ollama/api/tags").then(g=>g.ok)]),l=c.status==="fulfilled"&&c.value,p=d.status==="fulfilled"&&d.value;e({gateway:l,ollama:p,version:(l==null?void 0:l.version)||"unknown",uptime:(l==null?void 0:l.uptime)||0})}catch{e({gateway:!1,ollama:!1,version:"unknown",uptime:0})}finally{r(!1)}};if(w.useEffect(()=>{i();const c=setInterval(i,3e4);return()=>clearInterval(c)},[]),s)return n.jsx("div",{className:"w-full h-full flex items-center justify-center",children:n.jsx(so,{className:"w-4 h-4 text-[#6366f1] animate-spin"})});const o=c=>{const d=Math.floor(c/3600),l=Math.floor(c%3600/60);return`${d}h ${l}m`};return n.jsx("div",{className:"w-full h-full p-3 overflow-auto",children:n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[t!=null&&t.gateway?n.jsx(Rl,{className:"w-3.5 h-3.5 text-emerald-400"}):n.jsx($l,{className:"w-3.5 h-3.5 text-red-400"}),n.jsx("span",{className:"text-[11px] text-[#a1a1aa]",children:"TITAN Gateway"})]}),n.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full uppercase ${t!=null&&t.gateway?"bg-emerald-400/10 text-emerald-400":"bg-red-400/10 text-red-400"}`,children:t!=null&&t.gateway?"Online":"Offline"})]}),n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Vt,{className:`w-3.5 h-3.5 ${t!=null&&t.ollama?"text-emerald-400":"text-red-400"}`}),n.jsx("span",{className:"text-[11px] text-[#a1a1aa]",children:"Ollama"})]}),n.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full uppercase ${t!=null&&t.ollama?"bg-emerald-400/10 text-emerald-400":"bg-red-400/10 text-red-400"}`,children:t!=null&&t.ollama?"Online":"Offline"})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[n.jsxs("div",{className:"px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[n.jsx("div",{className:"text-[9px] text-[#52525b] uppercase tracking-wider",children:"Version"}),n.jsx("div",{className:"text-[11px] text-[#a1a1aa] font-mono mt-0.5",children:t==null?void 0:t.version})]}),n.jsxs("div",{className:"px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[n.jsx("div",{className:"text-[9px] text-[#52525b] uppercase tracking-wider",children:"Uptime"}),n.jsx("div",{className:"text-[11px] text-[#a1a1aa] font-mono mt-0.5",children:o((t==null?void 0:t.uptime)||0)})]})]})]})})}function Fs({label:t,value:e,icon:s,color:r,unknown:i}){const o=Math.max(0,Math.min(100,Math.round(e)));return n.jsxs("div",{className:"px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[n.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[n.jsxs("div",{className:"flex items-center gap-1.5",children:[s,n.jsx("span",{className:"text-[10px] text-[#52525b] uppercase tracking-wider",children:t})]}),n.jsx("span",{className:"text-[11px] text-[#a1a1aa] font-mono",children:i?"—":`${o}%`})]}),n.jsx("div",{className:"h-1.5 rounded-full bg-[#27272a] overflow-hidden",children:n.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:i?"0%":`${o}%`,backgroundColor:r}})})]})}function Lg(){const[t,e]=w.useState({cpu:0,memory:0,disk:0,load:0,loaded:!1,error:null,diskAvailable:!0});w.useEffect(()=>{let r=!1;async function i(){try{const c=await ge("/api/stats");if(!c.ok){const y=`HTTP ${c.status}`;r||e(E=>({...E,loaded:!0,error:y}));return}const d=await c.json();if(r)return;const l=d.host;if(!l){e(y=>({...y,loaded:!0,error:"no host metrics"}));return}const p=typeof l.cpuPercent=="number"?l.cpuPercent:0,g=typeof l.memPercent=="number"?l.memPercent:0,u=typeof l.diskPercent=="number"?l.diskPercent:0,f=l.cores||1,x=typeof l.loadAvg1=="number"?Math.min(100,l.loadAvg1/f*100):0;e({cpu:p,memory:g,disk:u,load:x,loaded:!0,error:null,diskAvailable:!l.diskError})}catch(c){r||e(d=>({...d,loaded:!0,error:c.message}))}}i();const o=setInterval(i,3e3);return()=>{r=!0,clearInterval(o)}},[]);const s=!t.loaded||!!t.error;return n.jsxs("div",{className:"w-full h-full p-3 overflow-auto",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(Fs,{label:"CPU",value:t.cpu,icon:n.jsx(Nr,{className:"w-3 h-3 text-[#6366f1]"}),color:"#6366f1",unknown:s}),n.jsx(Fs,{label:"Memory",value:t.memory,icon:n.jsx(Al,{className:"w-3 h-3 text-[#a78bfa]"}),color:"#a78bfa",unknown:s}),n.jsx(Fs,{label:"Disk",value:t.disk,icon:n.jsx(Ll,{className:"w-3 h-3 text-[#10b981]"}),color:"#10b981",unknown:s||!t.diskAvailable}),n.jsx(Fs,{label:"Load",value:t.load,icon:n.jsx(Vt,{className:"w-3 h-3 text-[#f59e0b]"}),color:"#f59e0b",unknown:s})]}),t.error&&n.jsx("div",{className:"mt-2 text-[10px] text-[#ef4444]/80",children:t.error})]})}const Ig=[{label:"Nav",source:"system:nav",w:3,h:4,icon:n.jsx(Hl,{className:"w-3.5 h-3.5"})},{label:"Agents",source:"system:agents",w:3,h:4,icon:n.jsx(mo,{className:"w-3.5 h-3.5"})},{label:"Health",source:"system:health",w:3,h:3,icon:n.jsx(Vt,{className:"w-3.5 h-3.5"})},{label:"Stats",source:"system:stats",w:3,h:4,icon:n.jsx(Yl,{className:"w-3.5 h-3.5"})},{label:"Chat",source:"system:chat",w:4,h:5,icon:n.jsx(lo,{className:"w-3.5 h-3.5"})},{label:"Files",source:"system:files",w:4,h:6,icon:n.jsx(pn,{className:"w-3.5 h-3.5"})},{label:"Skills",source:"system:tools",w:5,h:4,icon:n.jsx(Er,{className:"w-3.5 h-3.5"})},{label:"Soma",source:"system:soma",w:6,h:6,icon:n.jsx(Il,{className:"w-3.5 h-3.5"})},{label:"Intel",source:"system:intelligence",w:6,h:5,icon:n.jsx(yt,{className:"w-3.5 h-3.5"})},{label:"Infra",source:"system:infra",w:6,h:4,icon:n.jsx(Rr,{className:"w-3.5 h-3.5"})},{label:"Tools",source:"system:tools",w:5,h:4,icon:n.jsx(jr,{className:"w-3.5 h-3.5"})},{label:"Settings",source:"system:settings",w:4,h:6,icon:n.jsx(Sr,{className:"w-3.5 h-3.5"})},{label:"Wiki",source:"system:memory-wiki",w:5,h:5,icon:n.jsx(fs,{className:"w-3.5 h-3.5"})},{label:"Research",source:"system:autoresearch",w:5,h:5,icon:n.jsx(uo,{className:"w-3.5 h-3.5"})},{label:"Proposals",source:"system:self-proposals",w:5,h:5,icon:n.jsx(go,{className:"w-3.5 h-3.5"})},{label:"Overview",source:"system:overview",w:5,h:4,icon:n.jsx(eo,{className:"w-3.5 h-3.5"})},{label:"Sessions",source:"system:sessions",w:5,h:4,icon:n.jsx(ps,{className:"w-3.5 h-3.5"})},{label:"Watch",source:"system:watch",w:6,h:5,icon:n.jsx(Vt,{className:"w-3.5 h-3.5"})},{label:"Backup",source:"system:backup",w:5,h:5,icon:n.jsx(ho,{className:"w-3.5 h-3.5"})},{label:"Training",source:"system:training",w:5,h:5,icon:n.jsx(yt,{className:"w-3.5 h-3.5"})},{label:"Recipes",source:"system:recipes",w:5,h:5,icon:n.jsx(fs,{className:"w-3.5 h-3.5"})},{label:"VRAM",source:"system:vram",w:5,h:5,icon:n.jsx(Nr,{className:"w-3.5 h-3.5"})},{label:"Teams",source:"system:teams",w:5,h:5,icon:n.jsx(Cr,{className:"w-3.5 h-3.5"})},{label:"Cron",source:"system:cron",w:5,h:5,icon:n.jsx(ps,{className:"w-3.5 h-3.5"})},{label:"Checkpoints",source:"system:checkpoints",w:5,h:5,icon:n.jsx(mn,{className:"w-3.5 h-3.5"})},{label:"Organism",source:"system:organism",w:5,h:5,icon:n.jsx(Tr,{className:"w-3.5 h-3.5"})},{label:"Fleet",source:"system:fleet",w:5,h:5,icon:n.jsx(fo,{className:"w-3.5 h-3.5"})},{label:"Browser",source:"system:browser",w:5,h:5,icon:n.jsx(to,{className:"w-3.5 h-3.5"})},{label:"Eval",source:"system:eval",w:5,h:5,icon:n.jsx(po,{className:"w-3.5 h-3.5"})}];function Dg(){const t=(e,s,r)=>{window.dispatchEvent(new CustomEvent("titan:widget:add",{detail:{source:e,w:s,h:r}}))};return n.jsx("div",{className:"w-full h-full p-3 overflow-auto",children:n.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:Ig.map(e=>n.jsxs("button",{onClick:()=>t(e.source,e.w,e.h),className:"flex items-center gap-2 px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a] text-[#71717a] hover:text-[#a1a1aa] hover:border-[#3f3f46] hover:bg-[#27272a]/30 transition-all text-left",children:[n.jsx("span",{className:"text-[#6366f1]",children:e.icon}),n.jsx("span",{className:"text-[10px] font-medium",children:e.label})]},e.source))})})}class Mg extends oe.Component{componentDidCatch(e){this.props.onError(e.message)}render(){return this.props.children}}function Og({name:t,children:e}){const[s,r]=oe.useState(null);return s?n.jsx("div",{className:"w-full h-full flex items-center justify-center p-4",children:n.jsxs("span",{className:"text-xs text-red-400",children:[t,": ",s]})}):n.jsx(Mg,{onError:r,children:e})}const Pg=oe.lazy(()=>le(()=>import("./legacy-DbwFsW2A.js"),__vite__mapDeps([105,1,2,4])).then(t=>({default:t.Responsive}))),Wg={"system:nav":ll,"system:chat":hl,"system:cmd":yl,"system:soma":bl,"system:command-post":Dp,"system:intelligence":Op,"system:memory-graph":Wp,"system:voice":Bp,"system:infra":Fp,"system:tools":zp,"system:settings":Vp,"system:files":Gp,"system:settings-general":Yp,"system:settings-security":Jp,"system:settings-audit":Qp,"system:settings-specialists":em,"system:settings-privacy":sm,"system:intelligence-autopilot":rm,"system:intelligence-workflows":om,"system:intelligence-learning":lm,"system:intelligence-self-improve":dm,"system:intelligence-personas":hm,"system:intelligence-persona-profiles":pm,"system:intelligence-dream":gm,"system:infra-homelab":bm,"system:infra-gpu":wm,"system:infra-files":_m,"system:infra-logs":Sm,"system:infra-telemetry":Em,"system:tools-skills":Cm,"system:tools-mcp":Rm,"system:tools-integrations":Lm,"system:tools-channels":Dm,"system:tools-mesh":Om,"system:agents":Rg,"system:health":Ag,"system:stats":Lg,"system:quick-links":Dg,"system:memory-wiki":Wm,"system:autoresearch":Um,"system:self-proposals":$m,"system:overview":Hm,"system:sessions":Gm,"system:watch":Ym,"system:backup":Jm,"system:training":Qm,"system:recipes":eg,"system:vram":sg,"system:teams":rg,"system:cron":og,"system:checkpoints":lg,"system:organism":dg,"system:fleet":hg,"system:browser":pg,"system:eval":gg,"system:time-travel":xg,"system:mission-driver":_g,"system:daily-digest":Ng,"system:mission-graph":Tg},Bg={lg:12,md:10,sm:6,xs:4,xxs:2},Ug=60,Fg={lg:1200,md:996,sm:768,xs:480,xxs:0},$g=[12,12],zg=["se","sw","ne","nw","e","w","n","s"],xl=oe.forwardRef(({widget:t,space:e,onRemove:s,style:r,className:i,onMouseDown:o,onMouseUp:c,onTouchStart:d,onTouchEnd:l,children:p},g)=>{const u=w.useCallback(()=>s(t.id),[t.id,s]);return n.jsxs("div",{ref:g,style:r,className:i,onMouseDown:o,onMouseUp:c,onTouchStart:d,onTouchEnd:l,children:[n.jsx(Gg,{widget:t,space:e,onRemove:u}),p]})});xl.displayName="MemoWidgetItem";const Hg=oe.memo(xl);function Vg({widget:t,space:e,onRemove:s}){const r=w.useRef(null),i=w.useRef(null),o=w.useRef(e),[c,d]=w.useState(null),[l,p]=w.useState(!0);if(w.useEffect(()=>{o.current=e},[e]),w.useEffect(()=>{if(t.format==="system"||!r.current)return;if(!t.source||t.source.trim()===""){d("Empty widget — no source code"),p(!1);return}p(!0),d(null),i.current=new al(r.current,{onLog:u=>console.log(`[Widget ${t.id}]`,u)}),i.current.setMessageHandler(u=>{var x,y,E,I;const f=o.current;if(u.type==="canvas"&&((x=u.payload)==null?void 0:x.action)==="createWidget"){const v=u.payload.def;if(!v)return{ok:!1,error:"createWidget requires a `def` object"};const A=Number.isFinite(v.w)?v.w:4,m=Number.isFinite(v.h)?v.h:4,k=Number.isFinite(v.x)&&Number.isFinite(v.y)?{x:v.x,y:v.y}:Gs(f.widgets||[],A,m);try{const _=ke.addWidget(f.id,{name:v.name||"Agent Widget",format:v.format||"react",source:v.source||"",x:k.x,y:k.y,w:A,h:m});return window.dispatchEvent(new CustomEvent("titan:space:refresh",{detail:{spaceId:f.id}})),{ok:!0,widgetId:_.id}}catch(_){return{ok:!1,error:_.message}}}if(u.type==="canvas"&&((y=u.payload)==null?void 0:y.action)==="updateWidget"){const{id:v,patch:A}=u.payload;return v?(ke.updateWidget(f.id,v,A||{}),window.dispatchEvent(new CustomEvent("titan:space:refresh",{detail:{spaceId:f.id}})),{ok:!0,id:v}):{ok:!1,error:"updateWidget requires an `id`"}}if(u.type==="canvas"&&((E=u.payload)==null?void 0:E.action)==="listWidgets")return{ok:!0,widgets:f.widgets||[]};if(u.type==="canvas"&&((I=u.payload)==null?void 0:I.action)==="removeWidget"){const v=u.payload.id;return v?(ke.removeWidget(f.id,v),window.dispatchEvent(new CustomEvent("titan:space:refresh",{detail:{spaceId:f.id}})),{ok:!0}):{ok:!1,error:"removeWidget requires an `id`"}}return{ok:!1,error:"Unknown message type"}});const g=setTimeout(()=>{p(!1),d("Sandbox timeout: widget took longer than 30s to render. The widget source may have an infinite loop or an unhandled exception. Open DevTools (F12) → Console to see the iframe-side error.")},3e4);return i.current.render(t.format,t.source).then(()=>{clearTimeout(g),p(!1)}).catch(u=>{clearTimeout(g),p(!1),d(String(u))}),()=>{var u;clearTimeout(g),(u=i.current)==null||u.destroy()}},[t.format,t.source,t.id]),t.format==="system"){const g=Wg[t.source];return g?n.jsxs("div",{className:"w-full h-full rounded-xl overflow-hidden flex flex-col group transition-colors shadow-md",style:{background:"var(--color-desk-widget-bg)",border:"1px solid var(--color-desk-border)",boxShadow:"0 4px 12px var(--theme-shadow, rgba(60,40,15,0.15))"},children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b panel-drag-handle cursor-move",style:{borderColor:"var(--color-desk-border-light)",background:"var(--theme-leather, rgba(58,37,24,0.05))"},children:[n.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--color-desk-accent)"},children:t.name}),n.jsx("button",{onClick:s,className:"opacity-0 group-hover:opacity-100 text-xs px-1 transition-opacity",style:{color:"var(--color-desk-text-muted)"},children:"×"})]}),n.jsx("div",{className:"flex-1 overflow-auto relative",children:n.jsx(Og,{name:t.name,children:n.jsx(g,{space:e,widget:t,onRemove:s})})})]}):n.jsxs("div",{className:"w-full h-full flex items-center justify-center text-xs text-red-400",children:["Unknown system widget: ",t.source]})}return n.jsxs("div",{className:"w-full h-full rounded-xl overflow-hidden flex flex-col shadow-md",style:{background:"var(--color-desk-widget-bg)",border:"1px solid var(--color-desk-border)",boxShadow:"0 4px 12px var(--theme-shadow, rgba(60,40,15,0.15))"},children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b panel-drag-handle cursor-move",style:{borderColor:"var(--color-desk-border-light)",background:"var(--theme-leather, rgba(58,37,24,0.05))"},children:[n.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--color-desk-accent)"},children:t.name}),n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("button",{onClick:g=>{g.stopPropagation(),window.dispatchEvent(new CustomEvent("titan:widget:edit",{detail:{spaceId:e.id,widgetId:t.id}}))},onMouseDown:g=>g.stopPropagation(),className:"px-1",style:{color:"var(--color-desk-text-muted)"},title:"Edit widget",children:n.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("path",{d:"m18 2 4 4-14 14H4v-4L18 2z"})})}),n.jsx("button",{onClick:s,className:"text-xs px-1",style:{color:"var(--color-desk-text-muted)"},children:"×"})]})]}),n.jsx("div",{className:"flex-1 relative",children:c?n.jsx("div",{className:"p-3 text-xs text-red-400 font-mono whitespace-pre-wrap",children:c}):n.jsxs(n.Fragment,{children:[n.jsx("iframe",{ref:r,className:"w-full h-full border-0",sandbox:"allow-scripts",title:t.name}),l&&n.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-xs",style:{background:"var(--theme-paper, rgba(253,246,227,0.85))",color:"var(--color-desk-text-muted)",fontFamily:"var(--theme-font-display, 'Georgia', serif)"},children:n.jsx("span",{className:"animate-pulse",children:"Loading widget…"})})]})})]})}const Gg=oe.memo(Vg);function qg(){const{spaceId:t}=Dl(),e=Zi(),[s,r]=w.useState(null),[i]=w.useState(!0),[o,c]=w.useState(!1),[d,l]=w.useState(null),[p,g]=w.useState(!1),[u,f]=w.useState(!1),[x,y]=w.useState(!1),[E,I]=w.useState(1200),v=w.useRef(null),A=w.useRef(null),{info:m,triggerUpdate:k,waitForReload:_}=xf(),[T,S]=w.useState(!1);w.useEffect(()=>{const $=t||"home",F=ke.get($);F?r(F):e("/space/home",{replace:!0})},[t,e]),w.useEffect(()=>{const $=()=>{const se=A.current;if(!se)return null;const Y=new ResizeObserver(te=>{for(const Q of te)I(Q.contentRect.width)});return Y.observe(se),I(se.getBoundingClientRect().width||1200),Y};let F=$();const V=setInterval(()=>{F||(F=$()),F&&clearInterval(V)},200);return()=>{F==null||F.disconnect(),clearInterval(V)}},[s==null?void 0:s.id]),w.useEffect(()=>{const $=F=>{(F.metaKey||F.ctrlKey)&&F.key==="k"&&(F.preventDefault(),f(V=>!V)),(F.metaKey||F.ctrlKey)&&F.key==="j"&&(F.preventDefault(),window.dispatchEvent(new CustomEvent("titan:chat:toggle")))};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[]),wf([{key:"?",action:()=>y(!0),description:"Show keyboard shortcuts help"},{key:"g",shift:!0,action:()=>e("/space/command"),description:"Go to Command Post space"},{key:"h",shift:!0,action:()=>e("/space/home"),description:"Go to Home space"},{key:"s",shift:!0,action:()=>e("/space/settings"),description:"Go to Settings space"},{key:"i",shift:!0,action:()=>e("/space/intelligence"),description:"Go to Intelligence space"}]);const C=w.useCallback(()=>{},[]),D=w.useRef(null),j=w.useRef(null),R=w.useCallback($=>{s&&(j.current=$,D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{const F=j.current;!F||!s||(ke.updateLayout(s.id,F.map(V=>({i:V.i,x:V.x,y:V.y,w:V.w,h:V.h}))),j.current=null,D.current=null)},50))},[s]),P=w.useCallback($=>{var se;if(!s)return;const F=(se=s.widgets)==null?void 0:se.find(Y=>Y.id===$);Dn("canvas_panel_removed",{widgetId:$,format:F==null?void 0:F.format,source:F==null?void 0:F.source}),ke.removeWidget(s.id,$);const V=Array.isArray(s.widgets)?s.widgets:[];r({...s,widgets:V.filter(Y=>Y.id!==$)})},[s]),B=w.useCallback($=>{if(!s)return;const F=ke.addWidget(s.id,$),V=Array.isArray(s.widgets)?s.widgets:[];return r({...s,widgets:[...V,F]}),Dn($.format==="system"?"canvas_system_panel_created":"canvas_panel_created",{source:$.source,name:$.name,format:$.format}),F},[s]),z=w.useCallback(($,F)=>{if(!s||!Array.isArray(s.widgets)||s.widgets.length===0)return{x:0,y:0};const V=12,se=new Set;for(const Y of s.widgets)for(let te=0;te<Y.w;te++)for(let Q=0;Q<Y.h;Q++)se.add(`${Y.x+te},${Y.y+Q}`);for(let Y=0;Y<200;Y++)for(let te=0;te<=V-$;te++){let Q=!0;for(let be=0;be<$;be++){for(let Ce=0;Ce<F;Ce++)if(se.has(`${te+be},${Y+Ce}`)){Q=!1;break}if(!Q)break}if(Q)return{x:te,y:Y}}return{x:0,y:0}},[s]),q=w.useCallback(($,F,V=4,se=4)=>{const Y=z(V,se);B({name:F,format:"system",source:$,x:Y.x,y:Y.y,w:V,h:se})},[B,z]);w.useEffect(()=>{const $=F=>{const V=F.detail;if(console.log("[TitanCanvas] titan:space:refresh received:",V),!!s&&(V==null?void 0:V.spaceId)===s.id){const se=ke.get(s.id);se&&(console.log("[TitanCanvas] Refreshing space, widget count:",se.widgets.length),r(se))}};return window.addEventListener("titan:space:refresh",$),()=>window.removeEventListener("titan:space:refresh",$)},[s]),w.useEffect(()=>{const $=F=>{const V=F.detail;if(s&&V!=null&&V.source){const se=Number.isFinite(V.w)?V.w:4,Y=Number.isFinite(V.h)?V.h:4,te=typeof V.name=="string"&&V.name.trim()?V.name.trim():String(V.source).replace("system:","").replace(/-/g," "),Q=V.format==="react"||V.format==="vanilla"||V.format==="html"||V.format==="system"?V.format:String(V.source).startsWith("system:")?"system":"react",be=z(se,Y);B({name:te,format:Q,source:String(V.source),x:be.x,y:be.y,w:se,h:Y})}};return window.addEventListener("titan:widget:add",$),()=>window.removeEventListener("titan:widget:add",$)},[s,B,z]),w.useEffect(()=>{const $=F=>{const V=F.detail;s&&(V==null?void 0:V.spaceId)===s.id&&typeof(V==null?void 0:V.widgetId)=="string"&&l(V.widgetId)};return window.addEventListener("titan:widget:edit",$),()=>window.removeEventListener("titan:widget:edit",$)},[s]),w.useEffect(()=>s?ke.observe(s.id,F=>{console.log("[TitanCanvas] CRDT observer fired, widgets:",F.length),r(V=>V&&{...V,widgets:F})}):void 0,[s==null?void 0:s.id]);const H=w.useMemo(()=>{const $=s==null?void 0:s.widgets;return Array.isArray($)?$.filter(Boolean):[]},[s]),J=w.useMemo(()=>H.map(($,F)=>({i:$.id,x:Number.isFinite($.x)?$.x:F%3*4,y:Number.isFinite($.y)?$.y:Math.floor(F/3)*4,w:Number.isFinite($.w)?$.w:4,h:Number.isFinite($.h)?$.h:4,minW:2,minH:2,maxW:12,maxH:40})),[H]);return s?n.jsxs("div",{className:"h-full w-full flex",children:[n.jsx(gp,{}),n.jsxs("div",{ref:v,className:"flex-1 relative overflow-auto",children:[n.jsx("style",{children:`
|
|
968
|
+
<div style="padding:16px;color:#e4e4e7">Hello, widget!</div>`,iframe:"",system:""};function Sp(t){return String(t||"").startsWith("system:")?"system":"react"}const jp={productivity:"#a78bfa",finance:"#34d399","health-fitness":"#f472b6","music-dj":"#c084fc",creative:"#fb923c",travel:"#60a5fa",gaming:"#f87171",social:"#38bdf8",cooking:"#fbbf24",vehicle:"#94a3b8",homelab:"#a3e635","ml-ai":"#818cf8",research:"#2dd4bf",document:"#f9a8d4",devops:"#fcd34d","e-commerce":"#fda4af",lifestyle:"#86efac",web:"#67e8f9",data:"#d8b4fe","multi-modal":"#fdba74",automation:"#facc15","smart-home":"#bef264",agents:"#e879f9","software-builder":"#7dd3fc",utilities:"#a5b4fc",media:"#fca5a5",communication:"#5eead4",education:"#c4b5fd",misc:"#9ca3af"};function Ep(t){return t.split(/[-_/]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function Np({open:t,onClose:e}){const[s,r]=w.useState([]),[i,o]=w.useState([]),[c,d]=w.useState("All"),[l,p]=w.useState(""),[g,u]=w.useState(null),[f,x]=w.useState(!1),[y,E]=w.useState(null);w.useEffect(()=>{t&&(x(!0),ge("/api/widget-gallery").then(m=>m.json()).then(m=>{r(m.templates||[]),o(m.categories||[]),x(!1)}).catch(m=>{E(m.message),x(!1)}))},[t]),w.useEffect(()=>{if(!t)return;const m=k=>{k.key==="Escape"&&e()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t,e]);const I=w.useMemo(()=>{const m=c==="All"?s:s.filter(_=>_.category===c),k=l.trim().toLowerCase();return k?m.filter(_=>[_.name,_.description,_.category,..._.tags||[],..._.triggers||[]].join(" ").toLowerCase().includes(k)):m},[c,l,s]);if(!t)return null;const v=async m=>{var k,_,T,S;u(m.id),E(null);try{const C=await ge(`/api/widget-gallery/${encodeURIComponent(m.id)}`);if(!C.ok)throw new Error(`Could not load template (${C.status})`);const D=await C.json(),j={templateId:m.id,templateName:D.name||m.name,source:D.source,format:Sp(D.source),defaultSize:{w:((k=D.defaultSize)==null?void 0:k.w)??((_=m.defaultSize)==null?void 0:_.w)??4,h:((T=D.defaultSize)==null?void 0:T.h)??((S=m.defaultSize)==null?void 0:S.h)??4}};window.dispatchEvent(new CustomEvent("titan:gallery:run-template",{detail:j})),e()}catch(C){E(C.message)}finally{u(null)}},A=["All",...i.map(m=>m.category)];return n.jsx("div",{className:"fixed inset-0 z-[2147483150] flex items-center justify-center p-4 titan-menu-overlay",onClick:e,children:n.jsxs("div",{className:"w-full max-w-4xl titan-modal-surface flex flex-col",style:{height:"min(720px, 90vh)",borderRadius:12},onClick:m=>m.stopPropagation(),children:[n.jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:"1px solid var(--theme-menu-border)"},children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Er,{className:"w-4 h-4",style:{color:"var(--theme-accent)"}}),n.jsx("h3",{className:"font-semibold text-sm",style:{color:"var(--theme-ink)",fontFamily:"var(--theme-font-display)"},children:"Widget gallery"}),n.jsx("span",{className:"text-[10px]",style:{color:"var(--theme-ink-soft)"},children:f?"Loading…":`${s.length} templates`})]}),n.jsx("button",{onClick:e,className:"titan-close-btn",title:"Close (Esc)","aria-label":"Close",children:n.jsx(js,{className:"w-4 h-4"})})]}),n.jsx("div",{className:"flex items-center gap-1.5 px-5 py-2 border-b border-[#27272a] text-[11px] overflow-x-auto",children:A.map(m=>{var k;return n.jsxs("button",{onClick:()=>d(m),className:`px-2.5 py-1 rounded-full border transition-colors whitespace-nowrap ${c===m?"border-[#6366f1] bg-[#6366f1]/15 text-white":"border-[#27272a] bg-transparent text-[#a1a1aa] hover:border-[#3f3f46] hover:text-white"}`,children:[Ep(m),m!=="All"&&n.jsx("span",{className:"ml-1.5 text-[9px] opacity-70",children:((k=i.find(_=>_.category===m))==null?void 0:k.count)??0})]},m)})}),n.jsx("div",{className:"px-5 py-2 border-b border-[#27272a]",children:n.jsxs("label",{className:"flex items-center gap-2 rounded-lg border border-[#27272a] bg-[#18181b]/60 px-3 py-2",children:[n.jsx(oo,{className:"w-3.5 h-3.5 text-[#71717a]"}),n.jsx("input",{value:l,onChange:m=>p(m.target.value),placeholder:"Search templates...",className:"flex-1 bg-transparent text-xs text-white placeholder:text-[#71717a] outline-none"})]})}),n.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[f&&n.jsx("div",{className:"flex items-center justify-center h-full text-[#a1a1aa] text-sm",children:"Loading templates…"}),y&&n.jsxs("div",{className:"flex items-center justify-center h-full text-[#f87171] text-sm",children:["Error: ",y]}),!f&&!y&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:I.map(m=>n.jsxs("button",{onClick:()=>v(m),disabled:g!==null,className:"text-left p-3 rounded-lg border border-[#27272a] bg-[#18181b]/60 hover:border-[#6366f1]/50 hover:bg-[#18181b] transition-colors group",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[n.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[n.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:jp[m.category]??"#9ca3af"}}),n.jsx("span",{className:"text-[12px] font-medium text-white truncate",children:m.name})]}),n.jsx(ao,{className:"w-3 h-3 text-[#52525b] group-hover:text-[#a5b4fc] transition-colors shrink-0"})]}),n.jsx("div",{className:"text-[11px] text-[#a1a1aa] leading-relaxed line-clamp-2",children:g===m.id?"Adding to canvas...":m.description}),m.tags&&m.tags.length>0&&n.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:m.tags.slice(0,3).map(k=>n.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-[#27272a] text-[#71717a]",children:k},k))})]},m.id))}),I.length===0&&n.jsx("div",{className:"flex items-center justify-center h-40 text-[#a1a1aa] text-sm",children:"No templates in this category."})]}),n.jsxs("div",{className:"mt-4 p-3 rounded-lg border border-dashed border-[#27272a] bg-[#0a0a0e] flex items-start gap-2",children:[n.jsx(yo,{className:"w-3.5 h-3.5 text-[#71717a] mt-0.5 shrink-0"}),n.jsxs("div",{className:"text-[11px] text-[#a1a1aa] leading-relaxed",children:["Don’t see what you want? Open the chat (click the mascot) and describe your widget in plain English. TITAN can build anything that runs inside a sandboxed iframe with access to ",n.jsx("span",{className:"font-mono text-[#d4d4d8]",children:"titan.fetch"}),","," ",n.jsx("span",{className:"font-mono text-[#d4d4d8]",children:"titan.api.call"}),", and"," ",n.jsx("span",{className:"font-mono text-[#d4d4d8]",children:"titan.state"}),"."]})]})]})]})})}const Cp=[{type:"widget",source:"system:nav",name:"Nav Widget",w:3,h:4,icon:n.jsx(yo,{className:"w-4 h-4"})},{type:"widget",source:"system:chat",name:"Chat Widget",w:4,h:5,icon:n.jsx(lo,{className:"w-4 h-4"})},{type:"widget",source:"system:soma",name:"SOMA",w:6,h:6,icon:n.jsx(yt,{className:"w-4 h-4"})},{type:"widget",source:"system:command-post",name:"Command Post",w:8,h:6,icon:n.jsx(ro,{className:"w-4 h-4"})},{type:"widget",source:"system:intelligence",name:"Intelligence",w:6,h:5,icon:n.jsx(no,{className:"w-4 h-4"})},{type:"widget",source:"system:memory-graph",name:"Memory Graph",w:8,h:7,icon:n.jsx(Gl,{className:"w-4 h-4"})},{type:"widget",source:"system:voice",name:"Voice",w:5,h:5,icon:n.jsx(co,{className:"w-4 h-4"})},{type:"widget",source:"system:infra",name:"Infrastructure",w:6,h:4,icon:n.jsx(Rr,{className:"w-4 h-4"})},{type:"widget",source:"system:tools",name:"Tools",w:5,h:4,icon:n.jsx(jr,{className:"w-4 h-4"})},{type:"widget",source:"system:settings",name:"Settings",w:5,h:5,icon:n.jsx(Sr,{className:"w-4 h-4"})},{type:"widget",source:"system:files",name:"Files",w:4,h:6,icon:n.jsx(pn,{className:"w-4 h-4"})},{type:"widget",source:"system:memory-wiki",name:"Memory Wiki",w:6,h:6,icon:n.jsx(fs,{className:"w-4 h-4"})},{type:"widget",source:"system:autoresearch",name:"Autoresearch",w:6,h:6,icon:n.jsx(uo,{className:"w-4 h-4"})},{type:"widget",source:"system:self-proposals",name:"Self-Proposals",w:6,h:6,icon:n.jsx(go,{className:"w-4 h-4"})},{type:"widget",source:"system:overview",name:"Overview",w:6,h:5,icon:n.jsx(eo,{className:"w-4 h-4"})},{type:"widget",source:"system:sessions",name:"Sessions",w:6,h:5,icon:n.jsx(ps,{className:"w-4 h-4"})},{type:"widget",source:"system:watch",name:"Watch",w:8,h:7,icon:n.jsx(Vt,{className:"w-4 h-4"})},{type:"widget",source:"system:backup",name:"Backup Manager",w:6,h:6,icon:n.jsx(ho,{className:"w-4 h-4"})},{type:"widget",source:"system:training",name:"Training Dashboard",w:6,h:6,icon:n.jsx(yt,{className:"w-4 h-4"})},{type:"widget",source:"system:recipes",name:"Recipe Kitchen",w:6,h:6,icon:n.jsx(fs,{className:"w-4 h-4"})},{type:"widget",source:"system:vram",name:"VRAM Monitor",w:6,h:6,icon:n.jsx(Nr,{className:"w-4 h-4"})},{type:"widget",source:"system:teams",name:"Team Hub",w:6,h:6,icon:n.jsx(Cr,{className:"w-4 h-4"})},{type:"widget",source:"system:cron",name:"Cron Scheduler",w:6,h:6,icon:n.jsx(ps,{className:"w-4 h-4"})},{type:"widget",source:"system:checkpoints",name:"Checkpoints",w:6,h:5,icon:n.jsx(mn,{className:"w-4 h-4"})},{type:"widget",source:"system:organism",name:"Organism Monitor",w:6,h:6,icon:n.jsx(Tr,{className:"w-4 h-4"})},{type:"widget",source:"system:fleet",name:"Fleet Router",w:6,h:5,icon:n.jsx(fo,{className:"w-4 h-4"})},{type:"widget",source:"system:browser",name:"Browser Tools",w:6,h:5,icon:n.jsx(to,{className:"w-4 h-4"})},{type:"widget",source:"system:eval",name:"Test Lab",w:6,h:6,icon:n.jsx(po,{className:"w-4 h-4"})}];function yl({currentSpaceId:t,onSpaceSelect:e,onAction:s,onClose:r}){const[i,o]=w.useState(""),[c,d]=w.useState(0),l=w.useRef(null),p=ke.list(),g=w.useMemo(()=>{const u=i.toLowerCase(),f=p.filter(y=>y.id!==t&&y.name.toLowerCase().includes(u)).map(y=>({type:"space",id:y.id,name:y.name,color:y.color})),x=Cp.filter(y=>y.name.toLowerCase().includes(u)).map(y=>({type:"action",action:y,name:y.name}));return[...f,...x]},[i,p,t]);return w.useEffect(()=>{var u;(u=l.current)==null||u.focus()},[]),w.useEffect(()=>{d(0)},[i]),w.useEffect(()=>{const u=f=>{if((f.metaKey||f.ctrlKey)&&f.key.toLowerCase()==="k"){f.preventDefault(),r();return}if(f.key==="Escape"){r();return}if(f.key==="ArrowDown"){f.preventDefault(),d(x=>Math.min(x+1,g.length-1));return}if(f.key==="ArrowUp"){f.preventDefault(),d(x=>Math.max(x-1,0));return}if(f.key==="Enter"){f.preventDefault();const x=g[c];if(!x)return;x.type==="space"&&e(x.id),x.type==="action"&&s(x.action)}};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[g,c,e,s,r]),n.jsx("div",{className:"fixed inset-0 z-[2147483200] flex items-start justify-center pt-[20vh]",onClick:r,children:n.jsxs("div",{className:"w-full max-w-lg bg-[#18181b]/98 backdrop-blur-xl border border-[#27272a]/60 rounded-2xl shadow-2xl shadow-black/60 overflow-hidden",onClick:u=>u.stopPropagation(),children:[n.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-[#27272a]/40",children:[n.jsx(oo,{className:"w-4 h-4 text-[#3f3f46]"}),n.jsx("input",{ref:l,value:i,onChange:u=>o(u.target.value),placeholder:"Search spaces, widgets, actions...",className:"flex-1 bg-transparent text-sm text-[#e4e4e7] placeholder:text-[#3f3f46] outline-none"}),n.jsx("button",{onClick:r,className:"text-[#3f3f46] hover:text-[#71717a]",children:n.jsx(js,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"max-h-[50vh] overflow-auto py-1",children:[g.length===0&&n.jsxs("div",{className:"px-4 py-6 text-center text-xs text-[#52525b]",children:['No results for "',i,'"']}),g.map((u,f)=>n.jsxs("button",{onClick:()=>{u.type==="space"&&e(u.id),u.type==="action"&&s(u.action)},className:`w-full flex items-center gap-3 px-4 py-2.5 text-left transition-colors ${f===c?"bg-[#6366f1]/10 text-[#818cf8]":"text-[#a1a1aa] hover:bg-[#27272a]/30"}`,children:[u.type==="space"?n.jsx("div",{className:"w-4 h-4 rounded-full",style:{background:u.color||"#52525b"}}):n.jsx("span",{className:"text-[#6366f1]/60",children:u.action.icon}),n.jsx("span",{className:"text-sm",children:u.name}),n.jsx("span",{className:"ml-auto text-[10px] text-[#3f3f46] uppercase tracking-wider",children:u.type==="space"?"Space":"Widget"})]},u.type==="space"?u.id:u.action.source))]}),n.jsxs("div",{className:"px-4 py-2 border-t border-[#27272a]/40 flex items-center gap-3 text-[10px] text-[#3f3f46]",children:[n.jsx("span",{children:"↑↓ Navigate"}),n.jsx("span",{children:"↵ Select"}),n.jsx("span",{children:"ESC Close"})]})]})})}const Tp=oe.lazy(()=>le(()=>import("./SomaView-BejcfdMM.js"),__vite__mapDeps([0,1,2,3,4,5,6]))),Ae={bgBase:"var(--theme-bg-base, var(--color-bg, #09090b))",surface:"color-mix(in srgb, var(--theme-bg-grain, var(--color-bg-secondary, #18181b)) 82%, transparent)",surfaceSoft:"color-mix(in srgb, var(--theme-bg-grain, var(--color-bg-tertiary, #27272a)) 62%, transparent)",border:"color-mix(in srgb, var(--theme-metal-dark, var(--color-border, #3f3f46)) 66%, transparent)",ink:"var(--theme-paper-fg, var(--color-text, #fafafa))",inkSoft:"color-mix(in srgb, var(--theme-paper-fg, var(--color-text-secondary, #a1a1aa)) 72%, transparent)",paperFg:"var(--theme-paper-fg, var(--color-text-secondary, #a1a1aa))",accent:"var(--theme-accent, var(--color-accent, #6366f1))",success:"var(--color-success, #22c55e)",error:"var(--color-error, #ef4444)"},sr={background:Ae.bgBase,color:Ae.ink};function bl(){const[t,e]=w.useState(null),[s,r]=w.useState(!1),[i,o]=w.useState(null),c=w.useCallback(async()=>{var p;try{const g=await ge("/api/config");if(!g.ok)throw new Error(`HTTP ${g.status}`);const u=await g.json();e(!!((p=u==null?void 0:u.organism)!=null&&p.enabled)),o(null)}catch(g){o(g.message),e(!1)}},[]);w.useEffect(()=>{c()},[c]);const d=w.useRef(0),l=w.useCallback(async p=>{const g=++d.current;r(!0),o(null);try{const u=await ge("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({organism:{enabled:p}})});if(g!==d.current)return;if(!u.ok)throw new Error(`HTTP ${u.status}`);e(p),window.dispatchEvent(new CustomEvent("titan:soma:changed",{detail:{enabled:p}}))}catch(u){if(g!==d.current)return;o(u.message)}finally{g===d.current&&r(!1)}},[]);return t===null?n.jsx("div",{className:"w-full h-full flex items-center justify-center text-xs",style:{...sr,color:Ae.paperFg},children:"Loading Soma…"}):t?n.jsxs("div",{className:"w-full h-full overflow-auto flex flex-col",style:sr,children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b",style:{background:Ae.surface,borderColor:Ae.border},children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-1.5 h-1.5 rounded-full animate-pulse",style:{background:Ae.success}}),n.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:Ae.success},children:"Soma active"})]}),n.jsxs("button",{onClick:()=>l(!1),disabled:s,className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full border text-[10px] disabled:opacity-60 transition-colors",style:{borderColor:Ae.border,color:Ae.inkSoft,background:Ae.surfaceSoft},title:"Disable Soma",children:[n.jsx(di,{className:"w-3 h-3"}),s?"saving…":"disable"]})]}),n.jsx("div",{className:"flex-1 overflow-auto",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"p-4 text-xs",style:{color:Ae.paperFg},children:"Loading Soma dashboard…"}),children:n.jsx(Tp,{})})})]}):n.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center gap-4 p-6 text-center",style:sr,children:[n.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center",style:{background:"color-mix(in srgb, var(--theme-accent, var(--color-accent, #6366f1)) 18%, transparent)",border:`1px solid ${Ae.border}`},children:n.jsx(Vt,{className:"w-7 h-7",style:{color:Ae.accent}})}),n.jsxs("div",{className:"space-y-1 max-w-md",children:[n.jsx("h3",{className:"text-lg font-semibold",style:{color:Ae.ink},children:"Soma is off"}),n.jsx("p",{className:"text-xs leading-relaxed",style:{color:Ae.inkSoft},children:"TITAN’s homeostatic drive layer. When enabled, TITAN has a sense of its own state — purpose, curiosity, hunger, safety, social, rest — and will propose work when those drives drift. Every proposal still requires your approval."})]}),n.jsxs("button",{onClick:()=>l(!0),disabled:s,className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-full disabled:opacity-60 disabled:cursor-not-allowed text-sm font-medium transition-colors",style:{background:Ae.accent,color:"var(--theme-bg-base, var(--color-bg, #09090b))"},children:[n.jsx(di,{className:"w-4 h-4"}),s?"Enabling…":"Enable Soma"]}),i&&n.jsx("p",{className:"text-xs",style:{color:Ae.error},children:i}),n.jsx("p",{className:"text-[10px]",style:{color:Ae.paperFg},children:"You can turn this off anytime from the same button."})]})}const Rp={calm:{primary:"#6366f1",glow:"rgba(99,102,241,0.4)",pulse:"rgba(99,102,241,0.15)"},focused:{primary:"#10b981",glow:"rgba(16,185,129,0.4)",pulse:"rgba(16,185,129,0.15)"},excited:{primary:"#f59e0b",glow:"rgba(245,158,11,0.4)",pulse:"rgba(245,158,11,0.15)"},concerned:{primary:"#ef4444",glow:"rgba(239,68,68,0.4)",pulse:"rgba(239,68,68,0.15)"},dreaming:{primary:"#8b5cf6",glow:"rgba(139,92,246,0.4)",pulse:"rgba(139,92,246,0.15)"}},Ee={surface:"color-mix(in srgb, var(--theme-bg-grain, var(--color-bg-secondary, #18181b)) 90%, transparent)",surfaceSoft:"color-mix(in srgb, var(--theme-bg-grain, var(--color-bg-tertiary, #27272a)) 62%, transparent)",overlay:"color-mix(in srgb, var(--theme-bg-base, var(--color-bg, #09090b)) 56%, transparent)",border:"color-mix(in srgb, var(--theme-metal-dark, var(--color-border, #3f3f46)) 66%, transparent)",metal:"var(--theme-metal, var(--color-border-light, #52525b))",ink:"var(--theme-paper-fg, var(--color-text, #fafafa))",accent:"var(--theme-accent, var(--color-accent, #6366f1))",warning:"var(--color-warning, #f59e0b)"};function Ap(t,e,s){if(!s)return{emotion:"dreaming",intensity:.25,activity:"Dormant"};const r=e[0],i=Math.min(1,t/2);switch(r){case"purpose":return{emotion:"focused",intensity:.4+i*.4,activity:"Pursuing purpose"};case"curiosity":return{emotion:"excited",intensity:.4+i*.5,activity:"Exploring"};case"hunger":return{emotion:"focused",intensity:.5+i*.3,activity:"Satiating"};case"safety":return{emotion:"concerned",intensity:.5+i*.4,activity:"Securing"};case"social":return{emotion:"calm",intensity:.3+i*.3,activity:"Connecting"};case"rest":return{emotion:"dreaming",intensity:.2+i*.2,activity:"Recuperating"};default:return t>.5?{emotion:"focused",intensity:i,activity:"Processing"}:{emotion:"calm",intensity:.3,activity:"Observing"}}}function Lp(){const[t,e]=w.useState(!1),[s,r]=w.useState({emotion:"calm",intensity:.3,activity:"Observing"}),[i,o]=w.useState(!1),[c,d]=w.useState({x:280,y:80}),[l,p]=w.useState(!1),g=w.useRef({x:0,y:0}),u=w.useRef(null);w.useEffect(()=>{let v=!1;const A=async()=>{try{const k=await ge("/api/soma/state");if(!k.ok||v)return;const _=await k.json();if(v)return;r(Ap(Number((_==null?void 0:_.totalPressure)??0),Array.isArray(_==null?void 0:_.dominantDrives)?_.dominantDrives:[],!!(_!=null&&_.enabled)))}catch{}};A();const m=setInterval(A,15e3);return()=>{v=!0,clearInterval(m)}},[]),w.useEffect(()=>{const v=A=>{var m;(m=u.current)!=null&&m.contains(A.target)||o(!1)};return window.addEventListener("mousedown",v),()=>window.removeEventListener("mousedown",v)},[]);const f=v=>{v.button===0&&(g.current={x:v.clientX-c.x,y:v.clientY-c.y},p(!0))},x=v=>{l&&d({x:v.clientX-g.current.x,y:v.clientY-g.current.y})},y=()=>{p(!1)},E=Rp[s.emotion],I=s.activity==="Dormant"?Ee.metal:Ee.accent;return n.jsxs(n.Fragment,{children:[t&&n.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center backdrop-blur-sm",style:{background:Ee.overlay},onClick:()=>e(!1),children:n.jsxs("div",{className:"border rounded-2xl shadow-2xl overflow-hidden",style:{width:"min(900px, 90vw)",height:"min(600px, 80vh)",background:Ee.surface,borderColor:Ee.border,color:Ee.ink,boxShadow:"0 24px 64px color-mix(in srgb, var(--theme-bg-base, var(--color-bg, #09090b)) 72%, transparent)"},onClick:v=>v.stopPropagation(),children:[n.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b",style:{borderColor:Ee.border},children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(yt,{className:"w-4 h-4",style:{color:I}}),n.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wider",style:{color:Ee.ink},children:"SOMA Consciousness"})]}),n.jsx("button",{onClick:()=>e(!1),className:"p-1",style:{color:Ee.metal},children:n.jsx(js,{className:"w-4 h-4"})})]}),n.jsx("div",{className:"h-[calc(100%-40px)]",children:n.jsx(bl,{})})]})}),n.jsxs("div",{ref:u,className:"fixed z-50 select-none",style:{left:c.x,top:c.y},onMouseDown:f,onMouseMove:x,onMouseUp:y,onMouseLeave:y,children:[i&&n.jsxs("div",{className:"absolute bottom-full left-0 mb-2 backdrop-blur-xl border rounded-xl shadow-2xl overflow-hidden min-w-[160px] py-1",style:{background:Ee.surface,borderColor:Ee.border,boxShadow:"0 18px 40px color-mix(in srgb, var(--theme-bg-base, var(--color-bg, #09090b)) 70%, transparent)"},children:[n.jsxs("button",{onClick:()=>{e(!0),o(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-left text-[11px] transition-colors",style:{color:Ee.ink,background:"transparent"},children:[n.jsx(yt,{className:"w-3.5 h-3.5",style:{color:I}}),"Open SOMA"]}),n.jsxs("button",{onClick:()=>{o(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-left text-[11px] transition-colors",style:{color:Ee.ink,background:"transparent"},children:[n.jsx(Er,{className:"w-3.5 h-3.5",style:{color:Ee.warning}}),"Summarize Canvas"]}),n.jsxs("button",{onClick:()=>{o(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-left text-[11px] transition-colors",style:{color:Ee.ink,background:"transparent"},children:[n.jsx(Nl,{className:"w-3.5 h-3.5",style:{color:Ee.accent}}),"Run Self-Check"]})]}),n.jsxs("div",{className:"relative cursor-pointer group",onClick:()=>!l&&e(!0),onContextMenu:v=>{v.preventDefault(),o(!0)},children:[n.jsx("div",{className:"absolute inset-0 rounded-full animate-ping opacity-20",style:{background:E.pulse,animationDuration:`${3-s.intensity*2}s`}}),n.jsx("div",{className:"absolute -inset-2 rounded-full opacity-30 blur-md transition-all duration-1000",style:{background:E.glow}}),n.jsx("div",{className:"relative w-12 h-12 rounded-full flex items-center justify-center transition-all duration-500 hover:scale-110",style:{background:`radial-gradient(circle at 30% 30%, ${I}, ${Ee.metal})`,boxShadow:`0 0 ${20+s.intensity*30}px ${E.glow}, inset 0 0 10px color-mix(in srgb, var(--theme-ink, var(--color-text, #fafafa)) 12%, transparent)`},children:n.jsx(yt,{className:"w-5 h-5",style:{color:Ee.ink}})}),n.jsx("div",{className:"absolute -bottom-5 left-1/2 -translate-x-1/2 whitespace-nowrap",children:n.jsx("span",{className:"text-[9px] font-medium uppercase tracking-wider px-1.5 py-0.5 rounded border",style:{color:Ee.ink,background:Ee.surfaceSoft,borderColor:Ee.border},children:s.activity})})]})]})]})}const Ip=oe.lazy(()=>le(()=>import("./CommandPostHub-BLnNTvBO.js"),__vite__mapDeps([7,1,2,3,4,8,9,10,11,12,5,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28])));function Dp(){return n.jsx("div",{className:"w-full h-full overflow-auto p-2",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"p-4 text-xs text-[#52525b]",children:"Loading Command Post..."}),children:n.jsx(Ip,{})})})}const Mp=oe.lazy(()=>le(()=>import("./IntelligenceView-DXYSyS1a.js"),__vite__mapDeps([29,1,2,4])));function Op(){return n.jsx("div",{className:"w-full h-full overflow-auto",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"p-4 text-xs text-[#52525b]",children:"Loading Intelligence..."}),children:n.jsx(Mp,{})})})}const Pp=oe.lazy(()=>le(()=>import("./MemoryGraphPanel-Qle7Bodz.js"),__vite__mapDeps([30,1,2,31,24,28,32])));function Wp(){return n.jsx("div",{className:"w-full h-full overflow-auto bg-[#09090b]",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsxs("div",{className:"text-center",children:[n.jsx("div",{className:"w-8 h-8 rounded-full border-2 border-[#6366f1]/20 border-t-[#6366f1] animate-spin mx-auto mb-3"}),n.jsx("p",{className:"text-[11px] text-[#52525b]",children:"Loading memory graph..."})]})}),children:n.jsx("div",{className:"p-4",children:n.jsx(Pp,{})})})})}function Bp(){const[t,e]=w.useState(!1);return t?n.jsx(Wl,{onClose:()=>e(!1)}):n.jsx("div",{className:"w-full h-full flex flex-col items-center justify-center bg-[#09090b]",children:n.jsxs("button",{onClick:()=>e(!0),className:"group relative flex flex-col items-center gap-4",children:[n.jsxs("div",{className:"relative w-20 h-20 rounded-full flex items-center justify-center transition-all duration-300 group-hover:scale-110",children:[n.jsx("div",{className:"absolute inset-0 rounded-full bg-[#6366f1]/20 animate-pulse"}),n.jsx("div",{className:"absolute inset-0 rounded-full bg-gradient-to-br from-[#6366f1]/30 to-[#4f46e5]/10 border border-[#6366f1]/30"}),n.jsx(co,{className:"w-8 h-8 text-[#818cf8] relative z-10"})]}),n.jsxs("div",{className:"text-center",children:[n.jsx("p",{className:"text-sm font-medium text-[#a1a1aa]",children:"Tap to speak"}),n.jsx("p",{className:"text-[10px] text-[#52525b] mt-1",children:"F5-TTS · Voice Cloning"})]})]})})}const Up=oe.lazy(()=>le(()=>import("./InfraView-DgasEqoR.js"),__vite__mapDeps([33,1,2,4])));function Fp(){return n.jsx("div",{className:"w-full h-full overflow-auto",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"p-4 text-xs text-[#52525b]",children:"Loading Infrastructure..."}),children:n.jsx(Up,{})})})}const $p=oe.lazy(()=>le(()=>import("./ToolsView-C97QnPeY.js"),__vite__mapDeps([34,1,2,4])));function zp(){return n.jsx("div",{className:"w-full h-full overflow-auto",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"p-4 text-xs text-[#52525b]",children:"Loading Tools..."}),children:n.jsx($p,{})})})}const Hp=oe.lazy(()=>le(()=>import("./SettingsView-BZIgBz0P.js"),__vite__mapDeps([35,1,2,4])));function Vp(){return n.jsx("div",{className:"w-full h-full overflow-auto",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"p-4 text-xs text-[#52525b]",children:"Loading Settings..."}),children:n.jsx(Hp,{})})})}function Gp(){const[t,e]=w.useState([]),[s,r]=w.useState("/"),[i,o]=w.useState(!1),[c,d]=w.useState(null),l=async()=>{o(!0),d(null);try{const p=await ge(`/api/files?path=${encodeURIComponent(s)}`);if(p.ok){const g=await p.json();e(g.files||[])}else e([]),d(`Couldn't load files (HTTP ${p.status})`)}catch(p){e([]),d(`Couldn't reach /api/files — ${p.message}`)}finally{o(!1)}};return w.useEffect(()=>{l()},[s]),n.jsxs("div",{className:"w-full h-full flex flex-col",children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-[#27272a]/40",children:[n.jsxs("div",{className:"flex items-center gap-1 text-[11px] text-[#71717a]",children:[n.jsx("span",{className:"text-[#6366f1]",children:"~"}),n.jsx(Bl,{className:"w-3 h-3"}),n.jsx("span",{children:s})]}),n.jsx("button",{onClick:l,className:"p-1 text-[#3f3f46] hover:text-[#71717a]",children:n.jsx(gn,{className:`w-3 h-3 ${i?"animate-spin":""}`})})]}),n.jsxs("div",{className:"flex-1 overflow-auto",children:[c&&n.jsx("div",{className:"px-3 py-2 text-[11px] text-[#ef4444]/80",children:c}),!c&&!i&&t.length===0&&n.jsx("div",{className:"px-3 py-2 text-[11px] text-[#52525b]",children:"No files"}),t.map(p=>n.jsxs("button",{onClick:()=>p.type==="directory"&&r(p.path),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left hover:bg-[#27272a]/20 transition-colors",children:[p.type==="directory"?n.jsx(Ul,{className:"w-3.5 h-3.5 text-[#f59e0b]"}):n.jsx(pn,{className:"w-3.5 h-3.5 text-[#6366f1]"}),n.jsx("span",{className:"text-[12px] text-[#a1a1aa]",children:p.name})]},p.path))]})]})}const qp=oe.lazy(()=>le(()=>import("./SettingsPanel-Cp8decIS.js"),__vite__mapDeps([36,1,2,3,4,37,14,5,38,39,24,40,41,42,43])));function Yp(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(qp,{})})})}const Kp=oe.lazy(()=>le(()=>import("./SecurityPanel-BcnpsElV.js"),__vite__mapDeps([44,1,2,37,14])));function Jp(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Kp,{})})})}const Xp=oe.lazy(()=>le(()=>import("./AuditPanel-TdDAyJUQ.js"),__vite__mapDeps([45,1,2,46,24,47])));function Qp(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Xp,{})})})}const Yi={researcher:"#60a5fa",engineer:"#f87171",manager:"#a78bfa",ceo:"#fbbf24",general:"#9ca3af"},Zp={Recommended:"bg-[#10b981]/15 text-[#10b981] border-[#10b981]/30",Reasoning:"bg-[#8b5cf6]/15 text-[#8b5cf6] border-[#8b5cf6]/30",Fast:"bg-[#0ea5e9]/15 text-[#0ea5e9] border-[#0ea5e9]/30",Light:"bg-[#f59e0b]/15 text-[#f59e0b] border-[#f59e0b]/30","Long Context":"bg-[#6366f1]/15 text-[#6366f1] border-[#6366f1]/30","High Output":"bg-[#ec4899]/15 text-[#ec4899] border-[#ec4899]/30","Needs Key":"bg-[#ef4444]/15 text-[#ef4444] border-[#ef4444]/30"};function em(){const[t,e]=w.useState(null),[s,r]=w.useState({}),[i,o]=w.useState({}),[c,d]=w.useState(null),[l,p]=w.useState({}),[g,u]=w.useState(!0),f=w.useCallback(async()=>{d(null);try{const[E,I]=await Promise.all([ge("/api/specialists"),ge("/api/models")]);if(!E.ok)throw new Error(`Specialists request failed: ${E.status}`);if(!I.ok)throw new Error(`Models request failed: ${I.status}`);const v=await E.json(),A=await I.json();e(v),r(A);const m={};await Promise.all(v.map(async k=>{try{const _=await ge(`/api/specialists/${encodeURIComponent(k.id)}/recommendations`);if(_.ok){const T=await _.json();T.recommendations&&(m[k.id]=T.recommendations)}}catch{}})),o(m)}catch(E){d(E.message)}finally{u(!1)}},[]);w.useEffect(()=>{f()},[f]);const x=w.useCallback(E=>{const I=i[E];if(I&&I.length)return I.map(A=>A.id);const v=new Set;if(s&&typeof s=="object")for(const A of Object.keys(s)){const m=s[A];if(Array.isArray(m))for(const k of m)typeof k=="string"?v.add(k):k&&typeof k=="object"&&"id"in k&&typeof k.id=="string"&&v.add(k.id)}if(Array.isArray(t))for(const A of t)A!=null&&A.activeModel&&v.add(A.activeModel),A!=null&&A.defaultModel&&v.add(A.defaultModel);return Array.from(v).sort((A,m)=>A.localeCompare(m))},[i,s,t]),y=w.useCallback(async(E,I)=>{p(v=>({...v,[E]:"saving"}));try{const v=await ge(`/api/specialists/${encodeURIComponent(E)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:I})});if(!v.ok){const m=await v.text().catch(()=>"");throw new Error(`PATCH failed (${v.status}): ${m||v.statusText}`)}const A=await v.json();e(m=>(m==null?void 0:m.map(k=>k.id===E?{...k,activeModel:A.activeModel??k.defaultModel,overridden:(A.activeModel??k.defaultModel)!==k.defaultModel}:k))??null),p(m=>({...m,[E]:"saved"})),setTimeout(()=>{p(m=>{if(m[E]!=="saved")return m;const k={...m};return delete k[E],k})},1500)}catch(v){p(A=>({...A,[E]:"error"})),d(`${E}: ${v.message}`)}},[]);return g&&!t?n.jsx("div",{className:"h-full w-full flex items-center justify-center text-xs text-[#52525b]",children:"Loading specialists…"}):n.jsxs("div",{className:"w-full h-full flex flex-col bg-[#0a0a0f] text-[#e4e4e7] text-sm",children:[n.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[#27272a]/60",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Cr,{className:"w-4 h-4 text-[#6366f1]"}),n.jsx("h3",{className:"font-semibold",children:"Specialist Models"}),n.jsxs("span",{className:"text-[10px] text-[#52525b]",children:[(t==null?void 0:t.length)??0," sub-agents"]})]}),n.jsxs("button",{onClick:()=>{u(!0),f()},className:"flex items-center gap-1 px-2 py-1 rounded text-[11px] text-[#71717a] hover:text-[#e4e4e7] hover:bg-[#27272a]/60 transition-colors",title:"Refresh from server",children:[n.jsx(gn,{className:`w-3 h-3 ${g?"animate-spin":""}`}),"Refresh"]})]}),c&&n.jsxs("div",{className:"mx-4 mt-3 flex items-start gap-2 px-3 py-2 rounded bg-[#7f1d1d]/20 border border-[#7f1d1d]/40 text-[11px] text-[#fca5a5]",children:[n.jsx(fn,{className:"w-3 h-3 mt-0.5 shrink-0"}),n.jsx("span",{className:"font-mono",children:c})]}),n.jsxs("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-3",children:[(t==null?void 0:t.length)===0&&n.jsx("div",{className:"text-xs text-[#52525b] italic",children:"No specialists registered."}),t==null?void 0:t.map(E=>n.jsx(tm,{row:E,models:x(E.id),recommendations:i[E.id]??[],state:l[E.id]??"idle",onChange:I=>y(E.id,I),onReset:()=>y(E.id,null)},E.id))]}),n.jsxs("div",{className:"px-4 py-2 border-t border-[#27272a]/60 text-[10px] text-[#52525b]",children:["Overrides write to ",n.jsx("span",{className:"font-mono text-[#71717a]",children:"config.specialists.overrides"}),". Top-scored models are recommended per specialist role."]})]})}function tm({row:t,models:e,recommendations:s,state:r,onChange:i,onReset:o}){var u;const c=Yi[t.role]??Yi.general,d=s.find(f=>f.id===t.activeModel),l=s[0]??null,[p,g]=w.useState(!1);return n.jsxs("div",{className:"rounded-lg border border-[#27272a]/60 bg-[#18181b]/70 hover:border-[#3f3f46]/80 transition-colors",children:[n.jsxs("div",{className:"px-3 py-2 flex items-center gap-3",children:[n.jsxs("div",{className:"flex items-center gap-2 min-w-[180px]",children:[n.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{background:c},title:t.role}),n.jsxs("div",{className:"flex flex-col min-w-0",children:[n.jsx("div",{className:"text-sm font-medium truncate",children:t.name}),n.jsx("div",{className:"text-[10px] text-[#52525b] truncate",children:t.title})]})]}),n.jsxs("div",{className:"flex-1 flex items-center gap-2 min-w-0",children:[n.jsx("select",{value:t.activeModel,onChange:f=>i(f.target.value),disabled:r==="saving",className:"flex-1 min-w-0 px-2 py-1 rounded bg-[#0a0a0f] border border-[#27272a] text-xs font-mono focus:outline-none focus:border-[#6366f1] disabled:opacity-50",title:`default: ${t.defaultModel}`,children:e.map(f=>{const x=s.find(I=>I.id===f),y=(x==null?void 0:x.badges)??[],E=y.length?`${f} [${y.join(", ")}]`:f;return n.jsx("option",{value:f,children:E},f)})}),d&&d.badges.length>0&&n.jsx("div",{className:"hidden sm:flex items-center gap-1 shrink-0",children:d.badges.slice(0,3).map(f=>n.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] border ${Zp[f]??"bg-[#27272a] text-[#a1a1aa] border-[#27272a]"}`,children:f},f))}),t.overridden&&n.jsxs("button",{onClick:o,disabled:r==="saving",className:"flex items-center gap-1 px-2 py-1 rounded text-[10px] text-[#fbbf24] border border-[#fbbf24]/30 hover:bg-[#fbbf24]/10 transition-colors disabled:opacity-50",title:`Reset to default: ${t.defaultModel}`,children:[n.jsx(io,{className:"w-3 h-3"}),"Reset"]}),n.jsx("button",{onClick:()=>g(f=>!f),className:"flex items-center justify-center w-6 h-6 rounded hover:bg-[#27272a]/60 text-[#52525b] hover:text-[#a1a1aa] transition-colors",title:"Show recommendation details",children:n.jsx(ci,{className:"w-3.5 h-3.5"})}),n.jsxs("div",{className:"w-5 h-5 flex items-center justify-center shrink-0",children:[r==="saving"&&n.jsx(gn,{className:"w-3.5 h-3.5 animate-spin text-[#6366f1]"}),r==="saved"&&n.jsx(ui,{className:"w-3.5 h-3.5 text-[#10b981]"}),r==="error"&&n.jsx(fn,{className:"w-3.5 h-3.5 text-[#ef4444]"})]})]})]}),p&&n.jsxs("div",{className:"px-3 pb-3 space-y-1.5",children:[d&&n.jsxs("div",{className:"flex items-start gap-2 text-[11px] text-[#a1a1aa]",children:[n.jsx(ci,{className:"w-3 h-3 mt-0.5 shrink-0 text-[#6366f1]"}),n.jsx("span",{children:d.rationale})]}),l&&l.id!==t.activeModel&&n.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-[#10b981]",children:[n.jsx(ui,{className:"w-3 h-3 shrink-0"}),n.jsxs("span",{children:["Recommended upgrade: ",n.jsx("span",{className:"font-mono",children:l.id})," (score ",l.score,"/100)",l.badges.length>0&&n.jsxs("span",{className:"ml-1 text-[#71717a]",children:["[",l.badges.join(", "),"]"]})]})]}),d&&n.jsxs("div",{className:"grid grid-cols-3 gap-2 text-[10px] text-[#52525b]",children:[n.jsxs("div",{children:["Capability: ",n.jsxs("span",{className:"text-[#a1a1aa]",children:[d.breakdown.capabilityScore,"/40"]})]}),n.jsxs("div",{children:["Fit: ",n.jsxs("span",{className:"text-[#a1a1aa]",children:[d.breakdown.specialistFit,"/40"]})]}),n.jsxs("div",{children:["Availability: ",n.jsxs("span",{className:"text-[#a1a1aa]",children:[d.breakdown.availability,"/20"]})]})]})]}),n.jsxs("div",{className:"px-3 pb-2 flex items-center gap-2 text-[10px] text-[#52525b]",children:[n.jsxs("span",{children:["id: ",n.jsx("span",{className:"font-mono text-[#71717a]",children:t.id})]}),n.jsx("span",{children:"•"}),n.jsxs("span",{children:["role: ",n.jsx("span",{className:"font-mono",style:{color:c},children:t.role})]}),((u=t.templateMatches)==null?void 0:u.length)>0&&n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"•"}),n.jsxs("span",{className:"truncate",children:["templates: ",n.jsx("span",{className:"font-mono text-[#71717a]",children:t.templateMatches.join(", ")})]})]})]})]})}function sm(){const[t,e]=w.useState(null),[s,r]=w.useState(null),[i,o]=w.useState(null),[c,d]=w.useState(!1),[l,p]=w.useState(null),[g,u]=w.useState(null),f=w.useCallback(async()=>{p(null);try{const[I,v,A]=await Promise.all([ge("/api/telemetry/consent").then(m=>m.ok?m.json():Promise.reject(new Error(`consent ${m.status}`))),ge("/api/analytics/profile").then(m=>m.ok?m.json():null),ge("/api/telemetry/status").then(m=>m.ok?m.json():null)]);e(I),r(v),A!=null&&A.remote&&o(A.remote)}catch(I){p(I.message)}},[]);w.useEffect(()=>{const I=setInterval(()=>{ge("/api/telemetry/status").then(v=>v.ok?v.json():null).then(v=>{v!=null&&v.remote&&o(v.remote)}).catch(()=>{})},15e3);return()=>clearInterval(I)},[]),w.useEffect(()=>{f()},[f]);const x=w.useCallback(async I=>{d(!0),p(null);try{const v=await ge("/api/telemetry/consent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(I)});if(!v.ok)throw new Error(`save failed: ${v.status}`);const A=await v.json();e(m=>m?{...m,...A,consentedAt:A.enabled?new Date().toISOString():void 0}:null),u(Date.now()),setTimeout(()=>u(null),2e3)}catch(v){p(v.message)}finally{d(!1)}},[]),y=!!(t!=null&&t.enabled),E=!!(t!=null&&t.crashReports);return n.jsxs("div",{className:"w-full h-full overflow-auto bg-[#0a0a0f] text-[#e4e4e7] text-sm p-4",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[y?n.jsx(Fl,{className:"w-5 h-5 text-[#10b981]"}):n.jsx(Tr,{className:"w-5 h-5 text-[#71717a]"}),n.jsx("h3",{className:"font-semibold text-base",children:"Privacy & Telemetry"}),n.jsx("span",{className:`ml-2 text-[10px] px-2 py-0.5 rounded-full border ${y?"border-[#10b981]/40 bg-[#10b981]/10 text-[#10b981]":"border-[#3f3f46] bg-[#18181b] text-[#71717a]"}`,children:y?"ENABLED":"OFF"}),n.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[g&&n.jsxs("span",{className:"text-[11px] text-[#10b981] flex items-center gap-1",children:[n.jsx(Cl,{className:"w-3 h-3"})," Saved"]}),l&&n.jsxs("span",{className:"text-[11px] text-[#ef4444] flex items-center gap-1",children:[n.jsx(Tl,{className:"w-3 h-3"})," ",l]}),n.jsxs("button",{onClick:()=>{f()},className:"flex items-center gap-1 px-2 py-1 rounded text-[11px] text-[#71717a] hover:text-[#e4e4e7] hover:bg-[#27272a]/60 transition-colors",children:[n.jsx(gn,{className:"w-3 h-3"})," Refresh"]})]})]}),n.jsx("div",{className:"mb-4 p-4 rounded-lg border border-[#27272a]/60 bg-[#18181b]/70",children:n.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:y,disabled:c,onChange:I=>x({enabled:I.target.checked,crashReports:E}),className:"mt-1 w-4 h-4 accent-[#6366f1] disabled:opacity-50"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"font-medium",children:"Send anonymous usage stats"}),n.jsx("div",{className:"text-xs text-[#a1a1aa] mt-1 leading-relaxed",children:"OS, Node version, CPU/GPU model + VRAM, RAM, TITAN version, and install method. A heartbeat every 5 minutes so we see uptime + concurrent-session counts. Never sends: prompts, file contents, credentials, IP address, or conversations."}),(t==null?void 0:t.consentedAt)&&n.jsxs("div",{className:"text-[10px] text-[#71717a] mt-2",children:["Consented ",n.jsx("span",{className:"font-mono",children:new Date(t.consentedAt).toLocaleString()}),t.consentedVersion&&n.jsxs(n.Fragment,{children:[" on TITAN v",n.jsx("span",{className:"font-mono",children:t.consentedVersion})]})]})]})]})}),n.jsx("div",{className:`mb-4 p-4 rounded-lg border transition-opacity ${y?"border-[#27272a]/60 bg-[#18181b]/70":"border-[#27272a]/30 bg-[#18181b]/30 opacity-60"}`,children:n.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:E,disabled:c||!y,onChange:I=>x({enabled:y,crashReports:I.target.checked}),className:"mt-1 w-4 h-4 accent-[#6366f1] disabled:opacity-50"}),n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"font-medium",children:"Send crash reports"}),n.jsxs("div",{className:"text-xs text-[#a1a1aa] mt-1 leading-relaxed",children:["When TITAN throws an uncaught exception or unhandled promise rejection, send the error class, message, and stack trace. ",n.jsxs("span",{className:"text-[#fbbf24]",children:["Your $HOME path is replaced with the string ",n.jsx("span",{className:"font-mono",children:'"$HOME"'})," before sending."]})]})]})]})}),n.jsxs("div",{className:"mb-4 p-4 rounded-lg border border-[#27272a]/60 bg-[#18181b]/40",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[n.jsx(fn,{className:"w-4 h-4 text-[#6366f1]"}),n.jsx("div",{className:"text-sm font-medium",children:"What would be sent right now"})]}),s?n.jsxs("dl",{className:"grid grid-cols-[160px_1fr] gap-y-1 text-xs",children:[n.jsx("dt",{className:"text-[#71717a]",children:"installId"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[s.installId.slice(0,32),"…"]}),n.jsx("dt",{className:"text-[#71717a]",children:"os / arch"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[s.os," / ",s.arch," (",s.osRelease,")"]}),n.jsx("dt",{className:"text-[#71717a]",children:"cpu"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[s.cpuModel," · ",s.cpuCores,"c"]}),n.jsx("dt",{className:"text-[#71717a]",children:"ram"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[(s.ramTotalMB/1024).toFixed(1)," GB"]}),n.jsx("dt",{className:"text-[#71717a]",children:"gpu"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[s.gpuVendor,"/",s.gpuName," · ",(s.gpuVramMB/1024).toFixed(1)," GB VRAM"]}),n.jsx("dt",{className:"text-[#71717a]",children:"disk"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[s.diskTotalGB," GB"]}),n.jsx("dt",{className:"text-[#71717a]",children:"version / node"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[s.version," · ",s.nodeVersion]}),n.jsx("dt",{className:"text-[#71717a]",children:"install method"}),n.jsx("dd",{className:"font-mono text-[#e4e4e7]",children:s.installMethod})]}):n.jsx("div",{className:"text-xs text-[#71717a]",children:"Loading profile preview…"})]}),n.jsxs("div",{className:"mb-4 p-4 rounded-lg border border-[#27272a]/60 bg-[#18181b]/50",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[n.jsx(ao,{className:"w-4 h-4 text-[#6366f1]"}),n.jsx("div",{className:"text-sm font-medium",children:"Delivery status"}),(i==null?void 0:i.lastSuccessAt)&&!i.lastError&&n.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full border border-[#10b981]/40 bg-[#10b981]/10 text-[#10b981]",children:"FLOWING"}),(i==null?void 0:i.lastError)&&n.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full border border-[#ef4444]/40 bg-[#ef4444]/10 text-[#ef4444]",children:"ERROR"}),!(i!=null&&i.configured)&&n.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full border border-[#71717a]/40 bg-[#71717a]/10 text-[#71717a]",children:"NO REMOTE"})]}),i?n.jsxs("dl",{className:"grid grid-cols-[160px_1fr] gap-y-1 text-xs",children:[n.jsx("dt",{className:"text-[#71717a]",children:"remote URL"}),n.jsx("dd",{className:"font-mono text-[#e4e4e7] break-all",children:i.remoteUrl||"—"}),n.jsx("dt",{className:"text-[#71717a]",children:"sent / failed"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7]",children:[n.jsx("span",{className:"text-[#10b981]",children:i.sentCount})," / ",n.jsx("span",{className:i.failedCount>0?"text-[#ef4444]":"text-[#71717a]",children:i.failedCount}),i.lastEventType&&n.jsxs("span",{className:"text-[#71717a]",children:[" · last event: ",n.jsx("span",{className:"text-[#a1a1aa]",children:i.lastEventType})]})]}),n.jsx("dt",{className:"text-[#71717a]",children:"last attempt"}),n.jsxs("dd",{className:"font-mono text-[#e4e4e7] flex items-center gap-1",children:[n.jsx(ps,{className:"w-3 h-3 text-[#71717a]"}),i.lastAttemptAt?new Date(i.lastAttemptAt).toLocaleString():"—"]}),n.jsx("dt",{className:"text-[#71717a]",children:"last success"}),n.jsx("dd",{className:"font-mono text-[#e4e4e7]",children:i.lastSuccessAt?new Date(i.lastSuccessAt).toLocaleString():"—"}),i.lastError&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{className:"text-[#ef4444]",children:"last error"}),n.jsx("dd",{className:"font-mono text-[#fca5a5] break-all",children:i.lastError})]})]}):n.jsx("div",{className:"text-xs text-[#71717a]",children:"Checking collector reachability…"})]}),n.jsxs("div",{className:"mb-4 p-3 rounded-lg border border-[#27272a]/60 bg-[#0a0a0f]",children:[n.jsx("div",{className:"text-[10px] text-[#71717a] uppercase tracking-wider mb-1",children:"Collector"}),n.jsx("div",{className:"font-mono text-[11px] text-[#a1a1aa] break-all",children:(t==null?void 0:t.remoteUrl)||"—"})]}),n.jsxs("div",{className:"flex items-center gap-3 text-[11px]",children:[n.jsxs("a",{href:"https://github.com/Djtony707/TITAN/blob/main/PRIVACY.md",target:"_blank",rel:"noreferrer",className:"flex items-center gap-1 text-[#6366f1] hover:underline",children:[n.jsx(hi,{className:"w-3 h-3"})," Read the full PRIVACY.md"]}),n.jsx("span",{className:"text-[#52525b]",children:"·"}),n.jsxs("a",{href:"https://github.com/Djtony707/TITAN/blob/main/src/analytics/collector.ts",target:"_blank",rel:"noreferrer",className:"flex items-center gap-1 text-[#6366f1] hover:underline",children:[n.jsx(hi,{className:"w-3 h-3"})," See the collector source"]})]})]})}const nm=oe.lazy(()=>le(()=>import("./AutopilotPanel-CLe14-eq.js"),__vite__mapDeps([48,1,2,37,14])));function rm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(nm,{})})})}const im=oe.lazy(()=>le(()=>import("./WorkflowsPanel-Do5EOPQ-.js"),__vite__mapDeps([49,1,2,37,14,3,4,10,11,12,24,27,42,16,28,20,50,51])));function om(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(im,{})})})}const am=oe.lazy(()=>le(()=>import("./LearningPanel-BsKhgbeS.js"),__vite__mapDeps([52,1,2,37,14,24,51,53,54,55,27,22,56,31,23,43,12,57,32,26,21,39,58,20,59,60,61,62,63,64,11,65,66,15,40])));function lm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(am,{})})})}const cm=oe.lazy(()=>le(()=>import("./SelfImprovePanel-do5xDzc8.js"),__vite__mapDeps([67,1,2,24,38,20,68,54,15,14,42,23,60,28])));function dm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(cm,{})})})}const um=oe.lazy(()=>le(()=>import("./PersonasPanel-G5Jz55AB.js"),__vite__mapDeps([69,1,2])));function hm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(um,{})})})}const fm=oe.lazy(()=>le(()=>import("./PersonaProfilesPanel-BvQlozzS.js"),__vite__mapDeps([70,1,2,37,14,24,11,16,63,20])));function pm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(fm,{})})})}const mm=oe.lazy(()=>le(()=>import("./DreamPanel-B28qIraZ.js"),__vite__mapDeps([71,1,2,37,14,24])));function gm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(mm,{})})})}const ym=oe.lazy(()=>le(()=>import("./HomelabPanel-Dov1f68P.js"),__vite__mapDeps([72,1,2,37,14,73,74,4,24,20,21,56,19,31,38,40,17])));function bm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(ym,{})})})}const xm=oe.lazy(()=>le(()=>import("./NvidiaPanel-Dwvf8UD2.js"),__vite__mapDeps([75,1,2,24,43,38,66,32])));function wm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(xm,{})})})}const vm=oe.lazy(()=>le(()=>import("./FilesPanel-DDRjQukY.js"),__vite__mapDeps([76,1,2,27,24,14,77,20,12,28,43,41,11,22,55,56,31,23,51,57,32,26,21,39,58,59,60,61,62,63,64,65,66,15,40])));function _m(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(vm,{})})})}const km=oe.lazy(()=>le(()=>import("./LogsPanel-C-H_axtp.js"),__vite__mapDeps([78,1,2,24])));function Sm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(km,{})})})}const jm=oe.lazy(()=>le(()=>import("./TelemetryPanel-CqbkTW3V.js"),__vite__mapDeps([79,1,2,73,20,18,19,56])));function Em(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(jm,{})})})}const Nm=oe.lazy(()=>le(()=>import("./SkillsPanel-B0VL9cO1.js"),__vite__mapDeps([80,1,2,37,14,32,28,41])));function Cm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Nm,{})})})}const Tm=oe.lazy(()=>le(()=>import("./McpPanel-BizAlt2h.js"),__vite__mapDeps([81,1,2,82,24,27,56,61,28])));function Rm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Tm,{})})})}const Am=oe.lazy(()=>le(()=>import("./IntegrationsPanel-BmnWsnvF.js"),__vite__mapDeps([83,1,2,82,38,43,14])));function Lm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Am,{})})})}const Im=oe.lazy(()=>le(()=>import("./ChannelsPanel-rF_yHmYD.js"),__vite__mapDeps([84,1,2,37,14,24,38,43])));function Dm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Im,{})})})}const Mm=oe.lazy(()=>le(()=>import("./MeshPanel-D35hLDX4.js"),__vite__mapDeps([85,1,2,86,24,65])));function Om(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Mm,{})})})}const Pm=oe.lazy(()=>le(()=>import("./MemoryWikiPanel-CKY4HY4k.js"),__vite__mapDeps([87,1,2,37,14,77,20,32,51])));function Wm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Pm,{})})})}const Bm=oe.lazy(()=>le(()=>import("./AutoresearchPanel-C14q_kh7.js"),__vite__mapDeps([88,1,2,58,42,16,24,68,54,20,14])));function Um(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Bm,{})})})}const Fm=oe.lazy(()=>le(()=>import("./SelfProposalsPanel-DM4B-HLa.js"),__vite__mapDeps([89,1,2,37,14,20,55,27,22,56,31,23,51,43,12,57,32,26,21,39,58,59,60,61,62,63,24,64,11,65,66,15,40])));function $m(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Fm,{})})})}const zm=oe.lazy(()=>le(()=>import("./OverviewPanel-DiOrl6LB.js"),__vite__mapDeps([90,1,2,73,37,14,74,4,20,21,56,91])));function Hm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(zm,{})})})}const Vm=oe.lazy(()=>le(()=>import("./SessionsPanel-Bl8h6Bfu.js"),__vite__mapDeps([92,1,2,37,14,3,4,86,10,11,12,32,28])));function Gm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Vm,{})})})}const qm=oe.lazy(()=>le(()=>import("./WatchView-CUGArdWk.js"),__vite__mapDeps([93,1,2,9])));function Ym(){return n.jsx("div",{className:"w-full h-full overflow-auto",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(qm,{})})})}const Km=oe.lazy(()=>le(()=>import("./BackupPanel-CoEbryip.js"),__vite__mapDeps([94,1,2,37,14,27,24,59,38])));function Jm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Km,{})})})}const Xm=oe.lazy(()=>le(()=>import("./TrainingPanel-43gDnkVS.js"),__vite__mapDeps([95,1,2,37,14,24,41])));function Qm(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Xm,{})})})}const Zm=oe.lazy(()=>le(()=>import("./RecipesPanel-DB6Kuo1a.js"),__vite__mapDeps([96,1,2,37,14,24,51,42,28])));function eg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(Zm,{})})})}const tg=oe.lazy(()=>le(()=>import("./VramPanel-nadiVKRZ.js"),__vite__mapDeps([97,1,2,37,14,24])));function sg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(tg,{})})})}const ng=oe.lazy(()=>le(()=>import("./TeamsPanel-7UwGxnbj.js"),__vite__mapDeps([98,1,2,37,14,24,28])));function rg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(ng,{})})})}const ig=oe.lazy(()=>le(()=>import("./CronPanel-DELTcCV-.js"),__vite__mapDeps([99,1,2,37,14,24,20,50,28])));function og(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(ig,{})})})}const ag=oe.lazy(()=>le(()=>import("./CheckpointsPanel-DO0QSjuz.js"),__vite__mapDeps([100,1,2,37,14,24,43,28])));function lg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(ag,{})})})}const cg=oe.lazy(()=>le(()=>import("./OrganismPanel-mhCf2syl.js"),__vite__mapDeps([101,1,2,37,14,24,38])));function dg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(cg,{})})})}const ug=oe.lazy(()=>le(()=>import("./FleetPanel-eEudyOkP.js"),__vite__mapDeps([102,1,2,37,14,24,60])));function hg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(ug,{})})})}const fg=oe.lazy(()=>le(()=>import("./BrowserPanel-CRTJOXQV.js"),__vite__mapDeps([103,1,2,37,14])));function pg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(fg,{})})})}const mg=oe.lazy(()=>le(()=>import("./EvalPanel-DKdn69V8.js"),__vite__mapDeps([104,1,2,37,14,24,42])));function gg(){return n.jsx("div",{className:"w-full h-full overflow-auto p-4",children:n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"text-xs text-[#52525b]",children:"Loading..."}),children:n.jsx(mg,{})})})}function yg(t){const e=Date.now()-new Date(t).getTime();if(!Number.isFinite(e)||e<0)return t;const s=Math.floor(e/1e3);if(s<60)return`${s}s ago`;const r=Math.floor(s/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function bg(t){const e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return e>=0?t.slice(e+1):t}function xg(){const[t,e]=w.useState([]),[s,r]=w.useState(!0),[i,o]=w.useState(""),[c,d]=w.useState(null),[l,p]=w.useState(""),[g,u]=w.useState(!1),[f,x]=w.useState(null),[y,E]=w.useState(null),[I,v]=w.useState(null),A=w.useCallback(async()=>{r(!0),x(null);try{const C=await ge("/api/time-travel/checkpoints?limit=100");if(!C.ok)throw new Error(`${C.status} ${C.statusText}`);const D=await C.json();e(D.checkpoints||[])}catch(C){x(C.message||"Failed to load")}finally{r(!1)}},[]);w.useEffect(()=>{A()},[A]);const m=w.useCallback((C,D)=>{v({kind:C,message:D}),setTimeout(()=>v(null),4e3)},[]),k=w.useCallback(async C=>{d(C),p(""),u(!0);try{const D=await ge(`/api/time-travel/diff/${encodeURIComponent(C)}`);if(!D.ok)throw new Error(`${D.status} ${D.statusText}`);const j=await D.json();p(j.diff||"(no diff returned)")}catch(D){p(`Failed to load diff: ${D.message}`)}finally{u(!1)}},[]),_=w.useCallback(C=>{E(C)},[]),T=w.useCallback(async()=>{if(!y)return;const C=y;E(null);try{const D=await ge(`/api/time-travel/restore/${encodeURIComponent(C)}`,{method:"POST"});if(!D.ok)throw new Error(`${D.status} ${D.statusText}`);const j=await D.json();j.ok?(m("ok",j.message||`Restored to ${C.slice(0,8)}.`),A()):m("err",j.message||"Restore failed.")}catch(D){m("err",D.message||"Restore failed.")}},[y,A,m]),S=w.useMemo(()=>{const C=i.trim().toLowerCase();return C?t.filter(D=>D.filePath.toLowerCase().includes(C)||D.toolName.toLowerCase().includes(C)||D.id.toLowerCase().includes(C)):t},[t,i]);return n.jsxs("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",color:"#e2e8f5",fontSize:12,background:"transparent"},children:[n.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:13,fontWeight:600},children:"Time Travel"}),n.jsxs("div",{style:{fontSize:10,color:"rgba(255,255,255,0.45)"},children:[t.length," file checkpoints · newest first"]})]}),n.jsxs("div",{style:{display:"flex",gap:6},children:[n.jsx("input",{type:"text",value:i,onChange:C=>o(C.target.value),placeholder:"Filter by file or tool…",style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:6,color:"#fff",fontSize:11,padding:"4px 8px",outline:"none",width:180}}),n.jsx("button",{onClick:A,disabled:s,title:"Refresh checkpoint list",style:{background:"rgba(99,102,241,0.15)",border:"1px solid rgba(99,102,241,0.35)",borderRadius:6,color:"#c7d2fe",fontSize:11,padding:"4px 10px",cursor:s?"wait":"pointer"},children:s?"…":"Refresh"})]})]}),I&&n.jsx("div",{style:{margin:"8px 14px 0",padding:"6px 10px",borderRadius:6,background:I.kind==="ok"?"rgba(34,197,94,0.12)":"rgba(239,68,68,0.12)",border:`1px solid ${I.kind==="ok"?"rgba(34,197,94,0.3)":"rgba(239,68,68,0.3)"}`,color:I.kind==="ok"?"#86efac":"#fca5a5",fontSize:11},children:I.message}),f&&n.jsx("div",{style:{margin:"8px 14px 0",padding:"6px 10px",borderRadius:6,background:"rgba(239,68,68,0.12)",border:"1px solid rgba(239,68,68,0.3)",color:"#fca5a5",fontSize:11},children:f}),n.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[n.jsx("div",{style:{flex:1,overflow:"auto",borderRight:"1px solid rgba(255,255,255,0.06)"},children:s&&t.length===0?n.jsx("div",{style:{padding:16,color:"rgba(255,255,255,0.4)"},children:"Loading checkpoints…"}):S.length===0?n.jsx("div",{style:{padding:16,color:"rgba(255,255,255,0.4)"},children:i?"No matches for that filter.":"No file checkpoints yet. They're created automatically whenever TITAN writes or edits a file."}):S.map(C=>n.jsxs("div",{onClick:()=>k(C.id),style:{padding:"8px 14px",borderBottom:"1px solid rgba(255,255,255,0.04)",cursor:"pointer",background:c===C.id?"rgba(99,102,241,0.08)":"transparent",borderLeft:c===C.id?"2px solid #818cf8":"2px solid transparent"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:2},children:[n.jsx("span",{style:{fontSize:11,fontFamily:"ui-monospace, monospace",color:"#a5b4fc"},children:C.commitHash.slice(0,8)}),n.jsx("span",{style:{fontSize:10,color:"rgba(255,255,255,0.5)"},children:yg(C.timestamp)})]}),n.jsx("div",{style:{fontSize:12,color:"#e2e8f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:C.filePath,children:bg(C.filePath)}),n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:4},children:[n.jsxs("span",{style:{fontSize:10,color:"rgba(255,255,255,0.4)"},children:["before ",n.jsx("code",{style:{color:"#fbbf24"},children:C.toolName})]}),n.jsx("button",{onClick:D=>{D.stopPropagation(),_(C.id)},title:"Restore this file to the state it was in at this checkpoint",style:{fontSize:10,padding:"2px 8px",borderRadius:999,background:"rgba(34,197,94,0.12)",border:"1px solid rgba(34,197,94,0.3)",color:"#86efac",cursor:"pointer"},children:"Restore"})]})]},C.id))}),n.jsx("div",{style:{flex:1,overflow:"auto",padding:14},children:c?g?n.jsx("div",{style:{color:"rgba(255,255,255,0.4)"},children:"Loading diff…"}):n.jsx("pre",{style:{margin:0,fontFamily:'ui-monospace, "SF Mono", Menlo, monospace',fontSize:11,lineHeight:1.5,color:"#e2e8f5",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:(l||"").split(`
|
|
969
|
+
`).map((C,D)=>{let j="rgba(255,255,255,0.7)";return C.startsWith("+")&&!C.startsWith("+++")?j="#86efac":C.startsWith("-")&&!C.startsWith("---")?j="#fca5a5":C.startsWith("@@")?j="#a5b4fc":(C.startsWith("diff")||C.startsWith("index")||C.startsWith("+++")||C.startsWith("---"))&&(j="rgba(255,255,255,0.45)"),n.jsx("div",{style:{color:j},children:C||" "},D)})}):n.jsx("div",{style:{color:"rgba(255,255,255,0.4)"},children:"Select a checkpoint on the left to see its diff vs the current file."})})]}),y&&n.jsx("div",{onClick:()=>E(null),style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10},children:n.jsxs("div",{onClick:C=>C.stopPropagation(),style:{background:"#0d0f1d",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,padding:18,maxWidth:380,color:"#e2e8f5"},children:[n.jsx("div",{style:{fontSize:14,fontWeight:600,marginBottom:8},children:"Restore this checkpoint?"}),n.jsxs("div",{style:{fontSize:12,color:"rgba(255,255,255,0.7)",marginBottom:12},children:["The file will be overwritten with its state at ",n.jsx("code",{children:y.slice(0,8)}),". A NEW checkpoint of the current state is taken first, so you can always come back."]}),n.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[n.jsx("button",{onClick:()=>E(null),style:{background:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.1)",color:"#e2e8f5",borderRadius:6,padding:"6px 12px",fontSize:12,cursor:"pointer"},children:"Cancel"}),n.jsx("button",{onClick:T,style:{background:"rgba(34,197,94,0.18)",border:"1px solid rgba(34,197,94,0.4)",color:"#86efac",borderRadius:6,padding:"6px 12px",fontSize:12,cursor:"pointer"},children:"Restore"})]})]})})]})}const Ki=5e3,Ji={planning:"#a5b4fc",delegating:"#60a5fa",observing:"#22d3ee",iterating:"#f59e0b",verifying:"#a78bfa",reporting:"#34d399",blocked:"#facc15",escalated:"#fb7185",done:"#34d399",failed:"#ef4444",cancelled:"#737373"};function wg(t){if(!Number.isFinite(t)||t<0)return"—";const e=Math.floor(t/1e3);if(e<60)return`${e}s`;const s=Math.floor(e/60);if(s<60)return`${s}m`;const r=Math.floor(s/60),i=s%60;return`${r}h ${i}m`}function vg(t){return t===0?"$0":t<.01?"$<0.01":`$${t.toFixed(2)}`}function _g(){const[t,e]=w.useState([]),[s,r]=w.useState(!0),[i,o]=w.useState(null),[c,d]=w.useState(!1),[l,p]=w.useState(""),[g,u]=w.useState(2),[f,x]=w.useState(!1),[y,E]=w.useState(null),I=w.useCallback(async()=>{try{const _=await ge("/api/missions/active");if(!_.ok)throw new Error(`${_.status} ${_.statusText}`);const T=await _.json();e(T.missions||[]),o(null)}catch(_){o(_.message||"failed to load")}finally{r(!1)}},[]);w.useEffect(()=>{I();const _=setInterval(I,Ki);return()=>clearInterval(_)},[I]);const v=w.useCallback((_,T)=>{E({kind:_,message:T}),setTimeout(()=>E(null),5e3)},[]),A=w.useCallback(async()=>{var T;const _=l.trim();if(_.length<10){v("err","Describe the mission (>=10 chars).");return}x(!0);try{const S=await ge("/api/mission/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:_,budgetUsd:g})});if(!S.ok)throw new Error(`${S.status} ${S.statusText}`);const C=await S.json();v("ok",C.message||`Mission "${((T=C.goal)==null?void 0:T.title)??"?"}" launched.`),p(""),d(!1),I()}catch(S){v("err",S.message||"launch failed")}finally{x(!1)}},[l,g,I,v]),m=w.useCallback(async _=>{try{const T=await ge(`/api/mission/${encodeURIComponent(_)}/cancel`,{method:"POST"});if(!T.ok)throw new Error(`${T.status} ${T.statusText}`);v("ok","Mission marked for cancellation."),I()}catch(T){v("err",T.message||"cancel failed")}},[I,v]),k=w.useMemo(()=>{const _={delegating:0,observing:1,iterating:2,verifying:3,planning:4,reporting:5,blocked:6,escalated:7};return[...t].sort((T,S)=>(_[T.phase]??99)-(_[S.phase]??99))},[t]);return n.jsxs("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",color:"#e2e8f5",background:"transparent"},children:[n.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:13,fontWeight:600},children:"Mission Driver"}),n.jsxs("div",{style:{fontSize:10,color:"rgba(255,255,255,0.45)"},children:[t.length," active · polling every ",Ki/1e3,"s"]})]}),n.jsxs("div",{style:{display:"flex",gap:6},children:[n.jsx("button",{onClick:()=>d(_=>!_),title:"Launch a new autonomous mission",style:{fontSize:11,padding:"4px 10px",borderRadius:6,border:"1px solid rgba(99,102,241,0.4)",background:c?"rgba(99,102,241,0.25)":"rgba(99,102,241,0.12)",color:"#c7d2fe",cursor:"pointer"},children:c?"× Close":"+ New mission"}),n.jsx("button",{onClick:I,title:"Refresh",style:{fontSize:11,padding:"4px 10px",borderRadius:6,border:"1px solid rgba(255,255,255,0.1)",background:"rgba(255,255,255,0.04)",color:"#e2e8f5",cursor:"pointer"},children:"↻"})]})]}),y&&n.jsx("div",{style:{margin:"8px 14px 0",padding:"6px 10px",borderRadius:6,fontSize:11,background:y.kind==="ok"?"rgba(34,197,94,0.12)":"rgba(239,68,68,0.12)",border:`1px solid ${y.kind==="ok"?"rgba(34,197,94,0.3)":"rgba(239,68,68,0.3)"}`,color:y.kind==="ok"?"#86efac":"#fca5a5"},children:y.message}),c&&n.jsxs("div",{style:{padding:12,borderBottom:"1px solid rgba(255,255,255,0.06)",background:"rgba(99,102,241,0.04)"},children:[n.jsx("div",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:.6,color:"#a5b4fc",marginBottom:6},children:"Describe the mission"}),n.jsx("textarea",{value:l,onChange:_=>p(_.target.value),placeholder:"e.g. 'Research the top 5 AI agent frameworks for 2026, summarize their differentiation in a markdown report, and save to ~/Documents/agent-research.md'",rows:3,style:{width:"100%",background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:6,color:"#fff",fontSize:12,padding:"6px 10px",resize:"vertical",fontFamily:"inherit",boxSizing:"border-box"}}),n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:8,gap:8},children:[n.jsxs("label",{style:{fontSize:11,color:"rgba(255,255,255,0.6)"},children:["Budget cap: $",n.jsx("input",{type:"number",value:g,onChange:_=>u(Math.max(.05,Math.min(50,Number(_.target.value)||2))),step:"0.5",min:"0.05",max:"50",style:{width:60,marginLeft:4,background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:4,color:"#fff",fontSize:11,padding:"2px 6px"}})]}),n.jsx("button",{onClick:A,disabled:f||l.trim().length<10,style:{fontSize:12,padding:"6px 14px",borderRadius:6,border:"none",background:f?"rgba(255,255,255,0.05)":"rgba(34,197,94,0.18)",color:"#86efac",cursor:f?"wait":"pointer",fontWeight:600},children:f?"Decomposing…":"🚀 Launch"})]})]}),n.jsxs("div",{style:{flex:1,overflow:"auto",padding:8},children:[i&&n.jsx("div",{style:{padding:10,color:"#fca5a5",fontSize:11},children:i}),s&&t.length===0?n.jsx("div",{style:{padding:16,color:"rgba(255,255,255,0.4)",fontSize:12},children:"Loading missions…"}):k.length===0?n.jsxs("div",{style:{padding:24,color:"rgba(255,255,255,0.45)",fontSize:12,textAlign:"center"},children:["No active missions.",n.jsx("br",{}),n.jsx("span",{style:{fontSize:11,color:"rgba(255,255,255,0.35)"},children:'Click "+ New mission" to launch one.'})]}):k.map(_=>{const T=Ji[_.phase]??"#94a3b8",S=_.subtasks.total>0?Math.round(_.subtasks.completed/_.subtasks.total*100):0;return n.jsxs("div",{style:{padding:"10px 12px",marginBottom:6,borderRadius:8,background:"rgba(255,255,255,0.025)",border:`1px solid ${_.phase==="blocked"?"rgba(250,204,21,0.4)":"rgba(255,255,255,0.06)"}`},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:4},children:[n.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#fafafa",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:_.title,children:_.title}),n.jsx("button",{onClick:()=>m(_.goalId),title:"Cancel this mission",style:{fontSize:10,padding:"2px 8px",borderRadius:999,background:"rgba(239,68,68,0.1)",border:"1px solid rgba(239,68,68,0.3)",color:"#fca5a5",cursor:"pointer",marginLeft:6},children:"Cancel"})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:10,color:"rgba(255,255,255,0.7)"},children:[n.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"1px 6px",borderRadius:4,background:`${T}22`,border:`1px solid ${T}55`,color:T,textTransform:"uppercase",letterSpacing:.5,fontWeight:600,fontSize:9},children:_.phase}),n.jsxs("span",{children:[_.subtasks.completed,"/",_.subtasks.total," subtasks (",S,"%)"]}),n.jsx("span",{children:"·"}),n.jsx("span",{children:vg(_.budget.costUsd)}),n.jsx("span",{children:"·"}),n.jsx("span",{children:wg(Date.now()-new Date(_.startedAt).getTime())})]}),_.blockedReason&&n.jsxs("div",{style:{marginTop:6,padding:"6px 8px",borderRadius:4,background:"rgba(250,204,21,0.08)",border:"1px solid rgba(250,204,21,0.25)",fontSize:11,color:"#fde68a"},children:[n.jsx("strong",{children:"Blocked:"})," ",_.blockedReason.question??"(no reason)"]}),_.lastHistory.length>0&&n.jsx("div",{style:{marginTop:6,fontSize:10,color:"rgba(255,255,255,0.45)",display:"flex",flexDirection:"column",gap:1},children:_.lastHistory.slice(-3).map((C,D)=>n.jsxs("div",{style:{display:"flex",gap:6,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[n.jsx("span",{style:{color:Ji[C.phase]??"rgba(255,255,255,0.6)",minWidth:70,fontFamily:"ui-monospace, monospace",fontSize:9},children:C.phase}),n.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.note??""})]},D))})]},_.goalId)})]})]})}const kg=6e4,Sg=[{label:"6h",hours:6},{label:"24h",hours:24},{label:"7d",hours:168}];function jg(t){return t===0?"$0":t<.01?"$<0.01":`$${t.toFixed(2)}`}function Eg(t){return t<1e3?String(t):t<1e6?`${(t/1e3).toFixed(1)}k`:`${(t/1e6).toFixed(2)}M`}function Ng(){const[t,e]=w.useState(24),[s,r]=w.useState(null),[i,o]=w.useState(!0),[c,d]=w.useState(null),l=w.useCallback(async()=>{o(!0);try{const p=await ge(`/api/missions/digest?hours=${t}`);if(!p.ok)throw new Error(`${p.status} ${p.statusText}`);const g=await p.json();r(g),d(null)}catch(p){d(p.message||"failed")}finally{o(!1)}},[t]);return w.useEffect(()=>{l();const p=setInterval(l,kg);return()=>clearInterval(p)},[l]),n.jsxs("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",color:"#e2e8f5",background:"transparent"},children:[n.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:13,fontWeight:600},children:"Daily digest"}),n.jsx("div",{style:{fontSize:10,color:"rgba(255,255,255,0.45)"},children:"what TITAN did while you were away"})]}),n.jsx("div",{style:{display:"flex",gap:4},children:Sg.map(p=>n.jsx("button",{onClick:()=>e(p.hours),style:{fontSize:10,padding:"3px 8px",borderRadius:4,border:"1px solid rgba(255,255,255,0.1)",background:t===p.hours?"rgba(99,102,241,0.25)":"rgba(255,255,255,0.03)",color:t===p.hours?"#c7d2fe":"rgba(255,255,255,0.65)",cursor:"pointer"},children:p.label},p.label))})]}),s&&n.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid rgba(255,255,255,0.04)",display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:8},children:[n.jsx(Ws,{label:"Done",value:s.stats.completed,color:"#34d399"}),n.jsx(Ws,{label:"Failed",value:s.stats.failed,color:s.stats.failed>0?"#fca5a5":"rgba(255,255,255,0.5)"}),n.jsx(Ws,{label:"Active",value:s.stats.active,color:"#60a5fa"}),n.jsx(Ws,{label:"Blocked",value:s.stats.blocked,color:s.stats.blocked>0?"#facc15":"rgba(255,255,255,0.5)"})]}),s&&(s.stats.totalCostUsd>0||s.stats.totalTokens>0)&&n.jsxs("div",{style:{padding:"6px 14px",borderBottom:"1px solid rgba(255,255,255,0.04)",fontSize:10,color:"rgba(255,255,255,0.55)",display:"flex",justifyContent:"space-between"},children:[n.jsxs("span",{children:["Spend: ",n.jsx("strong",{style:{color:"#e2e8f5"},children:jg(s.stats.totalCostUsd)})]}),n.jsxs("span",{children:["Tokens: ",n.jsx("strong",{style:{color:"#e2e8f5"},children:Eg(s.stats.totalTokens)})]})]}),n.jsxs("div",{style:{flex:1,overflow:"auto",padding:14},children:[i&&!s&&n.jsx("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:11},children:"Loading…"}),c&&n.jsx("div",{style:{color:"#fca5a5",fontSize:11},children:c}),s&&n.jsxs(n.Fragment,{children:[n.jsx("pre",{style:{margin:0,fontFamily:'ui-monospace, "SF Mono", Menlo, monospace',fontSize:11,lineHeight:1.55,color:"#e2e8f5",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:s.summaryText||"(no activity in this window)"}),s.recentLessons.length>0&&n.jsxs("div",{style:{marginTop:16,paddingTop:12,borderTop:"1px solid rgba(255,255,255,0.06)"},children:[n.jsx("div",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:.6,color:"#a5b4fc",marginBottom:6},children:"Lessons learned (Reflexion)"}),s.recentLessons.map((p,g)=>n.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.8)",padding:"4px 0",borderBottom:"1px dashed rgba(255,255,255,0.04)"},children:["• ",p]},g))]})]})]})]})}function Ws({label:t,value:e,color:s}){return n.jsxs("div",{style:{textAlign:"center",padding:"6px 4px",borderRadius:6,background:"rgba(255,255,255,0.02)"},children:[n.jsx("div",{style:{fontSize:18,fontWeight:700,color:s,lineHeight:1},children:e}),n.jsx("div",{style:{fontSize:9,color:"rgba(255,255,255,0.5)",textTransform:"uppercase",letterSpacing:.5,marginTop:4},children:t})]})}const Bs={pending:"#737373",running:"#60a5fa",done:"#34d399",failed:"#ef4444",skipped:"#a78bfa"},Xi=6e3,_t=180,nr=64,Qi=96,Us=24;function Cg(t){const e=new Map,s=new Map(t.map(i=>[i.id,i])),r=(i,o)=>{if(e.has(i))return e.get(i);if(o.has(i))return 0;const c=s.get(i);if(!c)return 0;o.add(i);const d=(c.dependsOn??[]).filter(p=>s.has(p)),l=d.length===0?0:Math.max(...d.map(p=>r(p,o)))+1;return o.delete(i),e.set(i,l),l};for(const i of t)r(i.id,new Set);return e}function Tg(){const[t,e]=w.useState([]),[s,r]=w.useState(null),[i,o]=w.useState(null),[c,d]=w.useState(null),[l,p]=w.useState(null),g=w.useCallback(async()=>{try{const v=await ge("/api/missions/active");if(!v.ok)throw new Error(`${v.status} ${v.statusText}`);const m=(await v.json()).missions||[];e(m),!s&&m.length>0&&r(m[0].goalId)}catch(v){d(v.message||"failed")}},[s]),u=w.useCallback(async v=>{try{const A=await ge(`/api/mission/${encodeURIComponent(v)}`);if(!A.ok)throw new Error(`${A.status} ${A.statusText}`);const m=await A.json();o(m),d(null)}catch(A){d(A.message||"failed to load mission"),o(null)}},[]);w.useEffect(()=>{g();const v=setInterval(g,Xi);return()=>clearInterval(v)},[g]),w.useEffect(()=>{if(!s){o(null);return}u(s);const v=setInterval(()=>u(s),Xi);return()=>clearInterval(v)},[s,u]);const{layout:f,edges:x,viewBox:y}=w.useMemo(()=>{if(!(i!=null&&i.goal.subtasks))return{layout:[],edges:[],viewBox:"0 0 600 200"};const v=i.goal.subtasks,A=Cg(v),m=new Map;for(const R of v){const P=A.get(R.id)??0;m.has(P)||m.set(P,[]),m.get(P).push(R)}const k=Array.from(m.keys()).sort((R,P)=>R-P),_=Math.max(...Array.from(m.values()).map(R=>R.length),1),T=Math.max(640,_*(_t+Us)+Us),S=k.length*Qi+nr+40,C=new Map,D=[];for(const R of k){const P=m.get(R),B=P.length*_t+(P.length-1)*Us,z=(T-B)/2,q=R*Qi+20;for(let H=0;H<P.length;H++){const J=z+H*(_t+Us);C.set(P[H].id,{x:J,y:q}),D.push({...P[H],x:J,y:q})}}const j=[];for(const R of v){const P=C.get(R.id);if(P)for(const B of R.dependsOn??[]){const z=C.get(B);z&&j.push({from:B,to:R.id,x1:z.x+_t/2,y1:z.y+nr,x2:P.x+_t/2,y2:P.y})}}return{layout:D,edges:j,viewBox:`0 0 ${T} ${S}`}},[i]),E=w.useMemo(()=>new Map(((i==null?void 0:i.goal.subtasks)??[]).map(v=>[v.id,v])),[i]),I=l?E.get(l):null;return n.jsxs("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",color:"#e2e8f5",background:"transparent"},children:[n.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:10},children:[n.jsxs("div",{style:{flex:1},children:[n.jsx("div",{style:{fontSize:13,fontWeight:600},children:"Mission graph"}),n.jsxs("div",{style:{fontSize:10,color:"rgba(255,255,255,0.45)"},children:[t.length," active mission(s) · subtask DAG"]})]}),t.length>0&&n.jsx("select",{value:s??"",onChange:v=>r(v.target.value||null),style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:6,color:"#fff",fontSize:11,padding:"4px 8px",maxWidth:240},children:t.map(v=>n.jsxs("option",{value:v.goalId,children:[v.title," [",v.phase,"]"]},v.goalId))})]}),c&&n.jsx("div",{style:{padding:10,color:"#fca5a5",fontSize:11},children:c}),n.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[n.jsx("div",{style:{flex:1,overflow:"auto",padding:14},children:i?f.length===0?n.jsx("div",{style:{padding:24,color:"rgba(255,255,255,0.45)",fontSize:12,textAlign:"center"},children:"This mission has no subtasks yet."}):n.jsxs("svg",{viewBox:y,style:{width:"100%",height:"auto"},role:"img","aria-label":"Mission subtask DAG",children:[n.jsx("defs",{children:n.jsx("marker",{id:"mg-arrow",viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:n.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"rgba(255,255,255,0.35)"})})}),x.map((v,A)=>n.jsx("line",{x1:v.x1,y1:v.y1,x2:v.x2,y2:v.y2,stroke:"rgba(255,255,255,0.25)",strokeWidth:"1.4",markerEnd:"url(#mg-arrow)"},`e-${A}`)),f.map(v=>{var _;const A=((_=i.driver)==null?void 0:_.currentSubtaskId)===v.id,m=Bs[v.status],k=l===v.id;return n.jsxs("g",{transform:`translate(${v.x}, ${v.y})`,onClick:()=>p(v.id),style:{cursor:"pointer"},children:[n.jsx("rect",{width:_t,height:nr,rx:"8",fill:A?`${m}22`:"rgba(255,255,255,0.04)",stroke:k||A?m:`${m}55`,strokeWidth:A||k?2:1}),n.jsx("circle",{cx:14,cy:14,r:"5",fill:m,children:v.status==="running"&&n.jsx("animate",{attributeName:"r",values:"4;6;4",dur:"1.2s",repeatCount:"indefinite"})}),n.jsx("text",{x:28,y:18,fontSize:"11",fontWeight:"600",fill:"#fafafa",children:v.title.length>22?v.title.slice(0,21)+"…":v.title}),n.jsxs("text",{x:28,y:34,fontSize:"9",fill:"rgba(255,255,255,0.55)",letterSpacing:"0.5",style:{textTransform:"uppercase"},children:[v.status,v.retries>0?` · ${v.retries} retr${v.retries===1?"y":"ies"}`:""]}),n.jsxs("text",{x:14,y:52,fontSize:"9",fill:"rgba(255,255,255,0.45)",children:[(v.description||"").slice(0,30),(v.description||"").length>30?"…":""]}),A&&n.jsx("text",{x:_t-8,y:14,fontSize:"8",fill:m,textAnchor:"end",fontWeight:"700",children:"NOW"})]},v.id)})]}):n.jsx("div",{style:{padding:24,color:"rgba(255,255,255,0.45)",fontSize:12,textAlign:"center"},children:t.length===0?"No active missions. Launch one via the Mission Driver widget.":"Select a mission to view its graph."})}),I&&n.jsxs("div",{style:{width:260,borderLeft:"1px solid rgba(255,255,255,0.06)",padding:14,overflow:"auto",fontSize:11},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:8},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#fafafa",flex:1},children:I.title}),n.jsx("button",{onClick:()=>p(null),style:{background:"transparent",border:"none",color:"rgba(255,255,255,0.5)",cursor:"pointer",fontSize:14,padding:0,marginLeft:6},children:"×"})]}),n.jsxs("div",{style:{marginBottom:8},children:[n.jsx("span",{style:{padding:"2px 8px",borderRadius:4,fontSize:9,fontWeight:600,textTransform:"uppercase",letterSpacing:.5,background:`${Bs[I.status]}22`,border:`1px solid ${Bs[I.status]}55`,color:Bs[I.status]},children:I.status}),I.retries>0&&n.jsxs("span",{style:{marginLeft:6,color:"rgba(255,255,255,0.5)"},children:[I.retries," retries"]})]}),n.jsx("div",{style:{color:"rgba(255,255,255,0.85)",lineHeight:1.5,marginBottom:10},children:I.description}),I.dependsOn.length>0&&n.jsxs("div",{style:{color:"rgba(255,255,255,0.55)",fontSize:10,marginBottom:6},children:[n.jsx("strong",{children:"Depends on:"})," ",I.dependsOn.map(v=>{var A;return((A=E.get(v))==null?void 0:A.title)||v}).join(", ")]}),I.completedAt&&n.jsxs("div",{style:{color:"rgba(255,255,255,0.45)",fontSize:10},children:["Completed: ",new Date(I.completedAt).toLocaleString()]})]})]}),i&&n.jsxs("div",{style:{padding:"6px 14px",borderTop:"1px solid rgba(255,255,255,0.06)",display:"flex",justifyContent:"space-between",fontSize:10,color:"rgba(255,255,255,0.55)"},children:[n.jsxs("span",{children:[i.goal.subtasks.length," subtasks · ",i.goal.progress,"% progress"]}),i.driver&&n.jsxs("span",{children:[i.driver.phase," · $",i.driver.budget.costUsd.toFixed(2)," spent"]})]})]})}function Rg(){const[t,e]=w.useState([]),[s,r]=w.useState(!0),[i,o]=w.useState(null),c=async()=>{try{const d=await fetch("/api/agents");if(!d.ok)throw new Error(`HTTP ${d.status}`);const l=await d.json();e(Array.isArray(l)?l:l.agents||[]),o(null)}catch(d){o(d.message)}finally{r(!1)}};return w.useEffect(()=>{c();const d=setInterval(c,1e4);return()=>clearInterval(d)},[]),s?n.jsx("div",{className:"w-full h-full flex items-center justify-center",children:n.jsx(so,{className:"w-4 h-4 text-[#6366f1] animate-spin"})}):i?n.jsx("div",{className:"w-full h-full flex items-center justify-center p-4",children:n.jsxs("div",{className:"text-center",children:[n.jsx(fn,{className:"w-4 h-4 text-red-400 mx-auto mb-1"}),n.jsx("span",{className:"text-[10px] text-red-400",children:i})]})}):t.length===0?n.jsx("div",{className:"w-full h-full flex items-center justify-center p-4",children:n.jsx("span",{className:"text-[10px] text-[#52525b]",children:"No active agents"})}):n.jsx("div",{className:"w-full h-full p-3 overflow-auto",children:n.jsx("div",{className:"space-y-2",children:t.map(d=>n.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[n.jsx(mo,{className:`w-3.5 h-3.5 ${d.status==="busy"?"text-[#f59e0b]":d.status==="error"?"text-red-400":"text-[#6366f1]"}`}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"text-[11px] text-[#a1a1aa] truncate",children:d.name}),n.jsxs("div",{className:"text-[10px] text-[#52525b] truncate",children:[d.role,d.model?` · ${d.model}`:""]})]}),n.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full uppercase ${d.status==="busy"?"bg-[#f59e0b]/10 text-[#f59e0b]":d.status==="error"?"bg-red-400/10 text-red-400":"bg-[#6366f1]/10 text-[#818cf8]"}`,children:d.status})]},d.id))})})}function Ag(){const[t,e]=w.useState(null),[s,r]=w.useState(!0),i=async()=>{try{const[c,d]=await Promise.allSettled([fetch("/api/health").then(g=>g.ok?g.json():null),fetch("/ollama/api/tags").then(g=>g.ok)]),l=c.status==="fulfilled"&&c.value,p=d.status==="fulfilled"&&d.value;e({gateway:l,ollama:p,version:(l==null?void 0:l.version)||"unknown",uptime:(l==null?void 0:l.uptime)||0})}catch{e({gateway:!1,ollama:!1,version:"unknown",uptime:0})}finally{r(!1)}};if(w.useEffect(()=>{i();const c=setInterval(i,3e4);return()=>clearInterval(c)},[]),s)return n.jsx("div",{className:"w-full h-full flex items-center justify-center",children:n.jsx(so,{className:"w-4 h-4 text-[#6366f1] animate-spin"})});const o=c=>{const d=Math.floor(c/3600),l=Math.floor(c%3600/60);return`${d}h ${l}m`};return n.jsx("div",{className:"w-full h-full p-3 overflow-auto",children:n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[t!=null&&t.gateway?n.jsx(Rl,{className:"w-3.5 h-3.5 text-emerald-400"}):n.jsx($l,{className:"w-3.5 h-3.5 text-red-400"}),n.jsx("span",{className:"text-[11px] text-[#a1a1aa]",children:"TITAN Gateway"})]}),n.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full uppercase ${t!=null&&t.gateway?"bg-emerald-400/10 text-emerald-400":"bg-red-400/10 text-red-400"}`,children:t!=null&&t.gateway?"Online":"Offline"})]}),n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Vt,{className:`w-3.5 h-3.5 ${t!=null&&t.ollama?"text-emerald-400":"text-red-400"}`}),n.jsx("span",{className:"text-[11px] text-[#a1a1aa]",children:"Ollama"})]}),n.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full uppercase ${t!=null&&t.ollama?"bg-emerald-400/10 text-emerald-400":"bg-red-400/10 text-red-400"}`,children:t!=null&&t.ollama?"Online":"Offline"})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[n.jsxs("div",{className:"px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[n.jsx("div",{className:"text-[9px] text-[#52525b] uppercase tracking-wider",children:"Version"}),n.jsx("div",{className:"text-[11px] text-[#a1a1aa] font-mono mt-0.5",children:t==null?void 0:t.version})]}),n.jsxs("div",{className:"px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[n.jsx("div",{className:"text-[9px] text-[#52525b] uppercase tracking-wider",children:"Uptime"}),n.jsx("div",{className:"text-[11px] text-[#a1a1aa] font-mono mt-0.5",children:o((t==null?void 0:t.uptime)||0)})]})]})]})})}function Fs({label:t,value:e,icon:s,color:r,unknown:i}){const o=Math.max(0,Math.min(100,Math.round(e)));return n.jsxs("div",{className:"px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[n.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[n.jsxs("div",{className:"flex items-center gap-1.5",children:[s,n.jsx("span",{className:"text-[10px] text-[#52525b] uppercase tracking-wider",children:t})]}),n.jsx("span",{className:"text-[11px] text-[#a1a1aa] font-mono",children:i?"—":`${o}%`})]}),n.jsx("div",{className:"h-1.5 rounded-full bg-[#27272a] overflow-hidden",children:n.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:i?"0%":`${o}%`,backgroundColor:r}})})]})}function Lg(){const[t,e]=w.useState({cpu:0,memory:0,disk:0,load:0,loaded:!1,error:null,diskAvailable:!0});w.useEffect(()=>{let r=!1;async function i(){try{const c=await ge("/api/stats");if(!c.ok){const y=`HTTP ${c.status}`;r||e(E=>({...E,loaded:!0,error:y}));return}const d=await c.json();if(r)return;const l=d.host;if(!l){e(y=>({...y,loaded:!0,error:"no host metrics"}));return}const p=typeof l.cpuPercent=="number"?l.cpuPercent:0,g=typeof l.memPercent=="number"?l.memPercent:0,u=typeof l.diskPercent=="number"?l.diskPercent:0,f=l.cores||1,x=typeof l.loadAvg1=="number"?Math.min(100,l.loadAvg1/f*100):0;e({cpu:p,memory:g,disk:u,load:x,loaded:!0,error:null,diskAvailable:!l.diskError})}catch(c){r||e(d=>({...d,loaded:!0,error:c.message}))}}i();const o=setInterval(i,3e3);return()=>{r=!0,clearInterval(o)}},[]);const s=!t.loaded||!!t.error;return n.jsxs("div",{className:"w-full h-full p-3 overflow-auto",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(Fs,{label:"CPU",value:t.cpu,icon:n.jsx(Nr,{className:"w-3 h-3 text-[#6366f1]"}),color:"#6366f1",unknown:s}),n.jsx(Fs,{label:"Memory",value:t.memory,icon:n.jsx(Al,{className:"w-3 h-3 text-[#a78bfa]"}),color:"#a78bfa",unknown:s}),n.jsx(Fs,{label:"Disk",value:t.disk,icon:n.jsx(Ll,{className:"w-3 h-3 text-[#10b981]"}),color:"#10b981",unknown:s||!t.diskAvailable}),n.jsx(Fs,{label:"Load",value:t.load,icon:n.jsx(Vt,{className:"w-3 h-3 text-[#f59e0b]"}),color:"#f59e0b",unknown:s})]}),t.error&&n.jsx("div",{className:"mt-2 text-[10px] text-[#ef4444]/80",children:t.error})]})}const Ig=[{label:"Nav",source:"system:nav",w:3,h:4,icon:n.jsx(Hl,{className:"w-3.5 h-3.5"})},{label:"Agents",source:"system:agents",w:3,h:4,icon:n.jsx(mo,{className:"w-3.5 h-3.5"})},{label:"Health",source:"system:health",w:3,h:3,icon:n.jsx(Vt,{className:"w-3.5 h-3.5"})},{label:"Stats",source:"system:stats",w:3,h:4,icon:n.jsx(Yl,{className:"w-3.5 h-3.5"})},{label:"Chat",source:"system:chat",w:4,h:5,icon:n.jsx(lo,{className:"w-3.5 h-3.5"})},{label:"Files",source:"system:files",w:4,h:6,icon:n.jsx(pn,{className:"w-3.5 h-3.5"})},{label:"Skills",source:"system:tools",w:5,h:4,icon:n.jsx(Er,{className:"w-3.5 h-3.5"})},{label:"Soma",source:"system:soma",w:6,h:6,icon:n.jsx(Il,{className:"w-3.5 h-3.5"})},{label:"Intel",source:"system:intelligence",w:6,h:5,icon:n.jsx(yt,{className:"w-3.5 h-3.5"})},{label:"Infra",source:"system:infra",w:6,h:4,icon:n.jsx(Rr,{className:"w-3.5 h-3.5"})},{label:"Tools",source:"system:tools",w:5,h:4,icon:n.jsx(jr,{className:"w-3.5 h-3.5"})},{label:"Settings",source:"system:settings",w:4,h:6,icon:n.jsx(Sr,{className:"w-3.5 h-3.5"})},{label:"Wiki",source:"system:memory-wiki",w:5,h:5,icon:n.jsx(fs,{className:"w-3.5 h-3.5"})},{label:"Research",source:"system:autoresearch",w:5,h:5,icon:n.jsx(uo,{className:"w-3.5 h-3.5"})},{label:"Proposals",source:"system:self-proposals",w:5,h:5,icon:n.jsx(go,{className:"w-3.5 h-3.5"})},{label:"Overview",source:"system:overview",w:5,h:4,icon:n.jsx(eo,{className:"w-3.5 h-3.5"})},{label:"Sessions",source:"system:sessions",w:5,h:4,icon:n.jsx(ps,{className:"w-3.5 h-3.5"})},{label:"Watch",source:"system:watch",w:6,h:5,icon:n.jsx(Vt,{className:"w-3.5 h-3.5"})},{label:"Backup",source:"system:backup",w:5,h:5,icon:n.jsx(ho,{className:"w-3.5 h-3.5"})},{label:"Training",source:"system:training",w:5,h:5,icon:n.jsx(yt,{className:"w-3.5 h-3.5"})},{label:"Recipes",source:"system:recipes",w:5,h:5,icon:n.jsx(fs,{className:"w-3.5 h-3.5"})},{label:"VRAM",source:"system:vram",w:5,h:5,icon:n.jsx(Nr,{className:"w-3.5 h-3.5"})},{label:"Teams",source:"system:teams",w:5,h:5,icon:n.jsx(Cr,{className:"w-3.5 h-3.5"})},{label:"Cron",source:"system:cron",w:5,h:5,icon:n.jsx(ps,{className:"w-3.5 h-3.5"})},{label:"Checkpoints",source:"system:checkpoints",w:5,h:5,icon:n.jsx(mn,{className:"w-3.5 h-3.5"})},{label:"Organism",source:"system:organism",w:5,h:5,icon:n.jsx(Tr,{className:"w-3.5 h-3.5"})},{label:"Fleet",source:"system:fleet",w:5,h:5,icon:n.jsx(fo,{className:"w-3.5 h-3.5"})},{label:"Browser",source:"system:browser",w:5,h:5,icon:n.jsx(to,{className:"w-3.5 h-3.5"})},{label:"Eval",source:"system:eval",w:5,h:5,icon:n.jsx(po,{className:"w-3.5 h-3.5"})}];function Dg(){const t=(e,s,r)=>{window.dispatchEvent(new CustomEvent("titan:widget:add",{detail:{source:e,w:s,h:r}}))};return n.jsx("div",{className:"w-full h-full p-3 overflow-auto",children:n.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:Ig.map(e=>n.jsxs("button",{onClick:()=>t(e.source,e.w,e.h),className:"flex items-center gap-2 px-2.5 py-2 rounded-lg bg-[#0a0a0f] border border-[#27272a] text-[#71717a] hover:text-[#a1a1aa] hover:border-[#3f3f46] hover:bg-[#27272a]/30 transition-all text-left",children:[n.jsx("span",{className:"text-[#6366f1]",children:e.icon}),n.jsx("span",{className:"text-[10px] font-medium",children:e.label})]},e.source))})})}class Mg extends oe.Component{componentDidCatch(e){this.props.onError(e.message)}render(){return this.props.children}}function Og({name:t,children:e}){const[s,r]=oe.useState(null);return s?n.jsx("div",{className:"w-full h-full flex items-center justify-center p-4",children:n.jsxs("span",{className:"text-xs text-red-400",children:[t,": ",s]})}):n.jsx(Mg,{onError:r,children:e})}const Pg=oe.lazy(()=>le(()=>import("./legacy-Wbf7An22.js"),__vite__mapDeps([105,1,2,4])).then(t=>({default:t.Responsive}))),Wg={"system:nav":ll,"system:chat":hl,"system:cmd":yl,"system:soma":bl,"system:command-post":Dp,"system:intelligence":Op,"system:memory-graph":Wp,"system:voice":Bp,"system:infra":Fp,"system:tools":zp,"system:settings":Vp,"system:files":Gp,"system:settings-general":Yp,"system:settings-security":Jp,"system:settings-audit":Qp,"system:settings-specialists":em,"system:settings-privacy":sm,"system:intelligence-autopilot":rm,"system:intelligence-workflows":om,"system:intelligence-learning":lm,"system:intelligence-self-improve":dm,"system:intelligence-personas":hm,"system:intelligence-persona-profiles":pm,"system:intelligence-dream":gm,"system:infra-homelab":bm,"system:infra-gpu":wm,"system:infra-files":_m,"system:infra-logs":Sm,"system:infra-telemetry":Em,"system:tools-skills":Cm,"system:tools-mcp":Rm,"system:tools-integrations":Lm,"system:tools-channels":Dm,"system:tools-mesh":Om,"system:agents":Rg,"system:health":Ag,"system:stats":Lg,"system:quick-links":Dg,"system:memory-wiki":Wm,"system:autoresearch":Um,"system:self-proposals":$m,"system:overview":Hm,"system:sessions":Gm,"system:watch":Ym,"system:backup":Jm,"system:training":Qm,"system:recipes":eg,"system:vram":sg,"system:teams":rg,"system:cron":og,"system:checkpoints":lg,"system:organism":dg,"system:fleet":hg,"system:browser":pg,"system:eval":gg,"system:time-travel":xg,"system:mission-driver":_g,"system:daily-digest":Ng,"system:mission-graph":Tg},Bg={lg:12,md:10,sm:6,xs:4,xxs:2},Ug=60,Fg={lg:1200,md:996,sm:768,xs:480,xxs:0},$g=[12,12],zg=["se","sw","ne","nw","e","w","n","s"],xl=oe.forwardRef(({widget:t,space:e,onRemove:s,style:r,className:i,onMouseDown:o,onMouseUp:c,onTouchStart:d,onTouchEnd:l,children:p},g)=>{const u=w.useCallback(()=>s(t.id),[t.id,s]);return n.jsxs("div",{ref:g,style:r,className:i,onMouseDown:o,onMouseUp:c,onTouchStart:d,onTouchEnd:l,children:[n.jsx(Gg,{widget:t,space:e,onRemove:u}),p]})});xl.displayName="MemoWidgetItem";const Hg=oe.memo(xl);function Vg({widget:t,space:e,onRemove:s}){const r=w.useRef(null),i=w.useRef(null),o=w.useRef(e),[c,d]=w.useState(null),[l,p]=w.useState(!0);if(w.useEffect(()=>{o.current=e},[e]),w.useEffect(()=>{if(t.format==="system"||!r.current)return;if(!t.source||t.source.trim()===""){d("Empty widget — no source code"),p(!1);return}p(!0),d(null),i.current=new al(r.current,{onLog:u=>console.log(`[Widget ${t.id}]`,u)}),i.current.setMessageHandler(u=>{var x,y,E,I;const f=o.current;if(u.type==="canvas"&&((x=u.payload)==null?void 0:x.action)==="createWidget"){const v=u.payload.def;if(!v)return{ok:!1,error:"createWidget requires a `def` object"};const A=Number.isFinite(v.w)?v.w:4,m=Number.isFinite(v.h)?v.h:4,k=Number.isFinite(v.x)&&Number.isFinite(v.y)?{x:v.x,y:v.y}:Gs(f.widgets||[],A,m);try{const _=ke.addWidget(f.id,{name:v.name||"Agent Widget",format:v.format||"react",source:v.source||"",x:k.x,y:k.y,w:A,h:m});return window.dispatchEvent(new CustomEvent("titan:space:refresh",{detail:{spaceId:f.id}})),{ok:!0,widgetId:_.id}}catch(_){return{ok:!1,error:_.message}}}if(u.type==="canvas"&&((y=u.payload)==null?void 0:y.action)==="updateWidget"){const{id:v,patch:A}=u.payload;return v?(ke.updateWidget(f.id,v,A||{}),window.dispatchEvent(new CustomEvent("titan:space:refresh",{detail:{spaceId:f.id}})),{ok:!0,id:v}):{ok:!1,error:"updateWidget requires an `id`"}}if(u.type==="canvas"&&((E=u.payload)==null?void 0:E.action)==="listWidgets")return{ok:!0,widgets:f.widgets||[]};if(u.type==="canvas"&&((I=u.payload)==null?void 0:I.action)==="removeWidget"){const v=u.payload.id;return v?(ke.removeWidget(f.id,v),window.dispatchEvent(new CustomEvent("titan:space:refresh",{detail:{spaceId:f.id}})),{ok:!0}):{ok:!1,error:"removeWidget requires an `id`"}}return{ok:!1,error:"Unknown message type"}});const g=setTimeout(()=>{p(!1),d("Sandbox timeout: widget took longer than 30s to render. The widget source may have an infinite loop or an unhandled exception. Open DevTools (F12) → Console to see the iframe-side error.")},3e4);return i.current.render(t.format,t.source).then(()=>{clearTimeout(g),p(!1)}).catch(u=>{clearTimeout(g),p(!1),d(String(u))}),()=>{var u;clearTimeout(g),(u=i.current)==null||u.destroy()}},[t.format,t.source,t.id]),t.format==="system"){const g=Wg[t.source];return g?n.jsxs("div",{className:"w-full h-full rounded-xl overflow-hidden flex flex-col group transition-colors shadow-md",style:{background:"var(--color-desk-widget-bg)",border:"1px solid var(--color-desk-border)",boxShadow:"0 4px 12px var(--theme-shadow, rgba(60,40,15,0.15))"},children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b panel-drag-handle cursor-move",style:{borderColor:"var(--color-desk-border-light)",background:"var(--theme-leather, rgba(58,37,24,0.05))"},children:[n.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--color-desk-accent)"},children:t.name}),n.jsx("button",{onClick:s,className:"opacity-0 group-hover:opacity-100 text-xs px-1 transition-opacity",style:{color:"var(--color-desk-text-muted)"},children:"×"})]}),n.jsx("div",{className:"flex-1 overflow-auto relative",children:n.jsx(Og,{name:t.name,children:n.jsx(g,{space:e,widget:t,onRemove:s})})})]}):n.jsxs("div",{className:"w-full h-full flex items-center justify-center text-xs text-red-400",children:["Unknown system widget: ",t.source]})}return n.jsxs("div",{className:"w-full h-full rounded-xl overflow-hidden flex flex-col shadow-md",style:{background:"var(--color-desk-widget-bg)",border:"1px solid var(--color-desk-border)",boxShadow:"0 4px 12px var(--theme-shadow, rgba(60,40,15,0.15))"},children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b panel-drag-handle cursor-move",style:{borderColor:"var(--color-desk-border-light)",background:"var(--theme-leather, rgba(58,37,24,0.05))"},children:[n.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--color-desk-accent)"},children:t.name}),n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("button",{onClick:g=>{g.stopPropagation(),window.dispatchEvent(new CustomEvent("titan:widget:edit",{detail:{spaceId:e.id,widgetId:t.id}}))},onMouseDown:g=>g.stopPropagation(),className:"px-1",style:{color:"var(--color-desk-text-muted)"},title:"Edit widget",children:n.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("path",{d:"m18 2 4 4-14 14H4v-4L18 2z"})})}),n.jsx("button",{onClick:s,className:"text-xs px-1",style:{color:"var(--color-desk-text-muted)"},children:"×"})]})]}),n.jsx("div",{className:"flex-1 relative",children:c?n.jsx("div",{className:"p-3 text-xs text-red-400 font-mono whitespace-pre-wrap",children:c}):n.jsxs(n.Fragment,{children:[n.jsx("iframe",{ref:r,className:"w-full h-full border-0",sandbox:"allow-scripts",title:t.name}),l&&n.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-xs",style:{background:"var(--theme-paper, rgba(253,246,227,0.85))",color:"var(--color-desk-text-muted)",fontFamily:"var(--theme-font-display, 'Georgia', serif)"},children:n.jsx("span",{className:"animate-pulse",children:"Loading widget…"})})]})})]})}const Gg=oe.memo(Vg);function qg(){const{spaceId:t}=Dl(),e=Zi(),[s,r]=w.useState(null),[i]=w.useState(!0),[o,c]=w.useState(!1),[d,l]=w.useState(null),[p,g]=w.useState(!1),[u,f]=w.useState(!1),[x,y]=w.useState(!1),[E,I]=w.useState(1200),v=w.useRef(null),A=w.useRef(null),{info:m,triggerUpdate:k,waitForReload:_}=xf(),[T,S]=w.useState(!1);w.useEffect(()=>{const $=t||"home",F=ke.get($);F?r(F):e("/space/home",{replace:!0})},[t,e]),w.useEffect(()=>{const $=()=>{const se=A.current;if(!se)return null;const Y=new ResizeObserver(te=>{for(const Q of te)I(Q.contentRect.width)});return Y.observe(se),I(se.getBoundingClientRect().width||1200),Y};let F=$();const V=setInterval(()=>{F||(F=$()),F&&clearInterval(V)},200);return()=>{F==null||F.disconnect(),clearInterval(V)}},[s==null?void 0:s.id]),w.useEffect(()=>{const $=F=>{(F.metaKey||F.ctrlKey)&&F.key==="k"&&(F.preventDefault(),f(V=>!V)),(F.metaKey||F.ctrlKey)&&F.key==="j"&&(F.preventDefault(),window.dispatchEvent(new CustomEvent("titan:chat:toggle")))};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[]),wf([{key:"?",action:()=>y(!0),description:"Show keyboard shortcuts help"},{key:"g",shift:!0,action:()=>e("/space/command"),description:"Go to Command Post space"},{key:"h",shift:!0,action:()=>e("/space/home"),description:"Go to Home space"},{key:"s",shift:!0,action:()=>e("/space/settings"),description:"Go to Settings space"},{key:"i",shift:!0,action:()=>e("/space/intelligence"),description:"Go to Intelligence space"}]);const C=w.useCallback(()=>{},[]),D=w.useRef(null),j=w.useRef(null),R=w.useCallback($=>{s&&(j.current=$,D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{const F=j.current;!F||!s||(ke.updateLayout(s.id,F.map(V=>({i:V.i,x:V.x,y:V.y,w:V.w,h:V.h}))),j.current=null,D.current=null)},50))},[s]),P=w.useCallback($=>{var se;if(!s)return;const F=(se=s.widgets)==null?void 0:se.find(Y=>Y.id===$);Dn("canvas_panel_removed",{widgetId:$,format:F==null?void 0:F.format,source:F==null?void 0:F.source}),ke.removeWidget(s.id,$);const V=Array.isArray(s.widgets)?s.widgets:[];r({...s,widgets:V.filter(Y=>Y.id!==$)})},[s]),B=w.useCallback($=>{if(!s)return;const F=ke.addWidget(s.id,$),V=Array.isArray(s.widgets)?s.widgets:[];return r({...s,widgets:[...V,F]}),Dn($.format==="system"?"canvas_system_panel_created":"canvas_panel_created",{source:$.source,name:$.name,format:$.format}),F},[s]),z=w.useCallback(($,F)=>{if(!s||!Array.isArray(s.widgets)||s.widgets.length===0)return{x:0,y:0};const V=12,se=new Set;for(const Y of s.widgets)for(let te=0;te<Y.w;te++)for(let Q=0;Q<Y.h;Q++)se.add(`${Y.x+te},${Y.y+Q}`);for(let Y=0;Y<200;Y++)for(let te=0;te<=V-$;te++){let Q=!0;for(let be=0;be<$;be++){for(let Ce=0;Ce<F;Ce++)if(se.has(`${te+be},${Y+Ce}`)){Q=!1;break}if(!Q)break}if(Q)return{x:te,y:Y}}return{x:0,y:0}},[s]),q=w.useCallback(($,F,V=4,se=4)=>{const Y=z(V,se);B({name:F,format:"system",source:$,x:Y.x,y:Y.y,w:V,h:se})},[B,z]);w.useEffect(()=>{const $=F=>{const V=F.detail;if(console.log("[TitanCanvas] titan:space:refresh received:",V),!!s&&(V==null?void 0:V.spaceId)===s.id){const se=ke.get(s.id);se&&(console.log("[TitanCanvas] Refreshing space, widget count:",se.widgets.length),r(se))}};return window.addEventListener("titan:space:refresh",$),()=>window.removeEventListener("titan:space:refresh",$)},[s]),w.useEffect(()=>{const $=F=>{const V=F.detail;if(s&&V!=null&&V.source){const se=Number.isFinite(V.w)?V.w:4,Y=Number.isFinite(V.h)?V.h:4,te=typeof V.name=="string"&&V.name.trim()?V.name.trim():String(V.source).replace("system:","").replace(/-/g," "),Q=V.format==="react"||V.format==="vanilla"||V.format==="html"||V.format==="system"?V.format:String(V.source).startsWith("system:")?"system":"react",be=z(se,Y);B({name:te,format:Q,source:String(V.source),x:be.x,y:be.y,w:se,h:Y})}};return window.addEventListener("titan:widget:add",$),()=>window.removeEventListener("titan:widget:add",$)},[s,B,z]),w.useEffect(()=>{const $=F=>{const V=F.detail;s&&(V==null?void 0:V.spaceId)===s.id&&typeof(V==null?void 0:V.widgetId)=="string"&&l(V.widgetId)};return window.addEventListener("titan:widget:edit",$),()=>window.removeEventListener("titan:widget:edit",$)},[s]),w.useEffect(()=>s?ke.observe(s.id,F=>{console.log("[TitanCanvas] CRDT observer fired, widgets:",F.length),r(V=>V&&{...V,widgets:F})}):void 0,[s==null?void 0:s.id]);const H=w.useMemo(()=>{const $=s==null?void 0:s.widgets;return Array.isArray($)?$.filter(Boolean):[]},[s]),J=w.useMemo(()=>H.map(($,F)=>({i:$.id,x:Number.isFinite($.x)?$.x:F%3*4,y:Number.isFinite($.y)?$.y:Math.floor(F/3)*4,w:Number.isFinite($.w)?$.w:4,h:Number.isFinite($.h)?$.h:4,minW:2,minH:2,maxW:12,maxH:40})),[H]);return s?n.jsxs("div",{className:"h-full w-full flex",children:[n.jsx(gp,{}),n.jsxs("div",{ref:v,className:"flex-1 relative overflow-auto",children:[n.jsx("style",{children:`
|
|
970
970
|
.titan-canvas-grid .react-grid-item > .react-resizable-handle {
|
|
971
971
|
background: none;
|
|
972
972
|
padding: 0;
|