agentroam-runtime-darwin-arm64 0.2.0-preview.64 → 0.2.0-preview.65
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/manifest.json +2 -2
- package/package.json +1 -1
- package/runtime/.next/BUILD_ID +1 -1
- package/runtime/.next/app-build-manifest.json +10 -10
- package/runtime/.next/app-path-routes-manifest.json +1 -1
- package/runtime/.next/build-manifest.json +3 -3
- package/runtime/.next/prerender-manifest.json +1 -1
- package/runtime/.next/required-server-files.json +1 -1
- package/runtime/.next/server/app/_not-found/page.js +1 -1
- package/runtime/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/runtime/.next/server/app/_not-found.html +1 -1
- package/runtime/.next/server/app/_not-found.rsc +1 -1
- package/runtime/.next/server/app/api/agent/abort/route.js +1 -1
- package/runtime/.next/server/app/api/agent/answer/route.js +1 -1
- package/runtime/.next/server/app/api/agent/codex-sharing/route.js +1 -1
- package/runtime/.next/server/app/api/agent/harness/status/route.js +1 -1
- package/runtime/.next/server/app/api/agent/model/route.js +1 -1
- package/runtime/.next/server/app/api/agent/models/route.js +1 -1
- package/runtime/.next/server/app/api/agent/run/route.js +2 -2
- package/runtime/.next/server/app/api/agent/runtime-health/route.js +1 -1
- package/runtime/.next/server/app/api/agent/steer/route.js +1 -1
- package/runtime/.next/server/app/api/agent/stream/route.js +3 -3
- package/runtime/.next/server/app/api/agent-workspaces/[workspaceId]/sessions/route.js +1 -1
- package/runtime/.next/server/app/api/agent-workspaces/route.js +1 -1
- package/runtime/.next/server/app/api/auth/verify/route.js +1 -1
- package/runtime/.next/server/app/api/business/route.js +1 -1
- package/runtime/.next/server/app/api/client-logs/route.js +1 -1
- package/runtime/.next/server/app/api/collaboration/route.js +1 -1
- package/runtime/.next/server/app/api/flow/v1/catalog/route.js +1 -1
- package/runtime/.next/server/app/api/flow/v1/runs/[runId]/cancel/route.js +1 -1
- package/runtime/.next/server/app/api/flow/v1/runs/[runId]/events/route.js +4 -4
- package/runtime/.next/server/app/api/flow/v1/runs/route.js +1 -1
- package/runtime/.next/server/app/api/flow-studio/config/route.js +1 -1
- package/runtime/.next/server/app/api/mcp/connect/route.js +1 -1
- package/runtime/.next/server/app/api/mcp/disconnect/route.js +1 -1
- package/runtime/.next/server/app/api/mcp/servers/route.js +1 -1
- package/runtime/.next/server/app/api/memory/[key]/route.js +1 -1
- package/runtime/.next/server/app/api/memory/route.js +1 -1
- package/runtime/.next/server/app/api/plugins/load/route.js +1 -1
- package/runtime/.next/server/app/api/projects/[id]/route.js +1 -1
- package/runtime/.next/server/app/api/projects/check/route.js +1 -1
- package/runtime/.next/server/app/api/projects/directories/route.js +1 -1
- package/runtime/.next/server/app/api/projects/roots/route.js +1 -1
- package/runtime/.next/server/app/api/projects/route.js +1 -1
- package/runtime/.next/server/app/api/push/subscribe/route.js +2 -2
- package/runtime/.next/server/app/api/push/unsubscribe/route.js +2 -2
- package/runtime/.next/server/app/api/push/vapid/route.js +2 -2
- package/runtime/.next/server/app/api/push/vapid.body +1 -1
- package/runtime/.next/server/app/api/remote-tools/register/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/changes/route.js +2 -2
- package/runtime/.next/server/app/api/sessions/[id]/fork/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/fork-at/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/goals/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/handoff/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/native-goal/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/query-index/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/release/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/thread-goal/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/tool-result/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/route.js +1 -1
- package/runtime/.next/server/app/api/settings/route.js +1 -1
- package/runtime/.next/server/app/api/skills/route.js +1 -1
- package/runtime/.next/server/app/api/tool-policies/[policyId]/route.js +1 -1
- package/runtime/.next/server/app/api/tool-policies/route.js +1 -1
- package/runtime/.next/server/app/api/tools/route.js +1 -1
- package/runtime/.next/server/app/api/update/check/route.js +1 -1
- package/runtime/.next/server/app/api/update/install/route.js +1 -1
- package/runtime/.next/server/app/api/update/status/route.js +1 -1
- package/runtime/.next/server/app/api/web-auth/login/route.js +1 -1
- package/runtime/.next/server/app/api/web-auth/logout/route.js +1 -1
- package/runtime/.next/server/app/api/web-auth/revoke-all/route.js +1 -1
- package/runtime/.next/server/app/api/web-auth/setup/route.js +1 -1
- package/runtime/.next/server/app/api/web-auth/status/route.js +1 -1
- package/runtime/.next/server/app/api/web-console/bootstrap/route.js +1 -1
- package/runtime/.next/server/app/api/web-console/computer-settings/route.js +1 -1
- package/runtime/.next/server/app/api/web-console/computers/route.js +1 -1
- package/runtime/.next/server/app/api/web-console/device-state/route.js +1 -1
- package/runtime/.next/server/app/api/web-console/history/route.js +1 -1
- package/runtime/.next/server/app/api/web-console/preferences/route.js +1 -1
- package/runtime/.next/server/app/web/page.js +4 -4
- package/runtime/.next/server/app/web/page_client-reference-manifest.js +1 -1
- package/runtime/.next/server/app-paths-manifest.json +34 -34
- package/runtime/.next/server/chunks/5303.js +1 -1
- package/runtime/.next/server/middleware-build-manifest.js +1 -1
- package/runtime/.next/server/pages/404.html +1 -1
- package/runtime/.next/server/pages/500.html +1 -1
- package/runtime/.next/server/pages-manifest.json +1 -1
- package/runtime/.next/server/server-reference-manifest.json +1 -1
- package/runtime/.next/static/chunks/216-befe93998f760830.js +1 -0
- package/runtime/.next/static/chunks/app/web/{error-4d3646f97c1344d3.js → error-17e28c153738a003.js} +1 -1
- package/runtime/.next/static/chunks/app/web/layout-60e82f81fa232177.js +1 -0
- package/runtime/.next/static/chunks/app/web/page-9d2cdb1ef9ad40b2.js +1 -0
- package/runtime/.next/static/chunks/{main-app-00dfdb2d5c09719c.js → main-app-a953e6764afe1e60.js} +1 -1
- package/runtime/.next/static/css/1c4153a5b834f93f.css +1 -0
- package/runtime/native/Support.noindex/AgentRoam Remote Desktop.app/Contents/MacOS/agentroam-remote-desktop +0 -0
- package/runtime/native/Support.noindex/AgentRoam Remote Desktop.app/Contents/Resources/agentroam-component.json +1 -1
- package/runtime/native/Support.noindex/AgentRoam Remote Desktop.app/Contents/_CodeSignature/CodeResources +2 -2
- package/runtime/node_modules/.package-lock.json +126 -126
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/bridge.mjs +73 -73
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/browser-sdk.js +32 -32
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/{core-xpxe8nzb.mjs → core-1qw7dszx.mjs} +1 -1
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-cz9sh4ze.mjs +40 -0
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-nmrdrt5c.mjs +52 -0
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/{core-5682eevd.mjs → core-nxm5bcfb.mjs} +2 -2
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core.mjs +8 -8
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/extractFromBunfs.js +169 -40
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/manifest.json +21 -22
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/manifest.zst.json +25 -26
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/package.json +14 -14
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs +56 -56
- package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.cjs +25 -13
- package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.min.cjs +8 -8
- package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.min.mjs +8 -8
- package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.mjs +25 -13
- package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.node.cjs +25 -13
- package/runtime/node_modules/mediabunny/dist/modules/src/isobmff/isobmff-demuxer.js +22 -11
- package/runtime/node_modules/mediabunny/dist/modules/src/matroska/matroska-demuxer.js +27 -11
- package/runtime/node_modules/mediabunny/dist/modules/src/tsconfig.tsbuildinfo +1 -1
- package/runtime/node_modules/mediabunny/dist/modules/src/version.js +1 -1
- package/runtime/node_modules/mediabunny/package.json +1 -1
- package/runtime/node_modules/mediabunny/src/isobmff/isobmff-demuxer.ts +23 -11
- package/runtime/node_modules/mediabunny/src/matroska/matroska-demuxer.ts +30 -11
- package/runtime/node_modules/mediabunny/src/version.ts +1 -1
- package/runtime/package-lock.json +159 -159
- package/runtime/server.js +1 -1
- package/runtime/webapp/dist/assets/{AiHubPane-D1SGdI6y.js → AiHubPane-Cd-7gwJs.js} +1 -1
- package/runtime/webapp/dist/assets/{App-Y_UUrP8i.js → App-DQqv62sH.js} +3 -3
- package/runtime/webapp/dist/assets/{BrowserLivePanel-CapyOwFL.js → BrowserLivePanel-DDrnghqj.js} +1 -1
- package/runtime/webapp/dist/assets/{CollaborationDashboard-CEF41i5J.js → CollaborationDashboard-qQQqXrQI.js} +1 -1
- package/runtime/webapp/dist/assets/{CollaborationPage-C8PN5oNe.js → CollaborationPage-BS3Z5dAy.js} +1 -1
- package/runtime/webapp/dist/assets/{FilePreview-BdB8syBQ.js → FilePreview-C4gxZRtw.js} +3 -3
- package/runtime/webapp/dist/assets/{FileTree-Cf8wDAVy.js → FileTree-DrpruRST.js} +1 -1
- package/runtime/webapp/dist/assets/{FlowStudioPane-DuUmV_ki.js → FlowStudioPane-BjOuLwks.js} +1 -1
- package/runtime/webapp/dist/assets/{RemoteDesktopPage-DBoSlmlh.js → RemoteDesktopPage-B1AGyJrT.js} +1 -1
- package/runtime/webapp/dist/assets/{TerminalPane-B2s2ff23.js → TerminalPane-BxEtw8rn.js} +1 -1
- package/runtime/webapp/dist/assets/{abnfDiagram-VCTEODGH-CQ78RP8v.js → abnfDiagram-VCTEODGH-BHgKdAyZ.js} +1 -1
- package/runtime/webapp/dist/assets/{arc-B4CNFgtV.js → arc-B8zNXyCl.js} +1 -1
- package/runtime/webapp/dist/assets/{architectureDiagram-5GKGNRK7-B-pYUJdJ.js → architectureDiagram-5GKGNRK7-D596eLfj.js} +1 -1
- package/runtime/webapp/dist/assets/{artifact-links-DrWFmMXT.js → artifact-links-DwSH3xn_.js} +1 -1
- package/runtime/webapp/dist/assets/{blockDiagram-I7D4REHJ-CEEpSPhh.js → blockDiagram-I7D4REHJ-C4eZ-RzC.js} +1 -1
- package/runtime/webapp/dist/assets/{c4Diagram-7LVT6UL2-Bq7l-OxC.js → c4Diagram-7LVT6UL2-Cxe44X-3.js} +1 -1
- package/runtime/webapp/dist/assets/channel-8FdPmR58.js +1 -0
- package/runtime/webapp/dist/assets/{chunk-2Q5K7J3B-B2yw0jQL.js → chunk-2Q5K7J3B-D_syaagC.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-5VM5RSS4-D7AIGjlP.js → chunk-5VM5RSS4-q_wDWTVC.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-F27PBJKO-_wNxBMaG.js → chunk-F27PBJKO-C5U_ckFK.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-IMKFNOWR-bMSiSCLu.js → chunk-IMKFNOWR-5a_rZZVM.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-JWPE2WC7-Zu8gSQip.js → chunk-JWPE2WC7-DR8znCWR.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-POPQ4Y6H-8G7L6RqL.js → chunk-POPQ4Y6H-3vOXloa3.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-SVP7TREG-a6VVTk08.js → chunk-SVP7TREG-y9Uxi4pg.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-TICWLB2K-ddeHMudM.js → chunk-TICWLB2K-Bi7VvqOR.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-XXDRQBXY-DSuvta0Q.js → chunk-XXDRQBXY-CRpw-5Cj.js} +1 -1
- package/runtime/webapp/dist/assets/classDiagram-ZZMXUADV-CCHBpIvI.js +1 -0
- package/runtime/webapp/dist/assets/classDiagram-v2-VYDZK3BY-CCHBpIvI.js +1 -0
- package/runtime/webapp/dist/assets/{clipboard-DS4Pu9OB.js → clipboard-BKglnESD.js} +1 -1
- package/runtime/webapp/dist/assets/{codeSyntax-BWSPpoSH.js → codeSyntax-Dmbrlor0.js} +1 -1
- package/runtime/webapp/dist/assets/{collaboration-D7MlFa87.js → collaboration-BZSnjFZ-.js} +1 -1
- package/runtime/webapp/dist/assets/{cose-bilkent-JH36ORCC-D1TkGbTC.js → cose-bilkent-JH36ORCC-4JQKrvR5.js} +1 -1
- package/runtime/webapp/dist/assets/{cynefin-OW5HDTMX-CYPV2qwK.js → cynefin-OW5HDTMX-BO4eLWHY.js} +1 -1
- package/runtime/webapp/dist/assets/{cynefinDiagram-5FMLGOSQ-DH8spH6U.js → cynefinDiagram-5FMLGOSQ-Dg-Bt9fs.js} +1 -1
- package/runtime/webapp/dist/assets/{dagre-GXQ25YYZ-Dkv69aQ5.js → dagre-GXQ25YYZ-utMMpYq0.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-S7CK7UJ4-Gl094s_z.js → diagram-S7CK7UJ4-BUzOnotG.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-UQ7AKVKN-DKzCe2K6.js → diagram-UQ7AKVKN-Bkesml6e.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-VSXAHHWV-Dq1LtLSa.js → diagram-VSXAHHWV-P-Qqxnpn.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-VX7I27RA-CN9QKehv.js → diagram-VX7I27RA-xpyBMRkH.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-Z3DM3KII-1J67VxEA.js → diagram-Z3DM3KII-FMNqO2NJ.js} +1 -1
- package/runtime/webapp/dist/assets/{ebnfDiagram-PWID7BFC-CRyJYtkK.js → ebnfDiagram-PWID7BFC-D8-cmvEK.js} +1 -1
- package/runtime/webapp/dist/assets/{erDiagram-RLTQ6QDP-C0jVGZ7x.js → erDiagram-RLTQ6QDP-mEgSpGUN.js} +1 -1
- package/runtime/webapp/dist/assets/{file-types-Bi7YTERW.js → file-types-DgQXHGm7.js} +1 -1
- package/runtime/webapp/dist/assets/{flowDiagram-HODETNUW-wm5Kefw0.js → flowDiagram-HODETNUW-DJWXgpoo.js} +1 -1
- package/runtime/webapp/dist/assets/{ganttDiagram-EL5Y4UJY-DN5F7ix3.js → ganttDiagram-EL5Y4UJY-B5HA7Xox.js} +1 -1
- package/runtime/webapp/dist/assets/{gitGraphDiagram-WWUBYQGX-DcpXNY21.js → gitGraphDiagram-WWUBYQGX-CP4Zmize.js} +1 -1
- package/runtime/webapp/dist/assets/index-BReRPZnZ.js +485 -0
- package/runtime/webapp/dist/assets/index-DfpiL3X7.css +1 -0
- package/runtime/webapp/dist/assets/{infoDiagram-27XIBGKW-B1iXrK9c.js → infoDiagram-27XIBGKW-DApDSX70.js} +1 -1
- package/runtime/webapp/dist/assets/{ishikawaDiagram-5VMMS53U-C1jZv655.js → ishikawaDiagram-5VMMS53U-BCYtD2Fm.js} +1 -1
- package/runtime/webapp/dist/assets/{journeyDiagram-3NMN7TZE-BRSFQ0r1.js → journeyDiagram-3NMN7TZE-D3WEyKHq.js} +1 -1
- package/runtime/webapp/dist/assets/{kanban-definition-UXKFOSKX-Cl9je8cc.js → kanban-definition-UXKFOSKX-Q6vb0ZbD.js} +1 -1
- package/runtime/webapp/dist/assets/{layout-CKkSxSc4.js → layout-Bp7cvpx1.js} +1 -1
- package/runtime/webapp/dist/assets/{linear-CC85eD8_.js → linear-4ik7NzLN.js} +1 -1
- package/runtime/webapp/dist/assets/{loader-circle-C63zcjMg.js → loader-circle-BCsj2yyN.js} +1 -1
- package/runtime/webapp/dist/assets/{mermaid.core-DIjc2ZR6.js → mermaid.core-CmhaKXiP.js} +5 -5
- package/runtime/webapp/dist/assets/{mindmap-definition-YA3MSWOX-mJUtqDVt.js → mindmap-definition-YA3MSWOX-DabuuB2q.js} +1 -1
- package/runtime/webapp/dist/assets/{page-bnT1btVj.js → page-Cgp9NEw1.js} +5 -5
- package/runtime/webapp/dist/assets/{pegDiagram-XKGWAZYB-Dt3xAyl2.js → pegDiagram-XKGWAZYB-eIBdAhCQ.js} +1 -1
- package/runtime/webapp/dist/assets/{pieDiagram-E7YTZNPT-DleFmb0m.js → pieDiagram-E7YTZNPT-DUd7f60Q.js} +1 -1
- package/runtime/webapp/dist/assets/{quadrantDiagram-AXDQQJYC-BpeD8UfU.js → quadrantDiagram-AXDQQJYC-BPSqBWPV.js} +1 -1
- package/runtime/webapp/dist/assets/{railroadDiagram-O6MQD6OU-BBQ5ixic.js → railroadDiagram-O6MQD6OU-CHqMz56-.js} +1 -1
- package/runtime/webapp/dist/assets/{requirementDiagram-BXWQKSXE-xO5TSQS3.js → requirementDiagram-BXWQKSXE-BfOzGN7B.js} +1 -1
- package/runtime/webapp/dist/assets/{rotate-ccw-AmWkL3kV.js → rotate-ccw-p76OF6j6.js} +1 -1
- package/runtime/webapp/dist/assets/{rotate-cw-DrY9cGmB.js → rotate-cw-D5iQzT0K.js} +1 -1
- package/runtime/webapp/dist/assets/{sankeyDiagram-P5KCCOFB-Fyt0-RhU.js → sankeyDiagram-P5KCCOFB-BFOPAhWl.js} +1 -1
- package/runtime/webapp/dist/assets/{send-ATfKaKHb.js → send-DdY_K1RT.js} +1 -1
- package/runtime/webapp/dist/assets/{sequenceDiagram-WJ2MYXX4-xkFumv3g.js → sequenceDiagram-WJ2MYXX4-CdQhFjho.js} +1 -1
- package/runtime/webapp/dist/assets/{sizeCapture-INFHLROL-Ch5NIy5j.js → sizeCapture-INFHLROL-BP_2bwHb.js} +1 -1
- package/runtime/webapp/dist/assets/{smartphone-BL3ONtnq.js → smartphone-C2--txxG.js} +1 -1
- package/runtime/webapp/dist/assets/{stateDiagram-D77RDMKH-BYyhiW6f.js → stateDiagram-D77RDMKH-D2_O1o9C.js} +1 -1
- package/runtime/webapp/dist/assets/stateDiagram-v2-MP3YSRHH-b3DtWIlg.js +1 -0
- package/runtime/webapp/dist/assets/{swimlanes-42K2YHIH-Da71LrsA.js → swimlanes-42K2YHIH-BwEWz-Bu.js} +1 -1
- package/runtime/webapp/dist/assets/swimlanesDiagram-VR7AAH4N-CxL0Wh2Z.js +8 -0
- package/runtime/webapp/dist/assets/{timeline-definition-24CTP7MA-BaXSS2__.js → timeline-definition-24CTP7MA-DqDB5dmr.js} +1 -1
- package/runtime/webapp/dist/assets/{trash-2-DBC-hIuM.js → trash-2-CZx0p0L3.js} +1 -1
- package/runtime/webapp/dist/assets/{vennDiagram-4TSXK5OY-D_V4cbSG.js → vennDiagram-4TSXK5OY-Cf4VnZ2O.js} +1 -1
- package/runtime/webapp/dist/assets/{wardleyDiagram-VM6X3IG4-C-31z3KF.js → wardleyDiagram-VM6X3IG4-D9FBNJOU.js} +1 -1
- package/runtime/webapp/dist/assets/{web-Co-fisS2.js → web-BVybOQy8.js} +1 -1
- package/runtime/webapp/dist/assets/{web-C3itPQLn.js → web-CT9Joona.js} +1 -1
- package/runtime/webapp/dist/assets/{x-qYJy8CK-.js → x-COYLzqlQ.js} +1 -1
- package/runtime/webapp/dist/assets/{xychartDiagram-S5SC5T6Z-DKF--ymA.js → xychartDiagram-S5SC5T6Z-BRVtPtRz.js} +1 -1
- package/runtime/webapp/dist/index.html +2 -2
- package/runtime/.next/static/chunks/344-04fd45d8838bfada.js +0 -1
- package/runtime/.next/static/chunks/app/web/layout-c8709c08fb7ad857.js +0 -1
- package/runtime/.next/static/chunks/app/web/page-b876912c109021db.js +0 -1
- package/runtime/.next/static/css/71e679260520d186.css +0 -1
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-36zyfan5.mjs +0 -52
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-nne0e2ds.mjs +0 -40
- package/runtime/webapp/dist/assets/channel-B0Az_kl0.js +0 -1
- package/runtime/webapp/dist/assets/classDiagram-ZZMXUADV-HNxe_TWF.js +0 -1
- package/runtime/webapp/dist/assets/classDiagram-v2-VYDZK3BY-HNxe_TWF.js +0 -1
- package/runtime/webapp/dist/assets/index-Ddj6oQ7t.js +0 -480
- package/runtime/webapp/dist/assets/index-hju2LxNM.css +0 -1
- package/runtime/webapp/dist/assets/stateDiagram-v2-MP3YSRHH-BbZH2Sb9.js +0 -1
- package/runtime/webapp/dist/assets/swimlanesDiagram-VR7AAH4N-CxBioyEE.js +0 -8
- /package/runtime/.next/static/{4yVGaJwabJff1LDiyzYia → nDZmrx61FQSBYCG7rH1JD}/_buildManifest.js +0 -0
- /package/runtime/.next/static/{4yVGaJwabJff1LDiyzYia → nDZmrx61FQSBYCG7rH1JD}/_ssgManifest.js +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g as oe}from"./chunk-XXDRQBXY-
|
|
1
|
+
import{g as oe}from"./chunk-XXDRQBXY-CRpw-5Cj.js";import{s as ce}from"./chunk-POPQ4Y6H-3vOXloa3.js";import{_ as h,l as R,u as le,v as he,y as de,B as W,c as U,i as H,b4 as ge,ac as ue,ad as pe,ae as fe}from"./mermaid.core-CmhaKXiP.js";import"./index-BReRPZnZ.js";const _=[];for(let t=0;t<256;++t)_.push((t+256).toString(16).slice(1));function me(t,e=0){return(_[t[e+0]]+_[t[e+1]]+_[t[e+2]]+_[t[e+3]]+"-"+_[t[e+4]]+_[t[e+5]]+"-"+_[t[e+6]]+_[t[e+7]]+"-"+_[t[e+8]]+_[t[e+9]]+"-"+_[t[e+10]]+_[t[e+11]]+_[t[e+12]]+_[t[e+13]]+_[t[e+14]]+_[t[e+15]]).toLowerCase()}const ye=new Uint8Array(16);function Ee(){return crypto.getRandomValues(ye)}function _e(t,e,o){return crypto.randomUUID?crypto.randomUUID():be(t)}function be(t,e,o){var n;t=t||{};const l=t.random??((n=t.rng)==null?void 0:n.call(t))??Ee();if(l.length<16)throw new Error("Random bytes length must be >= 16");return l[6]=l[6]&15|64,l[8]=l[8]&63|128,me(l)}var K=function(){var t=h(function(O,s,i,a){for(i=i||{},a=O.length;a--;i[O[a]]=s);return i},"o"),e=[1,4],o=[1,13],l=[1,12],n=[1,15],d=[1,16],p=[1,20],y=[1,19],E=[6,7,8],k=[1,26],L=[1,24],D=[1,25],b=[6,7,11],$=[1,6,13,15,16,19,22],f=[1,33],B=[1,34],P=[1,6,7,11,13,15,16,19,22],z={trace:h(function(){},"trace"),yy:{},symbols_:{error:2,start:3,mindMap:4,spaceLines:5,SPACELINE:6,NL:7,MINDMAP:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,node:14,ICON:15,CLASS:16,nodeWithId:17,nodeWithoutId:18,NODE_DSTART:19,NODE_DESCR:20,NODE_DEND:21,NODE_ID:22,$accept:0,$end:1},terminals_:{2:"error",6:"SPACELINE",7:"NL",8:"MINDMAP",11:"EOF",13:"SPACELIST",15:"ICON",16:"CLASS",19:"NODE_DSTART",20:"NODE_DESCR",21:"NODE_DEND",22:"NODE_ID"},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,2],[12,2],[12,2],[12,1],[12,1],[12,1],[12,1],[12,1],[14,1],[14,1],[18,3],[17,1],[17,4]],performAction:h(function(s,i,a,c,u,r,M){var g=r.length-1;switch(u){case 6:case 7:return c;case 8:c.getLogger().trace("Stop NL ");break;case 9:c.getLogger().trace("Stop EOF ");break;case 11:c.getLogger().trace("Stop NL2 ");break;case 12:c.getLogger().trace("Stop EOF2 ");break;case 15:c.getLogger().info("Node: ",r[g].id),c.addNode(r[g-1].length,r[g].id,r[g].descr,r[g].type);break;case 16:c.getLogger().trace("Icon: ",r[g]),c.decorateNode({icon:r[g]});break;case 17:case 21:c.decorateNode({class:r[g]});break;case 18:c.getLogger().trace("SPACELIST");break;case 19:c.getLogger().trace("Node: ",r[g].id),c.addNode(0,r[g].id,r[g].descr,r[g].type);break;case 20:c.decorateNode({icon:r[g]});break;case 25:c.getLogger().trace("node found ..",r[g-2]),this.$={id:r[g-1],descr:r[g-1],type:c.getType(r[g-2],r[g])};break;case 26:this.$={id:r[g],descr:r[g],type:c.nodeType.DEFAULT};break;case 27:c.getLogger().trace("node found ..",r[g-3]),this.$={id:r[g-3],descr:r[g-1],type:c.getType(r[g-2],r[g])};break}},"anonymous"),table:[{3:1,4:2,5:3,6:[1,5],8:e},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:e},{6:o,7:[1,10],9:9,12:11,13:l,14:14,15:n,16:d,17:17,18:18,19:p,22:y},t(E,[2,3]),{1:[2,2]},t(E,[2,4]),t(E,[2,5]),{1:[2,6],6:o,12:21,13:l,14:14,15:n,16:d,17:17,18:18,19:p,22:y},{6:o,9:22,12:11,13:l,14:14,15:n,16:d,17:17,18:18,19:p,22:y},{6:k,7:L,10:23,11:D},t(b,[2,22],{17:17,18:18,14:27,15:[1,28],16:[1,29],19:p,22:y}),t(b,[2,18]),t(b,[2,19]),t(b,[2,20]),t(b,[2,21]),t(b,[2,23]),t(b,[2,24]),t(b,[2,26],{19:[1,30]}),{20:[1,31]},{6:k,7:L,10:32,11:D},{1:[2,7],6:o,12:21,13:l,14:14,15:n,16:d,17:17,18:18,19:p,22:y},t($,[2,14],{7:f,11:B}),t(P,[2,8]),t(P,[2,9]),t(P,[2,10]),t(b,[2,15]),t(b,[2,16]),t(b,[2,17]),{20:[1,35]},{21:[1,36]},t($,[2,13],{7:f,11:B}),t(P,[2,11]),t(P,[2,12]),{21:[1,37]},t(b,[2,25]),t(b,[2,27])],defaultActions:{2:[2,1],6:[2,2]},parseError:h(function(s,i){if(i.recoverable)this.trace(s);else{var a=new Error(s);throw a.hash=i,a}},"parseError"),parse:h(function(s){var i=this,a=[0],c=[],u=[null],r=[],M=this.table,g="",F=0,Q=0,ie=2,Z=1,se=r.slice.call(arguments,1),m=Object.create(this.lexer),C={yy:{}};for(var X in this.yy)Object.prototype.hasOwnProperty.call(this.yy,X)&&(C.yy[X]=this.yy[X]);m.setInput(s,C.yy),C.yy.lexer=m,C.yy.parser=this,typeof m.yylloc>"u"&&(m.yylloc={});var Y=m.yylloc;r.push(Y);var re=m.options&&m.options.ranges;typeof C.yy.parseError=="function"?this.parseError=C.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function ae(x){a.length=a.length-2*x,u.length=u.length-x,r.length=r.length-x}h(ae,"popStack");function ee(){var x;return x=c.pop()||m.lex()||Z,typeof x!="number"&&(x instanceof Array&&(c=x,x=c.pop()),x=i.symbols_[x]||x),x}h(ee,"lex");for(var S,I,N,q,w={},G,v,te,j;;){if(I=a[a.length-1],this.defaultActions[I]?N=this.defaultActions[I]:((S===null||typeof S>"u")&&(S=ee()),N=M[I]&&M[I][S]),typeof N>"u"||!N.length||!N[0]){var J="";j=[];for(G in M[I])this.terminals_[G]&&G>ie&&j.push("'"+this.terminals_[G]+"'");m.showPosition?J="Parse error on line "+(F+1)+`:
|
|
2
2
|
`+m.showPosition()+`
|
|
3
3
|
Expecting `+j.join(", ")+", got '"+(this.terminals_[S]||S)+"'":J="Parse error on line "+(F+1)+": Unexpected "+(S==Z?"end of input":"'"+(this.terminals_[S]||S)+"'"),this.parseError(J,{text:m.match,token:this.terminals_[S]||S,line:m.yylineno,loc:Y,expected:j})}if(N[0]instanceof Array&&N.length>1)throw new Error("Parse Error: multiple actions possible at state: "+I+", token: "+S);switch(N[0]){case 1:a.push(S),u.push(m.yytext),r.push(m.yylloc),a.push(N[1]),S=null,Q=m.yyleng,g=m.yytext,F=m.yylineno,Y=m.yylloc;break;case 2:if(v=this.productions_[N[1]][1],w.$=u[u.length-v],w._$={first_line:r[r.length-(v||1)].first_line,last_line:r[r.length-1].last_line,first_column:r[r.length-(v||1)].first_column,last_column:r[r.length-1].last_column},re&&(w._$.range=[r[r.length-(v||1)].range[0],r[r.length-1].range[1]]),q=this.performAction.apply(w,[g,Q,F,C.yy,N[1],u,r].concat(se)),typeof q<"u")return q;v&&(a=a.slice(0,-1*v*2),u=u.slice(0,-1*v),r=r.slice(0,-1*v)),a.push(this.productions_[N[1]][0]),u.push(w.$),r.push(w._$),te=M[a[a.length-2]][a[a.length-1]],a.push(te);break;case 3:return!0}}return!0},"parse")},ne=function(){var O={EOF:1,parseError:h(function(i,a){if(this.yy.parser)this.yy.parser.parseError(i,a);else throw new Error(i)},"parseError"),setInput:h(function(s,i){return this.yy=i||this.yy||{},this._input=s,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:h(function(){var s=this._input[0];this.yytext+=s,this.yyleng++,this.offset++,this.match+=s,this.matched+=s;var i=s.match(/(?:\r\n?|\n).*/g);return i?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),s},"input"),unput:h(function(s){var i=s.length,a=s.split(/(?:\r\n?|\n)/g);this._input=s+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-i),this.offset-=i;var c=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),a.length-1&&(this.yylineno-=a.length-1);var u=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:a?(a.length===c.length?this.yylloc.first_column:0)+c[c.length-a.length].length-a[0].length:this.yylloc.first_column-i},this.options.ranges&&(this.yylloc.range=[u[0],u[0]+this.yyleng-i]),this.yyleng=this.yytext.length,this},"unput"),more:h(function(){return this._more=!0,this},"more"),reject:h(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
|
|
4
4
|
`+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:h(function(s){this.unput(this.match.slice(s))},"less"),pastInput:h(function(){var s=this.matched.substr(0,this.matched.length-this.match.length);return(s.length>20?"...":"")+s.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:h(function(){var s=this.match;return s.length<20&&(s+=this._input.substr(0,20-s.length)),(s.substr(0,20)+(s.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:h(function(){var s=this.pastInput(),i=new Array(s.length+1).join("-");return s+this.upcomingInput()+`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./TerminalPane-
|
|
2
|
-
import{c as dt,r as t,j as e,P as $e,f as Te,R as be,m as Ar,n as zr,o as Re,s as cr,p as Dr,b as Ne,q as Fe,t as Or,v as Wr,w as qt,x as _r,d as Fr,y as $r,U as ut,l as et,g as lr,z as dr,L as ur,D as pt,E as Ur,F as Br,G as Ht,I as qr,J as Hr,K as Vr,N as Kr,O as tt,Q as Gr,S as rt,T as Qe,V as Yr,X as Jr,Y as Xr,Z as Qr,_ as Zr,$ as Vt,a0 as Pe}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./TerminalPane-BxEtw8rn.js","./index-BReRPZnZ.js","./index-DfpiL3X7.css","./clipboard-BKglnESD.js","./smartphone-C2--txxG.js","./x-COYLzqlQ.js","./artifact-links-DwSH3xn_.js","./trash-2-CZx0p0L3.js","./CollaborationTabBridge-Dqnn1SXm.js","./RemoteDesktopTabBridge-Cp9mLtcY.js","./TerminalPane-6GBZ9nXN.css","./FileTree-DrpruRST.js","./file-types-DgQXHGm7.js","./loader-circle-BCsj2yyN.js","./FilePreview-C4gxZRtw.js","./rotate-ccw-p76OF6j6.js","./FilePreview-Zls_kcY7.css","./AiHubPane-Cd-7gwJs.js","./send-DdY_K1RT.js","./FlowStudioPane-BjOuLwks.js","./rotate-cw-D5iQzT0K.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as dt,r as t,j as e,P as $e,f as Te,R as be,m as Ar,n as zr,o as Re,s as cr,p as Dr,b as Ne,q as Fe,t as Or,v as Wr,w as qt,x as _r,d as Fr,y as $r,U as ut,l as et,g as lr,z as dr,L as ur,D as pt,E as Ur,F as Br,G as Ht,I as qr,J as Hr,K as Vr,N as Kr,O as tt,Q as Gr,S as rt,T as Qe,V as Yr,X as Jr,Y as Xr,Z as Qr,_ as Zr,$ as Vt,a0 as Pe}from"./index-BReRPZnZ.js";import{S as pr,M as Kt,a as en,G as tn,C as rn,P as nn}from"./smartphone-C2--txxG.js";import{X as ke}from"./x-COYLzqlQ.js";import{C as nt,a as on,r as an,i as Gt}from"./artifact-links-DwSH3xn_.js";import{T as mt,P as ot,C as sn,A as cn}from"./trash-2-CZx0p0L3.js";import{E as ft,c as ln}from"./clipboard-BKglnESD.js";import{r as dn,d as un,e as pn}from"./CollaborationTabBridge-Dqnn1SXm.js";import{c as mn,d as fn,R as hn,b as gn}from"./RemoteDesktopTabBridge-Cp9mLtcY.js";/**
|
|
3
3
|
* @license lucide-react v0.468.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
@@ -28,7 +28,7 @@ import{c as dt,r as t,j as e,P as $e,f as Te,R as be,m as Ar,n as zr,o as Re,s a
|
|
|
28
28
|
.codex-sharing-actions button:focus-visible{outline:2px solid var(--ui-tab-accent,#7aa2f7);outline-offset:3px}
|
|
29
29
|
.codex-sharing-actions button:disabled{opacity:.5;cursor:wait}
|
|
30
30
|
@media(pointer:coarse){.codex-sharing-actions button{min-height:44px}}
|
|
31
|
-
`;function jn({computerName:r,page:o,onClose:a,onSave:s}){const[l,d]=t.useState((o==null?void 0:o.name)??""),[u,p]=t.useState((o==null?void 0:o.url)??""),[j,v]=t.useState((o==null?void 0:o.openMode)??"current"),[C,c]=t.useState(!!o),[k,T]=t.useState(""),[L,m]=t.useState(!1),y=t.useRef(!1),w=t.useRef(null);return t.useEffect(()=>{var R,N;(N=(R=w.current)==null?void 0:R.querySelector("input"))==null||N.focus();const x=D=>{var H;if(D.key==="Escape"&&!y.current&&a(),D.key!=="Tab")return;const M=(H=w.current)==null?void 0:H.querySelectorAll("button:not(:disabled), input:not(:disabled), select:not(:disabled)");if(!(M!=null&&M.length))return;const X=M[0],B=M[M.length-1];D.shiftKey&&document.activeElement===X?(D.preventDefault(),B.focus()):!D.shiftKey&&document.activeElement===B&&(D.preventDefault(),X.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[a]),e.jsx("div",{className:"computer-dialog-backdrop","data-toolbar-overlay":!0,onClick:x=>{x.target===x.currentTarget&&!y.current&&a()},children:e.jsxs("section",{ref:w,className:"computer-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"computer-page-title",children:[e.jsxs("div",{className:"computer-dialog-heading",children:[e.jsx("h2",{id:"computer-page-title",children:o?"编辑页面":"添加页面"}),e.jsx("button",{type:"button",className:"computer-close","aria-label":"关闭",disabled:L,onClick:a,children:e.jsx(ke,{size:20})})]}),e.jsxs("p",{className:"computer-hint",children:["所属电脑:",r]}),e.jsxs("form",{onSubmit:async x=>{if(x.preventDefault(),!y.current){y.current=!0,m(!0),T("");try{const R=zr(u),N=(o==null?void 0:o.id)??Array.from(crypto.getRandomValues(new Uint8Array(16)),D=>D.toString(16).padStart(2,"0")).join("");await s({id:N,name:l.trim(),url:R,openMode:j})}catch(R){T(R.message)}finally{y.current=!1,m(!1)}}},children:[e.jsx("label",{htmlFor:"computer-page-name",children:"页面名称"}),e.jsx("input",{id:"computer-page-name",maxLength:60,required:!0,disabled:L,value:l,onChange:x=>d(x.target.value),placeholder:"例如:Zcode / Qoder",autoComplete:"off"}),e.jsx("label",{htmlFor:"computer-page-url",children:"页面地址"}),e.jsx("input",{id:"computer-page-url",required:!0,disabled:L,value:u,onChange:x=>{p(x.target.value),C||v(Ar(x.target.value))},placeholder:"https://…",autoComplete:"off",spellCheck:!1}),e.jsx("label",{htmlFor:"computer-page-mode",children:"打开方式"}),e.jsxs("select",{id:"computer-page-mode",disabled:L,value:j,onChange:x=>{v(x.target.value),c(!0)},children:[e.jsx("option",{value:"current",children:"当前页面打开,保留顶部图标栏"}),e.jsx("option",{value:"new-tab",children:"新页面打开,保留原会话页"})]}),e.jsx("p",{className:"computer-hint",children:"当前页面会显示网站自己的界面。若网站禁止内嵌(如 Qoder),可改为新页面打开。"}),k&&e.jsx("p",{className:"computer-error",role:"alert",children:k}),e.jsx("button",{type:"submit",className:"computer-action computer-primary",disabled:L||!l.trim()||!u.trim(),children:L?"正在保存…":"保存页面"})]})]})})}async function En(r,o){const a=new AbortController,s=()=>a.abort();if(o!=null&&o.aborted)return"offline";o==null||o.addEventListener("abort",s,{once:!0});const l=setTimeout(s,4e3);try{const d=new URL("/pwa/icon-192.png",r);d.searchParams.set("online",String(Date.now()));const u=await fetch(d,{mode:"no-cors",credentials:"omit",cache:"no-store",referrerPolicy:"no-referrer",signal:a.signal});return u.type==="opaque"||u.ok?"online":"offline"}catch{return"offline"}finally{clearTimeout(l),o==null||o.removeEventListener("abort",s)}}const Sn=20;function at(r){if(!Array.isArray(r)||r.length>Sn)throw new Error("最多可添加 20 台电脑。");const o=new Set;return r.map(a=>{if(!a||typeof a!="object"||Array.isArray(a)||Object.keys(a).some(l=>!["origin","name"].includes(l))||typeof a.origin!="string"||a.origin.length>2048)throw new Error("电脑地址无效。");let s;try{s=new URL(a.origin)}catch{throw new Error("电脑地址无效。")}if(!["http:","https:"].includes(s.protocol)||s.username||s.password||s.pathname!=="/"||s.search||s.hash||o.has(s.origin))throw new Error("电脑地址无效或重复。");if(typeof a.name!="string"||!a.name.trim()||a.name.trim().length>60)throw new Error("电脑名称需为 1–60 个字符。");return o.add(s.origin),{origin:s.origin,name:a.name.trim()}})}async function Jt(r,o="GET",a){var d;const s=await fetch("/api/web-console/computers",{method:o,credentials:"same-origin",cache:"no-store",headers:a?{"content-type":"application/json","x-csrf-token":r}:void 0,body:a?JSON.stringify(a):void 0,signal:AbortSignal.timeout(15e3)}).catch(()=>{throw new Error("无法连接当前电脑,请检查连接后重试。")}),l=await s.json().catch(()=>null);if(!s.ok)throw new Error(((d=l==null?void 0:l.error)==null?void 0:d.message)??"电脑列表保存失败,请重试。");return at(l==null?void 0:l.computers)}function Cn(r){const[o,a]=t.useState([]),[s,l]=t.useState(!1),[d,u]=t.useState(!1),[p,j]=t.useState(""),v=t.useRef(!0),C=t.useRef(!1),c=t.useRef(0),k=t.useRef(!1),T=t.useCallback(R=>{if(v.current){a(N=>N.length===R.length&&N.every((D,M)=>D.origin===R[M].origin&&D.name===R[M].name)?N:R),l(!0);try{const N=Re();cr(R.map(D=>({...N.find(M=>M.origin===D.origin),...D})))}catch{}}},[]),L=t.useCallback(async()=>{if(C.current)return;const R=++c.current;try{const N=k.current?void 0:Dr(Ne(),void 0).map(({origin:M,name:X})=>({origin:M,name:X})),D=await Jt(r,N?"POST":"GET",N?{computers:N}:void 0);if(!v.current||R!==c.current)return;k.current=!0,T(D),j("")}catch(N){v.current&&R===c.current&&j(N instanceof Error?N.message:"无法读取电脑列表。")}},[T,r]);t.useEffect(()=>{v.current=!0,L();const R=()=>{document.hidden||L()};window.addEventListener("focus",R),window.addEventListener("pageshow",R);const N=window.setInterval(R,15e3);return()=>{v.current=!1,c.current++,window.removeEventListener("focus",R),window.removeEventListener("pageshow",R),window.clearInterval(N)}},[L]);const m=t.useCallback(async(R,N)=>{if(!s||C.current)throw new Error("电脑列表尚未就绪,请稍后重试。");C.current=!0,c.current++,u(!0),j("");try{T(await Jt(r,R,N))}catch(D){const M=D instanceof Error?D.message:"电脑列表保存失败,请重试。";throw v.current&&j(M),new Error(M)}finally{C.current=!1,v.current&&u(!1)}},[T,r,s]),y=t.useCallback((R,N)=>m("PATCH",at([{origin:R,name:N}])[0]),[m]),w=t.useCallback(async R=>{if(new URL(R).origin===Ne())throw new Error("不能删除当前连接的电脑。");await m("DELETE",{origin:R})},[m]),x=t.useCallback((R,N)=>m("POST",{computers:at([{origin:R,name:N}]),restore:!0}),[m]);return{computers:o,loaded:s,saving:d,error:p,reload:L,rename:y,remove:w,add:x}}let Xt;function mr(){return window.jsQR?Promise.resolve():Xt||(Xt=new Promise((r,o)=>{const a=document.createElement("script");a.src="/pwa/qr-decoder.js";const s=()=>{clearTimeout(l),Xt=null,a.remove(),o(new Error("二维码识别器加载失败,请重试。"))},l=setTimeout(s,1e4);a.onload=()=>{clearTimeout(l),r()},a.onerror=s,document.head.append(a)}))}function st(){var r;return!!(window.isSecureContext&&((r=navigator.mediaDevices)!=null&&r.getUserMedia))}async function Tn(r){if(!r||r.type&&!r.type.startsWith("image/"))throw new Error("请选择二维码照片。");if(r.size>20*1024*1024)throw new Error("照片过大,请重新拍摄二维码。");await mr();const o=new Image,a=URL.createObjectURL(r);try{await new Promise((d,u)=>{const p=setTimeout(()=>u(new Error("照片加载超时,请重新拍摄。")),1e4);o.onload=()=>{clearTimeout(p),d()},o.onerror=()=>{clearTimeout(p),u(new Error("无法读取照片,请重新拍摄二维码。"))},o.src=a});const s=document.createElement("canvas"),l=s.getContext("2d",{willReadFrequently:!0});for(const d of[1600,1024,640]){const u=Math.min(1,d/Math.max(o.naturalWidth,o.naturalHeight));s.width=Math.max(1,Math.round(o.naturalWidth*u)),s.height=Math.max(1,Math.round(o.naturalHeight*u)),l.drawImage(o,0,0,s.width,s.height);const p=l.getImageData(0,0,s.width,s.height),j=window.jsQR(p.data,p.width,p.height);if(j)return j.data}throw new Error("照片中没有识别到二维码,请靠近电脑屏幕重新拍摄。")}finally{o.onload=null,o.onerror=null,URL.revokeObjectURL(a)}}function Rn(r,o,a){let s,l=0,d;const u=()=>{l++,clearTimeout(d),s==null||s.getTracks().forEach(C=>C.stop()),s=null,r.srcObject=null},p=(C,c)=>{C===l&&(u(),a((c==null?void 0:c.name)==="NotAllowedError"?"相机权限未开启,请允许相机或粘贴二维码链接。":(c==null?void 0:c.message)||"无法启动扫码,请重试。"))},j=async()=>{u();const C=l;if(!st()){a("实时扫码需要 HTTPS,请使用拍照扫码。");return}try{if(await mr(),C!==l)return;const c=await navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:"environment"}},audio:!1});if(C!==l){c.getTracks().forEach(y=>y.stop());return}s=c,r.srcObject=c;let k;try{await Promise.race([r.play(),new Promise((y,w)=>{k=setTimeout(()=>w(new Error("相机没有返回画面,请重试。")),1e4)})])}finally{clearTimeout(k)}if(C!==l)return;const T=document.createElement("canvas"),L=T.getContext("2d",{willReadFrequently:!0}),m=()=>{if(C===l)try{if(r.videoWidth&&r.videoHeight){T.width=Math.min(r.videoWidth,640),T.height=Math.round(r.videoHeight*T.width/r.videoWidth),L.drawImage(r,0,0,T.width,T.height);const y=L.getImageData(0,0,T.width,T.height),w=window.jsQR(y.data,y.width,y.height);if(w){u(),o(w.data);return}}d=setTimeout(m,250)}catch(y){u(),a((y==null?void 0:y.message)||"二维码识别失败,请重试。")}};m()}catch(c){p(C,c)}},v=()=>{document.hidden&&u()};return window.addEventListener("pagehide",u),document.addEventListener("visibilitychange",v),{start:j,stop:u,dispose(){u(),window.removeEventListener("pagehide",u),document.removeEventListener("visibilitychange",v)}}}const Nn=[{id:"refresh",name:"刷新",Icon:be},{id:"collaboration",name:"群聊看板",Icon:ut},{id:"remote",name:"远程桌面",Icon:et},{id:"theme",name:"皮肤",Icon:lr},{id:"files",name:"文件树",Icon:dr},{id:"ai-hub",name:"AI Hub",Icon:ur},{id:"flow",name:"数字人",Icon:pt},{id:"install",name:"添加到主屏幕",Icon:pr}];function Pn({username:r,connected:o,accent:a,accentText:s,selectedPageId:l,onSelectPage:d,onUpdatePage:u,configuration:p,csrfToken:j}){const v=t.useRef(null),C=t.useRef(null),c=Cn(j),k=c.computers,[T,L]=t.useState(""),[m,y]=t.useState(null),[w,x]=t.useState(!1),[R,N]=t.useState("home"),[D,M]=t.useState(!1),[X,B]=t.useState({top:48,right:12}),[H,ne]=t.useState(null),[$,P]=t.useState(null),[A,E]=t.useState(""),[I,z]=t.useState({}),g=k.find(b=>b.origin===T),_=p.settings.savedPages??[];t.useEffect(()=>{var b;p.loaded&&l&&u(((b=p.settings.savedPages)==null?void 0:b.find(O=>O.id===l))??null)},[p.loaded,p.settings.savedPages,l,u]),t.useEffect(()=>{var Y;L(Ne()),y(((Y=v.current)==null?void 0:Y.closest(".web-root"))??document.body);const b=window.matchMedia("(max-width: 600px)"),O=()=>M(b.matches);return O(),b.addEventListener("change",O),()=>{b.removeEventListener("change",O)}},[]),t.useEffect(()=>{if(!w)return;const b=U=>{var V,G;!((V=C.current)!=null&&V.contains(U.target))&&!((G=v.current)!=null&&G.contains(U.target))&&x(!1)},O=U=>{var Ie,Me;if(U.key==="Escape"&&(x(!1),(Ie=v.current)==null||Ie.focus()),!D||U.key!=="Tab")return;const V=(Me=C.current)==null?void 0:Me.querySelectorAll("button:not(:disabled), input:not(:disabled)");if(!(V!=null&&V.length))return;const G=V[0],se=V[V.length-1];U.shiftKey&&document.activeElement===G?(U.preventDefault(),se.focus()):!U.shiftKey&&document.activeElement===se&&(U.preventDefault(),G.focus())},Y=()=>{var G;const U=(G=v.current)==null?void 0:G.getBoundingClientRect();if(!U)return;const V=Math.min(292,innerWidth-24);B({top:U.bottom+8,right:Math.max(12,Math.min(innerWidth-V-12,innerWidth-U.right))})};return document.addEventListener("pointerdown",b),document.addEventListener("keydown",O),window.addEventListener("resize",Y),()=>{document.removeEventListener("pointerdown",b),document.removeEventListener("keydown",O),window.removeEventListener("resize",Y)}},[w,D]),t.useEffect(()=>{var b,O;w&&((O=(b=C.current)==null?void 0:b.querySelector("button"))==null||O.focus())},[w,R]),t.useEffect(()=>{if(!w)return;const b=new AbortController,O=()=>{for(const U of k)U.origin!==T&&En(U.origin,b.signal).then(V=>{b.signal.aborted||z(G=>({...G,[U.origin]:V}))})};O();const Y=window.setInterval(O,15e3);return window.addEventListener("online",O),()=>{b.abort(),window.clearInterval(Y),window.removeEventListener("online",O)}},[w,k,T]);const K=t.useCallback(()=>{var b;ne(null),(b=v.current)==null||b.focus()},[]),ie=t.useCallback(()=>{var b;P(null),(b=v.current)==null||b.focus()},[]),F=t.useCallback(async(b,O)=>{var G;if(Fe()){await Fe().pair(b);return}const Y=Or(b),U={origin:Y.origin,name:O.trim()||((G=k.find(se=>se.origin===Y.origin))==null?void 0:G.name)||Y.hostname},V=Wr(b,qt(Re(),k,[U]),O);await c.add(U.origin,U.name),location.assign(V)},[k,c.add]),ee=t.useCallback(async b=>{await c.rename(Ne(),b),K()},[K,c.rename]);return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:In}),e.jsxs("div",{className:"theme-avatar-with-status",children:[e.jsx("button",{ref:v,type:"button",className:"theme-avatar","aria-label":`电脑与连接状态(${r})`,title:r,style:{border:`1px solid ${a}`,background:a,color:s},"aria-expanded":w,"aria-haspopup":"true",onClick:()=>{const b=v.current.getBoundingClientRect(),O=Math.min(292,innerWidth-24);B({top:b.bottom+8,right:Math.max(12,Math.min(innerWidth-O-12,innerWidth-b.right))}),w||(N("home"),E(""),p.reload(),c.reload()),x(Y=>!Y)},children:(r.trim()[0]??"?").toUpperCase()}),e.jsx("span",{className:"theme-avatar-status","data-connected":o,"aria-label":o?"已连接":"未连接"})]}),w&&m&&Te.createPortal(e.jsx("div",{className:"computer-menu-backdrop","data-toolbar-overlay":!0,children:e.jsxs("div",{ref:C,className:"computer-menu",style:D?void 0:X,role:"dialog","aria-modal":D,"aria-label":R==="tools"?"配置顶部工具":R==="computers"?"选择电脑":"电脑与保存页面",children:[e.jsx("div",{className:"computer-menu-grip","aria-hidden":"true"}),e.jsxs("div",{className:"computer-menu-heading",children:[R!=="home"&&e.jsx("button",{type:"button",className:"computer-close","aria-label":"返回电脑菜单",onClick:()=>N("home"),children:e.jsx(_r,{size:20})}),R==="home"?e.jsxs("button",{type:"button",className:"computer-menu-item computer-current","aria-label":"选择电脑",onClick:()=>N("computers"),children:[e.jsx(Kt,{size:17}),e.jsxs("span",{children:[e.jsx("strong",{children:(g==null?void 0:g.name)||"当前电脑"}),e.jsx("small",{children:o?"当前 · 在线":"当前 · 未连接"})]}),e.jsx(Fr,{size:16})]}):e.jsx("strong",{children:R==="tools"?`${(g==null?void 0:g.name)||"当前电脑"} · 顶部工具`:"选择电脑"}),e.jsx("button",{type:"button",className:"computer-close","aria-label":"关闭电脑菜单",onClick:()=>{var b;x(!1),(b=v.current)==null||b.focus()},children:e.jsx(ke,{size:20})})]}),R==="computers"&&e.jsxs(e.Fragment,{children:[!c.loaded&&e.jsx("p",{className:"computer-save-status",role:"status",children:c.error?"电脑列表尚未加载":"正在读取电脑列表…"}),k.map(b=>{const O=b.origin===T?o?"online":"offline":I[b.origin]??"checking",Y=O==="online"?"在线":O==="offline"?"无法连接":"检测中";return e.jsxs("div",{className:"computer-menu-row",children:[e.jsxs("button",{type:"button",className:"computer-menu-item","data-computer-origin":b.origin,"aria-label":`${b.name},${Y}${b.origin===T?",当前电脑":""}`,"aria-current":b.origin===T?"true":void 0,onClick:()=>{if(b.origin===T)N("home");else try{const U=Fe();U?U.switchComputer(b.origin).catch(V=>E(V.message)):location.assign($r(b.origin,qt(Re(),k)))}catch(U){E(U.message)}},children:[e.jsx(Kt,{size:17,"aria-hidden":"true"}),e.jsxs("span",{children:[e.jsx("strong",{children:b.name}),e.jsx("small",{children:b.origin})]}),e.jsx("span",{className:"computer-status-dot","data-status":O,role:"img","aria-label":Y,title:Y}),b.origin===T&&e.jsx(nt,{size:16,"aria-label":"当前电脑"})]}),b.origin!==T&&e.jsx("button",{type:"button",className:"computer-page-control computer-delete-control","aria-label":`删除电脑:${b.name}`,title:`删除电脑:${b.name}`,disabled:c.saving,onClick:()=>{c.remove(b.origin).catch(()=>{})},children:e.jsx(mt,{size:15})})]},b.origin)}),e.jsx("div",{className:"computer-menu-divider"}),e.jsxs("button",{type:"button",className:"computer-menu-item",disabled:!c.loaded||c.saving,onClick:()=>{const b=Fe();b?b.scan().catch(O=>E(O.message)):(x(!1),ne("add"))},children:[e.jsx($e,{size:17,"aria-hidden":"true"}),e.jsx("span",{children:"扫码添加电脑"})]}),e.jsxs("button",{type:"button",className:"computer-menu-item",disabled:!c.loaded||c.saving||!g,onClick:()=>{x(!1),ne("rename")},children:[e.jsx(ot,{size:16,"aria-hidden":"true"}),e.jsx("span",{children:"修改当前电脑名称"})]}),c.error&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"computer-error",role:"alert",children:c.error}),e.jsxs("button",{type:"button",className:"computer-menu-item",onClick:()=>{c.reload()},children:[e.jsx(be,{size:16}),e.jsx("span",{children:"重新加载电脑列表"})]})]})]}),R==="home"&&e.jsxs(e.Fragment,{children:[e.jsx(vn,{csrfToken:j}),e.jsxs("div",{className:"computer-menu-label computer-pages-heading",children:[e.jsx("span",{children:"保存的页面"}),e.jsx("button",{type:"button",className:"computer-page-control","aria-label":"添加页面",disabled:!p.loaded||p.saving,onClick:()=>{x(!1),P({computer:g??{origin:T,name:"当前电脑"}})},children:e.jsx($e,{size:17})})]}),e.jsxs("button",{type:"button",className:"computer-menu-item","aria-current":l?void 0:"true",onClick:()=>{x(!1),d(null)},children:[e.jsx(bn,{size:17}),e.jsx("span",{children:"电脑会话"}),!l&&e.jsx(nt,{size:16})]}),_.map(b=>e.jsxs("div",{className:"computer-menu-row",children:[e.jsxs("button",{type:"button",className:"computer-menu-item","aria-label":`打开 ${b.name}`,"aria-current":l===b.id?"true":void 0,onClick:()=>{x(!1),d(b)},children:[e.jsx(it,{size:15,"aria-hidden":"true"}),e.jsxs("span",{children:[e.jsx("strong",{children:b.name}),e.jsxs("small",{children:[b.openMode==="current"?"当前页面":"新页面"," · ",new URL(b.url).hostname]})]}),b.openMode==="new-tab"&&e.jsx(ft,{size:13,"aria-hidden":"true"})]}),e.jsx("button",{type:"button",className:"computer-page-control","aria-label":`编辑 ${b.name}`,disabled:p.saving,onClick:()=>{x(!1),P({computer:g??{origin:T,name:"当前电脑"},page:b})},children:e.jsx(ot,{size:14})}),e.jsx("button",{type:"button",className:"computer-page-control","aria-label":`删除 ${b.name}`,disabled:p.saving,onClick:()=>{p.setSavedPages(_.filter(O=>O.id!==b.id)).catch(()=>{})},children:e.jsx(ke,{size:15})})]},b.id)),e.jsx("div",{className:"computer-menu-divider"}),e.jsxs("button",{type:"button",className:"computer-menu-item",onClick:()=>N("tools"),children:[e.jsx(en,{size:17}),e.jsx("span",{children:"配置顶部工具"}),e.jsx(sn,{size:16})]})]}),R==="tools"&&e.jsx("div",{className:"computer-tools-list",children:Nn.map(({id:b,name:O,Icon:Y})=>e.jsxs("label",{className:"computer-tool-option",children:[e.jsx(Y,{size:17,"aria-hidden":"true"}),e.jsx("span",{children:O}),e.jsx("input",{type:"checkbox","aria-label":`显示${O}`,checked:p.settings.visibleTools.includes(b),disabled:!p.loaded||p.saving,onChange:U=>{const V=p.settings.visibleTools;p.setVisibleTools(U.target.checked?[...V,b]:V.filter(G=>G!==b)).catch(()=>{})}})]},b))}),R!=="computers"&&e.jsx("p",{className:"computer-save-status",role:"status",children:p.loaded?p.saving?"正在保存…":p.notice:p.error?"配置尚未加载":"正在读取电脑配置…"}),p.error&&R!=="computers"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"computer-error",role:"alert",children:p.error}),e.jsxs("button",{type:"button",className:"computer-menu-item",onClick:()=>{p.reload()},children:[e.jsx(be,{size:16}),e.jsx("span",{children:"重新加载配置"})]})]}),A&&e.jsx("p",{className:"computer-error",role:"alert",children:A})]})}),m),H&&m&&Te.createPortal(e.jsx(Ln,{mode:H,currentName:(g==null?void 0:g.name)||"",onClose:K,onNavigate:F,onRename:ee}),m),$&&m&&Te.createPortal(e.jsx(jn,{computerName:$.computer.name,page:$.page,onClose:ie,onSave:async b=>{if($.page&&!_.some(O=>O.id===b.id))throw new Error("这个页面已在其他设备删除,请重新添加。");await p.setSavedPages($.page?_.map(O=>O.id===b.id?b:O):[..._,b]),ie()}}),m)]})}function Ln({mode:r,currentName:o,onClose:a,onNavigate:s,onRename:l}){const[d,u]=t.useState(r==="rename"?o:""),p=t.useRef(d);p.current=d;const[j,v]=t.useState(""),[C,c]=t.useState(""),[k,T]=t.useState(!1),[L,m]=t.useState(!1),[y,w]=t.useState(!1),[x,R]=t.useState(!1),N=t.useRef(null),D=t.useRef(null),M=t.useRef(0),X=t.useRef(null),B=t.useRef(null),H=t.useRef(null),ne=t.useCallback(async $=>{var P;T(!0),(P=H.current)==null||P.stop(),m(!1),c("");try{await s($,p.current)}catch(A){c(A.message)}finally{T(!1)}},[s]);return t.useEffect(()=>{var A,E,I;w(st()),r==="rename"?(A=X.current)==null||A.focus():(I=(E=B.current)==null?void 0:E.querySelector("button"))==null||I.focus();const $=z=>{var ie;if(z.key==="Escape"&&a(),z.key!=="Tab")return;const g=(ie=B.current)==null?void 0:ie.querySelectorAll("button:not(:disabled), input:not(:disabled)");if(!(g!=null&&g.length))return;const _=g[0],K=g[g.length-1];z.shiftKey&&document.activeElement===_?(z.preventDefault(),K.focus()):!z.shiftKey&&document.activeElement===K&&(z.preventDefault(),_.focus())},P=()=>{document.hidden&&m(!1)};return document.addEventListener("keydown",$),document.addEventListener("visibilitychange",P),r==="add"&&N.current&&(H.current=Rn(N.current,ne,z=>{m(!1),c(z)})),()=>{var z;M.current++,document.removeEventListener("keydown",$),document.removeEventListener("visibilitychange",P),(z=H.current)==null||z.dispose(),H.current=null}},[r,ne,a]),e.jsx("div",{className:"computer-dialog-backdrop","data-toolbar-overlay":!0,onClick:$=>{$.target===$.currentTarget&&a()},children:e.jsxs("section",{ref:B,className:"computer-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"computer-dialog-title",children:[e.jsxs("div",{className:"computer-dialog-heading",children:[e.jsx("h2",{id:"computer-dialog-title",children:r==="add"?"添加电脑":"修改电脑名称"}),e.jsx("button",{type:"button",className:"computer-close","aria-label":"关闭",onClick:a,children:e.jsx(ke,{size:20})})]}),e.jsxs("form",{onSubmit:async $=>{if($.preventDefault(),!k)if(r==="add")await ne(j);else{T(!0);try{await l(d.trim())}catch(P){c(P.message)}finally{T(!1)}}},children:[e.jsxs("label",{htmlFor:"computer-name",children:["电脑名称",r==="add"?"(选填)":""]}),e.jsx("input",{ref:X,id:"computer-name",maxLength:60,value:d,required:r==="rename",disabled:k,onChange:$=>u($.target.value),placeholder:"例如:A 电脑 / 家里的电脑",autoComplete:"off"}),r==="add"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"computer-hint",children:"扫描另一台电脑上的 AgentRoam 授权二维码,连接后会保留已有电脑。"}),e.jsx("input",{ref:D,type:"file",accept:"image/*",capture:"environment",hidden:!0,"aria-label":"拍摄授权二维码",onChange:async $=>{var E,I;const P=(E=$.currentTarget.files)==null?void 0:E[0];if($.currentTarget.value="",!P)return;const A=++M.current;(I=H.current)==null||I.stop(),m(!1),R(!0),c("");try{const z=await Tn(P);A===M.current&&ne(z)}catch(z){A===M.current&&c(z.message)}finally{A===M.current&&R(!1)}}}),e.jsx("video",{ref:N,playsInline:!0,muted:!0,hidden:!L,"aria-label":"扫码相机画面"}),e.jsxs("button",{className:"computer-action",type:"button",disabled:x,onClick:()=>{var $,P,A;c(""),L?(($=H.current)==null||$.stop(),m(!1)):st()?(m(!0),(A=H.current)==null||A.start()):(P=D.current)==null||P.click()},children:[e.jsx(Ur,{size:17,"aria-hidden":"true"}),x?"正在识别二维码…":L?"取消扫码":y?"打开相机扫码":"拍照扫码"]}),y&&e.jsx("button",{className:"computer-action",type:"button",disabled:x,onClick:()=>{var $,P;($=H.current)==null||$.stop(),m(!1),(P=D.current)==null||P.click()},children:"拍照识别二维码"}),e.jsx("label",{htmlFor:"computer-link",children:"或粘贴授权二维码链接"}),e.jsx("input",{id:"computer-link",value:j,onChange:$=>v($.target.value),placeholder:"http(s)://…/pair#pair=…",autoComplete:"off",spellCheck:!1})]}),C&&e.jsx("p",{className:"computer-error",role:"alert",children:C}),e.jsx("button",{className:"computer-action computer-primary",type:"submit",disabled:k||(r==="add"?!j.trim()||x:!d.trim()),children:r==="add"?"连接这台电脑":k?"正在保存…":"保存名称"})]})]})})}const In=`
|
|
31
|
+
`;function jn({computerName:r,page:o,onClose:a,onSave:s}){const[l,d]=t.useState((o==null?void 0:o.name)??""),[u,p]=t.useState((o==null?void 0:o.url)??""),[j,v]=t.useState((o==null?void 0:o.openMode)??"current"),[C,c]=t.useState(!!o),[k,T]=t.useState(""),[L,m]=t.useState(!1),y=t.useRef(!1),w=t.useRef(null);return t.useEffect(()=>{var R,N;(N=(R=w.current)==null?void 0:R.querySelector("input"))==null||N.focus();const x=D=>{var H;if(D.key==="Escape"&&!y.current&&a(),D.key!=="Tab")return;const M=(H=w.current)==null?void 0:H.querySelectorAll("button:not(:disabled), input:not(:disabled), select:not(:disabled)");if(!(M!=null&&M.length))return;const X=M[0],B=M[M.length-1];D.shiftKey&&document.activeElement===X?(D.preventDefault(),B.focus()):!D.shiftKey&&document.activeElement===B&&(D.preventDefault(),X.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[a]),e.jsx("div",{className:"computer-dialog-backdrop","data-toolbar-overlay":!0,onClick:x=>{x.target===x.currentTarget&&!y.current&&a()},children:e.jsxs("section",{ref:w,className:"computer-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"computer-page-title",children:[e.jsxs("div",{className:"computer-dialog-heading",children:[e.jsx("h2",{id:"computer-page-title",children:o?"编辑页面":"添加页面"}),e.jsx("button",{type:"button",className:"computer-close","aria-label":"关闭",disabled:L,onClick:a,children:e.jsx(ke,{size:20})})]}),e.jsxs("p",{className:"computer-hint",children:["所属电脑:",r]}),e.jsxs("form",{onSubmit:async x=>{if(x.preventDefault(),!y.current){y.current=!0,m(!0),T("");try{const R=zr(u),N=(o==null?void 0:o.id)??Array.from(crypto.getRandomValues(new Uint8Array(16)),D=>D.toString(16).padStart(2,"0")).join("");await s({id:N,name:l.trim(),url:R,openMode:j})}catch(R){T(R.message)}finally{y.current=!1,m(!1)}}},children:[e.jsx("label",{htmlFor:"computer-page-name",children:"页面名称"}),e.jsx("input",{id:"computer-page-name",maxLength:60,required:!0,disabled:L,value:l,onChange:x=>d(x.target.value),placeholder:"例如:Zcode / Qoder",autoComplete:"off"}),e.jsx("label",{htmlFor:"computer-page-url",children:"页面地址"}),e.jsx("input",{id:"computer-page-url",required:!0,disabled:L,value:u,onChange:x=>{p(x.target.value),C||v(Ar(x.target.value))},placeholder:"https://…",autoComplete:"off",spellCheck:!1}),e.jsx("label",{htmlFor:"computer-page-mode",children:"打开方式"}),e.jsxs("select",{id:"computer-page-mode",disabled:L,value:j,onChange:x=>{v(x.target.value),c(!0)},children:[e.jsx("option",{value:"current",children:"当前页面打开,保留顶部图标栏"}),e.jsx("option",{value:"new-tab",children:"新页面打开,保留原会话页"})]}),e.jsx("p",{className:"computer-hint",children:"当前页面会显示网站自己的界面。若网站禁止内嵌(如 Qoder),可改为新页面打开。"}),k&&e.jsx("p",{className:"computer-error",role:"alert",children:k}),e.jsx("button",{type:"submit",className:"computer-action computer-primary",disabled:L||!l.trim()||!u.trim(),children:L?"正在保存…":"保存页面"})]})]})})}async function En(r,o){const a=new AbortController,s=()=>a.abort();if(o!=null&&o.aborted)return"offline";o==null||o.addEventListener("abort",s,{once:!0});const l=setTimeout(s,4e3);try{const d=new URL("/pwa/icon-192.png",r);d.searchParams.set("online",String(Date.now()));const u=await fetch(d,{mode:"no-cors",credentials:"omit",cache:"no-store",referrerPolicy:"no-referrer",signal:a.signal});return u.type==="opaque"||u.ok?"online":"offline"}catch{return"offline"}finally{clearTimeout(l),o==null||o.removeEventListener("abort",s)}}const Sn=20;function at(r){if(!Array.isArray(r)||r.length>Sn)throw new Error("最多可添加 20 台电脑。");const o=new Set;return r.map(a=>{if(!a||typeof a!="object"||Array.isArray(a)||Object.keys(a).some(l=>!["origin","name"].includes(l))||typeof a.origin!="string"||a.origin.length>2048)throw new Error("电脑地址无效。");let s;try{s=new URL(a.origin)}catch{throw new Error("电脑地址无效。")}if(!["http:","https:"].includes(s.protocol)||s.username||s.password||s.pathname!=="/"||s.search||s.hash||o.has(s.origin))throw new Error("电脑地址无效或重复。");if(typeof a.name!="string"||!a.name.trim()||a.name.trim().length>60)throw new Error("电脑名称需为 1–60 个字符。");return o.add(s.origin),{origin:s.origin,name:a.name.trim()}})}async function Jt(r,o="GET",a){var d;const s=await fetch("/api/web-console/computers",{method:o,credentials:"same-origin",cache:"no-store",headers:a?{"content-type":"application/json","x-csrf-token":r}:void 0,body:a?JSON.stringify(a):void 0,signal:AbortSignal.timeout(15e3)}).catch(()=>{throw new Error("无法连接当前电脑,请检查连接后重试。")}),l=await s.json().catch(()=>null);if(!s.ok)throw new Error(((d=l==null?void 0:l.error)==null?void 0:d.message)??"电脑列表保存失败,请重试。");return at(l==null?void 0:l.computers)}function Cn(r){const[o,a]=t.useState([]),[s,l]=t.useState(!1),[d,u]=t.useState(!1),[p,j]=t.useState(""),v=t.useRef(!0),C=t.useRef(!1),c=t.useRef(0),k=t.useRef(!1),T=t.useCallback(R=>{if(v.current){a(N=>N.length===R.length&&N.every((D,M)=>D.origin===R[M].origin&&D.name===R[M].name)?N:R),l(!0);try{const N=Re();cr(R.map(D=>({...N.find(M=>M.origin===D.origin),...D})))}catch{}}},[]),L=t.useCallback(async()=>{if(C.current)return;const R=++c.current;try{const N=k.current?void 0:Dr(Ne(),void 0).map(({origin:M,name:X})=>({origin:M,name:X})),D=await Jt(r,N?"POST":"GET",N?{computers:N}:void 0);if(!v.current||R!==c.current)return;k.current=!0,T(D),j("")}catch(N){v.current&&R===c.current&&j(N instanceof Error?N.message:"无法读取电脑列表。")}},[T,r]);t.useEffect(()=>{v.current=!0,L();const R=()=>{document.hidden||L()};window.addEventListener("focus",R),window.addEventListener("pageshow",R);const N=window.setInterval(R,15e3);return()=>{v.current=!1,c.current++,window.removeEventListener("focus",R),window.removeEventListener("pageshow",R),window.clearInterval(N)}},[L]);const m=t.useCallback(async(R,N)=>{if(!s||C.current)throw new Error("电脑列表尚未就绪,请稍后重试。");C.current=!0,c.current++,u(!0),j("");try{T(await Jt(r,R,N))}catch(D){const M=D instanceof Error?D.message:"电脑列表保存失败,请重试。";throw v.current&&j(M),new Error(M)}finally{C.current=!1,v.current&&u(!1)}},[T,r,s]),y=t.useCallback((R,N)=>m("PATCH",at([{origin:R,name:N}])[0]),[m]),w=t.useCallback(async R=>{if(new URL(R).origin===Ne())throw new Error("不能删除当前连接的电脑。");await m("DELETE",{origin:R})},[m]),x=t.useCallback((R,N)=>m("POST",{computers:at([{origin:R,name:N}]),restore:!0}),[m]);return{computers:o,loaded:s,saving:d,error:p,reload:L,rename:y,remove:w,add:x}}let Xt;function mr(){return window.jsQR?Promise.resolve():Xt||(Xt=new Promise((r,o)=>{const a=document.createElement("script");a.src="/pwa/qr-decoder.js";const s=()=>{clearTimeout(l),Xt=null,a.remove(),o(new Error("二维码识别器加载失败,请重试。"))},l=setTimeout(s,1e4);a.onload=()=>{clearTimeout(l),r()},a.onerror=s,document.head.append(a)}))}function st(){var r;return!!(window.isSecureContext&&((r=navigator.mediaDevices)!=null&&r.getUserMedia))}async function Tn(r){if(!r||r.type&&!r.type.startsWith("image/"))throw new Error("请选择二维码照片。");if(r.size>20*1024*1024)throw new Error("照片过大,请重新拍摄二维码。");await mr();const o=new Image,a=URL.createObjectURL(r);try{await new Promise((d,u)=>{const p=setTimeout(()=>u(new Error("照片加载超时,请重新拍摄。")),1e4);o.onload=()=>{clearTimeout(p),d()},o.onerror=()=>{clearTimeout(p),u(new Error("无法读取照片,请重新拍摄二维码。"))},o.src=a});const s=document.createElement("canvas"),l=s.getContext("2d",{willReadFrequently:!0});for(const d of[1600,1024,640]){const u=Math.min(1,d/Math.max(o.naturalWidth,o.naturalHeight));s.width=Math.max(1,Math.round(o.naturalWidth*u)),s.height=Math.max(1,Math.round(o.naturalHeight*u)),l.drawImage(o,0,0,s.width,s.height);const p=l.getImageData(0,0,s.width,s.height),j=window.jsQR(p.data,p.width,p.height);if(j)return j.data}throw new Error("照片中没有识别到二维码,请靠近电脑屏幕重新拍摄。")}finally{o.onload=null,o.onerror=null,URL.revokeObjectURL(a)}}function Rn(r,o,a){let s,l=0,d;const u=()=>{l++,clearTimeout(d),s==null||s.getTracks().forEach(C=>C.stop()),s=null,r.srcObject=null},p=(C,c)=>{C===l&&(u(),a((c==null?void 0:c.name)==="NotAllowedError"?"相机权限未开启,请允许相机或粘贴二维码链接。":(c==null?void 0:c.message)||"无法启动扫码,请重试。"))},j=async()=>{u();const C=l;if(!st()){a("实时扫码需要 HTTPS,请使用拍照扫码。");return}try{if(await mr(),C!==l)return;const c=await navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:"environment"}},audio:!1});if(C!==l){c.getTracks().forEach(y=>y.stop());return}s=c,r.srcObject=c;let k;try{await Promise.race([r.play(),new Promise((y,w)=>{k=setTimeout(()=>w(new Error("相机没有返回画面,请重试。")),1e4)})])}finally{clearTimeout(k)}if(C!==l)return;const T=document.createElement("canvas"),L=T.getContext("2d",{willReadFrequently:!0}),m=()=>{if(C===l)try{if(r.videoWidth&&r.videoHeight){T.width=Math.min(r.videoWidth,640),T.height=Math.round(r.videoHeight*T.width/r.videoWidth),L.drawImage(r,0,0,T.width,T.height);const y=L.getImageData(0,0,T.width,T.height),w=window.jsQR(y.data,y.width,y.height);if(w){u(),o(w.data);return}}d=setTimeout(m,250)}catch(y){u(),a((y==null?void 0:y.message)||"二维码识别失败,请重试。")}};m()}catch(c){p(C,c)}},v=()=>{document.hidden&&u()};return window.addEventListener("pagehide",u),document.addEventListener("visibilitychange",v),{start:j,stop:u,dispose(){u(),window.removeEventListener("pagehide",u),document.removeEventListener("visibilitychange",v)}}}const Nn=[{id:"refresh",name:"刷新",Icon:be},{id:"collaboration",name:"群聊看板",Icon:ut},{id:"remote",name:"远程桌面",Icon:et},{id:"theme",name:"皮肤",Icon:lr},{id:"files",name:"文件树",Icon:dr},{id:"ai-hub",name:"AI Hub",Icon:ur},{id:"flow",name:"数字人",Icon:pt},{id:"install",name:"添加到主屏幕",Icon:pr}];function Pn({username:r,connected:o,accent:a,accentText:s,selectedPageId:l,onSelectPage:d,onUpdatePage:u,configuration:p,csrfToken:j}){const v=t.useRef(null),C=t.useRef(null),c=Cn(j),k=c.computers,[T,L]=t.useState(""),[m,y]=t.useState(null),[w,x]=t.useState(!1),[R,N]=t.useState("home"),[D,M]=t.useState(!1),[X,B]=t.useState({top:48,right:12}),[H,oe]=t.useState(null),[$,P]=t.useState(null),[A,E]=t.useState(""),[I,z]=t.useState({}),g=k.find(b=>b.origin===T),_=p.settings.savedPages??[];t.useEffect(()=>{var b;p.loaded&&l&&u(((b=p.settings.savedPages)==null?void 0:b.find(O=>O.id===l))??null)},[p.loaded,p.settings.savedPages,l,u]),t.useEffect(()=>{var Y;L(Ne()),y(((Y=v.current)==null?void 0:Y.closest(".web-root"))??document.body);const b=window.matchMedia("(max-width: 600px)"),O=()=>M(b.matches);return O(),b.addEventListener("change",O),()=>{b.removeEventListener("change",O)}},[]),t.useEffect(()=>{if(!w)return;const b=U=>{var V,G;!((V=C.current)!=null&&V.contains(U.target))&&!((G=v.current)!=null&&G.contains(U.target))&&x(!1)},O=U=>{var Ie,Me;if(U.key==="Escape"&&(x(!1),(Ie=v.current)==null||Ie.focus()),!D||U.key!=="Tab")return;const V=(Me=C.current)==null?void 0:Me.querySelectorAll("button:not(:disabled), input:not(:disabled)");if(!(V!=null&&V.length))return;const G=V[0],se=V[V.length-1];U.shiftKey&&document.activeElement===G?(U.preventDefault(),se.focus()):!U.shiftKey&&document.activeElement===se&&(U.preventDefault(),G.focus())},Y=()=>{var G;const U=(G=v.current)==null?void 0:G.getBoundingClientRect();if(!U)return;const V=Math.min(292,innerWidth-24);B({top:U.bottom+8,right:Math.max(12,Math.min(innerWidth-V-12,innerWidth-U.right))})};return document.addEventListener("pointerdown",b),document.addEventListener("keydown",O),window.addEventListener("resize",Y),()=>{document.removeEventListener("pointerdown",b),document.removeEventListener("keydown",O),window.removeEventListener("resize",Y)}},[w,D]),t.useEffect(()=>{var b,O;w&&((O=(b=C.current)==null?void 0:b.querySelector("button"))==null||O.focus())},[w,R]),t.useEffect(()=>{if(!w)return;const b=new AbortController,O=()=>{for(const U of k)U.origin!==T&&En(U.origin,b.signal).then(V=>{b.signal.aborted||z(G=>({...G,[U.origin]:V}))})};O();const Y=window.setInterval(O,15e3);return window.addEventListener("online",O),()=>{b.abort(),window.clearInterval(Y),window.removeEventListener("online",O)}},[w,k,T]);const K=t.useCallback(()=>{var b;oe(null),(b=v.current)==null||b.focus()},[]),ie=t.useCallback(()=>{var b;P(null),(b=v.current)==null||b.focus()},[]),F=t.useCallback(async(b,O)=>{var G;if(Fe()){await Fe().pair(b);return}const Y=Or(b),U={origin:Y.origin,name:O.trim()||((G=k.find(se=>se.origin===Y.origin))==null?void 0:G.name)||Y.hostname},V=Wr(b,qt(Re(),k,[U]),O);await c.add(U.origin,U.name),location.assign(V)},[k,c.add]),ee=t.useCallback(async b=>{await c.rename(Ne(),b),K()},[K,c.rename]);return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:In}),e.jsxs("div",{className:"theme-avatar-with-status",children:[e.jsx("button",{ref:v,type:"button",className:"theme-avatar","aria-label":`电脑与连接状态(${r})`,title:r,style:{border:`1px solid ${a}`,background:a,color:s},"aria-expanded":w,"aria-haspopup":"true",onClick:()=>{const b=v.current.getBoundingClientRect(),O=Math.min(292,innerWidth-24);B({top:b.bottom+8,right:Math.max(12,Math.min(innerWidth-O-12,innerWidth-b.right))}),w||(N("home"),E(""),p.reload(),c.reload()),x(Y=>!Y)},children:(r.trim()[0]??"?").toUpperCase()}),e.jsx("span",{className:"theme-avatar-status","data-connected":o,"aria-label":o?"已连接":"未连接"})]}),w&&m&&Te.createPortal(e.jsx("div",{className:"computer-menu-backdrop","data-toolbar-overlay":!0,children:e.jsxs("div",{ref:C,className:"computer-menu",style:D?void 0:X,role:"dialog","aria-modal":D,"aria-label":R==="tools"?"配置顶部工具":R==="computers"?"选择电脑":"电脑与保存页面",children:[e.jsx("div",{className:"computer-menu-grip","aria-hidden":"true"}),e.jsxs("div",{className:"computer-menu-heading",children:[R!=="home"&&e.jsx("button",{type:"button",className:"computer-close","aria-label":"返回电脑菜单",onClick:()=>N("home"),children:e.jsx(_r,{size:20})}),R==="home"?e.jsxs("button",{type:"button",className:"computer-menu-item computer-current","aria-label":"选择电脑",onClick:()=>N("computers"),children:[e.jsx(Kt,{size:17}),e.jsxs("span",{children:[e.jsx("strong",{children:(g==null?void 0:g.name)||"当前电脑"}),e.jsx("small",{children:o?"当前 · 在线":"当前 · 未连接"})]}),e.jsx(Fr,{size:16})]}):e.jsx("strong",{children:R==="tools"?`${(g==null?void 0:g.name)||"当前电脑"} · 顶部工具`:"选择电脑"}),e.jsx("button",{type:"button",className:"computer-close","aria-label":"关闭电脑菜单",onClick:()=>{var b;x(!1),(b=v.current)==null||b.focus()},children:e.jsx(ke,{size:20})})]}),R==="computers"&&e.jsxs(e.Fragment,{children:[!c.loaded&&e.jsx("p",{className:"computer-save-status",role:"status",children:c.error?"电脑列表尚未加载":"正在读取电脑列表…"}),k.map(b=>{const O=b.origin===T?o?"online":"offline":I[b.origin]??"checking",Y=O==="online"?"在线":O==="offline"?"无法连接":"检测中";return e.jsxs("div",{className:"computer-menu-row",children:[e.jsxs("button",{type:"button",className:"computer-menu-item","data-computer-origin":b.origin,"aria-label":`${b.name},${Y}${b.origin===T?",当前电脑":""}`,"aria-current":b.origin===T?"true":void 0,onClick:()=>{if(b.origin===T)N("home");else try{const U=Fe();U?U.switchComputer(b.origin).catch(V=>E(V.message)):location.assign($r(b.origin,qt(Re(),k)))}catch(U){E(U.message)}},children:[e.jsx(Kt,{size:17,"aria-hidden":"true"}),e.jsxs("span",{children:[e.jsx("strong",{children:b.name}),e.jsx("small",{children:b.origin})]}),e.jsx("span",{className:"computer-status-dot","data-status":O,role:"img","aria-label":Y,title:Y}),b.origin===T&&e.jsx(nt,{size:16,"aria-label":"当前电脑"})]}),b.origin!==T&&e.jsx("button",{type:"button",className:"computer-page-control computer-delete-control","aria-label":`删除电脑:${b.name}`,title:`删除电脑:${b.name}`,disabled:c.saving,onClick:()=>{c.remove(b.origin).catch(()=>{})},children:e.jsx(mt,{size:15})})]},b.origin)}),e.jsx("div",{className:"computer-menu-divider"}),e.jsxs("button",{type:"button",className:"computer-menu-item",disabled:!c.loaded||c.saving,onClick:()=>{const b=Fe();b?b.scan().catch(O=>E(O.message)):(x(!1),oe("add"))},children:[e.jsx($e,{size:17,"aria-hidden":"true"}),e.jsx("span",{children:"扫码添加电脑"})]}),e.jsxs("button",{type:"button",className:"computer-menu-item",disabled:!c.loaded||c.saving||!g,onClick:()=>{x(!1),oe("rename")},children:[e.jsx(ot,{size:16,"aria-hidden":"true"}),e.jsx("span",{children:"修改当前电脑名称"})]}),c.error&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"computer-error",role:"alert",children:c.error}),e.jsxs("button",{type:"button",className:"computer-menu-item",onClick:()=>{c.reload()},children:[e.jsx(be,{size:16}),e.jsx("span",{children:"重新加载电脑列表"})]})]})]}),R==="home"&&e.jsxs(e.Fragment,{children:[e.jsx(vn,{csrfToken:j}),e.jsxs("div",{className:"computer-menu-label computer-pages-heading",children:[e.jsx("span",{children:"保存的页面"}),e.jsx("button",{type:"button",className:"computer-page-control","aria-label":"添加页面",disabled:!p.loaded||p.saving,onClick:()=>{x(!1),P({computer:g??{origin:T,name:"当前电脑"}})},children:e.jsx($e,{size:17})})]}),e.jsxs("button",{type:"button",className:"computer-menu-item","aria-current":l?void 0:"true",onClick:()=>{x(!1),d(null)},children:[e.jsx(bn,{size:17}),e.jsx("span",{children:"电脑会话"}),!l&&e.jsx(nt,{size:16})]}),_.map(b=>e.jsxs("div",{className:"computer-menu-row",children:[e.jsxs("button",{type:"button",className:"computer-menu-item","aria-label":`打开 ${b.name}`,"aria-current":l===b.id?"true":void 0,onClick:()=>{x(!1),d(b)},children:[e.jsx(it,{size:15,"aria-hidden":"true"}),e.jsxs("span",{children:[e.jsx("strong",{children:b.name}),e.jsxs("small",{children:[b.openMode==="current"?"当前页面":"新页面"," · ",new URL(b.url).hostname]})]}),b.openMode==="new-tab"&&e.jsx(ft,{size:13,"aria-hidden":"true"})]}),e.jsx("button",{type:"button",className:"computer-page-control","aria-label":`编辑 ${b.name}`,disabled:p.saving,onClick:()=>{x(!1),P({computer:g??{origin:T,name:"当前电脑"},page:b})},children:e.jsx(ot,{size:14})}),e.jsx("button",{type:"button",className:"computer-page-control","aria-label":`删除 ${b.name}`,disabled:p.saving,onClick:()=>{p.setSavedPages(_.filter(O=>O.id!==b.id)).catch(()=>{})},children:e.jsx(ke,{size:15})})]},b.id)),e.jsx("div",{className:"computer-menu-divider"}),e.jsxs("button",{type:"button",className:"computer-menu-item",onClick:()=>N("tools"),children:[e.jsx(en,{size:17}),e.jsx("span",{children:"配置顶部工具"}),e.jsx(sn,{size:16})]})]}),R==="tools"&&e.jsx("div",{className:"computer-tools-list",children:Nn.map(({id:b,name:O,Icon:Y})=>e.jsxs("label",{className:"computer-tool-option",children:[e.jsx(Y,{size:17,"aria-hidden":"true"}),e.jsx("span",{children:O}),e.jsx("input",{type:"checkbox","aria-label":`显示${O}`,checked:p.settings.visibleTools.includes(b),disabled:!p.loaded||p.saving,onChange:U=>{const V=p.settings.visibleTools;p.setVisibleTools(U.target.checked?[...V,b]:V.filter(G=>G!==b)).catch(()=>{})}})]},b))}),R!=="computers"&&e.jsx("p",{className:"computer-save-status",role:"status",children:p.loaded?p.saving?"正在保存…":p.notice:p.error?"配置尚未加载":"正在读取电脑配置…"}),p.error&&R!=="computers"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"computer-error",role:"alert",children:p.error}),e.jsxs("button",{type:"button",className:"computer-menu-item",onClick:()=>{p.reload()},children:[e.jsx(be,{size:16}),e.jsx("span",{children:"重新加载配置"})]})]}),A&&e.jsx("p",{className:"computer-error",role:"alert",children:A})]})}),m),H&&m&&Te.createPortal(e.jsx(Ln,{mode:H,currentName:(g==null?void 0:g.name)||"",onClose:K,onNavigate:F,onRename:ee}),m),$&&m&&Te.createPortal(e.jsx(jn,{computerName:$.computer.name,page:$.page,onClose:ie,onSave:async b=>{if($.page&&!_.some(O=>O.id===b.id))throw new Error("这个页面已在其他设备删除,请重新添加。");await p.setSavedPages($.page?_.map(O=>O.id===b.id?b:O):[..._,b]),ie()}}),m)]})}function Ln({mode:r,currentName:o,onClose:a,onNavigate:s,onRename:l}){const[d,u]=t.useState(r==="rename"?o:""),p=t.useRef(d);p.current=d;const[j,v]=t.useState(""),[C,c]=t.useState(""),[k,T]=t.useState(!1),[L,m]=t.useState(!1),[y,w]=t.useState(!1),[x,R]=t.useState(!1),N=t.useRef(null),D=t.useRef(null),M=t.useRef(0),X=t.useRef(null),B=t.useRef(null),H=t.useRef(null),oe=t.useCallback(async $=>{var P;T(!0),(P=H.current)==null||P.stop(),m(!1),c("");try{await s($,p.current)}catch(A){c(A.message)}finally{T(!1)}},[s]);return t.useEffect(()=>{var A,E,I;w(st()),r==="rename"?(A=X.current)==null||A.focus():(I=(E=B.current)==null?void 0:E.querySelector("button"))==null||I.focus();const $=z=>{var ie;if(z.key==="Escape"&&a(),z.key!=="Tab")return;const g=(ie=B.current)==null?void 0:ie.querySelectorAll("button:not(:disabled), input:not(:disabled)");if(!(g!=null&&g.length))return;const _=g[0],K=g[g.length-1];z.shiftKey&&document.activeElement===_?(z.preventDefault(),K.focus()):!z.shiftKey&&document.activeElement===K&&(z.preventDefault(),_.focus())},P=()=>{document.hidden&&m(!1)};return document.addEventListener("keydown",$),document.addEventListener("visibilitychange",P),r==="add"&&N.current&&(H.current=Rn(N.current,oe,z=>{m(!1),c(z)})),()=>{var z;M.current++,document.removeEventListener("keydown",$),document.removeEventListener("visibilitychange",P),(z=H.current)==null||z.dispose(),H.current=null}},[r,oe,a]),e.jsx("div",{className:"computer-dialog-backdrop","data-toolbar-overlay":!0,onClick:$=>{$.target===$.currentTarget&&a()},children:e.jsxs("section",{ref:B,className:"computer-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"computer-dialog-title",children:[e.jsxs("div",{className:"computer-dialog-heading",children:[e.jsx("h2",{id:"computer-dialog-title",children:r==="add"?"添加电脑":"修改电脑名称"}),e.jsx("button",{type:"button",className:"computer-close","aria-label":"关闭",onClick:a,children:e.jsx(ke,{size:20})})]}),e.jsxs("form",{onSubmit:async $=>{if($.preventDefault(),!k)if(r==="add")await oe(j);else{T(!0);try{await l(d.trim())}catch(P){c(P.message)}finally{T(!1)}}},children:[e.jsxs("label",{htmlFor:"computer-name",children:["电脑名称",r==="add"?"(选填)":""]}),e.jsx("input",{ref:X,id:"computer-name",maxLength:60,value:d,required:r==="rename",disabled:k,onChange:$=>u($.target.value),placeholder:"例如:A 电脑 / 家里的电脑",autoComplete:"off"}),r==="add"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"computer-hint",children:"扫描另一台电脑上的 AgentRoam 授权二维码,连接后会保留已有电脑。"}),e.jsx("input",{ref:D,type:"file",accept:"image/*",capture:"environment",hidden:!0,"aria-label":"拍摄授权二维码",onChange:async $=>{var E,I;const P=(E=$.currentTarget.files)==null?void 0:E[0];if($.currentTarget.value="",!P)return;const A=++M.current;(I=H.current)==null||I.stop(),m(!1),R(!0),c("");try{const z=await Tn(P);A===M.current&&oe(z)}catch(z){A===M.current&&c(z.message)}finally{A===M.current&&R(!1)}}}),e.jsx("video",{ref:N,playsInline:!0,muted:!0,hidden:!L,"aria-label":"扫码相机画面"}),e.jsxs("button",{className:"computer-action",type:"button",disabled:x,onClick:()=>{var $,P,A;c(""),L?(($=H.current)==null||$.stop(),m(!1)):st()?(m(!0),(A=H.current)==null||A.start()):(P=D.current)==null||P.click()},children:[e.jsx(Ur,{size:17,"aria-hidden":"true"}),x?"正在识别二维码…":L?"取消扫码":y?"打开相机扫码":"拍照扫码"]}),y&&e.jsx("button",{className:"computer-action",type:"button",disabled:x,onClick:()=>{var $,P;($=H.current)==null||$.stop(),m(!1),(P=D.current)==null||P.click()},children:"拍照识别二维码"}),e.jsx("label",{htmlFor:"computer-link",children:"或粘贴授权二维码链接"}),e.jsx("input",{id:"computer-link",value:j,onChange:$=>v($.target.value),placeholder:"http(s)://…/pair#pair=…",autoComplete:"off",spellCheck:!1})]}),C&&e.jsx("p",{className:"computer-error",role:"alert",children:C}),e.jsx("button",{className:"computer-action computer-primary",type:"submit",disabled:k||(r==="add"?!j.trim()||x:!d.trim()),children:r==="add"?"连接这台电脑":k?"正在保存…":"保存名称"})]})]})})}const In=`
|
|
32
32
|
.computer-menu-backdrop{position:fixed;inset:0;z-index:10000}
|
|
33
33
|
.computer-menu-heading{display:flex;align-items:center;gap:4px;padding:2px 4px}.computer-menu-heading>strong{flex:1;min-width:0;font-size:14px;font-weight:500;overflow-wrap:anywhere}.computer-menu-heading>.computer-current{flex:1;min-width:0}.computer-menu-heading>.computer-close{flex-shrink:0}
|
|
34
34
|
.computer-menu-grip{display:none}.computer-pages-heading{display:flex;align-items:center;justify-content:space-between}.computer-tool-option{display:flex;align-items:center;gap:12px;min-height:44px;padding:8px 12px;cursor:pointer}.computer-tool-option span{flex:1;font-size:14px}.computer-tool-option input{width:18px;height:18px;accent-color:var(--ui-tab-accent,#7aa2f7)}.computer-tool-option svg{flex-shrink:0}.computer-save-status{margin:6px 10px 2px;line-height:18px;color:var(--ui-muted-text,#999dab);font-size:12px}.computer-save-status:empty{display:none}.computer-menu button:disabled,.computer-tool-option:has(input:disabled){opacity:.55;cursor:default}
|
|
@@ -84,7 +84,7 @@ import{c as dt,r as t,j as e,P as $e,f as Te,R as be,m as Ar,n as zr,o as Re,s a
|
|
|
84
84
|
@keyframes flow-appear { from { opacity:0; } to { opacity:1; } }
|
|
85
85
|
@media (max-height:420px) { .flow-loading { gap:12px; } .flow-loader-art { width:200px; height:200px; zoom:.65; } }
|
|
86
86
|
@media (prefers-reduced-motion:reduce) { .flow-loading, .flow-loader-halo, .flow-loader-orbit, .flow-loader-core, .flow-loader-node, .flow-loader-track span { animation:none; } }
|
|
87
|
-
`})]})}function Mn(r){const o=new URL(r).hostname;return o==="qoder.com"||o.endsWith(".qoder.com")}function An({page:r,reloadKey:o}){const[a,s]=t.useState(!0),[l,d]=t.useState(!1);return t.useEffect(()=>{s(!0),d(!1);const u=window.setTimeout(()=>d(!0),12e3);return()=>window.clearTimeout(u)},[r.id,r.url,o]),Mn(r.url)?e.jsxs("main",{className:"computer-page-blocked",children:[e.jsx(it,{size:36,strokeWidth:1.5,"aria-hidden":"true"}),e.jsxs("h2",{children:[r.name," 不允许内嵌"]}),e.jsx("p",{children:"这个网站限制了当前页面打开。可以在新页面使用,也可以在电脑菜单中修改打开方式。"}),e.jsxs("a",{href:r.url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(ft,{size:16,"aria-hidden":"true"}),"打开新页面"]})]}):e.jsxs("main",{className:"computer-page-pane","aria-label":r.name,"aria-busy":a,children:[e.jsx("iframe",{title:r.name,src:r.url,referrerPolicy:"no-referrer",allow:"clipboard-read; clipboard-write; microphone; camera",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-downloads allow-modals",onLoad:()=>s(!1),onError:()=>{s(!1),d(!0)},style:{visibility:a?"hidden":"visible"}},`${r.id}:${o}`),a&&e.jsx(Be,{label:"REMOTE PAGE",title:`正在打开 ${r.name}`,caption:"正在连接页面",icon:e.jsx(it,{size:36,strokeWidth:1.5})}),l&&e.jsx("a",{className:"computer-page-fallback",href:r.url,target:"_blank",rel:"noopener noreferrer",children:"打开原页面"})]})}const Ze=["refresh","collaboration","remote","theme","files","ai-hub","flow","install"],zn=["refresh","remote","theme","files"];function Dn(r){return{userId:r,revision:0,visibleTools:[...zn],savedPages:null,updatedAt:""}}function fr(r){if(!Array.isArray(r)||r.length>Ze.length||r.some(o=>!Ze.includes(o)))throw new Error("顶部工具包含未知选项。");if(new Set(r).size!==r.length)throw new Error("顶部工具不能重复。");return Ze.filter(o=>r.includes(o))}function hr(r){if(!Array.isArray(r)||r.length>20)throw new Error("每台电脑最多可添加 20 个页面。");const o=new Set;return r.map(a=>{if(!a||typeof a.id!="string"||!/^[A-Za-z0-9_-]{1,80}$/.test(a.id)||o.has(a.id))throw new Error("页面标识无效或重复。");if(typeof a.name!="string"||!a.name.trim()||a.name.trim().length>60)throw new Error("页面名称需为 1–60 个字符。");if(!["current","new-tab"].includes(a.openMode))throw new Error("页面打开方式无效。");if(typeof a.url!="string"||a.url.length>8192)throw new Error("请填写有效的 http(s) 页面地址。");let s;try{s=new URL(a.url.trim())}catch{throw new Error("请填写有效的 http(s) 页面地址。")}if(!["http:","https:"].includes(s.protocol)||s.username||s.password)throw new Error("请填写无账号密码的 http(s) 页面地址。");return o.add(a.id),{id:a.id,name:a.name.trim(),url:s.href,openMode:a.openMode}})}class ct extends Error{constructor(o,a){super(o),this.status=a}}async function Ce(r,o){var l;const a=await fetch("/api/web-console/computer-settings",{method:o?"PATCH":"GET",credentials:"same-origin",cache:"no-store",headers:o?{"content-type":"application/json","x-csrf-token":r}:void 0,body:o?JSON.stringify(o):void 0,signal:AbortSignal.timeout(15e3)}).catch(d=>{throw new Error((d==null?void 0:d.name)==="TimeoutError"?"电脑响应超时,请检查连接后重试。":"无法连接当前电脑,请检查连接后重试。")}),s=await a.json().catch(()=>null);if(!a.ok)throw new ct(((l=s==null?void 0:s.error)==null?void 0:l.message)??"电脑配置保存失败,请检查连接后重试。",a.status);if(!(s!=null&&s.settings)||!Number.isSafeInteger(s.settings.revision))throw new Error("无法读取电脑配置,请重新加载。");return{...s.settings,visibleTools:fr(s.settings.visibleTools),savedPages:s.settings.savedPages===null?null:hr(s.settings.savedPages)}}function On(r){const[o,a]=t.useState(()=>Dn("")),s=t.useRef(o),[l,d]=t.useState(!1),[u,p]=t.useState(!1),j=t.useRef(!1),v=t.useRef(!0),C=t.useRef(0),[c,k]=t.useState(""),[T,L]=t.useState(""),m=t.useCallback(x=>{s.current=x,v.current&&a(x)},[]),y=t.useCallback(async()=>{var R;if(j.current)return;const x=++C.current;k(""),L("");try{let N=await Ce(r);if(N.savedPages===null){const D=((R=Re().find(M=>M.origin===location.origin))==null?void 0:R.pages)??[];try{N=await Ce(r,{expectedRevision:N.revision,initializePages:D})}catch(M){if(!(M instanceof ct)||M.status!==409)throw M;if(N=await Ce(r),N.savedPages===null)throw new Error("电脑配置已更新,请重试旧页面导入。")}}if(!v.current||x!==C.current)return;m(N),d(!0);try{cr(Re().map(D=>{if(D.origin!==location.origin)return D;const{pages:M,...X}=D;return{...X,pagesMigrated:!0}}))}catch{}}catch(N){v.current&&x===C.current&&k(N instanceof Error?N.message:"无法读取电脑配置。")}},[m,r]);t.useEffect(()=>{v.current=!0,y();const x=()=>{y()};return window.addEventListener("focus",x),()=>{v.current=!1,C.current++,window.removeEventListener("focus",x)}},[y]);const w=t.useCallback(async x=>{if(!l||j.current)throw new Error("配置尚未就绪,请稍后重试。");j.current=!0,C.current++,p(!0),k(""),L("");const R=s.current;x.visibleTools&&m({...R,visibleTools:x.visibleTools});try{m(await Ce(r,{...x,expectedRevision:R.revision})),v.current&&L("已保存到当前电脑")}catch(N){if(m(R),N instanceof ct&&N.status===409)try{m(await Ce(r))}catch{}const D=N instanceof Error?N.message:"电脑配置保存失败,请重试。";throw v.current&&k(D),new Error(D)}finally{j.current=!1,v.current&&p(!1)}},[m,r,l]);return{settings:o,loaded:l,saving:u,error:c,notice:T,reload:y,setVisibleTools:x=>w({visibleTools:fr(x)}),setSavedPages:x=>w({savedPages:hr(x)})}}const Wn=["codex","claude agents","opencode","agent-tui"];function _n(){return Wn.map((r,o)=>({id:`default-${o+1}`,command:r}))}async function Fn(r,o,a,s){const l=a.find(u=>u&&u===r.source);if(!l)return!1;const d=Br(r,o,l);if(!d)return!1;try{const u=await s(d.method,d.payload);l.postMessage({type:Ht,id:d.id,ok:!0,result:u},o)}catch(u){const p=u;l.postMessage({type:Ht,id:d.id,ok:!1,error:p.message||"项目操作失败",code:p.code},o)}return!0}const $n=1,lt={watcherFrame:4,producerFrame:5},Qt=10;function Un(r){const o=r instanceof Uint8Array?r:new Uint8Array(r.buffer,r.byteOffset,r.byteLength);if(o.byteLength<Qt||o[0]!==$n||o[1]!==lt.watcherFrame&&o[1]!==lt.producerFrame)return null;const a=new DataView(o.buffer,o.byteOffset,o.byteLength);return{type:o[1],channelId:a.getUint32(2,!1),sequence:a.getUint32(6,!1),payload:o.subarray(Qt)}}function Bn(){return Hr()}function qn(r,o,a){const[s,l]=t.useState({connected:!1,error:null}),[d,u]=t.useState(0),p=t.useRef(null),j=t.useRef(0),v=t.useRef(new Map),C=t.useRef([]),c=t.useRef(0),k=t.useRef(new Map),T=t.useRef(new Map),L=t.useRef(new Map),m=t.useRef(1e3),y=t.useRef(!1),w=t.useRef(null),x=t.useRef(r),R=t.useRef(o),N=t.useRef(a);x.current=r,R.current=o,N.current=a;const D=t.useCallback((P,A)=>{let E=k.current.get(P);return E||k.current.set(P,E=new Set),E.add(A),()=>E.delete(A)},[]),M=t.useCallback((P,A)=>{let E=T.current.get(P);return E||T.current.set(P,E=new Set),E.add(A),()=>E.delete(A)},[]),X=t.useCallback((P,A)=>{let E=L.current.get(P);return E||L.current.set(P,E=new Set),E.add(A),()=>E.delete(A)},[]),B=t.useCallback((P,A)=>{const E=p.current;if(!E||E.readyState!==WebSocket.OPEN)return!1;const I=new TextEncoder().encode(A),z=new Uint8Array(6+I.byteLength),g=new DataView(z.buffer);return z[0]=1,z[1]=1,g.setUint32(2,P),z.set(I,6),E.send(z),!0},[]),H=t.useCallback(P=>{const A=p.current;(A==null?void 0:A.readyState)===WebSocket.OPEN?A.send(P):C.current.push(P)},[]),ne=t.useCallback((P,A={},E=15e3)=>new Promise((I,z)=>{var K;if(P.startsWith("browser:")&&((K=p.current)==null?void 0:K.readyState)!==WebSocket.OPEN){z(Object.assign(new Error("远程连接已断开,请等待重新连接"),{code:"EOFFLINE"}));return}const g=++c.current,_=setTimeout(()=>{v.current.delete(g),z(new Error(`${P} timeout`))},E);v.current.set(g,{resolve:I,reject:z,timer:_,type:P}),H(JSON.stringify({type:P,_req:g,...A}))}),[H]),$=t.useCallback(async()=>{y.current=!1;const P=++j.current;w.current&&(clearInterval(w.current),w.current=null);const A=p.current;if(A){A.onopen=A.onmessage=A.onerror=A.onclose=null;try{A.close()}catch{}}let E;try{E=await R.current()}catch{P===j.current&&N.current();return}if(P!==j.current||y.current)return;let I;try{I=new WebSocket(`${Bn()}?nonce=${encodeURIComponent(E)}`)}catch(z){l({connected:!1,error:String(z)});return}I.binaryType="arraybuffer",p.current=I,I.onopen=()=>{if(P!==j.current||p.current!==I)return;m.current=1e3,l({connected:!0,error:null}),u(K=>K+1);const z=C.current.splice(0);for(const K of z)I.send(K);let g=Date.now();w.current=setInterval(()=>{if(p.current!==I||I.readyState!==WebSocket.OPEN){clearInterval(w.current),w.current=null;return}if(Date.now()-g>25e3){try{I.close()}catch{}return}try{I.send(JSON.stringify({type:"ping"}))}catch{}},1e4);const _=()=>{g=Date.now()};I.addEventListener("message",_),I.addEventListener("close",()=>I.removeEventListener("message",_),{once:!0})},I.onmessage=z=>{var _,K,ie;if(P!==j.current||p.current!==I)return;if(typeof z.data!="string"){const F=new Uint8Array(z.data);if(F.byteLength>=6&&F[0]===1&&(F[1]===2||F[1]===6)){const ee=new DataView(F.buffer,F.byteOffset,F.byteLength).getUint32(2);(_=T.current.get(ee))==null||_.forEach(b=>b(F.subarray(6),F[1]===6))}else if(F.byteLength>=6&&F[0]===1&&F[1]===3){const ee=new DataView(F.buffer,F.byteOffset,F.byteLength).getUint32(2);(K=L.current.get(ee))==null||K.forEach(b=>b())}else x.current(F);return}let g;try{g=JSON.parse(z.data)}catch{return}if(g.type==="error"&&g.id!=null){const F=v.current.get(g.id);if(F){v.current.delete(g.id),clearTimeout(F.timer);const ee=Object.assign(new Error(g.error||"gateway error"),{code:g.code});F.reject(ee)}return}if(g.id!=null&&typeof g.type=="string"&&g.type.endsWith(":result")){const F=v.current.get(g.id);(F==null?void 0:F.type)==="fs:preview-open"&&typeof g.url=="string"&&(g.url=qr(g.url)),F&&(v.current.delete(g.id),clearTimeout(F.timer),F.resolve(g));return}(ie=k.current.get(g.type))==null||ie.forEach(F=>F(g))},I.onclose=z=>{if(P!==j.current||p.current!==I)return;w.current&&(clearInterval(w.current),w.current=null),p.current=null;for(const[_,K]of v.current)K.type.startsWith("browser:")&&(clearTimeout(K.timer),v.current.delete(_),K.reject(Object.assign(new Error("远程连接已断开,请重新接管"),{code:"EOFFLINE"})));if(l({connected:!1,error:null}),z.code===4001||z.code===4003){N.current();return}if(y.current)return;const g=m.current;m.current=Math.min(g*2,8e3),setTimeout(()=>{!y.current&&P===j.current&&$()},g)},I.onerror=()=>{}},[]);return t.useEffect(()=>($(),()=>{y.current=!0,j.current++,w.current&&(clearInterval(w.current),w.current=null);const P=p.current;if(p.current=null,P){P.onopen=P.onmessage=P.onerror=P.onclose=null;try{P.close()}catch{}}}),[$]),{state:s,epoch:d,rpc:ne,onEvent:D,onTerminalData:M,onTerminalReset:X,sendTerminalInput:B,reconnect:$}}function Hn(){const[r,o]=t.useState("loading"),[a,s]=t.useState(null),[l]=t.useState("same-origin"),[d,u]=t.useState(null),p=t.useCallback(async()=>{o("loading"),u(null);try{const c=await fetch("/api/web-console/bootstrap",{credentials:"same-origin",cache:"no-store"});if(c.status===401||c.status===423){window.location.reload();return}if(!c.ok)throw new Error(`HTTP ${c.status}`);const k=await c.json();s(k.user),o("authenticated")}catch{u("无法连接远程控制台"),o("needsLogin")}},[]);t.useEffect(()=>{p()},[p]);const j=t.useCallback(async()=>{const c=await fetch("/api/web-console/bootstrap",{credentials:"same-origin",cache:"no-store"});if((c.status===401||c.status===423)&&window.location.reload(),!c.ok)throw new Error("bootstrap failed");const k=await c.json();return s(k.user),o("authenticated"),k.wsNonce},[]),v=t.useCallback(async()=>(window.location.reload(),!1),[]),C=t.useCallback(async()=>{const c=await fetch("/api/pairing/logout",{method:"POST",credentials:"same-origin"});c.ok||c.status===401||c.status===423?window.location.reload():u("退出失败,请重试")},[]);return{status:r,user:a,error:d,csrfToken:l,setup:v,login:v,logout:C,refresh:p,getWsNonce:j}}function Vn({children:r}){const o=Hn(),[a,s]=t.useState(!1),l=o.status==="authenticated",d=t.useCallback(()=>s(!0),[]);return t.useEffect(()=>{l||s(!1)},[l]),e.jsxs(e.Fragment,{children:[l?r(o,d):null,e.jsx(Vr,{ready:l&&a,error:o.error,onRetry:()=>void o.refresh()})]})}function Zt(r,o,a){const s=r.findIndex(p=>p.id===o),l=r.findIndex(p=>p.id===a);if(s<0||l<0||s===l)return[...r];const d=[...r],[u]=d.splice(s,1);return d.splice(l,0,u),d}function Kn(){return typeof crypto.randomUUID=="function"?crypto.randomUUID():Array.from(crypto.getRandomValues(new Uint8Array(16)),r=>r.toString(16).padStart(2,"0")).join("")}function gr(r,o=Kn()){return{id:o,command:r.trim()}}function Gn({commands:r,onChange:o,onExecute:a}){const[s,l]=t.useState(null),[d,u]=t.useState(""),[p,j]=t.useState(null),v=t.useRef(null),C=()=>{if(!s)return;const m=s.value.trim();if(!m)return u("命令不能为空");if(m.length>1e3)return u("命令最多 1000 个字符");if(/[\r\n\0]/.test(m))return u("命令只能包含一行");s.id?o(r.map(y=>y.id===s.id?{...y,command:m}:y)):o([...r,gr(m)]),l(null),u("")},c=(m,y)=>{m.preventDefault(),m.stopPropagation(),v.current=y,j(y),m.currentTarget.setPointerCapture(m.pointerId)},k=m=>{var x;if(!v.current)return;const y=(x=document.elementFromPoint(m.clientX,m.clientY))==null?void 0:x.closest("[data-pinned-id]"),w=y==null?void 0:y.dataset.pinnedId;w&&w!==v.current&&o(Zt(r,v.current,w))},T=m=>{m.currentTarget.hasPointerCapture(m.pointerId)&&m.currentTarget.releasePointerCapture(m.pointerId),v.current=null,j(null)},L=(m,y)=>{if(m.key!=="ArrowUp"&&m.key!=="ArrowDown")return;m.preventDefault();const w=r.findIndex(R=>R.id===y),x=r[w+(m.key==="ArrowUp"?-1:1)];x&&o(Zt(r,y,x.id))};return e.jsxs("section",{className:"pinned-commands","aria-labelledby":"pinned-command-title",children:[e.jsxs("div",{className:"pinned-command-head",children:[e.jsx("span",{id:"pinned-command-title",children:"置顶命令"}),e.jsx("button",{className:"history-icon-button",onClick:()=>{l({id:null,value:""}),u("")},"aria-label":"新增置顶命令",title:"新增置顶命令",children:e.jsx($e,{size:14,"aria-hidden":"true"})})]}),r.map(m=>(s==null?void 0:s.id)===m.id?e.jsx(er,{editor:s,error:d,onChange:y=>{l({...s,value:y}),u("")},onSave:C,onCancel:()=>{l(null),u("")}},m.id):e.jsxs("div",{className:`pinned-command-row${p===m.id?" pinned-command-dragging":""}`,"data-pinned-id":m.id,role:"button",tabIndex:0,onClick:()=>a(m.command),onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),a(m.command))},children:[e.jsx("button",{className:"pinned-command-grip",onPointerDown:y=>c(y,m.id),onPointerMove:k,onPointerUp:T,onPointerCancel:T,onKeyDown:y=>L(y,m.id),onClick:y=>y.stopPropagation(),"aria-label":`调整 ${m.command} 的顺序`,title:"拖动排序,或按上下方向键",children:e.jsx(tn,{size:14,"aria-hidden":"true"})}),e.jsx("code",{children:m.command}),e.jsxs("div",{className:"pinned-command-actions",onClick:y=>y.stopPropagation(),children:[e.jsx("button",{className:"history-icon-button",onClick:()=>{l({id:m.id,value:m.command}),u("")},"aria-label":`编辑 ${m.command}`,title:"编辑",children:e.jsx(ot,{size:12,"aria-hidden":"true"})}),e.jsx("button",{className:"history-icon-button history-icon-danger",onClick:()=>o(r.filter(y=>y.id!==m.id)),"aria-label":`删除 ${m.command}`,title:"删除",children:e.jsx(mt,{size:12,"aria-hidden":"true"})})]})]},m.id)),(s==null?void 0:s.id)===null&&e.jsx(er,{editor:s,error:d,onChange:m=>{l({...s,value:m}),u("")},onSave:C,onCancel:()=>{l(null),u("")}})]})}function er({editor:r,error:o,onChange:a,onSave:s,onCancel:l}){return e.jsxs("div",{className:"pinned-command-editor",children:[e.jsx("input",{autoFocus:!0,value:r.value,maxLength:1e3,onChange:d=>a(d.target.value),onKeyDown:d=>{d.key==="Enter"&&s(),d.key==="Escape"&&l()},"aria-label":r.id?"编辑置顶命令":"新增置顶命令"}),e.jsx("button",{className:"history-icon-button",onClick:s,"aria-label":"保存命令",title:"保存",children:e.jsx(nt,{size:13,"aria-hidden":"true"})}),e.jsx("button",{className:"history-icon-button",onClick:l,"aria-label":"取消编辑",title:"取消",children:e.jsx(ke,{size:13,"aria-hidden":"true"})}),o&&e.jsx("small",{role:"alert",children:o})]})}function Yn({csrfToken:r,terminalId:o,pinnedCommands:a,onPinnedCommandsChange:s,onFill:l,onExecute:d}){const[u,p]=t.useState([]),[j,v]=t.useState(""),[C,c]=t.useState(""),k=t.useCallback(async()=>{const w=new URLSearchParams({q:j,limit:"200"}),x=await fetch(`/api/web-console/history?${w}`,{credentials:"same-origin"});x.ok&&p((await x.json()).history)},[j]);t.useEffect(()=>{const w=setTimeout(k,200);return()=>clearTimeout(w)},[k]);const T=async w=>{await fetch("/api/web-console/history",{method:"DELETE",credentials:"same-origin",headers:{"content-type":"application/json","x-csrf-token":r},body:JSON.stringify({id:w})}),k()},L=w=>{o&&l(w)},m=t.useCallback(w=>{w==="[REDACTED]"||a.some(x=>x.command===w)||s([...a,gr(w)])},[s,a]),y=async w=>{const x=await ln(w);c(x?"已复制命令":"复制失败,请长按命令手动复制")};return e.jsxs("div",{className:"history-panel",children:[e.jsx(Gn,{commands:a,onChange:s,onExecute:d}),e.jsxs("div",{className:"history-search",children:[e.jsx("input",{value:j,onChange:w=>v(w.target.value),placeholder:"搜索命令"}),e.jsx("button",{className:"history-icon-button",onClick:k,"aria-label":"刷新历史",title:"刷新历史",children:e.jsx(be,{size:13,"aria-hidden":"true"})})]}),C&&e.jsx("div",{className:"terminal-clipboard-notice",role:"status",children:C}),u.map(w=>e.jsxs("div",{className:`history-item${o?"":" history-item-disabled"}`,role:"button",tabIndex:o?0:-1,onClick:()=>L(w.command),onKeyDown:x=>{x.target===x.currentTarget&&(x.key==="Enter"||x.key===" ")&&o&&(x.preventDefault(),L(w.command))},children:[e.jsx("code",{children:w.command}),e.jsxs("small",{children:[w.cwd," · ",new Date(w.executedAt).toLocaleString()]}),e.jsxs("div",{className:"history-item-actions",onClick:x=>x.stopPropagation(),onPointerDown:x=>x.stopPropagation(),children:[e.jsx("button",{className:"history-icon-button",onClick:()=>void y(w.command),"aria-label":"复制命令",title:"复制",children:e.jsx(rn,{size:12,"aria-hidden":"true"})}),e.jsx("button",{className:"history-icon-button",disabled:!o,onClick:()=>L(w.command),"aria-label":"填入命令",title:"填入",children:e.jsx(wn,{size:12,"aria-hidden":"true"})}),e.jsx("button",{className:"history-icon-button",disabled:w.command==="[REDACTED]"||a.some(x=>x.command===w.command),onClick:()=>m(w.command),"aria-label":"置顶命令",title:"置顶",children:e.jsx(nn,{size:12,"aria-hidden":"true"})}),e.jsx("button",{className:"history-icon-button history-icon-danger",onClick:()=>T(w.id),"aria-label":"删除历史",title:"删除",children:e.jsx(mt,{size:12,"aria-hidden":"true"})})]})]},w.id)),!u.length&&e.jsx("div",{className:"history-empty",children:"暂无 Shell 命令历史"}),!o&&!!u.length&&e.jsx("div",{className:"history-empty",children:"请先打开一个终端页签"})]})}function Jn({themeId:r,onThemeChange:o}){const[a,s]=t.useState(!1),l=t.useRef(null),d=t.useRef(null),u=t.useRef(null),[p,j]=t.useState(null),[v,C]=t.useState({top:-1e3,left:0});return t.useEffect(()=>{var c;j(((c=l.current)==null?void 0:c.closest(".web-root"))??document.body)},[]),t.useLayoutEffect(()=>{if(!a)return;const c=()=>{var L;const k=(L=d.current)==null?void 0:L.getBoundingClientRect();if(!k)return;const T=Math.min(176,innerWidth-16);C({top:k.bottom+6,left:Math.max(8,Math.min(innerWidth-T-8,k.right-T))})};return c(),window.addEventListener("resize",c),window.addEventListener("scroll",c,!0),()=>{window.removeEventListener("resize",c),window.removeEventListener("scroll",c,!0)}},[a]),t.useEffect(()=>{if(!a)return;const c=T=>{var L,m;!((L=l.current)!=null&&L.contains(T.target))&&!((m=u.current)!=null&&m.contains(T.target))&&s(!1)},k=T=>{var L;T.key==="Escape"&&(s(!1),(L=d.current)==null||L.focus())};return document.addEventListener("pointerdown",c),document.addEventListener("keydown",k),()=>{document.removeEventListener("pointerdown",c),document.removeEventListener("keydown",k)}},[a]),e.jsxs("div",{ref:l,className:"theme-picker",children:[e.jsx("button",{ref:d,type:"button",className:"file-drawer-toggle","aria-label":"换肤",title:"换肤","aria-expanded":a,"aria-haspopup":"dialog",onClick:()=>s(c=>!c),children:e.jsx(lr,{size:17,"aria-hidden":"true"})}),a&&p&&Te.createPortal(e.jsxs("div",{ref:u,className:"theme-popover",role:"dialog","aria-label":"选择皮肤","data-toolbar-overlay":!0,style:{position:"fixed",...v,zIndex:210,width:Math.min(176,innerWidth-16),boxSizing:"border-box",padding:8,borderRadius:10,border:"1px solid var(--ui-tabbar-border, #282b36)",background:"var(--ui-tab-active-bg, #262b38)",boxShadow:"0 10px 28px rgba(0,0,0,.45)"},children:[e.jsx("div",{style:{fontSize:10,color:"var(--ui-connection-text, #777b8c)",margin:"2px 4px 6px",letterSpacing:.5},children:"皮肤"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:2},children:Kr.map(c=>{const k=c.id===r;return e.jsxs("button",{type:"button",className:"theme-popover-item","aria-label":c.label,"aria-pressed":k,onPointerDown:T=>T.stopPropagation(),onClick:()=>{o(c.id),s(!1)},style:{background:k?"color-mix(in srgb, var(--ui-tab-accent, #7aa2f7) 14%, transparent)":"transparent"},children:[e.jsx("span",{style:{width:18,height:18,borderRadius:5,flexShrink:0,background:`linear-gradient(135deg, ${c.preview[0]} 55%, ${c.preview[1]} 55%)`,boxShadow:"inset 0 0 0 1px rgba(128,128,160,.25)"}}),e.jsx("span",{style:{flex:1,textAlign:"left",fontSize:12,fontWeight:k?600:400,color:k?"var(--ui-tab-active-text, #edf0f7)":"var(--ui-tab-text, #8f93a4)"},children:c.label}),k&&e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--ui-tab-accent, #7aa2f7)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"m5 12 4 4L19 6"})})]},c.id)})})]}),p)]})}function Xn(r,o){return{height:Math.round((r==null?void 0:r.height)??o.height),width:Math.round((r==null?void 0:r.width)??o.width),top:Math.round((r==null?void 0:r.offsetTop)??0),left:Math.round((r==null?void 0:r.offsetLeft)??0)}}function Qn(r){r&&(r.scrollLeft=0)}const Zn="agent-webapp:tab-swipe:v1";function eo(r){if(!r||typeof r!="object")return null;const o=r;return o.type!==Zn||o.phase!=="move"&&o.phase!=="end"&&o.phase!=="cancel"||typeof o.deltaX!="number"||!Number.isFinite(o.deltaX)?null:o}function to(r,o,a){return r.origin!==o||r.source!==a?null:eo(r.data)}const tr="agent-webapp:ready:v1";function ro(r){return!r||typeof r!="object"||r.type!==tr?null:{type:tr}}function rr(r,o,a){return r.origin!==o||r.source!==a?null:ro(r.data)}function nr({groupId:r,title:o,onFrame:a,onLoad:s}){const l=t.useRef(null),[d,u]=t.useState("loading"),[p,j]=t.useState(0),v=r===void 0;return t.useEffect(()=>{const C=c=>{var k;dn(c,window.location.origin,((k=l.current)==null?void 0:k.contentWindow)??null,r??null)&&u("ready")};return window.addEventListener("message",C),()=>window.removeEventListener("message",C)},[r]),t.useEffect(()=>{if(d!=="loading")return;const C=window.setTimeout(()=>u(c=>c==="loading"?"error":c),3e4);return()=>window.clearTimeout(C)},[d,p]),e.jsxs("div",{className:"collaboration-pane","aria-busy":d==="loading",children:[e.jsx("iframe",{ref:C=>{l.current=C,a(C)},className:`webapp-frame collaboration-frame${d==="ready"?" is-ready":""}`,style:{visibility:d==="ready"?"visible":"hidden"},src:tt(v?"/app/?view=collaboration-dashboard":`/app/?view=collaboration&groupId=${encodeURIComponent(r)}`),title:o,onLoad:s,onError:()=>u("error")},p),d==="loading"&&e.jsx(Be,{label:"AGENT COLLABORATION",title:v?"正在打开群聊看板":"正在进入群聊",caption:v?"正在加载已保存的群聊":"正在加载群成员与聊天记录",icon:e.jsx(ut,{size:36,strokeWidth:1.5})}),d==="error"&&e.jsxs("div",{className:"collaboration-load-error",role:"alert",children:[e.jsx("strong",{children:v?"暂时无法打开群聊看板":"暂时无法打开群聊"}),e.jsx("span",{children:"请检查连接后重试。"}),e.jsxs("button",{onClick:()=>{u("loading"),j(C=>C+1)},children:[e.jsx(be,{size:15}),"重新加载"]})]}),e.jsx("style",{jsx:!0,children:`
|
|
87
|
+
`})]})}function Mn(r){const o=new URL(r).hostname;return o==="qoder.com"||o.endsWith(".qoder.com")}function An({page:r,reloadKey:o}){const[a,s]=t.useState(!0),[l,d]=t.useState(!1);return t.useEffect(()=>{s(!0),d(!1);const u=window.setTimeout(()=>d(!0),12e3);return()=>window.clearTimeout(u)},[r.id,r.url,o]),Mn(r.url)?e.jsxs("main",{className:"computer-page-blocked",children:[e.jsx(it,{size:36,strokeWidth:1.5,"aria-hidden":"true"}),e.jsxs("h2",{children:[r.name," 不允许内嵌"]}),e.jsx("p",{children:"这个网站限制了当前页面打开。可以在新页面使用,也可以在电脑菜单中修改打开方式。"}),e.jsxs("a",{href:r.url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(ft,{size:16,"aria-hidden":"true"}),"打开新页面"]})]}):e.jsxs("main",{className:"computer-page-pane","aria-label":r.name,"aria-busy":a,children:[e.jsx("iframe",{title:r.name,src:r.url,referrerPolicy:"no-referrer",allow:"clipboard-read; clipboard-write; microphone; camera",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-downloads allow-modals",onLoad:()=>s(!1),onError:()=>{s(!1),d(!0)},style:{visibility:a?"hidden":"visible"}},`${r.id}:${o}`),a&&e.jsx(Be,{label:"REMOTE PAGE",title:`正在打开 ${r.name}`,caption:"正在连接页面",icon:e.jsx(it,{size:36,strokeWidth:1.5})}),l&&e.jsx("a",{className:"computer-page-fallback",href:r.url,target:"_blank",rel:"noopener noreferrer",children:"打开原页面"})]})}const Ze=["refresh","collaboration","remote","theme","files","ai-hub","flow","install"],zn=["refresh","remote","theme","files"];function Dn(r){return{userId:r,revision:0,visibleTools:[...zn],savedPages:null,updatedAt:""}}function fr(r){if(!Array.isArray(r)||r.length>Ze.length||r.some(o=>!Ze.includes(o)))throw new Error("顶部工具包含未知选项。");if(new Set(r).size!==r.length)throw new Error("顶部工具不能重复。");return Ze.filter(o=>r.includes(o))}function hr(r){if(!Array.isArray(r)||r.length>20)throw new Error("每台电脑最多可添加 20 个页面。");const o=new Set;return r.map(a=>{if(!a||typeof a.id!="string"||!/^[A-Za-z0-9_-]{1,80}$/.test(a.id)||o.has(a.id))throw new Error("页面标识无效或重复。");if(typeof a.name!="string"||!a.name.trim()||a.name.trim().length>60)throw new Error("页面名称需为 1–60 个字符。");if(!["current","new-tab"].includes(a.openMode))throw new Error("页面打开方式无效。");if(typeof a.url!="string"||a.url.length>8192)throw new Error("请填写有效的 http(s) 页面地址。");let s;try{s=new URL(a.url.trim())}catch{throw new Error("请填写有效的 http(s) 页面地址。")}if(!["http:","https:"].includes(s.protocol)||s.username||s.password)throw new Error("请填写无账号密码的 http(s) 页面地址。");return o.add(a.id),{id:a.id,name:a.name.trim(),url:s.href,openMode:a.openMode}})}class ct extends Error{constructor(o,a){super(o),this.status=a}}async function Ce(r,o){var l;const a=await fetch("/api/web-console/computer-settings",{method:o?"PATCH":"GET",credentials:"same-origin",cache:"no-store",headers:o?{"content-type":"application/json","x-csrf-token":r}:void 0,body:o?JSON.stringify(o):void 0,signal:AbortSignal.timeout(15e3)}).catch(d=>{throw new Error((d==null?void 0:d.name)==="TimeoutError"?"电脑响应超时,请检查连接后重试。":"无法连接当前电脑,请检查连接后重试。")}),s=await a.json().catch(()=>null);if(!a.ok)throw new ct(((l=s==null?void 0:s.error)==null?void 0:l.message)??"电脑配置保存失败,请检查连接后重试。",a.status);if(!(s!=null&&s.settings)||!Number.isSafeInteger(s.settings.revision))throw new Error("无法读取电脑配置,请重新加载。");return{...s.settings,visibleTools:fr(s.settings.visibleTools),savedPages:s.settings.savedPages===null?null:hr(s.settings.savedPages)}}function On(r){const[o,a]=t.useState(()=>Dn("")),s=t.useRef(o),[l,d]=t.useState(!1),[u,p]=t.useState(!1),j=t.useRef(!1),v=t.useRef(!0),C=t.useRef(0),[c,k]=t.useState(""),[T,L]=t.useState(""),m=t.useCallback(x=>{s.current=x,v.current&&a(x)},[]),y=t.useCallback(async()=>{var R;if(j.current)return;const x=++C.current;k(""),L("");try{let N=await Ce(r);if(N.savedPages===null){const D=((R=Re().find(M=>M.origin===location.origin))==null?void 0:R.pages)??[];try{N=await Ce(r,{expectedRevision:N.revision,initializePages:D})}catch(M){if(!(M instanceof ct)||M.status!==409)throw M;if(N=await Ce(r),N.savedPages===null)throw new Error("电脑配置已更新,请重试旧页面导入。")}}if(!v.current||x!==C.current)return;m(N),d(!0);try{cr(Re().map(D=>{if(D.origin!==location.origin)return D;const{pages:M,...X}=D;return{...X,pagesMigrated:!0}}))}catch{}}catch(N){v.current&&x===C.current&&k(N instanceof Error?N.message:"无法读取电脑配置。")}},[m,r]);t.useEffect(()=>{v.current=!0,y();const x=()=>{y()};return window.addEventListener("focus",x),()=>{v.current=!1,C.current++,window.removeEventListener("focus",x)}},[y]);const w=t.useCallback(async x=>{if(!l||j.current)throw new Error("配置尚未就绪,请稍后重试。");j.current=!0,C.current++,p(!0),k(""),L("");const R=s.current;x.visibleTools&&m({...R,visibleTools:x.visibleTools});try{m(await Ce(r,{...x,expectedRevision:R.revision})),v.current&&L("已保存到当前电脑")}catch(N){if(m(R),N instanceof ct&&N.status===409)try{m(await Ce(r))}catch{}const D=N instanceof Error?N.message:"电脑配置保存失败,请重试。";throw v.current&&k(D),new Error(D)}finally{j.current=!1,v.current&&p(!1)}},[m,r,l]);return{settings:o,loaded:l,saving:u,error:c,notice:T,reload:y,setVisibleTools:x=>w({visibleTools:fr(x)}),setSavedPages:x=>w({savedPages:hr(x)})}}const Wn=["codex","claude agents","opencode","agent-tui"];function _n(){return Wn.map((r,o)=>({id:`default-${o+1}`,command:r}))}async function Fn(r,o,a,s){const l=a.find(u=>u&&u===r.source);if(!l)return!1;const d=Br(r,o,l);if(!d)return!1;try{const u=await s(d.method,d.payload);l.postMessage({type:Ht,id:d.id,ok:!0,result:u},o)}catch(u){const p=u;l.postMessage({type:Ht,id:d.id,ok:!1,error:p.message||"项目操作失败",code:p.code},o)}return!0}const $n=1,lt={watcherFrame:4,producerFrame:5},Qt=10;function Un(r){const o=r instanceof Uint8Array?r:new Uint8Array(r.buffer,r.byteOffset,r.byteLength);if(o.byteLength<Qt||o[0]!==$n||o[1]!==lt.watcherFrame&&o[1]!==lt.producerFrame)return null;const a=new DataView(o.buffer,o.byteOffset,o.byteLength);return{type:o[1],channelId:a.getUint32(2,!1),sequence:a.getUint32(6,!1),payload:o.subarray(Qt)}}function Bn(){return Hr()}function qn(r,o,a){const[s,l]=t.useState({connected:!1,error:null}),[d,u]=t.useState(0),p=t.useRef(null),j=t.useRef(0),v=t.useRef(new Map),C=t.useRef([]),c=t.useRef(0),k=t.useRef(new Map),T=t.useRef(new Map),L=t.useRef(new Map),m=t.useRef(1e3),y=t.useRef(!1),w=t.useRef(null),x=t.useRef(r),R=t.useRef(o),N=t.useRef(a);x.current=r,R.current=o,N.current=a;const D=t.useCallback((P,A)=>{let E=k.current.get(P);return E||k.current.set(P,E=new Set),E.add(A),()=>E.delete(A)},[]),M=t.useCallback((P,A)=>{let E=T.current.get(P);return E||T.current.set(P,E=new Set),E.add(A),()=>E.delete(A)},[]),X=t.useCallback((P,A)=>{let E=L.current.get(P);return E||L.current.set(P,E=new Set),E.add(A),()=>E.delete(A)},[]),B=t.useCallback((P,A)=>{const E=p.current;if(!E||E.readyState!==WebSocket.OPEN)return!1;const I=new TextEncoder().encode(A),z=new Uint8Array(6+I.byteLength),g=new DataView(z.buffer);return z[0]=1,z[1]=1,g.setUint32(2,P),z.set(I,6),E.send(z),!0},[]),H=t.useCallback(P=>{const A=p.current;(A==null?void 0:A.readyState)===WebSocket.OPEN?A.send(P):C.current.push(P)},[]),oe=t.useCallback((P,A={},E=15e3)=>new Promise((I,z)=>{var K;if(P.startsWith("browser:")&&((K=p.current)==null?void 0:K.readyState)!==WebSocket.OPEN){z(Object.assign(new Error("远程连接已断开,请等待重新连接"),{code:"EOFFLINE"}));return}const g=++c.current,_=setTimeout(()=>{v.current.delete(g),z(new Error(`${P} timeout`))},E);v.current.set(g,{resolve:I,reject:z,timer:_,type:P}),H(JSON.stringify({type:P,_req:g,...A}))}),[H]),$=t.useCallback(async()=>{y.current=!1;const P=++j.current;w.current&&(clearInterval(w.current),w.current=null);const A=p.current;if(A){A.onopen=A.onmessage=A.onerror=A.onclose=null;try{A.close()}catch{}}let E;try{E=await R.current()}catch{P===j.current&&N.current();return}if(P!==j.current||y.current)return;let I;try{I=new WebSocket(`${Bn()}?nonce=${encodeURIComponent(E)}`)}catch(z){l({connected:!1,error:String(z)});return}I.binaryType="arraybuffer",p.current=I,I.onopen=()=>{if(P!==j.current||p.current!==I)return;m.current=1e3,l({connected:!0,error:null}),u(K=>K+1);const z=C.current.splice(0);for(const K of z)I.send(K);let g=Date.now();w.current=setInterval(()=>{if(p.current!==I||I.readyState!==WebSocket.OPEN){clearInterval(w.current),w.current=null;return}if(Date.now()-g>25e3){try{I.close()}catch{}return}try{I.send(JSON.stringify({type:"ping"}))}catch{}},1e4);const _=()=>{g=Date.now()};I.addEventListener("message",_),I.addEventListener("close",()=>I.removeEventListener("message",_),{once:!0})},I.onmessage=z=>{var _,K,ie;if(P!==j.current||p.current!==I)return;if(typeof z.data!="string"){const F=new Uint8Array(z.data);if(F.byteLength>=6&&F[0]===1&&(F[1]===2||F[1]===6)){const ee=new DataView(F.buffer,F.byteOffset,F.byteLength).getUint32(2);(_=T.current.get(ee))==null||_.forEach(b=>b(F.subarray(6),F[1]===6))}else if(F.byteLength>=6&&F[0]===1&&F[1]===3){const ee=new DataView(F.buffer,F.byteOffset,F.byteLength).getUint32(2);(K=L.current.get(ee))==null||K.forEach(b=>b())}else x.current(F);return}let g;try{g=JSON.parse(z.data)}catch{return}if(g.type==="error"&&g.id!=null){const F=v.current.get(g.id);if(F){v.current.delete(g.id),clearTimeout(F.timer);const ee=Object.assign(new Error(g.error||"gateway error"),{code:g.code});F.reject(ee)}return}if(g.id!=null&&typeof g.type=="string"&&g.type.endsWith(":result")){const F=v.current.get(g.id);(F==null?void 0:F.type)==="fs:preview-open"&&typeof g.url=="string"&&(g.url=qr(g.url)),F&&(v.current.delete(g.id),clearTimeout(F.timer),F.resolve(g));return}(ie=k.current.get(g.type))==null||ie.forEach(F=>F(g))},I.onclose=z=>{if(P!==j.current||p.current!==I)return;w.current&&(clearInterval(w.current),w.current=null),p.current=null;for(const[_,K]of v.current)K.type.startsWith("browser:")&&(clearTimeout(K.timer),v.current.delete(_),K.reject(Object.assign(new Error("远程连接已断开,请重新接管"),{code:"EOFFLINE"})));if(l({connected:!1,error:null}),z.code===4001||z.code===4003){N.current();return}if(y.current)return;const g=m.current;m.current=Math.min(g*2,8e3),setTimeout(()=>{!y.current&&P===j.current&&$()},g)},I.onerror=()=>{}},[]);return t.useEffect(()=>($(),()=>{y.current=!0,j.current++,w.current&&(clearInterval(w.current),w.current=null);const P=p.current;if(p.current=null,P){P.onopen=P.onmessage=P.onerror=P.onclose=null;try{P.close()}catch{}}}),[$]),{state:s,epoch:d,rpc:oe,onEvent:D,onTerminalData:M,onTerminalReset:X,sendTerminalInput:B,reconnect:$}}function Hn(){const[r,o]=t.useState("loading"),[a,s]=t.useState(null),[l]=t.useState("same-origin"),[d,u]=t.useState(null),p=t.useCallback(async()=>{o("loading"),u(null);try{const c=await fetch("/api/web-console/bootstrap",{credentials:"same-origin",cache:"no-store"});if(c.status===401||c.status===423){window.location.reload();return}if(!c.ok)throw new Error(`HTTP ${c.status}`);const k=await c.json();s(k.user),o("authenticated")}catch{u("无法连接远程控制台"),o("needsLogin")}},[]);t.useEffect(()=>{p()},[p]);const j=t.useCallback(async()=>{const c=await fetch("/api/web-console/bootstrap",{credentials:"same-origin",cache:"no-store"});if((c.status===401||c.status===423)&&window.location.reload(),!c.ok)throw new Error("bootstrap failed");const k=await c.json();return s(k.user),o("authenticated"),k.wsNonce},[]),v=t.useCallback(async()=>(window.location.reload(),!1),[]),C=t.useCallback(async()=>{const c=await fetch("/api/pairing/logout",{method:"POST",credentials:"same-origin"});c.ok||c.status===401||c.status===423?window.location.reload():u("退出失败,请重试")},[]);return{status:r,user:a,error:d,csrfToken:l,setup:v,login:v,logout:C,refresh:p,getWsNonce:j}}function Vn({children:r}){const o=Hn(),[a,s]=t.useState(!1),l=o.status==="authenticated",d=t.useCallback(()=>s(!0),[]);return t.useEffect(()=>{l||s(!1)},[l]),e.jsxs(e.Fragment,{children:[l?r(o,d):null,e.jsx(Vr,{ready:l&&a,error:o.error,onRetry:()=>void o.refresh()})]})}function Zt(r,o,a){const s=r.findIndex(p=>p.id===o),l=r.findIndex(p=>p.id===a);if(s<0||l<0||s===l)return[...r];const d=[...r],[u]=d.splice(s,1);return d.splice(l,0,u),d}function Kn(){return typeof crypto.randomUUID=="function"?crypto.randomUUID():Array.from(crypto.getRandomValues(new Uint8Array(16)),r=>r.toString(16).padStart(2,"0")).join("")}function gr(r,o=Kn()){return{id:o,command:r.trim()}}function Gn({commands:r,onChange:o,onExecute:a}){const[s,l]=t.useState(null),[d,u]=t.useState(""),[p,j]=t.useState(null),v=t.useRef(null),C=()=>{if(!s)return;const m=s.value.trim();if(!m)return u("命令不能为空");if(m.length>1e3)return u("命令最多 1000 个字符");if(/[\r\n\0]/.test(m))return u("命令只能包含一行");s.id?o(r.map(y=>y.id===s.id?{...y,command:m}:y)):o([...r,gr(m)]),l(null),u("")},c=(m,y)=>{m.preventDefault(),m.stopPropagation(),v.current=y,j(y),m.currentTarget.setPointerCapture(m.pointerId)},k=m=>{var x;if(!v.current)return;const y=(x=document.elementFromPoint(m.clientX,m.clientY))==null?void 0:x.closest("[data-pinned-id]"),w=y==null?void 0:y.dataset.pinnedId;w&&w!==v.current&&o(Zt(r,v.current,w))},T=m=>{m.currentTarget.hasPointerCapture(m.pointerId)&&m.currentTarget.releasePointerCapture(m.pointerId),v.current=null,j(null)},L=(m,y)=>{if(m.key!=="ArrowUp"&&m.key!=="ArrowDown")return;m.preventDefault();const w=r.findIndex(R=>R.id===y),x=r[w+(m.key==="ArrowUp"?-1:1)];x&&o(Zt(r,y,x.id))};return e.jsxs("section",{className:"pinned-commands","aria-labelledby":"pinned-command-title",children:[e.jsxs("div",{className:"pinned-command-head",children:[e.jsx("span",{id:"pinned-command-title",children:"置顶命令"}),e.jsx("button",{className:"history-icon-button",onClick:()=>{l({id:null,value:""}),u("")},"aria-label":"新增置顶命令",title:"新增置顶命令",children:e.jsx($e,{size:14,"aria-hidden":"true"})})]}),r.map(m=>(s==null?void 0:s.id)===m.id?e.jsx(er,{editor:s,error:d,onChange:y=>{l({...s,value:y}),u("")},onSave:C,onCancel:()=>{l(null),u("")}},m.id):e.jsxs("div",{className:`pinned-command-row${p===m.id?" pinned-command-dragging":""}`,"data-pinned-id":m.id,role:"button",tabIndex:0,onClick:()=>a(m.command),onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),a(m.command))},children:[e.jsx("button",{className:"pinned-command-grip",onPointerDown:y=>c(y,m.id),onPointerMove:k,onPointerUp:T,onPointerCancel:T,onKeyDown:y=>L(y,m.id),onClick:y=>y.stopPropagation(),"aria-label":`调整 ${m.command} 的顺序`,title:"拖动排序,或按上下方向键",children:e.jsx(tn,{size:14,"aria-hidden":"true"})}),e.jsx("code",{children:m.command}),e.jsxs("div",{className:"pinned-command-actions",onClick:y=>y.stopPropagation(),children:[e.jsx("button",{className:"history-icon-button",onClick:()=>{l({id:m.id,value:m.command}),u("")},"aria-label":`编辑 ${m.command}`,title:"编辑",children:e.jsx(ot,{size:12,"aria-hidden":"true"})}),e.jsx("button",{className:"history-icon-button history-icon-danger",onClick:()=>o(r.filter(y=>y.id!==m.id)),"aria-label":`删除 ${m.command}`,title:"删除",children:e.jsx(mt,{size:12,"aria-hidden":"true"})})]})]},m.id)),(s==null?void 0:s.id)===null&&e.jsx(er,{editor:s,error:d,onChange:m=>{l({...s,value:m}),u("")},onSave:C,onCancel:()=>{l(null),u("")}})]})}function er({editor:r,error:o,onChange:a,onSave:s,onCancel:l}){return e.jsxs("div",{className:"pinned-command-editor",children:[e.jsx("input",{autoFocus:!0,value:r.value,maxLength:1e3,onChange:d=>a(d.target.value),onKeyDown:d=>{d.key==="Enter"&&s(),d.key==="Escape"&&l()},"aria-label":r.id?"编辑置顶命令":"新增置顶命令"}),e.jsx("button",{className:"history-icon-button",onClick:s,"aria-label":"保存命令",title:"保存",children:e.jsx(nt,{size:13,"aria-hidden":"true"})}),e.jsx("button",{className:"history-icon-button",onClick:l,"aria-label":"取消编辑",title:"取消",children:e.jsx(ke,{size:13,"aria-hidden":"true"})}),o&&e.jsx("small",{role:"alert",children:o})]})}function Yn({csrfToken:r,terminalId:o,pinnedCommands:a,onPinnedCommandsChange:s,onFill:l,onExecute:d}){const[u,p]=t.useState([]),[j,v]=t.useState(""),[C,c]=t.useState(""),k=t.useCallback(async()=>{const w=new URLSearchParams({q:j,limit:"200"}),x=await fetch(`/api/web-console/history?${w}`,{credentials:"same-origin"});x.ok&&p((await x.json()).history)},[j]);t.useEffect(()=>{const w=setTimeout(k,200);return()=>clearTimeout(w)},[k]);const T=async w=>{await fetch("/api/web-console/history",{method:"DELETE",credentials:"same-origin",headers:{"content-type":"application/json","x-csrf-token":r},body:JSON.stringify({id:w})}),k()},L=w=>{o&&l(w)},m=t.useCallback(w=>{w==="[REDACTED]"||a.some(x=>x.command===w)||s([...a,gr(w)])},[s,a]),y=async w=>{const x=await ln(w);c(x?"已复制命令":"复制失败,请长按命令手动复制")};return e.jsxs("div",{className:"history-panel",children:[e.jsx(Gn,{commands:a,onChange:s,onExecute:d}),e.jsxs("div",{className:"history-search",children:[e.jsx("input",{value:j,onChange:w=>v(w.target.value),placeholder:"搜索命令"}),e.jsx("button",{className:"history-icon-button",onClick:k,"aria-label":"刷新历史",title:"刷新历史",children:e.jsx(be,{size:13,"aria-hidden":"true"})})]}),C&&e.jsx("div",{className:"terminal-clipboard-notice",role:"status",children:C}),u.map(w=>e.jsxs("div",{className:`history-item${o?"":" history-item-disabled"}`,role:"button",tabIndex:o?0:-1,onClick:()=>L(w.command),onKeyDown:x=>{x.target===x.currentTarget&&(x.key==="Enter"||x.key===" ")&&o&&(x.preventDefault(),L(w.command))},children:[e.jsx("code",{children:w.command}),e.jsxs("small",{children:[w.cwd," · ",new Date(w.executedAt).toLocaleString()]}),e.jsxs("div",{className:"history-item-actions",onClick:x=>x.stopPropagation(),onPointerDown:x=>x.stopPropagation(),children:[e.jsx("button",{className:"history-icon-button",onClick:()=>void y(w.command),"aria-label":"复制命令",title:"复制",children:e.jsx(rn,{size:12,"aria-hidden":"true"})}),e.jsx("button",{className:"history-icon-button",disabled:!o,onClick:()=>L(w.command),"aria-label":"填入命令",title:"填入",children:e.jsx(wn,{size:12,"aria-hidden":"true"})}),e.jsx("button",{className:"history-icon-button",disabled:w.command==="[REDACTED]"||a.some(x=>x.command===w.command),onClick:()=>m(w.command),"aria-label":"置顶命令",title:"置顶",children:e.jsx(nn,{size:12,"aria-hidden":"true"})}),e.jsx("button",{className:"history-icon-button history-icon-danger",onClick:()=>T(w.id),"aria-label":"删除历史",title:"删除",children:e.jsx(mt,{size:12,"aria-hidden":"true"})})]})]},w.id)),!u.length&&e.jsx("div",{className:"history-empty",children:"暂无 Shell 命令历史"}),!o&&!!u.length&&e.jsx("div",{className:"history-empty",children:"请先打开一个终端页签"})]})}function Jn({themeId:r,onThemeChange:o}){const[a,s]=t.useState(!1),l=t.useRef(null),d=t.useRef(null),u=t.useRef(null),[p,j]=t.useState(null),[v,C]=t.useState({top:-1e3,left:0});return t.useEffect(()=>{var c;j(((c=l.current)==null?void 0:c.closest(".web-root"))??document.body)},[]),t.useLayoutEffect(()=>{if(!a)return;const c=()=>{var L;const k=(L=d.current)==null?void 0:L.getBoundingClientRect();if(!k)return;const T=Math.min(176,innerWidth-16);C({top:k.bottom+6,left:Math.max(8,Math.min(innerWidth-T-8,k.right-T))})};return c(),window.addEventListener("resize",c),window.addEventListener("scroll",c,!0),()=>{window.removeEventListener("resize",c),window.removeEventListener("scroll",c,!0)}},[a]),t.useEffect(()=>{if(!a)return;const c=T=>{var L,m;!((L=l.current)!=null&&L.contains(T.target))&&!((m=u.current)!=null&&m.contains(T.target))&&s(!1)},k=T=>{var L;T.key==="Escape"&&(s(!1),(L=d.current)==null||L.focus())};return document.addEventListener("pointerdown",c),document.addEventListener("keydown",k),()=>{document.removeEventListener("pointerdown",c),document.removeEventListener("keydown",k)}},[a]),e.jsxs("div",{ref:l,className:"theme-picker",children:[e.jsx("button",{ref:d,type:"button",className:"file-drawer-toggle","aria-label":"换肤",title:"换肤","aria-expanded":a,"aria-haspopup":"dialog",onClick:()=>s(c=>!c),children:e.jsx(lr,{size:17,"aria-hidden":"true"})}),a&&p&&Te.createPortal(e.jsxs("div",{ref:u,className:"theme-popover",role:"dialog","aria-label":"选择皮肤","data-toolbar-overlay":!0,style:{position:"fixed",...v,zIndex:210,width:Math.min(176,innerWidth-16),boxSizing:"border-box",padding:8,borderRadius:10,border:"1px solid var(--ui-tabbar-border, #282b36)",background:"var(--ui-tab-active-bg, #262b38)",boxShadow:"0 10px 28px rgba(0,0,0,.45)"},children:[e.jsx("div",{style:{fontSize:10,color:"var(--ui-connection-text, #777b8c)",margin:"2px 4px 6px",letterSpacing:.5},children:"皮肤"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:2},children:Kr.map(c=>{const k=c.id===r;return e.jsxs("button",{type:"button",className:"theme-popover-item","aria-label":c.label,"aria-pressed":k,onPointerDown:T=>T.stopPropagation(),onClick:()=>{o(c.id),s(!1)},style:{background:k?"color-mix(in srgb, var(--ui-tab-accent, #7aa2f7) 14%, transparent)":"transparent"},children:[e.jsx("span",{style:{width:18,height:18,borderRadius:5,flexShrink:0,background:`linear-gradient(135deg, ${c.preview[0]} 55%, ${c.preview[1]} 55%)`,boxShadow:"inset 0 0 0 1px rgba(128,128,160,.25)"}}),e.jsx("span",{style:{flex:1,textAlign:"left",fontSize:12,fontWeight:k?600:400,color:k?"var(--ui-tab-active-text, #edf0f7)":"var(--ui-tab-text, #8f93a4)"},children:c.label}),k&&e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--ui-tab-accent, #7aa2f7)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"m5 12 4 4L19 6"})})]},c.id)})})]}),p)]})}function Xn(r,o){return{height:Math.round((r==null?void 0:r.height)??o.height),width:Math.round((r==null?void 0:r.width)??o.width),top:Math.round((r==null?void 0:r.offsetTop)??0),left:Math.round((r==null?void 0:r.offsetLeft)??0)}}function Qn(r){r&&(r.scrollLeft=0)}const Zn="agent-webapp:tab-swipe:v1";function eo(r){if(!r||typeof r!="object")return null;const o=r;return o.type!==Zn||o.phase!=="move"&&o.phase!=="end"&&o.phase!=="cancel"||typeof o.deltaX!="number"||!Number.isFinite(o.deltaX)?null:o}function to(r,o,a){return r.origin!==o||r.source!==a?null:eo(r.data)}const tr="agent-webapp:ready:v1";function ro(r){return!r||typeof r!="object"||r.type!==tr?null:{type:tr}}function rr(r,o,a){return r.origin!==o||r.source!==a?null:ro(r.data)}function nr({groupId:r,title:o,onFrame:a,onLoad:s}){const l=t.useRef(null),[d,u]=t.useState("loading"),[p,j]=t.useState(0),v=r===void 0;return t.useEffect(()=>{const C=c=>{var k;dn(c,window.location.origin,((k=l.current)==null?void 0:k.contentWindow)??null,r??null)&&u("ready")};return window.addEventListener("message",C),()=>window.removeEventListener("message",C)},[r]),t.useEffect(()=>{if(d!=="loading")return;const C=window.setTimeout(()=>u(c=>c==="loading"?"error":c),3e4);return()=>window.clearTimeout(C)},[d,p]),e.jsxs("div",{className:"collaboration-pane","aria-busy":d==="loading",children:[e.jsx("iframe",{ref:C=>{l.current=C,a(C)},className:`webapp-frame collaboration-frame${d==="ready"?" is-ready":""}`,style:{visibility:d==="ready"?"visible":"hidden"},src:tt(v?"/app/?view=collaboration-dashboard":`/app/?view=collaboration&groupId=${encodeURIComponent(r)}`),title:o,onLoad:s,onError:()=>u("error")},p),d==="loading"&&e.jsx(Be,{label:"AGENT COLLABORATION",title:v?"正在打开群聊看板":"正在进入群聊",caption:v?"正在加载已保存的群聊":"正在加载群成员与聊天记录",icon:e.jsx(ut,{size:36,strokeWidth:1.5})}),d==="error"&&e.jsxs("div",{className:"collaboration-load-error",role:"alert",children:[e.jsx("strong",{children:v?"暂时无法打开群聊看板":"暂时无法打开群聊"}),e.jsx("span",{children:"请检查连接后重试。"}),e.jsxs("button",{onClick:()=>{u("loading"),j(C=>C+1)},children:[e.jsx(be,{size:15}),"重新加载"]})]}),e.jsx("style",{jsx:!0,children:`
|
|
88
88
|
.collaboration-pane { position:relative; height:100%; background:var(--ui-term-col-bg, #101014); }
|
|
89
89
|
.collaboration-frame.is-ready { animation:collaboration-appear 220ms ease-out both; }
|
|
90
90
|
.collaboration-load-error { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; color:var(--ui-text, #e5e7eb); background:var(--ui-term-col-bg, #101014); padding:20px; text-align:center; }
|
|
@@ -93,4 +93,4 @@ import{c as dt,r as t,j as e,P as $e,f as Te,R as be,m as Ar,n as zr,o as Re,s a
|
|
|
93
93
|
.collaboration-load-error button:focus-visible { outline:2px solid currentColor; outline-offset:3px; }
|
|
94
94
|
@keyframes collaboration-appear { from { opacity:0; } to { opacity:1; } }
|
|
95
95
|
@media (prefers-reduced-motion:reduce) { .collaboration-frame.is-ready { animation:none; } }
|
|
96
|
-
`})]})}function or(r){try{const o=JSON.parse(r||"null");if(!o||!Array.isArray(o.tabs))return null;const a=new Set,s=new Set(["webapp","aihub","flowstudio","remote-desktop","collaboration","collaboration-dashboard"]),l=[];for(const d of o.tabs.slice(0,100))!d||typeof d.id!="string"||typeof d.title!="string"||a.has(d.id)||d.kind!==void 0&&!s.has(d.kind)||d.kind==="collaboration"&&typeof d.groupId!="string"||(a.add(d.id),l.push({id:d.id,title:d.title,...d.kind?{kind:d.kind}:{},...typeof d.groupId=="string"?{groupId:d.groupId}:{}}));return{tabs:l,activeTerminalId:typeof o.activeTerminalId=="string"?o.activeTerminalId:null}}catch{return null}}function no(r,o,a){const s=new Map(o.filter(u=>u.status==="active"||u.status==="detached").map(u=>[u.id,{id:u.id,title:u.title}])),l=[],d=new Set;for(const u of[...(r==null?void 0:r.tabs)??[],...a,...s.values()])d.has(u.id)||!u.kind&&!s.has(u.id)||(d.add(u.id),l.push(u.kind?u:s.get(u.id)));return l}const ve={id:"remote-desktop",title:"远程桌面",kind:"remote-desktop"};function ir(r){const o=r.find(a=>a.kind==="remote-desktop");return o?r.map(a=>a===o?{...ve}:a):[...r,{...ve}]}const Ue={id:"collaboration-dashboard",title:"群聊看板",kind:"collaboration-dashboard"};function oo(r){return r.some(o=>o.id===Ue.id)?r:[...r,{...Ue}]}const io=Le(()=>Pe(()=>import("./TerminalPane-B2s2ff23.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]),import.meta.url),{ssr:!1}),ao=Le(()=>Pe(()=>import("./FileTree-Cf8wDAVy.js"),__vite__mapDeps([11,1,2,12,5,13,7]),import.meta.url),{ssr:!1}),so=Le(()=>Pe(()=>import("./FilePreview-BdB8syBQ.js").then(r=>r.b),__vite__mapDeps([14,1,2,6,15,13,7,5,16]),import.meta.url),{ssr:!1}),co=Le(()=>Pe(()=>import("./AiHubPane-D1SGdI6y.js"),__vite__mapDeps([17,1,2,5,13,18]),import.meta.url),{ssr:!1}),lo=Le(()=>Pe(()=>import("./FlowStudioPane-DuUmV_ki.js"),__vite__mapDeps([19,1,2,20,4,5,6,7,3,8,9]),import.meta.url),{ssr:!1,loading:()=>e.jsx(Be,{})});function uo(){return e.jsx(Vn,{children:(r,o)=>e.jsx(fo,{auth:r,onWorkspaceReady:o})})}const de={id:"webapp-agent",title:"智能助手",kind:"webapp"},ar={id:"ai-hub",title:"AI Hub",kind:"aihub"},sr={id:"flow-studio",title:"Flow Studio",kind:"flowstudio"};function po(){var r;return typeof document>"u"?Xr:rt((r=document.getElementById("web-theme-root"))==null?void 0:r.dataset.webTheme).id}const mo="agent-web-shell:skin:v1";function fo({auth:r,onWorkspaceReady:o}){var Nt,Pt,Lt,It;const[a,s]=t.useState(null),[l,d]=t.useState(0),u=t.useCallback(n=>{if((n==null?void 0:n.openMode)==="new-tab"){window.open(n.url,"_blank","noopener,noreferrer");return}s(n)},[]),p=t.useCallback(n=>s((n==null?void 0:n.openMode)==="current"?n:null),[]),j=t.useRef(null),v=t.useRef(null),C=t.useRef(null),[c,k]=t.useState({}),T=t.useRef(new Map),[L,m]=t.useState(0),[y,w]=t.useState(!1),[x,R]=t.useState(!1),N=t.useRef(()=>{}),D=t.useCallback(n=>{var f;const i=Un(n);if(!(!i||i.type!==lt.watcherFrame)){N.current(i.channelId,i.sequence);for(const h of[j,v]){if(!((f=h.current)!=null&&f.contentWindow))continue;const S=i.payload.slice().buffer;h.current.contentWindow.postMessage({type:Gr,channelId:i.channelId,sequence:i.sequence,data:S},window.location.origin,[S])}}},[]),{state:M,epoch:X,rpc:B,onEvent:H,onTerminalData:ne,onTerminalReset:$,sendTerminalInput:P}=qn(D,r.getWsNonce,r.refresh),A=t.useMemo(()=>({request:(n,i,f)=>B(n,i,f),subscribe:(n,i)=>H("fs:event",i)}),[H,B]);N.current=(n,i)=>{B("browser:frame-ack",{channelId:n,sequence:i}).catch(()=>{})};const[E,I]=t.useState([{...de}]),z=t.useRef(E);z.current=E;const[g,_]=t.useState(de.id),[K,ie]=t.useState({}),F=t.useRef(!1),[ee,b]=t.useState(!1),[O,Y]=t.useState(0),U=`agentroam:workspace:${typeof window>"u"?"":Ne()}:${((Nt=r.user)==null?void 0:Nt.id)??""}`,V=t.useRef(null),G=t.useRef(new Map),se=t.useRef(new Map),Ie=t.useCallback((n,i)=>{G.current.set(n,i);const f=window.setTimeout(()=>{if(G.current.get(n)!==i)return;const h=se.current.get(n);h&&(se.current.delete(n),i(h,!0))},180);return()=>{window.clearTimeout(f),G.current.get(n)===i&&G.current.delete(n)}},[]),Me=t.useCallback(n=>{var f;if(!g||(f=E.find(h=>h.id===g))!=null&&f.kind)return;const i=G.current.get(g);i?i(n):B("term:input",{id:g,data:`${n}`}).catch(()=>{}),le(!1)},[g,B,E]),[we,br]=t.useState(!1),[je,qe]=t.useState({}),[ue,Ae]=t.useState(null),[ce,le]=t.useState(!1),[he,ze]=t.useState("files"),[Ee,ht]=t.useState(null),[Se,gt]=t.useState(!0),[wr,xr]=t.useState(null),[He,bt]=t.useState(!1),[Ve,wt]=t.useState([]),[Ke,xt]=t.useState(_n()),[oe,yt]=t.useState(po),[vt,yr]=t.useState(!1),De=On(r.csrfToken),[kt,vr]=t.useState(!1),te=rt(oe),xe=t.useRef(null),[kr,Ge]=t.useState(0),[jr,Ye]=t.useState(!1),Je=t.useRef(null),jt=t.useRef(null),pe=t.useCallback(n=>{var f;const i=[j.current,v.current,C.current,...T.current.values()];for(const h of i)(f=h==null?void 0:h.contentWindow)==null||f.postMessage({type:mo,skin:n},window.location.origin)},[]);t.useEffect(()=>{pe(oe)},[oe,pe]),t.useEffect(()=>{const n=te.cssVars["--ui-root-bg"],i=te.cssVars["--ui-color-scheme"],f=document.getElementById("web-theme-root");for(const[S,W]of Object.entries(te.cssVars))f==null||f.style.setProperty(S,W);f&&(f.dataset.webTheme=te.id),document.documentElement.style.background=n,document.documentElement.style.colorScheme=i,document.body.style.background=n,document.body.style.colorScheme=i;let h=document.querySelector('meta[name="theme-color"]');h||(h=document.createElement("meta"),h.name="theme-color",document.head.append(h)),h.content=te.cssVars["--ui-tabbar-bg"]},[te]),t.useEffect(()=>{const n=i=>{var Mt,At,zt,Dt,Ot,Wt,_t,Ft,$t,Ut,Bt;const f=((Mt=C.current)==null?void 0:Mt.contentWindow)??null,h=un(i,window.location.origin,f);if(h){I(q=>h.deleted?q.filter(Q=>Q.groupId!==h.groupId):q.map(Q=>Q.groupId===h.groupId?{...Q,title:h.title}:Q)),h.deleted?_(q=>q===`collaboration-${h.groupId}`?Ue.id:q):k(q=>({...q,[h.groupId]:(q[h.groupId]||0)+1}));return}const S=pn(i,window.location.origin,i.source===f?f:((At=j.current)==null?void 0:At.contentWindow)??null);if(S){const q=`collaboration-${S.groupId}`;I(Q=>Q.some(_e=>_e.id===q)?Q:[...Q,{id:q,title:S.title,kind:"collaboration",groupId:S.groupId}]),_(q);return}const W=((zt=v.current)==null?void 0:zt.contentWindow)??null,J=fn(i,window.location.origin,W);if(J!==null){w(J);return}if(rr(i,window.location.origin,W)){w(!1),m(q=>q+1),R(!1),pe(oe);return}if(W&&i.origin===window.location.origin&&i.source===W&&((Dt=i.data)==null?void 0:Dt.type)===hn){R(!0);return}if(i.origin===window.location.origin&&i.source===W&&W&&((Ot=i.data)==null?void 0:Ot.type)===gn){w(!1),B("browser:unwatch").catch(()=>{}),I(q=>q.filter(Q=>Q.kind!=="remote-desktop")),m(0),R(!1),_(de.id);return}if(Qr(i,window.location.origin,((Wt=j.current)==null?void 0:Wt.contentWindow)??null)){I(ir),_(ve.id);return}if(rr(i,window.location.origin,((_t=j.current)==null?void 0:_t.contentWindow)??null)){vr(!0),o();return}const Z=(Ft=[...T.current.values()].find(q=>q.contentWindow===i.source))==null?void 0:Ft.contentWindow,re=on(i,window.location.origin,Z??(($t=j.current)==null?void 0:$t.contentWindow)??null);if(re){const q=Q=>{ze("files"),le(!Gt(Q)),Ae(Q),Gt(Q)||xr({...re,path:Q})};re.path.startsWith("~/")?B("hello").then(({home:Q})=>{const _e=an(re.path,null,Q);_e&&q(_e)}).catch(()=>{}):q(re.path);return}const ge=i.source===W&&W?W:((Ut=j.current)==null?void 0:Ut.contentWindow)??null,ye=Zr(i,window.location.origin,ge);if(ye){B(ye.method,{...ye.payload,...ye.method==="browser:watch"?{frameAck:!0}:{}}).then(q=>{ge==null||ge.postMessage({type:Vt,id:ye.id,ok:!0,result:q},window.location.origin)},q=>{ge==null||ge.postMessage({type:Vt,id:ye.id,ok:!1,error:q.message||"浏览器操作失败",code:q.code},window.location.origin)});return}Fn(i,window.location.origin,[((Bt=j.current)==null?void 0:Bt.contentWindow)??null,f,...[...T.current.values()].map(q=>q.contentWindow)],B)};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)},[o,B,pe,oe]),t.useEffect(()=>{const n=h=>{var S,W;for(const J of[j,v])(W=(S=J.current)==null?void 0:S.contentWindow)==null||W.postMessage({type:Qe,event:h},window.location.origin)},f=["browser:session","browser:frame","browser:state","browser:closed","browser:webrtc"].map(h=>H(h,n));return()=>f.forEach(h=>h())},[H]),t.useEffect(()=>{var n,i;kt&&((i=(n=j.current)==null?void 0:n.contentWindow)==null||i.postMessage({type:Qe,event:{type:"browser:connection",connected:M.connected,epoch:X}},window.location.origin))},[M.connected,X,kt]),t.useEffect(()=>{var n,i;L&&((i=(n=v.current)==null?void 0:n.contentWindow)==null||i.postMessage({type:mn,visible:g===ve.id},window.location.origin))},[g,L]),t.useEffect(()=>{var n,i;L&&((i=(n=v.current)==null?void 0:n.contentWindow)==null||i.postMessage({type:Qe,event:{type:"browser:connection",connected:M.connected,epoch:X}},window.location.origin))},[M.connected,X,L]);const Et=t.useRef(0),St=g?K[g]??null:null;t.useEffect(()=>{const n=window.visualViewport;let i=null,f="";const h=()=>{const S=Xn(n,{height:window.innerHeight,width:window.innerWidth}),W=`${S.width}x${S.height}+${S.top}+${S.left}`;W!==f&&(f=W,document.documentElement.style.setProperty("--vv-height",`${S.height}px`),document.documentElement.style.setProperty("--vv-width",`${S.width}px`),document.documentElement.style.setProperty("--vv-top",`${S.top}px`),document.documentElement.style.setProperty("--vv-left",`${S.left}px`),i&&window.clearTimeout(i),i=window.setTimeout(h,250))};return h(),n==null||n.addEventListener("resize",h),n==null||n.addEventListener("scroll",h),window.addEventListener("orientationchange",h),window.addEventListener("resize",h),document.addEventListener("visibilitychange",h),window.addEventListener("pageshow",h),()=>{n==null||n.removeEventListener("resize",h),n==null||n.removeEventListener("scroll",h),window.removeEventListener("orientationchange",h),window.removeEventListener("resize",h),document.removeEventListener("visibilitychange",h),window.removeEventListener("pageshow",h),i&&window.clearTimeout(i),document.documentElement.style.removeProperty("--vv-height"),document.documentElement.style.removeProperty("--vv-width"),document.documentElement.style.removeProperty("--vv-top"),document.documentElement.style.removeProperty("--vv-left")}},[]),t.useEffect(()=>{fetch("/api/web-console/preferences",{credentials:"same-origin"}).then(n=>n.json()).then(n=>{var i,f,h,S;typeof((i=n.preferences)==null?void 0:i.keybarHidden)=="boolean"&&bt(n.preferences.keybarHidden),Array.isArray((f=n.preferences)==null?void 0:f.keyOrder)&&wt(n.preferences.keyOrder),Array.isArray((h=n.preferences)==null?void 0:h.pinnedCommands)&&xt(n.preferences.pinnedCommands),(S=n.preferences)!=null&&S.theme&&yt(rt(n.preferences.theme).id)}).catch(()=>{}).finally(()=>yr(!0)),fetch("/api/web-console/device-state",{credentials:"same-origin"}).then(n=>n.json()).then(n=>{const i=n.deviceState;i!=null&&i.drawerTab&&ze(i.drawerTab),i!=null&&i.activeTerminalId&&(V.current=i.activeTerminalId),typeof(i==null?void 0:i.drawerOpen)=="boolean"&&le(i.drawerOpen),i!=null&&i.fileTreeRoot&&ht(i.fileTreeRoot),typeof(i==null?void 0:i.fileTreeFollowMode)=="boolean"&>(i.fileTreeFollowMode),i!=null&&i.selectedFile&&Ae(i.selectedFile),i!=null&&i.terminalScroll&&typeof i.terminalScroll=="object"&&qe(i.terminalScroll)}).catch(()=>{}).finally(()=>br(!0))},[]);const Ct=t.useCallback(n=>{fetch("/api/web-console/preferences",{method:"PATCH",credentials:"same-origin",headers:{"content-type":"application/json","x-csrf-token":r.csrfToken},body:JSON.stringify(n)}).catch(()=>{})},[r.csrfToken]);t.useEffect(()=>{if(!vt)return;const n=setTimeout(()=>Ct({keybarHidden:He,keyOrder:Ve,pinnedCommands:Ke,theme:oe}),500);return()=>clearTimeout(n)},[He,Ve,Ke,oe,vt,Ct]);const Oe=t.useCallback(n=>{r.csrfToken&&fetch("/api/web-console/device-state",{method:"PUT",credentials:"same-origin",keepalive:!0,headers:{"content-type":"application/json","x-csrf-token":r.csrfToken},body:JSON.stringify(n)}).catch(()=>{})},[r.csrfToken]);t.useEffect(()=>{if(!r.csrfToken||!ee||!we)return;const n=setTimeout(()=>Oe({activeTerminalId:g,drawerOpen:ce,drawerTab:he,fileTreeRoot:Ee,fileTreeFollowMode:Se,selectedFile:ue,terminalScroll:je}),500);return()=>clearTimeout(n)},[g,ce,he,Ee,Se,ue,je,r.csrfToken,Oe,ee,we]),t.useEffect(()=>{if(!r.csrfToken||!ee||!we)return;const n=()=>Oe({activeTerminalId:g,drawerOpen:ce,drawerTab:he,fileTreeRoot:Ee,fileTreeFollowMode:Se,selectedFile:ue,terminalScroll:je});return window.addEventListener("pagehide",n),()=>window.removeEventListener("pagehide",n)},[g,ce,he,Ee,Se,ue,je,r.csrfToken,Oe,ee,we]);const Er=t.useCallback(n=>{Ae(n),le(!1)},[]),Sr=t.useCallback(()=>{if(E.length>=8)return;const n=`t-web-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;I(i=>i.length>=8?i:[...i,{id:n,title:`Terminal ${i.length+1}`}]),_(n)},[E.length]),Cr=t.useCallback(n=>{const i=E.find(S=>S.id===g);if(i!=null&&i.kind&&i.kind!=="webapp")return;if(i&&!i.kind){const S=G.current.get(i.id);S?S(n,!0):se.current.set(i.id,n),le(!1);return}const f=E.length>=8?E.find(S=>!S.kind):null,h=(f==null?void 0:f.id)??`t-web-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;f?se.current.set(h,n):I(S=>[...S,{id:h,title:`Terminal ${S.length+1}`,initialCommand:n}]),_(h),le(!1)},[g,E]);t.useEffect(()=>{if(!M.connected||!we||F.current)return;F.current=!0;let n=!1,i=!1,f;return B("term:list").then(h=>{if(n)return;let S=null;try{S=or(localStorage.getItem(U))}catch{}const W=no(S,h.tabs,z.current);I(W),_(J=>{const fe=z.current.find(re=>re.id===J&&re.kind&&re.kind!=="webapp");if(fe)return fe.id;const Z=(S==null?void 0:S.activeTerminalId)||V.current||J||de.id;return Z===de.id?de.id:W.some(re=>re.id===Z)?Z:de.id}),i=!0,b(!0)}).catch(()=>{n||(F.current=!1,f=setTimeout(()=>Y(h=>h+1),2e3))}),()=>{n=!0,clearTimeout(f),i||(F.current=!1)}},[M.connected,we,B,U,O]),t.useLayoutEffect(()=>{if(ee)try{const n=or(JSON.stringify({tabs:E,activeTerminalId:g}));localStorage.setItem(U,JSON.stringify(n))}catch{}},[E,g,ee,U]);const Tr=n=>{var f;if(n===de.id)return;const i=(f=E.find(h=>h.id===n))==null?void 0:f.kind;i==="remote-desktop"&&(m(0),R(!1),B("browser:unwatch").catch(()=>{})),!(!i&&!window.confirm("关闭页签会终止该终端进程,确认关闭?"))&&(I(h=>{var W;const S=h.filter(J=>J.id!==n);return g===n&&_(((W=S[0])==null?void 0:W.id)??null),S}),i||B("term:kill",{id:n}).catch(()=>{}))},Rr=t.useCallback(()=>{I(n=>{const i=n.find(f=>f.kind==="aihub");return i?(_(i.id),n):(_(ar.id),[...n,{...ar}])})},[]),Nr=t.useCallback(()=>{I(n=>{const i=n.find(f=>f.kind==="flowstudio");return i?(_(i.id),n):(_(sr.id),[...n,{...sr}])})},[]),Pr=t.useCallback(()=>{I(ir),_(ve.id)},[]);t.useEffect(()=>{const n=H("term:exited",i=>{const f=i==null?void 0:i.id;f&&(I(h=>{const S=h.filter(W=>W.id!==f);return _(W=>{var J;return W===f?((J=S[0])==null?void 0:J.id)??null:W}),S}),qe(h=>{if(!(f in h))return h;const S={...h};return delete S[f],S}))});return()=>{n()}},[H]);const Tt=t.useCallback(n=>{if(!g||E.length<2)return;const f=(E.findIndex(h=>h.id===g)+n+E.length)%E.length;_(E[f].id)},[g,E]),Rt=Math.max(0,E.findIndex(n=>n.id===g)),Lr=((Pt=E[Rt])==null?void 0:Pt.kind)==="webapp"?te.cssVars["--ui-term-col-bg"]:te.termHostBg,Ir={...ae.root,...te.cssVars,"--ui-active-content-bg":Lr,"--ui-terminal-bg":te.termHostBg,"--ui-primary-text":te.keybar.accentText,background:"var(--ui-root-bg)",color:"var(--ui-text)"},me=t.useCallback(()=>{xe.current=null,Ge(0),Ye(!1)},[]),Xe=t.useCallback(n=>{Math.abs(n)>=64&&E.length>1&&Tt(n<0?1:-1),me()},[E.length,Tt,me]),Mr=n=>n instanceof Element&&!!n.closest(".terminal-screen");t.useEffect(()=>{const n=i=>{var h;if(g!==de.id)return;const f=to(i,window.location.origin,((h=j.current)==null?void 0:h.contentWindow)??null);f&&(f.phase==="move"?(Ye(!0),Ge(f.deltaX)):f.phase==="end"?Xe(f.deltaX):me())};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)},[g,Xe,me]);const We=t.useCallback((n="smooth")=>{const i=jt.current;if(!i||!g)return;const f=i.querySelector(`[data-terminal-id="${g}"]`);if(!f)return;if(f===i.querySelector("[data-terminal-id]")){Qn(i);return}const h=i.querySelector(".terminal-connection"),S=(h==null?void 0:h.offsetWidth)??0,W=8,J=f.offsetLeft,fe=J+f.offsetWidth,Z=i.scrollLeft,re=Z+i.clientWidth-S;J<Z+W?i.scrollTo({left:Math.max(0,J-W),behavior:n}):fe>re-W&&i.scrollTo({left:fe-i.clientWidth+S+W,behavior:n})},[g]);return t.useLayoutEffect(()=>{if(!g)return;const n=E.length>Et.current;Et.current=E.length,We(n?"auto":"smooth")},[g,E.length,We]),t.useEffect(()=>{const n=()=>requestAnimationFrame(()=>We("auto"));return window.addEventListener("pageshow",n),()=>window.removeEventListener("pageshow",n)},[We]),e.jsxs("div",{className:`web-root ${y&&g===ve.id&&!a?"is-remote-fullscreen":""}`,style:Ir,children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:Yr}}),e.jsxs("div",{className:"terminal-tabs",children:[a&&e.jsxs("div",{className:"computer-page-heading",children:[e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":"返回电脑会话",title:"返回电脑会话",onClick:()=>s(null),children:e.jsx(cn,{size:18})}),e.jsx("span",{children:a.name}),e.jsx("a",{className:"file-drawer-toggle",href:a.url,target:"_blank",rel:"noopener noreferrer","aria-label":"在新页面打开当前页面",title:"打开原页面",children:e.jsx(ft,{size:16})})]}),e.jsx("div",{className:"terminal-tab-list",ref:jt,hidden:!!a,children:E.map(n=>e.jsxs("div",{"data-terminal-id":n.id,draggable:!0,className:`terminal-tab ${n.id===g?"active":""}`,onDragStart:()=>{Je.current=n.id},onDragOver:i=>i.preventDefault(),onDrop:i=>{i.preventDefault();const f=Je.current;Je.current=null,!(!f||f===n.id)&&I(h=>{const S=h.findIndex(Z=>Z.id===f),W=h.findIndex(Z=>Z.id===n.id);if(S<0||W<0)return h;const J=[...h],[fe]=J.splice(S,1);return J.splice(W,0,fe),B("term:reorder",{ids:J.filter(Z=>!Z.kind).map(Z=>Z.id)}).catch(()=>{}),J})},onClick:()=>_(n.id),onDoubleClick:()=>{var f;if(n.kind)return;const i=(f=window.prompt("页签名称",n.title))==null?void 0:f.trim();i&&B("term:rename",{id:n.id,title:i}).then(()=>I(h=>h.map(S=>S.id===n.id?{...S,title:i}:S))).catch(()=>{})},children:[e.jsx("span",{children:n.title}),n.kind!=="webapp"&&e.jsx("button",{tabIndex:-1,onClick:i=>{i.stopPropagation(),Tr(n.id)},children:"×"})]},n.id))}),e.jsx("button",{className:"terminal-add","aria-label":"新建终端页签",hidden:!!a,disabled:E.length>=8,onClick:Sr,children:"+"}),e.jsx("div",{className:"terminal-connection",children:e.jsx(Jr,{avatar:e.jsx(Pn,{username:((Lt=r.user)==null?void 0:Lt.username)??"?",connected:M.connected,accent:te.keybar.accent,accentText:te.keybar.accentText,selectedPageId:a==null?void 0:a.id,onSelectPage:u,onUpdatePage:p,configuration:De,csrfToken:r.csrfToken}),items:[{id:"refresh",content:e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":"刷新页面",title:"刷新页面",onClick:()=>a?d(n=>n+1):window.location.reload(),children:e.jsx(be,{size:17,"aria-hidden":"true"})})},{id:"collaboration",content:e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":"打开群聊看板",title:"群聊看板",onClick:()=>{s(null),I(oo),_(Ue.id)},children:e.jsx(ut,{size:17,"aria-hidden":"true"})})},{id:"install",content:e.jsx(yn,{})},{id:"remote",content:e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":"打开远程桌面",title:"远程桌面 · 浏览器直播",onClick:()=>{s(null),Pr()},children:e.jsx(et,{size:17,"aria-hidden":"true"})})},{id:"ai-hub",content:e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":"打开 AI Hub",title:"AI Hub · 多模型对比",onClick:()=>{s(null),Rr()},children:e.jsx(ur,{size:17,"aria-hidden":"true"})})},{id:"flow",content:e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":"打开数字人",title:"数字人 · Flow Studio",onClick:()=>{s(null),Nr()},children:e.jsx(pt,{size:17,"aria-hidden":"true"})})},{id:"theme",content:e.jsx(Jn,{themeId:oe,onThemeChange:yt})},{id:"files",content:e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":ce?"关闭我的文件":"打开我的文件",title:"我的文件","aria-expanded":ce,onClick:()=>{s(null),le(n=>!n)},children:e.jsx(dr,{size:17,"aria-hidden":"true"})})}].filter(n=>De.settings.visibleTools.some(i=>i===n.id)).sort((n,i)=>De.settings.visibleTools.findIndex(f=>f===n.id)-De.settings.visibleTools.findIndex(f=>f===i.id))})})]}),e.jsxs("main",{className:`workspace ${ce?"show-tree":""} ${ue?"has-preview":""}`,hidden:!!a,style:ae.workspace,children:[e.jsx("section",{className:"term-col",style:ae.termCol,onPointerDownCapture:n=>{n.pointerType!=="touch"||!Mr(n.target)||(me(),xe.current={x:n.clientX,y:n.clientY,axis:"pending",pointerId:n.pointerId})},onPointerMoveCapture:n=>{const i=xe.current;if(!i||n.pointerId!==i.pointerId||n.pointerType!=="touch")return;const f=n.clientX-i.x,h=n.clientY-i.y;if(i.axis==="pending"){if(Math.max(Math.abs(f),Math.abs(h))<=8)return;if(Math.abs(h)>=Math.abs(f)*1.2){xe.current=null;return}i.axis="horizontal",Ye(!0);const S=W=>{window.removeEventListener("pointerup",S),window.removeEventListener("pointercancel",S),xe.current===i&&me()};window.addEventListener("pointerup",S),window.addEventListener("pointercancel",S)}i.axis==="horizontal"&&(n.preventDefault(),Ge(f))},onPointerUpCapture:n=>{const i=xe.current;if(!i||n.pointerId!==i.pointerId)return;const f=n.clientX-i.x;i.axis==="horizontal"&&Math.abs(f)>=64?Xe(f):me()},onPointerCancelCapture:me,children:e.jsx("div",{className:"terminal-track",style:{transform:`translate3d(calc(${-Rt*100}% + ${kr}px),0,0)`,transition:jr?"none":"transform 260ms cubic-bezier(.22,.8,.32,1)"},children:E.map(n=>e.jsx("div",{className:"terminal-slide",style:{position:"relative"},children:n.kind==="webapp"?e.jsx("iframe",{ref:j,className:"webapp-frame",src:tt("/app/"),title:n.title,onLoad:()=>pe(oe)}):n.kind==="collaboration-dashboard"?e.jsx(nr,{title:"群聊看板",onFrame:i=>{C.current=i},onLoad:()=>pe(oe)}):n.kind==="collaboration"?e.jsx(nr,{groupId:n.groupId||"",title:n.title,onFrame:i=>{i?T.current.set(n.id,i):T.current.delete(n.id)},onLoad:()=>pe(oe)},`${n.id}-${c[n.groupId||""]||0}`):n.kind==="remote-desktop"?e.jsxs("div",{style:{height:"100%",background:"var(--ui-term-col-bg, #101014)"},"aria-busy":!x,children:[e.jsx("iframe",{ref:v,className:"webapp-frame",style:{visibility:x?"visible":"hidden"},src:tt("/app/?view=remote-desktop"),title:"远程桌面",onLoad:()=>pe(oe)}),!x&&e.jsx(Be,{label:"REMOTE DESKTOP",title:"正在打开远程桌面",caption:"正在准备桌面与连接",icon:e.jsx(et,{size:36,strokeWidth:1.5})})]}):n.kind==="aihub"?e.jsx(co,{visible:n.id===g,rpc:B}):n.kind==="flowstudio"?e.jsx(lo,{visible:n.id===g}):e.jsx(io,{terminalId:n.id,title:n.title,initialCommand:n.initialCommand,visible:n.id===g,state:M,rpc:B,onEvent:H,onTerminalData:ne,onTerminalReset:$,sendTerminalInput:P,keyOrder:Ve,keybarHidden:He,onKeyOrderChange:wt,onKeybarHiddenChange:bt,terminalTheme:te,initialScrollLine:je[n.id]??null,onScrollLineChange:i=>qe(f=>f[n.id]===i?f:{...f,[n.id]:i}),onRegisterFill:i=>Ie(n.id,i),onCwdChange:i=>i&&ie(f=>({...f,[n.id]:i}))})},n.id))})}),ce&&e.jsx("div",{className:"drawer-mask",onClick:()=>le(!1)}),e.jsxs("aside",{className:`tree-col ${ce?"tree-col-open":""}`,style:ae.treeCol,children:[e.jsxs("div",{className:"tree-head",style:ae.treeHead,children:[e.jsx("button",{className:he==="files"?"drawer-tab-active":"",onClick:()=>ze("files"),children:"文件"}),e.jsx("button",{className:he==="history"?"drawer-tab-active":"",onClick:()=>ze("history"),children:"历史"}),e.jsx("span",{className:"tree-cwd",style:ae.treeCwd,children:St??""}),e.jsx("button",{style:{...ae.iconBtn,marginLeft:"auto",flexShrink:0},onClick:()=>le(!1),"aria-label":"close drawer",children:e.jsx(ke,{size:15,"aria-hidden":"true"})})]}),he==="files"?e.jsx(ao,{ready:X>0,followCwd:!0,cwd:St,gateway:A,onOpenFile:Er,selectedPath:ue,initialRoot:Ee,initialFollow:Se,revealRequest:wr,onTreeStateChange:(n,i)=>{ht(n),gt(i)}}):e.jsx(Yn,{csrfToken:r.csrfToken,terminalId:((It=E.find(n=>n.id===g))==null?void 0:It.kind)==="webapp"?null:g,pinnedCommands:Ke,onPinnedCommandsChange:xt,onFill:Me,onExecute:Cr}),e.jsxs("div",{style:ae.treeFoot,children:[e.jsx("span",{style:ae.treeFootDot}),e.jsx("span",{children:"实时同步"})]})]}),ue&&e.jsx("section",{className:"preview-col",style:ae.previewCol,children:e.jsx(so,{path:ue,gateway:A,onClose:()=>Ae(null)})})]}),a&&e.jsx(An,{page:a,reloadKey:l},a.id)]})}const ae={root:{height:"100dvh",display:"flex",flexDirection:"column",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif',overflow:"hidden"},iconBtn:{minWidth:28,height:28,borderRadius:7,border:"1px solid var(--ui-tabbar-border, #303442)",background:"var(--ui-tab-bg, #202029)",color:"var(--ui-tab-text, #aaaab8)",fontSize:13},workspace:{flex:1,minHeight:0,display:"grid",position:"relative"},treeCol:{background:"var(--ui-tree-bg, #121218)",minHeight:0,flexDirection:"column"},treeHead:{display:"flex",alignItems:"center",gap:8,padding:"10px 12px 4px",fontSize:11,textTransform:"uppercase",letterSpacing:1,color:"#778",flexShrink:0},treeCwd:{fontSize:10,color:"#556",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:150,textTransform:"none",letterSpacing:0},treeFoot:{display:"flex",alignItems:"center",gap:7,minHeight:31,padding:"6px 11px calc(env(safe-area-inset-bottom) + 6px)",borderTop:"1px solid var(--ui-tabbar-border, #282832)",boxShadow:"0 -5px 16px rgba(0,0,0,.22)",background:"var(--ui-tab-bg, #15151c)",color:"var(--ui-connection-text, #777789)",fontSize:10.5,flexShrink:0},treeFootDot:{width:6,height:6,borderRadius:99,background:"var(--ui-success, #9ece6a)",boxShadow:"0 0 0 2px color-mix(in srgb, var(--ui-success, #9ece6a) 12%, transparent)",flexShrink:0},termCol:{minWidth:0,minHeight:0,display:"flex",flexDirection:"column",background:"var(--ui-term-col-bg, #101014)",gridColumn:1,overflow:"hidden"},previewCol:{minWidth:0,minHeight:0}},jo=Object.freeze(Object.defineProperty({__proto__:null,default:uo},Symbol.toStringTag,{value:"Module"}));export{Be as F,jo as p,Qn as r};
|
|
96
|
+
`})]})}function or(r){try{const o=JSON.parse(r||"null");if(!o||!Array.isArray(o.tabs))return null;const a=new Set,s=new Set(["webapp","aihub","flowstudio","remote-desktop","collaboration","collaboration-dashboard"]),l=[];for(const d of o.tabs.slice(0,100))!d||typeof d.id!="string"||typeof d.title!="string"||a.has(d.id)||d.kind!==void 0&&!s.has(d.kind)||d.kind==="collaboration"&&typeof d.groupId!="string"||(a.add(d.id),l.push({id:d.id,title:d.title,...d.kind?{kind:d.kind}:{},...typeof d.groupId=="string"?{groupId:d.groupId}:{}}));return{tabs:l,activeTerminalId:typeof o.activeTerminalId=="string"?o.activeTerminalId:null}}catch{return null}}function no(r,o,a){const s=new Map(o.filter(u=>u.status==="active"||u.status==="detached").map(u=>[u.id,{id:u.id,title:u.title}])),l=[],d=new Set;for(const u of[...(r==null?void 0:r.tabs)??[],...a,...s.values()])d.has(u.id)||!u.kind&&!s.has(u.id)||(d.add(u.id),l.push(u.kind?u:s.get(u.id)));return l}const ve={id:"remote-desktop",title:"远程桌面",kind:"remote-desktop"};function ir(r){const o=r.find(a=>a.kind==="remote-desktop");return o?r.map(a=>a===o?{...ve}:a):[...r,{...ve}]}const Ue={id:"collaboration-dashboard",title:"群聊看板",kind:"collaboration-dashboard"};function oo(r){return r.some(o=>o.id===Ue.id)?r:[...r,{...Ue}]}const io=Le(()=>Pe(()=>import("./TerminalPane-BxEtw8rn.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]),import.meta.url),{ssr:!1}),ao=Le(()=>Pe(()=>import("./FileTree-DrpruRST.js"),__vite__mapDeps([11,1,2,12,5,13,7]),import.meta.url),{ssr:!1}),so=Le(()=>Pe(()=>import("./FilePreview-C4gxZRtw.js").then(r=>r.b),__vite__mapDeps([14,1,2,6,15,13,7,5,16]),import.meta.url),{ssr:!1}),co=Le(()=>Pe(()=>import("./AiHubPane-Cd-7gwJs.js"),__vite__mapDeps([17,1,2,5,13,18]),import.meta.url),{ssr:!1}),lo=Le(()=>Pe(()=>import("./FlowStudioPane-BjOuLwks.js"),__vite__mapDeps([19,1,2,20,4,5,6,7,3,8,9]),import.meta.url),{ssr:!1,loading:()=>e.jsx(Be,{})});function uo(){return e.jsx(Vn,{children:(r,o)=>e.jsx(fo,{auth:r,onWorkspaceReady:o})})}const de={id:"webapp-agent",title:"智能助手",kind:"webapp"},ar={id:"ai-hub",title:"AI Hub",kind:"aihub"},sr={id:"flow-studio",title:"Flow Studio",kind:"flowstudio"};function po(){var r;return typeof document>"u"?Xr:rt((r=document.getElementById("web-theme-root"))==null?void 0:r.dataset.webTheme).id}const mo="agent-web-shell:skin:v1";function fo({auth:r,onWorkspaceReady:o}){var Nt,Pt,Lt,It;const[a,s]=t.useState(null),[l,d]=t.useState(0),u=t.useCallback(n=>{if((n==null?void 0:n.openMode)==="new-tab"){window.open(n.url,"_blank","noopener,noreferrer");return}s(n)},[]),p=t.useCallback(n=>s((n==null?void 0:n.openMode)==="current"?n:null),[]),j=t.useRef(null),v=t.useRef(null),C=t.useRef(null),[c,k]=t.useState({}),T=t.useRef(new Map),[L,m]=t.useState(0),[y,w]=t.useState(!1),[x,R]=t.useState(!1),N=t.useRef(()=>{}),D=t.useCallback(n=>{var f;const i=Un(n);if(!(!i||i.type!==lt.watcherFrame)){N.current(i.channelId,i.sequence);for(const h of[j,v]){if(!((f=h.current)!=null&&f.contentWindow))continue;const S=i.payload.slice().buffer;h.current.contentWindow.postMessage({type:Gr,channelId:i.channelId,sequence:i.sequence,data:S},window.location.origin,[S])}}},[]),{state:M,epoch:X,rpc:B,onEvent:H,onTerminalData:oe,onTerminalReset:$,sendTerminalInput:P}=qn(D,r.getWsNonce,r.refresh),A=t.useMemo(()=>({request:(n,i,f)=>B(n,i,f),subscribe:(n,i)=>H("fs:event",i)}),[H,B]);N.current=(n,i)=>{B("browser:frame-ack",{channelId:n,sequence:i}).catch(()=>{})};const[E,I]=t.useState([{...de}]),z=t.useRef(E);z.current=E;const[g,_]=t.useState(de.id),[K,ie]=t.useState({}),F=t.useRef(!1),[ee,b]=t.useState(!1),[O,Y]=t.useState(0),U=`agentroam:workspace:${typeof window>"u"?"":Ne()}:${((Nt=r.user)==null?void 0:Nt.id)??""}`,V=t.useRef(null),G=t.useRef(new Map),se=t.useRef(new Map),Ie=t.useCallback((n,i)=>{G.current.set(n,i);const f=window.setTimeout(()=>{if(G.current.get(n)!==i)return;const h=se.current.get(n);h&&(se.current.delete(n),i(h,!0))},180);return()=>{window.clearTimeout(f),G.current.get(n)===i&&G.current.delete(n)}},[]),Me=t.useCallback(n=>{var f;if(!g||(f=E.find(h=>h.id===g))!=null&&f.kind)return;const i=G.current.get(g);i?i(n):B("term:input",{id:g,data:`${n}`}).catch(()=>{}),le(!1)},[g,B,E]),[we,br]=t.useState(!1),[je,qe]=t.useState({}),[ue,Ae]=t.useState(null),[ce,le]=t.useState(!1),[he,ze]=t.useState("files"),[Ee,ht]=t.useState(null),[Se,gt]=t.useState(!0),[wr,xr]=t.useState(null),[He,bt]=t.useState(!1),[Ve,wt]=t.useState([]),[Ke,xt]=t.useState(_n()),[re,yt]=t.useState(po),[vt,yr]=t.useState(!1),De=On(r.csrfToken),[kt,vr]=t.useState(!1),te=rt(re),xe=t.useRef(null),[kr,Ge]=t.useState(0),[jr,Ye]=t.useState(!1),Je=t.useRef(null),jt=t.useRef(null),pe=t.useCallback(n=>{var f;const i=[j.current,v.current,C.current,...T.current.values()];for(const h of i)(f=h==null?void 0:h.contentWindow)==null||f.postMessage({type:mo,skin:n},window.location.origin)},[]);t.useEffect(()=>{pe(re)},[re,pe]),t.useEffect(()=>{const n=te.cssVars["--ui-root-bg"],i=te.cssVars["--ui-color-scheme"],f=document.getElementById("web-theme-root");for(const[S,W]of Object.entries(te.cssVars))f==null||f.style.setProperty(S,W);f&&(f.dataset.webTheme=te.id),document.documentElement.style.background=n,document.documentElement.style.colorScheme=i,document.body.style.background=n,document.body.style.colorScheme=i;let h=document.querySelector('meta[name="theme-color"]');h||(h=document.createElement("meta"),h.name="theme-color",document.head.append(h)),h.content=te.cssVars["--ui-tabbar-bg"]},[te]),t.useEffect(()=>{const n=i=>{var Mt,At,zt,Dt,Ot,Wt,_t,Ft,$t,Ut,Bt;const f=((Mt=C.current)==null?void 0:Mt.contentWindow)??null,h=un(i,window.location.origin,f);if(h){I(q=>h.deleted?q.filter(Q=>Q.groupId!==h.groupId):q.map(Q=>Q.groupId===h.groupId?{...Q,title:h.title}:Q)),h.deleted?_(q=>q===`collaboration-${h.groupId}`?Ue.id:q):k(q=>({...q,[h.groupId]:(q[h.groupId]||0)+1}));return}const S=pn(i,window.location.origin,i.source===f?f:((At=j.current)==null?void 0:At.contentWindow)??null);if(S){const q=`collaboration-${S.groupId}`;I(Q=>Q.some(_e=>_e.id===q)?Q:[...Q,{id:q,title:S.title,kind:"collaboration",groupId:S.groupId}]),_(q);return}const W=((zt=v.current)==null?void 0:zt.contentWindow)??null,J=fn(i,window.location.origin,W);if(J!==null){w(J);return}if(rr(i,window.location.origin,W)){w(!1),m(q=>q+1),R(!1),pe(re);return}if(W&&i.origin===window.location.origin&&i.source===W&&((Dt=i.data)==null?void 0:Dt.type)===hn){R(!0);return}if(i.origin===window.location.origin&&i.source===W&&W&&((Ot=i.data)==null?void 0:Ot.type)===gn){w(!1),B("browser:unwatch").catch(()=>{}),I(q=>q.filter(Q=>Q.kind!=="remote-desktop")),m(0),R(!1),_(de.id);return}if(Qr(i,window.location.origin,((Wt=j.current)==null?void 0:Wt.contentWindow)??null)){I(ir),_(ve.id);return}if(rr(i,window.location.origin,((_t=j.current)==null?void 0:_t.contentWindow)??null)){vr(!0),o();return}const Z=(Ft=[...T.current.values()].find(q=>q.contentWindow===i.source))==null?void 0:Ft.contentWindow,ne=on(i,window.location.origin,Z??(($t=j.current)==null?void 0:$t.contentWindow)??null);if(ne){const q=Q=>{ze("files"),le(!Gt(Q)),Ae(Q),Gt(Q)||xr({...ne,path:Q})};ne.path.startsWith("~/")?B("hello").then(({home:Q})=>{const _e=an(ne.path,null,Q);_e&&q(_e)}).catch(()=>{}):q(ne.path);return}const ge=i.source===W&&W?W:((Ut=j.current)==null?void 0:Ut.contentWindow)??null,ye=Zr(i,window.location.origin,ge);if(ye){B(ye.method,{...ye.payload,...ye.method==="browser:watch"?{frameAck:!0}:{}}).then(q=>{ge==null||ge.postMessage({type:Vt,id:ye.id,ok:!0,result:q},window.location.origin)},q=>{ge==null||ge.postMessage({type:Vt,id:ye.id,ok:!1,error:q.message||"浏览器操作失败",code:q.code},window.location.origin)});return}Fn(i,window.location.origin,[((Bt=j.current)==null?void 0:Bt.contentWindow)??null,f,...[...T.current.values()].map(q=>q.contentWindow)],B)};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)},[o,B,pe,re]),t.useEffect(()=>{const n=h=>{var S,W;for(const J of[j,v])(W=(S=J.current)==null?void 0:S.contentWindow)==null||W.postMessage({type:Qe,event:h},window.location.origin)},f=["browser:session","browser:frame","browser:state","browser:closed","browser:webrtc"].map(h=>H(h,n));return()=>f.forEach(h=>h())},[H]),t.useEffect(()=>{var n,i;kt&&((i=(n=j.current)==null?void 0:n.contentWindow)==null||i.postMessage({type:Qe,event:{type:"browser:connection",connected:M.connected,epoch:X}},window.location.origin))},[M.connected,X,kt]),t.useEffect(()=>{var n,i;L&&((i=(n=v.current)==null?void 0:n.contentWindow)==null||i.postMessage({type:mn,visible:g===ve.id},window.location.origin))},[g,L]),t.useEffect(()=>{var n,i;L&&((i=(n=v.current)==null?void 0:n.contentWindow)==null||i.postMessage({type:Qe,event:{type:"browser:connection",connected:M.connected,epoch:X}},window.location.origin))},[M.connected,X,L]);const Et=t.useRef(0),St=g?K[g]??null:null;t.useEffect(()=>{const n=window.visualViewport;let i=null,f="";const h=()=>{const S=Xn(n,{height:window.innerHeight,width:window.innerWidth}),W=`${S.width}x${S.height}+${S.top}+${S.left}`;W!==f&&(f=W,document.documentElement.style.setProperty("--vv-height",`${S.height}px`),document.documentElement.style.setProperty("--vv-width",`${S.width}px`),document.documentElement.style.setProperty("--vv-top",`${S.top}px`),document.documentElement.style.setProperty("--vv-left",`${S.left}px`),i&&window.clearTimeout(i),i=window.setTimeout(h,250))};return h(),n==null||n.addEventListener("resize",h),n==null||n.addEventListener("scroll",h),window.addEventListener("orientationchange",h),window.addEventListener("resize",h),document.addEventListener("visibilitychange",h),window.addEventListener("pageshow",h),()=>{n==null||n.removeEventListener("resize",h),n==null||n.removeEventListener("scroll",h),window.removeEventListener("orientationchange",h),window.removeEventListener("resize",h),document.removeEventListener("visibilitychange",h),window.removeEventListener("pageshow",h),i&&window.clearTimeout(i),document.documentElement.style.removeProperty("--vv-height"),document.documentElement.style.removeProperty("--vv-width"),document.documentElement.style.removeProperty("--vv-top"),document.documentElement.style.removeProperty("--vv-left")}},[]),t.useEffect(()=>{fetch("/api/web-console/preferences",{credentials:"same-origin"}).then(n=>n.json()).then(n=>{var i,f,h,S;typeof((i=n.preferences)==null?void 0:i.keybarHidden)=="boolean"&&bt(n.preferences.keybarHidden),Array.isArray((f=n.preferences)==null?void 0:f.keyOrder)&&wt(n.preferences.keyOrder),Array.isArray((h=n.preferences)==null?void 0:h.pinnedCommands)&&xt(n.preferences.pinnedCommands),(S=n.preferences)!=null&&S.theme&&yt(rt(n.preferences.theme).id)}).catch(()=>{}).finally(()=>yr(!0)),fetch("/api/web-console/device-state",{credentials:"same-origin"}).then(n=>n.json()).then(n=>{const i=n.deviceState;i!=null&&i.drawerTab&&ze(i.drawerTab),i!=null&&i.activeTerminalId&&(V.current=i.activeTerminalId),typeof(i==null?void 0:i.drawerOpen)=="boolean"&&le(i.drawerOpen),i!=null&&i.fileTreeRoot&&ht(i.fileTreeRoot),typeof(i==null?void 0:i.fileTreeFollowMode)=="boolean"&>(i.fileTreeFollowMode),i!=null&&i.selectedFile&&Ae(i.selectedFile),i!=null&&i.terminalScroll&&typeof i.terminalScroll=="object"&&qe(i.terminalScroll)}).catch(()=>{}).finally(()=>br(!0))},[]);const Ct=t.useCallback(n=>{fetch("/api/web-console/preferences",{method:"PATCH",credentials:"same-origin",headers:{"content-type":"application/json","x-csrf-token":r.csrfToken},body:JSON.stringify(n)}).catch(()=>{})},[r.csrfToken]);t.useEffect(()=>{if(!vt)return;const n=setTimeout(()=>Ct({keybarHidden:He,keyOrder:Ve,pinnedCommands:Ke,theme:re}),500);return()=>clearTimeout(n)},[He,Ve,Ke,re,vt,Ct]);const Oe=t.useCallback(n=>{r.csrfToken&&fetch("/api/web-console/device-state",{method:"PUT",credentials:"same-origin",keepalive:!0,headers:{"content-type":"application/json","x-csrf-token":r.csrfToken},body:JSON.stringify(n)}).catch(()=>{})},[r.csrfToken]);t.useEffect(()=>{if(!r.csrfToken||!ee||!we)return;const n=setTimeout(()=>Oe({activeTerminalId:g,drawerOpen:ce,drawerTab:he,fileTreeRoot:Ee,fileTreeFollowMode:Se,selectedFile:ue,terminalScroll:je}),500);return()=>clearTimeout(n)},[g,ce,he,Ee,Se,ue,je,r.csrfToken,Oe,ee,we]),t.useEffect(()=>{if(!r.csrfToken||!ee||!we)return;const n=()=>Oe({activeTerminalId:g,drawerOpen:ce,drawerTab:he,fileTreeRoot:Ee,fileTreeFollowMode:Se,selectedFile:ue,terminalScroll:je});return window.addEventListener("pagehide",n),()=>window.removeEventListener("pagehide",n)},[g,ce,he,Ee,Se,ue,je,r.csrfToken,Oe,ee,we]);const Er=t.useCallback(n=>{Ae(n),le(!1)},[]),Sr=t.useCallback(()=>{if(E.length>=8)return;const n=`t-web-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;I(i=>i.length>=8?i:[...i,{id:n,title:`Terminal ${i.length+1}`}]),_(n)},[E.length]),Cr=t.useCallback(n=>{const i=E.find(S=>S.id===g);if(i!=null&&i.kind&&i.kind!=="webapp")return;if(i&&!i.kind){const S=G.current.get(i.id);S?S(n,!0):se.current.set(i.id,n),le(!1);return}const f=E.length>=8?E.find(S=>!S.kind):null,h=(f==null?void 0:f.id)??`t-web-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;f?se.current.set(h,n):I(S=>[...S,{id:h,title:`Terminal ${S.length+1}`,initialCommand:n}]),_(h),le(!1)},[g,E]);t.useEffect(()=>{if(!M.connected||!we||F.current)return;F.current=!0;let n=!1,i=!1,f;return B("term:list").then(h=>{if(n)return;let S=null;try{S=or(localStorage.getItem(U))}catch{}const W=no(S,h.tabs,z.current);I(W),_(J=>{const fe=z.current.find(ne=>ne.id===J&&ne.kind&&ne.kind!=="webapp");if(fe)return fe.id;const Z=(S==null?void 0:S.activeTerminalId)||V.current||J||de.id;return Z===de.id?de.id:W.some(ne=>ne.id===Z)?Z:de.id}),i=!0,b(!0)}).catch(()=>{n||(F.current=!1,f=setTimeout(()=>Y(h=>h+1),2e3))}),()=>{n=!0,clearTimeout(f),i||(F.current=!1)}},[M.connected,we,B,U,O]),t.useLayoutEffect(()=>{if(ee)try{const n=or(JSON.stringify({tabs:E,activeTerminalId:g}));localStorage.setItem(U,JSON.stringify(n))}catch{}},[E,g,ee,U]);const Tr=n=>{var f;if(n===de.id)return;const i=(f=E.find(h=>h.id===n))==null?void 0:f.kind;i==="remote-desktop"&&(m(0),R(!1),B("browser:unwatch").catch(()=>{})),!(!i&&!window.confirm("关闭页签会终止该终端进程,确认关闭?"))&&(I(h=>{var W;const S=h.filter(J=>J.id!==n);return g===n&&_(((W=S[0])==null?void 0:W.id)??null),S}),i||B("term:kill",{id:n}).catch(()=>{}))},Rr=t.useCallback(()=>{I(n=>{const i=n.find(f=>f.kind==="aihub");return i?(_(i.id),n):(_(ar.id),[...n,{...ar}])})},[]),Nr=t.useCallback(()=>{I(n=>{const i=n.find(f=>f.kind==="flowstudio");return i?(_(i.id),n):(_(sr.id),[...n,{...sr}])})},[]),Pr=t.useCallback(()=>{I(ir),_(ve.id)},[]);t.useEffect(()=>{const n=H("term:exited",i=>{const f=i==null?void 0:i.id;f&&(I(h=>{const S=h.filter(W=>W.id!==f);return _(W=>{var J;return W===f?((J=S[0])==null?void 0:J.id)??null:W}),S}),qe(h=>{if(!(f in h))return h;const S={...h};return delete S[f],S}))});return()=>{n()}},[H]);const Tt=t.useCallback(n=>{if(!g||E.length<2)return;const f=(E.findIndex(h=>h.id===g)+n+E.length)%E.length;_(E[f].id)},[g,E]),Rt=Math.max(0,E.findIndex(n=>n.id===g)),Lr=((Pt=E[Rt])==null?void 0:Pt.kind)==="webapp"?te.cssVars["--ui-term-col-bg"]:te.termHostBg,Ir={...ae.root,...te.cssVars,"--ui-active-content-bg":Lr,"--ui-terminal-bg":te.termHostBg,"--ui-primary-text":te.keybar.accentText,background:"var(--ui-root-bg)",color:"var(--ui-text)"},me=t.useCallback(()=>{xe.current=null,Ge(0),Ye(!1)},[]),Xe=t.useCallback(n=>{Math.abs(n)>=64&&E.length>1&&Tt(n<0?1:-1),me()},[E.length,Tt,me]),Mr=n=>n instanceof Element&&!!n.closest(".terminal-screen");t.useEffect(()=>{const n=i=>{var h;if(g!==de.id)return;const f=to(i,window.location.origin,((h=j.current)==null?void 0:h.contentWindow)??null);f&&(f.phase==="move"?(Ye(!0),Ge(f.deltaX)):f.phase==="end"?Xe(f.deltaX):me())};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)},[g,Xe,me]);const We=t.useCallback((n="smooth")=>{const i=jt.current;if(!i||!g)return;const f=i.querySelector(`[data-terminal-id="${g}"]`);if(!f)return;if(f===i.querySelector("[data-terminal-id]")){Qn(i);return}const h=i.querySelector(".terminal-connection"),S=(h==null?void 0:h.offsetWidth)??0,W=8,J=f.offsetLeft,fe=J+f.offsetWidth,Z=i.scrollLeft,ne=Z+i.clientWidth-S;J<Z+W?i.scrollTo({left:Math.max(0,J-W),behavior:n}):fe>ne-W&&i.scrollTo({left:fe-i.clientWidth+S+W,behavior:n})},[g]);return t.useLayoutEffect(()=>{if(!g)return;const n=E.length>Et.current;Et.current=E.length,We(n?"auto":"smooth")},[g,E.length,We]),t.useEffect(()=>{const n=()=>requestAnimationFrame(()=>We("auto"));return window.addEventListener("pageshow",n),()=>window.removeEventListener("pageshow",n)},[We]),e.jsxs("div",{className:`web-root ${y&&g===ve.id&&!a?"is-remote-fullscreen":""}`,style:Ir,children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:Yr}}),e.jsxs("div",{className:"terminal-tabs",children:[a&&e.jsxs("div",{className:"computer-page-heading",children:[e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":"返回电脑会话",title:"返回电脑会话",onClick:()=>s(null),children:e.jsx(cn,{size:18})}),e.jsx("span",{children:a.name}),e.jsx("a",{className:"file-drawer-toggle",href:a.url,target:"_blank",rel:"noopener noreferrer","aria-label":"在新页面打开当前页面",title:"打开原页面",children:e.jsx(ft,{size:16})})]}),e.jsx("div",{className:"terminal-tab-list",ref:jt,hidden:!!a,children:E.map(n=>e.jsxs("div",{"data-terminal-id":n.id,draggable:!0,className:`terminal-tab ${n.id===g?"active":""}`,onDragStart:()=>{Je.current=n.id},onDragOver:i=>i.preventDefault(),onDrop:i=>{i.preventDefault();const f=Je.current;Je.current=null,!(!f||f===n.id)&&I(h=>{const S=h.findIndex(Z=>Z.id===f),W=h.findIndex(Z=>Z.id===n.id);if(S<0||W<0)return h;const J=[...h],[fe]=J.splice(S,1);return J.splice(W,0,fe),B("term:reorder",{ids:J.filter(Z=>!Z.kind).map(Z=>Z.id)}).catch(()=>{}),J})},onClick:()=>_(n.id),onDoubleClick:()=>{var f;if(n.kind)return;const i=(f=window.prompt("页签名称",n.title))==null?void 0:f.trim();i&&B("term:rename",{id:n.id,title:i}).then(()=>I(h=>h.map(S=>S.id===n.id?{...S,title:i}:S))).catch(()=>{})},children:[e.jsx("span",{children:n.title}),n.kind!=="webapp"&&e.jsx("button",{tabIndex:-1,onClick:i=>{i.stopPropagation(),Tr(n.id)},children:"×"})]},n.id))}),e.jsx("button",{className:"terminal-add","aria-label":"新建终端页签",hidden:!!a,disabled:E.length>=8,onClick:Sr,children:"+"}),e.jsx("div",{className:"terminal-connection",children:e.jsx(Jr,{glass:re==="glass",avatar:e.jsx(Pn,{username:((Lt=r.user)==null?void 0:Lt.username)??"?",connected:M.connected,accent:te.keybar.accent,accentText:te.keybar.accentText,selectedPageId:a==null?void 0:a.id,onSelectPage:u,onUpdatePage:p,configuration:De,csrfToken:r.csrfToken}),items:[{id:"refresh",content:e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":"刷新页面",title:"刷新页面",onClick:()=>a?d(n=>n+1):window.location.reload(),children:e.jsx(be,{size:17,"aria-hidden":"true"})})},{id:"collaboration",content:e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":"打开群聊看板",title:"群聊看板",onClick:()=>{s(null),I(oo),_(Ue.id)},children:e.jsx(ut,{size:17,"aria-hidden":"true"})})},{id:"install",content:e.jsx(yn,{})},{id:"remote",content:e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":"打开远程桌面",title:"远程桌面 · 浏览器直播",onClick:()=>{s(null),Pr()},children:e.jsx(et,{size:17,"aria-hidden":"true"})})},{id:"ai-hub",content:e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":"打开 AI Hub",title:"AI Hub · 多模型对比",onClick:()=>{s(null),Rr()},children:e.jsx(ur,{size:17,"aria-hidden":"true"})})},{id:"flow",content:e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":"打开数字人",title:"数字人 · Flow Studio",onClick:()=>{s(null),Nr()},children:e.jsx(pt,{size:17,"aria-hidden":"true"})})},{id:"theme",content:e.jsx(Jn,{themeId:re,onThemeChange:yt})},{id:"files",content:e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":ce?"关闭我的文件":"打开我的文件",title:"我的文件","aria-expanded":ce,onClick:()=>{s(null),le(n=>!n)},children:e.jsx(dr,{size:17,"aria-hidden":"true"})})}].filter(n=>De.settings.visibleTools.some(i=>i===n.id)).sort((n,i)=>De.settings.visibleTools.findIndex(f=>f===n.id)-De.settings.visibleTools.findIndex(f=>f===i.id))})})]}),e.jsxs("main",{className:`workspace ${ce?"show-tree":""} ${ue?"has-preview":""}`,hidden:!!a,style:ae.workspace,children:[e.jsx("section",{className:"term-col",style:ae.termCol,onPointerDownCapture:n=>{n.pointerType!=="touch"||!Mr(n.target)||(me(),xe.current={x:n.clientX,y:n.clientY,axis:"pending",pointerId:n.pointerId})},onPointerMoveCapture:n=>{const i=xe.current;if(!i||n.pointerId!==i.pointerId||n.pointerType!=="touch")return;const f=n.clientX-i.x,h=n.clientY-i.y;if(i.axis==="pending"){if(Math.max(Math.abs(f),Math.abs(h))<=8)return;if(Math.abs(h)>=Math.abs(f)*1.2){xe.current=null;return}i.axis="horizontal",Ye(!0);const S=W=>{window.removeEventListener("pointerup",S),window.removeEventListener("pointercancel",S),xe.current===i&&me()};window.addEventListener("pointerup",S),window.addEventListener("pointercancel",S)}i.axis==="horizontal"&&(n.preventDefault(),Ge(f))},onPointerUpCapture:n=>{const i=xe.current;if(!i||n.pointerId!==i.pointerId)return;const f=n.clientX-i.x;i.axis==="horizontal"&&Math.abs(f)>=64?Xe(f):me()},onPointerCancelCapture:me,children:e.jsx("div",{className:"terminal-track",style:{transform:`translate3d(calc(${-Rt*100}% + ${kr}px),0,0)`,transition:jr?"none":"transform 260ms cubic-bezier(.22,.8,.32,1)"},children:E.map(n=>e.jsx("div",{className:"terminal-slide",style:{position:"relative"},children:n.kind==="webapp"?e.jsx("iframe",{ref:j,className:"webapp-frame",src:tt("/app/"),title:n.title,onLoad:()=>pe(re)}):n.kind==="collaboration-dashboard"?e.jsx(nr,{title:"群聊看板",onFrame:i=>{C.current=i},onLoad:()=>pe(re)}):n.kind==="collaboration"?e.jsx(nr,{groupId:n.groupId||"",title:n.title,onFrame:i=>{i?T.current.set(n.id,i):T.current.delete(n.id)},onLoad:()=>pe(re)},`${n.id}-${c[n.groupId||""]||0}`):n.kind==="remote-desktop"?e.jsxs("div",{style:{height:"100%",background:"var(--ui-term-col-bg, #101014)"},"aria-busy":!x,children:[e.jsx("iframe",{ref:v,className:"webapp-frame",style:{visibility:x?"visible":"hidden"},src:tt("/app/?view=remote-desktop"),title:"远程桌面",onLoad:()=>pe(re)}),!x&&e.jsx(Be,{label:"REMOTE DESKTOP",title:"正在打开远程桌面",caption:"正在准备桌面与连接",icon:e.jsx(et,{size:36,strokeWidth:1.5})})]}):n.kind==="aihub"?e.jsx(co,{visible:n.id===g,rpc:B}):n.kind==="flowstudio"?e.jsx(lo,{visible:n.id===g}):e.jsx(io,{terminalId:n.id,title:n.title,initialCommand:n.initialCommand,visible:n.id===g,state:M,rpc:B,onEvent:H,onTerminalData:oe,onTerminalReset:$,sendTerminalInput:P,keyOrder:Ve,keybarHidden:He,onKeyOrderChange:wt,onKeybarHiddenChange:bt,terminalTheme:te,initialScrollLine:je[n.id]??null,onScrollLineChange:i=>qe(f=>f[n.id]===i?f:{...f,[n.id]:i}),onRegisterFill:i=>Ie(n.id,i),onCwdChange:i=>i&&ie(f=>({...f,[n.id]:i}))})},n.id))})}),ce&&e.jsx("div",{className:"drawer-mask",onClick:()=>le(!1)}),e.jsxs("aside",{className:`tree-col ${ce?"tree-col-open":""}`,style:ae.treeCol,children:[e.jsxs("div",{className:"tree-head",style:ae.treeHead,children:[e.jsx("button",{className:he==="files"?"drawer-tab-active":"",onClick:()=>ze("files"),children:"文件"}),e.jsx("button",{className:he==="history"?"drawer-tab-active":"",onClick:()=>ze("history"),children:"历史"}),e.jsx("span",{className:"tree-cwd",style:ae.treeCwd,children:St??""}),e.jsx("button",{style:{...ae.iconBtn,marginLeft:"auto",flexShrink:0},onClick:()=>le(!1),"aria-label":"close drawer",children:e.jsx(ke,{size:15,"aria-hidden":"true"})})]}),he==="files"?e.jsx(ao,{ready:X>0,followCwd:!0,cwd:St,gateway:A,onOpenFile:Er,selectedPath:ue,initialRoot:Ee,initialFollow:Se,revealRequest:wr,onTreeStateChange:(n,i)=>{ht(n),gt(i)}}):e.jsx(Yn,{csrfToken:r.csrfToken,terminalId:((It=E.find(n=>n.id===g))==null?void 0:It.kind)==="webapp"?null:g,pinnedCommands:Ke,onPinnedCommandsChange:xt,onFill:Me,onExecute:Cr}),e.jsxs("div",{style:ae.treeFoot,children:[e.jsx("span",{style:ae.treeFootDot}),e.jsx("span",{children:"实时同步"})]})]}),ue&&e.jsx("section",{className:"preview-col",style:ae.previewCol,children:e.jsx(so,{path:ue,gateway:A,onClose:()=>Ae(null)})})]}),a&&e.jsx(An,{page:a,reloadKey:l},a.id)]})}const ae={root:{height:"100dvh",display:"flex",flexDirection:"column",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif',overflow:"hidden"},iconBtn:{minWidth:28,height:28,borderRadius:7,border:"1px solid var(--ui-tabbar-border, #303442)",background:"var(--ui-tab-bg, #202029)",color:"var(--ui-tab-text, #aaaab8)",fontSize:13},workspace:{flex:1,minHeight:0,display:"grid",position:"relative"},treeCol:{background:"var(--ui-tree-bg, #121218)",minHeight:0,flexDirection:"column"},treeHead:{display:"flex",alignItems:"center",gap:8,padding:"10px 12px 4px",fontSize:11,textTransform:"uppercase",letterSpacing:1,color:"#778",flexShrink:0},treeCwd:{fontSize:10,color:"#556",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:150,textTransform:"none",letterSpacing:0},treeFoot:{display:"flex",alignItems:"center",gap:7,minHeight:31,padding:"6px 11px calc(env(safe-area-inset-bottom) + 6px)",borderTop:"1px solid var(--ui-tabbar-border, #282832)",boxShadow:"0 -5px 16px rgba(0,0,0,.22)",background:"var(--ui-tab-bg, #15151c)",color:"var(--ui-connection-text, #777789)",fontSize:10.5,flexShrink:0},treeFootDot:{width:6,height:6,borderRadius:99,background:"var(--ui-success, #9ece6a)",boxShadow:"0 0 0 2px color-mix(in srgb, var(--ui-success, #9ece6a) 12%, transparent)",flexShrink:0},termCol:{minWidth:0,minHeight:0,display:"flex",flexDirection:"column",background:"var(--ui-term-col-bg, #101014)",gridColumn:1,overflow:"hidden"},previewCol:{minWidth:0,minHeight:0}},jo=Object.freeze(Object.defineProperty({__proto__:null,default:uo},Symbol.toStringTag,{value:"Module"}));export{Be as F,jo as p,Qn as r};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as l,r as m,d as a}from"./chunk-SVP7TREG-
|
|
1
|
+
import{g as l,r as m,d as a}from"./chunk-SVP7TREG-y9Uxi4pg.js";import{p}from"./chunk-JWPE2WC7-DR8znCWR.js";import{_ as t,l as o}from"./mermaid.core-CmhaKXiP.js";import{M as u,d as c}from"./cynefin-OW5HDTMX-BO4eLWHY.js";import"./index-BReRPZnZ.js";var f=c().RailroadPeg.parser.LangiumParser,i=t(e=>{const r=e.alternatives.map(d);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformOrderedChoice"),d=t(e=>{const r=e.elements.map(P);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformSequence"),P=t(e=>{const r=g(e.suffix);return e.operator?{type:"special",text:e.operator==="&"?`&${s(r)}`:`!${s(r)}`}:r},"transformPrefix"),s=t(e=>{switch(e.type){case"terminal":return`"${e.value}"`;case"nonterminal":return e.name;case"special":return e.text;default:return"(...)"}},"nodeToLabel"),g=t(e=>{const r=v(e.primary);if(!e.operator)return r;switch(e.operator){case"?":return{type:"optional",element:r};case"*":return{type:"repetition",element:r,min:0,max:1/0};case"+":return{type:"repetition",element:r,min:1,max:1/0};default:throw new Error(`Unsupported PEG suffix operator: ${e.operator}`)}},"transformSuffix"),v=t(e=>{switch(e.$type){case"PegLiteral":return{type:"terminal",value:e.value};case"PegIdentifier":return{type:"nonterminal",name:e.name};case"PegGroup":return i(e.element);case"PegAny":return{type:"special",text:e.dot};default:throw new Error(`Unsupported PEG primary node: ${e.$type}`)}},"transformPrimary"),y=t(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=t(e=>{p(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(y(r)))},"populateDb"),b={parse:t(e=>{a.clear(),o.debug("[PEG Parser] Starting Langium parse");const r=f.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new u(r);const n=r.value;o.debug("[PEG Parser] Parsed rules:",n.rules.length),h(n),o.debug("[PEG Parser] Parse complete")},"parse"),parser:{yy:a}},G={parser:b,db:a,renderer:m,styles:l};export{G as diagram};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{p as rt}from"./chunk-JWPE2WC7-
|
|
1
|
+
import{p as rt}from"./chunk-JWPE2WC7-DR8znCWR.js";import{a1 as T,a4 as B,b3 as nt,g as it,s as ot,a as st,b as lt,o as ct,n as ut,_ as d,l as G,c as gt,A as dt,D as pt,L as ht,d as ft,p as mt,B as vt}from"./mermaid.core-CmhaKXiP.js";import{p as xt}from"./cynefin-OW5HDTMX-BO4eLWHY.js";import{d as J}from"./arc-B8zNXyCl.js";import{o as St}from"./ordinal-BENe2yWM.js";import"./index-BReRPZnZ.js";import"./init-Gi6I4Gst.js";function yt(t,n){return n<t?-1:n>t?1:n>=t?0:NaN}function wt(t){return t}function At(){var t=wt,n=yt,y=null,b=T(0),l=T(B),p=T(0);function i(e){var r,s=(e=nt(e)).length,h,w,$=0,f=new Array(s),o=new Array(s),D=+b.apply(this,arguments),E=Math.min(B,Math.max(-B,l.apply(this,arguments)-D)),k,R=Math.min(Math.abs(E)/s,p.apply(this,arguments)),u=R*(E<0?-1:1),A;for(r=0;r<s;++r)(A=o[f[r]=r]=+t(e[r],r,e))>0&&($+=A);for(n!=null?f.sort(function(M,m){return n(o[M],o[m])}):y!=null&&f.sort(function(M,m){return y(e[M],e[m])}),r=0,w=$?(E-s*u)/$:0;r<s;++r,D=k)h=f[r],A=o[h],k=D+(A>0?A*w:0)+u,o[h]={data:e[h],index:r,value:A,startAngle:D,endAngle:k,padAngle:R};return o}return i.value=function(e){return arguments.length?(t=typeof e=="function"?e:T(+e),i):t},i.sortValues=function(e){return arguments.length?(n=e,y=null,i):n},i.sort=function(e){return arguments.length?(y=e,n=null,i):y},i.startAngle=function(e){return arguments.length?(b=typeof e=="function"?e:T(+e),i):b},i.endAngle=function(e){return arguments.length?(l=typeof e=="function"?e:T(+e),i):l},i.padAngle=function(e){return arguments.length?(p=typeof e=="function"?e:T(+e),i):p},i}var Ct=vt.pie,I={sections:new Map,showData:!1},F=I.sections,V=I.showData,$t=structuredClone(Ct),Dt=d(()=>structuredClone($t),"getConfig"),Tt=d(()=>{F=new Map,V=I.showData,mt()},"clear"),bt=d(({label:t,value:n})=>{if(n<0)throw new Error(`"${t}" has invalid value: ${n}. Negative values are not allowed in pie charts. All slice values must be >= 0.`);F.has(t)||(F.set(t,n),G.debug(`added new section: ${t}, with value: ${n}`))},"addSection"),kt=d(()=>F,"getSections"),zt=d(t=>{V=t},"setShowData"),Et=d(()=>V,"getShowData"),K={getConfig:Dt,clear:Tt,setDiagramTitle:ut,getDiagramTitle:ct,setAccTitle:lt,getAccTitle:st,setAccDescription:ot,getAccDescription:it,addSection:bt,getSections:kt,setShowData:zt,getShowData:Et},Mt=d((t,n)=>{rt(t,n),n.setShowData(t.showData),t.sections.map(n.addSection)},"populateDb"),Lt={parse:d(async t=>{const n=await xt("pie",t);G.debug(n),Mt(n,K)},"parse")},Rt=d(t=>`
|
|
2
2
|
.pieCircle{
|
|
3
3
|
stroke: ${t.pieStrokeColor};
|
|
4
4
|
stroke-width : ${t.pieStrokeWidth};
|