@geminilight/mindos 0.6.58 → 0.6.60
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/_standalone/.mindos-build-version +1 -1
- package/_standalone/.next/BUILD_ID +1 -1
- package/_standalone/.next/app-path-routes-manifest.json +23 -22
- package/_standalone/.next/build-manifest.json +3 -3
- package/_standalone/.next/cache/.previewinfo +1 -1
- package/_standalone/.next/cache/.rscinfo +1 -1
- package/_standalone/.next/cache/config.json +3 -3
- package/_standalone/.next/prerender-manifest.json +3 -3
- package/_standalone/.next/react-loadable-manifest.json +1 -1
- package/_standalone/.next/routes-manifest.json +6 -0
- package/_standalone/.next/server/app/.well-known/agent-card.json/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/_global-error.html +2 -2
- package/_standalone/.next/server/app/_global-error.rsc +1 -1
- package/_standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/_standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/_standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/_standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/_standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/_standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/_standalone/.next/server/app/_not-found/page.js +1 -1
- package/_standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/agents/[agentKey]/page.js +1 -1
- package/_standalone/.next/server/app/agents/[agentKey]/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/agents/[agentKey]/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/agents/page.js +2 -2
- package/_standalone/.next/server/app/agents/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/agents/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/a2a/agents/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/a2a/delegations/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/a2a/discover/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/a2a/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/acp/config/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/acp/detect/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/acp/install/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/acp/registry/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/acp/session/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/agent-activity/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/agents/copy-skill/route.js +1 -0
- package/_standalone/.next/server/app/api/agents/copy-skill/route.js.nft.json +1 -0
- package/_standalone/.next/server/app/api/agents/copy-skill/route_client-reference-manifest.js +1 -0
- package/_standalone/.next/server/app/api/agents/custom/detect/route.js +1 -1
- package/_standalone/.next/server/app/api/agents/custom/detect/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/agents/custom/route.js +1 -1
- package/_standalone/.next/server/app/api/agents/custom/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/ask/route.js +18 -7
- package/_standalone/.next/server/app/api/ask/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/ask-sessions/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/auth/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/backlinks/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/bootstrap/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/changes/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/export/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/extract-pdf/route.js +2 -2
- package/_standalone/.next/server/app/api/extract-pdf/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/file/import/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/file/raw/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/file/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/files/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/graph/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/health/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/inbox/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/init/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/agents/route.js +1 -1
- package/_standalone/.next/server/app/api/mcp/agents/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/install/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/install-skill/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/restart/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/status/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/uninstall/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/monitoring/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/recent-files/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/restart/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/search/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/settings/list-models/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/settings/reset-token/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/settings/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/settings/test-key/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/setup/check-path/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/setup/check-port/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/setup/generate-token/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/setup/ls/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/setup/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/skills/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/sync/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/tree-version/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/uninstall/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/update-check/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/update-status/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/workflows/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/changes/page.js +2 -2
- package/_standalone/.next/server/app/changes/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/changes/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/echo/[segment]/page.js +3 -3
- package/_standalone/.next/server/app/echo/[segment]/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/echo/[segment]/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/echo/page.js +1 -1
- package/_standalone/.next/server/app/echo/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/echo/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/explore/page.js +2 -2
- package/_standalone/.next/server/app/explore/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/explore/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/help/page.js +2 -2
- package/_standalone/.next/server/app/help/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/help/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/inbox/history/page.js +1 -1
- package/_standalone/.next/server/app/inbox/history/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/inbox/history/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/login/page.js +2 -2
- package/_standalone/.next/server/app/login/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/page.js +2 -8
- package/_standalone/.next/server/app/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/setup/page.js +2 -2
- package/_standalone/.next/server/app/setup/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/setup/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/trash/page.js +3 -3
- package/_standalone/.next/server/app/trash/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/trash/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/view/[...path]/page.js +3 -3
- package/_standalone/.next/server/app/view/[...path]/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/view/[...path]/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/wiki/page.js +2 -2
- package/_standalone/.next/server/app/wiki/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/wiki/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app-paths-manifest.json +23 -22
- package/_standalone/.next/server/chunks/1550.js +1 -1
- package/_standalone/.next/server/chunks/3484.js +1 -1
- package/_standalone/.next/server/chunks/530.js +70 -71
- package/_standalone/.next/server/chunks/{6793.js → 9753.js} +2 -2
- package/_standalone/.next/server/chunks/9787.js +2 -0
- package/_standalone/.next/server/middleware-build-manifest.js +1 -1
- package/_standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/_standalone/.next/server/pages/500.html +2 -2
- package/_standalone/.next/server/server-reference-manifest.js +1 -1
- package/_standalone/.next/server/server-reference-manifest.json +1 -1
- package/_standalone/.next/static/K3wZNf5bj_AFYwtqcRXIf/_buildManifest.js +1 -0
- package/_standalone/.next/static/chunks/1369-7d0ac5d1564eed1e.js +1 -0
- package/_standalone/.next/static/chunks/{1814.a7c127b2c73d1f70.js → 1814.a79b84d37df75c43.js} +1 -1
- package/_standalone/.next/static/chunks/3427-2e61a5df1f5e55fb.js +1 -0
- package/_standalone/.next/static/chunks/{1053-fe009233cff06e72.js → 5581-974dfb26d1d1b38f.js} +3 -3
- package/_standalone/.next/static/chunks/6297-085daa21037d5f81.js +1 -0
- package/_standalone/.next/static/chunks/7249-b0a9c77b9a84b11c.js +11 -0
- package/_standalone/.next/static/chunks/7637-904b0a381dc3ec02.js +1 -0
- package/_standalone/.next/static/chunks/8520-76d1b05072178b43.js +22 -0
- package/_standalone/.next/static/chunks/9186-ead47513192f658b.js +1 -0
- package/_standalone/.next/static/chunks/9905-a19d379cb225246e.js +1 -0
- package/_standalone/.next/static/chunks/app/.well-known/agent-card.json/{route-2f4705aa66819b86.js → route-2ceea6eabf25b1f2.js} +1 -1
- package/_standalone/.next/static/chunks/app/_global-error/{page-2f4705aa66819b86.js → page-2ceea6eabf25b1f2.js} +1 -1
- package/_standalone/.next/static/chunks/app/agents/[agentKey]/page-0ea3571c8fbae823.js +1 -0
- package/_standalone/.next/static/chunks/app/agents/page-66858acbcd1d4bf8.js +1 -0
- package/_standalone/.next/static/chunks/app/api/a2a/agents/{route-2f4705aa66819b86.js → route-2ceea6eabf25b1f2.js} +1 -1
- package/_standalone/.next/static/chunks/app/api/a2a/delegations/{route-2f4705aa66819b86.js → route-2ceea6eabf25b1f2.js} +1 -1
- package/_standalone/.next/static/chunks/app/api/a2a/discover/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/a2a/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/acp/config/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/acp/detect/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/acp/install/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/acp/registry/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/acp/session/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/agent-activity/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/agents/copy-skill/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/agents/custom/detect/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/agents/custom/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/ask/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/ask-sessions/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/auth/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/backlinks/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/bootstrap/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/changes/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/export/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/extract-pdf/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/file/import/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/file/raw/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/file/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/files/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/git/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/graph/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/health/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/inbox/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/init/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/mcp/agents/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/mcp/install/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/mcp/install-skill/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/mcp/restart/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/mcp/status/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/mcp/uninstall/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/monitoring/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/recent-files/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/restart/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/search/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/settings/list-models/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/settings/reset-token/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/settings/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/settings/test-key/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/setup/check-path/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/setup/check-port/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/setup/generate-token/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/setup/ls/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/setup/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/skills/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/sync/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/tree-version/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/uninstall/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/update/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/update-check/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/update-status/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/api/workflows/route-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/changes/page-dd0b00a7b81f74e2.js +1 -0
- package/_standalone/.next/static/chunks/app/echo/[segment]/page-bf5c290fa3ccff09.js +11 -0
- package/_standalone/.next/static/chunks/app/echo/page-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/explore/{page-d3d99308146c2240.js → page-d9f58000bc445360.js} +2 -2
- package/_standalone/.next/static/chunks/app/help/{page-222df603080b5fab.js → page-f8cb806371b3175f.js} +1 -1
- package/_standalone/.next/static/chunks/app/inbox/history/{page-07819cf95cb0805f.js → page-3279585360df132c.js} +1 -1
- package/_standalone/.next/static/chunks/app/layout-6a0169582db11a08.js +164 -0
- package/_standalone/.next/static/chunks/app/loading-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/login/{page-0eeef685052869a6.js → page-18fb00d568cd1f0e.js} +1 -1
- package/_standalone/.next/static/chunks/app/page-6a1f8d21c12b829e.js +1 -0
- package/_standalone/.next/static/chunks/app/setup/{page-99fcfc460fa29733.js → page-821714e7477be46c.js} +1 -1
- package/_standalone/.next/static/chunks/app/trash/page-ed7ba3b0b50223a6.js +1 -0
- package/_standalone/.next/static/chunks/app/view/[...path]/loading-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/app/view/[...path]/{not-found-fc04c2bd4f35bc6f.js → not-found-6e0c75ad26ce8572.js} +1 -1
- package/_standalone/.next/static/chunks/app/view/[...path]/page-678139779971cfcb.js +12 -0
- package/_standalone/.next/static/chunks/app/wiki/page-194ae9af2d461481.js +1 -0
- package/_standalone/.next/static/chunks/next/dist/client/components/builtin/app-error-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/next/dist/client/components/builtin/forbidden-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/next/dist/client/components/builtin/not-found-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/next/dist/client/components/builtin/unauthorized-2ceea6eabf25b1f2.js +1 -0
- package/_standalone/.next/static/chunks/{webpack-2c19436659aa657b.js → webpack-72e8d9e9073fd1f9.js} +1 -1
- package/_standalone/.next/static/css/9c558c42831fae58.css +1 -0
- package/_standalone/.next/trace +65 -64
- package/_standalone/.next/types/routes.d.ts +2 -1
- package/_standalone/.next/types/validator.ts +9 -0
- package/_standalone/__tests__/api/mcp-install.test.ts +4 -2
- package/_standalone/app/globals.css +2 -1
- package/_standalone/components/AskFab.tsx +11 -5
- package/_standalone/components/AskModal.tsx +1 -1
- package/_standalone/components/FileTree.tsx +83 -1
- package/_standalone/components/GuideCard.tsx +101 -152
- package/_standalone/components/Panel.tsx +6 -1
- package/_standalone/components/RightAskPanel.tsx +2 -2
- package/_standalone/components/agents/AgentsOverviewSection.tsx +13 -11
- package/_standalone/components/agents/CustomAgentModal.tsx +72 -18
- package/_standalone/components/ask/AskContent.tsx +109 -54
- package/_standalone/components/ask/AskHeader.tsx +218 -18
- package/_standalone/components/ask/FileChip.tsx +93 -12
- package/_standalone/components/ask/MessageList.tsx +66 -47
- package/_standalone/components/ask/SessionHistory.tsx +86 -60
- package/_standalone/components/ask/SessionTabBar.tsx +29 -21
- package/_standalone/components/ask/ThinkingBlock.tsx +6 -5
- package/_standalone/components/ask/ToolCallBlock.tsx +10 -9
- package/_standalone/components/changes/ChangesBanner.tsx +1 -1
- package/_standalone/components/settings/SettingsContent.tsx +1 -1
- package/_standalone/components/walkthrough/WalkthroughTooltip.tsx +3 -1
- package/_standalone/components/walkthrough/steps.ts +1 -1
- package/_standalone/data/skills/mindos/SKILL.md +67 -15
- package/_standalone/data/skills/mindos-zh/SKILL.md +67 -11
- package/_standalone/hooks/useAskChat.ts +10 -8
- package/_standalone/hooks/useAskSession.ts +23 -1
- package/_standalone/hooks/useFileUpload.ts +97 -43
- package/_standalone/hooks/useImageUpload.ts +1 -1
- package/_standalone/lib/inbox-upload.ts +86 -0
- package/_standalone/lib/stores/locale-store.ts +20 -6
- package/_standalone/package-lock.json +2 -2
- package/_standalone/package.json +1 -1
- package/_standalone/scripts/extract-pdf.cjs +110 -3
- package/_standalone/tsconfig.tsbuildinfo +1 -1
- package/app/app/api/agents/copy-skill/route.ts +110 -0
- package/app/app/api/agents/custom/detect/route.ts +16 -1
- package/app/app/api/ask/route.ts +7 -1
- package/app/app/api/extract-pdf/route.ts +12 -5
- package/app/app/api/mcp/agents/route.ts +64 -2
- package/app/app/globals.css +2 -1
- package/app/app/layout.tsx +16 -4
- package/app/components/AskFab.tsx +11 -5
- package/app/components/AskModal.tsx +1 -1
- package/app/components/FileTree.tsx +83 -1
- package/app/components/GuideCard.tsx +101 -152
- package/app/components/HomeContent.tsx +123 -574
- package/app/components/Panel.tsx +6 -1
- package/app/components/RightAskPanel.tsx +2 -2
- package/app/components/WikiHomeContent.tsx +151 -3
- package/app/components/agents/AgentDetailContent.tsx +58 -1
- package/app/components/agents/AgentsOverviewSection.tsx +13 -11
- package/app/components/agents/CustomAgentModal.tsx +72 -18
- package/app/components/ask/AskContent.tsx +109 -54
- package/app/components/ask/AskHeader.tsx +218 -18
- package/app/components/ask/FileChip.tsx +93 -12
- package/app/components/ask/MessageList.tsx +66 -47
- package/app/components/ask/SessionHistory.tsx +86 -60
- package/app/components/ask/SessionTabBar.tsx +29 -21
- package/app/components/ask/ThinkingBlock.tsx +6 -5
- package/app/components/ask/ToolCallBlock.tsx +10 -9
- package/app/components/changes/ChangesBanner.tsx +1 -1
- package/app/components/changes/ChangesContentPage.tsx +368 -168
- package/app/components/settings/SettingsContent.tsx +1 -1
- package/app/components/walkthrough/WalkthroughTooltip.tsx +3 -1
- package/app/components/walkthrough/steps.ts +1 -1
- package/app/data/skills/mindos/SKILL.md +67 -15
- package/app/data/skills/mindos-zh/SKILL.md +67 -11
- package/app/hooks/useAskChat.ts +10 -8
- package/app/hooks/useAskSession.ts +23 -1
- package/app/hooks/useFileUpload.ts +97 -43
- package/app/hooks/useImageUpload.ts +1 -1
- package/app/lib/agent/prompt.ts +15 -4
- package/app/lib/custom-agents.ts +109 -1
- package/app/lib/file-ops.ts +58 -0
- package/app/lib/i18n/modules/ai-chat.ts +134 -10
- package/app/lib/i18n/modules/knowledge.ts +2 -0
- package/app/lib/i18n/modules/onboarding.ts +12 -12
- package/app/lib/inbox-upload.ts +86 -0
- package/app/lib/mcp-agents.ts +21 -1
- package/app/lib/stores/LocaleStoreInit.tsx +24 -1
- package/app/lib/stores/locale-store.ts +20 -6
- package/app/lib/types.ts +13 -0
- package/app/package.json +1 -1
- package/app/scripts/extract-pdf.cjs +110 -3
- package/package.json +1 -1
- package/skills/mindos/SKILL.md +67 -15
- package/skills/mindos/references/knowledge-health.md +120 -0
- package/skills/mindos-max/SKILL.md +52 -5
- package/skills/mindos-max-zh/SKILL.md +55 -6
- package/skills/mindos-zh/SKILL.md +67 -11
- package/_standalone/.next/server/chunks/2364.js +0 -2
- package/_standalone/.next/server/chunks/357.js +0 -1
- package/_standalone/.next/static/2ksXveDzEcnCMRIElDkLq/_buildManifest.js +0 -1
- package/_standalone/.next/static/chunks/178-105779afb62d36d9.js +0 -1
- package/_standalone/.next/static/chunks/2218-d54538000574ffef.js +0 -1
- package/_standalone/.next/static/chunks/2549-e63cf57fa927a41d.js +0 -1
- package/_standalone/.next/static/chunks/4237-ffc6e7c15d4007b6.js +0 -1
- package/_standalone/.next/static/chunks/6878-e2c5459e1c608f89.js +0 -1
- package/_standalone/.next/static/chunks/7249-fa98ca10e9a10f39.js +0 -11
- package/_standalone/.next/static/chunks/9274-296ab35f9f09e42e.js +0 -1
- package/_standalone/.next/static/chunks/9286-5b09baa5200318c2.js +0 -1
- package/_standalone/.next/static/chunks/app/agents/[agentKey]/page-7bdeab5af8e4f5f2.js +0 -1
- package/_standalone/.next/static/chunks/app/agents/page-5d1446665ddb3801.js +0 -1
- package/_standalone/.next/static/chunks/app/api/a2a/discover/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/a2a/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/acp/config/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/acp/detect/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/acp/install/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/acp/registry/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/acp/session/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/agent-activity/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/agents/custom/detect/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/agents/custom/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/ask/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/ask-sessions/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/auth/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/backlinks/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/bootstrap/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/changes/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/export/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/extract-pdf/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/file/import/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/file/raw/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/file/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/files/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/git/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/graph/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/health/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/inbox/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/init/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/mcp/agents/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/mcp/install/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/mcp/install-skill/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/mcp/restart/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/mcp/status/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/mcp/uninstall/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/monitoring/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/recent-files/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/restart/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/search/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/settings/list-models/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/settings/reset-token/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/settings/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/settings/test-key/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/setup/check-path/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/setup/check-port/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/setup/generate-token/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/setup/ls/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/setup/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/skills/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/sync/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/tree-version/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/uninstall/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/update/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/update-check/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/update-status/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/api/workflows/route-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/changes/page-5a72144d1080a699.js +0 -1
- package/_standalone/.next/static/chunks/app/echo/[segment]/page-b0103509ce34444b.js +0 -11
- package/_standalone/.next/static/chunks/app/echo/page-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/layout-7e02ddf4144b01f1.js +0 -186
- package/_standalone/.next/static/chunks/app/loading-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/page-6a6a12bd6d6812d0.js +0 -7
- package/_standalone/.next/static/chunks/app/trash/page-54cbd5c98d9de69b.js +0 -1
- package/_standalone/.next/static/chunks/app/view/[...path]/loading-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/app/view/[...path]/page-ca7bdcbf27f88a46.js +0 -12
- package/_standalone/.next/static/chunks/app/wiki/page-d492256a93f0b8bc.js +0 -1
- package/_standalone/.next/static/chunks/next/dist/client/components/builtin/app-error-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/next/dist/client/components/builtin/forbidden-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/next/dist/client/components/builtin/not-found-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/chunks/next/dist/client/components/builtin/unauthorized-2f4705aa66819b86.js +0 -1
- package/_standalone/.next/static/css/fd84c8316ead16eb.css +0 -1
- /package/_standalone/.next/static/{2ksXveDzEcnCMRIElDkLq → K3wZNf5bj_AFYwtqcRXIf}/_ssgManifest.js +0 -0
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7177],{2431:(e,t,s)=>{"use strict";s.d(t,{z:()=>a});var r=s(12115);let n="mindos:acp-detection";function a(){let e=(0,r.useRef)(function(){try{let e=sessionStorage.getItem(n);if(!e)return null;let t=JSON.parse(e);if("number"!=typeof t.ts||Date.now()-t.ts>18e5)return null;return t}catch{return null}}()),[t,s]=(0,r.useState)(e.current?.installed??[]),[a,o]=(0,r.useState)(e.current?.notInstalled??[]),[l,i]=(0,r.useState)(!e.current),[d,c]=(0,r.useState)(null),[u,m]=(0,r.useState)(0),x=(0,r.useRef)(!1),p=(0,r.useRef)(!1),h=(0,r.useCallback)(()=>{try{sessionStorage.removeItem(n)}catch{}e.current=null,p.current=!0,m(e=>e+1)},[]);return(0,r.useEffect)(()=>{let e=()=>h();return window.addEventListener("mindos:settings-changed",e),()=>window.removeEventListener("mindos:settings-changed",e)},[h]),(0,r.useEffect)(()=>{let r=p.current;if(p.current=!1,e.current&&Date.now()-e.current.ts<18e5&&0===u||x.current)return;x.current=!0;let l=t.length>0||a.length>0;l||i(!0),c(null);let d=!1;return fetch(`/api/acp/detect${r?"?force=1":""}`).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(t=>{if(d)return;let r=t.installed??[],a=t.notInstalled??[];try{sessionStorage.setItem(n,JSON.stringify({installed:r,notInstalled:a,ts:Date.now()}))}catch{}e.current={installed:r,notInstalled:a,ts:Date.now()},s(r),o(a)}).catch(e=>{!d&&(l||c(e.message))}).finally(()=>{x.current=!1,d||i(!1)}),()=>{d=!0}},[u]),{installedAgents:t,notInstalledAgents:a,loading:l,error:d,refresh:h}}},2736:(e,t,s)=>{"use strict";s.d(t,{f:()=>n});var r=s(9339);let n=(0,r.createServerReference)("60d09de4b0dbd6c28d853100924e4b354001093bef",r.callServer,void 0,r.findSourceMapURL,"renameFileAction")},9456:(e,t,s)=>{"use strict";s.d(t,{E:()=>n});var r=s(9339);let n=(0,r.createServerReference)("00809d79730b2c8db2301565845c7cca4060acf801",r.callServer,void 0,r.findSourceMapURL,"cleanupExamplesAction")},10377:(e,t,s)=>{"use strict";s.d(t,{Z:()=>h});var r=s(12115);let n="mindos-pinned-files",a="mindos:pins-changed";function o(){try{let e=localStorage.getItem(n);return e?JSON.parse(e):[]}catch{return[]}}function l(){return c}let i=[];function d(){return i}let c=[],u=!1;function m(){u||(c=o(),u=!0)}function x(e){m();let t=t=>{t.key===n&&(c=o(),e())},s=()=>{c=o(),e()};return window.addEventListener("storage",t),window.addEventListener(a,s),()=>{window.removeEventListener("storage",t),window.removeEventListener(a,s)}}function p(e){c=e;try{localStorage.setItem(n,JSON.stringify(e))}catch{}window.dispatchEvent(new Event(a))}function h(){m();let e=(0,r.useSyncExternalStore)(x,l,d),t=(0,r.useCallback)(t=>e.includes(t),[e]),s=(0,r.useCallback)(e=>{let t=o(),s=t.indexOf(e);s>=0?t.splice(s,1):t.unshift(e),p(t)},[]);return{pinnedFiles:e,isPinned:t,togglePin:s,reorderPins:(0,r.useCallback)(e=>{p(e)},[]),removePin:(0,r.useCallback)(e=>{p(o().filter(t=>t!==e))},[])}}},14446:(e,t,s)=>{"use strict";s.r(t),s.d(t,{AudioRenderer:()=>a});var r=s(95155),n=s(12115);function a({filePath:e}){let t=`/api/file/raw?path=${encodeURIComponent(e)}`,s=e.split("/").pop()??"audio",a=s.split(".").pop()?.toLowerCase()??"",[o,l]=(0,n.useState)(!1),[i,d]=(0,n.useState)(0),[c,u]=(0,n.useState)(null);(0,n.useEffect)(()=>{fetch(t,{method:"HEAD"}).then(e=>{let t=e.headers.get("Content-Length");t&&u(parseInt(t,10))}).catch(()=>{})},[t]);let m=(0,n.useCallback)(()=>{l(!1),d(e=>e+1)},[]);return(0,r.jsxs)("div",{className:"w-full flex flex-col items-center gap-6 py-12 px-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 text-xs text-[var(--text-secondary)]",children:[(0,r.jsx)("span",{className:"text-4xl opacity-40",children:"\uD83C\uDFB5"}),(0,r.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:s}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"uppercase opacity-60",children:a}),null!==c&&(0,r.jsx)("span",{children:c<1024?`${c} B`:c<1048576?`${(c/1024).toFixed(1)} KB`:`${(c/1048576).toFixed(1)} MB`})]})]})]}),o?(0,r.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm text-[var(--text-secondary)]",children:"Failed to load audio"}),(0,r.jsx)("button",{onClick:m,className:"text-xs px-3 py-1.5 rounded-md bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] transition-colors",children:"Retry"})]}):(0,r.jsx)("audio",{controls:!0,preload:"metadata",className:"w-full max-w-lg",onError:()=>l(!0),children:(0,r.jsx)("source",{src:t})},i)]})}},16518:(e,t,s)=>{"use strict";s.d(t,{AI:()=>n,RS:()=>r});let r=["about-you","continued","daily","past-you","growth"],n={"about-you":"/echo/about-you",continued:"/echo/continued",daily:"/echo/daily","past-you":"/echo/past-you",growth:"/echo/growth"}},18847:(e,t,s)=>{"use strict";s.r(t),s.d(t,{AgentInspectorRenderer:()=>y});var r=s(95155),n=s(12115),a=s(73321),o=s(84980),l=s(3926),i=s(93631),d=s(68459),c=s(61878),u=s(10762),m=s(12651),x=s(13545),p=s(66088);function h(e){return/read|list|get|search/.test(e)?/search/.test(e)?"search":"read":/create/.test(e)?"create":/delete/.test(e)?"delete":/write|update|insert|append/.test(e)?"write":"other"}let g={read:{bg:"rgba(138,180,216,0.10)",text:"#8ab4d8",border:"rgba(138,180,216,0.25)"},write:{bg:"rgba(200,135,58,0.10)",text:"var(--amber)",border:"rgba(200,135,58,0.25)"},create:{bg:"rgba(122,173,128,0.10)",text:"var(--success)",border:"rgba(122,173,128,0.25)"},delete:{bg:"rgba(200,80,80,0.10)",text:"var(--error)",border:"rgba(200,80,80,0.25)"},search:{bg:"rgba(200,160,216,0.10)",text:"#c8a0d8",border:"rgba(200,160,216,0.25)"},other:{bg:"var(--muted)",text:"var(--muted-foreground)",border:"var(--border)"}};function f({kind:e,size:t=13}){return"read"===e?(0,r.jsx)(o.A,{size:t}):"write"===e?(0,r.jsx)(l.A,{size:t}):"create"===e?(0,r.jsx)(i.A,{size:t}):"delete"===e?(0,r.jsx)(d.A,{size:t}):"search"===e?(0,r.jsx)(c.A,{size:t}):(0,r.jsx)(u.A,{size:t})}function b(e){try{return new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return e}}function v({op:e}){var t,s;let o,l,i,d,c=(0,a.useRouter)(),[u,v]=(0,n.useState)(!1),j=h(e.tool),y=g[j],N="string"==typeof(t=e.params).path?t.path:null,k=e.tool.replace("mindos_","");return(0,r.jsxs)("div",{style:{background:"var(--card)",border:"1px solid var(--border)",borderRadius:10,overflow:"hidden",marginBottom:8},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 14px",cursor:"pointer",userSelect:"none"},onClick:()=>v(e=>!e),children:[(0,r.jsxs)("span",{className:"font-display",style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",borderRadius:999,fontSize:"0.68rem",fontWeight:600,background:y.bg,color:y.text,border:`1px solid ${y.border}`,flexShrink:0},children:[(0,r.jsx)(f,{kind:j,size:10}),j]}),(0,r.jsx)("span",{className:"font-display",style:{fontSize:"0.78rem",color:"var(--foreground)",fontWeight:600,flexShrink:0},children:k}),N&&(0,r.jsx)("span",{style:{fontSize:"0.72rem",color:"var(--amber)",flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:"pointer"},onClick:e=>{e.stopPropagation(),c.push("/view/"+N.split("/").map(encodeURIComponent).join("/"))},title:N,className:"font-display",children:N}),(0,r.jsxs)("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[e.agentName&&(0,r.jsx)("span",{className:"font-display",style:{fontSize:"0.62rem",fontWeight:500,padding:"1px 6px",borderRadius:999,background:"var(--muted)",color:"var(--muted-foreground)",whiteSpace:"nowrap",maxWidth:120,overflow:"hidden",textOverflow:"ellipsis"},title:e.agentName,children:e.agentName.length>30?e.agentName.slice(0,30)+"...":e.agentName}),"ok"===e.result?(0,r.jsx)(m.A,{size:13,style:{color:"var(--success)"}}):(0,r.jsx)(x.A,{size:13,style:{color:"var(--error)"}}),(0,r.jsx)("span",{className:"font-display",style:{fontSize:"0.68rem",color:"var(--muted-foreground)",opacity:.6},title:b(e.ts),children:(s=e.ts,l=Math.floor((o=Date.now()-new Date(s).getTime())/6e4),i=Math.floor(o/36e5),d=Math.floor(o/864e5),l<1?"just now":l<60?`${l}m ago`:i<24?`${i}h ago`:`${d}d ago`)}),(0,r.jsx)(p.A,{size:12,style:{color:"var(--muted-foreground)",transform:u?"rotate(180deg)":"none",transition:"transform .15s"}})]})]}),u&&(0,r.jsxs)("div",{style:{borderTop:"1px solid var(--border)",padding:"10px 14px",background:"var(--background)"},children:[(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4,marginBottom:8*!!e.message},children:Object.entries(e.params).map(([e,t])=>(0,r.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"flex-start"},children:[(0,r.jsx)("span",{className:"font-display",style:{fontSize:"0.68rem",color:"var(--muted-foreground)",opacity:.7,flexShrink:0,minWidth:80},children:e}),(0,r.jsx)("span",{className:"font-display",style:{fontSize:"0.72rem",color:"var(--foreground)",wordBreak:"break-all",lineHeight:1.5},children:function(e,t=120){let s="string"==typeof e?e:JSON.stringify(e);return s.length>t?s.slice(0,t)+"…":s}(t)})]},e))}),e.message&&(0,r.jsx)("div",{className:"font-display",style:{marginTop:6,padding:"5px 9px",borderRadius:5,fontSize:"0.72rem",background:"error"===e.result?"rgba(200,80,80,0.08)":"rgba(122,173,128,0.08)",color:"error"===e.result?"var(--error)":"var(--success)",border:`1px solid ${"error"===e.result?"rgba(200,80,80,0.2)":"rgba(122,173,128,0.2)"}`},children:e.message}),e.agentName&&(0,r.jsxs)("div",{className:"font-display",style:{marginTop:6,fontSize:"0.68rem",color:"var(--muted-foreground)"},children:["Agent: ",(0,r.jsx)("span",{style:{color:"var(--foreground)",fontWeight:500},children:e.agentName})]}),(0,r.jsx)("div",{className:"font-display",style:{marginTop:6,fontSize:"0.65rem",color:"var(--muted-foreground)",opacity:.5},children:b(e.ts)})]})]})}let j=["all","write","create","delete","read","search"];function y({content:e}){let[t,s]=(0,n.useState)("all"),a=(0,n.useMemo)(()=>(function(e){try{let t=JSON.parse(e);if(Array.isArray(t.events))return t.events.filter(e=>!!e?.tool&&!!e?.ts).sort((e,t)=>new Date(t.ts).getTime()-new Date(e.ts).getTime())}catch{}return(function(e){let t=[];for(let s of e.split("\n")){let e=s.trim();if(!(!e||e.startsWith("#")||e.startsWith("//")))try{let s=JSON.parse(e);s.tool&&s.ts&&t.push(s)}catch{}}return t})(e).sort((e,t)=>new Date(t.ts).getTime()-new Date(e.ts).getTime())})(e),[e]),o=(0,n.useMemo)(()=>"all"===t?a:a.filter(e=>h(e.tool)===t),[a,t]),l=(0,n.useMemo)(()=>{let e={all:a.length};for(let t of a){let s=h(t.tool);e[s]=(e[s]??0)+1}return e},[a]);return 0===a.length?(0,r.jsxs)("div",{className:"font-display",style:{padding:"3rem 1rem",textAlign:"center",color:"var(--muted-foreground)",fontSize:12},children:[(0,r.jsx)(u.A,{size:28,style:{margin:"0 auto 10px",opacity:.3}}),(0,r.jsx)("p",{children:"No agent operations logged yet."}),(0,r.jsxs)("p",{style:{marginTop:6,opacity:.6,fontSize:11},children:["Agent writes appear here from ",(0,r.jsx)("code",{style:{background:"var(--muted)",padding:"1px 5px",borderRadius:4},children:".mindos/agent-audit-log.json"}),"."]})]}):(0,r.jsxs)("div",{style:{maxWidth:760,margin:"0 auto",padding:"1.5rem 0"},children:[(0,r.jsx)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:"1.2rem",flexWrap:"wrap"},children:j.map(e=>{let n=l[e]??0;if("all"!==e&&!n)return null;let a="all"!==e?g[e]:void 0,o=t===e;return(0,r.jsxs)("button",{onClick:()=>s(e),className:"font-display",style:{display:"inline-flex",alignItems:"center",gap:4,padding:"3px 10px",borderRadius:999,fontSize:"0.7rem",cursor:"pointer",border:"none",background:o?a?.bg??"var(--accent)":"var(--muted)",color:o?a?.text??"var(--foreground)":"var(--muted-foreground)",outline:o?`1px solid ${a?.border??"var(--border)"}`:"none",transition:"all .1s"},children:["all"!==e&&(0,r.jsx)(f,{kind:e,size:10}),e," ",(0,r.jsxs)("span",{style:{opacity:.6},children:["(",n,")"]})]},e)})}),(0,r.jsx)("div",{children:o.map((e,t)=>(0,r.jsx)(v,{op:e},t))})]})}},20555:(e,t,s)=>{"use strict";s.d(t,{LD:()=>r,LZ:()=>n,qQ:()=>a});let r=[{id:"c1",icon:"\uD83D\uDC64",category:"memory-sync",scenario:"first-day"},{id:"c2",icon:"\uD83D\uDCE5",category:"knowledge-management",scenario:"daily"},{id:"c3",icon:"\uD83D\uDD04",category:"memory-sync",scenario:"project"},{id:"c4",icon:"\uD83D\uDD01",category:"experience-evolution",scenario:"daily"},{id:"c5",icon:"\uD83D\uDCA1",category:"auto-execute",scenario:"daily"},{id:"c6",icon:"\uD83D\uDE80",category:"auto-execute",scenario:"project"},{id:"c7",icon:"\uD83D\uDD0D",category:"knowledge-management",scenario:"project"},{id:"c8",icon:"\uD83E\uDD1D",category:"human-insights",scenario:"daily"},{id:"c9",icon:"\uD83D\uDEE1️",category:"audit-control",scenario:"advanced"}],n=["knowledge-management","memory-sync","auto-execute","experience-evolution","human-insights","audit-control"],a=["first-day","daily","project","advanced"]},20814:(e,t,s)=>{"use strict";s.r(t),s.d(t,{ImageRenderer:()=>o});var r=s(95155),n=s(12115);let a=[.25,.5,.75,1,1.5,2,3,4];function o({filePath:e}){let t=`/api/file/raw?path=${encodeURIComponent(e)}`,s=e.split("/").pop()??"image",o=s.split(".").pop()?.toLowerCase()??"",l=["png","svg","webp","ico","gif"].includes(o),[i,d]=(0,n.useState)(!0),[c,u]=(0,n.useState)(!1),[m,x]=(0,n.useState)(0),[p,h]=(0,n.useState)("fit"),[g,f]=(0,n.useState)(null),[b,v]=(0,n.useState)(null),j=(0,n.useRef)(null),y=(0,n.useRef)(null),N=(0,n.useCallback)(()=>{d(!1);let e=j.current;e&&f({w:e.naturalWidth,h:e.naturalHeight})},[]),k=(0,n.useCallback)(()=>{d(!1),u(!0)},[]),w=(0,n.useCallback)(()=>{u(!1),d(!0),x(e=>e+1)},[]);(0,n.useEffect)(()=>{i||c||null!==b||fetch(t,{method:"HEAD"}).then(e=>{let t=e.headers.get("Content-Length");t&&v(parseInt(t,10))}).catch(()=>{})},[t,i,c,b]);let S=(0,n.useCallback)(()=>{h(e=>{let t="fit"===e?1:e;return a.find(e=>e>t)??t})},[]),C=(0,n.useCallback)(()=>{h(e=>{let t="fit"===e?1:e;return[...a].reverse().find(e=>e<t)??t})},[]),A=(0,n.useCallback)(()=>{h(e=>"fit"===e?1:"fit")},[]);(0,n.useEffect)(()=>{let e=y.current;if(!e)return;let t=t=>{t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement||(document.activeElement===document.body||e.contains(document.activeElement))&&(("+"===t.key||"="===t.key)&&(t.preventDefault(),S()),"-"===t.key&&(t.preventDefault(),C()),"0"===t.key&&(t.preventDefault(),h("fit")),"1"===t.key&&(t.preventDefault(),h(1)))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[S,C]);let z="fit"===p?"Fit":`${Math.round(100*p)}%`,E="fit"===p?{maxWidth:"100%",maxHeight:"70vh",objectFit:"contain"}:g?{width:g.w*p,height:"auto"}:{maxWidth:"100%",maxHeight:"70vh",objectFit:"contain"};return(0,r.jsxs)("div",{className:"w-full flex flex-col gap-0",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border text-xs text-[var(--text-secondary)]",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[g&&(0,r.jsxs)("span",{children:[g.w," x ",g.h]}),null!==b&&(0,r.jsx)("span",{children:b<1024?`${b} B`:b<1048576?`${(b/1024).toFixed(1)} KB`:`${(b/1048576).toFixed(1)} MB`}),(0,r.jsx)("span",{className:"uppercase opacity-60",children:o})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("button",{onClick:C,disabled:!g,className:"px-2 py-1 rounded hover:bg-[var(--bg-hover)] transition-colors disabled:opacity-30",title:"Zoom out (-)",children:"-"}),(0,r.jsx)("button",{onClick:A,disabled:!g,className:"px-2 py-1 rounded hover:bg-[var(--bg-hover)] transition-colors min-w-[48px] text-center disabled:opacity-30",title:"fit"===p?"Actual size (1)":"Fit to view (0)",children:z}),(0,r.jsx)("button",{onClick:S,disabled:!g,className:"px-2 py-1 rounded hover:bg-[var(--bg-hover)] transition-colors disabled:opacity-30",title:"Zoom in (+)",children:"+"})]})]}),(0,r.jsxs)("div",{ref:y,tabIndex:-1,className:`relative flex-1 min-h-[70vh] overflow-auto flex items-center justify-center outline-none ${l?"bg-checkerboard":"bg-[var(--bg-secondary)]"}`,children:[i&&!c&&(0,r.jsx)("div",{className:"absolute inset-0 flex items-center justify-center z-10",children:(0,r.jsx)("span",{className:"text-sm text-[var(--text-tertiary)] animate-pulse",children:"Loading..."})}),c&&(0,r.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center z-10 gap-2",children:[(0,r.jsx)("span",{className:"text-sm text-[var(--text-secondary)]",children:"Failed to load image"}),(0,r.jsx)("button",{onClick:w,className:"text-xs px-3 py-1.5 rounded-md bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] transition-colors",children:"Retry"})]}),(0,r.jsx)("img",{ref:j,src:t,alt:s,onLoad:N,onError:k,draggable:!1,className:"select-none",style:{display:c?"none":"block",...E}},m)]})]})}},20870:(e,t,s)=>{"use strict";s.r(t),s.d(t,{PdfRenderer:()=>a});var r=s(95155),n=s(12115);function a({filePath:e}){let t=`/api/file/raw?path=${encodeURIComponent(e)}`,[s,a]=(0,n.useState)(!0),[o,l]=(0,n.useState)(!1),[i,d]=(0,n.useState)(0),c=(0,n.useCallback)(()=>{l(!1),a(!0),d(e=>e+1)},[]);return(0,r.jsxs)("div",{className:"w-full h-full min-h-[80vh] flex flex-col relative",children:[s&&!o&&(0,r.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-[var(--bg-secondary)] rounded-lg z-10",children:(0,r.jsx)("span",{className:"text-sm text-[var(--text-tertiary)] animate-pulse",children:"Loading PDF..."})}),o&&(0,r.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-[var(--bg-secondary)] rounded-lg z-10 gap-2",children:[(0,r.jsx)("span",{className:"text-sm text-[var(--text-secondary)]",children:"Failed to load PDF"}),(0,r.jsx)("button",{onClick:c,className:"text-xs px-3 py-1.5 rounded-md bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] transition-colors",children:"Retry"})]}),(0,r.jsx)("iframe",{src:t,className:"w-full flex-1 min-h-[80vh] border-0 rounded-lg bg-[var(--bg-secondary)]",title:e.split("/").pop()??"PDF",onLoad:()=>a(!1),onError:()=>{a(!1),l(!0)},style:{display:o?"none":"block"}},i)]})}},22554:(e,t,s)=>{"use strict";s.d(t,{default:()=>nw});var r=s(95155),n=s(73321),a=s(12115),o=s(98500),l=s.n(o),i=s(29857),d=s(61878),c=s(89363),u=s(33210),m=s(59511),x=s(47857),p=s(46029),h=s(49619),g=s(53961),f=s(34530),b=s(91958),v=s(41641),j=s(21362),y=s(91053),N=s(12651),k=s(62791),w=s(22356),S=s(13545),C=s(6296),A=s(8765),z=s(94514),E=s(31025),T=s(15411),$=s(7915),R=s(20171);function M(e,t){if(!e)return t?.timeNever??"never";let s=Date.now()-new Date(e).getTime();if(s<6e4)return t?.timeJustNow??"just now";let r=Math.floor(s/6e4);if(s<36e5)return t?.timeMinAgo?.(r)??`${r}m ago`;let n=Math.floor(s/36e5);if(s<864e5)return t?.timeHourAgo?.(n)??`${n}h ago`;let a=Math.floor(s/864e5);return t?.timeDayAgo?.(a)??`${a}d ago`}function D(e,t,s){let r=e.toLowerCase();return r.includes("permission denied")||r.includes("publickey")?s?.hintSshAuth??"SSH key may not be configured. Run: ssh-keygen -t ed25519 && ssh -T git@github.com":r.includes("host key")||r.includes("known_hosts")||r.includes("fingerprint")?s?.hintSshHost??"Run: ssh-keyscan github.com >> ~/.ssh/known_hosts":r.includes("authentication failed")||r.includes("invalid credentials")||r.includes("401")||r.includes("403")?s?.hintHttpsAuth??"Access token may be expired or missing. Check Settings → Developer settings → Personal access tokens.":r.includes("timed out")||r.includes("timeout")||r.includes("could not resolve")?s?.hintNetwork??"Check your network connection and try again.":r.includes("not found")||r.includes("does not exist")||r.includes("repository not found")?s?.hintNotFound??"Repository not found. Check the URL and ensure the repo exists.":r.includes("non-fast-forward")||r.includes("rejected")||r.includes("fetch first")?s?.hintPushRejected??'Remote has changes. Click "Sync Now" to pull and retry.':r.includes("conflict")||r.includes("merge")?s?.hintConflict??"Merge conflict detected. Check the Conflicts section below.":""}function I({file:e,time:t,syncT:s,onResolved:n}){let[o,l]=(0,a.useState)(null),[i,d]=(0,a.useState)(!1),[c,u]=(0,a.useState)(null),[m,x]=(0,a.useState)(!1),p=async()=>{if(i)return void d(!1);if(!c){x(!0);try{let t=await (0,w.n)("/api/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"conflict-preview",remote:e})});u(t)}catch{}x(!1)}d(!0)},h=async t=>{l("keep-local"===t?"local":"remote");try{await (0,w.n)("/api/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"resolve-conflict",remote:e,branch:t})}),n()}catch{l(null)}};return(0,r.jsxs)("div",{className:"rounded-lg border border-border/50 overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 p-2 text-xs bg-muted/20",children:[(0,r.jsx)(S.A,{size:12,className:"text-error shrink-0"}),(0,r.jsxs)("button",{type:"button",onClick:p,className:"font-mono truncate hover:text-foreground hover:underline transition-colors flex-1 min-w-0 text-left",title:s?.viewDiff??"View differences",children:[(0,r.jsx)(j.A,{size:11,className:`inline mr-1 transition-transform ${i?"rotate-90":""}`}),e]}),(0,r.jsx)("span",{className:"text-muted-foreground shrink-0",children:M(t,s)}),(0,r.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,r.jsx)("button",{type:"button",onClick:()=>h("keep-local"),disabled:!!o,className:"px-2 py-0.5 rounded border border-border text-2xs hover:bg-muted transition-colors disabled:opacity-40",title:s?.keepLocalHint??"Keep this device's version",children:"local"===o?(0,r.jsx)(C.A,{size:10,className:"animate-spin"}):s?.keepLocal??"Keep local"}),(0,r.jsx)("button",{type:"button",onClick:()=>h("keep-remote"),disabled:!!o,className:"px-2 py-0.5 rounded border border-border text-2xs hover:bg-muted transition-colors disabled:opacity-40",title:s?.keepRemoteHint??"Replace with remote version",children:"remote"===o?(0,r.jsx)(C.A,{size:10,className:"animate-spin"}):s?.keepRemote??"Keep remote"})]})]}),i&&(0,r.jsx)("div",{className:"border-t border-border/50",children:m?(0,r.jsx)("div",{className:"flex justify-center py-3",children:(0,r.jsx)(C.A,{size:13,className:"animate-spin text-muted-foreground"})}):c?(0,r.jsxs)("div",{className:"grid grid-cols-2 divide-x divide-border/50 text-2xs font-mono max-h-60 overflow-auto",children:[(0,r.jsxs)("div",{className:"p-2",children:[(0,r.jsx)("div",{className:"text-muted-foreground mb-1 font-sans text-xs font-medium",children:s?.localVersion??"Local (this device)"}),(0,r.jsx)("pre",{className:"whitespace-pre-wrap text-foreground/80 leading-relaxed",children:c.local||(s?.emptyFile??"(empty)")})]}),(0,r.jsxs)("div",{className:"p-2",children:[(0,r.jsx)("div",{className:"text-muted-foreground mb-1 font-sans text-xs font-medium",children:s?.remoteVersion??"Remote"}),(0,r.jsx)("pre",{className:"whitespace-pre-wrap text-foreground/80 leading-relaxed",children:c.remote||(s?.emptyFile??"(empty)")})]})]}):null})]})}function L({syncT:e}){let[t,s]=(0,a.useState)(!1),[n,o]=(0,a.useState)(""),[l,i]=(0,a.useState)(""),[d,c]=(0,a.useState)(!1),[u,m]=(0,a.useState)(!1),x=(0,a.useRef)(!1),p=n!==l;(0,a.useEffect)(()=>{t&&!x.current&&(x.current=!0,c(!0),(0,w.n)("/api/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"gitignore-get"})}).then(e=>{o(e.content),i(e.content)}).catch(()=>{}).finally(()=>c(!1)))},[t]);let h=async()=>{try{await (0,w.n)("/api/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"gitignore-save",content:n})}),i(n),m(!0),setTimeout(()=>m(!1),2e3)}catch{}};return(0,r.jsxs)("div",{className:"pt-2 border-t border-border/50",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>s(!t),className:"flex items-center gap-2 w-full text-left text-sm text-muted-foreground hover:text-foreground transition-colors py-1",children:[(0,r.jsx)(j.A,{size:14,className:`shrink-0 transition-transform ${t?"rotate-90":""}`}),(0,r.jsx)(A.A,{size:13,className:"shrink-0"}),(0,r.jsx)("span",{children:e?.gitignoreTitle??"Excluded files"}),(0,r.jsx)("span",{className:"text-2xs opacity-50",children:".gitignore"})]}),t&&(0,r.jsx)("div",{className:"mt-2 space-y-2",children:d?(0,r.jsx)("div",{className:"flex justify-center py-4",children:(0,r.jsx)(C.A,{size:14,className:"animate-spin text-muted-foreground"})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("textarea",{value:n,onChange:e=>o(e.target.value),rows:8,className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-xs font-mono leading-relaxed text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring resize-y",placeholder:e?.gitignorePlaceholder??"# Files to exclude from sync\n*.tmp\nsecret/",spellCheck:!1}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[p&&(0,r.jsx)("button",{type:"button",onClick:h,className:"flex items-center gap-1.5 px-3 py-1 text-xs rounded-lg bg-[var(--amber)] text-[var(--amber-foreground)] hover:opacity-90 transition-opacity",children:e?.gitignoreSave??"Save"}),u&&(0,r.jsxs)("span",{className:"flex items-center gap-1 text-xs text-success",children:[(0,r.jsx)(z.A,{size:12})," ",e?.gitignoreSaved??"Saved"]})]})]})})]})}function P({t:e,onInitComplete:t}){var s;let n=e.settings?.sync,[o,l]=(0,a.useState)(""),[i,d]=(0,a.useState)(""),[c,u]=(0,a.useState)("main"),[m,x]=(0,a.useState)(!1),[p,h]=(0,a.useState)(-1),[g,f]=(0,a.useState)(""),b=(0,a.useRef)(null),v=p>=0&&p<4,j=o.trim()?(s=o.trim(),/^https:\/\/.+/.test(s)?"https":!!/^git@[\w.-]+:.+/.test(s)&&"ssh"):null,y="https"===j||"ssh"===j,k=async()=>{h(0),f("");let e=(e,t)=>setTimeout(()=>h(t=>t>=0&&t<4?e:t),t);b.current=e(1,2e3);let s=e(2,5e3);try{await (0,w.n)("/api/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"init",remote:o.trim(),token:i.trim()||void 0,branch:c.trim()||"main"}),timeout:12e4}),h(4),setTimeout(()=>t(),600)}catch(s){let e=s instanceof Error?s.message:"Connection failed";e.includes("timed out")&&(e=n?.timeoutError??"Connection timed out. The remote repository may be large or the network is slow. Please try again.");let t=D(e,o,n);f(t?`${e}
|
|
2
|
-
${t}`:e),h(-1)}finally{b.current&&clearTimeout(b.current),clearTimeout(s)}},A=[n?.stepConnecting??"Connecting to remote...",n?.stepAuthenticating??"Authenticating...",n?.stepSyncing??"Syncing data...",n?.stepAlmostDone??"Almost done..."];return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)(R.L7,{icon:(0,r.jsx)(E.A,{size:15}),title:n?.emptyTitle??"Cross-device Sync",description:n?.emptyDesc??"Automatically sync your knowledge base across devices via Git.",children:[(0,r.jsxs)(R.D0,{label:n?.remoteUrl??"Git Remote URL",hint:"ssh"===j?n?.sshHint??"Requires SSH key on this machine. Verify with: ssh -T git@github.com":void 0,children:[(0,r.jsx)(R.pd,{type:"text",value:o,onChange:e=>{l(e.target.value),f("")},placeholder:"git@github.com:user/repo.git",className:`font-mono ${o.trim()&&!y?"border-destructive":""}`}),!o.trim()&&(0,r.jsxs)("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground mt-1.5",children:[(0,r.jsxs)("span",{children:[(0,r.jsx)("code",{className:"text-foreground/60 bg-muted/60 px-1 py-0.5 rounded text-2xs",children:"SSH"})," ",n?.sshBrief??"one-time key setup, no token needed"]}),(0,r.jsxs)("span",{children:[(0,r.jsx)("code",{className:"text-foreground/60 bg-muted/60 px-1 py-0.5 rounded text-2xs",children:"HTTPS"})," ",n?.httpsBrief??"works anywhere, token recommended"]})]}),o.trim()&&!y&&(0,r.jsx)("p",{className:"text-xs text-destructive mt-1",children:n?.invalidUrl??"Invalid Git URL — use HTTPS (https://...) or SSH (git@...)"})]}),"https"===j&&(0,r.jsxs)(R.D0,{label:(0,r.jsxs)(r.Fragment,{children:[n?.accessToken??"Access Token"," ",(0,r.jsx)("span",{className:"text-muted-foreground font-normal",children:n?.optional??"(optional, for private repos)"})]}),hint:void 0,children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(R.pd,{type:m?"text":"password",value:i,onChange:e=>d(e.target.value),placeholder:"ghp_xxxxxxxxxxxx",className:"pr-9 font-mono"}),(0,r.jsx)("button",{type:"button",onClick:()=>x(!m),className:"absolute right-2 top-1/2 -translate-y-1/2 p-0.5 rounded hover:bg-muted text-muted-foreground transition-colors",children:m?(0,r.jsx)(T.A,{size:14}):(0,r.jsx)($.A,{size:14})})]}),(0,r.jsxs)("p",{className:"text-xs text-muted-foreground mt-1",children:[n?.tokenHint??"GitHub:"," ",(0,r.jsx)("a",{href:"https://github.com/settings/tokens/new?scopes=repo&description=MindOS+Sync",target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-foreground transition-colors",children:n?.tokenLink??"Create a token (repo scope)"})]})]}),(0,r.jsx)(R.D0,{label:n?.branchLabel??"Branch",children:(0,r.jsx)(R.pd,{type:"text",value:c,onChange:e=>u(e.target.value),placeholder:"main",className:"max-w-[200px] font-mono"})}),!v&&4!==p&&(0,r.jsx)(R.jn,{onClick:k,disabled:!y,className:"flex items-center gap-2",children:n?.connectButton??"Connect & Start Sync"}),(v||4===p)&&(0,r.jsxs)("div",{className:"space-y-2 py-1",children:[A.map((e,t)=>{let s=p>t||4===p,n=p===t&&p<4;return p<t&&p<4?null:(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[s?(0,r.jsx)(z.A,{size:13,className:"text-success shrink-0"}):(0,r.jsx)(C.A,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),(0,r.jsx)("span",{className:s?"text-success":n?"text-foreground":"text-muted-foreground",children:e})]},t)}),4===p&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,r.jsx)(N.A,{size:13,className:"text-success shrink-0"}),(0,r.jsx)("span",{className:"text-success font-medium",children:n?.stepDone??"Sync configured successfully!"})]})]}),g&&(0,r.jsxs)("div",{className:"flex items-start gap-2 text-xs p-3 rounded-lg bg-destructive/10 text-destructive",role:"alert","aria-live":"polite",children:[(0,r.jsx)(S.A,{size:13,className:"shrink-0 mt-0.5"}),(0,r.jsx)("div",{className:"space-y-1",children:g.split("\n").map((e,t)=>(0,r.jsx)("span",{className:`block ${t>0?"text-destructive/70":""}`,children:e},t))})]})]}),(0,r.jsx)("div",{className:"grid grid-cols-2 gap-2 text-xs text-muted-foreground px-5",children:[n?.featureAutoCommit??"Auto-commit on save",n?.featureAutoPull??"Auto-pull from remote",n?.featureConflict??"Conflict detection",n?.featureMultiDevice??"Works across devices"].map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)(N.A,{size:11,className:"text-success/60 shrink-0"}),(0,r.jsx)("span",{children:e})]},t))})]})}function F({t:e}){let t=e.settings?.sync,[s,n]=(0,a.useState)(null),[o,l]=(0,a.useState)(!0),[i,d]=(0,a.useState)(!1),[c,u]=(0,a.useState)(!1),[m,x]=(0,a.useState)(null),p=(0,a.useCallback)(async()=>{try{let e=await (0,w.n)("/api/sync",{timeout:1e4});n(e)}catch{n(e=>e??null)}finally{l(!1)}},[]);(0,a.useEffect)(()=>{p()},[p]);let h=async()=>{d(!0),x(null);try{await (0,w.n)("/api/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"now"}),timeout:12e4}),x({type:"success",text:t?.syncComplete??"Sync complete"}),await p()}catch(r){var e;let s;x({type:"error",text:(s=D(e=r instanceof Error?r.message:"Sync failed",void 0,t))?`${e}
|
|
3
|
-
${s}`:e})}finally{d(!1),setTimeout(()=>x(null),3e3)}},g=async()=>{if(!s)return;u(!0),x(null);let e=s.enabled?"off":"on";try{await (0,w.n)("/api/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e})}),await p(),x({type:"success",text:s.enabled?t?.autoSyncDisabled??"Auto-sync disabled":t?.autoSyncEnabled??"Auto-sync enabled"})}catch{x({type:"error",text:t?.toggleFailed??"Failed to toggle sync"})}finally{u(!1),setTimeout(()=>x(null),3e3)}},f=async()=>{u(!0);try{await (0,w.n)("/api/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"reset"})}),await p()}catch{x({type:"error",text:t?.resetFailed??"Failed to reset sync configuration"})}finally{u(!1),setTimeout(()=>x(null),3e3)}};if(o)return(0,r.jsx)("div",{className:"flex justify-center py-8",children:(0,r.jsx)(C.A,{size:18,className:"animate-spin text-muted-foreground"})});if(!s||!s.enabled)return(0,r.jsx)(P,{t:e,onInitComplete:p});if(s.needsSetup)return(0,r.jsx)("div",{className:"space-y-6",children:(0,r.jsxs)("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-destructive/10",children:[(0,r.jsx)(S.A,{size:18,className:"text-destructive shrink-0 mt-0.5"}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-destructive",children:t?.brokenTitle??"Sync configuration is broken"}),(0,r.jsx)("p",{className:"text-xs text-destructive/80",children:s.lastError||(t?.brokenDesc??"The git repository or remote is missing. Reset to re-configure.")}),(0,r.jsxs)(R.jn,{onClick:f,disabled:c,className:"flex items-center gap-2 mt-2",children:[c&&(0,r.jsx)(C.A,{size:14,className:"animate-spin"}),t?.resetButton??"Reset & Re-configure"]})]})]})});let v=s.conflicts||[];return(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsxs)(R.L7,{icon:(0,r.jsx)(E.A,{size:15}),title:t?.sectionTitle??"Sync",description:s.remote,badge:(0,r.jsx)("span",{className:"text-2xs px-1.5 py-0.5 rounded bg-success/15 text-success font-medium",children:t?.labelEnabled??"Active"}),children:[(0,r.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:t?.labelBranch??"Branch"}),(0,r.jsx)("span",{className:"font-mono text-xs",children:s.branch})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:t?.labelLastSync??"Last sync"}),(0,r.jsx)("span",{className:"text-xs",children:M(s.lastSync,t)})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:t?.labelUnpushed??"Unpushed"}),(0,r.jsx)("span",{className:"text-xs",children:"string"==typeof s.unpushed&&/^\d+$/.test(s.unpushed)?t?.unpushedCommits?.(parseInt(s.unpushed,10))??`${s.unpushed} commits`:`${s.unpushed??"?"} commits`})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:t?.labelAutoSync??"Auto-sync"}),(0,r.jsxs)("span",{className:"flex items-center gap-1 text-xs",children:["commit"," ",(0,r.jsxs)("select",{className:"bg-muted rounded px-1.5 py-0.5 text-xs border border-border cursor-pointer",value:s.autoCommitInterval,onChange:async e=>{let t=parseInt(e.target.value,10);try{(await fetch("/api/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"update-intervals",autoCommitInterval:t})})).ok&&p()}catch{}},children:[(0,r.jsx)("option",{value:10,children:"10s"}),(0,r.jsx)("option",{value:15,children:"15s"}),(0,r.jsx)("option",{value:30,children:"30s"}),(0,r.jsx)("option",{value:60,children:"60s"}),(0,r.jsx)("option",{value:120,children:"120s"})]})," \xb7 pull ",(0,r.jsxs)("select",{className:"bg-muted rounded px-1.5 py-0.5 text-xs border border-border cursor-pointer",value:s.autoPullInterval,onChange:async e=>{let t=parseInt(e.target.value,10);try{(await fetch("/api/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"update-intervals",autoPullInterval:t})})).ok&&p()}catch{}},children:[(0,r.jsx)("option",{value:60,children:"1min"}),(0,r.jsx)("option",{value:120,children:"2min"}),(0,r.jsx)("option",{value:300,children:"5min"}),(0,r.jsx)("option",{value:600,children:"10min"}),(0,r.jsx)("option",{value:1800,children:"30min"}),(0,r.jsx)("option",{value:3600,children:"60min"})]})]})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 pt-1",children:[(0,r.jsxs)("button",{type:"button",onClick:h,disabled:i,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg border border-border text-muted-foreground hover:text-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:[(0,r.jsx)(b.A,{size:12,className:i?"animate-spin":""}),t?.syncNow??"Sync Now"]}),(0,r.jsx)("button",{type:"button",onClick:g,disabled:c,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg border border-border text-muted-foreground hover:text-destructive hover:border-destructive/50 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:t?.disableAutoSync??"Disable Auto-sync"})]}),m&&(0,r.jsx)("div",{className:"flex items-start gap-1.5 text-xs",role:"status","aria-live":"polite",children:"success"===m.type?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(N.A,{size:13,className:"text-success shrink-0 mt-0.5"}),(0,r.jsx)("span",{className:"text-success",children:m.text})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(S.A,{size:13,className:"text-destructive shrink-0 mt-0.5"}),(0,r.jsx)("div",{className:"space-y-0.5",children:m.text.split("\n").map((e,t)=>(0,r.jsx)("span",{className:`block ${t>0?"text-destructive/70":"text-destructive"}`,children:e},t))})]})}),v.length>0&&(0,r.jsxs)("div",{className:"pt-2 border-t border-border/50 space-y-3",children:[(0,r.jsx)("p",{className:"text-xs font-medium text-foreground",children:t?.conflictsTitle?.(v.length)??`Conflicts (${v.length})`}),(0,r.jsx)("p",{className:"text-2xs text-muted-foreground",children:t?.conflictExplain??"These files were changed on both this device and the remote. Choose which version to keep for each file."}),(0,r.jsx)("div",{className:"space-y-2",children:v.map((e,s)=>(0,r.jsx)(I,{file:e.file,time:e.time,syncT:t,onResolved:p},s))})]}),s.lastError&&0===v.length&&(0,r.jsxs)("div",{className:"flex items-start gap-2 text-xs p-2.5 rounded-lg bg-destructive/10 text-destructive",children:[(0,r.jsx)(S.A,{size:12,className:"shrink-0 mt-0.5"}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("span",{className:"block",children:s.lastError}),D(s.lastError,s.remote,t)&&(0,r.jsx)("span",{className:"block text-destructive/70",children:D(s.lastError,s.remote,t)})]})]}),(0,r.jsx)(L,{syncT:t})]})})}function O(e,t){return t?"syncing":e&&e.enabled?e.lastError?"error":e.conflicts&&e.conflicts.length>0?"conflicts":parseInt(e.unpushed||"0",10)>0?"unpushed":"synced":"off"}let _={synced:"bg-success",unpushed:"bg-yellow-500",conflicts:"bg-error",error:"bg-error",off:"bg-muted-foreground/40",syncing:"bg-blue-500"};function U(){let[e,t]=(0,a.useState)(null),[s,r]=(0,a.useState)(!1),n=(0,a.useRef)(void 0),o=(0,a.useCallback)(async()=>{try{let e=await (0,w.n)("/api/sync");t(e)}catch{t(null)}finally{r(!0)}},[]);return(0,a.useEffect)(()=>{o();let e=()=>{n.current&&clearInterval(n.current),n.current=setInterval(o,3e4)},t=()=>{n.current&&clearInterval(n.current),n.current=void 0};e();let s=()=>{"visible"===document.visibilityState?(o(),e()):t()};return document.addEventListener("visibilitychange",s),()=>{t(),document.removeEventListener("visibilitychange",s)}},[o]),{status:e,loaded:s,fetchStatus:o}}function B(e){let[t,s]=(0,a.useState)(!1),[r,n]=(0,a.useState)(null),o=(0,a.useCallback)(async()=>{if(!t){s(!0),n(null);try{await (0,w.n)("/api/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"now"})}),await e(),n("success")}catch{await e(),n("error")}finally{s(!1),setTimeout(()=>n(null),2500)}}},[t,e]);return{syncing:t,syncResult:r,syncNow:o}}function W(e,t,s){switch(e){case"syncing":{let e=s?.syncing??"Syncing...";return{label:e,tooltip:e}}case"synced":{let e=`${s?.synced??"Synced"} \xb7 ${M(t?.lastSync)}`;return{label:e,tooltip:e}}case"unpushed":{let e=parseInt(t?.unpushed||"0",10);return{label:`${e} ${s?.unpushed??"awaiting push"}`,tooltip:s?.unpushedHint??`${e} commit(s) not yet pushed to remote`}}case"conflicts":{let e=t?.conflicts?.length||0;return{label:`${e} ${s?.conflicts??"conflicts"}`,tooltip:s?.conflictsHint??`${e} file(s) have merge conflicts — resolve in Settings > Sync`}}case"error":return{label:s?.syncError??"Sync error",tooltip:t?.lastError||(s?.syncError??"Sync error")};default:{let e=s?.syncOff??"Sync off";return{label:e,tooltip:e}}}}function H({collapsed:e,onOpenSyncSettings:t}){let{status:s,loaded:n,fetchStatus:o}=U(),{syncing:l,syncResult:i,syncNow:d}=B(o),[c,u]=(0,a.useState)(null),m=(0,a.useRef)("off"),[x,p]=(0,a.useState)(()=>{try{return!!localStorage.getItem("sync-hint-dismissed")}catch(e){console.warn("[SyncStatusBar] localStorage read failed:",e)}return!1}),{t:h}=(0,y.Y)();if(!function(e){let[,t]=(0,a.useState)(0);(0,a.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),6e4);return()=>clearInterval(e)},[6e4])}(0),(0,a.useEffect)(()=>{if(!n||l)return;let e=O(s,!1),t=m.current;if(t!==e){let s=h.sidebar?.sync;("error"===t||"conflicts"===t)&&"synced"===e&&(u(s?.syncRestored??"Sync restored"),setTimeout(()=>u(null),3e3)),m.current=e}},[s,n,l,h]),!n||e)return null;let g=O(s,l);if("off"===g){if(x)return null;let e=h.sidebar?.sync;return(0,r.jsxs)("div",{className:"hidden md:flex items-center justify-between px-4 py-1.5 border-t border-border text-xs text-muted-foreground shrink-0 animate-in fade-in duration-300",children:[(0,r.jsxs)("button",{onClick:t,className:"flex items-center gap-2 min-w-0 hover:text-foreground transition-colors truncate",title:e?.enableHint??"Set up cross-device sync",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0 bg-muted-foreground/40"}),(0,r.jsxs)("span",{className:"truncate",children:[e?.enableSync??"Enable sync"," →"]})]}),(0,r.jsx)("button",{onClick:e=>{e.stopPropagation();try{localStorage.setItem("sync-hint-dismissed","1")}catch(e){console.warn("[SyncStatusBar] localStorage write dismissed:",e)}p(!0)},className:"p-1 rounded hover:bg-muted hover:text-foreground transition-colors shrink-0 ml-2 text-muted-foreground/50 hover:text-muted-foreground",title:"Dismiss",children:(0,r.jsx)("span",{className:"text-2xs",children:"✕"})})]})}let f=h.sidebar?.sync,{label:v,tooltip:j}=W(g,s,f);return(0,r.jsxs)("div",{className:"hidden md:flex items-center justify-between px-4 py-1.5 border-t border-border text-xs text-muted-foreground shrink-0 animate-in fade-in duration-300",children:[(0,r.jsxs)("button",{onClick:t,className:"flex items-center gap-2 min-w-0 hover:text-foreground transition-colors truncate",title:j,children:[(0,r.jsx)("span",{className:`w-2 h-2 rounded-full shrink-0 ${_[g]} ${"syncing"===g||"conflicts"===g?"animate-pulse":""}`}),(0,r.jsx)("span",{className:"truncate",children:c||v})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1 shrink-0 ml-2",children:[("success"===i||c)&&(0,r.jsx)(N.A,{size:12,className:"text-success animate-in fade-in duration-200"}),"error"===i&&(0,r.jsx)(k.A,{size:12,className:"text-error animate-in fade-in duration-200"}),(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),d()},disabled:l,className:"p-1 rounded hover:bg-muted hover:text-foreground transition-colors disabled:opacity-40",title:f?.syncNow??"Sync now",children:(0,r.jsx)(b.A,{size:12,className:l?"animate-spin":""})})]})]})}function K({status:e,syncing:t}){let s=O(e,t??!1);return"off"===s||"synced"===s?null:(0,r.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ${_[s]} ${"conflicts"===s||"error"===s?"animate-pulse":""}`})}var G=s(59960);function Y({icon:e,label:t,shortcut:s,active:n=!1,expanded:a,onClick:o,buttonRef:l,badge:i,walkthroughId:d}){return(0,r.jsxs)("button",{ref:l,onClick:o,"aria-pressed":n,"aria-label":t,title:s?`${t} (${s})`:t,"data-walkthrough":d,className:`
|
|
4
|
-
relative flex items-center ${a?"justify-start px-3 w-full":"justify-center w-10"} h-10 rounded-md transition-colors
|
|
5
|
-
${n?"text-[var(--amber)] bg-[var(--amber-dim)]":"text-muted-foreground hover:text-foreground hover:bg-muted"}
|
|
6
|
-
focus-visible:ring-2 focus-visible:ring-ring
|
|
7
|
-
`,children:[n&&(0,r.jsx)("span",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-[2px] h-[18px] rounded-r-full bg-[var(--amber)]"}),(0,r.jsx)("span",{className:"shrink-0 flex items-center justify-center w-[18px]",children:e}),i,a&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"ml-2.5 text-sm whitespace-nowrap",children:t}),s&&(0,r.jsx)("span",{className:"ml-auto text-2xs text-muted-foreground/60 font-mono shrink-0",children:s})]})]})}function J({activePanel:e,onPanelChange:t,onEchoClick:s,onAgentsClick:n,onDiscoverClick:o,onWorkflowsClick:i,onSpacesClick:u,syncStatus:m,expanded:N,onExpandedChange:k,onSettingsClick:w,onSyncClick:S}){let C=(0,a.useRef)(0),A=(0,a.useRef)(null),{t:z}=(0,y.Y)(),[E,T]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let e=window.mindos;if(e?.checkUpdate){let t=e.checkUpdate.bind(e),s=setTimeout(async()=>{try{(await t()).available&&T(!0)}catch{}},1e4),r=e.onUpdateAvailable?.(()=>T(!0));return()=>{clearTimeout(s),r?.()}}let t=localStorage.getItem("mindos_update_dismissed"),s=localStorage.getItem("mindos_update_latest");s&&s!==t&&T(!0);let r=setTimeout(async()=>{try{let e=await fetch("/api/update-check",{signal:AbortSignal.timeout(5e3)});if(!e.ok)return;let t=await e.json();if(!t.hasUpdate){localStorage.removeItem("mindos_update_latest"),localStorage.removeItem("mindos_update_dismissed"),T(!1);return}let s=localStorage.getItem("mindos_update_dismissed");if(t.latest===s)return;localStorage.setItem("mindos_update_latest",t.latest),T(!0)}catch{}},5e3),n=()=>T(!0),a=()=>T(!1);return window.addEventListener("mindos:update-available",n),window.addEventListener("mindos:update-dismissed",a),()=>{clearTimeout(r),window.removeEventListener("mindos:update-available",n),window.removeEventListener("mindos:update-dismissed",a)}},[]);let[$,R]=(0,a.useState)(!1),[M,D]=(0,a.useState)(!1);(0,a.useEffect)(()=>{R("1"===localStorage.getItem("mindos:labs-echo")),D("1"===localStorage.getItem("mindos:labs-workflows"));let e=()=>{R("1"===localStorage.getItem("mindos:labs-echo")),D("1"===localStorage.getItem("mindos:labs-workflows"))};return window.addEventListener("mindos:labs-changed",e),()=>window.removeEventListener("mindos:labs-changed",e)},[]);let I=(0,a.useCallback)(e=>{let t=Date.now();t-C.current<300||(C.current=t,e())},[]),L=(0,a.useCallback)(s=>{I(()=>t(e===s?null:s))},[e,t,I]),P=O(m,!1),F=N?180:48,U="off"!==P&&"synced"!==P?(0,r.jsx)("span",{className:`absolute ${N?"left-[26px] top-1.5":"top-1.5 right-1.5"} w-2 h-2 rounded-full ${_[P]} ${"error"===P||"conflicts"===P?"animate-pulse":""}`}):void 0;return(0,r.jsxs)("aside",{className:"group hidden md:flex fixed top-0 left-0 h-screen z-[31] flex-col bg-background border-r border-border transition-[width] duration-200 ease-out",style:{width:`${F}px`},role:"toolbar","aria-label":"Navigation","aria-orientation":"vertical",children:[(0,r.jsxs)("div",{className:"flex flex-col h-full w-full overflow-hidden",children:[(0,r.jsxs)(l(),{href:"/",className:`flex items-center ${N?"px-3 gap-2":"justify-center"} w-full h-[45px] shrink-0 hover:opacity-80 transition-opacity`,"aria-label":"MindOS Home",children:[(0,r.jsx)(G.A,{id:"rail",className:"w-7 h-3.5 shrink-0"}),N&&(0,r.jsx)("span",{className:"text-sm text-foreground font-brand whitespace-nowrap",children:"MindOS"})]}),(0,r.jsx)("div",{className:`${N?"mx-3":"mx-2"} border-t border-border`}),(0,r.jsxs)("div",{className:`flex flex-col ${N?"px-1.5":"items-center"} gap-1 py-2`,children:[(0,r.jsx)(Y,{icon:(0,r.jsx)(x.A,{size:18}),label:z.sidebar.files,active:"files"===e,expanded:N,onClick:()=>u?I(u):L("files"),walkthroughId:"files-panel"}),$&&(0,r.jsx)(Y,{icon:(0,r.jsx)(p.A,{size:18}),label:z.sidebar.echo,active:"echo"===e,expanded:N,onClick:()=>s?I(s):L("echo"),walkthroughId:"echo-panel"}),(0,r.jsx)(Y,{icon:(0,r.jsx)(d.A,{size:18}),label:z.sidebar.searchTitle,shortcut:"⌘K",active:"search"===e,expanded:N,onClick:()=>L("search")}),(0,r.jsx)(Y,{icon:(0,r.jsx)(h.A,{size:18}),label:z.sidebar.agents,active:"agents"===e,expanded:N,onClick:()=>n?I(n):L("agents"),walkthroughId:"agents-panel"}),M&&(0,r.jsx)(Y,{icon:(0,r.jsx)(g.A,{size:18}),label:z.sidebar.workflows??"Flows",active:"workflows"===e,expanded:N,onClick:()=>i?I(i):L("workflows")})]}),(0,r.jsx)("div",{className:"flex-1"}),(0,r.jsx)("div",{className:`${N?"mx-3":"mx-2"} border-t border-border`}),(0,r.jsx)("div",{className:`flex flex-col ${N?"px-1.5":"items-center"} gap-1 py-2`,children:(0,r.jsx)(Y,{icon:(0,r.jsx)(f.A,{size:18}),label:z.sidebar.discover,active:"discover"===e,expanded:N,onClick:()=>o?I(o):L("discover")})}),(0,r.jsx)("div",{className:`${N?"mx-3":"mx-2"} border-t border-border`}),(0,r.jsxs)("div",{className:`flex flex-col ${N?"px-1.5":"items-center"} gap-1 py-2`,children:[(0,r.jsx)(Y,{icon:(0,r.jsx)(c.A,{size:18}),label:z.sidebar.settingsTitle,shortcut:"⌘,",expanded:N,onClick:()=>I(w),badge:E?(0,r.jsx)("span",{className:`absolute ${N?"left-[26px] top-1.5":"top-1.5 right-1.5"} w-2 h-2 rounded-full bg-error`}):void 0}),m?.enabled&&m?.remote&&"(not configured)"!==m.remote&&(0,r.jsx)(Y,{icon:(0,r.jsx)(b.A,{size:18}),label:z.sidebar.syncLabel,expanded:N,buttonRef:A,badge:U,onClick:()=>I(()=>{let e=A.current?.getBoundingClientRect();e&&S(e)})})]})]}),(0,r.jsx)("button",{onClick:()=>k(!N),className:" absolute right-0 top-1/2 -translate-y-1/2 translate-x-1/2 z-[32] w-5 h-5 rounded-full bg-card border border-border shadow-sm flex items-center justify-center opacity-0 group-hover:opacity-100 hover:!opacity-100 transition-opacity duration-200 text-muted-foreground hover:text-foreground hover:bg-muted focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-ring ","aria-label":N?"Collapse sidebar":"Expand sidebar",title:N?"Collapse":"Expand",children:N?(0,r.jsx)(v.A,{size:10}):(0,r.jsx)(j.A,{size:10})})]})}var V=s(51914),q=s(48368),Z=s(33024),Q=s(10579),X=s(38569),ee=s(56563),et=s(60285),es=s(15282),er=s(68459),en=s(82125),ea=s(91337),eo=s(33078),el=s(997),ei=s(94290),ed=s(67635),ec=s(49387),eu=s(66088),em=s(42129),ex=s(38798),ep=s(9339);let eh=(0,ep.createServerReference)("40289b249d6dfc8a4575aac816866972665d90d1b0",ep.callServer,void 0,ep.findSourceMapURL,"convertToSpaceAction"),eg=(0,ep.createServerReference)("60f29abf6d4cc6f20a617986b6c16c018eaa8f06b1",ep.callServer,void 0,ep.findSourceMapURL,"createFileAction"),ef=(0,ep.createServerReference)("609fe9b0b2c7d399738a663492c86f249f7cdaa100",ep.callServer,void 0,ep.findSourceMapURL,"renameSpaceAction");var eb=s(2736);let ev=(0,ep.createServerReference)("406d5e07dd1f760d65eca07925dee0612da18b4283",ep.callServer,void 0,ep.findSourceMapURL,"deleteSpaceAction"),ej=(0,ep.createServerReference)("40e5c58505c56cc2e8e4d0b07c324638b3b03c0155",ep.callServer,void 0,ep.findSourceMapURL,"deleteFolderAction");var ey=s(70736),eN=s(56532),ek=s(4235),ew=s(39498),eS=s(10377);async function eC(){try{let e=await (0,w.n)("/api/settings"),t=e.ai?.provider??"",s=(e.ai?.providers??{})[t];return!!s?.apiKey}catch{return!1}}function eA(e,t,s=""){let r="u">typeof document&&"zh"===document.documentElement.lang?`初始化新建的心智空间「${e}」,路径为「${t}/」。${s?`描述:「${s}」。`:""}两个文件均已存在模板,用 write_file 覆盖:
|
|
8
|
-
1. 「${t}/README.md」— 写入空间用途、结构概览、使用指南
|
|
9
|
-
2. 「${t}/INSTRUCTION.md」— 写入 AI Agent 在此空间中的行为规则和操作约定
|
|
10
|
-
|
|
11
|
-
内容简洁实用,直接使用工具写入。`:`Initialize the new Mind Space "${e}" at "${t}/". ${s?`Description: "${s}". `:""}Both files already exist with templates — use write_file to overwrite:
|
|
12
|
-
1. "${t}/README.md" — write purpose, structure overview, usage guidelines
|
|
13
|
-
2. "${t}/INSTRUCTION.md" — write rules for AI agents operating in this space
|
|
14
|
-
|
|
15
|
-
Keep content concise and actionable. Write files directly using tools.`;window.dispatchEvent(new CustomEvent("mindos:ai-init",{detail:{spaceName:e,spacePath:t,description:s,state:"working"}})),fetch("/api/ask",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:[{role:"user",content:r}],currentFile:t+"/INSTRUCTION.md"})}).then(async e=>{if(!e.ok||!e.body)throw Error(`HTTP ${e.status}`);let s=e.body.getReader();try{for(;;){let{done:e}=await s.read();if(e)break}}finally{s.releaseLock()}window.dispatchEvent(new CustomEvent("mindos:ai-init",{detail:{spacePath:t,state:"done"}})),window.dispatchEvent(new Event("mindos:files-changed"))}).catch(()=>{window.dispatchEvent(new CustomEvent("mindos:ai-init",{detail:{spacePath:t,state:"error"}}))})}function ez(){window.dispatchEvent(new Event("mindos:files-changed"))}async function eE(e){try{await navigator.clipboard.writeText(e)}catch{}}let eT="show-hidden-files";function e$(e){let t=t=>{t.key===eT&&e()},s=()=>e();return window.addEventListener("storage",t),window.addEventListener("mindos:hidden-files-changed",s),()=>{window.removeEventListener("storage",t),window.removeEventListener("mindos:hidden-files-changed",s)}}function eR(){return"true"===localStorage.getItem(eT)}function eM(e){localStorage.setItem(eT,String(e)),window.dispatchEvent(new Event("mindos:hidden-files-changed"))}function eD(){return(0,a.useSyncExternalStore)(e$,eR,()=>!1)}function eI({x:e,y:t,onClose:s,menuHeight:n,children:o}){let l=(0,a.useRef)(null);(0,a.useEffect)(()=>{let e=e=>{l.current&&!l.current.contains(e.target)&&s()},t=e=>{"Escape"===e.key&&s()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[s]);let i=Math.min(t,window.innerHeight-(n??160)),d=Math.min(e,window.innerWidth-200);return(0,r.jsx)("div",{ref:l,className:"fixed z-50 min-w-[180px] bg-card border border-border rounded-lg shadow-lg py-1",style:{top:i,left:d},children:o})}let eL="w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground hover:bg-muted transition-colors text-left",eP="w-full flex items-center gap-2 px-3 py-2 text-sm text-error hover:bg-error/10 transition-colors text-left",eF="my-1 border-t border-border/50";function eO({x:e,y:t,node:s,onClose:a,onRename:o,onNewFile:l,onImport:i,onDelete:d}){let c=(0,n.useRouter)(),{t:u}=(0,y.Y)(),{isPinned:x,togglePin:p}=(0,eS.Z)(),h=x(s.path);return(0,r.jsxs)(eI,{x:e,y:t,onClose:a,children:[(0,r.jsxs)("button",{className:eL,onClick:()=>{l(),a()},children:[(0,r.jsx)(V.A,{size:14,className:"shrink-0"})," ",u.fileTree.newFile]}),(0,r.jsxs)("button",{className:eL,onClick:()=>{c.push(`/view/${(0,ea.O0)(`${s.path}/INSTRUCTION.md`)}`),a()},children:[(0,r.jsx)(el.A,{size:14,className:"shrink-0"})," ",u.fileTree.viewRules]}),i&&(0,r.jsxs)("button",{className:eL,onClick:()=>{i(s.path),a()},children:[(0,r.jsx)(m.A,{size:14,className:"shrink-0"})," ",u.fileTree.importFile]}),(0,r.jsx)("div",{className:eF}),(0,r.jsxs)("button",{className:eL,onClick:()=>{p(s.path),a()},children:[(0,r.jsx)(ei.A,{size:14,className:`shrink-0 ${h?"fill-[var(--amber)] text-[var(--amber)]":""}`}),h?u.fileTree.removeFromFavorites:u.fileTree.pinToFavorites]}),(0,r.jsxs)("button",{className:eL,onClick:()=>{eE(s.path),a()},children:[(0,r.jsx)(ed.A,{size:14,className:"shrink-0"})," ",u.fileTree.copyPath]}),(0,r.jsxs)("button",{className:eL,onClick:()=>{o(),a()},children:[(0,r.jsx)(ec.A,{size:14,className:"shrink-0"})," ",u.fileTree.renameSpace]}),(0,r.jsx)("div",{className:eF}),(0,r.jsxs)("button",{className:eP,onClick:()=>{a(),d()},children:[(0,r.jsx)(er.A,{size:14,className:"shrink-0"}),u.fileTree.deleteSpace]})]})}function e_({x:e,y:t,node:s,onClose:o,onRename:l,onNewFile:i,onDelete:d}){let c=(0,n.useRouter)(),{t:u}=(0,y.Y)(),[m,x]=(0,a.useTransition)(),{isPinned:p,togglePin:h}=(0,eS.Z)(),g=p(s.path);return(0,r.jsxs)(eI,{x:e,y:t,onClose:o,menuHeight:220,children:[(0,r.jsxs)("button",{className:eL,onClick:()=>{i(),o()},children:[(0,r.jsx)(V.A,{size:14,className:"shrink-0"})," ",u.fileTree.newFile]}),(0,r.jsx)("div",{className:eF}),(0,r.jsxs)("button",{className:eL,onClick:()=>{h(s.path),o()},children:[(0,r.jsx)(ei.A,{size:14,className:`shrink-0 ${g?"fill-[var(--amber)] text-[var(--amber)]":""}`}),g?u.fileTree.removeFromFavorites:u.fileTree.pinToFavorites]}),(0,r.jsxs)("button",{className:eL,disabled:m,onClick:()=>{x(async()=>{if((await eh(s.path)).success){c.refresh(),ez();let e=s.name.replace(/^[\p{Emoji_Presentation}\p{Extended_Pictographic}\s]+/u,"")||s.name;eC().then(t=>{t&&eA(e,s.path)})}o()})},children:[(0,r.jsx)(Z.A,{size:14,className:"shrink-0 text-[var(--amber)]"})," ",u.fileTree.convertToSpace]}),(0,r.jsxs)("button",{className:eL,onClick:()=>{eE(s.path),o()},children:[(0,r.jsx)(ed.A,{size:14,className:"shrink-0"})," ",u.fileTree.copyPath]}),(0,r.jsxs)("button",{className:eL,onClick:()=>{l(),o()},children:[(0,r.jsx)(ec.A,{size:14,className:"shrink-0"})," ",u.fileTree.rename]}),(0,r.jsx)("div",{className:eF}),(0,r.jsxs)("button",{className:eP,onClick:()=>{o(),d()},children:[(0,r.jsx)(er.A,{size:14,className:"shrink-0"}),u.fileTree.deleteFolder]})]})}function eU({dirPath:e,depth:t,onDone:s}){let[o,l]=(0,a.useState)(""),[i,d]=(0,a.useTransition)(),[c,u]=(0,a.useState)(""),m=(0,n.useRouter)(),{t:x}=(0,y.Y)(),p=(0,a.useRef)(null),h=(0,a.useCallback)(()=>{let t=o.trim();t?d(async()=>{let r=await eg(e,t);r.success&&r.filePath?(s(),m.push(`/view/${(0,ea.O0)(r.filePath)}`),m.refresh(),ez()):u(r.error||x.fileTree.failed)}):u(x.fileTree.enterFileName)},[o,e,s,m,x]);return(0,a.useEffect)(()=>{let e=e=>{p.current&&!p.current.contains(e.target)&&s()},t=setTimeout(()=>document.addEventListener("mousedown",e),0);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[s]),(0,r.jsxs)("div",{ref:p,className:"px-2 pb-1",style:{paddingLeft:`${12*t+20}px`},children:[(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("input",{autoFocus:!0,type:"text",value:o,onChange:e=>{l(e.target.value),u("")},onKeyDown:e=>{"Enter"===e.key&&h(),"Escape"===e.key&&s()},placeholder:"filename.md",className:" flex-1 bg-muted border border-border rounded px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring "}),i?(0,r.jsx)(C.A,{size:13,className:"text-muted-foreground animate-spin shrink-0"}):(0,r.jsx)("button",{onClick:h,className:"text-xs text-[var(--amber)] hover:text-foreground shrink-0 px-1",children:x.fileTree.create})]}),c&&(0,r.jsx)("p",{className:"text-xs text-error mt-0.5 px-1",children:c})]})}function eB({node:e,depth:t,currentPath:s,onNavigate:o,maxOpenDepth:l,onImport:i}){let d=(0,n.useRouter)(),c=s.startsWith(e.path+"/")||s===e.path,u=!!e.isSpace,[m,x]=(0,a.useState)(0===t||c),[p,h]=(0,a.useState)(!1),[g,f]=(0,a.useState)(!1),[b,v]=(0,a.useState)(e.name),[j,N]=(0,a.useTransition)(),k=(0,a.useRef)(null),w=(0,a.useRef)(null),[S,A]=(0,a.useState)(null),{t:z}=(0,y.Y)(),[E,T]=(0,a.useState)(null),[$,R]=(0,a.useTransition)(),M=(0,a.useCallback)(()=>x(e=>!e),[]),D=(0,a.useRef)(void 0);(0,a.useEffect)(()=>{if(null==l){D.current=l;return}D.current!==l&&(null===D.current||void 0===D.current?t>l&&x(!1):x(t<=l),D.current=l)},[l,t]),(0,a.useEffect)(()=>()=>{w.current&&clearTimeout(w.current)},[]);let I=(0,a.useCallback)(t=>{t?.preventDefault(),t?.stopPropagation(),w.current&&(clearTimeout(w.current),w.current=null),v(e.name),f(!0),setTimeout(()=>k.current?.select(),0)},[e.name]),L=(0,a.useCallback)(()=>{let t=b.trim();t&&t!==e.name?N(async()=>{let s=u?ef:eb.f,r=await s(e.path,t);r.success&&r.newPath?(f(!1),d.push(`/view/${(0,ea.O0)(r.newPath)}`),d.refresh(),ez()):f(!1)}):f(!1)},[b,e.name,e.path,d,u]),P=(0,a.useCallback)(()=>{g||(w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{d.push(`/view/${(0,ea.O0)(e.path)}`),o?.(),w.current=null},180))},[g,d,e.path,o]);(0,a.useCallback)(e=>{e.stopPropagation(),M()},[M]);let F=(0,a.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),A({x:e.clientX,y:e.clientY})},[]),O=u?function e(t){return"file"===t.type?+!en.C.has(t.name):(t.children??[]).reduce((t,s)=>t+e(s),0)}(e):0;if(g)return(0,r.jsxs)("div",{className:"relative px-2 py-0.5",style:{paddingLeft:`${12*t+8}px`},children:[(0,r.jsx)("input",{ref:k,autoFocus:!0,value:b,onChange:e=>v(e.target.value),onKeyDown:e=>{"Enter"===e.key&&L(),"Escape"===e.key&&f(!1)},onBlur:L,className:"w-full bg-muted border border-border rounded px-2 py-0.5 text-xs text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"}),j&&(0,r.jsx)(C.A,{size:12,className:"absolute right-3 top-1/2 -translate-y-1/2 animate-spin text-muted-foreground"})]});let _=u&&0===t;return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"relative group/dir flex items-center",onContextMenu:F,children:[(0,r.jsx)("button",{onClick:M,className:"shrink-0 p-1 rounded hover:bg-muted text-muted-foreground transition-colors",style:{marginLeft:`${12*t+4}px`},"aria-label":m?`Collapse ${e.name}`:`Expand ${e.name}`,"aria-expanded":m,children:(0,r.jsx)("span",{className:"block transition-transform duration-150",style:{transform:m?"rotate(0deg)":"rotate(-90deg)"},children:(0,r.jsx)(eu.A,{size:10})})}),(0,r.jsxs)("button",{type:"button",onClick:P,draggable:!0,onDragStart:t=>{t.dataTransfer.setData("text/mindos-path",e.path),t.dataTransfer.setData("text/mindos-type","directory"),t.dataTransfer.effectAllowed="copy"},className:`
|
|
16
|
-
flex-1 flex items-center gap-1.5 px-1 py-1 rounded text-left min-w-0 pr-16
|
|
17
|
-
text-sm transition-colors duration-100
|
|
18
|
-
hover:bg-muted cursor-default
|
|
19
|
-
${c?"text-foreground":"text-muted-foreground hover:text-foreground"}
|
|
20
|
-
`,children:[u?"Inbox"===e.name?(0,r.jsx)(es.A,{size:14,className:"shrink-0 text-[var(--amber)]"}):(0,r.jsx)(Z.A,{size:14,className:"shrink-0 text-[var(--amber)]"}):m?(0,r.jsx)(em.A,{size:14,className:"text-yellow-400 shrink-0"}):(0,r.jsx)(ex.A,{size:14,className:"text-yellow-400 shrink-0"}),(0,r.jsx)("span",{className:"truncate leading-5",suppressHydrationWarning:!0,children:e.name}),u&&!m&&(0,r.jsx)("span",{className:"ml-auto text-xs text-muted-foreground shrink-0 tabular-nums pr-1",children:O})]}),(0,r.jsx)("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 hidden group-hover/dir:flex items-center gap-0.5 z-10",children:(0,r.jsx)("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation();let t=e.currentTarget.getBoundingClientRect();A({x:t.left,y:t.bottom+4})},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",title:"More",children:(0,r.jsx)(et.A,{size:14})})})]}),(0,r.jsx)("div",{className:`grid transition-[grid-template-rows] duration-200 ease-out ${m?"grid-rows-[1fr]":"grid-rows-[0fr]"}`,children:(0,r.jsxs)("div",{className:`overflow-hidden ${_?"border-l-2 ml-[18px]":""}`,style:_?{borderColor:"color-mix(in srgb, var(--amber) 30%, transparent)"}:void 0,...!m&&{inert:!0},children:[e.children&&(0,r.jsx)(eH,{nodes:e.children,depth:_?1:t+1,onNavigate:o,maxOpenDepth:l,parentIsSpace:u,onImport:i}),p&&(0,r.jsx)(eU,{dirPath:e.path,depth:_?0:t,onDone:()=>h(!1)})]})}),S&&(u?(0,r.jsx)(eO,{x:S.x,y:S.y,node:e,onClose:()=>A(null),onRename:()=>I(),onNewFile:()=>{x(!0),h(!0)},onImport:i,onDelete:()=>T("space")}):(0,r.jsx)(e_,{x:S.x,y:S.y,node:e,onClose:()=>A(null),onRename:()=>I(),onNewFile:()=>{x(!0),h(!0)},onDelete:()=>T("folder")})),(0,r.jsx)(ew.TM,{open:null!==E,title:"space"===E?z.fileTree.deleteSpace:z.fileTree.deleteFolder,message:"space"===E?z.fileTree.confirmDeleteSpace(e.name):z.fileTree.confirmDeleteFolder(e.name),confirmLabel:"space"===E?z.fileTree.deleteSpace:z.fileTree.deleteFolder,cancelLabel:z.view?.cancel??"Cancel",variant:"destructive",onCancel:()=>T(null),onConfirm:()=>{T(null),R(async()=>{let t="space"===E?await ev(e.path):await ej(e.path);if(t.success&&t.trashId){let s=t.trashId,r=e.path.split("/").pop()??e.path;ek.oR.undo(`${z.trash?.movedToTrash??"Deleted"} ${r}`,async()=>{let e=await (0,ey.Y)(s);e.success?(d.refresh(),ez()):ek.oR.error(e.error??"Undo failed")},{label:z.trash?.undo??"Undo"}),d.push("/"),d.refresh(),ez()}})}})]})}function eW({node:e,depth:t,currentPath:s,onNavigate:o}){let l=(0,n.useRouter)(),i=s===e.path,[d,c]=(0,a.useState)(!1),[u,m]=(0,a.useState)(e.name),[x,p]=(0,a.useTransition)(),[,h]=(0,a.useTransition)(),g=(0,a.useRef)(null),{t:f}=(0,y.Y)(),{isPinned:b,togglePin:v}=(0,eS.Z)(),j=b(e.path),N=!e.path.includes("/")&&en.A.has(e.name),[k,w]=(0,a.useState)(!1),[S,A]=(0,a.useState)(null),z=(0,a.useCallback)(()=>{d||(l.push(`/view/${(0,ea.O0)(e.path)}`),o?.())},[l,e.path,o,d]),E=(0,a.useCallback)(t=>{t.stopPropagation(),m(e.name),c(!0),setTimeout(()=>g.current?.select(),0)},[e.name]),T=(0,a.useCallback)(()=>{let t=u.trim();t&&t!==e.name?p(async()=>{let s=await (0,eb.f)(e.path,t);s.success&&s.newPath?(c(!1),l.push(`/view/${(0,ea.O0)(s.newPath)}`),l.refresh(),ez()):c(!1)}):c(!1)},[u,e.name,e.path,l]),$=(0,a.useCallback)(e=>{e.stopPropagation(),w(!0)},[]),R=(0,a.useCallback)(t=>{t.dataTransfer.setData("text/mindos-path",e.path),t.dataTransfer.effectAllowed="copy"},[e.path]),M=(0,a.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),A({x:e.clientX,y:e.clientY})},[]);return d?(0,r.jsxs)("div",{className:"relative px-2 py-0.5",style:{paddingLeft:`${12*t+8}px`},children:[(0,r.jsx)("input",{ref:g,autoFocus:!0,value:u,onChange:e=>m(e.target.value),onKeyDown:e=>{"Enter"===e.key&&T(),"Escape"===e.key&&c(!1)},onBlur:T,className:"w-full bg-muted border border-border rounded px-2 py-0.5 text-xs text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"}),x&&(0,r.jsx)(C.A,{size:12,className:"absolute right-3 top-1/2 -translate-y-1/2 animate-spin text-muted-foreground"})]}):(0,r.jsxs)("div",{className:"relative group/file",children:[(0,r.jsxs)("button",{onClick:z,onContextMenu:M,draggable:!0,onDragStart:R,"data-filepath":e.path,className:`
|
|
21
|
-
w-full flex items-center gap-1.5 px-2 py-1 rounded text-left
|
|
22
|
-
text-sm transition-colors duration-100 cursor-default pr-16
|
|
23
|
-
${i?"bg-accent text-foreground":"hover:bg-muted text-muted-foreground hover:text-foreground"}
|
|
24
|
-
`,style:{paddingLeft:`${12*t+8}px`},children:["directory"===e.type?null:".csv"===e.extension?(0,r.jsx)(eo.A,{size:14,className:"text-success shrink-0"}):(0,r.jsx)(q.A,{size:14,className:"text-muted-foreground shrink-0"}),(0,r.jsx)("span",{className:"truncate leading-5",suppressHydrationWarning:!0,children:e.name}),j&&(0,r.jsx)(ei.A,{size:10,className:"shrink-0 fill-[var(--amber)] text-[var(--amber)] opacity-60"})]}),(0,r.jsx)("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 hidden group-hover/file:flex items-center gap-0.5",children:(0,r.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation();let t=e.currentTarget.getBoundingClientRect();A({x:t.left,y:t.bottom+4})},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",title:"More",children:(0,r.jsx)(et.A,{size:14})})}),S&&(0,r.jsxs)(eI,{x:S.x,y:S.y,onClose:()=>A(null),menuHeight:140,children:[(0,r.jsxs)("button",{className:eL,onClick:()=>{eE(e.path),A(null)},children:[(0,r.jsx)(ed.A,{size:14,className:"shrink-0"})," ",f.fileTree.copyPath]}),(0,r.jsxs)("button",{className:eL,onClick:()=>{v(e.path),A(null)},children:[(0,r.jsx)(ei.A,{size:14,className:`shrink-0 ${j?"fill-[var(--amber)] text-[var(--amber)]":""}`}),j?f.fileTree.removeFromFavorites:f.fileTree.pinToFavorites]}),!N&&(0,r.jsxs)("button",{className:eL,onClick:e=>{A(null),E(e)},children:[(0,r.jsx)(ec.A,{size:14,className:"shrink-0"})," ",f.fileTree.rename]}),!N&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:eF}),(0,r.jsxs)("button",{className:eP,onClick:e=>{A(null),$(e)},children:[(0,r.jsx)(er.A,{size:14,className:"shrink-0"})," ",f.fileTree.delete]})]})]}),(0,r.jsx)(ew.TM,{open:k,title:f.fileTree.delete,message:f.fileTree.confirmDelete(e.name),confirmLabel:f.fileTree.delete,cancelLabel:f.view?.cancel??"Cancel",variant:"destructive",onCancel:()=>w(!1),onConfirm:()=>{w(!1),h(async()=>{let t=await (0,eN.i)(e.path);if(t.success){if(t.trashId){let s=t.trashId,r=e.path.split("/").pop()??e.path;ek.oR.undo(`${f.trash?.movedToTrash??"Deleted"} ${r}`,async()=>{let e=await (0,ey.Y)(s);e.success?(l.refresh(),ez()):ek.oR.error(e.error??"Undo failed")},{label:f.trash?.undo??"Undo"})}l.refresh(),ez()}})}})]})}function eH({nodes:e,depth:t=0,onNavigate:s,maxOpenDepth:o,parentIsSpace:l,onImport:i}){var d;let c,u=(c="/view/",(d=(0,n.usePathname)()).startsWith(c)?d.slice(c.length).split("/").map(decodeURIComponent).join("/"):""),m=eD(),x=0===t,p=m?e:e.filter(e=>!(x&&e.name.startsWith(".")||"file"===e.type&&en.C.has(e.name)||"directory"===e.type&&e.name.startsWith("."))),h=x?p.filter(e=>"directory"!==e.type||"Inbox"!==e.name):p;return(0,a.useEffect)(()=>{if(!u||0!==t)return;let e=setTimeout(()=>{let e=document.querySelector(`[data-filepath="${CSS.escape(u)}"]`);e?.scrollIntoView({block:"nearest",behavior:"smooth"})},120);return()=>clearTimeout(e)},[u,t]),(0,r.jsx)("div",{className:"flex flex-col gap-0.5",children:h.map(e=>"directory"===e.type?(0,r.jsx)(eB,{node:e,depth:t,currentPath:u,onNavigate:s,maxOpenDepth:o,onImport:i},e.path):(0,r.jsx)(eW,{node:e,depth:t,currentPath:u,onNavigate:s},e.path))})}var eK=s(60241),eG=s(24371);function eY({title:e,children:t,maximized:s,onMaximize:n}){return(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 h-[46px] border-b border-border shrink-0",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:e}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[t,n&&(0,r.jsx)("button",{onClick:n,className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors","aria-label":s?"Restore panel":"Maximize panel",children:s?(0,r.jsx)(eK.A,{size:13}):(0,r.jsx)(eG.A,{size:13})})]})]})}function eJ({width:e,minWidth:t,maxWidth:s,maxWidthRatio:r,direction:n,disabled:o,onResize:l,onResizeEnd:i}){let d=(0,a.useRef)(!1),c=(0,a.useRef)(0),u=(0,a.useRef)(0),m=(0,a.useRef)(e);return m.current=e,(0,a.useCallback)(a=>{if(o)return;a.preventDefault(),d.current=!0,c.current=a.clientX,u.current=e,document.body.classList.add("select-none"),document.body.style.cursor="col-resize";let x=e=>{if(!d.current)return;let a="right"===n?e.clientX-c.current:c.current-e.clientX;l(Math.round(Math.max(t,Math.min(Math.min(s,window.innerWidth*r),u.current+a))))},p=()=>{d.current=!1,document.body.classList.remove("select-none"),document.body.style.cursor="",i(m.current),document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",p)};document.addEventListener("mousemove",x),document.addEventListener("mouseup",p)},[e,t,s,r,n,o,l,i])}let eV=(0,ep.createServerReference)("009286475afd7d7b14e85ea1aab03ef850c1ec5ca2",ep.callServer,void 0,ep.findSourceMapURL,"listTrashAction"),eq=()=>{},eZ={files:280,search:320,echo:340,agents:300,discover:300,workflows:320};function eQ({activePanel:e,fileTree:t,onNavigate:s,onOpenSyncSettings:o,railWidth:l=48,panelWidth:i,onWidthChange:d,onWidthCommit:c,maximized:u=!1,onMaximize:m,onImport:x,children:p}){let h=e?eZ[e]:280,g=u?void 0:i??h,{t:f}=(0,y.Y)(),b=(0,n.useRouter)(),[v,j]=(0,a.useState)(null),N=(0,a.useMemo)(()=>(function e(t,s=0){let r=s;for(let n of t)"directory"===n.type&&(r=Math.max(r,e(n.children??[],s+1)));return r})(t),[t]),[k,w]=(0,a.useState)(!1),S=(0,a.useRef)(null),C=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(!k)return;let e=e=>{S.current&&!S.current.contains(e.target)&&C.current&&!C.current.contains(e.target)&&w(!1)},t=e=>{"Escape"===e.key&&w(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[k]);let[A,z]=(0,a.useState)(!1),E=(0,a.useRef)(null),R=(0,a.useRef)(null),M=eD(),[D,I]=(0,a.useState)(0);(0,a.useEffect)(()=>{if(!A)return;let e=e=>{E.current&&!E.current.contains(e.target)&&R.current&&!R.current.contains(e.target)&&z(!1)},t=e=>{"Escape"===e.key&&z(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[A]);let[L,P]=(0,a.useState)(0);(0,a.useEffect)(()=>{let e=()=>{eV().then(e=>I(e.length)).catch(()=>{})},t=()=>{fetch("/api/inbox").then(e=>e.json()).then(e=>{Array.isArray(e.files)&&P(e.files.length)}).catch(()=>{})};return e(),t(),window.addEventListener("mindos:files-changed",e),window.addEventListener("mindos:inbox-updated",t),()=>{window.removeEventListener("mindos:files-changed",e),window.removeEventListener("mindos:inbox-updated",t)}},[]);let[F,O]=(0,a.useState)(!1);(0,a.useEffect)(()=>{try{"1"===localStorage.getItem("mindos-tree-dblclick-hint")&&O(!0)}catch{}},[]);let _=(0,a.useCallback)(()=>{if(!F){O(!0);try{localStorage.setItem("mindos-tree-dblclick-hint","1")}catch{}}},[F]),U=eJ({width:i??h,minWidth:240,maxWidth:600,maxWidthRatio:.45,direction:"right",disabled:u,onResize:d??eq,onResizeEnd:c??eq});return(0,r.jsxs)("aside",{className:`
|
|
25
|
-
hidden md:flex fixed top-0 h-screen z-30
|
|
26
|
-
flex-col bg-card border-r border-border
|
|
27
|
-
transition-[transform,left,width] duration-200 ease-out
|
|
28
|
-
${null!==e?"translate-x-0":"-translate-x-full pointer-events-none"}
|
|
29
|
-
`,style:{width:u?`calc(100vw - ${l}px)`:`${g}px`,left:`${l}px`},role:"region","aria-label":e?`${e} panel`:void 0,children:[(0,r.jsxs)("div",{className:`flex flex-col h-full ${"files"===e?"":"hidden"}`,children:[(0,r.jsx)(eY,{title:f.sidebar.files,children:(0,r.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("button",{ref:S,type:"button",onClick:()=>{z(!1),w(e=>!e)},className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors focus-visible:ring-1 focus-visible:ring-ring","aria-label":f.sidebar.new,title:f.sidebar.new,children:(0,r.jsx)(V.A,{size:13})}),k&&(0,r.jsxs)("div",{ref:C,className:"absolute top-full right-0 mt-1 min-w-[152px] bg-card border border-border rounded-lg shadow-lg py-1 z-50",children:[(0,r.jsxs)("button",{className:"w-full flex items-center gap-2 px-3 py-1.5 text-sm text-foreground hover:bg-muted transition-colors text-left",onClick:()=>{w(!1),b.push("/view/Untitled.md")},children:[(0,r.jsx)(q.A,{size:14,className:"shrink-0"}),f.sidebar.newFile]}),(0,r.jsxs)("button",{className:"w-full flex items-center gap-2 px-3 py-1.5 text-sm text-foreground hover:bg-muted transition-colors text-left",onClick:()=>{w(!1),window.dispatchEvent(new Event("mindos:create-space"))},children:[(0,r.jsx)(Z.A,{size:14,className:"shrink-0 text-[var(--amber)]"}),f.sidebar.newSpace]})]})]}),(0,r.jsx)("button",{type:"button",onClick:()=>x?.(),className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors focus-visible:ring-1 focus-visible:ring-ring","aria-label":f.sidebar.importFile,title:f.sidebar.importFile,children:(0,r.jsx)(Q.A,{size:13})}),(0,r.jsx)("div",{className:"w-px h-3.5 bg-border mx-0.5"}),(0,r.jsx)("button",{onClick:()=>j(e=>Math.max(-1,(e??N)-1)),onDoubleClick:()=>{j(-1),_()},className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors focus-visible:ring-1 focus-visible:ring-ring","aria-label":f.sidebar.collapseLevel,title:F?f.sidebar.collapseLevel:f.sidebar.collapseLevelHint??f.sidebar.collapseLevel,children:(0,r.jsx)(X.A,{size:13})}),(0,r.jsx)("button",{onClick:()=>j(e=>{let t=(e??0)+1;return t>N?null:t}),onDoubleClick:()=>{j(null),_()},className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors focus-visible:ring-1 focus-visible:ring-ring","aria-label":f.sidebar.expandLevel,title:F?f.sidebar.expandLevel:f.sidebar.expandLevelHint??f.sidebar.expandLevel,children:(0,r.jsx)(ee.A,{size:13})}),(0,r.jsx)("div",{className:"w-px h-3.5 bg-border mx-0.5"}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("button",{ref:E,type:"button",onClick:()=>{w(!1),z(e=>!e)},className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors focus-visible:ring-1 focus-visible:ring-ring","aria-label":f.sidebar.more,title:f.sidebar.more,children:(0,r.jsx)(et.A,{size:13})}),A&&(0,r.jsxs)("div",{ref:R,className:"absolute top-full right-0 mt-1 min-w-[172px] bg-card border border-border rounded-lg shadow-lg py-1 z-50",children:[(0,r.jsxs)("button",{className:"w-full flex items-center gap-2 px-3 py-1.5 text-sm text-foreground hover:bg-muted transition-colors text-left",onClick:()=>{eM(!M)},children:[M?(0,r.jsx)(T.A,{size:14,className:"shrink-0"}):(0,r.jsx)($.A,{size:14,className:"shrink-0"}),(0,r.jsx)("span",{className:"flex-1",children:f.sidebar.showHiddenFiles}),M&&(0,r.jsx)("span",{className:"text-[var(--amber)] text-xs",children:"✓"})]}),(0,r.jsx)("div",{className:"my-1 border-t border-border/50"}),(0,r.jsxs)("button",{className:"w-full flex items-center gap-2 px-3 py-1.5 text-sm text-foreground hover:bg-muted transition-colors text-left",onClick:()=>{z(!1),b.push("/view/Inbox/")},children:[(0,r.jsx)(es.A,{size:14,className:"shrink-0 text-[var(--amber)]"}),(0,r.jsx)("span",{className:"flex-1",children:f.sidebar.capture}),L>0&&(0,r.jsx)("span",{className:"text-xs font-medium text-[var(--amber)] tabular-nums",children:L})]}),(0,r.jsxs)("button",{className:"w-full flex items-center gap-2 px-3 py-1.5 text-sm text-foreground hover:bg-muted transition-colors text-left",onClick:()=>{z(!1),b.push("/trash")},children:[(0,r.jsx)(er.A,{size:14,className:"shrink-0"}),(0,r.jsx)("span",{className:"flex-1",children:f.trash.title}),D>0&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground tabular-nums",children:D})]})]})]})]})}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0 px-2 py-2",children:(0,r.jsx)(eH,{nodes:t,onNavigate:s,maxOpenDepth:v,onImport:x})}),(0,r.jsx)(H,{collapsed:!1,onOpenSyncSettings:o})]}),p,!u&&d&&(0,r.jsx)("div",{className:"absolute top-0 -right-[3px] w-[6px] h-full cursor-col-resize z-40 group hidden md:block",onMouseDown:U,children:(0,r.jsx)("div",{className:"absolute right-[2px] top-0 w-[2px] h-full opacity-0 group-hover:opacity-100 bg-[var(--amber)]/60 transition-opacity"})})]})}var eX=s(14871);function e0({active:e,onNavigate:t,maximized:s,onMaximize:o}){let[l,i]=(0,a.useState)(""),[c,m]=(0,a.useState)([]),[x,p]=(0,a.useState)(!1),[h,g]=(0,a.useState)(0),f=(0,a.useRef)(null),b=(0,n.useRouter)(),v=(0,a.useRef)(null),{t:j}=(0,y.Y)();(0,a.useEffect)(()=>{e&&setTimeout(()=>f.current?.focus(),50)},[e]);let N=(0,a.useCallback)(e=>{if(v.current&&clearTimeout(v.current),!e.trim()){m([]),p(!1);return}p(!0),v.current=setTimeout(async()=>{try{let t=await (0,w.n)(`/api/search?q=${encodeURIComponent(e)}`);m(Array.isArray(t)?t:[]),g(0)}catch{m([])}finally{p(!1)}},300)},[]),k=(0,a.useCallback)(e=>{let t=e.target.value;i(t),N(t)},[N]),S=(0,a.useCallback)(e=>{b.push(`/view/${(0,ea.O0)(e.path)}`),t?.()},[b,t]),C=(0,a.useCallback)(e=>{"ArrowDown"===e.key?(e.preventDefault(),g(e=>Math.min(e+1,c.length-1))):"ArrowUp"===e.key?(e.preventDefault(),g(e=>Math.max(e-1,0))):"Enter"===e.key&&c[h]&&S(c[h])},[c,h,S]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eY,{title:"Search",maximized:s,onMaximize:o}),(0,r.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2.5 border-b border-border shrink-0",children:[(0,r.jsx)(d.A,{size:14,className:"text-muted-foreground shrink-0"}),(0,r.jsx)("input",{ref:f,type:"text",value:l,onChange:k,onKeyDown:C,placeholder:j.search.placeholder,"aria-label":j.search.placeholder,className:"flex-1 bg-transparent text-foreground placeholder:text-muted-foreground text-sm outline-none"}),x&&(0,r.jsx)("div",{className:"w-3.5 h-3.5 border-2 border-muted-foreground/40 border-t-foreground rounded-full animate-spin shrink-0"}),!x&&l&&(0,r.jsx)("button",{onClick:()=>{i(""),m([]),f.current?.focus()},children:(0,r.jsx)(u.A,{size:13,className:"text-muted-foreground hover:text-foreground"})})]}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto min-h-0",role:"listbox","aria-label":"Search results",children:[0===c.length&&l&&!x&&(0,r.jsx)("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:j.search.noResults}),0===c.length&&!l&&(0,r.jsx)("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground/60",children:j.search.prompt}),c.length>0&&(0,r.jsx)(eX.aY,{totalCount:c.length,overscan:100,itemContent:e=>{let t=c[e],s=t.path.endsWith(".csv")?".csv":".md",n=t.path.split("/"),a=n[n.length-1],o=n.slice(0,-1).join("/");return(0,r.jsxs)("button",{role:"option","aria-selected":e===h,onClick:()=>S(t),onMouseEnter:()=>g(e),className:`
|
|
30
|
-
w-full px-4 py-2.5 flex items-start gap-3 text-left transition-colors duration-75
|
|
31
|
-
${e===h?"bg-muted":"hover:bg-muted/50"}
|
|
32
|
-
${e<c.length-1?"border-b border-border":""}
|
|
33
|
-
`,children:[".csv"===s?(0,r.jsx)(eo.A,{size:13,className:"text-success shrink-0 mt-0.5"}):(0,r.jsx)(q.A,{size:13,className:"text-muted-foreground shrink-0 mt-0.5"}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-baseline gap-2 flex-wrap",children:[(0,r.jsx)("span",{className:"text-sm text-foreground font-medium truncate",title:a,children:a}),o&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate",title:o,children:o})]}),t.snippet&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-2 leading-relaxed",title:t.snippet,children:function(e,t){if(!t.trim())return e;let s=t.trim().split(/\s+/).filter(Boolean).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),n=RegExp(`(${s.join("|")})`,"gi");return e.split(n).map((e,t)=>n.test(e)?(0,r.jsx)("mark",{className:"bg-yellow-300/40 text-foreground rounded-sm px-0.5",children:e},t):e)}(t.snippet,l)})]})]})}})]}),c.length>0&&(0,r.jsxs)("div",{className:"px-4 py-2 border-t border-border flex items-center gap-3 text-xs text-muted-foreground/50 shrink-0",children:[(0,r.jsxs)("span",{children:[(0,r.jsx)("kbd",{className:"font-mono",children:"↑↓"})," ",j.search.navigate]}),(0,r.jsxs)("span",{children:[(0,r.jsx)("kbd",{className:"font-mono",children:"↵"})," ",j.search.open]})]})]})}var e1=s(92451),e2=s(70617),e5=s(2857),e3=s(98401),e4=s(15573);function e6({icon:e,title:t,subtitle:s,badge:n,href:a,onClick:o,active:i}){let d=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-muted",children:e}),(0,r.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{className:"block text-left text-sm font-medium text-foreground truncate",title:t,children:t}),s?(0,r.jsx)("span",{className:"block text-left text-2xs text-muted-foreground truncate",title:s,children:s}):null]}),n,(0,r.jsx)(j.A,{size:14,className:"shrink-0 text-muted-foreground"})]}),c=!!(i&&a),u=(0,ea.cn)("relative flex items-center gap-3 py-2.5 transition-colors duration-150 rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",c?"bg-[var(--amber-dim)]/40 pl-3.5 pr-4 text-foreground":"px-4",a&&!c&&"cursor-pointer hover:bg-muted/50",c&&"cursor-default",!a&&"cursor-pointer hover:bg-muted/50");return a?(0,r.jsxs)(l(),{href:a,className:u,"aria-current":i?"page":void 0,children:[c?(0,r.jsx)("span",{className:"pointer-events-none absolute bottom-[22%] left-0 top-[22%] w-0.5 rounded-r-full bg-[var(--amber)]","aria-hidden":!0}):null,d]}):(0,r.jsx)("button",{type:"button",onClick:o,className:(0,ea.cn)(u,"w-full"),children:d})}function e8({label:e}){return(0,r.jsx)("span",{className:"text-2xs px-2 py-0.5 rounded-full bg-muted text-muted-foreground shrink-0",children:e})}function e9({copy:e,connectedCount:t,mcpEnabled:s=!0}){let a=(0,n.usePathname)(),o=(0,n.useSearchParams)().get("tab"),l="/agents"===a;return(0,r.jsxs)("div",{className:"py-2",children:[(0,r.jsx)(e6,{icon:(0,r.jsx)(e3.A,{size:14,className:l&&(null===o||"overview"===o)?"text-[var(--amber)]":"text-muted-foreground"}),title:e.navOverview,badge:(0,r.jsx)("span",{className:"text-2xs tabular-nums text-muted-foreground/60 px-1.5 py-0.5 rounded bg-muted/40 font-medium",children:t}),href:"/agents",active:l&&(null===o||"overview"===o)}),s&&(0,r.jsx)(e6,{icon:(0,r.jsx)(e4.A,{size:14,className:l&&"mcp"===o?"text-[var(--amber)]":"text-muted-foreground"}),title:e.navMcp,href:"/agents?tab=mcp",active:l&&"mcp"===o}),(0,r.jsx)(e6,{icon:(0,r.jsx)(g.A,{size:14,className:l&&"skills"===o?"text-[var(--amber)]":"text-muted-foreground"}),title:e.navSkills,href:"/agents?tab=skills",active:l&&"skills"===o}),(0,r.jsx)(e6,{icon:(0,r.jsx)(e1.A,{size:14,className:l&&"a2a"===o?"text-[var(--amber)]":"text-muted-foreground"}),title:e.navNetwork,href:"/agents?tab=a2a",active:l&&"a2a"===o})]})}var e7=s(20986);function te({agent:e,agentStatus:t,selected:s=!1,detailHref:n,onInstallAgent:a,copy:o,isA2aReady:i=!1,a2aTooltip:d}){return(0,r.jsxs)("div",{className:`
|
|
34
|
-
group flex items-center gap-0 rounded-xl border transition-all duration-150
|
|
35
|
-
${s?"border-border ring-2 ring-ring/50 bg-[var(--amber-dim)]/45":"border-border/70 bg-card/50 hover:border-border hover:bg-muted/25"}
|
|
36
|
-
`,children:[(0,r.jsxs)(l(),{href:n,className:"flex flex-1 min-w-0 items-center gap-2.5 text-left rounded-xl pl-2.5 pr-2 py-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,r.jsx)(ew.lx,{name:e.name,status:t,size:"sm"}),(0,r.jsx)("span",{className:"text-sm font-medium text-foreground truncate leading-tight",children:e.name}),"connected"===t&&e.transport&&(0,r.jsx)("span",{className:"text-2xs font-mono tabular-nums px-1.5 py-0.5 rounded-md bg-muted/90 text-muted-foreground shrink-0 border border-border/50",children:e.transport}),i&&(0,r.jsx)("span",{title:d,className:"shrink-0 text-muted-foreground/70",children:(0,r.jsx)(e1.A,{size:12})}),(0,r.jsx)("span",{className:"flex-1 min-w-[4px]"}),(0,r.jsx)(j.A,{size:15,className:`shrink-0 transition-opacity duration-150 ${s?"text-[var(--amber)] opacity-90":"text-muted-foreground/45 group-hover:text-muted-foreground/80"}`,"aria-hidden":!0})]}),"detected"===t&&(0,r.jsx)("div",{className:"pr-2 py-2 shrink-0",children:(0,r.jsx)(tt,{agentKey:e.key,agentName:e.name,onInstallAgent:a,copy:o})})]})}function tt({agentKey:e,agentName:t,onInstallAgent:s,copy:n}){let[o,l]=(0,a.useState)(!1),[i,d]=(0,a.useState)("idle"),c=async t=>{if(t.stopPropagation(),o)return;l(!0),d("idle");let r=await s(e);l(!1),d(r?"success":"error")},u="error"===i,m="success"===i,x=o?n.installing:m?n.installSuccess:u?n.retryInstall:n.install;return(0,r.jsxs)("button",{type:"button",onClick:c,disabled:o,className:`flex items-center gap-1 px-2 py-1.5 text-2xs rounded-lg font-medium text-white disabled:opacity-50 transition-colors shrink-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${u?"bg-error hover:bg-error/90":m?"bg-success hover:bg-success/90":"bg-[var(--amber)] hover:bg-[var(--amber)]/90"}`,"aria-label":`${t} ${x}`,children:[o?(0,r.jsx)(C.A,{size:10,className:"animate-spin"}):null,!o&&m?(0,r.jsx)(z.A,{size:10}):null,!o&&u?(0,r.jsx)(e7.A,{size:10}):null,x,(0,r.jsx)("span",{className:"sr-only","aria-live":"polite",children:u?n.installFailed:""})]})}function ts({connected:e,detected:t,notFound:s,selectedAgentKey:n,onInstallAgent:a,listCopy:o,showNotDetected:l,setShowNotDetected:i,p:d}){return(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"px-0 py-1.5 mb-1",children:(0,r.jsx)("span",{className:"text-2xs font-semibold text-muted-foreground/70 uppercase tracking-wider",children:d.rosterLabel})}),e.length>0&&(0,r.jsxs)("section",{className:"mb-3",children:[(0,r.jsxs)("h3",{className:"flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground/80 uppercase tracking-wider mb-2 pl-0.5",children:[(0,r.jsx)("span",{className:"w-1 h-3 rounded-full bg-[var(--success)]/50","aria-hidden":"true"}),d.sectionConnected," ",(0,r.jsxs)("span",{className:"text-muted-foreground/50 tabular-nums",children:["(",e.length,")"]})]}),(0,r.jsx)("div",{className:"space-y-1.5",children:e.map(e=>(0,r.jsx)(te,{agent:e,agentStatus:"connected",selected:n===e.key,detailHref:`/agents/${encodeURIComponent(e.key)}`,onInstallAgent:a,copy:o},e.key))})]}),t.length>0&&(0,r.jsxs)("section",{className:"mb-3",children:[(0,r.jsxs)("h3",{className:"flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground/80 uppercase tracking-wider mb-2 pl-0.5",children:[(0,r.jsx)("span",{className:"w-1 h-3 rounded-full bg-[var(--amber)]/50","aria-hidden":"true"}),d.sectionDetected," ",(0,r.jsxs)("span",{className:"text-muted-foreground/50 tabular-nums",children:["(",t.length,")"]})]}),(0,r.jsx)("div",{className:"space-y-1.5",children:t.map(e=>(0,r.jsx)(te,{agent:e,agentStatus:"detected",selected:n===e.key,detailHref:`/agents/${encodeURIComponent(e.key)}`,onInstallAgent:a,copy:o},e.key))})]}),s.length>0&&(0,r.jsxs)("section",{children:[(0,r.jsxs)("button",{type:"button",onClick:()=>i(!l),className:"flex items-center gap-1 text-[11px] font-medium text-muted-foreground uppercase tracking-wider mb-2 hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm pl-0.5",children:[l?(0,r.jsx)(eu.A,{size:12}):(0,r.jsx)(j.A,{size:12}),d.sectionNotDetected," (",s.length,")"]}),l&&(0,r.jsx)("div",{className:"space-y-1.5",children:s.map(e=>(0,r.jsx)(te,{agent:e,agentStatus:"notFound",selected:n===e.key,detailHref:`/agents/${encodeURIComponent(e.key)}`,onInstallAgent:a,copy:o},e.key))})]})]})}var tr=s(66709);function tn({active:e,maximized:t,onMaximize:s,selectedAgentKey:o=null}){let{t:l}=(0,y.Y)(),i=l.panels.agents,d=(0,e2.kr)(),u=(0,n.usePathname)(),[m,x]=(0,a.useState)(!1),[p,h]=(0,a.useState)(!1),[g,f]=(0,a.useState)(!1),v=(0,e5.V)(),j=async()=>{x(!0),await d.refresh(),x(!1)},N=d.agents.filter(e=>e.present&&e.installed),k=d.agents.filter(e=>e.present&&!e.installed),w=d.agents.filter(e=>!e.present),S=async e=>{let t=await d.installAgent(e);return t&&await d.refresh(),t},A=u?.startsWith("/agents/")?decodeURIComponent(u.slice(8)):null,z={installing:i.installing,install:i.install,installSuccess:i.installSuccess,installFailed:i.installFailed,retryInstall:i.retryInstall},E={navOverview:i.navOverview,navMcp:i.navMcp,navSkills:i.navSkills,navNetwork:i.navNetwork,navSessions:i.navSessions,navActivity:i.navActivity},T=(0,r.jsx)(e9,{copy:E,connectedCount:N.length,mcpEnabled:d.status?.connectionMode?.mcp??!1});return(0,r.jsxs)("div",{className:`flex flex-col h-full ${e?"":"hidden"}`,children:[(0,r.jsx)(eY,{title:i.title,maximized:t,onMaximize:s,children:(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[!d.loading&&(0,r.jsxs)("span",{className:"text-2xs text-muted-foreground",children:[N.length," ",i.connected,v.agents.length>0&&(0,r.jsxs)(r.Fragment,{children:[" \xb7 ",i.a2aLabel," ",v.agents.length]})]}),(0,r.jsx)("button",{onClick:j,disabled:m,className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground disabled:opacity-50 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":i.refresh,title:i.refresh,type:"button",children:(0,r.jsx)(b.A,{size:12,className:m?"animate-spin":""})})]})}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0",children:d.loading?(0,r.jsx)("div",{className:"flex justify-center py-8",children:(0,r.jsx)(C.A,{size:16,className:"animate-spin text-muted-foreground"})}):0===d.agents.length&&0===d.skills.length?(0,r.jsxs)("div",{className:"flex flex-col gap-2 py-4 px-0",children:[T,(0,r.jsx)("div",{className:"mx-4 border-t border-border"}),(0,r.jsxs)("div",{className:"mx-3 rounded-lg border border-border/40 bg-card/30 px-3 py-5 text-center",children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground/70 mb-1.5",children:i.noAgents}),(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/40 mb-3",children:i.skillsEmptyHint}),(0,r.jsxs)("button",{onClick:j,type:"button",className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs rounded-lg border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,r.jsx)(b.A,{size:11})," ",i.retry]})]})]}):(0,r.jsxs)("div",{className:"pb-3",children:[T,(0,r.jsx)("div",{className:"mx-4 border-t border-border"}),(0,r.jsx)("div",{className:"px-3 py-3 space-y-4",children:(0,r.jsx)(ts,{connected:N,detected:k,notFound:w,selectedAgentKey:A??o,listCopy:z,onInstallAgent:S,showNotDetected:p,setShowNotDetected:h,p:{rosterLabel:i.rosterLabel,sectionConnected:i.sectionConnected,sectionDetected:i.sectionDetected,sectionNotDetected:i.sectionNotDetected}})})]})}),(0,r.jsxs)("div",{className:"px-3 py-2 border-t border-border shrink-0 space-y-1",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>f(!0),className:"flex items-center gap-1.5 text-2xs text-muted-foreground hover:text-foreground transition-colors w-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm",children:[(0,r.jsx)(e1.A,{size:11}),i.a2aDiscover]}),(0,r.jsxs)("button",{type:"button",onClick:()=>{window.dispatchEvent(new CustomEvent("mindos:open-settings",{detail:{tab:"mcp"}}))},className:"flex items-center gap-1.5 text-2xs text-muted-foreground hover:text-foreground transition-colors w-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm",children:[(0,r.jsx)(c.A,{size:11}),i.advancedConfig]})]}),(0,r.jsx)(tr.A,{open:g,onClose:()=>f(!1),onDiscover:v.discover,discovering:v.discovering,error:v.error})]})}var ta=s(42869),to=s(6962),tl=s(5121),ti=s(31885),td=s(65266),tc=s(4903),tu=s(44478),tm=s(14780),tx=s(95057),tp=s(20555),th=s(27318),tg=s(46838);function tf({icon:e,title:t,prompt:s,tryLabel:n}){return(0,r.jsxs)("div",{className:"group flex items-center gap-2.5 px-4 py-1.5 hover:bg-muted/50 transition-colors rounded-sm mx-1",children:[(0,r.jsx)("span",{className:"text-muted-foreground shrink-0",children:e}),(0,r.jsx)("span",{className:"text-xs text-foreground truncate flex-1",title:t,children:t}),(0,r.jsx)("button",{onClick:()=>(0,th.NH)(s,"user"),className:"opacity-0 group-hover:opacity-100 text-2xs px-2 py-0.5 rounded text-[var(--amber-text)] bg-[var(--amber-dim)] hover:opacity-80 transition-all duration-150 shrink-0",children:n})]})}let tb={c1:(0,r.jsx)(ta.A,{size:12}),c2:(0,r.jsx)(to.A,{size:12}),c3:(0,r.jsx)(b.A,{size:12}),c4:(0,r.jsx)(tl.A,{size:12}),c5:(0,r.jsx)(ti.A,{size:12}),c6:(0,r.jsx)(td.A,{size:12}),c7:(0,r.jsx)(d.A,{size:12}),c8:(0,r.jsx)(tc.A,{size:12}),c9:(0,r.jsx)(tu.A,{size:12})};function tv({active:e,maximized:t,onMaximize:s}){let{t:o}=(0,y.Y)(),l=o.panels.discover,i=o.explore,d=o.panels.plugins,c=(0,n.useRouter)(),[u,m]=(0,a.useState)(!1),[x,p]=(0,a.useState)(!1),[,h]=(0,a.useState)(0),[f,b]=(0,a.useState)(new Set),v=(0,a.useRef)(!1);(0,a.useEffect)(()=>{(0,tg.UG)(),m(!0)},[]),(0,a.useEffect)(()=>{if(!u||v.current)return;v.current=!0;let e=(0,tg.MZ)().map(e=>e.entryPath).filter(e=>!!e);0!==e.length&&fetch("/api/files").then(e=>e.ok?e.json():[]).then(t=>{let s=new Set(t);b(new Set(e.filter(e=>s.has(e))))}).catch(e=>{console.warn("[DiscoverPanel] fetch /api/files failed:",e)})},[u]);let j=(0,a.useCallback)((e,t)=>{(0,tg.$7)(e,t),h(e=>e+1),window.dispatchEvent(new Event("renderer-state-changed"))},[]),N=(0,a.useCallback)(e=>{c.push(`/view/${e.split("/").map(encodeURIComponent).join("/")}`)},[c]),k=u?(0,tg.MZ)():[],w=u?k.filter(e=>(0,tg.pl)(e.id)).length:0;return(0,r.jsxs)("div",{className:`flex flex-col h-full ${e?"":"hidden"}`,children:[(0,r.jsx)(eY,{title:l.title,maximized:t,onMaximize:s}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto min-h-0",children:[(0,r.jsxs)("div",{className:"py-2",children:[(0,r.jsx)(e6,{icon:(0,r.jsx)(ti.A,{size:14,className:"text-[var(--amber)]"}),title:l.useCases,badge:(0,r.jsx)("span",{className:"text-2xs tabular-nums text-muted-foreground",children:tp.LD.length}),href:"/explore"}),(0,r.jsx)(e6,{icon:(0,r.jsx)(tm.A,{size:14,className:"text-muted-foreground"}),title:l.pluginMarket,badge:(0,r.jsx)(e8,{label:l.comingSoon})}),(0,r.jsx)(e6,{icon:(0,r.jsx)(g.A,{size:14,className:"text-muted-foreground"}),title:l.skillMarket,badge:(0,r.jsx)(e8,{label:l.comingSoon})}),(0,r.jsx)(e6,{icon:(0,r.jsx)(tx.A,{size:14,className:"text-muted-foreground"}),title:l.spaceTemplates,badge:(0,r.jsx)(e8,{label:l.comingSoon})})]}),(0,r.jsx)("div",{className:"mx-4 border-t border-border"}),(0,r.jsxs)("div",{className:"py-2",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>p(e=>!e),className:"w-full flex items-center gap-1.5 px-4 py-1.5 text-left",children:[(0,r.jsx)(eu.A,{size:11,className:`text-muted-foreground transition-transform duration-150 ${x?"":"-rotate-90"}`}),(0,r.jsx)(tm.A,{size:13,className:"text-muted-foreground shrink-0"}),(0,r.jsx)("span",{className:"text-2xs font-medium text-muted-foreground uppercase tracking-wider flex-1",children:d.title}),(0,r.jsxs)("span",{className:"text-2xs text-muted-foreground tabular-nums",children:[w,"/",k.length]})]}),(0,r.jsx)("div",{className:`grid transition-[grid-template-rows] duration-200 ease-out ${x?"grid-rows-[1fr]":"grid-rows-[0fr]"}`,children:(0,r.jsx)("div",{className:"overflow-hidden",...!x&&{inert:!0},children:k.map(e=>{let t=(0,tg.pl)(e.id),s=!!e.entryPath&&f.has(e.entryPath),n=t&&e.entryPath&&s;return(0,r.jsxs)("div",{className:`flex items-center gap-2 px-4 py-1.5 mx-1 rounded-sm transition-colors ${n?"cursor-pointer hover:bg-muted/50":""} ${!t?"opacity-50":""}`,onClick:n?()=>N(e.entryPath):void 0,role:n?"link":void 0,tabIndex:n?0:void 0,onKeyDown:n?t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),N(e.entryPath))}:void 0,children:[(0,r.jsx)("span",{className:"text-sm shrink-0",suppressHydrationWarning:!0,children:e.icon}),(0,r.jsx)("span",{className:"text-xs text-foreground truncate flex-1",title:e.name,children:e.name}),e.core?(0,r.jsx)("span",{className:"text-2xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground shrink-0",children:d.core}):(0,r.jsx)("div",{onClick:e=>e.stopPropagation(),children:(0,r.jsx)(R.lM,{checked:t,onChange:t=>j(e.id,t),size:"sm"})})]},e.id)})})})]}),(0,r.jsx)("div",{className:"mx-4 border-t border-border"}),(0,r.jsxs)("div",{className:"py-2",children:[(0,r.jsx)("div",{className:"px-4 py-1.5",children:(0,r.jsx)("span",{className:"text-2xs font-medium text-muted-foreground uppercase tracking-wider",children:l.useCases})}),tp.LD.map(e=>{var t;let s=(t=e.id,({c1:i.c1,c2:i.c2,c3:i.c3,c4:i.c4,c5:i.c5,c6:i.c6,c7:i.c7,c8:i.c8,c9:i.c9})[t]);return s?(0,r.jsx)(tf,{icon:tb[e.id]||(0,r.jsx)(ti.A,{size:12}),title:s.title,prompt:s.prompt,tryLabel:l.tryIt},e.id):null})]})]})]})}var tj=s(22368),ty=s(41762),tN=s(51900),tk=s(50538),tw=s(90718),tS=s(44071),tC=s(96035);function tA(){let[e,t]=(0,a.useState)(null),[s,n]=(0,a.useState)([]),[o,l]=(0,a.useState)(!0),{t:i}=(0,y.Y)();return((0,a.useEffect)(()=>{let e=async()=>{try{l(!0);let[e,s,r]=await Promise.all([(0,w.n)("/api/monitoring"),(0,w.n)("/api/changes?op=list&limit=3"),(0,w.n)("/api/ask-sessions")]);t({fileCount:e?.knowledgeBase?.fileCount??0,unreadChanges:s?.events?.length??0,sessionCount:Array.isArray(r)?r.length:0}),n((s?.events??[]).slice(0,3))}catch(e){console.warn("[EchoSidebarStats] Failed to load stats:",e),t({fileCount:0,unreadChanges:0,sessionCount:0}),n([])}finally{l(!1)}};e();let s=setInterval(e,1e4);return()=>clearInterval(s)},[]),o||!e)?(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:(0,r.jsx)("div",{className:"h-2 w-20 bg-muted rounded animate-pulse"})}):(0,r.jsxs)("div",{className:"flex flex-col gap-2 px-3 py-3 border-t border-border",children:[(0,r.jsxs)("div",{className:"grid grid-cols-3 gap-2",children:[(0,r.jsxs)("div",{className:"flex flex-col items-center p-1.5 rounded bg-muted/40 hover:bg-muted/60 transition-colors cursor-default",children:[(0,r.jsx)("div",{className:"text-sm font-semibold text-foreground",children:e.fileCount}),(0,r.jsx)("div",{className:"text-xs text-muted-foreground truncate",children:"Files"})]}),(0,r.jsxs)("div",{className:"flex flex-col items-center p-1.5 rounded bg-muted/40 hover:bg-muted/60 transition-colors cursor-default",children:[(0,r.jsx)("div",{className:"text-sm font-semibold text-foreground",children:e.unreadChanges}),(0,r.jsx)("div",{className:"text-xs text-muted-foreground truncate",children:"Changes"})]}),(0,r.jsxs)("div",{className:"flex flex-col items-center p-1.5 rounded bg-muted/40 hover:bg-muted/60 transition-colors cursor-default",children:[(0,r.jsx)("div",{className:"text-sm font-semibold text-foreground",children:e.sessionCount}),(0,r.jsx)("div",{className:"text-xs text-muted-foreground truncate",children:"Chats"})]})]}),s.length>0&&(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)("div",{className:"text-xs font-medium text-muted-foreground px-0.5",children:"Recent"}),s.map(e=>{let t=function(e){try{let t=new Date(e),s=new Date().getTime()-t.getTime(),r=Math.floor(s/6e4),n=Math.floor(s/36e5),a=Math.floor(s/864e5);if(r<1)return"now";if(r<60)return`${r}m ago`;if(n<24)return`${n}h ago`;if(a<7)return`${a}d ago`;return t.toLocaleDateString("en-US",{month:"short",day:"numeric"})}catch{return"recently"}}(e.ts),s=function(e){switch(e){case"create":return(0,r.jsx)(tS.A,{size:12,className:"text-success"});case"write":case"append":return(0,r.jsx)(S.A,{size:12,className:"text-foreground"});case"delete":return(0,r.jsx)(S.A,{size:12,className:"text-destructive"});case"rename":case"move":return(0,r.jsx)(tC.A,{size:12,className:"text-muted-foreground"});default:return(0,r.jsx)(S.A,{size:12,className:"text-muted-foreground"})}}(e.op),n=e.path.split("/").pop()||e.path;return(0,r.jsxs)("div",{className:"flex items-start gap-2 p-1.5 rounded hover:bg-muted/40 transition-colors text-xs",children:[(0,r.jsx)("span",{className:"text-muted-foreground shrink-0 mt-0.5",children:s}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("p",{className:"text-foreground truncate font-medium",title:n,children:n}),(0,r.jsx)("p",{className:"text-muted-foreground text-2xs",children:t})]})]},e.id)})]})]})}var tz=s(16518);function tE({active:e,maximized:t,onMaximize:s}){let{t:a}=(0,y.Y)(),o=a.panels.echo,l=(0,n.usePathname)()??"",i={"about-you":{icon:(0,r.jsx)(tj.A,{size:14}),title:o.aboutYouTitle},continued:{icon:(0,r.jsx)(ty.A,{size:14}),title:o.continuedTitle},daily:{icon:(0,r.jsx)(tN.A,{size:14}),title:o.dailyEchoTitle},"past-you":{icon:(0,r.jsx)(tk.A,{size:14}),title:o.pastYouTitle},growth:{icon:(0,r.jsx)(tw.A,{size:14}),title:o.intentGrowthTitle}};return(0,r.jsxs)("div",{className:`flex flex-col h-full ${e?"":"hidden"}`,children:[(0,r.jsx)(eY,{title:o.title,maximized:t,onMaximize:s}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto min-h-0 flex flex-col",children:[(0,r.jsx)("div",{className:"flex flex-col gap-0.5 py-1.5",children:tz.RS.map(e=>{let t=i[e],s=tz.AI[e],n=l===s||l.startsWith(`${s}/`);return(0,r.jsx)(e6,{href:s,icon:t.icon,title:t.title,active:n},e)})}),(0,r.jsx)("div",{className:"mt-auto",children:(0,r.jsx)(tA,{})})]})]})}var tT=s(41585);function t$({active:e,maximized:t,onMaximize:s}){let{t:n}=(0,y.Y)(),o=n.panels.workflows,[i,d]=(0,a.useState)([]),[c,u]=(0,a.useState)(!0),[m,x]=(0,a.useState)(!1),[p,h]=(0,a.useState)(""),[f,b]=(0,a.useState)(!1),[v,j]=(0,a.useState)(""),N=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/workflows");if(!e.ok)return;let t=await e.json();d(t.workflows??[])}catch{}finally{u(!1)}},[]);(0,a.useEffect)(()=>{e&&N()},[e,N]);let k=async()=>{let e=p.trim();if(e&&!f){b(!0),j("");try{let t=await fetch("/api/workflows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})}),s=await t.json();if(!t.ok)return void j(409===t.status?o.exists:s.error||"Error");x(!1),h(""),await N(),window.location.href=`/view/${(0,ea.O0)(s.path)}`}catch{j("Network error")}finally{b(!1)}}};return(0,r.jsxs)("div",{className:`flex flex-col h-full ${e?"":"hidden"}`,children:[(0,r.jsx)(eY,{title:o.title,maximized:t,onMaximize:s,children:(0,r.jsx)("button",{onClick:()=>x(e=>!e),className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors focus-visible:ring-1 focus-visible:ring-ring","aria-label":o.newWorkflow,title:o.newWorkflow,children:(0,r.jsx)(V.A,{size:13})})}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto min-h-0",children:[m&&(0,r.jsxs)("div",{className:"px-3 py-3 border-b border-border",children:[(0,r.jsx)("label",{className:"block text-xs font-medium text-muted-foreground mb-1.5",children:o.name}),(0,r.jsx)("input",{type:"text",value:p,onChange:e=>{h(e.target.value),j("")},onKeyDown:e=>"Enter"===e.key&&k(),placeholder:o.namePlaceholder,autoFocus:!0,className:"w-full px-2.5 py-1.5 text-sm rounded-md border border-border bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring"}),v&&(0,r.jsx)("p",{className:"text-xs text-[var(--error)] mt-1",children:v}),(0,r.jsxs)("div",{className:"flex gap-2 mt-2.5",children:[(0,r.jsx)("button",{onClick:()=>{x(!1),h(""),j("")},className:"flex-1 px-3 py-1.5 text-xs rounded-md border border-border text-muted-foreground hover:bg-muted transition-colors",children:o.cancel}),(0,r.jsx)("button",{onClick:k,disabled:!p.trim()||f,className:"flex-1 px-3 py-1.5 text-xs rounded-md font-medium transition-colors disabled:opacity-50 bg-[var(--amber)] text-[var(--amber-foreground)]",children:f?o.creating:o.create})]})]}),c&&(0,r.jsx)("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:(0,r.jsx)(C.A,{size:16,className:"animate-spin"})}),!c&&0===i.length&&!m&&(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 px-4 text-center",children:[(0,r.jsx)(g.A,{size:24,className:"text-muted-foreground/40 mb-3"}),(0,r.jsx)("p",{className:"text-sm font-medium text-muted-foreground mb-1",children:o.empty}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground/70 mb-4 max-w-[200px]",children:o.emptyDesc}),(0,r.jsxs)("button",{onClick:()=>x(!0),className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md font-medium bg-[var(--amber)] text-[var(--amber-foreground)] transition-colors",children:[(0,r.jsx)(V.A,{size:12}),o.newWorkflow]})]}),!c&&i.length>0&&(0,r.jsx)("div",{className:"flex flex-col gap-0.5 py-1.5",children:i.map(e=>(0,r.jsxs)(l(),{href:`/view/${(0,ea.O0)(e.path)}`,className:`flex items-start gap-2.5 px-3 py-2 mx-1 rounded-lg transition-colors hover:bg-muted ${e.error?"opacity-70":""}`,children:[(0,r.jsx)(g.A,{size:14,className:"shrink-0 mt-0.5 text-[var(--amber)]"}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-foreground block truncate",children:e.title}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-0.5",children:[e.error?(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 text-2xs text-[var(--error)]",children:[(0,r.jsx)(tT.A,{size:10}),o.parseError]}):(0,r.jsx)("span",{className:"text-2xs text-muted-foreground",children:o.nSteps(e.stepCount)}),(0,r.jsx)("span",{className:"text-2xs text-muted-foreground/60",suppressHydrationWarning:!0,children:(0,ea.KW)(e.mtime,n.home?.relativeTime)})]})]})]},e.path))})]})]})}var tR=s(17243),tM=s(46757),tD=s(56204),tI=s(47650),tL=s(86901);let tP="mindos-ask-mode",tF=["agent","chat"];function tO({mode:e,onChange:t,disabled:s}){let{t:n}=(0,y.Y)(),[o,l]=(0,a.useState)(!1),[i,d]=(0,a.useState)(null),c=(0,a.useRef)(null),u=(0,a.useRef)(null),m=(0,a.useCallback)(()=>{if(!c.current)return;let e=c.current.getBoundingClientRect(),t=e.top,s=t>window.innerHeight-e.bottom&&t>120?"up":"down";d({left:e.left,top:"up"===s?e.top-6:e.bottom+6,direction:s})},[]);(0,a.useEffect)(()=>{o&&m()},[o,m]),(0,a.useEffect)(()=>{if(!o)return;let e=e=>{let t=e.target;c.current&&!c.current.contains(t)&&u.current&&!u.current.contains(t)&&l(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[o]),(0,a.useEffect)(()=>{if(!o)return;let e=e=>{"Escape"===e.key&&l(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[o]),(0,a.useEffect)(()=>{if(o)return window.addEventListener("scroll",m,!0),window.addEventListener("resize",m),()=>{window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m)}},[o,m]);let x=(0,a.useCallback)(e=>{t(e);try{localStorage.setItem(tP,e)}catch{}l(!1)},[t]),p="chat"===e,h=(e,t)=>"chat"===e?(0,r.jsx)(tC.A,{size:t,className:"shrink-0"}):(0,r.jsx)(tL.A,{size:t,className:"shrink-0"}),g=e=>"chat"===e?n.ask.modeChat:n.ask.modeAgent,f=e=>"chat"===e?n.ask.modeChatHint:n.ask.modeAgentHint,b=o&&i?(0,r.jsx)("div",{ref:u,role:"listbox","aria-label":"Select mode",className:"fixed z-50 min-w-[200px] max-w-[260px] rounded-lg border border-border bg-card shadow-lg py-1 animate-in fade-in-0 zoom-in-95 duration-100",style:{left:i.left,..."up"===i.direction?{bottom:window.innerHeight-i.top}:{top:i.top}},children:tF.map(t=>{let s=e===t;return(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":s,onClick:()=>x(t),className:"flex w-full items-center gap-2.5 px-3 py-2 text-xs text-left transition-colors hover:bg-muted",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:h(t,13)}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"font-medium",children:g(t)}),(0,r.jsx)("div",{className:"text-2xs text-muted-foreground mt-0.5",children:f(t)})]}),s&&(0,r.jsx)(z.A,{size:12,className:"shrink-0 text-[var(--amber)]"})]},t)})}):null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{ref:c,type:"button",onClick:()=>{s||l(e=>!e)},disabled:s,className:`
|
|
37
|
-
inline-flex items-center gap-1 rounded-full px-2.5 py-0.5
|
|
38
|
-
text-2xs font-medium transition-colors select-none
|
|
39
|
-
border focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring
|
|
40
|
-
disabled:opacity-40 disabled:cursor-not-allowed
|
|
41
|
-
${p?"bg-muted/50 border-border/50 text-muted-foreground hover:bg-muted hover:text-foreground":"bg-[var(--amber)]/10 border-[var(--amber)]/25 text-foreground hover:bg-[var(--amber)]/15"}
|
|
42
|
-
`,title:f(e),"aria-expanded":o,"aria-haspopup":"listbox",children:[h(e,11),(0,r.jsx)("span",{className:"truncate max-w-[80px]",children:g(e)}),(0,r.jsx)(eu.A,{size:10,className:"shrink-0 text-muted-foreground"})]}),"u">typeof document&&b&&(0,tI.createPortal)(b,document.body)]})}function t_(e){let t=Date.now();return{id:`${t}-${Math.random().toString(36).slice(2,8)}`,currentFile:e,createdAt:t,updatedAt:t,messages:[]}}function tU(e){if(e.title)return e.title;let t=e.messages.find(e=>"user"===e.role);if(!t)return"(empty session)";let s=t.content.replace(/\s+/g," ").trim();return!s&&t.images&&t.images.length>0?`[${t.images.length} image${t.images.length>1?"s":""}]`:s.length>42?`${s.slice(0,42)}...`:s||"(empty session)"}async function tB(){try{let e=await fetch("/api/ask-sessions",{cache:"no-store"});if(!e.ok)return[];let t=await e.json();if(!Array.isArray(t))return[];return t.slice(0,30)}catch{return[]}}async function tW(e){try{let t={...e,messages:e.messages.map(e=>e.images&&0!==e.images.length?{...e,images:e.images.map(e=>({...e,data:""}))}:e)};await fetch("/api/ask-sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session:t})})}catch{}}async function tH(e){try{await fetch("/api/ask-sessions",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e})})}catch{}}async function tK(e){try{await fetch("/api/ask-sessions",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:e})})}catch{}}let tG=new Set([".txt",".md",".markdown",".csv",".json",".yaml",".yml",".xml",".html",".htm",".pdf"]);function tY(e){let t=e.lastIndexOf(".");return t>=0?e.slice(t).toLowerCase():""}async function tJ(e){let t=function(e){let t="";for(let s=0;s<e.length;s+=32768)t+=String.fromCharCode(...e.subarray(s,s+32768));return btoa(t)}(new Uint8Array(await e.arrayBuffer())),s=await fetch("/api/extract-pdf",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,dataBase64:t})}),r={};try{r=await s.json()}catch{}if(!s.ok)throw Error(r.error||`PDF extraction failed (${s.status})`);return r.extracted&&r.text||""}let tV=new Set(["image/png","image/jpeg","image/gif","image/webp"]);async function tq(e){let t=e.type;if(e.size<=5242880){let s=new Uint8Array(await e.arrayBuffer()),r="";for(let e=0;e<s.length;e+=32768)r+=String.fromCharCode(...s.subarray(e,e+32768));return{data:btoa(r),mimeType:t}}return new Promise((t,s)=>{let r=new Image;r.onload=()=>{let{width:e,height:n}=r;if(e>1920||n>1920){let t=Math.min(1920/e,1920/n);e=Math.round(e*t),n=Math.round(n*t)}let a=document.createElement("canvas");a.width=e,a.height=n;let o=a.getContext("2d");o?(o.drawImage(r,0,0,e,n),t({data:a.toDataURL("image/jpeg",.85).split(",")[1],mimeType:"image/jpeg"}),URL.revokeObjectURL(r.src)):s(Error("Canvas not supported"))},r.onerror=()=>{s(Error("Failed to load image")),URL.revokeObjectURL(r.src)},r.src=URL.createObjectURL(e)})}function tZ(e){let t=[];for(let s of Array.from(e))if("file"===s.kind&&tV.has(s.type)){let e=s.getAsFile();e&&t.push(e)}return t}var tQ=s(32967),tX=s(84755),t0=s(56842),t1=s(66804),t2=s(32957);function t5(e){let t=e.replace(/<(thinking|reasoning|scratchpad)>[\s\S]*?<\/\1>/gi,"");return(t=t.replace(/<(?:thinking|reasoning|scratchpad)>[\s\S]*$/gi,"")).trim()}let t3=new Set(["create_file","write_file","batch_create_files","append_to_file","insert_after_heading","update_section","edit_lines","delete_file","rename_file","move_file","append_csv"]),t4=new Set(["read_file","read_lines","search","list_files"]);function t6(e,t){return t&&"object"==typeof t?"string"==typeof t.path?t.path:"string"==typeof t.from_path?t.from_path:"batch_create_files"===e&&Array.isArray(t.files)?t.files.map(e=>e.path??"").filter(Boolean).join(", "):"":""}async function t8(e){try{let t=await fetch(`/api/file?path=${encodeURIComponent(e)}&op=read_file`);if(!t.ok)return"";return(await t.json()).content??""}catch{return""}}async function t9(e,t,s,r){let n=e.getReader(),a=new TextDecoder,o="",l=[],i=new Map,d="",c=0,u=new Set;try{for(;!r?.aborted;){let{done:e,value:r}=await n.read();if(e)break;let h=(o+=a.decode(r,{stream:!0})).split("\n");for(let e of(o=h.pop()??"",h)){let r,n=e.trim();if(!n.startsWith("data:"))continue;let a=n.slice(5).trim();if(!a)continue;try{r=JSON.parse(a)}catch{continue}let o=r.type;switch(o){case"tool_start":{var m,x,p;let e=r.toolName,n=r.toolCallId,a=r.args;c++;let l=(m=o,x=e,p=a,"text_delta"===m?{stage:"analyzing"}:"tool_start"===m&&x?t3.has(x)?{stage:"writing",detail:t6(x,p)||void 0}:t4.has(x)?{stage:"reading",detail:p&&"object"==typeof p&&"path"in p&&"string"==typeof p.path?p.path:void 0}:{stage:"analyzing"}:null);if(l&&t({stageHint:l}),t3.has(e)){let r=t6(e,a),o="update";"create_file"===e||"batch_create_files"===e?o="create":("delete_file"===e||"rename_file"===e||"move_file"===e)&&(o="unknown"),"update"===o&&r&&!u.has(r)&&(u.add(r),t8(r).then(e=>{e&&s(r,e)})),i.set(n,{name:e,path:r,action:o}),t({currentTool:{name:e,path:r}})}break}case"tool_end":{let e=r.toolCallId,s=!!r.isError,n=i.get(e);if(n){if("batch_create_files"===n.name)for(let t of n.path.split(", ").filter(Boolean))l.push({action:n.action,path:t,toolCallId:e,ok:!s});else l.push({action:n.action,path:n.path,toolCallId:e,ok:!s});i.delete(e),t({changes:[...l],currentTool:null})}break}case"text_delta":d+=r.delta??"",t({stageHint:{stage:"analyzing"},summary:t5(d)});break;case"error":throw Error(r.message||"AI organize failed")}}}}finally{n.releaseLock()}return{changes:l,summary:t5(d),toolCallCount:c}}var t7=s(7834),se=s(97810),st=s(93631),ss=s(45049),sr=s(48334),sn=s(97233),sa=s(84980);let so=new Set(["delete_file","move_file","rename_file","write_file"]),sl=new Set(["write_file","create_file","update_section","insert_after_heading","edit_lines","append_to_file"]),si={search:d.A,list_files:em.A,read_file:se.A,write_file:ec.A,create_file:st.A,append_to_file:q.A,insert_after_heading:ss.A,update_section:ec.A,delete_file:er.A,rename_file:q.A,move_file:sr.A,get_backlinks:sn.A,get_history:tk.A,get_file_at_version:tk.A,get_recent:sa.A,append_csv:eo.A},sd="--- changes ---";function sc({part:e}){let t=sl.has(e.toolName),s="done"===e.state,[n,o]=(0,a.useState)(null),l=n??(t&&s),i=si[e.toolName]??tQ.A,d=so.has(e.toolName),c=(0,a.useMemo)(()=>(function(e){if(!e)return{header:"",stats:"",diffLines:[]};let t=e.indexOf(sd);if(-1===t)return{header:e,stats:"",diffLines:[]};let s=e.slice(0,t).trim(),r=e.slice(t+sd.length).trim(),n=s.match(/\((\+\d+\s*−\d+)\)/);return{header:s,stats:n?n[1]:"",diffLines:r.split("\n").map(e=>e.startsWith("+ ")?{prefix:"+",text:e.slice(2)}:e.startsWith("- ")?{prefix:"-",text:e.slice(2)}:e.startsWith(" ")?{prefix:" ",text:e.slice(2)}:{prefix:" ",text:e})}})(e.output),[e.output]),u=(0,a.useMemo)(()=>e.input&&"object"==typeof e.input?e.input.path??"":"",[e.input]),m=u?`${u.split("/").pop()??u}${c.stats?` (${c.stats})`:""}`:function(e){if(!e||"object"!=typeof e)return String(e??"");let t=[];for(let s of Object.values(e))"string"==typeof s?t.push(s.length>60?`${s.slice(0,60)}…`:s):Array.isArray(s)?t.push(`[${s.length} items]`):null!=s&&t.push(String(s));return t.join(", ")}(e.input);return(0,r.jsxs)("div",{className:`my-1 rounded-md border text-xs font-mono ${d?"border-[var(--amber)]/30 bg-background/60":"border-border/50 bg-background/60"}`,children:[(0,r.jsxs)("button",{type:"button",onClick:()=>o(e=>null===e?!l:!e),className:"w-full flex items-center gap-1.5 px-2 py-1.5 text-left hover:bg-muted/30 transition-colors rounded-md",children:[l?(0,r.jsx)(eu.A,{size:12,className:"shrink-0 text-muted-foreground"}):(0,r.jsx)(j.A,{size:12,className:"shrink-0 text-muted-foreground"}),d&&(0,r.jsx)(tT.A,{size:11,className:"shrink-0 text-[var(--amber)]"}),(0,r.jsx)(i,{size:12,className:`shrink-0 ${d?"text-[var(--amber)]":"text-muted-foreground"}`}),(0,r.jsx)("span",{className:`font-medium ${d?"text-[var(--amber)]":"text-foreground"}`,children:e.toolName}),(0,r.jsx)("span",{className:"text-muted-foreground truncate flex-1",children:m}),(0,r.jsx)("span",{className:"shrink-0 ml-auto",children:"pending"===e.state||"running"===e.state?(0,r.jsx)(C.A,{size:12,className:"animate-spin text-[var(--amber)]"}):"done"===e.state?(0,r.jsx)(N.A,{size:12,className:"text-success"}):(0,r.jsx)(k.A,{size:12,className:"text-error"})})]}),l&&(0,r.jsx)("div",{className:"border-t border-border/30",children:t&&s&&c.diffLines.length>0?(0,r.jsx)("div",{className:"max-h-64 overflow-y-auto",children:c.diffLines.map((e,t)=>(0,r.jsxs)("div",{className:`px-2 py-px flex items-start gap-1.5 ${"+"===e.prefix?"bg-success/8":"-"===e.prefix?"bg-error/8":""}`,children:[(0,r.jsx)("span",{className:`select-none w-3 shrink-0 text-right ${"+"===e.prefix?"text-success":"-"===e.prefix?"text-error":"text-muted-foreground/50"}`,children:e.prefix}),(0,r.jsx)("span",{className:`whitespace-pre-wrap break-all flex-1 ${"+"===e.prefix?"text-success":"-"===e.prefix?"text-error":"text-muted-foreground"}`,children:e.text||"\xa0"})]},t))}):(0,r.jsxs)("div",{className:"px-2 pb-2 pt-1 space-y-1",children:["running"===e.state&&(0,r.jsxs)("div",{className:"text-muted-foreground/60 text-2xs flex items-center gap-1",children:[(0,r.jsx)(C.A,{size:10,className:"animate-spin"})," Running..."]}),(0,r.jsxs)("div",{className:"text-muted-foreground",children:[(0,r.jsx)("span",{className:"font-semibold",children:"Input: "}),(0,r.jsx)("span",{className:"break-all whitespace-pre-wrap",children:JSON.stringify(e.input,null,2)})]}),void 0!==e.output&&""!==e.output&&(0,r.jsxs)("div",{className:"text-muted-foreground",children:[(0,r.jsx)("span",{className:"font-semibold",children:"Output: "}),(0,r.jsx)("span",{className:"break-all whitespace-pre-wrap",children:e.output.length>500?e.output.slice(0,500)+"…":e.output})]})]})})]})}function su({text:e,isStreaming:t}){let[s,n]=(0,a.useState)(!1),{t:o}=(0,y.Y)();return e||t?(0,r.jsxs)("div",{className:"my-1 rounded-md border border-border/40 bg-muted/20 text-xs",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>n(e=>!e),className:"w-full flex items-center gap-1.5 px-2 py-1.5 text-left hover:bg-muted/30 transition-colors rounded-md",children:[s?(0,r.jsx)(eu.A,{size:12,className:"shrink-0 text-muted-foreground"}):(0,r.jsx)(j.A,{size:12,className:"shrink-0 text-muted-foreground"}),(0,r.jsx)(tw.A,{size:12,className:"shrink-0 text-muted-foreground"}),(0,r.jsxs)("span",{className:"text-muted-foreground font-medium",children:[o.ask.thinkingLabel,t&&!s&&(0,r.jsx)("span",{className:"ml-1 animate-pulse",children:"..."})]}),!s&&e&&(0,r.jsxs)("span",{className:"text-muted-foreground/60 truncate flex-1 ml-1",children:[e.slice(0,80),e.length>80?"...":""]})]}),s&&(0,r.jsx)("div",{className:"px-2 pb-2 pt-0.5 border-t border-border/30",children:(0,r.jsxs)("div",{className:"text-muted-foreground whitespace-pre-wrap leading-relaxed",children:[e,t&&(0,r.jsx)("span",{className:"inline-block w-1 h-3 bg-muted-foreground/40 ml-0.5 align-middle animate-pulse rounded-sm"})]})})]}):null}let sm=/^Use the skill ([^:]+):\s*/;function sx({text:e}){let[t,s]=(0,a.useState)(!1),n=(0,a.useCallback)(()=>{(0,t7.l)(e).then(e=>{e&&(s(!0),setTimeout(()=>s(!1),2e3))})},[e]);return(0,r.jsx)("button",{type:"button",onClick:n,className:"absolute -bottom-1 right-1 p-1 rounded-md bg-card border border-border/60 shadow-sm text-muted-foreground hover:text-foreground opacity-0 group-hover:opacity-100 transition-opacity",title:"Copy",children:t?(0,r.jsx)(z.A,{size:11,className:"text-success"}):(0,r.jsx)(ed.A,{size:11})})}function sp({content:e,skillName:t,images:s}){let n=t??e.match(sm)?.[1],a=e.match(sm),o=a?e.slice(a[0].length):e;return(0,r.jsxs)(r.Fragment,{children:[s&&s.length>0&&(0,r.jsx)("div",{className:`flex flex-wrap gap-1.5${e?" mb-2":""}`,children:s.map((e,t)=>e.data?(0,r.jsx)("img",{src:`data:${e.mimeType};base64,${e.data}`,alt:`Image ${t+1}`,className:"max-h-48 max-w-full rounded-md object-contain"},t):(0,r.jsx)("div",{className:"h-12 px-3 rounded-md bg-muted flex items-center gap-1.5 text-xs text-muted-foreground",children:(0,r.jsxs)("span",{children:["[Image ",t+1,"]"]})},t))}),n&&(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[11px] font-medium bg-[var(--amber)]/15 text-[var(--amber)] mr-1 align-middle",children:[(0,r.jsx)(g.A,{size:10,className:"shrink-0"}),n]}),n?o:e]})}function sh({content:e,isStreaming:t}){let s=t5(e);return s||t?(0,r.jsxs)("div",{className:"prose prose-sm prose-panel dark:prose-invert max-w-none text-foreground prose-p:my-2 prose-p:leading-relaxed prose-headings:font-semibold prose-headings:my-3 prose-h1:text-base prose-h2:text-[15px] prose-h3:text-sm prose-ul:my-1.5 prose-li:my-0.5 prose-ol:my-1.5 prose-code:text-[0.8em] prose-code:bg-background/60 prose-code:px-1 prose-code:py-0.5 prose-code:rounded prose-code:before:content-none prose-code:after:content-none prose-pre:bg-background/60 prose-pre:text-foreground prose-pre:text-xs prose-blockquote:border-l-[var(--amber)] prose-blockquote:text-muted-foreground prose-a:text-[var(--amber)] prose-a:no-underline hover:prose-a:underline prose-strong:text-foreground prose-strong:font-semibold prose-table:text-xs prose-th:py-1 prose-td:py-1 ",children:[(0,r.jsx)(t1.oz,{remarkPlugins:[t2.A],children:s}),t&&(0,r.jsx)("span",{className:"inline-block w-1.5 h-3.5 bg-[var(--amber)] ml-0.5 align-middle animate-pulse rounded-sm"})]}):null}function sg({message:e,isStreaming:t}){let s=e.parts;if(!s||0===s.length)return e.content?(0,r.jsx)(sh,{content:e.content,isStreaming:t}):null;let n=s[s.length-1],a=t&&"tool-call"===n.type&&("running"===n.state||"pending"===n.state);return(0,r.jsxs)("div",{children:[s.map((e,n)=>{if("reasoning"===e.type){let a=t&&n===s.length-1;return(0,r.jsx)(su,{text:e.text,isStreaming:a},`reasoning-${n}`)}if("text"===e.type){let a=t&&n===s.length-1;return e.text?(0,r.jsx)(sh,{content:e.text,isStreaming:a},n):null}return"tool-call"===e.type?(0,r.jsx)(sc,{part:e},e.toolCallId):null}),a&&(0,r.jsxs)("div",{className:"flex items-center gap-2 py-1 mt-1",children:[(0,r.jsx)(C.A,{size:12,className:"animate-spin text-[var(--amber)]"}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground animate-pulse",children:"Executing tool…"})]})]})}function sf({parts:e}){if(!e)return null;let t=e.filter(e=>"tool-call"===e.type);if(0===t.length)return null;let s=t[t.length-1],n="tool-call"===s.type?s.toolName:"";return(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mt-1.5 text-xs text-muted-foreground/70",children:[(0,r.jsx)(tQ.A,{size:10}),(0,r.jsxs)("span",{children:["Step ",t.length,n?` — ${n}`:""]})]})}let sb=(0,a.memo)(function({messages:e,isLoading:t,loadingPhase:s,emptyPrompt:n,emptyHint:o,suggestions:l,onSuggestionClick:i,labels:d}){let c=(0,a.useRef)(null),u=(0,a.useRef)(null),[m,x]=(0,a.useState)(!1),p=(0,a.useCallback)(()=>{c.current?.scrollIntoView({behavior:"smooth"})},[]);return(0,a.useEffect)(()=>{p()},[e,p]),(0,a.useEffect)(()=>{let e=u.current;if(!e)return;let t=()=>{let{scrollTop:t,scrollHeight:s,clientHeight:r}=e;x(s-t-r>100)};return e.addEventListener("scroll",t,{passive:!0}),()=>e.removeEventListener("scroll",t)},[]),(0,r.jsxs)("div",{ref:u,className:"relative flex-1 overflow-y-auto overflow-x-hidden px-4 py-4 space-y-4 min-h-0",children:[0===e.length&&(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center flex-1 min-h-[200px] px-4",children:[(0,r.jsx)("div",{className:"w-10 h-10 rounded-xl bg-[var(--amber)]/10 flex items-center justify-center mb-4",children:(0,r.jsx)(tL.A,{size:20,className:"text-[var(--amber)]"})}),(0,r.jsx)("p",{className:"text-center text-sm font-medium text-foreground/80 mb-1",children:n}),o&&(0,r.jsx)("p",{className:"text-center text-[11px] text-muted-foreground/50 mb-5",children:o}),(0,r.jsx)("div",{className:"grid grid-cols-2 gap-2 max-w-sm w-full",children:l.map((e,t)=>(0,r.jsx)("button",{type:"button",onClick:()=>i(e),className:"text-left text-xs px-3 py-2.5 rounded-lg border border-border/60 bg-card text-muted-foreground hover:text-foreground hover:border-[var(--amber)]/30 hover:bg-[var(--amber)]/5 transition-colors leading-snug",children:e},t))})]}),e.map((n,a)=>(0,r.jsxs)("div",{className:`flex gap-3 ${"user"===n.role?"justify-end":"justify-start"}`,children:["assistant"===n.role&&(0,r.jsx)("div",{className:"w-6 h-6 rounded-full flex items-center justify-center shrink-0 mt-0.5 bg-[var(--amber-dim)]",children:(0,r.jsx)(tL.A,{size:12,className:"text-[var(--amber)]"})}),"user"===n.role?(0,r.jsx)("div",{className:"max-w-[85%] px-3 py-2 rounded-xl rounded-br-sm text-sm leading-relaxed whitespace-pre-wrap bg-[var(--amber)] text-[var(--amber-foreground)]",children:(0,r.jsx)(sp,{content:n.content,skillName:n.skillName,images:n.images})}):n.content.startsWith("__error__")?(0,r.jsx)("div",{className:"max-w-[85%] px-3 py-2.5 rounded-xl rounded-bl-sm border border-error/20 bg-error/8 text-sm",children:(0,r.jsxs)("div",{className:"flex items-start gap-2 text-error",children:[(0,r.jsx)(S.A,{size:14,className:"shrink-0 mt-0.5"}),(0,r.jsx)("span",{className:"leading-relaxed",children:n.content.slice(9)})]})}):(0,r.jsx)("div",{className:"group relative max-w-[85%] px-3 py-2 rounded-xl rounded-bl-sm bg-muted text-foreground text-sm",children:n.parts&&n.parts.length>0||t5(n.content)?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(sg,{message:n,isStreaming:t&&a===e.length-1}),t&&a===e.length-1&&(0,r.jsx)(sf,{parts:n.parts}),!(t&&a===e.length-1)&&t5(n.content)&&(0,r.jsx)(sx,{text:t5(n.content)})]}):t&&a===e.length-1?(0,r.jsxs)("div",{className:"flex items-center gap-2 py-1",children:["reconnecting"===s?(0,r.jsx)(tX.A,{size:14,className:"text-[var(--amber)] animate-pulse"}):(0,r.jsx)(C.A,{size:14,className:"animate-spin text-[var(--amber)]"}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground animate-pulse",children:"reconnecting"===s?d.reconnecting??"Reconnecting...":"connecting"===s?d.connecting:"thinking"===s?d.thinking:d.generating})]}):null})]},a)),(0,r.jsx)("div",{ref:c}),m&&e.length>0&&(0,r.jsx)("button",{type:"button",onClick:p,className:"sticky bottom-2 left-1/2 -translate-x-1/2 z-10 p-1.5 rounded-full border border-border/60 bg-card shadow-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",title:"Scroll to bottom",children:(0,r.jsx)(t0.A,{size:14})})]})});function sv({text:e,query:t}){if(!t)return(0,r.jsx)(r.Fragment,{children:e});let s=e.toLowerCase().indexOf(t.toLowerCase());return -1===s?(0,r.jsx)(r.Fragment,{children:e}):(0,r.jsxs)(r.Fragment,{children:[e.slice(0,s),(0,r.jsx)("span",{className:"text-[var(--amber)] font-semibold",children:e.slice(s,s+t.length)}),e.slice(s+t.length)]})}function sj({results:e,selectedIndex:t,query:s,onSelect:n}){let o=(0,a.useRef)(null),l=(0,a.useRef)(null),[i,d]=(0,a.useState)(280);return((0,a.useEffect)(()=>{let e=l.current;e&&d(Math.max(120,Math.min(320,Math.min(e.getBoundingClientRect().top-8,.5*window.innerHeight)-80)))},[e.length]),(0,a.useEffect)(()=>{let e=o.current;if(!e)return;let s=e.children[t];s?.scrollIntoView({block:"nearest"})},[t]),0===e.length)?null:(0,r.jsxs)("div",{ref:l,className:"border border-border rounded-lg bg-card shadow-lg overflow-hidden",children:[(0,r.jsxs)("div",{className:"px-3 py-1.5 border-b border-border flex items-center gap-1.5",children:[(0,r.jsx)(em.A,{size:11,className:"text-muted-foreground/50"}),(0,r.jsx)("span",{className:"text-2xs font-medium text-muted-foreground/70 uppercase tracking-wider",children:"Files"}),(0,r.jsx)("span",{className:"text-2xs text-muted-foreground/40 ml-auto",children:e.length})]}),(0,r.jsx)("div",{ref:o,className:"overflow-y-auto",style:{maxHeight:i},children:e.map((e,a)=>{let o=e.split("/").pop()??e,l=e.split("/").slice(0,-1).join("/"),i=o.endsWith(".csv");return(0,r.jsxs)("button",{type:"button",onMouseDown:t=>{t.preventDefault(),n(e)},className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${a===t?"bg-accent text-foreground":"text-muted-foreground hover:bg-muted"}`,children:[i?(0,r.jsx)(eo.A,{size:13,className:"text-success shrink-0"}):(0,r.jsx)(q.A,{size:13,className:"text-muted-foreground shrink-0"}),(0,r.jsx)("span",{className:"truncate font-medium flex-1",title:o,children:(0,r.jsx)(sv,{text:o,query:s})}),l&&(0,r.jsx)("span",{className:"text-2xs text-muted-foreground/40 truncate max-w-[140px] shrink-0",title:l,children:(0,r.jsx)(sv,{text:l,query:s})})]},e)})}),(0,r.jsxs)("div",{className:"px-3 py-1.5 border-t border-border flex gap-3 text-2xs text-muted-foreground/40 shrink-0",children:[(0,r.jsx)("span",{children:"↑↓ navigate"}),(0,r.jsx)("span",{children:"↵ select"}),(0,r.jsx)("span",{children:"ESC dismiss"})]})]})}function sy({results:e,selectedIndex:t,query:s,onSelect:n}){let o=(0,a.useRef)(null),l=(0,a.useRef)(null),[i,d]=(0,a.useState)(280);return((0,a.useEffect)(()=>{let e=l.current;e&&d(Math.max(120,Math.min(320,Math.min(e.getBoundingClientRect().top-8,.5*window.innerHeight)-80)))},[e.length]),(0,a.useEffect)(()=>{let e=o.current;if(!e)return;let s=e.children[t];s?.scrollIntoView({block:"nearest"})},[t]),0===e.length)?null:(0,r.jsxs)("div",{ref:l,className:"border border-border rounded-lg bg-card shadow-lg overflow-hidden",children:[(0,r.jsxs)("div",{className:"px-3 py-1.5 border-b border-border flex items-center gap-1.5",children:[(0,r.jsx)(g.A,{size:11,className:"text-[var(--amber)]/50"}),(0,r.jsx)("span",{className:"text-2xs font-medium text-muted-foreground/70 uppercase tracking-wider",children:"Skills"}),(0,r.jsx)("span",{className:"text-2xs text-muted-foreground/40 ml-auto",children:e.length})]}),(0,r.jsx)("div",{ref:o,className:"overflow-y-auto",style:{maxHeight:i},children:e.map((e,a)=>(0,r.jsxs)("button",{type:"button",onMouseDown:t=>{t.preventDefault(),n(e)},className:`w-full flex items-center gap-2.5 px-3 py-2 text-left transition-colors ${a===t?"bg-accent text-foreground":"text-muted-foreground hover:bg-muted"}`,children:[(0,r.jsx)(g.A,{size:13,className:"text-[var(--amber)] shrink-0"}),(0,r.jsxs)("span",{className:"text-sm font-medium shrink-0",children:["/",(0,r.jsx)(sv,{text:e.name,query:s})]}),e.description&&(0,r.jsx)("span",{className:"text-2xs text-muted-foreground/50 truncate min-w-0 flex-1",title:e.description,children:e.description})]},e.name))}),(0,r.jsxs)("div",{className:"px-3 py-1.5 border-t border-border flex gap-3 text-2xs text-muted-foreground/40 shrink-0",children:[(0,r.jsx)("span",{children:"↑↓ navigate"}),(0,r.jsx)("span",{children:"↵ / Tab select"}),(0,r.jsx)("span",{children:"ESC dismiss"})]})]})}function sN({sessions:e,activeSessionId:t,onLoad:s,onDelete:n,onRename:o,onClearAll:l,labels:i}){let[d,c]=(0,a.useState)(!1),u=(0,a.useRef)(void 0),[m,x]=(0,a.useState)(null),[p,h]=(0,a.useState)(""),g=(0,a.useRef)(null);(0,a.useEffect)(()=>()=>{u.current&&clearTimeout(u.current)},[]),(0,a.useEffect)(()=>{m&&g.current&&(g.current.focus(),g.current.select())},[m]);let f=(0,a.useCallback)(e=>{x(e.id),h(tU(e))},[]),b=(0,a.useCallback)(()=>{m&&(o(m,p),x(null))},[m,p,o]),v=(0,a.useCallback)(()=>{x(null)},[]);return(0,r.jsxs)("div",{className:"border-b border-border px-4 py-2.5 max-h-[190px] overflow-y-auto",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:i.title}),e.length>1&&(0,r.jsx)("button",{type:"button",onClick:()=>{if(!d){c(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>c(!1),3e3);return}u.current&&clearTimeout(u.current),l(),c(!1)},className:`text-2xs px-1.5 py-0.5 rounded transition-colors ${d?"bg-error/10 text-error font-medium":"text-muted-foreground hover:text-error hover:bg-muted"}`,children:d?i.confirmClear:i.clearAll})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-1.5",children:[0===e.length&&(0,r.jsx)("div",{className:"text-xs text-muted-foreground/70",children:i.noSessions}),e.map(e=>(0,r.jsxs)("div",{className:"group flex items-center gap-1",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>s(e.id),onDoubleClick:()=>f(e),className:`flex-1 text-left px-2 py-1.5 rounded text-xs transition-colors min-w-0 ${t===e.id?"bg-accent text-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"}`,children:[m===e.id?(0,r.jsx)("input",{ref:g,type:"text",value:p,onChange:e=>h(e.target.value),onBlur:b,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),b()),"Escape"===e.key&&(e.preventDefault(),v())},onClick:e=>e.stopPropagation(),className:"w-full bg-transparent border-b border-[var(--amber)] outline-none text-xs text-foreground"}):(0,r.jsx)("div",{className:"truncate",children:tU(e)}),m!==e.id&&(0,r.jsx)("div",{className:"text-2xs opacity-60",children:new Date(e.updatedAt).toLocaleString()})]}),(0,r.jsx)("button",{type:"button",onClick:()=>f(e),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted opacity-0 group-hover:opacity-100 transition-opacity",title:i.rename,children:(0,r.jsx)(ec.A,{size:11})}),(0,r.jsx)("button",{type:"button",onClick:()=>n(e.id),className:"p-1 rounded text-muted-foreground hover:text-error hover:bg-muted opacity-0 group-hover:opacity-100 transition-opacity",title:"Delete session",children:(0,r.jsx)(er.A,{size:12})})]},e.id))]})]})}function sk({sessions:e,activeSessionId:t,onLoad:s,onDelete:n,onNew:a,maxTabs:o=3}){let{t:l}=(0,y.Y)(),i=e.slice(0,o);return 0===i.length?null:(0,r.jsxs)("div",{className:"flex items-center border-b border-border shrink-0 bg-background/50",children:[(0,r.jsx)("div",{className:"flex flex-1 min-w-0",children:i.map(e=>{let a=e.id===t,o=tU(e);return(0,r.jsxs)("button",{type:"button",onClick:()=>s(e.id),className:`group relative flex items-center gap-1 min-w-0 max-w-[160px] px-3 py-2 text-xs transition-colors
|
|
43
|
-
${a?"text-foreground border-b-2 border-[var(--amber)] bg-card":"text-muted-foreground hover:text-foreground hover:bg-muted/50 border-b-2 border-transparent"}`,title:o,children:[(0,r.jsx)("span",{className:"truncate",children:"(empty session)"===o?l.hints.newChat:o}),i.length>1&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:t=>{t.stopPropagation(),n(e.id)},onKeyDown:t=>{"Enter"===t.key&&(t.stopPropagation(),n(e.id))},className:"shrink-0 p-0.5 rounded opacity-0 group-hover:opacity-100 hover:bg-muted hover:text-error transition-opacity",title:l.hints.closeSession,children:(0,r.jsx)(u.A,{size:10})})]},e.id)})}),(0,r.jsx)("button",{type:"button",onClick:a,className:"shrink-0 p-2 text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors",title:l.hints.newChat,children:(0,r.jsx)(V.A,{size:13})})]})}var sw=s(89823),sS=s(52335),sC=s(94852);let sA=(0,a.memo)(function({isPanel:e,showHistory:t,onToggleHistory:s,onReset:n,isLoading:a,maximized:o,onMaximize:l,askMode:i,onModeSwitch:d,onClose:c}){let{t:m}=(0,y.Y)(),x=e?13:14;return(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border shrink-0",children:[!e&&(0,r.jsx)("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 w-8 h-1 rounded-full bg-muted-foreground/20 md:hidden"}),(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[(0,r.jsx)(tL.A,{size:e?14:15,className:"text-[var(--amber)]"}),(0,r.jsx)("span",{className:e?"text-xs uppercase tracking-wider text-muted-foreground":"",children:e?"MindOS Agent":m.ask.title})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,r.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),s()},"aria-pressed":t,className:`p-2 rounded transition-colors ${t?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:m.hints.sessionHistory,children:(0,r.jsx)(tk.A,{size:x})}),(0,r.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),n()},disabled:a,className:"p-2 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-40",title:m.hints.newSession,children:(0,r.jsx)(sw.A,{size:x})}),e&&l&&(0,r.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),l()},className:"p-2 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:o?m.hints.restorePanel:m.hints.maximizePanel,children:o?(0,r.jsx)(eK.A,{size:x}):(0,r.jsx)(eG.A,{size:x})}),d&&(0,r.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),d()},className:"p-2 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:"popup"===i?m.hints.dockToSide:m.hints.openAsPopup,children:"popup"===i?(0,r.jsx)(sS.A,{size:x}):(0,r.jsx)(sC.A,{size:x})}),c&&(0,r.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),c()},className:"p-2 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:m.hints.closePanel,"aria-label":"Close",children:(0,r.jsx)(u.A,{size:e?x:15})})]})]})});var sz=s(56558);let sE={kb:{icon:q.A,cls:"text-muted-foreground"},upload:{icon:sz.A,cls:"text-muted-foreground"},image:{icon:tR.A,cls:"text-muted-foreground"},skill:{icon:g.A,cls:"text-[var(--amber)]"},agent:{icon:h.A,cls:"text-muted-foreground"}},sT={kb:"border-border bg-muted text-foreground",upload:"border-border bg-muted text-foreground",image:"border-border bg-muted text-foreground",skill:"border-[var(--amber)]/25 bg-[var(--amber)]/10 text-foreground",agent:"border-[var(--amber)]/25 bg-[var(--amber)]/10 text-foreground"};function s$({path:e,onRemove:t,variant:s="kb",imageData:n,imageMime:o}){let[l,i]=(0,a.useState)(!1),[d,c]=(0,a.useState)(!1),m=(0,a.useRef)(null),[x,p]=(0,a.useState)(null);(0,a.useEffect)(()=>c(!0),[]);let h="kb"===s&&e.endsWith("/"),g=h?e.slice(0,-1):e,f=g.split("/").pop()??g,b="kb"===s&&!h&&f.endsWith(".csv"),{icon:v,cls:j}=h?{icon:ex.A,cls:"text-yellow-400"}:b?{icon:eo.A,cls:"text-success"}:sE[s],y=sT[s];(0,a.useEffect)(()=>{if(!l||!m.current)return void p(null);let e=m.current.getBoundingClientRect();p({top:e.top-8,left:e.left})},[l]);let N=l&&x&&n&&o?(0,r.jsx)("div",{className:"fixed z-50 p-1 rounded-lg border border-border bg-card shadow-lg pointer-events-none",style:{left:x.left,bottom:window.innerHeight-x.top},children:(0,r.jsx)("img",{src:`data:${o};base64,${n}`,alt:f,className:"max-h-48 max-w-64 rounded object-contain"})}):null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{ref:m,className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-xs border max-w-[220px] ${y}`,onMouseEnter:()=>n&&i(!0),onMouseLeave:()=>i(!1),children:[(0,r.jsx)(v,{size:11,className:`${j} shrink-0`}),(0,r.jsx)("span",{className:"truncate",title:h?g:e,children:f}),(0,r.jsx)("button",{type:"button",onClick:t,"aria-label":`Remove ${f}`,className:"p-0.5 -mr-1 rounded hover:text-foreground transition-colors shrink-0 text-muted-foreground",children:(0,r.jsx)(u.A,{size:10})})]}),d&&N&&(0,tI.createPortal)(N,document.body)]})}function sR({selectedAgent:e,onSelect:t,installedAgents:s,loading:n=!1}){let{t:o}=(0,y.Y)(),l=o.panels.agents,[i,d]=(0,a.useState)(!1),[c,m]=(0,a.useState)(null),x=(0,a.useRef)(null),p=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(!i||!x.current)return;let e=x.current.getBoundingClientRect(),t=e.top,s=t>window.innerHeight-e.bottom&&t>200?"up":"down";m({left:e.left,top:"up"===s?e.top-6:e.bottom+6,direction:s})},[i]),(0,a.useEffect)(()=>{if(!i)return;let e=e=>{let t=e.target;x.current&&!x.current.contains(t)&&p.current&&!p.current.contains(t)&&d(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]),(0,a.useEffect)(()=>{if(!i)return;let e=e=>{"Escape"===e.key&&d(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[i]),(0,a.useEffect)(()=>{if(!i||!x.current)return;let e=()=>{if(!x.current)return;let e=x.current.getBoundingClientRect(),t=e.top,s=t>window.innerHeight-e.bottom&&t>200?"up":"down";m({left:e.left,top:"up"===s?e.top-6:e.bottom+6,direction:s})};return window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[i]);let g=(0,a.useCallback)(()=>{t(null),d(!1)},[t]),f=(0,a.useCallback)(e=>{t({id:e.id,name:e.name}),d(!1)},[t]),b=(0,a.useCallback)(e=>{e.stopPropagation(),t(null)},[t]),v=!e,j=e?.name??l.acpDefaultAgent;if(!n&&0===s.length&&!e)return null;let N=i&&c?(0,r.jsxs)("div",{ref:p,role:"listbox","aria-label":l.acpSelectAgent,className:"fixed z-50 min-w-[180px] max-w-[240px] rounded-lg border border-border bg-card shadow-lg py-1 animate-in fade-in-0 zoom-in-95 duration-100",style:{left:c.left,..."up"===c.direction?{bottom:window.innerHeight-c.top}:{top:c.top}},children:[(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":v,onClick:g,className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs text-left transition-colors hover:bg-muted",children:[(0,r.jsx)(h.A,{size:12,className:"shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:"flex-1 truncate font-medium",children:l.acpDefaultAgent}),v&&(0,r.jsx)(z.A,{size:11,className:"shrink-0 text-[var(--amber)]"})]}),s.length>0&&(0,r.jsx)("div",{className:"mx-2 my-1 border-t border-border/60"}),s.map(t=>{let s=e?.id===t.id;return(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":s,onClick:()=>f(t),className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs text-left transition-colors hover:bg-muted",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full bg-[var(--success)] shrink-0"}),(0,r.jsx)("span",{className:"flex-1 truncate",children:t.name}),s&&(0,r.jsx)(z.A,{size:11,className:"shrink-0 text-[var(--amber)]"})]},t.id)})]}):null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{ref:x,type:"button",onClick:()=>d(e=>!e),className:`
|
|
44
|
-
inline-flex items-center gap-1 rounded-full px-2.5 py-0.5
|
|
45
|
-
text-2xs font-medium transition-colors
|
|
46
|
-
border focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring
|
|
47
|
-
${v?"bg-muted/50 border-border/50 text-muted-foreground hover:bg-muted hover:text-foreground":"bg-[var(--amber)]/10 border-[var(--amber)]/25 text-foreground hover:bg-[var(--amber)]/15"}
|
|
48
|
-
`,title:l.acpChangeAgent,"aria-expanded":i,"aria-haspopup":"listbox",children:[v?(0,r.jsx)(h.A,{size:11,className:"shrink-0 text-muted-foreground"}):(0,r.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--success)] shrink-0"}),(0,r.jsx)("span",{className:"truncate max-w-[120px]",children:j}),e?(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:b,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),b(e))},className:"p-0.5 -mr-1 rounded-full text-muted-foreground hover:text-foreground transition-colors","aria-label":`Remove ${e.name}`,children:(0,r.jsx)(u.A,{size:9})}):(0,r.jsx)(eu.A,{size:10,className:"shrink-0 text-muted-foreground"})]}),"u">typeof document&&N&&(0,tI.createPortal)(N,document.body)]})}var sM=s(65576),sD=s(47376);let sI="mindos-provider-override";function sL(e){try{e?localStorage.setItem(sI,e):localStorage.removeItem(sI)}catch{}}function sP({value:e,onChange:t,disabled:s=!1}){let{t:n,locale:o}=(0,y.Y)(),[l,i]=(0,a.useState)(!1),[d,u]=(0,a.useState)(null),m=(0,a.useRef)(null),x=(0,a.useRef)(null),[p,h]=(0,a.useState)(null);(0,a.useEffect)(()=>{let e=!1,t=()=>{fetch("/api/settings",{cache:"no-store"}).then(e=>e.json()).then(t=>{e||h(t)}).catch(()=>{})};t();let s=()=>{"visible"===document.visibilityState&&t()},r=()=>t();return document.addEventListener("visibilitychange",s),window.addEventListener("mindos:settings-changed",r),()=>{e=!0,document.removeEventListener("visibilitychange",s),window.removeEventListener("mindos:settings-changed",r)}},[]);let g=p?.ai?.provider&&(0,sD.rl)(p.ai.provider)?p.ai.provider:"anthropic",f=(0,a.useMemo)(()=>p?function(e){let t=[],s=e.ai?.providers??{},r=e.envOverrides??{};for(let n of sD.jt){let a=sD.T_[n],o=s[n]?.apiKey==="***set***",l=(0,sD.Ux)(n),i=!!l&&!!r[l];if(o||i)t.push(n);else if(a.apiKeyFallback){let r=e.ai?.provider===n,a=s[n];(r||a&&(a.model||a.baseUrl))&&t.push(n)}}return t}(p):[],[p]);(0,a.useEffect)(()=>{p&&e&&(f.includes(e)||(t(null),sL(null)))},[p,e,f,t]);let b=e??g,v=sD.T_[b],j=p?.ai?.providers?.[b]?.model||v.defaultModel,N="zh"===o?v.nameZh:v.name,k=(0,a.useCallback)(()=>{if(!m.current)return;let e=m.current.getBoundingClientRect(),t=e.top,s=t>window.innerHeight-e.bottom&&t>240?"up":"down";u({left:e.left,top:"up"===s?e.top-6:e.bottom+6,direction:s})},[]);(0,a.useEffect)(()=>{l&&k()},[l,k]),(0,a.useEffect)(()=>{if(!l)return;let e=e=>{let t=e.target;m.current&&!m.current.contains(t)&&x.current&&!x.current.contains(t)&&i(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[l]),(0,a.useEffect)(()=>{if(!l)return;let e=e=>{"Escape"===e.key&&i(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[l]),(0,a.useEffect)(()=>{if(l)return window.addEventListener("scroll",k,!0),window.addEventListener("resize",k),()=>{window.removeEventListener("scroll",k,!0),window.removeEventListener("resize",k)}},[l,k]);let w=(0,a.useCallback)(e=>{t(e),sL(e),i(!1)},[t]);if(!p||0===f.length)return null;let S=j.length>24?j.slice(0,22)+"…":j,C=l&&d?(0,r.jsxs)("div",{ref:x,role:"listbox","aria-label":n.ask.providerCapsule,className:"fixed z-50 min-w-[200px] max-w-[280px] rounded-lg border border-border bg-card shadow-lg py-1 animate-in fade-in-0 zoom-in-95 duration-100",style:{left:d.left,..."up"===d.direction?{bottom:window.innerHeight-d.top}:{top:d.top}},children:[(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":null===e,onClick:()=>w(null),className:"flex w-full items-center gap-2.5 px-3 py-2 text-xs text-left transition-colors hover:bg-muted",children:[(0,r.jsx)(c.A,{size:12,className:"shrink-0 text-muted-foreground"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"font-medium",children:n.ask.providerDefault}),(0,r.jsxs)("div",{className:"text-2xs text-muted-foreground mt-0.5",children:["zh"===o?sD.T_[g].nameZh:sD.T_[g].name," \xb7 ",p?.ai?.providers?.[g]?.model||sD.T_[g].defaultModel]})]}),null===e&&(0,r.jsx)(z.A,{size:12,className:"shrink-0 text-[var(--amber)]"})]}),f.length>0&&(0,r.jsx)("div",{className:"mx-2 my-1 border-t border-border/60"}),f.map(t=>{let s=sD.T_[t],n="zh"===o?s.nameZh:s.name,a=p?.ai?.providers?.[t]?.model||s.defaultModel,l=e===t;return(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":l,onClick:()=>w(t),className:"flex w-full items-center gap-2.5 px-3 py-2 text-xs text-left transition-colors hover:bg-muted",children:[(0,r.jsx)(sM.A,{size:12,className:"shrink-0 text-muted-foreground"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"font-medium",children:n}),(0,r.jsx)("div",{className:"text-2xs text-muted-foreground mt-0.5 truncate",children:a})]}),l&&(0,r.jsx)(z.A,{size:12,className:"shrink-0 text-[var(--amber)]"})]},t)})]}):null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{ref:m,type:"button",onClick:()=>{s||i(e=>!e)},disabled:s,className:`
|
|
49
|
-
inline-flex items-center gap-1 rounded-full px-2.5 py-0.5
|
|
50
|
-
text-2xs font-medium transition-colors select-none
|
|
51
|
-
border focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring
|
|
52
|
-
disabled:opacity-40 disabled:cursor-not-allowed
|
|
53
|
-
${e?"bg-[var(--amber)]/10 border-[var(--amber)]/25 text-foreground hover:bg-[var(--amber)]/15":"bg-muted/50 border-border/50 text-muted-foreground hover:bg-muted hover:text-foreground"}
|
|
54
|
-
`,title:n.ask.providerCapsule,"aria-expanded":l,"aria-haspopup":"listbox",children:[(0,r.jsx)(sM.A,{size:11,className:"shrink-0"}),(0,r.jsxs)("span",{className:"truncate max-w-[140px]",children:[N,(0,r.jsx)("span",{className:"text-muted-foreground",children:" \xb7 "}),(0,r.jsx)("span",{className:"text-muted-foreground",children:S})]}),(0,r.jsx)(eu.A,{size:10,className:"shrink-0 text-muted-foreground"})]}),"u">typeof document&&C&&(0,tI.createPortal)(C,document.body)]})}var sF=s(68589);let sO=new Set([401,403,429]),s_=[/api.?key/i,/model.*not.?found/i,/authentication/i,/unauthorized/i,/forbidden/i];var sU=s(2431);let sB=new WeakMap;function sW({visible:e,currentFile:t,initialMessage:s,initialAcpAgent:n,onFirstMessage:o,variant:l,onClose:i,maximized:d,onMaximize:c,askMode:m,onModeSwitch:x}){let p="panel"===l,h=(0,a.useRef)(null),g=(0,a.useRef)(null),{t:f}=(0,y.Y)(),[b,v]=(0,a.useState)(!1);(0,a.useEffect)(()=>v(!0),[]);let[j,N]=(0,a.useState)(""),k=(0,a.useRef)("");k.current=j;let[w,S]=(0,a.useState)([]),C=(0,a.useRef)(w);C.current=w;let[A,z]=(0,a.useState)(!1),[E,T]=(0,a.useState)(!1),[$,R]=(0,a.useState)(!1),[M,D]=(0,a.useState)(null),I=(0,a.useRef)(M);I.current=M;let[L,P]=(0,a.useState)(null),F=(0,a.useRef)(L);F.current=L;let[O,_]=(0,a.useState)("agent"),[U,B]=(0,a.useState)(null);(0,a.useEffect)(()=>{_(function(){try{let e=localStorage.getItem(tP);if("chat"===e||"agent"===e)return e}catch{}return"agent"}()),B(function(){try{let e=localStorage.getItem(sI);if(e&&(0,sD.rl)(e))return e}catch{}return null}())},[]);let W=function(e){let[t,s]=(0,a.useState)([]),[r,n]=(0,a.useState)([]),[o,l]=(0,a.useState)(null),i=(0,a.useRef)(null),d=(0,a.useCallback)(async()=>{let t=(await tB()).sort((e,t)=>t.updatedAt-e.updatedAt).slice(0,30),r=t.filter(e=>0===e.messages.length).map(e=>e.id),a=r.length>0?t.filter(e=>!r.includes(e.id)):t;r.length>0&&tK(r);let o=t_(e),i=e?a.find(t=>t.currentFile===e):a[0];i?(l(i.id),s(i.messages),n([...a])):(l(o.id),s([]),n([o,...a].slice(0,30)))},[e]),c=(0,a.useCallback)((t,s)=>{if(!s||0===t.length)return;let r=null;n(n=>{let a=Date.now(),o=n.find(e=>e.id===s);r=o?{...o,currentFile:e,updatedAt:a,messages:t}:{id:s,currentFile:e,createdAt:a,updatedAt:a,messages:t};let l=n.filter(e=>e.id!==s);return[r,...l].sort((e,t)=>t.updatedAt-e.updatedAt).slice(0,30)}),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{r&&tW(r)},600)},[e]),u=(0,a.useCallback)(()=>{i.current&&(clearTimeout(i.current),i.current=null)},[]),m=(0,a.useCallback)(()=>{n(t=>{let r=t.find(e=>e.id===o);if(r&&0===r.messages.length)return t;let n=t_(e);return l(n.id),s([]),[n,...t].sort((e,t)=>t.updatedAt-e.updatedAt).slice(0,30)})},[e,o]),x=(0,a.useCallback)(e=>{let t=r.find(t=>t.id===e);if(!t)return;let a=o?r.find(e=>e.id===o):null;a&&0===a.messages.length&&a.id!==e&&n(e=>e.filter(e=>e.id!==a.id)),l(t.id),s(t.messages)},[r,o]),p=(0,a.useCallback)(t=>{let a=r.find(e=>e.id===t);a&&a.messages.length>0&&tH(t);let i=r.filter(e=>e.id!==t);if(n(i),o===t){let t=t_(e);l(t.id),s([]),n([t,...i].slice(0,30))}},[o,e,r]),h=(0,a.useCallback)((e,t)=>{let s=t.trim();n(t=>{let r=t.findIndex(t=>t.id===e);if(r<0)return t;let n={...t[r],title:s||void 0},a=[...t];return a[r]=n,tW(n),a})},[]),g=(0,a.useCallback)(()=>{let t=r.filter(e=>e.messages.length>0).map(e=>e.id);t.length>0&&tK(t);let a=t_(e);l(a.id),s([]),n([a])},[e,r]);return{messages:t,setMessages:s,sessions:r,activeSessionId:o,initSessions:d,persistSession:c,clearPersistTimer:u,resetSession:m,loadSession:x,deleteSession:p,renameSession:h,clearAllSessions:g}}(t),H=(0,a.useRef)(W);H.current=W;let K=function(){let[e,t]=(0,a.useState)([]),[s,r]=(0,a.useState)(""),n=(0,a.useRef)(null),o=(0,a.useCallback)(async e=>{if(!e||0===e.length)return;let s=Array.from(e).slice(0,8),n=[],a=[];for(let e of s){let t=tY(e.name);tG.has(t)?n.push(e):a.push(e.name)}a.length>0?r(`Unsupported file type: ${a.join(", ")}`):r("");let o=await Promise.all(n.map(async e=>{if(".pdf"===tY(e.name))try{let t=await tJ(e);return{name:e.name,content:t?`[PDF TEXT EXTRACTED: ${e.name}]
|
|
55
|
-
|
|
56
|
-
${t}`:`[PDF: ${e.name}] Could not extract readable text (possibly scanned/image PDF).`}}catch{return{name:e.name,content:`[PDF: ${e.name}] Failed to extract text from this PDF.`}}return{name:e.name,content:await e.text()}}));t(e=>{let t=[...e];for(let e of o)t.some(t=>t.name===e.name&&t.content===e.content)||t.push(e);return t})},[]),l=(0,a.useCallback)(e=>{t(t=>t.filter((t,s)=>s!==e))},[]);return{localAttachments:e,uploadError:s,uploadInputRef:n,pickFiles:o,removeAttachment:l,clearAttachments:(0,a.useCallback)(()=>{t([]),r("")},[]),injectFiles:(0,a.useCallback)(e=>{t(t=>{let s=[...t];for(let t of e)s.some(e=>e.name===t.name)||s.push(t);return s})},[])}}(),G=(0,a.useRef)(K);G.current=K;let Y=function(){let[e,t]=(0,a.useState)([]),[s,r]=(0,a.useState)(""),n=(0,a.useCallback)(async e=>{r("");let s=e.slice(0,4),n=[];for(let e of s){var a;if(a=e.type,!tV.has(a)){r(`Unsupported image type: ${e.type}`);continue}try{let{data:t,mimeType:s}=await tq(e);n.push({type:"image",data:t,mimeType:s})}catch{r(`Failed to process image: ${e.name}`)}}t(e=>{let t=[...e,...n];return t.length>4?(r("Maximum 4 images allowed"),t.slice(0,4)):t})},[]),o=(0,a.useCallback)(async e=>{let t=e.clipboardData?.items;if(!t)return!1;let s=tZ(t);return 0!==s.length&&(await n(s),!0)},[n]),l=(0,a.useCallback)(async e=>{let t=e.dataTransfer?.items;if(!t)return;let s=tZ(t);s.length>0&&(e.preventDefault(),await n(s))},[n]),i=(0,a.useCallback)(async e=>{if(!e)return;let t=Array.from(e).filter(e=>{var t;return t=e.type,tV.has(t)});await n(t)},[n]);return{images:e,imageError:s,addImages:n,handlePaste:o,handleDrop:l,handleFileSelect:i,removeImage:(0,a.useCallback)(e=>{t(t=>t.filter((t,s)=>s!==e))},[]),clearImages:(0,a.useCallback)(()=>{t([]),r("")},[])}}(),J=function(){let[e,t]=(0,a.useState)([]),[s,r]=(0,a.useState)(null),[n,o]=(0,a.useState)([]),[l,i]=(0,a.useState)(0),d=(0,a.useCallback)(()=>{fetch("/api/files").then(e=>e.ok?e.json():[]).then(e=>Array.isArray(e)?e:[]).catch(()=>[]).then(t)},[]);(0,a.useEffect)(()=>{d();let e=()=>d();return window.addEventListener("mindos:files-changed",e),()=>window.removeEventListener("mindos:files-changed",e)},[d]);let c=(0,a.useCallback)((t,s)=>{let n=s??t.length,a=t.slice(0,n),l=a.lastIndexOf("@");if(-1===l||l>0&&" "!==a[l-1]&&"\n"!==a[l-1])return void r(null);let d=a.slice(l+1);if(d.includes(" ")||d.includes("\n")){r(null),o([]),i(0);return}let c=d.toLowerCase();if(!c){r(d),o(e.slice(0,30)),i(0);return}let u=e.map(e=>{let t=(e.split("/").pop()??e).toLowerCase(),s=e.toLowerCase(),r=0;return t.startsWith(c)?r=100:t.includes(c)?r=50:s.includes(c)&&(r=10),{path:e,score:r}}).filter(e=>e.score>0).sort((e,t)=>t.score-e.score).slice(0,30);if(0===u.length){r(null),o([]),i(0);return}r(d),o(u.map(e=>e.path)),i(0)},[e]),u=(0,a.useCallback)(e=>{0!==n.length&&("down"===e?i(e=>Math.min(e+1,n.length-1)):i(e=>Math.max(e-1,0)))},[n.length]);return{mentionQuery:s,mentionResults:n,mentionIndex:l,updateMentionFromInput:c,navigateMention:u,resetMention:(0,a.useCallback)(()=>{r(null),o([]),i(0)},[])}}(),Z=function(){let[e,t]=(0,a.useState)([]),[s,r]=(0,a.useState)(null),[n,o]=(0,a.useState)([]),[l,i]=(0,a.useState)(0),d=(0,a.useRef)(!1),c=(0,a.useCallback)(async()=>{t((await fetch("/api/skills").then(e=>e.ok?e.json():{skills:[]}).then(e=>Array.isArray(e?.skills)?e.skills:[]).catch(()=>[])).filter(e=>e.enabled)),d.current=!0},[]);(0,a.useEffect)(()=>{c();let e=()=>c();return window.addEventListener("mindos:skills-changed",e),()=>window.removeEventListener("mindos:skills-changed",e)},[c]);let u=(0,a.useCallback)((t,s)=>{let n=t.slice(0,s),a=n.lastIndexOf("/");if(-1===a||a>0&&" "!==n[a-1]&&"\n"!==n[a-1])return void r(null);let l=n.slice(a+1);if(l.includes(" "))return void r(null);if(!d.current){c(),r(null);return}let u=l.toLowerCase(),m=u?e.map(e=>{let t=e.name.toLowerCase(),s=0;return t.startsWith(u)?s=100:t.includes(u)?s=50:e.description.toLowerCase().includes(u)&&(s=10),{s:e,score:s}}).filter(e=>e.score>0).sort((e,t)=>t.score-e.score).slice(0,20).map(e=>({type:"skill",name:e.s.name,description:e.s.description})):e.slice(0,20).map(e=>({type:"skill",name:e.name,description:e.description}));if(0===m.length){r(null),o([]),i(0);return}r(l),o(m),i(0)},[e,c]),m=(0,a.useCallback)(e=>{0!==n.length&&("down"===e?i(e=>Math.min(e+1,n.length-1)):i(e=>Math.max(e-1,0)))},[n.length]);return{slashQuery:s,slashResults:n,slashIndex:l,updateSlashFromInput:u,navigateSlash:m,resetSlash:(0,a.useCallback)(()=>{r(null),o([]),i(0)},[])}}(),Q=(0,sU.z)(),X=(0,a.useRef)(Y);X.current=Y;let ee=(0,a.useRef)(J);ee.current=J;let et=(0,a.useRef)(Z);et.current=Z;let es=(0,a.useCallback)(()=>{N(""),D(null),P(null),S(t?[t]:[])},[t]),er=(0,a.useRef)({inputValueRef:k,mentionRef:ee,slashRef:et,imageUploadRef:X,sessionRef:H,uploadRef:G,selectedSkillRef:I,selectedAcpAgentRef:F,attachedFilesRef:C}),en=function({currentFile:e,chatMode:t,providerOverride:s,onFirstMessage:r,refs:n,errorLabels:o,resetInputState:l}){let[i,d]=(0,a.useState)(!1),[c,u]=(0,a.useState)("connecting"),[m,x]=(0,a.useState)(0),p=(0,a.useRef)(3),h=(0,a.useRef)(null),g=(0,a.useRef)(!1),f=(0,a.useCallback)(()=>{h.current?.abort()},[]),b=(0,a.useCallback)(async a=>{a.preventDefault();let i=n.mentionRef.current,c=n.slashRef.current,m=n.imageUploadRef.current,f=n.sessionRef.current,b=n.uploadRef.current;if(!i||!c||!m||!f||!b||null!==i.mentionQuery||null!==c.slashQuery)return;let j=n.inputValueRef.current?.trim()??"";if(!j&&0===m.images.length||v.current)return;let y=n.selectedSkillRef.current,N=n.selectedAcpAgentRef.current,k=m.images.length>0?[...m.images]:void 0,w={role:"user",content:j,timestamp:Date.now(),...y&&{skillName:y.name},...k&&{images:k}};m.clearImages();let S=[...f.messages,w];f.setMessages([...S,{role:"assistant",content:"",timestamp:Date.now()}]),l(),r&&!g.current&&(g.current=!0,r()),d(!0),u("connecting"),x(0);let C=new AbortController;h.current=C;let A=3;try{let e=localStorage.getItem("mindos-reconnect-retries");if(null!==e){let t=parseInt(e,10);Number.isFinite(t)&&(A=Math.max(0,Math.min(10,t)))}}catch{}p.current=A;let z=JSON.stringify({messages:S,currentFile:e,attachedFiles:n.attachedFilesRef.current,uploadedFiles:b.localAttachments.map(e=>({name:e.name,content:e.content.length>2e4?e.content.slice(0,2e4)+"\n\n[...truncated to first ~20000 chars]":e.content})),selectedAcpAgent:N,mode:t,providerOverride:s??void 0}),E=async()=>{let e=await fetch("/api/ask",{method:"POST",headers:{"Content-Type":"application/json"},body:z,signal:C.signal});if(!e.ok){let t=`Request failed (${e.status})`;try{let s=await e.json();"string"==typeof s?.error&&s.error.trim()?t=s.error:"object"==typeof s?.error&&"string"==typeof s.error?.message&&s.error.message.trim()?t=s.error.message:"string"==typeof s?.message&&s.message.trim()&&(t=s.message)}catch(e){console.warn("[useAskChat] error body parse failed:",e)}let s=Error(t);throw s.httpStatus=e.status,s}if(!e.body)throw Error("No response body");return u("thinking"),{finalMessage:await (0,sF.m)(e.body,e=>{u("streaming"),n.sessionRef.current?.setMessages(t=>{let s=[...t];return s[s.length-1]=e,s})},C.signal)}};try{let e=null;for(let t=0;t<=A&&!C.signal.aborted;t++){if(t>0){var T;x(t),u("reconnecting"),n.sessionRef.current?.setMessages(e=>{let t=[...e];return t[t.length-1]={role:"assistant",content:"",timestamp:Date.now()},t}),await function(e,t){return new Promise((s,r)=>{let n=()=>t?.reason??new DOMException("The operation was aborted.","AbortError");if(t?.aborted)return void r(n());let a=setTimeout(s,e);t?.addEventListener("abort",()=>{clearTimeout(a),r(n())},{once:!0})})}((T=t-1,Math.min(1e3*2**T,1e4)),C.signal),u("connecting")}try{let{finalMessage:e}=await E();e.content.trim()||e.parts&&0!==e.parts.length||n.sessionRef.current?.setMessages(e=>{let t=[...e];return t[t.length-1]={role:"assistant",content:`__error__${o.noResponse}`},t});return}catch(r){e=r instanceof Error?r:Error(String(r));let s=r.httpStatus;if(!function(e,t){if(e instanceof DOMException&&"AbortError"===e.name||t&&sO.has(t))return!1;if(e instanceof Error){let t=e.message;if(s_.some(e=>e.test(t)))return!1}return!0}(r,s)||t>=A)break}}if(e)throw e}catch(e){if("AbortError"===e.name)n.sessionRef.current?.setMessages(e=>{let t=[...e],s=t.length-1;if(s>=0&&"assistant"===t[s].role){let e=t[s];e.content.trim()||e.parts&&e.parts.length>0||(t[s]={role:"assistant",content:`__error__${o.stopped}`})}return t});else{let t=e instanceof Error?e.message:"Something went wrong";n.sessionRef.current?.setMessages(e=>{let s=[...e],r=s.length-1;if(r>=0&&"assistant"===s[r].role){let e=s[r];if(!(e.content.trim()||e.parts&&e.parts.length>0))return s[r]={role:"assistant",content:`__error__${t}`},s}return[...s,{role:"assistant",content:`__error__${t}`}]})}}finally{d(!1),x(0),h.current=null}},[e,t,s,o.noResponse,o.stopped,r,n,l]),v=(0,a.useRef)(i);return v.current=i,{isLoading:i,isLoadingRef:v,loadingPhase:c,reconnectAttempt:m,reconnectMaxRef:p,abortRef:h,firstMessageFired:g,submit:b,stop:f}}({currentFile:t,chatMode:O,providerOverride:U,onFirstMessage:o,refs:er.current,errorLabels:{noResponse:f.ask.errorNoResponse,stopped:f.ask.stopped},resetInputState:es}),{isLoading:eo,loadingPhase:el,reconnectAttempt:ei,reconnectMaxRef:ed}=en,ec=en.submit,eu=en.stop;(0,a.useEffect)(()=>{let e=e=>{let t=e.detail?.files;Array.isArray(t)&&t.length>0&&G.current.injectFiles(t)};return window.addEventListener("mindos:inject-ask-files",e),()=>window.removeEventListener("mindos:inject-ask-files",e)},[]);let em=(0,a.useRef)(!1),ex=(0,a.useRef)(t);(0,a.useEffect)(()=>{let r="panel"===l?e&&!em.current:e,a=e&&em.current&&t!==ex.current;r?(setTimeout(()=>h.current?.focus(),50),W.initSessions(),N(s||""),en.firstMessageFired.current=!1,S(t?[t]:[]),K.clearAttachments(),Y.clearImages(),J.resetMention(),Z.resetSlash(),D(null),P(n??null),z(!1)):a?S(t?[t]:[]):e||"modal"!==l||en.abortRef.current?.abort(),em.current=e,ex.current=t},[e,t]),(0,a.useEffect)(()=>{if(!e||!W.activeSessionId)return;let t=W.messages;if(en.isLoading&&t.length>0){let e=t[t.length-1];if("assistant"===e.role&&!e.content.trim()&&(!e.parts||0===e.parts.length))return}return W.persistSession(t,W.activeSessionId),()=>W.clearPersistTimer()},[e,W.messages,W.activeSessionId,en.isLoading]),(0,a.useEffect)(()=>{if(!e)return;let t="modal"===l,s="panel"===l&&d;if(!t&&!s)return;let r=e=>{if("Escape"===e.key){if(null!==ee.current.mentionQuery)return void ee.current.resetMention();if(null!==et.current.slashQuery)return void et.current.resetSlash();if(s&&c)return void c();t&&i&&i()}};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[l,e,i,d,c]),(0,a.useEffect)(()=>{if(!$)return;let e=()=>R(!1),t=setTimeout(()=>document.addEventListener("click",e),0);return()=>{clearTimeout(t),document.removeEventListener("click",e)}},[$]);let ep=(0,a.useRef)(null);(0,a.useLayoutEffect)(()=>{if(!e)return;let t=h.current;t&&t instanceof HTMLTextAreaElement&&function(e,t){let s=sB.get(e);if(!s){let t=getComputedStyle(e),r=parseFloat(t.lineHeight),n=parseFloat(t.fontSize),a=Number.isFinite(n)?n:14,o=8*(Number.isFinite(r)?r:1.375*a)+((Number.isFinite(parseFloat(t.paddingTop))?parseFloat(t.paddingTop):0)+(Number.isFinite(parseFloat(t.paddingBottom))?parseFloat(t.paddingBottom):0));if(!Number.isFinite(o)||o<=0)return;s={maxH:o},sB.set(e,s)}let{maxH:r}=s;e.style.height="auto";let n=e.scrollHeight,a=Math.min(n,r);e.style.height=`${a}px`,e.style.overflowY=n>r?"auto":"hidden"}(t,0)},[j,eo,e]),(0,a.useEffect)(()=>{let e=h.current;if(!e)return;let t=()=>sB.delete(e);return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]);let eh=(0,a.useRef)(null),eg=(0,a.useRef)(null),ef=(0,a.useCallback)((e,t)=>{N(e);let s=t??e.length;eh.current&&clearTimeout(eh.current),eg.current&&clearTimeout(eg.current),eh.current=setTimeout(()=>ee.current.updateMentionFromInput(e,s),80),eg.current=setTimeout(()=>et.current.updateSlashFromInput(e,s),80)},[]);(0,a.useEffect)(()=>()=>{eh.current&&clearTimeout(eh.current),eg.current&&clearTimeout(eg.current)},[]);let eb=(0,a.useCallback)(e=>{let t=h.current,s=k.current,r=t?.selectionStart??s.length,n=s.slice(0,r).lastIndexOf("@");N(s.slice(0,n)+s.slice(r)),ee.current.resetMention(),C.current.includes(e)||S(t=>[...t,e]),setTimeout(()=>{h.current?.focus(),h.current?.setSelectionRange(n,n)},0)},[]),ev=(0,a.useCallback)(e=>{let t=h.current,s=k.current,r=t?.selectionStart??s.length,n=s.slice(0,r).lastIndexOf("/");N(s.slice(0,n)+s.slice(r)),D(e),et.current.resetSlash(),setTimeout(()=>{h.current?.focus(),h.current?.setSelectionRange(n,n)},0)},[]),ej=(0,a.useRef)(eb);ej.current=eb;let ey=(0,a.useRef)(ev);ey.current=ev;let eN=(0,a.useCallback)(e=>{let t=ee.current,s=et.current;if(null!==t.mentionQuery){if("Escape"===e.key){e.preventDefault(),t.resetMention();return}if("ArrowDown"===e.key)e.preventDefault(),t.navigateMention("down");else if("ArrowUp"===e.key)e.preventDefault(),t.navigateMention("up");else if("Enter"===e.key||"Tab"===e.key){if("Enter"===e.key&&(e.shiftKey||e.nativeEvent.isComposing))return;t.mentionResults.length>0&&(e.preventDefault(),ej.current(t.mentionResults[t.mentionIndex]))}return}if(null!==s.slashQuery){if("Escape"===e.key){e.preventDefault(),s.resetSlash();return}if("ArrowDown"===e.key)e.preventDefault(),s.navigateSlash("down");else if("ArrowUp"===e.key)e.preventDefault(),s.navigateSlash("up");else if("Enter"===e.key||"Tab"===e.key){if("Enter"===e.key&&(e.shiftKey||e.nativeEvent.isComposing))return;s.slashResults.length>0&&(e.preventDefault(),ey.current(s.slashResults[s.slashIndex]))}return}"Enter"===e.key&&!e.shiftKey&&!e.nativeEvent.isComposing&&!en.isLoadingRef.current&&(k.current.trim()||X.current.images.length>0)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},[]),ek=(0,a.useCallback)(()=>{en.isLoadingRef.current||(H.current.resetSession(),N(""),S(t?[t]:[]),G.current.clearAttachments(),X.current.clearImages(),ee.current.resetMention(),et.current.resetSlash(),D(null),P(null),z(!1),setTimeout(()=>h.current?.focus(),0))},[t]),ew=(0,a.useCallback)(e=>{(e.dataTransfer.types.includes("text/mindos-path")||e.dataTransfer.types.includes("Files"))&&(e.preventDefault(),e.dataTransfer.dropEffect="copy",T(!0))},[]),eS=(0,a.useCallback)(()=>T(!1),[]),eC=(0,a.useCallback)(async e=>{e.preventDefault(),T(!1);let t=e.dataTransfer.getData("text/mindos-path");if(t){let s="directory"===e.dataTransfer.getData("text/mindos-type")?t.replace(/\/?$/,"/"):t;C.current.includes(s)||S(e=>[...e,s]);return}await X.current.handleDrop(e)},[]),eA=(0,a.useCallback)(e=>{let t=e.clipboardData?.items;!t||Array.from(t).some(e=>"file"===e.kind&&e.type.startsWith("image/"))&&(e.preventDefault(),X.current.handlePaste(e))},[]),ez=(0,a.useCallback)(e=>{H.current.loadSession(e),z(!1),N(""),S(t?[t]:[]),G.current.clearAttachments(),X.current.clearImages(),ee.current.resetMention(),et.current.resetSlash(),D(null),P(null),setTimeout(()=>h.current?.focus(),0)},[t]),eE=(0,a.useCallback)(()=>z(e=>!e),[]),eT=(0,a.useMemo)(()=>({connecting:f.ask.connecting,thinking:f.ask.thinking,generating:f.ask.generating,reconnecting:ei>0?f.ask.reconnecting(ei,ed.current):void 0}),[f,ei]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(sA,{isPanel:p,showHistory:A,onToggleHistory:eE,onReset:ek,isLoading:eo,maximized:d,onMaximize:c,askMode:m,onModeSwitch:x,onClose:i}),p&&W.sessions.length>0&&(0,r.jsx)(sk,{sessions:W.sessions,activeSessionId:W.activeSessionId,onLoad:ez,onDelete:W.deleteSession,onNew:ek}),A&&(0,r.jsx)(sN,{sessions:W.sessions,activeSessionId:W.activeSessionId,onLoad:ez,onDelete:W.deleteSession,onRename:W.renameSession,onClearAll:W.clearAllSessions,labels:{title:f.ask.sessionHistory??"Session History",clearAll:f.ask.clearAll??"Clear all",confirmClear:f.ask.confirmClear??"Confirm clear?",noSessions:f.ask.noSessions??"No saved sessions.",rename:f.ask.renameSession??"Rename"}}),(0,r.jsx)(sb,{messages:W.messages,isLoading:eo,loadingPhase:el,emptyPrompt:f.ask.emptyPrompt,emptyHint:f.ask.emptyHint,suggestions:f.ask.suggestions,onSuggestionClick:N,labels:eT}),null!==J.mentionQuery&&J.mentionResults.length>0&&(0,r.jsx)("div",{className:"shrink-0 px-3 pb-1",children:(0,r.jsx)(sj,{results:J.mentionResults,selectedIndex:J.mentionIndex,query:J.mentionQuery??void 0,onSelect:eb})}),null!==Z.slashQuery&&Z.slashResults.length>0&&(0,r.jsx)("div",{className:"shrink-0 px-3 pb-1",children:(0,r.jsx)(sy,{results:Z.slashResults,selectedIndex:Z.slashIndex,query:Z.slashQuery??void 0,onSelect:ev})}),(0,r.jsx)("div",{className:"shrink-0 px-3 pb-2 pt-1",children:(0,r.jsxs)("div",{className:(0,ea.cn)("rounded-xl border border-border/60 bg-card shadow-sm transition-shadow",E&&"ring-2 ring-[var(--amber)] bg-[var(--amber-dim)]"),onDragOver:ew,onDragLeave:eS,onDrop:eC,children:[(w.length>0||K.localAttachments.length>0||Y.images.length>0||M||L||K.uploadError||Y.imageError)&&(0,r.jsxs)("div",{className:(0,ea.cn)("px-3 pt-2.5 pb-1",p?"max-h-24 overflow-y-auto":"max-h-28 overflow-y-auto"),children:[(0,r.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[w.map(e=>(0,r.jsx)(s$,{path:e,variant:"kb",onRemove:()=>S(t=>t.filter(t=>t!==e))},e)),K.localAttachments.map((e,t)=>(0,r.jsx)(s$,{path:e.name,variant:"upload",onRemove:()=>K.removeAttachment(t)},`up-${e.name}-${t}`)),Y.images.map((e,t)=>(0,r.jsx)(s$,{path:`Image ${t+1}`,variant:"image",imageData:e.data,imageMime:e.mimeType,onRemove:()=>Y.removeImage(t)},`img-${t}`)),M&&(0,r.jsx)(s$,{path:M.name,variant:"skill",onRemove:()=>{D(null),h.current?.focus()}})]}),(K.uploadError||Y.imageError)&&(0,r.jsx)("div",{className:"mt-1 text-xs text-error",children:K.uploadError||Y.imageError})]}),(0,r.jsxs)("form",{ref:ep,onSubmit:ec,className:"flex items-end gap-1 px-1.5 py-1.5",children:[(0,r.jsxs)("div",{className:"relative shrink-0",children:[(0,r.jsx)("button",{type:"button",onClick:()=>R(e=>!e),className:"p-1.5 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors",title:f.hints.attachFile,children:(0,r.jsx)(V.A,{size:15})}),$&&(0,r.jsxs)("div",{className:"absolute bottom-full left-0 mb-1 py-1 rounded-lg border border-border bg-card shadow-lg z-50 min-w-[140px]",children:[(0,r.jsxs)("button",{type:"button",className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs hover:bg-muted transition-colors text-left",onClick:()=>{R(!1),K.uploadInputRef.current?.click()},children:[(0,r.jsx)(q.A,{size:12,className:"shrink-0 text-muted-foreground"}),f.ask.attachFileLabel]}),(0,r.jsxs)("button",{type:"button",className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs hover:bg-muted transition-colors text-left",onClick:()=>{R(!1),g.current?.click()},children:[(0,r.jsx)(tR.A,{size:12,className:"shrink-0 text-muted-foreground"}),f.ask.attachImageLabel]})]})]}),(0,r.jsx)("input",{ref:K.uploadInputRef,type:"file",className:"hidden",multiple:!0,accept:".txt,.md,.markdown,.csv,.json,.yaml,.yml,.xml,.html,.htm,.pdf,text/plain,text/markdown,text/csv,application/json,application/pdf",onChange:async e=>{let t=e.currentTarget;await K.pickFiles(t.files),t.value=""}}),(0,r.jsx)("input",{ref:g,type:"file",className:"hidden",multiple:!0,accept:"image/png,image/jpeg,image/gif,image/webp",onChange:async e=>{let t=e.currentTarget;await Y.handleFileSelect(t.files),t.value=""}}),(0,r.jsx)("textarea",{ref:e=>{h.current=e},value:j,onChange:e=>ef(e.target.value,e.target.selectionStart??void 0),onKeyDown:eN,onPaste:eA,placeholder:f.ask.placeholder,rows:1,className:"min-w-0 flex-1 resize-none overflow-y-hidden bg-transparent py-1.5 text-sm leading-snug text-foreground placeholder:text-muted-foreground outline-none focus-visible:ring-0"}),eo?(0,r.jsx)("button",{type:"button",onClick:eu,className:"p-1.5 rounded-lg transition-colors shrink-0 text-muted-foreground hover:text-foreground hover:bg-muted/60",title:"reconnecting"===el?f.ask.cancelReconnect:f.ask.stopTitle,children:"reconnecting"===el?(0,r.jsx)(u.A,{size:15}):(0,r.jsx)(tM.A,{size:15})}):(0,r.jsx)("button",{type:"submit",disabled:!j.trim()&&0===Y.images.length,className:"p-1.5 rounded-lg disabled:opacity-40 disabled:cursor-not-allowed transition-opacity shrink-0 bg-[var(--amber)] text-[var(--amber-foreground)]",children:(0,r.jsx)(tD.A,{size:14})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 px-3 pb-2 pt-0.5 border-t border-border/30",children:[(0,r.jsx)(tO,{mode:O,onChange:_,disabled:eo}),b&&Q.installedAgents.length>0&&(0,r.jsx)(sR,{selectedAgent:L,onSelect:P,installedAgents:Q.installedAgents,loading:Q.loading}),b&&(0,r.jsx)(sP,{value:U,onChange:B,disabled:eo})]})]})})]})}var sH=s(86343);function sK({open:e,onClose:t,currentFile:s,initialMessage:n,initialAcpAgent:o,onFirstMessage:l,width:i,onWidthChange:d,onWidthCommit:c,askMode:u,onModeSwitch:m,maximized:x=!1,onMaximize:p,sidebarOffset:h=0}){let g=(0,a.useRef)(!1),f=(0,a.useRef)(!1),b=window.innerWidth-h,v=(0,a.useCallback)(e=>{if(g.current)return;let t=Math.min(e,b);if(x&&t<b-16&&p){f.current=!0,p(),d(Math.min(t,window.innerWidth-h-360));return}let s=window.innerWidth-h-t,r=t>=b-80||!f.current&&s<360;if(!x&&r&&p){g.current=!0,p();return}x||d(t)},[b,h,p,x,d]),j=eJ({width:x?b:i,minWidth:400,maxWidth:b,maxWidthRatio:1,direction:"left",onResize:v,onResizeEnd:(0,a.useCallback)(e=>{g.current||c(e)},[c])}),y=(0,a.useCallback)(e=>{g.current=!1,f.current&&window.innerWidth-h-i>=360&&(f.current=!1),j(e)},[j,h,i]),N=x?`calc(100vw - ${h}px)`:`${i}px`;return(0,r.jsxs)("aside",{className:`
|
|
57
|
-
hidden md:flex fixed top-0 right-0 h-screen z-40
|
|
58
|
-
flex-col bg-card border-l border-border
|
|
59
|
-
transition-[width,transform] duration-200 ease-out
|
|
60
|
-
${e?"translate-x-0":"translate-x-full pointer-events-none"}
|
|
61
|
-
`,style:{width:N,minWidth:"400px"},role:"complementary","aria-label":"MindOS Agent panel",children:[(0,r.jsx)(sH.default,{fallback:(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-3 px-6 text-center",children:[(0,r.jsx)(S.A,{size:20,className:"text-muted-foreground"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"AI panel encountered an error."}),(0,r.jsx)("button",{onClick:()=>window.location.reload(),className:"text-xs px-3 py-1.5 rounded-lg border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:"Reload page"})]}),children:(0,r.jsx)("div",{className:"flex min-h-0 w-full flex-1 flex-col overflow-hidden",children:(0,r.jsx)(sW,{visible:e,variant:"panel",currentFile:e?s:void 0,initialMessage:n,initialAcpAgent:o,onFirstMessage:l,onClose:t,askMode:u,onModeSwitch:m,maximized:x,onMaximize:p})})}),(0,r.jsx)("div",{className:"absolute top-0 -left-[3px] w-[6px] h-full cursor-col-resize z-40 group hidden md:block",onMouseDown:y,children:(0,r.jsx)("div",{className:"absolute left-[2px] top-0 w-[2px] h-full opacity-0 group-hover:opacity-100 bg-[var(--amber)]/60 transition-opacity"})})]})}var sG=s(92972),sY=s(13845);function sJ({agent:e,agentStatus:t,mcpStatus:s,onBack:n,onInstallAgent:o,copy:l,headerVariant:i="inline"}){let[d,c]=(0,a.useState)(!1),[m,x]=(0,a.useState)(null),[p,h]=(0,a.useState)(()=>e.preferredTransport),g=(0,a.useMemo)(()=>"notFound"===t?null:(0,sY.$k)(e,s,p),[e,s,p,t]),f=async()=>{c(!0),x(null),x(await o(e.key)?{type:"success",text:`${e.name} ${l.connected}`}:{type:"error",text:l.installFailed}),c(!1)},b=async()=>{!g||await (0,t7.l)(g.snippet)&&ek.oR.copy()},j="connected"===t?"bg-[var(--success)]":"detected"===t?"bg-[var(--amber)]":"bg-muted-foreground";return(0,r.jsxs)("div",{className:"flex flex-col h-full min-h-0",children:["dock"===i?(0,r.jsxs)("header",{className:"shrink-0 flex items-center justify-between gap-3 border-b border-border px-4 py-3 bg-card",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0",children:[(0,r.jsx)("span",{className:`w-2 h-2 rounded-full shrink-0 ${j}`}),(0,r.jsx)("h2",{className:"text-sm font-semibold text-foreground truncate",title:e.name,children:e.name})]}),(0,r.jsx)("button",{type:"button",onClick:n,className:"p-1.5 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring shrink-0","aria-label":l.closeDetail??"Close",children:(0,r.jsx)(u.A,{size:16})})]}):(0,r.jsxs)("div",{className:"sticky top-0 z-10 flex items-center gap-2 border-b border-border bg-background/95 px-3 py-2.5 backdrop-blur-sm shrink-0",children:[(0,r.jsxs)("button",{type:"button",onClick:n,className:"flex items-center gap-1 text-2xs text-muted-foreground hover:text-foreground rounded-md px-1 py-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring shrink-0",children:[(0,r.jsx)(v.A,{size:16}),l.backToList]}),(0,r.jsx)("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${j}`}),(0,r.jsx)("span",{className:"text-sm font-medium text-foreground truncate",title:e.name,children:e.name})]}),(0,r.jsxs)("div",{className:"px-4 py-4 space-y-4 flex-1 min-h-0 overflow-y-auto",children:["detected"===t&&(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxs)("button",{type:"button",onClick:f,disabled:d,className:"inline-flex items-center gap-1.5 px-3 py-2 text-xs rounded-lg font-medium text-white disabled:opacity-50 bg-[var(--amber)] hover:bg-[var(--amber)]/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[d?(0,r.jsx)(C.A,{size:14,className:"animate-spin"}):null,d?l.installing:l.install]}),m&&(0,r.jsxs)("span",{className:`flex items-center gap-1 text-2xs ${"success"===m.type?"text-success":"text-destructive"}`,children:["success"===m.type?(0,r.jsx)(N.A,{size:12}):(0,r.jsx)(S.A,{size:12}),m.text]})]}),"notFound"===t&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground leading-relaxed",children:l.notFoundDetail}),"notFound"!==t&&g&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-2xs font-medium text-muted-foreground uppercase tracking-wider mb-1",children:l.configPath}),(0,r.jsx)("p",{className:"text-xs font-mono text-foreground break-all",children:g.path})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-2xs font-medium text-muted-foreground uppercase tracking-wider mb-2",children:l.agentDetailTransport}),(0,r.jsxs)("div",{className:"flex items-center gap-1 p-0.5 rounded-lg bg-muted/40 w-fit",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>h("stdio"),className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${"stdio"===p?"bg-card shadow-sm text-foreground":"text-muted-foreground"}`,children:[(0,r.jsx)(sG.A,{size:13}),l.transportLocal]}),(0,r.jsxs)("button",{type:"button",onClick:()=>h("http"),className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${"http"===p?"bg-card shadow-sm text-foreground":"text-muted-foreground"}`,children:[(0,r.jsx)(e1.A,{size:13}),l.transportRemote]})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-2xs font-medium text-muted-foreground uppercase tracking-wider mb-2",children:l.agentDetailSnippet}),(0,r.jsx)("pre",{className:"text-[11px] font-mono bg-muted/50 border border-border rounded-lg p-3 overflow-x-auto whitespace-pre max-h-[min(320px,50vh)] overflow-y-auto select-all",children:g.displaySnippet})]}),(0,r.jsxs)("button",{type:"button",onClick:b,className:"inline-flex items-center gap-1.5 px-3 py-2 rounded-lg border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors text-xs focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,r.jsx)(ed.A,{size:14}),l.copyConfig]})]})]})]})}function sV({open:e,agentKey:t,onClose:s,rightOffset:n,width:o,onWidthChange:l,onWidthCommit:i}){let d=(0,e2.kr)(),{t:c}=(0,y.Y)(),u=c.panels.agents,m=d.agents.filter(e=>e.present&&e.installed),x=d.agents.filter(e=>e.present&&!e.installed),p=d.agents.filter(e=>!e.present),h=(0,a.useMemo)(()=>{if(!t)return null;let e=d.agents.find(e=>e.key===t);if(!e)return null;let s=m.some(e=>e.key===t)?"connected":x.some(e=>e.key===t)?"detected":p.some(e=>e.key===t)?"notFound":null;return s?{agent:e,status:s}:null},[t,d.agents,m,x,p]);(0,a.useEffect)(()=>{if(t&&!h){let e=requestAnimationFrame(()=>s());return()=>cancelAnimationFrame(e)}},[t,h,s]);let g=eJ({width:o,minWidth:300,maxWidth:640,maxWidthRatio:.42,direction:"left",onResize:l,onResizeEnd:i}),f={connected:u.connected,installing:u.installing,install:u.install,installFailed:u.installFailed,copyConfig:u.copyConfig,copied:u.copied,transportLocal:u.transportLocal,transportRemote:u.transportRemote,configPath:u.configPath,notFoundDetail:u.notFoundDetail,backToList:u.backToList,closeDetail:u.closeAgentDetail,agentDetailTransport:u.agentDetailTransport,agentDetailSnippet:u.agentDetailSnippet};return(0,r.jsxs)("aside",{className:`
|
|
62
|
-
hidden md:flex fixed top-0 h-screen z-[31] flex-col bg-card border-l border-border shadow-sm
|
|
63
|
-
transition-transform duration-200 ease-out
|
|
64
|
-
${e?"translate-x-0":"translate-x-full pointer-events-none"}
|
|
65
|
-
`,style:{width:`${o}px`,right:`${n}px`},role:"complementary","aria-label":u.agentDetailPanelAria,"aria-hidden":!e||!h,children:[h&&(0,r.jsx)("div",{className:"flex flex-col flex-1 min-h-0 overflow-y-auto",children:(0,r.jsx)(sJ,{agent:h.agent,agentStatus:h.status,mcpStatus:d.status,onBack:s,onInstallAgent:d.installAgent,copy:f,headerVariant:"dock"})}),(0,r.jsx)("div",{className:"absolute top-0 -left-[3px] w-[6px] h-full cursor-col-resize z-40 group hidden md:block",onMouseDown:g,children:(0,r.jsx)("div",{className:"absolute left-[2px] top-0 w-[2px] h-full opacity-0 group-hover:opacity-100 bg-[var(--amber)]/50 transition-opacity"})})]})}function sq({onToggle:e,askPanelOpen:t}){let{t:s}=(0,y.Y)(),n=`${s.ask?.fabLabel??"Ask AI"} (⌘/)`;return(0,r.jsxs)("button",{onClick:e,className:`
|
|
66
|
-
group hidden md:flex
|
|
67
|
-
fixed z-40 bottom-5 right-5
|
|
68
|
-
items-center justify-center
|
|
69
|
-
gap-0 hover:gap-2
|
|
70
|
-
p-3 rounded-xl
|
|
71
|
-
text-white font-medium text-[13px]
|
|
72
|
-
shadow-sm shadow-amber-900/10
|
|
73
|
-
transition-all duration-200 ease-out
|
|
74
|
-
hover:shadow-md hover:shadow-amber-900/15
|
|
75
|
-
active:scale-95 cursor-pointer overflow-hidden
|
|
76
|
-
${t?"opacity-0 pointer-events-none translate-y-2":"opacity-100 translate-y-0"}
|
|
77
|
-
`,style:{background:"var(--amber)"},title:n,"aria-label":n,children:[(0,r.jsx)(tL.A,{size:16,className:"relative z-10 shrink-0"}),(0,r.jsx)("span",{className:" relative z-10 max-w-0 group-hover:max-w-[120px] opacity-0 group-hover:opacity-100 transition-all duration-200 ease-out whitespace-nowrap overflow-hidden ",children:s.ask?.fabLabel??"Ask AI"})]})}function sZ({open:e,onClose:t,anchorRect:s,railWidth:n,onOpenSyncSettings:o,syncStatus:l,onSyncStatusRefresh:i}){let d=(0,a.useRef)(null),c=(0,a.useRef)(t);c.current=t;let{syncing:m,syncResult:x,syncNow:p}=B(i);if((0,a.useEffect)(()=>{if(!e)return;let t=e=>{"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),c.current())};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e]),(0,a.useEffect)(()=>{if(!e)return;let t=e=>{d.current&&!d.current.contains(e.target)&&c.current()},s=setTimeout(()=>window.addEventListener("mousedown",t),0);return()=>{clearTimeout(s),window.removeEventListener("mousedown",t)}},[e]),!e||!s)return null;let h=O(l,m),{label:g}=W(h,l),f=Math.max(8,s.bottom-180);return(0,r.jsxs)("div",{ref:d,className:"fixed z-40 w-[240px] border rounded-lg bg-card shadow-lg border-border animate-in fade-in slide-in-from-left-2 duration-150",style:{top:f,left:n},children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Sync"}),(0,r.jsx)("button",{onClick:t,className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors focus-visible:ring-2 focus-visible:ring-ring","aria-label":"Close",children:(0,r.jsx)(u.A,{size:14})})]}),(0,r.jsxs)("div",{className:"p-3 space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:`w-2.5 h-2.5 rounded-full shrink-0 ${_[h]} ${"syncing"===h||"conflicts"===h||"error"===h?"animate-pulse":""}`}),(0,r.jsx)("span",{className:"text-sm text-foreground",children:g}),"success"===x&&(0,r.jsx)(N.A,{size:14,className:"text-success shrink-0"}),"error"===x&&(0,r.jsx)(k.A,{size:14,className:"text-error shrink-0"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:["off"!==h&&(0,r.jsxs)(R.jn,{onClick:p,disabled:m,className:"text-xs px-3 py-1.5 flex items-center gap-1.5",children:[(0,r.jsx)(b.A,{size:12,className:m?"animate-spin":""}),"Sync Now"]}),(0,r.jsx)("button",{onClick:()=>{o(),t()},className:"text-xs text-muted-foreground hover:text-foreground transition-colors rounded px-1 py-0.5 focus-visible:ring-2 focus-visible:ring-ring",children:"Settings →"})]})]})]})}var sQ=s(9199),sX=s(36999),s0=s(94961);function s1({open:e,onClose:t}){let[s,o]=(0,a.useState)(""),[l,i]=(0,a.useState)([]),[m,x]=(0,a.useState)(!1),[p,g]=(0,a.useState)(0),[b,v]=(0,a.useState)("search"),[j,N]=(0,a.useState)(0),k=(0,a.useRef)(null),S=(0,a.useRef)(null),C=(0,a.useRef)(null),A=(0,n.useRouter)(),z=(0,a.useRef)(null),{t:E}=(0,y.Y)(),T="u">typeof document&&document.documentElement.classList.contains("dark"),$=(0,a.useMemo)(()=>[{id:"settings",label:E.search.openSettings,icon:(0,r.jsx)(c.A,{size:15}),shortcut:"⌘,",execute:()=>{A.push("/settings"),t()}},{id:"restart-walkthrough",label:E.search.restartWalkthrough,icon:(0,r.jsx)(sQ.A,{size:15}),execute:()=>{fetch("/api/setup",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({walkthroughStep:0,walkthroughDismissed:!1})}).then(()=>{ek.oR.success(E.search.walkthroughRestarted)}).catch(()=>{ek.oR.error("Failed to restart walkthrough")}),t()}},{id:"toggle-dark-mode",label:E.search.toggleDarkMode,icon:T?(0,r.jsx)(tN.A,{size:15}):(0,r.jsx)(sX.A,{size:15}),execute:()=>{let e=document.documentElement,s=e.classList.contains("dark");e.classList.toggle("dark",!s);try{localStorage.setItem("theme",s?"light":"dark")}catch{}t()}},{id:"go-agents",label:E.search.goToAgents,icon:(0,r.jsx)(h.A,{size:15}),execute:()=>{A.push("/agents"),t()}},{id:"go-discover",label:E.search.goToDiscover,icon:(0,r.jsx)(f.A,{size:15}),execute:()=>{A.push("/discover"),t()}},{id:"go-help",label:E.search.goToHelp,icon:(0,r.jsx)(s0.A,{size:15}),execute:()=>{A.push("/help"),t()}}],[E,A,t,T]);(0,a.useEffect)(()=>{e&&(setTimeout(()=>k.current?.focus(),50),o(""),i([]),g(0),v("search"),N(0))},[e]);let R=(0,a.useCallback)(e=>{if(z.current&&clearTimeout(z.current),!e.trim()){i([]),x(!1);return}x(!0),z.current=setTimeout(async()=>{try{let t=await (0,w.n)(`/api/search?q=${encodeURIComponent(e)}`);i(Array.isArray(t)?t:[]),g(0)}catch{i([])}finally{x(!1)}},300)},[]),M=(0,a.useCallback)(e=>{let t=e.target.value;o(t),R(t)},[R]),D=(0,a.useCallback)(e=>{A.push(`/view/${(0,ea.O0)(e.path)}`),t()},[A,t]);return((0,a.useEffect)(()=>{if(!e)return;let s=e=>{"Escape"===e.key?t():"Tab"===e.key?(e.preventDefault(),v(e=>"search"===e?"actions":"search"),N(0),g(0)):"ArrowDown"===e.key?(e.preventDefault(),"search"===b?g(e=>Math.min(e+1,l.length-1)):N(e=>Math.min(e+1,$.length-1))):"ArrowUp"===e.key?(e.preventDefault(),"search"===b?g(e=>Math.max(e-1,0)):N(e=>Math.max(e-1,0))):"Enter"===e.key&&("search"===b?l[p]&&D(l[p]):$[j]&&$[j].execute())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e,t,l,p,D,b,$,j]),(0,a.useLayoutEffect)(()=>{if("search"===b){let e=S.current;if(!e)return;let t=e.children[p];t?.scrollIntoView({block:"nearest"})}else{let e=C.current;if(!e)return;let t=e.children[j];t?.scrollIntoView({block:"nearest"})}},[p,j,b]),e)?(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-end md:items-start justify-center md:pt-[15vh] modal-backdrop",onClick:e=>e.target===e.currentTarget&&t(),children:(0,r.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":"Command palette",className:"w-full md:max-w-xl md:mx-4 bg-card border-t md:border border-border rounded-t-2xl md:rounded-xl shadow-2xl overflow-hidden max-h-[85vh] md:max-h-none flex flex-col",children:[(0,r.jsx)("div",{className:"flex justify-center pt-2 pb-0 md:hidden",children:(0,r.jsx)("div",{className:"w-8 h-1 rounded-full bg-muted-foreground/20"})}),(0,r.jsxs)("div",{className:"flex items-center gap-1 px-4 pt-2 pb-0",children:[(0,r.jsx)("button",{onClick:()=>{v("search"),setTimeout(()=>k.current?.focus(),50)},className:`px-3 py-1.5 text-xs font-medium rounded-t transition-colors ${"search"===b?"text-foreground border-b-2 border-[var(--amber)]":"text-muted-foreground hover:text-foreground"}`,children:E.search.tabSearch}),(0,r.jsx)("button",{onClick:()=>{v("actions"),N(0)},className:`px-3 py-1.5 text-xs font-medium rounded-t transition-colors ${"actions"===b?"text-foreground border-b-2 border-[var(--amber)]":"text-muted-foreground hover:text-foreground"}`,children:E.search.tabActions})]}),"search"===b&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border",children:[(0,r.jsx)(d.A,{size:16,className:"text-muted-foreground shrink-0"}),(0,r.jsx)("input",{ref:k,type:"text",value:s,onChange:M,placeholder:E.search.placeholder,className:"flex-1 bg-transparent text-foreground placeholder:text-muted-foreground text-sm outline-none"}),m&&(0,r.jsx)("div",{className:"w-4 h-4 border-2 border-muted-foreground/40 border-t-foreground rounded-full animate-spin shrink-0"}),!m&&s&&(0,r.jsx)("button",{onClick:()=>{o(""),i([]),k.current?.focus()},children:(0,r.jsx)(u.A,{size:14,className:"text-muted-foreground hover:text-foreground"})}),(0,r.jsx)("kbd",{className:"hidden md:inline text-xs text-muted-foreground border border-border rounded px-1.5 py-0.5 font-mono",children:"ESC"})]}),(0,r.jsxs)("div",{ref:S,className:"max-h-[50vh] md:max-h-80 overflow-y-auto flex-1",children:[0===l.length&&s&&!m&&(0,r.jsx)("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:E.search.noResults}),0===l.length&&!s&&(0,r.jsx)("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground/60",children:E.search.prompt}),l.map((e,t)=>{let n=e.path.endsWith(".csv")?".csv":".md",a=e.path.split("/"),o=a[a.length-1],i=a.slice(0,-1).join("/");return(0,r.jsxs)("button",{onClick:()=>D(e),onMouseEnter:()=>g(t),className:`
|
|
78
|
-
w-full px-4 py-3 flex items-start gap-3 text-left transition-colors duration-75
|
|
79
|
-
${t===p?"bg-muted":"hover:bg-muted/50"}
|
|
80
|
-
${t<l.length-1?"border-b border-border":""}
|
|
81
|
-
`,children:[".csv"===n?(0,r.jsx)(eo.A,{size:14,className:"text-success shrink-0 mt-0.5"}):(0,r.jsx)(q.A,{size:14,className:"text-muted-foreground shrink-0 mt-0.5"}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-baseline gap-2 flex-wrap",children:[(0,r.jsx)("span",{className:"text-sm text-foreground font-medium truncate",title:o,children:o}),i&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate",title:i,children:i})]}),e.snippet&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-2 leading-relaxed",title:e.snippet,children:function(e,t){if(!t.trim())return e;let s=t.trim().split(/\s+/).filter(Boolean).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),n=RegExp(`(${s.join("|")})`,"gi");return e.split(n).map((e,t)=>n.test(e)?(0,r.jsx)("mark",{className:"bg-yellow-300/40 text-foreground rounded-sm px-0.5",children:e},t):e)}(e.snippet,s)})]})]},e.path)})]}),l.length>0&&(0,r.jsxs)("div",{className:"hidden md:flex px-4 py-2 border-t border-border items-center gap-3 text-xs text-muted-foreground/60",children:[(0,r.jsxs)("span",{children:[(0,r.jsx)("kbd",{className:"font-mono",children:"↑↓"})," ",E.search.navigate]}),(0,r.jsxs)("span",{children:[(0,r.jsx)("kbd",{className:"font-mono",children:"↵"})," ",E.search.open]}),(0,r.jsxs)("span",{children:[(0,r.jsx)("kbd",{className:"font-mono",children:"ESC"})," ",E.search.close]})]})]}),"actions"===b&&(0,r.jsx)("div",{ref:C,className:"max-h-[50vh] md:max-h-80 overflow-y-auto flex-1 py-1",children:$.map((e,t)=>(0,r.jsxs)("button",{onClick:()=>e.execute(),onMouseEnter:()=>N(t),className:`
|
|
82
|
-
w-full px-4 py-2.5 flex items-center gap-3 text-left transition-colors duration-75
|
|
83
|
-
${t===j?"bg-muted":"hover:bg-muted/50"}
|
|
84
|
-
`,children:[(0,r.jsx)("span",{className:"text-muted-foreground shrink-0",children:e.icon}),(0,r.jsx)("span",{className:"text-sm text-foreground flex-1",children:e.label}),e.shortcut&&(0,r.jsx)("kbd",{className:"text-xs text-muted-foreground/60 font-mono border border-border rounded px-1.5 py-0.5",children:e.shortcut})]},e.id))})]})}):null}function s2({open:e,onClose:t,currentFile:s,initialMessage:n,initialAcpAgent:a,onFirstMessage:o,askMode:l,onModeSwitch:i}){let{t:d}=(0,y.Y)();return e?(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-end md:items-start justify-center md:pt-[10vh] modal-backdrop",onClick:e=>e.target===e.currentTarget&&t(),children:(0,r.jsx)("div",{role:"dialog","aria-modal":"true","aria-label":d.ask.title,className:"w-full md:max-w-2xl md:mx-4 bg-card border-t md:border border-border rounded-t-2xl md:rounded-xl shadow-2xl flex flex-col h-[92vh] md:h-auto md:max-h-[75vh]",children:(0,r.jsx)(sW,{visible:e,variant:"modal",onClose:t,currentFile:s,initialMessage:n,initialAcpAgent:a,onFirstMessage:o,askMode:l,onModeSwitch:i})})}):null}var s5=s(68806),s3=s(6489),s4=s(22164),s6=s(51842);function s8({data:e,updateAi:t,updateAgent:s,t:n}){var o,l;let i,d,c,{locale:u}=(0,y.Y)(),m=e.envOverrides??{};e.envValues;let x=e.ai.provider,p=(0,sD.rl)(x)?sD.T_[x]:null,[g,f]=(0,a.useState)({}),b=(0,a.useRef)(void 0),v=(0,a.useRef)(x);(0,a.useEffect)(()=>{v.current!==x&&(v.current=x,f({}),b.current&&(clearTimeout(b.current),b.current=void 0))},[x]),(0,a.useEffect)(()=>()=>{b.current&&clearTimeout(b.current)},[]),(0,a.useEffect)(()=>{let t=e.agent?.reconnectRetries??3;try{localStorage.setItem("mindos-reconnect-retries",String(t))}catch(e){console.warn("[AiTab] localStorage setItem reconnectRetries failed:",e)}},[e.agent?.reconnectRetries]);let j=(0,a.useCallback)(async t=>{let s=e.ai.providers?.[t]??{};f(e=>({...e,[t]:{state:"testing"}}));try{let e={provider:t};s.apiKey&&(e.apiKey=s.apiKey),s.model&&(e.model=s.model),s.baseUrl&&(e.baseUrl=s.baseUrl);let r=await fetch("/api/settings/test-key",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await r.json();n.ok?(f(e=>({...e,[t]:{state:"ok",latency:n.latency}})),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{f(e=>({...e,[t]:{state:"idle"}}))},8e3)):f(e=>({...e,[t]:{state:"error",error:n.error,code:n.code}}))}catch{f(e=>({...e,[t]:{state:"error",code:"network_error",error:"Network error"}}))}},[e.ai.providers]),N=(0,a.useCallback)((s,r)=>{"apiKey"in r&&f(e=>({...e,[s]:{state:"idle"}})),t({providers:{...e.ai.providers,[s]:{...e.ai.providers?.[s],...r}}})},[e.ai.providers,t]),k=e.ai.providers?.[x]??{apiKey:"",model:"",baseUrl:""},w=p?(0,sD.Ux)(x):void 0,A=k.apiKey,z=!!w&&m[w],E=!!p?.apiKeyFallback,T=new Set(Object.entries(e.ai.providers??{}).filter(([e,t])=>t&&t.apiKey||sD.T_[e]?.apiKeyFallback).map(([e])=>e)),$=p?"zh"===u?p.nameZh:p.name:x;return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)(R.L7,{icon:(0,r.jsx)(tL.A,{size:15}),title:n.settings.ai.provider,description:$,children:[(0,r.jsx)(s6.A,{value:x,onChange:e=>{"skip"!==e&&t({provider:e})},compact:!0,configuredProviders:T}),p&&(0,r.jsxs)("div",{className:"space-y-3 pt-3",style:{borderTop:"1px solid var(--border)"},children:[(0,r.jsxs)(R.D0,{label:(0,r.jsxs)(r.Fragment,{children:[n.settings.ai.apiKey," ",w&&(0,r.jsx)(R.Bt,{overridden:m[w]})]}),hint:z?n.settings.ai.envFieldNote(w):E?n.settings.ai.keyOptionalHint:n.settings.ai.keyHint,children:[(0,r.jsx)(R.Ak,{value:k.apiKey,onChange:e=>N(x,{apiKey:e}),labels:{change:n.settings.ai.keyChange,cancel:n.settings.ai.keyCancel}}),p.signupUrl&&!k.apiKey&&!z&&(0,r.jsxs)("a",{href:p.signupUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs mt-1.5 hover:underline",style:{color:"var(--amber)"},children:[(0,r.jsx)(s4.A,{size:10}),E?"zh"===u?`下载 ${p.nameZh}`:`Download ${p.name}`:"zh"===u?`获取 ${p.nameZh} API Key`:`Get ${p.name} API Key`]})]}),p.supportsBaseUrl&&(0,r.jsx)(R.D0,{label:n.settings.ai.baseUrl,hint:n.settings.ai.baseUrlHint,children:(0,r.jsx)(R.pd,{value:k.baseUrl??"",onChange:e=>N(x,{baseUrl:e.target.value}),placeholder:p.fixedBaseUrl||(0,sD.Ot)(x)||"https://api.openai.com/v1"})}),(0,r.jsx)(R.D0,{label:n.settings.ai.model,children:(0,r.jsx)(s9,{value:k.model,onChange:e=>N(x,{model:e}),placeholder:p.defaultModel,provider:x,apiKey:k.apiKey,envKey:!!z,baseUrl:k.baseUrl,supportsListModels:p.supportsListModels,t:n})}),(o=!!k.apiKey,l=!!z,i=g[x]??{state:"idle"},d=!!sD.T_[x]?.apiKeyFallback,c="testing"===i.state||!o&&!l&&!d,(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-1.5",children:[(0,r.jsx)("button",{type:"button",disabled:c,title:c?n.hints.testInProgressOrNoKey:void 0,onClick:()=>j(x),className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg border border-border text-muted-foreground hover:text-foreground hover:border-foreground/20 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:"testing"===i.state?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(C.A,{size:12,className:"animate-spin"}),n.settings.ai.testKeyTesting]}):n.settings.ai.testKey}),"ok"===i.state&&null!=i.latency&&(0,r.jsx)("span",{className:"text-xs text-success",children:n.settings.ai.testKeyOk(i.latency)}),"error"===i.state&&(0,r.jsxs)("span",{className:"text-xs text-error",children:["✗ ",function(e,t){switch(t){case"auth_error":return e.settings.ai.testKeyAuthError;case"model_not_found":return e.settings.ai.testKeyModelNotFound;case"rate_limited":return e.settings.ai.testKeyRateLimited;case"network_error":return e.settings.ai.testKeyNetworkError;default:return e.settings.ai.testKeyUnknown}}(n,i.code)]})]}))]}),!A&&!z&&!E&&(0,r.jsxs)("div",{className:"flex items-start gap-2 text-xs text-destructive/80 bg-destructive/8 border border-destructive/20 rounded-lg px-3 py-2.5",children:[(0,r.jsx)(S.A,{size:13,className:"shrink-0 mt-0.5"}),(0,r.jsx)("span",{children:n.settings.ai.noApiKey})]}),Object.values(m).some(Boolean)&&(0,r.jsxs)("div",{className:"flex items-start gap-2 text-xs text-[var(--amber)] bg-[var(--amber-subtle)] border border-[var(--amber)]/20 rounded-lg px-3 py-2.5",children:[(0,r.jsx)(S.A,{size:13,className:"shrink-0 mt-0.5"}),(0,r.jsx)("span",{children:n.settings.ai.envHint})]})]}),(0,r.jsxs)(R.L7,{icon:(0,r.jsx)(h.A,{size:15}),title:n.settings.agent.title,description:n.settings.agent.subtitle??"Configure how the AI agent operates",children:[(0,r.jsx)(R.pM,{label:n.settings.agent.maxSteps,hint:n.settings.agent.maxStepsHint,children:(0,r.jsxs)(R.l6,{value:String(e.agent?.maxSteps??20),onChange:e=>s({maxSteps:Number(e.target.value)}),className:"w-20",children:[(0,r.jsx)("option",{value:"5",children:"5"}),(0,r.jsx)("option",{value:"10",children:"10"}),(0,r.jsx)("option",{value:"15",children:"15"}),(0,r.jsx)("option",{value:"20",children:"20"}),(0,r.jsx)("option",{value:"25",children:"25"}),(0,r.jsx)("option",{value:"30",children:"30"})]})}),(0,r.jsx)(R.pM,{label:n.settings.agent.contextStrategy,hint:n.settings.agent.contextStrategyHint,children:(0,r.jsxs)(R.l6,{value:e.agent?.contextStrategy??"auto",onChange:e=>s({contextStrategy:e.target.value}),className:"w-24",children:[(0,r.jsx)("option",{value:"auto",children:n.settings.agent.contextStrategyAuto}),(0,r.jsx)("option",{value:"off",children:n.settings.agent.contextStrategyOff})]})}),(0,r.jsx)(R.pM,{label:n.settings.agent.reconnectRetries,hint:n.settings.agent.reconnectRetriesHint,children:(0,r.jsxs)(R.l6,{value:String(e.agent?.reconnectRetries??3),onChange:e=>{let t=Number(e.target.value);s({reconnectRetries:t});try{localStorage.setItem("mindos-reconnect-retries",String(t))}catch(e){console.warn("[AiTab] localStorage setItem reconnectRetries failed:",e)}},className:"w-20",children:[(0,r.jsx)("option",{value:"0",children:"Off"}),(0,r.jsx)("option",{value:"1",children:"1"}),(0,r.jsx)("option",{value:"2",children:"2"}),(0,r.jsx)("option",{value:"3",children:"3"}),(0,r.jsx)("option",{value:"5",children:"5"}),(0,r.jsx)("option",{value:"10",children:"10"})]})}),p?.supportsThinking&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(R.pM,{label:n.settings.agent.thinking,hint:n.settings.agent.thinkingHint,children:(0,r.jsx)(R.lM,{checked:e.agent?.enableThinking??!1,onChange:()=>s({enableThinking:!e.agent?.enableThinking})})}),e.agent?.enableThinking&&(0,r.jsx)(R.D0,{label:n.settings.agent.thinkingBudget,hint:n.settings.agent.thinkingBudgetHint,children:(0,r.jsx)(R.pd,{type:"number",value:String(e.agent?.thinkingBudget??5e3),onChange:e=>{let t=parseInt(e.target.value,10);isNaN(t)||s({thinkingBudget:Math.max(1e3,Math.min(5e4,t))})},min:1e3,max:5e4,step:1e3})})]})]}),(0,r.jsx)(s7,{})]})}function s9({value:e,onChange:t,placeholder:s,provider:n,apiKey:o,envKey:l,baseUrl:i,supportsListModels:d,t:c}){let[u,m]=(0,a.useState)(null),[x,p]=(0,a.useState)(!1),[h,g]=(0,a.useState)(!1),[f,b]=(0,a.useState)(""),[v,j]=(0,a.useState)(!1),[y,N]=(0,a.useState)(-1),k=(0,a.useRef)(null),w=(0,a.useRef)(null),S=(0,a.useRef)(!1),A=(0,a.useRef)(0),z=(0,a.useRef)(!1),E=!!o||!!l||!!sD.T_[n]?.apiKeyFallback;(0,a.useEffect)(()=>{S.current=!1,A.current++,m(null)},[n,o,i]);let T=(0,a.useCallback)(async(e=!1)=>{if(z.current)return;z.current=!0,p(!0),e||b("");let t=A.current;try{let s={provider:n};o&&(s.apiKey=o),i&&(s.baseUrl=i);let r=await fetch("/api/settings/list-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(t!==A.current)return;let a=await r.json();if(t!==A.current)return;a.ok&&Array.isArray(a.models)?(m(a.models),S.current=!0,e||g(!0)):e||b(a.error||"Failed to fetch models")}catch{if(t!==A.current)return;e||b("Network error")}finally{z.current=!1,p(!1)}},[n,o,i]),$=(0,a.useCallback)(()=>{j(!0),!S.current&&d&&E&&!z.current&&T(!0)},[d,E,T]),M=(0,a.useMemo)(()=>{if(!u||!e.trim())return u??[];let t=e.toLowerCase();return u.filter(e=>e.toLowerCase().includes(t))},[u,e]),D=h||v&&null!==u&&e.trim().length>0&&M.length>0;(0,a.useEffect)(()=>{N(-1)},[M]),(0,a.useEffect)(()=>{if(y<0||!w.current)return;let e=w.current.querySelectorAll("[data-model-item]");e[y]?.scrollIntoView({block:"nearest"})},[y]);let I=(0,a.useCallback)(e=>{let s=D?M:[];s.length&&("ArrowDown"===e.key?(e.preventDefault(),N(e=>(e+1)%s.length)):"ArrowUp"===e.key?(e.preventDefault(),N(e=>(e-1+s.length)%s.length)):"Enter"===e.key&&y>=0&&y<s.length?(e.preventDefault(),t(s[y]),g(!1),j(!1)):"Escape"===e.key&&(g(!1),j(!1)))},[D,M,y,t]);return(0,a.useEffect)(()=>{if(D)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e);function e(e){k.current&&!k.current.contains(e.target)&&(g(!1),j(!1))}},[D]),(0,r.jsxs)("div",{ref:k,className:"relative",children:[(0,r.jsxs)("div",{className:"flex gap-1.5",children:[(0,r.jsx)(R.pd,{value:e,onChange:e=>{t(e.target.value),h||j(!0)},onFocus:$,onKeyDown:I,placeholder:s,className:"flex-1",autoComplete:"off"}),d&&(0,r.jsxs)("button",{type:"button",disabled:!E||x,onClick:()=>T(!1),title:c.settings.ai.listModels,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg border border-border text-muted-foreground hover:text-foreground hover:border-foreground/20 transition-colors disabled:opacity-40 disabled:cursor-not-allowed shrink-0",children:[x?(0,r.jsx)(C.A,{size:12,className:"animate-spin"}):(0,r.jsx)(eu.A,{size:12}),c.settings.ai.listModels]})]}),f&&(0,r.jsx)("p",{className:"text-xs text-error mt-1",children:f}),D&&M.length>0&&(0,r.jsx)("div",{ref:w,className:"absolute z-50 mt-1 w-full max-h-48 overflow-y-auto rounded-lg border border-border bg-popover shadow-lg",children:M.map((s,n)=>(0,r.jsx)("button",{type:"button","data-model-item":!0,className:`w-full text-left px-3 py-1.5 text-sm transition-colors ${s===e?"bg-accent/60 font-medium":n===y?"bg-accent":"hover:bg-accent"}`,onClick:()=>{t(s),g(!1),j(!1)},children:s},s))}),h&&0===M.length&&(0,r.jsx)("div",{className:"absolute z-50 mt-1 w-full rounded-lg border border-border bg-popover shadow-lg px-3 py-2 text-xs text-muted-foreground",children:c.settings.ai.noModelsFound})]})}function s7(){let{t:e}=(0,y.Y)(),[t,s]=(0,a.useState)("panel");return(0,a.useEffect)(()=>{try{let e=localStorage.getItem("ask-mode");"popup"===e&&s("popup")}catch(e){console.warn("[AiTab] localStorage getItem ask-mode failed:",e)}},[]),(0,r.jsx)(R.L7,{icon:(0,r.jsx)(sG.A,{size:15}),title:e.settings.askDisplayMode?.label??"Display Mode",description:e.settings.askDisplayMode?.hint??"Side panel stays docked on the right. Popup opens a floating dialog.",children:(0,r.jsxs)(R.l6,{value:t,onChange:e=>(e=>{s(e);try{localStorage.setItem("ask-mode",e)}catch(e){console.warn("[AiTab] localStorage setItem ask-mode failed:",e)}window.dispatchEvent(new StorageEvent("storage",{key:"ask-mode",newValue:e}))})(e.target.value),children:[(0,r.jsx)("option",{value:"panel",children:e.settings.askDisplayMode?.panel??"Side Panel"}),(0,r.jsx)("option",{value:"popup",children:e.settings.askDisplayMode?.popup??"Popup"})]})})}var re=s(24338),rt=s(88833),rs=s(91405);let rr=[{value:"680px",label:"Narrow",width:42},{value:"780px",label:"Default",width:56},{value:"960px",label:"Wide",width:75},{value:"100%",label:"Full",width:100}],rn=[{value:"lora",label:"Lora",category:"Serif",style:{fontFamily:"Lora, Georgia, serif"}},{value:"ibm-plex-sans",label:"IBM Plex Sans",category:"Sans",style:{fontFamily:"'IBM Plex Sans', sans-serif"}},{value:"inter",label:"Inter",category:"Sans",style:{fontFamily:"var(--font-inter), sans-serif"}},{value:"ibm-plex-mono",label:"IBM Plex Mono",category:"Mono",style:{fontFamily:"'IBM Plex Mono', monospace"}}];function ra({icon:e,label:t,children:s}){return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e}),(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:t})]}),s]})}function ro({options:e,value:t,onChange:s}){return(0,r.jsx)("div",{className:"flex gap-2",children:e.map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>s(e.value),className:`flex items-center gap-1.5 px-3.5 py-2 text-sm font-medium rounded-xl transition-all ${t===e.value?"bg-[var(--amber)] text-[var(--amber-foreground)] shadow-sm":"bg-muted/50 text-muted-foreground hover:text-foreground hover:bg-muted"}`,children:[e.icon,e.label]},e.value))})}function rl({font:e,setFont:t,fontSize:s,setFontSize:n,contentWidth:o,setContentWidth:l,dark:i,setDark:d,locale:c,setLocale:u,t:m}){let[x,p]=(0,a.useState)(!1),[h,g]=(0,a.useState)(()=>localStorage.getItem("theme")??"system"),[f,b]=(0,a.useState)(()=>localStorage.getItem("locale")??"system"),v=m.settings.appearance;return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)(R.L7,{icon:(0,r.jsx)(s3.A,{size:15}),title:v.preferencesTitle??"Preferences",children:[(0,r.jsx)(ra,{icon:(0,r.jsx)(tN.A,{size:14}),label:v.colorTheme,children:(0,r.jsx)(ro,{options:[{value:"system",label:v.system,icon:(0,r.jsx)(sG.A,{size:14})},{value:"dark",label:v.dark,icon:(0,r.jsx)(sX.A,{size:14})},{value:"light",label:v.light,icon:(0,r.jsx)(tN.A,{size:14})}],value:h,onChange:e=>{g(e),localStorage.setItem("theme",e);let t="system"===e?window.matchMedia("(prefers-color-scheme: dark)").matches:"dark"===e;d(t),document.documentElement.classList.toggle("dark",t)}})}),(0,r.jsx)(ra,{icon:(0,r.jsx)(e1.A,{size:14}),label:v.language,children:(0,r.jsx)(ro,{options:[{value:"system",label:v.system,icon:(0,r.jsx)(sG.A,{size:14})},{value:"en",label:"EN"},{value:"zh",label:"中文"}],value:f,onChange:e=>{b(e),localStorage.setItem("locale",e);let t="system"===e?navigator.language.startsWith("zh")?"zh":"en":e;u(t),document.cookie=`locale=${t};path=/;max-age=31536000;SameSite=Lax`}})})]}),(0,r.jsxs)(R.L7,{icon:(0,r.jsx)(se.A,{size:15}),title:v.readingTitle??"Reading",description:v.readingDesc??"Customize how your notes look",children:[(0,r.jsx)(ra,{icon:(0,r.jsx)(re.A,{size:14}),label:v.readingFont,children:(0,r.jsx)("div",{className:"space-y-0.5",children:rn.map(s=>{let n=e===s.value;return(0,r.jsxs)("button",{type:"button",onClick:()=>t(s.value),className:`flex items-center gap-4 w-full px-3 py-2.5 rounded-lg transition-all text-left relative ${n?"bg-[var(--amber-subtle)]":"hover:bg-muted/50"}`,children:[n&&(0,r.jsx)("div",{className:"absolute left-0 top-2 bottom-2 w-[3px] rounded-r-full bg-[var(--amber)]"}),(0,r.jsx)("span",{className:`text-xl font-medium w-10 text-center shrink-0 ${n?"text-foreground":"text-muted-foreground/60"}`,style:{fontFamily:s.style.fontFamily},children:"Aa"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,r.jsx)("span",{className:`text-sm font-medium ${n?"text-foreground":"text-muted-foreground"}`,style:{fontFamily:s.style.fontFamily},children:s.label}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground/50",children:s.category})]}),(0,r.jsx)("p",{className:`text-sm truncate mt-0.5 ${n?"text-muted-foreground":"text-muted-foreground/40"}`,style:{fontFamily:s.style.fontFamily},children:v.fontPreview})]})]},s.value)})})}),(0,r.jsx)(ra,{icon:(0,r.jsx)(rt.A,{size:14}),label:v.fontSize,children:(0,r.jsxs)("div",{className:"px-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground/60 shrink-0",style:{fontSize:"11px"},children:"A"}),(0,r.jsx)("input",{type:"range",min:14,max:17,step:1,value:parseInt(s),onChange:e=>n(`${e.target.value}px`),className:"flex-1 h-1.5 rounded-full appearance-none bg-muted cursor-pointer accent-[var(--amber)] [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[var(--amber)] [&::-webkit-slider-thumb]:shadow-sm [&::-webkit-slider-thumb]:cursor-pointer [&::-webkit-slider-thumb]:transition-transform [&::-webkit-slider-thumb]:hover:scale-110 [&::-moz-range-thumb]:w-4 [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:bg-[var(--amber)] [&::-moz-range-thumb]:border-0 [&::-moz-range-thumb]:shadow-sm [&::-moz-range-thumb]:cursor-pointer"}),(0,r.jsx)("span",{className:"text-base text-muted-foreground/60 shrink-0",children:"A"})]}),(0,r.jsx)("div",{className:"text-center mt-1.5",children:(0,r.jsxs)("span",{className:"text-xs tabular-nums text-muted-foreground",children:[parseInt(s),"px"]})}),(0,r.jsx)("p",{className:"text-muted-foreground leading-relaxed mt-2 px-1",style:{fontSize:s,fontFamily:rn.find(t=>t.value===e)?.style.fontFamily},children:v.fontSizePreview})]})}),(0,r.jsx)(ra,{icon:(0,r.jsx)(rs.A,{size:14}),label:v.contentWidth,children:(0,r.jsx)("div",{className:"space-y-1",children:rr.map(e=>{let t=o===e.value;return(0,r.jsxs)("button",{type:"button",onClick:()=>l(e.value),className:`flex items-center gap-3 w-full px-3 py-2 rounded-lg transition-all ${t?"bg-[var(--amber-subtle)]":"hover:bg-muted/50"}`,children:[(0,r.jsx)("div",{className:"flex-1 h-2 rounded-full bg-muted/40 overflow-hidden",children:(0,r.jsx)("div",{className:`h-full rounded-full transition-all ${t?"bg-[var(--amber)]":"bg-muted-foreground/20"}`,style:{width:`${e.width}%`}})}),(0,r.jsx)("span",{className:`text-sm shrink-0 w-14 text-right ${t?"text-foreground font-medium":"text-muted-foreground"}`,children:e.label})]},e.value)})})})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground/40 px-0.5",children:v.browserNote}),(0,r.jsxs)("div",{className:"border-t border-border pt-4",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>p(!x),className:"flex items-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors",children:[x?(0,r.jsx)(eu.A,{size:14}):(0,r.jsx)(j.A,{size:14}),m.settings.tabs.shortcuts]}),x&&(0,r.jsx)("div",{className:"mt-3 space-y-0.5",children:m.shortcuts.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center justify-between py-1.5 px-1",children:[(0,r.jsx)("span",{className:"text-sm text-foreground",children:e.description}),(0,r.jsx)("div",{className:"flex items-center gap-1",children:e.keys.map((e,t)=>(0,r.jsx)("kbd",{className:"px-1.5 py-0.5 text-2xs font-mono bg-muted border border-border rounded text-muted-foreground",children:e},t))})]},t))})]})]})}var ri=s(8195),rd=s(9114),rc=s(25221);function ru(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<0x40000000?`${(e/1048576).toFixed(1)} MB`:`${(e/0x40000000).toFixed(2)} GB`}var rm=s(63671),rx=s(9456);function rp({data:e,setData:t,t:s}){let n=e.envOverrides??{},o=s.settings.knowledge,l=s.settings.appearance,[i,d]=(0,a.useState)(()=>"1"===localStorage.getItem("mindos:labs-echo")),[c,u]=(0,a.useState)(()=>"1"===localStorage.getItem("mindos:labs-workflows")),[m,x]=(0,a.useState)(()=>"true"===localStorage.getItem("show-hidden-files")),[p,h]=(0,a.useState)(null),[g,f]=(0,a.useState)(!1),[v,j]=(0,a.useState)(null);(0,a.useEffect)(()=>{(0,rm.D)().then(e=>h(e.files.length)).catch(e=>{console.warn("[KnowledgeTab] scanExampleFilesAction failed:",e)})},[]);let[y,N]=(0,a.useState)(null),[k,S]=(0,a.useState)(!1);(0,a.useEffect)(()=>{(0,w.n)("/api/setup").then(e=>{let t=e.guideState;t&&(N(t.active),S(!!t.dismissed))}).catch(e=>{console.error("Failed to fetch guide state:",e)})},[]);let A=(0,a.useCallback)(()=>{let e=!k;S(e);let t={dismissed:e};e||(t.active=!0),(0,w.n)("/api/setup",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({guideState:t})}).then(()=>window.dispatchEvent(new Event("guide-state-updated"))).catch(t=>{console.error("Failed to update guide state:",t),S(!e)})},[k]),E=(0,a.useCallback)(()=>{(0,w.n)("/api/setup",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({guideState:{active:!0,dismissed:!1,walkthroughStep:0,walkthroughDismissed:!1}})}).then(()=>{N(!0),S(!1),window.dispatchEvent(new Event("guide-state-updated"))}).catch(e=>console.error("Failed to restart walkthrough:",e))},[]),T=(0,a.useSyncExternalStore)(()=>()=>{},()=>`${window.location.protocol}//${window.location.hostname}`,()=>"http://localhost"),[$,M]=(0,a.useState)(!1),D="***set***"===e.webPassword,[I,L]=(0,a.useState)(!1),[P,F]=(0,a.useState)(null),[O,_]=(0,a.useState)(!1),[U,B]=(0,a.useState)(!1),W=!!e.authToken,H=P??e.authToken??"";async function K(){L(!0);try{let e=await (0,w.n)("/api/settings/reset-token",{method:"POST"});F(e.token),t(t=>t?{...t,authToken:e.token}:t)}finally{L(!1)}}async function G(){t(e=>e?{...e,authToken:""}:e),F(null)}return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)(R.L7,{icon:(0,r.jsx)(ri.A,{size:15}),title:o.cardTitle??"Knowledge Base",description:o.mindRootHint,children:[(0,r.jsx)(R.D0,{label:(0,r.jsxs)(r.Fragment,{children:[o.mindRoot," ",(0,r.jsx)(R.Bt,{overridden:n.MIND_ROOT})]}),hint:n.MIND_ROOT?o.envNote:o.mindRootHint,children:(0,r.jsx)(R.pd,{value:e.mindRoot,onChange:e=>t(t=>t?{...t,mindRoot:e.target.value}:t),placeholder:"/path/to/your/notes"})}),(0,r.jsx)(R.pM,{label:o.showHiddenFiles,hint:o.showHiddenFilesHint,children:(0,r.jsx)(R.lM,{checked:m,onChange:()=>{let e=!m;x(e),eM(e)}})}),null!==p&&p>0&&null===v&&(0,r.jsx)(R.pM,{label:o.cleanupExamples,hint:o.cleanupExamplesHint,children:(0,r.jsxs)("button",{onClick:()=>B(!0),disabled:g,title:g?s.hints.cleanupInProgress:void 0,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-lg border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors shrink-0 disabled:opacity-50",children:[g?(0,r.jsx)(C.A,{size:12,className:"animate-spin"}):(0,r.jsx)(er.A,{size:12}),o.cleanupExamplesButton,(0,r.jsx)("span",{className:"ml-1 tabular-nums text-2xs opacity-70",children:p})]})}),null!==v&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-success",children:[(0,r.jsx)(z.A,{size:14}),o.cleanupExamplesDone(v)]})]}),(0,r.jsxs)(R.L7,{icon:(0,r.jsx)(rd.A,{size:15}),title:o.securityTitle??"Security",children:[(0,r.jsx)(R.D0,{label:o.webPassword,hint:o.webPasswordHint,children:(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(R.pd,{type:$?"text":"password",value:D?"••••••••":e.webPassword??"",onChange:e=>t(t=>t?{...t,webPassword:e.target.value}:t),onFocus:()=>{D&&t(e=>e?{...e,webPassword:""}:e)},placeholder:o.passwordPlaceholder??"Leave empty to disable"}),(0,r.jsx)("button",{type:"button",onClick:()=>M(e=>!e),className:"px-3 py-2 text-sm rounded-lg border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors shrink-0",children:$?o.passwordHide??"Hide":o.passwordShow??"Show"})]})}),(0,r.jsx)(R.D0,{label:o.authToken,hint:W?o.authTokenHint:o.authTokenNone,children:(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-background border border-border rounded-lg min-h-[38px]",children:[(0,r.jsx)("code",{className:"flex-1 text-xs font-mono text-foreground break-all select-all",children:H||(0,r.jsx)("span",{className:"text-muted-foreground italic",children:o.tokenNotSet??"— not set —"})}),H&&(0,r.jsx)("button",{type:"button",onClick:function(){let t=P??e.authToken??"";t&&(0,t7.l)(t).then(e=>{e&&ek.oR.copy()})},className:"shrink-0 p-1 rounded text-muted-foreground hover:text-foreground transition-colors",title:o.authTokenCopy,children:(0,r.jsx)(ed.A,{size:13})})]}),e.mcpPort&&(0,r.jsxs)("p",{className:"text-xs text-muted-foreground",children:[o.authTokenMcpPort,": ",(0,r.jsx)("code",{className:"font-mono",children:e.mcpPort}),H&&(0,r.jsxs)(r.Fragment,{children:[" \xa0\xb7\xa0 ",o.mcpUrl??"MCP URL",": ",(0,r.jsx)("code",{className:"font-mono select-all",children:`${T}:${e.mcpPort}/mcp`})]})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)("button",{type:"button",onClick:function(){_(!0)},disabled:I,title:I?s.hints.tokenResetInProgress:void 0,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg border border-border text-muted-foreground hover:text-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:[(0,r.jsx)(b.A,{size:14,className:I?"animate-spin":""}),o.authTokenReset]}),W&&(0,r.jsxs)("button",{type:"button",onClick:G,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg border border-border text-muted-foreground hover:text-destructive hover:border-destructive/50 transition-colors",children:[(0,r.jsx)(er.A,{size:14}),o.authTokenClear]})]}),P&&(0,r.jsx)("p",{className:"text-xs text-[var(--amber-text)]",children:o.tokenGenerated})]})})]}),null!==y&&(0,r.jsxs)(R.L7,{icon:(0,r.jsx)(tL.A,{size:15}),title:s.guide?.title??"Getting Started",children:[(0,r.jsx)(R.pM,{label:s.guide?.showGuide??"Show getting started guide",children:(0,r.jsx)(R.lM,{checked:!k,onChange:()=>A()})}),(0,r.jsxs)("button",{onClick:E,className:"flex items-center gap-1.5 mt-2 px-3 py-1.5 text-sm rounded-lg border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[(0,r.jsx)(sQ.A,{size:14}),o.restartWalkthrough??"Restart walkthrough"]})]}),(0,r.jsx)(R.L7,{icon:(0,r.jsx)(rc.A,{size:15}),title:l.labsTitle??"Labs",description:l.labsDesc??"Experimental features that are still in development.",children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(rh,{label:l.labsEcho??"Echo",description:l.labsEchoDesc??"Reflective journaling powered by your notes.",checked:i,onChange:e=>{d(e),localStorage.setItem("mindos:labs-echo",e?"1":"0"),window.dispatchEvent(new Event("mindos:labs-changed"))}}),(0,r.jsx)(rh,{label:l.labsWorkflows??"Flows",description:l.labsWorkflowsDesc??"Visual workflow automation for agents.",checked:c,onChange:e=>{u(e),localStorage.setItem("mindos:labs-workflows",e?"1":"0"),window.dispatchEvent(new Event("mindos:labs-changed"))}})]})}),(0,r.jsx)(rg,{k:o}),(0,r.jsx)(ew.TM,{open:O,title:o.authTokenReset??"Regenerate Token",message:o.authTokenResetConfirm,confirmLabel:o.authTokenReset??"Regenerate",cancelLabel:o.cancel??"Cancel",onConfirm:()=>{_(!1),K()},onCancel:()=>_(!1)}),(0,r.jsx)(ew.TM,{open:U,title:o.cleanupExamples??"Cleanup Examples",message:null!==p?o.cleanupExamplesConfirm(p):"",confirmLabel:o.cleanupExamplesButton??"Clean up",cancelLabel:o.cancel??"Cancel",variant:"destructive",onConfirm:async()=>{B(!1),f(!0);let e=await (0,rx.E)();f(!1),e.success&&(j(e.deleted),h(0))},onCancel:()=>B(!1)})]})}function rh({label:e,description:t,checked:s,onChange:n}){return(0,r.jsxs)("label",{className:"flex items-center gap-3 cursor-pointer group",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-foreground block",children:e}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:t})]}),(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":s,onClick:()=>n(!s),className:`relative w-9 h-5 rounded-full transition-colors shrink-0 ${s?"bg-[var(--amber)]":"bg-muted-foreground/20"}`,children:(0,r.jsx)("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white shadow-sm transition-transform ${s?"translate-x-4":"translate-x-0"}`})})]})}function rg({k:e}){let[t,s]=(0,a.useState)(!1),[n,o]=(0,a.useState)(null),[l,i]=(0,a.useState)(!1),d=(0,a.useCallback)(async()=>{i(!0);try{let e=await (0,w.n)("/api/monitoring",{timeout:5e3});o(e)}catch{}i(!1)},[]),c=(0,a.useRef)(!1);return(0,a.useEffect)(()=>{if(!t){c.current=!1;return}c.current||(d(),c.current=!0);let e=setInterval(d,1e4);return()=>clearInterval(e)},[t,d]),(0,r.jsxs)("div",{className:"border-t border-border pt-5",children:[(0,r.jsxs)("button",{onClick:()=>s(e=>!e),className:"flex items-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors w-full",children:[t?(0,r.jsx)(eu.A,{size:14}):(0,r.jsx)(j.A,{size:14}),(0,r.jsx)(sM.A,{size:12}),e.monitoringTitle??"System Monitoring",l&&(0,r.jsx)(C.A,{size:10,className:"animate-spin ml-1"})]}),t&&n&&(0,r.jsxs)("div",{className:"mt-3 grid grid-cols-2 gap-x-6 gap-y-2 text-xs",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.monitorHeap??"Heap"}),(0,r.jsxs)("span",{className:"ml-2 tabular-nums",children:[ru(n.system.memory.heapUsed)," / ",ru(n.system.memory.heapTotal)]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.monitorRss??"RSS"}),(0,r.jsx)("span",{className:"ml-2 tabular-nums",children:ru(n.system.memory.rss)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.monitorUptime??"Uptime"}),(0,r.jsx)("span",{className:"ml-2 tabular-nums",children:function(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let s=Math.floor(t/60);if(s<60)return`${s}m ${t%60}s`;let r=Math.floor(s/60);if(r<24)return`${r}h ${s%60}m`;let n=Math.floor(r/24);return`${n}d ${r%24}h`}(n.system.uptimeMs)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.monitorNode??"Node"}),(0,r.jsx)("span",{className:"ml-2",children:n.system.nodeVersion})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.monitorRequests??"Requests"}),(0,r.jsx)("span",{className:"ml-2 tabular-nums",children:n.application.agentRequests})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.monitorToolCalls??"Tool Calls"}),(0,r.jsx)("span",{className:"ml-2 tabular-nums",children:n.application.toolExecutions})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.monitorTokens??"Tokens"}),(0,r.jsx)("span",{className:"ml-2 tabular-nums",children:(n.application.totalTokens.input+n.application.totalTokens.output).toLocaleString()})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.monitorFiles??"Files"}),(0,r.jsxs)("span",{className:"ml-2 tabular-nums",children:[n.knowledgeBase.fileCount," (",ru(n.knowledgeBase.totalSizeBytes),")"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"MCP"}),(0,r.jsx)("span",{className:"ml-2",children:n.mcp.running?e.monitorMcpRunning?.(n.mcp.port)??`Running :${n.mcp.port}`:e.monitorMcpStopped??"Stopped"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.monitorErrors??"Errors"}),(0,r.jsx)("span",{className:"ml-2 tabular-nums",children:n.application.errors})]})]}),t&&!n&&!l&&(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:e.monitoringFailed??"Failed to load monitoring data"})]})}var rf=s(10762),rb=s(439),rv=s(7810),rj=s(27996);function ry({agents:e,t,onRefresh:s,mode:n="mcp",activeSkillName:o="mindos"}){let l=t.settings?.mcp,[i,d]=(0,a.useState)(new Set),[c,u]=(0,a.useState)("auto"),[m,x]=(0,a.useState)("http://localhost:8781/mcp"),[p,h]=(0,a.useState)(""),[g,f]=(0,a.useState)({}),[b,v]=(0,a.useState)(!1),[j,y]=(0,a.useState)(null),k=async()=>{if(0!==i.size){v(!0),y(null);try{let t={agents:[...i].map(t=>{let s=e.find(e=>e.key===t),r="auto"===c?s?.preferredTransport||"stdio":c;return{key:t,scope:g[t]||(s?.hasProjectScope?"project":"global"),transport:r}}),transport:c,..."http"===c?{url:m,token:p}:{},..."auto"===c?{url:m,token:p}:{}},r=await (0,w.n)("/api/mcp/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),n=r.results.filter(e=>"ok"===e.status).length,a=r.results.filter(e=>"error"===e.status);a.length>0?y({type:"error",text:a.map(e=>`${e.agent}: ${e.message}`).join("; ")}):y({type:"success",text:l?.installSuccess?l.installSuccess(n):`${n} agent(s) configured`}),d(new Set),s()}catch{y({type:"error",text:l?.installFailed??"Install failed"})}finally{v(!1),setTimeout(()=>y(null),4e3)}}},A="http"===c||"auto"===c&&[...i].some(t=>{let s=e.find(e=>e.key===t);return s?.preferredTransport==="http"});return"cli"===n?(0,r.jsx)(rN,{agents:e,m:l,activeSkillName:o}):(0,r.jsxs)("div",{className:"space-y-3 pt-2",children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:l?.mcpInstallDesc??"Install MCP config + Skill to detected agents on this machine."}),(0,r.jsx)("div",{className:"space-y-1",children:e.map(e=>(0,r.jsxs)("div",{className:"flex items-center gap-3 py-1.5 text-sm",children:[(0,r.jsx)("input",{type:"checkbox",checked:i.has(e.key),onChange:()=>{var t;return t=e.key,void d(e=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s})},className:"form-check"}),(0,r.jsx)("span",{className:"w-28 shrink-0 text-xs",children:e.name}),(0,r.jsx)("span",{className:"text-2xs px-1.5 py-0.5 rounded font-mono bg-muted",children:"auto"===c?e.preferredTransport:c}),e.installed?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-2xs px-1.5 py-0.5 rounded bg-success/15 text-success font-mono",children:e.transport}),(0,r.jsx)("span",{className:"text-2xs text-muted-foreground",children:e.scope})]}):(0,r.jsx)("span",{className:"text-2xs text-muted-foreground",children:e.present?l?.detected??"Detected":l?.notFound??"Not found"}),i.has(e.key)&&e.hasProjectScope&&e.hasGlobalScope&&(0,r.jsx)(rj.A,{value:g[e.key]||"project",onChange:t=>f({...g,[e.key]:t}),size:"sm",className:"ml-auto",options:[{value:"project",label:l?.project??"Project"},{value:"global",label:l?.global??"Global"}]})]},e.key))}),(0,r.jsxs)("div",{className:"flex gap-2 text-xs pt-1",children:[(0,r.jsx)("button",{type:"button",onClick:()=>d(new Set(e.filter(e=>!e.installed&&e.present).map(e=>e.key))),className:"px-2.5 py-1 rounded-md border border-[var(--amber)] text-[var(--amber)] transition-colors hover:bg-muted/50",children:l?.selectDetected??"Select Detected"}),(0,r.jsx)("button",{type:"button",onClick:()=>d(new Set),className:"px-2.5 py-1 rounded-md border border-border text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",children:l?.clearSelection??"Clear"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-4 text-xs pt-1",children:[(0,r.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[(0,r.jsx)("input",{type:"radio",name:"transport",checked:"auto"===c,onChange:()=>u("auto"),className:"form-radio"}),l?.transportAuto??"auto (recommended)"]}),(0,r.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[(0,r.jsx)("input",{type:"radio",name:"transport",checked:"stdio"===c,onChange:()=>u("stdio"),className:"form-radio"}),l?.transportStdio??"stdio"]}),(0,r.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[(0,r.jsx)("input",{type:"radio",name:"transport",checked:"http"===c,onChange:()=>u("http"),className:"form-radio"}),l?.transportHttp??"http"]})]}),A&&(0,r.jsxs)("div",{className:"space-y-2 pl-5 text-xs",children:[(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("label",{className:"text-muted-foreground",children:l?.httpUrl??"MCP URL"}),(0,r.jsx)("input",{type:"text",value:m,onChange:e=>x(e.target.value),className:"w-full px-2.5 py-1.5 text-xs rounded-md border border-border bg-background font-mono text-foreground outline-none focus-visible:ring-1 focus-visible:ring-ring"})]}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("label",{className:"text-muted-foreground",children:l?.httpToken??"Auth Token"}),(0,r.jsx)("input",{type:"password",value:p,onChange:e=>h(e.target.value),placeholder:"Bearer token",className:"w-full px-2.5 py-1.5 text-xs rounded-md border border-border bg-background font-mono text-foreground outline-none focus-visible:ring-1 focus-visible:ring-ring"})]})]}),(0,r.jsxs)("button",{onClick:k,disabled:0===i.size||b,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-lg transition-colors disabled:opacity-40 disabled:cursor-not-allowed bg-[var(--amber)] text-[var(--amber-foreground)]",children:[b&&(0,r.jsx)(C.A,{size:12,className:"animate-spin"}),b?l?.installing??"Installing...":l?.installSelected??"Install Selected"]}),j&&(0,r.jsx)("div",{className:"flex items-center gap-1.5 text-xs",role:"status",children:"success"===j.type?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(N.A,{size:12,className:"text-success"}),(0,r.jsx)("span",{className:"text-success",children:j.text})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(S.A,{size:12,className:"text-destructive"}),(0,r.jsx)("span",{className:"text-destructive",children:j.text})]})})]})}function rN({agents:e,m:t,activeSkillName:s}){let[n,o]=(0,a.useState)(e[0]?.key??"claude-code"),l=e.find(e=>e.key===n),i=`npx skills add GeminiLight/MindOS --skill ${s} -a ${n} -g -y`,d=async()=>{await (0,t7.l)(i)&&ek.oR.copy()},c=e.filter(e=>e.present&&e.installed),u=e.filter(e=>e.present&&!e.installed),m=e.filter(e=>!e.present);return(0,r.jsxs)("div",{className:"space-y-3 pt-2",children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:t?.cliInstallDesc??"Install the MindOS Skill to your agent so it can operate your knowledge base."}),(0,r.jsx)(rj.A,{value:n,onChange:o,size:"sm",options:[...c.length>0?[{label:t?.connectedGroup??"Connected",options:c.map(e=>({value:e.key,label:e.name}))}]:[],...u.length>0?[{label:t?.detectedGroup??"Detected",options:u.map(e=>({value:e.key,label:e.name}))}]:[],...m.length>0?[{label:t?.notFoundGroup??"Not Installed",options:m.map(e=>({value:e.key,label:e.name}))}]:[]]}),l&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-2xs",children:[l.present&&l.installed?(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full font-medium bg-success/10 text-success",children:[(0,r.jsx)(N.A,{size:10})," ",t?.tagConnected??"Connected"]}):l.present?(0,r.jsx)("span",{className:"text-muted-foreground",children:t?.detected??"Detected"}):(0,r.jsx)("span",{className:"text-muted-foreground",children:t?.notFound??"Not found"}),null!=l.installedSkillCount&&l.installedSkillCount>0&&(0,r.jsxs)("span",{className:"text-muted-foreground",children:[l.installedSkillCount," ",t?.skillsInstalled??"skills installed"]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("code",{className:"flex-1 text-[10px] font-mono bg-muted/50 border border-border rounded-lg px-2.5 py-2 text-muted-foreground select-all overflow-x-auto whitespace-nowrap",children:i}),(0,r.jsx)("button",{onClick:d,className:"p-1.5 rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors shrink-0",children:(0,r.jsx)(ed.A,{size:11})})]})]})}var rk=s(37206);let rw=(0,rk.default)(()=>Promise.all([s.e(3013),s.e(3637)]).then(s.bind(s,63637)),{loadableGenerated:{webpack:()=>[63637]},ssr:!1});function rS({skill:e,expanded:t,onExpand:s,onToggle:n,onDelete:a,onEditStart:o,onEditSave:l,onEditCancel:i,editing:d,editContent:c,setEditContent:u,editError:m,saving:x,fullContent:p,loadingContent:h,loadErrors:g,m:f}){return(0,r.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>s(e.name),children:[t?(0,r.jsx)(eu.A,{size:12}):(0,r.jsx)(j.A,{size:12}),(0,r.jsx)("span",{className:"text-xs font-medium flex-1",children:e.name}),(0,r.jsx)("span",{className:`text-2xs px-1.5 py-0.5 rounded ${"builtin"===e.source?"bg-muted text-muted-foreground":"bg-[var(--amber-subtle)] text-[var(--amber-text)]"}`,children:"builtin"===e.source?f?.skillBuiltin??"Built-in":f?.skillUser??"Custom"}),(0,r.jsx)(R.lM,{size:"sm",checked:e.enabled,onClick:t=>{t.stopPropagation(),n(e.name,!e.enabled)}})]}),t&&(0,r.jsxs)("div",{className:"px-3 py-2 border-t border-border text-xs space-y-2 bg-muted/20",children:[(0,r.jsx)("p",{className:"text-muted-foreground",children:e.description||"No description"}),(0,r.jsx)("p",{className:"text-muted-foreground font-mono text-2xs",children:e.path}),h===e.name?(0,r.jsxs)("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,r.jsx)(C.A,{size:10,className:"animate-spin"}),(0,r.jsx)("span",{className:"text-2xs",children:"Loading..."})]}):p[e.name]?(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-2xs text-muted-foreground font-medium",children:f?.skillContent??"Content"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[e.editable&&d!==e.name&&(0,r.jsxs)("button",{onClick:()=>o(e.name),className:"flex items-center gap-1 text-2xs text-muted-foreground hover:text-foreground transition-colors",children:[(0,r.jsx)(ec.A,{size:10}),f?.editSkill??"Edit"]}),e.editable&&(0,r.jsxs)("button",{onClick:()=>a(e.name),className:"flex items-center gap-1 text-2xs text-destructive hover:underline",children:[(0,r.jsx)(er.A,{size:10}),f?.deleteSkill??"Delete"]})]})]}),d===e.name?(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)("textarea",{value:c,onChange:e=>u(e.target.value),rows:Math.min(20,(c.match(/\n/g)||[]).length+3),className:"w-full px-2.5 py-1.5 text-xs rounded-md border border-border bg-background text-foreground outline-none focus-visible:ring-1 focus-visible:ring-ring resize-y font-mono"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("button",{onClick:()=>l(e.name),disabled:x,className:"flex items-center gap-1 px-2.5 py-1 text-xs rounded-md disabled:opacity-40 disabled:cursor-not-allowed transition-colors bg-[var(--amber)] text-[var(--amber-foreground)]",children:[x&&(0,r.jsx)(C.A,{size:10,className:"animate-spin"}),f?.saveSkill??"Save"]}),(0,r.jsx)("button",{onClick:i,className:"px-2.5 py-1 text-xs rounded-md border border-border text-muted-foreground hover:text-foreground transition-colors",children:f?.cancelSkill??"Cancel"})]}),m&&(0,r.jsxs)("p",{className:"text-2xs text-destructive flex items-center gap-1",children:[(0,r.jsx)(S.A,{size:10}),m]})]}):(0,r.jsx)("div",{className:"w-full rounded-md border border-border bg-background/50 max-h-[300px] overflow-y-auto px-2.5 py-1.5 text-xs [&_.prose]:max-w-none [&_.prose]:text-xs [&_h1]:text-sm [&_h2]:text-xs [&_h3]:text-xs [&_pre]:text-2xs [&_code]:text-2xs",children:(0,r.jsx)(rw,{content:function(e){if(!e.startsWith("---"))return e;let t=e.indexOf("\n---",3);return -1===t?e:e.slice(t+4).replace(/^\n+/,"")}(p[e.name])})})]}):g[e.name]?(0,r.jsxs)("p",{className:"text-2xs text-destructive flex items-center gap-1",children:[(0,r.jsx)(S.A,{size:10}),g[e.name]]}):null]})]})}let rC=e=>`---
|
|
85
|
-
name: ${e}
|
|
86
|
-
description: >
|
|
87
|
-
Describe WHEN the agent should use this
|
|
88
|
-
skill. Be specific about trigger conditions.
|
|
89
|
-
---`,rA={general:e=>`${rC(e)}
|
|
90
|
-
|
|
91
|
-
# Instructions
|
|
92
|
-
|
|
93
|
-
## Context
|
|
94
|
-
<!-- Background knowledge for the agent -->
|
|
95
|
-
|
|
96
|
-
## Steps
|
|
97
|
-
1.
|
|
98
|
-
2.
|
|
99
|
-
|
|
100
|
-
## Rules
|
|
101
|
-
<!-- Constraints, edge cases, formats -->
|
|
102
|
-
- `,"tool-use":e=>`${rC(e)}
|
|
103
|
-
|
|
104
|
-
# Instructions
|
|
105
|
-
|
|
106
|
-
## Available Tools
|
|
107
|
-
<!-- List tools the agent can use -->
|
|
108
|
-
-
|
|
109
|
-
|
|
110
|
-
## When to Use
|
|
111
|
-
<!-- Conditions that trigger this skill -->
|
|
112
|
-
|
|
113
|
-
## Output Format
|
|
114
|
-
<!-- Expected response structure -->
|
|
115
|
-
`,workflow:e=>`${rC(e)}
|
|
116
|
-
|
|
117
|
-
# Instructions
|
|
118
|
-
|
|
119
|
-
## Trigger
|
|
120
|
-
<!-- What triggers this workflow -->
|
|
121
|
-
|
|
122
|
-
## Steps
|
|
123
|
-
1.
|
|
124
|
-
2.
|
|
125
|
-
|
|
126
|
-
## Validation
|
|
127
|
-
<!-- How to verify success -->
|
|
128
|
-
|
|
129
|
-
## Rollback
|
|
130
|
-
<!-- What to do on failure -->
|
|
131
|
-
`};function rz({onSave:e,onCancel:t,saving:s,error:n,m:o}){let[l,i]=(0,a.useState)(""),[d,c]=(0,a.useState)(""),[m,x]=(0,a.useState)("general"),p=(e,t)=>(rA[t||m]||rA.general)(e||"my-skill");return(0,r.jsxs)("div",{className:"border border-border rounded-lg p-3 space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs font-medium",children:o?.addSkill??"+ Add Skill"}),(0,r.jsx)("button",{onClick:t,className:"p-0.5 rounded hover:bg-muted text-muted-foreground",children:(0,r.jsx)(u.A,{size:12})})]}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("label",{className:"text-2xs text-muted-foreground",children:o?.skillName??"Name"}),(0,r.jsx)("input",{type:"text",value:l,onChange:e=>{let t,s;return t=e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,""),s=p(l||"my-skill"),void((!d||d===s)&&c(p(t||"my-skill")),i(t))},placeholder:"my-skill",className:"w-full px-2.5 py-1.5 text-xs rounded-md border border-border bg-background font-mono text-foreground outline-none focus-visible:ring-1 focus-visible:ring-ring"})]}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("label",{className:"text-2xs text-muted-foreground",children:o?.skillTemplate??"Template"}),(0,r.jsx)("div",{className:"flex rounded-md border border-border overflow-hidden w-fit",children:["general","tool-use","workflow"].map((e,t)=>(0,r.jsx)("button",{onClick:()=>{let t;return t=p(l||"my-skill",m),void(x(e),(!d||d===t)&&c(p(l||"my-skill",e)))},className:`px-2.5 py-1 text-xs transition-colors ${t>0?"border-l border-border":""} ${m===e?"bg-[var(--amber-subtle)] text-[var(--amber-text)] font-medium":"text-muted-foreground hover:bg-muted"}`,children:"general"===e?o?.skillTemplateGeneral??"General":"tool-use"===e?o?.skillTemplateToolUse??"Tool-use":o?.skillTemplateWorkflow??"Workflow"},e))})]}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("label",{className:"text-2xs text-muted-foreground",children:o?.skillContent??"Content"}),(0,r.jsx)("textarea",{value:d||p(l||"my-skill"),onChange:e=>c(e.target.value),rows:16,placeholder:"Skill instructions (markdown)...",className:"w-full px-2.5 py-1.5 text-xs rounded-md border border-border bg-background text-foreground outline-none focus-visible:ring-1 focus-visible:ring-ring resize-y font-mono"})]}),n&&(0,r.jsxs)("p",{className:"text-2xs text-destructive flex items-center gap-1",children:[(0,r.jsx)(S.A,{size:10}),n]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("button",{onClick:()=>e(l.trim(),d||p(l.trim()||"my-skill")),disabled:!l.trim()||s,className:"flex items-center gap-1 px-2.5 py-1 text-xs rounded-md disabled:opacity-40 disabled:cursor-not-allowed transition-colors bg-[var(--amber)] text-[var(--amber-foreground)]",children:[s&&(0,r.jsx)(C.A,{size:10,className:"animate-spin"}),o?.saveSkill??"Save"]}),(0,r.jsx)("button",{onClick:t,className:"px-2.5 py-1 text-xs rounded-md border border-border text-muted-foreground hover:text-foreground transition-colors",children:o?.cancelSkill??"Cancel"})]})]})}function rE({t:e}){let t,s,n=e.settings?.mcp,o=(0,e2.cd)(),[l,i]=(0,a.useState)([]),[c,m]=(0,a.useState)(!0),[x,p]=(0,a.useState)(null),[h,g]=(0,a.useState)(!1),[f,b]=(0,a.useState)(!1),[v,y]=(0,a.useState)(""),[N,k]=(0,a.useState)(""),[S,A]=(0,a.useState)(!0),[z,E]=(0,a.useState)(null),[T,$]=(0,a.useState)(""),[R,M]=(0,a.useState)(""),[D,I]=(0,a.useState)({}),[L,P]=(0,a.useState)(null),[F,O]=(0,a.useState)({}),[_,U]=(0,a.useState)(!1),[B,W]=(0,a.useState)(null),H=(0,a.useCallback)(async()=>{try{let e=await (0,w.n)("/api/skills");i(e.skills),O({})}catch(t){let e=t instanceof Error?t.message:"Failed to load skills";console.error("fetchSkills error:",e),O(t=>({...t,_root:e}))}m(!1)},[]);(0,a.useEffect)(()=>{H()},[H]);let K=(0,a.useMemo)(()=>{if(!N)return l;let e=N.toLowerCase();return l.filter(t=>t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e))},[l,N]),G=(0,a.useMemo)(()=>K.filter(e=>"user"===e.source),[K]),Y=(0,a.useMemo)(()=>K.filter(e=>"builtin"===e.source),[K]),J=async(e,t)=>{if(o){await o.toggleSkill(e,t),i(s=>s.map(s=>s.name===e?{...s,enabled:t}:s));return}try{await (0,w.n)("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"toggle",name:e,enabled:t})}),i(s=>s.map(s=>s.name===e?{...s,enabled:t}:s)),O(t=>{let s={...t};return delete s[e],s})}catch(s){let t=s instanceof Error?s.message:"Failed to toggle skill";console.error("handleToggle error:",t),O(s=>({...s,[e]:t}))}},q=e=>{W(e)},Z=async e=>{try{await (0,w.n)("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"delete",name:e})}),I(t=>{let s={...t};return delete s[e],s}),z===e&&E(null),x===e&&p(null),O(t=>{let s={...t};return delete s[e],s}),H(),window.dispatchEvent(new Event("mindos:skills-changed"))}catch(s){let t=s instanceof Error?s.message:"Failed to delete skill";console.error("handleDelete error:",t),O(s=>({...s,[e]:t}))}},Q=async e=>{if(!D[e]){P(e);try{let t=await (0,w.n)("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"read",name:e})});I(s=>({...s,[e]:t.content})),O(t=>{let s={...t};return delete s[e],s})}catch(t){O(s=>({...s,[e]:t instanceof Error?t.message:"Failed to load skill content"}))}finally{P(null)}}},X=e=>{let t=x===e?null:e;p(t),t&&Q(e),z&&z!==e&&E(null)},ee=e=>{E(e),$(D[e]||""),M("")},et=async e=>{b(!0),M("");try{await (0,w.n)("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"update",name:e,content:T})}),I(t=>({...t,[e]:T})),E(null),H(),window.dispatchEvent(new Event("mindos:skills-changed"))}catch(e){M(e instanceof Error?e.message:"Failed to save skill")}finally{b(!1)}},es=()=>{E(null),$(""),M("")},er=async(e,t)=>{if(e){b(!0),y("");try{await (0,w.n)("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"create",name:e,content:t})}),g(!1),H(),window.dispatchEvent(new Event("mindos:skills-changed"))}catch(e){y(e instanceof Error?e.message:"Failed to create skill")}finally{b(!1)}}};return c?(0,r.jsx)("div",{className:"flex justify-center py-4",children:(0,r.jsx)(C.A,{size:16,className:"animate-spin text-muted-foreground"})}):(0,r.jsxs)("div",{className:"space-y-3 pt-2",children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(d.A,{size:12,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),(0,r.jsx)("input",{type:"text",value:N,onChange:e=>k(e.target.value),placeholder:n?.searchSkills??"Search skills...",className:"w-full pl-7 pr-2.5 py-1.5 text-xs rounded-md border border-border bg-background text-foreground outline-none focus-visible:ring-1 focus-visible:ring-ring"}),N&&(0,r.jsx)("button",{onClick:()=>k(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:(0,r.jsx)(u.A,{size:10})})]}),(t=l.find(e=>"mindos"===e.name)?.enabled??!0?"en":"zh",s=async e=>{if(e!==t&&!_){U(!0);try{"en"===e?(await J("mindos",!0),await J("mindos-zh",!1)):(await J("mindos-zh",!0),await J("mindos",!1))}catch(e){console.error("Lang switch failed:",e)}finally{U(!1)}}},(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:n?.skillLanguage??"Skill Language"}),(0,r.jsxs)("div",{className:"flex rounded-md border border-border overflow-hidden",children:[(0,r.jsx)("button",{onClick:()=>s("en"),disabled:_,className:`px-2.5 py-1 text-xs transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${"en"===t?"bg-[var(--amber-subtle)] text-[var(--amber-text)] font-medium":"text-muted-foreground hover:bg-muted"}`,children:n?.skillLangEn??"English"}),(0,r.jsx)("button",{onClick:()=>s("zh"),disabled:_,className:`px-2.5 py-1 text-xs transition-colors disabled:opacity-50 disabled:cursor-not-allowed border-l border-border ${"zh"===t?"bg-[var(--amber-subtle)] text-[var(--amber-text)] font-medium":"text-muted-foreground hover:bg-muted"}`,children:n?.skillLangZh??"中文"})]})]})),0===K.length&&N&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground text-center py-3",children:n?.noSkillsMatch?n.noSkillsMatch(N):`No skills match "${N}"`}),G.length>0&&(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground",children:(0,r.jsxs)("span",{children:[n?.customGroup??"Custom"," (",G.length,")"]})}),(0,r.jsx)("div",{className:"space-y-1.5",children:G.map(e=>(0,r.jsx)(rS,{skill:e,expanded:x===e.name,onExpand:X,onToggle:J,onDelete:q,onEditStart:ee,onEditSave:et,onEditCancel:es,editing:z,editContent:T,setEditContent:$,editError:R,saving:f,fullContent:D,loadingContent:L,loadErrors:F,m:n},e.name))})]}),Y.length>0&&(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground cursor-pointer hover:text-foreground transition-colors",onClick:()=>A(!S),children:[S?(0,r.jsx)(j.A,{size:12}):(0,r.jsx)(eu.A,{size:12}),(0,r.jsxs)("span",{children:[n?.builtinGroup??"Built-in"," (",Y.length,")"]})]}),!S&&(0,r.jsx)("div",{className:"space-y-1.5",children:Y.map(e=>(0,r.jsx)(rS,{skill:e,expanded:x===e.name,onExpand:X,onToggle:J,onDelete:q,onEditStart:ee,onEditSave:et,onEditCancel:es,editing:z,editContent:T,setEditContent:$,editError:R,saving:f,fullContent:D,loadingContent:L,loadErrors:F,m:n},e.name))})]}),h?(0,r.jsx)(rz,{onSave:er,onCancel:()=>{g(!1),y("")},saving:f,error:v,m:n}):(0,r.jsxs)("button",{onClick:()=>g(!0),className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[(0,r.jsx)(V.A,{size:12}),n?.addSkill??"+ Add Skill"]}),(0,r.jsx)(rT,{agents:o?.agents??[],skillName:l.find(e=>"mindos"===e.name)?.enabled??!0?"mindos":"mindos-zh",m:n}),(0,r.jsx)(ew.TM,{open:!!B,title:"Delete skill?",message:B?n?.skillDeleteConfirm?.(B)??`Delete skill "${B}"?`:"",confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:async()=>{W(null),await Z(B)},onCancel:()=>W(null)})]})}function rT({agents:e,skillName:t,m:s}){let[n,o]=(0,a.useState)("claude-code"),l=`npx skills add GeminiLight/MindOS --skill ${t} -a ${n} -g -y`,i=`~/.agents/skills/${t}/SKILL.md`,d=async()=>{await (0,t7.l)(l)&&ek.oR.copy()},c=e.filter(e=>e.present&&e.installed),u=e.filter(e=>e.present&&!e.installed),m=e.filter(e=>!e.present);return(0,r.jsxs)("div",{className:"border-t border-border pt-3 mt-3 space-y-2.5",children:[(0,r.jsx)("p",{className:"text-2xs font-medium text-muted-foreground",children:s?.cliInstallHint??"Install via CLI:"}),(0,r.jsx)(rj.A,{value:n,onChange:o,size:"sm",options:[...c.length>0?[{label:s?.connectedGroup??"Connected",options:c.map(e=>({value:e.key,label:e.name}))}]:[],...u.length>0?[{label:s?.detectedGroup??"Detected",options:u.map(e=>({value:e.key,label:e.name}))}]:[],...m.length>0?[{label:s?.notFoundGroup??"Not Installed",options:m.map(e=>({value:e.key,label:e.name}))}]:[]]}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("code",{className:"flex-1 text-[10px] font-mono bg-muted/50 border border-border rounded-lg px-2.5 py-2 text-muted-foreground select-all overflow-x-auto whitespace-nowrap",children:l}),(0,r.jsx)("button",{onClick:d,className:"p-1.5 rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors shrink-0",children:(0,r.jsx)(ed.A,{size:11})})]}),(0,r.jsxs)("p",{className:"text-2xs text-muted-foreground",children:[s?.skillPathHint??"Skill files installed at:"," ",(0,r.jsx)("code",{className:"font-mono text-[10px] bg-muted px-1 py-0.5 rounded",children:i})]})]})}function r$({t:e}){let t=(0,e2.cd)(),s=e.settings?.mcp,[n,o]=(0,a.useState)("cli"),[l,i]=(0,a.useState)(!1),[d,c]=(0,a.useState)(""),[u,m]=(0,a.useState)(!1),x=(0,a.useRef)(void 0),p=t?.status?.connectionMode,h=p?.mcp??!1;if((0,a.useEffect)(()=>()=>clearInterval(x.current),[]),!t||t.loading)return(0,r.jsx)("div",{className:"flex justify-center py-8",children:(0,r.jsx)(C.A,{size:18,className:"animate-spin text-muted-foreground"})});let g=t.agents.filter(e=>e.present&&e.installed),f=t.agents.filter(e=>e.present&&!e.installed),b=t.agents.filter(e=>!e.present),v=d||(t.agents[0]?.key??""),j=t.agents.find(e=>e.key===v),y=t.skills?.find(e=>"mindos"===e.name)?.enabled??!0,N=async e=>{m(!0);try{await (0,w.n)("/api/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({connectionMode:{cli:!0,mcp:e}})}),await t.refresh(),e&&o("mcp")}catch{ek.oR.error("Failed to toggle connection mode")}finally{m(!1)}},k=async()=>{i(!0);try{await (0,w.n)("/api/mcp/restart",{method:"POST"})}catch(e){console.error("[McpTab] Restart request failed:",e),i(!1);return}let e=Date.now()+6e4;clearInterval(x.current),x.current=setInterval(async()=>{if(Date.now()>e){clearInterval(x.current),i(!1);return}try{(await (0,w.n)("/api/mcp/status",{timeout:3e3})).running&&(clearInterval(x.current),i(!1),t.refresh())}catch{}},3e3)};return(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)(rR,{mcpEnabled:h,onToggle:N,saving:u,mcpRunning:t.status?.running??!1,m:s}),(0,r.jsx)(rM,{status:t.status,m:s}),(0,r.jsx)(rI,{mode:n,onModeChange:o,status:t.status,agents:t.agents,connectedAgents:g,detectedAgents:f,notFoundAgents:b,currentAgent:j??null,selectedAgent:v,onSelectAgent:c,restarting:l,onRestart:k,onRefresh:t.refresh,activeSkillName:y?"mindos":"mindos-zh",mcpEnabled:h,m:s,t:e}),(0,r.jsxs)("div",{className:"rounded-xl border border-border bg-card overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2.5 px-4 pt-4 pb-3",children:[(0,r.jsx)("div",{className:"w-7 h-7 rounded-lg bg-muted flex items-center justify-center shrink-0",children:(0,r.jsx)(tL.A,{size:14,className:"text-muted-foreground"})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:s?.skillsTitle??"Skills"}),(0,r.jsx)("p",{className:"text-2xs text-muted-foreground",children:s?.skillsDesc??"Teach agents how to operate your knowledge base."})]})]}),(0,r.jsx)("div",{className:"px-4 pb-4",children:(0,r.jsx)(rE,{t:e})})]})]})}function rR({mcpEnabled:e,onToggle:t,saving:s,mcpRunning:n,m:a}){return(0,r.jsxs)("div",{className:"rounded-xl border border-border bg-card overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2.5 px-4 pt-4 pb-3",children:[(0,r.jsx)("div",{className:"w-7 h-7 rounded-lg bg-[var(--amber-subtle)] flex items-center justify-center shrink-0",children:(0,r.jsx)(s5.A,{size:14,className:"text-[var(--amber)]"})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:a?.modeCardTitle??"Connection Mode"}),(0,r.jsx)("p",{className:"text-2xs text-muted-foreground",children:a?.modeCardDesc??"Choose how agents connect to MindOS."})]})]}),(0,r.jsxs)("div",{className:"px-4 pb-4 space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-lg bg-muted/30 border border-border/50",children:[(0,r.jsx)("input",{type:"checkbox",checked:!0,disabled:!0,className:"w-3.5 h-3.5 rounded accent-[var(--amber)]"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)(rf.A,{size:12,className:"text-muted-foreground"}),(0,r.jsx)("span",{className:"text-xs font-semibold text-foreground",children:"CLI"}),(0,r.jsx)("span",{className:"text-2xs px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium leading-none",children:a?.alwaysOn??"Always On"})]}),(0,r.jsx)("p",{className:"text-2xs text-muted-foreground mt-0.5",children:a?.cliModeDesc??"Claude Code, Gemini CLI, Codex, etc."})]})]}),(0,r.jsxs)("label",{className:`flex items-center gap-3 px-3 py-2.5 rounded-lg border cursor-pointer transition-colors ${e?"border-[var(--amber)]/40 bg-[var(--amber)]/[0.03]":"border-border/50 bg-muted/30 hover:bg-muted/50"}`,children:[(0,r.jsx)("input",{type:"checkbox",checked:e,disabled:s,onChange:e=>t(e.target.checked),className:"w-3.5 h-3.5 rounded accent-[var(--amber)] cursor-pointer"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)(s5.A,{size:12,className:e?"text-[var(--amber)]":"text-muted-foreground"}),(0,r.jsx)("span",{className:"text-xs font-semibold text-foreground",children:"MCP"}),e&&(0,r.jsx)("span",{className:`text-2xs px-1.5 py-0.5 rounded-full font-medium leading-none ${n?"bg-success/10 text-success":"bg-[var(--amber-subtle)] text-[var(--amber-text)]"}`,children:n?a?.mcpRunning??"Running":a?.mcpStopped??"Stopped"})]}),(0,r.jsx)("p",{className:"text-2xs text-muted-foreground mt-0.5",children:a?.mcpModeDesc??"Claude Desktop, Cursor, Windsurf, etc."})]}),s&&(0,r.jsx)(C.A,{size:14,className:"animate-spin text-[var(--amber)] shrink-0"})]}),(0,r.jsx)("p",{className:"text-2xs text-muted-foreground px-1 leading-relaxed",children:e?a?.mcpEnabledHint??"MCP mode enabled. Disable to simplify the interface if you only use CLI agents.":a?.mcpDisabledHint??"Enable MCP to connect Desktop clients like Claude Desktop or Cursor."})]})]})}function rM({status:e,m:t}){let[s,n]=(0,a.useState)(null),[o,l]=(0,a.useState)(!1);(0,a.useEffect)(()=>()=>l(!1),[]),(0,a.useEffect)(()=>{if(!s)return;let e=setTimeout(()=>n(null),2e3);return()=>clearTimeout(e)},[s]);let i=(0,a.useCallback)(async(e,t)=>{!e||await (0,t7.l)(e)&&(n(t),ek.oR.copy())},[]);if(!e)return null;let d=e.authConfigured&&!!e.authToken,c=o?e.authToken??"":e.maskedToken??"";return(0,r.jsxs)("div",{className:"rounded-xl border border-border bg-card overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2.5 px-4 pt-4 pb-3",children:[(0,r.jsx)("div",{className:"w-7 h-7 rounded-lg bg-muted flex items-center justify-center shrink-0",children:(0,r.jsx)(rb.A,{size:14,className:"text-muted-foreground"})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:t?.tokenCardTitle??"Auth Token"}),(0,r.jsx)("p",{className:"text-2xs text-muted-foreground",children:t?.tokenCardDesc??"Used by CLI remote mode and MCP connections."})]})]}),(0,r.jsx)("div",{className:"px-4 pb-4",children:d?(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"flex-1 flex items-center gap-2 px-2.5 py-1.5 bg-muted/50 border border-border rounded-lg min-h-[34px]",children:(0,r.jsx)("code",{className:"flex-1 text-xs font-mono text-foreground break-all select-all leading-relaxed",children:c})}),(0,r.jsx)("button",{type:"button",onClick:()=>l(e=>!e),className:"shrink-0 p-1.5 rounded-lg border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors focus-visible:ring-2 focus-visible:ring-ring",title:o?t?.tokenHide??"Hide":t?.tokenShow??"Show",children:o?(0,r.jsx)(T.A,{size:13}):(0,r.jsx)($.A,{size:13})}),(0,r.jsx)(rB,{onCopy:()=>i(e.authToken??"","token-card"),copied:"token-card"===s,title:t?.tokenCopy??"Copy",size:"sm"})]}):(0,r.jsxs)("div",{className:"px-2.5 py-2 bg-[var(--amber-subtle)] border border-[var(--amber)]/20 rounded-lg",children:[(0,r.jsx)("p",{className:"text-xs text-[var(--amber-text)]",children:t?.tokenNone??"No token set."}),(0,r.jsx)("p",{className:"text-2xs text-muted-foreground mt-0.5",children:t?.tokenNoneAction??"Generate one in Settings → General → Security."})]})})]})}function rD(){let[e,t]=(0,a.useState)(null);return(0,a.useEffect)(()=>{if(!e)return;let s=setTimeout(()=>t(null),2e3);return()=>clearTimeout(s)},[e]),{copiedField:e,handleCopy:(0,a.useCallback)(async(e,s)=>{!e||await (0,t7.l)(e)&&(t(s),ek.oR.copy())},[])}}function rI({mode:e,onModeChange:t,status:s,agents:n,connectedAgents:a,detectedAgents:o,notFoundAgents:l,currentAgent:i,selectedAgent:d,onSelectAgent:c,restarting:u,onRestart:m,onRefresh:x,activeSkillName:p,mcpEnabled:h,m:g,t:f}){if(!s)return null;let b=h?e:"cli";return(0,r.jsxs)("div",{className:"rounded-xl border border-border bg-card overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2.5 px-4 pt-4 pb-3",children:[(0,r.jsx)("div",{className:"w-7 h-7 rounded-lg bg-[var(--amber-subtle)] flex items-center justify-center shrink-0",children:(0,r.jsx)(sn.A,{size:14,className:"text-[var(--amber)]"})}),(0,r.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:g?.connectionTitle??"Connect Agents"})]}),h?(0,r.jsxs)("div",{className:"grid grid-cols-2 mx-4 mb-3 rounded-lg border border-border overflow-hidden",children:[(0,r.jsxs)("button",{onClick:()=>t("cli"),className:`flex flex-col items-start px-3 py-2.5 text-left transition-colors ${"cli"===b?"bg-muted":"hover:bg-muted/50"}`,children:[(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,r.jsx)(rf.A,{size:12,className:"cli"===b?"text-[var(--amber)]":"text-muted-foreground"}),(0,r.jsx)("span",{className:`text-xs font-semibold ${"cli"===b?"text-foreground":"text-muted-foreground"}`,children:"CLI"}),(0,r.jsx)("span",{className:"text-2xs px-1 py-0.5 rounded bg-[var(--amber-subtle)] text-[var(--amber-text)] font-medium leading-none",children:g?.recommended??"Recommended"})]}),(0,r.jsx)("span",{className:"text-2xs text-muted-foreground mt-0.5",children:g?.cliAgents??"Claude Code \xb7 Gemini CLI \xb7 Codex"})]}),(0,r.jsxs)("button",{onClick:()=>t("mcp"),className:`flex flex-col items-start px-3 py-2.5 text-left transition-colors border-l border-border ${"mcp"===b?"bg-muted":"hover:bg-muted/50"}`,children:[(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,r.jsx)(s5.A,{size:12,className:"mcp"===b?"text-foreground":"text-muted-foreground"}),(0,r.jsx)("span",{className:`text-xs font-semibold ${"mcp"===b?"text-foreground":"text-muted-foreground"}`,children:"MCP"})]}),(0,r.jsx)("span",{className:"text-2xs text-muted-foreground mt-0.5",children:g?.mcpAgents??"Claude Desktop \xb7 Cursor"})]})]}):(0,r.jsx)("div",{className:"mx-4 mb-3 px-3 py-2 rounded-lg border border-border bg-muted/30",children:(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,r.jsx)(rf.A,{size:12,className:"text-[var(--amber)]"}),(0,r.jsx)("span",{className:"text-xs font-semibold text-foreground",children:"CLI"}),(0,r.jsx)("span",{className:"text-2xs px-1 py-0.5 rounded bg-[var(--amber-subtle)] text-[var(--amber-text)] font-medium leading-none",children:g?.recommended??"Recommended"})]})}),(0,r.jsx)("div",{className:"px-4 pb-4 space-y-4",children:"cli"===b?(0,r.jsx)(rL,{status:s,activeSkillName:p,agents:n,connectedAgents:a,detectedAgents:o,notFoundAgents:l,onRefresh:x,m:g,t:f}):(0,r.jsx)(rP,{status:s,agents:n,activeSkillName:p,connectedAgents:a,detectedAgents:o,notFoundAgents:l,currentAgent:i,selectedAgent:d,onSelectAgent:c,restarting:u,onRestart:m,onRefresh:x,m:g,t:f})})]})}function rL({status:e,activeSkillName:t,agents:s,connectedAgents:n,detectedAgents:a,notFoundAgents:o,onRefresh:l,m:i,t:d}){let{copiedField:c,handleCopy:u}=rD(),m=e.authConfigured&&!!e.authToken,x=e.localIP||"localhost",p=window.location.port||"3456",h=`http://${x}:${p}`,g=e.maskedToken??"";return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"space-y-2.5",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(sG.A,{size:12,className:"text-success"}),(0,r.jsx)("span",{className:"text-xs font-semibold text-foreground",children:i?.localTitle??"Local"}),(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-2xs font-medium bg-success/10 text-success",children:[(0,r.jsx)(N.A,{size:10}),i?.localReady??"Ready to use"]})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:i?.cliLocalDesc??"MindOS Skill is built-in. Install the CLI and you're good to go."}),(0,r.jsx)(rU,{code:"mindos file list",label:i?.cliSkillVerify??"Verify",onCopy:u,copiedField:c,fieldId:"cli-verify"}),s.length>0&&(0,r.jsx)(rF,{icon:(0,r.jsx)(rv.A,{size:12,className:"text-muted-foreground"}),title:i?.detectedAgentsTitle??"Detected Agents",badge:`${n.length+a.length}/${s.length}`,children:(0,r.jsx)(ry,{agents:s,t:d,onRefresh:l,mode:"cli",activeSkillName:t})})]}),(0,r.jsxs)("div",{className:"border-t border-border pt-3 space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(e1.A,{size:12,className:"text-muted-foreground"}),(0,r.jsx)("span",{className:"text-xs font-semibold text-foreground",children:i?.remoteTitle??"Remote Access"})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:i?.cliRemoteDesc??"Install the CLI on another machine and connect to this MindOS server."}),(0,r.jsx)(rO,{step:"1",label:i?.cliSkillInstall??"Install",children:(0,r.jsx)(rU,{code:"npm install -g @geminilight/mindos",onCopy:u,copiedField:c,fieldId:"cli-install",compact:!0})}),(0,r.jsx)(rO,{step:"2",label:i?.cliRemoteConfigure??"Configure",children:(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)(rU,{code:`mindos config set url ${h}`,onCopy:u,copiedField:c,fieldId:"cli-url",compact:!0}),(0,r.jsx)(rU,{code:`mindos config set authToken ${m?g:"<token>"}`,onCopy:(t,s)=>{u(`mindos config set authToken ${e.authToken??"<token>"}`,s)},copiedField:c,fieldId:"cli-token",compact:!0,hint:m?i?.tokenCopyFullHint??"Copies full token":void 0})]})}),(0,r.jsx)(rO,{step:"3",label:i?.cliInstallSkill??"Install Skill",children:(0,r.jsx)(rU,{code:`npx skills add GeminiLight/MindOS --skill ${t} -g -y`,onCopy:u,copiedField:c,fieldId:"cli-skill",compact:!0})}),(0,r.jsx)(rO,{step:"4",label:i?.cliSkillVerify??"Verify",children:(0,r.jsx)(rU,{code:"mindos file list",onCopy:u,copiedField:c,fieldId:"cli-remote-verify",compact:!0})})]})]})}function rP({status:e,agents:t,activeSkillName:s,connectedAgents:n,detectedAgents:o,notFoundAgents:l,currentAgent:i,selectedAgent:d,onSelectAgent:c,restarting:u,onRestart:m,onRefresh:x,m:p,t:h}){let{copiedField:g,handleCopy:f}=rD(),b=e.authConfigured&&!!e.authToken,v=e.localIP||"localhost",j=`http://${v}:${e.port}/mcp`,y=(0,a.useMemo)(()=>i?(0,sY.$k)(i,e,"stdio"):null,[i,e]),k=(0,a.useMemo)(()=>i?(0,sY.$k)(i,e,"http"):null,[i,e]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(r_,{status:e,restarting:u,onRestart:m,onRefresh:x,m:p}),(0,r.jsxs)("div",{className:"space-y-2.5",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(sG.A,{size:12,className:e.running?"text-success":"text-muted-foreground"}),(0,r.jsx)("span",{className:"text-xs font-semibold text-foreground",children:p?.localTitle??"Local"})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:p?.mcpLocalDesc??"Copy the config snippet and paste into your agent's MCP settings."}),t.length>0&&(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(rj.A,{value:d,onChange:c,options:[...n.length>0?[{label:p?.connectedGroup??"Connected",options:n.map(e=>({value:e.key,label:e.name}))}]:[],...o.length>0?[{label:p?.detectedGroup??"Detected",options:o.map(e=>({value:e.key,label:e.name}))}]:[],...l.length>0?[{label:p?.notFoundGroup??"Not Installed",options:l.map(e=>({value:e.key,label:e.name}))}]:[]]}),i&&y&&(0,r.jsxs)(r.Fragment,{children:[i.present&&i.installed&&(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-2xs font-medium bg-success/10 text-success",children:[(0,r.jsx)(N.A,{size:10})," ",p?.tagConnected??"Connected"]}),(0,r.jsx)("pre",{className:"text-[11px] font-mono bg-muted/50 border border-border rounded-lg p-3 overflow-x-auto whitespace-pre select-all max-h-[200px] overflow-y-auto",children:y.displaySnippet}),(0,r.jsxs)("div",{className:"flex items-center gap-3 text-sm",children:[(0,r.jsxs)("button",{onClick:async()=>{await (0,t7.l)(y.snippet)&&ek.oR.copy()},className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors shrink-0",children:[(0,r.jsx)(ed.A,{size:14})," ",p?.copyConfig??"Copy"]}),(0,r.jsx)("span",{className:"text-muted-foreground",children:"→"}),(0,r.jsx)("span",{className:"font-mono text-muted-foreground truncate text-2xs",children:y.path})]})]})]})]}),t.length>0&&(0,r.jsx)(rF,{icon:(0,r.jsx)(rv.A,{size:12,className:"text-muted-foreground"}),title:p?.detectedAgentsTitle??"Detected Agents",badge:`${n.length+o.length}/${t.length}`,children:(0,r.jsx)(ry,{agents:t,t:h,onRefresh:x,mode:"mcp",activeSkillName:s})}),(0,r.jsxs)("div",{className:"border-t border-border pt-3 space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(e1.A,{size:12,className:"text-muted-foreground"}),(0,r.jsx)("span",{className:"text-xs font-semibold text-foreground",children:p?.remoteTitle??"Remote Access"})]}),!b&&(0,r.jsxs)("p",{className:"flex items-center gap-1.5 text-xs text-[var(--amber-text)]",children:[(0,r.jsx)(S.A,{size:12})," ",p?.noAuthWarning??"Set an Auth Token in Settings → General before enabling remote access."]}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("span",{className:"text-2xs font-medium text-muted-foreground uppercase tracking-wider",children:p?.serverUrl??"MCP Server URL"}),(0,r.jsxs)("div",{className:"flex items-center gap-2 px-2.5 py-1.5 bg-muted/50 border border-border rounded-lg",children:[(0,r.jsx)("code",{className:"flex-1 text-xs font-mono text-foreground select-all truncate",children:j}),(0,r.jsx)(rB,{onCopy:()=>f(j,"mcp-url"),copied:"mcp-url"===g,size:"sm"})]})]}),t.length>0&&i&&k&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("pre",{className:"text-[11px] font-mono bg-muted/50 border border-border rounded-lg p-3 overflow-x-auto whitespace-pre select-all max-h-[200px] overflow-y-auto",children:k.displaySnippet}),(0,r.jsxs)("div",{className:"flex items-center gap-3 text-sm",children:[(0,r.jsxs)("button",{onClick:async()=>{await (0,t7.l)(k.snippet)&&ek.oR.copy()},className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors shrink-0",children:[(0,r.jsx)(ed.A,{size:14})," ",p?.copyConfig??"Copy"]}),(0,r.jsx)("span",{className:"text-muted-foreground",children:"→"}),(0,r.jsx)("span",{className:"font-mono text-muted-foreground truncate text-2xs",children:k.path})]})]})]})]})}function rF({icon:e,title:t,badge:s,defaultOpen:n=!1,children:o}){let[l,i]=(0,a.useState)(n);return(0,r.jsxs)("div",{className:"rounded-lg border border-border overflow-hidden",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>i(e=>!e),className:"flex items-center gap-2 w-full px-3 py-2 text-left bg-muted/30 hover:bg-muted/60 transition-colors",children:[l?(0,r.jsx)(eu.A,{size:11,className:"text-muted-foreground"}):(0,r.jsx)(j.A,{size:11,className:"text-muted-foreground"}),e,(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:t}),s&&(0,r.jsx)("span",{className:"text-2xs text-muted-foreground/70 ml-auto",children:s})]}),l&&(0,r.jsx)("div",{className:"px-3 py-2.5 border-t border-border",children:o})]})}function rO({step:e,label:t,children:s}){return(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"w-4 h-4 rounded-full bg-muted flex items-center justify-center text-2xs font-semibold text-muted-foreground shrink-0",children:e}),(0,r.jsx)("span",{className:"text-2xs font-medium text-muted-foreground uppercase tracking-wider",children:t})]}),(0,r.jsx)("div",{className:"pl-6",children:s})]})}function r_({status:e,restarting:t,onRestart:s,onRefresh:n,m:a}){return(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 rounded-lg border border-border bg-muted/30",children:[(0,r.jsx)("div",{className:"flex items-center gap-2 text-xs",children:t?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(C.A,{size:11,className:"animate-spin text-[var(--amber)]"}),(0,r.jsx)("span",{className:"text-[var(--amber)]",children:a?.restarting??"Restarting..."})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full shrink-0 ${e.running?"bg-success":"bg-muted-foreground"}`}),(0,r.jsxs)("span",{className:"font-medium text-foreground",children:["MCP ",e.running?a?.running??"Running":a?.stopped??"Stopped"]}),e.running&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"\xb7"}),(0,r.jsxs)("span",{className:"text-muted-foreground",children:[":",e.port]}),(0,r.jsx)("span",{className:"text-muted-foreground",children:"\xb7"}),(0,r.jsxs)("span",{className:"text-muted-foreground",children:[e.toolCount," ",a?.tools??"tools"]})]})]})}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[!e.running&&!t&&(0,r.jsxs)("button",{onClick:s,className:"flex items-center gap-1 px-2 py-1 text-2xs rounded-md font-medium text-[var(--amber-foreground)] bg-[var(--amber)] transition-colors",children:[(0,r.jsx)(sQ.A,{size:11})," ",a?.restart??"Restart"]}),(0,r.jsx)("button",{onClick:n,className:"p-1 rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:(0,r.jsx)(b.A,{size:11})})]})]})}function rU({label:e,code:t,onCopy:s,copiedField:n,fieldId:a,compact:o,hint:l}){return(0,r.jsxs)("div",{className:o?"":"space-y-1",children:[e&&(0,r.jsx)("span",{className:"text-2xs font-medium text-muted-foreground uppercase tracking-wider",children:e}),(0,r.jsxs)("div",{className:`flex items-center gap-2 ${o?"px-2.5 py-1.5":"px-3 py-2"} bg-muted/50 border border-border rounded-lg`,children:[(0,r.jsx)("code",{className:"flex-1 text-xs font-mono text-foreground select-all truncate",children:t}),l&&(0,r.jsx)("span",{className:"text-2xs text-muted-foreground/60 shrink-0 hidden sm:inline",children:l}),(0,r.jsx)(rB,{onCopy:()=>s(t,a),copied:n===a,size:"sm"})]})]})}function rB({onCopy:e,copied:t,title:s,size:n}){let a="sm"===n?11:14;return(0,r.jsx)("button",{type:"button",onClick:e,title:s??"Copy",className:`shrink-0 ${"sm"===n?"p-1":"p-2"} rounded-lg border transition-colors focus-visible:ring-2 focus-visible:ring-ring ${t?"border-success/50 bg-success/10 text-success":"border-border text-muted-foreground hover:text-foreground hover:bg-muted"}`,children:t?(0,r.jsx)(z.A,{size:a}):(0,r.jsx)(ed.A,{size:a})})}var rW=s(16950);function rH(){let e=window;return e.mindos?.checkUpdate?e.mindos:null}let rK="https://github.com/GeminiLight/MindOS/releases",rG="mindos_update_in_progress",rY={downloading:{en:"Downloading update",zh:"下载更新"},skills:{en:"Updating skills",zh:"更新 Skills"},rebuilding:{en:"Rebuilding app",zh:"重新构建应用"},restarting:{en:"Restarting server",zh:"重启服务"}};function rJ({status:e}){switch(e){case"done":return(0,r.jsx)(N.A,{size:14,className:"text-success shrink-0"});case"running":return(0,r.jsx)(C.A,{size:14,className:"animate-spin shrink-0 text-[var(--amber)]"});case"failed":return(0,r.jsx)(S.A,{size:14,className:"text-destructive shrink-0"});default:return(0,r.jsx)(rW.A,{size:14,className:"text-muted-foreground/40 shrink-0"})}}function rV(e){return e<1048576?`${Math.round(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function rq(){let{t:e}=(0,y.Y)(),t=e.settings.update,s=rH(),[n,o]=(0,a.useState)("idle"),[l,i]=(0,a.useState)(""),[d,c]=(0,a.useState)(""),[u,m]=(0,a.useState)(null),[x,p]=(0,a.useState)(0),[h,g]=(0,a.useState)(""),[f,v]=(0,a.useState)("");(0,a.useEffect)(()=>{(async()=>{try{let e=await s.checkCoreUpdate?.();if(e&&(i(e.currentVersion),!e.available))return void o("idle")}catch{}try{let e=await s.getCoreUpdatePending?.();if(e?.version){c(e.version),o("ready");return}}catch{}j()})();let e=[];return s.onCoreUpdateProgress&&e.push(s.onCoreUpdateProgress(e=>p(Math.round(e.percent)))),s.onCoreUpdateAvailable&&e.push(s.onCoreUpdateAvailable(e=>{i(e.current),c(e.latest),o(e.ready?"ready":"available")})),()=>e.forEach(e=>e())},[]);let j=async()=>{if(s.checkCoreUpdate){o("checking"),g("");try{let e=await s.checkCoreUpdate();i(e.currentVersion),e.desktopTooOld?(c(e.latestVersion),v(e.minDesktopVersion),o("desktopTooOld")):e.available?(c(e.latestVersion),m({urls:e.urls,size:e.size,sha256:e.sha256}),o("available")):o("idle")}catch{o("idle")}}},k=async()=>{if(s.downloadCoreUpdate&&u){o("downloading"),p(0);try{await s.downloadCoreUpdate(u.urls,d,u.size,u.sha256),o("ready")}catch(t){let e=t instanceof Error?t.message:String(t);e.includes("aborted")?o("available"):(o("error"),g(e||"Download failed"))}}},w=async()=>{if(s.applyCoreUpdate){o("applying");try{let e=await s.applyCoreUpdate();e?.version&&i(e.version),o("idle")}catch(e){o("error"),g(e instanceof Error?e.message:"Apply failed")}}};return s.checkCoreUpdate?(0,r.jsxs)("div",{className:"rounded-xl border border-border bg-card p-4 space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:t?.coreTitle??"MindOS Core"}),l&&(0,r.jsxs)("span",{className:"text-xs font-mono text-muted-foreground",children:["v",l]})]}),"checking"===n&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(C.A,{size:13,className:"animate-spin"}),t?.checking??"Checking for updates..."]}),"idle"===n&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-success",children:[(0,r.jsx)(N.A,{size:13}),t?.coreUpToDate??"Core is up to date"]}),"available"===n&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-[var(--amber-text)]",children:[(0,r.jsx)(to.A,{size:13}),"v",d," ",t?.coreAvailable?t.coreAvailable(rV(u?.size??0)):`available (${rV(u?.size??0)})`]}),("downloading"===n||"cancelling"===n)&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-foreground",children:[(0,r.jsx)(C.A,{size:13,className:"animate-spin text-[var(--amber)]"}),"cancelling"===n?t?.coreCancel??"Cancelling...":(0,r.jsxs)(r.Fragment,{children:[t?.coreDownloading??"Downloading..."," v",d]})]}),"downloading"===n&&(0,r.jsx)("button",{onClick:()=>{s.cancelCoreDownload?.(),o("cancelling")},className:"text-muted-foreground hover:text-foreground transition-colors",children:t?.coreCancel??"Cancel"})]}),(0,r.jsx)("div",{className:"h-1 rounded-full bg-muted overflow-hidden",children:(0,r.jsx)("div",{className:"h-full rounded-full bg-[var(--amber)] transition-all duration-300",style:{width:`${Math.max(x,3)}%`}})})]}),"ready"===n&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-success",children:[(0,r.jsx)(N.A,{size:13}),"v",d," ",t?.coreReady??"ready — restart services to apply"]}),"applying"===n&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(C.A,{size:13,className:"animate-spin text-[var(--amber)]"}),t?.coreApplying??"Applying update..."]}),"desktopTooOld"===n&&(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-[var(--amber-text)]",children:[(0,r.jsx)(S.A,{size:13}),t?.coreDesktopTooOld?t.coreDesktopTooOld(d):`v${d} requires a newer Desktop.`]}),(0,r.jsxs)("p",{className:"text-2xs text-muted-foreground",children:[t?.coreDesktopTooOldHint??"Please update MindOS Desktop first."," (Desktop ≥ v",f,")"]})]}),"error"===n&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-destructive",children:[(0,r.jsx)(S.A,{size:13}),h||(t?.coreError??"Core update failed.")]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 pt-1",children:[("idle"===n||"error"===n)&&(0,r.jsxs)("button",{onClick:j,disabled:"idle"!==n&&"error"!==n,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg border border-border text-muted-foreground hover:text-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:[(0,r.jsx)(b.A,{size:14}),t?.checkButton??"Check for Updates"]}),"available"===n&&(0,r.jsxs)("button",{onClick:k,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg font-medium text-[var(--amber-foreground)] bg-[var(--amber)] transition-colors",children:[(0,r.jsx)(to.A,{size:14}),t?.updateButton?t.updateButton(d):`Update to v${d}`]}),"ready"===n&&(0,r.jsxs)("button",{onClick:w,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg font-medium text-[var(--amber-foreground)] bg-[var(--amber)] transition-colors",children:[(0,r.jsx)(b.A,{size:14}),t?.coreRestartServices??"Restart Services"]}),"error"===n&&(0,r.jsxs)("button",{onClick:u?k:j,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[(0,r.jsx)(b.A,{size:14}),t?.coreRetry??"Retry"]})]}),(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/60",children:t?.coreHint??"Core updates only restart services — no app restart needed."})]}):null}function rZ(){let{t:e}=(0,y.Y)(),t=e.settings.update,s=rH(),[n,o]=(0,a.useState)("idle"),[l,i]=(0,a.useState)(!1),[d,c]=(0,a.useState)(null),[u,m]=(0,a.useState)(""),[x,p]=(0,a.useState)(0),[h,g]=(0,a.useState)("");(0,a.useEffect)(()=>{o("idle"),s.getAppInfo?.().then(e=>{e?.version&&m(e.version)}).catch(e=>{console.warn("[UpdateTab] getAppInfo failed:",e)}),f();let e=[];return s.onUpdateAvailable&&e.push(s.onUpdateAvailable(e=>{i(!0),e?.version&&c(e.version),o(e=>"checking"===e?"idle":e)})),s.onUpdateProgress&&e.push(s.onUpdateProgress(e=>p(Math.round(e.percent)))),s.onUpdateReady&&e.push(s.onUpdateReady(()=>o("ready"))),s.onUpdateError&&e.push(s.onUpdateError(e=>{o("error"),g(e?.message||"Update failed. Please try again.")})),()=>e.forEach(e=>e())},[]);let f=async()=>{o("checking"),g("");try{let e=await s.checkUpdate();i(e.available),e.version&&c(e.version),o("idle")}catch{o("error"),g(t?.error??"Failed to check for updates.")}},v=async()=>{o("downloading"),p(0);try{await s.installUpdate()}catch{o("error"),g("Update failed. Please try again.")}};return(0,r.jsxs)("div",{className:"rounded-xl border border-border bg-card p-4 space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(sG.A,{size:14,className:"text-muted-foreground"}),(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:t?.shellTitle??"MindOS Desktop"})]}),u&&(0,r.jsxs)("span",{className:"text-xs font-mono text-muted-foreground",children:["v",u]})]}),"checking"===n&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(C.A,{size:13,className:"animate-spin"}),t?.checking??"Checking for updates..."]}),"idle"===n&&!l&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-success",children:[(0,r.jsx)(N.A,{size:13}),t?.upToDate??"You're up to date"]}),"idle"===n&&l&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-[var(--amber-text)]",children:[(0,r.jsx)(to.A,{size:13}),d?`Update available: v${d}`:"Update available"]}),"downloading"===n&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-foreground",children:[(0,r.jsx)(C.A,{size:13,className:"animate-spin text-[var(--amber)]"}),t?.desktopDownloading??"Downloading update..."]}),(0,r.jsx)("div",{className:"h-1 rounded-full bg-muted overflow-hidden",children:(0,r.jsx)("div",{className:"h-full rounded-full bg-[var(--amber)] transition-all duration-300",style:{width:`${Math.max(x,3)}%`}})})]}),"ready"===n&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-success",children:[(0,r.jsx)(N.A,{size:13}),t?.desktopReady??"Update downloaded. Restart to apply."]}),"error"===n&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-destructive",children:[(0,r.jsx)(S.A,{size:13}),h]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 pt-1",children:[(0,r.jsxs)("button",{onClick:f,disabled:"checking"===n||"downloading"===n,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg border border-border text-muted-foreground hover:text-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:[(0,r.jsx)(b.A,{size:14,className:"checking"===n?"animate-spin":""}),t?.checkButton??"Check for Updates"]}),"idle"===n&&l&&(0,r.jsxs)("button",{onClick:v,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg font-medium text-[var(--amber-foreground)] bg-[var(--amber)] transition-colors",children:[(0,r.jsx)(to.A,{size:14}),d?`Update to v${d}`:"Update"]}),"ready"===n&&(0,r.jsxs)("button",{onClick:async()=>{try{await s.installUpdate()}catch{o("error"),g(t?.error??"Failed to install update.")}},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg font-medium text-[var(--amber-foreground)] bg-[var(--amber)] transition-colors",children:[(0,r.jsx)(b.A,{size:14}),t?.desktopRestart??"Restart Now"]})]}),(0,r.jsxs)("div",{className:"border-t border-border/50 pt-3 space-y-2",children:[(0,r.jsxs)("a",{href:rK,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[(0,r.jsx)(s4.A,{size:12}),t?.releaseNotes??"View release notes"]}),(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/60",children:t?.desktopHint??"Updates are delivered through the Desktop app auto-updater."})]})]})}function rQ(){let[e,t]=(0,a.useState)(!1),[s,n]=(0,a.useState)(!0);return((0,a.useEffect)(()=>{let e=rH();t(!!e),e?.getAppInfo&&e.getAppInfo().then(e=>{e&&"mode"in e&&n("remote"!==e.mode)}).catch(()=>{})},[]),e)?(0,r.jsxs)("div",{className:"space-y-6",children:[s&&(0,r.jsx)(rq,{}),(0,r.jsx)(rZ,{})]}):(0,r.jsx)(rX,{})}function rX(){let{t:e,locale:t}=(0,y.Y)(),s=e.settings.update,[n,o]=(0,a.useState)(null),[l,i]=(0,a.useState)("idle"),[d,c]=(0,a.useState)(""),[u,m]=(0,a.useState)([]),[x,p]=(0,a.useState)(null),[h,g]=(0,a.useState)(!1),f=(0,a.useRef)(void 0),v=(0,a.useRef)(void 0),j=(0,a.useRef)(""),k=(0,a.useCallback)(async()=>{i("checking"),c("");try{let e=await (0,w.n)("/api/update-check");if(o(e),j.current||(j.current=e.current),e.hasUpdate){let t=localStorage.getItem("mindos_update_dismissed");localStorage.setItem("mindos_update_latest",e.latest),window.dispatchEvent(new Event(e.latest===t?"mindos:update-dismissed":"mindos:update-available"))}else localStorage.removeItem("mindos_update_latest"),localStorage.removeItem("mindos_update_dismissed"),window.dispatchEvent(new Event("mindos:update-dismissed"));i("idle")}catch{i("error"),c(s?.error??"Failed to check for updates.")}},[s]),A=(0,a.useCallback)(()=>{clearInterval(f.current),clearTimeout(v.current)},[]),z=(0,a.useCallback)(e=>{A(),o(e),i("updated"),localStorage.removeItem("mindos_update_latest"),localStorage.removeItem("mindos_update_dismissed"),localStorage.removeItem(rG),window.dispatchEvent(new Event("mindos:update-dismissed")),setTimeout(()=>window.location.reload(),2e3)},[A]),E=(0,a.useCallback)(()=>{f.current=setInterval(async()=>{try{let e=await (0,w.n)("/api/update-status",{timeout:5e3});if(g(!1),e.stages?.length>0&&m(e.stages),"failed"===e.stage){A(),localStorage.removeItem(rG),p(e.error||"Update failed"),i("error");return}if("done"===e.stage)try{let e=await (0,w.n)("/api/update-check");if(e.current!==j.current)return void z(e)}catch{}}catch{g(!0);try{let e=await (0,w.n)("/api/update-check",{timeout:5e3});e.current&&e.current!==j.current&&(m(e=>e.map(e=>({...e,status:"done"}))),z(e))}catch{}}},3e3),v.current=setTimeout(()=>{A(),localStorage.removeItem(rG),i("timeout")},9e5)},[A,z]);(0,a.useEffect)(()=>{let e=localStorage.getItem(rG);if(e)try{let{originalVer:t}=JSON.parse(e);j.current=t,i("updating"),g(!0),m([{id:"downloading",status:"done"},{id:"skills",status:"done"},{id:"rebuilding",status:"done"},{id:"restarting",status:"running"}]),E()}catch{localStorage.removeItem(rG),k()}else k()},[]),(0,a.useEffect)(()=>A,[A]);let T=(0,a.useCallback)(async()=>{i("updating"),c(""),p(null),g(!1),m([{id:"downloading",status:"pending"},{id:"skills",status:"pending"},{id:"rebuilding",status:"pending"},{id:"restarting",status:"pending"}]),localStorage.setItem(rG,JSON.stringify({originalVer:j.current||n?.current,startedAt:Date.now()})),window.dispatchEvent(new Event("mindos:update-started"));try{await (0,w.n)("/api/update",{method:"POST"})}catch(e){if(e instanceof w.h){localStorage.removeItem(rG),p(e.message||"Update failed"),i("error");return}}E()},[E,n]),$=(0,a.useCallback)(()=>{p(null),T()},[T]),R="zh"===t?"zh":"en",M=u.filter(e=>"done"===e.status).length,D=u.length>0?Math.round(M/u.length*100):0;return(0,r.jsx)("div",{className:"space-y-6",children:(0,r.jsxs)("div",{className:"rounded-xl border border-border bg-card p-4 space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:"MindOS"}),n&&(0,r.jsxs)("span",{className:"text-xs font-mono text-muted-foreground",children:["v",n.current]})]}),"checking"===l&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(C.A,{size:13,className:"animate-spin"}),s?.checking??"Checking for updates..."]}),"idle"===l&&n&&!n.hasUpdate&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-success",children:[(0,r.jsx)(N.A,{size:13}),s?.upToDate??"You're up to date"]}),"idle"===l&&n?.hasUpdate&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-[var(--amber-text)]",children:[(0,r.jsx)(to.A,{size:13}),s?.available?s.available(n.current,n.latest):`Update available: v${n.current} → v${n.latest}`]}),"updating"===l&&(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("div",{className:"space-y-1.5",children:u.map(e=>(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,r.jsx)(rJ,{status:e.status}),(0,r.jsx)("span",{className:"pending"===e.status?"text-muted-foreground/50":"running"===e.status?"text-foreground":"text-muted-foreground",children:rY[e.id]?.[R]??e.id})]},e.id))}),(0,r.jsx)("div",{className:"h-1 rounded-full bg-muted overflow-hidden",children:(0,r.jsx)("div",{className:"h-full rounded-full bg-[var(--amber)] transition-all duration-500 ease-out",style:{width:`${Math.max(D,5)}%`}})}),(0,r.jsx)("p",{className:"text-2xs text-muted-foreground",children:h?s?.serverRestarting??"Server is restarting, please wait...":s?.updatingHint??"This may take 1–3 minutes. Do not close this page."})]}),"updated"===l&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-success",children:[(0,r.jsx)(N.A,{size:13}),s?.updated??"Updated successfully! Reloading..."]}),"timeout"===l&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-[var(--amber-text)]",children:[(0,r.jsx)(S.A,{size:13}),s?.timeout??"Update may still be in progress."]}),(0,r.jsx)("p",{className:"text-2xs text-muted-foreground",children:s?.timeoutHint??"The server may need more time to rebuild. Try refreshing."}),(0,r.jsxs)("button",{onClick:()=>window.location.reload(),className:"flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-lg border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[(0,r.jsx)(b.A,{size:12}),s?.refreshButton??"Refresh Page"]})]}),"error"===l&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-destructive",children:[(0,r.jsx)(S.A,{size:13}),x||d]}),x&&(0,r.jsxs)("button",{onClick:$,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-lg border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[(0,r.jsx)(b.A,{size:12}),s?.retryButton??"Retry Update"]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 pt-1",children:[(0,r.jsxs)("button",{onClick:k,disabled:"checking"===l||"updating"===l,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg border border-border text-muted-foreground hover:text-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:[(0,r.jsx)(b.A,{size:14,className:"checking"===l?"animate-spin":""}),s?.checkButton??"Check for Updates"]}),n?.hasUpdate&&"updating"!==l&&"updated"!==l&&(0,r.jsxs)("button",{onClick:T,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg font-medium text-[var(--amber-foreground)] bg-[var(--amber)] transition-colors",children:[(0,r.jsx)(to.A,{size:14}),s?.updateButton?s.updateButton(n.latest):`Update to v${n.latest}`]})]}),(0,r.jsxs)("div",{className:"border-t border-border/50 pt-3 space-y-2",children:[(0,r.jsxs)("a",{href:rK,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[(0,r.jsx)(s4.A,{size:12}),s?.releaseNotes??"View release notes"]}),(0,r.jsxs)("p",{className:"text-2xs text-muted-foreground/60",children:[s?.hint??"Updates are installed via npm. Equivalent to running"," ",(0,r.jsx)("code",{className:"font-mono bg-muted px-1 py-0.5 rounded",children:"mindos update"})," ",s?.inTerminal??"in your terminal."]})]})]})})}function r0(){let e=window;return e.mindos?.uninstallApp?e.mindos:null}function r1(){let{t:e}=(0,y.Y)(),t=e.settings.uninstall,s=!!r0(),[n,o]=(0,a.useState)("idle"),[l,i]=(0,a.useState)(""),[d,c]=(0,a.useState)(!0),[u,m]=(0,a.useState)(!0),x=async()=>{o("running"),i("");try{if(await (0,w.n)("/api/uninstall",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({removeConfig:d})}),s&&u){let e=r0();if(e?.uninstallApp){let t=await e.uninstallApp();if(!t.ok)throw Error(t.error||"Failed to remove app");o("success");return}}o("success")}catch(e){i(e instanceof Error?e.message:String(e)),o("error")}},p=({checked:e,onChange:t,label:s,desc:n,disabled:a})=>(0,r.jsxs)("label",{className:`flex items-start gap-2.5 p-2.5 rounded bg-muted/30 cursor-pointer select-none ${a?"opacity-50 cursor-not-allowed":"hover:bg-muted/50"}`,children:[(0,r.jsx)("input",{type:"checkbox",checked:e,onChange:e=>!a&&t(e.target.checked),disabled:a,className:"mt-0.5 form-check"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium text-foreground",children:s}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:n})]})]});return(0,r.jsxs)(R.L7,{icon:(0,r.jsx)(er.A,{size:15}),title:t.title,description:s?t.descDesktop:t.descCli,children:[(0,r.jsxs)("div",{className:"flex gap-2.5 p-3 rounded-md bg-muted/50 border border-border",children:[(0,r.jsx)(tu.A,{size:14,className:"text-success shrink-0 mt-0.5"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:t.kbSafe})]}),"idle"===n||"confirming"===n?(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(p,{checked:!0,disabled:!0,label:t.stopServices,desc:t.stopServicesDesc,onChange:()=>{}}),(0,r.jsx)(p,{checked:d,onChange:c,label:t.removeConfig,desc:t.removeConfigDesc}),!s&&(0,r.jsx)(p,{checked:!0,disabled:!0,label:t.removeNpm,desc:t.removeNpmDesc,onChange:()=>{}}),s&&(0,r.jsx)(p,{checked:u,onChange:m,label:t.removeApp,desc:t.removeAppDesc})]}):null,"idle"===n&&(0,r.jsxs)("button",{onClick:()=>o("confirming"),className:"px-3.5 py-2 text-sm font-medium rounded-lg bg-error/10 text-error border border-error/20 hover:bg-error/20 transition-colors focus-visible:ring-1 focus-visible:ring-ring disabled:opacity-40 disabled:cursor-not-allowed",children:[(0,r.jsx)(er.A,{size:12,className:"inline mr-1.5 -mt-px"}),t.confirmButton]}),"confirming"===n&&(0,r.jsxs)("div",{className:"p-3 rounded-md border border-error/30 bg-error/5 space-y-2.5",children:[(0,r.jsx)("p",{className:"text-xs font-medium text-error",children:t.confirmTitle}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{onClick:x,className:"px-3.5 py-2 text-sm font-medium rounded-lg bg-error text-white hover:bg-error/90 transition-colors focus-visible:ring-1 focus-visible:ring-ring",children:t.confirmButton}),(0,r.jsx)("button",{onClick:()=>o("idle"),className:"px-3.5 py-2 text-sm font-medium rounded-lg bg-muted text-foreground hover:bg-muted/80 transition-colors focus-visible:ring-1 focus-visible:ring-ring",children:t.cancelButton})]})]}),"running"===n&&(0,r.jsxs)("div",{className:"flex items-center gap-2 py-2",children:[(0,r.jsx)(C.A,{size:14,className:"animate-spin text-muted-foreground"}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:t.running})]}),"success"===n&&(0,r.jsxs)("div",{className:"flex items-center gap-2 py-2",children:[(0,r.jsx)(N.A,{size:14,className:"text-success"}),(0,r.jsx)("span",{className:"text-xs text-success font-medium",children:s&&u?t.successDesktop:t.success})]}),"error"===n&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(tT.A,{size:14,className:"text-error"}),(0,r.jsx)("span",{className:"text-xs text-error font-medium",children:t.error})]}),l&&(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground font-mono",children:l}),(0,r.jsx)("button",{onClick:()=>o("idle"),className:"px-3 py-1.5 text-xs font-medium rounded-md bg-muted text-foreground hover:bg-muted/80 transition-colors focus-visible:ring-1 focus-visible:ring-ring",children:t.cancelButton})]})]})}function r2({visible:e,initialTab:t,variant:s,onClose:o}){let[l,i]=(0,a.useState)("ai"),[d,m]=(0,a.useState)(null),[x,p]=(0,a.useState)(!1),[h,g]=(0,a.useState)("idle"),{t:f,locale:v,setLocale:j}=(0,y.Y)(),k=(0,n.useRouter)(),A=(0,a.useRef)(void 0),z=(0,a.useRef)(!1),E=(0,a.useRef)(null),[T,$]=(0,a.useState)("lora"),[R,M]=(0,a.useState)("15px"),[D,I]=(0,a.useState)("780px"),[L,P]=(0,a.useState)(!0),[O,_]=(0,a.useState)(()=>{let e=localStorage.getItem("mindos_update_dismissed"),t=localStorage.getItem("mindos_update_latest");return!!t&&t!==e});(0,a.useEffect)(()=>{let e=()=>_(!0),t=()=>_(!1);return window.addEventListener("mindos:update-available",e),window.addEventListener("mindos:update-dismissed",t),()=>{window.removeEventListener("mindos:update-available",e),window.removeEventListener("mindos:update-dismissed",t)}},[]);let U="panel"===s,B=(0,a.useRef)(!1);(0,a.useEffect)(()=>{if(U?e&&!B.current:e){(0,w.n)("/api/settings").then(e=>{m(e),z.current=!0}).catch(()=>g("load-error")),$("geist"===localStorage.getItem("prose-font")?"inter":localStorage.getItem("prose-font")??"lora"),M(localStorage.getItem("prose-font-size")??"15px"),I(localStorage.getItem("content-width")??"780px");let e=localStorage.getItem("theme");P(e?"dark"===e:window.matchMedia("(prefers-color-scheme: dark)").matches),g("idle")}e||(z.current=!1),B.current=e},[e,U]),(0,a.useEffect)(()=>{e&&t&&W(t)},[e,t]);let W=(0,a.useCallback)(e=>{i(e),E.current?.scrollTo?.(0,0)},[]);(0,a.useEffect)(()=>{document.documentElement.style.setProperty("--prose-font-override",{lora:"'Lora', Georgia, serif","ibm-plex-sans":"'IBM Plex Sans', sans-serif",inter:"var(--font-inter), sans-serif","ibm-plex-mono":"'IBM Plex Mono', monospace"}[T]??""),localStorage.setItem("prose-font",T)},[T]),(0,a.useEffect)(()=>{document.documentElement.style.setProperty("--prose-font-size-override",R),localStorage.setItem("prose-font-size",R)},[R]),(0,a.useEffect)(()=>{document.documentElement.style.setProperty("--content-width-override",D),localStorage.setItem("content-width",D)},[D]),(0,a.useEffect)(()=>{if("modal"!==s||!e||!o)return;let t=e=>{"Escape"===e.key&&o()};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[s,e,o]);let H=(0,a.useCallback)(async e=>{p(!0);try{await (0,w.n)("/api/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ai:e.ai,agent:e.agent,mindRoot:e.mindRoot,webPassword:e.webPassword,authToken:e.authToken})}),g("saved"),window.dispatchEvent(new Event("mindos:settings-changed")),setTimeout(()=>g("idle"),2500)}catch{g("error"),setTimeout(()=>g("idle"),2500)}finally{p(!1)}},[]),K=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(d&&z.current)return K.current=d,clearTimeout(A.current),A.current=setTimeout(()=>{K.current=null,H(d)},800),()=>clearTimeout(A.current)},[d,H]),(0,a.useEffect)(()=>{if(!e&&K.current){let e=K.current;K.current=null,clearTimeout(A.current),H(e)}},[e,H]),(0,a.useEffect)(()=>()=>{if(K.current){clearTimeout(A.current);let e=K.current;K.current=null,(0,w.n)("/api/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ai:e.ai,agent:e.agent,mindRoot:e.mindRoot,webPassword:e.webPassword,authToken:e.authToken})}).catch(()=>{})}},[]);let G=(0,a.useCallback)(e=>{m(t=>t?{...t,ai:{...t.ai,...e}}:t)},[]),Y=(0,a.useCallback)(e=>{m(t=>t?{...t,agent:{...t.agent??{},...e}}:t)},[]),J=(0,a.useCallback)(async()=>{if(!d)return;let e={provider:"anthropic",providers:{anthropic:{apiKey:"",model:"claude-sonnet-4-6"},openai:{apiKey:"",model:"gpt-5.4",baseUrl:""}}};m(t=>t?{...t,ai:e}:t),setTimeout(()=>{(0,w.n)("/api/settings").then(e=>{m(e)}).catch(()=>g("error"))},1300)},[d]),V=d?.envOverrides??{},q=U?12:13,Z=[{id:"ai",label:f.settings.tabs.ai,icon:(0,r.jsx)(tL.A,{size:q})},{id:"mcp",label:f.settings.tabs.mcp??"Connections",icon:(0,r.jsx)(s5.A,{size:q})},{id:"knowledge",label:f.settings.tabs.knowledge,icon:(0,r.jsx)(c.A,{size:q})},{id:"appearance",label:f.settings.tabs.appearance,icon:(0,r.jsx)(s3.A,{size:q})},{id:"sync",label:f.settings.tabs.sync??"Sync",icon:(0,r.jsx)(b.A,{size:q})},{id:"update",label:f.settings.tabs.update??"Update",icon:(0,r.jsx)(to.A,{size:q}),badge:O},{id:"uninstall",label:f.settings.tabs.uninstall??"Uninstall",icon:(0,r.jsx)(er.A,{size:q})}],Q=Z.find(e=>e.id===l)?.label??"",X=()=>(0,r.jsx)("div",{ref:E,className:`flex-1 overflow-y-auto min-h-0 ${U?"px-4 py-4 space-y-4":"px-5 py-5 space-y-5"}`,children:"load-error"===h&&("ai"===l||"knowledge"===l)?(0,r.jsxs)("div",{className:"flex flex-col items-center gap-2 py-8 text-center",children:[(0,r.jsx)(S.A,{size:U?18:20,className:"text-destructive"}),(0,r.jsx)("p",{className:`${U?"text-xs":"text-sm"} text-destructive font-medium`,children:"Failed to load settings"}),!U&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Check that the server is running and AUTH_TOKEN is configured correctly."})]}):d||"appearance"===l||"mcp"===l||"sync"===l||"update"===l||"uninstall"===l?(0,r.jsxs)(r.Fragment,{children:["ai"===l&&d?.ai&&(0,r.jsx)(s8,{data:d,updateAi:G,updateAgent:Y,t:f}),"appearance"===l&&(0,r.jsx)(rl,{font:T,setFont:$,fontSize:R,setFontSize:M,contentWidth:D,setContentWidth:I,dark:L,setDark:P,locale:v,setLocale:j,t:f}),"knowledge"===l&&d&&(0,r.jsx)(rp,{data:d,setData:m,t:f}),"sync"===l&&(0,r.jsx)(F,{t:f}),"mcp"===l&&(0,r.jsx)(r$,{t:f}),"update"===l&&(0,r.jsx)(rQ,{}),"uninstall"===l&&(0,r.jsx)(r1,{})]}):(0,r.jsx)("div",{className:"flex justify-center py-8",children:(0,r.jsx)(C.A,{size:U?16:18,className:"animate-spin text-muted-foreground"})})}),ee=()=>"ai"===l||"knowledge"===l?(0,r.jsxs)("div",{className:`${U?"px-4 py-2":"px-5 py-2.5"} border-t border-border shrink-0 flex items-center justify-between`,children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:["ai"===l&&Object.values(V).some(Boolean)&&(0,r.jsxs)("button",{onClick:J,disabled:x||!d,className:`flex items-center gap-1.5 ${U?"px-2.5 py-1 text-xs rounded-md":"px-3 py-1.5 text-sm rounded-lg"} border border-border text-muted-foreground hover:text-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:[(0,r.jsx)(sQ.A,{size:U?12:13}),f.settings.ai.restoreFromEnv]}),"knowledge"===l&&(0,r.jsxs)("a",{href:"/setup?force=1",className:`flex items-center gap-1.5 ${U?"px-2.5 py-1 text-xs rounded-md":"px-3 py-1.5 text-sm rounded-lg"} border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors`,children:[(0,r.jsx)(sQ.A,{size:U?12:13}),f.settings.reconfigure]})]}),!U&&(0,r.jsxs)("div",{className:"flex items-center gap-1.5 text-xs",role:"status","aria-live":"polite",children:[x&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(C.A,{size:12,className:"animate-spin text-muted-foreground"}),(0,r.jsxs)("span",{className:"text-muted-foreground",children:[f.settings.save,"..."]})]}),"saved"===h&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(N.A,{size:12,className:"text-success"}),(0,r.jsx)("span",{className:"text-success",children:f.settings.saved})]}),"error"===h&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(S.A,{size:12,className:"text-destructive"}),(0,r.jsx)("span",{className:"text-destructive",children:f.settings.saveFailed})]})]})]}):null;return U?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border shrink-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[(0,r.jsx)(c.A,{size:14,className:"text-muted-foreground"}),(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Settings"})]}),(0,r.jsx)("div",{className:"flex items-center gap-1.5",children:(0,r.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px]",role:"status","aria-live":"polite",children:[x&&(0,r.jsx)(C.A,{size:10,className:"animate-spin text-muted-foreground"}),"saved"===h&&(0,r.jsx)(N.A,{size:10,className:"text-success"}),"error"===h&&(0,r.jsx)(S.A,{size:10,className:"text-destructive"})]})})]}),(0,r.jsx)("div",{className:"flex border-b border-border px-3 shrink-0 overflow-x-auto scrollbar-none gap-0",children:Z.map(e=>(0,r.jsxs)("button",{onClick:()=>W(e.id),className:`flex items-center gap-1 px-2 py-2 text-xs font-medium transition-colors border-b-2 -mb-px whitespace-nowrap ${l===e.id?"border-[var(--amber)] text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.icon,e.label,e.badge&&(0,r.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-error shrink-0"})]},e.id))}),X(),ee()]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex flex-col h-full md:hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border shrink-0",children:[(0,r.jsx)("div",{className:"flex justify-center pt-2 pb-0 absolute top-0 left-1/2 -translate-x-1/2",children:(0,r.jsx)("div",{className:"w-8 h-1 rounded-full bg-muted-foreground/20"})}),(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[(0,r.jsx)(c.A,{size:15,className:"text-muted-foreground"}),(0,r.jsx)("span",{children:f.settings.title})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px]",role:"status","aria-live":"polite",children:[x&&(0,r.jsx)(C.A,{size:12,className:"animate-spin text-muted-foreground"}),"saved"===h&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(N.A,{size:12,className:"text-success"}),(0,r.jsx)("span",{className:"text-success",children:f.settings.saved})]}),"error"===h&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(S.A,{size:12,className:"text-destructive"}),(0,r.jsx)("span",{className:"text-destructive",children:f.settings.saveFailed})]})]}),o&&(0,r.jsx)("button",{onClick:o,className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",children:(0,r.jsx)(u.A,{size:15})})]})]}),(0,r.jsxs)("div",{className:"flex border-b border-border px-4 shrink-0 overflow-x-auto scrollbar-none gap-0",children:[Z.map(e=>(0,r.jsxs)("button",{onClick:()=>W(e.id),className:`flex items-center gap-1.5 px-3 py-2.5 text-sm font-medium transition-colors border-b-2 -mb-px whitespace-nowrap ${l===e.id?"border-[var(--amber)] text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.icon,e.label,e.badge&&(0,r.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-error shrink-0"})]},e.id)),(0,r.jsxs)("button",{onClick:()=>{o?.(),k.push("/help")},className:"flex items-center gap-1.5 px-3 py-2.5 text-sm font-medium transition-colors border-b-2 -mb-px whitespace-nowrap border-transparent text-muted-foreground hover:text-foreground",children:[(0,r.jsx)(s0.A,{size:q}),f.sidebar.help]})]}),X(),ee()]}),(0,r.jsxs)("div",{className:"hidden md:flex flex-row h-full min-h-0",children:[(0,r.jsxs)("div",{className:"w-[180px] shrink-0 border-r border-border flex flex-col",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[(0,r.jsx)(c.A,{size:15,className:"text-muted-foreground"}),(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:f.settings.title})]}),(0,r.jsx)("nav",{className:"flex-1 overflow-y-auto py-1.5",children:Z.map(e=>(0,r.jsxs)("button",{onClick:()=>W(e.id),className:`flex items-center gap-2 w-full px-4 py-2 text-sm font-medium transition-colors relative ${l===e.id?"text-foreground bg-muted":"text-muted-foreground hover:text-foreground hover:bg-muted/50"}`,children:[l===e.id&&(0,r.jsx)("div",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-r-full bg-[var(--amber)]"}),e.icon,e.label,e.badge&&(0,r.jsx)("span",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-error shrink-0"})]},e.id))}),(0,r.jsx)("div",{className:"shrink-0 border-t border-border px-4 py-2",children:(0,r.jsxs)("button",{onClick:()=>{o?.(),k.push("/help")},className:"flex items-center gap-2 w-full px-0 py-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[(0,r.jsx)(s0.A,{size:13}),f.sidebar.help]})})]}),(0,r.jsxs)("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border shrink-0",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:Q}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px]",role:"status","aria-live":"polite",children:[x&&(0,r.jsx)(C.A,{size:12,className:"animate-spin text-muted-foreground"}),"saved"===h&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(N.A,{size:12,className:"text-success"}),(0,r.jsx)("span",{className:"text-success",children:f.settings.saved})]}),"error"===h&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(S.A,{size:12,className:"text-destructive"}),(0,r.jsx)("span",{className:"text-destructive",children:f.settings.saveFailed})]})]}),o&&(0,r.jsx)("button",{onClick:o,className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",children:(0,r.jsx)(u.A,{size:15})})]})]}),X(),ee()]})]})]})}function r5({open:e,onClose:t,initialTab:s}){return e?(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-end md:items-start justify-center md:pt-[10vh] modal-backdrop",onClick:e=>e.target===e.currentTarget&&t(),children:(0,r.jsx)("div",{role:"dialog","aria-modal":"true","aria-label":"Settings",className:"w-full md:max-w-3xl md:mx-4 bg-card border-t md:border border-border rounded-t-2xl md:rounded-xl shadow-2xl flex flex-col h-[88vh] md:h-[80vh] md:max-h-[85vh]",children:(0,r.jsx)(r2,{visible:e,variant:"modal",onClose:t,initialTab:s})})}):null}function r3(){let[e,t]=(0,a.useState)(!1),{t:s}=(0,y.Y)(),n=s.shortcutPanel,o="u">typeof navigator&&/Mac|iPhone|iPad/.test(navigator.userAgent)?"⌘":"Ctrl",l=(0,a.useMemo)(()=>[{keys:`${o} K`,label:n.toggleSearch,section:n.navigation},{keys:`${o} /`,label:n.toggleAskAI,section:n.navigation},{keys:`${o} ,`,label:n.openSettings,section:n.navigation},{keys:`${o} ?`,label:n.keyboardShortcuts,section:n.navigation},{keys:"Esc",label:n.closePanel,section:n.panelsSection},{keys:`${o} S`,label:n.saveFile,section:n.editor},{keys:`${o} Z`,label:n.undo,section:n.editor},{keys:`${o} Shift Z`,label:n.redo,section:n.editor}],[o,n]);if((0,a.useEffect)(()=>{let s=s=>{(s.metaKey||s.ctrlKey)&&s.shiftKey&&"/"===s.key&&(s.preventDefault(),t(e=>!e)),"Escape"===s.key&&e&&t(!1)};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e]),!e)return null;let i=[...new Set(l.map(e=>e.section))];return(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center modal-backdrop",onClick:e=>e.target===e.currentTarget&&t(!1),children:(0,r.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":n.title,className:"w-full max-w-md mx-4 bg-card border border-border rounded-xl shadow-2xl overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-5 py-3.5 border-b border-border",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:n.title}),(0,r.jsx)("button",{onClick:()=>t(!1),className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",children:(0,r.jsx)(u.A,{size:15})})]}),(0,r.jsx)("div",{className:"px-5 py-4 space-y-4 max-h-[60vh] overflow-y-auto",children:i.map(e=>(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wider mb-2",children:e}),(0,r.jsx)("div",{className:"space-y-1",children:l.filter(t=>t.section===e).map(e=>(0,r.jsxs)("div",{className:"flex items-center justify-between py-1.5",children:[(0,r.jsx)("span",{className:"text-xs text-foreground",children:e.label}),(0,r.jsx)("div",{className:"flex items-center gap-1",children:e.keys.split(" ").map((e,t)=>(0,r.jsx)("kbd",{className:"px-1.5 py-0.5 text-2xs rounded border border-border bg-muted text-muted-foreground font-mono min-w-[24px] text-center",children:e},t))})]},e.keys))})]},e))}),(0,r.jsx)("div",{className:"px-5 py-2.5 border-t border-border",children:(0,r.jsxs)("p",{className:"text-2xs text-muted-foreground/60",children:["Press ",(0,r.jsx)("kbd",{className:"px-1 py-0.5 text-2xs rounded border border-border bg-muted font-mono",children:o}),(0,r.jsx)("kbd",{className:"px-1 py-0.5 text-2xs rounded border border-border bg-muted font-mono ml-0.5",children:"?"})," ",n.toggleHint]})})]})})}function r4(){let[e,t]=(0,a.useState)(0),[s,o]=(0,a.useState)(null),[i,d]=(0,a.useState)(!1),c=(0,a.useRef)(0),[m,x]=(0,a.useState)(!1),[p,h]=(0,a.useState)(!1),g=(0,n.usePathname)(),{t:f}=(0,y.Y)();(0,a.useEffect)(()=>{let e=!0,s=async()=>{try{let s=await (0,w.n)("/api/changes?op=summary");e&&t(s.unreadCount)}catch{e&&t(0)}};s();let r=setInterval(()=>void s(),15e3);return()=>{e=!1,clearInterval(r)}},[]),(0,a.useEffect)(()=>{e>c.current&&i&&d(!1),c.current=e},[e,i]);let b=(0,a.useMemo)(()=>!(e<=0||g?.startsWith("/changes"))&&(null===s||!(e<=s))&&!i,[s,g,e,i]);async function v(){try{await (0,w.n)("/api/changes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({op:"mark_seen"})})}catch{}finally{t(0),o(0)}}return((0,a.useEffect)(()=>{if(!b)return;let e=setTimeout(()=>d(!0),1e4);return()=>clearTimeout(e)},[b]),(0,a.useEffect)(()=>{if(b){x(!0);let e=requestAnimationFrame(()=>h(!0));return()=>cancelAnimationFrame(e)}h(!1);let e=setTimeout(()=>x(!1),160);return()=>clearTimeout(e)},[b]),m)?(0,r.jsx)("div",{className:`fixed right-3 top-[60px] md:right-6 md:top-4 z-30 transition-all duration-150 ease-out ${p?"opacity-100 translate-y-0 scale-100":"opacity-0 -translate-y-2 scale-[0.98] pointer-events-none"}`,children:(0,r.jsx)("div",{className:"rounded-2xl border bg-card/95 backdrop-blur px-3 py-2.5 shadow-lg min-w-[260px] max-w-[350px]",style:{borderColor:"color-mix(in srgb, var(--amber) 45%, var(--border))",boxShadow:"0 12px 28px color-mix(in srgb, var(--amber) 14%, rgba(0,0,0,.24))"},children:(0,r.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,r.jsx)("span",{className:"inline-flex h-7 w-7 items-center justify-center rounded-full text-[var(--amber)] bg-[var(--amber-subtle)]",children:(0,r.jsx)(tk.A,{size:14})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("p",{className:"text-xs text-foreground font-display whitespace-nowrap",children:f.changes.unreadBanner(e)}),(0,r.jsxs)("div",{className:"mt-1 flex items-center gap-1.5",children:[(0,r.jsx)(l(),{href:"/changes",className:"inline-flex items-center rounded-md px-2.5 py-1 text-xs font-medium bg-[var(--amber)] text-white focus-visible:ring-2 focus-visible:ring-ring hover:opacity-90",children:f.changes.reviewNow}),(0,r.jsx)("button",{type:"button",onClick:()=>void v(),className:"inline-flex items-center rounded-md px-2 py-1 text-xs font-medium bg-muted text-muted-foreground hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:f.changes.markAllRead})]})]}),(0,r.jsx)("button",{type:"button",onClick:()=>o(e),"aria-label":f.changes.dismiss,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/60 focus-visible:ring-2 focus-visible:ring-ring",children:(0,r.jsx)(u.A,{size:14})})]})})}):null}var r6=s(55711);let r8=(0,ep.createServerReference)("70d3fff92e9e59ba3e4cb777730dd47ad8bdb82650",ep.callServer,void 0,ep.findSourceMapURL,"revertSpaceInitAction");function r9(){let[e,t]=(0,a.useState)(null),[s,o]=(0,a.useState)(!1),[l,i]=(0,a.useTransition)(),d=(0,n.useRouter)(),{t:c}=(0,y.Y)(),m=(0,a.useCallback)(()=>{o(!1),setTimeout(()=>t(null),200)},[]),x=(0,a.useCallback)(e=>{let s=e.detail;"working"===s.state?(t(s),requestAnimationFrame(()=>o(!0))):"done"===s.state?(t(e=>e?{...e,state:"done"}:null),d.refresh()):m()},[d,m]);(0,a.useEffect)(()=>(window.addEventListener("mindos:ai-init",x),()=>window.removeEventListener("mindos:ai-init",x)),[x]);let p=(0,a.useCallback)(()=>{e&&(m(),d.push(`/view/${(0,ea.O0)(e.spacePath+"/")}`))},[e,m,d]),h=(0,a.useCallback)(()=>{e&&i(async()=>{await r8(e.spacePath,e.spaceName,e.description),t(e=>e?{...e,state:"reverted"}:null),d.refresh(),window.dispatchEvent(new Event("mindos:files-changed")),setTimeout(m,2e3)})},[e,d,m]),g=(0,a.useCallback)(()=>{m()},[m]);if(!e)return null;let f=c.home,{state:b}=e,v="done"===b,j="reverted"===b;return(0,r.jsx)("div",{className:`fixed bottom-6 left-1/2 z-50 -translate-x-1/2 transition-all duration-200 ease-out ${s?"opacity-100 translate-y-0 scale-100":"opacity-0 translate-y-3 scale-[0.96] pointer-events-none"}`,children:(0,r.jsxs)("div",{className:"flex items-center gap-2.5 rounded-full border bg-card/95 backdrop-blur py-2 shadow-lg",style:{borderColor:"color-mix(in srgb, var(--amber) 40%, var(--border))",boxShadow:"0 8px 24px color-mix(in srgb, var(--amber) 12%, rgba(0,0,0,.2))",paddingLeft:"0.75rem",paddingRight:v?"0.5rem":"1rem"},children:[(0,r.jsx)("span",{className:`inline-flex h-6 w-6 items-center justify-center rounded-full shrink-0 ${j?"text-muted-foreground bg-muted":"text-[var(--amber)] bg-[var(--amber-subtle)]"} ${"working"===b?"animate-pulse":""}`,children:j?(0,r.jsx)(r6.A,{size:12}):v?(0,r.jsx)(z.A,{size:13,strokeWidth:2.5}):(0,r.jsx)(tL.A,{size:13})}),(0,r.jsx)("span",{className:"text-xs text-foreground whitespace-nowrap select-none font-medium",children:j?f.aiInitReverted(e.spaceName):v?f.aiInitReady(e.spaceName):(0,r.jsxs)(r.Fragment,{children:[f.aiInitGenerating(e.spaceName),(0,r.jsx)(r7,{})]})}),v&&(0,r.jsxs)("div",{className:"flex items-center gap-1 ml-1",children:[(0,r.jsx)("button",{type:"button",onClick:p,className:"px-2.5 py-1 rounded-full text-2xs font-medium bg-[var(--amber)] text-white hover:opacity-90 transition-opacity focus-visible:ring-2 focus-visible:ring-ring",children:f.aiInitReview}),(0,r.jsx)("button",{type:"button",onClick:h,disabled:l,className:"px-2.5 py-1 rounded-full text-2xs font-medium bg-muted text-muted-foreground hover:text-foreground transition-colors focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",children:f.aiInitDiscard}),(0,r.jsx)("button",{type:"button",onClick:g,"aria-label":"Accept",className:"ml-0.5 inline-flex h-5 w-5 items-center justify-center rounded-full text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors focus-visible:ring-2 focus-visible:ring-ring",children:(0,r.jsx)(u.A,{size:12})})]})]})})}function r7(){return(0,r.jsxs)("span",{className:"inline-flex gap-[2px] items-end h-[1em] ml-px",children:[(0,r.jsx)("span",{className:"w-[3px] h-[3px] rounded-full bg-muted-foreground animate-[dotBounce_1.2s_0ms_infinite]"}),(0,r.jsx)("span",{className:"w-[3px] h-[3px] rounded-full bg-muted-foreground animate-[dotBounce_1.2s_200ms_infinite]"}),(0,r.jsx)("span",{className:"w-[3px] h-[3px] rounded-full bg-muted-foreground animate-[dotBounce_1.2s_400ms_infinite]"}),(0,r.jsx)("style",{children:`
|
|
132
|
-
@keyframes dotBounce {
|
|
133
|
-
0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
|
|
134
|
-
30% { opacity: 1; transform: translateY(-2px); }
|
|
135
|
-
}
|
|
136
|
-
`})]})}var ne=s(3926),nt=s(78916),ns=s(78520);function nr(e,t){let s=e.fileImport;if(!t)return s.organizeProcessing;switch(t.stage){case"connecting":return s.organizeConnecting;case"analyzing":return s.organizeAnalyzing;case"reading":return s.organizeReading(t.detail);case"thinking":return s.organizeThinking;case"writing":return s.organizeWriting(t.detail);default:return s.organizeProcessing}}function nn({aiOrganize:e,onDismiss:t,onCancel:s,onHistoryUpdate:o}){let{t:l}=(0,y.Y)(),i=(0,n.useRouter)(),d=l.fileImport,c="organizing"===e.phase,{elapsed:m,displayHint:x}=function(e,t){let[s,r]=(0,a.useState)(0),[n,o]=(0,a.useState)(!1),l=(0,a.useRef)(Date.now());return(0,a.useEffect)(()=>{l.current=Date.now(),o(!1)},[t]),(0,a.useEffect)(()=>{if(!e){r(0),o(!1);return}let t=setInterval(()=>{r(e=>e+1),Date.now()-l.current>=5e3&&o(!0)},1e3);return()=>clearInterval(t)},[e]),{elapsed:s,displayHint:n?{stage:"thinking"}:t}}(c,e.stageHint),[p,h]=(0,a.useState)(!1),[g,f]=(0,a.useState)(!1),[b,v]=(0,a.useState)(!1),j=(0,a.useRef)(null),N=(0,a.useRef)(null),k="done"===e.phase,w="error"===e.phase,A=c||k||w,E=e.changes.filter(e=>e.ok&&!e.undone).length;(0,a.useEffect)(()=>{c&&(N.current=null)},[c]),(0,a.useEffect)(()=>{if(k&&!N.current){let t=(0,ns.jQ)();N.current=t,(0,ns.D4)({id:t,timestamp:Date.now(),sourceFiles:e.sourceFileNames,files:e.changes.map(e=>({action:e.action,path:e.path,ok:e.ok,undone:e.undone})),status:"completed",source:e.source,durationMs:e.durationMs}),o?.()}},[k,e.changes,e.sourceFileNames,e.source,e.durationMs,o]);let T=(0,a.useCallback)(()=>{j.current&&clearTimeout(j.current),(k||w)&&(j.current=setTimeout(()=>{t()},18e4))},[k,w,t]);(0,a.useEffect)(()=>(T(),()=>{j.current&&clearTimeout(j.current)}),[T]);let $=(0,a.useCallback)(()=>{T()},[T]),R=(0,a.useCallback)(async t=>{$(),v(!0);let s=await e.undoOne(t);v(!1),s&&(window.dispatchEvent(new Event("mindos:files-changed")),setTimeout(()=>{if(N.current){let s=e.changes.map(e=>({action:e.action,path:e.path,ok:e.ok,undone:e.path===t||e.undone})),r=s.every(e=>!e.ok||e.undone);(0,ns.W8)(N.current,{files:s,status:r?"undone":"partial"}),o?.()}},0))},[e,$,o]),M=(0,a.useCallback)(async()=>{$(),v(!0);let t=await e.undoAll();v(!1),t>0&&(window.dispatchEvent(new Event("mindos:files-changed")),N.current&&((0,ns.W8)(N.current,{files:e.changes.map(e=>({action:e.action,path:e.path,ok:e.ok,undone:!!e.ok||e.undone})),status:"undone"}),o?.()))},[e,$,o]),D=(0,a.useCallback)(e=>{$(),i.push(`/view/${(0,ea.O0)(e)}`)},[i,$]),I=(0,a.useCallback)(()=>{t()},[t]);if(!A)return null;function L(t,s){let n=t.undone,a=e.canUndo(t.path),o=t.path.split("/").pop()??t.path;return(0,r.jsxs)("div",{className:`flex items-center gap-2 px-3 py-2 rounded-md text-sm transition-colors ${n?"bg-muted/30 opacity-50":"bg-muted/50"}`,children:[n?(0,r.jsx)(r6.A,{size:14,className:"text-muted-foreground shrink-0"}):"create"===t.action?(0,r.jsx)(st.A,{size:14,className:"text-success shrink-0"}):(0,r.jsx)(ne.A,{size:14,className:"text-[var(--amber)] shrink-0"}),(0,r.jsx)("span",{className:`truncate flex-1 ${n?"line-through text-muted-foreground":"text-foreground"}`,children:o}),n?(0,r.jsx)("span",{className:"text-xs text-muted-foreground shrink-0",children:d.organizeUndone}):(0,r.jsx)("span",{className:`text-xs shrink-0 ${t.ok?"text-muted-foreground":"text-error"}`,children:t.ok?"create"===t.action?d.organizeCreated:d.organizeUpdated:d.organizeFailed}),a&&(0,r.jsx)("button",{type:"button",onClick:()=>R(t.path),disabled:b,className:"text-2xs text-muted-foreground/60 hover:text-foreground transition-colors shrink-0 px-1 disabled:opacity-40",title:d.organizeUndoOne,children:(0,r.jsx)(r6.A,{size:12})}),t.ok&&!t.undone&&(0,r.jsx)("button",{type:"button",onClick:()=>D(t.path),className:"text-2xs text-muted-foreground/60 hover:text-[var(--amber)] transition-colors shrink-0 px-1",title:d.organizeViewFile,children:(0,r.jsx)(s4.A,{size:12})})]},`${t.path}-${s}`)}function P(){return(0,r.jsxs)("div",{className:"flex items-center justify-end gap-3 px-4 py-3 border-t border-border",children:[k&&e.hasAnyUndoable&&(0,r.jsxs)("button",{onClick:M,disabled:b,className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors px-2 py-1.5 disabled:opacity-50",children:[b?(0,r.jsx)(C.A,{size:12,className:"animate-spin"}):(0,r.jsx)(r6.A,{size:12}),d.organizeUndoAll]}),(0,r.jsxs)("button",{onClick:I,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium bg-[var(--amber)] text-[var(--amber-foreground)] hover:opacity-90 transition-all",children:[(0,r.jsx)(z.A,{size:12}),d.organizeDone]})]})}return g?(0,r.jsx)("div",{className:"fixed inset-0 z-50 overlay-backdrop flex items-center justify-center p-4",onClick:e=>{e.target===e.currentTarget&&f(!1)},children:(0,r.jsxs)("div",{className:"w-full max-w-xl max-h-[80vh] flex flex-col bg-card rounded-xl shadow-xl border border-border animate-in fade-in-0 zoom-in-95 duration-200",onClick:$,role:"dialog","aria-modal":"true","aria-label":d.organizeDetailTitle,children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-5 pt-5 pb-3 shrink-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[c?(0,r.jsxs)("div",{className:"relative shrink-0",children:[(0,r.jsx)(tL.A,{size:16,className:"text-[var(--amber)]"}),(0,r.jsx)(C.A,{size:10,className:"absolute -bottom-0.5 -right-0.5 text-[var(--amber)] animate-spin"})]}):k?(0,r.jsx)(z.A,{size:16,className:"text-success"}):(0,r.jsx)(S.A,{size:16,className:"text-error"}),(0,r.jsx)("h2",{className:"text-base font-semibold text-foreground",children:d.organizeDetailTitle}),c&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground/60 tabular-nums",children:d.organizeElapsed(m)})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("button",{type:"button",onClick:()=>f(!1),className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:d.organizeMinimizeModal,children:(0,r.jsx)(eK.A,{size:14})}),(0,r.jsx)("button",{type:"button",onClick:I,className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",children:(0,r.jsx)(u.A,{size:14})})]})]}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto px-5 pb-2 space-y-4",children:[c&&(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2.5 rounded-lg bg-[var(--amber-subtle)] border border-[var(--amber-dim)]",children:[(0,r.jsx)(C.A,{size:14,className:"text-[var(--amber)] animate-spin shrink-0"}),(0,r.jsx)("span",{className:"text-xs text-foreground",children:nr(l,x)})]}),e.sourceFileNames.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-xs font-medium text-muted-foreground mb-1.5",children:d.organizeSourceFiles}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:e.sourceFileNames.map((e,t)=>(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded-md bg-muted/60 text-xs text-foreground",children:[(0,r.jsx)(nt.A,{size:11,className:"text-muted-foreground shrink-0"}),e]},t))})]}),(e.summary||c)&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-xs font-medium text-muted-foreground mb-1.5",children:d.organizeSummaryLabel}),(0,r.jsx)("div",{className:"px-3 py-2.5 rounded-lg bg-muted/30 border border-border text-sm text-foreground leading-relaxed whitespace-pre-wrap",children:e.summary||d.organizeNoSummary})]}),e.changes.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-xs font-medium text-muted-foreground mb-1.5",children:d.organizeChangesLabel(e.changes.length)}),(0,r.jsx)("div",{className:"space-y-0.5",children:e.changes.map((e,t)=>L(e,t))})]}),w&&(0,r.jsx)("div",{className:"px-3 py-2.5 rounded-lg bg-error/5 border border-error/20 text-xs text-error",children:e.error})]}),(k||w)&&P()]})}):p&&(k||w)?(0,r.jsxs)("div",{className:"fixed bottom-4 left-1/2 -translate-x-1/2 z-50 w-[420px] max-w-[calc(100vw-2rem)] bg-card border border-border rounded-xl shadow-xl animate-in fade-in-0 slide-in-from-bottom-2 duration-200",onClick:$,children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[k?(0,r.jsx)(z.A,{size:14,className:"text-success"}):(0,r.jsx)(S.A,{size:14,className:"text-error"}),(0,r.jsx)("span",{className:"text-xs font-medium text-foreground",children:k?d.organizeReviewTitle:d.organizeErrorTitle})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("button",{type:"button",onClick:()=>{h(!1),f(!0)},className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:d.organizeDetailTitle,children:(0,r.jsx)(eG.A,{size:13})}),(0,r.jsx)("button",{type:"button",onClick:()=>h(!1),className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",children:(0,r.jsx)(eu.A,{size:14})})]})]}),k&&(0,r.jsx)("div",{className:"max-h-[240px] overflow-y-auto p-2 space-y-0.5",children:e.changes.map((e,t)=>L(e,t))}),w&&(0,r.jsx)("div",{className:"p-4 text-center",children:(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:e.error})}),P()]}):(0,r.jsx)("div",{className:"fixed bottom-4 left-1/2 -translate-x-1/2 z-50 flex items-center gap-3 bg-card border border-border rounded-xl shadow-lg px-4 py-3 max-w-md animate-in fade-in-0 slide-in-from-bottom-2 duration-200",onClick:$,children:k?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(z.A,{size:16,className:"text-success shrink-0"}),(0,r.jsx)("span",{className:"text-xs text-foreground truncate",children:d.organizeReviewDesc(E)}),e.changes.length>0&&(0,r.jsxs)("button",{type:"button",onClick:()=>{h(!0),$()},className:"flex items-center gap-1 text-xs font-medium text-[var(--amber)] hover:opacity-80 transition-colors shrink-0",children:[(0,r.jsx)(eu.A,{size:12,className:"rotate-180"}),d.organizeExpand]}),(0,r.jsxs)("button",{type:"button",onClick:I,className:"flex items-center gap-1 text-xs font-medium text-[var(--amber)] hover:opacity-80 transition-colors shrink-0",children:[(0,r.jsx)(z.A,{size:12}),d.organizeDone]})]}):w?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(S.A,{size:16,className:"text-error shrink-0"}),(0,r.jsx)("span",{className:"text-xs text-foreground truncate",children:d.organizeError}),(0,r.jsx)("button",{type:"button",onClick:()=>{h(!0),$()},className:"text-xs font-medium text-[var(--amber)] hover:opacity-80 transition-colors shrink-0",children:d.organizeExpand}),(0,r.jsx)("button",{type:"button",onClick:I,className:"text-muted-foreground/50 hover:text-muted-foreground transition-colors shrink-0",children:(0,r.jsx)(u.A,{size:14})})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"relative shrink-0",children:[(0,r.jsx)(tL.A,{size:16,className:"text-[var(--amber)]"}),(0,r.jsx)(C.A,{size:10,className:"absolute -bottom-0.5 -right-0.5 text-[var(--amber)] animate-spin"})]}),(0,r.jsx)("span",{className:"text-xs text-foreground truncate",children:nr(l,x)}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground/60 tabular-nums shrink-0",children:d.organizeElapsed(m)}),(0,r.jsx)("button",{type:"button",onClick:()=>{f(!0),$()},className:"text-muted-foreground/50 hover:text-muted-foreground transition-colors shrink-0",title:d.organizeDetailTitle,children:(0,r.jsx)(eG.A,{size:13})}),(0,r.jsx)("button",{type:"button",onClick:I,className:"text-muted-foreground/50 hover:text-muted-foreground transition-colors shrink-0",children:(0,r.jsx)(u.A,{size:14})})]})})}let na=(0,ep.createServerReference)("70cf5e0fa72b001245332ed28b4e48a98d03cd4580",ep.callServer,void 0,ep.findSourceMapURL,"createSpaceAction");var no=s(70620);function nl({t:e,dirPaths:t}){let s=(0,n.useRouter)(),[o,l]=(0,a.useState)(!1),[i,d]=(0,a.useState)(""),[c,m]=(0,a.useState)(""),[x,p]=(0,a.useState)(""),[h,g]=(0,a.useState)(!1),[f,b]=(0,a.useState)(""),[v,j]=(0,a.useState)(""),[y,N]=(0,a.useState)(null),[k,w]=(0,a.useState)(!0),S=(0,a.useRef)(null);(0,a.useEffect)(()=>{let e=()=>{l(!0),b(""),j(""),setTimeout(()=>S.current?.focus(),80)};return window.addEventListener("mindos:create-space",e),()=>window.removeEventListener("mindos:create-space",e)},[]),(0,a.useEffect)(()=>{o&&null===y&&eC().then(e=>{N(e),w(e)})},[o,y]);let A=(0,a.useCallback)(()=>{l(!1),d(""),m(""),p(""),b(""),j(""),N(null)},[]),z=(0,a.useCallback)(t=>t.includes("/")||t.includes("\\")?(j(e.home.spaceNameNoSlash??"Name cannot contain / or \\"),!1):(j(""),!0),[e]),E=(0,a.useMemo)(()=>{let e=i.trim();return e?(x?x+"/":"")+e+"/":""},[i,x]),T=(0,a.useCallback)(async()=>{if(!i.trim()||h||!z(i))return;g(!0),b("");let t=i.trim(),r=await na(t,c,x);if(r.success){let e=r.path??t;k&&y&&eA(t,e,c),A(),s.refresh(),window.dispatchEvent(new Event("mindos:files-changed")),s.push(`/view/${(0,ea.O0)(e+"/")}`)}else(r.error??"").includes("already exists")?b(e.home.spaceExists??"A space with this name already exists"):b(e.home.spaceCreateFailed??"Failed to create space");g(!1)},[i,c,x,h,A,s,e,z,k,y]),$=(0,a.useCallback)(e=>{"Escape"===e.key&&A(),"Enter"===e.key&&!e.shiftKey&&e.target instanceof HTMLInputElement&&(e.preventDefault(),T())},[A,T]);if(!o)return null;let R=e.home;return(0,tI.createPortal)((0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onKeyDown:$,children:[(0,r.jsx)("div",{className:"absolute inset-0 overlay-backdrop",onClick:A}),(0,r.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":R.newSpace,className:"relative w-full max-w-md mx-4 rounded-2xl border border-border bg-card shadow-xl",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-5 pt-5 pb-3",children:[(0,r.jsx)("h3",{className:"text-base font-semibold text-foreground",children:R.newSpace}),(0,r.jsx)("button",{onClick:A,className:"p-1 rounded-md text-muted-foreground hover:bg-muted transition-colors",children:(0,r.jsx)(u.A,{size:14})})]}),(0,r.jsxs)("div",{className:"px-5 pb-5 flex flex-col gap-3",children:[(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:R.spaceLocation??"Location"}),(0,r.jsx)(no.A,{dirPaths:t,value:x,onChange:p,rootLabel:R.rootLevel??"Root"})]}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:R.spaceName}),(0,r.jsx)("input",{ref:S,type:"text",value:i,onChange:e=>{d(e.target.value),b(""),z(e.target.value)},placeholder:"e.g. \uD83D\uDCDD Notes",maxLength:80,"aria-invalid":!!v,"aria-describedby":v?"space-name-hint":void 0,className:`w-full px-3 py-2 text-sm rounded-lg border bg-background outline-none transition-colors ${v?"border-error focus:border-error":"border-border focus-visible:ring-1 focus-visible:ring-ring"}`}),v&&(0,r.jsx)("span",{id:"space-name-hint",className:"text-xs text-error",children:v})]}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)("label",{className:"text-xs font-medium text-muted-foreground",children:[R.spaceDescription," ",(0,r.jsxs)("span",{className:"opacity-50",children:["(",R.optional??"optional",")"]})]}),(0,r.jsx)("input",{type:"text",value:c,onChange:e=>m(e.target.value),placeholder:R.spaceDescPlaceholder??"Describe the purpose of this space",maxLength:200,className:"w-full px-3 py-2 text-sm rounded-lg border border-border bg-background text-foreground placeholder:text-muted-foreground outline-none focus-visible:ring-1 focus-visible:ring-ring transition-colors"})]}),(0,r.jsxs)("div",{className:"flex items-start gap-2.5 px-1 py-1",children:[(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":k,disabled:!y,title:y?void 0:e.hints.configureAiKey,onClick:()=>w(e=>!e),className:`relative mt-0.5 inline-flex shrink-0 h-4 w-7 cursor-pointer rounded-full border-2 border-transparent transition-colors focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 ${k?"bg-[var(--amber)]":"bg-muted"}`,children:(0,r.jsx)("span",{className:`pointer-events-none inline-block h-3 w-3 rounded-full bg-white shadow-sm transition-transform ${k?"translate-x-3":"translate-x-0"}`})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)(tL.A,{size:12,className:"text-[var(--amber)] shrink-0"}),(0,r.jsx)("span",{className:"text-xs font-medium text-foreground",children:R.aiInit??"AI initialize content"})]}),!1===y&&(0,r.jsxs)("p",{className:"text-2xs text-muted-foreground mt-0.5 flex items-center gap-1",children:[(0,r.jsx)(tT.A,{size:10,className:"text-[var(--amber)] shrink-0"}),R.aiInitNoKey??"Configure an API key in Settings → AI to enable"]}),y&&k&&(0,r.jsx)("p",{className:"text-2xs text-muted-foreground mt-0.5",children:R.aiInitHint??"AI will generate README and INSTRUCTION for this space"})]})]}),E&&(0,r.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground font-mono px-1",children:[(0,r.jsx)(ex.A,{size:12,className:"shrink-0 text-[var(--amber)]"}),(0,r.jsx)("span",{className:"truncate",children:E})]}),f&&(0,r.jsx)("span",{role:"alert",className:"text-xs text-error px-1",children:f}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2 pt-1",children:[(0,r.jsx)("button",{onClick:A,className:"px-4 py-2 rounded-lg text-sm font-medium text-muted-foreground transition-colors hover:bg-muted",children:R.cancelCreate}),(0,r.jsxs)("button",{onClick:T,disabled:!i.trim()||h||!!v,className:"flex items-center gap-1.5 px-4 py-2 rounded-lg text-sm font-medium bg-[var(--amber)] text-[var(--amber-foreground)] transition-colors hover:opacity-90 disabled:opacity-50 disabled:cursor-not-allowed",children:[h&&(0,r.jsx)(C.A,{size:14,className:"animate-spin"}),R.createSpace]})]})]})]})]}),document.body)}function ni(){return(0,a.useEffect)(()=>e2.zd.getState()._init(),[]),null}var nd=s(1934),nc=s(76449);let nu="mindos_walkthrough_done";function nm(e,t){if(e>=nc.g.length||t)try{localStorage.setItem(nu,"1")}catch{}fetch("/api/setup",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({guideState:{walkthroughStep:e,walkthroughDismissed:t}})}).catch(e=>{console.warn("[walkthrough-store] persist failed:",e)})}let nx=(0,nd.v)((e,t)=>{let s=nc.g.length;return{status:"idle",currentStep:0,totalSteps:s,start:()=>{e({currentStep:0,status:"active"}),nm(0,!1)},next:()=>{let r=t().currentStep+1;r>=s?(e({status:"completed"}),nm(s,!1)):(e({currentStep:r}),nm(r,!1))},back:()=>{let s=t().currentStep;s>0&&(e({currentStep:s-1}),nm(s-1,!1))},skip:()=>{e({status:"dismissed"}),nm(t().currentStep,!0)},_init:()=>{let t="1"===new URLSearchParams(window.location.search).get("welcome");if(t){let e=new URL(window.location.href);e.searchParams.delete("welcome"),window.history.replaceState({},"",e.pathname+(e.search||"")),window.dispatchEvent(new Event("mindos:first-visit"))}return window.innerWidth<768||function(){try{return"1"===localStorage.getItem(nu)}catch{return!1}}()?()=>{}:(fetch("/api/setup").then(e=>e.json()).then(r=>{let n=r.guideState;if(n){if(n.walkthroughDismissed||"number"==typeof n.walkthroughStep&&n.walkthroughStep>=s){try{localStorage.setItem(nu,"1")}catch{}return}n.active&&!n.dismissed&&void 0===n.walkthroughStep?t&&e({status:"active",currentStep:0}):"number"==typeof n.walkthroughStep&&n.walkthroughStep>=0&&n.walkthroughStep<s&&!n.walkthroughDismissed&&e({status:"active",currentStep:n.walkthroughStep})}}).catch(e=>{console.warn("[walkthrough-store] guideState read failed:",e)}),()=>{})}}});function np({stepIndex:e,rect:t,position:s}){let n,o,l=nx(),{t:i}=(0,y.Y)(),[d,c]=(0,a.useState)({width:1024,height:768});if((0,a.useEffect)(()=>{let e=()=>c({width:window.innerWidth,height:window.innerHeight});return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),!l)return null;let u=i.walkthrough.steps[e];if(!u)return null;"right"===s?(n=t.top+t.height/2,o=t.right+12):(n=t.bottom+12,o=t.left+t.width/2);let m=d.width-320,x=d.height-200;return o=Math.min(o,m),n=Math.max(n=Math.min(n,x),8),(0,r.jsxs)("div",{className:"fixed z-[102] w-[280px] rounded-xl border shadow-lg animate-in fade-in slide-in-from-left-2 duration-200",style:{top:`${n}px`,left:`${o}px`,transform:"right"===s?"translateY(-50%)":"translateX(-50%)",background:"var(--card)",borderColor:"var(--amber)"},children:[(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)("div",{className:"flex items-center gap-2 mb-2",children:(0,r.jsx)("span",{className:"text-2xs font-mono px-1.5 py-0.5 rounded-full",style:{background:"var(--amber-dim)",color:"var(--amber)"},children:i.walkthrough.step(e+1,l.totalSteps)})}),(0,r.jsx)("h3",{className:"text-sm font-semibold mb-1",style:{color:"var(--foreground)"},children:u.title}),(0,r.jsx)("p",{className:"text-xs leading-relaxed",style:{color:"var(--muted-foreground)"},children:u.body}),(0,r.jsxs)("div",{className:"flex items-center justify-between mt-4 pt-3",style:{borderTop:"1px solid var(--border)"},children:[(0,r.jsx)("button",{onClick:l.skip,className:"text-xs transition-colors hover:opacity-80",style:{color:"var(--muted-foreground)"},children:i.walkthrough.skip}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[e>0&&(0,r.jsx)("button",{onClick:l.back,className:"text-xs px-2.5 py-1 rounded-lg transition-colors hover:bg-muted",style:{color:"var(--muted-foreground)"},children:i.walkthrough.back}),(0,r.jsx)("button",{onClick:l.next,className:"text-xs px-3 py-1.5 rounded-lg font-medium transition-all hover:opacity-90",style:{background:"var(--amber)",color:"var(--amber-foreground)"},children:e===l.totalSteps-1?i.walkthrough.done:i.walkthrough.next})]})]})]}),(0,r.jsx)("div",{className:"flex items-center justify-center gap-1.5 pb-3",children:Array.from({length:l.totalSteps},(t,s)=>(0,r.jsx)("div",{className:"w-1.5 h-1.5 rounded-full transition-all duration-200",style:{background:s===e?"var(--amber)":"var(--border)",transform:s===e?"scale(1.3)":void 0}},s))})]})}function nh(){let e=nx(),[t,s]=(0,a.useState)(null),[n,o]=(0,a.useState)(!1),l=(0,a.useId)(),i=e?nc.g[e.currentStep]:null,d=(0,a.useCallback)(()=>{if(!i)return;let e=document.querySelector(`[data-walkthrough="${i.anchor}"]`);e?s(e.getBoundingClientRect()):s(null)},[i]);(0,a.useEffect)(()=>{o(window.innerWidth<768),d();let e=()=>{o(window.innerWidth<768),d()};return window.addEventListener("resize",e),window.addEventListener("scroll",d,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",d,!0)}},[d]),(0,a.useEffect)(()=>{d();let e=setTimeout(d,100);return()=>clearTimeout(e)},[e?.currentStep,d]);let c=e?.skip;(0,a.useEffect)(()=>{if(!c)return;let e=e=>{"Escape"===e.key&&(e.stopPropagation(),c())};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[c]);let u=e?.currentStep??0;return((0,a.useEffect)(()=>{if(!i)return;let e=setTimeout(()=>{document.querySelector(`[data-walkthrough="${i.anchor}"]`)||nx.getState().next()},500);return()=>clearTimeout(e)},[u]),(0,a.useEffect)(()=>{let e=setTimeout(()=>{nx.getState().skip()},6e4);return()=>clearTimeout(e)},[u]),e&&i)?n?(0,r.jsx)(ng,{}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("svg",{className:"fixed inset-0 z-[100] pointer-events-auto",width:"100%",height:"100%",onClick:s=>{if(t){let r=s.clientX,n=s.clientY;r>=t.left-6&&r<=t.right+6&&n>=t.top-6&&n<=t.bottom+6||e.skip()}else e.skip()},children:[(0,r.jsx)("defs",{children:(0,r.jsxs)("mask",{id:l,children:[(0,r.jsx)("rect",{width:"100%",height:"100%",fill:"white"}),t&&(0,r.jsx)("rect",{x:t.left-6,y:t.top-6,width:t.width+12,height:t.height+12,rx:8,ry:8,fill:"black"})]})}),(0,r.jsx)("rect",{width:"100%",height:"100%",fill:"rgba(0, 0, 0, 0.5)",mask:`url(#${l})`})]}),t&&(0,r.jsx)(np,{stepIndex:e.currentStep,rect:t,position:i.position}),!t&&(0,r.jsx)("div",{className:"fixed inset-0 z-[101] flex items-center justify-center pointer-events-none",children:(0,r.jsx)("button",{onClick:e.skip,className:"pointer-events-auto px-4 py-2 text-sm rounded-lg font-medium transition-all hover:opacity-90",style:{background:"var(--amber)",color:"var(--amber-foreground)"},children:e.currentStep===e.totalSteps-1?"✓":"→"})})]}):null}function ng(){let e=nx(),{t}=(0,y.Y)();if(!e)return null;let s=t.walkthrough.steps[e.currentStep];return s?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed inset-0 z-[100] bg-black/40 backdrop-blur-sm",onClick:e.skip}),(0,r.jsxs)("div",{className:"fixed bottom-0 left-0 right-0 z-[101] rounded-t-2xl border-t shadow-lg p-5 pb-8 animate-in slide-in-from-bottom duration-300",style:{background:"var(--card)",borderColor:"var(--border)"},children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,r.jsx)("span",{className:"text-2xs font-mono px-1.5 py-0.5 rounded-full",style:{background:"var(--amber-dim)",color:"var(--amber)"},children:t.walkthrough.step(e.currentStep+1,e.totalSteps)}),(0,r.jsx)("div",{className:"flex items-center gap-1 ml-auto",children:Array.from({length:e.totalSteps},(t,s)=>(0,r.jsx)("div",{className:"w-1.5 h-1.5 rounded-full",style:{background:s===e.currentStep?"var(--amber)":"var(--border)"}},s))})]}),(0,r.jsx)("h3",{className:"text-base font-semibold mb-1",style:{color:"var(--foreground)"},children:s.title}),(0,r.jsx)("p",{className:"text-sm leading-relaxed mb-5",style:{color:"var(--muted-foreground)"},children:s.body}),(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("button",{onClick:e.skip,className:"text-sm transition-colors hover:opacity-80",style:{color:"var(--muted-foreground)"},children:t.walkthrough.skip}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[e.currentStep>0&&(0,r.jsx)("button",{onClick:e.back,className:"text-sm px-3 py-2 rounded-lg transition-colors hover:bg-muted",style:{color:"var(--muted-foreground)"},children:t.walkthrough.back}),(0,r.jsx)("button",{onClick:e.next,className:"text-sm px-4 py-2 rounded-lg font-medium transition-all hover:opacity-90",style:{background:"var(--amber)",color:"var(--amber-foreground)"},children:e.currentStep===e.totalSteps-1?t.walkthrough.done:t.walkthrough.next})]})]})]})]}):null}function nf(){return(0,a.useEffect)(()=>nx.getState()._init(),[]),"active"===nx(e=>e.status)?(0,r.jsx)(nh,{}):null}let nb=new Set(["mp3","wav","m4a","ogg","flac","aac"]),nv=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico"]),nj=new Set(["mp4","webm","mov","mkv"]);for(let e of[{id:"agent-inspector",name:"Agent Inspector",description:"Visualizes agent tool-call logs as a filterable timeline. Auto-activates on .mindos/agent-audit-log.json and supports legacy .agent-log.json.",author:"MindOS",icon:"\uD83D\uDD0D",tags:["agent","inspector","log","mcp","tools"],builtin:!0,core:!0,appBuiltinFeature:!0,entryPath:".mindos/agent-audit-log.json",match:({filePath:e})=>/(^|\/)\.mindos\/agent-audit-log\.json$/i.test(e)||/\.agent-log\.json$/i.test(e),load:()=>Promise.resolve().then(s.bind(s,18847)).then(e=>({default:e.AgentInspectorRenderer}))},{id:"audio",name:"Audio Player",description:"Plays audio files with native browser controls.",author:"MindOS",icon:"\uD83C\uDFB5",tags:["audio","music","voice","mp3","wav"],builtin:!0,core:!0,appBuiltinFeature:!0,match:({extension:e})=>nb.has(e),load:()=>Promise.resolve().then(s.bind(s,14446)).then(e=>({default:e.AudioRenderer}))},{id:"backlinks",name:"Backlinks Explorer",description:"Shows all files that link to the current page via wikilinks or markdown links, with highlighted snippet context.",author:"MindOS",icon:"\uD83D\uDD17",tags:["backlinks","wiki","links","references"],builtin:!0,entryPath:"BACKLINKS.md",match:({filePath:e})=>/\bBACKLINKS\b.*\.md$/i.test(e),load:()=>Promise.resolve().then(s.bind(s,88946)).then(e=>({default:e.BacklinksRenderer}))},{id:"config-panel",name:"Config Panel",description:"Renders CONFIG.json as an editable control panel based on uiSchema/keySpecs. Changes are written back to the JSON file directly.",author:"MindOS",icon:"\uD83E\uDDE9",tags:["config","json","settings","schema"],builtin:!0,core:!0,appBuiltinFeature:!0,entryPath:"CONFIG.json",match:({filePath:e,extension:t})=>"json"===t&&/(^|\/)CONFIG\.json$/i.test(e),load:()=>Promise.resolve().then(s.bind(s,35504)).then(e=>({default:e.ConfigRenderer}))},{id:"csv",name:"CSV Views",description:"Renders any CSV file as Table, Gallery, or Board. Each view is independently configurable — choose which columns map to title, description, tag, and group.",author:"MindOS",icon:"\uD83D\uDCCA",tags:["csv","table","gallery","board","data"],builtin:!0,core:!0,appBuiltinFeature:!0,entryPath:"Resources/Products.csv",match:({extension:e,filePath:t})=>"csv"===e&&!/\bTODO\b/i.test(t),load:()=>Promise.resolve().then(s.bind(s,92306)).then(e=>({default:e.CsvRenderer}))},{id:"image",name:"Image Viewer",description:"Renders image files with zoom, fit-to-view, and transparency support.",author:"MindOS",icon:"\uD83D\uDDBC",tags:["image","photo","viewer","png","jpg","svg"],builtin:!0,core:!0,appBuiltinFeature:!0,match:({extension:e})=>nv.has(e),load:()=>Promise.resolve().then(s.bind(s,20814)).then(e=>({default:e.ImageRenderer}))},{id:"pdf",name:"PDF Viewer",description:"Renders PDF files using the browser built-in PDF viewer.",author:"MindOS",icon:"\uD83D\uDCC4",tags:["pdf","document","viewer"],builtin:!0,core:!0,appBuiltinFeature:!0,match:({extension:e})=>"pdf"===e,load:()=>Promise.resolve().then(s.bind(s,20870)).then(e=>({default:e.PdfRenderer}))},{id:"summary",name:"AI Briefing",description:"Streams an AI-generated daily briefing summarizing your most recently modified files — key changes, recurring themes, and suggested next actions.",author:"MindOS",icon:"✨",tags:["ai","summary","briefing","daily"],builtin:!0,entryPath:"DAILY.md",match:({filePath:e})=>/\b(SUMMARY|summary|Summary|BRIEFING|briefing|Briefing|DAILY|daily|Daily)\b.*\.md$/i.test(e),load:()=>Promise.resolve().then(s.bind(s,56406)).then(e=>({default:e.SummaryRenderer}))},{id:"timeline",name:"Timeline",description:"Renders changelog and journal files as a vertical timeline. Any markdown with ## date headings (e.g. ## 2025-01-15) becomes a card in the feed.",author:"MindOS",icon:"\uD83D\uDCC5",tags:["timeline","changelog","journal","history"],builtin:!0,entryPath:"CHANGELOG.md",match:({filePath:e})=>/\b(CHANGELOG|changelog|TIMELINE|timeline|journal|Journal|diary|Diary)\b.*\.md$/i.test(e),load:()=>Promise.resolve().then(s.bind(s,39594)).then(e=>({default:e.TimelineRenderer}))},{id:"todo",name:"TODO Board",description:"Renders TODO.md/TODO.csv as an interactive kanban board grouped by section. Check items off directly — changes are written back to the source file.",author:"MindOS",icon:"✅",tags:["productivity","tasks","markdown"],builtin:!0,core:!0,appBuiltinFeature:!0,entryPath:"TODO.md",match:({filePath:e})=>/\bTODO\b.*\.(md|csv)$/i.test(e),load:()=>Promise.resolve().then(s.bind(s,87500)).then(e=>({default:e.TodoRenderer}))},{id:"video",name:"Video Player",description:"Plays video files with native browser controls.",author:"MindOS",icon:"\uD83C\uDFAC",tags:["video","movie","recording","mp4","webm"],builtin:!0,core:!0,appBuiltinFeature:!0,match:({extension:e})=>nj.has(e),load:()=>Promise.resolve().then(s.bind(s,87986)).then(e=>({default:e.VideoRenderer}))},{id:"workflow-yaml",name:"Workflow Runner",description:"Execute step-by-step YAML workflows with Skills & Agent support.",author:"MindOS",icon:"⚡",tags:["workflow","automation","steps","ai","yaml"],builtin:!0,core:!0,appBuiltinFeature:!0,entryPath:".mindos/workflows/",match:({extension:e,filePath:t})=>("yaml"===e||"yml"===e)&&/\.flow\.(yaml|yml)$/i.test(t),load:()=>Promise.resolve().then(s.bind(s,48133)).then(e=>({default:e.WorkflowYamlRenderer}))},{id:"graph",name:"Wiki Graph",description:"Force-directed graph of wikilink references across all markdown files. Supports Global and Local (2-hop) scope filters.",author:"MindOS",icon:"\uD83D\uDD78️",tags:["graph","wiki","links","visualization"],builtin:!0,match:()=>!1,load:()=>Promise.resolve().then(s.bind(s,92950)).then(e=>({default:e.GraphRenderer}))}])(0,tg.TS)(e);var ny=s(29494);let nN=(0,rk.default)(()=>s.e(1814).then(s.bind(s,51814)),{loadableGenerated:{webpack:()=>[51814]},ssr:!1});function nk({fileTree:e,children:t}){let s=function(){let[e,t]=(0,a.useState)("files"),[s,r]=(0,a.useState)(null),[n,o]=(0,a.useState)(!1),[l,i]=(0,a.useState)(!1);(0,a.useEffect)(()=>{try{"true"===localStorage.getItem("rail-expanded")&&i(!0)}catch{}},[]),(0,a.useEffect)(()=>{if(e){try{let e=localStorage.getItem("left-panel-width");if(e){let t=parseInt(e,10);if(t>=240&&t<=600)return void r(t)}}catch{}r(280)}},[e]),(0,a.useEffect)(()=>{o(!1)},[e]);let d=(0,a.useCallback)(e=>r(e),[]),c=(0,a.useCallback)(e=>{try{localStorage.setItem("left-panel-width",String(e))}catch{}},[]),u=(0,a.useCallback)(()=>o(e=>!e),[]),m=(0,a.useCallback)(e=>{i(e);try{localStorage.setItem("rail-expanded",String(e))}catch{}},[]),x=null!==e,p=s??(e?eZ[e]:280);return{activePanel:e,setActivePanel:t,panelWidth:s,panelMaximized:n,railExpanded:l,railWidth:l?180:48,panelOpen:x,effectivePanelWidth:p,handlePanelWidthChange:d,handlePanelWidthCommit:c,handlePanelMaximize:u,handleExpandedChange:m}}(),o=function(){let[e,t]=(0,a.useState)(!1),[s,r]=(0,a.useState)(420),[n,o]=(0,a.useState)("panel"),[l,i]=(0,a.useState)(!1),[d,c]=(0,a.useState)(""),[u,m]=(0,a.useState)(!1),[x,p]=(0,a.useState)("user"),[h,g]=(0,a.useState)(null),f=(0,a.useRef)(420),b=(0,th.KT)();(0,a.useEffect)(()=>{try{let e=localStorage.getItem("right-ask-panel-width");if(e){let t=parseInt(e,10);t>=400&&t<=4e3&&(r(t),f.current=t)}let t=localStorage.getItem("ask-mode");"popup"===t&&o("popup")}catch{}let e=e=>{"ask-mode"===e.key&&("panel"===e.newValue||"popup"===e.newValue)&&o(e.newValue)};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[]),(0,a.useEffect)(()=>{b.open&&(c(b.initialMessage),p(b.source),g(b.acpAgent),"popup"===n?i(!0):t(!0),b.close())},[b.open,b.initialMessage,b.source,b.acpAgent,b.close,n]);let v=(0,a.useCallback)(()=>{"popup"===n?i(e=>(e||(c(""),p("user"),g(null)),!e)):t(e=>(e||(c(""),p("user"),g(null)),!e))},[n]),j=(0,a.useCallback)(()=>{t(!1),u&&(r(f.current),m(!1))},[u]),y=(0,a.useCallback)(()=>{m(e=>(e?r(f.current):f.current=s,!e))},[s]),N=(0,a.useCallback)(()=>i(!1),[]),k=(0,a.useCallback)(e=>r(e),[]);return{askPanelOpen:e,askPanelWidth:s,askMaximized:u,askMode:n,desktopAskPopupOpen:l,askInitialMessage:d,askOpenSource:x,askAcpAgent:h,toggleAskPanel:v,closeAskPanel:j,closeDesktopAskPopup:N,handleAskWidthChange:k,handleAskWidthCommit:(0,a.useCallback)(e=>{try{localStorage.setItem("right-ask-panel-width",String(e))}catch{}},[]),handleAskModeSwitch:(0,a.useCallback)(()=>{o(e=>{let s="panel"===e?"popup":"panel";try{localStorage.setItem("ask-mode",s),window.dispatchEvent(new StorageEvent("storage",{key:"ask-mode",newValue:s}))}catch{}return"popup"===s?(t(!1),i(!0)):(i(!1),t(!0)),s})},[]),toggleAskMaximized:y}}(),[x,p]=(0,a.useState)(!1),[h,g]=(0,a.useState)(void 0),[f,b]=(0,a.useState)(!1),[v,j]=(0,a.useState)(null),[N,k]=(0,a.useState)(null),[w,S]=(0,a.useState)(()=>{try{let e=localStorage.getItem("right-agent-detail-panel-width");if(e){let t=parseInt(e,10);if(t>=300&&t<=640)return t}}catch{}return 400}),C=function(){let[e,t]=(0,a.useState)("idle"),[s,r]=(0,a.useState)([]),[n,o]=(0,a.useState)(null),[l,i]=(0,a.useState)(null),[d,c]=(0,a.useState)(""),[u,m]=(0,a.useState)(null),[x,p]=(0,a.useState)(0),h=(0,a.useRef)(null),g=(0,a.useRef)(0),f=(0,a.useRef)(new Map),[b,v]=(0,a.useState)([]),[j,y]=(0,a.useState)("upload"),N=(0,a.useRef)(0),[k,w]=(0,a.useState)(0),S=(0,a.useCallback)(async(e,s,n="upload")=>{t("organizing"),r([]),o(null),i({stage:"connecting"}),c(""),m(null),p(0),v(e.map(e=>e.name)),y(n),N.current=Date.now(),w(0),f.current=new Map,g.current=Date.now();let a=new AbortController;h.current=a;let l=e.map(e=>({name:e.name,content:e.content.length>2e4?e.content.slice(0,2e4)+"\n\n[...truncated to first ~20000 chars]":e.content}));try{let e=await fetch("/api/ask",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:[{role:"user",content:s}],uploadedFiles:l,maxSteps:15,mode:"organize"}),signal:a.signal});if(!e.ok){let t=`Request failed (${e.status})`;try{let s=await e.json();"string"==typeof s?.error?t=s.error:"object"==typeof s?.error&&s.error?.message?t=s.error.message:s?.message&&(t=s.message)}catch{}throw Error(t)}if(!e.body)throw Error("No response body");let n=await t9(e.body,e=>{g.current=Date.now(),e.changes&&r(e.changes),void 0!==e.currentTool&&o(e.currentTool),e.stageHint&&i(e.stageHint),void 0!==e.summary&&c(e.summary)},(e,t)=>{f.current.set(e,t)},a.signal);r(n.changes),c(n.summary),p(n.toolCallCount),o(null),w(Date.now()-N.current),t("done")}catch(e){"AbortError"===e.name?t("idle"):(m(e.message),t("error"))}finally{h.current=null}},[]),C=(0,a.useCallback)(()=>{h.current?.abort()},[]),A=(0,a.useCallback)(async e=>{let t=s.find(t=>t.path===e&&t.ok&&!t.undone);if(!t)return!1;try{if("create"===t.action){if(!(await fetch("/api/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({op:"delete_file",path:t.path})})).ok)return!1}else{if("update"!==t.action)return!1;let s=f.current.get(e);if(!s||!(await fetch("/api/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({op:"write_file",path:t.path,content:s})})).ok)return!1}return r(t=>t.map(t=>t.path===e&&t.ok&&!t.undone?{...t,undone:!0}:t)),!0}catch{return!1}},[s]),z=(0,a.useCallback)(async()=>{let e=s.filter(e=>e.ok&&!e.undone&&("create"===e.action||"update"===e.action&&f.current.has(e.path))),t=0;for(let s of e)try{if("create"===s.action)(await fetch("/api/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({op:"delete_file",path:s.path})})).ok&&t++;else if("update"===s.action){let e=f.current.get(s.path);e&&(await fetch("/api/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({op:"write_file",path:s.path,content:e})})).ok&&t++}}catch{}return t>0&&r(e=>e.map(e=>!e.ok||e.undone?e:"create"===e.action||"update"===e.action&&f.current.has(e.path)?{...e,undone:!0}:e)),t},[s]),E=(0,a.useCallback)(e=>{let t=s.find(t=>t.path===e&&t.ok&&!t.undone);return!!t&&("create"===t.action||"update"===t.action&&f.current.has(e))},[s]),T=s.some(e=>e.ok&&!e.undone&&("create"===e.action||"update"===e.action&&f.current.has(e.path))),$=(0,a.useCallback)(()=>{t("idle"),r([]),o(null),i(null),c(""),m(null),p(0),v([]),y("upload"),w(0),N.current=0,f.current=new Map,g.current=0},[]);return{phase:e,changes:s,currentTool:n,stageHint:l,summary:d,error:u,toolCallCount:x,sourceFileNames:b,source:j,durationMs:k,snapshots:f,start:S,abort:C,undoOne:A,undoAll:z,canUndo:E,hasAnyUndoable:T,reset:$}}(),[A,z]=(0,a.useState)(!1),[E,T]=(0,a.useState)(0);(0,a.useEffect)(()=>{("organizing"===C.phase||"done"===C.phase||"error"===C.phase)&&z(!0)},[C.phase]);let $=(0,a.useCallback)(()=>{z(!1),"organizing"!==C.phase||C.abort(),C.reset()},[C]),R=(0,a.useCallback)(()=>{T(e=>e+1),window.dispatchEvent(new Event("mindos:organize-history-update"))},[]),[M,D]=(0,a.useState)(!1),[I,L]=(0,a.useState)(void 0),[P,F]=(0,a.useState)(void 0),[O,_]=(0,a.useState)(!1),B=(0,a.useRef)(0),W=(0,a.useCallback)(e=>{L(e),F(void 0),D(!0)},[]),H=(0,a.useCallback)(()=>{D(!1),L(void 0),F(void 0)},[]),[Y,V]=(0,a.useState)(!1),[q,Z]=(0,a.useState)(!1),[Q,X]=(0,a.useState)(!1),{t:ee}=(0,y.Y)(),et=(0,n.useRouter)(),es=(0,n.usePathname)(),er=(0,a.useMemo)(()=>(function e(t,s=""){let r=[];for(let n of t)if("directory"===n.type&&!n.name.startsWith(".")){let t=s?`${s}/${n.name}`:n.name;r.push(t),n.children&&r.push(...e(n.children,t))}return r})(e),[e]),{status:en,fetchStatus:ea}=U(),eo=es.startsWith("/view/")?es.slice(6).split("/").map(decodeURIComponent).join("/"):void 0;(0,a.useEffect)(()=>{o.askMaximized&&o.toggleAskMaximized()},[es]);let el=es?.startsWith("/agents"),ei=s.activePanel??(el?"agents":null);(0,a.useEffect)(()=>{let e=e=>{let t=e.detail?.tab;t&&g(t),p(!0)};return window.addEventListener("mindos:open-settings",e),()=>window.removeEventListener("mindos:open-settings",e)},[]),(0,a.useEffect)(()=>{let e=()=>W();return window.addEventListener("mindos:open-import",e),()=>window.removeEventListener("mindos:open-import",e)},[W]);let ed=(0,a.useRef)([]);(0,a.useEffect)(()=>{let e=e=>{let t=e.detail?.files;if(!t||0===t.length||"organizing"===C.phase)return;let s=ee.inbox.organizePrompt(t.map(e=>e.name));ed.current=t.map(e=>e.name),(async()=>{let e=[];for(let s of t)try{let t=await fetch(`/api/file?path=${encodeURIComponent(s.path)}`);if(t.ok){let r=await t.json();e.push({name:s.name,content:r.content??""})}}catch{}e.length>0?C.start(e,s,"inbox-organize"):(ek.oR.error(ee.inbox.organizeFailed,4e3),window.dispatchEvent(new Event("mindos:organize-done")))})()};return window.addEventListener("mindos:inbox-organize",e),()=>window.removeEventListener("mindos:inbox-organize",e)},[C,ee]),(0,a.useEffect)(()=>{if("done"===C.phase){let e=C.changes.some(e=>e.ok),t=ed.current;e&&t.length>0&&(fetch("/api/inbox",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({names:t})}).then(()=>{window.dispatchEvent(new Event("mindos:inbox-updated"))}).catch(()=>{}),ed.current=[]),window.dispatchEvent(new Event("mindos:organize-done"))}else"error"===C.phase&&window.dispatchEvent(new Event("mindos:organize-done"))},[C.phase,C.changes]),(0,a.useEffect)(()=>{let e=e=>{let t=e.detail?.panel;t&&s.setActivePanel(t)};return window.addEventListener("mindos:open-panel",e),()=>window.removeEventListener("mindos:open-panel",e)},[s]);let ec=(0,a.useCallback)(()=>{let e=()=>window.dispatchEvent(new Event("guide-state-updated"));"guide"===o.askOpenSource?fetch("/api/setup",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({guideState:{askedAI:!0}})}).then(e).catch(e=>console.warn("Guide state update failed:",e)):"guide-next"===o.askOpenSource&&e()},[o.askOpenSource]);(0,a.useEffect)(()=>{let e=requestAnimationFrame(()=>V(!1));return()=>cancelAnimationFrame(e)},[es]),(0,a.useEffect)(()=>{es?.startsWith("/echo")&&s.setActivePanel("echo")},[es,s.setActivePanel]);let eu=(0,a.useCallback)(e=>{S(e);try{localStorage.setItem("right-agent-detail-panel-width",String(e))}catch{}},[]),em=(0,a.useCallback)(()=>k(null),[]),ex=null!==N&&"agents"===s.activePanel;(0,a.useEffect)(()=>{let e=-1,t=!1,s=async()=>{if(!t&&"hidden"!==document.visibilityState)try{let t=await fetch("/api/tree-version");if(!t.ok)return;let{v:s}=await t.json();if(-1===e){e=s;return}s!==e&&(e=s,et.refresh(),window.dispatchEvent(new Event("mindos:files-changed")))}catch(e){console.debug("[tree-version] poll failed",e)}},r=()=>{"visible"===document.visibilityState&&s()};s();let n=setInterval(()=>void s(),3e3);return document.addEventListener("visibilitychange",r),()=>{t=!0,clearInterval(n),document.removeEventListener("visibilitychange",r)}},[et]),(0,a.useEffect)(()=>{let e=e=>{if("Escape"===e.key){if(s.panelMaximized)return void s.handlePanelMaximize();if(ex)return void k(null);if(o.askPanelOpen)return void o.closeAskPanel();if(o.desktopAskPopupOpen)return void o.closeDesktopAskPopup()}(e.metaKey||e.ctrlKey)&&"k"===e.key&&(e.preventDefault(),window.innerWidth>=768?s.setActivePanel(e=>"search"===e?null:"search"):Z(e=>!e)),(e.metaKey||e.ctrlKey)&&"/"===e.key&&(e.preventDefault(),window.innerWidth>=768?o.toggleAskPanel():X(e=>!e)),(e.metaKey||e.ctrlKey)&&","===e.key&&(e.preventDefault(),p(e=>!e)),(e.metaKey||e.ctrlKey)&&"i"===e.key&&(e.preventDefault(),D(e=>!e))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[ex,s,o]);let ep=(0,a.useCallback)(()=>{g("sync"),b(!1),p(!0)},[]),eh=(0,a.useCallback)(()=>{p(!0),g(void 0)},[]),eg=(0,a.useCallback)(()=>{p(!1),g(void 0)},[]),ef=(0,a.useCallback)(e=>{j(e),b(e=>!e)},[]),eb=(0,a.useCallback)(e=>{s.handleExpandedChange(e),b(!1)},[s]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ni,{}),(0,r.jsx)(nf,{}),(0,r.jsx)("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:fixed focus:top-2 focus:left-2 focus:z-[60] focus:px-4 focus:py-2 focus:rounded-lg focus:text-sm focus:font-medium bg-[var(--amber)] text-[var(--amber-foreground)]",children:"Skip to main content"}),(0,r.jsx)(J,{activePanel:ei,onPanelChange:s.setActivePanel,onEchoClick:()=>{let e="echo"===s.activePanel;s.setActivePanel(e?null:"echo"),e||et.push("/echo/about-you")},onAgentsClick:()=>{let e="agents"===s.activePanel;s.setActivePanel(e?null:"agents"),e||et.push("/agents"),k(null)},onDiscoverClick:()=>{let e="discover"===s.activePanel;s.setActivePanel(e?null:"discover"),e||et.push("/explore")},onSpacesClick:()=>{let e="files"===s.activePanel;s.setActivePanel(e?null:"files"),e||et.push("/wiki")},syncStatus:en,expanded:s.railExpanded,onExpandedChange:eb,onSettingsClick:eh,onSyncClick:ef}),(0,r.jsxs)(eQ,{activePanel:s.activePanel,fileTree:e,onNavigate:()=>{},onOpenSyncSettings:ep,railWidth:s.railWidth,panelWidth:s.panelWidth??void 0,onWidthChange:s.handlePanelWidthChange,onWidthCommit:s.handlePanelWidthCommit,maximized:s.panelMaximized,onMaximize:s.handlePanelMaximize,onImport:W,children:[(0,r.jsx)("div",{className:`flex flex-col h-full ${"echo"===s.activePanel?"":"hidden"}`,children:(0,r.jsx)(tE,{active:"echo"===s.activePanel,maximized:s.panelMaximized,onMaximize:s.handlePanelMaximize})}),(0,r.jsx)("div",{className:`flex flex-col h-full ${"search"===s.activePanel?"":"hidden"}`,children:(0,r.jsx)(e0,{active:"search"===s.activePanel,maximized:s.panelMaximized,onMaximize:s.handlePanelMaximize})}),(0,r.jsx)("div",{className:`flex flex-col h-full ${"agents"===s.activePanel?"":"hidden"}`,children:(0,r.jsx)(tn,{active:"agents"===s.activePanel,maximized:s.panelMaximized,onMaximize:s.handlePanelMaximize,selectedAgentKey:ex?N:null})}),(0,r.jsx)("div",{className:`flex flex-col h-full ${"discover"===s.activePanel?"":"hidden"}`,children:(0,r.jsx)(tv,{active:"discover"===s.activePanel,maximized:s.panelMaximized,onMaximize:s.handlePanelMaximize})}),(0,r.jsx)("div",{className:`flex flex-col h-full ${"workflows"===s.activePanel?"":"hidden"}`,children:(0,r.jsx)(t$,{active:"workflows"===s.activePanel,maximized:s.panelMaximized,onMaximize:s.handlePanelMaximize})})]}),(0,r.jsx)(sK,{open:o.askPanelOpen,onClose:o.closeAskPanel,currentFile:eo,initialMessage:o.askInitialMessage,initialAcpAgent:o.askAcpAgent,onFirstMessage:ec,width:o.askPanelWidth,onWidthChange:o.handleAskWidthChange,onWidthCommit:o.handleAskWidthCommit,askMode:o.askMode,onModeSwitch:o.handleAskModeSwitch,maximized:o.askMaximized,onMaximize:o.toggleAskMaximized,sidebarOffset:s.panelOpen?s.railWidth+s.effectivePanelWidth:s.railWidth}),(0,r.jsx)(sV,{open:ex,agentKey:N,onClose:em,rightOffset:o.askPanelOpen?o.askPanelWidth:0,width:w,onWidthChange:S,onWidthCommit:eu}),(0,r.jsx)(s2,{open:o.desktopAskPopupOpen,onClose:o.closeDesktopAskPopup,currentFile:eo,initialMessage:o.askInitialMessage,initialAcpAgent:o.askAcpAgent,onFirstMessage:ec,askMode:o.askMode,onModeSwitch:o.handleAskModeSwitch}),(0,r.jsx)(sq,{onToggle:o.toggleAskPanel,askPanelOpen:o.askPanelOpen||o.desktopAskPopupOpen}),(0,r.jsx)(r3,{}),(0,r.jsx)(r5,{open:x,onClose:eg,initialTab:h}),(0,r.jsx)(sZ,{open:f,onClose:()=>b(!1),anchorRect:v,railWidth:s.railWidth,onOpenSyncSettings:ep,syncStatus:en,onSyncStatusRefresh:ea}),(0,r.jsxs)("header",{className:"md:hidden fixed top-0 left-0 right-0 z-30 bg-card border-b border-border flex items-center justify-between px-3 py-2",style:{paddingTop:"env(safe-area-inset-top, 0px)"},children:[(0,r.jsx)("button",{onClick:()=>V(!0),className:"p-3 -ml-1 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors active:bg-accent","aria-label":"Open menu",children:(0,r.jsx)(i.A,{size:20})}),(0,r.jsxs)(l(),{href:"/",className:"flex items-center gap-2 hover:opacity-80 transition-opacity",children:[(0,r.jsx)(G.A,{id:"mobile"}),(0,r.jsx)("span",{className:"text-foreground text-sm font-brand",children:"MindOS"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,r.jsx)("button",{onClick:ep,className:"p-3 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors active:bg-accent flex items-center justify-center","aria-label":"Sync status",children:(0,r.jsx)(K,{status:en})}),(0,r.jsx)("button",{onClick:()=>Z(!0),className:"p-3 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors active:bg-accent","aria-label":ee.sidebar.searchTitle,children:(0,r.jsx)(d.A,{size:20})}),(0,r.jsx)("button",{onClick:()=>{p(!0),g(void 0)},className:"p-3 -mr-1 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors active:bg-accent","aria-label":ee.sidebar.settingsTitle,children:(0,r.jsx)(c.A,{size:20})})]})]}),Y&&(0,r.jsx)("div",{className:"md:hidden fixed inset-0 z-40 overlay-backdrop",onClick:()=>V(!1)}),(0,r.jsxs)("aside",{className:`md:hidden fixed top-0 left-0 h-screen w-[85vw] max-w-[320px] z-50 bg-card border-r border-border flex flex-col transition-transform duration-300 ease-in-out ${Y?"translate-x-0":"-translate-x-full"}`,children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-4 border-b border-border shrink-0",children:[(0,r.jsxs)(l(),{href:"/",className:"flex items-center gap-2 hover:opacity-80 transition-opacity",children:[(0,r.jsx)(G.A,{id:"drawer"}),(0,r.jsx)("span",{className:"text-foreground text-sm font-brand",children:"MindOS"})]}),(0,r.jsx)("button",{onClick:()=>V(!1),className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",children:(0,r.jsx)(u.A,{size:16})})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0 px-2 py-2",children:(0,r.jsx)(eH,{nodes:e,onNavigate:()=>V(!1),onImport:W})})]}),(0,r.jsx)(s1,{open:q,onClose:()=>Z(!1)}),(0,r.jsx)(s2,{open:Q,onClose:()=>X(!1),currentFile:eo}),(0,r.jsxs)("main",{id:"main-content",className:"min-h-screen transition-all duration-200 pt-[52px] md:pt-0",onDragEnter:e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),B.current++,1===B.current&&_(!0))},onDragOver:e=>{e.dataTransfer.types.includes("Files")&&e.preventDefault()},onDragLeave:()=>{B.current=Math.max(0,B.current-1),0===B.current&&_(!1)},onDrop:e=>{e.preventDefault(),B.current=0,_(!1),e.dataTransfer.files.length>0&&!M&&(0,ny.Q)(Array.from(e.dataTransfer.files),ee)},children:[(0,r.jsxs)("div",{className:"min-h-screen bg-background",style:{overflowX:"clip"},children:[(0,r.jsx)(r4,{}),t]}),(0,r.jsx)(r9,{}),(0,r.jsx)(nl,{t:ee,dirPaths:er}),O&&!M&&(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm transition-opacity duration-200",children:(0,r.jsxs)("div",{className:"border-2 border-dashed border-[var(--amber)]/50 rounded-xl p-12 flex flex-col items-center gap-3",children:[(0,r.jsx)(m.A,{size:48,className:"text-[var(--amber)]/60"}),(0,r.jsx)("p",{className:"text-sm text-foreground font-medium",children:ee.inbox.dropOverlay}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:ee.inbox.dropOverlayFormats})]})})]}),(0,r.jsx)(nN,{open:M,onClose:H,defaultSpace:I,initialFiles:P,aiOrganize:C,dirPaths:er}),A&&(0,r.jsx)(nn,{aiOrganize:C,onDismiss:$,onCancel:()=>{C.abort(),C.reset(),z(!1)},onHistoryUpdate:R}),(0,r.jsx)("style",{children:`
|
|
137
|
-
@media (min-width: 768px) {
|
|
138
|
-
:root {
|
|
139
|
-
--right-panel-width: ${o.askMaximized?`calc(100vw - ${s.panelOpen?s.railWidth+s.effectivePanelWidth:s.railWidth}px)`:`${o.askPanelOpen?o.askPanelWidth:0}px`};
|
|
140
|
-
--right-agent-detail-width: ${ex?w:0}px;
|
|
141
|
-
}
|
|
142
|
-
#main-content {
|
|
143
|
-
padding-left: ${s.panelOpen&&s.panelMaximized?"100vw":`${s.panelOpen?s.railWidth+s.effectivePanelWidth:s.railWidth}px`} !important;
|
|
144
|
-
padding-right: calc(var(--right-panel-width) + var(--right-agent-detail-width) + var(--toc-extra-right, 0px)) !important;
|
|
145
|
-
padding-top: 0;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
`})]})}function nw({fileTree:e,children:t}){return"/login"===(0,n.usePathname)()?(0,r.jsx)(r.Fragment,{children:t}):(0,r.jsx)(nk,{fileTree:e,children:t})}},26490:(e,t,s)=>{"use strict";s.d(t,{default:()=>u});var r=s(95155),n=s(12115),a=s(94514),o=s(13545),l=s(68822),i=s(33210),d=s(4235);let c={success:(0,r.jsx)(a.A,{size:15,className:"text-success shrink-0"}),error:(0,r.jsx)(o.A,{size:15,className:"text-error shrink-0"}),info:(0,r.jsx)(l.A,{size:15,className:"text-muted-foreground shrink-0"})};function u(){let e=(0,n.useSyncExternalStore)(d.B1,d.dV,d.dV);return 0===e.length?null:(0,r.jsx)("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col-reverse gap-2 pointer-events-none",role:"status","aria-live":"polite","aria-atomic":"false",children:e.map(e=>(0,r.jsxs)("div",{className:"pointer-events-auto flex items-center gap-2.5 bg-card border border-border rounded-lg shadow-lg px-4 py-2.5 min-w-[180px] max-w-[320px] animate-in slide-in-from-right-4 fade-in duration-200",children:[c[e.type],(0,r.jsx)("span",{className:"text-sm text-foreground flex-1 truncate",children:e.message}),e.action&&(0,r.jsx)("button",{type:"button",onClick:()=>{e.action.onClick(),(0,d.X8)(e.id)},className:"shrink-0 px-2.5 py-1 rounded text-xs font-medium text-[var(--amber)] hover:bg-[var(--amber-dim)] transition-colors min-h-[28px] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:e.action.label}),(0,r.jsx)("button",{type:"button",onClick:()=>(0,d.X8)(e.id),className:"shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-label":e.action?.label?"Close":"Dismiss",children:(0,r.jsx)(i.A,{size:13})})]},e.id))})}},27318:(e,t,s)=>{"use strict";s.d(t,{KT:()=>c,NH:()=>d});var r=s(12115);let n={open:!1,initialMessage:"",source:"user",acpAgent:null},a=new Set;function o(){a.forEach(e=>e())}function l(e){return a.add(e),()=>{a.delete(e)}}function i(){return n}function d(e="",t="user",s=null){n={open:!0,initialMessage:e,source:t,acpAgent:s},o()}function c(){let e=(0,r.useSyncExternalStore)(l,i,i);return{open:e.open,initialMessage:e.initialMessage,source:e.source,acpAgent:e.acpAgent,openWith:(0,r.useCallback)((e,t="user",s=null)=>d(e,t,s),[]),close:(0,r.useCallback)(()=>void(n={open:!1,initialMessage:"",source:"user",acpAgent:null},o()),[])}}},27996:(e,t,s)=>{"use strict";s.d(t,{A:()=>d});var r=s(95155),n=s(12115),a=s(47650),o=s(94514),l=s(66088);function i(e){return"options"in e}function d({value:e,onChange:t,options:s,className:d="",size:c="md",placeholder:u}){let[m,x]=(0,n.useState)(!1),[p,h]=(0,n.useState)(-1),[g,f]=(0,n.useState)(null),b=(0,n.useRef)(null),v=(0,n.useRef)(null),j=(0,n.useMemo)(()=>(function(e){let t=[];for(let s of e)i(s)?t.push(...s.options):t.push(s);return t})(s),[s]),y=(0,n.useMemo)(()=>j.find(t=>t.value===e)??null,[j,e]),N=(0,n.useCallback)(()=>{x(!1),h(-1)},[]),k=(0,n.useCallback)(e=>{t(e),N()},[t,N]);(0,n.useEffect)(()=>{if(!m)return;let e=e=>{b.current&&!b.current.contains(e.target)&&v.current&&!v.current.contains(e.target)&&N()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[m,N]),(0,n.useEffect)(()=>{if(!m)return;let e=e=>{switch(e.key){case"Escape":e.preventDefault(),N(),b.current?.focus();break;case"ArrowDown":e.preventDefault(),h(e=>Math.min(e+1,j.length-1));break;case"ArrowUp":e.preventDefault(),h(e=>Math.max(e-1,0));break;case"Enter":e.preventDefault(),p>=0&&p<j.length&&(k(j[p].value),b.current?.focus())}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[m,N,p,j,k]),(0,n.useEffect)(()=>{if(!m||!v.current||p<0)return;let e=v.current.querySelector(`[data-idx="${p}"]`);e&&e.scrollIntoView({block:"nearest"})},[m,p]);let w=(0,n.useCallback)(()=>{if(!b.current)return;let e=b.current.getBoundingClientRect(),t="sm"===c?200:260,s=window.innerHeight-e.bottom,r=e.top;f({top:s<t+8&&r>s?e.top:e.bottom,left:e.left,width:e.width,flipUp:s<t+8&&r>s})},[c]);(0,n.useEffect)(()=>{if(!m)return void f(null);let t=j.findIndex(t=>t.value===e);return h(t>=0?t:0),w(),window.addEventListener("scroll",w,!0),window.addEventListener("resize",w),()=>{window.removeEventListener("scroll",w,!0),window.removeEventListener("resize",w)}},[m,j,e,w]);let S="sm"===c,C=S?`inline-flex items-center gap-1 appearance-none rounded-md border border-border bg-background text-foreground outline-none focus-visible:ring-1 focus-visible:ring-ring transition-colors text-2xs px-1.5 py-0.5 pr-5 ${d}`:`w-full flex items-center gap-2 appearance-none rounded-lg border border-border bg-background text-foreground outline-none focus-visible:ring-1 focus-visible:ring-ring transition-colors text-sm px-3 py-2 pr-8 ${d}`,A=S?"w-full flex items-center gap-1.5 px-2 py-1 text-2xs text-left transition-colors cursor-pointer":"w-full flex items-center gap-2 px-3 py-1.5 text-sm text-left transition-colors cursor-pointer",z=-1;function E(t){let s=++z,n=t.value===e,a=s===p;return(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":n,"data-idx":s,onClick:()=>k(t.value),onMouseEnter:()=>h(s),className:`${A} ${a?"bg-muted text-foreground":"text-foreground"}`,children:[t.icon,(0,r.jsx)("span",{className:"flex-1 truncate",children:t.label}),t.suffix,n&&(0,r.jsx)(o.A,{size:S?10:12,className:"shrink-0 text-[var(--amber)]"})]},t.value)}let T=m&&g&&(0,a.createPortal)((0,r.jsx)("div",{ref:v,className:S?"fixed z-[9999] overflow-y-auto rounded-md border border-border bg-card shadow-lg py-0.5":"fixed z-[9999] overflow-y-auto rounded-lg border border-border bg-card shadow-lg py-1",role:"listbox",style:{left:g.left,minWidth:g.width,maxHeight:S?200:260,...g.flipUp?{bottom:window.innerHeight-g.top+4}:{top:g.top+4}},children:s.map((e,t)=>i(e)?(0,r.jsxs)("div",{children:[t>0&&(0,r.jsx)("div",{className:"my-0.5 border-t border-border/50"}),(0,r.jsx)("div",{className:`py-1 text-2xs font-medium text-muted-foreground uppercase tracking-wider ${S?"px-2":"px-3"}`,children:e.label}),e.options.map(E)]},e.label):E(e))}),document.body);return(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsxs)("button",{ref:b,type:"button",onClick:()=>x(e=>!e),"aria-haspopup":"listbox","aria-expanded":m,className:C,children:[y?.icon,(0,r.jsx)("span",{className:"flex-1 truncate text-left",children:y?.label??u??"—"}),y?.suffix,(0,r.jsx)(l.A,{size:S?12:14,className:`${S?"absolute right-1 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none":"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"} transition-transform duration-150 ${m?"rotate-180":""}`})]}),T]})}},29494:(e,t,s)=>{"use strict";s.d(t,{Q:()=>n});var r=s(4235);async function n(e,t){let s=[],n=0;for(let t of e){if(t.size>0xa00000){n++;continue}try{if(t.name.toLowerCase().endsWith(".pdf")){let e=await t.arrayBuffer();s.push({name:t.name,content:function(e){let t=new Uint8Array(e),s=[];for(let e=0;e<t.length;e+=8192)s.push(String.fromCharCode(...t.subarray(e,e+8192)));return btoa(s.join(""))}(e),encoding:"base64"})}else{let e=await t.text();s.push({name:t.name,content:e})}}catch{}}if(0===s.length)return void(n>0?r.oR.error(t.inbox.tooLarge(n),4e3):e.length>0&&r.oR.error(t.inbox.saveFailed,4e3));try{var a;let e=await fetch("/api/inbox",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:s})});if(!e.ok){let s=await e.json().catch(()=>({}));console.error("[QuickDrop] Save failed:",s.error),r.oR.error(t.inbox.saveFailed,4e3);return}let o=await e.json(),l=o.saved?.length??0,i=o.skipped?.length??0;a=n,l>0&&a>0&&0===i?r.oR.success(t.inbox.savedWithOversized(l,a),4e3):l>0&&i+a>0?r.oR.success(t.inbox.savedWithSkipped(l,i+a),4e3):l>0?r.oR.success(t.inbox.savedToast(l),3e3):(a>0&&r.oR.error(t.inbox.tooLarge(a),4e3),i>0&&r.oR.error(t.inbox.savedWithSkipped(0,i),4e3),0===a&&0===i&&r.oR.error(t.inbox.saveFailed,4e3)),window.dispatchEvent(new Event("mindos:files-changed")),window.dispatchEvent(new Event("mindos:inbox-updated"))}catch(e){console.error("[QuickDrop] Network error:",e),r.oR.error(t.inbox.saveFailed,4e3)}}},35504:(e,t,s)=>{"use strict";s.r(t),s.d(t,{ConfigRenderer:()=>d});var r=s(95155),n=s(12115),a=s(6296),o=s(94514),l=s(33210),i=s(51914);function d({content:e,saveAction:t}){let s=(0,n.useMemo)(()=>{try{return JSON.parse(e)}catch{return null}},[e]),[d,c]=(0,n.useState)(s),[u,m]=(0,n.useState)(!1),[x,p]=(0,n.useState)(!1),[h,g]=(0,n.useState)(""),[f,b]=(0,n.useState)({});(0,n.useEffect)(()=>{c(s),g("")},[s]);let v=d??{},j=v.uiSchema?.sections??[],y=v.keySpecs??{},N=(0,n.useCallback)(async e=>{m(!0),p(!1),g("");try{await t(`${JSON.stringify(e,null,2)}
|
|
149
|
-
`),p(!0),setTimeout(()=>p(!1),1200)}catch(e){g(e instanceof Error?e.message:"Failed to save")}finally{m(!1)}},[t]),k=(0,n.useCallback)(async(e,t)=>{if(!d)return;let s=function(e,t,s){let r=t.split("."),n=structuredClone(e),a=n;for(let e=0;e<r.length-1;e++){let t=r[e],s=a[t];(!s||"object"!=typeof s||Array.isArray(s))&&(a[t]={}),a=a[t]}return a[r[r.length-1]]=s,n}(d,e,t);c(s),await N(s)},[d,N]);return s&&d?(0,r.jsxs)("div",{className:"max-w-3xl mx-auto flex flex-col gap-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between rounded-xl border border-border bg-card px-4 py-2.5",children:[(0,r.jsx)("div",{className:"text-xs text-muted-foreground",children:"CONFIG Control Panel"}),(0,r.jsxs)("div",{className:"text-xs flex items-center gap-2",children:[u&&(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 text-muted-foreground",children:[(0,r.jsx)(a.A,{size:12,className:"animate-spin"}),"Saving"]}),!u&&x&&(0,r.jsxs)("span",{className:"inline-flex items-center gap-1",style:{color:"var(--success)"},children:[(0,r.jsx)(o.A,{size:12}),"Saved"]})]})]}),h&&(0,r.jsx)("div",{className:"rounded-lg border border-error/30 bg-error/10 px-3 py-2 text-xs text-error",children:h}),j.map(e=>(0,r.jsxs)("div",{className:"rounded-xl border border-border bg-card p-4",children:[(0,r.jsxs)("div",{className:"mb-3",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:e.title}),e.description&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:e.description})]}),(0,r.jsx)("div",{className:"space-y-3",children:e.fields.map(e=>{let t=y[e]??{},s=function(e,t){let s=t.split("."),r=e;for(let e of s){if(!r||"object"!=typeof r||!(e in r))return null;r=r[e]}return r}(d,e),n=t.label||e;return(0,r.jsxs)("div",{className:"rounded-lg border border-border/80 bg-background px-3 py-2.5",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 mb-1.5",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-sm text-foreground",children:n}),t.description&&(0,r.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:t.description})]}),"switch"===t.control&&"boolean"==typeof s&&(0,r.jsx)("button",{type:"button",onClick:()=>k(e,!s),className:"px-2.5 py-1 rounded-md text-xs font-medium",style:{background:s?"var(--amber)":"var(--muted)",color:s?"var(--amber-foreground)":"var(--muted-foreground)"},children:s?"ON":"OFF"})]}),"text"===t.control&&"string"==typeof s&&(0,r.jsx)("input",{defaultValue:s,onBlur:t=>k(e,t.target.value),className:"w-full px-2 py-1.5 text-sm bg-card border border-border rounded text-foreground"}),"number"===t.control&&"number"==typeof s&&(0,r.jsx)("input",{type:"number",defaultValue:s,min:t.constraints?.min,max:t.constraints?.max,onBlur:r=>{let n=Number(r.target.value),a=t.constraints?.min,o=t.constraints?.max,l=Number.isFinite(n)?n:s;"number"==typeof a&&l<a&&(l=a),"number"==typeof o&&l>o&&(l=o),k(e,l)},className:"w-full px-2 py-1.5 text-sm bg-card border border-border rounded text-foreground"}),"tag-list"===t.control&&Array.isArray(s)&&(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:s.map((t,n)=>(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded border border-border text-xs bg-muted text-foreground",children:[String(t),(0,r.jsx)("button",{type:"button",onClick:()=>k(e,s.filter((e,t)=>t!==n)),className:"text-muted-foreground hover:text-foreground",children:(0,r.jsx)(l.A,{size:11})})]},`${String(t)}-${n}`))}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("input",{value:f[e]??"",onChange:t=>b(s=>({...s,[e]:t.target.value})),onKeyDown:t=>{if("Enter"!==t.key)return;t.preventDefault();let r=(f[e]??"").trim();r&&(k(e,[...s,r]),b(t=>({...t,[e]:""})))},className:"flex-1 px-2 py-1.5 text-sm bg-card border border-border rounded text-foreground",placeholder:"Add item"}),(0,r.jsxs)("button",{type:"button",onClick:()=>{let t=(f[e]??"").trim();t&&(k(e,[...s,t]),b(t=>({...t,[e]:""})))},className:"px-2.5 py-1.5 rounded-md text-xs bg-muted text-foreground inline-flex items-center gap-1",children:[(0,r.jsx)(i.A,{size:12})," Add"]})]})]})]},e)})})]},e.id))]}):(0,r.jsx)("div",{className:"rounded-xl border border-border p-4 text-sm text-error",children:"CONFIG.json parse failed. Please check JSON format."})}},39594:(e,t,s)=>{"use strict";s.r(t),s.d(t,{TimelineRenderer:()=>i});var r=s(95155),n=s(12115);let a=/(\d{4}[-/]\d{1,2}(?:[-/]\d{1,2})?|[A-Za-z]+ \d{4}|\d{4}年\d{1,2}月(?:\d{1,2}日)?)/;function o(e){return e.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/`(.+?)`/g,'<code class="font-display" style="font-size:0.85em;padding:1px 5px;border-radius:4px;background:var(--muted)">$1</code>').replace(/\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/g,(e,t,s)=>`<span style="color:var(--amber);cursor:pointer" title="${t}">${s??t}</span>`).replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" style="color:var(--amber)">$1</a>')}let l=[{bg:"rgba(200,135,58,0.12)",text:"var(--amber)"},{bg:"rgba(122,173,128,0.12)",text:"var(--success)"},{bg:"rgba(138,180,216,0.12)",text:"#8ab4d8"},{bg:"rgba(200,160,216,0.12)",text:"#c8a0d8"}];function i({content:e}){let t=(0,n.useMemo)(()=>(function(e){let t=e.split("\n"),s=[],r=null,n=[],o=()=>{let e,t;if(!r)return;let a=n.join("\n").trim();r.body=a,r.tags=(e=[],(t=a.match(/#([\w\u4e00-\u9fff]+)/g))&&e.push(...t.map(e=>e.slice(1))),[...new Set(e)]),s.push(r),r=null,n=[]};for(let e of t)if(!/^# /.test(e)){if(/^## /.test(e)){o();let t=e.slice(3).trim();r={heading:t,date:function(e){let t=a.exec(e);if(!t)return null;let s=new Date(t[1].replace(/[/年月]/g,"-").replace("日",""));return isNaN(s.getTime())?null:s}(t),body:"",tags:[]};continue}r&&n.push(e)}return o(),s})(e),[e]);return 0===t.length?(0,r.jsxs)("div",{className:"font-display",style:{padding:"3rem 1rem",textAlign:"center",color:"var(--muted-foreground)",fontSize:13},children:["No timeline entries found. Add ",(0,r.jsx)("code",{style:{background:"var(--muted)",padding:"1px 6px",borderRadius:4},children:"## 2025-01-15"})," headings to create entries."]}):(0,r.jsxs)("div",{style:{maxWidth:720,margin:"0 auto",padding:"1.5rem 0"},children:[(0,r.jsx)("div",{style:{marginBottom:"1.5rem",display:"flex",alignItems:"center",gap:8},children:(0,r.jsxs)("span",{className:"font-display",style:{fontSize:11,color:"var(--muted-foreground)"},children:[t.length," ",1===t.length?"entry":"entries"]})}),(0,r.jsxs)("div",{style:{position:"relative",paddingLeft:28},children:[(0,r.jsx)("div",{style:{position:"absolute",left:6,top:8,bottom:8,width:1,background:"var(--border)"}}),t.map((e,t)=>(0,r.jsxs)("div",{style:{position:"relative",marginBottom:"1.5rem"},children:[(0,r.jsx)("div",{style:{position:"absolute",left:-22,top:10,width:9,height:9,borderRadius:"50%",background:e.date?"var(--amber)":"var(--border)",outline:e.date?"2px solid var(--amber-dim)":"none",zIndex:1}}),(0,r.jsxs)("div",{style:{background:"var(--card)",border:"1px solid var(--border)",borderRadius:10,padding:"14px 18px",transition:"border-color .15s"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:12,flexWrap:"wrap",marginBottom:8},children:[(0,r.jsx)("span",{style:{fontWeight:600,fontSize:"0.9rem",color:"var(--foreground)"},children:e.heading}),e.date&&(0,r.jsx)("span",{className:"font-display",style:{fontSize:"0.7rem",color:"var(--muted-foreground)",opacity:.7,flexShrink:0},children:e.date.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})})]}),e.body&&(0,r.jsx)("div",{dangerouslySetInnerHTML:{__html:function(e){let t=e.split("\n"),s=[],r=!1,n=()=>{r&&(s.push("</ul>"),r=!1)};for(let e of t){let t=e.trimEnd();if(!t){n(),s.push("<br/>");continue}if(/^### /.test(t)){n(),s.push(`<h3 style="font-size:0.8rem;font-weight:600;color:var(--muted-foreground);text-transform:uppercase;letter-spacing:.06em;margin:.9em 0 .3em">${o(t.slice(4))}</h3>`);continue}if(/^- /.test(t)||/^\* /.test(t)){r||(s.push('<ul style="margin:.3em 0;padding-left:1.2em;list-style:disc">'),r=!0),s.push(`<li style="margin:.15em 0;font-size:.82rem;color:var(--foreground)">${o(t.slice(2))}</li>`);continue}if(/^\d+\. /.test(t)){r||(s.push('<ol style="margin:.3em 0;padding-left:1.2em">'),r=!0),s.push(`<li style="margin:.15em 0;font-size:.82rem;color:var(--foreground)">${o(t.replace(/^\d+\. /,""))}</li>`);continue}n(),s.push(`<p style="margin:.25em 0;font-size:.82rem;line-height:1.6;color:var(--foreground)">${o(t)}</p>`)}return n(),s.join("")}(e.body)}}),e.tags.length>0&&(0,r.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:5,marginTop:10},children:e.tags.map(e=>{let t=function(e){let t=0;for(let s=0;s<e.length;s++)t=31*t+e.charCodeAt(s)&65535;return l[t%l.length]}(e);return(0,r.jsxs)("span",{className:"font-display",style:{fontSize:"0.68rem",padding:"1px 8px",borderRadius:999,background:t.bg,color:t.text},children:["#",e]},e)})})]})]},t))]})]})}},40430:(e,t,s)=>{"use strict";s.d(t,{default:()=>d});var r=s(95155),n=s(12115),a=s(12651),o=s(6296),l=s(91053);let i="mindos_update_in_progress";function d(){let[e,t]=(0,n.useState)(!1),[s,d]=(0,n.useState)(!1),c=(0,n.useRef)(void 0),{locale:u}=(0,l.Y)(),m="zh"===u,x=(0,n.useCallback)(()=>{c.current=setInterval(async()=>{try{if((await fetch("/api/health",{signal:AbortSignal.timeout(3e3)})).ok){clearInterval(c.current),c.current=void 0;try{let e=localStorage.getItem(i);if(e){let{originalVer:t}=JSON.parse(e),s=await fetch("/api/update-check",{signal:AbortSignal.timeout(5e3)}).then(e=>e.json());if(s.current&&s.current!==t){d(!0),localStorage.removeItem(i),localStorage.removeItem("mindos_update_latest"),localStorage.removeItem("mindos_update_dismissed"),setTimeout(()=>window.location.reload(),1500);return}}}catch{}localStorage.removeItem(i),window.location.reload()}}catch{}},3e3)},[]);return((0,n.useEffect)(()=>{let e=()=>{localStorage.getItem(i)&&(t(!0),c.current||x())};e();let s=()=>e();return window.addEventListener("mindos:update-started",s),window.addEventListener("storage",s),()=>{clearInterval(c.current),c.current=void 0,window.removeEventListener("mindos:update-started",s),window.removeEventListener("storage",s)}},[x]),e)?(0,r.jsxs)("div",{style:{position:"fixed",inset:0,zIndex:99999,background:"rgba(0,0,0,0.7)",backdropFilter:"blur(8px)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",fontFamily:"'IBM Plex Sans', system-ui, sans-serif"},children:[s?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(a.A,{size:32,style:{color:"var(--success)",marginBottom:12}}),(0,r.jsx)("div",{style:{color:"var(--foreground)",fontSize:18,fontWeight:600},children:m?"更新成功!":"Update Complete!"}),(0,r.jsx)("div",{style:{color:"var(--muted-foreground)",fontSize:13,marginTop:6},children:m?"正在刷新页面...":"Reloading..."})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.A,{size:32,style:{color:"var(--amber)",marginBottom:12,animation:"spin 1s linear infinite"}}),(0,r.jsx)("div",{style:{color:"var(--foreground)",fontSize:18,fontWeight:600},children:m?"MindOS 正在更新...":"MindOS is Updating..."}),(0,r.jsx)("div",{style:{color:"var(--muted-foreground)",fontSize:13,marginTop:6,textAlign:"center",maxWidth:300,lineHeight:1.5},children:m?"服务正在重启,请勿关闭此页面。完成后将自动刷新。":"The server is restarting. Please do not close this page. It will auto-reload when ready."})]}),(0,r.jsx)("style",{children:"@keyframes spin { to { transform: rotate(360deg) } }"})]}):null}},46838:(e,t,s)=>{"use strict";s.d(t,{$7:()=>o,MZ:()=>c,TS:()=>i,UG:()=>a,YB:()=>d,pl:()=>l});let r=[],n=new Set;function a(){try{let e=localStorage.getItem("mindos-disabled-renderers");n=new Set(e?JSON.parse(e):[])}catch{n=new Set}}function o(e,t){let s=r.find(t=>t.id===e);s?.core||(t?n.delete(e):n.add(e),localStorage.setItem("mindos-disabled-renderers",JSON.stringify([...n])))}function l(e){let t=r.find(t=>t.id===e);return!!t?.core||!n.has(e)}function i(e){r.find(t=>t.id===e.id)||r.push(e)}function d(e,t,s){if(s){let e=r.find(e=>e.id===s);return e&&l(e.id)?e:void 0}return r.find(s=>l(s.id)&&s.match({filePath:e,extension:t}))}function c(){return r.filter(e=>!e.appBuiltinFeature)}},47376:(e,t,s)=>{"use strict";s.d(t,{Ot:()=>u,T_:()=>n,Ux:()=>c,bf:()=>l,jt:()=>a,rl:()=>o});var r=s(20699);s(87358);let n={anthropic:{id:"anthropic",name:"Anthropic",nameZh:"Anthropic",defaultModel:"claude-sonnet-4-6",supportsBaseUrl:!0,supportsThinking:!0,supportsListModels:!0,signupUrl:"https://console.anthropic.com/settings/keys",category:"primary"},openai:{id:"openai",name:"OpenAI",nameZh:"OpenAI",defaultModel:"gpt-5.4",supportsBaseUrl:!0,supportsThinking:!0,supportsListModels:!0,signupUrl:"https://platform.openai.com/api-keys",category:"primary"},google:{id:"google",name:"Google Gemini",nameZh:"Google Gemini",defaultModel:"gemini-2.5-flash",supportsBaseUrl:!1,supportsThinking:!0,supportsListModels:!1,signupUrl:"https://aistudio.google.com/apikey",category:"primary"},groq:{id:"groq",name:"Groq",nameZh:"Groq",defaultModel:"llama-3.3-70b-versatile",supportsBaseUrl:!1,supportsThinking:!1,supportsListModels:!0,signupUrl:"https://console.groq.com/keys",category:"more"},xai:{id:"xai",name:"xAI (Grok)",nameZh:"xAI (Grok)",defaultModel:"grok-3",supportsBaseUrl:!1,supportsThinking:!1,supportsListModels:!0,category:"more"},openrouter:{id:"openrouter",name:"OpenRouter",nameZh:"OpenRouter",defaultModel:"anthropic/claude-sonnet-4",supportsBaseUrl:!1,supportsThinking:!1,supportsListModels:!0,category:"more"},mistral:{id:"mistral",name:"Mistral",nameZh:"Mistral",defaultModel:"mistral-large-latest",supportsBaseUrl:!1,supportsThinking:!1,supportsListModels:!0,category:"more"},deepseek:{id:"deepseek",name:"DeepSeek",nameZh:"DeepSeek",defaultModel:"deepseek-chat",piProviderOverride:"openai",fixedBaseUrl:"https://api.deepseek.com/v1",supportsBaseUrl:!0,supportsThinking:!0,supportsListModels:!0,signupUrl:"https://platform.deepseek.com/api_keys",category:"more"},zai:{id:"zai",name:"ZhipuAI (GLM)",nameZh:"智谱 AI (GLM 国际版)",defaultModel:"glm-4-plus",supportsBaseUrl:!1,supportsThinking:!0,supportsListModels:!1,category:"more"},"zai-cn":{id:"zai-cn",name:"ZhipuAI (GLM China)",nameZh:"智谱 AI (GLM 国内版)",defaultModel:"glm-4-plus",piProviderOverride:"zai",fixedBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",supportsBaseUrl:!1,supportsThinking:!0,supportsListModels:!1,signupUrl:"https://open.bigmodel.cn/",category:"more"},"kimi-coding":{id:"kimi-coding",name:"Kimi Coding",nameZh:"Kimi Coding (月之暗面)",defaultModel:"kimi-k2-thinking",supportsBaseUrl:!1,supportsThinking:!0,supportsListModels:!1,category:"more"},cerebras:{id:"cerebras",name:"Cerebras",nameZh:"Cerebras",defaultModel:"llama-4-scout-17b-16e",supportsBaseUrl:!1,supportsThinking:!1,supportsListModels:!0,category:"more"},minimax:{id:"minimax",name:"MiniMax",nameZh:"MiniMax (国际版)",defaultModel:"MiniMax-M2.5",supportsBaseUrl:!1,supportsThinking:!0,supportsListModels:!1,category:"more"},"minimax-cn":{id:"minimax-cn",name:"MiniMax (China)",nameZh:"MiniMax (国内版)",defaultModel:"MiniMax-M2.5",supportsBaseUrl:!1,supportsThinking:!0,supportsListModels:!1,category:"more"},huggingface:{id:"huggingface",name:"Hugging Face",nameZh:"Hugging Face",defaultModel:"Qwen/Qwen3-235B-A22B-Thinking-2507",supportsBaseUrl:!1,supportsThinking:!0,supportsListModels:!1,category:"more"},ollama:{id:"ollama",name:"Ollama",nameZh:"Ollama (本地)",defaultModel:"llama3.2",piProviderOverride:"openai",fixedBaseUrl:"http://localhost:11434/v1",apiKeyFallback:"ollama",supportsBaseUrl:!0,supportsThinking:!1,supportsListModels:!0,signupUrl:"https://ollama.com/download",category:"more"}},a=Object.keys(n);function o(e){return e in n}function l(){let e=[],t=[];for(let s of a)"primary"===n[s].category?e.push(s):t.push(s);return t.sort((e,t)=>n[e].name.localeCompare(n[t].name)),{primary:e,more:t}}function i(e){return n[e].piProviderOverride??e}let d={deepseek:"DEEPSEEK_API_KEY"};function c(e){return d[e]?d[e]:m[i(e)]}function u(e){let t=n[e];if(t.fixedBaseUrl)return t.fixedBaseUrl;try{let t=(0,r.zr)(i(e));return t[0]?.baseUrl??""}catch{return""}}let m={anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY","azure-openai-responses":"AZURE_OPENAI_API_KEY",google:"GEMINI_API_KEY",groq:"GROQ_API_KEY",cerebras:"CEREBRAS_API_KEY",xai:"XAI_API_KEY",openrouter:"OPENROUTER_API_KEY",zai:"ZAI_API_KEY","zai-cn":"ZAI_API_KEY",mistral:"MISTRAL_API_KEY",minimax:"MINIMAX_API_KEY","minimax-cn":"MINIMAX_API_KEY",huggingface:"HF_TOKEN","kimi-coding":"KIMI_API_KEY"}},48133:(e,t,s)=>{"use strict";s.r(t),s.d(t,{WorkflowYamlRenderer:()=>X});var r=s(95155),n=s(12115),a=s(49387),o=s(20232),l=s(53961),i=s(13545),d=s(73620),c=s(42129),u=s(51914),m=s(6296),x=s(55243),p=s(12651),h=s(66088),g=s(9921),f=s(68459),b=s(1164),v=s(61878),j=s(33210),y=s(48368),N=s(38798),k=s(21362);function w({trigger:e,children:t,open:s,onClose:a}){let o=(0,n.useRef)(null);return(0,n.useEffect)(()=>{if(!s)return;let e=e=>{o.current&&!o.current.contains(e.target)&&a()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[s,a]),(0,r.jsxs)("div",{ref:o,className:"relative",children:[e,s&&(0,r.jsx)("div",{className:"absolute top-full left-0 mt-1 w-full min-w-[220px] max-h-[260px] overflow-y-auto bg-card border border-border rounded-lg shadow-lg z-50",children:t})]})}let S=null,C=!1,A=[];function z({value:e,onChange:t}){let[s,a]=(0,n.useState)(!1),[o,l]=(0,n.useState)(""),[i,d]=(0,n.useState)(S??[]),[c,u]=(0,n.useState)("");(0,n.useEffect)(()=>{S?d(S):(A.push(d),C||(C=!0,fetch("/api/acp/registry").then(e=>e.json()).then(e=>{let t=(e.registry?.agents??[]).map(e=>({id:e.id,name:e.name||e.id}));S=t,A.forEach(e=>e(t)),A.length=0}).catch(()=>{S=[],A.forEach(e=>e([])),A.length=0})))},[]);let m=c?i.filter(e=>e.id.toLowerCase().includes(c.toLowerCase())||e.name.toLowerCase().includes(c.toLowerCase())):i,x=e=>{t(e),a(!1),u("")},p=e?i.find(t=>t.id===e)?.name||e:void 0;return(0,r.jsxs)(w,{open:s,onClose:()=>{a(!1),u("")},trigger:(0,r.jsxs)("button",{type:"button",onClick:()=>a(e=>!e),className:"w-full flex items-center justify-between px-2.5 py-1.5 text-xs rounded-md border border-border bg-background text-foreground hover:bg-muted transition-colors",children:[(0,r.jsx)("span",{className:e?"text-foreground truncate":"text-muted-foreground",children:p||"MindOS"}),(0,r.jsx)(h.A,{size:12,className:"text-muted-foreground shrink-0"})]}),children:[(0,r.jsx)("div",{className:"sticky top-0 bg-card border-b border-border px-2.5 py-1.5",children:(0,r.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded border border-border bg-background",children:[(0,r.jsx)(v.A,{size:11,className:"text-muted-foreground shrink-0"}),(0,r.jsx)("input",{type:"text",value:c,onChange:e=>u(e.target.value),autoFocus:!0,placeholder:"Search agents...",className:"flex-1 text-xs bg-transparent text-foreground placeholder:text-muted-foreground focus:outline-none"})]})}),(0,r.jsxs)("button",{onClick:()=>x(void 0),className:`w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors ${!e?"text-[var(--amber)] font-medium":"text-foreground"}`,children:["MindOS ",(0,r.jsx)("span",{className:"text-muted-foreground/50 ml-1",children:"(default)"})]}),m.slice(0,30).map(t=>(0,r.jsxs)("button",{onClick:()=>x(t.id),className:`w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors ${e===t.id?"text-[var(--amber)] font-medium":"text-foreground"}`,children:[t.name," ",t.name!==t.id&&(0,r.jsxs)("span",{className:"text-muted-foreground/50 ml-1",children:["(",t.id,")"]})]},t.id)),0===i.length&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Loading..."}),i.length>0&&0===m.length&&!c&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No ACP agents found"}),(0,r.jsx)("div",{className:"border-t border-border px-2.5 py-1.5",children:(0,r.jsx)("input",{type:"text",value:o,onChange:e=>l(e.target.value),onKeyDown:e=>{"Enter"===e.key&&o.trim()&&(x(o.trim()),l(""))},placeholder:"Custom agent ID...",className:"w-full px-2 py-1 text-xs rounded border border-border bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring"})})]})}let E=[{group:"Anthropic",models:["claude-sonnet-4-6","claude-opus-4","claude-3.5-sonnet","claude-3.5-haiku"]},{group:"OpenAI",models:["gpt-4o","gpt-4o-mini","o3","o4-mini"]},{group:"Google",models:["gemini-2.5-pro","gemini-2.5-flash"]}];function T({value:e,onChange:t}){let[s,a]=(0,n.useState)(!1),[o,l]=(0,n.useState)(""),i=e=>{t(e),a(!1)};return(0,r.jsxs)(w,{open:s,onClose:()=>a(!1),trigger:(0,r.jsxs)("button",{type:"button",onClick:()=>a(e=>!e),className:"w-full flex items-center justify-between px-2.5 py-1.5 text-xs rounded-md border border-border bg-background text-foreground hover:bg-muted transition-colors",children:[(0,r.jsx)("span",{className:e?"text-foreground truncate":"text-muted-foreground",children:e||"Default model"}),e?(0,r.jsx)(j.A,{size:12,className:"text-muted-foreground shrink-0 hover:text-foreground cursor-pointer",onClick:e=>{e.stopPropagation(),i(void 0)}}):(0,r.jsx)(h.A,{size:12,className:"text-muted-foreground shrink-0"})]}),children:[(0,r.jsx)("button",{onClick:()=>i(void 0),className:`w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors ${!e?"text-[var(--amber)] font-medium":"text-muted-foreground"}`,children:"(default)"}),E.map(t=>(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"px-3 py-1 text-2xs font-semibold text-muted-foreground/60 uppercase tracking-wide bg-muted/30",children:t.group}),t.models.map(t=>(0,r.jsx)("button",{onClick:()=>i(t),className:`w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors ${e===t?"text-[var(--amber)] font-medium":"text-foreground"}`,children:t},t))]},t.group)),(0,r.jsx)("div",{className:"border-t border-border px-2.5 py-1.5",children:(0,r.jsx)("input",{type:"text",value:o,onChange:e=>l(e.target.value),onKeyDown:e=>{"Enter"===e.key&&o.trim()&&(i(o.trim()),l(""))},placeholder:"Custom model ID...",className:"w-full px-2 py-1 text-xs rounded border border-border bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring"})})]})}let $=null,R=!1,M=[];function D({value:e,onChange:t}){let[s,a]=(0,n.useState)(!1),[o,l]=(0,n.useState)($??[]),[i,d]=(0,n.useState)("");(0,n.useEffect)(()=>{$?l($):(M.push(l),R||(R=!0,fetch("/api/skills").then(e=>e.json()).then(e=>{$=(e.skills??[]).map(e=>({name:e.name,description:e.description})),M.forEach(e=>e($)),M.length=0}).catch(()=>{$=[],M.forEach(e=>e([])),M.length=0})))},[]);let c=i?o.filter(e=>e.name.toLowerCase().includes(i.toLowerCase())):o;return(0,r.jsxs)("div",{children:[e.length>0&&(0,r.jsx)("div",{className:"flex flex-wrap gap-1 mb-1.5",children:e.map(s=>(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 pl-2 pr-1 py-0.5 rounded-md text-2xs bg-[var(--amber)]/10 text-[var(--amber)] border border-[var(--amber)]/20",children:[s,(0,r.jsx)("button",{onClick:()=>t(e.filter(e=>e!==s)),className:"p-0.5 rounded hover:bg-[var(--amber)]/20 transition-colors",children:(0,r.jsx)(j.A,{size:10})})]},s))}),(0,r.jsxs)(w,{open:s,onClose:()=>{a(!1),d("")},trigger:(0,r.jsxs)("button",{type:"button",onClick:()=>a(e=>!e),className:"w-full flex items-center justify-between px-2.5 py-1.5 text-xs rounded-md border border-border bg-background text-foreground hover:bg-muted transition-colors",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:0===e.length?"Add skills...":`${e.length} selected`}),(0,r.jsx)(h.A,{size:12,className:"text-muted-foreground"})]}),children:[(0,r.jsx)("div",{className:"sticky top-0 bg-card border-b border-border px-2.5 py-1.5",children:(0,r.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded border border-border bg-background",children:[(0,r.jsx)(v.A,{size:11,className:"text-muted-foreground shrink-0"}),(0,r.jsx)("input",{type:"text",value:i,onChange:e=>d(e.target.value),autoFocus:!0,placeholder:"Search skills...",className:"flex-1 text-xs bg-transparent text-foreground placeholder:text-muted-foreground focus:outline-none"})]})}),c.slice(0,60).map(s=>{let n=e.includes(s.name);return(0,r.jsxs)("button",{onClick:()=>{var r;return r=s.name,void(e.includes(r)?t(e.filter(e=>e!==r)):t([...e,r]))},className:`w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2 ${n?"bg-[var(--amber)]/5":""}`,children:[(0,r.jsx)("span",{className:`w-3.5 h-3.5 rounded border flex items-center justify-center shrink-0 transition-colors ${n?"bg-[var(--amber)] border-[var(--amber)] text-white":"border-border"}`,children:n&&(0,r.jsx)("span",{className:"text-[9px]",children:"✓"})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("span",{className:"block truncate",children:s.name}),s.description&&(0,r.jsx)("span",{className:"block text-2xs text-muted-foreground truncate mt-0.5",children:s.description})]})]},s.name)}),0===o.length&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Loading..."}),o.length>0&&0===c.length&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No skills found"})]})]})}function I({value:e,onChange:t}){let[s,a]=(0,n.useState)(!1),[o,l]=(0,n.useState)(""),i=(0,n.useCallback)(s=>{let r=s.trim();r&&!e.includes(r)&&t([...e,r])},[e,t]),d=(0,n.useCallback)(e=>{e.preventDefault(),a(!1);let t=e.dataTransfer.getData("text/mindos-path");if(t)return void i(t);let s=e.dataTransfer.getData("text/plain");s&&i(s)},[i]),u=(0,n.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect="copy",a(!0)},[]),m=(0,n.useCallback)(()=>a(!1),[]);return(0,r.jsxs)("div",{children:[e.length>0&&(0,r.jsx)("div",{className:"flex flex-col gap-1 mb-1.5",children:e.map(s=>(0,r.jsxs)("div",{className:"flex items-center gap-1.5 pl-2 pr-1 py-1 rounded-md text-2xs bg-muted/60 border border-border group",children:[(0,r.jsx)(y.A,{size:11,className:"text-muted-foreground shrink-0"}),(0,r.jsx)("span",{className:"text-foreground truncate flex-1",title:s,children:s}),(0,r.jsx)("button",{onClick:()=>t(e.filter(e=>e!==s)),className:"p-0.5 rounded hover:bg-[var(--error)]/10 text-muted-foreground hover:text-[var(--error)] opacity-0 group-hover:opacity-100 transition-all",children:(0,r.jsx)(j.A,{size:10})})]},s))}),(0,r.jsxs)("div",{onDrop:d,onDragOver:u,onDragLeave:m,className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 border-dashed transition-colors ${s?"border-[var(--amber)] bg-[var(--amber)]/5":"border-border hover:border-muted-foreground/30"}`,children:[(0,r.jsx)(c.A,{size:14,className:`shrink-0 ${s?"text-[var(--amber)]":"text-muted-foreground/40"}`}),(0,r.jsx)("span",{className:"text-2xs text-muted-foreground",children:"Drag files here from the sidebar"})]}),(0,r.jsx)("div",{className:"mt-1.5",children:(0,r.jsx)("input",{type:"text",value:o,onChange:e=>l(e.target.value),onKeyDown:e=>{"Enter"===e.key&&o.trim()&&(i(o.trim()),l(""))},placeholder:"Or type a file path...",className:"w-full px-2.5 py-1 text-2xs rounded-md border border-border bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring"})})]})}async function L(e){try{let t=await fetch("/api/setup/ls",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e||"~"})});if(!t.ok)return[];return(await t.json()).dirs??[]}catch{return[]}}function P({value:e,onChange:t}){let[s,a]=(0,n.useState)([]),[o,l]=(0,n.useState)(!1),[i,d]=(0,n.useState)(-1),u=(0,n.useRef)(!1),m=(0,n.useRef)(null),[x,p]=(0,n.useState)(!1),[h,g]=(0,n.useState)(e||"~"),[f,b]=(0,n.useState)([]),[v,j]=(0,n.useState)(!1);(0,n.useEffect)(()=>{if(u.current){u.current=!1;return}if(!e.trim()){a([]),l(!1);return}let t=setTimeout(async()=>{let t=function(e){let t=e.trim();if(!t)return"";if(t.endsWith("/")||t.endsWith("\\"))return t;let s=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return s>=0?t.slice(0,s+1):""}(e)||"~",s=await L(t);if(!s.length){a([]),l(!1);return}let r=t.includes("\\")?"\\":"/",n=t.endsWith("/")||t.endsWith("\\")?t:t+r,o=s.map(e=>n+e),i=e.endsWith("/")||e.endsWith("\\")?o:o.filter(t=>t.startsWith(e.trim()));a(i.slice(0,15)),l(i.length>0),d(-1)},300);return()=>clearTimeout(t)},[e]);let y=()=>{a([]),l(!1),d(-1)},S=e=>{u.current=!0,t(e),y(),m.current?.focus()},C=(0,n.useCallback)(async e=>{j(!0),b(await L(e)),j(!1)},[]);return(0,n.useEffect)(()=>{x&&C(h)},[x,h,C]),(0,r.jsxs)("div",{className:"relative flex gap-1.5",children:[(0,r.jsxs)("div",{className:"relative flex-1",children:[(0,r.jsx)("input",{ref:m,type:"text",value:e,onChange:e=>{t(e.target.value),l(!0)},onKeyDown:e=>{o&&0!==s.length&&("ArrowDown"===e.key?(e.preventDefault(),d(e=>Math.min(e+1,s.length-1))):"ArrowUp"===e.key?(e.preventDefault(),d(e=>Math.max(e-1,-1))):"Enter"===e.key&&i>=0?(e.preventDefault(),S(s[i])):"Escape"===e.key?y():"Tab"===e.key&&i>=0&&(e.preventDefault(),S(s[i])))},onBlur:()=>setTimeout(y,150),onFocus:()=>s.length>0&&l(!0),placeholder:"~/projects/my-app",className:"w-full px-2.5 py-1.5 text-xs rounded-lg border border-border bg-background text-foreground font-mono placeholder:text-muted-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring"}),o&&s.length>0&&(0,r.jsx)("div",{role:"listbox",className:"absolute z-50 left-0 right-0 top-full mt-1 rounded-lg border border-border bg-card shadow-lg overflow-auto max-h-[200px]",children:s.map((e,t)=>(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":t===i,onMouseDown:()=>S(e),className:`w-full text-left px-3 py-1.5 text-xs font-mono transition-colors flex items-center gap-1.5 ${t===i?"bg-muted text-foreground":"text-foreground hover:bg-muted/50"}`,children:[(0,r.jsx)(N.A,{size:11,className:"text-[var(--amber)] shrink-0"}),(0,r.jsx)("span",{className:"truncate",children:e})]},e))})]}),(0,r.jsxs)(w,{open:x,onClose:()=>p(!1),trigger:(0,r.jsx)("button",{type:"button",onClick:()=>{g(e||"~"),p(e=>!e)},className:"px-2 py-1.5 rounded-lg border border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground transition-colors",title:"Browse directories",children:(0,r.jsx)(c.A,{size:13})}),children:[(0,r.jsxs)("div",{className:"sticky top-0 bg-card border-b border-border px-2.5 py-2 flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"text-2xs font-mono text-muted-foreground truncate flex-1",title:h,children:h}),(0,r.jsx)("button",{onClick:()=>{t(h),p(!1)},className:"px-2 py-0.5 text-2xs rounded font-medium bg-[var(--amber)] text-[var(--amber-foreground)] shrink-0",children:"Select"})]}),"~"!==h&&(0,r.jsxs)("button",{onClick:()=>{let e=h.split("/");e.length<=1||(e.pop(),g(e.join("/")||"~"))},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors text-muted-foreground flex items-center gap-1.5",children:[(0,r.jsx)(N.A,{size:12,className:"shrink-0"})," .."]}),v&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Loading..."}),!v&&0===f.length&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No subdirectories"}),f.map(e=>(0,r.jsxs)("button",{onClick:()=>{g("~"===h?`~/${e}`:`${h.replace(/\/+$/,"")}/${e}`)},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors text-foreground flex items-center gap-1.5",children:[(0,r.jsx)(N.A,{size:12,className:"text-[var(--amber)] shrink-0"}),(0,r.jsx)("span",{className:"truncate flex-1",children:e}),(0,r.jsx)(k.A,{size:10,className:"text-muted-foreground/40 shrink-0"})]},e))]})]})}function F({step:e,index:t,onChange:s,onDelete:a,onMoveUp:o,onMoveDown:l}){let[i,d]=(0,n.useState)(!e.prompt),[c,u]=(0,n.useState)(!1),m=t=>s({...e,...t}),x=e.skills?.length?e.skills:e.skill?[e.skill]:[],p=!!(e.agent||e.model||x.length||e.context?.length||e.description||e.timeout);return i?(0,r.jsxs)("div",{className:"rounded-lg border border-[var(--amber)]/20 bg-card overflow-hidden shadow-sm",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-muted/20",children:[(0,r.jsx)("span",{className:`text-xs font-medium flex-1 truncate ${e.name?"text-foreground":"text-muted-foreground/50 italic"}`,children:e.name||"Untitled step"}),(0,r.jsxs)("div",{className:"flex items-center gap-0.5",children:[o&&(0,r.jsx)("button",{onClick:o,className:"p-1 rounded hover:bg-muted text-muted-foreground/50 hover:text-foreground transition-colors",title:"Move up",children:(0,r.jsx)(g.A,{size:12})}),l&&(0,r.jsx)("button",{onClick:l,className:"p-1 rounded hover:bg-muted text-muted-foreground/50 hover:text-foreground transition-colors",title:"Move down",children:(0,r.jsx)(h.A,{size:12})}),(0,r.jsx)("button",{onClick:a,className:"p-1 rounded hover:bg-[var(--error)]/10 text-muted-foreground/50 hover:text-[var(--error)] transition-colors",title:"Delete",children:(0,r.jsx)(f.A,{size:11})}),(0,r.jsx)("button",{onClick:()=>d(!1),className:"p-1 rounded hover:bg-muted text-muted-foreground/50 transition-colors",title:"Collapse",children:(0,r.jsx)(g.A,{size:12})})]})]}),(0,r.jsxs)("div",{className:"px-3 py-3 space-y-3",children:[(0,r.jsx)("input",{type:"text",value:e.name,onChange:e=>m({name:e.target.value}),placeholder:"Step name...",autoFocus:!e.name,className:"w-full text-sm font-medium bg-transparent text-foreground placeholder:text-muted-foreground/30 focus:outline-none border-none p-0"}),(0,r.jsx)("textarea",{value:e.prompt,onChange:e=>m({prompt:e.target.value}),placeholder:"What should the AI do?",rows:3,className:"w-full px-3 py-2.5 text-sm rounded-lg border border-border bg-background text-foreground placeholder:text-muted-foreground/40 focus:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-y leading-relaxed"}),(0,r.jsxs)("div",{className:`grid ${e.agent?"grid-cols-2":"grid-cols-1"} gap-2`,children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-2xs text-muted-foreground/60 mb-1",children:"Agent"}),(0,r.jsx)(z,{value:e.agent,onChange:t=>m({agent:t,model:t?e.model:void 0})})]}),e.agent&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-2xs text-muted-foreground/60 mb-1",children:"Model"}),(0,r.jsx)(T,{value:e.model,onChange:e=>m({model:e})})]})]}),(0,r.jsxs)("button",{onClick:()=>u(e=>!e),className:`flex items-center gap-1.5 text-2xs transition-colors ${c||p?"text-muted-foreground":"text-muted-foreground/40 hover:text-muted-foreground"}`,children:[(0,r.jsx)(b.A,{size:11}),c?"Less options":"More options",!c&&p&&(0,r.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--amber)]"})]}),c&&(0,r.jsxs)("div",{className:"space-y-3 pt-1",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-2xs text-muted-foreground/60 mb-1",children:"Skills"}),(0,r.jsx)(D,{value:x,onChange:e=>m({skills:e,skill:void 0})})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-2xs text-muted-foreground/60 mb-1",children:"Context files"}),(0,r.jsx)(I,{value:e.context??[],onChange:e=>m({context:e.length?e:void 0})})]}),(0,r.jsxs)("div",{className:"grid grid-cols-[1fr,auto] gap-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-2xs text-muted-foreground/60 mb-1",children:"Description"}),(0,r.jsx)("input",{type:"text",value:e.description||"",onChange:e=>m({description:e.target.value||void 0}),placeholder:"Optional note...",className:"w-full px-2.5 py-1.5 text-xs rounded-md border border-border bg-background text-foreground placeholder:text-muted-foreground/30 focus:outline-none focus-visible:ring-1 focus-visible:ring-ring"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-2xs text-muted-foreground/60 mb-1",children:"Timeout"}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("input",{type:"number",min:0,value:e.timeout||"",onChange:e=>m({timeout:e.target.value?Number(e.target.value):void 0}),placeholder:"120",className:"w-16 px-2 py-1.5 text-xs rounded-md border border-border bg-background text-foreground placeholder:text-muted-foreground/30 focus:outline-none focus-visible:ring-1 focus-visible:ring-ring"}),(0,r.jsx)("span",{className:"text-2xs text-muted-foreground/40",children:"s"})]})]})]})]})]})]}):(0,r.jsxs)("div",{className:"group flex items-start gap-2 px-3 py-2 rounded-lg hover:bg-muted/40 transition-colors cursor-pointer -ml-1",onClick:()=>d(!0),children:[(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("span",{className:`text-sm leading-tight block ${e.name?"text-foreground font-medium":"text-muted-foreground/50 italic"}`,children:e.name||"Untitled step"}),p&&(0,r.jsxs)("div",{className:"flex items-center gap-1 mt-1 flex-wrap",children:[e.agent&&(0,r.jsx)("span",{className:"text-2xs px-1.5 py-0.5 rounded-full bg-muted text-muted-foreground",children:e.agent}),x.slice(0,2).map(e=>(0,r.jsx)("span",{className:"text-2xs px-1.5 py-0.5 rounded-full bg-[var(--amber)]/8 text-[var(--amber)]",children:e},e)),x.length>2&&(0,r.jsxs)("span",{className:"text-2xs text-muted-foreground/50",children:["+",x.length-2]}),e.context?.length?(0,r.jsxs)("span",{className:"text-2xs text-muted-foreground/50",children:[e.context.length," files"]}):null]}),e.prompt&&(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/50 mt-1 line-clamp-1 leading-relaxed",children:e.prompt})]}),(0,r.jsx)(h.A,{size:12,className:"text-muted-foreground/30 mt-1 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"})]})}function O({workflow:e,filePath:t,onChange:s,onSaved:a}){let[o,i]=(0,n.useState)(!1),[h,g]=(0,n.useState)(""),[f,b]=(0,n.useState)(!1);(0,n.useEffect)(()=>{if(!f)return;let e=setTimeout(()=>b(!1),3e3);return()=>clearTimeout(e)},[f]);let v=t=>s({...e,...t}),j=(0,n.useCallback)((t,r)=>{let n=[...e.steps];n[t]=r,s({...e,steps:n})},[e,s]),y=(0,n.useCallback)(t=>{let r=e.steps[t];(!(r.name||r.prompt)||window.confirm(`Delete step "${r.name||"Untitled"}"?`))&&s({...e,steps:e.steps.filter((e,s)=>s!==t)})},[e,s]),N=(0,n.useCallback)(()=>{let t=e.steps.map(e=>e.id),r=e.steps.length+1,n={id:function(e,t){let s=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"step",r=s,n=2;for(;t.includes(r);)r=`${s}-${n}`,n++;return r}(`step-${r}`,t),name:`Step ${r}`,prompt:""};s({...e,steps:[...e.steps,n]})},[e,s]),k=(0,n.useCallback)((t,r)=>{if(r<0||r>=e.steps.length)return;let n=[...e.steps],[a]=n.splice(t,1);n.splice(r,0,a),s({...e,steps:n})},[e,s]),w=async()=>{i(!0),g(""),b(!1);try{let s,r=(s={title:e.title},e.description&&(s.description=e.description),e.workDir&&(s.workDir=e.workDir),e.skills?.length&&(s.skills=e.skills),e.tools?.length&&(s.tools=e.tools),s.steps=e.steps.map(e=>{let t={id:e.id,name:e.name};return e.description&&(t.description=e.description),e.agent&&(t.agent=e.agent),e.model&&(t.model=e.model),e.skill&&(t.skill=e.skill),e.skills?.length&&(t.skills=e.skills),e.tools?.length&&(t.tools=e.tools),e.context?.length&&(t.context=e.context),t.prompt=e.prompt,e.timeout&&(t.timeout=e.timeout),t}),d.Ay.dump(s,{lineWidth:-1,noRefs:!0,quotingType:'"',forceQuotes:!1})),n=await fetch("/api/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t,op:"save_file",content:r})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Save failed (HTTP ${n.status})`)}b(!0),a?.()}catch(e){g(e instanceof Error?e.message:"Save failed")}finally{i(!1)}};(0,n.useEffect)(()=>{let t=t=>{(t.metaKey||t.ctrlKey)&&"s"===t.key&&(t.preventDefault(),!o&&e.title.trim()&&e.steps.length>0&&w())};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)});let S=!o&&!!e.title.trim()&&e.steps.length>0;return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"space-y-3 mb-8",children:[(0,r.jsx)("input",{type:"text",value:e.title,onChange:e=>v({title:e.target.value}),placeholder:"Flow title...",className:"w-full text-lg font-semibold bg-transparent text-foreground placeholder:text-muted-foreground/40 focus:outline-none border-none p-0 leading-tight"}),(0,r.jsx)("input",{type:"text",value:e.description||"",onChange:e=>v({description:e.target.value||void 0}),placeholder:"Add a description...",className:"w-full text-sm bg-transparent text-muted-foreground placeholder:text-muted-foreground/30 focus:outline-none border-none p-0"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(c.A,{size:12,className:"text-muted-foreground/40 shrink-0"}),(0,r.jsx)(P,{value:e.workDir||"",onChange:e=>v({workDir:e||void 0})})]})]}),e.steps.length>0?(0,r.jsxs)("div",{className:"relative",children:[e.steps.length>1&&(0,r.jsx)("div",{className:"absolute left-[19px] top-6 bottom-16 w-px bg-border"}),(0,r.jsx)("div",{className:"flex flex-col gap-3 mb-5 relative",children:e.steps.map((t,s)=>(0,r.jsxs)("div",{className:"relative pl-11",children:[(0,r.jsx)("div",{className:"absolute left-[7px] top-3 w-[22px] h-[22px] rounded-full border-2 border-border bg-background z-10 flex items-center justify-center",children:(0,r.jsx)("span",{className:"text-[10px] font-bold text-muted-foreground/60",children:s+1})}),(0,r.jsx)(F,{step:t,index:s,onChange:e=>j(s,e),onDelete:()=>y(s),onMoveUp:s>0?()=>k(s,s-1):void 0,onMoveDown:s<e.steps.length-1?()=>k(s,s+1):void 0})]},t.id))}),(0,r.jsxs)("div",{className:"relative pl-11",children:[(0,r.jsx)("div",{className:"absolute left-[7px] top-2.5 w-[22px] h-[22px] rounded-full border-2 border-dashed border-border bg-background z-10 flex items-center justify-center",children:(0,r.jsx)(u.A,{size:9,className:"text-muted-foreground/40"})}),(0,r.jsx)("button",{onClick:N,className:"w-full text-left px-3 py-2 rounded-lg text-xs text-muted-foreground/60 hover:text-muted-foreground hover:bg-muted/40 transition-colors",children:"Add step..."})]})]}):(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(0,r.jsx)("div",{className:"w-12 h-12 rounded-2xl bg-[var(--amber)]/8 flex items-center justify-center mb-4",children:(0,r.jsx)(l.A,{size:22,className:"text-[var(--amber)]/60"})}),(0,r.jsx)("p",{className:"text-sm font-medium text-foreground mb-1",children:"Build your flow"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground/60 mb-5 max-w-[240px]",children:"Each step is a task for an AI agent. Chain them together to automate complex workflows."}),(0,r.jsxs)("button",{onClick:N,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-lg text-xs font-medium bg-[var(--amber)] text-[var(--amber-foreground)] hover:opacity-90 transition-opacity",children:[(0,r.jsx)(u.A,{size:12}),"Add first step"]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-3 mt-8 pt-4 border-t border-border/50",children:[(0,r.jsxs)("button",{onClick:w,disabled:!S,title:e.title.trim()?0===e.steps.length?"Add at least one step":void 0:"Title is required",className:`flex items-center gap-1.5 px-4 py-2 rounded-lg text-xs font-medium transition-all disabled:opacity-40 disabled:cursor-not-allowed ${S?"bg-[var(--amber)] text-[var(--amber-foreground)] hover:opacity-90":"bg-muted text-muted-foreground"}`,children:[o?(0,r.jsx)(m.A,{size:12,className:"animate-spin"}):(0,r.jsx)(x.A,{size:12}),o?"Saving...":"Save"]}),h&&(0,r.jsx)("span",{className:"text-xs text-[var(--error)]",children:h}),f&&!h&&(0,r.jsxs)("span",{className:"flex items-center gap-1 text-2xs text-[var(--success)]",children:[(0,r.jsx)(p.A,{size:11}),"Saved"]}),(0,r.jsx)("kbd",{className:"text-2xs text-muted-foreground/30 ml-auto font-mono",children:"Ctrl+S"})]})]})}var _=s(30125),U=s(62791),B=s(86901),W=s(21628),H=s(9199);let K=new Map;async function G(e,t){if(K.has(e))return K.get(e);try{let s=await fetch("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"read",name:e}),signal:t});if(!s.ok)return K.set(e,null),null;let r=(await s.json()).content;return K.set(e,r??null),r??null}catch{return null}}async function Y(e,t){try{let s=await fetch(`/api/acp/registry?agent=${encodeURIComponent(e)}`,{signal:t});if(!s.ok)return null;let r=await s.json();if(r.agent?.id)return{id:r.agent.id,name:r.agent.name||e};return null}catch{return null}}async function J(e,t,s,r,n){let a=function(e,t){let s=[];if(e.skills?.length)for(let t of e.skills)s.includes(t)||s.push(t);else e.skill&&s.push(e.skill);for(let e of t.skills??[])s.includes(e)||s.push(e);return s}(e,t),o=new Map;if(a.length>0)for(let[e,t]of(await Promise.all(a.map(async e=>{let t=await G(e,n);return[e,t]}))))t&&o.set(e,t);let l=null;e.agent&&(l=await Y(e.agent,n));let i={messages:[{role:"user",content:function(e,t,s){let r=t.steps.map((e,t)=>`${t+1}. ${e.name}`).join("\n"),n=e.skills?.length?e.skills[0]:e.skill,a="";if(s.size>0){let e=[];for(let[t,r]of s){let s=t===n;e.push(`### ${s?"[Primary] ":""}Skill: ${t}
|
|
150
|
-
|
|
151
|
-
${r}`)}a=`
|
|
152
|
-
|
|
153
|
-
---
|
|
154
|
-
## Skill Reference
|
|
155
|
-
|
|
156
|
-
Follow the guidelines from these skills when executing this step:
|
|
157
|
-
|
|
158
|
-
${e.join("\n\n---\n\n")}`}return`You are executing step ${e.index+1} of a workflow: "${e.name}".
|
|
159
|
-
|
|
160
|
-
Context of the full workflow "${t.title}":
|
|
161
|
-
${r}
|
|
162
|
-
|
|
163
|
-
Current step instructions:
|
|
164
|
-
${e.prompt||"(No specific instructions — use common sense.)"}${a}
|
|
165
|
-
|
|
166
|
-
Execute concisely. Provide:
|
|
167
|
-
1. What you did / what the output is
|
|
168
|
-
2. Any decisions made
|
|
169
|
-
3. What the next step should watch out for
|
|
170
|
-
|
|
171
|
-
Be specific and actionable. Format in Markdown.`}(e,t,o)}],currentFile:s};l&&(i.selectedAcpAgent=l);let d=await fetch("/api/ask",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i),signal:n});if(!d.ok)throw Error(`Request failed (HTTP ${d.status})`);if(!d.body)throw Error("No response body");let c=d.body.getReader(),u=new TextDecoder,m="";for(;;){let{done:e,value:t}=await c.read();if(e)break;for(let e of u.decode(t,{stream:!0}).split("\n")){let t=e.match(/^data:(.+)$/);if(t){try{let e=JSON.parse(t[1]);if("text_delta"===e.type&&"string"==typeof e.delta)m+=e.delta,r(m);else if("thinking_delta"===e.type&&"string"==typeof e.delta)m+=e.delta,r(m);else if("error"===e.type&&e.message)throw Error(e.message)}catch{let t=e.match(/^0:"((?:[^"\\]|\\.)*)"$/);t&&r(m+=t[1].replace(/\\n/g,"\n").replace(/\\"/g,'"').replace(/\\\\/g,"\\"))}continue}let s=e.match(/^0:"((?:[^"\\]|\\.)*)"$/);s&&r(m+=s[1].replace(/\\n/g,"\n").replace(/\\"/g,'"').replace(/\\\\/g,"\\"))}}}function V(e){return e.steps.map((e,t)=>({...e,index:t,status:"pending",output:"",error:void 0}))}function q({status:e,index:t}){let s="w-[26px] h-[26px] rounded-full flex items-center justify-center shrink-0 transition-all";return"running"===e?(0,r.jsx)("div",{className:`${s} bg-[var(--amber)]/15 ring-2 ring-[var(--amber)]/30`,children:(0,r.jsx)(m.A,{size:12,className:"text-[var(--amber)] animate-spin"})}):"done"===e?(0,r.jsx)("div",{className:`${s} bg-[var(--success)]/15`,children:(0,r.jsx)(p.A,{size:13,className:"text-[var(--success)]"})}):"error"===e?(0,r.jsx)("div",{className:`${s} bg-[var(--error)]/15`,children:(0,r.jsx)(i.A,{size:13,className:"text-[var(--error)]"})}):"skipped"===e?(0,r.jsx)("div",{className:`${s} bg-muted/50`,children:(0,r.jsx)(_.A,{size:11,className:"text-muted-foreground/40"})}):(0,r.jsx)("div",{className:`${s} border-2 border-border bg-background`,children:(0,r.jsx)("span",{className:"text-[11px] font-bold text-muted-foreground/50",children:t+1})})}function Z({step:e,canRun:t,onRun:s,onSkip:a,onCancel:l}){let[d,c]=(0,n.useState)(!1),u=!!(e.output||e.error),m=e.skills?.length?e.skills:e.skill?[e.skill]:[];return"running"===e.status||e.status,(0,r.jsx)("div",{className:`transition-opacity ${"skipped"===e.status?"opacity-50":""}`,children:(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)(q,{status:e.status,index:e.index}),(0,r.jsxs)("div",{className:"flex-1 min-w-0 pt-0.5",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 justify-between",children:[(0,r.jsx)("span",{className:`text-sm font-medium truncate ${"done"===e.status?"text-foreground":"running"===e.status?"text-[var(--amber)]":"error"===e.status?"text-[var(--error)]":"text-foreground/70"}`,children:e.name}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[null!=e.durationMs&&("done"===e.status||"error"===e.status)&&(0,r.jsx)("span",{className:"text-2xs text-muted-foreground/40 font-mono",children:function(e){if(e<1e3)return`${e}ms`;let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}(e.durationMs)}),"pending"===e.status&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{onClick:s,disabled:!t,className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-2xs font-medium transition-all disabled:opacity-30 bg-[var(--amber)] text-[var(--amber-foreground)]",children:[(0,r.jsx)(o.A,{size:9})," Run"]}),(0,r.jsx)("button",{onClick:a,className:"px-1.5 py-0.5 rounded-md text-2xs text-muted-foreground/50 hover:text-muted-foreground hover:bg-muted transition-colors",children:"Skip"})]}),"running"===e.status&&(0,r.jsxs)("button",{onClick:l,className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-2xs text-[var(--error)]/70 hover:text-[var(--error)] hover:bg-[var(--error)]/10 transition-colors",children:[(0,r.jsx)(U.A,{size:9})," Stop"]}),u&&"running"!==e.status&&(0,r.jsx)("button",{onClick:()=>c(e=>!e),className:"p-0.5 rounded text-muted-foreground/30 hover:text-muted-foreground transition-colors",children:(0,r.jsx)(h.A,{size:12,className:`transition-transform ${d?"rotate-180":""}`})})]})]}),(e.agent||m.length>0)&&(0,r.jsxs)("div",{className:"flex gap-1 mt-0.5 flex-wrap",children:[e.agent&&(0,r.jsx)("span",{className:"text-2xs text-muted-foreground/50",children:e.agent}),e.agent&&m.length>0&&(0,r.jsx)("span",{className:"text-2xs text-muted-foreground/20",children:"/"}),m.map(e=>(0,r.jsx)("span",{className:"text-2xs text-[var(--amber)]/60",children:e},e))]}),(d||"running"===e.status)&&u&&(0,r.jsxs)("div",{className:"mt-2 rounded-lg overflow-hidden border border-border/50",children:[e.error&&(0,r.jsxs)("div",{className:"px-3 py-2.5 bg-[var(--error)]/5",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,r.jsx)(i.A,{size:10,className:"text-[var(--error)]"}),(0,r.jsx)("span",{className:"text-2xs font-medium text-[var(--error)]",children:"Error"})]}),(0,r.jsx)("div",{className:"text-xs text-[var(--error)]/80 whitespace-pre-wrap break-words leading-relaxed",children:e.error})]}),e.output&&(0,r.jsxs)("div",{className:"px-3 py-2.5 bg-muted/20",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-1.5",children:[(0,r.jsx)(B.A,{size:10,className:"text-[var(--amber)]"}),(0,r.jsx)("span",{className:"text-2xs text-muted-foreground/50 uppercase tracking-wider font-medium",children:"Output"}),"running"===e.status&&(0,r.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--amber)] animate-pulse"})]}),(0,r.jsx)("div",{className:"text-xs leading-relaxed text-foreground/80 whitespace-pre-wrap break-words",children:e.output})]})]})]})]})})}function Q({workflow:e,filePath:t}){let[s,a]=(0,n.useState)(()=>V(e)),[o,l]=(0,n.useState)(!1),d=(0,n.useRef)(null);(0,n.useEffect)(()=>{a(V(e)),l(!1)},[e]);let u=(0,n.useCallback)(()=>{d.current?.abort(),d.current=null,l(!1),a(e=>e.map(e=>"running"===e.status?{...e,status:"error",error:"Cancelled"}:e))},[]),x=(0,n.useCallback)(async s=>{if(o)return;d.current?.abort();let r=new AbortController;d.current=r,l(!0);let n=Date.now();a(e=>e.map((e,t)=>t===s?{...e,status:"running",output:"",error:void 0,startedAt:new Date}:e));try{let o={...e.steps[s],index:s,status:"running",output:""};await J(o,e,t,e=>a(t=>t.map((t,r)=>r===s?{...t,output:e}:t)),r.signal);let l=Date.now()-n;a(e=>e.map((e,t)=>t===s?{...e,status:"done",completedAt:new Date,durationMs:l}:e))}catch(t){if(t instanceof Error&&"AbortError"===t.name)return;let e=Date.now()-n;a(r=>r.map((r,n)=>n===s?{...r,status:"error",error:t instanceof Error?t.message:String(t),durationMs:e}:r))}finally{l(!1)}},[o,e,t]),h=(0,n.useCallback)(e=>{a(t=>t.map((t,s)=>s===e?{...t,status:"skipped"}:t))},[]),g=(0,n.useCallback)(()=>{d.current?.abort(),d.current=null,l(!1),K.clear(),a(V(e))},[e]),f=s.filter(e=>"done"===e.status).length,b=s.length>0?Math.round(f/s.length*100):0,v=f===s.length&&s.length>0,j=s.findIndex(e=>"pending"===e.status),y=s.some(e=>"error"===e.status);return(0,r.jsxs)("div",{children:[(e.workDir||e.description)&&(0,r.jsxs)("div",{className:"flex items-center gap-3 mb-4 text-xs text-muted-foreground flex-wrap",children:[e.workDir&&(0,r.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-2xs bg-muted/50 px-2 py-0.5 rounded",children:[(0,r.jsx)(c.A,{size:10,className:"shrink-0"}),e.workDir]}),e.description&&(0,r.jsx)("span",{className:"leading-relaxed",children:e.description})]}),(0,r.jsxs)("div",{className:"mb-6",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsx)("div",{className:"flex items-center gap-2",children:v?(0,r.jsxs)("span",{className:"flex items-center gap-1.5 text-xs font-medium text-[var(--success)]",children:[(0,r.jsx)(p.A,{size:13}),"Complete"]}):y?(0,r.jsxs)("span",{className:"flex items-center gap-1.5 text-xs font-medium text-[var(--error)]",children:[(0,r.jsx)(i.A,{size:13}),f,"/",s.length," done"]}):(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[f,"/",s.length]})}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[j>=0&&(0,r.jsxs)("button",{onClick:()=>x(j),disabled:o,className:"flex items-center gap-1.5 px-3 py-1 rounded-md text-xs font-medium transition-all disabled:opacity-40 bg-[var(--amber)] text-[var(--amber-foreground)]",children:[o?(0,r.jsx)(m.A,{size:11,className:"animate-spin"}):(0,r.jsx)(W.A,{size:11}),o?"Running...":"Run next"]}),(0,r.jsxs)("button",{onClick:g,className:"flex items-center gap-1 px-2 py-1 rounded-md text-2xs text-muted-foreground/50 hover:text-muted-foreground hover:bg-muted transition-colors",children:[(0,r.jsx)(H.A,{size:10}),"Reset"]})]})]}),(0,r.jsx)("div",{className:"h-1 rounded-full bg-border/50 overflow-hidden",children:(0,r.jsx)("div",{className:`h-full rounded-full transition-all duration-500 ease-out ${v?"bg-[var(--success)]":y?"bg-[var(--error)]":"bg-[var(--amber)]"}`,style:{width:`${b}%`}})})]}),(0,r.jsxs)("div",{className:"relative",children:[s.length>1&&(0,r.jsx)("div",{className:"absolute left-[12px] top-5 bottom-5 w-px bg-border/50"}),(0,r.jsx)("div",{className:"flex flex-col gap-4",children:s.map((e,t)=>(0,r.jsx)(Z,{step:e,canRun:!o,onRun:()=>x(t),onSkip:()=>h(t),onCancel:u},e.id))})]})]})}function X({filePath:e,content:t}){let s=(0,n.useMemo)(()=>(function(e){try{let t=d.Ay.load(e,{schema:d.Ay.JSON_SCHEMA});if(!t)return{workflow:null,errors:["File is empty"]};if("object"!=typeof t)return{workflow:null,errors:["Content is not valid YAML"]};let s=function(e){let t=[];if(!e||"object"!=typeof e)return{valid:!1,errors:["Must be a valid YAML object"]};if(e.title&&"string"==typeof e.title&&e.title.trim()||t.push("Missing required field 'title' (string)"),void 0!==e.description&&"string"!=typeof e.description&&t.push("'description' must be a string"),void 0!==e.skills&&(Array.isArray(e.skills)?e.skills.every(e=>"string"==typeof e)||t.push("'skills' must contain only strings"):t.push("'skills' must be an array of strings")),void 0!==e.tools&&(Array.isArray(e.tools)?e.tools.every(e=>"string"==typeof e)||t.push("'tools' must contain only strings"):t.push("'tools' must be an array of strings")),e.steps)if(Array.isArray(e.steps))if(0===e.steps.length)t.push("'steps' must have at least 1 step");else{let s=new Set;e.steps.forEach((e,r)=>{var n,a;let o,l,i=(n=e,a=r,o=[],l=`steps[${a}]`,n&&"object"==typeof n?(n.id&&"string"==typeof n.id&&n.id.trim()?/^[a-z0-9_-]+$/.test(n.id)||o.push(`${l}.id: '${n.id}' is invalid — use only lowercase letters, numbers, hyphens, underscores (e.g., 'run-tests')`):o.push(`${l}: missing required field 'id' (non-empty string)`),n.name&&"string"==typeof n.name&&n.name.trim()||o.push(`${l}: missing required field 'name' (non-empty string)`),void 0!==n.description&&"string"!=typeof n.description&&o.push(`${l}.description: must be a string`),void 0===n.agent||"string"==typeof n.agent&&n.agent.trim()||o.push(`${l}.agent: must be a non-empty string`),void 0===n.skill||"string"==typeof n.skill&&n.skill.trim()||o.push(`${l}.skill: must be a non-empty string`),void 0!==n.tools&&(Array.isArray(n.tools)?n.tools.every(e=>"string"==typeof e)||o.push(`${l}.tools: must contain only strings`):o.push(`${l}.tools: must be an array of strings`)),n.prompt&&"string"==typeof n.prompt&&n.prompt.trim()||o.push(`${l}: missing required field 'prompt' (non-empty string)`),void 0!==n.timeout&&("number"!=typeof n.timeout||n.timeout<=0)&&o.push(`${l}.timeout: must be a positive number (seconds)`)):o.push(`${l}: must be a valid object`),o);t.push(...i);let d=e?.id;"string"==typeof d&&d.trim()&&(s.has(d)&&t.push(`steps[${r}].id: duplicate id '${d}' (each step must have a unique id)`),s.add(d))})}else t.push("'steps' must be an array");else t.push("Missing required field 'steps' (array)");return{valid:0===t.length,errors:t}}(t);if(!s.valid)return{workflow:null,errors:s.errors};return{workflow:t,errors:[]}}catch(e){return{workflow:null,errors:[e instanceof Error?e.message:String(e)]}}})(t),[t]),[c,u]=(0,n.useState)("edit"),[m,x]=(0,n.useState)(!1),[p,h]=(0,n.useState)(()=>s.workflow?structuredClone(s.workflow):{title:"",description:"",steps:[]});(0,n.useRef)(t);let g=(0,n.useMemo)(()=>s.workflow??null,[s.workflow]),f=(0,n.useCallback)(e=>{h(e),x(!0)},[]),b=(0,n.useCallback)(()=>x(!1),[]),v=g??p,j=v.steps.length>0&&!!v.title,y=s.errors.length>0,N=v.title?0===v.steps.length?"Add at least one step":m?"Save changes first":void 0:"Add a title first",k=e=>{("run"!==e||j)&&u(e)};return(0,r.jsxs)("div",{className:"max-w-[720px] mx-auto py-8 px-2",children:[(0,r.jsxs)("div",{className:"mb-8",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 p-0.5 rounded-lg bg-muted/50",children:[(0,r.jsxs)("button",{onClick:()=>k("edit"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-all ${"edit"===c?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,r.jsx)(a.A,{size:11}),"Edit"]}),(0,r.jsxs)("button",{onClick:()=>k("run"),disabled:!j,title:N,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-all disabled:opacity-30 disabled:cursor-not-allowed ${"run"===c?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,r.jsx)(o.A,{size:11}),"Run"]})]}),p.steps.length>0&&(0,r.jsxs)("span",{className:"text-2xs text-muted-foreground/60 font-mono",children:[p.steps.length," step",1!==p.steps.length?"s":""]})]}),(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)("div",{className:"mt-1 w-8 h-8 rounded-lg bg-[var(--amber)]/10 flex items-center justify-center shrink-0",children:(0,r.jsx)(l.A,{size:16,className:"text-[var(--amber)]"})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("h1",{className:"text-lg font-semibold text-foreground truncate leading-tight",children:[p.title||"Untitled Flow",m&&(0,r.jsx)("span",{className:"text-[var(--amber)] ml-1.5 text-sm",title:"Unsaved changes",children:"*"})]}),p.description&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:p.description})]})]})]}),y&&"edit"===c&&(0,r.jsxs)("div",{className:"mb-5 px-3.5 py-3 rounded-lg bg-[var(--error)]/8 border border-[var(--error)]/20",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,r.jsx)(i.A,{size:13,className:"text-[var(--error)] shrink-0"}),(0,r.jsx)("span",{className:"text-xs font-medium text-[var(--error)]",children:"Parse issues found"})]}),(0,r.jsx)("ul",{className:"text-2xs text-[var(--error)]/70 pl-5 list-disc space-y-0.5",children:s.errors.slice(0,3).map((e,t)=>(0,r.jsx)("li",{children:e},t))})]}),"edit"===c?(0,r.jsx)(O,{workflow:p,filePath:e,onChange:f,onSaved:b}):(0,r.jsx)(Q,{workflow:v,filePath:e})]})}},48755:(e,t,s)=>{Promise.resolve().then(s.t.bind(s,66872,23)),Promise.resolve().then(s.bind(s,92524)),Promise.resolve().then(s.bind(s,86343)),Promise.resolve().then(s.bind(s,18847)),Promise.resolve().then(s.bind(s,14446)),Promise.resolve().then(s.bind(s,88946)),Promise.resolve().then(s.bind(s,35504)),Promise.resolve().then(s.bind(s,92306)),Promise.resolve().then(s.bind(s,92950)),Promise.resolve().then(s.bind(s,20814)),Promise.resolve().then(s.bind(s,20870)),Promise.resolve().then(s.bind(s,56406)),Promise.resolve().then(s.bind(s,39594)),Promise.resolve().then(s.bind(s,87500)),Promise.resolve().then(s.bind(s,87986)),Promise.resolve().then(s.bind(s,48133)),Promise.resolve().then(s.bind(s,22554)),Promise.resolve().then(s.bind(s,26490)),Promise.resolve().then(s.bind(s,91459)),Promise.resolve().then(s.bind(s,40430)),Promise.resolve().then(s.bind(s,93042)),Promise.resolve().then(s.t.bind(s,16719,23)),Promise.resolve().then(s.t.bind(s,377,23)),Promise.resolve().then(s.t.bind(s,98663,23)),Promise.resolve().then(s.t.bind(s,75282,23))},51842:(e,t,s)=>{"use strict";s.d(t,{A:()=>c});var r=s(95155),n=s(12115),a=s(12651),o=s(66088),l=s(30125),i=s(47376),d=s(91053);function c({value:e,onChange:t,showSkip:s=!1,compact:c=!1,configuredProviders:u}){let{locale:m}=(0,d.Y)(),[x,p]=(0,n.useState)(!1),h=(0,i.bf)(),g=s=>{let n=i.T_[s],o="zh"===m?n.nameZh:n.name,l=e===s,d=u?.has(s);return c?(0,r.jsxs)("button",{type:"button",onClick:()=>t(s),className:`flex items-center gap-2 px-3 py-2 rounded-lg border text-left transition-all text-sm ${l?"border-[var(--amber)] bg-[var(--amber-subtle)] shadow-sm":"border-border/50 hover:border-border hover:bg-muted/30"}`,children:[(0,r.jsx)("span",{className:`font-medium ${l?"text-foreground":"text-muted-foreground"}`,children:o}),d&&!l&&(0,r.jsx)(a.A,{size:12,className:"text-success ml-auto shrink-0"}),l&&(0,r.jsx)(a.A,{size:14,className:"ml-auto shrink-0",style:{color:"var(--amber)"}})]},s):(0,r.jsxs)("button",{type:"button",onClick:()=>t(s),className:"flex items-start gap-3 p-4 rounded-xl border text-left transition-all duration-150",style:{background:l?"var(--amber-dim)":"var(--card)",borderColor:l?"var(--amber)":"var(--border)"},children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("p",{className:"text-sm font-medium",style:{color:"var(--foreground)"},children:o}),(0,r.jsx)("p",{className:"text-xs mt-0.5",style:{color:"var(--muted-foreground)"},children:n.defaultModel})]}),d&&!l&&(0,r.jsx)(a.A,{size:14,className:"text-success shrink-0 mt-0.5"}),l&&(0,r.jsx)(a.A,{size:16,className:"shrink-0 mt-0.5",style:{color:"var(--amber)"}})]},s)},{primary:f,more:b}=h;return(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("div",{className:c?"flex flex-wrap gap-2":"grid grid-cols-1 gap-2",children:f.map(g)}),b.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{type:"button",onClick:()=>p(!x),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",children:[(0,r.jsx)(o.A,{size:12,className:`transition-transform ${x?"rotate-180":""}`}),x?"zh"===m?"收起":"Show less":"zh"===m?`更多 (${b.length})`:`More providers (${b.length})`]}),x&&(0,r.jsx)("div",{className:c?"flex flex-wrap gap-2":"grid grid-cols-1 gap-2",children:b.map(g)})]}),s&&(0,r.jsxs)("button",{type:"button",onClick:()=>t("skip"),className:"flex items-center gap-2 px-3 py-2 rounded-lg border text-left transition-all text-sm w-full mt-1",style:{background:"skip"===e?"var(--amber-dim)":"var(--card)",borderColor:"skip"===e?"var(--amber)":"var(--border)"},children:[(0,r.jsx)(l.A,{size:14,className:"shrink-0",style:{color:"skip"===e?"var(--amber)":"var(--muted-foreground)"}}),(0,r.jsx)("span",{className:`font-medium ${"skip"===e?"text-foreground":"text-muted-foreground"}`,children:"zh"===m?"暂时跳过":"Skip for now"}),"skip"===e&&(0,r.jsx)(a.A,{size:14,className:"ml-auto shrink-0",style:{color:"var(--amber)"}})]})]})}},56406:(e,t,s)=>{"use strict";s.r(t),s.d(t,{SummaryRenderer:()=>x});var r=s(95155),n=s(12115),a=s(91958),o=s(86901),l=s(48368),i=s(84980),d=s(91337),c=s(22356);function u(e){let t=Date.now()-e,s=Math.floor(t/6e4),r=Math.floor(t/36e5),n=Math.floor(t/864e5);return s<1?"just now":s<60?`${s}m ago`:r<24?`${r}h ago`:`${n}d ago`}function m(e){return e.split("/").pop()?.replace(/\.(md|csv)$/,"")??e}function x({filePath:e}){let[t,s]=(0,n.useState)([]),[x,p]=(0,n.useState)(""),[h,g]=(0,n.useState)(!1),[f,b]=(0,n.useState)(""),[v,j]=(0,n.useState)(!1),y=(0,n.useRef)(null);async function N(){if(0===t.length)return;y.current?.abort();let e=new AbortController;y.current=e,p(""),b(""),g(!0),j(!1);let s=t.map(e=>e.path),r=t.map(e=>`- **${m(e.path)}** (${e.path}, modified ${u(e.mtime)})`).join("\n"),n=`You are summarizing recent changes in a personal knowledge base (MindOS).
|
|
172
|
-
|
|
173
|
-
The following files were recently modified:
|
|
174
|
-
${r}
|
|
175
|
-
|
|
176
|
-
Please provide a concise daily briefing in this format:
|
|
177
|
-
1. **Key changes**: What was added or updated in each file (1–2 sentences per file)
|
|
178
|
-
2. **Themes**: Any patterns or recurring topics across the changes
|
|
179
|
-
3. **Suggested next actions**: 2–3 actionable follow-ups based on the content
|
|
180
|
-
|
|
181
|
-
Be specific. Reference actual content from the files. Keep the total response under 300 words.`;try{let t=await fetch("/api/ask",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:[{role:"user",content:n}],attachedFiles:s}),signal:e.signal});if(!t.ok)throw Error(`HTTP ${t.status}`);if(!t.body)throw Error("No response body");let r=t.body.getReader(),a=new TextDecoder,o="";for(;;){let{done:e,value:t}=await r.read();if(e)break;for(let e of a.decode(t,{stream:!0}).split("\n")){let t=e.match(/^0:"((?:[^"\\]|\\.)*)"$/);t?o+=t[1].replace(/\\n/g,"\n").replace(/\\"/g,'"').replace(/\\\\/g,"\\"):!e||e.startsWith("d:")||e.startsWith("e:")||e.startsWith("0:")||(o+=e)}p(o)}j(!0)}catch(e){e instanceof Error&&"AbortError"!==e.name&&b(e.message||"Failed to generate summary")}finally{g(!1)}}return(0,n.useEffect)(()=>{(0,c.n)("/api/recent-files?limit=8").then(e=>s(e.filter(e=>e.path.endsWith(".md")))).catch(e=>{console.warn("[SummaryRenderer] fetch recent-files failed:",e)})},[e]),(0,n.useEffect)(()=>()=>{y.current?.abort()},[]),(0,r.jsxs)("div",{style:{maxWidth:720,margin:"0 auto",padding:"1.5rem 0"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:"1.5rem",flexWrap:"wrap"},children:[(0,r.jsx)("span",{className:"font-display",style:{fontSize:11,color:"var(--muted-foreground)"},children:t.length>0?`${t.length} recently modified files`:"Loading recent files…"}),(0,r.jsxs)("button",{onClick:N,disabled:h||0===t.length,className:"font-display",style:{display:"flex",alignItems:"center",gap:6,padding:"5px 14px",borderRadius:7,fontSize:12,cursor:h||0===t.length?"not-allowed":"pointer",border:"none",background:h?"var(--muted)":"var(--amber)",color:h?"var(--muted-foreground)":"var(--amber-foreground)",opacity:0===t.length?.5:1,transition:"opacity .15s"},children:[h?(0,r.jsx)(a.A,{size:12,style:{animation:"spin 1s linear infinite"}}):(0,r.jsx)(o.A,{size:12}),h?"Generating…":v?"Regenerate":"Generate briefing"]})]}),t.length>0&&(0,r.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginBottom:"1.5rem"},children:t.map(e=>(0,r.jsxs)("a",{href:`/view/${(0,d.O0)(e.path)}`,className:"font-display",style:{display:"inline-flex",alignItems:"center",gap:5,padding:"3px 10px",borderRadius:999,fontSize:"0.7rem",background:"var(--muted)",color:"var(--muted-foreground)",textDecoration:"none",border:"1px solid var(--border)",transition:"color .15s"},onMouseEnter:e=>e.currentTarget.style.color="var(--foreground)",onMouseLeave:e=>e.currentTarget.style.color="var(--muted-foreground)",title:e.path,children:[(0,r.jsx)(l.A,{size:10}),m(e.path),(0,r.jsxs)("span",{style:{opacity:.5},children:[(0,r.jsx)(i.A,{size:9,style:{display:"inline",marginLeft:2}})," ",u(e.mtime)]})]},e.path))}),f&&(0,r.jsx)("div",{className:"font-display",style:{padding:"10px 14px",borderRadius:8,background:"color-mix(in srgb, var(--error) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--error) 30%, transparent)",color:"var(--error)",fontSize:12,marginBottom:"1rem"},children:f}),x?(0,r.jsxs)("div",{style:{background:"var(--card)",border:"1px solid var(--border)",borderRadius:10,padding:"18px 20px",position:"relative"},children:[h&&(0,r.jsx)("div",{style:{position:"absolute",top:12,right:14,width:6,height:6,borderRadius:"50%",background:"var(--amber)",animation:"pulse 1.2s ease-in-out infinite"}}),(0,r.jsx)("div",{dangerouslySetInnerHTML:{__html:x.replace(/^### (.+)$/gm,'<h3 style="font-size:.8rem;font-weight:600;color:var(--muted-foreground);text-transform:uppercase;letter-spacing:.06em;margin:1em 0 .3em">$1</h3>').replace(/^## (.+)$/gm,'<h2 style="font-size:.9rem;font-weight:700;color:var(--foreground);margin:1.2em 0 .4em">$1</h2>').replace(/^# (.+)$/gm,'<h1 style="font-size:1rem;font-weight:700;color:var(--foreground);margin:1.2em 0 .4em">$1</h1>').replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/`(.+?)`/g,'<code class="font-display" style="font-size:.82em;padding:1px 5px;border-radius:4px;background:var(--muted)">$1</code>').replace(/^[-*] (.+)$/gm,'<li style="margin:.2em 0;padding-left:.3em">$1</li>').replace(/(<li[^>]*>.*<\/li>\n?)+/g,e=>`<ul style="margin:.4em 0;padding-left:1.4em;list-style:disc">${e}</ul>`).replace(/\n{2,}/g,'</p><p style="margin:.5em 0;font-size:.85rem;line-height:1.7;color:var(--foreground)">').replace(/^(?!<[hulo])(.+)$/gm,'<p style="margin:.5em 0;font-size:.85rem;line-height:1.7;color:var(--foreground)">$1</p>')}})]}):h||v||!(t.length>0)?null:(0,r.jsxs)("div",{style:{border:"1px dashed var(--border)",borderRadius:10,padding:"2.5rem 1.5rem",textAlign:"center",color:"var(--muted-foreground)"},children:[(0,r.jsx)(o.A,{size:28,style:{margin:"0 auto 10px",opacity:.3,color:"var(--amber)"}}),(0,r.jsxs)("p",{className:"font-display",style:{fontSize:12},children:["Click ",(0,r.jsx)("strong",{style:{color:"var(--foreground)"},children:"Generate briefing"})," to summarize recent changes with AI."]})]}),(0,r.jsx)("style",{children:`
|
|
182
|
-
@keyframes spin { to { transform: rotate(360deg); } }
|
|
183
|
-
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.3; } }
|
|
184
|
-
`})]})}},56532:(e,t,s)=>{"use strict";s.d(t,{i:()=>n});var r=s(9339);let n=(0,r.createServerReference)("40bf5b9708b2392789ab4a52d289618fa86c7ae763",r.callServer,void 0,r.findSourceMapURL,"deleteFileAction")},59960:(e,t,s)=>{"use strict";s.d(t,{A:()=>n});var r=s(95155);function n({id:e,className:t="w-8 h-4"}){return(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 80 40",fill:"none",className:`${t} text-[var(--amber)]`,"aria-hidden":"true",children:[(0,r.jsxs)("defs",{children:[(0,r.jsxs)("linearGradient",{id:`grad-human-${e}`,x1:"35",y1:"20",x2:"5",y2:"20",gradientUnits:"userSpaceOnUse",children:[(0,r.jsx)("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:"0.8"}),(0,r.jsx)("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:"0.3"})]}),(0,r.jsxs)("linearGradient",{id:`grad-agent-${e}`,x1:"35",y1:"20",x2:"75",y2:"20",gradientUnits:"userSpaceOnUse",children:[(0,r.jsx)("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:"0.8"}),(0,r.jsx)("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:"1"})]})]}),(0,r.jsx)("path",{d:"M35,20 C25,35 8,35 8,20 C8,5 25,5 35,20",stroke:`url(#grad-human-${e})`,strokeWidth:"3",strokeDasharray:"2 4",strokeLinecap:"round"}),(0,r.jsx)("path",{d:"M35,20 C45,2 75,2 75,20 C75,38 45,38 35,20",stroke:`url(#grad-agent-${e})`,strokeWidth:"4.5",strokeLinecap:"round"}),(0,r.jsx)("path",{d:"M35,17.5 Q35,20 37.5,20 Q35,20 35,22.5 Q35,20 32.5,20 Q35,20 35,17.5 Z",fill:"#FEF3C7"})]})}},60392:e=>{function t(e){return Promise.resolve().then(()=>{var t=Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t})}t.keys=()=>[],t.resolve=t,t.id=60392,e.exports=t},63671:(e,t,s)=>{"use strict";s.d(t,{D:()=>n});var r=s(9339);let n=(0,r.createServerReference)("0008d30589fef4c58d54df4e165c7f5efdfe7ead5d",r.callServer,void 0,r.findSourceMapURL,"scanExampleFilesAction")},66709:(e,t,s)=>{"use strict";s.d(t,{A:()=>u});var r=s(95155),n=s(12115),a=s(92451),o=s(33210),l=s(6296),i=s(13545),d=s(12651),c=s(91053);function u({open:e,onClose:t,onDiscover:s,discovering:u,error:m}){let{t:x}=(0,c.Y)(),p=x.panels.agents,[h,g]=(0,n.useState)(""),[f,b]=(0,n.useState)(null);if(!e)return null;let v=async()=>{if(!h.trim()||u)return;b(null);let e=await s(h.trim());e&&b(e)},j=()=>{g(""),b(null),t()};return(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:j,children:(0,r.jsxs)("div",{className:"bg-popover border border-border rounded-xl shadow-lg w-full max-w-md mx-4 p-5",onClick:e=>e.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":p.a2aDiscover,children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsxs)("h3",{className:"text-sm font-semibold text-foreground flex items-center gap-2",children:[(0,r.jsx)(a.A,{size:15,className:"text-muted-foreground"}),p.a2aDiscover]}),(0,r.jsx)("button",{type:"button",onClick:j,className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":"Close",children:(0,r.jsx)(o.A,{size:14})})]}),(0,r.jsx)("p",{className:"text-2xs text-muted-foreground mb-3",children:p.a2aDiscoverHint}),(0,r.jsxs)("div",{className:"flex gap-2 mb-4",children:[(0,r.jsx)("input",{type:"url",value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{"Enter"===e.key&&v(),"Escape"===e.key&&t()},placeholder:p.a2aDiscoverPlaceholder,disabled:u,className:"flex-1 px-3 py-2 text-xs rounded-lg border border-border bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring disabled:opacity-50",autoFocus:!0}),(0,r.jsxs)("button",{type:"button",onClick:v,disabled:u||!h.trim(),className:"px-3 py-2 text-xs font-medium rounded-lg bg-foreground text-background hover:bg-foreground/90 disabled:opacity-50 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring flex items-center gap-1.5 shrink-0",children:[u&&(0,r.jsx)(l.A,{size:12,className:"animate-spin"}),u?p.a2aDiscovering:p.a2aDiscover]})]}),m&&!f&&(0,r.jsx)("div",{className:"rounded-lg border border-error/30 bg-error/5 px-3 py-2.5 mb-3",children:(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)(i.A,{size:14,className:"text-error mt-0.5 shrink-0"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs font-medium text-error",children:p.a2aDiscoverFailed}),(0,r.jsx)("p",{className:"text-2xs text-muted-foreground mt-0.5",children:p.a2aDiscoverFailedHint})]})]})}),f&&(0,r.jsx)("div",{className:"rounded-lg border border-success/30 bg-success/5 px-3 py-2.5",children:(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)(d.A,{size:14,className:"text-success mt-0.5 shrink-0"}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("p",{className:"text-xs font-medium text-success mb-1.5",children:p.a2aDiscoverSuccess}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)("p",{className:"text-xs font-medium text-foreground truncate",title:f.card.name,children:[f.card.name,(0,r.jsxs)("span",{className:"text-2xs text-muted-foreground ml-1.5",children:["v",f.card.version]})]}),(0,r.jsx)("p",{className:"text-2xs text-muted-foreground truncate",title:f.card.description,children:f.card.description}),f.card.skills.length>0&&(0,r.jsxs)("div",{className:"mt-1.5",children:[(0,r.jsxs)("p",{className:"text-2xs text-muted-foreground mb-1",children:[p.a2aSkills,":"]}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:f.card.skills.map(e=>(0,r.jsx)("span",{className:"text-2xs px-1.5 py-0.5 rounded bg-muted/80 text-muted-foreground border border-border/50",title:e.description,children:e.name},e.id))})]}),(0,r.jsxs)("p",{className:"text-2xs text-muted-foreground mt-1 truncate",title:f.endpoint,children:[p.a2aEndpoint,": ",f.endpoint]})]})]})]})})]})})}},66872:()=>{},68589:(e,t,s)=>{"use strict";s.d(t,{m:()=>n});let r=new Set(["write_file","create_file","batch_create_files","update_section","insert_after_heading","delete_file","rename_file","create_space"]);async function n(e,t,s){let n=e.getReader(),a=new TextDecoder,o="",l=[],i=new Map,d=null,c=null,u=Date.now();function m(){let e=l.map(e=>"text"===e.type?{type:"text",text:e.text}:"reasoning"===e.type?{type:"reasoning",text:e.text}:{...e});return{role:"assistant",content:e.filter(e=>"text"===e.type).map(e=>e.text).join(""),parts:e,timestamp:u}}try{for(;!s?.aborted;){let{done:e,value:s}=await n.read();if(e)break;let u=(o+=a.decode(s,{stream:!0})).split("\n");o=u.pop()??"";let x=!1;for(let e of u){let t,s=e.trim(),n=null;if(s.startsWith("data:")&&(n=s.slice(5).trim()),n){try{t=JSON.parse(n)}catch{continue}switch(t.type){case"text_delta":{let e=function(e){if(d===e){let e=l[l.length-1];if(e&&"text"===e.type)return e}let t={type:"text",text:""};return l.push(t),d=e,t}("text");e.text+=t.delta??"",x=!0;break}case"thinking_delta":c||(c={type:"reasoning",text:""},l.push(c),d=null),c.text+=t.delta??"",x=!0;break;case"tool_start":{let e=t.toolCallId,s=t.toolName,r=function(e,t){let s=i.get(e);return s||(s={type:"tool-call",toolCallId:e,toolName:t??"unknown",input:void 0,state:"pending"},i.set(e,s),l.push(s),d=null),s}(e,s);r.input=t.args,r.state="running",x=!0;break}case"tool_end":{let e=t.toolCallId,s=i.get(e);s&&(s.output=t.output??"",s.state=t.isError?"error":"done",x=!0,!t.isError&&r.has(s.toolName)&&window.dispatchEvent(new Event("mindos:files-changed")));break}case"error":{let e=t.message;l.push({type:"text",text:`
|
|
185
|
-
|
|
186
|
-
**Stream Error:** ${e}`}),d=null,x=!0}}}}x&&t(m())}}finally{n.releaseLock()}let x=!1;for(let e of i.values())("running"===e.state||"pending"===e.state)&&(e.state="error",e.output=e.output??"Stream ended before tool completed",x=!0);return x&&t(m()),m()}},70620:(e,t,s)=>{"use strict";s.d(t,{A:()=>u});var r=s(95155),n=s(12115),a=s(47650),o=s(21362),l=s(38798),i=s(94514),d=s(66088),c=s(91337);function u({dirPaths:e,value:t,onChange:s,rootLabel:u="Root"}){let[m,x]=(0,n.useState)(!1),[p,h]=(0,n.useState)(t),[g,f]=(0,n.useState)(null),b=(0,n.useRef)(null),v=(0,n.useRef)(null);(0,n.useEffect)(()=>{h(t)},[t]);let j=(0,n.useCallback)(()=>{if(!b.current)return;let e=b.current.getBoundingClientRect(),t=window.innerHeight-e.bottom,s=e.top,r=t<208&&s>t;f({top:r?e.top:e.bottom,left:e.left,width:e.width,flipUp:r})},[]);(0,n.useEffect)(()=>m?(j(),window.addEventListener("scroll",j,!0),window.addEventListener("resize",j),()=>{window.removeEventListener("scroll",j,!0),window.removeEventListener("resize",j)}):void f(null),[m,j]);let y=(0,n.useCallback)(()=>x(!1),[]);(0,n.useEffect)(()=>{if(!m)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),y())},t=e=>{let t=e.target;b.current?.contains(t)||v.current?.contains(t)||y()};return document.addEventListener("keydown",e),document.addEventListener("mousedown",t),()=>{document.removeEventListener("keydown",e),document.removeEventListener("mousedown",t)}},[m,y]);let N=(0,n.useMemo)(()=>{let t=p?p+"/":"";return e.filter(e=>{if(!e.startsWith(t))return!1;let s=e.slice(t.length);return s.length>0&&!s.includes("/")}).sort()},[e,p]),k=(0,n.useMemo)(()=>p?p.split("/"):[],[p]),w=e=>{if(e<0)h(""),s("");else{let t=k.slice(0,e+1).join("/");h(t),s(t)}},S=t?t.split("/").map(e=>(0,c.vr)(e)).join(" / "):"/ "+u,C=m&&g&&(0,a.createPortal)((0,r.jsxs)("div",{ref:v,className:"fixed z-[9999] rounded-lg border border-[var(--amber)] bg-card shadow-lg overflow-hidden flex flex-col",style:{left:g.left,width:g.width,maxHeight:200,...g.flipUp?{bottom:window.innerHeight-g.top+4}:{top:g.top+4}},children:[(0,r.jsxs)("div",{className:"flex items-center gap-0.5 px-3 py-1.5 bg-muted/30 border-b border-border overflow-x-auto text-xs shrink-0",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>w(-1),className:`shrink-0 px-1.5 py-0.5 rounded transition-colors ${""===p?"text-[var(--amber)] font-medium":"text-muted-foreground hover:text-foreground"}`,children:["/ ",u]}),k.map((e,t)=>(0,r.jsxs)("span",{className:"flex items-center gap-0.5 shrink-0",children:[(0,r.jsx)(o.A,{size:10,className:"text-muted-foreground/50"}),(0,r.jsx)("button",{type:"button",onClick:()=>w(t),className:`px-1.5 py-0.5 rounded transition-colors truncate max-w-[100px] ${t===k.length-1?"text-[var(--amber)] font-medium":"text-muted-foreground hover:text-foreground"}`,children:e})]},t))]}),N.length>0?(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:N.map(t=>{let n=t.split("/").pop()||t,a=e.some(e=>e.startsWith(t+"/"));return(0,r.jsxs)("button",{type:"button",onClick:()=>{h(t),s(t)},className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-muted/60 transition-colors",children:[(0,r.jsx)(l.A,{size:12,className:"shrink-0 text-[var(--amber)]"}),(0,r.jsx)("span",{className:"flex-1 text-left truncate",children:n}),a&&(0,r.jsx)(o.A,{size:11,className:"shrink-0 text-muted-foreground/40"})]},t)})}):(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground/50 text-center",children:"—"}),(0,r.jsx)("button",{type:"button",onClick:y,className:"w-full py-1.5 flex items-center justify-center gap-1 text-xs font-medium text-[var(--amber)] border-t border-border hover:bg-muted/30 transition-colors shrink-0",children:(0,r.jsx)(i.A,{size:12})})]}),document.body);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{ref:b,type:"button",onClick:()=>x(e=>!e),"aria-haspopup":"true","aria-expanded":m,className:`w-full flex items-center gap-2 px-3 py-2 text-sm rounded-lg border bg-background text-foreground transition-colors text-left focus-visible:ring-1 focus-visible:ring-ring outline-none ${m?"border-[var(--amber)]":"border-border hover:border-[var(--amber)]/40"}`,children:[(0,r.jsx)(l.A,{size:14,className:"shrink-0 text-[var(--amber)]"}),(0,r.jsx)("span",{className:"flex-1 truncate",children:S}),(0,r.jsx)(d.A,{size:14,className:`shrink-0 text-muted-foreground transition-transform duration-150 ${m?"rotate-180":""}`})]}),C]})}},70736:(e,t,s)=>{"use strict";s.d(t,{Y:()=>n});var r=s(9339);let n=(0,r.createServerReference)("40e908ae647e6fd15c1942e762e035026ad89704dd",r.callServer,void 0,r.findSourceMapURL,"undoDeleteAction")},76449:(e,t,s)=>{"use strict";s.d(t,{g:()=>r});let r=[{anchor:"files-panel",position:"right"},{anchor:"ask-button",position:"right"},{anchor:"agents-panel",position:"right"}]},77148:(e,t,s)=>{"use strict";s.d(t,{Un:()=>a});var r=s(12115);let n="mindos-renderer-state-change";function a(e,t,s){let a=`mindos-renderer:${e}:${t}`,o=(0,r.useRef)({key:a,raw:null,parsed:s});return o.current.key!==a&&(o.current={key:a,raw:null,parsed:s}),[(0,r.useSyncExternalStore)(e=>{let t=()=>e();return window.addEventListener("storage",t),window.addEventListener(n,t),()=>{window.removeEventListener("storage",t),window.removeEventListener(n,t)}},()=>{try{let e=localStorage.getItem(a);if(e===o.current.raw)return o.current.parsed;if(null===e)return o.current={key:a,raw:null,parsed:s},s;let t=JSON.parse(e);return o.current={key:a,raw:e,parsed:t},t}catch{return s}},()=>s),(0,r.useCallback)(e=>{try{let t=(()=>{try{let e=localStorage.getItem(a);return null!==e?JSON.parse(e):s}catch{return s}})(),r="function"==typeof e?e(t):e,n=JSON.stringify(r);localStorage.setItem(a,n),o.current={key:a,raw:n,parsed:r}}catch{}window.dispatchEvent(new Event(n))},[a,s])]}},78520:(e,t,s)=>{"use strict";s.d(t,{D4:()=>o,FB:()=>n,W8:()=>l,g4:()=>i,jQ:()=>c});let r="mindos:organize-history";function n(){try{let e=localStorage.getItem(r);if(!e)return[];return JSON.parse(e)}catch{return[]}}function a(e){try{localStorage.setItem(r,JSON.stringify(e.slice(0,50)))}catch{}}function o(e){let t=n();t.unshift(e);let s=t.slice(0,50);return a(s),s}function l(e,t){let s=n(),r=s.findIndex(t=>t.id===e);return r>=0&&(s[r]={...s[r],...t},a(s)),s}function i(){try{localStorage.removeItem(r)}catch{}}let d=0;function c(){return`org-${Date.now()}-${++d}`}},82125:(e,t,s)=>{"use strict";s.d(t,{A:()=>n,C:()=>r});let r=new Set(["INSTRUCTION.md","README.md","CONFIG.json","CHANGELOG.md"]),n=new Set(["TODO.md"])},84825:e=>{function t(e){return Promise.resolve().then(()=>{var t=Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t})}t.keys=()=>[],t.resolve=t,t.id=84825,e.exports=t},86343:(e,t,s)=>{"use strict";s.d(t,{default:()=>a});var r=s(95155),n=s(12115);class a extends n.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("[ErrorBoundary]",e,t.componentStack)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,r.jsx)("div",{className:"flex items-center justify-center min-h-[50vh] px-4",children:(0,r.jsxs)("div",{className:"text-center max-w-md",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold text-foreground mb-2",children:"Something went wrong"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:this.state.error?.message||"An unexpected error occurred."}),(0,r.jsx)("button",{onClick:()=>this.setState({hasError:!1,error:void 0}),className:"px-4 py-2 text-sm rounded-lg border border-border hover:bg-muted transition-colors",children:"Try again"})]})}):this.props.children}}},87500:(e,t,s)=>{"use strict";s.r(t),s.d(t,{TodoRenderer:()=>_});var r=s(95155),n=s(12115),a=s(92622),o=s(33210),l=s(57420),i=s(58515),d=s(16950),c=s(36201),u=s(51914),m=s(66088),x=s(21362),p=s(68459),h=s(84980);let g=/^##\s+(.+)/,f=/^#\s+/,b=/^#{3,6}\s+(.+)/,v=/^(\s*)- \[([ xX~])\]\s+(.*)$/,j=/`(P[012])`/,y=/`(\d{4}-\d{2}-\d{2}|\d{2}-\d{2})`/,N=/#([a-zA-Z\u4e00-\u9fff][\w\u4e00-\u9fff-]*)/g;function k(e,t){let s=[...e];return t(s),s.join("\n")}function w(e){let t=function(e){if(!e)return null;let t=new Date;return new Date(/^\d{2}-\d{2}$/.test(e)?`${t.getFullYear()}-${e}`:e)}(e);if(!t||isNaN(t.getTime()))return null;let s=new Date,r=new Date(s.getFullYear(),s.getMonth(),s.getDate()),n=(new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()-r.getTime())/864e5;return n<0?"overdue":0===n?"today":n<=3?"soon":"future"}let S={P0:{bg:"bg-red-500/10",text:"text-red-500",border:"border-red-500/20"},P1:{bg:"bg-amber-500/10",text:"text-amber-500",border:"border-amber-500/20"},P2:{bg:"bg-blue-500/10",text:"text-blue-500",border:"border-blue-500/20"}},C={overdue:{text:"text-red-500",bg:"bg-red-500/10"},today:{text:"text-amber-500",bg:"bg-amber-500/10"},soon:{text:"text-amber-400",bg:"bg-amber-400/5"},future:{text:"text-muted-foreground",bg:""}},A={TODAY:{dot:"bg-red-400",label:"text-red-400"},"This Week":{dot:"bg-orange-400",label:"text-orange-400"},Workflows:{dot:"bg-amber-400",label:"text-amber-400"},Backlog:{dot:"bg-blue-400",label:"text-blue-400"},Done:{dot:"bg-emerald-400",label:"text-emerald-400"},Maintenance:{dot:"bg-zinc-400",label:"text-zinc-400"}};function z(e,t){return e.reduce((e,s)=>e+ +(s.status===t)+z(s.children,t),0)}function E(e){return e.reduce((e,t)=>e+1+E(t.children),0)}function T({filters:e,onFilterChange:t,allTags:s,allPriorities:n,counts:l}){let i="all"!==e.priority||"all"!==e.tag||"all"!==e.status;return 0===s.length&&0===n.length?null:(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mb-4",children:[(0,r.jsx)(a.A,{size:12,className:"text-muted-foreground shrink-0"}),(0,r.jsxs)("div",{className:"flex items-center rounded-lg border border-border overflow-hidden text-xs",children:[(0,r.jsxs)("button",{onClick:()=>t({...e,status:"all"}),className:`px-2.5 py-1 transition-colors ${"all"===e.status?"bg-muted text-foreground font-medium":"text-muted-foreground hover:bg-muted/50"}`,children:["All ",l.total]}),(0,r.jsxs)("button",{onClick:()=>t({...e,status:"todo"}),className:`px-2.5 py-1 transition-colors border-l border-border ${"todo"===e.status?"bg-muted text-foreground font-medium":"text-muted-foreground hover:bg-muted/50"}`,children:["Todo ",l.todo]}),(0,r.jsxs)("button",{onClick:()=>t({...e,status:"in-progress"}),className:`px-2.5 py-1 transition-colors border-l border-border ${"in-progress"===e.status?"bg-amber-500/10 text-amber-500 font-medium":"text-muted-foreground hover:bg-muted/50"}`,children:["In Progress ",l.inProgress]}),(0,r.jsxs)("button",{onClick:()=>t({...e,status:"done"}),className:`px-2.5 py-1 transition-colors border-l border-border ${"done"===e.status?"bg-emerald-500/10 text-emerald-500 font-medium":"text-muted-foreground hover:bg-muted/50"}`,children:["Done ",l.done]})]}),n.length>0&&(0,r.jsx)("div",{className:"flex items-center gap-1",children:n.map(s=>{if(!s)return null;let n=S[s],a=e.priority===s;return(0,r.jsx)("button",{onClick:()=>t({...e,priority:a?"all":s}),className:`px-2 py-0.5 rounded text-xs font-mono font-medium border transition-colors ${a?`${n.bg} ${n.text} ${n.border}`:"border-transparent text-muted-foreground hover:bg-muted"}`,children:s},s)})}),s.length>0&&(0,r.jsx)("div",{className:"flex items-center gap-1",children:s.map(s=>{let n=e.tag===s;return(0,r.jsxs)("button",{onClick:()=>t({...e,tag:n?"all":s}),className:`px-2 py-0.5 rounded-full text-xs transition-colors ${n?"bg-[var(--amber)]/15 text-[var(--amber)]":"text-muted-foreground hover:bg-muted"}`,children:["#",s]},s)})}),i&&(0,r.jsxs)("button",{onClick:()=>t({priority:"all",tag:"all",status:"all"}),className:"flex items-center gap-1 px-2 py-0.5 rounded text-xs text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[(0,r.jsx)(o.A,{size:10})," Clear"]})]})}function $({priority:e}){if(!e)return null;let t=S[e];return(0,r.jsx)("span",{className:`inline-flex items-center px-1.5 py-0 rounded text-[10px] font-mono font-semibold leading-4 border shrink-0 ${t.bg} ${t.text} ${t.border}`,children:e})}function R({dateStr:e,status:t}){if(!e||"done"===t)return null;let s=w(e);if(!s)return null;let n=C[s];return(0,r.jsxs)("span",{className:`inline-flex items-center gap-0.5 px-1.5 py-0 rounded text-[10px] leading-4 shrink-0 ${n.text} ${n.bg}`,children:[(0,r.jsx)(l.A,{size:9}),e]})}function M({tag:e}){return(0,r.jsxs)("span",{className:"inline-flex items-center px-1.5 py-0 rounded-full text-[10px] leading-4 text-muted-foreground bg-muted/60 shrink-0",children:["#",e]})}function D({status:e,onClick:t}){return(0,r.jsxs)("button",{onClick:t,className:"shrink-0 transition-colors",title:"Click to cycle status",children:["done"===e&&(0,r.jsx)(i.A,{size:15,style:{color:"var(--amber)"}}),"in-progress"===e&&(0,r.jsx)(d.A,{size:15,className:"text-amber-500 fill-amber-500/20"}),"todo"===e&&(0,r.jsx)(c.A,{size:15,style:{color:"var(--muted-foreground)"}})]})}function I({text:e,status:t,onRename:s}){let[a,o]=(0,n.useState)(!1),[l,i]=(0,n.useState)(e),d=(0,n.useRef)(null);function c(){let t=l.trim();t&&t!==e?s(t):i(e),o(!1)}return((0,n.useEffect)(()=>{i(e)},[e]),(0,n.useEffect)(()=>{a&&d.current?.select()},[a]),a)?(0,r.jsx)("input",{ref:d,value:l,onChange:e=>i(e.target.value),onBlur:c,onKeyDown:t=>{"Enter"===t.key&&c(),"Escape"===t.key&&(i(e),o(!1))},className:"flex-1 bg-transparent border-b text-sm leading-relaxed outline-none min-w-0",style:{borderColor:"var(--amber)",color:"var(--foreground)"},onClick:e=>e.stopPropagation()}):(0,r.jsx)("span",{className:`flex-1 text-sm leading-relaxed cursor-text min-w-0 ${"done"===t?"line-through text-muted-foreground":"text-foreground"}`,onDoubleClick:()=>o(!0),title:"Double-click to edit",children:e})}function L({onAdd:e}){let[t,s]=(0,n.useState)(!1),[a,o]=(0,n.useState)(""),l=(0,n.useRef)(null);function i(){let t=a.trim();t&&e(t),o(""),s(!1)}return((0,n.useEffect)(()=>{t&&l.current?.focus()},[t]),t)?(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 mt-1",children:[(0,r.jsx)("span",{className:"w-[13px] shrink-0"}),(0,r.jsx)("span",{className:"shrink-0",style:{color:"var(--muted-foreground)"},children:(0,r.jsx)(c.A,{size:15})}),(0,r.jsx)("input",{ref:l,value:a,onChange:e=>o(e.target.value),onBlur:i,onKeyDown:e=>{"Enter"===e.key&&i(),"Escape"===e.key&&(o(""),s(!1))},placeholder:"New item… (supports `P0` `03-28` #tag)",className:"flex-1 bg-transparent border-b text-sm outline-none",style:{borderColor:"var(--amber)",color:"var(--foreground)"}})]}):(0,r.jsxs)("button",{onClick:()=>s(!0),className:"flex items-center gap-1.5 w-full px-3 py-1.5 rounded-lg text-xs transition-colors hover:bg-muted/60 mt-1",style:{color:"var(--muted-foreground)"},children:[(0,r.jsx)(u.A,{size:12}),(0,r.jsx)("span",{children:"Add item"})]})}function P(e,t){return("all"===t.status||e.status===t.status)&&("all"===t.priority||e.meta.priority===t.priority)&&("all"===t.tag||!!e.meta.tags.includes(t.tag))}function F({item:e,depth:t,filters:s,onCycleStatus:a,onRename:o,onDelete:l}){let[i,d]=(0,n.useState)(!0),c=e.children.length>0,u=P(e,s),h=e.children.some(e=>(function e(t,s){return!!P(t,s)||t.children.some(t=>e(t,s))})(e,s));if(("all"!==s.status||"all"!==s.priority||"all"!==s.tag)&&!u&&!h)return null;let g=w(e.meta.dueDate);return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:`group flex items-center gap-2 py-1.5 px-2 rounded-lg transition-colors hover:bg-muted/60 ${"done"===e.status?"opacity-45":""} ${"overdue"===g&&"done"!==e.status?"bg-red-500/[0.03]":""}`,style:{paddingLeft:`${8+20*t}px`},children:[c?(0,r.jsx)("button",{onClick:()=>d(e=>!e),className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors",children:i?(0,r.jsx)(m.A,{size:13}):(0,r.jsx)(x.A,{size:13})}):(0,r.jsx)("span",{className:"w-[13px] shrink-0"}),(0,r.jsx)(D,{status:e.status,onClick:()=>{var t;return a(e.lineIndex,"todo"===(t=e.status)?"in-progress":"in-progress"===t?"done":"todo")}}),(0,r.jsx)(I,{text:e.text,status:e.status,onRename:t=>o(e.lineIndex,t)}),(0,r.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,r.jsx)($,{priority:e.meta.priority}),(0,r.jsx)(R,{dateStr:e.meta.dueDate,status:e.status}),e.meta.tags.map(e=>(0,r.jsx)(M,{tag:e},e))]}),(0,r.jsx)("button",{onClick:()=>l(e.lineIndex),className:"shrink-0 opacity-0 group-hover:opacity-100 transition-opacity p-0.5 rounded hover:bg-destructive/10",style:{color:"var(--muted-foreground)"},title:"Delete item",children:(0,r.jsx)(p.A,{size:12})})]}),c&&i&&(0,r.jsx)("div",{children:e.children.map(e=>(0,r.jsx)(F,{item:e,depth:t+1,filters:s,onCycleStatus:a,onRename:o,onDelete:l},e.id))})]})}function O({name:e,meta:t,filters:s,defaultCollapsed:a,onCycleStatus:o,onRename:l,onDelete:i,onAdd:d}){let c,[u,p]=(0,n.useState)(a??!1),g=(c=Object.keys(A).find(t=>e.includes(t)))?A[c]:{dot:"bg-zinc-500",label:"text-zinc-400"},{items:f,lastLineIndex:b}=t,v=z(f,"done"),j=z(f,"in-progress"),y=E(f),N=e.includes("Done");return(0,r.jsxs)("div",{className:"border border-border rounded-xl overflow-hidden bg-card",children:[(0,r.jsxs)("button",{onClick:()=>p(e=>!e),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-muted/40 transition-colors",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:`w-2 h-2 rounded-full shrink-0 ${g.dot}`}),(0,r.jsx)("span",{className:`text-xs font-semibold uppercase tracking-wider ${g.label} font-display`,children:e}),(0,r.jsxs)("span",{className:"text-xs text-muted-foreground tabular-nums",children:[v,"/",y]}),j>0&&(0,r.jsxs)("span",{className:"flex items-center gap-0.5 text-[10px] text-amber-500",children:[(0,r.jsx)(h.A,{size:9})," ",j]})]}),u?(0,r.jsx)(x.A,{size:14,className:"text-muted-foreground"}):(0,r.jsx)(m.A,{size:14,className:"text-muted-foreground"})]}),(0,r.jsx)("div",{className:"h-0.5 bg-muted mx-4",children:(0,r.jsx)("div",{className:"h-full rounded-full transition-all duration-500",style:{width:y?`${v/y*100}%`:"0%",background:N?"var(--success, #22c55e)":"var(--amber)"}})}),!u&&(0,r.jsxs)("div",{className:"px-2 py-2",children:[f.map(e=>(0,r.jsx)(F,{item:e,depth:0,filters:s,onCycleStatus:o,onRename:l,onDelete:i},e.id)),0===f.length&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground px-4 py-2",children:"No items"}),!N&&(0,r.jsx)(L,{onAdd:e=>d(b,e)})]})]})}function _({content:e,saveAction:t}){let[s,a]=(0,n.useState)(e),[o,l]=(0,n.useState)({priority:"all",tag:"all",status:"all"}),{sections:i,lines:c,sectionOrder:u}=(0,n.useMemo)(()=>{let e,t,r,n,a,o,l;return e=s.split("\n"),t="General",r={},n=[],a=[],o=!1,l=!1,e.forEach((e,s)=>{if(!l){if(0===s&&"---"===e.trim()){o=!0;return}if(o){"---"===e.trim()&&(o=!1,l=!0);return}l=!0}if(f.test(e))return;let i=e.match(g);if(i){r[t=i[1].replace(/^[^\w\s\u4e00-\u9fff]+\s*/,"").trim()]||(r[t]={items:[],lastLineIndex:-1,headingLineIndex:s},n.push(t));return}if(b.test(e))return;let d=e.match(v);if(!d)return;let[,c,u,m]=d,x=Math.floor(c.length/2),p="~"===u?"in-progress":"x"===u.toLowerCase()?"done":"todo",{cleanText:h,meta:k}=function(e){let t,s=e,r=null,n=null,a=[],o=s.match(j);o&&(r=o[1],s=s.replace(j,"").trim());let l=s.match(y);l&&(n=l[1],s=s.replace(y,"").trim());let i=RegExp(N.source,"g");for(;null!==(t=i.exec(s));)a.push(t[1]);return a.length>0&&(s=s.replace(/#[a-zA-Z\u4e00-\u9fff][\w\u4e00-\u9fff-]*/g,"").trim()),{cleanText:s=s.replace(/\*\*(.*?)\*\*/g,"$1").trim(),meta:{priority:r,dueDate:n,tags:a}}}(m),w={id:`${s}`,text:h,rawText:m,status:p,indent:x,lineIndex:s,section:t,children:[],meta:k};for(;a.length>0&&a[a.length-1].indent>=x;)a.pop();r[t]||(r[t]={items:[],lastLineIndex:-1,headingLineIndex:-1},n.push(t)),a.length>0?a[a.length-1].children.push(w):r[t].items.push(w),r[t].lastLineIndex=Math.max(r[t].lastLineIndex,s),a.push(w)}),{sections:r,lines:e,sectionOrder:n}},[s]),m=(0,n.useMemo)(()=>Object.values(i).reduce((e,t)=>e+z(t.items,"done"),0),[i]),x=(0,n.useMemo)(()=>Object.values(i).reduce((e,t)=>e+z(t.items,"in-progress"),0),[i]),p=(0,n.useMemo)(()=>Object.values(i).reduce((e,t)=>e+E(t.items),0),[i]),h=p-m-x,w=(0,n.useMemo)(()=>(function(e){let t=new Set;for(let s of Object.values(e))!function e(s){for(let r of s){for(let e of r.meta.tags)t.add(e);e(r.children)}}(s.items);return[...t].sort()})(i),[i]),S=(0,n.useMemo)(()=>(function(e){let t=new Set;for(let s of Object.values(e))!function e(s){for(let r of s)r.meta.priority&&t.add(r.meta.priority),e(r.children)}(s.items);return["P0","P1","P2"].filter(e=>t.has(e))})(i),[i]),C=(0,n.useCallback)(async e=>{a(e),await t(e)},[t]),A=(0,n.useCallback)(async(e,t)=>{await C(k(c,s=>{s[e]=s[e].replace(/- \[[ xX~]\]/,`- [${"done"===t?"x":"in-progress"===t?"~":" "}]`)}))},[c,C]),$=(0,n.useCallback)(async(e,t)=>{await C(k(c,s=>{s[e]=s[e].replace(/(- \[[ xX~]\]\s*)(.*)$/,`$1${t}`)}))},[c,C]),R=(0,n.useCallback)(async e=>{await C(k(c,t=>{t.splice(e,1)}))},[c,C]),M=(0,n.useCallback)(async(e,t)=>{await C(k(c,s=>{let r=e<0?s.length:e+1;s.splice(r,0,`- [ ] ${t}`)}))},[c,C]),D=u.filter(e=>i[e]).map(e=>[e,i[e]]),I=p?Math.round(m/p*100):0;return(0,r.jsxs)("div",{className:"max-w-[900px] mx-auto xl:mr-[220px] px-0 py-2",children:[(0,r.jsx)("div",{className:"mb-5 flex items-center gap-4",children:(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,r.jsxs)("span",{className:"text-lg font-semibold font-display text-foreground tabular-nums",children:[I,"%"]}),(0,r.jsxs)("span",{className:"text-xs text-muted-foreground font-display",children:[m,"/",p," completed"]}),x>0&&(0,r.jsxs)("span",{className:"flex items-center gap-1 text-xs text-amber-500",children:[(0,r.jsx)(d.A,{size:8,className:"fill-amber-500/30"}),x," in progress"]})]}),(0,r.jsx)("div",{className:"mt-2 w-full max-w-xs h-1.5 bg-muted rounded-full overflow-hidden",children:(0,r.jsx)("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${I}%`,background:"var(--amber)"}})})]})}),(0,r.jsx)(T,{filters:o,onFilterChange:l,allTags:w,allPriorities:S,counts:{todo:h,inProgress:x,done:m,total:p}}),(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[D.map(([e,t])=>(0,r.jsx)(O,{name:e,meta:t,filters:o,defaultCollapsed:e.includes("Done"),onCycleStatus:A,onRename:$,onDelete:R,onAdd:M},e)),0===D.length&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"No TODO items found in this file."})]})]})}},87986:(e,t,s)=>{"use strict";s.r(t),s.d(t,{VideoRenderer:()=>a});var r=s(95155),n=s(12115);function a({filePath:e}){let t=`/api/file/raw?path=${encodeURIComponent(e)}`,s=e.split("/").pop()??"video",a=s.split(".").pop()?.toLowerCase()??"",[o,l]=(0,n.useState)(!1),[i,d]=(0,n.useState)(0),[c,u]=(0,n.useState)(null),[m,x]=(0,n.useState)(null),p=(0,n.useRef)(null);(0,n.useEffect)(()=>{fetch(t,{method:"HEAD"}).then(e=>{let t=e.headers.get("Content-Length");t&&u(parseInt(t,10))}).catch(()=>{})},[t]);let h=(0,n.useCallback)(()=>{let e=p.current;e&&x({w:e.videoWidth,h:e.videoHeight})},[]),g=(0,n.useCallback)(()=>{l(!1),d(e=>e+1)},[]);return(0,r.jsxs)("div",{className:"w-full flex flex-col gap-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 px-3 py-2 border-b border-border text-xs text-[var(--text-secondary)]",children:[m&&(0,r.jsxs)("span",{children:[m.w," x ",m.h]}),null!==c&&(0,r.jsx)("span",{children:c<1024?`${c} B`:c<1048576?`${(c/1024).toFixed(1)} KB`:`${(c/1048576).toFixed(1)} MB`}),(0,r.jsx)("span",{className:"uppercase opacity-60",children:a})]}),(0,r.jsx)("div",{className:"flex-1 min-h-[50vh] flex items-center justify-center bg-black rounded-b-lg overflow-hidden",children:o?(0,r.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm text-neutral-400",children:"Failed to load video"}),(0,r.jsx)("button",{onClick:g,className:"text-xs px-3 py-1.5 rounded-md bg-neutral-800 hover:bg-neutral-700 text-neutral-200 transition-colors",children:"Retry"})]}):(0,r.jsx)("video",{ref:p,controls:!0,preload:"metadata",className:"max-w-full max-h-[70vh]",onLoadedMetadata:h,onError:()=>l(!0),children:(0,r.jsx)("source",{src:t})},i)})]})}},88946:(e,t,s)=>{"use strict";s.r(t),s.d(t,{BacklinksRenderer:()=>m});var r=s(95155),n=s(12115),a=s(73321),o=s(48368),l=s(22164),i=s(91337),d=s(22356);function c(e){return e.split("/").pop()?.replace(/\.md$/,"")??e}function u({text:e}){let t=e.split(/(\[\[[^\]]+\]\]|\[[^\]]+\]\([^)]+\))/g);return(0,r.jsx)("span",{children:t.map((e,t)=>/^\[\[/.test(e)||/^\[/.test(e)?(0,r.jsx)("span",{style:{color:"var(--amber)",fontWeight:500},children:e},t):(0,r.jsx)("span",{children:e},t))})}function m({filePath:e}){let t=(0,a.useRouter)(),[s,m]=(0,n.useState)(null),[x,p]=(0,n.useState)(!0);if((0,n.useEffect)(()=>{p(!0),(0,d.n)(`/api/backlinks?path=${encodeURIComponent(e)}`).then(e=>{m(e),p(!1)}).catch(()=>p(!1))},[e]),x)return(0,r.jsx)("div",{className:"font-display",style:{padding:"3rem 1rem",textAlign:"center",fontSize:12,color:"var(--muted-foreground)"},children:"Scanning backlinks…"});let h=s??[];return(0,r.jsxs)("div",{style:{maxWidth:720,margin:"0 auto",padding:"1.5rem 0"},children:[(0,r.jsx)("div",{style:{marginBottom:"1.5rem",display:"flex",alignItems:"center",gap:8},children:(0,r.jsx)("span",{className:"font-display",style:{fontSize:11,color:"var(--muted-foreground)"},children:0===h.length?"No backlinks found":`${h.length} file${1===h.length?"":"s"} link here`})}),0===h.length?(0,r.jsxs)("div",{style:{border:"1px dashed var(--border)",borderRadius:10,padding:"2.5rem 1.5rem",textAlign:"center",color:"var(--muted-foreground)",fontSize:13},children:[(0,r.jsx)(o.A,{size:28,style:{margin:"0 auto 10px",opacity:.3}}),(0,r.jsxs)("p",{className:"font-display",style:{fontSize:12},children:["No other files link to ",(0,r.jsx)("strong",{style:{color:"var(--foreground)"},children:c(e)})," yet."]})]}):(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:h.map(({filePath:e,snippets:s})=>{let n,a=c(e),d=(n=e.split("/")).length>1?n.slice(0,-1).join("/"):"";return(0,r.jsxs)("div",{style:{background:"var(--card)",border:"1px solid var(--border)",borderRadius:10,overflow:"hidden",cursor:"pointer",transition:"border-color .15s"},onClick:()=>t.push("/view/"+(0,i.O0)(e)),onMouseEnter:e=>e.currentTarget.style.borderColor="rgba(200,135,58,0.4)",onMouseLeave:e=>e.currentTarget.style.borderColor="var(--border)",children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px",borderBottom:s.length>0?"1px solid var(--border)":"none",background:"var(--muted)"},children:[(0,r.jsx)(o.A,{size:13,style:{color:"var(--muted-foreground)",flexShrink:0}}),(0,r.jsx)("span",{style:{fontWeight:600,fontSize:"0.85rem",color:"var(--foreground)",flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a}),d&&(0,r.jsx)("span",{className:"font-display",style:{fontSize:"0.68rem",color:"var(--muted-foreground)",opacity:.6,flexShrink:0},children:d}),(0,r.jsx)(l.A,{size:11,style:{color:"var(--muted-foreground)",opacity:.5,flexShrink:0}})]}),s.map((e,t)=>(0,r.jsx)("div",{style:{padding:"8px 14px",borderBottom:t<s.length-1?"1px solid var(--border)":"none",background:"var(--background)"},children:e.split("\n").map((e,t)=>(0,r.jsx)("div",{className:"font-display",style:{fontSize:"0.72rem",color:"var(--muted-foreground)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:(0,r.jsx)(u,{text:e})},t))},t))]},e)})})]})}},91459:(e,t,s)=>{"use strict";s.d(t,{TooltipProvider:()=>a});var r=s(95155),n=s(32727);function a({delay:e=0,...t}){return(0,r.jsx)(n.B,{"data-slot":"tooltip-provider",delay:e,...t})}},92306:(e,t,s)=>{"use strict";s.r(t),s.d(t,{CsvRenderer:()=>z});var r=s(95155),n=s(12115),a=s(18837),o=s(37595),l=s(8434),i=s(1164),d=s(59386),c=s.n(d);function u(e,t){return c().unparse([e,...t])}let m=[{bg:"rgba(200,135,58,0.12)",text:"var(--amber)"},{bg:"rgba(122,173,128,0.12)",text:"var(--success)"},{bg:"rgba(138,180,216,0.12)",text:"#8ab4d8"},{bg:"rgba(200,160,216,0.12)",text:"#c8a0d8"},{bg:"rgba(200,96,96,0.12)",text:"#c86060"},{bg:"rgba(150,150,150,0.12)",text:"var(--muted-foreground)"}];function x(e){let t=0;for(let s=0;s<e.length;s++)t=31*t+e.charCodeAt(s)&65535;return m[t%m.length]}var p=s(77148),h=s(9921),g=s(66088),f=s(68459),b=s(51914);function v({value:e,onCommit:t}){let[s,a]=(0,n.useState)(!1),[o,l]=(0,n.useState)(e),i=(0,n.useRef)(null);function d(){a(!1),o!==e?t(o):l(e)}return((0,n.useEffect)(()=>{l(e)},[e]),(0,n.useEffect)(()=>{s&&i.current?.select()},[s]),s)?(0,r.jsx)("input",{ref:i,value:o,onChange:e=>l(e.target.value),onBlur:d,onKeyDown:t=>{"Enter"===t.key&&d(),"Escape"===t.key&&(l(e),a(!1))},className:"w-full bg-transparent outline-none text-sm",onClick:e=>e.stopPropagation(),style:{color:"var(--foreground)",borderBottom:"1px solid var(--amber)",minWidth:60}}):(0,r.jsx)("div",{className:"truncate text-sm cursor-text",style:{color:"var(--foreground)",minWidth:60},onClick:()=>a(!0),title:e,children:e||(0,r.jsx)("span",{style:{color:"var(--muted-foreground)",opacity:.3},children:"—"})})}function j({headers:e,visibleIndices:t,onAdd:s,onCancel:a}){let[o,l]=(0,n.useState)(()=>Array(e.length).fill(""));return(0,r.jsxs)("tr",{style:{background:"color-mix(in srgb, var(--amber) 6%, transparent)",borderTop:"1px solid var(--amber)"},children:[t.map((t,n)=>(0,r.jsx)("td",{className:"px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:(0,r.jsx)("input",{autoFocus:0===n,value:o[t],onChange:e=>{var s;return s=e.target.value,void l(e=>{let r=[...e];return r[t]=s,r})},onKeyDown:e=>{"Enter"===e.key&&s(o),"Escape"===e.key&&a()},placeholder:e[t],className:"w-full bg-transparent outline-none text-sm placeholder:opacity-30",style:{color:"var(--foreground)",borderBottom:"1px solid var(--border)"}})},t)),(0,r.jsx)("td",{className:"px-2 py-2",style:{borderBottom:"1px solid var(--border)"}})]})}function y({headers:e,rows:t,cfg:s,saveAction:a}){let[o,l]=(0,n.useState)(t),[i,d]=(0,n.useState)(!1);(0,n.useEffect)(()=>{l(t)},[t]);let c=(0,n.useMemo)(()=>e.map((e,t)=>t).filter(t=>!s.hiddenFields.includes(e[t])),[e,s.hiddenFields]),m=e.indexOf(s.sortField),x=(0,n.useMemo)(()=>{let e=[...o];return m>=0&&e.sort((e,t)=>{let r=e[m]??"",n=t[m]??"",a=parseFloat(r),o=parseFloat(n),l=isNaN(a)||isNaN(o)?r.localeCompare(n):a-o;return"asc"===s.sortDir?l:-l}),e},[o,m,s.sortDir]),p=e.indexOf(s.groupField),y=(0,n.useMemo)(()=>{if(p<0)return[{key:null,rows:x.map(e=>({row:e,orig:e}))}];let e=new Map;for(let t of x){let s=t[p]||"(empty)";e.has(s)||e.set(s,[]),e.get(s).push(t)}return[...e.entries()].map(([e,t])=>({key:e,rows:t.map(e=>({row:e,orig:e}))}))},[x,p]);async function N(t,s,r){let n=o.map(e=>e===t?e.map((e,t)=>t===s?r:e):e);l(n),await a(u(e,n))}async function k(t){let s=o.filter(e=>e!==t);l(s),await a(u(e,s))}async function w(t){let s=[...o,t];l(s),d(!1),await a(u(e,s))}let S={borderBottom:"1px solid var(--border)",fontSize:"0.72rem",letterSpacing:"0.05em",textTransform:"uppercase",color:"var(--muted-foreground)",fontWeight:600},C=0;return(0,r.jsxs)("div",{className:"rounded-xl overflow-hidden border",style:{borderColor:"var(--border)"},children:[(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"min-w-full text-sm border-collapse",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{style:{background:"var(--muted)"},children:[c.map(t=>(0,r.jsx)("th",{className:"px-4 py-2.5 text-left whitespace-nowrap",style:S,children:(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[e[t],s.sortField===e[t]&&("asc"===s.sortDir?(0,r.jsx)(h.A,{size:10,style:{color:"var(--amber)"}}):(0,r.jsx)(g.A,{size:10,style:{color:"var(--amber)"}}))]})},t)),(0,r.jsx)("th",{className:"w-8",style:{...S,background:"var(--muted)"}})]})}),(0,r.jsxs)("tbody",{children:[y.map((e,t)=>(0,r.jsxs)(n.Fragment,{children:[null!==e.key&&(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:c.length+1,className:"px-4 py-1.5",style:{background:"var(--accent)",borderBottom:"1px solid var(--border)",borderTop:"1px solid var(--border)"},children:(0,r.jsxs)("span",{className:"text-xs font-semibold font-display",style:{color:"var(--muted-foreground)"},children:[e.key," \xb7 ",e.rows.length]})})},`grp-${e.key}`),e.rows.map(({row:e,orig:t})=>{let s=C++;return(0,r.jsxs)("tr",{className:"group transition-colors",style:{background:s%2==0?"var(--background)":"var(--card)"},onMouseEnter:e=>e.currentTarget.style.background="var(--muted)",onMouseLeave:e=>e.currentTarget.style.background=s%2==0?"var(--background)":"var(--card)",children:[c.map(s=>(0,r.jsx)("td",{className:"px-4 py-2 max-w-xs",style:{borderBottom:"1px solid var(--border)"},children:(0,r.jsx)(v,{value:e[s]??"",onCommit:e=>N(t,s,e)})},s)),(0,r.jsx)("td",{className:"px-2 py-2",style:{borderBottom:"1px solid var(--border)"},children:(0,r.jsx)("button",{onClick:()=>k(t),className:"opacity-0 group-hover:opacity-100 transition-opacity p-1 rounded hover:bg-destructive/10",style:{color:"var(--muted-foreground)"},children:(0,r.jsx)(f.A,{size:12})})})]},s)})]},e.key??`section-${t}`)),i&&(0,r.jsx)(j,{headers:e,visibleIndices:c,onAdd:w,onCancel:()=>d(!1)})]})]})}),(0,r.jsxs)("div",{className:"px-4 py-2 flex items-center justify-between",style:{background:"var(--muted)",borderTop:"1px solid var(--border)"},children:[(0,r.jsxs)("span",{className:"text-xs font-display",style:{color:"var(--muted-foreground)"},children:[o.length," rows \xb7 ",e.length," cols"]}),i?(0,r.jsx)("button",{onClick:()=>d(!1),className:"text-xs px-2.5 py-1 rounded-md",style:{color:"var(--muted-foreground)"},children:"Cancel"}):(0,r.jsxs)("button",{onClick:()=>d(!0),className:"flex items-center gap-1 text-xs px-2.5 py-1 rounded-md",style:{color:"var(--amber)",background:"var(--amber-dim)"},children:[(0,r.jsx)(b.A,{size:12})," Add row"]})]})]})}function N({headers:e,rows:t,cfg:s}){let n=e.indexOf(s.titleField),a=e.indexOf(s.descField),o=e.indexOf(s.tagField);return(0,r.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:t.map((t,s)=>{let l=n>=0?t[n]:t[0]??"",i=a>=0?t[a]:"",d=o>=0?t[o]:"",c=d?x(d):null;return(0,r.jsxs)("div",{className:"rounded-xl border p-4 flex flex-col gap-2 hover:bg-muted/50 transition-colors",style:{borderColor:"var(--border)",background:"var(--card)"},children:[d&&c&&(0,r.jsx)("span",{className:"self-start text-xs px-2 py-0.5 rounded-full font-medium",style:{background:c.bg,color:c.text},children:d}),(0,r.jsx)("p",{className:"text-sm font-semibold leading-snug",style:{color:"var(--foreground)"},children:l}),i&&(0,r.jsx)("p",{className:"text-xs leading-relaxed line-clamp-3",style:{color:"var(--muted-foreground)"},children:i}),(0,r.jsx)("div",{className:"mt-1 flex flex-col gap-0.5",children:e.map((e,s)=>{if(s===n||s===a||s===o)return null;let l=t[s];return l?(0,r.jsxs)("div",{className:"flex items-baseline gap-1.5 text-xs",children:[(0,r.jsx)("span",{className:"font-display",style:{color:"var(--muted-foreground)",opacity:.6,fontSize:"0.68rem"},children:e}),(0,r.jsx)("span",{className:"truncate",style:{color:"var(--muted-foreground)"},children:l})]},s):null})})]},s)})})}function k({headers:e,rows:t,cfg:s,saveAction:a}){let[o,l]=(0,n.useState)(t),[i,d]=(0,n.useState)(null),[c,m]=(0,n.useState)(""),[p,h]=(0,n.useState)(!1);(0,n.useEffect)(()=>{l(t)},[t]);let g=e.indexOf(s.groupField),f=e.indexOf(s.titleField),v=e.indexOf(s.descField),{groups:j,groupKeys:y}=(0,n.useMemo)(()=>{let e=new Map;return o.forEach((t,s)=>{let r=(g>=0?t[g]:"")||"(empty)";e.has(r)||e.set(r,[]),e.get(r).push({row:t,origIdx:s})}),{groups:e,groupKeys:[...e.keys()]}},[o,g]);async function N(t,s){let r=o.map((e,r)=>{if(r!==t)return e;let n=[...e];return g>=0&&(n[g]=s),n});l(r),await a(u(e,r))}function k({group:t}){let s=j.get(t)??[],n=x(t),a=i===t;return(0,r.jsxs)("div",{className:"flex-shrink-0 w-64 flex flex-col gap-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-1 py-1.5",children:[(0,r.jsx)("span",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{background:n.text}}),(0,r.jsx)("span",{className:"text-xs font-semibold uppercase tracking-wider truncate font-display",style:{color:n.text},children:t}),(0,r.jsx)("span",{className:"text-xs ml-auto shrink-0",style:{color:"var(--muted-foreground)",opacity:.5},children:s.length})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl p-1.5 min-h-[80px] transition-colors",style:{background:a?"var(--amber-dim)":"var(--muted)",border:`1px solid ${a?"var(--amber)":"transparent"}`},onDragOver:e=>{e.preventDefault(),d(t)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||d(null)},onDrop:e=>{d(null);let s=parseInt(e.dataTransfer.getData("origIdx"));isNaN(s)||N(s,t)},children:[s.map(({row:t,origIdx:s})=>{let n=f>=0?t[f]:t[0]??"",a=v>=0?t[v]:"";return(0,r.jsxs)("div",{draggable:!0,onDragStart:e=>{e.dataTransfer.setData("origIdx",String(s)),d(null)},onDragEnd:()=>d(null),className:"rounded-lg border p-3 flex flex-col gap-1.5 cursor-grab active:cursor-grabbing hover:bg-muted/50 transition-colors",style:{borderColor:"var(--border)",background:"var(--card)"},children:[(0,r.jsx)("p",{className:"text-sm font-medium leading-snug",style:{color:"var(--foreground)"},children:n}),a&&(0,r.jsx)("p",{className:"text-xs leading-relaxed line-clamp-2",style:{color:"var(--muted-foreground)"},children:a}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1 mt-0.5",children:e.map((e,s)=>{if(s===g||s===f||s===v)return null;let n=t[s];return n?(0,r.jsxs)("span",{className:"text-2xs px-1.5 py-0.5 rounded font-display",style:{background:"var(--muted)",color:"var(--muted-foreground)"},children:[e,": ",n]},s):null})})]},s)}),0===s.length&&(0,r.jsx)("div",{className:"flex items-center justify-center h-12",children:(0,r.jsx)("span",{className:"text-xs",style:{color:"var(--muted-foreground)",opacity:.4},children:"Drop here"})})]})]})}return(0,r.jsxs)("div",{className:"flex gap-3 overflow-x-auto pb-3 items-start",children:[y.map(e=>(0,r.jsx)(k,{group:e},e)),(0,r.jsx)("div",{className:"flex-shrink-0 w-64",children:p?(0,r.jsxs)("div",{className:"rounded-xl border p-3 flex flex-col gap-2",style:{borderColor:"var(--border)",background:"var(--card)"},children:[(0,r.jsx)("input",{autoFocus:!0,value:c,onChange:e=>m(e.target.value),onKeyDown:e=>{"Enter"===e.key&&c.trim()&&(m(""),h(!1)),"Escape"===e.key&&(m(""),h(!1))},placeholder:"Column name…",className:"text-xs bg-transparent outline-none w-full font-display",style:{color:"var(--foreground)",borderBottom:"1px solid var(--amber)"}}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{onClick:()=>{m(""),h(!1)},className:"text-xs px-2 py-1 rounded font-display",style:{background:"var(--amber)",color:"var(--amber-foreground)"},children:"Create"}),(0,r.jsx)("button",{onClick:()=>{m(""),h(!1)},className:"text-xs px-2 py-1 rounded font-display",style:{color:"var(--muted-foreground)"},children:"Cancel"})]})]}):(0,r.jsxs)("button",{onClick:()=>h(!0),className:"flex items-center gap-1.5 text-xs px-3 py-2 rounded-xl border border-dashed w-full transition-colors hover:bg-muted font-display",style:{borderColor:"var(--border)",color:"var(--muted-foreground)"},children:[(0,r.jsx)(b.A,{size:12})," Add column"]})})]})}var w=s(33210),S=s(27996);function C({headers:e,cfg:t,view:s,onClose:n,onChange:a}){let o={color:"var(--muted-foreground)",fontSize:"0.72rem"};function l({label:t,value:s,onChange:n}){return(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"font-display",style:o,children:t}),(0,r.jsx)(S.A,{value:s,onChange:n,size:"sm",options:[{value:"",label:"— none —"},...e.map(e=>({value:e,label:e}))]})]})}return(0,r.jsxs)("div",{className:"absolute right-0 top-10 z-20 w-72 rounded-xl border shadow-xl p-4 flex flex-col gap-3",style:{background:"var(--card)",borderColor:"var(--border)"},children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("span",{className:"text-xs font-semibold uppercase tracking-wider",style:o,children:[s," settings"]}),(0,r.jsx)("button",{onClick:n,style:{color:"var(--muted-foreground)"},children:(0,r.jsx)(w.A,{size:13})})]}),"table"===s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"h-px",style:{background:"var(--border)"}}),(0,r.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wider",style:o,children:"Sort"}),(0,r.jsx)(l,{label:"Sort by",value:t.table.sortField,onChange:e=>a({...t,table:{...t.table,sortField:e}})}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{style:o,children:"Direction"}),(0,r.jsx)("div",{className:"flex rounded overflow-hidden border",style:{borderColor:"var(--border)"},children:["asc","desc"].map(e=>(0,r.jsx)("button",{onClick:()=>a({...t,table:{...t.table,sortDir:e}}),className:"px-3 py-1 text-xs transition-colors font-display",style:{fontSize:"0.72rem",background:t.table.sortDir===e?"var(--amber)":"var(--background)",color:t.table.sortDir===e?"var(--amber-foreground)":"var(--muted-foreground)"},children:e},e))})]}),(0,r.jsx)("div",{className:"h-px",style:{background:"var(--border)"}}),(0,r.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wider",style:o,children:"Group"}),(0,r.jsx)(l,{label:"Group by",value:t.table.groupField,onChange:e=>a({...t,table:{...t.table,groupField:e}})}),(0,r.jsx)("div",{className:"h-px",style:{background:"var(--border)"}}),(0,r.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wider",style:o,children:"Columns"}),(0,r.jsx)("div",{className:"flex flex-col gap-1.5",children:e.map(e=>{let s=t.table.hiddenFields.includes(e);return(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{style:o,children:e}),(0,r.jsx)("button",{onClick:()=>{let r=s?t.table.hiddenFields.filter(t=>t!==e):[...t.table.hiddenFields,e];a({...t,table:{...t.table,hiddenFields:r}})},className:"text-xs px-2 py-0.5 rounded transition-colors font-display",style:{background:s?"var(--muted)":"var(--amber-dim)",color:s?"var(--muted-foreground)":"var(--amber)"},children:s?"Hidden":"Visible"})]},e)})})]}),"gallery"===s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l,{label:"Title",value:t.gallery.titleField,onChange:e=>a({...t,gallery:{...t.gallery,titleField:e}})}),(0,r.jsx)(l,{label:"Description",value:t.gallery.descField,onChange:e=>a({...t,gallery:{...t.gallery,descField:e}})}),(0,r.jsx)(l,{label:"Tag / Badge",value:t.gallery.tagField,onChange:e=>a({...t,gallery:{...t.gallery,tagField:e}})})]}),"board"===s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l,{label:"Group by",value:t.board.groupField,onChange:e=>a({...t,board:{...t.board,groupField:e}})}),(0,r.jsx)(l,{label:"Card title",value:t.board.titleField,onChange:e=>a({...t,board:{...t.board,titleField:e}})}),(0,r.jsx)(l,{label:"Card desc",value:t.board.descField,onChange:e=>a({...t,board:{...t.board,descField:e}})})]})]})}let A=[{id:"table",icon:(0,r.jsx)(a.A,{size:13}),label:"Table"},{id:"gallery",icon:(0,r.jsx)(o.A,{size:13}),label:"Gallery"},{id:"board",icon:(0,r.jsx)(l.A,{size:13}),label:"Board"}];function z({filePath:e,content:t,saveAction:s}){let{headers:a,rows:o}=(0,n.useMemo)(()=>{let e;return{headers:(e=c().parse(t,{skipEmptyLines:!0}).data)[0]??[],rows:e.slice(1)}},[t]),l=(0,n.useMemo)(()=>({activeView:"table",table:{sortField:"",sortDir:"asc",groupField:"",hiddenFields:[]},gallery:{titleField:a[0]??"",descField:a[1]??"",tagField:a[2]??""},board:{groupField:a[a.length-1]??"",titleField:a[0]??"",descField:a[1]??""}}),[a]),[d,u]=(0,p.Un)("csv",e,l),[m,x]=(0,n.useState)(!1),h=(0,n.useCallback)(e=>{u(e)},[u]),g=d.activeView;return(0,r.jsxs)("div",{className:"max-w-[1100px] mx-auto px-0 py-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-4 relative",children:[(0,r.jsx)("div",{className:"flex items-center gap-0.5 p-1 rounded-lg",style:{background:"var(--muted)"},children:A.map(e=>(0,r.jsxs)("button",{onClick:()=>h({...d,activeView:e.id}),className:"flex items-center gap-1.5 px-3 py-1.5 rounded text-xs font-medium transition-colors font-display",style:{background:g===e.id?"var(--card)":"transparent",color:g===e.id?"var(--foreground)":"var(--muted-foreground)",boxShadow:g===e.id?"0 1px 3px rgba(0,0,0,0.1)":"none"},children:[e.icon,e.label]},e.id))}),(0,r.jsx)("div",{className:"flex-1"}),(0,r.jsxs)("span",{className:"text-xs font-display",style:{color:"var(--muted-foreground)",opacity:.5},children:[o.length," rows"]}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("button",{onClick:()=>x(e=>!e),className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs transition-colors",style:{background:m?"var(--accent)":"var(--muted)",color:m?"var(--foreground)":"var(--muted-foreground)"},title:"View settings",children:(0,r.jsx)(i.A,{size:13})}),m&&(0,r.jsx)(C,{headers:a,cfg:d,view:g,onClose:()=>x(!1),onChange:h})]})]}),"table"===g&&(0,r.jsx)(y,{headers:a,rows:o,cfg:d.table,saveAction:s}),"gallery"===g&&(0,r.jsx)(N,{headers:a,rows:o,cfg:d.gallery}),"board"===g&&(0,r.jsx)(k,{headers:a,rows:o,cfg:d.board,saveAction:s})]})}},92524:(e,t,s)=>{"use strict";s.d(t,{default:()=>n});var r=s(12115);function n(){return(0,r.useEffect)(()=>{!("u">typeof navigator&&/electron/i.test(navigator.userAgent))&&"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").catch(e=>{console.warn("[SW] Registration failed:",e)})},[]),null}},92950:(e,t,s)=>{"use strict";s.r(t),s.d(t,{GraphRenderer:()=>c});var r=s(95155),n=s(12115),a=s(73321),o=s(81750),l=s(61278);s(53255);var i=s(22356);let d=(0,n.memo)(function({data:e}){let t=(0,a.useRouter)(),{label:s,id:i,isCurrent:d,isOrphan:c,size:u=1}=e,m=(0,n.useCallback)(()=>{let e=i.split("/").map(encodeURIComponent).join("/");t.push("/view/"+e)},[i,t]),x=.8+Math.min(.1*u,1.2);return(0,r.jsxs)("div",{onClick:m,title:i,className:"group font-display",style:{fontSize:10*x,padding:`${4*x}px ${12*x}px`,borderRadius:999,cursor:"pointer",userSelect:"none",whiteSpace:"nowrap",maxWidth:240,overflow:"hidden",textOverflow:"ellipsis",opacity:c?.4:1,background:d?"var(--amber)":"var(--card)",color:d?"var(--amber-foreground)":"var(--foreground)",border:`1.5px solid ${d?"var(--amber)":"var(--border)"}`,boxShadow:d?"0 0 20px var(--amber-dim), 0 0 0 2px var(--amber-dim)":"0 2px 4px rgba(0,0,0,0.1)",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",zIndex:d?10:1},onMouseEnter:e=>{d||(e.currentTarget.style.borderColor="var(--amber)",e.currentTarget.style.background="var(--accent)")},onMouseLeave:e=>{d||(e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.background="var(--card)")},children:[(0,r.jsx)(o.h7,{type:"target",position:l.yX.Top,style:{opacity:0}}),s,(0,r.jsx)(o.h7,{type:"source",position:l.yX.Bottom,style:{opacity:0}})]})});function c({filePath:e}){let[t,s]=(0,n.useState)(null),[a,l]=(0,n.useState)(!0),[c,u]=(0,n.useState)("local"),[m,x]=(0,n.useState)(!1);(0,n.useEffect)(()=>{x(!0)},[]),(0,n.useEffect)(()=>{(0,i.n)("/api/graph").then(e=>{s(e),l(!1)}).catch(()=>l(!1))},[]);let p=(0,n.useMemo)(()=>{if(!t)return new Map;let e=new Map;for(let s of t.edges)e.set(s.source,(e.get(s.source)||0)+1),e.set(s.target,(e.get(s.target)||0)+1);return e},[t]),h=(0,n.useMemo)(()=>{if(!t)return null;let e=new Map;for(let s of t.edges)e.has(s.source)||e.set(s.source,new Set),e.has(s.target)||e.set(s.target,new Set),e.get(s.source).add(s.target),e.get(s.target).add(s.source);return e},[t]),{filteredNodes:g,filteredEdges:f}=(0,n.useMemo)(()=>{let s,r;if(!t)return{filteredNodes:[],filteredEdges:[]};if("global"===c)s=t.nodes,r=t.edges;else{let n=new Set,a=[{id:e,depth:0}];for(n.add(e);a.length>0;){let{id:e,depth:t}=a.shift();if(!(t>=2))for(let s of h?.get(e)??new Set)n.has(s)||(n.add(s),a.push({id:s,depth:t+1}))}let o=new Set((s=t.nodes.filter(e=>n.has(e.id))).map(e=>e.id));r=t.edges.filter(e=>o.has(e.source)&&o.has(e.target))}return{filteredNodes:s,filteredEdges:r}},[t,c,e,h]),b=(0,n.useMemo)(()=>{let e=new Set;for(let t of f)e.add(t.source),e.add(t.target);return e},[f]),{rfNodes:v,rfEdges:j}=(0,n.useMemo)(()=>{if(0===g.length)return{rfNodes:[],rfEdges:[]};let t=function(e,t,s){let r=e.length;if(0===r)return{};let n=(void 0)??(r>100?80:150),a=.6*Math.sqrt(108e4/Math.max(r,1)),o={};e.forEach((e,t)=>{let s=2*Math.PI*t/r,n=360*Math.random();o[e]={x:600+Math.cos(s)*n,y:450+Math.sin(s)*n}});let l={};for(let s=0;s<n;s++){let i=120*(1-s/n);for(let t of e)l[t]={x:0,y:0};for(let t=0;t<r;t++)for(let s=t+1;s<r;s++){let r=e[t],n=e[s],i=o[r].x-o[n].x,d=o[r].y-o[n].y,c=Math.sqrt(i*i+d*d||.01),u=a*a/c;l[r].x+=i/c*u,l[r].y+=d/c*u,l[n].x-=i/c*u,l[n].y-=d/c*u}for(let e of t){let t=e.source,s=e.target;if(!o[t]||!o[s])continue;let r=o[t].x-o[s].x,n=o[t].y-o[s].y,i=Math.sqrt(r*r+n*n||.01),d=i*i/a;l[t].x-=r/i*d,l[t].y-=n/i*d,l[s].x+=r/i*d,l[s].y+=n/i*d}for(let t of e){let e=o[t].x-600,s=o[t].y-450,r=Math.sqrt(e*e+s*s)||.01,n=.05*r;l[t].x-=e/r*n,l[t].y-=s/r*n}for(let t of e){let e=l[t],s=Math.sqrt(e.x*e.x+e.y*e.y)||.01;o[t].x+=e.x/s*Math.min(s,i),o[t].y+=e.y/s*Math.min(s,i),o[t].x=Math.max(0,Math.min(1200,o[t].x)),o[t].y=Math.max(0,Math.min(900,o[t].y))}}return o}(g.map(e=>e.id),f);return{rfNodes:g.map(s=>({id:s.id,type:"wiki",position:t[s.id]??{x:0,y:0},data:{label:s.label,id:s.id,isCurrent:s.id===e,isOrphan:!b.has(s.id),size:p.get(s.id)||1}})),rfEdges:f.map((t,s)=>{let r=t.source===e||t.target===e;return{id:`e-${s}`,source:t.source,target:t.target,type:"default",markerEnd:{type:"arrowclosed",color:r?"var(--amber)":"var(--border)"},style:{stroke:r?"var(--amber)":"var(--border)",strokeWidth:r?1.5:1,opacity:r?.8:.4},animated:r}})}},[g,f,e,b,p]),y=(0,n.useMemo)(()=>({wiki:d}),[]);return!m||a?(0,r.jsx)("div",{style:{width:"100%",height:"calc(100vh - 160px)",minHeight:400,borderRadius:12,background:"var(--muted)",border:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,r.jsx)("span",{className:"font-display",style:{color:"var(--muted-foreground)",fontSize:12},children:a?"Building graph…":"Loading…"})}):(0,r.jsxs)("div",{style:{width:"100%",position:"relative",zIndex:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:10,flexWrap:"wrap"},children:[(0,r.jsxs)("span",{className:"font-display",style:{fontSize:11,color:"var(--muted-foreground)"},children:[g.length," nodes \xb7 ",f.length," edges"]}),(0,r.jsx)("div",{style:{display:"flex",gap:2,padding:3,borderRadius:8,background:"var(--muted)"},children:[{id:"local",label:"Local"},{id:"global",label:"Global"}].map(e=>(0,r.jsx)("button",{onClick:()=>u(e.id),className:"font-display",style:{padding:"3px 12px",borderRadius:5,fontSize:11,cursor:"pointer",border:"none",outline:"none",background:c===e.id?"var(--card)":"transparent",color:c===e.id?"var(--foreground)":"var(--muted-foreground)",boxShadow:c===e.id?"0 1px 3px rgba(0,0,0,0.1)":"none",transition:"all 0.1s"},children:e.label},e.id))})]}),(0,r.jsx)("div",{style:{width:"100%",height:"calc(100vh - 160px)",minHeight:400},children:(0,r.jsxs)(o.Gc,{nodes:v,edges:j,nodeTypes:y,fitView:!0,fitViewOptions:{padding:.15},proOptions:{hideAttribution:!0},style:{background:"var(--background)",borderRadius:12,border:"1px solid var(--border)"},children:[(0,r.jsx)(o.VS,{color:"var(--border)",gap:24,size:1,variant:o._5.Dots}),(0,r.jsx)(o.H2,{showInteractive:!1}),(0,r.jsx)(o.of,{nodeColor:e=>e.data?.isCurrent?"var(--amber)":"var(--muted-foreground)"})]})})]})}},93042:(e,t,s)=>{"use strict";s.d(t,{default:()=>a});var r=s(12115),n=s(91053);function a({ssrLocale:e}){return(0,r.useEffect)(()=>n.D.getState()._init(e),[e]),null}}},e=>{e.O(0,[7513,3295,4913,3862,4237,8409,9286,7266,8658,9274,2549,1053,8252,6636,8441,3794,7358],()=>e(e.s=48755)),_N_E=e.O()}]);
|